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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{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 @@