Beispiel #1
0
 /**
  * Pass through method to the table for setting the last visit date
  *
  * @param   integer  $timestamp  The timestamp, defaults to 'now'.
  * @return  boolean  True on success.
  * @since   2.1.0
  */
 public function setLastVisit($timestamp = 'now')
 {
     $timestamp = new Date($timestamp);
     $query = $this->getQuery()->update($this->getTableName())->set(array('lastvisitDate' => $timestamp->toSql()))->whereEquals('id', $this->get('id'));
     return $query->execute();
 }
Beispiel #2
0
 /**
  * Mark entry as having been viewed
  *
  * @return  boolean
  */
 public function markAsViewed()
 {
     $dt = new Date('now');
     $this->set('viewed', $dt->toSql());
     return $this->save();
 }
Beispiel #3
0
 /**
  * Create a new ticket
  *
  * @apiMethod POST
  * @apiUri    /support
  * @apiParameter {
  * 		"name":        "scope",
  * 		"description": "Scope type (group, member, etc.)",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "scope_id",
  * 		"description": "Scope object ID",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "title",
  * 		"description": "Entry title",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "alias",
  * 		"description": "Entry alias",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @return     void
  */
 public function createTask()
 {
     //get the userid and attempt to load user profile
     $userid = User::get('id');
     $result = User::getInstance($userid);
     //make sure we have a user
     if (!$result || !$result->get('id')) {
         throw new Exception(Lang::txt('User not found.'), 500);
     }
     // Initiate class and bind data to database fields
     $ticket = new \Components\Support\Models\Ticket();
     // Set the created date
     $ticket->set('created', Date::toSql());
     // Incoming
     $ticket->set('report', Request::getVar('report', '', 'post', 'none', 2));
     if (!$ticket->get('report')) {
         throw new Exception(Lang::txt('Error: Report contains no text.'), 500);
     }
     $ticket->set('os', Request::getVar('os', 'unknown', 'post'));
     $ticket->set('browser', Request::getVar('browser', 'unknown', 'post'));
     $ticket->set('severity', Request::getVar('severity', 'normal', 'post'));
     // Cut suggestion at 70 characters
     $summary = substr($ticket->get('report'), 0, 70);
     if (strlen($summary) >= 70) {
         $summary .= '...';
     }
     $ticket->set('summary', $summary);
     // Get user data
     $ticket->set('name', $result->get('name'));
     $ticket->set('email', $result->get('email'));
     $ticket->set('login', $result->get('username'));
     // Set some helpful info
     $ticket->set('instances', 1);
     $ticket->set('section', 1);
     $ticket->set('open', 1);
     $ticket->set('status', 0);
     $ticket->set('ip', Request::ip());
     $ticket->set('hostname', gethostbyaddr(Request::getVar('REMOTE_ADDR', '', 'server')));
     // Save the data
     if (!$ticket->store()) {
         throw new Exception($ticket->getErrors(), 500);
     }
     // Any tags?
     if ($tags = trim(Request::getVar('tags', '', 'post'))) {
         $ticket->tag($tags, $result->get('id'));
     }
     // Set the response
     $msg = new stdClass();
     $msg->submitted = $ticket->get('created');
     $msg->ticket = $ticket->get('id');
     $this->send($msg);
 }
Beispiel #4
0
 /**
  * Generates automatic expires field
  *
  * @param   array   $data  the data being saved
  * @return  string
  */
 public function automaticExpires($data)
 {
     if (!isset($data['expires'])) {
         $dt = new Date($data['created']);
         $dt->modify('+1 hour');
         $data['expires'] = $dt->toSql();
     }
     return $data['expires'];
 }
Beispiel #5
0
 /**
  * Create a new comment
  *
  * @apiMethod POST
  * @apiUri    /support/comments
  * @apiParameter {
  * 		"name":        "ticket",
  * 		"description": "Id of the ticket to make a comment on",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":		 null
  * }
  * @apiParameter {
  * 		"name":        "comment",
  * 		"description": "Comment text",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":		 null
  * }
  * @apiParameter {
  * 		"name":        "group",
  * 		"description": "Group to assign the ticket to (by alias)",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":		 null
  * }
  * @apiParameter {
  * 		"name":        "owner",
  * 		"description": "Id of the owner to assign ticket to",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":		 null
  * }
  * @apiParameter {
  * 		"name":        "severity",
  * 		"description": "Severity of the ticket",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":		 null
  *		"allowed_values":	"minor, normal, major, critical"
  * }
  * @apiParameter {
  * 		"name":        "status",
  * 		"description": "Status of the ticket",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":		 null
  * }
  * @apiParameter {
  * 		"name":        "target_date",
  * 		"description": "Target date for completion of ticket (YYYY-MM-DD hh:mm:ss)",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":		 null
  * }
  * @apiParameter {
  * 		"name":        "cc",
  * 		"description": "Comma seperated list of email addresses to email updates to",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":		 submitter,owner
  * }
  * @apiParameter {
  * 		"name":        "private",
  * 		"description": "Should the comment be flagged as private",
  * 		"type":        "boolean",
  * 		"required":    false,
  * 		"default":		 false
  * }
  * @apiParameter {
  * 		"name":        "email_submitter",
  * 		"description": "Should the submitter be emailed about this comment",
  * 		"type":        "boolean",
  * 		"required":    false,
  * 		"default":		 false
  * }
  * @apiParameter {
  * 		"name":        "email_owner",
  * 		"description": "Should the ticket owner be emailed about this comment",
  * 		"type":        "boolean",
  * 		"required":    false,
  * 		"default":		 false
  * }
  * @return     void
  */
 public function createTask()
 {
     $this->requiresAuthentication();
     if (!$this->acl->check('create', 'comments')) {
         throw new Exception(Lang::txt('Not authorized'), 403);
     }
     $ticket_id = Request::getInt('ticket', null);
     if (!isset($ticket_id)) {
         throw new Exception(Lang::txt('Bad request - ticket ID required'), 400);
     }
     $comment_text = Request::getString('comment', '');
     if ($comment_text == '') {
         throw new Exception(Lang::txt('Bad request - comment required'), 400);
     }
     $ticket = \Components\Support\Models\Orm\Ticket::oneOrFail($ticket_id);
     $comment = new \Components\Support\Models\Orm\Comment();
     $changelog = new stdClass();
     $comment->set('ticket', Request::get('ticket', ''));
     $comment->set('comment', nl2br(Request::get('comment')));
     $comment->set('created_by', User::get('id'));
     $comment->set('access', Request::get('private', false) == 'true' ? 1 : 0);
     $changes = array();
     foreach (['group', 'owner', 'severity', 'status', 'target_date', 'category'] as $index) {
         if (Request::get($index, null)) {
             if (Request::get($index) != $ticket->get($index)) {
                 $temp = new stdClass();
                 $temp->field = $index;
                 $temp->before = $ticket->get($index);
                 $temp->after = Request::get($index);
                 if ($index == 'status') {
                     if ($ticket->get('status') == 0) {
                         $status_model = new \Components\Support\Models\Orm\Status();
                         $status_model->set('title', 'Closed');
                         $status_model->set('open', 0);
                     } else {
                         $status_model = \Components\Support\Models\Orm\Status::oneOrFail(Request::get('status'));
                     }
                     if ($ticket->get('status') == 0) {
                         $old_status = new \Components\Support\Models\Orm\Status();
                         $old_status->set('title', 'Closed');
                         $old_status->set('open', 0);
                     } else {
                         $old_status = \Components\Support\Models\Orm\Status::oneOrFail($ticket->get('status'));
                     }
                     $temp->before = $old_status->get('title');
                     $temp->after = $status_model->get('title');
                     $ticket->set('open', $status_model->get('open'));
                     if ($status_model->get('get') == 'open' && $ticket->get('status', null) == 'closed') {
                         $tiket->set('closed', '0000-00-00 00:00:00');
                     }
                     if ($status_model->get('get') == 'closed' && $ticket->get('status', null) == 'open') {
                         $ticket->set('closed', Date::toSql());
                     }
                 }
                 if ($index == 'owner') {
                     $old_owner = User::getInstance($ticket->get('owner'));
                     $new_owner = User::getInstance(Request::get('owner'));
                     $temp->before = $old_owner->get('username');
                     $temp->after = $new_owner->get('username');
                 }
                 $ticket->set($index, Request::get($index));
                 $changes[] = $temp;
             }
         }
     }
     $changelog->changes = $changes;
     if ($comment->get('comment')) {
         // If a comment was posted by the ticket submitter to a "waiting user response" ticket, change status.
         $user = User::getInstance(User::get('id'));
         if ($ticket->get('status') == 2 && $user->get('username') == $ticket->get('login')) {
             $ticket->set('status', 0);
         }
     }
     $comment->set('changelog', json_encode($changelog));
     if (!$comment->save()) {
         throw new Exception(print_r($comment->getErrors(), 1), 500);
     }
     if (!$ticket->save()) {
         throw new Exception(print_r($ticket->getErrors(), 1), 500);
     }
     // There's now a ticket and a comment, lets add attachments
     \Components\Support\Helpers\Utilities::addAttachments($ticket->get('id'), $comment->get('id'));
     $msg = new stdClass();
     $msg->id = $comment->get('id');
     $msg->notified = $comment->get('changelog');
     $this->send($msg, 200, 'OK');
     /*
     		$changlog->notifications = array();
     		if (Request::get('email_owner'))
     		{
     			$comment->addTo(array(
     				'role'  => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_OWNER'),
     				'name'  => $ticket->get_owner->get('name'),
     				'email' => $ticket->get_owner->get('email'),
     				'id'    => $ticket->get_owner->get('id')
     			));
     			$changelog->notifications[] = json_encode(array('role'=>'Ticket owner', 'address'=>$ticket->get_owner()->get('email'), 'name'=>$ticket->get_owner()->get('name')));
     		}
     
     		// Add any CCs to the e-mail list
     		$cc = Request::get('cc', null);
     		if ($cc)
     		{
     			$cc = explode(',', $cc);
     			foreach ($cc)
     			{
     				$comment->addTo($cc, Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_CC'));
     			}
     			$changelog->cc = json_encode($cc);
     		}
     
     		// Check if the notify list has eny entries
     		if (count($comment->to()))
     		{
     			include_once(PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'helpers' . DS . 'utilities.php');
     
     			$allowEmailResponses = $ticket->config('email_processing');
     			if ($allowEmailResponses)
     			{
     				try
     				{
     					$encryptor = new \Hubzero\Mail\Token();
     				}
     				catch (Exception $e)
     				{
     					$allowEmailResponses = false;
     				}
     			}
     
     			$subject = Lang::txt('COM_SUPPORT_EMAIL_SUBJECT_TICKET_COMMENT', $ticket->get('id'));
     
     			$from = array(
     				'name'      => Lang::txt('COM_SUPPORT_EMAIL_FROM', Config::get('sitename')),
     				'email'     => Config::get('mailfrom'),
     				'multipart' => md5(date('U'))
     			);
     
     			$message = array();
     
     			// Plain text email
     			$eview = new \Hubzero\Mail\View(array(
     				'base_path' => PATH_CORE . '/components/com_support/site',
     				'name'      => 'emails',
     				'layout'    => 'comment_plain'
     			));
     			$eview->option     = 'com_support';
     			$eview->controller = 'tickets';
     			$eview->comment    = $comment;
     			$eview->ticket     = $ticket;
     			$eview->delimiter  = ($allowEmailResponses ? '~!~!~!~!~!~!~!~!~!~!' : '');
     
     			$message['plaintext'] = $eview->loadTemplate(false);
     			$message['plaintext'] = str_replace("\n", "\r\n", $message['plaintext']);
     
     			// HTML email
     			$eview->setLayout('comment_html');
     			$message['multipart'] = $eview->loadTemplate();
     
     			// Send e-mail to admin?
     			foreach ($comment->to('ids') as $to)
     			{
     				if ($allowEmailResponses)
     				{
     					// The reply-to address contains the token
     					$token = $encryptor->buildEmailToken(1, 1, $to['id'], $ticket->get('id'));
     					$from['replytoemail'] = 'htc-' . $token . strstr(Config::get('mailfrom'), '@');
     				}
     
     				// Get the user's email address
     				if (!Event::trigger('xmessage.onSendMessage', array('support_reply_submitted', $subject, $message, $from, array($to['id']), 'com_support')))
     				{
     					$this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_MESSAGE', $to['name'] . '(' . $to['role'] . ')'));
     				}
     				$comment->changelog()->notified(
     					$to['role'],
     					$to['name'],
     					$to['email']
     				);
     			}
     
     			foreach ($comment->to('emails') as $to)
     			{
     				if ($allowEmailResponses)
     				{
     					$token = $encryptor->buildEmailToken(1, 1, -9999, $ticket->get('id'));
     
     					$email = array(
     						$to['email'],
     						'htc-' . $token . strstr(Config::get('mailfrom'), '@')
     					);
     
     					// In this case each item in email in an array, 1- To, 2:reply to address
     					\Components\Support\Helpers\Utilities::sendEmail($email[0], $subject, $message, $from, $email[1]);
     				}
     				else
     				{
     					// email is just a plain 'ol string
     					\Components\Support\Helpers\Utilities::sendEmail($to['email'], $subject, $message, $from);
     				}
     
     				$comment->changelog()->notified(
     					$to['role'],
     					$to['name'],
     					$to['email']
     				);
     			}
     		}
     		$comment->set('changelog', json_encode($changelog));
     		$comment->save();
     		$ticket->save();
     
     		$msg = new stdClass;
     		$msg->id  = $comment->get('id');
     		$msg->notified = $comment->get('changelog');
     
     		$this->send($msg, 200, 'OK');
     */
 }
Beispiel #6
0
 /**
  * Mark a message as being read by the recipient
  *
  * @return  boolean  True on success
  */
 public function markAsRead()
 {
     if (!$this->get('id')) {
         $this->addError('Recipient record not found');
         return false;
     }
     $xseen = Seen::oneByMessageAndUser($this->get('mid'), $this->get('uid'));
     if ($xseen->get('whenseen') == '' || $xseen->get('whenseen') == '0000-00-00 00:00:00' || $xseen->get('whenseen') == null) {
         $dt = new Date('now');
         $xseen->set('mid', $this->get('mid'));
         $xseen->set('uid', $this->get('uid'));
         $xseen->set('whenseen', $dt->toSql());
         if (!$xseen->save()) {
             $this->addError($xseen->getError());
             return false;
         }
     }
     return true;
 }
Beispiel #7
0
 /**
  * Mark entry as having been viewed
  *
  * @return  boolean
  */
 public function markAsViewed()
 {
     $dt = new Date('now');
     $this->set('viewed', $dt->toSql());
     if (!$this->save()) {
         return false;
     }
     return true;
 }
 /**
  * Build Query to get Announcements
  *
  * @param   array   $filters
  * @return  string
  */
 private function _buildQuery($filters = array())
 {
     //array to hold where statements
     $where = array();
     //start query
     $query = " FROM {$this->_tbl} AS a";
     //apply filters based on filters passed in
     if (isset($filters['scope']) && $filters['scope']) {
         $where[] = "a.`scope` = " . $this->_db->quote($filters['scope']);
     }
     if (isset($filters['scope_id']) && $filters['scope_id']) {
         $where[] = "a.`scope_id` = " . $this->_db->quote(intval($filters['scope_id']));
     }
     if (isset($filters['state']) && $filters['state']) {
         $where[] = "a.`state` = " . $this->_db->quote(intval($filters['state']));
     }
     if (isset($filters['created_by']) && $filters['created_by']) {
         $where[] = "a.`created_by` = " . $this->_db->quote(intval($filters['created_by']));
     }
     if (isset($filters['priority']) && $filters['priority']) {
         $where[] = "a.`priority` = " . $this->_db->quote(intval($filters['priority']));
     }
     if (isset($filters['sticky']) && in_array($filters['sticky'], array(0, 1))) {
         $where[] = "a.`sticky` = " . $this->_db->quote(intval($filters['sticky']));
     }
     if (isset($filters['email']) && in_array($filters['email'], array(0, 1))) {
         $where[] = "a.`email` = " . $this->_db->quote(intval($filters['email']));
     }
     if (isset($filters['sent']) && in_array($filters['sent'], array(0, 1))) {
         $where[] = "a.`sent` = " . $this->_db->quote(intval($filters['sent']));
     }
     //published
     if (isset($filters['published'])) {
         $now = new Date('now');
         $where[] = "(a.`publish_up` = '0000-00-00 00:00:00' OR a.`publish_up` <= " . $this->_db->quote($now->toSql()) . ")";
         $where[] = "(a.`publish_down` = '0000-00-00 00:00:00' OR a.`publish_down` >= " . $this->_db->quote($now->toSql()) . ")";
     }
     //search
     if (isset($filters['search']) && $filters['search']) {
         if (is_numeric($filters['search'])) {
             $where[] = "a.`id`=" . $this->_db->quote(intval($filters['search']));
         } else {
             $where[] = "(LOWER(a.content) LIKE " . $this->_db->quote('%' . strtolower($filters['search']) . '%') . ")";
         }
     }
     //if we have an wheres append them
     if (count($where) > 0) {
         $query .= " WHERE " . implode(' AND ', $where);
     }
     return $query;
 }
 /**
  * Create a new comment
  *
  * @apiMethod POST
  * @apiUri    /support/{ticket}/comments
  * @apiParameter {
  * 		"name":        "scope",
  * 		"description": "Scope type (group, member, etc.)",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "scope_id",
  * 		"description": "Scope object ID",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "title",
  * 		"description": "Entry title",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "alias",
  * 		"description": "Entry alias",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @return     void
  */
 public function createTask()
 {
     $this->requiresAuthentication();
     if (!$this->acl->check('create', 'comments')) {
         throw new Exception(Lang::txt('Not authorized'), 403);
     }
     $ticket_id = Request::getInt('ticket', 0, 'post');
     // Load the old ticket so we can compare for the changelog
     $old = new \Components\Support\Models\Ticket($ticket_id);
     $old->set('tags', $old->tags('string'));
     if (!$old->exists()) {
         $this->errorMessage(500, Lang::txt('Ticket "%s" does not exist.', $ticket_id));
         return;
     }
     // Initiate class and bind posted items to database fields
     $ticket = new \Components\Support\Models\Ticket($ticket_id);
     $ticket->set('status', Request::getInt('status', $ticket->get('status'), 'post'));
     $ticket->set('open', Request::getInt('open', $ticket->get('open'), 'post'));
     $ticket->set('category', Request::getInt('category', $ticket->get('category'), 'post'));
     $ticket->set('severity', Request::getVar('severity', $ticket->get('severity'), 'post'));
     $ticket->set('owner', Request::getVar('owner', $ticket->get('owner'), 'post'));
     $ticket->set('group', Request::getVar('group', $ticket->get('group'), 'post'));
     // If an existing ticket AND closed AND previously open
     if ($ticket_id && !$ticket->get('open') && $ticket->get('open') != $old->get('open')) {
         // Record the closing time
         $ticket->set('closed', Date::toSql());
     }
     // Any tags?
     if ($tags = trim(Request::getVar('tags', '', 'post'))) {
         $ticket->tag($tags, $user->get('uidNumber'));
         $ticket->set('tags', $ticket->tags('string'));
     }
     // Store new content
     if (!$ticket->store()) {
         $this->errorMessage(500, $ticket->getError());
         return;
     }
     // Create a new comment
     $comment = new \Components\Support\Models\Comment();
     $comment->set('ticket', $ticket->get('id'));
     $comment->set('comment', nl2br(Request::getVar('comment', '', 'post', 'none', 2)));
     if ($comment->get('comment')) {
         // If a comment was posted by the ticket submitter to a "waiting user response" ticket, change status.
         if ($ticket->isWaiting() && $user->get('username') == $ticket->get('login')) {
             $ticket->open();
         }
     }
     $comment->set('created', Date::toSql());
     $comment->set('created_by', $user->get('uidNumber'));
     $comment->set('access', Request::getInt('access', 0, 'post'));
     // Compare fields to find out what has changed for this ticket and build a changelog
     $comment->changelog()->diff($old, $ticket);
     $comment->changelog()->cced(Request::getVar('cc', '', 'post'));
     // Store new content
     if (!$comment->store()) {
         $this->errorMessage(500, $comment->getError());
         return;
     }
     if ($ticket->get('owner')) {
         $comment->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_OWNER'), 'name' => $ticket->owner('name'), 'email' => $ticket->owner('email'), 'id' => $ticket->owner('id')));
     }
     // Add any CCs to the e-mail list
     foreach ($comment->changelog()->get('cc') as $cc) {
         $comment->addTo($cc, Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_CC'));
     }
     // Check if the notify list has eny entries
     if (count($comment->to())) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'helpers' . DS . 'utilities.php';
         $allowEmailResponses = $ticket->config('email_processing');
         if ($allowEmailResponses) {
             try {
                 $encryptor = new \Hubzero\Mail\Token();
             } catch (Exception $e) {
                 $allowEmailResponses = false;
             }
         }
         $subject = Lang::txt('COM_SUPPORT_EMAIL_SUBJECT_TICKET_COMMENT', $ticket->get('id'));
         $from = array('name' => Lang::txt('COM_SUPPORT_EMAIL_FROM', Config::get('sitename')), 'email' => Config::get('mailfrom'), 'multipart' => md5(date('U')));
         $message = array();
         // Plain text email
         $eview = new \Hubzero\Mail\View(array('base_path' => PATH_CORE . '/components/com_support/site', 'name' => 'emails', 'layout' => 'comment_plain'));
         $eview->option = 'com_support';
         $eview->controller = 'tickets';
         $eview->comment = $comment;
         $eview->ticket = $ticket;
         $eview->delimiter = $allowEmailResponses ? '~!~!~!~!~!~!~!~!~!~!' : '';
         $message['plaintext'] = $eview->loadTemplate(false);
         $message['plaintext'] = str_replace("\n", "\r\n", $message['plaintext']);
         // HTML email
         $eview->setLayout('comment_html');
         $message['multipart'] = $eview->loadTemplate();
         // Send e-mail to admin?
         foreach ($comment->to('ids') as $to) {
             if ($allowEmailResponses) {
                 // The reply-to address contains the token
                 $token = $encryptor->buildEmailToken(1, 1, $to['id'], $ticket->get('id'));
                 $from['replytoemail'] = 'htc-' . $token . strstr(Config::get('mailfrom'), '@');
             }
             // Get the user's email address
             if (!Event::trigger('xmessage.onSendMessage', array('support_reply_submitted', $subject, $message, $from, array($to['id']), 'com_support'))) {
                 $this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_MESSAGE', $to['name'] . '(' . $to['role'] . ')'));
             }
             $comment->changelog()->notified($to['role'], $to['name'], $to['email']);
         }
         foreach ($comment->to('emails') as $to) {
             if ($allowEmailResponses) {
                 $token = $encryptor->buildEmailToken(1, 1, -9999, $ticket->get('id'));
                 $email = array($to['email'], 'htc-' . $token . strstr(Config::get('mailfrom'), '@'));
                 // In this case each item in email in an array, 1- To, 2:reply to address
                 \Components\Support\Helpers\Utilities::sendEmail($email[0], $subject, $message, $from, $email[1]);
             } else {
                 // email is just a plain 'ol string
                 \Components\Support\Helpers\Utilities::sendEmail($to['email'], $subject, $message, $from);
             }
             $comment->changelog()->notified($to['role'], $to['name'], $to['email']);
         }
     }
     // Were there any changes?
     if (count($comment->changelog()->get('notifications')) > 0 || count($comment->changelog()->get('cc')) > 0 || count($comment->changelog()->get('changes')) > 0) {
         // Save the data
         if (!$comment->store()) {
             $this->errorMessage(500, $comment->getError());
             return;
         }
     }
     $msg = new stdClass();
     $msg->ticket = $ticket->get('id');
     $msg->comment = $comment->get('id');
     $msg->notified = $comment->changelog()->get('notifications');
     $this->setMessageType(Request::getVar('format', 'json'));
     $this->send($msg, 200, 'OK');
 }
Beispiel #10
0
 /**
  * Generates automatic created field value
  *
  * @return  string
  * @since   2.0.0
  **/
 public function automaticRanAt()
 {
     $dt = new Date('now');
     return $dt->toSql();
 }