124dd63929ce093684c366152b79d79715605503
jdarwood007 Add SMF 2.1 Support

jdarwood007 authored 6 years ago

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 '
jdarwood007 Improvement on the UI

jdarwood007 authored 6 years ago

186) 					<div class="information noup">
jdarwood007 Add SMF 2.1 Support

jdarwood007 authored 6 years ago

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>
jdarwood007 Improvement on the UI

jdarwood007 authored 6 years ago

196) 					</div>';