/** * Method used to get the previous and next issues that are available * according to the current search parameters. * * @param integer $issue_id The issue ID * @param array $options The search parameters * @return array The list of issues */ public static function getSides($issue_id, $options) { $usr_id = Auth::getUserID(); $role_id = Auth::getCurrentRole(); $usr_details = User::getDetails($usr_id); $stmt = 'SELECT iss_id, ' . self::getLastActionFields() . ' FROM ( {{%issue}}, {{%user}}'; // join custom fields if we are searching by custom fields if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) { continue; } if ($field['fld_type'] == 'integer' && empty($search_value['value'])) { continue; } if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeString($search_value); foreach ($search_value as $cfo_id) { $stmt .= ",\n {{%issue_custom_field}} as cf" . $fld_id . '_' . $cfo_id . "\n"; } } else { $stmt .= ",\n {{%issue_custom_field}} as cf" . $fld_id . "\n"; } } } $stmt .= ')'; // check for the custom fields we want to sort by if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_id = str_replace('custom_field_', '', $options['sort_by']); $stmt .= "\n LEFT JOIN {{%issue_custom_field}} as cf_sort\n ON\n (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = {$fld_id}) \n"; } if (!empty($options['users']) || @$options['sort_by'] == 'isu_usr_id') { $stmt .= ' LEFT JOIN {{%issue_user}} ON isu_iss_id=iss_id'; } if (!empty($options['show_authorized_issues']) || $role_id == User::ROLE_REPORTER && Project::getSegregateReporters(Auth::getCurrentProject())) { $stmt .= ' LEFT JOIN {{%issue_user_replier}} ON iur_iss_id=iss_id'; } if (!empty($options['show_notification_list_issues'])) { $stmt .= ' LEFT JOIN {{%subscription}} ON sub_iss_id=iss_id'; } if (!empty($options['product'])) { $stmt .= ' LEFT JOIN {{%issue_product_version}} ON ipv_iss_id=iss_id'; } if (@$options['sort_by'] == 'pre_scheduled_date') { $stmt .= ' LEFT JOIN {{%project_release}} ON iss_pre_id = pre_id'; } if (@$options['sort_by'] == 'prc_title') { $stmt .= ' LEFT JOIN {{%project_category}} ON iss_prc_id = prc_id'; } if (!empty($usr_details['usr_par_code'])) { // restrict partners $stmt .= ' LEFT JOIN {{%issue_partner}} ON ipa_iss_id=iss_id'; } $stmt .= ' LEFT JOIN {{%status}} ON iss_sta_id=sta_id LEFT JOIN {{%project_priority}} ON iss_pri_id=pri_id LEFT JOIN {{%project_severity}} ON iss_sev_id=sev_id WHERE iss_prj_id=' . Auth::getCurrentProject(); $stmt .= Search::buildWhereClause($options); if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_details = Custom_Field::getDetails($fld_id); $sort_by = 'cf_sort.' . Custom_Field::getDBValueFieldNameByType($fld_details['fld_type']); } else { $sort_by = Misc::escapeString($options['sort_by']); } $stmt .= ' GROUP BY iss_id ORDER BY ' . $sort_by . ' ' . Misc::escapeString($options['sort_order']) . ', iss_id DESC'; try { $res = DB_Helper::getInstance()->getColumn($stmt); } catch (DbException $e) { return ''; } $index = array_search($issue_id, $res); if (!empty($res[$index + 1])) { $next = $res[$index + 1]; } if (!empty($res[$index - 1])) { $previous = $res[$index - 1]; } return array('next' => @$next, 'previous' => @$previous); }
if (is_array($fields) && count($fields) > 0) { foreach ($fields as $field) { $custom_fields[$field['fld_id']] = $field['fld_title']; $options[$field['fld_id']] = Custom_Field::getOptions($field['fld_id']); } } else { echo ev_gettext('No custom fields for this project'); exit; } if (!empty($_REQUEST['start']['Year']) && !empty($_REQUEST['start']['Month']) && !empty($_REQUEST['start']['Day'])) { $start = implode('-', $_REQUEST['start']); } else { $start = false; } if (!empty($_REQUEST['end']['Year']) && !empty($_REQUEST['end']['Month']) && !empty($_REQUEST['end']['Day'])) { $end = implode('-', $_REQUEST['end']); } else { $end = false; } if (count(@$_GET['custom_field']) > 0) { $data = Report::getCustomFieldReport(@$_GET['custom_field'], @$_GET['custom_options'], @$_GET['group_by'], $start, $end, true, @$_REQUEST['interval'], @$_REQUEST['assignee']); } if ($start == false || ($end = false)) { $start = '--'; $end = '--'; } $tpl->assign(array('custom_fields' => $custom_fields, 'custom_field' => @$_GET['custom_field'], 'options' => $options, 'custom_options' => @$_GET['custom_options'], 'group_by' => @$_GET['group_by'], 'selected_options' => @$_REQUEST['custom_options'], 'data' => @$data, 'start_date' => $start, 'end_date' => $end, 'assignees' => Project::getUserAssocList($prj_id, 'active', User::ROLE_CUSTOMER), 'assignee' => @$_REQUEST['assignee'])); if (isset($_GET['custom_field'])) { $tpl->assign(array('field_info' => Custom_Field::getDetails($_GET['custom_field']))); } $tpl->displayTemplate();
/** * Method used to get the list of issues to be displayed in the grid layout. * * @param array $options The search parameters * @return string The where clause */ public static function buildWhereClause($options) { $usr_id = Auth::getUserID(); $prj_id = Auth::getCurrentProject(); $role_id = User::getRoleByUser($usr_id, $prj_id); $usr_details = User::getDetails($usr_id); $stmt = ' AND iss_usr_id = usr_id'; if ($role_id == User::getRoleID('Customer')) { $crm = CRM::getInstance($prj_id); $contact = $crm->getContact($usr_details['usr_customer_contact_id']); $stmt .= " AND iss_customer_contract_id IN('" . implode("','", $contact->getContractIDS()) . "')"; $stmt .= " AND iss_customer_id ='" . Auth::getCurrentCustomerID() . "'"; } elseif ($role_id == User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id)) { $stmt .= " AND (\n iss_usr_id = {$usr_id} OR\n iur_usr_id = {$usr_id}\n )"; } if (!empty($usr_details['usr_par_code'])) { // restrict partners $stmt .= " AND ipa_par_code = '" . Misc::escapeString($usr_details['usr_par_code']) . "'"; } if (!empty($options['users'])) { $stmt .= " AND (\n"; if (stristr($options['users'], 'grp') !== false) { $chunks = explode(':', $options['users']); $stmt .= 'iss_grp_id = ' . Misc::escapeInteger($chunks[1]); } else { if ($options['users'] == '-1') { $stmt .= 'isu_usr_id IS NULL'; } elseif ($options['users'] == '-2') { $stmt .= 'isu_usr_id IS NULL OR isu_usr_id=' . $usr_id; } elseif ($options['users'] == '-3') { $stmt .= 'isu_usr_id = ' . $usr_id . ' OR iss_grp_id = ' . User::getGroupID($usr_id); } elseif ($options['users'] == '-4') { $stmt .= 'isu_usr_id IS NULL OR isu_usr_id = ' . $usr_id . ' OR iss_grp_id = ' . User::getGroupID($usr_id); } else { $stmt .= 'isu_usr_id =' . Misc::escapeInteger($options['users']); } } $stmt .= ')'; } if (!empty($options['reporter'])) { $stmt .= ' AND iss_usr_id = ' . Misc::escapeInteger($options['reporter']); } if (!empty($options['show_authorized_issues'])) { $stmt .= " AND (iur_usr_id={$usr_id})"; } if (!empty($options['show_notification_list_issues'])) { $stmt .= " AND (sub_usr_id={$usr_id})"; } if (!empty($options['keywords'])) { $stmt .= " AND (\n"; if ($options['search_type'] == 'all_text' && APP_ENABLE_FULLTEXT) { $stmt .= 'iss_id IN(' . implode(', ', self::getFullTextIssues($options)) . ')'; } elseif ($options['search_type'] == 'customer' && CRM::hasCustomerIntegration($prj_id)) { // check if the user is trying to search by customer name / email $crm = CRM::getInstance($prj_id); $customer_ids = $crm->getCustomerIDsByString($options['keywords'], true); if (count($customer_ids) > 0) { $stmt .= ' iss_customer_id IN (' . implode(', ', $customer_ids) . ')'; } else { // no results, kill query $stmt .= ' iss_customer_id = -1'; } } else { $stmt .= '(' . Misc::prepareBooleanSearch('iss_summary', $options['keywords']); $stmt .= ' OR ' . Misc::prepareBooleanSearch('iss_description', $options['keywords']) . ')'; } $stmt .= "\n) "; } if (!empty($options['customer_id'])) { $stmt .= " AND iss_customer_id='" . Misc::escapeString($options['customer_id']) . "'"; } if (!empty($options['priority'])) { $stmt .= ' AND iss_pri_id=' . Misc::escapeInteger($options['priority']); } if (!empty($options['status'])) { $stmt .= ' AND iss_sta_id=' . Misc::escapeInteger($options['status']); } if (!empty($options['category'])) { if (!is_array($options['category'])) { $options['category'] = array($options['category']); } $stmt .= ' AND iss_prc_id IN(' . implode(', ', Misc::escapeInteger($options['category'])) . ')'; } if (!empty($options['hide_closed'])) { $stmt .= ' AND sta_is_closed=0'; } if (!empty($options['release'])) { $stmt .= ' AND iss_pre_id = ' . Misc::escapeInteger($options['release']); } if (!empty($options['product'])) { $stmt .= ' AND ipv_pro_id = ' . Misc::escapeInteger($options['product']); } // now for the date fields $date_fields = array('created_date', 'updated_date', 'last_response_date', 'first_response_date', 'closed_date'); foreach ($date_fields as $field_name) { if (!empty($options[$field_name])) { switch ($options[$field_name]['filter_type']) { case 'greater': $stmt .= " AND iss_{$field_name} >= '" . Misc::escapeString($options[$field_name]['start']) . "'"; break; case 'less': $stmt .= " AND iss_{$field_name} <= '" . Misc::escapeString($options[$field_name]['start']) . "'"; break; case 'between': $stmt .= " AND iss_{$field_name} BETWEEN '" . Misc::escapeString($options[$field_name]['start']) . "' AND '" . Misc::escapeString($options[$field_name]['end']) . "'"; break; case 'null': $stmt .= " AND iss_{$field_name} IS NULL"; break; case 'in_past': if (strlen($options[$field_name]['time_period']) == 0) { $options[$field_name]['time_period'] = 0; } $stmt .= " AND (UNIX_TIMESTAMP('" . Date_Helper::getCurrentDateGMT() . "') - UNIX_TIMESTAMP(iss_{$field_name})) <= (" . Misc::escapeInteger($options[$field_name]['time_period']) . '*3600)'; break; } } } // custom fields if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); $fld_db_name = Custom_Field::getDBValueFieldNameByType($field['fld_type']); if ($field['fld_type'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) { continue; } if ($field['fld_type'] == 'integer' && empty($search_value['value'])) { continue; } if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeString($search_value); foreach ($search_value as $cfo_id) { $cfo_id = Misc::escapeString($cfo_id); $stmt .= " AND\n cf" . $fld_id . '_' . $cfo_id . '.icf_iss_id = iss_id'; $stmt .= " AND\n cf" . $fld_id . '_' . $cfo_id . ".icf_fld_id = {$fld_id}"; $stmt .= " AND\n cf" . $fld_id . '_' . $cfo_id . '.' . $fld_db_name . " = '{$cfo_id}'"; } } elseif ($field['fld_type'] == 'date') { if (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day'])) { continue; } $search_value = $search_value['Year'] . '-' . $search_value['Month'] . '-' . $search_value['Day']; $stmt .= " AND\n (iss_id = cf" . $fld_id . '.icf_iss_id AND cf' . $fld_id . '.' . $fld_db_name . " = '" . Misc::escapeString($search_value) . "')"; } elseif ($field['fld_type'] == 'integer') { $value = $search_value['value']; switch ($search_value['filter_type']) { case 'ge': $cmp = '>='; break; case 'le': $cmp = '<='; break; case 'gt': $cmp = '>'; break; case 'lt': $cmp = '<'; break; default: $cmp = '='; break; } $stmt .= " AND\n (iss_id = cf" . $fld_id . '.icf_iss_id'; $stmt .= " AND\n cf" . $fld_id . ".icf_fld_id = {$fld_id}"; $stmt .= ' AND cf' . $fld_id . '.' . $fld_db_name . $cmp . Misc::escapeString($value) . ')'; } else { $stmt .= " AND\n (iss_id = cf" . $fld_id . '.icf_iss_id'; $stmt .= " AND\n cf" . $fld_id . ".icf_fld_id = {$fld_id}"; if ($field['fld_type'] == 'combo') { $stmt .= ' AND cf' . $fld_id . '.' . $fld_db_name . " IN('" . implode("', '", Misc::escapeString($search_value)) . "')"; } else { $stmt .= ' AND cf' . $fld_id . '.' . $fld_db_name . " LIKE '%" . Misc::escapeString($search_value) . "%'"; } $stmt .= ')'; } } } // clear cached full-text values if we are not searching fulltext anymore if (APP_ENABLE_FULLTEXT && @$options['search_type'] != 'all_text') { Session::set('fulltext_string', ''); Session::set('fulltext_issues', ''); } return $stmt; }
/** * Generates a graph for the selected custom field. * * @param string $type * @param int $custom_field The id of the custom field. * @param array $custom_options An array of option ids. * @param string $group_by How the data should be grouped. * @param string $start * @param string $end * @param string $interval * @return bool */ public function CustomFieldGraph($type, $custom_field, $custom_options, $group_by, $start, $end, $interval) { $data = Report::getCustomFieldReport($custom_field, $custom_options, $group_by, $start, $end, false, $interval); if (count($data) < 2) { return false; } $field_details = Custom_Field::getDetails($custom_field); // convert to phplot format $i = 0; $plotData = $labels = array(); unset($data['All Others']); foreach ($data as $label => $value) { $plotData[$i] = array($label, $value); $labels[] = $label; $i++; } if ($type == 'pie') { $plot = $this->create(500, 300); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); } else { // bar chart $plot = $this->create(500, 350); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetXTitle($field_details['fld_title']); $plot->SetYTitle(ev_gettext('Issue Count')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetYDataLabelPos('plotin'); } if ($group_by == 'customers') { $title = ev_gettext('Customers by %s', $field_details['fld_title']); } else { $title = ev_gettext('Issues by %s', $field_details['fld_title']); } $plot->SetDataValues($plotData); $plot->SetLegend($labels); $plot->SetImageBorderType('plain'); $plot->SetTitle($title); return $plot->DrawGraph(); }
/** * Method used to update the details for a specific custom field. * * @access public * @return integer 1 if the update worked, -1 otherwise */ function update() { global $HTTP_POST_VARS; if (empty($HTTP_POST_VARS["report_form"])) { $HTTP_POST_VARS["report_form"] = 0; } if (empty($HTTP_POST_VARS["report_form_required"])) { $HTTP_POST_VARS["report_form_required"] = 0; } if (empty($HTTP_POST_VARS["anon_form"])) { $HTTP_POST_VARS["anon_form"] = 0; } if (empty($HTTP_POST_VARS["anon_form_required"])) { $HTTP_POST_VARS["anon_form_required"] = 0; } if (empty($HTTP_POST_VARS["list_display"])) { $HTTP_POST_VARS["list_display"] = 0; } if (empty($HTTP_POST_VARS["min_role"])) { $HTTP_POST_VARS["min_role"] = 1; } if (!isset($HTTP_POST_VARS["rank"])) { $HTTP_POST_VARS["rank"] = Custom_Field::getMaxRank() + 1; } $old_details = Custom_Field::getDetails($HTTP_POST_VARS["id"]); $stmt = "UPDATE\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field\n SET\n fld_title='" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n fld_description='" . Misc::escapeString($HTTP_POST_VARS["description"]) . "',\n fld_type='" . Misc::escapeString($HTTP_POST_VARS["field_type"]) . "',\n fld_report_form=" . Misc::escapeInteger($HTTP_POST_VARS["report_form"]) . ",\n fld_report_form_required=" . Misc::escapeInteger($HTTP_POST_VARS["report_form_required"]) . ",\n fld_anonymous_form=" . Misc::escapeInteger($HTTP_POST_VARS["anon_form"]) . ",\n fld_anonymous_form_required=" . Misc::escapeInteger($HTTP_POST_VARS["anon_form_required"]) . ",\n fld_list_display=" . Misc::escapeInteger($HTTP_POST_VARS["list_display"]) . ",\n fld_min_role=" . Misc::escapeInteger($HTTP_POST_VARS['min_role']) . ",\n fld_rank = " . Misc::escapeInteger($HTTP_POST_VARS['rank']) . ",\n fld_backend = '" . Misc::escapeString(@$HTTP_POST_VARS['custom_field_backend']) . "'\n WHERE\n fld_id=" . Misc::escapeInteger($HTTP_POST_VARS["id"]); $res = $GLOBALS["db_api"]->dbh->query($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return -1; } else { // if the current custom field is a combo box, get all of the current options if (in_array($HTTP_POST_VARS["field_type"], array('combo', 'multiple'))) { $stmt = "SELECT\n cfo_id\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option\n WHERE\n cfo_fld_id=" . Misc::escapeInteger($HTTP_POST_VARS["id"]); $current_options = $GLOBALS["db_api"]->dbh->getCol($stmt); } // gotta remove all custom field options if the field is being changed from a combo box to a text field if ($old_details["fld_type"] != $HTTP_POST_VARS["field_type"] && !in_array($old_details['fld_type'], array('text', 'textarea')) && !in_array($HTTP_POST_VARS["field_type"], array('combo', 'multiple'))) { Custom_Field::removeOptionsByFields($HTTP_POST_VARS["id"]); } // update the custom field options, if any if ($HTTP_POST_VARS["field_type"] == "combo" || $HTTP_POST_VARS["field_type"] == "multiple") { $updated_options = array(); if (empty($HTTP_POST_VARS['custom_field_backend'])) { foreach ($HTTP_POST_VARS["field_options"] as $option_value) { $params = Custom_Field::parseParameters($option_value); if ($params["type"] == 'new') { Custom_Field::addOptions($HTTP_POST_VARS["id"], $params["value"]); } else { $updated_options[] = $params["id"]; // check if the user is trying to update the value of this option if ($params["value"] != Custom_Field::getOptionValue($HTTP_POST_VARS["id"], $params["id"])) { Custom_Field::updateOption($params["id"], $params["value"]); } } } } } // get the diff between the current options and the ones posted by the form // and then remove the options not found in the form submissions if (in_array($HTTP_POST_VARS["field_type"], array('combo', 'multiple'))) { $diff_ids = @array_diff($current_options, $updated_options); if (@count($diff_ids) > 0) { Custom_Field::removeOptions($HTTP_POST_VARS['id'], array_values($diff_ids)); } } // now we need to check for any changes in the project association of this custom field // and update the mapping table accordingly $old_proj_ids = @array_keys(Custom_Field::getAssociatedProjects($HTTP_POST_VARS["id"])); // COMPAT: this next line requires PHP > 4.0.4 $diff_ids = array_diff($old_proj_ids, $HTTP_POST_VARS["projects"]); if (count($diff_ids) > 0) { foreach ($diff_ids as $removed_prj_id) { Custom_Field::removeIssueAssociation($HTTP_POST_VARS["id"], false, $removed_prj_id); } } // update the project associations now $stmt = "DELETE FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_custom_field\n WHERE\n pcf_fld_id=" . Misc::escapeInteger($HTTP_POST_VARS["id"]); $res = $GLOBALS["db_api"]->dbh->query($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return -1; } else { for ($i = 0; $i < count($HTTP_POST_VARS["projects"]); $i++) { Custom_Field::associateProject($HTTP_POST_VARS["projects"][$i], $HTTP_POST_VARS["id"]); } } return 1; } }
/** * Returns an array of information about all the different filter fields. * * @return array an array of information. */ public static function getFiltersInfo() { // format is "name_of_db_field" => array( // "title" => human readable title, // "param" => name that appears in get, post or cookie $fields = array('iss_pri_id' => array('title' => ev_gettext('Priority'), 'param' => 'priority', 'quickfilter' => true), 'iss_sev_id' => array('title' => ev_gettext('Severity'), 'param' => 'severity', 'quickfilter' => true), 'keywords' => array('title' => ev_gettext('Keyword(s)'), 'param' => 'keywords', 'quickfilter' => true), 'users' => array('title' => ev_gettext('Assigned'), 'param' => 'users', 'quickfilter' => true), 'iss_prc_id' => array('title' => ev_gettext('Category'), 'param' => 'category', 'quickfilter' => true), 'iss_sta_id' => array('title' => ev_gettext('Status'), 'param' => 'status', 'quickfilter' => true), 'iss_pre_id' => array('title' => ev_gettext('Release'), 'param' => 'release'), 'created_date' => array('title' => ev_gettext('Created Date'), 'param' => 'created_date', 'is_date' => true), 'updated_date' => array('title' => ev_gettext('Updated Date'), 'param' => 'updated_date', 'is_date' => true), 'last_response_date' => array('title' => ev_gettext('Last Response Date'), 'param' => 'last_response_date', 'is_date' => true), 'first_response_date' => array('title' => ev_gettext('First Response Date'), 'param' => 'first_response_date', 'is_date' => true), 'closed_date' => array('title' => ev_gettext('Closed Date'), 'param' => 'closed_date', 'is_date' => true), 'rows' => array('title' => ev_gettext('Rows Per Page'), 'param' => 'rows'), 'sort_by' => array('title' => ev_gettext('Sort By'), 'param' => 'sort_by'), 'sort_order' => array('title' => ev_gettext('Sort Order'), 'param' => 'sort_order'), 'hide_closed' => array('title' => ev_gettext('Hide Closed Issues'), 'param' => 'hide_closed'), 'show_authorized' => array('title' => ev_gettext('Authorized to Send Emails'), 'param' => 'show_authorized_issues'), 'show_notification_list' => array('title' => ev_gettext('In Notification List'), 'param' => 'show_notification_list_issues'), 'search_type' => array('title' => ev_gettext('Search Type'), 'param' => 'search_type'), 'reporter' => array('title' => ev_gettext('Reporter'), 'param' => 'reporter'), 'customer_id' => array('title' => ev_gettext('Customer'), 'param' => 'customer_id'), 'pro_id' => array('title' => ev_gettext('Product'), 'param' => 'product')); // add custom fields $custom_fields = Custom_Field::getFieldsByProject(Auth::getCurrentProject()); if (count($custom_fields) > 0) { foreach ($custom_fields as $fld_id) { $field = Custom_Field::getDetails($fld_id); $fields['custom_field_' . $fld_id] = array('title' => $field['fld_title'], 'is_custom' => 1, 'fld_id' => $fld_id, 'fld_type' => $field['fld_type']); } } return $fields; }
Auth::checkAuthentication(APP_COOKIE); $tpl->assign("type", "custom_fields"); $role_id = Auth::getCurrentRole(); if ($role_id == User::getRoleID('administrator')) { $tpl->assign("show_setup_links", true); if (@$HTTP_POST_VARS["cat"] == "new") { $tpl->assign("result", Custom_Field::insert()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Custom_Field::update()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Custom_Field::remove(); } elseif (@$_REQUEST["cat"] == "change_rank") { Custom_Field::changeRank(); } if (@$HTTP_GET_VARS["cat"] == "edit") { $tpl->assign("info", Custom_Field::getDetails($HTTP_GET_VARS["id"])); } $excluded_roles = array(); if (!Customer::hasCustomerIntegration(Auth::getCurrentProject())) { $excluded_roles[] = "customer"; } $user_roles = User::getRoles($excluded_roles); $user_roles[9] = "Never Display"; $tpl->assign("list", Custom_Field::getList()); $tpl->assign("project_list", Project::getAll()); $tpl->assign("user_roles", $user_roles); $tpl->assign("backend_list", Custom_Field::getBackendList()); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } $tpl->assign('project_list', Project::getAll()); if (@$_POST['cat'] == 'new') { $res = Custom_Field::insert(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the custom field was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new custom field.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'update') { $res = Custom_Field::update(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the custom field was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the custom field information.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'delete') { $res = Custom_Field::remove(); Misc::mapMessages($res, array(true => array(ev_gettext('Thank you, the custom field was removed successfully.'), Misc::MSG_INFO), false => array(ev_gettext('An error occurred while trying to remove the custom field information.'), Misc::MSG_ERROR))); } elseif (@$_REQUEST['cat'] == 'change_rank') { Custom_Field::changeRank(); } if (@$_GET['cat'] == 'edit') { $tpl->assign('info', Custom_Field::getDetails($_GET['id'])); } $excluded_roles = array(); if (!CRM::hasCustomerIntegration(Auth::getCurrentProject())) { $excluded_roles[] = 'customer'; } $user_roles = User::getRoles($excluded_roles); $user_roles[9] = 'Never Display'; $tpl->assign('list', Custom_Field::getList()); $tpl->assign('project_list', Project::getAll()); $tpl->assign('user_roles', $user_roles); $tpl->assign('backend_list', Custom_Field::getBackendList()); $tpl->displayTemplate();
/** * Method used to get the previous and next issues that are available * according to the current search parameters. * * @access public * @param integer $issue_id The issue ID * @param array $options The search parameters * @return array The list of issues */ function getSides($issue_id, $options) { $usr_id = Auth::getUserID(); $role_id = Auth::getCurrentRole(); $stmt = "SELECT\n iss_id,\n " . Issue::getLastActionFields() . "\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . ETEL_USER_TABLE_NOSUB . ""; // join custom fields if we are searching by custom fields if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeInteger($search_value); foreach ($search_value as $cfo_id) { $stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . '_' . $cfo_id . "\n"; } } else { $stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . "\n"; } } } $stmt .= ")"; // check for the custom fields we want to sort by if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_id = str_replace("custom_field_", '', $options['sort_by']); $stmt .= "\n LEFT JOIN \n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf_sort\n ON\n (icf_iss_id = iss_id AND icf_fld_id = {$fld_id}) \n"; } if (!empty($options["users"]) || $role_id <= User::getRoleID("Standard User") && Project::getSegregateReporters(Auth::getCurrentProject())) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id"; } if (!empty($options["show_authorized_issues"]) || $role_id <= User::getRoleID("Standard User") && Project::getSegregateReporters(Auth::getCurrentProject())) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier\n ON\n iur_iss_id=iss_id"; } if (!empty($options["show_notification_list_issues"])) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription\n ON\n sub_iss_id=iss_id"; } if (@$options['sort_by'] == 'prc_title') { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category\n ON\n iss_prc_id = prc_id"; } $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n ON\n iss_sta_id=sta_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority\n ON\n iss_pri_id=pri_id\n WHERE\n iss_prj_id=" . Auth::getCurrentProject(); $stmt .= Issue::buildWhereClause($options); if (strstr($options["sort_by"], 'custom_field') !== false) { $sort_by = 'cf_sort.icf_value'; } else { $sort_by = Misc::escapeString($options["sort_by"]); } $stmt .= "\n GROUP BY\n iss_id\n ORDER BY\n " . $sort_by . " " . Misc::escapeString($options["sort_order"]) . ",\n iss_id DESC"; $res = $GLOBALS["db_api"]->dbh->getCol($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return ""; } else { // COMPAT: the next line requires PHP >= 4.0.5 $index = array_search($issue_id, $res); if (!empty($res[$index + 1])) { $next = $res[$index + 1]; } if (!empty($res[$index - 1])) { $previous = $res[$index - 1]; } return array("next" => @$next, "previous" => @$previous); } }
include_once APP_INC_PATH . "class.report.php"; include_once APP_INC_PATH . "class.custom_field.php"; include_once APP_INC_PATH . "db_access.php"; include_once APP_JPGRAPH_PATH . "jpgraph.php"; include_once APP_JPGRAPH_PATH . "jpgraph_bar.php"; include_once APP_JPGRAPH_PATH . "jpgraph_pie.php"; Auth::checkAuthentication(APP_COOKIE); if (Auth::getCurrentRole() <= User::getRoleID("Customer")) { echo "Invalid role"; exit; } /** * Generates a graph for the selected custom field */ $data = Report::getCustomFieldReport(@$HTTP_GET_VARS["custom_field"], @$HTTP_GET_VARS["custom_options"], @$HTTP_GET_VARS["group_by"]); $field_details = Custom_Field::getDetails(@$HTTP_GET_VARS["custom_field"]); if (count($data) < 2) { header("Location: " . APP_RELATIVE_URL . "images/no_data.gif"); } if (@$HTTP_GET_VARS["type"] == "pie") { if (empty($data["All Others"])) { unset($data["All Others"]); } // A new graph $graph = new PieGraph(500, 300, "auto"); // The pie plot $plot = new PiePlot(array_values($data)); $plot->SetTheme('pastel'); // Move center of pie to the left to make better room // for the legend $plot->SetCenter(0.26, 0.55);
$assign_options['-4'] = 'myself, un-assigned and my group'; } if (count($groups) > 0 && Auth::getCurrentRole() > User::getRoleID("Customer")) { foreach ($groups as $grp_id => $grp_name) { $assign_options["grp:{$grp_id}"] = "Group: " . $grp_name; } } $assign_options += $users; // get display values for custom fields $custom_fields_display = array(); if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'combo' || $field['fld_type'] == 'multiple') { $custom_fields_display[$fld_id] = join(', ', Custom_Field::getOptions($fld_id, $search_value)); } } } $list = Issue::getListing($prj_id, $options, $pagerRow, $rows); $tpl->assign("list", $list["list"]); $tpl->assign("list_info", $list["info"]); $tpl->assign("csv_data", base64_encode(@$list["csv"])); $tpl->assign("columns", Display_Column::getColumnsToDisplay($prj_id, 'list_issues')); $tpl->assign("priorities", Priority::getAssocList($prj_id)); $tpl->assign("status", Status::getAssocStatusList($prj_id)); $tpl->assign("open_status", Status::getAssocStatusList($prj_id, true)); $tpl->assign("users", $users); $tpl->assign("assign_options", $assign_options);