/** * (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(); }
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) { $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) { 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(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', '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 (!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 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) { 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) { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php'); $requestId = $context->get('requestId'); $mealPlan = $context->get('mealPlan'); $errorCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest'); $errorCmd->setRequestId($requestId); $errorCmd->setMealPlan($mealPlan); // 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(); } // Check for a meal plan if (!isset($mealPlan) || $mealPlan == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a meal plan.'); $errorCmd->redirect(); } $term = PHPWS_Settings::get('hms', 'lottery_term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); // Update the meal plan field on the application $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term); $app->setMealPlan($mealPlan); try { $app->save(); } catch (Exception $e) { PHPWS_Error::log('hms', $e->getMessage()); NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.'); $errorCmd->redirect(); } // Try to actually make the assignment PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); try { HMS_Lottery::confirm_roommate_request(UserStatus::getUsername(), $requestId, $mealPlan); } catch (Exception $e) { PHPWS_Error::log('hms', $e->getMessage()); NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.'); $errorCmd->redirect(); } # Log the fact that the roommate was accepted and successfully assigned HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_CONFIRMED_ROOMMATE, UserStatus::getUsername(), "Captcha: \"{$captcha}\""); // Check for an RLC membership and update status if necessary // If this student was an RLC self-select, update the RLC memberhsip state $rlcAssignment = RlcMembershipFactory::getMembership($student, $term); if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment)); } $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId); $successCmd = CommandFactory::getCommand('LotteryShowConfirmedRoommateThanks'); $successCmd->setRequestId($requestId); $successCmd->redirect(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
public function onEnter() { PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); $application = $this->rlcAssignment->getApplication(); $term = $application->getTerm(); $username = $application->getUsername(); $community = $this->rlcAssignment->getRlc(); $student = StudentFactory::getStudentByUsername($username, $term); HMS_Email::sendRlcInviteEmail($student, $community, $term, $this->respondByTimestamp); HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_RLC_INVITE_SENT, UserStatus::getUsername()); }
public function execute(CommandContext $context) { $term = $context->get('term'); if (!isset($term)) { throw new InvalidArgumentException('Missing term!'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentConfirmedState.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentDeclinedState.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername(UserStatus::getUsername(), $term); $rlcApplication = $rlcAssignment->getApplication(); $student = StudentFactory::getStudentByUsername($rlcApplication->getUsername(), $rlcApplication->getTerm()); $acceptStatus = $context->get('acceptance'); $termsCheck = $context->get('terms_cond'); if ($acceptStatus == 'accept' && !isset($termsCheck)) { // Student accepted the invite, but didn't check the terms/conditions box $errorCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $errorCmd->setTerm($term); NQ::simple('hms', hms\NotificationView::ERROR, 'Please check the box indicating that you agree to the learning communitiy terms and conditions.'); $errorCmd->redirect(); } else { if ($acceptStatus == 'accept' && isset($termsCheck)) { // Student accepted the invite and checked the terms/conditions box $rlcAssignment->changeState(new RlcAssignmentConfirmedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>accepted</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_ACCEPT_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } else { if ($acceptStatus == 'decline') { // student declined $rlcAssignment->changeState(new RlcAssignmentDeclinedState($rlcAssignment)); NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have <strong>declined</strong> your Residential Learning Community invitation.'); // Log this! HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_DECLINE_RLC_INVITE, UserStatus::getUsername(), $rlcAssignment->getRlcName()); $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } else { // Didn't choose $errorCmd = CommandFactory::getCommand('ShowAcceptRlcInvite'); $errorCmd->setTerm($term); NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose to either accept or decline your learning community invitation.'); $errorCmd->redirect(); } } } $context->setContent('confirmed or denied'); }
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) { $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 (!UserStatus::isUser()) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to request a roommate.'); } $term = $context->get('term'); $requestee = $context->get('username'); $requestor = UserStatus::getUsername(); if (empty($term)) { throw new InvalidArgumentException('Term was not specified.'); } $err = CommandFactory::getCommand('ShowRequestRoommate'); $err->setTerm($term); if (empty($requestee)) { NQ::simple('hms', hms\NotificationView::WARNING, 'You did not enter a username.'); $err->redirect(); } if (!PHPWS_Text::isValidInput($requestee)) { NQ::simple('hms', hms\NotificationView::WARNING, 'You entered an invalid username. Please use letters and numbers only.'); $err->redirect(); } // Attempt to Create Roommate Request PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $request = new HMS_Roommate(); try { $request->request($requestor, $requestee, $term); } catch (RoommateCompatibilityException $rre) { NQ::simple('hms', hms\NotificationView::WARNING, $rre->getMessage()); $err->redirect(); } $request->save(); $endTime = $request->calc_req_expiration_date(); $expirationMsg = " expires on " . date('m/d/Y h:i:s a', $endTime); HMS_Activity_Log::log_activity($requestee, ACTIVITY_REQUESTED_AS_ROOMMATE, $requestor, "{$requestor} requested {$requestee}" . $expirationMsg); HMS_Activity_Log::log_activity($requestor, ACTIVITY_REQUESTED_AS_ROOMMATE, $requestee, "{$requestor} requested {$requestee}" . $expirationMsg); // Email both parties PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_request_emails($request); // Notify PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $student = StudentFactory::getStudentByUsername($requestee, $term); $name = $student->getName(); $fname = $student->getFirstName(); NQ::simple('hms', hms\NotificationView::SUCCESS, "You have requested {$name} to be your roommate. {$fname} has been emailed, and will need to log into HMS and approve your roommate request."); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $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_Application.php'); $app = HMS_RLC_Application::getApplicationById($context->get('applicationId')); $app->denied = 0; $app->save(); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($app->username, 29, UserStatus::getUsername(), "Application un-denied"); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application un-denied.'); $successCmd = CommandFactory::getCommand('ShowDeniedRlcApplicants'); $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->requestee) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to confirm roommate pairing {$roommate->id}"); } $err = CommandFactory::getCommand('ShowRoommateConfirmAccept'); $err->setRoommateId($id); PHPWS_Core::initCoreClass('Captcha.php'); $verified = Captcha::verify(TRUE); if ($verified === FALSE || is_null($verified)) { NQ::Simple('hms', hms\NotificationView::ERROR, 'Sorry, please try again.'); $err->redirect(); } try { $roommate->confirm(); } catch (RoommateCompatibilityException $rce) { NQ::simple('hms', hms\NotificationView::WARNING, $rce->getMessage()); $err->redirect(); } $roommate->save(); HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_ACCEPTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} accepted request, CAPTCHA: {$verified}"); HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_ACCEPTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} accepted request, CAPTCHA: {$verified}"); // Email both parties PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_confirm_emails($roommate); // Remove any other requests for the requestor HMS_Roommate::removeOutstandingRequests($roommate->requestor, $roommate->term); // Remove any other requests for the requestee HMS_Roommate::removeOutstandingRequests($roommate->requestee, $roommate->term); $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term); $name = $requestor->getFullName(); NQ::Simple('hms', hms\NotificationView::SUCCESS, "You and {$name} are confirmed as roommates."); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $cmd->redirect(); }
/** * Shows filtering options for the log view. The first argument is usually * $_SESSION. The second argument is laid out in the same way, and * specifies default values. If a default value is specified in the second * argument, that option will not appear in the filter; this way, if you're * in the Student Info thing, you can show the activity log for only that * user. */ public static function showFilters($selection = NULL) { PHPWS_Core::initCoreClass('Form.php'); $submitCmd = CommandFactory::getCommand('ShowActivityLog'); $form = new PHPWS_Form(); $submitCmd->initForm($form); $form->setMethod('get'); $form->addText('actor'); $form->setLabel('actor', 'Action Performed By:'); if (isset($selection['actor'])) { $form->setValue('actor', $selection['actor']); } $form->addText('actee'); $form->setLabel('actee', 'Action Affected:'); if (isset($selection['actee'])) { $form->setValue('actee', $selection['actee']); } // "exact" flag $form->addCheck('exact', 'yes'); $form->setMatch('exact', 'yes'); $form->setLabel('exact', 'Exact? '); $form->addText('begin', isset($selection['begin']) ? $selection['begin'] : ''); $form->setClass('begin', 'datepicker'); $form->addText('end', isset($selection['end']) ? $selection['end'] : ''); $form->setClass('end', 'datepicker'); $form->addText('notes'); $form->setLabel('notes', 'Note:'); if (isset($selection['notes'])) { $form->setValue('notes', $selection['notes']); } $activities = HMS_Activity_Log::getActivityMapping(); foreach ($activities as $id => $text) { $name = "a{$id}"; $form->addCheckbox($name); $form->setLabel($name, $text); $form->setMatch($name, isset($selection[$name])); } $form->addSubmit('Refresh'); $tpl = $form->getTemplate(); $tpl['BEGIN_LABEL'] = 'After:'; $tpl['END_LABEL'] = 'Before:'; javascript('jquery'); javascript('modules/hms/activity_log'); return PHPWS_Template::process($tpl, 'hms', 'admin/activity_log_filters.tpl'); }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); $participantId = $context->get('participantId'); // Command for showing the request, redirected to on success/error $cmd = CommandFactory::getCommand('ShowManageRoomChange'); $cmd->setRequestId($requestId); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participant $participant = RoomChangeParticipantFactory::getParticipantById($participantId); // Load the Student $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), $request->getTerm()); // Check permissions. Must be the participant or an admin if (UserStatus::getUsername() != $student->getUsername() && !Current_User::allow('hms', 'admin_approve_room_change')) { throw new PermissionException('You do not have permission to appove this room change.'); } // Check for CAPTCHA if this is the student; admins don't need a CAPTCHA $captchaResult = Captcha::verify(true); if (UserStatus::getUsername() == $student->getUsername() && $captchaResult === false) { // Failed the captcha NQ::simple('hms', hms\NotificationView::ERROR, "You didn't type the magic words correctly. Please try again."); $cmd = CommandFactory::getCommand('ShowRoomChangeRequestApproval'); $cmd->redirect(); } // If there was a captcha, then log the activity if ($captchaResult !== false) { HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_AGREED, UserStatus::getUsername(FALSE), 'Request id: ' . $requestId . ' Captcha: ' . $captchaResult); } // Transition to StudentApproved state $participant->transitionTo(new ParticipantStateStudentApproved($participant, time(), null, UserStatus::getUsername())); // If all students have approved, notify RDs if ($request->isApprovedByAllParticipants()) { HMS_Email::sendRoomChangeCurrRDNotice($request); } // If the student is logged in, redirect to the main menu, other wise go back to the room change management view if (UserStatus::getUsername() == $student->getUsername()) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have agreed to the room change request. You will be notified by email when the reqeust is approved or denied.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->redirect(); } else { $cmd->redirect(); } }
public function process() { // This hack is the most awful hack ever. Fix phpWebSite so that // user logins are logged separately. if (Current_User::isLogged() && !isset($_SESSION['HMS_LOGGED_THE_LOGIN'])) { $username = strtolower(Current_User::getUsername()); HMS_Activity_Log::log_activity($username, ACTIVITY_LOGIN, $username, NULL); $_SESSION['HMS_LOGGED_THE_LOGIN'] = $username; } if (!Current_User::isLogged() && $this->context->get('action') != 'ShowFrontPage') { NQ::simple('hms', hms\NotificationView::ERROR, 'You must be logged in to do that.'); $action = 'ShowFrontPage'; } else { $action = $this->context->get('action'); } $cmd = CommandFactory::getCommand($action); if (HMS_DEBUG) { $cmd->execute($this->context); } else { try { $cmd->execute($this->context); } catch (PermissionException $p) { NQ::Simple('hms', hms\NotificationView::ERROR, 'You do not have permission to perform that action. If you believe this is an error, please contact University Housing.'); $nv = new hms\NotificationView(); $nv->popNotifications(); Layout::add($nv->show()); } catch (Exception $e) { try { $message = $this->formatException($e); NQ::Simple('hms', hms\NotificationView::ERROR, 'An internal error has occurred, and the authorities have been notified. We apologize for the inconvenience.'); $this->emailError($message); $nv = new hms\NotificationView(); $nv->popNotifications(); Layout::add($nv->show()); } catch (Exception $e) { $message2 = $this->formatException($e); echo "HMS has experienced a major internal error. Attempting to email an admin and then exit."; $message = "Something terrible has happened, and the exception catch-all threw an exception.\n\nThe first exception was:\n\n{$message}\n\nThe second exception was:\n\n{$message2}"; mail(FROM_ADDRESS, 'A Major HMS Error Has Occurred', $message); exit; } } } }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $this->setAppId($context->get('applicationId')); if (!isset($this->applicationId) || is_null($this->applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } $application = HousingApplicationFactory::getApplicationById($this->applicationId); $application->setCancelled(0); $application->setCancelledBy(null); $application->setCancelledReason(null); $application->setCancelledOn(null); $application->save(); HMS_Activity_Log::log_activity($application->getUsername(), ACTIVITY_REINSTATE_APPLICATION, UserStatus::getUsername()); $returnCmd = CommandFactory::getCommand('ShowStudentProfile'); $returnCmd->setBannerId($application->getBannerId()); $returnCmd->redirect(); }
public function execute(CommandContext $context) { // Get input $requestId = $context->get('requestId'); $participantId = $context->get('participantId'); // Load the request $request = RoomChangeRequestFactory::getRequestById($requestId); // Load the participant $participant = RoomChangeParticipantFactory::getParticipantById($participantId); // Load the Student $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), $request->getTerm()); // Check permissions. Must be the participant or an admin if (UserStatus::getUsername() != $student->getUsername() && !Current_User::allow('hms', 'admin_approve_room_change')) { throw new PermissionException('You do not have permission to decline this room change.'); } // Check for CAPTCHA if this is the student; admins don't need a CAPTCHA $captchaResult = Captcha::verify(true); if ($captchaResult === false) { // Failed the captcha NQ::simple('hms', hms\NotificationView::ERROR, "You didn't type the magic words correctly. Please try again."); $cmd = CommandFactory::getCommand('ShowRoomChangeRequestApproval'); $cmd->redirect(); } HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_DECLINE, UserStatus::getUsername(FALSE), 'Request id: ' . $requestId . ' Captcha: ' . $captchaResult); // Transition request to cancelled status $request->transitionTo(new RoomChangeStateCancelled($request, time(), null, UserStatus::getUsername())); // Transition all participants to cancelled // TODO... Do this in the cancelled transition? $participants = $request->getParticipants(); foreach ($participants as $p) { $p->transitionTo(new ParticipantStateCancelled($p, time(), null, UserStatus::getUsername())); } // TODO Notify everyone that the request was cancelled NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have declined the room change request.'); $menuCmd = CommandFactory::getCommand('ShowStudentMenu'); $menuCmd->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 && $username != $roommate->requestee) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}"); } $err = CommandFactory::getCommand('ShowRoommateBreak'); $err->setRoommateId($id); PHPWS_Core::initCoreClass('Captcha.php'); $verified = Captcha::verify(TRUE); if ($verified === FALSE || is_null($verified)) { NQ::Simple('hms', hms\NotificationView::ERROR, 'Sorry, please try again.'); $err->redirect(); } $roommate->delete(); $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term); HMS_Activity_Log::log_activity($other->getUsername(), ACTIVITY_STUDENT_BROKE_ROOMMATE, $username, "{$username} broke pairing, CAPTCHA: {$verified}"); HMS_Activity_Log::log_activity($username, ACTIVITY_STUDENT_BROKE_ROOMMATE, $other->getUsername(), "{$username} broke pairing, CAPTCHA: {$verified}"); // Email both parties PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_break_emails($roommate, $username); $name = $other->getFullName(); NQ::Simple('hms', hms\NotificationView::SUCCESS, "You have removed your roommate request for {$name}."); $cmd = CommandFactory::getCommand('ShowStudentMenu'); $cmd->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.'); } */ PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Floor.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Permission.php'); // Sanity checks if (is_null($context->get('hall')) && is_null($context->get('floor'))) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must select a hall or floor 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') ? true : false; $from = $anonymous && Current_User::allow('hms', 'anonymous_notifications') ? FROM_ADDRESS : Current_User::getUsername() . '@' . DOMAIN_NAME; $halls = $context->get('hall'); $floors = $context->get('floor'); if (empty($subject)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the subject line of the email.'); $cmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $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 = CommandFactory::getCommand('ShowHallNotificationEdit'); $cmd->loadContext($context); $cmd->redirect(); } } //Consider using a batch process instead of doing this this inline // Log that this is happening if ($anonymous) { HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_ANON_NOTIFICATION_SENT, Current_User::getUsername()); } else { HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_NOTIFICATION_SENT, Current_User::getUsername()); } //load the floors foreach ($floors as $key => $floor_id) { $floors[$key] = new HMS_Floor($floor_id); } // TODO accurate logging //HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_HALL_NOTIFIED_ANONYMOUSLY, Current_User::getUsername(), $hall->hall_name); //HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_HALL_NOTIFIED, Current_User::getUsername(), $hall->hall_name); $floorObj = array(); //load the halls and add floors that aren't already present, if they have js enabled should be zero foreach ($halls as $hall) { $hallObj = new HMS_Residence_Hall($hall); $hallFloors = $hallObj->get_floors(); //if the hall has zero floors, skip it if (!is_array($hallFloors)) { continue; } foreach ($hallFloors as $hallFloor) { if (!empty($floors)) { foreach ($floors as $floor) { if ($hallFloor->id == $floor->id) { break; } } } if (!in_array($hallFloor, $floors)) { $floorObj[] = $hallFloor; } } } if (!is_array($floorObj)) { $floorObj = array(); } if (!is_array($floors)) { $floors = array(); } $floorObj = array_merge($floorObj, $floors); $permission = new HMS_Permission(); foreach ($floorObj as $floor) { if (!$permission->verify(Current_User::getUsername(), $floor, 'email') && !$permission->verify(Current_User::getUsername(), $floor->get_parent(), 'email') && !Current_User::allow('hms', 'email_all')) { continue; } /** $rooms = $floor->get_rooms(); foreach($rooms as $room){ $students = $room->get_assignees(); foreach($students as $student){ $people[] = $student->getUsername(); HMS_Email::send_email($student->getUsername() . '@appstate.edu', $from, $subject, $body); } } */ $students = $floor->getUsernames(); foreach ($students as $student) { HMS_Email::send_email($student . '@' . DOMAIN_NAME, $from, $subject, $body); } HMS_Activity_Log::log_activity(Current_User::getUsername(), $anonymous ? ACTIVITY_FLOOR_NOTIFIED_ANONYMOUSLY : ACTIVITY_FLOOR_NOTIFIED, Current_User::getUsername(), $floor->where_am_i()); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Emails sent successfully!'); $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $cmd->redirect(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $roomId = $context->get('roomId'); $roommates = $context->get('roommates'); $mealPlan = $context->get('mealPlan'); $term = PHPWS_Settings::get('hms', 'lottery_term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $errorCmd = CommandFactory::getCommand('LotteryShowConfirm'); $errorCmd->setRoomId($roomId); $errorCmd->setRoommates($roommates); $errorCmd->setMealPlan($mealPlan); $successCmd = CommandFactory::getCommand('LotteryShowConfirmed'); $successCmd->setRoomId($roomId); PHPWS_Core::initCoreClass('Captcha.php'); $captcha = Captcha::verify(TRUE); // returns the words entered if correct, FALSE otherwise //$captcha = TRUE; if ($captcha === FALSE) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, the words you eneted were incorrect. Please try again.'); $errorCmd->redirect(); } PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php'); $room = new HMS_Room($roomId); // Check for an RLC assignment in the self-select status $rlcAssignment = RlcMembershipFactory::getMembership($student, $term); // Check roommates for validity foreach ($roommates as $bed_id => $username) { // Double check the student is valid try { $roommate = StudentFactory::getStudentByUsername($username, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not a valid student. Please choose a different roommate."); $errorCmd->redirect(); } // Make sure the bed is still empty $bed = new HMS_Bed($bed_id); if ($bed->has_vacancy() != TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Make sure none of the needed beds are reserved if ($bed->is_lottery_reserved()) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Double check the genders are all the same as the person logged in if ($student->getGender() != $roommate->getGender()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // Double check the genders are the same as the room (as long as the room isn't AUTO) if ($room->gender_type != AUTO && $roommate->getGender() != $room->gender_type) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // If this student is an RLC-self-selection, then each roommate must be in the same RLC and in the selfselect-invite state too if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { // This student is an RLC-self-select, so check the roommate's RLC status $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); // Make sure the roommate is a member of the same RLC and is eligible for self-selection if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$roommate} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } // Otherwise (if not RLC members), make sure each roommate is eligible } else { if (HMS_Lottery::determineEligibility($username) !== TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not eligible for assignment."); $errorCmd->redirect(); } } // If this student is a self-select RLC member, then this student must also be a self-select RLC member of the same RLC if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } } } // If the room's gender is 'AUTO' and no one is assigned to it yet, switch it to the student's gender if ($room->gender_type == AUTO && $room->get_number_of_assignees() == 0) { $room->gender_type = $student->getGender(); $room->save(); } // Assign the student to the requested bed $bed_id = array_search(UserStatus::getUsername(), $roommates); // Find the bed id of the student who's logged in try { $result = HMS_Assignment::assignStudent($student, PHPWS_Settings::get('hms', 'lottery_term'), NULL, $bed_id, $mealPlan, 'Confirmed lottery invite', TRUE, ASSIGN_LOTTERY); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error creating your room assignment. Please try again or contact University Housing.'); $errorCmd->redirect(); } // Log the assignment HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOM_CHOSEN, UserStatus::getUsername(), 'Captcha: ' . $captcha); // Update the student's meal plan in the housing application, just for future reference $app = HousingApplication::getApplicationByUser($student->getUsername(), $term); $app->setMealPlan($mealPlan); $app->save(); // If this student was an RLC self-select, update the RLC memberhsip state if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment)); } foreach ($roommates as $bed_id => $username) { // Skip the current user if ($username == $student->getUsername()) { continue; } # Reserve the bed for the roommate $expires_on = time() + INVITE_TTL_HRS * 3600; $bed = new HMS_Bed($bed_id); if (!$bed->lottery_reserve($username, $student->getUsername(), $expires_on)) { NQ::smiple('hms', hms\NotificationView::WARNING, "You were assigned, but there was a problem reserving space for your roommates. Please contact University Housing."); $successCmd->redirect(); } HMS_Activity_Log::log_activity($username, ACTIVITY_LOTTERY_REQUESTED_AS_ROOMMATE, $student->getUsername(), 'Expires: ' . HMS_Util::get_long_date_time($expires_on)); # Invite the selected roommates $roomie = StudentFactory::getStudentByUsername($username, $term); $term = PHPWS_Settings::get('hms', 'lottery_term'); $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::send_lottery_roommate_invite($roomie, $student, $expires_on, $room->where_am_i(), $year); } HMS_Email::send_lottery_assignment_confirmation($student, $room->where_am_i(), $term); $successCmd->redirect(); }
/** * Processes a queued item. This can be something actually queued, * or an immediate processing because the queue is disabled. */ public function process() { PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'SOAP.php'); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $result = null; switch ($this->type) { case BANNER_QUEUE_ASSIGNMENT: $result = $soap->reportRoomAssignment($this->asu_username, $this->term, $this->building_code, $this->bed_code, 'HOME', $this->meal_code); if ($result === TRUE) { HMS_Activity_Log::log_activity($this->asu_username, ACTIVITY_ASSIGNMENT_REPORTED, Current_User::getUsername(), $this->term . ' ' . $this->building_code . ' ' . $this->bed_code . ' ' . 'HOME' . ' ' . $this->meal_code); } break; case BANNER_QUEUE_REMOVAL: // Get the Banner ID from the user name // TODO fix this to use BannerID directly $bannerId = $soap->getBannerId($this->asu_username); $result = $soap->removeRoomAssignment($bannerId, $this->term, $this->building_code, $this->bed_code, $this->percent_refund); if ($result === TRUE) { HMS_Activity_Log::log_activity($this->asu_username, ACTIVITY_REMOVAL_REPORTED, Current_User::getUsername(), $this->term . ' ' . $this->building_code . ' ' . $this->bed_code . ' '); } break; } return $result; }
public function show() { javascript('jquery'); javascript('jquery_ui'); javascriptMod('hms', 'StudentProfile'); $tpl = array(); $tpl['USERNAME'] = $this->student->getUsername(); if (Current_User::allow('hms', 'login_as_student')) { $loginAsStudent = CommandFactory::getCommand('LoginAsStudent'); $loginAsStudent->setUsername($this->student->getUsername()); $tpl['LOGIN_AS_STUDENT_URI'] = $loginAsStudent->getURI(); } $tpl['BANNER_ID'] = $this->student->getBannerId(); $tpl['NAME'] = $this->student->getFullName(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $tpl['GENDER'] = $this->student->getPrintableGender(); $tpl['DOB'] = $this->student->getDOB(); if (strtotime($this->student->getDOB()) < strtotime("-25 years")) { NQ::simple('hms', hms\NotificationView::WARNING, 'Student is 25 years old or older!'); } $tpl['CLASS'] = $this->student->getPrintableClass(); $tpl['TYPE'] = $this->student->getPrintableType(); $tpl['STUDENT_LEVEL'] = $this->student->getPrintableLevel(); $tpl['ADMISSION_DECISION'] = $this->student->getAdmissionDecisionCode(); $tpl['INTERNATIONAL'] = $this->student->isInternational() ? 'Yes' : 'No'; $tpl['HONORS'] = $this->student->isHonors() ? 'Yes' : 'No'; $tpl['TEACHING_FELLOW'] = $this->student->isTeachingFellow() ? 'Yes' : 'No'; $tpl['WATAUGA'] = $this->student->isWataugaMember() ? 'Yes' : 'No'; if ($this->student->pinDisabled()) { NQ::simple('hms', hms\NotificationView::WARNING, "This student's PIN is disabled."); } try { $tpl['APPLICATION_TERM'] = Term::toString($this->student->getApplicationTerm()); } catch (InvalidTermException $e) { NQ::simple('hms', hms\NotificationView::WARNING, 'Application term is bad or missing.'); $tpl['APPLICATION_TERM'] = 'WARNING: Application Term is bad or missing: "' . $this->student->getApplicationTerm() . '"'; } /***************** * Phone Numbers * *****************/ $phoneNumberList = $this->student->getPhoneNumberList(); if (isset($phoneNumberList) && !is_null($phoneNumberList)) { foreach ($this->student->getPhoneNumberList() as $phone_number) { $tpl['phone_number'][] = array('NUMBER' => $phone_number); } } /************* * Addresses * *************/ foreach ($this->student->getAddressList() as $address) { //If it's not a PS or PR address, skip it if ($address->atyp_code != 'PR' && $address->atyp_code != 'PS') { continue; } switch ($address->atyp_code) { case 'PS': $addr_type = 'Student Address'; break; case 'PR': $addr_type = 'Permanent Residence Address'; break; default: $addr_type = 'Unknown-type address'; } $addr_array = array(); $addr_array['ADDR_TYPE'] = $addr_type; $addr_array['ADDRESS_L1'] = $address->line1; if (isset($address->line2)) { $addr_array['ADDRESS_L2'] = $address->line2; } if (isset($address->line3)) { $addr_array['ADDRESS_L3'] = $address->line3; } $addr_array['CITY'] = $address->city; $addr_array['STATE'] = $address->state; $addr_array['ZIP'] = $address->zip; $tpl['addresses'][] = $addr_array; } /************** * Assignment * **************/ if (!is_null($this->assignment)) { $reassignCmd = CommandFactory::getCommand('ShowAssignStudent'); $reassignCmd->setUsername($this->student->getUsername()); $unassignCmd = CommandFactory::getCommand('ShowUnassignStudent'); $unassignCmd->setUsername($this->student->getUsername()); $tpl['ASSIGNMENT'] = $this->assignment->where_am_i(true) . ' ' . $reassignCmd->getLink('Reassign') . ' ' . $unassignCmd->getLink('Unassign'); } else { $assignCmd = CommandFactory::getCommand('ShowAssignStudent'); $assignCmd->setUsername($this->student->getUsername()); $tpl['NOT_ASSIGNED'] = $assignCmd->getURI(); } /************* * Roommates *************/ if (isset($this->roommates) && !empty($this->roommates)) { // Remember, student can only have one confirmed or pending request // but multiple assigned roommates if (isset($this->roommates['PENDING'])) { $tpl['pending'][]['ROOMMATE'] = $this->roommates['PENDING']; } else { if (isset($this->roommates['CONFIRMED'])) { $tpl['confirmed'][]['ROOMMATE'] = $this->roommates['CONFIRMED']; } else { if (isset($this->roommates['NO_BED_AVAILABLE'])) { $tpl['error_status'][]['ROOMMATE'] = $this->roommates['NO_BED_AVAILABLE']; } else { if (isset($this->roommates['MISMATCHED_ROOMS'])) { $tpl['error_status'][]['ROOMMATE'] = $this->roommates['MISMATCHED_ROOMS']; } } } } if (isset($this->roommates['ASSIGNED'])) { foreach ($this->roommates['ASSIGNED'] as $roommate) { $tpl['assigned'][]['ROOMMATE'] = $roommate; } } } /************** * RLC Status * *************/ $rlc_names = RlcFactory::getRlcList(Term::getSelectedTerm()); $rlc_assignment = HMS_RLC_Assignment::getAssignmentByUsername($this->student->getUsername(), Term::getSelectedTerm()); $rlc_application = HMS_RLC_Application::getApplicationByUsername($this->student->getUsername(), Term::getSelectedTerm()); if (!is_null($rlc_assignment)) { $tpl['RLC_STATUS'] = "This student is assigned to: " . $rlc_names[$rlc_assignment->rlc_id]; } else { if (!is_null($rlc_application)) { $rlcViewCmd = CommandFactory::getCommand('ShowRlcApplicationReView'); $rlcViewCmd->setAppId($rlc_application->getId()); $tpl['RLC_STATUS'] = "This student has a " . $rlcViewCmd->getLink('pending RLC application') . "."; } else { $tpl['RLC_STATUS'] = "This student is not in a Learning Community and has no pending application."; } } /************************* * Re-application status * *************************/ $reapplication = HousingApplicationFactory::getAppByStudent($this->student, Term::getSelectedTerm()); # If this is a re-application, then check the special interest group status # TODO: incorporate all this into the LotteryApplication class if ($reapplication !== FALSE && $reapplication instanceof LotteryApplication) { if (isset($reapplication->special_interest) && !is_null($reapplication->special_interest) && !empty($reapplication->special_interest)) { # Student has been approved for a special group # TODO: format the name according to the specific group (sororities, etc) $tpl['SPECIAL_INTEREST'] = $reapplication->special_interest . '(confirmed)'; } else { # Check if the student selected a group on the application, but hasn't been approved if (!is_null($reapplication->sorority_pref)) { $tpl['SPECIAL_INTEREST'] = $reapplication->sorority_pref . ' (pending)'; //}else if($reapplication->tf_pref == 1){ //$tpl['SPECIAL_INTEREST'] = 'Teaching Fellow (pending)'; } else { if ($reapplication->wg_pref == 1) { $tpl['SPECIAL_INTEREST'] = 'Watauga Global (pending)'; } else { if ($reapplication->honors_pref == 1) { $tpl['SPECIAL_INTEREST'] = 'Honors (pending)'; } else { if ($reapplication->rlc_interest == 1) { $tpl['SPECIAL_INTEREST'] = 'RLC (pending)'; } else { # Student didn't select anything $tpl['SPECIAL_INTEREST'] = 'No'; } } } } } } else { # Not a re-application, so can't have a special group $tpl['SPECIAL_INTEREST'] = 'No'; } /****************** * Housing Waiver * *************/ $tpl['HOUSING_WAIVER'] = $this->student->housingApplicationWaived() ? 'Yes' : 'No'; if ($this->student->housingApplicationWaived()) { NQ::simple('hms', hms\NotificationView::WARNING, "This student's housing application has been waived for this term."); } /**************** * Applications * *************/ $appList = new ProfileHousingAppList($this->applications); $tpl['APPLICATIONS'] = $appList->show(); /********* * Assignment History * *********/ $historyArray = StudentAssignmentHistory::getAssignments($this->student->getBannerId()); $historyView = new StudentAssignmentHistoryView($historyArray); $tpl['HISTORY'] = $historyView->show(); /********** * Checkins */ $checkins = CheckinFactory::getCheckinsForStudent($this->student); $checkinHistory = new CheckinHistoryView($checkins); $tpl['CHECKINS'] = $checkinHistory->show(); /********* * Notes * *********/ $addNoteCmd = CommandFactory::getCommand('AddNote'); $addNoteCmd->setUsername($this->student->getUsername()); $form = new PHPWS_Form('add_note_dialog'); $addNoteCmd->initForm($form); $form->addTextarea('note'); $form->addSubmit('Add Note'); /******** * Logs * ********/ $everything_but_notes = HMS_Activity_Log::get_activity_list(); unset($everything_but_notes[array_search(ACTIVITY_ADD_NOTE, $everything_but_notes)]); if (Current_User::allow('hms', 'view_activity_log') && Current_User::allow('hms', 'view_student_log')) { PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); $activityLogPager = new ActivityLogPager($this->student->getUsername(), null, null, true, null, null, $everything_but_notes, true, 10); $activityNotePager = new ActivityLogPager($this->student->getUsername(), null, null, true, null, null, array(0 => ACTIVITY_ADD_NOTE), true, 10); $tpl['LOG_PAGER'] = $activityLogPager->show(); $tpl['NOTE_PAGER'] = $activityNotePager->show(); $logsCmd = CommandFactory::getCommand('ShowActivityLog'); $logsCmd->setActeeUsername($this->student->getUsername()); $tpl['LOG_PAGER'] .= $logsCmd->getLink('View more'); $notesCmd = CommandFactory::getCommand('ShowActivityLog'); $notesCmd->setActeeUsername($this->student->getUsername()); $notesCmd->setActivity(array(0 => ACTIVITY_ADD_NOTE)); $tpl['NOTE_PAGER'] .= $notesCmd->getLink('View more'); } $tpl = array_merge($tpl, $form->getTemplate()); // TODO logs // TODO tabs Layout::addPageTitle("Student Profile"); return PHPWS_Template::process($tpl, 'hms', 'admin/StudentProfile.tpl'); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'exception/InvalidTermException.php'); $term = $context->get('term'); $username = UserStatus::getUsername(); $student = StudentFactory::getStudentByUsername($username, $term); $sem = Term::getTermSem($term); // Check for an existing application and delete it $app_result = HousingApplication::checkForApplication($username, $term); // If there's an existing housing application, handle deleting it if ($app_result !== FALSE) { switch ($sem) { case TERM_SPRING: $application = new SpringApplication($app_result['id']); break; case TERM_SUMMER1: case TERM_SUMMER2: $application = new SummerApplication($app_result['id']); break; case TERM_FALL: $application = new FallApplication($app_result['id']); break; default: throw new InvalidTermException('Invalid term specified.'); } // Save the old created on dates for re-use on new application $oldCreatedOn = $application->getCreatedOn(); $oldCreatedBy = $application->getCreatedBy(); $application->delete(); } switch ($sem) { case TERM_FALL: $appType = 'fall'; break; case TERM_SPRING: $appType = 'spring'; break; case TERM_SUMMER1: case TERM_SUMMER2: $appType = 'summer'; break; default: throw new Exception('Unknown application type'); } $application = HousingApplicationFactory::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType); // If old created dates exist, use them as the 'created on' dates if (isset($oldCreatedOn)) { $application->setCreatedOn($oldCreatedOn); $application->setCreatedBy($oldCreatedBy); } $application->setCancelled(0); // Hard code a summer meal option for all summer applications. // Application for other terms use whatever the student selected if ($sem == TERM_SUMMER1 || $sem == TERM_SUMMER2) { $application->setMealPlan(BANNER_MEAL_5WEEK); } $result = $application->save(); if ($result == TRUE) { // Log the fact that the application was submitted PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($username, ACTIVITY_SUBMITTED_APPLICATION, $username); try { // report the application to banner; $application->reportToBanner(); } catch (Exception $e) { // ignore any errors reporting this to banner, they'll be logged and admins notified // we've saved the student's application locally, so it's ok if this doesn't work } // Send the email confirmation PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_hms_application_confirmation($student, $application->getTerm()); } $friendly_term = Term::toString($application->getTerm()); NQ::simple('hms', hms\NotificationView::SUCCESS, "Your application for {$friendly_term} was successfully processed! You will receive an email confirmation in the next 24 hours."); PHPWS_Core::initModClass('hms', 'applicationFeature/RlcApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcReg = new RLCApplicationRegistration(); if (ApplicationFeature::isEnabledForStudent($rlcReg, $term, $student) && HMS_RLC_Application::checkForApplication($student->getUsername(), $term) == FALSE && $application->rlc_interest == 1) { $rlcCmd = CommandFactory::getCommand('ShowRlcApplicationPage1View'); $rlcCmd->setTerm($term); $rlcCmd->redirect(); } else { $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); } }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); PHPWS_Core::initModClass('hms', 'exception/InvalidTermException.php'); $term = $context->get('term'); $username = UserStatus::getUsername(); $student = StudentFactory::getStudentByUsername($username, $term); $sem = Term::getTermSem($term); // Check for an existing application and load it $application = NULL; $app_result = HousingApplication::checkForApplication($username, $term); if ($app_result !== FALSE) { switch ($sem) { case TERM_SPRING: $application = new SpringApplication($app_result['id']); break; case TERM_SUMMER1: case TERM_SUMMER2: $application = new SummerApplication($app_result['id']); break; case TERM_FALL: $application = new FallApplication($app_result['id']); break; default: throw new InvalidTermException('Invalid term specified.'); } } else { // TODO What if there is no application found? Should I cry? // Execution shouldn't be able to make it this far if an application doesn't exist. throw new Exception('No application found.'); } // Update the Emergency Contact and Missing Person information // TODO Sanity check all this new contact information /* Emergency Contact */ $application->setEmergencyContactName($context->get('emergency_contact_name')); $application->setEmergencyContactRelationship($context->get('emergency_contact_relationship')); $application->setEmergencyContactPhone($context->get('emergency_contact_phone')); $application->setEmergencyContactEmail($context->get('emergency_contact_email')); /* Emergency Medical Condition */ $application->setEmergencyMedicalCondition($context->get('emergency_medical_condition')); /* Missing Person */ $application->setMissingPersonName($context->get('missing_person_name')); $application->setMissingPersonRelationship($context->get('missing_person_relationship')); $application->setMissingPersonPhone($context->get('missing_person_phone')); $application->setMissingPersonEmail($context->get('missing_person_email')); // Save the modified application $result = $application->save(); if ($result == TRUE) { // Log the fact that the application updated PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($username, ACTIVITY_EMERGENCY_CONTACT_UPDATED, $username); try { // report the application to banner; $application->reportToBanner(); } catch (Exception $e) { // ignore any errors reporting this to banner, they'll be logged and admins notified. // we've saved the student's application locally, so it's ok if this doesn't work. } // Send the email confirmation PHPWS_Core::initModClass('hms', 'HMS_Email.php'); HMS_Email::send_emergency_contact_updated_confirmation($student, $application->getTerm()); } // Notify user of success //$friendly_term = Term::toString($application->getTerm()); //NQ::simple('hms', hms\NotificationView::SUCCESS, "Your Emergency Contact & Missing Person information for $friendly_term was successfully modified! You will receive an email confirmation in the next 24 hours."); // Redirect to the student menu $successCmd = CommandFactory::getCommand('ShowStudentMenu'); $successCmd->redirect(); }