本文整理汇总了PHP中CakeSession::read方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeSession::read方法的具体用法?PHP CakeSession::read怎么用?PHP CakeSession::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeSession
的用法示例。
在下文中一共展示了CakeSession::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: __construct
/**
* Checks to see if there is already a logged in session
*/
public function __construct()
{
if (CakeSession::check('auth') && CakeSession::read('auth') == TRUE) {
$this->status = TRUE;
$this->admin_user = CakeSession::read('admin_user');
}
}
示例3: order
/**
*
*/
public function order()
{
$countries = array("Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Barbuda", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Trty.", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Caicos Islands", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Futuna Islands", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard", "Herzegovina", "Holy See", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Jan Mayen Islands", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea", "Korea (Democratic)", "Kuwait", "Kyrgyzstan", "Lao", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "McDonald Islands", "Mexico", "Micronesia", "Miquelon", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "Nevis", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Principe", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthelemy", "Saint Helena", "Saint Kitts", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre", "Saint Vincent", "Samoa", "San Marino", "Sao Tome", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia", "South Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Grenadines", "Timor-Leste", "Tobago", "Togo", "Tokelau", "Tonga", "Trinidad", "Tunisia", "Turkey", "Turkmenistan", "Turks Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "US Minor Outlying Islands", "Uzbekistan", "Vanuatu", "Vatican City State", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (US)", "Wallis", "Western Sahara", "Yemen", "Zambia", "Zimbabwe");
$captcha = $this->Session->read('captcha_code');
if ($this->request->is('post')) {
if (!empty($this->request->data['Order'])) {
if ($captcha == $this->request->data['Order']['captcha']) {
$order_details = $this->request->data['Order'];
$order_details['order_item_count'] = $this->Cart->getCount();
$order_details['total'] = CakeSession::read('total');
$order_details['user_id'] = $this->Auth->user('id');
$order_details['country'] = $countries[$order_details['country']];
if (!$this->Order->save($order_details)) {
$this->Session->setFlash('Something went wrong, please try again!');
}
$foreign_key = $this->Order->getLastInsertID();
$this->OrderItem->updateAll(array('OrderItem.order_id' => $foreign_key), array('OrderItem.session_id' => CakeSession::id()));
$order = $this->OrderItem->find('all', array('conditions' => array('OrderItem.session_id' => CakeSession::id())));
$this->Session->write('order', $order);
$filename = date('Y-m-d H.i.s');
$this->createPdf($filename);
$email = $order_details['email'];
$this->sendBill($order, $email, $filename);
//ez töröl mindent, de nekem csak a kosarat kell, a user cuccokat nem (ne jelentkeztessen ki)
CakeSession::destroy();
$this->view = 'success';
} else {
$this->Session->setFlash(__('Captcha code does not match'));
$this->redirect(array('action' => 'checkOut'));
}
}
}
}
示例4: add
function add()
{
$marketing_adv = $this->AdvertisingLink->find('list', array('fields' => 'id,description', 'conditions' => array('AdvertisingLink.marketing_channels_id' => (int) Configure::read('Settings.Company.DefaultChannel'), 'AdvertisingLink.history_status' => 1), 'recursive' => -1, 'permissionable' => false));
$this->set('files', array());
$this->set('advertisingLinks', $marketing_adv);
$this->set('affiliates', $this->Affiliate->find('list', array('fields' => 'id,name', 'joins' => array(array('table' => 'users_groups', 'alias' => 'UsersGroup', 'type' => 'LEFT', 'conditions' => array('UsersGroup.user_id = Affiliate.id'))), 'conditions' => array('UsersGroup.group_id' => (int) Configure::read('Settings.Company.AffiliateGroupId'), 'Affiliate.active' => 1))));
if ($this->request->is('post') || $this->request->is('put')) {
$this->request->data['Enquiry']['enq_date'] = sqlFormatDate($this->request->data['Enquiry']['enq_date']);
$this->request->data['Enquiry']['enquiry_time'] = gmdate('Y-m-d H:i:s');
$this->Captcha = $this->Components->load('Captcha');
$this->Enquiry->setCaptcha($this->Captcha->getVerCode());
if (isset($this->request->data['Enquiry']['files'])) {
$dataImage = $this->request->data['Enquiry']['files'];
$this->request->data['Enquiry']['file_list'] = json_encode($dataImage);
} else {
$this->request->data['Enquiry']['file_list'] = null;
}
$this->Enquiry->create();
$this->request->data['Enquiry']['agent_id'] = CakeSession::read("Auth.User.id");
//print_r( $this->request->data );die;
if ($this->Enquiry->save($this->request->data)) {
$this->Session->setFlash(__('Enquiry has been saved'));
return $this->redirect(array('action' => 'index'));
}
}
$this->render('edit');
}
示例5: _getSite
protected function _getSite($siteId = null)
{
$Site = ClassRegistry::init('Sites.Site');
$SiteDomain = $Site->SiteDomain;
$SiteMeta = $Site->SiteMeta;
$siteDomainTable = $SiteDomain->getDataSource()->fullTableName($SiteDomain, true, true);
$siteMetaTable = $Site->SiteMeta->getDataSource()->fullTableName($SiteMeta, true, true);
$options = array('recursive' => false, 'fields' => array('Site.id', 'Site.title', 'Site.tagline', 'Site.theme', 'Site.timezone', 'Site.locale', 'Site.status', 'SiteMeta.robots', 'SiteMeta.keywords', 'SiteMeta.description'), 'joins' => array(array('table' => $siteDomainTable, 'alias' => 'SiteDomain', 'conditions' => array('SiteDomain.site_id = Site.id'))), array('table' => $siteMetaTable, 'alias' => 'SiteMeta', 'conditions' => array('SiteMeta.site_id = Site.id')));
$host = env('HTTP_HOST');
if (empty($siteId)) {
$options['joins'][0]['conditions']['SiteDomain.domain LIKE'] = '%' . $host;
$options['cache'] = array('name' => 'sites_' . $host, 'config' => 'sites');
} else {
$options['conditions'] = array('Site.id' => $siteId);
$options['cache'] = array('name' => 'sites_' . $siteId, 'config' => 'sites');
}
$site = $Site->find('first', $options);
if (empty($site)) {
$site = $Site->find('first', array('recursive' => false, 'fields' => array('id', 'title', 'tagline', 'theme', 'timezone', 'locale', 'status'), 'joins' => array(array('table' => $siteDomainTable, 'alias' => 'SiteDomain', 'conditions' => array('SiteDomain.site_id = Site.id'))), array('table' => $siteMetaTable, 'alias' => 'SiteMeta', 'conditions' => array('SiteMeta.site_id = Site.id')), 'conditions' => array('Site.default' => 1)));
}
if ($siteId === null && CakeSession::check(self::$_sessionKey) && ($active = CakeSession::read(self::$_sessionKey))) {
$found = $SiteDomain->find('count', array('cache' => array('name' => 'sites_count_' . $host, 'config' => 'sites'), 'conditions' => array('SiteDomain.domain' => $host)));
if ($found == 0) {
$site = $active;
}
}
return $site;
}
示例6: 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;
}
示例7: view
/**
* view
*
* @return void
* @throws Exception
*/
public function view()
{
if (!Current::read('Block.id')) {
$this->autoRender = false;
return;
}
$isAccessed = 'block_key_' . Current::read('Block.key');
//AccessCounterFrameSettingデータ取得
$counterFrameSetting = $this->AccessCounterFrameSetting->getAccessCounterFrameSetting(true);
$this->set('accessCounterFrameSetting', $counterFrameSetting['AccessCounterFrameSetting']);
//AccessCounterデータ取得
$accessCounter = $this->AccessCounter->getAccessCounter(true);
// カウントアップ処理
if (!$this->Session->read($isAccessed)) {
try {
$this->AccessCounter->updateCountUp($accessCounter);
$accessCounter['AccessCounter']['count']++;
// アクセス情報を記録
$this->Session->write($isAccessed, CakeSession::read('Config.userAgent'));
} catch (Exception $ex) {
CakeLog::error($ex);
throw $ex;
}
}
$this->set('accessCounter', $accessCounter['AccessCounter']);
}
示例8: _retrive_access_token
/**
* retrives access token
*
* @param CakeRequest $request
* @return mixed Either false on failure, or string the access_token facebook.
*/
private function _retrive_access_token(CakeRequest $request)
{
if ($this->access_token) {
return $this->access_token;
}
$session_name = $this->settings['session'];
if ($user = CakeSession::read($session_name)) {
$this->access_token = $user->access_token;
return $this->access_token;
}
if (!isset($request->query['code'])) {
return false;
}
$code = $request->query['code'];
$access_token = false;
$url = 'https://accounts.google.com/o/oauth2/token';
$query = implode('&', array('code=' . $code, 'client_id=' . $this->settings['client_id'], 'client_secret=' . $this->settings['client_secret'], 'redirect_uri=' . urlencode($this->settings['redirect_uri']), 'grant_type=authorization_code'));
$headers = array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($query));
$context = array('http' => array("method" => "POST", "header" => implode("\r\n", $headers), "content" => $query));
if ($res = @file_get_contents($url, false, stream_context_create($context))) {
$params = json_decode($res);
$access_token = $params->access_token;
}
return $access_token;
}
示例9: afterSave
public function afterSave($created, $options = array())
{
// We need to add Activities to corresponding Feeds
// -> The User who liked
// -> The receiving Object
$Feed = ClassRegistry::init('Social.Feed');
$user_id = CakeSession::read("Auth.User.id");
if ($created) {
$feeds = array();
// We need to get if the Object's feed.
$ObjectFeed = $Feed->find('first', array('conditions' => array('Feed.object_id' => $this->data['Comment']['object_id'], 'Feed.object' => $this->data['Comment']['object'])));
$feeds[] = array('feed_id' => $ObjectFeed['Feed']['id']);
$UserFeed = $Feed->find('first', array('conditions' => array('Feed.object_id' => $this->data['Comment']['user_id'], 'Feed.object' => 'User')));
$feeds[] = array('feed_id' => $UserFeed['Feed']['id']);
// Let's add Activities to all the feeds
$Activity = ClassRegistry::init('Social.Activity');
$Activity->create();
$Activity->saveAll(array('Activity' => array('object_id' => $this->data['Comment']['object_id'], 'object' => $this->data['Comment']['object'], 'subject_id' => $this->data['Comment']['user_id'], 'verb' => 'commented', 'text' => 'a commenté ', 'type' => 'comment', 'pole_id' => $this->data['Comment']['pole_id'], 'data' => json_encode(array('text' => $this->data['Comment']['content']))), 'Feed' => $feeds));
// We need to Subscribe the Author of the comment to the Object's Feed if he isn't already
$Subscription = ClassRegistry::init('Social.Subscription');
$_subscription = $Subscription->find('first', array('conditions' => array('Subscription.feed_id' => $ObjectFeed['Feed']['id'], 'Subscription.user_id' => $this->data['Comment']['user_id'])));
if (!count($_subscription)) {
$Subscription->create();
$Subscription->save(array('Subscription' => array('feed_id' => $ObjectFeed['Feed']['id'], 'user_id' => $this->data['Comment']['user_id'], 'reason' => 'commentor')));
}
}
}
示例10: _getCurrentUser
protected function _getCurrentUser()
{
App::uses('CakeSession', 'Model/Datasource');
$Session = new CakeSession();
$user_id = $Session->read('Auth.User.User.id');
return $user_id;
}
示例11: _fileManager
protected function _fileManager()
{
if (CakeSession::read('Auth.User') && defined('WWW_ROOT')) {
} else {
return null;
}
}
示例12: 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'];
}
}
示例13: getUploadPath
/**
* MISC
**/
private function getUploadPath(Model $model, $path, $extension)
{
$path = trim($path, '/');
$replace = array(':id1000' => ceil($model->id / 1000), ':id100' => ceil($model->id / 100), ':id' => $model->id, ':y' => date('Y'), ':m' => date('m'), ':uid' => CakeSession::read('Auth.User.id'), ':md5' => md5(rand() . uniqid() . time()));
$path = strtr($path, $replace) . '.' . $extension;
return $path;
}
示例14: getUserSession
private function getUserSession()
{
App::uses('CakeSession', 'Model/Datasource');
$Session = new CakeSession();
$user = $Session->read('UserAuth');
return $user;
}
示例15: afterFind
/**
* This happens after a find happens.
*
* @param object $Model Model about to be saved.
* @return boolean true if save should proceed, false otherwise
* @access public
*/
public function afterFind($Model, $data)
{
// skip finds with more than one result.
$skip = $Model->findQueryType == 'neighbors' || $Model->findQueryType == 'count' || empty($data) || isset($data[0][0]['count']) || isset($data[0]) && count($data) > 1 || !isset($data[0][$Model->alias][$Model->primaryKey]);
if ($skip) {
return $data;
}
if (isset($this->__settings[$Model->alias]['session_tracking']) && $this->__settings[$Model->alias]['session_tracking']) {
$this->__session[$Model->alias] = CakeSession::read('Viewable.' . $Model->alias);
}
$user_id = AuthComponent::user('id');
$view['ViewCount'] = array('user_id' => $user_id > 0 ? $user_id : 0, 'model' => Inflector::camelize($Model->plugin) . '.' . $Model->name, 'foreign_key' => $data[0][$Model->alias][$Model->primaryKey], 'referer' => str_replace(InfinitasRouter::url('/'), '/', $Model->__referer));
$location = EventCore::trigger($this, 'GeoLocation.getLocation');
$location = current($location['getLocation']);
foreach ($location as $k => $v) {
$view['ViewCount'][$k] = $v;
}
$view['ViewCount']['year'] = date('Y');
$view['ViewCount']['month'] = date('m');
$view['ViewCount']['day'] = date('j');
$view['ViewCount']['day_of_year'] = date('z');
$view['ViewCount']['week_of_year'] = date('W');
$view['ViewCount']['hour'] = date('G');
// no leading 0
$view['ViewCount']['city'] = $view['ViewCount']['city'] ? $view['ViewCount']['city'] : 'Unknown';
/**
* http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dayofweek
* sunday is 1, php uses 0
*/
$view['ViewCount']['day_of_week'] = date('w') + 1;
$Model->ViewCount->unBindModel(array('belongsTo' => array('GlobalCategory')));
$Model->ViewCount->create();
$Model->ViewCount->save($view);
return $data;
}