diff --git a/codepot/src/codepot/controllers/issue.php b/codepot/src/codepot/controllers/issue.php index c77a9773..7c3319cb 100644 --- a/codepot/src/codepot/controllers/issue.php +++ b/codepot/src/codepot/controllers/issue.php @@ -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']}"; } diff --git a/codepot/src/codepot/models/issuemodel.php b/codepot/src/codepot/models/issuemodel.php index 7bd704e9..2c11dbae 100644 --- a/codepot/src/codepot/models/issuemodel.php +++ b/codepot/src/codepot/models/issuemodel.php @@ -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); + } } ?>