/** * Check whether $record already exists in collection * * @param RecordInterface $record Record to be checked * * @return boolean true if it exists */ public function exists(RecordInterface $record) { foreach ($this->_records as $curRecord) { if ($curRecord->getRecordType() === $record->getRecordType() && $curRecord->getRecordID() === $record->getRecordID()) { return true; } } return false; }
static function getObjectStructure() { //Load Libraries for lookup values require_once ROOT_DIR . '/RecordDrivers/Interface.php'; $validSources = RecordInterface::getValidMoreDetailsSources(); $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'source' => array('property' => 'source', 'type' => 'enum', 'label' => 'Source', 'values' => $validSources, 'description' => 'The source of the data to display'), 'collapseByDefault' => array('property' => 'collapseByDefault', 'type' => 'checkbox', 'label' => 'Collapse By Default', 'description' => 'Whether or not the section should be collapsed by default', 'default' => true), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget. Lower weights are displayed to the left of the screen.', 'required' => true)); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
static function getObjectStructure() { global $user; //Load Libraries for lookup values $library = new Library(); $library->orderBy('displayName'); if ($user->hasRole('libraryAdmin')) { $homeLibrary = Library::getPatronHomeLibrary(); $library->libraryId = $homeLibrary->libraryId; } $library->find(); $libraryList = array(); while ($library->fetch()) { $libraryList[$library->libraryId] = $library->displayName; } require_once ROOT_DIR . '/RecordDrivers/Interface.php'; $validSources = RecordInterface::getValidMoreDetailsSources(); $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'source' => array('property' => 'source', 'type' => 'enum', 'label' => 'Source', 'values' => $validSources, 'description' => 'The source of the data to display'), 'collapseByDefault' => array('property' => 'collapseByDefault', 'type' => 'checkbox', 'label' => 'Collapse By Default', 'description' => 'Whether or not the section should be collapsed by default', 'default' => true), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget. Lower weights are displayed to the left of the screen.', 'required' => true)); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
function resetMoreDetailsToDefault() { $library = new Library(); $libraryId = $_REQUEST['id']; $library->libraryId = $libraryId; if ($library->find(true)) { $library->clearMoreDetailsOptions(); $defaultOptions = array(); require_once ROOT_DIR . '/RecordDrivers/Interface.php'; $defaultMoreDetailsOptions = RecordInterface::getDefaultMoreDetailsOptions(); $i = 0; foreach ($defaultMoreDetailsOptions as $source => $defaultState) { $optionObj = new LibraryMoreDetails(); $optionObj->libraryId = $libraryId; $optionObj->collapseByDefault = $defaultState == 'closed'; $optionObj->source = $source; $optionObj->weight = $i++; $defaultOptions[] = $optionObj; } $library->moreDetailsOptions = $defaultOptions; $library->update(); $_REQUEST['objectAction'] = 'edit'; } $structure = $this->getObjectStructure(); header("Location: /Admin/Libraries?objectAction=edit&id=" . $libraryId); }
public function filterAndSortMoreDetailsOptions($allOptions) { global $library; global $locationSingleton; $activeLocation = $locationSingleton->getActiveLocation(); $useDefault = true; if ($library && count($library->moreDetailsOptions) > 0) { $moreDetailsFilters = array(); $useDefault = false; /** @var LibraryMoreDetails $option */ foreach ($library->moreDetailsOptions as $option) { $moreDetailsFilters[$option->source] = $option->collapseByDefault ? 'closed' : 'open'; } } if ($activeLocation && count($activeLocation->moreDetailsOptions) > 0) { $moreDetailsFilters = array(); $useDefault = false; /** @var LocationMoreDetails $option */ foreach ($activeLocation->moreDetailsOptions as $option) { $moreDetailsFilters[$option->source] = $option->collapseByDefault ? 'closed' : 'open'; } } if ($useDefault) { $moreDetailsFilters = RecordInterface::getDefaultMoreDetailsOptions(); } $filteredMoreDetailsOptions = array(); foreach ($moreDetailsFilters as $option => $initialState) { if (array_key_exists($option, $allOptions)) { $detailOptions = $allOptions[$option]; $detailOptions['openByDefault'] = $initialState == 'open'; $filteredMoreDetailsOptions[$option] = $detailOptions; } } return $filteredMoreDetailsOptions; }