@@ -41,167 +41,167 @@ |
||
| 41 | 41 | use OCP\Share\IShare; |
| 42 | 42 | |
| 43 | 43 | class UserPlugin implements ISearchPlugin { |
| 44 | - /* @var bool */ |
|
| 45 | - protected $shareWithGroupOnly; |
|
| 46 | - protected $shareeEnumeration; |
|
| 47 | - protected $shareeEnumerationInGroupOnly; |
|
| 48 | - |
|
| 49 | - /** @var IConfig */ |
|
| 50 | - private $config; |
|
| 51 | - /** @var IGroupManager */ |
|
| 52 | - private $groupManager; |
|
| 53 | - /** @var IUserSession */ |
|
| 54 | - private $userSession; |
|
| 55 | - /** @var IUserManager */ |
|
| 56 | - private $userManager; |
|
| 57 | - |
|
| 58 | - public function __construct(IConfig $config, IUserManager $userManager, IGroupManager $groupManager, IUserSession $userSession) { |
|
| 59 | - $this->config = $config; |
|
| 60 | - |
|
| 61 | - $this->groupManager = $groupManager; |
|
| 62 | - $this->userSession = $userSession; |
|
| 63 | - $this->userManager = $userManager; |
|
| 64 | - |
|
| 65 | - $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; |
|
| 66 | - $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; |
|
| 67 | - $this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function search($search, $limit, $offset, ISearchResult $searchResult) { |
|
| 71 | - $result = ['wide' => [], 'exact' => []]; |
|
| 72 | - $users = []; |
|
| 73 | - $autoCompleteUsers = []; |
|
| 74 | - $hasMoreResults = false; |
|
| 75 | - |
|
| 76 | - $userGroups = []; |
|
| 77 | - if ($this->shareWithGroupOnly) { |
|
| 78 | - // Search in all the groups this user is part of |
|
| 79 | - $userGroups = $this->groupManager->getUserGroups($this->userSession->getUser()); |
|
| 80 | - foreach ($userGroups as $userGroup) { |
|
| 81 | - $usersInGroup = $userGroup->searchDisplayName($search, $limit, $offset); |
|
| 82 | - foreach ($usersInGroup as $user) { |
|
| 83 | - $users[$user->getUID()] = $user; |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - // Search in all users |
|
| 88 | - $usersTmp = $this->userManager->searchDisplayName($search, $limit, $offset); |
|
| 89 | - $currentUserGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser()); |
|
| 90 | - foreach ($usersTmp as $user) { |
|
| 91 | - if ($user->isEnabled()) { // Don't keep deactivated users |
|
| 92 | - $users[$user->getUID()] = $user; |
|
| 93 | - |
|
| 94 | - $addToWideResults = false; |
|
| 95 | - if ($this->shareeEnumeration && !$this->shareeEnumerationInGroupOnly) { |
|
| 96 | - $addToWideResults = true; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if ($this->shareeEnumerationInGroupOnly) { |
|
| 100 | - $commonGroups = array_intersect($currentUserGroups, $this->groupManager->getUserGroupIds($user)); |
|
| 101 | - if (!empty($commonGroups)) { |
|
| 102 | - $addToWideResults = true; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - if ($addToWideResults) { |
|
| 107 | - $autoCompleteUsers[] = [ |
|
| 108 | - 'label' => $user->getDisplayName(), |
|
| 109 | - 'value' => [ |
|
| 110 | - 'shareType' => IShare::TYPE_USER, |
|
| 111 | - 'shareWith' => (string)$user->getUID(), |
|
| 112 | - ], |
|
| 113 | - ]; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - $this->takeOutCurrentUser($users); |
|
| 120 | - |
|
| 121 | - if (!$this->shareeEnumeration || count($users) < $limit) { |
|
| 122 | - $hasMoreResults = true; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - $foundUserById = false; |
|
| 126 | - $lowerSearch = strtolower($search); |
|
| 127 | - foreach ($users as $uid => $user) { |
|
| 128 | - $userDisplayName = $user->getDisplayName(); |
|
| 129 | - $userEmail = $user->getEMailAddress(); |
|
| 130 | - $uid = (string) $uid; |
|
| 131 | - if ( |
|
| 132 | - strtolower($uid) === $lowerSearch || |
|
| 133 | - strtolower($userDisplayName) === $lowerSearch || |
|
| 134 | - strtolower($userEmail) === $lowerSearch |
|
| 135 | - ) { |
|
| 136 | - if (strtolower($uid) === $lowerSearch) { |
|
| 137 | - $foundUserById = true; |
|
| 138 | - } |
|
| 139 | - $result['exact'][] = [ |
|
| 140 | - 'label' => $userDisplayName, |
|
| 141 | - 'value' => [ |
|
| 142 | - 'shareType' => Share::SHARE_TYPE_USER, |
|
| 143 | - 'shareWith' => $uid, |
|
| 144 | - ], |
|
| 145 | - ]; |
|
| 146 | - } else { |
|
| 147 | - $result['wide'][] = [ |
|
| 148 | - 'label' => $userDisplayName, |
|
| 149 | - 'value' => [ |
|
| 150 | - 'shareType' => Share::SHARE_TYPE_USER, |
|
| 151 | - 'shareWith' => $uid, |
|
| 152 | - ], |
|
| 153 | - ]; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if ($offset === 0 && !$foundUserById) { |
|
| 158 | - // On page one we try if the search result has a direct hit on the |
|
| 159 | - // user id and if so, we add that to the exact match list |
|
| 160 | - $user = $this->userManager->get($search); |
|
| 161 | - if ($user instanceof IUser) { |
|
| 162 | - $addUser = true; |
|
| 163 | - |
|
| 164 | - if ($this->shareWithGroupOnly) { |
|
| 165 | - // Only add, if we have a common group |
|
| 166 | - $userGroupIds = array_map(function(IGroup $group) { |
|
| 167 | - return $group->getGID(); |
|
| 168 | - }, $userGroups); |
|
| 169 | - $commonGroups = array_intersect($userGroupIds, $this->groupManager->getUserGroupIds($user)); |
|
| 170 | - $addUser = !empty($commonGroups); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - if ($addUser) { |
|
| 174 | - $result['exact'][] = [ |
|
| 175 | - 'label' => $user->getDisplayName(), |
|
| 176 | - 'value' => [ |
|
| 177 | - 'shareType' => Share::SHARE_TYPE_USER, |
|
| 178 | - 'shareWith' => $user->getUID(), |
|
| 179 | - ], |
|
| 180 | - ]; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - // overwrite wide matches if they are limited |
|
| 186 | - if (!$this->shareeEnumeration || $this->shareeEnumerationInGroupOnly) { |
|
| 187 | - $result['wide'] = $autoCompleteUsers; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $type = new SearchResultType('users'); |
|
| 191 | - $searchResult->addResultSet($type, $result['wide'], $result['exact']); |
|
| 192 | - if (count($result['exact'])) { |
|
| 193 | - $searchResult->markExactIdMatch($type); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return $hasMoreResults; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - public function takeOutCurrentUser(array &$users) { |
|
| 200 | - $currentUser = $this->userSession->getUser(); |
|
| 201 | - if(!is_null($currentUser)) { |
|
| 202 | - if (isset($users[$currentUser->getUID()])) { |
|
| 203 | - unset($users[$currentUser->getUID()]); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 44 | + /* @var bool */ |
|
| 45 | + protected $shareWithGroupOnly; |
|
| 46 | + protected $shareeEnumeration; |
|
| 47 | + protected $shareeEnumerationInGroupOnly; |
|
| 48 | + |
|
| 49 | + /** @var IConfig */ |
|
| 50 | + private $config; |
|
| 51 | + /** @var IGroupManager */ |
|
| 52 | + private $groupManager; |
|
| 53 | + /** @var IUserSession */ |
|
| 54 | + private $userSession; |
|
| 55 | + /** @var IUserManager */ |
|
| 56 | + private $userManager; |
|
| 57 | + |
|
| 58 | + public function __construct(IConfig $config, IUserManager $userManager, IGroupManager $groupManager, IUserSession $userSession) { |
|
| 59 | + $this->config = $config; |
|
| 60 | + |
|
| 61 | + $this->groupManager = $groupManager; |
|
| 62 | + $this->userSession = $userSession; |
|
| 63 | + $this->userManager = $userManager; |
|
| 64 | + |
|
| 65 | + $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; |
|
| 66 | + $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; |
|
| 67 | + $this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function search($search, $limit, $offset, ISearchResult $searchResult) { |
|
| 71 | + $result = ['wide' => [], 'exact' => []]; |
|
| 72 | + $users = []; |
|
| 73 | + $autoCompleteUsers = []; |
|
| 74 | + $hasMoreResults = false; |
|
| 75 | + |
|
| 76 | + $userGroups = []; |
|
| 77 | + if ($this->shareWithGroupOnly) { |
|
| 78 | + // Search in all the groups this user is part of |
|
| 79 | + $userGroups = $this->groupManager->getUserGroups($this->userSession->getUser()); |
|
| 80 | + foreach ($userGroups as $userGroup) { |
|
| 81 | + $usersInGroup = $userGroup->searchDisplayName($search, $limit, $offset); |
|
| 82 | + foreach ($usersInGroup as $user) { |
|
| 83 | + $users[$user->getUID()] = $user; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + // Search in all users |
|
| 88 | + $usersTmp = $this->userManager->searchDisplayName($search, $limit, $offset); |
|
| 89 | + $currentUserGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser()); |
|
| 90 | + foreach ($usersTmp as $user) { |
|
| 91 | + if ($user->isEnabled()) { // Don't keep deactivated users |
|
| 92 | + $users[$user->getUID()] = $user; |
|
| 93 | + |
|
| 94 | + $addToWideResults = false; |
|
| 95 | + if ($this->shareeEnumeration && !$this->shareeEnumerationInGroupOnly) { |
|
| 96 | + $addToWideResults = true; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if ($this->shareeEnumerationInGroupOnly) { |
|
| 100 | + $commonGroups = array_intersect($currentUserGroups, $this->groupManager->getUserGroupIds($user)); |
|
| 101 | + if (!empty($commonGroups)) { |
|
| 102 | + $addToWideResults = true; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + if ($addToWideResults) { |
|
| 107 | + $autoCompleteUsers[] = [ |
|
| 108 | + 'label' => $user->getDisplayName(), |
|
| 109 | + 'value' => [ |
|
| 110 | + 'shareType' => IShare::TYPE_USER, |
|
| 111 | + 'shareWith' => (string)$user->getUID(), |
|
| 112 | + ], |
|
| 113 | + ]; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + $this->takeOutCurrentUser($users); |
|
| 120 | + |
|
| 121 | + if (!$this->shareeEnumeration || count($users) < $limit) { |
|
| 122 | + $hasMoreResults = true; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $foundUserById = false; |
|
| 126 | + $lowerSearch = strtolower($search); |
|
| 127 | + foreach ($users as $uid => $user) { |
|
| 128 | + $userDisplayName = $user->getDisplayName(); |
|
| 129 | + $userEmail = $user->getEMailAddress(); |
|
| 130 | + $uid = (string) $uid; |
|
| 131 | + if ( |
|
| 132 | + strtolower($uid) === $lowerSearch || |
|
| 133 | + strtolower($userDisplayName) === $lowerSearch || |
|
| 134 | + strtolower($userEmail) === $lowerSearch |
|
| 135 | + ) { |
|
| 136 | + if (strtolower($uid) === $lowerSearch) { |
|
| 137 | + $foundUserById = true; |
|
| 138 | + } |
|
| 139 | + $result['exact'][] = [ |
|
| 140 | + 'label' => $userDisplayName, |
|
| 141 | + 'value' => [ |
|
| 142 | + 'shareType' => Share::SHARE_TYPE_USER, |
|
| 143 | + 'shareWith' => $uid, |
|
| 144 | + ], |
|
| 145 | + ]; |
|
| 146 | + } else { |
|
| 147 | + $result['wide'][] = [ |
|
| 148 | + 'label' => $userDisplayName, |
|
| 149 | + 'value' => [ |
|
| 150 | + 'shareType' => Share::SHARE_TYPE_USER, |
|
| 151 | + 'shareWith' => $uid, |
|
| 152 | + ], |
|
| 153 | + ]; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if ($offset === 0 && !$foundUserById) { |
|
| 158 | + // On page one we try if the search result has a direct hit on the |
|
| 159 | + // user id and if so, we add that to the exact match list |
|
| 160 | + $user = $this->userManager->get($search); |
|
| 161 | + if ($user instanceof IUser) { |
|
| 162 | + $addUser = true; |
|
| 163 | + |
|
| 164 | + if ($this->shareWithGroupOnly) { |
|
| 165 | + // Only add, if we have a common group |
|
| 166 | + $userGroupIds = array_map(function(IGroup $group) { |
|
| 167 | + return $group->getGID(); |
|
| 168 | + }, $userGroups); |
|
| 169 | + $commonGroups = array_intersect($userGroupIds, $this->groupManager->getUserGroupIds($user)); |
|
| 170 | + $addUser = !empty($commonGroups); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + if ($addUser) { |
|
| 174 | + $result['exact'][] = [ |
|
| 175 | + 'label' => $user->getDisplayName(), |
|
| 176 | + 'value' => [ |
|
| 177 | + 'shareType' => Share::SHARE_TYPE_USER, |
|
| 178 | + 'shareWith' => $user->getUID(), |
|
| 179 | + ], |
|
| 180 | + ]; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + // overwrite wide matches if they are limited |
|
| 186 | + if (!$this->shareeEnumeration || $this->shareeEnumerationInGroupOnly) { |
|
| 187 | + $result['wide'] = $autoCompleteUsers; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $type = new SearchResultType('users'); |
|
| 191 | + $searchResult->addResultSet($type, $result['wide'], $result['exact']); |
|
| 192 | + if (count($result['exact'])) { |
|
| 193 | + $searchResult->markExactIdMatch($type); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return $hasMoreResults; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + public function takeOutCurrentUser(array &$users) { |
|
| 200 | + $currentUser = $this->userSession->getUser(); |
|
| 201 | + if(!is_null($currentUser)) { |
|
| 202 | + if (isset($users[$currentUser->getUID()])) { |
|
| 203 | + unset($users[$currentUser->getUID()]); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -31,75 +31,75 @@ |
||
| 31 | 31 | use OCP\Share; |
| 32 | 32 | |
| 33 | 33 | class Search implements ISearch { |
| 34 | - /** @var IContainer */ |
|
| 35 | - private $c; |
|
| 34 | + /** @var IContainer */ |
|
| 35 | + private $c; |
|
| 36 | 36 | |
| 37 | - protected $pluginList = []; |
|
| 37 | + protected $pluginList = []; |
|
| 38 | 38 | |
| 39 | - public function __construct(IContainer $c) { |
|
| 40 | - $this->c = $c; |
|
| 41 | - } |
|
| 39 | + public function __construct(IContainer $c) { |
|
| 40 | + $this->c = $c; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param string $search |
|
| 45 | - * @param array $shareTypes |
|
| 46 | - * @param bool $lookup |
|
| 47 | - * @param int|null $limit |
|
| 48 | - * @param int|null $offset |
|
| 49 | - * @return array |
|
| 50 | - * @throws \OCP\AppFramework\QueryException |
|
| 51 | - */ |
|
| 52 | - public function search($search, array $shareTypes, $lookup, $limit, $offset) { |
|
| 53 | - $hasMoreResults = false; |
|
| 43 | + /** |
|
| 44 | + * @param string $search |
|
| 45 | + * @param array $shareTypes |
|
| 46 | + * @param bool $lookup |
|
| 47 | + * @param int|null $limit |
|
| 48 | + * @param int|null $offset |
|
| 49 | + * @return array |
|
| 50 | + * @throws \OCP\AppFramework\QueryException |
|
| 51 | + */ |
|
| 52 | + public function search($search, array $shareTypes, $lookup, $limit, $offset) { |
|
| 53 | + $hasMoreResults = false; |
|
| 54 | 54 | |
| 55 | - /** @var ISearchResult $searchResult */ |
|
| 56 | - $searchResult = $this->c->resolve(SearchResult::class); |
|
| 55 | + /** @var ISearchResult $searchResult */ |
|
| 56 | + $searchResult = $this->c->resolve(SearchResult::class); |
|
| 57 | 57 | |
| 58 | - foreach ($shareTypes as $type) { |
|
| 59 | - if(!isset($this->pluginList[$type])) { |
|
| 60 | - continue; |
|
| 61 | - } |
|
| 62 | - foreach ($this->pluginList[$type] as $plugin) { |
|
| 63 | - /** @var ISearchPlugin $searchPlugin */ |
|
| 64 | - $searchPlugin = $this->c->resolve($plugin); |
|
| 65 | - $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); |
|
| 66 | - } |
|
| 67 | - } |
|
| 58 | + foreach ($shareTypes as $type) { |
|
| 59 | + if(!isset($this->pluginList[$type])) { |
|
| 60 | + continue; |
|
| 61 | + } |
|
| 62 | + foreach ($this->pluginList[$type] as $plugin) { |
|
| 63 | + /** @var ISearchPlugin $searchPlugin */ |
|
| 64 | + $searchPlugin = $this->c->resolve($plugin); |
|
| 65 | + $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - // Get from lookup server, not a separate share type |
|
| 70 | - if ($lookup) { |
|
| 71 | - $searchPlugin = $this->c->resolve(LookupPlugin::class); |
|
| 72 | - $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); |
|
| 73 | - } |
|
| 69 | + // Get from lookup server, not a separate share type |
|
| 70 | + if ($lookup) { |
|
| 71 | + $searchPlugin = $this->c->resolve(LookupPlugin::class); |
|
| 72 | + $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - // sanitizing, could go into the plugins as well |
|
| 75 | + // sanitizing, could go into the plugins as well |
|
| 76 | 76 | |
| 77 | - // if we have a exact match, either for the federated cloud id or for the |
|
| 78 | - // email address we only return the exact match. It is highly unlikely |
|
| 79 | - // that the exact same email address and federated cloud id exists |
|
| 80 | - $emailType = new SearchResultType('emails'); |
|
| 81 | - $remoteType = new SearchResultType('remotes'); |
|
| 82 | - if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) { |
|
| 83 | - $searchResult->unsetResult($remoteType); |
|
| 84 | - } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) { |
|
| 85 | - $searchResult->unsetResult($emailType); |
|
| 86 | - } |
|
| 77 | + // if we have a exact match, either for the federated cloud id or for the |
|
| 78 | + // email address we only return the exact match. It is highly unlikely |
|
| 79 | + // that the exact same email address and federated cloud id exists |
|
| 80 | + $emailType = new SearchResultType('emails'); |
|
| 81 | + $remoteType = new SearchResultType('remotes'); |
|
| 82 | + if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) { |
|
| 83 | + $searchResult->unsetResult($remoteType); |
|
| 84 | + } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) { |
|
| 85 | + $searchResult->unsetResult($emailType); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // if we have an exact local user match, there is no need to show the remote and email matches |
|
| 89 | - $userType = new SearchResultType('users'); |
|
| 90 | - if($searchResult->hasExactIdMatch($userType)) { |
|
| 91 | - $searchResult->unsetResult($remoteType); |
|
| 92 | - $searchResult->unsetResult($emailType); |
|
| 93 | - } |
|
| 88 | + // if we have an exact local user match, there is no need to show the remote and email matches |
|
| 89 | + $userType = new SearchResultType('users'); |
|
| 90 | + if($searchResult->hasExactIdMatch($userType)) { |
|
| 91 | + $searchResult->unsetResult($remoteType); |
|
| 92 | + $searchResult->unsetResult($emailType); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - return [$searchResult->asArray(), (bool)$hasMoreResults]; |
|
| 96 | - } |
|
| 95 | + return [$searchResult->asArray(), (bool)$hasMoreResults]; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - public function registerPlugin(array $pluginInfo) { |
|
| 99 | - $shareType = constant(Share::class . '::' . $pluginInfo['shareType']); |
|
| 100 | - if($shareType === null) { |
|
| 101 | - throw new \InvalidArgumentException('Provided ShareType is invalid'); |
|
| 102 | - } |
|
| 103 | - $this->pluginList[$shareType][] = $pluginInfo['class']; |
|
| 104 | - } |
|
| 98 | + public function registerPlugin(array $pluginInfo) { |
|
| 99 | + $shareType = constant(Share::class . '::' . $pluginInfo['shareType']); |
|
| 100 | + if($shareType === null) { |
|
| 101 | + throw new \InvalidArgumentException('Provided ShareType is invalid'); |
|
| 102 | + } |
|
| 103 | + $this->pluginList[$shareType][] = $pluginInfo['class']; |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $searchResult = $this->c->resolve(SearchResult::class); |
| 57 | 57 | |
| 58 | 58 | foreach ($shareTypes as $type) { |
| 59 | - if(!isset($this->pluginList[$type])) { |
|
| 59 | + if (!isset($this->pluginList[$type])) { |
|
| 60 | 60 | continue; |
| 61 | 61 | } |
| 62 | 62 | foreach ($this->pluginList[$type] as $plugin) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // that the exact same email address and federated cloud id exists |
| 80 | 80 | $emailType = new SearchResultType('emails'); |
| 81 | 81 | $remoteType = new SearchResultType('remotes'); |
| 82 | - if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) { |
|
| 82 | + if ($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) { |
|
| 83 | 83 | $searchResult->unsetResult($remoteType); |
| 84 | 84 | } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) { |
| 85 | 85 | $searchResult->unsetResult($emailType); |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | // if we have an exact local user match, there is no need to show the remote and email matches |
| 89 | 89 | $userType = new SearchResultType('users'); |
| 90 | - if($searchResult->hasExactIdMatch($userType)) { |
|
| 90 | + if ($searchResult->hasExactIdMatch($userType)) { |
|
| 91 | 91 | $searchResult->unsetResult($remoteType); |
| 92 | 92 | $searchResult->unsetResult($emailType); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - return [$searchResult->asArray(), (bool)$hasMoreResults]; |
|
| 95 | + return [$searchResult->asArray(), (bool) $hasMoreResults]; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public function registerPlugin(array $pluginInfo) { |
| 99 | - $shareType = constant(Share::class . '::' . $pluginInfo['shareType']); |
|
| 100 | - if($shareType === null) { |
|
| 99 | + $shareType = constant(Share::class.'::'.$pluginInfo['shareType']); |
|
| 100 | + if ($shareType === null) { |
|
| 101 | 101 | throw new \InvalidArgumentException('Provided ShareType is invalid'); |
| 102 | 102 | } |
| 103 | 103 | $this->pluginList[$shareType][] = $pluginInfo['class']; |