public function __invoke(Template_Helper $tpl) { $units = array('hour' => 'Hours', 'day' => 'Days'); $type_list = array('phone' => 'Phone Calls', 'note' => 'Notes', 'email' => 'Email', 'draft' => 'Drafts', 'time' => 'Time Tracking', 'reminder' => 'Reminders'); $tpl->assign(array('units' => $units, 'users' => Project::getUserAssocList($this->prj_id, 'active', User::getRoleID('Customer')), 'developer' => $this->usr_id, 'type_list' => $type_list, 'activity_types' => $this->activity_types ?: array_keys($type_list), 'unit' => $this->unit, 'amount' => $this->amount, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'sort_order' => $this->sort_order)); if (!$this->unit && !$this->amount) { return; } $data = array(); if (in_array('phone', $this->activity_types)) { $data['phone'] = $this->phoneActivity(); } if (in_array('note', $this->activity_types)) { $data['note'] = $this->noteActivity(); } if (in_array('email', $this->activity_types)) { $data['email'] = $this->emailActivity(); } if (in_array('draft', $this->activity_types)) { $data['draft'] = $this->draftActivity(); } if (in_array('time', $this->activity_types)) { $data['time'] = $this->timeActivity(); } if (!$this->developer && in_array('reminder', $this->activity_types)) { $data['reminder'] = $this->reminderActivity(); } $tpl->assign(array('data' => $data, 'developer' => $this->developer)); }
/** * Adds an email to the outgoing mail queue. * * @param string $recipient The recipient of this email * @param array $headers The list of headers that should be sent with this email * @param string $body The body of the message * @param integer $save_email_copy Whether to send a copy of this email to a configurable address or not (eventum_sent@) * @param integer $issue_id The ID of the issue. If false, email will not be associated with issue. * @param string $type The type of message this is. * @param integer $sender_usr_id The id of the user sending this email. * @param integer $type_id The ID of the event that triggered this notification (issue_id, sup_id, not_id, etc) * @return true, or a PEAR_Error object */ public static function add($recipient, $headers, $body, $save_email_copy = 0, $issue_id = false, $type = '', $sender_usr_id = false, $type_id = false) { Workflow::modifyMailQueue(Auth::getCurrentProject(false), $recipient, $headers, $body, $issue_id, $type, $sender_usr_id, $type_id); // avoid sending emails out to users with inactive status $recipient_email = Mail_Helper::getEmailAddress($recipient); $usr_id = User::getUserIDByEmail($recipient_email); if (!empty($usr_id)) { $user_status = User::getStatusByEmail($recipient_email); // if user is not set to an active status, then silently ignore if (!User::isActiveStatus($user_status) && !User::isPendingStatus($user_status)) { return false; } } $to_usr_id = User::getUserIDByEmail($recipient_email); $recipient = Mail_Helper::fixAddressQuoting($recipient); $reminder_addresses = Reminder::_getReminderAlertAddresses(); // add specialized headers if (!empty($issue_id) && (!empty($to_usr_id) && User::getRoleByUser($to_usr_id, Issue::getProjectID($issue_id)) != User::getRoleID('Customer')) || @in_array(Mail_Helper::getEmailAddress($recipient), $reminder_addresses)) { $headers += Mail_Helper::getSpecializedHeaders($issue_id, $type, $headers, $sender_usr_id); } // try to prevent triggering absence auto responders $headers['precedence'] = 'bulk'; // the 'classic' way, works with e.g. the unix 'vacation' tool $headers['Auto-submitted'] = 'auto-generated'; // the RFC 3834 way if (empty($issue_id)) { $issue_id = 'null'; } // if the Date: header is missing, add it. if (empty($headers['Date'])) { $headers['Date'] = Mime_Helper::encode(date('D, j M Y H:i:s O')); } if (!empty($headers['To'])) { $headers['To'] = Mail_Helper::fixAddressQuoting($headers['To']); } // encode headers and add special mime headers $headers = Mime_Helper::encodeHeaders($headers); $res = Mail_Helper::prepareHeaders($headers); if (Misc::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return $res; } // convert array of headers into text headers list(, $text_headers) = $res; $params = array('maq_save_copy' => $save_email_copy, 'maq_queued_date' => Date_Helper::getCurrentDateGMT(), 'maq_sender_ip_address' => !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'maq_recipient' => $recipient, 'maq_headers' => $text_headers, 'maq_body' => $body, 'maq_iss_id' => $issue_id, 'maq_subject' => $headers['Subject'], 'maq_type' => $type); if ($sender_usr_id) { $params['maq_usr_id'] = $sender_usr_id; } if ($type_id) { $params['maq_type_id'] = $type_id; } $stmt = 'INSERT INTO {{%mail_queue}} SET ' . DB_Helper::buildSet($params); try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return $res; } return true; }
public function getIssueIDs($options) { // Build the Sphinx client $this->sphinx->SetSortMode(SPH_SORT_RELEVANCE); // $this->sphinx->SetWeights(array(1, 1)); $this->sphinx->SetLimits(0, 500, 100000); $this->sphinx->SetArrayResult(true); if (empty($options['match_mode'])) { $options['match_mode'] = SPH_MATCH_ALL; } $this->sphinx->SetMatchMode($options['match_mode']); $this->sphinx->SetFilter('prj_id', array(Auth::getCurrentProject())); // TODO: Add support for selecting indexes to search $indexes = implode('; ', $this->getIndexes(Auth::getCurrentRole() > User::getRoleID('Customer'))); if (isset($options['customer_id']) && !empty($options['customer_id'])) { $this->sphinx->SetFilter('customer_id', array($options['customer_id'])); } $this->keywords = $options['keywords']; $this->match_mode = $options['match_mode']; $res = $this->sphinx->Query($options['keywords'], $indexes); // TODO: report these somehow back to the UI if (method_exists($this->sphinx, 'IsConnectError') && $this->sphinx->IsConnectError()) { error_log('sphinx_fulltext_search: Network Error'); } if ($this->sphinx->GetLastWarning()) { error_log('sphinx_fulltext_search: WARNING: ' . $this->sphinx->GetLastWarning()); } if ($this->sphinx->GetLastError()) { error_log('sphinx_fulltext_search: ERROR: ' . $this->sphinx->GetLastError()); } $issue_ids = array(); if (isset($res['matches'])) { foreach ($res['matches'] as $match_details) { // Variable translation $match_id = $match_details['id']; $issue_id = $match_details['attrs']['issue_id']; $weight = $match_details['weight']; $index_id = $match_details['attrs']['index_id']; // if sphinx returns 0 as a weight, make it one because it // did find a match in the result set if ($weight <= 0) { $weight = 1; } $index_name = $this->getIndexNameByID($index_id); $this->matches[$issue_id][] = array('weight' => $weight, 'index' => $index_name, 'match_id' => $match_id); $issue_ids[] = $issue_id; } } return $issue_ids; }
/** * Returns the columns that should be displayed for the specified page. * This method will remove columns that should not be displayed, due to * lack of customer integration or insufficient role. * * @param integer $prj_id The ID of the project. * @param string $page The page to return columns for. * @return array An array of columns that should be displayed. */ public static function getColumnsToDisplay($prj_id, $page) { static $returns; // poor man's caching system if (!empty($returns[$prj_id][$page])) { return $returns[$prj_id][$page]; } $current_role = Auth::getCurrentRole(); $data = self::getSelectedColumns($prj_id, $page); $has_customer_integration = CRM::hasCustomerIntegration($prj_id); $only_with_customers = array('iss_customer_id', 'support_level'); // remove groups if there are no groups in the system. if (count(Group::getAssocList($prj_id)) < 1) { unset($data['iss_grp_id']); } // remove category column if there are no categories in the system if (count(Category::getAssocList($prj_id)) < 1) { unset($data['prc_title']); } // remove custom fields column if there are no custom fields if (count(Custom_Field::getFieldsToBeListed($prj_id)) < 1) { unset($data['custom_fields']); } // remove customer field if user has a role of customer if ($current_role == User::getRoleID('Customer')) { unset($data['iss_customer_id']); } foreach ($data as $field => $info) { // remove fields based on role if ($info['min_role'] > $current_role) { unset($data[$field]); continue; } // remove fields based on customer integration if (!$has_customer_integration && in_array($field, $only_with_customers)) { unset($data[$field]); continue; } // get title $data[$field] = self::getColumnInfo($page, $field); if (!isset($data[$field]['width'])) { $data[$field]['width'] = ''; } } $returns[$prj_id][$page] = $data; return $data; }
$email = Mail_API::getEmailAddress($senders[$i]); $sender_emails[$email] = $senders[$i]; } $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); } } } }
function getList($fld_id) { return User::getActiveAssocList(Auth::getCurrentProject(), User::getRoleID("Standard User")); }
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", Customer::insertAccountManager()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Customer::updateAccountManager()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Customer::removeAccountManager(); } elseif (!empty($HTTP_GET_VARS['prj_id'])) { $tpl->assign("info", array('cam_prj_id' => $HTTP_GET_VARS['prj_id'])); $tpl->assign('customers', Customer::getAssocList($HTTP_GET_VARS['prj_id'])); } if (@$HTTP_GET_VARS["cat"] == "edit") { $info = Customer::getAccountManagerDetails($HTTP_GET_VARS["id"]); if (!empty($HTTP_GET_VARS['prj_id'])) { $info['cam_prj_id'] = $HTTP_GET_VARS['prj_id']; } $tpl->assign('customers', Customer::getAssocList($info['cam_prj_id'])); $tpl->assign("info", $info); } $tpl->assign("list", Customer::getAccountManagerList()); if (!empty($_REQUEST['prj_id'])) { $tpl->assign("user_options", User::getActiveAssocList($_REQUEST['prj_id'], User::getRoleID('Customer'))); } $tpl->assign("project_list", Project::getAll(false)); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
/** * 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; }
public static function canAccessReports($usr_id) { $prj_id = Auth::getCurrentProject(); if (User::isPartner($usr_id)) { $partner = Partner::canUserAccessFeature($usr_id, 'reports'); if (is_bool($partner)) { return $partner; } } if (User::getRoleByUser($usr_id, $prj_id) > User::getRoleID('Customer')) { return true; } return false; }
// @(#) $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.display_column.php"; include_once APP_INC_PATH . "db_access.php"; $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) {
/** * Called when an attempt is made to add a user or email address to the * notification list. * * @param integer $prj_id The project ID * @param integer $issue_id The ID of the issue. * @param integer $subscriber_usr_id The ID of the user to subscribe if this is a real user (false otherwise). * @param string $email The email address to subscribe to subscribe (if this is not a real user). * @param array $types The action types. * @return mixed An array of information or true to continue unchanged or false to prevent the user from being added. */ function handleSubscription($prj_id, $issue_id, &$subscriber_usr_id, &$email, &$actions) { if ($prj_id != 5) { if (User::getRoleByUser($subscriber_usr_id, $prj_id) >= User::getRoleID('Developer')) { return false; } } return true; }
/** * TODO: merge use of $options and $email arrays to just $email * * @param int $issue_id * @param string $type type of email * @param string $from * @param string $to * @param string $cc * @param string $subject * @param string $body * @param array $options optional parameters * - (int) parent_sup_id * - (array) iaf_ids attachment file ids * - (bool) add_unknown * - (int) ema_id * @return int 1 if it worked, -1 otherwise */ public static function sendEmail($issue_id, $type, $from, $to, $cc, $subject, $body, $options = array()) { $parent_sup_id = $options['parent_sup_id']; $iaf_ids = $options['iaf_ids']; $add_unknown = $options['add_unknown']; $ema_id = $options['ema_id']; $current_usr_id = Auth::getUserID(); $prj_id = Issue::getProjectID($issue_id); // if we are replying to an existing email, set the In-Reply-To: header accordingly $in_reply_to = $parent_sup_id ? self::getMessageIDByID($parent_sup_id) : false; // get ID of whoever is sending this. $sender_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($from)) ?: false; // remove extra 'Re: ' from subject $subject = Mail_Helper::removeExcessRe($subject, true); $internal_only = false; $message_id = Mail_Helper::generateMessageID(); // process any files being uploaded // from ajax upload, attachment file ids if ($iaf_ids) { // FIXME: is it correct to use sender from post data? $attach_usr_id = $sender_usr_id ?: $current_usr_id; Attachment::attachFiles($issue_id, $attach_usr_id, $iaf_ids, false, 'Attachment originated from outgoing email'); } // hack needed to get the full headers of this web-based email $full_email = self::buildFullHeaders($issue_id, $message_id, $from, $to, $cc, $subject, $body, $in_reply_to, $iaf_ids); // email blocking should only be done if this is an email about an associated issue if ($issue_id) { $user_info = User::getNameEmail($current_usr_id); // check whether the current user is allowed to send this email to customers or not if (!self::isAllowedToEmail($issue_id, $user_info['usr_email'])) { // add the message body as a note $note = Mail_Helper::getCannedBlockedMsgExplanation() . $body; $note_options = array('full_message' => $full_email, 'is_blocked' => true); Note::insertNote($current_usr_id, $issue_id, $subject, $note, $note_options); $email_details = array('from' => $from, 'to' => $to, 'cc' => $cc, 'subject' => $subject, 'body' => &$body, 'message' => &$body, 'title' => $subject); Workflow::handleBlockedEmail($prj_id, $issue_id, $email_details, 'web'); return 1; } } // only send a direct email if the user doesn't want to add the Cc'ed people to the notification list if (($add_unknown || Workflow::shouldAutoAddToNotificationList($prj_id)) && $issue_id) { // add the recipients to the notification list of the associated issue $recipients = array($to); $recipients = array_merge($recipients, self::getRecipientsCC($cc)); foreach ($recipients as $address) { if ($address && !Notification::isIssueRoutingSender($issue_id, $address)) { $actions = Notification::getDefaultActions($issue_id, $address, 'add_unknown_user'); Notification::subscribeEmail($current_usr_id, $issue_id, Mail_Helper::getEmailAddress($address), $actions); } } } else { // Usually when sending out emails associated to an issue, we would // simply insert the email in the table and call the Notification::notifyNewEmail() method, // but on this case we need to actually send the email to the recipients that are not // already in the notification list for the associated issue, if any. // In the case of replying to an email that is not yet associated with an issue, then // we are always directly sending the email, without using any notification list // functionality. if ($issue_id) { // send direct emails only to the unknown addresses, and leave the rest to be // catched by the notification list $from = Notification::getFixedFromHeader($issue_id, $from, 'issue'); // build the list of unknown recipients if ($to) { $recipients = array($to); $recipients = array_merge($recipients, self::getRecipientsCC($cc)); } else { $recipients = self::getRecipientsCC($cc); } $unknowns = array(); foreach ($recipients as $address) { if (!Notification::isSubscribedToEmails($issue_id, $address)) { $unknowns[] = $address; } } if ($unknowns) { $to2 = array_shift($unknowns); $cc2 = implode('; ', $unknowns); // send direct emails self::sendDirectEmail($issue_id, $from, $to2, $cc2, $subject, $body, $_FILES['attachment'], $message_id, $sender_usr_id); } } else { // send direct emails to all recipients, since we don't have an associated issue $project_info = Project::getOutgoingSenderAddress(Auth::getCurrentProject()); // use the project-related outgoing email address, if there is one if (!empty($project_info['email'])) { $from = Mail_Helper::getFormattedName(User::getFullName($current_usr_id), $project_info['email']); } else { // otherwise, use the real email address for the current user $from = User::getFromHeader($current_usr_id); } // send direct emails self::sendDirectEmail($issue_id, $from, $to, $cc, $subject, $body, $_FILES['attachment'], $message_id); } } $email = array('customer_id' => 'NULL', 'issue_id' => $issue_id, 'ema_id' => $ema_id, 'message_id' => $message_id, 'date' => Date_Helper::getCurrentDateGMT(), 'from' => $from, 'to' => $to, 'cc' => $cc, 'subject' => $subject, 'body' => $body, 'full_email' => $full_email); // associate this new email with a customer, if appropriate if (Auth::getCurrentRole() == User::getRoleID('Customer')) { if ($issue_id) { $crm = CRM::getInstance($prj_id); try { $contact = $crm->getContact(User::getCustomerContactID($current_usr_id)); $issue_contract = $crm->getContract(Issue::getContractID($issue_id)); if ($contact->canAccessContract($issue_contract)) { $email['customer_id'] = $issue_contract->getCustomerID(); } } catch (CRMException $e) { } } else { $customer_id = User::getCustomerID($current_usr_id); if ($customer_id && $customer_id != -1) { $email['customer_id'] = $customer_id; } } } $email['has_attachment'] = $iaf_ids ? 1 : 0; $structure = Mime_Helper::decode($full_email, true, false); $email['headers'] = $structure->headers; self::insertEmail($email, $structure, $sup_id); if ($issue_id) { // need to send a notification Notification::notifyNewEmail($current_usr_id, $issue_id, $email, $internal_only, false, $type, $sup_id); // mark this issue as updated $has_customer = $email['customer_id'] && $email['customer_id'] != 'NULL'; if ($has_customer && (!$current_usr_id || User::getRoleByUser($current_usr_id, $prj_id) == User::getRoleID('Customer'))) { Issue::markAsUpdated($issue_id, 'customer action'); } else { if ($sender_usr_id && User::getRoleByUser($sender_usr_id, $prj_id) > User::getRoleID('Customer')) { Issue::markAsUpdated($issue_id, 'staff response'); } else { Issue::markAsUpdated($issue_id, 'user response'); } } History::add($issue_id, $current_usr_id, 'email_sent', 'Outgoing email sent by {user}', array('user' => User::getFullName($current_usr_id))); } return 1; }
// | 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('add_phone_entry.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : $_GET['iss_id']; if (!Issue::canAccess($issue_id, Auth::getUserID()) || Auth::getCurrentRole() <= User::getRoleID('Customer')) { $tpl = new Template_Helper(); $tpl->setTemplate('permission_denied.tpl.html'); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'add_phone') { $res = Phone_Support::insert(); $tpl->assign('add_phone_result', $res); } $prj_id = Issue::getProjectID($issue_id); $usr_id = Auth::getUserID(); $tpl->assign(array('issue_id' => $issue_id, 'phone_categories' => Phone_Support::getCategoryAssocList($prj_id), 'current_user_prefs' => Prefs::get($usr_id))); $tpl->displayTemplate();
// +----------------------------------------------------------------------+ // | Authors: Raul Raat <*****@*****.**> | // | Authors: Elan Ruusamäe <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../../init.php'; // check login Auth::checkAuthentication(APP_COOKIE); $field_name = !empty($_POST['field_name']) ? $_POST['field_name'] : null; $issue_id = !empty($_POST['issue_id']) ? (int) $_POST['issue_id'] : null; // check if correct issue id was sent if (!$issue_id || !Issue::exists($issue_id)) { die('Invalid issue_id'); } $usr_id = Auth::getUserID(); // check if user role is above "Standard User" if (User::getRoleByUser($usr_id, Issue::getProjectID($issue_id)) < User::getRoleID('Standard User')) { die('Forbidden'); } // check if user can acess the issue if (!Issue::canAccess($issue_id, $usr_id)) { die('Forbidden'); } switch ($field_name) { case 'expected_resolution_date': $day = Misc::escapeInteger($_POST['day']); $month = Misc::escapeInteger($_POST['month']); $year = Misc::escapeInteger($_POST['year']); if ($day == 0 && $month == 1 && $year == 0) { // clear button $date = null; } else {
public function getList($fld_id) { return User::getActiveAssocList(Auth::getCurrentProject(), User::getRoleID('Viewer')); }
/** * 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; }
// | 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();
/** * Plot various stats charts * * @param string $plotType * @param bool $hide_closed * @return bool return false if no data is available */ public function StatsChart($plotType, $hide_closed) { // don't bother if user has no access $prj_id = Auth::getCurrentProject(); if (Auth::getCurrentRole() <= User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id)) { return false; } $colors = array(); switch ($plotType) { case 'status': $data = Stats::getAssocStatus($hide_closed); $graph_title = ev_gettext('Issues by Status'); // use same colors as defined for statuses foreach ($data as $sta_title => $trash) { $sta_id = Status::getStatusID($sta_title); $status_details = Status::getDetails($sta_id); $colors[] = $status_details['sta_color']; } break; case 'release': $data = Stats::getAssocRelease($hide_closed); $graph_title = ev_gettext('Issues by Release'); break; case 'priority': $data = Stats::getAssocPriority($hide_closed); $graph_title = ev_gettext('Issues by Priority'); break; case 'user': $data = Stats::getAssocUser($hide_closed); $graph_title = ev_gettext('Issues by Assignment'); break; case 'category': $data = Stats::getAssocCategory($hide_closed); $graph_title = ev_gettext('Issues by Category'); break; default: return false; } // check the values coming from the database and if they are all empty, then // output a pre-generated 'No Data Available' picture if (!Stats::hasData($data)) { return false; } $plot = $this->create(360, 200); $plot->SetImageBorderType('plain'); $plot->SetTitle($graph_title); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); if ($colors) { $plot->SetDataColors($colors); } $legend = $dataValue = array(); foreach ($data as $label => $count) { $legend[] = $label . ' (' . $count . ')'; $dataValue[] = array($label, $count); } $plot->SetDataValues($dataValue); foreach ($legend as $label) { $plot->SetLegend($label); } return $plot->DrawGraph(); }
/** * 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; } }
} elseif (@$_POST['cat'] == 'change_status') { User::changeStatus($_POST['items'], $_POST['status']); } $project_roles = array(); $project_list = Project::getAll(); if (@$_GET['cat'] == 'edit') { $info = User::getDetails($_GET['id']); $tpl->assign('info', $info); } foreach ($project_list as $prj_id => $prj_title) { $excluded_roles = array('Customer'); if (@$info['roles'][$prj_id]['pru_role'] == User::getRoleID('Customer')) { if (count($excluded_roles) == 1) { $excluded_roles = false; } else { $excluded_roles = array('administrator'); } if (@$info['roles'][$prj_id]['pru_role'] == User::getRoleID('administrator')) { $excluded_roles = false; } } $project_roles[$prj_id] = $user_roles = array(0 => 'No Access') + User::getRoles($excluded_roles); } $show_customer = !empty($_GET['show_customers']); $show_inactive = !empty($_GET['show_inactive']); $tpl->assign('list', User::getList($show_customer, $show_inactive)); $tpl->assign('project_list', $project_list); $tpl->assign('project_roles', $project_roles); $tpl->assign('group_list', Group::getAssocListAllProjects()); $tpl->assign('partners', Partner::getAssocList()); $tpl->displayTemplate();
// +----------------------------------------------------------------------+ 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();
/** * Selects a mail queue entry from the table and returns the contents. * * @param string $id The mail queue entry ID. * @return A string containing the body. */ function getMailQueue($id) { if (Auth::getCurrentRole() < User::getRoleID('Developer')) { return; } $res = Mail_Queue::getEntry($id); if (!Issue::canAccess($res['maq_iss_id'], $GLOBALS['usr_id'])) { return ''; } if (empty($_GET['ec_id'])) { return $res['maq_body']; } return Link_Filter::processText(Auth::getCurrentProject(), nl2br(htmlspecialchars($res['maq_headers'] . "\n" . $res['maq_body']))); }
if (CRM::hasCustomerIntegration($prj_id)) { $sender_email = Mail_Helper::getEmailAddress($email_details['sup_from']); try { $contact = $crm->getContactByEmail($sender_email); $tpl->assign('contact_details', $contact->getDetails()); } catch (CRMException $e) { } } } } } $tpl->assign(array('cats' => Category::getAssocList($prj_id), 'priorities' => Priority::getAssocList($prj_id), 'severities' => Severity::getList($prj_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'releases' => Release::getAssocList($prj_id), 'custom_fields' => Custom_Field::getListByProject($prj_id, 'report_form'), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'max_attachment_bytes' => Attachment::getMaxAttachmentSize(true), 'field_display_settings' => Project::getFieldDisplaySettings($prj_id), 'groups' => Group::getAssocList($prj_id), 'products' => Product::getList(false))); $prefs = Prefs::get($usr_id); $tpl->assign('user_prefs', $prefs); $tpl->assign('zones', Date_Helper::getTimezoneList()); if (Auth::getCurrentRole() == User::getRoleID('Customer')) { $crm = CRM::getInstance(Auth::getCurrentProject()); $customer_contact_id = User::getCustomerContactID($usr_id); $contact = $crm->getContact($customer_contact_id); $customer_id = Auth::getCurrentCustomerID(); $customer = $crm->getCustomer($customer_id); // TODOCRM: Pull contacts via ajax when user selects contract $tpl->assign(array('customer_id' => $customer_id, 'contact_id' => $customer_contact_id, 'customer' => $customer, 'contact' => $contact)); } $clone_iss_id = isset($_GET['clone_iss_id']) ? (int) $_GET['clone_iss_id'] : null; if ($clone_iss_id && Access::canCloneIssue($clone_iss_id, $usr_id)) { $tpl->assign(Issue::getCloneIssueTemplateVariables($clone_iss_id)); } else { $tpl->assign('defaults', $_REQUEST); } $tpl->displayTemplate();
// | it under the terms of the GNU General Public License as published by | // | the Free Software Foundation; either version 2 of the License, or | // | (at your option) any later version. | // | | // | 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. | // | 59 Temple Place - Suite 330 | // | Boston, MA 02111-1307, USA. | // +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ // // @(#) $Id: s.index.php 1.1 03/09/16 23:01:42-00:00 jpradomaia $ // include_once "../config.inc.php"; include_once APP_INC_PATH . "class.template.php"; include_once APP_INC_PATH . "db_access.php"; Auth::checkAuthentication(APP_COOKIE); if (Auth::getCurrentRole() <= User::getRoleID("Customer")) { Auth::redirect("../main.php"); } $tpl = new Template_API(); $tpl->setTemplate("reports/index.tpl.html"); $tpl->displayTemplate();
$displayFields = User::$editableItems; foreach ($displayFields as $key => $value) { echo "<p>" . $value . "<br>"; echo '<input type="text" name="' . $key . '" title="User ID" value="' . $userProperties[$key] . '"/></p>'; } if (!$newUser) { echo "<p>Employee Number<br>" . $User->getEID() . '</p>'; } //Show Access Role Options echo '<p>Access Role <br>'; echo '<select name="RoleID">'; /** @var UserRole $role */ $UserRoles = UserRole::getRoleList(); foreach ($UserRoles as $role) { echo '<option value="' . $role->getRoleID() . '" '; if ($role->getRoleID() == $User->getRoleID()) { echo 'selected'; } echo '> ' . $role->getRole() . '</option></p>'; } echo '</select>'; //Show Account Status and Employee info if set, else add verification options if (!$newUser) { echo '<p>Account Status <br>' . DisableCode::getDisableReason($User->getDisableCode()) . '</p>'; $employeeProperties = $Employee->getProperties(); foreach (Employee::$displayItems as $key => $value) { echo "<p>" . $value . "<br>"; echo '<input type="text" name="' . $key . '" title="' . $key . '" value="' . $employeeProperties[$key] . '"/></p>'; } } else { echo '<h2>Required Verification</h2>
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']); History::add($issue_id, $usr_id, History::getTypeID('status_changed'), "Status changed to '{$new_status}' by " . User::getFullName($usr_id)); } } $res = Note::insert($usr_id, $issue_id); $tpl->assign("post_result", $res); // enter the time tracking entry about this phone support entry if (!empty($HTTP_POST_VARS['time_spent'])) { $HTTP_POST_VARS['issue_id'] = $issue_id; $HTTP_POST_VARS['category'] = $HTTP_POST_VARS['time_category']; $HTTP_POST_VARS['summary'] = 'Time entry inserted when sending an internal note.'; Time_Tracking::insertEntry(); } } elseif (@$HTTP_GET_VARS["cat"] == "reply") { if (!@empty($HTTP_GET_VARS["id"])) { $note = Note::getDetails($HTTP_GET_VARS["id"]); $date = Misc::formatReplyDate($note["timestamp"]); $header = "\n\n\nOn {$date}, " . $note["not_from"] . " wrote:\n>\n"; $note["not_body"] = $header . Misc::formatReply($note["not_note"]); $tpl->bulkAssign(array("note" => $note, "parent_note_id" => $HTTP_GET_VARS["id"])); $reply_subject = Mail_API::removeExcessRe($note['not_title']); } } if (empty($reply_subject)) { $reply_subject = 'Re: ' . $details['iss_summary']; } $tpl->assign(array('from' => User::getFromHeader($usr_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'current_user_prefs' => Prefs::get($usr_id), 'subscribers' => Notification::getSubscribers($issue_id, false, User::getRoleID("Standard User")), 'statuses' => Status::getAssocStatusList($prj_id, false), 'current_issue_status' => Issue::getStatusID($issue_id), 'time_categories' => Time_Tracking::getAssocCategories(), 'note_category_id' => Time_Tracking::getCategoryID('Note Discussion'), 'reply_subject' => $reply_subject)); $tpl->displayTemplate();
$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))); } $tpl->assign('new_status_result', $res); } elseif ($cat == 'authorize_reply') { $res = Authorized_Replier::addUser($iss_id, $usr_id); $tpl->assign('authorize_reply_result', $res); } elseif ($cat == 'remove_quarantine') { if (Auth::getCurrentRole() > User::getRoleID('Developer')) { $res = Issue::setQuarantine($iss_id, 0); $tpl->assign('remove_quarantine_result', $res); } } elseif ($cat == 'selfnotify') { if (Issue::canAccess($iss_id, $usr_id)) { $res = Notification::subscribeUser($usr_id, $iss_id, $usr_id, Notification::getDefaultActions($iss_id)); $tpl->assign('selfnotify_result', $res); } } $tpl->assign('current_user_prefs', Prefs::get($usr_id)); $tpl->assign('cat', $cat); $tpl->displayTemplate();
include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("reports/weekly.tpl.html"); Auth::checkAuthentication(APP_COOKIE); if (Auth::getCurrentRole() <= User::getRoleID("Customer")) { echo "Invalid role"; exit; } $prj_id = Auth::getCurrentProject(); if (count(@$HTTP_POST_VARS["start"]) > 0 && @$HTTP_POST_VARS["start"]["Year"] != 0 && @$HTTP_POST_VARS["start"]["Month"] != 0 && @$HTTP_POST_VARS["start"]["Day"] != 0) { $start_date = join("-", $HTTP_POST_VARS["start"]); } if (count(@$HTTP_POST_VARS["end"]) > 0 && @$HTTP_POST_VARS["end"]["Year"] != 0 && @$HTTP_POST_VARS["end"]["Month"] != 0 && @$HTTP_POST_VARS["end"]["Day"] != 0) { $end_date = join("-", $HTTP_POST_VARS["end"]); } $tpl->assign(array("weeks" => Date_API::getWeekOptions(3, 0), "users" => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), "start_date" => @$start_date, "end_date" => @$end_date, "report_type" => @$HTTP_POST_VARS["report_type"])); if (!empty($HTTP_POST_VARS["developer"])) { //split date up if (@$HTTP_POST_VARS["report_type"] == "weekly") { $dates = explode("_", $HTTP_POST_VARS["week"]); } else { $dates = array($start_date, $end_date); } // print out emails $data = Report::getWeeklyReport($HTTP_POST_VARS["developer"], $dates[0], $dates[1], @$_REQUEST['separate_closed']); $tpl->assign("data", $data); } if (empty($HTTP_POST_VARS["week"])) { $tpl->assign("week", Date_API::getCurrentWeek()); } else { $tpl->assign("week", $HTTP_POST_VARS["week"]);
/** * Returns data on when support emails are sent/received. * * @param string $timezone Timezone to display time in in addition to GMT * @param boolean $graph If the data should be formatted for use in a graph. Default false * @return array An array of data. */ public static function getEmailWorkloadByTimePeriod($timezone, $graph = false) { // get total counts $stmt = 'SELECT hour(sup_date) AS time_period, count(*) as events FROM {{%support_email}} GROUP BY time_period'; try { $total = DB_Helper::getInstance()->fetchAssoc($stmt); } catch (DbException $e) { return array(); } // get all developer email addresses $users = User::getActiveAssocList(Auth::getCurrentProject(), User::getRoleID('customer')); $emails = array(); foreach ($users as $usr_id => $usr_full_name) { $emails[] = User::getFromHeader($usr_id); } // get number of support emails from developers $list = DB_Helper::buildList($emails); $stmt = "SELECT\n hour(sup_date) AS time_period,\n count(*) as events\n FROM\n {{%support_email}}\n WHERE\n sup_from IN({$list})\n GROUP BY\n time_period"; try { $dev_stats = DB_Helper::getInstance()->fetchAssoc($stmt, $emails); } catch (DbException $e) { return array(); } // get total number of developer and customer events and build cust_stats array $dev_count = 0; $cust_count = 0; $cust_stats = array(); for ($i = 0; $i < 24; $i++) { if (empty($dev_stats[$i])) { $dev_stats[$i] = 0; } $cust_stats[$i] = @$total[$i] - @$dev_stats[$i]; $cust_count += @$total[$i] - @$dev_stats[$i]; $dev_count += @$dev_stats[$i]; } $data = array(); $sort_values = array(); for ($i = 0; $i < 24; $i++) { // convert to the users time zone $dt = Date_Helper::getDateTime(mktime($i, 0, 0), 'GMT'); $gmt_time = $dt->format('H:i'); $dt->setTimeZone(new DateTimeZone($timezone)); $hour = $dt->format('H'); $user_time = $dt->format('H:i'); if ($graph) { $data['developer'][$hour] = ''; $data['customer'][$hour] = ''; } else { $data[$i]['display_time_gmt'] = $gmt_time; $data[$i]['display_time_user'] = $user_time; } // use later to find highest value $sort_values['developer'][$i] = $dev_stats[$i]; $sort_values['customer'][$i] = $cust_stats[$i]; if ($graph) { if ($dev_count == 0) { $data['developer'][$hour] = 0; } else { $data['developer'][$hour] = $dev_stats[$i] / $dev_count * 100; } if ($cust_count == 0) { $data['customer'][$hour] = 0; } else { $data['customer'][$hour] = $cust_stats[$i] / $cust_count * 100; } } else { $data[$i]['developer']['count'] = $dev_stats[$i]; if ($dev_count == 0) { $data[$i]['developer']['percentage'] = 0; } else { $data[$i]['developer']['percentage'] = $dev_stats[$i] / $dev_count * 100; } $data[$i]['customer']['count'] = $cust_stats[$i]; if ($cust_count == 0) { $data[$i]['customer']['percentage'] = 0; } else { $data[$i]['customer']['percentage'] = $cust_stats[$i] / $cust_count * 100; } } } if (!$graph) { // get the highest action times foreach ($sort_values as $performer => $values) { arsort($values); reset($values); $data[key($values)][$performer]['rank'] = 1; } } return $data; }
// | | // | 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('manage/link_filters.tpl.html'); Auth::checkAuthentication(APP_COOKIE); $role_id = Auth::getCurrentRole(); if ($role_id < User::getRoleID('manager')) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'new') { $res = Link_Filter::insert(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the link filter was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new link filter.'), Misc::MSG_INFO))); } elseif (@$_POST['cat'] == 'update') { $res = Link_Filter::update(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the link filter was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the link filter.'), Misc::MSG_INFO))); } elseif (@$_POST['cat'] == 'delete') { $res = Link_Filter::remove(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the link filter was deleted successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to delete the link filter.'), Misc::MSG_INFO))); } if (@$_GET['cat'] == 'edit') {