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


PHP UserModel::can方法代码示例

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


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

示例1: _onAfterActivateUser

 /**
  * Takes over after a user has been activated.
  *
  * @param UserModel $user
  */
 private function _onAfterActivateUser(UserModel $user)
 {
     // Should we log them in?
     $loggedIn = false;
     if (craft()->config->get('autoLoginAfterAccountActivation')) {
         $loggedIn = craft()->userSession->loginByUserId($user->id, false, true);
     }
     // Can they access the CP?
     if ($user->can('accessCp')) {
         $postCpLoginRedirect = craft()->config->get('postCpLoginRedirect');
         $url = UrlHelper::getCpUrl($postCpLoginRedirect);
     } else {
         $activateAccountSuccessPath = craft()->config->getLocalized('activateAccountSuccessPath');
         $url = UrlHelper::getSiteUrl($activateAccountSuccessPath);
     }
     $this->redirect($url);
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:22,代码来源:UsersController.php

示例2: getPasswordResetUrl

 /**
  * Sets a new verification code on a user, and returns their new Password Reset URL.
  *
  * @param UserModel $user The user that should get the new Password Reset URL
  *
  * @return string The new Password Reset URL.
  */
 public function getPasswordResetUrl(UserModel $user)
 {
     $userRecord = $this->_getUserRecordById($user->id);
     $unhashedVerificationCode = $this->_setVerificationCodeOnUserRecord($userRecord);
     $userRecord->save();
     if ($user->can('accessCp')) {
         $url = UrlHelper::getActionUrl('users/setpassword', array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid), craft()->request->isSecureConnection() ? 'https' : 'http');
     } else {
         // We want to hide the CP trigger if they don't have access to the CP.
         $path = craft()->config->get('actionTrigger') . '/users/setpassword';
         $url = UrlHelper::getSiteUrl($path, array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid), craft()->request->isSecureConnection() ? 'https' : 'http');
     }
     return $url;
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:21,代码来源:UsersService.php

示例3: getPasswordResetUrl

 /**
  * Sets a new verification code on a user, and returns their new Password Reset URL.
  *
  * @param UserModel $user The user that should get the new Password Reset URL
  *
  * @return string The new Password Reset URL.
  */
 public function getPasswordResetUrl(UserModel $user)
 {
     $userRecord = $this->_getUserRecordById($user->id);
     $unhashedVerificationCode = $this->_setVerificationCodeOnUserRecord($userRecord);
     $userRecord->save();
     $path = craft()->config->get('actionTrigger') . '/users/setpassword';
     $params = array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid);
     $scheme = UrlHelper::getProtocolForTokenizedUrl();
     if ($user->can('accessCp')) {
         return UrlHelper::getCpUrl($path, $params, $scheme);
     } else {
         $locale = $user->preferredLocale ?: craft()->i18n->getPrimarySiteLocaleId();
         return UrlHelper::getSiteUrl($path, $params, $scheme, $locale);
     }
 }
开发者ID:vescoyez,项目名称:portfolio_v2,代码行数:22,代码来源:UsersService.php

示例4: getSetPasswordPath

 /**
  * Returns a user’s Set Password path with a given activation code and user’s UID.
  *
  * @param string    $code    The activation code.
  * @param string    $uid     The user’s UID.
  * @param UserModel $user The user.
  * @param bool      $full Whether a full URL should be returned. Defaults to `false`.
  *
  * @return string The Set Password path.
  *
  * @internal This is a little awkward in that the method is called getActivateAccount**Path**, but it's also capable
  * of returning a full **URL**. And it requires you pass in both a user’s UID *and* the UserModel - presumably we
  * could get away with just the UserModel and get the UID from that.
  *
  * @todo Create a new getSetPasswordUrl() method (probably elsewhere, such as UrlHelper) which handles
  * everything that setting $full to `true` currently does here. The function should not accetp a UID since that's
  * already covered by the UserModel. Let this function continue working as a wrapper for getSetPasswordUrl() for the
  * time being, with deprecation logs.
  */
 public function getSetPasswordPath($code, $uid, $user, $full = false)
 {
     if ($user->can('accessCp')) {
         $url = $this->getCpSetPasswordPath();
         if ($full) {
             if (craft()->request->isSecureConnection()) {
                 $url = UrlHelper::getCpUrl($url, array('code' => $code, 'id' => $uid), 'https');
             } else {
                 $url = UrlHelper::getCpUrl($url, array('code' => $code, 'id' => $uid));
             }
         }
     } else {
         $url = $this->getLocalized('setPasswordPath');
         if ($full) {
             if (craft()->request->isSecureConnection()) {
                 $url = UrlHelper::getUrl($url, array('code' => $code, 'id' => $uid), 'https');
             } else {
                 $url = UrlHelper::getUrl($url, array('code' => $code, 'id' => $uid));
             }
         }
     }
     return $url;
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:42,代码来源:ConfigService.php

示例5: getPasswordResetUrl

 /**
  * Sets a new verification code on a user, and returns their new Password Reset URL.
  *
  * @param UserModel $user The user that should get the new Password Reset URL
  *
  * @return string The new Password Reset URL.
  */
 public function getPasswordResetUrl(UserModel $user)
 {
     $userRecord = $this->_getUserRecordById($user->id);
     $unhashedVerificationCode = $this->_setVerificationCodeOnUserRecord($userRecord);
     $userRecord->save();
     $path = craft()->config->get('actionTrigger') . '/users/setpassword';
     $params = array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid);
     $scheme = craft()->request->isSecureConnection() ? 'https' : 'http';
     if ($user->can('accessCp')) {
         return UrlHelper::getCpUrl($path, $params, $scheme);
     } else {
         return UrlHelper::getSiteUrl($path, $params, $scheme);
     }
 }
开发者ID:encryptdesigns,项目名称:MarkyMarksGlooFactory,代码行数:21,代码来源:UsersService.php

示例6: _redirectUserAfterAccountActivation

 /**
  * Redirect the browser after a user’s account has been activated.
  *
  * @param UserModel $user The user that was just activated
  *
  * @return void
  */
 private function _redirectUserAfterAccountActivation(UserModel $user)
 {
     // Can they access the CP?
     if ($user->can('accessCp')) {
         $postCpLoginRedirect = craft()->config->get('postCpLoginRedirect');
         $url = UrlHelper::getCpUrl($postCpLoginRedirect);
     } else {
         $activateAccountSuccessPath = craft()->config->getLocalized('activateAccountSuccessPath');
         $url = UrlHelper::getSiteUrl($activateAccountSuccessPath);
     }
     $this->redirect($url);
 }
开发者ID:floodhelpers,项目名称:floodhelpers,代码行数:19,代码来源:UsersController.php

示例7: saveBackup

 /**
  * @codeCoverageIgnore
  *
  * @param array     $settings
  * @param string    $backup
  * @param UserModel $currentUser
  *
  * @return string Backup filename
  */
 protected function saveBackup($settings, $backup, $currentUser)
 {
     if ($currentUser->can('backup') && $settings['backup'] && IOHelper::fileExists($backup)) {
         $destZip = craft()->path->getTempPath() . IOHelper::getFileName($backup, false) . '.zip';
         if (IOHelper::fileExists($destZip)) {
             IOHelper::deleteFile($destZip, true);
         }
         IOHelper::createFile($destZip);
         if (Zip::add($destZip, $backup, craft()->path->getDbBackupPath())) {
             $backup = $destZip;
         }
     }
     return $backup;
 }
开发者ID:transomdesign,项目名称:transom-craft-starter,代码行数:23,代码来源:ImportService.php


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