Example #1
0
 /**
  * Writes the current session.
  *
  * @return  boolean
  */
 protected function _write()
 {
     // Save to Redis
     $this->_redis->set($this->_prefix . $this->_session_id, $this->__toString(), $this->_lifetime);
     // Update the cookie with the new session id
     Cookie::set($this->_name, $this->_session_id, $this->_lifetime);
     return TRUE;
 }
Example #2
0
 public static function init()
 {
     if (!self::$_includePath) {
         self::$_includePath = self::_buildIncludePath();
     }
     if (!is_null(TestHelperSettings::get("database"))) {
         Database::set(self::_getDatabaseAdapter(TestHelperSettings::get("database")));
     }
 }
Example #3
0
 public function add_as_author_of(User_Model $author, ORM $object)
 {
     if ($this->is_possible_to_add_authors_to($object)) {
         Benchmark::start('add_as_author_of');
         try {
             $database = new Database();
             $database->from('workshop_data');
             $database->set(array('object_name' => $object->object_name, 'user_id' => $author->id, 'object_id' => $object->id));
             $database->insert();
         } catch (Kohana_Database_Exception $e) {
             if (strstr($e->getMessage(), 'Duplicate entry')) {
                 throw new Workshop_Duplicate_Author_Exception($author, $object);
             } else {
                 throw $e;
             }
         }
         Benchmark::stop('add_as_author_of');
     } else {
         throw new Workshop_Max_Limit_Exception($object, $this->get_number_of_authors_of($object), 1, $this->config_delegate->max_authors_for($object));
     }
 }
 function activate($name)
 {
     $db = new Database();
     $query = $db->query('SELECT * FROM plugins WHERE plugin_name = ' . $db->escape($name));
     // Test if row already in database
     if ($query->count() == 1) {
         $db->update('plugin_instances', array('status' => 1), array('plugin_name' => $name));
     } else {
         $db->set('plugin_name', $name)->set('status', 1)->insert('plugins');
     }
     try {
         // Is there a difference between Inactive and deleted?
         return self::getPlugin($name)->activate();
     } catch (Exception $e) {
         Kohana::log('debug', $e->getMessage());
     }
 }