/** * Update the release topic for this contribution */ public function update_release_topic() { if (titania_types::$types[$this->contrib_type]->forum_robot && titania_types::$types[$this->contrib_type]->forum_database && titania_types::$types[$this->contrib_type]->create_public) { titania::_include('functions_posting', 'phpbb_posting'); // Get the latest download $this->get_download(); // If there is not a download do not update. if (!$this->download) { return; } // Get the latest revision $this->get_revisions(); // If there is not a revision do not update. if (!$this->revisions) { return; } $phpbb_version = $this->revisions[$this->download['revision_id']]['phpbb_versions'][0]; $contrib_description = $this->contrib_desc; titania_decode_message($contrib_description, $this->contrib_desc_uid); // Global body and options $body = sprintf(phpbb::$user->lang[titania_types::$types[$this->contrib_type]->create_public], $this->contrib_name, titania_url::remove_sid($this->author->get_url()), users_overlord::get_user($this->author->user_id, '_username'), $contrib_description, $this->download['revision_version'], titania_url::build_clean_url('download', array('id' => $this->download['attachment_id'])), $this->download['real_filename'], $this->download['filesize'], titania_url::remove_sid($this->get_url()), titania_url::remove_sid($this->get_url('support')), $phpbb_version['phpbb_version_branch'][0] . '.' . $phpbb_version['phpbb_version_branch'][1] . '.' . $phpbb_version['phpbb_version_revision']); $options = array('poster_id' => titania_types::$types[$this->contrib_type]->forum_robot, 'forum_id' => titania_types::$types[$this->contrib_type]->forum_database); if ($this->contrib_release_topic_id) { // We edit the first post of contrib release topic $options_edit = array('topic_id' => $this->contrib_release_topic_id, 'topic_title' => $this->contrib_name, 'post_text' => $body); $options_edit = array_merge($options_edit, $options); phpbb_posting('edit_first_post', $options_edit); } else { // We create a new topic in database $options_post = array('topic_title' => $this->contrib_name, 'post_text' => $body); $options_post = array_merge($options_post, $options); $this->contrib_release_topic_id = phpbb_posting('post', $options_post); $sql = 'UPDATE ' . $this->sql_table . ' SET contrib_release_topic_id = ' . $this->contrib_release_topic_id . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); } } }