added Issue::isCreatedBy()

This commit is contained in:
hyung-hwan 2015-12-30 13:17:06 +00:00
parent 866a78c908
commit 0ccf0428b2
2 changed files with 29 additions and 6 deletions

View File

@ -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']}";
}

View File

@ -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);
}
}
?>