jdarwood007 commited on 2016-10-22 20:30:04
Showing 12 changed files, with 304 additions and 117 deletions.
Signed-off-by: jdarwood007 <unmonitored+github@sleepycode.com>
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
# An advanced help desk modifcation built on SMF # |
6 | 6 |
########################################################### |
7 | 7 |
# # |
8 |
-# * Copyright 2015 - SimpleDesk.net # |
|
8 |
+# * Copyright 2016 - SimpleDesk.net # |
|
9 | 9 |
# # |
10 | 10 |
# This file and its contents are subject to the license # |
11 | 11 |
# included with this distribution, license.txt, which # |
... | ... |
@@ -31,7 +31,71 @@ |
31 | 31 |
/** |
32 | 32 |
* Before attempting to execute, this file attempts to load SSI.php to enable access to the database functions. |
33 | 33 |
*/ |
34 |
+global $modSettings, $smcFunc, $txt; |
|
35 |
+sd_initialize_install(); |
|
34 | 36 |
|
37 |
+// Update mod settings if applicable |
|
38 |
+foreach (sd_get_install_modSettings() as $new_setting => $new_value) |
|
39 |
+{ |
|
40 |
+ if (empty($modSettings[$new_setting])) |
|
41 |
+ updateSettings(array($new_setting => $new_value)); |
|
42 |
+} |
|
43 |
+ |
|
44 |
+// Create new tables, if any |
|
45 |
+foreach (sd_get_install_tables() as $table) |
|
46 |
+{ |
|
47 |
+ $smcFunc['db_create_table']($table['table_name'], $table['columns'], $table['indexes'], $table['parameters'], $table['if_exists'], $table['error']); |
|
48 |
+ |
|
49 |
+ // Because of issues with SMF at least in 2.0 RC5, users coming from older installs may not have all columns as if_exists => update doesn't appear to work. |
|
50 |
+ // So, for every column, add it to the columns addition - and let SMF deal with it that way. |
|
51 |
+ foreach ($table['columns'] as $table_info) |
|
52 |
+ $columns[] = array( |
|
53 |
+ 'table_name' => $table['table_name'], |
|
54 |
+ 'column_info' => $table_info, |
|
55 |
+ 'parameters' => array(), |
|
56 |
+ 'if_exists' => 'ignore', |
|
57 |
+ 'error' => 'fatal', |
|
58 |
+ ); |
|
59 |
+} |
|
60 |
+ |
|
61 |
+// Another row we might want to add is package server. Except we may have to remove a pre-existing plugins one, because the version may be wrong. |
|
62 |
+$query = $smcFunc['db_query']('', ' |
|
63 |
+ DELETE FROM {db_prefix}package_servers |
|
64 |
+ WHERE url LIKE {string:plugins}', |
|
65 |
+ array( |
|
66 |
+ 'plugins' => 'http://www.simpledesk.net/download%', |
|
67 |
+ ) |
|
68 |
+); |
|
69 |
+ |
|
70 |
+// Create new rows, if any |
|
71 |
+foreach (sd_get_install_rows() as $row) |
|
72 |
+ $smcFunc['db_insert']($row['method'], $row['table_name'], $row['columns'], $row['data'], $row['keys']); |
|
73 |
+ |
|
74 |
+// Create new columns, if any |
|
75 |
+foreach (sd_get_install_columns() as $column) |
|
76 |
+ $smcFunc['db_add_column']($column['table_name'], $column['column_info'], $column['parameters'], $column['if_exists'], $column['error']); |
|
77 |
+ |
|
78 |
+// Add integration hooks, if any |
|
79 |
+foreach (sd_get_install_hooks() as $hook) |
|
80 |
+ add_integration_function($hook['hook'], $hook['function'], $hook['perm'], !isset($hook['file']) ? '' : $hook['file'], !isset($hook['object']) ? false : $hook['object']); |
|
81 |
+ |
|
82 |
+// SimpleDesk specific, after schema changes |
|
83 |
+sd_upgrade_create_depts(); |
|
84 |
+sd_upgrade_recreate_search(); |
|
85 |
+sd_upgrade_fix_last_updated(); |
|
86 |
+sd_upgrade_convert_serialize(); |
|
87 |
+ |
|
88 |
+// Are we done? |
|
89 |
+if (SMF == 'SSI') |
|
90 |
+ echo 'Database changes are complete!'; |
|
91 |
+ |
|
92 |
+/* |
|
93 |
+ * Sets up the installer |
|
94 |
+ * |
|
95 |
+ * @since 1.0 |
|
96 |
+*/ |
|
97 |
+function sd_initialize_install() |
|
98 |
+{ |
|
35 | 99 |
// If we have found SSI.php and we are outside of SMF, then we are running standalone. |
36 | 100 |
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) |
37 | 101 |
require_once(dirname(__FILE__) . '/SSI.php'); |
... | ... |
@@ -39,29 +103,46 @@ elseif (file_exists(getcwd() . '/SSI.php') && !defined('SMF')) |
39 | 103 |
require_once(getcwd() . '/SSI.php'); |
40 | 104 |
elseif (!defined('SMF')) // If we are outside SMF and can't find SSI.php, then throw an error |
41 | 105 |
die('<b>Error:</b> Cannot install - please verify you put this file in the same place as SMF\'s SSI.php.'); |
42 |
-elseif (@version_compare(PHP_VERSION, '4.3.0', '<')) |
|
43 |
- die('<b>Error:</b> SimpleDesk 2.0 requires PHP 4.3.0 to be installed on your server.'); |
|
106 |
+ elseif (@version_compare(PHP_VERSION, '5.3.8', '<')) |
|
107 |
+ die('<b>Error:</b> SimpleDesk 2.1 requires PHP 5.3.8 to be installed on your server.'); |
|
44 | 108 |
|
45 | 109 |
if (SMF == 'SSI') |
46 | 110 |
db_extend('packages'); |
47 | 111 |
|
48 | 112 |
// We have a lot to do. Make sure as best we can that we have the time to do so. |
49 | 113 |
@set_time_limit(600); |
114 |
+} |
|
50 | 115 |
|
51 |
-global $modSettings, $smcFunc, $txt; |
|
52 |
- |
|
53 |
-// For our BBC settings, we first fetch a list off all BBC tags there are. |
|
116 |
+/* |
|
117 |
+ * Gets a list of bbc tags, we will use this during the install |
|
118 |
+ * |
|
119 |
+ * @since 1.0 |
|
120 |
+*/ |
|
121 |
+function sd_get_bbc_tags() |
|
122 |
+{ |
|
54 | 123 |
$bbc_tags = array(); |
55 | 124 |
foreach (parse_bbc(false) AS $tag) |
56 | 125 |
$bbc_tags[] = $tag['tag']; |
57 | 126 |
|
127 |
+ return $bbc_tags; |
|
128 |
+} |
|
129 |
+ |
|
130 |
+/* |
|
131 |
+ * New modSettings |
|
132 |
+ * |
|
133 |
+ * @since 1.0 |
|
134 |
+*/ |
|
135 |
+function sd_get_install_modSettings($getAll = false) |
|
136 |
+{ |
|
137 |
+ global $modSettings; |
|
138 |
+ |
|
58 | 139 |
// Here we will update the $modSettings variables. |
59 | 140 |
$mod_settings = array(); |
60 | 141 |
$new_settings = array( |
61 | 142 |
'shd_attachments_mode' => 'ticket', |
62 | 143 |
'shd_staff_badge' => 'nobadge', |
63 | 144 |
'shd_ticketnav_style' => 'sd', |
64 |
- 'shd_enabled_bbc' => implode(',', $bbc_tags), // By default, all available tags are enabled. |
|
145 |
+ 'shd_enabled_bbc' => implode(',', sd_get_bbc_tags()), // By default, all available tags are enabled. |
|
65 | 146 |
'shd_privacy_display' => 'smart', |
66 | 147 |
'shd_allow_wikilinks' => 1, |
67 | 148 |
'shd_display_ticket_logs' => 1, |
... | ... |
@@ -92,13 +173,86 @@ $new_settings = array( |
92 | 173 |
'shd_notify_assign_own' => 1, |
93 | 174 |
); |
94 | 175 |
|
176 |
+ if ($getAll) |
|
177 |
+ return $new_settings; |
|
178 |
+ |
|
95 | 179 |
foreach ($new_settings as $k => $v) |
96 | 180 |
if (!isset($modSettings[$k])) |
97 | 181 |
$mod_settings[$k] = $v; |
98 |
-// Anything that shouldn't be set by default won't be in the list. Note that the check is made to isset not empty, because empty values are pre-existing off values, which are not purged from the DB. |
|
99 | 182 |
|
183 |
+ return $mod_settings; |
|
184 |
+} |
|
185 |
+ |
|
186 |
+/* |
|
187 |
+ * All the rows we need to add. |
|
188 |
+ * Anything that shouldn't be set by default won't be in the list. Note that the check is made to isset not empty, because empty values are pre-existing off values, which are not purged from the DB. |
|
189 |
+ * |
|
190 |
+ * @since 1.0 |
|
191 |
+*/ |
|
192 |
+function sd_get_install_rows() |
|
193 |
+{ |
|
194 |
+ $rows = array(); |
|
195 |
+ $rows[] = array( |
|
196 |
+ 'method' => 'replace', |
|
197 |
+ 'table_name' => '{db_prefix}scheduled_tasks', |
|
198 |
+ 'columns' => array( |
|
199 |
+ 'next_time' => 'int', |
|
200 |
+ 'time_offset' => 'int', |
|
201 |
+ 'time_regularity' => 'int', |
|
202 |
+ 'time_unit' => 'string', |
|
203 |
+ 'disabled' => 'int', |
|
204 |
+ 'task' => 'string', |
|
205 |
+ ), |
|
206 |
+ 'data' => array( |
|
207 |
+ strtotime('tomorrow'), |
|
208 |
+ 0, |
|
209 |
+ 1, |
|
210 |
+ 'd', |
|
211 |
+ 0, |
|
212 |
+ 'simpledesk', |
|
213 |
+ ), |
|
214 |
+ 'keys' => array('task'), |
|
215 |
+ ); |
|
216 |
+ |
|
217 |
+ $rows[] = array( |
|
218 |
+ 'method' => 'insert', |
|
219 |
+ 'table_name' => '{db_prefix}package_servers', |
|
220 |
+ 'columns' => array( |
|
221 |
+ 'name' => 'string', |
|
222 |
+ 'url' => 'string', |
|
223 |
+ ), |
|
224 |
+ 'data' => array( |
|
225 |
+ 'SimpleDesk Plugins', |
|
226 |
+ 'http://www.simpledesk.net/download/plugins/2.0', // !!! This should be updated in later releases! |
|
227 |
+ ), |
|
228 |
+ 'keys' => array('id_server'), |
|
229 |
+ ); |
|
230 |
+ |
|
231 |
+ return $rows; |
|
232 |
+} |
|
233 |
+ |
|
234 |
+/* |
|
235 |
+ * All the columns we need to add to any existing tables. |
|
236 |
+ * |
|
237 |
+ * @since 1.0 |
|
238 |
+*/ |
|
239 |
+function sd_get_install_columns() |
|
240 |
+{ |
|
241 |
+ $columns = array(); |
|
242 |
+ |
|
243 |
+ return $columns; |
|
244 |
+} |
|
245 |
+ |
|
246 |
+/* |
|
247 |
+ * Gets a list of all the hooks we need during install |
|
248 |
+ * |
|
249 |
+ * @since 1.0 |
|
250 |
+*/ |
|
251 |
+function sd_get_install_hooks() |
|
252 |
+{ |
|
100 | 253 |
// Hook references to be added. |
101 | 254 |
$hooks = array(); |
255 |
+ |
|
102 | 256 |
// SMF Core stuff |
103 | 257 |
$hooks[] = array( |
104 | 258 |
'hook' => 'integrate_pre_include', |
... | ... |
@@ -264,11 +423,23 @@ $hooks = array(); |
264 | 423 |
// Other |
265 | 424 |
$hooks[] = array( |
266 | 425 |
'hook' => 'integrate_SSI', |
267 |
- 'function' => 'ssi_shd_called', |
|
426 |
+ 'function' => false, |
|
268 | 427 |
'file' => '$sourcedir/sd_source/SimpleDesk-SSI.php', |
269 | 428 |
'perm' => true, |
270 | 429 |
); |
271 | 430 |
|
431 |
+ return $hooks; |
|
432 |
+} |
|
433 |
+ |
|
434 |
+/* |
|
435 |
+ * Gets a list of all the tables we need to install SimpleDesk |
|
436 |
+ * |
|
437 |
+ * @since 1.0 |
|
438 |
+*/ |
|
439 |
+function sd_get_install_tables() |
|
440 |
+{ |
|
441 |
+ global $modSettings; |
|
442 |
+ |
|
272 | 443 |
// Now, we move on to adding new tables to the database. |
273 | 444 |
$tables = array(); |
274 | 445 |
$tables[] = array( |
... | ... |
@@ -352,7 +523,7 @@ $tables[] = array( |
352 | 523 |
db_field('action', 'varchar', 30), // defines the message to use |
353 | 524 |
db_field('id_ticket', 'mediumint'), // ticket it applies to |
354 | 525 |
db_field('id_msg', 'int'), // msg it applies to |
355 |
- db_field('extra', 'mediumtext') // serialised array of params for log message |
|
526 |
+ db_field('extra', 'mediumtext') // json array of params for log message |
|
356 | 527 |
), |
357 | 528 |
'indexes' => array( |
358 | 529 |
array( |
... | ... |
@@ -697,94 +868,21 @@ $tables[] = array( |
697 | 868 |
'parameters' => array(), |
698 | 869 |
); |
699 | 870 |
|
700 |
-// Oh joy, we've now made it to extra rows... |
|
701 |
-$rows = array(); |
|
702 |
-$rows[] = array( |
|
703 |
- 'method' => 'replace', |
|
704 |
- 'table_name' => '{db_prefix}scheduled_tasks', |
|
705 |
- 'columns' => array( |
|
706 |
- 'next_time' => 'int', |
|
707 |
- 'time_offset' => 'int', |
|
708 |
- 'time_regularity' => 'int', |
|
709 |
- 'time_unit' => 'string', |
|
710 |
- 'disabled' => 'int', |
|
711 |
- 'task' => 'string', |
|
712 |
- ), |
|
713 |
- 'data' => array( |
|
714 |
- strtotime('tomorrow'), |
|
715 |
- 0, |
|
716 |
- 1, |
|
717 |
- 'd', |
|
718 |
- 0, |
|
719 |
- 'simpledesk', |
|
720 |
- ), |
|
721 |
- 'keys' => array('task'), |
|
722 |
-); |
|
723 |
-// Another row we might want to add is package server. Except we may have to remove a pre-existing plugins one, because the version may be wrong. |
|
724 |
-$query = $smcFunc['db_query']('', ' |
|
725 |
- DELETE FROM {db_prefix}package_servers |
|
726 |
- WHERE url LIKE {string:plugins}', |
|
727 |
- array( |
|
728 |
- 'plugins' => 'http://www.simpledesk.net/download%', |
|
729 |
- ) |
|
730 |
-); |
|
731 |
-$rows[] = array( |
|
732 |
- 'method' => 'insert', |
|
733 |
- 'table_name' => '{db_prefix}package_servers', |
|
734 |
- 'columns' => array( |
|
735 |
- 'name' => 'string', |
|
736 |
- 'url' => 'string', |
|
737 |
- ), |
|
738 |
- 'data' => array( |
|
739 |
- 'SimpleDesk Plugins', |
|
740 |
- 'http://www.simpledesk.net/download/plugins/2.0', // !!! This should be updated in later releases! |
|
741 |
- ), |
|
742 |
- 'keys' => array('id_server'), |
|
743 |
-); |
|
744 |
- |
|
745 |
-// Now we can add a new column to an existing table |
|
746 |
-$columns = array(); |
|
747 |
- |
|
748 |
-// Update mod settings if applicable |
|
749 |
-foreach ($mod_settings as $new_setting => $new_value) |
|
750 |
-{ |
|
751 |
- if (empty($modSettings[$new_setting])) |
|
752 |
- updateSettings(array($new_setting => $new_value)); |
|
871 |
+ return $tables; |
|
753 | 872 |
} |
754 | 873 |
|
755 |
-// Create new tables, if any |
|
756 |
-foreach ($tables as $table) |
|
874 |
+/* |
|
875 |
+ * If this is an upgraded 1.0 installation, we won't have any departments. Make sure we create one, if possible using the right language strings |
|
876 |
+ * |
|
877 |
+ * @since 2.0 |
|
878 |
+*/ |
|
879 |
+function sd_upgrade_create_depts() |
|
757 | 880 |
{ |
758 |
- $smcFunc['db_create_table']($table['table_name'], $table['columns'], $table['indexes'], $table['parameters'], $table['if_exists'], $table['error']); |
|
759 |
- |
|
760 |
- // Because of issues with SMF at least in 2.0 RC5, users coming from older installs may not have all columns as if_exists => update doesn't appear to work. |
|
761 |
- // So, for every column, add it to the columns addition - and let SMF deal with it that way. |
|
762 |
- foreach ($table['columns'] as $table_info) |
|
763 |
- $columns[] = array( |
|
764 |
- 'table_name' => $table['table_name'], |
|
765 |
- 'column_info' => $table_info, |
|
766 |
- 'parameters' => array(), |
|
767 |
- 'if_exists' => 'ignore', |
|
768 |
- 'error' => 'fatal', |
|
769 |
- ); |
|
770 |
-} |
|
881 |
+ global $smcFunc, $txt; |
|
771 | 882 |
|
772 |
-// Create new rows, if any |
|
773 |
-foreach ($rows as $row) |
|
774 |
- $smcFunc['db_insert']($row['method'], $row['table_name'], $row['columns'], $row['data'], $row['keys']); |
|
775 |
- |
|
776 |
-// Create new columns, if any |
|
777 |
-foreach ($columns as $column) |
|
778 |
- $smcFunc['db_add_column']($column['table_name'], $column['column_info'], $column['parameters'], $column['if_exists'], $column['error']); |
|
779 |
- |
|
780 |
-// Add integration hooks, if any |
|
781 |
-foreach ($hooks as $hook) |
|
782 |
- add_integration_function($hook['hook'], $hook['function'], $hook['perm'], !isset($hook['file']) ? '' : $hook['file'], !isset($hook['object']) ? false : $hook['object']); |
|
783 |
- |
|
784 |
-// SimpleDesk specific, after schema changes |
|
785 |
-// If this is an upgraded 1.0 installation, we won't have any departments. Make sure we create one, if possible using the right language strings. |
|
786 | 883 |
loadLanguage('SimpleDesk', 'english', false); |
787 | 884 |
loadLanguage('SimpleDesk', '', false); |
885 |
+ |
|
788 | 886 |
$query = $smcFunc['db_query']('', 'SELECT COUNT(*) FROM {db_prefix}helpdesk_depts'); |
789 | 887 |
list($count) = $smcFunc['db_fetch_row']($query); |
790 | 888 |
$smcFunc['db_free_result']($query); |
... | ... |
@@ -818,23 +916,43 @@ if (!empty($new_dept)) |
818 | 916 |
) |
819 | 917 |
); |
820 | 918 |
} |
919 |
+} |
|
920 |
+ |
|
921 |
+/* |
|
922 |
+ * Recreate the search index |
|
923 |
+ * |
|
924 |
+ * @since 2.0 |
|
925 |
+*/ |
|
926 |
+function sd_upgrade_recreate_search() |
|
927 |
+{ |
|
928 |
+ global $smcFunc; |
|
821 | 929 |
|
822 |
-// Do we need to flag that a new search index is needed? If there are any pre-existing tickets, we will... |
|
823 | 930 |
$query = $smcFunc['db_query']('', 'SELECT COUNT(*) FROM {db_prefix}helpdesk_tickets'); |
824 | 931 |
list($count) = $smcFunc['db_fetch_row']($query); |
825 | 932 |
if (!empty($count)) |
826 | 933 |
updateSettings(array('shd_new_search_index' => 1)); |
934 |
+} |
|
935 |
+ |
|
936 |
+/* |
|
937 |
+ * If we're updating an existing install, we need to make sure there is a normalised value in the last_updated column. |
|
938 |
+ * |
|
939 |
+ * @since 2.0 |
|
940 |
+*/ |
|
941 |
+function sd_upgrade_fix_last_updated() |
|
942 |
+{ |
|
943 |
+ global $smcFunc; |
|
827 | 944 |
|
828 |
-// If we're updating an existing install, we need to make sure there is a normalised value in the last_updated column. |
|
829 | 945 |
$smcFunc['db_query']('', ' |
830 | 946 |
UPDATE {db_prefix}helpdesk_tickets AS hdt, {db_prefix}helpdesk_ticket_replies AS hdtr |
831 | 947 |
SET hdt.last_updated = hdtr.poster_time |
832 | 948 |
WHERE hdt.id_last_msg = hdtr.id_msg AND hdt.last_updated = 0'); |
949 |
+} |
|
833 | 950 |
|
834 |
-// Are we done? |
|
835 |
-if (SMF == 'SSI') |
|
836 |
- echo 'Database changes are complete!'; |
|
837 |
- |
|
951 |
+/* |
|
952 |
+ * Calculates the proper settings to use in a column. |
|
953 |
+ * |
|
954 |
+ * @since 1.0 |
|
955 |
+*/ |
|
838 | 956 |
function db_field($name, $type, $size = 0, $unsigned = true, $auto = false) |
839 | 957 |
{ |
840 | 958 |
$fields = array( |
... | ... |
@@ -901,3 +1019,71 @@ function db_field($name, $type, $size = 0, $unsigned = true, $auto = false) |
901 | 1019 |
|
902 | 1020 |
return $field; |
903 | 1021 |
} |
1022 |
+ |
|
1023 |
+/* |
|
1024 |
+ * Converts Seralized to JSON |
|
1025 |
+*/ |
|
1026 |
+function sd_upgrade_convert_serialize() |
|
1027 |
+{ |
|
1028 |
+ global $smcFunc; |
|
1029 |
+ |
|
1030 |
+ $seralizeSettings = array(); |
|
1031 |
+ |
|
1032 |
+ // The log actions. |
|
1033 |
+ $seralizeSettings[] = array( |
|
1034 |
+ 'table' => 'helpdesk_log_action', |
|
1035 |
+ 'id' => 'id_action', |
|
1036 |
+ 'column' => 'extra', |
|
1037 |
+ ); |
|
1038 |
+ |
|
1039 |
+ // The log actions. |
|
1040 |
+ $seralizeSettings[] = array( |
|
1041 |
+ 'table' => 'helpdesk_custom_fields', |
|
1042 |
+ 'id' => 'id_field', |
|
1043 |
+ 'column' => 'field_options', |
|
1044 |
+ ); |
|
1045 |
+ |
|
1046 |
+ |
|
1047 |
+ // Run the upgrader. |
|
1048 |
+ foreach ($seralizeSettings as $tempID => $data) |
|
1049 |
+ { |
|
1050 |
+ $request = $smcFunc['db_query']('', ' |
|
1051 |
+ SELECT {raw:idColumn} AS rowID, {raw:valueColumn} AS rowValue |
|
1052 |
+ FROM {db_prefix}{raw:table} |
|
1053 |
+ WHERE {raw:valueColumn} LIKE {string:findSerialize} AND {raw:valueColumn} NOT LIKE {string:findJSON}', |
|
1054 |
+ array( |
|
1055 |
+ 'idColumn' => $data['id'], |
|
1056 |
+ 'valueColumn' => $data['column'], |
|
1057 |
+ 'table' => $data['table'], |
|
1058 |
+ 'findSerialize' => 'a:%', |
|
1059 |
+ 'findJSON' => '{%', |
|
1060 |
+ ) |
|
1061 |
+ ); |
|
1062 |
+ while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1063 |
+ { |
|
1064 |
+ $temp = @safe_unserialize($row['rowValue']); |
|
1065 |
+ |
|
1066 |
+ if ($temp !== false) |
|
1067 |
+ { |
|
1068 |
+ $newValue = json_encode($temp); |
|
1069 |
+ |
|
1070 |
+ $smcFunc['db_query']('', ' |
|
1071 |
+ UPDATE {db_prefix}{raw:table} |
|
1072 |
+ SET {raw:valueColumn} = {string:rowValue} |
|
1073 |
+ WHERE {raw:idColumn} = {int:rowID}', |
|
1074 |
+ array( |
|
1075 |
+ 'table' => $data['table'], |
|
1076 |
+ |
|
1077 |
+ 'valueColumn' => $data['column'], |
|
1078 |
+ 'rowValue' => $newValue, |
|
1079 |
+ |
|
1080 |
+ 'idColumn' => $data['id'], |
|
1081 |
+ 'rowID' => $row['rowID'], |
|
1082 |
+ ) |
|
1083 |
+ ); |
|
1084 |
+ } |
|
1085 |
+ } |
|
1086 |
+ $smcFunc['db_free_result']($request); |
|
1087 |
+ |
|
1088 |
+ } |
|
1089 |
+} |
|
904 | 1090 |
\ No newline at end of file |
... | ... |
@@ -170,7 +170,7 @@ function shd_admin_custom_edit() |
170 | 170 |
$context['section_desc'] = $txt['shd_admin_edit_custom_field_desc']; |
171 | 171 |
$context['page_title'] = $txt['shd_admin_edit_custom_field']; |
172 | 172 |
$context['sub_template'] = 'shd_custom_field_edit'; |
173 |
- $context['custom_field']['options'] = !empty($row['field_options']) ? unserialize($row['field_options']) : array(1 => '', '', ''); |
|
173 |
+ $context['custom_field']['options'] = !empty($row['field_options']) ? smf_json_decode($row['field_options'], true) : array(1 => '', '', ''); |
|
174 | 174 |
if (empty($context['custom_field']['options']['inactive'])) |
175 | 175 |
$context['custom_field']['options']['inactive'] = array(); |
176 | 176 |
|
... | ... |
@@ -392,7 +392,7 @@ function shd_admin_custom_save() |
392 | 392 |
if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
393 | 393 |
$_POST['default_check'] = $k; |
394 | 394 |
} |
395 |
- $options = serialize($newOptions); |
|
395 |
+ $options = json_encode($newOptions); |
|
396 | 396 |
} |
397 | 397 |
|
398 | 398 |
// Sort out the default selection if it's a multi-select, as well as required amounts |
... | ... |
@@ -503,7 +503,7 @@ function shd_admin_custom_save() |
503 | 503 |
// Depending on the field type, we may need to be funky about overlaying things, hence grabbing the old options. |
504 | 504 |
if (!empty($row['field_options']) && in_array($row['field_type'], array(CFIELD_TYPE_SELECT, CFIELD_TYPE_RADIO, CFIELD_TYPE_MULTI))) |
505 | 505 |
{ |
506 |
- $row['field_options'] = unserialize($row['field_options']); |
|
506 |
+ $row['field_options'] = smf_json_decode($row['field_options'], true); |
|
507 | 507 |
ksort($row['field_options']); |
508 | 508 |
ksort($newOptions); |
509 | 509 |
$inactive = array(); |
... | ... |
@@ -521,7 +521,7 @@ function shd_admin_custom_save() |
521 | 521 |
foreach ($newOptions as $k => $v) |
522 | 522 |
$new_fields[$k] = $v; |
523 | 523 |
$new_fields['inactive'] = $inactive; |
524 |
- $options = serialize($new_fields); |
|
524 |
+ $options = json_encode($new_fields); |
|
525 | 525 |
} |
526 | 526 |
|
527 | 527 |
shd_db_query('', ' |
... | ... |
@@ -400,7 +400,7 @@ function shd_view_ticket() |
400 | 400 |
'icon' => $row['icon'], |
401 | 401 |
'type' => $row['field_type'], |
402 | 402 |
'default_value' => $row['field_type'] == CFIELD_TYPE_LARGETEXT ? explode(',', $row['default_value']) : $row['default_value'], |
403 |
- 'options' => !empty($row['field_options']) ? unserialize($row['field_options']) : array(), |
|
403 |
+ 'options' => !empty($row['field_options']) ? smf_json_decode($row['field_options'], true) : array(), |
|
404 | 404 |
'display_empty' => !empty($row['required']) ? true : !empty($row['display_empty']), // Required and "selection" fields will always be displayed. |
405 | 405 |
'bbc' => !empty($row['bbc']) && ($row['field_type'] == CFIELD_TYPE_TEXT || $row['field_type'] == CFIELD_TYPE_LARGETEXT) && $row['placement'] != CFIELD_PLACE_PREFIX, |
406 | 406 |
'editable' => !empty($editable), |
... | ... |
@@ -461,7 +461,7 @@ function shd_notify_users($notify_data) |
461 | 461 |
'log_time' => 'int', 'id_member' => 'int', 'ip' => 'string-16', 'action' => 'string', 'id_ticket' => 'int', 'id_msg' => 'int', 'extra' => 'string-65534', |
462 | 462 |
), |
463 | 463 |
array( |
464 |
- time(), 0, '', 'notify', $notify_data['ticket'], !empty($notify_data['msg']) ? $notify_data['msg'] : 0, serialize($log), |
|
464 |
+ time(), 0, '', 'notify', $notify_data['ticket'], !empty($notify_data['msg']) ? $notify_data['msg'] : 0, json_encode($log), |
|
465 | 465 |
), |
466 | 466 |
array('id_action') |
467 | 467 |
); |
... | ... |
@@ -506,7 +506,7 @@ function shd_notify_popup() |
506 | 506 |
$row = $smcFunc['db_fetch_assoc']($query); |
507 | 507 |
$smcFunc['db_free_result']($query); |
508 | 508 |
|
509 |
- $row['extra'] = unserialize($row['extra']); |
|
509 |
+ $row['extra'] = smf_json_decode($row['extra'], true); |
|
510 | 510 |
|
511 | 511 |
// Just check we did actually log an email of that type. |
512 | 512 |
if (empty($row['extra']['emails'][$_GET['template']])) |
... | ... |
@@ -109,7 +109,7 @@ function shd_scheduled_close_tickets() |
109 | 109 |
'autoclose', // action |
110 | 110 |
$ticket, // id_ticket |
111 | 111 |
0, // id_msg |
112 |
- serialize(array( |
|
112 |
+ json_encode(array( |
|
113 | 113 |
'subject' => $subjects[$ticket], |
114 | 114 |
'auto' => true, // indicate to the action log that this is the case |
115 | 115 |
)), |
... | ... |
@@ -228,11 +228,11 @@ function shd_search2() |
228 | 228 |
spamProtection('search'); |
229 | 229 |
else |
230 | 230 |
{ |
231 |
- list($temp_clauses, $temp_params, $temp_terms) = unserialize($_SESSION['lastsearch']); |
|
231 |
+ list($temp_clauses, $temp_params, $temp_terms) = smf_json_decode($_SESSION['lastsearch'], true); |
|
232 | 232 |
if ($temp_clauses != $context['search_clauses'] || $temp_params != $context['search_params'] || $temp_terms != $context['search_terms']) |
233 | 233 |
spamProtection('search'); |
234 | 234 |
} |
235 |
- $_SESSION['lastsearch'] = serialize(array($context['search_clauses'], $context['search_params'], $context['search_terms'])); |
|
235 |
+ $_SESSION['lastsearch'] = json_encode(array($context['search_clauses'], $context['search_params'], $context['search_terms'])); |
|
236 | 236 |
|
237 | 237 |
$context['search_params']['start'] = ($context['pagenum'] - 1) * $number_per_page; |
238 | 238 |
$context['search_params']['limit'] = $number_per_page; |
... | ... |
@@ -388,7 +388,7 @@ function shd_tickettotopic2() |
388 | 388 |
'name' => $row['field_name'], |
389 | 389 |
'type' => $row['field_type'], |
390 | 390 |
'bbc' => !empty($row['bbc']), |
391 |
- 'options' => !empty($row['field_options']) ? unserialize($row['field_options']) : array(), |
|
391 |
+ 'options' => !empty($row['field_options']) ? smf_json_decode($row['field_options'], true) : array(), |
|
392 | 392 |
'placement' => $row['placement'], |
393 | 393 |
'visible' => array( |
394 | 394 |
'user' => $user_see, |
... | ... |
@@ -1150,7 +1150,7 @@ function shd_helpdesk_listing() |
1150 | 1150 |
{ |
1151 | 1151 |
if (!empty($row['field_options'])) |
1152 | 1152 |
{ |
1153 |
- $row['field_options'] = unserialize($row['field_options']); |
|
1153 |
+ $row['field_options'] = smf_json_decode($row['field_options'], true); |
|
1154 | 1154 |
if (isset($row['field_options']['inactive'])) |
1155 | 1155 |
unset($row['field_options']['inactive']); |
1156 | 1156 |
foreach ($row['field_options'] as $k => $v) |
... | ... |
@@ -528,7 +528,7 @@ function shd_log_action($action, $params, $do_last_update = true) |
528 | 528 |
'log_time' => 'int', 'id_member' => 'int', 'ip' => 'string-16', 'action' => 'string', 'id_ticket' => 'int', 'id_msg' => 'int', 'extra' => 'string-65534', |
529 | 529 |
), |
530 | 530 |
array( |
531 |
- time(), $user_info['id'], $user_info['ip'], $action, $ticket_id, $msg_id, serialize($params), |
|
531 |
+ time(), $user_info['id'], $user_info['ip'], $action, $ticket_id, $msg_id, json_encode($params), |
|
532 | 532 |
), |
533 | 533 |
array('id_action') |
534 | 534 |
); |
... | ... |
@@ -1668,7 +1668,7 @@ function shd_init_actions(&$actionArray) |
1668 | 1668 |
* |
1669 | 1669 |
* @since 2.0 |
1670 | 1670 |
*/ |
1671 |
-function shd_buffer_replace(&$buffer) |
|
1671 |
+function shd_buffer_replace($buffer) |
|
1672 | 1672 |
{ |
1673 | 1673 |
global $modSettings, $context; |
1674 | 1674 |
|
... | ... |
@@ -114,7 +114,7 @@ function shd_load_action_log_entries($start = 0, $items_per_page = 10, $sort = ' |
114 | 114 |
$notify_members = array(); |
115 | 115 |
while ($row = $smcFunc['db_fetch_assoc']($request)) |
116 | 116 |
{ |
117 |
- $row['extra'] = @unserialize($row['extra']); |
|
117 |
+ $row['extra'] = smf_json_decode($row['extra'], true); |
|
118 | 118 |
$row['extra'] = is_array($row['extra']) ? $row['extra'] : array(); |
119 | 119 |
|
120 | 120 |
// Uhoh, we don't know who this is! Check it's not automatically by the system. If it is... mark it so. |
... | ... |
@@ -188,7 +188,7 @@ function shd_load_action_log_entries($start = 0, $items_per_page = 10, $sort = ' |
188 | 188 |
// Notifications are pretty tricky. So let's take care of all of it at once, and skip the rest if we're doing that. |
189 | 189 |
if ($action['action'] == 'notify' && isset($action['extra']['emails'])) |
190 | 190 |
{ |
191 |
- // Because this could be a lot of people etc., we compact its storage heavily compared to a conventional serialize(). |
|
191 |
+ // Because this could be a lot of people etc., we compact its storage heavily compared to a conventional smf_json_decode(). |
|
192 | 192 |
// See shd_notify_users in SimpleDesk-Notifications.php for what this is. |
193 | 193 |
|
194 | 194 |
// Now we have all the usernames for this instance, let's go and build this entry. |
... | ... |
@@ -812,7 +812,7 @@ function shd_load_custom_fields($is_ticket = true, $ticketContext = 0, $dept = 0 |
812 | 812 |
'name' => $row['field_name'], |
813 | 813 |
'desc' => parse_bbc($row['field_desc'], false), |
814 | 814 |
'icon' => $row['icon'], |
815 |
- 'options' => !empty($row['field_options']) ? unserialize($row['field_options']) : array(), |
|
815 |
+ 'options' => !empty($row['field_options']) ? smf_json_decode($row['field_options'], true) : array(), |
|
816 | 816 |
'type' => $row['field_type'], |
817 | 817 |
'default_value' => $row['field_type'] == CFIELD_TYPE_LARGETEXT ? explode(',', $row['default_value']) : $row['default_value'], |
818 | 818 |
'display_empty' => !empty($row['required']) ? 1 : $row['display_empty'], // Required and "selection" fields will always be displayed. |
819 | 819 |