Пример #1
0
 public function delete()
 {
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
     // Delete the queue item
     $queue = $this->get_queue();
     if ($queue !== false) {
         $queue->delete();
     }
     // Delete the attachment
     $operator = phpbb::$container->get('phpbb.titania.attachment.operator');
     $operator->configure(TITANIA_CONTRIB, $this->contrib_id)->load(array($this->attachment_id))->delete(array($this->attachment_id));
     repository::trigger_cron($this->config);
     // Delete translations
     // $translations = new titania_attachment(TITANIA_TRANSLATION, $this->revision_id);
     // $attachment->delete_all();
     // Self-destruct
     parent::delete();
 }
Пример #2
0
    /**
     * Delete the user's own rating
     */
    public function delete_rating()
    {
        if (!phpbb::$user->data['is_registered'] || !$this->rating_id) {
            return false;
        }
        parent::delete();
        if ($this->rating_count == 1) {
            $sql_ary = array($this->cache_rating => 0, $this->cache_rating_count => 0);
            $sql = 'UPDATE ' . $this->cache_table . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE ' . $this->object_column . ' = ' . $this->rating_object_id;
            phpbb::$db->sql_query($sql);
        } else {
            // This is accurate enough as long as we have at least 2 decimal places
            $sql = "UPDATE {$this->cache_table} SET\n\t\t\t\t{$this->cache_rating} = ({$this->cache_rating} * {$this->rating_count} - {$this->rating_value}) / ({$this->rating_count} - 1),\n\t\t\t\t{$this->cache_rating_count} = {$this->cache_rating_count} - 1\n\t\t\t\tWHERE {$this->object_column} = {$this->rating_object_id}";
            phpbb::$db->sql_query($sql);
        }
        return true;
    }
Пример #3
0
 /**
  * Removes file from server and database.
  *
  * @return void
  */
 public function delete()
 {
     @unlink($this->get_filepath());
     @unlink($this->get_filepath(true));
     parent::delete();
 }