From c3a2cbcd02f890f0c659e272088301ac6636fa46 Mon Sep 17 00:00:00 2001 From: aydreeihn <adriane@enhancesoft.com> Date: Thu, 12 Jul 2018 14:13:07 -0500 Subject: [PATCH] Final Additions For v1.11 - Separate 'message' and 'response' variables on New Ticket Notice so they can be styles separately - Add Thread Event state for 'released' - Add 'refer' and 'release' permissions to the Role table - Update install-mysql - Update patch file name - Update core.sig - Set flags in correct place for class.depts.php - Make sure when opening Ticket, User stays selected if submitted with errors - Make sure Mail Box Protocol saves correctly when configuring emails --- include/class.dept.php | 2 +- include/class.email.php | 16 +++++----- include/class.ticket.php | 10 ++---- include/i18n/en_US/role.yaml | 1 + .../en_US/templates/email/ticket.notice.yaml | 3 ++ include/upgrader/streams/core.sig | 2 +- .../streams/core/70921d5c-192aeec9.patch.sql | 15 --------- .../streams/core/70921d5c-26fd79dc.patch.sql | 31 +++++++++++++++++++ scp/tickets.php | 9 ++++-- setup/inc/streams/core/install-mysql.sql | 5 +-- 10 files changed, 57 insertions(+), 37 deletions(-) delete mode 100644 include/upgrader/streams/core/70921d5c-192aeec9.patch.sql create mode 100644 include/upgrader/streams/core/70921d5c-26fd79dc.patch.sql diff --git a/include/class.dept.php b/include/class.dept.php index 384a749a2..387e8f7fa 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -786,6 +786,7 @@ implements TemplateVariable, Searchable { $this->group_membership = $vars['group_membership']; $this->ticket_auto_response = isset($vars['ticket_auto_response'])?$vars['ticket_auto_response']:1; $this->message_auto_response = isset($vars['message_auto_response'])?$vars['message_auto_response']:1; + $this->flags = $vars['flags'] ?: 0; $this->setFlag(self::FLAG_ASSIGN_MEMBERS_ONLY, isset($vars['assign_members_only'])); $this->setFlag(self::FLAG_DISABLE_AUTO_CLAIM, isset($vars['disable_auto_claim'])); @@ -812,7 +813,6 @@ implements TemplateVariable, Searchable { $this->setFlag(self::FLAG_ARCHIVED, true); } - $this->flags = 0; $this->setFlag(self::FLAG_DISABLE_AUTO_CLAIM, isset($vars['disable_auto_claim'])); switch ($vars['assignment_flag']) { diff --git a/include/class.email.php b/include/class.email.php index b0dce8bbc..41bb55a1a 100644 --- a/include/class.email.php +++ b/include/class.email.php @@ -118,7 +118,9 @@ class Email extends VerySimpleModel { function getInfo() { $base = $this->getHashtable(); - $base['mail_proto'] = $this->mail_proto; + $base['mail_proto'] = $this->mail_protocol; + if ($this->mail_encryption != 'NONE') + $base['mail_proto'] .= "/{$this->mail_encryption}"; return $base; } @@ -395,16 +397,16 @@ class Email extends VerySimpleModel { $this->userid = $vars['userid']; $this->mail_active = $vars['mail_active']; $this->mail_host = $vars['mail_host']; - $this->mail_protocol = $vars['mail_protocol']?$vars['mail_protocol']:'POP'; + $this->mail_protocol = $vars['mail_protocol'] ?: 'POP'; $this->mail_encryption = $vars['mail_encryption']; - $this->mail_port = $vars['mail_port']?$vars['mail_port']:0; - $this->mail_fetchfreq = $vars['mail_fetchfreq']?$vars['mail_fetchfreq']:0; - $this->mail_fetchmax = $vars['mail_fetchmax']?$vars['mail_fetchmax']:0; + $this->mail_port = $vars['mail_port'] ?: 0; + $this->mail_fetchfreq = $vars['mail_fetchfreq'] ?: 0; + $this->mail_fetchmax = $vars['mail_fetchmax'] ?: 0; $this->smtp_active = $vars['smtp_active']; $this->smtp_host = $vars['smtp_host']; - $this->smtp_port = $vars['smtp_port']?$vars['smtp_port']:0; + $this->smtp_port = $vars['smtp_port'] ?: 0; $this->smtp_auth = $vars['smtp_auth']; - $this->smtp_spoofing = isset($vars['smtp_spoofing'])?1:0; + $this->smtp_spoofing = isset($vars['smtp_spoofing']) ? 1 : 0; $this->notes = Format::sanitize($vars['notes']); //Post fetch email handling... diff --git a/include/class.ticket.php b/include/class.ticket.php index 2ca2f89ba..71e890add 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -4026,7 +4026,7 @@ implements RestrictedAccess, Threadable, Searchable { // department if ($vars['assignId'] && !( $role - ? $role->hasPerm(Ticket::PERM_ASSIGN) + ? ($role->hasPerm(Ticket::PERM_ASSIGN) || $role->__new__) : $thisstaff->hasPerm(Ticket::PERM_ASSIGN, false) )) { $errors['assignId'] = __('Action Denied. You are not allowed to assign/reassign tickets.'); @@ -4100,12 +4100,6 @@ implements RestrictedAccess, Threadable, Searchable { $attachments = $attachments->merge($response->getAttachments()); } - $message = (string) $message; - if ($response) { - $message .= ($cfg->isRichTextEnabled()) ? "<br><br>" : "\n\n"; - $message .= $response->getBody(); - } - if ($vars['signature']=='mine') $signature=$thisstaff->getSignature(); elseif ($vars['signature']=='dept' && $dept && $dept->isPublic()) @@ -4117,7 +4111,7 @@ implements RestrictedAccess, Threadable, Searchable { array( 'message' => $message, 'signature' => $signature, - 'response' => ($response) ? $response->getBody() : '', + 'response' => $response ?: '', 'recipient' => $ticket->getOwner(), //End user 'staff' => $thisstaff, ) diff --git a/include/i18n/en_US/role.yaml b/include/i18n/en_US/role.yaml index 15dc3be64..ec0832d8d 100644 --- a/include/i18n/en_US/role.yaml +++ b/include/i18n/en_US/role.yaml @@ -68,6 +68,7 @@ permissions: [ ticket.create, ticket.assign, + ticket.release, ticket.transfer, ticket.refer, ticket.reply diff --git a/include/i18n/en_US/templates/email/ticket.notice.yaml b/include/i18n/en_US/templates/email/ticket.notice.yaml index bf2a6803c..9cfbefb80 100644 --- a/include/i18n/en_US/templates/email/ticket.notice.yaml +++ b/include/i18n/en_US/templates/email/ticket.notice.yaml @@ -26,6 +26,9 @@ body: | %{message} <br> <br> + %{response} + <br> + <br> If need be, a representative will follow-up with you as soon as possible. You can also <a href="%{recipient.ticket_link}">view this ticket's progress online</a>. diff --git a/include/upgrader/streams/core.sig b/include/upgrader/streams/core.sig index 5a71b05a5..fbebb45e6 100644 --- a/include/upgrader/streams/core.sig +++ b/include/upgrader/streams/core.sig @@ -1 +1 @@ -192aeec968ad819b88c49d7e0fecd723 +26fd79dc5443f37779f9d2c4108058f4 diff --git a/include/upgrader/streams/core/70921d5c-192aeec9.patch.sql b/include/upgrader/streams/core/70921d5c-192aeec9.patch.sql deleted file mode 100644 index 3302029a2..000000000 --- a/include/upgrader/streams/core/70921d5c-192aeec9.patch.sql +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @signature 192aeec968ad819b88c49d7e0fecd723 -* @version v1.11.0 -* @title Final Revisions -* -* This patch is for final revisions needed for v1.11 -*/ - -ALTER TABLE `%TABLE_PREFIX%thread_event` - CHANGE `state` `state` enum('created','closed','reopened','assigned','transferred', 'referred', 'overdue','edited','viewed','error','collab','resent', 'deleted') NOT NULL; - - -- Finished with patch -UPDATE `%TABLE_PREFIX%config` - SET `value` = '192aeec968ad819b88c49d7e0fecd723' - WHERE `key` = 'schema_signature' AND `namespace` = 'core'; diff --git a/include/upgrader/streams/core/70921d5c-26fd79dc.patch.sql b/include/upgrader/streams/core/70921d5c-26fd79dc.patch.sql new file mode 100644 index 000000000..ed631e92d --- /dev/null +++ b/include/upgrader/streams/core/70921d5c-26fd79dc.patch.sql @@ -0,0 +1,31 @@ +/** +* @signature 26fd79dc5443f37779f9d2c4108058f4 +* @version v1.11.0 +* @title Final Revisions +* +* This patch is for final revisions needed for v1.11 +*/ + +ALTER TABLE `%TABLE_PREFIX%thread_event` + CHANGE `state` `state` enum('created','closed','reopened','assigned', 'released', 'transferred', 'referred', 'overdue','edited','viewed','error','collab','resent', 'deleted') NOT NULL; + +ALTER TABLE `%TABLE_PREFIX%attachment` + ADD INDEX `file_object` (`file_id`,`object_id`); + +UPDATE `%TABLE_PREFIX%role` + SET `permissions` = REPLACE(`permissions`, '"ticket.transfer":1,', '"ticket.transfer":1,"ticket.refer":1,') + WHERE `permissions` IS NOT NULL; + +UPDATE `%TABLE_PREFIX%role` + SET `permissions` = REPLACE(`permissions`, '"ticket.assign":1,', '"ticket.assign":1,"ticket.release":1,') + WHERE `permissions` IS NOT NULL AND `permissions` LIKE '%"ticket.assign":1,%'; + +-- Ticket Notice Template +UPDATE `%TABLE_PREFIX%email_template` + SET `code_name` = REPLACE('ticket.notice', '%{message}', '%{message}<br><br>%{response}') + WHERE `code_name` = 'ticket.notice'; + + -- Finished with patch +UPDATE `%TABLE_PREFIX%config` + SET `value` = '26fd79dc5443f37779f9d2c4108058f4', `updated` = NOW() + WHERE `key` = 'schema_signature' AND `namespace` = 'core'; diff --git a/scp/tickets.php b/scp/tickets.php index ca0770817..a3b7103f3 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -43,8 +43,11 @@ if (!$ticket) { $queue_id = null; // Search for user - if (isset($_GET['uid'])) - $user = User::lookup($_GET['uid']); + if (isset($_REQUEST['uid'])) + $user = User::lookup($_REQUEST['uid']); + + if (isset($_REQUEST['email'])) + $user = User::lookupByEmail($_REQUEST['email']); if ($user && $_GET['a'] !== 'open' @@ -398,7 +401,7 @@ if($_POST && !$errors): } else { $vars = $_POST; - if ($vars['uid'] && (!User::lookup($vars['uid']))) + if ($vars['uid'] && !($user=User::lookup($vars['uid']))) $vars['uid'] = 0; $vars['cannedattachments'] = $response_form->getField('attachments')->getClean(); diff --git a/setup/inc/streams/core/install-mysql.sql b/setup/inc/streams/core/install-mysql.sql index f8e31e06d..fbbb6e450 100644 --- a/setup/inc/streams/core/install-mysql.sql +++ b/setup/inc/streams/core/install-mysql.sql @@ -25,7 +25,8 @@ CREATE TABLE `%TABLE_PREFIX%attachment` ( `inline` tinyint(1) unsigned NOT NULL DEFAULT '0', `lang` varchar(16), PRIMARY KEY (`id`), - UNIQUE KEY `file-type` (`object_id`,`file_id`,`type`) + UNIQUE KEY `file-type` (`object_id`,`file_id`,`type`), + UNIQUE KEY `file_object` (`file_id`,`object_id`) ) DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `%TABLE_PREFIX%faq`; @@ -718,7 +719,7 @@ CREATE TABLE `%TABLE_PREFIX%thread_event` ( `team_id` int(11) unsigned NOT NULL, `dept_id` int(11) unsigned NOT NULL, `topic_id` int(11) unsigned NOT NULL, - `state` enum('created','closed','reopened','assigned','transferred', 'referred', 'overdue','edited','viewed','error','collab','resent', 'deleted') NOT NULL, + `state` enum('created','closed','reopened','assigned','released','transferred', 'referred', 'overdue','edited','viewed','error','collab','resent', 'deleted') NOT NULL, `data` varchar(1024) DEFAULT NULL COMMENT 'Encoded differences', `username` varchar(128) NOT NULL default 'SYSTEM', `uid` int(11) unsigned DEFAULT NULL, -- GitLab