diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/acl.php | 4 | ||||
-rw-r--r-- | models/project.php | 53 |
2 files changed, 55 insertions, 2 deletions
diff --git a/models/acl.php b/models/acl.php index 9667a1e3..4ab3ff41 100644 --- a/models/acl.php +++ b/models/acl.php @@ -32,8 +32,8 @@ class Acl extends Base */ private $user_actions = array( 'app' => array('index'), - 'board' => array('index', 'show', 'assign', 'assigntask', 'save'), - 'project' => array('tasks', 'index', 'forbidden'), + 'board' => array('index', 'show', 'assign', 'assigntask', 'save', 'check'), + 'project' => array('tasks', 'index', 'forbidden', 'search'), 'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'confirmclose', 'open', 'confirmopen', 'description', 'duplicate'), 'comment' => array('save', 'confirm', 'remove', 'update', 'edit'), 'user' => array('index', 'edit', 'update', 'forbidden', 'logout', 'index', 'unlinkgoogle'), diff --git a/models/project.php b/models/project.php index b9def0be..680d0750 100644 --- a/models/project.php +++ b/models/project.php @@ -6,9 +6,11 @@ require_once __DIR__.'/base.php'; require_once __DIR__.'/acl.php'; require_once __DIR__.'/board.php'; require_once __DIR__.'/task.php'; +require_once __DIR__.'/../events/task_modification.php'; use \SimpleValidator\Validator; use \SimpleValidator\Validators; +use \Event\TaskModification; /** * Project model @@ -390,6 +392,36 @@ class Project extends Base } /** + * Check if the project have been modified + * + * @access public + * @param integer $project_id Project id + * @param integer $timestamp Timestamp + * @return bool + */ + public function isModifiedSince($project_id, $timestamp) + { + return (bool) $this->db->table(self::TABLE) + ->eq('id', $project_id) + ->gt('last_modified', $timestamp) + ->count(); + } + + /** + * Update modification date + * + * @access public + * @param integer $project_id Project id + * @return bool + */ + public function updateModificationDate($project_id) + { + return $this->db->table(self::TABLE)->eq('id', $project_id)->save(array( + 'last_modified' => time() + )); + } + + /** * Update a project * * @access public @@ -508,4 +540,25 @@ class Project extends Base $v->getErrors() ); } + + /** + * Attach events + * + * @access public + */ + public function attachEvents() + { + $events = array( + Task::EVENT_UPDATE, + Task::EVENT_CREATE, + Task::EVENT_CLOSE, + Task::EVENT_OPEN, + ); + + $listener = new TaskModification($this); + + foreach ($events as $event_name) { + $this->event->attach($event_name, $listener); + } + } } |