/**
  * @param Trouble $trouble
  */
 public final function support(Trouble $trouble)
 {
     if ($this->resolve($trouble)) {
         $this->done($trouble);
     } elseif (!is_null($this->next)) {
         $this->next->support($trouble);
     } else {
         $this->fail($trouble);
     }
 }
Example #2
0
 public function __call($method, $parameters)
 {
     if (!defined('static::factory')) {
         throw new UndefinedConstException('[const factory] is required to use the [Call Factory Method Ability]!');
     }
     $originMethodName = $method;
     $method = strtolower($method);
     $calledClass = get_called_class();
     if (!isset(static::factory['methods'][$method])) {
         Support::classMethod($calledClass, $originMethodName);
     }
     $class = static::factory['methods'][$method];
     $factory = static::factory['class'] ?? NULL;
     if ($factory !== NULL) {
         return $factory::class($class)->{$method}(...$parameters);
     } else {
         $classEx = explode('::', $class);
         $class = $classEx[0] ?? NULL;
         $method = $classEx[1] ?? NULL;
         $isThis = NULL;
         if (stristr($method, ':this')) {
             $method = str_replace(':this', NULL, $method);
             $isThis = 'this';
         }
         $namespace = str_ireplace(divide($calledClass, '\\', -1), NULL, $calledClass);
         $return = uselib($namespace . $class)->{$method}(...$parameters);
         if ($isThis === 'this') {
             return $this;
         }
         return $return;
     }
 }
 /**
  * LimitSupport constructor.
  * @param string $name
  * @param int $limit
  */
 public function __construct($name, $limit)
 {
     if (!is_int($limit)) {
         throw new \InvalidArgumentException();
     }
     parent::__construct($name);
     $this->limit = $limit;
 }
 public function loadModel($id)
 {
     $model = Support::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param $post
  * @return Response
  */
 public function getEdit($autoreply)
 {
     $roles = Support::getRoles();
     $deps = Support::getDeps();
     $actions = Support::getActions();
     $title = Lang::get('l4cp-support::core.autoreply_update');
     return Theme::make('l4cp-support::autoreplys/create_edit', compact('autoreply', 'title', 'deps', 'actions', 'roles'));
 }
Example #6
0
 public function __construct()
 {
     $this->path = STORAGE_DIR . 'Cache/';
     if (!is_dir($this->path)) {
         \Folder::create($this->path, 0755);
     }
     \Support::writable($this->path);
 }
/**
 * Selects the email from the table and returns the contents. Since jsrs only supports returning one value, 
 * the string that is returned is in the format
 * of ec_id:id:email. If ec_id is not passed as a parameter, only the email is returned.
 * 
 * @param   string $id The sup_ema_id and sup_id seperated by a -.
 * @return  A string containing the body of the email, optionally prefaced by the ec_id and $id.
 */
function getEmail($id)
{
    $split = explode("-", $id);
    $info = Support::getEmailDetails($split[0], $split[1]);
    if (!empty($_GET["ec_id"])) {
        return Link_Filter::processText(Auth::getCurrentProject(), nl2br($_GET["ec_id"] . ":" . $id . ":" . Misc::highlightQuotedReply($info["message"])));
    } else {
        return $info["seb_body"];
    }
}
Example #8
0
 /**
  * Find users who have specified roles on this instance
  *
  * @param string|array|\Illuminate\Support\Collection $roles A role, or list of roles. Can be a string, array or Illuminate\Support\Collection instance.
  *
  * @return \Illuminate\Support\Collection A list of users
  */
 public function whoHasRoles($roles)
 {
     $roles = Support::makeRoleIds($roles);
     $rrus = RRU::whereResourceType(get_class($this))->whereResourceId($this->getKey())->whereIn('role_id', $roles)->get();
     $userIds = $rrus->map(function ($rru) {
         return $rru->user_id;
     });
     $userModel = config('roller.model.user');
     $userModel = new $userModel();
     return $userModel->whereIn($userModel->getKeyName(), $userIds)->get();
 }
Example #9
0
/**
 * Selects the email from the table and returns the contents.
 *
 * @param   string $id The sup_ema_id and sup_id seperated by a -.
 * @return  A string containing the body of the email,
 */
function getEmail($id)
{
    $split = explode('-', $id);
    $info = Support::getEmailDetails($split[0], $split[1]);
    if (!Issue::canAccess($info['sup_iss_id'], $GLOBALS['usr_id'])) {
        return '';
    }
    if (empty($_GET['ec_id'])) {
        return $info['seb_body'];
    }
    return Link_Filter::processText(Auth::getCurrentProject(), nl2br(Misc::highlightQuotedReply($info['seb_body'])));
}
Example #10
0
 public function __construct(string $driver = NULL)
 {
     parent::__construct();
     if (!defined('static::driver')) {
         throw new UndefinedConstException('[const driver] is required to use the [Driver Ability]!');
     }
     nullCoalesce($driver, $this->config['driver'] ?? NULL);
     $this->selectedDriverName = $driver;
     Support::driver(static::driver['options'], $driver);
     if (!isset(static::driver['namespace'])) {
         $this->driver = uselib($driver);
     } else {
         $this->driver = uselib(suffix(static::driver['namespace'], '\\') . $driver . 'Driver');
     }
     if (isset(static::driver['construct'])) {
         $construct = static::driver['construct'];
         $this->{$construct}();
     }
 }
Example #11
0
 /**
  * @dataProvider dataProviderForCheckLimitsUndefinedParameterException
  */
 public function testCheckLimitsUndefinedParameterException(array $limits, array $params)
 {
     $this->setExpectedException('MathPHP\\Exception\\BadParameterException');
     Support::checkLimits($limits, $params);
 }
Example #12
0
// | 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';
Auth::checkAuthentication(APP_COOKIE);
if (@$_GET['cat'] == 'blocked_email') {
    $email = Note::getBlockedMessage($_GET['note_id']);
} else {
    $email = Support::getFullEmail($_GET['sup_id']);
}
if (!empty($_GET['raw'])) {
    Attachment::outputDownload($email, 'message.eml', strlen($email), 'message/rfc822');
} else {
    if (!empty($_GET['cid'])) {
        list($mimetype, $data) = Mime_Helper::getAttachment($email, $_GET['filename'], $_GET['cid']);
    } else {
        list($mimetype, $data) = Mime_Helper::getAttachment($email, $_GET['filename']);
    }
    Attachment::outputDownload($data, $_GET['filename'], strlen($data), $mimetype);
}
Example #13
0
            if ($res) {
                list($HTTP_POST_VARS["from"]) = Support::getSender(array($HTTP_POST_VARS['item'][$i]));
                Workflow::handleBlockedEmail(Issue::getProjectID($HTTP_POST_VARS['issue']), $HTTP_POST_VARS['issue'], $HTTP_POST_VARS, 'associated');
                Support::removeEmail($HTTP_POST_VARS['item'][$i]);
            }
        }
        $tpl->assign("associate_result", $res);
    }
    @$tpl->assign('total_emails', count($HTTP_POST_VARS['item']));
} else {
    @$tpl->assign('emails', $HTTP_GET_VARS['item']);
    @$tpl->assign('total_emails', count($HTTP_GET_VARS['item']));
    $prj_id = Issue::getProjectID($HTTP_GET_VARS['issue']);
    if (Customer::hasCustomerIntegration($prj_id)) {
        // check if the selected emails all have sender email addresses that are associated with the issue' customer
        $senders = Support::getSender($HTTP_GET_VARS['item']);
        $sender_emails = array();
        for ($i = 0; $i < count($senders); $i++) {
            $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 {
Example #14
0
    $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)));
    }
    $tpl->assign('new_status_result', $res);
} elseif ($cat == 'authorize_reply') {
    $res = Authorized_Replier::addUser($iss_id, $usr_id);
Example #15
0
include_once "../core.php";
$action = "register";
$error_message = "";
if (User::Logged()) {
    header("Location:" . PREFIX . "/dashboard/");
    exit;
}
$user_name = isset($_POST["user_name"]) ? $_POST["user_name"] : "";
$user_email = isset($_POST["user_email"]) ? $_POST["user_email"] : "";
Viewer::AddData("user_name", $user_name);
Viewer::AddData("user_email", $user_email);
if (!empty($user_name) && !empty($user_email) && !empty($_POST["user_password"]) && !empty($_POST["user_password2"])) {
    if ($_POST["user_password"] != $_POST["user_password2"]) {
        $error_message = I18n::L("Passwords mismatch.");
    } else {
        if (!Support::IsEMail($user_email)) {
            $error_message = I18n::L("Wrong E-mail address.");
        } else {
            if (User::FindUser($user_name)) {
                $error_message = I18n::L("Username &laquo;%s&raquo; is already taken, please find another username.", array($user_name));
            } else {
                if (User::FindUserByEmail($user_email)) {
                    $error_message = I18n::L("This email &laquo;%s&raquo; is already regesitered, please use another email.", array($user_email));
                } else {
                    $obj = User::Add(User::Create($user_name, $user_email, $_POST["user_password"]));
                    if ($obj->user_id) {
                        Session::StartUser($obj);
                        header("Location:" . PREFIX . "/dashboard/");
                        exit;
                    } else {
                        $error_message = I18n::L("Error while registring user.");
Example #16
0
 public function __construct($name, $specialNumber)
 {
     parent::__construct($name);
     $this->specialNumber = $specialNumber;
 }
Example #17
0
 /**
  * Returns the sequential number of the specified email ID.
  *
  * @param   integer $sup_id The email ID
  * @return  integer The sequence number of the email
  */
 public static function getSequenceByID($sup_id)
 {
     if (empty($sup_id)) {
         return '';
     }
     try {
         DB_Helper::getInstance()->query('SET @sup_seq = 0');
     } catch (DbException $e) {
         return 0;
     }
     $issue_id = Support::getIssueFromEmail($sup_id);
     $sql = 'SELECT
                 sup_id,
                 @sup_seq := @sup_seq+1
             FROM
                 {{%support_email}}
             WHERE
                 sup_iss_id = ?
             ORDER BY
                 sup_id ASC';
     try {
         $res = DB_Helper::getInstance()->getPair($sql, array($issue_id));
     } catch (DbException $e) {
         return 0;
     }
     return @$res[$sup_id];
 }
 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;
 }
Example #19
0
 /**
  * Returns the data used by the weekly report.
  *
  * @param string $usr_id The ID of the user this report is for.
  * @param int $prj_id The project id
  * @param string|DateTime $start The start date of this report.
  * @param string|DateTime $end The end date of this report.
  * @param array $options extra options for report:
  * - $separate_closed If closed issues should be separated from other issues.
  * - $ignore_statuses If issue status changes should be ignored in report.
  * - $separate_not_assigned_to_user Separate Issues Not Assigned to User
  * - $show_per_issue Add time spent on issue to issues
  * - $separate_no_time Separate No time spent issues
  * @return array An array of data containing all the elements of the weekly report.
  */
 public static function getWeeklyReport($usr_id, $prj_id, $start, $end, $options = array())
 {
     // figure out timezone
     $user_prefs = Prefs::get($usr_id);
     $tz = $user_prefs['timezone'];
     // if start or end is string, convert assume min and max date are specified
     if (!$start instanceof DateTime) {
         $start = Date_Helper::getDateTime($start, $tz)->setTime(0, 0, 0);
     }
     if (!$end instanceof DateTime) {
         $end = Date_Helper::getDateTime($end, $tz)->setTime(23, 59, 59);
     }
     $start_ts = Date_Helper::getSqlDateTime($start);
     $end_ts = Date_Helper::getSqlDateTime($end);
     $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $prj_id, $start_ts, $end_ts);
     // replace spaces in index with _ and calculate total time
     $total_time = 0;
     foreach ($time_tracking as $category => $data) {
         unset($time_tracking[$category]);
         $time_tracking[str_replace(' ', '_', $category)] = $data;
         $total_time += $data['total_time'];
     }
     // get count of issues assigned in week of report.
     $stmt = 'SELECT
                 COUNT(*)
              FROM
                 {{%issue}},
                 {{%issue_user}},
                 {{%status}}
              WHERE
                 iss_id = isu_iss_id AND
                 iss_sta_id = sta_id AND
                 isu_usr_id = ? AND
                 iss_prj_id = ? AND
                 isu_assigned_date BETWEEN ? AND ?';
     $params = array($usr_id, Auth::getCurrentProject(), $start_ts, $end_ts);
     try {
         $newly_assigned = DB_Helper::getInstance()->getOne($stmt, $params);
     } catch (DbException $e) {
         $newly_assigned = null;
     }
     $email_count = array('associated' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), 'other' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false));
     $htt_exclude = array();
     if (!empty($options['ignore_statuses'])) {
         $htt_exclude[] = 'status_changed';
         $htt_exclude[] = 'status_auto_changed';
         $htt_exclude[] = 'remote_status_change';
     }
     $issue_list = History::getTouchedIssuesByUser($usr_id, $prj_id, $start_ts, $end_ts, $htt_exclude);
     $issues = array('no_time' => array(), 'not_mine' => array(), 'closed' => array(), 'other' => array());
     // organize issues into categories
     if ($issue_list) {
         if (!empty($options['show_per_issue']) || !empty($options['separate_no_time'])) {
             Time_Tracking::fillTimeSpentByIssueAndTime($issue_list, $usr_id, $start_ts, $end_ts);
         }
         foreach ($issue_list as $row) {
             if (!empty($row['iss_customer_id']) && CRM::hasCustomerIntegration($row['iss_prj_id'])) {
                 $row['customer_name'] = CRM::getCustomerName($row['iss_prj_id'], $row['iss_customer_id']);
             } else {
                 $row['customer_name'] = null;
             }
             if (!empty($options['separate_closed']) && $row['sta_is_closed'] == 1) {
                 $issues['closed'][] = $row;
             } elseif (!empty($options['separate_not_assigned_to_user']) && !Issue::isAssignedToUser($row['iss_id'], $usr_id)) {
                 $issues['not_mine'][] = $row;
             } elseif (!empty($options['separate_no_time']) && empty($row['it_spent'])) {
                 $issues['no_time'][] = $row;
             } else {
                 $issues['other'][] = $row;
             }
         }
         $sort_function = function ($a, $b) {
             return strcasecmp($a['customer_name'], $b['customer_name']);
         };
         usort($issues['closed'], $sort_function);
         usort($issues['other'], $sort_function);
     }
     return array('start' => $start_ts, 'end' => $end_ts, 'user' => User::getDetails($usr_id), 'group_name' => Group::getName(User::getGroupID($usr_id)), 'issues' => $issues, 'status_counts' => History::getTouchedIssueCountByStatus($usr_id, $prj_id, $start_ts, $end_ts), 'new_assigned_count' => $newly_assigned, 'time_tracking' => $time_tracking, 'email_count' => $email_count, 'phone_count' => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), 'note_count' => Note::getCountByUser($usr_id, $start_ts, $end_ts), 'total_time' => Misc::getFormattedTime($total_time, false));
 }
Example #20
0
<?php

require_once "models/User.php";
require_once "views/Standard.php";
require_once "views/Support.php";
echo Standard::render(Support::getBar(), Support::getText(), User::generateLoginState());
Example #21
0
<?php

namespace PressGang;

/**
 * Class Support
 *
 * @package PressGang
 */
class Support
{
    /**
     * init
     *
     */
    public static function init()
    {
        foreach (Config::get('support') as &$support) {
            add_theme_support($support);
        }
    }
}
Support::init();
Example #22
0
 public function __construct()
 {
     \Support::extension('apc');
 }
Example #23
0
 /**
  * Method used to add a new issue using the normal report form.
  *
  * @return  integer The new issue ID
  */
 public static function createFromPost()
 {
     $keys = array('add_primary_contact', 'attached_emails', 'category', 'contact', 'contact_email', 'contact_extra_emails', 'contact_person_fname', 'contact_person_lname', 'contact_phone', 'contact_timezone', 'contract', 'customer', 'custom_fields', 'description', 'estimated_dev_time', 'group', 'notify_customer', 'notify_senders', 'priority', 'private', 'release', 'severity', 'summary', 'users', 'product', 'product_version', 'expected_resolution_date', 'associated_issues');
     $data = array();
     foreach ($keys as $key) {
         if (isset($_POST[$key])) {
             $data[$key] = $_POST[$key];
         }
     }
     $prj_id = Auth::getCurrentProject();
     $current_usr_id = Auth::getUserID();
     $usr_id = $current_usr_id;
     // if we are creating an issue for a customer, put the
     // main customer contact as the reporter for it
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         $contact_usr_id = User::getUserIDByContactID($data['contact']);
         if (empty($contact_usr_id)) {
             $contact_usr_id = $usr_id;
         }
         $data['reporter'] = $contact_usr_id;
     } else {
         $data['reporter'] = $usr_id;
     }
     $data['msg_id'] = Mail_Helper::generateMessageID();
     $issue_id = self::insertIssue($prj_id, $data);
     if ($issue_id == -1) {
         return -1;
     }
     $has_RR = false;
     $info = User::getNameEmail($usr_id);
     // log the creation of the issue
     History::add($issue_id, $current_usr_id, 'issue_opened', 'Issue opened by {user}', array('user' => User::getFullName($current_usr_id)));
     $clone_iss_id = isset($_POST['clone_iss_id']) ? (int) $_POST['clone_iss_id'] : null;
     if ($clone_iss_id && Access::canCloneIssue($clone_iss_id, $current_usr_id)) {
         History::add($issue_id, $current_usr_id, 'issue_cloned_from', 'Issue cloned from #{issue_id}', array('issue_id' => $clone_iss_id));
         History::add($clone_iss_id, $current_usr_id, 'issue_cloned_to', 'Issue cloned to #{issue_id}', array('issue_id' => $issue_id));
         self::addAssociation($issue_id, $clone_iss_id, $usr_id, true);
     }
     $emails = array();
     if (CRM::hasCustomerIntegration($prj_id)) {
         $customer = $crm->getCustomer($data['customer']);
         $contract = $crm->getContract($data['contract']);
         if (!empty($data['contact_extra_emails']) && count($data['contact_extra_emails']) > 0) {
             $emails = $data['contact_extra_emails'];
         }
         // add the primary contact to the notification list
         if (isset($data['add_primary_contact']) && $data['add_primary_contact'] == 'yes') {
             $contact_email = User::getEmailByContactID($data['contact']);
             if (!empty($contact_email)) {
                 $emails[] = $contact_email;
             }
         }
         // if there are any technical account managers associated with this customer, add these users to the notification list
         $managers = $customer->getEventumAccountManagers();
         foreach ($managers as $manager) {
             $emails[] = $manager['usr_email'];
         }
     }
     // add the reporter to the notification list
     $emails[] = $info['usr_email'];
     $emails = array_unique($emails);
     foreach ($emails as $address) {
         Notification::subscribeEmail($usr_id, $issue_id, $address, Notification::getDefaultActions($issue_id, $address, 'new_issue'));
     }
     // only assign the issue to an user if the associated customer has any technical account managers
     $users = array();
     $has_TAM = false;
     if (CRM::hasCustomerIntegration($prj_id) && count($managers) > 0) {
         foreach ($managers as $manager) {
             if ($manager['cam_type'] == 'intpart') {
                 continue;
             }
             $users[] = $manager['cam_usr_id'];
             self::addUserAssociation($usr_id, $issue_id, $manager['cam_usr_id'], false);
             History::add($issue_id, $usr_id, 'issue_auto_assigned', 'Issue auto-assigned to {assignee} (TAM)', array('assignee' => User::getFullName($manager['cam_usr_id'])));
         }
         $has_TAM = true;
     }
     // now add the user/issue association (aka assignments)
     if (!empty($data['users']) && count($data['users']) > 0) {
         foreach ($data['users'] as $user) {
             $actions = Notification::getDefaultActions($issue_id, User::getEmail($user), 'new_issue');
             Notification::subscribeUser($usr_id, $issue_id, $user, $actions);
             self::addUserAssociation($usr_id, $issue_id, $user);
             if ($user != $usr_id) {
                 $users[] = $user;
             }
         }
     } else {
         // only use the round-robin feature if this new issue was not
         // already assigned to a customer account manager
         if (@count($managers) < 1) {
             $assignee = Round_Robin::getNextAssignee($prj_id);
             // assign the issue to the round robin person
             if (!empty($assignee)) {
                 $users[] = $assignee;
                 self::addUserAssociation($usr_id, $issue_id, $assignee, false);
                 History::add($issue_id, APP_SYSTEM_USER_ID, 'rr_issue_assigned', 'Issue auto-assigned to {assignee} (RR)', array('assignee' => User::getFullName($assignee)));
                 $has_RR = true;
             }
         }
     }
     // set product and version
     if (isset($data['product']) && $data['product'] != '-1') {
         Product::addIssueProductVersion($issue_id, $data['product'], $data['product_version']);
     }
     // process any files being uploaded
     // from ajax upload, attachment file ids
     $iaf_ids = !empty($_POST['iaf_ids']) ? explode(',', $_POST['iaf_ids']) : null;
     // if no iaf_ids passed, perhaps it's old style upload
     // TODO: verify that the uploaded file(s) owner is same as attachment owner.
     if (!$iaf_ids && isset($_FILES['file'])) {
         $iaf_ids = Attachment::addFiles($_FILES['file']);
     }
     if ($iaf_ids) {
         Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, false, 'Files uploaded at issue creation time');
     }
     // need to associate any emails ?
     if (!empty($data['attached_emails'])) {
         $items = explode(',', $data['attached_emails']);
         Support::associate($usr_id, $issue_id, $items);
     }
     // need to notify any emails being converted into issues ?
     if (@count($data['notify_senders']) > 0) {
         $recipients = Notification::notifyEmailConvertedIntoIssue($prj_id, $issue_id, $data['notify_senders'], @$data['customer']);
     } else {
         $recipients = array();
     }
     // need to process any custom fields ?
     if (@count($data['custom_fields']) > 0) {
         foreach ($data['custom_fields'] as $fld_id => $value) {
             Custom_Field::associateIssue($issue_id, $fld_id, $value);
         }
     }
     // also send a special confirmation email to the customer contact
     if (@$data['notify_customer'] == 'yes' && !empty($data['contact'])) {
         $contact = $contract->getContact($data['contact']);
         // also need to pass the list of sender emails already notified,
         // so we can avoid notifying the same person again
         $contact_email = User::getEmailByContactID($data['contact']);
         if (@(!in_array($contact_email, $recipients))) {
             $contact->notifyNewIssue($issue_id);
         }
         // now check for additional emails in contact_extra_emails
         if (@count($data['contact_extra_emails']) > 0) {
             $notification_emails = $data['contact_extra_emails'];
             foreach ($notification_emails as $notification_email) {
                 if (@(!in_array($notification_email, $recipients))) {
                     try {
                         $notification_contact = $crm->getContactByEmail($notification_email);
                         $notification_contact->notifyNewIssue($issue_id);
                     } catch (ContactNotFoundException $e) {
                     }
                 }
             }
         }
     }
     // handle associated issues
     if (isset($data['associated_issues'])) {
         $associated_issues = explode(',', $data['associated_issues']);
         if ($clone_iss_id) {
             $associated_issues[] = $clone_iss_id;
         }
         self::updateAssociatedIssuesRelations($issue_id, $associated_issues);
     }
     Workflow::handleNewIssue($prj_id, $issue_id, $has_TAM, $has_RR);
     // also notify any users that want to receive emails anytime a new issue is created
     Notification::notifyNewIssue($prj_id, $issue_id);
     return $issue_id;
 }
Example #24
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;
 }
Example #25
0
        $res = Support::getListDetails($item);
        $tpl->assign('emails', $res);
        $tpl->assign('attached_emails', @implode(',', $item));
        if (CRM::hasCustomerIntegration($prj_id)) {
            $crm = CRM::getInstance($prj_id);
            // also need to guess the contact_id from any attached emails
            try {
                $info = $crm->getCustomerInfoFromEmails($prj_id, $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']));
            } catch (CRMException $e) {
            }
        }
        // if we are dealing with just one message, use the subject line as the
        // summary for the issue, and the body as the description
        if (count($item) == 1) {
            $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($item[0]), $item[0]);
            $tpl->assign(array('issue_summary' => $email_details['sup_subject'], 'issue_description' => $email_details['seb_body']));
            // also auto pre-fill the customer contact text fields
            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);
Example #26
0
 public function __construct()
 {
     \Support::library('ZipArchive', 'ZIP Archive');
 }
Example #27
0
 /**
  * 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;
 }
Example #28
0
// | 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.removed_emails.php 1.2 03/01/21 04:06:59-00:00 jpm $
//
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.support.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("removed_emails.tpl.html");
Auth::checkAuthentication(APP_COOKIE, NULL, true);
if (@$HTTP_POST_VARS["cat"] == "restore") {
    $res = Support::restoreEmails();
    $tpl->assign("result_msg", $res);
} elseif (@$HTTP_POST_VARS["cat"] == "remove") {
    $res = Support::expungeEmails($HTTP_POST_VARS["item"]);
    $tpl->assign("result_msg", $res);
}
$tpl->assign("list", Support::getRemovedList());
$tpl->displayTemplate();
 /**
  * Method used to remove the specified support email accounts.
  *
  * @access  public
  * @return  boolean
  */
 function remove()
 {
     global $HTTP_POST_VARS;
     $items = @implode(", ", Misc::escapeInteger($HTTP_POST_VARS["items"]));
     $stmt = "DELETE FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account\n                 WHERE\n                    ema_id IN ({$items})";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return false;
     } else {
         Support::removeEmailByAccounts($HTTP_POST_VARS["items"]);
         return true;
     }
 }
Example #30
0
// | 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.                                       |
// | 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('removed_emails.tpl.html');
Auth::checkAuthentication(APP_COOKIE, null, true);
if (@$_POST['cat'] == 'restore') {
    $res = Support::restoreEmails();
    $tpl->assign('result_msg', $res);
} elseif (@$_POST['cat'] == 'remove') {
    $res = Support::expungeEmails($_POST['item']);
    $tpl->assign('result_msg', $res);
}
$tpl->assign('list', Support::getRemovedList());
$tpl->displayTemplate();