Completed
Push — develop ( 053968...47dc8d )
by Maxim
12s
created
manager/includes/accesscontrol.inc.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 }
19 19
 
20 20
 // andrazk 20070416 - if installer is running, destroy active sessions
21
-if (file_exists(MODX_BASE_PATH . 'assets/cache/installProc.inc.php')) {
22
-    include_once(MODX_BASE_PATH . 'assets/cache/installProc.inc.php');
21
+if (file_exists(MODX_BASE_PATH.'assets/cache/installProc.inc.php')) {
22
+    include_once(MODX_BASE_PATH.'assets/cache/installProc.inc.php');
23 23
     if (isset($installStartTime)) {
24 24
         if ((time() - $installStartTime) > 5 * 60) { // if install flag older than 5 minutes, discard
25 25
             unset($installStartTime);
26
-            @ chmod(MODX_BASE_PATH . 'assets/cache/installProc.inc.php', 0755);
27
-            unlink(MODX_BASE_PATH . 'assets/cache/installProc.inc.php');
26
+            @ chmod(MODX_BASE_PATH.'assets/cache/installProc.inc.php', 0755);
27
+            unlink(MODX_BASE_PATH.'assets/cache/installProc.inc.php');
28 28
         } else {
29 29
             if ($_SERVER['REQUEST_METHOD'] != 'POST') {
30 30
                 if (isset($_COOKIE[session_name()])) {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                         //						setcookie(session_name(), '', 0, MODX_BASE_URL);
51 51
                     }
52 52
                     header('HTTP/1.0 307 Redirect');
53
-                    header('Location: ' . MODX_MANAGER_URL . 'index.php?installGoingOn=2');
53
+                    header('Location: '.MODX_MANAGER_URL.'index.php?installGoingOn=2');
54 54
                 }
55 55
             }
56 56
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         // establish fallback to English default
63 63
         include_once "lang/english.inc.php";
64 64
         // include localized overrides
65
-        include_once "lang/" . $manager_language . ".inc.php";
65
+        include_once "lang/".$manager_language.".inc.php";
66 66
     } else {
67 67
         include_once "lang/english.inc.php";
68 68
     }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     $modx->setPlaceholder('modx_charset', $modx_manager_charset);
71 71
     $modx->setPlaceholder('theme', $manager_theme);
72 72
     $modx->setPlaceholder('favicon',
73
-        (file_exists(MODX_BASE_PATH . 'favicon.ico') ? MODX_SITE_URL . 'favicon.ico' : 'media/style/' . $modx->config['manager_theme'] . '/images/favicon.ico'));
73
+        (file_exists(MODX_BASE_PATH.'favicon.ico') ? MODX_SITE_URL . 'favicon.ico' : 'media/style/'.$modx->config['manager_theme'].'/images/favicon.ico'));
74 74
 
75 75
     // invoke OnManagerLoginFormPrerender event
76 76
     $evtOut = $modx->invokeEvent('OnManagerLoginFormPrerender');
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     $modx->setPlaceholder('logo_slogan', $_lang["logo_slogan"]);
83 83
     $modx->setPlaceholder('login_message', $_lang["login_message"]);
84 84
     $modx->setPlaceholder('manager_theme_url',
85
-        MODX_MANAGER_URL . 'media/style/' . $modx->config['manager_theme'] . '/');
85
+        MODX_MANAGER_URL.'media/style/'.$modx->config['manager_theme'].'/');
86 86
     $modx->setPlaceholder('year', date('Y'));
87 87
     $modx->setPlaceholder('manager_theme_style',
88 88
         (isset($_COOKIE['MODX_themeColor']) ? $_COOKIE['MODX_themeColor'] : ''));
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
         switch ($installGoingOn) {
96 96
             case 1 :
97 97
                 $modx->setPlaceholder('login_message',
98
-                    "<p><span class=\"fail\">" . $_lang["login_cancelled_install_in_progress"] . "</p><p>" . $_lang["login_message"] . "</p>");
98
+                    "<p><span class=\"fail\">".$_lang["login_cancelled_install_in_progress"]."</p><p>".$_lang["login_message"]."</p>");
99 99
                 break;
100 100
             case 2 :
101 101
                 $modx->setPlaceholder('login_message',
102
-                    "<p><span class=\"fail\">" . $_lang["login_cancelled_site_was_updated"] . "</p><p>" . $_lang["login_message"] . "</p>");
102
+                    "<p><span class=\"fail\">".$_lang["login_cancelled_site_was_updated"]."</p><p>".$_lang["login_message"]."</p>");
103 103
                 break;
104 104
         }
105 105
     }
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
     if ($modx->config['use_captcha'] == 1) {
108 108
         $modx->setPlaceholder('login_captcha_message', $_lang["login_captcha_message"]);
109 109
         $modx->setPlaceholder('captcha_image',
110
-            '<a href="' . MODX_MANAGER_URL . '" class="loginCaptcha"><img id="captcha_image" src="' . MODX_MANAGER_URL . 'includes/veriword.php?rand=' . rand() . '" alt="' . $_lang["login_captcha_message"] . '" /></a>');
110
+            '<a href="'.MODX_MANAGER_URL.'" class="loginCaptcha"><img id="captcha_image" src="'.MODX_MANAGER_URL.'includes/veriword.php?rand='.rand().'" alt="'.$_lang["login_captcha_message"].'" /></a>');
111 111
         $modx->setPlaceholder('captcha_input',
112
-            '<label>' . $_lang["captcha_code"] . '</label> <input type="text" name="captcha_code" tabindex="3" value="" />');
112
+            '<label>'.$_lang["captcha_code"].'</label> <input type="text" name="captcha_code" tabindex="3" value="" />');
113 113
     }
114 114
 
115 115
     // login info
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
     // invoke OnManagerLoginFormRender event
129 129
     $evtOut = $modx->invokeEvent('OnManagerLoginFormRender');
130
-    $html = is_array($evtOut) ? '<div id="onManagerLoginFormRender">' . implode('', $evtOut) . '</div>' : '';
130
+    $html = is_array($evtOut) ? '<div id="onManagerLoginFormRender">'.implode('', $evtOut).'</div>' : '';
131 131
     $modx->setPlaceholder('OnManagerLoginFormRender', $html);
132 132
 
133 133
     // load template
@@ -145,29 +145,29 @@  discard block
 block discarded – undo
145 145
             $login_tpl = file_get_contents($target);
146 146
         }
147 147
     } else {
148
-        $theme_path = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/';
149
-        if (is_file($theme_path . 'style.php')) {
150
-            include($theme_path . 'style.php');
148
+        $theme_path = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/';
149
+        if (is_file($theme_path.'style.php')) {
150
+            include($theme_path.'style.php');
151 151
         }
152 152
         $chunk = $modx->getChunk($target);
153 153
         if ($chunk !== false && !empty($chunk)) {
154 154
             $login_tpl = $chunk;
155
-        } elseif (is_file(MODX_BASE_PATH . $target)) {
156
-            $target = MODX_BASE_PATH . $target;
155
+        } elseif (is_file(MODX_BASE_PATH.$target)) {
156
+            $target = MODX_BASE_PATH.$target;
157 157
             $login_tpl = file_get_contents($target);
158 158
         } elseif (is_file($target)) {
159 159
             $login_tpl = file_get_contents($target);
160
-        } elseif (is_file($theme_path . 'login.tpl')) {
161
-            $target = $theme_path . 'login.tpl';
160
+        } elseif (is_file($theme_path.'login.tpl')) {
161
+            $target = $theme_path.'login.tpl';
162 162
             $login_tpl = file_get_contents($target);
163
-        } elseif (is_file($theme_path . 'templates/actions/login.tpl')) {
164
-            $target = $theme_path . 'templates/actions/login.tpl';
163
+        } elseif (is_file($theme_path.'templates/actions/login.tpl')) {
164
+            $target = $theme_path.'templates/actions/login.tpl';
165 165
             $login_tpl = file_get_contents($target);
166
-        } elseif (is_file($theme_path . 'html/login.html')) { // ClipperCMS compatible
167
-            $target = $theme_path . 'html/login.html';
166
+        } elseif (is_file($theme_path.'html/login.html')) { // ClipperCMS compatible
167
+            $target = $theme_path.'html/login.html';
168 168
             $login_tpl = file_get_contents($target);
169 169
         } else {
170
-            $target = MODX_MANAGER_PATH . 'media/style/common/login.tpl';
170
+            $target = MODX_MANAGER_PATH.'media/style/common/login.tpl';
171 171
             $login_tpl = file_get_contents($target);
172 172
         }
173 173
     }
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
     $modx->updateValidatedUserSession();
188 188
 
189 189
     // Update last action in table active_users
190
-    $itemid = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
190
+    $itemid = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
191 191
     $lasthittime = time();
192
-    $action = isset($_REQUEST['a']) ? (int)$_REQUEST['a'] : 1;
192
+    $action = isset($_REQUEST['a']) ? (int) $_REQUEST['a'] : 1;
193 193
 
194 194
     if ($action !== 1) {
195
-        if ((int)$itemid <= 0) {
195
+        if ((int) $itemid <= 0) {
196 196
             $itemid = null;
197 197
         }
198 198
         $sql = sprintf("REPLACE INTO %s (sid, internalKey, username, lasthit, action, id) VALUES ('%s', %d, '%s', %d, '%s', %s)",
199 199
             $modx->getFullTableName('active_users') // Table
200
-            , session_id(), $modx->getLoginUserID(), $_SESSION['mgrShortname'], $lasthittime, (string)$action,
200
+            , session_id(), $modx->getLoginUserID(), $_SESSION['mgrShortname'], $lasthittime, (string) $action,
201 201
             $itemid == null ? var_export(null, true) : $itemid);
202 202
         $modx->db->query($sql);
203 203
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
 if (file_exists(MODX_BASE_PATH . 'assets/cache/installProc.inc.php')) {
22 22
     include_once(MODX_BASE_PATH . 'assets/cache/installProc.inc.php');
23 23
     if (isset($installStartTime)) {
24
-        if ((time() - $installStartTime) > 5 * 60) { // if install flag older than 5 minutes, discard
24
+        if ((time() - $installStartTime) > 5 * 60) {
25
+// if install flag older than 5 minutes, discard
25 26
             unset($installStartTime);
26 27
             @ chmod(MODX_BASE_PATH . 'assets/cache/installProc.inc.php', 0755);
27 28
             unlink(MODX_BASE_PATH . 'assets/cache/installProc.inc.php');
@@ -163,7 +164,8 @@  discard block
 block discarded – undo
163 164
         } elseif (is_file($theme_path . 'templates/actions/login.tpl')) {
164 165
             $target = $theme_path . 'templates/actions/login.tpl';
165 166
             $login_tpl = file_get_contents($target);
166
-        } elseif (is_file($theme_path . 'html/login.html')) { // ClipperCMS compatible
167
+        } elseif (is_file($theme_path . 'html/login.html')) {
168
+// ClipperCMS compatible
167 169
             $target = $theme_path . 'html/login.html';
168 170
             $login_tpl = file_get_contents($target);
169 171
         } else {
Please login to merge, or discard this patch.
manager/includes/mutate_settings.ajax.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
7 7
 }
8 8
 
9
-require_once(dirname(__FILE__) . '/protect.inc.php');
9
+require_once(dirname(__FILE__).'/protect.inc.php');
10 10
 
11 11
 $action = preg_replace('/[^A-Za-z0-9_\-\.\/]/', '', $_POST['action']);
12 12
 $lang = preg_replace('/[^A-Za-z0-9_\s\+\-\.\/]/', '', $_POST['lang']);
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
 switch (true) {
25 25
     case ($action == 'get' && preg_match('/^[A-z0-9_-]+$/',
26
-            $lang) && file_exists(dirname(__FILE__) . '/lang/' . $lang . '.inc.php')): {
27
-        include(dirname(__FILE__) . '/lang/' . $lang . '.inc.php');
26
+            $lang) && file_exists(dirname(__FILE__).'/lang/'.$lang.'.inc.php')): {
27
+        include(dirname(__FILE__).'/lang/'.$lang.'.inc.php');
28 28
         $str = isset($key, $_lang, $_lang[$key]) ? $_lang[$key] : "";
29 29
         break;
30 30
     }
31 31
     case ($action == 'setsetting' && !empty($key) && !empty($value)): {
32
-        $sql = "REPLACE INTO " . $modx->getFullTableName("system_settings") . " (setting_name, setting_value) VALUES('{$key}', '{$value}');";
32
+        $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) VALUES('{$key}', '{$value}');";
33 33
         $str = "true";
34 34
         $modx->db->query($sql);
35 35
         $emptyCache = true;
Please login to merge, or discard this patch.
manager/includes/preload.functions.inc.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     $_ = crc32(__FILE__);
12 12
     $_ = sprintf('%u', $_);
13 13
 
14
-    return 'evo' . base_convert($_, 10, 36);
14
+    return 'evo'.base_convert($_, 10, 36);
15 15
 }
16 16
 
17 17
 /**
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     session_start();
33 33
     $key = "modx.mgr.session.cookie.lifetime";
34 34
     if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
35
-        $cookieLifetime = (int)$_SESSION[$key];
35
+        $cookieLifetime = (int) $_SESSION[$key];
36 36
         if ($cookieLifetime) {
37 37
             $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime;
38 38
         }
Please login to merge, or discard this patch.
Braces   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 /**
7 7
  * @return string
8 8
  */
9
-function genEvoSessionName()
10
-{
9
+function genEvoSessionName()
10
+{
11 11
     $_ = crc32(__FILE__);
12 12
     $_ = sprintf('%u', $_);
13 13
 
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * @return void
19 19
  */
20
-function startCMSSession()
21
-{
20
+function startCMSSession()
21
+{
22 22
 
23 23
     global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain;
24 24
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
     session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
32 32
     session_start();
33 33
     $key = "modx.mgr.session.cookie.lifetime";
34
-    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
34
+    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
35 35
         $cookieLifetime = (int)$_SESSION[$key];
36
-        if ($cookieLifetime) {
36
+        if ($cookieLifetime) {
37 37
             $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime;
38 38
         }
39 39
         setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
40 40
     }
41
-    if (!isset($_SESSION['modx.session.created.time'])) {
41
+    if (!isset($_SESSION['modx.session.created.time'])) {
42 42
         $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME'];
43 43
     }
44 44
 }
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
  * @param $session_name
49 49
  * @return void
50 50
  */
51
-function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
52
-{
53
-    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
51
+function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
52
+{
53
+    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
54 54
         unset($storage[$session_name]);
55 55
     }
56 56
 }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
  * @param $session_name
60 60
  * @return void
61 61
  */
62
-function removeInvalidCmsSessionIds($session_name)
63
-{
62
+function removeInvalidCmsSessionIds($session_name)
63
+{
64 64
     // session ids is invalid iff it is empty string
65 65
     // storage priorioty can see in PHP source ext/session/session.c
66 66
     removeInvalidCmsSessionFromStorage($_COOKIE, $session_name);
Please login to merge, or discard this patch.
manager/includes/rss.inc.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 ---------------------------------------------- */
28 28
 
29 29
 // include MagPieRSS
30
-require_once(MODX_MANAGER_PATH . 'media/rss/rss_fetch.inc');
30
+require_once(MODX_MANAGER_PATH.'media/rss/rss_fetch.inc');
31 31
 /**
32 32
  * Convert relative path into absolute url
33 33
  *
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     $tmp = parse_url($base);
42 42
     extract($tmp);
43 43
     if (strpos($rel, "//") === 0) {
44
-        return $scheme . ':' . $rel;
44
+        return $scheme.':'.$rel;
45 45
     }
46 46
     // return if already absolute URL
47 47
     if (parse_url($rel, PHP_URL_SCHEME) != '') {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     }
50 50
     // queries and anchors
51 51
     if ($rel[0] == '#' || $rel[0] == '?') {
52
-        return $base . $rel;
52
+        return $base.$rel;
53 53
     }
54 54
     // remove non-directory element from path
55 55
     $path = preg_replace('#/[^/]*$#', '', $path);
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
         $path = '';
59 59
     }
60 60
     // dirty absolute URL
61
-    $abs = $host . $path . "/" . $rel;
61
+    $abs = $host.$path."/".$rel;
62 62
     // replace '//' or  '/./' or '/foo/../' with '/'
63 63
     $abs = preg_replace("/(\/\.?\/)/", "/", $abs);
64 64
     $abs = preg_replace("/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs);
65 65
 
66 66
     // absolute URL is ready!
67
-    return $scheme . '://' . $abs;
67
+    return $scheme.'://'.$abs;
68 68
 }
69 69
 
70 70
 $feedData = array();
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     $output = '';
75 75
     $rss = @fetch_rss($url);
76 76
     if (!$rss) {
77
-        $feedData[$section] = 'Failed to retrieve ' . $url;
77
+        $feedData[$section] = 'Failed to retrieve '.$url;
78 78
         continue;
79 79
     }
80 80
     $output .= '<ul>';
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
         $description = strip_tags($item['description']);
89 89
         if (strlen($description) > 199) {
90 90
             $description = substr($description, 0, 200);
91
-            $description .= '...<br />Read <a href="' . $href . '" target="_blank">more</a>.';
91
+            $description .= '...<br />Read <a href="'.$href.'" target="_blank">more</a>.';
92 92
         }
93
-        $output .= '<li><a href="' . $href . '" target="_blank">' . $title . '</a> - <b>' . $pubdate . '</b><br />' . $description . '</li>';
93
+        $output .= '<li><a href="'.$href.'" target="_blank">'.$title.'</a> - <b>'.$pubdate.'</b><br />'.$description.'</li>';
94 94
     }
95 95
 
96 96
     $output .= '</ul>';
Please login to merge, or discard this patch.
manager/includes/config_check.inc.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  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
 // PROCESSOR FIRST
7
-if($_SESSION['mgrRole'] == 1) {
8
-	if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) {
7
+if ($_SESSION['mgrRole'] == 1) {
8
+	if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) {
9 9
 		$current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']);
10
-		if(!empty($current)) {
10
+		if (!empty($current)) {
11 11
 			$modx->manager->setSystemChecksum($current);
12 12
 			$modx->clearCache('full');
13 13
 			$modx->config['sys_files_checksum'] = $current;
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check !== '0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29
-    if(@fileperms('includes/config.inc.php') & 0x0002) {
29
+    if (@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
31 31
       $warnings[] = array($_lang['configcheck_configinc']);
32 32
     }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     $warnings[] = array($_lang['configcheck_php_gdzip']);
43 43
 }
44 44
 
45
-if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') {
46
-    if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') {
45
+if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') {
46
+    if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') {
47 47
         if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) {
48 48
             $warningspresent = 1;
49 49
             $warnings[] = array($_lang['configcheck_validate_referer']);
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 }
53 53
 
54 54
 // check for Template Switcher plugin
55
-if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') {
56
-    if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') {
55
+if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') {
56
+    if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') {
57 57
         $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'");
58 58
         $row = $modx->db->getRow($rs);
59
-        if($row && $row['disabled'] == 0) {
59
+        if ($row && $row['disabled'] == 0) {
60 60
             $warningspresent = 1;
61 61
             $warnings[] = array($_lang['configcheck_templateswitcher_present']);
62 62
             $tplName = $row['name'];
@@ -120,36 +120,36 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return bool
122 122
      */
123
-    function checkSiteCache() {
123
+    function checkSiteCache(){
124 124
         global $modx;
125
-        $checked= true;
126
-        if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
127
-            $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php');
125
+        $checked = true;
126
+        if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) {
127
+            $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php');
128 128
         }
129 129
         return $checked;
130 130
     }
131 131
 }
132 132
 
133
-if (!is_writable(MODX_BASE_PATH . "assets/cache/")) {
133
+if (!is_writable(MODX_BASE_PATH."assets/cache/")) {
134 134
     $warningspresent = 1;
135 135
     $warnings[] = array($_lang['configcheck_cache']);
136 136
 }
137 137
 
138 138
 if (!checkSiteCache()) {
139 139
     $warningspresent = 1;
140
-    $warnings[]= array($lang['configcheck_sitecache_integrity']);
140
+    $warnings[] = array($lang['configcheck_sitecache_integrity']);
141 141
 }
142 142
 
143
-if (!is_writable(MODX_BASE_PATH . "assets/images/")) {
143
+if (!is_writable(MODX_BASE_PATH."assets/images/")) {
144 144
     $warningspresent = 1;
145 145
     $warnings[] = array($_lang['configcheck_images']);
146 146
 }
147 147
 
148
-if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) {
148
+if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) {
149 149
     $warningspresent = 1;
150 150
     $warnings[] = array($_lang['configcheck_rb_base_dir']);
151 151
 }
152
-if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) {
152
+if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) {
153 153
     $warningspresent = 1;
154 154
     $warnings[] = array($_lang['configcheck_filemanager_path']);
155 155
 }
@@ -157,36 +157,36 @@  discard block
 block discarded – undo
157 157
 // clear file info cache
158 158
 clearstatcache();
159 159
 
160
-if ($warningspresent==1) {
160
+if ($warningspresent == 1) {
161 161
 
162
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
162
+if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3';
163 163
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
164 164
 
165
-for ($i=0;$i<count($warnings);$i++) {
165
+for ($i = 0; $i < count($warnings); $i++) {
166 166
     switch ($warnings[$i][0]) {
167 167
         case $_lang['configcheck_configinc'];
168 168
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
169
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
169
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']);
170 170
             break;
171 171
         case $_lang['configcheck_installer'] :
172 172
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
173
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
173
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']);
174 174
             break;
175 175
         case $_lang['configcheck_cache'] :
176 176
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
177
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
177
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']);
178 178
             break;
179 179
         case $_lang['configcheck_images'] :
180 180
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
181
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
181
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']);
182 182
             break;
183 183
         case $_lang['configcheck_sysfiles_mod']:
184 184
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
185
-			$warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>';
186
-			if($modx->hasPermission('settings')) {
187
-				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
185
+			$warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>';
186
+			if ($modx->hasPermission('settings')) {
187
+				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>';
188 188
 			}
189
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
189
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']);
190 190
             break;
191 191
         case $_lang['configcheck_lang_difference'] :
192 192
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
@@ -208,18 +208,18 @@  discard block
 block discarded – undo
208 208
             break;
209 209
         case $_lang['configcheck_validate_referer'] :
210 210
             $msg = $_lang['configcheck_validate_referer_msg'];
211
-            $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer');
211
+            $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer');
212 212
             $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n";
213 213
             break;
214 214
         case $_lang['configcheck_templateswitcher_present'] :
215 215
             $msg = $_lang["configcheck_templateswitcher_present_msg"];
216
-            if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') {
217
-                $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"];
216
+            if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') {
217
+                $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"];
218 218
             }
219
-            if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') {
220
-                $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"];
219
+            if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') {
220
+                $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"];
221 221
             }
222
-            $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present');
222
+            $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present');
223 223
             $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n";
224 224
             break;
225 225
         case $_lang['configcheck_rb_base_dir'] :
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             $warnings[$i][1] = $_lang['configcheck_default_msg'];
233 233
     }
234 234
 
235
-    $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ;
235
+    $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : "";
236 236
     $config_check_results .= "
237 237
             <fieldset>
238 238
             <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p>
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
             ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')."
242 242
             </fieldset>
243 243
 ";
244
-        if ($i!=count($warnings)-1) {
244
+        if ($i != count($warnings) - 1) {
245 245
             $config_check_results .= "<br />";
246 246
         }
247 247
     }
248
-    $_SESSION["mgrConfigCheck"]=true;
248
+    $_SESSION["mgrConfigCheck"] = true;
249 249
 } else {
250 250
     $config_check_results = $_lang['configcheck_ok'];
251 251
 }
Please login to merge, or discard this patch.
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check!=='0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29 29
     if(@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
@@ -120,7 +120,8 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return bool
122 122
      */
123
-    function checkSiteCache() {
123
+    function checkSiteCache()
124
+    {
124 125
         global $modx;
125 126
         $checked= true;
126 127
         if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
@@ -159,26 +160,36 @@  discard block
 block discarded – undo
159 160
 
160 161
 if ($warningspresent==1) {
161 162
 
162
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
163
+if(!isset($modx->config['send_errormail'])) {
164
+    $modx->config['send_errormail']='3';
165
+}
163 166
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
164 167
 
165 168
 for ($i=0;$i<count($warnings);$i++) {
166 169
     switch ($warnings[$i][0]) {
167 170
         case $_lang['configcheck_configinc'];
168 171
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
169
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
172
+            if(!$_SESSION["mgrConfigCheck"]) {
173
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
174
+            }
170 175
             break;
171 176
         case $_lang['configcheck_installer'] :
172 177
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
173
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
178
+            if(!$_SESSION["mgrConfigCheck"]) {
179
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
180
+            }
174 181
             break;
175 182
         case $_lang['configcheck_cache'] :
176 183
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
177
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
184
+            if(!$_SESSION["mgrConfigCheck"]) {
185
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
186
+            }
178 187
             break;
179 188
         case $_lang['configcheck_images'] :
180 189
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
181
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
190
+            if(!$_SESSION["mgrConfigCheck"]) {
191
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
192
+            }
182 193
             break;
183 194
         case $_lang['configcheck_sysfiles_mod']:
184 195
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
@@ -186,7 +197,9 @@  discard block
 block discarded – undo
186 197
 			if($modx->hasPermission('settings')) {
187 198
 				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
188 199
 			}
189
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
200
+            if(!$_SESSION["mgrConfigCheck"]) {
201
+                $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
202
+            }
190 203
             break;
191 204
         case $_lang['configcheck_lang_difference'] :
192 205
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
Please login to merge, or discard this patch.
manager/includes/categories.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     $newCat = $modx->db->escape($newCat);
35 35
     $cats = $modx->db->select('id', $modx->getFullTableName('categories'), "category='{$newCat}'");
36 36
     if ($cat = $modx->db->getValue($cats)) {
37
-        return (int)$cat;
37
+        return (int) $cat;
38 38
     }
39 39
 
40 40
     return 0;
Please login to merge, or discard this patch.
manager/processors/save_user.processor.php 4 patches
Indentation   +368 added lines, -368 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
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
 if(!$modx->hasPermission('save_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $modx->loadExtension('phpass');
@@ -45,134 +45,134 @@  discard block
 block discarded – undo
45 45
 
46 46
 // verify password
47 47
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
48
-	webAlertAndQuit("Password typed is mismatched");
48
+    webAlertAndQuit("Password typed is mismatched");
49 49
 }
50 50
 
51 51
 // verify email
52 52
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
53
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
53
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
54 54
 }
55 55
 
56 56
 // verify admin security
57 57
 if($_SESSION['mgrRole'] != 1) {
58
-	// Check to see if user tried to spoof a "1" (admin) role
59
-	if(!$modx->hasPermission('save_role')) {
60
-		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61
-	}
62
-	// Verify that the user being edited wasn't an admin and the user ID got spoofed
63
-	$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64
-	$limit = $modx->db->getValue($rs);
65
-	if($limit > 0) {
66
-		webAlertAndQuit("You cannot alter an administrative user.");
67
-	}
58
+    // Check to see if user tried to spoof a "1" (admin) role
59
+    if(!$modx->hasPermission('save_role')) {
60
+        webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61
+    }
62
+    // Verify that the user being edited wasn't an admin and the user ID got spoofed
63
+    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64
+    $limit = $modx->db->getValue($rs);
65
+    if($limit > 0) {
66
+        webAlertAndQuit("You cannot alter an administrative user.");
67
+    }
68 68
 
69 69
 }
70 70
 
71 71
 switch($input['mode']) {
72
-	case '11' : // new user
73
-		// check if this user name already exist
74
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
-		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
77
-			webAlertAndQuit("User name is already in use!");
78
-		}
79
-
80
-		// check if the email address already exist
81
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
-		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
84
-			webAlertAndQuit("Email is already in use!");
85
-		}
86
-
87
-		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
90
-				webAlertAndQuit("Password is too short!");
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!");
100
-		}
101
-
102
-		// invoke OnBeforeUserFormSave event
103
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
104
-			"mode" => "new",
105
-		));
106
-
107
-		// create the user account
108
-		$internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
-
110
-		$field = array();
111
-		$field['password'] = $modx->phpass->HashPassword($newpassword);
112
-		$modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
-
114
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
-		$field = $modx->db->escape($field);
116
-		$modx->db->insert($field, $tbl_user_attributes);
117
-
118
-		// Save user settings
119
-		saveUserSettings($internalKey);
120
-
121
-		// invoke OnManagerSaveUser event
122
-		$modx->invokeEvent("OnManagerSaveUser", array(
123
-			"mode" => "new",
124
-			"userid" => $internalKey,
125
-			"username" => $newusername,
126
-			"userpassword" => $newpassword,
127
-			"useremail" => $email,
128
-			"userfullname" => $fullname,
129
-			"userroleid" => $role
130
-		));
131
-
132
-		// invoke OnUserFormSave event
133
-		$modx->invokeEvent("OnUserFormSave", array(
134
-			"mode" => "new",
135
-			"id" => $internalKey
136
-		));
137
-
138
-		// Set the item name for logger
139
-		$_SESSION['itemname'] = $newusername;
140
-
141
-		/*******************************************************************************/
142
-		// put the user in the user_groups he/ she should be in
143
-		// first, check that up_perms are switched on!
144
-		if($use_udperms == 1) {
145
-			if(!empty($user_groups)) {
146
-				for($i = 0; $i < count($user_groups); $i++) {
147
-					$f = array();
148
-					$f['user_group'] = (int)$user_groups[$i];
149
-					$f['member'] = $internalKey;
150
-					$modx->db->insert($f, $tbl_member_groups);
151
-				}
152
-			}
153
-		}
154
-		// end of user_groups stuff!
155
-
156
-		if($passwordnotifymethod == 'e') {
157
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-				header($header);
162
-			} else {
163
-				$header = "Location: index.php?a=75&r=2";
164
-				header($header);
165
-			}
166
-		} else {
167
-			if($input['stay'] != '') {
168
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
-			} else {
171
-				$stayUrl = "index.php?a=75&r=2";
172
-			}
173
-
174
-			include_once "header.inc.php";
175
-			?>
72
+    case '11' : // new user
73
+        // check if this user name already exist
74
+        $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
+        $limit = $modx->db->getValue($rs);
76
+        if($limit > 0) {
77
+            webAlertAndQuit("User name is already in use!");
78
+        }
79
+
80
+        // check if the email address already exist
81
+        $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
+        $limit = $modx->db->getValue($rs);
83
+        if($limit > 0) {
84
+            webAlertAndQuit("Email is already in use!");
85
+        }
86
+
87
+        // generate a new password for this user
88
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+            if(strlen($specifiedpassword) < 6) {
90
+                webAlertAndQuit("Password is too short!");
91
+            } else {
92
+                $newpassword = $specifiedpassword;
93
+            }
94
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+            webAlertAndQuit("You didn't specify a password for this user!");
96
+        } elseif($passwordgenmethod == 'g') {
97
+            $newpassword = generate_password(8);
98
+        } else {
99
+            webAlertAndQuit("No password generation method specified!");
100
+        }
101
+
102
+        // invoke OnBeforeUserFormSave event
103
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
104
+            "mode" => "new",
105
+        ));
106
+
107
+        // create the user account
108
+        $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
+
110
+        $field = array();
111
+        $field['password'] = $modx->phpass->HashPassword($newpassword);
112
+        $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
+
114
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
+        $field = $modx->db->escape($field);
116
+        $modx->db->insert($field, $tbl_user_attributes);
117
+
118
+        // Save user settings
119
+        saveUserSettings($internalKey);
120
+
121
+        // invoke OnManagerSaveUser event
122
+        $modx->invokeEvent("OnManagerSaveUser", array(
123
+            "mode" => "new",
124
+            "userid" => $internalKey,
125
+            "username" => $newusername,
126
+            "userpassword" => $newpassword,
127
+            "useremail" => $email,
128
+            "userfullname" => $fullname,
129
+            "userroleid" => $role
130
+        ));
131
+
132
+        // invoke OnUserFormSave event
133
+        $modx->invokeEvent("OnUserFormSave", array(
134
+            "mode" => "new",
135
+            "id" => $internalKey
136
+        ));
137
+
138
+        // Set the item name for logger
139
+        $_SESSION['itemname'] = $newusername;
140
+
141
+        /*******************************************************************************/
142
+        // put the user in the user_groups he/ she should be in
143
+        // first, check that up_perms are switched on!
144
+        if($use_udperms == 1) {
145
+            if(!empty($user_groups)) {
146
+                for($i = 0; $i < count($user_groups); $i++) {
147
+                    $f = array();
148
+                    $f['user_group'] = (int)$user_groups[$i];
149
+                    $f['member'] = $internalKey;
150
+                    $modx->db->insert($f, $tbl_member_groups);
151
+                }
152
+            }
153
+        }
154
+        // end of user_groups stuff!
155
+
156
+        if($passwordnotifymethod == 'e') {
157
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
158
+            if($input['stay'] != '') {
159
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+                header($header);
162
+            } else {
163
+                $header = "Location: index.php?a=75&r=2";
164
+                header($header);
165
+            }
166
+        } else {
167
+            if($input['stay'] != '') {
168
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
+            } else {
171
+                $stayUrl = "index.php?a=75&r=2";
172
+            }
173
+
174
+            include_once "header.inc.php";
175
+            ?>
176 176
 
177 177
 			<h1><?php echo $_lang['user_title']; ?></h1>
178 178
 
@@ -194,125 +194,125 @@  discard block
 block discarded – undo
194 194
 			</div>
195 195
 			<?php
196 196
 
197
-			include_once "footer.inc.php";
198
-		}
199
-		break;
200
-	case '12' : // edit user
201
-		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
205
-					webAlertAndQuit("Password is too short!");
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!");
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
218
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
219
-		}
220
-
221
-		// check if the username already exist
222
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
-		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
225
-			webAlertAndQuit("User name is already in use!");
226
-		}
227
-
228
-		// check if the email address already exists
229
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
-		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
232
-			webAlertAndQuit("Email is already in use!");
233
-		}
234
-
235
-		// invoke OnBeforeUserFormSave event
236
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
237
-			"mode" => "upd",
238
-			"id" => $id
239
-		));
240
-
241
-		// update user name and password
242
-		$field = array();
243
-		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
245
-			$field['password'] = $modx->phpass->HashPassword($newpassword);
246
-		}
247
-		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
-		$field = $modx->db->escape($field);
250
-		$modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
-
252
-		// Save user settings
253
-		saveUserSettings($id);
254
-
255
-		// Set the item name for logger
256
-		$_SESSION['itemname'] = $newusername;
257
-
258
-		// invoke OnManagerSaveUser event
259
-		$modx->invokeEvent("OnManagerSaveUser", array(
260
-			"mode" => "upd",
261
-			"userid" => $id,
262
-			"username" => $newusername,
263
-			"userpassword" => $newpassword,
264
-			"useremail" => $email,
265
-			"userfullname" => $fullname,
266
-			"userroleid" => $role,
267
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
-		));
270
-
271
-		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
273
-			$modx->invokeEvent("OnManagerChangePassword", array(
274
-				"userid" => $id,
275
-				"username" => $newusername,
276
-				"userpassword" => $newpassword
277
-			));
278
-		}
279
-
280
-		// invoke OnUserFormSave event
281
-		$modx->invokeEvent("OnUserFormSave", array(
282
-			"mode" => "upd",
283
-			"id" => $id
284
-		));
285
-
286
-		/*******************************************************************************/
287
-		// put the user in the user_groups he/ she should be in
288
-		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
290
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
-			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
294
-					$field = array();
295
-					$field['user_group'] = (int)$user_groups[$i];
296
-					$field['member'] = $id;
297
-					$modx->db->insert($field, $tbl_member_groups);
298
-				}
299
-			}
300
-		}
301
-		// end of user_groups stuff!
302
-		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
-		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
308
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
-			} else {
311
-				$stayUrl = "index.php?a=75&r=2";
312
-			}
313
-
314
-			include_once "header.inc.php";
315
-			?>
197
+            include_once "footer.inc.php";
198
+        }
199
+        break;
200
+    case '12' : // edit user
201
+        // generate a new password for this user
202
+        if($genpassword == 1) {
203
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+                if(strlen($specifiedpassword) < 6) {
205
+                    webAlertAndQuit("Password is too short!");
206
+                } else {
207
+                    $newpassword = $specifiedpassword;
208
+                }
209
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+                webAlertAndQuit("You didn't specify a password for this user!");
211
+            } elseif($passwordgenmethod == 'g') {
212
+                $newpassword = generate_password(8);
213
+            } else {
214
+                webAlertAndQuit("No password generation method specified!");
215
+            }
216
+        }
217
+        if($passwordnotifymethod == 'e') {
218
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
219
+        }
220
+
221
+        // check if the username already exist
222
+        $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
+        $limit = $modx->db->getValue($rs);
224
+        if($limit > 0) {
225
+            webAlertAndQuit("User name is already in use!");
226
+        }
227
+
228
+        // check if the email address already exists
229
+        $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
+        $limit = $modx->db->getValue($rs);
231
+        if($limit > 0) {
232
+            webAlertAndQuit("Email is already in use!");
233
+        }
234
+
235
+        // invoke OnBeforeUserFormSave event
236
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
237
+            "mode" => "upd",
238
+            "id" => $id
239
+        ));
240
+
241
+        // update user name and password
242
+        $field = array();
243
+        $field['username'] = $modx->db->escape($newusername);
244
+        if($genpassword == 1) {
245
+            $field['password'] = $modx->phpass->HashPassword($newpassword);
246
+        }
247
+        $modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
+        $field = $modx->db->escape($field);
250
+        $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
+
252
+        // Save user settings
253
+        saveUserSettings($id);
254
+
255
+        // Set the item name for logger
256
+        $_SESSION['itemname'] = $newusername;
257
+
258
+        // invoke OnManagerSaveUser event
259
+        $modx->invokeEvent("OnManagerSaveUser", array(
260
+            "mode" => "upd",
261
+            "userid" => $id,
262
+            "username" => $newusername,
263
+            "userpassword" => $newpassword,
264
+            "useremail" => $email,
265
+            "userfullname" => $fullname,
266
+            "userroleid" => $role,
267
+            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
+            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
+        ));
270
+
271
+        // invoke OnManagerChangePassword event
272
+        if($genpassword == 1) {
273
+            $modx->invokeEvent("OnManagerChangePassword", array(
274
+                "userid" => $id,
275
+                "username" => $newusername,
276
+                "userpassword" => $newpassword
277
+            ));
278
+        }
279
+
280
+        // invoke OnUserFormSave event
281
+        $modx->invokeEvent("OnUserFormSave", array(
282
+            "mode" => "upd",
283
+            "id" => $id
284
+        ));
285
+
286
+        /*******************************************************************************/
287
+        // put the user in the user_groups he/ she should be in
288
+        // first, check that up_perms are switched on!
289
+        if($use_udperms == 1) {
290
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
+            $modx->db->delete($tbl_member_groups, "member='{$id}'");
292
+            if(!empty($user_groups)) {
293
+                for($i = 0; $i < count($user_groups); $i++) {
294
+                    $field = array();
295
+                    $field['user_group'] = (int)$user_groups[$i];
296
+                    $field['member'] = $id;
297
+                    $modx->db->insert($field, $tbl_member_groups);
298
+                }
299
+            }
300
+        }
301
+        // end of user_groups stuff!
302
+        /*******************************************************************************/
303
+        if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
+            $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
+        }
306
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
307
+            if($input['stay'] != '') {
308
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
+            } else {
311
+                $stayUrl = "index.php?a=75&r=2";
312
+            }
313
+
314
+            include_once "header.inc.php";
315
+            ?>
316 316
 
317 317
 			<h1><?php echo $_lang['user_title']; ?></h1>
318 318
 
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
 			</div>
333 333
 			<?php
334 334
 
335
-			include_once "footer.inc.php";
336
-		} else {
337
-			if($input['stay'] != '') {
338
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
-				header($header);
341
-			} else {
342
-				$header = "Location: index.php?a=75&r=2";
343
-				header($header);
344
-			}
345
-		}
346
-		break;
347
-	default:
348
-		webAlertAndQuit("No operation set in request.");
335
+            include_once "footer.inc.php";
336
+        } else {
337
+            if($input['stay'] != '') {
338
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
+                header($header);
341
+            } else {
342
+                $header = "Location: index.php?a=75&r=2";
343
+                header($header);
344
+            }
345
+        }
346
+        break;
347
+    default:
348
+        webAlertAndQuit("No operation set in request.");
349 349
 }
350 350
 
351 351
 /**
@@ -357,31 +357,31 @@  discard block
 block discarded – undo
357 357
  * @param string $ufn
358 358
  */
359 359
 function sendMailMessage($email, $uid, $pwd, $ufn) {
360
-	global $modx, $_lang, $signupemail_message;
361
-	global $emailsubject, $emailsender;
362
-	global $site_name;
363
-	$manager_url = MODX_MANAGER_URL;
364
-	$message = sprintf($signupemail_message, $uid, $pwd); // use old method
365
-	// replace placeholders
366
-	$message = str_replace("[+uid+]", $uid, $message);
367
-	$message = str_replace("[+pwd+]", $pwd, $message);
368
-	$message = str_replace("[+ufn+]", $ufn, $message);
369
-	$message = str_replace("[+sname+]", $site_name, $message);
370
-	$message = str_replace("[+saddr+]", $emailsender, $message);
371
-	$message = str_replace("[+semail+]", $emailsender, $message);
372
-	$message = str_replace("[+surl+]", $manager_url, $message);
373
-
374
-	$param = array();
375
-	$param['from'] = "{$site_name}<{$emailsender}>";
376
-	$param['subject'] = $emailsubject;
377
-	$param['body'] = $message;
378
-	$param['to'] = $email;
379
-	$param['type'] = 'text';
380
-	$rs = $modx->sendmail($param);
381
-	if(!$rs) {
382
-		$modx->manager->saveFormValues();
383
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
384
-	}
360
+    global $modx, $_lang, $signupemail_message;
361
+    global $emailsubject, $emailsender;
362
+    global $site_name;
363
+    $manager_url = MODX_MANAGER_URL;
364
+    $message = sprintf($signupemail_message, $uid, $pwd); // use old method
365
+    // replace placeholders
366
+    $message = str_replace("[+uid+]", $uid, $message);
367
+    $message = str_replace("[+pwd+]", $pwd, $message);
368
+    $message = str_replace("[+ufn+]", $ufn, $message);
369
+    $message = str_replace("[+sname+]", $site_name, $message);
370
+    $message = str_replace("[+saddr+]", $emailsender, $message);
371
+    $message = str_replace("[+semail+]", $emailsender, $message);
372
+    $message = str_replace("[+surl+]", $manager_url, $message);
373
+
374
+    $param = array();
375
+    $param['from'] = "{$site_name}<{$emailsender}>";
376
+    $param['subject'] = $emailsubject;
377
+    $param['body'] = $message;
378
+    $param['to'] = $email;
379
+    $param['type'] = 'text';
380
+    $rs = $modx->sendmail($param);
381
+    if(!$rs) {
382
+        $modx->manager->saveFormValues();
383
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
384
+    }
385 385
 }
386 386
 
387 387
 /**
@@ -390,86 +390,86 @@  discard block
 block discarded – undo
390 390
  * @param int $id
391 391
  */
392 392
 function saveUserSettings($id) {
393
-	global $modx;
394
-	$tbl_user_settings = $modx->getFullTableName('user_settings');
395
-
396
-	$ignore = array(
397
-		'id',
398
-		'oldusername',
399
-		'oldemail',
400
-		'newusername',
401
-		'fullname',
402
-		'newpassword',
403
-		'newpasswordcheck',
404
-		'passwordgenmethod',
405
-		'passwordnotifymethod',
406
-		'specifiedpassword',
407
-		'confirmpassword',
408
-		'email',
409
-		'phone',
410
-		'mobilephone',
411
-		'fax',
412
-		'dob',
413
-		'country',
414
-		'street',
415
-		'city',
416
-		'state',
417
-		'zip',
418
-		'gender',
419
-		'photo',
420
-		'comment',
421
-		'role',
422
-		'failedlogincount',
423
-		'blocked',
424
-		'blockeduntil',
425
-		'blockedafter',
426
-		'user_groups',
427
-		'mode',
428
-		'blockedmode',
429
-		'stay',
430
-		'save',
431
-		'theme_refresher'
432
-	);
433
-
434
-	// determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values)
435
-	$defaults = array(
436
-		'upload_images',
437
-		'upload_media',
438
-		'upload_flash',
439
-		'upload_files'
440
-	);
441
-
442
-	// get user setting field names
443
-	$settings = array();
444
-	foreach($_POST as $n => $v) {
445
-		if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
446
-			continue;
447
-		} // ignore blacklist and empties
448
-		$settings[$n] = $v; // this value should be saved
449
-	}
450
-
451
-	foreach($defaults as $k) {
452
-		if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
453
-			unset($settings[$k]);
454
-		}
455
-		unset($settings['default_' . $k]);
456
-	}
457
-
458
-	$modx->db->delete($tbl_user_settings, "user='{$id}'");
459
-
460
-	foreach($settings as $n => $vl) {
461
-		if(is_array($vl)) {
462
-			$vl = implode(",", $vl);
463
-		}
464
-		if($vl != '') {
465
-			$f = array();
466
-			$f['user'] = $id;
467
-			$f['setting_name'] = $n;
468
-			$f['setting_value'] = $vl;
469
-			$f = $modx->db->escape($f);
470
-			$modx->db->insert($f, $tbl_user_settings);
471
-		}
472
-	}
393
+    global $modx;
394
+    $tbl_user_settings = $modx->getFullTableName('user_settings');
395
+
396
+    $ignore = array(
397
+        'id',
398
+        'oldusername',
399
+        'oldemail',
400
+        'newusername',
401
+        'fullname',
402
+        'newpassword',
403
+        'newpasswordcheck',
404
+        'passwordgenmethod',
405
+        'passwordnotifymethod',
406
+        'specifiedpassword',
407
+        'confirmpassword',
408
+        'email',
409
+        'phone',
410
+        'mobilephone',
411
+        'fax',
412
+        'dob',
413
+        'country',
414
+        'street',
415
+        'city',
416
+        'state',
417
+        'zip',
418
+        'gender',
419
+        'photo',
420
+        'comment',
421
+        'role',
422
+        'failedlogincount',
423
+        'blocked',
424
+        'blockeduntil',
425
+        'blockedafter',
426
+        'user_groups',
427
+        'mode',
428
+        'blockedmode',
429
+        'stay',
430
+        'save',
431
+        'theme_refresher'
432
+    );
433
+
434
+    // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values)
435
+    $defaults = array(
436
+        'upload_images',
437
+        'upload_media',
438
+        'upload_flash',
439
+        'upload_files'
440
+    );
441
+
442
+    // get user setting field names
443
+    $settings = array();
444
+    foreach($_POST as $n => $v) {
445
+        if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
446
+            continue;
447
+        } // ignore blacklist and empties
448
+        $settings[$n] = $v; // this value should be saved
449
+    }
450
+
451
+    foreach($defaults as $k) {
452
+        if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
453
+            unset($settings[$k]);
454
+        }
455
+        unset($settings['default_' . $k]);
456
+    }
457
+
458
+    $modx->db->delete($tbl_user_settings, "user='{$id}'");
459
+
460
+    foreach($settings as $n => $vl) {
461
+        if(is_array($vl)) {
462
+            $vl = implode(",", $vl);
463
+        }
464
+        if($vl != '') {
465
+            $f = array();
466
+            $f['user'] = $id;
467
+            $f['setting_name'] = $n;
468
+            $f['setting_value'] = $vl;
469
+            $f = $modx->db->escape($f);
470
+            $modx->db->insert($f, $tbl_user_settings);
471
+        }
472
+    }
473 473
 }
474 474
 
475 475
 /**
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
  * @param $msg
479 479
  */
480 480
 function webAlertAndQuit($msg) {
481
-	global $id, $modx;
482
-	$mode = $_POST['mode'];
483
-	$modx->manager->saveFormValues($mode);
484
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
481
+    global $id, $modx;
482
+    $mode = $_POST['mode'];
483
+    $modx->manager->saveFormValues($mode);
484
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
485 485
 }
486 486
 
487 487
 /**
@@ -491,12 +491,12 @@  discard block
 block discarded – undo
491 491
  * @return string
492 492
  */
493 493
 function generate_password($length = 10) {
494
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495
-	$ps_len = strlen($allowable_characters);
496
-	mt_srand((double) microtime() * 1000000);
497
-	$pass = "";
498
-	for($i = 0; $i < $length; $i++) {
499
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
500
-	}
501
-	return $pass;
494
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495
+    $ps_len = strlen($allowable_characters);
496
+    mt_srand((double) microtime() * 1000000);
497
+    $pass = "";
498
+    for($i = 0; $i < $length; $i++) {
499
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
500
+    }
501
+    return $pass;
502 502
 }
Please login to merge, or discard this patch.
Switch Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -69,110 +69,110 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 switch($input['mode']) {
72
-	case '11' : // new user
73
-		// check if this user name already exist
74
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
-		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
77
-			webAlertAndQuit("User name is already in use!");
78
-		}
79
-
80
-		// check if the email address already exist
81
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
-		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
84
-			webAlertAndQuit("Email is already in use!");
85
-		}
86
-
87
-		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
90
-				webAlertAndQuit("Password is too short!");
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!");
100
-		}
101
-
102
-		// invoke OnBeforeUserFormSave event
103
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
104
-			"mode" => "new",
105
-		));
106
-
107
-		// create the user account
108
-		$internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
-
110
-		$field = array();
111
-		$field['password'] = $modx->phpass->HashPassword($newpassword);
112
-		$modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
-
114
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
-		$field = $modx->db->escape($field);
116
-		$modx->db->insert($field, $tbl_user_attributes);
117
-
118
-		// Save user settings
119
-		saveUserSettings($internalKey);
120
-
121
-		// invoke OnManagerSaveUser event
122
-		$modx->invokeEvent("OnManagerSaveUser", array(
123
-			"mode" => "new",
124
-			"userid" => $internalKey,
125
-			"username" => $newusername,
126
-			"userpassword" => $newpassword,
127
-			"useremail" => $email,
128
-			"userfullname" => $fullname,
129
-			"userroleid" => $role
130
-		));
131
-
132
-		// invoke OnUserFormSave event
133
-		$modx->invokeEvent("OnUserFormSave", array(
134
-			"mode" => "new",
135
-			"id" => $internalKey
136
-		));
137
-
138
-		// Set the item name for logger
139
-		$_SESSION['itemname'] = $newusername;
140
-
141
-		/*******************************************************************************/
142
-		// put the user in the user_groups he/ she should be in
143
-		// first, check that up_perms are switched on!
144
-		if($use_udperms == 1) {
145
-			if(!empty($user_groups)) {
146
-				for($i = 0; $i < count($user_groups); $i++) {
147
-					$f = array();
148
-					$f['user_group'] = (int)$user_groups[$i];
149
-					$f['member'] = $internalKey;
150
-					$modx->db->insert($f, $tbl_member_groups);
151
-				}
152
-			}
153
-		}
154
-		// end of user_groups stuff!
155
-
156
-		if($passwordnotifymethod == 'e') {
157
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-				header($header);
162
-			} else {
163
-				$header = "Location: index.php?a=75&r=2";
164
-				header($header);
165
-			}
166
-		} else {
167
-			if($input['stay'] != '') {
168
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
-			} else {
171
-				$stayUrl = "index.php?a=75&r=2";
172
-			}
173
-
174
-			include_once "header.inc.php";
175
-			?>
72
+	    case '11' : // new user
73
+		    // check if this user name already exist
74
+		    $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
+		    $limit = $modx->db->getValue($rs);
76
+		    if($limit > 0) {
77
+			    webAlertAndQuit("User name is already in use!");
78
+		    }
79
+
80
+		    // check if the email address already exist
81
+		    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
+		    $limit = $modx->db->getValue($rs);
83
+		    if($limit > 0) {
84
+			    webAlertAndQuit("Email is already in use!");
85
+		    }
86
+
87
+		    // generate a new password for this user
88
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+			    if(strlen($specifiedpassword) < 6) {
90
+				    webAlertAndQuit("Password is too short!");
91
+			    } else {
92
+				    $newpassword = $specifiedpassword;
93
+			    }
94
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+			    webAlertAndQuit("You didn't specify a password for this user!");
96
+		    } elseif($passwordgenmethod == 'g') {
97
+			    $newpassword = generate_password(8);
98
+		    } else {
99
+			    webAlertAndQuit("No password generation method specified!");
100
+		    }
101
+
102
+		    // invoke OnBeforeUserFormSave event
103
+		    $modx->invokeEvent("OnBeforeUserFormSave", array(
104
+			    "mode" => "new",
105
+		    ));
106
+
107
+		    // create the user account
108
+		    $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
+
110
+		    $field = array();
111
+		    $field['password'] = $modx->phpass->HashPassword($newpassword);
112
+		    $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
+
114
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
+		    $field = $modx->db->escape($field);
116
+		    $modx->db->insert($field, $tbl_user_attributes);
117
+
118
+		    // Save user settings
119
+		    saveUserSettings($internalKey);
120
+
121
+		    // invoke OnManagerSaveUser event
122
+		    $modx->invokeEvent("OnManagerSaveUser", array(
123
+			    "mode" => "new",
124
+			    "userid" => $internalKey,
125
+			    "username" => $newusername,
126
+			    "userpassword" => $newpassword,
127
+			    "useremail" => $email,
128
+			    "userfullname" => $fullname,
129
+			    "userroleid" => $role
130
+		    ));
131
+
132
+		    // invoke OnUserFormSave event
133
+		    $modx->invokeEvent("OnUserFormSave", array(
134
+			    "mode" => "new",
135
+			    "id" => $internalKey
136
+		    ));
137
+
138
+		    // Set the item name for logger
139
+		    $_SESSION['itemname'] = $newusername;
140
+
141
+		    /*******************************************************************************/
142
+		    // put the user in the user_groups he/ she should be in
143
+		    // first, check that up_perms are switched on!
144
+		    if($use_udperms == 1) {
145
+			    if(!empty($user_groups)) {
146
+				    for($i = 0; $i < count($user_groups); $i++) {
147
+					    $f = array();
148
+					    $f['user_group'] = (int)$user_groups[$i];
149
+					    $f['member'] = $internalKey;
150
+					    $modx->db->insert($f, $tbl_member_groups);
151
+				    }
152
+			    }
153
+		    }
154
+		    // end of user_groups stuff!
155
+
156
+		    if($passwordnotifymethod == 'e') {
157
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
158
+			    if($input['stay'] != '') {
159
+				    $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+				    header($header);
162
+			    } else {
163
+				    $header = "Location: index.php?a=75&r=2";
164
+				    header($header);
165
+			    }
166
+		    } else {
167
+			    if($input['stay'] != '') {
168
+				    $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
+			    } else {
171
+				    $stayUrl = "index.php?a=75&r=2";
172
+			    }
173
+
174
+			    include_once "header.inc.php";
175
+			    ?>
176 176
 
177 177
 			<h1><?php echo $_lang['user_title']; ?></h1>
178 178
 
@@ -194,125 +194,125 @@  discard block
 block discarded – undo
194 194
 			</div>
195 195
 			<?php
196 196
 
197
-			include_once "footer.inc.php";
198
-		}
199
-		break;
200
-	case '12' : // edit user
201
-		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
205
-					webAlertAndQuit("Password is too short!");
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!");
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
218
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
219
-		}
220
-
221
-		// check if the username already exist
222
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
-		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
225
-			webAlertAndQuit("User name is already in use!");
226
-		}
227
-
228
-		// check if the email address already exists
229
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
-		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
232
-			webAlertAndQuit("Email is already in use!");
233
-		}
234
-
235
-		// invoke OnBeforeUserFormSave event
236
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
237
-			"mode" => "upd",
238
-			"id" => $id
239
-		));
240
-
241
-		// update user name and password
242
-		$field = array();
243
-		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
245
-			$field['password'] = $modx->phpass->HashPassword($newpassword);
246
-		}
247
-		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
-		$field = $modx->db->escape($field);
250
-		$modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
-
252
-		// Save user settings
253
-		saveUserSettings($id);
254
-
255
-		// Set the item name for logger
256
-		$_SESSION['itemname'] = $newusername;
257
-
258
-		// invoke OnManagerSaveUser event
259
-		$modx->invokeEvent("OnManagerSaveUser", array(
260
-			"mode" => "upd",
261
-			"userid" => $id,
262
-			"username" => $newusername,
263
-			"userpassword" => $newpassword,
264
-			"useremail" => $email,
265
-			"userfullname" => $fullname,
266
-			"userroleid" => $role,
267
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
-		));
270
-
271
-		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
273
-			$modx->invokeEvent("OnManagerChangePassword", array(
274
-				"userid" => $id,
275
-				"username" => $newusername,
276
-				"userpassword" => $newpassword
277
-			));
278
-		}
279
-
280
-		// invoke OnUserFormSave event
281
-		$modx->invokeEvent("OnUserFormSave", array(
282
-			"mode" => "upd",
283
-			"id" => $id
284
-		));
285
-
286
-		/*******************************************************************************/
287
-		// put the user in the user_groups he/ she should be in
288
-		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
290
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
-			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
294
-					$field = array();
295
-					$field['user_group'] = (int)$user_groups[$i];
296
-					$field['member'] = $id;
297
-					$modx->db->insert($field, $tbl_member_groups);
298
-				}
299
-			}
300
-		}
301
-		// end of user_groups stuff!
302
-		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
-		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
308
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
-			} else {
311
-				$stayUrl = "index.php?a=75&r=2";
312
-			}
313
-
314
-			include_once "header.inc.php";
315
-			?>
197
+			    include_once "footer.inc.php";
198
+		    }
199
+		    break;
200
+	    case '12' : // edit user
201
+		    // generate a new password for this user
202
+		    if($genpassword == 1) {
203
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+				    if(strlen($specifiedpassword) < 6) {
205
+					    webAlertAndQuit("Password is too short!");
206
+				    } else {
207
+					    $newpassword = $specifiedpassword;
208
+				    }
209
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+				    webAlertAndQuit("You didn't specify a password for this user!");
211
+			    } elseif($passwordgenmethod == 'g') {
212
+				    $newpassword = generate_password(8);
213
+			    } else {
214
+				    webAlertAndQuit("No password generation method specified!");
215
+			    }
216
+		    }
217
+		    if($passwordnotifymethod == 'e') {
218
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
219
+		    }
220
+
221
+		    // check if the username already exist
222
+		    $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
+		    $limit = $modx->db->getValue($rs);
224
+		    if($limit > 0) {
225
+			    webAlertAndQuit("User name is already in use!");
226
+		    }
227
+
228
+		    // check if the email address already exists
229
+		    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
+		    $limit = $modx->db->getValue($rs);
231
+		    if($limit > 0) {
232
+			    webAlertAndQuit("Email is already in use!");
233
+		    }
234
+
235
+		    // invoke OnBeforeUserFormSave event
236
+		    $modx->invokeEvent("OnBeforeUserFormSave", array(
237
+			    "mode" => "upd",
238
+			    "id" => $id
239
+		    ));
240
+
241
+		    // update user name and password
242
+		    $field = array();
243
+		    $field['username'] = $modx->db->escape($newusername);
244
+		    if($genpassword == 1) {
245
+			    $field['password'] = $modx->phpass->HashPassword($newpassword);
246
+		    }
247
+		    $modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
+		    $field = $modx->db->escape($field);
250
+		    $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
+
252
+		    // Save user settings
253
+		    saveUserSettings($id);
254
+
255
+		    // Set the item name for logger
256
+		    $_SESSION['itemname'] = $newusername;
257
+
258
+		    // invoke OnManagerSaveUser event
259
+		    $modx->invokeEvent("OnManagerSaveUser", array(
260
+			    "mode" => "upd",
261
+			    "userid" => $id,
262
+			    "username" => $newusername,
263
+			    "userpassword" => $newpassword,
264
+			    "useremail" => $email,
265
+			    "userfullname" => $fullname,
266
+			    "userroleid" => $role,
267
+			    "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
+			    "olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
+		    ));
270
+
271
+		    // invoke OnManagerChangePassword event
272
+		    if($genpassword == 1) {
273
+			    $modx->invokeEvent("OnManagerChangePassword", array(
274
+				    "userid" => $id,
275
+				    "username" => $newusername,
276
+				    "userpassword" => $newpassword
277
+			    ));
278
+		    }
279
+
280
+		    // invoke OnUserFormSave event
281
+		    $modx->invokeEvent("OnUserFormSave", array(
282
+			    "mode" => "upd",
283
+			    "id" => $id
284
+		    ));
285
+
286
+		    /*******************************************************************************/
287
+		    // put the user in the user_groups he/ she should be in
288
+		    // first, check that up_perms are switched on!
289
+		    if($use_udperms == 1) {
290
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
+			    $modx->db->delete($tbl_member_groups, "member='{$id}'");
292
+			    if(!empty($user_groups)) {
293
+				    for($i = 0; $i < count($user_groups); $i++) {
294
+					    $field = array();
295
+					    $field['user_group'] = (int)$user_groups[$i];
296
+					    $field['member'] = $id;
297
+					    $modx->db->insert($field, $tbl_member_groups);
298
+				    }
299
+			    }
300
+		    }
301
+		    // end of user_groups stuff!
302
+		    /*******************************************************************************/
303
+		    if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
+			    $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
+		    }
306
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
307
+			    if($input['stay'] != '') {
308
+				    $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
+			    } else {
311
+				    $stayUrl = "index.php?a=75&r=2";
312
+			    }
313
+
314
+			    include_once "header.inc.php";
315
+			    ?>
316 316
 
317 317
 			<h1><?php echo $_lang['user_title']; ?></h1>
318 318
 
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
 			</div>
333 333
 			<?php
334 334
 
335
-			include_once "footer.inc.php";
336
-		} else {
337
-			if($input['stay'] != '') {
338
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
-				header($header);
341
-			} else {
342
-				$header = "Location: index.php?a=75&r=2";
343
-				header($header);
344
-			}
345
-		}
346
-		break;
347
-	default:
348
-		webAlertAndQuit("No operation set in request.");
335
+			    include_once "footer.inc.php";
336
+		    } else {
337
+			    if($input['stay'] != '') {
338
+				    $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
+				    header($header);
341
+			    } else {
342
+				    $header = "Location: index.php?a=75&r=2";
343
+				    header($header);
344
+			    }
345
+		    }
346
+		    break;
347
+	    default:
348
+		    webAlertAndQuit("No operation set in request.");
349 349
 }
350 350
 
351 351
 /**
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  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
-if(!$modx->hasPermission('save_user')) {
5
+if (!$modx->hasPermission('save_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 $input = $_POST;
16 16
 
17
-$id = (int)$input['id'];
17
+$id = (int) $input['id'];
18 18
 $oldusername = $input['oldusername'];
19 19
 $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User";
20 20
 $fullname = $input['fullname'];
@@ -44,56 +44,56 @@  discard block
 block discarded – undo
44 44
 $user_groups = $input['user_groups'];
45 45
 
46 46
 // verify password
47
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
47
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
48 48
 	webAlertAndQuit("Password typed is mismatched");
49 49
 }
50 50
 
51 51
 // verify email
52
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
52
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
53 53
 	webAlertAndQuit("E-mail address doesn't seem to be valid!");
54 54
 }
55 55
 
56 56
 // verify admin security
57
-if($_SESSION['mgrRole'] != 1) {
57
+if ($_SESSION['mgrRole'] != 1) {
58 58
 	// Check to see if user tried to spoof a "1" (admin) role
59
-	if(!$modx->hasPermission('save_role')) {
59
+	if (!$modx->hasPermission('save_role')) {
60 60
 		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61 61
 	}
62 62
 	// Verify that the user being edited wasn't an admin and the user ID got spoofed
63 63
 	$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64 64
 	$limit = $modx->db->getValue($rs);
65
-	if($limit > 0) {
65
+	if ($limit > 0) {
66 66
 		webAlertAndQuit("You cannot alter an administrative user.");
67 67
 	}
68 68
 
69 69
 }
70 70
 
71
-switch($input['mode']) {
71
+switch ($input['mode']) {
72 72
 	case '11' : // new user
73 73
 		// check if this user name already exist
74 74
 		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75 75
 		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
76
+		if ($limit > 0) {
77 77
 			webAlertAndQuit("User name is already in use!");
78 78
 		}
79 79
 
80 80
 		// check if the email address already exist
81 81
 		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82 82
 		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
83
+		if ($limit > 0) {
84 84
 			webAlertAndQuit("Email is already in use!");
85 85
 		}
86 86
 
87 87
 		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
88
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+			if (strlen($specifiedpassword) < 6) {
90 90
 				webAlertAndQuit("Password is too short!");
91 91
 			} else {
92 92
 				$newpassword = $specifiedpassword;
93 93
 			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
94
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
95 95
 			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
96
+		} elseif ($passwordgenmethod == 'g') {
97 97
 			$newpassword = generate_password(8);
98 98
 		} else {
99 99
 			webAlertAndQuit("No password generation method specified!");
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 		/*******************************************************************************/
142 142
 		// put the user in the user_groups he/ she should be in
143 143
 		// first, check that up_perms are switched on!
144
-		if($use_udperms == 1) {
145
-			if(!empty($user_groups)) {
146
-				for($i = 0; $i < count($user_groups); $i++) {
144
+		if ($use_udperms == 1) {
145
+			if (!empty($user_groups)) {
146
+				for ($i = 0; $i < count($user_groups); $i++) {
147 147
 					$f = array();
148
-					$f['user_group'] = (int)$user_groups[$i];
148
+					$f['user_group'] = (int) $user_groups[$i];
149 149
 					$f['member'] = $internalKey;
150 150
 					$modx->db->insert($f, $tbl_member_groups);
151 151
 				}
@@ -153,20 +153,20 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 		// end of user_groups stuff!
155 155
 
156
-		if($passwordnotifymethod == 'e') {
156
+		if ($passwordnotifymethod == 'e') {
157 157
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
158
+			if ($input['stay'] != '') {
159 159
 				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
160
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
161 161
 				header($header);
162 162
 			} else {
163 163
 				$header = "Location: index.php?a=75&r=2";
164 164
 				header($header);
165 165
 			}
166 166
 		} else {
167
-			if($input['stay'] != '') {
167
+			if ($input['stay'] != '') {
168 168
 				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
169
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
170 170
 			} else {
171 171
 				$stayUrl = "index.php?a=75&r=2";
172 172
 			}
@@ -199,36 +199,36 @@  discard block
 block discarded – undo
199 199
 		break;
200 200
 	case '12' : // edit user
201 201
 		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
202
+		if ($genpassword == 1) {
203
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+				if (strlen($specifiedpassword) < 6) {
205 205
 					webAlertAndQuit("Password is too short!");
206 206
 				} else {
207 207
 					$newpassword = $specifiedpassword;
208 208
 				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
209
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
210 210
 				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
211
+			} elseif ($passwordgenmethod == 'g') {
212 212
 				$newpassword = generate_password(8);
213 213
 			} else {
214 214
 				webAlertAndQuit("No password generation method specified!");
215 215
 			}
216 216
 		}
217
-		if($passwordnotifymethod == 'e') {
217
+		if ($passwordnotifymethod == 'e') {
218 218
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
219 219
 		}
220 220
 
221 221
 		// check if the username already exist
222 222
 		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223 223
 		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
224
+		if ($limit > 0) {
225 225
 			webAlertAndQuit("User name is already in use!");
226 226
 		}
227 227
 
228 228
 		// check if the email address already exists
229 229
 		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230 230
 		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
231
+		if ($limit > 0) {
232 232
 			webAlertAndQuit("Email is already in use!");
233 233
 		}
234 234
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		// update user name and password
242 242
 		$field = array();
243 243
 		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
244
+		if ($genpassword == 1) {
245 245
 			$field['password'] = $modx->phpass->HashPassword($newpassword);
246 246
 		}
247 247
 		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		));
270 270
 
271 271
 		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
272
+		if ($genpassword == 1) {
273 273
 			$modx->invokeEvent("OnManagerChangePassword", array(
274 274
 				"userid" => $id,
275 275
 				"username" => $newusername,
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
 		/*******************************************************************************/
287 287
 		// put the user in the user_groups he/ she should be in
288 288
 		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
289
+		if ($use_udperms == 1) {
290 290
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291 291
 			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
292
+			if (!empty($user_groups)) {
293
+				for ($i = 0; $i < count($user_groups); $i++) {
294 294
 					$field = array();
295
-					$field['user_group'] = (int)$user_groups[$i];
295
+					$field['user_group'] = (int) $user_groups[$i];
296 296
 					$field['member'] = $id;
297 297
 					$modx->db->insert($field, $tbl_member_groups);
298 298
 				}
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 		// end of user_groups stuff!
302 302
 		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
303
+		if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304 304
 			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305 305
 		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
306
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
307
+			if ($input['stay'] != '') {
308 308
 				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
309
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
310 310
 			} else {
311 311
 				$stayUrl = "index.php?a=75&r=2";
312 312
 			}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 				<div class="sectionHeader"><?php echo $_lang['user_title']; ?></div>
327 327
 				<div class="sectionBody">
328 328
 					<div id="disp">
329
-						<p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p>
329
+						<p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p>
330 330
 					</div>
331 331
 				</div>
332 332
 			</div>
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 
335 335
 			include_once "footer.inc.php";
336 336
 		} else {
337
-			if($input['stay'] != '') {
337
+			if ($input['stay'] != '') {
338 338
 				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
339
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
340 340
 				header($header);
341 341
 			} else {
342 342
 				$header = "Location: index.php?a=75&r=2";
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
  * @param string $pwd
357 357
  * @param string $ufn
358 358
  */
359
-function sendMailMessage($email, $uid, $pwd, $ufn) {
359
+function sendMailMessage($email, $uid, $pwd, $ufn){
360 360
 	global $modx, $_lang, $signupemail_message;
361 361
 	global $emailsubject, $emailsender;
362 362
 	global $site_name;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	$param['to'] = $email;
379 379
 	$param['type'] = 'text';
380 380
 	$rs = $modx->sendmail($param);
381
-	if(!$rs) {
381
+	if (!$rs) {
382 382
 		$modx->manager->saveFormValues();
383 383
 		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
384 384
 	}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
  *
390 390
  * @param int $id
391 391
  */
392
-function saveUserSettings($id) {
392
+function saveUserSettings($id){
393 393
 	global $modx;
394 394
 	$tbl_user_settings = $modx->getFullTableName('user_settings');
395 395
 
@@ -441,27 +441,27 @@  discard block
 block discarded – undo
441 441
 
442 442
 	// get user setting field names
443 443
 	$settings = array();
444
-	foreach($_POST as $n => $v) {
445
-		if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
444
+	foreach ($_POST as $n => $v) {
445
+		if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
446 446
 			continue;
447 447
 		} // ignore blacklist and empties
448 448
 		$settings[$n] = $v; // this value should be saved
449 449
 	}
450 450
 
451
-	foreach($defaults as $k) {
452
-		if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
451
+	foreach ($defaults as $k) {
452
+		if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') {
453 453
 			unset($settings[$k]);
454 454
 		}
455
-		unset($settings['default_' . $k]);
455
+		unset($settings['default_'.$k]);
456 456
 	}
457 457
 
458 458
 	$modx->db->delete($tbl_user_settings, "user='{$id}'");
459 459
 
460
-	foreach($settings as $n => $vl) {
461
-		if(is_array($vl)) {
460
+	foreach ($settings as $n => $vl) {
461
+		if (is_array($vl)) {
462 462
 			$vl = implode(",", $vl);
463 463
 		}
464
-		if($vl != '') {
464
+		if ($vl != '') {
465 465
 			$f = array();
466 466
 			$f['user'] = $id;
467 467
 			$f['setting_name'] = $n;
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
  *
478 478
  * @param $msg
479 479
  */
480
-function webAlertAndQuit($msg) {
480
+function webAlertAndQuit($msg){
481 481
 	global $id, $modx;
482 482
 	$mode = $_POST['mode'];
483 483
 	$modx->manager->saveFormValues($mode);
484
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
484
+	$modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : ''));
485 485
 }
486 486
 
487 487
 /**
@@ -490,12 +490,12 @@  discard block
 block discarded – undo
490 490
  * @param int $length
491 491
  * @return string
492 492
  */
493
-function generate_password($length = 10) {
493
+function generate_password($length = 10){
494 494
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495 495
 	$ps_len = strlen($allowable_characters);
496 496
 	mt_srand((double) microtime() * 1000000);
497 497
 	$pass = "";
498
-	for($i = 0; $i < $length; $i++) {
498
+	for ($i = 0; $i < $length; $i++) {
499 499
 		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
500 500
 	}
501 501
 	return $pass;
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -356,7 +356,8 @@  discard block
 block discarded – undo
356 356
  * @param string $pwd
357 357
  * @param string $ufn
358 358
  */
359
-function sendMailMessage($email, $uid, $pwd, $ufn) {
359
+function sendMailMessage($email, $uid, $pwd, $ufn)
360
+{
360 361
 	global $modx, $_lang, $signupemail_message;
361 362
 	global $emailsubject, $emailsender;
362 363
 	global $site_name;
@@ -389,7 +390,8 @@  discard block
 block discarded – undo
389 390
  *
390 391
  * @param int $id
391 392
  */
392
-function saveUserSettings($id) {
393
+function saveUserSettings($id)
394
+{
393 395
 	global $modx;
394 396
 	$tbl_user_settings = $modx->getFullTableName('user_settings');
395 397
 
@@ -477,7 +479,8 @@  discard block
 block discarded – undo
477 479
  *
478 480
  * @param $msg
479 481
  */
480
-function webAlertAndQuit($msg) {
482
+function webAlertAndQuit($msg)
483
+{
481 484
 	global $id, $modx;
482 485
 	$mode = $_POST['mode'];
483 486
 	$modx->manager->saveFormValues($mode);
@@ -490,7 +493,8 @@  discard block
 block discarded – undo
490 493
  * @param int $length
491 494
  * @return string
492 495
  */
493
-function generate_password($length = 10) {
496
+function generate_password($length = 10)
497
+{
494 498
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495 499
 	$ps_len = strlen($allowable_characters);
496 500
 	mt_srand((double) microtime() * 1000000);
Please login to merge, or discard this patch.
manager/processors/user_documents_permissions.class.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $role = $this->role;
37 37
 
38 38
         if ($role == 1) {
39
-            return true;  // administrator - grant all document permissions
39
+            return true; // administrator - grant all document permissions
40 40
         }
41 41
 
42 42
         if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) {
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
             are private to the manager users will not be private to web users if the
64 64
             document group is not assigned to a web user group and visa versa.
65 65
          */
66
-        $permissionsok = false;  // set permissions to false
66
+        $permissionsok = false; // set permissions to false
67 67
 
68 68
         $rs = $modx->db->select(
69 69
             'count(DISTINCT sc.id)',
70 70
             "{$tblsc} AS sc 
71 71
 				LEFT JOIN {$tbldg} AS dg on dg.document = sc.id 
72 72
 				LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group",
73
-            "sc.id='{$this->document}' AND (" . (empty($docgrp) ? '' : "dg.document_group = " . $docgrp . " ||") . " sc.privatemgr = 0)"
73
+            "sc.id='{$this->document}' AND (".(empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)"
74 74
         );
75 75
         $limit = $modx->db->getValue($rs);
76 76
         if ($limit == 1) {
Please login to merge, or discard this patch.
manager/processors/duplicate_module.processor.php 3 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
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
 if(!$modx->hasPermission('new_module')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /**
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
  * @return string
18 18
  */
19 19
 function createGUID(){
20
-	srand((double)microtime()*1000000);
21
-	$r = rand() ;
22
-	$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
23
-	$m = md5 ($u);
24
-	return $m;
20
+    srand((double)microtime()*1000000);
21
+    $r = rand() ;
22
+    $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
23
+    $m = md5 ($u);
24
+    return $m;
25 25
 }
26 26
 
27 27
 // count duplicates
@@ -32,40 +32,40 @@  discard block
 block discarded – undo
32 32
 
33 33
 // duplicate module
34 34
 $newid = $modx->db->insert(
35
-	array(
36
-		'name'=>'',
37
-		'description'=>'',
38
-		'disabled'=>'',
39
-		'category'=>'',
40
-		'wrap'=>'',
41
-		'icon'=>'',
42
-		'enable_resource'=>'',
43
-		'resourcefile'=>'',
44
-		'createdon'=>'',
45
-		'editedon'=>'',
46
-		'guid'=>'',
47
-		'enable_sharedparams'=>'',
48
-		'properties'=>'',
49
-		'modulecode'=>'',
50
-		), $modx->getFullTableName('site_modules'), // Insert into
51
-	"CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from
35
+    array(
36
+        'name'=>'',
37
+        'description'=>'',
38
+        'disabled'=>'',
39
+        'category'=>'',
40
+        'wrap'=>'',
41
+        'icon'=>'',
42
+        'enable_resource'=>'',
43
+        'resourcefile'=>'',
44
+        'createdon'=>'',
45
+        'editedon'=>'',
46
+        'guid'=>'',
47
+        'enable_sharedparams'=>'',
48
+        'properties'=>'',
49
+        'modulecode'=>'',
50
+        ), $modx->getFullTableName('site_modules'), // Insert into
51
+    "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from
52 52
 
53 53
 // duplicate module dependencies
54 54
 $modx->db->insert(
55
-	array(
56
-		'module'=>'',
57
-		'resource'=>'',
58
-		'type'=>'',
59
-		), $modx->getFullTableName('site_module_depobj'), // Insert into
60
-	"'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from
55
+    array(
56
+        'module'=>'',
57
+        'resource'=>'',
58
+        'type'=>'',
59
+        ), $modx->getFullTableName('site_module_depobj'), // Insert into
60
+    "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from
61 61
 
62 62
 // duplicate module user group access
63 63
 $modx->db->insert(
64
-	array(
65
-		'module'=>'',
66
-		'usergroup'=>'',
67
-		), $modx->getFullTableName('site_module_access'), // Insert into
68
-	"'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from
64
+    array(
65
+        'module'=>'',
66
+        'usergroup'=>'',
67
+        ), $modx->getFullTableName('site_module_access'), // Insert into
68
+    "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from
69 69
 
70 70
 // Set the item name for logger
71 71
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'"));
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  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
-if(!$modx->hasPermission('new_module')) {
5
+if (!$modx->hasPermission('new_module')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
  * @return string
18 18
  */
19 19
 function createGUID(){
20
-	srand((double)microtime()*1000000);
21
-	$r = rand() ;
22
-	$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
23
-	$m = md5 ($u);
20
+	srand((double) microtime() * 1000000);
21
+	$r = rand();
22
+	$u = uniqid(getmypid().$r.(double) microtime() * 1000000, 1);
23
+	$m = md5($u);
24 24
 	return $m;
25 25
 }
26 26
 
27 27
 // count duplicates
28 28
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'"));
29 29
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
30
-if($count>=1) $count = ' '.($count+1);
30
+if ($count >= 1) $count = ' '.($count + 1);
31 31
 else $count = '';
32 32
 
33 33
 // duplicate module
@@ -72,5 +72,5 @@  discard block
 block discarded – undo
72 72
 $_SESSION['itemname'] = $name;
73 73
 
74 74
 // finish duplicating - redirect to new module
75
-$header="Location: index.php?r=2&a=108&id=$newid";
75
+$header = "Location: index.php?r=2&a=108&id=$newid";
76 76
 header($header);
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @return string
18 18
  */
19
-function createGUID(){
19
+function createGUID()
20
+{
20 21
 	srand((double)microtime()*1000000);
21 22
 	$r = rand() ;
22 23
 	$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
@@ -27,8 +28,11 @@  discard block
 block discarded – undo
27 28
 // count duplicates
28 29
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'"));
29 30
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
30
-if($count>=1) $count = ' '.($count+1);
31
-else $count = '';
31
+if($count>=1) {
32
+    $count = ' '.($count+1);
33
+} else {
34
+    $count = '';
35
+}
32 36
 
33 37
 // duplicate module
34 38
 $newid = $modx->db->insert(
Please login to merge, or discard this patch.