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;
 }
 private function build_view($request)
 {
     //Configuration load
     $config = BugtrackerConfig::load();
     $severities = $config->get_severities();
     $field = $request->get_value('field', 'date');
     $sort = $request->get_value('sort', 'desc');
     $current_page = $request->get_getint('page', 1);
     $filter = $request->get_value('filter', '');
     $filter_id = $request->get_value('filter_id', '');
     if (!empty($filter) && empty($filter_id)) {
         $filter = $filter_id = '';
     }
     $filters = !empty($filter) ? explode('-', $filter) : array();
     $nb_filters = count($filters);
     $filters_ids = !empty($filter_id) ? explode('-', $filter_id) : array();
     $nb_filters_ids = count($filters_ids);
     if ($nb_filters != $nb_filters_ids) {
         for ($i = $nb_filters_ids; $i < $nb_filters; $i++) {
             $filters_ids[] = 0;
         }
     }
     $mode = $sort == 'top' ? 'ASC' : 'DESC';
     switch ($field) {
         case 'id':
             $field_bdd = 'id';
             break;
         case 'title':
             $field_bdd = 'title';
             break;
         case 'status':
             $field_bdd = 'status';
             break;
         default:
             $field_bdd = 'submit_date';
             break;
     }
     $select_filters = '';
     foreach ($filters as $key => $f) {
         $select_filters .= in_array($f, array('type', 'category', 'severity', 'status', 'detected_in')) && $filters_ids[$key] ? "AND " . $f . " = '" . $filters_ids[$key] . "'" : '';
     }
     $stats_cache = BugtrackerStatsCache::load();
     $bugs_number = BugtrackerService::count("WHERE status <> '" . Bug::FIXED . "' AND status <> '" . Bug::REJECTED . "'" . $select_filters);
     $pagination = $this->get_pagination($bugs_number, $current_page, $field, $sort, $filter, $filter_id);
     $result = PersistenceContext::get_querier()->select("SELECT b.*, member.*\n\t\tFROM " . BugtrackerSetup::$bugtracker_table . " b\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " member ON member.user_id = b.author_id\n\t\tWHERE status <> '" . Bug::FIXED . "' AND status <> '" . Bug::REJECTED . "'" . $select_filters . "\n\t\tORDER BY " . $field_bdd . " " . $mode . "\n\t\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()));
     $displayed_severities = array();
     while ($row = $result->fetch()) {
         $bug = new Bug();
         $bug->set_properties($row);
         if (!in_array($bug->get_severity(), $displayed_severities)) {
             $displayed_severities[] = $bug->get_severity();
         }
         $this->view->assign_block_vars('bug', array_merge($bug->get_array_tpl_vars(), array('C_LINE_COLOR' => $bug->get_severity() && isset($severities[$bug->get_severity()]), 'LINE_COLOR' => stripslashes($severities[$bug->get_severity()]['color']), 'U_CHANGE_STATUS' => BugtrackerUrlBuilder::change_status($bug->get_id())->rel(), 'U_EDIT' => BugtrackerUrlBuilder::edit($bug->get_id(), 'unsolved', $current_page, $filter, $filter_id)->rel(), 'U_DELETE' => BugtrackerUrlBuilder::delete($bug->get_id(), 'unsolved', $current_page, $filter, $filter_id)->rel())));
     }
     $result->dispose();
     $bugs_colspan = BugtrackerAuthorizationsService::check_authorizations()->moderation() ? 5 : 4;
     if ($config->is_type_column_displayed()) {
         $bugs_colspan++;
     }
     if ($config->is_category_column_displayed()) {
         $bugs_colspan++;
     }
     if ($config->is_priority_column_displayed()) {
         $bugs_colspan++;
     }
     if ($config->is_detected_in_column_displayed()) {
         $bugs_colspan++;
     }
     $this->view->put_all(array('C_IS_ADMIN' => BugtrackerAuthorizationsService::check_authorizations()->moderation(), 'C_UNSOLVED' => true, 'C_BUGS' => $result->get_rows_count() > 0, 'C_DISPLAY_AUTHOR' => true, 'C_DISPLAY_TYPE_COLUMN' => $config->is_type_column_displayed(), 'C_DISPLAY_CATEGORY_COLUMN' => $config->is_category_column_displayed(), 'C_DISPLAY_PRIORITY_COLUMN' => $config->is_priority_column_displayed(), 'C_DISPLAY_DETECTED_IN_COLUMN' => $config->is_detected_in_column_displayed(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'BUGS_COLSPAN' => $bugs_colspan, 'L_NO_BUG' => empty($filters) ? $this->lang['notice.no_bug'] : (count($filters) > 1 ? $this->lang['notice.no_bug_matching_filters'] : $this->lang['notice.no_bug_matching_filter']), 'FILTER_LIST' => BugtrackerViews::build_filters('unsolved', $bugs_number), 'LEGEND' => BugtrackerViews::build_legend($displayed_severities, 'unsolved'), 'LINK_BUG_ID_TOP' => BugtrackerUrlBuilder::unsolved('id', 'top', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_ID_BOTTOM' => BugtrackerUrlBuilder::unsolved('id', 'bottom', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_TITLE_TOP' => BugtrackerUrlBuilder::unsolved('title', 'top', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_TITLE_BOTTOM' => BugtrackerUrlBuilder::unsolved('title', 'bottom', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_STATUS_TOP' => BugtrackerUrlBuilder::unsolved('status', 'top', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_STATUS_BOTTOM' => BugtrackerUrlBuilder::unsolved('status', 'bottom', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_DATE_TOP' => BugtrackerUrlBuilder::unsolved('date', 'top', $current_page, $filter, $filter_id)->rel(), 'LINK_BUG_DATE_BOTTOM' => BugtrackerUrlBuilder::unsolved('date', 'bottom', $current_page, $filter, $filter_id)->rel()));
     return $this->view;
 }
 private function build_view($request)
 {
     $severities = $this->config->get_severities();
     $versions = array_reverse($this->config->get_versions(), true);
     if (!empty($versions)) {
         $roadmap_version = $request->get_int('id_version', 0);
         $roadmap_version_name = $request->get_value('version', '');
         $roadmap_status = $request->get_value('status', 'all');
         if ($roadmap_status !== 'all' && $roadmap_status !== Bug::FIXED && $roadmap_status !== Bug::IN_PROGRESS) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
         if (empty($roadmap_version) && empty($roadmap_version_name)) {
             $roadmap_version = key($versions);
             $roadmap_version_name = Url::encode_rewrite($versions[key($versions)]['name']);
         } else {
             if (!isset($versions[$roadmap_version])) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         }
         $field = $request->get_value('field', BugtrackerUrlBuilder::DEFAULT_SORT_FIELD);
         $sort = $request->get_value('sort', BugtrackerUrlBuilder::DEFAULT_SORT_MODE);
         $current_page = $request->get_int('page', 1);
         $mode = $sort == 'top' ? 'ASC' : 'DESC';
         switch ($field) {
             case 'id':
                 $field_bdd = 'id';
                 break;
             case 'title':
                 $field_bdd = 'title';
                 break;
             case 'severity':
                 $field_bdd = 'severity';
                 break;
             case 'status':
                 $field_bdd = 'status';
                 break;
             default:
                 $field_bdd = 'fix_date';
                 break;
         }
         $stats_cache = BugtrackerStatsCache::load();
         $bugs_number = $stats_cache->get_bugs_number_per_version($roadmap_version);
         $pagination = $this->get_pagination($bugs_number[$roadmap_status], $current_page, $roadmap_version, $roadmap_version_name, $roadmap_status, $field, $sort);
         $result = PersistenceContext::get_querier()->select("SELECT b.*, member.*\n\t\t\tFROM " . BugtrackerSetup::$bugtracker_table . " b\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " member ON member.user_id = b.author_id\n\t\t\tWHERE fixed_in = " . $roadmap_version . "\n\t\t\t" . ($roadmap_status != 'all' ? $roadmap_status == Bug::IN_PROGRESS ? "AND (b.status = '" . Bug::IN_PROGRESS . "' OR b.status = '" . Bug::REOPEN . "')" : "AND b.status = '" . Bug::FIXED . "'" : "") . "\n\t\t\tORDER BY " . $field_bdd . " " . $mode . "\n\t\t\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()));
         $displayed_severities = array();
         while ($row = $result->fetch()) {
             $bug = new Bug();
             $bug->set_properties($row);
             if (!in_array($bug->get_severity(), $displayed_severities)) {
                 $displayed_severities[] = $bug->get_severity();
             }
             $this->view->assign_block_vars('bug', array_merge($bug->get_array_tpl_vars(), array('C_LINE_COLOR' => !empty($row['severity']) && isset($severities[$row['severity']]), 'LINE_COLOR' => stripslashes($severities[$row['severity']]['color']))));
         }
         $result->dispose();
         $bugs_colspan = 4;
         if ($this->config->is_type_column_displayed()) {
             $bugs_colspan++;
         }
         if ($this->config->is_category_column_displayed()) {
             $bugs_colspan++;
         }
         if ($this->config->is_priority_column_displayed()) {
             $bugs_colspan++;
         }
         if ($this->config->is_detected_in_column_displayed()) {
             $bugs_colspan++;
         }
         $this->view->put_all(array('C_VERSIONS_AVAILABLE' => true, 'C_BUGS' => $bugs_number[$roadmap_status], 'C_STATUS_IN_PROGRESS' => $roadmap_status == Bug::IN_PROGRESS, 'C_DISPLAY_TYPE_COLUMN' => $this->config->is_type_column_displayed(), 'C_DISPLAY_CATEGORY_COLUMN' => $this->config->is_category_column_displayed(), 'C_DISPLAY_PRIORITY_COLUMN' => $this->config->is_priority_column_displayed(), 'C_DISPLAY_DETECTED_IN_COLUMN' => $this->config->is_detected_in_column_displayed(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'BUGS_COLSPAN' => $bugs_colspan, 'SELECT_VERSION' => $this->build_form(isset($versions[$roadmap_version]) ? $roadmap_version : 0, isset($versions[$roadmap_version]) ? Url::encode_rewrite($versions[$roadmap_version]['name']) : '', $roadmap_status, (int) $bugs_number[$roadmap_status], isset($versions[$roadmap_version]) ? $versions[$roadmap_version]['release_date'] : 0)->display(), 'LEGEND' => BugtrackerViews::build_legend($displayed_severities, 'roadmap'), 'LINK_BUG_ID_TOP' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'id', 'top', $current_page)->rel(), 'LINK_BUG_ID_BOTTOM' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'id', 'bottom', $current_page)->rel(), 'LINK_BUG_TITLE_TOP' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'title', 'top', $current_page)->rel(), 'LINK_BUG_TITLE_BOTTOM' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'title', 'bottom', $current_page)->rel(), 'LINK_BUG_SEVERITY_TOP' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'severity', 'top', $current_page)->rel(), 'LINK_BUG_SEVERITY_BOTTOM' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'severity', 'bottom', $current_page)->rel(), 'LINK_BUG_STATUS_TOP' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'status', 'top', $current_page)->rel(), 'LINK_BUG_STATUS_BOTTOM' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'status', 'bottom', $current_page)->rel(), 'LINK_BUG_DATE_TOP' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'date', 'top', $current_page)->rel(), 'LINK_BUG_DATE_BOTTOM' => BugtrackerUrlBuilder::roadmap($roadmap_version, $roadmap_version_name, $roadmap_status, 'date', 'bottom', $current_page)->rel()));
     }
     return $this->view;
 }