Completed
Push — 16.1 ( 57f9df...776177 )
by Hadi
32:14 queued 15:10
created
mail/inc/class.mail_acl.inc.php 1 patch
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 */
35 35
 	var $aclRightsAbbrvs = array(
36
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
37
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
-		'ilprsw'	=> array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
-		'aeiklprstwx'=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
36
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
37
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
+		'ilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
+		'aeiklprstwx'=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
42 42
 	);
43 43
 
44 44
 	/**
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	 * @param string $msg = ''
62 62
 	 *
63 63
 	 */
64
-	function edit(array $content=null ,$msg='')
64
+	function edit(array $content = null, $msg = '')
65 65
 	{
66 66
 		$tmpl = new Etemplate('mail.acl');
67 67
 		if (!is_array($content))
68 68
 		{
69
-			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
69
+			$acc_id = $_GET['acc_id'] ? $_GET['acc_id'] : $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
70 70
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
71 71
 			{
72 72
 				Framework::window_close(lang('Permission denied'));
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 		$account = Mail\Account::read($acc_id, $account_id);
82 82
 		$this->imap = $account->imapServer(isset($account_id) ? (int)$account_id : false);
83 83
 
84
-		$mailbox = $_GET['mailbox']? base64_decode($_GET['mailbox']):
85
-			preg_replace("/^".$acc_id."::/",'',$content['mailbox'][0]);
84
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : preg_replace("/^".$acc_id."::/", '', $content['mailbox'][0]);
86 85
 		if (empty($mailbox))
87 86
 		{
88 87
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($account_id) : 'INBOX';
@@ -113,14 +112,14 @@  discard block
 block discarded – undo
113 112
 
114 113
 					foreach ($rights as $right)
115 114
 					{
116
-						$content['grid'][$n]['acl_'. $right] = true;
115
+						$content['grid'][$n]['acl_'.$right] = true;
117 116
 					}
118
-					$virtualD = array('e','t');
119
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
120
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
117
+					$virtualD = array('e', 't');
118
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false : true; //c=kx more information rfc4314, Obsolote Rights
119
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false : true; //d=et more information rfc4314, Obsolote Rights
121 120
 
122 121
 					sort($rights);
123
-					$acl_abbrvs = implode('',$rights);
122
+					$acl_abbrvs = implode('', $rights);
124 123
 
125 124
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
126 125
 					{
@@ -161,7 +160,7 @@  discard block
 block discarded – undo
161 160
 				case 'apply':
162 161
 					if ($content)
163 162
 					{
164
-						$validation_err = $this->update_acl($content,$msg);
163
+						$validation_err = $this->update_acl($content, $msg);
165 164
 						if ($validation_err)
166 165
 						{
167 166
 							foreach ($validation_err as &$row)
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 					}
193 192
 					else
194 193
 					{
195
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
194
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
196 195
 					}
197 196
 					Framework::message($msg);
198 197
 			}
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
202 201
 
203 202
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
204
-		foreach($content['grid'] as $key => $fields)
203
+		foreach ($content['grid'] as $key => $fields)
205 204
 		{
206 205
 			if (self::_extract_acc_id($fields['acc_id']) == $this->imap->acc_imap_username ||
207 206
 					$this->imap->getMailBoxUserName(self::_extract_acc_id($fields['acc_id'])) == $this->imap->acc_imap_username)
@@ -240,7 +239,7 @@  discard block
 block discarded – undo
240 239
 			));
241 240
 		}
242 241
 
243
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
242
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
244 243
 	}
245 244
 
246 245
 	/**
@@ -259,7 +258,7 @@  discard block
 block discarded – undo
259 258
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
260 259
 
261 260
 		$folders = array();
262
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
261
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
263 262
 		{
264 263
 			if (stripos($folder, $_GET['query']) !== false)
265 264
 			{
@@ -287,7 +286,7 @@  discard block
 block discarded – undo
287 286
 	 * @param string $msg Message
288 287
 	 *
289 288
 	 */
290
-	function update_acl ($content, &$msg)
289
+	function update_acl($content, &$msg)
291 290
 	{
292 291
 		$validator = array();
293 292
 
@@ -303,10 +302,10 @@  discard block
 block discarded – undo
303 302
 			{
304 303
 				if ($value[$key] == true)
305 304
 				{
306
-					$right = explode("acl_" ,$key);
305
+					$right = explode("acl_", $key);
307 306
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
308 307
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
309
-					$options['rights'] .=  $right[1];
308
+					$options['rights'] .= $right[1];
310 309
 				}
311 310
 			}
312 311
 			$username = self::_extract_acc_id($content['grid'][$keys]['acc_id']);
@@ -319,7 +318,7 @@  discard block
 block discarded – undo
319 318
 			if (!empty($username))
320 319
 			{
321 320
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
322
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
321
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
323 322
 				{
324 323
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
325 324
 
@@ -331,7 +330,7 @@  discard block
 block discarded – undo
331 330
 			}
332 331
 			else
333 332
 			{
334
-				if($keys !== count($content['grid']))
333
+				if ($keys !== count($content['grid']))
335 334
 				{
336 335
 					array_push($validator, $keys);
337 336
 					$msg = lang("Error:Could not save the ACL! Because some names are empty!");
@@ -348,7 +347,7 @@  discard block
 block discarded – undo
348 347
 	 * Retrieve Folder ACL rights
349 348
 	 * @todo rights 'c' and 'd' should be fixed
350 349
 	 */
351
-	function retrieve_acl ($mailbox, &$msg)
350
+	function retrieve_acl($mailbox, &$msg)
352 351
 	{
353 352
 		if (($acl = $this->getACL($mailbox)))
354 353
 		 {
@@ -373,34 +372,34 @@  discard block
 block discarded – undo
373 372
 	 */
374 373
 	function remove_acl($content, &$msg)
375 374
 	{
376
-		$row_num = array_keys($content['grid']['delete'],"pressed");
375
+		$row_num = array_keys($content['grid']['delete'], "pressed");
377 376
 		if ($row_num) $row_num = $row_num[0];
378 377
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
379 378
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
380
-		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
379
+		$content['mailbox'] = is_array($content['mailbox']) ? $content['mailbox'][0] : $content['mailbox'];
381 380
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
382 381
 		{
383 382
 			$identifier = $u;
384 383
 		}
385 384
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
386
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
385
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
387 386
 		{
388 387
 			unset($content['grid'][$row_num]);
389 388
 			unset($content['grid']['delete']);
390 389
 			if ($recursive)
391 390
 			{
392
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
391
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
393 392
 			}
394 393
 			else
395 394
 			{
396
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
395
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
397 396
 			}
398 397
 
399 398
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
400 399
 		}
401 400
 		else
402 401
 		{
403
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
402
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
404 403
 			return false;
405 404
 		}
406 405
 	}
@@ -415,7 +414,7 @@  discard block
 block discarded – undo
415 414
 	 *
416 415
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
417 416
 	 */
418
-	function deleteACL ($mailbox, $identifier, $recursive)
417
+	function deleteACL($mailbox, $identifier, $recursive)
419 418
 	{
420 419
 		if ($recursive)
421 420
 		{
@@ -425,7 +424,7 @@  discard block
 block discarded – undo
425 424
 		{
426 425
 			$folders = (array)$mailbox;
427 426
 		}
428
-		foreach($folders as $sbFolders)
427
+		foreach ($folders as $sbFolders)
429 428
 		{
430 429
 			try
431 430
 			{
@@ -433,7 +432,7 @@  discard block
 block discarded – undo
433 432
 			}
434 433
 			catch (Exception $e)
435 434
 			{
436
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ."." .$e->getMessage());
435
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
437 436
 				return false;
438 437
 			}
439 438
 		}
@@ -476,7 +475,7 @@  discard block
 block discarded – undo
476 475
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
477 476
 	 *
478 477
 	 */
479
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
478
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
480 479
 	{
481 480
 		if ($recursive)
482 481
 		{
@@ -486,16 +485,16 @@  discard block
 block discarded – undo
486 485
 		{
487 486
 			$folders = (array)$mailbox;
488 487
 		}
489
-		foreach($folders as $sbFolders)
488
+		foreach ($folders as $sbFolders)
490 489
 		{
491 490
 			try
492 491
 			{
493
-				$this->imap->setACL($sbFolders,$identifier,$options);
492
+				$this->imap->setACL($sbFolders, $identifier, $options);
494 493
 			}
495 494
 			catch (Exception $e)
496 495
 			{
497 496
 				$msg = $e->getMessage();
498
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . "." .$e->getMessage());
497
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
499 498
 				return false;
500 499
 			}
501 500
 		}
@@ -508,14 +507,14 @@  discard block
 block discarded – undo
508 507
 	 * @param String $mailbox folder name that needs to be read
509 508
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
510 509
 	 */
511
-	function getACL ($mailbox)
510
+	function getACL($mailbox)
512 511
 	{
513 512
 		try
514 513
 		{
515 514
 			$acl = $this->imap->getACL($mailbox);
516 515
 			return $acl;
517 516
 		} catch (Exception $e) {
518
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
517
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox.".".$e->getMessage());
519 518
 			return false;
520 519
 		}
521 520
 	}
@@ -527,8 +526,8 @@  discard block
 block discarded – undo
527 526
 	 *
528 527
 	 * @return string returns acc_id in flat format
529 528
 	 */
530
-	private static function _extract_acc_id ($acc_id)
529
+	private static function _extract_acc_id($acc_id)
531 530
 	{
532
-		return is_array($acc_id)?$acc_id[0]:$acc_id;
531
+		return is_array($acc_id) ? $acc_id[0] : $acc_id;
533 532
 	}
534 533
 }
Please login to merge, or discard this patch.