Completed
Push — develop ( d271f8...cb7ecf )
by Serg
08:17 queued 57s
created
manager/actions/mutate_user.dynamic.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6
-switch($modx->manager->action) {
6
+switch ($modx->manager->action) {
7 7
 	case 12:
8
-		if(!$modx->hasPermission('edit_user')) {
8
+		if (!$modx->hasPermission('edit_user')) {
9 9
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
10 10
 		}
11 11
 		break;
12 12
 	case 11:
13
-		if(!$modx->hasPermission('new_user')) {
13
+		if (!$modx->hasPermission('new_user')) {
14 14
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15 15
 		}
16 16
 		break;
@@ -18,24 +18,24 @@  discard block
 block discarded – undo
18 18
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21
-$user = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
21
+$user = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
22 22
 
23 23
 // check to see the snippet editor isn't locked
24
-$rs = $modx->db->select('username', $modx->getFullTableName('active_users'), "action=12 AND id='{$user}' AND internalKey!='" . $modx->getLoginUserID() . "'");
25
-if($username = $modx->db->getValue($rs)) {
24
+$rs = $modx->db->select('username', $modx->getFullTableName('active_users'), "action=12 AND id='{$user}' AND internalKey!='".$modx->getLoginUserID()."'");
25
+if ($username = $modx->db->getValue($rs)) {
26 26
 	$modx->webAlertAndQuit(sprintf($_lang["lock_msg"], $username, "user"));
27 27
 }
28 28
 // end check for lock
29 29
 
30
-if($modx->manager->action == '12') {
30
+if ($modx->manager->action == '12') {
31 31
 	// get user attribute
32 32
 	$rs = $modx->db->select('*', $modx->getFullTableName('user_attributes'), "internalKey = '{$user}'");
33 33
 	$userdata = $modx->db->getRow($rs);
34
-	if(!$userdata) {
34
+	if (!$userdata) {
35 35
 		$modx->webAlertAndQuit("No user returned!");
36 36
 	}
37 37
 
38
-    if($_SESSION['mgrRole'] != 1 && $userdata['role'] == 1) {
38
+    if ($_SESSION['mgrRole'] != 1 && $userdata['role'] == 1) {
39 39
         $modx->webAlertAndQuit('Illegal attempt to create/modify administrator by non-administrator!');
40 40
     }
41 41
 
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	// get user settings
44 44
 	$rs = $modx->db->select('*', $modx->getFullTableName('user_settings'), "user = '{$user}'");
45 45
 	$usersettings = array();
46
-	while($row = $modx->db->getRow($rs)) $usersettings[$row['setting_name']] = $row['setting_value'];
46
+	while ($row = $modx->db->getRow($rs)) $usersettings[$row['setting_name']] = $row['setting_value'];
47 47
 	// manually extract so that user display settings are not overwritten
48
-	foreach($usersettings as $k => $v) {
49
-		if($k != 'manager_language' && $k != 'manager_theme') {
48
+	foreach ($usersettings as $k => $v) {
49
+		if ($k != 'manager_language' && $k != 'manager_theme') {
50 50
 			${$k} = $v;
51 51
 		}
52 52
 	}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	// get user name
55 55
 	$rs = $modx->db->select('*', $modx->getFullTableName('manager_users'), "id = '{$user}'");
56 56
 	$usernamedata = $modx->db->getRow($rs);
57
-	if(!$usernamedata) {
57
+	if (!$usernamedata) {
58 58
 		$modx->webAlertAndQuit("No user returned while getting username!");
59 59
 	}
60 60
 	$_SESSION['itemname'] = $usernamedata['username'];
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 // avoid doubling htmlspecialchars (already encoded in DB)
69
-foreach($userdata as $key => $val) {
69
+foreach ($userdata as $key => $val) {
70 70
 	$userdata[$key] = html_entity_decode($val, ENT_NOQUOTES, $modx->config['modx_charset']);
71 71
 };
72 72
 $usernamedata['username'] = html_entity_decode($usernamedata['username'], ENT_NOQUOTES, $modx->config['modx_charset']);
73 73
 
74 74
 // restore saved form
75 75
 $formRestored = false;
76
-if($modx->manager->hasFormValues()) {
76
+if ($modx->manager->hasFormValues()) {
77 77
 	$modx->manager->loadFormValues();
78 78
 	// restore post values
79 79
 	$userdata = array_merge($userdata, $_POST);
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 // include the country list language file
89 89
 $_country_lang = array();
90 90
 include_once "lang/country/english_country.inc.php";
91
-if($manager_language != "english" && file_exists($modx->config['site_manager_path'] . "includes/lang/country/" . $manager_language . "_country.inc.php")) {
92
-	include_once "lang/country/" . $manager_language . "_country.inc.php";
91
+if ($manager_language != "english" && file_exists($modx->config['site_manager_path']."includes/lang/country/".$manager_language."_country.inc.php")) {
92
+	include_once "lang/country/".$manager_language."_country.inc.php";
93 93
 }
94 94
 asort($_country_lang);
95 95
 
96 96
 $displayStyle = ($_SESSION['browser'] === 'modern') ? 'table-row' : 'block';
97
-if($which_browser == 'default') {
97
+if ($which_browser == 'default') {
98 98
 	$which_browser = $modx->configGlobal['which_browser'] ? $modx->configGlobal['which_browser'] : $modx->config['which_browser'];
99 99
 }
100 100
 ?>
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			document.userform.save.click();
187 187
 		},
188 188
 		delete: function() {
189
-			<?php if($_GET['id'] == $modx->getLoginUserID()) { ?>
189
+			<?php if ($_GET['id'] == $modx->getLoginUserID()) { ?>
190 190
 			alert("<?php echo $_lang['alert_delete_self']; ?>");
191 191
 			<?php } else { ?>
192 192
 			if(confirm("<?php echo $_lang['confirm_delete_user']; ?>") === true) {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	$evtOut = $modx->invokeEvent("OnUserFormPrerender", array(
210 210
 		"id" => $user
211 211
 	));
212
-	if(is_array($evtOut)) {
212
+	if (is_array($evtOut)) {
213 213
 		echo implode("", $evtOut);
214 214
 	}
215 215
 	?>
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	<input type="hidden" name="blockedmode" value="<?php echo ($userdata['blocked'] == 1 || ($userdata['blockeduntil'] > time() && $userdata['blockeduntil'] != 0) || ($userdata['blockedafter'] < time() && $userdata['blockedafter'] != 0) || $userdata['failedlogins'] > 3) ? "1" : "0" ?>" />
219 219
 
220 220
 	<h1>
221
-        <i class="fa fa fa-user"></i><?= ($usernamedata['username'] ? $usernamedata['username'] . '<small>(' . $usernamedata['id'] . ')</small>' : $_lang['user_title']) ?>
221
+        <i class="fa fa fa-user"></i><?= ($usernamedata['username'] ? $usernamedata['username'].'<small>('.$usernamedata['id'].')</small>' : $_lang['user_title']) ?>
222 222
     </h1>
223 223
 
224 224
 	<?php echo $_style['actionbuttons']['dynamic']['user'] ?>
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 				<table border="0" cellspacing="0" cellpadding="3" class="table table--edit table--editUser">
237 237
 					<tr>
238 238
 						<td colspan="3"><span id="blocked" class="warning">
239
-							<?php if($userdata['blocked'] == 1 || ($userdata['blockeduntil'] > time() && $userdata['blockeduntil'] != 0) || $userdata['failedlogins'] > 3) { ?>
239
+							<?php if ($userdata['blocked'] == 1 || ($userdata['blockeduntil'] > time() && $userdata['blockeduntil'] != 0) || $userdata['failedlogins'] > 3) { ?>
240 240
 								<?php echo $_lang['user_is_blocked']; ?>
241 241
 							<?php } ?>
242 242
 							</span>
243 243
 							<br /></td>
244 244
 					</tr>
245
-					<?php if(!empty($userdata['id'])) { ?>
245
+					<?php if (!empty($userdata['id'])) { ?>
246 246
 						<tr id="showname" style="display: <?php echo ($modx->manager->action == '12' && (!isset($usernamedata['oldusername']) || $usernamedata['oldusername'] == $usernamedata['username'])) ? $displayStyle : 'none'; ?> ">
247 247
 							<td colspan="3"><i class="<?php echo $_style["icons_user"] ?>"></i>&nbsp;<b><?php echo $modx->htmlspecialchars(!empty($usernamedata['oldusername']) ? $usernamedata['oldusername'] : $usernamedata['username']); ?></b> - <span class="comment"><a href="javascript:;" onClick="changeName();return false;"><?php echo $_lang["change_name"]; ?></a></span>
248 248
 								<input type="hidden" name="oldusername" value="<?php echo $modx->htmlspecialchars(!empty($usernamedata['oldusername']) ? $usernamedata['oldusername'] : $usernamedata['username']); ?>" />
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 						<td><input type="text" name="newusername" class="inputBox" value="<?php echo $modx->htmlspecialchars($usernamedata['username']); ?>" onChange='documentDirty=true;' maxlength="100" /></td>
256 256
 					</tr>
257 257
 					<tr>
258
-						<th><?php echo $modx->manager->action == '11' ? $_lang['password'] . ":" : $_lang['change_password_new'] . ":"; ?></th>
258
+						<th><?php echo $modx->manager->action == '11' ? $_lang['password'].":" : $_lang['change_password_new'].":"; ?></th>
259 259
 						<td>&nbsp;</td>
260 260
 						<td><input name="newpasswordcheck" type="checkbox" onClick="changestate(document.userform.newpassword);changePasswordState(document.userform.newpassword);"<?php echo $modx->manager->action == "11" ? " checked disabled" : ""; ?>>
261 261
 							<input type="hidden" name="newpassword" value="<?php echo $modx->manager->action == "11" ? 1 : 0; ?>" onChange="documentDirty=true;" />
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 							?>
310 310
 							<select name="role" class="inputBox" onChange='documentDirty=true;' style="width:300px">
311 311
 								<?php
312
-								while($row = $modx->db->getRow($rs)) {
313
-									if($modx->manager->action == '11') {
312
+								while ($row = $modx->db->getRow($rs)) {
313
+									if ($modx->manager->action == '11') {
314 314
 										$selectedtext = $row['id'] == '1' ? ' selected="selected"' : '';
315 315
 									} else {
316 316
 										$selectedtext = $row['id'] == $userdata['role'] ? "selected='selected'" : '';
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 								<?php $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $userdata['country']; ?>
365 365
 								<option value="" <?php (!isset($chosenCountry) ? ' selected' : '') ?> >&nbsp;</option>
366 366
 								<?php
367
-								foreach($_country_lang as $key => $country) {
368
-									echo "<option value=\"$key\"" . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . ">$country</option>";
367
+								foreach ($_country_lang as $key => $country) {
368
+									echo "<option value=\"$key\"".(isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '').">$country</option>";
369 369
 								}
370 370
 								?>
371 371
 							</select></td>
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 						<td>&nbsp;</td>
392 392
 						<td><textarea type="text" name="comment" class="inputBox" rows="5" onChange="documentDirty=true;"><?php echo $modx->htmlspecialchars($userdata['comment']); ?></textarea></td>
393 393
 					</tr>
394
-					<?php if($modx->manager->action == '12') { ?>
394
+					<?php if ($modx->manager->action == '12') { ?>
395 395
 						<tr>
396 396
 							<th><?php echo $_lang['user_logincount']; ?>:</th>
397 397
 							<td>&nbsp;</td>
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 						</tr>
429 429
 					<?php } ?>
430 430
 				</table>
431
-				<?php if($_GET['id'] == $modx->getLoginUserID()) { ?>
431
+				<?php if ($_GET['id'] == $modx->getLoginUserID()) { ?>
432 432
 					<p><?php echo $_lang['user_edit_self_msg']; ?></p>
433 433
 				<?php } ?>
434 434
 			</div>
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 								<?php
446 446
 								$activelang = !empty($usersettings['manager_language']) ? $usersettings['manager_language'] : '';
447 447
 								$dir = dir("includes/lang");
448
-								while($file = $dir->read()) {
449
-									if(strpos($file, ".inc.php") > 0) {
448
+								while ($file = $dir->read()) {
449
+									if (strpos($file, ".inc.php") > 0) {
450 450
 										$endpos = strpos($file, ".");
451 451
 										$languagename = substr($file, 0, $endpos);
452 452
 										$selectedtext = $languagename == $activelang ? "selected='selected'" : "";
@@ -533,17 +533,17 @@  discard block
 block discarded – undo
533 533
 								<option value=""></option>
534 534
 								<?php
535 535
 								$dir = dir("media/style/");
536
-								while($file = $dir->read()) {
537
-									if($file != "." && $file != ".." && is_dir("media/style/$file") && substr($file, 0, 1) != '.') {
536
+								while ($file = $dir->read()) {
537
+									if ($file != "." && $file != ".." && is_dir("media/style/$file") && substr($file, 0, 1) != '.') {
538 538
 										$themename = $file;
539
-										if($themename === 'common') {
539
+										if ($themename === 'common') {
540 540
 											continue;
541 541
 										}
542
-										$attr = 'value="' . $themename . '" ';
543
-										if(isset($usersettings['manager_theme']) && $themename == $usersettings['manager_theme']) {
542
+										$attr = 'value="'.$themename.'" ';
543
+										if (isset($usersettings['manager_theme']) && $themename == $usersettings['manager_theme']) {
544 544
 											$attr .= 'selected="selected" ';
545 545
 										}
546
-										echo "\t\t<option " . rtrim($attr) . '>' . ucwords(str_replace("_", " ", $themename)) . "</option>\n";
546
+										echo "\t\t<option ".rtrim($attr).'>'.ucwords(str_replace("_", " ", $themename))."</option>\n";
547 547
 									}
548 548
 								}
549 549
 								$dir->close();
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
 						<td><select name="which_browser" class="inputBox" onChange="documentDirty=true;">
585 585
 								<?php
586 586
 								$selected = 'default' == $usersettings['which_browser'] || !$usersettings['which_browser'] ? ' selected="selected"' : '';
587
-								echo '<option value="default"' . $selected . '>' . $_lang['option_default'] . "</option>\n";
588
-								foreach(glob("media/browser/*", GLOB_ONLYDIR) as $dir) {
587
+								echo '<option value="default"'.$selected.'>'.$_lang['option_default']."</option>\n";
588
+								foreach (glob("media/browser/*", GLOB_ONLYDIR) as $dir) {
589 589
 									$dir = str_replace('\\', '/', $dir);
590 590
 									$browser_name = substr($dir, strrpos($dir, '/') + 1);
591 591
 									$selected = $browser_name == $usersettings['which_browser'] ? ' selected="selected"' : '';
592
-									echo '<option value="' . $browser_name . '"' . $selected . '>' . "{$browser_name}</option>\n";
592
+									echo '<option value="'.$browser_name.'"'.$selected.'>'."{$browser_name}</option>\n";
593 593
 								}
594 594
 								?>
595 595
 							</select></td>
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 					</tr>
617 617
 					<tr>
618 618
 						<td>&nbsp;</td>
619
-						<td class='comment'><?php echo $_lang["uploadable_images_message"] . $_lang["user_upload_message"] ?></td>
619
+						<td class='comment'><?php echo $_lang["uploadable_images_message"].$_lang["user_upload_message"] ?></td>
620 620
 					</tr>
621 621
 					<tr>
622 622
 						<th><?php echo $_lang["uploadable_media_title"] ?></th>
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 					</tr>
629 629
 					<tr>
630 630
 						<td>&nbsp;</td>
631
-						<td class='comment'><?php echo $_lang["uploadable_media_message"] . $_lang["user_upload_message"] ?></td>
631
+						<td class='comment'><?php echo $_lang["uploadable_media_message"].$_lang["user_upload_message"] ?></td>
632 632
 					</tr>
633 633
 					<tr>
634 634
 						<th><?php echo $_lang["uploadable_flash_title"] ?></th>
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 					</tr>
641 641
 					<tr>
642 642
 						<td>&nbsp;</td>
643
-						<td class='comment'><?php echo $_lang["uploadable_flash_message"] . $_lang["user_upload_message"] ?></td>
643
+						<td class='comment'><?php echo $_lang["uploadable_flash_message"].$_lang["user_upload_message"] ?></td>
644 644
 					</tr>
645 645
 					<tr>
646 646
 						<th><?php echo $_lang["uploadable_files_title"] ?></th>
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 					</tr>
653 653
 					<tr>
654 654
 						<td>&nbsp;</td>
655
-						<td class='comment'><?php echo $_lang["uploadable_files_message"] . $_lang["user_upload_message"] ?></td>
655
+						<td class='comment'><?php echo $_lang["uploadable_files_message"].$_lang["user_upload_message"] ?></td>
656 656
 					</tr>
657 657
 					<tr class='row2'>
658 658
 						<th><?php echo $_lang["upload_maxsize_title"] ?></th>
@@ -671,11 +671,11 @@  discard block
 block discarded – undo
671 671
 								$edt = isset ($usersettings["which_editor"]) ? $usersettings["which_editor"] : '';
672 672
 								// invoke OnRichTextEditorRegister event
673 673
 								$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
674
-								echo "<option value='none'" . ($edt == 'none' ? " selected='selected'" : "") . ">" . $_lang["none"] . "</option>\n";
675
-								if(is_array($evtOut)) {
676
-									for($i = 0; $i < count($evtOut); $i++) {
674
+								echo "<option value='none'".($edt == 'none' ? " selected='selected'" : "").">".$_lang["none"]."</option>\n";
675
+								if (is_array($evtOut)) {
676
+									for ($i = 0; $i < count($evtOut); $i++) {
677 677
 										$editor = $evtOut[$i];
678
-										echo "<option value='$editor'" . ($edt == $editor ? " selected='selected'" : "") . ">$editor</option>\n";
678
+										echo "<option value='$editor'".($edt == $editor ? " selected='selected'" : "").">$editor</option>\n";
679 679
 									}
680 680
 								}
681 681
 								?>
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 				<?php
714 714
 				// invoke OnInterfaceSettingsRender event
715 715
 				$evtOut = $modx->invokeEvent("OnInterfaceSettingsRender");
716
-				if(is_array($evtOut)) {
716
+				if (is_array($evtOut)) {
717 717
 					echo implode("", $evtOut);
718 718
 				}
719 719
 				?>
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 					function BrowseServer() {
741 741
 						var w = screen.width * 0.7;
742 742
 						var h = screen.height * 0.7;
743
-						OpenServerBrowser("<?php echo MODX_MANAGER_URL; ?>media/browser/<?php echo $which_browser;?>/browser.php?Type=images", w, h);
743
+						OpenServerBrowser("<?php echo MODX_MANAGER_URL; ?>media/browser/<?php echo $which_browser; ?>/browser.php?Type=images", w, h);
744 744
 					}
745 745
 
746 746
 					function SetUrl(url, width, height, alt) {
@@ -763,17 +763,17 @@  discard block
 block discarded – undo
763 763
 					</tr>
764 764
 				</table>
765 765
 			</div>
766
-			<?php if($use_udperms == 1) {
766
+			<?php if ($use_udperms == 1) {
767 767
 
768 768
 			$groupsarray = array();
769 769
 
770
-			if($modx->manager->action == '12') { // only do this bit if the user is being edited
770
+			if ($modx->manager->action == '12') { // only do this bit if the user is being edited
771 771
 				$rs = $modx->db->select('user_group', $modx->getFullTableName('member_groups'), "member='{$user}'");
772 772
 				$groupsarray = $modx->db->getColumn('user_group', $rs);
773 773
 			}
774 774
 			// retain selected doc groups between post
775
-			if(is_array($_POST['user_groups'])) {
776
-				foreach($_POST['user_groups'] as $n => $v) $groupsarray[] = $v;
775
+			if (is_array($_POST['user_groups'])) {
776
+				foreach ($_POST['user_groups'] as $n => $v) $groupsarray[] = $v;
777 777
 			}
778 778
 			?>
779 779
 			<div class="tab-page" id="tabAccess">
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 				<p><?php echo $_lang['access_permissions_user_message'] ?></p>
783 783
 				<?php
784 784
 				$rs = $modx->db->select('name, id', $modx->getFullTableName('membergroup_names'), '', 'name');
785
-				while($row = $modx->db->getRow($rs)) {
786
-					echo "<label><input type='checkbox' name='user_groups[]' value='" . $row['id'] . "'" . (in_array($row['id'], $groupsarray) ? " checked='checked'" : "") . " />" . $row['name'] . "</label><br />";
785
+				while ($row = $modx->db->getRow($rs)) {
786
+					echo "<label><input type='checkbox' name='user_groups[]' value='".$row['id']."'".(in_array($row['id'], $groupsarray) ? " checked='checked'" : "")." />".$row['name']."</label><br />";
787 787
 				}
788 788
 				}
789 789
 				?>
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	$evtOut = $modx->invokeEvent("OnUserFormRender", array(
797 797
 		"id" => $user
798 798
 	));
799
-	if(is_array($evtOut)) {
799
+	if (is_array($evtOut)) {
800 800
 		echo implode("", $evtOut);
801 801
 	}
802 802
 	?>
Please login to merge, or discard this patch.