本文整理汇总了PHP中CakeSession::check方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeSession::check方法的具体用法?PHP CakeSession::check怎么用?PHP CakeSession::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeSession
的用法示例。
在下文中一共展示了CakeSession::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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">×</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;
}
示例2: _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;
}
示例3: 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;
}
}
示例4: __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');
}
}
示例5: flash
public function flash($key = 'flash', $attrs = array())
{
$out = false;
if (CakeSession::check('Message.' . $key)) {
$flash = CakeSession::read('Message.' . $key);
if (is_array($flash)) {
foreach ($flash as $fkey => $msg) {
$message = $msg['message'];
// unset($flash[$fkey]['message']);
if (!empty($attrs)) {
$msg = array_merge($msg, $attrs);
}
if ($msg['element'] === 'default') {
$class = 'message';
if (!empty($msg['params']['class'])) {
$class = $msg['params']['class'];
}
$out .= '<div id="' . $key . 'Message" class="' . $class . '">' . $message . '</div>';
} elseif (!$msg['element']) {
$out .= $message;
} else {
$options = array();
if (isset($msg['params']['plugin'])) {
$options['plugin'] = $msg['params']['plugin'];
}
$tmpVars = $msg['params'];
$tmpVars['message'] = $message;
$out .= $this->_View->element($msg['element'], $tmpVars, $options);
}
CakeSession::delete('Message.' . $key . '.' . $fkey);
}
} else {
$message = $flash['message'];
unset($flash['message']);
if (!empty($attrs)) {
$flash = array_merge($flash, $attrs);
}
if ($flash['element'] === 'default') {
$class = 'message';
if (!empty($flash['params']['class'])) {
$class = $flash['params']['class'];
}
$out = '<div id="' . $key . 'Message" class="' . $class . '">' . $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;
}
示例6: initialize
public function initialize(Controller $controller)
{
if (CakeSession::check('Config.language')) {
Configure::write('Config.language', CakeSession::read('Config.language'));
}
if (CakeSession::check('Config.language')) {
Configure::write('Config.language', CakeSession::read('Config.language'));
}
}
示例7: beforeRender
public function beforeRender()
{
parent::beforeRender();
$this->set("title_for_layout", "サマリー");
if (CakeSession::check('errMsg')) {
$this->set("errMsg", CakeSession::read('errMsg'));
CakeSession::delete('errMsg');
}
}
示例8: __construct
public function __construct($id = false, $table = null, $ds = null)
{
parent::__construct($id, $table, $ds);
if (!CakeSession::check($this->_strategy)) {
$config = ClassRegistry::init('Opauth.OpauthSetting')->findByName($this->_strategy);
if (!empty($config['OpauthSetting'])) {
CakeSession::write($this->_strategy, $config['OpauthSetting']);
}
}
$this->_config = CakeSession::read($this->_strategy);
}
示例9: index
public function index()
{
$loginId = $this->_checkLogin();
if (!empty($loginId)) {
$this->redirect('../summary/');
}
if (CakeSession::check('errMsg')) {
$this->set("errMsg", CakeSession::read('errMsg'));
CakeSession::delete('errMsg');
}
}
示例10: currentBasketId
public function currentBasketId()
{
if (!CakeSession::check('WebshopShoppingBasket.current_basket_id')) {
$basketId = $this->createBasket();
if (!$basketId) {
return false;
}
CakeSession::write('WebshopShoppingBasket.current_basket_id', $basketId);
}
return CakeSession::read('WebshopShoppingBasket.current_basket_id');
}
示例11: render
/**
* Used to render the message set in FlashComponent::set()
*
* In your view: $this->Flash->render('somekey');
* Will default to flash if no param is passed
*
* You can pass additional information into the flash message generation. This allows you
* to consolidate all the parameters for a given type of flash message into the view.
*
* ```
* echo $this->Flash->render('flash', array('params' => array('name' => $user['User']['name'])));
* ```
*
* This would pass the current user's name into the flash message, so you could create personalized
* messages without the controller needing access to that data.
*
* Lastly you can choose the element that is used for rendering the flash message. Using
* custom elements allows you to fully customize how flash messages are generated.
*
* ```
* echo $this->Flash->render('flash', array('element' => 'my_custom_element'));
* ```
*
* If you want to use an element from a plugin for rendering your flash message
* you can use the dot notation for the plugin's element name:
*
* ```
* echo $this->Flash->render('flash', array(
* 'element' => 'MyPlugin.my_custom_element',
* ));
* ```
*
* @param string $key The [Message.]key you are rendering in the view.
* @param array $options Additional options to use for the creation of this flash message.
* Supports the 'params', and 'element' keys that are used in the helper.
* @return string|null Rendered flash message or null if flash key does not exist
* in session.
* @throws UnexpectedValueException If value for flash settings key is not an array.
*/
public function render($key = 'flash', $options = array())
{
if (!CakeSession::check("Message.{$key}")) {
return;
}
$flash = CakeSession::read("Message.{$key}");
if (!is_array($flash)) {
throw new UnexpectedValueException(sprintf('Value for flash setting key "%s" must be an array.', $key));
}
$flash = $options + $flash;
CakeSession::delete("Message.{$key}");
return $this->_View->element($flash['element'], $flash);
}
示例12: getSelectedRate
public function getSelectedRate()
{
if (CakeSession::check('DrexCartOrder')) {
$order = CakeSession::read('DrexCartOrder');
if (isset($order['shipping_option'])) {
foreach ($this->rates as $rate) {
if ($rate['code'] == $order['shipping_option']) {
return $rate;
}
}
}
}
return false;
}
示例13: captcha
public function captcha(Model $Model, $check)
{
$value = array_values($check);
$value = $value[0];
$field = key($check);
if (CakeSession::check('captcha')) {
$builder = new CaptchaBuilder();
$builder->setPhrase(CakeSession::read('captcha'));
if ($builder->testPhrase($value)) {
return true;
}
}
return false;
}
示例14: processAction
public function processAction(Model $model, $controller)
{
if (CakeSession::check('Auth.User') == false) {
$controller->redirect($controller->Auth->loginAction);
}
$model->controller = $controller;
$controller->autoRender = false;
$params = $controller->request->params;
$action = 'index';
$plugin = $params['plugin'];
if (!empty($params['pass'])) {
$action = array_shift($params['pass']);
}
$model->action = $action;
$controller->set('action', $action);
$module = $controller->action;
$model->beforeAction();
$result = call_user_func_array(array($model, $action), $params['pass']);
$model->afterAction();
if (!is_null($plugin)) {
//$name = $plugin . '/' . $name;
}
if ($model->render === 'auto') {
if ($action == 'add' || $action == 'edit') {
$controller->render('../Elements/templates/edit');
} else {
if ($action == 'view') {
$controller->render('../Elements/templates/view');
}
}
} else {
if ($model->render === true) {
$controller->render($module . '/' . $action);
} else {
if ($model->render === 'override') {
$controller->render($model->render_override);
} else {
if ($model->render !== false) {
$controller->render($module . '/' . $model->render);
}
}
}
}
return $result;
}
示例15: 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);
}
$tmpVars = $flash['params'];
$tmpVars['message'] = $message;
$tmpOptions = array('plugin' => 'TwitterBootstrap');
$out = $this->_View->element('alert', $tmpVars, $tmpOptions);
CakeSession::delete('Message.' . $key);
}
return $out;
}