Exemplo n.º 1
0
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     // Fetch List object
     $list = User_list::staticGet($_GET['id']);
     if (!$list->public && $list->user_id != $user->id) {
         PEAR::raiseError(new PEAR_Error(translate('list_access_denied')));
     }
     $interface->assign('list', $list);
     $interface->assign('publicList', true);
     $interface->assign('ownList', $list->user_id == $user->id);
     $date = new VuFindDate();
     if (strtotime($list->modified) !== false && strtotime($list->modified) > 0) {
         $interface->assign('listModified', $date->convertToDisplayDate('Y-m-d H:i:s', $list->modified));
     }
     // Load the User object for the owner of the list (if necessary):
     if ($user && $user->id == $list->user_id) {
         $listUser = $user;
     } else {
         $listUser = User::staticGet($list->user_id);
     }
     $listOwner = null;
     if ($listUser->email && ($pos = strpos($listUser->email, '@')) !== false) {
         $listOwner = substr($listUser->email, 0, $pos);
     } else {
         if ($listUser->firstname && $listUser->lastname) {
             $listOwner = "{$listUser->firstname} {$listUser->lastname}";
         }
     }
     if ($listOwner) {
         $interface->assign('listUsername', $listOwner);
     }
     $searchObject = SearchObjectFactory::initSearchObject();
     $searchObject->init();
     $interface->assign('viewList', $searchObject->getViewList());
     // Build Favorites List
     $favorites = $list->getResources(isset($_GET['tag']) ? $_GET['tag'] : null);
     // Create a handler for displaying favorites and use it to assign
     // appropriate template variables:
     $favList = new FavoriteHandler($favorites, $listUser, $list->id, false);
     $favList->initPublicListView($searchObject->getView(), $listOwner);
     $favList->assign();
     $interface->assign('recordSet', $interface->get_template_vars('resourceList'));
     $interface->assign('openUrlAutoCheck', true);
     $currentView = $searchObject->getView();
     $interface->assign('subpage', 'Search/list-' . $currentView . '.tpl');
     $interface->setTemplate('home.tpl');
     $interface->setPageTitle($list->title);
     $interface->display('layout.tpl');
 }
function smarty_function_displaydateformat($params, &$smarty)
{
    // @codingStandardsIgnoreEnd
    $dateFormat = new VuFindDate();
    $search = array("1", "2", "3");
    if (!empty($params['replace']) && !empty($params['date'])) {
        $replace = $params['replace'];
        $dueDateHelpString = $params['date'];
    } else {
        $dueDateHelpString = $dateFormat->convertToDisplayDate("m-d-y", "11-22-3333");
        $replace = array(translate("date_month_placeholder"), translate("date_day_placeholder"), translate("date_year_placeholder"));
    }
    return str_replace($search, $replace, $dueDateHelpString);
}
Exemplo n.º 3
0
 /**
  * Get a list of all comments associated with this record.
  *
  * @param string $recordId Record ID
  *
  * @return array
  * @access public
  */
 public function getComments($recordId)
 {
     $recordId = $this->escape($recordId);
     $sql = "SELECT comments.*, user.firstname || user.lastname as fullname, " . "user.email " . "FROM comments " . "RIGHT OUTER JOIN user ON comments.user_id = user.id " . "JOIN comments_record ON comments.id = comments_record.comment_id " . "WHERE comments_record.record_id = '{$recordId}' " . "AND comments.visible = 1 " . "ORDER BY comments.created ";
     $commentList = array();
     $result = $this->query($sql);
     $date = new VuFindDate();
     if ($this->N) {
         while ($this->fetch()) {
             $comment = clone $this;
             $comment->created = $date->convertToDisplayDate('Y-m-d H:i:s', $comment->created) . ' ' . $date->convertToDisplayTime('Y-m-d H:i:s', $comment->created);
             $commentList[] = $comment;
         }
     }
     return $commentList;
 }
Exemplo n.º 4
0
 /**
  * Get a list of catalog accounts
  * 
  * @return array Account details
  */
 public function getCatalogAccounts()
 {
     $accounts = array();
     $account = new User_account();
     $account->user_id = $this->id;
     if ($account->find(false)) {
         $date = new VuFindDate();
         while ($account->fetch()) {
             $accounts[] = array('id' => $account->id, 'account_name' => $account->account_name, 'description' => $account->description, 'created' => $date->convertToDisplayDate('Y-m-d H:i:s', $account->created), 'cat_username' => $account->cat_username);
         }
     }
     return $accounts;
 }
Exemplo n.º 5
0
 /**
  * Send scheduled alerts
  *
  * @return void
  */
 public function send()
 {
     global $configArray;
     global $interface;
     global $translator;
     $iso8601 = 'Y-m-d\\TH:i:s\\Z';
     ini_set('display_errors', true);
     $configArray = $mainConfig = readConfig();
     $datasourceConfig = getExtraConfigArray('datasources');
     $siteLocal = $configArray['Site']['local'];
     // Set up time zone. N.B. Don't use msg() or other functions requiring date before this.
     date_default_timezone_set($configArray['Site']['timezone']);
     $this->msg('Sending scheduled alerts');
     // Setup Local Database Connection
     ConnectionManager::connectToDatabase();
     // Initialize Mailer
     $mailer = new VuFindMailer();
     // Find all scheduled alerts
     $sql = 'SELECT * FROM "search" WHERE "schedule" > 0 ORDER BY user_id';
     $s = new SearchEntry();
     $s->query($sql);
     $this->msg('Processing ' . $s->N . ' searches');
     $user = false;
     $interface = false;
     $institution = false;
     $todayTime = new DateTime();
     while ($s->fetch()) {
         $lastTime = new DateTime($s->last_executed);
         if ($s->schedule == 1) {
             // Daily
             if ($todayTime->format('Y-m-d') == $lastTime->format('Y-m-d')) {
                 $this->msg('Bypassing search ' . $s->id . ': previous execution too recent (daily, ' . $lastTime->format($iso8601) . ')');
                 continue;
             }
         } elseif ($s->schedule == 2) {
             // Weekly
             $diff = $todayTime->diff($lastTime);
             if ($diff->days < 6) {
                 $this->msg('Bypassing search ' . $s->id . ': previous execution too recent (weekly, ' . $lastTime->format($iso8601) . ')');
                 continue;
             }
         } else {
             $this->msg('Search ' . $s->id . ': unknown schedule: ' . $s->schedule);
             continue;
         }
         if ($user === false || $s->user_id != $user->id) {
             $user = User::staticGet($s->user_id);
         }
         if (!$user->email || trim($user->email) == '') {
             $this->msg('User ' . $user->username . ' does not have an email address, bypassing alert ' . $s->id);
             continue;
         }
         $userInstitution = reset(explode(':', $user->username, 2));
         if (!$institution || $institution != $userInstitution) {
             $institution = $userInstitution;
             if (!isset($datasourceConfig[$institution])) {
                 foreach ($datasourceConfig as $code => $values) {
                     if (isset($values['institution']) && strcasecmp($values['institution'], $institution) == 0) {
                         $institution = $code;
                         break;
                     }
                 }
             }
             if (!($configArray = $this->readInstitutionConfig($institution))) {
                 continue;
             }
             $configArray['Site']['url'] = $s->schedule_base_url;
             // Start Interface
             $interface = new UInterface($siteLocal);
             $validLanguages = array_keys($configArray['Languages']);
             $dateFormat = new VuFindDate();
         }
         $language = $user->language;
         if (!in_array($user->language, $validLanguages)) {
             $language = $configArray['Site']['language'];
         }
         $translator = new I18N_Translator(array($configArray['Site']['local'] . '/lang', $configArray['Site']['local'] . '/lang_local'), $language, $configArray['System']['debug']);
         $interface->setLanguage($language);
         $minSO = unserialize($s->search_object);
         // Check minified search object type
         $searchObject = SearchObjectFactory::deminify($minSO);
         if (!$searchObject instanceof SearchObject_Solr) {
             $this->msg('Search ' . $s->id . ': search object type not supported');
             continue;
         }
         // Create a new search object to avoid cached defaults for e.g.
         // hidden filters.
         $searchObject = SearchObjectFactory::initSearchObject();
         $searchObject->deminify($minSO);
         $searchObject->setSort('first_indexed desc');
         $searchTime = time();
         $searchDate = gmdate($iso8601, time());
         $searchObject->setLimit(50);
         $searchObject->disableLogging();
         $results = $searchObject->processSearch();
         if (PEAR::isError($results)) {
             $this->msg('Search ' . $s->id . ' failed: ' . $results->getMessage());
             continue;
         }
         if ($searchObject->getResultTotal() < 1) {
             $this->msg('No results found for search ' . $s->id);
             continue;
         }
         $newestRecordDate = date($iso8601, strtotime($results['response']['docs'][0]['first_indexed']));
         $lastExecutionDate = $lastTime->format($iso8601);
         if ($newestRecordDate < $lastExecutionDate) {
             $this->msg('No new results for search ' . $s->id . ": {$newestRecordDate} < {$lastExecutionDate}");
         } else {
             $this->msg('New results for search ' . $s->id . ": {$newestRecordDate} >= {$lastExecutionDate}");
             $interface->assign('summary', $searchObject->getResultSummary());
             $interface->assign('searchDate', $dateFormat->convertToDisplayDate("U", floor($searchTime)));
             $interface->assign('lastSearchDate', $dateFormat->convertToDisplayDate("U", floor($lastTime->getTimestamp())));
             $records = array();
             foreach ($results['response']['docs'] as &$doc) {
                 $docDate = date($iso8601, strtotime($doc['first_indexed']));
                 if ($docDate < $lastExecutionDate) {
                     break;
                 }
                 $record = RecordDriverFactory::initRecordDriver($doc);
                 $records[] = $interface->fetch($record->getSearchResult('email'));
             }
             $interface->assign('recordSet', $records);
             $key = $this->getSecret($user, $s->id);
             $params = array('id' => $s->id, 'type' => 'alert', 'key' => $key);
             $unsubscribeUrl = $configArray['Site']['url'] . '/MyResearch/Unsubscribe?' . http_build_query($params);
             $interface->assign('info', array('time' => $dateFormat->convertToDisplayDate("U", floor($searchObject->getStartTime())), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => $searchObject->getResultTotal(), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'schedule' => $s->schedule, 'last_executed' => $s->last_executed, 'recordCount' => count($records), 'unsubscribeUrl' => $unsubscribeUrl));
             $searchObject->close();
             // Load template
             $message = $interface->fetch('MyResearch/alert-email.tpl');
             if (strstr($message, 'Warning: Smarty error:')) {
                 $this->msg("Message template processing failed: {$message}");
                 continue;
             }
             $result = $mailer->send($user->email, $configArray['Site']['email'], translate('Scheduled Alert Results'), $message);
             if (PEAR::isError($result)) {
                 $this->msg("Failed to send message to {$user->email}: " . $result->getMessage());
                 continue;
             }
         }
         // Update search date
         $s->changeLastExecuted($searchDate);
     }
     $this->reportErrors();
     $this->msg('Scheduled alerts execution completed');
 }
Exemplo n.º 6
0
 /**
  * Test citation generation
  *
  * @return void
  * @access public
  */
 public function testDates()
 {
     global $configArray;
     // Clear out config array date settings to ensure we always test defaults
     // in code:
     unset($configArray['Site']['displayDateFormat']);
     unset($configArray['Site']['displayTimeFormat']);
     // Build an object to test with:
     $date = new VuFindDate();
     // Try some conversions:
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('U', 123456879));
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y', '11-29-73'));
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y', '11-29-1973'));
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y H:i', '11-29-73 23:01'));
     $this->_checkDate('23:01', $date->convertToDisplayTime('m-d-y H:i', '11-29-73 23:01'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y', '01-02-01'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y', '01-02-2001'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y H:i', '01-02-01 05:11'));
     $this->_checkDate('05:11', $date->convertToDisplayTime('m-d-y H:i', '01-02-01 05:11'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('Y-m-d', '2001-01-02'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('Y-m-d H:i', '2001-01-02 05:11'));
     $this->_checkDate('05:11', $date->convertToDisplayTime('Y-m-d H:i', '2001-01-02 05:11'));
     $this->_checkDate('01-2001', $date->convertFromDisplayDate('m-Y', '01-02-2001'));
     // Check for proper handling of known problems:
     $bad = $date->convertToDisplayDate('U', 'invalid');
     $this->assertTrue(PEAR::isError($bad));
     $this->assertTrue((bool) stristr($bad->getMessage(), 'failed to parse time string'));
     $bad = $date->convertToDisplayDate('d-m-Y', '31-02-2001');
     $this->assertTrue(PEAR::isError($bad));
     $this->assertTrue((bool) stristr($bad->getMessage(), 'parsed date was invalid'));
 }
Exemplo n.º 7
0
 /**
  * Format the given unix time stamp to a human readable format. The format is
  * configurable in Unicorn.ini
  *
  * @param int $time Unix time stamp.
  *
  * @return string Formatted date/time.
  */
 private function _formatDateTime($time)
 {
     $dateTimeString = '';
     if ($time) {
         $dateTimeString = strftime('%m/%d/%Y %H:%M', $time);
         $dateFormat = new VuFindDate();
         $dateTimeString = $dateFormat->convertToDisplayDate('m/d/Y H:i', $dateTimeString);
     }
     return $dateTimeString;
 }
Exemplo n.º 8
0
 /**
  * Send due date reminders
  *
  * @return void
  */
 public function send()
 {
     global $configArray;
     global $interface;
     global $translator;
     $iso8601 = 'Y-m-d\\TH:i:s\\Z';
     ini_set('display_errors', true);
     $configArray = $mainConfig = readConfig();
     $datasourceConfig = getExtraConfigArray('datasources');
     $siteLocal = $configArray['Site']['local'];
     // Set up time zone. N.B. Don't use msg() or other functions requiring date before this.
     date_default_timezone_set($configArray['Site']['timezone']);
     $this->msg('Sending due date reminders');
     // Setup Local Database Connection
     ConnectionManager::connectToDatabase();
     // And index
     $db = ConnectionManager::connectToIndex();
     // Initialize Mailer
     $mailer = new VuFindMailer();
     // Find all scheduled alerts
     $sql = 'SELECT * FROM "user" WHERE "due_date_reminder" > 0 ORDER BY id';
     $user = new User();
     $user->query($sql);
     $this->msg('Processing ' . $user->N . ' users');
     $interface = false;
     $institution = false;
     $todayTime = new DateTime();
     $catalog = ConnectionManager::connectToCatalog();
     while ($user->fetch()) {
         if (!$user->email || trim($user->email) == '') {
             $this->msg('User ' . $user->username . ' does not have an email address, bypassing due date reminders');
             continue;
         }
         // Initialize settings and interface
         $userInstitution = reset(explode(':', $user->username, 2));
         if (!$institution || $institution != $userInstitution) {
             $institution = $userInstitution;
             if (!isset($datasourceConfig[$institution])) {
                 foreach ($datasourceConfig as $code => $values) {
                     if (isset($values['institution']) && strcasecmp($values['institution'], $institution) == 0) {
                         $institution = $code;
                         break;
                     }
                 }
             }
             if (!($configArray = $this->readInstitutionConfig($institution))) {
                 continue;
             }
             // Start Interface
             $interface = new UInterface($siteLocal);
             $validLanguages = array_keys($configArray['Languages']);
             $dateFormat = new VuFindDate();
         }
         $language = $user->language;
         if (!in_array($user->language, $validLanguages)) {
             $language = $configArray['Site']['language'];
         }
         $translator = new I18N_Translator(array($configArray['Site']['local'] . '/lang', $configArray['Site']['local'] . '/lang_local'), $language, $configArray['System']['debug']);
         $interface->setLanguage($language);
         // Go through accounts and check loans
         $account = new User_account();
         $account->user_id = $user->id;
         if (!$account->find(false)) {
             continue;
         }
         $remindLoans = array();
         while ($account->fetch()) {
             $patron = $catalog->patronLogin($account->cat_username, $account->cat_password);
             if ($patron === null || PEAR::isError($patron)) {
                 $this->msg('Catalog login failed for user ' . $user->id . ', account ' . $account->id . ' (' . $account->cat_username . '): ' . ($patron ? $patron->getMessage() : 'patron not found'));
                 continue;
             }
             $loans = $catalog->getMyTransactions($patron);
             if (PEAR::isError($loans)) {
                 $this->msg('Could not fetch loans for user ' . $user->id . ', account ' . $account->id . ' (' . $account->cat_username . ')');
                 continue;
             }
             foreach ($loans as $loan) {
                 $dueDate = new DateTime($loan['duedate']);
                 if ($todayTime >= $dueDate || $dueDate->diff($todayTime)->days <= $user->due_date_reminder) {
                     // Check that a reminder hasn't been sent already
                     $reminder = new Due_date_reminder();
                     $reminder->user_id = $user->id;
                     $reminder->loan_id = $loan['item_id'];
                     $reminder->due_date = $dueDate->format($iso8601);
                     if ($reminder->find(false)) {
                         // Reminder already sent
                         continue;
                     }
                     // Store also title for display in email
                     $title = isset($loan['title']) ? $loan['title'] : translate('Title not available');
                     if (isset($loan['id'])) {
                         $record = $db->getRecord($loan['id']);
                         if ($record && isset($record['title'])) {
                             $title = $record['title'];
                         }
                     }
                     $remindLoans[] = array('loanId' => $loan['item_id'], 'dueDate' => $loan['duedate'], 'dueDateFormatted' => $dueDate->format(isset($configArray['Site']['displayDateFormat']) ? $configArray['Site']['displayDateFormat'] : "m-d-Y"), 'title' => $title);
                 }
             }
         }
         if ($remindLoans) {
             $this->msg(count($remindLoans) . ' new loans to remind for user ' . $user->id);
             $interface->assign('date', $dateFormat->convertToDisplayDate("U", floor(time())));
             $interface->assign('loans', $remindLoans);
             $key = $this->getSecret($user, $user->id);
             $params = array('id' => $user->id, 'type' => 'reminder', 'key' => $key);
             $unsubscribeUrl = $configArray['Site']['url'] . '/MyResearch/Unsubscribe?' . http_build_query($params);
             $interface->assign(compact('unsubscribeUrl'));
             // Load template
             $message = $interface->fetch('MyResearch/due-date-email.tpl');
             if (strstr($message, 'Warning: Smarty error:')) {
                 $this->msg("Message template processing failed: {$message}");
                 continue;
             }
             $result = $mailer->send($user->email, $configArray['Site']['email'], translate('due_date_email_subject'), $message);
             if (PEAR::isError($result)) {
                 $this->msg("Failed to send message to {$user->email}: " . $result->getMessage());
                 continue;
             }
             // Mark reminders sent
             foreach ($remindLoans as $loan) {
                 $reminder = new Due_date_reminder();
                 $reminder->user_id = $user->id;
                 $reminder->loan_id = $loan['loanId'];
                 $reminder->delete();
                 $dueDate = new DateTime($loan['dueDate']);
                 $reminder->due_date = $dueDate->format($iso8601);
                 $reminder->notification_date = gmdate($iso8601, time());
                 $reminder->insert();
             }
         } else {
             $this->msg('No loans to remind for user ' . $user->id);
         }
     }
     $this->reportErrors();
     $this->msg('Due date reminders execution completed');
 }
Exemplo n.º 9
0
 /**
  * Get an array of dates for results list display
  *
  * @return array
  * @access protected
  */
 protected function getResultDates()
 {
     if (!isset($this->fields['creation_sdaterange'])) {
         return null;
     }
     $range = explode(' ', $this->fields['creation_sdaterange'], 2);
     if (!$range) {
         return null;
     }
     $range[0] *= 86400;
     $range[1] *= 86400;
     $startDate = new DateTime("@{$range[0]}");
     $endDate = new DateTime("@{$range[1]}");
     if ($startDate->format('m') == 1 && $startDate->format('d') == 1 && $endDate->format('m') == 12 && $endDate->format('d') == 31) {
         return array($startDate->format('Y'), $endDate->format('Y'));
     }
     $date = new VuFindDate();
     return array($date->convertToDisplayDate('U', $range[0]), $date->convertToDisplayDate('U', $range[1]));
 }
Exemplo n.º 10
0
 /**
  * Get UB Request Details
  *
  * This is responsible for getting information on whether a UB request
  * can be made and the possible pickup locations
  *
  * @param array $details BIB, item and patron information
  *
  * @return bool|array False if request not allowed, or an array of associative
  * arrays with items, libraries, default library locations and default required by date.
  * @access public
  */
 public function getUBRequestDetails($details)
 {
     if (rand() % 10 == 1) {
         return false;
     }
     $dateFormat = new VuFindDate();
     $requiredByDate = $dateFormat->convertToDisplayDate("Y-m-d H:i", "now + 30 days");
     return array('items' => array(array('id' => 1, 'name' => 'Item 1'), array('id' => 2, 'name' => 'Item 2'), array('id' => 3, 'name' => 'Item 3')), 'libraries' => array(array('id' => 1, 'name' => 'Main Library', 'isDefault' => true), array('id' => 2, 'name' => 'Branch Library', 'isDefault' => false)), 'locations' => array(array('id' => 1, 'name' => 'Circulation Desk', 'isDefault' => true), array('id' => 2, 'name' => 'Reference Desk', 'isDefault' => false)), 'requiredBy' => $requiredByDate);
 }
Exemplo n.º 11
0
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $user;
     // Assign the ID of the last search so the user can return to it.
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : 'perkele');
     $dateFormat = new VuFindDate();
     // In some contexts, we want to require a login before showing search
     // history:
     if (isset($_REQUEST['require_login']) && !UserAccount::isLoggedIn()) {
         include_once 'services/MyResearch/Login.php';
         Login::launch();
         exit;
     }
     $interface->setPageTitle('Search History');
     // Retrieve search history
     $s = new SearchEntry();
     $searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
     if (count($searchHistory) > 0) {
         // Build an array of history entries
         $links = array();
         $saved = array();
         // Loop through the history
         foreach ($searchHistory as $search) {
             $size = strlen($search->search_object);
             $minSO = unserialize($search->search_object);
             $searchObject = SearchObjectFactory::deminify($minSO);
             // Make sure all facets are active so we get appropriate
             // descriptions in the filter box.
             $searchObject->activateAllFacets();
             $newItem = array('time' => $dateFormat->convertToDisplayDate("U", floor($searchObject->getStartTime())), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => number_format($searchObject->getResultTotal(), 0, ',', ' '), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'size' => round($size / 1024, 3) . "kb", 'schedule' => $search->schedule, 'last_executed' => $search->last_executed);
             // Saved searches
             if ($search->saved == 1) {
                 $saved[] = $newItem;
             } else {
                 // All the others...
                 // If this was a purge request we don't need this
                 if (isset($_REQUEST['purge']) && $_REQUEST['purge'] == 'true') {
                     $search->delete();
                     // We don't want to remember the last search after a purge:
                     unset($_SESSION['lastSearchURL']);
                     unset($_SESSION['lastSearchDisplayQuery']);
                 } else {
                     // Otherwise add to the list
                     $links[] = $newItem;
                 }
             }
         }
         // One final check, after a purge make sure we still have a history
         if (count($links) > 0 || count($saved) > 0) {
             $interface->assign('links', array_reverse($links));
             $interface->assign('saved', array_reverse($saved));
             $interface->assign('noHistory', false);
         } else {
             // Nothing left in history
             $interface->assign('noHistory', true);
         }
     } else {
         // No history
         $interface->assign('noHistory', true);
     }
     $interface->setTemplate('history.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 12
0
 /**
  * Convert spatial date range filter to displayable string
  *
  * @param string $filter Spatial date range filter
  *
  * @return string Resulting display string
  */
 protected function spatialDateRangeFilterToString($filter)
 {
     $range = VuFindSolrUtils::parseSpatialDateRange($filter, $this->spatialDateRangeFilterType);
     if ($range === false) {
         return $filter;
     }
     $startDate = new DateTime("@{$range['from']}");
     $endDate = new DateTime("@{$range['to']}");
     if ($startDate->format('m') == 1 && $startDate->format('d') == 1 && $endDate->format('m') == 12 && $endDate->format('d') == 31) {
         return $startDate->format('Y') . ' - ' . $endDate->format('Y');
     }
     $date = new VuFindDate();
     return $date->convertToDisplayDate('U', $range['from']) . ' - ' . $date->convertToDisplayDate('U', $range['to']);
 }
Exemplo n.º 13
0
 /**
  * Protected method for getting a default due date
  *
  * @return string A formatted default due date
  * @access protected
  */
 protected function getDefaultDueDate()
 {
     include_once 'sys/VuFindDate.php';
     $formatDate = new VuFindDate();
     $dateArray = isset($this->checkHolds['defaultRequiredDate']) ? explode(":", $this->checkHolds['defaultRequiredDate']) : array(0, 1, 0);
     list($d, $m, $y) = $dateArray;
     $nextMonth = mktime(0, 0, 0, date("m") + $m, date("d") + $d, date("Y") + $y);
     return $formatDate->convertToDisplayDate("U", $nextMonth);
 }
Exemplo n.º 14
0
 /**
  * Add or edit an account
  *
  * @param int $id Account ID (null to add a new account)
  *
  * @return void
  */
 protected function editAccount($id)
 {
     global $user;
     global $interface;
     if (isset($id)) {
         $account = new User_account();
         $account->id = $id;
         $account->user_id = $user->id;
         if (!$account->find(true)) {
             header('Location: Accounts');
             die;
         }
         $date = new VuFindDate();
         $interface->assign('id', $account->id);
         $interface->assign('account_name', isset($_REQUEST['account_name']) ? $_REQUEST['account_name'] : $account->account_name);
         $interface->assign('description', isset($_REQUEST['description']) ? $_REQUEST['description'] : $account->description);
         list($login_target, $cat_username) = explode('.', $account->cat_username, 2);
         $interface->assign('login_target', isset($_REQUEST['login_target']) ? $_REQUEST['login_target'] : $login_target);
         $interface->assign('cat_username', isset($_REQUEST['username']) ? $_REQUEST['username'] : $cat_username);
         $interface->assign('cat_password', $account->cat_password);
         $interface->assign('home_library', $account->home_library);
         $interface->assign('created', $date->convertToDisplayDate('Y-m-d H:i:s', $account->created));
         $interface->assign('changed', $date->convertToDisplayDate('Y-m-d H:i:s', $account->saved));
     } else {
         $interface->assign('account_name', isset($_REQUEST['account_name']) ? $_REQUEST['account_name'] : '');
         $interface->assign('description', isset($_REQUEST['description']) ? $_REQUEST['description'] : '');
         $interface->assign('login_target', isset($_REQUEST['login_target']) ? $_REQUEST['login_target'] : '');
         $interface->assign('cat_username', isset($_REQUEST['username']) ? $_REQUEST['username'] : '');
     }
     Login::setupLoginFormVars();
     $interface->setTemplate('editAccount.tpl');
     $interface->setPageTitle('Library Cards');
     $interface->display('layout.tpl');
 }