Exemplo n.º 1
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $configArray;
     // Don't allow account creation if a non-DB authentication method
     // is being used!!
     if ($configArray['Authentication']['method'] !== 'DB') {
         header('Location: Home');
         die;
     }
     if (isset($_POST['submit'])) {
         $result = $this->_processInput();
         if (PEAR::isError($result)) {
             $interface->assign('message', $result->getMessage());
             $interface->assign('formVars', $_POST);
             $interface->setTemplate('account.tpl');
             $interface->display('layout.tpl');
         } else {
             // Now that the account is created, log the user in:
             UserAccount::login();
             header('Location: Home');
             die;
         }
     } else {
         $interface->setPageTitle('User Account');
         $interface->setTemplate('account.tpl');
         $interface->display('layout.tpl');
     }
 }
Exemplo n.º 2
0
 function Login()
 {
     global $configArray;
     // Fetch Salt
     $salt = $this->generateSalt();
     // HexDecode Password
     $password = pack('H*', $_GET['password']);
     // Decrypt Password
     /*
     require_once 'Crypt/Blowfish.php';
     $cipher = new Crypt_Blowfish($salt);
     $password = $cipher->decrypt($_GET['password']);
     */
     /*
     require_once 'Crypt/XXTEA.php';
     $cipher = new Crypt_XXTEA();
     $cipher->setKey($salt);
     $password = $cipher->decrypt($password);
     */
     require_once 'Crypt/rc4.php';
     $password = rc4Encrypt($salt, $password);
     // Put the username/password in POST fields where the authentication module
     // expects to find them:
     $_POST['username'] = $_GET['username'];
     $_POST['password'] = $password;
     // Authenticate the user:
     $user = UserAccount::login();
     if (PEAR_Singleton::isError($user)) {
         return 'Error';
     } else {
         return 'True';
     }
 }
Exemplo n.º 3
0
 function loginUser()
 {
     //Login the user.  Must be called via Post parameters.
     global $user;
     global $interface;
     $user = UserAccount::isLoggedIn();
     if (!$user || PEAR_Singleton::isError($user)) {
         $user = UserAccount::login();
         $interface->assign('user', $user);
         if (!$user || PEAR_Singleton::isError($user)) {
             return array('success' => false, 'message' => translate("Sorry that login information was not recognized, please try again."));
         }
     }
     $patronHomeBranch = Location::getUserHomeLocation();
     //Check to see if materials request should be activated
     require_once ROOT_DIR . '/sys/MaterialsRequest.php';
     return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname), 'phone' => $user->phone, 'email' => $user->email, 'homeLocation' => isset($patronHomeBranch) ? $patronHomeBranch->code : '', 'homeLocationId' => isset($patronHomeBranch) ? $patronHomeBranch->locationId : '', 'enableMaterialsRequest' => MaterialsRequest::enableMaterialsRequest(true));
 }
Exemplo n.º 4
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.º 5
0
 /**
  * Login with post'ed username and encrypted password.
  *
  * @return void
  * @access public
  */
 public function login()
 {
     global $configArray;
     unset($_SESSION['no_store']);
     // Fetch Salt
     $salt = $this->_generateSalt();
     // HexDecode Password
     $password = pack('H*', $_POST['ajax_password']);
     // Decrypt Password
     include_once 'Crypt/rc4.php';
     // Looks like we need utf8_encode to handle the password properly
     $password = utf8_encode(rc4Decrypt($salt, $password));
     // Put the username/password in POST fields where the authentication module
     // expects to find them:
     $_POST['username'] = $_POST['ajax_username'];
     $_POST['password'] = $password;
     $_POST['login_target'] = $_POST['ajax_loginTarget'];
     // Authenticate the user:
     $user = UserAccount::login();
     if (PEAR::isError($user)) {
         $msgType = $user->getMessage();
         $msg = translate($msgType);
         if ($user->getCode() == ILSAuthentication::ERROR_CONFIRM_CREATE_ACCOUNT) {
             return $this->output(array('msg' => $msg, 'type' => $msgType, 'accounts' => $user->getUserInfo()), JSON::STATUS_ERROR);
         } else {
             return $this->output($msg, JSON::STATUS_ERROR);
         }
     }
     return $this->output(true, JSON::STATUS_OK);
 }
Exemplo n.º 6
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     $driver = new EContentDriver();
     $id = strip_tags($_REQUEST['id']);
     $interface->assign('id', $id);
     global $logger;
     //Get title information for the record.
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError("Unable to find eContent record for id: {$id}");
     }
     if (isset($_REQUEST['autologout'])) {
         $_SESSION['autologout'] = true;
     }
     if (isset($_POST['submit']) || $user) {
         if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
             //Log the user in
             $user = UserAccount::login();
         }
         if (!PEAR_Singleton::isError($user) && $user) {
             //The user is already logged in
             $return = $driver->placeHold($id, $user);
             $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 (!PEAR_Singleton::isError($user) && $user) {
             //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');
         }
     }
     if (isset($return) && $showMessage) {
         $hold_message_data = array('successful' => $return['result'] ? 'all' : 'none', 'error' => $return['error'], 'titles' => array($return));
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             $logger->log('Hold Referrer is set, redirecting to there.  type = ' . $_REQUEST['type'], PEAR_LOG_INFO);
             header("Location: " . $_SESSION['hold_referrer']);
             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: " . $configArray['Site']['path'] . '/MyResearch/EContentHolds?section=unavailable');
         }
     } 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.º 7
0
 function placeHolds()
 {
     global $interface;
     global $configArray;
     global $user;
     if (!isset($_REQUEST['selected'])) {
         $hold_message_data = array('successful' => 'none', 'error' => 'No titles were selected', 'titles' => array());
         $showMessage = true;
     } else {
         $selectedIds = $_REQUEST['selected'];
         $eContentDriver = null;
         $showMessage = false;
         $holdings = array();
         //Check to see if all items are eContent
         $ids = array();
         $allItemsEContent = true;
         foreach ($selectedIds as $recordId => $onOff) {
             $ids[] = $recordId;
             //Get the title for the item
             $resource = new Resource();
             if (strpos($recordId, 'econtentRecord') !== 0) {
                 $allItemsEContent = false;
                 $resource->record_id = '.' . $recordId;
                 $resource->source = 'VuFind';
                 $resource->deleted = 0;
             } else {
                 $shortId = str_replace('econtentRecord', '', $recordId);
                 $resource->record_id = $shortId;
                 $resource->source = 'eContent';
                 $resource->deleted = 0;
             }
             if ($resource->find(true)) {
                 $holdings[] = $resource->title;
             } else {
                 echo "Could not find resource for record id {$recordId}";
             }
         }
         $interface->assign('ids', $ids);
         $interface->assign('holdings', $holdings);
         $hold_message_data = array('successful' => 'all', 'titles' => array());
         if (isset($_REQUEST['autologout'])) {
             $_SESSION['autologout'] = true;
         }
         //Check to see if we are ready to place the hold.
         $placeHold = false;
         if (isset($_REQUEST['holdType']) && isset($_REQUEST['campus'])) {
             $placeHold = true;
         } else {
             if ($user && $allItemsEContent) {
                 $placeHold = true;
             }
         }
         if ($placeHold) {
             $hold_message_data['campus'] = $_REQUEST['campus'];
             //This is a new login
             if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
                 $user = UserAccount::login();
             }
             if ($user == false) {
                 $hold_message_data['error'] = 'Incorrect Patron Information';
                 $showMessage = true;
             } else {
                 $atLeast1Successful = false;
                 foreach ($selectedIds as $recordId => $onOff) {
                     if (strpos($recordId, 'econtentRecord', 0) === 0) {
                         if ($eContentDriver == null) {
                             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                             $eContentDriver = new EContentDriver();
                         }
                         $return = $eContentDriver->placeHold($recordId, $user);
                     } else {
                         $return = $this->catalog->placeHold($recordId, $user->password, '', $_REQUEST['holdType']);
                     }
                     $hold_message_data['titles'][] = $return;
                     if (!$return['result']) {
                         $hold_message_data['successful'] = 'partial';
                     } else {
                         $atLeast1Successful = true;
                     }
                     //Check to see if there are item level holds that need follow-up by the user
                     if (isset($return['items'])) {
                         $hold_message_data['showItemForm'] = true;
                     }
                     $showMessage = true;
                 }
                 if (!$atLeast1Successful) {
                     $hold_message_data['successful'] = 'none';
                 }
             }
         } 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 + count($selectedIds) > $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 $librarySingleton;
             $patronHomeBranch = $librarySingleton->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 {
                 //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 = $librarySingleton->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', '');
             }
         }
     }
     if ($showMessage) {
         $hold_message_data['fromCart'] = isset($_REQUEST['fromCart']);
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             if ($_REQUEST['type'] != 'recall' && $_REQUEST['type'] != 'cancel' && $_REQUEST['type'] != 'update') {
                 header("Location: " . $_SESSION['hold_referrer']);
             } else {
                 //Redirect for hold cancellation or update
                 header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds');
             }
             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 {
             header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds');
         }
     } else {
         $interface->assign('fromCart', isset($_REQUEST['fromCart']));
         $interface->setPageTitle('Request Items');
         $interface->setTemplate('holdMultiple.tpl');
         $interface->display('layout.tpl', 'RecordHolds');
     }
 }
Exemplo n.º 8
0
 /**
  * Logs in the user and sets a cookie indicating that the user is logged in.
  * Must be called by POSTing data to the API.
  * This method is only useful from VuFind itself or from files which can share cookies
  * with the VuFind server.
  *
  * Sample call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI
  * Post variables:
  *   method=login
  *   username=23025003575917
  *   password=7604
  * </code>
  *
  * Sample response:
  * <code>
  * {"result":true}
  * </code>
  *
  * @access private
  * @author Mark Noble <*****@*****.**>
  */
 function login()
 {
     //Login the user.  Must be called via Post parameters.
     $user = UserAccount::isLoggedIn();
     if (isset($_POST['username']) && isset($_POST['password'])) {
         if ($user && !PEAR_Singleton::isError($user)) {
             return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname));
         } else {
             $user = UserAccount::login();
             if ($user && !PEAR_Singleton::isError($user)) {
                 return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname));
             } else {
                 return array('success' => false);
             }
         }
     } else {
         return array('success' => false, 'message' => 'This method must be called via POST.');
     }
 }
Exemplo n.º 9
0
    } else {
        $analytics->setPatronType('logged out');
        $analytics->setHomeLocationId(-1);
    }
}
// Process Authentication, must be done here so we can redirect based on user information
// immediately after logging in.
$interface->assign('loggedIn', $user == false ? 'false' : 'true');
if ($user) {
    $interface->assign('user', $user);
    //Create a cookie for the user's home branch so we can sort holdings even if they logout.
    //Cookie expires in 1 week.
    setcookie('home_location', $user->homeLocationId, time() + 60 * 60 * 24 * 7, '/');
} else {
    if (isset($_POST['username']) && isset($_POST['password']) && ($action != 'Account' && $module != 'AJAX')) {
        $user = UserAccount::login();
        if (PEAR_Singleton::isError($user)) {
            require_once ROOT_DIR . '/services/MyAccount/Login.php';
            $launchAction = new MyAccount_Login();
            $launchAction->launch($user->getMessage());
            exit;
        }
        $interface->assign('user', $user);
        $interface->assign('loggedIn', $user == false ? 'false' : 'true');
        //Check to see if there is a followup module and if so, use that module and action for the next page load
        if (isset($_REQUEST['returnUrl'])) {
            $followupUrl = $_REQUEST['returnUrl'];
            header("Location: " . $followupUrl);
            exit;
        }
        if ($user) {
Exemplo n.º 10
0
#instantiate classes
$view = new View();
$user = new UserAccount();
$crud = new Crud();
$queries = new Queries();
#routes
if (!empty($_GET["action"])) {
    # =-=-=-=-=-=-= Route for Admin log in page =-=-=-=
    if ($_GET['action'] == "aDmInLoGIN") {
        $view->getView("../views/head.php");
        $view->getView("../views/nav.php");
        $view->getView("../views/loginForm.php");
    }
    # =-=-=-=-=-=-= Action to login=-=-=-=-=-=-=-=-=-=
    if ($_GET['action'] == "login") {
        $user->login();
    }
    # =-=-=-=-=-=-= Action to logout =-=-=-=-=-=-=-=-=-=
    if ($_GET["action"] == "logout") {
        $view->getView("../views/head.php");
        $view->getView("../views/footer.php");
    }
    # =-=-=-=-=-=-= Route for admin page =-=-=-=-=-=-=
    if ($_GET["action"] == "aDmINDasHBoard") {
        $view->getView("../views/head.php");
        $view->getView("../views/nav.php");
        $view->getView("../views/uploadForm.php");
    }
    # =-=-=-=-=-=-= Action to upload song =-=-=-=-=-=-=
    if ($_GET["action"] == "createPost") {
        $checkUpload = $crud->postSong();
Exemplo n.º 11
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Make sure that the user is valid
     $processForm = true;
     if (!$user) {
         $user = UserAccount::login();
         if ($user == null) {
             $interface->assign('error', 'Sorry, we could not log you in.  Please enter a valid barcode and pin number submit a materials request.');
             $processForm = false;
         }
     }
     if ($processForm) {
         //Check to see if the user type is ok to submit a request
         $enableMaterialsRequest = true;
         if (isset($configArray['MaterialsRequest']['allowablePatronTypes'])) {
             //Check to see if we need to do additonal restrictions by patron type
             $allowablePatronTypes = $configArray['MaterialsRequest']['allowablePatronTypes'];
             if (strlen($allowablePatronTypes) > 0 && $user) {
                 if (!preg_match("/^{$allowablePatronTypes}\$/i", $user->patronType)) {
                     $enableMaterialsRequest = false;
                 }
             }
         }
         if (!$enableMaterialsRequest) {
             $interface->assign('success', false);
             $interface->assign('error', 'Sorry, only residents may submit materials requests at this time.');
         } else {
             if ($_REQUEST['format'] == 'article' && $_REQUEST['acceptCopyright'] != 1) {
                 $interface->assign('success', false);
                 $interface->assign('error', 'Sorry, you must accept the copyright agreement before submitting a materials request.');
             } else {
                 //Check to see how many active materials request results the user has already.
                 $materialsRequest = new MaterialsRequest();
                 $materialsRequest->createdBy = $user->id;
                 $statusQuery = new MaterialsRequestStatus();
                 $homeLibrary = Library::getPatronHomeLibrary();
                 $statusQuery->libraryId = $homeLibrary->libraryId;
                 $statusQuery->isOpen = 1;
                 $materialsRequest->joinAdd($statusQuery);
                 $materialsRequest->selectAdd();
                 $materialsRequest->selectAdd('materials_request.*, description as statusLabel');
                 $materialsRequest->find();
                 if ($materialsRequest->N >= 5) {
                     $interface->assign('success', false);
                     $interface->assign('error', "You\\'ve already reached your maximum limit of five requests open at one time. Once we've processed your existing requests, you'll be able to submit again. To check the status of your current requests, visit your account page [link to account page].");
                 } else {
                     //Materials request can be submitted.
                     $materialsRequest = new MaterialsRequest();
                     $materialsRequest->phone = isset($_REQUEST['phone']) ? strip_tags($_REQUEST['phone']) : '';
                     $materialsRequest->email = strip_tags($_REQUEST['email']);
                     $materialsRequest->title = strip_tags($_REQUEST['title']);
                     $materialsRequest->season = isset($_REQUEST['season']) ? strip_tags($_REQUEST['season']) : '';
                     $materialsRequest->magazineTitle = isset($_REQUEST['magazineTitle']) ? strip_tags($_REQUEST['magazineTitle']) : '';
                     $materialsRequest->magazineDate = isset($_REQUEST['magazineDate']) ? strip_tags($_REQUEST['magazineDate']) : '';
                     $materialsRequest->magazineVolume = isset($_REQUEST['magazineVolume']) ? strip_tags($_REQUEST['magazineVolume']) : '';
                     $materialsRequest->magazineNumber = isset($_REQUEST['magazineNumber']) ? strip_tags($_REQUEST['magazineNumber']) : '';
                     $materialsRequest->magazinePageNumbers = isset($_REQUEST['magazinePageNumbers']) ? strip_tags($_REQUEST['magazinePageNumbers']) : '';
                     $materialsRequest->author = strip_tags($_REQUEST['author']);
                     $materialsRequest->format = strip_tags($_REQUEST['format']);
                     if ($materialsRequest->format == 'ebook' && isset($_REQUEST['ebookFormat'])) {
                         $materialsRequest->subFormat = strip_tags($_REQUEST['ebookFormat']);
                     } elseif ($materialsRequest->format == 'eaudio' && isset($_REQUEST['eaudioFormat'])) {
                         $materialsRequest->subFormat = strip_tags($_REQUEST['eaudioFormat']);
                     }
                     $materialsRequest->subFormat = isset($_REQUEST['subFormat']) ? strip_tags($_REQUEST['subFormat']) : '';
                     $materialsRequest->ageLevel = isset($_REQUEST['ageLevel']) ? strip_tags($_REQUEST['ageLevel']) : '';
                     $materialsRequest->bookType = isset($_REQUEST['bookType']) ? strip_tags($_REQUEST['bookType']) : '';
                     $materialsRequest->isbn = isset($_REQUEST['isbn']) ? strip_tags($_REQUEST['isbn']) : '';
                     $materialsRequest->upc = isset($_REQUEST['upc']) ? strip_tags($_REQUEST['upc']) : '';
                     $materialsRequest->issn = isset($_REQUEST['issn']) ? strip_tags($_REQUEST['issn']) : '';
                     $materialsRequest->oclcNumber = isset($_REQUEST['oclcNumber']) ? strip_tags($_REQUEST['oclcNumber']) : '';
                     $materialsRequest->publisher = strip_tags($_REQUEST['publisher']);
                     $materialsRequest->publicationYear = strip_tags($_REQUEST['publicationYear']);
                     if (isset($_REQUEST['abridged'])) {
                         if ($_REQUEST['abridged'] == 'abridged') {
                             $materialsRequest->abridged = 1;
                         } elseif ($_REQUEST['abridged'] == 'unabridged') {
                             $materialsRequest->abridged = 0;
                         } else {
                             $materialsRequest->abridged = 2;
                             //Not applicable
                         }
                     }
                     $materialsRequest->about = strip_tags($_REQUEST['about']);
                     $materialsRequest->comments = strip_tags($_REQUEST['comments']);
                     if (isset($_REQUEST['placeHoldWhenAvailable'])) {
                         $materialsRequest->placeHoldWhenAvailable = $_REQUEST['placeHoldWhenAvailable'];
                     } else {
                         $materialsRequest->placeHoldWhenAvailable = 0;
                     }
                     if (isset($_REQUEST['holdPickupLocation'])) {
                         $materialsRequest->holdPickupLocation = $_REQUEST['holdPickupLocation'];
                     }
                     if (isset($_REQUEST['bookmobileStop'])) {
                         $materialsRequest->bookmobileStop = $_REQUEST['bookmobileStop'];
                     }
                     if (isset($_REQUEST['illItem'])) {
                         $materialsRequest->illItem = $_REQUEST['illItem'];
                     } else {
                         $materialsRequest->illItem = 0;
                     }
                     $defaultStatus = new MaterialsRequestStatus();
                     $defaultStatus->isDefault = 1;
                     $userLibraryId = Library::getPatronHomeLibrary();
                     $defaultStatus->libraryId = $userLibraryId->libraryId;
                     if (!$defaultStatus->find(true)) {
                         $interface->assign('success', false);
                         $interface->assign('error', 'There was an error submitting your materials request, could not determine the default status.');
                     } else {
                         $materialsRequest->status = $defaultStatus->id;
                         $materialsRequest->dateCreated = time();
                         $materialsRequest->createdBy = $user->id;
                         $materialsRequest->dateUpdated = time();
                         if ($materialsRequest->insert()) {
                             $interface->assign('success', true);
                             $interface->assign('materialsRequest', $materialsRequest);
                         } else {
                             $interface->assign('success', false);
                             $interface->assign('error', 'There was an error submitting your materials request.');
                         }
                     }
                 }
             }
         }
     }
     $interface->setTemplate('submission-result.tpl');
     $interface->setPageTitle('Submission Result');
     $interface->display('layout.tpl');
 }
Exemplo n.º 12
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     $driver = new EContentDriver();
     $id = strip_tags($_REQUEST['id']);
     $interface->assign('id', $id);
     global $logger;
     //Get title information for the record.
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError("Unable to find eContent record for id: {$id}");
     }
     if (isset($_POST['submit']) || $user) {
         if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
             //Log the user in
             $user = UserAccount::login();
         }
         if (!PEAR_Singleton::isError($user) && $user) {
             //The user is already logged in
             $return = $driver->checkoutRecord($id, $user);
             $interface->assign('result', $return['result']);
             $message = $return['message'];
             $interface->assign('message', $message);
             global $logger;
             $logger->log("Result of checkout " . print_r($return, true), PEAR_LOG_DEBUG);
             $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['checkout_referrer'] = $referer;
         }
         //Showing checkout form.
         if (!PEAR_Singleton::isError($user) && $user) {
             //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');
         }
     }
     if (isset($return) && $showMessage) {
         $hold_message_data = array('successful' => $return['result'] ? 'all' : 'none', 'error' => isset($return['error']) ? $return['error'] : null, 'titles' => array($return));
         $_SESSION['checkout_message'] = $hold_message_data;
         if (isset($_SESSION['checkout_referrer'])) {
             $logger->log('Checkout Referrer is set, redirecting to there.  referrer = ' . $_SESSION['checkout_referrer'], PEAR_LOG_INFO);
             header("Location: " . $_SESSION['checkout_referrer']);
             unset($_SESSION['checkout_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 eContent page', PEAR_LOG_INFO);
             header("Location: /MyResearch/EContentCheckedOut");
         }
     } else {
         //Var for the IDCLREADER TEMPLATE
         $interface->assign('ButtonBack', true);
         $interface->assign('ButtonHome', true);
         $interface->assign('MobileTitle', 'Login to your account');
         $logger->log('eContent checkout finished, do not need to show a message', PEAR_LOG_INFO);
         $interface->setPageTitle('Checkout Item');
         $interface->assign('subTemplate', 'checkout.tpl');
         $interface->setTemplate('checkout.tpl');
         $interface->display('layout.tpl', 'RecordHold' . $_GET['id']);
     }
 }