Completed
Pull Request — master (#7490)
by Tobia
30:30 queued 16:48
created
apps/files_sharing/lib/External/Cache.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -27,44 +27,44 @@
 block discarded – undo
27 27
 use OCP\Federation\ICloudId;
28 28
 
29 29
 class Cache extends \OC\Files\Cache\Cache {
30
-	/** @var ICloudId */
31
-	private $cloudId;
32
-	private $remote;
33
-	private $remoteUser;
34
-	private $storage;
30
+    /** @var ICloudId */
31
+    private $cloudId;
32
+    private $remote;
33
+    private $remoteUser;
34
+    private $storage;
35 35
 
36
-	/**
37
-	 * @param \OCA\Files_Sharing\External\Storage $storage
38
-	 * @param ICloudId $cloudId
39
-	 */
40
-	public function __construct($storage, ICloudId $cloudId) {
41
-		$this->cloudId = $cloudId;
42
-		$this->storage = $storage;
43
-		list(, $remote) = explode('://', $cloudId->getRemote(), 2);
44
-		$this->remote = $remote;
45
-		$this->remoteUser = $cloudId->getUser();
46
-		parent::__construct($storage);
47
-	}
36
+    /**
37
+     * @param \OCA\Files_Sharing\External\Storage $storage
38
+     * @param ICloudId $cloudId
39
+     */
40
+    public function __construct($storage, ICloudId $cloudId) {
41
+        $this->cloudId = $cloudId;
42
+        $this->storage = $storage;
43
+        list(, $remote) = explode('://', $cloudId->getRemote(), 2);
44
+        $this->remote = $remote;
45
+        $this->remoteUser = $cloudId->getUser();
46
+        parent::__construct($storage);
47
+    }
48 48
 
49
-	public function get($file) {
50
-		$result = parent::get($file);
51
-		if (!$result) {
52
-			return false;
53
-		}
54
-		$result['displayname_owner'] = $this->cloudId->getDisplayId();
55
-		if (!$file || $file === '') {
56
-			$result['is_share_mount_point'] = true;
57
-			$mountPoint = rtrim($this->storage->getMountPoint());
58
-			$result['name'] = basename($mountPoint);
59
-		}
60
-		return $result;
61
-	}
49
+    public function get($file) {
50
+        $result = parent::get($file);
51
+        if (!$result) {
52
+            return false;
53
+        }
54
+        $result['displayname_owner'] = $this->cloudId->getDisplayId();
55
+        if (!$file || $file === '') {
56
+            $result['is_share_mount_point'] = true;
57
+            $mountPoint = rtrim($this->storage->getMountPoint());
58
+            $result['name'] = basename($mountPoint);
59
+        }
60
+        return $result;
61
+    }
62 62
 
63
-	public function getFolderContentsById($id) {
64
-		$results = parent::getFolderContentsById($id);
65
-		foreach ($results as &$file) {
66
-			$file['displayname_owner'] = $this->cloudId->getDisplayId();
67
-		}
68
-		return $results;
69
-	}
63
+    public function getFolderContentsById($id) {
64
+        $results = parent::getFolderContentsById($id);
65
+        foreach ($results as &$file) {
66
+            $file['displayname_owner'] = $this->cloudId->getDisplayId();
67
+        }
68
+        return $results;
69
+    }
70 70
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/MountProvider.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -29,59 +29,59 @@
 block discarded – undo
29 29
 use OCP\IUser;
30 30
 
31 31
 class MountProvider implements IMountProvider {
32
-	const STORAGE = '\OCA\Files_Sharing\External\Storage';
32
+    const STORAGE = '\OCA\Files_Sharing\External\Storage';
33 33
 
34
-	/**
35
-	 * @var \OCP\IDBConnection
36
-	 */
37
-	private $connection;
34
+    /**
35
+     * @var \OCP\IDBConnection
36
+     */
37
+    private $connection;
38 38
 
39
-	/**
40
-	 * @var callable
41
-	 */
42
-	private $managerProvider;
39
+    /**
40
+     * @var callable
41
+     */
42
+    private $managerProvider;
43 43
 
44
-	/**
45
-	 * @var ICloudIdManager
46
-	 */
47
-	private $cloudIdManager;
44
+    /**
45
+     * @var ICloudIdManager
46
+     */
47
+    private $cloudIdManager;
48 48
 
49
-	/**
50
-	 * @param \OCP\IDBConnection $connection
51
-	 * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself
52
-	 * @param ICloudIdManager $cloudIdManager
53
-	 */
54
-	public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) {
55
-		$this->connection = $connection;
56
-		$this->managerProvider = $managerProvider;
57
-		$this->cloudIdManager = $cloudIdManager;
58
-	}
49
+    /**
50
+     * @param \OCP\IDBConnection $connection
51
+     * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself
52
+     * @param ICloudIdManager $cloudIdManager
53
+     */
54
+    public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) {
55
+        $this->connection = $connection;
56
+        $this->managerProvider = $managerProvider;
57
+        $this->cloudIdManager = $cloudIdManager;
58
+    }
59 59
 
60
-	public function getMount(IUser $user, $data, IStorageFactory $storageFactory) {
61
-		$managerProvider = $this->managerProvider;
62
-		$manager = $managerProvider();
63
-		$data['manager'] = $manager;
64
-		$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
65
-		$data['mountpoint'] = $mountPoint;
66
-		$data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
67
-		$data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
68
-		$data['HttpClientService'] = \OC::$server->getHTTPClientService();
69
-		return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
70
-	}
60
+    public function getMount(IUser $user, $data, IStorageFactory $storageFactory) {
61
+        $managerProvider = $this->managerProvider;
62
+        $manager = $managerProvider();
63
+        $data['manager'] = $manager;
64
+        $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
65
+        $data['mountpoint'] = $mountPoint;
66
+        $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
67
+        $data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
68
+        $data['HttpClientService'] = \OC::$server->getHTTPClientService();
69
+        return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
70
+    }
71 71
 
72
-	public function getMountsForUser(IUser $user, IStorageFactory $loader) {
73
-		$query = $this->connection->prepare('
72
+    public function getMountsForUser(IUser $user, IStorageFactory $loader) {
73
+        $query = $this->connection->prepare('
74 74
 				SELECT `remote`, `share_token`, `password`, `mountpoint`, `owner`
75 75
 				FROM `*PREFIX*share_external`
76 76
 				WHERE `user` = ? AND `accepted` = ?
77 77
 			');
78
-		$query->execute([$user->getUID(), 1]);
79
-		$mounts = [];
80
-		while ($row = $query->fetch()) {
81
-			$row['manager'] = $this;
82
-			$row['token'] = $row['share_token'];
83
-			$mounts[] = $this->getMount($user, $row, $loader);
84
-		}
85
-		return $mounts;
86
-	}
78
+        $query->execute([$user->getUID(), 1]);
79
+        $mounts = [];
80
+        while ($row = $query->fetch()) {
81
+            $row['manager'] = $this;
82
+            $row['token'] = $row['share_token'];
83
+            $mounts[] = $this->getMount($user, $row, $loader);
84
+        }
85
+        return $mounts;
86
+    }
87 87
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/Watcher.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@
 block discarded – undo
23 23
 namespace OCA\Files_Sharing\External;
24 24
 
25 25
 class Watcher extends \OC\Files\Cache\Watcher {
26
-	/**
27
-	 * remove deleted files in $path from the cache
28
-	 *
29
-	 * @param string $path
30
-	 */
31
-	public function cleanFolder($path) {
32
-		// not needed, the scanner takes care of this
33
-	}
26
+    /**
27
+     * remove deleted files in $path from the cache
28
+     *
29
+     * @param string $path
30
+     */
31
+    public function cleanFolder($path) {
32
+        // not needed, the scanner takes care of this
33
+    }
34 34
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/Mount.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -29,43 +29,43 @@
 block discarded – undo
29 29
 
30 30
 class Mount extends MountPoint implements MoveableMount {
31 31
 
32
-	/**
33
-	 * @var \OCA\Files_Sharing\External\Manager
34
-	 */
35
-	protected $manager;
32
+    /**
33
+     * @var \OCA\Files_Sharing\External\Manager
34
+     */
35
+    protected $manager;
36 36
 
37
-	/**
38
-	 * @param string|\OC\Files\Storage\Storage $storage
39
-	 * @param string $mountpoint
40
-	 * @param array $options
41
-	 * @param \OCA\Files_Sharing\External\Manager $manager
42
-	 * @param \OC\Files\Storage\StorageFactory $loader
43
-	 */
44
-	public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
45
-		parent::__construct($storage, $mountpoint, $options, $loader);
46
-		$this->manager = $manager;
47
-	}
37
+    /**
38
+     * @param string|\OC\Files\Storage\Storage $storage
39
+     * @param string $mountpoint
40
+     * @param array $options
41
+     * @param \OCA\Files_Sharing\External\Manager $manager
42
+     * @param \OC\Files\Storage\StorageFactory $loader
43
+     */
44
+    public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
45
+        parent::__construct($storage, $mountpoint, $options, $loader);
46
+        $this->manager = $manager;
47
+    }
48 48
 
49
-	/**
50
-	 * Move the mount point to $target
51
-	 *
52
-	 * @param string $target the target mount point
53
-	 * @return bool
54
-	 */
55
-	public function moveMount($target) {
56
-		$result = $this->manager->setMountPoint($this->mountPoint, $target);
57
-		$this->setMountPoint($target);
49
+    /**
50
+     * Move the mount point to $target
51
+     *
52
+     * @param string $target the target mount point
53
+     * @return bool
54
+     */
55
+    public function moveMount($target) {
56
+        $result = $this->manager->setMountPoint($this->mountPoint, $target);
57
+        $this->setMountPoint($target);
58 58
 
59
-		return $result;
60
-	}
59
+        return $result;
60
+    }
61 61
 
62
-	/**
63
-	 * Remove the mount points
64
-	 *
65
-	 * @return mixed
66
-	 * @return bool
67
-	 */
68
-	public function removeMount() {
69
-		return $this->manager->removeShare($this->mountPoint);
70
-	}
62
+    /**
63
+     * Remove the mount points
64
+     *
65
+     * @return mixed
66
+     * @return bool
67
+     */
68
+    public function removeMount() {
69
+        return $this->manager->removeShare($this->mountPoint);
70
+    }
71 71
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Updater.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -27,81 +27,81 @@
 block discarded – undo
27 27
 
28 28
 class Updater {
29 29
 
30
-	/**
31
-	 * @param array $params
32
-	 */
33
-	static public function renameHook($params) {
34
-		self::renameChildren($params['oldpath'], $params['newpath']);
35
-		self::moveShareToShare($params['newpath']);
36
-	}
37
-
38
-	/**
39
-	 * Fix for https://github.com/owncloud/core/issues/20769
40
-	 *
41
-	 * The owner is allowed to move their files (if they are shared) into a receiving folder
42
-	 * In this case we need to update the parent of the moved share. Since they are
43
-	 * effectively handing over ownership of the file the rest of the code needs to know
44
-	 * they need to build up the reshare tree.
45
-	 *
46
-	 * @param string $path
47
-	 */
48
-	static private function moveShareToShare($path) {
49
-		$userFolder = \OC::$server->getUserFolder();
50
-
51
-		// If the user folder can't be constructed (e.g. link share) just return.
52
-		if ($userFolder === null) {
53
-			return;
54
-		}
55
-
56
-		$src = $userFolder->get($path);
57
-
58
-		$shareManager = \OC::$server->getShareManager();
59
-
60
-		$shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1);
61
-		$shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1));
62
-
63
-		// If the path we move is not a share we don't care
64
-		if (empty($shares)) {
65
-			return;
66
-		}
67
-
68
-		// Check if the destination is inside a share
69
-		$mountManager = \OC::$server->getMountManager();
70
-		$dstMount = $mountManager->find($src->getPath());
71
-		if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) {
72
-			return;
73
-		}
74
-
75
-		$newOwner = $dstMount->getShare()->getShareOwner();
76
-
77
-		//Ownership is moved over
78
-		foreach ($shares as $share) {
79
-			/** @var \OCP\Share\IShare $share */
80
-			$share->setShareOwner($newOwner);
81
-			$shareManager->updateShare($share);
82
-		}
83
-	}
84
-
85
-	/**
86
-	 * rename mount point from the children if the parent was renamed
87
-	 *
88
-	 * @param string $oldPath old path relative to data/user/files
89
-	 * @param string $newPath new path relative to data/user/files
90
-	 */
91
-	static private function renameChildren($oldPath, $newPath) {
92
-
93
-		$absNewPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
94
-		$absOldPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
95
-
96
-		$mountManager = \OC\Files\Filesystem::getMountManager();
97
-		$mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
98
-		foreach ($mountedShares as $mount) {
99
-			if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
100
-				$mountPoint = $mount->getMountPoint();
101
-				$target = str_replace($absOldPath, $absNewPath, $mountPoint);
102
-				$mount->moveMount($target);
103
-			}
104
-		}
105
-	}
30
+    /**
31
+     * @param array $params
32
+     */
33
+    static public function renameHook($params) {
34
+        self::renameChildren($params['oldpath'], $params['newpath']);
35
+        self::moveShareToShare($params['newpath']);
36
+    }
37
+
38
+    /**
39
+     * Fix for https://github.com/owncloud/core/issues/20769
40
+     *
41
+     * The owner is allowed to move their files (if they are shared) into a receiving folder
42
+     * In this case we need to update the parent of the moved share. Since they are
43
+     * effectively handing over ownership of the file the rest of the code needs to know
44
+     * they need to build up the reshare tree.
45
+     *
46
+     * @param string $path
47
+     */
48
+    static private function moveShareToShare($path) {
49
+        $userFolder = \OC::$server->getUserFolder();
50
+
51
+        // If the user folder can't be constructed (e.g. link share) just return.
52
+        if ($userFolder === null) {
53
+            return;
54
+        }
55
+
56
+        $src = $userFolder->get($path);
57
+
58
+        $shareManager = \OC::$server->getShareManager();
59
+
60
+        $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1);
61
+        $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1));
62
+
63
+        // If the path we move is not a share we don't care
64
+        if (empty($shares)) {
65
+            return;
66
+        }
67
+
68
+        // Check if the destination is inside a share
69
+        $mountManager = \OC::$server->getMountManager();
70
+        $dstMount = $mountManager->find($src->getPath());
71
+        if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) {
72
+            return;
73
+        }
74
+
75
+        $newOwner = $dstMount->getShare()->getShareOwner();
76
+
77
+        //Ownership is moved over
78
+        foreach ($shares as $share) {
79
+            /** @var \OCP\Share\IShare $share */
80
+            $share->setShareOwner($newOwner);
81
+            $shareManager->updateShare($share);
82
+        }
83
+    }
84
+
85
+    /**
86
+     * rename mount point from the children if the parent was renamed
87
+     *
88
+     * @param string $oldPath old path relative to data/user/files
89
+     * @param string $newPath new path relative to data/user/files
90
+     */
91
+    static private function renameChildren($oldPath, $newPath) {
92
+
93
+        $absNewPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
94
+        $absOldPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
95
+
96
+        $mountManager = \OC\Files\Filesystem::getMountManager();
97
+        $mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
98
+        foreach ($mountedShares as $mount) {
99
+            if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
100
+                $mountPoint = $mount->getMountPoint();
101
+                $target = str_replace($absOldPath, $absNewPath, $mountPoint);
102
+                $mount->moveMount($target);
103
+            }
104
+        }
105
+    }
106 106
 
107 107
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/DeleteOrphanedSharesJob.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@
 block discarded – undo
31 31
  */
32 32
 class DeleteOrphanedSharesJob extends TimedJob {
33 33
 
34
-	/**
35
-	 * Default interval in minutes
36
-	 *
37
-	 * @var int $defaultIntervalMin
38
-	 **/
39
-	protected $defaultIntervalMin = 15;
34
+    /**
35
+     * Default interval in minutes
36
+     *
37
+     * @var int $defaultIntervalMin
38
+     **/
39
+    protected $defaultIntervalMin = 15;
40 40
 
41
-	/**
42
-	 * sets the correct interval for this timed job
43
-	 */
44
-	public function __construct(){
45
-		$this->interval = $this->defaultIntervalMin * 60;
46
-	}
41
+    /**
42
+     * sets the correct interval for this timed job
43
+     */
44
+    public function __construct(){
45
+        $this->interval = $this->defaultIntervalMin * 60;
46
+    }
47 47
 
48
-	/**
49
-	 * Makes the background job do its work
50
-	 *
51
-	 * @param array $argument unused argument
52
-	 */
53
-	public function run($argument) {
54
-		$connection = \OC::$server->getDatabaseConnection();
55
-		$logger = \OC::$server->getLogger();
48
+    /**
49
+     * Makes the background job do its work
50
+     *
51
+     * @param array $argument unused argument
52
+     */
53
+    public function run($argument) {
54
+        $connection = \OC::$server->getDatabaseConnection();
55
+        $logger = \OC::$server->getLogger();
56 56
 
57
-		$sql =
58
-			'DELETE FROM `*PREFIX*share` ' .
59
-			'WHERE `item_type` in (\'file\', \'folder\') ' .
60
-			'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
57
+        $sql =
58
+            'DELETE FROM `*PREFIX*share` ' .
59
+            'WHERE `item_type` in (\'file\', \'folder\') ' .
60
+            'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
61 61
 
62
-		$deletedEntries = $connection->executeUpdate($sql);
63
-		$logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
64
-	}
62
+        $deletedEntries = $connection->executeUpdate($sql);
63
+        $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
64
+    }
65 65
 
66 66
 }
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/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/Middleware/Exceptions/NotSubAdminException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use OCP\AppFramework\Http;
6 6
 
7 7
 class NotSubAdminException extends \Exception {
8
-	public function __construct() {
9
-		parent::__construct('Logged in user must be at least a sub admin', Http::STATUS_FORBIDDEN);
10
-	}
8
+    public function __construct() {
9
+        parent::__construct('Logged in user must be at least a sub admin', Http::STATUS_FORBIDDEN);
10
+    }
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.