Beispiel #1
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');
 }
Beispiel #2
0
 /**
  * Returns the menu link objects associated to a menu
  */
 public function getLinks($parent = 0, $active_only = TRUE)
 {
     if (!$this->id) {
         return NULL;
     }
     // Get all records for this menu
     $db = new PHPWS_DB('menu_links');
     $db->setDistinct();
     $db->addWhere('menu_id', $this->id, NULL, NULL, 1);
     Key::restrictView($db);
     $db->addOrder('link_order');
     $db->setIndexBy('id');
     $data = $db->getObjects('Menu_Link');
     if (empty($data) || PHPWS_Error::logIfError($data)) {
         return NULL;
     }
     $final = $this->formLink($data);
     $GLOBALS['MENU_LINKS'][$this->id] = $final;
     return $final;
 }
Beispiel #3
0
 public function getAllSlots($bare = false, $search = null)
 {
     PHPWS_Core::initModClass('signup', 'Slots.php');
     $db = new PHPWS_DB('signup_slots');
     $db->addOrder('s_order');
     $db->addWhere('sheet_id', $this->id);
     $db->setDistinct('true');
     // Prevents a slot from showing up multiple times in the results
     if ($search) {
         $db->addWhere('id', 'signup_peeps.slot_id');
         // Limits results to only Slots containing the search query
         $db->addWhere('signup_peeps.sheet_id', $this->id);
         $db->addWhere('signup_peeps.first_name', "{$search}%", 'like', 'and', 'search');
         $db->addWhere('signup_peeps.last_name', "{$search}%", 'like', 'or', 'search');
     }
     if ($bare) {
         $db->addColumn('id');
         $db->addColumn('title');
         $db->setIndexBy('id');
         return $db->select('col');
     } else {
         $result = $db->getObjects('Signup_Slot');
         if (empty($result) || PHPWS_Error::logIfError($result)) {
             return null;
         }
         $db = new PHPWS_DB('signup_peeps');
         $db->addColumn('id', null, null, true);
         foreach ($result as $slot) {
             $db->addWhere('slot_id', $slot->id);
             $db->addWhere('registered', 1);
             $sub = $db->select('one');
             $db->resetWhere();
             if (!PHPWS_Error::logIfError($sub)) {
                 $slot->_filled = $sub;
             }
         }
     }
     return $result;
 }
Beispiel #4
0
 public static function getAllFreeRooms($term)
 {
     $db = new PHPWS_DB('hms_room');
     $db->addColumn('id');
     $db->setDistinct();
     // Join other tables so we can do the other 'assignable' checks
     $db->addJoin('LEFT', 'hms_room', 'hms_bed', 'id', 'room_id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     // Term
     $db->addWhere('hms_room.term', $term);
     // Only get rooms with free beds
     $db->addJoin('LEFT OUTER', 'hms_bed', 'hms_assignment', 'id', 'bed_id');
     $db->addWhere('hms_assignment.asu_username', NULL);
     // Order by gender preference (0=>female, 1=>male, 2=>coed), rooms in a single gender hall will be first
     $db->addOrder('hms_residence_hall.gender_type ASC');
     // 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);
     // 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);
     $result = $db->select('col');
     // In case of an error, log it and return false
     if (PHPWS_Error::logIfError($result)) {
         return false;
     }
     // Make sure each room is empty and has only two beds
     $ret = array_values(array_filter($result, array('HMS_Room', 'check_two_bed_and_empty_by_id')));
     if ($randomize) {
         shuffle($ret);
     }
     return $ret;
 }