/** * Pass-thru function for ACL check instance. Check methods * are used to check whether or not an ARO can access an ACO * * @param string $aro ARO The requesting object identifier. * @param string $aco ACO The controlled object identifier. * @param string $action Action (defaults to *) * @return boolean Success * @access public */ function check($aro, $aco, $action = "*") { $path = $this->__cachePath($aro, $aco, $action); if ($this->Session->check($path)) { return $this->Session->read($path); } else { $check = parent::check($aro, $aco, $action); $this->Session->write($path, $check); return $check; } }
/** * * @deprecated */ public function get($criterio = null) { if (!$this->Session->check('Desafio.docs') and is_null($criterio)) { $this->Session->setFlash('Ganaste la posibilidad de descargar documentos, haz una búsqueda para poder acceder a ellos!'); $this->redirect(array('controller' => 'tags')); } else { if (!is_null($criterio)) { $docs = $this->Tag->findDocumentsByTags(array($criterio)); } else { $docs = $this->Session->read('Desafio.docs'); } } $this->Session->delete('Desafio'); $criterio = $this->Criterio->find('first', array('recursive' => -1)); $pack = $criterio['Criterio']['tamano_pack']; $doc_objs = $this->Documento->find('all', array('conditions' => array('Documento.id_documento' => $docs), 'recursive' => -1)); $premio = array(); if (count($doc_objs) > 0) { if (count($doc_objs) < $pack) { $pack = count($doc_objs); } /* shuffle documents */ shuffle($doc_objs); $tmp = array_rand($doc_objs, $pack); $tmp = is_array($tmp) ? $tmp : array($tmp); /* insersect by keys from documents and some random subset of size $pack of $doc_objs */ /* $premio are $pack random documents from search result */ $premio = array_intersect_key($doc_objs, array_flip($tmp)); } $this->set(compact('premio', 'doc_objs')); }
/** * dispatch to user action: * - upload * - download * - index (for earn points) * requires Session var "Points.dispatch" given by PointsController::process() * @see PointsController::process() */ function _dispatch() { $action = $this->_get_action(); $action_name = $this->Session->read('Action.type'); if (!$this->Session->check('Points.dispatch')) { $this->_cancel_everything('This is not meant to happen'); } if ($this->Session->check('Points.proceed') && !$this->Session->read('Points.proceed')) { $this->_cancel_everything($this->Session->read('Points.status')); } if ($this->getConnectedUser() == $this->anonymous) { $this->Session->setFlash("Thank you, now you can {$action_name} document(s)"); } else { $this->Session->setFlash($this->Session->read('Points.status')); } if ($action == $this->earn) { $this->redirect('/'); } if ($action == $this->upload || $action == $this->download) { $this->Session->write('Document.continue', true); $this->_clean_session(); $this->redirect(array('controller' => 'documents', 'action' => $action_name)); } else { $this->_cancel_everything('Action not recognized'); } }
/** * return logged user Information * @author vovich */ function getLoggedUserInfo() { if ($this->Session->check('loggedUser')) { $userSession = $this->Session->read('loggedUser'); } else { $userSession = null; } return $userSession; }
/** * * wrapper for _validate_challenge */ function validate_challenge() { if (empty($this->data) || !$this->Session->check('Challenge.validate')) { $this->e404(); } $this->Session->delete('Challenge.validate'); $this->Session->delete('Challenge.play'); $this->_validate_challenge($this->data); }
function parse($url) { $params = parent::parse($url); if (empty($params)) { return false; } App::import('Component', 'Session'); $Session = new SessionComponent(); if ($Session->check('Auth.User.slug')) { return $params; } return false; }
function parse($url) { // import the session controller so we can check if they're logged in or not App::import('Component', 'Session'); $Session = new SessionComponent(); // check the login if ($Session->check('Auth.User.email')) { // logged in, parse params and return return parent::parse($url); } else { // not logge in, return false return false; } }
/** * セッションをリクエストパラメータに設定 * * @param CakeRequest $request * @param SessionComponent $session * @param type $sessionKey * @throws RuntimeException */ public static function setSessionToRequestData(CakeRequest $request, SessionComponent $session, $sessionKey = null) { $sessionKey = is_null($sessionKey) ? static::TMP_REQUEST_SESSION_KEY : $sessionKey; if (empty($sessionKey)) { throw new RuntimeException(); } $dataSession = $session->check($sessionKey) ? $session->read($sessionKey) : array(); $dataRequest = $request->data; $multipleFields = static::$multipleFields; for ($i = 0, $cnt = count($multipleFields); $i < $cnt; ++$i) { $tmp = $multipleFields[$i]; $arrTmp = explode('.', $tmp); $alias = $arrTmp[0]; $field = $arrTmp[1]; if (isset($dataSession[$alias][$field]) && isset($dataRequest[$alias][$field])) { unset($dataSession[$alias][$field]); } } $request->data = Hash::merge($dataSession, $dataRequest); }
/** * returns current repository data as array * note: if host is localhost, it just reads from the session var * which means to have an expiration time */ function getCurrentRepository() { $repo = null; if (Configure::read('App.subdomains')) { $url = explode('.', $_SERVER['HTTP_HOST'], 3); if (count($url) === 2 or $url[0] === 'www') { $repo = null; } else { $repo = $url[0]; } } elseif ($this->Session->check('Repository.current')) { $repo = $this->Session->read('Repository.current'); } if (!is_null($repo)) { $data = $this->Repository->find('first', array('conditions' => array('Repository.url' => $repo))); if (!is_null($data) && !empty($data)) { return $data; } } return null; }
/** * testSessionCheck method * * @return void */ public function testSessionCheck() { $Session = new SessionComponent($this->ComponentCollection); $this->assertFalse($Session->check('Test')); $Session->write('Test', 'some value'); $this->assertTrue($Session->check('Test')); $Session->delete('Test'); }
/** * testSessionId method * * @return void */ public function testSessionId() { unset($_SESSION); $Session = new SessionComponent($this->ComponentCollection); $Session->check('test'); $this->assertEquals(session_id(), $Session->id()); }
/** * testSessionCheck method * * @access public * @return void */ function testSessionCheck() { $Session = new SessionComponent(); $this->assertFalse($Session->check('Test')); $Session->write('Test', 'some value'); $this->assertTrue($Session->check('Test')); $Session->delete('Test'); Configure::write('Session.start', false); $Session = new SessionComponent(); $Session->write('Test', 'some value'); $this->assertFalse($Session->check('Test')); Configure::write('Session.start', true); }
/** * Prune items in the Shopping Cart * @param $items * @param bool $saveCart * @param null $productCredits * @return array */ public function pruneItems($items, $saveCart = true, $productCredits = NULL) { $this->Presenter = ClassRegistry::init('Presenter'); $this->userId = $this->session->read("user_id"); $itemCount = count($items); //lets look for any product with max quantities $skus = array(); $limitCloud9 = 0; foreach ($items as $key => $item) { if ($item['sku'] == 'US-91516-14' || $item['sku'] == 'US-91516-15') { $presenter_id = $this->session->read("presenter_id"); //check for the item restrictions on history if ($presenter_id) { $db = $this->getDataSource(); $sql = "SELECT count(*) AS count FROM order_items AS oi\r\n\t\t\t\t\t\t\t\t\tINNER JOIN order_customers AS oc ON oi.order_customer_id = oc.id\r\n\t\t\t\t\t\t\t\t\tINNER JOIN orders as o ON oc.order_id = o.id\r\n\t\t\t\t\t\t\t\t\tINNER JOIN items AS i ON oi.item_id = i.id\r\n\t\t\t\t\t\t\t\t\tINNER JOIN presenters AS p ON p.user_id = oc.user_id\r\n\t\t\t\t\t\t\t\t\tWHERE o.user_id = {$this->userId}\r\n\t\t\t\t\t\t\t\t\tAND o.order_status_id IN (3, 4, 5, 8, 9)\r\n\t\t\t\t\t\t\t\t\tAND (i.sku IN ('US-91516-14', 'US-91516-15'))"; $result = $db->fetchAll($sql); if ($result[0][0]['count'] > 0) { $limitCloud9 = $result[0][0]['count']; } } } } foreach ($items as $key => $item) { $removed = FALSE; if (is_null($item['qty'])) { unset($items[$key]); continue; } if ($item['sku'] == 'US-60011-00' && $itemCount == 1) { unset($items['key']); } //Cloud9: US-42015-01 if ($item['sku'] == 'US-91516-14' || $item['sku'] == 'US-91516-15') { $limitCloud9++; if ($limitCloud9 > 1) { $removed = TRUE; unset($items[$key]); } } if ($removed === FALSE) { $skus[$item['sku']] = $key; } } $dbItems = $this->Item->quickBySkus(array_keys($skus)); foreach ($dbItems as $item) { //lifetime max $orderCount = $this->Item->OrderItem->orderCount($item['id'], $this->userId); $cartQty = $items[$skus[$item['sku']]]['qty']; $maxQty = $item['max_qty']; $availableQty = 999; // test for item max qty in Drupal restrictions $restricted_array = $this->session->check("product_restrictions") ? $this->session->read("product_restrictions") : []; foreach ($restricted_array as $r) { //override $maxQty if it is set. if ($r['sku'] == $item['sku']) { $maxQty = isset($r['max']) ? $r['max'] : $maxQty; } } if (!empty($maxQty) && $cartQty + $orderCount > $maxQty) { $availableQty = $maxQty - $orderCount; } if ($availableQty <= 0) { unset($items[$skus[$item['sku']]]); } else { $items[$skus[$item['sku']]]['qty'] = min($cartQty, $availableQty); } /** * Remove unavailable items */ $this->removeUnavailable($item, $items, $skus); } $promoItems = $this->getSpecialCoupons($this->userId); if (count($promoItems) > 0) { foreach ($promoItems as $addItem) { foreach ($items as $item) { if ($item['coupons'][0] == $addItem['id']) { continue 2; } } $new = array(); $new[0]['sku'] = $addItem['discount_sku']; $new[0]['kudosItem'] = TRUE; $new[0]['qty'] = 1; $new[0]['coupons'][] = $addItem['id']; $items[] = $new[0]; } } /** * Kudos Promo Adjustment * @see PromoAdjustmentBehavior * @see PromotionalComponent * @see KudosMaster */ if ($this->Behaviors->loaded('PromoAdjustment')) { $items = $this->addPromoItem($items, $this, $productCredits); } /** * Promo Items Behavior */ if ($this->Behaviors->loaded('PromoItems')) { $items = $this->addPromoItems($items, $productCredits); } //temporary hack to get this working if (count($items) == 1 && $items[0]['sku'] == 'US-60011-00') { $items = array(); } $cart = $this->consolidateCart($items, $saveCart); return $cart; }