/** * Modifies an Issue's Reporter. * * @param integer $issue_id The id of the issue. * @param string $fullname The id of the user. * @param boolean $add_history If this should be logged. * @return int */ public static function update($issue_id, $email, $add_history = true) { $email = strtolower(Mail_Helper::getEmailAddress($email)); $usr_id = User::getUserIDByEmail($email, true); // If no valid user found reset to system account if (!$usr_id) { $usr_id = APP_SYSTEM_USER_ID; } $sql = 'UPDATE {{%issue}} SET iss_usr_id = ? WHERE iss_id = ?'; try { DB_Helper::getInstance()->query($sql, array($usr_id, $issue_id)); } catch (DbException $e) { return -1; } if ($add_history) { // TRANSLATORS: %1: email, %2: full name $current_usr_id = Auth::getUserID(); History::add($issue_id, $current_usr_id, 'issue_updated', 'Reporter was changed to {email} by {user}', array('email' => $email, 'user' => User::getFullName($current_usr_id))); } // Add new user to notification list if ($usr_id > 0) { Notification::subscribeEmail($usr_id, $issue_id, $email, Notification::getDefaultActions()); } return 1; }
/** * 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; }
/** * カートの中を確認 * route --> /item/purchase */ public function purchaseAction() { $this->_log->debug(__CLASS__ . ":" . __FUNCTION__ . " called:(" . __LINE__ . ")"); $customerID = Auth::getUserID(); $params = $this->getPostList(); if (count($params) == 0) { $this->_log->debug("パラメータがPOSTされていません."); $mapper = new Item(); $cartContent = $mapper->showCartContent($customerID); $this->_log->debug("カートの中身:" . print_r($cartContent, true)); $this->setViewSearchlist($cartContent); return; } return; }
/** * Method used to remove a specific list of checkins * * @param int[] $items list to remove * @return integer 1 if the update worked, -1 otherwise */ public static function remove($items) { $itemlist = DB_Helper::buildList($items); $stmt = "SELECT\n isc_iss_id\n FROM\n {{%issue_checkin}}\n WHERE\n isc_id IN ({$itemlist})"; $issue_id = DB_Helper::getInstance()->getOne($stmt, $items); $stmt = "DELETE FROM\n {{%issue_checkin}}\n WHERE\n isc_id IN ({$itemlist})"; try { DB_Helper::getInstance()->query($stmt, $items); } catch (DbException $e) { return -1; } // need to mark this issue as updated Issue::markAsUpdated($issue_id); $usr_id = Auth::getUserID(); History::add($issue_id, $usr_id, 'scm_checkin_removed', 'SCM Checkins removed by {user}', array('user' => User::getFullName($usr_id))); return 1; }
public function __construct() { $this->usr_id = Auth::getUserID(); if (!Access::canAccessReports($this->usr_id)) { throw new LogicException('Invalid role'); } $this->prj_id = Auth::getCurrentProject(); $this->activity_types = !empty($_REQUEST['activity_types']) ? (array) $_REQUEST['activity_types'] : array(); $this->report_type = isset($_REQUEST['report_type']) ? (string) $_REQUEST['report_type'] : null; $this->unit = $this->getParam('unit', array('hour', 'day')); $this->amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : null; $this->developer = isset($_REQUEST['developer']) ? $_REQUEST['developer'] : null; $this->start_date = $this->parseDate(isset($_POST['start']) ? $_POST['start'] : null); $this->end_date = $this->parseDate(isset($_POST['end']) ? $_POST['end'] : null); $this->sort_order = $this->getParam('sort_order', array('ASC', 'DESC')); if (CRM::hasCustomerIntegration($this->prj_id)) { $this->crm = CRM::getInstance($this->prj_id); } }
/** * 人物を評価する * route --> /customer/evaluate */ public function evaluateAction() { $this->_log->debug(__CLASS__ . ":" . __FUNCTION__ . " called:(" . __LINE__ . ")"); $customerID = Auth::getUserID(); // 配達者or依頼者 $params = $this->getPostList(); $mapper = new Customer(); /* 評価画面をセット */ if (!array_key_exists('rate', $params)) { $this->_log->debug("評価画面をセット."); $indata = $mapper->selectRequestInfo($params['requestID']); $indata['customerID'] = $customerID; $indata['requestID'] = $params['requestID']; $this->setViewIndata($indata); $this->_log->debug("リクエスト情報" . print_r($indata, true)); return; } /* 相手を評価 */ $mapper->evaluatePerson($customerID, $params); $this->redirect('/item'); return; }
$tpl->assign('delete_filter_result', $res); } elseif ($cat == 'remove_support_email') { $res = Support::removeAssociation(); $tpl->assign('remove_association_result', $res); } elseif ($cat == 'delete_attachment') { $res = Attachment::remove($id); $tpl->assign('remove_attachment_result', $res); } elseif ($cat == 'delete_file') { $res = Attachment::removeIndividualFile($id); $tpl->assign('remove_file_result', $res); } elseif ($cat == 'remove_checkin') { $res = SCM::remove($items); $tpl->assign('remove_checkin_result', $res); } elseif ($cat == 'unassign') { $res = Issue::deleteUserAssociation($iss_id, $usr_id); Workflow::handleAssignmentChange($prj_id, $iss_id, Auth::getUserID(), Issue::getDetails($iss_id), Issue::getAssignedUserIDs($iss_id)); $tpl->assign('unassign_result', $res); } elseif ($cat == 'remove_email') { $res = Support::removeEmails(); $tpl->assign('remove_email_result', $res); } elseif ($cat == 'clear_duplicate') { $res = Issue::clearDuplicateStatus($iss_id); $tpl->assign('clear_duplicate_result', $res); } elseif ($cat == 'delete_phone') { $res = Phone_Support::remove($id); $tpl->assign('delete_phone_result', $res); } elseif ($cat == 'new_status') { $res = Issue::setStatus($iss_id, $status_id, true); if ($res == 1) { History::add($iss_id, $usr_id, 'status_changed', "Issue manually set to status '{status}' by {user}", array('status' => Status::getStatusTitle($status_id), 'user' => User::getFullName($usr_id))); }
public static function removePartnerFromIssue($iss_id, $par_code) { $params = array($iss_id, $par_code); $sql = 'DELETE FROM {{%issue_partner}} WHERE ipa_iss_id = ? AND ipa_par_code = ?'; try { DB_Helper::getInstance()->query($sql, $params); } catch (DbException $e) { return false; } $backend = self::getBackend($par_code); $backend->issueRemoved($iss_id); $usr_id = Auth::getUserID(); History::add($iss_id, $usr_id, 'partner_removed', "Partner '{partner}' removed from issue by {user}", array('partner' => $backend->getName(), 'user' => User::getFullName($usr_id))); return true; }
/* * 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'; $tpl = new Template_Helper(); $tpl->setTemplate('reports/custom_fields.tpl.html'); Auth::checkAuthentication(); if (!Access::canAccessReports(Auth::getUserID())) { echo 'Invalid role'; exit; } $prj_id = Auth::getCurrentProject(); // get list of fields and convert info useful arrays $fields = Custom_Field::getListByProject($prj_id, ''); $custom_fields = array(); $options = array(); 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');
/** * Method used to get the list of custom fields and custom field * values associated with a given issue ID. If usr_id is false method * defaults to current user. * * @param integer $prj_id The project ID * @param integer $iss_id The issue ID * @param integer $usr_id The ID of the user who is going to be viewing this list. * @param mixed $form_type The name of the form this is for or if this is an array the ids of the fields to return * @return array The list of custom fields */ public static function getListByIssue($prj_id, $iss_id, $usr_id = null, $form_type = false) { if (!$usr_id) { $usr_id = Auth::getUserID(); } $usr_role = User::getRoleByUser($usr_id, $prj_id); if (empty($usr_role)) { $usr_role = 0; } $stmt = 'SELECT fld_id, fld_title, fld_type, fld_report_form_required, fld_anonymous_form_required, fld_close_form_required, ' . self::getDBValueFieldSQL() . ' as value, icf_value, icf_value_date, icf_value_integer, fld_min_role, fld_description FROM ( {{%custom_field}}, {{%project_custom_field}} ) LEFT JOIN {{%issue_custom_field}} ON pcf_fld_id=icf_fld_id AND icf_iss_id=? WHERE pcf_fld_id=fld_id AND pcf_prj_id=? AND fld_min_role <= ?'; $params = array($iss_id, $prj_id, $usr_role); if ($form_type != false) { if (is_array($form_type)) { $stmt .= ' AND fld_id IN(' . DB_Helper::buildList($form_type) . ')'; $params = array_merge($params, $form_type); } else { $fld_name = 'fld_' . Misc::escapeString($form_type); $stmt .= " AND {$fld_name}=1"; } } $stmt .= ' ORDER BY fld_rank ASC'; try { $res = DB_Helper::getInstance()->getAll($stmt, $params); } catch (DbException $e) { return array(); } if (count($res) == 0) { return array(); } $fields = array(); foreach ($res as &$row) { if ($row['fld_type'] == 'combo') { $row['selected_cfo_id'] = $row['value']; $row['original_value'] = $row['value']; $row['value'] = self::getOptionValue($row['fld_id'], $row['value']); $row['field_options'] = self::getOptions($row['fld_id'], false, $iss_id); // add the select option to the list of values if it isn't on the list (useful for fields with active and non-active items) if (!empty($row['original_value']) && !isset($row['field_options'][$row['original_value']])) { $row['field_options'][$row['original_value']] = self::getOptionValue($row['fld_id'], $row['original_value']); } $fields[] = $row; } elseif ($row['fld_type'] == 'multiple' || $row['fld_type'] == 'checkbox') { // check whether this field is already in the array $found = 0; foreach ($fields as $y => $field) { if ($field['fld_id'] == $row['fld_id']) { $found = 1; $found_index = $y; } } $original_value = $row['value']; if (!$found) { $row['selected_cfo_id'] = array($row['value']); $row['value'] = self::getOptionValue($row['fld_id'], $row['value']); $row['field_options'] = self::getOptions($row['fld_id']); $fields[] = $row; $found_index = count($fields) - 1; } else { $fields[$found_index]['value'] .= ', ' . self::getOptionValue($row['fld_id'], $row['value']); $fields[$found_index]['selected_cfo_id'][] = $row['value']; } // add the select option to the list of values if it isn't on the list (useful for fields with active and non-active items) if ($original_value !== null && !in_array($original_value, $fields[$found_index]['field_options'])) { $fields[$found_index]['field_options'][$original_value] = self::getOptionValue($row['fld_id'], $original_value); } } else { $row['value'] = $row[self::getDBValueFieldNameByType($row['fld_type'])]; $fields[] = $row; } } foreach ($fields as $key => $field) { $backend = self::getBackend($field['fld_id']); if (is_object($backend) && is_subclass_of($backend, 'Dynamic_Custom_Field_Backend')) { $fields[$key]['dynamic_options'] = $backend->getStructuredData(); $fields[$key]['controlling_field_id'] = $backend->getControllingCustomFieldID(); $fields[$key]['controlling_field_name'] = $backend->getControllingCustomFieldName(); $fields[$key]['hide_when_no_options'] = $backend->hideWhenNoOptions(); $fields[$key]['lookup_method'] = $backend->lookupMethod(); } // check if the backend implements "isRequired" if (is_object($backend) && method_exists($backend, 'isRequired')) { $fields[$key]['fld_report_form_required'] = $backend->isRequired($fields[$key]['fld_id'], 'report', $iss_id); $fields[$key]['fld_anonymous_form_required'] = $backend->isRequired($fields[$key]['fld_id'], 'anonymous', $iss_id); $fields[$key]['fld_close_form_required'] = $backend->isRequired($fields[$key]['fld_id'], 'close', $iss_id); } if (is_object($backend) && method_exists($backend, 'getValidationJS')) { $fields[$key]['validation_js'] = $backend->getValidationJS($fields[$key]['fld_id'], $form_type, $iss_id); } else { $fields[$key]['validation_js'] = ''; } } return $fields; }
// +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('view_note.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $usr_id = Auth::getUserID(); $note_id = $_GET['id']; $note = Note::getDetails($note_id); if ($note == '') { $tpl->assign('note', ''); $tpl->displayTemplate(); exit; } else { $note['message'] = $note['not_note']; $issue_id = Note::getIssueID($note_id); $usr_id = Auth::getUserID(); } if (User::getRoleByUser($usr_id, Issue::getProjectID($issue_id)) < User::getRoleID('Standard User') || !Access::canViewInternalNotes($issue_id, Auth::getUserID())) { $tpl->setTemplate('permission_denied.tpl.html'); $tpl->displayTemplate(); exit; } $note = Note::getDetails($_GET['id']); $note['message'] = $note['not_note']; $issue_id = Note::getIssueID($_GET['id']); $tpl->assign(array('note' => $note, 'issue_id' => $issue_id, 'extra_title' => 'Note #' . Note::getNoteSequenceNumber($issue_id, $note_id) . ': ' . $note['not_title'], 'recipients' => Mail_Queue::getMessageRecipients('notes', $note_id))); if (!empty($issue_id)) { $sides = Note::getSideLinks($issue_id, $_GET['id']); $tpl->assign(array('previous' => $sides['previous'], 'next' => $sides['next'])); } $tpl->displayTemplate();
public function addExtraRecipientsToNotificationList($prj_id, $email, $is_auto_created = false) { if (empty($email['to']) && !empty($email['sup_to'])) { $email['to'] = $email['sup_to']; } if (empty($email['cc']) && !empty($email['sup_cc'])) { $email['cc'] = $email['sup_cc']; } $project_details = Project::getDetails($prj_id); $addresses_not_too_add = explode(',', strtolower($project_details['prj_mail_aliases'])); array_push($addresses_not_too_add, $project_details['prj_outgoing_sender_email']); $addresses = array(); $to_addresses = Mail_Helper::getEmailAddresses(@$email['to']); if (count($to_addresses)) { $addresses = $to_addresses; } $cc_addresses = Mail_Helper::getEmailAddresses(@$email['cc']); if (count($cc_addresses)) { $addresses = array_merge($addresses, $cc_addresses); } $subscribers = Notification::getSubscribedEmails($email['issue_id']); foreach ($addresses as $address) { $address = strtolower($address); if (!in_array($address, $subscribers) && !in_array($address, $addresses_not_too_add)) { Notification::subscribeEmail(Auth::getUserID(), $email['issue_id'], $address, Notification::getDefaultActions($email['issue_id'], $address, 'add_extra_recipients')); if ($is_auto_created) { Notification::notifyAutoCreatedIssue($prj_id, $email['issue_id'], $email['from'], $email['date'], $email['subject'], $address); } } } }
/** * 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; }
/** * Method used to get the timezone preferred by the user. * * @param integer $usr_id The user ID * @return string The timezone preferred by the user */ public static function getPreferredTimezone($usr_id = null) { if (!$usr_id) { $usr_id = Auth::getUserID(); } if (!$usr_id) { return self::getDefaultTimezone(); } $prefs = Prefs::get($usr_id); if (!empty($prefs['timezone'])) { return $prefs['timezone']; } return self::getDefaultTimezone(); }
// | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('emails.tpl.html'); Auth::checkAuthentication(APP_COOKIE); if (!Access::canAccessAssociateEmails(Auth::getUserID())) { $tpl->assign('no_access', 1); $tpl->displayTemplate(); exit; } $pagerRow = Support::getParam('pagerRow'); if (empty($pagerRow)) { $pagerRow = 0; } $rows = Support::getParam('rows'); if (empty($rows)) { $rows = APP_DEFAULT_PAGER_SIZE; } $options = Support::saveSearchParams(); $tpl->assign('options', $options); $tpl->assign('sorting', Support::getSortingInfo($options)); $list = Support::getEmailListing($options, $pagerRow, $rows); $tpl->assign('list', $list['list']); $tpl->assign('list_info', $list['info']); $tpl->assign('issues', Issue::getColList()); $tpl->assign('accounts', Email_Account::getAssocList(Auth::getCurrentProject())); $prefs = Prefs::get(Auth::getUserID()); $tpl->assign('refresh_rate', $prefs['email_refresh_rate'] * 60); $tpl->assign('refresh_page', 'emails.php'); $tpl->displayTemplate();
/** * Sets the current selected project for the user session. * * @access public * @param integer $project The project ID * @param integer $remember Whether to automatically remember the setting or not * @return void */ function setCurrentProject($project, $remember) { $cookie = array("prj_id" => $project, "remember" => $remember); $cookie = base64_encode(serialize($cookie)); setcookie(APP_PROJECT_COOKIE, $cookie, APP_PROJECT_COOKIE_EXPIRE, APP_COOKIE_URL, APP_COOKIE_DOMAIN); Auth::createFakeCookie(Auth::getUserID(), $project); }
// | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to: | // | | // | Free Software Foundation, Inc. | // | 51 Franklin Street, Suite 330 | // | Boston, MA 02110-1301, USA. | // +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('history.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $iss_id = $_GET['iss_id']; if (!Access::canViewHistory($iss_id, Auth::getUserID())) { $tpl->setTemplate('permission_denied.tpl.html'); $tpl->displayTemplate(); exit; } $tpl->assign('changes', History::getListing($iss_id)); $tpl->assign('issue_id', $iss_id); $role_id = Auth::getCurrentRole(); if ($role_id > User::getRoleID('Customer')) { $tpl->assign('reminders', Reminder::getHistoryList($_GET['iss_id'])); } $tpl->displayTemplate();
} $customer_id = Issue::getCustomerID($HTTP_GET_VARS['issue']); if (!empty($customer_id)) { $contact_emails = array_keys(Customer::getContactEmailAssocList($prj_id, $customer_id)); $unknown_contacts = array(); foreach ($sender_emails as $email => $address) { if (!@in_array($email, $contact_emails)) { $usr_id = User::getUserIDByEmail($email); if (empty($usr_id)) { $unknown_contacts[] = $address; } else { // if we got a real user ID, check if the customer user is the correct one // (i.e. a contact from the customer associated with the selected issue) if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) { // also check if the associated customer ID, if any, matches the one in the issue $user_customer_id = User::getCustomerID($usr_id); if ($user_customer_id != $customer_id) { $unknown_contacts[] = $address; } } } } } if (count($unknown_contacts) > 0) { $tpl->assign('unknown_contacts', $unknown_contacts); } } } } $tpl->assign("current_user_prefs", Prefs::get(Auth::getUserID())); $tpl->displayTemplate();
/** * Generates the workload by time period graph. * * @param string $type */ public function WorkloadTimePeriodGraph($type) { $usr_id = Auth::getUserID(); // get timezone of current user $user_prefs = Prefs::get($usr_id); if ($type == 'email') { $data = Report::getEmailWorkloadByTimePeriod($user_prefs['timezone'], true); $graph_title = ev_gettext('Email by Time Period'); $event_type = ev_gettext('emails'); } else { $data = Report::getWorkloadByTimePeriod($user_prefs['timezone'], true); $graph_title = ev_gettext('Workload by Time Period'); $event_type = ev_gettext('actions'); } // TRANSLATORS: %s = Timezone name $xtitle = ev_gettext('Hours (%s)', Date_Helper::getTimezoneShortNameByUser($usr_id)); // rebuild data for phplot format $plotData = array(); $legends = array(); $i = 1; foreach ($data as $performer => $values) { foreach ($values as $hour => $value) { $plotData[(int) $hour][0] = $hour; $plotData[(int) $hour][$i] = $value; } $legends[$i] = ucfirst($performer) . ' ' . $event_type; $i++; } $plot = $this->create(900, 350); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($plotData); $plot->SetTitle($graph_title); $plot->SetLegend($legends); $plot->SetYTitle($event_type); $plot->SetXTitle($xtitle); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetYDataLabelPos('plotin'); $plot->SetYLabelType('printf', '%.0f%%'); $plot->group_frac_width = 1; $plot->DrawGraph(); }
/** * Method used to add a FAQ entry to the system. * * @return integer 1 if the insert worked, -1 otherwise */ public static function insert() { if (Validation::isWhitespace($_POST['title'])) { return -2; } if (Validation::isWhitespace($_POST['message'])) { return -3; } $stmt = 'INSERT INTO {{%faq}} ( faq_prj_id, faq_usr_id, faq_created_date, faq_title, faq_message, faq_rank ) VALUES ( ?, ?, ?, ?, ?, ? )'; $params = array($_POST['project'], Auth::getUserID(), Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['message'], $_POST['rank']); try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return -1; } $new_faq_id = DB_Helper::get_last_insert_id(); if (isset($_POST['support_levels']) && count($_POST['support_levels']) > 0) { // now populate the faq-support level mapping table foreach ($_POST['support_levels'] as $support_level_id) { self::addSupportLevelAssociation($new_faq_id, $support_level_id); } } return 1; }
/** * Sets the assignees for the issue * * @param integer $issue_id * @param array $assignees * @return int 1 if success, -1 if error, 0 if no change was needed. */ public static function setAssignees($issue_id, $assignees) { if (!is_array($assignees)) { $assignees = array(); } // see if there is anything to change $old_assignees = self::getAssignedUserIDs($issue_id); if (count(array_diff($old_assignees, $assignees)) == 0 && count(array_diff($assignees, $old_assignees)) == 0) { return 0; } $old_assignee_names = self::getAssignedUsers($issue_id); Workflow::handleAssignmentChange(self::getProjectID($issue_id), $issue_id, Auth::getUserID(), self::getDetails($issue_id), $assignees, true); // clear up the assignments for this issue, and then assign it to the current user self::deleteUserAssociations($issue_id); $assignee_names = array(); foreach ($assignees as $assignee) { $res = self::addUserAssociation(Auth::getUserID(), $issue_id, $assignee, false); if ($res == -1) { return -1; } $assignee_names[] = User::getFullName($assignee); Notification::subscribeUser(Auth::getUserID(), $issue_id, $assignee, Notification::getDefaultActions($issue_id, User::getEmail($assignee), 'set_assignees'), false); } Notification::notifyNewAssignment($assignees, $issue_id); $usr_id = Auth::getUserID(); History::add($issue_id, $usr_id, 'user_associated', 'Issue assignment to changed ({changes}) by {user}', array('changes' => History::formatChanges(implode(', ', $old_assignee_names), implode(', ', $assignee_names)), 'user' => User::getFullName($usr_id))); return 1; }
// | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to: | // | | // | Free Software Foundation, Inc. | // | 51 Franklin Street, Suite 330 | // | Boston, MA 02110-1301, USA. | // +----------------------------------------------------------------------+ // | Authors: Dave Anderson <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('edit_reporter.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $prj_id = Auth::getCurrentProject(); $issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : $_GET['iss_id']; $tpl->assign('issue_id', $issue_id); if (!Access::canChangeReporter($issue_id, Auth::getUserID())) { $tpl->setTemplate('permission_denied.tpl.html'); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'update') { $res = Edit_Reporter::update($issue_id, trim($_POST['email'])); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the Reporter was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the Reporter.'), Misc::MSG_ERROR))); Auth::redirect(APP_RELATIVE_URL . 'view.php?id=' . $issue_id); } $t = Project::getAddressBook($prj_id, $issue_id); $tpl->assign('allowed_reporters', $t); $tpl->displayTemplate();
/** * Converts a note to a draft or an email * * @param int $note_id The id of the note * @param string $target What the note should be converted too (email, etc) * @param bool $authorize_sender If $authorize_sender If the sender should be added to authorized senders list. * @return int */ public static function convertNote($note_id, $target, $authorize_sender = false) { $issue_id = self::getIssueID($note_id); $email_account_id = Email_Account::getEmailAccount(); $blocked_message = self::getBlockedMessage($note_id); $unknown_user = self::getUnknownUser($note_id); $structure = Mime_Helper::decode($blocked_message, true, true); $body = $structure->body; $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from'])); $current_usr_id = Auth::getUserID(); if ($target == 'email') { if (Mime_Helper::hasAttachments($structure)) { $has_attachments = 1; } else { $has_attachments = 0; } list($blocked_message, $headers) = Mail_Helper::rewriteThreadingHeaders($issue_id, $blocked_message, @$structure->headers); $t = array('issue_id' => $issue_id, 'ema_id' => $email_account_id, 'message_id' => @$structure->headers['message-id'], 'date' => Date_Helper::getCurrentDateGMT(), 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => @$body, 'full_email' => @$blocked_message, 'has_attachment' => $has_attachments, 'headers' => $headers); // need to check for a possible customer association if (!empty($structure->headers['from'])) { $details = Email_Account::getDetails($email_account_id); // check from the associated project if we need to lookup any customers by this email address if (CRM::hasCustomerIntegration($details['ema_prj_id'])) { $crm = CRM::getInstance($details['ema_prj_id']); // check for any customer contact association try { $contact = $crm->getContactByEmail($sender_email); $issue_contract = $crm->getContract(Issue::getContractID($issue_id)); if ($contact->canAccessContract($issue_contract)) { $t['customer_id'] = $issue_contract->getCustomerID(); } } catch (CRMException $e) { } } } if (empty($t['customer_id'])) { $update_type = 'staff response'; $t['customer_id'] = null; } else { $update_type = 'customer action'; } $res = Support::insertEmail($t, $structure, $sup_id); if ($res != -1) { Support::extractAttachments($issue_id, $structure); // notifications about new emails are always external $internal_only = false; // special case when emails are bounced back, so we don't want to notify the customer about those if (Notification::isBounceMessage($sender_email)) { $internal_only = true; } Notification::notifyNewEmail($current_usr_id, $issue_id, $t, $internal_only, false, '', $sup_id); Issue::markAsUpdated($issue_id, $update_type); self::remove($note_id, false); History::add($issue_id, $current_usr_id, 'note_converted_email', 'Note converted to e-mail (from: {from}) by {user}', array('from' => @$structure->headers['from'], 'user' => User::getFullName($current_usr_id))); // now add sender as an authorized replier if ($authorize_sender) { Authorized_Replier::manualInsert($issue_id, @$structure->headers['from']); } } return $res; } // save message as a draft $res = Draft::saveEmail($issue_id, $structure->headers['to'], $structure->headers['cc'], $structure->headers['subject'], $body, false, $unknown_user); // remove the note, if the draft was created successfully if ($res) { self::remove($note_id, false); $usr_id = $current_usr_id; History::add($issue_id, $usr_id, 'note_converted_draft', 'Note converted to draft (from: {from}) by {user}', array('from' => @$structure->headers['from'], 'user' => User::getFullName($current_usr_id))); } return $res; }
/** * Method used to add a news entry to the system. * * @return integer 1 if the insert worked, -1 otherwise */ public static function insert() { if (Validation::isWhitespace($_POST['title'])) { return -2; } if (Validation::isWhitespace($_POST['message'])) { return -3; } $stmt = 'INSERT INTO {{%news}} ( nws_usr_id, nws_created_date, nws_title, nws_message, nws_status ) VALUES ( ?, ?, ?, ?, ? )'; $params = array(Auth::getUserID(), Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['message'], $_POST['status']); try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return -1; } $new_news_id = DB_Helper::get_last_insert_id(); // now populate the project-news mapping table foreach ($_POST['projects'] as $prj_id) { self::addProjectAssociation($new_news_id, $prj_id); } return 1; }
/** * Adds a real user to the authorized repliers list. * * @param integer $issue_id The id of the issue. * @param integer $usr_id The id of the user. * @param boolean $add_history If this should be logged. */ public static function addUser($issue_id, $usr_id, $add_history = true) { // don't add customers to this list. They should already be able to send if (User::getRoleByUser($usr_id, Issue::getProjectID($issue_id)) == User::getRoleID('Customer')) { return -2; } $stmt = 'INSERT INTO {{%issue_user_replier}} ( iur_iss_id, iur_usr_id ) VALUES ( ?, ? )'; try { DB_Helper::getInstance()->query($stmt, array($issue_id, $usr_id)); } catch (DbException $e) { return -1; } if ($add_history) { // add the change to the history of the issue $current_usr_id = Auth::getUserID(); History::add($issue_id, $current_usr_id, 'replier_added', '{other_user} added to the authorized repliers list by {user}', array('other_user' => User::getFullName($usr_id), 'user' => User::getFullName($current_usr_id))); } return 1; }
/** * Method used to remove specific custom filters. * * @return integer 1 if the removals worked properly, any other value otherwise */ public static function remove() { foreach ($_POST['item'] as $cst_id) { $stmt = 'DELETE FROM {{%custom_filter}} WHERE'; $params = array(); if (self::isGlobal($cst_id)) { if (Auth::getCurrentRole() >= User::ROLE_MANAGER) { $stmt .= ' cst_is_global=1 AND '; } else { $stmt .= ' cst_is_global=1 AND cst_usr_id=? AND '; $params[] = Auth::getUserID(); } } else { $stmt .= ' cst_usr_id=? AND '; $params[] = Auth::getUserID(); } $stmt .= ' cst_prj_id=? AND cst_id=?'; $params[] = Auth::getCurrentProject(); $params[] = $cst_id; try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return -1; } } return 1; }
// | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ // // @(#) $Id$ // 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.user.php"; include_once APP_INC_PATH . "class.note.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("post_note.tpl.html"); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $prj_id = Auth::getCurrentProject(); $usr_id = Auth::getUserID(); @($issue_id = $HTTP_GET_VARS["issue_id"] ? $HTTP_GET_VARS["issue_id"] : $HTTP_POST_VARS["issue_id"]); $details = Issue::getDetails($issue_id); $tpl->assign("issue_id", $issue_id); $tpl->assign("issue", $details); if (!Issue::canAccess($issue_id, $usr_id)) { $tpl->setTemplate("permission_denied.tpl.html"); $tpl->displayTemplate(); exit; } if (@$HTTP_POST_VARS["cat"] == "post_note") { // change status if (!@empty($HTTP_POST_VARS['new_status'])) { $res = Issue::setStatus($issue_id, $HTTP_POST_VARS['new_status']); if ($res != -1) { $new_status = Status::getStatusTitle($HTTP_POST_VARS['new_status']);
include_once APP_INC_PATH . "class.workflow.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("manage/index.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $tpl->assign("type", "projects"); $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"] == "new") { $tpl->assign("result", Project::insert()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Project::update()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Project::remove(); } $tpl->assign("active_projects", Project::getAssocList(Auth::getUserID(), true)); if (@$HTTP_GET_VARS["cat"] == "edit") { $tpl->assign("info", Project::getDetails($HTTP_GET_VARS["id"])); } $tpl->assign("list", Project::getList()); $tpl->assign("user_options", User::getActiveAssocList(false, NULL, false, false, true)); $tpl->assign("status_options", Status::getAssocList()); $tpl->assign("customer_backends", Customer::getBackendList()); $tpl->assign("workflow_backends", Workflow::getBackendList()); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
/** * Method used to add a FAQ entry to the system. * * @access public * @return integer 1 if the insert worked, -1 otherwise */ function insert() { global $HTTP_POST_VARS; if (Validation::isWhitespace($HTTP_POST_VARS["title"])) { return -2; } if (Validation::isWhitespace($HTTP_POST_VARS["message"])) { return -3; } $stmt = "INSERT INTO\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq\n (\n faq_prj_id,\n faq_usr_id,\n faq_created_date,\n faq_title,\n faq_message,\n faq_rank\n ) VALUES (\n " . $HTTP_POST_VARS['project'] . ",\n " . Auth::getUserID() . ",\n '" . Date_API::getCurrentDateGMT() . "',\n '" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["message"]) . "',\n " . $HTTP_POST_VARS['rank'] . "\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_faq_id = $GLOBALS["db_api"]->get_last_insert_id(); if (Customer::doesBackendUseSupportLevels(Misc::escapeInteger($HTTP_POST_VARS['project']))) { // now populate the faq-support level mapping table foreach ($HTTP_POST_VARS['support_levels'] as $support_level_id) { FAQ::addSupportLevelAssociation($new_faq_id, $support_level_id); } } return 1; } }
/** * @param string $command * @return string * @access protected */ public function logCommand($command) { $usr_id = Auth::getUserID(); $email = User::getEmail($usr_id); Logger::cli()->info($command, array('usr_id' => $usr_id, 'email' => $email)); return 'OK'; }