Add proper PHPDoc

Makes my IDE happier when going through that file.
This commit is contained in:
Lukas Reschke 2015-09-08 14:02:30 +02:00
parent 75f939b8fe
commit a7f132a964
3 changed files with 100 additions and 24 deletions

View File

@ -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);

View File

@ -25,6 +25,8 @@ namespace OCA\Provisioning_API;
use \OC_OCS_Result;
use \OC_SubAdmin;
use OCP\IGroup;
use OCP\IUser;
class Groups{
@ -46,14 +48,18 @@ class Groups{
/**
* 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

View File

@ -48,7 +48,7 @@ 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,
@ -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
*/