本文整理汇总了PHP中CommandContext::get方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandContext::get方法的具体用法?PHP CommandContext::get怎么用?PHP CommandContext::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandContext
的用法示例。
在下文中一共展示了CommandContext::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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();
}
示例2: execute
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());
}
示例3: execute
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);
// Check permissions. Must be an RD for current bed, or an admin
$rds = $participant->getFutureRdList();
if (!in_array(UserStatus::getUsername(), $rds) && !Current_User::allow('hms', 'admin_approve_room_change')) {
throw new PermissionException('You do not have permission to approve this room change.');
}
// Transition to CurrRdApproved
$participant->transitionTo(new ParticipantStateFutureRdApproved($participant, time(), null, UserStatus::getUsername()));
//TODO If all participants are approved, send notification to Housing
if ($request->isApprovedByAllFutureRDs()) {
HMS_Email::sendRoomChangeAdministratorNotice($request);
}
// Redirect to the manage request page
$cmd->redirect();
}
示例4: execute
/**
* (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());
}
示例5: execute
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();
}
示例6: execute
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'edit_role_members')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit role members.');
}
$username = $context->get('username');
$rolename = $context->get('role');
$class = $context->get('className');
$instance = $context->get('instance');
if (is_null($username) || is_null($rolename)) {
echo json_encode(false);
exit;
}
$db = new PHPWS_DB('hms_role');
$db->addWhere('name', $rolename);
$result = $db->select('row');
if (PHPWS_Error::logIfError($result) || is_null($result['id'])) {
echo json_encode(false);
exit;
}
$role_id = $result['id'];
$role = new HMS_Role();
$role->id = $role_id;
if ($role->load()) {
echo json_encode($role->removeUser($username, $class, $instance));
exit;
}
echo json_encode(false);
exit;
}
示例7: execute
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'edit_role_members')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit role members.');
}
$username = $context->get('username');
$role_id = $context->get('role');
$classname = $context->get('class');
$instance = $context->get('instance');
if (is_null($username) || is_null($role_id)) {
echo json_encode(false);
exit;
}
$role = new HMS_Role();
$role->id = $role_id;
if ($role->load()) {
try {
$role->addUser($username, $classname, $instance);
echo json_encode('true');
exit;
} catch (Exception $e) {
echo json_encode($e->getMessage());
exit;
}
}
}
示例8: execute
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();
}
示例9: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assign_by_floor')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to assign students by floor.');
}
$username = $context->get('username');
$banner_id = (int) $context->get('banner_id');
$reason = $context->get('reason');
$meal_plan = $context->get('meal_plan');
$bed_id = $context->get('bed_id');
$term = Term::getSelectedTerm();
try {
if ($banner_id) {
$student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
} elseif (!empty($username)) {
$student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
} else {
$context->setContent(json_encode(array('status' => 'failure', 'message' => 'Did not receive Banner ID or user name.')));
return;
}
try {
HMS_Assignment::assignStudent($student, $term, null, $bed_id, $meal_plan, null, null, $reason);
} catch (AssignmentException $e) {
$context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
return;
}
$message = $student->first_name . ' ' . $student->last_name;
$context->setContent(json_encode(array('status' => 'success', 'message' => $message, 'student' => $student)));
} catch (\StudentNotFoundException $e) {
$context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
}
}
示例10: execute
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();
}
示例11: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'search')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to lookup student names!');
}
$student = null;
$error = new JsonError(403);
$username = $context->get('username');
$banner_id = (int) $context->get('banner_id');
try {
if ($banner_id) {
$student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
} elseif (!empty($username)) {
$student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
} else {
$error->setMessage('Did not receive Banner ID or user name.');
$context->setContent(json_encode($error));
}
$student->gender_string = HMS_Util::formatGender($student->gender);
$context->setContent(json_encode($student));
} catch (\StudentNotFoundException $e) {
$error->setMessage($e->getMessage());
$context->setContent(json_encode($error));
}
}
示例12: execute
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();
}
示例13: execute
public function execute(CommandContext $context)
{
$term = new Term(Term::getSelectedTerm());
$term->setDocusignTemplate($context->get('template'));
$term->setDocusignUnder18Template($context->get('under18_template'));
$term->save();
$cmd = CommandFactory::getCommand('ShowEditTerm');
$cmd->redirect();
}
示例14: execute
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;
}
示例15: execute
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'StudentFactory.php');
PHPWS_Core::initModClass('hms', 'RoommateProfile.php');
PHPWS_Core::initModClass('hms', 'RoommateProfileView.php');
$student = StudentFactory::getStudentByBannerID($context->get('banner_id'), $context->get('term'));
$profile = RoommateProfileFactory::getProfile($context->get('banner_id'), $context->get('term'));
$view = new RoommateProfileView($student, $profile);
$context->setContent($view->show());
}