Example #1
0
 public function testGetWithSession()
 {
     $c = new Config($this->container);
     session_id('test');
     $this->assertTrue(SessionManager::isOpen());
     $this->assertEquals('', $c->get('board_columns'));
     $this->assertEquals('test', $c->get('board_columns', 'test'));
     $this->container['sessionStorage']->config = array('board_columns' => 'foo', 'empty_value' => 0);
     $this->assertEquals('foo', $c->get('board_columns'));
     $this->assertEquals('foo', $c->get('board_columns', 'test'));
     $this->assertEquals('test', $c->get('empty_value', 'test'));
     session_id('');
     $this->assertFalse(SessionManager::isOpen());
 }
Example #2
0
 /**
  * Get a config variable from the session or the database
  *
  * @access public
  * @param  string   $name            Parameter name
  * @param  string   $default_value   Default value of the parameter
  * @return string
  */
 public function get($name, $default_value = '')
 {
     if (!SessionManager::isOpen()) {
         return $this->getOption($name, $default_value);
     }
     // Cache config in session
     if (!isset($this->sessionStorage->config[$name])) {
         $this->sessionStorage->config = $this->getAll();
     }
     if (!empty($this->sessionStorage->config[$name])) {
         return $this->sessionStorage->config[$name];
     }
     return $default_value;
 }
Example #3
0
 /**
  * Modify a new user
  *
  * @access public
  * @param  array  $values  Form values
  * @return array
  */
 public function update(array $values)
 {
     $this->prepare($values);
     $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
     // If the user is connected refresh his session
     if (SessionManager::isOpen() && $this->userSession->getId() == $values['id']) {
         $this->userSession->initialize($this->getById($this->userSession->getId()));
     }
     return $result;
 }