summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Litzbarski <tili2@gmx.de>2015-09-18 14:18:34 +0000
committerTimo Litzbarski <tili2@gmx.de>2015-09-18 14:18:34 +0000
commit1fa72295f20aa9794f1b33dfde95960c34d85366 (patch)
tree01727142fb5196192c468d1ec3970c92e3a063be
parent55ca46ad754b87991e5cc4c4bc26657b19d37830 (diff)
User-Api: add getMyPorjects (#1233)
-rw-r--r--ChangeLog2
-rw-r--r--app/Api/Base.php1
-rw-r--r--app/Api/Me.php5
-rw-r--r--app/Model/Project.php12
-rw-r--r--doc/api-json-rpc.markdown49
5 files changed, 68 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a2cbb77..c17e25c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,7 +7,7 @@ New features:
* Add swimlane description
* New plugin system (alpha)
* Added Bahasa Indonesia translation
-* Api changes: new getMyOverdueTasks, new getOverdueTasksByProject, allow getProjectActivity for user-api
+* Api changes: new getMyOverdueTasks, new getOverdueTasksByProject, allow getProjectActivity for user-api, new GetMyProjects
Breaking changes:
diff --git a/app/Api/Base.php b/app/Api/Base.php
index fe78d99d..c1be1878 100644
--- a/app/Api/Base.php
+++ b/app/Api/Base.php
@@ -20,6 +20,7 @@ abstract class Base extends \Core\Base
'createMyPrivateProject',
'getMyProjectsList',
'getMyOverdueTasks',
+ 'getMyProjects',
);
private $both_allowed_procedures = array(
diff --git a/app/Api/Me.php b/app/Api/Me.php
index bc721c09..ff317557 100644
--- a/app/Api/Me.php
+++ b/app/Api/Me.php
@@ -57,4 +57,9 @@ class Me extends Base
{
return $this->taskFinder->getOverdueTasksByUser($this->userSession->getId());
}
+
+ public function getMyProjects()
+ {
+ return $this->formatProjects($this->project->getAllByIds($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId())));
+ }
}
diff --git a/app/Model/Project.php b/app/Model/Project.php
index 52500820..6e4cfcfd 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -172,6 +172,18 @@ class Project extends Base
{
return $this->db->table(self::TABLE)->asc('name')->findAll();
}
+
+ /**
+ * Get all projects with given Ids
+ *
+ * @access public
+ * @param integer[] $project_ids Projects id
+ * @return array
+ */
+ public function getAllByIds($project_ids)
+ {
+ return $this->db->table(self::TABLE)->in('id', $project_ids)->asc('name')->findAll();
+ }
/**
* Get all project ids
diff --git a/doc/api-json-rpc.markdown b/doc/api-json-rpc.markdown
index 23371669..a7a8b546 100644
--- a/doc/api-json-rpc.markdown
+++ b/doc/api-json-rpc.markdown
@@ -69,6 +69,7 @@ If there is an authentication error, you will receive the HTTP status code `401
- getMyActivityStream
- createMyPrivateProject
- getMyProjectsList
+- getMyProjects
- getTimezone
- getVersion
- getDefaultTaskColor
@@ -4462,3 +4463,51 @@ Response example:
]
}
```
+
+### getMyProjects
+
+- Purpose: **Get projects of connected user with full details**
+- Parameters:
+ - **none**
+- Result on success: **List of projects with details**
+- Result on failure: **false**
+
+Request example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "method": "getmyProjects",
+ "id": 2134420212
+}
+```
+
+Response example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "id": 2134420212,
+ "result": [
+ {
+ "id": "1",
+ "name": "API test",
+ "is_active": "1",
+ "token": "",
+ "last_modified": "1436119570",
+ "is_public": "0",
+ "is_private": "0",
+ "is_everybody_allowed": "0",
+ "default_swimlane": "Default swimlane",
+ "show_default_swimlane": "1",
+ "description": null,
+ "identifier": "",
+ "url": {
+ "board": "http:\/\/127.0.0.1:8000\/?controller=board&action=show&project_id=1",
+ "calendar": "http:\/\/127.0.0.1:8000\/?controller=calendar&action=show&project_id=1",
+ "list": "http:\/\/127.0.0.1:8000\/?controller=listing&action=show&project_id=1"
+ }
+ }
+ ]
+}
+``` \ No newline at end of file