示例#1
0
function getIssueDescription($issue_id)
{
    if (Issue::canAccess($issue_id, $GLOBALS['usr_id'])) {
        $details = Issue::getDetails($issue_id);
        return Link_Filter::processText(Auth::getCurrentProject(), $details['iss_description']);
    }
}
示例#2
0
function scm_ping($module, $username, $scm_name, $issues, $commit_msg)
{
    // module is per file (svn hook)
    if (is_array($module)) {
        $module = null;
    }
    // process checkins for each issue
    foreach ($issues as $issue_id) {
        // check early if issue exists to report proper message back
        // workflow needs to know project_id to find out which workflow class to use.
        $prj_id = Issue::getProjectID($issue_id);
        if (empty($prj_id)) {
            echo "issue #{$issue_id} not found\n";
            continue;
        }
        $files = array();
        $nfiles = count($_GET['files']);
        for ($y = 0; $y < $nfiles; $y++) {
            $file = array('file' => $_GET['files'][$y], 'old_version' => isset($_GET['old_versions'][$y]) ? $_GET['old_versions'][$y] : null, 'new_version' => isset($_GET['new_versions'][$y]) ? $_GET['new_versions'][$y] : null, 'module' => isset($module) ? $module : $_GET['module'][$y]);
            $files[] = $file;
        }
        $commit_time = Date_Helper::getCurrentDateGMT();
        SCM::addCheckins($issue_id, $commit_time, $scm_name, $username, $commit_msg, $files);
        // print report to stdout of commits so hook could report status back to commiter
        $details = Issue::getDetails($issue_id);
        echo "#{$issue_id} - {$details['iss_summary']} ({$details['sta_title']})\n";
    }
}
示例#3
0
 /**
  * Method to determine if user can access a particular issue
  *
  * @param   integer $issue_id The ID of the issue.
  * @param   integer $usr_id The ID of the user
  * @return  boolean If the user can access the issue
  */
 public static function canAccessIssue($issue_id, $usr_id)
 {
     static $access;
     if (empty($issue_id)) {
         return false;
     }
     if (isset($access[$issue_id . '-' . $usr_id])) {
         return $access[$issue_id . '-' . $usr_id];
     }
     $details = Issue::getDetails($issue_id);
     if (empty($details)) {
         return true;
     }
     $usr_details = User::getDetails($usr_id);
     $usr_role = User::getRoleByUser($usr_id, $details['iss_prj_id']);
     $prj_id = $details['iss_prj_id'];
     $can_access_contract = false;
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         try {
             if (!empty($usr_details['usr_customer_contact_id']) && !empty($details['iss_customer_contract_id'])) {
                 $contact = $crm->getContact($usr_details['usr_customer_contact_id']);
                 $can_access_contract = $contact->canAccessContract($crm->getContract($details['iss_customer_contract_id']));
             }
         } catch (CRMException $e) {
             // TODOCRM: Log exception?
         }
     }
     if (empty($usr_role)) {
         // check if they are even allowed to access the project
         $return = false;
     } elseif (CRM::hasCustomerIntegration($details['iss_prj_id']) && $usr_role == User::getRoleID('Customer') && $can_access_contract === false) {
         // check customer permissions
         $return = false;
     } elseif (!empty($usr_details['usr_par_code']) && !Partner::isPartnerEnabledForIssue($usr_details['usr_par_code'], $issue_id)) {
         // check if the user is a partner
         $return = false;
     } elseif ($details['iss_private'] == 1) {
         // check if the issue is even private
         // check role, reporter, assignment and group
         if ($usr_role > User::getRoleID('Developer')) {
             $return = true;
         } elseif ($details['iss_usr_id'] == $usr_id) {
             $return = true;
         } elseif (Issue::isAssignedToUser($issue_id, $usr_id)) {
             $return = true;
         } elseif (!empty($details['iss_grp_id']) && !empty($usr_details['usr_grp_id']) && $details['iss_grp_id'] == $usr_details['usr_grp_id']) {
             $return = true;
         } elseif (Authorized_Replier::isUserAuthorizedReplier($issue_id, $usr_id)) {
             $return = true;
         } else {
             $return = false;
         }
     } elseif (Auth::getCurrentRole() == User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id) && $details['iss_usr_id'] != $usr_id && !Authorized_Replier::isUserAuthorizedReplier($issue_id, $usr_id)) {
         return false;
     } else {
         $return = true;
     }
     $access[$issue_id . '-' . $usr_id] = $return;
     return $return;
 }
示例#4
0
    $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)));
    }
示例#5
0
 /**
  * @param int $issue_id
  * @param int $email_id
  * @return array
  * @access protected
  */
 public function getEmail($issue_id, $email_id)
 {
     if ($email_id == 0) {
         // return issue description instead
         $issue = Issue::getDetails($issue_id);
         $email = array('sup_date' => $issue['iss_created_date'], 'sup_from' => $issue['reporter'], 'sup_to' => '', 'recipients' => '', 'sup_cc' => '', 'sup_has_attachment' => 0, 'sup_subject' => $issue['iss_summary'], 'message' => $issue['iss_original_description'], 'seb_full_email' => $issue['iss_original_description']);
     } else {
         $email = Support::getEmailBySequence($issue_id, $email_id);
     }
     // get requested email
     if (count($email) < 1 || !is_array($email)) {
         throw new RemoteApiException('Email #' . $email_id . " does not exist for issue #{$issue_id}");
     }
     return $email;
 }
示例#6
0
 /**
  * Checks whether the given email address is allowed to send emails in the
  * issue ID.
  *
  * @param   integer $issue_id The issue ID
  * @param   string $sender_email The email address
  * @return  boolean
  */
 public static function isAllowedToEmail($issue_id, $sender_email)
 {
     $prj_id = Issue::getProjectID($issue_id);
     // check the workflow
     $workflow_can_email = Workflow::canEmailIssue($prj_id, $issue_id, $sender_email);
     if ($workflow_can_email != null) {
         return $workflow_can_email;
     }
     $is_allowed = true;
     $sender_usr_id = User::getUserIDByEmail($sender_email, true);
     if (empty($sender_usr_id)) {
         if (CRM::hasCustomerIntegration($prj_id)) {
             // check for a customer contact with several email addresses
             $crm = CRM::getInstance($prj_id);
             try {
                 $contract = $crm->getContract(Issue::getContractID($issue_id));
                 $contact_emails = array_keys($contract->getContactEmailAssocList());
                 $contact_emails = array_map(function ($s) {
                     return strtolower($s);
                 }, $contact_emails);
             } catch (CRMException $e) {
                 $contact_emails = array();
             }
             if (!in_array(strtolower($sender_email), $contact_emails) && !Authorized_Replier::isAuthorizedReplier($issue_id, $sender_email)) {
                 $is_allowed = false;
             }
         } else {
             if (!Authorized_Replier::isAuthorizedReplier($issue_id, $sender_email)) {
                 $is_allowed = false;
             }
         }
     } else {
         // check if this user is not a customer and
         // also not in the assignment list for the current issue and
         // also not in the authorized repliers list
         // also not the reporter
         $details = Issue::getDetails($issue_id);
         if ($sender_usr_id == $details['iss_usr_id']) {
             $is_allowed = true;
         } elseif (User::isPartner($sender_usr_id) && in_array(User::getPartnerID($sender_usr_id), Partner::getPartnerCodesByIssue($issue_id))) {
             $is_allowed = true;
         } elseif (!Issue::canAccess($issue_id, $sender_usr_id) && !Authorized_Replier::isAuthorizedReplier($issue_id, $sender_email)) {
             $is_allowed = false;
         } elseif (!Authorized_Replier::isAuthorizedReplier($issue_id, $sender_email) && !Issue::isAssignedToUser($issue_id, $sender_usr_id) && User::getRoleByUser($sender_usr_id, Issue::getProjectID($issue_id)) != User::getRoleID('Customer')) {
             $is_allowed = false;
         }
     }
     return $is_allowed;
 }
示例#7
0
 /**
  * Checks whether the given email address is allowed to send emails in the
  * issue ID.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   string $sender_email The email address
  * @return  boolean
  */
 function isAllowedToEmail($issue_id, $sender_email)
 {
     $prj_id = Issue::getProjectID($issue_id);
     // check the workflow
     $workflow_can_email = Workflow::canEmailIssue($prj_id, $issue_id, $sender_email);
     if ($workflow_can_email != null) {
         return $workflow_can_email;
     }
     $is_allowed = true;
     $sender_usr_id = User::getUserIDByEmail($sender_email);
     if (empty($sender_usr_id)) {
         if (Customer::hasCustomerIntegration($prj_id)) {
             // check for a customer contact with several email addresses
             $customer_id = Issue::getCustomerID($issue_id);
             $contact_emails = array_keys(Customer::getContactEmailAssocList($prj_id, $customer_id, Issue::getContractID($issue_id)));
             $contact_emails = array_map('strtolower', $contact_emails);
             if (!in_array(strtolower($sender_email), $contact_emails) && !Authorized_Replier::isAuthorizedReplier($issue_id, $sender_email)) {
                 $is_allowed = false;
             }
         } else {
             if (!Authorized_Replier::isAuthorizedReplier($issue_id, $sender_email)) {
                 $is_allowed = false;
             }
         }
     } else {
         // check if this user is not a customer and
         // also not in the assignment list for the current issue and
         // also not in the authorized repliers list
         // also not the reporter
         $details = Issue::getDetails($issue_id);
         if (!Issue::canAccess($issue_id, $sender_usr_id)) {
             $is_allowed = false;
         }
         if ($sender_usr_id != $details['iss_usr_id'] && !Authorized_Replier::isUserAuthorizedReplier($issue_id, $sender_usr_id) && !Issue::isAssignedToUser($issue_id, $sender_usr_id) && User::getRoleByUser($sender_usr_id, Issue::getProjectID($issue_id)) != User::getRoleID('Customer')) {
             $is_allowed = false;
         } elseif (User::getRoleByUser($sender_usr_id, Issue::getProjectID($issue_id)) == User::getRoleID('Customer') && User::getCustomerID($sender_usr_id) != Issue::getCustomerID($issue_id)) {
             $is_allowed = false;
         }
     }
     return $is_allowed;
 }
示例#8
0
 /**
  * Returns an array of variables to be set on the new issue page when cloning an issue.
  *
  * @param integer $issue_id The ID of the issue to clone
  * @return array
  */
 public static function getCloneIssueTemplateVariables($issue_id)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $clone_details = Issue::getDetails($issue_id);
     $defaults = array('clone_iss_id' => $issue_id, 'category' => $clone_details['iss_prc_id'], 'group' => $clone_details['iss_grp_id'], 'severity' => $clone_details['iss_sev_id'], 'priority' => $clone_details['iss_pri_id'], 'users' => $clone_details['assigned_users'], 'summary' => $clone_details['iss_summary'], 'description' => $clone_details['iss_original_description'], 'expected_resolution_date' => $clone_details['iss_expected_resolution_date'], 'estimated_dev_time' => $clone_details['iss_dev_time'], 'private' => $clone_details['iss_private']);
     if (count($clone_details['products']) > 0) {
         $defaults['product'] = $clone_details['products'][0]['pro_id'];
         $defaults['product_version'] = $clone_details['products'][0]['version'];
     }
     $defaults['custom_fields'] = array();
     foreach (Custom_Field::getListByIssue($prj_id, $issue_id) as $field) {
         if (isset($field['selected_cfo_id'])) {
             $defaults['custom_fields'][$field['fld_id']] = $field['selected_cfo_id'];
         } else {
             $defaults['custom_fields'][$field['fld_id']] = $field['value'];
         }
     }
     $clone_variables = array('defaults' => $defaults);
     if (isset($clone_details['customer']) && isset($clone_details['contact'])) {
         $clone_variables += array('customer_id' => $clone_details['iss_customer_id'], 'contact_id' => $clone_details['iss_customer_contact_id'], 'customer' => $clone_details['customer'], 'contact' => $clone_details['contact']);
     }
     return $clone_variables;
 }
示例#9
0
            $tpl->assign('customer', Customer::getDetails($prj_id, $customer_id));
            $tpl->displayTemplate();
            exit;
        }
        $tpl->assign("message", Customer::getNewIssueMessage($prj_id, $customer_id));
    }
}
if (@$HTTP_POST_VARS["cat"] == "report") {
    $res = Issue::insert();
    if ($res != -1) {
        // show direct links to the issue page, issue listing page and
        // email listing page
        $tpl->assign("new_issue_id", $res);
        $tpl->assign("quarantine", Issue::getQuarantineInfo($res));
        $tpl->assign("errors", $insert_errors);
        $tpl->assign("ticket", Issue::getDetails($res));
    } else {
        // need to show everything again
        $tpl->assign("error_msg", "1");
    }
}
if (@$HTTP_GET_VARS["cat"] == "associate") {
    if (@count($HTTP_GET_VARS["item"]) > 0) {
        $res = Support::getListDetails($HTTP_GET_VARS["item"]);
        $tpl->assign("emails", $res);
        $tpl->assign("attached_emails", @implode(",", $HTTP_GET_VARS["item"]));
        if (Customer::hasCustomerIntegration($prj_id)) {
            // also need to guess the contact_id from any attached emails
            $info = Customer::getCustomerInfoFromEmails($prj_id, $HTTP_GET_VARS["item"]);
            $tpl->assign(array("customer_id" => $info['customer_id'], 'customer_name' => $info['customer_name'], "contact_id" => $info['contact_id'], 'contact_name' => $info['contact_name'], 'contacts' => $info['contacts']));
        }
示例#10
0
    $tpl->assign("delete_filter_result", $res);
} elseif (@$HTTP_POST_VARS["cat"] == "remove_support_email") {
    $res = Support::removeAssociation();
    $tpl->assign("remove_association_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "delete_attachment") {
    $res = Attachment::remove($HTTP_GET_VARS["id"]);
    $tpl->assign("remove_attachment_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "delete_file") {
    $res = Attachment::removeIndividualFile($HTTP_GET_VARS["id"]);
    $tpl->assign("remove_file_result", $res);
} elseif (@$HTTP_POST_VARS["cat"] == "remove_checkin") {
    $res = SCM::remove();
    $tpl->assign("remove_checkin_result", $res);
} elseif (@$HTTP_GET_VARS['cat'] == 'unassign') {
    $res = Issue::deleteUserAssociation($HTTP_GET_VARS["iss_id"], $usr_id);
    Workflow::handleAssignmentChange($prj_id, $HTTP_GET_VARS["iss_id"], Auth::getUserID(), Issue::getDetails($HTTP_GET_VARS["iss_id"]), Issue::getAssignedUserIDs($HTTP_GET_VARS["iss_id"]));
    $tpl->assign('unassign_result', $res);
} elseif (@$HTTP_POST_VARS["cat"] == "remove_email") {
    $res = Support::removeEmails();
    $tpl->assign("remove_email_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "clear_duplicate") {
    $res = Issue::clearDuplicateStatus($HTTP_GET_VARS["iss_id"]);
    $tpl->assign("clear_duplicate_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "delete_phone") {
    $res = Phone_Support::remove($HTTP_GET_VARS["id"]);
    $tpl->assign("delete_phone_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_status") {
    // XXX: need to call the workflow api in the following function?
    $res = Issue::setStatus($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["new_sta_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to status '" . Status::getStatusTitle($HTTP_GET_VARS["new_sta_id"]) . "' by " . User::getFullName($usr_id));
 /**
  * Method used to perform a specific action to an issue.
  *
  * @param   integer $issue_id The issue ID
  * @param   array $reminder The reminder details
  * @param   array $action The action details
  * @return  boolean
  */
 public static function perform($issue_id, $reminder, $action)
 {
     $type = '';
     // - see which action type we're talking about here...
     $action_type = self::getActionType($action['rma_rmt_id']);
     // - do we also need to alert the group leader about this?
     $group_leader_usr_id = 0;
     if ($action['rma_alert_group_leader']) {
         if (Reminder::isDebug()) {
             echo '  - ' . ev_gettext('Processing Group Leader notification') . "\n";
         }
         $group_id = Issue::getGroupID($issue_id);
         // check if there's even a group associated with this issue
         if (empty($group_id)) {
             if (Reminder::isDebug()) {
                 echo '  - ' . ev_gettext('No group associated with issue %1$s', $issue_id) . "\n";
             }
         } else {
             $group_details = Group::getDetails($group_id);
             if (!empty($group_details['grp_manager_usr_id'])) {
                 $group_leader_usr_id = $group_details['grp_manager_usr_id'];
             }
         }
     }
     if (Reminder::isDebug()) {
         echo '  - ' . ev_gettext('Performing action %1$s for issue # %2$s', $action_type, $issue_id) . "\n";
     }
     switch ($action_type) {
         case 'email_assignee':
             $type = 'email';
             $assignees = Issue::getAssignedUserIDs($issue_id);
             $to = array();
             foreach ($assignees as $assignee) {
                 $to[] = User::getFromHeader($assignee);
             }
             // add the group leader to the recipient list, if needed
             if (!empty($group_leader_usr_id)) {
                 $leader_email = User::getFromHeader($group_leader_usr_id);
                 if (!empty($leader_email) && !in_array($leader_email, $to)) {
                     $to[] = $leader_email;
                 }
             }
             break;
         case 'email_list':
             $type = 'email';
             $list = self::getUserList($action['rma_id']);
             $to = array();
             foreach ($list as $key => $value) {
                 // add the recipient to the list if it's a simple email address
                 if (Validation::isEmail($key)) {
                     $to[] = $key;
                 } else {
                     $to[] = User::getFromHeader($key);
                 }
             }
             // add the group leader to the recipient list, if needed
             if (!empty($group_leader_usr_id)) {
                 $leader_email = User::getFromHeader($group_leader_usr_id);
                 if (!empty($leader_email) && !in_array($leader_email, $to)) {
                     $to[] = $leader_email;
                 }
             }
             break;
         case 'sms_assignee':
             $type = 'sms';
             $assignees = Issue::getAssignedUserIDs($issue_id);
             $to = array();
             foreach ($assignees as $assignee) {
                 if (User::isClockedIn($assignee)) {
                     $sms_email = User::getSMS($assignee);
                     if (!empty($sms_email)) {
                         $to[] = $sms_email;
                     }
                 }
             }
             // add the group leader to the recipient list, if needed
             if (!empty($group_leader_usr_id) && User::isClockedIn($group_leader_usr_id)) {
                 $leader_sms_email = User::getSMS($group_leader_usr_id);
                 if (!empty($leader_sms_email) && !in_array($leader_sms_email, $to)) {
                     $to[] = $leader_sms_email;
                 }
             }
             break;
         case 'sms_list':
             $type = 'sms';
             $list = self::getUserList($action['rma_id']);
             $to = array();
             foreach ($list as $key => $value) {
                 // add the recipient to the list if it's a simple email address
                 if (Validation::isEmail($key)) {
                     $to[] = $key;
                 } else {
                     // otherwise, check for the clocked-in status
                     if (User::isClockedIn($key)) {
                         $sms_email = User::getSMS($key);
                         if (!empty($sms_email)) {
                             $to[] = $sms_email;
                         }
                     }
                 }
             }
             // add the group leader to the recipient list, if needed
             if (!empty($group_leader_usr_id) && User::isClockedIn($group_leader_usr_id)) {
                 $leader_sms_email = User::getSMS($group_leader_usr_id);
                 if (!empty($leader_sms_email) && !in_array($leader_sms_email, $to)) {
                     $to[] = $leader_sms_email;
                 }
             }
             break;
     }
     $data = Issue::getDetails($issue_id);
     $conditions = Reminder_Condition::getAdminList($action['rma_id']);
     // alert IRC if needed
     if ($action['rma_alert_irc']) {
         if (Reminder::isDebug()) {
             echo "  - Processing IRC notification\n";
         }
         $irc_notice = "Issue #{$issue_id} (";
         if (!empty($data['pri_title'])) {
             $irc_notice .= 'Priority: ' . $data['pri_title'];
         }
         if (!empty($data['sev_title'])) {
             $irc_notice .= 'Severity: ' . $data['sev_title'];
         }
         // also add information about the assignee, if any
         $assignment = Issue::getAssignedUsers($issue_id);
         if (count($assignment) > 0) {
             $irc_notice .= '; Assignment: ' . implode(', ', $assignment);
         }
         if (!empty($data['iss_grp_id'])) {
             $irc_notice .= '; Group: ' . Group::getName($data['iss_grp_id']);
         }
         $irc_notice .= "), Reminder action '" . $action['rma_title'] . "' was just triggered; " . $action['rma_boilerplate'];
         Notification::notifyIRC(Issue::getProjectID($issue_id), $irc_notice, $issue_id, false, APP_EVENTUM_IRC_CATEGORY_REMINDER);
     }
     $setup = Setup::get();
     // if there are no recipients, then just skip to the next action
     if (count($to) == 0) {
         if (Reminder::isDebug()) {
             echo "  - No recipients could be found\n";
         }
         // if not even an irc alert was sent, then save
         // a notice about this on reminder_sent@, if needed
         if (!$action['rma_alert_irc']) {
             if ($setup['email_reminder']['status'] == 'enabled') {
                 self::_recordNoRecipientError($issue_id, $type, $reminder, $action, $data, $conditions);
             }
             return false;
         }
     }
     // - save a history entry about this action
     self::saveHistory($issue_id, $action['rma_id']);
     // - save this action as the latest triggered one for the given issue ID
     self::recordLastTriggered($issue_id, $action['rma_id']);
     // - perform the action
     if (count($to) > 0) {
         // send a copy of this reminder to reminder_sent@, if needed
         if ($setup['email_reminder']['status'] == 'enabled' && $setup['email_reminder']['addresses']) {
             $addresses = Reminder::_getReminderAlertAddresses();
             if (count($addresses) > 0) {
                 $to = array_merge($to, $addresses);
             }
         }
         $tpl = new Template_Helper();
         $tpl->setTemplate('reminders/' . $type . '_alert.tpl.text');
         $tpl->assign(array('data' => $data, 'reminder' => $reminder, 'action' => $action, 'conditions' => $conditions, 'has_customer_integration' => CRM::hasCustomerIntegration(Issue::getProjectID($issue_id))));
         $text_message = $tpl->getTemplateContents();
         foreach ($to as $address) {
             // send email (use PEAR's classes)
             $mail = new Mail_Helper();
             $mail->setTextBody($text_message);
             $setup = $mail->getSMTPSettings();
             // TRANSLATORS: %1 - issue_id, %2 - rma_title
             $subject = ev_gettext('[#%1$s] Reminder: %2$s', $issue_id, $action['rma_title']);
             $mail->send($setup['from'], $address, $subject, 0, $issue_id, 'reminder');
         }
     }
     // - eventum saves the day once again
     return true;
 }
示例#12
0
 /**
  * Method to determine if user can access a particular issue
  *
  * @access  public
  * @param   integer $issue_id The ID of the issue.
  * @param   integer $usr_id The ID of the user
  * @return  boolean If the user can access the issue
  */
 function canAccess($issue_id, $usr_id)
 {
     static $access;
     if (empty($issue_id)) {
         return true;
     }
     if (isset($access[$issue_id . "-" . $usr_id])) {
         return $access[$issue_id . "-" . $usr_id];
     }
     $details = Issue::getDetails($issue_id);
     if (empty($details)) {
         return true;
     }
     $usr_details = User::getDetails($usr_id);
     $usr_role = User::getRoleByUser($usr_id, $details['iss_prj_id']);
     $prj_id = Issue::getProjectID($issue_id);
     // check customer permissions
     if (Customer::hasCustomerIntegration($details['iss_prj_id']) && $usr_role == User::getRoleID("Customer") && $details['iss_customer_id'] != $usr_details['usr_customer_id']) {
         $return = false;
     } elseif ($details['iss_private'] == 1) {
         // check if the issue is even private
         // check role, reporter, assigment and group
         if (User::getRoleByUser($usr_id, $details['iss_prj_id']) > User::getRoleID("Developer")) {
             $return = true;
         } elseif ($details['iss_usr_id'] == $usr_id) {
             $return = true;
         } elseif (Issue::isAssignedToUser($issue_id, $usr_id)) {
             $return = true;
         } elseif (!empty($details['iss_grp_id']) && !empty($usr_details['usr_grp_id']) && $details['iss_grp_id'] == $usr_details['usr_grp_id']) {
             $return = true;
         } elseif (Authorized_Replier::isUserAuthorizedReplier($issue_id, $usr_id)) {
             $return = true;
         } else {
             $return = false;
         }
     } elseif (Auth::getCurrentRole() <= User::getRoleID("Standard User") && Project::getSegregateReporters($prj_id) && $details['iss_usr_id'] != $usr_id && !Issue::isAssignedToUser($issue_id, $usr_id) && !Authorized_Replier::isUserAuthorizedReplier($issue_id, $usr_id)) {
         return false;
     } else {
         $return = true;
     }
     $access[$issue_id . "-" . $usr_id] = $return;
     return $return;
 }
示例#13
0
 /**
  * Method used to send an email notification when an issue is
  * assigned to an user.
  *
  * @param   array $users The list of users
  * @param   integer $issue_id The issue ID
  */
 public static function notifyNewAssignment($users, $issue_id)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $emails = array();
     foreach ($users as $usr_id) {
         if ($usr_id == Auth::getUserID()) {
             continue;
         }
         $prefs = Prefs::get($usr_id);
         if (!empty($prefs) && isset($prefs['receive_assigned_email'][$prj_id]) && $prefs['receive_assigned_email'][$prj_id] && $usr_id != Auth::getUserID()) {
             $emails[] = User::getFromHeader($usr_id);
         }
     }
     if (!$emails) {
         return;
     }
     // get issue details
     $issue = Issue::getDetails($issue_id);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/assigned.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'issue' => $issue, 'current_user' => User::getFullName(Auth::getUserID())));
     foreach ($emails as $email) {
         $text_message = $tpl->getTemplateContents();
         Language::set(User::getLang(User::getUserIDByEmail(Mail_Helper::getEmailAddress($email))));
         $subject = "[#{$issue_id}] New Assignment: " . $issue['iss_summary'];
         $from = self::getFixedFromHeader($issue_id, '', 'issue');
         // send email (use PEAR's classes)
         $mail = new Mail_Helper();
         $mail->setTextBody($text_message);
         $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
         $mail->send($from, $email, $subject, true, $issue_id, 'assignment');
     }
     Language::restore();
 }
 public function getExcerpts()
 {
     if (count($this->matches) < 1) {
         return false;
     }
     $excerpt_options = array('query_mode' => $this->match_mode, 'before_match' => $this->excerpt_placeholder . '-before', 'after_match' => $this->excerpt_placeholder . '-after', 'allow_empty' => true);
     $excerpts = array();
     foreach ($this->matches as $issue_id => $matches) {
         $excerpt = array('issue' => array(), 'email' => array(), 'phone' => array(), 'note' => array());
         foreach ($matches as $match) {
             if ($match['index'] == 'issue') {
                 $issue = Issue::getDetails($issue_id);
                 $documents = array($issue['iss_summary']);
                 $res = $this->sphinx->BuildExcerpts($documents, 'issue_stemmed', $this->keywords, $excerpt_options);
                 if ($res[0] != $issue['iss_summary']) {
                     $excerpt['issue']['summary'] = self::cleanUpExcerpt($res[0]);
                 }
                 $documents = array($issue['iss_original_description']);
                 $res = $this->sphinx->BuildExcerpts($documents, 'issue_stemmed', $this->keywords, $excerpt_options);
                 if ($res[0] != $issue['iss_original_description']) {
                     $excerpt['issue']['description'] = self::cleanUpExcerpt($res[0]);
                     error_log(print_r($excerpt['issue']['description'], 1));
                 }
             } elseif ($match['index'] == 'email') {
                 $email = Support::getEmailDetails(null, $match['match_id']);
                 $documents = array($email['sup_subject'] . "\n" . $email['message']);
                 $res = $this->sphinx->BuildExcerpts($documents, 'email_stemmed', $this->keywords, $excerpt_options);
                 $excerpt['email'][Support::getSequenceByID($match['match_id'])] = self::cleanUpExcerpt($res[0]);
             } elseif ($match['index'] == 'phone') {
                 $phone_call = Phone_Support::getDetails($match['match_id']);
                 $documents = array($phone_call['phs_description']);
                 $res = $this->sphinx->BuildExcerpts($documents, 'phonesupport_stemmed', $this->keywords, $excerpt_options);
                 $excerpt['phone'][] = self::cleanUpExcerpt($res[0]);
             } elseif ($match['index'] == 'note') {
                 $note = Note::getDetails($match['match_id']);
                 $documents = array($note['not_title'] . "\n" . $note['not_note']);
                 $res = $this->sphinx->BuildExcerpts($documents, 'note_stemmed', $this->keywords, $excerpt_options);
                 $note_seq = Note::getNoteSequenceNumber($issue_id, $match['match_id']);
                 $excerpt['note'][$note_seq] = self::cleanUpExcerpt($res[0]);
             }
         }
         foreach ($excerpt as $key => $val) {
             if (count($val) < 1) {
                 unset($excerpt[$key]);
             }
         }
         $excerpts[$issue_id] = $excerpt;
     }
     return $excerpts;
 }
示例#15
0
function getIssueDetails($p)
{
    $email = XML_RPC_decode($p->getParam(0));
    $password = XML_RPC_decode($p->getParam(1));
    $auth = authenticate($email, $password);
    if (is_object($auth)) {
        return $auth;
    }
    $issue_id = XML_RPC_decode($p->getParam(2));
    createFakeCookie($email, Issue::getProjectID($issue_id));
    $res = Issue::getDetails($issue_id);
    foreach ($res as $k => $v) {
        $res[$k] = base64_encode($v);
    }
    if (empty($res)) {
        return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "Issue #{$issue_id} could not be found");
    } else {
        // remove some naughty fields
        unset($res['iss_original_description']);
        return new XML_RPC_Response(XML_RPC_Encode($res));
    }
}
示例#16
0
//
// @(#) $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']);
            History::add($issue_id, $usr_id, History::getTypeID('status_changed'), "Status changed to '{$new_status}' by " . User::getFullName($usr_id));
        }
 /**
  * Method used to send an email notification to the sender of a
  * set of email messages that were manually converted into an
  * issue.
  *
  * @access  public
  * @param   integer $prj_id The project ID
  * @param   integer $issue_id The issue ID
  * @param   array $sup_ids The email IDs
  * @param   integer $customer_id The customer ID
  * @return  array The list of recipient emails
  */
 function notifyEmailConvertedIntoIssue($prj_id, $issue_id, $sup_ids, $customer_id = FALSE)
 {
     if (Customer::hasCustomerIntegration($prj_id)) {
         return Customer::notifyEmailConvertedIntoIssue($prj_id, $issue_id, $sup_ids, $customer_id);
     } else {
         // build the list of recipients
         $recipients = array();
         $recipient_emails = array();
         for ($i = 0; $i < count($sup_ids); $i++) {
             $senders = Support::getSender(array($sup_ids[$i]));
             if (count($senders) > 0) {
                 $sender_email = Mail_API::getEmailAddress($senders[0]);
                 $recipients[$sup_ids[$i]] = $senders[0];
                 $recipient_emails[] = $sender_email;
             }
         }
         if (count($recipients) == 0) {
             return false;
         }
         $data = Issue::getDetails($issue_id);
         foreach ($recipients as $sup_id => $recipient) {
             // open text template
             $tpl = new Template_API();
             $tpl->setTemplate('notifications/new_auto_created_issue.tpl.text');
             $tpl->bulkAssign(array("data" => $data, "sender_name" => Mail_API::getName($recipient)));
             $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($sup_id), $sup_id);
             $tpl->assign(array('email' => array('date' => $email_details['sup_date'], 'from' => $email_details['sup_from'], 'subject' => $email_details['sup_subject'])));
             $text_message = $tpl->getTemplateContents();
             // send email (use PEAR's classes)
             $mail = new Mail_API();
             $mail->setTextBody($text_message);
             $setup = $mail->getSMTPSettings();
             $from = Notification::getFixedFromHeader($issue_id, $setup["from"], 'issue');
             $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
             $mail->send($from, $recipient, 'New Issue Created', 1, $issue_id, 'email_converted_to_issue');
         }
         return $recipient_emails;
     }
 }