jdarwood007 commited on 2019-12-24 08:03:03
Showing 6 changed files, with 358 additions and 308 deletions.
... | ... |
@@ -0,0 +1,206 @@ |
1 |
+<?php |
|
2 |
+global $modSettings; |
|
3 |
+ |
|
4 |
+/** |
|
5 |
+ * The Main class for Add to Existing Ban Group |
|
6 |
+ * @package A2EBG |
|
7 |
+ * @author SleePy <sleepy @ simplemachines (dot) org> |
|
8 |
+ * @copyright 2019 |
|
9 |
+ * @license 3-Clause BSD https://opensource.org/licenses/BSD-3-Clause |
|
10 |
+ * @version 2.0 |
|
11 |
+ */ |
|
12 |
+class a2ebg |
|
13 |
+{ |
|
14 |
+ public static function loadLanguage() |
|
15 |
+ { |
|
16 |
+ loadLanguage('Add2ExistingBanGroup'); |
|
17 |
+ } |
|
18 |
+ |
|
19 |
+ public static function hook_general_mod_settings(&$config_vars) |
|
20 |
+ { |
|
21 |
+ global $txt; |
|
22 |
+ |
|
23 |
+ self::loadLanguage(); |
|
24 |
+ |
|
25 |
+ $config_vars[] = array( |
|
26 |
+ 'select', 'aebg_auto_select', |
|
27 |
+ array('main_ip_check' => $txt['ban_on_ip'], 'hostname_check' => $txt['ban_on_hostname'], 'email_check' => $txt['ban_on_email'], 'user_check' => $txt['ban_on_username']), |
|
28 |
+ 'multiple' => true, |
|
29 |
+ ); |
|
30 |
+ } |
|
31 |
+ |
|
32 |
+ // This is called when we edit a ban regardless of if its new or not. |
|
33 |
+ // This also gets called during saving the edit and we do some work here. |
|
34 |
+ public static function hook_edit_bans(&$ban_info, $isNew) |
|
35 |
+ { |
|
36 |
+ global $context, $smcFunc; |
|
37 |
+ |
|
38 |
+ $ban_info['easy_ban_group'] = empty($_POST['easy_ban_group']) ? '0' : '1'; |
|
39 |
+ |
|
40 |
+ // We are adding or modifying a ban normally. |
|
41 |
+ if (empty($_POST['ban_group'])) |
|
42 |
+ { |
|
43 |
+ if (!empty($_POST['bg'])) |
|
44 |
+ { |
|
45 |
+ $request = $smcFunc['db_query']('', ' |
|
46 |
+ SELECT |
|
47 |
+ bg.id_ban_group, bg.easy_bg |
|
48 |
+ FROM {db_prefix}ban_groups AS bg |
|
49 |
+ WHERE bg.id_ban_group = {int:current_ban}', |
|
50 |
+ array( |
|
51 |
+ 'current_ban' => (int) $_REQUEST['bg'], |
|
52 |
+ ) |
|
53 |
+ ); |
|
54 |
+ $row = $smcFunc['db_fetch_assoc']($request); |
|
55 |
+ $smcFunc['db_free_result']($request); |
|
56 |
+ |
|
57 |
+ $context['ban']['id'] = $row['id_ban_group']; |
|
58 |
+ $context['ban']['easy_bg'] = $row['easy_bg']; |
|
59 |
+ } |
|
60 |
+ else |
|
61 |
+ $context['ban']['easy_bg'] = 0; |
|
62 |
+ |
|
63 |
+ $context['easy_ban_group'] = $ban_info['easy_ban_group']; |
|
64 |
+ return; |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ // This occurs when we are "adding" a ban. |
|
68 |
+ $request = $smcFunc['db_query']('', ' |
|
69 |
+ SELECT |
|
70 |
+ bg.id_ban_group, bg.name, bg.ban_time, COALESCE(bg.expire_time, 0) AS expire_time, bg.reason, bg.notes, bg.cannot_access, bg.cannot_register, bg.cannot_login, bg.cannot_post, bg.easy_bg |
|
71 |
+ FROM {db_prefix}ban_groups AS bg |
|
72 |
+ WHERE bg.id_ban_group = {int:current_ban}', |
|
73 |
+ array( |
|
74 |
+ 'current_ban' => (int) $_REQUEST['ban_group'], |
|
75 |
+ ) |
|
76 |
+ ); |
|
77 |
+ $row = $smcFunc['db_fetch_assoc']($request); |
|
78 |
+ $smcFunc['db_free_result']($request); |
|
79 |
+ |
|
80 |
+ $context['ban'] = array( |
|
81 |
+ 'id' => $row['id_ban_group'], |
|
82 |
+ 'easy_bg' => $row['easy_bg'], |
|
83 |
+ 'name' => $row['name'], |
|
84 |
+ 'expiration' => array( |
|
85 |
+ 'status' => empty($row['expire_time']) ? 'never' : ($row['expire_time'] < time() ? 'expired' : 'one_day'), |
|
86 |
+ 'days' => $row['expire_time'] > time() ? ($row['expire_time'] - time() < 86400 ? 1 : ceil(($row['expire_time'] - time()) / 86400)) : 0 |
|
87 |
+ ), |
|
88 |
+ 'reason' => $row['reason'], |
|
89 |
+ 'notes' => $row['notes'], |
|
90 |
+ 'cannot' => array( |
|
91 |
+ 'access' => !empty($row['cannot_access']), |
|
92 |
+ 'post' => !empty($row['cannot_post']), |
|
93 |
+ 'register' => !empty($row['cannot_register']), |
|
94 |
+ 'login' => !empty($row['cannot_login']), |
|
95 |
+ ), |
|
96 |
+ 'is_new' => false, |
|
97 |
+ 'hostname' => '', |
|
98 |
+ 'email' => '', |
|
99 |
+ ); |
|
100 |
+ |
|
101 |
+ // Setup info for later. |
|
102 |
+ $ban_info = $context['ban']; |
|
103 |
+ $ban_info['db_expiration'] = $ban_info['expiration']['status'] == 'never' ? 'NULL' : ($ban_info['expiration']['status'] == 'one_day' ? time() + 24 * 60 * 60 * $ban_info['expire_date'] : 0); |
|
104 |
+ $ban_info['cannot']['access'] = $ban_info['cannot']['access'] ? 1 : 0; |
|
105 |
+ $ban_info['cannot']['post'] = $ban_info['cannot']['post'] ? 1 : 0; |
|
106 |
+ $ban_info['cannot']['register'] = $ban_info['cannot']['register'] ? 1 : 0; |
|
107 |
+ $ban_info['cannot']['login'] = $ban_info['cannot']['login'] ? 1 : 0; |
|
108 |
+ |
|
109 |
+ // Fake it till you make it. |
|
110 |
+ $_REQUEST['bg'] = $ban_info['id']; |
|
111 |
+ } |
|
112 |
+ |
|
113 |
+ // Called when we edit a existing ban group |
|
114 |
+ public static function hook_ban_edit_list() |
|
115 |
+ { |
|
116 |
+ global $context; |
|
117 |
+ |
|
118 |
+ self::loadLanguage(); |
|
119 |
+ loadTemplate('Add2ExistingBanGroup'); |
|
120 |
+ $context['template_layers'][] = 'easyban_edits'; |
|
121 |
+ } |
|
122 |
+ |
|
123 |
+ // Called when we do a new ban group but not calling with a from user. |
|
124 |
+ public static function hook_ban_edit_new() |
|
125 |
+ { |
|
126 |
+ global $context, $smcFunc, $modSettings; |
|
127 |
+ |
|
128 |
+ self::loadLanguage(); |
|
129 |
+ loadTemplate('Add2ExistingBanGroup'); |
|
130 |
+ |
|
131 |
+ // Normal way of doing a new one? Skip. |
|
132 |
+ if (empty($context['ban']['from_user'])) |
|
133 |
+ { |
|
134 |
+ $context['template_layers'][] = 'easyban_edits'; |
|
135 |
+ return; |
|
136 |
+ } |
|
137 |
+ |
|
138 |
+ // Find our ban groups we can append. |
|
139 |
+ $request = $smcFunc['db_query']('', ' |
|
140 |
+ SELECT id_ban_group, name |
|
141 |
+ FROM {db_prefix}ban_groups |
|
142 |
+ WHERE easy_bg = {int:one} |
|
143 |
+ ORDER BY name', |
|
144 |
+ array( |
|
145 |
+ 'one' => '1', |
|
146 |
+ ) |
|
147 |
+ ); |
|
148 |
+ while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
149 |
+ $context['ban_group_suggestions'][$row['id_ban_group']] = $row['name']; |
|
150 |
+ $smcFunc['db_free_result']($request); |
|
151 |
+ |
|
152 |
+ $context['ban_group_auto_selects'] = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : $smcFunc['json_decode']($modSettings['aebg_auto_select']); |
|
153 |
+ |
|
154 |
+ // Onions and layers... |
|
155 |
+ self::loadLanguage(); |
|
156 |
+ loadTemplate('Add2ExistingBanGroup'); |
|
157 |
+ $context['template_layers'][] = 'easyban'; |
|
158 |
+ } |
|
159 |
+ |
|
160 |
+ // We are saving a ban. Lets update that info if needed. |
|
161 |
+ public static function hook_edit_bans_post() |
|
162 |
+ { |
|
163 |
+ global $context, $smcFunc; |
|
164 |
+ |
|
165 |
+ if (!isset($context['easy_ban_group'])) |
|
166 |
+ return; |
|
167 |
+ |
|
168 |
+ $smcFunc['db_query']('', ' |
|
169 |
+ UPDATE {db_prefix}ban_groups |
|
170 |
+ SET |
|
171 |
+ easy_bg = {int:easy_bg} |
|
172 |
+ WHERE id_ban_group = {int:id_ban_group}', |
|
173 |
+ array( |
|
174 |
+ 'easy_bg' => $context['easy_ban_group'], |
|
175 |
+ 'id_ban_group' => $context['ban']['id'], |
|
176 |
+ ) |
|
177 |
+ ); |
|
178 |
+ } |
|
179 |
+ |
|
180 |
+ // Get our ban info for the modify ban |
|
181 |
+ public static function hook_ban_list() |
|
182 |
+ { |
|
183 |
+ global $smcFunc, $context; |
|
184 |
+ |
|
185 |
+ // Main page seems to call this as well. |
|
186 |
+ if (empty($context['ban']['id'])) |
|
187 |
+ return; |
|
188 |
+ |
|
189 |
+ $request = $smcFunc['db_query']('', ' |
|
190 |
+ SELECT |
|
191 |
+ bg.easy_bg |
|
192 |
+ FROM {db_prefix}ban_groups AS bg |
|
193 |
+ WHERE bg.id_ban_group = {int:current_ban} |
|
194 |
+ ', |
|
195 |
+ array( |
|
196 |
+ 'current_ban' => $context['ban']['id'], |
|
197 |
+ ) |
|
198 |
+ ); |
|
199 |
+ if ($smcFunc['db_num_rows']($request) == 0) |
|
200 |
+ fatal_lang_error('ban_not_found', false); |
|
201 |
+ |
|
202 |
+ $row = $smcFunc['db_fetch_assoc']($request); |
|
203 |
+ $context['ban']['easy_bg'] = $row['easy_bg']; |
|
204 |
+ $smcFunc['db_free_result']($request); |
|
205 |
+ } |
|
206 |
+} |
... | ... |
@@ -0,0 +1,107 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+function template_easyban_above() |
|
4 |
+{ |
|
5 |
+ global $context, $txt; |
|
6 |
+ |
|
7 |
+ // Only allow selecting a ban group if it is new. |
|
8 |
+ if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) |
|
9 |
+ { |
|
10 |
+ echo ' |
|
11 |
+ <div class="cat_bar"> |
|
12 |
+ <h3 class="catbg">', $txt['aebg_add_existing'], '</h3> |
|
13 |
+ </div> |
|
14 |
+ <div class="windowbg noup"> |
|
15 |
+ <select name="ban_group" onchange="disableOtherFields();" id="ban_group"> |
|
16 |
+ <option value="-1" selected="selected">', $txt['aebg_new_ban_group'], '</option>'; |
|
17 |
+ |
|
18 |
+ foreach ($context['ban_group_suggestions'] as $id_ban_group => $ban_name) |
|
19 |
+ echo ' |
|
20 |
+ <option value="', $id_ban_group, '" onselect="disableOtherFields();">', $ban_name, '</option>'; |
|
21 |
+ echo ' |
|
22 |
+ </select> |
|
23 |
+ </div>'; |
|
24 |
+ } |
|
25 |
+ |
|
26 |
+} |
|
27 |
+ |
|
28 |
+function template_easyban_below() |
|
29 |
+{ |
|
30 |
+ global $context, $modSettings; |
|
31 |
+ |
|
32 |
+ // Only allow selecting a ban group if it is new. |
|
33 |
+ if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) |
|
34 |
+ { |
|
35 |
+ echo ' |
|
36 |
+ <script type="text/javascript"> |
|
37 |
+ function disableOtherFields() |
|
38 |
+ { |
|
39 |
+ var visibility = $("#ban_group").val() == "-1" ? true : false; |
|
40 |
+ $("#manage_bans .windowbg>.settings").toggle(visibility); |
|
41 |
+ $("#manage_bans .windowbg>.ban_settings").toggle(visibility);'; |
|
42 |
+ |
|
43 |
+ // Do we want to auto select some options? |
|
44 |
+ if (!empty($modSettings['aebg_auto_select'])) |
|
45 |
+ { |
|
46 |
+ // Incase it isn't an array. |
|
47 |
+ $allOptions = array_flip(array('main_ip_check', 'hostname_check', 'email_check', 'user_check')); |
|
48 |
+ if (!empty($modSettings['disableHostnameLookup'])) |
|
49 |
+ unset($allOptions['hostname_check']); |
|
50 |
+ |
|
51 |
+ $autoSelects = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : json_decode($modSettings['aebg_auto_select'], true); |
|
52 |
+ foreach ($allOptions as $elID => $dummy) |
|
53 |
+ echo ' |
|
54 |
+ $("#', $elID, '").prop("checked", ', (in_array($elID, $autoSelects) ? 'true' : 'false'),');'; |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ echo ' |
|
58 |
+ } |
|
59 |
+ </script>'; |
|
60 |
+ } |
|
61 |
+} |
|
62 |
+ |
|
63 |
+function template_easyban_edits_above() |
|
64 |
+{ |
|
65 |
+} |
|
66 |
+ |
|
67 |
+function template_easyban_edits_below() |
|
68 |
+{ |
|
69 |
+ global $context, $txt; |
|
70 |
+ |
|
71 |
+ echo ' |
|
72 |
+ <div class="cat_bar"> |
|
73 |
+ <h3 class="catbg">', $txt['aebg_add_existing'], '</h3> |
|
74 |
+ </div> |
|
75 |
+ <div class="windowbg noup"> |
|
76 |
+ <dl class="settings"> |
|
77 |
+ <dt> |
|
78 |
+ <strong>', $txt['aebg_ban_group'], ':</strong><br /> |
|
79 |
+ <span class="smalltext">', $txt['aebg_ban_group_desc'], '</span> |
|
80 |
+ </dt> |
|
81 |
+ <dd> |
|
82 |
+ <input type="checkbox" id="easy_ban_group" value="1" class="input_check"', !empty($context['ban']['easy_bg']) ? ' checked="checked"' : '', ' /> |
|
83 |
+ </dd> |
|
84 |
+ </dl> |
|
85 |
+ </div> |
|
86 |
+ |
|
87 |
+ <input type="submit" name="', $context['ban']['is_new'] ? 'add_ban' : 'modify_ban', '" value="', $context['ban']['is_new'] ? $txt['ban_add'] : $txt['ban_modify'], '" class="button" onclick="A2ebgSave()"> |
|
88 |
+ |
|
89 |
+ <script type="text/javascript"> |
|
90 |
+ $("#admin_form_wrapper").find("input[type=submit]").hide(); |
|
91 |
+ |
|
92 |
+ function A2ebgSave() |
|
93 |
+ { |
|
94 |
+ if ($("#easy_ban_group").is(":checked")) |
|
95 |
+ $("<input>").attr({ |
|
96 |
+ type: "hidden", |
|
97 |
+ name: "easy_ban_group", |
|
98 |
+ value: 1 |
|
99 |
+ }).appendTo("#admin_form_wrapper"); |
|
100 |
+ |
|
101 |
+ $("#admin_form_wrapper").find("input[type=submit]").trigger("click"); |
|
102 |
+ } |
|
103 |
+ </script> |
|
104 |
+ '; |
|
105 |
+ |
|
106 |
+} |
|
107 |
+ |
... | ... |
@@ -1,300 +0,0 @@ |
1 |
-<?xml version="1.0"?> |
|
2 |
-<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification"> |
|
3 |
-<!-- This package was generated by SleePys Modification Maker at https://sleepycode.com --> |
|
4 |
-<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/"> |
|
5 |
- <id>SleePy:Add_to_existing_ban_group</id> |
|
6 |
- <version>1.1</version> |
|
7 |
- <file name="$languagedir/Modifications.english.php" error="skip"> |
|
8 |
- <operation> |
|
9 |
- <search position="end" /> |
|
10 |
- <add><![CDATA[ |
|
11 |
-$txt['aebg_add_existing'] = 'Add to existing ban group'; |
|
12 |
-$txt['aebg_new_ban_group'] = 'Create New Ban Group'; |
|
13 |
-$txt['aebg_ban_group'] = 'Allow quick ban?'; |
|
14 |
-$txt['aebg_ban_group_desc'] = 'Quick bans are done via ban link from profiles'; |
|
15 |
-$txt['aebg_auto_select'] = 'Easy Ban Auto select ban options'; |
|
16 |
-]]></add> |
|
17 |
- </operation> |
|
18 |
- </file> |
|
19 |
- <file name="$sourcedir/ManageSettings.php"> |
|
20 |
- <operation> |
|
21 |
- <search position="before"><![CDATA[ |
|
22 |
- $config_vars = array( |
|
23 |
- // Mod authors, add any settings UNDER this line. Include a comma at the end of the line and don't remove this statement!! |
|
24 |
-]]></search> |
|
25 |
- <add><![CDATA[ |
|
26 |
- array( |
|
27 |
- 'select', 'aebg_auto_select', |
|
28 |
- array('main_ip_check' => $txt['ban_on_ip'], 'hostname_check' => $txt['ban_on_hostname'], 'email_check' => $txt['ban_on_email'], 'user_check' => $txt['ban_on_username']), |
|
29 |
- 'multiple' => true, |
|
30 |
- ), |
|
31 |
-]]></add> |
|
32 |
- </operation> |
|
33 |
- </file> |
|
34 |
- <file name="$sourcedir/ManageBans.php"> |
|
35 |
- <operation> |
|
36 |
- <search position="before"><![CDATA[ |
|
37 |
- $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
|
38 |
-]]></search> |
|
39 |
- <add><![CDATA[ $ban_info['easy_ban_group'] = empty($_POST['easy_ban_group']) ? '0' : '1'; |
|
40 |
-]]></add> |
|
41 |
- </operation> |
|
42 |
- <operation> |
|
43 |
- <search position="after"><![CDATA[ |
|
44 |
- $context['ban']['from_user'] = true; |
|
45 |
- } |
|
46 |
- } |
|
47 |
- } |
|
48 |
- |
|
49 |
- loadJavaScriptFile('suggest.js', array(), 'smf_suggest'); |
|
50 |
-]]></search> |
|
51 |
- <add><![CDATA[ $context['ban']['from_user'] = true; |
|
52 |
- } |
|
53 |
- |
|
54 |
- // Find our ban groups we can append. |
|
55 |
- $request = $smcFunc['db_query']('', ' |
|
56 |
- SELECT id_ban_group, name |
|
57 |
- FROM {db_prefix}ban_groups |
|
58 |
- WHERE easy_bg = {int:one} |
|
59 |
- ORDER BY name', |
|
60 |
- array( |
|
61 |
- 'one' => '1', |
|
62 |
- ) |
|
63 |
- ); |
|
64 |
- while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
65 |
- $context['ban_group_suggestions'][$row['id_ban_group']] = $row['name']; |
|
66 |
- $smcFunc['db_free_result']($request); |
|
67 |
- |
|
68 |
- $context['ban_group_auto_selects'] = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : $smcFunc['json_decode']($modSettings['aebg_auto_select']); |
|
69 |
- } |
|
70 |
- } |
|
71 |
- |
|
72 |
- loadJavaScriptFile('suggest.js', array(), 'smf_suggest'); |
|
73 |
-]]></add> |
|
74 |
- </operation> |
|
75 |
- <operation> |
|
76 |
- <search position="replace"><![CDATA[ // Yes yes, we're ready to add now. |
|
77 |
- $ban_info['id'] = $smcFunc['db_insert']('', |
|
78 |
- '{db_prefix}ban_groups', |
|
79 |
- array( |
|
80 |
- 'name' => 'string-20', 'ban_time' => 'int', 'expire_time' => 'raw', 'cannot_access' => 'int', 'cannot_register' => 'int', |
|
81 |
- 'cannot_post' => 'int', 'cannot_login' => 'int', 'reason' => 'string-255', 'notes' => 'string-65534', |
|
82 |
- ), |
|
83 |
- array( |
|
84 |
- $ban_info['name'], time(), $ban_info['db_expiration'], $ban_info['cannot']['access'], $ban_info['cannot']['register'], |
|
85 |
- $ban_info['cannot']['post'], $ban_info['cannot']['login'], $ban_info['reason'], $ban_info['notes'], |
|
86 |
- ), |
|
87 |
- array('id_ban_group'), |
|
88 |
- 1 |
|
89 |
- ); |
|
90 |
-]]></search> |
|
91 |
- <add><![CDATA[ // No No, we're not adding yet another group. |
|
92 |
- if (!empty($_REQUEST['ban_group'])) |
|
93 |
- { |
|
94 |
- // Make sure the ban group exists. |
|
95 |
- $request = $smcFunc['db_query']('', ' |
|
96 |
- SELECT id_ban_group |
|
97 |
- FROM {db_prefix}ban_groups |
|
98 |
- WHERE id_ban_group = {int:ban_group}', |
|
99 |
- array( |
|
100 |
- 'ban_group' => $_REQUEST['ban_group'], |
|
101 |
- ) |
|
102 |
- ); |
|
103 |
- if ($smcFunc['db_num_rows']($request) != 1) |
|
104 |
- unset($_REQUEST['ban_group']); |
|
105 |
- else |
|
106 |
- $ban_info['id'] = (int) $_REQUEST['ban_group']; |
|
107 |
- $smcFunc['db_free_result']($request); |
|
108 |
- } |
|
109 |
- |
|
110 |
- // Yes yes, we're ready to add now. |
|
111 |
- if (empty($ban_info['id'])) |
|
112 |
- { |
|
113 |
- $ban_info['id'] = $smcFunc['db_insert']('', |
|
114 |
- '{db_prefix}ban_groups', |
|
115 |
- array( |
|
116 |
- 'name' => 'string-20', 'ban_time' => 'int', 'expire_time' => 'raw', 'cannot_access' => 'int', 'cannot_register' => 'int', |
|
117 |
- 'cannot_post' => 'int', 'cannot_login' => 'int', 'reason' => 'string-255', 'notes' => 'string-65534', |
|
118 |
- 'easy_bg' => 'int', |
|
119 |
- ), |
|
120 |
- array( |
|
121 |
- $ban_info['name'], time(), $ban_info['db_expiration'], $ban_info['cannot']['access'], $ban_info['cannot']['register'], |
|
122 |
- $ban_info['cannot']['post'], $ban_info['cannot']['login'], $ban_info['reason'], $ban_info['notes'], |
|
123 |
- $ban_info['easy_ban_group'], |
|
124 |
- ), |
|
125 |
- array('id_ban_group'), |
|
126 |
- 1 |
|
127 |
- ); |
|
128 |
- }]]></add> |
|
129 |
- </operation> |
|
130 |
- <operation> |
|
131 |
- <search position="replace"><![CDATA[ |
|
132 |
- cannot_login = {int:cannot_login} |
|
133 |
- WHERE id_ban_group = {int:id_ban_group}', |
|
134 |
- array( |
|
135 |
- 'expiration' => $ban_info['db_expiration'], |
|
136 |
-]]></search> |
|
137 |
- <add><![CDATA[ |
|
138 |
- cannot_login = {int:cannot_login}, |
|
139 |
- easy_bg = {int:easy_bg} |
|
140 |
- WHERE id_ban_group = {int:id_ban_group}', |
|
141 |
- array( |
|
142 |
- 'easy_bg' => $ban_info['easy_ban_group'], |
|
143 |
- 'expiration' => $ban_info['db_expiration'], |
|
144 |
-]]></add> |
|
145 |
- </operation> |
|
146 |
- <operation> |
|
147 |
- <search position="replace"><![CDATA[ |
|
148 |
- COALESCE(mem.id_member, 0) AS id_member, mem.member_name, mem.real_name |
|
149 |
- FROM {db_prefix}ban_groups AS bg |
|
150 |
- LEFT JOIN {db_prefix}ban_items AS bi ON (bi.id_ban_group = bg.id_ban_group) |
|
151 |
-]]></search> |
|
152 |
- <add><![CDATA[ |
|
153 |
- COALESCE(mem.id_member, 0) AS id_member, mem.member_name, mem.real_name, bg.easy_bg |
|
154 |
- FROM {db_prefix}ban_groups AS bg |
|
155 |
- LEFT JOIN {db_prefix}ban_items AS bi ON (bi.id_ban_group = bg.id_ban_group) |
|
156 |
-]]></add> |
|
157 |
- </operation> |
|
158 |
- <operation> |
|
159 |
- <search position="replace"><![CDATA[ |
|
160 |
- 'reason' => $row['reason'], |
|
161 |
- 'notes' => $row['notes'], |
|
162 |
- 'cannot' => array( |
|
163 |
-]]></search> |
|
164 |
- <add><![CDATA[ |
|
165 |
- 'reason' => $row['reason'], |
|
166 |
- 'notes' => $row['notes'], |
|
167 |
- 'easy_bg' => $row['easy_bg'], |
|
168 |
- 'cannot' => array( |
|
169 |
-]]></add> |
|
170 |
- </operation> |
|
171 |
- </file> |
|
172 |
- <file name="$themedir/ManageBans.template.php"> |
|
173 |
- <operation> |
|
174 |
- <search position="replace"><![CDATA[ |
|
175 |
- echo ' |
|
176 |
- <div class="windowbg2 noup"> |
|
177 |
- <dl class="settings"> |
|
178 |
- <dt id="ban_name_label"> |
|
179 |
- <strong>', $txt['ban_name'], ':</strong> |
|
180 |
-]]></search> |
|
181 |
- <add><![CDATA[ |
|
182 |
- // Only allow selecting a ban group if it is new. |
|
183 |
- if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) |
|
184 |
- { |
|
185 |
- echo ' |
|
186 |
- <div class="information noup"> |
|
187 |
- <legend>', $txt['aebg_add_existing'], '</legend> |
|
188 |
- <select name="ban_group" onchange="disableOtherFields();" id="ban_group"> |
|
189 |
- <option value="-1" selected="selected">', $txt['aebg_new_ban_group'], '</option>'; |
|
190 |
- |
|
191 |
- foreach ($context['ban_group_suggestions'] as $id_ban_group => $ban_name) |
|
192 |
- echo ' |
|
193 |
- <option value="', $id_ban_group, '" onselect="disableOtherFields();">', $ban_name, '</option>'; |
|
194 |
- echo ' |
|
195 |
- </select> |
|
196 |
- </div>'; |
|
197 |
- } |
|
198 |
- |
|
199 |
- echo ' |
|
200 |
- <div class="windowbg2 noup"> |
|
201 |
- <dl id="ban_info" class="settings"> |
|
202 |
- <dt id="ban_name_label"> |
|
203 |
- <strong>', $txt['ban_name'], ':</strong> |
|
204 |
-]]></add> |
|
205 |
- </operation> |
|
206 |
- <operation> |
|
207 |
- <search position="before"><![CDATA[ |
|
208 |
- if (isset($context['ban']['reason'])) |
|
209 |
- echo ' |
|
210 |
- <dt> |
|
211 |
- <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
|
212 |
- <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
|
213 |
- </dt> |
|
214 |
- <dd> |
|
215 |
- <textarea name="reason" id="reason" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['reason'], '</textarea> |
|
216 |
- </dd>'; |
|
217 |
-]]></search> |
|
218 |
- <add><![CDATA[ |
|
219 |
- echo ' |
|
220 |
- <dt id="aebg_select"> |
|
221 |
- <strong>', $txt['aebg_ban_group'], ':</strong><br /> |
|
222 |
- <span class="smalltext">', $txt['aebg_ban_group_desc'], '</span> |
|
223 |
- </dt> |
|
224 |
- <dd> |
|
225 |
- <input type="checkbox" name="easy_ban_group" value="1" class="input_check"', !empty($context['ban']['easy_bg']) ? ' checked="checked"' : '', ' /> |
|
226 |
- </dd>'; |
|
227 |
-]]></add> |
|
228 |
- </operation> |
|
229 |
- <operation> |
|
230 |
- <search position="replace"><![CDATA[ |
|
231 |
- <fieldset class="ban_settings floatleft"> |
|
232 |
- <legend> |
|
233 |
- ', $txt['ban_expiration'], ' |
|
234 |
-]]></search> |
|
235 |
- <add><![CDATA[ |
|
236 |
- <fieldset id="ban_expire" class="ban_settings floatleft"> |
|
237 |
- <legend> |
|
238 |
- ', $txt['ban_expiration'], ' |
|
239 |
-]]></add> |
|
240 |
- </operation> |
|
241 |
- <operation> |
|
242 |
- <search position="replace"><![CDATA[ |
|
243 |
- <fieldset class="ban_settings floatright"> |
|
244 |
- <legend> |
|
245 |
- ', $txt['ban_restriction'], ' |
|
246 |
-]]></search> |
|
247 |
- <add><![CDATA[ |
|
248 |
- <fieldset id="ban_restrict" class="ban_settings floatright"> |
|
249 |
- <legend> |
|
250 |
- ', $txt['ban_restriction'], ' |
|
251 |
-]]></add> |
|
252 |
- </operation> |
|
253 |
- <operation> |
|
254 |
- <search position="after"><![CDATA[ |
|
255 |
- var fUpdateStatus = function () |
|
256 |
- { |
|
257 |
- document.getElementById("expire_date").disabled = !document.getElementById("expires_one_day").checked; |
|
258 |
-]]></search> |
|
259 |
- <add><![CDATA['; |
|
260 |
- |
|
261 |
- // Only allow selecting a ban group if it is new. |
|
262 |
- if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) |
|
263 |
- { |
|
264 |
- echo ' |
|
265 |
- function disableOtherFields() |
|
266 |
- { |
|
267 |
- var display_value = document.getElementById("ban_group").value == "-1" ? "" : "none"; |
|
268 |
- |
|
269 |
- document.getElementById("ban_info").style.display = display_value; |
|
270 |
- document.getElementById("ban_expire").style.display = display_value; |
|
271 |
- document.getElementById("ban_restrict").style.display = display_value;'; |
|
272 |
- |
|
273 |
- // Do we want to auto select some options? |
|
274 |
- if (!empty($modSettings['aebg_auto_select'])) |
|
275 |
- { |
|
276 |
- // Incase it isn't an array. |
|
277 |
- $allOptions = array_flip(array('main_ip_check', 'hostname_check', 'email_check', 'user_check')); |
|
278 |
- if (!empty($modSettings['disableHostnameLookup'])) |
|
279 |
- unset($allOptions['hostname_check']); |
|
280 |
- |
|
281 |
- $autoSelects = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : safe_unserialize($modSettings['aebg_auto_select']); |
|
282 |
- foreach ($autoSelects as $elID) |
|
283 |
- { |
|
284 |
- unset($allOptions[$elID]); |
|
285 |
- echo ' |
|
286 |
- document.getElementById("', $elID, '").checked = "checked";'; |
|
287 |
- } |
|
288 |
- foreach ($allOptions as $elID => $dummy) |
|
289 |
- echo ' |
|
290 |
- document.getElementById("', $elID, '").checked = "";'; |
|
291 |
- } |
|
292 |
- |
|
293 |
- echo ' |
|
294 |
- }'; |
|
295 |
- } |
|
296 |
- |
|
297 |
- echo ']]></add> |
|
298 |
- </operation> |
|
299 |
- </file> |
|
300 |
-</modification> |
|
301 | 0 |
\ No newline at end of file |
... | ... |
@@ -14,11 +14,19 @@ global $db_prefix, $modSettings, $func, $smcFunc; |
14 | 14 |
|
15 | 15 |
if (version_compare('2.0 RC2', $modSettings['smfVersion']) > 0) |
16 | 16 |
exit('<b>Error:</b> Cannot install - Your SMF version is not sufficient enough. Please upgrade to SMF 2.0 RC2 or higher'); |
17 |
-elseif (version_compare('2.1 Beta 2', $modSettings['smfVersion']) > 0 && version_compare('2.1 Beta 1', $modSettings['smfVersion']) < 0) |
|
18 |
- exit('<b>Error:</b> Cannot install - Your SMF version is not sufficient enough. Please upgrade to SMF 2.1 Beta 3 or higher'); |
|
17 |
+elseif (version_compare('2.1 RC2', $modSettings['smfVersion']) > 0 && version_compare('2.1 Beta 1', $modSettings['smfVersion']) < 0) |
|
18 |
+ exit('<b>Error:</b> Cannot install - Your SMF version is not sufficient enough. Please upgrade to SMF 2.1 RC2 or higher'); |
|
19 | 19 |
|
20 | 20 |
// Our column. |
21 |
-$smcFunc['db_add_column']($db_prefix . "ban_groups", array('name'=> 'easy_bg', 'type'=>'smallint', 'size' => '3')); |
|
21 |
+$smcFunc['db_add_column']( |
|
22 |
+ $db_prefix . "ban_groups", |
|
23 |
+ array( |
|
24 |
+ 'name'=> 'easy_bg', |
|
25 |
+ 'type'=>'smallint', |
|
26 |
+ 'size' => '3', |
|
27 |
+ 'default' => 0, |
|
28 |
+ ) |
|
29 |
+); |
|
22 | 30 |
|
23 | 31 |
if(!empty($using_ssi)) |
24 | 32 |
echo 'If no errors, Success!'; |
... | ... |
@@ -0,0 +1,8 @@ |
1 |
+<?php |
|
2 |
+// Version: 2.1 RC2; Add2ExistingBanGroup |
|
3 |
+ |
|
4 |
+$txt['aebg_add_existing'] = 'Add to existing ban group'; |
|
5 |
+$txt['aebg_new_ban_group'] = 'Create New Ban Group'; |
|
6 |
+$txt['aebg_ban_group'] = 'Allow quick ban?'; |
|
7 |
+$txt['aebg_ban_group_desc'] = 'Quick bans are done via ban link from profiles'; |
|
8 |
+$txt['aebg_auto_select'] = 'Easy Ban Auto select ban options'; |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/"> |
5 | 5 |
<id>SleePy:Add_to_Existing_Ban_Group</id> |
6 | 6 |
<name>Add to Existing Ban Group</name> |
7 |
- <version>1.1</version> |
|
7 |
+ <version>2.0</version> |
|
8 | 8 |
<type>modification</type> |
9 | 9 |
<install for="2.0-2.0.99"> |
10 | 10 |
<readme>README.txt</readme> |
... | ... |
@@ -15,13 +15,34 @@ |
15 | 15 |
<modification reverse="true">add_to_existing_ban_group-20x.xml</modification> |
16 | 16 |
</uninstall> |
17 | 17 |
|
18 |
- <install for="2.1 Beta 3, 2.1 Beta 4, 2.1 RC1"> |
|
18 |
+ <install for="2.1 RC2, 2.1 RC3, 2.1-2.1.99"> |
|
19 | 19 |
<readme>README.txt</readme> |
20 |
- <modification>add_to_existing_ban_group-21x.xml</modification> |
|
21 | 20 |
<database>database_install.php</database> |
21 |
+ |
|
22 |
+ <require-file name="language/Add2ExistingBanGroup.english.php" destination="$themes_dir/default/languages" /> |
|
23 |
+ <require-file name="Add2ExistingBanGroup.template.php" destination="$themedir" /> |
|
24 |
+ <require-file name="Add2ExistingBanGroup.php" destination="$sourcedir" /> |
|
25 |
+ |
|
26 |
+ <!-- All the hooks --> |
|
27 |
+ <hook hook="integrate_general_mod_settings" function="a2ebg::hook_general_mod_settings" file="$sourcedir/Add2ExistingBanGroup.php" /> |
|
28 |
+ <hook hook="integrate_edit_bans" function="a2ebg::hook_edit_bans" file="$sourcedir/Add2ExistingBanGroup.php" /> |
|
29 |
+ <hook hook="integrate_ban_edit_new" function="a2ebg::hook_ban_edit_new" file="$sourcedir/Add2ExistingBanGroup.php" /> |
|
30 |
+ <hook hook="integrate_edit_bans_post" function="a2ebg::hook_edit_bans_post" file="$sourcedir/Add2ExistingBanGroup.php" /> |
|
31 |
+ <hook hook="integrate_ban_list" function="a2ebg::hook_ban_list" file="$sourcedir/Add2ExistingBanGroup.php" /> |
|
32 |
+ <hook hook="integrate_ban_edit_list" function="a2ebg::hook_ban_edit_list" file="$sourcedir/Add2ExistingBanGroup.php" /> |
|
22 | 33 |
</install> |
23 |
- <uninstall for="2.1 Beta 3, 2.1 Beta 4, 2.1 RC1"> |
|
24 |
- <modification reverse="true">add_to_existing_ban_group-21x.xml</modification> |
|
34 |
+ <uninstall for="2.1 RC2, 2.1 RC3, 2.1-2.1.99"> |
|
35 |
+ <remove-file name="language/Add2ExistingBanGroup.english.php" destination="$themes_dir/default/languages" /> |
|
36 |
+ <remove-file name="Add2ExistingBanGroup.template.php" destination="$themedir" /> |
|
37 |
+ <remove-file name="Add2ExistingBanGroup.php" destination="$sourcedir" /> |
|
38 |
+ |
|
39 |
+ <!-- All the hooks in reverse --> |
|
40 |
+ <hook hook="integrate_general_mod_settings" function="a2ebg::hook_general_mod_settings" file="$sourcedir/Add2ExistingBanGroup.php" reverse="true" /> |
|
41 |
+ <hook hook="integrate_edit_bans" function="a2ebg::hook_edit_bans" file="$sourcedir/Add2ExistingBanGroup.php" reverse="true" /> |
|
42 |
+ <hook hook="integrate_ban_edit_new" function="a2ebg::hook_ban_edit_new" file="$sourcedir/Add2ExistingBanGroup.php" reverse="true" /> |
|
43 |
+ <hook hook="integrate_edit_bans_post" function="a2ebg::hook_edit_bans_post" file="$sourcedir/Add2ExistingBanGroup.php" reverse="true" /> |
|
44 |
+ <hook hook="integrate_ban_list" function="a2ebg::hook_ban_list" file="$sourcedir/Add2ExistingBanGroup.php" reverse="true" /> |
|
45 |
+ <hook hook="integrate_ban_edit_list" function="a2ebg::hook_ban_edit_list" file="$sourcedir/Add2ExistingBanGroup.php" reverse="true" /> |
|
25 | 46 |
</uninstall> |
26 | 47 |
|
27 | 48 |
</package-info> |
28 | 49 |
\ No newline at end of file |
29 | 50 |