本文整理汇总了PHP中Current_User::getUserObj方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::getUserObj方法的具体用法?PHP Current_User::getUserObj怎么用?PHP Current_User::getUserObj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current_User
的用法示例。
在下文中一共展示了Current_User::getUserObj方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doTransition
public function doTransition($note = null)
{
// Make sure the transition makes sense based on the current state of the internship
$currStateName = $this->internship->getStateName();
$sourceStateName = $this->t->getSourceState();
if (is_array($sourceStateName)) {
if (!in_array($currStateName, $sourceStateName)) {
throw new InvalidArgumentException('Invalid transition source state.');
}
} else {
if ($sourceStateName != '*' && $sourceStateName != $currStateName) {
throw new InvalidArgumentException('Invalid transition source state.');
}
}
if (!$this->t->allowed($this->internship)) {
throw new Exception("You do not have permission to set the internship to the requested status.");
}
// Check that the fields required to take this transition have been filled in
// Will throw an exception in the case of any missing data.
$this->t->checkRequiredFields($this->internship);
$sourceState = WorkflowStateFactory::getState($currStateName);
$destStateName = $this->t->getDestState();
if ($destStateName == null) {
// No destination state, so see if we need to add a note (no state change)
if (!is_null($note)) {
$changeHistory = new ChangeHistory($this->internship, Current_User::getUserObj(), time(), $sourceState, $sourceState, $note);
$changeHistory->save();
}
return;
}
$destState = WorkflowStateFactory::getState($destStateName);
$this->t->onTransition($this->internship);
$this->internship->setState($destState);
$this->internship->save();
$changeHistory = new ChangeHistory($this->internship, Current_User::getUserObj(), time(), $sourceState, $destState, $note);
$changeHistory->save();
}
示例2: execute
//.........这里部分代码省略.........
$i->oied_certified = 1;
} else {
if ($_POST['oied_certified_hidden'] == 'false') {
$i->oied_certified = 0;
} else {
$i->oied_certified = 0;
}
}
// If we don't have a state and this is a new internship,
// the set an initial state
if ($i->id == 0 && is_null($i->state)) {
$state = WorkflowStateFactory::getState('CreationState');
$i->setState($state);
// Set this initial value
}
try {
$i->save();
} catch (\Exception $e) {
// Rollback and re-throw the exception so that admins gets an email
\PHPWS_DB::rollback();
throw $e;
}
// Update agency
try {
$agency = AgencyFactory::getAgencyById($_REQUEST['agency_id']);
} catch (\Exception $e) {
// Rollback and re-throw the exception so that admins gets an email
\PHPWS_DB::rollback();
throw $e;
}
// Agency Info
$agency->name = $_REQUEST['agency_name'];
$agency->address = $_REQUEST['agency_address'];
$agency->city = $_REQUEST['agency_city'];
$agency->zip = $_REQUEST['agency_zip'];
$agency->phone = $_REQUEST['agency_phone'];
if ($i->isDomestic()) {
$agency->state = $_REQUEST['agency_state'] == '-1' ? null : $_REQUEST['agency_state'];
} else {
$agency->province = $_REQUEST['agency_province'];
$agency->country = $_REQUEST['agency_country'] == '-1' ? null : $_REQUEST['agency_country'];
}
// Agency Supervisor Info
$agency->supervisor_first_name = $_REQUEST['agency_sup_first_name'];
$agency->supervisor_last_name = $_REQUEST['agency_sup_last_name'];
$agency->supervisor_title = $_REQUEST['agency_sup_title'];
$agency->supervisor_phone = $_REQUEST['agency_sup_phone'];
$agency->supervisor_email = $_REQUEST['agency_sup_email'];
$agency->supervisor_fax = $_REQUEST['agency_sup_fax'];
$agency->supervisor_address = $_REQUEST['agency_sup_address'];
$agency->supervisor_city = $_REQUEST['agency_sup_city'];
$agency->supervisor_zip = $_REQUEST['agency_sup_zip'];
if ($i->isDomestic()) {
$agency->supervisor_state = $_REQUEST['agency_sup_state'];
} else {
$agency->supervisor_province = $_REQUEST['agency_sup_province'];
$agency->supervisor_country = $_REQUEST['agency_sup_country'] == '-1' ? null : $_REQUEST['agency_sup_country'];
}
$agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f';
try {
DatabaseStorage::save($agency);
} catch (\Exception $e) {
// Rollback and re-throw the exception so that admins gets an email
\PHPWS_DB::rollback();
throw $e;
}
/***************************
* State/Workflow Handling *
***************************/
$t = \Intern\WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']);
$workflow = new \Intern\WorkflowController($i, $t);
try {
$workflow->doTransition(isset($_POST['notes']) ? $_POST['notes'] : null);
} catch (\Intern\Exception\MissingDataException $e) {
\NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $e->getMessage());
\NQ::close();
return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id);
}
// Create a ChangeHisotry for the OIED certification.
if ($oiedCertified) {
$currState = WorkflowStateFactory::getState($i->getStateName());
$ch = new ChangeHistory($i, \Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED');
$ch->save();
}
\PHPWS_DB::commit();
$workflow->doNotification(isset($_POST['notes']) ? $_POST['notes'] : null);
//var_dump($_POST['generateContract']);exit;
// If the user clicked the 'Generate Contract' button, then redirect to the PDF view
if (isset($_POST['generateContract']) && $_POST['generateContract'] == 'true') {
//return \PHPWS_Core::reroute('index.php?module=intern&action=pdf&internship_id=' . $i->id);
echo json_encode($i);
exit;
} else {
// Otherwise, redirect to the internship edit view
// Show message if user edited internship
\NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Saved internship for ' . $i->getFullName());
\NQ::close();
return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id);
}
}
示例3: execute
//.........这里部分代码省略.........
$i->ugrad_major = $_REQUEST['ugrad_major'];
$i->grad_prog = null;
} else {
if ($i->getLevel() == 'grad') {
$i->grad_prog = $_REQUEST['grad_prog'];
$i->ugrad_major = null;
}
}
$i->gpa = $_REQUEST['student_gpa'];
$i->campus = $_REQUEST['campus'];
$i->student_address = $_REQUEST['student_address'];
$i->student_city = $_REQUEST['student_city'];
if ($_REQUEST['student_state'] != '-1') {
$i->student_state = $_REQUEST['student_state'];
} else {
$i->student_state = "";
}
$i->student_zip = $_REQUEST['student_zip'];
/*
$i->emergency_contact_name = $_REQUEST['emergency_contact_name'];
$i->emergency_contact_relation = $_REQUEST['emergency_contact_relation'];
$i->emergency_contact_phone = $_REQUEST['emergency_contact_phone'];
*/
/************
* OIED Certification
*/
// If OIED certification has changed, then double check permissions
$cert = $i->oied_certified == 1 ? true : false;
$certSubmitted = $_POST['oied_certified_hidden'] == 'true' ? true : false;
$certChanged = $cert != $certSubmitted;
if ($certChanged && !Current_User::allow('intern', 'oied_certify')) {
$url = "index.php?module=intern&action=edit_internship&internship_id={$i->getId()}";
NQ::simple('intern', INTERN_ERROR, "You do not have permission to change the OIED certification checkbox. No changes were saved.");
NQ::close();
return PHPWS_Core::reroute($url);
}
// Check if this has changed from non-certified->certified so we can log it later
if ($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true') {
// note the change for later
$oiedCertified = true;
} else {
$oiedCertified = false;
}
if ($_POST['oied_certified_hidden'] == 'true') {
$i->oied_certified = 1;
} else {
if ($_POST['oied_certified_hidden'] == 'false') {
$i->oied_certified = 0;
} else {
$i->oied_certified = 0;
}
}
// If we don't have a state and this is a new internship,
// the set an initial state
if ($i->id == 0 && is_null($i->state)) {
PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
$state = WorkflowStateFactory::getState('CreationState');
$i->setState($state);
// Set this initial value
}
try {
$i->save();
} catch (Exception $e) {
// Rollback and re-throw the exception so that admins gets an email
PHPWS_DB::rollback();
throw $e;
}
PHPWS_DB::commit();
/***************************
* State/Workflow Handling *
***************************/
PHPWS_Core::initModClass('intern', 'WorkflowController.php');
PHPWS_Core::initModClass('intern', 'WorkflowTransitionFactory.php');
$t = WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']);
$workflow = new WorkflowController($i, $t);
try {
$workflow->doTransition(isset($_POST['notes']) ? $_POST['notes'] : null);
} catch (MissingDataException $e) {
NQ::simple('intern', INTERN_ERROR, $e->getMessage());
NQ::close();
return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
}
// Create a ChangeHisotry for the OIED certification.
if ($oiedCertified) {
$currState = WorkflowStateFactory::getState($i->getStateName());
$ch = new ChangeHistory($i, Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED');
$ch->save();
}
$workflow->doNotification(isset($_POST['notes']) ? $_POST['notes'] : null);
if (isset($_REQUEST['internship_id'])) {
// Show message if user edited internship
NQ::simple('intern', INTERN_SUCCESS, 'Saved internship for ' . $i->getFullName());
NQ::close();
return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
} else {
NQ::simple('intern', INTERN_SUCCESS, 'Added internship for ' . $i->getFullName());
NQ::close();
return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
}
}
示例4: formatException
private static function formatException(Exception $e)
{
ob_start();
echo "Ohes Noes! An HMS report threw an exception that was not caught!\n\n";
echo "Host: {$_SERVER['SERVER_NAME']}({$_SERVER['SERVER_ADDR']})\n";
echo 'Request time: ' . date("D M j G:i:s T Y", $_SERVER['REQUEST_TIME']) . "\n";
if (isset($_SERVER['HTTP_REFERER'])) {
echo "Referrer: {$_SERVER['HTTP_REFERER']}\n";
} else {
echo "Referrer: (none)\n";
}
echo "Remote addr: {$_SERVER['REMOTE_ADDR']}\n\n";
$user = Current_User::getUserObj();
if (isset($user) && !is_null($user)) {
echo "User name: {$user->getUsername()}\n\n";
} else {
echo "User name: (none)\n\n";
}
echo "Here is the exception:\n\n";
print_r($e);
$message = ob_get_contents();
ob_end_clean();
return $message;
}
示例5: loggedOut
public static function loggedOut()
{
if (isset($_REQUEST['phpws_username'])) {
$username = $_REQUEST['phpws_username'];
} else {
$username = NULL;
}
$form = new PHPWS_Form('User_Login_Box');
$form->setProtected(false);
$form->addHidden('module', 'users');
$form->addHidden('action', 'user');
$form->addHidden('command', 'login');
$form->addText('phpws_username', $username);
$form->setSize('phpws_username', 10);
$form->setClass('phpws_username', 'form-control');
$form->addPassword('phpws_password');
$form->setSize('phpws_password', 10);
$form->setClass('phpws_password', 'form-control');
$form->addSubmit('submit', LOGIN_BUTTON);
$form->setLabel('phpws_username', dgettext('users', 'Username'));
$form->setLabel('phpws_password', dgettext('users', 'Password'));
$form->setPlaceholder('phpws_username', dgettext('users', 'Username'));
$form->setPlaceholder('phpws_password', dgettext('users', 'Password'));
$template = $form->getTemplate();
$template = array();
$signup_vars = array('action' => 'user', 'command' => 'signup_user');
$template['HOME_LOGIN'] = PHPWS_Text::moduleLink(dgettext('users', 'Home'));
if (PHPWS_Settings::get('users', 'new_user_method')) {
$template['NEW_ACCOUNT'] = PHPWS_Text::moduleLink(USER_SIGNUP_QUESTION, 'users', $signup_vars);
}
$fg_vars = array('action' => 'user', 'command' => 'forgot_password');
$template['FORGOT'] = PHPWS_Text::moduleLink(dgettext('users', 'Forgot password?'), 'users', $fg_vars);
$usermenu = PHPWS_User::getUserSetting('user_menu');
$user = Current_User::getUserObj();
$authorization = $user->getAuthorization();
$template['LOGIN_VIEW'] = $authorization->getView();
return PHPWS_Template::process($template, 'users', 'usermenus/' . $usermenu);
}