added issue owner change notification

This commit is contained in:
hyung-hwan 2016-08-01 07:23:43 +00:00
parent 5527dd04b1
commit 3244ff8f07
3 changed files with 39 additions and 21 deletions

View File

@ -698,6 +698,8 @@ class Issue extends Controller
} }
else else
{ {
$issue_url_base = $this->input->post('issue_url_base');
$change = new stdClass(); $change = new stdClass();
$change->type = $this->input->post('issue_change_type'); $change->type = $this->input->post('issue_change_type');
$change->status = $this->input->post('issue_change_status'); $change->status = $this->input->post('issue_change_status');
@ -705,13 +707,27 @@ class Issue extends Controller
$change->priority = $this->input->post('issue_change_priority'); $change->priority = $this->input->post('issue_change_priority');
$change->comment = $this->input->post('issue_change_comment'); $change->comment = $this->input->post('issue_change_comment');
if ($this->issues->change ($login['id'], $project, $issueid, $change, $is_nonmember) === FALSE) if ($this->issues->change ($login['id'], $project, $issueid, $change, $is_nonmember, $old_state) === FALSE)
{ {
$status = 'error - ' . $this->issues->getErrorMessage(); $status = 'error - ' . $this->issues->getErrorMessage();
} }
else else
{ {
$status = 'ok'; $status = 'ok';
if (CODEPOT_ISSUE_NOTIFICATION && $old_state->owner != $change->owner)
{
// TODO: message localization
$email_subject = sprintf (
'Issue #%d - owner change from %s to %s in %s',
$issueid, $old_state->owner, $change->owner, $projectid
);
$email_message = $issue_url_base . '/' . $this->converter->AsciiToHex((string)$issueid) . "\r\n" . $email_subject;
$this->projects->emailMessageToMembers (
$projectid, $this->login, $email_subject, $email_message
);
}
} }
} }
} }

View File

@ -269,7 +269,7 @@ class IssueModel extends Model
return $result[0]; return $result[0];
} }
function change ($userid, $project, $id, $change, $disallow_state_change) function change ($userid, $project, $id, $change, $disallow_state_change, &$old_state)
{ {
$now = codepot_nowtodbdate(); $now = codepot_nowtodbdate();
@ -289,8 +289,6 @@ class IssueModel extends Model
$maxsno = (empty($result) || $result[0] == NULL)? 0: $result[0]->maxsno; $maxsno = (empty($result) || $result[0] == NULL)? 0: $result[0]->maxsno;
$newsno = $maxsno + 1; $newsno = $maxsno + 1;
if ($change->comment == '' || $disallow_state_change)
{
$this->db->where ('projectid', $project->id); $this->db->where ('projectid', $project->id);
$this->db->where ('id', $id); $this->db->where ('id', $id);
$this->db->where ('sno', $maxsno); $this->db->where ('sno', $maxsno);
@ -306,12 +304,14 @@ class IssueModel extends Model
$result = $query->result(); $result = $query->result();
if (!empty($result)) if (!empty($result))
{ {
$c = $result[0]; $old_state = $result[0];
if ($change->comment == '' || $disallow_state_change)
{
if ($c->type == $change->type && if ($old_state->type == $change->type &&
$c->status == $change->status && $old_state->status == $change->status &&
$c->owner == $change->owner && $old_state->owner == $change->owner &&
$c->priority == $change->priority) $old_state->priority == $change->priority)
{ {
if ($change->comment == '') if ($change->comment == '')
{ {

View File

@ -694,6 +694,8 @@ $(function () {
var form_data = new FormData(); var form_data = new FormData();
form_data.append ('issue_url_base', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/issue/show/{$project->id}"; ?>'));
form_data.append ('issue_change_type', $('#issue_change_type').val()); form_data.append ('issue_change_type', $('#issue_change_type').val());
form_data.append ('issue_change_status', $('#issue_change_status').val()); form_data.append ('issue_change_status', $('#issue_change_status').val());
form_data.append ('issue_change_priority', $('#issue_change_priority').val()); form_data.append ('issue_change_priority', $('#issue_change_priority').val());