本文整理汇总了PHP中XLite\Core\Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Auth类的具体用法?PHP Auth怎么用?PHP Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: correctProfileIdForURLParams
/**
* Remove profileId from URL params if it is profileId of already logged in user
*
* @param integer $profileId Profile ID
*
* @return integer
*/
protected function correctProfileIdForURLParams($profileId)
{
if (\XLite\Core\Auth::getInstance()->getProfile()->getProfileId() === $profileId) {
$profileId = null;
}
return $profileId;
}
示例2: getPortalDrupalArgs
/**
* Argument convertion: <LC> --> <DRUPAL>
*
* @param string $path Drupal path
* @param array $args LC URL arguments OPTIONAL
*
* @return array
*/
public static function getPortalDrupalArgs($path, array $args = array())
{
$id = empty($args['profile_id']) ? \XLite\Core\Auth::getInstance()->getProfile()->getProfileId() : $args['profile_id'];
unset($args['profile_id']);
list($path, $args) = parent::getPortalDrupalArgs($path, $args);
$path = preg_replace('/\\%/', static::getDrupalProfileId($id), $path, 1);
return array($path, $args);
}
示例3: getUserTypes
/**
* Get user types
*
* @return array
*/
protected function getUserTypes()
{
$types = array('C' => static::t('Registered Customers'), 'N' => static::t('Anonymous Customers'));
if (\XLite\Core\Auth::getInstance()->isPermissionAllowed('manage admins')) {
$types['A'] = static::t('Administrator');
}
return $types;
}
示例4: defineWidgetParams
/**
* Define widget parameters
*
* @return void
*/
protected function defineWidgetParams()
{
parent::defineWidgetParams();
$this->widgetParams[static::PARAM_LIST]->setValue('content');
$this->widgetParams[static::PARAM_CLASS]->setValue('hl');
$this->widgetParams[static::PARAM_TITLE]->setValue(static::t('Content'));
$this->widgetParams[static::PARAM_TARGET]->setValue(\XLite\Core\Auth::getInstance()->isPermissionAllowed('manage custom pages') ? 'pages' : 'menus');
}
示例5: fireEvent
/**
* Fire event
*
* @return void
*/
protected function fireEvent()
{
\XLite\Core\Event::switchStorefront(array('opened' => !\XLite\Core\Auth::getInstance()->isClosedStorefront(), 'link' => $this->buildURL('storefront', '', array('action' => \XLite\Core\Auth::getInstance()->isClosedStorefront() ? 'open' : 'close')), 'privatelink' => $this->getAccessibleShopURL(false)));
if ($this->isAJAX()) {
$this->silent = true;
$this->setSuppressOutput(true);
}
}
示例6: checkFieldValue
/**
* Check field value validity
*
* @return boolean
*/
protected function checkFieldValue()
{
$isAllowedForCurrentUser = TRUE;
if (!\XLite\Core\Auth::getInstance()->isPermissionAllowed('manage admins') && $this->getValue() == \XLite\Core\Auth::getInstance()->getAdminAccessLevel()) {
$isAllowedForCurrentUser = FALSE;
}
return $isAllowedForCurrentUser && in_array($this->getValue(), \XLite\Core\Auth::getInstance()->getAccessLevelsList());
}
示例7: doActionConfirmWithPassword
/**
* Do action
*
* @return void
*/
protected function doActionConfirmWithPassword()
{
$password = \XLite\Core\Request::getInstance()->password;
$result = null !== $password && \XLite\Core\Auth::comparePassword(\XLite\Core\Auth::getInstance()->getProfile()->getPassword(), $password);
if (!$result) {
\XLite\Core\TopMessage::addError('Incorrect password. Please try again.');
}
\XLite\Core\Event::passwordConfirmed(array('result' => $result));
}
示例8: getInstance
/**
* Method to access a singleton
*
* @param boolean $doCalculate Flag for cart recalculation OPTIONAL
*
* @return \XLite\Model\Cart
*/
public static function getInstance($doCalculate = true)
{
$className = get_called_class();
// Create new instance of the object (if it is not already created)
if (!isset(static::$instances[$className])) {
$auth = \XLite\Core\Auth::getInstance();
if ($auth->isLogged()) {
// Try to find cart of logged in user
$cart = \XLite\Core\Database::getRepo('XLite\\Model\\Cart')->findOneByProfile($auth->getProfile());
}
if (empty($cart)) {
// Try to get cart from session
$orderId = \XLite\Core\Session::getInstance()->order_id;
if ($orderId) {
$cart = \XLite\Core\Database::getRepo('XLite\\Model\\Cart')->findOneForCustomer($orderId);
// Forget cart if cart is order
if ($cart && !$cart->hasCartStatus()) {
unset(\XLite\Core\Session::getInstance()->order_id, $cart);
}
}
}
if (!isset($cart)) {
// Cart not found - create a new instance
$cart = new $className();
$cart->initializeCart();
}
static::$instances[$className] = $cart;
if ($auth->isLogged() && (!$cart->getProfile() || $auth->getProfile()->getProfileId() != $cart->getProfile()->getProfileId())) {
$cart->setProfile($auth->getProfile());
$cart->setOrigProfile($auth->getProfile());
}
// Check login state
if (\XLite\Core\Session::getInstance()->lastLoginUnique === null && $cart->getProfile() && $cart->getProfile()->getAnonymous() && $cart->getProfile()->getLogin()) {
$tmpProfile = new \XLite\Model\Profile();
$tmpProfile->setProfileId(0);
$tmpProfile->setLogin($cart->getProfile()->getLogin());
$profile2 = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findUserWithSameLogin($tmpProfile);
if ($profile2) {
\XLite\Core\Database::getEM()->detach($profile2);
}
\XLite\Core\Session::getInstance()->lastLoginUnique = !$profile2;
}
if (!$doCalculate) {
$cart->setIgnoreLongCalculations();
}
if (!$cart->isIgnoreLongCalculations() && ($cart instanceof \XLite\Model\Cart || \XLite\Core\Converter::time() - static::RENEW_PERIOD > $cart->getLastRenewDate())) {
$cart->renew();
} else {
$cart->calculate();
}
$cart->renewSoft();
\XLite\Core\Session::getInstance()->order_id = $cart->getOrderId();
}
return static::$instances[$className];
}
示例9: doActionConfirmWithPassword
/**
* Do action
*
* @return void
*/
protected function doActionConfirmWithPassword()
{
$password = \XLite\Core\Request::getInstance()->password;
$result = null !== $password && \XLite\Core\Auth::comparePassword(\XLite\Core\Auth::getInstance()->getProfile()->getPassword(), $password);
if ($result) {
echo 1;
} else {
\XLite\Core\TopMessage::addError('Incorrect password. Please try again.');
echo 0;
}
}
示例10: getAdminAreaURLArgs
/**
* Return URL to redirect to
*
* @return string
*/
protected function getAdminAreaURLArgs()
{
$query = '';
if (\XLite\Core\Auth::getInstance()->isAdmin()) {
$query .= '?' . \XLite\Core\Session::getInstance()->getName();
$query .= '=' . \XLite\Core\Session::getInstance()->getId();
$query .= '&' . static::PARAM_DRUPAL_RETURN_URL;
$query .= '=' . urlencode(\Includes\Utils\URLManager::getCurrentURL());
}
return $query;
}
示例11: defineItems
/**
* Define menu items
*
* @return array
*/
protected function defineItems()
{
$menu = array();
$cnd = new \XLite\Core\CommonCell();
$cnd->type = \XLite\Module\CDev\SimpleCMS\Model\Menu::MENU_TYPE_FOOTER;
$cnd->enabled = true;
$cnd->visibleFor = array('AL', \XLite\Core\Auth::getInstance()->isLogged() ? 'L' : 'A');
foreach (\XLite\Core\Database::getRepo('XLite\\Module\\CDev\\SimpleCMS\\Model\\Menu')->search($cnd) as $v) {
$menu[] = array('url' => $v->getURL(), 'label' => $v->getName(), 'controller' => $v->getLinkController());
}
return $menu ?: parent::defineItems();
}
示例12: defineItems
/**
* Define menu items
*
* @return array
*/
protected function defineItems()
{
$menu = array();
$cnd = new \XLite\Core\CommonCell();
$cnd->type = \XLite\Module\CDev\SimpleCMS\Model\Menu::MENU_TYPE_PRIMARY;
$cnd->enabled = true;
$cnd->visibleFor = array('AL', \XLite\Core\Auth::getInstance()->isLogged() ? 'L' : 'A');
foreach (\XLite\Core\Database::getRepo('XLite\\Module\\CDev\\SimpleCMS\\Model\\Menu')->search($cnd) as $v) {
$menu[] = $this->defineItem($v);
}
return \XLite\Core\Config::getInstance()->CDev->SimpleCMS->show_default_menu ? array_merge(parent::defineItems(), $menu) : ($menu ?: parent::defineItems());
}
示例13: getProfile
/**
* getProfile
*
* @return \XLite\Model\Profile
*/
public function getProfile()
{
if (!isset($this->profile)) {
$profileId = \XLite\Core\Request::getInstance()->profile_id;
if (isset($profileId)) {
$this->profile = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->find($profileId);
} else {
$this->profile = \XLite\Core\Auth::getInstance()->getProfile();
}
}
return $this->profile;
}
示例14: defineItems
/**
* Define menu items
*
* @return array
*/
protected function defineItems()
{
$menu = array();
$menu[] = array('target' => \XLite::TARGET_DEFAULT, 'url' => $this->buildURL(''), 'label' => static::t('Home'));
$menu[] = array('target' => 'cart', 'url' => $this->buildURL('cart'), 'label' => static::t('Shopping bag'));
if (\XLite\Core\Auth::getInstance()->isLogged()) {
$menu[] = array('target' => 'profile', 'url' => $this->buildURL('profile'), 'label' => static::t('My account'));
} else {
$menu[] = array('target' => 'profile', 'url' => $this->buildURL('profile', '', array('mode' => 'register')), 'label' => static::t('Register'));
}
return $menu;
}
示例15: __construct
/**
* Override constructor to add new tab
*
* @param array $params Handler params OPTIONAL
*
* @return void
*/
public function __construct(array $params = array())
{
if ($this->isLogged()) {
$cnd = new \XLite\Core\CommonCell();
$cnd->user = \XLite\Core\Auth::getInstance()->getProfile();
$count = \XLite\Core\Database::getRepo('XLite\\Model\\Order')->searchWithPinCodes($cnd, true);
if ($count > 0) {
$this->tabs['pin_codes'] = array('title' => 'PIN codes', 'template' => 'modules/CDev/PINCodes/account_pin_codes.tpl');
}
}
parent::__construct($params);
}