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


PHP CakeSession类代码示例

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


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

示例1: getUserSession

 private function getUserSession()
 {
     App::uses('CakeSession', 'Model/Datasource');
     $Session = new CakeSession();
     $user = $Session->read('UserAuth');
     return $user;
 }
开发者ID:alextalha,项目名称:sg,代码行数:7,代码来源:AppModel.php

示例2: beforeFind

 public function beforeFind($queryData)
 {
     $res = parent::beforeFind($queryData);
     /*
     if(AuthComponent::user('id') == 1)
     {
       return $queryData;
     }
     */
     App::import('Model', 'CakeSession');
     $session = new CakeSession();
     $userAvailableTags = $session->read('Rights.UserAvailablesTags');
     $userForbiddenTags = $session->read('Rights.UserForbiddenTags');
     $userAvailableAlbums = $session->read('Rights.UserAvailablesAlbums');
     $userForbiddenAlbums = $session->read('Rights.UserForbiddenAlbums');
     if (count($userForbiddenAlbums) != 0) {
         //       $queryData['conditions']['Image.album'] = 'not in ('.implode(',', $userForbiddenAlbums).')';
     }
     /*    App::import('Model', 'ImageTag');
         $imageTag = new ImageTag();
         $subSqlQuery = $imageTag->find('sql', array('fields'=>'imageid','conditions'=>'tagid not in ('.implode(',', $userForbiddenTags).')'));
         */
     if (count($userForbiddenTags) != 0) {
         //       $subSqlQuery = 'SELECT imageid from ImageTags where tagid not in ('.implode(',', $userForbiddenTags).')';
         //       $queryData['conditions']['Image.id'] = 'not in ('.$subSqlQuery.')';
     }
     //     debug($queryData);
     return $queryData;
 }
开发者ID:bjoern-tantau,项目名称:digikamWebUi,代码行数:29,代码来源:Image.php

示例3: __construct

 /**
  * Default Constructor
  *
  * @param array $config options
  * @access public
  */
 public function __construct($config)
 {
     // _toPost keys are case sensitive for google api, changin them will result in bad authentication
     $_toPost['accountType'] = $config['accounttype'];
     $_toPost['Email'] = $config['email'];
     $_toPost['Passwd'] = $config['passwd'];
     $_toPost['service'] = $config['service'];
     $_toPost['source'] = $config['source'];
     $this->HttpSocket = new HttpSocket();
     // Initializing Cake Session
     $session = new CakeSession();
     $session->start();
     // Validating if curl is available
     if (function_exists('curl_init')) {
         $this->_method = 'curl';
     } else {
         $this->_method = 'fopen';
     }
     // Looking for auth key in cookie of google api client login
     $cookie_key = $session->read('GoogleClientLogin' . $_toPost['service'] . '._auth_key');
     if ($cookie_key == null || $cookie_key == "") {
         // Geting auth key via HttpSocket
         $results = $this->HttpSocket->post($this->_login_uri, $_toPost);
         $first_split = split("\n", $results);
         foreach ($first_split as $string) {
             $arr = split("=", $string);
             if ($arr[0] == "Auth") {
                 $this->_auth_key = $arr[1];
             }
         }
         $session->write('GoogleClientLogin' . $_toPost['service'] . '._auth_key', $this->_auth_key);
     } else {
         $this->_auth_key = $cookie_key;
     }
 }
开发者ID:sdoney,项目名称:infinitas,代码行数:41,代码来源:google_api_base.php

示例4: currentUser

 public function currentUser()
 {
     App::uses('CakeSession', 'Model/Datasource');
     $Session = new CakeSession();
     $user = $Session->read('Auth.User');
     return array('id' => $user['User']['username']);
 }
开发者ID:ophilli,项目名称:Inventory,代码行数:7,代码来源:AppModel.php

示例5: _getCurrentUser

 protected function _getCurrentUser()
 {
     App::uses('CakeSession', 'Model/Datasource');
     $Session = new CakeSession();
     $user_id = $Session->read('Auth.User.User.id');
     return $user_id;
 }
开发者ID:ei17ringo,项目名称:wordPotProject,代码行数:7,代码来源:AppModel.php

示例6: testSaveConvertVideoMp4Exception

 /**
  * 動画変換とデータ保存 MP4例外テスト
  *
  * @return void
  * @throws Exception
  */
 public function testSaveConvertVideoMp4Exception()
 {
     // 暫定対応(;'∀') ffmpeg未インストールによる travis-ci error のため、コメントアウト
     //$this->setExpectedException('InternalErrorException');
     // AuthComponent::user('id');対応
     $Session = new CakeSession();
     $Session->write('Auth.User.id', 1);
     $data = array('Video' => array('block_id' => 2));
     $video = array('Video' => array('mp4_id' => 1), Video::VIDEO_FILE_FIELD => array('FilesPlugin' => array('plugin_key' => 'videos')));
     $roomId = 1;
     // テストファイル準備
     $contentsId = $video['Video']['mp4_id'];
     $fileName = 'video1.mp4';
     $this->_readyTestFile($contentsId, $roomId, $fileName);
     // 例外を発生させるためのモック
     $videoMock = $this->getMockForModel('Videos.Video', ['save']);
     $videoMock->expects($this->any())->method('save')->will($this->returnValue(false));
     $videoMock->FileModel = ClassRegistry::init('Files.FileModel');
     try {
         // 動画変換とデータ保存
         $videoMock->saveConvertVideo($data, $video, $roomId);
     } catch (Exception $e) {
         // テストファイル削除
         $this->_deleteTestFile();
         // 暫定対応(;'∀') ffmpeg未インストールによる travis-ci error のため、コメントアウト
         //throw $e;
     }
 }
开发者ID:Onasusweb,项目名称:Videos,代码行数:34,代码来源:VideoBehaviorExceptionTest.php

示例7: getCurrentUser

 public function getCurrentUser()
 {
     // for CakePHP 2.x:
     App::uses('CakeSession', 'Model/Datasource');
     $Session = new CakeSession();
     $user = $Session->read('Auth.User');
     return $user;
 }
开发者ID:yenchuchu,项目名称:MoneyLover,代码行数:8,代码来源:AppModel.php

示例8: beforeSave

 public function beforeSave($options = array())
 {
     // if (isset($this->data[$this->alias]['user_id'])) {
     App::uses('CakeSession', 'Model/Datasource');
     $Session = new CakeSession();
     $this->data[$this->alias]['user_id'] = $Session->read('Auth.User.id');
     //}
     return true;
 }
开发者ID:krzysztofglodzik,项目名称:projekt_kulinarny,代码行数:9,代码来源:Comment.php

示例9: loginUser

 /**
  * ログインユーザーのデータを取得する
  * 
  * @return array
  */
 public static function loginUser($prefix = 'admin')
 {
     $Session = new CakeSession();
     $sessionKey = BcUtil::authSessionKey($prefix);
     $user = $Session->read('Auth.' . $sessionKey);
     if (!$user) {
         if (!empty($_SESSION['Auth'][$sessionKey])) {
             $user = $_SESSION['Auth'][$sessionKey];
         }
     }
     return $user;
 }
开发者ID:baserproject,项目名称:basercms,代码行数:17,代码来源:BcUtil.php

示例10: beforeSave

 public function beforeSave($options = array())
 {
     // a file has been uploaded so grab the filepath
     if (!empty($this->data[$this->alias]['picture'])) {
         $this->data[$this->alias]['picture'] = $this->path;
     }
     if (!isset($this->data[$this->alias]['user_id'])) {
         App::uses('CakeSession', 'Model/Datasource');
         $Session = new CakeSession();
         $this->data[$this->alias]['user_id'] = $Session->read('Auth.User.id');
     }
     return parent::beforeSave($options);
 }
开发者ID:krzysztofglodzik,项目名称:projekt_kulinarny,代码行数:13,代码来源:Recipe.php

示例11: getCurrentUser

 public function getCurrentUser($field = false)
 {
     App::uses('CakeSession', 'Model/Datasource');
     $Session = new CakeSession();
     $user = $Session->read('Auth.User');
     if ($user && is_array($user)) {
         if ($field === false) {
             return $user;
         } else {
             return isset($user[$field]) ? $user[$field] : false;
         }
     } else {
         return false;
     }
 }
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:15,代码来源:AppModel.php

示例12: flash

 public function flash($key = 'flash', $attrs = array())
 {
     $out = false;
     if (CakeSession::check('Message.' . $key)) {
         $flash = CakeSession::read('Message.' . $key);
         $message = $flash['message'];
         unset($flash['message']);
         if (!empty($attrs)) {
             $flash = array_merge($flash, $attrs);
         }
         if ($flash['element'] === 'default') {
             $class = 'success';
             if (!empty($flash['params']['class'])) {
                 $class = $flash['params']['class'];
             }
             $out = '<div id="' . $key . 'Message" class="alert alert-' . $class . '"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $message . '</div>';
         } elseif (!$flash['element']) {
             $out = $message;
         } else {
             $options = array();
             if (isset($flash['params']['plugin'])) {
                 $options['plugin'] = $flash['params']['plugin'];
             }
             $tmpVars = $flash['params'];
             $tmpVars['message'] = $message;
             $out = $this->_View->element($flash['element'], $tmpVars, $options);
         }
         CakeSession::delete('Message.' . $key);
     }
     return $out;
 }
开发者ID:shahariaazam,项目名称:cakephp-quick-start,代码行数:31,代码来源:SessionHelper.php

示例13: validateLoginStatus

 /**
  * Check user is login or not and also setup user and other necessary veriable
  * 
  *  @param null
  *  @return null
  */
 private function validateLoginStatus()
 {
     $useridentity = CakeSession::read('User.identity');
     if ($this->params['controller'] != 'admin_dashbords' && !in_array($this->params['action'], array('login'))) {
         if (empty($useridentity['User'])) {
             if (substr($this->params['controller'], 0, 6) == 'admin_') {
                 $this->redirect('/admin/');
             } else {
                 //$this->redirect('/');
             }
         }
     }
     $hasIdentity = !empty($useridentity['User']) ? true : false;
     $this->set('hasIdentity', $hasIdentity);
     $username = NULL;
     if (!$hasIdentity && ($this->params['controller'] != 'admin_dashbords' && $this->params['action'] != 'login')) {
         if (substr($this->params['controller'], 0, 6) == 'admin_') {
             $this->redirect('/admin/');
         } else {
             //$this->redirect('/');
         }
     } else {
         $username = ucfirst($useridentity['User']['user']);
         $this->set('username', $username);
     }
     if (!empty($useridentity)) {
         $this->useridentity->id = $useridentity['User']['id'];
         $this->useridentity->user = $useridentity['User']['user'];
         $this->useridentity->email = $useridentity['User']['email'];
         $this->useridentity->role_id = $useridentity['User']['role_id'];
     }
 }
开发者ID:ruzdi,项目名称:bestjokes,代码行数:38,代码来源:AppController.php

示例14: setup

 /**
  * Check Auth is user is admin
  */
 public function setup(Model $model, $settings = array())
 {
     parent::setup($model, $settings);
     if (CakeSession::check('Auth')) {
         $this->_isAdmin = CakeSession::read('Auth.User.is_admin') ? true : false;
     }
 }
开发者ID:superstarrajini,项目名称:cakepackages,代码行数:10,代码来源:CakePackagesTaggableBehavior.php

示例15: saveCredit

 /**
  * Saves a new product credit
  *
  * @param int $market_id
  * @param int $presenter_sequence_id The presenter sequence id
  * @param int $credit_type
  * @param decimal $amount
  * @param int $user_id
  * @return boolean
  */
 public function saveCredit($market_id, $presenter_sequence_id, $credit_type, $amount, $user_id)
 {
     $entry_type_id = 2;
     $status_type_id = 2;
     $ref = CakeSession::read('admin_user')->id;
     $entry_user = 'Customer service portal';
     //convert presenter sequence id to primary key id
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter.php';
     $presenter = new Presenter();
     $presenter_id = $presenter->getIdBySequenceId($presenter_sequence_id);
     $sql = "INSERT INTO {$this->_table_name} " . "(market_id, user_id, presenter_id, product_credit_type_id, product_credit_entry_type_id, product_credit_status_type_id, entry_user, created, reference_id, amount) " . "VALUES (:market, :user, :presenter, :type, :entry, :status, :entry_user, NOW(), :ref, :amt)";
     $query = $this->_db->prepare($sql);
     $query->bindParam(':market', $market_id);
     $query->bindParam(':user', $user_id);
     $query->bindParam(':presenter', $presenter_id);
     $query->bindParam(':type', $credit_type);
     $query->bindParam(':entry', $entry_type_id);
     $query->bindParam(':status', $status_type_id);
     $query->bindParam(':ref', $ref);
     $query->bindParam(':entry_user', $entry_user);
     $query->bindParam(':amt', $amount);
     if ($query->execute()) {
         return TRUE;
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:35,代码来源:Product_credits.php


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