Пример #1
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $db = FWS_Props::get()->db();
     $tpl = FWS_Props::get()->tpl();
     $num = $db->get_row_count(TDL_TB_PROJECTS, 'id', '');
     $tpl->add_variables(array('num' => $num));
     $projects = array();
     $i = 0;
     foreach ($db->get_rows('SELECT * FROM ' . TDL_TB_PROJECTS . ' ORDER BY id DESC') as $data) {
         $projects[] = array('title' => $data['project_name'], 'shortcut' => $data['project_name_short'], 'start' => FWS_Date::get_date($data['project_start'], false), 'index' => $i++, 'id' => $data['id']);
     }
     $tpl->add_variable_ref('projects', $projects);
     $tpl->add_variables(array('index' => $i));
 }
Пример #2
0
 /**
  * This method checks a field for a given type. By default the check will only be performed
  * if the value is not NULL. You can force the check by setting <var>$is_required</var> to true.
  * The possible values for $for are:
  * <ul>
  * 	<li>timestamp		=> uses {@link FWS_Date::is_valid_timestamp()}</li>
  * 	<li>empty				=> has to be empty</li>
  * 	<li>notempty		=> has to be not-empty</li>
  * 	<li>id					=> has to be a positive integer
  * 	<li>numeric			=> uses <var>is_numeric()</var></li>
  * 	<li>enum				=> requires <var>$values</var> and uses <var>in_array()</var></li>
  * </ul>
  * Will add a default-error message if invalid
  * 
  * @param string $field the field-name
  * @param string $for the type to check for. See the list above!
  * @param boolean $is_required force the check?
  * @param array $values possible values for the field. empty if it should not be used
  * @return boolean true if the value is ok
  */
 protected function check_field_for($field, $for = 'timestamp', $is_required = false, $values = array())
 {
     $errors = 0;
     $method = 'get_' . $field;
     $val = $this->{$method}();
     if ($val !== null || $is_required) {
         $error = false;
         switch ($for) {
             case 'empty':
                 $error = !empty($val);
                 break;
             case 'notempty':
                 $error = empty($val);
                 break;
             case 'timestamp':
                 $error = !FWS_Date::is_valid_timestamp($val);
                 break;
             case 'id':
                 $error = !FWS_Helper::is_integer($val) || $val <= 0;
                 break;
             case 'numeric':
                 $error = !is_numeric($val);
                 break;
             case 'enum':
                 if (!is_array($values) || count($values) == 0) {
                     FWS_Helper::def_error('array>0', 'values', $values);
                 }
                 $error = !in_array($val, $values);
                 break;
         }
         if ($error) {
             if ($is_required && empty($val)) {
                 $this->add_error($this->missing_field_msg($field), $field);
             } else {
                 $this->add_error($this->invalid_field_msg($field), $field);
             }
             $errors++;
         }
     }
     return $errors == 0;
 }
Пример #3
0
    /**
     * @see FWS_Module::run()
     */
    public function run()
    {
        $input = FWS_Props::get()->input();
        $db = FWS_Props::get()->db();
        $versions = FWS_Props::get()->versions();
        $functions = FWS_Props::get()->functions();
        $user = FWS_Props::get()->user();
        $tpl = FWS_Props::get()->tpl();
        $id = $input->get_predef(TDL_URL_ID, 'get');
        if ($id == null) {
            $this->report_error();
            return;
        }
        $data = $db->get_row('SELECT e.*,c.category_name FROM ' . TDL_TB_ENTRIES . ' e
			 LEFT JOIN ' . TDL_TB_CATEGORIES . ' c ON entry_category = c.id
			 WHERE e.id = ' . $id);
        if ($data['id'] == '') {
            $this->report_error();
            return;
        }
        $start_version = $versions->get_element($data['entry_start_version']);
        $fixed_date = '-';
        $fixed_version = '-';
        if ($data['entry_fixed_date'] > 0) {
            $fixed_date = FWS_Date::get_date($data['entry_fixed_date']);
            if ($data['entry_fixed_version'] > 0) {
                $version = $versions->get_element($data['entry_fixed_version']);
            } else {
                $version = $versions->get_element($data['entry_start_version']);
            }
            $fixed_version = $version['version_name'];
        }
        if ($data['entry_info_link'] != '') {
            $info_link = '<a class="tl_main" target="_blank" href="' . $data['entry_info_link'] . '">';
            $info_link .= $data['entry_info_link'] . '</a>';
        } else {
            $info_link = '-';
        }
        if ($data['entry_description'] != '') {
            $desc = nl2br($data['entry_description']);
        } else {
            $desc = '-';
        }
        $type_text = $functions->get_type_text($data['entry_type']);
        $type = '<img src="' . $user->get_theme_item_path('images/type/' . $data['entry_type'] . '.gif') . '" align="top"';
        $type .= ' alt="' . $type_text . '" title="' . $type_text . '" />&nbsp;&nbsp;' . $type_text;
        $prio_text = $functions->get_priority_text($data['entry_priority']);
        $prio = '<img src="' . $user->get_theme_item_path('images/priority/' . $data['entry_priority'] . '.png') . '" align="top"';
        $prio .= ' alt="' . $prio_text . '" title="' . $prio_text . '" />&nbsp;&nbsp;' . $prio_text;
        $tpl->add_variables(array('project_name' => $start_version['project_name'], 'category_name' => $data['category_name'], 'priority' => $prio, 'id' => $data['id'], 'type' => $type, 'status' => $functions->get_status_text($data['entry_status']), 'status_class' => 'tl_status_' . $data['entry_status'], 'title' => $data['entry_title'], 'start_date' => FWS_Date::get_date($data['entry_start_date']), 'start_version' => $start_version['version_name'], 'fixed_date' => $fixed_date, 'fixed_version' => $fixed_version, 'changed_date' => FWS_Date::get_date($data['entry_changed_date']), 'description' => $desc, 'info_link' => $info_link));
    }
Пример #4
0
    /**
     * @see FWS_Module::run()
     */
    public function run()
    {
        $input = FWS_Props::get()->input();
        $functions = FWS_Props::get()->functions();
        $cfg = FWS_Props::get()->cfg();
        $cats = FWS_Props::get()->cats();
        $versions = FWS_Props::get()->versions();
        $db = FWS_Props::get()->db();
        $tpl = FWS_Props::get()->tpl();
        $user = FWS_Props::get()->user();
        $locale = FWS_Props::get()->locale();
        $s_keyword = $input->get_predef(TDL_URL_S_KEYWORD, 'get');
        $s_from_changed_date = $input->get_predef(TDL_URL_S_FROM_CHANGED_DATE, 'get');
        $s_to_changed_date = $input->get_predef(TDL_URL_S_TO_CHANGED_DATE, 'get');
        $s_from_start_date = $input->get_predef(TDL_URL_S_FROM_START_DATE, 'get');
        $s_to_start_date = $input->get_predef(TDL_URL_S_TO_START_DATE, 'get');
        $s_from_fixed_date = $input->get_predef(TDL_URL_S_FROM_FIXED_DATE, 'get');
        $s_to_fixed_date = $input->get_predef(TDL_URL_S_TO_FIXED_DATE, 'get');
        $s_type = $input->get_predef(TDL_URL_S_TYPE, 'get', '');
        $s_priority = $input->get_predef(TDL_URL_S_PRIORITY, 'get', '');
        $s_status = $input->get_predef(TDL_URL_S_STATUS, 'get', '');
        $s_category = $input->get_predef(TDL_URL_S_CATEGORY, 'get');
        $t_from_changed = $functions->get_date_from_string($s_from_changed_date);
        $t_to_changed = $functions->get_date_from_string($s_to_changed_date, 23, 59, 59);
        $t_from_start = $functions->get_date_from_string($s_from_start_date);
        $t_to_start = $functions->get_date_from_string($s_to_start_date, 23, 59, 59);
        $t_from_fixed = $functions->get_date_from_string($s_from_fixed_date);
        $t_to_fixed = $functions->get_date_from_string($s_to_fixed_date, 23, 59, 59);
        $form = new FWS_HTML_Formular(false);
        $s_type_combo = $form->get_combobox(TDL_URL_S_TYPE, $functions->get_types(true), $s_type);
        $s_priority_combo = $form->get_combobox(TDL_URL_S_PRIORITY, $functions->get_priorities(true), $s_priority);
        $s_status_combo = $form->get_combobox(TDL_URL_S_STATUS, $functions->get_states(true), $s_status);
        $category_options = array('' => $locale->_('- All -'));
        if ($cfg['project_id'] != 0) {
            $cat_rows = $cats->get_elements_with(array('project_id' => $cfg['project_id']));
        } else {
            $cat_rows = $cats->get_elements_with(array());
        }
        foreach ($cat_rows as $row) {
            $project = $versions->get_element_with(array('project_id' => $row['project_id']));
            $category_options[$row['id']] = $project['project_name_short'] . ' :: ' . $row['category_name'];
        }
        $s_category_combo = $form->get_combobox(TDL_URL_S_CATEGORY, $category_options, $s_category);
        $search_display_value = $input->get_var(TDL_COOKIE_PREFIX . 'display_search_form', 'cookie', FWS_Input::INT_BOOL);
        $where = ' WHERE ';
        if ($cfg['project_id'] != 0) {
            $where .= ' e.project_id = ' . $cfg['project_id'] . ' AND ';
        }
        if ($s_keyword != '') {
            $where .= " (LOWER(e.entry_title) LIKE LOWER('%" . $s_keyword . "%') OR";
            $where .= " LOWER(e.entry_description) LIKE LOWER('%" . $s_keyword . "%')) AND ";
        }
        if ($s_type != '') {
            $where .= " e.entry_type = '" . $s_type . "' AND ";
        }
        if ($s_priority != '') {
            $where .= " e.entry_priority = '" . $s_priority . "' AND ";
        }
        if ($s_status != '') {
            $where .= " e.entry_status = '" . $s_status . "' AND ";
        }
        if ($s_category != '') {
            $where .= " e.entry_category = " . $s_category . " AND ";
        }
        if ($t_from_changed) {
            $where .= ' e.entry_changed_date >= ' . $t_from_changed . ' AND ';
        }
        if ($t_to_changed) {
            $where .= ' e.entry_changed_date <= ' . $t_to_changed . ' AND ';
        }
        if ($t_from_start) {
            $where .= ' e.entry_start_date >= ' . $t_from_start . ' AND ';
        }
        if ($t_to_start) {
            $where .= ' e.entry_start_date <= ' . $t_to_start . ' AND ';
        }
        if ($t_from_fixed) {
            $where .= ' e.entry_fixed_date >= ' . $t_from_fixed . ' AND ';
        }
        if ($t_to_fixed) {
            $where .= ' e.entry_fixed_date <= ' . $t_to_fixed . ' AND ';
        }
        if (FWS_String::substr($where, -5) == ' AND ') {
            $where = FWS_String::substr($where, 0, -5);
        } else {
            $where = FWS_String::substr($where, 0, -7);
        }
        $order = $input->get_predef(TDL_URL_ORDER, 'get', 'changed');
        $base_url = new TDL_URL();
        $base_url->set(TDL_URL_S_KEYWORD, $s_keyword);
        $base_url->set(TDL_URL_S_CATEGORY, $s_category);
        $base_url->set(TDL_URL_S_PRIORITY, $s_priority);
        $base_url->set(TDL_URL_S_TYPE, $s_type);
        $base_url->set(TDL_URL_S_STATUS, $s_status);
        $base_url->set(TDL_URL_S_FROM_CHANGED_DATE, $s_from_changed_date);
        $base_url->set(TDL_URL_S_FROM_START_DATE, $s_from_start_date);
        $base_url->set(TDL_URL_S_FROM_FIXED_DATE, $s_from_fixed_date);
        $base_url->set(TDL_URL_S_TO_CHANGED_DATE, $s_to_changed_date);
        $base_url->set(TDL_URL_S_TO_START_DATE, $s_to_start_date);
        $base_url->set(TDL_URL_S_TO_FIXED_DATE, $s_to_fixed_date);
        $num = $db->get_row_count(TDL_TB_ENTRIES . ' e', 'e.id', ' LEFT JOIN ' . TDL_TB_CATEGORIES . ' c ON entry_category = c.id ' . $where);
        $site = $input->get_predef(TDL_URL_SITE, 'get');
        $order_url = clone $base_url;
        $order_url->set(TDL_URL_SITE, $site);
        $tpl->add_variables(array('num' => $num, 'date_comps' => $locale->get_date_order(), 'search_target' => $input->get_var('PHP_SELF', 'server', FWS_Input::STRING), 'cookie_name' => TDL_COOKIE_PREFIX . 'display_search_form', 'search_display_value' => $search_display_value == 1 ? 'block' : 'none', 's_keyword_param' => TDL_URL_S_KEYWORD, 's_from_start_date_param' => TDL_URL_S_FROM_START_DATE, 's_to_start_date_param' => TDL_URL_S_TO_START_DATE, 's_from_fixed_date_param' => TDL_URL_S_FROM_FIXED_DATE, 's_to_fixed_date_param' => TDL_URL_S_TO_FIXED_DATE, 's_from_changed_date_param' => TDL_URL_S_FROM_CHANGED_DATE, 's_to_changed_date_param' => TDL_URL_S_TO_CHANGED_DATE, 's_keyword' => stripslashes($s_keyword), 's_from_changed_date' => $s_from_changed_date, 's_to_changed_date' => $s_to_changed_date, 's_from_start_date' => $s_from_start_date, 's_to_start_date' => $s_to_start_date, 's_from_fixed_date' => $s_from_fixed_date, 's_to_fixed_date' => $s_to_fixed_date, 's_type_combo' => $s_type_combo, 's_priority_combo' => $s_priority_combo, 's_status_combo' => $s_status_combo, 's_category_combo' => $s_category_combo, 'type_col' => $functions->get_order_column($locale->_('Type'), 'type', 'ASC', $order, $order_url), 'title_col' => $functions->get_order_column($locale->_('Title'), 'title', 'ASC', $order, $order_url), 'project_col' => $functions->get_order_column($locale->_('Project'), 'project', 'ASC', $order, $order_url), 'start_col' => $functions->get_order_column($locale->_('Start'), 'start', 'DESC', $order, $order_url), 'fixed_col' => $functions->get_order_column($locale->_('Fixed'), 'fixed', 'DESC', $order, $order_url)));
        $ad = $input->get_predef(TDL_URL_AD, 'get', 'DESC');
        switch ($order) {
            case 'type':
                $sql_order = 'e.entry_type ' . $ad . ', e.entry_priority ' . $ad;
                break;
            case 'title':
                $sql_order = 'e.entry_title ' . $ad;
                break;
            case 'project':
                $sql_order = 'e.project_id ' . $ad . ', e.entry_category ' . $ad;
                break;
            case 'start':
                $sql_order = 'e.entry_start_date ' . $ad . ',e.id ' . $ad;
                break;
            case 'fixed':
                $sql_order = 'e.entry_fixed_date ' . $ad . ',e.id ' . $ad;
                break;
            default:
                $sql_order = 'e.entry_changed_date ' . $ad . ',e.id ' . $ad;
                break;
        }
        $limit = 20;
        $pagination = new TDL_Pagination($limit, $num);
        $hl = new FWS_KeywordHighlighter(array($s_keyword));
        $entries = array();
        $rows = $db->get_rows('SELECT e.*,c.category_name FROM ' . TDL_TB_ENTRIES . ' e
			 LEFT JOIN ' . TDL_TB_CATEGORIES . ' c ON entry_category = c.id
			 ' . $where . '
			 ORDER BY ' . $sql_order . '
			 LIMIT ' . $pagination->get_start() . ',' . $limit);
        $i = 0;
        foreach ($rows as $data) {
            $type_text = $functions->get_type_text($data['entry_type']);
            $priority_text = $functions->get_priority_text($data['entry_priority']);
            $start_version = $versions->get_element($data['entry_start_version']);
            if ($data['entry_fixed_date'] > 0) {
                if ($data['entry_fixed_version'] > 0) {
                    $fixed_version = $versions->get_element($data['entry_fixed_version']);
                } else {
                    $fixed_version = $versions->get_element($data['entry_start_version']);
                }
            }
            $title = $data['entry_title'];
            if ($s_keyword) {
                $title = $hl->highlight($title);
            }
            $entries[] = array('start_date' => FWS_Date::get_date($data['entry_start_date']), 'start_version' => $start_version['version_name'], 'project_name' => $start_version['project_name'], 'project_name_short' => $start_version['project_name_short'], 'category' => $data['entry_category'] ? $data['category_name'] : '', 'project' => $project, 'fixed_date' => $data['entry_fixed_date'] ? FWS_Date::get_date($data['entry_fixed_date']) : '', 'fixed_version' => $data['entry_fixed_date'] ? $fixed_version['version_name'] : '', 'title' => $title, 'info_link' => $data['entry_info_link'], 'priority' => $data['entry_priority'], 'type' => $data['entry_type'], 'type_text' => $type_text, 'priority_text' => $priority_text, 'image' => $data['entry_description'] != '' ? 'details_available' : 'details_not_available', 'id' => $data['id'], 'status' => $functions->get_status_text($data['entry_status']), 'class' => 'tl_status_' . $data['entry_status'], 'description' => nl2br($data['entry_description']));
            $i++;
        }
        $tpl->add_variable_ref('entries', $entries);
        $base_url->set(TDL_URL_ORDER, $order);
        $base_url->set(TDL_URL_AD, $ad);
        $pagination->populate_tpl($base_url);
        $edit_base = clone $base_url;
        $edit_base->set_separator('&');
        $edit_base->set(TDL_URL_IDS, '__IDS__');
        $edit_url = clone $edit_base;
        $edit_url->set(TDL_URL_ACTION, 'edit_entry');
        $edit_url->set(TDL_URL_MODE, 'edit');
        $chgstate_url = clone $edit_base;
        $chgstate_url->set(TDL_URL_ACTION, 'change_status');
        $del_url = clone $edit_base;
        $del_url->set(TDL_URL_ACTION, 'ajax_delmsg');
        $del_url->set(TDL_URL_LOC, 'view_entries');
        $tpl->add_variables(array('index' => $i, 'edit_url' => $edit_url->to_url(), 'chgstate_url' => $chgstate_url->to_url(), 'del_url' => $del_url->to_url()));
    }
Пример #5
0
    /**
     * @see FWS_Module::run()
     */
    public function run()
    {
        $input = FWS_Props::get()->input();
        $cfg = FWS_Props::get()->cfg();
        $versions = FWS_Props::get()->versions();
        $tpl = FWS_Props::get()->tpl();
        $db = FWS_Props::get()->db();
        $functions = FWS_Props::get()->functions();
        $user = FWS_Props::get()->user();
        $locale = FWS_Props::get()->locale();
        $mode = $input->get_predef(TDL_URL_MODE, 'get');
        if ($mode == 'export') {
            $this->_export();
            return;
        }
        $where = ' WHERE entry_fixed_date > 0';
        if ($cfg['project_id'] != 0) {
            $sel_version = $versions->get_element_with(array('project_id' => $cfg['project_id']));
            $title = $sel_version['project_name'];
            $where .= ' AND e.project_id = ' . $cfg['project_id'];
        } else {
            $title = $locale->_('All Projects');
        }
        $tpl->add_variables(array('title' => $title));
        $entries = array();
        $last_version = '';
        $rows = $db->get_rows('SELECT e.id,entry_title,e.project_id,entry_fixed_date,entry_start_version,
							entry_fixed_version,entry_type
			 FROM ' . TDL_TB_ENTRIES . ' e
			 LEFT JOIN ' . TDL_TB_VERSIONS . ' v ON entry_fixed_version = v.id
			 ' . $where . '
			 ORDER BY e.project_id DESC, v.version_name DESC, entry_fixed_date DESC');
        foreach ($rows as $data) {
            $tpldata = array();
            $tpldata['show_version'] = false;
            if ($last_version != $data['entry_fixed_version']) {
                $fixed_version = $versions->get_element($data['entry_fixed_version']);
                $tpldata['show_version'] = true;
                $tpldata['product_version'] = $fixed_version['project_name'] . ' :: ' . $fixed_version['version_name'];
                $last_version = $data['entry_fixed_version'];
            }
            $tpldata['type'] = $data['entry_type'];
            $tpldata['type_text'] = $functions->get_type_text($data['entry_type']);
            $tpldata['title'] = $data['entry_title'];
            $tpldata['date'] = FWS_Date::get_date($data['entry_fixed_date']);
            $entries[] = $tpldata;
        }
        $tpl->add_variable_ref('entries', $entries);
    }