Merge pull request #18895 from owncloud/make-code-analyzers-happier

Add proper PHPDoc
This commit is contained in:
Morris Jobke 2015-09-09 23:40:30 +02:00
commit f67a691215
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;
}
/**
* @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,6 +69,10 @@ class Apps {
}
}
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function getAppInfo($parameters) {
$app = $parameters['appid'];
$info = \OCP\App::getAppInfo($app);
@ -72,12 +83,20 @@ class Apps {
}
}
/**
* @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);
}
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function disable($parameters) {
$app = $parameters['appid'];
$this->appManager->disableApp($app);

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,6 +48,9 @@ class Groups{
/**
* returns a list of groups
*
* @param array $parameters
* @return OC_OCS_Result
*/
public function getGroups($parameters) {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
@ -54,6 +59,7 @@ class Groups{
$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
@ -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,22 +100,29 @@ class Groups{
/**
* creates a new group
*
* @param array $parameters
* @return OC_OCS_Result
*/
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);
}
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function deleteGroup($parameters) {
// Check it exists
if(!$this->groupManager->groupExists($parameters['groupid'])){
@ -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,6 +62,8 @@ class Users {
/**
* returns a list of users
*
* @return OC_OCS_Result
*/
public function getUsers() {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
@ -76,6 +78,9 @@ class Users {
]);
}
/**
* @return OC_OCS_Result
*/
public function addUser() {
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
@ -96,6 +101,9 @@ class Users {
/**
* gets user info
*
* @param array $parameters
* @return OC_OCS_Result
*/
public function getUser($parameters){
$userId = $parameters['userid'];
@ -150,6 +158,9 @@ class Users {
/**
* edit users
*
* @param array $parameters
* @return OC_OCS_Result
*/
public function editUser($parameters) {
$userId = $parameters['userid'];
@ -230,6 +241,10 @@ class Users {
return new OC_OCS_Result(null, 100);
}
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function deleteUser($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
@ -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,6 +305,10 @@ class Users {
}
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function addToGroup($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
@ -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
*/