private function delete_question(FaqQuestion $question) { FaqService::delete('WHERE id=:id', array('id' => $question->get_id())); PersistenceContext::get_querier()->delete(DB_TABLE_EVENTS, 'WHERE module=:module AND id_in_module=:id', array('module' => 'faq', 'id' => $question->get_id())); Feed::clear_cache('faq'); FaqCache::invalidate(); }
private function delete_question() { AppContext::get_session()->csrf_post_protect(); FaqService::delete('WHERE id=:id', array('id' => $this->faq_question->get_id())); PersistenceContext::get_querier()->delete(DB_TABLE_EVENTS, 'WHERE module=:module AND id_in_module=:id', array('module' => 'faq', 'id' => $this->faq_question->get_id())); Feed::clear_cache('faq'); FaqCache::invalidate(); }
public function get_menu_content() { //Create file template $tpl = new FileTemplate('faq/FaqModuleMiniMenu.tpl'); //Assign the lang file to the tpl $tpl->add_lang(LangLoader::get('common', 'faq')); //Load module cache $faq_cache = FaqCache::load(); //Get authorized categories for the current user $authorized_categories = FaqService::get_authorized_categories(Category::ROOT_CATEGORY); $categories = array_intersect($faq_cache->get_categories(), $authorized_categories); if (!empty($categories)) { $id_category = $categories[array_rand($categories)]; $category_questions = $faq_cache->get_category_questions($id_category); $random_question = $category_questions[array_rand($category_questions)]; if (!empty($random_question)) { $category = FaqService::get_categories_manager()->get_categories_cache()->get_category($id_category); $tpl->put_all(array('C_QUESTION' => true, 'QUESTION' => $random_question['question'], 'U_LINK' => FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $random_question['id'])->rel())); } } return $tpl->render(); }
private function save() { $this->config->set_categories_number_per_page($this->form->get_value('categories_number_per_page')); $this->config->set_columns_number_per_line($this->form->get_value('columns_number_per_line')); $this->config->set_display_type($this->form->get_value('display_type')->get_raw_value()); $this->config->set_root_category_description($this->form->get_value('root_category_description')); $this->config->set_authorizations($this->form->get_value('authorizations')->build_auth_array()); FaqConfig::save(); FaqService::get_categories_manager()->regenerate_cache(); FaqCache::invalidate(); }
private function save() { $faq_question = $this->get_faq_question(); $faq_question->set_question($this->form->get_value('question')); $faq_question->set_rewrited_question(Url::encode_rewrite($faq_question->get_question())); $faq_question->set_id_category($this->form->get_value('id_category')->get_raw_value()); $faq_question->set_answer($this->form->get_value('answer')); if ($faq_question->get_q_order() === null) { $number_questions_in_category = FaqService::count('WHERE id_category = :id_category', array('id_category' => $faq_question->get_id_category())); $faq_question->set_q_order($number_questions_in_category + 1); } if (!$this->is_contributor_member() && $this->form->get_value('approved')) { $faq_question->approve(); } else { $faq_question->unapprove(); } if ($faq_question->get_id() === null) { $id = FaqService::add($faq_question); } else { $id = $faq_question->get_id(); FaqService::update($faq_question); } $this->contribution_actions($faq_question, $id); Feed::clear_cache('faq'); FaqCache::invalidate(); }