Completed
Pull Request — master (#3233)
by Christoph
14:36
created
apps/files_sharing/lib/ShareBackend/Folder.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -29,79 +29,79 @@
 block discarded – undo
29 29
 
30 30
 class Folder extends File implements \OCP\Share_Backend_Collection {
31 31
 
32
-	/**
33
-	 * get shared parents
34
-	 *
35
-	 * @param int $itemSource item source ID
36
-	 * @param string $shareWith with whom should the item be shared
37
-	 * @param string $owner owner of the item
38
-	 * @return array with shares
39
-	 */
40
-	public function getParents($itemSource, $shareWith = null, $owner = null) {
41
-		$result = array();
42
-		$parent = $this->getParentId($itemSource);
43
-		while ($parent) {
44
-			$shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner);
45
-			if ($shares) {
46
-				foreach ($shares as $share) {
47
-					$name = basename($share['path']);
48
-					$share['collection']['path'] = $name;
49
-					$share['collection']['item_type'] = 'folder';
50
-					$share['file_path'] = $name;
51
-					$displayNameOwner = \OCP\User::getDisplayName($share['uid_owner']);
52
-					$displayNameShareWith = \OCP\User::getDisplayName($share['share_with']);
53
-					$share['displayname_owner'] = ($displayNameOwner) ? $displayNameOwner : $share['uid_owner'];
54
-					$share['share_with_displayname'] = ($displayNameShareWith) ? $displayNameShareWith : $share['uid_owner'];
32
+    /**
33
+     * get shared parents
34
+     *
35
+     * @param int $itemSource item source ID
36
+     * @param string $shareWith with whom should the item be shared
37
+     * @param string $owner owner of the item
38
+     * @return array with shares
39
+     */
40
+    public function getParents($itemSource, $shareWith = null, $owner = null) {
41
+        $result = array();
42
+        $parent = $this->getParentId($itemSource);
43
+        while ($parent) {
44
+            $shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner);
45
+            if ($shares) {
46
+                foreach ($shares as $share) {
47
+                    $name = basename($share['path']);
48
+                    $share['collection']['path'] = $name;
49
+                    $share['collection']['item_type'] = 'folder';
50
+                    $share['file_path'] = $name;
51
+                    $displayNameOwner = \OCP\User::getDisplayName($share['uid_owner']);
52
+                    $displayNameShareWith = \OCP\User::getDisplayName($share['share_with']);
53
+                    $share['displayname_owner'] = ($displayNameOwner) ? $displayNameOwner : $share['uid_owner'];
54
+                    $share['share_with_displayname'] = ($displayNameShareWith) ? $displayNameShareWith : $share['uid_owner'];
55 55
 
56
-					$result[] = $share;
57
-				}
58
-			}
59
-			$parent = $this->getParentId($parent);
60
-		}
56
+                    $result[] = $share;
57
+                }
58
+            }
59
+            $parent = $this->getParentId($parent);
60
+        }
61 61
 
62
-		return $result;
63
-	}
62
+        return $result;
63
+    }
64 64
 
65
-	/**
66
-	 * get file cache ID of parent
67
-	 *
68
-	 * @param int $child file cache ID of child
69
-	 * @return mixed parent ID or null
70
-	 */
71
-	private function getParentId($child) {
72
-		$query = \OCP\DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
73
-		$result = $query->execute(array($child));
74
-		$row = $result->fetchRow();
75
-		$parent = ($row) ? $row['parent'] : null;
65
+    /**
66
+     * get file cache ID of parent
67
+     *
68
+     * @param int $child file cache ID of child
69
+     * @return mixed parent ID or null
70
+     */
71
+    private function getParentId($child) {
72
+        $query = \OCP\DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
73
+        $result = $query->execute(array($child));
74
+        $row = $result->fetchRow();
75
+        $parent = ($row) ? $row['parent'] : null;
76 76
 
77
-		return $parent;
78
-	}
77
+        return $parent;
78
+    }
79 79
 
80
-	public function getChildren($itemSource) {
81
-		$children = array();
82
-		$parents = array($itemSource);
83
-		$query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
84
-		$result = $query->execute(array('httpd/unix-directory'));
85
-		if ($row = $result->fetchRow()) {
86
-			$mimetype = $row['id'];
87
-		} else {
88
-			$mimetype = -1;
89
-		}
90
-		while (!empty($parents)) {
91
-			$parents = "'".implode("','", $parents)."'";
92
-			$query = \OCP\DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache`'
93
-				.' WHERE `parent` IN ('.$parents.')');
94
-			$result = $query->execute();
95
-			$parents = array();
96
-			while ($file = $result->fetchRow()) {
97
-				$children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
98
-				// If a child folder is found look inside it
99
-				if ($file['mimetype'] == $mimetype) {
100
-					$parents[] = $file['fileid'];
101
-				}
102
-			}
103
-		}
104
-		return $children;
105
-	}
80
+    public function getChildren($itemSource) {
81
+        $children = array();
82
+        $parents = array($itemSource);
83
+        $query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
84
+        $result = $query->execute(array('httpd/unix-directory'));
85
+        if ($row = $result->fetchRow()) {
86
+            $mimetype = $row['id'];
87
+        } else {
88
+            $mimetype = -1;
89
+        }
90
+        while (!empty($parents)) {
91
+            $parents = "'".implode("','", $parents)."'";
92
+            $query = \OCP\DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache`'
93
+                .' WHERE `parent` IN ('.$parents.')');
94
+            $result = $query->execute();
95
+            $parents = array();
96
+            while ($file = $result->fetchRow()) {
97
+                $children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
98
+                // If a child folder is found look inside it
99
+                if ($file['mimetype'] == $mimetype) {
100
+                    $parents[] = $file['fileid'];
101
+                }
102
+            }
103
+        }
104
+        return $children;
105
+    }
106 106
 
107 107
 }
Please login to merge, or discard this patch.
apps/files_sharing/public.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@
 block discarded – undo
28 28
 $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare';
29 29
 
30 30
 if($token !== '') {
31
-	OC_Response::redirect($urlGenerator->linkToRoute($route, array('token' => $token)));
31
+    OC_Response::redirect($urlGenerator->linkToRoute($route, array('token' => $token)));
32 32
 } else {
33
-	header('HTTP/1.0 404 Not Found');
34
-	$tmpl = new OCP\Template('', '404', 'guest');
35
-	print_unescaped($tmpl->fetchPage());
33
+    header('HTTP/1.0 404 Not Found');
34
+    $tmpl = new OCP\Template('', '404', 'guest');
35
+    print_unescaped($tmpl->fetchPage());
36 36
 }
Please login to merge, or discard this patch.
apps/files_sharing/appinfo/update.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
 
27 27
 // Migration OC8.2 -> OC9
28 28
 if (version_compare($installedVersion, '0.9.1', '<')) {
29
-	$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
30
-	$m->removeReShares();
31
-	$m->updateInitiatorInfo();
29
+    $m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
30
+    $m->removeReShares();
31
+    $m->updateInitiatorInfo();
32 32
 }
33 33
 
34 34
 if (version_compare($installedVersion, '1.1.1', '<')) {
35
-	$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
35
+    $m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
36 36
 }
Please login to merge, or discard this patch.
apps/files_sharing/appinfo/routes.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -30,105 +30,105 @@
 block discarded – undo
30 30
 
31 31
 $application = new \OCA\Files_Sharing\AppInfo\Application();
32 32
 $application->registerRoutes($this, [
33
-	'resources' => [
34
-		'ExternalShares' => ['url' => '/api/externalShares'],
35
-	],
36
-	'routes' => [
37
-		[
38
-			'name' => 'externalShares#testRemote',
39
-			'url' => '/testremote',
40
-			'verb' => 'GET'
41
-		],
42
-		[
43
-			'name' => 'PublicPreview#getPreview',
44
-			'url' => '/publicpreview',
45
-			'verb' => 'GET',
46
-		],
33
+    'resources' => [
34
+        'ExternalShares' => ['url' => '/api/externalShares'],
35
+    ],
36
+    'routes' => [
37
+        [
38
+            'name' => 'externalShares#testRemote',
39
+            'url' => '/testremote',
40
+            'verb' => 'GET'
41
+        ],
42
+        [
43
+            'name' => 'PublicPreview#getPreview',
44
+            'url' => '/publicpreview',
45
+            'verb' => 'GET',
46
+        ],
47 47
 
48
-		[
49
-			'name' => 'PublicPreview#getPreview',
50
-			'url' => '/ajax/publicpreview.php',
51
-			'verb' => 'GET',
52
-		],
53
-	],
54
-	'ocs' => [
55
-		/*
48
+        [
49
+            'name' => 'PublicPreview#getPreview',
50
+            'url' => '/ajax/publicpreview.php',
51
+            'verb' => 'GET',
52
+        ],
53
+    ],
54
+    'ocs' => [
55
+        /*
56 56
 		 * OCS Share API
57 57
 		 */
58
-		[
59
-			'name' => 'ShareAPI#getShares',
60
-			'url'  => '/api/v1/shares',
61
-			'verb' => 'GET',
62
-		],
63
-		[
64
-			'name' => 'ShareAPI#createShare',
65
-			'url'  => '/api/v1/shares',
66
-			'verb' => 'POST',
67
-		],
68
-		[
69
-			'name' => 'ShareAPI#getShare',
70
-			'url'  => '/api/v1/shares/{id}',
71
-			'verb' => 'GET',
72
-		],
73
-		[
74
-			'name' => 'ShareAPI#updateShare',
75
-			'url'  => '/api/v1/shares/{id}',
76
-			'verb' => 'PUT',
77
-		],
78
-		[
79
-			'name' => 'ShareAPI#deleteShare',
80
-			'url'  => '/api/v1/shares/{id}',
81
-			'verb' => 'DELETE',
82
-		],
83
-		/*
58
+        [
59
+            'name' => 'ShareAPI#getShares',
60
+            'url'  => '/api/v1/shares',
61
+            'verb' => 'GET',
62
+        ],
63
+        [
64
+            'name' => 'ShareAPI#createShare',
65
+            'url'  => '/api/v1/shares',
66
+            'verb' => 'POST',
67
+        ],
68
+        [
69
+            'name' => 'ShareAPI#getShare',
70
+            'url'  => '/api/v1/shares/{id}',
71
+            'verb' => 'GET',
72
+        ],
73
+        [
74
+            'name' => 'ShareAPI#updateShare',
75
+            'url'  => '/api/v1/shares/{id}',
76
+            'verb' => 'PUT',
77
+        ],
78
+        [
79
+            'name' => 'ShareAPI#deleteShare',
80
+            'url'  => '/api/v1/shares/{id}',
81
+            'verb' => 'DELETE',
82
+        ],
83
+        /*
84 84
 		 * OCS Sharee API
85 85
 		 */
86
-		[
87
-			'name' => 'ShareesAPI#search',
88
-			'url' => '/api/v1/sharees',
89
-			'verb' => 'GET',
90
-		],
91
-		/*
86
+        [
87
+            'name' => 'ShareesAPI#search',
88
+            'url' => '/api/v1/sharees',
89
+            'verb' => 'GET',
90
+        ],
91
+        /*
92 92
 		 * Remote Shares
93 93
 		 */
94
-		[
95
-			'name' => 'Remote#getShares',
96
-			'url' => '/api/v1/remote_shares',
97
-			'verb' => 'GET',
98
-		],
99
-		[
100
-			'name' => 'Remote#getOpenShares',
101
-			'url' => '/api/v1/remote_shares/pending',
102
-			'verb' => 'GET',
103
-		],
104
-		[
105
-			'name' => 'Remote#acceptShare',
106
-			'url' => '/api/v1/remote_shares/pending/{id}',
107
-			'verb' => 'POST',
108
-		],
109
-		[
110
-			'name' => 'Remote#declineShare',
111
-			'url' => '/api/v1/remote_shares/pending/{id}',
112
-			'verb' => 'DELETE',
113
-		],
114
-		[
115
-			'name' => 'Remote#getShare',
116
-			'url' => '/api/v1/remote_shares/{id}',
117
-			'verb' => 'GET',
118
-		],
119
-		[
120
-			'name' => 'Remote#unshare',
121
-			'url' => '/api/v1/remote_shares/{id}',
122
-			'verb' => 'DELETE',
123
-		],
124
-	],
94
+        [
95
+            'name' => 'Remote#getShares',
96
+            'url' => '/api/v1/remote_shares',
97
+            'verb' => 'GET',
98
+        ],
99
+        [
100
+            'name' => 'Remote#getOpenShares',
101
+            'url' => '/api/v1/remote_shares/pending',
102
+            'verb' => 'GET',
103
+        ],
104
+        [
105
+            'name' => 'Remote#acceptShare',
106
+            'url' => '/api/v1/remote_shares/pending/{id}',
107
+            'verb' => 'POST',
108
+        ],
109
+        [
110
+            'name' => 'Remote#declineShare',
111
+            'url' => '/api/v1/remote_shares/pending/{id}',
112
+            'verb' => 'DELETE',
113
+        ],
114
+        [
115
+            'name' => 'Remote#getShare',
116
+            'url' => '/api/v1/remote_shares/{id}',
117
+            'verb' => 'GET',
118
+        ],
119
+        [
120
+            'name' => 'Remote#unshare',
121
+            'url' => '/api/v1/remote_shares/{id}',
122
+            'verb' => 'DELETE',
123
+        ],
124
+    ],
125 125
 ]);
126 126
 
127 127
 /** @var $this \OCP\Route\IRouter */
128 128
 $this->create('files_sharing_ajax_list', 'ajax/list.php')
129
-	->actionInclude('files_sharing/ajax/list.php');
129
+    ->actionInclude('files_sharing/ajax/list.php');
130 130
 $this->create('sharing_external_shareinfo', '/shareinfo')
131
-	->actionInclude('files_sharing/ajax/shareinfo.php');
131
+    ->actionInclude('files_sharing/ajax/shareinfo.php');
132 132
 
133 133
 // OCS API
134 134
 
Please login to merge, or discard this patch.
apps/files_sharing/appinfo/app.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
 $eventDispatcher = \OC::$server->getEventDispatcher();
40 40
 $eventDispatcher->addListener(
41
-	'OCA\Files::loadAdditionalScripts',
42
-	function() {
43
-		\OCP\Util::addScript('files_sharing', 'share');
44
-		\OCP\Util::addScript('files_sharing', 'sharetabview');
45
-		\OCP\Util::addScript('files_sharing', 'sharebreadcrumbview');
46
-		\OCP\Util::addStyle('files_sharing', 'sharetabview');
47
-		\OCP\Util::addStyle('files_sharing', 'sharebreadcrumb');
48
-	}
41
+    'OCA\Files::loadAdditionalScripts',
42
+    function() {
43
+        \OCP\Util::addScript('files_sharing', 'share');
44
+        \OCP\Util::addScript('files_sharing', 'sharetabview');
45
+        \OCP\Util::addScript('files_sharing', 'sharebreadcrumbview');
46
+        \OCP\Util::addStyle('files_sharing', 'sharetabview');
47
+        \OCP\Util::addStyle('files_sharing', 'sharebreadcrumb');
48
+    }
49 49
 );
50 50
 
51 51
 // \OCP\Util::addStyle('files_sharing', 'sharetabview');
@@ -53,38 +53,38 @@  discard block
 block discarded – undo
53 53
 $config = \OC::$server->getConfig();
54 54
 if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
55 55
 
56
-	\OCA\Files\App::getNavigationManager()->add(
57
-		array(
58
-			"id" => 'sharingin',
59
-			"appname" => 'files_sharing',
60
-			"script" => 'list.php',
61
-			"order" => 10,
62
-			"name" => $l->t('Shared with you')
63
-		)
64
-	);
56
+    \OCA\Files\App::getNavigationManager()->add(
57
+        array(
58
+            "id" => 'sharingin',
59
+            "appname" => 'files_sharing',
60
+            "script" => 'list.php',
61
+            "order" => 10,
62
+            "name" => $l->t('Shared with you')
63
+        )
64
+    );
65 65
 
66
-	if (\OCP\Util::isSharingDisabledForUser() === false) {
66
+    if (\OCP\Util::isSharingDisabledForUser() === false) {
67 67
 
68
-		\OCA\Files\App::getNavigationManager()->add(
69
-			array(
70
-				"id" => 'sharingout',
71
-				"appname" => 'files_sharing',
72
-				"script" => 'list.php',
73
-				"order" => 15,
74
-				"name" => $l->t('Shared with others')
75
-			)
76
-		);
77
-		// Check if sharing by link is enabled
78
-		if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
79
-			\OCA\Files\App::getNavigationManager()->add(
80
-				array(
81
-					"id" => 'sharinglinks',
82
-					"appname" => 'files_sharing',
83
-					"script" => 'list.php',
84
-					"order" => 20,
85
-					"name" => $l->t('Shared by link')
86
-				)
87
-			);
88
-		}
89
-	}
68
+        \OCA\Files\App::getNavigationManager()->add(
69
+            array(
70
+                "id" => 'sharingout',
71
+                "appname" => 'files_sharing',
72
+                "script" => 'list.php',
73
+                "order" => 15,
74
+                "name" => $l->t('Shared with others')
75
+            )
76
+        );
77
+        // Check if sharing by link is enabled
78
+        if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
79
+            \OCA\Files\App::getNavigationManager()->add(
80
+                array(
81
+                    "id" => 'sharinglinks',
82
+                    "appname" => 'files_sharing',
83
+                    "script" => 'list.php',
84
+                    "order" => 20,
85
+                    "name" => $l->t('Shared by link')
86
+                )
87
+            );
88
+        }
89
+    }
90 90
 }
Please login to merge, or discard this patch.
apps/provisioning_api/lib/Controller/AppsController.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -33,86 +33,86 @@
 block discarded – undo
33 33
 use OCP\IRequest;
34 34
 
35 35
 class AppsController extends OCSController {
36
-	/** @var \OCP\App\IAppManager */
37
-	private $appManager;
36
+    /** @var \OCP\App\IAppManager */
37
+    private $appManager;
38 38
 
39
-	/**
40
-	 * @param string $appName
41
-	 * @param IRequest $request
42
-	 * @param IAppManager $appManager
43
-	 */
44
-	public function __construct(
45
-		$appName,
46
-		IRequest $request,
47
-		IAppManager $appManager
48
-	) {
49
-		parent::__construct($appName, $request);
39
+    /**
40
+     * @param string $appName
41
+     * @param IRequest $request
42
+     * @param IAppManager $appManager
43
+     */
44
+    public function __construct(
45
+        $appName,
46
+        IRequest $request,
47
+        IAppManager $appManager
48
+    ) {
49
+        parent::__construct($appName, $request);
50 50
 
51
-		$this->appManager = $appManager;
52
-	}
51
+        $this->appManager = $appManager;
52
+    }
53 53
 
54
-	/**
55
-	 * @param string $filter
56
-	 * @return DataResponse
57
-	 * @throws OCSException
58
-	 */
59
-	public function getApps($filter = null) {
60
-		$apps = (new OC_App())->listAllApps();
61
-		$list = [];
62
-		foreach($apps as $app) {
63
-			$list[] = $app['id'];
64
-		}
65
-		if($filter){
66
-			switch($filter){
67
-				case 'enabled':
68
-					return new DataResponse(['apps' => \OC_App::getEnabledApps()]);
69
-					break;
70
-				case 'disabled':
71
-					$enabled = OC_App::getEnabledApps();
72
-					return new DataResponse(['apps' => array_diff($list, $enabled)]);
73
-					break;
74
-				default:
75
-					// Invalid filter variable
76
-					throw new OCSException('', 101);
77
-			}
54
+    /**
55
+     * @param string $filter
56
+     * @return DataResponse
57
+     * @throws OCSException
58
+     */
59
+    public function getApps($filter = null) {
60
+        $apps = (new OC_App())->listAllApps();
61
+        $list = [];
62
+        foreach($apps as $app) {
63
+            $list[] = $app['id'];
64
+        }
65
+        if($filter){
66
+            switch($filter){
67
+                case 'enabled':
68
+                    return new DataResponse(['apps' => \OC_App::getEnabledApps()]);
69
+                    break;
70
+                case 'disabled':
71
+                    $enabled = OC_App::getEnabledApps();
72
+                    return new DataResponse(['apps' => array_diff($list, $enabled)]);
73
+                    break;
74
+                default:
75
+                    // Invalid filter variable
76
+                    throw new OCSException('', 101);
77
+            }
78 78
 
79
-		} else {
80
-			return new DataResponse(['apps' => $list]);
81
-		}
82
-	}
79
+        } else {
80
+            return new DataResponse(['apps' => $list]);
81
+        }
82
+    }
83 83
 
84
-	/**
85
-	 * @param string $app
86
-	 * @return DataResponse
87
-	 * @throws OCSException
88
-	 */
89
-	public function getAppInfo($app) {
90
-		$info = \OCP\App::getAppInfo($app);
91
-		if(!is_null($info)) {
92
-			return new DataResponse(OC_App::getAppInfo($app));
93
-		} else {
94
-			throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND);
95
-		}
96
-	}
84
+    /**
85
+     * @param string $app
86
+     * @return DataResponse
87
+     * @throws OCSException
88
+     */
89
+    public function getAppInfo($app) {
90
+        $info = \OCP\App::getAppInfo($app);
91
+        if(!is_null($info)) {
92
+            return new DataResponse(OC_App::getAppInfo($app));
93
+        } else {
94
+            throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND);
95
+        }
96
+    }
97 97
 
98
-	/**
99
-	 * @PasswordConfirmationRequired
100
-	 * @param string $app
101
-	 * @return DataResponse
102
-	 */
103
-	public function enable($app) {
104
-		$this->appManager->enableApp($app);
105
-		return new DataResponse();
106
-	}
98
+    /**
99
+     * @PasswordConfirmationRequired
100
+     * @param string $app
101
+     * @return DataResponse
102
+     */
103
+    public function enable($app) {
104
+        $this->appManager->enableApp($app);
105
+        return new DataResponse();
106
+    }
107 107
 
108
-	/**
109
-	 * @PasswordConfirmationRequired
110
-	 * @param string $app
111
-	 * @return DataResponse
112
-	 */
113
-	public function disable($app) {
114
-		$this->appManager->disableApp($app);
115
-		return new DataResponse();
116
-	}
108
+    /**
109
+     * @PasswordConfirmationRequired
110
+     * @param string $app
111
+     * @return DataResponse
112
+     */
113
+    public function disable($app) {
114
+        $this->appManager->disableApp($app);
115
+        return new DataResponse();
116
+    }
117 117
 
118 118
 }
Please login to merge, or discard this patch.
apps/provisioning_api/lib/Controller/GroupsController.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -37,156 +37,156 @@
 block discarded – undo
37 37
 
38 38
 class GroupsController extends OCSController {
39 39
 
40
-	/** @var IGroupManager */
41
-	private $groupManager;
42
-
43
-	/** @var IUserSession */
44
-	private $userSession;
45
-
46
-	/**
47
-	 * @param string $appName
48
-	 * @param IRequest $request
49
-	 * @param IGroupManager $groupManager
50
-	 * @param IUserSession $userSession
51
-	 */
52
-	public function __construct(
53
-			$appName,
54
-			IRequest $request,
55
-			IGroupManager $groupManager,
56
-			IUserSession $userSession) {
57
-		parent::__construct($appName, $request);
58
-
59
-		$this->groupManager = $groupManager;
60
-		$this->userSession = $userSession;
61
-	}
62
-
63
-	/**
64
-	 * returns a list of groups
65
-	 *
66
-	 * @NoAdminRequired
67
-	 *
68
-	 * @param string $search
69
-	 * @param int $limit
70
-	 * @param int $offset
71
-	 * @return DataResponse
72
-	 */
73
-	public function getGroups($search = '', $limit = null, $offset = null) {
74
-		if ($limit !== null) {
75
-			$limit = (int)$limit;
76
-		}
77
-		if ($offset !== null) {
78
-			$offset = (int)$offset;
79
-		}
80
-
81
-		$groups = $this->groupManager->search($search, $limit, $offset);
82
-		$groups = array_map(function($group) {
83
-			/** @var IGroup $group */
84
-			return $group->getGID();
85
-		}, $groups);
86
-
87
-		return new DataResponse(['groups' => $groups]);
88
-	}
89
-
90
-	/**
91
-	 * returns an array of users in the group specified
92
-	 *
93
-	 * @NoAdminRequired
94
-	 *
95
-	 * @param string $groupId
96
-	 * @return DataResponse
97
-	 * @throws OCSException
98
-	 */
99
-	public function getGroup($groupId) {
100
-		$user = $this->userSession->getUser();
101
-
102
-		// Check the group exists
103
-		if(!$this->groupManager->groupExists($groupId)) {
104
-			throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
105
-		}
106
-
107
-		$isSubadminOfGroup = false;
108
-		$group = $this->groupManager->get($groupId);
109
-		if ($group !== null) {
110
-			$isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group);
111
-		}
112
-
113
-		// Check subadmin has access to this group
114
-		if($this->groupManager->isAdmin($user->getUID())
115
-		   || $isSubadminOfGroup) {
116
-			$users = $this->groupManager->get($groupId)->getUsers();
117
-			$users =  array_map(function($user) {
118
-				/** @var IUser $user */
119
-				return $user->getUID();
120
-			}, $users);
121
-			$users = array_values($users);
122
-			return new DataResponse(['users' => $users]);
123
-		} else {
124
-			throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED);
125
-		}
126
-	}
127
-
128
-	/**
129
-	 * creates a new group
130
-	 *
131
-	 * @PasswordConfirmationRequired
132
-	 *
133
-	 * @param string $groupid
134
-	 * @return DataResponse
135
-	 * @throws OCSException
136
-	 */
137
-	public function addGroup($groupid) {
138
-		// Validate name
139
-		if(empty($groupid)){
140
-			\OCP\Util::writeLog('provisioning_api', 'Group name not supplied', \OCP\Util::ERROR);
141
-			throw new OCSException('Invalid group name', 101);
142
-		}
143
-		// Check if it exists
144
-		if($this->groupManager->groupExists($groupid)){
145
-			throw new OCSException('', 102);
146
-		}
147
-		$this->groupManager->createGroup($groupid);
148
-		return new DataResponse();
149
-	}
150
-
151
-	/**
152
-	 * @PasswordConfirmationRequired
153
-	 *
154
-	 * @param string $groupId
155
-	 * @return DataResponse
156
-	 * @throws OCSException
157
-	 */
158
-	public function deleteGroup($groupId) {
159
-		// Check it exists
160
-		if(!$this->groupManager->groupExists($groupId)){
161
-			throw new OCSException('', 101);
162
-		} else if($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){
163
-			// Cannot delete admin group
164
-			throw new OCSException('', 102);
165
-		}
166
-
167
-		return new DataResponse(null, 100);
168
-	}
169
-
170
-	/**
171
-	 * @param string $groupId
172
-	 * @return DataResponse
173
-	 * @throws OCSException
174
-	 */
175
-	public function getSubAdminsOfGroup($groupId) {
176
-		// Check group exists
177
-		$targetGroup = $this->groupManager->get($groupId);
178
-		if($targetGroup === null) {
179
-			throw new OCSException('Group does not exist', 101);
180
-		}
181
-
182
-		$subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup);
183
-		// New class returns IUser[] so convert back
184
-		$uids = [];
185
-		foreach ($subadmins as $user) {
186
-			$uids[] = $user->getUID();
187
-		}
188
-
189
-		return new DataResponse($uids);
190
-	}
40
+    /** @var IGroupManager */
41
+    private $groupManager;
42
+
43
+    /** @var IUserSession */
44
+    private $userSession;
45
+
46
+    /**
47
+     * @param string $appName
48
+     * @param IRequest $request
49
+     * @param IGroupManager $groupManager
50
+     * @param IUserSession $userSession
51
+     */
52
+    public function __construct(
53
+            $appName,
54
+            IRequest $request,
55
+            IGroupManager $groupManager,
56
+            IUserSession $userSession) {
57
+        parent::__construct($appName, $request);
58
+
59
+        $this->groupManager = $groupManager;
60
+        $this->userSession = $userSession;
61
+    }
62
+
63
+    /**
64
+     * returns a list of groups
65
+     *
66
+     * @NoAdminRequired
67
+     *
68
+     * @param string $search
69
+     * @param int $limit
70
+     * @param int $offset
71
+     * @return DataResponse
72
+     */
73
+    public function getGroups($search = '', $limit = null, $offset = null) {
74
+        if ($limit !== null) {
75
+            $limit = (int)$limit;
76
+        }
77
+        if ($offset !== null) {
78
+            $offset = (int)$offset;
79
+        }
80
+
81
+        $groups = $this->groupManager->search($search, $limit, $offset);
82
+        $groups = array_map(function($group) {
83
+            /** @var IGroup $group */
84
+            return $group->getGID();
85
+        }, $groups);
86
+
87
+        return new DataResponse(['groups' => $groups]);
88
+    }
89
+
90
+    /**
91
+     * returns an array of users in the group specified
92
+     *
93
+     * @NoAdminRequired
94
+     *
95
+     * @param string $groupId
96
+     * @return DataResponse
97
+     * @throws OCSException
98
+     */
99
+    public function getGroup($groupId) {
100
+        $user = $this->userSession->getUser();
101
+
102
+        // Check the group exists
103
+        if(!$this->groupManager->groupExists($groupId)) {
104
+            throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
105
+        }
106
+
107
+        $isSubadminOfGroup = false;
108
+        $group = $this->groupManager->get($groupId);
109
+        if ($group !== null) {
110
+            $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group);
111
+        }
112
+
113
+        // Check subadmin has access to this group
114
+        if($this->groupManager->isAdmin($user->getUID())
115
+           || $isSubadminOfGroup) {
116
+            $users = $this->groupManager->get($groupId)->getUsers();
117
+            $users =  array_map(function($user) {
118
+                /** @var IUser $user */
119
+                return $user->getUID();
120
+            }, $users);
121
+            $users = array_values($users);
122
+            return new DataResponse(['users' => $users]);
123
+        } else {
124
+            throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED);
125
+        }
126
+    }
127
+
128
+    /**
129
+     * creates a new group
130
+     *
131
+     * @PasswordConfirmationRequired
132
+     *
133
+     * @param string $groupid
134
+     * @return DataResponse
135
+     * @throws OCSException
136
+     */
137
+    public function addGroup($groupid) {
138
+        // Validate name
139
+        if(empty($groupid)){
140
+            \OCP\Util::writeLog('provisioning_api', 'Group name not supplied', \OCP\Util::ERROR);
141
+            throw new OCSException('Invalid group name', 101);
142
+        }
143
+        // Check if it exists
144
+        if($this->groupManager->groupExists($groupid)){
145
+            throw new OCSException('', 102);
146
+        }
147
+        $this->groupManager->createGroup($groupid);
148
+        return new DataResponse();
149
+    }
150
+
151
+    /**
152
+     * @PasswordConfirmationRequired
153
+     *
154
+     * @param string $groupId
155
+     * @return DataResponse
156
+     * @throws OCSException
157
+     */
158
+    public function deleteGroup($groupId) {
159
+        // Check it exists
160
+        if(!$this->groupManager->groupExists($groupId)){
161
+            throw new OCSException('', 101);
162
+        } else if($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){
163
+            // Cannot delete admin group
164
+            throw new OCSException('', 102);
165
+        }
166
+
167
+        return new DataResponse(null, 100);
168
+    }
169
+
170
+    /**
171
+     * @param string $groupId
172
+     * @return DataResponse
173
+     * @throws OCSException
174
+     */
175
+    public function getSubAdminsOfGroup($groupId) {
176
+        // Check group exists
177
+        $targetGroup = $this->groupManager->get($groupId);
178
+        if($targetGroup === null) {
179
+            throw new OCSException('Group does not exist', 101);
180
+        }
181
+
182
+        $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup);
183
+        // New class returns IUser[] so convert back
184
+        $uids = [];
185
+        foreach ($subadmins as $user) {
186
+            $uids[] = $user->getUID();
187
+        }
188
+
189
+        return new DataResponse($uids);
190
+    }
191 191
 
192 192
 }
Please login to merge, or discard this patch.
apps/provisioning_api/lib/Controller/AppConfigController.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -31,127 +31,127 @@
 block discarded – undo
31 31
 
32 32
 class AppConfigController extends OCSController {
33 33
 
34
-	/** @var IConfig */
35
-	protected $config;
36
-
37
-	/** @var IAppConfig */
38
-	protected $appConfig;
39
-
40
-	/**
41
-	 * @param string $appName
42
-	 * @param IRequest $request
43
-	 * @param IConfig $config
44
-	 * @param IAppConfig $appConfig
45
-	 */
46
-	public function __construct($appName,
47
-								IRequest $request,
48
-								IConfig $config,
49
-								IAppConfig $appConfig) {
50
-		parent::__construct($appName, $request);
51
-		$this->config = $config;
52
-		$this->appConfig = $appConfig;
53
-	}
54
-
55
-	/**
56
-	 * @return DataResponse
57
-	 */
58
-	public function getApps() {
59
-		return new DataResponse([
60
-			'data' => $this->appConfig->getApps(),
61
-		]);
62
-	}
63
-
64
-	/**
65
-	 * @param string $app
66
-	 * @return DataResponse
67
-	 */
68
-	public function getKeys($app) {
69
-		try {
70
-			$this->verifyAppId($app);
71
-		} catch (\InvalidArgumentException $e) {
72
-			return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
73
-		}
74
-		return new DataResponse([
75
-			'data' => $this->config->getAppKeys($app),
76
-		]);
77
-	}
78
-
79
-	/**
80
-	 * @param string $app
81
-	 * @param string $key
82
-	 * @param string $defaultValue
83
-	 * @return DataResponse
84
-	 */
85
-	public function getValue($app, $key, $defaultValue = '') {
86
-		try {
87
-			$this->verifyAppId($app);
88
-		} catch (\InvalidArgumentException $e) {
89
-			return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
90
-		}
91
-		return new DataResponse([
92
-			'data' => $this->config->getAppValue($app, $key, $defaultValue),
93
-		]);
94
-	}
95
-
96
-	/**
97
-	 * @PasswordConfirmationRequired
98
-	 * @param string $app
99
-	 * @param string $key
100
-	 * @param string $value
101
-	 * @return DataResponse
102
-	 */
103
-	public function setValue($app, $key, $value) {
104
-		try {
105
-			$this->verifyAppId($app);
106
-			$this->verifyConfigKey($app, $key);
107
-		} catch (\InvalidArgumentException $e) {
108
-			return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
109
-		}
110
-
111
-		$this->config->setAppValue($app, $key, $value);
112
-		return new DataResponse();
113
-	}
114
-
115
-	/**
116
-	 * @PasswordConfirmationRequired
117
-	 * @param string $app
118
-	 * @param string $key
119
-	 * @return DataResponse
120
-	 */
121
-	public function deleteKey($app, $key) {
122
-		try {
123
-			$this->verifyAppId($app);
124
-			$this->verifyConfigKey($app, $key);
125
-		} catch (\InvalidArgumentException $e) {
126
-			return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
127
-		}
128
-
129
-		$this->config->deleteAppValue($app, $key);
130
-		return new DataResponse();
131
-	}
132
-
133
-	/**
134
-	 * @param string $app
135
-	 * @throws \InvalidArgumentException
136
-	 */
137
-	protected function verifyAppId($app) {
138
-		if (\OC_App::cleanAppId($app) !== $app) {
139
-			throw new \InvalidArgumentException('Invalid app id given');
140
-		}
141
-	}
142
-
143
-	/**
144
-	 * @param string $app
145
-	 * @param string $key
146
-	 * @throws \InvalidArgumentException
147
-	 */
148
-	protected function verifyConfigKey($app, $key) {
149
-		if (in_array($key, ['installed_version', 'enabled', 'types'])) {
150
-			throw new \InvalidArgumentException('The given key can not be set');
151
-		}
152
-
153
-		if ($app === 'core' && (strpos($key, 'public_') === 0 || strpos($key, 'remote_') === 0)) {
154
-			throw new \InvalidArgumentException('The given key can not be set');
155
-		}
156
-	}
34
+    /** @var IConfig */
35
+    protected $config;
36
+
37
+    /** @var IAppConfig */
38
+    protected $appConfig;
39
+
40
+    /**
41
+     * @param string $appName
42
+     * @param IRequest $request
43
+     * @param IConfig $config
44
+     * @param IAppConfig $appConfig
45
+     */
46
+    public function __construct($appName,
47
+                                IRequest $request,
48
+                                IConfig $config,
49
+                                IAppConfig $appConfig) {
50
+        parent::__construct($appName, $request);
51
+        $this->config = $config;
52
+        $this->appConfig = $appConfig;
53
+    }
54
+
55
+    /**
56
+     * @return DataResponse
57
+     */
58
+    public function getApps() {
59
+        return new DataResponse([
60
+            'data' => $this->appConfig->getApps(),
61
+        ]);
62
+    }
63
+
64
+    /**
65
+     * @param string $app
66
+     * @return DataResponse
67
+     */
68
+    public function getKeys($app) {
69
+        try {
70
+            $this->verifyAppId($app);
71
+        } catch (\InvalidArgumentException $e) {
72
+            return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
73
+        }
74
+        return new DataResponse([
75
+            'data' => $this->config->getAppKeys($app),
76
+        ]);
77
+    }
78
+
79
+    /**
80
+     * @param string $app
81
+     * @param string $key
82
+     * @param string $defaultValue
83
+     * @return DataResponse
84
+     */
85
+    public function getValue($app, $key, $defaultValue = '') {
86
+        try {
87
+            $this->verifyAppId($app);
88
+        } catch (\InvalidArgumentException $e) {
89
+            return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
90
+        }
91
+        return new DataResponse([
92
+            'data' => $this->config->getAppValue($app, $key, $defaultValue),
93
+        ]);
94
+    }
95
+
96
+    /**
97
+     * @PasswordConfirmationRequired
98
+     * @param string $app
99
+     * @param string $key
100
+     * @param string $value
101
+     * @return DataResponse
102
+     */
103
+    public function setValue($app, $key, $value) {
104
+        try {
105
+            $this->verifyAppId($app);
106
+            $this->verifyConfigKey($app, $key);
107
+        } catch (\InvalidArgumentException $e) {
108
+            return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
109
+        }
110
+
111
+        $this->config->setAppValue($app, $key, $value);
112
+        return new DataResponse();
113
+    }
114
+
115
+    /**
116
+     * @PasswordConfirmationRequired
117
+     * @param string $app
118
+     * @param string $key
119
+     * @return DataResponse
120
+     */
121
+    public function deleteKey($app, $key) {
122
+        try {
123
+            $this->verifyAppId($app);
124
+            $this->verifyConfigKey($app, $key);
125
+        } catch (\InvalidArgumentException $e) {
126
+            return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN);
127
+        }
128
+
129
+        $this->config->deleteAppValue($app, $key);
130
+        return new DataResponse();
131
+    }
132
+
133
+    /**
134
+     * @param string $app
135
+     * @throws \InvalidArgumentException
136
+     */
137
+    protected function verifyAppId($app) {
138
+        if (\OC_App::cleanAppId($app) !== $app) {
139
+            throw new \InvalidArgumentException('Invalid app id given');
140
+        }
141
+    }
142
+
143
+    /**
144
+     * @param string $app
145
+     * @param string $key
146
+     * @throws \InvalidArgumentException
147
+     */
148
+    protected function verifyConfigKey($app, $key) {
149
+        if (in_array($key, ['installed_version', 'enabled', 'types'])) {
150
+            throw new \InvalidArgumentException('The given key can not be set');
151
+        }
152
+
153
+        if ($app === 'core' && (strpos($key, 'public_') === 0 || strpos($key, 'remote_') === 0)) {
154
+            throw new \InvalidArgumentException('The given key can not be set');
155
+        }
156
+    }
157 157
 }
Please login to merge, or discard this patch.
apps/provisioning_api/lib/AppInfo/Application.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 use OCP\AppFramework\App;
8 8
 
9 9
 class Application extends App {
10
-	public function __construct(array $urlParams = array()) {
11
-		parent::__construct('provisioning_api', $urlParams);
10
+    public function __construct(array $urlParams = array()) {
11
+        parent::__construct('provisioning_api', $urlParams);
12 12
 
13
-		$container = $this->getContainer();
14
-		$server = $container->getServer();
13
+        $container = $this->getContainer();
14
+        $server = $container->getServer();
15 15
 
16
-		$container->registerService('ProvisioningApiMiddleware', function(SimpleContainer $c) use ($server) {
17
-			$user = $server->getUserManager()->get($c['UserId']);
18
-			$isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false;
19
-			$isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false;
20
-			return new ProvisioningApiMiddleware(
21
-				$c['ControllerMethodReflector'],
22
-				$isAdmin,
23
-				$isSubAdmin
24
-			);
25
-		});
26
-		$container->registerMiddleWare('ProvisioningApiMiddleware');
27
-	}
16
+        $container->registerService('ProvisioningApiMiddleware', function(SimpleContainer $c) use ($server) {
17
+            $user = $server->getUserManager()->get($c['UserId']);
18
+            $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false;
19
+            $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false;
20
+            return new ProvisioningApiMiddleware(
21
+                $c['ControllerMethodReflector'],
22
+                $isAdmin,
23
+                $isSubAdmin
24
+            );
25
+        });
26
+        $container->registerMiddleWare('ProvisioningApiMiddleware');
27
+    }
28 28
 }
Please login to merge, or discard this patch.