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) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'select_term')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do no have permission to select other terms.'); } if (UserStatus::isGuest()) { $context->goBack(); } if (!isset($this->term)) { $this->term = $context->get('term'); } Term::setSelectedTerm($this->term); $context->goBack(); }
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(); }
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) { 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) { if (!Current_User::allow('hms', 'search')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to search for students.'); } PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'StudentProfile.php'); $username = $context->get('username'); $bannerId = $context->get('bannerId'); $term = Term::getSelectedTerm(); try { if (isset($bannerId)) { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } else { $student = StudentFactory::getStudentByUsername($username, $term); } } catch (InvalidArgumentException $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); /* $cmd = CommandFactory::getCommand('ShowStudentSearch'); $cmd->setUsername($userid); $cmd->redirect(); */ $context->goBack(); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage()); /* $cmd = CommandFactory::getCommand('ShowStudentSearch'); $cmd->setUsername($userid); $cmd->redirect(); */ $context->goBack(); } $profile = new StudentProfile($student, $term); $context->setContent($profile->getProfileView()->show()); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'RlcApplicationReView.php'); $application = new HMS_RLC_Application($context->get('appId')); if (is_null($application->username)) { NQ::simple('hms', hms\NotificationView::ERROR, 'There is no RLC application available with that id.'); $context->goBack(); } // This is used both on the admin side and on the student side, so the permission check is a bit more complex if (UserStatus::isAdmin() && !Current_User::allow('view_rlc_applications') || UserStatus::isUser() && $application->getUsername() != UserStatus::getUsername()) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to view this RLC application.'); } try { $student = StudentFactory::getStudentByUsername($application->username, $application->term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Unknown student.'); $context->goBack(); } $view = new RlcApplicationReView($student, $application); $context->setContent($view->show()); }
public function execute(CommandContext $context) { $username = $context->get('username'); $note = $context->get('note'); if (!isset($username) || empty($username)) { throw new InvalidArgumentException('Missing username'); } if (!isset($note) || empty($note)) { throw new InvalidArgumentException('No text was provided for the note.'); } PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($username, ACTIVITY_ADD_NOTE, UserStatus::getUsername(), $note); # Redirect back to whereever the user came from $context->goBack(); }
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_Application.php'); $app = HMS_RLC_Application::getApplicationById($context->get('applicationId')); $app->denied = 1; $app->save(); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($app->username, 28, Current_User::getUsername(), 'Application Denied'); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application denied.'); $context->goBack(); }
public function execute(CommandContext $context) { if (!Current_User::allow('withdrawn_search')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to makr applications withdrawn.'); } $id = $context->get('appId'); if (!isset($id) || is_null($id)) { throw new InvalidArugumentException('Missing application id.'); } PHPWS_Core::initModclass('hms', 'HousingApplicationFactory.php'); $app = HousingApplicationFactory::getApplicationById($context->get('appId')); $app->setWithdrawn(1); $app->save(); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application successfully marked as withdrawn.'); $context->goBack(); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to enable/disable the Banner queue.'); } if (is_null($this->term)) { $this->term = $context->get('term'); } $term = $this->term; if (is_null($term)) { throw new InvalidArgumentException('No term was specified to DisableBannerQueue'); } $term = new Term($term); $term->setBannerQueue(TRUE); $term->save(); NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been enabled for ' . Term::toString($term->term) . '.'); CommandContext::goBack(); }
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(); // Check role-based permissions for list of hall or all halls // TODO (for now just listing all halls) PHPWS_Core::initModClass('hms', 'ResidenceHallFactory.php'); $halls = ResidenceHallFactory::getHallNamesAssoc($term); if (!isset($halls) || count($halls) < 1) { NQ::simple('hms', hms\NotificationView::ERROR, 'No residence halls are setup for this term, so the check-in cannot be accessed.'); $context->goBack(); } PHPWS_Core::initModClass('hms', 'CheckinStartView.php'); $view = new CheckinStartView($halls, $term); $context->setContent($view->show()); }
public function execute(CommandContext $context) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'email_rlc_rejections')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to send RLC rejections.'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); PHPWS_Core::initModClass('hms', 'Term.php'); $term = Term::getSelectedTerm(); $deniedApps = HMS_RLC_Application::getNonNotifiedDeniedApplicantsByTerm($term); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); $email = new HMS_Email(); foreach ($deniedApps as $app) { $student = StudentFactory::getStudentByUsername($app['username'], $term); $email->sendRlcApplicationRejected($student, $term); $application = HMS_RLC_Application::getApplicationById($app['id']); $application->setDeniedEmailSent(1); $application->save(); } NQ::Simple('hms', hms\NotificationView::SUCCESS, 'RLC rejection emails sent.'); $context->goBack(); }
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(); }