当前位置: 首页>>代码示例>>PHP>>正文


PHP Note::insertFromPost方法代码示例

本文整理汇总了PHP中Note::insertFromPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Note::insertFromPost方法的具体用法?PHP Note::insertFromPost怎么用?PHP Note::insertFromPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Note的用法示例。


在下文中一共展示了Note::insertFromPost方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: close

 /**
  * Method used to close off an issue.
  *
  * @param   integer $usr_id The user ID
  * @param   integer $issue_id The issue ID
  * @param   bool $send_notification Whether to send a notification about this action or not
  * @param   integer $resolution_id The resolution ID
  * @param   integer $status_id The status ID
  * @param   string $reason The reason for closing this issue
  * @param   string  $send_notification_to Who this notification should be sent too
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function close($usr_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason, $send_notification_to = 'internal')
 {
     $usr_id = (int) $usr_id;
     $issue_id = (int) $issue_id;
     $resolution_id = (int) $resolution_id;
     $status_id = (int) $status_id;
     $params = array('iss_updated_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_type' => 'closed', 'iss_closed_date' => Date_Helper::getCurrentDateGMT(), 'iss_sta_id' => $status_id);
     if (!empty($resolution_id)) {
         $params['iss_res_id'] = $resolution_id;
     }
     $stmt = 'UPDATE {{%issue}} SET ' . DB_Helper::buildSet($params) . ' WHERE iss_id=?';
     $params[] = $issue_id;
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $prj_id = self::getProjectID($issue_id);
     // record the change
     History::add($issue_id, $usr_id, 'issue_closed', "Issue updated to status '{status}' by {user}", array('status' => Status::getStatusTitle($status_id), 'user' => User::getFullName($usr_id)));
     if ($send_notification_to == 'all') {
         $from = User::getFromHeader($usr_id);
         $message_id = User::getFromHeader($usr_id);
         $full_email = Support::buildFullHeaders($issue_id, $message_id, $from, '', '', 'Issue closed comments', $reason, '');
         $structure = Mime_Helper::decode($full_email, true, false);
         $email = array('ema_id' => Email_Account::getEmailAccount(self::getProjectID($issue_id)), 'issue_id' => $issue_id, 'message_id' => $message_id, 'date' => Date_Helper::getCurrentDateGMT(), 'subject' => 'Issue closed comments', 'from' => $from, 'has_attachment' => 0, 'body' => $reason, 'full_email' => $full_email, 'headers' => $structure->headers);
         $sup_id = null;
         Support::insertEmail($email, $structure, $sup_id, true);
         $ids = $sup_id;
     } else {
         // add note with the reason to close the issue
         $_POST['title'] = 'Issue closed comments';
         $_POST['note'] = $reason;
         Note::insertFromPost($usr_id, $issue_id, false, true, true, $send_notification);
         $ids = false;
     }
     if ($send_notification) {
         if (CRM::hasCustomerIntegration($prj_id)) {
             $crm = CRM::getInstance($prj_id);
             // send a special confirmation email when customer issues are closed
             $stmt = 'SELECT
                         iss_customer_contact_id
                      FROM
                         {{%issue}}
                      WHERE
                         iss_id=?';
             $customer_contact_id = DB_Helper::getInstance()->getOne($stmt, array($issue_id));
             if (!empty($customer_contact_id)) {
                 try {
                     $contact = $crm->getContact($customer_contact_id);
                     $contact->notifyIssueClosed($issue_id, $reason);
                 } catch (CRMException $e) {
                 }
             }
         }
         // send notifications for the issue being closed
         Notification::notify($issue_id, 'closed', $ids);
     }
     Workflow::handleIssueClosed($prj_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason, $usr_id);
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:73,代码来源:class.issue.php

示例2: blockEmailIfNeeded

 /**
  * Check if this email needs to be blocked and if so, block it.
  *
  *
  */
 public static function blockEmailIfNeeded($email)
 {
     if (empty($email['issue_id'])) {
         return false;
     }
     $issue_id = $email['issue_id'];
     $prj_id = Issue::getProjectID($issue_id);
     $sender_email = strtolower(Mail_Helper::getEmailAddress($email['from']));
     list($text_headers, $body) = Mime_Helper::splitHeaderBody($email['full_email']);
     if (Mail_Helper::isVacationAutoResponder($email['headers']) || Notification::isBounceMessage($sender_email) || !self::isAllowedToEmail($issue_id, $sender_email)) {
         // add the message body as a note
         $_POST = array('full_message' => $email['full_email'], 'title' => @$email['headers']['subject'], 'note' => Mail_Helper::getCannedBlockedMsgExplanation($issue_id) . $email['body'], 'message_id' => Mail_Helper::getMessageID($text_headers, $body));
         // avoid having this type of message re-open the issue
         if (Mail_Helper::isVacationAutoResponder($email['headers'])) {
             $closing = true;
             $notify = false;
         } else {
             $closing = false;
             $notify = true;
         }
         $res = Note::insertFromPost(Auth::getUserID(), $issue_id, $email['headers']['from'], false, $closing, $notify, true);
         // associate the email attachments as internal-only files on this issue
         if ($res != -1) {
             self::extractAttachments($issue_id, $email['full_email'], true, $res);
         }
         $_POST['issue_id'] = $issue_id;
         $_POST['from'] = $sender_email;
         // avoid having this type of message re-open the issue
         if (Mail_Helper::isVacationAutoResponder($email['headers'])) {
             $email_type = 'vacation-autoresponder';
         } else {
             $email_type = 'routed';
         }
         Workflow::handleBlockedEmail($prj_id, $issue_id, $_POST, $email_type);
         // try to get usr_id of sender, if not, use system account
         $usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($email['from']), true);
         if (!$usr_id) {
             $usr_id = APP_SYSTEM_USER_ID;
         }
         History::add($issue_id, $usr_id, 'email_blocked', "Email from '{from}' blocked", array('from' => $email['from']));
         return true;
     }
     return false;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:49,代码来源:class.support.php

示例3: elseif

    } elseif ($_POST['target'] == 'reference') {
        $res = Support::associateEmail(Auth::getUserID(), $_POST['issue_id'], $_POST['item']);
        if ($res == 1) {
            Workflow::handleManualEmailAssociation(Issue::getProjectID($_POST['issue_id']), $_POST['issue_id']);
        }
        $tpl->assign('associate_result', $res);
    } else {
        foreach ($_POST['item'] as $item) {
            $email = Support::getEmailDetails(Email_Account::getAccountByEmail($item), $item);
            // add the message body as a note
            $_POST['full_message'] = $email['seb_full_email'];
            $_POST['title'] = $email['sup_subject'];
            $_POST['note'] = $email['seb_body'];
            // XXX: probably broken to use the current logged in user as the 'owner' of
            // XXX: this new note, but that's how it was already
            $res = Note::insertFromPost(Auth::getUserID(), $_POST['issue_id'], false, true, false, true, true);
            // remove the associated email
            if ($res) {
                list($_POST['from']) = Support::getSender(array($item));
                Workflow::handleBlockedEmail(Issue::getProjectID($_POST['issue_id']), $_POST['issue_id'], $_POST, 'associated');
                Support::removeEmail($item);
            }
        }
        $tpl->assign('associate_result', $res);
    }
    @$tpl->assign('total_emails', count($_POST['item']));
} else {
    @$tpl->assign('emails', $_GET['item']);
    @$tpl->assign('total_emails', count($_GET['item']));
    $prj_id = Issue::getProjectID($_GET['issue_id']);
    if (CRM::hasCustomerIntegration($prj_id)) {
开发者ID:korusdipl,项目名称:eventum,代码行数:31,代码来源:associate.php

示例4: getEmailInfo


//.........这里部分代码省略.........
     }
     if ($should_create_array['type'] == 'note') {
         // assume that this is not a valid note
         $res = -1;
         if ($t['issue_id'] != 0) {
             // check if this is valid user
             $usr_id = User::getUserIDByEmail($sender_email);
             if (!empty($usr_id)) {
                 $role_id = User::getRoleByUser($usr_id, $prj_id);
                 if ($role_id > User::ROLE_CUSTOMER) {
                     // actually a valid user so insert the note
                     AuthCookie::setAuthCookie($usr_id);
                     AuthCookie::setProjectCookie($prj_id);
                     $users = Project::getUserEmailAssocList($prj_id, 'active', User::ROLE_CUSTOMER);
                     $user_emails = Misc::lowercase(array_values($users));
                     $users = array_flip($users);
                     $addresses = array();
                     $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
                     if (count($to_addresses)) {
                         $addresses = $to_addresses;
                     }
                     $cc_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['cc']);
                     if (count($cc_addresses)) {
                         $addresses = array_merge($addresses, $cc_addresses);
                     }
                     $cc_users = array();
                     foreach ($addresses as $email) {
                         if (in_array(strtolower($email), $user_emails)) {
                             $cc_users[] = $users[strtolower($email)];
                         }
                     }
                     // XXX FIXME, this is not nice thing to do
                     $_POST = array('title' => Mail_Helper::removeExcessRe($t['subject']), 'note' => $t['body'], 'note_cc' => $cc_users, 'add_extra_recipients' => 'yes', 'message_id' => $t['message_id'], 'parent_id' => $should_create_array['parent_id']);
                     $res = Note::insertFromPost($usr_id, $t['issue_id']);
                     // need to handle attachments coming from notes as well
                     if ($res != -1) {
                         self::extractAttachments($t['issue_id'], $structure, true, $res);
                     }
                 }
             }
         }
     } else {
         // check if we need to block this email
         if ($should_create_issue == true || !self::blockEmailIfNeeded($t)) {
             if (!empty($t['issue_id'])) {
                 list($t['full_email'], $t['headers']) = Mail_Helper::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
             }
             // make variable available for workflow to be able to detect whether this email created new issue
             $t['should_create_issue'] = $should_create_array['should_create_issue'];
             $res = self::insertEmail($t, $structure, $sup_id);
             if ($res != -1) {
                 // only extract the attachments from the email if we are associating the email to an issue
                 if (!empty($t['issue_id'])) {
                     self::extractAttachments($t['issue_id'], $structure);
                     // notifications about new emails are always external
                     $internal_only = false;
                     $assignee_only = false;
                     // special case when emails are bounced back, so we don't want a notification to customers about those
                     if (Notification::isBounceMessage($sender_email)) {
                         // broadcast this email only to the assignees for this issue
                         $internal_only = true;
                         $assignee_only = true;
                     } elseif ($should_create_issue == true) {
                         // if a new issue was created, only send a copy of the email to the assignee (if any), don't resend to the original TO/CC list
                         $assignee_only = true;
                         $internal_only = true;
开发者ID:dabielkabuto,项目名称:eventum,代码行数:67,代码来源:class.support.php

示例5: route_notes

 /**
  * Routes a note to the correct issue
  *
  * @param   string $full_message The full note
  * @return  mixed   true or array(ERROR_CODE, ERROR_STRING) in case of failure
  */
 public static function route_notes($full_message)
 {
     // save the full message for logging purposes
     Note::saveRoutedNote($full_message);
     // join the Content-Type line (for easier parsing?)
     if (preg_match('/^boundary=/m', $full_message)) {
         $pattern = "#(Content-Type: multipart/.+); ?\r?\n(boundary=.*)\$#im";
         $replacement = '$1; $2';
         $full_message = preg_replace($pattern, $replacement, $full_message);
     }
     list($headers) = Mime_Helper::splitHeaderBody($full_message);
     // need some validation here
     if (empty($full_message)) {
         return array(self::EX_NOINPUT, ev_gettext('Error: The email message was empty.') . "\n");
     }
     // remove the reply-to: header
     if (preg_match('/^reply-to:.*/im', $full_message)) {
         $full_message = preg_replace("/^(reply-to:).*\n/im", '', $full_message, 1);
     }
     // check if the email routing interface is even supposed to be enabled
     $setup = Setup::get();
     if ($setup['note_routing']['status'] != 'enabled') {
         return array(self::EX_CONFIG, ev_gettext('Error: The internal note routing interface is disabled.') . "\n");
     }
     if (empty($setup['note_routing']['address_prefix'])) {
         return array(self::EX_CONFIG, ev_gettext('Error: Please configure the email address prefix.') . "\n");
     }
     if (empty($setup['note_routing']['address_host'])) {
         return array(self::EX_CONFIG, ev_gettext('Error: Please configure the email address domain.') . "\n");
     }
     $structure = Mime_Helper::decode($full_message, true, true);
     // find which issue ID this email refers to
     if (isset($structure->headers['to'])) {
         $issue_id = self::getMatchingIssueIDs($structure->headers['to'], 'note');
     }
     // validation is always a good idea
     if (empty($issue_id) and isset($structure->headers['cc'])) {
         // we need to try the Cc header as well
         $issue_id = self::getMatchingIssueIDs($structure->headers['cc'], 'note');
     }
     if (empty($issue_id)) {
         return array(self::EX_DATAERR, ev_gettext('Error: The routed note had no associated Eventum issue ID or had an invalid recipient address.') . "\n");
     }
     $prj_id = Issue::getProjectID($issue_id);
     // check if the sender is allowed in this issue' project and if it is an internal user
     $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
     $sender_usr_id = User::getUserIDByEmail($sender_email, true);
     if ((empty($sender_usr_id) || User::getRoleByUser($sender_usr_id, $prj_id) < User::ROLE_USER || User::isPartner($sender_usr_id) && !Access::canViewInternalNotes($issue_id, $sender_usr_id)) && !Workflow::canSendNote($prj_id, $issue_id, $sender_email, $structure)) {
         return array(self::EX_NOPERM, ev_gettext("Error: The sender of this email is not allowed in the project associated with issue #{$issue_id}.") . "\n");
     }
     if (empty($sender_usr_id)) {
         $sender_usr_id = APP_SYSTEM_USER_ID;
         $unknown_user = $structure->headers['from'];
     } else {
         $unknown_user = false;
     }
     AuthCookie::setAuthCookie($sender_usr_id);
     AuthCookie::setProjectCookie($prj_id);
     // parse the Cc: list, if any, and add these internal users to the issue notification list
     $addresses = array();
     $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
     if (count($to_addresses)) {
         $addresses = $to_addresses;
     }
     $cc_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['cc']);
     if (count($cc_addresses)) {
         $addresses = array_merge($addresses, $cc_addresses);
     }
     $cc_users = array();
     foreach ($addresses as $email) {
         $cc_usr_id = User::getUserIDByEmail(strtolower($email), true);
         if (!empty($cc_usr_id) && User::getRoleByUser($cc_usr_id, $prj_id) >= User::ROLE_USER) {
             $cc_users[] = $cc_usr_id;
         }
     }
     $body = $structure->body;
     $reference_msg_id = Mail_Helper::getReferenceMessageID($headers);
     if (!empty($reference_msg_id)) {
         $parent_id = Note::getIDByMessageID($reference_msg_id);
     } else {
         $parent_id = false;
     }
     // insert the new note and send notification about it
     $_POST = array('title' => @$structure->headers['subject'], 'note' => $body, 'note_cc' => $cc_users, 'add_extra_recipients' => 'yes', 'message_id' => @$structure->headers['message-id'], 'parent_id' => $parent_id);
     // add the full email to the note if there are any attachments
     // this is needed because the front end code will display attachment links
     if (Mime_Helper::hasAttachments($structure)) {
         $_POST['full_message'] = $full_message;
     }
     $usr_id = Auth::getUserID();
     $res = Note::insertFromPost($usr_id, $issue_id, $unknown_user, false);
     // need to handle attachments coming from notes as well
     if ($res != -1) {
         Support::extractAttachments($issue_id, $structure, true, $res);
//.........这里部分代码省略.........
开发者ID:dabielkabuto,项目名称:eventum,代码行数:101,代码来源:class.routing.php

示例6: elseif

}
Workflow::prePage($prj_id, 'post_note');
if ($cat == 'post_result' && !empty($_GET['post_result'])) {
    $res = (int) $_GET['post_result'];
    $tpl->assign('post_result', $res);
} elseif ($cat == 'post_note') {
    // change status
    $status = isset($_POST['new_status']) ? (int) $_POST['new_status'] : null;
    if ($status) {
        $res = Issue::setStatus($issue_id, $status);
        if ($res != -1) {
            $new_status = Status::getStatusTitle($status);
            History::add($issue_id, $usr_id, 'status_changed', "Status changed to '{status}' by {user} when sending a note", array('status' => $new_status, 'user' => User::getFullName($usr_id)));
        }
    }
    $res = Note::insertFromPost($usr_id, $issue_id);
    Issue_Field::updateValues($issue_id, 'post_note', @$_REQUEST['issue_field']);
    if ($res == -1) {
        Misc::setMessage(ev_gettext('An error occurred while trying to run your query'), Misc::MSG_ERROR);
    } else {
        Misc::setMessage(ev_gettext('Thank you, the internal note was posted successfully.'), Misc::MSG_INFO);
    }
    $tpl->assign('post_result', $res);
    // enter the time tracking entry about this phone support entry
    if (!empty($_POST['time_spent'])) {
        if (isset($_POST['time_summary']) && !empty($_POST['time_summary'])) {
            $summary = (string) $_POST['time_summary'];
        } else {
            $summary = 'Time entry inserted when sending an internal note.';
        }
        $date = (array) $_POST['date'];
开发者ID:korusdipl,项目名称:eventum,代码行数:31,代码来源:post_note.php


注:本文中的Note::insertFromPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。