/** * Update data or submit new faq * * @return void */ public function submit() { // Get the FAQ count to update it $sql = 'SELECT contrib_faq_count FROM ' . TITANIA_CONTRIBS_TABLE . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); $contrib_faq_count = phpbb::$db->sql_fetchfield('contrib_faq_count'); phpbb::$db->sql_freeresult(); // If already submitted we need to decrement first if ($this->faq_id) { if (empty($this->sql_data)) { throw new exception('Modifying a FAQ entry requires you load it through the load() function (we require the original information).'); } $original_flags = count::update_flags($this->sql_data['faq_access']); $contrib_faq_count = count::decrement($contrib_faq_count, $original_flags); } // Update the FAQ count $flags = count::update_flags($this->faq_access); $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET contrib_faq_count = \'' . phpbb::$db->sql_escape(count::increment($contrib_faq_count, $flags)) . '\' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); // Submit this FAQ item parent::submit(); // Index $this->search_manager->index(TITANIA_FAQ, $this->faq_id, array('title' => $this->faq_subject, 'text' => $this->faq_text, 'text_uid' => $this->faq_text_uid, 'text_bitfield' => $this->faq_text_bitfield, 'text_options' => $this->faq_text_options, 'author' => 0, 'date' => 0, 'url' => serialize(array('contrib_type' => $this->contrib->type->url, 'contrib' => $this->contrib->contrib_name_clean)), 'access_level' => $this->faq_access)); }
/** * Index this post */ public function index() { $this->search_manager->index($this->post_type, $this->post_id, array('parent_id' => $this->topic->parent_id, 'title' => $this->post_subject, 'text' => $this->post_text, 'text_uid' => $this->post_text_uid, 'text_bitfield' => $this->post_text_bitfield, 'text_options' => $this->post_text_options, 'author' => $this->post_user_id, 'date' => $this->post_time, 'url' => serialize($this->get_url_params()), 'access_level' => min($this->post_access, $this->topic->topic_access), 'approved' => $this->post_approved, 'reported' => $this->post_reported, 'parent_contrib_type' => $this->parent_contrib_type)); }
/** * Index the contribution */ public function index() { if (!sizeof($this->revisions)) { $this->get_revisions(); } $phpbb_versions = array(); foreach ($this->revisions as $revision) { if ($revision['revision_status'] == TITANIA_REVISION_APPROVED) { $phpbb_versions = array_merge($phpbb_versions, $revision['phpbb_versions']); } } $phpbb_versions = array_unique(versions::order_phpbb_version_list_from_db($this->cache, $phpbb_versions)); $data = array('title' => $this->contrib_name, 'text' => $this->contrib_desc, 'text_uid' => $this->contrib_desc_uid, 'text_bitfield' => $this->contrib_desc_bitfield, 'text_options' => $this->contrib_desc_options, 'author' => $this->contrib_user_id, 'date' => $this->contrib_last_update, 'url' => serialize(array('contrib_type' => $this->type->url, 'contrib' => $this->contrib_name_clean)), 'approved' => in_array($this->contrib_status, array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) ? true : false, 'categories' => explode(',', $this->contrib_categories), 'phpbb_versions' => $phpbb_versions); $this->search_manager->index(TITANIA_CONTRIB, $this->contrib_id, $data); }