diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-16 21:07:29 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-16 21:07:29 -0400 |
commit | b1e2ca00ce7375ffcbe5e927135c8892036e6bd6 (patch) | |
tree | 07ce453261f6493de7c901cfd8b4f0d9af85556d /app/Api/ProjectApi.php | |
parent | 4514bc1d4b4abff23902e46da76e70f13a3647eb (diff) |
Rename Api classes
Diffstat (limited to 'app/Api/ProjectApi.php')
-rw-r--r-- | app/Api/ProjectApi.php | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/app/Api/ProjectApi.php b/app/Api/ProjectApi.php new file mode 100644 index 00000000..70cd8d16 --- /dev/null +++ b/app/Api/ProjectApi.php @@ -0,0 +1,87 @@ +<?php + +namespace Kanboard\Api; + +/** + * Project API controller + * + * @package Kanboard\Api + * @author Frederic Guillot + */ +class ProjectApi extends BaseApi +{ + public function getProjectById($project_id) + { + $this->checkProjectPermission($project_id); + return $this->formatProject($this->project->getById($project_id)); + } + + public function getProjectByName($name) + { + return $this->formatProject($this->project->getByName($name)); + } + + public function getAllProjects() + { + return $this->formatProjects($this->project->getAll()); + } + + public function removeProject($project_id) + { + return $this->project->remove($project_id); + } + + public function enableProject($project_id) + { + return $this->project->enable($project_id); + } + + public function disableProject($project_id) + { + return $this->project->disable($project_id); + } + + public function enableProjectPublicAccess($project_id) + { + return $this->project->enablePublicAccess($project_id); + } + + public function disableProjectPublicAccess($project_id) + { + return $this->project->disablePublicAccess($project_id); + } + + public function getProjectActivities(array $project_ids) + { + return $this->helper->projectActivity->getProjectsEvents($project_ids); + } + + public function getProjectActivity($project_id) + { + $this->checkProjectPermission($project_id); + return $this->helper->projectActivity->getProjectEvents($project_id); + } + + public function createProject($name, $description = null) + { + $values = array( + 'name' => $name, + 'description' => $description + ); + + list($valid, ) = $this->projectValidator->validateCreation($values); + return $valid ? $this->project->create($values) : false; + } + + public function updateProject($id, $name, $description = null) + { + $values = array( + 'id' => $id, + 'name' => $name, + 'description' => $description + ); + + list($valid, ) = $this->projectValidator->validateModification($values); + return $valid && $this->project->update($values); + } +} |