Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
api/src/Etemplate/Request.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @var array
93 93
 	 */
94
-	protected $data=array();
94
+	protected $data = array();
95 95
 	/**
96 96
 	 * Flag if data has been modified and therefor need to be stored again in the session
97 97
 	 *
98 98
 	 * @var boolean
99 99
 	 */
100
-	protected $data_modified=false;
100
+	protected $data_modified = false;
101 101
 	/**
102 102
 	 * Flag that stored data should be removed by destructor, if not modified.
103 103
 	 *
104 104
 	 * @var boolean
105 105
 	 */
106
-	protected $remove_if_not_modified=false;
106
+	protected $remove_if_not_modified = false;
107 107
 	/**
108 108
 	 * mcrypt resource
109 109
 	 *
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param string $id =null
142 142
 	 * @return Request
143 143
 	 */
144
-	public static function read($id=null)
144
+	public static function read($id = null)
145 145
 	{
146 146
 		if (is_null(self::$request_class))
147 147
 		{
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 				// decrypt the data if available
168 168
 				if (self::init_crypt())
169 169
 				{
170
-					$id = mdecrypt_generic(self::$mcrypt,$id);
170
+					$id = mdecrypt_generic(self::$mcrypt, $id);
171 171
 				}
172 172
 				// uncompress the data if available
173 173
 				if (self::$compression_level && function_exists('gzcompress'))
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @param string $id =null
222 222
 	 */
223
-	private function __construct($id=null)
223
+	private function __construct($id = null)
224 224
 	{
225 225
 		unset($id);
226 226
 	}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @param string $type etemplate type
264 264
 	 * @param array $data =array() optional extra data
265 265
 	 */
266
-	public function set_to_process($_form_name, $type, $data=array())
266
+	public function set_to_process($_form_name, $type, $data = array())
267 267
 	{
268 268
 		if (!$_form_name || !$type) return;
269 269
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		$data['type'] = $type;
272 272
 
273 273
 		// unquote single and double quotes, as this is how they get returned in $_POST
274
-		$form_name = str_replace(array('\\\'','"'), array('\'','"'), $_form_name);
274
+		$form_name = str_replace(array('\\\'', '"'), array('\'', '"'), $_form_name);
275 275
 
276 276
 		$this->data['to_process'][$form_name] = $data;
277 277
 		$this->data_modified = true;
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * @param array $value
286 286
 	 * @param boolean $add_to_array =false should $value be added to the attribute array
287 287
 	 */
288
-	public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array=false)
288
+	public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array = false)
289 289
 	{
290 290
 		//echo '<p>'.__METHOD__."($form_name,$attribute,$value,$add_to_array)</p>\n";
291 291
 		if (!$_form_name) return;
292 292
 
293 293
 		// unquote single and double quotes, as this is how they get returned in $_POST
294
-		$form_name = str_replace(array('\\\'','&quot;'), array('\'','"'), $_form_name);
294
+		$form_name = str_replace(array('\\\'', '&quot;'), array('\'', '"'), $_form_name);
295 295
 
296 296
 		if ($add_to_array)
297 297
 		{
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @param string $form_name =null
323 323
 	 * @return array
324 324
 	 */
325
-	public function get_to_process($form_name=null)
325
+	public function get_to_process($form_name = null)
326 326
 	{
327 327
 		//echo '<p>'.__METHOD__."($form_name)</p>\n";
328 328
 		return $form_name ? $this->data['to_process'][$form_name] : $this->data['to_process'];
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 * @param string $var
347 347
 	 * @param mixed $val
348 348
 	 */
349
-	public function __set($var,$val)
349
+	public function __set($var, $val)
350 350
 	{
351 351
 		if ($this->data[$var] !== $val)
352 352
 		{
@@ -397,23 +397,23 @@  discard block
 block discarded – undo
397 397
 	 * @param double $min_share minimum share to be reported (in percent of the whole request)
398 398
 	 * @param double $dump_share minimum share from which on a variable get output
399 399
 	 */
400
-	public function debug($min_share=1.0,$dump_share=25.0)
400
+	public function debug($min_share = 1.0, $dump_share = 25.0)
401 401
 	{
402
-		echo "<p><b>total size request data = ".($total=strlen(serialize($this->data)))."</b></p>\n";
402
+		echo "<p><b>total size request data = ".($total = strlen(serialize($this->data)))."</b></p>\n";
403 403
 		echo "<p>shares bigger then $min_share% percent of it:</p>\n";
404
-		foreach($this->data as $key => $val)
404
+		foreach ($this->data as $key => $val)
405 405
 		{
406 406
 			$len = strlen(is_array($val) ? serialize($val) : $val);
407
-			$len .= ' ('.sprintf('%2.1lf',($percent = 100.0 * $len / $total)).'%)';
407
+			$len .= ' ('.sprintf('%2.1lf', ($percent = 100.0 * $len / $total)).'%)';
408 408
 			if ($percent < $min_share) continue;
409 409
 			echo "<p><b>$key</b>: strlen(\$val)=$len</p>\n";
410 410
 			if ($percent >= $dump_share) _debug_array($val);
411 411
 			if (is_array($val) && $len > 2000)
412 412
 			{
413
-				foreach($val as $k => $v)
413
+				foreach ($val as $k => $v)
414 414
 				{
415 415
 					$l = strlen(is_array($v) ? serialize($v) : $v);
416
-					$l .= ' ('.sprintf('%2.1lf',($p = 100.0 * $l / $total)).'%)';
416
+					$l .= ' ('.sprintf('%2.1lf', ($p = 100.0 * $l / $total)).'%)';
417 417
 					if ($p < $min_share) continue;
418 418
 					echo "<p>&nbsp;- {$key}[$k]: strlen(\$v)=$l</p>\n";
419 419
 				}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * @param string $mode ='ecb'
429 429
 	 * @return boolean true if encryption is used, false otherwise
430 430
 	 */
431
-	static public function init_crypt($algo='tripledes',$mode='ecb')
431
+	static public function init_crypt($algo = 'tripledes', $mode = 'ecb')
432 432
 	{
433 433
 		if (is_null(self::$mcrypt))
434 434
 		{
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 			}
453 453
 			$iv_size = mcrypt_enc_get_iv_size(self::$mcrypt);
454 454
 			$iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ?
455
-				mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);
455
+				mcrypt_create_iv($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'], 0, $iv_size);
456 456
 
457 457
 			$key_size = mcrypt_enc_get_key_size(self::$mcrypt);
458
-			if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1);
458
+			if (bytes($key) > $key_size) $key = cut_bytes($key, 0, $key_size - 1);
459 459
 
460
-			if (mcrypt_generic_init(self::$mcrypt,$key, $iv) < 0)
460
+			if (mcrypt_generic_init(self::$mcrypt, $key, $iv) < 0)
461 461
 			{
462 462
 				error_log(__METHOD__."() could not initialise mcrypt, sessions get NOT encrypted!");
463 463
 				return self::$mcrypt = false;
Please login to merge, or discard this patch.
Braces   +32 added lines, -8 removed lines patch added patch discarded remove patch
@@ -189,9 +189,12 @@  discard block
 block discarded – undo
189 189
 				//error_log(__METHOD__."() size of request = ".bytes($id));
190 190
 			}
191 191
 		}
192
-		if (!$request)	// eT2 request/session expired
192
+		if (!$request)
193
+		{
194
+			// eT2 request/session expired
193 195
 		{
194 196
 			list($app) = explode('.', $_GET['menuaction']);
197
+		}
195 198
 			$index_url = isset($GLOBALS['egw_info']['apps'][$app]['index']) ?
196 199
 				'/index.php?menuaction='.$GLOBALS['egw_info']['apps'][$app]['index'] : '/'.$app.'/index.php';
197 200
 			// add a unique token to redirect to avoid client-side framework tries refreshing via nextmatch
@@ -265,7 +268,10 @@  discard block
 block discarded – undo
265 268
 	 */
266 269
 	public function set_to_process($_form_name, $type, $data=array())
267 270
 	{
268
-		if (!$_form_name || !$type) return;
271
+		if (!$_form_name || !$type)
272
+		{
273
+			return;
274
+		}
269 275
 
270 276
 		//echo '<p>'.__METHOD__."($form_name,$type,".array2string($data).")</p>\n";
271 277
 		$data['type'] = $type;
@@ -288,7 +294,10 @@  discard block
 block discarded – undo
288 294
 	public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array=false)
289 295
 	{
290 296
 		//echo '<p>'.__METHOD__."($form_name,$attribute,$value,$add_to_array)</p>\n";
291
-		if (!$_form_name) return;
297
+		if (!$_form_name)
298
+		{
299
+			return;
300
+		}
292 301
 
293 302
 		// unquote single and double quotes, as this is how they get returned in $_POST
294 303
 		$form_name = str_replace(array('\\\'','&quot;'), array('\'','"'), $_form_name);
@@ -364,7 +373,10 @@  discard block
 block discarded – undo
364 373
 	 */
365 374
 	public function &__get($var)
366 375
 	{
367
-		if ($var == 'data_modified') return $this->data_modified;
376
+		if ($var == 'data_modified')
377
+		{
378
+			return $this->data_modified;
379
+		}
368 380
 
369 381
 		return $this->data[$var];
370 382
 	}
@@ -405,16 +417,25 @@  discard block
 block discarded – undo
405 417
 		{
406 418
 			$len = strlen(is_array($val) ? serialize($val) : $val);
407 419
 			$len .= ' ('.sprintf('%2.1lf',($percent = 100.0 * $len / $total)).'%)';
408
-			if ($percent < $min_share) continue;
420
+			if ($percent < $min_share)
421
+			{
422
+				continue;
423
+			}
409 424
 			echo "<p><b>$key</b>: strlen(\$val)=$len</p>\n";
410
-			if ($percent >= $dump_share) _debug_array($val);
425
+			if ($percent >= $dump_share)
426
+			{
427
+				_debug_array($val);
428
+			}
411 429
 			if (is_array($val) && $len > 2000)
412 430
 			{
413 431
 				foreach($val as $k => $v)
414 432
 				{
415 433
 					$l = strlen(is_array($v) ? serialize($v) : $v);
416 434
 					$l .= ' ('.sprintf('%2.1lf',($p = 100.0 * $l / $total)).'%)';
417
-					if ($p < $min_share) continue;
435
+					if ($p < $min_share)
436
+					{
437
+						continue;
438
+					}
418 439
 					echo "<p>&nbsp;- {$key}[$k]: strlen(\$v)=$l</p>\n";
419 440
 				}
420 441
 			}
@@ -455,7 +476,10 @@  discard block
 block discarded – undo
455 476
 				mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);
456 477
 
457 478
 			$key_size = mcrypt_enc_get_key_size(self::$mcrypt);
458
-			if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1);
479
+			if (bytes($key) > $key_size)
480
+			{
481
+				$key = cut_bytes($key,0,$key_size-1);
482
+			}
459 483
 
460 484
 			if (mcrypt_generic_init(self::$mcrypt,$key, $iv) < 0)
461 485
 			{
Please login to merge, or discard this patch.
api/src/Etemplate/WidgetBrowser.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	{
33 33
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'etemplate';
34 34
 		$GLOBALS['egw_info']['flags']['app_header'] = 'et2 Widgets';
35
-                //'js_link_registry'      => True,
35
+				//'js_link_registry'      => True,
36 36
 
37 37
 		// Widget browser code
38 38
 		Api\Framework::includeJS('/api/js/etemplate/widget_browser.js');
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 
47 47
 		Api\Framework::includeCSS('/api/templates/default/etemplate2.css');
48 48
 
49
-		Api\Framework::includeCSS('api','widget_browser',false);
49
+		Api\Framework::includeCSS('api', 'widget_browser', false);
50 50
 
51 51
 		// load translations
52 52
 		Api\Translation::add_app('etemplate');
Please login to merge, or discard this patch.
api/src/Etemplate/Request/Session.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @param array $id
63 63
 	 */
64
-	private function __construct($id=null)
64
+	private function __construct($id = null)
65 65
 	{
66 66
 		if (!$id) $id = self::request_id();
67 67
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @param string $id =null
89 89
 	 * @return etemplate_request|boolean the object or false if $id is not found
90 90
 	 */
91
-	static function read($id=null)
91
+	static function read($id = null)
92 92
 	{
93 93
 		$request = new Session($id);
94 94
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		{
97 97
 			if (!($data = Api\Cache::getSession('etemplate', $id)))
98 98
 			{
99
-				return false;	// request not found
99
+				return false; // request not found
100 100
 			}
101 101
 			$request->data = $data;
102 102
 		}
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	static function request_id()
113 113
 	{
114
-		$time = (int) (100 * microtime(true));	// gives precision of 1/100 sec
115
-		$id = $GLOBALS['egw_info']['flags']['currentapp'] .':'. $time;
114
+		$time = (int)(100 * microtime(true)); // gives precision of 1/100 sec
115
+		$id = $GLOBALS['egw_info']['flags']['currentapp'].':'.$time;
116 116
 
117 117
 		return $id;
118 118
 	}
@@ -152,30 +152,30 @@  discard block
 block discarded – undo
152 152
 	protected function _php4_request_garbage_collection()
153 153
 	{
154 154
 		// now we are on php4 sessions and do a bit of garbage collection
155
-		$appsessions =& $_SESSION[Api\Session::EGW_APPSESSION_VAR]['etemplate'];
156
-		$session_used =& $appsessions['session_used'];
155
+		$appsessions = & $_SESSION[Api\Session::EGW_APPSESSION_VAR]['etemplate'];
156
+		$session_used = & $appsessions['session_used'];
157 157
 
158 158
 		if ($this->id)
159 159
 		{
160 160
 			//echo "session_used[$id_used]='".$session_used[$id_used]."'<br/>\n";
161
-			++$session_used[$this->id];	// count the number of times a session got used
161
+			++$session_used[$this->id]; // count the number of times a session got used
162 162
 		}
163 163
 		$this->garbage_collection_done = true;
164 164
 
165
-		if (count($appsessions) < 20) return;	// we dont need to care
165
+		if (count($appsessions) < 20) return; // we dont need to care
166 166
 
167
-		$now = (int) (100 * microtime(true));	// gives precision of 1/100 sec
167
+		$now = (int)(100 * microtime(true)); // gives precision of 1/100 sec
168 168
 
169
-		foreach(array_keys($appsessions) as $id)
169
+		foreach (array_keys($appsessions) as $id)
170 170
 		{
171
-			list(,$time) = explode(':',$id);
171
+			list(,$time) = explode(':', $id);
172 172
 
173
-			if (!$time) continue;	// other data, no session
173
+			if (!$time) continue; // other data, no session
174 174
 
175 175
 			//echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n";
176 176
 
177
-			if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min
178
-				$time < $now - 30*6000)	// session not used and older then 30min
177
+			if ($session_used[$id] == 1 && $time < $now - 10 * 6000 || // session used and older then 10min
178
+				$time < $now - 30 * 6000)	// session not used and older then 30min
179 179
 			{
180 180
 				//echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n";
181 181
 				unset($appsessions[$id]);
Please login to merge, or discard this patch.
Braces   +22 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,12 +63,18 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	private function __construct($id=null)
65 65
 	{
66
-		if (!$id) $id = self::request_id();
66
+		if (!$id)
67
+		{
68
+			$id = self::request_id();
69
+		}
67 70
 
68 71
 		$this->id = $id;
69 72
 
70 73
 		// hack to quiten IDE Warning for not calling parent::__construct, which we can not!
71
-		if (false) parent::__construct();
74
+		if (false)
75
+		{
76
+			parent::__construct();
77
+		}
72 78
 	}
73 79
 
74 80
 	/**
@@ -162,7 +168,11 @@  discard block
 block discarded – undo
162 168
 		}
163 169
 		$this->garbage_collection_done = true;
164 170
 
165
-		if (count($appsessions) < 20) return;	// we dont need to care
171
+		if (count($appsessions) < 20)
172
+		{
173
+			return;
174
+		}
175
+		// we dont need to care
166 176
 
167 177
 		$now = (int) (100 * microtime(true));	// gives precision of 1/100 sec
168 178
 
@@ -170,15 +180,22 @@  discard block
 block discarded – undo
170 180
 		{
171 181
 			list(,$time) = explode(':',$id);
172 182
 
173
-			if (!$time) continue;	// other data, no session
183
+			if (!$time)
184
+			{
185
+				continue;
186
+			}
187
+			// other data, no session
174 188
 
175 189
 			//echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n";
176 190
 
177 191
 			if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min
178
-				$time < $now - 30*6000)	// session not used and older then 30min
192
+				$time < $now - 30*6000)
193
+			{
194
+				// session not used and older then 30min
179 195
 			{
180 196
 				//echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n";
181 197
 				unset($appsessions[$id]);
198
+			}
182 199
 				unset($session_used[$id]);
183 200
 			}
184 201
 		}
Please login to merge, or discard this patch.
api/src/Etemplate/Request/Files.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param array $id
73 73
 	 */
74
-	private function __construct($id=null)
74
+	private function __construct($id = null)
75 75
 	{
76 76
 		if (is_null(self::$directory))
77 77
 		{
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param string $id =null
103 103
 	 * @return etemplate_request|boolean the object or false if $id is not found
104 104
 	 */
105
-	static function read($id=null)
105
+	static function read($id = null)
106 106
 	{
107 107
 		$request = new Files($id);
108 108
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	{
130 130
 		do
131 131
 		{
132
-			$id = uniqid('etemplate_'.$GLOBALS['egw_info']['flags']['currentapp'].'_',true);
132
+			$id = uniqid('etemplate_'.$GLOBALS['egw_info']['flags']['currentapp'].'_', true);
133 133
 		}
134 134
 		while (file_exists(self::$directory.'/'.$id));
135 135
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			@unlink(self::$directory.'/'.$this->id);
153 153
 		}
154 154
 		elseif (!$this->destroyed && $this->data_modified &&
155
-			!file_put_contents($filename = self::$directory.'/'.$this->id,serialize($this->data)))
155
+			!file_put_contents($filename = self::$directory.'/'.$this->id, serialize($this->data)))
156 156
 		{
157 157
 			error_log("Error opening '$filename' to store the etemplate request data!");
158 158
 		}
Please login to merge, or discard this patch.
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,12 +77,18 @@  discard block
 block discarded – undo
77 77
 		{
78 78
 			self::$directory = $GLOBALS['egw_info']['server']['temp_dir'];
79 79
 		}
80
-		if (!$id) $id = self::request_id();
80
+		if (!$id)
81
+		{
82
+			$id = self::request_id();
83
+		}
81 84
 
82 85
 		$this->id = $id;
83 86
 
84 87
 		// hack to quiten IDE Warning for not calling parent::__construct, which we can not!
85
-		if (false) parent::__construct();
88
+		if (false)
89
+		{
90
+			parent::__construct();
91
+		}
86 92
 	}
87 93
 
88 94
 	/**
@@ -114,7 +120,10 @@  discard block
 block discarded – undo
114 120
 				return false;
115 121
 			}
116 122
 			$request->data = unserialize(file_get_contents($filename));
117
-			if ($request->data === false) error_log("Error unserializing '$filename' to read the etemplate request data!");
123
+			if ($request->data === false)
124
+			{
125
+				error_log("Error unserializing '$filename' to read the etemplate request data!");
126
+			}
118 127
 		}
119 128
 		//error_log(__METHOD__."(id=$id");
120 129
 		return $request;
Please login to merge, or discard this patch.
api/src/Etemplate/Request/Cache.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param string $_id
74 74
 	 */
75
-	private function __construct($_id=null)
75
+	private function __construct($_id = null)
76 76
 	{
77 77
 		$this->id = $_id ? $_id : self::request_id();
78 78
 		//error_log(__METHOD__."($_id) this->id=$this->id");
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @param string $id =null
99 99
 	 * @return Request|boolean the object or false if $id is not found
100 100
 	 */
101
-	static function read($id=null)
101
+	static function read($id = null)
102 102
 	{
103 103
 		$request = new Cache($id);
104 104
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	{
125 125
 		// As we replace spaces with + for those account ids which contain spaces, therefore we need to do the same for getting request id too.
126 126
 		$userID = str_replace(' ', '+', rawurldecode($GLOBALS['egw_info']['user']['account_lid']));
127
-		return uniqid($GLOBALS['egw_info']['flags']['currentapp'].'_'.$userID.'_',true);
127
+		return uniqid($GLOBALS['egw_info']['flags']['currentapp'].'_'.$userID.'_', true);
128 128
 	}
129 129
 
130 130
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 		elseif (($this->data_modified ||
146 146
 			// if half of expiration time is over, save it anyway, to restart expiration time
147
-			isset($this->data['last_saved']) && (time()-$this->data['last_saved']) > self::EXPIRATION/2))
147
+			isset($this->data['last_saved']) && (time() - $this->data['last_saved']) > self::EXPIRATION / 2))
148 148
 		{
149 149
 			//error_log(__METHOD__."() saving $this->id".($this->data_modified?'':' data NOT modified, just keeping session alife'));
150 150
 			$this->data['last_saved'] = time();
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,10 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function __construct(Array &$context = array(), &$need_reload = false)
53 53
 	{
54
-		if (false) parent::__construct();
54
+		if (false)
55
+		{
56
+			parent::__construct();
57
+		}
55 58
 
56 59
 		// Process dropped data into something useable
57 60
 		if($context['dropped_data'])
Please login to merge, or discard this patch.
api/src/MimeMagic.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		{
47 47
 			return $mime;
48 48
 		}
49
-		return lang('%1 file',strtoupper($ext)).' ('.$mime.')';
49
+		return lang('%1 file', strtoupper($ext)).' ('.$mime.')';
50 50
 	}
51 51
 
52 52
 	/**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	{
64 64
 		if (empty($_ext))
65 65
 		{
66
-			return 'text/plain';//assume no extension is a text file
66
+			return 'text/plain'; //assume no extension is a text file
67 67
 		}
68 68
 		$ext = strtolower($_ext);
69 69
 		if (!array_key_exists($ext, self::$mime_extension_map))
@@ -188,24 +188,24 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public static function analyze_data($data)
190 190
 	{
191
-		if(!is_writeable(@$GLOBALS['egw_info']['server']['temp_dir']))
191
+		if (!is_writeable(@$GLOBALS['egw_info']['server']['temp_dir']))
192 192
 		{
193 193
 			//nothing we can do but bail out
194 194
 			return false;
195 195
 		}
196 196
 
197 197
 		mt_srand(time());
198
-		$filename = $GLOBALS['egw_info']['server']['temp_dir'] . '/'
199
-			. md5( time() + mt_rand() ) . '.tmp';
198
+		$filename = $GLOBALS['egw_info']['server']['temp_dir'].'/'
199
+			. md5(time() + mt_rand()).'.tmp';
200 200
 
201 201
 		$fp = @fopen($filename, 'ab');
202
-		if(!$fp || !$data)
202
+		if (!$fp || !$data)
203 203
 		{
204 204
 			//houston we have a problem - bail out
205 205
 			return false;
206 206
 		}
207 207
 
208
-		if(!fwrite($fp, $data))
208
+		if (!fwrite($fp, $data))
209 209
 		{
210 210
 			//bail out again
211 211
 			return false;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 		$mime = self::analyze_file($filename);
217 217
 
218
-		unlink($filename);//remove the temp file
218
+		unlink($filename); //remove the temp file
219 219
 
220 220
 		return $mime;
221 221
 	}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @var array of extenstion to mime mappings
234 234
 	 */
235 235
 	static $mime_extension_map = array(
236
-		'txt'				=> 'text/plain',	// should be first, so text/plain maps back to .txt
236
+		'txt'				=> 'text/plain', // should be first, so text/plain maps back to .txt
237 237
 		'3dml'              => 'text/vnd.in3d.3dml',
238 238
 		'3ds'               => 'image/x-3ds',
239 239
 		'3g2'               => 'video/3gpp2',
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,10 @@
 block discarded – undo
106 106
 	public static function mime2ext($_type)
107 107
 	{
108 108
 		$type = strtolower($_type);
109
-		if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type];
109
+		if (isset(self::$mime_alias_map[$type]))
110
+		{
111
+			$type = self::$mime_alias_map[$type];
112
+		}
110 113
 		$key = array_search($type, self::$mime_extension_map);
111 114
 		if (empty($type) || $key === false)
112 115
 		{
Please login to merge, or discard this patch.
api/src/Exception.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 class Exception extends \Exception
30 30
 {
31 31
 	// nothing fancy yet
32
-	function __construct($msg=null,$code=100,\Exception $previous=null)
32
+	function __construct($msg = null, $code = 100, \Exception $previous = null)
33 33
 	{
34 34
 		return parent::__construct($msg, $code, $previous);
35 35
 	}
Please login to merge, or discard this patch.
api/src/Cache.php 2 patches
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @var array
84 84
 	 */
85
-	static $default_provider;	// = array('EGroupware\Api\Cache\Files');// array('EGroupware\Api\Cache\Memcache','localhost');
85
+	static $default_provider; // = array('EGroupware\Api\Cache\Files');// array('EGroupware\Api\Cache\Memcache','localhost');
86 86
 
87 87
 	/**
88 88
 	 * Maximum expiration time, if set unlimited expiration (=0) or bigger expiration times are replaced with that time
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
109 109
 	 * @return boolean true if data could be stored, false otherwise incl. key already existed
110 110
 	 */
111
-	static public function addCache($level,$app,$location,$data,$expiration=0)
111
+	static public function addCache($level, $app, $location, $data, $expiration = 0)
112 112
 	{
113 113
 		//error_log(__METHOD__."('$level','$app','$location',".array2string($data).",$expiration)");
114
-		switch($level)
114
+		switch ($level)
115 115
 		{
116 116
 			case self::SESSION:
117 117
 			case self::REQUEST:
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 				{
130 130
 					$expiration = self::$max_expiration;
131 131
 				}
132
-				return $provider->add(self::keys($level,$app,$location),$data,$expiration);
132
+				return $provider->add(self::keys($level, $app, $location), $data, $expiration);
133 133
 		}
134 134
 		throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
135 135
 	}
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
145 145
 	 * @return boolean true if data could be stored, false otherwise
146 146
 	 */
147
-	static public function setCache($level,$app,$location,$data,$expiration=0)
147
+	static public function setCache($level, $app, $location, $data, $expiration = 0)
148 148
 	{
149 149
 		//error_log(__METHOD__."('$level','$app','$location',".array2string($data).",$expiration)");
150
-		switch($level)
150
+		switch ($level)
151 151
 		{
152 152
 			case self::SESSION:
153 153
 			case self::REQUEST:
154
-				return call_user_func(array(__CLASS__,'set'.$level),$app,$location,$data,$expiration);
154
+				return call_user_func(array(__CLASS__, 'set'.$level), $app, $location, $data, $expiration);
155 155
 
156 156
 			case self::INSTANCE:
157 157
 			case self::TREE:
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				{
166 166
 					$expiration = self::$max_expiration;
167 167
 				}
168
-				return $provider->set(self::keys($level,$app,$location),$data,$expiration);
168
+				return $provider->set(self::keys($level, $app, $location), $data, $expiration);
169 169
 		}
170 170
 		throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
171 171
 	}
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 	 * @return mixed NULL if data not found in cache (and no callback specified) or
183 183
 	 * 	if $location is an array: location => data pairs for existing location-data, non-existing is not returned
184 184
 	 */
185
-	static public function getCache($level,$app,$location,$callback=null,array $callback_params=array(),$expiration=0)
185
+	static public function getCache($level, $app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
186 186
 	{
187
-		switch($level)
187
+		switch ($level)
188 188
 		{
189 189
 			case self::SESSION:
190 190
 			case self::REQUEST:
191
-				foreach((array)$location as $l)
191
+				foreach ((array)$location as $l)
192 192
 				{
193
-					$data[$l] = call_user_func(array(__CLASS__,'get'.$level),$app,$l,$callback,$callback_params,$expiration);
193
+					$data[$l] = call_user_func(array(__CLASS__, 'get'.$level), $app, $l, $callback, $callback_params, $expiration);
194 194
 				}
195 195
 				return is_array($location) ? $data : $data[$l];
196 196
 
@@ -210,34 +210,34 @@  discard block
 block discarded – undo
210 210
 						}
211 211
 						if (is_a($provider, 'EGroupware\Api\Cache\ProviderMultiple'))
212 212
 						{
213
-							$data = $provider->mget($keys=self::keys($level,$app,$location));
213
+							$data = $provider->mget($keys = self::keys($level, $app, $location));
214 214
 						}
215 215
 						else	// default implementation calls get multiple times
216 216
 						{
217 217
 							$data = array();
218
-							foreach($location as $l)
218
+							foreach ($location as $l)
219 219
 							{
220
-								$data[$l] = $provider->get($keys=self::keys($level,$app,$l));
220
+								$data[$l] = $provider->get($keys = self::keys($level, $app, $l));
221 221
 								if (!isset($data[$l])) unset($data[$l]);
222 222
 							}
223 223
 						}
224 224
 					}
225 225
 					else
226 226
 					{
227
-						$data = $provider->get($keys=self::keys($level,$app,$location));
227
+						$data = $provider->get($keys = self::keys($level, $app, $location));
228 228
 						if (is_null($data) && !is_null($callback))
229 229
 						{
230
-							$data = call_user_func_array($callback,$callback_params);
230
+							$data = call_user_func_array($callback, $callback_params);
231 231
 							// limit expiration to configured maximum time
232 232
 							if (isset(self::$max_expiration) && (!$expiration || $expiration > self::$max_expiration))
233 233
 							{
234 234
 								$expiration = self::$max_expiration;
235 235
 							}
236
-							$provider->set($keys,$data,$expiration);
236
+							$provider->set($keys, $data, $expiration);
237 237
 						}
238 238
 					}
239 239
 				}
240
-				catch(Exception $e) {
240
+				catch (Exception $e) {
241 241
 					unset($e);
242 242
 					$data = null;
243 243
 				}
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 	 * @param string $location location name for data
255 255
 	 * @return boolean true if data was set, false if not (like isset())
256 256
 	 */
257
-	static public function unsetCache($level,$app,$location)
257
+	static public function unsetCache($level, $app, $location)
258 258
 	{
259
-		switch($level)
259
+		switch ($level)
260 260
 		{
261 261
 			case self::SESSION:
262 262
 			case self::REQUEST:
263
-				return call_user_func(array(__CLASS__,'unset'.$level),$app,$location);
263
+				return call_user_func(array(__CLASS__, 'unset'.$level), $app, $location);
264 264
 
265 265
 			case self::INSTANCE:
266 266
 			case self::TREE:
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				{
270 270
 					return false;
271 271
 				}
272
-				return $provider->delete(self::keys($level,$app,$location));
272
+				return $provider->delete(self::keys($level, $app, $location));
273 273
 		}
274 274
 		throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
275 275
 	}
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
284 284
 	 * @return boolean true if data could be stored, false otherwise
285 285
 	 */
286
-	static public function setTree($app,$location,$data,$expiration=0)
286
+	static public function setTree($app, $location, $data, $expiration = 0)
287 287
 	{
288 288
 		//error_log(__METHOD__."('$app','$location',".array2string($data).",$expiration)");
289
-		return self::setCache(self::TREE,$app,$location,$data,$expiration);
289
+		return self::setCache(self::TREE, $app, $location, $data, $expiration);
290 290
 	}
291 291
 
292 292
 	/**
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
300 300
 	 * @return mixed NULL if data not found in cache (and no callback specified)
301 301
 	 */
302
-	static public function getTree($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
302
+	static public function getTree($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
303 303
 	{
304
-		return self::getCache(self::TREE,$app,$location,$callback,$callback_params,$expiration);
304
+		return self::getCache(self::TREE, $app, $location, $callback, $callback_params, $expiration);
305 305
 	}
306 306
 
307 307
 	/**
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 * @param string $location location name for data
312 312
 	 * @return boolean true if data was set, false if not (like isset())
313 313
 	 */
314
-	static public function unsetTree($app,$location)
314
+	static public function unsetTree($app, $location)
315 315
 	{
316
-		return self::unsetCache(self::TREE,$app,$location);
316
+		return self::unsetCache(self::TREE, $app, $location);
317 317
 	}
318 318
 
319 319
 	/**
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
326 326
 	 * @return boolean true if data could be stored, false otherwise
327 327
 	 */
328
-	static public function setInstance($app,$location,$data,$expiration=0)
328
+	static public function setInstance($app, $location, $data, $expiration = 0)
329 329
 	{
330
-		return self::setCache(self::INSTANCE,$app,$location,$data,$expiration);
330
+		return self::setCache(self::INSTANCE, $app, $location, $data, $expiration);
331 331
 	}
332 332
 
333 333
 	/**
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
341 341
 	 * @return mixed NULL if data not found in cache (and no callback specified)
342 342
 	 */
343
-	static public function getInstance($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
343
+	static public function getInstance($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
344 344
 	{
345
-		return self::getCache(self::INSTANCE,$app,$location,$callback,$callback_params,$expiration);
345
+		return self::getCache(self::INSTANCE, $app, $location, $callback, $callback_params, $expiration);
346 346
 	}
347 347
 
348 348
 	/**
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 	 * @param string $location location name for data
353 353
 	 * @return boolean true if data was set, false if not (like isset())
354 354
 	 */
355
-	static public function unsetInstance($app,$location)
355
+	static public function unsetInstance($app, $location)
356 356
 	{
357
-		return self::unsetCache(self::INSTANCE,$app,$location);
357
+		return self::unsetCache(self::INSTANCE, $app, $location);
358 358
 	}
359 359
 
360 360
 	/**
@@ -366,13 +366,13 @@  discard block
 block discarded – undo
366 366
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
367 367
 	 * @return boolean true if data could be stored, false otherwise
368 368
 	 */
369
-	static public function setSession($app,$location,$data,$expiration=0)
369
+	static public function setSession($app, $location, $data, $expiration = 0)
370 370
 	{
371
-		unset($expiration);	// not used, but required by function signature
371
+		unset($expiration); // not used, but required by function signature
372 372
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
373 373
 		{
374 374
 			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
375
-			return false;	// can no longer store something in the session, eg. because commit_session() was called
375
+			return false; // can no longer store something in the session, eg. because commit_session() was called
376 376
 		}
377 377
 		$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = $data;
378 378
 
@@ -391,17 +391,17 @@  discard block
 block discarded – undo
391 391
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
392 392
 	 * @return mixed NULL if data not found in cache (and no callback specified)
393 393
 	 */
394
-	static public function &getSession($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
394
+	static public function &getSession($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
395 395
 	{
396
-		unset($expiration);	// not used, but required by function signature
396
+		unset($expiration); // not used, but required by function signature
397 397
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
398 398
 		{
399 399
 			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
400
-			return null;	// can no longer store something in the session, eg. because commit_session() was called
400
+			return null; // can no longer store something in the session, eg. because commit_session() was called
401 401
 		}
402 402
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]) && !is_null($callback))
403 403
 		{
404
-			$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = call_user_func_array($callback,$callback_params);
404
+			$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = call_user_func_array($callback, $callback_params);
405 405
 		}
406 406
 		return $_SESSION[Session::EGW_APPSESSION_VAR][$app][$location];
407 407
 	}
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
 	 * @param string $location location name for data
414 414
 	 * @return boolean true if data was set, false if not (like isset())
415 415
 	 */
416
-	static public function unsetSession($app,$location)
416
+	static public function unsetSession($app, $location)
417 417
 	{
418 418
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
419 419
 		{
420 420
 			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
421
-			return false;	// can no longer store something in the session, eg. because commit_session() was called
421
+			return false; // can no longer store something in the session, eg. because commit_session() was called
422 422
 		}
423 423
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]))
424 424
 		{
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 	 * @param int $expiration =0 expiration time is NOT used for REQUEST!
446 446
 	 * @return boolean true if data could be stored, false otherwise
447 447
 	 */
448
-	static public function setRequest($app,$location,$data,$expiration=0)
448
+	static public function setRequest($app, $location, $data, $expiration = 0)
449 449
 	{
450
-		unset($expiration);	// not used, but required by function signature
450
+		unset($expiration); // not used, but required by function signature
451 451
 		self::$request_cache[$app][$location] = $data;
452 452
 
453 453
 		return true;
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 	 * @param int $expiration =0 expiration time is NOT used for REQUEST!
464 464
 	 * @return mixed NULL if data not found in cache (and no callback specified)
465 465
 	 */
466
-	static public function getRequest($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
466
+	static public function getRequest($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
467 467
 	{
468
-		unset($expiration);	// not used, but required by function signature
468
+		unset($expiration); // not used, but required by function signature
469 469
 		if (!isset(self::$request_cache[$app][$location]) && !is_null($callback))
470 470
 		{
471
-			self::$request_cache[$app][$location] = call_user_func_array($callback,$callback_params);
471
+			self::$request_cache[$app][$location] = call_user_func_array($callback, $callback_params);
472 472
 		}
473 473
 		return self::$request_cache[$app][$location];
474 474
 	}
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @param string $location location name for data
481 481
 	 * @return boolean true if data was set, false if not (like isset())
482 482
 	 */
483
-	static public function unsetRequest($app,$location)
483
+	static public function unsetRequest($app, $location)
484 484
 	{
485 485
 		if (!isset(self::$request_cache[$app][$location]))
486 486
 		{
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 * @param boolean $log_not_found =true false do not log if no provider found, used eg. to supress error via unsetCache during installation
501 501
 	 * @return Api\Cache\Provider
502 502
 	 */
503
-	static protected function get_provider($level, $log_not_found=true)
503
+	static protected function get_provider($level, $log_not_found = true)
504 504
 	{
505 505
 		static $providers = array();
506 506
 
@@ -521,13 +521,13 @@  discard block
 block discarded – undo
521 521
 				}
522 522
 				else
523 523
 				{
524
-					$providers[$level] = false;	// no provider specified
524
+					$providers[$level] = false; // no provider specified
525 525
 					$reason = 'no provider specified';
526 526
 				}
527 527
 			}
528 528
 			elseif (!$params)
529 529
 			{
530
-					$providers[$level] = false;	// cache for $level disabled
530
+					$providers[$level] = false; // cache for $level disabled
531 531
 					$reason = "cache for $level disabled";
532 532
 			}
533 533
 			else
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 				$class = array_shift($params);
538 538
 				if (!class_exists($class))
539 539
 				{
540
-					$providers[$level] = false;	// provider class not found
540
+					$providers[$level] = false; // provider class not found
541 541
 					$reason = "provider $class not found";
542 542
 				}
543 543
 				else
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 					{
547 547
 						$providers[$level] = new $class($params);
548 548
 					}
549
-					catch(Exception $e)
549
+					catch (Exception $e)
550 550
 					{
551
-						$providers[$level] = false;	// eg. could not open connection to backend
551
+						$providers[$level] = false; // eg. could not open connection to backend
552 552
 						$reason = "error instanciating provider $class: ".$e->getMessage();
553 553
 					}
554 554
 				}
@@ -566,35 +566,35 @@  discard block
 block discarded – undo
566 566
 	 * @param boolean $throw =true throw an exception, if we can't retriev the value
567 567
 	 * @return string|boolean string with config or false if not found and !$throw
568 568
 	 */
569
-	static public function get_system_config($name,$throw=true)
569
+	static public function get_system_config($name, $throw = true)
570 570
 	{
571
-		if(!isset($GLOBALS['egw_info']['server'][$name]))
571
+		if (!isset($GLOBALS['egw_info']['server'][$name]))
572 572
 		{
573 573
 			if (isset($GLOBALS['egw_setup']) && isset($GLOBALS['egw_setup']->db) || $GLOBALS['egw']->db)
574 574
 			{
575 575
 				$db = $GLOBALS['egw']->db ? $GLOBALS['egw']->db : $GLOBALS['egw_setup']->db;
576 576
 
577 577
 				try {
578
-					if (($rs = $db->select(Config::TABLE,'config_value',array(
578
+					if (($rs = $db->select(Config::TABLE, 'config_value', array(
579 579
 						'config_app'	=> 'phpgwapi',
580 580
 						'config_name'	=> $name,
581
-					),__LINE__,__FILE__)))
581
+					), __LINE__, __FILE__)))
582 582
 					{
583 583
 						$GLOBALS['egw_info']['server'][$name] = $rs->fetchColumn();
584 584
 					}
585 585
 					else
586 586
 					{
587
-						error_log(__METHOD__."('$name', $throw) config value NOT found!");//.function_backtrace());
587
+						error_log(__METHOD__."('$name', $throw) config value NOT found!"); //.function_backtrace());
588 588
 					}
589 589
 				}
590
-				catch(Db\Exception $e)
590
+				catch (Db\Exception $e)
591 591
 				{
592
-					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace());
592
+					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage()); //.function_backtrace());
593 593
 				}
594 594
 			}
595 595
 			if (!$GLOBALS['egw_info']['server'][$name] && $throw)
596 596
 			{
597
-				throw new Exception (__METHOD__."($name) \$GLOBALS['egw_info']['server']['$name'] is NOT set!");
597
+				throw new Exception(__METHOD__."($name) \$GLOBALS['egw_info']['server']['$name'] is NOT set!");
598 598
 			}
599 599
 		}
600 600
 		return $GLOBALS['egw_info']['server'][$name];
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	 * @param string $level =self::INSTANCE
607 607
 	 * @param string $app =null
608 608
 	 */
609
-	static public function flush($level=self::INSTANCE, $app=null)
609
+	static public function flush($level = self::INSTANCE, $app = null)
610 610
 	{
611 611
 		$ret = true;
612 612
 		if (!($provider = self::get_provider($level)))
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 * @param string $install_id =null default use install_id of current instance
654 654
 	 * @return string new key also stored in self::$instance_key
655 655
 	 */
656
-	static public function generate_instance_key($install_id=null)
656
+	static public function generate_instance_key($install_id = null)
657 657
 	{
658 658
 		if (!isset($install_id))
659 659
 		{
@@ -675,18 +675,18 @@  discard block
 block discarded – undo
675 675
 	 * @param string $location =null
676 676
 	 * @return array
677 677
 	 */
678
-	static public function keys($level, $app=null, $location=null)
678
+	static public function keys($level, $app = null, $location = null)
679 679
 	{
680 680
 		static $tree_key = null;
681 681
 
682
-		switch($level)
682
+		switch ($level)
683 683
 		{
684 684
 			case self::TREE:
685 685
 				if (!isset($tree_key))
686 686
 				{
687
-					$tree_key = $level.'-'.str_replace(array(':','/','\\'),'-', self::$egw_server_root);
687
+					$tree_key = $level.'-'.str_replace(array(':', '/', '\\'), '-', self::$egw_server_root);
688 688
 					// add charset to key, if not utf-8 (as everything we store depends on charset!)
689
-					if (($charset = self::get_system_config('system_charset',false)) && $charset != 'utf-8')
689
+					if (($charset = self::get_system_config('system_charset', false)) && $charset != 'utf-8')
690 690
 					{
691 691
 						$tree_key .= '-'.$charset;
692 692
 					}
Please login to merge, or discard this patch.
Braces   +49 added lines, -12 removed lines patch added patch discarded remove patch
@@ -218,7 +218,10 @@  discard block
 block discarded – undo
218 218
 							foreach($location as $l)
219 219
 							{
220 220
 								$data[$l] = $provider->get($keys=self::keys($level,$app,$l));
221
-								if (!isset($data[$l])) unset($data[$l]);
221
+								if (!isset($data[$l]))
222
+								{
223
+									unset($data[$l]);
224
+								}
222 225
 							}
223 226
 						}
224 227
 					}
@@ -371,7 +374,10 @@  discard block
 block discarded – undo
371 374
 		unset($expiration);	// not used, but required by function signature
372 375
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
373 376
 		{
374
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
377
+			if (Session::ERROR_LOG_DEBUG)
378
+			{
379
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
380
+			}
375 381
 			return false;	// can no longer store something in the session, eg. because commit_session() was called
376 382
 		}
377 383
 		$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = $data;
@@ -396,7 +402,10 @@  discard block
 block discarded – undo
396 402
 		unset($expiration);	// not used, but required by function signature
397 403
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
398 404
 		{
399
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
405
+			if (Session::ERROR_LOG_DEBUG)
406
+			{
407
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
408
+			}
400 409
 			return null;	// can no longer store something in the session, eg. because commit_session() was called
401 410
 		}
402 411
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]) && !is_null($callback))
@@ -417,7 +426,10 @@  discard block
 block discarded – undo
417 426
 	{
418 427
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
419 428
 		{
420
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
429
+			if (Session::ERROR_LOG_DEBUG)
430
+			{
431
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
432
+			}
421 433
 			return false;	// can no longer store something in the session, eg. because commit_session() was called
422 434
 		}
423 435
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]))
@@ -504,7 +516,10 @@  discard block
 block discarded – undo
504 516
 	{
505 517
 		static $providers = array();
506 518
 
507
-		if ($level != self::TREE) $level = self::INSTANCE;
519
+		if ($level != self::TREE)
520
+		{
521
+			$level = self::INSTANCE;
522
+		}
508 523
 
509 524
 		if (!isset($providers[$level]))
510 525
 		{
@@ -515,10 +530,13 @@  discard block
 block discarded – undo
515 530
 			}
516 531
 			if (!isset($params))
517 532
 			{
518
-				if ($level == self::TREE)	// if no tree level provider use the instance level one
533
+				if ($level == self::TREE)
534
+				{
535
+					// if no tree level provider use the instance level one
519 536
 				{
520 537
 					$providers[$level] = self::get_provider(self::INSTANCE);
521 538
 				}
539
+				}
522 540
 				else
523 541
 				{
524 542
 					$providers[$level] = false;	// no provider specified
@@ -532,7 +550,10 @@  discard block
 block discarded – undo
532 550
 			}
533 551
 			else
534 552
 			{
535
-				if (!is_array($params)) $params = (array)$params;
553
+				if (!is_array($params))
554
+				{
555
+					$params = (array)$params;
556
+				}
536 557
 
537 558
 				$class = array_shift($params);
538 559
 				if (!class_exists($class))
@@ -553,7 +574,10 @@  discard block
 block discarded – undo
553 574
 					}
554 575
 				}
555 576
 			}
556
-			if (!$providers[$level] && $log_not_found) error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
577
+			if (!$providers[$level] && $log_not_found)
578
+			{
579
+				error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
580
+			}
557 581
 		}
558 582
 		//error_log(__METHOD__."($level) = ".array2string($providers[$level]).', cache_provider='.array2string($GLOBALS['egw_info']['server']['cache_provider_'.strtolower($level)]));
559 583
 		return $providers[$level];
@@ -589,7 +613,11 @@  discard block
 block discarded – undo
589 613
 				}
590 614
 				catch(Db\Exception $e)
591 615
 				{
592
-					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace());
616
+					if ($throw)
617
+					{
618
+						error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());
619
+					}
620
+					//.function_backtrace());
593 621
 				}
594 622
 			}
595 623
 			if (!$GLOBALS['egw_info']['server'][$name] && $throw)
@@ -697,7 +725,10 @@  discard block
 block discarded – undo
697 725
 				if ($level !== $GLOBALS['egw_info']['server']['install_id'])
698 726
 				{
699 727
 					$level_key = self::getTree(__CLASS__, $level);
700
-					if (!isset($level_key)) $level_key = self::generate_instance_key($level);
728
+					if (!isset($level_key))
729
+					{
730
+						$level_key = self::generate_instance_key($level);
731
+					}
701 732
 					break;
702 733
 				}
703 734
 				// fall-through for current instance
@@ -706,7 +737,10 @@  discard block
 block discarded – undo
706 737
 				{
707 738
 					self::$instance_key = self::getTree(__CLASS__, self::get_system_config('install_id'));
708 739
 					//error_log(__METHOD__."('$level',...) instance_key read from tree-cache=".array2string(self::$instance_key));
709
-					if (!isset(self::$instance_key)) self::$instance_key = self::generate_instance_key();
740
+					if (!isset(self::$instance_key))
741
+					{
742
+						self::$instance_key = self::generate_instance_key();
743
+					}
710 744
 				}
711 745
 				$level_key = self::$instance_key;
712 746
 				break;
@@ -715,7 +749,10 @@  discard block
 block discarded – undo
715 749
 		if (isset($app))
716 750
 		{
717 751
 			$keys[] = $app;
718
-			if (isset($location)) $keys[] = $location;
752
+			if (isset($location))
753
+			{
754
+				$keys[] = $location;
755
+			}
719 756
 		}
720 757
 		return $keys;
721 758
 	}
Please login to merge, or discard this patch.
api/src/Accounts/Sql.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -198,38 +198,38 @@  discard block
 block discarded – undo
198 198
 		if ($data['account_passwd'])
199 199
 		{
200 200
 			// if password it's not already entcrypted, do so now
201
-			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
202
-				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))	// md5 hash
201
+			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $data['account_passwd']) &&
202
+				!preg_match('/^[0-9a-f]{32}$/', $data['account_passwd']))	// md5 hash
203 203
 			{
204 204
 				$data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']);
205 205
 			}
206 206
 			$to_write['account_pwd'] = $data['account_passwd'];
207 207
 			$to_write['account_lastpwd_change'] = time();
208 208
 		}
209
-		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0;
209
+		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change'] = 0;
210 210
 		if (!(int)$data['account_id'] || !$this->id2name($data['account_id']))
211 211
 		{
212 212
 			if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1;
213 213
 
214
-			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = '';	// is NOT NULL!
215
-			if (!isset($to_write['account_status'])) $to_write['account_status'] = '';	// is NOT NULL!
214
+			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = ''; // is NOT NULL!
215
+			if (!isset($to_write['account_status'])) $to_write['account_status'] = ''; // is NOT NULL!
216 216
 
217 217
 			// postgres requires the auto-id field to be unset!
218 218
 			if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']);
219 219
 
220
-			if (!in_array($to_write['account_type'],array('u','g')) ||
221
-				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false;
220
+			if (!in_array($to_write['account_type'], array('u', 'g')) ||
221
+				!$this->db->insert($this->table, $to_write, false, __LINE__, __FILE__)) return false;
222 222
 
223 223
 			if (!(int)$data['account_id'])
224 224
 			{
225
-				$data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id');
225
+				$data['account_id'] = $this->db->get_last_insert_id($this->table, 'account_id');
226 226
 				if ($data['account_type'] == 'g') $data['account_id'] *= -1;
227 227
 			}
228 228
 		}
229 229
 		else	// update of existing account
230 230
 		{
231 231
 			unset($to_write['account_id']);
232
-			if (!$this->db->update($this->table,$to_write,array('account_id' => abs($data['account_id'])),__LINE__,__FILE__))
232
+			if (!$this->db->update($this->table, $to_write, array('account_id' => abs($data['account_id'])), __LINE__, __FILE__))
233 233
 			{
234 234
 				return false;
235 235
 			}
@@ -278,16 +278,16 @@  discard block
 block discarded – undo
278 278
 	{
279 279
 		if (!(int)$account_id) return false;
280 280
 
281
-		$contact_id = $this->id2name($account_id,'person_id');
281
+		$contact_id = $this->id2name($account_id, 'person_id');
282 282
 
283
-		if (!$this->db->delete($this->table,array('account_id' => abs($account_id)),__LINE__,__FILE__))
283
+		if (!$this->db->delete($this->table, array('account_id' => abs($account_id)), __LINE__, __FILE__))
284 284
 		{
285 285
 			return false;
286 286
 		}
287 287
 		if ($contact_id)
288 288
 		{
289 289
 			if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
290
-			$this->contacts->delete($contact_id,false);	// false = allow to delete accounts (!)
290
+			$this->contacts->delete($contact_id, false); // false = allow to delete accounts (!)
291 291
 		}
292 292
 		return true;
293 293
 	}
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 		if (!(int)$account_id) return false;
304 304
 
305 305
 		$memberships = array();
306
-		if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
306
+		if (($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
307 307
 		{
308
-			foreach($gids as $gid)
308
+			foreach ($gids as $gid)
309 309
 			{
310
-				$memberships[(string) $gid] = $this->id2name($gid);
310
+				$memberships[(string)$gid] = $this->id2name($gid);
311 311
 			}
312 312
 		}
313 313
 		return $memberships;
@@ -319,17 +319,17 @@  discard block
 block discarded – undo
319 319
 	 * @param array $groups array with gidnumbers
320 320
 	 * @param int $account_id numerical account-id
321 321
 	 */
322
-	function set_memberships($groups,$account_id)
322
+	function set_memberships($groups, $account_id)
323 323
 	{
324 324
 		if (!(int)$account_id) return;
325 325
 
326 326
 		$acl = new Api\Acl($account_id);
327 327
 		$acl->read_repository();
328
-		$acl->delete('phpgw_group',false);
328
+		$acl->delete('phpgw_group', false);
329 329
 
330
-		foreach($groups as $group)
330
+		foreach ($groups as $group)
331 331
 		{
332
-			$acl->add('phpgw_group',$group,1);
332
+			$acl->add('phpgw_group', $group, 1);
333 333
 		}
334 334
 		$acl->save_repository();
335 335
 	}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		if (!is_numeric($account_id)) $account_id = $this->name2id($account_id);
346 346
 
347 347
 		$members = array();
348
-		foreach($this->db->select($this->table, 'account_id,account_lid',
348
+		foreach ($this->db->select($this->table, 'account_id,account_lid',
349 349
 			$this->db->expression(Api\Acl::TABLE, array(
350 350
 				'acl_appname'  => 'phpgw_group',
351 351
 				'acl_location' => $account_id,
@@ -364,15 +364,15 @@  discard block
 block discarded – undo
364 364
 	 * @param array $members array with uidnumber or uid's
365 365
 	 * @param int $gid gidnumber of group to set
366 366
 	 */
367
-	function set_members($members,$gid)
367
+	function set_members($members, $gid)
368 368
 	{
369
-		$GLOBALS['egw']->acl->delete_repository('phpgw_group',$gid,false);
369
+		$GLOBALS['egw']->acl->delete_repository('phpgw_group', $gid, false);
370 370
 
371 371
 		if (is_array($members))
372 372
 		{
373
-			foreach($members as $id)
373
+			foreach ($members as $id)
374 374
 			{
375
-				$GLOBALS['egw']->acl->add_repository('phpgw_group',$gid,$id,1);
375
+				$GLOBALS['egw']->acl->add_repository('phpgw_group', $gid, $id, 1);
376 376
 			}
377 377
 		}
378 378
 	}
@@ -407,20 +407,20 @@  discard block
 block discarded – undo
407 407
 		);
408 408
 
409 409
 		// fetch order of account_fullname from Api\Accounts::format_username
410
-		if (strpos($param['order'],'account_fullname') !== false)
410
+		if (strpos($param['order'], 'account_fullname') !== false)
411 411
 		{
412
-			$param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/',',',str_replace(array('[',']'),'',
413
-				Api\Accounts::format_username('account_lid','account_firstname','account_lastname'))), $param['order']);
412
+			$param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/', ',', str_replace(array('[', ']'), '',
413
+				Api\Accounts::format_username('account_lid', 'account_firstname', 'account_lastname'))), $param['order']);
414 414
 		}
415
-		$order = str_replace(array_keys($order2contact),array_values($order2contact),$param['order']);
415
+		$order = str_replace(array_keys($order2contact), array_values($order2contact), $param['order']);
416 416
 		// allways add 'account_lid', as it is only valid one for groups
417 417
 		if (strpos($order, 'account_lid') === false)
418 418
 		{
419
-			$order .= ($order?',':'').'account_lid';
419
+			$order .= ($order ? ',' : '').'account_lid';
420 420
 		}
421 421
 		if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
422 422
 
423
-		$search_cols = array('account_lid','n_family','n_given','email');
423
+		$search_cols = array('account_lid', 'n_family', 'n_given', 'email');
424 424
 		$join = $this->contacts_join;
425 425
 		$email_cols = array('email');
426 426
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 
438 438
 		$filter = array();
439
-		switch($param['type'])
439
+		switch ($param['type'])
440 440
 		{
441 441
 			case 'accounts':
442 442
 				$filter['owner'] = 0;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 			case 'groupmembers':
452 452
 			case 'groupmembers+memberships':
453 453
 				$members = array();
454
-				foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp => $name)
454
+				foreach ((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp => $name)
455 455
 				{
456 456
 					unset($name);
457 457
 					$members = array_unique(array_merge($members, array_keys((array)$this->members($grp))));
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 		}
487 487
 		if ($param['active'])
488 488
 		{
489
-			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),Api\Contacts\Sql::ACOUNT_ACTIVE_FILTER);
489
+			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())', time(), Api\Contacts\Sql::ACOUNT_ACTIVE_FILTER);
490 490
 		}
491 491
 		$criteria = array();
492 492
 		$wildcard = $param['query_type'] == 'start' || $param['query_type'] == 'exact' ? '' : '%';
493 493
 		if (($query = $param['query']))
494 494
 		{
495
-			switch($param['query_type'])
495
+			switch ($param['query_type'])
496 496
 			{
497 497
 				case 'start':
498 498
 					$query .= '*';
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				case 'all':
501 501
 				default:
502 502
 				case 'exact':
503
-					foreach($search_cols as $col)
503
+					foreach ($search_cols as $col)
504 504
 					{
505 505
 						$criteria[$col] = $query;
506 506
 					}
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 				case 'email':
522 522
 					$criteria['email'] = $query;
523 523
 					// Group email
524
-					if(in_array(Api\Mail\Smtp\Sql::TABLE, $this->db->table_names(true)))
524
+					if (in_array(Api\Mail\Smtp\Sql::TABLE, $this->db->table_names(true)))
525 525
 					{
526 526
 						$criteria[Api\Mail\Smtp\Sql::TABLE.'.mail_value'] = $query;
527 527
 					}
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
 		if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
532 532
 
533 533
 		$accounts = array();
534
-		foreach((array) $this->contacts->search($criteria,
535
-			array_merge(array(1,'n_given','n_family','id','created','modified',$this->table.'.account_id AS account_id'),$email_cols),
536
-			$order,"account_lid,account_type,account_status,account_expires,account_primary_group,account_description",
537
-			$wildcard,false,$query[0] == '!' ? 'AND' : 'OR',
534
+		foreach ((array)$this->contacts->search($criteria,
535
+			array_merge(array(1, 'n_given', 'n_family', 'id', 'created', 'modified', $this->table.'.account_id AS account_id'), $email_cols),
536
+			$order, "account_lid,account_type,account_status,account_expires,account_primary_group,account_description",
537
+			$wildcard, false, $query[0] == '!' ? 'AND' : 'OR',
538 538
 			$param['offset'] ? array($param['start'], $param['offset']) : (is_null($param['start']) ? false : $param['start']),
539
-			$filter,$join) as $contact)
539
+			$filter, $join) as $contact)
540 540
 		{
541 541
 			if ($contact)
542 542
 			{
@@ -576,13 +576,13 @@  discard block
 block discarded – undo
576 576
 	 * @param string $account_type u = user, g = group, default null = try both
577 577
 	 * @return int/false numeric account_id or false on error ($name not found)
578 578
 	 */
579
-	function name2id($name,$which='account_lid',$account_type=null)
579
+	function name2id($name, $which = 'account_lid', $account_type = null)
580 580
 	{
581 581
 		if ($account_type === 'g' && $which != 'account_lid') return false;
582 582
 
583 583
 		$where = array();
584 584
 		$cols = 'account_id';
585
-		switch($which)
585
+		switch ($which)
586 586
 		{
587 587
 			case 'account_fullname':
588 588
 				$table = $this->contacts_table;
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 		}
614 614
 		else
615 615
 		{
616
-			$where[] = 'account_id IS NOT NULL'.	// otherwise contacts with eg. the same email hide the accounts!
617
-				($table == $this->contacts_table ? " AND contact_tid != 'D'" : '');	// ignore deleted accounts contact-data
616
+			$where[] = 'account_id IS NOT NULL'.// otherwise contacts with eg. the same email hide the accounts!
617
+				($table == $this->contacts_table ? " AND contact_tid != 'D'" : ''); // ignore deleted accounts contact-data
618 618
 
619 619
 		}
620
-		if (!($rs = $this->db->select($table,$cols,$where,__LINE__,__FILE__)) || !($row = $rs->fetch()))
620
+		if (!($rs = $this->db->select($table, $cols, $where, __LINE__, __FILE__)) || !($row = $rs->fetch()))
621 621
 		{
622 622
 			//error_log(__METHOD__."('$name', '$which', ".array2string($account_type).") db->select('$table', '$cols', ".array2string($where).") returned ".array2string($rs).' '.function_backtrace());
623 623
 			return false;
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @param string $which ='account_lid' type to convert to: account_lid (default), account_email, ...
635 635
 	 * @return string/false converted value or false on error ($account_id not found)
636 636
 	 */
637
-	function id2name($account_id,$which='account_lid')
637
+	function id2name($account_id, $which = 'account_lid')
638 638
 	{
639
-		return $this->frontend->id2name($account_id,$which);
639
+		return $this->frontend->id2name($account_id, $which);
640 640
 	}
641 641
 
642 642
 	/**
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 	 */
649 649
 	function update_lastlogin($account_id, $ip)
650 650
 	{
651
-		$previous_login = $this->db->select($this->table,'account_lastlogin',array('account_id'=>abs($account_id)),__LINE__,__FILE__)->fetchColumn();
651
+		$previous_login = $this->db->select($this->table, 'account_lastlogin', array('account_id'=>abs($account_id)), __LINE__, __FILE__)->fetchColumn();
652 652
 
653
-		$this->db->update($this->table,array(
653
+		$this->db->update($this->table, array(
654 654
 			'account_lastloginfrom' => $ip,
655 655
 			'account_lastlogin'     => time(),
656
-		),array(
656
+		), array(
657 657
 			'account_id' => abs($account_id),
658
-		),__LINE__,__FILE__);
658
+		), __LINE__, __FILE__);
659 659
 
660 660
 		return $previous_login;
661 661
 	}
Please login to merge, or discard this patch.
Braces   +94 added lines, -23 removed lines patch added patch discarded remove patch
@@ -122,7 +122,10 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	function read($account_id)
124 124
 	{
125
-		if (!(int)$account_id) return false;
125
+		if (!(int)$account_id)
126
+		{
127
+			return false;
128
+		}
126 129
 
127 130
 		if ($account_id > 0)
128 131
 		{
@@ -152,11 +155,14 @@  discard block
 block discarded – undo
152 155
 			unset($e);
153 156
 		}
154 157
 
155
-		if (!$rs)	// handle not (yet) existing mailaccounts table
158
+		if (!$rs)
159
+		{
160
+			// handle not (yet) existing mailaccounts table
156 161
 		{
157 162
 			$rs = $this->db->select($this->table, $this->table.'.*',
158 163
 				$this->table.'.account_id='.abs($account_id), __LINE__, __FILE__);
159 164
 		}
165
+		}
160 166
 		if (!$rs || !($data = $rs->fetch()))
161 167
 		{
162 168
 			return false;
@@ -166,7 +172,10 @@  discard block
 block discarded – undo
166 172
 			$data['account_id'] = -$data['account_id'];
167 173
 			$data['mailAllowed'] = true;
168 174
 		}
169
-		if (!$data['account_firstname']) $data['account_firstname'] = $data['account_lid'];
175
+		if (!$data['account_firstname'])
176
+		{
177
+			$data['account_firstname'] = $data['account_lid'];
178
+		}
170 179
 		if (!$data['account_lastname'])
171 180
 		{
172 181
 			$data['account_lastname'] = $data['account_type'] == 'g' ? 'Group' : 'User';
@@ -177,7 +186,10 @@  discard block
 block discarded – undo
177 186
 				$data['account_lastname'] = lang($data['account_lastname']);
178 187
 			}
179 188
 		}
180
-		if (!$data['account_fullname']) $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
189
+		if (!$data['account_fullname'])
190
+		{
191
+			$data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
192
+		}
181 193
 
182 194
 		return $data;
183 195
 	}
@@ -199,31 +211,57 @@  discard block
 block discarded – undo
199 211
 		{
200 212
 			// if password it's not already entcrypted, do so now
201 213
 			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
202
-				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))	// md5 hash
214
+				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))
215
+			{
216
+				// md5 hash
203 217
 			{
204 218
 				$data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']);
205 219
 			}
220
+			}
206 221
 			$to_write['account_pwd'] = $data['account_passwd'];
207 222
 			$to_write['account_lastpwd_change'] = time();
208 223
 		}
209
-		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0;
224
+		if ($data['mustchangepassword'] == 1)
225
+		{
226
+			$to_write['account_lastpwd_change']=0;
227
+		}
210 228
 		if (!(int)$data['account_id'] || !$this->id2name($data['account_id']))
211 229
 		{
212
-			if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1;
230
+			if ($to_write['account_id'] < 0)
231
+			{
232
+				$to_write['account_id'] *= -1;
233
+			}
213 234
 
214
-			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = '';	// is NOT NULL!
215
-			if (!isset($to_write['account_status'])) $to_write['account_status'] = '';	// is NOT NULL!
235
+			if (!isset($to_write['account_pwd']))
236
+			{
237
+				$to_write['account_pwd'] = '';
238
+			}
239
+			// is NOT NULL!
240
+			if (!isset($to_write['account_status']))
241
+			{
242
+				$to_write['account_status'] = '';
243
+			}
244
+			// is NOT NULL!
216 245
 
217 246
 			// postgres requires the auto-id field to be unset!
218
-			if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']);
247
+			if (isset($to_write['account_id']) && !$to_write['account_id'])
248
+			{
249
+				unset($to_write['account_id']);
250
+			}
219 251
 
220 252
 			if (!in_array($to_write['account_type'],array('u','g')) ||
221
-				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false;
253
+				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__))
254
+			{
255
+				return false;
256
+			}
222 257
 
223 258
 			if (!(int)$data['account_id'])
224 259
 			{
225 260
 				$data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id');
226
-				if ($data['account_type'] == 'g') $data['account_id'] *= -1;
261
+				if ($data['account_type'] == 'g')
262
+				{
263
+					$data['account_id'] *= -1;
264
+				}
227 265
 			}
228 266
 		}
229 267
 		else	// update of existing account
@@ -276,7 +314,10 @@  discard block
 block discarded – undo
276 314
 	 */
277 315
 	function delete($account_id)
278 316
 	{
279
-		if (!(int)$account_id) return false;
317
+		if (!(int)$account_id)
318
+		{
319
+			return false;
320
+		}
280 321
 
281 322
 		$contact_id = $this->id2name($account_id,'person_id');
282 323
 
@@ -286,7 +327,10 @@  discard block
 block discarded – undo
286 327
 		}
287 328
 		if ($contact_id)
288 329
 		{
289
-			if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
330
+			if (!isset($this->contacts))
331
+			{
332
+				$this->contacts = new Api\Contacts();
333
+			}
290 334
 			$this->contacts->delete($contact_id,false);	// false = allow to delete accounts (!)
291 335
 		}
292 336
 		return true;
@@ -300,7 +344,10 @@  discard block
 block discarded – undo
300 344
 	 */
301 345
 	function memberships($account_id)
302 346
 	{
303
-		if (!(int)$account_id) return false;
347
+		if (!(int)$account_id)
348
+		{
349
+			return false;
350
+		}
304 351
 
305 352
 		$memberships = array();
306 353
 		if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
@@ -321,7 +368,10 @@  discard block
 block discarded – undo
321 368
 	 */
322 369
 	function set_memberships($groups,$account_id)
323 370
 	{
324
-		if (!(int)$account_id) return;
371
+		if (!(int)$account_id)
372
+		{
373
+			return;
374
+		}
325 375
 
326 376
 		$acl = new Api\Acl($account_id);
327 377
 		$acl->read_repository();
@@ -342,7 +392,10 @@  discard block
 block discarded – undo
342 392
 	 */
343 393
 	function members($account_id)
344 394
 	{
345
-		if (!is_numeric($account_id)) $account_id = $this->name2id($account_id);
395
+		if (!is_numeric($account_id))
396
+		{
397
+			$account_id = $this->name2id($account_id);
398
+		}
346 399
 
347 400
 		$members = array();
348 401
 		foreach($this->db->select($this->table, 'account_id,account_lid',
@@ -418,7 +471,10 @@  discard block
 block discarded – undo
418 471
 		{
419 472
 			$order .= ($order?',':'').'account_lid';
420 473
 		}
421
-		if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
474
+		if ($param['sort'])
475
+		{
476
+			$order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
477
+		}
422 478
 
423 479
 		$search_cols = array('account_lid','n_family','n_given','email');
424 480
 		$join = $this->contacts_join;
@@ -455,7 +511,10 @@  discard block
 block discarded – undo
455 511
 				{
456 512
 					unset($name);
457 513
 					$members = array_unique(array_merge($members, array_keys((array)$this->members($grp))));
458
-					if ($param['type'] == 'groupmembers+memberships') $members[] = abs($grp);
514
+					if ($param['type'] == 'groupmembers+memberships')
515
+					{
516
+						$members[] = abs($grp);
517
+					}
459 518
 				}
460 519
 				$filter['account_id'] = $members;
461 520
 				break;
@@ -474,9 +533,12 @@  discard block
 block discarded – undo
474 533
 		// fix ambigous account_id (used in accounts and contacts table)
475 534
 		if (array_key_exists('account_id', $filter))
476 535
 		{
477
-			if (!$filter['account_id'])	// eg. group without members (would give SQL error)
536
+			if (!$filter['account_id'])
537
+			{
538
+				// eg. group without members (would give SQL error)
478 539
 			{
479 540
 				$this->total = 0;
541
+			}
480 542
 				return array();
481 543
 			}
482 544
 			$filter[] = $this->db->expression($this->table, $this->table.'.', array(
@@ -528,7 +590,10 @@  discard block
 block discarded – undo
528 590
 					break;
529 591
 			}
530 592
 		}
531
-		if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
593
+		if (!isset($this->contacts))
594
+		{
595
+			$this->contacts = new Api\Contacts();
596
+		}
532 597
 
533 598
 		$accounts = array();
534 599
 		foreach((array) $this->contacts->search($criteria,
@@ -578,7 +643,10 @@  discard block
 block discarded – undo
578 643
 	 */
579 644
 	function name2id($name,$which='account_lid',$account_type=null)
580 645
 	{
581
-		if ($account_type === 'g' && $which != 'account_lid') return false;
646
+		if ($account_type === 'g' && $which != 'account_lid')
647
+		{
648
+			return false;
649
+		}
582 650
 
583 651
 		$where = array();
584 652
 		$cols = 'account_id';
@@ -601,9 +669,12 @@  discard block
 block discarded – undo
601 669
 				$cols .= ',account_type';
602 670
 				$where[$which] = $name;
603 671
 				// check if we need to treat username case-insensitive
604
-				if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username'])	// = is case sensitiv eg. on postgres, but not on mysql!
672
+				if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username'])
673
+				{
674
+					// = is case sensitiv eg. on postgres, but not on mysql!
605 675
 				{
606 676
 					$where[] = 'account_lid '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote($where['account_lid']);
677
+				}
607 678
 					unset($where['account_lid']);
608 679
 				}
609 680
 		}
Please login to merge, or discard this patch.