当前位置: 首页>>代码示例>>PHP>>正文


PHP Current_User::loadAuthorization方法代码示例

本文整理汇总了PHP中Current_User::loadAuthorization方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::loadAuthorization方法的具体用法?PHP Current_User::loadAuthorization怎么用?PHP Current_User::loadAuthorization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Current_User的用法示例。


在下文中一共展示了Current_User::loadAuthorization方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PHPWS_User

<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id: runtime.php 7776 2010-06-11 13:52:58Z jtickle $
 */
if (!class_exists('PHPWS_User')) {
    include '../../core/conf/404.html';
    exit;
}
if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'users' && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset')) {
    $_SESSION['User'] = new PHPWS_User();
} elseif (!isset($_SESSION['User'])) {
    Current_User::init();
    if (Current_User::allowRememberMe()) {
        if (PHPWS_Settings::get('users', 'allow_remember')) {
            Current_User::rememberLogin();
        }
    }
}
Current_User::loadAuthorization($_SESSION['User']);
Current_User::getLogin();
if (Current_User::isLogged() && PHPWS_Settings::get('users', 'session_warning')) {
    $lifetime = ini_get('session.gc_maxlifetime');
    $path = PHPWS_SOURCE_HTTP . 'mod/users/javascript/session_check/script.min.js';
    $timeout = floor($lifetime / 60);
    $warning_minutes = $timeout - 5;
    javascript('jquery');
    \Layout::addJSHeader("<script type='text/javascript'>var sess_expirationMinutes = {$timeout};var sess_warningMinutes = {$warning_minutes};</script>" . "<script type='text/javascript' src='{$path}'></script>");
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:30,代码来源:runtime.php

示例2: loginUser

 /**
  * Logs in a user dependant on their authorization setting
  */
 public static function loginUser($username, $password = null)
 {
     if (!Current_User::allowUsername($username)) {
         return PHPWS_Error::get(USER_BAD_CHARACTERS, 'users', 'Current_User::loginUser');
     }
     // First check if they are currently a user
     $user = new PHPWS_User();
     $db = new PHPWS_DB('users');
     $db->addWhere('username', strtolower($username));
     $result = $db->loadObject($user);
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     if ($result == false) {
         if (PHPWS_Error::logIfError($user->setUsername($username))) {
             return false;
         }
     } else {
         // This user is in the local database
         if (!$user->approved) {
             return PHPWS_Error::get(USER_NOT_APPROVED, 'users', 'Current_User::loginUser');
         }
         if (!$user->loadScript()) {
             Layout::add(dgettext('users', 'Could not load authentication script. Please contact site administrator.'));
             return false;
         }
     }
     if (!Current_User::loadAuthorization($user)) {
         Layout::add(dgettext('users', 'Could not load authentication script. Please contact site administrator.'));
         return false;
     }
     $auth = Current_User::getAuthorization();
     $auth->setPassword($password);
     $result = $auth->authenticate();
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     if ($result == true) {
         // If the user id is zero and the authorization wants a new
         // user created
         if (!$user->id && $auth->create_new_user) {
             $user->setActive(true);
             $user->setApproved(true);
             $auth->createUser();
             $user->save();
             PHPWS_Core::initModClass('users', 'Action.php');
             User_Action::assignDefaultGroup($user);
         }
         if (!$user->active) {
             return PHPWS_Error::get(USER_DEACTIVATED, 'users', 'Current_User:loginUser', $user->username);
         }
         if ($auth->localUser()) {
             $user->login();
         }
         unset($_SESSION['User']);
         $_SESSION['User'] = $user;
         return true;
     } else {
         return false;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:64,代码来源:Current_User.php


注:本文中的Current_User::loadAuthorization方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。