コード例 #1
0
ファイル: SaveSearch.php プロジェクト: victorfcm/VuFind-Plus
 function launch()
 {
     global $configArray;
     global $user;
     $searchId = null;
     $todo = 'addSearch';
     if (isset($_REQUEST['delete']) && $_REQUEST['delete']) {
         $todo = 'deleteSearch';
         $searchId = $_REQUEST['delete'];
     }
     // If for some strange reason the user tries
     //    to do both, just focus on the save.
     if (isset($_REQUEST['save']) && $_REQUEST['save']) {
         $todo = 'addSearch';
         $searchId = $_REQUEST['save'];
     }
     $search = new SearchEntry();
     $search->id = $searchId;
     if ($search->find(true)) {
         // Found, make sure this is a search from this user
         if ($search->session_id == session_id() || $search->user_id == $user->id) {
             // Call whichever function is required below
             $this->{$todo}($search);
         }
     }
     // If we are in "edit history" mode, stay in Search History:
     if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'history') {
         header("Location: " . $configArray['Site']['path'] . "/Search/History");
     } else {
         // If the ID wasn't found, or some other error occurred, nothing will
         //   have processed be now, let the error handling on the display
         //   screen take care of it.
         header("Location: " . $configArray['Site']['path'] . "/Search/Results?saved={$searchId}");
     }
 }
コード例 #2
0
ファイル: Advanced.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Load a saved search, if appropriate and legal; assign an error to the
  * interface if necessary.
  *
  * @return mixed Search Object on successful load, false otherwise
  * @access private
  */
 private function _loadSavedSearch()
 {
     global $interface;
     // Are we editing an existing search?
     if (isset($_REQUEST['edit'])) {
         // Go find it
         $search = new SearchEntry();
         $search->id = $_REQUEST['edit'];
         if ($search->find(true)) {
             // Check permissions
             if ($search->session_id == session_id() || $search->user_id == $user->id) {
                 // Retrieve the search details
                 $minSO = unserialize($search->search_object);
                 $savedSearch = SearchObjectFactory::deminify($minSO);
                 // Make sure it's an advanced search
                 if ($savedSearch->getSearchType() == 'MetaLibAdvanced') {
                     // Activate facets so we get appropriate descriptions
                     // in the filter list:
                     $savedSearch->activateAllFacets();
                     return $savedSearch;
                 } else {
                     $interface->assign('editErr', 'notAdvanced');
                 }
             } else {
                 // No permissions
                 $interface->assign('editErr', 'noRights');
             }
         } else {
             // Not found
             $interface->assign('editErr', 'notFound');
         }
     }
     return false;
 }
コード例 #3
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}");
 }
コード例 #4
0
ファイル: Home.php プロジェクト: bryandease/VuFind-Plus
 function __construct($subAction = false, $record_id = null)
 {
     global $interface;
     global $configArray;
     global $library;
     global $timer;
     global $user;
     //Check to see if a user is logged in with admin permissions
     if ($user && $user->hasRole('genealogyContributor')) {
         $interface->assign('userIsAdmin', true);
     } else {
         $interface->assign('userIsAdmin', false);
     }
     $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
     //Load basic information needed in subclasses
     if ($record_id == null || !isset($record_id)) {
         $this->id = $_GET['id'];
     } else {
         $this->id = $record_id;
     }
     // Setup Search Engine Connection
     // Include Search Engine Class
     require_once ROOT_DIR . '/sys/' . $configArray['Genealogy']['engine'] . '.php';
     $timer->logTime('Include search engine');
     // Initialise from the current search globals
     $this->db = SearchObjectFactory::initSearchObject($configArray['Genealogy']['searchObject']);
     $this->db->init($searchSource);
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord('person' . $this->id))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $this->record = $record;
     //Load person from the database to get additional information
     $person = Person::staticGet('personId', $this->id);
     $record['picture'] = $person->picture;
     $interface->assign('record', $record);
     $interface->assign('person', $person);
     $this->recordDriver = RecordDriverFactory::initRecordDriver($record);
     $timer->logTime('Initialized the Record Driver');
     $marriages = array();
     $personMarriages = $person->marriages;
     if (isset($personMarriages)) {
         foreach ($personMarriages as $marriage) {
             $marriageArray = (array) $marriage;
             $marriageArray['formattedMarriageDate'] = $person->formatPartialDate($marriage->marriageDateDay, $marriage->marriageDateMonth, $marriage->marriageDateYear);
             $marriages[] = $marriageArray;
         }
     }
     $interface->assign('marriages', $marriages);
     $obituaries = array();
     $personObituaries = $person->obituaries;
     if (isset($personObituaries)) {
         foreach ($personObituaries as $obit) {
             $obitArray = (array) $obit;
             $obitArray['formattedObitDate'] = $person->formatPartialDate($obit->dateDay, $obit->dateMonth, $obit->dateYear);
             $obituaries[] = $obitArray;
         }
     }
     $interface->assign('obituaries', $obituaries);
     //Do actions needed if this is the main action.
     $interface->assign('id', $this->id);
     // Retrieve User Search History
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     $this->cacheId = 'Person|' . $_GET['id'] . '|' . get_class($this);
     // Send down text for inclusion in breadcrumbs
     $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb());
     $formattedBirthdate = $person->formatPartialDate($person->birthDateDay, $person->birthDateMonth, $person->birthDateYear);
     $interface->assign('birthDate', $formattedBirthdate);
     $formattedDeathdate = $person->formatPartialDate($person->deathDateDay, $person->deathDateMonth, $person->deathDateYear);
     $interface->assign('deathDate', $formattedDeathdate);
     //Setup next and previous links based on the search results.
     if (isset($_REQUEST['searchId'])) {
         //rerun the search
         $s = new SearchEntry();
         $s->id = $_REQUEST['searchId'];
         $interface->assign('searchId', $_REQUEST['searchId']);
         $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
         $interface->assign('page', $currentPage);
         $s->find();
         if ($s->N > 0) {
             $s->fetch();
             $minSO = unserialize($s->search_object);
             $searchObject = SearchObjectFactory::deminify($minSO);
             $searchObject->setPage($currentPage);
             //Run the search
             $result = $searchObject->processSearch(true, false, false);
             //Check to see if we need to run a search for the next or previous page
             $currentResultIndex = $_REQUEST['recordIndex'] - 1;
             $recordsPerPage = $searchObject->getLimit();
             if ($currentResultIndex % $recordsPerPage == 0 && $currentResultIndex > 0) {
                 //Need to run a search for the previous page
                 $interface->assign('previousPage', $currentPage - 1);
                 $previousSearchObject = clone $searchObject;
                 $previousSearchObject->setPage($currentPage - 1);
                 $previousSearchObject->processSearch(true, false, false);
                 $previousResults = $previousSearchObject->getResultRecordSet();
             } else {
                 if (($currentResultIndex + 1) % $recordsPerPage == 0 && $currentResultIndex + 1 < $searchObject->getResultTotal()) {
                     //Need to run a search for the next page
                     $nextSearchObject = clone $searchObject;
                     $interface->assign('nextPage', $currentPage + 1);
                     $nextSearchObject->setPage($currentPage + 1);
                     $nextSearchObject->processSearch(true, false, false);
                     $nextResults = $nextSearchObject->getResultRecordSet();
                 }
             }
             if (PEAR_Singleton::isError($result)) {
                 //If we get an error excuting the search, just eat it for now.
             } else {
                 if ($searchObject->getResultTotal() < 1) {
                     //No results found
                 } else {
                     $recordSet = $searchObject->getResultRecordSet();
                     //Record set is 0 based, but we are passed a 1 based index
                     if ($currentResultIndex > 0) {
                         if (isset($previousResults)) {
                             $previousRecord = $previousResults[count($previousResults) - 1];
                         } else {
                             $previousRecord = $recordSet[$currentResultIndex - 1 - ($currentPage - 1) * $recordsPerPage];
                         }
                         $interface->assign('previousId', $previousRecord['id']);
                         //Convert back to 1 based index
                         $interface->assign('previousIndex', $currentResultIndex - 1 + 1);
                         $interface->assign('previousTitle', $previousRecord['title']);
                     }
                     if ($currentResultIndex + 1 < $searchObject->getResultTotal()) {
                         if (isset($nextResults)) {
                             $nextRecord = $nextResults[0];
                         } else {
                             $nextRecord = $recordSet[$currentResultIndex + 1 - ($currentPage - 1) * $recordsPerPage];
                         }
                         $interface->assign('nextId', $nextRecord['id']);
                         //Convert back to 1 based index
                         $interface->assign('nextIndex', $currentResultIndex + 1 + 1);
                         $interface->assign('nextTitle', $nextRecord['title']);
                     }
                 }
             }
         }
         $timer->logTime('Got next/previous links');
     }
 }
コード例 #5
0
ファイル: User.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Anonymize user account by updating username to a random string 
  * and setting other user object fields (besides id) to their default values.
  * User comments are preserved. Catalog accounts, due date reminders, 
  * saved searches and lists are deleted.
  * 
  * @return boolean True on success
  */
 public function anonymizeAccount()
 {
     $conn = $this->getDatabaseConnection();
     $res = $conn->query("START TRANSACTION");
     try {
         // Delete catalog accounts
         $account = new User_account();
         $account->user_id = $this->id;
         if ($account->find(false)) {
             while ($account->fetch()) {
                 $account->delete();
             }
         }
         // Delete due date reminders
         $reminder = new Due_date_reminder();
         $reminder->user_id = $this->id;
         if ($reminder->find(false)) {
             while ($reminder->fetch()) {
                 $reminder->delete();
             }
         }
         // Delete lists (linked user_resource objects cascade)
         $list = new User_list();
         $list->user_id = $this->id;
         if ($list->find(false)) {
             while ($list->fetch()) {
                 $list->delete();
             }
         }
         // Delete saved searches
         $search = new SearchEntry();
         $search->user_id = $this->id;
         if ($search->find(false)) {
             while ($search->fetch()) {
                 $search->delete();
             }
         }
         // Anonymize user object
         $this->username = '******' . uniqid();
         $this->password = '';
         $this->firstname = '';
         $this->lastname = '';
         $this->email = '';
         $this->cat_username = '******';
         $this->cat_password = '******';
         $this->college = '';
         $this->major = '';
         $this->home_library = '';
         $this->language = '';
         $this->due_date_notification = 0;
         $this->due_date_reminder = 0;
         $this->authMethod = 'null';
         $this->update();
     } catch (Exception $e) {
         $conn->query("ROLLBACK");
         throw $e;
         return false;
     }
     $conn->query("COMMIT");
     return true;
 }
コード例 #6
0
ファイル: ResultScroller.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Restore the last saved search.
  *
  * @return SearchObject
  * @access private
  */
 private function _restoreLastSearch()
 {
     if (isset($_SESSION['lastSearchId'])) {
         $search = new SearchEntry();
         $search->id = $_SESSION['lastSearchId'];
         if ($search->find(true)) {
             $minSO = unserialize($search->search_object);
             $savedSearch = SearchObjectFactory::deminify($minSO);
             return $savedSearch;
         }
     }
     return null;
 }
コード例 #7
0
ファイル: Base.php プロジェクト: victorfcm/VuFind-Plus
 public function getNextPrevLinks()
 {
     global $interface;
     global $timer;
     //Setup next and previous links based on the search results.
     if (isset($_REQUEST['searchId']) && isset($_REQUEST['recordIndex'])) {
         //rerun the search
         $s = new SearchEntry();
         $s->id = $_REQUEST['searchId'];
         $interface->assign('searchId', $_REQUEST['searchId']);
         $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
         $interface->assign('page', $currentPage);
         $s->find();
         if ($s->N > 0) {
             $s->fetch();
             $minSO = unserialize($s->search_object);
             $searchObject = SearchObjectFactory::deminify($minSO);
             $searchObject->setPage($currentPage);
             //Run the search
             $result = $searchObject->processSearch(true, false, false);
             //Check to see if we need to run a search for the next or previous page
             $currentResultIndex = $_REQUEST['recordIndex'] - 1;
             $recordsPerPage = $searchObject->getLimit();
             $adjustedResultIndex = $currentResultIndex - $recordsPerPage * ($currentPage - 1);
             if ($currentResultIndex % $recordsPerPage == 0 && $currentResultIndex > 0) {
                 //Need to run a search for the previous page
                 $interface->assign('previousPage', $currentPage - 1);
                 $previousSearchObject = clone $searchObject;
                 $previousSearchObject->setPage($currentPage - 1);
                 $previousSearchObject->processSearch(true, false, false);
                 $previousResults = $previousSearchObject->getResultRecordSet();
             } else {
                 if (($currentResultIndex + 1) % $recordsPerPage == 0 && $currentResultIndex + 1 < $searchObject->getResultTotal()) {
                     //Need to run a search for the next page
                     $nextSearchObject = clone $searchObject;
                     $interface->assign('nextPage', $currentPage + 1);
                     $nextSearchObject->setPage($currentPage + 1);
                     $nextSearchObject->processSearch(true, false, false);
                     $nextResults = $nextSearchObject->getResultRecordSet();
                 }
             }
             if (PEAR_Singleton::isError($result)) {
                 //If we get an error excuting the search, just eat it for now.
             } else {
                 if ($searchObject->getResultTotal() < 1) {
                     //No results found
                 } else {
                     $recordSet = $searchObject->getResultRecordSet();
                     //Record set is 0 based, but we are passed a 1 based index
                     if ($currentResultIndex > 0) {
                         if (isset($previousResults)) {
                             $previousRecord = $previousResults[count($previousResults) - 1];
                         } else {
                             $previousId = $adjustedResultIndex - 1;
                             if (isset($recordSet[$previousId])) {
                                 $previousRecord = $recordSet[$previousId];
                             }
                         }
                         //Convert back to 1 based index
                         if (isset($previousRecord)) {
                             $interface->assign('previousIndex', $currentResultIndex - 1 + 1);
                             $interface->assign('previousTitle', $previousRecord['title_display']);
                             if (strpos($previousRecord['id'], 'econtentRecord') === 0) {
                                 $interface->assign('previousType', 'EcontentRecord');
                                 $interface->assign('previousId', str_replace('econtentRecord', '', $previousRecord['id']));
                             } elseif (strpos($previousRecord['id'], 'list') === 0) {
                                 $interface->assign('previousType', 'MyAccount/MyList');
                                 $interface->assign('previousId', str_replace('list', '', $previousRecord['id']));
                             } else {
                                 if ($previousRecord['recordtype'] == 'grouped_work') {
                                     $interface->assign('previousType', 'GroupedWork');
                                     $interface->assign('previousId', $previousRecord['id']);
                                 } else {
                                     $interface->assign('previousType', 'Record');
                                     $interface->assign('previousId', $previousRecord['id']);
                                 }
                             }
                         }
                     }
                     if ($currentResultIndex + 1 < $searchObject->getResultTotal()) {
                         if (isset($nextResults)) {
                             $nextRecord = $nextResults[0];
                         } else {
                             $nextRecordIndex = $adjustedResultIndex + 1;
                             if (isset($recordSet[$nextRecordIndex])) {
                                 $nextRecord = $recordSet[$nextRecordIndex];
                             }
                         }
                         //Convert back to 1 based index
                         $interface->assign('nextIndex', $currentResultIndex + 1 + 1);
                         if (isset($nextRecord)) {
                             $interface->assign('nextTitle', $nextRecord['title_display']);
                             if (strpos($nextRecord['id'], 'econtentRecord') === 0) {
                                 $interface->assign('nextType', 'EcontentRecord');
                                 $interface->assign('nextId', str_replace('econtentRecord', '', $nextRecord['id']));
                             } elseif (strpos($nextRecord['id'], 'list') === 0) {
                                 $interface->assign('nextType', 'MyAccount/MyList');
                                 $interface->assign('nextId', str_replace('list', '', $nextRecord['id']));
                             } else {
                                 if ($nextRecord['recordtype'] == 'grouped_work') {
                                     $interface->assign('nextType', 'GroupedWork');
                                     $interface->assign('nextId', $nextRecord['id']);
                                 } else {
                                     $interface->assign('nextType', 'Record');
                                     $interface->assign('nextId', $nextRecord['id']);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $timer->logTime('Got next/previous links');
     }
 }
コード例 #8
0
ファイル: Base.php プロジェクト: bharatm/NDL-VuFind
 /**
  * If there is a saved search being loaded through $_REQUEST, redirect to the
  * URL for that search.  If no saved search was requested, return false.  If
  * unable to load a requested saved search, return a PEAR_Error object.
  *
  * @return mixed Does not return on successful load, returns false if no search
  * to restore, returns PEAR_Error object in case of trouble.
  * @access protected
  */
 protected function restoreSavedSearch()
 {
     global $user;
     // Is this is a saved search?
     if (isset($_REQUEST['saved'])) {
         // Yes, retrieve it
         $search = new SearchEntry();
         $search->id = $_REQUEST['saved'];
         if ($search->find(true)) {
             // Found, make sure the user has the
             //   rights to view this search
             if ($search->session_id == session_id() || $search->user_id == $user->id) {
                 // They do, deminify it to a new object.
                 $minSO = unserialize($search->search_object);
                 $savedSearch = SearchObjectFactory::deminify($minSO);
                 // Now redirect to the URL associated with the saved search;
                 // this simplifies problems caused by mixing different classes
                 // of search object, and it also prevents the user from ever
                 // landing on a "?saved=xxxx" URL, which may not persist beyond
                 // the current session.  (We want all searches to be
                 // persistent and bookmarkable).
                 header('Location: ' . $savedSearch->renderSearchUrl());
                 die;
             } else {
                 // They don't
                 // TODO : Error handling -
                 //    User is trying to view a saved search from
                 //    another session (deliberate or expired) or
                 //    associated with another user.
                 return new PEAR_Error("Attempt to access invalid search ID");
             }
         }
     }
     // Report no saved search to restore.
     return false;
 }
コード例 #9
0
ファイル: AJAX.php プロジェクト: victorfcm/VuFind-Plus
 function deleteSavedSearch()
 {
     global $user;
     $searchId = $_REQUEST['searchId'];
     $search = new SearchEntry();
     $search->id = $searchId;
     $saveOk = false;
     if ($search->find(true)) {
         // Found, make sure this is a search from this user
         if ($search->session_id == session_id() || $search->user_id == $user->id) {
             if ($search->saved != 0) {
                 $search->saved = 0;
                 $saveOk = $search->update() !== FALSE;
                 $message = $saveOk ? "Your saved search was deleted successfully." : "Sorry, we could not delete that search for you.  It may have already been deleted.";
             } else {
                 $saveOk = true;
                 $message = "That search is not saved.";
             }
         } else {
             $message = "Sorry, it looks like that search does not belong to you.";
         }
     } else {
         $message = "Sorry, it looks like that search has expired.";
     }
     $result = array('result' => $saveOk, 'message' => $message);
     return $result;
 }