Example #1
0
 /**
  * Loads available updates.
  *
  * @return array List of AvailableUpdate instances.
  *
  * @throws \RuntimeException If something went wrong and the list could not
  *   be loaded.
  */
 public static function all()
 {
     $rows = Database::getInstance()->query("SELECT * FROM {availableupdate}", null, array('return_rows' => Database::RETURN_ALL_ROWS));
     if ($rows === false) {
         throw new \RuntimeException('List of available updates cannot be retrieved.');
     }
     $updates = array();
     foreach ($rows as $item) {
         $update = new self();
         $update->populateFromDbFields($item);
         $updates[] = $update;
     }
     return $updates;
 }
Example #2
0
 /**
  * Load thread from database
  *
  * @param int $id ID of the thread to load
  * @return boolean|Thread Returns an object of the Thread class or boolean
  *   false on failure
  */
 public static function load($id, $last_token = null)
 {
     // Check $id
     if (empty($id)) {
         return false;
     }
     // Load thread
     $thread_info = Database::getInstance()->query("SELECT * FROM {thread} WHERE threadid = :threadid", array(':threadid' => $id), array('return_rows' => Database::RETURN_ONE_ROW));
     // There is no thread with such id in database
     if (!$thread_info) {
         return;
     }
     // Create new empty thread and populate it with the values from database
     $thread = new self();
     $thread->populateFromDbFields($thread_info);
     // Check last token
     if (!is_null($last_token)) {
         if ($thread->lastToken != $last_token) {
             return false;
         }
     }
     return $thread;
 }
Example #3
0
 /**
  * Loads all bans.
  *
  * @return array List of Ban instances.
  *
  * @throws \RuntimeException If something went wrong and the list could not
  *   be loaded.
  */
 public static function all()
 {
     $rows = Database::getInstance()->query("SELECT * FROM {ban}", null, array('return_rows' => Database::RETURN_ALL_ROWS));
     if ($rows === false) {
         throw new \RuntimeException('Bans list cannot be retrieved.');
     }
     $bans = array();
     foreach ($rows as $item) {
         $ban = new self();
         $ban->populateFromDbFields($item);
         $bans[] = $ban;
     }
     return $bans;
 }
Example #4
0
 /**
  * Loads state for all enabled plugins.
  *
  * @return State[] List of state objects.
  * @throws \RuntimeException If the data cannot be retrieved because of a
  *   failure.
  */
 public static function loadAllEnabled()
 {
     $rows = Database::getInstance()->query('SELECT * FROM {plugin} WHERE enabled = :enabled AND installed = :installed', array(':enabled' => 1, ':installed' => 1), array('return_rows' => Database::RETURN_ALL_ROWS));
     if ($rows === false) {
         throw new \RuntimeException('Plugins list cannot be retrieved.');
     }
     $states = array();
     foreach ($rows as $row) {
         $state = new self();
         $state->populateFromDbFields($row);
         $states[] = $state;
     }
     return $states;
 }