Exemplo n.º 1
0
 function CancelRequest()
 {
     global $user;
     if (!$user) {
         return array('success' => false, 'error' => 'Could not cancel the request, you must be logged in to cancel the request.');
     } elseif (!isset($_REQUEST['id'])) {
         return array('success' => false, 'error' => 'Could not cancel the request, no id provided.');
     } else {
         $id = $_REQUEST['id'];
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->id = $id;
         $materialsRequest->createdBy = $user->id;
         if ($materialsRequest->find(true)) {
             //get the correct status to set based on the user's home library
             $homeLibrary = Library::getPatronHomeLibrary();
             $cancelledStatus = new MaterialsRequestStatus();
             $cancelledStatus->isPatronCancel = 1;
             $cancelledStatus->libraryId = $homeLibrary->libraryId;
             $cancelledStatus->find(true);
             $materialsRequest->dateUpdated = time();
             $materialsRequest->status = $cancelledStatus->id;
             if ($materialsRequest->update()) {
                 return array('success' => true);
             } else {
                 return array('success' => false, 'error' => 'Could not cancel the request, error during update.');
             }
         } else {
             return array('success' => false, 'error' => 'Could not cancel the request, could not find a request for the provided id.');
         }
     }
 }
 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 . '/sys/Browse/BrowseCategory.php';
     $browseCategories = new BrowseCategory();
     $browseCategories->orderBy('label');
     $browseCategories->find();
     $browseCategoryList = array();
     while ($browseCategories->fetch()) {
         $browseCategoryList[$browseCategories->textId] = $browseCategories->label . " ({$browseCategories->textId})";
     }
     $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'), 'browseCategoryTextId' => array('property' => 'browseCategoryTextId', 'type' => 'enum', 'values' => $browseCategoryList, 'label' => 'Browse Category', 'description' => 'The browse category to display '), '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 isValidForUser($locationCode, $eContentFieldData)
 {
     $sharing = $this->getSharing($locationCode, $eContentFieldData);
     if ($sharing == 'shared') {
         return true;
     } else {
         if ($sharing == 'library') {
             $searchLibrary = Library::getSearchLibrary();
             if ($searchLibrary == null || strlen($searchLibrary->ilsCode) > 0 && strpos($locationCode, $searchLibrary->ilsCode) === 0) {
                 global $user;
                 if ($user) {
                     $patronHomeLibrary = Library::getPatronHomeLibrary();
                     return $patronHomeLibrary == null || strlen($patronHomeLibrary->ilsCode) > 0 && strpos($locationCode, $patronHomeLibrary->ilsCode) === 0;
                 } else {
                     return true;
                 }
             } else {
                 return false;
             }
         } else {
             //Just share with the specific location
             $searchLocation = Location::getSearchLocation();
             if (!$searchLocation) {
                 return true;
             } elseif (strpos($locationCode, $searchLocation->code) === 0) {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
Exemplo n.º 4
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     $source = $_REQUEST['source'];
     $sourceId = $_REQUEST['id'];
     $existingWidget = isset($_REQUEST['widgetId']) ? $_REQUEST['widgetId'] : -1;
     $widgetName = isset($_REQUEST['widgetName']) ? $_REQUEST['widgetName'] : '';
     if ($existingWidget == -1) {
         $widget = new ListWidget();
         $widget->name = $widgetName;
         if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
             //Get all widgets for the library
             $userLibrary = Library::getPatronHomeLibrary();
             $widget->libraryId = $userLibrary->libraryId;
         } else {
             $widget->libraryId = -1;
         }
         $widget->customCss = '';
         $widget->autoRotate = 0;
         $widget->description = '';
         $widget->showTitleDescriptions = 1;
         $widget->onSelectCallback = '';
         $widget->fullListLink = '';
         $widget->listDisplayType = 'tabs';
         $widget->showMultipleTitles = 1;
         $widget->insert();
     } else {
         $widget = new ListWidget();
         $widget->id = $existingWidget;
         $widget->find(true);
     }
     //Make sure to save the search
     if ($source == 'search') {
         $searchObject = new SearchEntry();
         $searchObject->id = $sourceId;
         $searchObject->find(true);
         $searchObject->saved = 1;
         $searchObject->update();
     }
     //Add the list to the widget
     $widgetList = new ListWidgetList();
     $widgetList->listWidgetId = $widget->id;
     $widgetList->displayFor = 'all';
     $widgetList->source = "{$source}:{$sourceId}";
     $widgetList->name = $widgetName;
     $widgetList->weight = 0;
     $widgetList->insert();
     //Redirect to the widget
     header("Location: {$path}/Admin/ListWidgets?objectAction=view&id={$widget->id}");
 }
Exemplo n.º 5
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     global $analytics;
     $interface->setPageTitle('eContent Support');
     if (isset($_REQUEST['submit'])) {
         //E-mail the library with details of the support request
         require_once ROOT_DIR . '/sys/Mailer.php';
         $mail = new VuFindMailer();
         $userLibrary = Library::getPatronHomeLibrary();
         if ($userLibrary == null) {
             $to = $configArray['Site']['email'];
         } else {
             $to = $userLibrary->eContentSupportAddress;
         }
         $name = $_REQUEST['name'];
         $interface->assign('bookAuthor', $_REQUEST['bookAuthor']);
         $interface->assign('device', $_REQUEST['device']);
         $interface->assign('format', $_REQUEST['format']);
         $interface->assign('operatingSystem', $_REQUEST['operatingSystem']);
         $interface->assign('problem', $_REQUEST['problem']);
         $subject = 'eContent Support Request from ' . $name;
         $from = $_REQUEST['email'];
         $body = $interface->fetch('Help/eContentSupportEmail.tpl');
         if ($mail->send($to, $configArray['Site']['email'], $subject, $body, $from)) {
             $analytics->addEvent("Emails", "eContent Support Succeeded", $_REQUEST['device'], $_REQUEST['format'], $_REQUEST['operatingSystem']);
             echo json_encode(array('title' => "Support Request Sent", 'message' => "<p>Your request was sent to our support team.  We will respond to your request as quickly as possible.</p><p>Thank you for using the catalog.</p>"));
         } else {
             $analytics->addEvent("Emails", "eContent Support Failed", $_REQUEST['device'], $_REQUEST['format'], $_REQUEST['operatingSystem']);
             echo json_encode(array('title' => "Support Request Not Sent", 'message' => "<p>We're sorry, but your request could not be submitted to our support team at this time.</p><p>Please try again later.</p>"));
         }
     } else {
         if (isset($_REQUEST['lightbox'])) {
             $interface->assign('lightbox', true);
             if ($user) {
                 $interface->assign('name', $user->cat_username);
                 $interface->assign('email', $user->email);
             }
             $result = array('title' => 'eContent Support', 'modalBody' => $interface->fetch('Help/eContentSupport.tpl'), 'modalButtons' => "<button class='btn btn-sm btn-primary' onclick='return VuFind.EContent.submitHelpForm();'>Submit</button>");
             echo json_encode($result);
         } else {
             $interface->assign('lightbox', false);
             $interface->setTemplate('eContentSupport.tpl');
             $interface->assign('sidebar', 'Search/home-sidebar.tpl');
             $interface->display('layout.tpl');
         }
     }
 }
Exemplo n.º 6
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     global $analytics;
     $interface->setPageTitle('eContent Support');
     if (isset($_REQUEST['submit'])) {
         //E-mail the library with details of the support request
         require_once ROOT_DIR . '/sys/Mailer.php';
         $mail = new VuFindMailer();
         $userLibrary = Library::getPatronHomeLibrary();
         if ($userLibrary == null) {
             $to = $configArray['Site']['email'];
         } else {
             $to = $userLibrary->eContentSupportAddress;
         }
         $name = $_REQUEST['name'];
         $interface->assign('bookAuthor', $_REQUEST['bookAuthor']);
         $interface->assign('device', $_REQUEST['device']);
         $interface->assign('format', $_REQUEST['format']);
         $interface->assign('operatingSystem', $_REQUEST['operatingSystem']);
         $interface->assign('problem', $_REQUEST['problem']);
         $subject = 'eContent Support Request from ' . $name;
         $from = $_REQUEST['email'];
         $body = $interface->fetch('Help/eContentSupportEmail.tpl');
         if ($mail->send($to, $configArray['Site']['email'], $subject, $body, $from)) {
             $analytics->addEvent("Emails", "eContent Support Succeeded", $_REQUEST['device'], $_REQUEST['format'], $_REQUEST['operatingSystem']);
             echo "<p>Your request was sent to our support team.  We will respond to your request as quickly as possible.</p><p>Thank you for using the catalog.</p><input type='button' onclick='hideLightbox()' value='Close'/>";
         } else {
             $analytics->addEvent("Emails", "eContent Support Failed", $_REQUEST['device'], $_REQUEST['format'], $_REQUEST['operatingSystem']);
             echo "<p>We're sorry, but your request could not be submitted to our support team at this time.</p><p>Please try again later.</p><input type='button' onclick='hideLightbox()' value='Close' />";
         }
     } else {
         if (isset($_REQUEST['lightbox'])) {
             if ($user) {
                 $interface->assign('name', $user->cat_username);
                 $interface->assign('email', $user->email);
             }
             $interface->assign('popupTitle', 'eContent Support');
             $popupContent = $interface->fetch('Help/eContentSupport.tpl');
             $interface->assign('popupContent', $popupContent);
             $interface->display('popup-wrapper.tpl');
         } else {
             $interface->setTemplate('eContentSupport.tpl');
             $interface->display('layout.tpl');
         }
     }
 }
Exemplo n.º 7
0
 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;
     }
     //Look lookup information for display in the user interface
     $location = new Location();
     $location->orderBy('displayName');
     $location->find();
     $locationList = array();
     $locationLookupList = array();
     $locationLookupList[-1] = '<No Nearby Location>';
     while ($location->fetch()) {
         $locationLookupList[$location->locationId] = $location->displayName;
         $locationList[$location->locationId] = clone $location;
     }
     // get the structure for the location's hours
     $hoursStructure = LocationHours::getObjectStructure();
     // we don't want to make the locationId property editable
     // because it is associated with this location only
     unset($hoursStructure['locationId']);
     $facetSettingStructure = LocationFacetSetting::getObjectStructure();
     unset($facetSettingStructure['weight']);
     unset($facetSettingStructure['locationId']);
     unset($facetSettingStructure['numEntriesToShowByDefault']);
     unset($facetSettingStructure['showAsDropDown']);
     //unset($facetSettingStructure['sortMode']);
     $structure = array(array('property' => 'code', 'type' => 'text', 'label' => 'Code', 'description' => 'The code for use when communicating with Millennium'), array('property' => 'displayName', 'type' => 'text', 'label' => 'Display Name', 'description' => 'The full name of the location for display to the user', 'size' => '40'), array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), array('property' => 'extraLocationCodesToInclude', 'type' => 'text', 'label' => 'Extra Locations To Include', 'description' => 'A list of other location codes to include in this location for indexing special collections, juvenile collections, etc.', 'size' => '40', 'hideInLists' => true), array('property' => 'nearbyLocation1', 'type' => 'enum', 'values' => $locationLookupList, 'label' => 'Nearby Location 1', 'description' => 'A secondary location which is nearby and could be used for pickup of materials.', 'hideInLists' => true), array('property' => 'nearbyLocation2', 'type' => 'enum', 'values' => $locationLookupList, 'label' => 'Nearby Location 2', 'description' => 'A tertiary location which is nearby and could be used for pickup of materials.', 'hideInLists' => true), array('property' => 'automaticTimeoutLength', 'type' => 'integer', 'label' => 'Automatic Timeout Length (logged in)', 'description' => 'The length of time before the user is automatically logged out in seconds.', 'size' => '8', 'hideInLists' => true), array('property' => 'automaticTimeoutLengthLoggedOut', 'type' => 'integer', 'label' => 'Automatic Timeout Length (logged out)', 'description' => 'The length of time before the catalog resets to the home page set to 0 to disable.', 'size' => '8', 'hideInLists' => true), array('property' => 'displaySection', 'type' => 'section', 'label' => 'Basic Display', 'hideInLists' => true, 'properties' => array(array('property' => 'homeLink', 'type' => 'text', 'label' => 'Home Link', 'description' => 'The location to send the user when they click on the home button or logo.  Use default or blank to go back to the vufind home location.', 'hideInLists' => true, 'size' => '40'), array('property' => 'homePageWidgetId', 'type' => 'integer', 'label' => 'Home Page Widget Id', 'description' => 'An id for the list widget to display on the home page', 'hideInLists' => true), array('property' => 'footerTemplate', 'type' => 'text', 'label' => 'Footer Template', 'description' => 'The name of the footer file to display in the regular interface when scoped to a single school.  Use default to display the default footer', 'hideInLists' => true, 'default' => 'default'))), array('property' => 'ilsSection', 'type' => 'section', 'label' => 'ILS/Account Integration', 'hideInLists' => true, 'properties' => array(array('property' => 'holdingBranchLabel', 'type' => 'text', 'label' => 'Holding Branch Label', 'description' => 'The label used within the holdings table in Millennium'), array('property' => 'scope', 'type' => 'text', 'label' => 'Scope', 'description' => 'The scope for the system in Millennium to refine holdings to the branch.  If there is no scope defined for the branch, this can be set to 0.'), array('property' => 'useScope', 'type' => 'checkbox', 'label' => 'Use Scope?', 'description' => 'Whether or not the scope should be used when displaying holdings.', 'hideInLists' => true), array('property' => 'defaultPType', 'type' => 'text', 'label' => 'Default P-Type', 'description' => 'The P-Type to use when accessing a subdomain if the patron is not logged in.  Use -1 to use the library default PType.'), array('property' => 'validHoldPickupBranch', 'type' => 'checkbox', 'label' => 'Valid Hold Pickup Branch?', 'description' => 'Determines if the location can be used as a pickup location if it is not the patrons home location or the location they are in.', 'hideInLists' => true), array('property' => 'showHoldButton', 'type' => 'checkbox', 'label' => 'Show Hold Button', 'description' => 'Whether or not the hold button is displayed so patrons can place holds on items', 'hideInLists' => true), array('property' => 'ptypesToAllowRenewals', 'type' => 'text', 'label' => 'PTypes that can renew', 'description' => 'A list of P-Types that can renew items or * to allow all P-Types to renew items.', 'hideInLists' => true), array('property' => 'suppressHoldings', 'type' => 'checkbox', 'label' => 'Suppress Holdings', 'description' => 'Whether or not all items for the title should be suppressed', 'hideInLists' => true))), array('property' => 'searchingSection', 'type' => 'section', 'label' => 'Searching', 'hideInLists' => true, 'properties' => array(array('property' => 'facetLabel', 'type' => 'text', 'label' => 'Facet Label', 'description' => 'The label of the facet that identifies this location.', 'hideInLists' => true, 'size' => '40'), array('property' => 'restrictSearchByLocation', 'type' => 'checkbox', 'label' => 'Restrict Search By Location', 'description' => 'Whether or not search results should only include titles from this location', 'hideInLists' => true), array('property' => 'includeDigitalCollection', 'type' => 'checkbox', 'label' => 'Include Digital Collection', 'description' => 'Whether or not titles from the digital collection should be included in searches', 'hideInLists' => true), array('property' => 'boostByLocation', 'type' => 'checkbox', 'label' => 'Boost By Location', 'description' => 'Whether or not boosting of titles owned by this location should be applied', 'hideInLists' => true), array('property' => 'recordsToBlackList', 'type' => 'textarea', 'label' => 'Records to deaccession', 'description' => 'A list of records to deaccession (hide) in search results.  Enter one record per line.', 'hideInLists' => true), array('property' => 'repeatSearchOption', 'type' => 'enum', 'values' => array('none' => 'None', 'librarySystem' => 'Library System', 'marmot' => 'Marmot'), 'label' => 'Repeat Search Options', 'description' => 'Where to allow repeating search. Valid options are: none, librarySystem, marmot, all'), array('property' => 'repeatInProspector', 'type' => 'checkbox', 'label' => 'Repeat In Prospector', 'description' => 'Turn on to allow repeat search in Prospector functionality.', 'hideInLists' => true), array('property' => 'repeatInWorldCat', 'type' => 'checkbox', 'label' => 'Repeat In WorldCat', 'description' => 'Turn on to allow repeat search in WorldCat functionality.', 'hideInLists' => true), array('property' => 'repeatInOverdrive', 'type' => 'checkbox', 'label' => 'Repeat In Overdrive', 'description' => 'Turn on to allow repeat search in Overdrive functionality.', 'hideInLists' => true), array('property' => 'systemsToRepeatIn', 'type' => 'text', 'label' => 'Systems To Repeat In', 'description' => 'A list of library codes that you would like to repeat search in separated by pipes |.', 'hideInLists' => true))), array('property' => 'enrichmentSection', 'type' => 'section', 'label' => 'Catalog Enrichment', 'hideInLists' => true, 'properties' => array(array('property' => 'showAmazonReviews', 'type' => 'checkbox', 'label' => 'Show Amazon Reviews', 'description' => 'Whether or not reviews from Amazon are displayed on the full record page.', 'hideInLists' => true), array('property' => 'showStandardReviews', 'type' => 'checkbox', 'label' => 'Show Standard Reviews', 'description' => 'Whether or not reviews from Content Cafe/Syndetics are displayed on the full record page.', 'hideInLists' => true))), array('property' => 'hours', 'type' => 'oneToMany', 'keyThis' => 'locationId', 'keyOther' => 'locationId', 'subObjectType' => 'LocationHours', 'structure' => $hoursStructure, 'label' => 'Hours', 'description' => 'Library Hours', 'sortable' => false, 'storeDb' => true), 'facets' => array('property' => 'facets', 'type' => 'oneToMany', 'label' => 'Facets', 'description' => 'A list of facets to display in search results', 'keyThis' => 'locationId', 'keyOther' => 'locationId', 'subObjectType' => 'LocationFacetSetting', 'structure' => $facetSettingStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => true, 'canEdit' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Exemplo n.º 8
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     $showOpen = true;
     if (isset($_REQUEST['requestsToShow']) && $_REQUEST['requestsToShow'] == 'allRequests') {
         $showOpen = false;
     }
     $interface->assign('showOpen', $showOpen);
     $defaultStatus = new MaterialsRequestStatus();
     $defaultStatus->isDefault = 1;
     $defaultStatus->libraryId = Library::getPatronHomeLibrary()->libraryId;
     $defaultStatus->find(true);
     $interface->assign('defaultStatus', $defaultStatus->id);
     //Get a list of all materials requests for the user
     $allRequests = array();
     if ($user) {
         $materialsRequests = new MaterialsRequest();
         $materialsRequests->createdBy = $user->id;
         $materialsRequests->orderBy('title, dateCreated');
         $statusQuery = new MaterialsRequestStatus();
         if ($showOpen) {
             $homeLibrary = Library::getPatronHomeLibrary();
             $statusQuery->libraryId = $homeLibrary->libraryId;
             $statusQuery->isOpen = 1;
         }
         $materialsRequests->joinAdd($statusQuery);
         $materialsRequests->selectAdd();
         $materialsRequests->selectAdd('materials_request.*, description as statusLabel');
         $materialsRequests->find();
         while ($materialsRequests->fetch()) {
             $allRequests[] = clone $materialsRequests;
         }
     } else {
         header('Location: ' . $configArray['Site']['path'] . '/MyResearch/Home?followupModule=MaterialsRequest&followupAction=MyRequests');
         //$interface->assign('error', "You must be logged in to view your requests.");
     }
     $interface->assign('allRequests', $allRequests);
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('myMaterialRequests.tpl');
     $interface->setPageTitle('My Materials Requests');
     $interface->display('layout.tpl');
 }
 static function getObjectStructure()
 {
     global $user;
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     }
     $library->find();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = parent::getObjectStructure();
     $structure['libraryId'] = array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'The id of a library');
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
 function getObjectStructure()
 {
     global $user;
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     } else {
         $libraryList[-1] = 'Default';
     }
     $library->find();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the libary within the database'), 'description' => array('property' => 'description', 'type' => 'text', 'size' => 80, 'label' => 'Description', 'description' => 'A unique name for the Status'), 'isDefault' => array('property' => 'isDefault', 'type' => 'checkbox', 'label' => 'Default Status?', 'description' => 'Whether or not this status is the default status to apply to new requests'), 'isPatronCancel' => array('property' => 'isPatronCancel', 'type' => 'checkbox', 'label' => 'Set When Patron Cancels?', 'description' => 'Whether or not this status should be set when the patron cancels their request'), 'isOpen' => array('property' => 'isOpen', 'type' => 'checkbox', 'label' => 'Open Status?', 'description' => 'Whether or not this status needs further processing'), 'sendEmailToPatron' => array('property' => 'sendEmailToPatron', 'type' => 'checkbox', 'label' => 'Send Email To Patron?', 'description' => 'Whether or not an email should be sent to the patron when this status is set'), 'emailTemplate' => array('property' => 'emailTemplate', 'type' => 'textarea', 'rows' => 6, 'cols' => 60, 'label' => 'Email Template', 'description' => 'The template to use when sending emails to the user', 'hideInLists' => true), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'The id of a library'));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Exemplo n.º 11
0
 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;
     }
     $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'), 'category' => array('property' => 'category', 'type' => 'text', 'label' => 'Category', 'description' => 'The category of the link', 'size' => '80', 'maxLength' => 100), 'linkText' => array('property' => 'linkText', 'type' => 'text', 'label' => 'Link Text', 'description' => 'The text to display for the link ', 'size' => '80', 'maxLength' => 100), 'url' => array('property' => 'url', 'type' => 'text', 'label' => 'URL', 'description' => 'The url to link to', 'size' => '80', 'maxLength' => 255), '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;
 }
Exemplo n.º 12
0
 function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $libraryList = array();
     if ($user->hasRole('opacAdmin')) {
         $library = new Library();
         $library->orderBy('displayName');
         $library->find();
         $libraryList[-1] = 'All Libraries';
         while ($library->fetch()) {
             $libraryList[$library->libraryId] = $library->displayName;
         }
     } elseif ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $libraryList[$homeLibrary->libraryId] = $homeLibrary->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'hidden', 'label' => 'Id', 'description' => 'The unique id of the list widget file.', 'primaryKey' => true, 'storeDb' => true), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'name' => array('property' => 'name', 'type' => 'text', 'label' => 'Name', 'description' => 'The name of the widget.', 'maxLength' => 255, 'size' => 100, 'serverValidation' => 'validateName', 'storeDb' => true), 'description' => array('property' => 'description', 'type' => 'textarea', 'rows' => 3, 'cols' => 80, 'label' => 'Description', 'description' => 'A description for the widget', 'storeDb' => true, 'hideInLists' => true), 'showTitle' => array('property' => 'showTitle', 'type' => 'checkbox', 'label' => 'Should the title for the currently selected title be shown?', 'storeDb' => true, 'default' => true, 'hideInLists' => true), 'showAuthor' => array('property' => 'showAuthor', 'type' => 'checkbox', 'label' => 'Should the author for the currently selected title be shown?', 'storeDb' => true, 'default' => true, 'hideInLists' => true), 'showRatings' => array('property' => 'showRatings', 'type' => 'checkbox', 'label' => 'Should ratings widgets be shown under each cover?', 'storeDb' => true, 'default' => false, 'hideInLists' => true), 'style' => array('property' => 'style', 'type' => 'enum', 'label' => 'The style to use when displaying the list widget', 'values' => $this->styles, 'storeDb' => true, 'default' => 'horizontal', 'hideInLists' => true), 'autoRotate' => array('property' => 'autoRotate', 'type' => 'checkbox', 'label' => 'Should the widget automatically rotate between titles?', 'storeDb' => true, 'hideInLists' => true), 'coverSize' => array('property' => 'coverSize', 'type' => 'enum', 'label' => 'The cover size to use when showing a widget', 'values' => array('small' => 'Small', 'medium' => 'Medium'), 'storeDb' => true, 'default' => 'small', 'hideInLists' => true), 'customCss' => array('property' => 'customCss', 'type' => 'url', 'label' => 'Custom CSS File', 'maxLength' => 255, 'size' => 100, 'description' => 'The URL to an external css file to be included when rendering as an iFrame.', 'storeDb' => true, 'required' => false, 'hideInLists' => true), 'listDisplayType' => array('property' => 'listDisplayType', 'type' => 'enum', 'values' => $this->displayTypes, 'label' => 'Display lists as', 'description' => 'The method used to show the user the multiple lists associated with the widget.', 'storeDb' => true, 'hideInLists' => true), 'showListWidgetTitle' => array('property' => 'showListWidgetTitle', 'type' => 'checkbox', 'label' => 'Show the list widget\'s title bar', 'description' => 'Whether or not the widget\'s title bar is shown. (Enabling the Show More Link will force the title bar to be shown as well.)', 'storeDb' => true, 'hideInLists' => true, 'default' => true), 'showViewMoreLink' => array('property' => 'showViewMoreLink', 'type' => 'checkbox', 'label' => 'Show the View More link on the title bar of the widget.', 'storeDb' => true, 'hideInLists' => true, 'default' => false), 'viewMoreLinkMode' => array('property' => 'viewMoreLinkMode', 'type' => 'enum', 'values' => array('list' => 'List', 'covers' => 'Covers'), 'label' => 'Display mode for search results link', 'description' => 'The mode to show full search results in when the View More link is clicked.', 'storeDb' => true, 'hideInLists' => true), 'lists' => array('property' => 'lists', 'type' => 'oneToMany', 'keyThis' => 'id', 'keyOther' => 'listWidgetId', 'subObjectType' => 'ListWidgetList', 'structure' => ListWidgetList::getObjectStructure(), 'label' => 'Lists', 'description' => 'The lists to be displayed within the widget.', 'sortable' => true, 'storeDb' => true, 'serverValidation' => 'validateLists', 'editLink' => 'ListWidgetsListsLinks', 'hideInLists' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $libraryList = array();
     if ($user->hasRole('opacAdmin')) {
         $library = new Library();
         $library->orderBy('displayName');
         $library->find();
         $libraryList[-1] = 'All Libraries';
         while ($library->fetch()) {
             $libraryList[$library->libraryId] = $library->displayName;
         }
     } elseif ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $libraryList[$homeLibrary->libraryId] = $homeLibrary->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'hidden', 'label' => 'Id', 'description' => 'The unique id of the list widget file.', 'primaryKey' => true, 'storeDb' => true), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'name' => array('property' => 'name', 'type' => 'text', 'label' => 'Name', 'description' => 'The name of the widget.', 'maxLength' => 255, 'size' => 100, 'serverValidation' => 'validateName', 'storeDb' => true), 'description' => array('property' => 'description', 'type' => 'textarea', 'rows' => 3, 'cols' => 80, 'label' => 'Description', 'description' => 'A description for the widget', 'storeDb' => true, 'hideInLists' => true), 'showTitleDescriptions' => array('property' => 'showTitleDescriptions', 'type' => 'checkbox', 'label' => 'Should the description pop-up be shown when hovering over titles?', 'storeDb' => true, 'default' => true, 'hideInLists' => true), 'showMultipleTitles' => array('property' => 'showMultipleTitles', 'type' => 'checkbox', 'label' => 'Should multiple titles by shown in in the widget or should only one title be shown at a time?', 'storeDb' => true, 'default' => true, 'hideInLists' => true), 'style' => array('property' => 'style', 'type' => 'enum', 'label' => 'The style to use when displaying the list widget', 'values' => array('horizontal' => 'Horizontal', 'vertical' => 'Vertical', 'single' => 'Single Title'), 'storeDb' => true, 'default' => 'horizontal', 'hideInLists' => true), 'autoRotate' => array('property' => 'autoRotate', 'type' => 'checkbox', 'label' => 'Should the widget automatically rotate between titles?', 'storeDb' => true, 'hideInLists' => true), 'onSelectCallback' => array('property' => 'onSelectCallback', 'type' => 'text', 'label' => 'On Select Callback', 'description' => 'A javascript callback to invoke when a title is selected to override the default behavior.', 'storeDb' => true, 'hideInLists' => true), 'customCss' => array('property' => 'customCss', 'type' => 'url', 'label' => 'Custom CSS File', 'maxLength' => 255, 'size' => 100, 'description' => 'The URL to an external css file to be included when rendering as an iFrame.', 'storeDb' => true, 'required' => false, 'hideInLists' => true), 'listDisplayType' => array('property' => 'listDisplayType', 'type' => 'enum', 'values' => array('tabs' => 'Tabbed Display', 'dropdown' => 'Drop Down List'), 'label' => 'Display lists as', 'description' => 'The URL to an external css file to be included wen rendering as an iFrame.', 'storeDb' => true, 'hideInLists' => true), 'lists' => array('property' => 'lists', 'type' => 'oneToMany', 'keyThis' => 'id', 'keyOther' => 'listWidgetId', 'subObjectType' => 'ListWidgetList', 'structure' => ListWidgetList::getObjectStructure(), 'label' => 'Lists', 'description' => 'The lists to be displayed within the widget.', 'sortable' => true, 'storeDb' => true, 'serverValidation' => 'validateLists', 'editLink' => 'ListWidgetsListsLinks', 'hideInLists' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Exemplo n.º 15
0
 /**
  * @param User $patron
  * @param bool $forceReload
  * @return array
  */
 public function getMyProfile($patron, $forceReload = false)
 {
     //Update to not use SIP, just screen scrape for performance (sigh)
     global $timer;
     /** @var Memcache $memCache */
     global $memCache;
     if (!is_object($patron)) {
         $tmpPatron = new User();
         $tmpPatron->username = $patron['username'];
         $tmpPatron->cat_username = $patron['cat_username'];
         $tmpPatron->cat_password = $patron['cat_password'];
         $tmpPatron->firstname = $patron['firstname'];
         $tmpPatron->lastname = $patron['lastname'];
         $tmpPatron->email = $patron['email'];
         $tmpPatron->patronType = $patron['patronType'];
         $patron = $tmpPatron;
     }
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         // Check the Object for profile
         if (array_key_exists($patron->username, $this->patronProfiles)) {
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $this->patronProfiles[$patron->username];
         }
     }
     // Determine memcache key
     global $serverName;
     $memCacheProfileKey = "patronProfile_{$serverName}_";
     if (is_object($patron) && !isset($tmpPatron)) {
         // exclude the new patron object $tmpPatron created above. It won't have an id or be stored in memcache
         //				$patron         = get_object_vars($patron);
         //			$memCacheProfileKey = $patron['username'];
         // $patron needs to remain an object for initial loading below
         $memCacheProfileKey .= $patron->username;
     } else {
         global $user;
         //				$memCacheProfileKey = $user->id;
         $memCacheProfileKey .= $user->username;
     }
     // Check MemCache for profile
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         $patronProfile = $memCache->get($memCacheProfileKey);
         if ($patronProfile) {
             //echo("Using cached profile for patron " . $userId);
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $patronProfile;
         }
     }
     $this->initDatabaseConnection();
     $this->getUserInfoStmt->bind_param('ss', $patron->cat_username, $patron->cat_username);
     if ($this->getUserInfoStmt->execute()) {
         if ($userFromDbResultSet = $this->getUserInfoStmt->get_result()) {
             $userFromDb = $userFromDbResultSet->fetch_assoc();
             $userFromDbResultSet->close();
             //				$city = $userFromDb['city'];
             //				$state = "";
             //				$commaPos = strpos($city, ',');
             //				if ($commaPos !== false){ // fix this
             //					$cityState = $city;
             //					$city = substr($cityState, 0, $commaPos);
             //					$state = substr($cityState, $commaPos);
             //				}
             $city = strtok($userFromDb['city'], ',');
             $state = strtok(',');
             $city = trim($city);
             $state = trim($state);
             //Get fines
             //Load fines from database
             $outstandingFines = $this->getOutstandingFineTotal();
             //Get number of items checked out
             $checkedOutItemsRS = mysqli_query($this->dbConnection, 'SELECT count(*) as numCheckouts FROM issues WHERE borrowernumber = ' . $patron->username);
             $numCheckouts = 0;
             if ($checkedOutItemsRS) {
                 $checkedOutItems = $checkedOutItemsRS->fetch_assoc();
                 $numCheckouts = $checkedOutItems['numCheckouts'];
                 $checkedOutItemsRS->close();
             }
             //Get number of available holds
             $availableHoldsRS = mysqli_query($this->dbConnection, 'SELECT count(*) as numHolds FROM reserves WHERE waitingdate is not null and borrowernumber = ' . $patron->username);
             $numAvailableHolds = 0;
             if ($availableHoldsRS) {
                 $availableHolds = $availableHoldsRS->fetch_assoc();
                 $numAvailableHolds = $availableHolds['numHolds'];
                 $availableHoldsRS->close();
             }
             //Get number of unavailable
             $waitingHoldsRS = mysqli_query($this->dbConnection, 'SELECT count(*) as numHolds FROM reserves WHERE waitingdate is null and borrowernumber = ' . $patron->username);
             $numWaitingHolds = 0;
             if ($waitingHoldsRS) {
                 $waitingHolds = $waitingHoldsRS->fetch_assoc();
                 $numWaitingHolds = $waitingHolds['numHolds'];
                 $waitingHoldsRS->close();
             }
             $homeBranchCode = $userFromDb['branchcode'];
             $location = new Location();
             $location->code = $homeBranchCode;
             $location->find(1);
             if ($location->N == 0) {
                 unset($location);
             }
             global $user;
             $profile = array('lastname' => $patron->lastname, 'firstname' => $patron->firstname, 'displayName' => isset($patron->displayName) ? $patron->displayName : '', 'fullname' => $user->lastname . ', ' . $user->firstname, 'address1' => trim($userFromDb['streetnumber'] . ' ' . $userFromDb['address'] . ' ' . $userFromDb['address2']), 'city' => $city, 'state' => $state, 'zip' => $userFromDb['zipcode'], 'phone' => $userFromDb['phone'], 'email' => $userFromDb['email'], 'homeLocationId' => isset($location) ? $location->locationId : -1, 'homeLocationName' => '', 'expires' => $userFromDb['dateexpiry'], 'fines' => sprintf('$%0.2f', $outstandingFines), 'finesval' => floatval($outstandingFines), 'numHolds' => $numWaitingHolds + $numAvailableHolds, 'numHoldsAvailable' => $numAvailableHolds, 'numHoldsRequested' => $numWaitingHolds, 'numCheckedOut' => $numCheckouts, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : false);
             $profile['noticePreferenceLabel'] = 'Unknown';
             //Get eContent info as well
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $eContentDriver = new EContentDriver();
             $eContentAccountSummary = $eContentDriver->getAccountSummary();
             $profile = array_merge($profile, $eContentAccountSummary);
             require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
             $overDriveDriver = OverDriveDriverFactory::getDriver();
             if ($overDriveDriver->isUserValidForOverDrive($user)) {
                 $overDriveSummary = $overDriveDriver->getOverDriveSummary($user);
                 $profile['numOverDriveCheckedOut'] = $overDriveSummary['numCheckedOut'];
                 $profile['numOverDriveHoldsAvailable'] = $overDriveSummary['numAvailableHolds'];
                 $profile['numOverDriveHoldsRequested'] = $overDriveSummary['numUnavailableHolds'];
                 $profile['canUseOverDrive'] = true;
             } else {
                 $profile['numOverDriveCheckedOut'] = 0;
                 $profile['numOverDriveHoldsAvailable'] = 0;
                 $profile['numOverDriveHoldsRequested'] = 0;
                 $profile['canUseOverDrive'] = false;
             }
             $profile['numCheckedOutTotal'] = $profile['numCheckedOut'] + $profile['numOverDriveCheckedOut'] + $eContentAccountSummary['numEContentCheckedOut'];
             $profile['numHoldsAvailableTotal'] = $profile['numHoldsAvailable'] + $profile['numOverDriveHoldsAvailable'] + $eContentAccountSummary['numEContentAvailableHolds'];
             $profile['numHoldsRequestedTotal'] = $profile['numHoldsRequested'] + $profile['numOverDriveHoldsRequested'] + $eContentAccountSummary['numEContentUnavailableHolds'];
             $profile['numHoldsTotal'] = $profile['numHoldsAvailableTotal'] + $profile['numHoldsRequestedTotal'];
             //Get a count of the materials requests for the user
             if ($user) {
                 $homeLibrary = Library::getPatronHomeLibrary();
                 if ($homeLibrary) {
                     $materialsRequest = new MaterialsRequest();
                     $materialsRequest->createdBy = $user->id;
                     $statusQuery = new MaterialsRequestStatus();
                     $statusQuery->isOpen = 1;
                     $statusQuery->libraryId = $homeLibrary->libraryId;
                     $materialsRequest->joinAdd($statusQuery);
                     $materialsRequest->find();
                     $profile['numMaterialsRequests'] = $materialsRequest->N;
                 } else {
                     $profile['numMaterialsRequests'] = 0;
                 }
                 if ($user->homeLocationId == 0 && isset($location)) {
                     $user->homeLocationId = $location->locationId;
                     if ($location->nearbyLocation1 > 0) {
                         $user->myLocation1Id = $location->nearbyLocation1;
                     } else {
                         $user->myLocation1Id = $location->locationId;
                     }
                     if ($location->nearbyLocation2 > 0) {
                         $user->myLocation2Id = $location->nearbyLocation2;
                     } else {
                         $user->myLocation2Id = $location->locationId;
                     }
                     if ($user instanceof User) {
                         //Update the database
                         $user->update();
                         //Update the serialized instance stored in the session
                         $_SESSION['userinfo'] = serialize($user);
                     }
                 } else {
                     if (isset($location) && $location->locationId != $user->homeLocationId) {
                         $user->homeLocationId = $location->locationId;
                         //Update the database
                         $user->update();
                         //Update the serialized instance stored in the session
                         $_SESSION['userinfo'] = serialize($user);
                     }
                 }
             }
         } else {
             $profile = PEAR_Singleton::raiseError('patron_info_error_technical - could not load from database');
         }
     } else {
         $profile = PEAR_Singleton::raiseError('patron_info_error_technical - could not execute user info statement');
     }
     $this->patronProfiles[$patron->username] = $profile;
     $timer->logTime('Retrieved Profile for Patron from Database');
     global $configArray, $serverName;
     $memCache->set($memCacheProfileKey, $profile, 0, $configArray['Caching']['patron_profile']);
     // Looks like all drivers but aspencat use id rather than username.
     // plb 4-16-2014
     return $profile;
 }
Exemplo n.º 16
0
 function placeHold()
 {
     global $interface;
     global $configArray;
     global $user;
     global $logger;
     //TODO: Clean this up so there is only ever one id.
     if (isset($_REQUEST['recordId'])) {
         $recordId = $_REQUEST['recordId'];
     } else {
         $recordId = $_REQUEST['id'];
     }
     $interface->assign('id', $recordId);
     //Get title information for the record.
     $holding = $this->catalog->getHolding($recordId);
     if (PEAR_Singleton::isError($holding)) {
         PEAR_Singleton::raiseError($holding);
     }
     $interface->assign('holding', $holding);
     if (isset($_REQUEST['autologout'])) {
         $_SESSION['autologout'] = true;
     }
     $showMessage = false;
     $type = isset($_REQUEST['holdType']) ? $_REQUEST['holdType'] : '';
     if (isset($_POST['submit']) || $type == 'recall' || $type == 'update' || $type == 'hold') {
         if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
             //Log the user in
             $user = UserAccount::login();
         }
         if ($user) {
             //The user is already logged in
             $barcodeProperty = $configArray['Catalog']['barcodeProperty'];
             $return = $this->catalog->placeHold($recordId, $user->{$barcodeProperty}, '', $type);
             $interface->assign('result', $return['result']);
             $message = $return['message'];
             $interface->assign('message', $message);
             $showMessage = true;
         } else {
             $message = 'Incorrect Patron Information';
             $interface->assign('message', $message);
             $interface->assign('focusElementId', 'username');
             $showMessage = true;
         }
     } else {
         //Get the referrer so we can go back there.
         if (isset($_SERVER['HTTP_REFERER'])) {
             $referer = $_SERVER['HTTP_REFERER'];
             $_SESSION['hold_referrer'] = $referer;
         }
         //Showing place hold form.
         if ($user) {
             $profile = $this->catalog->getMyProfile($user);
             $interface->assign('profile', $profile);
             //Get information to show a warning if the user does not have sufficient holds
             require_once ROOT_DIR . '/Drivers/marmot_inc/PType.php';
             $maxHolds = -1;
             //Determine if we should show a warning
             $ptype = new PType();
             $ptype->pType = $user->patronType;
             if ($ptype->find(true)) {
                 $maxHolds = $ptype->maxHolds;
             }
             $currentHolds = $profile['numHolds'];
             if ($maxHolds != -1 && $currentHolds + 1 > $maxHolds) {
                 $interface->assign('showOverHoldLimit', true);
                 $interface->assign('maxHolds', $maxHolds);
                 $interface->assign('currentHolds', $currentHolds);
             }
             global $locationSingleton;
             //Get the list of pickup branch locations for display in the user interface.
             $locations = $locationSingleton->getPickupBranches($profile, $profile['homeLocationId']);
             $interface->assign('pickupLocations', $locations);
             //set focus to the submit button if the user is logged in since the campus will be correct most of the time.
             $interface->assign('focusElementId', 'submit');
         } else {
             //set focus to the username field by default.
             $interface->assign('focusElementId', 'username');
         }
         global $library;
         $patronHomeBranch = Library::getPatronHomeLibrary();
         if ($patronHomeBranch != null) {
             if ($patronHomeBranch->defaultNotNeededAfterDays > 0) {
                 $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $patronHomeBranch->defaultNotNeededAfterDays * 60 * 60 * 24));
             } else {
                 $interface->assign('defaultNotNeededAfterDays', '');
             }
             $interface->assign('showHoldCancelDate', $patronHomeBranch->showHoldCancelDate);
         } else {
             if ($library) {
                 //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                 if ($library->defaultNotNeededAfterDays > 0) {
                     $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $library->defaultNotNeededAfterDays * 60 * 60 * 24));
                 } else {
                     $interface->assign('defaultNotNeededAfterDays', '');
                 }
                 $interface->assign('showHoldCancelDate', $library->showHoldCancelDate);
             } else {
                 //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                 $interface->assign('showHoldCancelDate', 1);
                 $interface->assign('defaultNotNeededAfterDays', '');
             }
         }
         $activeLibrary = Library::getActiveLibrary();
         if ($activeLibrary != null) {
             $interface->assign('holdDisclaimer', $activeLibrary->holdDisclaimer);
         } else {
             //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
             $interface->assign('holdDisclaimer', '');
         }
     }
     $record = RecordDriverFactory::initRecordDriverById('ils:' . $_GET['id']);
     if ($record) {
         $interface->assign('record', $record);
     } else {
         PEAR_Singleton::raiseError('Cannot find record ' . $_GET['id']);
     }
     $interface->assign('id', $_GET['id']);
     if ($showMessage && isset($return)) {
         $hold_message_data = array('successful' => $return['result'] == true ? 'all' : 'none', 'error' => isset($return['error']) ? $return['error'] : '', 'titles' => array($return), 'campus' => $_REQUEST['campus']);
         //Check to see if there are item level holds that need follow-up by the user
         if (isset($return['items']) && count($return['items']) > 0) {
             $hold_message_data['showItemForm'] = true;
             $hold_message_data['items'] = $return['items'];
         }
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             $logger->log('Hold Referrer is set, redirecting to there. location ' . $_SESSION['hold_referrer'], PEAR_LOG_INFO);
             if ($_REQUEST['type'] != 'recall' && $_REQUEST['type'] != 'cancel' && $_REQUEST['type'] != 'update') {
                 header("Location: " . $_SESSION['hold_referrer']);
             } else {
                 //Redirect for hold cancellation or update
                 $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'unavailable';
                 header("Location: " . '/MyResearch/Holds?section=' . $section);
             }
             if (!isset($hold_message_data['showItemForm']) || $hold_message_data['showItemForm'] == false) {
                 unset($_SESSION['hold_referrer']);
                 if (isset($_SESSION['autologout'])) {
                     unset($_SESSION['autologout']);
                     UserAccount::softLogout();
                 }
             }
         } else {
             $logger->log('No referrer set, but there is a message to show, go to the main holds page', PEAR_LOG_INFO);
             header("Location: " . '/MyResearch/Holds');
             die;
         }
     } else {
         //$logger->log('placeHold finished, do not need to show a message', PEAR_LOG_INFO);
         $interface->setPageTitle('Request an Item');
         $interface->assign('subTemplate', 'hold.tpl');
         $interface->setTemplate('hold.tpl');
         $interface->display('layout.tpl', 'RecordHold' . $_GET['id']);
     }
 }
Exemplo n.º 17
0
 static function getObjectStructure()
 {
     // get the structure for the library system's holidays
     $holidaysStructure = Holiday::getObjectStructure();
     // we don't want to make the libraryId property editable
     // because it is associated with this library system only
     unset($holidaysStructure['libraryId']);
     $nearbyBookStoreStructure = NearbyBookStore::getObjectStructure();
     unset($nearbyBookStoreStructure['weight']);
     unset($nearbyBookStoreStructure['libraryId']);
     $facetSettingStructure = LibraryFacetSetting::getObjectStructure();
     unset($facetSettingStructure['weight']);
     unset($facetSettingStructure['libraryId']);
     unset($facetSettingStructure['numEntriesToShowByDefault']);
     unset($facetSettingStructure['showAsDropDown']);
     //unset($facetSettingStructure['sortMode']);
     $searchSourceStructure = LibrarySearchSource::getObjectStructure();
     unset($searchSourceStructure['weight']);
     unset($searchSourceStructure['libraryId']);
     $libraryMoreDetailsStructure = LibraryMoreDetails::getObjectStructure();
     unset($libraryMoreDetailsStructure['weight']);
     unset($libraryMoreDetailsStructure['libraryId']);
     $libraryLinksStructure = LibraryLinks::getObjectStructure();
     unset($libraryLinksStructure['weight']);
     unset($libraryLinksStructure['libraryId']);
     $libraryTopLinksStructure = LibraryTopLinks::getObjectStructure();
     unset($libraryTopLinksStructure['weight']);
     unset($libraryTopLinksStructure['libraryId']);
     $libraryBrowseCategoryStructure = LibraryBrowseCategory::getObjectStructure();
     unset($libraryBrowseCategoryStructure['weight']);
     unset($libraryBrowseCategoryStructure['libraryId']);
     global $user;
     require_once ROOT_DIR . '/sys/ListWidget.php';
     $widget = new ListWidget();
     if (($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) && !$user->hasRole('opacAdmin')) {
         $patronLibrary = Library::getPatronHomeLibrary();
         if ($patronLibrary) {
             $widget->libraryId = $patronLibrary->libraryId;
         }
     }
     $availableWidgets = array();
     $widget->orderBy('name');
     $widget->find();
     $availableWidgets[0] = 'No Widget';
     while ($widget->fetch()) {
         $availableWidgets[$widget->id] = $widget->name;
     }
     $structure = array('libraryId' => array('property' => 'libraryId', 'type' => 'label', 'label' => 'Library Id', 'description' => 'The unique id of the library within the database'), 'subdomain' => array('property' => 'subdomain', 'type' => 'text', 'label' => 'Subdomain', 'description' => 'A unique id to identify the library within the system'), 'displayName' => array('property' => 'displayName', 'type' => 'text', 'label' => 'Display Name', 'description' => 'A name to identify the library within the system', 'size' => '40'), 'showDisplayNameInHeader' => array('property' => 'showDisplayNameInHeader', 'type' => 'checkbox', 'label' => 'Show Display Name in Header', 'description' => 'Whether or not the display name should be shown in the header next to the logo', 'hideInLists' => true, 'default' => false), 'abbreviatedDisplayName' => array('property' => 'abbreviatedDisplayName', 'type' => 'text', 'label' => 'Abbreviated Display Name', 'description' => 'A short name to identify the library when space is low', 'size' => '40'), 'systemMessage' => array('property' => 'systemMessage', 'type' => 'html', 'label' => 'System Message', 'description' => 'A message to be displayed at the top of the screen', 'size' => '80', 'maxLength' => '512', 'allowableTags' => '<a><b><em><div><script><span><p><strong><sub><sup>', 'hideInLists' => true), array('property' => 'displaySection', 'type' => 'section', 'label' => 'Basic Display', 'hideInLists' => true, 'properties' => array('themeName' => array('property' => 'themeName', 'type' => 'text', 'label' => 'Theme Name', 'description' => 'The name of the theme which should be used for the library', 'hideInLists' => true, 'default' => 'default'), 'homeLink' => array('property' => 'homeLink', 'type' => 'text', 'label' => 'Home Link', 'description' => 'The location to send the user when they click on the home button or logo.  Use default or blank to go back to the Pika home location.', 'size' => '40', 'hideInLists' => true), 'additionalCss' => array('property' => 'additionalCss', 'type' => 'textarea', 'label' => 'Additional CSS', 'description' => 'Extra CSS to apply to the site.  Will apply to all pages.', 'hideInLists' => true), 'useHomeLinkInBreadcrumbs' => array('property' => 'useHomeLinkInBreadcrumbs', 'type' => 'checkbox', 'label' => 'Use Home Link in Breadcrumbs', 'description' => 'Whether or not the home link should be used in the breadcumbs.', 'hideInLists' => true), 'useHomeLinkForLogo' => array('property' => 'useHomeLinkForLogo', 'type' => 'checkbox', 'label' => 'Use Home Link for Logo', 'description' => 'Whether or not the home link should be used as the link for the main logo.', 'hideInLists' => true), 'homeLinkText' => array('property' => 'homeLinkText', 'type' => 'text', 'label' => 'Home Link Text', 'description' => 'The text to show for the Home breadcrumb link', 'size' => '40', 'hideInLists' => true, 'default' => 'Home'), 'showLibraryHoursAndLocationsLink' => array('property' => 'showLibraryHoursAndLocationsLink', 'type' => 'checkbox', 'label' => 'Show Library Hours and Locations Link', 'description' => 'Whether or not the library hours and locations link is shown on the home page.', 'hideInLists' => true, 'default' => true), 'eContentSupportAddress' => array('property' => 'eContentSupportAddress', 'type' => 'multiemail', 'label' => 'E-Content Support Address', 'description' => 'An e-mail address to receive support requests for patrons with eContent problems.', 'size' => '80', 'hideInLists' => true, 'default' => '*****@*****.**'), 'enableGenealogy' => array('property' => 'enableGenealogy', 'type' => 'checkbox', 'label' => 'Enable Genealogy Functionality', 'description' => 'Whether or not patrons can search genealogy.', 'hideInLists' => true, 'default' => 1), 'enableCourseReserves' => array('property' => 'enableCourseReserves', 'type' => 'checkbox', 'label' => 'Enable Repeat Search in Course Reserves', 'description' => 'Whether or not patrons can repeat searches within course reserves.', 'hideInLists' => true), 'defaultBrowseMode' => array('property' => 'defaultBrowseMode', 'type' => 'enum', 'label' => 'Default Viewing Mode for Browse Categories', 'description' => 'Sets how browse categories will be displayed when users haven\'t chosen themselves.', 'hideInLists' => true, 'values' => array('covers' => 'Show Covers Only', 'grid' => 'Show as Grid'), 'default' => 'covers'))), array('property' => 'contact', 'type' => 'section', 'label' => 'Contact Links', 'hideInLists' => true, 'properties' => array('facebookLink' => array('property' => 'facebookLink', 'type' => 'text', 'label' => 'Facebook Link Url', 'description' => 'The url to Facebook (leave blank if the library does not have a Facebook account', 'size' => '40', 'maxLength' => 255, 'hideInLists' => true), 'twitterLink' => array('property' => 'twitterLink', 'type' => 'text', 'label' => 'Twitter Link Url', 'description' => 'The url to Twitter (leave blank if the library does not have a Twitter account', 'size' => '40', 'maxLength' => 255, 'hideInLists' => true), 'youtubeLink' => array('property' => 'youtubeLink', 'type' => 'text', 'label' => 'Youtube Link Url', 'description' => 'The url to Youtube (leave blank if the library does not have a Youtube account', 'size' => '40', 'maxLength' => 255, 'hideInLists' => true), 'instagramLink' => array('property' => 'instagramLink', 'type' => 'text', 'label' => 'Instagram Link Url', 'description' => 'The url to Instagram (leave blank if the library does not have a Instagram account', 'size' => '40', 'maxLength' => 255, 'hideInLists' => true), 'goodreadsLink' => array('property' => 'goodreadsLink', 'type' => 'text', 'label' => 'GoodReads Link Url', 'description' => 'The url to GoodReads (leave blank if the library does not have a GoodReads account', 'size' => '40', 'maxLength' => 255, 'hideInLists' => true), 'generalContactLink' => array('property' => 'generalContactLink', 'type' => 'text', 'label' => 'General Contact Link Url', 'description' => 'The url to a General Contact Page, i.e webform or mailto link', 'size' => '40', 'maxLength' => 255, 'hideInLists' => true))), array('property' => 'ilsSection', 'type' => 'section', 'label' => 'ILS/Account Integration', 'hideInLists' => true, 'properties' => array('ilsCode' => array('property' => 'ilsCode', 'type' => 'text', 'label' => 'ILS Code', 'description' => 'The location code that all items for this location start with.', 'size' => '4', 'hideInLists' => false), 'scope' => array('property' => 'scope', 'type' => 'text', 'label' => 'Scope', 'description' => 'The scope for the system in Millennium to refine holdings for the user.', 'size' => '4', 'hideInLists' => true), 'useScope' => array('property' => 'useScope', 'type' => 'checkbox', 'label' => 'Use Scope', 'description' => 'Whether or not the scope should be used when displaying holdings.', 'hideInLists' => true), 'orderAccountingUnit' => array('property' => 'orderAccountingUnit', 'type' => 'integer', 'label' => 'Order Accounting Unit', 'description' => 'The accounting unit this library belongs to for orders', 'size' => '4', 'hideInLists' => false), 'makeOrderRecordsAvailableToOtherLibraries' => array('property' => 'makeOrderRecordsAvailableToOtherLibraries', 'type' => 'checkbox', 'label' => 'Make Order Records Available To Other Libraries', 'description' => 'Whether or not order records should be shown to other libraries', 'hideInLists' => true), 'minBarcodeLength' => array('property' => 'minBarcodeLength', 'type' => 'integer', 'label' => 'Min Barcode Length', 'description' => 'A minimum length the patron barcode is expected to be. Leave as 0 to extra processing of barcodes.', 'hideInLists' => true, 'default' => 0), 'maxBarcodeLength' => array('property' => 'maxBarcodeLength', 'type' => 'integer', 'label' => 'Max Barcode Length', 'description' => 'The maximum length the patron barcode is expected to be. Leave as 0 to extra processing of barcodes.', 'hideInLists' => true, 'default' => 0), 'barcodePrefix' => array('property' => 'barcodePrefix', 'type' => 'text', 'label' => 'Barcode Prefix', 'description' => 'A barcode prefix to apply to the barcode if it does not start with the barcode prefix or if it is not within the expected min/max range.  Multiple prefixes can be specified by separating them with commas. Leave blank to avoid additional processing of barcodes.', 'hideInLists' => true, 'default' => ''), 'pTypes' => array('property' => 'pTypes', 'type' => 'text', 'label' => 'P-Types', 'description' => 'A list of pTypes that are valid for the library.  Separate multiple pTypes with commas.'), 'defaultPType' => array('property' => 'defaultPType', 'type' => 'text', 'label' => 'Default P-Type', 'description' => 'The P-Type to use when accessing a subdomain if the patron is not logged in.'), 'showExpirationWarnings' => array('property' => 'showExpirationWarnings', 'type' => 'checkbox', 'label' => 'Show Expiration Warnings', 'description' => 'Whether or not the user should be shown expiration warnings if their card is nearly expired.', 'hideInLists' => true, 'default' => 1), 'userProfileSection' => array('property' => 'userProfileSection', 'type' => 'section', 'label' => 'User Profile', 'hideInLists' => true, 'properties' => array('allowProfileUpdates' => array('property' => 'allowProfileUpdates', 'type' => 'checkbox', 'label' => 'Allow Profile Updates', 'description' => 'Whether or not the user can update their own profile.', 'hideInLists' => true, 'default' => 1), 'allowPatronAddressUpdates' => array('property' => 'allowPatronAddressUpdates', 'type' => 'checkbox', 'label' => 'Allow Patrons to Update Their Address', 'description' => 'Whether or not patrons should be able to update their own address in their profile.', 'hideInLists' => true, 'default' => 1), 'showAlternateLibraryOptionsInProfile' => array('property' => 'showAlternateLibraryOptionsInProfile', 'type' => 'checkbox', 'label' => 'Allow Patrons to Update their Alternate Libraries', 'description' => 'Allow Patrons to See and Change Alternate Library Settings in the Catalog Options Tab in their profile.', 'hideInLists' => true, 'default' => 1), 'showWorkPhoneInProfile' => array('property' => 'showWorkPhoneInProfile', 'type' => 'checkbox', 'label' => 'Show Work Phone in Profile', 'description' => 'Whether or not patrons should be able to change a secondary/work phone number in their profile.', 'hideInLists' => true, 'default' => 0), 'treatPrintNoticesAsPhoneNotices' => array('property' => 'treatPrintNoticesAsPhoneNotices', 'type' => 'checkbox', 'label' => 'Treat Print Notices As Phone Notices', 'description' => 'When showing detailed information about hold notices, treat print notices as if they are phone calls', 'hideInLists' => true, 'default' => 0), 'showNoticeTypeInProfile' => array('property' => 'showNoticeTypeInProfile', 'type' => 'checkbox', 'label' => 'Show Notice Type in Profile', 'description' => 'Whether or not patrons should be able to change how they receive notices in their profile.', 'hideInLists' => true, 'default' => 0), 'showPickupLocationInProfile' => array('property' => 'showPickupLocationInProfile', 'type' => 'checkbox', 'label' => 'Allow Patrons to Update Their Pickup Location', 'description' => 'Whether or not patrons should be able to update their preferred pickup location in their profile.', 'hideInLists' => true, 'default' => 0), 'addSMSIndicatorToPhone' => array('property' => 'addSMSIndicatorToPhone', 'type' => 'checkbox', 'label' => 'Add SMS Indicator to Primary Phone', 'description' => 'Whether or not add TEXT ONLY to the user\'s primary phone number when they opt in to SMS notices.', 'hideInLists' => true, 'default' => 0))), 'holdsSection' => array('property' => 'holdsSection', 'type' => 'section', 'label' => 'Holds', 'hideInLists' => true, 'properties' => array('showHoldButton' => array('property' => 'showHoldButton', 'type' => 'checkbox', 'label' => 'Show Hold Button', 'description' => 'Whether or not the hold button is displayed so patrons can place holds on items', 'hideInLists' => true, 'default' => 1), 'showHoldButtonInSearchResults' => array('property' => 'showHoldButtonInSearchResults', 'type' => 'checkbox', 'label' => 'Show Hold Button within the search results', 'description' => 'Whether or not the hold button is displayed within the search results so patrons can place holds on items', 'hideInLists' => true, 'default' => 1), 'showHoldCancelDate' => array('property' => 'showHoldCancelDate', 'type' => 'checkbox', 'label' => 'Show Cancellation Date', 'description' => 'Whether or not the patron should be able to set a cancellation date (not needed after date) when placing holds.', 'hideInLists' => true, 'default' => 1), 'allowFreezeHolds' => array('property' => 'allowFreezeHolds', 'type' => 'checkbox', 'label' => 'Allow Freezing Holds', 'description' => 'Whether or not the user can freeze their holds.', 'hideInLists' => true, 'default' => 1), 'defaultNotNeededAfterDays' => array('property' => 'defaultNotNeededAfterDays', 'type' => 'integer', 'label' => 'Default Not Needed After Days', 'description' => 'Number of days to use for not needed after date by default. Use -1 for no default.', 'hideInLists' => true), 'showDetailedHoldNoticeInformation' => array('property' => 'showDetailedHoldNoticeInformation', 'type' => 'checkbox', 'label' => 'Show Detailed Hold Notice Information', 'description' => 'Whether or not the user should be presented with detailed hold notification information, i.e. you will receive an e-mail/phone call to xxx when the hold is available', 'hideInLists' => true, 'default' => 1), 'inSystemPickupsOnly' => array('property' => 'inSystemPickupsOnly', 'type' => 'checkbox', 'label' => 'In System Pickups Only', 'description' => 'Restrict pickup locations to only locations within the library system which is active.', 'hideInLists' => true), 'validPickupSystems' => array('property' => 'validPickupSystems', 'type' => 'text', 'label' => 'Valid Pickup Systems', 'description' => 'A list of library codes that can be used as pickup locations separated by pipes |', 'size' => '20', 'hideInLists' => true), 'holdDisclaimer' => array('property' => 'holdDisclaimer', 'type' => 'textarea', 'label' => 'Hold Disclaimer', 'description' => 'A disclaimer to display to patrons when they are placing a hold on items letting them know that their information may be available to other libraries.  Leave blank to not show a disclaimer.', 'hideInLists' => true))), 'loginSection' => array('property' => 'loginSection', 'type' => 'section', 'label' => 'Login', 'hideInLists' => true, 'properties' => array('showLoginButton' => array('property' => 'showLoginButton', 'type' => 'checkbox', 'label' => 'Show Login Button', 'description' => 'Whether or not the login button is displayed so patrons can login to the site', 'hideInLists' => true, 'default' => 1), 'allowPinReset' => array('property' => 'allowPinReset', 'type' => 'checkbox', 'label' => 'Allow PIN Reset', 'description' => 'Whether or not the user can reset their PIN if they forget it.', 'hideInLists' => true, 'default' => 0), 'loginFormUsernameLabel' => array('property' => 'loginFormUsernameLabel', 'type' => 'text', 'label' => 'Login Form Username Label', 'description' => 'The label to show for the username when logging in', 'size' => '50', 'hideInLists' => true, 'default' => 'Your Name'), 'loginFormPasswordLabel' => array('property' => 'loginFormPasswordLabel', 'type' => 'text', 'label' => 'Login Form Password Label', 'description' => 'The label to show for the password when logging in', 'size' => '50', 'hideInLists' => true, 'default' => 'Library Card Number'))), 'selfRegistrationSection' => array('property' => 'selfRegistrationSection', 'type' => 'section', 'label' => 'Self Registration', 'hideInLists' => true, 'properties' => array('enableSelfRegistration' => array('property' => 'enableSelfRegistration', 'type' => 'checkbox', 'label' => 'Enable Self Registration', 'description' => 'Whether or not patrons can self register on the site', 'hideInLists' => true), 'promptForBirthDateInSelfReg' => array('property' => 'promptForBirthDateInSelfReg', 'type' => 'checkbox', 'label' => 'Prompt For Birth Date', 'description' => 'Whether or not to prompt for birth date when self registering'), 'selfRegistrationFormMessage' => array('property' => 'selfRegistrationFormMessage', 'type' => 'html', 'label' => 'Self Registration Form Message', 'description' => 'Message shown to users with the form to submit the self registration.  Leave blank to give users the default message.', 'hideInLists' => true), 'selfRegistrationSuccessMessage' => array('property' => 'selfRegistrationSuccessMessage', 'type' => 'html', 'label' => 'Self Registration Success Message', 'description' => 'Message shown to users when the self registration has been completed successfully.  Leave blank to give users the default message.', 'hideInLists' => true), 'selfRegistrationTemplate' => array('property' => 'selfRegistrationTemplate', 'type' => 'text', 'label' => 'Self Registration Template', 'description' => 'The ILS template to use during self registration (Sierra and Millennium).', 'hideInLists' => true, 'default' => 'default'))))), array('property' => 'ecommerceSection', 'type' => 'section', 'label' => 'Fines/e-commerce', 'hideInLists' => true, 'properties' => array('showEcommerceLink' => array('property' => 'showEcommerceLink', 'type' => 'checkbox', 'label' => 'Show E-Commerce Link', 'description' => 'Whether or not users should be given a link to classic opac to pay fines', 'hideInLists' => true), 'payFinesLink' => array('property' => 'payFinesLink', 'type' => 'text', 'label' => 'Pay Fines Link', 'description' => 'The link to pay fines.  Leave as default to link to classic (should have eCommerce link enabled)', 'hideInLists' => true, 'default' => 'default', 'size' => 80), 'payFinesLinkText' => array('property' => 'payFinesLinkText', 'type' => 'text', 'label' => 'Pay Fines Link Text', 'description' => 'The text when linking to pay fines.', 'hideInLists' => true, 'default' => 'Click to Pay Fines Online ', 'size' => 80), 'minimumFineAmount' => array('property' => 'minimumFineAmount', 'type' => 'currency', 'displayFormat' => '%0.2f', 'label' => 'Minimum Fine Amount', 'description' => 'The minimum fine amount to display the e-commerce link', 'hideInLists' => true))), array('property' => 'searchingSection', 'type' => 'section', 'label' => 'Searching', 'hideInLists' => true, 'properties' => array('facetLabel' => array('property' => 'facetLabel', 'type' => 'text', 'label' => 'Facet Label', 'description' => 'The label for the library system in the Library System Facet.', 'size' => '40', 'hideInLists' => true), 'restrictSearchByLibrary' => array('property' => 'restrictSearchByLibrary', 'type' => 'checkbox', 'label' => 'Restrict Search By Library', 'description' => 'Whether or not search results should only include titles from this library', 'hideInLists' => true), 'econtentLocationsToInclude' => array('property' => 'econtentLocationsToInclude', 'type' => 'text', 'label' => 'eContent Locations To Include', 'description' => 'A list of eContent Locations to include within the scope.', 'size' => '40', 'hideInLists' => true), 'includeOutOfSystemExternalLinks' => array('property' => 'includeOutOfSystemExternalLinks', 'type' => 'checkbox', 'label' => 'Include Out Of System External Links', 'description' => 'Whether or not to include external links from other library systems.  Should only be enabled for global scope.', 'hideInLists' => true, 'default' => 0), 'boostByLibrary' => array('property' => 'boostByLibrary', 'type' => 'checkbox', 'label' => 'Boost By Library', 'description' => 'Whether or not boosting of titles owned by this library should be applied', 'hideInLists' => true), 'additionalLocalBoostFactor' => array('property' => 'additionalLocalBoostFactor', 'type' => 'integer', 'label' => 'Additional Local Boost Factor', 'description' => 'An additional numeric boost to apply to any locally owned and locally available titles', 'hideInLists' => true), 'restrictOwningBranchesAndSystems' => array('property' => 'restrictOwningBranchesAndSystems', 'type' => 'checkbox', 'label' => 'Restrict Owning Branch and System Facets to this library', 'description' => 'Whether or not the Owning Branch and Owning System Facets will only display values relevant to this library.', 'hideInLists' => true), 'showAvailableAtAnyLocation' => array('property' => 'showAvailableAtAnyLocation', 'type' => 'checkbox', 'label' => 'Show Available At Any Location?', 'description' => 'Whether or not to show any Marmot Location within the Available At facet', 'hideInLists' => true), 'repeatSearchOption' => array('property' => 'repeatSearchOption', 'type' => 'enum', 'values' => array('none' => 'None', 'librarySystem' => 'Library System', 'marmot' => 'Marmot'), 'label' => 'Repeat Search Options', 'description' => 'Where to allow repeating search. Valid options are: none, librarySystem, marmot, all'), 'systemsToRepeatIn' => array('property' => 'systemsToRepeatIn', 'type' => 'text', 'label' => 'Systems To Repeat In', 'description' => 'A list of library codes that you would like to repeat search in separated by pipes |.', 'size' => '20', 'hideInLists' => true), 'additionalLocationsToShowAvailabilityFor' => array('property' => 'additionalLocationsToShowAvailabilityFor', 'type' => 'text', 'label' => 'Additional Locations to Include in Available At Facet', 'description' => 'A list of library codes that you would like included in the available at facet separated by pipes |.', 'size' => '20', 'hideInLists' => true), 'availabilityToggleLabelSuperScope' => array('property' => 'availabilityToggleLabelSuperScope', 'type' => 'text', 'label' => 'SuperScope Toggle Label', 'description' => 'The label to show when viewing super scope i.e. Consortium Name / Entire Collection / Everything.  Does not show if superscope is not enabled.', 'default' => 'Entire Collection'), 'availabilityToggleLabelLocal' => array('property' => 'availabilityToggleLabelLocal', 'type' => 'text', 'label' => 'Local Collection Toggle Label', 'description' => 'The label to show when viewing the local collection i.e. Library Name / Local Collection.  Leave blank to hide the button.', 'default' => ''), 'availabilityToggleLabelAvailable' => array('property' => 'availabilityToggleLabelAvailable', 'type' => 'text', 'label' => 'Available Toggle Label', 'description' => 'The label to show when viewing available items i.e. Available Now / Available Locally / Available Here.', 'default' => 'Available Now'), 'repeatInOnlineCollection' => array('property' => 'repeatInOnlineCollection', 'type' => 'checkbox', 'label' => 'Repeat In Online Collection', 'description' => 'Turn on to allow repeat search in the Online Collection.', 'hideInLists' => true, 'default' => false), 'showMarmotResultsAtEndOfSearch' => array('property' => 'showMarmotResultsAtEndOfSearch', 'type' => 'checkbox', 'label' => 'Show Consortium Results at the end of Scoped Searches', 'description' => 'Whether or not the Pika should show search results from the entire Consortium at the end of scoped searches.', 'hideInLists' => true, 'default' => 1), 'showAdvancedSearchbox' => array('property' => 'showAdvancedSearchbox', 'type' => 'checkbox', 'label' => 'Show Advanced Search Link', 'description' => 'Whether or not users should see the advanced search link next to the search box.  It will still appear in the footer.', 'hideInLists' => true, 'default' => 1), 'applyNumberOfHoldingsBoost' => array('property' => 'applyNumberOfHoldingsBoost', 'type' => 'checkbox', 'label' => 'Apply Number Of Holdings Boost', 'description' => 'Whether or not the relevance will use boosting by number of holdings in the catalog.', 'hideInLists' => true, 'default' => 1), 'showSearchTools' => array('property' => 'showSearchTools', 'type' => 'checkbox', 'label' => 'Show Search Tools', 'description' => 'Turn on to activate search tools (save search, export to excel, rss feed, etc).', 'hideInLists' => true), 'recordsToBlackList' => array('property' => 'recordsToBlackList', 'type' => 'textarea', 'label' => 'Records to deaccession', 'description' => 'A list of records to deaccession (hide) in search results.  Enter one record per line.', 'hideInLists' => true))), array('property' => 'enrichmentSection', 'type' => 'section', 'label' => 'Catalog Enrichment', 'hideInLists' => true, 'properties' => array('showStandardReviews' => array('property' => 'showStandardReviews', 'type' => 'checkbox', 'label' => 'Show Standard Reviews', 'description' => 'Whether or not reviews from Content Cafe/Syndetics are displayed on the full record page.', 'hideInLists' => true, 'default' => 1), 'showGoodReadsReviews' => array('property' => 'showGoodReadsReviews', 'type' => 'checkbox', 'label' => 'Show GoodReads Reviews', 'description' => 'Whether or not reviews from GoodReads are displayed on the full record page.', 'hideInLists' => true, 'default' => true), 'preferSyndeticsSummary' => array('property' => 'preferSyndeticsSummary', 'type' => 'checkbox', 'label' => 'Prefer Syndetics Summary', 'description' => 'Whether or not the Syndetics Summary should be preferred over the Summary in the Marc Record.', 'hideInLists' => true, 'default' => 1), 'showSimilarAuthors' => array('property' => 'showSimilarAuthors', 'type' => 'checkbox', 'label' => 'Show Similar Authors', 'description' => 'Whether or not Similar Authors from Novelist is shown.', 'default' => 1, 'hideInLists' => true), 'showSimilarTitles' => array('property' => 'showSimilarTitles', 'type' => 'checkbox', 'label' => 'Show Similar Titles', 'description' => 'Whether or not Similar Titles from Novelist is shown.', 'default' => 1, 'hideInLists' => true), 'showGoDeeper' => array('property' => 'showGoDeeper', 'type' => 'checkbox', 'label' => 'Show Go Deeper', 'description' => 'Whether or not Go Deeper link is shown in full record page', 'default' => 1, 'hideInLists' => true), 'showRatings' => array('property' => 'showRatings', 'type' => 'checkbox', 'label' => 'Show Ratings', 'description' => 'Whether or not ratings are shown', 'hideInLists' => true, 'default' => 1), 'showFavorites' => array('property' => 'showFavorites', 'type' => 'checkbox', 'label' => 'Show Favorites', 'description' => 'Whether or not users can maintain favorites lists', 'hideInLists' => true, 'default' => 1), 'showOtherEditionsPopup' => array('property' => 'showOtherEditionsPopup', 'type' => 'checkbox', 'label' => 'Show Other Editions Popup', 'description' => 'Whether or not the Other Formats and Langauges popup will be shown (if not shows Other Editions sidebar)', 'default' => '1', 'hideInLists' => true), 'showWikipediaContent' => array('property' => 'showWikipediaContent', 'type' => 'checkbox', 'label' => 'Show Wikipedia Content', 'description' => 'Whether or not Wikipedia content should be shown on author page', 'default' => '1', 'hideInLists' => true))), array('property' => 'fullRecordSection', 'type' => 'section', 'label' => 'Full Record Display', 'hideInLists' => true, 'properties' => array('showTextThis' => array('property' => 'showTextThis', 'type' => 'checkbox', 'label' => 'Show Text This', 'description' => 'Whether or not the Text This link is shown', 'hideInLists' => true, 'default' => 1), 'showEmailThis' => array('property' => 'showEmailThis', 'type' => 'checkbox', 'label' => 'Show Email This', 'description' => 'Whether or not the Email This link is shown', 'hideInLists' => true, 'default' => 1), 'showShareOnExternalSites' => array('property' => 'showShareOnExternalSites', 'type' => 'checkbox', 'label' => 'Show Sharing To External Sites', 'description' => 'Whether or not sharing on external sites (Twitter, Facebook, Pinterest, etc. is shown)', 'hideInLists' => true, 'default' => 1), 'showQRCode' => array('property' => 'showQRCode', 'type' => 'checkbox', 'label' => 'Show QR Code', 'description' => 'Whether or not the catalog should show a QR Code in full record view', 'hideInLists' => true, 'default' => 1), 'showComments' => array('property' => 'showComments', 'type' => 'checkbox', 'label' => 'Show Comments', 'description' => 'Whether or not user comments are shown (also disables adding comments)', 'hideInLists' => true, 'default' => 1), 'hideCommentsWithBadWords' => array('property' => 'hideCommentsWithBadWords', 'type' => 'checkbox', 'label' => 'Hide Comments with Bad Words', 'description' => 'If checked, any comments with bad words are completely removed from the user interface for everyone except the original poster.', 'hideInLists' => true), 'showTagging' => array('property' => 'showTagging', 'type' => 'checkbox', 'label' => 'Show Tagging', 'description' => 'Whether or not tags are shown (also disables adding tags)', 'hideInLists' => true, 'default' => 1), 'showTableOfContentsTab' => array('property' => 'showTableOfContentsTab', 'type' => 'checkbox', 'label' => 'Show Table of Contents Tab', 'description' => 'Whether or not a separate tab will be shown for table of contents 505 field.', 'hideInLists' => true, 'default' => 1), 'notesTabName' => array('property' => 'notesTabName', 'type' => 'text', 'label' => 'Notes Tab Name', 'description' => 'Text to display for the the notes tab.', 'size' => '40', 'maxLength' => '50', 'hideInLists' => true, 'default' => 'Notes'), 'exportOptions' => array('property' => 'exportOptions', 'type' => 'text', 'label' => 'Export Options', 'description' => 'A list of export options that should be enabled separated by pipes.  Valid values are currently RefWorks and EndNote.', 'size' => '40', 'hideInLists' => true), 'show856LinksAsTab' => array('property' => 'show856LinksAsTab', 'type' => 'checkbox', 'label' => 'Show 856 Links as Tab', 'description' => 'Whether or not 856 links will be shown in their own tab or on the same tab as holdings.', 'hideInLists' => true, 'default' => 1), 'showProspectorTitlesAsTab' => array('property' => 'showProspectorTitlesAsTab', 'type' => 'checkbox', 'label' => 'Show Prospector Titles as Tab', 'description' => 'Whether or not Prospector TItles links will be shown in their own tab or in the sidebar in full record view.', 'default' => 1, 'hideInLists' => true), 'showCheckInGrid' => array('property' => 'showCheckInGrid', 'type' => 'checkbox', 'label' => 'Show Check-in Grid', 'description' => 'Whether or not the check-in grid is shown for periodicals.', 'default' => 1, 'hideInLists' => true), 'showStaffView' => array('property' => 'showStaffView', 'type' => 'checkbox', 'label' => 'Show Staff View', 'description' => 'Whether or not the staff view is displayed in full record view.', 'hideInLists' => true, 'default' => true), 'showInMainDetails' => array('property' => 'showInMainDetails', 'type' => 'multiSelect', 'label' => 'Which details to show in the main/top details section : ', 'description' => 'Selected details will be shown in the top/main section of the full record view. Details not selected are moved to the More Details accordion.', 'listStyle' => 'checkboxSimple', 'values' => self::$showInMainDetailsOptions), 'moreDetailsOptions' => array('property' => 'moreDetailsOptions', 'type' => 'oneToMany', 'label' => 'Full Record Options', 'description' => 'Record Options for the display of full record', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'LibraryMoreDetails', 'structure' => $libraryMoreDetailsStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => true, 'canEdit' => true))), array('property' => 'holdingsSummarySection', 'type' => 'section', 'label' => 'Holdings Summary', 'hideInLists' => true, 'properties' => array('showCopiesLineInHoldingsSummary' => array('property' => 'showCopiesLineInHoldingsSummary', 'type' => 'checkbox', 'label' => 'Show Copies Line In Holdings Summary', 'description' => 'Whether or not the number of copies should be shown in the holdins summary', 'default' => '1', 'hideInLists' => true), 'showItsHere' => array('property' => 'showItsHere', 'type' => 'checkbox', 'label' => 'Show It\'s Here', 'description' => 'Whether or not the holdings summray should show It\'s here based on IP and the currently logged in patron\'s location.', 'hideInLists' => true, 'default' => 1))), array('property' => 'materialsRequestSection', 'type' => 'section', 'label' => 'Materials Request', 'hideInLists' => true, 'properties' => array('enableMaterialsRequest' => array('property' => 'enableMaterialsRequest', 'type' => 'checkbox', 'label' => 'Enable Pika Materials Request System', 'description' => 'Enable Materials Request functionality so patrons can request items not in the catalog.', 'hideInLists' => true), 'externalMaterialsRequestUrl' => array('property' => 'externalMaterialsRequestUrl', 'type' => 'text', 'label' => 'External Materials Request URL', 'description' => 'A link to an external Materials Request System to be used instead of the built in Pika system', 'hideInList' => true), 'maxRequestsPerYear' => array('property' => 'maxRequestsPerYear', 'type' => 'integer', 'label' => 'Max Requests Per Year', 'description' => 'The maximum number of requests that a user can make within a year', 'hideInLists' => true, 'default' => 60), 'maxOpenRequests' => array('property' => 'maxOpenRequests', 'type' => 'integer', 'label' => 'Max Open Requests', 'description' => 'The maximum number of requests that a user can have open at one time', 'hideInLists' => true, 'default' => 5))), array('property' => 'goldrushSection', 'type' => 'section', 'label' => 'Gold Rush', 'hideInLists' => true, 'properties' => array('goldRushCode' => array('property' => 'goldRushCode', 'type' => 'text', 'label' => 'Gold Rush Inst Code', 'description' => 'The INST Code to use with Gold Rush.  Leave blank to not link to Gold Rush.', 'hideInLists' => true))), array('property' => 'prospectorSection', 'type' => 'section', 'label' => 'Prospector', 'hideInLists' => true, 'properties' => array('repeatInProspector' => array('property' => 'repeatInProspector', 'type' => 'checkbox', 'label' => 'Repeat In Prospector', 'description' => 'Turn on to allow repeat search in Prospector functionality.', 'hideInLists' => true, 'default' => 1), 'prospectorCode' => array('property' => 'prospectorCode', 'type' => 'text', 'label' => 'Prospector Code', 'description' => 'The code used to identify this location within Prospector. Leave blank if items for this location are not in Prospector.', 'hideInLists' => true), 'enablePospectorIntegration' => array('property' => 'enablePospectorIntegration', 'type' => 'checkbox', 'label' => 'Enable Prospector Integration', 'description' => 'Whether or not Prospector Integrations should be displayed for this library.', 'hideInLists' => true, 'default' => 1), 'showProspectorResultsAtEndOfSearch' => array('property' => 'showProspectorResultsAtEndOfSearch', 'type' => 'checkbox', 'label' => 'Show Prospector Results At End Of Search', 'description' => 'Whether or not Prospector Search Results should be shown at the end of search results.', 'hideInLists' => true, 'default' => 1))), array('property' => 'worldCatSection', 'type' => 'section', 'label' => 'WorldCat', 'hideInLists' => true, 'properties' => array('repeatInWorldCat' => array('property' => 'repeatInWorldCat', 'type' => 'checkbox', 'label' => 'Repeat In WorldCat', 'description' => 'Turn on to allow repeat search in WorldCat functionality.', 'hideInLists' => true), 'worldCatUrl' => array('property' => 'worldCatUrl', 'type' => 'text', 'label' => 'WorldCat URL', 'description' => 'A custom World Cat URL to use while searching.', 'hideInLists' => true, 'size' => '80'), 'worldCatQt' => array('property' => 'worldCatQt', 'type' => 'text', 'label' => 'WorldCat QT', 'description' => 'A custom World Cat QT term to use while searching.', 'hideInLists' => true, 'size' => '40'))), array('property' => 'overdriveSection', 'type' => 'section', 'label' => 'OverDrive', 'hideInLists' => true, 'properties' => array('enableOverdriveCollection' => array('property' => 'enableOverdriveCollection', 'type' => 'checkbox', 'label' => 'Enable Overdrive Collection', 'description' => 'Whether or not titles from the Overdrive collection should be included in searches', 'hideInLists' => true), 'repeatInOverdrive' => array('property' => 'repeatInOverdrive', 'type' => 'checkbox', 'label' => 'Repeat In Overdrive', 'description' => 'Turn on to allow repeat search in Overdrive functionality.', 'hideInLists' => true, 'default' => 0), 'overdriveAuthenticationILSName' => array('property' => 'overdriveAuthenticationILSName', 'type' => 'text', 'label' => 'The ILS Name Overdrive uses for user Authentication', 'description' => 'The name of the ILS that OverDrive uses to authenticate users logging into the Overdrive website.', 'size' => '20', 'hideInLists' => true), 'overdriveRequirePin' => array('property' => 'overdriveRequirePin', 'type' => 'checkbox', 'label' => 'Is a Pin Required to log into Overdrive website?', 'description' => 'Turn on to allow repeat search in Overdrive functionality.', 'hideInLists' => true, 'default' => 0), 'overdriveAdvantageName' => array('property' => 'overdriveAdvantageName', 'type' => 'text', 'label' => 'Overdrive Advantage Name', 'description' => 'The name of the OverDrive Advantage account if any.', 'size' => '80', 'hideInLists' => true), 'overdriveAdvantageProductsKey' => array('property' => 'overdriveAdvantageProductsKey', 'type' => 'text', 'label' => 'Overdrive Advantage Products Key', 'description' => 'The products key for use when building urls to the API from the advantageAccounts call.', 'size' => '80', 'hideInLists' => false))), array('property' => 'hooplaSection', 'type' => 'section', 'label' => 'Hoopla', 'hideInLists' => true, 'properties' => array('includeHoopla' => array('property' => 'includeHoopla', 'type' => 'checkbox', 'label' => 'Include Hoopla content in search results', 'description' => 'Whether or not Hoopla data should be included for this library.', 'hideInLists' => true, 'default' => 0))), array('property' => 'dplaSection', 'type' => 'section', 'label' => 'DPLA', 'hideInLists' => true, 'properties' => array('includeDplaResults' => array('property' => 'includeDplaResults', 'type' => 'checkbox', 'label' => 'Include DPLA content in search results', 'description' => 'Whether or not DPLA data should be included for this library.', 'hideInLists' => true, 'default' => 0))), 'holidays' => array('property' => 'holidays', 'type' => 'oneToMany', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'Holiday', 'structure' => $holidaysStructure, 'label' => 'Holidays', 'description' => 'Holidays', 'sortable' => false, 'storeDb' => true), 'nearbyBookStores' => array('property' => 'nearbyBookStores', 'type' => 'oneToMany', 'label' => 'Nearby Book Stores', 'description' => 'A list of book stores to search', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'NearbyBookStore', 'structure' => $nearbyBookStoreStructure, 'sortable' => true, 'storeDb' => true), 'facets' => array('property' => 'facets', 'type' => 'oneToMany', 'label' => 'Facets', 'description' => 'A list of facets to display in search results', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'LibraryFacetSetting', 'structure' => $facetSettingStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => true, 'canEdit' => true), 'searchSources' => array('property' => 'searchSources', 'type' => 'oneToMany', 'label' => 'Search Sources', 'description' => 'Searches to display to the user', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'LibrarySearchSource', 'structure' => $searchSourceStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => true, 'canEdit' => true), 'browseCategories' => array('property' => 'browseCategories', 'type' => 'oneToMany', 'label' => 'Browse Categories', 'description' => 'Browse Categories To Show on the Home Screen', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'LibraryBrowseCategory', 'structure' => $libraryBrowseCategoryStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => false, 'canEdit' => false), 'libraryLinks' => array('property' => 'libraryLinks', 'type' => 'oneToMany', 'label' => 'Sidebar Links', 'description' => 'Links To Show in the sidebar', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'LibraryLinks', 'structure' => $libraryLinksStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => false, 'canEdit' => false), 'libraryTopLinks' => array('property' => 'libraryTopLinks', 'type' => 'oneToMany', 'label' => 'Header Links', 'description' => 'Links To Show in the header', 'keyThis' => 'libraryId', 'keyOther' => 'libraryId', 'subObjectType' => 'LibraryTopLinks', 'structure' => $libraryTopLinksStructure, 'sortable' => true, 'storeDb' => true, 'allowEdit' => false, 'canEdit' => false));
     foreach ($structure as $fieldName => $field) {
         if (isset($field['property'])) {
             $field['propertyOld'] = $field['property'] . 'Old';
             $structure[$fieldName] = $field;
         }
     }
     return $structure;
 }
Exemplo n.º 18
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     //Get a list of all reports the user has access to
     $reportDir = $configArray['Site']['reportPath'];
     $allowableLocationCodes = "";
     if ($user->hasRole('opacAdmin')) {
         $allowableLocationCodes = '.*';
     } elseif ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $allowableLocationCodes = trim($homeLibrary->ilsCode) . '.*';
     } elseif ($user->hasRole('locationReports')) {
         $homeLocation = Location::getUserHomeLocation();
         $allowableLocationCodes = trim($homeLocation->code) . '.*';
     }
     $availableReports = array();
     $dh = opendir($reportDir);
     while (false !== ($filename = readdir($dh))) {
         if (is_file($reportDir . '/' . $filename)) {
             if (preg_match('/(\\w+)_school_report\\.csv/i', $filename, $matches)) {
                 $locationCode = $matches[1];
                 if (preg_match("/{$allowableLocationCodes}/", $locationCode)) {
                     $availableReports[$locationCode] = $filename;
                 }
             }
         }
     }
     ksort($availableReports);
     $interface->assign('availableReports', $availableReports);
     $selectedReport = isset($_REQUEST['selectedReport']) ? $availableReports[$_REQUEST['selectedReport']] : reset($availableReports);
     $interface->assign('selectedReport', $selectedReport);
     $showOverdueOnly = isset($_REQUEST['showOverdueOnly']) ? $_REQUEST['showOverdueOnly'] == 'overdue' : true;
     $interface->assign('showOverdueOnly', $showOverdueOnly);
     $now = time();
     $fileData = array();
     if ($selectedReport) {
         $fhnd = fopen($reportDir . '/' . $selectedReport, "r");
         if ($fhnd) {
             while (($data = fgetcsv($fhnd)) !== FALSE) {
                 $okToInclude = true;
                 if ($showOverdueOnly) {
                     $dueDate = $data[12];
                     $dueTime = strtotime($dueDate);
                     if ($dueTime >= $now) {
                         $okToInclude = false;
                     }
                 }
                 if ($okToInclude || count($fileData) == 0) {
                     $fileData[] = $data;
                 }
             }
             $interface->assign('reportData', $fileData);
         }
     }
     if (isset($_REQUEST['download'])) {
         header('Content-Type: text/csv');
         header('Content-Disposition: attachment; filename=' . $selectedReport);
         header('Content-Length:' . filesize($reportDir . '/' . $selectedReport));
         foreach ($fileData as $row) {
             foreach ($row as $index => $cell) {
                 if ($index != 0) {
                     echo ",";
                 }
                 if (strpos($cell, ',') != false) {
                     echo '"' . $cell . '"';
                 } else {
                     echo $cell;
                 }
             }
             echo "\r\n";
         }
         exit;
     }
     $interface->setPageTitle('Student Report');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('studentReport.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 19
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Load status information
     $materialsRequestStatus = new MaterialsRequestStatus();
     $materialsRequestStatus->orderBy('isDefault DESC, isOpen DESC, description ASC');
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $materialsRequestStatus->libraryId = $homeLibrary->libraryId;
     } else {
         $libraryList[-1] = 'Default';
     }
     $materialsRequestStatus->find();
     $allStatuses = array();
     $availableStatuses = array();
     $defaultStatusesToShow = array();
     while ($materialsRequestStatus->fetch()) {
         $availableStatuses[$materialsRequestStatus->id] = $materialsRequestStatus->description;
         $allStatuses[$materialsRequestStatus->id] = clone $materialsRequestStatus;
         if ($materialsRequestStatus->isOpen == 1 || $materialsRequestStatus->isDefault == 1) {
             $defaultStatusesToShow[] = $materialsRequestStatus->id;
         }
     }
     $interface->assign('availableStatuses', $availableStatuses);
     if (isset($_REQUEST['statusFilter'])) {
         $statusesToShow = $_REQUEST['statusFilter'];
         $_SESSION['materialsRequestStatusFilter'] = $statusesToShow;
     } elseif (isset($_SESSION['materialsRequestStatusFilter'])) {
         $statusesToShow = $_SESSION['materialsRequestStatusFilter'];
     } else {
         $statusesToShow = $defaultStatusesToShow;
     }
     $interface->assign('statusFilter', $statusesToShow);
     //Process status change if needed
     if (isset($_REQUEST['updateStatus']) && isset($_REQUEST['select'])) {
         //Look for which titles should be modified
         $selectedRequests = $_REQUEST['select'];
         $statusToSet = $_REQUEST['newStatus'];
         require_once ROOT_DIR . '/sys/Mailer.php';
         $mail = new VuFindMailer();
         foreach ($selectedRequests as $requestId => $selected) {
             $materialRequest = new MaterialsRequest();
             $materialRequest->id = $requestId;
             if ($materialRequest->find(true)) {
                 $materialRequest->status = $statusToSet;
                 $materialRequest->dateUpdated = time();
                 $materialRequest->update();
                 if ($allStatuses[$statusToSet]->sendEmailToPatron == 1 && $materialRequest->email) {
                     $body = '*****This is an auto-generated email response. Please do not reply.*****';
                     $body .= "\r\n" . $allStatuses[$statusToSet]->emailTemplate;
                     //Replace tags with appropriate values
                     $materialsRequestUser = new User();
                     $materialsRequestUser->id = $materialRequest->createdBy;
                     $materialsRequestUser->find(true);
                     foreach ($materialsRequestUser as $fieldName => $fieldValue) {
                         if (!is_array($fieldValue)) {
                             $body = str_replace('{' . $fieldName . '}', $fieldValue, $body);
                         }
                     }
                     foreach ($materialRequest as $fieldName => $fieldValue) {
                         if (!is_array($fieldValue)) {
                             $body = str_replace('{' . $fieldName . '}', $fieldValue, $body);
                         }
                     }
                     $materialsRequestUser->find(true);
                     $mail->send($materialRequest->email, $configArray['Site']['email'], "Your Materials Request Update", $body, $configArray['Site']['email']);
                 }
             }
         }
     }
     $availableFormats = MaterialsRequest::getFormats();
     $interface->assign('availableFormats', $availableFormats);
     $defaultFormatsToShow = array_keys($availableFormats);
     if (isset($_REQUEST['formatFilter'])) {
         $formatsToShow = $_REQUEST['formatFilter'];
         $_SESSION['materialsRequestFormatFilter'] = $formatsToShow;
     } elseif (isset($_SESSION['materialsRequestFormatFilter'])) {
         $formatsToShow = $_SESSION['materialsRequestFormatFilter'];
     } else {
         $formatsToShow = $defaultFormatsToShow;
     }
     $interface->assign('formatFilter', $formatsToShow);
     //Get a list of all materials requests for the user
     $allRequests = array();
     if ($user) {
         $materialsRequests = new MaterialsRequest();
         $materialsRequests->joinAdd(new Location(), "LEFT");
         $materialsRequests->joinAdd(new MaterialsRequestStatus());
         $materialsRequests->joinAdd(new User(), 'INNER', 'user');
         $materialsRequests->selectAdd();
         $materialsRequests->selectAdd('materials_request.*, description as statusLabel, location.displayName as location, firstname, lastname, ' . $configArray['Catalog']['barcodeProperty'] . ' as barcode');
         if ($user->hasRole('library_material_requests')) {
             //Need to limit to only requests submitted for the user's home location
             $userHomeLibrary = Library::getPatronHomeLibrary();
             $locations = new Location();
             $locations->libraryId = $userHomeLibrary->libraryId;
             $locations->find();
             $locationsForLibrary = array();
             while ($locations->fetch()) {
                 $locationsForLibrary[] = $locations->locationId;
             }
             $materialsRequests->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
         }
         if (count($availableStatuses) > count($statusesToShow)) {
             $statusSql = "";
             foreach ($statusesToShow as $status) {
                 if (strlen($statusSql) > 0) {
                     $statusSql .= ",";
                 }
                 $statusSql .= "'" . $materialsRequests->escape($status) . "'";
             }
             $materialsRequests->whereAdd("status in ({$statusSql})");
         }
         if (count($availableFormats) > count($formatsToShow)) {
             //At least one format is disabled
             $formatSql = "";
             foreach ($formatsToShow as $format) {
                 if (strlen($formatSql) > 0) {
                     $formatSql .= ",";
                 }
                 $formatSql .= "'" . $materialsRequests->escape($format) . "'";
             }
             $materialsRequests->whereAdd("format in ({$formatSql})");
         }
         //Add filtering by date as needed
         if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
             $startDate = strtotime($_REQUEST['startDate']);
             $materialsRequests->whereAdd("dateCreated >= {$startDate}");
             $interface->assign('startDate', $_REQUEST['startDate']);
         }
         if (isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0) {
             $endDate = strtotime($_REQUEST['endDate']);
             $materialsRequests->whereAdd("dateCreated <= {$endDate}");
             $interface->assign('endDate', $_REQUEST['endDate']);
         }
         $materialsRequests->find();
         while ($materialsRequests->fetch()) {
             $allRequests[] = clone $materialsRequests;
         }
     } else {
         $interface->assign('error', "You must be logged in to manage requests.");
     }
     $interface->assign('allRequests', $allRequests);
     if (isset($_REQUEST['exportSelected'])) {
         $this->exportToExcel($_REQUEST['select'], $allRequests);
     } else {
         $interface->setTemplate('manageRequests.tpl');
         $interface->setPageTitle('Manage Materials Requests');
         $interface->display('layout.tpl');
     }
 }
Exemplo n.º 20
0
 function getAddToWidgetForm()
 {
     global $interface;
     global $user;
     // Display Page
     $interface->assign('id', strip_tags($_REQUEST['id']));
     $interface->assign('source', strip_tags($_REQUEST['source']));
     $interface->assign('popupTitle', 'Create a Widget');
     $existingWidgets = array();
     $listWidget = new ListWidget();
     if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
         //Get all widgets for the library
         $userLibrary = Library::getPatronHomeLibrary();
         $listWidget->libraryId = $userLibrary->libraryId;
     }
     $listWidget->find();
     while ($listWidget->fetch()) {
         $existingWidgets[$listWidget->id] = $listWidget->name;
     }
     $interface->assign('existingWidgets', $existingWidgets);
     $pageContent = $interface->fetch('Admin/addToWidgetForm.tpl');
     $interface->assign('popupContent', $pageContent);
     echo $interface->fetch('popup-wrapper.tpl');
 }
Exemplo n.º 21
0
 function getAddToWidgetForm()
 {
     global $interface;
     global $user;
     // Display Page
     $interface->assign('id', strip_tags($_REQUEST['id']));
     $interface->assign('source', strip_tags($_REQUEST['source']));
     $existingWidgets = array();
     $listWidget = new ListWidget();
     if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
         //Get all widgets for the library
         $userLibrary = Library::getPatronHomeLibrary();
         $listWidget->libraryId = $userLibrary->libraryId;
     }
     $listWidget->find();
     while ($listWidget->fetch()) {
         $existingWidgets[$listWidget->id] = $listWidget->name;
     }
     $interface->assign('existingWidgets', $existingWidgets);
     $results = array('title' => 'Create a Widget', 'modalBody' => $interface->fetch('Admin/addToWidgetForm.tpl'), 'modalButtons' => "<span class='tool btn btn-primary' onclick='\$(\"#bulkAddToList\").submit();'>Create Widget</span>");
     return json_encode($results);
 }
Exemplo n.º 22
0
 /**
  * Get filters based on scoping for the search
  * @param Library $searchLibrary
  * @param Location $searchLocation
  * @return array
  */
 public function getScopingFilters($searchLibrary, $searchLocation)
 {
     global $user;
     global $configArray;
     $filter = array();
     //*************************
     //Marmot overrides for filtering based on library system and location
     //Only show visible records
     if (!isset($configArray['Index']['ignoreBibSuppression']) || $configArray['Index']['ignoreBibSuppression'] == false) {
         $filter[] = '-bib_suppression:suppressed';
     }
     //Only include titles that the user has access to based on pType
     $pType = 0;
     $owningSystem = '';
     $owningLibrary = '';
     $canUseDefaultPType = !$this->scopingDisabled;
     if ($user) {
         $pType = $user->patronType;
     } elseif (isset($searchLocation) && $searchLocation->defaultPType > 0 && $canUseDefaultPType) {
         $pType = $searchLocation->defaultPType;
     } elseif (isset($searchLibrary) && $searchLibrary->defaultPType > 0 && $canUseDefaultPType) {
         $pType = $searchLibrary->defaultPType;
     }
     if (isset($searchLocation)) {
         $owningLibrary = $searchLocation->facetLabel;
     }
     if (isset($searchLibrary)) {
         $owningSystem = $searchLibrary->facetLabel;
     }
     if ($pType > 0 && $configArray['Index']['enableUsableByFilter'] == true) {
         $usableFilter = 'usable_by:(' . $pType . ' OR all)';
         if (strlen($owningLibrary) > 0) {
             $usableFilter .= " OR building:\"{$owningLibrary}\" OR building:\"{$owningLibrary} Online\"";
         }
         if (strlen($owningSystem) > 0) {
             $usableFilter .= " OR institution:\"{$owningSystem}\" OR building:\"{$owningSystem} Online\"";
         }
         $homeLibrary = Library::getPatronHomeLibrary();
         if ($homeLibrary && $homeLibrary != $searchLibrary) {
             $homeLibraryFacet = $homeLibrary->facetLabel;
             $usableFilter .= " OR building:\"{$homeLibraryFacet}\" OR building:\"{$homeLibraryFacet} Online\"";
         }
         $filter[] = '(' . $usableFilter . ')';
     }
     $blacklistRecords = null;
     if (isset($searchLocation) && strlen($searchLocation->recordsToBlackList) > 0) {
         $blacklistRecords = $searchLocation->recordsToBlackList;
     }
     if (isset($searchLibrary) && strlen($searchLibrary->recordsToBlackList) > 0) {
         if (is_null($blacklistRecords)) {
             $blacklistRecords = $searchLibrary->recordsToBlackList;
         } else {
             $blacklistRecords .= "\n" . $searchLibrary->recordsToBlackList;
         }
     }
     if (!is_null($blacklistRecords)) {
         $recordsToBlacklist = preg_split('/\\s|\\r\\n|\\r|\\n/s', $blacklistRecords);
         $blacklist = "NOT (";
         $numRecords = 0;
         foreach ($recordsToBlacklist as $curRecord) {
             if (strlen($curRecord) > 0) {
                 $numRecords++;
                 if ($numRecords > 1) {
                     $blacklist .= " OR ";
                 }
                 $blacklist .= "id:" . $curRecord;
             }
         }
         $blacklist .= ")";
         $filter[] = $blacklist;
     }
     //Process anything that the user is not interested in.
     require_once ROOT_DIR . '/sys/NotInterested.php';
     if ($user) {
         $notInterested = new NotInterested();
         $resource = new Resource();
         $notInterested->joinAdd($resource);
         $notInterested->userId = $user->id;
         $notInterested->find();
         if ($notInterested->N > 0) {
             $notInterestedFilter = " NOT(";
             $numRecords = 0;
             while ($notInterested->fetch()) {
                 $numRecords++;
                 if ($numRecords > 1) {
                     $notInterestedFilter .= " OR ";
                 }
                 if ($notInterested->source == 'VuFind') {
                     $notInterestedFilter .= "id:" . $notInterested->record_id;
                 } else {
                     $notInterestedFilter .= "id:econtentRecord" . $notInterested->record_id;
                 }
             }
             $notInterestedFilter .= ")";
             $filter[] = $notInterestedFilter;
         }
     }
     if ($this->scopingDisabled == false) {
         if (isset($searchLibrary)) {
             if ($searchLibrary->restrictSearchByLibrary && $searchLibrary->includeDigitalCollection) {
                 $filter[] = "(institution:\"{$searchLibrary->facetLabel}\" OR institution:\"Shared Digital Collection\" OR institution:\"Digital Collection\" OR institution:\"{$searchLibrary->facetLabel} Online\")";
             } else {
                 if ($searchLibrary->restrictSearchByLibrary) {
                     $filter[] = "institution:\"{$searchLibrary->facetLabel}\"";
                 } else {
                     if (!$searchLibrary->includeDigitalCollection) {
                         $filter[] = "!(institution:\"Digital Collection\" OR institution:\"{$searchLibrary->facetLabel} Online\")";
                     }
                 }
             }
         }
         if ($searchLocation != null) {
             if ($searchLocation->restrictSearchByLocation && $searchLocation->includeDigitalCollection) {
                 $filter[] = "(building:\"{$searchLocation->facetLabel}\" OR building:\"Shared Digital Collection\" OR building:\"Digital Collection\" OR building:\"{$searchLocation->facetLabel} Online\")";
             } else {
                 if ($searchLocation->restrictSearchByLocation) {
                     $filter[] = "(building:\"{$searchLocation->facetLabel}\")";
                 } else {
                     if (!$searchLocation->includeDigitalCollection) {
                         $filter[] = "!(building:\"Shared Digital Collection\" OR building:\"Digital Collection\" OR building:\"{$searchLibrary->facetLabel} Online\")";
                     }
                 }
             }
         }
         global $defaultCollection;
         if (isset($defaultCollection) && strlen($defaultCollection) > 0) {
             $filter[] = 'collection_group:"' . $defaultCollection . '"';
         }
         if ($this->searchSource == 'econtent') {
             $filter[] = 'recordtype:"econtentRecord"';
         }
     }
     return $filter;
 }
Exemplo n.º 23
0
 function resetToDefault()
 {
     global $user;
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $materialRequestStatus = new MaterialsRequestStatus();
         $materialRequestStatus->libraryId = $homeLibrary->libraryId;
         $materialRequestStatus->delete();
         $materialRequestStatus = new MaterialsRequestStatus();
         $materialRequestStatus->libraryId = -1;
         $materialRequestStatus->find();
         while ($materialRequestStatus->fetch()) {
             $materialRequestStatus->id = null;
             $materialRequestStatus->libraryId = $homeLibrary->libraryId;
             $materialRequestStatus->insert();
         }
     }
     header("Location: /Admin/ManageStatuses");
 }
Exemplo n.º 24
0
 public function getMyProfile($patron, $forceReload = false)
 {
     global $timer;
     global $configArray;
     /** @var Memcache $memCache */
     global $memCache;
     global $serverName;
     $memCacheProfileKey = "patronProfile_{$serverName}_";
     if (is_object($patron)) {
         $patron = get_object_vars($patron);
         $userId = $patron['id'];
         $patronUserName = $patron['username'];
         $memCacheProfileKey .= $patron['username'];
     } else {
         global $user;
         $userId = $user->id;
         $patronUserName = $user->username;
         $memCacheProfileKey .= $user->username;
     }
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         $patronProfile = $memCache->get($memCacheProfileKey);
         if ($patronProfile) {
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $patronProfile;
         }
     }
     global $user;
     if ($configArray['Catalog']['offline'] == true) {
         $fullName = $patron['cat_username'];
         $Address1 = "";
         $City = "";
         $State = "";
         $Zip = "";
         $Email = "";
         $finesVal = 0;
         $expireClose = false;
         $homeBranchCode = '';
         $numHoldsAvailable = '?';
         $numHoldsRequested = '?';
         if (!$user) {
             $user = new User();
             $user->username = $patronUserName;
             if ($user->find(true)) {
                 $location = new Location();
                 $location->locationId = $user->homeLocationId;
                 $location->find(1);
                 $homeBranchCode = $location->code;
             }
         }
     } else {
         //Load the raw information about the patron from web services
         if (isset(HorizonAPI::$sessionIdsForUsers[$userId])) {
             $sessionToken = HorizonAPI::$sessionIdsForUsers[$userId];
             // keys off username
         } else {
             //Log the user in
             $return = $this->loginViaWebService($patron['cat_username'], $patron['cat_password']);
             if (count($return) == 1) {
                 $userValid = $return[0];
             } else {
                 list($userValid, $sessionToken) = $return;
             }
             if (!$userValid) {
                 echo "No session id found for user";
                 return PEAR_Singleton::raiseError("Could not login to web service " . $return);
             }
         }
         $lookupMyAccountInfoResponse = $this->getWebServiceResponse($configArray['Catalog']['webServiceUrl'] . '/standard/lookupMyAccountInfo?clientID=' . $configArray['Catalog']['clientId'] . '&sessionToken=' . $sessionToken . '&includeAddressInfo=true&includeHoldInfo=true&includeBlockInfo=true&includeItemsOutInfo=true');
         if ($lookupMyAccountInfoResponse === false) {
             global $logger;
             $logger->log("Unable to login", PEAR_LOG_WARNING);
             return null;
         }
         if (isset($lookupMyAccountInfoResponse->AddressInfo)) {
             $Address1 = (string) $lookupMyAccountInfoResponse->AddressInfo->line1;
             if (isset($lookupMyAccountInfoResponse->AddressInfo->cityState)) {
                 $cityState = (string) $lookupMyAccountInfoResponse->AddressInfo->cityState;
                 list($City, $State) = explode(', ', $cityState);
             } else {
                 $City = "";
                 $State = "";
             }
             $Zip = (string) $lookupMyAccountInfoResponse->AddressInfo->postalCode;
             if (isset($lookupMyAccountInfoResponse->AddressInfo->email)) {
                 $Email = (string) $lookupMyAccountInfoResponse->AddressInfo->email;
             }
         } else {
             $Address1 = "";
             $City = "";
             $State = "";
             $Zip = "";
             $Email = '';
         }
         $fullName = $lookupMyAccountInfoResponse->name;
         //Get additional information about the patron's home branch for display.
         if (isset($lookupMyAccountInfoResponse->locationID)) {
             $homeBranchCode = trim((string) $lookupMyAccountInfoResponse->locationID);
             //Translate home branch to plain text
             $location = new Location();
             $location->code = $homeBranchCode;
             $location->find(1);
             if ($location->N == 0) {
                 unset($location);
             }
         }
         if ($user) {
             if ($user->homeLocationId == 0 && isset($location)) {
                 $user->homeLocationId = $location->locationId;
                 if ($location->nearbyLocation1 > 0) {
                     $user->myLocation1Id = $location->nearbyLocation1;
                 } else {
                     $user->myLocation1Id = $location->locationId;
                 }
                 if ($location->nearbyLocation2 > 0) {
                     $user->myLocation2Id = $location->nearbyLocation2;
                 } else {
                     $user->myLocation2Id = $location->locationId;
                 }
                 if ($user instanceof User) {
                     //Update the database
                     $user->update();
                     //Update the serialized instance stored in the session
                     $_SESSION['userinfo'] = serialize($user);
                 }
             } else {
                 if (isset($location) && $location->locationId != $user->homeLocationId) {
                     $user->homeLocationId = $location->locationId;
                     //Update the database
                     $user->update();
                     //Update the serialized instance stored in the session
                     $_SESSION['userinfo'] = serialize($user);
                 }
             }
         }
         //TODO: See if we can get information about card expiration date
         $expireClose = 0;
         $finesVal = 0;
         if (isset($lookupMyAccountInfoResponse->BlockInfo)) {
             foreach ($lookupMyAccountInfoResponse->BlockInfo as $block) {
                 // $block is a simplexml object with attribute info about currency, type casting as below seems to work for adding up. plb 3-27-2015
                 $fineAmount = (double) $block->balance;
                 $finesVal += $fineAmount;
             }
         }
         $numHoldsAvailable = 0;
         $numHoldsRequested = 0;
         if (isset($lookupMyAccountInfoResponse->HoldInfo)) {
             foreach ($lookupMyAccountInfoResponse->HoldInfo as $hold) {
                 if ($hold->status == 'FILLED') {
                     $numHoldsAvailable++;
                 } else {
                     $numHoldsRequested++;
                 }
             }
         }
     }
     if ($user) {
         //Get display name for preferred location 1
         $myLocation1 = new Location();
         $myLocation1->whereAdd("locationId = '{$user->myLocation1Id}'");
         $myLocation1->find(1);
         //Get display name for preferred location 1
         $myLocation2 = new Location();
         $myLocation2->whereAdd("locationId = '{$user->myLocation2Id}'");
         $myLocation2->find(1);
     }
     list($fullName, $lastName, $firstName) = $this->splitFullName($fullName);
     $profile = array('lastname' => $lastName, 'firstname' => $firstName, 'fullname' => $fullName, 'address1' => $Address1, 'address2' => $City . ', ' . $State, 'city' => $City, 'state' => $State, 'zip' => $Zip, 'email' => $user && $user->email ? $user->email : $Email, 'overdriveEmail' => $user ? $user->overdriveEmail : $Email, 'promptForOverdriveEmail' => $user ? $user->promptForOverdriveEmail : 1, 'phone' => isset($lookupMyAccountInfoResponse->phone) ? (string) $lookupMyAccountInfoResponse->phone : '', 'workPhone' => '', 'mobileNumber' => '', 'fines' => sprintf('$%01.2f', $finesVal), 'finesval' => $finesVal, 'expires' => '', 'expireclose' => $expireClose, 'homeLocationCode' => isset($homeBranchCode) ? trim($homeBranchCode) : '', 'homeLocationId' => isset($location) ? $location->locationId : 0, 'homeLocation' => isset($location) ? $location->displayName : '', 'myLocation1Id' => $user ? $user->myLocation1Id : -1, 'myLocation1' => isset($myLocation1) ? $myLocation1->displayName : '', 'myLocation2Id' => $user ? $user->myLocation2Id : -1, 'myLocation2' => isset($myLocation2) ? $myLocation2->displayName : '', 'numCheckedOut' => isset($lookupMyAccountInfoResponse->ItemsOutInfo) ? count($lookupMyAccountInfoResponse->ItemsOutInfo) : 0, 'numHolds' => $numHoldsAvailable + $numHoldsRequested, 'numHoldsAvailable' => $numHoldsAvailable, 'numHoldsRequested' => $numHoldsRequested, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : 0, 'ptype' => 0, 'notices' => '-', 'noticePreferenceLabel' => 'e-mail', 'web_note' => '');
     //Get eContent info as well
     require_once ROOT_DIR . '/Drivers/EContentDriver.php';
     $eContentDriver = new EContentDriver();
     $eContentAccountSummary = $eContentDriver->getAccountSummary();
     $profile = array_merge($profile, $eContentAccountSummary);
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     if ($overDriveDriver->isUserValidForOverDrive($user)) {
         $overDriveSummary = $overDriveDriver->getOverDriveSummary($user);
         $profile['numOverDriveCheckedOut'] = $overDriveSummary['numCheckedOut'];
         $profile['numOverDriveHoldsAvailable'] = $overDriveSummary['numAvailableHolds'];
         $profile['numOverDriveHoldsRequested'] = $overDriveSummary['numUnavailableHolds'];
         $profile['canUseOverDrive'] = true;
     } else {
         $profile['numOverDriveCheckedOut'] = 0;
         $profile['numOverDriveHoldsAvailable'] = 0;
         $profile['numOverDriveHoldsRequested'] = 0;
         $profile['canUseOverDrive'] = false;
     }
     $profile['numCheckedOutTotal'] = $profile['numCheckedOut'] + $profile['numOverDriveCheckedOut'] + $eContentAccountSummary['numEContentCheckedOut'];
     $profile['numHoldsAvailableTotal'] = $profile['numHoldsAvailable'] + $profile['numOverDriveHoldsAvailable'] + $eContentAccountSummary['numEContentAvailableHolds'];
     $profile['numHoldsRequestedTotal'] = $profile['numHoldsRequested'] + $profile['numOverDriveHoldsRequested'] + $eContentAccountSummary['numEContentUnavailableHolds'];
     $profile['numHoldsTotal'] = $profile['numHoldsAvailableTotal'] + $profile['numHoldsRequestedTotal'];
     //Get a count of the materials requests for the user
     if ($user) {
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->createdBy = $user->id;
         $homeLibrary = Library::getPatronHomeLibrary();
         $statusQuery = new MaterialsRequestStatus();
         $statusQuery->isOpen = 1;
         $statusQuery->libraryId = $homeLibrary->libraryId;
         $materialsRequest->joinAdd($statusQuery);
         $materialsRequest->find();
         $profile['numMaterialsRequests'] = $materialsRequest->N;
     }
     $timer->logTime("Got Patron Profile");
     $memCache->set($memCacheProfileKey, $profile, 0, $configArray['Caching']['patron_profile']);
     return $profile;
 }
Exemplo n.º 25
0
 /**
  * Get Patron Profile
  *
  * This is responsible for retrieving the profile for a specific patron.
  * Interface defined in CatalogConnection.php
  *
  * @param   array   $patron     The patron array
  * @return  array               Array of the patron's profile data
  *                              If an error occures, return a PEAR_Error
  * @access  public
  */
 public function getMyProfile($patron)
 {
     global $timer;
     global $configArray;
     if (is_object($patron)) {
         $patron = get_object_vars($patron);
         $id2 = $this->_getBarcode();
     } else {
         $id2 = $patron['id'];
     }
     if (array_key_exists($patron['id'], $this->patronProfiles)) {
         $timer->logTime('Retrieved Cached Profile for Patron');
         return $this->patronProfiles[$patron['id']];
     }
     //Load the raw information about the patron
     $patronDump = $this->_getPatronDump($id2);
     if (isset($patronDump['ADDRESS'])) {
         $Fulladdress = $patronDump['ADDRESS'];
         $addressParts = explode('$', $Fulladdress);
         $Address1 = $addressParts[0];
         $City = isset($addressParts[1]) ? $addressParts[1] : '';
         $State = isset($addressParts[2]) ? $addressParts[2] : '';
         $Zip = isset($addressParts[3]) ? $addressParts[3] : '';
         if (preg_match('/(.*?),\\s+(.*)\\s+(\\d*(?:-\\d*)?)/', $City, $matches)) {
             $City = $matches[1];
             $State = $matches[2];
             $Zip = $matches[3];
         }
     } else {
         $Address1 = "";
         $City = "";
         $State = "";
         $Zip = "";
     }
     $fullName = $patronDump['PATRN_NAME'];
     $nameParts = explode(', ', $fullName);
     $lastName = $nameParts[0];
     $secondName = isset($nameParts[1]) ? $nameParts[1] : '';
     if (strpos($secondName, ' ')) {
         $nameParts2 = explode(' ', $secondName);
         $firstName = $nameParts2[0];
     } else {
         $firstName = $secondName;
     }
     //Get additional information about the patron's home branch for display.
     $homeBranchCode = $patronDump['HOME_LIBR'];
     //Translate home branch to plain text
     global $user;
     $location = new Location();
     $location->whereAdd("code = '{$homeBranchCode}'");
     $location->find(1);
     if ($user) {
         if ($user->homeLocationId == 0) {
             $user->homeLocationId = $location->locationId;
             if ($location->nearbyLocation1 > 0) {
                 $user->myLocation1Id = $location->nearbyLocation1;
             } else {
                 $user->myLocation1Id = $location->locationId;
             }
             if ($location->nearbyLocation2 > 0) {
                 $user->myLocation2Id = $location->nearbyLocation2;
             } else {
                 $user->myLocation2Id = $location->locationId;
             }
             if ($user instanceof User) {
                 //Update the database
                 $user->update();
                 //Update the serialized instance stored in the session
                 $_SESSION['userinfo'] = serialize($user);
             }
         }
         //Get display name for preferred location 1
         $myLocation1 = new Location();
         $myLocation1->whereAdd("locationId = '{$user->myLocation1Id}'");
         $myLocation1->find(1);
         //Get display name for preferred location 1
         $myLocation2 = new Location();
         $myLocation2->whereAdd("locationId = '{$user->myLocation2Id}'");
         $myLocation2->find(1);
     }
     //see if expiration date is close
     list($monthExp, $dayExp, $yearExp) = explode("-", $patronDump['EXP_DATE']);
     $timeExpire = strtotime($monthExp . "/" . $dayExp . "/" . $yearExp);
     $timeNow = time();
     $timeToExpire = $timeExpire - $timeNow;
     if ($timeToExpire <= 30 * 24 * 60 * 60) {
         $expireClose = 1;
     } else {
         $expireClose = 0;
     }
     $finesVal = floatval(preg_replace('/[^\\d.]/', '', $patronDump['MONEY_OWED']));
     $numHoldsAvailable = 0;
     $numHoldsRequested = 0;
     $availableStatusRegex = isset($configArray['Catalog']['patronApiAvailableHoldsRegex']) ? $configArray['Catalog']['patronApiAvailableHoldsRegex'] : "/ST=(105|98),/";
     if (isset($patronDump['HOLD']) && count($patronDump['HOLD']) > 0) {
         foreach ($patronDump['HOLD'] as $hold) {
             if (preg_match("{$availableStatusRegex}", $hold)) {
                 $numHoldsAvailable++;
             } else {
                 $numHoldsRequested++;
             }
         }
     }
     $profile = array('lastname' => $lastName, 'firstname' => $firstName, 'fullname' => $fullName, 'address1' => $Address1, 'address2' => $City . ', ' . $State, 'city' => $City, 'state' => $State, 'zip' => $Zip, 'email' => isset($patronDump['EMAIL_ADDR']) ? $patronDump['EMAIL_ADDR'] : '', 'overdriveEmail' => $user ? $user->overdriveEmail : (isset($patronDump['EMAIL_ADDR']) ? $patronDump['EMAIL_ADDR'] : ''), 'promptForOverdriveEmail' => $user ? $user->promptForOverdriveEmail : 1, 'phone' => isset($patronDump['TELEPHONE']) ? $patronDump['TELEPHONE'] : '', 'fines' => $patronDump['MONEY_OWED'], 'finesval' => $finesVal, 'expires' => $patronDump['EXP_DATE'], 'expireclose' => $expireClose, 'homeLocationCode' => trim($homeBranchCode), 'homeLocationId' => $location->locationId, 'homeLocation' => $location->displayName, 'myLocation1Id' => $user ? $user->myLocation1Id : -1, 'myLocation1' => isset($myLocation1) ? $myLocation1->displayName : '', 'myLocation2Id' => $user ? $user->myLocation2Id : -1, 'myLocation2' => isset($myLocation2) ? $myLocation2->displayName : '', 'numCheckedOut' => $patronDump['CUR_CHKOUT'], 'numHolds' => isset($patronDump['HOLD']) ? count($patronDump['HOLD']) : 0, 'numHoldsAvailable' => $numHoldsAvailable, 'numHoldsRequested' => $numHoldsRequested, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : 0, 'ptype' => $patronDump['P_TYPE'], 'notices' => $patronDump['NOTICE_PREF'], 'web_note' => isset($patronDump['WEB_NOTE']) ? $patronDump['WEB_NOTE'] : '');
     //Get eContent info as well
     require_once ROOT_DIR . '/Drivers/EContentDriver.php';
     $eContentDriver = new EContentDriver();
     $eContentAccountSummary = $eContentDriver->getAccountSummary();
     $profile = array_merge($profile, $eContentAccountSummary);
     //Get a count of the materials requests for the user
     if ($user) {
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->createdBy = $user->id;
         $homeLibrary = Library::getPatronHomeLibrary();
         $statusQuery = new MaterialsRequestStatus();
         $statusQuery->isOpen = 1;
         $statusQuery->libraryId = $homeLibrary->libraryId;
         $materialsRequest->joinAdd($statusQuery);
         $materialsRequest->find();
         $profile['numMaterialsRequests'] = $materialsRequest->N;
     }
     $timer->logTime("Got Patron Profile");
     $this->patronProfiles[$patron['id']] = $profile;
     return $profile;
 }
Exemplo n.º 26
0
 /**
  * Process facets from the results object
  *
  * @access  public
  * @param   array   $filter         Array of field => on-screen description
  *                                  listing all of the desired facet fields;
  *                                  set to null to get all configured values.
  * @param   bool    $expandingLinks If true, we will include expanding URLs
  *                                  (i.e. get all matches for a facet, not
  *                                  just a limit to the current search) in
  *                                  the return array.
  * @return  array   Facets data arrays
  */
 public function getFacetList($filter = null, $expandingLinks = false)
 {
     // If there is no filter, we'll use all facets as the filter:
     if (is_null($filter)) {
         $filter = $this->facetConfig;
     }
     // Start building the facet list:
     $list = array();
     // If we have no facets to process, give up now
     if (!isset($this->indexResult['facet_counts'])) {
         return $list;
     } elseif (!is_array($this->indexResult['facet_counts']['facet_fields']) && !is_array($this->indexResult['facet_counts']['facet_dates'])) {
         return $list;
     }
     // Loop through every field returned by the result set
     $validFields = array_keys($filter);
     global $locationSingleton;
     /** @var Library $currentLibrary */
     $currentLibrary = Library::getActiveLibrary();
     $activeLocationFacet = null;
     $activeLocation = $locationSingleton->getActiveLocation();
     if (!is_null($activeLocation)) {
         $activeLocationFacet = $activeLocation->facetLabel;
     }
     $relatedLocationFacets = null;
     $relatedHomeLocationFacets = null;
     if (!is_null($currentLibrary)) {
         $relatedLocationFacets = $locationSingleton->getLocationsFacetsForLibrary($currentLibrary->libraryId);
     }
     $homeLibrary = Library::getPatronHomeLibrary();
     if (!is_null($homeLibrary)) {
         $relatedHomeLocationFacets = $locationSingleton->getLocationsFacetsForLibrary($homeLibrary->libraryId);
     }
     $allFacets = array_merge($this->indexResult['facet_counts']['facet_fields'], $this->indexResult['facet_counts']['facet_dates']);
     foreach ($allFacets as $field => $data) {
         // Skip filtered fields and empty arrays:
         if (!in_array($field, $validFields) || count($data) < 1) {
             continue;
         }
         // Initialize the settings for the current field
         $list[$field] = array();
         // Add the on-screen label
         $list[$field]['label'] = $filter[$field];
         // Build our array of values for this field
         $list[$field]['list'] = array();
         $foundInstitution = false;
         $doInstitutionProcessing = false;
         $foundBranch = false;
         $doBranchProcessing = false;
         //Marmot specific processing to do custom resorting of facets.
         if ($field == 'institution' && isset($currentLibrary) && !is_null($currentLibrary)) {
             $doInstitutionProcessing = true;
         }
         if ($field == 'building' && (!is_null($relatedLocationFacets) || !is_null($activeLocationFacet))) {
             $doBranchProcessing = true;
         } elseif ($field == 'available_at') {
             $doBranchProcessing = true;
         }
         // Should we translate values for the current facet?
         $translate = in_array($field, $this->translatedFacets);
         $numValidRelatedLocations = 0;
         $numValidLibraries = 0;
         // Loop through values:
         foreach ($data as $facet) {
             // Initialize the array of data about the current facet:
             $currentSettings = array();
             $currentSettings['value'] = $facet[0];
             $currentSettings['display'] = $translate ? translate($facet[0]) : $facet[0];
             $currentSettings['count'] = $facet[1];
             $currentSettings['isApplied'] = false;
             $currentSettings['url'] = $this->renderLinkWithFilter("{$field}:" . $facet[0]);
             // If we want to have expanding links (all values matching the facet)
             // in addition to limiting links (filter current search with facet),
             // do some extra work:
             if ($expandingLinks) {
                 $currentSettings['expandUrl'] = $this->getExpandingFacetLink($field, $facet[0]);
             }
             // Is this field a current filter?
             if (in_array($field, array_keys($this->filterList))) {
                 // and is this value a selected filter?
                 if (in_array($facet[0], $this->filterList[$field])) {
                     $currentSettings['isApplied'] = true;
                     $currentSettings['removalUrl'] = $this->renderLinkWithoutFilter("{$field}:{$facet[0]}");
                 }
             }
             //Setup the key to allow sorting alphabetically if needed.
             $valueKey = $facet[0];
             $okToAdd = true;
             if ($doInstitutionProcessing) {
                 //Special processing for Marmot digital library
                 if ($facet[0] == $currentLibrary->facetLabel) {
                     $valueKey = '1' . $valueKey;
                     $numValidLibraries++;
                     $foundInstitution = true;
                 } elseif ($facet[0] == $currentLibrary->facetLabel . ' Online') {
                     $valueKey = '1' . $valueKey;
                     $foundInstitution = true;
                     $numValidLibraries++;
                 } elseif ($facet[0] == $currentLibrary->facetLabel . ' On Order' || $facet[0] == $currentLibrary->facetLabel . ' Under Consideration') {
                     $valueKey = '1' . $valueKey;
                     $foundInstitution = true;
                     $numValidLibraries++;
                 } elseif ($facet[0] == 'Digital Collection' || $facet[0] == 'Marmot Digital Library') {
                     $valueKey = '2' . $valueKey;
                     $foundInstitution = true;
                     $numValidLibraries++;
                 } else {
                     if (!is_null($currentLibrary) && $currentLibrary->restrictOwningBranchesAndSystems == 1) {
                         $okToAdd = false;
                     }
                 }
             } else {
                 if ($doBranchProcessing) {
                     if (strlen($facet[0]) > 0) {
                         if ($activeLocationFacet != null && $facet[0] == $activeLocationFacet) {
                             $valueKey = '1' . $valueKey;
                             $foundBranch = true;
                             $numValidRelatedLocations++;
                         } elseif (isset($currentLibrary) && $facet[0] == $currentLibrary->facetLabel . ' Online') {
                             $valueKey = '1' . $valueKey;
                             $numValidRelatedLocations++;
                         } elseif (isset($currentLibrary) && ($facet[0] == $currentLibrary->facetLabel . ' On Order' || $facet[0] == $currentLibrary->facetLabel . ' Under Consideration')) {
                             $valueKey = '1' . $valueKey;
                             $numValidRelatedLocations++;
                         } else {
                             if (!is_null($relatedLocationFacets) && in_array($facet[0], $relatedLocationFacets)) {
                                 $valueKey = '2' . $valueKey;
                                 $numValidRelatedLocations++;
                             } else {
                                 if (!is_null($relatedLocationFacets) && in_array($facet[0], $relatedLocationFacets)) {
                                     $valueKey = '2' . $valueKey;
                                     $numValidRelatedLocations++;
                                 } else {
                                     if (!is_null($relatedHomeLocationFacets) && in_array($facet[0], $relatedHomeLocationFacets)) {
                                         $valueKey = '2' . $valueKey;
                                         $numValidRelatedLocations++;
                                     } elseif (!is_null($currentLibrary) && $facet[0] == $currentLibrary->facetLabel . ' Online') {
                                         $valueKey = '3' . $valueKey;
                                         $numValidRelatedLocations++;
                                     } elseif ($facet[0] == 'Marmot Digital Library' || $facet[0] == 'Digital Collection' || $facet[0] == 'OverDrive' || $facet[0] == 'Online') {
                                         $valueKey = '4' . $valueKey;
                                         $numValidRelatedLocations++;
                                     } else {
                                         if (!is_null($currentLibrary) && $currentLibrary->restrictOwningBranchesAndSystems == 1) {
                                             $okToAdd = false;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             // Store the collected values:
             if ($okToAdd) {
                 $list[$field]['list'][$valueKey] = $currentSettings;
             }
         }
         if (!$foundInstitution && $doInstitutionProcessing) {
             $list[$field]['list']['1' . $currentLibrary->facetLabel] = array('value' => $currentLibrary->facetLabel, 'display' => $currentLibrary->facetLabel, 'count' => 0, 'isApplied' => false, 'url' => null, 'expandUrl' => null);
         }
         if (!$foundBranch && $doBranchProcessing && !is_null($activeLocationFacet)) {
             $list[$field]['list']['1' . $activeLocationFacet] = array('value' => $activeLocationFacet, 'display' => $activeLocationFacet, 'count' => 0, 'isApplied' => false, 'url' => null, 'expandUrl' => null);
             $numValidRelatedLocations++;
         }
         //How many facets should be shown by default
         //Only show one system unless we are in the global scope
         if ($field == 'institution' && isset($currentLibrary)) {
             $list[$field]['valuesToShow'] = $numValidLibraries;
         } else {
             if ($field == 'building' && isset($relatedLocationFacets) && $numValidRelatedLocations > 0) {
                 $list[$field]['valuesToShow'] = $numValidRelatedLocations;
             } else {
                 if ($field == 'available_at') {
                     $list[$field]['valuesToShow'] = count($list[$field]['list']);
                 } else {
                     $list[$field]['valuesToShow'] = 5;
                 }
             }
         }
         //Sort the facet alphabetically?
         //Sort the system and location alphabetically unless we are in the global scope
         if (in_array($field, array('institution', 'building', 'available_at')) && isset($currentLibrary)) {
             $list[$field]['showAlphabetically'] = true;
         } else {
             $list[$field]['showAlphabetically'] = false;
         }
         if ($list[$field]['showAlphabetically']) {
             ksort($list[$field]['list']);
         }
     }
     return $list;
 }
Exemplo n.º 27
0
 public function getLibraryScopingId()
 {
     //For econtent, we need to be more specific when restricting copies
     //since patrons can't use copies that are only available to other libraries.
     $searchLibrary = Library::getSearchLibrary();
     $searchLocation = Location::getSearchLocation();
     $activeLibrary = Library::getActiveLibrary();
     $activeLocation = Location::getActiveLocation();
     $homeLibrary = Library::getPatronHomeLibrary();
     //Load the holding label for the branch where the user is physically.
     if (!is_null($homeLibrary)) {
         return $homeLibrary->includeOutOfSystemExternalLinks ? -1 : $homeLibrary->libraryId;
     } else {
         if (!is_null($activeLocation)) {
             $activeLibrary = Library::getLibraryForLocation($activeLocation->locationId);
             return $activeLibrary->includeOutOfSystemExternalLinks ? -1 : $activeLibrary->libraryId;
         } else {
             if (isset($activeLibrary)) {
                 return $activeLibrary->includeOutOfSystemExternalLinks ? -1 : $activeLibrary->libraryId;
             } else {
                 if (!is_null($searchLocation)) {
                     $searchLibrary = Library::getLibraryForLocation($searchLibrary->locationId);
                     return $searchLibrary->includeOutOfSystemExternalLinks ? -1 : $searchLocation->libraryId;
                 } else {
                     if (isset($searchLibrary)) {
                         return $searchLibrary->includeOutOfSystemExternalLinks ? -1 : $searchLibrary->libraryId;
                     } else {
                         return -1;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 28
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     $interface->assign('canAddNew', $this->canAddNew());
     $interface->assign('canDelete', $this->canDelete());
     $interface->assign('showReturnToList', $this->showReturnToList());
     $interface->assign('showExportAndCompare', $this->showExportAndCompare());
     //Figure out what mode we are in
     if (isset($_REQUEST['objectAction'])) {
         $objectAction = $_REQUEST['objectAction'];
     } else {
         $objectAction = 'list';
     }
     if ($objectAction == 'delete' && isset($_REQUEST['id'])) {
         parent::launch();
         exit;
     }
     //Get all available widgets
     $availableWidgets = array();
     $listWidget = new ListWidget();
     if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $listWidget->libraryId = $homeLibrary->libraryId;
     }
     $listWidget->orderBy('name ASC');
     $listWidget->find();
     while ($listWidget->fetch()) {
         $availableWidgets[$listWidget->id] = clone $listWidget;
     }
     $interface->assign('availableWidgets', $availableWidgets);
     //Get the selected widget
     if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
         $widget = $availableWidgets[$_REQUEST['id']];
         $interface->assign('object', $widget);
     }
     //Do actions that require preprocessing
     if ($objectAction == 'save') {
         if (!isset($widget)) {
             $widget = new ListWidget();
         }
         DataObjectUtil::updateFromUI($widget, $listWidget->getObjectStructure());
         $validationResults = DataObjectUtil::saveObject($listWidget->getObjectStructure(), "ListWidget");
         if (!$validationResults['validatedOk']) {
             $interface->assign('object', $widget);
             $interface->assign('errors', $validationResults['errors']);
             $objectAction = 'edit';
         } else {
             $interface->assign('object', $validationResults['object']);
             $objectAction = 'view';
         }
     }
     if ($objectAction == 'list') {
         $interface->setTemplate('listWidgets.tpl');
     } else {
         if ($objectAction == 'edit' || $objectAction == 'add') {
             if (isset($_REQUEST['id'])) {
                 $interface->assign('widgetid', $_REQUEST['id']);
                 $interface->assign('id', $_REQUEST['id']);
             }
             $editForm = DataObjectUtil::getEditForm($listWidget->getObjectStructure());
             $interface->assign('editForm', $editForm);
             $interface->setTemplate('listWidgetEdit.tpl');
         } else {
             $interface->setTemplate('listWidget.tpl');
         }
     }
     $interface->setPageTitle('List Widgets');
     $interface->display('layout.tpl');
 }
Exemplo n.º 29
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Load status information
     $materialsRequestStatus = new MaterialsRequestStatus();
     $materialsRequestStatus->orderBy('isDefault DESC, isOpen DESC, description ASC');
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $materialsRequestStatus->libraryId = $homeLibrary->libraryId;
     }
     $materialsRequestStatus->find();
     $availableStatuses = array();
     $defaultStatusesToShow = array();
     while ($materialsRequestStatus->fetch()) {
         $availableStatuses[$materialsRequestStatus->id] = $materialsRequestStatus->description;
         if ($materialsRequestStatus->isOpen == 1 || $materialsRequestStatus->isDefault == 1) {
             $defaultStatusesToShow[] = $materialsRequestStatus->id;
         }
     }
     $interface->assign('availableStatuses', $availableStatuses);
     if (isset($_REQUEST['statusFilter'])) {
         $statusesToShow = $_REQUEST['statusFilter'];
     } else {
         $statusesToShow = $defaultStatusesToShow;
     }
     $interface->assign('statusFilter', $statusesToShow);
     //Get a list of users that have requests open
     $materialsRequest = new MaterialsRequest();
     $materialsRequest->joinAdd(new User());
     $materialsRequest->joinAdd(new MaterialsRequestStatus());
     $materialsRequest->selectAdd();
     $materialsRequest->selectAdd('COUNT(materials_request.id) as numRequests');
     $materialsRequest->selectAdd('user.id as userId, status, description, user.firstName, user.lastName, user.cat_username, user.cat_password');
     if ($user->hasRole('library_material_requests')) {
         //Need to limit to only requests submitted for the user's home location
         $userHomeLibrary = Library::getPatronHomeLibrary();
         $locations = new Location();
         $locations->libraryId = $userHomeLibrary->libraryId;
         $locations->find();
         $locationsForLibrary = array();
         while ($locations->fetch()) {
             $locationsForLibrary[] = $locations->locationId;
         }
         $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
     }
     $statusSql = "";
     foreach ($statusesToShow as $status) {
         if (strlen($statusSql) > 0) {
             $statusSql .= ",";
         }
         $statusSql .= "'" . $materialsRequest->escape($status) . "'";
     }
     $materialsRequest->whereAdd("status in ({$statusSql})");
     $materialsRequest->groupBy('userId, status');
     $materialsRequest->find();
     $userData = array();
     while ($materialsRequest->fetch()) {
         if (!array_key_exists($materialsRequest->userId, $userData)) {
             $userData[$materialsRequest->userId] = array();
             $userData[$materialsRequest->userId]['firstName'] = $materialsRequest->firstName;
             $userData[$materialsRequest->userId]['lastName'] = $materialsRequest->lastName;
             $barcodeProperty = $configArray['Catalog']['barcodeProperty'];
             $userData[$materialsRequest->userId]['barcode'] = $materialsRequest->{$barcodeProperty};
             $userData[$materialsRequest->userId]['totalRequests'] = 0;
             $userData[$materialsRequest->userId]['requestsByStatus'] = array();
         }
         $userData[$materialsRequest->userId]['requestsByStatus'][$materialsRequest->description] = $materialsRequest->numRequests;
         $userData[$materialsRequest->userId]['totalRequests'] += $materialsRequest->numRequests;
     }
     $interface->assign('userData', $userData);
     //Get a list of all of the statuses that will be shown
     $statuses = array();
     foreach ($userData as $userInfo) {
         foreach ($userInfo['requestsByStatus'] as $status => $numRequests) {
             $statuses[$status] = translate($status);
         }
     }
     $interface->assign('statuses', $statuses);
     //Check to see if we are exporting to Excel
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($userData, $statuses);
     }
     $interface->setTemplate('userReport.tpl');
     $interface->setPageTitle('Materials Request User Report');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 30
0
 function launch()
 {
     global $interface;
     global $user;
     $period = isset($_REQUEST['period']) ? $_REQUEST['period'] : 'week';
     if ($period == 'week') {
         $periodLength = new DateInterval("P1W");
     } elseif ($period == 'day') {
         $periodLength = new DateInterval("P1D");
     } elseif ($period == 'month') {
         $periodLength = new DateInterval("P1M");
     } else {
         //year
         $periodLength = new DateInterval("P1Y");
     }
     $interface->assign('period', $period);
     $endDate = isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0 ? DateTime::createFromFormat('m/d/Y', $_REQUEST['endDate']) : new DateTime();
     $interface->assign('endDate', $endDate->format('m/d/Y'));
     if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
         $startDate = DateTime::createFromFormat('m/d/Y', $_REQUEST['startDate']);
     } else {
         if ($period == 'day') {
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 7 days");
         } elseif ($period == 'week') {
             //Get the sunday after this
             $endDate->setISODate($endDate->format('Y'), $endDate->format("W"), 0);
             $endDate->modify("+7 days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 28 days");
         } elseif ($period == 'month') {
             $endDate->modify("+1 month");
             $numDays = $endDate->format("d");
             $endDate->modify(" -{$numDays} days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 6 months");
         } else {
             //year
             $endDate->modify("+1 year");
             $numDays = $endDate->format("m");
             $endDate->modify(" -{$numDays} months");
             $numDays = $endDate->format("d");
             $endDate->modify(" -{$numDays} days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 2 years");
         }
     }
     $interface->assign('startDate', $startDate->format('m/d/Y'));
     //Set the end date to the end of the day
     $endDate->setTime(24, 0, 0);
     $startDate->setTime(0, 0, 0);
     //Create the periods that are being represented
     $periods = array();
     $periodEnd = clone $endDate;
     while ($periodEnd >= $startDate) {
         array_unshift($periods, clone $periodEnd);
         $periodEnd->sub($periodLength);
     }
     //print_r($periods);
     //Load data for each period
     //this will be a two dimensional array
     //         Period 1, Period 2, Period 3
     //Status 1
     //Status 2
     //Status 3
     $periodData = array();
     for ($i = 0; $i < count($periods) - 1; $i++) {
         /** @var DateTime $periodStart */
         $periodStart = clone $periods[$i];
         /** @var DateTime $periodEnd */
         $periodEnd = clone $periods[$i + 1];
         $periodData[$periodStart->getTimestamp()] = array();
         //Determine how many requests were created
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->joinAdd(new User(), 'INNER', 'user');
         $materialsRequest->selectAdd();
         $materialsRequest->selectAdd('COUNT(id) as numRequests');
         $materialsRequest->whereAdd('dateCreated >= ' . $periodStart->getTimestamp() . ' AND dateCreated < ' . $periodEnd->getTimestamp());
         if ($user->hasRole('library_material_requests')) {
             //Need to limit to only requests submitted for the user's home location
             $userHomeLibrary = Library::getPatronHomeLibrary();
             $locations = new Location();
             $locations->libraryId = $userHomeLibrary->libraryId;
             $locations->find();
             $locationsForLibrary = array();
             while ($locations->fetch()) {
                 $locationsForLibrary[] = $locations->locationId;
             }
             $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
         }
         $materialsRequest->find();
         while ($materialsRequest->fetch()) {
             $periodData[$periodStart->getTimestamp()]['Created'] = $materialsRequest->numRequests;
         }
         //Get a list of all requests by the status of the request
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->joinAdd(new MaterialsRequestStatus());
         $materialsRequest->joinAdd(new User(), 'INNER', 'user');
         $materialsRequest->selectAdd();
         $materialsRequest->selectAdd('COUNT(materials_request.id) as numRequests,description');
         $materialsRequest->whereAdd('dateUpdated >= ' . $periodStart->getTimestamp() . ' AND dateUpdated < ' . $periodEnd->getTimestamp());
         if ($user->hasRole('library_material_requests')) {
             //Need to limit to only requests submitted for the user's home location
             $userHomeLibrary = Library::getPatronHomeLibrary();
             $locations = new Location();
             $locations->libraryId = $userHomeLibrary->libraryId;
             $locations->find();
             $locationsForLibrary = array();
             while ($locations->fetch()) {
                 $locationsForLibrary[] = $locations->locationId;
             }
             $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
         }
         $materialsRequest->groupBy('status');
         $materialsRequest->orderBy('status');
         $materialsRequest->find();
         while ($materialsRequest->fetch()) {
             $periodData[$periodStart->getTimestamp()][$materialsRequest->description] = $materialsRequest->numRequests;
         }
     }
     $interface->assign('periodData', $periodData, $periods);
     //Get a list of all of the statuses that will be shown
     $statuses = array();
     foreach ($periodData as $periodInfo) {
         foreach ($periodInfo as $status => $numRequests) {
             $statuses[$status] = translate($status);
         }
     }
     $interface->assign('statuses', $statuses);
     //Check to see if we are exporting to Excel
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($periodData, $statuses);
     } else {
         //Generate the graph
         $this->generateGraph($periodData, $statuses);
     }
     $interface->setTemplate('summaryReport.tpl');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setPageTitle('Materials Request Summary Report');
     $interface->display('layout.tpl');
 }