本文整理汇总了PHP中CommandContext::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandContext::setContent方法的具体用法?PHP CommandContext::setContent怎么用?PHP CommandContext::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandContext
的用法示例。
在下文中一共展示了CommandContext::setContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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())));
}
}
示例2: 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));
}
}
示例3: execute
public function execute(CommandContext $context)
{
$newrows = array();
$pdo = PdoFactory::getPdoInstance();
$floor_id = (int) $context->get('floorId');
$query = <<<EOF
select\troom.id as room_id,
\troom.room_number,
\troom.gender_type,
\tbed.id as bed_id,
\tbed.bedroom_label,
\tbed.bed_letter,
\tassign.banner_id,
\tassign.meal_option,
assign.asu_username
from \thms_room as room
\tfull join
\t\thms_bed as bed on room.id=bed.room_id
\tfull join
\t\thms_assignment as assign on bed.id=assign.bed_id
where\troom.floor_id = :floor_id
order by room_number asc, bedroom_label, bed_letter;
EOF;
$prep = $pdo->prepare($query);
$prep->execute(array(':floor_id' => $floor_id));
$rows = $prep->fetchAll(PDO::FETCH_ASSOC);
if (empty($rows)) {
$context->setContent(json_encode(array()));
return;
}
$count = -1;
$room_number_track = 0;
foreach ($rows as $k => $v) {
$gender = HMS_Util::formatGender($v['gender_type']);
if ($v['banner_id']) {
$student = StudentFactory::getStudentByBannerID($v['banner_id'], Term::getSelectedTerm());
if ($student) {
$v['student'] = $student->first_name . ' ' . $student->last_name;
} else {
$v['student'] = null;
}
} else {
$v['student'] = null;
}
if ($v['room_number'] != $room_number_track) {
$count++;
$newrows[$count]['room_number'] = $v['room_number'];
$newrows[$count]['gender'] = $gender;
$newrows[$count]['beds'][] = $v;
$room_number_track = $v['room_number'];
} else {
$newrows[$count]['beds'][] = $v;
}
}
$context->setContent(json_encode($newrows));
}
示例4: execute
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
$rlc = new HMS_Learning_Community($context->get('id'));
if ($rlc->extra_info != NULL) {
$tpl = array();
$tpl['INFO'] = $rlc->extra_info;
$returnData = array();
$returnData['content'] = PHPWS_Template::process($tpl, 'hms', 'student/rlcExtraInfoDialog.tpl');
$returnData['title'] = 'Extra Info for ' . $rlc->community_name;
$context->setContent(json_encode($returnData));
} else {
$context->setContent('');
}
}
示例5: execute
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php');
PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
$bedId = $context->get('bed_id');
$bed = new HMS_Bed($bedId);
$room = $bed->get_parent();
// Get the damages for this student's room
$damages = RoomDamageFactory::getDamagesByRoom($room);
if ($damages == null) {
$context->setContent(json_encode(array()));
return;
}
$context->setContent(json_encode($damages));
}
示例6: execute
public function execute(CommandContext $context)
{
$send_to = array();
$send_to[] = 'brownbw@appstate.edu';
$send_to[] = 'jb67803@appstate.edu';
$send_to[] = 'braswelldl@appstate.edu';
$send_to[] = 'berrybm@appstate.edu';
$from = FROM_ADDRESS;
$subject = 'HMS Contact Form';
$body = "Username: " . $context->get('asu_username') . "\n";
$body .= "Application date: " . $context->get('application_term') . "\n";
$body .= "Student Type: " . $context->get('student_type') . "\n";
$body .= "\n\nInput from student:\n\n";
$body .= "Name: " . $context->get('name') . "\n";
$body .= "Email: " . $context->get('email') . "\n";
$body .= "Phone #: " . $context->get('phone') . "\n";
$body .= "Type: " . $context->get('stype') . "\n";
$body .= "Text field:\n";
$body .= "" . $context->get('comments') . "\n\n";
if (!HMS_Email::send_email($send_to, $from, $subject, $body)) {
//Maybe we shouldn't say anything...
//NQ::simple('hms', hms\NotificationView::ERROR, 'Error sending email!');
}
$view = new ContactFormThankYouView();
$context->setContent($view->show());
}
示例7: execute
/**
* Shows the requested report's HTML output.
*
* @param CommandContext $context
* @throws InvalidArgumentExection
*/
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'reports')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do no have permission to run reports.');
}
$reportId = $context->get('reportId');
if (!isset($reportId) || is_null($reportId)) {
throw new InvalidArgumentExection('Missing report id.');
}
// Instantiate the report controller with the requested report id
PHPWS_Core::initModClass('hms', 'ReportFactory.php');
$report = ReportFactory::getReportById($reportId);
Layout::addPageTitle($report->getFriendlyName());
$detailCmd = CommandFactory::getCommand('ShowReportDetail');
$detailCmd->setReportClass($report->getClass());
$content = '<div> ' . $detailCmd->getLink('« back') . ' </div>';
$content .= file_get_contents($report->getHtmlOutputFilename());
if ($content === FALSE) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
$reportCmd = CommandFactory::getCommand('ShowReportDetail');
$reportCmd->setReportClass($report->getClass());
$reportCmd->redirect();
}
$context->setContent($content);
}
示例8: execute
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());
}
示例9: execute
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'room_structure')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to add a room.');
}
PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
PHPWS_Core::initModClass('hms', 'HMS_Util.php');
PHPWS_Core::initModClass('hms', 'AddRoomView.php');
$floor_id = $context->get('floor');
$tpl = array();
# Setup the title and color of the title bar
$tpl['TITLE'] = 'Add Room';
# Check to make sure we have a floor and hall.
$floor = new HMS_Floor($floor_id);
if (!$floor) {
$tpl['ERROR_MSG'] = 'There was an error getting the floor object. Please contact ESS.';
return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl');
}
$hall = $floor->get_parent();
if (!$hall) {
$tpl['ERROR_MSG'] = 'There was an error getting the hall object. Please contact ESS.';
return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl');
}
# Check Permissions
if (!Current_User::allow('hms', 'room_structure')) {
HMS_Floor::show_edit_floor($floor_id, NULL, 'You do not have permission to add rooms.');
}
$view = new AddRoomView($floor);
$context->setContent($view->show());
}
示例10: 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());
}
示例11: execute
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'RoommateProfileSearchForm.php');
$term = $context->get('term');
$view = new RoommateProfileSearchForm($term);
$context->setContent($view->show());
}
示例12: execute
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'room_view')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to view rooms.');
}
// Check for a hall ID
$roomId = $context->get('room');
if (!isset($roomId)) {
throw new InvalidArgumentException('Missing room ID.');
}
// Load the room
$room = new HMS_Room($roomId);
if ($room->term != Term::getSelectedTerm()) {
$roomCmd = CommandFactory::getCommand('SelectRoom');
$roomCmd->setTitle('Edit a Room');
$roomCmd->setOnSelectCmd(CommandFactory::getCommand('EditRoomView'));
$roomCmd->redirect();
}
// Load the floor/hall
$floor = $room->get_parent();
$hall = $floor->get_parent();
// Load the room damages and damage types
$damageTypes = DamageTypeFactory::getDamageTypeAssoc();
$roomView = new RoomView($hall, $floor, $room, $damageTypes);
$context->setContent($roomView->show());
}
示例13: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit floors.');
}
// Check for a hall ID
$floorId = $context->get('floor');
if (!isset($floorId)) {
throw new InvalidArgumentException('Missing floor ID.');
}
PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
PHPWS_Core::initModClass('hms', 'FloorView.php');
$floor = new HMS_Floor($floorId);
if ($floor->term != Term::getSelectedTerm()) {
$floorCmd = CommandFactory::getCommand('SelectFloor');
$floorCmd->setTitle('Edit a Floor');
$floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView'));
$floorCmd->redirect();
}
$hall = $floor->get_parent();
$floorView = new FloorView($hall, $floor);
$context->setContent($floorView->show());
}
示例14: execute
public function execute(CommandContext $context)
{
$id = $context->get('roommateId');
if (is_null($id)) {
throw new InvalidArgumentException('Must set roommateId');
}
PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
$roommate = new HMS_Roommate($id);
if ($roommate->id = 0) {
throw new InvalidArgumentException('Invalid roommateId ' . $id);
}
$username = UserStatus::getUsername();
if ($username != $roommate->requestor && $username != $roommate->requestee) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}");
}
PHPWS_Core::initCoreClass('Captcha.php');
// get other roommate
$other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term);
$form = new PHPWS_Form();
$cmd = CommandFactory::getCommand('RoommateBreak');
$cmd->setRoommateId($id);
$cmd->initForm($form);
$form->addTplTag('CAPTCHA_IMAGE', Captcha::get());
$form->addTplTag('NAME', $other->getFullName());
$form->addSubmit('Confirm');
$form->addCssClass('submit', 'btn btn-danger');
$context->setContent(PHPWS_Template::process($form->getTemplate(), 'hms', 'student/roommate_break_confirm.tpl'));
}
示例15: execute
public function execute(CommandContext $context)
{
$term = $context->get('term');
if (!isset($term) || is_null($term) || empty($term)) {
throw new InvalidArgumentException('Missing term.');
}
$cmd = CommandFactory::getCommand('ShowStudentMenu');
$feature = ApplicationFeature::getInstanceByNameAndTerm('RlcApplication', $term);
// Make sure the RLC application feature is enabled
if (is_null($feature) || !$feature->isEnabled()) {
NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC applications are not avaialable for this term.");
$cmd->redirect();
}
// Check feature's deadlines
if ($feature->getStartDate() > time()) {
NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to fill out an RLC application.");
$cmd->redirect();
} else {
if ($feature->getEndDate() < time()) {
NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC.");
$cmd->redirect();
}
}
// Get the Student object
$student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
$view = new RlcApplicationPage1View($context, $student);
$context->setContent($view->show());
}