コード例 #1
0
ファイル: rating.php プロジェクト: Gfksx/customisation-db
    /**
     * 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;
    }
コード例 #2
0
ファイル: attachment.php プロジェクト: Gfksx/customisation-db
 /**
  * Removes file from server and database.
  *
  * @return void
  */
 public function delete($attachment_id = false)
 {
     $attachment_id = $attachment_id === false ? $this->attachment_id : (int) $attachment_id;
     if (!$attachment_id) {
         return;
     }
     if ($attachment_id == $this->attachment_id) {
         @unlink(titania::$config->upload_path . utf8_basename($this->attachment_directory) . '/' . utf8_basename($this->physical_filename));
         @unlink(titania::$config->upload_path . utf8_basename($this->attachment_directory) . '/thumb_' . utf8_basename($this->physical_filename));
         parent::delete();
     } else {
         if (isset($this->attachments[$attachment_id])) {
             @unlink(titania::$config->upload_path . utf8_basename($this->attachments[$attachment_id]['attachment_directory']) . '/' . utf8_basename($this->attachments[$attachment_id]['physical_filename']));
             @unlink(titania::$config->upload_path . utf8_basename($this->attachments[$attachment_id]['attachment_directory']) . '/thumb_' . utf8_basename($this->attachments[$attachment_id]['physical_filename']));
             $sql = 'DELETE FROM ' . $this->sql_table . ' WHERE attachment_id = ' . $attachment_id;
             phpbb::$db->sql_query($sql);
         }
     }
     if (isset($this->attachments[$attachment_id])) {
         unset($this->attachments[$attachment_id]);
     }
 }
コード例 #3
0
ファイル: revision.php プロジェクト: Gfksx/customisation-db
 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
     $attachment = new titania_attachment(TITANIA_CONTRIB);
     $attachment->attachment_id = $this->attachment_id;
     $attachment->load();
     $attachment->delete();
     // Delete translations
     // $translations = new titania_attachment(TITANIA_TRANSLATION, $this->revision_id);
     // $attachment->delete_all();
     // Self-destruct
     parent::delete();
 }
コード例 #4
0
 /**
  * Removes file from server and database.
  *
  * @return void
  */
 public function delete($attachment_id = false)
 {
     $attachment_id = $attachment_id === false ? $this->attachment_id : (int) $attachment_id;
     if (!$attachment_id) {
         return;
     }
     if ($attachment_id == $this->attachment_id) {
         @unlink(titania::$config->upload_path . utf8_basename($this->attachment_directory) . '/' . utf8_basename($this->physical_filename));
         @unlink(titania::$config->upload_path . utf8_basename($this->attachment_directory) . '/thumb_' . utf8_basename($this->physical_filename));
         parent::delete();
     } else {
         if (isset($this->attachments[$attachment_id])) {
             @unlink(titania::$config->upload_path . utf8_basename($this->attachments[$attachment_id]['attachment_directory']) . '/' . utf8_basename($this->attachments[$attachment_id]['physical_filename']));
             @unlink(titania::$config->upload_path . utf8_basename($this->attachments[$attachment_id]['attachment_directory']) . '/thumb_' . utf8_basename($this->attachments[$attachment_id]['physical_filename']));
             $sql = 'DELETE FROM ' . $this->sql_table . ' WHERE attachment_id = ' . $attachment_id;
             phpbb::$db->sql_query($sql);
             if ($this->attachments[$attachment_id]['is_preview'] && ($this->attachments[$attachment_id]['object_type'] == TITANIA_SCREENSHOT || $this->attachments[$attachment_id]['object_type'] == TITANIA_CLR_SCREENSHOT)) {
                 $set_new_preview = true;
             }
         }
     }
     if (isset($this->attachments[$attachment_id])) {
         unset($this->attachments[$attachment_id]);
     }
     // set the next screenshot as preview
     if (key($this->attachments) && isset($set_new_preview) && $set_new_preview) {
         $this->set_preview(key($this->attachments));
     }
 }