Ejemplo n.º 1
0
 public function submit()
 {
     // @todo search indexer on posts (reindex all in case the topic_access level has changed))
     $this->topic_subject_clean = url::generate_slug($this->topic_subject);
     parent::submit();
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
 }
Ejemplo n.º 2
0
 public function submit()
 {
     // Subscriptions
     if (!$this->attention_id) {
         $u_view = $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => $this->attention_type, 'id' => $this->attention_object_id));
         $email_vars = array('NAME' => $this->attention_title, 'U_VIEW' => $this->path_helper->strip_url_params($u_view, 'sid'));
         $this->subscriptions->send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify', $email_vars, $this->attention_poster_id);
     }
     parent::submit();
 }
Ejemplo n.º 3
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;
    }
Ejemplo n.º 4
0
    /**
     * Update/create the queue entry for this revision
     *
     * @param array $exclude_from_closing		Revisions to exclude from getting marked as repacked/resubmitted
     *	upon the new revision getting added to the queue.
     */
    public function update_queue($exclude_from_closing = array())
    {
        // Create the queue entry if required, else update it
        if (titania::$config->use_queue && $this->contrib->type->use_queue) {
            $queue = $this->get_queue();
            // Only create the queue for revisions set as new
            if ($queue === false && ($this->revision_status == TITANIA_REVISION_NEW || $this->revision_status == TITANIA_REVISION_ON_HOLD)) {
                $queue = new titania_queue();
            }
            // If we have to create or update one...
            if ($queue !== false) {
                $queue->__set_array(array('revision_id' => $this->revision_id, 'contrib_id' => $this->contrib_id, 'contrib_name_clean' => $this->contrib->contrib_name_clean));
                // Set the queue status to new if it's submitted and the queue status is set to hide it
                if ($this->revision_submitted && $queue->queue_status == TITANIA_QUEUE_HIDE) {
                    // Only set the queue as new if there are not any newer revisions in the queue
                    $sql = 'SELECT queue_id FROM ' . TITANIA_QUEUE_TABLE . '
						WHERE contrib_id = ' . (int) $this->contrib_id . '
							AND revision_id > ' . $this->revision_id;
                    $result = phpbb::$db->sql_query($sql);
                    if (!($row = phpbb::$db->sql_fetchrow($result))) {
                        $queue->queue_status = TITANIA_QUEUE_NEW;
                    }
                }
                $queue->submit();
                // Set the revision queue id
                $this->revision_queue_id = $queue->queue_id;
                parent::submit();
                if ($this->revision_submitted) {
                    $exclude = '';
                    if (!empty($exclude_from_closing)) {
                        $exclude = 'AND ' . phpbb::$db->sql_in_set('revision_id', $exclude_from_closing, true);
                    }
                    // Change the status on any old revisions that were in the queue and marked as New to repacked
                    $sql = 'SELECT * FROM ' . TITANIA_QUEUE_TABLE . '
						WHERE contrib_id = ' . (int) $this->contrib_id . '
							AND revision_id < ' . $this->revision_id . "\n\t\t\t\t\t\t\t{$exclude}\n\t\t\t\t\t\t\tAND queue_status = " . TITANIA_QUEUE_NEW;
                    $result = phpbb::$db->sql_query($sql);
                    while ($row = phpbb::$db->sql_fetchrow($result)) {
                        $queue = new titania_queue();
                        $queue->__set_array($row);
                        $queue->close(TITANIA_REVISION_RESUBMITTED);
                        unset($queue);
                    }
                    phpbb::$db->sql_freeresult($result);
                }
            }
        }
    }
Ejemplo n.º 5
0
 /**
  * Removes file from server and database.
  *
  * @return void
  */
 public function delete()
 {
     @unlink($this->get_filepath());
     @unlink($this->get_filepath(true));
     parent::delete();
 }