本文整理汇总了PHP中UserStatus::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserStatus::getUsername方法的具体用法?PHP UserStatus::getUsername怎么用?PHP UserStatus::getUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStatus
的用法示例。
在下文中一共展示了UserStatus::getUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
示例2: execute
/**
* (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();
}
示例3: 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());
}
示例4: execute
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();
}
示例5: execute
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();
}
示例6: 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);
}
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();
}
示例7: show
public function show()
{
$username = UserStatus::getUsername();
$currentTerm = Term::getCurrentTerm();
$student = StudentFactory::getStudentByUsername($username, $currentTerm);
$applicationTerm = $student->getApplicationTerm();
$tpl = array();
$tpl['TITLE'] = 'Contact Form';
$form = new PHPWS_Form();
$form->addText('name');
$form->setLabel('name', 'Name');
$form->addText('email');
$form->setLabel('email', 'Email Address');
$form->addText('phone');
$form->setLabel('phone', 'Phone number');
$form->addDropBox('stype', array('F' => 'New Freshmen', 'T' => 'Transfer', 'C' => 'Returning'));
$form->setLabel('stype', 'Classification');
$form->addTextArea('comments');
$form->setLabel('comments', 'Question, Comments, or Description of the Problem');
$form->addSubmit('Submit');
$form->mergeTemplate($tpl);
$cmd = CommandFactory::getCommand('SubmitContactForm');
$cmd->setUsername($username);
$cmd->setApplicationTerm($applicationTerm);
$cmd->setStudentType($student->getType());
$cmd->initForm($form);
$tpl = $form->getTemplate();
//var_dump($tpl);exit;
return PHPWS_Template::process($tpl, 'hms', 'student/contact_page.tpl');
}
示例8: 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) {
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();
}
示例9: execute
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();
}
}
}
示例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)
{
// 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();
}
示例12: 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->requestee) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException("{$username} tried to display confirmation screen for pairing {$roommate->id}");
}
$tpl = array();
$acceptCmd = CommandFactory::getCommand('ShowRoommateConfirmAccept');
$acceptCmd->setRoommateId($roommate->id);
$tpl['ACCEPT'] = $acceptCmd->getURI();
$rejectCmd = CommandFactory::getCommand('RoommateReject');
$rejectCmd->setRoommateId($roommate->id);
$tpl['DECLINE'] = $rejectCmd->getURI();
$cancelCmd = CommandFactory::getCommand('ShowStudentMenu');
$tpl['CANCEL'] = $cancelCmd->getURI();
$requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
$tpl['REQUESTOR_NAME'] = $requestor->getFullName();
$context->setContent(PHPWS_Template::process($tpl, 'hms', 'student/roommate_accept_reject_screen.tpl'));
}
示例13: 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());
}
示例14: execute
public function execute(CommandContext $context)
{
$term = Term::getSelectedTerm();
$messageAll = Current_User::allow('hms', 'email_all');
$db = new PHPWS_DB('hms_residence_hall');
$db->addWhere('term', $term);
$results = $db->getObjects('HMS_Residence_Hall');
if (PHPWS_Error::logIfError($results) || is_null($results)) {
$errorMsg = array();
if (is_null($results)) {
$errorMsg['error'] = 'You do not have permission to message any halls, sorry.';
} else {
$errorMsg['error'] = 'There was a problem reading the database, please try reloading the page. If the problem persists contact ESS.';
}
echo json_encode($errorMsg);
exit;
}
$permission = new HMS_Permission();
$data = array();
foreach ($results as $hall) {
$somethingEnabled = false;
$floors = $hall->get_floors();
unset($obj);
$obj = new stdClass();
$obj->name = $hall->getHallName();
$obj->id = $hall->getId();
$obj->floors = array();
//$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false');
if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) {
$obj->enabled = true;
$somethingEnabled = true;
foreach ($floors as $floor) {
unset($floor_obj);
$floor_obj = new stdClass();
$floor_obj->name = "Floor: " . $floor->getFloorNumber();
$floor_obj->id = $floor->getId();
$floor_obj->enabled = true;
$obj->floors[] = $floor_obj;
}
} else {
$obj->enabled = false;
foreach ($floors as $floor) {
unset($floor_obj);
$floor_obj = new stdClass();
$floor_obj->name = "Floor: " . $floor->getFloorNumber();
$floor_obj->id = $floor->getId();
$floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email');
$obj->floors[] = $floor_obj;
if ($floor_obj->enabled) {
$somethingEnabled = true;
}
}
}
if ($somethingEnabled) {
$data[] = $obj;
}
}
echo json_encode($data);
exit;
}
示例15: getStudentById
public function getStudentById($id, $term)
{
// Sanity checking on the Banner ID
$id = trim($id);
if (!isset($id) || empty($id) || $id == '') {
throw new InvalidArgumentException('Missing Banner id. Please enter a valid Banner ID (nine digits).');
}
if (strlen($id) > 9 || strlen($id) < 9 || !preg_match("/^[0-9]{9}\$/", $id)) {
throw new InvalidArgumentException('That was not a valid Banner ID. Please enter a valid Banner ID (nine digits).');
}
$student = new Student();
$soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER);
$soapData = $soap->getStudentProfile($id, $term);
if ($soapData->error_num == 1101 && $soapData->error_desc == 'LookupStudentID') {
PHPWS_Core::initModClass('hms', 'exception/StudentNotFoundException.php');
throw new StudentNotFoundException('No matching student found.');
} elseif (isset($soapData->error_num) && $soapData->error_num > 0) {
//test($soapData,1);
throw new SOAPException("Error while accessing SOAP interface: {$soapData->error_desc} ({$soapData->error_num})", $soapData->error_num, 'getStudentProfile', array($id, $term));
}
SOAPDataProvider::plugSOAPData($student, $soapData);
//SOAPDataProvider::applyExceptions($student);
require_once PHPWS_SOURCE_DIR . SOAP_DATA_OVERRIDE_PATH;
$dataOverride = new SOAPDataOverride();
$dataOverride->applyExceptions($student);
$student->setDataSource(get_class($this));
return $student;
}