From 2c1e5f1a616c11e4056a3665f65b7dad0c06e915 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Sun, 8 Jul 2018 17:40:03 -0300 Subject: [PATCH] Add version upgrade for 4.1.3 --- version_upgrades/4.1.3/4.1.3.php | 35 +- .../data/mail-templates/ticket-closed.html | 384 +++++++++++++++++ .../mail-templates/ticket-created-staff.html | 378 +++++++++++++++++ .../data/mail-templates/ticket-created.html | 389 ++++++++++++++++++ .../data/mail-templates/ticket-responded.html | 384 +++++++++++++++++ .../data/mail-templates/user-edit-email.html | 356 ++++++++++++++++ .../mail-templates/user-edit-password.html | 356 ++++++++++++++++ .../mail-templates/user-password-forgot.html | 389 ++++++++++++++++++ .../data/mail-templates/user-signup.html | 389 ++++++++++++++++++ .../mail-templates/user-system-disabled.html | 389 ++++++++++++++++++ .../mail-templates/user-system-enabled.html | 389 ++++++++++++++++++ version_upgrades/mysql_connect.php | 4 +- 12 files changed, 3826 insertions(+), 16 deletions(-) create mode 100644 version_upgrades/4.1.3/data/mail-templates/ticket-closed.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/ticket-created-staff.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/ticket-created.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/ticket-responded.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/user-edit-email.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/user-edit-password.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/user-password-forgot.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/user-signup.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/user-system-disabled.html create mode 100644 version_upgrades/4.1.3/data/mail-templates/user-system-enabled.html diff --git a/version_upgrades/4.1.3/4.1.3.php b/version_upgrades/4.1.3/4.1.3.php index 889bd226..c1e1de03 100644 --- a/version_upgrades/4.1.3/4.1.3.php +++ b/version_upgrades/4.1.3/4.1.3.php @@ -3,40 +3,46 @@ require_once '../mysql_connect.php'; require_once 'libs/InitialMails.php'; // Unassign tickets whose owner doesn't service the department +function parse_department($carry, $departmentId) { + return $carry ." AND (NOT department_id='$departmentId')"; +} + $staffQueryResult = $mysql->query("SELECT id FROM staff"); while($staff = $staffQueryResult->fetch_array(MYSQLI_ASSOC)) { + $staffId = $staff['id']; $departments = []; - $departmentQueryResult = $mysql->query("SELECT department_id FROM department_staff WHERE staff_id='" . $staff['id'] . "'"); + $departmentQueryResult = $mysql->query("SELECT department_id FROM department_staff WHERE staff_id='$staffId'"); while($department = $departmentQueryResult->fetch_array(MYSQLI_ASSOC)) $departments[] = $department['department_id']; - function parse_department($departmentId) { - return " AND (NOT department_id='$departmentId')"; - } - $ticketQueryResult = $mysql->query( - "SELECT id FROM ticket WHERE owner_id='" . $staff['id'] . "'" . array_map("parse_department", $departments) . ")" + "SELECT id FROM ticket WHERE owner_id='$staffId'" . array_reduce($departments, "parse_department", "") ); - while($ticket = $ticketQueryResult->fetch_array(MYSQLI_ASSOC)) { - $mysql->query("UPDATE ticket SET owner_id=NULL WHERE id='" . $ticket['id'] . "'"); - $mysql->query("DELETE staff_ticket WHERE ticket_id='" . $ticket['id'] . "'"); + while($ticketQueryResult && $ticket = $ticketQueryResult->fetch_array(MYSQLI_ASSOC)) { + $ticketId = $ticket['id']; + $currentDate = date('YmdHi'); + + $mysql->query("UPDATE ticket SET owner_id=NULL WHERE id='$ticketId'"); + $mysql->query("DELETE from staff_ticket WHERE ticket_id='$ticketId'"); + $mysql->query("INSERT into ticketevent VALUES(NULL, 'UN_ASSIGN', $currentDate, $ticketId, $staffId, NULL)"); } } // Add new languages -$mysql->query("INSERT into langauge VALUES(NULL, 'br', '0', '0')"); -$mysql->query("INSERT into langauge VALUES(NULL, 'gr', '0', '0')"); -$mysql->query("INSERT into langauge VALUES(NULL, 'bl', '0', '0')"); +$mysql->query("INSERT into language VALUES(NULL, 'br', '0', '0')"); +$mysql->query("INSERT into language VALUES(NULL, 'gr', '0', '0')"); +$mysql->query("INSERT into language VALUES(NULL, 'nl', '0', '0')"); + // Repopulate mails $mysql->query("DELETE FROM mailtemplate"); -InitialMails::retrieve(); +$mails = InitialMails::retrieve(); foreach ($mails as $mailType => $mailLanguages) { foreach ($mailLanguages as $mailLanguage => $mailContent) { $mailSubject = $mailContent['subject']; - $mailBody = $mailContent['body']; + $mailBody = $mysql->real_escape_string($mailContent['body']); $mysql->query( "INSERT into mailtemplate (id, type, subject, language, body) VALUES " . "(NULL, '$mailType', '$mailSubject', '$mailLanguage' , '$mailBody')" @@ -53,5 +59,6 @@ $content .= 'define(\'MYSQL_USER\', \'' . MYSQL_USER . '\');' . PHP_EOL; $content .= 'define(\'MYSQL_PASSWORD\', \'' . MYSQL_PASSWORD . '\');' . PHP_EOL; $content .= 'define(\'MYSQL_DATABASE\', \'' . MYSQL_DATABASE . '\');' . PHP_EOL; + fwrite($configFile, $content); fclose($configFile); diff --git a/version_upgrades/4.1.3/data/mail-templates/ticket-closed.html b/version_upgrades/4.1.3/data/mail-templates/ticket-closed.html new file mode 100644 index 00000000..bdecca82 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/ticket-closed.html @@ -0,0 +1,384 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{TICKET_CLOSED_MATCH_1}} +
+ {{TICKET_CLOSED_MATCH_2}} +
+ + + + +
+ + + + + + + +
+ {{TICKET_CLOSED_MATCH_3}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/ticket-created-staff.html b/version_upgrades/4.1.3/data/mail-templates/ticket-created-staff.html new file mode 100644 index 00000000..b927e2bc --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/ticket-created-staff.html @@ -0,0 +1,378 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{TICKET_CREATED_STAFF_MATCH_1}} +
+ {{TICKET_CREATED_STAFF_MATCH_2}} +
+ + + + +
+ + + + + + + +
+ {{TICKET_CREATED_STAFF_MATCH_3}} +
+ {{TICKET_CREATED_STAFF_MATCH_4}} +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/ticket-created.html b/version_upgrades/4.1.3/data/mail-templates/ticket-created.html new file mode 100644 index 00000000..5a8334c5 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/ticket-created.html @@ -0,0 +1,389 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{TICKET_CREATED_MATCH_1}} +
+ {{TICKET_CREATED_MATCH_2}} +
+ + + + +
+ + + + + + + + + + +
+ {{TICKET_CREATED_MATCH_3}} +
+ {{TICKET_CREATED_MATCH_4}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/ticket-responded.html b/version_upgrades/4.1.3/data/mail-templates/ticket-responded.html new file mode 100644 index 00000000..3b3e014f --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/ticket-responded.html @@ -0,0 +1,384 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{TICKET_RESPONDED_MATCH_1}} +
+ {{TICKET_RESPONDED_MATCH_2}} +
+ + + + +
+ + + + + + + +
+ {{TICKET_RESPONDED_MATCH_3}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/user-edit-email.html b/version_upgrades/4.1.3/data/mail-templates/user-edit-email.html new file mode 100644 index 00000000..5e275154 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/user-edit-email.html @@ -0,0 +1,356 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + +
+ {{USER_EMAIL_MATCH_1}} +
+ {{USER_EMAIL_MATCH_2}} +
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/user-edit-password.html b/version_upgrades/4.1.3/data/mail-templates/user-edit-password.html new file mode 100644 index 00000000..d96c5985 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/user-edit-password.html @@ -0,0 +1,356 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + logo + +
+
+
+ +
+
+
+
+ + + + + + + +
+ {{USER_PASSWORD_MATCH_1}} +
+ {{USER_PASSWORD_MATCH_2}} +
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/user-password-forgot.html b/version_upgrades/4.1.3/data/mail-templates/user-password-forgot.html new file mode 100644 index 00000000..bf8ca548 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/user-password-forgot.html @@ -0,0 +1,389 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{PASSWORD_FORGOT_MATCH_1}} +
+ {{PASSWORD_FORGOT_MATCH_2}} +
+ + + + +
+ + + + + + + + + + +
+ {{PASSWORD_FORGOT_MATCH_3}} +
+ {{PASSWORD_FORGOT_MATCH_4}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/user-signup.html b/version_upgrades/4.1.3/data/mail-templates/user-signup.html new file mode 100644 index 00000000..6a976373 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/user-signup.html @@ -0,0 +1,389 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{USER_SIGNUP_MATCH_1}} +
+ {{USER_SIGNUP_MATCH_2}} +
+ + + + +
+ + + + + + + + + + +
+ {{USER_SIGNUP_MATCH_3}} +
+ {{USER_SIGNUP_MATCH_4}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/user-system-disabled.html b/version_upgrades/4.1.3/data/mail-templates/user-system-disabled.html new file mode 100644 index 00000000..9d860c10 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/user-system-disabled.html @@ -0,0 +1,389 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{USER_SYSTEM_DISABLED_MATCH_1}} +
+ {{USER_SYSTEM_DISABLED_MATCH_2}} +
+ + + + +
+ + + + + + + + + + +
+ {{USER_SYSTEM_DISABLED_MATCH_3}} +
+ {{USER_SYSTEM_DISABLED_MATCH_4}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/4.1.3/data/mail-templates/user-system-enabled.html b/version_upgrades/4.1.3/data/mail-templates/user-system-enabled.html new file mode 100644 index 00000000..8a5b64a3 --- /dev/null +++ b/version_upgrades/4.1.3/data/mail-templates/user-system-enabled.html @@ -0,0 +1,389 @@ + + + + + + Support Center + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ logo +
+
+ +
+
+
+
+ + + + + + + + + + +
+ {{USER_SYSTEM_ENABLED_MATCH_1}} +
+ {{USER_SYSTEM_ENABLED_MATCH_2}} +
+ + + + +
+ + + + + + + + + + +
+ {{USER_SYSTEM_ENABLED_MATCH_3}} +
+ {{USER_SYSTEM_ENABLED_MATCH_4}} +
+ +
+
+
+
+
+
+ + + + +
+ OpenSupports
+ Open source ticket system
+ www.opensupports.com

+
+
+
+ + diff --git a/version_upgrades/mysql_connect.php b/version_upgrades/mysql_connect.php index cab2fbbb..acb06d98 100644 --- a/version_upgrades/mysql_connect.php +++ b/version_upgrades/mysql_connect.php @@ -1,11 +1,11 @@