Project

General

Profile

Patch #4071 » mailer.patch

Oxan -, 2009-10-21 16:18

View differences:

redmine-dev/app/models/mail_handler.rb 2009-10-21 16:15:25.000000000 +0200
118 118
  
119 119
  # Adds a note to an existing issue
120 120
  def receive_issue_update(issue_id)
121
    # Get issue
122
    issue = Issue.find_by_id(issue_id)
123

  
124
    # Get project
125
    project = Project.find_by_identifier(get_keyword(:project))
126
    project = issue.project if project.nil?
127
   
128
    # Get other properties
121 129
    status =  (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
122
    
130
    priority = (get_keyword(:priority) && Enumeration.find_by_opt_and_name('IPRI', get_keyword(:priority)))
131
    category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category)))
132
    tracker = (get_keyword(:tracker) && project.trackers.find_by_name(get_keyword(:tracker)))
133
    target = (get_keyword(:target) && project.versions.find_by_name(get_keyword(:target)))
134
    doneratio = (get_keyword(:done))
135

  
123 136
    issue = Issue.find_by_id(issue_id)
124 137
    return unless issue
125 138
    # check permission
......
129 142
    # add the note
130 143
    journal = issue.init_journal(user, plain_text_body)
131 144
    add_attachments(issue)
145

  
146
    # status
132 147
    # check workflow
133 148
    if status && issue.new_statuses_allowed_to(user).include?(status)
134 149
      issue.status = status
135 150
    end
151

  
152
    # priority, category, tracker, project, target version and done ratio
153
    issue.priority = priority if priority
154
    issue.category = category if category
155
    issue.tracker = tracker if tracker
156
    issue.project = project
157
    issue.done_ratio = doneratio if doneratio
158

  
159
    # target version
160
    if target.nil? && get_keyword(:target) == 'none'
161
       issue.fixed_version = nil
162
    elsif !target.nil?
163
       issue.fixed_version = target
164
    end  
165

  
166
    # custom fields
167
    issue.custom_field_values = issue.available_custom_fields.inject({}) do |h, c|
168
      if value = get_keyword(c.name, :override => true)
169
        h[c.id] = value
170
      end
171
      h
172
    end
173

  
174
    # save issue
136 175
    issue.save!
137 176
    logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
138 177
    Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
(1-1/2)