Exemplo n.º 1
0
 /**
  * Report lists rooms in each residence hall that are still available, along with
  * the available beds in the room.  Also, show the number of beds allocated to the
  * lotter for each residence hall.
  *
  */
 public static function reappAvailability()
 {
     $term = Term::getSelectedTerm();
     // Available rooms in each residence hall.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     //$db->addWhere('hms_bed.ra_bed', 0);
     $db->addWhere('hms_room.private', 0);
     $db->addWhere('hms_room.overflow', 0);
     $db->addWhere('hms_room.reserved', 0);
     $db->addWhere('hms_room.offline', 0);
     $db->addWhere('hms_bed.term', $term);
     $db->addColumn('hms_room.room_number');
     $db->addColumn('hms_bed.bed_letter', null, null, True);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_room.room_number');
     $db->addOrder('hms_residence_hall.hall_name');
     $availRooms = $db->select();
     // Allocated beds for lottery.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addJoin('RIGHT', 'hms_bed', 'hms_lottery_reservation', 'id', 'bed_id');
     $db->addWhere('hms_lottery_reservation.term', $term);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addColumn('hms_bed.id', null, null, True);
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->setIndexBy('hall_name');
     $lotteryBeds = $db->select();
     $tpl = new PHPWS_Template('hms');
     $tpl->setFile('admin/reports/reapp_availability.tpl');
     //
     // "The parent row must be parsed after the child rows."
     // Preload currHall with first residence hall name
     $currHall = $availRooms[0]['hall_name'];
     foreach ($availRooms as $row) {
         // Change halls, create new block.
         if ($currHall != $row['hall_name'] || $currHall == null) {
             $tpl->setCurrentBlock('halls');
             // Get allocated beds for the residence hall.
             $lottCount = isset($lotteryBeds[$currHall]['count']) ? $lotteryBeds[$currHall]['count'] : 0;
             $tpl->setData(array('HALL_NAME' => $currHall, 'LOTTERY_BEDS' => $lottCount));
             $tpl->parseCurrentBlock();
             $currHall = $row['hall_name'];
         }
         // Add room to residence hall template block.
         $tpl->setCurrentBlock('rooms');
         $tpl->setData(array('ROOM_NUM' => $row['room_number'], 'BED_COUNT' => $row['count']));
         $tpl->parseCurrentBlock();
     }
     // Get last residence hall. Can't parse parent before child with template class.
     $tpl->setCurrentBlock('halls');
     $tpl->setData(array('HALL_NAME' => $currHall));
     $tpl->parseCurrentBlock();
     return $tpl->get();
 }
Exemplo n.º 2
0
 public static function processAll($term)
 {
     $db = new PHPWS_DB('hms_banner_queue');
     $db->addWhere('term', $term);
     $db->addOrder('id');
     $items = $db->getObjects('BannerQueueItem');
     $errors = array();
     foreach ($items as $item) {
         $result = null;
         try {
             $result = $item->process();
         } catch (Exception $e) {
             $error = array();
             $error['username'] = $item->asu_username;
             $error['code'] = $e->getCode();
             $error['message'] = $e->getMessage();
             $errors[] = $error;
             continue;
         }
         if ($result === TRUE) {
             $item->delete();
         }
     }
     if (empty($errors)) {
         return TRUE;
     }
     return $errors;
 }
Exemplo n.º 3
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     $term = $this->term;
     $db = new PHPWS_DB('hms_checkin');
     // Join hall structure
     $db->addJoin('', 'hms_checkin', 'hms_hall_structure', 'bed_id', 'bedid');
     $db->addColumn('hms_checkin.banner_id');
     $db->addColumn('hms_checkin.checkin_date');
     $db->addColumn('hms_hall_structure.hall_name');
     $db->addColumn('hms_hall_structure.room_number');
     $db->addWhere('hms_checkin.term', $term);
     $db->addWhere('hms_checkin.checkout_date', null, 'IS NULL');
     // Sort by hall, then room number
     $db->addOrder(array('hms_hall_structure.hall_name ASC', 'hms_hall_structure.room_number ASC'));
     $results = $db->select();
     if (PHPWS_Error::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     // Post-processing, cleanup, making it pretty
     foreach ($results as $row) {
         // Updates counts
         $this->total++;
         $row['checkin_date'] = HMS_Util::get_short_date_time($row['checkin_date']);
         // Copy the cleaned up row to the member var for data
         $this->data[] = $row;
     }
 }
Exemplo n.º 4
0
 /**
  * Executes this pulse. Checks for any pending reports and runs them.
  */
 public static function execute()
 {
     // Reschedule the next run of this process
     /*
      $sp = $this->makeClone();
      $sp->execute_at = strtotime("+1 minutes");
      $sp->save();
     * 
     */
     // Load necessary classes
     PHPWS_Core::initModClass('hms', 'UserStatus.php');
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     PHPWS_Core::initModCLass('hms', 'HMS_Email.php');
     // Fake a user, in case we need that
     UserStatus::wearMask('HMS System');
     // Check for any pending reports (scheduled for any time up until now)
     $db = new PHPWS_DB('hms_report');
     $db->addWhere('completed_timestamp', null, 'IS');
     // not completed
     $db->addWhere('began_timestamp', null, 'IS');
     // not already running somewhere
     $db->addWhere('scheduled_exec_time', time(), '<=');
     // scheduled exec time is now or before
     $db->addOrder('scheduled_exec_time ASC');
     // Run in order scheduled
     $results = $db->select();
     // If there's nothing to do, quite nicely
     if (!isset($results) || is_null($results) || empty($results)) {
         UserStatus::removeMask();
         return 'No reports waiting.';
     }
     // Run each report
     foreach ($results as $row) {
         $report = null;
         try {
             // Load the proper controller for this report
             $reportCtrl = ReportFactory::getControllerById($row['id']);
             // Load this report's params
             $reportCtrl->loadParams();
             // Generate the report
             $reportCtrl->generateReport();
             $report = $reportCtrl->getReport();
         } catch (Exception $e) {
             // handle the exception nicely
             self::emailError(self::formatException($e));
             exit;
         }
         // Send success notification
         $username = $report->getCreatedBy();
         if ($username == 'jbooker') {
             $username = '******';
         }
         HMS_Email::sendReportCompleteNotification($username, $report->getFriendlyName());
     }
     // Remove the mask
     UserStatus::removeMask();
     // Exit cleanly
     return;
 }
 public static function getChangesForInternship(Internship $internship)
 {
     $db = new \PHPWS_DB('intern_change_history');
     $db->addWhere('internship_id', $internship->getId());
     $db->addOrder('timestamp ASC');
     $results = $db->getObjects('\\Intern\\ChangeHistory');
     if (\PHPWS_Error::logIfError($results)) {
         throw new \Exception($results->toString());
     }
     return $results;
 }
 public static function getChangesForInternship(Internship $internship)
 {
     PHPWS_Core::initModClass('intern', 'ChangeHistory.php');
     $db = new PHPWS_DB('intern_change_history');
     $db->addWhere('internship_id', $internship->getId());
     $db->addOrder('timestamp ASC');
     $results = $db->getObjects('ChangeHistory');
     if (PHPWS_Error::logIfError($results)) {
         throw new Exception($results->toString());
     }
     return $results;
 }
 /**
  * initialize this object (fill the array) with assignment histories
  *
  * @param int $bannerID banner id of student
  * @param int $term term to be searching
  * @return boolean flag to signal if the initialization was a success
  */
 private function init()
 {
     $db = new PHPWS_DB('hms_assignment_history');
     $db->addWhere('banner_id', $this->bannerId);
     $db->loadClass('hms', 'AssignmentHistory.php');
     $db->addOrder(array('term DESC', 'assigned_on DESC'));
     $result = $db->getObjects('AssignmentHistory');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     if (isset($result)) {
         $this->assignmentHistory = $result;
     }
     return true;
 }
Exemplo n.º 8
0
 private function getHallList()
 {
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addColumn('id');
     $db->addColumn('hall_name');
     $db->addWhere('term', $this->term);
     $db->addWhere('is_online', 1);
     // only get halls that are online
     $db->addOrder('hall_name', 'asc');
     $result = $db->select();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return $result;
 }
Exemplo n.º 9
0
 public static function getSubjects($mustIncludeId = null)
 {
     $subjects = array('-1' => 'Select a subject...');
     $db = new PHPWS_DB('intern_subject');
     $db->addWhere('active', 1, '=', 'OR');
     if (!is_null($mustIncludeId)) {
         $db->addWhere('id', $mustIncludeId, '=', 'OR');
     }
     $db->addOrder('abbreviation ASC');
     $results = $db->select();
     foreach ($results as $row) {
         $subjects[$row['id']] = $row['abbreviation'] . ' - ' . $row['description'];
     }
     return $subjects;
 }
Exemplo n.º 10
0
 public static function getAllowedStates()
 {
     $db = new \PHPWS_DB('intern_state');
     $db->addWhere('active', 1);
     $db->addColumn('abbr');
     $db->addColumn('full_name');
     $db->setIndexBy('abbr');
     $db->addOrder('full_name ASC');
     $states = $db->select('col');
     if (empty($states)) {
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
         \NQ::close();
         PHPWS_Core::goBack();
     }
     return $states;
 }
Exemplo n.º 11
0
 public static function display()
 {
     javascriptMod('intern', 'pick_state');
     $db = new PHPWS_DB('intern_state');
     $db->addOrder('full_name');
     $states = $db->select();
     foreach ($states as $state) {
         extract($state);
         //abbr, full_name, active
         $row = array('ABBR' => $abbr, 'NAME' => $full_name);
         if (!$active) {
             $tpl['state_row'][] = $row;
         } else {
             $tpl['active_row'][] = $row;
         }
     }
     return PHPWS_Template::process($tpl, 'intern', 'state_list.tpl');
 }
Exemplo n.º 12
0
 /**
  * Returns an associative array containing the list of RLCs using their full names, keyed by their id.
  *
  * @param int $term
  * @param string $studentType
  * @param string $hidden
  * @throws DatabaseException
  * @return Array Array of communities
  */
 public static function getRlcList($term, $studentType = NULL, $hidden = NULL)
 {
     $db = new PHPWS_DB('hms_learning_communities');
     $db->addColumn('id');
     $db->addColumn('community_name');
     if (!is_null($studentType) && strlen($studentType) == 1) {
         $db->addWhere('allowed_student_types', "%{$student_type}%", 'ilike');
     }
     if ($hidden === FALSE) {
         $db->addWhere('hide', 0);
     }
     $db->addOrder('community_name ASC');
     $rlcs = $db->select('assoc');
     if (PHPWS_Error::logIfError($rlcs)) {
         throw new DatabaseException($rlcs->toString());
     }
     return $rlcs;
 }
Exemplo n.º 13
0
 public function execute()
 {
     if (!isset($this->term) || is_null($this->term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     /*****
      * Total Beds
      */
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addWhere('hms_bed.term', $this->term);
     $this->totalBedCount = $db->count();
     if (PHPWS_Error::logIfError($this->totalBedCount)) {
         PHPWS_Core::initModClass('hms', 'exception', 'DatabaseException.php');
         throw new DatabaseException($this->totalBedCount->toString());
     }
     /*******
      * Unavailable Beds
      */
     $db = new PHPWS_DB('hms_bed');
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addColumn('hms_bed.*');
     $db->addColumn('hms_room.*');
     $db->addJoin('', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addWhere('hms_room.reserved', 1, null, 'OR', 'foo');
     $db->addWhere('hms_room.ra', 1, null, 'OR', 'foo');
     $db->addWhere('hms_room.private', 1, null, 'OR', 'foo');
     $db->addWhere('hms_room.overflow', 1, null, 'OR', 'foo');
     $db->addWhere('hms_room.parlor', 1, null, 'OR', 'foo');
     $db->addWhere('hms_room.offline', 1, null, 'OR', 'foo');
     $db->addWhere('hms_bed.ra_roommate', 1, null, 'OR', 'foo');
     $db->addWhere('hms_bed.international_reserved', 1, null, 'OR', 'foo');
     $db->addWhere('hms_bed.term', $this->term);
     $db->addOrder(array('hms_residence_hall.hall_name', 'hms_room.room_number', 'bed_letter'));
     $this->unavailableBeds = $db->select();
     if (PHPWS_Error::logIfError($this->unavailableBeds)) {
         PHPWS_Core::initModClass('hms', 'exception/DatabaseException.php');
         throw new DatabaseException($this->unavailableBeds->toString());
     }
 }
Exemplo n.º 14
0
 public static function getAllowedStates()
 {
     $db = new PHPWS_DB('intern_state');
     $db->addWhere('active', 1);
     $db->addColumn('abbr');
     $db->addColumn('full_name');
     $db->setIndexBy('abbr');
     // get backwards because we flip it
     $db->addOrder('full_name desc');
     $states = $db->select('col');
     if (empty($states)) {
         NQ::simple('intern', INTERN_ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
         NQ::close();
         PHPWS_Core::goBack();
     }
     $states[-1] = 'Select a state';
     $states = array_reverse($states, true);
     return $states;
 }
Exemplo n.º 15
0
 public function loadPeeps($registered = true)
 {
     PHPWS_Core::initModClass('signup', 'Peeps.php');
     $db = new PHPWS_DB('signup_peeps');
     $db->addWhere('slot_id', $this->id);
     if ($registered) {
         $db->addWhere('registered', 1);
     } else {
         $db->addWhere('registered', 0);
     }
     $db->addOrder('last_name');
     $peeps = $db->getObjects('Signup_Peep');
     if (PHPWS_Error::logIfError($peeps)) {
         return false;
     } else {
         $this->_peeps =& $peeps;
         return true;
     }
 }
 /**
  * Returns an array of EmergencyContact objects for the given Internship.
  *
  * @param Internship $i
  * @return Array<EmergencyContact> Array of EmergencyContact objects for the given Internship, or an empty array if none exist.
  * @throws InvalidArgumentException
  * @throws Exception
  * @see EmergencyContactDB
  */
 public static function getContactsForInternship(Internship $i)
 {
     $internshipId = $i->getId();
     if (is_null($internshipId) || !isset($internshipId)) {
         throw new \InvalidArgumentException('Internship ID is required.');
     }
     $db = new \PHPWS_DB('intern_emergency_contact');
     $db->addWhere('internship_id', $internshipId);
     $db->addOrder('id ASC');
     // Get them in order of ID, so earliest contacts come first
     $result = $db->getObjects('Intern\\EmergencyContactDB');
     if (\PHPWS_Error::logIfError($result)) {
         throw new \Exception($result->toString());
     }
     if (sizeof($result) <= 0) {
         return array();
         // Return an empty array
     }
     return $result;
 }
Exemplo n.º 17
0
 /**
  * Returns an array of HMS_Residence_Hall objects for the given term.
  *
  * @param integer $term
  * @throws InvalidArgumentException
  * @throws DatabaseException
  * @return multitype:HMS_Residence_Hall
  */
 public static function getHallsForTerm($term)
 {
     if (!isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $halls = array();
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addColumn('id');
     $db->addOrder('hall_name', 'DESC');
     $db->addWhere('term', $term);
     $results = $db->select();
     if (PHPWS_Error::logIfError($results)) {
         throw new DatabaseException($result->toString());
     }
     //TODO this is terribly inefficient
     foreach ($results as $result) {
         $halls[] = new HMS_Residence_Hall($result['id']);
     }
     return $halls;
 }
Exemplo n.º 18
0
 public static function get_movein_times_array($term = NULL)
 {
     if (!isset($term)) {
         PHPWS_Core::initModClass('hms', 'Term.php');
         $term = Term::getSelectedTerm();
     }
     $db = new PHPWS_DB('hms_movein_time');
     $db->addWhere('term', $term);
     $db->addOrder('begin_timestamp', 'ASC');
     $result = $db->getObjects('HMS_Movein_Time');
     if (PEAR::isError($result)) {
         return false;
     }
     $timestamps = array();
     $timestamps[0] = 'None';
     if (!empty($result)) {
         foreach ($result as $movein) {
             $timestamps[$movein->id] = $movein->get_formatted_begin_end();
         }
     }
     return $timestamps;
 }
Exemplo n.º 19
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'SpringApplication.php');
     PHPWS_Core::initModClass('hms', 'SummerApplication.php');
     PHPWS_Core::initModClass('hms', 'FallApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $term = $this->term;
     $sem = Term::getTermSem($term);
     // List of student 'application terms' which we'll consider as 'Freshmen' for term we're looking at
     // E.g. Students with an applicationt erm in Summer 1, Summer 2, and Fall all count as Freshmen for Fall.
     $applicationTerms = array();
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('hms_new_application.banner_id');
     $db->addColumn('hms_new_application.username');
     $db->addColumn('hms_new_application.term');
     $db->addColumn('hms_new_application.gender');
     $db->addColumn('hms_new_application.application_term');
     $db->addColumn('hms_new_application.student_type');
     $db->addColumn('hms_new_application.cell_phone');
     $db->addColumn('hms_new_application.meal_plan');
     $db->addColumn('hms_new_application.physical_disability');
     $db->addColumn('hms_new_application.psych_disability');
     $db->addColumn('hms_new_application.medical_need');
     $db->addColumn('hms_new_application.gender_need');
     $db->addColumn('hms_new_application.international');
     $db->addColumn('hms_new_application.created_on');
     // Join for additional application data based on semester
     switch ($sem) {
         case TERM_SUMMER1:
         case TERM_SUMMER2:
             $db->addJoin('', 'hms_new_application', 'hms_summer_application', 'id', 'id');
             $db->addColumn('hms_summer_application.*');
             $applicationTerms[] = $term;
             $db->addWhere('application_type', 'summer');
             break;
         case TERM_FALL:
             $db->addJoin('', 'hms_new_application', 'hms_fall_application', 'id', 'id');
             $db->addColumn('hms_fall_application.*');
             // Add the summer 1 and summe 2 application terms
             $summer2 = Term::getPrevTerm($term);
             $summer1 = Term::getPrevTerm($summer2);
             $applicationTerms[] = $summer1;
             $applicationTerms[] = $summer2;
             $applicationTerms[] = $term;
             $db->addWhere('application_type', 'fall');
             break;
         case TERM_SPRING:
             $db->addJoin('', 'hms_new_application', 'hms_spring_application', 'id', 'id');
             $db->addColumn('hms_spring_application.*');
             $applicationTerms[] = $term;
             $db->addWhere('application_type', 'spring');
             break;
         default:
             // error
             throw new InvalidArgumentException('Invalid term specified.');
     }
     // Join for un-assigned students
     $db->addJoin('LEFT OUTER', 'hms_new_application', 'hms_assignment', 'banner_id', 'banner_id AND hms_new_application.term = hms_assignment.term');
     $db->addWhere('hms_assignment.banner_id', 'NULL');
     $db->addWhere('hms_new_application.term', $term);
     $db->addWhere('hms_new_application.student_type', 'F');
     // Don't show students who have cancelled applications
     $db->addWhere('hms_new_application.cancelled', 0);
     // Limit by application term
     foreach ($applicationTerms as $t) {
         $db->addWhere('application_term', $t, '=', 'OR', 'app_term_group');
     }
     // Sort by gender, then application date (earliest to latest)
     $db->addOrder(array('gender ASC', 'created_on ASC'));
     $results = $db->select();
     if (PHPWS_Error::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     // Post-processing, cleanup, making it pretty
     foreach ($results as $row) {
         // Updates counts
         $this->total++;
         if ($row['gender'] == MALE) {
             $this->male++;
         } else {
             if ($row['gender'] == FEMALE) {
                 $this->female++;
             }
         }
         $row['application_term'] = Term::toString($row['application_term']);
         $row['gender'] = HMS_Util::formatGender($row['gender']);
         $row['created_on'] = HMS_Util::get_short_date_time($row['created_on']);
         $row['meal_plan'] = HMS_Util::formatMealOption($row['meal_plan']);
         $row['lifestyle_option'] = HMS_Util::formatLifestyle($row['lifestyle_option']);
         $row['room_condition'] = HMS_Util::formatRoomCondition($row['room_condition']);
         $row['preferred_bedtime'] = HMS_Util::formatBedtime($row['preferred_bedtime']);
         // Roommates
         $roommie = HMS_Roommate::get_confirmed_roommate($row['username'], $this->term);
         if (!is_null($roommie)) {
             $row['roommate'] = $roommie->getUsername();
             $row['roommate_banner_id'] = $roommie->getBannerId();
         }
         // Copy the cleaned up row to the member var for data
         $this->data[] = $row;
     }
 }
Exemplo n.º 20
0
 /**
  * View of files in current folder
  */
 public function folderContentView()
 {
     javascript('jquery');
     PHPWS_Core::initModClass('filecabinet', 'Image.php');
     javascript('confirm');
     // needed for deletion
     Layout::addStyle('filecabinet');
     if (empty($this->current_folder) || empty($this->folder_type)) {
         javascript('alert', array('content' => dgettext('filecabinet', 'Problem with opening browser page. Closing File Manager window.')));
         javascript('close_refresh', array('timeout' => 3, 'refresh' => 0));
         return;
     }
     $tpl = array();
     $this->folderIcons($tpl);
     if (Current_User::allow('filecabinet', 'edit_folders')) {
         $tpl['FOLDER_TITLE'] = $this->current_folder->editLink('title', $this->current_folder->module_created);
     } else {
         $tpl['FOLDER_TITLE'] =& $this->current_folder->title;
     }
     $img_dir = PHPWS_SOURCE_HTTP . 'mod/filecabinet/img/file_manager/';
     $image_string = '<img src="%s" title="%s" alt="%s" />';
     $link_info = $this->linkInfo();
     switch ($this->folder_type) {
         case IMAGE_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize image.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This image is larger than the %s x %s limit. Do you want to resize the image to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             $db = new PHPWS_DB('images');
             $class_name = 'PHPWS_Image';
             $file_type = FC_IMAGE;
             $altvars = $link_info;
             // check
             unset($altvars['mw']);
             unset($altvars['mh']);
             unset($altvars['fr']);
             $img1 = 'folder_random.png';
             $img2 = 'thumbnails.png';
             $img3 = 'lightbox.png';
             $img1_alt = dgettext('filecabinet', 'Random image icon');
             $img2_alt = dgettext('filecabinet', 'Thumbnail icon');
             $img3_alt = dgettext('filecabinet', 'Lightbox icon');
             if (!$this->reserved_folder) {
                 if ($this->current_folder->public_folder) {
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_IMAGE_RANDOM;
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     if (!$this->lock_type || in_array(FC_IMAGE_RANDOM, $this->lock_type)) {
                         $img1_title = dgettext('filecabinet', 'Show a random image from this folder');
                         $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                         $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                         if ($this->file_assoc->file_type == FC_IMAGE_RANDOM && $this->current_folder->id == $this->file_assoc->file_id) {
                             $tpl['ALT_HIGH1'] = ' alt-high';
                         }
                     } else {
                         $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                         $tpl['ALT1'] = $image1;
                         $tpl['ALT_HIGH1'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_FOLDER, $this->lock_type)) {
                         /** start new * */
                         if ($this->file_assoc->file_type == FC_IMAGE_FOLDER) {
                             $tpl['ALT_HIGH2'] = ' alt-high';
                         }
                         $img2_title = dgettext('filecabinet', 'Show block of thumbnails');
                         $image2 = sprintf($image_string, $img_dir . $img2, $img2_title, $img2_alt);
                         $form = new PHPWS_Form('carousel-options');
                         $form->setMethod('get');
                         $altvars['file_type'] = FC_IMAGE_FOLDER;
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8);
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Carousel direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return carousel_pick();">%s</a>', $image2);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT2'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/carousel_pick.tpl');
                     } else {
                         $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                         $tpl['ALT2'] = $image2;
                         $tpl['ALT_HIGH2'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_LIGHTBOX, $this->lock_type)) {
                         /** start VV * */
                         if ($this->file_assoc->file_type == FC_IMAGE_LIGHTBOX) {
                             $tpl['ALT_HIGH3'] = ' alt-high';
                         }
                         $img3_title = dgettext('filecabinet', 'Show lightbox slideshow');
                         $image3 = sprintf($image_string, $img_dir . $img3, $img3_title, $img3_alt);
                         $altvars['file_type'] = FC_IMAGE_LIGHTBOX;
                         $form = new PHPWS_Form('lightbox-options');
                         $form->setMethod('get');
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(3 => 3, 6 => 6, 9 => 9, 12 => 12, 15 => 15, 18 => 18, 21 => 21, 99 => 'unlimited');
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Thumbnail direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return lightbox_pick();">%s</a>', $image3);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT3'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/lightbox_pick.tpl');
                     } else {
                         $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                         $tpl['ALT3'] = $image3;
                         $tpl['ALT_HIGH3'] = ' no-use';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                     $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                     $tpl['ALT2'] = $image2;
                     $tpl['ALT_HIGH2'] = ' no-use';
                     $tpl['ALT3'] = $image3;
                     $tpl['ALT_HIGH3'] = ' no-use';
                 }
             }
             break;
         case DOCUMENT_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Document.php');
             $db = new PHPWS_DB('documents');
             $class_name = 'PHPWS_Document';
             $file_type = FC_DOCUMENT;
             $img1 = 'all_files.png';
             $img1_alt = dgettext('filecabinet', 'All files icon');
             if ($this->current_folder->public_folder) {
                 if (!$this->lock_type || in_array(FC_DOCUMENT_FOLDER, $this->lock_type)) {
                     $altvars = $link_info;
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_DOCUMENT_FOLDER;
                     $img1_title = dgettext('filecabinet', 'Show all files in the folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                     $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                     if ($this->file_assoc->file_type == FC_DOCUMENT_FOLDER && $this->current_folder->id == $this->file_assoc->file_id) {
                         $tpl['ALT_HIGH1'] = ' alt-high';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                 }
             } else {
                 $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                 $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                 $tpl['ALT1'] = $image1;
                 $tpl['ALT_HIGH1'] = ' no-use';
             }
             break;
         case MULTIMEDIA_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize media.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This media is larger than the %s x %s limit. Do you want to resize the media to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
             $db = new PHPWS_DB('multimedia');
             $class_name = 'PHPWS_Multimedia';
             $file_type = FC_MEDIA;
             //$tpl['ADD_EMBED'] = $this->current_folder->embedLink(true);
             break;
     }
     $db->addWhere('folder_id', $this->current_folder->id);
     $db->addOrder('title');
     $items = $db->getObjects($class_name);
     if ($items) {
         foreach ($items as $item) {
             $stpl = $item->managerTpl($this);
             $tpl['items'][] = $stpl;
         }
     } else {
         $not_allowed = dgettext('filecabinet', 'No files in folder');
         if (isset($tpl['ALT1'])) {
             $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
             $tpl['ALT1'] = $image1;
             $tpl['ALT_HIGH1'] = ' no-use';
         }
         if (isset($tpl['ALT2'])) {
             $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
             $tpl['ALT2'] = $image2;
             $tpl['ALT_HIGH2'] = ' no-use';
         }
     }
     if (Current_User::allow('filecabinet', 'edit_folders', $this->current_folder->id, 'folder')) {
         if ($this->force_upload_dimensions) {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true, $this->max_width, $this->max_height);
         } else {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true);
         }
     }
     $tpl['CLOSE'] = javascript('close_window');
     return PHPWS_Template::process($tpl, 'filecabinet', 'file_manager/folder_content_view.tpl');
 }
Exemplo n.º 21
0
 /**
  * Gets random page from the database
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function random()
 {
     $db = new PHPWS_DB('wiki_pages');
     $db->addOrder('random');
     $db->setLimit(1);
     $db->addColumn('title');
     $result = $db->select('col');
     if (!PHPWS_Error::logIfError($result) && $result != NULL) {
         PHPWS_Core::reroute(PHPWS_Text::linkAddress('wiki', array('page' => $result[0])));
     }
     PHPWS_Core::reroute(PHPWS_Text::linkAddress('wiki'));
 }
Exemplo n.º 22
0
 public static function getLastCheckoutForStudent(Student $student)
 {
     $db = new PHPWS_DB('hms_checkin');
     $db->addWhere('banner_id', $student->getBannerId());
     $db->addWhere('checkout_date', null, '!=');
     $db->addOrder(array('term DESC', 'checkout_date DESC'));
     $result = $db->getObjects('RestoredCheckin');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     if (sizeof($result) <= 0) {
         return array();
     }
     return array_shift($result);
 }
Exemplo n.º 23
0
 public function getResizeIds($image)
 {
     $db = new PHPWS_DB('fc_file_assoc');
     $db->addOrder('width');
     $db->addWhere('file_id', $image->id);
     $db->addWhere('file_type', 7, null, null, 'x');
     $db->addWhere('file_type', 9, null, 'or', 'x');
     $db->addColumn('id');
     return $db->select('col');
 }
Exemplo n.º 24
0
 public static function channels()
 {
     PHPWS_Core::initModClass('rss', 'Channel.php');
     $final_tpl['TITLE'] = dgettext('rss', 'Administrate RSS Feeds');
     $db = new PHPWS_DB('rss_channel');
     $db->addOrder('title');
     $channels = $db->getObjects('RSS_Channel');
     if (empty($channels)) {
         $final_tpl['CONTENT'] = dgettext('rss', 'No channels have been registered.');
         return $final_tpl;
     } elseif (PHPWS_Error::isError($channels)) {
         PHPWS_Error::log($channels);
         $final_tpl['CONTENT'] = dgettext('rss', 'An error occurred when trying to access your RSS channels.');
         return $final_tpl;
     }
     foreach ($channels as $oChannel) {
         $row['TITLE'] = $oChannel->getTitle();
         $row['ACTION'] = implode(' | ', $oChannel->getActionLinks());
         if ($oChannel->active) {
             $row['ACTIVE'] = dgettext('rss', 'Yes');
         } else {
             $row['ACTIVE'] = dgettext('rss', 'No');
         }
         $tpl['channels'][] = $row;
     }
     $tpl['TITLE_LABEL'] = dgettext('rss', 'Title');
     $tpl['ACTIVE_LABEL'] = dgettext('rss', 'Active');
     $tpl['ACTION_LABEL'] = dgettext('rss', 'Action');
     $final_tpl['CONTENT'] = PHPWS_Template::process($tpl, 'rss', 'channel_list.tpl');
     return $final_tpl;
 }
Exemplo n.º 25
0
 public function loadFeeds()
 {
     $db = new PHPWS_DB('phpws_key');
     $db->addWhere('module', $this->module);
     $db->addWhere('active', 1);
     $db->addWhere('restricted', 0);
     $db->addWhere('show_after', time(), '<');
     $db->addWhere('hide_after', time(), '>');
     $db->addOrder('create_date desc');
     // rss limit is 15
     $db->setLimit('15');
     $result = $db->getObjects('Key');
     if (PHPWS_Error::isError($result)) {
         $this->_feeds = NULL;
         $this->_error = $result;
         return $result;
     } else {
         $this->_feeds = $result;
         return TRUE;
     }
 }
Exemplo n.º 26
0
 /**
  * Pulls all the rooms associated with this floor and stores
  * them in the _room variable.
  */
 public function loadRooms()
 {
     $db = new PHPWS_DB('hms_room');
     $db->addWhere('floor_id', $this->id);
     $db->addOrder('room_number', 'ASC');
     $db->loadClass('hms', 'HMS_Room.php');
     $result = $db->getObjects('HMS_Room');
     //test($result);
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     } else {
         $this->_rooms =& $result;
         return true;
     }
 }
Exemplo n.º 27
0
 public function getPhotos()
 {
     $db = new \PHPWS_DB('prop_photo');
     $db->addColumn('path');
     $db->addColumn('title');
     $db->addWhere('pid', $this->id);
     $db->addOrder('main_pic desc');
     $photos = $db->select();
     if (empty($photos)) {
         return null;
     }
     return $photos;
 }
Exemplo n.º 28
0
 /**
  * Returns an array of IDs of free beds (which can be auto_assigned)
  * Returns FALSE if there are no more free beds
  */
 public static function get_all_free_beds($term, $gender, $randomize = FALSE, $banner = FALSE)
 {
     $db = new PHPWS_DB('hms_bed');
     if ($banner) {
         $db->addColumn('hms_bed.banner_id');
         $db->addColumn('hms_residence_hall.banner_building_code');
     }
     $db->addColumn('id');
     // Only get free beds
     $db->addJoin('LEFT OUTER', 'hms_bed', 'hms_assignment', 'id', 'bed_id');
     $db->addWhere('hms_assignment.asu_username', NULL);
     // Join other tables so we can do the other 'assignable' checks
     $db->addJoin('LEFT OUTER', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT OUTER', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT OUTER', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     // Term
     $db->addWhere('hms_bed.term', $term);
     // Gender
     $db->addWhere('hms_room.gender_type', $gender);
     // Make sure everything is online
     $db->addWhere('hms_room.offline', 0);
     $db->addWhere('hms_floor.is_online', 1);
     $db->addWhere('hms_residence_hall.is_online', 1);
     // Make sure nothing is reserved
     $db->addWhere('hms_room.reserved', 0);
     // $db->addWhere('hms_room.is_medical', 0);
     // Don't get RA beds
     $db->addWhere('hms_room.ra', 0);
     // Don't get lobbies
     $db->addWhere('hms_room.overflow', 0);
     // Don't get private rooms
     $db->addWhere('hms_room.private', 0);
     // Don't get rooms on floors reserved for an RLC
     $db->addWhere('hms_floor.rlc_id', NULL);
     // Randomize if necessary
     if ($randomize) {
         $db->addOrder('random');
     }
     // $db->setTestMode();
     if ($banner) {
         $result = $db->select();
         if (PHPWS_Error::logIfError($result)) {
             throw new DatabaseException($result->toString());
         }
         return $result;
     }
     $result = $db->select('col');
     // In case of an error, log it and return it
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     // Return FALSE if there were no results
     if (sizeof($result) <= 0) {
         return FALSE;
     }
     return $result;
 }
Exemplo n.º 29
0
 public function reorderBoxes($theme, $themeVar)
 {
     $db = new PHPWS_DB('layout_box');
     $db->addWhere('theme', $theme);
     $db->addWhere('theme_var', $themeVar);
     $db->addOrder('box_order');
     $boxes = $db->getObjects('Layout_Box');
     if (!isset($boxes)) {
         return;
     }
     $count = 1;
     foreach ($boxes as $box) {
         $box->setBoxOrder($count);
         $box->save();
         $count++;
     }
 }
Exemplo n.º 30
0
 public function modulesInUse()
 {
     $db = new PHPWS_DB('phpws_key');
     $db->addColumn('module');
     $db->addColumn('modules.proper_name');
     $db->addWhere('module', 'modules.title');
     $db->addOrder('phpws_key.module');
     $db->setIndexBy('module');
     $db->setDistinct(true);
     return $db->select('col');
 }