2014-11-23 20:13:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Model;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Task permission model
|
|
|
|
*
|
|
|
|
* @package model
|
|
|
|
* @author Frederic Guillot
|
|
|
|
*/
|
|
|
|
class TaskPermission extends Base
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Return true if the user can remove a task
|
|
|
|
*
|
|
|
|
* Regular users can't remove tasks from other people
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function canRemoveTask(array $task)
|
|
|
|
{
|
2015-01-16 14:23:05 +01:00
|
|
|
if ($this->userSession->isAdmin() || $this->projectPermission->isManager($task['project_id'], $this->userSession->getId())) {
|
2014-11-23 20:13:38 +01:00
|
|
|
return true;
|
|
|
|
}
|
2015-01-16 14:23:05 +01:00
|
|
|
else if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
|
2014-11-23 20:13:38 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|