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


PHP Authentication::getInstance方法代码示例

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


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

示例1: registerObjects

 public function registerObjects()
 {
     $key = 'class';
     if (!$this->parameterExists($key)) {
         throw new Exception("Parameter '{$key}' not set\n");
     }
     $classname = $this->getParameter($key);
     // user must log in
     $auth = Authentication::getInstance();
     $key = 'username';
     if (!$this->parameterExists($key)) {
         throw new Exception("Parameter '{$key}' not set\n");
     }
     $username = $this->getParameter($key);
     $key = 'password';
     if (!$this->parameterExists($key)) {
         throw new Exception("Parameter '{$key}' not set\n");
     }
     $password = $this->getParameter($key);
     $auth->login($username, $password, false);
     // user must have backend rights
     if ($auth->isLogin() && !$auth->isRole(SystemUser::ROLE_BACKEND)) {
         throw new Exception('Access denied.');
     }
     try {
         $this->director->pluginManager->loadPlugin($classname);
     } catch (Exception $e) {
         // normal plugin failed, try to load admin plugin
         $this->director->adminManager->loadPlugin($classname);
         //throw new Exception($e->getMessage());
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:32,代码来源:CliServer.php

示例2: saveToDb

 private function saveToDb($params)
 {
     $objAuth = Authentication::getInstance();
     $user_id = $objAuth->user_id;
     $objForm = new FormModel();
     $saveData = array();
     $saveData['form_id'] = $params['formSubmit']['id'];
     $saveData['user_id'] = $user_id;
     $saveData['fromPage'] = !empty($params['returnUrlRequest']) ? $params['returnUrlRequest'] : false;
     if (!empty($params['formSubmit']['fields'])) {
         foreach ($params['formSubmit']['fields'] as $fieldId => $value) {
             $fieldInfo = array();
             $fieldInfo['field_id'] = intval($fieldId);
             $fieldInfo['value'] = $value;
             $saveData['fields'][] = $fieldInfo;
         }
     }
     if (!empty($params['formSubmit']['userfields'])) {
         foreach ($params['formSubmit']['userfields'] as $fieldId => $value) {
             $fieldInfo = array();
             $fieldInfo['field_id'] = intval($fieldId);
             $fieldInfo['value'] = $value;
             $saveData['fields'][] = $fieldInfo;
         }
     }
     $submission_id = $objForm->saveSubmission($saveData);
     return $submission_id;
 }
开发者ID:ngardner,项目名称:BentoCMS,代码行数:28,代码来源:Form.php

示例3: filterFields

 /**
  * filters field values like checkbox conversion and date conversion
  *
  * @param array unfiltered values
  * @return array filtered values
  * @see DbConnector::filterFields
  */
 public function filterFields($fields)
 {
     $authentication = Authentication::getInstance();
     $userId = $authentication->getUserId();
     $fields['usr_id'] = $userId['id'];
     return $fields;
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:14,代码来源:NewsTreeRef.php

示例4: initialize

 private function initialize()
 {
     $auth = Authentication::getInstance();
     if (!$auth->isLogin() || !$auth->isRole(SystemUser::ROLE_ADMIN)) {
         throw new Exception('Access denied');
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:7,代码来源:InstallPlugin.php

示例5: __construct

 function __construct($user_id = '')
 {
     parent::__construct();
     $this->permissions = new PermissionsModel();
     $this->objAuthentication = Authentication::getInstance();
     if (!empty($user_id)) {
         $this->setUserId($user_id);
     }
 }
开发者ID:ngardner,项目名称:BentoCMS,代码行数:9,代码来源:UserModel.php

示例6: setInformations

 private function setInformations()
 {
     try {
         $model = new UserModel();
         self::$informations = $model->getUser(Authentication::getInstance()->getUserId());
     } catch (InputNotSetException $e) {
         $e->getMessage();
     }
 }
开发者ID:kazuohirai,项目名称:awayfromswag,代码行数:9,代码来源:UserInformations.php

示例7: smarty_function_form

/**
 * Smarty {form} function plugin
 *
 * Type:     function<br>
 * Name:     form<br>
 * Purpose:  generates form from database<br>
 * @author Nathan Gardner <nathan@factory8.com>
 */
function smarty_function_form($localparams, &$smarty)
{
    global $params;
    if (!empty($localparams['identifier'])) {
        $objForm = new FormModel();
        $objAuth = Authentication::getInstance();
        $objTemplate = new TemplatesModel();
        $objUser = new UserModel($objAuth->user_id);
        $userInfo = $objUser->getInfo();
        $form_id = $objForm->getFormId($localparams['identifier']);
        if ($form_id) {
            $formInfo = $objForm->loadForm($form_id);
            $templateInfo = $objTemplate->loadTemplateFromKeyname('form');
            // assign values if already submitted
            if (!empty($params['formSubmit']['fields']) && !empty($formInfo['fields'])) {
                foreach ($formInfo['fields'] as &$formField) {
                    foreach ($params['formSubmit']['fields'] as $submittedId => $submittedValue) {
                        if ($formField['id'] == $submittedId) {
                            if ($formField['type'] == 'checkbox' || $formField['type'] == 'radio') {
                                $formField['checked'] = 'checked';
                            } else {
                                $formField['value'] = $submittedValue;
                            }
                            break;
                        }
                    }
                }
            }
            // assign error flag and message if invalid
            if (!empty($params['formErrors']) && !empty($formInfo['fields'])) {
                foreach ($params['formErrors'] as $formError) {
                    foreach ($formInfo['fields'] as &$formField) {
                        if ($formError['field_id'] == $formField['id']) {
                            $formField['hasError'] = true;
                            $formField['errorMsg'] = $formError['errorMsg'];
                            break;
                        }
                    }
                }
            }
            // assign var to template
            if (!empty($params['formSubmitted'])) {
                $smarty->assign('formSubmitted', 1);
            }
            if (!empty($params['formErrors'])) {
                $smarty->assign('formErrors', $params['formErrors']);
            }
            $smarty->assign('formInfo', $formInfo);
            $output = $smarty->fetch('fromstring:' . $templateInfo['content']);
        } else {
            return 'Unknown form identifier';
        }
    } else {
        return 'Must pass an identifier';
    }
    return $output;
}
开发者ID:ngardner,项目名称:BentoCMS,代码行数:65,代码来源:function.form.php

示例8: assignCommons

 function assignCommons()
 {
     global $params;
     ##prod info
     $this->assign('ProductTitle', PRODUCT_NAME);
     ##skin dir
     $this->assign('skin', '/' . $this->location . '/views/');
     $this->assign('bento', '/bento/');
     ##global url http/https
     if (empty($_SERVER["HTTPS"])) {
         $this->assign('httpUrl', 'http://' . URL . '/');
     } else {
         $this->assign('httpUrl', 'https://' . URL . '/');
     }
     ##site settings
     $objSettings = Settings::getInstance();
     $settings = $objSettings->getEntrys();
     $this->assign('Settings', $settings);
     $metaTitle = $settings['meta']['default-meta-title'];
     $metaDescription = $settings['meta']['default-meta-description'];
     $metaKeywords = $settings['meta']['default-meta-keywords'];
     if (!empty($params['_urlrequest'])) {
         $objUrls = new FriendlyurlModel();
         $objUrls->parseRequest($params['_urlrequest']);
         $urlMeta = $objUrls->getMetaData($objUrls->url_id);
         if (!empty($urlMeta['title'])) {
             $metaTitle = $urlMeta['title'];
         }
         if (!empty($urlMeta['description'])) {
             $metaDescription = $urlMeta['description'];
         }
         if (!empty($urlMeta['keywords'])) {
             $metaKeywords = $urlMeta['keywords'];
         }
         $this->assign('urlrequest', $params['_urlrequest']);
     }
     ##meta deta
     $this->assign('metaTitle', $metaTitle);
     $this->assign('metaDescription', $metaDescription);
     $this->assign('metaKeywords', $metaKeywords);
     ##global filesystem path
     $this->assign('fsPath', DIR);
     ##user vars
     $objAuthentication = Authentication::getInstance();
     if ($objAuthentication->loggedIn()) {
         $objUser = new UserModel($objAuthentication->user_id);
         $this->assign('loggedIn', true);
         $this->assign('UserInfo', $objUser->getInfo());
     } else {
         $this->assign('loggedIn', false);
     }
 }
开发者ID:ngardner,项目名称:BentoCMS,代码行数:52,代码来源:View.php

示例9: saveSearch

 private function saveSearch($query)
 {
     $objAuth = Authentication::getInstance();
     if ($objAuth->loggedIn()) {
         $user_id = $objAuth->user_id;
     } else {
         $user_id = 0;
     }
     $this->db->reset();
     $this->db->assign_str('searchQuery', $query);
     $this->db->assign('user_id', $user_id);
     $this->db->insert('searches');
     return true;
 }
开发者ID:ngardner,项目名称:BentoCMS,代码行数:14,代码来源:SearchModel.php

示例10: initialize

 private function initialize()
 {
     $request = Request::getInstance();
     $siteGroup = $this->director->siteGroup;
     // disable caching if disabled or type is not get
     if (!$this->director->getConfig()->enable_caching || $request->getRequestType() != Request::GET) {
         $this->setCacheable(false);
         self::$cacheEnabled = false;
     }
     $authentication = Authentication::getInstance();
     $this->path = realpath(DIF_SYSTEM_ROOT . $this->director->getConfig()->path) . '/';
     $userId = $authentication->getUserId();
     $this->url = $request->getUrl() . $userId['id'] . $siteGroup->getCurrentId();
     $this->expiration = $this->director->getConfig()->expiration;
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:15,代码来源:Cache.php

示例11: smarty_block_userHasPermission

/**
 * Smarty {userHasPermission} block plugin
 *
 * Type:     block<br>
 * Name:     userHasPermission<br>
 * Purpose: Outputs $content if user has permission
 * Useage:  {userHasPermission controller='foo' action='bar'}you have permission{/userHasPermission}
 * @author Nathan Gardner <nathan@factory8.com>
 */
function smarty_block_userHasPermission(&$params, $content, &$smarty, &$repeat)
{
    if (!empty($params['controller']) && !empty($params['action'])) {
        $objPermissions = Permissions::getInstance();
        $objAuth = Authentication::getInstance();
        $user_id = $objAuth->user_id;
        $isAllowed = $objPermissions->actionAllowed($params['controller'], $params['action'], $user_id);
        if ($isAllowed) {
            return $content;
        } else {
            return false;
        }
    } else {
        echo 'Must pass controller and action to do permission check.';
    }
}
开发者ID:ngardner,项目名称:BentoCMS,代码行数:25,代码来源:block.userHasPermission.php

示例12: before

 public function before()
 {
     //return;
     $request = $this->getAction()->getRequest();
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $resModule = ucfirst($module);
     $resController = $resModule . '_' . ucfirst($controller);
     $resAction = $resController . '_' . ucfirst($action);
     $aclFile = ZOODPP_APP . '/access/acl.php';
     if (file_exists($aclFile)) {
         include $aclFile;
     }
     $aclFile = ZOODPP_APP . '/access/acl.' . strtolower($module[0]) . substr($module, 1) . '.php';
     if (file_exists($aclFile)) {
         include $aclFile;
     }
     if (isset($ACL_IGNORE[$resModule]) && (in_array($resAction, $ACL_IGNORE[$resModule]) || in_array($resController, $ACL_IGNORE[$resModule]) || in_array($resModule, $ACL_IGNORE[$resModule]))) {
         //Permission check ignored, do nothing
     } else {
         if (isset($ACL_LOGIN[$resModule]) && (in_array($resAction, $ACL_LOGIN[$resModule]) || in_array($resController, $ACL_LOGIN[$resModule]) || in_array($resModule, $ACL_LOGIN[$resModule]))) {
             //Only login is required, check whether user has logged in or not
             $isLoggedIn = Authentication::getInstance()->isLoggedIn();
             if (!$isLoggedIn) {
                 exit('You are not allowed to access this action. <a href="/login/">Click here to Login!</a> ');
             }
         } else {
             $permissionNeeded = array();
             if (isset($ACL[$resModule]) && !empty($ACL[$resModule])) {
                 $permissionNeeded += $ACL[$resModule];
             }
             if (isset($ACL[$resController]) && !empty($ACL[$resController])) {
                 $permissionNeeded += $ACL[$resController];
             }
             if (isset($ACL[$resAction]) && !empty($ACL[$resAction])) {
                 $permissionNeeded += $ACL[$resAction];
             }
             if (!empty($permissionNeeded)) {
                 //@todo 检查相应权限
             }
         }
     }
 }
开发者ID:BGCX261,项目名称:zoodphp-svn-to-git,代码行数:44,代码来源:ActionAccessInterceptor.php

示例13: getUserList

 /**
  * Returns protected var $oberserver.
  * @param string observer key
  * @return array
  */
 public function getUserList($search)
 {
     try {
         if (!array_key_exists('tree_id', $search)) {
             throw new Exception('Tree node not set');
         }
         if (!array_key_exists('tag', $search)) {
             throw new Exception('Template tag not set');
         }
         if (!array_key_exists('date', $search)) {
             throw new Exception('Date not set');
         }
         if (!array_key_exists('hour', $search)) {
             throw new Exception('Hour not set');
         }
         $maxpage = 10;
         $page = array_key_exists('page', $search) ? intval($search['page']) : 0;
         $hour = $search['hour'];
         $date = $search['date'] ? $search['date'] : date('Y-m-d');
         $authentication = Authentication::getInstance();
         $user = $authentication->getUserId();
         $usr_id = $user['id'];
         $canEdit = $authentication->canEdit($search['tree_id']);
         $canView = $authentication->canView($search['tree_id']);
         if (!$canEdit && !$canView) {
             throw new Exception('Access denied');
         }
         $subObj = $this->getObject(self::TYPE_DEFAULT);
         $settingObj = $this->getObject(self::TYPE_SETTINGS);
         $settings = $settingObj->getSettings($search['tree_id'], $search['tag']);
         // get linked users
         $userLink = new ReservationUserLink();
         $list = $userLink->getList(array('own_id' => $usr_id));
         $userList = array($usr_id);
         foreach ($list['data'] as $item) {
             $userList[] = $item['usr_id'];
         }
         $vipCount = $subObj->getVipCount($search);
         $legitimateUserList = $canEdit ? array() : $subObj->getLegitimateUserList($userList, $settings['max_subscribe']);
         // check if there are any users that are allowed to make a reservation
         if (!$legitimateUserList && !$canEdit) {
             throw new Exception("Reservation count exceeded.");
         }
         // user is super user, let him be able to make reservations for his self
         //if(!$legitimateUserList) $legitimateUserList = array($usr_id); // COMMENTED OUT BECAUSE SUPER USER CAN MAKE RESERVATIONS FOR ALL MEMBERS
         $userSearch = array('id' => $legitimateUserList);
         //if($vipCount >= $settings['vip_slots']) $userSearch['no_grp_id'] = $settings['vip_grp_id']; // vip_grp_id is not used anymore
         // add search string for user
         if (array_key_exists('user', $search) && $search['user']) {
             $userSearch['search'] = $search['user'];
         }
         $userObj = $this->director->systemUser;
         // backup pager url
         $tmppagerUrl = $userObj->getPagerUrl();
         $tmppagerKey = $userObj->getPagerKey();
         $url = new JsUrl();
         $url->setPath('javascript:userSearch');
         $url->setParameter('date', "'{$date}'");
         $url->setParameter('hour', $hour);
         $url->setParameter('user', "'{$search['user']}'");
         $userObj->setPagerUrl($url);
         $users = $userObj->getList($userSearch, $maxpage, $page);
         // restore pager url
         $userObj->setPagerUrl($tmppagerUrl);
         $userObj->setPagerKey($tmppagerKey);
         $template = new TemplateEngine($this->getPath() . "templates/reservationuserselect.tpl");
         $template->setVariable('users', $users);
         $template->setVariable('date', $date);
         $template->setVariable('hour', $hour);
         $template->setVariable('htdocs_path', $this->getHtdocsPath(false));
         $template->setVariable('include_vip', $vipCount < $settings['vip_slots']);
         $template->setVariable('usersearch', array_key_exists('user', $search) ? $search['user'] : '');
         return $template->fetch();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:82,代码来源:Reservation.php

示例14: handleRequest

 /**
  * handle request
  */
 public function handleRequest()
 {
     $request = Request::getInstance();
     $auth = Authentication::getInstance();
     if ($request->getRequestType() == Request::POST && !$auth->isLogin()) {
         $this->setIntrusion();
     }
     if ($this->isIntrusion()) {
         $error = $intrusion->getExpiration() ? 'Intrusion detected. Request disabled untill ' . strftime('%c', $intrusion->getExpiration()) : 'Request disabled';
         throw new Exception($error);
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:15,代码来源:Intrusion.php

示例15: __construct

 function __construct()
 {
     parent::__construct();
     $this->objAuthentication = Authentication::getInstance();
     $this->view = new View('frontend');
 }
开发者ID:ngardner,项目名称:BentoCMS,代码行数:6,代码来源:EmailSender.php


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