private function init_filter_custom_fields()
 {
     if (!$this->cfield_mgr) {
         $this->cfield_mgr = new cfield_mgr($this->db, $this->args->testproject_id);
     }
     $no_warning = true;
     $key = 'filter_custom_fields';
     $this->filters[$key] = false;
     $this->active_filters[$key] = null;
     global $g_locales_date_format;
     $locale = isset($_SESSION['locale']) ? $_SESSION['locale'] : 'en_GB';
     $date_format = str_replace('%', '', $g_locales_date_format[$locale]);
     $collapsed = isset($_SESSION['cf_filter_collapsed']) ? $_SESSION['cf_filter_collapsed'] : 0;
     $collapsed = isset($_REQUEST['btn_toggle_cf']) ? !$collapsed : $collapsed;
     $_SESSION['cf_filter_collapsed'] = $collapsed;
     $btn_label = $collapsed ? lang_get('btn_show_cf') : lang_get('btn_hide_cf');
     $cfields = $this->cfield_mgr->get_linked_cfields_at_design($this->args->testproject_id, 1, null, 'testcase');
     $cf_prefix = $this->cfield_mgr->name_prefix;
     $cf_html_code = "";
     $selection = array();
     if (!is_null($cfields)) {
         // display and compute only when custom fields are in use
         foreach ($cfields as $cf_id => $cf) {
             // has a value been selected?
             $id = $cf['id'];
             $type = $cf['type'];
             $verbose_type = trim($this->cfield_mgr->custom_field_types[$type]);
             $cf_input_name = "{$cf_prefix}{$type}_{$id}";
             $value = isset($_REQUEST[$cf_input_name]) ? $_REQUEST[$cf_input_name] : null;
             if ($this->args->reset_filters) {
                 $value = null;
             } else {
                 if ($verbose_type == 'datetime') {
                     // if cf is a date field, convert the three given values to unixtime format
                     if (isset($_REQUEST[$cf_input_name . '_input']) && $_REQUEST[$cf_input_name . '_input'] != '' && isset($_REQUEST[$cf_input_name . '_hour']) && $_REQUEST[$cf_input_name . '_hour'] != '' && isset($_REQUEST[$cf_input_name . '_minute']) && $_REQUEST[$cf_input_name . '_minute'] != '' && isset($_REQUEST[$cf_input_name . '_second']) && $_REQUEST[$cf_input_name . '_second'] != '') {
                         $date = $_REQUEST[$cf_input_name . '_input'];
                         $hour = $_REQUEST[$cf_input_name . '_hour'];
                         $minute = $_REQUEST[$cf_input_name . '_minute'];
                         $second = $_REQUEST[$cf_input_name . '_second'];
                         $date_array = split_localized_date($date, $date_format);
                         $value = mktime($hour, $minute, $second, $date_array['month'], $date_array['day'], $date_array['year']);
                     }
                 }
                 if ($verbose_type == 'date') {
                     if (isset($_REQUEST[$cf_input_name . '_input']) && $_REQUEST[$cf_input_name . '_input'] != '') {
                         $date = $_REQUEST[$cf_input_name . '_input'];
                         $date_array = split_localized_date($date, $date_format);
                         $value = mktime(0, 0, 0, $date_array['month'], $date_array['day'], $date_array['year']);
                     }
                 }
             }
             $value2display = $value;
             if (!is_null($value2display) && is_array($value2display)) {
                 $value2display = implode("|", $value2display);
             } else {
                 $value = trim($value);
                 $value2display = $value;
             }
             $cf['value'] = $value2display;
             if (!is_null($value) && $value != '') {
                 $this->do_filtering = true;
                 $selection[$id] = $value;
             }
             $label = str_replace(TL_LOCALIZE_TAG, '', lang_get($cf['label'], null, $no_warning));
             $cf_size = self::CF_INPUT_SIZE;
             if ($verbose_type == 'list' || $verbose_type == 'multiselection list') {
                 $cf_size = 3;
             }
             // don't show textarea inputs here, they are too large for filterpanel
             if ($verbose_type != 'text area') {
                 $cf_html_code .= '<tr class="cfRow"><td>' . htmlspecialchars($label) . '</td><td>' . $this->cfield_mgr->string_custom_field_input($cf, '', $cf_size, true) . '</td></tr>';
             }
         }
         $this->filters[$key] = array('items' => $cf_html_code, 'btn_label' => $btn_label, 'collapsed' => $collapsed);
         $this->active_filters[$key] = count($selection) ? $selection : null;
     }
 }