private function build_table()
    {
        $table_model = new SQLHTMLTableModel(DownloadSetup::$download_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['download.management']);
        $results = array();
        $result = $table_model->get_sql_results('download
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
			LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id', array('*', 'download.id'));
        foreach ($result as $row) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $category = $downloadfile->get_category();
            $user = $downloadfile->get_author_user();
            $edit_link = new LinkHTMLElement(DownloadUrlBuilder::edit($downloadfile->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(DownloadUrlBuilder::delete($downloadfile->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(DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name()), $downloadfile->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($downloadfile->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($downloadfile->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 build_view($group_id)
    {
        if (!empty($group_id)) {
            $group = $this->groups_cache->get_group($group_id);
            $this->view->put_all(array('C_ADMIN' => AppContext::get_current_user()->check_level(User::ADMIN_LEVEL), 'U_ADMIN_GROUPS' => TPL_PATH_TO_ROOT . '/admin/admin_groups.php?id=' . $group_id, 'GROUP_NAME' => $group['name']));
        } else {
            $this->view->put_all(array('GROUP_NAME' => $this->lang['groups']));
        }
        $user_accounts_config = UserAccountsConfig::load();
        $number_member = 0;
        foreach ($this->get_members_group($group_id) as $user_id) {
            if (!empty($user_id)) {
                $user = PersistenceContext::get_querier()->select('SELECT 
					member.display_name, member.level, member.groups, member.warning_percentage, member.delay_banned, ext_field.user_avatar
					FROM ' . DB_TABLE_MEMBER . ' member
					LEFT JOIN ' . DB_TABLE_MEMBER_EXTENDED_FIELDS . ' ext_field ON ext_field.user_id = member.user_id
					WHERE member.user_id = :user_id
				', array('user_id' => $user_id))->fetch();
                if (!empty($user)) {
                    //Avatar
                    $user_avatar = !empty($user['user_avatar']) ? Url::to_rel($user['user_avatar']) : ($user_accounts_config->is_default_avatar_enabled() ? Url::to_rel('/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name()) : '');
                    $group_color = User::get_group_color($user['groups'], $user['level']);
                    $this->view->assign_block_vars('members_list', array('C_AVATAR' => $user['user_avatar'] || $user_accounts_config->is_default_avatar_enabled(), 'C_GROUP_COLOR' => !empty($group_color), 'PSEUDO' => $user['display_name'], 'LEVEL' => $user['warning_percentage'] < '100' || time() - $user['delay_banned'] < 0 ? UserService::get_level_lang($user['level']) : $this->lang['banned'], 'LEVEL_CLASS' => UserService::get_level_class($user['level']), 'GROUP_COLOR' => $group_color, 'U_PROFILE' => UserUrlBuilder::profile($user_id)->rel(), 'U_AVATAR' => $user_avatar));
                    $number_member++;
                }
            }
        }
        $this->view->put_all(array('C_NOT_MEMBERS' => $number_member == 0, 'SELECT_GROUP' => $this->build_form($group_id)->display()));
    }
 private function build_form($user_id)
 {
     $form = new HTMLForm('member-view-profile', '', false);
     $fieldset = new FormFieldsetHTML('profile', $this->lang['profile']);
     $form->add_fieldset($fieldset);
     if (AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $link_edit = '<a href="' . UserUrlBuilder::edit_profile($user_id)->rel() . '" title="' . $this->lang['profile.edit'] . '" class="fa fa-edit"></a>';
         $fieldset->add_field(new FormFieldFree('profile_edit', $this->lang['profile.edit'], $link_edit));
     }
     $fieldset->add_field(new FormFieldFree('display_name', $this->lang['display_name'], $this->user_infos['display_name']));
     $fieldset->add_field(new FormFieldFree('level', $this->lang['level'], '<a class="' . UserService::get_level_class($this->user_infos['level']) . '">' . $this->get_level_lang() . '</a>'));
     $fieldset->add_field(new FormFieldFree('groups', $this->lang['groups'], $this->build_groups($this->user_infos['groups'])));
     $registration_date = new Date($this->user_infos['registration_date']);
     $fieldset->add_field(new FormFieldFree('registered_on', $this->lang['registration_date'], $registration_date ? $registration_date->format(Date::FORMAT_DAY_MONTH_YEAR) : ''));
     $fieldset->add_field(new FormFieldFree('nbr_msg', $this->lang['number-messages'], $this->user_infos['posted_msg'] . '<br>' . '<a href="' . UserUrlBuilder::messages($user_id)->rel() . '">' . $this->lang['messages'] . '</a>'));
     $last_connection_date = !empty($this->user_infos['last_connection_date']) ? Date::to_format($this->user_infos['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main');
     $fieldset->add_field(new FormFieldFree('last_connect', $this->lang['last_connection'], $last_connection_date));
     if (AppContext::get_current_user()->check_auth(UserAccountsConfig::load()->get_auth_read_members(), UserAccountsConfig::AUTH_READ_MEMBERS_BIT) && $this->user_infos['show_email']) {
         $link_email = '<a href="mailto:' . $this->user_infos['email'] . '" class="basic-button smaller">Mail</a>';
         $fieldset->add_field(new FormFieldFree('email', $this->lang['email'], $link_email));
     }
     if (!$this->same_user_view_profile($user_id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         $link_mp = '<a href="' . UserUrlBuilder::personnal_message($user_id)->rel() . '" class="basic-button smaller">MP</a>';
         $fieldset->add_field(new FormFieldFree('private_message', $this->lang['private_message'], $link_mp));
     }
     MemberExtendedFieldsService::display_profile_fields($form, $user_id);
     $this->form = $form;
 }
    private function build_table()
    {
        $table_model = new SQLHTMLTableModel(CalendarSetup::$calendar_events_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('date', 'date-common'), 'start_date'), new HTMLTableColumn($this->lang['calendar.titles.repetition']), new HTMLTableColumn(LangLoader::get_message('status.approved', 'common'), 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('start_date', HTMLTableSortingRule::DESC));
        $table = new HTMLTable($table_model);
        $table_model->set_caption($this->lang['calendar.config.events.management']);
        $table_model->add_permanent_filter('parent_id = 0');
        $results = array();
        $result = $table_model->get_sql_results('event
			LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id');
        foreach ($result as $row) {
            $event = new CalendarEvent();
            $event->set_properties($row);
            $category = $event->get_content()->get_category();
            $user = $event->get_content()->get_author_user();
            $edit_link = new LinkHTMLElement(CalendarUrlBuilder::edit_event(!$event->get_parent_id() ? $event->get_id() : $event->get_parent_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(CalendarUrlBuilder::delete_event($event->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => !$event->belongs_to_a_serie() ? '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();
            $br = new BrHTMLElement();
            $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()), $event->get_content()->get_title()), 'left'), new HTMLTableRowCell(new SpanHTMLElement($category->get_name(), array('style' => $category->get_id() != Category::ROOT_CATEGORY && $category->get_color() ? 'color:' . $category->get_color() : ''))), new HTMLTableRowCell($author), new HTMLTableRowCell(LangLoader::get_message('from_date', 'main') . ' ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('to_date', 'main') . ' ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($event->belongs_to_a_serie() ? $this->lang['calendar.labels.repeat.' . $event->get_content()->get_repeat_type()] . ' - ' . $event->get_content()->get_repeat_number() . ' ' . $this->lang['calendar.labels.repeat_times'] : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($event->get_content()->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 build_view($request)
 {
     $config = BugtrackerConfig::load();
     $versions = $config->get_versions();
     $display_versions = count($versions);
     $stats_cache = BugtrackerStatsCache::load();
     $bugs_number_per_version = $stats_cache->get_bugs_number_per_version_list();
     $top_posters = $stats_cache->get_top_posters_list();
     $this->view->put_all(array('C_BUGS' => $stats_cache->get_bugs_number('total'), 'C_FIXED_BUGS' => !empty($bugs_number_per_version), 'C_POSTERS' => !empty($top_posters), 'C_DISPLAY_VERSIONS' => $display_versions, 'C_DISPLAY_TOP_POSTERS' => $config->are_stats_top_posters_enabled(), 'C_ROADMAP_ENABLED' => $config->is_roadmap_enabled()));
     foreach ($stats_cache->get_bugs_number_list() as $status => $bugs_number) {
         if ($status != 'total') {
             $this->view->assign_block_vars('status', array('NAME' => $this->lang['status.' . $status], 'NUMBER' => $bugs_number));
         }
     }
     foreach ($bugs_number_per_version as $version_id => $bugs_number) {
         $release_date = !empty($versions[$version_id]['release_date']) && is_numeric($versions[$version_id]['release_date']) ? new Date($versions[$version_id]['release_date'], Timezone::SERVER_TIMEZONE) : null;
         $this->view->assign_block_vars('fixed_version', array('NAME' => stripslashes($versions[$version_id]['name']), 'RELEASE_DATE' => !empty($release_date) ? $release_date->format(Date::FORMAT_DAY_MONTH_YEAR) : $this->lang['notice.not_defined_e_date'], 'LINK_VERSION_ROADMAP' => BugtrackerUrlBuilder::roadmap($version_id, Url::encode_rewrite($versions[$version_id]['name']))->rel(), 'NUMBER' => $bugs_number['all']));
     }
     foreach ($top_posters as $id => $poster) {
         if (isset($poster['user'])) {
             $author_group_color = User::get_group_color($poster['user']->get_groups(), $poster['user']->get_level(), true);
             $this->view->assign_block_vars('top_poster', array('C_AUTHOR_GROUP_COLOR' => !empty($author_group_color), 'ID' => $id, 'AUTHOR' => $poster['user']->get_display_name(), 'AUTHOR_LEVEL_CLASS' => UserService::get_level_class($poster['user']->get_level()), 'AUTHOR_GROUP_COLOR' => $author_group_color, 'LINK_AUTHOR_PROFILE' => UserUrlBuilder::profile($poster['user']->get_id())->rel(), 'USER_BUGS' => $poster['bugs_number']));
         }
     }
     return $this->view;
 }
 public function execute(HTTPRequestCustom $request)
 {
     $lang = LangLoader::get('common');
     $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
     $number_admins = UserService::count_admin_members();
     $suggestions = array();
     try {
         $result = PersistenceContext::get_querier()->select("SELECT user_id, display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
         while ($row = $result->fetch()) {
             $user_group_color = User::get_group_color($row['groups'], $row['level']);
             $suggestion = '';
             if ($is_admin) {
                 $edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($row['user_id']), '', array('title' => $lang['edit']), 'fa fa-edit');
                 if ($row['level'] != User::ADMIN_LEVEL || $row['level'] == User::ADMIN_LEVEL && $number_admins > 1) {
                     $delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($row['user_id']), '', array('title' => $lang['delete'], 'data-confirmation' => 'delete-element'), 'fa fa-delete');
                 } else {
                     $delete_link = new LinkHTMLElement('', '', array('title' => $lang['delete'], 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
                 }
                 $suggestion .= $edit_link->display() . '&nbsp;' . $delete_link->display() . '&nbsp;';
             }
             $profile_link = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id'])->rel(), $row['display_name'], array('style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
             $suggestion .= $profile_link->display();
             $suggestions[] = $suggestion;
         }
         $result->dispose();
     } catch (Exception $e) {
     }
     return new JSONResponse(array('suggestions' => $suggestions));
 }
 public function get_menu_content()
 {
     global $LANG;
     //Chargement de la langue du module.
     load_module_lang('stats');
     $tpl = new FileTemplate('stats/stats_mini.tpl');
     $stats_cache = StatsCache::load();
     $l_member_registered = $stats_cache->get_stats_properties('nbr_members') > 1 ? $LANG['member_registered_s'] : $LANG['member_registered'];
     $group_color = User::get_group_color($stats_cache->get_stats_properties('last_member_groups'), $stats_cache->get_stats_properties('last_member_level'));
     $tpl->put_all(array('L_MORE_STAT' => $LANG['more_stats'], 'L_USER_REGISTERED' => sprintf($l_member_registered, $stats_cache->get_stats_properties('nbr_members')), 'L_LAST_REGISTERED_USER' => $LANG['last_member'], 'U_LINK_LAST_USER' => '<a href="' . UserUrlBuilder::profile($stats_cache->get_stats_properties('last_member_id'))->rel() . '" class="' . UserService::get_level_class($stats_cache->get_stats_properties('last_member_level')) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $stats_cache->get_stats_properties('last_member_login') . '</a>'));
     return $tpl->render();
 }
 public function display($tpl = false)
 {
     global $LANG;
     if (!Url::is_current_url('/user/login')) {
         $tpl = new FileTemplate('connect/connect_mini.tpl');
         $user = AppContext::get_current_user();
         MenuService::assign_positions_conditions($tpl, $this->get_block());
         if ($user->check_level(User::MEMBER_LEVEL)) {
             $unread_contributions = UnreadContributionsCache::load();
             //Vaut 0 si l'utilisateur n'a aucune contribution. Est > 0 si on connait le nombre de contributions
             //Vaut -1 si l'utilisateur a au moins une contribution (mais on ne sait pas combien à cause des recoupements entre les groupes)
             $contribution_number = 0;
             if ($user->check_level(User::ADMIN_LEVEL)) {
                 $contribution_number = $unread_contributions->get_admin_unread_contributions_number();
             } elseif ($user->check_level(User::MODERATOR_LEVEL)) {
                 if ($unread_contributions->have_moderators_unread_contributions()) {
                     $contribution_number = -1;
                 }
             } else {
                 if ($unread_contributions->have_members_unread_contributions()) {
                     $contribution_number = -1;
                 } else {
                     if ($unread_contributions->has_user_unread_contributions($user->get_id())) {
                         $contribution_number = -1;
                     } else {
                         foreach ($user->get_groups() as $group_id) {
                             if ($unread_contributions->has_group_unread_contributions($group_id)) {
                                 $contribution_number = -1;
                                 break;
                             }
                         }
                     }
                 }
             }
             $user_accounts_config = UserAccountsConfig::load();
             $user_avatar = AppContext::get_session()->get_cached_data('user_avatar');
             if (empty($user_avatar)) {
                 $user_avatar = '/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name();
             }
             $total_alert = $user->get_unread_pm() + $contribution_number + ($user->check_level(User::ADMIN_LEVEL) ? AdministratorAlertService::get_number_unread_alerts() : 0);
             $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
             $tpl->put_all(array('C_ADMIN_AUTH' => $user->check_level(User::ADMIN_LEVEL), 'C_MODERATOR_AUTH' => $user->check_level(User::MODERATOR_LEVEL), 'C_UNREAD_CONTRIBUTION' => $contribution_number != 0, 'C_KNOWN_NUMBER_OF_UNREAD_CONTRIBUTION' => $contribution_number > 0, 'C_UNREAD_ALERT' => (bool) AdministratorAlertService::get_number_unread_alerts(), 'C_HAS_PM' => $user->get_unread_pm() > 0, 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'NUMBER_UNREAD_CONTRIBUTIONS' => $contribution_number, 'NUMBER_UNREAD_ALERTS' => AdministratorAlertService::get_number_unread_alerts(), 'NUMBER_PM' => $user->get_unread_pm(), 'NUMBER_TOTAL_ALERT' => $total_alert, 'PSEUDO' => $user->get_display_name(), 'USER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'USER_GROUP_COLOR' => $user_group_color, 'U_USER_PROFILE' => UserUrlBuilder::profile($user->get_id())->rel(), 'U_USER_PM' => UserUrlBuilder::personnal_message($user->get_id())->rel(), 'U_AVATAR_IMG' => Url::to_rel($user_avatar), 'L_NBR_PM' => $user->get_unread_pm() > 0 ? $user->get_unread_pm() . ' ' . ($user->get_unread_pm() > 1 ? $LANG['message_s'] : $LANG['message']) : $LANG['private_messaging'], 'L_PROFIL' => LangLoader::get_message('profile', 'user-common'), 'L_ADMIN_PANEL' => $LANG['admin_panel'], 'L_MODO_PANEL' => $LANG['modo_panel'], 'L_PRIVATE_PROFIL' => $LANG['my_private_profile'], 'L_DISCONNECT' => LangLoader::get_message('disconnect', 'user-common'), 'L_CONTRIBUTION_PANEL' => $LANG['contribution_panel']));
         } else {
             $authentication_config = AuthenticationConfig::load();
             $tpl->put_all(array('C_USER_NOTCONNECTED' => true, 'C_USER_REGISTER' => UserAccountsConfig::load()->is_registration_enabled(), 'C_FB_AUTH_ENABLED' => $authentication_config->is_fb_auth_available(), 'C_GOOGLE_AUTH_ENABLED' => $authentication_config->is_google_auth_available(), 'L_REQUIRE_PSEUDO' => $LANG['require_pseudo'], 'L_REQUIRE_PASSWORD' => $LANG['require_password'], 'L_CONNECT' => LangLoader::get_message('connection', 'user-common'), 'L_PSEUDO' => LangLoader::get_message('login', 'user-common'), 'L_PASSWORD' => LangLoader::get_message('password', 'user-common'), 'L_AUTOCONNECT' => LangLoader::get_message('autoconnect', 'user-common'), 'L_FORGOT_PASS' => LangLoader::get_message('forget-password', 'user-common'), 'L_REGISTER' => LangLoader::get_message('register', 'user-common'), 'U_CONNECT' => UserUrlBuilder::connect()->rel(), 'SITE_REWRITED_SCRIPT' => substr(REWRITED_SCRIPT, strlen(GeneralConfig::load()->get_site_path()))));
         }
         return $tpl->render();
     }
     return '';
 }
Esempio n. 9
0
function forum_list_user_online($condition)
{
    list($total_admin, $total_modo, $total_member, $total_visit, $users_list) = array(0, 0, 0, 0, '');
    $result = PersistenceContext::get_querier()->select("SELECT s.user_id, m.level, m.display_name, m.groups\n\tFROM " . DB_TABLE_SESSIONS . " s \n\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = s.user_id \n\tWHERE s.timestamp > :timestamp " . $condition . "\n\tORDER BY s.timestamp DESC", array('timestamp' => time() - SessionsConfig::load()->get_active_session_duration()));
    while ($row = $result->fetch()) {
        $group_color = User::get_group_color($row['groups'], $row['level']);
        switch ($row['level']) {
            case -1:
            case '':
                $total_visit++;
                break;
            case 0:
                $total_member++;
                break;
            case 1:
                $total_modo++;
                break;
            case 2:
                $total_admin++;
                break;
        }
        $coma = !empty($users_list) && $row['level'] != -1 ? ', ' : '';
        $users_list .= !empty($row['display_name']) && $row['level'] != -1 ? $coma . '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['display_name'] . '</a>' : '';
    }
    $result->dispose();
    $total = $total_admin + $total_modo + $total_member + $total_visit;
    if (empty($total)) {
        $current_user = AppContext::get_current_user();
        if ($current_user->get_level() != User::VISITOR_LEVEL) {
            $group_color = User::get_group_color($current_user->get_groups(), $current_user->get_level(), true);
            switch ($current_user->get_level()) {
                case 0:
                    $total_member++;
                    break;
                case 1:
                    $total_modo++;
                    break;
                case 2:
                    $total_admin++;
                    break;
            }
            $users_list .= '<a href="' . UserUrlBuilder::profile($current_user->get_id())->rel() . '" class="' . UserService::get_level_class($current_user->get_level()) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $current_user->get_display_name() . '</a>';
        } else {
            $total_visit++;
        }
        $total++;
    }
    return array($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total);
}
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('guestbook/GuestbookModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'guestbook'));
     $tpl->put('U_GUESTBOOK', GuestbookUrlBuilder::home()->rel());
     $guestbook_cache = GuestbookMessagesCache::load();
     $random_message = $guestbook_cache->get_message(array_rand($guestbook_cache->get_messages()));
     if ($random_message !== null) {
         $user_group_color = User::get_group_color($random_message['groups'], $random_message['level']);
         $tpl->put_all(array('C_ANY_MESSAGE_GUESTBOOK' => true, 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'C_MORE_CONTENTS' => strlen($random_message['contents']) >= 200, 'C_VISITOR' => empty($random_message['user_id']), 'CONTENTS' => $random_message['contents'], 'SHORT_CONTENTS' => nl2br(TextHelper::substr_html($random_message['contents'], 0, 200)), 'USER_PSEUDO' => $random_message['login'], 'USER_LEVEL_CLASS' => UserService::get_level_class($random_message['level']), 'USER_GROUP_COLOR' => $user_group_color, 'U_MESSAGE' => GuestbookUrlBuilder::home($random_message['page'], $random_message['id'])->rel(), 'U_PROFILE' => UserUrlBuilder::profile($random_message['user_id'])->rel()));
     }
     return $tpl->render();
 }
 private function build_table()
 {
     $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['messages'], 'posted_msg'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['private_message'])), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC));
     $table = new HTMLTable($table_model);
     $results = array();
     $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id');
     foreach ($result as $row) {
         $posted_msg = !empty($row['posted_msg']) ? $row['posted_msg'] : '0';
         $group_color = User::get_group_color($row['groups'], $row['level']);
         $author = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id']), $row['display_name'], !empty($group_color) ? array('style' => 'color: ' . $group_color) : array(), UserService::get_level_class($row['level']));
         $results[] = new HTMLTableRow(array(new HTMLTableRowCell($author), new HTMLTableRowCell($row['show_email'] == 1 ? new LinkHTMLElement('mailto:' . $row['email'], $this->lang['email'], array(), 'basic-button smaller') : ''), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell($posted_msg), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::personnal_message($row['user_id']), 'PM', array(), 'basic-button smaller'))));
     }
     $table->set_rows($table_model->get_number_of_matching_rows(), $results);
     $this->view->put('table', $table->display());
 }
 public function execute(HTTPRequestCustom $request)
 {
     $suggestions = array();
     try {
         $result = PersistenceContext::get_querier()->select("SELECT display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
         while ($row = $result->fetch()) {
             $user_group_color = User::get_group_color($row['groups'], $row['level']);
             $profile_link = new LinkHTMLElement('', $row['display_name'], array('onclick' => 'return false;', 'style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
             $suggestions[] = $profile_link->display();
         }
         $result->dispose();
     } catch (Exception $e) {
     }
     return new JSONResponse(array('suggestions' => $suggestions));
 }
 private function build_view($request)
 {
     //Configuration load
     $config = BugtrackerConfig::load();
     $types = $config->get_types();
     $categories = $config->get_categories();
     $severities = $config->get_severities();
     $priorities = $config->get_priorities();
     $versions = $config->get_versions_detected();
     $user_assigned = $this->bug->get_assigned_to_id() && UserService::user_exists("WHERE user_id=:user_id", array('user_id' => $this->bug->get_assigned_to_id())) ? UserService::get_user($this->bug->get_assigned_to_id()) : '';
     $user_assigned_group_color = $user_assigned ? User::get_group_color($user_assigned->get_groups(), $user_assigned->get_level(), true) : '';
     $this->view->put_all($this->bug->get_array_tpl_vars());
     $this->view->put_all(array('C_TYPES' => $types, 'C_CATEGORIES' => $categories, 'C_SEVERITIES' => $severities, 'C_PRIORITIES' => $priorities, 'C_VERSIONS' => $versions, 'C_EDIT_BUG' => BugtrackerAuthorizationsService::check_authorizations()->moderation() || $this->current_user->get_id() == $this->bug->get_assigned_to_id() || $this->current_user->get_id() == $this->bug->get_author_user()->get_id() && $this->bug->get_author_user()->get_id() != User::VISITOR_LEVEL, 'C_DELETE_BUG' => BugtrackerAuthorizationsService::check_authorizations()->moderation(), 'C_CHANGE_STATUS' => BugtrackerAuthorizationsService::check_authorizations()->moderation() || $this->current_user->get_id() == $this->bug->get_assigned_to_id(), 'C_USER_ASSIGNED_GROUP_COLOR' => !empty($user_assigned_group_color), 'C_USER_ASSIGNED' => $user_assigned, 'USER_ASSIGNED' => $user_assigned ? $user_assigned->get_display_name() : '', 'USER_ASSIGNED_LEVEL_CLASS' => $user_assigned ? UserService::get_level_class($user_assigned->get_level()) : '', 'USER_ASSIGNED_GROUP_COLOR' => $user_assigned_group_color, 'U_CHANGE_STATUS' => BugtrackerUrlBuilder::change_status($this->bug->get_id())->rel(), 'U_EDIT' => BugtrackerUrlBuilder::edit($this->bug->get_id(), 'detail')->rel(), 'U_DELETE' => BugtrackerUrlBuilder::delete($this->bug->get_id(), 'unsolved')->rel()));
     $comments_topic = new BugtrackerCommentsTopic();
     $comments_topic->set_id_in_module($this->bug->get_id());
     $comments_topic->set_url(BugtrackerUrlBuilder::detail_comments($this->bug->get_id() . '-' . $this->bug->get_rewrited_title()));
     $this->view->put('COMMENTS', $comments_topic->display());
 }
 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());
 }
 public function get_menu_content()
 {
     $tpl = new FileTemplate('online/OnlineModuleMiniMenu.tpl');
     $lang = LangLoader::get('common', 'online');
     $tpl->add_lang($lang);
     $online_config = OnlineConfig::load();
     $condition = 'WHERE s.timestamp > :time ORDER BY ' . $online_config->get_display_order_request();
     $parameters = array('time' => time() - SessionsConfig::load()->get_active_session_duration());
     $users = OnlineService::get_online_users($condition, $parameters);
     foreach ($users as $user) {
         $this->incremente_level($user);
         if ($this->total_users <= $online_config->get_number_member_displayed()) {
             $group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
             if ($user->get_level() != User::VISITOR_LEVEL) {
                 $tpl->assign_block_vars('users', array('U_PROFILE' => UserUrlBuilder::profile($user->get_id())->rel(), 'PSEUDO' => TextHelper::wordwrap_html($user->get_display_name(), 19), 'LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'C_GROUP_COLOR' => !empty($group_color), 'GROUP_COLOR' => $group_color));
             }
         }
     }
     $main_lang = LangLoader::get('main');
     $tpl->put_all(array('C_MORE_USERS' => $this->total_users > $online_config->get_number_member_displayed(), 'L_VISITOR' => $this->number_visitor > 1 ? $main_lang['guest_s'] : $main_lang['guest'], 'L_MEMBER' => $this->number_member > 1 ? $main_lang['member_s'] : $main_lang['member'], 'L_MODO' => $this->number_moderator > 1 ? $main_lang['modo_s'] : $main_lang['modo'], 'L_ADMIN' => $this->number_administrator > 1 ? $main_lang['admin_s'] : $main_lang['admin'], 'L_USERS_ONLINE' => $this->total_users > 1 ? $lang['online_users'] : $lang['online_user'], 'L_TOTAL' => $main_lang['total'], 'TOTAL_USERS_CONNECTED' => $this->total_users, 'TOTAL_VISITOR_CONNECTED' => $this->number_visitor, 'TOTAL_MEMBER_CONNECTED' => $this->number_member, 'TOTAL_MODERATOR_CONNECTED' => $this->number_moderator, 'TOTAL_ADMINISTRATOR_CONNECTED' => $this->number_administrator));
     return $tpl->render();
 }
    public function build_view()
    {
        $active_sessions_start_time = time() - SessionsConfig::load()->get_active_session_duration();
        $number_users_online = OnlineService::get_number_users_connected('WHERE user_id <> -1 AND timestamp > :time', array('time' => $active_sessions_start_time));
        $pagination = $this->get_pagination($number_users_online);
        $users = OnlineService::get_online_users('WHERE s.user_id <> -1 AND s.timestamp > :time
		ORDER BY ' . $this->config->get_display_order_request() . '
		LIMIT :number_items_per_page OFFSET :display_from', array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from(), 'time' => $active_sessions_start_time));
        foreach ($users as $user) {
            if ($user->get_id() == AppContext::get_current_user()->get_id()) {
                $user->set_location_script(OnlineUrlBuilder::home()->rel());
                $user->set_location_title($this->lang['online']);
                $user->set_last_update(new Date());
            }
            $group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
            if ($user->get_level() != User::VISITOR_LEVEL) {
                $this->view->assign_block_vars('users', array('C_AVATAR' => $user->has_avatar(), 'C_GROUP_COLOR' => !empty($group_color), 'PSEUDO' => $user->get_display_name(), 'LEVEL' => UserService::get_level_lang($user->get_level()), 'LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'GROUP_COLOR' => $group_color, 'TITLE_LOCATION' => $user->get_location_title(), 'LAST_UPDATE' => $user->get_last_update()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'U_PROFILE' => UserUrlBuilder::profile($user->get_id())->rel(), 'U_LOCATION' => $user->get_location_script(), 'U_AVATAR' => $user->get_avatar()));
            }
        }
        $this->view->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'C_USERS' => count($users), 'PAGINATION' => $pagination->display()));
        return $this->view;
    }
    private function build_table()
    {
        $table_model = new SQLHTMLTableModel(ArticlesSetup::$articles_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), 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'), 'date_created'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'published'), new HTMLTableColumn('')), new HTMLTableSortingRule('date_created', HTMLTableSortingRule::DESC));
        $table = new HTMLTable($table_model);
        $table_model->set_caption($this->lang['articles_management']);
        $results = array();
        $result = $table_model->get_sql_results('articles
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = articles.id AND notes.module_name = \'articles\'
			LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = articles.id AND note.module_name = \'articles\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = articles.author_user_id', array('*', 'articles.id'));
        foreach ($result as $row) {
            $article = new Article();
            $article->set_properties($row);
            $category = $article->get_category();
            $user = $article->get_author_user();
            $edit_link = new LinkHTMLElement(ArticlesUrlBuilder::edit_article($article->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(ArticlesUrlBuilder::delete_article($article->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();
            $br = new BrHTMLElement();
            $dates = '';
            if ($article->get_publishing_start_date() != null && $article->get_publishing_end_date() != null) {
                $dates = LangLoader::get_message('form.date.start', 'common') . ' ' . $article->get_publishing_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('form.date.end', 'common') . ' ' . $article->get_publishing_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE);
            } else {
                if ($article->get_publishing_start_date() != null) {
                    $dates = $article->get_publishing_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE);
                } else {
                    if ($article->get_publishing_end_date() != null) {
                        $dates = LangLoader::get_message('until', 'main') . ' ' . $article->get_publishing_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE);
                    }
                }
            }
            $start_and_end_dates = new SpanHTMLElement($dates, array(), 'smaller');
            $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(ArticlesUrlBuilder::display_article($category->get_id(), $category->get_rewrited_name(), $article->get_id(), $article->get_rewrited_title()), $article->get_title()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(ArticlesUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($article->get_date_created()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($article->get_status() . $br->display() . ($dates ? $start_and_end_dates->display() : '')), 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 build_table()
 {
     $number_admins = UserService::count_admin_members();
     $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['level'], 'level'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['approbation'], 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC));
     $table = new HTMLTable($table_model);
     $table_model->set_caption(LangLoader::get_message('members.members-management', 'admin-user-common'));
     $results = array();
     $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id');
     foreach ($result as $row) {
         $user = new User();
         $user->set_properties($row);
         $edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($user->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
         if ($user->get_level() != User::ADMIN_LEVEL || $user->get_level() == User::ADMIN_LEVEL && $number_admins > 1) {
             $delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($user->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
         } else {
             $delete_link = new LinkHTMLElement('', '', array('title' => LangLoader::get_message('delete', 'common'), 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
         }
         $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
         $results[] = new HTMLTableRow(array(new HTMLTableRowCell(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()))), new HTMLTableRowCell(UserService::get_level_lang($user->get_level())), new HTMLTableRowCell(new LinkHTMLElement('mailto:' . $user->get_email(), $this->lang['email'], array(), 'basic-button smaller')), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell($row['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_all(array('FORM' => $this->build_form()->display(), 'table' => $table->display()));
 }
Esempio n. 19
0
         $last_page_rewrite = $last_page > 1 ? '-' . $last_page : '';
         $last_page = $last_page > 1 ? 'pt=' . $last_page . '&amp;' : '';
     }
     //On encode l'url pour un éventuel rewriting, c'est une opération assez gourmande
     $rewrited_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($row['title']) : '';
     //Affichage du dernier message posté.
     $last_group_color = User::get_group_color($row['last_user_groups'], $row['last_user_level']);
     $last_msg = '<a href="topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . $rewrited_title . '.php') . '#m' . $last_msg_id . '" title=""><i class="fa fa-hand-o-right"></i></a>' . ' ' . $LANG['on'] . ' ' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br /> ' . $LANG['by'] . ' ' . (!empty($row['last_login']) ? '<a class="small ' . UserService::get_level_class($row['last_user_level']) . '"' . (!empty($last_group_color) ? ' style="color:' . $last_group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '">' . TextHelper::wordwrap_html($row['last_login'], 13) . '</a>' : '<em>' . $LANG['guest'] . '</em>');
     //Ancre ajoutée aux messages non lus.
     $new_ancre = '<a href="topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . $rewrited_title . '.php') . '#m' . $last_msg_id . '" title=""><i class="fa fa-hand-o-right"></i></a>';
     //On crée une pagination (si activé) si le nombre de topics est trop important.
     $page = AppContext::get_request()->get_getint('pt', 1);
     $topic_pagination = new ModulePagination($page, $row['nbr_msg'], $config->get_number_messages_per_page(), Pagination::LIGHT_PAGINATION);
     $topic_pagination->set_url(new Url('/forum/topic.php?id=' . $row['id'] . '&amp;pt=%d'));
     $group_color = User::get_group_color($row['groups'], $row['user_level']);
     $tpl->assign_block_vars('topics', array('C_PAGINATION' => $topic_pagination->has_several_pages(), 'C_IMG_POLL' => !empty($row['question']), 'C_IMG_TRACK' => !empty($row['idtrack']), 'C_DISPLAY_MSG' => $config->is_message_before_topic_title_displayed() && $config->is_message_before_topic_title_icon_displayed() && $row['display_msg'], 'C_HOT_TOPIC' => $row['type'] == '0' && $row['status'] != '0' && $row['nbr_msg'] > $config->get_number_messages_per_page(), 'C_BLINK' => $blink, 'IMG_ANNOUNCE' => $img_announce, 'ANCRE' => $new_ancre, 'TYPE' => $type[$row['type']], 'TITLE' => stripslashes($row['title']), 'AUTHOR' => !empty($row['login']) ? '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : '<em>' . $LANG['guest'] . '</em>', 'DESC' => $row['subtitle'], 'PAGINATION' => $topic_pagination->display(), 'MSG' => $row['nbr_msg'] - 1, 'VUS' => $row['nbr_views'], 'U_TOPIC_VARS' => url('.php?id=' . $row['id'], '-' . $row['id'] . $rewrited_title . '.php'), 'U_LAST_MSG' => $last_msg, 'L_DISPLAY_MSG' => $config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : ''));
 }
 $result->dispose();
 //Le membre a déjà lu tous les messages.
 if ($nbr_topics == 0) {
     $tpl->put_all(array('C_NO_TOPICS' => true, 'L_NO_TOPICS' => '0 ' . $LANG['no_last_read']));
 }
 //Listes les utilisateurs en lignes.
 list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online("AND s.location_script LIKE '%" . "/forum/lastread.php%'");
 //Liste des catégories.
 $search_category_children_options = new SearchCategoryChildrensOptions();
 $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
 $categories_tree = ForumService::get_categories_manager()->get_select_categories_form_field('cats', '', Category::ROOT_CATEGORY, $search_category_children_options);
 $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
 $method->setAccessible(true);
 $categories_tree_options = $method->invoke($categories_tree);
    private function build_view()
    {
        global $LANG, $Bread_crumb;
        load_module_lang('gallery');
        $g_idpics = retrieve(GET, 'id', 0);
        $g_views = retrieve(GET, 'views', false);
        $g_notes = retrieve(GET, 'notes', false);
        $g_sort = retrieve(GET, 'sort', '');
        $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : '';
        //Récupération du mode d'ordonnement.
        if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) {
            $g_type = $array_match[1];
            $g_mode = $array_match[2];
        } else {
            list($g_type, $g_mode) = array('date', 'desc');
        }
        $comments_topic = new GalleryCommentsTopic();
        $config = GalleryConfig::load();
        $category = $this->get_category();
        $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id());
        $authorized_categories = GalleryService::get_authorized_categories($category->get_id());
        $Gallery = new Gallery();
        $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id()));
        $total_cat = count($categories);
        //On crée une pagination si le nombre de catégories est trop important.
        $page = AppContext::get_request()->get_getint('p', 1);
        $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page());
        $pagination->set_url(new Url('/gallery/gallery.php?p=%d&amp;cat=' . $category->get_id() . '&amp;id=' . $g_idpics . '&amp;' . $g_sort));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        //Colonnes des catégories.
        $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $column_width_cats = floor(100 / $nbr_column_cats);
        //Colonnes des images.
        $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics;
        $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1;
        $column_width_pics = floor(100 / $nbr_column_pics);
        $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
        $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation();
        $module_data_path = $this->tpl->get_pictures_data_path();
        $rewrite_title = Url::encode_rewrite($category->get_name());
        ##### Catégorie disponibles #####
        $nbr_cat_displayed = 0;
        if ($total_cat > 0 && empty($g_idpics)) {
            $this->tpl->put('C_GALLERY_CATS', true);
            $j = 0;
            $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*,
			(SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . '
				WHERE idcat IN (
					@id_cat,
					(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), 
					(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents
					INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent
					WHERE parents.id_parent = @id_cat)
				)
				AND aprob = 1
			) AS nbr_pics
			FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats
			WHERE id_parent = :id_category
			AND id IN :authorized_categories
			ORDER BY id_parent, c_order
			LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
            while ($row = $result->fetch()) {
                $category_image = new Url($row['image']);
                $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name'])));
                $nbr_cat_displayed++;
            }
            $result->dispose();
        }
        $category_description = FormatingHelper::second_parse($category->get_description());
        $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s']));
        ##### Affichage des photos #####
        if ($nbr_pics > 0) {
            switch ($g_type) {
                case 'name':
                    $sort_type = 'g.name';
                    break;
                case 'date':
                    $sort_type = 'g.timestamp';
                    break;
                case 'views':
                    $sort_type = 'g.views';
                    break;
                case 'notes':
                    $sort_type = 'notes.average_notes';
                    break;
                case 'com':
                    $sort_type = 'com.number_comments';
                    break;
                default:
                    $sort_type = 'g.timestamp';
            }
            switch ($g_mode) {
                case 'desc':
                    $sort_mode = 'DESC';
                    break;
                case 'asc':
                    $sort_mode = 'ASC';
                    break;
                default:
                    $sort_mode = 'DESC';
            }
            $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode;
            if ($g_views) {
                $g_sql_sort = ' ORDER BY g.views DESC';
            } elseif ($g_notes) {
                $g_sql_sort = ' ORDER BY notes.average_notes DESC';
            }
            $this->tpl->put('C_GALLERY_PICS', true);
            //Affichage d'une photo demandée.
            if (!empty($g_idpics)) {
                $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics));
                if (!empty($info_pics['id'])) {
                    $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&amp;id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php'));
                    //Affichage miniatures.
                    $id_previous = 0;
                    $id_next = 0;
                    $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2);
                    //Nombres de photos de chaque côté de la miniature de la photo affichée.
                    $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before);
                    list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after);
                    $array_pics = array();
                    $array_js = 'var array_pics = new Array();';
                    $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id()));
                    while ($row = $result->fetch()) {
                        //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                        if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                            $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                        }
                        //Redimensionnement + création miniature
                        //Affichage de la liste des miniatures sous l'image.
                        $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>';
                        if ($row['id'] == $g_idpics) {
                            $reach_pics_pos = true;
                            $pos_pics = $i;
                        } else {
                            if (!$reach_pics_pos) {
                                $thumbnails_before++;
                                $id_previous = $row['id'];
                            } else {
                                $thumbnails_after++;
                                if (empty($id_next)) {
                                    $id_next = $row['id'];
                                }
                            }
                        }
                        $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n";
                        $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n";
                        $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n";
                        $i++;
                    }
                    $result->dispose();
                    $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                    if ($activ_note) {
                        //Affichage notation.
                        $notation = new Notation();
                        $notation->set_module_name('gallery');
                        $notation->set_id_in_module($info_pics['id']);
                        $notation->set_notation_scale($config->get_notation_scale());
                        $notation->set_number_notes($info_pics['number_notes']);
                        $notation->set_average_notes($info_pics['average_notes']);
                        $notation->set_user_already_noted(!empty($info_pics['note']));
                    }
                    if ($thumbnails_before < $nbr_pics_display_before) {
                        $end_thumbnails += $nbr_pics_display_before - $thumbnails_before;
                    }
                    if ($thumbnails_after < $nbr_pics_display_after) {
                        $start_thumbnails += $nbr_pics_display_after - $thumbnails_after;
                    }
                    $html_protected_name = $info_pics['name'];
                    $comments_topic->set_id_in_module($info_pics['id']);
                    $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0'));
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']);
                    //Affichage de l'image et de ses informations.
                    $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&amp;cat=' . $info_pics['idcat']));
                    //Affichage de la liste des miniatures sous l'image.
                    $i = 0;
                    foreach ($array_pics as $pics) {
                        if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) {
                            $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics));
                        }
                        $i++;
                    }
                    //Commentaires
                    if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) {
                        $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render()));
                    }
                }
            } else {
                $sort = retrieve(GET, 'sort', '');
                //On crée une pagination si le nombre de photos est trop important.
                $page = AppContext::get_request()->get_getint('pp', 1);
                $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page());
                $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&amp;sort=' . $sort : '') . '&amp;cat=' . $category->get_id()));
                if ($pagination->current_page_is_empty() && $page > 1) {
                    $error_controller = PHPBoostErrors::unexisting_page();
                    DispatchManager::redirect($error_controller);
                }
                $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views']));
                $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                $j = 0;
                $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
                while ($row = $result->fetch()) {
                    //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                    if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                        $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                    }
                    //Redimensionnement + création miniature
                    $onclick = '';
                    //Affichage de l'image en grand.
                    if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) {
                        $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name']));
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;';
                        $display_link = '';
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\');return false;';
                        $display_link = '';
                    } else {
                        $onclick = true;
                        $display_link = url('gallery.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max';
                    }
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $notation = new Notation();
                    $notation->set_module_name('gallery');
                    $notation->set_notation_scale($config->get_notation_scale());
                    $notation->set_id_in_module($row['id']);
                    $notation->set_number_notes($row['number_notes']);
                    $notation->set_average_notes($row['average_notes']);
                    $notation->set_user_already_noted(!empty($row['note']));
                    $group_color = User::get_group_color($row['groups'], $row['level']);
                    $comments_topic->set_id_in_module($row['id']);
                    $html_protected_name = $row['name'];
                    $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list'));
                }
                $result->dispose();
                //Création des cellules du tableau si besoin est.
                while (!is_int($j / $nbr_column_pics)) {
                    $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%">&nbsp;</td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : ''));
                }
            }
        }
    }
Esempio n. 21
0
 public function get_array_tpl_vars()
 {
     $lang = LangLoader::get('common', 'calendar');
     $category = $this->content->get_category();
     $author = $this->content->get_author_user();
     $author_group_color = User::get_group_color($author->get_groups(), $author->get_level(), true);
     $missing_participants_number = $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() < $this->content->get_max_registered_members() ? $this->content->get_max_registered_members() - $this->get_registered_members_number() : 0;
     $registration_days_left = $this->content->get_last_registration_date() && time() < $this->content->get_last_registration_date()->get_timestamp() ? (int) (($this->content->get_last_registration_date()->get_timestamp() - time()) / 3600 / 24) : 0;
     return array('C_APPROVED' => $this->content->is_approved(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_LOCATION' => $this->content->get_location(), 'C_BELONGS_TO_A_SERIE' => $this->belongs_to_a_serie(), 'C_PARTICIPATION_ENABLED' => $this->content->is_registration_authorized(), 'C_DISPLAY_PARTICIPANTS' => $this->content->is_authorized_to_display_registered_users(), 'C_PARTICIPANTS' => !empty($this->participants), 'C_PARTICIPATE' => $this->content->is_registration_authorized() && $this->content->is_authorized_to_register() && time() < $this->start_date->get_timestamp() && (!$this->content->get_max_registered_members() || $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() < $this->content->get_max_registered_members()) && (!$this->content->get_last_registration_date() || $this->content->is_last_registration_date_enabled() && time() < $this->content->get_last_registration_date()->get_timestamp()) && !in_array(AppContext::get_current_user()->get_id(), array_keys($this->participants)), 'C_IS_PARTICIPANT' => in_array(AppContext::get_current_user()->get_id(), array_keys($this->participants)), 'C_REGISTRATION_CLOSED' => $this->content->is_last_registration_date_enabled() && $this->content->get_last_registration_date() && time() > $this->content->get_last_registration_date()->get_timestamp(), 'C_MAX_PARTICIPANTS_REACHED' => $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() == $this->content->get_max_registered_members(), 'C_MISSING_PARTICIPANTS' => !empty($missing_participants_number) && $missing_participants_number <= 5, 'C_REGISTRATION_DAYS_LEFT' => !empty($registration_days_left) && $registration_days_left <= 5, 'C_AUTHOR_GROUP_COLOR' => !empty($author_group_color), 'C_AUTHOR_EXIST' => $author->get_id() !== User::VISITOR_LEVEL, 'ID' => $this->id, 'CONTENT_ID' => $this->content->get_id(), 'TITLE' => $this->content->get_title(), 'CONTENTS' => FormatingHelper::second_parse($this->content->get_contents()), 'LOCATION' => $this->content->get_location(), 'START_DATE' => $this->start_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'START_DATE_DAY' => $this->start_date->get_day(), 'START_DATE_MONTH' => $this->start_date->get_month(), 'START_DATE_YEAR' => $this->start_date->get_year(), 'START_DATE_HOUR' => $this->start_date->get_hours(), 'START_DATE_MINUTE' => $this->start_date->get_minutes(), 'START_DATE_ISO8601' => $this->start_date->format(Date::FORMAT_ISO8601), 'END_DATE' => $this->end_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'END_DATE_DAY' => $this->end_date->get_day(), 'END_DATE_MONTH' => $this->end_date->get_month(), 'END_DATE_YEAR' => $this->end_date->get_year(), 'END_DATE_HOUR' => $this->end_date->get_hours(), 'END_DATE_MINUTE' => $this->end_date->get_minutes(), 'END_DATE_ISO8601' => $this->end_date->format(Date::FORMAT_ISO8601), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('calendar', $this->id), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('calendar', $this->id), 'REPEAT_NUMBER' => $this->content->get_repeat_number(), 'AUTHOR' => $author->get_display_name(), 'AUTHOR_LEVEL_CLASS' => UserService::get_level_class($author->get_level()), 'AUTHOR_GROUP_COLOR' => $author_group_color, 'L_MISSING_PARTICIPANTS' => $missing_participants_number > 1 ? StringVars::replace_vars($lang['calendar.labels.remaining_places'], array('missing_number' => $missing_participants_number)) : $lang['calendar.labels.remaining_place'], 'L_REGISTRATION_DAYS_LEFT' => $registration_days_left > 1 ? StringVars::replace_vars($lang['calendar.labels.remaining_days'], array('days_left' => $registration_days_left)) : $lang['calendar.labels.remaining_day'], 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_COLOR' => $category->get_id() != Category::ROOT_CATEGORY ? $category->get_color() : '', 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? CalendarUrlBuilder::configuration()->rel() : CalendarUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('calendar', $category->get_id())->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($author->get_id())->rel(), 'U_LINK' => CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $this->id, $this->content->get_rewrited_title())->rel(), 'U_EDIT' => CalendarUrlBuilder::edit_event(!$this->parent_id ? $this->id : $this->parent_id)->rel(), 'U_DELETE' => CalendarUrlBuilder::delete_event($this->id)->rel(), 'U_SUSCRIBE' => CalendarUrlBuilder::suscribe_event($this->id)->rel(), 'U_UNSUSCRIBE' => CalendarUrlBuilder::unsuscribe_event($this->id)->rel(), 'U_COMMENTS' => CalendarUrlBuilder::display_event_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->content->get_rewrited_title())->rel());
 }
 public function get_array_tpl_vars()
 {
     $group_color = User::get_group_color($this->user_groups, $this->level, true);
     return array('C_GROUP_COLOR' => !empty($group_color), 'DISPLAY_NAME' => $this->display_name, 'LEVEL_CLASS' => UserService::get_level_class($this->level), 'GROUP_COLOR' => $group_color, 'U_PROFILE' => UserUrlBuilder::profile($this->user_id)->rel());
 }
Esempio n. 23
0
 if (!in_array($criteria, array('entitled', 'module', 'status', 'creation_date', 'fixing_date', 'poster_id', 'fixer_id'))) {
     $criteria = 'current_status';
 }
 $order = $order == 'desc' ? 'desc' : 'asc';
 //On liste les contributions
 foreach (ContributionService::get_all_contributions($criteria, $order) as $this_contribution) {
     //Obligé de faire une variable temp à cause de php4.
     $creation_date = $this_contribution->get_creation_date();
     $fixing_date = $this_contribution->get_fixing_date();
     //Affichage des contributions du membre
     if (AppContext::get_current_user()->check_auth($this_contribution->get_auth(), Contribution::CONTRIBUTION_AUTH_BIT) || AppContext::get_current_user()->get_id() == $this_contribution->get_poster_id()) {
         //On affiche seulement si on est dans le bon cadre d'affichage
         if ($num_contributions > CONTRIBUTIONS_PER_PAGE * ($page - 1) && $num_contributions <= CONTRIBUTIONS_PER_PAGE * $page) {
             $poster_group_color = User::get_group_color($this_contribution->get_poster_groups(), $this_contribution->get_poster_level());
             $fixer_group_color = User::get_group_color($this_contribution->get_fixer_groups(), $this_contribution->get_fixer_level());
             $template->assign_block_vars('contributions', array('C_POSTER_GROUP_COLOR' => !empty($poster_group_color), 'C_FIXER_GROUP_COLOR' => !empty($fixer_group_color), 'ENTITLED' => $this_contribution->get_entitled(), 'MODULE' => $this_contribution->get_module_name(), 'STATUS' => $this_contribution->get_status_name(), 'CREATION_DATE' => $creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'FIXING_DATE' => $fixing_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'POSTER' => $this_contribution->get_poster_login(), 'POSTER_LEVEL_CLASS' => UserService::get_level_class($this_contribution->get_poster_level()), 'POSTER_GROUP_COLOR' => $poster_group_color, 'FIXER' => $this_contribution->get_fixer_login(), 'FIXER_LEVEL_CLASS' => UserService::get_level_class($this_contribution->get_fixer_level()), 'FIXER_GROUP_COLOR' => $fixer_group_color, 'ACTIONS' => '', 'U_FIXER_PROFILE' => UserUrlBuilder::profile($this_contribution->get_fixer_id())->rel(), 'U_POSTER_PROFILE' => UserUrlBuilder::profile($this_contribution->get_poster_id())->rel(), 'U_CONSULT' => PATH_TO_ROOT . '/user/' . url('contribution_panel.php?id=' . $this_contribution->get_id()), 'C_FIXED' => $this_contribution->get_status() == Event::EVENT_STATUS_PROCESSED, 'C_PROCESSING' => $this_contribution->get_status() == Event::EVENT_STATUS_BEING_PROCESSED));
         }
         $num_contributions++;
     }
 }
 $pagination = new ModulePagination($page, $num_contributions, CONTRIBUTIONS_PER_PAGE);
 $pagination->set_url(new Url('/user/contribution_panel.php?p=%d&criteria=' . $criteria . '&order=' . $order));
 if ($pagination->current_page_is_empty() && $page > 1) {
     $error_controller = PHPBoostErrors::unexisting_page();
     DispatchManager::redirect($error_controller);
 }
 if ($num_contributions > 1) {
     $template->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display()));
 } else {
     $template->put_all(array('C_NO_CONTRIBUTION' => true, 'L_NO_CONTRIBUTION_TO_DISPLAY' => LangLoader::get_message('no_item_now', 'common')));
 }
Esempio n. 24
0
                 break;
         }
         $stats_array[$name] = $row['compt'];
     }
     $result->dispose();
     $Stats->color_index = 0;
     $Stats->load_data($stats_array, 'ellipse');
     foreach ($Stats->data_stats as $name => $angle_value) {
         $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)];
         $tpl->assign_block_vars('sex', array('NBR_MBR' => NumberHelper::round($angle_value * $Stats->nbr_entry / 360, 0), 'COLOR' => 'RGB(' . $array_color[0] . ', ' . $array_color[1] . ', ' . $array_color[2] . ')', 'SEX' => $name == 'Other' ? $LANG['other'] : $name, 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1)));
     }
     $i = 1;
     $result = $db_querier->select("SELECT user_id, display_name, level, groups, posted_msg\n\t\tFROM " . DB_TABLE_MEMBER . "\n\t\tORDER BY posted_msg DESC\n\t\tLIMIT 10 OFFSET 0");
     while ($row = $result->fetch()) {
         $user_group_color = User::get_group_color($row['groups'], $row['level']);
         $tpl->assign_block_vars('top_poster', array('C_USER_GROUP_COLOR' => !empty($user_group_color), 'ID' => $i, 'LOGIN' => $row['display_name'], 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), 'USER_GROUP_COLOR' => $user_group_color, 'USER_POST' => $row['posted_msg'], 'U_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel()));
         $i++;
     }
     $result->dispose();
 } elseif ($visit || $visit_year) {
     //On affiche les visiteurs totaux et du jour
     $compteur = array('nbr_ip' => 0, 'total' => 0);
     try {
         $compteur = $db_querier->select_single_row(DB_TABLE_VISIT_COUNTER, array('ip AS nbr_ip', 'total'), 'WHERE id = :id', array('id' => 1));
     } catch (RowNotFoundException $e) {
     }
     $compteur_total = !empty($compteur['nbr_ip']) ? $compteur['nbr_ip'] : '1';
     $compteur_day = !empty($compteur['total']) ? $compteur['total'] : '1';
     $tpl->put_all(array('L_TODAY' => $date_lang['today'], 'L_TOTAL' => $LANG['total'], 'L_AVERAGE' => $LANG['average'], 'L_VISITORS' => $LANG['guest_s'] . ':', 'L_VISITS_DAY' => $LANG['guest_s'], 'L_DAY' => $date_lang['date'], 'L_MONTH' => $date_lang['month'], 'L_SUBMIT' => $LANG['submit']));
     $time = Date::to_format(Date::DATE_NOW, 'Ym');
     $current_year = substr($time, 0, 4);
Esempio n. 25
0
 }
 $user_accounts_config = UserAccountsConfig::load();
 //Avatar
 if (empty($row['user_avatar'])) {
     $user_avatar = $user_accounts_config->is_default_avatar_enabled() == '1' ? '<img src="../templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />' : '';
 } else {
     $user_avatar = '<img src="' . Url::to_rel($row['user_avatar']) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />';
 }
 //Affichage du nombre de message.
 if ($row['posted_msg'] >= 1) {
     $posted_msg = '<a href="' . UserUrlBuilder::messages($row['user_id'])->rel() . '" class="small">' . $LANG['message_s'] . '</a>: ' . $row['posted_msg'];
 } else {
     $posted_msg = !$is_guest ? '<a href="' . PATH_TO_ROOT . '/forum/membermsg' . url('.php?id=' . $row['user_id'], '') . '" class="small">' . $LANG['message'] . '</a>: 0' : $LANG['message'] . ': 0';
 }
 $user_sign_field = $extended_fields_cache->get_extended_field_by_field_name('user_sign');
 $tpl->assign_block_vars('list', array('C_GROUP_COLOR' => !empty($group_color), 'C_GUEST' => empty($row['display_name']), 'CONTENTS' => FormatingHelper::second_parse($row['contents']), 'DATE' => $LANG['on'] . ' ' . Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'ID' => $row['id'], 'USER_RANK' => $row['warning_percentage'] < '100' || time() - $row['delay_banned'] < 0 ? $user_rank : LangLoader::get_message('banned', 'user-common'), 'USER_IMG_ASSOC' => $user_assoc_img, 'USER_AVATAR' => $user_avatar, 'USER_GROUP' => $user_groups, 'USER_DATE' => !$is_guest ? $LANG['registered_on'] . ': ' . Date::to_format($row['registered'], Date::FORMAT_DAY_MONTH_YEAR) : '', 'USER_MSG' => !$is_guest ? $posted_msg : '', 'USER_MAIL' => !empty($row['email']) && $row['show_email'] == '1' ? '<a href="mailto:' . $row['email'] . '" class="basic-button smaller">Mail</a>' : '', 'USER_SIGN' => !empty($row['user_sign']) && !empty($user_sign_field) && $user_sign_field['display'] ? '____________________<br />' . FormatingHelper::second_parse($row['user_sign']) : '', 'USER_WARNING' => $row['warning_percentage'], 'USER_PM' => !$is_guest && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) ? '<a href="' . UserUrlBuilder::personnal_message($row['user_id'])->rel() . '" class="basic-button smaller">MP</a>' : '', 'USER_ONLINE' => '<i class="fa ' . (!empty($row['connect']) ? 'fa-online' : 'fa-offline') . '"></i>', 'USER_PSEUDO' => !empty($row['display_name']) ? wordwrap(TextHelper::html_entity_decode($row['display_name']), 13, '<br />', 1) : $LANG['guest'], 'LEVEL_CLASS' => UserService::get_level_class($row['level']), 'GROUP_COLOR' => $group_color, 'U_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_VARS_ANCRE' => url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php'), 'U_FORUM_CAT' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/forum' . url('.php?id=' . $row['idcat'], '-' . $row['idcat'] . $rewrited_cat_title . '.php') . '">' . $row['name'] . '</a>', 'U_TITLE_T' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php') . '">' . stripslashes($row['title']) . '</a>'));
 foreach ($displayed_extended_fields as $field_type) {
     $field = $extended_fields_cache->get_extended_field_by_field_name($field_type);
     if (!empty($row[$field_type]) && !empty($field) && $field['display']) {
         $button = '';
         if ($field['regex'] == 4) {
             foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) {
                 if (strstr($row[$field_type], $id)) {
                     $button = '<a href="mailto:' . $row[$field_type] . '" class="basic-button smaller"><i class="fa ' . $parameters['picture'] . '"></i> ' . $parameters['title'] . '</a>';
                 }
             }
         } else {
             if ($field['regex'] == 5) {
                 $button = '<a href="' . $row[$field_type] . '" class="basic-button smaller">' . LangLoader::get_message('regex.website', 'admin-user-common') . '</a>';
                 foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) {
                     if (strstr($row[$field_type], $id)) {
Esempio n. 26
0
         $moderation_panel_template->assign_block_vars('member_list', array('C_USER_GROUP_COLOR' => !empty($group_color), 'LOGIN' => $row['display_name'], 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), 'USER_GROUP_COLOR' => $group_color, 'INFO' => $row['warning_percentage'] != 100 ? Date::to_format($row['delay_banned'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) : $LANG['illimited'], 'U_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_ACTION_USER' => '<a href="' . UserUrlBuilder::moderation_panel('ban', $row['user_id'])->rel() . '" class="fa fa-forbidden"></a>', 'U_PM' => UserUrlBuilder::personnal_message($row['user_id'])->rel()));
         $i++;
     }
     $result->dispose();
     if ($i === 0) {
         $moderation_panel_template->put_all(array('C_EMPTY_LIST' => true, 'L_NO_USER' => $LANG['no_ban']));
     }
 } else {
     try {
         $member = PersistenceContext::get_querier()->select_single_row(DB_TABLE_MEMBER, array('display_name', 'level', 'groups', 'delay_banned', 'warning_percentage'), 'WHERE user_id=:id', array('id' => $id_get));
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_element();
         DispatchManager::redirect($error_controller);
     }
     $group_color = User::get_group_color($member['groups'], $member['level']);
     $moderation_panel_template->put_all(array('C_MODO_PANEL_USER_BAN' => true, 'C_USER_GROUP_COLOR' => !empty($group_color), 'LOGIN' => $member['display_name'], 'USER_LEVEL_CLASS' => UserService::get_level_class($member['level']), 'USER_GROUP_COLOR' => $group_color, 'KERNEL_EDITOR' => $editor->display(), 'U_PM' => UserUrlBuilder::personnal_message($id_get)->rel(), 'U_ACTION_INFO' => UserUrlBuilder::moderation_panel('ban', $id_get)->rel() . '&amp;token=' . AppContext::get_session()->get_token(), 'U_PROFILE' => UserUrlBuilder::profile($id_get)->rel(), 'L_PM' => $LANG['user_contact_pm'], 'L_LOGIN' => LangLoader::get_message('display_name', 'user-common'), 'L_BAN' => $LANG['ban_user'], 'L_DELAY_BAN' => $LANG['user_ban_delay']));
     //Temps de bannissement.
     $date_lang = LangLoader::get('date-common');
     $array_time = array(0, 60, 300, 900, 1800, 3600, 7200, 86400, 172800, 604800, 1209600, 2419200, 326592000);
     $array_sanction = array(LangLoader::get_message('no', 'common'), '1 ' . $date_lang['minute'], '5 ' . $date_lang['minutes'], '15 ' . $date_lang['minutes'], '30 ' . $date_lang['minutes'], '1 ' . $date_lang['hour'], '2 ' . $date_lang['hours'], '1 ' . $date_lang['day'], '2 ' . $date_lang['days'], '1 ' . $date_lang['week'], '2 ' . $date_lang['weeks'], '1 ' . $date_lang['month'], $LANG['illimited']);
     $diff = $member['delay_banned'] - time();
     $key_sanction = 0;
     if ($diff > 0) {
         //Retourne la sanction la plus proche correspondant au temp de bannissement.
         for ($i = 11; $i >= 0; $i--) {
             $avg = ceil(($array_time[$i] + $array_time[$i - 1]) / 2);
             if ($diff - $array_time[$i] > $avg) {
                 $key_sanction = $i + 1;
                 break;
             }
         }
Esempio n. 27
0
 public function get_array_tpl_vars()
 {
     $category = $this->get_category();
     $contents = FormatingHelper::second_parse($this->contents);
     $description = $this->get_real_short_contents();
     $user = $this->get_author_user();
     $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
     $number_comments = CommentsService::get_number_comments('download', $this->id);
     return array('C_VISIBLE' => $this->is_visible(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_READ_MORE' => !$this->is_short_contents_enabled() && $description != $contents && strlen($description) >= DownloadConfig::NUMBER_CARACTERS_BEFORE_CUT, 'C_SIZE' => !empty($this->size), 'C_PICTURE' => $this->has_picture(), 'C_CUSTOM_AUTHOR_DISPLAY_NAME' => $this->is_author_display_name_enabled(), 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'C_UPDATED_DATE' => $this->has_updated_date(), 'ID' => $this->id, 'NAME' => $this->name, 'SIZE' => $this->formated_size, 'CONTENTS' => $contents, 'DESCRIPTION' => $description, 'DATE' => $this->creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'DATE_DAY' => $this->creation_date->get_day(), 'DATE_MONTH' => $this->creation_date->get_month(), 'DATE_YEAR' => $this->creation_date->get_year(), 'DATE_DAY_MONTH' => $this->creation_date->format(Date::FORMAT_DAY_MONTH), 'DATE_ISO8601' => $this->creation_date->format(Date::FORMAT_ISO8601), 'UPDATED_DATE' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_DAY_MONTH_YEAR) : '', 'UPDATED_DATE_ISO8601' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_ISO8601) : '', 'STATUS' => $this->get_status(), 'CUSTOM_AUTHOR_DISPLAY_NAME' => $this->author_display_name, '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, 'NUMBER_DOWNLOADS' => $this->number_downloads, 'L_DOWNLOADED_TIMES' => StringVars::replace_vars(LangLoader::get_message('downloaded_times', 'common', 'download'), array('number_downloads' => $this->number_downloads)), 'STATIC_NOTATION' => NotationService::display_static_image($this->get_notation()), 'NOTATION' => NotationService::display_active_image($this->get_notation()), 'C_COMMENTS' => !empty($number_comments), 'L_COMMENTS' => CommentsService::get_lang_comments('download', $this->id), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('download', $this->id), '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 ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('download', $this->id_category)->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($this->get_author_user()->get_id())->rel(), 'U_LINK' => DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel(), 'U_DOWNLOAD' => DownloadUrlBuilder::download($this->id)->rel(), 'U_DEADLINK' => DownloadUrlBuilder::dead_link($this->id)->rel(), 'U_CATEGORY' => DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())->rel(), 'U_EDIT' => DownloadUrlBuilder::edit($this->id)->rel(), 'U_DELETE' => DownloadUrlBuilder::delete($this->id)->rel(), 'U_PICTURE' => $this->get_picture()->rel(), 'U_COMMENTS' => DownloadUrlBuilder::display_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel());
 }
    private function build_view()
    {
        global $LANG, $MEDIA_LANG;
        require_once PATH_TO_ROOT . '/media/media_constant.php';
        load_module_lang('media');
        $config = MediaConfig::load();
        $category = $this->get_category();
        $authorized_categories = MediaService::get_authorized_categories($category->get_id());
        //Contenu de la catégorie
        $page = AppContext::get_request()->get_getint('p', 1);
        $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
        $get_sort = retrieve(GET, 'sort', '');
        $get_mode = retrieve(GET, 'mode', '');
        $mode = $get_mode == 'asc' ? 'ASC' : 'DESC';
        $unget = !empty($get_sort) && !empty($mode) ? '?sort=' . $get_sort . '&amp;mode=' . $get_mode : '';
        //On crée une pagination si le nombre de sous-catégories est trop important.
        $subcategories_number = count(MediaService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id()));
        $pagination = new ModulePagination($subcategories_page, $subcategories_number, $config->get_categories_number_per_page());
        $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&amp;' : '?') . 'cat=' . $category->get_id() . '&amp;p=' . $page . '&amp;subcategories_page=%d'));
        if ($pagination->current_page_is_empty() && $subcategories_page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        //Children categories
        $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= media_cats.id, media_cats.*,
		(SELECT COUNT(*) FROM ' . MediaSetup::$media_table . '
			WHERE idcat IN (
				@id_cat,
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' WHERE id_parent = @id_cat), 
				(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' parents
				INNER JOIN ' . MediaSetup::$media_cats_table . ' childs ON parents.id = childs.id_parent
				WHERE parents.id_parent = @id_cat)
			)
			AND infos = :status
		) AS mediafiles_number
		FROM ' . MediaSetup::$media_cats_table . ' media_cats
		WHERE id_parent = :id_category
		AND id IN :authorized_categories
		ORDER BY id_parent, c_order
		LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED, 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
        $nbr_cat_displayed = 0;
        while ($row = $result->fetch()) {
            $category_image = new Url($row['image']);
            $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'MEDIAFILES_NUMBER' => sprintf($row['mediafiles_number'] > 1 ? $MEDIA_LANG['num_medias'] : $MEDIA_LANG['num_media'], $row['mediafiles_number']), 'U_CATEGORY' => MediaUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
            $nbr_cat_displayed++;
        }
        $result->dispose();
        $nbr_column_cats = $nbr_cat_displayed > $config->get_columns_number_per_line() ? $config->get_columns_number_per_line() : $nbr_cat_displayed;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $cats_columns_width = floor(100 / $nbr_column_cats);
        $category_description = FormatingHelper::second_parse($category->get_description());
        $this->tpl->put_all(array('C_CATEGORIES' => true, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_MODO' => MediaAuthorizationsService::check_authorizations($category->get_id())->moderation(), 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'L_BY' => $MEDIA_LANG['media_added_by'], 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'CATEGORY_NAME' => $category->get_id() == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : $category->get_name(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($category->get_id())->rel(), 'ID_CAT' => $category->get_id()));
        $selected_fields = array('alpha' => '', 'date' => '', 'nbr' => '', 'note' => '', 'com' => '', 'asc' => '', 'desc' => '');
        switch ($get_sort) {
            case 'alpha':
                $sort = 'name';
                $selected_fields['alpha'] = ' selected="selected"';
                break;
            default:
            case 'date':
                $sort = 'timestamp';
                $selected_fields['date'] = ' selected="selected"';
                break;
            case 'nbr':
                $sort = 'counter';
                $selected_fields['nbr'] = ' selected="selected"';
                break;
            case 'note':
                $sort = 'average_notes';
                $selected_fields['note'] = ' selected="selected"';
                break;
            case 'com':
                $sort = 'com.number_comments';
                $selected_fields['com'] = ' selected="selected"';
                break;
        }
        if ($mode == 'ASC') {
            $selected_fields['asc'] = ' selected="selected"';
        } else {
            $selected_fields['desc'] = ' selected="selected"';
        }
        $this->tpl->put_all(array('C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'L_ALPHA' => $MEDIA_LANG['sort_title'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_NBR' => $MEDIA_LANG['sort_popularity'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_DESC' => $LANG['desc'], 'L_ASC' => $LANG['asc'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common'), 'SELECTED_ALPHA' => $selected_fields['alpha'], 'SELECTED_DATE' => $selected_fields['date'], 'SELECTED_NBR' => $selected_fields['nbr'], 'SELECTED_NOTE' => $selected_fields['note'], 'SELECTED_COM' => $selected_fields['com'], 'SELECTED_ASC' => $selected_fields['asc'], 'SELECTED_DESC' => $selected_fields['desc']));
        $condition = 'WHERE idcat = :idcat AND infos = :status';
        $parameters = array('idcat' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED);
        //On crée une pagination si le nombre de fichiers est trop important.
        $mediafiles_number = MediaService::count($condition, $parameters);
        $pagination = new ModulePagination($page, $mediafiles_number, $config->get_items_number_per_page());
        $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&amp;' : '?') . 'cat=' . $category->get_id() . '&amp;p=%d&amp;subcategories_page=' . $subcategories_page));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        $notation = new Notation();
        $notation->set_module_name('media');
        $notation->set_notation_scale($config->get_notation_scale());
        $result = PersistenceContext::get_querier()->select("SELECT v.id, v.iduser, v.name, v.timestamp, v.counter, v.infos, v.contents, mb.display_name, mb.groups, mb.level, notes.average_notes, com.number_comments\n\t\t\tFROM " . PREFIX . "media AS v\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " AS mb ON v.iduser = mb.user_id\n\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON v.id = notes.id_in_module AND notes.module_name = 'media'\n\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON v.id = com.id_in_module AND com.module_id = 'media'\n\t\t\t" . $condition . "\n\t\t\tORDER BY " . $sort . " " . $mode . "\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
        $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_DISPLAY_NO_FILE_MSG' => $result->get_rows_count() == 0 && $category->get_id() != Category::ROOT_CATEGORY, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TARGET_ON_CHANGE_ORDER' => ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? 'media-0-' . $category->get_id() . '.php?' : 'media.php?cat=' . $category->get_id() . '&'));
        while ($row = $result->fetch()) {
            $notation->set_id_in_module($row['id']);
            $group_color = User::get_group_color($row['groups'], $row['level']);
            $this->tpl->assign_block_vars('file', array('ID' => $row['id'], 'NAME' => $row['name'], 'IMG_NAME' => str_replace('"', '\\"', $row['name']), 'C_DESCRIPTION' => !empty($row['contents']), 'DESCRIPTION' => stripslashes(FormatingHelper::second_parse($row['contents'])), 'POSTER' => $MEDIA_LANG['media_added_by'] . ' : ' . !empty($row['display_name']) ? '<a href="' . UserUrlBuilder::profile($row['iduser'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['display_name'] . '</a>' : $LANG['guest'], 'DATE' => sprintf($MEDIA_LANG['add_on_date'], Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR)), 'COUNT' => sprintf($MEDIA_LANG['view_n_times'], $row['counter']), 'NOTE' => NotationService::display_static_image($notation), 'U_MEDIA_LINK' => PATH_TO_ROOT . '/media/' . url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php'), 'U_ADMIN_UNVISIBLE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?unvisible=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token()), 'U_ADMIN_EDIT_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?edit=' . $row['id']), 'U_ADMIN_DELETE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?del=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token()), 'U_COM_LINK' => '<a href="' . PATH_TO_ROOT . '/media/media' . url('.php?id=' . $row['id'] . '&amp;com=0', '-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php?com=0') . '">' . CommentsService::get_number_and_lang_comments('media', $row['id']) . '</a>'));
        }
        $result->dispose();
    }
Esempio n. 29
0
        DispatchManager::redirect($error_controller);
    }
    $tpl->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_POLL_MANAGEMENT' => $LANG['poll_management'], 'L_POLL_ADD' => $LANG['poll_add'], 'L_POLL_CONFIG' => $LANG['poll_config'], 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_QUESTION' => $LANG['question'], 'L_POLLS' => $LANG['polls'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_PSEUDO' => LangLoader::get_message('author', 'common'), 'L_APROB' => $LANG['aprob'], 'L_UPDATE' => $LANG['update']));
    $result = PersistenceContext::get_querier()->select("SELECT p.id, p.question, p.archive, p.timestamp, p.visible, p.start, p.end, p.user_id, m.display_name, m.groups, m.level\n\tFROM " . PREFIX . "poll p\n\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON p.user_id = m.user_id\n\tORDER BY p.timestamp DESC \n\tLIMIT :number_items_per_page OFFSET :display_from", array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
    while ($row = $result->fetch()) {
        if ($row['visible'] == 2) {
            $aprob = $LANG['waiting'];
        } elseif ($row['visible'] == 1) {
            $aprob = LangLoader::get_message('yes', 'common');
        } else {
            $aprob = LangLoader::get_message('no', 'common');
        }
        $archive = $row['archive'] == 1 ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common');
        //On reccourci le lien si il est trop long pour éviter de déformer l'administration.
        $question = stripslashes(strlen($row['question']) > 45 ? substr($row['question'], 0, 45) . '...' : $row['question']);
        $visible = '';
        if ($row['start'] > 0) {
            $visible .= Date::to_format($row['start'], Date::FORMAT_DAY_MONTH_YEAR);
        }
        if ($row['end'] > 0 && $row['start'] > 0) {
            $visible .= ' ' . strtolower($LANG['until']) . ' ' . Date::to_format($row['end'], Date::FORMAT_DAY_MONTH_YEAR);
        } elseif ($row['end'] > 0) {
            $visible .= $LANG['until'] . ' ' . Date::to_format($row['end'], Date::FORMAT_DAY_MONTH_YEAR);
        }
        $group_color = User::get_group_color($row['groups'], $row['level']);
        $tpl->assign_block_vars('questions', array('C_USER_GROUP_COLOR' => !empty($group_color), 'QUESTIONS' => $question, 'IDPOLL' => $row['id'], 'PSEUDO' => $row['display_name'], 'USER_GROUP_COLOR' => $group_color, 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), 'DATE' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'ARCHIVES' => $archive, 'APROBATION' => $aprob, 'VISIBLE' => !empty($visible) ? '(' . $visible . ')' : '', 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel()));
    }
    $result->dispose();
    $tpl->display();
}
require_once '../admin/admin_footer.php';
Esempio n. 30
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());
 }