Completed
Push — release-2.1 ( 5ca5b8...e49a83 )
by Mathias
07:07
created
Sources/tasks/Birthday-Notify.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
  */
19 19
 class Birthday_Notify_Background extends SMF_BackgroundTask
20 20
 {
21
-    /**
22
-     * This executes the task. It loads up the birthdays, figures out the greeting, etc.
23
-     * @return bool Always returns true
24
-     */
21
+	/**
22
+	 * This executes the task. It loads up the birthdays, figures out the greeting, etc.
23
+	 * @return bool Always returns true
24
+	 */
25 25
 	public function execute()
26 26
  	{
27 27
 		global $txt, $smcFunc, $txtBirthdayEmails, $language, $modSettings, $sourcedir;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
 		$birthdays = array();
52 52
 		while ($row = $smcFunc['db_fetch_assoc']($result))
53 53
 		{
54
-			if (!isset($birthdays[$row['lngfile']]))
55
-				$birthdays[$row['lngfile']] = array();
54
+			if (!isset($birthdays[$row['lngfile']])) {
55
+							$birthdays[$row['lngfile']] = array();
56
+			}
56 57
 			$birthdays[$row['lngfile']][$row['id_member']] = array(
57 58
 				'name' => $row['real_name'],
58 59
 				'email' => $row['email_address']
@@ -117,8 +118,8 @@  discard block
 block discarded – undo
117 118
 			AddMailQueue(true);
118 119
 
119 120
 			// Insert the alerts if any
120
-			if (!empty($alert_rows))
121
-				$smcFunc['db_insert']('',
121
+			if (!empty($alert_rows)) {
122
+							$smcFunc['db_insert']('',
122 123
 					'{db_prefix}user_alerts',
123 124
 					array(
124 125
 						'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string',
@@ -127,6 +128,7 @@  discard block
 block discarded – undo
127 128
 					$alert_rows,
128 129
 					array()
129 130
 				);
131
+			}
130 132
 		}
131 133
 
132 134
 		return true;
Please login to merge, or discard this patch.
Sources/tasks/MsgReportReply-Notify.php 2 patches
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 				'last_comment' => $this->_details['comment_id'],
41 41
 			)
42 42
 		);
43
-		while ($row = $smcFunc['db_fetch_row']($request))
44
-			$possible_members[] = $row[0];
43
+		while ($row = $smcFunc['db_fetch_row']($request)) {
44
+					$possible_members[] = $row[0];
45
+		}
45 46
 		$smcFunc['db_free_result']($request);
46 47
 
47 48
 		// Presumably, there are some people?
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 			$possible_members = array_flip(array_flip($possible_members));
51 52
 			$possible_members = array_diff($possible_members, array($this->_details['sender_id']));
52 53
 		}
53
-		if (empty($possible_members))
54
-			return true;
54
+		if (empty($possible_members)) {
55
+					return true;
56
+		}
55 57
 
56 58
 		// We need to know who can moderate this board - and therefore who can see this report.
57 59
 		// First up, people who have moderate_board in the board this topic was in.
@@ -67,8 +69,9 @@  discard block
 block discarded – undo
67 69
 				'current_board' => $this->_details['board_id'],
68 70
 			)
69 71
 		);
70
-		while ($row = $smcFunc['db_fetch_assoc']($request))
71
-			$members[] = $row['id_member'];
72
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
73
+					$members[] = $row['id_member'];
74
+		}
72 75
 		$smcFunc['db_free_result']($request);
73 76
 
74 77
 		// Thirdly, anyone assigned to be a moderator of this group as a group->board moderator.
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 			)
86 89
 		);
87 90
 
88
-		while ($row = $smcFunc['db_fetch_assoc']($request))
89
-			$members[] = $row['id_member'];
91
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
92
+					$members[] = $row['id_member'];
93
+		}
90 94
 		$smcFunc['db_free_result']($request);
91 95
 
92 96
 		// So now we have two lists: the people who replied to a report in the past,
@@ -108,8 +112,9 @@  discard block
 block discarded – undo
108 112
 		{
109 113
 			foreach ($alert_bits as $type => $bitvalue)
110 114
 			{
111
-				if ($pref_option['msg_report_reply'] & $bitvalue)
112
-					$notifies[$type][] = $member;
115
+				if ($pref_option['msg_report_reply'] & $bitvalue) {
116
+									$notifies[$type][] = $member;
117
+				}
113 118
 			}
114 119
 		}
115 120
 
@@ -170,8 +175,9 @@  discard block
 block discarded – undo
170 175
 			);
171 176
 			while ($row = $smcFunc['db_fetch_assoc']($request))
172 177
 			{
173
-				if (empty($row['lngfile']))
174
-					$row['lngfile'] = $language;
178
+				if (empty($row['lngfile'])) {
179
+									$row['lngfile'] = $language;
180
+				}
175 181
 				$emails[$row['lngfile']][$row['id_member']] = $row['email_address'];
176 182
 			}
177 183
 			$smcFunc['db_free_result']($request);
@@ -203,8 +209,9 @@  discard block
 block discarded – undo
203 209
 				$emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang);
204 210
 
205 211
 				// And do the actual sending...
206
-				foreach ($recipients as $id_member => $email_address)
207
-					sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3);
212
+				foreach ($recipients as $id_member => $email_address) {
213
+									sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3);
214
+				}
208 215
 			}
209 216
 		}
210 217
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 class Likes_Notify_Background extends SMF_BackgroundTask
20 20
 {
21 21
 	/**
22
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
22
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23 23
 	 * @return bool Always returns true
24 24
 	 */
25 25
 	public function execute()
Please login to merge, or discard this patch.
Sources/tasks/ApproveReply-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 class ApproveReply_Notify_Background extends SMF_BackgroundTask
19 19
 {
20 20
 	/**
21
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts.
21
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts.
22 22
 	 * @return bool Always returns true.
23 23
 	 */
24 24
 	public function execute()
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,14 +96,15 @@
 block discarded – undo
96 96
 		}
97 97
 
98 98
 		// Insert the alerts if any
99
-		if (!empty($alert_rows))
100
-			$smcFunc['db_insert']('',
99
+		if (!empty($alert_rows)) {
100
+					$smcFunc['db_insert']('',
101 101
 				'{db_prefix}user_alerts',
102 102
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
103 103
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
104 104
 				$alert_rows,
105 105
 				array()
106 106
 			);
107
+		}
107 108
 
108 109
 		return true;
109 110
 	}
Please login to merge, or discard this patch.
Sources/tasks/MsgReport-Notify.php 2 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 				'current_board' => $this->_details['board_id'],
41 41
 			)
42 42
 		);
43
-		while ($row = $smcFunc['db_fetch_assoc']($request))
44
-			$members[] = $row['id_member'];
43
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
44
+					$members[] = $row['id_member'];
45
+		}
45 46
 		$smcFunc['db_free_result']($request);
46 47
 
47 48
 		// Thirdly, anyone assigned to be a moderator of this group as a group->board moderator.
@@ -58,8 +59,9 @@  discard block
 block discarded – undo
58 59
 			)
59 60
 		);
60 61
 
61
-		while ($row = $smcFunc['db_fetch_assoc']($request))
62
-			$members[] = $row['id_member'];
62
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
63
+					$members[] = $row['id_member'];
64
+		}
63 65
 		$smcFunc['db_free_result']($request);
64 66
 
65 67
 		// And now weed out the duplicates.
@@ -81,9 +83,10 @@  discard block
 block discarded – undo
81 83
 
82 84
 		foreach ($prefs as $member => $pref_option)
83 85
 		{
84
-			foreach ($alert_bits as $type => $bitvalue)
85
-				if ($pref_option['msg_report'] & $bitvalue)
86
+			foreach ($alert_bits as $type => $bitvalue) {
87
+							if ($pref_option['msg_report'] & $bitvalue)
86 88
 					$notifies[$type][] = $member;
89
+			}
87 90
 		}
88 91
 
89 92
 		// Firstly, anyone who wants alerts.
@@ -143,8 +146,9 @@  discard block
 block discarded – undo
143 146
 			);
144 147
 			while ($row = $smcFunc['db_fetch_assoc']($request))
145 148
 			{
146
-				if (empty($row['lngfile']))
147
-					$row['lngfile'] = $language;
149
+				if (empty($row['lngfile'])) {
150
+									$row['lngfile'] = $language;
151
+				}
148 152
 				$emails[$row['lngfile']][$row['id_member']] = $row['email_address'];
149 153
 			}
150 154
 			$smcFunc['db_free_result']($request);
@@ -177,8 +181,9 @@  discard block
 block discarded – undo
177 181
 				$emaildata = loadEmailTemplate('report_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang);
178 182
 
179 183
 				// And do the actual sending...
180
-				foreach ($recipients as $id_member => $email_address)
181
-					sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'report' . $this->_details['report_id'], $emaildata['is_html'], 2);
184
+				foreach ($recipients as $id_member => $email_address) {
185
+									sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'report' . $this->_details['report_id'], $emaildata['is_html'], 2);
186
+				}
182 187
 			}
183 188
 		}
184 189
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 class Likes_Notify_Background extends SMF_BackgroundTask
20 20
 {
21 21
 	/**
22
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
22
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23 23
 	 * @return bool Always returns true
24 24
 	 */
25 25
 	public function execute()
Please login to merge, or discard this patch.
Sources/tasks/Buddy-Notify.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 class Buddy_Notify_Background extends SMF_BackgroundTask
20 20
 {
21 21
 	/**
22
-     * This executes the task - loads up the info, sets the alerts and loads up the email queue.
22
+	 * This executes the task - loads up the info, sets the alerts and loads up the email queue.
23 23
 	 * @return bool Always returns true
24 24
 	 */
25 25
 	public function execute()
Please login to merge, or discard this patch.
Sources/tasks/GroupReq-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 class GroupReq_Notify_Background extends SMF_BackgroundTask
21 21
 {
22 22
 	/**
23
-     * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed.
23
+	 * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed.
24 24
 	 * @return bool Always returns true.
25 25
 	 */
26 26
 	public function execute()
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@  discard block
 block discarded – undo
37 37
 			)
38 38
 		);
39 39
 		$moderators = array();
40
-		while ($row = $smcFunc['db_fetch_assoc']($request))
41
-			$moderators[] = $row['id_member'];
40
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
41
+					$moderators[] = $row['id_member'];
42
+		}
42 43
 		$smcFunc['db_free_result']($request);
43 44
 
44 45
 		require_once($sourcedir . '/Subs-Members.php');
@@ -59,11 +60,13 @@  discard block
 block discarded – undo
59 60
 			{
60 61
 				if (!empty($prefs[$mod]['request_group']))
61 62
 				{
62
-					if ($prefs[$mod]['request_group'] & 0x01)
63
-						$data['alert'][] = $mod;
63
+					if ($prefs[$mod]['request_group'] & 0x01) {
64
+											$data['alert'][] = $mod;
65
+					}
64 66
 
65
-					if ($prefs[$mod]['request_group'] & 0x02)
66
-						$data['email'][] = $mod;
67
+					if ($prefs[$mod]['request_group'] & 0x02) {
68
+											$data['email'][] = $mod;
69
+					}
67 70
 				}
68 71
 			}
69 72
 
Please login to merge, or discard this patch.
Sources/tasks/GroupAct-Notify.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
  */
20 20
 class GroupAct_Notify_Background extends SMF_BackgroundTask
21 21
 {
22
-    /**
23
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24
-     * @return bool Always returns true
25
-     */
22
+	/**
23
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24
+	 * @return bool Always returns true
25
+	 */
26 26
 	public function execute()
27 27
 	{
28 28
 		global $sourcedir, $smcFunc, $language, $modSettings;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
 			// Same as for approving, kind of.
104 104
 			foreach ($affected_users as $user)
105 105
 			{
106
-				$pref = !empty($prefs[$user['member_id']]['groupr_' . $pref_name]) ? $prefs[$user['member_id']]['groupr_'. $pref_name] : 0;
106
+				$pref = !empty($prefs[$user['member_id']]['groupr_' . $pref_name]) ? $prefs[$user['member_id']]['groupr_' . $pref_name] : 0;
107 107
 				$custom_reason = isset($this->_details['reason']) && isset($this->_details['reason'][$user['rid']]) ? $this->_details['reason'][$user['rid']] : '';
108 108
 
109 109
 				if ($pref & 0x01)
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,8 +132,9 @@  discard block
 block discarded – undo
132 132
 						'GROUPNAME' => $user['group_name'],
133 133
 					);
134 134
 
135
-					if (!empty($custom_reason))
136
-						$replacements['REASON'] = $custom_reason;
135
+					if (!empty($custom_reason)) {
136
+											$replacements['REASON'] = $custom_reason;
137
+					}
137 138
 
138 139
 					$emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']);
139 140
 
@@ -142,8 +143,8 @@  discard block
 block discarded – undo
142 143
 			}
143 144
 
144 145
 			// Insert the alerts if any
145
-			if (!empty($alert_rows))
146
-				$smcFunc['db_insert']('',
146
+			if (!empty($alert_rows)) {
147
+							$smcFunc['db_insert']('',
147 148
 					'{db_prefix}user_alerts',
148 149
 					array(
149 150
 						'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string',
@@ -152,6 +153,7 @@  discard block
 block discarded – undo
152 153
 					$alert_rows,
153 154
 					array()
154 155
 				);
156
+			}
155 157
 		}
156 158
 
157 159
 		return true;
Please login to merge, or discard this patch.
Sources/tasks/Likes-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 class Likes_Notify_Background extends SMF_BackgroundTask
20 20
 {
21 21
 	/**
22
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
22
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23 23
 	 * @return bool Always returns true
24 24
 	 */
25 25
 	public function execute()
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,30 +49,33 @@  discard block
 block discarded – undo
49 49
 				$allowed = explode(',', $row['member_groups']);
50 50
 
51 51
 				// If the user is in group 1 anywhere, they can see everything anyway.
52
-				if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0)
53
-					$author = $row['id_member'];
52
+				if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) {
53
+									$author = $row['id_member'];
54
+				}
54 55
 			}
55 56
 			$smcFunc['db_free_result']($request);
56
-		}
57
-		else
57
+		} else
58 58
 		{
59 59
 			// This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id.
60 60
 			$hook_results = call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id']));
61
-			foreach ($hook_results as $result)
62
-				if (!empty($result))
61
+			foreach ($hook_results as $result) {
62
+							if (!empty($result))
63 63
 				{
64 64
 					$author = $result;
65
+			}
65 66
 					break;
66 67
 				}
67 68
 		}
68 69
 
69 70
 		// If we didn't have a member... leave.
70
-		if (empty($author))
71
-			return true;
71
+		if (empty($author)) {
72
+					return true;
73
+		}
72 74
 
73 75
 		// If the person who sent the notification is the person whose content it is, do nothing.
74
-		if ($author == $this->_details['sender_id'])
75
-			return true;
76
+		if ($author == $this->_details['sender_id']) {
77
+					return true;
78
+		}
76 79
 
77 80
 		require_once($sourcedir . '/Subs-Notify.php');
78 81
 		$prefs = getNotifyPrefs($author, $this->_details['content_type'] . '_like', true);
@@ -81,8 +84,9 @@  discard block
 block discarded – undo
81 84
 		// As a result, the value should really just be non empty.
82 85
 
83 86
 		// Check the value. If no value or it's empty, they didn't want alerts, oh well.
84
-		if (empty($prefs[$author][$this->_details['content_type'] . '_like']))
85
-			return true;
87
+		if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) {
88
+					return true;
89
+		}
86 90
 
87 91
 		// Don't spam the alerts: if there is an existing unread alert of the
88 92
 		// requested type for the target user from the sender, don't make a new one.
@@ -102,8 +106,9 @@  discard block
 block discarded – undo
102 106
 			)
103 107
 		);
104 108
 
105
-		if ($smcFunc['db_num_rows']($request) > 0)
106
-			return true;
109
+		if ($smcFunc['db_num_rows']($request) > 0) {
110
+					return true;
111
+		}
107 112
 		$smcFunc['db_free_result']($request);
108 113
 
109 114
 		// Issue, update, move on.
Please login to merge, or discard this patch.
Sources/DbPackages-mysql.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	// Righty - let's do the damn thing!
126 126
 	$table_query = 'CREATE TABLE ' . $table_name . "\n" . '(';
127 127
 	foreach ($columns as $column)
128
-		$table_query .= "\n\t" . smf_db_create_query_column($column)  . ',';
128
+		$table_query .= "\n\t" . smf_db_create_query_column($column) . ',';
129 129
 
130 130
 	// Loop through the indexes next...
131 131
 	foreach ($indexes as $index)
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 		$type = $type . '(' . $size . ')';
745 745
 
746 746
 	// Now just put it together!
747
-	return '`' .$column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default;
747
+	return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default;
748 748
 }
749 749
 
750 750
 ?>
751 751
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +127 added lines, -101 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Add the file functions to the $smcFunc array.
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
 		'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages',
53 54
 		'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys',
54 55
 		'themes', 'topics');
55
-	foreach ($reservedTables as $k => $table_name)
56
-		$reservedTables[$k] = strtolower($db_prefix . $table_name);
56
+	foreach ($reservedTables as $k => $table_name) {
57
+			$reservedTables[$k] = strtolower($db_prefix . $table_name);
58
+	}
57 59
 
58 60
 	// We in turn may need the extra stuff.
59 61
 	db_extend('extra');
@@ -105,8 +107,9 @@  discard block
 block discarded – undo
105 107
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
106 108
 
107 109
 	// First - no way do we touch SMF tables.
108
-	if (in_array(strtolower($table_name), $reservedTables))
109
-		return false;
110
+	if (in_array(strtolower($table_name), $reservedTables)) {
111
+			return false;
112
+	}
110 113
 
111 114
 	// Log that we'll want to remove this on uninstall.
112 115
 	$db_package_log[] = array('remove_table', $table_name);
@@ -116,16 +119,18 @@  discard block
 block discarded – undo
116 119
 	if (in_array($full_table_name, $tables))
117 120
 	{
118 121
 		// This is a sad day... drop the table? If not, return false (error) by default.
119
-		if ($if_exists == 'overwrite')
120
-			$smcFunc['db_drop_table']($table_name);
121
-		else
122
-			return $if_exists == 'ignore';
122
+		if ($if_exists == 'overwrite') {
123
+					$smcFunc['db_drop_table']($table_name);
124
+		} else {
125
+					return $if_exists == 'ignore';
126
+		}
123 127
 	}
124 128
 
125 129
 	// Righty - let's do the damn thing!
126 130
 	$table_query = 'CREATE TABLE ' . $table_name . "\n" . '(';
127
-	foreach ($columns as $column)
128
-		$table_query .= "\n\t" . smf_db_create_query_column($column)  . ',';
131
+	foreach ($columns as $column) {
132
+			$table_query .= "\n\t" . smf_db_create_query_column($column)  . ',';
133
+	}
129 134
 
130 135
 	// Loop through the indexes next...
131 136
 	foreach ($indexes as $index)
@@ -133,19 +138,21 @@  discard block
 block discarded – undo
133 138
 		$columns = implode(',', $index['columns']);
134 139
 
135 140
 		// Is it the primary?
136
-		if (isset($index['type']) && $index['type'] == 'primary')
137
-			$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
138
-		else
141
+		if (isset($index['type']) && $index['type'] == 'primary') {
142
+					$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
143
+		} else
139 144
 		{
140
-			if (empty($index['name']))
141
-				$index['name'] = implode('_', $index['columns']);
145
+			if (empty($index['name'])) {
146
+							$index['name'] = implode('_', $index['columns']);
147
+			}
142 148
 			$table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),';
143 149
 		}
144 150
 	}
145 151
 
146 152
 	// No trailing commas!
147
-	if (substr($table_query, -1) == ',')
148
-		$table_query = substr($table_query, 0, -1);
153
+	if (substr($table_query, -1) == ',') {
154
+			$table_query = substr($table_query, 0, -1);
155
+	}
149 156
 
150 157
 	// Which engine do we want here?
151 158
 	if (empty($engines))
@@ -155,8 +162,9 @@  discard block
 block discarded – undo
155 162
 
156 163
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
157 164
 		{
158
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
159
-				$engines[] = $row['Engine'];
165
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
166
+							$engines[] = $row['Engine'];
167
+			}
160 168
 		}
161 169
 
162 170
 		$smcFunc['db_free_result']($get_engines);
@@ -170,8 +178,9 @@  discard block
 block discarded – undo
170 178
 	}
171 179
 
172 180
 	$table_query .= ') ENGINE=' . $parameters['engine'];
173
-	if (!empty($db_character_set) && $db_character_set == 'utf8')
174
-		$table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
181
+	if (!empty($db_character_set) && $db_character_set == 'utf8') {
182
+			$table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
183
+	}
175 184
 
176 185
 	// Create the table!
177 186
 	$smcFunc['db_query']('', $table_query,
@@ -203,8 +212,9 @@  discard block
 block discarded – undo
203 212
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
204 213
 
205 214
 	// God no - dropping one of these = bad.
206
-	if (in_array(strtolower($table_name), $reservedTables))
207
-		return false;
215
+	if (in_array(strtolower($table_name), $reservedTables)) {
216
+			return false;
217
+	}
208 218
 
209 219
 	// Does it exist?
210 220
 	if (in_array($full_table_name, $smcFunc['db_list_tables']()))
@@ -245,14 +255,16 @@  discard block
 block discarded – undo
245 255
 
246 256
 	// Does it exist - if so don't add it again!
247 257
 	$columns = $smcFunc['db_list_columns']($table_name, false);
248
-	foreach ($columns as $column)
249
-		if ($column == $column_info['name'])
258
+	foreach ($columns as $column) {
259
+			if ($column == $column_info['name'])
250 260
 		{
251 261
 			// If we're going to overwrite then use change column.
252 262
 			if ($if_exists == 'update')
253 263
 				return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
254
-			else
255
-				return false;
264
+	}
265
+			else {
266
+							return false;
267
+			}
256 268
 		}
257 269
 
258 270
 	// Get the specifics...
@@ -262,8 +274,9 @@  discard block
 block discarded – undo
262 274
 	// Allow unsigned integers (mysql only)
263 275
 	$unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : '';
264 276
 
265
-	if ($size !== null)
266
-		$type = $type . '(' . $size . ')';
277
+	if ($size !== null) {
278
+			$type = $type . '(' . $size . ')';
279
+	}
267 280
 
268 281
 	// Now add the thing!
269 282
 	$query = '
@@ -295,8 +308,8 @@  discard block
 block discarded – undo
295 308
 
296 309
 	// Does it exist?
297 310
 	$columns = $smcFunc['db_list_columns']($table_name, true);
298
-	foreach ($columns as $column)
299
-		if ($column['name'] == $column_name)
311
+	foreach ($columns as $column) {
312
+			if ($column['name'] == $column_name)
300 313
 		{
301 314
 			$smcFunc['db_query']('', '
302 315
 				ALTER TABLE ' . $table_name . '
@@ -305,6 +318,7 @@  discard block
 block discarded – undo
305 318
 					'security_override' => true,
306 319
 				)
307 320
 			);
321
+	}
308 322
 
309 323
 			return true;
310 324
 		}
@@ -331,37 +345,47 @@  discard block
 block discarded – undo
331 345
 	// Check it does exist!
332 346
 	$columns = $smcFunc['db_list_columns']($table_name, true);
333 347
 	$old_info = null;
334
-	foreach ($columns as $column)
335
-		if ($column['name'] == $old_column)
348
+	foreach ($columns as $column) {
349
+			if ($column['name'] == $old_column)
336 350
 			$old_info = $column;
351
+	}
337 352
 
338 353
 	// Nothing?
339
-	if ($old_info == null)
340
-		return false;
354
+	if ($old_info == null) {
355
+			return false;
356
+	}
341 357
 
342 358
 	// Get the right bits.
343
-	if (!isset($column_info['name']))
344
-		$column_info['name'] = $old_column;
345
-	if (!isset($column_info['default']))
346
-		$column_info['default'] = $old_info['default'];
347
-	if (!isset($column_info['null']))
348
-		$column_info['null'] = $old_info['null'];
349
-	if (!isset($column_info['auto']))
350
-		$column_info['auto'] = $old_info['auto'];
351
-	if (!isset($column_info['type']))
352
-		$column_info['type'] = $old_info['type'];
353
-	if (!isset($column_info['size']) || !is_numeric($column_info['size']))
354
-		$column_info['size'] = $old_info['size'];
355
-	if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')))
356
-		$column_info['unsigned'] = '';
359
+	if (!isset($column_info['name'])) {
360
+			$column_info['name'] = $old_column;
361
+	}
362
+	if (!isset($column_info['default'])) {
363
+			$column_info['default'] = $old_info['default'];
364
+	}
365
+	if (!isset($column_info['null'])) {
366
+			$column_info['null'] = $old_info['null'];
367
+	}
368
+	if (!isset($column_info['auto'])) {
369
+			$column_info['auto'] = $old_info['auto'];
370
+	}
371
+	if (!isset($column_info['type'])) {
372
+			$column_info['type'] = $old_info['type'];
373
+	}
374
+	if (!isset($column_info['size']) || !is_numeric($column_info['size'])) {
375
+			$column_info['size'] = $old_info['size'];
376
+	}
377
+	if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) {
378
+			$column_info['unsigned'] = '';
379
+	}
357 380
 
358 381
 	list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
359 382
 
360 383
 	// Allow for unsigned integers (mysql only)
361 384
 	$unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : '';
362 385
 
363
-	if ($size !== null)
364
-		$type = $type . '(' . $size . ')';
386
+	if ($size !== null) {
387
+			$type = $type . '(' . $size . ')';
388
+	}
365 389
 
366 390
 	$smcFunc['db_query']('', '
367 391
 		ALTER TABLE ' . $table_name . '
@@ -391,21 +415,23 @@  discard block
 block discarded – undo
391 415
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
392 416
 
393 417
 	// No columns = no index.
394
-	if (empty($index_info['columns']))
395
-		return false;
418
+	if (empty($index_info['columns'])) {
419
+			return false;
420
+	}
396 421
 	$columns = implode(',', $index_info['columns']);
397 422
 
398 423
 	// No name - make it up!
399 424
 	if (empty($index_info['name']))
400 425
 	{
401 426
 		// No need for primary.
402
-		if (isset($index_info['type']) && $index_info['type'] == 'primary')
403
-			$index_info['name'] = '';
404
-		else
405
-			$index_info['name'] = implode('_', $index_info['columns']);
427
+		if (isset($index_info['type']) && $index_info['type'] == 'primary') {
428
+					$index_info['name'] = '';
429
+		} else {
430
+					$index_info['name'] = implode('_', $index_info['columns']);
431
+		}
432
+	} else {
433
+			$index_info['name'] = $index_info['name'];
406 434
 	}
407
-	else
408
-		$index_info['name'] = $index_info['name'];
409 435
 
410 436
 	// Log that we are going to want to remove this!
411 437
 	$db_package_log[] = array('remove_index', $table_name, $index_info['name']);
@@ -418,10 +444,11 @@  discard block
 block discarded – undo
418 444
 		if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary'))
419 445
 		{
420 446
 			// If we want to overwrite simply remove the current one then continue.
421
-			if ($if_exists != 'update' || $index['type'] == 'primary')
422
-				return false;
423
-			else
424
-				$smcFunc['db_remove_index']($table_name, $index_info['name']);
447
+			if ($if_exists != 'update' || $index['type'] == 'primary') {
448
+							return false;
449
+			} else {
450
+							$smcFunc['db_remove_index']($table_name, $index_info['name']);
451
+			}
425 452
 		}
426 453
 	}
427 454
 
@@ -435,8 +462,7 @@  discard block
 block discarded – undo
435 462
 				'security_override' => true,
436 463
 			)
437 464
 		);
438
-	}
439
-	else
465
+	} else
440 466
 	{
441 467
 		$smcFunc['db_query']('', '
442 468
 			ALTER TABLE ' . $table_name . '
@@ -520,8 +546,7 @@  discard block
 block discarded – undo
520 546
 		$types = array(
521 547
 			'inet' => 'varbinary',
522 548
 		);
523
-	}
524
-	else
549
+	} else
525 550
 	{
526 551
 		$types = array(
527 552
 			'varbinary' => 'inet',
@@ -535,16 +560,15 @@  discard block
 block discarded – undo
535 560
 		{
536 561
 			$type_size = 16;
537 562
 			$type_name = 'varbinary';
538
-		}
539
-		elseif ($type_name == 'varbinary' && $reverse && $type_size == 16)
563
+		} elseif ($type_name == 'varbinary' && $reverse && $type_size == 16)
540 564
 		{
541 565
 			$type_name = 'inet';
542 566
 			$type_size = null;
567
+		} elseif ($type_name == 'varbinary') {
568
+					$type_name = 'varbinary';
569
+		} else {
570
+					$type_name = $types[$type_name];
543 571
 		}
544
-		elseif ($type_name == 'varbinary')
545
-			$type_name = 'varbinary';
546
-		else
547
-			$type_name = $types[$type_name];
548 572
 	}
549 573
 
550 574
 	return array($type_name, $type_size);
@@ -612,8 +636,7 @@  discard block
 block discarded – undo
612 636
 		if (!$detail)
613 637
 		{
614 638
 			$columns[] = $row['Field'];
615
-		}
616
-		else
639
+		} else
617 640
 		{
618 641
 			// Is there an auto_increment?
619 642
 			$auto = strpos($row['Extra'], 'auto_increment') !== false ? true : false;
@@ -623,10 +646,10 @@  discard block
 block discarded – undo
623 646
 			{
624 647
 				$type = $matches[1];
625 648
 				$size = $matches[2];
626
-				if (!empty($matches[3]) && $matches[3] == 'unsigned')
627
-					$unsigned = true;
628
-			}
629
-			else
649
+				if (!empty($matches[3]) && $matches[3] == 'unsigned') {
650
+									$unsigned = true;
651
+				}
652
+			} else
630 653
 			{
631 654
 				$type = $row['Type'];
632 655
 				$size = null;
@@ -677,19 +700,20 @@  discard block
 block discarded – undo
677 700
 	$indexes = array();
678 701
 	while ($row = $smcFunc['db_fetch_assoc']($result))
679 702
 	{
680
-		if (!$detail)
681
-			$indexes[] = $row['Key_name'];
682
-		else
703
+		if (!$detail) {
704
+					$indexes[] = $row['Key_name'];
705
+		} else
683 706
 		{
684 707
 			// What is the type?
685
-			if ($row['Key_name'] == 'PRIMARY')
686
-				$type = 'primary';
687
-			elseif (empty($row['Non_unique']))
688
-				$type = 'unique';
689
-			elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT')
690
-				$type = 'fulltext';
691
-			else
692
-				$type = 'index';
708
+			if ($row['Key_name'] == 'PRIMARY') {
709
+							$type = 'primary';
710
+			} elseif (empty($row['Non_unique'])) {
711
+							$type = 'unique';
712
+			} elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') {
713
+							$type = 'fulltext';
714
+			} else {
715
+							$type = 'index';
716
+			}
693 717
 
694 718
 			// This is the first column we've seen?
695 719
 			if (empty($indexes[$row['Key_name']]))
@@ -702,10 +726,11 @@  discard block
 block discarded – undo
702 726
 			}
703 727
 
704 728
 			// Is it a partial index?
705
-			if (!empty($row['Sub_part']))
706
-				$indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')';
707
-			else
708
-				$indexes[$row['Key_name']]['columns'][] = $row['Column_name'];
729
+			if (!empty($row['Sub_part'])) {
730
+							$indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')';
731
+			} else {
732
+							$indexes[$row['Key_name']]['columns'][] = $row['Column_name'];
733
+			}
709 734
 		}
710 735
 	}
711 736
 	$smcFunc['db_free_result']($result);
@@ -727,11 +752,11 @@  discard block
 block discarded – undo
727 752
 	if (!empty($column['auto']))
728 753
 	{
729 754
 		$default = 'auto_increment';
755
+	} elseif (isset($column['default']) && $column['default'] !== null) {
756
+			$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
757
+	} else {
758
+			$default = '';
730 759
 	}
731
-	elseif (isset($column['default']) && $column['default'] !== null)
732
-		$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
733
-	else
734
-		$default = '';
735 760
 
736 761
 	// Sort out the size... and stuff...
737 762
 	$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
@@ -740,8 +765,9 @@  discard block
 block discarded – undo
740 765
 	// Allow unsigned integers (mysql only)
741 766
 	$unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : '';
742 767
 
743
-	if ($size !== null)
744
-		$type = $type . '(' . $size . ')';
768
+	if ($size !== null) {
769
+			$type = $type . '(' . $size . ')';
770
+	}
745 771
 
746 772
 	// Now just put it together!
747 773
 	return '`' .$column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -518,7 +518,7 @@
 block discarded – undo
518 518
  * @param array $parameters Not used?
519 519
  * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated.
520 520
  * @param string $error
521
- * @return boolean Whether or not the operation was successful
521
+ * @return false|null Whether or not the operation was successful
522 522
  */
523 523
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
524 524
 {
Please login to merge, or discard this patch.