Exemplo n.º 1
0
 /**
  * Method used to add a new project to the system.
  *
  * @access  public
  * @return  integer 1 if the update worked, -1 or -2 otherwise
  */
 function insert()
 {
     global $HTTP_POST_VARS;
     if (Validation::isWhitespace($HTTP_POST_VARS["title"])) {
         return -2;
     }
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project\n                 (\n                    prj_created_date,\n                    prj_title,\n                    prj_status,\n                    prj_lead_usr_id,\n                    prj_initial_sta_id,\n                    prj_outgoing_sender_name,\n                    prj_outgoing_sender_email,\n                    prj_remote_invocation,\n                    prj_customer_backend,\n                    prj_workflow_backend\n                 ) VALUES (\n                    '" . Date_API::getCurrentDateGMT() . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["status"]) . "',\n                    " . Misc::escapeInteger($HTTP_POST_VARS["lead_usr_id"]) . ",\n                    " . Misc::escapeInteger($HTTP_POST_VARS["initial_status"]) . ",\n                    '" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_name"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_email"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["remote_invocation"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["customer_backend"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["workflow_backend"]) . "'\n                 )";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         $new_prj_id = $GLOBALS["db_api"]->get_last_insert_id();
         for ($i = 0; $i < count($HTTP_POST_VARS["users"]); $i++) {
             if ($HTTP_POST_VARS["users"][$i] == $HTTP_POST_VARS["lead_usr_id"]) {
                 $role_id = User::getRoleID("Manager");
             } else {
                 $role_id = User::getRoleID("Standard User");
             }
             Project::associateUser($new_prj_id, $HTTP_POST_VARS["users"][$i], $role_id);
         }
         foreach ($HTTP_POST_VARS['statuses'] as $sta_id) {
             Status::addProjectAssociation($sta_id, $new_prj_id);
         }
         Display_Column::setupNewProject($new_prj_id);
         return 1;
     }
 }
Exemplo n.º 2
0
$prj_id = $_REQUEST['prj_id'];
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "column_display");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    if (@$HTTP_POST_VARS["cat"] == "save") {
        $tpl->assign("result", Display_Column::save());
    }
    $page = 'list_issues';
    $available = Display_Column::getAllColumns($page);
    $selected = Display_Column::getSelectedColumns($prj_id, $page);
    // re-order available array to match rank
    $available_ordered = array();
    foreach ($selected as $field_name => $field_info) {
        $available_ordered[$field_name] = $available[$field_name];
        unset($available[$field_name]);
    }
    if (count($available) > 0) {
        $available_ordered += $available;
    }
    $excluded_roles = array();
    if (!Customer::hasCustomerIntegration($prj_id)) {
        $excluded_roles[] = "customer";
    }
    $user_roles = User::getRoles($excluded_roles);
    $user_roles[9] = "Never Display";
Exemplo n.º 3
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));
 }
Exemplo n.º 4
0
 /**
  * Method used to add a new project to the system.
  *
  * @return  integer 1 if the update worked, -1 or -2 otherwise
  */
 public static function insert()
 {
     if (Validation::isWhitespace($_POST['title'])) {
         return -2;
     }
     $stmt = 'INSERT INTO
                 {{%project}}
              (
                 prj_created_date,
                 prj_title,
                 prj_status,
                 prj_lead_usr_id,
                 prj_initial_sta_id,
                 prj_outgoing_sender_name,
                 prj_outgoing_sender_email,
                 prj_mail_aliases,
                 prj_remote_invocation,
                 prj_customer_backend,
                 prj_workflow_backend
              ) VALUES (
                  ?, ?, ?, ?, ?,
                  ?, ?, ?, ?, ?, ?
              )';
     try {
         DB_Helper::getInstance()->query($stmt, array(Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['status'], $_POST['lead_usr_id'], $_POST['initial_status'], $_POST['outgoing_sender_name'], $_POST['outgoing_sender_email'], $_POST['mail_aliases'], $_POST['remote_invocation'], $_POST['customer_backend'], $_POST['workflow_backend']));
     } catch (DbException $e) {
         return -1;
     }
     $new_prj_id = DB_Helper::get_last_insert_id();
     foreach ($_POST['users'] as $user) {
         if ($user == $_POST['lead_usr_id']) {
             $role_id = User::getRoleID('Manager');
         } else {
             $role_id = User::getRoleID('Standard User');
         }
         self::associateUser($new_prj_id, $user, $role_id);
     }
     foreach ($_POST['statuses'] as $sta_id) {
         Status::addProjectAssociation($sta_id, $new_prj_id);
     }
     Display_Column::setupNewProject($new_prj_id);
     // insert default timetracking categories
     Time_Tracking::addProjectDefaults($new_prj_id);
     return 1;
 }
<?php

// create database entries for all projects in the columns_to_display table
// so all projects have fields that show up on the list issue page.
include_once "../../../config.inc.php";
include_once APP_INC_PATH . "class.display_column.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "db_access.php";
$projects = Project::getAll();
foreach ($projects as $prj_id => $prj_title) {
    echo "Setting Display columns for {$prj_title}<br />";
    Display_Column::setupNewProject($prj_id);
}
?>
Done. You can now control which columns are displayed on the list issues page through the administration page.
Exemplo n.º 6
0
    $assign_options['-3'] = ev_gettext('myself and my group');
    $assign_options['-4'] = ev_gettext('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}"] = ev_gettext('Group') . ': ' . $grp_name;
    }
}
$assign_options += $users;
$list = Search::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('match_modes', Search::getMatchModes());
$tpl->assign('supports_excerpts', Search::doesBackendSupportExcerpts());
$tpl->assign('columns', Display_Column::getColumnsToDisplay($prj_id, 'list_issues'));
$tpl->assign('priorities', Priority::getAssocList($prj_id));
$tpl->assign('severities', Severity::getAssocList($prj_id));
$tpl->assign('status', Status::getAssocStatusList($prj_id));
$tpl->assign('assign_options', $assign_options);
$tpl->assign('custom', Filter::getAssocList($prj_id));
$tpl->assign('csts', Filter::getListing(true));
$tpl->assign('active_filters', Filter::getActiveFilters($options));
$tpl->assign('categories', Category::getAssocList($prj_id));
$tpl->assign('releases', Release::getAssocList($prj_id, true));
$tpl->assign('reporters', Project::getReporters($prj_id));
$tpl->assign(array('products' => Product::getAssocList(false)));
$prefs = Prefs::get($usr_id);
$tpl->assign('refresh_rate', $prefs['list_refresh_rate'] * 60);
$tpl->assign('refresh_page', 'list.php');
// items needed for bulk update tool
 /**
  * Adds records in database for new project.
  *
  * @param   integer $prj_id The ID of the project.
  */
 function setupNewProject($prj_id)
 {
     $page = 'list_issues';
     $columns = Display_Column::getAllColumns($page);
     $rank = 1;
     foreach ($columns as $field_name => $column) {
         if (!empty($column['default_role'])) {
             $min_role = $column['default_role'];
         } else {
             $min_role = 1;
         }
         $stmt = "INSERT INTO\n                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "columns_to_display\n                     SET\n                        ctd_prj_id = {$prj_id},\n                        ctd_page = '{$page}',\n                        ctd_field = '{$field_name}',\n                        ctd_min_role = {$min_role},\n                        ctd_rank = {$rank}";
         $res = $GLOBALS["db_api"]->dbh->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
         }
         $rank++;
     }
 }