/** * @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); } }
/** * @see FWS_Module::run() */ public function run() { $tpl = FWS_Props::get()->tpl(); $input = FWS_Props::get()->input(); $cookies = FWS_Props::get()->cookies(); $file = $input->get_var('file', -1, FWS_Input::STRING); $msg = $input->get_var('msg', -1, FWS_Input::STRING); $types = $input->get_var('types', -1); if (!FWS_Array_Utils::is_numeric($types)) { $types = array(); } $url = PC_URL::get_mod_url(); $url->set('file', $file); $url->set('msg', $msg); if (count($types)) { $url->set('types', $types); } $surl = clone $url; $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, PC_DAO::get_errors()->get_count_with($file, $msg, $types)); $pagination->populate_tpl($url); $start = $pagination->get_start(); $errs = array(); $errors = PC_DAO::get_errors()->get_list(PC_Project::CURRENT_ID, $start, PC_ENTRIES_PER_PAGE, $file, $msg, $types); foreach ($errors as $err) { /* @var $err PC_Obj_Error */ $url = PC_URL::get_mod_url('file'); $url->set('path', $err->get_loc()->get_file()); $url->set('line', $err->get_loc()->get_line()); $url->set_anchor('l' . $err->get_loc()->get_line()); $errs[] = array('id' => $err->get_id(), 'type' => PC_Obj_Error::get_type_name($err->get_type()), 'message' => $this->get_msg($err), 'file' => $err->get_loc()->get_file(), 'line' => $err->get_loc()->get_line(), 'fileurl' => $url->to_url(), 'typeurl' => PC_URL::get_mod_url()->set('types', array($err->get_type()))->to_url()); } $this->request_formular(); $typecbs = array(); $row = -1; $i = 0; $error_types = PC_Obj_Error::get_types(); asort($error_types); foreach ($error_types as $type => $name) { if ($i % 4 == 0) { $typecbs[++$row] = array(); } $typecbs[$row][] = array('name' => 'types[' . $type . ']', 'selected' => count($types) == 0 || in_array($type, $types), 'value' => $type, 'text' => $name); $i++; } for ($i = $i % 4; $i < 4; $i++) { $typecbs[$row][] = array('name' => ''); } $callurl = PC_URL::get_mod_url('filepart'); $callurl->set('id', '__ID__'); $callurl->set('type', 'error'); $tpl->add_variables(array('errors' => $errs, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('error_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'error_search', 'file' => $file, 'msg' => $msg, 'typecbs' => $typecbs, 'get_code_url' => $callurl->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; } // 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 ''; }
/** * @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 ''; }
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 ''; }
/** * @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(' '); 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(' '); 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())); }
/** * Deletes the projects with given ids * * @param array $ids the ids * @return int the number of affected rows */ public function delete($ids) { if (!FWS_Array_Utils::is_numeric($ids) || count($ids) == 0) { FWS_Helper::def_error('numarray>0', 'ids', $ids); } $db = FWS_Props::get()->db(); $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_PROJECT_DEPS . ' WHERE project_id IN (:ids) OR dep_id IN (:ids)'); $stmt->bind(':ids', $ids); $db->execute($stmt->get_statement()); $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_PROJECTS . ' WHERE id IN (:ids)'); $stmt->bind(':ids', $ids); $db->execute($stmt->get_statement()); return $db->get_affected_rows(); }
/** * Returns all errors. Optionally you can filter the search by file and message * * @param int $pid the project-id (default = current) * @param int $start the start-position (for the LIMIT-statement) * @param int $count the max. number of rows (for the LIMIT-statement) (0 = unlimited) * @param string $file the file * @param string $msg the message * @param array $types an array of types (numeric!) * @return array all found errors */ public function get_list($pid = PC_Project::CURRENT_ID, $start = 0, $count = 0, $file = '', $msg = '', $types = array()) { $db = FWS_Props::get()->db(); if (!FWS_Helper::is_integer($start) || $start < 0) { FWS_Helper::def_error('intge0', 'start', $start); } if (!FWS_Helper::is_integer($count) || $count < 0) { FWS_Helper::def_error('intge0', 'count', $count); } if (!FWS_Array_Utils::is_numeric($types)) { FWS_Helper::def_error('numarray', 'types', $types); } $errs = array(); $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_ERRORS . ' WHERE project_id = :pid' . ($file ? ' AND file LIKE :file' : '') . ($msg ? ' AND message LIKE :msg' : '') . (count($types) ? ' AND type IN (:types)' : '') . ' ORDER BY file ASC, line ASC' . ($count > 0 ? ' LIMIT :start,:count' : '')); $stmt->bind(':pid', PC_Utils::get_project_id($pid)); if ($file) { $stmt->bind(':file', '%' . $file . '%'); } if ($msg) { $stmt->bind(':msg', '%' . $msg . '%'); } if (count($types)) { $stmt->bind(':types', $types); } if ($count > 0) { $stmt->bind(':start', $start); $stmt->bind(':count', $count); } foreach ($db->get_rows($stmt->get_statement()) as $row) { $errs[] = $this->build_error($row); } return $errs; }