本文整理汇总了PHP中CWebUser类的典型用法代码示例。如果您正苦于以下问题:PHP CWebUser类的具体用法?PHP CWebUser怎么用?PHP CWebUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CWebUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: kannLoeschen
/**
* @param CWebUser $c
* @return bool
*/
public function kannLoeschen($c)
{
if ($this->getVeranstaltung()->isAdminCurUser()) {
return true;
}
if (!is_null($this->verfasserIn->auth) && $c->getId() == $this->verfasserIn->auth) {
return true;
}
return false;
}
示例2: local_generateHeader
function local_generateHeader($data)
{
// only needed for zbx_construct_menu
global $page;
header('Content-Type: text/html; charset=UTF-8');
// construct menu
$main_menu = [];
$sub_menus = [];
zbx_construct_menu($main_menu, $sub_menus, $page, $data['controller']['action']);
$pageHeader = new CView('layout.htmlpage.header', ['javascript' => ['files' => $data['javascript']['files']], 'page' => ['title' => $data['page']['title']], 'user' => ['lang' => CWebUser::$data['lang'], 'theme' => CWebUser::$data['theme']]]);
echo $pageHeader->getOutput();
if ($data['fullscreen'] == 0) {
global $ZBX_SERVER_NAME;
$pageMenu = new CView('layout.htmlpage.menu', ['server_name' => isset($ZBX_SERVER_NAME) ? $ZBX_SERVER_NAME : '', 'menu' => ['main_menu' => $main_menu, 'sub_menus' => $sub_menus, 'selected' => $page['menu']], 'user' => ['is_guest' => CWebUser::isGuest(), 'alias' => CWebUser::$data['alias'], 'name' => CWebUser::$data['name'], 'surname' => CWebUser::$data['surname']]]);
echo $pageMenu->getOutput();
}
echo '<div class="' . ZBX_STYLE_ARTICLE . '">';
// should be replaced with addPostJS() at some point
zbx_add_post_js('initMessages({});');
// if a user logs in after several unsuccessful attempts, display a warning
if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) {
$attempt_ip = CProfile::get('web.login.attempt.ip', '');
$attempt_date = CProfile::get('web.login.attempt.clock', 0);
$error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempt_ip, zbx_date2str(DATE_FORMAT, $attempt_date), zbx_date2str(TIME_FORMAT, $attempt_date), $failedAttempts);
error($error_msg);
CProfile::update('web.login.attempt.failed', 0, PROFILE_TYPE_INT);
}
show_messages();
}
示例3: checkSelementPermissions
/**
* Checks that the user has write permissions to objects used in the map elements.
*
* @throws APIException if the user has no permissions to at least one of the objects
*
* @param array $selements
*/
protected function checkSelementPermissions(array $selements)
{
if (CWebUser::getType() == USER_TYPE_SUPER_ADMIN) {
return;
}
$hostIds = $groupIds = $triggerIds = $mapIds = array();
foreach ($selements as $selement) {
switch ($selement['elementtype']) {
case SYSMAP_ELEMENT_TYPE_HOST:
$hostIds[$selement['elementid']] = $selement['elementid'];
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$groupIds[$selement['elementid']] = $selement['elementid'];
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$triggerIds[$selement['elementid']] = $selement['elementid'];
break;
case SYSMAP_ELEMENT_TYPE_MAP:
$mapIds[$selement['elementid']] = $selement['elementid'];
break;
}
}
if ($hostIds && !API::Host()->isWritable($hostIds) || $groupIds && !API::HostGroup()->isWritable($groupIds) || $triggerIds && !API::Trigger()->isWritable($triggerIds) || $mapIds && !API::Map()->isWritable($mapIds)) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
}
}
示例4: bodyToString
function bodyToString($destroy = true)
{
$setup_left = (new CDiv([(new CDiv())->addClass(ZBX_STYLE_SIGNIN_LOGO), $this->getList()]))->addClass(ZBX_STYLE_SETUP_LEFT);
$setup_right = (new CDiv($this->getStage()))->addClass(ZBX_STYLE_SETUP_RIGHT);
if (CWebUser::$data && CWebUser::getType() == USER_TYPE_SUPER_ADMIN) {
$cancel_button = (new CSubmit('cancel', _('Cancel')))->addClass(ZBX_STYLE_BTN_ALT)->addClass(ZBX_STYLE_FLOAT_LEFT);
if ($this->DISABLE_CANCEL_BUTTON) {
$cancel_button->setEnabled(false);
}
} else {
$cancel_button = null;
}
if (array_key_exists($this->getStep() + 1, $this->stage)) {
$next_button = new CSubmit('next[' . $this->getStep() . ']', _('Next step'));
} else {
$next_button = new CSubmit($this->SHOW_RETRY_BUTTON ? 'retry' : 'finish', _('Finish'));
}
$back_button = (new CSubmit('back[' . $this->getStep() . ']', _('Back')))->addClass(ZBX_STYLE_BTN_ALT)->addClass(ZBX_STYLE_FLOAT_LEFT);
if ($this->getStep() == 0 || $this->DISABLE_BACK_BUTTON) {
$back_button->setEnabled(false);
}
$setup_footer = (new CDiv([new CDiv([$next_button, $back_button]), $cancel_button]))->addClass(ZBX_STYLE_SETUP_FOOTER);
$setup_container = (new CDiv([$setup_left, $setup_right, $setup_footer]))->addClass(ZBX_STYLE_SETUP_CONTAINER);
return parent::bodyToString($destroy) . $setup_container->ToString();
}
示例5: getReturnUrl
public function getReturnUrl($defaultUrl = null)
{
if ($defaultUrl === null) {
$defaultUrl = $this->defaultReturnUrl;
}
return parent::getReturnUrl($defaultUrl);
}
示例6: beforeLogin
protected function beforeLogin($id, $states, $fromCookie)
{
if ($fromCookie) {
//the cookie isn't here, so we refuse the login
if (!isset($states[UserIdentity::LOGIN_TOKEN])) {
return false;
}
$model = Users::model()->findByPk($id);
if ($model == null) {
return false;
}
//check if cookie is correct
$cookieLoginToken = $states[UserIdentity::LOGIN_TOKEN];
if (!isset($cookieLoginToken) || $cookieLoginToken != $model->logintoken) {
return false;
}
if (!$model->activated || $model->blocked || $model->deleted) {
//user deleted
return false;
}
}
if (!parent::beforeLogin($id, $states, $fromCookie)) {
return false;
}
return true;
}
示例7: checkAccess
public function checkAccess($operation, $params=array(), $allowCaching=true)
{
if(!Yum::hasModule('role') || Yum::module('role')->useYiiCheckAccess )
return parent::checkAccess($operation, $params, $allowCaching);
return $this->can($operation);
}
示例8: checkAccess
public function checkAccess($operation, $params = array(), $allowCaching = true)
{
if ($operation === 'admin') {
return $this->isAdmin();
}
return parent::checkAccess($operation, $params, $allowCaching);
}
示例9: checkAccess
/**
* Performs access check for this user.
* @param string $operation the name of the operation that need access check.
* @param array $params name-value pairs that would be passed to business rules associated
* with the tasks and roles assigned to the user.
* @param boolean $allowCaching whether to allow caching the result of access check.
* @return boolean whether the operations can be performed by this user.
*/
public function checkAccess($operation, $params = array(), $allowCaching = true)
{
if ($this->getIsAdmin()) {
return true;
}
return parent::checkAccess($operation, $params, $allowCaching);
}
示例10: __set
public function __set($attributeName, $value)
{
if ($attributeName == 'userModel') {
$this->userModel = $value;
} else {
parent::__set($attributeName, $value);
}
}
示例11: getReturnUrl
public function getReturnUrl($defaultUrl = '/')
{
$returnUrl = parent::getReturnUrl($defaultUrl);
if ($returnUrl == '/index.php') {
return '/';
}
return $returnUrl;
}
示例12: checkAccess
public function checkAccess($operation, $params = array(), $allowCaching = true)
{
if ($operation == 'administrator') {
return Permission::model()->hasGlobalPermission('superadmin', 'read');
} else {
return parent::checkAccess($operation, $params, $allowCaching);
}
}
示例13: isCustomer
public function isCustomer()
{
if ($this->_isCustomer === null) {
$customer_user_role = Yii::app()->getModule('user')->customerUser['role'];
$this->_isCustomer = parent::checkAccess($customer_user_role);
}
return $this->_isCustomer;
}
示例14: afterLogin
protected function afterLogin($fromCookie)
{
parent::afterLogin($fromCookie);
$this->updateSession();
$this->updateIdentity();
$this->recordlogintime();
$this->recordonline();
}
示例15: login
/**
* @param IUserIdentity $identity
* @param int $duration
* @return bool
*/
public function login($identity, $duration = 0)
{
$this->setState("__branchId", $identity->getBranchId());
$this->setState("__scope", $identity->getScope());
$this->setState("__roles", $identity->getRoles());
$this->setState("__userData", $identity->getUserData());
return parent::login($identity, $duration);
}