Example #1
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     if (isset($_REQUEST['followup'])) {
         $followupUrl = $configArray['Site']['path'] . "/" . strip_tags($_REQUEST['followupModule']);
         if (!empty($_REQUEST['recordId'])) {
             $followupUrl .= "/" . strip_tags($_REQUEST['recordId']);
         }
         $followupUrl .= "/" . strip_tags($_REQUEST['followupAction']);
         if (isset($_REQUEST['comment'])) {
             $followupUrl .= "?comment=" . urlencode($_REQUEST['comment']);
         }
         header("Location: " . $followupUrl);
     }
     if (isset($_REQUEST['returnUrl'])) {
         $followupUrl = $_REQUEST['returnUrl'];
         header("Location: " . $followupUrl);
     }
     // Delete Resource
     if (isset($_GET['delete'])) {
         $resource = Resource::staticGet('record_id', strip_tags($_GET['delete']));
         $user->removeResource($resource);
     }
     // Narrow by Tag
     if (isset($_GET['tag'])) {
         $interface->assign('tags', strip_tags($_GET['tag']));
     }
     global $library;
     if (isset($library)) {
         $interface->assign('showRatings', $library->showRatings);
     } else {
         $interface->assign('showRatings', 1);
     }
     //Check to see if the user has rated any titles
     $interface->assign('hasRatings', $user->hasRatings());
     // Get My Lists
     $listList = $user->getLists();
     $interface->assign('listList', $listList);
     // Get My Tags
     $tagList = $user->getTags();
     $interface->assign('tagList', $tagList);
     $interface->setPageTitle('Favorites');
     $interface->setTemplate('favorites.tpl');
     $interface->display('layout.tpl');
 }
Example #2
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Get all lists for the user
     if ($user) {
         $tmpList = new User_list();
         $tmpList->user_id = $user->id;
         $tmpList->orderBy("title ASC");
         $tmpList->find();
         $allLists = array();
         if ($tmpList->N > 0) {
             while ($tmpList->fetch()) {
                 $allLists[$tmpList->id] = $tmpList->title;
             }
         } else {
             $allList["-1"] = "My Favorites";
         }
         $interface->assign('allLists', $allLists);
     }
     //Figure out if we should show a link to classic opac to pay holds.
     $ecommerceLink = $configArray['Site']['ecommerceLink'];
     if ($user) {
         $homeLibrary = Library::getLibraryForLocation($user->homeLocationId);
     }
     if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) {
         $interface->assign('showEcommerceLink', true);
         $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
         if ($homeLibrary->payFinesLink == 'default' || strlen($homeLibrary->payFinesLink) == 0) {
             $interface->assign('ecommerceLink', $ecommerceLink);
         } else {
             $interface->assign('ecommerceLink', $homeLibrary->payFinesLink);
         }
         $interface->assign('payFinesLinkText', $homeLibrary->payFinesLinkText);
     } else {
         $interface->assign('showEcommerceLink', false);
         $interface->assign('minimumFineAmount', 0);
     }
     // Fetch List object
     if (isset($_GET['id'])) {
         $list = User_list::staticGet($_GET['id']);
     } else {
         //Use the first list.
         if (isset($allLists)) {
             $firstListId = reset(array_keys($allLists));
             if ($firstListId == false || $firstListId == -1) {
                 $list = new User_list();
                 $list->user_id = $user->id;
                 $list->public = false;
                 $list->title = "My Favorites";
             } else {
                 $list = User_list::staticGet($firstListId);
             }
         }
     }
     // Ensure user have privs to view the list
     if (!isset($list) || !$list->public && !UserAccount::isLoggedIn()) {
         require_once 'Login.php';
         Login::launch();
         exit;
     }
     if (!$list->public && $list->user_id != $user->id) {
         PEAR_Singleton::raiseError(new PEAR_Error(translate('list_access_denied')));
     }
     //Reindex can happen by anyone since it needs to be called by cron
     if (isset($_REQUEST['myListActionHead']) && strlen($_REQUEST['myListActionHead']) > 0) {
         $actionToPerform = $_REQUEST['myListActionHead'];
         if ($actionToPerform == 'reindex') {
             $list->updateDetailed(true);
         }
     }
     if (isset($_SESSION['listNotes'])) {
         $interface->assign('notes', $_SESSION['listNotes']);
         unset($_SESSION['listNotes']);
     }
     //Perform an action on the list, but verify that the user has permission to do so.
     $userCanEdit = false;
     if ($user != false) {
         if ($user->id == $list->user_id) {
             $userCanEdit = true;
         } elseif ($user->hasRole('opacAdmin')) {
             $userCanEdit = true;
         } elseif ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) {
             $listUser = new User();
             $listUser->id = $list->user_id;
             $listUser->find(true);
             $listLibrary = Library::getLibraryForLocation($listUser->homeLocationId);
             $userLibrary = Library::getLibraryForLocation($user->homeLocationId);
             if ($userLibrary->libraryId == $listLibrary->libraryId) {
                 $userCanEdit = true;
             }
         }
     }
     if ($userCanEdit && (isset($_REQUEST['myListActionHead']) || isset($_REQUEST['myListActionItem']) || isset($_GET['delete']))) {
         if (isset($_REQUEST['myListActionHead']) && strlen($_REQUEST['myListActionHead']) > 0) {
             $actionToPerform = $_REQUEST['myListActionHead'];
             if ($actionToPerform == 'makePublic') {
                 $list->public = 1;
                 $list->update();
             } elseif ($actionToPerform == 'makePrivate') {
                 $list->public = 0;
                 $list->updateDetailed(false);
                 $list->removeFromSolr();
             } elseif ($actionToPerform == 'saveList') {
                 $list->title = $_REQUEST['newTitle'];
                 $list->description = $_REQUEST['newDescription'];
                 $list->update();
             } elseif ($actionToPerform == 'deleteList') {
                 $list->delete();
                 header("Location: {$configArray['Site']['path']}/MyResearch/Home");
                 die;
             } elseif ($actionToPerform == 'bulkAddTitles') {
                 $notes = $this->bulkAddTitles($list);
                 $_SESSION['listNotes'] = $notes;
             }
         } elseif (isset($_REQUEST['myListActionItem']) && strlen($_REQUEST['myListActionItem']) > 0) {
             $actionToPerform = $_REQUEST['myListActionItem'];
             if ($actionToPerform == 'deleteMarked') {
                 //get a list of all titles that were selected
                 $itemsToRemove = $_REQUEST['selected'];
                 foreach ($itemsToRemove as $id => $selected) {
                     //add back the leading . to get the full bib record
                     $resource = Resource::staticGet('record_id', "{$id}");
                     $list->removeResource($resource);
                 }
             } elseif ($actionToPerform == 'deleteAll') {
                 $list->removeAllResources(isset($_GET['tag']) ? $_GET['tag'] : null);
             }
             $list->update();
         } elseif (isset($_GET['delete'])) {
             $resource = Resource::staticGet('record_id', $_GET['delete']);
             $list->removeResource($resource);
             $list->update();
         }
         //Redirect back to avoid having the parameters stay in the URL.
         header("Location: {$configArray['Site']['path']}/MyResearch/MyList/{$list->id}");
         die;
     }
     // Send list to template so title/description can be displayed:
     $interface->assign('favList', $list);
     $interface->assign('listSelected', $list->id);
     // Build Favorites List
     $favorites = $list->getResources(isset($_GET['tag']) ? $_GET['tag'] : null);
     // Load the User object for the owner of the list (if necessary):
     if ($user && $user->id == $list->user_id) {
         $listUser = $user;
     } else {
         if ($list->user_id != 0) {
             $listUser = new User();
             $listUser->id = $list->user_id;
             if (!$listUser->fetch(true)) {
                 $listUser = false;
             }
         } else {
             $listUser = false;
         }
     }
     // Create a handler for displaying favorites and use it to assign
     // appropriate template variables:
     $interface->assign('allowEdit', $userCanEdit);
     $favList = new FavoriteHandler($favorites, $listUser, $list->id, $userCanEdit);
     $favList->assign();
     //Need to add profile information from MyResearch to show profile data.
     if ($user !== false) {
         global $configArray;
         $this->catalog = new CatalogConnection($configArray['Catalog']['driver']);
         // Get My Profile
         if ($this->catalog->status) {
             if ($user->cat_username) {
                 $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
                 if (PEAR_Singleton::isError($patron)) {
                     PEAR_Singleton::raiseError($patron);
                 }
                 $result = $this->catalog->getMyProfile($patron);
                 if (!PEAR_Singleton::isError($result)) {
                     $interface->assign('profile', $result);
                 }
             }
         }
         //Figure out if we should show a link to classic opac to pay holds.
         $homeLibrary = Library::getLibraryForLocation($user->homeLocationId);
         if (isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) {
             $interface->assign('showEcommerceLink', true);
             $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
         } else {
             $interface->assign('showEcommerceLink', false);
             $interface->assign('minimumFineAmount', 0);
         }
     }
     $interface->setTemplate('list.tpl');
     $interface->display('layout.tpl');
 }
Example #3
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     if (isset($_REQUEST['returnUrl'])) {
         $followupUrl = $_REQUEST['returnUrl'];
         header("Location: " . $followupUrl);
         exit;
     }
     // Delete Resource
     if (isset($_GET['delete'])) {
         $resource = Resource::staticGet('record_id', strip_tags($_GET['delete']));
         $user->removeResource($resource);
     }
     // Narrow by Tag
     if (isset($_GET['tag'])) {
         $interface->assign('tags', strip_tags($_GET['tag']));
     }
     //We are going to the "main page of My Research"
     //Be smart about this depending on the user's information.
     $hasHomeTemplate = $interface->template_exists('MyResearch/home.tpl');
     if (!$user) {
         $action = 'Home';
     } elseif ($hasHomeTemplate) {
         //Var for the IDCLREADER TEMPLATE
         $interface->assign('ButtonBack', false);
         $interface->assign('ButtonHome', true);
         $interface->assign('MobileTitle', ' ');
         $interface->setTemplate('home.tpl');
     } else {
         if ($user && !$interface->isMobile()) {
             // Connect to Database
             $catalog = new CatalogConnection($configArray['Catalog']['driver']);
             $patron = $catalog->patronLogin($user->cat_username, $user->cat_password);
             $profile = $catalog->getMyProfile($patron);
             if ($profile['numCheckedOut'] > 0) {
                 $action = 'CheckedOut';
             } elseif ($profile['numHolds'] > 0) {
                 $action = 'Holds';
             } else {
                 $action = 'Favorites';
             }
             header("Location: /MyResearch/{$action}");
         } else {
             //Go to the login page which is the home page
             $action = 'Home';
         }
         // Build Favorites List
         $favorites = $user->getResources(isset($_GET['tag']) ? strip_tags($_GET['tag']) : null);
         $favList = new FavoriteHandler($favorites, $user);
         $favList->assign();
         // Get My Lists
         $listList = $user->getLists();
         $interface->assign('listList', $listList);
         // Get My Tags
         $tagList = $user->getTags();
         $interface->assign('tagList', $tagList);
         $interface->setPageTitle('Favorites');
         $interface->setTemplate('favorites.tpl');
     }
     $interface->display('layout.tpl');
 }