public function show()
 {
     $submitCmd = CommandFactory::getCommand('SaveTermSettings');
     $form = new PHPWS_Form('docusign');
     $submitCmd->initForm($form);
     // Over 18 template
     $existingTemplate = '';
     try {
         $existingTemplate = $this->term->getDocusignTemplate();
     } catch (InvalidConfigurationException $e) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'No DocuSign template id has been set for students over 18.');
     }
     $form->addText('template', $existingTemplate);
     $form->addCssClass('template', 'form-control');
     // Under 18 template
     $under18Template = '';
     try {
         $under18Template = $this->term->getDocusignUnder18Template();
     } catch (InvalidConfigurationException $e) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'No DocuSign template id has been set for students under 18.');
     }
     $form->addText('under18_template', $under18Template);
     $form->addCssClass('under18_template', 'form-control');
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'admin/TermsConditionsAdminView.tpl');
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentDataProvider.php');
     $provider = StudentDataProvider::getInstance();
     $provider->clearCache();
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Cache cleared.');
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $term = $context->get('term');
     if (!isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $user = UserStatus::getUsername();
     $student = StudentFactory::getStudentByUsername($user, $term);
     // Load the student's application. Should be a lottery application.
     $application = HousingApplicationFactory::getAppByStudent($student, $term);
     // If there isn't a valid application in the DB, then we have a problem.
     if (!isset($application) || !$application instanceof LotteryApplication) {
         throw new InvalidArgumentException('Null application object.');
     }
     // Check to make sure the date isn't already set
     $time = $application->getWaitingListDate();
     if (isset($time)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already applied for the waiting list.');
         $cmd = CommandFactory::getCommand('ShowStudentMenu');
         $cmd->redirect();
     }
     // Set the date
     $application->setWaitingListDate(time());
     // Save the application again
     $application->save();
     // Log it to the activity log
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_REAPP_WAITINGLIST_APPLY, UserStatus::getUsername());
     // Success command
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
 /**
  * Shows the requested report's HTML output.
  * 
  * @param CommandContext $context
  * @throws InvalidArgumentExection
  */
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do no have permission to run reports.');
     }
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentExection('Missing report id.');
     }
     // Instantiate the report controller with the requested report id
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $report = ReportFactory::getReportById($reportId);
     Layout::addPageTitle($report->getFriendlyName());
     $detailCmd = CommandFactory::getCommand('ShowReportDetail');
     $detailCmd->setReportClass($report->getClass());
     $content = '<div> ' . $detailCmd->getLink('&laquo; back') . ' </div>';
     $content .= file_get_contents($report->getHtmlOutputFilename());
     if ($content === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
         PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
         $reportCmd = CommandFactory::getCommand('ShowReportDetail');
         $reportCmd->setReportClass($report->getClass());
         $reportCmd->redirect();
     }
     $context->setContent($content);
 }
 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);
     }
     if (UserStatus::getUsername() != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to reject roommate pairing {$roommate->id}");
     }
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $name = $requestor->getFullName();
     $username = $requestor->getUsername();
     $roommate->delete();
     HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_reject_emails($roommate);
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "<b>You rejected the roommate request from {$name}.</b>  If this was an error, you may re-request using their username, <b>{$username}</b>.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     // Check for report ID
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentException('Missing report id.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     // Load the report to get its class
     try {
         $report = ReportFactory::getReportById($reportId);
     } catch (InvalidArgumentException $e) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
         $context->goBack();
     }
     $db = new PHPWS_DB('hms_report');
     $db->addWhere('id', $reportId);
     $result = $db->delete();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
     $cmd = CommandFactory::getCommand('ShowReportDetail');
     $cmd->setReportClass($report->getClass());
     $cmd->redirect();
 }
Beispiel #7
0
 /**
  * Converts the database entry of Term into human
  * If $super is true then <sup> tags will be used in 1st and 2nd.
  * readable form. (Ex: 20111 => 'Spring 2011')
  */
 public static function rawToRead($t, $super = false)
 {
     $semester = substr($t, strlen($t) - 1, 1);
     $year = substr($t, 0, strlen($t) - 1);
     switch ($semester) {
         case '1':
             return "Spring {$year}";
         case '2':
             if ($super) {
                 return "1<sup>st</sup> Summer {$year}";
             } else {
                 return "1st Summer {$year}";
             }
         case '3':
             if ($super) {
                 return "2<sup>nd</sup> Summer {$year}";
             } else {
                 return "2nd Summer {$year}";
             }
         case '4':
             return "Fall {$year}";
         default:
             // Whaattt??
             \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, 'Term error: ' . $t);
             return "{$year}";
     }
 }
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to remove a bed.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     $viewCmd = CommandFactory::getCommand('EditRoomView');
     $viewCmd->setRoomId($context->get('roomId'));
     $bedId = $context->get('bedId');
     $roomId = $context->get('roomId');
     if (!isset($roomId)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Missing room ID.');
         $viewCmd->redirect();
     }
     if (!isset($bedId)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Missing bed ID.');
         $viewCmd->redirect();
     }
     # Try to delete the bed
     try {
         HMS_Bed::deleteBed($bedId);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error deleting the bed: ' . $e->getMessage());
         $viewCmd->redirect();
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Bed successfully deleted.');
     $viewCmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     /*
     if(!Current_User::allow('hms', 'email_hall') && !Current_User::allow('hms', 'email_all')){
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to send messages.');
     }
     */
     if (is_null($context->get('hall')) && is_null($context->get('floor'))) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must select a hall to continue!');
         $cmd = CommandFactory::getCommand('ShowHallNotificationSelect');
         $cmd->redirect();
     }
     $subject = $context->get('subject');
     $body = $context->get('body');
     $anonymous = !is_null($context->get('anonymous')) ? $context->get('anonymous') : false;
     $halls = $context->get('hall');
     $floors = $context->get('floor');
     $cmd = CommandFactory::getCommand('ShowHallNotificationEdit');
     if (empty($subject)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the subject line of the email.');
         $cmd->loadContext($context);
         $cmd->redirect();
     } else {
         if (empty($body)) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the message to be sent.');
             $cmd->loadContext($context);
             $cmd->redirect();
         }
     }
     $view = new ReviewHallNotificationMessageView($subject, $body, $anonymous, $halls, $floors);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Foreach rlc assignment made
     # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
     # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
     foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
         if ($rlc_id <= 0) {
             continue;
         }
         $app = HMS_RLC_Application::getApplicationById($app_id);
         $student = StudentFactory::getStudentByUsername($app->username, $app->term);
         # Insert a new assignment in the 'learning_community_assignment' table
         $assign = new HMS_RLC_Assignment();
         $assign->rlc_id = $rlc_id;
         $assign->gender = $student->getGender();
         $assign->assigned_by = UserStatus::getUsername();
         $assign->application_id = $app->id;
         $assign->state = 'new';
         $assign->save();
         # Log the assignment
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
     }
     // Show a success message
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
     $context->goBack();
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'CheckinFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     $term = Term::getSelectedTerm();
     // Get the total damages assessed for each student
     $damages = RoomDamageFactory::getAssessedDamagesStudentTotals($term);
     foreach ($damages as $dmg) {
         $student = StudentFactory::getStudentByBannerId($dmg['banner_id'], $term);
         // Get the student's last checkout
         // (NB: the damages may be for multiple check-outs,
         // but we'll just take the last one)
         $checkout = CheckinFactory::getLastCheckoutForStudent($student);
         $bed = new HMS_Bed($checkout->getBedId());
         $room = $bed->get_parent();
         $floor = $room->get_parent();
         $hall = $floor->get_parent();
         $coordinators = $hall->getCoordinators();
         if ($coordinators != null) {
             $coordinatorName = $coordinators[0]->getDisplayName();
             $coordinatorEmail = $coordinators[0]->getEmail();
         } else {
             $coordinatorName = '(No coordinator set for this hall.)';
             $coordinatorEmail = '(No coordinator set for this hall.)';
         }
         HMS_Email::sendDamageNotification($student, $term, $dmg['sum'], $coordinatorName, $coordinatorEmail);
     }
     // Show a success message and redirect back to the main admin menu
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Room damage noties sent.');
     $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     NQ::close();
     header('HTTP/1.1 303 See Other');
     header("Location: {$_SERVER['SCRIPT_NAME']}?module=controlpanel");
     HMS::quit();
 }
Beispiel #13
0
 /**
  * Generates the activity log table
  */
 public function getPagerTags()
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $tpl = array();
     try {
         $student = StudentFactory::getStudentByUsername($this->get_user_id(), Term::getSelectedTerm());
     } catch (StudentNotFoundException $e) {
         NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for student: {$this->get_user_id()}");
         $student = null;
     }
     if (is_null($student)) {
         $tpl['ACTEE'] = 'UNKNOWN';
     } else {
         $tpl['ACTEE'] = $student->getProfileLink();
     }
     if (strcmp($this->get_user_id(), $this->get_actor()) == 0) {
         $tpl['ACTOR'] = NULL;
     } else {
         $tpl['ACTOR'] = $this->get_actor();
     }
     $time = $this->get_timestamp();
     $tpl['DATE'] = date('j M Y', $time);
     $tpl['TIME'] = date('g:i a', $time);
     $tpl['ACTIVITY'] = $this->get_text_activity();
     $notes = $this->get_notes();
     if (!is_null($notes)) {
         $tpl['NOTES'] = $notes;
     }
     return $tpl;
 }
 /**
  * Exec
  *
  * @param CommandContext $context
  * @throws InvalidArgumentExection
  */
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do no have permission to run reports.');
     }
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentExection('Missing report id.');
     }
     // Instantiate the report controller with the requested report id
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $report = ReportFactory::getReportById($reportId);
     // Check to make sure the file exists
     if (!file_exists($report->getCsvOutputFilename())) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
         PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
         $reportCmd = CommandFactory::getCommand('ShowReportDetail');
         $reportCmd->setReportClass($report->getClass());
         $reportCmd->redirect();
     }
     $pdf = file_get_contents($report->getCsvOutputFilename());
     // Hoepfully force the browser to open a 'save as' dialogue
     header('Content-Type: text/csv');
     header('Cache-Control: public, must-revalidate, max-age=0');
     // HTTP/1.1
     header('Pragma: public');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Length: ' . strlen($pdf));
     header('Content-Disposition: attachment; filename="' . basename($report->getCsvOutputFilename()) . '";');
     echo $pdf;
     exit;
 }
 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.');
     }
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     $bannerId = $context->get('banner_id');
     $hallId = $context->get('residence_hall_hidden');
     $errorCmd = CommandFactory::getCommand('ShowCheckoutStart');
     // TODO
     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();
     }
     // Everything checks out, so redirect to the form
     $cmd = CommandFactory::getCommand('ShowCheckoutForm');
     // TODO
     $cmd->setBannerId($bannerId);
     $cmd->setHallId($hallId);
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'view_activity_log')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view the activity log.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModClass('hms', 'ActivityLogView.php');
     $actee = $context->get('actee');
     $actor = $context->get('actor');
     $notes = $context->get('notes');
     $exact = $context->get('exact');
     $begin = $context->get('begin');
     $end = $context->get('end');
     if (!is_null($begin) && !is_null($end) && $end <= $begin) {
         unset($_REQUEST['begin_year'], $_REQUEST['begin_month'], $_REQUEST['begin_day'], $_REQUEST['end_year'], $_REQUEST['end_month'], $_REQUEST['end_day']);
         $begin = null;
         $end = null;
         NQ::simple('hms', hms\NotificationView::WARNING, 'Invalid date range. The search results will not be filtered by date.');
     }
     $activityMap = HMS_Activity_Log::getActivityMapping();
     $activities = array();
     foreach ($activityMap as $i => $t) {
         $act = $context->get("a{$i}");
         if (!is_null($act)) {
             $activities[] = $i;
         }
     }
     $activityLogView = new ActivityLogView($actee, $actor, $notes, $exact, $begin, $end, $activities);
     $context->setContent($activityLogView->show());
 }
 public function display()
 {
     // permissions...
     if (!\Current_User::isDeity()) {
         \NQ::simple('intern', NotifyUI::ERROR, 'You cannot edit administrators.');
         return false;
     }
     // set up some stuff for the page template
     $tpl = array();
     // create the list of admins
     $adminList = Admin::getAdminPager();
     // get the list of departments
     $depts = Department::getDepartmentsAssoc();
     // make the form for adding a new admin
     $form = new \PHPWS_Form('add_admin');
     $form->addSelect('department_id', $depts);
     $form->setLabel('department_id', 'Department');
     $form->addText('username');
     $form->setLabel('username', 'Username');
     $form->addCheck('all');
     $form->setLabel('all', 'All Departments');
     $form->addSubmit('submit', 'Create Admin');
     $form->setAction('index.php?module=intern&action=edit_admins');
     $form->addHidden('add', 1);
     // TODO: Add Javascript autocomplete for usernames.
     javascript('jquery');
     javascript('jquery_ui');
     javascriptMod('intern', 'admin');
     $tpl['PAGER'] = $adminList;
     $form->mergeTemplate($tpl);
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_admin.tpl');
 }
 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();
 }
 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $term = $context->get('term');
     // Check if the student has already applied. If so, redirect to the student menu
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     if (isset($result) && $result->getApplicationType == 'offcampus_waiting_list') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already enrolled on the on-campus housing Open Waiting List for this term.');
         $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
         $menuCmd->redirect();
     }
     // Make sure the student agreed to the terms, if not, send them back to the terms & agreement command
     $event = $context->get('event');
     $_SESSION['application_data'] = array();
     // If they haven't agreed, redirect to the agreement
     if (is_null($event) || !isset($event) || $event != 'signing_complete' && $event != 'viewing_complete') {
         $onAgree = CommandFactory::getCommand('ShowOffCampusWaitListApplication');
         $onAgree->setTerm($term);
         $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement');
         $agreementCmd->setTerm($term);
         $agreementCmd->setAgreedCommand($onAgree);
         $agreementCmd->redirect();
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     PHPWS_Core::initModClass('hms', 'ReApplicationOffCampusFormView.php');
     $view = new ReApplicationOffCampusFormView($student, $term);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     if (!isset($term) || is_null($term) || empty($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcApplication', $term);
     // Make sure the RLC application feature is enabled
     if (is_null($feature) || !$feature->isEnabled()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC applications are not avaialable for this term.");
         $cmd->redirect();
     }
     // Check feature's deadlines
     if ($feature->getStartDate() > time()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to fill out an RLC application.");
         $cmd->redirect();
     } else {
         if ($feature->getEndDate() < time()) {
             NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC.");
             $cmd->redirect();
         }
     }
     // Get the Student object
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
     $view = new RlcApplicationPage1View($context, $student);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve/deny RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     // Remove assignment
     $assignment = HMS_RLC_Assignment::getAssignmentById($context->get('assignId'));
     $rlcName = $assignment->getRlcName();
     $rlcApp = $assignment->getApplication();
     if (!is_null($assignment)) {
         $assignment->delete();
     } else {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not find an RLC assignment with that id.');
     }
     HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_RLC_UNASSIGN, Current_User::getUsername(), "Removed from {$rlcName}");
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Removed from RLC');
     // Deny application
     $rlcApp->denied = 1;
     $rlcApp->save();
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC Application denied');
     HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_DENIED_RLC_APPLICATION, Current_User::getUsername(), 'RLC Application Denied');
     $context->goBack();
 }
 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();
 }
 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)
 {
     // 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)
 {
     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();
 }
Beispiel #27
0
 public function show()
 {
     $tpl = array();
     if ($this->halls == NULL) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There are no halls available for the selected term.');
         $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
         $cmd->redirect();
     }
     $tpl['TITLE'] = $this->title;
     $tpl['TERM'] = Term::getPrintableSelectedTerm();
     javascript('jquery');
     javascript('modules/hms/select_floor');
     # Setup the form
     $form = new PHPWS_Form();
     $this->onSelectCmd->initForm($form);
     $form->setMethod('get');
     $form->addDropBox('residence_hall', $this->halls);
     $form->setLabel('residence_hall', 'Residence hall');
     $form->setMatch('residence_hall', 0);
     $form->setClass('residence_hall', 'form-control');
     $form->addDropBox('floor', array(0 => ''));
     $form->setLabel('floor', 'Floor');
     $form->setClass('floor', 'form-control');
     $form->addSubmit('submit_button', 'Select');
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     Layout::addPageTitle("Select Floor");
     return PHPWS_Template::process($tpl, 'hms', 'admin/select_floor.tpl');
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     Layout::addPageTitle("RLC Application Review");
     $tags = array();
     if (UserStatus::isAdmin()) {
         $menuCmd = CommandFactory::getCommand('ShowAssignRlcApplicants');
         $tags['MENU_LINK'] = $menuCmd->getURI();
     } else {
         $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
         $tags['MENU_LINK'] = $menuCmd->getURI();
     }
     $tags['FULL_NAME'] = $this->student->getFullName();
     $tags['STUDENT_TYPE'] = $this->student->getPrintableType();
     $tags['TERM'] = Term::toString($this->application->getTerm());
     $appType = $this->application->getApplicationType();
     if ($appType == RLC_APP_FRESHMEN) {
         $tags['APPLICATION_TYPE'] = 'Freshmen';
     } else {
         if ($appType == RLC_APP_RETURNING) {
             $tags['APPLICATION_TYPE'] = 'Re-application';
         }
     }
     $rlcs = HMS_Learning_Community::getRlcList();
     $tags['FIRST_CHOICE'] = $rlcs[$this->application->rlc_first_choice_id];
     if (isset($this->application->rlc_second_choice_id)) {
         $tags['SECOND_CHOICE'] = $rlcs[$this->application->rlc_second_choice_id];
     }
     if (isset($this->application->rlc_third_choice_id)) {
         $tags['THIRD_CHOICE'] = $rlcs[$this->application->rlc_third_choice_id];
     }
     $tags['WHY_SPECIFIC'] = $this->application->why_specific_communities;
     $tags['STRENGTHS_AND_WEAKNESSES'] = $this->application->strengths_weaknesses;
     $tags['WHY_FIRST_CHOICE'] = $this->application->rlc_question_0;
     if (isset($this->application->rlc_second_choice_id)) {
         $tags['WHY_SECOND_CHOICE'] = $this->application->rlc_question_1;
     }
     if (isset($this->application->rlc_second_choice_id)) {
         $tags['WHY_THIRD_CHOICE'] = $this->application->rlc_question_2;
     }
     // If this application is denied and the person logged in is an admin, show a warning
     if ($this->application->isDenied() && UserStatus::isAdmin()) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been denied.');
     }
     // Show options depending of status of application.
     if (UserStatus::isAdmin() && Current_User::allow('hms', 'approve_rlc_applications')) {
         if (!$this->application->denied && !HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), Term::getSelectedTerm())) {
             // Approve application for the community selected from dropdown
             $approvalForm = $this->getApprovalForm();
             $approvalForm->mergeTemplate($tags);
             $tags = $approvalForm->getTemplate();
             // Deny application
             $tags['DENY_APP'] = $this->getDenialLink();
         }
     }
     return PHPWS_Template::process($tags, 'hms', 'student/rlc_application.tpl');
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $term = $context->get('term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowReApplication');
     $errorCmd->setTerm($term);
     $depositAgreed = $context->get('deposit_check');
     if (is_null($depositAgreed)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must check the box indicating you understand the License Contract deposit fees.');
         $errorCmd->redirect();
     }
     // Data sanity checking
     $doNotCall = $context->get('do_not_call');
     $number = $context->get('number');
     if (is_null($doNotCall)) {
         // do not call checkbox was not selected, so check the number
         if (is_null($number)) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.');
             $errorCmd->redirect();
         }
     }
     //$mealPlan = $context->get('meal_plan');
     /* Emergency Contact Sanity Checking */
     $emergencyName = $context->get('emergency_contact_name');
     $emergencyRelationship = $context->get('emergency_contact_relationship');
     $emergencyPhone = $context->get('emergency_contact_phone');
     $emergencyEmail = $context->get('emergency_contact_email');
     if (empty($emergencyName) || empty($emergencyRelationship) || empty($emergencyPhone) || empty($emergencyEmail)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the emergency contact person information.');
         $errorCmd->redirect();
     }
     /* Missing Persons Sanity Checking */
     $missingPersonName = $context->get('missing_person_name');
     $missingPersonRelationship = $context->get('missing_person_relationship');
     $missingPersonPhone = $context->get('missing_person_phone');
     $missingPersonEmail = $context->get('missing_person_email');
     if (empty($missingPersonName) || empty($missingPersonRelationship) || empty($missingPersonPhone) || empty($missingPersonEmail)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please complete all of the missing persons contact information.');
         $errorCmd->redirect();
     }
     $specialNeed = $context->get('special_need');
     if (isset($specialNeed)) {
         $onSubmitCmd = CommandFactory::getCommand('ReApplicationFormSave');
         $onSubmitCmd->loadContext($context);
         $onSubmitCmd->setTerm($term);
         $specialNeedCmd = CommandFactory::getCommand('ShowSpecialNeedsForm');
         $specialNeedCmd->setTerm($term);
         $specialNeedCmd->setVars($context->getParams());
         $specialNeedCmd->setOnSubmitCmd($onSubmitCmd);
         $specialNeedCmd->redirect();
     } else {
         $reviewCmd = CommandFactory::getCommand('ReApplicationFormSave');
         $reviewCmd->setTerm($term);
         $reviewCmd->loadContext($context);
         $reviewCmd->redirect();
     }
 }
Beispiel #30
0
 function redirect()
 {
     $path = $this->getURI();
     NQ::close();
     header('HTTP/1.1 303 See Other');
     header("Location: {$path}");
     Events::quit();
 }