public static function execute() { PHPWS_Core::initModClass('hms', 'HMS.php'); // Copied and pasted from index.php require_once PHPWS_SOURCE_DIR . 'mod/hms/inc/defines.php'; // Copied and pasted from ExecuteLotteryCommand.php PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); HMS_Lottery::runLottery(); $now = time(); $date = date('m/d/Y H:i:s', $now); if ($_SESSION['UNSCHEDULE_LOTTERY']) { echo "Lottery has executed. The time is {$date}. Lottery asked to be unscheduled.\n"; } else { $hr = date('H', $now); $day = date('d', $now); if ($hr >= 9 && $hr < 16) { $then = strtotime("16:00:00", $now); } else { if ($hr >= 16) { $then = strtotime("+1 day 09:00:00", $now); } else { $then = strtotime("09:00:00", $now); } } $newdate = date('m/d/Y H:i:s', $then); echo "Lottery has executed. The time is {$date}. Lottery has been scheduled to run at {$newdate}.\n"; $sp = $this->makeClone(); $sp->execute_at = $then; $sp->save(); } return TRUE; }
public function show() { $tpl = array(); $tpl['CHANGELOG_REPEAT'] = array(); PHPWS_Core::initModClass('intern', 'ChangeHistoryFactory.php'); $changes = ChangeHistoryFactory::getChangesForInternship($this->internship); if (is_null($changes)) { return ""; } foreach ($changes as $change) { $changeFields = array(); $changeFields['RELATIVE_DATE'] = $change->getRelativeDate(); $changeFields['EXACT_DATE'] = $change->getFormattedDate(); $changeFields['USERNAME'] = $change->getUsername(); if ($change->getFromStateFriendlyname() != $change->getToStateFriendlyName()) { $changeFields['FROM_STATE'] = $change->getFromStateFriendlyName(); $changeFields['TO_STATE'] = $change->getToStateFriendlyName(); } $note = $change->getNote(); if (!is_null($note)) { $changeFields['NOTE'] = $note; } $tpl['changelog_repeat'][] = $changeFields; } return PHPWS_Template::process($tpl, 'intern', 'changeHistory.tpl'); }
public function runTime(\Request $request) { if (\PHPWS_Core::atHome()) { require_once PHPWS_SOURCE_DIR . 'mod/tailgate/conf/defines.php'; \tailgate\Controller\User\Game::userStatusSidebar(); } }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $term = $context->get('term'); // Application must exist $app = HMS_RLC_Application::getApplicationByUsername(UserStatus::getUsername(), $term); if (is_null($app)) { NQ::simple('hms', hms\NotificationView::ERROR, 'No RLC application exists.'); $context->goBack(); } else { if (!HMS_RLC_Assignment::checkForAssignment(UserStatus::getUsername(), $term)) { // Delete the app $app->delete(); // Log it PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_RLC_APPLICATION_DELETED, UserStatus::getUsername()); // Show a notification and go back NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC application deleted.'); $context->goBack(); } else { NQ::simple('hms', hms\NotificationView::WARNING, 'You have already been assigned to an RLC.'); $context->goBack(); } } }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $requestId = $context->get('requestId'); $errorCmd = CommandFactory::getCommand('LotteryShowDenyRoommateRequest'); $errorCmd->setRequestId($requestId); # Confirm the captcha PHPWS_Core::initCoreClass('Captcha.php'); $captcha = Captcha::verify(TRUE); if ($captcha === FALSE) { NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.'); $errorCmd->redirect(); } # Get the roommate request $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId')); # Make sure that the logged in user is the same as the confirming the request if (UserStatus::getUsername() != $request['asu_username']) { NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid roommate request. You can not confirm that roommate request.'); $errorCmd->redirect(); } # Deny the roommate requst try { HMS_Lottery::denyRoommateRequest($requestId); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error denying the roommate request. Please contact University Housing.'); $errorCmd->redirect(); } # Log that it happened PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOMMATE_DENIED, UserStatus::getUsername(), 'Captcha words: ' . $captcha); # Success NQ::simple('hms', hms\NotificationView::SUCCESS, 'The roommate request was successfully declined.'); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); }
protected function propertiesList($contact_id = null) { \PHPWS_Core::initModClass('properties', 'Property.php'); $this->title = 'Property listing'; $pager = new \DBPager('properties', 'Properties\\Property'); if ($contact_id) { $pager->addWhere('contact_id', $contact_id); $data['is_contact'] = 1; $page_tags['new'] = \PHPWS_Text::moduleLink('<i class="fa fa-plus"></i> Add new property', 'properties', array('cop' => 'edit_property', 'k' => $this->contact->getKey()), null, null, 'btn btn-success'); } else { $page_tags['new'] = \PHPWS_Text::secureLink('<i class="fa fa-plus"></i> Add new property', 'properties', array('aop' => 'edit_property'), null, null, 'btn btn-success'); } // photo was previously uploaded if (!empty($_GET['pid'])) { $data['pid'] = $_GET['pid']; } else { $data['pid'] = 0; } javascriptMod('properties', 'photo_upload', $data); $pager->setSearch('name', 'company_name'); $pager->addSortHeader('name', 'Name of property'); $pager->addSortHeader('company_name', 'Management company'); $pager->addSortHeader('timeout', 'Time until purge'); $pager->setModule('properties'); $pager->setTemplate('properties_list.tpl'); $pager->addRowTags('row_tags', (bool) $contact_id); $pager->joinResult('contact_id', 'prop_contacts', 'id', 'company_name', null, true); $pager->addPageTags($page_tags); $pager->cacheQueries(); $this->content = $pager->get(); }
public function __construct($term) { $this->term = $term; echo "Term is {$term}\n\n"; PHPWS_Core::initModClass('hms', 'RoommatePairingStrategy.php'); PHPWS_Core::initModClass('hms', 'RequestedRoommatePairingStrategy.php'); PHPWS_Core::initModClass('hms', 'PreferencesRoommatePairingStrategy.php'); PHPWS_Core::initModClass('hms', 'AssignmentStrategy.php'); PHPWS_Core::initModClass('hms', 'SpecialAssignmentStrategy.php'); PHPWS_Core::initModClass('hms', 'SingleGenderAssignmentStrategy.php'); PHPWS_Core::initModClass('hms', 'CoedAssignmentStrategy.php'); PHPWS_Core::initModClass('hms', 'RandomAssignmentStrategy.php'); # Load all the unassigned applicants for this term $this->applications = HousingApplication::getUnassignedFreshmenApplications($term, null); # Setup the pairing strategies $this->pairingStrategies = array(); $this->pairingStrategies[] = new RequestedRoommatePairingStrategy($term); $this->pairingStrategies[] = new PreferencesRoommatePairingStrategy($term); # Setup the assignment strategies $this->assignmentStrategies = array(); $this->assignmentStrategies[] = new SpecialAssignmentStrategy($term); $this->assignmentStrategies[] = new SingleGenderAssignmentStrategy($term); $this->assignmentStrategies[] = new CoedAssignmentStrategy($term); $this->assignmentStrategies[] = new RandomAssignmentStrategy($term); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit floors.'); } // Check for a hall ID $floorId = $context->get('floor'); if (!isset($floorId)) { throw new InvalidArgumentException('Missing floor ID.'); } PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Floor.php'); PHPWS_Core::initModClass('hms', 'FloorView.php'); $floor = new HMS_Floor($floorId); if ($floor->term != Term::getSelectedTerm()) { $floorCmd = CommandFactory::getCommand('SelectFloor'); $floorCmd->setTitle('Edit a Floor'); $floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView')); $floorCmd->redirect(); } $hall = $floor->get_parent(); $floorView = new FloorView($hall, $floor); $context->setContent($floorView->show()); }
public function execute(CommandContext $context) { $id = $context->get('roommateId'); if (is_null($id)) { throw new InvalidArgumentException('Must set roommateId'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $roommate = new HMS_Roommate($id); if ($roommate->id == 0) { throw new InvalidArgumentException('Invalid roommateId ' . $id); } $username = UserStatus::getUsername(); if ($username != $roommate->requestee) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to display confirmation screen for pairing {$roommate->id}"); } $tpl = array(); $acceptCmd = CommandFactory::getCommand('ShowRoommateConfirmAccept'); $acceptCmd->setRoommateId($roommate->id); $tpl['ACCEPT'] = $acceptCmd->getURI(); $rejectCmd = CommandFactory::getCommand('RoommateReject'); $rejectCmd->setRoommateId($roommate->id); $tpl['DECLINE'] = $rejectCmd->getURI(); $cancelCmd = CommandFactory::getCommand('ShowStudentMenu'); $tpl['CANCEL'] = $cancelCmd->getURI(); $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term); $tpl['REQUESTOR_NAME'] = $requestor->getFullName(); $context->setContent(PHPWS_Template::process($tpl, 'hms', 'student/roommate_accept_reject_screen.tpl')); }
/** * @version $Id$ * @author Matthew McNaney <mcnaney at gmail dot com> */ function my_page() { $title = $content = $message = NULL; if (isset($_SESSION['Layout_User_Message'])) { $message = $_SESSION['Layout_User_Message']; unset($_SESSION['Layout_User_Message']); } if (isset($_SESSION['Reset_Layout'])) { unset($_SESSION['Reset_Layout']); Layout::reset(); } if (isset($_REQUEST['lo_command'])) { $lo_command = $_REQUEST['lo_command']; } else { $lo_command = 'user_form'; } switch ($lo_command) { case 'user_form': $title = dgettext('layout', 'Display settings'); $content = Layout_User_Settings::user_form(); break; case 'save_settings': Layout_User_Settings::save_settings(); $_SESSION['Reset_Layout'] = 1; $_SESSION['Layout_User_Message'] = dgettext('layout', 'Settings saved'); PHPWS_Core::reroute('index.php?module=users&action=user&tab=layout'); break; } $tpl['TITLE'] = $title; $tpl['CONTENT'] = $content; $tpl['MESSAGE'] = $message; return PHPWS_Template::process($tpl, 'layout', 'main.tpl'); }
function hms_install(&$content) { PHPWS_Core::initModClass('users', 'Users.php'); $DB = new PHPWS_DB('users'); $DB->addWhere('username', 'hms_admin'); $result = $DB->select('one'); if ($result == null) { $user = new PHPWS_User(); $user->setUsername('hms_admin'); $user->setPassword('in the white room, with black curtains'); $user->save(); } $DB = new PHPWS_DB('users'); $DB->addWhere('username', 'hms_student'); $result = $DB->select('one'); if ($result == null) { $user = new PHPWS_User(); $user->setUsername('hms_student'); $user->setPassword('shes my everything, shes my pride and joy'); $user->save(); } $directory = PHPWS_HOME_DIR . 'files/hms_reports/'; if (!is_dir($directory)) { mkdir($directory); } return true; }
public function execute() { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); // Select all cancelled apps for the given term $db = new PHPWS_DB('hms_new_application'); $db->addWhere('cancelled', 1); $db->addWhere('term', $this->term); $results = $db->select(); // Initialize storage for processed rows $this->rows = array(); // Get friendly cancellation reasons from HousingApplication $reasons = HousingApplication::getCancellationReasons(); // Process and store each result foreach ($results as $app) { $row = array(); $row['bannerId'] = $app['banner_id']; $row['username'] = $app['username']; $row['gender'] = HMS_Util::formatGender($app['gender']); $row['application_term'] = $app['application_term']; $row['student_type'] = $app['student_type']; $row['cancelled_reason'] = $reasons[$app['cancelled_reason']]; $row['cancelled_on'] = HMS_Util::get_long_date($app['cancelled_on']); $row['cancelled_by'] = $app['cancelled_by']; $this->rows[] = $row; } }
public function forceLogin() { if (!$this->force_login) { return; } PHPWS_Core::reroute($this->login_link); }
public function execute(CommandContext $context) { $resultCmd = CommandFactory::getCommand('ShowSendRlcInvites'); $respondByDate = $context->get('respond_by_date'); $respondByTime = $context->get('time'); if (!isset($respondByDate) || $respondByDate == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a \'respond by\' date.'); $resultCmd->redirect(); } $dateParts = explode('/', $respondByDate); $respondByTimestamp = mktime($respondByTime, null, null, $dateParts[0], $dateParts[1], $dateParts[2]); $term = Term::getSelectedTerm(); $studentType = $context->get('type'); if (!isset($studentType)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a student type.'); $resultCmd->redirect(); } PHPWS_Core::initModClass('hms', 'RlcAssignmentFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentInvitedState.php'); $assignments = RlcAssignmentFactory::getAssignmentsByTermStateType($term, 'new', $studentType); if (sizeof($assignments) == 0) { NQ::simple('hms', hms\NotificationView::WARNING, 'No invites needed to be sent.'); $resultCmd->redirect(); } foreach ($assignments as $assign) { $assign->changeState(new RlcAssignmentInvitedState($assign, $respondByTimestamp)); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Learning community invites sent.'); $resultCmd->redirect(); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'LotteryApplication.php'); $this->setTitle('Special Interest Group'); javascript('jquery'); $tpl = array(); $groups = HMS_Lottery::getSpecialInterestGroupsMap(); // If a group was selected if (!is_null($this->group) && $this->group != 'none') { $tpl['GROUP_PAGER'] = LotteryApplication::specialInterestPager($this->group, PHPWS_Settings::get('hms', 'lottery_term')); $tpl['GROUP'] = $groups[$this->group]; } // Show the drop down box of groups $form = new PHPWS_Form('special_interest'); $form->setMethod('get'); $form->addDropBox('group', $groups); $form->setClass('group', 'form-control'); $form->setMatch('group', $this->group); $cmd = CommandFactory::getCommand('ShowSpecialInterestGroupApproval'); $cmd->initForm($form); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'admin/special_interest_approval.tpl'); }
public function execute(CommandContext $context) { $reminders = $context->get('send_reminders'); $sendReminders = isset($reminders) ? true : false; $magic = $context->get('magic_flag'); $sendMagic = isset($magic) ? true : false; $srMale = $context->get('sr_male'); $srFemale = $context->get('sr_female'); $jrMale = $context->get('jr_male'); $jrFemale = $context->get('jr_female'); $sophMale = $context->get('soph_male'); $sophFemale = $context->get('soph_female'); PHPWS_Core::initModClass('hms', 'LotteryProcess.php'); $inviteCounts = array(); $inviteCounts[CLASS_SENIOR][MALE] = $srMale; $inviteCounts[CLASS_SENIOR][FEMALE] = $srFemale; $inviteCounts[CLASS_JUNIOR][MALE] = $jrMale; $inviteCounts[CLASS_JUNIOR][FEMALE] = $jrFemale; $inviteCounts[CLASS_SOPHOMORE][MALE] = $sophMale; $inviteCounts[CLASS_SOPHOMORE][FEMALE] = $sophFemale; $lottery = new LotteryProcess($sendMagic, $sendReminders, $inviteCounts); $lottery->sendInvites(); $_SESSION['LOTTERY_OUTPUT'] = $lottery->getOutput(); $viewCmd = CommandFactory::getCommand('ShowLotteryInviteResults'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'edit_role_members')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit role members.'); } $username = $context->get('username'); $rolename = $context->get('role'); $class = $context->get('className'); $instance = $context->get('instance'); if (is_null($username) || is_null($rolename)) { echo json_encode(false); exit; } $db = new PHPWS_DB('hms_role'); $db->addWhere('name', $rolename); $result = $db->select('row'); if (PHPWS_Error::logIfError($result) || is_null($result['id'])) { echo json_encode(false); exit; } $role_id = $result['id']; $role = new HMS_Role(); $role->id = $role_id; if ($role->load()) { echo json_encode($role->removeUser($username, $class, $instance)); exit; } echo json_encode(false); exit; }
/** * unregisters deleted keys from menu * * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function menu_unregister_key(Key $key) { PHPWS_Core::initModClass('menu', 'Menu_Link.php'); if (empty($key) || empty($key->id)) { return FALSE; } $db = new PHPWS_DB('menu_links'); $db->addWhere('key_id', $key->id); $result = $db->delete(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); } $db2 = new PHPWS_DB('menu_assoc'); $db2->addWhere('key_id', $key->id); $result = $db2->delete(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); } $db3 = new PHPWS_DB('menus'); $db3->addWhere('assoc_key', $key->id); $db3->addValue('assoc_key', 0); $db3->addValue('assoc_url', null); $db3->update(); return true; }
/** * Loads the form's fields with the internship's information. * TODO: Use getter methods instead of just accessing Internship member variables directly. */ public function plugInternship() { $this->plugStudent(); $this->plugDept(); $this->plugFaculty(); $this->plugAgency(); $this->plugInternInfo(); $this->plugCourseInfo(); // We're editing an internship... // If this internship's term is in the past, then replace the term list with just that term if (!in_array($this->intern->term, array_keys(Term::getFutureTermsAssoc()))) { // Remove the term dropdown and repalce it $this->form->dropElement('term'); $this->form->addSelect('term', array($this->intern->term => Term::rawToRead($this->intern->term))); $this->form->setLabel('term', 'Select Term'); $this->form->addCssClass('term', 'form-control'); } $this->form->setMatch('term', $this->intern->term); $this->form->setMatch('experience_type', $this->intern->getExperienceType()); // Plug $this->form->plugIn($this->formVals); /** * * * Emergency Contacts */ //javascript('jquery'); PHPWS_Core::initModClass('intern', 'EmergencyContactFactory.php'); $contacts = EmergencyContactFactory::getContactsForInternship($this->intern); $emgContactJson = json_encode($contacts); Layout::add(javascriptMod('intern', 'emergencyContact', array('existing_contacts_json' => $emgContactJson))); }
function showFP() { $db = new PHPWS_DB('ps_page'); $db->addWhere('front_page', 1); if ($db->isTableColumn('deleted')) { $db->addWhere('deleted', 0); } Key::restrictView($db, 'pagesmith'); $db->loadClass('pagesmith', 'PS_Page.php'); $result = $db->getObjects('PS_Page'); if (!PHPWS_Error::logIfError($result) && !empty($result)) { PHPWS_Core::initModClass('pagesmith', 'PageSmith.php'); foreach ($result as $page) { $content = $page->view(); if ($content && !PHPWS_Error::logIfError($content)) { if (Current_User::allow('pagesmith', 'edit_page', $page->id)) { $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink()); } Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE); } } } else { return null; } }
public function execute(CommandContext $context) { $id = $context->get('roommateId'); if (is_null($id)) { throw new InvalidArgumentException('Must set roommateId'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $roommate = new HMS_Roommate($id); if ($roommate->id == 0) { throw new InvalidArgumentException('Invalid roommateId ' . $id); } $username = UserStatus::getUsername(); if ($username != $roommate->requestor) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}"); } $roommate->delete(); $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term); HMS_Activity_Log::log_activity($other->getUsername(), ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $username, "{$username} cancelled roommate request"); HMS_Activity_Log::log_activity($username, ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $other->getUsername(), "{$username} cancelled roommate request"); // Email both parties PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_cancel_emails($roommate); $name = $other->getFullName(); NQ::Simple('hms', hms\NotificationView::SUCCESS, "You have cancelled your roommate request for {$name}."); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $cmd->redirect(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'roommate_maintenance')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to create/edit roommate groups.'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $id = $context->get('id'); if (is_null($id)) { throw new InvalidArgumentException('Missing roommate group id.'); } $viewCmd = CommandFactory::getCommand('EditRoommateGroupsView'); try { $roommate = new HMS_Roommate($id); $roommate->delete(); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Error deleting roommate group: ' . $e->getMessage()); $viewCmd->redirect(); } // Log the success $notes = "{$roommate->getRequestor()} requested {$roommate->getRequestee()}"; HMS_Activity_Log::log_activity($roommate->getRequestor(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); HMS_Activity_Log::log_activity($roommate->getRequestee(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Roommate group successfully deleted.'); $viewCmd->redirect(); }
public function execute() { PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $halls = HMS_Residence_Hall::get_halls($this->term); $rows = array(); foreach ($halls as $hall) { if ($hall->count_avail_lottery_rooms('1') || $hall->count_avail_lottery_rooms('0')) { $row = array(); $row['HALL_NAME'] = $hall->getHallName(); $row['MALE_FREE'] = $hall->count_avail_lottery_rooms('1'); $row['FEMALE_FREE'] = $hall->count_avail_lottery_rooms('0'); $rooms = $hall->get_rooms(); $roomRows = ""; foreach ($rooms as $room) { if ($room->count_avail_lottery_beds() > 0) { $roomRow = "<tr><td>"; $roomRow = $roomRow . $room->getRoomNumber(); $roomRow = $roomRow . "</td><td>"; $roomRow = $roomRow . HMS_Util::formatGender($room->getGender()); $roomRow = $roomRow . "</td><td>"; $roomRow = $roomRow . $room->count_avail_lottery_beds(); $roomRow = $roomRow . "</td></tr>"; $roomRows = $roomRows . $roomRow; } } $row['ROOMS'] = $roomRows; $rows[] = $row; } } $this->data = $rows; }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; if (!is_null($this->application) && $this->application->getApplicationType() == 'offcampus_waiting_list') { $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['ALREADY_APPLIED'] = ""; } else { if (time() < $this->startDate) { $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { //TODO $tpl['ICON'] = FEATURE_OPEN_ICON; $waitListCommand = CommandFactory::getCommand('ShowOffCampusWaitListApplication'); $waitListCommand->setTerm($this->term); $tpl['WAIT_LIST_LINK'] = $waitListCommand->getLink('Apply to the waiting list'); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/OffCampusWaitingListMenuBlock.tpl'); }
public function execute(CommandContext $context) { $id = $context->get('roommateId'); if (is_null($id)) { throw new InvalidArgumentException('Must set roommateId'); } PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $roommate = new HMS_Roommate($id); if ($roommate->id = 0) { throw new InvalidArgumentException('Invalid roommateId ' . $id); } $username = UserStatus::getUsername(); if ($username != $roommate->requestor && $username != $roommate->requestee) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}"); } PHPWS_Core::initCoreClass('Captcha.php'); // get other roommate $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term); $form = new PHPWS_Form(); $cmd = CommandFactory::getCommand('RoommateBreak'); $cmd->setRoommateId($id); $cmd->initForm($form); $form->addTplTag('CAPTCHA_IMAGE', Captcha::get()); $form->addTplTag('NAME', $other->getFullName()); $form->addSubmit('Confirm'); $form->addCssClass('submit', 'btn btn-danger'); $context->setContent(PHPWS_Template::process($form->getTemplate(), 'hms', 'student/roommate_break_confirm.tpl')); }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $term = Term::getSelectedTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckinStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // Check the Banner ID if (preg_match("/[\\d]{9}/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, 'Imporperly formatted Banner ID.'); $errorCmd->redirect(); } // Try to lookup the student in Banner try { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Make sure the student is assigned in the current term $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); if (!isset($assignment) || is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' is not assigned for ' . Term::toString($term) . '. Please contact the University Housing Assignments Office at 828-262-6111.'); $errorCmd->redirect(); } // Make sure the student's assignment matches the hall the user selected $bed = $assignment->get_parent(); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); if ($hallId != $hall->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, 'Wrong hall! ' . $student->getName() . ' is assigned to ' . $assignment->where_am_i()); $errorCmd->redirect(); } // Load any existing check-in $checkin = CheckinFactory::getLastCheckinByBannerId($bannerId, $term); // If there is a checkin for the same bed, and the difference between the current time and the checkin time is // greater than 48 hours, then show an error. if (!is_null($checkin)) { $checkoutDate = $checkin->getCheckoutDate(); if ($checkin->getBedId() == $bed->getId() && !isset($checkoutDate) && time() - $checkin->getCheckinDate() > Checkin::CHECKIN_TIMEOUT) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' has already checked in to ' . $assignment->where_am_i()); $errorCmd->redirect(); } } $view = new CheckinFormView($student, $assignment, $hall, $floor, $room, $checkin); $context->setContent($view->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'RoommateProfileSearchForm.php'); $term = $context->get('term'); $view = new RoommateProfileSearchForm($term); $context->setContent($view->show()); }
public function execute() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } $db = new PHPWS_DB('hms_new_application'); $db->addColumn('banner_id'); $db->addColumn('username'); $db->addWhere('term', $this->term); $results = $db->select(); if (empty($results)) { return; } elseif (PEAR::isError($results)) { throw new DatabaseException($results->toString()); } $twentyFiveYearsAgo = strtotime("-25 years"); foreach ($results as $student) { try { $sf = StudentFactory::getStudentByBannerId($student['banner_id'], $this->term); $dob = $sf->getDOB(); if (strtotime($dob) > $twentyFiveYearsAgo) { continue; } $student['dob'] = $dob; $student['full_name'] = $sf->getFullName(); $this->all_rows[] = $student; } catch (Exception $e) { $student['dob'] = $student['full_name'] = null; $this->problems[] = $student['banner_id']; } } }
public function getMenuBlockView(Student $student) { PHPWS_Core::initModClass('hms', 'RoommateProfile.php'); $profile = RoommateProfileFactory::getProfile($student->getBannerID(), $this->term); PHPWS_Core::initModClass('hms', 'StudentMenuProfileView.php'); return new StudentMenuProfileView($student, $this->getStartDate(), $this->getEndDate(), $this->term, $profile); }
public static function getHMS() { $rh = getallheaders(); if (isset(HMSFactory::$hms)) { return HMSFactory::$hms; } else { if (isset($_REQUEST['ajax']) || !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || isset($_REQUEST['callback']) || array_key_exists('Accept', $rh) && stripos($rh['Accept'], 'application/json') !== FALSE) { PHPWS_Core::initModClass('hms', 'AjaxHMS.php'); HMSFactory::$hms = new AjaxHMS(); } else { if (UserStatus::isAdmin()) { PHPWS_Core::initModClass('hms', 'AdminHMS.php'); HMSFactory::$hms = new AdminHMS(); } else { if (UserStatus::isUser()) { PHPWS_Core::initModClass('hms', 'UserHMS.php'); HMSFactory::$hms = new UserHMS(); } else { // Guest PHPWS_Core::initModClass('hms', 'GuestHMS.php'); HMSFactory::$hms = new GuestHMS(); } } } } return HMSFactory::$hms; }