diff --git a/include/class.task.php b/include/class.task.php index acefedda76d947209305f32f63bd7675f0f1e316..fdacbc4eba1e5d730ff931a2d0d394caf783c76e 100644 --- a/include/class.task.php +++ b/include/class.task.php @@ -204,8 +204,24 @@ class TaskModel extends VerySimpleModel { return $this->setFlag(self::ISOPEN); } - function isAssigned() { - return ($this->isOpen() && ($this->getStaffId() || $this->getTeamId())); + function isAssigned($to=null) { + if (!$this->isOpen()) + return false; + + if (is_null($to)) + return ($this->getStaffId() || $this->getTeamId()); + + switch (true) { + case $to instanceof Staff: + return ($to->getId() == $this->getStaffId() || + $to->isTeamMember($this->getTeamId())); + break; + case $to instanceof Team: + return ($to->getId() == $this->getTeamId()); + break; + } + + return false; } function isOverdue() { diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php index 54a2821c996b9fa4c3ef64ce8546aea735076825..b529436954730871070a75d1c3d553e3b45b5474 100644 --- a/include/class.thread_actions.php +++ b/include/class.thread_actions.php @@ -138,6 +138,13 @@ class TEA_EditThreadEntry extends ThreadEntryAction { && ($role = $thisstaff->getRole($T->getDeptId(), $T->isAssigned($thisstaff))) && $role->hasPerm(ThreadEntry::PERM_EDIT) ) + || ($T instanceof Task + && $T->getDept()->getManagerId() == $thisstaff->getId() + ) + || ($T instanceof Task + && ($role = $thisstaff->getRole($T->getDeptId(), $T->isAssigned($thisstaff))) + && $role->hasPerm(ThreadEntry::PERM_EDIT) + ) ); }