Example #1
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);
     }
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $user = FWS_Props::get()->user();
     $folderstr = $input->get_var('folders', 'post', FWS_Input::STRING);
     $exclstr = $input->get_var('exclude', 'post', FWS_Input::STRING);
     $files = array();
     $folders = FWS_Array_Utils::advanced_explode("\n", $folderstr);
     $excl = FWS_Array_Utils::advanced_explode("\n", $exclstr);
     FWS_Array_Utils::trim($excl);
     // determine files to scan
     foreach ($folders as $folder) {
         $folder = trim($folder);
         if (is_file($folder)) {
             $files[] = $folder;
         } else {
             foreach (FWS_FileUtils::get_list($folder, true, true) as $item) {
                 if (!$this->is_excluded($item, $excl)) {
                     $files[] = $item;
                 }
             }
         }
     }
     // clear position, just to be sure
     $storage = new FWS_Progress_Storage_Session('ptypescan_');
     $storage->clear();
     // store in session
     $user->set_session_data('typescan_files', $files);
     // store in project
     $project = FWS_Props::get()->project();
     $project->set_type_folders($folderstr);
     $project->set_type_exclude($exclstr);
     PC_DAO::get_projects()->update($project);
     // clear previous data in the db
     PC_DAO::get_classes()->delete_by_project($project->get_id());
     PC_DAO::get_functions()->delete_by_project($project->get_id());
     PC_DAO::get_constants()->delete_by_project($project->get_id());
     PC_DAO::get_classfields()->delete_by_project($project->get_id());
     PC_DAO::get_errors()->delete_by_type(PC_Obj_Error::get_types_of(PC_Obj_Error::R_TYPESCANNER), $project->get_id());
     $this->set_redirect(true, PC_URL::get_submod_url(0, 'cliscan'));
     $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 '';
 }
Example #4
0
    /**
     * @see FWS_Module::run()
     */
    public function run()
    {
        $input = FWS_Props::get()->input();
        $db = FWS_Props::get()->db();
        $functions = FWS_Props::get()->functions();
        $versions = FWS_Props::get()->versions();
        $tpl = FWS_Props::get()->tpl();
        $id_str = $input->get_predef(TDL_URL_IDS, 'get');
        $ids = FWS_Array_Utils::advanced_explode(',', $id_str);
        if (!FWS_Array_Utils::is_numeric($ids)) {
            $this->report_error();
            return;
        }
        $this->request_formular();
        $projects = array();
        $id_str = FWS_Array_Utils::advanced_implode(',', $ids);
        $entries = array();
        $rows = $db->get_rows('SELECT id,project_id,entry_title,entry_status FROM ' . TDL_TB_ENTRIES . '
			 WHERE id IN (' . $id_str . ')');
        foreach ($rows as $data) {
            if (!isset($projects[$data['project_id']])) {
                $projects[$data['project_id']] = true;
            }
            $entries[] = array('title' => $data['entry_title'], 'status' => $functions->get_status_text($data['entry_status']));
        }
        $version_options = array(' ');
        $rows = $versions->get_elements();
        usort($rows, array($functions, 'sort_versions_by_name_callback'));
        foreach ($rows as $row) {
            if (isset($projects[$row['project_id']])) {
                $version_options[$row['project_id'] . ',' . $row['id']] = $row['project_name'] . ' ' . $row['version_name'];
            }
        }
        next($version_options);
        $def_version = key($version_options);
        reset($version_options);
        $tpl->add_variables(array('ids' => $id_str, 'action_type' => TDL_ACTION_CHANGE_STATUS, 'status' => $functions->get_states(false), 'versions' => $version_options, 'def_version' => $def_version, 'entries' => $entries));
    }
 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;
     }
     // delete the entries
     foreach ($ids as $id) {
         $entry = new TDL_Objects_Entry(TDL_TB_ENTRIES);
         $entry->set_id($id);
         if (!$entry->check('delete')) {
             return $entry->errors();
         }
         $entry->delete();
     }
     $this->set_success_msg($locale->_('The entries have been deleted successfully'));
     $this->set_redirect(false);
     $this->set_action_performed(true);
     return '';
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $idstr = $input->get_var('ids', 'get', FWS_Input::STRING);
     $ids = FWS_Array_Utils::advanced_explode(',', $idstr);
     if (!FWS_Array_Utils::is_numeric($ids)) {
         return 'Got an invalid id-string';
     }
     PC_DAO::get_projects()->delete($ids);
     foreach ($ids as $id) {
         PC_DAO::get_calls()->delete_by_project($id);
         PC_DAO::get_classes()->delete_by_project($id);
         PC_DAO::get_classfields()->delete_by_project($id);
         PC_DAO::get_constants()->delete_by_project($id);
         PC_DAO::get_errors()->delete_by_project($id);
         PC_DAO::get_functions()->delete_by_project($id);
         PC_DAO::get_vars()->delete_by_project($id);
     }
     $this->set_redirect(false);
     $this->set_show_status_page(false);
     $this->set_action_performed(true);
     return '';
 }
Example #7
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();
 }
 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 #9
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 #10
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 #11
0
 /**
  * Builds an instance of PC_Obj_Class from the given row
  *
  * @param array $row the row from the db
  * @param int $pid the project-id
  * @param bool $lazy whether to load it lazy
  * @return PC_Obj_Class the class
  */
 private function build_class($row, $pid, $lazy = true)
 {
     $c = new PC_Obj_Class($row['file'], $row['line'], $row['id'], $pid, $lazy);
     $c->set_name($row['name']);
     $c->set_super_class($row['superclass']);
     $c->set_abstract($row['abstract']);
     $c->set_interface($row['interface']);
     $c->set_final($row['final']);
     $c->get_version()->set(unserialize($row['min_version']), unserialize($row['max_version']));
     foreach (FWS_Array_Utils::advanced_explode(',', $row['interfaces']) as $if) {
         $c->add_interface($if);
     }
     return $c;
 }