public function execute(HTTPRequestCustom $request)
 {
     AppContext::get_session()->csrf_get_protect();
     $question = $this->get_faq_question($request);
     $this->check_authorizations($question);
     $this->delete_question($question);
     AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : FaqUrlBuilder::home(), StringVars::replace_vars(LangLoader::get_message('faq.message.success.delete', 'common', 'faq'), array('question' => $question->get_question())));
 }
 public function __construct($view, $title_page)
 {
     parent::__construct($view);
     $lang = LangLoader::get('common', 'faq');
     $this->set_title($lang['module_title']);
     $this->add_link(LangLoader::get_message('categories.management', 'categories-common'), FaqUrlBuilder::manage_categories());
     $this->add_link(LangLoader::get_message('category.add', 'categories-common'), FaqUrlBuilder::add_category());
     $this->add_link($lang['faq.management'], FaqUrlBuilder::manage());
     $this->add_link($lang['faq.actions.add'], FaqUrlBuilder::add());
     $this->add_link(LangLoader::get_message('configuration', 'admin-common'), FaqUrlBuilder::configuration());
     $env = $this->get_graphical_environment();
     $env->set_page_title($title_page, $lang['module_title']);
 }
예제 #3
0
 public function get_actions_tree_links()
 {
     $lang = LangLoader::get('common', 'faq');
     $tree = new ModuleTreeLinks();
     $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), FaqUrlBuilder::manage_categories());
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), FaqUrlBuilder::manage_categories()));
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), FaqUrlBuilder::add_category()));
     $tree->add_link($manage_categories_link);
     $manage_link = new AdminModuleLink($lang['faq.manage'], FaqUrlBuilder::manage());
     $manage_link->add_sub_link(new AdminModuleLink($lang['faq.manage'], FaqUrlBuilder::manage()));
     $manage_link->add_sub_link(new AdminModuleLink($lang['faq.actions.add'], FaqUrlBuilder::add(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY))));
     $tree->add_link($manage_link);
     $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), FaqUrlBuilder::configuration()));
     if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $tree->add_link(new ModuleLink($lang['faq.actions.add'], FaqUrlBuilder::add(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY)), FaqAuthorizationsService::check_authorizations()->write() || FaqAuthorizationsService::check_authorizations()->contribution()));
     }
     $tree->add_link(new ModuleLink($lang['faq.pending'], FaqUrlBuilder::display_pending(), FaqAuthorizationsService::check_authorizations()->write() || FaqAuthorizationsService::check_authorizations()->contribution() || FaqAuthorizationsService::check_authorizations()->moderation()));
     return $tree;
 }
 private function build_table()
 {
     $table_model = new SQLHTMLTableModel(FaqSetup::$faq_table, 'table', array(new HTMLTableColumn($this->lang['faq.form.question'], 'question'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status.approved', 'common'), 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC));
     $table = new HTMLTable($table_model);
     $table_model->set_caption($this->lang['faq.management']);
     $results = array();
     $result = $table_model->get_sql_results('faq LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = faq.author_user_id');
     foreach ($result as $row) {
         $faq_question = new FaqQuestion();
         $faq_question->set_properties($row);
         $category = $faq_question->get_category();
         $user = $faq_question->get_author_user();
         $edit_link = new LinkHTMLElement(FaqUrlBuilder::edit($faq_question->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
         $delete_link = new LinkHTMLElement(FaqUrlBuilder::delete($faq_question->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
         $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
         $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
         $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $faq_question->get_id()), $faq_question->get_question()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($faq_question->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($faq_question->is_approved() ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
     }
     $table->set_rows($table_model->get_number_of_matching_rows(), $results);
     $this->view->put('table', $table->display());
 }
예제 #5
0
    public function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (FaqService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $querier = PersistenceContext::get_querier();
            $category = FaqService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = LangLoader::get_message('module_title', 'common', 'faq');
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('faq', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = FaqService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $results = $querier->select('SELECT faq.id, faq.id_category, faq.question, faq.answer, faq.creation_date, cat.rewrited_name AS rewrited_name_cat
				FROM ' . FaqSetup::$faq_table . ' faq
				LEFT JOIN ' . FaqSetup::$faq_cats_table . ' cat ON cat.id = faq.id_category
				WHERE approved = 1
				AND faq.id_category IN :ids_categories
				ORDER BY faq.creation_date DESC', array('ids_categories' => $ids_categories));
            foreach ($results as $row) {
                $row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root';
                $link = FaqUrlBuilder::display($row['id_category'], $row['rewrited_name_cat'], $row['id']);
                $item = new FeedItem();
                $item->set_title($row['question']);
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($row['answer']));
                $item->set_date(new Date($row['creation_date'], Timezone::SERVER_TIMEZONE));
                $item->set_auth(FaqService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $results->dispose();
            return $data;
        }
    }
 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();
 }
 protected function get_categories_management_url()
 {
     return FaqUrlBuilder::manage_categories();
 }
예제 #8
0
 public function get_array_tpl_vars()
 {
     $category = $this->get_category();
     $user = $this->get_author_user();
     $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
     return array('C_APPROVED' => $this->is_approved(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'ID' => $this->id, 'QUESTION' => $this->question, 'ANSWER' => FormatingHelper::second_parse($this->answer), 'DATE' => $this->creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'DATE_ISO8601' => $this->creation_date->format(Date::FORMAT_ISO8601), 'C_AUTHOR_EXIST' => $user->get_id() !== User::VISITOR_LEVEL, 'PSEUDO' => $user->get_display_name(), 'USER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'USER_GROUP_COLOR' => $user_group_color, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_DESCRIPTION' => $category->get_description(), 'CATEGORY_IMAGE' => $category->get_image()->rel(), 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? FaqUrlBuilder::configuration()->rel() : FaqUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('faq', $this->id_category)->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($this->get_author_user()->get_id())->rel(), 'U_LINK' => FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $this->id)->rel(), 'U_CATEGORY' => FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())->rel(), 'U_EDIT' => FaqUrlBuilder::edit($this->id)->rel(), 'U_DELETE' => FaqUrlBuilder::delete($this->id)->rel());
 }
예제 #9
0
 *
 ###################################################
 *
 * This program is a free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
####################################################
#						English						#
####################################################
$lang['root_category_description'] = 'Welcome on the FAQ!
<br /><br />
Two categories and some questions were created to show you how this module works. Here are some tips to get started on this module.
<br /><br /> 
<ul class="formatter-ul">
	<li class="formatter-li"> To configure or customize the module homepage your module, go into the <a href="' . FaqUrlBuilder::configuration()->relative() . '">module administration</a></li>
	<li class="formatter-li"> To create categories, <a href="' . FaqUrlBuilder::add_category()->relative() . '">clic here</a></li>
	<li class="formatter-li"> To create questions, <a href="' . FaqUrlBuilder::add()->relative() . '">clic here</a></li>
</ul>
<br />To learn more, don \'t hesitate to consult the documentation for the module on <a href="http://www.phpboost.com">PHPBoost</a> website.';
예제 #10
0
 *
 ###################################################
 *
 * This program is a free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
####################################################
#						French						#
####################################################
$lang['root_category_description'] = 'Bienvenue dans la FAQ !
<br /><br />
2 catégories et quelques questions ont été créées pour vous montrer comment fonctionne ce module. Voici quelques conseils pour bien débuter sur ce module.
<br /><br /> 
<ul class="formatter-ul">
	<li class="formatter-li"> Pour configurer ou personnaliser l\'accueil de votre module, rendez vous dans l\'<a href="' . FaqUrlBuilder::configuration()->relative() . '">administration du module</a></li>
	<li class="formatter-li"> Pour créer des catégories, <a href="' . FaqUrlBuilder::add_category()->relative() . '">cliquez ici</a> </li>
	<li class="formatter-li"> Pour créer des questions, <a href="' . FaqUrlBuilder::add()->relative() . '">cliquez ici</a></li>
</ul>
<br />Pour en savoir plus, n\'hésitez pas à consulter la documentation du module sur le site de <a href="http://www.phpboost.com">PHPBoost</a>.';
 private function generate_response()
 {
     $response = new SiteDisplayResponse($this->tpl);
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($this->get_category()->get_name(), $this->lang['module_title']);
     $graphical_environment->get_seo_meta_data()->set_description($this->get_category()->get_description());
     $graphical_environment->get_seo_meta_data()->set_canonical_url(FaqUrlBuilder::display_category($this->get_category()->get_id(), $this->get_category()->get_rewrited_name(), AppContext::get_request()->get_getint('page', 1)));
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], FaqUrlBuilder::home());
     $categories = array_reverse(FaqService::get_categories_manager()->get_parents($this->get_category()->get_id(), true));
     foreach ($categories as $id => $category) {
         if ($category->get_id() != Category::ROOT_CATEGORY) {
             $breadcrumb->add($category->get_name(), FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()));
         }
     }
     return $response;
 }
 protected function get_delete_category_url(Category $category)
 {
     return FaqUrlBuilder::delete_category($category->get_id());
 }
 private function generate_response()
 {
     $response = new SiteDisplayResponse($this->tpl);
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($this->lang['faq.pending'], $this->lang['module_title']);
     $graphical_environment->get_seo_meta_data()->set_description($this->lang['faq.seo.description.pending']);
     $graphical_environment->get_seo_meta_data()->set_canonical_url(FaqUrlBuilder::display_pending());
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], FaqUrlBuilder::home());
     $breadcrumb->add($this->lang['faq.pending'], FaqUrlBuilder::display_pending());
     return $response;
 }
예제 #14
0
 private function generate_response(View $tpl)
 {
     $faq_question = $this->get_faq_question();
     $response = new SiteDisplayResponse($tpl);
     $graphical_environment = $response->get_graphical_environment();
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], FaqUrlBuilder::home());
     if ($faq_question->get_id() === null) {
         $graphical_environment->set_page_title($this->lang['faq.add'], $this->lang['module_title']);
         $breadcrumb->add($this->lang['faq.add'], FaqUrlBuilder::add($faq_question->get_id_category()));
         $graphical_environment->get_seo_meta_data()->set_description($this->lang['faq.add']);
         $graphical_environment->get_seo_meta_data()->set_canonical_url(FaqUrlBuilder::add($faq_question->get_id_category()));
     } else {
         $graphical_environment->set_page_title($this->lang['faq.edit'], $this->lang['module_title']);
         $graphical_environment->get_seo_meta_data()->set_description($this->lang['faq.edit']);
         $graphical_environment->get_seo_meta_data()->set_canonical_url(FaqUrlBuilder::edit($faq_question->get_id()));
         $categories = array_reverse(FaqService::get_categories_manager()->get_parents($faq_question->get_id_category(), true));
         foreach ($categories as $id => $category) {
             if ($category->get_id() != Category::ROOT_CATEGORY) {
                 $breadcrumb->add($category->get_name(), FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()));
             }
         }
         $category = $faq_question->get_category();
         $breadcrumb->add($faq_question->get_question(), FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $faq_question->get_id()));
         $breadcrumb->add($this->lang['faq.edit'], FaqUrlBuilder::edit($faq_question->get_id()));
     }
     return $response;
 }
 protected function get_category_url(Category $category)
 {
     return FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name());
 }