Ejemplo n.º 1
0
 /**
  * User's Library cards (home_library values)
  *
  * @return	array
  */
 public function getUsersHomeLibraries()
 {
     if ($this->useLibraryCardsForPriority && ($user = $this->authManager->isLoggedIn())) {
         // is loggedIn
         $libraryCards = $user->getLibraryCards()->toArray();
         $myLibs = array();
         foreach ($libraryCards as $libCard) {
             $homeLib = $libCard['home_library'];
             $myLibs[] = $homeLib;
         }
         return array_unique($myLibs);
     }
     return [];
 }
Ejemplo n.º 2
0
 /**
  * Attempt to log in the user to the ILS, and save credentials if it works.
  *
  * @param string $username Catalog username
  * @param string $password Catalog password
  *
  * Returns associative array of patron data on success, false on failure.
  *
  * @return array|bool
  * @throws ILSException
  */
 public function newCatalogLogin($username, $password)
 {
     $result = $this->catalog->patronLogin($username, $password);
     if ($result) {
         $user = $this->auth->isLoggedIn();
         if ($user) {
             $user->saveCredentials($username, $password);
             $this->auth->updateSession($user);
             // cache for future use
             $this->ilsAccount[$username] = $result;
         }
         return $result;
     }
     return false;
 }
Ejemplo n.º 3
0
 public function handleSort(Manager $manager, Parameters $request, $defaultSort, $target)
 {
     $user = $manager->isLoggedIn();
     $requestParams = $request->toArray();
     if ($user) {
         //in case user changed the the sort settings on the result list with a specialized UI control
         //we want to serialize the new value in database
         if (array_key_exists('sortControlElement', $requestParams)) {
             if (array_key_exists('sort', $requestParams)) {
                 $sort = $requestParams['sort'];
                 $dbSort = unserialize($user->default_sort);
                 $dbSort[$target] = $requestParams['sort'];
                 $user->default_sort = serialize($dbSort);
                 $user->save();
             } else {
                 $tSort = $request->get('sort');
                 $sort = !empty($tSort) ? $tSort : $defaultSort;
             }
         } else {
             $tSort = $request->get('sort');
             $sort = !empty($tSort) ? $tSort : $defaultSort;
             //overwrite sort if value is set in database
             if ($user->default_sort) {
                 $userDefaultSort = unserialize($user->default_sort);
                 if (isset($userDefaultSort[$target])) {
                     $sort = $userDefaultSort[$target];
                 }
             }
         }
     } else {
         $sort = $request->get('sort');
     }
     // Check for special parameter only relevant in RSS mode:
     if ($request->get('skip_rss_sort', 'unset') != 'unset') {
         $this->skipRssSort = true;
     }
     return $sort;
 }
Ejemplo n.º 4
0
 /**
  * Get user institutions from database
  *
  * @return    String[]
  */
 protected function getFromDatabase()
 {
     $favoriteList = $this->authManager->isLoggedIn()->favorite_institutions;
     return $favoriteList ? explode(',', $favoriteList) : array();
 }
Ejemplo n.º 5
0
 /**
  * Determines whether or not the current user session is identifed as a guest
  * session
  *
  * @return string 'y'|'n'
  */
 protected function isGuest()
 {
     // If the user is not logged in, then treat them as a guest. Unless they are
     // using IP Authentication.
     // If IP Authentication is used, then don't treat them as a guest.
     if ($this->ipAuth) {
         return 'n';
     }
     if (isset($this->authManager)) {
         return $this->authManager->isLoggedIn() ? 'n' : 'y';
     }
     return 'y';
 }
Ejemplo n.º 6
0
 /**
  * Check whether user is logged in
  *
  * @return Boolean
  */
 protected function isLoggedIn()
 {
     return $this->authManager->isLoggedIn() !== false;
 }