本文整理汇总了PHP中Current_User::getAuthorization方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::getAuthorization方法的具体用法?PHP Current_User::getAuthorization怎么用?PHP Current_User::getAuthorization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current_User
的用法示例。
在下文中一共展示了Current_User::getAuthorization方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main()
{
$auth = Current_User::getAuthorization();
if (!Current_User::isLogged() || !$auth->local_user) {
PHPWS_Core::errorPage('403');
}
$result = $this->init();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'The is a problem with My Page.')));
return;
} elseif (!$result) {
Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'No modules are registered to My Page.')));
return;
}
$panel = My_Page::cpanel();
$module = $panel->getCurrentTab();
if (!$this->moduleIsRegistered($module)) {
Layout::add(dgettext('users', 'This module is not registered with My Page'));
return;
}
$content = My_Page::userOption($module);
if (PHPWS_Error::isError($content)) {
$content = $content->getMessage();
}
Layout::add(PHPWS_ControlPanel::display($content));
}
示例2: loadNavBar
public static function loadNavBar()
{
$auth = \Current_User::getAuthorization();
$vars['is_admin'] = \Current_User::allow('election');
$vars['logout_uri'] = $auth->logout_link;
$vars['username'] = \Current_User::getDisplayName();
$template = new \Template($vars);
$template->setModuleTemplate('election', 'navbar.html');
$content = $template->get();
\Layout::plug($content, 'NAV_LINKS');
}
示例3: loggedIn
public static function loggedIn()
{
$auth = Current_User::getAuthorization();
$template['GREETING'] = dgettext('users', 'Hello');
$template['USERNAME'] = Current_User::getUsername();
$template['DISPLAY_NAME'] = Current_User::getDisplayName();
$template['PANEL'] = $template['MODULES'] = PHPWS_ControlPanel::panelLink();
$logout_link = $auth->getLogoutLink();
$template['ACCOUNT'] = '<a href="index.php?module=users&action=user&tab=my_page">' . dgettext('users', '<span class="glyphicon glyphicon-user"></span> Account') . '</a>';
if ($logout_link) {
$template['LOGOUT'] =& $logout_link;
} else {
$template['LOGOUT'] = PHPWS_Text::moduleLink(dgettext('users', '<span class="fa fa-sign-out"></span> Log Out'), 'users', array('action' => 'user', 'command' => 'logout'));
}
$template['HOME_USER_PANEL'] = $template['HOME'] = PHPWS_Text::moduleLink(dgettext('users', 'Home'));
$usermenu = PHPWS_User::getUserSetting('user_menu');
return PHPWS_Template::process($template, 'users', 'usermenus/' . $usermenu);
}
示例4: plug
public static function plug()
{
$tpl = array();
$tpl['HOME_LINK'] = PHPWS_Text::moduleLink('Menu', 'intern');
$tpl['ADD_LINK'] = PHPWS_Text::moduleLink('Add Student', 'intern', array('action' => 'edit_internship'));
$tpl['SEARCH_LINK'] = PHPWS_Text::moduleLink('Search', 'intern', array('action' => 'search'));
$auth = Current_User::getAuthorization();
$tpl['USER_FULL_NAME'] = Current_User::getDisplayName();
$tpl['LOGOUT_URI'] = $auth->logout_link;
$adminOptions = array();
// Edit list of majors
if (Current_User::allow('intern', 'edit_major')) {
$adminOptions['EDIT_MAJORS_LINK'] = PHPWS_Text::secureLink('Edit Undergraduate Majors', 'intern', array('action' => MAJOR_EDIT));
}
// Edit list grad programs
if (Current_User::allow('intern', 'edit_grad_prog')) {
$adminOptions['EDIT_GRAD_LINK'] = PHPWS_Text::secureLink('Edit Graduate Programs', 'intern', array('action' => GRAD_PROG_EDIT));
}
// Edit departments
if (Current_User::allow('intern', 'edit_dept')) {
$adminOptions['EDIT_DEPARTMENTS_LINK'] = PHPWS_Text::secureLink('Edit Departments', 'intern', array('action' => DEPT_EDIT));
}
// Edit list of states
if (Current_User::allow('intern', 'edit_states')) {
$adminOptions['EDIT_STATES_LINK'] = PHPWS_Text::secureLink('Edit States', 'intern', array('action' => STATE_EDIT));
}
if (Current_User::isDeity()) {
$adminOptions['CONTROL_PANEL'] = PHPWS_Text::secureLink('Control Panel', 'controlpanel');
$adminOptions['EDIT_ADMINS_LINK'] = PHPWS_Text::secureLink('Edit Administrators', 'intern', array('action' => 'edit_admins'));
}
// If any admin options were added, them show the dropdown and merge those
// links into the main set of template tags
if (sizeof($adminOptions) > 0) {
$tpl['ADMIN_OPTIONS'] = '';
// dummy var to show dropdown menu in template
$tpl = array_merge($tpl, $adminOptions);
}
Layout::plug(PHPWS_Template::process($tpl, 'intern', 'top.tpl'), 'NAV_LINKS');
}
示例5: getLogoutURI
public static function getLogoutURI()
{
return Current_User::getAuthorization()->logout_link;
}
示例6: addNavLinks
/**
* This function adds links to the navigation bar at the top of the page.
* This function assumes that there is a NAV_LINKS tag in the main theme template.
*/
private function addNavLinks()
{
// Link to the pages. One nav button for each link.
$viewStats = array("LINK" => "index.php?module=faxmaster&op=show_stats", "TEXT" => "View Statistics");
$viewArchive = array("LINK" => "index.php?module=faxmaster&op=show_archive", "TEXT" => "View Archive");
$settings = array("LINK" => "index.php?module=faxmaster&op=settings", "TEXT" => "Settings");
$actionLog = array("LINK" => "index.php?module=faxmaster&op=showActionLog", "TEXT" => "Action Log");
// Fill the links array
$links = array();
$links['repeat_nav_links'][] = $viewStats;
// view stats button
// Only show 'View Archive' button if user has permission to view the archive
if (Current_User::allow('faxmaster', 'viewArchive')) {
$links['repeat_nav_links'][] = $viewArchive;
// view archive button
}
// Only show 'Settings' button if user has proper permissions
if (Current_User::allow('faxmaster', 'settings')) {
$links['repeat_nav_links'][] = $settings;
// settings button
}
$links['repeat_nav_links'][] = $actionLog;
$links['BRAND'] = 'Fax Server';
$links['BRAND_LINK'] = 'index.php';
if (Current_User::isDeity()) {
$links['CONTROL_PANEL'] = PHPWS_Text::secureLink('Control Panel', 'controlpanel');
$links['ADMIN_OPTIONS'] = '';
//dummy tag to show dropdown menu in template
}
$links['USER_FULL_NAME'] = Current_User::getDisplayName();
$auth = Current_User::getAuthorization();
$links['LOGOUT_URI'] = $auth->logout_link;
// Plug the navlinks into the navbar
$navLinks = PHPWS_Template::process($links, 'faxmaster', 'navLinks.tpl');
Layout::plug($navLinks, 'NAV_LINKS');
}
示例7: loadAdminBar
public static function loadAdminBar()
{
$auth = \Current_User::getAuthorization();
$nav_vars['is_deity'] = \Current_user::isDeity();
$nav_vars['logout_uri'] = $auth->logout_link;
$nav_vars['username'] = \Current_User::getDisplayName();
if (\Current_User::allow('systemsinventory', 'edit')) {
$nav_vars['add'] = '<a href="systemsinventory/system/add"><i class="fa fa-plus"></i> Add System</a>';
}
if (\Current_User::allow('systemsinventory', 'view')) {
$nav_vars['search'] = '<a href="systemsinventory/search"><i class="fa fa-search"></i> Search Systems</a>';
}
if (\Current_User::allow('systemsinventory', 'reports')) {
$nav_vars['reports'] = '<a href="systemsinventory/reports"><i class="fa fa-area-chart"></i> Reports</a>';
}
if (\Current_User::allow('systemsinventory', 'settings')) {
$nav_vars['settings'] = '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"><i class="fa fa-cog"></i> Settings</a>';
}
$nav_bar = new \Template($nav_vars);
$nav_bar->setModuleTemplate('systemsinventory', 'navbar.html');
$content = $nav_bar->get();
\Layout::plug($content, 'NAV_LINKS');
}
示例8: userAction
/**
* Controller of user requests. Based on the command request variable
* defaults to my_page
*/
public static function userAction()
{
$auth = Current_User::getAuthorization();
$content = $title = null;
if (isset($_REQUEST['command'])) {
$command = $_REQUEST['command'];
} else {
$command = 'my_page';
}
switch ($command) {
case 'login':
if (!Current_User::isLogged() && isset($_POST['phpws_username']) && isset($_POST['phpws_password'])) {
$result = Current_User::loginUser($_POST['phpws_username'], $_POST['phpws_password']);
// here
if (!$result) {
$title = dgettext('users', 'Login page');
$message = dgettext('users', 'Username and password combination not found.');
$content = User_Form::loginPage();
} elseif (PHPWS_Error::isError($result)) {
if (preg_match('/L\\d/', $result->code)) {
$title = dgettext('users', 'Sorry');
$content = $result->getMessage();
$content .= ' ' . sprintf('<a href="mailto:%s">%s</a>', PHPWS_User::getUserSetting('site_contact'), dgettext('users', 'Contact the site administrator'));
} else {
PHPWS_Error::log($result);
$message = dgettext('users', 'A problem occurred when accessing user information. Please try again later.');
}
} else {
Current_User::getLogin();
PHPWS_Core::returnToBookmark();
}
} else {
PHPWS_Core::errorPage('403');
}
break;
// This is used by auth scripts if they need to return the user to
// where they left off after redirection to another site for SSO
// This is used by auth scripts if they need to return the user to
// where they left off after redirection to another site for SSO
case 'return_bookmark':
PHPWS_Core::popUrlHistory();
break;
// reset user password
// reset user password
case 'rp':
$user_id = User_Action::checkResetPassword();
if ($user_id) {
$title = dgettext('users', 'Reset my password');
$content = User_Form::resetPassword($user_id, $_GET['auth']);
} else {
$title = dgettext('users', 'Sorry');
$content = dgettext('users', 'Your password request was not found or timed out. Please apply again.');
}
break;
case 'my_page':
if ($auth->local_user) {
PHPWS_Core::initModClass('users', 'My_Page.php');
$my_page = new My_Page();
$my_page->main();
} else {
Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'My Page unavailable to remote users.'), 'my_page'));
}
break;
case 'signup_user':
$title = dgettext('users', 'New Account Sign-up');
if (Current_User::isLogged()) {
$content = dgettext('users', 'You already have an account.');
break;
}
$user = new PHPWS_User();
if (PHPWS_User::getUserSetting('new_user_method') == 0) {
$content = dgettext('users', 'Sorry, we are not accepting new users at this time.');
break;
}
$content = User_Form::signup_form($user);
break;
case 'submit_new_user':
$title = dgettext('users', 'New Account Sign-up');
$user_method = PHPWS_User::getUserSetting('new_user_method');
if ($user_method == 0) {
Current_User::disallow(dgettext('users', 'New user signup not allowed.'));
return;
}
$user = new PHPWS_User();
$result = User_Action::postNewUser($user);
if (is_array($result)) {
$content = User_Form::signup_form($user, $result);
} else {
$content = User_Action::successfulSignup($user);
}
break;
case 'logout':
$auth = Current_User::getAuthorization();
$auth->logout();
PHPWS_Core::killAllSessions();
PHPWS_Core::reroute('index.php?module=users&action=reset');
//.........这里部分代码省略.........
示例9: isLocalUser
public static function isLocalUser()
{
$auth = Current_User::getAuthorization();
return $auth->local_user;
}