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()); }
private function contribution_actions(FaqQuestion $faq_question, $id) { if ($faq_question->get_id() === null) { if ($this->is_contributor_member()) { $contribution = new Contribution(); $contribution->set_id_in_module($id); $contribution->set_description(stripslashes($this->form->get_value('contribution_description'))); $contribution->set_entitled($faq_question->get_question()); $contribution->set_fixing_url(FaqUrlBuilder::edit($id)->relative()); $contribution->set_poster_id(AppContext::get_current_user()->get_id()); $contribution->set_module('faq'); $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(FaqService::get_categories_manager()->get_heritated_authorizations($faq_question->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT)); ContributionService::save_contribution($contribution); } } else { $corresponding_contributions = ContributionService::find_by_criteria('faq', $id); if (count($corresponding_contributions) > 0) { $faq_question_contribution = $corresponding_contributions[0]; $faq_question_contribution->set_status(Event::EVENT_STATUS_PROCESSED); ContributionService::save_contribution($faq_question_contribution); } } $faq_question->set_id($id); }