コード例 #1
0
 function perform()
 {
     // don't lose the db!
     $db = $_REQUEST['db'];
     // PatronTypeAddAction
     $patron_type = $_POST['new_option'];
     $parent_pk = $_POST['parent_pk'];
     $description = $_POST['description'];
     $examples = $_POST['examples'];
     $ptf = new PatronTypeFinder($db);
     $new_option = $ptf->addPatronType($patron_type, $parent_pk, $description, $examples);
     $short_name = $_POST['library'];
     $lib_f = new LibraryFinder($db);
     $library = $lib_f->getLibraryByName($short_name);
     $laa = new LibraryAdminAction();
     $result = $laa->perform();
     $result['library_id'] = $library['library_id'];
     $result['library'] = $library['short_name'];
     $result['full_name'] = $library['full_name'];
     return $result;
 }
コード例 #2
0
 function perform()
 {
     // don't lose the db!
     $db = $_REQUEST['db'];
     if (isset($_POST['all'])) {
         $patron_type_id = $_POST['all'];
     } else {
         $patron_type_id = $_POST['visible'];
     }
     $short_name = $_POST['library'];
     $lib_f = new LibraryFinder($db);
     $library = $lib_f->getLibraryByName($short_name);
     $library_id = $library['library_id'];
     $ptf = new PatronTypeFinder($db);
     if (isset($_POST['add'])) {
         $add = $ptf->addBridgeItem($patron_type_id, $library_id);
     } elseif (isset($_POST['remove'])) {
         $remove = $ptf->removeBridgeItem($patron_type_id, $library_id);
     } elseif (isset($_POST['up'])) {
         $patron_type_id = $_POST['visible'];
         $up = $ptf->moveBridgeItemUp($patron_type_id, $library_id);
     } elseif (isset($_POST['down'])) {
         $patron_type_id = $_POST['visible'];
         $down = $ptf->moveBridgeItemDown($patron_type_id, $library_id);
     }
     $loa = new LibraryAdminFormAction();
     $result = $loa->perform();
     $_REQUEST['library_id'] = $library['library_id'];
     $_REQUEST['library'] = $library['short_name'];
     $_REQUEST['full_name'] = $library['full_name'];
     $_REQUEST['parent_table'] = 'patron_types';
     $_REQUEST['locationList'] = $ptf->findByLibraryID($library['library_id']);
     return $result;
 }
コード例 #3
0
 function perform()
 {
     $layout = grwd('layout', 'menus');
     $optionFunctions = array('pulldown' => 'getSelectPulldown', 'radio' => 'getRadioList', 'menus' => 'getSelectBox');
     $optionFunction = $optionFunctions[$layout];
     // Ensure we have the variable questionId
     $questionId = grwd('questionId', -1) + 0;
     $db = $_REQUEST['db'];
     $tsf = new TimeSpentFinder($db);
     $ptf = new PatronTypeFinder($db);
     $qff = new QuestionFormatFinder($db);
     $qtf = new QuestionTypeFinder($db);
     $if = new InitialsFinder($db);
     $lf = new LocationFinder($db);
     $userFinder = new UserFinder($db);
     $user = $userFinder->findById($_SESSION['userId']);
     if ($questionId != -1) {
         // to the edit form!
         $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Edit Question', 'content' => 'content/questionEditForm.php');
         $result['optionFunction'] = $optionFunction;
         $libId = $user['library_id'];
         $result['timeSpentOpts'] = $tsf->findByLibrary($libId);
         $result['patronTypeOpts'] = $ptf->findByLibrary($libId);
         $result['questionTypeOpts'] = $qtf->findByLibrary($libId);
         $result['questionFormatOpts'] = $qff->findByLibrary($libId);
         $result['locationOpts'] = $lf->findByLibrary($libId);
         $result['locationId'] = $lf->getLastLocationId($_SERVER['REMOTE_ADDR'], $libId);
         $result['user'] = $user;
         $questionFinder = new QuestionFinder($db);
         $result['question'] = $questionFinder->getQuestion($questionId);
         $result['answer'] = $questionFinder->getQuestion($questionId);
         $result['delete_hide'] = gpwd('delete_hide');
         $result['origin'] = grwd('origin', 'questionAddForm.do');
     } else {
         echo "QuestionID {$questionId} not found";
         // Send somewere else
     }
     return $result;
 }
コード例 #4
0
 function perform()
 {
     $times = array();
     $start = 0;
     $end = 0;
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Add Question', 'content' => 'content/questionAddForm.php');
     // The number of questions and page offset we want
     $count = grwd('count', 50);
     $page = grwd('page', 1);
     $result['count'] = $count;
     $result['page'] = $page;
     // Learn what kind of menus we need
     $layout = grwd('layout', 'menus');
     $optionFunction = array('pulldown' => 'getSelectPulldown', 'radio' => 'getRadioList', 'menus' => 'getSelectBox');
     $result['optionFunction'] = $optionFunction[$layout];
     $db = $_REQUEST['db'];
     $tsf = new TimeSpentFinder($db);
     $ptf = new PatronTypeFinder($db);
     $qff = new QuestionFormatFinder($db);
     $qtf = new QuestionTypeFinder($db);
     $if = new InitialsFinder($db);
     $lf = new LocationFinder($db);
     $userFinder = new UserFinder($db);
     $start = mTimeFloat();
     $user = $userFinder->findById($_SESSION['userId']);
     $end = mTimeFloat();
     $times['userfind'] = $end - $start;
     $clientIp = getRemoteIp();
     $libId = $user['library_id'];
     $start = mTimeFloat();
     $result['timeSpentOpts'] = $tsf->findByLibrary($libId);
     $result['patronTypeOpts'] = $ptf->findByLibrary($libId);
     $result['questionTypeOpts'] = $qtf->findByLibrary($libId);
     $result['questionFormatOpts'] = $qff->findByLibrary($libId);
     $result['locationOpts'] = $lf->findByLibrary($libId);
     $times['menus'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     // Load the default (last used) values for this client
     $result['locationId'] = $lf->getLastLocationId($clientIp, $libId);
     if ($result['locationId'] == null) {
         $result['locationId'] = $result['locationOpts'][0]['location_id'];
     }
     $start = mTimeFloat();
     $result['lastInitials'] = $if->getLastInitials($clientIp);
     $times['lastInitials'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastTimeSpent'] = $tsf->getLast($clientIp);
     $times['lastTimeSpent'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastPatronType'] = $ptf->getLast($clientIp);
     $times['lastPatronType'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastQuestionType'] = $qtf->getLast($clientIp);
     $times['lastQuestionType'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastQuestionFormat'] = $qff->getLast($clientIp);
     $times['lastQuestionFormat'] = mTimeFloat() - $start;
     $result['user'] = $user;
     $questionFinder = new QuestionFinder($db);
     $start = mTimeFloat();
     $result['lastAdded'] = $questionFinder->getLastQuestionTime($clientIp, $libId);
     if ($result['lastAdded'] != null) {
         $result['lastAdded'] = date('n/d g:i A', strtotime($result['lastAdded']));
     }
     $times['lastAdded'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $qResult = $questionFinder->getPagedList($count, $page, 'questions.library_id = ?', array((int) $libId));
     $result['questionList'] =& $qResult['list'];
     $result['list_meta'] = $qResult['meta'];
     $result['questionCount'] = $qResult['meta']['totalQuestions'];
     $result['nonemptyQuestionCount'] = $qResult['meta']['nonemptyQuestions'];
     $times['getQuestions'] = mTimeFloat() - $start;
     $origin = "questionAddForm.do?page=" . $result['page'] . "&count=" . $result['count'];
     $result['origin'] = $origin;
     $result['target'] = 'questionAddForm.do';
     // Disabled debugging output
     // echo "<!-- ";
     // var_dump($times);
     // echo " -->";
     return $result;
 }