protected function buildAllowedConceptScheme() { $loggedUser = OpenSKOS_Db_Table_Users::requireFromIdentity(); $userForSearch = $this->getUserForSearch(); $userOptions = $userForSearch->getSearchOptions($loggedUser['id'] != $userForSearch['id']); $allowedConceptSchemes = array(); if (isset($userOptions['searchProfileId'])) { $profilesModel = new OpenSKOS_Db_Table_SearchProfiles(); $profile = $profilesModel->find($userOptions['searchProfileId'])->current(); if (null !== $profile) { $profileOptions = $profile->getSearchOptions(); $apiClient = new Editor_Models_ApiClient(); $inCollections = array(); if (isset($profileOptions['collections'])) { $inCollections = $profileOptions['collections']; } $conceptSchemesInCollections = $apiClient->getAllConceptSchemeUriTitlesMap(null, $inCollections); if (!empty($profileOptions['conceptScheme'])) { foreach ($profileOptions['conceptScheme'] as $allowedConceptSchemeUri) { $allowedConceptSchemes[$allowedConceptSchemeUri] = $conceptSchemesInCollections[$allowedConceptSchemeUri]; } } else { // If we don't have concept schemes checked - then all concept schemes in the collections are allowed. $allowedConceptSchemes = $conceptSchemesInCollections; } } } $this->addElement('multiCheckbox', 'allowedConceptScheme', array('label' => _('Concept scheme'), 'multiOptions' => $allowedConceptSchemes)); return $this; }
/** * Gets the first of the search profiles for the user. * @return OpenSKOS_Db_Table_Row_SearchProfile */ public function getFirstDefaultSearchProfile() { if (!empty($this->defaultSearchProfileIds)) { $defaultSearchProfilesIds = explode(', ', $this->defaultSearchProfileIds); $profilesModels = new OpenSKOS_Db_Table_SearchProfiles(); return $profilesModels->find($defaultSearchProfilesIds[0])->current(); } else { return null; } }
private function _switchUserToSearchProfile(OpenSKOS_Db_Table_Row_User $user, $profileId) { //!TODO Consider movin inside the user object. if ($user->isAllowedToUseSearchProfile($profileId)) { $profilesModel = new OpenSKOS_Db_Table_SearchProfiles(); $profile = $profilesModel->find($profileId)->current(); if (null !== $profile) { $detailedSearchOptions = $profile->getSearchOptions(); } else { $detailedSearchOptions = Editor_Forms_SearchOptions::getDefaultSearchOptions(); } $detailedSearchOptions['searchProfileId'] = $profileId; $user->setSearchOptions($detailedSearchOptions); } }