Importing a2ebg
Jeremy D

Jeremy D commited on 2011-09-28 12:15:38
Showing 4 changed files, with 346 additions and 0 deletions.

... ...
@@ -0,0 +1,24 @@
1
+Copyright (c) 2011, SleePy (smf-mods-license@sleepycode.com)
2
+All rights reserved.
3
+
4
+Redistribution and use in source and binary forms, with or without
5
+modification, are permitted provided that the following conditions are met:
6
+    * Redistributions of source code must retain the above copyright
7
+      notice, this list of conditions and the following disclaimer.
8
+    * Redistributions in binary form must reproduce the above copyright
9
+      notice, this list of conditions and the following disclaimer in the
10
+      documentation and/or other materials provided with the distribution.
11
+    * Neither the name of the <organization> nor the
12
+      names of its contributors may be used to endorse or promote products
13
+      derived from this software without specific prior written permission.
14
+
15
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 25
\ No newline at end of file
... ...
@@ -0,0 +1,282 @@
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 http://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.0.3</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
+		$_POST['cannot_login'] = !empty($_POST['full_ban']) || empty($_POST['cannot_login']) ? '0' : '1';
38
+]]></search>
39
+			<add><![CDATA[
40
+		$_POST['easy_ban_group'] = empty($_POST['easy_ban_group']) ? '0' : '1';
41
+]]></add>
42
+		</operation>
43
+		<operation>
44
+			<search position="before"><![CDATA[
45
+				// Borrowing a few language strings from profile.
46
+				loadLanguage('Profile');
47
+			}
48
+]]></search>
49
+			<add><![CDATA[
50
+			// Find our ban groups we can append.
51
+			$request = $smcFunc['db_query']('', '
52
+				SELECT id_ban_group, name
53
+				FROM {db_prefix}ban_groups
54
+				WHERE easy_bg = {int:one}
55
+				ORDER BY name',
56
+				array(
57
+					'one' => '1',
58
+				)
59
+			);
60
+			while ($row = $smcFunc['db_fetch_assoc']($request))
61
+				$context['ban_group_suggestions'][$row['id_ban_group']] = $row['name'];
62
+			$smcFunc['db_free_result']($request);
63
+]]></add>
64
+		</operation>
65
+		<operation>
66
+			<search position="replace"><![CDATA[
67
+			// Yes yes, we're ready to add now.
68
+			$smcFunc['db_insert']('',
69
+				'{db_prefix}ban_groups',
70
+				array(
71
+					'name' => 'string-20', 'ban_time' => 'int', 'expire_time' => 'raw', 'cannot_access' => 'int', 'cannot_register' => 'int',
72
+					'cannot_post' => 'int', 'cannot_login' => 'int', 'reason' => 'string-255', 'notes' => 'string-65534',
73
+				),
74
+				array(
75
+					$_POST['ban_name'], time(), $_POST['expiration'], $_POST['full_ban'], $_POST['cannot_register'],
76
+					$_POST['cannot_post'], $_POST['cannot_login'], $_POST['reason'], $_POST['notes'],
77
+				),
78
+				array('id_ban_group')
79
+			);
80
+			$_REQUEST['bg'] = $smcFunc['db_insert_id']('{db_prefix}ban_groups', 'id_ban_group');]]></search>
81
+			<add><![CDATA[
82
+			// No No, we're not adding yet another group.
83
+			if (!empty($_REQUEST['ban_group']))
84
+			{
85
+				// Make sure the ban group exists.
86
+				$request = $smcFunc['db_query']('', '
87
+					SELECT id_ban_group
88
+					FROM {db_prefix}ban_groups
89
+					WHERE id_ban_group = {int:ban_group}',
90
+					array(
91
+						'ban_group' => $_REQUEST['ban_group'],
92
+					)
93
+				);
94
+				if ($smcFunc['db_num_rows']($request) != 1)
95
+					unset($_REQUEST['ban_group']);
96
+				else
97
+					$_REQUEST['bg'] = $_REQUEST['ban_group'];
98
+				$smcFunc['db_free_result']($request);
99
+			}
100
+
101
+			// Yes yes, we're ready to add now.
102
+			if (empty($_REQUEST['bg']))
103
+			{
104
+				$smcFunc['db_insert']('',
105
+					'{db_prefix}ban_groups',
106
+					array(
107
+						'name' => 'string-20', 'ban_time' => 'int', 'expire_time' => 'raw', 'cannot_access' => 'int', 'cannot_register' => 'int',
108
+						'cannot_post' => 'int', 'cannot_login' => 'int', 'reason' => 'string-255', 'notes' => 'string-65534',
109
+						'easy_bg' => 'int',
110
+					),
111
+					array(
112
+						$_POST['ban_name'], time(), $_POST['expiration'], $_POST['full_ban'], $_POST['cannot_register'],
113
+						$_POST['cannot_post'], $_POST['cannot_login'], $_POST['reason'], $_POST['notes'],
114
+						$_POST['easy_ban_group'],
115
+					),
116
+					array('id_ban_group')
117
+				);
118
+				$_REQUEST['bg'] = $smcFunc['db_insert_id']('{db_prefix}ban_groups', 'id_ban_group');
119
+			}]]></add>
120
+		</operation>
121
+		<operation>
122
+			<search position="replace"><![CDATA[
123
+					cannot_login = {int:cannot_login}
124
+				WHERE id_ban_group = {int:id_ban_group}',
125
+				array(
126
+					'expiration' => $_POST['expiration'],
127
+]]></search>
128
+			<add><![CDATA[
129
+					cannot_login = {int:cannot_login},
130
+					easy_bg = {int:easy_bg}
131
+				WHERE id_ban_group = {int:id_ban_group}',
132
+				array(
133
+					'easy_bg' => $_POST['easy_ban_group'],
134
+					'expiration' => $_POST['expiration'],
135
+]]></add>
136
+		</operation>
137
+		<operation>
138
+			<search position="replace"><![CDATA[
139
+				IFNULL(mem.id_member, 0) AS id_member, mem.member_name, mem.real_name
140
+			FROM {db_prefix}ban_groups AS bg
141
+				LEFT JOIN {db_prefix}ban_items AS bi ON (bi.id_ban_group = bg.id_ban_group)
142
+				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = bi.id_member)
143
+			WHERE bg.id_ban_group = {int:current_ban}',
144
+			array(
145
+				'current_ban' => $_REQUEST['bg'],
146
+]]></search>
147
+			<add><![CDATA[
148
+				IFNULL(mem.id_member, 0) AS id_member, mem.member_name, mem.real_name, easy_bg
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
+				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = bi.id_member)
152
+			WHERE bg.id_ban_group = {int:current_ban}',
153
+			array(
154
+				'current_ban' => $_REQUEST['bg'],
155
+]]></add>
156
+		</operation>
157
+		<operation>
158
+			<search position="replace"><![CDATA[
159
+					'reason' => $row['reason'],
160
+					'notes' => $row['notes'],
161
+					'cannot' => array(
162
+]]></search>
163
+			<add><![CDATA[
164
+					'reason' => $row['reason'],
165
+					'notes' => $row['notes'],
166
+					'easy_bg' => $row['easy_bg'],
167
+					'cannot' => array(
168
+]]></add>
169
+		</operation>
170
+	</file>
171
+	<file name="$themedir/ManageBans.template.php">
172
+		<operation>
173
+			<search position="replace"><![CDATA[
174
+				<form action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '" onsubmit="if (this.ban_name.value == \'\') {alert(\'', $txt['ban_name_empty'], '\'); return false;} if (this.partial_ban.checked &amp;&amp; !(this.cannot_post.checked || this.cannot_register.checked || this.cannot_login.checked)) {alert(\'', $txt['ban_restriction_empty'], '\'); return false;}">
175
+					<dl class="settings">
176
+]]></search>
177
+			<add><![CDATA[
178
+				<form action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '" onsubmit="if (this.ban_name.value == \'\') {alert(\'', $txt['ban_name_empty'], '\'); return false;} if (this.partial_ban.checked &amp;&amp; !(this.cannot_post.checked || this.cannot_register.checked || this.cannot_login.checked)) {alert(\'', $txt['ban_restriction_empty'], '\'); return false;}">';
179
+	// Only allow selecting a ban group if it is new.
180
+	if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions']))
181
+	{		
182
+		echo '
183
+					<fieldset>
184
+						<legend>', $txt['aebg_add_existing'], '</legend>
185
+						<select name="ban_group" onchange="disableOtherFields();" id="ban_group">
186
+							<option value="-1" selected="selected">', $txt['aebg_new_ban_group'], '</option>';
187
+
188
+		foreach ($context['ban_group_suggestions'] as $id_ban_group => $ban_name)
189
+			echo '
190
+							<option value="', $id_ban_group, '" onselect="disableOtherFields();">', $ban_name, '</option>';
191
+		echo '
192
+						</select>
193
+					</fieldset>';
194
+	}
195
+
196
+	echo '
197
+					<dl id="ban_info" class="settings">
198
+]]></add>
199
+		</operation>
200
+		<operation>
201
+			<search position="before"><![CDATA[
202
+						<dt>
203
+							<strong>', $txt['ban_reason'], ':</strong><br />
204
+							<span class="smalltext">', $txt['ban_reason_desc'], '</span>
205
+						</dt>
206
+						<dd>
207
+							<textarea name="reason" cols="44" rows="3">', $context['ban']['reason'], '</textarea>
208
+						</dd>
209
+]]></search>
210
+			<add><![CDATA[
211
+						<dt>
212
+							<strong>', $txt['aebg_ban_group'], ':</strong><br />
213
+							<span class="smalltext">', $txt['aebg_ban_group_desc'], '</span>
214
+						</dt>
215
+						<dd>
216
+							<input type="checkbox" name="easy_ban_group" value="1" class="input_check"', !empty($context['ban']['easy_bg']) ? ' checked="checked"' : '', ' />
217
+						</dd>
218
+]]></add>
219
+		</operation>
220
+		<operation>
221
+			<search position="replace"><![CDATA[
222
+					<fieldset class="ban_settings floatright">
223
+						<legend>
224
+							', $txt['ban_restriction'], '
225
+]]></search>
226
+			<add><![CDATA[
227
+					<fieldset id="ban_restrict" class="ban_settings floatright">
228
+						<legend>
229
+							', $txt['ban_restriction'], '
230
+]]></add>
231
+		</operation>
232
+		<operation>
233
+			<search position="replace"><![CDATA[
234
+					<fieldset class="ban_settings floatleft">
235
+						<legend>
236
+							', $txt['ban_expiration'], '
237
+]]></search>
238
+			<add><![CDATA[
239
+					<fieldset id="ban_expire" class="ban_settings floatleft">
240
+						<legend>
241
+							', $txt['ban_expiration'], '
242
+]]></add>
243
+		</operation>
244
+		<operation>
245
+			<search position="after"><![CDATA[
246
+		var fUpdateStatus = function ()
247
+		{
248
+			document.getElementById("expire_date").disabled = !document.getElementById("expires_one_day").checked;
249
+]]></search>
250
+			<add><![CDATA[';
251
+
252
+	// Only allow selecting a ban group if it is new.
253
+	if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions']))
254
+	{
255
+		echo '
256
+		function disableOtherFields()
257
+		{
258
+			var display_value = document.getElementById("ban_group").value == "-1" ? "" : "none";
259
+
260
+			document.getElementById("ban_info").style.display = display_value;
261
+			document.getElementById("ban_expire").style.display = display_value;
262
+			document.getElementById("ban_restrict").style.display = display_value;';
263
+
264
+		// Do we want to auto select some options?
265
+		if (!empty($modSettings['aebg_auto_select']))
266
+		{
267
+			// Incase it isn't an array.
268
+			$autoSelects = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : unserialize($modSettings['aebg_auto_select']);
269
+			foreach ($autoSelects as $elID)
270
+				echo '
271
+			document.getElementById("', $elID, '").checked = "checked";';
272
+		}
273
+		
274
+		echo '
275
+		}';
276
+	}
277
+
278
+	echo '
279
+]]></add>
280
+		</operation>
281
+	</file>
282
+</modification>
0 283
\ No newline at end of file
... ...
@@ -0,0 +1,23 @@
1
+<?php
2
+error_reporting(E_ALL);
3
+
4
+// Hopefully we have the goodies.
5
+if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
6
+{
7
+	$using_ssi = true;
8
+	require_once(dirname(__FILE__) . '/SSI.php');
9
+}
10
+elseif (!defined('SMF'))
11
+	exit('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
12
+
13
+global $db_prefix, $modSettings, $func, $smcFunc;
14
+
15
+if (version_compare('2.0 RC2', $modSettings['smfVersion']) > 0)
16
+	exit('<b>Error:</b> Cannot install - Your SMF version is not sufficient enough.  Please upgrade to SMF 2.0 RC2 or higher');
17
+
18
+// Our column.
19
+$smcFunc['db_add_column']($db_prefix . "ban_groups", array('name'=> 'easy_bg', 'type'=>'smallint', 'size' => '3'));
20
+
21
+if(!empty($using_ssi))
22
+	echo 'If no errors, Success!';
23
+?>
0 24
\ No newline at end of file
... ...
@@ -0,0 +1,17 @@
1
+<?xml version="1.0"?>
2
+<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
3
+<!-- This package was generated by SleePys Package Maker at http://sleepycode.com -->
4
+<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
5
+	<id>SleePy:Add_to_Existing_Ban_Group</id>
6
+	<name>Add to Existing Ban Group</name>
7
+	<version>1.0.3</version>
8
+	<type>modification</type>
9
+	<install for="2.0-2.0.99">
10
+		<readme>README.txt</readme>
11
+		<modification>add_to_existing_ban_group-20x.xml</modification>
12
+		<database>database_install.php</database>
13
+	</install>
14
+	<uninstall for="2.0-2.0.99">
15
+		<modification reverse="true">add_to_existing_ban_group-20x.xml</modification>
16
+	</uninstall>
17
+</package-info>
0 18
\ No newline at end of file
1 19