Esempio n. 1
0
 /**
  * Returns an array of titles, options and current values for the specified
  * display location and issue.
  *
  * @param   integer $issue_id The ID of the issue
  * @param   string  $location The name of the location to display fields
  * @return  array An array of data.
  */
 public static function getDisplayData($issue_id, $location)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $available_fields = self::getAvailableFields();
     $fields = self::getFieldsToDisplay($issue_id, $location);
     $data = array();
     foreach ($fields as $field_name => $field_options) {
         $data[$field_name] = array('title' => $available_fields[$field_name], 'options' => self::getOptions($field_name, $issue_id), 'value' => self::getValue($issue_id, $field_name));
         if ($field_name == 'custom') {
             $data[$field_name]['custom'] = Custom_Field::getListByIssue($prj_id, $issue_id, Auth::getUserID(), $field_options);
         }
     }
     return $data;
 }
<?php

/*
 * This file is part of the Eventum (Issue Tracking System) package.
 *
 * @copyright (c) Eventum Team
 * @license GNU General Public License, version 2 or later (GPL-2+)
 *
 * For the full copyright and license information,
 * please see the COPYING and AUTHORS files
 * that were distributed with this source code.
 */
require_once __DIR__ . '/../../init.php';
Auth::checkAuthentication();
if (!empty($_REQUEST['iss_id'])) {
    $fields = Custom_Field::getListByIssue(Auth::getCurrentProject(), $_REQUEST['iss_id']);
} else {
    $fields = Custom_Field::getListByProject(Auth::getCurrentProject(), $_REQUEST['form_type']);
}
$data = array();
foreach ($fields as $field) {
    $backend = Custom_Field::getBackend($field['fld_id']);
    if (is_object($backend) && is_subclass_of($backend, 'Dynamic_Custom_Field_Backend')) {
        $field['structured_data'] = $backend->getStructuredData();
        $data[] = $field;
    }
}
header('Content-Type: text/javascript; charset=UTF-8');
$tpl = new Template_Helper();
$tpl->setTemplate('js/dynamic_custom_field.tpl.js');
$tpl->assign('fields', $data);
Esempio n. 3
0
 /**
  * @param int $issue_id
  * @return struct
  * @access protected
  */
 public function getIssueDetails($issue_id)
 {
     AuthCookie::setProjectCookie(Issue::getProjectID($issue_id));
     $res = Issue::getDetails($issue_id);
     // flatten some fields
     if (isset($res['customer'])) {
         $details = $res['customer']->getDetails();
         $res['customer'] = $details;
     }
     if (isset($res['contract'])) {
         $res['contract'] = $res['contract']->getDetails();
     }
     if (empty($res)) {
         throw new RemoteApiException("Issue #{$issue_id} could not be found");
     }
     // remove some naughty fields
     unset($res['iss_original_description']);
     // returns custom fields in an array
     $res['custom_fields'] = Custom_Field::getListByIssue($res['iss_prj_id'], $res['iss_id']);
     return $res;
 }
Esempio n. 4
0
 /**
  * Method used to get the list of issues to be displayed in the grid layout.
  *
  * @param   integer $prj_id The current project ID
  * @param   array $options The search parameters
  * @param   integer $current_row The current page number
  * @param   integer $max The maximum number of rows per page. 'ALL' for unlimited.
  * @return  array The list of issues to be displayed
  */
 public static function getListing($prj_id, $options, $current_row = 0, $max = 5)
 {
     if (strtoupper($max) == 'ALL') {
         $max = 9999999;
     }
     $start = $current_row * $max;
     // get the current user's role
     $usr_id = Auth::getUserID();
     $role_id = User::getRoleByUser($usr_id, $prj_id);
     $usr_details = User::getDetails($usr_id);
     // get any custom fields that should be displayed
     $custom_fields = Custom_Field::getFieldsToBeListed($prj_id);
     $stmt = 'SELECT
                 iss_id,
                 iss_grp_id,
                 iss_prj_id,
                 iss_sta_id,
                 iss_customer_id,
                 iss_customer_contract_id,
                 iss_created_date,
                 iss_updated_date,
                 iss_last_response_date,
                 iss_closed_date,
                 iss_last_customer_action_date,
                 iss_usr_id,
                 iss_summary,
                 pri_title,
                 prc_title,
                 sta_title,
                 sta_color status_color,
                 sta_id,
                 iqu_status,
                 grp_name,
                 pre_title,
                 iss_last_public_action_date,
                 iss_last_public_action_type,
                 iss_last_internal_action_date,
                 iss_last_internal_action_type,
                 ' . Issue::getLastActionFields() . ",\n                    CASE WHEN iss_last_internal_action_date > iss_last_public_action_date THEN 'internal' ELSE 'public' END AS action_type,\n                    iss_private,\n                    usr_full_name,\n                    iss_percent_complete,\n                    iss_dev_time,\n                    iss_expected_resolution_date,\n                    sev_title\n                 FROM\n                    (\n                    {{%issue}},\n                    {{%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 \n\n                    {{%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($usr_details['usr_par_code'])) {
         // restrict partners
         $stmt .= '
              LEFT JOIN
                 {{%issue_partner}}
              ON
                 ipa_iss_id=iss_id';
     }
     if (!empty($options['show_authorized_issues']) || $role_id == User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id)) {
         $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';
     }
     $stmt .= "\n                 LEFT JOIN\n                    {{%group}}\n                 ON\n                    iss_grp_id=grp_id\n                 LEFT JOIN\n                    {{%project_category}}\n                 ON\n                    iss_prc_id=prc_id\n                 LEFT JOIN\n                    {{%project_release}}\n                 ON\n                    iss_pre_id = pre_id\n                 LEFT JOIN\n                    {{%status}}\n                 ON\n                    iss_sta_id=sta_id\n                 LEFT JOIN\n                    {{%project_priority}}\n                 ON\n                    iss_pri_id=pri_id\n                 LEFT JOIN\n                    {{%project_severity}}\n                 ON\n                    iss_sev_id=sev_id\n                 LEFT JOIN\n                    {{%issue_quarantine}}\n                 ON\n                    iss_id=iqu_iss_id AND\n                    (iqu_expiration > '" . Date_Helper::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n                 WHERE\n                    iss_prj_id= " . Misc::escapeInteger($prj_id);
     $stmt .= self::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';
     $total_rows = Pager::getTotalRows($stmt);
     $stmt .= '
              LIMIT
                 ' . Misc::escapeInteger($max) . ' OFFSET ' . Misc::escapeInteger($start);
     try {
         $res = DB_Helper::getInstance()->getAll($stmt);
     } catch (DbException $e) {
         return array('list' => null, 'info' => null, 'csv' => null);
     }
     if (count($res) > 0) {
         Issue::getAssignedUsersByIssues($res);
         Time_Tracking::fillTimeSpentByIssues($res);
         // need to get the customer titles for all of these issues...
         if (CRM::hasCustomerIntegration($prj_id)) {
             $crm = CRM::getInstance($prj_id);
             $crm->processListIssuesResult($res);
         }
         Issue::formatLastActionDates($res);
         Issue::getLastStatusChangeDates($prj_id, $res);
     } elseif ($current_row > 0) {
         // if there are no results, and the page is not the first page reset page to one and reload results
         Auth::redirect("list.php?pagerRow=0&rows={$max}");
     }
     $groups = Group::getAssocList($prj_id);
     $categories = Category::getAssocList($prj_id);
     $column_headings = array();
     $columns_to_display = Display_Column::getColumnsToDisplay($prj_id, 'list_issues');
     foreach ($columns_to_display as $col_key => $column) {
         if ($col_key == 'custom_fields' && count($custom_fields) > 0) {
             foreach ($custom_fields as $fld_id => $fld_title) {
                 $column_headings['cstm_' . $fld_id] = $fld_title;
             }
         } else {
             $column_headings[$col_key] = $column['title'];
         }
     }
     $csv[] = @implode("\t", $column_headings);
     if (@$options['hide_excerpts'] != 1 && self::doesBackendSupportExcerpts() == true) {
         $excerpts = self::getFullTextExcerpts();
     }
     foreach ($res as &$row) {
         $issue_id = $row['iss_id'];
         $row['time_spent'] = Misc::getFormattedTime($row['time_spent']);
         $row['iss_created_date'] = Date_Helper::getFormattedDate($row['iss_created_date']);
         $row['iss_expected_resolution_date'] = Date_Helper::getSimpleDate($row['iss_expected_resolution_date'], false);
         $row['excerpts'] = isset($excerpts[$issue_id]) ? $excerpts[$issue_id] : '';
         $fields = array();
         foreach (array_keys($columns_to_display) as $col_key) {
             switch ($col_key) {
                 case 'pri_rank':
                     $col_key = 'pri_title';
                     break;
                 case 'assigned':
                     $col_key = 'assigned_users';
                     break;
                 case 'sta_rank':
                     $col_key = 'sta_title';
                     break;
                 case 'sta_change_date':
                     $col_key = 'status_change_date';
                     break;
                 case 'sev_rank':
                     $col_key = 'sev_title';
                     break;
             }
             if ($col_key == 'custom_fields' && count($custom_fields) > 0) {
                 $custom_field_values = Custom_Field::getListByIssue($prj_id, $row['iss_id']);
                 foreach ($custom_field_values as $this_field) {
                     if (!empty($custom_fields[$this_field['fld_id']])) {
                         $row['custom_field'][$this_field['fld_id']] = $this_field['value'];
                         $fields[] = $this_field['value'];
                     }
                 }
             } else {
                 $fields[] = isset($row[$col_key]) ? $row[$col_key] : '';
             }
         }
         if (CRM::hasCustomerIntegration($prj_id)) {
             // check if current user is a customer and has a per incident contract.
             // if so, check if issue is redeemed.
             if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) {
                 // TODOCRM: Fix per incident usage
                 //                    if ((Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) &&
                 //                            (Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])))) {
                 //                        $res[$i]['redeemed'] = true;
                 //                    }
             }
         }
         $csv[] = @implode("\t", $fields);
     }
     $total_pages = ceil($total_rows / $max);
     $last_page = $total_pages - 1;
     return array('list' => $res, 'info' => array('current_page' => $current_row, 'start_offset' => $start, 'end_offset' => $start + count($res), 'total_rows' => $total_rows, 'total_pages' => $total_pages, 'previous_page' => $current_row == 0 ? '-1' : $current_row - 1, 'next_page' => $current_row == $last_page ? '-1' : $current_row + 1, 'last_page' => $last_page, 'custom_fields' => $custom_fields), 'csv' => @implode("\n", $csv));
 }
Esempio n. 5
0
        $time_spent = (int) $_POST['time_spent'];
        $summary = 'Time entry inserted when closing issue.';
        Time_Tracking::addTimeEntry($iss_id, $ttc_id, $time_spent, $date, $summary);
    }
    if (CRM::hasCustomerIntegration($prj_id) && isset($details['contract'])) {
        $crm = CRM::getInstance($prj_id);
        $contract = $details['contract'];
        if ($contract->hasPerIncident()) {
            $contract->updateRedeemedIncidents($issue_id, @$_REQUEST['redeem']);
        }
    }
    $tpl->assign('close_result', $res);
    if ($res == 1) {
        Misc::setMessage(ev_gettext('Thank you, the issue was closed successfully'));
        Misc::displayNotifiedUsers(Notification::getLastNotifiedAddresses($issue_id));
        Auth::redirect(APP_RELATIVE_URL . 'view.php?id=' . $issue_id);
    }
}
$tpl->assign(array('statuses' => Status::getClosedAssocList($prj_id), 'resolutions' => Resolution::getAssocList(), 'time_categories' => Time_Tracking::getAssocCategories($prj_id), 'notify_list' => Notification::getLastNotifiedAddresses($issue_id), 'custom_fields' => Custom_Field::getListByIssue($prj_id, $issue_id, $usr_id, 'close_form'), 'issue_id' => $issue_id));
if (CRM::hasCustomerIntegration($prj_id) && isset($details['contract'])) {
    $crm = CRM::getInstance($prj_id);
    $contract = $details['contract'];
    if ($contract->hasPerIncident()) {
        $details = Issue::getDetails($issue_id);
        $tpl->assign(array('redeemed' => $contract->getRedeemedIncidentDetails($issue_id), 'incident_details' => $details['customer']['incident_details']));
    }
}
$usr_id = Auth::getUserID();
$user_prefs = Prefs::get($usr_id);
$tpl->assign('current_user_prefs', $user_prefs);
$tpl->displayTemplate();
 /**
  * Returns an array of fields and values for a specific issue
  *
  * @access  public
  * @param   integer $prj_id The ID of the project
  * @param   integer $iss_id The ID of the issue to return values for
  * @return  array An array containging fld_id => value
  */
 function getValuesByIssue($prj_id, $iss_id)
 {
     $values = array();
     $list = Custom_Field::getListByIssue($prj_id, $iss_id);
     foreach ($list as $field) {
         if (in_array($field['fld_type'], array('text', 'textarea'))) {
             $values[$field['fld_id']] = $field['icf_value'];
         } elseif ($field['fld_type'] == 'combo') {
             $values[$field['fld_id']] = array($field['selected_cfo_id'] => $field['icf_value']);
         } elseif ($field['fld_type'] == 'multiple') {
             $selected = $field['selected_cfo_id'];
             foreach ($selected as $cfo_id) {
                 $values[$field['fld_id']][$cfo_id] = @$field['field_options'][$cfo_id];
             }
         }
     }
     return $values;
 }
Esempio n. 7
0
     $show_releases = 0;
 }
 // get if categories should be displayed
 $cats = Category::getList($prj_id);
 if (count($cats) > 0) {
     $show_category = 1;
 } else {
     $show_category = 0;
 }
 $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
 if (!empty($auto_switched_from)) {
     $tpl->assign(array("project_auto_switched" => 1, "old_project" => Project::getName($auto_switched_from)));
 }
 $setup = Setup::load();
 $tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]);
 $tpl->assign(array('next_issue' => @$sides['next'], 'previous_issue' => @$sides['previous'], 'subscribers' => Notification::getSubscribers($issue_id), 'custom_fields' => Custom_Field::getListByIssue($prj_id, $issue_id), 'files' => Attachment::getList($issue_id), 'emails' => Support::getEmailsByIssue($issue_id), 'zones' => Date_API::getTimezoneList(), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'ema_id' => Email_Account::getEmailAccount(), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'show_releases' => $show_releases, 'show_category' => $show_category, 'categories' => Category::getAssocList($prj_id), 'quarantine' => Issue::getQuarantineInfo($issue_id)));
 if ($role_id != User::getRoleID('customer')) {
     if (@$_REQUEST['show_all_drafts'] == 1) {
         $show_all_drafts = true;
     } else {
         $show_all_drafts = false;
     }
     if (Workflow::hasWorkflowIntegration($prj_id)) {
         $statuses = Workflow::getAllowedStatuses($prj_id, $issue_id);
         // if currently selected release is not on list, go ahead and add it.
     } else {
         $statuses = Status::getAssocStatusList($prj_id);
     }
     if (!empty($details['iss_sta_id']) && empty($statuses[$details['iss_sta_id']])) {
         $statuses[$details['iss_sta_id']] = Status::getStatusTitle($details['iss_sta_id']);
     }
Esempio n. 8
0
 /**
  * Method used to get the list of issues to be displayed in the grid layout.
  *
  * @access  public
  * @param   integer $prj_id The current project ID
  * @param   array $options The search parameters
  * @param   integer $current_row The current page number
  * @param   integer $max The maximum number of rows per page
  * @return  array The list of issues to be displayed
  */
 function getListing($prj_id, $options, $current_row = 0, $max = 5, $get_reporter = FALSE)
 {
     if (strtoupper($max) == "ALL") {
         $max = 9999999;
     }
     $start = $current_row * $max;
     // get the current user's role
     $usr_id = Auth::getUserID();
     $role_id = User::getRoleByUser($usr_id, $prj_id);
     // get any custom fields that should be displayed
     $custom_fields = Custom_Field::getFieldsToBeListed($prj_id);
     $stmt = "SELECT\n                    iss_id,\n                    iss_grp_id,\n                    iss_prj_id,\n                    iss_sta_id,\n                    iss_customer_id,\n                    iss_created_date,\n                    iss_updated_date,\n                    iss_last_response_date,\n                    iss_closed_date,\n                    iss_last_customer_action_date,\n                    iss_usr_id,\n                    iss_summary,\n                    pri_title,\n                    prc_title,\n                    sta_title,\n                    sta_color status_color,\n                    sta_id,\n                    iqu_status,\n                    grp_name `group`,\n                    pre_title,\n                    iss_last_public_action_date,\n                    iss_last_public_action_type,\n                    iss_last_internal_action_date,\n                    iss_last_internal_action_type,\n                    " . Issue::getLastActionFields() . ",\n                    IF(iss_last_internal_action_date > iss_last_public_action_date, 'internal', 'public') AS action_type,\n                    iss_private,\n                    CONCAT(en_firstname,' ', en_lastname) as usr_full_name,\n                    iss_percent_complete,\n                    iss_dev_time,\n                    iss_expected_resolution_date\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'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) {
                 continue;
             }
             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                    (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = {$fld_id}) \n";
     }
     // START ETEL MODIFIED
     if (!empty($options["show_authorized_issues"]) || $role_id <= User::getRoleID("Standard User") && Project::getSegregateReporters($prj_id)) {
         $stmt .= "\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier\n                 ON\n                    iur_iss_id=iss_id\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n                 ON\n                    isu_iss_id=iss_id";
     } else {
         if (!empty($options["users"])) {
             $stmt .= "\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n                 ON\n                    isu_iss_id=iss_id";
         }
     }
     // END ETEL MODIFIED
     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";
     }
     $stmt .= "\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`\n                 ON\n                    iss_grp_id=grp_id\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category\n                 ON\n                    iss_prc_id=prc_id\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release\n                 ON\n                    iss_pre_id = pre_id\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                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine\n                 ON\n                    iss_id=iqu_iss_id AND\n                    (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n                 WHERE\n                    iss_prj_id= " . Misc::escapeInteger($prj_id);
     $stmt .= Issue::buildWhereClause($options);
     //echo $stmt;
     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";
     $total_rows = Pager::getTotalRows($stmt);
     if ($max > 100) {
         $max = 100;
     }
     $stmt .= "\n                 LIMIT\n                    " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
     $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
     // echo  $stmt;
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return array("list" => "", "info" => "");
     } else {
         if (count($res) > 0) {
             if ($get_reporter) {
                 Issue::getReportersByIssues($res);
             }
             Issue::getAssignedUsersByIssues($res);
             Time_Tracking::getTimeSpentByIssues($res);
             // need to get the customer titles for all of these issues...
             if (Customer::hasCustomerIntegration($prj_id)) {
                 Customer::getCustomerTitlesByIssues($prj_id, $res);
             }
             Issue::formatLastActionDates($res);
             Issue::getLastStatusChangeDates($prj_id, $res);
         } elseif ($current_row > 0) {
             // if there are no results, and the page is not the first page reset page to one and reload results
             Auth::redirect(APP_RELATIVE_URL . "list.php?pagerRow=0&rows={$max}");
         }
         $groups = Group::getAssocList($prj_id);
         $categories = Category::getAssocList($prj_id);
         $column_headings = Issue::getColumnHeadings($prj_id);
         if (count($custom_fields) > 0) {
             $column_headings = array_merge($column_headings, $custom_fields);
         }
         $csv[] = @implode("\t", $column_headings);
         for ($i = 0; $i < count($res); $i++) {
             $res[$i]["time_spent"] = Misc::getFormattedTime($res[$i]["time_spent"]);
             $res[$i]["iss_expected_resolution_date"] = Date_API::getSimpleDate($res[$i]["iss_expected_resolution_date"], false);
             $fields = array($res[$i]['pri_title'], $res[$i]['iss_id']);
             // hide the group column from the output if no
             // groups are available in the database
             if (count($groups) > 0) {
                 $fields[] = $res[$i]['group'];
             }
             $fields[] = $res[$i]['assigned_users'];
             $fields[] = $res[$i]['time_spent'];
             // hide the category column from the output if no
             // categories are available in the database
             if (count($categories) > 0) {
                 $fields[] = $res[$i]['prc_title'];
             }
             if (Customer::hasCustomerIntegration($prj_id)) {
                 $fields[] = @$res[$i]['customer_title'];
                 // check if current user is acustomer and has a per incident contract.
                 // if so, check if issue is redeemed.
                 if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) {
                     if (Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) && Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])) {
                         $res[$i]['redeemed'] = true;
                     }
                 }
             }
             $fields[] = $res[$i]['sta_title'];
             $fields[] = $res[$i]["status_change_date"];
             $fields[] = $res[$i]["last_action_date"];
             $fields[] = $res[$i]['iss_summary'];
             if (count($custom_fields) > 0) {
                 $res[$i]['custom_field'] = array();
                 $custom_field_values = Custom_Field::getListByIssue($prj_id, $res[$i]['iss_id']);
                 foreach ($custom_field_values as $this_field) {
                     if (!empty($custom_fields[$this_field['fld_id']])) {
                         $res[$i]['custom_field'][$this_field['fld_id']] = $this_field['icf_value'];
                         $fields[] = $this_field['icf_value'];
                     }
                 }
             }
             $csv[] = @implode("\t", $fields);
         }
         $total_pages = ceil($total_rows / $max);
         $last_page = $total_pages - 1;
         return array("list" => $res, "info" => array("current_page" => $current_row, "start_offset" => $start, "end_offset" => $start + count($res), "total_rows" => $total_rows, "total_pages" => $total_pages, "previous_page" => $current_row == 0 ? "-1" : $current_row - 1, "next_page" => $current_row == $last_page ? "-1" : $current_row + 1, "last_page" => $last_page, "custom_fields" => $custom_fields), "csv" => @implode("\n", $csv));
     }
 }
Esempio n. 9
0
// | 59 Temple Place - Suite 330                                          |
// | Boston, MA 02111-1307, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
//
// @(#) $Id: s.custom_fields.php 1.5 03/11/01 01:08:09-00:00 jpradomaia $
//
include_once "config.inc.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.custom_field.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("custom_fields_form.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$prj_id = Auth::getCurrentProject();
$issue_id = @$HTTP_POST_VARS["issue_id"] ? $HTTP_POST_VARS["issue_id"] : $HTTP_GET_VARS["issue_id"];
if (!Issue::canAccess($issue_id, Auth::getUserID())) {
    $tpl = new Template_API();
    $tpl->setTemplate("permission_denied.tpl.html");
    $tpl->displayTemplate();
    exit;
}
if (@$HTTP_POST_VARS["cat"] == "update_values") {
    $res = Custom_Field::updateValues();
    $tpl->assign("update_result", $res);
    $tpl->assign("current_user_prefs", Prefs::get(Auth::getUserID()));
}
$tpl->assign("custom_fields", Custom_Field::getListByIssue($prj_id, $issue_id));
$tpl->displayTemplate();
Esempio n. 10
0
 $columns[1][] = array('title' => ev_gettext('Associated Issues'), 'field' => 'associated_issues');
 if (!isset($issue_fields_display['expected_resolution']) || $issue_fields_display['expected_resolution'] != false) {
     $columns[1][] = array('title' => ev_gettext('Expected Resolution Date'), 'field' => 'expected_resolution');
 }
 if (!isset($issue_fields_display['estimated_dev_time']) || $issue_fields_display['estimated_dev_time'] != false) {
     $columns[1][] = array('title' => ev_gettext('Estimated Dev. Time'), 'data' => empty($details['iss_dev_time']) ? '' : $details['iss_dev_time'] . ' hours', 'field' => 'estimated_dev_time');
 }
 if ($role_id > User::getRoleID('Customer')) {
     $columns[1][] = array('title' => ev_gettext('Duplicates'), 'field' => 'duplicates', 'title_bgcolor' => APP_INTERNAL_COLOR);
     $columns[1][] = array('title' => ev_gettext('Authorized Repliers'), 'field' => 'authorized_repliers', 'title_bgcolor' => APP_INTERNAL_COLOR);
 }
 $groups = Group::getAssocList($prj_id);
 if ($role_id > User::getRoleID('Customer') && count($groups) > 0) {
     $columns[1][] = array('title' => ev_gettext('Group'), 'data' => isset($details['group']) ? $details['group']['grp_name'] : '', 'title_bgcolor' => APP_INTERNAL_COLOR);
 }
 $tpl->assign(array('next_issue' => @$sides['next'], 'previous_issue' => @$sides['previous'], 'subscribers' => Notification::getSubscribers($issue_id), 'custom_fields' => Custom_Field::getListByIssue($prj_id, $issue_id), 'files' => Attachment::getList($issue_id), 'emails' => Support::getEmailsByIssue($issue_id), 'zones' => Date_Helper::getTimezoneList(), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'ema_id' => Email_Account::getEmailAccount(), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'quarantine' => Issue::getQuarantineInfo($issue_id), 'grid' => $columns, 'can_update' => Issue::canUpdate($issue_id, $usr_id), 'enabled_partners' => Partner::getPartnersByProject($prj_id), 'partners' => Partner::getPartnersByIssue($issue_id), 'issue_access' => Access::getIssueAccessArray($issue_id, $usr_id), 'is_user_notified' => Notification::isUserNotified($issue_id, $usr_id)));
 if ($role_id != User::getRoleID('customer')) {
     if (@$_COOKIE['show_all_drafts'] == 1) {
         $show_all_drafts = true;
     } else {
         $show_all_drafts = false;
     }
     if (Workflow::hasWorkflowIntegration($prj_id)) {
         $statuses = Workflow::getAllowedStatuses($prj_id, $issue_id);
         // if currently selected release is not on list, go ahead and add it.
     } else {
         $statuses = Status::getAssocStatusList($prj_id, false);
     }
     if (!empty($details['iss_sta_id']) && empty($statuses[$details['iss_sta_id']])) {
         $statuses[$details['iss_sta_id']] = Status::getStatusTitle($details['iss_sta_id']);
     }
Esempio n. 11
0
 /**
  * Method used to format and send the email notifications.
  *
  * @param   integer $issue_id The issue ID
  * @param   array $emails The list of emails
  * @param   string $type The notification type
  * @param   array $data The issue details
  * @param   string $subject The subject of the email
  * @param   integer $type_id The ID of the event that triggered this notification (issue_id, sup_id, not_id, etc)
  * @param   array $headers Any extra headers that need to be added to this email (Default false)
  * @return  void
  */
 public function notifySubscribers($issue_id, $emails, $type, $data, $subject, $internal_only, $type_id = false, $headers = false)
 {
     global $_EVENTUM_LAST_NOTIFIED_LIST;
     $issue_id = (int) $issue_id;
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/' . $type . '.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'data' => $data, 'current_user' => User::getFullName(Auth::getUserID())));
     // type of notification is sent out: email, note, blocked_email
     $notify_type = $type;
     $sender_usr_id = false;
     $threading_headers = Mail_Helper::getBaseThreadingHeaders($issue_id);
     $emails = array_unique($emails);
     foreach ($emails as $email) {
         $can_access = true;
         $email_address = Mail_Helper::getEmailAddress($email);
         $recipient_usr_id = User::getUserIDByEmail($email_address);
         if (!empty($recipient_usr_id)) {
             if (!Issue::canAccess($issue_id, $recipient_usr_id)) {
                 $can_access = false;
             }
             $tpl->assign('recipient_role', User::getRoleByUser($recipient_usr_id, Issue::getProjectID($issue_id)));
             if (isset($data['custom_fields'])) {
                 $data['custom_fields'] = Custom_Field::getListByIssue($data['iss_prj_id'], $issue_id, $recipient_usr_id);
             }
             $is_assigned = Issue::isAssignedToUser($issue_id, $recipient_usr_id);
         } else {
             $tpl->assign('recipient_role', 0);
             unset($data['custom_fields']);
             $is_assigned = false;
         }
         $tpl->assign('data', $data);
         $tpl->assign('is_assigned', $is_assigned);
         if ($can_access != true) {
             continue;
         }
         if (!Workflow::shouldEmailAddress(Issue::getProjectID($issue_id), $email_address, $issue_id, $type)) {
             continue;
         }
         // change the current locale
         if (!empty($recipient_usr_id)) {
             Language::set(User::getLang($recipient_usr_id));
         } else {
             Language::set(APP_DEFAULT_LOCALE);
         }
         // send email (use PEAR's classes)
         $mail = new Mail_Helper();
         $mail->setTextBody($tpl->getTemplateContents());
         if ($headers != false) {
             $mail->setHeaders($headers);
         }
         if ($headers == false || $headers != false && (empty($headers['Message-ID']) && empty($headers['In-Reply-To']) && empty($headers['References']))) {
             $mail->setHeaders($threading_headers);
         }
         if ($type == 'notes') {
             // special handling of blocked messages
             if ($data['note']['not_is_blocked'] == 1) {
                 $subject = ev_gettext('BLOCKED');
                 $notify_type = 'blocked_email';
             }
             if (!empty($data['note']['not_unknown_user'])) {
                 $sender = $data['note']['not_unknown_user'];
             } else {
                 $sender = User::getFromHeader($data['note']['not_usr_id']);
             }
             $sender_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($sender));
             if (empty($sender_usr_id)) {
                 $sender_usr_id = false;
             }
             // show the title of the note, not the issue summary
             $extra_subject = $data['note']['not_title'];
             // don't add the "[#3333] Note: " prefix to messages that already have that in the subject line
             if (strstr($extra_subject, "[#{$issue_id}] {$subject}: ")) {
                 $pos = strpos($extra_subject, "[#{$issue_id}] {$subject}: ");
                 $full_subject = substr($extra_subject, $pos);
             } else {
                 $full_subject = "[#{$issue_id}] {$subject}: {$extra_subject}";
             }
         } elseif ($type == 'new_issue' && $is_assigned) {
             $full_subject = "[#{$issue_id}] New Issue Assigned: " . $data['iss_summary'];
         } else {
             $extra_subject = $data['iss_summary'];
             $full_subject = "[#{$issue_id}] {$subject}: {$extra_subject}";
         }
         if ($notify_type == 'notes' && $sender) {
             $from = self::getFixedFromHeader($issue_id, $sender, 'note');
         } else {
             $from = self::getFixedFromHeader($issue_id, '', 'issue');
         }
         $mail->send($from, $email, $full_subject, true, $issue_id, $notify_type, $sender_usr_id, $type_id);
         $_EVENTUM_LAST_NOTIFIED_LIST[$issue_id][] = $email;
     }
     // restore correct language
     Language::restore();
 }
Esempio n. 12
0
 /**
  * Returns an array of variables to be set on the new issue page when cloning an issue.
  *
  * @param integer $issue_id The ID of the issue to clone
  * @return array
  */
 public static function getCloneIssueTemplateVariables($issue_id)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $clone_details = Issue::getDetails($issue_id);
     $defaults = array('clone_iss_id' => $issue_id, 'category' => $clone_details['iss_prc_id'], 'group' => $clone_details['iss_grp_id'], 'severity' => $clone_details['iss_sev_id'], 'priority' => $clone_details['iss_pri_id'], 'users' => $clone_details['assigned_users'], 'summary' => $clone_details['iss_summary'], 'description' => $clone_details['iss_original_description'], 'expected_resolution_date' => $clone_details['iss_expected_resolution_date'], 'estimated_dev_time' => $clone_details['iss_dev_time'], 'private' => $clone_details['iss_private']);
     if (count($clone_details['products']) > 0) {
         $defaults['product'] = $clone_details['products'][0]['pro_id'];
         $defaults['product_version'] = $clone_details['products'][0]['version'];
     }
     $defaults['custom_fields'] = array();
     foreach (Custom_Field::getListByIssue($prj_id, $issue_id) as $field) {
         if (isset($field['selected_cfo_id'])) {
             $defaults['custom_fields'][$field['fld_id']] = $field['selected_cfo_id'];
         } else {
             $defaults['custom_fields'][$field['fld_id']] = $field['value'];
         }
     }
     $clone_variables = array('defaults' => $defaults);
     if (isset($clone_details['customer']) && isset($clone_details['contact'])) {
         $clone_variables += array('customer_id' => $clone_details['iss_customer_id'], 'contact_id' => $clone_details['iss_customer_contact_id'], 'customer' => $clone_details['customer'], 'contact' => $clone_details['contact']);
     }
     return $clone_variables;
 }
Esempio n. 13
0
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.misc.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.issue.php";
include_once APP_INC_PATH . "class.notification.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("self_assign.tpl.html");
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$usr_id = Auth::getUserID();
$target_usr_id = $usr_id;
$prj_id = Auth::getCurrentProject();
$issue_id = $_REQUEST["iss_id"];
$tpl->assign("issue_id", $issue_id);
if ($_REQUEST['assigntomerc']) {
    $custom_fields = Custom_Field::getListByIssue($prj_id, $issue_id);
    $ref_id = '';
    foreach ($custom_fields as $field) {
        if ($field['fld_title'] == 'Reference ID') {
            $ref_id = trim($field['icf_value']);
        }
    }
    if ($ref_id) {
        $stmt = "SELECT\n\t\t\t\ten_ID\n\t\t\t FROM\n\t\t\t\t" . ETEL_USER_TRANS_TABLE_NOSUB . "\n\t\t\t WHERE\n\t\t\t\treference_number='" . Misc::escapeString($ref_id) . "'";
        $info = $GLOBALS["db_api"]->dbh->getOne($stmt);
        if (PEAR::isError($info)) {
            Error_Handler::logError(array($info->getMessage(), $info->getDebugInfo()), __FILE__, __LINE__);
            return false;
        } else {
            $target_usr_id = $info;
            $newstatus = 8;
 /**
  * Method used to format and send the email notifications.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   array $emails The list of emails
  * @param   string $type The notification type
  * @param   array $data The issue details
  * @param   string $subject The subject of the email
  * @param   integer $type_id The ID of the event that triggered this notification (issue_id, sup_id, not_id, etc)
  * @param   array $headers Any extra headers that need to be added to this email (Default false)
  * @return  void
  */
 function notifySubscribers($issue_id, $emails, $type, $data, $subject, $internal_only, $type_id = false, $headers = false)
 {
     // open text template
     $tpl = new Template_API();
     $tpl->setTemplate('notifications/' . $type . '.tpl.text');
     $tpl->bulkAssign(array("app_title" => Misc::getToolCaption(), "data" => $data));
     $setup = Setup::load();
     $final_type = $type;
     $sender_usr_id = false;
     $threading_headers = Mail_API::getBaseThreadingHeaders($issue_id);
     for ($i = 0; $i < count($emails); $i++) {
         $can_access = true;
         $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($emails[$i]));
         if (!empty($recipient_usr_id)) {
             if (!Issue::canAccess($issue_id, $recipient_usr_id)) {
                 $can_access = false;
             }
             $tpl->assign("recipient_role", User::getRoleByUser($recipient_usr_id, Issue::getProjectID($issue_id)));
             if (isset($data['custom_fields'])) {
                 $data['custom_fields'] = Custom_Field::getListByIssue($data['iss_prj_id'], $issue_id, $recipient_usr_id);
             }
             $is_assigned = Issue::isAssignedToUser($issue_id, $recipient_usr_id);
         } else {
             $tpl->assign("recipient_role", 0);
             unset($data['custom_fields']);
             $is_assigned = false;
         }
         $tpl->assign("data", $data);
         $tpl->assign("is_assigned", $is_assigned);
         if ($can_access != true) {
             continue;
         }
         // send email (use PEAR's classes)
         $mail = new Mail_API();
         $mail->setTextBody($tpl->getTemplateContents());
         if ($headers != false) {
             $mail->setHeaders($headers);
         }
         if ($headers == false || $headers != false && (empty($headers['Message-ID']) && empty($headers['In-Reply-To']) && empty($headers['References']))) {
             $mail->setHeaders($threading_headers);
         }
         if ($type == 'notes') {
             // special handling of blocked messages
             if (!empty($data['note']['not_blocked_message'])) {
                 $subject = 'BLOCKED';
                 $final_type = 'blocked_email';
             }
             if (!empty($data["note"]["not_unknown_user"])) {
                 $sender = $data["note"]["not_unknown_user"];
             } else {
                 $sender = User::getFromHeader($data["note"]["not_usr_id"]);
             }
             $sender_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($sender));
             if (empty($sender_usr_id)) {
                 $sender_usr_id = false;
             }
             $from = Notification::getFixedFromHeader($issue_id, $sender, 'note');
         } else {
             $from = Notification::getFixedFromHeader($issue_id, '', 'issue');
         }
         // show the title of the note, not the issue summary
         if ($type == 'notes') {
             $extra_subject = $data['note']['not_title'];
             // don't add the "[#3333] Note: " prefix to messages that already have that in the subject line
             if (strstr($extra_subject, "[#{$issue_id}] {$subject}: ")) {
                 $pos = strpos($extra_subject, "[#{$issue_id}] {$subject}: ");
                 $full_subject = substr($extra_subject, 4);
             } else {
                 $full_subject = "[#{$issue_id}] {$subject}: {$extra_subject}";
             }
         } elseif ($type == 'new_issue' && $is_assigned) {
             $full_subject = "[#{$issue_id}] New Issue Assigned: " . $data['iss_summary'];
         } else {
             $extra_subject = $data['iss_summary'];
             $full_subject = "[#{$issue_id}] {$subject}: {$extra_subject}";
         }
         $mail->send($from, $emails[$i], $full_subject, TRUE, $issue_id, $final_type, $sender_usr_id, $type_id);
     }
 }