Example #1
0
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $db = FWS_Props::get()->db();
     $functions = FWS_Props::get()->functions();
     $locale = FWS_Props::get()->locale();
     $title = $input->get_var('entry_title', 'post', FWS_Input::STRING);
     $description = $input->get_var('entry_description', 'post', FWS_Input::STRING);
     $entry_info_link = $input->get_var('entry_info_link', 'post', FWS_Input::STRING);
     $category = $input->get_var('category', 'post', FWS_Input::INTEGER);
     $start_version = $input->get_var('start_version', 'post', FWS_Input::STRING);
     $fixed_version = $input->get_var('fixed_version', 'post', FWS_Input::STRING);
     $status = $input->correct_var('status', 'post', FWS_Input::STRING, array('open', 'running', 'fixed', 'not_tested', 'not_reproducable', 'need_info'), 'open');
     $type = $input->correct_var('type', 'post', FWS_Input::STRING, array('bug', 'feature', 'improvement', 'test'), 'bug');
     $priority = $input->correct_var('priority', 'post', FWS_Input::STRING, array('current', 'next', 'anytime'), 'anytime');
     @(list($start_project_id, $start_version_id) = explode(',', $start_version));
     $time = time();
     // create entry
     $entry = new TDL_Objects_Entry(TDL_TB_ENTRIES);
     $entry->set_project_id($start_project_id);
     $entry->set_entry_title($title);
     $entry->set_entry_description($description);
     $entry->set_entry_category($category);
     $entry->set_entry_start_date($time);
     $entry->set_entry_start_version($start_version_id);
     $entry->set_entry_changed_date($time);
     $entry->set_entry_status($status);
     $entry->set_entry_info_link($entry_info_link);
     $entry->set_entry_type($type);
     $entry->set_entry_priority($priority);
     // determine fixed-inputs
     $fixed_version_id = 0;
     if ($fixed_version == 0 || $status != 'fixed') {
         $entry->set_entry_fixed_date(0);
         $entry->set_entry_fixed_version(0);
     } else {
         @(list(, $fixed_version_id) = explode(',', $fixed_version));
         $entry->set_entry_fixed_date($time);
         $entry->set_entry_fixed_version($fixed_version_id);
     }
     // check for errors
     if (!$entry->check('create')) {
         return $entry->errors();
     }
     // create the object
     $entry->create();
     // update config
     $db->update(TDL_TB_CONFIG, ' WHERE is_selected = 1', array('last_start_version' => $start_version_id, 'last_fixed_version' => $fixed_version_id, 'last_category' => $category, 'last_type' => $type, 'last_priority' => $priority, 'last_status' => $status));
     $url = new TDL_URL();
     $this->add_link($locale->_('Back'), $url->set(TDL_URL_ACTION, 'view_entries'));
     $this->set_success_msg('Der Eintrag wurde erfolgreich erstellt!');
     $this->set_redirect(true, TDL_URL::get_entry_url());
     $this->set_action_performed(true);
     return '';
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $locale = FWS_Props::get()->locale();
     $project_name = $input->get_var('project_name', 'post', FWS_Input::STRING);
     $project_name_short = $input->get_var('project_name_short', 'post', FWS_Input::STRING);
     $start_day = $input->get_var('start_day', 'post', FWS_Input::INTEGER);
     $start_month = $input->get_var('start_month', 'post', FWS_Input::INTEGER);
     $start_year = $input->get_var('start_year', 'post', FWS_Input::INTEGER);
     $start = mktime(0, 0, 0, $start_month, $start_day, $start_year);
     $project = new TDL_Objects_Project(TDL_TB_PROJECTS);
     $project->set_project_name($project_name);
     $project->set_project_name_short($project_name_short);
     $project->set_project_start($start);
     if (!$project->check('create')) {
         return $project->errors();
     }
     $project->create();
     $id = $project->get_id();
     $edit_url = TDL_URL::get_mod_url('edit_project')->set(TDL_URL_MODE, 'edit')->set(TDL_URL_ID, $id);
     $this->set_success_msg($locale->_('The project has been added'));
     $this->set_redirect(true, $edit_url);
     $this->add_link($locale->_('Edit the project'), $edit_url);
     $this->set_action_performed(true);
     return '';
 }
Example #3
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $input = FWS_Props::get()->input();
     $functions = FWS_Props::get()->functions();
     $id_str = $input->get_var('ids', 'get', FWS_Input::STRING);
     $loc = $input->get_var('loc', 'get', FWS_Input::STRING);
     if (!$id_str || !$loc) {
         $this->report_error();
         return;
     }
     $ids = FWS_Array_Utils::advanced_explode(',', $id_str);
     if (FWS_Array_Utils::is_numeric($ids)) {
         switch ($loc) {
             case 'view_projects':
                 $table = TDL_TB_PROJECTS;
                 $field = 'project_name';
                 $yes_url = TDL_URL::get_mod_url('view_projects');
                 $yes_url->set(TDL_URL_AT, TDL_ACTION_DELETE_PROJECTS);
                 $yes_url->set(TDL_URL_IDS, implode(',', $ids));
                 $yes_url = $yes_url->to_url();
                 break;
             case 'view_entries':
                 $table = TDL_TB_ENTRIES;
                 $field = 'entry_title';
                 $yes_url = TDL_URL::get_mod_url(-1);
                 $yes_url->set(TDL_URL_AT, TDL_ACTION_DELETE_ENTRIES);
                 $yes_url->set(TDL_URL_IDS, implode(',', $ids));
                 $yes_url = $yes_url->to_url();
                 break;
         }
         $no_url = 'javascript:FWS_hideElement(\\\'delete_message_box\\\');';
         $functions->add_entry_delete_message($ids, $table, $field, $yes_url, $no_url);
     }
 }
Example #4
0
 /**
  * @see FWS_Module::init($doc)
  * 
  * @param TDL_Document $doc
  */
 public function init($doc)
 {
     parent::init($doc);
     $input = FWS_Props::get()->input();
     $renderer = $doc->use_default_renderer();
     $id = $input->get_predef(TDL_URL_ID, 'get');
     $renderer->add_breadcrumb('Eintrags Details', TDL_URL::get_mod_url()->set(TDL_URL_ID, $id)->to_url());
 }
Example #5
0
 /**
  * @see FWS_Module::init($doc)
  * 
  * @param TDL_Document $doc
  */
 public function init($doc)
 {
     parent::init($doc);
     $renderer = $doc->use_default_renderer();
     $locale = FWS_Props::get()->locale();
     $renderer->add_action(TDL_ACTION_DELETE_PROJECTS, 'delete');
     $renderer->add_breadcrumb($locale->_('Projects'), TDL_URL::get_mod_url()->to_url());
 }
Example #6
0
 /**
  * @see FWS_Module::init($doc)
  * 
  * @param TDL_Document $doc
  */
 public function init($doc)
 {
     parent::init($doc);
     $input = FWS_Props::get()->input();
     $renderer = $doc->use_default_renderer();
     $locale = FWS_Props::get()->locale();
     $renderer->add_action(TDL_ACTION_CHANGE_STATUS, 'default');
     $id_str = $input->get_predef(TDL_URL_IDS, 'get');
     $renderer->add_breadcrumb($locale->_('Change state'), TDL_URL::get_mod_url()->set(TDL_URL_IDS, $id_str)->to_url());
 }
Example #7
0
 /**
  * @see FWS_Module::init($doc)
  * 
  * @param TDL_Document $doc
  */
 public function init($doc)
 {
     parent::init($doc);
     $input = FWS_Props::get()->input();
     $renderer = $doc->use_default_renderer();
     $mode = $input->get_predef(TDL_URL_MODE, 'get');
     if ($mode == 'export') {
         $doc->use_raw_renderer();
     }
     $renderer->add_breadcrumb('Changelog', TDL_URL::build_mod_url('changelog'));
 }
Example #8
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->set_action_performer(new TDL_Actions_Performer());
     $tpl = FWS_Props::get()->tpl();
     $locale = FWS_Props::get()->locale();
     $tpl->set_path('theme/templates/');
     $tpl->set_cache_folder(FWS_Path::server_app() . 'cache/');
     // add the home-breadcrumb
     $this->add_breadcrumb($locale->_('TodoList'), TDL_URL::get_mod_url('view_entries')->to_url());
     $this->_action_perf->set_prefix('TDL_Action_');
     $a = new TDL_Actions_ChangeSelProject(TDL_ACTION_CHANGE_SEL_PROJECT);
     $this->_action_perf->add_action($a);
 }
Example #9
0
 /**
  * builds the text for an "order-column"
  * 
  * @param string $title the title of the column
  * @param string $order_value the value of the order-parameter
  * @param string $def_ascdesc the default value for TDL_URL_AD (ASC or DESC)
  * @param string $order the current value of TDL_URL_ORDER
  * @param TDL_URL $url the current URL
  * @return string the column-content
  */
 public function get_order_column($title, $order_value, $def_ascdesc, $order, $url)
 {
     $user = FWS_Props::get()->user();
     $ourl = $url->set(TDL_URL_ORDER, $order_value);
     if ($order == $order_value) {
         $result = $title . ' <a class="tl_coldesc" href="' . $ourl->set(TDL_URL_AD, 'ASC')->to_url() . '">';
         $result .= '<img src="' . $user->get_theme_item_path('images/asc.gif') . '" alt="ASC" border="0" />';
         $result .= '</a> ';
         $result .= '<a class="tl_coldesc" href="' . $ourl->set(TDL_URL_AD, 'DESC')->to_url() . '">';
         $result .= '<img src="' . $user->get_theme_item_path('images/desc.gif') . '" alt="DESC" border="0" />';
         $result .= '</a>';
     } else {
         $result = '<a class="tl_coldesc" href="' . $ourl->set(TDL_URL_AD, $def_ascdesc)->to_url() . '">' . $title . '</a>';
     }
     return $result;
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $db = FWS_Props::get()->db();
     $cats = FWS_Props::get()->cats();
     $versions = FWS_Props::get()->versions();
     $locale = FWS_Props::get()->locale();
     $pid = $input->get_predef(TDL_URL_ID, 'get');
     if ($pid == null) {
         return TDL_GENERAL_ERROR;
     }
     $project_name = $input->get_var('project_name', 'post', FWS_Input::STRING);
     $project_name_short = $input->get_var('project_name_short', 'post', FWS_Input::STRING);
     $start_day = $input->get_var('start_day', 'post', FWS_Input::INTEGER);
     $start_month = $input->get_var('start_month', 'post', FWS_Input::INTEGER);
     $start_year = $input->get_var('start_year', 'post', FWS_Input::INTEGER);
     $start = mktime(0, 0, 0, $start_month, $start_day, $start_year);
     $project = new TDL_Objects_Project(TDL_TB_PROJECTS);
     $project->set_id($pid);
     $project->set_project_name($project_name);
     $project->set_project_name_short($project_name_short);
     $project->set_project_start($start);
     if (!$project->check('update')) {
         return $project->errors();
     }
     $project->update();
     $nversions = $input->get_var('version', 'post');
     if (is_array($nversions)) {
         foreach ($nversions as $id => $version_name) {
             $db->execute('UPDATE ' . TDL_TB_VERSIONS . " SET version_name = '" . $version_name . "' WHERE id = " . $id);
             $versions->set_element_field($id, 'version_name', $version_name);
         }
     }
     $categories = $input->get_var('category', 'post');
     if (is_array($categories)) {
         foreach ($categories as $id => $category_name) {
             $db->execute('UPDATE ' . TDL_TB_CATEGORIES . " SET category_name = '" . $category_name . "' WHERE id = " . $id);
             $cats->set_element_field($id, 'category_name', $category_name);
         }
     }
     $this->set_success_msg($locale->_('The project has been edited successfully'));
     $this->set_redirect(true, TDL_URL::get_mod_url('edit_project')->set(TDL_URL_MODE, 'edit')->set(TDL_URL_ID, $pid));
     $this->set_show_status_page(false);
     $this->set_action_performed(true);
     return '';
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $db = FWS_Props::get()->db();
     $cats = FWS_Props::get()->cats();
     $locale = FWS_Props::get()->locale();
     $id = $input->get_predef(TDL_URL_SID, 'get');
     if ($id == null) {
         return TDL_GENERAL_ERROR;
     }
     $db->execute('DELETE FROM ' . TDL_TB_CATEGORIES . ' WHERE id = ' . $id);
     $db->execute('UPDATE ' . TDL_TB_ENTRIES . ' SET entry_category = 0 WHERE entry_category = ' . $id);
     $cats->remove_element($id);
     $pid = $input->get_predef(TDL_URL_ID, 'get');
     $this->set_success_msg($locale->_('The category has been deleted'));
     $this->set_redirect(true, TDL_URL::get_mod_url('edit_project')->set(TDL_URL_MODE, 'edit')->set(TDL_URL_ID, $pid));
     $this->set_show_status_page(false);
     $this->set_action_performed(true);
     return '';
 }
    public function perform_action()
    {
        $input = FWS_Props::get()->input();
        $db = FWS_Props::get()->db();
        $versions = FWS_Props::get()->versions();
        $locale = FWS_Props::get()->locale();
        $pid = $input->get_predef(TDL_URL_ID, 'get');
        if ($pid == null) {
            return TDL_GENERAL_ERROR;
        }
        $db->execute('INSERT INTO ' . TDL_TB_VERSIONS . ' (version_name,project_id)
			 VALUES (\'\',' . $pid . ')');
        $id = $db->get_inserted_id();
        $versions->add_element(array('id' => $id, 'version_name' => '', 'project_id' => $pid), $id);
        $this->set_success_msg($locale->_('The version has been added'));
        $this->set_redirect(true, TDL_URL::get_mod_url('edit_project')->set(TDL_URL_MODE, 'edit')->set(TDL_URL_ID, $pid));
        $this->set_show_status_page(false);
        $this->set_action_performed(true);
        return '';
    }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $locale = FWS_Props::get()->locale();
     $id_str = $input->get_predef(TDL_URL_IDS, 'get');
     $ids = FWS_Array_Utils::advanced_explode(',', $id_str);
     if (!FWS_Array_Utils::is_numeric($ids) || count($ids) == 0) {
         return TDL_GENERAL_ERROR;
     }
     // read variables from post
     $status = $input->correct_var('status', 'post', FWS_Input::STRING, array('open', 'fixed', 'running', 'not_tested', 'not_reproducable', 'need_info'), 'open');
     $fixed_version = $input->get_var('fixed_version', 'post', FWS_Input::STRING);
     if ($status == 'fixed') {
         @(list(, $fixed_version_id) = explode(',', $fixed_version));
         $fixed_date = time();
     } else {
         $fixed_date = 0;
         $fixed_version_id = 0;
     }
     // update entries
     foreach ($ids as $id) {
         // build object
         $entry = new TDL_Objects_Entry(TDL_TB_ENTRIES);
         $entry->set_id($id);
         $entry->set_entry_status($status);
         $entry->set_entry_fixed_version($fixed_version_id);
         $entry->set_entry_fixed_date($fixed_date);
         $entry->set_entry_changed_date(time());
         // write to db
         if (!$entry->check('update')) {
             return $entry->errors();
         }
         $entry->update();
     }
     $this->set_show_status_page(false);
     $this->set_success_msg($locale->_('The status has been changed successfully'));
     $this->set_action_performed(true);
     $this->set_redirect(true, TDL_URL::get_mod_url(-1));
     return '';
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $locale = FWS_Props::get()->locale();
     $id_str = $input->get_predef(TDL_URL_IDS, 'get');
     $ids = FWS_Array_Utils::advanced_explode(',', $id_str);
     if (!FWS_Array_Utils::is_numeric($ids) || count($ids) == 0) {
         return TDL_GENERAL_ERROR;
     }
     foreach ($ids as $id) {
         $project = new TDL_Objects_Project(TDL_TB_PROJECTS);
         $project->set_id($id);
         if (!$project->check('delete')) {
             return $project->errors();
         }
         $project->delete();
     }
     $this->set_success_msg($locale->_('The projects have been deleted'));
     $this->set_redirect(true, TDL_URL::get_mod_url('view_projects'));
     $this->add_link($locale->_('Back'), TDL_URL::get_mod_url('view_projects'));
     $this->set_action_performed(true);
     return '';
 }
Example #15
0
 /**
  * The default method. This generates an URL with given parameters and returns it.
  * The extern-variables (if you want it) and the session-id (if necessary)
  * will be appended.
  * The file will be <var>$_SERVER['PHP_SELF']</var>.
  *
  * @param string|int $target the action-parameter (0 = current, -1 = none)
  * @param string $additional additional parameters
  * @param string $separator the separator of the params (default is &amp;)
  * @return string the url
  */
 private static function get_url($target = 0, $additional = '', $separator = '&amp;')
 {
     $url = new TDL_URL();
     $url->set_separator($separator);
     $input = FWS_Props::get()->input();
     // add action
     $action_param = $input->get_var(TDL_URL_ACTION, 'get', FWS_Input::STRING);
     if ($target === 0 && $action_param !== null) {
         $url->set(TDL_URL_ACTION, $action_param);
     } else {
         if ($target !== -1) {
             $url->set(TDL_URL_ACTION, $target);
         } else {
             $url->set(TDL_URL_ACTION, 'view_entries');
         }
     }
     // add additional params
     foreach (FWS_Array_Utils::advanced_explode($separator, $additional) as $param) {
         @(list($k, $v) = explode('=', $param));
         $url->set($k, $v);
     }
     return $url->to_url();
 }
Example #16
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()));
    }
Example #17
0
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $functions = FWS_Props::get()->functions();
     $locale = FWS_Props::get()->locale();
     // check id
     $id = $input->get_predef(TDL_URL_IDS, 'get');
     if ($id == null) {
         return TDL_GENERAL_ERROR;
     }
     $ids = FWS_Array_Utils::advanced_explode(',', $id);
     if (count($ids) == 0) {
         return TDL_GENERAL_ERROR;
     }
     $multiple = count($ids) > 1;
     $time = time();
     if (!$multiple) {
         $title = $input->get_var('entry_title', 'post', FWS_Input::STRING);
         $description = $input->get_var('entry_description', 'post', FWS_Input::STRING);
         $info_link = $input->get_var('entry_info_link', 'post', FWS_Input::STRING);
     }
     $category = $input->get_var('category', 'post', FWS_Input::INTEGER);
     $start_version = $input->get_var('start_version', 'post', FWS_Input::STRING);
     $fixed_version = $input->get_var('fixed_version', 'post', FWS_Input::STRING);
     $status = $input->correct_var('status', 'post', FWS_Input::STRING, array('open', 'running', 'fixed', 'not_tested', 'not_reproducable', 'need_info'), 'open');
     $type = $input->correct_var('type', 'post', FWS_Input::STRING, array('bug', 'feature', 'improvement', 'test'), 'bug');
     $priority = $input->correct_var('priority', 'post', FWS_Input::STRING, array('current', 'next', 'anytime'), 'anytime');
     if ($multiple) {
         if (!$input->isset_var('use_start_version', 'post')) {
             $start_version = 0;
         }
         if (!$input->isset_var('use_fixed_version', 'post')) {
             $fixed_version = 0;
         }
         if (!$input->isset_var('use_category', 'post')) {
             $category = 0;
         }
     }
     if (!$multiple || $input->isset_var('use_start_version', 'post')) {
         @(list($start_project_id, $start_version_id) = explode(',', $start_version));
     }
     if ($fixed_version == 0 || $status != 'fixed') {
         $fixed_date = 0;
         $fixed_version_id = 0;
     } else {
         @(list(, $fixed_version_id) = explode(',', $fixed_version));
         $fixed_date = $time;
     }
     // update entries
     foreach ($ids as $id) {
         $entry = new TDL_Objects_Entry(TDL_TB_ENTRIES);
         $entry->set_id($id);
         if (isset($start_project_id)) {
             $entry->set_project_id($start_project_id);
         }
         if (!$multiple) {
             $entry->set_entry_title($title);
             $entry->set_entry_description($description);
             $entry->set_entry_info_link($info_link);
         }
         if (!$multiple || $input->isset_var('use_start_version', 'post')) {
             $entry->set_entry_start_version($start_version_id);
         }
         if (!$multiple || $input->isset_var('use_fixed_version', 'post')) {
             $entry->set_entry_fixed_version($fixed_version_id);
             $entry->set_entry_fixed_date($fixed_date);
         }
         if (!$multiple || $input->isset_var('use_category', 'post')) {
             $entry->set_entry_category($category);
         }
         if (!$multiple || $input->isset_var('use_status', 'post')) {
             $entry->set_entry_status($status);
         }
         if (!$multiple || $input->isset_var('use_type', 'post')) {
             $entry->set_entry_type($type);
         }
         if (!$multiple || $input->isset_var('use_priority', 'post')) {
             $entry->set_entry_priority($priority);
         }
         if (!$multiple || $input->get_var('change_lastchange_date', 'post', FWS_Input::INT_BOOL) == 1) {
             $entry->set_entry_changed_date($time);
         }
         if (!$entry->check('update')) {
             return $entry->errors();
         }
         $entry->update();
     }
     if ($multiple) {
         $msg = $locale->_('The entries have been edited successfully');
     } else {
         $msg = $locale->_('The entry has been edited successfully');
     }
     $this->set_success_msg($msg);
     $this->set_redirect(true, TDL_URL::get_entry_url());
     $this->set_action_performed(true);
     return '';
 }
Example #18
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $input = FWS_Props::get()->input();
     $functions = FWS_Props::get()->functions();
     $cfg = FWS_Props::get()->cfg();
     $db = FWS_Props::get()->db();
     $versions = FWS_Props::get()->versions();
     $cats = FWS_Props::get()->cats();
     $tpl = FWS_Props::get()->tpl();
     $mode = $input->correct_var(TDL_URL_MODE, 'get', FWS_Input::STRING, array('add', 'edit'), 'add');
     $id = $input->get_predef(TDL_URL_IDS, 'get');
     if ($id === null && $mode == 'edit') {
         $this->report_error();
         return;
     }
     $multiple = false;
     $base_url = TDL_URL::get_entry_url();
     $entries = array();
     $data = array('project_id' => $cfg['project_id'], 'entry_title' => '', 'entry_description' => '', 'entry_info_link' => '', 'entry_status' => $cfg['last_status'], 'entry_category' => $cfg['last_category'], 'entry_start_version' => $cfg['last_start_version'], 'entry_fixed_version' => $cfg['last_fixed_version'], 'entry_type' => $cfg['last_type'], 'entry_priority' => $cfg['last_priority']);
     $this->request_formular();
     if ($mode == 'edit') {
         $ids = FWS_Array_Utils::advanced_explode(',', $id);
         if (!FWS_Array_Utils::is_numeric($ids)) {
             $this->report_error();
             return;
         }
         $multiple = count($ids) > 1;
         if ($multiple) {
             $selected_entries = array();
             $rows = $db->get_rows('SELECT id,entry_title FROM ' . TDL_TB_ENTRIES . ' WHERE id IN (' . implode(',', $ids) . ')');
             foreach ($rows as $row) {
                 $selected_entries[] = $row['id'];
                 $entries[] = $row;
             }
             if (count($selected_entries) == 0) {
                 $this->report_error();
                 return;
             }
         } else {
             $id = (int) $id;
             if ($id <= 0) {
                 $this->report_error();
                 return;
             }
             $data = $db->get_row('SELECT * FROM ' . TDL_TB_ENTRIES . ' WHERE id = ' . $id);
             if ($data['id'] == '') {
                 $this->report_error();
                 return;
             }
         }
         $target_url = clone $base_url;
         $target_url->set(TDL_URL_ACTION, 'edit_entry');
         $target_url->set(TDL_URL_MODE, 'edit');
         $target_url->set(TDL_URL_IDS, $id);
         $action_type = TDL_ACTION_EDIT_ENTRY;
     } else {
         $target_url = clone $base_url;
         $target_url->set(TDL_URL_ACTION, 'edit_entry');
         $target_url->set(TDL_URL_MODE, 'add');
         $action_type = TDL_ACTION_NEW_ENTRY;
     }
     $version_options = array('&nbsp;');
     if ($cfg['project_id'] != 0) {
         $v_rows = $versions->get_elements_with(array('project_id' => $cfg['project_id']));
     } else {
         $v_rows = $versions->get_elements_with(array());
     }
     usort($v_rows, array($functions, 'sort_versions_by_name_callback'));
     foreach ($v_rows as $row) {
         $version_options[$row['project_id'] . ',' . $row['id']] = $row['project_name'] . ' ' . $row['version_name'];
     }
     $category_options = array('&nbsp;');
     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'];
     }
     $tpl->add_variables(array('not_multiple_edit' => !$multiple, 'mode' => $mode, 'selected_entries' => $entries, 'target_url' => $target_url->to_url(), 'action_type' => $action_type, 'def_title' => $data['entry_title'], 'def_description' => $data['entry_description'], 'def_info_link' => $data['entry_info_link'], 'start_version_combo' => $this->_get_combobox($multiple, 'start_version', $version_options, $data['project_id'] . ',' . $data['entry_start_version']), 'fixed_version_combo' => $this->_get_combobox($multiple, 'fixed_version', $version_options, $data['project_id'] . ',' . $data['entry_fixed_version']), 'category_combo' => $this->_get_combobox($multiple, 'category', $category_options, $data['entry_category']), 'status_combo' => $this->_get_combobox($multiple, 'status', $functions->get_states(false), $data['entry_status']), 'type_combo' => $this->_get_combobox($multiple, 'type', $functions->get_types(false), $data['entry_type']), 'priority_combo' => $this->_get_combobox($multiple, 'priority', $functions->get_priorities(false), $data['entry_priority']), 'back_url' => $base_url->to_url()));
 }
Example #19
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $input = FWS_Props::get()->input();
     $db = FWS_Props::get()->db();
     $cats = FWS_Props::get()->cats();
     $tpl = FWS_Props::get()->tpl();
     $versions = FWS_Props::get()->versions();
     $functions = FWS_Props::get()->functions();
     $mode = $input->correct_var(TDL_URL_MODE, 'get', FWS_Input::STRING, array('add', 'edit'), 'add');
     if ($mode == 'edit') {
         $id = $input->get_predef(TDL_URL_ID, 'get');
         if ($id === null) {
             $this->report_error();
             return;
         }
         $data = $db->get_row('SELECT * FROM ' . TDL_TB_PROJECTS . ' WHERE id = ' . $id);
         if ($data['id'] == '') {
             $this->report_error();
             return;
         }
         $target_url = TDL_URL::get_mod_url();
         $target_url->set(TDL_URL_MODE, 'edit');
         $target_url->set(TDL_URL_ID, $id);
         $action_type = TDL_ACTION_EDIT_PROJECT;
     } else {
         $data = array('project_name' => '', 'project_name_short' => '', 'project_start' => 0);
         $target_url = TDL_URL::get_mod_url();
         $target_url->set(TDL_URL_MODE, 'add');
         $action_type = TDL_ACTION_ADD_PROJECT;
     }
     $this->request_formular();
     $tplversions = '';
     $rows = $mode == 'edit' ? $versions->get_elements_with(array('project_id' => $id)) : array();
     usort($rows, array($functions, 'sort_versions_by_name_callback'));
     if (count($rows) == 0) {
         $tplversions = ' - ';
     } else {
         foreach ($rows as $row) {
             $tplversions .= $this->_get_input_delete_field($target_url, $row['id'], 'version', $row['version_name'], TDL_ACTION_DELETE_VERSION);
         }
     }
     $categories = '';
     $rows = $mode == 'edit' ? $cats->get_elements_with(array('project_id' => $id)) : array();
     if (count($rows) == 0) {
         $categories = ' - ';
     } else {
         foreach ($rows as $row) {
             $categories .= $this->_get_input_delete_field($target_url, $row['id'], 'category', $row['category_name'], TDL_ACTION_DELETE_CATEGORY);
         }
     }
     $tpl->add_variables(array('mode' => $mode, 'target_url' => $target_url->to_url(), 'action_type' => $action_type, 'def_name' => $data['project_name'], 'def_name_short' => $data['project_name_short'], 'def_start' => $data['project_start'], 'versions' => $tplversions, 'categories' => $categories, 'add_version_url' => $target_url->set(TDL_URL_AT, TDL_ACTION_ADD_VERSION)->to_url(), 'add_category_url' => $target_url->set(TDL_URL_AT, TDL_ACTION_ADD_CATEGORY)->to_url()));
 }