summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-09-08 14:02:30 +0200
committerLukas Reschke <lukas@owncloud.com>2015-09-08 14:02:30 +0200
commita7f132a9641e532ad68a60f916166d7ece685318 (patch)
treeedc37d3112dd0c97ba82f1e0e7f74fc1d1d3f870 /apps/provisioning_api
parent75f939b8fed56503b652f2a8b836f8c82ead40ab (diff)
downloadnextcloud-server-a7f132a9641e532ad68a60f916166d7ece685318.tar.gz
nextcloud-server-a7f132a9641e532ad68a60f916166d7ece685318.zip
Add proper PHPDoc
Makes my IDE happier when going through that file.
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/apps.php29
-rw-r--r--apps/provisioning_api/lib/groups.php39
-rw-r--r--apps/provisioning_api/lib/users.php56
3 files changed, 100 insertions, 24 deletions
diff --git a/apps/provisioning_api/lib/apps.php b/apps/provisioning_api/lib/apps.php
index 168f6f3cad8..80f6e7049c6 100644
--- a/apps/provisioning_api/lib/apps.php
+++ b/apps/provisioning_api/lib/apps.php
@@ -31,13 +31,20 @@ class Apps {
/** @var \OCP\App\IAppManager */
private $appManager;
+ /**
+ * @param \OCP\App\IAppManager $appManager
+ */
public function __construct(\OCP\App\IAppManager $appManager) {
$this->appManager = $appManager;
}
- public function getApps($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function getApps($parameters) {
$apps = OC_App::listAllApps();
- $list = array();
+ $list = [];
foreach($apps as $app) {
$list[] = $app['id'];
}
@@ -62,7 +69,11 @@ class Apps {
}
}
- public function getAppInfo($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function getAppInfo($parameters) {
$app = $parameters['appid'];
$info = \OCP\App::getAppInfo($app);
if(!is_null($info)) {
@@ -72,13 +83,21 @@ class Apps {
}
}
- public function enable($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function enable($parameters) {
$app = $parameters['appid'];
$this->appManager->enableApp($app);
return new OC_OCS_Result(null, 100);
}
- public function disable($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function disable($parameters) {
$app = $parameters['appid'];
$this->appManager->disableApp($app);
return new OC_OCS_Result(null, 100);
diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php
index 91d0a1c6342..c6fbe12b34e 100644
--- a/apps/provisioning_api/lib/groups.php
+++ b/apps/provisioning_api/lib/groups.php
@@ -25,6 +25,8 @@ namespace OCA\Provisioning_API;
use \OC_OCS_Result;
use \OC_SubAdmin;
+use OCP\IGroup;
+use OCP\IUser;
class Groups{
@@ -39,21 +41,25 @@ class Groups{
* @param \OCP\IUserSession $userSession
*/
public function __construct(\OCP\IGroupManager $groupManager,
- \OCP\IUserSession $userSession) {
+ \OCP\IUserSession $userSession) {
$this->groupManager = $groupManager;
$this->userSession = $userSession;
}
/**
* returns a list of groups
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
- public function getGroups($parameters){
+ public function getGroups($parameters) {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
$limit = !empty($_GET['limit']) ? $_GET['limit'] : null;
$offset = !empty($_GET['offset']) ? $_GET['offset'] : null;
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function($group) {
+ /** @var IGroup $group */
return $group->getGID();
}, $groups);
@@ -62,6 +68,9 @@ class Groups{
/**
* returns an array of users in the group specified
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
public function getGroup($parameters) {
// Check if user is logged in
@@ -71,7 +80,7 @@ class Groups{
}
// Check the group exists
- if(!$this->groupManager->groupExists($parameters['groupid'])){
+ if(!$this->groupManager->groupExists($parameters['groupid'])) {
return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested group could not be found');
}
// Check subadmin has access to this group
@@ -79,6 +88,7 @@ class Groups{
|| in_array($parameters['groupid'], \OC_SubAdmin::getSubAdminsGroups($user->getUID()))){
$users = $this->groupManager->get($parameters['groupid'])->getUsers();
$users = array_map(function($user) {
+ /** @var IUser $user */
return $user->getUID();
}, $users);
$users = array_values($users);
@@ -90,23 +100,30 @@ class Groups{
/**
* creates a new group
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
- public function addGroup($parameters){
+ public function addGroup($parameters) {
// Validate name
- $groupid = isset($_POST['groupid']) ? $_POST['groupid'] : '';
- if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $groupid ) || empty($groupid)){
+ $groupId = isset($_POST['groupid']) ? $_POST['groupid'] : '';
+ if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $groupId ) || empty($groupId)){
\OCP\Util::writeLog('provisioning_api', 'Attempt made to create group using invalid characters.', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Invalid group name');
}
// Check if it exists
- if($this->groupManager->groupExists($groupid)){
+ if($this->groupManager->groupExists($groupId)){
return new OC_OCS_Result(null, 102);
}
- $this->groupManager->createGroup($groupid);
+ $this->groupManager->createGroup($groupId);
return new OC_OCS_Result(null, 100);
}
- public function deleteGroup($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function deleteGroup($parameters) {
// Check it exists
if(!$this->groupManager->groupExists($parameters['groupid'])){
return new OC_OCS_Result(null, 101);
@@ -118,6 +135,10 @@ class Groups{
}
}
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
public function getSubAdminsOfGroup($parameters) {
$group = $parameters['groupid'];
// Check group exists
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php
index f5b201a55ea..617e50b403e 100644
--- a/apps/provisioning_api/lib/users.php
+++ b/apps/provisioning_api/lib/users.php
@@ -48,10 +48,10 @@ class Users {
* @param \OCP\IUserManager $userManager
* @param \OCP\IConfig $config
* @param \OCP\IGroupManager $groupManager
- * @param \OCP\IUserSession $user
+ * @param \OCP\IUserSession $userSession
*/
public function __construct(\OCP\IUserManager $userManager,
- \OCP\IConfig $config,
+ \OCP\IConfig $config,
\OCP\IGroupManager $groupManager,
\OCP\IUserSession $userSession) {
$this->userManager = $userManager;
@@ -62,8 +62,10 @@ class Users {
/**
* returns a list of users
+ *
+ * @return OC_OCS_Result
*/
- public function getUsers(){
+ public function getUsers() {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
$limit = !empty($_GET['limit']) ? $_GET['limit'] : null;
$offset = !empty($_GET['offset']) ? $_GET['offset'] : null;
@@ -76,7 +78,10 @@ class Users {
]);
}
- public function addUser(){
+ /**
+ * @return OC_OCS_Result
+ */
+ public function addUser() {
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
if($this->userManager->userExists($userId)) {
@@ -96,6 +101,9 @@ class Users {
/**
* gets user info
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
public function getUser($parameters){
$userId = $parameters['userid'];
@@ -150,8 +158,11 @@ class Users {
/**
* edit users
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
- public function editUser($parameters){
+ public function editUser($parameters) {
$userId = $parameters['userid'];
// Check if user is logged in
@@ -230,7 +241,11 @@ class Users {
return new OC_OCS_Result(null, 100);
}
- public function deleteUser($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function deleteUser($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
if ($user === null) {
@@ -253,6 +268,10 @@ class Users {
}
}
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
public function getUsersGroups($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
@@ -286,7 +305,11 @@ class Users {
}
- public function addToGroup($parameters){
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
+ public function addToGroup($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
if ($user === null) {
@@ -317,6 +340,10 @@ class Users {
return new OC_OCS_Result(null, 100);
}
+ /**
+ * @param array $parameters
+ * @return OC_OCS_Result
+ */
public function removeFromGroup($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
@@ -362,6 +389,9 @@ class Users {
/**
* Creates a subadmin
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
public function addSubAdmin($parameters) {
$group = $_POST['groupid'];
@@ -393,6 +423,9 @@ class Users {
/**
* Removes a subadmin from a group
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
public function removeSubAdmin($parameters) {
$group = $parameters['_delete']['groupid'];
@@ -414,7 +447,10 @@ class Users {
}
/**
- * @Get the groups a user is a subadmin of
+ * Get the groups a user is a subadmin of
+ *
+ * @param array $parameters
+ * @return OC_OCS_Result
*/
public function getUserSubAdminGroups($parameters) {
$user = $parameters['userid'];
@@ -431,8 +467,8 @@ class Users {
}
/**
- * @param $userId
- * @param $data
+ * @param string $userId
+ * @param array $data
* @return mixed
* @throws \OCP\Files\NotFoundException
*/