added Issue::isCreatedBy()
This commit is contained in:
		| @ -661,8 +661,7 @@ DEPRECATED | ||||
| 			// TODO: add a project option to accept an issue from anonymous users, logged-in users or just members. | ||||
| 			else if (!$login['sysadmin?'] &&  | ||||
| 			         $this->projects->projectHasMember($projectid, $login['id']) === FALSE && | ||||
| 			         ($issue = $this->issues->get ($login['id'], $project, $issueid)) !== FALSE && | ||||
| 			         $login['id'] != $issue->createdby) | ||||
| 			         $this->issues->isCreatedBy($projectid, $issueid, $login['id']) === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - not a member nor a creator - {$login['id']}"; | ||||
| 			} | ||||
| @ -793,8 +792,7 @@ DEPRECATED | ||||
| 			// TODO: add a project option to accept an issue from anonymous users, logged-in users or just members. | ||||
| 			else if (!$login['sysadmin?'] &&  | ||||
| 			         $this->projects->projectHasMember($projectid, $login['id']) === FALSE && | ||||
| 			         ($issue = $this->issues->get ($login['id'], $project, $issueid)) !== FALSE && | ||||
| 			         $login['id'] != $issue->createdby) | ||||
| 			         $this->issues->isCreatedBy($projectid, $issueid, $login['id']) === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - not a member nor a creator - {$login['id']}"; | ||||
| 			} | ||||
| @ -875,8 +873,7 @@ DEPRECATED | ||||
| 			// TODO: add a project option to accept an issue from anonymous users, logged-in users or just members. | ||||
| 			else if (!$login['sysadmin?'] &&  | ||||
| 			         $this->projects->projectHasMember($projectid, $login['id']) === FALSE && | ||||
| 			         ($issue = $this->issues->get ($login['id'], $project, $issueid)) !== FALSE && | ||||
| 			         $login['id'] != $issue->createdby) | ||||
| 			         $this->issues->isCreatedBy($projectid, $issueid, $login['id']) === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - not a member nor a creator - {$login['id']}"; | ||||
| 			} | ||||
|  | ||||
| @ -899,6 +899,32 @@ class IssueModel extends Model | ||||
| 		restore_error_handler (); | ||||
| 		return $x; | ||||
| 	} | ||||
|  | ||||
| 	function isCreatedBy ($projectid, $issueid, $userid) | ||||
| 	{ | ||||
| 		$this->db->trans_begin (); // manual transaction. not using trans_start(). | ||||
|  | ||||
| 		$this->db->where ('projectid', $projectod); | ||||
| 		$this->db->where ('id', $issueid); | ||||
| 		$query = $this->db->get ('issue'); | ||||
| 		if ($this->db->trans_status() === FALSE)  | ||||
| 		{ | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$result = $query->result (); | ||||
| 		if (empty($result)) | ||||
| 		{ | ||||
| 			$this->db->trans_commit (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->trans_commit (); | ||||
|  | ||||
| 		$issue = &$result[0]; | ||||
| 		return ($issue->created_by == $userid); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user