本文整理汇总了PHP中Current_User类的典型用法代码示例。如果您正苦于以下问题:PHP Current_User类的具体用法?PHP Current_User怎么用?PHP Current_User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Current_User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: execute
/**
* The main function for executing the command.
*/
public function execute()
{
// Retrieve the values from the request
$umbrellaId = $_REQUEST['umbrellaId'];
// Retrieve other important values and objects
$username = \Current_User::getUsername();
$permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId);
// If the permissions array is empty then the user does not have permission to use this command
// throw an error back to the front end.
if (sizeof($permissions) == 0) {
echo '<div style="display: none;">User does not have permission to access this data.</div>';
exit;
}
// Attempt to retrieve the portals and do a fuzzy search of them for the searchString
try {
$portals = \AppSync\PortalFactory::getPortals();
$searchString = $_REQUEST['searchString'];
$umbrella = $_REQUEST['umbrellaId'];
$portList = $this->portalFuzzySearch($searchString, $umbrella, $portals);
echo $this->encodePortals($portList);
} catch (\Exception $e) {
echo '<div style="display: none;">' . $e->getMessage() . '</div>';
}
exit;
}
示例3: process
public static function process()
{
if (!Current_User::authorized('analytics')) {
Current_User::disallow();
}
$panel = self::cpanel();
if (isset($_REQUEST['command'])) {
$command = $_REQUEST['command'];
} else {
$command = $panel->getCurrentTab();
}
switch ($command) {
case 'list':
$panel->setContent(self::listTrackers());
break;
case 'new':
$panel->setContent(self::newTracker());
break;
case 'create':
$panel->setContent(self::createTracker());
break;
case 'edit':
$panel->setContent(self::editTracker());
break;
case 'delete':
$panel->setContent(self::deleteTracker());
break;
case 'save_tracker':
$panel->setContent(self::saveTracker());
break;
}
Layout::add(PHPWS_ControlPanel::display($panel->display()));
}
示例4: 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());
}
示例5: test
public static function test($value, $show_recursive = FALSE)
{
if (DEITY_ONLY_TEST && (!isset($_SESSION['User']) || !class_exists('Current_User') || !Current_User::isDeity())) {
return;
}
if (empty($value)) {
$value = PHPWS_Debug::emptyVal($value);
}
switch (1) {
case is_object($value):
return PHPWS_Debug::testObject($value, 1, $show_recursive);
break;
case is_array($value):
return 'Array' . PHPWS_Debug::testArray($value, 1, $show_recursive);
break;
case is_bool($value):
if ($value) {
return '<pre>bool(TRUE)</pre>';
} else {
return '<pre>bool(FALSE)</pre>';
}
case is_numeric($value):
return '<pre>' . $value . '</pre>';
case is_string($value):
return '<pre>' . preg_replace('/\\n|(\\r\\n)/', '\\n', htmlspecialchars($value)) . '</pre>';
break;
default:
return '<pre>' . $value . '</pre>';
}
}
示例6: 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());
}
示例7: 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();
}
示例8: 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();
}
示例9: execute
/**
* Exec
*
* @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);
// Check to make sure the file exists
if (!file_exists($report->getCsvOutputFilename())) {
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();
}
$pdf = file_get_contents($report->getCsvOutputFilename());
// Hoepfully force the browser to open a 'save as' dialogue
header('Content-Type: text/csv');
header('Cache-Control: public, must-revalidate, max-age=0');
// HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen($pdf));
header('Content-Disposition: attachment; filename="' . basename($report->getCsvOutputFilename()) . '";');
echo $pdf;
exit;
}
示例10: 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());
}
示例11: 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());
}
示例12: __construct
public function __construct($asu_username, $term)
{
$this->asu_username = $asu_username;
$this->term = $term;
$this->created_on = time();
$this->created_by = Current_User::getUsername();
}
示例13: __construct
public function __construct()
{
parent::__construct();
// Check permissions
if (UserStatus::isAdmin()) {
if (Current_User::allow('hms', 'learning_community_maintenance')) {
$this->addCommandByName('Add/Edit Communities', 'ShowEditRlc');
}
if (Current_User::allow('hms', 'view_rlc_applications')) {
$this->addCommandByName('Assign Applicants to RLCs', 'ShowAssignRlcApplicants');
$this->addCommandByName('View Denied Applications', 'ShowDeniedRlcApplicants');
}
if (Current_User::allow('hms', 'learning_community_maintenance')) {
$this->addCommandByName('Send RLC Email Invites', 'ShowSendRlcInvites');
}
if (Current_User::allow('hms', 'view_rlc_members')) {
$this->addCommandByName('View RLC Members by RLC', 'ShowSearchByRlc');
$this->addCommandByName('View RLC Assignments', 'ViewRlcAssignments');
}
if (Current_User::allow('hms', 'email_rlc_rejections')) {
// Using JSConfirm, ask user if the _really_ want to send the emails
$onConfirmCmd = CommandFactory::getCommand('SendRlcRejectionEmails');
$cmd = CommandFactory::getCommand('JSConfirm');
$cmd->setLink('Send RLC Rejection Emails');
$cmd->setTitle('Send RLC Rejection Emails');
$cmd->setQuestion('Send notification emails to denied RLC applicants for selected term?');
$cmd->setOnConfirmCommand($onConfirmCmd);
$this->addCommand('Send RLC Rejection Emails', $cmd);
}
}
}
示例14: display
public function display()
{
// permissions...
if (!\Current_User::isDeity()) {
\NQ::simple('intern', NotifyUI::ERROR, 'You cannot edit administrators.');
return false;
}
// set up some stuff for the page template
$tpl = array();
// create the list of admins
$adminList = Admin::getAdminPager();
// get the list of departments
$depts = Department::getDepartmentsAssoc();
// make the form for adding a new admin
$form = new \PHPWS_Form('add_admin');
$form->addSelect('department_id', $depts);
$form->setLabel('department_id', 'Department');
$form->addText('username');
$form->setLabel('username', 'Username');
$form->addCheck('all');
$form->setLabel('all', 'All Departments');
$form->addSubmit('submit', 'Create Admin');
$form->setAction('index.php?module=intern&action=edit_admins');
$form->addHidden('add', 1);
// TODO: Add Javascript autocomplete for usernames.
javascript('jquery');
javascript('jquery_ui');
javascriptMod('intern', 'admin');
$tpl['PAGER'] = $adminList;
$form->mergeTemplate($tpl);
return \PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_admin.tpl');
}
示例15: checkRequiredFields
public function checkRequiredFields(Internship $i)
{
if (!$i->isSecondaryPart()) {
// Check the course subject
$courseSubj = $i->getSubject();
if (!isset($courseSubj) || $courseSubj == '' || $courseSubj->id == 0) {
throw new MissingDataException("Please select a course subject.");
}
// Check the course number
$courseNum = $i->getCourseNumber();
if (!isset($courseNum) || $courseNum == '') {
throw new MissingDataException("Please enter a course number.");
}
// Check the course section number
$sectionNum = $i->getCourseSection();
if (!isset($sectionNum) || $sectionNum == '') {
throw new MissingDataException("Please enter a course section number.");
}
// Check the course credit hours field
$creditHours = $i->getCreditHours();
if (!isset($creditHours) || $creditHours == '') {
throw new MissingDataException("Please enter the number of course credit hours.");
}
if (!\Current_User::isDeity() && $creditHours <= 0) {
throw new MissingDataException("The number of course credit hours should be greater than zero.");
}
}
}