public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $messageAll = Current_User::allow('hms', 'email_all');
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addWhere('term', $term);
     $results = $db->getObjects('HMS_Residence_Hall');
     if (PHPWS_Error::logIfError($results) || is_null($results)) {
         $errorMsg = array();
         if (is_null($results)) {
             $errorMsg['error'] = 'You do not have permission to message any halls, sorry.';
         } else {
             $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page.  If the problem persists contact ESS.';
         }
         echo json_encode($errorMsg);
         exit;
     }
     $permission = new HMS_Permission();
     $data = array();
     foreach ($results as $hall) {
         $somethingEnabled = false;
         $floors = $hall->get_floors();
         unset($obj);
         $obj = new stdClass();
         $obj->name = $hall->getHallName();
         $obj->id = $hall->getId();
         $obj->floors = array();
         //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false');
         if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) {
             $obj->enabled = true;
             $somethingEnabled = true;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = true;
                 $obj->floors[] = $floor_obj;
             }
         } else {
             $obj->enabled = false;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email');
                 $obj->floors[] = $floor_obj;
                 if ($floor_obj->enabled) {
                     $somethingEnabled = true;
                 }
             }
         }
         if ($somethingEnabled) {
             $data[] = $obj;
         }
     }
     echo json_encode($data);
     exit;
 }
예제 #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;
 }
예제 #3
0
/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function calendar_uninstall(&$content)
{
    PHPWS_Core::initModClass('calendar', 'Schedule.php');
    // Need functions to remove old event tables
    $db = new PHPWS_DB('calendar_schedule');
    $schedules = $db->getObjects('Calendar_Schedule');
    if (PHPWS_Error::isError($schedules)) {
        return $schedules;
    } elseif (empty($schedules)) {
        $result = PHPWS_DB::dropTable('calendar_schedule');
        if (PHPWS_Error::isError($result)) {
            return $result;
        }
        $result = PHPWS_DB::dropTable('calendar_notice');
        if (PHPWS_Error::isError($result)) {
            return $result;
        }
        $result = PHPWS_DB::dropTable('calendar_suggestions');
        if (PHPWS_Error::isError($result)) {
            return $result;
        }
        return true;
    }
    $error = false;
    foreach ($schedules as $sch) {
        $result = $sch->delete();
        if (PHPWS_Error::isError($result)) {
            PHPWS_Error::log($result);
            $error = true;
        }
    }
    $result = PHPWS_DB::dropTable('calendar_schedule');
    if (PHPWS_Error::isError($result)) {
        return $result;
    }
    $result = PHPWS_DB::dropTable('calendar_notice');
    if (PHPWS_Error::isError($result)) {
        return $result;
    }
    $result = PHPWS_DB::dropTable('calendar_suggestions');
    if (PHPWS_Error::isError($result)) {
        return $result;
    }
    if (PHPWS_DB::isTable('converted')) {
        $db2 = new PHPWS_DB('converted');
        $db2->addWhere('convert_name', array('schedule', 'calendar'));
        $db2->delete();
        $content[] = dgettext('calendar', 'Removed convert flag.');
    }
    if (!$error) {
        $content[] = dgettext('calendar', 'Calendar tables removed.');
    } else {
        $content[] = dgettext('calendar', 'Some errors occurred when uninstalling Calendar.');
    }
    return true;
}
예제 #4
0
 public static function getAssignmentsByTermStateType($term, $state, $type)
 {
     $db = new PHPWS_DB('hms_learning_community_applications');
     $db->addColumn('hms_learning_community_applications.*');
     $db->addColumn('hms_learning_community_assignment.*');
     $db->addJoin('', 'hms_learning_community_applications', 'hms_learning_community_assignment', 'id', 'application_id');
     $db->addWhere('term', $term);
     $db->addWhere('hms_learning_community_assignment.state', $state);
     $db->addWhere('application_type', $type);
     return $db->getObjects('HMS_RLC_Assignment');
 }
 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 getForTerm($term)
 {
     $db = new PHPWS_DB('hms_application_feature');
     $db->addWhere('term', $term);
     $result = $db->getObjects('ApplicationFeature');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     // TODO: Reorg so the array is indexed by the class name.
     return $result;
 }
 public function __construct($term)
 {
     parent::__construct($term);
     $db = new PHPWS_DB('hms_special_assignment');
     $db->addWhere('term', $this->term);
     $result = $db->getObjects('SpecialAssignment');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->getMessage());
     }
     $this->specials = $result;
 }
 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;
 }
예제 #9
0
파일: RSS.php 프로젝트: HaldunA/phpwebsite
 public static function showFeeds()
 {
     PHPWS_Core::initModClass('rss', 'Feed.php');
     $db = new PHPWS_DB('rss_feeds');
     $db->addWhere('display', 1);
     $result = $db->getObjects('RSS_Feed');
     if (empty($result)) {
         return;
     }
     foreach ($result as $feed) {
         $listing[] = $feed->view();
     }
     Layout::add(implode('', $listing), 'rss', 'feeds');
 }
예제 #10
0
 /**
  * Returns the set of RoomDamage objects that were created before
  * the give timestmap.
  *
  * @param HMS_Room $room
  * @param unknown $timestamp
  * @throws DatabaseException
  * @throws InvalidArgumentException
  * @return Array<RoomDamage> null
  */
 public static function getDamagesBefore(HMS_Room $room, $timestamp)
 {
     if (!isset($timestamp)) {
         throw new InvalidArgumentException('Missing timestamp.');
     }
     $db = new PHPWS_DB('hms_room_damage');
     $db->addWhere('room_persistent_id', $room->getPersistentId());
     $db->addWhere('repaired', 0);
     $db->addWhere('reported_on', $timestamp, '<=');
     $result = $db->getObjects('RoomDamageDb');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return $result;
 }
 /**
  * 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;
 }
예제 #12
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;
     }
 }
예제 #13
0
/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function layout_unregister($module, &$content)
{
    PHPWS_Core::initModClass('layout', 'Box.php');
    $content[] = dgettext('layout', 'Removing old layout components.');
    $db = new PHPWS_DB('layout_box');
    $db->addWhere('module', $module);
    $moduleBoxes = $db->getObjects('Layout_Box');
    if (empty($moduleBoxes)) {
        return;
    }
    if (PHPWS_Error::isError($moduleBoxes)) {
        return $moduleBoxes;
    }
    foreach ($moduleBoxes as $box) {
        $box->kill();
    }
    // below makes sure box doesn't get echoed
    unset($GLOBALS['Layout'][$module]);
    unset($_SESSION['Layout_Settings']->_boxes[$module]);
}
 /**
  * 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;
 }
예제 #15
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;
 }
예제 #16
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');
 }
예제 #17
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);
 }
예제 #18
0
 public function memberListForm($group)
 {
     $members = $group->getMembers();
     if (!isset($members)) {
         return dgettext('users', 'None found');
     }
     $db = new PHPWS_DB('users_groups');
     foreach ($members as $id) {
         $db->addWhere('id', $id);
     }
     $db->addOrder('name');
     $db->setIndexBy('id');
     $result = $db->getObjects('PHPWS_Group');
     $tpl = new PHPWS_Template('users');
     $tpl->setFile('forms/memberlist.tpl');
     $count = 0;
     $form = new PHPWS_Form();
     foreach ($result as $group) {
         $form->add('member_drop[' . $group->getId() . ']', 'submit', dgettext('users', 'Drop'));
         $dropbutton = $form->get('member_drop[' . $group->getId() . ']');
         $count++;
         $tpl->setCurrentBlock('row');
         $tpl->setData(array('NAME' => $group->getName(), 'DROP' => $dropbutton));
         if ($count % 2) {
             $tpl->setData(array('STYLE' => 'class="bg-light"'));
         }
         $tpl->parseCurrentBlock();
     }
     return $tpl->get();
 }
예제 #19
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;
     }
 }
예제 #20
0
파일: Key.php 프로젝트: HaldunA/phpwebsite
 /**
  * Unregisters a module by pulling current keys and
  * deleting them individually. Although this takes longer
  * than simply wiping the table, it cleans up old associations. Function
  * also removes the module from the phpws_key_register table.
  * Returns true is all is well, false if there was a problem cleaning
  * up the associations, and an error object if a major problem occurred.
  */
 public static function unregisterModule($module)
 {
     $error_free = true;
     $db1 = new PHPWS_DB('phpws_key');
     $db1->addWhere('module', $module);
     $result = $db1->getObjects('Key');
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     if (!empty($result)) {
         foreach ($result as $key) {
             $result = $key->delete();
             if (!$result) {
                 $error_free = false;
             }
         }
     }
     $db2 = new PHPWS_DB('phpws_key_register');
     $db2->addWhere('module', $module);
     $result = $db2->delete();
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     return $error_free;
 }
예제 #21
0
 public static function getBranches($load_db_info = false)
 {
     $db = new PHPWS_DB('branch_sites');
     $result = $db->getObjects('Branch');
     if (PHPWS_Error::isError($result) || !$load_db_info || empty($result)) {
         return $result;
     }
     foreach ($result as $branch) {
         if ($branch->loadDSN()) {
             $new_result[] = $branch;
         }
     }
     if (isset($new_result)) {
         return $new_result;
     } else {
         return $result;
     }
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'assignment_notify')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to send assignment notifications.');
     }
     PHPWS_Core::initModClass('hms', 'Term.php');
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     // Check if any move-in times are set for the selected term
     $moveinTimes = HMS_Movein_Time::get_movein_times_array(Term::getSelectedTerm());
     // If the array of move-in times ONLY has the zero-th element ['None'] then it's no good
     // Or, of course, if the array is null or emtpy it is no good
     if (count($moveinTimes) <= 1 || is_null($moveinTimes) || empty($moveinTimes)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There are no move-in times set for ' . Term::getPrintableSelectedTerm());
         $context->goBack();
     }
     // Keep track of floors missing move-in times
     $missingMovein = array();
     $term = Term::getSelectedTerm();
     $db = new PHPWS_DB('hms_assignment');
     $db->addWhere('email_sent', 0);
     $db->addWhere('term', $term);
     $result = $db->getObjects("HMS_Assignment");
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     foreach ($result as $assignment) {
         //get the students real name from their asu_username
         $student = StudentFactory::getStudentByUsername($assignment->getUsername(), $term);
         //get the location of their assignment
         PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
         $bed = new HMS_Bed($assignment->getBedId());
         $room = $bed->get_parent();
         $location = $bed->where_am_i() . ' - Bedroom ' . $bed->bedroom_label;
         // Lookup the floor and hall to make sure the
         // assignment notifications flag is true for this hall
         $floor = $room->get_parent();
         $hall = $floor->get_parent();
         if ($hall->assignment_notifications == 0) {
             continue;
         }
         // Get the student type for determining move-in time
         $type = $student->getType();
         // Check for an accepted and confirmed RLC assignment
         $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $term);
         // If there is an assignment, make sure the student "confirmed" the rlc invite
         if (!is_null($rlcAssignment)) {
             if ($rlcAssignment->getStateName() != 'confirmed' && $rlcAssignment->getStateName() != 'selfselect-assigned') {
                 $rlcAssignment = null;
             }
         }
         // Make sure this is re-initialized
         $moveinTimeId = null;
         $rlcSetMoveinTime = false;
         // Determine the move-in time
         if (!is_null($rlcAssignment)) {
             // If there is a 'confirmed' RLC assignment, use the RLC's move-in times
             $rlc = $rlcAssignment->getRlc();
             if ($type == TYPE_CONTINUING) {
                 $moveinTimeId = $rlc->getContinuingMoveinTime();
             } else {
                 if ($type == TYPE_TRANSFER) {
                     $moveinTimeId = $rlc->getTransferMoveinTime();
                 } else {
                     if ($type == TYPE_FRESHMEN) {
                         $moveinTimeId = $rlc->getFreshmenMoveinTime();
                     }
                 }
             }
         }
         // If there's a non-null move-in time ID at this point, then we know the RLC must have set it
         if (!is_null($moveinTimeId)) {
             $rlcSetMoveinTime = true;
         }
         // If the RLC didn't set a movein time, set it according to the floor
         // TODO: Find continuing students by checking the student's application term
         // against the term we're wending assignment notices for
         if (is_null($moveinTimeId)) {
             if ($type == TYPE_CONTINUING) {
                 $moveinTimeId = $assignment->get_rt_movein_time_id();
             } else {
                 if ($type == TYPE_TRANSFER) {
                     $moveinTimeId = $assignment->get_t_movein_time_id();
                 } else {
                     $moveinTimeId = $assignment->get_f_movein_time_id();
                 }
             }
         }
         // Check for missing move-in times
         if ($moveinTimeId == NULL) {
             //test($assignment, 1); // Will only happen if there's no move-in time set for the floor,student type
             // Lets only keep a set of the floors
             if (!in_array($floor, $missingMovein)) {
                 $missingMovein[] = $floor;
             }
             // Missing move-in time, so skip to the next assignment
             continue;
         }
         // TODO: Grab all the move-in times and index them in an array by ID so we don't have to query the DB every single time
         $movein_time_obj = new HMS_Movein_Time($moveinTimeId);
         $movein_time = $movein_time_obj->get_formatted_begin_end();
         // Add a bit of text if the move-in time was for an RLC
         if ($rlcSetMoveinTime) {
             $movein_time .= ' (for the ' . $rlc->get_community_name() . ' Residential Learning Community)';
         }
         //get the list of roommates
         $roommates = array();
         $beds = $room->get_beds();
         foreach ($beds as $bed) {
             $roommate = $bed->get_assignee();
             if ($roommate == false || is_null($roommate) || $roommate->getUsername() == $student->getUsername()) {
                 continue;
             }
             $roommates[] = $roommate->getFullName() . ' (' . $roommate->getUsername() . '@appstate.edu) - Bedroom ' . $bed->bedroom_label;
         }
         // Send the email
         HMS_Email::sendAssignmentNotice($student->getUsername(), $student->getName(), $term, $location, $roommates, $movein_time);
         // Mark the student as having received an email
         $db->reset();
         $db->addWhere('asu_username', $assignment->getUsername());
         $db->addWhere('term', $term);
         $db->addValue('email_sent', 1);
         $rslt = $db->update();
         if (PHPWS_Error::logIfError($rslt)) {
             throw new DatabaseException($result->toString());
         }
     }
     // Check for floors with missing move-in times.
     if (empty($missingMovein) || is_null($missingMovein)) {
         // Ther are none, so show a success message
         NQ::simple('hms', hms\NotificationView::SUCCESS, "Assignment notifications sent.");
     } else {
         // Show a warning for each floor that was missing a move-in time
         foreach ($missingMovein as $floor) {
             $hall = $floor->get_parent();
             $text = $floor->getLink($hall->getHallName() . " floor ") . " move-in times not set.";
             NQ::simple('hms', hms\NotificationView::WARNING, $text);
         }
     }
     $context->goBack();
 }
예제 #23
0
 public static function forward()
 {
     PHPWS_Core::initModClass('access', 'Shortcut.php');
     $db = new PHPWS_DB('access_shortcuts');
     $db->addWhere('keyword', $GLOBALS['Forward']);
     $db->setLimit(1);
     $scl = $db->getObjects('Access_Shortcut');
     if (isset($scl[0])) {
         $sc = $scl[0];
         $sc->loadGet();
     }
 }
예제 #24
0
 public function getUnregMods()
 {
     $db = new PHPWS_DB('modules');
     $db->addWhere('unregister', 1);
     return $db->getObjects('PHPWS_Module');
 }
예제 #25
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;
     }
 }
예제 #26
0
 /**
  * Removes a content variable from the layout_box table.
  * @param string $content_var
  * @return boolean
  */
 public static function purgeBox($content_var)
 {
     $db = new PHPWS_DB('layout_box');
     $db->addWhere('content_var', $content_var);
     $result = $db->getObjects('Layout_Box');
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     if (empty($result)) {
         return true;
     }
     foreach ($result as $box) {
         $check = $box->kill();
         if (PHPWS_Error::isError($check)) {
             return $check;
         }
     }
     return TRUE;
 }
예제 #27
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;
 }
예제 #28
0
 public function loadAssignment()
 {
     $db = new PHPWS_DB('hms_assignment');
     $db->addWhere('bed_id', $this->id);
     $db->addWhere('term', $this->term);
     $db->loadClass('hms', 'HMS_Assignment.php');
     $result = $db->getObjects('HMS_Assignment');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     } else {
         if ($result == null) {
             return true;
         } elseif (sizeof($result) > 1) {
             PHPWS_Error::log(HMS_MULTIPLE_ASSIGNMENTS, 'hms', 'HMS_Bed::loadAssignment', "bedid : {$this->id}");
             return false;
         } else {
             $this->_curr_assignment = $result[0];
             return TRUE;
         }
     }
 }
예제 #29
0
파일: Box.php 프로젝트: HaldunA/phpwebsite
 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++;
     }
 }
예제 #30
0
 public function viewImage($id, $view_folder = true)
 {
     Layout::addStyle('filecabinet');
     PHPWS_Core::initModClass('filecabinet', 'Image.php');
     $image = new PHPWS_Image($id);
     $folder = new Folder($image->folder_id);
     if (!$folder->allow()) {
         $content = dgettext('filecabinet', 'Sorry, the file you requested is off limits.');
         Layout::add($content);
         return;
     }
     $tpl['TITLE'] = $image->title;
     if ($image->width > FC_MAX_IMAGE_POPUP_WIDTH || $image->height > FC_MAX_IMAGE_POPUP_HEIGHT) {
         if (FC_MAX_IMAGE_POPUP_WIDTH < FC_MAX_IMAGE_POPUP_HEIGHT) {
             $ratio = FC_MAX_IMAGE_POPUP_WIDTH / $image->width;
             $image->width = FC_MAX_IMAGE_POPUP_WIDTH;
             $image->height = $image->height * $ratio;
         } else {
             $ratio = FC_MAX_IMAGE_POPUP_HEIGHT / $image->height;
             $image->height = FC_MAX_IMAGE_POPUP_HEIGHT;
             $image->width = $image->width * $ratio;
         }
         $tpl['IMAGE'] = sprintf('<a href="%s">%s</a>', $image->getPath(), $image->getTag());
     } else {
         $tpl['IMAGE'] = $image->getTag();
     }
     $tpl['DESCRIPTION'] = $image->getDescription();
     $tpl['CLOSE'] = javascript('close_window');
     if ($view_folder && $folder->public_folder) {
         $db = new PHPWS_DB('images');
         $db->setLimit(1);
         $db->addWhere('folder_id', $image->folder_id);
         $db->addWhere('title', $image->title, '>');
         $db->addOrder('title');
         $next_img = $db->getObjects('PHPWS_Image');
         if (!empty($next_img)) {
             $next_link = Icon::show('next', dgettext('filecabinet', 'Next image'));
             $tpl['NEXT'] = sprintf('<a id="next-link" href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $next_img[0]->popupAddress(), $next_link);
         }
         $db->resetWhere();
         $db->resetOrder();
         $db->addWhere('folder_id', $image->folder_id);
         $db->addWhere('title', $image->title, '<');
         $db->addOrder('title desc');
         $prev_img = $db->getObjects('PHPWS_Image');
         if (!empty($prev_img)) {
             $prev_link = Icon::show('previous', dgettext('filecabinet', 'Previous image'));
             $tpl['PREV'] = sprintf('<a id="prev-link" href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $prev_img[0]->popupAddress(), $prev_link);
         }
     }
     $content = PHPWS_Template::process($tpl, 'filecabinet', 'image_view.tpl');
     Layout::nakedDisplay($content);
 }