private function build_table()
    {
        $table_model = new SQLHTMLTableModel(WebSetup::$web_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), 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', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC));
        $table = new HTMLTable($table_model);
        $table_model->set_caption($this->lang['web.management']);
        $results = array();
        $result = $table_model->get_sql_results('web
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = web.id AND com.module_id = \'web\'
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = web.id AND notes.module_name = \'web\'
			LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = web.id AND note.module_name = \'web\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = web.author_user_id', array('*', 'web.id'));
        foreach ($result as $row) {
            $weblink = new WebLink();
            $weblink->set_properties($row);
            $category = $weblink->get_category();
            $user = $weblink->get_author_user();
            $edit_link = new LinkHTMLElement(WebUrlBuilder::edit($weblink->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(WebUrlBuilder::delete($weblink->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(WebUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $weblink->get_id(), $weblink->get_rewrited_name()), $weblink->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(WebUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($weblink->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($weblink->get_status()), 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(WebLink $weblink, $id)
 {
     if ($weblink->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($weblink->get_name());
             $contribution->set_fixing_url(WebUrlBuilder::edit($id)->relative());
             $contribution->set_poster_id(AppContext::get_current_user()->get_id());
             $contribution->set_module('web');
             $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(WebService::get_categories_manager()->get_heritated_authorizations($weblink->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('web', $id);
         if (count($corresponding_contributions) > 0) {
             $weblink_contribution = $corresponding_contributions[0];
             $weblink_contribution->set_status(Event::EVENT_STATUS_PROCESSED);
             ContributionService::save_contribution($weblink_contribution);
         }
     }
     $weblink->set_id($id);
 }
Esempio n. 3
0
 /**
  * @desc Update the number of views of a link.
  * @param string[] $weblink : WebLink to update
  */
 public static function update_number_views(WebLink $weblink)
 {
     self::$db_querier->update(WebSetup::$web_table, array('number_views' => $weblink->get_number_views()), 'WHERE id=:id', array('id' => $weblink->get_id()));
 }