/**
  * 
  *  @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'));
 }
Exemplo n.º 2
0
 /**
  * トークンチェック
  * @param CakeRequest $request
  * @param SessionComponent $session
  * @param string $dataAlias
  * @param string $tokenField
  * @return boolean
  */
 public static function checkToken(CakeRequest $request, SessionComponent $session, $dataAlias, $tokenField = self::TOKEN_FIELD)
 {
     $sessionKey = self::SESSION_KEY_BASE . $dataAlias;
     $requestToken = $request->data[$dataAlias][$tokenField];
     $sessionToken = $session->read($sessionKey);
     $session->delete($sessionKey);
     return $requestToken === $sessionToken ? true : false;
 }
Exemplo n.º 3
0
 /**
  * testGetRoleId
  */
 public function testGetRoleId()
 {
     $session = new SessionComponent($this->ComponentCollection);
     $session->write('Auth.User', array('id' => 1, 'username' => 'admin', 'role_id' => 1));
     $this->assertEqual($this->Layout->getRoleId(), 1);
     $session->delete('Auth');
     $this->assertEqual($this->Layout->getRoleId(), 3);
 }
Exemplo n.º 4
0
 /**
  * Clear Shoppingcart
  * @param null $userId
  * @return bool
  */
 public function clear($userId = null)
 {
     if (empty($userId)) {
         //check current cart
         $this->session->delete("shoppingcartcoupon");
         $this->session->write("shoppingcart", []);
         return true;
     }
 }
Exemplo n.º 5
0
 function setRepositorySession($repo)
 {
     if (!empty($repo)) {
         $this->Session->delete('Repository');
         $this->Session->write('Repository.current', $repo['Repository']['url']);
         $this->Session->write('Repository.name', $repo['Repository']['name']);
     }
     if ($this->isExpert()) {
         $this->Session->write('User.esExperto', true);
     } else {
         $this->Session->write('User.esExperto', false);
     }
 }
Exemplo n.º 6
0
 /**
  * Create session loggedUser
  * and Update User profile
  * @author vovich
  * @param int  $userID
  * @param bool $rememberMe
  */
 function loggining($userID = null, $rememberMe = false)
 {
     if (!$this->model) {
         $this->__initModel();
     }
     $loggedSessionFields = array('User.id', 'firstname', 'middlename', 'lastname', 'lgn', 'email', 'last_logged', 'pre_last_logged', 'Timezone.value', 'avatar');
     if ($userID) {
         $conditions = array('User.id' => $userID);
         $userInfo = $this->model->find('first', array('conditions' => $conditions, 'fields' => $loggedSessionFields));
         if (empty($userInfo)) {
             $this->log('error occured while Loggining: empty userInfo');
             return false;
         } else {
             $promocodes = $this->model->query("SELECT count(id) as promocodes FROM promocodes WHERE assign_user_id=" . $userID);
             if (!isset($promocodes[0][0]['promocodes']) || !$promocodes[0][0]['promocodes']) {
                 $promocodes[0][0]['promocodes'] = 0;
             }
             $userInfo['User']['promocodes'] = $promocodes[0][0]['promocodes'];
             $userInfo['User']['timezone'] = $userInfo['Timezone']['value'];
             $this->Session->delete('loggedUser');
             $this->Session->write('loggedUser', $userInfo['User']);
             //Create statuses
             $userStatuses = $this->model->query("SELECT user_id, status_id FROM users_statuses WHERE user_id=" . $userID);
             $this->Session->write('loggedUserStatuses', $userStatuses);
             /*Update User profile*/
             $userInfo['User']['pre_last_logged'] = $userInfo['User']['last_logged'];
             $userInfo['User']['last_logged'] = date('Y-m-d H:i:s');
             $userInfo['User']['last_logged_ip'] = $_SERVER['REMOTE_ADDR'];
             $this->model->save($userInfo, false, null, false);
             if ($rememberMe == 1) {
                 $this->Cookie->write('loggedUser', serialize($userInfo['User']), true, '65 Days');
             }
             return true;
         }
     } else {
         $this->log("error occured while Loggining: empty userID");
         return false;
     }
 }
 /**
  * testSessionFlash method
  *
  * @return void
  */
 public function testSessionFlash()
 {
     $Session = new SessionComponent($this->ComponentCollection);
     $this->assertNull($Session->read('Message.flash'));
     $Session->setFlash('This is a test message');
     $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.flash'));
     $Session->setFlash('This is a test message', 'test', array('name' => 'Joel Moss'));
     $this->assertEquals(array('message' => 'This is a test message', 'element' => 'test', 'params' => array('name' => 'Joel Moss')), $Session->read('Message.flash'));
     $Session->setFlash('This is a test message', 'default', array(), 'myFlash');
     $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.myFlash'));
     $Session->setFlash('This is a test message', 'non_existing_layout');
     $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.myFlash'));
     $Session->delete('Message');
 }
Exemplo n.º 8
0
 /**
  * Deletes the whole cache from the Session variable
  */
 function flushCache()
 {
     $this->Session->delete($this->settings['sessionKey']);
 }
 public function logout()
 {
     // just erase data in Session
     $session_name = $this->settings['session'];
     SessionComponent::delete($session_name);
     return true;
 }
 public function logout()
 {
     $cookie_name = 'linkedin_oauth_' . $this->settings['api_key'];
     ob_start();
     setcookie($cookie_name, '', time() - 86400, '/', $_SERVER['HTTP_HOST'], true);
     ob_end_flush();
     $session_name = $this->settings['session'];
     SessionComponent::delete($session_name);
     return true;
 }
Exemplo n.º 11
0
 /**
  * セッションに保存されたリクエストパラメータを破棄
  * @param SessionComponent $session
  */
 public static function deleteRequestSessionData(SessionComponent $session)
 {
     $session->delete(static::TMP_REQUEST_SESSION_KEY);
 }
Exemplo n.º 12
0
 /**
  * for retry challenge
  */
 function failure()
 {
     $this->Session->delete('Challenge');
 }
Exemplo n.º 13
0
 /**
  * cleans session variables
  */
 function _clean_session()
 {
     $this->Session->delete('Points');
 }