added issue owner change notification
This commit is contained in:
		| @ -698,6 +698,8 @@ class Issue extends Controller | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				$issue_url_base = $this->input->post('issue_url_base'); | ||||
|  | ||||
| 				$change = new stdClass(); | ||||
| 				$change->type = $this->input->post('issue_change_type'); | ||||
| 				$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->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(); | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					$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 | ||||
| 						); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @ -269,7 +269,7 @@ class IssueModel extends Model | ||||
| 		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(); | ||||
|  | ||||
| @ -289,29 +289,29 @@ class IssueModel extends Model | ||||
| 		$maxsno = (empty($result) || $result[0] == NULL)? 0: $result[0]->maxsno; | ||||
| 		$newsno = $maxsno + 1; | ||||
|  | ||||
| 		if ($change->comment == '' || $disallow_state_change) | ||||
| 		$this->db->where ('projectid', $project->id); | ||||
| 		$this->db->where ('id', $id); | ||||
| 		$this->db->where ('sno', $maxsno); | ||||
| 		$this->db->select('type,status,owner,priority'); | ||||
| 		$query = $this->db->get ('issue_change'); | ||||
| 		if ($this->db->trans_status() === FALSE)  | ||||
| 		{ | ||||
| 			$this->db->where ('projectid', $project->id); | ||||
| 			$this->db->where ('id', $id); | ||||
| 			$this->db->where ('sno', $maxsno); | ||||
| 			$this->db->select('type,status,owner,priority'); | ||||
| 			$query = $this->db->get ('issue_change'); | ||||
| 			if ($this->db->trans_status() === FALSE)  | ||||
| 			{ | ||||
| 				$this->errmsg = $this->db->_error_message();  | ||||
| 				$this->db->trans_rollback (); | ||||
| 				return FALSE; | ||||
| 			} | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 			$result = $query->result(); | ||||
| 			if (!empty($result)) | ||||
| 		$result = $query->result(); | ||||
| 		if (!empty($result)) | ||||
| 		{ | ||||
| 			$old_state = $result[0]; | ||||
| 			if ($change->comment == '' || $disallow_state_change) | ||||
| 			{ | ||||
| 				$c = $result[0]; | ||||
|  | ||||
| 				if ($c->type == $change->type && | ||||
| 				    $c->status == $change->status && | ||||
| 				    $c->owner == $change->owner && | ||||
| 				    $c->priority == $change->priority) | ||||
| 				if ($old_state->type == $change->type && | ||||
| 				    $old_state->status == $change->status && | ||||
| 				    $old_state->owner == $change->owner && | ||||
| 				    $old_state->priority == $change->priority) | ||||
| 				{ | ||||
| 					if ($change->comment == '') | ||||
| 					{ | ||||
|  | ||||
| @ -694,6 +694,8 @@ $(function () { | ||||
|  | ||||
| 						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_status', $('#issue_change_status').val()); | ||||
| 						form_data.append ('issue_change_priority', $('#issue_change_priority').val()); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user