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


PHP AuthComponent::user方法代码示例

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


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

示例1: beforeFilter

 /**
  * Configure AuthComponent
  *
  * @access public
  */
 function beforeFilter()
 {
     $this->Auth->authorize = 'actions';
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->logoutRedirect = array('controller' => 'people', 'action' => 'index');
     $this->Auth->loginRedirect = array('controller' => 'people', 'action' => 'index');
     //Set security temporary lower to reload page with javascript
     Configure::write('Security.level', 'medium');
     if ($this->Auth->user()) {
         $this->set('authUser', $this->Auth->user());
     }
     Configure::write('Security.level', 'high');
 }
开发者ID:jeroeningen,项目名称:stamboom_v2,代码行数:18,代码来源:app_controller.php

示例2: movePos

 /**
  * 位置情報を変更します。
  */
 public function movePos()
 {
     // 対象のIDが上か、下か、どこに移動するのかわたされてくるので、それを元に情報を変更する。
     $this->Sidemenu->movePos(AuthComponent::user('id'), $this->request->query['target'], $this->request->query['type']);
     // リダイレクト
     $this->redirect('index#' . $this->request->query['target']);
 }
开发者ID:buiquangquyet,项目名称:ipost,代码行数:10,代码来源:SidemenuController.php

示例3: __prepare

 /**
  * Return readable fields
  *
  * @param Model $model Model using this behavior
  * @return void
  */
 private function __prepare(Model $model)
 {
     $this->UserAttribute = ClassRegistry::init('UserAttributes.UserAttribute');
     $this->UserAttributesRole = ClassRegistry::init('UserRoles.UserAttributesRole');
     if (!isset($this->__readableFields)) {
         $results = $this->UserAttributesRole->find('list', array('recursive' => -1, 'fields' => array('user_attribute_key', 'user_attribute_key'), 'conditions' => array('role_key' => AuthComponent::user('role_key'), 'other_readable' => true)));
         $this->__readableFields = array('id');
         foreach ($results as $key => $field) {
             //Fieldのチェック
             if ($model->hasField($field)) {
                 $this->__readableFields[$key] = $model->escapeField($field);
             }
             if ($model->UsersLanguage->hasField($field)) {
                 $this->__readableFields[$key] = $model->UsersLanguage->escapeField($field);
             }
             //Field(is_xxxx_public)のチェック
             $fieldKey = sprintf(UserAttribute::PUBLIC_FIELD_FORMAT, $field);
             if ($model->hasField($fieldKey)) {
                 $this->__readableFields[$fieldKey] = $model->escapeField($fieldKey);
             }
             //Field(xxxx_file_id)のチェック
             $fieldKey = sprintf(UserAttribute::FILE_FIELD_FORMAT, $field);
             if ($model->hasField($fieldKey)) {
                 $this->__readableFields[$fieldKey] = $model->escapeField($fieldKey);
             }
         }
     }
 }
开发者ID:Onasusweb,项目名称:Users-1,代码行数:34,代码来源:UserSearchBehavior.php

示例4: setUserContext

 /**
  * Set the user context for the Raven client
  */
 private static function setUserContext()
 {
     // Clear the user context
     self::$_client->context->user = null;
     // Check if the `AuthComponent` is in use for current request
     if (class_exists('AuthComponent')) {
         // Instantiate the user model to get valid field names
         $modelName = Configure::read('Sentry.user.model');
         $user = ClassRegistry::init(empty($modelName) ? 'User' : $modelName);
         // Check if the user is authenticated
         $id = AuthComponent::user($user->primaryKey);
         if ($id) {
             // Check custom username field (defaults to `displayField` on `User` model)
             $usernameField = Configure::read('Sentry.user.fieldMapping.username');
             if (empty($usernameField)) {
                 $usernameField = $user->displayField;
             }
             $extraUserData = array('username' => AuthComponent::user($usernameField));
             // Get user emails
             $emailField = Configure::read('Sentry.user.fieldMapping.email');
             $email = !empty($emailField) ? AuthComponent::user($emailField) : null;
             // Set the user context
             self::$_client->set_user_data($id, $email, $extraUserData);
         }
     }
 }
开发者ID:bond-os,项目名称:cakephp-sentry,代码行数:29,代码来源:SentryErrorHandler.php

示例5: beforeSave

 /**
  * Fill the created_by and updated_by fields
  *
  * Note: Since shells do not have Sessions, created_by/updated_by fields
  * will not be populated. If a shell needs to populate these fields, you
  * can simulate a logged in user by setting `Trackable.Auth` config:
  *
  *   Configure::write('Trackable.User', array('id' => 1));
  *
  * Note that value stored in this variable overrides session data.
  */
 public function beforeSave(Model $model, $options = array())
 {
     if (!$this->_hasTrackableFields($model)) {
         return true;
     }
     $config = $this->settings[$model->alias];
     $User = ClassRegistry::init($config['userModel']);
     $userAlias = $User->alias;
     $userPk = $User->primaryKey;
     $user = Configure::read('Trackable.Auth.User');
     if (!$user && CakeSession::started()) {
         $user = AuthComponent::user();
     }
     if ($user && array_key_exists($userPk, $user)) {
         $userId = $user[$userPk];
     }
     if (empty($user) || empty($userId)) {
         return true;
     }
     $alias = $model->alias;
     $createdByField = $config['fields']['created_by'];
     $updatedByField = $config['fields']['updated_by'];
     if (empty($model->data[$alias][$createdByField])) {
         if (!$model->exists()) {
             $model->data[$alias][$createdByField] = $user[$userPk];
         }
     }
     $model->data[$alias][$updatedByField] = $userId;
     if (!empty($model->whitelist)) {
         $model->whitelist[] = $createdByField;
         $model->whitelist[] = $updatedByField;
     }
     return true;
 }
开发者ID:saydulk,项目名称:croogo,代码行数:45,代码来源:TrackableBehavior.php

示例6: isAdminUser

 public static function isAdminUser($user_id = null)
 {
     if (!$user_id) {
         $user_id = AuthComponent::user('id');
     }
     return $user_id == Configure::read('AdminUserId');
 }
开发者ID:Dowingows,项目名称:cartorio_net,代码行数:7,代码来源:User.php

示例7: beforeRender

 function beforeRender()
 {
     parent::beforeRender();
     $this->set('parent_categories', ClassRegistry::init('Category')->getParentCategories());
     // Admin permissions
     if (!empty($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin') {
         $this->loadModel('User');
         $this->set('permitted_controllers', $this->User->getWhitelist(AuthComponent::user('role')));
     }
     $this->set('overriden_response', $this->Session->read('response_replaced'));
     // Get number of modified services for currently logged in Facilitator
     if ($this->Auth->user('role') == 'f') {
         $facilitatorId = $this->Auth->user('id');
         // Get updated records
         $facilitatorChampions = $this->User->find('all', array('conditions' => array('facilitator_id' => $facilitatorId)));
         $this->loadModel('ServiceEdit');
         $modifiedServicesForFacilitator = 0;
         foreach ($facilitatorChampions as $key => $value) {
             $modifiedServicesForFacilitator += $this->ServiceEdit->find('count', array('conditions' => array('user_id' => $value['User']['id'], 'approved' => 0)));
         }
         $this->set(compact('modifiedServicesForFacilitator'));
     }
     // Disable login
     //$this->Auth->logout();
     //$this->Session->setFlash( '<strong>Login and registration is currently disabled while we undergo maintenance.</strong> Thanks for your patience.' );
 }
开发者ID:priyankasingh,项目名称:Genie,代码行数:26,代码来源:AppController.php

示例8: changePassword

 public function changePassword($previousPass, $newPass)
 {
     /*
      * récupère l'ancien mot de passe et le nouveau
      * va dans la base de données et change le mdp à l'email concerné
      */
     if (strcmp($previousPass, $newPass) != 0) {
         $change['Player']['email'] = AuthComponent::user('email');
         $previousPass = Security::hash($previousPass);
         $searchOldPass = "Select password From players Where email = '" . $change['Player']['email'] . "' and password = '" . $previousPass . "'";
         if ($this->query($searchOldPass)) {
             $newPass = Security::hash($newPass);
             $updatePass = "Update players Set password = '" . $newPass . "' Where email = '" . $change['Player']['email'] . "'";
             if ($this->query($updatePass)) {
                 return true;
             }
             return true;
         } else {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:afluong,项目名称:webarena,代码行数:25,代码来源:Player.php

示例9: beforeFilter

 public function beforeFilter()
 {
     if (!file_exists(APP . $this->dbConfig) || file_exists(APP . $this->install)) {
         return $this->redirect(array('controller' => '/', 'action' => 'installer'));
     }
     $config = ClassRegistry::init('ConfigItem');
     $attendance_view = $config->getValue('attendance_view');
     $name_display_format = $config->getValue('name_display_format');
     $versionFile = WWW_ROOT . 'version';
     if (file_exists($versionFile)) {
         $f = fopen($versionFile, 'r');
         $version = fgets($f);
         fclose($f);
     }
     $this->set('version', $version);
     $this->set('attendance_view', $attendance_view);
     $this->Session->write('name_display_format', $name_display_format);
     // full name
     $nameArray = array();
     $nameArray['SecurityUser'] = array();
     $nameArray['SecurityUser']['first_name'] = AuthComponent::user('first_name');
     $nameArray['SecurityUser']['middle_name'] = AuthComponent::user('middle_name');
     $nameArray['SecurityUser']['last_name'] = AuthComponent::user('last_name');
     $this->set('userFullName', $this->Message->getFullName($nameArray));
     $this->set('_userId', AuthComponent::user('id'));
     if ($this->Session->check('Security.accessViewType')) {
         $accessViewType = $this->Session->read('Security.accessViewType');
         $accessViewTypeName = $this->Session->read('Security.accessViewTypeName');
         $this->set('accessViewTypeName', $accessViewTypeName);
     }
     $this->set('_productName', $this->_productName);
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:32,代码来源:AppController.php

示例10: checkCurrentPassword

 public function checkCurrentPassword($current_password)
 {
     $this->id = AuthComponent::user('id');
     $saved_password = $this->field('password');
     $hasher = new BlowfishPasswordHasher();
     return $hasher->check($current_password, $saved_password);
 }
开发者ID:PaulArijit,项目名称:euro-psf,代码行数:7,代码来源:User.php

示例11: beforeSave

 public function beforeSave($options = array())
 {
     //parent::beforeSave($options);
     //print_r($this->data);
     $loggedInUser = AuthComponent::user();
     $found = false;
     $userId = $loggedInUser['user_id'];
     $this->data['Post']['post_by'] = $userId;
     $this->data['Post']['post_date'] = (new DateTime())->format('Y-m-d');
     //format('Y-m-d H:i:s')
     if (!empty($this->data['Topic']['topic_subject'])) {
         $str = $this->data['Topic']['topic_subject'];
         $num = $this->data['Post']['post_cat'];
         $subject = new Topic();
         $found = $subject->find('first', array('conditions' => array('Topic.topic_subject LIKE' => $str, 'Topic.topic_cat =' => $num)));
         if (!$found) {
             $subject->create();
             //create topic
             $subject->save(array('topic_subject' => $this->data['Topic']['topic_subject'], 'topic_date' => (new DateTime())->format('Y-m-d'), 'topic_cat' => $this->data['Post']['post_cat'], 'topic_by' => $userId));
             //see also save associated model method cakephp
             $this->data['Post']['post_topic'] = $this->Topic->getLastInsertId();
             return true;
         }
         $this->data['Post']['post_topic'] = $found['Topic']['topic_id'];
         return true;
     }
     //nothing
     return true;
 }
开发者ID:s3116979,项目名称:BulletinBoard,代码行数:29,代码来源:Post.php

示例12: beforeSave

 public function beforeSave($options = array())
 {
     // hash the password
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     // initially generate the url // generate default url if user_level_id is 10 or 20 in data
     if (isset($this->data[$this->alias]['email'])) {
         $this->data[$this->alias]['url'] = md5($this->data[$this->alias]['email']);
     } else {
         if (isset($this->data[$this->alias]['user_level_id']) && ($this->data[$this->alias]['user_level_id'] == 10 || $this->data[$this->alias]['user_level_id'] == 20)) {
             $this->data[$this->alias]['url'] = md5(AuthComponent::user('email'));
         }
     }
     //check if user has pre-url, prepend pre-url to url
     if (isset($this->data[$this->alias]['pre_url'])) {
         $this->data[$this->alias]['url'] = $this->data[$this->alias]['pre_url'] . "" . $this->data[$this->alias]['url'];
     }
     // check/set referral for user
     App::uses('CakeSession', 'Model/Datasource');
     $referral_id = CakeSession::read('referral');
     if (!empty($referral_id)) {
         $this->data[$this->alias]['referral_id'] = $referral_id;
         CakeSession::delete('referral');
     }
     return true;
 }
开发者ID:desnudopenguino,项目名称:fitin,代码行数:28,代码来源:User.php

示例13: display

 /**
  * Diese Funktion wird aufgerufen, wenn ein Zugriff auf / erfolgt.
  * Um Fehlermeldungen zu vermeiden, erfolgt eine Umleitung auf /plan, wenn der Benutzer eingeloggt ist, andernfalls wird auf /login umgeleitet.
  *
  * @param mixed What page to display
  * @return void
  * @throws NotFoundException When the view file could not be found
  *	or MissingViewException in debug mode.
  */
 public function display()
 {
     if (!AuthComponent::user('id')) {
         return $this->redirect(array('controller' => 'login', 'action' => 'index'));
     } else {
         return $this->redirect(array('controller' => 'plan', 'action' => 'index'));
     }
     $path = func_get_args();
     $count = count($path);
     if (!$count) {
         return $this->redirect('/');
     }
     $page = $subpage = $title_for_layout = null;
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $title_for_layout = Inflector::humanize($path[$count - 1]);
     }
     $this->set(compact('page', 'subpage', 'title_for_layout'));
     try {
         $this->render(implode('/', $path));
     } catch (MissingViewException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
 }
开发者ID:jgraeger,项目名称:cafeplaner,代码行数:41,代码来源:PagesController.php

示例14: me

 public function me()
 {
     $this->autoRender = false;
     $user = $this->User->read(null, AuthComponent::user('id'));
     $this->set(compact('user'));
     $this->render('Users/view');
 }
开发者ID:besimhu,项目名称:legacy,代码行数:7,代码来源:UsersController.php

示例15: add

 /**
  * This function adds songs into your favorites playlists.
  * All the information is passed through a POST request. To add multiple songs at the same time you can use a list
  * of song IDs separated by dashes : $this->request->data['Song']['id'] = '1-2-3-4-5'
  */
 public function add()
 {
     if ($this->request->is('post')) {
         // Verify that Playlist.id is correct
         if (empty($this->request->data['Playlist']['id']) && empty($this->request->data['Playlist']['title'])) {
             $this->Session->setFlash(__('You must specify a valid playlist'), 'flash_error');
             return $this->redirect($this->referer());
         }
         $playlist_length = 0;
         // Verify that Playlist.id exists
         if (isset($this->request->data['Playlist']['id']) && !empty($this->request->data['Playlist']['id'])) {
             $playlist = $this->PlaylistMembership->Playlist->exists($this->request->data['Playlist']['id']);
             if (empty($playlist)) {
                 $this->Session->setFlash(__('You must specify a valid playlist'), 'flash_error');
                 return $this->redirect($this->referer());
             }
             // Get playlist length to add the song at the end of the playlist
             $playlist_length = $this->PlaylistMembership->find('count', array('conditions' => array('PlaylistMembership.playlist_id' => $this->request->data['Playlist']['id'])));
             // Unset Playlist.title if Playlist.id is set to avoid erase Playlist.title
             unset($this->request->data['Playlist']['title']);
         }
         $data = array('Playlist' => $this->request->data['Playlist']);
         //Simple song id
         if (isset($this->request->data["song"])) {
             $data['PlaylistMembership'][] = array('song_id' => $this->request->data['song'], 'sort' => $playlist_length + 1);
         } else {
             if (isset($this->request->data['band'])) {
                 // It's a band!
                 $conditions = array('Song.band' => $this->request->data['band']);
                 $order = 'band';
                 if (isset($this->request->data['album'])) {
                     // It's an album!
                     $conditions['Song.album'] = $this->request->data['album'];
                     $order = 'disc';
                 }
                 $songs = $this->PlaylistMembership->Song->find('all', array('fields' => array('Song.id', 'Song.title', 'Song.album', 'Song.band', 'Song.track_number', 'Song.disc'), 'conditions' => $conditions));
                 $this->SortComponent = $this->Components->load('Sort');
                 if ($order == 'band') {
                     $songs = $this->SortComponent->sortByBand($songs);
                 } elseif ($order == 'disc') {
                     $songs = $this->SortComponent->sortByDisc($songs);
                 }
                 foreach ($songs as $song) {
                     $data['PlaylistMembership'][] = array('song_id' => $song['Song']['id'], 'sort' => ++$playlist_length);
                 }
             }
         }
         // Save data
         if ($this->PlaylistMembership->Playlist->saveAll($data, array('deep' => true))) {
             $this->Session->setFlash(__('Song successfully added to playlist'), 'flash_success');
         } else {
             $this->Session->setFlash(__('Unable to add the song'), 'flash_error');
         }
         $this->PlaylistMembership->Playlist->recursive = 0;
         $playlists = $this->PlaylistMembership->Playlist->find('list', array('fields' => array('Playlist.id', 'Playlist.title'), 'conditions' => array('user_id' => AuthComponent::user('id'))));
         $this->set('playlists', json_encode($playlists, true));
     } else {
         throw new MethodNotAllowedException();
     }
 }
开发者ID:aptitune,项目名称:app,代码行数:65,代码来源:PlaylistMembershipsController.php


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