Completed
Push — develop ( 614386...4063f2 )
by
unknown
15s
created
manager/actions/welcome.static.php 1 patch
Braces   +81 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  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 6
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8
-if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
8
+if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9 9
 	// seems to be a new install - send the user to the configuration page
10 10
 	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $_SESSION['nrnewmessages'] = 0;
17 17
 
18 18
 // setup message info
19
-if($modx->hasPermission('messages')) {
19
+if($modx->hasPermission('messages')) {
20 20
 	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21 21
 	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22 22
 	$_SESSION['nrnewmessages'] = $nrnewmessages;
@@ -32,46 +32,46 @@  discard block
 block discarded – undo
32 32
 }
33 33
 
34 34
 // setup icons
35
-if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
35
+if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36 36
 	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37 37
 	$ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39
-if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
39
+if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40 40
 	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41 41
 	$ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
43
+if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44 44
 	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45 45
 	$ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
47
+if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48 48
 	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49 49
 	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51
-if($modx->hasPermission('bk_manager')) {
51
+if($modx->hasPermission('bk_manager')) {
52 52
 	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53 53
 	$ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55
-if($modx->hasPermission('help')) {
55
+if($modx->hasPermission('help')) {
56 56
 	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57 57
 	$ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 
60
-if($modx->hasPermission('new_document')) {
60
+if($modx->hasPermission('new_document')) {
61 61
 	$icon = '<i class="[&icons_resource_large&]"></i>[%add_resource%]';
62 62
 	$ph['ResourceIcon'] = wrapIcon($icon, 4);
63 63
 	$icon = '<i class="[&icons_weblink_large&]"></i>[%add_weblink%]';
64 64
 	$ph['WeblinkIcon'] = wrapIcon($icon, 72);
65 65
 }
66
-if($modx->hasPermission('assets_images')) {
66
+if($modx->hasPermission('assets_images')) {
67 67
 	$icon = '<i class="[&icons_images_large&]"></i>[%images_management%]';
68 68
 	$ph['ImagesIcon'] = wrapIcon($icon, 72);
69 69
 }
70
-if($modx->hasPermission('assets_files')) {
70
+if($modx->hasPermission('assets_files')) {
71 71
 	$icon = '<i class="[&icons_files_large&]"></i>[%files_management%]';
72 72
 	$ph['FilesIcon'] = wrapIcon($icon, 72);
73 73
 }
74
-if($modx->hasPermission('change_password')) {
74
+if($modx->hasPermission('change_password')) {
75 75
 	$icon = '<i class="[&icons_password_large&]"></i>[%change_password%]';
76 76
 	$ph['PasswordIcon'] = wrapIcon($icon, 28);
77 77
 }
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 $ph['LogoutIcon'] = wrapIcon($icon, 8);
80 80
 
81 81
 // do some config checks
82
-if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
82
+if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
83 83
 	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
84
-	if($config_check_results != $_lang['configcheck_ok']) {
84
+	if($config_check_results != $_lang['configcheck_ok']) {
85 85
 		$ph['config_check_results'] = $config_check_results;
86 86
 		$ph['config_display'] = 'block';
87
-	} else {
87
+	} else {
88 88
 		$ph['config_display'] = 'none';
89 89
 	}
90
-} else {
90
+} else {
91 91
 	$ph['config_display'] = 'none';
92 92
 }
93 93
 
94 94
 // Check logout-reminder
95
-if(isset($_SESSION['show_logout_reminder'])) {
96
-	switch($_SESSION['show_logout_reminder']['type']) {
95
+if(isset($_SESSION['show_logout_reminder'])) {
96
+	switch($_SESSION['show_logout_reminder']['type']) {
97 97
 		case 'logout_reminder':
98 98
 			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
99 99
 			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 	$ph['show_logout_reminder'] = 'block';
103 103
 	unset($_SESSION['show_logout_reminder']);
104
-} else {
104
+} else {
105 105
 	$ph['show_logout_reminder'] = 'none';
106 106
 }
107 107
 
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'";
163 163
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
164 164
 
165
-if($modx->db->getRecordCount($rs) < 1) {
165
+if($modx->db->getRecordCount($rs) < 1) {
166 166
 	$html = '<p>[%no_active_users_found%]</p>';
167
-} else {
167
+} else {
168 168
 	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
169 169
 	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
170 170
 	$ph['now'] = strftime('%H:%M:%S', $now);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	$userList = array();
191 191
 	$userCount = array();
192 192
 	// Create userlist with session-count first before output
193
-	while($activeusers = $modx->db->getRow($rs)) {
193
+	while($activeusers = $modx->db->getRow($rs)) {
194 194
 		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
195 195
 
196 196
 		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$currentaction
209 209
 		);
210 210
 	}
211
-	foreach($userList as $params) {
211
+	foreach($userList as $params) {
212 212
 		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
213 213
 		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
214 214
 	}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 
254 254
 // invoke event OnManagerWelcomePrerender
255 255
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
256
-if(is_array($evtOut)) {
256
+if(is_array($evtOut)) {
257 257
 	$output = implode('', $evtOut);
258 258
 	$ph['OnManagerWelcomePrerender'] = $output;
259 259
 }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
359 359
 	'hide'=>'0'
360 360
 );
361
-if ($modx->config['rss_url_news']) {
361
+if ($modx->config['rss_url_news']) {
362 362
     $widgets['news'] = array(
363 363
         'menuindex' => '40',
364 364
         'id' => 'news',
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         'hide'=>'0'
370 370
     );
371 371
 }
372
-if ($modx->config['rss_url_security']) {
372
+if ($modx->config['rss_url_security']) {
373 373
     $widgets['security'] = array(
374 374
         'menuindex' => '50',
375 375
         'id' => 'security',
@@ -383,29 +383,29 @@  discard block
 block discarded – undo
383 383
 
384 384
 // invoke OnManagerWelcomeHome event
385 385
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
386
-if(is_array($sitewidgets)) {
386
+if(is_array($sitewidgets)) {
387 387
 	$newwidgets = array();
388
-    foreach($sitewidgets as $widget){
388
+    foreach($sitewidgets as $widget) {
389 389
         $newwidgets = array_merge($newwidgets, unserialize($widget));
390 390
     }
391 391
     $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets;
392 392
 }
393 393
 
394
-usort($widgets, function ($a, $b) {
394
+usort($widgets, function ($a, $b){
395 395
 	return $a['menuindex'] - $b['menuindex'];
396 396
 });
397 397
 
398 398
 $tpl = getTplWidget();
399 399
 $output = '';
400
-foreach($widgets as $widget) {
401
-	if ($widget['hide'] != '1'){
400
+foreach($widgets as $widget) {
401
+	if ($widget['hide'] != '1') {
402 402
 		$output .= $modx->parseText($tpl, $widget);
403 403
 	}
404 404
 }
405 405
 $ph['widgets'] = $output;
406 406
 
407 407
 // load template
408
-if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
408
+if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
409 409
 	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
410 410
 }
411 411
 
@@ -413,26 +413,28 @@  discard block
 block discarded – undo
413 413
 $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
414 414
 $target = $modx->mergeSettingsContent($target);
415 415
 
416
-if(substr($target, 0, 1) === '@') {
417
-	if(substr($target, 0, 6) === '@CHUNK') {
416
+if(substr($target, 0, 1) === '@') {
417
+	if(substr($target, 0, 6) === '@CHUNK') {
418 418
 		$content = $modx->getChunk(trim(substr($target, 7)));
419
-	} elseif(substr($target, 0, 5) === '@FILE') {
419
+	} elseif(substr($target, 0, 5) === '@FILE') {
420 420
 		$content = file_get_contents(trim(substr($target, 6)));
421
-	} else {
421
+	} else {
422 422
 		$content = '';
423 423
 	}
424
-} else {
424
+} else {
425 425
 	$chunk = $modx->getChunk($target);
426
-	if($chunk !== false && !empty($chunk)) {
426
+	if($chunk !== false && !empty($chunk)) {
427 427
 		$content = $chunk;
428
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
428
+	} elseif(is_file(MODX_BASE_PATH . $target)) {
429 429
 		$content = file_get_contents(MODX_BASE_PATH . $target);
430
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
430
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
431 431
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
432
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
432
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) {
433
+	    // ClipperCMS compatible
433 434
 	{
434
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
435
-	} else {
435
+		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
436
+	}
437
+	} else {
436 438
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
437 439
 	}
438 440
 }
@@ -441,7 +443,7 @@  discard block
 block discarded – undo
441 443
 $content = $modx->mergeConditionalTagsContent($content);
442 444
 $content = $modx->mergeSettingsContent($content);
443 445
 $content = $modx->parseText($content, $ph);
444
-if(strpos($content, '[+') !== false) {
446
+if(strpos($content, '[+') !== false) {
445 447
 	$modx->toPlaceholders($ph);
446 448
 	$content = $modx->mergePlaceholderContent($content);
447 449
 }
@@ -450,7 +452,7 @@  discard block
 block discarded – undo
450 452
 $content = $modx->parseText($content, $_style, '[&', '&]');
451 453
 $content = $modx->cleanUpMODXTags($content); //cleanup
452 454
 
453
-if($js = $modx->getRegisteredClientScripts()) {
455
+if($js = $modx->getRegisteredClientScripts()) {
454 456
 	$content .= $js;
455 457
 }
456 458
 
@@ -460,7 +462,9 @@  discard block
 block discarded – undo
460 462
 //	<a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a>
461 463
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
462 464
 //</span>
463
-function getTplWidget() { // recent document info
465
+function getTplWidget()
466
+{
467
+// recent document info
464 468
 	return '
465 469
 		<div class="[+cols+]" id="[+id+]">
466 470
 			<div class="card"[+cardAttr+]>
@@ -471,7 +475,9 @@  discard block
 block discarded – undo
471 475
 ';
472 476
 }
473 477
 
474
-function getRecentInfo() { // recent document info
478
+function getRecentInfo()
479
+{
480
+// recent document info
475 481
 	global $modx;
476 482
 
477 483
 	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
@@ -497,12 +503,13 @@  discard block
 block discarded – undo
497 503
 	return $html;
498 504
 }
499 505
 
500
-function getRecentInfoList() {
506
+function getRecentInfoList()
507
+{
501 508
 	global $modx;
502 509
 
503 510
 	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
504 511
 
505
-	if($modx->db->getRecordCount($rs) < 1) {
512
+	if($modx->db->getRecordCount($rs) < 1) {
506 513
 		return '<tr><td>[%no_activity_message%]</td></tr>';
507 514
 	}
508 515
 
@@ -512,22 +519,22 @@  discard block
 block discarded – undo
512 519
 	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
513 520
 
514 521
 	$output = array();
515
-	while($ph = $modx->db->getRow($rs)) {
522
+	while($ph = $modx->db->getRow($rs)) {
516 523
 		$docid = $ph['id'];
517 524
 		$_ = $modx->getUserInfo($ph['editedby']);
518 525
 		$ph['username'] = $_['username'];
519 526
 
520
-		if($ph['deleted'] == 1) {
527
+		if($ph['deleted'] == 1) {
521 528
 			$ph['status'] = 'deleted text-danger';
522
-		} elseif($ph['published'] == 0) {
529
+		} elseif($ph['published'] == 0) {
523 530
 			$ph['status'] = 'unpublished font-italic text-muted';
524
-		} else {
531
+		} else {
525 532
 			$ph['status'] = 'published';
526 533
 		}
527 534
 
528
-		if($modx->hasPermission('edit_document')) {
535
+		if($modx->hasPermission('edit_document')) {
529 536
 			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
530
-		} else {
537
+		} else {
531 538
 			$ph['edit_btn'] = '';
532 539
 		}
533 540
 
@@ -540,40 +547,40 @@  discard block
 block discarded – undo
540 547
 			$preview_disabled
541 548
 		), $btntpl['preview_btn']);
542 549
 
543
-		if($modx->hasPermission('delete_document')) {
544
-			if($ph['deleted'] == 0) {
550
+		if($modx->hasPermission('delete_document')) {
551
+			if($ph['deleted'] == 0) {
545 552
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
546
-			} else {
553
+			} else {
547 554
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
548 555
 			}
549 556
 			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
550
-		} else {
557
+		} else {
551 558
 			$ph['delete_btn'] = '';
552 559
 		}
553 560
 
554
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
561
+		if($ph['deleted'] == 1 && $ph['published'] == 0) {
555 562
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
556
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
563
+		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
557 564
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
558
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
565
+		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
559 566
 			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
560
-		} else {
567
+		} else {
561 568
 			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
562 569
 		}
563 570
 		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
564 571
 
565 572
 		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
566 573
 
567
-		if($ph['longtitle'] == '') {
574
+		if($ph['longtitle'] == '') {
568 575
 			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
569 576
 		}
570
-		if($ph['description'] == '') {
577
+		if($ph['description'] == '') {
571 578
 			$ph['description'] = '(<i>[%not_set%]</i>)';
572 579
 		}
573
-		if($ph['introtext'] == '') {
580
+		if($ph['introtext'] == '') {
574 581
 			$ph['introtext'] = '(<i>[%not_set%]</i>)';
575 582
 		}
576
-		if($ph['alias'] == '') {
583
+		if($ph['alias'] == '') {
577 584
 			$ph['alias'] = '(<i>[%not_set%]</i>)';
578 585
 		}
579 586
 
@@ -582,7 +589,8 @@  discard block
 block discarded – undo
582 589
 	return implode("\n", $output);
583 590
 }
584 591
 
585
-function getRecentInfoRowTpl() {
592
+function getRecentInfoRowTpl()
593
+{
586 594
 	$tpl = '
587 595
 						<tr>
588 596
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
@@ -611,11 +619,13 @@  discard block
 block discarded – undo
611 619
 }
612 620
 
613 621
 // setup icons
614
-function wrapIcon($i, $action) {
622
+function wrapIcon($i, $action)
623
+{
615 624
 	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
616 625
 }
617 626
 
618
-function getStartUpScript() {
627
+function getStartUpScript()
628
+{
619 629
 	$script = '
620 630
         <script type="text/javascript">
621 631
         function hideConfigCheckWarning(key) {
Please login to merge, or discard this patch.