Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
filemanager/inc/class.filemanager_collab.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@
 block discarded – undo
201 201
 	/**
202 202
 	 * Check if session is valid
203 203
 	 *
204
-	 * @param type $es_id
204
+	 * @param string $es_id
205 205
 	 *
206 206
 	 * @return boolean return true if session is valid otherwise false
207 207
 	 */
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
 
13 13
 use EGroupware\Api;
14 14
 
15
-class filemanager_collab extends filemanager_collab_bo {
15
+class filemanager_collab extends filemanager_collab_bo
16
+{
16 17
 
17 18
 	/**
18 19
 	 * Methods callable via menuaction
@@ -77,7 +78,10 @@  discard block
 block discarded – undo
77 78
 	 */
78 79
 	function leave_session ($es_id, $member_id)
79 80
 	{
80
-		if (!$this->is_sessionValid($es_id) || !$this->is_memberValid($es_id, $member_id)) throw new Exception ('Session is not valid!');
81
+		if (!$this->is_sessionValid($es_id) || !$this->is_memberValid($es_id, $member_id))
82
+		{
83
+			throw new Exception ('Session is not valid!');
84
+		}
81 85
 		$this->MEMBER_UpdateActiveMember($es_id, $member_id, 0);
82 86
 		return array (
83 87
 			'session_id' => $es_id,
@@ -138,7 +142,8 @@  discard block
 block discarded – undo
138 142
 						// we need to inform clients about session changes to update themselves
139 143
 						// based on that. For instance, after discarding changes other participants
140 144
 						// should get notified to reload their session.
141
-						if (!$this->is_memberValid($es_id, $memberid)) {
145
+						if (!$this->is_memberValid($es_id, $memberid))
146
+						{
142 147
 							$response = array (
143 148
 								'result' => 'error',
144 149
 								'error' => 'ENOSESSION'
@@ -150,7 +155,8 @@  discard block
 block discarded – undo
150 155
 						{
151 156
 							$client_ops = $params['args']['client_ops']? $params['args']['client_ops']: [];
152 157
 							$current_seq_head = $this->OP_getHeadSeq($es_id);
153
-							if ($seq_head == $current_seq_head) {
158
+							if ($seq_head == $current_seq_head)
159
+							{
154 160
 
155 161
 								if (count($client_ops)>0)
156 162
 								{
@@ -183,7 +189,8 @@  discard block
 block discarded – undo
183 189
 						{
184 190
 							throw new Exception('Invalid seq head!');
185 191
 						}
186
-					} catch (Exception $ex) {
192
+					}
193
+					catch (Exception $ex) {
187 194
 						error_log($ex->getMessage());
188 195
 					}
189 196
 
@@ -259,7 +266,10 @@  discard block
 block discarded – undo
259 266
 			case 'save':
260 267
 				$this->SESSION_Save($params['es_id']);
261 268
 				//update genesis file after save happened
262
-				if ($params['file_path']) self::generateGenesis ($params['file_path'], $params['es_id']);
269
+				if ($params['file_path'])
270
+				{
271
+					self::generateGenesis ($params['file_path'], $params['es_id']);
272
+				}
263 273
 				break;
264 274
 			case 'delete':
265 275
 				$this->SESSION_cleanup($params['es_id']);
@@ -349,7 +359,10 @@  discard block
 block discarded – undo
349 359
 		if ($session && $session['genesis_url'] !== '')
350 360
 		{
351 361
 			$gen_file = explode('/webdav.php',$session['genesis_url']);
352
-			if (!Api\Vfs::file_exists($gen_file[1])) self::generateGenesis ($file_path, $es_id);
362
+			if (!Api\Vfs::file_exists($gen_file[1]))
363
+			{
364
+				self::generateGenesis ($file_path, $es_id);
365
+			}
353 366
 			$result = array (
354 367
 				'es_id' => $session['es_id'],
355 368
 				'genesis_url' => $session['genesis_url']
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return array returns an array consists of session data
47 47
 	 */
48
-	function join_session ($es_id)
48
+	function join_session($es_id)
49 49
 	{
50 50
 		if ($es_id === self::NEW_FILE_ES_ID)
51 51
 		{
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		{
59 59
 			$response = $this->initSession($es_id);
60 60
 		}
61
-		$response += array (
61
+		$response += array(
62 62
 			'id' => $GLOBALS['egw_info']['user']['account_id'],
63 63
 			'full_name' => $GLOBALS['egw_info']['user']['account_fullname'],
64 64
 			'success' => true
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return array returns an array of data as response for client-side
77 77
 	 */
78
-	function leave_session ($es_id, $member_id)
78
+	function leave_session($es_id, $member_id)
79 79
 	{
80
-		if (!$this->is_sessionValid($es_id) || !$this->is_memberValid($es_id, $member_id)) throw new Exception ('Session is not valid!');
80
+		if (!$this->is_sessionValid($es_id) || !$this->is_memberValid($es_id, $member_id)) throw new Exception('Session is not valid!');
81 81
 		$this->MEMBER_UpdateActiveMember($es_id, $member_id, 0);
82
-		return array (
82
+		return array(
83 83
 			'session_id' => $es_id,
84 84
 			'memberid' => $member_id,
85 85
 			'success' => $this->OP_removeMember($es_id, $member_id)
@@ -91,26 +91,26 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @throws Exception
93 93
 	 */
94
-	function poll ()
94
+	function poll()
95 95
 	{
96 96
 		// Get POST request payload
97 97
 		$payload = file_get_contents('php://input');
98
-		$params = $payload? json_decode ($payload, true): null;
98
+		$params = $payload ? json_decode ($payload, true) : null;
99 99
 		$response = array();
100 100
 		if (is_array($params))
101 101
 		{
102 102
 			switch ($params['command'])
103 103
 			{
104 104
 				case 'join_session':
105
-					$response = $this->join_session($params['args']['es_id'],$params['args']['user_id']);
105
+					$response = $this->join_session($params['args']['es_id'], $params['args']['user_id']);
106 106
 					break;
107 107
 				case 'leave_session':
108 108
 					if ($params['args']['es_id'] === self::NEW_FILE_ES_ID)
109 109
 					{
110
-						$response = array ('success' => true,'memberid' => '0','session_id'=>self::NEW_FILE_ES_ID);
110
+						$response = array('success' => true, 'memberid' => '0', 'session_id'=>self::NEW_FILE_ES_ID);
111 111
 						break;
112 112
 					}
113
-					$response = $this->leave_session($params['args']['es_id'],$params['args']['member_id']);
113
+					$response = $this->leave_session($params['args']['es_id'], $params['args']['member_id']);
114 114
 					break;
115 115
 				case 'sync_ops':
116 116
 					try
@@ -132,27 +132,27 @@  discard block
 block discarded – undo
132 132
 							break;
133 133
 						}
134 134
 
135
-						$memberid = $params['args']['member_id']? $params['args']['member_id']: '';
135
+						$memberid = $params['args']['member_id'] ? $params['args']['member_id'] : '';
136 136
 						$es_id = $params['args']['es_id'];
137
-						$seq_head = (string) isset($params['args']['seq_head'])? $params['args']['seq_head']: null;
137
+						$seq_head = (string)isset($params['args']['seq_head']) ? $params['args']['seq_head'] : null;
138 138
 						// we need to inform clients about session changes to update themselves
139 139
 						// based on that. For instance, after discarding changes other participants
140 140
 						// should get notified to reload their session.
141 141
 						if (!$this->is_memberValid($es_id, $memberid)) {
142
-							$response = array (
142
+							$response = array(
143 143
 								'result' => 'error',
144 144
 								'error' => 'ENOSESSION'
145 145
 							);
146 146
 							throw new Exception('Session is not valid!');
147 147
 						}
148 148
 
149
-						if(!is_null($seq_head))
149
+						if (!is_null($seq_head))
150 150
 						{
151
-							$client_ops = $params['args']['client_ops']? $params['args']['client_ops']: [];
151
+							$client_ops = $params['args']['client_ops'] ? $params['args']['client_ops'] : [];
152 152
 							$current_seq_head = $this->OP_getHeadSeq($es_id);
153 153
 							if ($seq_head == $current_seq_head) {
154 154
 
155
-								if (count($client_ops)>0)
155
+								if (count($client_ops) > 0)
156 156
 								{
157 157
 									$newHead = $this->get_newHead($es_id, $memberid, $client_ops);
158 158
 									$response = array(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 							else
173 173
 							{
174 174
 								$response = array(
175
-									'result' => count($client_ops)>0 ? 'conflict' : 'new_ops',
175
+									'result' => count($client_ops) > 0 ? 'conflict' : 'new_ops',
176 176
 									'ops' => $this->OP_getOPSECS($es_id, $seq_head),
177 177
 									'head_seq' => $current_seq_head,
178 178
 								);
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 	{
209 209
 		$date = new Api\DateTime();
210 210
 		$use_id = $GLOBALS['egw_info']['user']['account_id'];
211
-		$response = array (
211
+		$response = array(
212 212
 			'result' => 'new_ops',
213
-			'ops'=> array (
214
-				0 => array (
213
+			'ops'=> array(
214
+				0 => array(
215 215
 					'optype' => 'AddMember',
216 216
 					'memberid' => '0',
217 217
 					'timestamp' => $date->getTimestamp(),
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return string return a seq head number
239 239
 	 */
240
-	function get_newHead ($es_id, $member_id, $client_ops)
240
+	function get_newHead($es_id, $member_id, $client_ops)
241 241
 	{
242 242
 		$this->OP_addOPS($es_id, $member_id, $client_ops);
243 243
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @param array $params
252 252
 	 * @param string $action
253 253
 	 */
254
-	function ajax_actions ($params, $action)
254
+	function ajax_actions($params, $action)
255 255
 	{
256 256
 		$response = Api\Json\Response::get();
257 257
 		switch ($action)
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			case 'save':
260 260
 				$this->SESSION_Save($params['es_id']);
261 261
 				//update genesis file after save happened
262
-				if ($params['file_path']) self::generateGenesis ($params['file_path'], $params['es_id']);
262
+				if ($params['file_path']) self::generateGenesis($params['file_path'], $params['es_id']);
263 263
 				break;
264 264
 			case 'delete':
265 265
 				$this->SESSION_cleanup($params['es_id']);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				break;
270 270
 			case 'checkLastMember':
271 271
 				$activeMembers = $this->MEMBER_getActiveMembers($params['es_id']);
272
-				$response->data(is_array($activeMembers) && count($activeMembers) > 1?false:true);
272
+				$response->data(is_array($activeMembers) && count($activeMembers) > 1 ?false:true);
273 273
 				break;
274 274
 			default:
275 275
 				//
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return boolean returns true if allowed
287 287
 	 */
288
-	function is_collabAllowed ($file_path, $_right=null)
288
+	function is_collabAllowed($file_path, $_right = null)
289 289
 	{
290 290
 		$paths = explode('/webdav.php', $file_path);
291 291
 		$right = $_right ? $_right : Api\Vfs::WRITABLE;
292
-		$allowed =	Api\Vfs::check_access($paths[1], $right) &&
292
+		$allowed = Api\Vfs::check_access($paths[1], $right) &&
293 293
 					!preg_match('/\/api\/js\/webodf\/template.odf$/', $file_path);
294 294
 		return $allowed;
295 295
 	}
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
 	 *
302 302
 	 * @return boolean return true if session is valid otherwise false
303 303
 	 */
304
-	function is_sessionValid ($es_id)
304
+	function is_sessionValid($es_id)
305 305
 	{
306 306
 		$session = $this->SESSION_Get($es_id);
307
-		return $session? true : false;
307
+		return $session ? true : false;
308 308
 	}
309 309
 
310 310
 	/**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @param type $member_id
316 316
 	 * @return boolean returns true if it's valid
317 317
 	 */
318
-	function is_memberValid ($es_id, $member_id)
318
+	function is_memberValid($es_id, $member_id)
319 319
 	{
320 320
 		$member = $this->MEMBER_getMember($es_id, $member_id);
321 321
 		return $member && $member['status'] != 0 ? true: false;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param boolean $_isNew true means this is an empty doc opened as new file
331 331
 	 * in client-side and not stored yet therefore no genesis file should get generated for it.
332 332
 	 */
333
-	function ajax_getGenesisUrl ($file_path, $_isNew)
333
+	function ajax_getGenesisUrl($file_path, $_isNew)
334 334
 	{
335 335
 		$result = array();
336 336
 		$es_id = md5($file_path);
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 		// handle new empty file
339 339
 		if ($_isNew)
340 340
 		{
341
-			$response->data(array (
341
+			$response->data(array(
342 342
 				'es_id' => self::NEW_FILE_ES_ID,
343 343
 				'genesis_url' => $GLOBALS['egw_info']['server']['webserver_url'].'/api/js/webodf/template.odt'
344 344
 			));
@@ -348,16 +348,16 @@  discard block
 block discarded – undo
348 348
 
349 349
 		if ($session && $session['genesis_url'] !== '')
350 350
 		{
351
-			$gen_file = explode('/webdav.php',$session['genesis_url']);
352
-			if (!Api\Vfs::file_exists($gen_file[1])) self::generateGenesis ($file_path, $es_id);
353
-			$result = array (
351
+			$gen_file = explode('/webdav.php', $session['genesis_url']);
352
+			if (!Api\Vfs::file_exists($gen_file[1])) self::generateGenesis($file_path, $es_id);
353
+			$result = array(
354 354
 				'es_id' => $session['es_id'],
355 355
 				'genesis_url' => $session['genesis_url']
356 356
 			);
357 357
 		}
358 358
 		else if ($this->is_collabAllowed($file_path, Api\Vfs::WRITABLE))
359 359
 		{
360
-			$result = array (
360
+			$result = array(
361 361
 				'es_id' => $es_id,
362 362
 				'genesis_url' => self::generateGenesis($file_path, $es_id)
363 363
 			);
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @return string returns genesis url
376 376
 	 */
377
-	static function generateGenesis ($file_path, $es_id)
377
+	static function generateGenesis($file_path, $es_id)
378 378
 	{
379 379
 		$paths = explode('/webdav.php', $file_path);
380
-		$dir_parts = explode('/',$paths[1]);
380
+		$dir_parts = explode('/', $paths[1]);
381 381
 		array_pop($dir_parts);
382 382
 		$dir = join('/', $dir_parts);
383 383
 		$genesis_file = $dir.'/.'.$es_id.'.webodf.odt';
Please login to merge, or discard this patch.
api/src/Accounts.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 	 * Not all existing accounts are visible because off account_selection preference: 'none' or 'groupmembers'
800 800
 	 *
801 801
 	 * @param int|string $account_id nummeric account_id or account_lid
802
-	 * @return boolean true = account is visible, false = account not visible, null = account does not exist
802
+	 * @return null|boolean true = account is visible, false = account not visible, null = account does not exist
803 803
 	 */
804 804
 	function visible($account_id)
805 805
 	{
@@ -994,7 +994,6 @@  discard block
 block discarded – undo
994 994
 	 *
995 995
 	 * @param string $account_lid
996 996
 	 * @param string $passwd
997
-	 * @param array $GLOBALS['auto_create_acct'] values for 'firstname', 'lastname', 'email' and 'primary_group'
998 997
 	 * @return int|boolean account_id or false on error
999 998
 	 */
1000 999
 	function auto_add($account_lid, $passwd)
@@ -1114,7 +1113,7 @@  discard block
 block discarded – undo
1114 1113
 	 *
1115 1114
 	 * We use now an instance-wide read-cache storing account-data and members(hips).
1116 1115
 	 *
1117
-	 * @param int|array $account_ids user- or group-id(s) for which cache should be invalidated, default 0 = only search/name2id cache
1116
+	 * @param integer $account_ids user- or group-id(s) for which cache should be invalidated, default 0 = only search/name2id cache
1118 1117
 	 */
1119 1118
 	static function cache_invalidate($account_ids=0)
1120 1119
 	{
Please login to merge, or discard this patch.
Braces   +118 added lines, -30 removed lines patch added patch discarded remove patch
@@ -148,7 +148,10 @@  discard block
 block discarded – undo
148 148
 		{
149 149
 			$this->config =& $GLOBALS['egw_info']['server'];
150 150
 
151
-			if (!isset(self::$_instance)) self::$_instance = $this;
151
+			if (!isset(self::$_instance))
152
+			{
153
+				self::$_instance = $this;
154
+			}
152 155
 		}
153 156
 		if (is_null($backend))
154 157
 		{
@@ -195,7 +198,11 @@  discard block
 block discarded – undo
195 198
 	function search($param)
196 199
 	{
197 200
 		//error_log(__METHOD__.'('.array2string($param).') '.function_backtrace());
198
-		if (!isset($param['active'])) $param['active'] = true;	// default is true = only return active accounts
201
+		if (!isset($param['active']))
202
+		{
203
+			$param['active'] = true;
204
+		}
205
+		// default is true = only return active accounts
199 206
 
200 207
 		// Check for lang(Group) in search - if there, we search all groups
201 208
 		$group_index = array_search(strtolower(lang('Group')), array_map('strtolower', $query = explode(' ',$param['query'])));
@@ -247,7 +254,10 @@  discard block
 block discarded – undo
247 254
 				foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'],true) as $grp)
248 255
 				{
249 256
 					$members = array_unique(array_merge($members, (array)$this->members($grp,true,$param['active'])));
250
-					if ($param['type'] == 'groupmembers+memberships') $members[] = $grp;
257
+					if ($param['type'] == 'groupmembers+memberships')
258
+					{
259
+						$members[] = $grp;
260
+					}
251 261
 				}
252 262
 				$param['type'] = $param['type'] == 'groupmembers+memberships' ? 'both' : 'accounts';
253 263
 			}
@@ -264,7 +274,10 @@  discard block
 block discarded – undo
264 274
 			if (isset($members))
265 275
 			{
266 276
 				//error_log(__METHOD__.'() members='.array2string($members));
267
-				if (!$members) $members = array();
277
+				if (!$members)
278
+				{
279
+					$members = array();
280
+				}
268 281
 				$valid = !$app ? $members : array_intersect($valid,$members);	// use the intersection
269 282
 			}
270 283
 			//error_log(__METHOD__."() limiting result to app='$app' and/or group=$group valid-ids=".array2string($valid));
@@ -387,7 +400,10 @@  discard block
 block discarded – undo
387 400
 		{
388 401
 			$id = $this->name2id($id);
389 402
 		}
390
-		if (!$id) return false;
403
+		if (!$id)
404
+		{
405
+			return false;
406
+		}
391 407
 
392 408
 		$data = self::cache_read($id);
393 409
 
@@ -455,7 +471,10 @@  discard block
 block discarded – undo
455 471
 		}
456 472
 		$is_group = $GLOBALS['egw']->accounts->get_type($accountid ? $accountid : $lid) == 'g';
457 473
 
458
-		if (empty($firstname)) $firstname = $lid;
474
+		if (empty($firstname))
475
+		{
476
+			$firstname = $lid;
477
+		}
459 478
 		if (empty($lastname) || $is_group)
460 479
 		{
461 480
 			$lastname  = $is_group ? lang('Group') : lang('User');
@@ -534,9 +553,12 @@  discard block
 block discarded – undo
534 553
 			$$name = Translation::to_ascii($$name);
535 554
 		}
536 555
 		//echo " --> ('$first', '$last', '$account')";
537
-		if (!$first && !$last)	// fallback to the account-name, if real names contain only special chars
556
+		if (!$first && !$last)
557
+		{
558
+			// fallback to the account-name, if real names contain only special chars
538 559
 		{
539 560
 			$first = '';
561
+		}
540 562
 			$last = $account;
541 563
 		}
542 564
 		if (!$first || !$last)
@@ -548,8 +570,14 @@  discard block
 block discarded – undo
548 570
 			$dot = '.';
549 571
 			$underscore = '_';
550 572
 		}
551
-		if (!$domain) $domain = $GLOBALS['egw_info']['server']['mail_suffix'];
552
-		if (!$domain) $domain = $_SERVER['SERVER_NAME'];
573
+		if (!$domain)
574
+		{
575
+			$domain = $GLOBALS['egw_info']['server']['mail_suffix'];
576
+		}
577
+		if (!$domain)
578
+		{
579
+			$domain = $_SERVER['SERVER_NAME'];
580
+		}
553 581
 
554 582
 		$email = str_replace(array('first','last','initial','account','dot','underscore','-'),
555 583
 			array($first,$last,substr($first,0,1),$account,$dot,$underscore,''),
@@ -622,7 +650,10 @@  discard block
 block discarded – undo
622 650
 				$old['account_lastname'] != $data['account_lastname'] ||
623 651
 				$old['account_email'] != $data['account_email']))
624 652
 			{
625
-				if (!$data['person_id']) $data['person_id'] = $old['person_id'];
653
+				if (!$data['person_id'])
654
+				{
655
+					$data['person_id'] = $old['person_id'];
656
+				}
626 657
 
627 658
 				$contact = array(
628 659
 					'n_given'    => $data['account_firstname'],
@@ -662,7 +693,10 @@  discard block
 block discarded – undo
662 693
 		{
663 694
 			$id = $this->name2id($id);
664 695
 		}
665
-		if (!$id) return false;
696
+		if (!$id)
697
+		{
698
+			return false;
699
+		}
666 700
 
667 701
 		if ($this->get_type($id) == 'u')
668 702
 		{
@@ -699,7 +733,10 @@  discard block
 block discarded – undo
699 733
 		{
700 734
 			throw new Exception\WrongParameter('Missing parameter to Accounts::is_active()');
701 735
 		}
702
-		if (!is_array($data)) $data = self::getInstance()->read($data);
736
+		if (!is_array($data))
737
+		{
738
+			$data = self::getInstance()->read($data);
739
+		}
703 740
 
704 741
 		$expires = isset($data['account_expires']) ? $data['account_expires'] : $data['expires'];
705 742
 
@@ -714,7 +751,10 @@  discard block
 block discarded – undo
714 751
 	 */
715 752
 	static function is_active($data)
716 753
 	{
717
-		if (!is_array($data)) $data = self::getInstance()->read($data);
754
+		if (!is_array($data))
755
+		{
756
+			$data = self::getInstance()->read($data);
757
+		}
718 758
 
719 759
 		return $data && !(self::is_expired($data) || $data['account_status'] != 'A');
720 760
 	}
@@ -767,7 +807,10 @@  discard block
 block discarded – undo
767 807
 			return false;
768 808
 		}
769 809
 		try {
770
-			if (!($data = self::cache_read($account_id))) return false;
810
+			if (!($data = self::cache_read($account_id)))
811
+			{
812
+				return false;
813
+			}
771 814
 		}
772 815
 		catch (Exception $e) {
773 816
 			unset($e);
@@ -821,14 +864,23 @@  discard block
 block discarded – undo
821 864
 	 */
822 865
 	function visible($account_id)
823 866
 	{
824
-		if (!is_numeric($account_id))	// account_lid given
867
+		if (!is_numeric($account_id))
868
+		{
869
+			// account_lid given
825 870
 		{
826 871
 			$account_lid = $account_id;
827
-			if (!($account_id = $this->name2id($account_lid))) return null;
872
+		}
873
+			if (!($account_id = $this->name2id($account_lid)))
874
+			{
875
+				return null;
876
+			}
828 877
 		}
829 878
 		else
830 879
 		{
831
-			if (!($account_lid = $this->id2name($account_id))) return null;
880
+			if (!($account_lid = $this->id2name($account_id)))
881
+			{
882
+				return null;
883
+			}
832 884
 		}
833 885
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) &&
834 886
 			// do NOT allow other user, if account-selection is none
@@ -882,7 +934,10 @@  discard block
 block discarded – undo
882 934
 		{
883 935
 			$this->backend->set_memberships($groups, $account_id);
884 936
 
885
-			if (!$old_memberships) $old_memberships = array();
937
+			if (!$old_memberships)
938
+			{
939
+				$old_memberships = array();
940
+			}
886 941
 			self::cache_invalidate(array_unique(array_merge(
887 942
 				array($account_id),
888 943
 				array_diff($old_memberships, $groups),
@@ -1028,7 +1083,10 @@  discard block
 block discarded – undo
1028 1083
 		{
1029 1084
 			if (($group_id = $this->name2id($group_lid,'account_lid','g')))
1030 1085
 			{
1031
-				if (!$default_group_id) $default_group_id = $group_id;
1086
+				if (!$default_group_id)
1087
+				{
1088
+					$default_group_id = $group_id;
1089
+				}
1032 1090
 				$memberships[] = $group_id;
1033 1091
 			}
1034 1092
 		}
@@ -1113,7 +1171,10 @@  discard block
 block discarded – undo
1113 1171
 	function change_account_lid_allowed()
1114 1172
 	{
1115 1173
 		$change_account_lid = constant(get_class($this->backend).'::CHANGE_ACCOUNT_LID');
1116
-		if (!isset($change_account_lid)) $change_account_lid = true;
1174
+		if (!isset($change_account_lid))
1175
+		{
1176
+			$change_account_lid = true;
1177
+		}
1117 1178
 		return $change_account_lid;
1118 1179
 	}
1119 1180
 
@@ -1152,12 +1213,19 @@  discard block
 block discarded – undo
1152 1213
 		}
1153 1214
 
1154 1215
 		// session-cache
1155
-		if (self::$cache) self::$cache = array();
1216
+		if (self::$cache)
1217
+		{
1218
+			self::$cache = array();
1219
+		}
1156 1220
 		Cache::unsetSession('accounts_cache','phpgwapi');
1157 1221
 
1158
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1222
+		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
1223
+		{
1224
+			// egw object in setup is limited
1159 1225
 		{
1160
-			Egw::invalidate_session_cache();	// invalidates whole egw-enviroment if stored in the session
1226
+			Egw::invalidate_session_cache();
1227
+		}
1228
+		// invalidates whole egw-enviroment if stored in the session
1161 1229
 		}
1162 1230
 	}
1163 1231
 
@@ -1183,27 +1251,39 @@  discard block
 block discarded – undo
1183 1251
 	 */
1184 1252
 	static function cache_read($account_id, $need_active=false)
1185 1253
 	{
1186
-		if (!is_numeric($account_id)) throw new Exception\WrongParameter('Not an integer!');
1254
+		if (!is_numeric($account_id))
1255
+		{
1256
+			throw new Exception\WrongParameter('Not an integer!');
1257
+		}
1187 1258
 
1188 1259
 		$account =& self::$request_cache[$account_id];
1189 1260
 
1190
-		if (!isset($account))	// not in request cache --> try instance cache
1261
+		if (!isset($account))
1262
+		{
1263
+			// not in request cache --> try instance cache
1191 1264
 		{
1192 1265
 			$instance = self::getInstance();
1266
+		}
1193 1267
 
1194 1268
 			$account = Cache::getCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id);
1195 1269
 
1196
-			if (!isset($account))	// not in instance cache --> read from backend
1270
+			if (!isset($account))
1271
+			{
1272
+				// not in instance cache --> read from backend
1197 1273
 			{
1198 1274
 				if (($account = $instance->backend->read($account_id)))
1199 1275
 				{
1200 1276
 					if ($instance->get_type($account_id) == 'u')
1201 1277
 					{
1202 1278
 						if (!isset($account['memberships'])) $account['memberships'] = $instance->backend->memberships($account_id);
1279
+			}
1203 1280
 					}
1204 1281
 					else
1205 1282
 					{
1206
-						if (!isset($account['members'])) $account['members'] = $instance->backend->members($account_id);
1283
+						if (!isset($account['members']))
1284
+						{
1285
+							$account['members'] = $instance->backend->members($account_id);
1286
+						}
1207 1287
 					}
1208 1288
 					Cache::setCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id, $account, self::READ_CACHE_TIMEOUT);
1209 1289
 				}
@@ -1218,7 +1298,10 @@  discard block
 block discarded – undo
1218 1298
 			$account['members-active'] = array();
1219 1299
 			foreach((array)$account['members'] as $id => $lid)
1220 1300
 			{
1221
-				if ($instance->is_active($id)) $account['members-active'][$id] = $lid;
1301
+				if ($instance->is_active($id))
1302
+				{
1303
+					$account['members-active'][$id] = $lid;
1304
+				}
1222 1305
 			}
1223 1306
 			Cache::setCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id, $account, self::READ_CACHE_TIMEOUT);
1224 1307
 		}
@@ -1242,7 +1325,11 @@  discard block
 block discarded – undo
1242 1325
 	 */
1243 1326
 	private static function setup_cache()
1244 1327
 	{
1245
-		if (is_array(self::$cache)) return;	// cache is already setup
1328
+		if (is_array(self::$cache))
1329
+		{
1330
+			return;
1331
+		}
1332
+		// cache is already setup
1246 1333
 
1247 1334
 		if (self::$use_session_cache && is_object($GLOBALS['egw']->session))
1248 1335
 		{
@@ -1256,7 +1343,8 @@  discard block
 block discarded – undo
1256 1343
 		}
1257 1344
 	}
1258 1345
 
1259
-	public function __destruct() {
1346
+	public function __destruct()
1347
+	{
1260 1348
 		if (self::$_instance === $this)
1261 1349
 		{
1262 1350
 			self::$_instance = NULL;
Please login to merge, or discard this patch.
Spacing   +102 added lines, -104 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @var array
57 57
 	 */
58
-	var $depricated_names = array('firstname','lastname','fullname','email','type',
59
-		'status','expires','lastlogin','lastloginfrom','lastpasswd_change');
58
+	var $depricated_names = array('firstname', 'lastname', 'fullname', 'email', 'type',
59
+		'status', 'expires', 'lastlogin', 'lastloginfrom', 'lastpasswd_change');
60 60
 
61 61
 	/**
62 62
 	 * List of all config vars accounts depend on and therefore should be passed in when calling contructor with array syntax
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 * @var array
65 65
 	 */
66 66
 	static public $config_vars = array(
67
-		'account_repository', 'auth_type',	// auth_type if fallback if account_repository is not set
68
-		'install_id',	// instance-specific caching
69
-		'auto_create_expire', 'default_group_lid',	// auto-creation of accounts
70
-		'ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter',	// ldap backend
71
-		'ads_domain', 'ads_host', 'ads_admin_user', 'ads_admin_passwd', 'ads_connection', 'ads_context',	// ads backend
67
+		'account_repository', 'auth_type', // auth_type if fallback if account_repository is not set
68
+		'install_id', // instance-specific caching
69
+		'auto_create_expire', 'default_group_lid', // auto-creation of accounts
70
+		'ldap_host', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_group_context', 'ldap_search_filter', // ldap backend
71
+		'ads_domain', 'ads_host', 'ads_admin_user', 'ads_admin_passwd', 'ads_connection', 'ads_context', // ads backend
72 72
 	);
73 73
 
74 74
 	/**
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param string|array $backend =null string with backend 'sql'|'ldap', or whole config array, default read from global egw_info
135 135
 	 */
136
-	public function __construct($backend=null)
136
+	public function __construct($backend = null)
137 137
 	{
138 138
 		if (is_array($backend))
139 139
 		{
140 140
 			$this->config = $backend;
141 141
 			$backend = null;
142
-			self::$_instance = $this;	// also set instance returned by singleton
143
-			self::$cache = array();		// and empty our internal (session) cache
142
+			self::$_instance = $this; // also set instance returned by singleton
143
+			self::$cache = array(); // and empty our internal (session) cache
144 144
 		}
145 145
 		else
146 146
 		{
147
-			$this->config =& $GLOBALS['egw_info']['server'];
147
+			$this->config = & $GLOBALS['egw_info']['server'];
148 148
 
149 149
 			if (!isset(self::$_instance)) self::$_instance = $this;
150 150
 		}
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
 	function search($param)
194 194
 	{
195 195
 		//error_log(__METHOD__.'('.array2string($param).') '.function_backtrace());
196
-		if (!isset($param['active'])) $param['active'] = true;	// default is true = only return active accounts
196
+		if (!isset($param['active'])) $param['active'] = true; // default is true = only return active accounts
197 197
 
198 198
 		// Check for lang(Group) in search - if there, we search all groups
199
-		$group_index = array_search(strtolower(lang('Group')), array_map('strtolower', $query = explode(' ',$param['query'])));
200
-		if($group_index !== FALSE && !(
199
+		$group_index = array_search(strtolower(lang('Group')), array_map('strtolower', $query = explode(' ', $param['query'])));
200
+		if ($group_index !== FALSE && !(
201 201
 				in_array($param['type'], array('accounts', 'groupmembers')) || is_int($param['type'])
202 202
 		))
203 203
 		{
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 		}
226 226
 		// no backend understands $param['app'], only sql understands type owngroups or groupmemember[+memberships]
227 227
 		// --> do an full search first and then filter and limit that search
228
-		elseif($param['app'] || $this->config['account_repository'] != 'sql' &&
229
-			in_array($param['type'], array('owngroups','groupmembers','groupmembers+memberships')))
228
+		elseif ($param['app'] || $this->config['account_repository'] != 'sql' &&
229
+			in_array($param['type'], array('owngroups', 'groupmembers', 'groupmembers+memberships')))
230 230
 		{
231 231
 			$app = $param['app'];
232 232
 			unset($param['app']);
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 
239 239
 			if ($param['type'] == 'owngroups')
240 240
 			{
241
-				$members = $this->memberships($GLOBALS['egw_info']['user']['account_id'],true);
241
+				$members = $this->memberships($GLOBALS['egw_info']['user']['account_id'], true);
242 242
 				$param['type'] = 'groups';
243 243
 			}
244
-			elseif(in_array($param['type'],array('groupmembers','groupmembers+memberships')))
244
+			elseif (in_array($param['type'], array('groupmembers', 'groupmembers+memberships')))
245 245
 			{
246 246
 				$members = array();
247
-				foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'],true) as $grp)
247
+				foreach ((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp)
248 248
 				{
249
-					$members = array_unique(array_merge($members, (array)$this->members($grp,true,$param['active'])));
249
+					$members = array_unique(array_merge($members, (array)$this->members($grp, true, $param['active'])));
250 250
 					if ($param['type'] == 'groupmembers+memberships') $members[] = $grp;
251 251
 				}
252 252
 				$param['type'] = $param['type'] == 'groupmembers+memberships' ? 'both' : 'accounts';
@@ -259,20 +259,20 @@  discard block
 block discarded – undo
259 259
 			if ($app)
260 260
 			{
261 261
 				// we want the result merged, whatever it takes, as we only care for the ids
262
-				$valid = $this->split_accounts($app,!in_array($param['type'],array('accounts','groups')) ? 'merge' : $param['type'],$param['active']);
262
+				$valid = $this->split_accounts($app, !in_array($param['type'], array('accounts', 'groups')) ? 'merge' : $param['type'], $param['active']);
263 263
 			}
264 264
 			if (isset($members))
265 265
 			{
266 266
 				//error_log(__METHOD__.'() members='.array2string($members));
267 267
 				if (!$members) $members = array();
268
-				$valid = !$app ? $members : array_intersect($valid,$members);	// use the intersection
268
+				$valid = !$app ? $members : array_intersect($valid, $members); // use the intersection
269 269
 			}
270 270
 			//error_log(__METHOD__."() limiting result to app='$app' and/or group=$group valid-ids=".array2string($valid));
271 271
 			$n = 0;
272 272
 			$account_search[$serial]['data'] = array();
273 273
 			foreach ($full_search as $id => $data)
274 274
 			{
275
-				if (!in_array($id,$valid))
275
+				if (!in_array($id, $valid))
276 276
 				{
277 277
 					$this->total--;
278 278
 					continue;
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			$account_search[$serial]['data'] = $this->backend->search($param);
293 293
 			if ($param['type'] !== 'accounts')
294 294
 			{
295
-				foreach($account_search[$serial]['data'] as &$account)
295
+				foreach ($account_search[$serial]['data'] as &$account)
296 296
 				{
297 297
 					// add default description for Admins and Default group
298 298
 					if ($account['account_type'] === 'g')
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		{
322 322
 			$options['filter'] = (array)$options['filter'];
323 323
 		}
324
-		switch($GLOBALS['egw_info']['user']['preferences']['common']['account_display'])
324
+		switch ($GLOBALS['egw_info']['user']['preferences']['common']['account_display'])
325 325
 		{
326 326
 			case 'firstname':
327 327
 			case 'firstall':
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 		$only_own = $GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] === 'groupmembers' &&
339 339
 			!isset($GLOBALS['egw_info']['user']['apps']['admin']);
340
-		switch($options['account_type'])
340
+		switch ($options['account_type'])
341 341
 		{
342 342
 			case 'accounts':
343 343
 				$type = $only_own ? 'groupmembers' : 'accounts';
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 				break;
359 359
 		}
360 360
 		$accounts = array();
361
-		foreach(self::getInstance()->search(array(
361
+		foreach (self::getInstance()->search(array(
362 362
 			'type' => $options['filter']['group'] < 0 ? $options['filter']['group'] : $type,
363 363
 			'query' => $pattern,
364 364
 			'query_type' => 'all',
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 		)) as $account)
367 367
 		{
368 368
 			$accounts[$account['account_id']] = self::format_username($account['account_lid'],
369
-				$account['account_firstname'],$account['account_lastname'],$account['account_id']);
369
+				$account['account_firstname'], $account['account_lastname'], $account['account_id']);
370 370
 		}
371 371
 		return $accounts;
372 372
 	}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 * @param boolean $set_depricated_names =false set _additionaly_ the depricated keys without 'account_' prefix
382 382
 	 * @return array/boolean array with account data (keys: account_id, account_lid, ...) or false if account not found
383 383
 	 */
384
-	function read($id, $set_depricated_names=false)
384
+	function read($id, $set_depricated_names = false)
385 385
 	{
386 386
 		if (!is_int($id) && !is_numeric($id))
387 387
 		{
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 
400 400
 		if ($set_depricated_names && $data)
401 401
 		{
402
-			foreach($this->depricated_names as $name)
402
+			foreach ($this->depricated_names as $name)
403 403
 			{
404
-				$data[$name] =& $data['account_'.$name];
404
+				$data[$name] = & $data['account_'.$name];
405 405
 			}
406 406
 		}
407 407
 		return $data;
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	function json($id)
419 419
 	{
420 420
 		static $keys = array(
421
-			'account_id','account_lid','person_id','account_status',
422
-			'account_firstname','account_lastname','account_email','account_fullname','account_phone',
421
+			'account_id', 'account_lid', 'person_id', 'account_status',
422
+			'account_firstname', 'account_lastname', 'account_email', 'account_fullname', 'account_phone',
423 423
 		);
424 424
 		if (($account = $this->read($id)))
425 425
 		{
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
 		// for current user, add the apps available to him
429 429
 		if ($id == $GLOBALS['egw_info']['user']['account_id'])
430 430
 		{
431
-			foreach((array)$GLOBALS['egw_info']['user']['apps'] as $app => $data)
431
+			foreach ((array)$GLOBALS['egw_info']['user']['apps'] as $app => $data)
432 432
 			{
433
-				unset($data['table_defs']);	// no need for that on the client
433
+				unset($data['table_defs']); // no need for that on the client
434 434
 				$account['apps'][$app] = $data;
435 435
 			}
436 436
 		}
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @param $lastname ='' lastname
446 446
 	 * @param $accountid =0 id, to check if it's a user or group, otherwise the lid will be used
447 447
 	 */
448
-	static function format_username($lid = '', $firstname = '', $lastname = '', $accountid=0)
448
+	static function format_username($lid = '', $firstname = '', $lastname = '', $accountid = 0)
449 449
 	{
450 450
 		if (!$lid && !$firstname && !$lastname)
451 451
 		{
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		if (empty($firstname)) $firstname = $lid;
459 459
 		if (empty($lastname) || $is_group)
460 460
 		{
461
-			$lastname  = $is_group ? lang('Group') : lang('User');
461
+			$lastname = $is_group ? lang('Group') : lang('User');
462 462
 		}
463 463
 		$display = $GLOBALS['egw_info']['user']['preferences']['common']['account_display'];
464 464
 
@@ -472,30 +472,30 @@  discard block
 block discarded – undo
472 472
 		}
473 473
 
474 474
 		$name = '';
475
-		switch($display)
475
+		switch ($display)
476 476
 		{
477 477
 			case 'firstname':
478
-				$name = $firstname . ' ' . $lastname;
478
+				$name = $firstname.' '.$lastname;
479 479
 				break;
480 480
 			case 'lastname':
481
-				$name = $lastname . $delimiter . $firstname;
481
+				$name = $lastname.$delimiter.$firstname;
482 482
 				break;
483 483
 			case 'username':
484 484
 				$name = $lid;
485 485
 				break;
486 486
 			case 'firstall':
487
-				$name = $firstname . ' ' . $lastname . ' ['.$lid.']';
487
+				$name = $firstname.' '.$lastname.' ['.$lid.']';
488 488
 				break;
489 489
 			case 'lastall':
490
-				$name = $lastname . $delimiter . $firstname . ' ['.$lid.']';
490
+				$name = $lastname.$delimiter.$firstname.' ['.$lid.']';
491 491
 				break;
492 492
 			case 'allfirst':
493
-				$name = '['.$lid.'] ' . $firstname . ' ' . $lastname;
493
+				$name = '['.$lid.'] '.$firstname.' '.$lastname;
494 494
 				break;
495 495
 			case 'all':
496 496
 				/* fall through */
497 497
 			default:
498
-				$name = '['.$lid.'] ' . $lastname . $delimiter . $firstname;
498
+				$name = '['.$lid.'] '.$lastname.$delimiter.$firstname;
499 499
 		}
500 500
 		return $name;
501 501
 	}
@@ -506,14 +506,14 @@  discard block
 block discarded – undo
506 506
 	 * @param string $account_id =null account id
507 507
 	 * @return string full name of user or "#$accountid" if user not found
508 508
 	 */
509
-	static function username($account_id=null)
509
+	static function username($account_id = null)
510 510
 	{
511 511
 		if ($account_id && !($account = self::cache_read((int)$account_id)))
512 512
 		{
513 513
 			return '#'.$account_id;
514 514
 		}
515 515
 		return self::format_username($account['account_lid'],
516
-			$account['account_firstname'] , $account['account_lastname'], $account_id);
516
+			$account['account_firstname'], $account['account_lastname'], $account_id);
517 517
 	}
518 518
 
519 519
 	/**
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 	 * @param string $domain =null domain-name or null to use eGW's default domain $GLOBALS['egw_info']['server']['mail_suffix]
528 528
 	 * @return string with email address
529 529
 	 */
530
-	static function email($first,$last,$account,$domain=null)
530
+	static function email($first, $last, $account, $domain = null)
531 531
 	{
532 532
 		if ($GLOBALS['egw_info']['server']['email_address_format'] === 'none')
533 533
 		{
534 534
 			return null;
535 535
 		}
536
-		foreach (array('first','last','account') as $name)
536
+		foreach (array('first', 'last', 'account') as $name)
537 537
 		{
538 538
 			$$name = Translation::to_ascii($$name);
539 539
 		}
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 		if (!$domain) $domain = $GLOBALS['egw_info']['server']['mail_suffix'];
556 556
 		if (!$domain) $domain = $_SERVER['SERVER_NAME'];
557 557
 
558
-		$email = str_replace(array('first','last','initial','account','dot','underscore','-'),
559
-			array($first,$last,substr($first,0,1),$account,$dot,$underscore,''),
558
+		$email = str_replace(array('first', 'last', 'initial', 'account', 'dot', 'underscore', '-'),
559
+			array($first, $last, substr($first, 0, 1), $account, $dot, $underscore, ''),
560 560
 			$GLOBALS['egw_info']['server']['email_address_format'] ? $GLOBALS['egw_info']['server']['email_address_format'] : 'first-dot-last').
561 561
 			($domain ? '@'.$domain : '');
562 562
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	{
578 578
 		if (empty($data['account_description']))
579 579
 		{
580
-			switch($data['account_lid'])
580
+			switch ($data['account_lid'])
581 581
 			{
582 582
 				case 'Default':
583 583
 					$data['account_description'] = lang('EGroupware all users group, do NOT delete');
@@ -605,15 +605,15 @@  discard block
 block discarded – undo
605 605
 	 * @param boolean $check_depricated_names =false check _additionaly_ the depricated keys without 'account_' prefix
606 606
 	 * @return int|boolean the account_id or false on error
607 607
 	 */
608
-	function save(&$data,$check_depricated_names=false)
608
+	function save(&$data, $check_depricated_names = false)
609 609
 	{
610 610
 		if ($check_depricated_names)
611 611
 		{
612
-			foreach($this->depricated_names as $name)
612
+			foreach ($this->depricated_names as $name)
613 613
 			{
614 614
 				if (isset($data[$name]) && !isset($data['account_'.$name]))
615 615
 				{
616
-					$data['account_'.$name] =& $data[$name];
616
+					$data['account_'.$name] = & $data[$name];
617 617
 				}
618 618
 			}
619 619
 		}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		{
627 627
 			// if we are not on a pure LDAP system, we have to write the account-date via the contacts class now
628 628
 			if (($this->config['account_repository'] == 'sql' || $this->config['contact_repository'] == 'sql-ldap') &&
629
-				(!($old = $this->read($data['account_id'])) ||	// only for new account or changed contact-data
629
+				(!($old = $this->read($data['account_id'])) || // only for new account or changed contact-data
630 630
 				$old['account_firstname'] != $data['account_firstname'] ||
631 631
 				$old['account_lastname'] != $data['account_lastname'] ||
632 632
 				$old['account_email'] != $data['account_email']))
@@ -641,14 +641,14 @@  discard block
 block discarded – undo
641 641
 					'id'         => $data['person_id'],
642 642
 					'owner'      => 0,
643 643
 				);
644
-				$GLOBALS['egw']->contacts->save($contact,true);		// true = ignore addressbook acl
644
+				$GLOBALS['egw']->contacts->save($contact, true); // true = ignore addressbook acl
645 645
 			}
646 646
 			// save primary group if necessary
647
-			if ($data['account_primary_group'] && (!($memberships = $this->memberships($id,true)) ||
648
-				!in_array($data['account_primary_group'],$memberships)))
647
+			if ($data['account_primary_group'] && (!($memberships = $this->memberships($id, true)) ||
648
+				!in_array($data['account_primary_group'], $memberships)))
649 649
 			{
650 650
 				$memberships[] = $data['account_primary_group'];
651
-				$this->set_memberships($memberships, $id);	// invalidates cache for account_id and primary group
651
+				$this->set_memberships($memberships, $id); // invalidates cache for account_id and primary group
652 652
 			}
653 653
 		}
654 654
 		// as some backends set (group-)members in save, we need to invalidate their members too!
@@ -740,10 +740,10 @@  discard block
 block discarded – undo
740 740
 	 * @param string $account_type =null u = user or g = group, or default null = try both
741 741
 	 * @return int|false numeric account_id or false on error ($name not found)
742 742
 	 */
743
-	function name2id($name,$which='account_lid',$account_type=null)
743
+	function name2id($name, $which = 'account_lid', $account_type = null)
744 744
 	{
745 745
 		// Don't bother searching for empty or non-scalar account_lid
746
-		if(empty($name) || !is_scalar($name))
746
+		if (empty($name) || !is_scalar($name))
747 747
 		{
748 748
 			return False;
749 749
 		}
@@ -751,12 +751,12 @@  discard block
 block discarded – undo
751 751
 		self::setup_cache();
752 752
 		$name_list = &self::$cache['name_list'];
753 753
 
754
-		if(@isset($name_list[$which][$name]) && $name_list[$which][$name])
754
+		if (@isset($name_list[$which][$name]) && $name_list[$which][$name])
755 755
 		{
756 756
 			return $name_list[$which][$name];
757 757
 		}
758 758
 
759
-		return $name_list[$which][$name] = $this->backend->name2id($name,$which,$account_type);
759
+		return $name_list[$which][$name] = $this->backend->name2id($name, $which, $account_type);
760 760
 	}
761 761
 
762 762
 	/**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 * @param boolean $generate_email =false true: generate an email address, if user has none
770 770
 	 * @return string|boolean converted value or false on error ($account_id not found)
771 771
 	 */
772
-	static function id2name($account_id, $which='account_lid', $generate_email=false)
772
+	static function id2name($account_id, $which = 'account_lid', $generate_email = false)
773 773
 	{
774 774
 		if (!is_numeric($account_id) && !($account_id = self::getInstance()->name2id($account_id)))
775 775
 		{
@@ -819,8 +819,7 @@  discard block
 block discarded – undo
819 819
 			if (is_a($this->backend, __CLASS__.'\\Univention'))
820 820
 			{
821 821
 				if (!is_numeric($account_id) ?
822
-					($account_id = $this->backend->name2id($account_id)) :
823
-					$this->backend->id2name($account_id))
822
+					($account_id = $this->backend->name2id($account_id)) : $this->backend->id2name($account_id))
824 823
 				{
825 824
 					return $account_id > 0 ? 1 : 2;
826 825
 				}
@@ -855,13 +854,13 @@  discard block
 block discarded – undo
855 854
 				$account_lid != $GLOBALS['egw_info']['user']['account_lid'] ||
856 855
 			// only allow group-members for account-selection is groupmembers
857 856
 			$GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'groupmembers' &&
858
-				!array_intersect((array)$this->memberships($account_id,true),
859
-					(array)$this->memberships($GLOBALS['egw_info']['user']['account_id'],true))))
857
+				!array_intersect((array)$this->memberships($account_id, true),
858
+					(array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true))))
860 859
 		{
861 860
 			//error_log(__METHOD__."($account_id='$account_lid') returning FALSE");
862
-			return false;	// user is not allowed to see given account
861
+			return false; // user is not allowed to see given account
863 862
 		}
864
-		return true;	// user allowed to see given account
863
+		return true; // user allowed to see given account
865 864
 	}
866 865
 
867 866
 	/**
@@ -871,11 +870,11 @@  discard block
 block discarded – undo
871 870
 	 * @param boolean $just_id =false return just account_id's or account_id => account_lid pairs
872 871
 	 * @return array with account_id's ($just_id) or account_id => account_lid pairs (!$just_id)
873 872
 	 */
874
-	function memberships($account_id, $just_id=false)
873
+	function memberships($account_id, $just_id = false)
875 874
 	{
876 875
 		if (!is_int($account_id) && !is_numeric($account_id))
877 876
 		{
878
-			$account_id = $this->name2id($account_id,'account_lid','u');
877
+			$account_id = $this->name2id($account_id, 'account_lid', 'u');
879 878
 		}
880 879
 		if ($account_id && ($data = self::cache_read($account_id)))
881 880
 		{
@@ -891,7 +890,7 @@  discard block
 block discarded – undo
891 890
 	 * @param array $groups array with gidnumbers
892 891
 	 * @param int $account_id uidnumber
893 892
 	 */
894
-	function set_memberships($groups,$account_id)
893
+	function set_memberships($groups, $account_id)
895 894
 	{
896 895
 		if (!is_int($account_id) && !is_numeric($account_id))
897 896
 		{
@@ -919,7 +918,7 @@  discard block
 block discarded – undo
919 918
 	 * @param boolean $active =false true: return only active (not expired or deactived) members, false: return all accounts
920 919
 	 * @return array with account_id ($just_id) or account_id => account_lid pairs (!$just_id)
921 920
 	 */
922
-	function members($account_id, $just_id=false, $active=true)
921
+	function members($account_id, $just_id = false, $active = true)
923 922
 	{
924 923
 		if (!is_int($account_id) && !is_numeric($account_id))
925 924
 		{
@@ -940,7 +939,7 @@  discard block
 block discarded – undo
940 939
 	 * @param array $members array with uidnumber or uid's
941 940
 	 * @param int $gid gidnumber of group to set
942 941
 	 */
943
-	function set_members($members,$gid)
942
+	function set_members($members, $gid)
944 943
 	{
945 944
 		if (($old_members = $this->members($gid, true, false)) != $members)
946 945
 		{
@@ -964,7 +963,7 @@  discard block
 block discarded – undo
964 963
 	 * @param boolean $active =false true: return only active (not expired or deactived) members, false: return all accounts
965 964
 	 * @return array/boolean see $use, false on error (wront $use)
966 965
 	 */
967
-	function split_accounts($app_users,$use='both',$active=true)
966
+	function split_accounts($app_users, $use = 'both', $active = true)
968 967
 	{
969 968
 		if (!is_array($app_users))
970 969
 		{
@@ -975,21 +974,21 @@  discard block
 block discarded – undo
975 974
 			{
976 975
 				return $cache;
977 976
 			}
978
-			$app_users = $GLOBALS['egw']->acl->get_ids_for_location('run',1,$app_users);
977
+			$app_users = $GLOBALS['egw']->acl->get_ids_for_location('run', 1, $app_users);
979 978
 		}
980 979
 		$accounts = array(
981 980
 			'accounts' => array(),
982 981
 			'groups' => array(),
983 982
 		);
984
-		foreach($app_users as $id)
983
+		foreach ($app_users as $id)
985 984
 		{
986 985
 			$type = $this->get_type($id);
987
-			if($type == 'g')
986
+			if ($type == 'g')
988 987
 			{
989 988
 				$accounts['groups'][$id] = $id;
990 989
 				if ($use != 'groups')
991 990
 				{
992
-					foreach((array)$this->members($id, true, $active) as $id)
991
+					foreach ((array)$this->members($id, true, $active) as $id)
993 992
 					{
994 993
 						$accounts['accounts'][$id] = $id;
995 994
 					}
@@ -1010,7 +1009,7 @@  discard block
 block discarded – undo
1010 1009
 			$cache = $accounts;
1011 1010
 		}
1012 1011
 
1013
-		switch($use)
1012
+		switch ($use)
1014 1013
 		{
1015 1014
 			case 'both':
1016 1015
 				return $accounts;
@@ -1019,7 +1018,7 @@  discard block
 block discarded – undo
1019 1018
 			case 'accounts':
1020 1019
 				return $accounts['accounts'];
1021 1020
 			case 'merge':
1022
-				return array_merge($accounts['accounts'],$accounts['groups']);
1021
+				return array_merge($accounts['accounts'], $accounts['groups']);
1023 1022
 		}
1024 1023
 		return False;
1025 1024
 	}
@@ -1037,21 +1036,20 @@  discard block
 block discarded – undo
1037 1036
 	function auto_add($account_lid, $passwd)
1038 1037
 	{
1039 1038
 		$expires = !isset($this->config['auto_create_expire']) ||
1040
-			$this->config['auto_create_expire'] == 'never' ? -1 :
1041
-			time() + $this->config['auto_create_expire'] + 2;
1039
+			$this->config['auto_create_expire'] == 'never' ? -1 : time() + $this->config['auto_create_expire'] + 2;
1042 1040
 
1043 1041
 		$memberships = array();
1044 1042
 		$default_group_id = null;
1045 1043
 		// check if we have a comma or semicolon delimited list of groups --> add first as primary and rest as memberships
1046
-		foreach(preg_split('/[,;] */',$this->config['default_group_lid']) as $group_lid)
1044
+		foreach (preg_split('/[,;] */', $this->config['default_group_lid']) as $group_lid)
1047 1045
 		{
1048
-			if (($group_id = $this->name2id($group_lid,'account_lid','g')))
1046
+			if (($group_id = $this->name2id($group_lid, 'account_lid', 'g')))
1049 1047
 			{
1050 1048
 				if (!$default_group_id) $default_group_id = $group_id;
1051 1049
 				$memberships[] = $group_id;
1052 1050
 			}
1053 1051
 		}
1054
-		if (!$default_group_id && ($default_group_id = $this->name2id('Default','account_lid','g')))
1052
+		if (!$default_group_id && ($default_group_id = $this->name2id('Default', 'account_lid', 'g')))
1055 1053
 		{
1056 1054
 			$memberships[] = $default_group_id;
1057 1055
 		}
@@ -1088,25 +1086,25 @@  discard block
 block discarded – undo
1088 1086
 		// set memberships if given
1089 1087
 		if ($memberships)
1090 1088
 		{
1091
-			$this->set_memberships($memberships,$data['account_id']);
1089
+			$this->set_memberships($memberships, $data['account_id']);
1092 1090
 		}
1093 1091
 		// set the appropriate value for the can change password flag (assume users can, if the admin requires users to change their password)
1094 1092
 		$data['changepassword'] = (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days'];
1095
-		if(!$data['changepassword'])
1093
+		if (!$data['changepassword'])
1096 1094
 		{
1097
-			$GLOBALS['egw']->acl->add_repository('preferences','nopasswordchange',$data['account_id'],1);
1095
+			$GLOBALS['egw']->acl->add_repository('preferences', 'nopasswordchange', $data['account_id'], 1);
1098 1096
 		}
1099 1097
 		else
1100 1098
 		{
1101
-			$GLOBALS['egw']->acl->delete_repository('preferences','nopasswordchange',$data['account_id']);
1099
+			$GLOBALS['egw']->acl->delete_repository('preferences', 'nopasswordchange', $data['account_id']);
1102 1100
 		}
1103 1101
 		// call hook to notify interested apps about the new account
1104 1102
 		$GLOBALS['hook_values'] = $data;
1105
-		Hooks::process($data+array(
1103
+		Hooks::process($data + array(
1106 1104
 			'location' => 'addaccount',
1107 1105
 			// at login-time only the hooks from the following apps will be called
1108
-			'order' => array('felamimail','fudforum'),
1109
-		),False,True);  // called for every app now, not only enabled ones
1106
+			'order' => array('felamimail', 'fudforum'),
1107
+		), False, True); // called for every app now, not only enabled ones
1110 1108
 		unset($data['changepassword']);
1111 1109
 
1112 1110
 		return $data['account_id'];
@@ -1153,7 +1151,7 @@  discard block
 block discarded – undo
1153 1151
 	 *
1154 1152
 	 * @param int|array $account_ids user- or group-id(s) for which cache should be invalidated, default 0 = only search/name2id cache
1155 1153
 	 */
1156
-	static function cache_invalidate($account_ids=0)
1154
+	static function cache_invalidate($account_ids = 0)
1157 1155
 	{
1158 1156
 		//error_log(__METHOD__.'('.array2string($account_ids).')');
1159 1157
 
@@ -1162,7 +1160,7 @@  discard block
 block discarded – undo
1162 1160
 		{
1163 1161
 			$instance = self::getInstance();
1164 1162
 
1165
-			foreach((array)$account_ids as $account_id)
1163
+			foreach ((array)$account_ids as $account_id)
1166 1164
 			{
1167 1165
 				Cache::unsetCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id);
1168 1166
 
@@ -1176,11 +1174,11 @@  discard block
 block discarded – undo
1176 1174
 
1177 1175
 		// session-cache
1178 1176
 		if (self::$cache) self::$cache = array();
1179
-		Cache::unsetSession('accounts_cache','phpgwapi');
1177
+		Cache::unsetSession('accounts_cache', 'phpgwapi');
1180 1178
 
1181
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1179
+		if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
1182 1180
 		{
1183
-			Egw::invalidate_session_cache();	// invalidates whole egw-enviroment if stored in the session
1181
+			Egw::invalidate_session_cache(); // invalidates whole egw-enviroment if stored in the session
1184 1182
 		}
1185 1183
 	}
1186 1184
 
@@ -1204,11 +1202,11 @@  discard block
 block discarded – undo
1204 1202
 	 * @return array
1205 1203
 	 * @throws Exception\WrongParameter if no integer was passed as $account_id
1206 1204
 	 */
1207
-	static function cache_read($account_id, $need_active=false)
1205
+	static function cache_read($account_id, $need_active = false)
1208 1206
 	{
1209 1207
 		if (!is_numeric($account_id)) throw new Exception\WrongParameter('Not an integer!');
1210 1208
 
1211
-		$account =& self::$request_cache[$account_id];
1209
+		$account = & self::$request_cache[$account_id];
1212 1210
 
1213 1211
 		if (!isset($account))	// not in request cache --> try instance cache
1214 1212
 		{
@@ -1239,7 +1237,7 @@  discard block
 block discarded – undo
1239 1237
 		{
1240 1238
 			$instance = self::getInstance();
1241 1239
 			$account['members-active'] = array();
1242
-			foreach((array)$account['members'] as $id => $lid)
1240
+			foreach ((array)$account['members'] as $id => $lid)
1243 1241
 			{
1244 1242
 				if ($instance->is_active($id)) $account['members-active'][$id] = $lid;
1245 1243
 			}
@@ -1265,11 +1263,11 @@  discard block
 block discarded – undo
1265 1263
 	 */
1266 1264
 	private static function setup_cache()
1267 1265
 	{
1268
-		if (is_array(self::$cache)) return;	// cache is already setup
1266
+		if (is_array(self::$cache)) return; // cache is already setup
1269 1267
 
1270 1268
 		if (self::$use_session_cache && is_object($GLOBALS['egw']->session))
1271 1269
 		{
1272
-			self::$cache =& Cache::getSession('accounts_cache','phpgwapi');
1270
+			self::$cache = & Cache::getSession('accounts_cache', 'phpgwapi');
1273 1271
 		}
1274 1272
 		//error_log(__METHOD__."() use_session_cache=".array2string(self::$use_session_cache).", is_array(self::\$cache)=".array2string(is_array(self::$cache)));
1275 1273
 
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_collab_bo.inc.php 3 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -448,7 +448,6 @@  discard block
 block discarded – undo
448 448
 	/**
449 449
 	 * Function to get member record of specific member id
450 450
 	 *
451
-	 * @param string $member_id member id
452 451
 	 *
453 452
 	 * @return string member id or null
454 453
 	 * @throws Exception throws exception if no member id is given
@@ -470,7 +469,6 @@  discard block
 block discarded – undo
470 469
 	/**
471 470
 	 * Function to get member record of specific member id
472 471
 	 *
473
-	 * @param string $member_id member id
474 472
 	 *
475 473
 	 * @return string member id or null
476 474
 	 * @throws Exception throws exception if no member id is given
@@ -517,7 +515,7 @@  discard block
 block discarded – undo
517 515
 	 * Utility function to map DB fields to ids
518 516
 	 *
519 517
 	 * @param array $data
520
-	 * @return array|boolean returns an array contains of mapped DB data, otherwise false
518
+	 * @return string returns an array contains of mapped DB data, otherwise false
521 519
 	 */
522 520
 	protected static function db2id($data)
523 521
 	{
Please login to merge, or discard this patch.
Braces   +47 added lines, -12 removed lines patch added patch discarded remove patch
@@ -122,7 +122,10 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function SESSION_cleanup ($es_id)
124 124
 	{
125
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
125
+		if (!$es_id)
126
+		{
127
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
128
+		}
126 129
 
127 130
 		$this->db->delete(
128 131
 				self::OP_TABLE,
@@ -154,7 +157,10 @@  discard block
 block discarded – undo
154 157
 	 */
155 158
 	public function SESSION_Save ($es_id)
156 159
 	{
157
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
160
+		if (!$es_id)
161
+		{
162
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
163
+		}
158 164
 		$query = $this->db->update(
159 165
 				self::SESSION_TABLE,
160 166
 				array('collab_last_save' => self::getTimeStamp()),
@@ -186,7 +192,10 @@  discard block
 block discarded – undo
186 192
 	 */
187 193
 	public function SESSION_Get($es_id)
188 194
 	{
189
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
195
+		if (!$es_id)
196
+		{
197
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
198
+		}
190 199
 		$query = $this->db->select(
191 200
 				self::SESSION_TABLE,
192 201
 				'*',
@@ -299,7 +308,10 @@  discard block
 block discarded – undo
299 308
 	 */
300 309
 	protected function OP_getHeadSeq($es_id)
301 310
 	{
302
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
311
+		if (!$es_id)
312
+		{
313
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
314
+		}
303 315
 
304 316
 		$query = $this->db->select(
305 317
 				self::OP_TABLE,
@@ -357,7 +369,10 @@  discard block
 block discarded – undo
357 369
 	 */
358 370
 	protected function OP_addOPS ($es_id, $member_id, $client_ops)
359 371
 	{
360
-		if (count($client_ops)<= 0) throw new Exception (self::EXCEPTION_MESSAGE_NO_OPS);
372
+		if (count($client_ops)<= 0)
373
+		{
374
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_OPS);
375
+		}
361 376
 
362 377
 		foreach ($client_ops as $op)
363 378
 		{
@@ -411,7 +426,10 @@  discard block
 block discarded – undo
411 426
 	 */
412 427
 	protected function MEMBER_UpdateActiveMember ($es_id, $member_id, $is_active = 0)
413 428
 	{
414
-		if (!$es_id || !$member_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
429
+		if (!$es_id || !$member_id)
430
+		{
431
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
432
+		}
415 433
 		$this->db->update(
416 434
 				self::MEMBER_TABLE,
417 435
 				array('collab_is_active' => $is_active),
@@ -432,7 +450,10 @@  discard block
 block discarded – undo
432 450
 	 */
433 451
 	protected function MEMBER_getActiveMembers ($es_id)
434 452
 	{
435
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
453
+		if (!$es_id)
454
+		{
455
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
456
+		}
436 457
 		$query = $this->db->select(
437 458
 				self::MEMBER_TABLE,
438 459
 				'*',
@@ -455,7 +476,10 @@  discard block
 block discarded – undo
455 476
 	 */
456 477
 	protected function MEMBER_getUserMemberId ($es_id, $user_id)
457 478
 	{
458
-		if (!$es_id || !$user_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
479
+		if (!$es_id || !$user_id)
480
+		{
481
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
482
+		}
459 483
 		$query = $this->db->select(
460 484
 				self::MEMBER_TABLE,
461 485
 				'collab_member_id',
@@ -477,7 +501,10 @@  discard block
 block discarded – undo
477 501
 	 */
478 502
 	protected function MEMBER_getUserLastMemberId ($es_id, $user_id)
479 503
 	{
480
-		if (!$es_id || !$user_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
504
+		if (!$es_id || !$user_id)
505
+		{
506
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
507
+		}
481 508
 		$query = $this->db->select(
482 509
 				self::MEMBER_TABLE,
483 510
 				'collab_member_id',
@@ -501,7 +528,10 @@  discard block
 block discarded – undo
501 528
 	 */
502 529
 	protected function MEMBER_getMember ($es_id, $member_id)
503 530
 	{
504
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
531
+		if (!$es_id)
532
+		{
533
+			throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
534
+		}
505 535
 		$query = $this->db->select(
506 536
 				self::MEMBER_TABLE,
507 537
 				'*',
@@ -521,9 +551,14 @@  discard block
 block discarded – undo
521 551
 	 */
522 552
 	protected static function db2id($data)
523 553
 	{
524
-		if (!is_array($data)) return false;
554
+		if (!is_array($data))
555
+		{
556
+			return false;
557
+		}
525 558
 		$keys = array_keys($data);
526
-		array_walk($keys,function (&$key){$key = str_replace(self::DB_FILEDS_PREFIX, '', $key);});
559
+		array_walk($keys,function (&$key)
560
+		{
561
+$key = str_replace(self::DB_FILEDS_PREFIX, '', $key);});
527 562
 		return array_combine ($keys, $data);
528 563
 	}
529 564
 
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return array returns an array contains of mapped session data
68 68
 	 */
69
-	protected function initSession ($es_id)
69
+	protected function initSession($es_id)
70 70
 	{
71
-		$query = $this->db->select(self::SESSION_TABLE,'*', array('collab_es_id' => $es_id),__LINE__,__FILE__);
71
+		$query = $this->db->select(self::SESSION_TABLE, '*', array('collab_es_id' => $es_id), __LINE__, __FILE__);
72 72
 		$full_name = $GLOBALS['egw_info']['user']['account_fullname'];
73 73
 		$color = $GLOBALS['egw_info']['user']['preferences']['filemanager']['collab_user_color'];
74 74
 		$user_id = $GLOBALS['egw_info']['user']['account_id'];
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 	 * @param string $genesis_url generated url out of genesis temp file
98 98
 	 * @return array returns an array contains of session data
99 99
 	 */
100
-	protected function SESSION_add2Db ($es_id, $genesis_url='')
100
+	protected function SESSION_add2Db($es_id, $genesis_url = '')
101 101
 	{
102 102
 		if ($es_id)
103 103
 		{
104
-			$data = array (
104
+			$data = array(
105 105
 				'collab_es_id' => $es_id,
106 106
 				'collab_genesis_url' => $genesis_url,
107 107
 				'collab_last_save' => self::getTimeStamp(),
108 108
 				'account_id' => $GLOBALS['egw_info']['user']['account_id']
109 109
 			);
110 110
 
111
-			$this->db->insert(self::SESSION_TABLE, $data,false,__LINE__, __FILE__,'filemanager');
111
+			$this->db->insert(self::SESSION_TABLE, $data, false, __LINE__, __FILE__, 'filemanager');
112 112
 		}
113 113
 		return $data;
114 114
 	}
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @throws Exception
122 122
 	 */
123
-	public function SESSION_cleanup ($es_id)
123
+	public function SESSION_cleanup($es_id)
124 124
 	{
125
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
125
+		if (!$es_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
126 126
 
127 127
 		$this->db->delete(
128 128
 				self::OP_TABLE,
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 * @return boolean returns true if update is successful otherwise false
153 153
 	 * @throws Exception
154 154
 	 */
155
-	public function SESSION_Save ($es_id)
155
+	public function SESSION_Save($es_id)
156 156
 	{
157
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
157
+		if (!$es_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
158 158
 		$query = $this->db->update(
159 159
 				self::SESSION_TABLE,
160 160
 				array('collab_last_save' => self::getTimeStamp()),
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				__FILE__,
174 174
 				'filemanager'
175 175
 		);
176
-		return !$query? false: true;
176
+		return !$query ? false: true;
177 177
 	}
178 178
 
179 179
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	public function SESSION_Get($es_id)
188 188
 	{
189
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
189
+		if (!$es_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
190 190
 		$query = $this->db->select(
191 191
 				self::SESSION_TABLE,
192 192
 				'*',
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				__FILE__
196 196
 		);
197 197
 		$session = $query->fetchrow();
198
-		return is_array($session)? self::db2id($session): false;
198
+		return is_array($session) ? self::db2id($session) : false;
199 199
 	}
200 200
 
201 201
 	/**
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	 * @param string $color
209 209
 	 * @param string $imageUrl
210 210
 	 */
211
-	protected function OP_addMember($es_id, $member_id, $full_name, $user_id, $color='', $imageUrl='')
211
+	protected function OP_addMember($es_id, $member_id, $full_name, $user_id, $color = '', $imageUrl = '')
212 212
 	{
213 213
 		$op = array(
214 214
 			'optype' => 'AddMember',
215
-			'memberid' => (string) $member_id,
215
+			'memberid' => (string)$member_id,
216 216
 			'timestamp' => self::getTimeStamp(),
217 217
 			'setProperties' => array(
218 218
 				'fullName' => $full_name,
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	 * @param string $es_id session id
231 231
 	 * @param string $member_id member id
232 232
 	 */
233
-	protected function OP_removeCursor ($es_id, $member_id)
233
+	protected function OP_removeCursor($es_id, $member_id)
234 234
 	{
235 235
 		$op = array(
236 236
 			'optype' => 'RemoveCursor',
237
-			'memberid' => (string) $member_id,
237
+			'memberid' => (string)$member_id,
238 238
 			'reason' => 'server-idle',
239 239
 			'timestamp' => self::getTimeStamp()
240 240
 		);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * Function to discard all changes applied to a session
247 247
 	 * @param type $es_id
248 248
 	 */
249
-	public function OP_Discard ($es_id)
249
+	public function OP_Discard($es_id)
250 250
 	{
251 251
 		$this->db->update(
252 252
 				self::MEMBER_TABLE,
@@ -279,14 +279,14 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return boolean returns true if remove member is successful otherwise false
281 281
 	 */
282
-	function OP_removeMember ($es_id, $member_id)
282
+	function OP_removeMember($es_id, $member_id)
283 283
 	{
284
-		$op = array (
284
+		$op = array(
285 285
 			'optype' => 'RemoveMember',
286
-			'memberid' => (string) $member_id,
286
+			'memberid' => (string)$member_id,
287 287
 			'timestamp' => self::getTimeStamp()
288 288
 		);
289
-		return $this->OP_add2Db($op, $es_id)?true:false;
289
+		return $this->OP_add2Db($op, $es_id) ?true:false;
290 290
 	}
291 291
 
292 292
 	/**
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	protected function OP_getHeadSeq($es_id)
301 301
 	{
302
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
302
+		if (!$es_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
303 303
 
304 304
 		$query = $this->db->select(
305 305
 				self::OP_TABLE,
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 				'filemanager'
313 313
 		);
314 314
 		$head_seq = $query->fetchRow();
315
-		return is_array($head_seq)? $head_seq['collab_seq']: '';
315
+		return is_array($head_seq) ? $head_seq['collab_seq'] : '';
316 316
 	}
317 317
 
318 318
 	/**
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 		$query = $this->db->select(
334 334
 				self::OP_TABLE,
335 335
 				'collab_opspec',
336
-				'collab_es_id ="'. $es_id.'" AND collab_seq >'.$seq_head,
336
+				'collab_es_id ="'.$es_id.'" AND collab_seq >'.$seq_head,
337 337
 				__LINE__,
338 338
 				__FILE__,
339
-				false, 'ORDER BY collab_seq ASC','filemanager');
339
+				false, 'ORDER BY collab_seq ASC', 'filemanager');
340 340
 
341 341
 		foreach ($query as $spec)
342 342
 		{
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @param array $client_ops array of ops
356 356
 	 * @throws Exception if no array of ops given
357 357
 	 */
358
-	protected function OP_addOPS ($es_id, $member_id, $client_ops)
358
+	protected function OP_addOPS($es_id, $member_id, $client_ops)
359 359
 	{
360
-		if (count($client_ops)<= 0) throw new Exception (self::EXCEPTION_MESSAGE_NO_OPS);
360
+		if (count($client_ops) <= 0) throw new Exception(self::EXCEPTION_MESSAGE_NO_OPS);
361 361
 
362 362
 		foreach ($client_ops as $op)
363 363
 		{
@@ -371,15 +371,15 @@  discard block
 block discarded – undo
371 371
 	 * @param array $op op data
372 372
 	 * @param string $es_id session id
373 373
 	 */
374
-	protected function OP_add2Db ($op, $es_id)
374
+	protected function OP_add2Db($op, $es_id)
375 375
 	{
376
-		$data = array (
376
+		$data = array(
377 377
 			'collab_es_id' => $es_id,
378 378
 			'collab_member' => $op['memberid'],
379 379
 			'collab_optype' => $op['optype'],
380 380
 			'collab_opspec' => json_encode($op)
381 381
 		);
382
-		return $this->db->insert(self::OP_TABLE, $data,false,__LINE__, __FILE__,'filemanager');
382
+		return $this->db->insert(self::OP_TABLE, $data, false, __LINE__, __FILE__, 'filemanager');
383 383
 	}
384 384
 
385 385
 	/**
@@ -389,15 +389,15 @@  discard block
 block discarded – undo
389 389
 	 * @param int $user_id user id
390 390
 	 * @param string $color user color code
391 391
 	 */
392
-	protected function MEMBER_add2Db ($es_id, $user_id, $color)
392
+	protected function MEMBER_add2Db($es_id, $user_id, $color)
393 393
 	{
394
-		$data = array (
394
+		$data = array(
395 395
 			'collab_es_id' => $es_id,
396 396
 			'collab_uid' => $user_id,
397 397
 			'collab_color' => $color,
398 398
 			'collab_is_active' => 1
399 399
 		);
400
-		$this->db->insert(self::MEMBER_TABLE, $data,false,__LINE__, __FILE__,'filemanager');
400
+		$this->db->insert(self::MEMBER_TABLE, $data, false, __LINE__, __FILE__, 'filemanager');
401 401
 	}
402 402
 
403 403
 	/**
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @throws Exception throws exception if no es_id or member id is given
411 411
 	 */
412
-	protected function MEMBER_UpdateActiveMember ($es_id, $member_id, $is_active = 0)
412
+	protected function MEMBER_UpdateActiveMember($es_id, $member_id, $is_active = 0)
413 413
 	{
414
-		if (!$es_id || !$member_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
414
+		if (!$es_id || !$member_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
415 415
 		$this->db->update(
416 416
 				self::MEMBER_TABLE,
417 417
 				array('collab_is_active' => $is_active),
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 	 * @return array returns array of members records
431 431
 	 * @throws Exception throws exception if no es_id is given
432 432
 	 */
433
-	protected function MEMBER_getActiveMembers ($es_id)
433
+	protected function MEMBER_getActiveMembers($es_id)
434 434
 	{
435
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
435
+		if (!$es_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
436 436
 		$query = $this->db->select(
437 437
 				self::MEMBER_TABLE,
438 438
 				'*',
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 				'filemanager'
443 443
 		);
444 444
 		$members = $query->getRows();
445
-		return is_array($members)?self::db2id($members):true;
445
+		return is_array($members) ?self::db2id($members) : true;
446 446
 	}
447 447
 
448 448
 	/**
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
 	 * @return string member id or null
454 454
 	 * @throws Exception throws exception if no member id is given
455 455
 	 */
456
-	protected function MEMBER_getUserMemberId ($es_id, $user_id)
456
+	protected function MEMBER_getUserMemberId($es_id, $user_id)
457 457
 	{
458
-		if (!$es_id || !$user_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
458
+		if (!$es_id || !$user_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
459 459
 		$query = $this->db->select(
460 460
 				self::MEMBER_TABLE,
461 461
 				'collab_member_id',
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 				__FILE__
465 465
 		);
466 466
 		$member = $query->fetchRow();
467
-		return is_array($member)? $member['collab_member_id']: null;
467
+		return is_array($member) ? $member['collab_member_id'] : null;
468 468
 	}
469 469
 
470 470
 	/**
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
 	 * @return string member id or null
476 476
 	 * @throws Exception throws exception if no member id is given
477 477
 	 */
478
-	protected function MEMBER_getUserLastMemberId ($es_id, $user_id)
478
+	protected function MEMBER_getUserLastMemberId($es_id, $user_id)
479 479
 	{
480
-		if (!$es_id || !$user_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
480
+		if (!$es_id || !$user_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
481 481
 		$query = $this->db->select(
482 482
 				self::MEMBER_TABLE,
483 483
 				'collab_member_id',
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 				"ORDER BY `collab_member_id` DESC LIMIT 1;"
489 489
 		);
490 490
 		$member = $query->fetchRow();
491
-		return is_array($member)? $member['collab_member_id']: null;
491
+		return is_array($member) ? $member['collab_member_id'] : null;
492 492
 	}
493 493
 
494 494
 	/**
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 	 * @return array array of records or null
500 500
 	 * @throws Exception throws exception if no member id is given
501 501
 	 */
502
-	protected function MEMBER_getMember ($es_id, $member_id)
502
+	protected function MEMBER_getMember($es_id, $member_id)
503 503
 	{
504
-		if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
504
+		if (!$es_id) throw new Exception(self::EXCEPTION_MESSAGE_NO_SESSION);
505 505
 		$query = $this->db->select(
506 506
 				self::MEMBER_TABLE,
507 507
 				'*',
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 				__FILE__
511 511
 		);
512 512
 		$member = $query->fetchRow();
513
-		return is_array($member)? self::db2id($member): null;
513
+		return is_array($member) ? self::db2id($member) : null;
514 514
 	}
515 515
 
516 516
 	/**
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	{
524 524
 		if (!is_array($data)) return false;
525 525
 		$keys = array_keys($data);
526
-		array_walk($keys,function (&$key){$key = str_replace(self::DB_FILEDS_PREFIX, '', $key);});
527
-		return array_combine ($keys, $data);
526
+		array_walk($keys, function(&$key) {$key = str_replace(self::DB_FILEDS_PREFIX, '', $key); });
527
+		return array_combine($keys, $data);
528 528
 	}
529 529
 
530 530
 	/**
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
 				"ORDER BY `collab_member_id` DESC LIMIT 1;"
545 545
 		);
546 546
 		$last_row = $query->fetchRow();
547
-		return is_array($last_row)? $last_row['collab_member_id']: 0;
547
+		return is_array($last_row) ? $last_row['collab_member_id'] : 0;
548 548
 	}
549 549
 
550 550
 	/**
551 551
 	 * Get timestamp
552 552
 	 * @return int returns current time as timestamp
553 553
 	 */
554
-	static function getTimeStamp ()
554
+	static function getTimeStamp()
555 555
 	{
556 556
 		$date = new DateTime();
557 557
 		return $date->getTimestamp();
Please login to merge, or discard this patch.
filemanager/setup/tables_current.inc.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 $phpgw_baseline = array(
15 15
 	'egw_collab_member' => array(
16 16
 		'fd' => array(
17
-			'collab_member_id' => array('type' => 'auto','nullable' => False, 'comment' => 'Unique per user and session'),
18
-			'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Related editing session id'),
19
-			'collab_uid' => array('type' => 'varchar','precision' => '64'),
20
-			'collab_color' => array('type' => 'varchar','precision' => '32'),
21
-			'collab_is_active' => array('type' => 'int','precision' => '2', 'default'=>'0','nullable' => False),
22
-			'collab_is_guest' => array('type' => 'int','precision' => '2','default' => '0','nullable' => False),
23
-			'collab_token' => array('type' => 'varchar','precision' => '32'),
24
-			'collab_status' => array('type' => 'int','precision' => '2','default' => '1','nullable' => False)
17
+			'collab_member_id' => array('type' => 'auto', 'nullable' => False, 'comment' => 'Unique per user and session'),
18
+			'collab_es_id' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False, 'comment' => 'Related editing session id'),
19
+			'collab_uid' => array('type' => 'varchar', 'precision' => '64'),
20
+			'collab_color' => array('type' => 'varchar', 'precision' => '32'),
21
+			'collab_is_active' => array('type' => 'int', 'precision' => '2', 'default'=>'0', 'nullable' => False),
22
+			'collab_is_guest' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'nullable' => False),
23
+			'collab_token' => array('type' => 'varchar', 'precision' => '32'),
24
+			'collab_status' => array('type' => 'int', 'precision' => '2', 'default' => '1', 'nullable' => False)
25 25
 		),
26 26
 		'pk' => array('collab_member_id'),
27 27
 		'fk' => array(),
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	),
31 31
 	'egw_collab_op' => array(
32 32
 		'fd' => array(
33
-			'collab_seq' => array('type' => 'auto','nullable' => False, 'comment' => 'Sequence number'),
34
-			'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Editing session id'),
35
-			'collab_member' => array('type' => 'int','precision' => '4','default' => '1','nullable' => False, 'comment' => 'User and time specific'),
36
-			'collab_optype' => array('type' => 'varchar','precision' => '64', 'comment' => 'Operation type'),
33
+			'collab_seq' => array('type' => 'auto', 'nullable' => False, 'comment' => 'Sequence number'),
34
+			'collab_es_id' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False, 'comment' => 'Editing session id'),
35
+			'collab_member' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'nullable' => False, 'comment' => 'User and time specific'),
36
+			'collab_optype' => array('type' => 'varchar', 'precision' => '64', 'comment' => 'Operation type'),
37 37
 			'collab_opspec' => array('type' => 'longtext', 'comment' => 'json-string')
38 38
 		),
39 39
 		'pk' => array('collab_seq'),
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	),
44 44
 	'egw_collab_session' => array(
45 45
 		'fd' => array(
46
-			'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Editing session id'),
47
-			'collab_genesis_url' => array('type' => 'varchar','precision' => '512', 'comment' => 'Relative to owner documents storage /template.odt'),
48
-			'account_id' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False, 'comment' => 'user who created the session'),
49
-			'collab_last_save' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'timestamp of the last save')
46
+			'collab_es_id' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False, 'comment' => 'Editing session id'),
47
+			'collab_genesis_url' => array('type' => 'varchar', 'precision' => '512', 'comment' => 'Relative to owner documents storage /template.odt'),
48
+			'account_id' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False, 'comment' => 'user who created the session'),
49
+			'collab_last_save' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'comment' => 'timestamp of the last save')
50 50
 		),
51 51
 		'pk' => array('collab_es_id'),
52 52
 		'fk' => array(),
Please login to merge, or discard this patch.
filemanager/setup/tables_update.inc.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 {
18 18
 	$GLOBALS['egw_setup']->oProc->CreateTable('egw_collab_member', array(
19 19
 		'fd' => array(
20
-			'collab_member_id' => array('type' => 'auto','nullable' => False, 'comment' => 'Unique per user and session'),
21
-			'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Related editing session id'),
22
-			'collab_uid' => array('type' => 'varchar','precision' => '64'),
23
-			'collab_color' => array('type' => 'varchar','precision' => '32'),
24
-			'collab_is_active' => array('type' => 'int','precision' => '2', 'default'=>'0','nullable' => False),
25
-			'collab_is_guest' => array('type' => 'int','precision' => '2','default' => '0','nullable' => False),
26
-			'collab_token' => array('type' => 'varchar','precision' => '32'),
27
-			'collab_status' => array('type' => 'int','precision' => '2','default' => '1','nullable' => False)
20
+			'collab_member_id' => array('type' => 'auto', 'nullable' => False, 'comment' => 'Unique per user and session'),
21
+			'collab_es_id' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False, 'comment' => 'Related editing session id'),
22
+			'collab_uid' => array('type' => 'varchar', 'precision' => '64'),
23
+			'collab_color' => array('type' => 'varchar', 'precision' => '32'),
24
+			'collab_is_active' => array('type' => 'int', 'precision' => '2', 'default'=>'0', 'nullable' => False),
25
+			'collab_is_guest' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'nullable' => False),
26
+			'collab_token' => array('type' => 'varchar', 'precision' => '32'),
27
+			'collab_status' => array('type' => 'int', 'precision' => '2', 'default' => '1', 'nullable' => False)
28 28
 		),
29 29
 		'pk' => array('collab_member_id'),
30 30
 		'fk' => array(),
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 
35 35
 	$GLOBALS['egw_setup']->oProc->CreateTable('egw_collab_op', array(
36 36
 		'fd' => array(
37
-			'collab_seq' => array('type' => 'auto','nullable' => False, 'comment' => 'Sequence number'),
38
-			'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Editing session id'),
39
-			'collab_member' => array('type' => 'int','precision' => '4','default' => '1','nullable' => False, 'comment' => 'User and time specific'),
40
-			'collab_optype' => array('type' => 'varchar','precision' => '64', 'comment' => 'Operation type'),
37
+			'collab_seq' => array('type' => 'auto', 'nullable' => False, 'comment' => 'Sequence number'),
38
+			'collab_es_id' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False, 'comment' => 'Editing session id'),
39
+			'collab_member' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'nullable' => False, 'comment' => 'User and time specific'),
40
+			'collab_optype' => array('type' => 'varchar', 'precision' => '64', 'comment' => 'Operation type'),
41 41
 			'collab_opspec' => array('type' => 'longtext', 'comment' => 'json-string')
42 42
 		),
43 43
 		'pk' => array('collab_seq'),
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 
49 49
 	$GLOBALS['egw_setup']->oProc->CreateTable('egw_collab_session', array(
50 50
 		'fd' => array(
51
-			'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Editing session id'),
52
-			'collab_genesis_url' => array('type' => 'varchar','precision' => '512', 'comment' => 'Relative to owner documents storage /template.odt'),
53
-			'account_id' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False, 'comment' => 'user who created the session'),
54
-			'collab_last_save' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'timestamp of the last save')
51
+			'collab_es_id' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False, 'comment' => 'Editing session id'),
52
+			'collab_genesis_url' => array('type' => 'varchar', 'precision' => '512', 'comment' => 'Relative to owner documents storage /template.odt'),
53
+			'account_id' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False, 'comment' => 'user who created the session'),
54
+			'collab_last_save' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'comment' => 'timestamp of the last save')
55 55
 		),
56 56
 		'pk' => array('collab_es_id'),
57 57
 		'fk' => array(),
Please login to merge, or discard this patch.
api/src/avatar.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 {
24 24
 	// background colors
25 25
 	private static $BG_COLORS = array(
26
-		array(90,135,112), array(178,183,187), array(111,169,171), array(245,175,41),
27
-		array(0,136,185), array(241,134,54), array(217,58,55), array(166,177,46),
28
-		array(0,136,185), array(241,134,54), array(217,58,55), array(166,177,46),
29
-		array(92,155,188), array(245,136,141), array(154,137,181), array(64,120,135),
30
-		array(154,137,181),array(90,135,112), array(211,63,51),	array(162,176,31),
31
-		array(240,177,38),array(0,135,191), array(241,134,54), array(0,135,191),
32
-		array(178,183,187),array(114,172,174), array(156,138,180), array(90,135,112),
33
-		array(238,180,36),array(64,120,135)
26
+		array(90, 135, 112), array(178, 183, 187), array(111, 169, 171), array(245, 175, 41),
27
+		array(0, 136, 185), array(241, 134, 54), array(217, 58, 55), array(166, 177, 46),
28
+		array(0, 136, 185), array(241, 134, 54), array(217, 58, 55), array(166, 177, 46),
29
+		array(92, 155, 188), array(245, 136, 141), array(154, 137, 181), array(64, 120, 135),
30
+		array(154, 137, 181), array(90, 135, 112), array(211, 63, 51), array(162, 176, 31),
31
+		array(240, 177, 38), array(0, 135, 191), array(241, 134, 54), array(0, 135, 191),
32
+		array(178, 183, 187), array(114, 172, 174), array(156, 138, 180), array(90, 135, 112),
33
+		array(238, 180, 36), array(64, 120, 135)
34 34
 	);
35 35
 
36 36
 	// ratio of font size to size
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	// ratio of text Y position to size
40 40
 	private static $_TEXT_Y_RATIO = 1.6;
41 41
 
42
-	private static $_TEXT_COLOR = array (255, 255, 255);
42
+	private static $_TEXT_COLOR = array(255, 255, 255);
43 43
 	// font path
44 44
 	private static $_FONT_PATH = '/api/templates/default/fonts/arial.ttf';
45 45
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 *		)
68 68
 	 * @param int $_size = 128 image size, default size is 128
69 69
 	 */
70
-	public static function lavatar ($_content = null, $_color = null, $_size = 128)
70
+	public static function lavatar($_content = null, $_color = null, $_size = 128)
71 71
 	{
72 72
 		// firstname
73
-		$firstname = isset($_content['firstname'])? $_content['firstname'] : '';
73
+		$firstname = isset($_content['firstname']) ? $_content['firstname'] : '';
74 74
 		//lastname
75
-		$lastname = isset($_content['lastname'])? $_content['lastname'] : '';
75
+		$lastname = isset($_content['lastname']) ? $_content['lastname'] : '';
76 76
 		// id
77
-		$id = isset($_content['id'])? $_content['id']: '';
77
+		$id = isset($_content['id']) ? $_content['id'] : '';
78 78
 
79 79
 		// Array of RGB color as background color
80 80
 		$bgcolor = $_color ? $_color : self::_getBgColor($firstname.$lastname.$id);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$bg = imagecolorallocate($image, $bgcolor[0], $bgcolor[1], $bgcolor[2]);
90 90
 
91 91
 		// allocate an image color as textcolor
92
-		$textcolor = imagecolorallocate($image, self::$_TEXT_COLOR[0],self::$_TEXT_COLOR[1],self::$_TEXT_COLOR[2]);
92
+		$textcolor = imagecolorallocate($image, self::$_TEXT_COLOR[0], self::$_TEXT_COLOR[1], self::$_TEXT_COLOR[2]);
93 93
 
94 94
 		// create a rectangle
95 95
 		imagefilledrectangle($image, 0, 0, $_size, $_size, $bg);
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 
99 99
 		$box = imagettfbbox($fontsize, 0, EGW_SERVER_ROOT.self::$_FONT_PATH, $text);
100 100
 
101
-		$x = floor(($_size - ($box[2] - $box[0]))/2);
101
+		$x = floor(($_size - ($box[2] - $box[0])) / 2);
102 102
 
103
-		$y = floor ($_size / self::$_TEXT_Y_RATIO);
103
+		$y = floor($_size / self::$_TEXT_Y_RATIO);
104 104
 
105 105
 		// write a ttf text
106
-		$ttf = imagettftext($image,	$fontsize, 0, $x, $y, $textcolor, EGW_SERVER_ROOT.self::$_FONT_PATH, $text);
106
+		$ttf = imagettftext($image, $fontsize, 0, $x, $y, $textcolor, EGW_SERVER_ROOT.self::$_FONT_PATH, $text);
107 107
 		if ($ttf)
108 108
 		{
109 109
 			ob_start();
110
-			imagejpeg($image, null,100);
110
+			imagejpeg($image, null, 100);
111 111
 			$result = ob_get_contents();
112 112
 			ob_clean();
113 113
 			imagedestroy($image);
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @return string color code
129 129
 	 */
130
-	private static function _getBgColor ($_str)
130
+	private static function _getBgColor($_str)
131 131
 	{
132 132
 		$hash = 0;
133
-		for ($i=0; $i< strlen($_str); $i++)
133
+		for ($i = 0; $i < strlen($_str); $i++)
134 134
 		{
135 135
 			$hash = ord($_str[$i]) + $hash;
136 136
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@
 block discarded – undo
43 43
 	// font path
44 44
 	private static $_FONT_PATH = '/api/templates/default/fonts/arial.ttf';
45 45
 
46
-	public function __construct() {
46
+	public function __construct()
47
+	{
47 48
 	}
48 49
 
49 50
 	/**
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_wizard_import_csv.inc.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@
 block discarded – undo
35 35
 		$this->mapping_fields = array('ts_id' => lang('Timesheet ID')) + $bo->field2label;
36 36
 
37 37
 		// These aren't in the list
38
-                $this->mapping_fields += array(
39
-                        'ts_modified'   => lang('Modified'),
40
-                );
38
+				$this->mapping_fields += array(
39
+						'ts_modified'   => lang('Modified'),
40
+				);
41 41
 
42 42
 		// List each custom field
43 43
 		unset($this->mapping_fields['customfields']);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		// List each custom field
43 43
 		unset($this->mapping_fields['customfields']);
44 44
 		$custom = Api\Storage\Customfields::get('timesheet');
45
-		foreach($custom as $name => $data) {
45
+		foreach ($custom as $name => $data) {
46 46
 			$this->mapping_fields['#'.$name] = $data['label'];
47 47
 		}
48 48
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	function wizard_step45(&$content, &$sel_options, &$readonlys, &$preserv)
74 74
 	{
75
-		if($this->debug) error_log(__METHOD__.'->$content '.print_r($content,true));
75
+		if ($this->debug) error_log(__METHOD__.'->$content '.print_r($content, true));
76 76
 
77 77
 		// return from step45
78 78
 		if ($content['step'] == 'wizard_step45')
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 			switch (array_search('pressed', $content['button']))
81 81
 			{
82 82
 				case 'next':
83
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
83
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
84 84
 				case 'previous' :
85
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
85
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
86 86
 				case 'finish':
87 87
 					return 'wizard_finish';
88 88
 				default :
89
-					return $this->wizard_step45($content,$sel_options,$readonlys,$preserv);
89
+					return $this->wizard_step45($content, $sel_options, $readonlys, $preserv);
90 90
 			}
91 91
 		}
92 92
 		// init step45
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 				'~skip~' => lang('Skip record'),
102 102
 				'add' => lang('Add'),
103 103
 			);
104
-			$set_to = lang('Set to') . ':';
105
-			$categories = new Api\Categories('','timesheet');
104
+			$set_to = lang('Set to').':';
105
+			$categories = new Api\Categories('', 'timesheet');
106 106
 			$cat_list = array();
107
-			foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat) {
108
-				$s = str_repeat('&nbsp;',$cat['level']) . stripslashes($cat['name']);
107
+			foreach ((array)$categories->return_sorted_array(0, False, '', '', '', true) as $cat) {
108
+				$s = str_repeat('&nbsp;', $cat['level']).stripslashes($cat['name']);
109 109
 
110 110
 				$cat_list[$cat['id']] = empty($cat['description']) ? $s : array(
111 111
 					'label' => $s,
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 					'translate_cat_id'	=> $options + array($set_to => $cat_list),
118 118
 			);
119 119
 			$preserv = $content;
120
-			foreach($sel_options as $field => $options) {
121
-				if(!array_key_exists($field,$content)) $content[$field] = $content['plugin_options'][$field];
120
+			foreach ($sel_options as $field => $options) {
121
+				if (!array_key_exists($field, $content)) $content[$field] = $content['plugin_options'][$field];
122 122
 			}
123 123
 			unset ($preserv['button']);
124 124
 			return $this->step_templates['wizard_step45'];
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	
135 135
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
136 136
 	{
137
-		if($this->debug) error_log(__METHOD__.'->$content '.print_r($content,true));
137
+		if ($this->debug) error_log(__METHOD__.'->$content '.print_r($content, true));
138 138
 		unset($content['no_owner_map']);
139 139
 
140 140
 		// return from step60
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 			switch (array_search('pressed', $content['button']))
144 144
 			{
145 145
 				case 'next':
146
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
146
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
147 147
 				case 'previous' :
148
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
148
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
149 149
 				case 'finish':
150 150
 					return 'wizard_finish';
151 151
 				default :
152
-					return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
152
+					return $this->wizard_step60($content, $sel_options, $readonlys, $preserv);
153 153
 			}
154 154
 		}
155 155
 		// init step60
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 			$content['message'] = $this->steps['wizard_step60'];
159 159
 			$content['step'] = 'wizard_step60';
160 160
 			$preserv = $content;
161
-			if(!array_key_exists('record_owner', $content) && $content['plugin_options']) {
161
+			if (!array_key_exists('record_owner', $content) && $content['plugin_options']) {
162 162
 				$content['record_owner'] = $content['plugin_options']['record_owner'];
163 163
 			}
164
-			if(!array_key_exists('owner_from_csv', $content) && $content['plugin_options']) {
164
+			if (!array_key_exists('owner_from_csv', $content) && $content['plugin_options']) {
165 165
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
166 166
 			}
167
-			if(!array_key_exists('change_owner', $content) && $content['plugin_options']) {
167
+			if (!array_key_exists('change_owner', $content) && $content['plugin_options']) {
168 168
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
169 169
 			}
170 170
 
171
-			if(!in_array('ts_owner', $content['field_mapping'])) {
171
+			if (!in_array('ts_owner', $content['field_mapping'])) {
172 172
 				$content['no_owner_map'] = true;
173 173
 			}
174 174
 
Please login to merge, or discard this patch.
Braces   +26 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
42 42
 		// List each custom field
43 43
 		unset($this->mapping_fields['customfields']);
44 44
 		$custom = Api\Storage\Customfields::get('timesheet');
45
-		foreach($custom as $name => $data) {
45
+		foreach($custom as $name => $data)
46
+		{
46 47
 			$this->mapping_fields['#'.$name] = $data['label'];
47 48
 		}
48 49
 
@@ -72,7 +73,10 @@  discard block
 block discarded – undo
72 73
 
73 74
 	function wizard_step45(&$content, &$sel_options, &$readonlys, &$preserv)
74 75
 	{
75
-		if($this->debug) error_log(__METHOD__.'->$content '.print_r($content,true));
76
+		if($this->debug)
77
+		{
78
+			error_log(__METHOD__.'->$content '.print_r($content,true));
79
+		}
76 80
 
77 81
 		// return from step45
78 82
 		if ($content['step'] == 'wizard_step45')
@@ -104,7 +108,8 @@  discard block
 block discarded – undo
104 108
 			$set_to = lang('Set to') . ':';
105 109
 			$categories = new Api\Categories('','timesheet');
106 110
 			$cat_list = array();
107
-			foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat) {
111
+			foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat)
112
+			{
108 113
 				$s = str_repeat('&nbsp;',$cat['level']) . stripslashes($cat['name']);
109 114
 
110 115
 				$cat_list[$cat['id']] = empty($cat['description']) ? $s : array(
@@ -117,8 +122,12 @@  discard block
 block discarded – undo
117 122
 					'translate_cat_id'	=> $options + array($set_to => $cat_list),
118 123
 			);
119 124
 			$preserv = $content;
120
-			foreach($sel_options as $field => $options) {
121
-				if(!array_key_exists($field,$content)) $content[$field] = $content['plugin_options'][$field];
125
+			foreach($sel_options as $field => $options)
126
+			{
127
+				if(!array_key_exists($field,$content))
128
+				{
129
+					$content[$field] = $content['plugin_options'][$field];
130
+				}
122 131
 			}
123 132
 			unset ($preserv['button']);
124 133
 			return $this->step_templates['wizard_step45'];
@@ -134,7 +143,10 @@  discard block
 block discarded – undo
134 143
 	
135 144
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
136 145
 	{
137
-		if($this->debug) error_log(__METHOD__.'->$content '.print_r($content,true));
146
+		if($this->debug)
147
+		{
148
+			error_log(__METHOD__.'->$content '.print_r($content,true));
149
+		}
138 150
 		unset($content['no_owner_map']);
139 151
 
140 152
 		// return from step60
@@ -158,17 +170,21 @@  discard block
 block discarded – undo
158 170
 			$content['message'] = $this->steps['wizard_step60'];
159 171
 			$content['step'] = 'wizard_step60';
160 172
 			$preserv = $content;
161
-			if(!array_key_exists('record_owner', $content) && $content['plugin_options']) {
173
+			if(!array_key_exists('record_owner', $content) && $content['plugin_options'])
174
+			{
162 175
 				$content['record_owner'] = $content['plugin_options']['record_owner'];
163 176
 			}
164
-			if(!array_key_exists('owner_from_csv', $content) && $content['plugin_options']) {
177
+			if(!array_key_exists('owner_from_csv', $content) && $content['plugin_options'])
178
+			{
165 179
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
166 180
 			}
167
-			if(!array_key_exists('change_owner', $content) && $content['plugin_options']) {
181
+			if(!array_key_exists('change_owner', $content) && $content['plugin_options'])
182
+			{
168 183
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
169 184
 			}
170 185
 
171
-			if(!in_array('ts_owner', $content['field_mapping'])) {
186
+			if(!in_array('ts_owner', $content['field_mapping']))
187
+			{
172 188
 				$content['no_owner_map'] = true;
173 189
 			}
174 190
 
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_import_csv.inc.php 4 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	private $bo;
73 73
 
74 74
 	/**
75
-	* For figuring out if a record has changed
76
-	*/
75
+	 * For figuring out if a record has changed
76
+	 */
77 77
 	protected $tracking;
78 78
 
79 79
 	/**
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	protected $errors = array();
98 98
 
99 99
 	/**
100
-	* List of actions, and how many times that action was taken
101
-	*/
100
+	 * List of actions, and how many times that action was taken
101
+	 */
102 102
 	protected $results = array();
103 103
 
104 104
 	/**
@@ -526,39 +526,39 @@  discard block
 block discarded – undo
526 526
 	}
527 527
 
528 528
 	/**
529
-	* Returns warnings that were encountered during importing
530
-	* Maximum of one warning message per record, but you can append if you need to
531
-	*
532
-	* @return Array (
533
-	*       record_# => warning message
534
-	*       )
535
-	*/
529
+	 * Returns warnings that were encountered during importing
530
+	 * Maximum of one warning message per record, but you can append if you need to
531
+	 *
532
+	 * @return Array (
533
+	 *       record_# => warning message
534
+	 *       )
535
+	 */
536 536
 	public function get_warnings()
537 537
 	{
538 538
 		return $this->warnings;
539 539
 	}
540 540
 
541 541
 	/**
542
-	* Returns errors that were encountered during importing
543
-	* Maximum of one error message per record, but you can append if you need to
544
-	*
545
-	* @return Array (
546
-	*       record_# => error message
547
-	*       )
548
-	*/
542
+	 * Returns errors that were encountered during importing
543
+	 * Maximum of one error message per record, but you can append if you need to
544
+	 *
545
+	 * @return Array (
546
+	 *       record_# => error message
547
+	 *       )
548
+	 */
549 549
 	public function get_errors()
550 550
 	{
551 551
 		return $this->errors;
552 552
 	}
553 553
 
554 554
 	/**
555
-	* Returns a list of actions taken, and the number of records for that action.
556
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
557
-	*
558
-	* @return Array (
559
-	*       action => record count
560
-	* )
561
-	*/
555
+	 * Returns a list of actions taken, and the number of records for that action.
556
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
557
+	 *
558
+	 * @return Array (
559
+	 *       action => record count
560
+	 * )
561
+	 */
562 562
 	public function get_results()
563 563
 	{
564 564
 			return $this->results;
Please login to merge, or discard this patch.
Braces   +53 added lines, -14 removed lines patch added patch discarded remove patch
@@ -137,9 +137,12 @@  discard block
 block discarded – undo
137 137
 		$import_csv->conversion_class = $this;
138 138
 
139 139
 		//check if file has a header lines
140
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
140
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
141
+		{
141 142
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
142
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
143
+		}
144
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
145
+		{
143 146
 			// First method is preferred
144 147
 			$import_csv->skip_records(1);
145 148
 		}
@@ -163,7 +166,10 @@  discard block
 block discarded – undo
163 166
 		foreach($lookups['ts_status'] as $id => &$label)
164 167
 		{
165 168
 			$label = str_replace('&nbsp;', '',trim($label));
166
-			if($label == '') unset($lookups['ts_status'][$id]);
169
+			if($label == '')
170
+			{
171
+				unset($lookups['ts_status'][$id]);
172
+			}
167 173
 		}
168 174
 
169 175
 		// Start counting successes
@@ -178,10 +184,16 @@  discard block
 block discarded – undo
178 184
 			$success = false;
179 185
 
180 186
 			// don't import empty records
181
-			if( count( array_unique( $record ) ) < 2 ) continue;
187
+			if( count( array_unique( $record ) ) < 2 )
188
+			{
189
+				continue;
190
+			}
182 191
 
183 192
 			$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
184
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
193
+			if($result)
194
+			{
195
+				$this->warnings[$import_csv->get_current_position()] = $result;
196
+			}
185 197
 
186 198
 			// Automatically handle text Api\Categories without explicit Api\Translation
187 199
 			foreach(array('ts_status','cat_id') as $field)
@@ -329,8 +341,14 @@  discard block
 block discarded – undo
329 341
 									$record['ts_id'] = $result['ts_id'];
330 342
 									if ( $_definition->plugin_options['update_cats'] == 'add' )
331 343
 									{
332
-										if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] );
333
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
344
+										if ( !is_array( $result['cat_id'] ) )
345
+										{
346
+											$result['cat_id'] = explode( ',', $result['cat_id'] );
347
+										}
348
+										if ( !is_array( $record['cat_id'] ) )
349
+										{
350
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
351
+										}
334 352
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) );
335 353
 									}
336 354
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
@@ -348,7 +366,10 @@  discard block
 block discarded – undo
348 366
 							die('condition / action not supported!!!');
349 367
 							break;
350 368
 					}
351
-					if ($action['last']) break;
369
+					if ($action['last'])
370
+					{
371
+						break;
372
+					}
352 373
 				}
353 374
 			}
354 375
 			else
@@ -356,7 +377,10 @@  discard block
 block discarded – undo
356 377
 				// unconditional insert
357 378
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
358 379
 			}
359
-			if($success) $count++;
380
+			if($success)
381
+			{
382
+				$count++;
383
+			}
360 384
 		}
361 385
 		return $count;
362 386
 	}
@@ -448,7 +472,10 @@  discard block
 block discarded – undo
448 472
 		$_link_id = false;
449 473
 		foreach(self::$special_fields as $field => $desc)
450 474
 		{
451
-			if(!$_data[$field]) continue;
475
+			if(!$_data[$field])
476
+			{
477
+				continue;
478
+			}
452 479
 
453 480
 			// Links
454 481
 			if(strpos($field, 'link') === 0)
@@ -577,28 +604,40 @@  discard block
 block discarded – undo
577 604
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
578 605
 		}
579 606
 		$n_family = trim($n_family);
580
-		if(!is_null($n_given)) $n_given = trim($n_given);
607
+		if(!is_null($n_given))
608
+		{
609
+			$n_given = trim($n_given);
610
+		}
581 611
 		if (!is_object($contacts))
582 612
 		{
583 613
 			$contacts =& CreateObject('phpgwapi.contacts');
584 614
 		}
585
-		if (!is_null($org_name))        // org_name given?
615
+		if (!is_null($org_name))
616
+		{
617
+			// org_name given?
586 618
 		{
587 619
 			$org_name = trim($org_name);
620
+		}
588 621
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
589 622
 			if (!count($addrs))
590 623
 			{
591 624
 				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
592 625
 			}
593 626
 		}
594
-		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
627
+		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))
628
+		{
629
+			// first name given and no result so far
595 630
 		{
596 631
 			$addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given));
597 632
 		}
598
-		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
633
+		}
634
+		if (is_null($n_given) && is_null($org_name))
635
+		{
636
+			// just one name given, check against fn (= full name)
599 637
 		{
600 638
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
601 639
 		}
640
+		}
602 641
 		if (count($addrs))
603 642
 		{
604 643
 			return $addrs[0]['id'];
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@
 block discarded – undo
104 104
 	/**
105 105
 	 * imports entries according to given definition object.
106 106
 	 * @param resource $_stream
107
-	 * @param string $_charset
108
-	 * @param definition $_definition
107
+	 * @param importexport_definition $_definition
109 108
 	 */
110 109
 	public function import( $_stream, importexport_definition $_definition )
111 110
 	{
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 class timesheet_import_csv implements importexport_iface_import_plugin
21 21
 {
22 22
 	private static $plugin_options = array(
23
-		'fieldsep', 		// char
24
-		'charset', 			// string
25
-		'update_cats', 			// string {override|add} overides record
23
+		'fieldsep', // char
24
+		'charset', // string
25
+		'update_cats', // string {override|add} overides record
26 26
 								// with cat(s) from csv OR add the cat from
27 27
 								// csv file to exeisting cat(s) of record
28 28
 		'num_header_lines', // int number of header lines
29 29
 		'field_conversion', // array( $csv_col_num => conversion)
30
-		'field_mapping',	// array( $csv_col_num => adb_filed)
31
-		'conditions',		/* => array containing condition arrays:
30
+		'field_mapping', // array( $csv_col_num => adb_filed)
31
+		'conditions', /* => array containing condition arrays:
32 32
 				'type' => exists, // exists
33 33
 				'string' => '#kundennummer',
34 34
 				'true' => array(
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * actions wich could be done to data entries
54 54
 	 */
55
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
55
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
56 56
 
57 57
 	/**
58 58
 	 * conditions for actions
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	protected static $conditions = array( 'exists' );
62
+	protected static $conditions = array('exists');
63 63
 
64 64
 	/**
65 65
 	 * @var definition
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param string $_charset
108 108
 	 * @param definition $_definition
109 109
 	 */
110
-	public function import( $_stream, importexport_definition $_definition )
110
+	public function import($_stream, importexport_definition $_definition)
111 111
 	{
112
-		$import_csv = new importexport_import_csv( $_stream, array(
112
+		$import_csv = new importexport_import_csv($_stream, array(
113 113
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
114 114
 			'charset' => $_definition->plugin_options['charset'],
115 115
 		));
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
120 120
 
121 121
 		// dry run?
122
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
122
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
123 123
 
124 124
 		// fetch the bo
125 125
 		$this->bo = new timesheet_bo();
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 		$import_csv->conversion_class = $this;
138 138
 
139 139
 		//check if file has a header lines
140
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
140
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
141 141
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
142
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
142
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
143 143
 			// First method is preferred
144 144
 			$import_csv->skip_records(1);
145 145
 		}
146 146
 
147 147
 		// set Owner
148 148
 		$plugin_options = $_definition->plugin_options;
149
-		$plugin_options['record_owner'] = isset( $_definition->plugin_options['record_owner'] ) ?
149
+		$plugin_options['record_owner'] = isset($_definition->plugin_options['record_owner']) ?
150 150
 			$_definition->plugin_options['record_owner'] : $this->user;
151 151
 		$_definition->plugin_options = $plugin_options;
152 152
 
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 		);
161 161
 
162 162
 		// Status need leading spaces removed
163
-		foreach($lookups['ts_status'] as $id => &$label)
163
+		foreach ($lookups['ts_status'] as $id => &$label)
164 164
 		{
165
-			$label = str_replace('&nbsp;', '',trim($label));
166
-			if($label == '') unset($lookups['ts_status'][$id]);
165
+			$label = str_replace('&nbsp;', '', trim($label));
166
+			if ($label == '') unset($lookups['ts_status'][$id]);
167 167
 		}
168 168
 
169 169
 		// Start counting successes
@@ -173,27 +173,27 @@  discard block
 block discarded – undo
173 173
 		// Failures
174 174
 		$this->errors = array();
175 175
 
176
-		while ( $record = $import_csv->get_record() )
176
+		while ($record = $import_csv->get_record())
177 177
 		{
178 178
 			$success = false;
179 179
 
180 180
 			// don't import empty records
181
-			if( count( array_unique( $record ) ) < 2 ) continue;
181
+			if (count(array_unique($record)) < 2) continue;
182 182
 
183 183
 			$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
184
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
184
+			if ($result) $this->warnings[$import_csv->get_current_position()] = $result;
185 185
 
186 186
 			// Automatically handle text Api\Categories without explicit Api\Translation
187
-			foreach(array('ts_status','cat_id') as $field)
187
+			foreach (array('ts_status', 'cat_id') as $field)
188 188
 			{
189
-				if(!is_numeric($record[$field]))
189
+				if (!is_numeric($record[$field]))
190 190
 				{
191
-					$translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id');
192
-					if(!is_null($lookups[$field]) && ($key = array_search($record[$field], $lookups[$field])))
191
+					$translate_key = 'translate'.(substr($field, 0, 2) == 'ts' ? substr($field, 2) : '_cat_id');
192
+					if (!is_null($lookups[$field]) && ($key = array_search($record[$field], $lookups[$field])))
193 193
 					{
194 194
 						$record[$field] = $key;
195 195
 					}
196
-					elseif(array_key_exists($translate_key, $_definition->plugin_options))
196
+					elseif (array_key_exists($translate_key, $_definition->plugin_options))
197 197
 					{
198 198
 						$t_field = $_definition->plugin_options[$translate_key];
199 199
 						switch ($t_field)
@@ -206,35 +206,35 @@  discard block
 block discarded – undo
206 206
 							case '~skip~':
207 207
 								continue 2;
208 208
 							default:
209
-								if(strpos($t_field, 'add') === 0)
209
+								if (strpos($t_field, 'add') === 0)
210 210
 								{
211 211
 									// Check for a parent
212
-									list($name, $parent_name) = explode('~',$t_field);
213
-									if($parent_name)
212
+									list($name, $parent_name) = explode('~', $t_field);
213
+									if ($parent_name)
214 214
 									{
215 215
 										$parent = importexport_helper_functions::cat_name2id($parent_name);
216 216
 									}
217 217
 
218
-									if($field == 'cat_id')
218
+									if ($field == 'cat_id')
219 219
 									{
220 220
 										$record[$field] = importexport_helper_functions::cat_name2id($record[$field], $parent);
221 221
 									}
222 222
 									elseif ($field == 'ts_status')
223 223
 									{
224 224
 										end($this->bo->status_labels);
225
-										$id = key($this->bo->status_labels)+1;
225
+										$id = key($this->bo->status_labels) + 1;
226 226
 										$this->bo->status_labels[$id] = $record[$field];
227 227
 										$this->bo->status_labels_config[$id] = array(
228 228
 											'name'   => $record[$field],
229 229
 											'parent' => $parent,
230 230
 											'admin'  => false
231 231
 										);
232
-										Api\Config::save_value('status_labels',$this->bo->status_labels_config,TIMESHEET_APP);
232
+										Api\Config::save_value('status_labels', $this->bo->status_labels_config, TIMESHEET_APP);
233 233
 										$lookups[$field][$id] = $name;
234 234
 										$record[$field] = $id;
235 235
 									}
236 236
 								}
237
-								elseif(!is_null($lookups[$field]) && ($key = array_search($t_field, $lookups[$field])))
237
+								elseif (!is_null($lookups[$field]) && ($key = array_search($t_field, $lookups[$field])))
238 238
 								{
239 239
 									$record[$field] = $key;
240 240
 								}
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
 			}
250 250
 
251 251
 			// Set creator, unless it's supposed to come from CSV file
252
-			if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner'])
252
+			if ($_definition->plugin_options['owner_from_csv'] && $record['ts_owner'])
253 253
 			{
254
-				if(!is_numeric($record['ts_owner']))
254
+				if (!is_numeric($record['ts_owner']))
255 255
 				{
256 256
 					// Automatically handle text owner without explicit Api\Translation
257 257
 					$new_owner = importexport_helper_functions::account_name2id($record['ts_owner']);
258
-					if($new_owner == '')
258
+					if ($new_owner == '')
259 259
 					{
260 260
 						$this->errors[$import_csv->get_current_position()] = lang(
261 261
 							'Unable to convert "%1" to account ID.  Using plugin setting (%2) for %3.',
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 
279 279
 			// Check account IDs
280
-			foreach(array('ts_modifier') as $field)
280
+			foreach (array('ts_modifier') as $field)
281 281
 			{
282
-				if($record[$field] && !is_numeric($record[$field]))
282
+				if ($record[$field] && !is_numeric($record[$field]))
283 283
 				{
284 284
 					// Try an automatic conversion
285 285
 					$account_id = importexport_helper_functions::account_name2id($record[$field]);
286
-					if($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field]))
286
+					if ($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field]))
287 287
 					{
288 288
 						$record[$field] = $account_id;
289 289
 					}
@@ -302,49 +302,49 @@  discard block
 block discarded – undo
302 302
 			// Special values
303 303
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
304 304
 			{
305
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
306
-				$record['addressbook'] = self::addr_id($lastname,$firstname,$org_name);
305
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
306
+				$record['addressbook'] = self::addr_id($lastname, $firstname, $org_name);
307 307
 			}
308 308
 			if ($record['pm_id'] && !is_numeric($record['pm_id']))
309 309
 			{
310
-				$pms = Link::query('projectmanager',$record['pm_id']);
310
+				$pms = Link::query('projectmanager', $record['pm_id']);
311 311
 				$record['pm_id'] = key($pms);
312 312
 			}
313 313
 
314
-			if ( $_definition->plugin_options['conditions'] )
314
+			if ($_definition->plugin_options['conditions'])
315 315
 			{
316
-				foreach ( $_definition->plugin_options['conditions'] as $condition )
316
+				foreach ($_definition->plugin_options['conditions'] as $condition)
317 317
 				{
318 318
 					$results = array();
319
-					switch ( $condition['type'] )
319
+					switch ($condition['type'])
320 320
 					{
321 321
 						// exists
322 322
 						case 'exists' :
323
-							if($record[$condition['string']])
323
+							if ($record[$condition['string']])
324 324
 							{
325 325
 								$results = $this->bo->search(array($condition['string'] => $record[$condition['string']]));
326 326
 							}
327 327
 
328
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1 )
328
+							if (is_array($results) && count(array_keys($results)) >= 1)
329 329
 							{
330 330
 								// apply action to all records matching this exists condition
331 331
 								$action = $condition['true'];
332
-								foreach ( (array)$results as $result )
332
+								foreach ((array)$results as $result)
333 333
 								{
334 334
 									$record['ts_id'] = $result['ts_id'];
335
-									if ( $_definition->plugin_options['update_cats'] == 'add' )
335
+									if ($_definition->plugin_options['update_cats'] == 'add')
336 336
 									{
337
-										if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] );
338
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
339
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) );
337
+										if (!is_array($result['cat_id'])) $result['cat_id'] = explode(',', $result['cat_id']);
338
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
339
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $result['cat_id'])));
340 340
 									}
341
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
341
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
342 342
 								}
343 343
 							}
344 344
 							else
345 345
 							{
346 346
 								$action = $condition['false'];
347
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
347
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
348 348
 							}
349 349
 							break;
350 350
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 			else
360 360
 			{
361 361
 				// unconditional insert
362
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
362
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
363 363
 			}
364
-			if($success) $count++;
364
+			if ($success) $count++;
365 365
 		}
366 366
 		return $count;
367 367
 	}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @param array $_data tracker data for the action
374 374
 	 * @return bool success or not
375 375
 	 */
376
-	private function action ( $_action, $_data, $record_num = 0 )
376
+	private function action($_action, $_data, $record_num = 0)
377 377
 	{
378 378
 		$result = true;
379 379
 		switch ($_action)
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				$old_record = new timesheet_egw_record($_data['ts_id']);
386 386
 				$old = $old_record->get_record_array();
387 387
 
388
-				if(!$this->definition->plugin_options['change_owner'])
388
+				if (!$this->definition->plugin_options['change_owner'])
389 389
 				{
390 390
 					// Don't change creator of an existing ticket
391 391
 					unset($_data['ts_owner']);
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 				// Merge to deal with fields not in import record
395 395
 				$_data = array_merge($old, $_data);
396 396
 				$changed = $this->tracking->changed_fields($_data, $old);
397
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
397
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
398 398
 				{
399 399
 					break;
400 400
 				}
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
 				// Clear old link, if different
403 403
 				if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id'])
404 404
 				{
405
-					Link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']);
405
+					Link::unlink2(0, TIMESHEET_APP, $_data['ts_id'], 0, 'projectmanager', $old['pm_id']);
406 406
 				}
407 407
 
408 408
 				// Fall through
409 409
 			case 'insert' :
410
-				if ( $this->dry_run )
410
+				if ($this->dry_run)
411 411
 				{
412 412
 					//print_r($_data);
413 413
 					$this->results[$_action]++;
@@ -415,24 +415,24 @@  discard block
 block discarded – undo
415 415
 				}
416 416
 				else
417 417
 				{
418
-					$result = $this->bo->save( $_data);
418
+					$result = $this->bo->save($_data);
419 419
 					$_data['ts_id'] = $this->bo->data['ts_id'];
420 420
 
421 421
 					// Set projectmanager link
422 422
 					if ($_data['pm_id'])
423 423
 					{
424
-						Link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']);
424
+						Link::link(TIMESHEET_APP, $_data['ts_id'], 'projectmanager', $_data['pm_id']);
425 425
 
426 426
 						// notify the link-class about the update, as other apps may be subscribed to it
427
-						Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
427
+						Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data);
428 428
 					}
429 429
 
430
-					if($result)
430
+					if ($result)
431 431
 					{
432 432
 						$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
433 433
 							$GLOBALS['egw']->accounts->id2name($_data['owner']),
434 434
 							lang($_action)
435
-						) . ' ' . $result;
435
+						).' '.$result;
436 436
 					}
437 437
 					else
438 438
 					{
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
 		}
447 447
 
448 448
 		// Process some additional fields
449
-		if(!is_numeric($result))
449
+		if (!is_numeric($result))
450 450
 		{
451 451
 			return $result;
452 452
 		}
453 453
 		$_link_id = false;
454
-		foreach(self::$special_fields as $field => $desc)
454
+		foreach (self::$special_fields as $field => $desc)
455 455
 		{
456
-			if(!$_data[$field]) continue;
456
+			if (!$_data[$field]) continue;
457 457
 
458 458
 			// Links
459
-			if(strpos($field, 'link') === 0)
459
+			if (strpos($field, 'link') === 0)
460 460
 			{
461 461
 				list($app, $app_id) = explode(':', $_data[$field]);
462 462
 			}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			}
468 468
 			if ($app && $app_id)
469 469
 			{
470
-				$link_id = Link::link('timesheet',$_data['ts_id'],$app,$app_id);
470
+				$link_id = Link::link('timesheet', $_data['ts_id'], $app, $app_id);
471 471
 			}
472 472
 		}
473 473
 		return true;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 * 		preserv		=> array,
516 516
 	 * )
517 517
 	 */
518
-	public function get_options_etpl(importexport_definition &$definition=null)
518
+	public function get_options_etpl(importexport_definition &$definition = null)
519 519
 	{
520 520
 		// lets do it!
521 521
 	}
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	// end of iface_export_plugin
572 572
 
573 573
 	// Extra conversion functions - must be static
574
-	public static function addr_id( $n_family,$n_given=null,$org_name=null )
574
+	public static function addr_id($n_family, $n_given = null, $org_name = null)
575 575
 	{
576 576
 
577 577
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
@@ -582,18 +582,18 @@  discard block
 block discarded – undo
582 582
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
583 583
 		}
584 584
 		$n_family = trim($n_family);
585
-		if(!is_null($n_given)) $n_given = trim($n_given);
585
+		if (!is_null($n_given)) $n_given = trim($n_given);
586 586
 		if (!is_object($contacts))
587 587
 		{
588
-			$contacts =& CreateObject('phpgwapi.contacts');
588
+			$contacts = & CreateObject('phpgwapi.contacts');
589 589
 		}
590 590
 		if (!is_null($org_name))        // org_name given?
591 591
 		{
592 592
 			$org_name = trim($org_name);
593
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
593
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
594 594
 			if (!count($addrs))
595 595
 			{
596
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
596
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
597 597
 			}
598 598
 		}
599 599
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		}
603 603
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
604 604
 		{
605
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
605
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
606 606
 		}
607 607
 		if (count($addrs))
608 608
 		{
Please login to merge, or discard this patch.
api/src/Html/htmLawed/htmLawedTest.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
    $j = 0;  
120 120
    // Add newline   
121 121
    if ($i !== $len-1){
122
-    echo "\n";
122
+	echo "\n";
123 123
    }
124 124
   }
125 125
  }
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
   if(!empty($v[4])){ // + input text box
545 545
    echo '<input type="radio" name="h', $k, '" value="', $j, '"', (((isset($_POST['h'. $k]) && $_POST['h'. $k] == $j) or (!isset($_POST['h'. $k]) && $j == $v[1])) ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
546 546
    if(!is_array($v[4])){
547
-    echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k. $j, '" value="', htmlspecialchars(isset($_POST['h'. $k. $j][0]) ? $_POST['h'. $k. $j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
547
+	echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k. $j, '" value="', htmlspecialchars(isset($_POST['h'. $k. $j][0]) ? $_POST['h'. $k. $j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
548 548
    }
549 549
    else{
550
-    foreach($v[4] as $z){
551
-     echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k. $j. $z[1], '" value="', htmlspecialchars(isset($_POST['h'. $k. $j. $z[1]][0]) ? $_POST['h'. $k. $j. $z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
552
-    }    
550
+	foreach($v[4] as $z){
551
+	 echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k. $j. $z[1], '" value="', htmlspecialchars(isset($_POST['h'. $k. $j. $z[1]][0]) ? $_POST['h'. $k. $j. $z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
552
+	}    
553 553
    }
554 554
   }
555 555
  }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $_slife = 30; // session life in min.
23 23
 
24 24
 // errors
25
-error_reporting(E_ALL | (defined('E_STRICT') ? E_STRICT : 0));
25
+error_reporting(E_ALL|(defined('E_STRICT') ? E_STRICT : 0));
26 26
 ini_set('display_errors', $_errs);
27 27
 
28 28
 // session
@@ -33,60 +33,60 @@  discard block
 block discarded – undo
33 33
 ini_set('session.use_only_cookies', 1);
34 34
 ini_set('session.cookie_lifetime', 0);
35 35
 session_start();
36
-if(!isset($_SESSION['token'])){
36
+if (!isset($_SESSION['token'])) {
37 37
  $_SESSION['token'] = md5(uniqid(rand(), 1));
38 38
 }
39 39
 
40 40
 // slashes
41
-if(get_magic_quotes_gpc()){
42
- foreach($_POST as $k => $v){
41
+if (get_magic_quotes_gpc()) {
42
+ foreach ($_POST as $k => $v) {
43 43
   $_POST[$k] = stripslashes($v);
44 44
  }
45 45
  ini_set('magic_quotes_gpc', 0);
46 46
 }
47
-if(get_magic_quotes_runtime()){
47
+if (get_magic_quotes_runtime()) {
48 48
  set_magic_quotes_runtime(0);
49 49
 }
50 50
 
51 51
 $_POST['enc'] = (isset($_POST['enc']) and preg_match('`^[-\w]+$`', $_POST['enc'])) ? $_POST['enc'] : 'utf-8';
52 52
 
53 53
 // token for anti-CSRF
54
-if(count($_POST)){
55
- if((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id())){
54
+if (count($_POST)) {
55
+ if ((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id())) {
56 56
   $_POST = array('enc'=>'utf-8');
57 57
  }
58 58
 }
59
-if(empty($_GET['pre'])){
59
+if (empty($_GET['pre'])) {
60 60
  $_SESSION['token'] = md5(uniqid(rand(), 1));
61 61
  $token = $_SESSION['token'];
62 62
  session_regenerate_id(1);
63 63
 }
64 64
 
65 65
 // compress
66
-if(function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression')){
66
+if (function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression')) {
67 67
  ob_start('ob_gzhandler');
68 68
 }
69 69
 
70 70
 // HTM for unprocessed
71
-if(isset($_POST['inputH'])){
71
+if (isset($_POST['inputH'])) {
72 72
  echo '<html><head><title>htmLawed test: HTML view of unprocessed input</title></head><body style="margin:0; padding: 0;"><p style="background-color: black; color: white; padding: 2px;">&nbsp; Rendering of unprocessed input without an HTML doctype or charset declaration &nbsp; &nbsp; <small><a style="color: white; text-decoration: none;" href="1" onclick="javascript:window.close(this); return false;">close window</a> | <a style="color: white; text-decoration: none;" href="htmLawedTest.php" onclick="javascript: window.open(\'htmLawedTest.php\', \'hlmain\'); window.close(this); return false;">htmLawed test page</a></small></p><div>', $_POST['inputH'], '</div></body></html>';
73 73
  exit;
74 74
 }
75 75
 
76 76
 // main
77
-$_POST['text'] = isset($_POST['text']) ? $_POST['text'] : 'text to process; < '. $_limit. ' characters'. ($_hlimit ? ' (for binary hexdump view, < '. $_hlimit. ')' : '');
77
+$_POST['text'] = isset($_POST['text']) ? $_POST['text'] : 'text to process; < '.$_limit.' characters'.($_hlimit ? ' (for binary hexdump view, < '.$_hlimit.')' : '');
78 78
 $do = (!empty($_POST[$_sid]) && isset($_POST['text'][0]) && !isset($_POST['text'][$_limit])) ? 1 : 0;
79 79
 $limit_exceeded = isset($_POST['text'][$_limit]) ? 1 : 0;
80 80
 $pre_mem = memory_get_usage();
81 81
 $validation = (!empty($_POST[$_sid]) and isset($_POST['w3c_validate'][0])) ? 1 : 0;
82 82
 include './htmLawed.php';
83 83
 
84
-function format($t){
85
- $t = "\n". str_replace(array("\t", "\r\n", "\r", '&', '<', '>', "\n"), array('    ', "\n", "\n", '&amp;', '&lt;', '&gt;', "<span class=\"newline\">&#172;</span><br />\n"), $t);
84
+function format($t) {
85
+ $t = "\n".str_replace(array("\t", "\r\n", "\r", '&', '<', '>', "\n"), array('    ', "\n", "\n", '&amp;', '&lt;', '&gt;', "<span class=\"newline\">&#172;</span><br />\n"), $t);
86 86
  return str_replace(array('<br />', "\n ", '  '), array("\n<br />\n", "\n&nbsp;", ' &nbsp;'), $t);
87 87
 }
88 88
 
89
-function hexdump($d){
89
+function hexdump($d) {
90 90
 // Mainly by Aidan Lister <[email protected]>, Peter Waller <[email protected]>
91 91
  $hexi = '';
92 92
  $ascii = '';
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
  echo '<pre>';
95 95
  $offset = 0;
96 96
  $len = strlen($d);
97
- for($i=$j=0; $i<$len; $i++)
97
+ for ($i = $j = 0; $i < $len; $i++)
98 98
  {
99 99
   // Convert to hexidecimal
100 100
   $hexi .= sprintf("%02X ", ord($d[$i]));
101 101
   // Replace non-viewable bytes with '.'
102
-  if(ord($d[$i]) >= 32){
102
+  if (ord($d[$i]) >= 32) {
103 103
    $ascii .= htmlspecialchars($d[$i]);
104
-  }else{
104
+  } else {
105 105
    $ascii .= '.';
106 106
   } 
107 107
   // Add extra column spacing
108
-  if($j == 7){
108
+  if ($j == 7) {
109 109
    $hexi .= ' ';
110 110
    $ascii .= '  ';
111 111
   }
112 112
   // Add row
113
-  if(++$j == 16 || $i == $len-1){
113
+  if (++$j == 16 || $i == $len - 1) {
114 114
    // Join the hexi / ascii output
115 115
    echo sprintf("%04X   %-49s   %s", $offset, $hexi, $ascii);   
116 116
    // Reset vars
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
    $offset += 16;
119 119
    $j = 0;  
120 120
    // Add newline   
121
-   if ($i !== $len-1){
121
+   if ($i !== $len - 1) {
122 122
     echo "\n";
123 123
    }
124 124
   }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 <html lang="en" xml:lang="en">
136 136
 <head>
137 137
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
138
-<meta name="description" content="htmLawed <?php echo hl_version();?> test page" />
138
+<meta name="description" content="htmLawed <?php echo hl_version(); ?> test page" />
139 139
 <style type="text/css"><!--/*--><![CDATA[/*><!--*/
140 140
 a, a.resizer{text-decoration:none;}
141 141
 a:hover, a.resizer:hover{color:red;}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 <script type="text/javascript"><!--//--><![CDATA[//><!-- 
170 170
 window.name = 'hlmain';
171 171
 function hl(i){
172
- <?php if(!$_hilite){echo 'return;'; }?>
172
+ <?php if (!$_hilite) {echo 'return;'; }?>
173 173
  var e = document.getElementById(i);
174 174
  if(!e){return;}
175 175
  run(e, '</[a-z1-6]+>', 'ctag');
@@ -432,27 +432,27 @@  discard block
 block discarded – undo
432 432
 var dmp = new diff_match_patch(); function diffLaunch(){var text1 = document.getElementById('text').value; var text2 = document.getElementById('text2').value; dmp.Diff_Timeout = 0; dmp.Diff_EditCost = 4; var d = dmp.diff_main(text1, text2); var ds = dmp.diff_prettyHtml(d); document.getElementById('diff').innerHTML = ds;
433 433
 }
434 434
 //--><!]]></script>
435
-<title>htmLawed (<?php echo hl_version();?>) test</title>
435
+<title>htmLawed (<?php echo hl_version(); ?>) test</title>
436 436
 </head>
437 437
 <body>
438 438
 <div id="topmost">
439 439
 
440
-<h5 style="float: left; display: inline; margin-top: 0; margin-bottom: 5px;"><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php" title="htmLawed home">HTM<big><big>L</big></big>AWED</a> <?php echo hl_version();?> <a href="htmLawedTest.php" title="test home">TEST</a></h5>
440
+<h5 style="float: left; display: inline; margin-top: 0; margin-bottom: 5px;"><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php" title="htmLawed home">HTM<big><big>L</big></big>AWED</a> <?php echo hl_version(); ?> <a href="htmLawedTest.php" title="test home">TEST</a></h5>
441 441
 <span style="float: right;" class="help"><a href="htmLawed_README.htm"><span class="notice">htm</span></a> / <a href="htmLawed_README.txt"><span class="notice">txt</span></a> documentation</span><br style="clear:both;" />
442 442
 
443
-<a href="htmLawedTest.php" title="[toggle visibility] type or copy-paste" onclick="javascript:toggle('inputF'); return false;"><span class="notice">Input &raquo;</span> <span class="help" title="limit lower with multibyte characters<?php echo (($_hlimit < $_limit && $_hlimit)? '; limit is '. $_hlimit. ' for viewing binaries' : ''); ?>"><small>(max. <?php echo htmlspecialchars($_limit);?> chars)</small></span></a>
443
+<a href="htmLawedTest.php" title="[toggle visibility] type or copy-paste" onclick="javascript:toggle('inputF'); return false;"><span class="notice">Input &raquo;</span> <span class="help" title="limit lower with multibyte characters<?php echo (($_hlimit < $_limit && $_hlimit) ? '; limit is '.$_hlimit.' for viewing binaries' : ''); ?>"><small>(max. <?php echo htmlspecialchars($_limit); ?> chars)</small></span></a>
444 444
 
445 445
 <form id="testform" name="testform" action="htmLawedTest.php" method="post" accept-charset="<?php echo htmlspecialchars($_POST['enc']); ?>" style="padding:0; margin: 0; display:inline;">
446 446
 
447 447
 <div id="inputF" style="display: block;">
448 448
 
449 449
 <input type="hidden" name="token" id="token" value="<?php echo $token; ?>" />
450
-<div><textarea id="text" class="textarea" name="text" rows="5" cols="100" style="width: 100%;"><?php echo htmlspecialchars($_POST['text']);?></textarea></div>
450
+<div><textarea id="text" class="textarea" name="text" rows="5" cols="100" style="width: 100%;"><?php echo htmlspecialchars($_POST['text']); ?></textarea></div>
451 451
 <input type="submit" id="submitF" name="submitF" value="Process" style="float:left;" title="filter using htmLawed" onclick="javascript: sndProc(); return false;" onkeypress="javascript: sndProc(); return false;" />
452 452
 
453 453
 <?php
454
-if($do){
455
- if($validation){
454
+if ($do) {
455
+ if ($validation) {
456 456
   echo '<input type="hidden" value="1" name="w3c_validate" id="w3c_validate" />';
457 457
  }
458 458
 ?>
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 <button type="button" onclick="javascript:document.getElementById('text').focus();document.getElementById('text').select()" title="select all to copy" style="float:right;">Select all</button>
462 462
 
463 463
 <?php
464
-if($_w3c_validate && $validation){
464
+if ($_w3c_validate && $validation) {
465 465
 ?>
466 466
   
467 467
 <button type="button" title="HTML 4.01 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text', 'html401'); return false;" onkeypress="javascript: sndValidn('text', 'html401'); return false;">Check HTML</button>
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 <?php
471 471
  }
472 472
 }
473
-else{
474
- if($_w3c_validate){
473
+else {
474
+ if ($_w3c_validate) {
475 475
   echo '<span style="float: right;" class="help" title="for direct submission of input or output code to W3C validator for (X)HTML validation"><span style="font-size: 85%;">&nbsp;Validator tools: </span><input type="checkbox" value="1" name="w3c_validate" id="w3c_validate" style="vertical-align: middle;"', ($validation ? ' checked="checked"' : ''), ' /></span>';
476 476
  }
477 477
 }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 <br style="clear:both;" />
484 484
 
485 485
 <?php
486
-if($limit_exceeded){
486
+if ($limit_exceeded) {
487 487
  echo '<br /><strong>Input text is too long!</strong><br />';
488 488
 }
489 489
 ?>
@@ -531,32 +531,32 @@  discard block
 block discarded – undo
531 531
 'valid_xhtml'=>array('2', 'nil', 'auto-set various parameters for most valid XHTML', 'nil'),
532 532
 'xml:lang'=>array('3', 'nil', 'auto-add <em>xml:lang</em> attribute', '0'),
533 533
 );
534
-foreach($cfg as $k=>$v){
534
+foreach ($cfg as $k=>$v) {
535 535
  echo '<li>', $k, ': ';
536
- if(!empty($v[0])){ // input radio
536
+ if (!empty($v[0])) { // input radio
537 537
   $j = $v[3];
538
-  for($i = $j-1; ++$i < $v[0]+$v[3];++$j){
539
-   echo '<input type="radio" name="h', $k, '" value="', $i, '"', (!isset($_POST['h'. $k]) ? ($v[1] == $i ? ' checked="checked"' : '') : ($_POST['h'. $k] == $i ? ' checked="checked"' : '')), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />', $i, ' ';
538
+  for ($i = $j - 1; ++$i < $v[0] + $v[3]; ++$j) {
539
+   echo '<input type="radio" name="h', $k, '" value="', $i, '"', (!isset($_POST['h'.$k]) ? ($v[1] == $i ? ' checked="checked"' : '') : ($_POST['h'.$k] == $i ? ' checked="checked"' : '')), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />', $i, ' ';
540 540
   }
541
-  if($v[1] == 'nil'){
542
-   echo '<input type="radio" name="h', $k, '" value="nil"', ((!isset($_POST['h'. $k]) or $_POST['h'. $k] == 'nil') ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />not set ';
541
+  if ($v[1] == 'nil') {
542
+   echo '<input type="radio" name="h', $k, '" value="nil"', ((!isset($_POST['h'.$k]) or $_POST['h'.$k] == 'nil') ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />not set ';
543 543
   }
544
-  if(!empty($v[4])){ // + input text box
545
-   echo '<input type="radio" name="h', $k, '" value="', $j, '"', (((isset($_POST['h'. $k]) && $_POST['h'. $k] == $j) or (!isset($_POST['h'. $k]) && $j == $v[1])) ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
546
-   if(!is_array($v[4])){
547
-    echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k. $j, '" value="', htmlspecialchars(isset($_POST['h'. $k. $j][0]) ? $_POST['h'. $k. $j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
544
+  if (!empty($v[4])) { // + input text box
545
+   echo '<input type="radio" name="h', $k, '" value="', $j, '"', (((isset($_POST['h'.$k]) && $_POST['h'.$k] == $j) or (!isset($_POST['h'.$k]) && $j == $v[1])) ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
546
+   if (!is_array($v[4])) {
547
+    echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k.$j, '" value="', htmlspecialchars(isset($_POST['h'.$k.$j][0]) ? $_POST['h'.$k.$j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
548 548
    }
549
-   else{
550
-    foreach($v[4] as $z){
551
-     echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k. $j. $z[1], '" value="', htmlspecialchars(isset($_POST['h'. $k. $j. $z[1]][0]) ? $_POST['h'. $k. $j. $z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
549
+   else {
550
+    foreach ($v[4] as $z) {
551
+     echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k.$j.$z[1], '" value="', htmlspecialchars(isset($_POST['h'.$k.$j.$z[1]][0]) ? $_POST['h'.$k.$j.$z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
552 552
     }    
553 553
    }
554 554
   }
555 555
  }
556
- elseif(ctype_digit($v[3])){ // input text
557
-  echo '<input type="text" size="', $v[3], '" name="h', $k, '" value="', htmlspecialchars(isset($_POST['h'. $k][0]) ? $_POST['h'. $k] : $v[1]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';  
556
+ elseif (ctype_digit($v[3])) { // input text
557
+  echo '<input type="text" size="', $v[3], '" name="h', $k, '" value="', htmlspecialchars(isset($_POST['h'.$k][0]) ? $_POST['h'.$k] : $v[1]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';  
558 558
  }
559
- else{} // text-area
559
+ else {} // text-area
560 560
  echo ' <span class="help">', $v[2], '</span></li>';
561 561
 }
562 562
 echo '</ul></td></tr><tr><td><span style="vertical-align: top;" class="help" title="$spec argument: element-specific attribute rules">Spec:</span></td><td><textarea name="spec" id="spec" cols="70" rows="3" style="width:80%;">', htmlspecialchars((isset($_POST['spec']) ? $_POST['spec'] : '')), '</textarea></td></tr></table>';
@@ -566,31 +566,31 @@  discard block
 block discarded – undo
566 566
 </form>
567 567
 
568 568
 <?php
569
-if($do){
569
+if ($do) {
570 570
  $cfg = array();
571
- foreach($_POST as $k=>$v){
572
-  if($k[0] == 'h' && $v != 'nil'){
571
+ foreach ($_POST as $k=>$v) {
572
+  if ($k[0] == 'h' && $v != 'nil') {
573 573
    $cfg[substr($k, 1)] = $v;
574 574
   }
575 575
  }
576 576
 
577
- if(isset($cfg['anti_link_spam']) && $cfg['anti_link_spam'] && (!empty($cfg['anti_link_spam11']) or !empty($cfg['anti_link_spam12']))){
577
+ if (isset($cfg['anti_link_spam']) && $cfg['anti_link_spam'] && (!empty($cfg['anti_link_spam11']) or !empty($cfg['anti_link_spam12']))) {
578 578
   $cfg['anti_link_spam'] = array($cfg['anti_link_spam11'], $cfg['anti_link_spam12']);
579 579
  }
580 580
  unset($cfg['anti_link_spam11'], $cfg['anti_link_spam12']);
581
- if(isset($cfg['anti_mail_spam']) && $cfg['anti_mail_spam'] == 1){
581
+ if (isset($cfg['anti_mail_spam']) && $cfg['anti_mail_spam'] == 1) {
582 582
   $cfg['anti_mail_spam'] = isset($cfg['anti_mail_spam1'][0]) ? $cfg['anti_mail_spam1'] : 0;
583 583
  }
584 584
  unset($cfg['anti_mail_spam11']);
585
- if(isset($cfg['deny_attribute']) && $cfg['deny_attribute'] == 1){
585
+ if (isset($cfg['deny_attribute']) && $cfg['deny_attribute'] == 1) {
586 586
   $cfg['deny_attribute'] = isset($cfg['deny_attribute1'][0]) ? $cfg['deny_attribute1'] : 0;
587 587
  }
588 588
  unset($cfg['deny_attribute1']);
589
- if(isset($cfg['tidy']) && $cfg['tidy'] == 2){
589
+ if (isset($cfg['tidy']) && $cfg['tidy'] == 2) {
590 590
   $cfg['tidy'] = isset($cfg['tidy2'][0]) ? $cfg['tidy2'] : 0;
591 591
  }
592 592
  unset($cfg['tidy2']);
593
- if(isset($cfg['unique_ids']) && $cfg['unique_ids'] == 2){
593
+ if (isset($cfg['unique_ids']) && $cfg['unique_ids'] == 2) {
594 594
   $cfg['unique_ids'] = isset($cfg['unique_ids2'][0]) ? $cfg['unique_ids2'] : 1;
595 595
  }
596 596
  unset($cfg['unique_ids2']);
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
  $st = microtime(); 
601 601
  $out = htmLawed($_POST['text'], $cfg, $_POST['spec']);
602 602
  $et = microtime();
603
- echo '<br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'inputR\'); return false;"><span class="notice">Input code &raquo;</span></a> <span class="help" title="tags estimated as half of total &gt; and &lt; chars; values may be inaccurate for non-ASCII text"><small><big>', strlen($_POST['text']), '</big> chars, ~<big>', ($tag = round((substr_count($_POST['text'], '>') + substr_count($_POST['text'], '<'))/2)), '</big> tag', ($tag > 1 ? 's' : ''), '</small>&nbsp;</span><div id="inputR" style="display: none;">', format($_POST['text']), '</div><script type="text/javascript">hl(\'inputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'inputD\'); return false;"><span class="notice">Input binary &raquo;&nbsp;</span></a><div id="inputD" style="display: none;">'. hexdump($_POST['text']). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] finalized internal settings as interpreted by htmLawed; for developers" onclick="javascript:toggle(\'settingF\'); return false;"><span class="notice">Finalized internal settings &raquo;&nbsp;</span></a> <div id="settingF" style="display: none;">$config: ', str_replace(array('    ', "\t", '  '), array('  ', '&nbsp;  ', '&nbsp; '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['config'], true)))), '<br />$spec: ', str_replace(array('    ', "\t", '  '), array('  ', '&nbsp;  ', '&nbsp; '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['spec'], true)))), '</div><script type="text/javascript">hl(\'settingF\');</script>', '<br /><a href="htmLawedTest.php" title="[toggle visibility] suitable for copy-paste" onclick="javascript:toggle(\'outputF\'); return false;"><span class="notice">Output &raquo;</span></a> <span class="help" title="approx., server-specific value excluding the \'include()\' call"><small>htmLawed processing time <big>', number_format(((substr($et,0,9)) + (substr($et,-10)) - (substr($st,0,9)) - (substr($st,-10))),4), '</big> s</small></span>', (($mem = memory_get_peak_usage()) !== false ? '<span class="help"><small>, peak memory usage <big>'. round(($mem-$pre_mem)/1048576, 2). '</big> <small>MB</small>' : ''), '</small></span><div id="outputF"  style="display: block;"><div><textarea id="text2" class="textarea" name="text2" rows="5" cols="100" style="width: 100%;">', htmlspecialchars($out), '</textarea></div><button type="button" onclick="javascript:document.getElementById(\'text2\').focus();document.getElementById(\'text2\').select()" title="select all to copy" style="float:right;">Select all</button>';
604
- if($_w3c_validate && $validation)
603
+ echo '<br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'inputR\'); return false;"><span class="notice">Input code &raquo;</span></a> <span class="help" title="tags estimated as half of total &gt; and &lt; chars; values may be inaccurate for non-ASCII text"><small><big>', strlen($_POST['text']), '</big> chars, ~<big>', ($tag = round((substr_count($_POST['text'], '>') + substr_count($_POST['text'], '<')) / 2)), '</big> tag', ($tag > 1 ? 's' : ''), '</small>&nbsp;</span><div id="inputR" style="display: none;">', format($_POST['text']), '</div><script type="text/javascript">hl(\'inputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'inputD\'); return false;"><span class="notice">Input binary &raquo;&nbsp;</span></a><div id="inputD" style="display: none;">'.hexdump($_POST['text']).'</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] finalized internal settings as interpreted by htmLawed; for developers" onclick="javascript:toggle(\'settingF\'); return false;"><span class="notice">Finalized internal settings &raquo;&nbsp;</span></a> <div id="settingF" style="display: none;">$config: ', str_replace(array('    ', "\t", '  '), array('  ', '&nbsp;  ', '&nbsp; '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['config'], true)))), '<br />$spec: ', str_replace(array('    ', "\t", '  '), array('  ', '&nbsp;  ', '&nbsp; '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['spec'], true)))), '</div><script type="text/javascript">hl(\'settingF\');</script>', '<br /><a href="htmLawedTest.php" title="[toggle visibility] suitable for copy-paste" onclick="javascript:toggle(\'outputF\'); return false;"><span class="notice">Output &raquo;</span></a> <span class="help" title="approx., server-specific value excluding the \'include()\' call"><small>htmLawed processing time <big>', number_format(((substr($et, 0, 9)) + (substr($et, -10)) - (substr($st, 0, 9)) - (substr($st, -10))), 4), '</big> s</small></span>', (($mem = memory_get_peak_usage()) !== false ? '<span class="help"><small>, peak memory usage <big>'.round(($mem - $pre_mem) / 1048576, 2).'</big> <small>MB</small>' : ''), '</small></span><div id="outputF"  style="display: block;"><div><textarea id="text2" class="textarea" name="text2" rows="5" cols="100" style="width: 100%;">', htmlspecialchars($out), '</textarea></div><button type="button" onclick="javascript:document.getElementById(\'text2\').focus();document.getElementById(\'text2\').select()" title="select all to copy" style="float:right;">Select all</button>';
604
+ if ($_w3c_validate && $validation)
605 605
  {
606 606
 ?>
607 607
   
@@ -610,9 +610,9 @@  discard block
 block discarded – undo
610 610
   
611 611
 <?php
612 612
  }
613
- echo '</div><br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'outputR\'); return false;"><span class="notice">Output code &raquo;</span></a><div id="outputR" style="display: block;">', format($out), '</div><script type="text/javascript">hl(\'outputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'outputD\'); return false;"><span class="notice">Output binary &raquo;</span></a><div id="outputD" style="display: none;">'. hexdump($out). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] inline output-input diff; might not be perfectly accurate, semantically or otherwise " onclick="javascript:toggle(\'diff\'); diffLaunch(); return false;"><span class="notice">Diff &raquo;</span></a> <div id="diff" style="display: none;"></div><br /><a href="htmLawedTest.php" title="[toggle visibility] XHTML 1 Transitional doctype" onclick="javascript:toggle(\'outputH\'); return false;"><span class="notice">Output rendered &raquo;</span></a><div id="outputH" style="display: block;">', $out, '</div>';
613
+ echo '</div><br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'outputR\'); return false;"><span class="notice">Output code &raquo;</span></a><div id="outputR" style="display: block;">', format($out), '</div><script type="text/javascript">hl(\'outputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'outputD\'); return false;"><span class="notice">Output binary &raquo;</span></a><div id="outputD" style="display: none;">'.hexdump($out).'</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] inline output-input diff; might not be perfectly accurate, semantically or otherwise " onclick="javascript:toggle(\'diff\'); diffLaunch(); return false;"><span class="notice">Diff &raquo;</span></a> <div id="diff" style="display: none;"></div><br /><a href="htmLawedTest.php" title="[toggle visibility] XHTML 1 Transitional doctype" onclick="javascript:toggle(\'outputH\'); return false;"><span class="notice">Output rendered &raquo;</span></a><div id="outputH" style="display: block;">', $out, '</div>';
614 614
 }
615
-else{
615
+else {
616 616
 ?>
617 617
 
618 618
 <br />
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 <br /><br />Hovering the mouse over some of the text can provide additional information in some browsers.</small>
631 631
 
632 632
 <?php
633
-if($_w3c_validate){
633
+if ($_w3c_validate) {
634 634
 ?>
635 635
 
636 636
 <small><br /><br />Because of character-encoding issues, the W3C validator (anyway not perfect) may reject validation requests or invalidate otherwise-valid code, esp. if text was copy-pasted in the input box. Local applications like the <em>HTML Validator</em> Firefox browser add-on may be useful in such cases.</small>
Please login to merge, or discard this patch.
Braces   +92 added lines, -43 removed lines patch added patch discarded remove patch
@@ -33,42 +33,51 @@  discard block
 block discarded – undo
33 33
 ini_set('session.use_only_cookies', 1);
34 34
 ini_set('session.cookie_lifetime', 0);
35 35
 session_start();
36
-if(!isset($_SESSION['token'])){
36
+if(!isset($_SESSION['token']))
37
+{
37 38
  $_SESSION['token'] = md5(uniqid(rand(), 1));
38 39
 }
39 40
 
40 41
 // slashes
41
-if(get_magic_quotes_gpc()){
42
- foreach($_POST as $k => $v){
42
+if(get_magic_quotes_gpc())
43
+{
44
+ foreach($_POST as $k => $v)
45
+ {
43 46
   $_POST[$k] = stripslashes($v);
44 47
  }
45 48
  ini_set('magic_quotes_gpc', 0);
46 49
 }
47
-if(get_magic_quotes_runtime()){
50
+if(get_magic_quotes_runtime())
51
+{
48 52
  set_magic_quotes_runtime(0);
49 53
 }
50 54
 
51 55
 $_POST['enc'] = (isset($_POST['enc']) and preg_match('`^[-\w]+$`', $_POST['enc'])) ? $_POST['enc'] : 'utf-8';
52 56
 
53 57
 // token for anti-CSRF
54
-if(count($_POST)){
55
- if((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id())){
58
+if(count($_POST))
59
+{
60
+ if((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id()))
61
+ {
56 62
   $_POST = array('enc'=>'utf-8');
57 63
  }
58 64
 }
59
-if(empty($_GET['pre'])){
65
+if(empty($_GET['pre']))
66
+{
60 67
  $_SESSION['token'] = md5(uniqid(rand(), 1));
61 68
  $token = $_SESSION['token'];
62 69
  session_regenerate_id(1);
63 70
 }
64 71
 
65 72
 // compress
66
-if(function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression')){
73
+if(function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression'))
74
+{
67 75
  ob_start('ob_gzhandler');
68 76
 }
69 77
 
70 78
 // HTM for unprocessed
71
-if(isset($_POST['inputH'])){
79
+if(isset($_POST['inputH']))
80
+{
72 81
  echo '<html><head><title>htmLawed test: HTML view of unprocessed input</title></head><body style="margin:0; padding: 0;"><p style="background-color: black; color: white; padding: 2px;">&nbsp; Rendering of unprocessed input without an HTML doctype or charset declaration &nbsp; &nbsp; <small><a style="color: white; text-decoration: none;" href="1" onclick="javascript:window.close(this); return false;">close window</a> | <a style="color: white; text-decoration: none;" href="htmLawedTest.php" onclick="javascript: window.open(\'htmLawedTest.php\', \'hlmain\'); window.close(this); return false;">htmLawed test page</a></small></p><div>', $_POST['inputH'], '</div></body></html>';
73 82
  exit;
74 83
 }
@@ -81,12 +90,14 @@  discard block
 block discarded – undo
81 90
 $validation = (!empty($_POST[$_sid]) and isset($_POST['w3c_validate'][0])) ? 1 : 0;
82 91
 include './htmLawed.php';
83 92
 
84
-function format($t){
93
+function format($t)
94
+{
85 95
  $t = "\n". str_replace(array("\t", "\r\n", "\r", '&', '<', '>', "\n"), array('    ', "\n", "\n", '&amp;', '&lt;', '&gt;', "<span class=\"newline\">&#172;</span><br />\n"), $t);
86 96
  return str_replace(array('<br />', "\n ", '  '), array("\n<br />\n", "\n&nbsp;", ' &nbsp;'), $t);
87 97
 }
88 98
 
89
-function hexdump($d){
99
+function hexdump($d)
100
+{
90 101
 // Mainly by Aidan Lister <[email protected]>, Peter Waller <[email protected]>
91 102
  $hexi = '';
92 103
  $ascii = '';
@@ -99,18 +110,23 @@  discard block
 block discarded – undo
99 110
   // Convert to hexidecimal
100 111
   $hexi .= sprintf("%02X ", ord($d[$i]));
101 112
   // Replace non-viewable bytes with '.'
102
-  if(ord($d[$i]) >= 32){
113
+  if(ord($d[$i]) >= 32)
114
+  {
103 115
    $ascii .= htmlspecialchars($d[$i]);
104
-  }else{
116
+  }
117
+  else
118
+  {
105 119
    $ascii .= '.';
106 120
   } 
107 121
   // Add extra column spacing
108
-  if($j == 7){
122
+  if($j == 7)
123
+  {
109 124
    $hexi .= ' ';
110 125
    $ascii .= '  ';
111 126
   }
112 127
   // Add row
113
-  if(++$j == 16 || $i == $len-1){
128
+  if(++$j == 16 || $i == $len-1)
129
+  {
114 130
    // Join the hexi / ascii output
115 131
    echo sprintf("%04X   %-49s   %s", $offset, $hexi, $ascii);   
116 132
    // Reset vars
@@ -118,7 +134,8 @@  discard block
 block discarded – undo
118 134
    $offset += 16;
119 135
    $j = 0;  
120 136
    // Add newline   
121
-   if ($i !== $len-1){
137
+   if ($i !== $len-1)
138
+   {
122 139
     echo "\n";
123 140
    }
124 141
   }
@@ -169,7 +186,9 @@  discard block
 block discarded – undo
169 186
 <script type="text/javascript"><!--//--><![CDATA[//><!-- 
170 187
 window.name = 'hlmain';
171 188
 function hl(i){
172
- <?php if(!$_hilite){echo 'return;'; }?>
189
+ <?php if(!$_hilite)
190
+{
191
+echo 'return;'; }?>
173 192
  var e = document.getElementById(i);
174 193
  if(!e){return;}
175 194
  run(e, '</[a-z1-6]+>', 'ctag');
@@ -451,8 +470,10 @@  discard block
 block discarded – undo
451 470
 <input type="submit" id="submitF" name="submitF" value="Process" style="float:left;" title="filter using htmLawed" onclick="javascript: sndProc(); return false;" onkeypress="javascript: sndProc(); return false;" />
452 471
 
453 472
 <?php
454
-if($do){
455
- if($validation){
473
+if($do)
474
+{
475
+ if($validation)
476
+ {
456 477
   echo '<input type="hidden" value="1" name="w3c_validate" id="w3c_validate" />';
457 478
  }
458 479
 ?>
@@ -461,7 +482,8 @@  discard block
 block discarded – undo
461 482
 <button type="button" onclick="javascript:document.getElementById('text').focus();document.getElementById('text').select()" title="select all to copy" style="float:right;">Select all</button>
462 483
 
463 484
 <?php
464
-if($_w3c_validate && $validation){
485
+if($_w3c_validate && $validation)
486
+{
465 487
 ?>
466 488
   
467 489
 <button type="button" title="HTML 4.01 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text', 'html401'); return false;" onkeypress="javascript: sndValidn('text', 'html401'); return false;">Check HTML</button>
@@ -470,8 +492,10 @@  discard block
 block discarded – undo
470 492
 <?php
471 493
  }
472 494
 }
473
-else{
474
- if($_w3c_validate){
495
+else
496
+{
497
+ if($_w3c_validate)
498
+ {
475 499
   echo '<span style="float: right;" class="help" title="for direct submission of input or output code to W3C validator for (X)HTML validation"><span style="font-size: 85%;">&nbsp;Validator tools: </span><input type="checkbox" value="1" name="w3c_validate" id="w3c_validate" style="vertical-align: middle;"', ($validation ? ' checked="checked"' : ''), ' /></span>';
476 500
  }
477 501
 }
@@ -483,7 +507,8 @@  discard block
 block discarded – undo
483 507
 <br style="clear:both;" />
484 508
 
485 509
 <?php
486
-if($limit_exceeded){
510
+if($limit_exceeded)
511
+{
487 512
  echo '<br /><strong>Input text is too long!</strong><br />';
488 513
 }
489 514
 ?>
@@ -531,32 +556,46 @@  discard block
 block discarded – undo
531 556
 'valid_xhtml'=>array('2', 'nil', 'auto-set various parameters for most valid XHTML', 'nil'),
532 557
 'xml:lang'=>array('3', 'nil', 'auto-add <em>xml:lang</em> attribute', '0'),
533 558
 );
534
-foreach($cfg as $k=>$v){
559
+foreach($cfg as $k=>$v)
560
+{
535 561
  echo '<li>', $k, ': ';
536
- if(!empty($v[0])){ // input radio
562
+ if(!empty($v[0]))
563
+ {
564
+// input radio
537 565
   $j = $v[3];
538
-  for($i = $j-1; ++$i < $v[0]+$v[3];++$j){
566
+  for($i = $j-1; ++$i < $v[0]+$v[3];++$j)
567
+  {
539 568
    echo '<input type="radio" name="h', $k, '" value="', $i, '"', (!isset($_POST['h'. $k]) ? ($v[1] == $i ? ' checked="checked"' : '') : ($_POST['h'. $k] == $i ? ' checked="checked"' : '')), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />', $i, ' ';
540 569
   }
541
-  if($v[1] == 'nil'){
570
+  if($v[1] == 'nil')
571
+  {
542 572
    echo '<input type="radio" name="h', $k, '" value="nil"', ((!isset($_POST['h'. $k]) or $_POST['h'. $k] == 'nil') ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />not set ';
543 573
   }
544
-  if(!empty($v[4])){ // + input text box
574
+  if(!empty($v[4]))
575
+  {
576
+// + input text box
545 577
    echo '<input type="radio" name="h', $k, '" value="', $j, '"', (((isset($_POST['h'. $k]) && $_POST['h'. $k] == $j) or (!isset($_POST['h'. $k]) && $j == $v[1])) ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
546
-   if(!is_array($v[4])){
578
+   if(!is_array($v[4]))
579
+   {
547 580
     echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k. $j, '" value="', htmlspecialchars(isset($_POST['h'. $k. $j][0]) ? $_POST['h'. $k. $j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
548 581
    }
549
-   else{
550
-    foreach($v[4] as $z){
582
+   else
583
+   {
584
+    foreach($v[4] as $z)
585
+    {
551 586
      echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k. $j. $z[1], '" value="', htmlspecialchars(isset($_POST['h'. $k. $j. $z[1]][0]) ? $_POST['h'. $k. $j. $z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';
552 587
     }    
553 588
    }
554 589
   }
555 590
  }
556
- elseif(ctype_digit($v[3])){ // input text
591
+ elseif(ctype_digit($v[3]))
592
+ {
593
+// input text
557 594
   echo '<input type="text" size="', $v[3], '" name="h', $k, '" value="', htmlspecialchars(isset($_POST['h'. $k][0]) ? $_POST['h'. $k] : $v[1]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />';  
558 595
  }
559
- else{} // text-area
596
+ else
597
+ {
598
+} // text-area
560 599
  echo ' <span class="help">', $v[2], '</span></li>';
561 600
 }
562 601
 echo '</ul></td></tr><tr><td><span style="vertical-align: top;" class="help" title="$spec argument: element-specific attribute rules">Spec:</span></td><td><textarea name="spec" id="spec" cols="70" rows="3" style="width:80%;">', htmlspecialchars((isset($_POST['spec']) ? $_POST['spec'] : '')), '</textarea></td></tr></table>';
@@ -566,31 +605,39 @@  discard block
 block discarded – undo
566 605
 </form>
567 606
 
568 607
 <?php
569
-if($do){
608
+if($do)
609
+{
570 610
  $cfg = array();
571
- foreach($_POST as $k=>$v){
572
-  if($k[0] == 'h' && $v != 'nil'){
611
+ foreach($_POST as $k=>$v)
612
+ {
613
+  if($k[0] == 'h' && $v != 'nil')
614
+  {
573 615
    $cfg[substr($k, 1)] = $v;
574 616
   }
575 617
  }
576 618
 
577
- if(isset($cfg['anti_link_spam']) && $cfg['anti_link_spam'] && (!empty($cfg['anti_link_spam11']) or !empty($cfg['anti_link_spam12']))){
619
+ if(isset($cfg['anti_link_spam']) && $cfg['anti_link_spam'] && (!empty($cfg['anti_link_spam11']) or !empty($cfg['anti_link_spam12'])))
620
+ {
578 621
   $cfg['anti_link_spam'] = array($cfg['anti_link_spam11'], $cfg['anti_link_spam12']);
579 622
  }
580 623
  unset($cfg['anti_link_spam11'], $cfg['anti_link_spam12']);
581
- if(isset($cfg['anti_mail_spam']) && $cfg['anti_mail_spam'] == 1){
624
+ if(isset($cfg['anti_mail_spam']) && $cfg['anti_mail_spam'] == 1)
625
+ {
582 626
   $cfg['anti_mail_spam'] = isset($cfg['anti_mail_spam1'][0]) ? $cfg['anti_mail_spam1'] : 0;
583 627
  }
584 628
  unset($cfg['anti_mail_spam11']);
585
- if(isset($cfg['deny_attribute']) && $cfg['deny_attribute'] == 1){
629
+ if(isset($cfg['deny_attribute']) && $cfg['deny_attribute'] == 1)
630
+ {
586 631
   $cfg['deny_attribute'] = isset($cfg['deny_attribute1'][0]) ? $cfg['deny_attribute1'] : 0;
587 632
  }
588 633
  unset($cfg['deny_attribute1']);
589
- if(isset($cfg['tidy']) && $cfg['tidy'] == 2){
634
+ if(isset($cfg['tidy']) && $cfg['tidy'] == 2)
635
+ {
590 636
   $cfg['tidy'] = isset($cfg['tidy2'][0]) ? $cfg['tidy2'] : 0;
591 637
  }
592 638
  unset($cfg['tidy2']);
593
- if(isset($cfg['unique_ids']) && $cfg['unique_ids'] == 2){
639
+ if(isset($cfg['unique_ids']) && $cfg['unique_ids'] == 2)
640
+ {
594 641
   $cfg['unique_ids'] = isset($cfg['unique_ids2'][0]) ? $cfg['unique_ids2'] : 1;
595 642
  }
596 643
  unset($cfg['unique_ids2']);
@@ -612,7 +659,8 @@  discard block
 block discarded – undo
612 659
  }
613 660
  echo '</div><br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'outputR\'); return false;"><span class="notice">Output code &raquo;</span></a><div id="outputR" style="display: block;">', format($out), '</div><script type="text/javascript">hl(\'outputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'outputD\'); return false;"><span class="notice">Output binary &raquo;</span></a><div id="outputD" style="display: none;">'. hexdump($out). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] inline output-input diff; might not be perfectly accurate, semantically or otherwise " onclick="javascript:toggle(\'diff\'); diffLaunch(); return false;"><span class="notice">Diff &raquo;</span></a> <div id="diff" style="display: none;"></div><br /><a href="htmLawedTest.php" title="[toggle visibility] XHTML 1 Transitional doctype" onclick="javascript:toggle(\'outputH\'); return false;"><span class="notice">Output rendered &raquo;</span></a><div id="outputH" style="display: block;">', $out, '</div>';
614 661
 }
615
-else{
662
+else
663
+{
616 664
 ?>
617 665
 
618 666
 <br />
@@ -630,7 +678,8 @@  discard block
 block discarded – undo
630 678
 <br /><br />Hovering the mouse over some of the text can provide additional information in some browsers.</small>
631 679
 
632 680
 <?php
633
-if($_w3c_validate){
681
+if($_w3c_validate)
682
+{
634 683
 ?>
635 684
 
636 685
 <small><br /><br />Because of character-encoding issues, the W3C validator (anyway not perfect) may reject validation requests or invalidate otherwise-valid code, esp. if text was copy-pasted in the input box. Local applications like the <em>HTML Validator</em> Firefox browser add-on may be useful in such cases.</small>
Please login to merge, or discard this patch.