| @@ -138,7 +138,7 @@ discard block | ||
| 138 | 138 | } | 
| 139 | 139 |  		foreach ($favorites['folders'] as $favorite) { | 
| 140 | 140 |  			$limitations[] = $query->expr()->like('file', $query->createNamedParameter( | 
| 141 | - $this->db->escapeLikeParameter($favorite . '/') . '%' | |
| 141 | + $this->db->escapeLikeParameter($favorite.'/').'%' | |
| 142 | 142 | )); | 
| 143 | 143 | } | 
| 144 | 144 | |
| @@ -148,9 +148,9 @@ discard block | ||
| 148 | 148 | |
| 149 | 149 |  		$function = $query->createFunction(' | 
| 150 | 150 | CASE | 
| 151 | -				WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1 | |
| 152 | -				WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . ' | |
| 153 | -					AND (' . implode(' OR ', $limitations) . ') | |
| 151 | +				WHEN ' . $query->getColumnName('app').' <> '.$query->createNamedParameter('files').' THEN 1 | |
| 152 | +				WHEN ' . $query->getColumnName('app').' = '.$query->createNamedParameter('files').' | |
| 153 | +					AND (' . implode(' OR ', $limitations).') | |
| 154 | 154 | THEN 1 | 
| 155 | 155 | END = 1' | 
| 156 | 156 | ); | 
| @@ -16,115 +16,115 @@ | ||
| 16 | 16 | |
| 17 | 17 |  class Favorites implements IFilter { | 
| 18 | 18 | |
| 19 | - /** | |
| 20 | - * @param IL10N $l | |
| 21 | - * @param IURLGenerator $url | |
| 22 | - * @param IManager $activityManager | |
| 23 | - * @param Helper $helper | |
| 24 | - * @param IDBConnection $db | |
| 25 | - */ | |
| 26 | - public function __construct( | |
| 27 | - protected IL10N $l, | |
| 28 | - protected IURLGenerator $url, | |
| 29 | - protected IManager $activityManager, | |
| 30 | - protected Helper $helper, | |
| 31 | - protected IDBConnection $db, | |
| 32 | -	) { | |
| 33 | - } | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * @return string Lowercase a-z only identifier | |
| 37 | - * @since 11.0.0 | |
| 38 | - */ | |
| 39 | -	public function getIdentifier() { | |
| 40 | - return 'files_favorites'; | |
| 41 | - } | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * @return string A translated string | |
| 45 | - * @since 11.0.0 | |
| 46 | - */ | |
| 47 | -	public function getName() { | |
| 48 | -		return $this->l->t('Favorites'); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * @return int | |
| 53 | - * @since 11.0.0 | |
| 54 | - */ | |
| 55 | -	public function getPriority() { | |
| 56 | - return 10; | |
| 57 | - } | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * @return string Full URL to an icon, empty string when none is given | |
| 61 | - * @since 11.0.0 | |
| 62 | - */ | |
| 63 | -	public function getIcon() { | |
| 64 | -		return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg')); | |
| 65 | - } | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * @param string[] $types | |
| 69 | - * @return string[] An array of allowed apps from which activities should be displayed | |
| 70 | - * @since 11.0.0 | |
| 71 | - */ | |
| 72 | -	public function filterTypes(array $types) { | |
| 73 | - return array_intersect([ | |
| 74 | - 'file_created', | |
| 75 | - 'file_changed', | |
| 76 | - 'file_deleted', | |
| 77 | - 'file_restored', | |
| 78 | - ], $types); | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * @return string[] An array of allowed apps from which activities should be displayed | |
| 83 | - * @since 11.0.0 | |
| 84 | - */ | |
| 85 | -	public function allowedApps() { | |
| 86 | - return ['files']; | |
| 87 | - } | |
| 88 | - | |
| 89 | - /** | |
| 90 | - * @param IQueryBuilder $query | |
| 91 | - */ | |
| 92 | -	public function filterFavorites(IQueryBuilder $query) { | |
| 93 | -		try { | |
| 94 | - $user = $this->activityManager->getCurrentUserId(); | |
| 95 | -		} catch (\UnexpectedValueException $e) { | |
| 96 | - return; | |
| 97 | - } | |
| 98 | - | |
| 99 | -		try { | |
| 100 | - $favorites = $this->helper->getFavoriteFilePaths($user); | |
| 101 | -		} catch (\RuntimeException $e) { | |
| 102 | - return; | |
| 103 | - } | |
| 104 | - | |
| 105 | - $limitations = []; | |
| 106 | -		if (!empty($favorites['items'])) { | |
| 107 | -			$limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY)); | |
| 108 | - } | |
| 109 | -		foreach ($favorites['folders'] as $favorite) { | |
| 110 | -			$limitations[] = $query->expr()->like('file', $query->createNamedParameter( | |
| 111 | - $this->db->escapeLikeParameter($favorite . '/') . '%' | |
| 112 | - )); | |
| 113 | - } | |
| 114 | - | |
| 115 | -		if (empty($limitations)) { | |
| 116 | - return; | |
| 117 | - } | |
| 118 | - | |
| 119 | -		$function = $query->createFunction(' | |
| 19 | + /** | |
| 20 | + * @param IL10N $l | |
| 21 | + * @param IURLGenerator $url | |
| 22 | + * @param IManager $activityManager | |
| 23 | + * @param Helper $helper | |
| 24 | + * @param IDBConnection $db | |
| 25 | + */ | |
| 26 | + public function __construct( | |
| 27 | + protected IL10N $l, | |
| 28 | + protected IURLGenerator $url, | |
| 29 | + protected IManager $activityManager, | |
| 30 | + protected Helper $helper, | |
| 31 | + protected IDBConnection $db, | |
| 32 | +    ) { | |
| 33 | + } | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * @return string Lowercase a-z only identifier | |
| 37 | + * @since 11.0.0 | |
| 38 | + */ | |
| 39 | +    public function getIdentifier() { | |
| 40 | + return 'files_favorites'; | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * @return string A translated string | |
| 45 | + * @since 11.0.0 | |
| 46 | + */ | |
| 47 | +    public function getName() { | |
| 48 | +        return $this->l->t('Favorites'); | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * @return int | |
| 53 | + * @since 11.0.0 | |
| 54 | + */ | |
| 55 | +    public function getPriority() { | |
| 56 | + return 10; | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * @return string Full URL to an icon, empty string when none is given | |
| 61 | + * @since 11.0.0 | |
| 62 | + */ | |
| 63 | +    public function getIcon() { | |
| 64 | +        return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg')); | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * @param string[] $types | |
| 69 | + * @return string[] An array of allowed apps from which activities should be displayed | |
| 70 | + * @since 11.0.0 | |
| 71 | + */ | |
| 72 | +    public function filterTypes(array $types) { | |
| 73 | + return array_intersect([ | |
| 74 | + 'file_created', | |
| 75 | + 'file_changed', | |
| 76 | + 'file_deleted', | |
| 77 | + 'file_restored', | |
| 78 | + ], $types); | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * @return string[] An array of allowed apps from which activities should be displayed | |
| 83 | + * @since 11.0.0 | |
| 84 | + */ | |
| 85 | +    public function allowedApps() { | |
| 86 | + return ['files']; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * @param IQueryBuilder $query | |
| 91 | + */ | |
| 92 | +    public function filterFavorites(IQueryBuilder $query) { | |
| 93 | +        try { | |
| 94 | + $user = $this->activityManager->getCurrentUserId(); | |
| 95 | +        } catch (\UnexpectedValueException $e) { | |
| 96 | + return; | |
| 97 | + } | |
| 98 | + | |
| 99 | +        try { | |
| 100 | + $favorites = $this->helper->getFavoriteFilePaths($user); | |
| 101 | +        } catch (\RuntimeException $e) { | |
| 102 | + return; | |
| 103 | + } | |
| 104 | + | |
| 105 | + $limitations = []; | |
| 106 | +        if (!empty($favorites['items'])) { | |
| 107 | +            $limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY)); | |
| 108 | + } | |
| 109 | +        foreach ($favorites['folders'] as $favorite) { | |
| 110 | +            $limitations[] = $query->expr()->like('file', $query->createNamedParameter( | |
| 111 | + $this->db->escapeLikeParameter($favorite . '/') . '%' | |
| 112 | + )); | |
| 113 | + } | |
| 114 | + | |
| 115 | +        if (empty($limitations)) { | |
| 116 | + return; | |
| 117 | + } | |
| 118 | + | |
| 119 | +        $function = $query->createFunction(' | |
| 120 | 120 | CASE | 
| 121 | 121 |  				WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1 | 
| 122 | 122 |  				WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . ' | 
| 123 | 123 |  					AND (' . implode(' OR ', $limitations) . ') | 
| 124 | 124 | THEN 1 | 
| 125 | 125 | END = 1' | 
| 126 | - ); | |
| 126 | + ); | |
| 127 | 127 | |
| 128 | - $query->andWhere($function); | |
| 129 | - } | |
| 128 | + $query->andWhere($function); | |
| 129 | + } | |
| 130 | 130 | } | 
| @@ -24,25 +24,25 @@ | ||
| 24 | 24 | namespace OCA\Files_External\Service; | 
| 25 | 25 | |
| 26 | 26 |  class ImportLegacyStoragesService extends LegacyStoragesService { | 
| 27 | - private $data; | |
| 27 | + private $data; | |
| 28 | 28 | |
| 29 | - /** | |
| 30 | - * @param BackendService $backendService | |
| 31 | - */ | |
| 32 | -	public function __construct(BackendService $backendService) { | |
| 33 | - $this->backendService = $backendService; | |
| 34 | - } | |
| 29 | + /** | |
| 30 | + * @param BackendService $backendService | |
| 31 | + */ | |
| 32 | +    public function __construct(BackendService $backendService) { | |
| 33 | + $this->backendService = $backendService; | |
| 34 | + } | |
| 35 | 35 | |
| 36 | -	public function setData($data) { | |
| 37 | - $this->data = $data; | |
| 38 | - } | |
| 36 | +    public function setData($data) { | |
| 37 | + $this->data = $data; | |
| 38 | + } | |
| 39 | 39 | |
| 40 | - /** | |
| 41 | - * Read legacy config data | |
| 42 | - * | |
| 43 | - * @return array list of mount configs | |
| 44 | - */ | |
| 45 | -	protected function readLegacyConfig() { | |
| 46 | - return $this->data; | |
| 47 | - } | |
| 40 | + /** | |
| 41 | + * Read legacy config data | |
| 42 | + * | |
| 43 | + * @return array list of mount configs | |
| 44 | + */ | |
| 45 | +    protected function readLegacyConfig() { | |
| 46 | + return $this->data; | |
| 47 | + } | |
| 48 | 48 | } | 
| @@ -172,11 +172,11 @@ | ||
| 172 | 172 |  	public function getStorageForAllUsers() { | 
| 173 | 173 | $mounts = $this->dbConfig->getAllMounts(); | 
| 174 | 174 | $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); | 
| 175 | -		$configs = array_filter($configs, function ($config) { | |
| 175 | +		$configs = array_filter($configs, function($config) { | |
| 176 | 176 | return $config instanceof StorageConfig; | 
| 177 | 177 | }); | 
| 178 | 178 | |
| 179 | -		$keys = array_map(function (StorageConfig $config) { | |
| 179 | +		$keys = array_map(function(StorageConfig $config) { | |
| 180 | 180 | return $config->getId(); | 
| 181 | 181 | }, $configs); | 
| 182 | 182 | |
| @@ -14,151 +14,151 @@ | ||
| 14 | 14 | * Service class to manage global external storage | 
| 15 | 15 | */ | 
| 16 | 16 |  class GlobalStoragesService extends StoragesService { | 
| 17 | - /** | |
| 18 | - * Triggers $signal for all applicable users of the given | |
| 19 | - * storage | |
| 20 | - * | |
| 21 | - * @param StorageConfig $storage storage data | |
| 22 | - * @param string $signal signal to trigger | |
| 23 | - */ | |
| 24 | -	protected function triggerHooks(StorageConfig $storage, $signal) { | |
| 25 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped | |
| 26 | - $applicableUsers = $storage->getApplicableUsers(); | |
| 27 | - $applicableGroups = $storage->getApplicableGroups(); | |
| 28 | -		if (empty($applicableUsers) && empty($applicableGroups)) { | |
| 29 | - // raise for user "all" | |
| 30 | - $this->triggerApplicableHooks( | |
| 31 | - $signal, | |
| 32 | - $storage->getMountPoint(), | |
| 33 | - MountConfig::MOUNT_TYPE_USER, | |
| 34 | - ['all'] | |
| 35 | - ); | |
| 36 | - return; | |
| 37 | - } | |
| 38 | - | |
| 39 | - $this->triggerApplicableHooks( | |
| 40 | - $signal, | |
| 41 | - $storage->getMountPoint(), | |
| 42 | - MountConfig::MOUNT_TYPE_USER, | |
| 43 | - $applicableUsers | |
| 44 | - ); | |
| 45 | - $this->triggerApplicableHooks( | |
| 46 | - $signal, | |
| 47 | - $storage->getMountPoint(), | |
| 48 | - MountConfig::MOUNT_TYPE_GROUP, | |
| 49 | - $applicableGroups | |
| 50 | - ); | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Triggers signal_create_mount or signal_delete_mount to | |
| 55 | - * accommodate for additions/deletions in applicableUsers | |
| 56 | - * and applicableGroups fields. | |
| 57 | - * | |
| 58 | - * @param StorageConfig $oldStorage old storage config | |
| 59 | - * @param StorageConfig $newStorage new storage config | |
| 60 | - */ | |
| 61 | -	protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) { | |
| 62 | - // if mount point changed, it's like a deletion + creation | |
| 63 | -		if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) { | |
| 64 | - $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount); | |
| 65 | - $this->triggerHooks($newStorage, Filesystem::signal_create_mount); | |
| 66 | - return; | |
| 67 | - } | |
| 68 | - | |
| 69 | - $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers()); | |
| 70 | - $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers()); | |
| 71 | - $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); | |
| 72 | - $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); | |
| 73 | - | |
| 74 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped | |
| 75 | - // if no applicable were set, raise a signal for "all" | |
| 76 | - $oldApplicableUsers = $oldStorage->getApplicableUsers(); | |
| 77 | - $oldApplicableGroups = $oldStorage->getApplicableGroups(); | |
| 78 | -		if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { | |
| 79 | - $this->triggerApplicableHooks( | |
| 80 | - Filesystem::signal_delete_mount, | |
| 81 | - $oldStorage->getMountPoint(), | |
| 82 | - MountConfig::MOUNT_TYPE_USER, | |
| 83 | - ['all'] | |
| 84 | - ); | |
| 85 | - } | |
| 86 | - | |
| 87 | - // trigger delete for removed users | |
| 88 | - $this->triggerApplicableHooks( | |
| 89 | - Filesystem::signal_delete_mount, | |
| 90 | - $oldStorage->getMountPoint(), | |
| 91 | - MountConfig::MOUNT_TYPE_USER, | |
| 92 | - $userDeletions | |
| 93 | - ); | |
| 94 | - | |
| 95 | - // trigger delete for removed groups | |
| 96 | - $this->triggerApplicableHooks( | |
| 97 | - Filesystem::signal_delete_mount, | |
| 98 | - $oldStorage->getMountPoint(), | |
| 99 | - MountConfig::MOUNT_TYPE_GROUP, | |
| 100 | - $groupDeletions | |
| 101 | - ); | |
| 102 | - | |
| 103 | - // and now add the new users | |
| 104 | - $this->triggerApplicableHooks( | |
| 105 | - Filesystem::signal_create_mount, | |
| 106 | - $newStorage->getMountPoint(), | |
| 107 | - MountConfig::MOUNT_TYPE_USER, | |
| 108 | - $userAdditions | |
| 109 | - ); | |
| 110 | - | |
| 111 | - // and now add the new groups | |
| 112 | - $this->triggerApplicableHooks( | |
| 113 | - Filesystem::signal_create_mount, | |
| 114 | - $newStorage->getMountPoint(), | |
| 115 | - MountConfig::MOUNT_TYPE_GROUP, | |
| 116 | - $groupAdditions | |
| 117 | - ); | |
| 118 | - | |
| 119 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped | |
| 120 | - // if no applicable, raise a signal for "all" | |
| 121 | - $newApplicableUsers = $newStorage->getApplicableUsers(); | |
| 122 | - $newApplicableGroups = $newStorage->getApplicableGroups(); | |
| 123 | -		if (empty($newApplicableUsers) && empty($newApplicableGroups)) { | |
| 124 | - $this->triggerApplicableHooks( | |
| 125 | - Filesystem::signal_create_mount, | |
| 126 | - $newStorage->getMountPoint(), | |
| 127 | - MountConfig::MOUNT_TYPE_USER, | |
| 128 | - ['all'] | |
| 129 | - ); | |
| 130 | - } | |
| 131 | - } | |
| 132 | - | |
| 133 | - /** | |
| 134 | - * Get the visibility type for this controller, used in validation | |
| 135 | - * | |
| 136 | - * @return int BackendService::VISIBILITY_* constants | |
| 137 | - */ | |
| 138 | -	public function getVisibilityType() { | |
| 139 | - return BackendService::VISIBILITY_ADMIN; | |
| 140 | - } | |
| 141 | - | |
| 142 | -	protected function isApplicable(StorageConfig $config) { | |
| 143 | - return true; | |
| 144 | - } | |
| 145 | - | |
| 146 | - /** | |
| 147 | - * Get all configured admin and personal mounts | |
| 148 | - * | |
| 149 | - * @return StorageConfig[] map of storage id to storage config | |
| 150 | - */ | |
| 151 | -	public function getStorageForAllUsers() { | |
| 152 | - $mounts = $this->dbConfig->getAllMounts(); | |
| 153 | - $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); | |
| 154 | -		$configs = array_filter($configs, function ($config) { | |
| 155 | - return $config instanceof StorageConfig; | |
| 156 | - }); | |
| 157 | - | |
| 158 | -		$keys = array_map(function (StorageConfig $config) { | |
| 159 | - return $config->getId(); | |
| 160 | - }, $configs); | |
| 161 | - | |
| 162 | - return array_combine($keys, $configs); | |
| 163 | - } | |
| 17 | + /** | |
| 18 | + * Triggers $signal for all applicable users of the given | |
| 19 | + * storage | |
| 20 | + * | |
| 21 | + * @param StorageConfig $storage storage data | |
| 22 | + * @param string $signal signal to trigger | |
| 23 | + */ | |
| 24 | +    protected function triggerHooks(StorageConfig $storage, $signal) { | |
| 25 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped | |
| 26 | + $applicableUsers = $storage->getApplicableUsers(); | |
| 27 | + $applicableGroups = $storage->getApplicableGroups(); | |
| 28 | +        if (empty($applicableUsers) && empty($applicableGroups)) { | |
| 29 | + // raise for user "all" | |
| 30 | + $this->triggerApplicableHooks( | |
| 31 | + $signal, | |
| 32 | + $storage->getMountPoint(), | |
| 33 | + MountConfig::MOUNT_TYPE_USER, | |
| 34 | + ['all'] | |
| 35 | + ); | |
| 36 | + return; | |
| 37 | + } | |
| 38 | + | |
| 39 | + $this->triggerApplicableHooks( | |
| 40 | + $signal, | |
| 41 | + $storage->getMountPoint(), | |
| 42 | + MountConfig::MOUNT_TYPE_USER, | |
| 43 | + $applicableUsers | |
| 44 | + ); | |
| 45 | + $this->triggerApplicableHooks( | |
| 46 | + $signal, | |
| 47 | + $storage->getMountPoint(), | |
| 48 | + MountConfig::MOUNT_TYPE_GROUP, | |
| 49 | + $applicableGroups | |
| 50 | + ); | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Triggers signal_create_mount or signal_delete_mount to | |
| 55 | + * accommodate for additions/deletions in applicableUsers | |
| 56 | + * and applicableGroups fields. | |
| 57 | + * | |
| 58 | + * @param StorageConfig $oldStorage old storage config | |
| 59 | + * @param StorageConfig $newStorage new storage config | |
| 60 | + */ | |
| 61 | +    protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) { | |
| 62 | + // if mount point changed, it's like a deletion + creation | |
| 63 | +        if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) { | |
| 64 | + $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount); | |
| 65 | + $this->triggerHooks($newStorage, Filesystem::signal_create_mount); | |
| 66 | + return; | |
| 67 | + } | |
| 68 | + | |
| 69 | + $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers()); | |
| 70 | + $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers()); | |
| 71 | + $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); | |
| 72 | + $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); | |
| 73 | + | |
| 74 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped | |
| 75 | + // if no applicable were set, raise a signal for "all" | |
| 76 | + $oldApplicableUsers = $oldStorage->getApplicableUsers(); | |
| 77 | + $oldApplicableGroups = $oldStorage->getApplicableGroups(); | |
| 78 | +        if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { | |
| 79 | + $this->triggerApplicableHooks( | |
| 80 | + Filesystem::signal_delete_mount, | |
| 81 | + $oldStorage->getMountPoint(), | |
| 82 | + MountConfig::MOUNT_TYPE_USER, | |
| 83 | + ['all'] | |
| 84 | + ); | |
| 85 | + } | |
| 86 | + | |
| 87 | + // trigger delete for removed users | |
| 88 | + $this->triggerApplicableHooks( | |
| 89 | + Filesystem::signal_delete_mount, | |
| 90 | + $oldStorage->getMountPoint(), | |
| 91 | + MountConfig::MOUNT_TYPE_USER, | |
| 92 | + $userDeletions | |
| 93 | + ); | |
| 94 | + | |
| 95 | + // trigger delete for removed groups | |
| 96 | + $this->triggerApplicableHooks( | |
| 97 | + Filesystem::signal_delete_mount, | |
| 98 | + $oldStorage->getMountPoint(), | |
| 99 | + MountConfig::MOUNT_TYPE_GROUP, | |
| 100 | + $groupDeletions | |
| 101 | + ); | |
| 102 | + | |
| 103 | + // and now add the new users | |
| 104 | + $this->triggerApplicableHooks( | |
| 105 | + Filesystem::signal_create_mount, | |
| 106 | + $newStorage->getMountPoint(), | |
| 107 | + MountConfig::MOUNT_TYPE_USER, | |
| 108 | + $userAdditions | |
| 109 | + ); | |
| 110 | + | |
| 111 | + // and now add the new groups | |
| 112 | + $this->triggerApplicableHooks( | |
| 113 | + Filesystem::signal_create_mount, | |
| 114 | + $newStorage->getMountPoint(), | |
| 115 | + MountConfig::MOUNT_TYPE_GROUP, | |
| 116 | + $groupAdditions | |
| 117 | + ); | |
| 118 | + | |
| 119 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped | |
| 120 | + // if no applicable, raise a signal for "all" | |
| 121 | + $newApplicableUsers = $newStorage->getApplicableUsers(); | |
| 122 | + $newApplicableGroups = $newStorage->getApplicableGroups(); | |
| 123 | +        if (empty($newApplicableUsers) && empty($newApplicableGroups)) { | |
| 124 | + $this->triggerApplicableHooks( | |
| 125 | + Filesystem::signal_create_mount, | |
| 126 | + $newStorage->getMountPoint(), | |
| 127 | + MountConfig::MOUNT_TYPE_USER, | |
| 128 | + ['all'] | |
| 129 | + ); | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + /** | |
| 134 | + * Get the visibility type for this controller, used in validation | |
| 135 | + * | |
| 136 | + * @return int BackendService::VISIBILITY_* constants | |
| 137 | + */ | |
| 138 | +    public function getVisibilityType() { | |
| 139 | + return BackendService::VISIBILITY_ADMIN; | |
| 140 | + } | |
| 141 | + | |
| 142 | +    protected function isApplicable(StorageConfig $config) { | |
| 143 | + return true; | |
| 144 | + } | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * Get all configured admin and personal mounts | |
| 148 | + * | |
| 149 | + * @return StorageConfig[] map of storage id to storage config | |
| 150 | + */ | |
| 151 | +    public function getStorageForAllUsers() { | |
| 152 | + $mounts = $this->dbConfig->getAllMounts(); | |
| 153 | + $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); | |
| 154 | +        $configs = array_filter($configs, function ($config) { | |
| 155 | + return $config instanceof StorageConfig; | |
| 156 | + }); | |
| 157 | + | |
| 158 | +        $keys = array_map(function (StorageConfig $config) { | |
| 159 | + return $config->getId(); | |
| 160 | + }, $configs); | |
| 161 | + | |
| 162 | + return array_combine($keys, $configs); | |
| 163 | + } | |
| 164 | 164 | } | 
| @@ -28,10 +28,10 @@ | ||
| 28 | 28 | * For auth mechanisms where the user needs to provide credentials | 
| 29 | 29 | */ | 
| 30 | 30 |  interface IUserProvided { | 
| 31 | - /** | |
| 32 | - * @param IUser $user the user for which to save the user provided options | |
| 33 | - * @param int $mountId the mount id to save the options for | |
| 34 | - * @param array $options the user provided options | |
| 35 | - */ | |
| 36 | - public function saveBackendOptions(IUser $user, $mountId, array $options); | |
| 31 | + /** | |
| 32 | + * @param IUser $user the user for which to save the user provided options | |
| 33 | + * @param int $mountId the mount id to save the options for | |
| 34 | + * @param array $options the user provided options | |
| 35 | + */ | |
| 36 | + public function saveBackendOptions(IUser $user, $mountId, array $options); | |
| 37 | 37 | } | 
| @@ -30,10 +30,10 @@ | ||
| 30 | 30 | */ | 
| 31 | 31 |  interface IBackendProvider { | 
| 32 | 32 | |
| 33 | - /** | |
| 34 | - * @since 9.1.0 | |
| 35 | - * @return Backend[] | |
| 36 | - */ | |
| 37 | - public function getBackends(); | |
| 33 | + /** | |
| 34 | + * @since 9.1.0 | |
| 35 | + * @return Backend[] | |
| 36 | + */ | |
| 37 | + public function getBackends(); | |
| 38 | 38 | |
| 39 | 39 | } | 
| @@ -30,10 +30,10 @@ | ||
| 30 | 30 | */ | 
| 31 | 31 |  interface IAuthMechanismProvider { | 
| 32 | 32 | |
| 33 | - /** | |
| 34 | - * @since 9.1.0 | |
| 35 | - * @return AuthMechanism[] | |
| 36 | - */ | |
| 37 | - public function getAuthMechanisms(); | |
| 33 | + /** | |
| 34 | + * @since 9.1.0 | |
| 35 | + * @return AuthMechanism[] | |
| 36 | + */ | |
| 37 | + public function getAuthMechanisms(); | |
| 38 | 38 | |
| 39 | 39 | } | 
| @@ -64,7 +64,7 @@ | ||
| 64 | 64 | |
| 65 | 65 |  	public function listen(callable $callback) { | 
| 66 | 66 | $oldRenamePath = null; | 
| 67 | -		$this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { | |
| 67 | +		$this->shareNotifyHandler->listen(function(\Icewind\SMB\Change $shareChange) use ($callback) { | |
| 68 | 68 | $change = $this->mapChange($shareChange); | 
| 69 | 69 |  			if (!is_null($change)) { | 
| 70 | 70 | return $callback($change); | 
| @@ -11,119 +11,119 @@ | ||
| 11 | 11 | use OCP\Files\Notify\INotifyHandler; | 
| 12 | 12 | |
| 13 | 13 |  class SMBNotifyHandler implements INotifyHandler { | 
| 14 | - /** | |
| 15 | - * @var string | |
| 16 | - */ | |
| 17 | - private $root; | |
| 14 | + /** | |
| 15 | + * @var string | |
| 16 | + */ | |
| 17 | + private $root; | |
| 18 | 18 | |
| 19 | - private $oldRenamePath = null; | |
| 19 | + private $oldRenamePath = null; | |
| 20 | 20 | |
| 21 | - /** | |
| 22 | - * SMBNotifyHandler constructor. | |
| 23 | - * | |
| 24 | - * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler | |
| 25 | - * @param string $root | |
| 26 | - */ | |
| 27 | - public function __construct( | |
| 28 | - private \Icewind\SMB\INotifyHandler $shareNotifyHandler, | |
| 29 | - $root, | |
| 30 | -	) { | |
| 31 | -		$this->root = str_replace('\\', '/', $root); | |
| 32 | - } | |
| 21 | + /** | |
| 22 | + * SMBNotifyHandler constructor. | |
| 23 | + * | |
| 24 | + * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler | |
| 25 | + * @param string $root | |
| 26 | + */ | |
| 27 | + public function __construct( | |
| 28 | + private \Icewind\SMB\INotifyHandler $shareNotifyHandler, | |
| 29 | + $root, | |
| 30 | +    ) { | |
| 31 | +        $this->root = str_replace('\\', '/', $root); | |
| 32 | + } | |
| 33 | 33 | |
| 34 | -	private function relativePath($fullPath) { | |
| 35 | -		if ($fullPath === $this->root) { | |
| 36 | - return ''; | |
| 37 | -		} elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { | |
| 38 | - return substr($fullPath, strlen($this->root)); | |
| 39 | -		} else { | |
| 40 | - return null; | |
| 41 | - } | |
| 42 | - } | |
| 34 | +    private function relativePath($fullPath) { | |
| 35 | +        if ($fullPath === $this->root) { | |
| 36 | + return ''; | |
| 37 | +        } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { | |
| 38 | + return substr($fullPath, strlen($this->root)); | |
| 39 | +        } else { | |
| 40 | + return null; | |
| 41 | + } | |
| 42 | + } | |
| 43 | 43 | |
| 44 | -	public function listen(callable $callback) { | |
| 45 | - $oldRenamePath = null; | |
| 46 | -		$this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { | |
| 47 | - $change = $this->mapChange($shareChange); | |
| 48 | -			if (!is_null($change)) { | |
| 49 | - return $callback($change); | |
| 50 | -			} else { | |
| 51 | - return true; | |
| 52 | - } | |
| 53 | - }); | |
| 54 | - } | |
| 44 | +    public function listen(callable $callback) { | |
| 45 | + $oldRenamePath = null; | |
| 46 | +        $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { | |
| 47 | + $change = $this->mapChange($shareChange); | |
| 48 | +            if (!is_null($change)) { | |
| 49 | + return $callback($change); | |
| 50 | +            } else { | |
| 51 | + return true; | |
| 52 | + } | |
| 53 | + }); | |
| 54 | + } | |
| 55 | 55 | |
| 56 | - /** | |
| 57 | - * Get all changes detected since the start of the notify process or the last call to getChanges | |
| 58 | - * | |
| 59 | - * @return IChange[] | |
| 60 | - */ | |
| 61 | -	public function getChanges() { | |
| 62 | - $shareChanges = $this->shareNotifyHandler->getChanges(); | |
| 63 | - $changes = []; | |
| 64 | -		foreach ($shareChanges as $shareChange) { | |
| 65 | - $change = $this->mapChange($shareChange); | |
| 66 | -			if ($change) { | |
| 67 | - $changes[] = $change; | |
| 68 | - } | |
| 69 | - } | |
| 70 | - return $changes; | |
| 71 | - } | |
| 56 | + /** | |
| 57 | + * Get all changes detected since the start of the notify process or the last call to getChanges | |
| 58 | + * | |
| 59 | + * @return IChange[] | |
| 60 | + */ | |
| 61 | +    public function getChanges() { | |
| 62 | + $shareChanges = $this->shareNotifyHandler->getChanges(); | |
| 63 | + $changes = []; | |
| 64 | +        foreach ($shareChanges as $shareChange) { | |
| 65 | + $change = $this->mapChange($shareChange); | |
| 66 | +            if ($change) { | |
| 67 | + $changes[] = $change; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + return $changes; | |
| 71 | + } | |
| 72 | 72 | |
| 73 | - /** | |
| 74 | - * Stop listening for changes | |
| 75 | - * | |
| 76 | - * Note that any pending changes will be discarded | |
| 77 | - */ | |
| 78 | -	public function stop() { | |
| 79 | - $this->shareNotifyHandler->stop(); | |
| 80 | - } | |
| 73 | + /** | |
| 74 | + * Stop listening for changes | |
| 75 | + * | |
| 76 | + * Note that any pending changes will be discarded | |
| 77 | + */ | |
| 78 | +    public function stop() { | |
| 79 | + $this->shareNotifyHandler->stop(); | |
| 80 | + } | |
| 81 | 81 | |
| 82 | - /** | |
| 83 | - * @param \Icewind\SMB\Change $change | |
| 84 | - * @return IChange|null | |
| 85 | - */ | |
| 86 | -	private function mapChange(\Icewind\SMB\Change $change) { | |
| 87 | - $path = $this->relativePath($change->getPath()); | |
| 88 | -		if (is_null($path)) { | |
| 89 | - return null; | |
| 90 | - } | |
| 91 | -		if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { | |
| 92 | - $this->oldRenamePath = $path; | |
| 93 | - return null; | |
| 94 | - } | |
| 95 | - $type = $this->mapNotifyType($change->getCode()); | |
| 96 | -		if (is_null($type)) { | |
| 97 | - return null; | |
| 98 | - } | |
| 99 | -		if ($type === IChange::RENAMED) { | |
| 100 | -			if (!is_null($this->oldRenamePath)) { | |
| 101 | - $result = new RenameChange($type, $this->oldRenamePath, $path); | |
| 102 | - $this->oldRenamePath = null; | |
| 103 | -			} else { | |
| 104 | - $result = null; | |
| 105 | - } | |
| 106 | -		} else { | |
| 107 | - $result = new Change($type, $path); | |
| 108 | - } | |
| 109 | - return $result; | |
| 110 | - } | |
| 82 | + /** | |
| 83 | + * @param \Icewind\SMB\Change $change | |
| 84 | + * @return IChange|null | |
| 85 | + */ | |
| 86 | +    private function mapChange(\Icewind\SMB\Change $change) { | |
| 87 | + $path = $this->relativePath($change->getPath()); | |
| 88 | +        if (is_null($path)) { | |
| 89 | + return null; | |
| 90 | + } | |
| 91 | +        if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { | |
| 92 | + $this->oldRenamePath = $path; | |
| 93 | + return null; | |
| 94 | + } | |
| 95 | + $type = $this->mapNotifyType($change->getCode()); | |
| 96 | +        if (is_null($type)) { | |
| 97 | + return null; | |
| 98 | + } | |
| 99 | +        if ($type === IChange::RENAMED) { | |
| 100 | +            if (!is_null($this->oldRenamePath)) { | |
| 101 | + $result = new RenameChange($type, $this->oldRenamePath, $path); | |
| 102 | + $this->oldRenamePath = null; | |
| 103 | +            } else { | |
| 104 | + $result = null; | |
| 105 | + } | |
| 106 | +        } else { | |
| 107 | + $result = new Change($type, $path); | |
| 108 | + } | |
| 109 | + return $result; | |
| 110 | + } | |
| 111 | 111 | |
| 112 | -	private function mapNotifyType($smbType) { | |
| 113 | -		switch ($smbType) { | |
| 114 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: | |
| 115 | - return IChange::ADDED; | |
| 116 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: | |
| 117 | - return IChange::REMOVED; | |
| 118 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: | |
| 119 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: | |
| 120 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: | |
| 121 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: | |
| 122 | - return IChange::MODIFIED; | |
| 123 | - case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: | |
| 124 | - return IChange::RENAMED; | |
| 125 | - default: | |
| 126 | - return null; | |
| 127 | - } | |
| 128 | - } | |
| 112 | +    private function mapNotifyType($smbType) { | |
| 113 | +        switch ($smbType) { | |
| 114 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: | |
| 115 | + return IChange::ADDED; | |
| 116 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: | |
| 117 | + return IChange::REMOVED; | |
| 118 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: | |
| 119 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: | |
| 120 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: | |
| 121 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: | |
| 122 | + return IChange::MODIFIED; | |
| 123 | + case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: | |
| 124 | + return IChange::RENAMED; | |
| 125 | + default: | |
| 126 | + return null; | |
| 127 | + } | |
| 128 | + } | |
| 129 | 129 | } | 
| @@ -29,14 +29,14 @@ | ||
| 29 | 29 | */ | 
| 30 | 30 |  trait DependencyTrait { | 
| 31 | 31 | |
| 32 | - /** | |
| 33 | - * Check if object is valid for use | |
| 34 | - * | |
| 35 | - * @return MissingDependency[] Unsatisfied dependencies | |
| 36 | - */ | |
| 37 | -	public function checkDependencies() { | |
| 38 | - return []; // no dependencies by default | |
| 39 | - } | |
| 32 | + /** | |
| 33 | + * Check if object is valid for use | |
| 34 | + * | |
| 35 | + * @return MissingDependency[] Unsatisfied dependencies | |
| 36 | + */ | |
| 37 | +    public function checkDependencies() { | |
| 38 | + return []; // no dependencies by default | |
| 39 | + } | |
| 40 | 40 | |
| 41 | 41 | } | 
| 42 | 42 | |
| @@ -23,12 +23,12 @@ | ||
| 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 | } |