summaryrefslogtreecommitdiff
path: root/app/Api/Project.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-05-23 21:44:33 -0400
committerFrederic Guillot <fred@kanboard.net>2015-05-23 21:44:33 -0400
commite32f26d048249b84166542d6442efdf202ff44fd (patch)
tree1868c5e83cec5ea8b821ad8a2036543aa37e5adb /app/Api/Project.php
parentc9ba525bab06eff76b1d5fb8701848d0e3990122 (diff)
API refactoring
Diffstat (limited to 'app/Api/Project.php')
-rw-r--r--app/Api/Project.php85
1 files changed, 85 insertions, 0 deletions
diff --git a/app/Api/Project.php b/app/Api/Project.php
new file mode 100644
index 00000000..2451cd9c
--- /dev/null
+++ b/app/Api/Project.php
@@ -0,0 +1,85 @@
+<?php
+
+namespace Api;
+
+/**
+ * Project API controller
+ *
+ * @package api
+ * @author Frederic Guillot
+ */
+class Project extends Base
+{
+ public function getProjectById($project_id)
+ {
+ return $this->project->getById($project_id);
+ }
+
+ public function getProjectByName($name)
+ {
+ return $this->project->getByName($name);
+ }
+
+ public function getAllProjects()
+ {
+ return $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->projectActivity->getProjects($project_ids);
+ }
+
+ public function getProjectActivity($project_id)
+ {
+ return $this->projectActivity->getProject($project_id);
+ }
+
+ public function createProject($name, $description = null)
+ {
+ $values = array(
+ 'name' => $name,
+ 'description' => $description
+ );
+
+ list($valid,) = $this->project->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->project->validateModification($values);
+ return $valid && $this->project->update($values);
+ }
+}