Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
infolog/inc/class.infolog_tracking.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,6 @@
 block discarded – undo
125 125
 	/**
126 126
 	 * Constructor
127 127
 	 *
128
-	 * @param botracker $botracker
129 128
 	 * @return tracker_tracking
130 129
 	 */
131 130
 	function __construct(&$infolog_bo)
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	function __construct(&$infolog_bo)
130 130
 	{
131
-		parent::__construct('infolog');	// add custom fields from infolog
131
+		parent::__construct('infolog'); // add custom fields from infolog
132 132
 
133
-		$this->infolog =& $infolog_bo;
133
+		$this->infolog = & $infolog_bo;
134 134
 	}
135 135
 
136 136
 	/**
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
 	 * @param array $old
143 143
 	 * @return string
144 144
 	 */
145
-	function get_subject($data,$old)
145
+	function get_subject($data, $old)
146 146
 	{
147 147
 		if ($data['prefix'])
148 148
 		{
149
-			$prefix = $data['prefix'];	// async notification
149
+			$prefix = $data['prefix']; // async notification
150 150
 		}
151 151
 		elseif (!$old || $old['info_status'] == 'deleted')
152 152
 		{
153
-			$prefix = lang('New %1',lang($this->infolog->enums['type'][$data['info_type']]));
153
+			$prefix = lang('New %1', lang($this->infolog->enums['type'][$data['info_type']]));
154 154
 		}
155
-		elseif($data['info_status'] == 'deleted')
155
+		elseif ($data['info_status'] == 'deleted')
156 156
 		{
157
-			$prefix = lang('%1 deleted',lang($this->infolog->enums['type'][$data['info_type']]));
157
+			$prefix = lang('%1 deleted', lang($this->infolog->enums['type'][$data['info_type']]));
158 158
 		}
159 159
 		else
160 160
 		{
161
-			$prefix = lang('%1 modified',lang($this->infolog->enums['type'][$data['info_type']]));
161
+			$prefix = lang('%1 modified', lang($this->infolog->enums['type'][$data['info_type']]));
162 162
 		}
163 163
 		return $prefix.': '.$data['info_subject'];
164 164
 	}
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
 	 * @param array $old
171 171
 	 * @return string
172 172
 	 */
173
-	function get_message($data,$old)
173
+	function get_message($data, $old)
174 174
 	{
175
-		if ($data['message']) return $data['message'];	// async notification
175
+		if ($data['message']) return $data['message']; // async notification
176 176
 
177 177
 		if (!$old || $old['info_status'] == 'deleted')
178 178
 		{
179
-			return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
180
-				Api\Accounts::username($this->infolog->user),$this->datetime('now'));
179
+			return lang('New %1 created by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
180
+				Api\Accounts::username($this->infolog->user), $this->datetime('now'));
181 181
 		}
182
-		elseif($data['info_status'] == 'deleted')
182
+		elseif ($data['info_status'] == 'deleted')
183 183
 		{
184
-			return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
184
+			return lang('%1 deleted by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
185 185
 				Api\Accounts::username($data['info_modifier']),
186 186
 				$this->datetime($data['info_datemodified']));
187 187
 		}
188
-		return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
188
+		return lang('%1 modified by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
189 189
 			Api\Accounts::username($data['info_modifier']),
190 190
 			$this->datetime($data['info_datemodified']));
191 191
 	}
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 	 * @param int|string $receiver nummeric account_id or email address
198 198
 	 * @return array of details as array with values for keys 'label','value','type'
199 199
 	 */
200
-	function get_details($data,$receiver=null)
200
+	function get_details($data, $receiver = null)
201 201
 	{
202 202
 		//error_log(__METHOD__.__LINE__.' Data:'.array2string($data));
203 203
 		$responsible = array();
204 204
 		if ($data['info_responsible'])
205 205
 		{
206
-			foreach($data['info_responsible'] as $uid)
206
+			foreach ($data['info_responsible'] as $uid)
207 207
 			{
208 208
 				$responsible[] = Api\Accounts::username($uid);
209 209
 			}
@@ -212,32 +212,32 @@  discard block
 block discarded – undo
212 212
 		{
213 213
 			$id = ' #'.$data['info_id'];
214 214
 		}
215
-		foreach(array(
215
+		foreach (array(
216 216
 			'info_type'      => lang($this->infolog->enums['type'][$data['info_type']]).$id,
217 217
 			'info_from'      => $data['info_from'],
218 218
 			'info_cat'       => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '',
219 219
 			'info_priority'  => lang($this->infolog->enums['priority'][$data['info_priority']]),
220 220
 			'info_owner'     => Api\Accounts::username($data['info_owner']),
221
-			'info_status'    => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]),
221
+			'info_status'    => lang($data['info_status'] == 'deleted' ? 'deleted' : $this->infolog->status[$data['info_type']][$data['info_status']]),
222 222
 			'info_percent'   => (int)$data['info_percent'].'%',
223 223
 			'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '',
224 224
 			'info_location'  => $data['info_location'],
225
-			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'],null) : '',
226
-			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'],null) : '',
227
-			'info_responsible' => implode(', ',$responsible),
225
+			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'], null) : '',
226
+			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'], null) : '',
227
+			'info_responsible' => implode(', ', $responsible),
228 228
 			'info_subject'   => $data['info_subject'],
229 229
 		) as $name => $value)
230 230
 		{
231 231
 			//error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value));
232
-			if ($name=='info_from' && empty($value))
232
+			if ($name == 'info_from' && empty($value))
233 233
 			{
234
-				if(!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
234
+				if (!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
235 235
 				{
236 236
 					$lkeys = array_keys($data['link_to']['to_id']);
237
-					if (in_array($data['info_contact'],$lkeys))
237
+					if (in_array($data['info_contact'], $lkeys))
238 238
 					{
239
-						list($app,$id) = explode(':',$data['info_contact']);
240
-						if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
239
+						list($app, $id) = explode(':', $data['info_contact']);
240
+						if (!empty($app) && !empty($id)) $value = Link::title($app, $id);
241 241
 					}
242 242
 				}
243 243
 				else if ($data['info_link_id'])
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 * @param boolean $skip_notification = false do NOT send any notification
276 276
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
277 277
 	 */
278
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
278
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
279 279
 	{
280 280
 		//error_log(__METHOD__.__LINE__.' notify?'.($skip_notification?'no':'yes').function_backtrace());
281 281
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -284,23 +284,23 @@  discard block
 block discarded – undo
284 284
 
285 285
 		if ($old && $this->field2history)
286 286
 		{
287
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
287
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
288 288
 		}
289 289
 
290 290
 		// Don't notify if the only change was to the modified date
291
-		if(is_null($changed_fields))
291
+		if (is_null($changed_fields))
292 292
 		{
293 293
 			$changed_fields = $this->changed_fields($data, $old);
294 294
 			$changes = count($changed_fields); // we need that since TRUE evaluates to 1
295 295
 		}
296 296
 		//error_log(__METHOD__.__LINE__.array2string($changed_fields));
297
-		if(is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
297
+		if (is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
298 298
 		{
299 299
 			return count($changes);
300 300
 		}
301 301
 
302 302
 		// do not run do_notifications if we have no changes
303
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
303
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
304 304
 		{
305 305
 			$changes = false;
306 306
 		}
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 	 * @param array $old = null old/last state of the entry or null for a new entry
319 319
 	 * @return mixed
320 320
 	 */
321
-	function get_config($name,$data,$old=null)
321
+	function get_config($name, $data, $old = null)
322 322
 	{
323
-		unset($old);	// not used, but required function signature
324
-		switch($name)
323
+		unset($old); // not used, but required function signature
324
+		switch ($name)
325 325
 		{
326 326
 			case 'copy':	// include the info_cc addresses
327
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
327
+				if ($data['info_access'] == 'private') return array(); // no copies for private entries
328 328
 				if ($data['info_cc'])
329 329
 				{
330
-					$config = preg_split('/, ?/',$data['info_cc']);
330
+					$config = preg_split('/, ?/', $data['info_cc']);
331 331
 				}
332 332
 				else
333 333
 				{
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				break;
337 337
 			case self::CUSTOM_NOTIFICATION:
338 338
 				$info_config = Api\Config::read('infolog');
339
-				if(!$info_config[self::CUSTOM_NOTIFICATION])
339
+				if (!$info_config[self::CUSTOM_NOTIFICATION])
340 340
 				{
341 341
 					return '';
342 342
 				}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
346 346
 
347 347
 				// Disabled
348
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
348
+				if (!$type_config['use_custom'] && !$global['use_custom']) return '';
349 349
 
350 350
 				// Type or globabl
351 351
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
Braces   +26 added lines, -6 removed lines patch added patch discarded remove patch
@@ -172,7 +172,11 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	function get_message($data,$old)
174 174
 	{
175
-		if ($data['message']) return $data['message'];	// async notification
175
+		if ($data['message'])
176
+		{
177
+			return $data['message'];
178
+		}
179
+		// async notification
176 180
 
177 181
 		if (!$old || $old['info_status'] == 'deleted')
178 182
 		{
@@ -237,20 +241,29 @@  discard block
 block discarded – undo
237 241
 					if (in_array($data['info_contact'],$lkeys))
238 242
 					{
239 243
 						list($app,$id) = explode(':',$data['info_contact']);
240
-						if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
244
+						if (!empty($app)&&!empty($id))
245
+						{
246
+							$value = Link::title($app,$id);
247
+						}
241 248
 					}
242 249
 				}
243 250
 				else if ($data['info_link_id'])
244 251
 				{
245 252
 					$this->infolog->link_id2from($data);
246
-					if (is_array($data['info_contact'])) $value = $data['info_contact']['title'];
253
+					if (is_array($data['info_contact']))
254
+					{
255
+						$value = $data['info_contact']['title'];
256
+					}
247 257
 				}
248 258
 			}
249 259
 			$details[$name] = array(
250 260
 				'label' => lang($this->field2label[$name]),
251 261
 				'value' => $value,
252 262
 			);
253
-			if ($name == 'info_subject') $details[$name]['type'] = 'summary';
263
+			if ($name == 'info_subject')
264
+			{
265
+				$details[$name]['type'] = 'summary';
266
+			}
254 267
 		}
255 268
 		$details['info_des'] = array(
256 269
 			'value' => $data['info_des'],
@@ -324,7 +337,11 @@  discard block
 block discarded – undo
324 337
 		switch($name)
325 338
 		{
326 339
 			case 'copy':	// include the info_cc addresses
327
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
340
+				if ($data['info_access'] == 'private')
341
+				{
342
+					return array();
343
+				}
344
+				// no copies for private entries
328 345
 				if ($data['info_cc'])
329 346
 				{
330 347
 					$config = preg_split('/, ?/',$data['info_cc']);
@@ -345,7 +362,10 @@  discard block
 block discarded – undo
345 362
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
346 363
 
347 364
 				// Disabled
348
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
365
+				if(!$type_config['use_custom'] && !$global['use_custom'])
366
+				{
367
+					return '';
368
+				}
349 369
 
350 370
 				// Type or globabl
351 371
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
json.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  * callback if the session-check fails, redirects to login.php, if no valid basic auth credentials given
19 19
  *
20 20
  * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
21
- * @return boolean|string true if we allow anon access and anon_account is set, a sessionid or false otherwise
21
+ * @return string|null true if we allow anon access and anon_account is set, a sessionid or false otherwise
22 22
  */
23 23
 function login_redirect(&$anon_account)
24 24
 {
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,9 +73,12 @@
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['menuaction']))
75 75
 {
76
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
76
+	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)
77
+	{
78
+		// static method name app_something::method
77 79
 	{
78 80
 		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
81
+	}
79 82
 
80 83
 		if (substr($className, 0, 11) == 'EGroupware\\')
81 84
 		{
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		return $session_id;
29 29
 	}
30
-	Json\Request::isJSONRequest(true);	// because Api\Json\Request::parseRequest() is not (yet) called
30
+	Json\Request::isJSONRequest(true); // because Api\Json\Request::parseRequest() is not (yet) called
31 31
 	$response = Json\Response::get();
32 32
 	$response->redirect($GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10', true);
33 33
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	$message = null;
53 53
 	if (function_exists('_egw_log_exception'))
54 54
 	{
55
-		_egw_log_exception($e,$message);
55
+		_egw_log_exception($e, $message);
56 56
 	}
57 57
 	$response = Json\Response::get();
58 58
 	$message .= ($message ? "\n\n" : '').$e->getMessage();
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 
73 73
 if (isset($_GET['menuaction']))
74 74
 {
75
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
75
+	if (strpos($_GET['menuaction'], '::') !== false && strpos($_GET['menuaction'], '.') === false)	// static method name app_something::method
76 76
 	{
77
-		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
77
+		@list($className, $functionName, $handler) = explode('::', $_GET['menuaction']);
78 78
 
79 79
 		if (substr($className, 0, 11) == 'EGroupware\\')
80 80
 		{
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 		}
83 83
 		else
84 84
 		{
85
-			list($appName) = explode('_',$className);
85
+			list($appName) = explode('_', $className);
86 86
 		}
87 87
 	}
88 88
 	else
89 89
 	{
90
-		@list($appName, $className, $functionName, $handler) = explode('.',$_GET['menuaction']);
90
+		@list($appName, $className, $functionName, $handler) = explode('.', $_GET['menuaction']);
91 91
 	}
92 92
 	//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
93 93
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'noheader'		=> True,
98 98
 			'disable_Template_class'	=> True,
99 99
 			'autocreate_session_callback' => 'login_redirect',
100
-			'no_exception_handler' => true,	// we already installed our own
100
+			'no_exception_handler' => true, // we already installed our own
101 101
 			// only log ajax requests which represent former GET requests or submits
102 102
 			// cuts down updates to egw_access_log table
103 103
 			'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']),
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	//Check whether the request data is set
113 113
 	if (isset($GLOBALS['egw_unset_vars']['_POST[json_data]']))
114 114
 	{
115
-		$json->isJSONRequest(true);	// otherwise exception is not send back to client, as we have not yet called parseRequest()
115
+		$json->isJSONRequest(true); // otherwise exception is not send back to client, as we have not yet called parseRequest()
116 116
 		throw new Json\Exception\ScriptTags("JSON Data contains script tags. Aborting...");
117 117
 	}
118 118
 	// check if we have a real json request
@@ -128,4 +128,4 @@  discard block
 block discarded – undo
128 128
 	exit();
129 129
 }
130 130
 
131
-throw new Json\Exception($_SERVER['PHP_SELF'] . ' Invalid AJAX JSON Request');
131
+throw new Json\Exception($_SERVER['PHP_SELF'].' Invalid AJAX JSON Request');
Please login to merge, or discard this patch.
mail/inc/class.mail_acl.inc.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -277,8 +277,6 @@
 block discarded – undo
277 277
 	 * Update ACL rights of a folder or including subfolders for an account(s)
278 278
 	 *
279 279
 	 * @param array $content content including the acl rights
280
-	 * @param Boolean $recursive boolean flag FALSE|TRUE. If it is FALSE, only the folder take in to account, but in case of TRUE
281
-	 *		the mailbox including all its subfolders will be considered.
282 280
 	 * @param string $msg Message
283 281
 	 *
284 282
 	 */
Please login to merge, or discard this patch.
Braces   +28 added lines, -8 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 			//Todo: Implement autocomplete_url function with admin stuffs consideration
98 98
 		}
99 99
 		// Unset the content if folder is changed, in order to read acl rights for new selected folder
100
-		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete'])) unset($content);
100
+		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete']))
101
+		{
102
+			unset($content);
103
+		}
101 104
 
102 105
 		if (!is_array($content))
103 106
 		{
@@ -172,7 +175,9 @@  discard block
 block discarded – undo
172 175
 
173 176
 						//Add new row at the end
174 177
 						if ($content['grid'][count($content['grid'])]['acc_id'])
175
-							array_push($content['grid'], array('acc_id'=>''));
178
+						{
179
+													array_push($content['grid'], array('acc_id'=>''));
180
+						}
176 181
 					}
177 182
 					else
178 183
 					{
@@ -180,7 +185,10 @@  discard block
 block discarded – undo
180 185
 					}
181 186
 					//Send message
182 187
 					Framework::message($msg);
183
-					if ($button == "apply") break;
188
+					if ($button == "apply")
189
+					{
190
+						break;
191
+					}
184 192
 					Framework::window_close();
185 193
 					exit;
186 194
 
@@ -304,8 +312,16 @@  discard block
 block discarded – undo
304 312
 				if ($value[$key] == true)
305 313
 				{
306 314
 					$right = explode("acl_" ,$key);
307
-					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
308
-					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
315
+					if ($right[1] === 'c')
316
+					{
317
+						$right[1] = 'kx';
318
+					}
319
+					// c = kx , rfc 4314
320
+					if ($right[1] === 'd')
321
+					{
322
+						$right[1] = 'et';
323
+					}
324
+					// d = et , rfc 4314
309 325
 					$options['rights'] .=  $right[1];
310 326
 				}
311 327
 			}
@@ -351,7 +367,7 @@  discard block
 block discarded – undo
351 367
 	function retrieve_acl ($mailbox, &$msg)
352 368
 	{
353 369
 		if (($acl = $this->getACL($mailbox)))
354
-		 {
370
+		{
355 371
 			$msg = lang('ACL rights retrieved successfully');
356 372
 			return $acl;
357 373
 		 }
@@ -374,7 +390,10 @@  discard block
 block discarded – undo
374 390
 	function remove_acl($content, &$msg)
375 391
 	{
376 392
 		$row_num = array_keys($content['grid']['delete'],"pressed");
377
-		if ($row_num) $row_num = $row_num[0];
393
+		if ($row_num)
394
+		{
395
+			$row_num = $row_num[0];
396
+		}
378 397
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
379 398
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
380 399
 		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
@@ -514,7 +533,8 @@  discard block
 block discarded – undo
514 533
 		{
515 534
 			$acl = $this->imap->getACL($mailbox);
516 535
 			return $acl;
517
-		} catch (Exception $e) {
536
+		}
537
+		catch (Exception $e) {
518 538
 			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
519 539
 			return false;
520 540
 		}
Please login to merge, or discard this patch.
Spacing   +43 added lines, -44 removed lines patch added patch discarded remove patch
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 */
85 85
 	var $aclRightsAbbrvs = array(
86
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
87
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
88
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
89
-		'ilprsw'	=> array('label'=>'write','title'=>'Allows a user to read and write the maibox, post to it, append messages to it.'),
90
-		'eilprswtk'	=> array('label'=>'write & delete','title'=>'Allows a user to read, write and create folders and mails, post to it, append messages to it and delete messages.'),
91
-		'aeiklprstwx'=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
92
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
86
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
87
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
88
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
89
+		'ilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read and write the maibox, post to it, append messages to it.'),
90
+		'eilprswtk'	=> array('label'=>'write & delete', 'title'=>'Allows a user to read, write and create folders and mails, post to it, append messages to it and delete messages.'),
91
+		'aeiklprstwx'=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
92
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
93 93
 	);
94 94
 
95 95
 	/**
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 	 * @param string $msg = ''
113 113
 	 *
114 114
 	 */
115
-	function edit(array $content=null ,$msg='')
115
+	function edit(array $content = null, $msg = '')
116 116
 	{
117 117
 		$tmpl = new Etemplate('mail.acl');
118 118
 		if (!is_array($content))
119 119
 		{
120
-			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
120
+			$acc_id = $_GET['acc_id'] ? $_GET['acc_id'] : $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
121 121
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
122 122
 			{
123 123
 				Framework::window_close(lang('Permission denied'));
@@ -132,8 +132,7 @@  discard block
 block discarded – undo
132 132
 		$account = Mail\Account::read($acc_id, $account_id);
133 133
 		$this->imap = $account->imapServer(isset($account_id) ? (int)$account_id : false);
134 134
 
135
-		$mailbox = $_GET['mailbox']? base64_decode($_GET['mailbox']):
136
-			preg_replace("/^".$acc_id."::/",'',$content['mailbox'][0]);
135
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : preg_replace("/^".$acc_id."::/", '', $content['mailbox'][0]);
137 136
 		if (empty($mailbox))
138 137
 		{
139 138
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($account_id) : 'INBOX';
@@ -168,14 +167,14 @@  discard block
 block discarded – undo
168 167
 
169 168
 					foreach ($rights as $right)
170 169
 					{
171
-						$content['grid'][$n]['acl_'. $right] = true;
170
+						$content['grid'][$n]['acl_'.$right] = true;
172 171
 					}
173
-					$virtualD = array('e','t');
174
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
175
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
172
+					$virtualD = array('e', 't');
173
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false: true; //c=kx more information rfc4314, Obsolote Rights
174
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false: true; //d=et more information rfc4314, Obsolote Rights
176 175
 
177 176
 					sort($rights);
178
-					$acl_abbrvs = implode('',$rights);
177
+					$acl_abbrvs = implode('', $rights);
179 178
 
180 179
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
181 180
 					{
@@ -216,7 +215,7 @@  discard block
 block discarded – undo
216 215
 				case 'apply':
217 216
 					if ($content)
218 217
 					{
219
-						$validation_err = $this->update_acl($content,$msg);
218
+						$validation_err = $this->update_acl($content, $msg);
220 219
 						if ($validation_err)
221 220
 						{
222 221
 							foreach ($validation_err as &$row)
@@ -247,7 +246,7 @@  discard block
 block discarded – undo
247 246
 					}
248 247
 					else
249 248
 					{
250
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
249
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
251 250
 					}
252 251
 					Framework::message($msg);
253 252
 			}
@@ -256,7 +255,7 @@  discard block
 block discarded – undo
256 255
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
257 256
 
258 257
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
259
-		foreach($content['grid'] as $key => $fields)
258
+		foreach ($content['grid'] as $key => $fields)
260 259
 		{
261 260
 			if (self::_extract_acc_id($fields['acc_id']) == $this->imap->acc_imap_username ||
262 261
 					$this->imap->getMailBoxUserName(self::_extract_acc_id($fields['acc_id'])) == $this->imap->acc_imap_username)
@@ -295,7 +294,7 @@  discard block
 block discarded – undo
295 294
 			));
296 295
 		}
297 296
 
298
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
297
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
299 298
 	}
300 299
 
301 300
 	/**
@@ -314,7 +313,7 @@  discard block
 block discarded – undo
314 313
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
315 314
 
316 315
 		$folders = array();
317
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
316
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
318 317
 		{
319 318
 			if (stripos($folder, $_GET['query']) !== false)
320 319
 			{
@@ -342,7 +341,7 @@  discard block
 block discarded – undo
342 341
 	 * @param string $msg Message
343 342
 	 *
344 343
 	 */
345
-	function update_acl ($content, &$msg)
344
+	function update_acl($content, &$msg)
346 345
 	{
347 346
 		$validator = array();
348 347
 
@@ -358,10 +357,10 @@  discard block
 block discarded – undo
358 357
 			{
359 358
 				if ($value[$key] == true)
360 359
 				{
361
-					$right = explode("acl_" ,$key);
360
+					$right = explode("acl_", $key);
362 361
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
363 362
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
364
-					$options['rights'] .=  $right[1];
363
+					$options['rights'] .= $right[1];
365 364
 				}
366 365
 			}
367 366
 			$username = self::_extract_acc_id($content['grid'][$keys]['acc_id']);
@@ -374,7 +373,7 @@  discard block
 block discarded – undo
374 373
 			if (!empty($username))
375 374
 			{
376 375
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
377
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
376
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
378 377
 				{
379 378
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
380 379
 
@@ -386,7 +385,7 @@  discard block
 block discarded – undo
386 385
 			}
387 386
 			else
388 387
 			{
389
-				if($keys !== count($content['grid']))
388
+				if ($keys !== count($content['grid']))
390 389
 				{
391 390
 					array_push($validator, $keys);
392 391
 					$msg = lang("Could not save the ACL because some names are empty");
@@ -403,7 +402,7 @@  discard block
 block discarded – undo
403 402
 	 * Retrieve Folder ACL rights
404 403
 	 * @todo rights 'c' and 'd' should be fixed
405 404
 	 */
406
-	function retrieve_acl ($mailbox, &$msg)
405
+	function retrieve_acl($mailbox, &$msg)
407 406
 	{
408 407
 		if (($acl = $this->getACL($mailbox)))
409 408
 		 {
@@ -429,34 +428,34 @@  discard block
 block discarded – undo
429 428
 	 */
430 429
 	function remove_acl($content, &$msg)
431 430
 	{
432
-		$row_num = array_keys($content['grid']['delete'],"pressed");
431
+		$row_num = array_keys($content['grid']['delete'], "pressed");
433 432
 		if ($row_num) $row_num = $row_num[0];
434 433
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
435 434
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
436
-		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
435
+		$content['mailbox'] = is_array($content['mailbox']) ? $content['mailbox'][0] : $content['mailbox'];
437 436
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
438 437
 		{
439 438
 			$identifier = $u;
440 439
 		}
441 440
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
442
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
441
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
443 442
 		{
444 443
 			unset($content['grid'][$row_num]);
445 444
 			unset($content['grid']['delete']);
446 445
 			if ($recursive)
447 446
 			{
448
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
447
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
449 448
 			}
450 449
 			else
451 450
 			{
452
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
451
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
453 452
 			}
454 453
 
455 454
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
456 455
 		}
457 456
 		else
458 457
 		{
459
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
458
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
460 459
 			return false;
461 460
 		}
462 461
 	}
@@ -471,7 +470,7 @@  discard block
 block discarded – undo
471 470
 	 *
472 471
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
473 472
 	 */
474
-	function deleteACL ($mailbox, $identifier, $recursive)
473
+	function deleteACL($mailbox, $identifier, $recursive)
475 474
 	{
476 475
 		if ($recursive)
477 476
 		{
@@ -481,7 +480,7 @@  discard block
 block discarded – undo
481 480
 		{
482 481
 			$folders = (array)$mailbox;
483 482
 		}
484
-		foreach($folders as $sbFolders)
483
+		foreach ($folders as $sbFolders)
485 484
 		{
486 485
 			try
487 486
 			{
@@ -489,7 +488,7 @@  discard block
 block discarded – undo
489 488
 			}
490 489
 			catch (Exception $e)
491 490
 			{
492
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ."." .$e->getMessage());
491
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
493 492
 				return false;
494 493
 			}
495 494
 		}
@@ -532,7 +531,7 @@  discard block
 block discarded – undo
532 531
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
533 532
 	 *
534 533
 	 */
535
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
534
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
536 535
 	{
537 536
 		if ($recursive)
538 537
 		{
@@ -542,16 +541,16 @@  discard block
 block discarded – undo
542 541
 		{
543 542
 			$folders = (array)$mailbox;
544 543
 		}
545
-		foreach($folders as $sbFolders)
544
+		foreach ($folders as $sbFolders)
546 545
 		{
547 546
 			try
548 547
 			{
549
-				$this->imap->setACL($sbFolders,$identifier,$options);
548
+				$this->imap->setACL($sbFolders, $identifier, $options);
550 549
 			}
551 550
 			catch (Exception $e)
552 551
 			{
553 552
 				$msg = $e->getMessage();
554
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . "." .$e->getMessage());
553
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
555 554
 				return false;
556 555
 			}
557 556
 		}
@@ -564,14 +563,14 @@  discard block
 block discarded – undo
564 563
 	 * @param String $mailbox folder name that needs to be read
565 564
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
566 565
 	 */
567
-	function getACL ($mailbox)
566
+	function getACL($mailbox)
568 567
 	{
569 568
 		try
570 569
 		{
571 570
 			$acl = $this->imap->getACL($mailbox);
572 571
 			return $acl;
573 572
 		} catch (Exception $e) {
574
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
573
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox.".".$e->getMessage());
575 574
 			return false;
576 575
 		}
577 576
 	}
@@ -583,8 +582,8 @@  discard block
 block discarded – undo
583 582
 	 *
584 583
 	 * @return string returns acc_id in flat format
585 584
 	 */
586
-	private static function _extract_acc_id ($acc_id)
585
+	private static function _extract_acc_id($acc_id)
587 586
 	{
588
-		return is_array($acc_id)?$acc_id[0]:$acc_id;
587
+		return is_array($acc_id) ? $acc_id[0] : $acc_id;
589 588
 	}
590 589
 }
Please login to merge, or discard this patch.
mail/inc/class.mail_sieve.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1278,7 +1278,7 @@
 block discarded – undo
1278 1278
 	 * int $_searchStringLength
1279 1279
 	 * @param boolean $_returnList
1280 1280
 	 * @param int $_mailaccountToSearch
1281
-	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1281
+	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283 1283
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1284
 	{
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277 277
 			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
278
-            $error = 0;
278
+			$error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 	/**
1203 1203
 	 *
1204 1204
 	 * Get the data for iterating the rows on rules list grid
1205
- 	 *
1205
+	 *
1206 1206
 	 * @return {boolean|array} Array of rows | false if failed
1207 1207
 	 */
1208 1208
 	function get_rows()
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
1224 1224
 				}
1225
-            }
1225
+			}
1226 1226
 		}
1227 1227
 		else
1228 1228
 		{
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 				'caption' => 'Edit',
1248 1248
 				'default' => true,
1249 1249
 				'onExecute' => 'javaScript:app.mail.action',
1250
-                'disableClass' => 'th'
1250
+				'disableClass' => 'th'
1251 1251
 			),
1252 1252
 			'add' => array(
1253 1253
 				'caption' => 'Add',
@@ -1257,13 +1257,13 @@  discard block
 block discarded – undo
1257 1257
 				'caption' => 'Enable',
1258 1258
 				'onExecute' => 'javaScript:app.mail.action',
1259 1259
 				'enableClass' => 'mail_sieve_DISABLED',
1260
-                'hideOnDisabled' => true
1260
+				'hideOnDisabled' => true
1261 1261
 			),
1262 1262
 			'disable' => array(
1263 1263
 				'caption' => 'Disable',
1264 1264
 				'onExecute' => 'javaScript:app.mail.action',
1265 1265
 				'disableClass' => 'mail_sieve_DISABLED',
1266
-                'hideOnDisabled' => true
1266
+				'hideOnDisabled' => true
1267 1267
 			),
1268 1268
 			'delete' => array(
1269 1269
 				'caption' => 'Delete',
Please login to merge, or discard this patch.
Braces   +39 added lines, -11 removed lines patch added patch discarded remove patch
@@ -305,11 +305,21 @@  discard block
 block discarded – undo
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307 307
 						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
308
+						if( $newRule['continue'] )
309
+						{
310
+$newRule['flg'] += 1; }
311
+						if( $newRule['gthan'] )
312
+						{
313
+$newRule['flg'] += 2; }
314
+						if( $newRule['anyof'] )
315
+						{
316
+$newRule['flg'] += 4; }
317
+						if( $newRule['keep'] )
318
+						{
319
+$newRule['flg'] += 8; }
320
+						if( $newRule['regexp'] )
321
+						{
322
+$newRule['flg'] += 128; }
313 323
 
314 324
 						if($newRule['action'] && $this->rulesByID['priority'])
315 325
 						{
@@ -443,7 +453,10 @@  discard block
 block discarded – undo
443 453
 		{
444 454
 			Framework::window_close(lang($e->getMessage()));
445 455
 		}
446
-		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
456
+		if (is_null($accountID))
457
+		{
458
+			$accountID = $GLOBALS['egw_info']['user']['account_id'];
459
+		}
447 460
 
448 461
 		$account_email =  Api\Accounts::id2name($accountID, 'account_email');
449 462
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
@@ -484,7 +497,10 @@  discard block
 block discarded – undo
484 497
 		$vtmpl = new Etemplate('mail.sieve.vacation');
485 498
 		$vacation = array();
486 499
 
487
-		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
500
+		if (isset($_GET['account_id']))
501
+		{
502
+			$account_id = $preserv['account_id'] = $_GET['account_id'];
503
+		}
488 504
 
489 505
 		if (isset($content['account_id']))
490 506
 		{
@@ -554,7 +570,10 @@  discard block
 block discarded – undo
554 570
 				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
555 571
 				{
556 572
 					$content = $vacation = $vacRules['vacation'];
557
-					if (!empty($profileID)) $content['acc_id'] = $profileID;
573
+					if (!empty($profileID))
574
+					{
575
+						$content['acc_id'] = $profileID;
576
+					}
558 577
 					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
559 578
 					{
560 579
 						$content['addresses'] = $vacRules['aliases'];
@@ -567,7 +586,10 @@  discard block
 block discarded – undo
567 586
 					{
568 587
 						$content['forwards'] = '';
569 588
 					}
570
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
589
+					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text'])
590
+					{
591
+						$content['text'] = $this->mailConfig['default_vacation_text'];
592
+					}
571 593
 					if (strlen(trim($content['text']))==0)
572 594
 					{
573 595
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
@@ -757,7 +779,10 @@  discard block
 block discarded – undo
757 779
 		}
758 780
 		// setting up an async job to enable/disable the vacation message
759 781
 		$async = new Api\Asyncservice();
760
-		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
782
+		if (empty($_vacation['account_id']))
783
+		{
784
+			$_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
785
+		}
761 786
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
762 787
 		$async->delete($async_id);
763 788
 
@@ -1294,7 +1319,10 @@  discard block
 block discarded – undo
1294 1319
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1295 1320
 	{
1296 1321
 		$mailCompose = new mail_compose();
1297
-		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
1322
+		if ($_REQUEST['noPrefixId'])
1323
+		{
1324
+			$_noPrefixId = $_REQUEST['noPrefixId'];
1325
+		}
1298 1326
 		$mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId);
1299 1327
 	}
1300 1328
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		if ($acc_id > 0)
75 75
 		{
76 76
 			$this->account = Mail\Account::read($acc_id);
77
-			$identity = Mail\Account::read_identity($this->account->ident_id,true);
78
-			$this->currentIdentity = Mail::generateIdentityString($identity,false);
77
+			$identity = Mail\Account::read_identity($this->account->ident_id, true);
78
+			$this->currentIdentity = Mail::generateIdentityString($identity, false);
79 79
 		}
80 80
 
81 81
 		$this->restoreSessionData();
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param {array} $content
88 88
 	 * @param {string} $msg
89 89
 	 */
90
-	function index(array $content=null,$msg=null)
90
+	function index(array $content = null, $msg = null)
91 91
 	{
92 92
 		if (!is_array($content))
93 93
 		{
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 		if ($this->account->acc_sieve_enabled)
105 105
 		{
106 106
 			//Initializes the Grid contents
107
-			$content['rg']= $this->get_rows();
107
+			$content['rg'] = $this->get_rows();
108 108
 
109 109
 			// Set content-menu actions
110
-			$tmpl->setElementAttribute('rg', 'actions',$this->get_actions());
110
+			$tmpl->setElementAttribute('rg', 'actions', $this->get_actions());
111 111
 
112 112
 			$sel_options = array(
113 113
 				'status' => array(
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 		}
119 119
 		else
120 120
 		{
121
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
122
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
121
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
122
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
123 123
 		}
124
-		$tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array());
124
+		$tmpl->exec('mail.mail_sieve.index', $content, $sel_options, array());
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param {array} $content
132 132
 	 * @param {string} $msg
133 133
 	 */
134
-	function editEmailNotification($content=null, $msg='')
134
+	function editEmailNotification($content = null, $msg = '')
135 135
 	{
136 136
 		//Instantiate an eTemplate object, representing sieve.emailNotification
137 137
 		$eNotitmpl = new Etemplate('mail.sieve.emailNotification');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 				if (!empty($eNotification['externalEmail']))
148 148
 				{
149
-					$content['externalEmail'] = explode(",",$eNotification['externalEmail']);
149
+					$content['externalEmail'] = explode(",", $eNotification['externalEmail']);
150 150
 				}
151 151
 			}
152 152
 			else
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 				list($button) = @each($content['button']);
156 156
 				unset ($content['button']);
157 157
 
158
-				switch($button)
158
+				switch ($button)
159 159
 				{
160 160
 					case 'save':
161 161
 					case 'apply':
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 						{
164 164
 							$newEmailNotification = $content;
165 165
 							if (empty($this->mailConfig['prefpreventforwarding']) ||
166
-								$this->mailConfig['prefpreventforwarding'] == 0 )
166
+								$this->mailConfig['prefpreventforwarding'] == 0)
167 167
 							{
168 168
 								if (is_array($content['externalEmail']) && !empty($content['externalEmail']))
169 169
 								{
170
-									$newEmailNotification['externalEmail'] = implode(",",$content['externalEmail']);
170
+									$newEmailNotification['externalEmail'] = implode(",", $content['externalEmail']);
171 171
 								}
172 172
 							}
173 173
 						}
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 		else
217 217
 		{
218
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
219
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
218
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
219
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
220 220
 		}
221
-		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options);
221
+		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content, $sel_options);
222 222
 	}
223 223
 
224 224
 	/**
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param {array} $content
228 228
 	 */
229
-	function edit ($content=null)
229
+	function edit($content = null)
230 230
 	{
231 231
 		//Instantiate an eTemplate object, representing sieve.edit template
232 232
 		$etmpl = new Etemplate('mail.sieve.edit');
233
-		$etmpl->setElementAttribute('action_folder_text','autocomplete_params', array('noPrefixId'=> true));
233
+		$etmpl->setElementAttribute('action_folder_text', 'autocomplete_params', array('noPrefixId'=> true));
234 234
 		if (!is_array($content))
235 235
 		{
236
-			if ( $this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
236
+			if ($this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
237 237
 			{
238 238
 
239 239
 				$rules = $this->rulesByID;
240
-				$content= $rules;
240
+				$content = $rules;
241 241
 				$content ['ruleID'] = $_GET['ruleID'];
242 242
 				switch ($rules['action'])
243 243
 				{
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			{
258 258
 
259 259
 				$this->getRules(null);
260
-				$newRulePriority = count($this->rules)*2+1;
260
+				$newRulePriority = count($this->rules) * 2 + 1;
261 261
 				$newRules ['priority'] = $newRulePriority;
262 262
 				$newRules ['status'] = 'ENABLED';
263 263
 				$readonlys = array(
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
 			list($button) = @each($content['button']);
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277
-			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
277
+			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] - 1) / 2;
278 278
             $error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
282 282
 				case 'apply':
283
-					if($content)
283
+					if ($content)
284 284
 					{
285 285
 						unset($content['button']);
286 286
 
287 287
 						$newRule = $content;
288
-						$newRule['priority']	= $this->rulesByID['priority'];
289
-						$newRule['status']	= $this->rulesByID['status'];
288
+						$newRule['priority'] = $this->rulesByID['priority'];
289
+						$newRule['status'] = $this->rulesByID['status'];
290 290
 
291 291
 						switch ($content['action'])
292 292
 						{
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 						unset($newRule['action_address_text']);
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307
-						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
307
+						$newRule['flg'] = 0;
308
+						if ($newRule['continue']) { $newRule['flg'] += 1; }
309
+						if ($newRule['gthan']) { $newRule['flg'] += 2; }
310
+						if ($newRule['anyof']) { $newRule['flg'] += 4; }
311
+						if ($newRule['keep']) { $newRule['flg'] += 8; }
312
+						if ($newRule['regexp']) { $newRule['flg'] += 128; }
313 313
 
314
-						if($newRule['action'] && $this->rulesByID['priority'])
314
+						if ($newRule['action'] && $this->rulesByID['priority'])
315 315
 						{
316 316
 							$this->rules[$ruleID] = $newRule;
317 317
 							$ret = $this->account->imapServer()->setRules($this->rules);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 							}
322 322
 							else
323 323
 							{
324
-								$msg .= lang("The rule with priority %1 successfully saved!",$ruleID);
324
+								$msg .= lang("The rule with priority %1 successfully saved!", $ruleID);
325 325
 							}
326 326
 							$this->saveSessionData();
327 327
 						}
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 				case 'delete':
347 347
 					if ($button == "delete")
348 348
 					{
349
-						if ($ruleID === count($this->rules)-1)
349
+						if ($ruleID === count($this->rules) - 1)
350 350
 						{
351
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!');
351
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!');
352 352
 						}
353 353
 						else
354 354
 						{
355 355
 
356
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$ruleID+1,$ruleID);
356
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $ruleID + 1, $ruleID);
357 357
 						}
358 358
 						unset($this->rules[$ruleID]);
359 359
 						$this->rules = array_values($this->rules);
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 		);
385 385
 
386 386
 		//Set the preselect_options for mail/folders as we are not allow free entry for folder taglist
387
-		$sel_options['action_folder_text'] = $this->ajax_getFolders(0,true,null,true);
387
+		$sel_options['action_folder_text'] = $this->ajax_getFolders(0, true, null, true);
388 388
 
389
-		return $etmpl->exec('mail.mail_sieve.edit',$content,$sel_options,$readonlys,array(),2);
389
+		return $etmpl->exec('mail.mail_sieve.edit', $content, $sel_options, $readonlys, array(), 2);
390 390
 	}
391 391
 
392 392
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	function getEmailNotification()
400 400
 	{
401
-		if(!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
401
+		if (!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
402 402
 		{
403 403
 			throw new Api\Exception\NoPermission();
404 404
 		}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$emailNotification = $this->account->imapServer()->getEmailNotification();
408 408
 		}
409
-		catch(Exception $e) {
409
+		catch (Exception $e) {
410 410
 			unset($e);
411 411
 			$emailNotification = array();
412 412
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	function getVacation($accountID = null)
424 424
 	{
425
-		if(!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
425
+		if (!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
426 426
 		{
427 427
 			throw new Api\Exception\NoPermission();
428 428
 		}
@@ -439,25 +439,25 @@  discard block
 block discarded – undo
439 439
 				$vacation = $icServer->getVacation();
440 440
 			}
441 441
 		}
442
-		catch(Exception $e)
442
+		catch (Exception $e)
443 443
 		{
444 444
 			Framework::window_close(lang($e->getMessage()));
445 445
 		}
446 446
 		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
447 447
 
448
-		$account_email =  Api\Accounts::id2name($accountID, 'account_email');
448
+		$account_email = Api\Accounts::id2name($accountID, 'account_email');
449 449
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
450
-		$allAliases = $this->account->ident_email !=''?
450
+		$allAliases = $this->account->ident_email != '' ?
451 451
 				// Fix ident_email with no domain part set
452 452
 				array(Mail::fixInvalidAliasAddress($account_email, $this->account->ident_email))
453 453
 				: array();
454 454
 		foreach ($accAllIdentities as &$val)
455 455
 		{
456
-			if ($val['type'] !='default')
456
+			if ($val['type'] != 'default')
457 457
 			{
458 458
 				// if the alias has no domain part set try to add
459 459
 				// default domain extracted from ident_email address
460
-				$allAliases[] =  Mail::fixInvalidAliasAddress($account_email, $val['address']);
460
+				$allAliases[] = Mail::fixInvalidAliasAddress($account_email, $val['address']);
461 461
 			}
462 462
 		}
463 463
 		// try to fix already stored aliases
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param {array} $content
479 479
 	 * @param {string} $msg
480 480
 	 */
481
-	function editVacation($content=null, $msg='')
481
+	function editVacation($content = null, $msg = '')
482 482
 	{
483 483
 		//Instantiate an eTemplate object, representing the sieve.vacation template
484 484
 		$vtmpl = new Etemplate('mail.sieve.vacation');
@@ -491,27 +491,27 @@  discard block
 block discarded – undo
491 491
 			$account_id = $content['account_id'];
492 492
 			$preserv['acc_id'] = $content['acc_id'];
493 493
 		}
494
-		if(isset($account_id) && $this->mail_admin)
494
+		if (isset($account_id) && $this->mail_admin)
495 495
 		{
496
-			foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account)
496
+			foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account)
497 497
 			{
498 498
 				try {
499 499
 					// check if account is valid for multiple users, has admin credentials and sieve enabled
500 500
 					if (Mail\Account::is_multiple($account) &&
501
-						($icServer = $account->imapServer(true)) &&	// check on icServer object, so plugins can overwrite
501
+						($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite
502 502
 						$icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled)
503 503
 					{
504 504
 						$allAccounts[$account->acc_id] = $account->acc_name;
505 505
 						$accounts[$account->acc_id] = $account;
506 506
 					}
507 507
 				}
508
-				catch(Exception $e) {
508
+				catch (Exception $e) {
509 509
 					unset($e);
510 510
 					// ignore broken accounts
511 511
 				}
512 512
 			}
513 513
 
514
-			$profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id'];
514
+			$profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id'];
515 515
 			if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']]))
516 516
 			{
517 517
 				$profileID = $content['acc_id'] = (int)$_GET['acc_id'];
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			$this->is_admin_vac = true;
524 524
 			$preserv['account_id'] = $account_id;
525 525
 		}
526
-		elseif(!is_array($content) && isset($_GET['acc_id']))
526
+		elseif (!is_array($content) && isset($_GET['acc_id']))
527 527
 		{
528 528
 			$this->account = Mail\Account::read($_GET['acc_id']);
529 529
 			$preserv['acc_id'] = $this->account->acc_id;
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
 		if ($icServer->acc_sieve_enabled)
540 540
 		{
541 541
 			$vacRules = $this->getVacation($account_id);
542
-			if ($vacRules['vacation']===false)
542
+			if ($vacRules['vacation'] === false)
543 543
 			{
544 544
 				$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
545
-					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
546
-				$content['hideIfSieveDisabled']='mail_DisplayNone';
545
+					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
546
+				$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
547 547
 			}
548 548
 			else
549 549
 			{
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
 				{
552 552
 					$ByDate = array('by_date' => lang('By date'));
553 553
 				}
554
-				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
554
+				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date'))))
555 555
 				{
556 556
 					$content = $vacation = $vacRules['vacation'];
557 557
 					if (!empty($profileID)) $content['acc_id'] = $profileID;
558
-					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
558
+					if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '')
559 559
 					{
560 560
 						$content['addresses'] = $vacRules['aliases'];
561 561
 					}
562 562
 					if (!empty($vacation['forwards']))
563 563
 					{
564
-						$content['forwards'] = explode(",",$vacation['forwards']);
564
+						$content['forwards'] = explode(",", $vacation['forwards']);
565 565
 					}
566 566
 					else
567 567
 					{
568 568
 						$content['forwards'] = '';
569 569
 					}
570
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
571
-					if (strlen(trim($content['text']))==0)
570
+					if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
571
+					if (strlen(trim($content['text'])) == 0)
572 572
 					{
573 573
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
574 574
 						Framework::refresh_opener($msg, 'mail');
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 					list($button) = @each($content['button']);
587 587
 					unset ($content['button']);
588 588
 
589
-					switch($button)
589
+					switch ($button)
590 590
 					{
591 591
 						case 'save':
592 592
 						case 'apply':
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 								$newVacation = $content;
605 605
 
606 606
 								if (empty($this->mailConfig['prefpreventforwarding']) ||
607
-									$this->mailConfig['prefpreventforwarding'] == 0 )
607
+									$this->mailConfig['prefpreventforwarding'] == 0)
608 608
 								{
609 609
 									$content['forwards'] = self::strip_rfc882_addresses($content['forwards']);
610 610
 									$newVacation['forwards'] = implode(',', $content['forwards']);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 									unset($newVacation ['forwards']);
615 615
 								}
616 616
 
617
-								if (!in_array($newVacation['status'],array('on','off','by_date')))
617
+								if (!in_array($newVacation['status'], array('on', 'off', 'by_date')))
618 618
 								{
619 619
 									$newVacation['status'] = 'off';
620 620
 								}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 										self::strip_rfc882_addresses($content['addresses']);
627 627
 								}
628 628
 
629
-								if($this->checkRule($newVacation,$checkAddresses))
629
+								if ($this->checkRule($newVacation, $checkAddresses))
630 630
 								{
631 631
 									if (isset($account_id) && $this->mail_admin)
632 632
 									{
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
 
640 640
 									if (!$resSetvac)
641 641
 									{
642
-										$msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error;
642
+										$msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error;
643 643
 										break;
644 644
 									}
645 645
 									// schedule job to switch message on/off, if request and not already in past
646 646
 									else
647 647
 									{
648
-										if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
648
+										if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() ||
649 649
 											$vacRules && $vacRules['vacation']['status'] == 'by_date')
650 650
 										{
651 651
 											self::setAsyncJob($newVacation);
@@ -653,29 +653,29 @@  discard block
 block discarded – undo
653 653
 										//Reset vacationNotice cache which is used in mail_ui get_rows
654 654
 										if (isset($account_id) && $this->mail_admin)
655 655
 										{
656
-											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
656
+											$account_lid = Api\Accounts::id2name($account_id, 'account_lid');
657 657
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
658 658
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
659
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
659
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations);
660 660
 										}
661 661
 										else
662 662
 										{
663 663
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
664 664
 											//error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations));
665
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
665
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
666 666
 										}
667 667
 										$msg = lang('Vacation notice sucessfully updated.');
668 668
 									}
669 669
 								}
670 670
 								else
671 671
 								{
672
-									$msg .= implode("\n",$this->errorStack);
672
+									$msg .= implode("\n", $this->errorStack);
673 673
 								}
674 674
 								// refresh vacationNotice on index
675 675
 								$response = Api\Json\Response::get();
676
-								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
676
+								$response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId);
677 677
 								Framework::refresh_opener($msg, 'mail');
678
-								if ($button === 'apply' || $icServer->error !=="")
678
+								if ($button === 'apply' || $icServer->error !== "")
679 679
 								{
680 680
 									break;
681 681
 								}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 						'on' => lang('Active'),
692 692
 						'off' => lang('Deactive'),
693 693
 					),
694
-					'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']),
694
+					'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']),
695 695
 				);
696 696
 				if (!isset($account_id))
697 697
 				{
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
 		}
716 716
 		else
717 717
 		{
718
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
719
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
718
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
719
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
720 720
 		}
721
-		$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);
721
+		$vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2);
722 722
 	}
723 723
 
724 724
 	/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	static function strip_rfc882_addresses($_addresses)
733 733
 	{
734 734
 		$addresses = array();
735
-		foreach(Mail::parseAddressList($_addresses) as $addr)
735
+		foreach (Mail::parseAddressList($_addresses) as $addr)
736 736
 		{
737 737
 			if ($addr->valid)
738 738
 			{
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes
750 750
 	 * @return  void
751 751
 	 */
752
-	static function setAsyncJob (array $_vacation, $_reschedule=false)
752
+	static function setAsyncJob(array $_vacation, $_reschedule = false)
753 753
 	{
754 754
 		if (!($_vacation['acc_id'] > 0))
755 755
 		{
@@ -761,19 +761,19 @@  discard block
 block discarded – undo
761 761
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
762 762
 		$async->delete($async_id);
763 763
 
764
-		$end_date = $_vacation['end_date'] + 24*3600;   // end-date is inclusive, so we have to add 24h
764
+		$end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h
765 765
 		if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
766 766
 		{
767 767
 			$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
768
-			$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
768
+			$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
769 769
 		}
770 770
 		if ($_reschedule)
771 771
 		{
772
-			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
772
+			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5;
773 773
 			// only try to reschedule for 2 days max
774 774
 			if ($_vacation['rescheduled'] <= 2 * 24 * 60)
775 775
 			{
776
-				$time = time() + 60*($_vacation['rescheduled']);
776
+				$time = time() + 60 * ($_vacation['rescheduled']);
777 777
 				unset($_vacation['next']);
778 778
 				unset($_vacation['times']);
779 779
 				$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		}
810 810
 		catch (Exception $e) {
811 811
 			error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
812
-			self::setAsyncJob($_vacation, true);	// reschedule
812
+			self::setAsyncJob($_vacation, true); // reschedule
813 813
 			$ret = false;
814 814
 		}
815 815
 
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 *
825 825
 	 * @return boolean
826 826
 	 */
827
-	function checkRule($_vacation,$_checkAddresses=true)
827
+	function checkRule($_vacation, $_checkAddresses = true)
828 828
 	{
829 829
 		$this->errorStack = array();
830 830
 
@@ -838,12 +838,12 @@  discard block
 block discarded – undo
838 838
 			$this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!';
839 839
 		}
840 840
 
841
-		if(is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
841
+		if (is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
842 842
 		{
843
-			$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
843
+			$regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
844 844
 			foreach ($_vacation['addresses'] as $addr)
845 845
 			{
846
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
846
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
847 847
 				{
848 848
 					$this->errorStack['addresses'] = lang('One address is not valid').'!';
849 849
 				}
@@ -859,23 +859,23 @@  discard block
 block discarded – undo
859 859
 			{
860 860
 				$this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!');
861 861
 			}
862
-			elseif($_vacation['start_date'] > $_vacation['end_date'])
862
+			elseif ($_vacation['start_date'] > $_vacation['end_date'])
863 863
 			{
864 864
 				$this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!');
865 865
 			}
866 866
 		}
867 867
 		if ($_vacation['forwards'])
868 868
 		{
869
-			foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr)
869
+			foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr)
870 870
 			{
871
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
871
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
872 872
 				{
873 873
 					$this->errorStack['forwards'] = lang('One address is not valid'.'!');
874 874
 				}
875 875
 			}
876 876
 		}
877 877
 		//error_log(__METHOD__. array2string($this->errorStack));
878
-		if(count($this->errorStack) == 0)
878
+		if (count($this->errorStack) == 0)
879 879
 		{
880 880
 			return true;
881 881
 		}
@@ -896,14 +896,14 @@  discard block
 block discarded – undo
896 896
 
897 897
 		foreach ($orders as $keys => $val)
898 898
 		{
899
-			$orders[$keys] = $val -1;
899
+			$orders[$keys] = $val - 1;
900 900
 		}
901 901
 
902 902
 		$this->getRules(null);
903 903
 
904 904
 		$newrules = $this->rules;
905 905
 
906
-		foreach($orders as $keys => $ruleID)
906
+		foreach ($orders as $keys => $ruleID)
907 907
 		{
908 908
 			$newrules[$keys] = $this->rules[$ruleID];
909 909
 		}
@@ -932,24 +932,24 @@  discard block
 block discarded – undo
932 932
 		switch ($action)
933 933
 		{
934 934
 			case 'delete':
935
-				if ($checked === count($this->rules)-1)
935
+				if ($checked === count($this->rules) - 1)
936 936
 				{
937
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!');
937
+					$msg = lang('rule with priority ').$checked.lang(' deleted!');
938 938
 				}
939 939
 				else
940 940
 				{
941 941
 
942
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked);
942
+					$msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked);
943 943
 				}
944 944
 				unset($this->rules[$checked]);
945 945
 				$this->rules = array_values($this->rules);
946 946
 				break;
947 947
 			case 'enable':
948
-				$msg = lang('rule with priority ') . $checked . lang(' enabled!');
948
+				$msg = lang('rule with priority ').$checked.lang(' enabled!');
949 949
 				$this->rules[$checked][status] = 'ENABLED';
950 950
 				break;
951 951
 			case 'disable':
952
-				$msg = lang('rule with priority ') . $checked . lang(' disabled!');
952
+				$msg = lang('rule with priority ').$checked.lang(' disabled!');
953 953
 				$this->rules[$checked][status] = 'DISABLED';
954 954
 				break;
955 955
 			case 'move':
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 
962 962
 		$response = Api\Json\Response::get();
963 963
 
964
-		if($result)
964
+		if ($result)
965 965
 		{
966 966
 			$response->message($result);
967 967
 			return;
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
 	 */
980 980
 	function buildRule($rule)
981 981
 	{
982
-		$andor = ' '. lang('and') .' ';
982
+		$andor = ' '.lang('and').' ';
983 983
 		$started = 0;
984 984
 		if ($rule['anyof'])
985 985
 		{
986
-			$andor = ' '. lang('or') .' ';
986
+			$andor = ' '.lang('or').' ';
987 987
 		}
988 988
 		$complete = lang('IF').' ';
989 989
 		if ($rule['unconditional'])
@@ -992,8 +992,8 @@  discard block
 block discarded – undo
992 992
 		}
993 993
 		if ($rule['from'])
994 994
 		{
995
-			$match = $this->setMatchType($rule['from'],$rule['regexp']);
996
-			$complete .= "'From:' " . $match . " '" . $rule['from'] . "'";
995
+			$match = $this->setMatchType($rule['from'], $rule['regexp']);
996
+			$complete .= "'From:' ".$match." '".$rule['from']."'";
997 997
 			$started = 1;
998 998
 		}
999 999
 		if ($rule['to'])
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 			{
1003 1003
 				$complete .= $andor;
1004 1004
 			}
1005
-			$match = $this->setMatchType($rule['to'],$rule['regexp']);
1006
-			$complete .= "'To:' " . $match . " '" . $rule['to'] . "'";
1005
+			$match = $this->setMatchType($rule['to'], $rule['regexp']);
1006
+			$complete .= "'To:' ".$match." '".$rule['to']."'";
1007 1007
 			$started = 1;
1008 1008
 		}
1009 1009
 		if ($rule['subject'])
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 			{
1013 1013
 				$complete .= $andor;
1014 1014
 			}
1015
-			$match = $this->setMatchType($rule['subject'],$rule['regexp']);
1016
-			$complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'";
1015
+			$match = $this->setMatchType($rule['subject'], $rule['regexp']);
1016
+			$complete .= "'Subject:' ".$match." '".$rule['subject']."'";
1017 1017
 			$started = 1;
1018 1018
 		}
1019 1019
 		if ($rule['field'] && $rule['field_val'])
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 			{
1023 1023
 				$complete .= $andor;
1024 1024
 			}
1025
-			$match = $this->setMatchType($rule['field_val'],$rule['regexp']);
1026
-			$complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'";
1025
+			$match = $this->setMatchType($rule['field_val'], $rule['regexp']);
1026
+			$complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'";
1027 1027
 			$started = 1;
1028 1028
 		}
1029 1029
 		if ($rule['size'])
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			{
1038 1038
 				$complete .= $andor;
1039 1039
 			}
1040
-			$complete .= "message " . $xthan . $rule['size'] . "KB'";
1040
+			$complete .= "message ".$xthan.$rule['size']."KB'";
1041 1041
 			$started = 1;
1042 1042
 		}
1043 1043
 		if (!empty($rule['field_bodytransform']))
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 			{
1047 1047
 				$newruletext .= ", ";
1048 1048
 			}
1049
-			$btransform	= " :raw ";
1049
+			$btransform = " :raw ";
1050 1050
 			$match = ' :contains';
1051 1051
 			if ($rule['bodytransform'])
1052 1052
 			{
@@ -1060,11 +1060,11 @@  discard block
 block discarded – undo
1060 1060
 			{
1061 1061
 				$match = ':regex';
1062 1062
 			}
1063
-			$complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\"";
1063
+			$complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\"";
1064 1064
 			$started = 1;
1065 1065
 
1066 1066
 		}
1067
-		if ($rule['ctype']!= '0' && !empty($rule['ctype']))
1067
+		if ($rule['ctype'] != '0' && !empty($rule['ctype']))
1068 1068
 		{
1069 1069
 			if ($started)
1070 1070
 			{
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 			{
1077 1077
 				$ctype_subtype = "/";
1078 1078
 			}
1079
-			$complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\"";
1079
+			$complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\"";
1080 1080
 			$started = 1;
1081 1081
 			//error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array));
1082 1082
 		}
@@ -1084,19 +1084,19 @@  discard block
 block discarded – undo
1084 1084
 		{
1085 1085
 			$complete .= ' '.lang('THEN').' ';
1086 1086
 		}
1087
-		if (preg_match("/folder/i",$rule['action']))
1087
+		if (preg_match("/folder/i", $rule['action']))
1088 1088
 		{
1089
-			$complete .= lang('file into')." '" . $rule['action_arg'] . "';";
1089
+			$complete .= lang('file into')." '".$rule['action_arg']."';";
1090 1090
 		}
1091
-		if (preg_match("/reject/i",$rule['action']))
1091
+		if (preg_match("/reject/i", $rule['action']))
1092 1092
 		{
1093
-			$complete .= lang('reject with')." '" . $rule['action_arg'] . "'.";
1093
+			$complete .= lang('reject with')." '".$rule['action_arg']."'.";
1094 1094
 		}
1095
-		if (preg_match("/address/i",$rule['action']))
1095
+		if (preg_match("/address/i", $rule['action']))
1096 1096
 		{
1097
-			$complete .= lang('forward to').' ' . $rule['action_arg'] .'.';
1097
+			$complete .= lang('forward to').' '.$rule['action_arg'].'.';
1098 1098
 		}
1099
-		if (preg_match("/discard/i",$rule['action']))
1099
+		if (preg_match("/discard/i", $rule['action']))
1100 1100
 		{
1101 1101
 			$complete .= lang('discard').'.';
1102 1102
 		}
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 	 * @param {string} $regex regular expresion as pattern to be matched
1119 1119
 	 * @return {string} return the type
1120 1120
 	 */
1121
-	function setMatchType (&$matchstr, $regex = false)
1121
+	function setMatchType(&$matchstr, $regex = false)
1122 1122
 	{
1123 1123
 		$match = lang('contains');
1124 1124
 		if (preg_match("/^\s*!/", $matchstr))
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 		}
1144 1144
 		if ($regex && preg_match("/^\s*\\\\!/", $matchstr))
1145 1145
 		{
1146
-			$matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr);
1146
+			$matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr);
1147 1147
 		}
1148 1148
 		else
1149 1149
 		{
1150
-			$matchstr = preg_replace("/^\s*!/","",$matchstr);
1150
+			$matchstr = preg_replace("/^\s*!/", "", $matchstr);
1151 1151
 		}
1152 1152
 		return $match;
1153 1153
 	}
@@ -1157,9 +1157,9 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	function saveSessionData()
1159 1159
 	{
1160
-		$sessionData['sieve_rules']		= $this->rules;
1160
+		$sessionData['sieve_rules'] = $this->rules;
1161 1161
 		$sessionData['sieve_rulesByID'] = $this->rulesByID;
1162
-		$sessionData['sieve_scriptToEdit']	= $this->scriptToEdit;
1162
+		$sessionData['sieve_scriptToEdit'] = $this->scriptToEdit;
1163 1163
 		Api\Cache::setSession(__CLASS__, 'sieve_session_data', $sessionData);
1164 1164
 	}
1165 1165
 
@@ -1185,15 +1185,15 @@  discard block
 block discarded – undo
1185 1185
 	{
1186 1186
 		try {
1187 1187
 			$this->account->imapServer()->retrieveRules();
1188
-			$this->rules	= $this->account->imapServer()->getRules();
1188
+			$this->rules = $this->account->imapServer()->getRules();
1189 1189
 			$this->rulesByID = $this->rules[$ruleID];
1190
-			$this->vacation	= $this->account->imapServer()->getVacation();
1190
+			$this->vacation = $this->account->imapServer()->getVacation();
1191 1191
 		}
1192
-		catch(Exception $e) {
1192
+		catch (Exception $e) {
1193 1193
 			error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details);
1194
-			$this->rules	= array();
1194
+			$this->rules = array();
1195 1195
 			$this->rulesByID = array();
1196
-			$this->vacation	= array();
1196
+			$this->vacation = array();
1197 1197
 			return false;
1198 1198
 		}
1199 1199
 		return true;
@@ -1205,9 +1205,9 @@  discard block
 block discarded – undo
1205 1205
 	function restoreSessionData()
1206 1206
 	{
1207 1207
 		$sessionData = Api\Cache::getSession(__CLASS__, 'sieve_session_data');
1208
-		$this->rules		= $sessionData['sieve_rules'];
1208
+		$this->rules = $sessionData['sieve_rules'];
1209 1209
 		$this->rulesByID = $sessionData['sieve_rulesByID'];
1210
-		$this->scriptToEdit	= $sessionData['sieve_scriptToEdit'];
1210
+		$this->scriptToEdit = $sessionData['sieve_scriptToEdit'];
1211 1211
 	}
1212 1212
 
1213 1213
 	/**
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
 		$rows = array();
1222 1222
 		$this->getRules(null);
1223 1223
 
1224
-		if (is_array($this->rules) && !empty($this->rules) )
1224
+		if (is_array($this->rules) && !empty($this->rules))
1225 1225
 		{
1226 1226
 			$rows = $this->rules;
1227 1227
 
1228
-			foreach ($rows as &$row )
1228
+			foreach ($rows as &$row)
1229 1229
 			{
1230 1230
 				$row['rules'] = $this->buildRule($row);
1231
-				$row['ruleID'] =(string)(($row['priority'] -1) / 2 );
1231
+				$row['ruleID'] = (string)(($row['priority'] - 1) / 2);
1232 1232
 				if ($row ['status'] === 'DISABLED')
1233 1233
 				{
1234 1234
 					$row['class'] = 'mail_sieve_DISABLED';
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 			return false;
1242 1242
 		}
1243 1243
 		// Shift one down, because in grid the first row is reserved for header
1244
-		array_unshift($rows,array(''=> ''));
1244
+		array_unshift($rows, array(''=> ''));
1245 1245
 		return $rows;
1246 1246
 	}
1247 1247
 
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 	 */
1253 1253
 	private function get_actions()
1254 1254
 	{
1255
-		$actions =array(
1255
+		$actions = array(
1256 1256
 
1257 1257
 			'edit' => array(
1258 1258
 				'caption' => 'Edit',
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 	 * @param int $_mailaccountToSearch
1292 1292
 	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1293 1293
 	 */
1294
-	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1294
+	function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false)
1295 1295
 	{
1296 1296
 		$mailCompose = new mail_compose();
1297 1297
 		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
Please login to merge, or discard this patch.
mail/inc/class.mail_tree.inc.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $_profileID icServer profile id
77 77
 	 * @param string $_err error message to be shown on tree node
78 78
 	 * @param mixed $_path
79
-	 * @param mixed $_parent
79
+	 * @param string $_parent
80 80
 	 * @return array returns an array of tree node
81 81
 	 */
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * Check if the given tree id is account node (means root)
125 125
 	 *
126
-	 * @param type $_node a tree id node
126
+	 * @param string|null $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129 129
 	private static function isAccountNode ($_node)
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @param string $_parent = null no parent node means root with the first level of folders
157 157
 	 * @param string $_profileID = '' icServer id
158
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
158
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
159 159
 	 *  false|0 leaves them in closed state
160 160
 	 * @param $_noCheckboxNS = false no checkbox for namesapaces makes sure to not put checkbox for namespaces node
161 161
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @param type $_profileID = null Null means all accounts and giving profileid means fetches node for the account
445 445
 	 * @param type $_noCheckbox = false option to switch checkbox of
446
-	 * @param type $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
446
+	 * @param integer $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
447 447
 	 *
448 448
 	 * @return array an array of baseNodes of accounts
449 449
 	 */
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 *
492 492
 	 * @param string $_parent = null no parent node means root with the first level of folders
493 493
 	 * @param string $_profileID = '' active profile / acc_id
494
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
494
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
495 495
 	 *  false|0 leaves them in closed state
496 496
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
497 497
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * bit flag: ident_name
46 46
 	 */
47
-	const IDENT_NAME_IDENTITY= 8;
47
+	const IDENT_NAME_IDENTITY = 8;
48 48
 
49 49
 	/**
50 50
 	 * Icons used for nodes different states
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 		$this->ui = $mail_ui;
79 79
 
80 80
 		// check images available in png or svg
81
-		foreach(self::$leafImages as &$image)
81
+		foreach (self::$leafImages as &$image)
82 82
 		{
83 83
 			if (strpos($image, '.') === false)
84 84
 			{
85
-				$image = basename($img=Api\Image::find('mail', 'dhtmlxtree/'.$image));
85
+				$image = basename($img = Api\Image::find('mail', 'dhtmlxtree/'.$image));
86 86
 			}
87 87
 		}
88 88
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
100 100
 	{
101 101
 		$baseNode = array('id' => $_profileID);
102
-		$leaf =  array(
102
+		$leaf = array(
103 103
 			'id' => $_profileID.self::DELIMITER.'INBOX',
104 104
 			'text' => $_err,
105 105
 			'tooltip' => $_err,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		);
112 112
 		self::setOutStructure($leaf, $baseNode, self::DELIMITER);
113 113
 
114
-		return ($baseNode?$baseNode:array( // fallback not connected array
114
+		return ($baseNode ? $baseNode : array( // fallback not connected array
115 115
 						'id'=>0,
116 116
 						'item'=> array(
117 117
 							'text'=>'INBOX',
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param array $_node array of a node
129 129
 	 * @return int returns 1 if it has children flag set otherwise 0
130 130
 	 */
131
-	private static function nodeHasChildren ($_node)
131
+	private static function nodeHasChildren($_node)
132 132
 	{
133 133
 		$hasChildren = 0;
134 134
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @param type $_node a tree id node
144 144
 	 * @return boolean returns true if the node is account node otherwise false
145 145
 	 */
146
-	private static function isAccountNode ($_node)
146
+	private static function isAccountNode($_node)
147 147
 	{
148 148
 		list(,$leaf) = explode(self::DELIMITER, $_node);
149 149
 		if ($leaf || $_node == null) return false;
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return array returns an array of mail tree structure according to provided node
183 183
 	 */
184
-	function getTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly= false, $_allInOneGo = false, $_checkSubscribed = true)
184
+	function getTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly = false, $_allInOneGo = false, $_checkSubscribed = true)
185 185
 	{
186 186
 		//Init mail folders
187
-		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
187
+		$tree = array(Tree::ID=> $_parent ? $_parent : 0, Tree::CHILDREN => array());
188 188
 		if (!isset($this->ui->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
189 189
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
190 190
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			{
197 197
 				$this->ui->changeProfile($_profileID);
198 198
 			} catch (Exception $ex) {
199
-				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
199
+				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
200 200
 			}
201 201
 		}
202 202
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
209 209
 			{
210 210
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
211
-				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
211
+				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly);
212 212
 
213 213
 				$childrenNode = array();
214 214
 				foreach ($folders as &$node)
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 					$nodeData = Mail::pathToFolderData($nodeId, $node['delimiter']);
218 218
 					$childrenNode[] = array(
219 219
 						Tree::ID=> $nodeId,
220
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node),
220
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ?false:self::nodeHasChildren($node),
221 221
 						Tree::CHILDREN =>array(),
222 222
 						Tree::LABEL => $nodeData['text'],
223 223
 						Tree::TOOLTIP => $nodeData['tooltip'],
224 224
 						Tree::IMAGE_LEAF => self::$leafImages['folderLeaf'],
225 225
 						Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'],
226 226
 						Tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClosed'],
227
-						Tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false,
227
+						Tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false,
228 228
 						'parent' => $_parent
229 229
 					);
230 230
 				}
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 				}
245 245
 
246 246
 				//List of folders
247
-				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, false);
247
+				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, false);
248 248
 
249 249
 				// User defined folders based on account
250 250
 				$definedFolders = array(
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 					$data = array(
267 267
 						Tree::ID=>$_profileID.self::DELIMITER.$folder['MAILBOX'],
268
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder),
268
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ?false:self::nodeHasChildren($folder),
269 269
 						Tree::CHILDREN =>array(),
270 270
 						Tree::LABEL =>lang($folder['MAILBOX']),
271
-						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0,
271
+						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0,
272 272
 						Tree::TOOLTIP => lang($folder['MAILBOX']),
273
-						Tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false,
273
+						Tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false,
274 274
 						Tree::NOCHECKBOX => 0,
275
-						'parent' => $parent?$_profileID.self::DELIMITER.implode($folder['delimiter'], $parent):$_profileID,
275
+						'parent' => $parent ? $_profileID.self::DELIMITER.implode($folder['delimiter'], $parent) : $_profileID,
276 276
 						'path' => $path,
277 277
 						'folderarray' => $folder
278 278
 					);
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		catch (Exception $ex) // Catch exceptions
311 311
 		{
312 312
 			//mail_ui::callWizard($ex->getMessage(), false, 'error');
313
-			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
313
+			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
314 314
 		}
315 315
 
316 316
 		return $tree;
@@ -327,19 +327,19 @@  discard block
 block discarded – undo
327 327
 	 *					as clearance for access may be limited to a single branch-node of a tree
328 328
 	 * @return void
329 329
 	 */
330
-	static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array())
330
+	static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array())
331 331
 	{
332 332
 		//error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
333 333
 		$components = $data['path'];
334
-		array_pop($components);	// remove own name
334
+		array_pop($components); // remove own name
335 335
 
336 336
 		$insert = &$out;
337 337
 		$parents = array();
338
-		foreach($components as $component)
338
+		foreach ($components as $component)
339 339
 		{
340
-			if (count($parents)>1)
340
+			if (count($parents) > 1)
341 341
 			{
342
-				$helper = array_slice($parents,1,null,true);
342
+				$helper = array_slice($parents, 1, null, true);
343 343
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
344 344
 				if ($parent) $parent .= $del;
345 345
 			}
@@ -362,21 +362,21 @@  discard block
 block discarded – undo
362 362
 				{
363 363
 					// if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent
364 364
 					// we want to create the node in question as we meet the above considerations
365
-					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
365
+					if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::DELIMITER.$nsp['prefix']) === 0)
366 366
 					{
367 367
 						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
368
-						$break=false;
368
+						$break = false;
369 369
 					}
370 370
 				}
371 371
 				if ($break) break;
372 372
 			}
373 373
 			if ($insert['item'])
374 374
 			{
375
-				foreach($insert['item'] as &$item)
375
+				foreach ($insert['item'] as &$item)
376 376
 				{
377 377
 					if ($item['id'] == $parent.$component)
378 378
 					{
379
-						$insert =& $item;
379
+						$insert = & $item;
380 380
 						break;
381 381
 					}
382 382
 				}
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 						'im2' => self::$leafImages["folderNoSelectClosed"],
395 395
 						'tooltip' => lang('no access')
396 396
 					);
397
-					$insert['item'][] =& $item;
398
-					$insert =& $item;
397
+					$insert['item'][] = & $item;
398
+					$insert = & $item;
399 399
 				}
400 400
 				else
401 401
 				{
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 					$data[Tree::IMAGE_FOLDER_OPEN] =
429 429
 					$data [Tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png";
430 430
 			}
431
-			elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false)
431
+			elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false)
432 432
 			{
433 433
 				$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
434 434
 				$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@@ -470,20 +470,20 @@  discard block
 block discarded – undo
470 470
 	 *
471 471
 	 * @return array an array of baseNodes of accounts
472 472
 	 */
473
-	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 )
473
+	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0)
474 474
 	{
475 475
 		$roots = array(Tree::ID => 0, Tree::CHILDREN => array());
476 476
 
477
-		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
477
+		foreach (Mail\Account::search(true, false) as $acc_id => $accObj)
478 478
 		{
479
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
480
-			$identity = self::getIdentityName(Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id'], true));
479
+			if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue;
480
+			$identity = self::getIdentityName(Mail\Account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id'], true));
481 481
 			// Open top level folders for active account
482
-			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
482
+			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0;
483 483
 
484 484
 			$baseNode = array(
485 485
 							Tree::ID=> (string)$acc_id,
486
-							Tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity),
486
+							Tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity),
487 487
 							Tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity),
488 488
 							Tree::IMAGE_LEAF => self::$leafImages['folderAccount'],
489 489
 							Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'],
@@ -492,16 +492,16 @@  discard block
 block discarded – undo
492 492
 							Tree::CHILDREN => array(), // dynamic loading on unfold
493 493
 							Tree::AUTOLOAD_CHILDREN => true,
494 494
 							'parent' => '',
495
-							Tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount,
495
+							Tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount,
496 496
 							// mark on account if Sieve is enabled
497 497
 							'data' => array(
498 498
 										'sieve' => $accObj->imapServer()->acc_sieve_enabled,
499
-										'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
500
-										'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
499
+										'spamfolder'=> $accObj->imapServer()->acc_folder_junk && (strtolower($accObj->imapServer()->acc_folder_junk) != 'none') ?true:false,
500
+										'archivefolder'=> $accObj->imapServer()->acc_folder_archive && (strtolower($accObj->imapServer()->acc_folder_archive) != 'none') ?true:false
501 501
 									),
502 502
 							Tree::NOCHECKBOX  => $_noCheckbox
503 503
 			);
504
-			self::setOutStructure($baseNode, $roots,self::DELIMITER);
504
+			self::setOutStructure($baseNode, $roots, self::DELIMITER);
505 505
 		}
506 506
 		return $roots;
507 507
 	}
@@ -520,15 +520,15 @@  discard block
 block discarded – undo
520 520
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
521 521
 	 * @return type an array of tree
522 522
 	 */
523
-	function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false)
523
+	function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false)
524 524
 	{
525 525
 		$tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo);
526
-		$branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo);
526
+		$branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo);
527 527
 		foreach ($tree[Tree::CHILDREN] as &$account)
528 528
 		{
529 529
 			if ($account[Tree::ID] == $_profileID)
530 530
 			{
531
-				$account = array_merge($account , $branches);
531
+				$account = array_merge($account, $branches);
532 532
 			}
533 533
 		}
534 534
 		return $tree;
@@ -540,33 +540,33 @@  discard block
 block discarded – undo
540 540
 	 * @param array $_account
541 541
 	 * @return string
542 542
 	 */
543
-	static function getIdentityName ($_account)
543
+	static function getIdentityName($_account)
544 544
 	{
545 545
 		$identLabel = $GLOBALS['egw_info']['user']['preferences']['mail']['identLabel'];
546 546
 		$name = array();
547 547
 
548
-		if ($identLabel & self::IDENT_NAME_IDENTITY)
548
+		if ($identLabel&self::IDENT_NAME_IDENTITY)
549 549
 		{
550 550
 			$name[] = $_account['ident_name'];
551 551
 		}
552 552
 
553
-		if ($identLabel & self::IDENT_NAME)
553
+		if ($identLabel&self::IDENT_NAME)
554 554
 		{
555
-			$name[] = $_account['ident_realname']. ' ';
555
+			$name[] = $_account['ident_realname'].' ';
556 556
 		}
557 557
 
558
-		if ($identLabel & self::IDENT_ORG)
558
+		if ($identLabel&self::IDENT_ORG)
559 559
 		{
560 560
 			$name[] = $_account['ident_org'];
561 561
 		}
562 562
 
563
-		if ($identLabel & self::IDENT_EMAIL || empty($name))
563
+		if ($identLabel&self::IDENT_EMAIL || empty($name))
564 564
 		{
565
-			if (strpos($_account['ident_email'], '@') !== false || trim($_account['ident_email']) !='')
565
+			if (strpos($_account['ident_email'], '@') !== false || trim($_account['ident_email']) != '')
566 566
 			{
567 567
 				$name[] = ' <'.$_account['ident_email'].'>';
568 568
 			}
569
-			elseif(strpos($_account['acc_imap_username'], '@') !== false || trim($_account['acc_imap_username']) !='')
569
+			elseif (strpos($_account['acc_imap_username'], '@') !== false || trim($_account['acc_imap_username']) != '')
570 570
 			{
571 571
 				$name[] = ' <'.$_account['acc_imap_username'].'>';
572 572
 			}
Please login to merge, or discard this patch.
Braces   +54 added lines, -14 removed lines patch added patch discarded remove patch
@@ -133,7 +133,10 @@  discard block
 block discarded – undo
133 133
 		$hasChildren = 0;
134 134
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
135 135
 				in_array('\Haschildren', $_node['ATTRIBUTES']) ||
136
-				in_array('\HasChildren', $_node['ATTRIBUTES'])) $hasChildren = 1;
136
+				in_array('\HasChildren', $_node['ATTRIBUTES']))
137
+		{
138
+			$hasChildren = 1;
139
+		}
137 140
 		return $hasChildren;
138 141
 	}
139 142
 
@@ -146,7 +149,10 @@  discard block
 block discarded – undo
146 149
 	private static function isAccountNode ($_node)
147 150
 	{
148 151
 		list(,$leaf) = explode(self::DELIMITER, $_node);
149
-		if ($leaf || $_node == null) return false;
152
+		if ($leaf || $_node == null)
153
+		{
154
+			return false;
155
+		}
150 156
 		return true;
151 157
 	}
152 158
 
@@ -185,17 +191,24 @@  discard block
 block discarded – undo
185 191
 	{
186 192
 		//Init mail folders
187 193
 		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
188
-		if (!isset($this->ui->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
194
+		if (!isset($this->ui->mail_bo))
195
+		{
196
+			throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
197
+		}
189 198
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
190 199
 
191
-		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
200
+		if ($_parent)
201
+		{
202
+			list($_profileID) = explode(self::DELIMITER, $_parent);
203
+		}
192 204
 
193 205
 		if (is_numeric($_profileID) && $_profileID != $this->ui->mail_bo->profileID)
194 206
 		{
195 207
 			try
196 208
 			{
197 209
 				$this->ui->changeProfile($_profileID);
198
-			} catch (Exception $ex) {
210
+			}
211
+			catch (Exception $ex) {
199 212
 				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
200 213
 			}
201 214
 		}
@@ -205,9 +218,12 @@  discard block
 block discarded – undo
205 218
 			// *** Note: Should not apply any imap transaction, because in case of exception it will stop the
206 219
 			// process of rendering root node
207 220
 
208
-			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
221
+			if ($_parent && !self::isAccountNode($_parent))
222
+			{
223
+				// Single node loader
209 224
 			{
210 225
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
226
+			}
211 227
 				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
212 228
 
213 229
 				$childrenNode = array();
@@ -232,15 +248,21 @@  discard block
 block discarded – undo
232 248
 			}
233 249
 			else //Top Level Nodes loader
234 250
 			{
235
-				if (self::isAccountNode($_parent)) // An account called for open
251
+				if (self::isAccountNode($_parent))
252
+				{
253
+					// An account called for open
236 254
 				{
237 255
 					$_openTopLevel = 1;
256
+				}
238 257
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
239 258
 				}
240 259
 				else // Initial accounts|root nodes
241 260
 				{
242 261
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
243
-					if (!$_profileID && !$_openTopLevel) return $tree;
262
+					if (!$_profileID && !$_openTopLevel)
263
+					{
264
+						return $tree;
265
+					}
244 266
 				}
245 267
 
246 268
 				//List of folders
@@ -341,19 +363,28 @@  discard block
 block discarded – undo
341 363
 			{
342 364
 				$helper = array_slice($parents,1,null,true);
343 365
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
344
-				if ($parent) $parent .= $del;
366
+				if ($parent)
367
+				{
368
+					$parent .= $del;
369
+				}
345 370
 			}
346 371
 			else
347 372
 			{
348 373
 				$parent = implode(self::DELIMITER, $parents);
349
-				if ($parent) $parent .= self::DELIMITER;
374
+				if ($parent)
375
+				{
376
+					$parent .= self::DELIMITER;
377
+				}
350 378
 			}
351 379
 
352 380
 			if (!is_array($insert) || !isset($insert['item']))
353 381
 			{
354 382
 				// throwing an exeption here seems to be unrecoverable,
355 383
 				// even if the cause is a something that can be handeled by the mailserver
356
-				if (mail_bo::$debug) error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
384
+				if (mail_bo::$debug)
385
+				{
386
+					error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
387
+				}
357 388
 				// should we hit the break? if in personal: sure, something is wrong with the folderstructure
358 389
 				// if in shared or others we may proceed as access to folders may very well be limited to
359 390
 				// a single folder within the tree
@@ -364,11 +395,17 @@  discard block
 block discarded – undo
364 395
 					// we want to create the node in question as we meet the above considerations
365 396
 					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
366 397
 					{
367
-						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
398
+						if (mail_bo::$debug)
399
+						{
400
+							error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
401
+						}
368 402
 						$break=false;
369 403
 					}
370 404
 				}
371
-				if ($break) break;
405
+				if ($break)
406
+				{
407
+					break;
408
+				}
372 409
 			}
373 410
 			if ($insert['item'])
374 411
 			{
@@ -476,7 +513,10 @@  discard block
 block discarded – undo
476 513
 
477 514
 		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
478 515
 		{
479
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
516
+			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID)
517
+			{
518
+				continue;
519
+			}
480 520
 			$identity = self::getIdentityName(Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id'], true));
481 521
 			// Open top level folders for active account
482 522
 			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
Please login to merge, or discard this patch.
notifications/inc/class.notifications.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -434,7 +434,7 @@
 block discarded – undo
434 434
 	 * Sets backends that should be skipped even if the user
435 435
 	 * defined them in its chain
436 436
 	 *
437
-	 * @param array $_skip_backends array with names of the backends to be skipped
437
+	 * @param string[] $_skip_backends array with names of the backends to be skipped
438 438
 	 * e.g. array('popup', 'winpopup')
439 439
 	 */
440 440
 	public function set_skip_backends(array $_skip_backends) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -660,14 +660,14 @@
 block discarded – undo
660 660
 	 }
661 661
 
662 662
 	 /**
663
-	 * returns notification chains based on admin prefs
664
-	 * @abstract the available chains can be retrieved in two different output formats:
665
-	 * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
-	 * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
-	 *
668
-	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
-	 * @return array containing notification chains, output like given in $_output
670
-	 */
663
+	  * returns notification chains based on admin prefs
664
+	  * @abstract the available chains can be retrieved in two different output formats:
665
+	  * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
+	  * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
+	  *
668
+	  * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
+	  * @return array containing notification chains, output like given in $_output
670
+	  */
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 */
187 187
 	public function __construct() {
188
-		$this->config = (object) Api\Config::read(self::_appname);
188
+		$this->config = (object)Api\Config::read(self::_appname);
189 189
 	}
190 190
 
191 191
 	/**
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param boolean $reset =false true: reset all errors
195 195
 	 * @return array
196 196
 	 */
197
-	public static function errors($reset=false)
197
+	public static function errors($reset = false)
198 198
 	{
199 199
 		$ret = self::$errors;
200 200
 		if ($reset) self::$errors = array();
@@ -209,19 +209,19 @@  discard block
 block discarded – undo
209 209
 	 * it's an int with the account id or the e-mail address of a non-eGW user
210 210
 	 */
211 211
 	public function set_sender($_sender) {
212
-		if(is_object($_sender)) {
212
+		if (is_object($_sender)) {
213 213
 			$this->sender = $_sender;
214 214
 			return true;
215 215
 		} else {
216 216
 			// no object atm, we have to handle this and make a pseudo-object
217
-			if(is_numeric($_sender)) {
218
-				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
217
+			if (is_numeric($_sender)) {
218
+				$this->sender = (object)$GLOBALS['egw']->accounts->read($_sender);
219 219
 				return true;
220 220
 			}
221
-			if(is_string($_sender) && strpos($_sender,'@')) {
222
-				$this->sender = (object) array (
223
-									'account_email' => $this->get_addresspart($_sender,'email'),
224
-									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
221
+			if (is_string($_sender) && strpos($_sender, '@')) {
222
+				$this->sender = (object)array(
223
+									'account_email' => $this->get_addresspart($_sender, 'email'),
224
+									'account_fullname' => $this->get_addresspart($_sender, 'fullname'),
225 225
 									);
226 226
 				return true;
227 227
 			}
@@ -251,19 +251,19 @@  discard block
 block discarded – undo
251 251
 	 * it's an int with the account id or the e-mail address of a non-eGW user
252 252
 	 */
253 253
 	public function add_receiver($_receiver) {
254
-		if(is_object($_receiver)) {
254
+		if (is_object($_receiver)) {
255 255
 			$this->receivers[] = $_receiver;
256 256
 			return true;
257 257
 		} else {
258 258
 			// no object atm, we have to handle this and make a pseudo-object
259
-			if(is_numeric($_receiver)) {
260
-				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
259
+			if (is_numeric($_receiver)) {
260
+				$this->receivers[] = (object)$GLOBALS['egw']->accounts->read($_receiver);
261 261
 				return true;
262 262
 			}
263
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
264
-				$this->receivers[] = (object) array (
265
-									'account_email' => $this->get_addresspart($_receiver,'email'),
266
-									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
263
+			if (is_string($_receiver) && strpos($_receiver, '@')) {
264
+				$this->receivers[] = (object)array(
265
+									'account_email' => $this->get_addresspart($_receiver, 'email'),
266
+									'account_fullname' => $this->get_addresspart($_receiver, 'fullname'),
267 267
 									);
268 268
 				return true;
269 269
 			}
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 	 * @param string $_type Type of message, 'plain' or 'html'
305 305
 	 */
306 306
 	public function set_message($_message, $_type = false) {
307
-		if(!$_type)
307
+		if (!$_type)
308 308
 		{
309 309
 			$_type = strlen($_message) == strlen(strip_tags($_message)) ? 'plain' : 'html';
310 310
 		}
311
-		if($_type == 'plain') {
311
+		if ($_type == 'plain') {
312 312
 			$this->message_plain = $_message;
313 313
 		} else {
314 314
 			$this->message_html = $_message;
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function set_popupmessage($_message) {
328 328
 		//popup requires html
329
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
329
+		if (strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
330 330
 		$this->message_popup = $_message;
331 331
 		return true;
332 332
 	}
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function set_links(array $_links) {
340 340
 		$this->links = array(); // clear array if set
341
-		foreach($_links as $link) {
342
-			if(is_array($link)) {
343
-				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
341
+		foreach ($_links as $link) {
342
+			if (is_array($link)) {
343
+				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'], $link['id']);
344 344
 			}
345 345
 		}
346 346
 		return true;
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 */
354 354
 	public function set_popuplinks(array $_links) {
355 355
 		$this->popup_links = array(); // clear array if set
356
-		foreach($_links as $link) {
357
-			if(is_array($link)) {
356
+		foreach ($_links as $link) {
357
+			if (is_array($link)) {
358 358
 				$this->add_popuplink($link['text'], $link['view'], $link['popup'], $link['app']);
359 359
 			}
360 360
 		}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
372 372
 	 */
373 373
 	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
374
-		if(!$_view || !$_text) { return false; }
374
+		if (!$_view || !$_text) { return false; }
375 375
 		$this->links[] = (object)array(
376 376
 			'text'	=> $_text,
377 377
 			'view'	=> $_view,
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 * @param string $_app application name
392 392
 	 */
393 393
 	public function add_popuplink($_text, $_view, $_popup = false, $_app = '') {
394
-		if(!$_view || !$_text) { return false; }
394
+		if (!$_view || !$_text) { return false; }
395 395
 		$this->popup_links[] = (object)array(
396 396
 										'text'	=> $_text,
397 397
 										'view'	=> $_view,
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 */
409 409
 	public function set_attachments(array $_attachments) {
410 410
 		$this->attachments = array(); // clear array if set
411
-		foreach($_attachments as $attachment) {
412
-			if(is_array($attachment)) {
411
+		foreach ($_attachments as $attachment) {
412
+			if (is_array($attachment)) {
413 413
 				$this->add_attachment(
414 414
 					$attachment['string'],
415 415
 					$attachment['filename'],
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 * @param string $_type File extension (MIME) type.
434 434
 	 * @param string $_path optional path to attachment, if !$_string
435 435
 	 */
436
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
437
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
436
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path = null) {
437
+		if (!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
438 438
 		$this->attachments[] = (object)array(
439 439
 			'string' => $_string,
440 440
 			'filename' => $_filename,
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 		if (!is_array($this->receivers) || count($this->receivers) == 0) {
467 467
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
468 468
 		}
469
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
469
+		if (!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
470 470
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
471 471
 		}
472 472
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 			$backend_errors = array();
481 481
 			try {
482 482
 				// system or non-system user
483
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
483
+				if ($receiver->account_id && is_numeric($receiver->account_id)) {
484 484
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
485 485
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
486 486
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -493,17 +493,17 @@  discard block
 block discarded – undo
493 493
 					}
494 494
 					$receiver->handle = $receiver->account_lid;
495 495
 					// check if the receiver has rights to run the notifcation app
496
-					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
496
+					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id, true);
497 497
 					$ids[] = $receiver->account_id;
498
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
498
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids, 'run', 'notifications')) {
499 499
 						// read the users notification chain
500 500
 						$prefs = new Api\Preferences($receiver->account_id);
501 501
 						$preferences_all = $prefs->read();
502 502
 						$preferences = (object)$preferences_all[self::_appname];
503
-						if($preferences->notification_chain) {
503
+						if ($preferences->notification_chain) {
504 504
 							// fallback: admin disabled user-chosen chain
505
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
506
-								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
505
+							if (!$notification_chain = $available_chains[$preferences->notification_chain]) {
506
+								$prepend_message .= lang('This eGroupWare notification has been sent to you by mail because your'
507 507
 															.' chosen notification-chain has been disabled by the administrator.'
508 508
 															.' Please choose another notification-chain in your preferences!');
509 509
 								$notification_chain = $available_chains[self::_fallback];
@@ -520,28 +520,28 @@  discard block
 block discarded – undo
520 520
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
521 521
 				}
522 522
 
523
-				if($notification_chain == 'disable') {
523
+				if ($notification_chain == 'disable') {
524 524
 					continue; //user disabled notifications
525 525
 				}
526 526
 
527
-				foreach($notification_chain as $backend => $action) {
527
+				foreach ($notification_chain as $backend => $action) {
528 528
 					$notification_backend = null;
529 529
 					try {
530 530
 						// check if backend should be skipped
531
-						if( in_array($backend, $this->skip_backends) ) {
531
+						if (in_array($backend, $this->skip_backends)) {
532 532
 							// log as error just for the case too much skipping prevents user from being notified
533 533
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
534 534
 							continue;
535 535
 						}
536 536
 
537 537
 						$notification_backend = self::_appname.'_'.$backend;
538
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
539
-							throw new Exception('file for '.$notification_backend. ' does not exist');
538
+						if (!file_exists(EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.'.$notification_backend.'.inc.php')) {
539
+							throw new Exception('file for '.$notification_backend.' does not exist');
540 540
 						}
541
-						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
542
-						if ( !($obj instanceof notifications_iface) ) {
543
-							unset ( $obj );
544
-					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
541
+						$obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences);
542
+						if (!($obj instanceof notifications_iface)) {
543
+							unset ($obj);
544
+					 		throw new Exception($notification_backend.' is no implementation of notifications_iface');
545 545
 						}
546 546
 						$lsubject = $this->subject;
547 547
 						$llinks = $this->links;
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 						// This is to make popup_or_email option sensfull since
557 557
 						// we save popup notifications in database anyway, email
558 558
 						// notifications should be based on user availability.
559
-						if ($backend == 'popup' && $action== 'fail' && !Api\Session::notifications_active($receiver->account_id))
559
+						if ($backend == 'popup' && $action == 'fail' && !Api\Session::notifications_active($receiver->account_id))
560 560
 						{
561 561
 							throw new Exception();
562 562
 						}
@@ -564,17 +564,17 @@  discard block
 block discarded – undo
564 564
 					catch (Exception $exception) {
565 565
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
566 566
 						// try next backend
567
-						if($action == 'fail' || $action == 'continue') {
567
+						if ($action == 'fail' || $action == 'continue') {
568 568
 							continue;
569 569
 						}
570 570
 						break; // stop running through chain
571 571
 					}
572 572
 					// backend sucseeded
573 573
 					$user_notified = true;
574
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
574
+					if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain
575 575
 				}
576 576
 				// check if the user has been notified at all
577
-				if(!$user_notified) {
577
+				if (!$user_notified) {
578 578
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
579 579
 					foreach($backend_errors as $id=>$backend_error) {
580 580
 						error_log($backend_error);
@@ -601,22 +601,22 @@  discard block
 block discarded – undo
601 601
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
602 602
 	 */
603 603
 	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
604
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
604
+		if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
605 605
 		$messages = array();
606 606
 
607 607
 		// create the messages
608
-		if(!empty($_message_plain)) {
608
+		if (!empty($_message_plain)) {
609 609
 			$messages['plain'] = $_message_plain;
610 610
 		} else {
611 611
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
612 612
 		}
613 613
 
614
-		if(!empty($_message_html)) {
614
+		if (!empty($_message_html)) {
615 615
 			$messages['html'] = $_message_html;
616 616
 		} else {
617 617
 			$messages['html'] = self::plain2html($_message_plain);
618 618
 		}
619
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
619
+		if (!empty($_message_popup)) $messages['popup'] = $_message_popup;
620 620
 		return $messages;
621 621
 	}
622 622
 
@@ -639,9 +639,9 @@  discard block
 block discarded – undo
639 639
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
640 640
 	 */
641 641
 	 private function prepend_message(array $_messages, $_prepend = null) {
642
-		if(strlen($_prepend) > 0) {
643
-			foreach($_messages as $key => $value) {
644
-				switch($key) {
642
+		if (strlen($_prepend) > 0) {
643
+			foreach ($_messages as $key => $value) {
644
+				switch ($key) {
645 645
 					case 'plain':
646 646
 						$_messages[$key] = $_prepend."\n\n".$value;
647 647
 						break;
@@ -665,17 +665,17 @@  discard block
 block discarded – undo
665 665
 	 * @param string $_part
666 666
 	 * @return string chosen part of the address
667 667
 	 */
668
-	private function get_addresspart($_address, $_part='email')
668
+	private function get_addresspart($_address, $_part = 'email')
669 669
 	{
670 670
 		$parts = null;
671
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
672
-	 		$fullname = trim(trim($parts[1]),'\"');
671
+	 	if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part
672
+	 		$fullname = trim(trim($parts[1]), '\"');
673 673
 	 		$email = $parts[2];
674 674
 	 	} else {
675 675
 	 		$fullname = false;
676 676
 	 		$email = $_address;
677 677
 	 	}
678
-	 	switch($_part) {
678
+	 	switch ($_part) {
679 679
 	 		case 'fullname':
680 680
 	 			return $fullname;
681 681
 	 		case 'email':
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	public function get_available_chains($_output = 'routing') {
698 698
 		// determine enabled backends from Api\Config
699 699
 		$enabled_backends = array();
700
-		foreach($this->backends as $backend) {
701
-			switch($backend) {
700
+		foreach ($this->backends as $backend) {
701
+			switch ($backend) {
702 702
 				case 'email':
703 703
 				case 'popup':
704 704
 				case 'jpopup':
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 
714 714
 		$enabled_chains = array();
715 715
 		$disabled_chains = array();
716
-		foreach($this->notification_chains as $key => $chain) {
716
+		foreach ($this->notification_chains as $key => $chain) {
717 717
 			$allow_chain = true;
718
-			if(is_array($chain)) {
719
-				foreach(array_keys($chain) as $name) {
720
-					if(!$enabled_backends[$name]) {
718
+			if (is_array($chain)) {
719
+				foreach (array_keys($chain) as $name) {
720
+					if (!$enabled_backends[$name]) {
721 721
 						$allow_chain = false; // disable whole chain if one backend is disabled
722 722
 					}
723 723
 				}
724
-				if($allow_chain) {
724
+				if ($allow_chain) {
725 725
 					$enabled_chains[$key] = $chain;
726 726
 				} else {
727 727
 					$disabled_chains[$key] = $chain;
@@ -736,15 +736,15 @@  discard block
 block discarded – undo
736 736
 		// create the 'all' chain from the enabled backends
737 737
 		$chain_all = array();
738 738
 		$backend_count = 1;
739
-		foreach($enabled_backends as $backend => $enabled) {
740
-			if($enabled) {
739
+		foreach ($enabled_backends as $backend => $enabled) {
740
+			if ($enabled) {
741 741
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
742 742
 			}
743 743
 			$backend_count++;
744 744
 		}
745 745
 		$common_chains['all'] = $chain_all;
746 746
 
747
-		switch($_output) {
747
+		switch ($_output) {
748 748
 			case 'human':
749 749
 				$chain_groups = array(
750 750
 					lang('Common chains')	=> 'common_chains',
@@ -753,10 +753,10 @@  discard block
 block discarded – undo
753 753
 					);
754 754
 				$suffix = '_human';
755 755
 				// create descriptions for each chain key in each group
756
-				foreach($chain_groups as $name => $arr_name) {
756
+				foreach ($chain_groups as $name => $arr_name) {
757 757
 					${$arr_name.$suffix} = array();
758
-					foreach(array_keys(${$arr_name}) as $key) {
759
-						if($arr_name == 'disabled_chains') {
758
+					foreach (array_keys(${$arr_name}) as $key) {
759
+						if ($arr_name == 'disabled_chains') {
760 760
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
761 761
 						} else {
762 762
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 				}
766 766
 				// summarize all groups with minimum one chain to the final array
767 767
 				$chains_final = array();
768
-				foreach($chain_groups as $name => $arr_name) {
769
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
768
+				foreach ($chain_groups as $name => $arr_name) {
769
+					if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
770 770
 						$chains_final[$name] = ${$arr_name.$suffix};
771 771
 					}
772 772
 				}
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
787 787
 	 */
788 788
 	public function deleteaccount($settings) {
789
-		foreach($this->backends as $backend) {
790
-			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
789
+		foreach ($this->backends as $backend) {
790
+			$backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount');
791 791
 			if (is_callable($backend_hook)) {
792
-				call_user_func($backend_hook,$settings);
792
+				call_user_func($backend_hook, $settings);
793 793
 			}
794 794
 		}
795 795
 	}
Please login to merge, or discard this patch.
Braces   +228 added lines, -98 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
  * called from this class. The backend's job is to deliver ONE message to ONE recipient.
25 25
  *
26 26
  */
27
-class notifications {
27
+class notifications
28
+{
28 29
 
29 30
 	/**
30 31
 	 * Appname
@@ -184,7 +185,8 @@  discard block
 block discarded – undo
184 185
 	 * constructor of notifications
185 186
 	 *
186 187
 	 */
187
-	public function __construct() {
188
+	public function __construct()
189
+	{
188 190
 		$this->config = (object) Api\Config::read(self::_appname);
189 191
 	}
190 192
 
@@ -197,7 +199,10 @@  discard block
 block discarded – undo
197 199
 	public static function errors($reset=false)
198 200
 	{
199 201
 		$ret = self::$errors;
200
-		if ($reset) self::$errors = array();
202
+		if ($reset)
203
+		{
204
+			self::$errors = array();
205
+		}
201 206
 		return $ret;
202 207
 	}
203 208
 
@@ -208,17 +213,23 @@  discard block
 block discarded – undo
208 213
 	 * as long as the accounts class isn't a nice object,
209 214
 	 * it's an int with the account id or the e-mail address of a non-eGW user
210 215
 	 */
211
-	public function set_sender($_sender) {
212
-		if(is_object($_sender)) {
216
+	public function set_sender($_sender)
217
+	{
218
+		if(is_object($_sender))
219
+		{
213 220
 			$this->sender = $_sender;
214 221
 			return true;
215
-		} else {
222
+		}
223
+		else
224
+		{
216 225
 			// no object atm, we have to handle this and make a pseudo-object
217
-			if(is_numeric($_sender)) {
226
+			if(is_numeric($_sender))
227
+			{
218 228
 				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
219 229
 				return true;
220 230
 			}
221
-			if(is_string($_sender) && strpos($_sender,'@')) {
231
+			if(is_string($_sender) && strpos($_sender,'@'))
232
+			{
222 233
 				$this->sender = (object) array (
223 234
 									'account_email' => $this->get_addresspart($_sender,'email'),
224 235
 									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
@@ -236,9 +247,11 @@  discard block
 block discarded – undo
236 247
 	 * as long as the accounts class isn't a nice object,
237 248
 	 * it's an array with the int of the account id or the e-mail address of a non-eGW user
238 249
 	 */
239
-	public function set_receivers(array $_receivers) {
250
+	public function set_receivers(array $_receivers)
251
+	{
240 252
 		$this->receivers = array();
241
-		foreach ($_receivers as $receiver) {
253
+		foreach ($_receivers as $receiver)
254
+		{
242 255
 			$this->add_receiver($receiver);
243 256
 		}
244 257
 	}
@@ -250,17 +263,23 @@  discard block
 block discarded – undo
250 263
 	 * as long as the accounts class isn't a nice object,
251 264
 	 * it's an int with the account id or the e-mail address of a non-eGW user
252 265
 	 */
253
-	public function add_receiver($_receiver) {
254
-		if(is_object($_receiver)) {
266
+	public function add_receiver($_receiver)
267
+	{
268
+		if(is_object($_receiver))
269
+		{
255 270
 			$this->receivers[] = $_receiver;
256 271
 			return true;
257
-		} else {
272
+		}
273
+		else
274
+		{
258 275
 			// no object atm, we have to handle this and make a pseudo-object
259
-			if(is_numeric($_receiver)) {
276
+			if(is_numeric($_receiver))
277
+			{
260 278
 				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
261 279
 				return true;
262 280
 			}
263
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
281
+			if(is_string($_receiver) && strpos($_receiver,'@'))
282
+			{
264 283
 				$this->receivers[] = (object) array (
265 284
 									'account_email' => $this->get_addresspart($_receiver,'email'),
266 285
 									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
@@ -276,7 +295,8 @@  discard block
 block discarded – undo
276 295
 	 *
277 296
 	 * @param string $_subject
278 297
 	 */
279
-	public function set_subject($_subject) {
298
+	public function set_subject($_subject)
299
+	{
280 300
 		$this->subject = $_subject;
281 301
 		return true;
282 302
 	}
@@ -286,7 +306,8 @@  discard block
 block discarded – undo
286 306
 	 *
287 307
 	 * @param string $_subject
288 308
 	 */
289
-	public function set_popupsubject($_subject) {
309
+	public function set_popupsubject($_subject)
310
+	{
290 311
 		$this->popupsubject = $_subject;
291 312
 		return true;
292 313
 	}
@@ -303,14 +324,18 @@  discard block
 block discarded – undo
303 324
 	 * @param string $_message
304 325
 	 * @param string $_type Type of message, 'plain' or 'html'
305 326
 	 */
306
-	public function set_message($_message, $_type = false) {
327
+	public function set_message($_message, $_type = false)
328
+	{
307 329
 		if(!$_type)
308 330
 		{
309 331
 			$_type = strlen($_message) == strlen(strip_tags($_message)) ? 'plain' : 'html';
310 332
 		}
311
-		if($_type == 'plain') {
333
+		if($_type == 'plain')
334
+		{
312 335
 			$this->message_plain = $_message;
313
-		} else {
336
+		}
337
+		else
338
+		{
314 339
 			$this->message_html = $_message;
315 340
 		}
316 341
 		return true;
@@ -324,9 +349,13 @@  discard block
 block discarded – undo
324 349
 	 *
325 350
 	 * @param string $_message
326 351
 	 */
327
-	public function set_popupmessage($_message) {
352
+	public function set_popupmessage($_message)
353
+	{
328 354
 		//popup requires html
329
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
355
+		if(strlen($_message) == strlen(strip_tags($_message)))
356
+		{
357
+			$_message = self::plain2html($_message);
358
+		}
330 359
 		$this->message_popup = $_message;
331 360
 		return true;
332 361
 	}
@@ -336,10 +365,13 @@  discard block
 block discarded – undo
336 365
 	 *
337 366
 	 * @param array $_links link array (like defined in $this->add_link)
338 367
 	 */
339
-	public function set_links(array $_links) {
368
+	public function set_links(array $_links)
369
+	{
340 370
 		$this->links = array(); // clear array if set
341
-		foreach($_links as $link) {
342
-			if(is_array($link)) {
371
+		foreach($_links as $link)
372
+		{
373
+			if(is_array($link))
374
+			{
343 375
 				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
344 376
 			}
345 377
 		}
@@ -351,10 +383,13 @@  discard block
 block discarded – undo
351 383
 	 *
352 384
 	 * @param array $_links link array (like defined in $this->add_link)
353 385
 	 */
354
-	public function set_popuplinks(array $_links) {
386
+	public function set_popuplinks(array $_links)
387
+	{
355 388
 		$this->popup_links = array(); // clear array if set
356
-		foreach($_links as $link) {
357
-			if(is_array($link)) {
389
+		foreach($_links as $link)
390
+		{
391
+			if(is_array($link))
392
+			{
358 393
 				$this->add_popuplink($link['text'], $link['view'], $link['popup'], $link['app']);
359 394
 			}
360 395
 		}
@@ -370,8 +405,11 @@  discard block
 block discarded – undo
370 405
 	 * @param string $_app Application name, to use link registry (popup & view ignored)
371 406
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
372 407
 	 */
373
-	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
374
-		if(!$_view || !$_text) { return false; }
408
+	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false)
409
+	{
410
+		if(!$_view || !$_text)
411
+		{
412
+return false; }
375 413
 		$this->links[] = (object)array(
376 414
 			'text'	=> $_text,
377 415
 			'view'	=> $_view,
@@ -390,8 +428,11 @@  discard block
 block discarded – undo
390 428
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
391 429
 	 * @param string $_app application name
392 430
 	 */
393
-	public function add_popuplink($_text, $_view, $_popup = false, $_app = '') {
394
-		if(!$_view || !$_text) { return false; }
431
+	public function add_popuplink($_text, $_view, $_popup = false, $_app = '')
432
+	{
433
+		if(!$_view || !$_text)
434
+		{
435
+return false; }
395 436
 		$this->popup_links[] = (object)array(
396 437
 										'text'	=> $_text,
397 438
 										'view'	=> $_view,
@@ -406,10 +447,13 @@  discard block
 block discarded – undo
406 447
 	 *
407 448
 	 * @param array $_attachments attachment array (like defined in $this->add_attachment)
408 449
 	 */
409
-	public function set_attachments(array $_attachments) {
450
+	public function set_attachments(array $_attachments)
451
+	{
410 452
 		$this->attachments = array(); // clear array if set
411
-		foreach($_attachments as $attachment) {
412
-			if(is_array($attachment)) {
453
+		foreach($_attachments as $attachment)
454
+		{
455
+			if(is_array($attachment))
456
+			{
413 457
 				$this->add_attachment(
414 458
 					$attachment['string'],
415 459
 					$attachment['filename'],
@@ -433,8 +477,12 @@  discard block
 block discarded – undo
433 477
 	 * @param string $_type File extension (MIME) type.
434 478
 	 * @param string $_path optional path to attachment, if !$_string
435 479
 	 */
436
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
437
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
480
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null)
481
+	{
482
+		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename)
483
+		{
484
+			return false;
485
+		}
438 486
 		$this->attachments[] = (object)array(
439 487
 			'string' => $_string,
440 488
 			'filename' => $_filename,
@@ -452,21 +500,26 @@  discard block
 block discarded – undo
452 500
 	 * @param array $_skip_backends array with names of the backends to be skipped
453 501
 	 * e.g. array('popup', 'winpopup')
454 502
 	 */
455
-	public function set_skip_backends(array $_skip_backends) {
503
+	public function set_skip_backends(array $_skip_backends)
504
+	{
456 505
 		$this->skip_backends = $_skip_backends;
457 506
 	}
458 507
 
459 508
 	/**
460 509
 	 * sends notifications
461 510
 	 */
462
-	public function send() {
463
-		if (!is_object($this->sender)) {
511
+	public function send()
512
+	{
513
+		if (!is_object($this->sender))
514
+		{
464 515
 			throw new Exception('Error: cannot send notifications. No sender supplied');
465 516
 		}
466
-		if (!is_array($this->receivers) || count($this->receivers) == 0) {
517
+		if (!is_array($this->receivers) || count($this->receivers) == 0)
518
+		{
467 519
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
468 520
 		}
469
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
521
+		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup))
522
+		{
470 523
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
471 524
 		}
472 525
 
@@ -474,13 +527,15 @@  discard block
 block discarded – undo
474 527
 
475 528
 		$available_chains = $this->get_available_chains('routing');
476 529
 
477
-		foreach ($this->receivers as $receiver) {
530
+		foreach ($this->receivers as $receiver)
531
+		{
478 532
 			$user_notified = false;
479 533
 			$prepend_message = '';
480 534
 			$backend_errors = array();
481 535
 			try {
482 536
 				// system or non-system user
483
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
537
+				if($receiver->account_id && is_numeric($receiver->account_id))
538
+				{
484 539
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
485 540
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
486 541
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -495,51 +550,65 @@  discard block
 block discarded – undo
495 550
 					// check if the receiver has rights to run the notifcation app
496 551
 					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
497 552
 					$ids[] = $receiver->account_id;
498
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
553
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications'))
554
+					{
499 555
 						// read the users notification chain
500 556
 						$prefs = new Api\Preferences($receiver->account_id);
501 557
 						$preferences_all = $prefs->read();
502 558
 						$preferences = (object)$preferences_all[self::_appname];
503
-						if($preferences->notification_chain) {
559
+						if($preferences->notification_chain)
560
+						{
504 561
 							// fallback: admin disabled user-chosen chain
505
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
562
+							if(!$notification_chain = $available_chains[$preferences->notification_chain])
563
+							{
506 564
 								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
507 565
 															.' chosen notification-chain has been disabled by the administrator.'
508 566
 															.' Please choose another notification-chain in your preferences!');
509 567
 								$notification_chain = $available_chains[self::_fallback];
510 568
 							}
511
-						} else {
569
+						}
570
+						else
571
+						{
512 572
 							$notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs
513 573
 						}
514
-					} else {
574
+					}
575
+					else
576
+					{
515 577
 						$notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app
516 578
 					}
517
-				} else {
579
+				}
580
+				else
581
+				{
518 582
 					// non-system user
519 583
 					$receiver->handle = $receiver->account_email;
520 584
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
521 585
 				}
522 586
 
523
-				if($notification_chain == 'disable') {
587
+				if($notification_chain == 'disable')
588
+				{
524 589
 					continue; //user disabled notifications
525 590
 				}
526 591
 
527
-				foreach($notification_chain as $backend => $action) {
592
+				foreach($notification_chain as $backend => $action)
593
+				{
528 594
 					$notification_backend = null;
529 595
 					try {
530 596
 						// check if backend should be skipped
531
-						if( in_array($backend, $this->skip_backends) ) {
597
+						if( in_array($backend, $this->skip_backends) )
598
+						{
532 599
 							// log as error just for the case too much skipping prevents user from being notified
533 600
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
534 601
 							continue;
535 602
 						}
536 603
 
537 604
 						$notification_backend = self::_appname.'_'.$backend;
538
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
605
+						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php'))
606
+						{
539 607
 							throw new Exception('file for '.$notification_backend. ' does not exist');
540 608
 						}
541 609
 						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
542
-						if ( !($obj instanceof notifications_iface) ) {
610
+						if ( !($obj instanceof notifications_iface) )
611
+						{
543 612
 							unset ( $obj );
544 613
 					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
545 614
 						}
@@ -547,9 +616,18 @@  discard block
 block discarded – undo
547 616
 						$llinks = $this->links;
548 617
 						if ($backend == 'popup')
549 618
 						{
550
-							if (!empty($this->popupsubject)) $lsubject = $this->popupsubject;
551
-							if ($this->popup_links) $llinks = $this->popup_links;
552
-							if (is_array($this->popup_data)) $popup_data = $this->popup_data;
619
+							if (!empty($this->popupsubject))
620
+							{
621
+								$lsubject = $this->popupsubject;
622
+							}
623
+							if ($this->popup_links)
624
+							{
625
+								$llinks = $this->popup_links;
626
+							}
627
+							if (is_array($this->popup_data))
628
+							{
629
+								$popup_data = $this->popup_data;
630
+							}
553 631
 						}
554 632
 						$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments, $popup_data);
555 633
 
@@ -564,23 +642,30 @@  discard block
 block discarded – undo
564 642
 					catch (Exception $exception) {
565 643
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
566 644
 						// try next backend
567
-						if($action == 'fail' || $action == 'continue') {
645
+						if($action == 'fail' || $action == 'continue')
646
+						{
568 647
 							continue;
569 648
 						}
570 649
 						break; // stop running through chain
571 650
 					}
572 651
 					// backend sucseeded
573 652
 					$user_notified = true;
574
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
653
+					if($action == 'stop' || $action == 'fail')
654
+					{
655
+break; } // stop running through chain
575 656
 				}
576 657
 				// check if the user has been notified at all
577
-				if(!$user_notified) {
658
+				if(!$user_notified)
659
+				{
578 660
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
579 661
 					foreach($backend_errors as $id=>$backend_error) {
580 662
 						error_log($backend_error);
581 663
 					}*/
582 664
 					$error = implode(', ', $backend_errors);
583
-					if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error;
665
+					if (stripos($error, (string)$receiver->handle) !== false)
666
+					{
667
+						$error = $receiver->handle.': '.$error;
668
+					}
584 669
 					self::$errors[] = $error;
585 670
 				}
586 671
 			}
@@ -600,23 +685,35 @@  discard block
 block discarded – undo
600 685
 	 * @param string $_message_popup
601 686
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
602 687
 	 */
603
-	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
604
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
688
+	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '')
689
+	{
690
+		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup))
691
+		{
692
+return false; } // no message set
605 693
 		$messages = array();
606 694
 
607 695
 		// create the messages
608
-		if(!empty($_message_plain)) {
696
+		if(!empty($_message_plain))
697
+		{
609 698
 			$messages['plain'] = $_message_plain;
610
-		} else {
699
+		}
700
+		else
701
+		{
611 702
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
612 703
 		}
613 704
 
614
-		if(!empty($_message_html)) {
705
+		if(!empty($_message_html))
706
+		{
615 707
 			$messages['html'] = $_message_html;
616
-		} else {
708
+		}
709
+		else
710
+		{
617 711
 			$messages['html'] = self::plain2html($_message_plain);
618 712
 		}
619
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
713
+		if (!empty($_message_popup))
714
+		{
715
+			$messages['popup']=$_message_popup;
716
+		}
620 717
 		return $messages;
621 718
 	}
622 719
 
@@ -638,10 +735,14 @@  discard block
 block discarded – undo
638 735
 	 * @param string $_prepend just a plain message to prepend, no html!
639 736
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
640 737
 	 */
641
-	 private function prepend_message(array $_messages, $_prepend = null) {
642
-		if(strlen($_prepend) > 0) {
643
-			foreach($_messages as $key => $value) {
644
-				switch($key) {
738
+	 private function prepend_message(array $_messages, $_prepend = null)
739
+	 {
740
+		if(strlen($_prepend) > 0)
741
+		{
742
+			foreach($_messages as $key => $value)
743
+			{
744
+				switch($key)
745
+				{
645 746
 					case 'plain':
646 747
 						$_messages[$key] = $_prepend."\n\n".$value;
647 748
 						break;
@@ -668,14 +769,19 @@  discard block
 block discarded – undo
668 769
 	private function get_addresspart($_address, $_part='email')
669 770
 	{
670 771
 		$parts = null;
671
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
772
+	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts))
773
+	 	{
774
+// _address contains a fullname part
672 775
 	 		$fullname = trim(trim($parts[1]),'\"');
673 776
 	 		$email = $parts[2];
674
-	 	} else {
777
+	 	}
778
+	 	else
779
+	 	{
675 780
 	 		$fullname = false;
676 781
 	 		$email = $_address;
677 782
 	 	}
678
-	 	switch($_part) {
783
+	 	switch($_part)
784
+	 	{
679 785
 	 		case 'fullname':
680 786
 	 			return $fullname;
681 787
 	 		case 'email':
@@ -694,11 +800,14 @@  discard block
 block discarded – undo
694 800
 	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
695 801
 	 * @return array containing notification chains, output like given in $_output
696 802
 	 */
697
-	public function get_available_chains($_output = 'routing') {
803
+	public function get_available_chains($_output = 'routing')
804
+	{
698 805
 		// determine enabled backends from Api\Config
699 806
 		$enabled_backends = array();
700
-		foreach($this->backends as $backend) {
701
-			switch($backend) {
807
+		foreach($this->backends as $backend)
808
+		{
809
+			switch($backend)
810
+			{
702 811
 				case 'email':
703 812
 				case 'popup':
704 813
 				case 'jpopup':
@@ -713,17 +822,24 @@  discard block
 block discarded – undo
713 822
 
714 823
 		$enabled_chains = array();
715 824
 		$disabled_chains = array();
716
-		foreach($this->notification_chains as $key => $chain) {
825
+		foreach($this->notification_chains as $key => $chain)
826
+		{
717 827
 			$allow_chain = true;
718
-			if(is_array($chain)) {
719
-				foreach(array_keys($chain) as $name) {
720
-					if(!$enabled_backends[$name]) {
828
+			if(is_array($chain))
829
+			{
830
+				foreach(array_keys($chain) as $name)
831
+				{
832
+					if(!$enabled_backends[$name])
833
+					{
721 834
 						$allow_chain = false; // disable whole chain if one backend is disabled
722 835
 					}
723 836
 				}
724
-				if($allow_chain) {
837
+				if($allow_chain)
838
+				{
725 839
 					$enabled_chains[$key] = $chain;
726
-				} else {
840
+				}
841
+				else
842
+				{
727 843
 					$disabled_chains[$key] = $chain;
728 844
 				}
729 845
 			}
@@ -736,15 +852,18 @@  discard block
 block discarded – undo
736 852
 		// create the 'all' chain from the enabled backends
737 853
 		$chain_all = array();
738 854
 		$backend_count = 1;
739
-		foreach($enabled_backends as $backend => $enabled) {
740
-			if($enabled) {
855
+		foreach($enabled_backends as $backend => $enabled)
856
+		{
857
+			if($enabled)
858
+			{
741 859
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
742 860
 			}
743 861
 			$backend_count++;
744 862
 		}
745 863
 		$common_chains['all'] = $chain_all;
746 864
 
747
-		switch($_output) {
865
+		switch($_output)
866
+		{
748 867
 			case 'human':
749 868
 				$chain_groups = array(
750 869
 					lang('Common chains')	=> 'common_chains',
@@ -753,20 +872,27 @@  discard block
 block discarded – undo
753 872
 					);
754 873
 				$suffix = '_human';
755 874
 				// create descriptions for each chain key in each group
756
-				foreach($chain_groups as $name => $arr_name) {
875
+				foreach($chain_groups as $name => $arr_name)
876
+				{
757 877
 					${$arr_name.$suffix} = array();
758
-					foreach(array_keys(${$arr_name}) as $key) {
759
-						if($arr_name == 'disabled_chains') {
878
+					foreach(array_keys(${$arr_name}) as $key)
879
+					{
880
+						if($arr_name == 'disabled_chains')
881
+						{
760 882
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
761
-						} else {
883
+						}
884
+						else
885
+						{
762 886
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
763 887
 						}
764 888
 					}
765 889
 				}
766 890
 				// summarize all groups with minimum one chain to the final array
767 891
 				$chains_final = array();
768
-				foreach($chain_groups as $name => $arr_name) {
769
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
892
+				foreach($chain_groups as $name => $arr_name)
893
+				{
894
+					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0)
895
+					{
770 896
 						$chains_final[$name] = ${$arr_name.$suffix};
771 897
 					}
772 898
 				}
@@ -785,10 +911,13 @@  discard block
 block discarded – undo
785 911
 	 *
786 912
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
787 913
 	 */
788
-	public function deleteaccount($settings) {
789
-		foreach($this->backends as $backend) {
914
+	public function deleteaccount($settings)
915
+	{
916
+		foreach($this->backends as $backend)
917
+		{
790 918
 			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
791
-			if (is_callable($backend_hook)) {
919
+			if (is_callable($backend_hook))
920
+			{
792 921
 				call_user_func($backend_hook,$settings);
793 922
 			}
794 923
 		}
@@ -802,7 +931,8 @@  discard block
 block discarded – undo
802 931
 	 * @param array $_data
803 932
 	 * @return boolean
804 933
 	 */
805
-	public function set_popupdata($_appname, $_data) {
934
+	public function set_popupdata($_appname, $_data)
935
+	{
806 936
 		$this->popup_data = array(
807 937
 			'appname' => $_appname,
808 938
 			'data' => $_data
Please login to merge, or discard this patch.
notifications/inc/class.notifications_email.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 	 * @param array $_links
132 132
 	 * @param boolean $_render_html
133 133
 	 * @param boolean $_render_external
134
-	 * @return plain or html rendered link(s) as complete string
134
+	 * @return false|string or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137 137
 		if(!is_array($_links) || count($_links) == 0) { return false; }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 	 * @param object $_preferences
67 67
 	 */
68 68
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
70
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
71 71
 		$this->sender = $_sender;
72 72
 		$this->recipient = $_recipient;
73 73
 		$this->config = $_config;
74 74
 		$this->preferences = $_preferences;
75
-		if(is_object($this->mail))
75
+		if (is_object($this->mail))
76 76
 		{
77 77
 			unset($this->mail);
78 78
 		}
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
 			// embed images as inline
113 113
 			\EGroupware\Api\Mail::processURL2InlineImages($this->mail, $body_html, null);
114 114
 		}
115
-		$this->mail->setHtmlBody($body_html, null, false);	// no automatic alternativ
115
+		$this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ
116 116
 		$this->mail->setBody($body_plain);
117 117
 
118
-		if(is_array($_attachments) && count($_attachments) > 0)
118
+		if (is_array($_attachments) && count($_attachments) > 0)
119 119
 		{
120
-			foreach($_attachments as $attachment)
120
+			foreach ($_attachments as $attachment)
121 121
 			{
122 122
 				if ($attachment->string)
123 123
 				{
124 124
 					$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
125 125
 				}
126
-				elseif($attachment->path)
126
+				elseif ($attachment->path)
127 127
 				{
128 128
 					$this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type);
129 129
 				}
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 * @return plain or html rendered link(s) as complete string
143 143
 	 */
144 144
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
145
-		if(!is_array($_links) || count($_links) == 0) { return false; }
145
+		if (!is_array($_links) || count($_links) == 0) { return false; }
146 146
 
147 147
 		// provide defaults if given arguments are null
148 148
 		// php distinguishes between missing and present(null) arguments
149
-		if(is_null($_render_html)) { $_render_html = false; }
150
-		if(is_null($_render_external)) { $_render_external = true; }
149
+		if (is_null($_render_html)) { $_render_html = false; }
150
+		if (is_null($_render_external)) { $_render_external = true; }
151 151
 		$newline = $_render_html ? "<br />" : "\n";
152 152
 		$hruler = $_render_html ? Api\Html::hr() : '';
153 153
 
154 154
 		$rendered_links = array();
155
-		foreach($_links as $link) {
156
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
155
+		foreach ($_links as $link) {
156
+			if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; }
157 157
 			// do not expose sensitive data
158
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
158
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', Api\Html::link('/index.php', $link->view));
159 159
 			// complete missing protocol and domain part if needed
160 160
 			if ($url[0] == '/' && $_render_external) $url = Api\Framework::getUrl($url);
161 161
 			$a_href = '<a href="'.$url.'" target="_blank">'.$link->text.'</a>';
162 162
 			$rendered_links[] = $_render_html ? $a_href : $url;
163 163
 		}
164 164
 
165
-		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links);
165
+		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links);
166 166
 	}
167 167
 
168 168
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via email.
17 17
  */
18
-class notifications_email implements notifications_iface {
18
+class notifications_email implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -65,9 +66,14 @@  discard block
 block discarded – undo
65 66
 	 * @param object $_config
66 67
 	 * @param object $_preferences
67 68
 	 */
68
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
70
+	{
71
+		if(!is_object($_sender))
72
+		{
73
+throw new Exception("no sender given."); }
74
+		if(!is_object($_recipient))
75
+		{
76
+throw new Exception("no recipient given."); }
71 77
 		$this->sender = $_sender;
72 78
 		$this->recipient = $_recipient;
73 79
 		$this->config = $_config;
@@ -141,23 +147,36 @@  discard block
 block discarded – undo
141 147
 	 * @param boolean $_render_external
142 148
 	 * @return plain or html rendered link(s) as complete string
143 149
 	 */
144
-	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
145
-		if(!is_array($_links) || count($_links) == 0) { return false; }
150
+	private function render_links($_links = false, $_render_html = false, $_render_external = true)
151
+	{
152
+		if(!is_array($_links) || count($_links) == 0)
153
+		{
154
+return false; }
146 155
 
147 156
 		// provide defaults if given arguments are null
148 157
 		// php distinguishes between missing and present(null) arguments
149
-		if(is_null($_render_html)) { $_render_html = false; }
150
-		if(is_null($_render_external)) { $_render_external = true; }
158
+		if(is_null($_render_html))
159
+		{
160
+$_render_html = false; }
161
+		if(is_null($_render_external))
162
+		{
163
+$_render_external = true; }
151 164
 		$newline = $_render_html ? "<br />" : "\n";
152 165
 		$hruler = $_render_html ? Api\Html::hr() : '';
153 166
 
154 167
 		$rendered_links = array();
155
-		foreach($_links as $link) {
156
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
168
+		foreach($_links as $link)
169
+		{
170
+			if($_render_external || ! $link->popup)
171
+			{
172
+$link->view['no_popup'] = 1; }
157 173
 			// do not expose sensitive data
158 174
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
159 175
 			// complete missing protocol and domain part if needed
160
-			if ($url[0] == '/' && $_render_external) $url = Api\Framework::getUrl($url);
176
+			if ($url[0] == '/' && $_render_external)
177
+			{
178
+				$url = Api\Framework::getUrl($url);
179
+			}
161 180
 			$a_href = '<a href="'.$url.'" target="_blank">'.$link->text.'</a>';
162 181
 			$rendered_links[] = $_render_html ? $a_href : $url;
163 182
 		}
Please login to merge, or discard this patch.
notifications/inc/class.notifications_jpopup.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,6 @@
 block discarded – undo
152 152
 	* saves notification into database so that the client can fetch it from there
153 153
 	*
154 154
 	* @param string $_message
155
-	* @param array $_user_sessions
156 155
 	*/
157 156
 	private function save( $_message ) {
158 157
 		$result = $this->db->insert( self::_notification_table, array(
Please login to merge, or discard this patch.
Braces   +17 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,8 +74,12 @@  discard block
 block discarded – undo
74 74
 	*/
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77
-		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
78
-		if( !is_object($_recipient) ) { throw new Exception("no recipient given."); }
77
+		if( !is_object($_sender) )
78
+		{
79
+throw new Exception("no sender given."); }
80
+		if( !is_object($_recipient) )
81
+		{
82
+throw new Exception("no recipient given."); }
79 83
 
80 84
 		$this->sender		= $_sender;
81 85
 		$this->recipient	= $_recipient;
@@ -138,13 +142,16 @@  discard block
 block discarded – undo
138 142
 	* @param string $_subject
139 143
 	* @return string html rendered info as complete string
140 144
 	*/
141
-	private function render_infos($_subject = false) {
145
+	private function render_infos($_subject = false)
146
+	{
142 147
 		$infos = array();
143 148
 		$newline = "<br />";
144 149
 
145 150
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
146 151
 		$infos[] = lang('Message from').': '.$sender;
147
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
152
+		if(!empty($_subject))
153
+		{
154
+$infos[] = Api\Html::bold($_subject); }
148 155
 		return implode($newline,$infos);
149 156
 	}
150 157
 
@@ -154,12 +161,16 @@  discard block
 block discarded – undo
154 161
 	* @param string $_message
155 162
 	* @param array $_user_sessions
156 163
 	*/
157
-	private function save( $_message ) {
164
+	private function save( $_message )
165
+	{
158 166
 		$result = $this->db->insert( self::_notification_table, array(
159 167
 			'account_id'     => $this->recipient->account_id,
160 168
 			'notify_message' => $_message,
161 169
 			'notify_type'	 => self::_type
162 170
 			), false,__LINE__,__FILE__,self::_appname);
163
-		if ($result === false) throw new Exception("Can't save notification into SQL table");
171
+		if ($result === false)
172
+		{
173
+			throw new Exception("Can't save notification into SQL table");
174
+		}
164 175
 	}
165 176
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,63 +15,63 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
 	/**
18
-	* Appname
19
-	*/
18
+	 * Appname
19
+	 */
20 20
 	const _appname = 'notifications';
21 21
 
22 22
 	/**
23
-	* Notification table in SQL database
24
-	*/
23
+	 * Notification table in SQL database
24
+	 */
25 25
 	const _notification_table = 'egw_notificationpopup';
26 26
 
27 27
 	/**
28
-	* Notification type
29
-	*/
28
+	 * Notification type
29
+	 */
30 30
 	const _type = 'jpopup';
31 31
 
32 32
 	/**
33
-	* holds account object for user who sends the message
34
-	*
35
-	* @var object
36
-	*/
33
+	 * holds account object for user who sends the message
34
+	 *
35
+	 * @var object
36
+	 */
37 37
 	private $sender;
38 38
 
39 39
 	/**
40
-	* holds account object for user to notify
41
-	*
42
-	* @var object
43
-	*/
40
+	 * holds account object for user to notify
41
+	 *
42
+	 * @var object
43
+	 */
44 44
 	private $recipient;
45 45
 
46 46
 	/**
47
-	* holds config object (sitewide application config)
48
-	*
49
-	* @var object
50
-	*/
47
+	 * holds config object (sitewide application config)
48
+	 *
49
+	 * @var object
50
+	 */
51 51
 	private $config;
52 52
 
53 53
 	/**
54
-	* holds preferences object of user to notify
55
-	*
56
-	* @var object
57
-	*/
54
+	 * holds preferences object of user to notify
55
+	 *
56
+	 * @var object
57
+	 */
58 58
 	private $preferences;
59 59
 
60 60
 	/**
61
-	* holds db object of SQL database
62
-	*
63
-	* @var Api\Db
64
-	*/
61
+	 * holds db object of SQL database
62
+	 *
63
+	 * @var Api\Db
64
+	 */
65 65
 	private $db;
66 66
 
67 67
 	/**
68
-	* constructor of notifications_egwpopup
69
-	*
70
-	* @param object $_sender
71
-	* @param object $_recipient
72
-	* @param object $_config
73
-	* @param object $_preferences
74
-	*/
68
+	 * constructor of notifications_egwpopup
69
+	 *
70
+	 * @param object $_sender
71
+	 * @param object $_recipient
72
+	 * @param object $_config
73
+	 * @param object $_preferences
74
+	 */
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77 77
 		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	/**
88
-	* sends notification if user is online
89
-	*
90
-	* @param array $_messages
91
-	* @param string $_subject
92
-	* @param array $_links
93
-	* @param array $_attachments
94
-	* @param array $_data
95
-	*/
88
+	 * sends notification if user is online
89
+	 *
90
+	 * @param array $_messages
91
+	 * @param string $_subject
92
+	 * @param array $_links
93
+	 * @param array $_attachments
94
+	 * @param array $_data
95
+	 */
96 96
 	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false, $_data = false)
97 97
 	{
98 98
 		unset($_attachments, $_data);	// not used
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 	/**
137
-	* renders additional infos from sender and subject
138
-	*
139
-	* @param string $_subject
140
-	* @return string html rendered info as complete string
141
-	*/
137
+	 * renders additional infos from sender and subject
138
+	 *
139
+	 * @param string $_subject
140
+	 * @return string html rendered info as complete string
141
+	 */
142 142
 	private function render_infos($_subject = false) {
143 143
 		$infos = array();
144 144
 		$newline = "<br />";
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	/**
153
-	* saves notification into database so that the client can fetch it from there
154
-	*
155
-	* @param string $_message
156
-	* @param array $_user_sessions
157
-	*/
153
+	 * saves notification into database so that the client can fetch it from there
154
+	 *
155
+	 * @param string $_message
156
+	 * @param array $_user_sessions
157
+	 */
158 158
 	private function save( $_message ) {
159 159
 		$result = $this->db->insert( self::_notification_table, array(
160 160
 			'account_id'     => $this->recipient->account_id,
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	*/
75 75
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
76 76
 	{
77
-		if( !is_object($_sender) ) { throw new Exception("no sender given."); }
78
-		if( !is_object($_recipient) ) { throw new Exception("no recipient given."); }
77
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
78
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
79 79
 
80 80
 		$this->sender		= $_sender;
81
-		$this->recipient	= $_recipient;
81
+		$this->recipient = $_recipient;
82 82
 		$this->config		= $_config;
83
-		$this->preferences	= $_preferences;
84
-		$this->db			= $GLOBALS['egw']->db;
83
+		$this->preferences = $_preferences;
84
+		$this->db = $GLOBALS['egw']->db;
85 85
 	}
86 86
 
87 87
 	/**
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	* @param array $_attachments
94 94
 	* @param array $_data
95 95
 	*/
96
-	public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false, $_data = false)
96
+	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false, $_data = false)
97 97
 	{
98
-		unset($_attachments, $_data);	// not used
98
+		unset($_attachments, $_data); // not used
99 99
 
100 100
 		$jmessage = array();
101 101
 
102 102
 		// app-message
103
-		if( ($_links != null) && (count($_links) > 0) )
103
+		if (($_links != null) && (count($_links) > 0))
104 104
 		{
105
-			$tlink		= $_links[0];
106
-			$appname	= "";
105
+			$tlink = $_links[0];
106
+			$appname = "";
107 107
 
108
-			if( key_exists('menuaction', $tlink->view) )
108
+			if (key_exists('menuaction', $tlink->view))
109 109
 			{
110 110
 				$tmp = explode(".", $tlink->view['menuaction']);
111 111
 				$appname = $tmp[0];
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
 			$link = array();
115 115
 
116
-			foreach( $tlink->view as $pkey => $pvalue )
116
+			foreach ($tlink->view as $pkey => $pvalue)
117 117
 			{
118
-				$link[] = $pkey . '=' . $pvalue;
118
+				$link[] = $pkey.'='.$pvalue;
119 119
 			}
120 120
 
121 121
 			// TODO more links?
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 			.Api\Html::hr()
127 127
 			.$_messages['html'];
128 128
 
129
-		$jmessage['msghtml']	= $message;
130
-		$jmessage['app']		= $appname;
129
+		$jmessage['msghtml'] = $message;
130
+		$jmessage['app'] = $appname;
131 131
 
132 132
 
133
-		$this->save( serialize($jmessage) );
133
+		$this->save(serialize($jmessage));
134 134
 	}
135 135
 
136 136
 	/**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 
146 146
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
147 147
 		$infos[] = lang('Message from').': '.$sender;
148
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
149
-		return implode($newline,$infos);
148
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
149
+		return implode($newline, $infos);
150 150
 	}
151 151
 
152 152
 	/**
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 	* @param string $_message
156 156
 	* @param array $_user_sessions
157 157
 	*/
158
-	private function save( $_message ) {
159
-		$result = $this->db->insert( self::_notification_table, array(
158
+	private function save($_message) {
159
+		$result = $this->db->insert(self::_notification_table, array(
160 160
 			'account_id'     => $this->recipient->account_id,
161 161
 			'notify_message' => $_message,
162 162
 			'notify_type'	 => self::_type
163
-			), false,__LINE__,__FILE__,self::_appname);
163
+			), false, __LINE__, __FILE__, self::_appname);
164 164
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
165 165
 	}
166 166
 }
Please login to merge, or discard this patch.
notifications/inc/class.notifications_winpopup.inc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * checks for a valid IPv4-address without CIDR notation
156 156
 	 *
157 157
 	 * @param string $_ip
158
-	 * @return true or false
158
+	 * @return integer or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161 161
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * renders additional info from subject
166 166
 	 *
167 167
 	 * @param string $_subject
168
-	 * @return plain rendered info as complete string
168
+	 * @return string|false rendered info as complete string
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	 * @param object $_preferences
82 82
 	 */
83 83
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
87
-			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
84
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
85
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!$this->netbios_command) {
87
+			throw new Exception('Winpopup plugin not configured yet. Skipped sending notification message. '.
88 88
 									'Please check var "netbios_command" in winpopup backend '.
89
-									'('.EGW_INCLUDE_ROOT. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
89
+									'('.EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.notifications_winpopup.inc.php).');
90 90
 		}
91 91
 		$this->sender = $_sender;
92 92
 		$this->recipient = $_recipient;
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false, $_data = false)
107 107
 	{
108
-		unset($_links, $_attachments, $_data);	// not used
108
+		unset($_links, $_attachments, $_data); // not used
109 109
 
110 110
 		$user_sessions = array();
111 111
 		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
112
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
113
-				if($this->valid_ip($session['session_ip'])) {
112
+			if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) {
113
+				if ($this->valid_ip($session['session_ip'])) {
114 114
 					$user_sessions[] = $session['session_ip'];
115 115
 				}
116 116
 			}
117 117
 		}
118
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
118
+		if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
119 119
 
120
-		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
120
+		$this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions);
121 121
 		return true;
122 122
 	}
123 123
 
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 	 * @param string $_message
128 128
 	 * @param array $_user_sessions
129 129
 	 */
130
-	private function send_winpopup( $_message, array $_user_sessions ) {
131
-		foreach($_user_sessions as $user_session) {
132
-			$ip_octets=explode(".",$user_session);
130
+	private function send_winpopup($_message, array $_user_sessions) {
131
+		foreach ($_user_sessions as $user_session) {
132
+			$ip_octets = explode(".", $user_session);
133 133
 			// format the ip_octets to 3 digits each
134
-			foreach($ip_octets as $id=>$ip_octet) {
135
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
136
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
134
+			foreach ($ip_octets as $id=>$ip_octet) {
135
+				if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; }
136
+				if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; }
137 137
 			}
138
-			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138
+			$placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
139 139
 									'/\[1\]/' => $ip_octets[0],
140 140
 									'/\[2\]/' => $ip_octets[1],
141 141
 									'/\[3\]/' => $ip_octets[2],
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 									);
146 146
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
147 147
 			$output = $returncode = null;
148
-			exec($command,$output,$returncode);
149
-			if($returncode != 0) {
148
+			exec($command, $output, $returncode);
149
+			if ($returncode != 0) {
150 150
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
151 151
 			}
152 152
 		}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @return true or false
160 160
 	 */
161 161
 	private function valid_ip($_ip) {
162
-		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
162
+		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip);
163 163
 	}
164 164
 
165 165
 	/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function render_infos($_subject = false) {
172 172
 		$newline = "\n";
173
-		if(!empty($_subject)) { return $_subject.$newline; }
173
+		if (!empty($_subject)) { return $_subject.$newline; }
174 174
 		return false;
175 175
 	}
176 176
 }
177 177
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +43 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via winpopup.
17 17
  */
18
-class notifications_winpopup implements notifications_iface {
18
+class notifications_winpopup implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -80,10 +81,16 @@  discard block
 block discarded – undo
80 81
 	 * @param object $_config
81 82
 	 * @param object $_preferences
82 83
 	 */
83
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
84
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
85
+	{
86
+		if(!is_object($_sender))
87
+		{
88
+throw new Exception("no sender given."); }
89
+		if(!is_object($_recipient))
90
+		{
91
+throw new Exception("no recipient given."); }
92
+		if(!$this->netbios_command)
93
+		{
87 94
 			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
88 95
 									'Please check var "netbios_command" in winpopup backend '.
89 96
 									'('.EGW_INCLUDE_ROOT. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
@@ -108,14 +115,20 @@  discard block
 block discarded – undo
108 115
 		unset($_links, $_attachments, $_data);	// not used
109 116
 
110 117
 		$user_sessions = array();
111
-		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
112
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
113
-				if($this->valid_ip($session['session_ip'])) {
118
+		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session)
119
+		{
120
+			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain'])
121
+			{
122
+				if($this->valid_ip($session['session_ip']))
123
+				{
114 124
 					$user_sessions[] = $session['session_ip'];
115 125
 				}
116 126
 			}
117 127
 		}
118
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
128
+		if ( empty($user_sessions) )
129
+		{
130
+			throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
131
+		}
119 132
 
120 133
 		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
121 134
 		return true;
@@ -127,13 +140,20 @@  discard block
 block discarded – undo
127 140
 	 * @param string $_message
128 141
 	 * @param array $_user_sessions
129 142
 	 */
130
-	private function send_winpopup( $_message, array $_user_sessions ) {
131
-		foreach($_user_sessions as $user_session) {
143
+	private function send_winpopup( $_message, array $_user_sessions )
144
+	{
145
+		foreach($_user_sessions as $user_session)
146
+		{
132 147
 			$ip_octets=explode(".",$user_session);
133 148
 			// format the ip_octets to 3 digits each
134
-			foreach($ip_octets as $id=>$ip_octet) {
135
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
136
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
149
+			foreach($ip_octets as $id=>$ip_octet)
150
+			{
151
+				if(strlen($ip_octet)==1)
152
+				{
153
+$ip_octets[$id] = '00'.$ip_octet; }
154
+				if(strlen($ip_octet)==2)
155
+				{
156
+$ip_octets[$id] = '0'.$ip_octet; }
137 157
 			}
138 158
 			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
139 159
 									'/\[1\]/' => $ip_octets[0],
@@ -146,7 +166,8 @@  discard block
 block discarded – undo
146 166
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
147 167
 			$output = $returncode = null;
148 168
 			exec($command,$output,$returncode);
149
-			if($returncode != 0) {
169
+			if($returncode != 0)
170
+			{
150 171
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
151 172
 			}
152 173
 		}
@@ -158,7 +179,8 @@  discard block
 block discarded – undo
158 179
 	 * @param string $_ip
159 180
 	 * @return true or false
160 181
 	 */
161
-	private function valid_ip($_ip) {
182
+	private function valid_ip($_ip)
183
+	{
162 184
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
163 185
 	}
164 186
 
@@ -168,9 +190,12 @@  discard block
 block discarded – undo
168 190
 	 * @param string $_subject
169 191
 	 * @return plain rendered info as complete string
170 192
 	 */
171
-	private function render_infos($_subject = false) {
193
+	private function render_infos($_subject = false)
194
+	{
172 195
 		$newline = "\n";
173
-		if(!empty($_subject)) { return $_subject.$newline; }
196
+		if(!empty($_subject))
197
+		{
198
+return $_subject.$newline; }
174 199
 		return false;
175 200
 	}
176 201
 }
177 202
\ No newline at end of file
Please login to merge, or discard this patch.