Completed
Pull Request — develop (#740)
by Maxim
08:32
created
manager/actions/eventlog.dynamic.php 3 patches
Braces   +7 added lines, -7 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('view_eventlog')) {
5
+if(!$modx->hasPermission('view_eventlog')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 $modx->getManagerApi()->initPageViewState();
16 16
 
17 17
 // get and save search string
18
-if($_REQUEST['op'] == 'reset') {
18
+if($_REQUEST['op'] == 'reset') {
19 19
 	$sqlQuery = $query = '';
20 20
 	$_PAGE['vs']['search'] = '';
21
-} else {
21
+} else {
22 22
 	$sqlQuery = $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search'];
23
-	if(!is_numeric($sqlQuery)) {
23
+	if(!is_numeric($sqlQuery)) {
24 24
 		$sqlQuery = $modx->getDatabase()->escape($query);
25 25
 	}
26 26
 	$_PAGE['vs']['search'] = $query;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 					$grd->colWidths = "1%,,1%,1%,1%";
144 144
 					$grd->colAligns = "center,,,center,center";
145 145
 					$grd->colTypes = "template:<a class='gridRowIcon' href='javascript:;' onclick='return showContentMenu([+id+],event);' title='" . $_lang['click_to_context'] . "'><i class='[+icon+]'></i></a>||template:<a href='index.php?a=115&id=[+id+]' title='" . $_lang['click_to_view_details'] . "'>[+source+]</a>||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p';
146
-					if($listmode == '1') {
146
+					if($listmode == '1') {
147 147
 						$grd->pageSize = 0;
148 148
 					}
149
-					if($_REQUEST['op'] == 'reset') {
149
+					if($_REQUEST['op'] == 'reset') {
150 150
 						$grd->pageNumber = 1;
151 151
 					}
152 152
 					// render grid
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 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('view_eventlog')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 // Get table Names (alphabetical)
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 
17 17
 // get and save search string
18 18
 if($_REQUEST['op'] == 'reset') {
19
-	$sqlQuery = $query = '';
20
-	$_PAGE['vs']['search'] = '';
19
+    $sqlQuery = $query = '';
20
+    $_PAGE['vs']['search'] = '';
21 21
 } else {
22
-	$sqlQuery = $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search'];
23
-	if(!is_numeric($sqlQuery)) {
24
-		$sqlQuery = $modx->getDatabase()->escape($query);
25
-	}
26
-	$_PAGE['vs']['search'] = $query;
22
+    $sqlQuery = $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search'];
23
+    if(!is_numeric($sqlQuery)) {
24
+        $sqlQuery = $modx->getDatabase()->escape($query);
25
+    }
26
+    $_PAGE['vs']['search'] = $query;
27 27
 }
28 28
 
29 29
 // get & save listmode
@@ -124,32 +124,32 @@  discard block
 block discarded – undo
124 124
 			<div class="row">
125 125
 				<div class="table-responsive">
126 126
 					<?php
127
-					$ds = $modx->getDatabase()->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el 
127
+                    $ds = $modx->getDatabase()->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el 
128 128
 			LEFT JOIN {$tbl_manager_users} AS mu ON mu.id=el.user AND el.usertype=0
129 129
 			LEFT JOIN {$tbl_web_users} AS wu ON wu.id=el.user AND el.usertype=1", ($sqlQuery ? "" . (is_numeric($sqlQuery) ? "(eventid='{$sqlQuery}') OR " : '') . "(source LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "createdon DESC");
130
-					$grd = new \EvolutionCMS\Support\DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items
131
-					$grd->pagerClass = '';
132
-					$grd->pageClass = 'page-item';
133
-					$grd->selPageClass = 'page-item active';
134
-					$grd->noRecordMsg = $_lang['no_records_found'];
135
-					$grd->cssClass = "table data nowrap";
136
-					$grd->columnHeaderClass = "tableHeader";
137
-					$grd->itemClass = "tableItem";
138
-					$grd->altItemClass = "tableAltItem";
139
-					$grd->fields = "type,source,createdon,eventid,username";
140
-					$grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid'];
141
-					$grd->colWidths = "1%,,1%,1%,1%";
142
-					$grd->colAligns = "center,,,center,center";
143
-					$grd->colTypes = "template:<a class='gridRowIcon' href='javascript:;' onclick='return showContentMenu([+id+],event);' title='" . $_lang['click_to_context'] . "'><i class='[+icon+]'></i></a>||template:<a href='index.php?a=115&id=[+id+]' title='" . $_lang['click_to_view_details'] . "'>[+source+]</a>||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p';
144
-					if($listmode == '1') {
145
-						$grd->pageSize = 0;
146
-					}
147
-					if($_REQUEST['op'] == 'reset') {
148
-						$grd->pageNumber = 1;
149
-					}
150
-					// render grid
151
-					echo $grd->render();
152
-					?>
130
+                    $grd = new \EvolutionCMS\Support\DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items
131
+                    $grd->pagerClass = '';
132
+                    $grd->pageClass = 'page-item';
133
+                    $grd->selPageClass = 'page-item active';
134
+                    $grd->noRecordMsg = $_lang['no_records_found'];
135
+                    $grd->cssClass = "table data nowrap";
136
+                    $grd->columnHeaderClass = "tableHeader";
137
+                    $grd->itemClass = "tableItem";
138
+                    $grd->altItemClass = "tableAltItem";
139
+                    $grd->fields = "type,source,createdon,eventid,username";
140
+                    $grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid'];
141
+                    $grd->colWidths = "1%,,1%,1%,1%";
142
+                    $grd->colAligns = "center,,,center,center";
143
+                    $grd->colTypes = "template:<a class='gridRowIcon' href='javascript:;' onclick='return showContentMenu([+id+],event);' title='" . $_lang['click_to_context'] . "'><i class='[+icon+]'></i></a>||template:<a href='index.php?a=115&id=[+id+]' title='" . $_lang['click_to_view_details'] . "'>[+source+]</a>||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p';
144
+                    if($listmode == '1') {
145
+                        $grd->pageSize = 0;
146
+                    }
147
+                    if($_REQUEST['op'] == 'reset') {
148
+                        $grd->pageNumber = 1;
149
+                    }
150
+                    // render grid
151
+                    echo $grd->render();
152
+                    ?>
153 153
 				</div>
154 154
 			</div>
155 155
 		</div>
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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('view_eventlog')) {
5
+if (!$modx->hasPermission('view_eventlog')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 $modx->getManagerApi()->initPageViewState();
16 16
 
17 17
 // get and save search string
18
-if($_REQUEST['op'] == 'reset') {
18
+if ($_REQUEST['op'] == 'reset') {
19 19
 	$sqlQuery = $query = '';
20 20
 	$_PAGE['vs']['search'] = '';
21 21
 } else {
22 22
 	$sqlQuery = $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search'];
23
-	if(!is_numeric($sqlQuery)) {
23
+	if (!is_numeric($sqlQuery)) {
24 24
 		$sqlQuery = $modx->getDatabase()->escape($query);
25 25
 	}
26 26
 	$_PAGE['vs']['search'] = $query;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 					<?php
127 127
 					$ds = $modx->getDatabase()->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el 
128 128
 			LEFT JOIN {$tbl_manager_users} AS mu ON mu.id=el.user AND el.usertype=0
129
-			LEFT JOIN {$tbl_web_users} AS wu ON wu.id=el.user AND el.usertype=1", ($sqlQuery ? "" . (is_numeric($sqlQuery) ? "(eventid='{$sqlQuery}') OR " : '') . "(source LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "createdon DESC");
129
+			LEFT JOIN {$tbl_web_users} AS wu ON wu.id=el.user AND el.usertype=1", ($sqlQuery ? "".(is_numeric($sqlQuery) ? "(eventid='{$sqlQuery}') OR " : '')."(source LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "createdon DESC");
130 130
 					$grd = new \EvolutionCMS\Support\DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items
131 131
 					$grd->pagerClass = '';
132 132
 					$grd->pageClass = 'page-item';
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 					$grd->itemClass = "tableItem";
138 138
 					$grd->altItemClass = "tableAltItem";
139 139
 					$grd->fields = "type,source,createdon,eventid,username";
140
-					$grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid'];
140
+					$grd->columns = $_lang['type']." ,".$_lang['source']." ,".$_lang['date']." ,".$_lang['event_id']." ,".$_lang['sysinfo_userid'];
141 141
 					$grd->colWidths = "1%,,1%,1%,1%";
142 142
 					$grd->colAligns = "center,,,center,center";
143
-					$grd->colTypes = "template:<a class='gridRowIcon' href='javascript:;' onclick='return showContentMenu([+id+],event);' title='" . $_lang['click_to_context'] . "'><i class='[+icon+]'></i></a>||template:<a href='index.php?a=115&id=[+id+]' title='" . $_lang['click_to_view_details'] . "'>[+source+]</a>||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p';
144
-					if($listmode == '1') {
143
+					$grd->colTypes = "template:<a class='gridRowIcon' href='javascript:;' onclick='return showContentMenu([+id+],event);' title='".$_lang['click_to_context']."'><i class='[+icon+]'></i></a>||template:<a href='index.php?a=115&id=[+id+]' title='".$_lang['click_to_view_details']."'>[+source+]</a>||date: ".$modx->toDateFormat(null, 'formatOnly').' %I:%M %p';
144
+					if ($listmode == '1') {
145 145
 						$grd->pageSize = 0;
146 146
 					}
147
-					if($_REQUEST['op'] == 'reset') {
147
+					if ($_REQUEST['op'] == 'reset') {
148 148
 						$grd->pageNumber = 1;
149 149
 					}
150 150
 					// render grid
Please login to merge, or discard this patch.
manager/actions/mutate_htmlsnippet.dynamic.php 2 patches
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@
 block discarded – undo
4 4
 }
5 5
 
6 6
 switch ($modx->getManagerApi()->action) {
7
-    case 78:
8
-        if (!$modx->hasPermission('edit_chunk')) {
9
-            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
-        }
11
-        break;
12
-    case 77:
13
-        if (!$modx->hasPermission('new_chunk')) {
7
+        case 78:
8
+            if (!$modx->hasPermission('edit_chunk')) {
9
+                $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
+            }
11
+            break;
12
+        case 77:
13
+            if (!$modx->hasPermission('new_chunk')) {
14
+                $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+            }
16
+            break;
17
+        default:
14 18
             $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
-        }
16
-        break;
17
-    default:
18
-        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21 21
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
21
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
22 22
 
23 23
 // Get table names (alphabetical)
24 24
 $tbl_site_htmlsnippets = $modx->getDatabase()->getFullTableName('site_htmlsnippets');
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $content['name'] = $_REQUEST['itemname'];
48 48
 } else {
49 49
     $_SESSION['itemname'] = $_lang["new_htmlsnippet"];
50
-    $content['category'] = (int)$_REQUEST['catid'];
50
+    $content['category'] = (int) $_REQUEST['catid'];
51 51
 }
52 52
 
53 53
 if ($modx->getManagerApi()->hasFormValues()) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 // Add lock-element JS-Script
66 66
 $lockElementId = $id;
67 67
 $lockElementType = 3;
68
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
68
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
69 69
 
70 70
 // Print RTE Javascript function
71 71
 ?>
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         <input type="hidden" name="mode" value="<?= $modx->getManagerApi()->action ?>" />
137 137
 
138 138
         <h1>
139
-            <i class="fa fa-th-large"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_htmlsnippet']) ?><i class="fa fa-question-circle help"></i>
139
+            <i class="fa fa-th-large"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_htmlsnippet']) ?><i class="fa fa-question-circle help"></i>
140 140
         </h1>
141 141
 
142 142
         <?= $_style['actionbuttons']['dynamic']['element'] ?>
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                             <div class="form-control-name clearfix">
161 161
                                 <input name="name" type="text" maxlength="100" value="<?= $modx->getPhpCompat()->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" />
162 162
                                 <?php if ($modx->hasPermission('save_role')): ?>
163
-                                    <label class="custom-control" title="<?= $_lang['lock_htmlsnippet'] . "\n" . $_lang['lock_htmlsnippet_msg'] ?>" tooltip>
163
+                                    <label class="custom-control" title="<?= $_lang['lock_htmlsnippet']."\n".$_lang['lock_htmlsnippet_msg'] ?>" tooltip>
164 164
                                         <input name="locked" type="checkbox" value="on"<?= ($content['locked'] == 1 || $content['locked'] == 'on' ? ' checked="checked"' : '') ?> />
165 165
                                         <i class="fa fa-lock"></i>
166 166
                                     </label>
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
                             <select name="categoryid" class="form-control" onchange="documentDirty=true;">
185 185
                                 <option>&nbsp;</option>
186 186
                                 <?php
187
-                                include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
187
+                                include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
188 188
                                 foreach (getCategories() as $n => $v) {
189
-                                    echo "\t\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] || (empty($content['category']) && $_POST['categoryid'] == $v['id']) ? ' selected="selected"' : '') . '>' . $modx->getPhpCompat()->htmlspecialchars($v['category']) . "</option>\n";
189
+                                    echo "\t\t\t\t".'<option value="'.$v['id'].'"'.($content['category'] == $v['id'] || (empty($content['category']) && $_POST['categoryid'] == $v['id']) ? ' selected="selected"' : '').'>'.$modx->getPhpCompat()->htmlspecialchars($v['category'])."</option>\n";
190 190
                                 }
191 191
                                 ?>
192 192
                             </select>
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                     </div>
201 201
                     <?php if ($_SESSION['mgrRole'] == 1): ?>
202 202
                         <div class="form-row">
203
-                            <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>" . $_lang['disabled'] . "</span>" : $_lang['disabled']) ?></label>
203
+                            <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>".$_lang['disabled']."</span>" : $_lang['disabled']) ?></label>
204 204
                         </div>
205 205
                     <?php endif; ?>
206 206
                 </div>
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                             $evtOut = $modx->invokeEvent('OnRichTextEditorRegister');
217 217
                             if (is_array($evtOut)) {
218 218
                                 foreach ($evtOut as $i => $editor) {
219
-                                    echo "\t" . '<option value="' . $editor . '"' . ($which_editor == $editor ? ' selected="selected"' : '') . '>' . $editor . "</option>\n";
219
+                                    echo "\t".'<option value="'.$editor.'"'.($which_editor == $editor ? ' selected="selected"' : '').'>'.$editor."</option>\n";
220 220
                                 }
221 221
                             }
222 222
                             ?>
Please login to merge, or discard this patch.
manager/processors/save_plugin.processor.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  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
 if (!$modx->hasPermission('save_plugin')) {
6 6
     $modx->webAlertAndQuit($_lang['error_no_privileges']);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $name = $modx->getDatabase()->escape(trim($_POST['name']));
11 11
 $description = $modx->getDatabase()->escape($_POST['description']);
12 12
 $locked = $_POST['locked'] == 'on' ? '1' : '0';
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 
21 21
 //Kyle Jaebker - added category support
22 22
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
23
-    $categoryid = (int)$_POST['categoryid'];
23
+    $categoryid = (int) $_POST['categoryid'];
24 24
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
25 25
     $categoryid = 0;
26 26
 } else {
27
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
27
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
28 28
     $categoryid = getCategory($_POST['newcategory']);
29 29
 }
30 30
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
     $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid;
41 41
 
42 42
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
43
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
43
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
44 44
     if ($version) {
45
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
45
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
46 46
     }
47 47
     if (isset($parsed['modx_category'])) {
48
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
48
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
49 49
         $categoryid = getCategory($parsed['modx_category']);
50 50
     }
51 51
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         // finished emptying cache - redirect
104 104
         if ($_POST['stay'] != '') {
105 105
             $a = ($_POST['stay'] == '2') ? "102&id=$newid" : '101';
106
-            $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay'];
106
+            $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay'];
107 107
             header($header);
108 108
         } else {
109 109
             $header = 'Location: index.php?a=76&r=2';
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // finished emptying cache - redirect
159 159
         if ($_POST['stay'] != '') {
160 160
             $a = ($_POST['stay'] == '2') ? "102&id=$id" : '101';
161
-            $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay'];
161
+            $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay'];
162 162
             header($header);
163 163
         } else {
164 164
             $modx->unlockElement(5, $id);
Please login to merge, or discard this patch.
manager/processors/send_message.processor.php 3 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,9 +10,13 @@
 block discarded – undo
10 10
 $userid = $_REQUEST['user'];
11 11
 $groupid = $_REQUEST['group'];
12 12
 $subject = $modx->getDatabase()->escape($_REQUEST['messagesubject']);
13
-if($subject=="") $subject="(no subject)";
13
+if($subject=="") {
14
+    $subject="(no subject)";
15
+}
14 16
 $message = $modx->getDatabase()->escape($_REQUEST['messagebody']);
15
-if($message=="") $message="(no message)";
17
+if($message=="") {
18
+    $message="(no message)";
19
+}
16 20
 $postdate = time();
17 21
 
18 22
 if($sendto=='u') {
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  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('messages')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $sendto = $_REQUEST['sendto'];
@@ -16,55 +16,55 @@  discard block
 block discarded – undo
16 16
 $postdate = time();
17 17
 
18 18
 if($sendto=='u') {
19
-	if($userid==0) {
20
-		$modx->webAlertAndQuit($_lang["error_no_user_selected"]);
21
-	}
22
-	$modx->getDatabase()->insert(
23
-		array(
24
-			'recipient' => $userid,
25
-			'sender'    => $modx->getLoginUserID(),
26
-			'subject'   => $subject,
27
-			'message'   => $message,
28
-			'postdate'  => $postdate,
29
-			'type'      => 'Message',
30
-			'private'   => 1,
31
-		), $modx->getDatabase()->getFullTableName('user_messages'));
19
+    if($userid==0) {
20
+        $modx->webAlertAndQuit($_lang["error_no_user_selected"]);
21
+    }
22
+    $modx->getDatabase()->insert(
23
+        array(
24
+            'recipient' => $userid,
25
+            'sender'    => $modx->getLoginUserID(),
26
+            'subject'   => $subject,
27
+            'message'   => $message,
28
+            'postdate'  => $postdate,
29
+            'type'      => 'Message',
30
+            'private'   => 1,
31
+        ), $modx->getDatabase()->getFullTableName('user_messages'));
32 32
 }
33 33
 
34 34
 if($sendto=='g') {
35
-	if($groupid==0) {
36
-		$modx->webAlertAndQuit($_lang["error_no_group_selected"]);
37
-	}
38
-	$rs = $modx->getDatabase()->select('internalKey', $modx->getDatabase()->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'");
39
-	while ($row=$modx->getDatabase()->getRow($rs)) {
40
-		$modx->getDatabase()->insert(
41
-			array(
42
-				'recipient' => $row['internalKey'],
43
-				'sender'    => $modx->getLoginUserID(),
44
-				'subject'   => $subject,
45
-				'message'   => $message,
46
-				'postdate'  => $postdate,
47
-				'type'      => 'Message',
48
-				'private'   => 0,
49
-			), $modx->getDatabase()->getFullTableName('user_messages'));
50
-	}
35
+    if($groupid==0) {
36
+        $modx->webAlertAndQuit($_lang["error_no_group_selected"]);
37
+    }
38
+    $rs = $modx->getDatabase()->select('internalKey', $modx->getDatabase()->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'");
39
+    while ($row=$modx->getDatabase()->getRow($rs)) {
40
+        $modx->getDatabase()->insert(
41
+            array(
42
+                'recipient' => $row['internalKey'],
43
+                'sender'    => $modx->getLoginUserID(),
44
+                'subject'   => $subject,
45
+                'message'   => $message,
46
+                'postdate'  => $postdate,
47
+                'type'      => 'Message',
48
+                'private'   => 0,
49
+            ), $modx->getDatabase()->getFullTableName('user_messages'));
50
+    }
51 51
 }
52 52
 
53 53
 
54 54
 if($sendto=='a') {
55
-	$rs = $modx->getDatabase()->select('id', $modx->getDatabase()->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'");
56
-	while ($row=$modx->getDatabase()->getRow($rs)) {
57
-		$modx->getDatabase()->insert(
58
-			array(
59
-				'recipient' => $row['id'],
60
-				'sender'    => $modx->getLoginUserID(),
61
-				'subject'   => $subject,
62
-				'message'   => $message,
63
-				'postdate'  => $postdate,
64
-				'type'      => 'Message',
65
-				'private'   => 0,
66
-			), $modx->getDatabase()->getFullTableName('user_messages'));
67
-	}
55
+    $rs = $modx->getDatabase()->select('id', $modx->getDatabase()->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'");
56
+    while ($row=$modx->getDatabase()->getRow($rs)) {
57
+        $modx->getDatabase()->insert(
58
+            array(
59
+                'recipient' => $row['id'],
60
+                'sender'    => $modx->getLoginUserID(),
61
+                'subject'   => $subject,
62
+                'message'   => $message,
63
+                'postdate'  => $postdate,
64
+                'type'      => 'Message',
65
+                'private'   => 0,
66
+            ), $modx->getDatabase()->getFullTableName('user_messages'));
67
+    }
68 68
 }
69 69
 
70 70
 $header = "Location: index.php?a=10";
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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('messages')) {
5
+if (!$modx->hasPermission('messages')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
 $userid = $_REQUEST['user'];
11 11
 $groupid = $_REQUEST['group'];
12 12
 $subject = $modx->getDatabase()->escape($_REQUEST['messagesubject']);
13
-if($subject=="") $subject="(no subject)";
13
+if ($subject == "") $subject = "(no subject)";
14 14
 $message = $modx->getDatabase()->escape($_REQUEST['messagebody']);
15
-if($message=="") $message="(no message)";
15
+if ($message == "") $message = "(no message)";
16 16
 $postdate = time();
17 17
 
18
-if($sendto=='u') {
19
-	if($userid==0) {
18
+if ($sendto == 'u') {
19
+	if ($userid == 0) {
20 20
 		$modx->webAlertAndQuit($_lang["error_no_user_selected"]);
21 21
 	}
22 22
 	$modx->getDatabase()->insert(
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 		), $modx->getDatabase()->getFullTableName('user_messages'));
32 32
 }
33 33
 
34
-if($sendto=='g') {
35
-	if($groupid==0) {
34
+if ($sendto == 'g') {
35
+	if ($groupid == 0) {
36 36
 		$modx->webAlertAndQuit($_lang["error_no_group_selected"]);
37 37
 	}
38 38
 	$rs = $modx->getDatabase()->select('internalKey', $modx->getDatabase()->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'");
39
-	while ($row=$modx->getDatabase()->getRow($rs)) {
39
+	while ($row = $modx->getDatabase()->getRow($rs)) {
40 40
 		$modx->getDatabase()->insert(
41 41
 			array(
42 42
 				'recipient' => $row['internalKey'],
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 }
52 52
 
53 53
 
54
-if($sendto=='a') {
54
+if ($sendto == 'a') {
55 55
 	$rs = $modx->getDatabase()->select('id', $modx->getDatabase()->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'");
56
-	while ($row=$modx->getDatabase()->getRow($rs)) {
56
+	while ($row = $modx->getDatabase()->getRow($rs)) {
57 57
 		$modx->getDatabase()->insert(
58 58
 			array(
59 59
 				'recipient' => $row['id'],
Please login to merge, or discard this patch.
manager/processors/save_template.processor.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  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
 if (!$modx->hasPermission('save_template')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $template = $modx->getDatabase()->escape($_POST['post']);
11 11
 $templatename = $modx->getDatabase()->escape(trim($_POST['templatename']));
12 12
 $description = $modx->getDatabase()->escape($_POST['description']);
13 13
 $locked = $_POST['locked'] == 'on' ? 1 : 0;
14
-$selectable = $id == $modx->config['default_template'] ? 1 :    // Force selectable
14
+$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable
15 15
     $_POST['selectable'] == 'on' ? 1 : 0;
16 16
 $currentdate = time() + $modx->config['server_offset_time'];
17 17
 
18 18
 //Kyle Jaebker - added category support
19 19
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
20
-    $categoryid = (int)$_POST['categoryid'];
20
+    $categoryid = (int) $_POST['categoryid'];
21 21
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
22 22
     $categoryid = 0;
23 23
 } else {
24
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
24
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
25 25
     $categoryid = checkCategory($_POST['newcategory']);
26 26
     if (!$categoryid) {
27 27
         $categoryid = newCategory($_POST['newcategory']);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         // finished emptying cache - redirect
79 79
         if ($_POST['stay'] != '') {
80 80
             $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
81
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
82 82
             header($header);
83 83
         } else {
84 84
             $header = "Location: index.php?a=76&r=2";
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         // finished emptying cache - redirect
131 131
         if ($_POST['stay'] != '') {
132 132
             $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
133
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
134 134
             header($header);
135 135
         } else {
136 136
             $modx->unlockElement(1, $id);
Please login to merge, or discard this patch.
Switch Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -33,113 +33,113 @@
 block discarded – undo
33 33
 }
34 34
 
35 35
 switch ($_POST['mode']) {
36
-    case '19':
37
-
38
-        // invoke OnBeforeTempFormSave event
39
-        $modx->invokeEvent("OnBeforeTempFormSave", array(
40
-            "mode" => "new",
41
-            "id" => $id
42
-        ));
43
-
44
-        // disallow duplicate names for new templates
45
-        $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}'");
46
-        $count = $modx->getDatabase()->getValue($rs);
47
-        if ($count > 0) {
48
-            $modx->getManagerApi()->saveFormValues(19);
49
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19");
50
-        }
51
-
52
-        //do stuff to save the new doc
53
-        $newid = $modx->getDatabase()->insert(array(
54
-            'templatename' => $templatename,
55
-            'description' => $description,
56
-            'content' => $template,
57
-            'locked' => $locked,
58
-            'selectable' => $selectable,
59
-            'category' => $categoryid,
60
-            'createdon' => $currentdate,
61
-            'editedon' => $currentdate
62
-        ), $modx->getDatabase()->getFullTableName('site_templates'));
63
-
64
-        // invoke OnTempFormSave event
65
-        $modx->invokeEvent("OnTempFormSave", array(
66
-            "mode" => "new",
67
-            "id" => $newid
68
-        ));
69
-        // Set new assigned Tvs
70
-        saveTemplateAccess($newid);
71
-
72
-        // Set the item name for logger
73
-        $_SESSION['itemname'] = $templatename;
74
-
75
-        // empty cache
76
-        $modx->clearCache('full');
77
-
78
-        // finished emptying cache - redirect
79
-        if ($_POST['stay'] != '') {
80
-            $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
82
-            header($header);
83
-        } else {
84
-            $header = "Location: index.php?a=76&r=2";
85
-            header($header);
86
-        }
87
-
88
-        break;
89
-    case '16':
90
-
91
-        // invoke OnBeforeTempFormSave event
92
-        $modx->invokeEvent("OnBeforeTempFormSave", array(
93
-            "mode" => "upd",
94
-            "id" => $id
95
-        ));
96
-
97
-        // disallow duplicate names for templates
98
-        $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'");
99
-        $count = $modx->getDatabase()->getValue($rs);
100
-        if ($count > 0) {
101
-            $modx->getManagerApi()->saveFormValues(16);
102
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}");
103
-        }
104
-
105
-        //do stuff to save the edited doc
106
-        $modx->getDatabase()->update(array(
107
-            'templatename' => $templatename,
108
-            'description' => $description,
109
-            'content' => $template,
110
-            'locked' => $locked,
111
-            'selectable' => $selectable,
112
-            'category' => $categoryid,
113
-            'editedon' => $currentdate
114
-        ), $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'");
115
-        // Set new assigned Tvs
116
-        saveTemplateAccess($id);
117
-
118
-        // invoke OnTempFormSave event
119
-        $modx->invokeEvent("OnTempFormSave", array(
120
-            "mode" => "upd",
121
-            "id" => $id
122
-        ));
123
-
124
-        // Set the item name for logger
125
-        $_SESSION['itemname'] = $templatename;
126
-
127
-        // first empty the cache
128
-        $modx->clearCache('full');
129
-
130
-        // finished emptying cache - redirect
131
-        if ($_POST['stay'] != '') {
132
-            $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
134
-            header($header);
135
-        } else {
136
-            $modx->unlockElement(1, $id);
137
-            $header = "Location: index.php?a=76&r=2";
138
-            header($header);
139
-        }
140
-
141
-
142
-        break;
143
-    default:
144
-        $modx->webAlertAndQuit("No operation set in request.");
36
+        case '19':
37
+
38
+            // invoke OnBeforeTempFormSave event
39
+            $modx->invokeEvent("OnBeforeTempFormSave", array(
40
+                "mode" => "new",
41
+                "id" => $id
42
+            ));
43
+
44
+            // disallow duplicate names for new templates
45
+            $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}'");
46
+            $count = $modx->getDatabase()->getValue($rs);
47
+            if ($count > 0) {
48
+                $modx->getManagerApi()->saveFormValues(19);
49
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19");
50
+            }
51
+
52
+            //do stuff to save the new doc
53
+            $newid = $modx->getDatabase()->insert(array(
54
+                'templatename' => $templatename,
55
+                'description' => $description,
56
+                'content' => $template,
57
+                'locked' => $locked,
58
+                'selectable' => $selectable,
59
+                'category' => $categoryid,
60
+                'createdon' => $currentdate,
61
+                'editedon' => $currentdate
62
+            ), $modx->getDatabase()->getFullTableName('site_templates'));
63
+
64
+            // invoke OnTempFormSave event
65
+            $modx->invokeEvent("OnTempFormSave", array(
66
+                "mode" => "new",
67
+                "id" => $newid
68
+            ));
69
+            // Set new assigned Tvs
70
+            saveTemplateAccess($newid);
71
+
72
+            // Set the item name for logger
73
+            $_SESSION['itemname'] = $templatename;
74
+
75
+            // empty cache
76
+            $modx->clearCache('full');
77
+
78
+            // finished emptying cache - redirect
79
+            if ($_POST['stay'] != '') {
80
+                $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
82
+                header($header);
83
+            } else {
84
+                $header = "Location: index.php?a=76&r=2";
85
+                header($header);
86
+            }
87
+
88
+            break;
89
+        case '16':
90
+
91
+            // invoke OnBeforeTempFormSave event
92
+            $modx->invokeEvent("OnBeforeTempFormSave", array(
93
+                "mode" => "upd",
94
+                "id" => $id
95
+            ));
96
+
97
+            // disallow duplicate names for templates
98
+            $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'");
99
+            $count = $modx->getDatabase()->getValue($rs);
100
+            if ($count > 0) {
101
+                $modx->getManagerApi()->saveFormValues(16);
102
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}");
103
+            }
104
+
105
+            //do stuff to save the edited doc
106
+            $modx->getDatabase()->update(array(
107
+                'templatename' => $templatename,
108
+                'description' => $description,
109
+                'content' => $template,
110
+                'locked' => $locked,
111
+                'selectable' => $selectable,
112
+                'category' => $categoryid,
113
+                'editedon' => $currentdate
114
+            ), $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'");
115
+            // Set new assigned Tvs
116
+            saveTemplateAccess($id);
117
+
118
+            // invoke OnTempFormSave event
119
+            $modx->invokeEvent("OnTempFormSave", array(
120
+                "mode" => "upd",
121
+                "id" => $id
122
+            ));
123
+
124
+            // Set the item name for logger
125
+            $_SESSION['itemname'] = $templatename;
126
+
127
+            // first empty the cache
128
+            $modx->clearCache('full');
129
+
130
+            // finished emptying cache - redirect
131
+            if ($_POST['stay'] != '') {
132
+                $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
134
+                header($header);
135
+            } else {
136
+                $modx->unlockElement(1, $id);
137
+                $header = "Location: index.php?a=76&r=2";
138
+                header($header);
139
+            }
140
+
141
+
142
+            break;
143
+        default:
144
+            $modx->webAlertAndQuit("No operation set in request.");
145 145
 }
Please login to merge, or discard this patch.
manager/processors/save_user.processor.php 3 patches
Switch Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -67,110 +67,110 @@  discard block
 block discarded – undo
67 67
 }
68 68
 
69 69
 switch($input['mode']) {
70
-	case '11' : // new user
71
-		// check if this user name already exist
72
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername)));
73
-		$limit = $modx->getDatabase()->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("User name is already in use!", 12);
76
-		}
77
-
78
-		// check if the email address already exist
79
-		$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id));
80
-		$limit = $modx->getDatabase()->getValue($rs);
81
-		if($limit > 0) {
82
-			webAlertAndQuit("Email is already in use!", 12);
83
-		}
84
-
85
-		// generate a new password for this user
86
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
87
-			if(strlen($specifiedpassword) < 6) {
88
-				webAlertAndQuit("Password is too short!", 12);
89
-			} else {
90
-				$newpassword = $specifiedpassword;
91
-			}
92
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
93
-			webAlertAndQuit("You didn't specify a password for this user!", 12);
94
-		} elseif($passwordgenmethod == 'g') {
95
-			$newpassword = generate_password(8);
96
-		} else {
97
-			webAlertAndQuit("No password generation method specified!", 12);
98
-		}
99
-
100
-		// invoke OnBeforeUserFormSave event
101
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
102
-			"mode" => "new",
103
-		));
104
-
105
-		// create the user account
106
-		$internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users);
107
-
108
-		$field = array();
109
-		$field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
110
-		$modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'");
111
-
112
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
113
-		$field = $modx->getDatabase()->escape($field);
114
-		$modx->getDatabase()->insert($field, $tbl_user_attributes);
115
-
116
-		// Save user settings
117
-        saveManagerUserSettings($internalKey);
118
-
119
-		// invoke OnManagerSaveUser event
120
-		$modx->invokeEvent("OnManagerSaveUser", array(
121
-			"mode" => "new",
122
-			"userid" => $internalKey,
123
-			"username" => $newusername,
124
-			"userpassword" => $newpassword,
125
-			"useremail" => $email,
126
-			"userfullname" => $fullname,
127
-			"userroleid" => $role
128
-		));
129
-
130
-		// invoke OnUserFormSave event
131
-		$modx->invokeEvent("OnUserFormSave", array(
132
-			"mode" => "new",
133
-			"id" => $internalKey
134
-		));
135
-
136
-		// Set the item name for logger
137
-		$_SESSION['itemname'] = $newusername;
138
-
139
-		/*******************************************************************************/
140
-		// put the user in the user_groups he/ she should be in
141
-		// first, check that up_perms are switched on!
142
-		if($use_udperms == 1) {
143
-			if(!empty($user_groups)) {
144
-				for($i = 0; $i < count($user_groups); $i++) {
145
-					$f = array();
146
-					$f['user_group'] = (int)$user_groups[$i];
147
-					$f['member'] = $internalKey;
148
-					$modx->getDatabase()->insert($f, $tbl_member_groups);
149
-				}
150
-			}
151
-		}
152
-		// end of user_groups stuff!
153
-
154
-		if($passwordnotifymethod == 'e') {
155
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
158
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-				header($header);
160
-			} else {
161
-				$header = "Location: index.php?a=75&r=2";
162
-				header($header);
163
-			}
164
-		} else {
165
-			if($input['stay'] != '') {
166
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
167
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
168
-			} else {
169
-				$stayUrl = "index.php?a=75&r=2";
170
-			}
171
-
172
-			include_once "header.inc.php";
173
-			?>
70
+	    case '11' : // new user
71
+		    // check if this user name already exist
72
+		    $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername)));
73
+		    $limit = $modx->getDatabase()->getValue($rs);
74
+		    if($limit > 0) {
75
+			    webAlertAndQuit("User name is already in use!", 12);
76
+		    }
77
+
78
+		    // check if the email address already exist
79
+		    $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id));
80
+		    $limit = $modx->getDatabase()->getValue($rs);
81
+		    if($limit > 0) {
82
+			    webAlertAndQuit("Email is already in use!", 12);
83
+		    }
84
+
85
+		    // generate a new password for this user
86
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
87
+			    if(strlen($specifiedpassword) < 6) {
88
+				    webAlertAndQuit("Password is too short!", 12);
89
+			    } else {
90
+				    $newpassword = $specifiedpassword;
91
+			    }
92
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
93
+			    webAlertAndQuit("You didn't specify a password for this user!", 12);
94
+		    } elseif($passwordgenmethod == 'g') {
95
+			    $newpassword = generate_password(8);
96
+		    } else {
97
+			    webAlertAndQuit("No password generation method specified!", 12);
98
+		    }
99
+
100
+		    // invoke OnBeforeUserFormSave event
101
+		    $modx->invokeEvent("OnBeforeUserFormSave", array(
102
+			    "mode" => "new",
103
+		    ));
104
+
105
+		    // create the user account
106
+		    $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users);
107
+
108
+		    $field = array();
109
+		    $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
110
+		    $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'");
111
+
112
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
113
+		    $field = $modx->getDatabase()->escape($field);
114
+		    $modx->getDatabase()->insert($field, $tbl_user_attributes);
115
+
116
+		    // Save user settings
117
+            saveManagerUserSettings($internalKey);
118
+
119
+		    // invoke OnManagerSaveUser event
120
+		    $modx->invokeEvent("OnManagerSaveUser", array(
121
+			    "mode" => "new",
122
+			    "userid" => $internalKey,
123
+			    "username" => $newusername,
124
+			    "userpassword" => $newpassword,
125
+			    "useremail" => $email,
126
+			    "userfullname" => $fullname,
127
+			    "userroleid" => $role
128
+		    ));
129
+
130
+		    // invoke OnUserFormSave event
131
+		    $modx->invokeEvent("OnUserFormSave", array(
132
+			    "mode" => "new",
133
+			    "id" => $internalKey
134
+		    ));
135
+
136
+		    // Set the item name for logger
137
+		    $_SESSION['itemname'] = $newusername;
138
+
139
+		    /*******************************************************************************/
140
+		    // put the user in the user_groups he/ she should be in
141
+		    // first, check that up_perms are switched on!
142
+		    if($use_udperms == 1) {
143
+			    if(!empty($user_groups)) {
144
+				    for($i = 0; $i < count($user_groups); $i++) {
145
+					    $f = array();
146
+					    $f['user_group'] = (int)$user_groups[$i];
147
+					    $f['member'] = $internalKey;
148
+					    $modx->getDatabase()->insert($f, $tbl_member_groups);
149
+				    }
150
+			    }
151
+		    }
152
+		    // end of user_groups stuff!
153
+
154
+		    if($passwordnotifymethod == 'e') {
155
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
156
+			    if($input['stay'] != '') {
157
+				    $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
158
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+				    header($header);
160
+			    } else {
161
+				    $header = "Location: index.php?a=75&r=2";
162
+				    header($header);
163
+			    }
164
+		    } else {
165
+			    if($input['stay'] != '') {
166
+				    $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
167
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
168
+			    } else {
169
+				    $stayUrl = "index.php?a=75&r=2";
170
+			    }
171
+
172
+			    include_once "header.inc.php";
173
+			    ?>
174 174
 
175 175
 			<h1><?php echo $_lang['user_title']; ?></h1>
176 176
 
@@ -192,125 +192,125 @@  discard block
 block discarded – undo
192 192
 			</div>
193 193
 			<?php
194 194
 
195
-			include_once "footer.inc.php";
196
-		}
197
-		break;
198
-	case '12' : // edit user
199
-		// generate a new password for this user
200
-		if($genpassword == 1) {
201
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
202
-				if(strlen($specifiedpassword) < 6) {
203
-					webAlertAndQuit("Password is too short!", 12);
204
-				} else {
205
-					$newpassword = $specifiedpassword;
206
-				}
207
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
208
-				webAlertAndQuit("You didn't specify a password for this user!", 12);
209
-			} elseif($passwordgenmethod == 'g') {
210
-				$newpassword = generate_password(8);
211
-			} else {
212
-				webAlertAndQuit("No password generation method specified!", 12);
213
-			}
214
-		}
215
-		if($passwordnotifymethod == 'e') {
216
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
217
-		}
218
-
219
-		// check if the username already exist
220
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id));
221
-		$limit = $modx->getDatabase()->getValue($rs);
222
-		if($limit > 0) {
223
-			webAlertAndQuit("User name is already in use!", 12);
224
-		}
225
-
226
-		// check if the email address already exists
227
-		$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id));
228
-		$limit = $modx->getDatabase()->getValue($rs);
229
-		if($limit > 0) {
230
-			webAlertAndQuit("Email is already in use!", 12);
231
-		}
232
-
233
-		// invoke OnBeforeUserFormSave event
234
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
235
-			"mode" => "upd",
236
-			"id" => $id
237
-		));
238
-
239
-		// update user name and password
240
-		$field = array();
241
-		$field['username'] = $modx->getDatabase()->escape($newusername);
242
-		if($genpassword == 1) {
243
-			$field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
244
-		}
245
-		$modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'");
246
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
247
-		$field = $modx->getDatabase()->escape($field);
248
-		$modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'");
249
-
250
-		// Save user settings
251
-        saveManagerUserSettings($id);
252
-
253
-		// Set the item name for logger
254
-		$_SESSION['itemname'] = $newusername;
255
-
256
-		// invoke OnManagerSaveUser event
257
-		$modx->invokeEvent("OnManagerSaveUser", array(
258
-			"mode" => "upd",
259
-			"userid" => $id,
260
-			"username" => $newusername,
261
-			"userpassword" => $newpassword,
262
-			"useremail" => $email,
263
-			"userfullname" => $fullname,
264
-			"userroleid" => $role,
265
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
266
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
267
-		));
268
-
269
-		// invoke OnManagerChangePassword event
270
-		if($genpassword == 1) {
271
-			$modx->invokeEvent("OnManagerChangePassword", array(
272
-				"userid" => $id,
273
-				"username" => $newusername,
274
-				"userpassword" => $newpassword
275
-			));
276
-		}
277
-
278
-		// invoke OnUserFormSave event
279
-		$modx->invokeEvent("OnUserFormSave", array(
280
-			"mode" => "upd",
281
-			"id" => $id
282
-		));
283
-
284
-		/*******************************************************************************/
285
-		// put the user in the user_groups he/ she should be in
286
-		// first, check that up_perms are switched on!
287
-		if($use_udperms == 1) {
288
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
289
-			$modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'");
290
-			if(!empty($user_groups)) {
291
-				for($i = 0; $i < count($user_groups); $i++) {
292
-					$field = array();
293
-					$field['user_group'] = (int)$user_groups[$i];
294
-					$field['member'] = $id;
295
-					$modx->getDatabase()->insert($field, $tbl_member_groups);
296
-				}
297
-			}
298
-		}
299
-		// end of user_groups stuff!
300
-		/*******************************************************************************/
301
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
302
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
303
-		}
304
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
305
-			if($input['stay'] != '') {
306
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
307
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
308
-			} else {
309
-				$stayUrl = "index.php?a=75&r=2";
310
-			}
311
-
312
-			include_once "header.inc.php";
313
-			?>
195
+			    include_once "footer.inc.php";
196
+		    }
197
+		    break;
198
+	    case '12' : // edit user
199
+		    // generate a new password for this user
200
+		    if($genpassword == 1) {
201
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
202
+				    if(strlen($specifiedpassword) < 6) {
203
+					    webAlertAndQuit("Password is too short!", 12);
204
+				    } else {
205
+					    $newpassword = $specifiedpassword;
206
+				    }
207
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
208
+				    webAlertAndQuit("You didn't specify a password for this user!", 12);
209
+			    } elseif($passwordgenmethod == 'g') {
210
+				    $newpassword = generate_password(8);
211
+			    } else {
212
+				    webAlertAndQuit("No password generation method specified!", 12);
213
+			    }
214
+		    }
215
+		    if($passwordnotifymethod == 'e') {
216
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
217
+		    }
218
+
219
+		    // check if the username already exist
220
+		    $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id));
221
+		    $limit = $modx->getDatabase()->getValue($rs);
222
+		    if($limit > 0) {
223
+			    webAlertAndQuit("User name is already in use!", 12);
224
+		    }
225
+
226
+		    // check if the email address already exists
227
+		    $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id));
228
+		    $limit = $modx->getDatabase()->getValue($rs);
229
+		    if($limit > 0) {
230
+			    webAlertAndQuit("Email is already in use!", 12);
231
+		    }
232
+
233
+		    // invoke OnBeforeUserFormSave event
234
+		    $modx->invokeEvent("OnBeforeUserFormSave", array(
235
+			    "mode" => "upd",
236
+			    "id" => $id
237
+		    ));
238
+
239
+		    // update user name and password
240
+		    $field = array();
241
+		    $field['username'] = $modx->getDatabase()->escape($newusername);
242
+		    if($genpassword == 1) {
243
+			    $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
244
+		    }
245
+		    $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'");
246
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
247
+		    $field = $modx->getDatabase()->escape($field);
248
+		    $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'");
249
+
250
+		    // Save user settings
251
+            saveManagerUserSettings($id);
252
+
253
+		    // Set the item name for logger
254
+		    $_SESSION['itemname'] = $newusername;
255
+
256
+		    // invoke OnManagerSaveUser event
257
+		    $modx->invokeEvent("OnManagerSaveUser", array(
258
+			    "mode" => "upd",
259
+			    "userid" => $id,
260
+			    "username" => $newusername,
261
+			    "userpassword" => $newpassword,
262
+			    "useremail" => $email,
263
+			    "userfullname" => $fullname,
264
+			    "userroleid" => $role,
265
+			    "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
266
+			    "olduseremail" => (($oldemail != $email) ? $oldemail : "")
267
+		    ));
268
+
269
+		    // invoke OnManagerChangePassword event
270
+		    if($genpassword == 1) {
271
+			    $modx->invokeEvent("OnManagerChangePassword", array(
272
+				    "userid" => $id,
273
+				    "username" => $newusername,
274
+				    "userpassword" => $newpassword
275
+			    ));
276
+		    }
277
+
278
+		    // invoke OnUserFormSave event
279
+		    $modx->invokeEvent("OnUserFormSave", array(
280
+			    "mode" => "upd",
281
+			    "id" => $id
282
+		    ));
283
+
284
+		    /*******************************************************************************/
285
+		    // put the user in the user_groups he/ she should be in
286
+		    // first, check that up_perms are switched on!
287
+		    if($use_udperms == 1) {
288
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
289
+			    $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'");
290
+			    if(!empty($user_groups)) {
291
+				    for($i = 0; $i < count($user_groups); $i++) {
292
+					    $field = array();
293
+					    $field['user_group'] = (int)$user_groups[$i];
294
+					    $field['member'] = $id;
295
+					    $modx->getDatabase()->insert($field, $tbl_member_groups);
296
+				    }
297
+			    }
298
+		    }
299
+		    // end of user_groups stuff!
300
+		    /*******************************************************************************/
301
+		    if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
302
+			    $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
303
+		    }
304
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
305
+			    if($input['stay'] != '') {
306
+				    $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
307
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
308
+			    } else {
309
+				    $stayUrl = "index.php?a=75&r=2";
310
+			    }
311
+
312
+			    include_once "header.inc.php";
313
+			    ?>
314 314
 
315 315
 			<h1><?php echo $_lang['user_title']; ?></h1>
316 316
 
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
 			</div>
331 331
 			<?php
332 332
 
333
-			include_once "footer.inc.php";
334
-		} else {
335
-			if($input['stay'] != '') {
336
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
337
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
338
-				header($header);
339
-			} else {
340
-				$header = "Location: index.php?a=75&r=2";
341
-				header($header);
342
-			}
343
-		}
344
-		break;
345
-	default:
346
-		webAlertAndQuit("No operation set in request.", 12);
333
+			    include_once "footer.inc.php";
334
+		    } else {
335
+			    if($input['stay'] != '') {
336
+				    $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
337
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
338
+				    header($header);
339
+			    } else {
340
+				    $header = "Location: index.php?a=75&r=2";
341
+				    header($header);
342
+			    }
343
+		    }
344
+		    break;
345
+	    default:
346
+		    webAlertAndQuit("No operation set in request.", 12);
347 347
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 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
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 
15
-$id = (int)$input['id'];
15
+$id = (int) $input['id'];
16 16
 $oldusername = $input['oldusername'];
17 17
 $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User";
18 18
 $fullname = $input['fullname'];
@@ -42,56 +42,56 @@  discard block
 block discarded – undo
42 42
 $user_groups = $input['user_groups'];
43 43
 
44 44
 // verify password
45
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
45
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
46 46
 	webAlertAndQuit("Password typed is mismatched", 12);
47 47
 }
48 48
 
49 49
 // verify email
50
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
50
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
51 51
 	webAlertAndQuit("E-mail address doesn't seem to be valid!", 12);
52 52
 }
53 53
 
54 54
 // verify admin security
55
-if($_SESSION['mgrRole'] != 1) {
55
+if ($_SESSION['mgrRole'] != 1) {
56 56
 	// Check to see if user tried to spoof a "1" (admin) role
57
-	if(!$modx->hasPermission('save_user')) {
57
+	if (!$modx->hasPermission('save_user')) {
58 58
 		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12);
59 59
 	}
60 60
 	// Verify that the user being edited wasn't an admin and the user ID got spoofed
61 61
 	$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
62 62
 	$limit = $modx->getDatabase()->getValue($rs);
63
-	if($limit > 0) {
63
+	if ($limit > 0) {
64 64
 		webAlertAndQuit("You cannot alter an administrative user.", 12);
65 65
 	}
66 66
 
67 67
 }
68 68
 
69
-switch($input['mode']) {
69
+switch ($input['mode']) {
70 70
 	case '11' : // new user
71 71
 		// check if this user name already exist
72 72
 		$rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername)));
73 73
 		$limit = $modx->getDatabase()->getValue($rs);
74
-		if($limit > 0) {
74
+		if ($limit > 0) {
75 75
 			webAlertAndQuit("User name is already in use!", 12);
76 76
 		}
77 77
 
78 78
 		// check if the email address already exist
79 79
 		$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id));
80 80
 		$limit = $modx->getDatabase()->getValue($rs);
81
-		if($limit > 0) {
81
+		if ($limit > 0) {
82 82
 			webAlertAndQuit("Email is already in use!", 12);
83 83
 		}
84 84
 
85 85
 		// generate a new password for this user
86
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
87
-			if(strlen($specifiedpassword) < 6) {
86
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
87
+			if (strlen($specifiedpassword) < 6) {
88 88
 				webAlertAndQuit("Password is too short!", 12);
89 89
 			} else {
90 90
 				$newpassword = $specifiedpassword;
91 91
 			}
92
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
92
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
93 93
 			webAlertAndQuit("You didn't specify a password for this user!", 12);
94
-		} elseif($passwordgenmethod == 'g') {
94
+		} elseif ($passwordgenmethod == 'g') {
95 95
 			$newpassword = generate_password(8);
96 96
 		} else {
97 97
 			webAlertAndQuit("No password generation method specified!", 12);
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 		/*******************************************************************************/
140 140
 		// put the user in the user_groups he/ she should be in
141 141
 		// first, check that up_perms are switched on!
142
-		if($use_udperms == 1) {
143
-			if(!empty($user_groups)) {
144
-				for($i = 0; $i < count($user_groups); $i++) {
142
+		if ($use_udperms == 1) {
143
+			if (!empty($user_groups)) {
144
+				for ($i = 0; $i < count($user_groups); $i++) {
145 145
 					$f = array();
146
-					$f['user_group'] = (int)$user_groups[$i];
146
+					$f['user_group'] = (int) $user_groups[$i];
147 147
 					$f['member'] = $internalKey;
148 148
 					$modx->getDatabase()->insert($f, $tbl_member_groups);
149 149
 				}
@@ -151,20 +151,20 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		// end of user_groups stuff!
153 153
 
154
-		if($passwordnotifymethod == 'e') {
154
+		if ($passwordnotifymethod == 'e') {
155 155
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
156
-			if($input['stay'] != '') {
156
+			if ($input['stay'] != '') {
157 157
 				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
158
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
158
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
159 159
 				header($header);
160 160
 			} else {
161 161
 				$header = "Location: index.php?a=75&r=2";
162 162
 				header($header);
163 163
 			}
164 164
 		} else {
165
-			if($input['stay'] != '') {
165
+			if ($input['stay'] != '') {
166 166
 				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
167
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
167
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
168 168
 			} else {
169 169
 				$stayUrl = "index.php?a=75&r=2";
170 170
 			}
@@ -197,36 +197,36 @@  discard block
 block discarded – undo
197 197
 		break;
198 198
 	case '12' : // edit user
199 199
 		// generate a new password for this user
200
-		if($genpassword == 1) {
201
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
202
-				if(strlen($specifiedpassword) < 6) {
200
+		if ($genpassword == 1) {
201
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
202
+				if (strlen($specifiedpassword) < 6) {
203 203
 					webAlertAndQuit("Password is too short!", 12);
204 204
 				} else {
205 205
 					$newpassword = $specifiedpassword;
206 206
 				}
207
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
207
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
208 208
 				webAlertAndQuit("You didn't specify a password for this user!", 12);
209
-			} elseif($passwordgenmethod == 'g') {
209
+			} elseif ($passwordgenmethod == 'g') {
210 210
 				$newpassword = generate_password(8);
211 211
 			} else {
212 212
 				webAlertAndQuit("No password generation method specified!", 12);
213 213
 			}
214 214
 		}
215
-		if($passwordnotifymethod == 'e') {
215
+		if ($passwordnotifymethod == 'e') {
216 216
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
217 217
 		}
218 218
 
219 219
 		// check if the username already exist
220 220
 		$rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id));
221 221
 		$limit = $modx->getDatabase()->getValue($rs);
222
-		if($limit > 0) {
222
+		if ($limit > 0) {
223 223
 			webAlertAndQuit("User name is already in use!", 12);
224 224
 		}
225 225
 
226 226
 		// check if the email address already exists
227 227
 		$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id));
228 228
 		$limit = $modx->getDatabase()->getValue($rs);
229
-		if($limit > 0) {
229
+		if ($limit > 0) {
230 230
 			webAlertAndQuit("Email is already in use!", 12);
231 231
 		}
232 232
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		// update user name and password
240 240
 		$field = array();
241 241
 		$field['username'] = $modx->getDatabase()->escape($newusername);
242
-		if($genpassword == 1) {
242
+		if ($genpassword == 1) {
243 243
 			$field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
244 244
 		}
245 245
 		$modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'");
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		));
268 268
 
269 269
 		// invoke OnManagerChangePassword event
270
-		if($genpassword == 1) {
270
+		if ($genpassword == 1) {
271 271
 			$modx->invokeEvent("OnManagerChangePassword", array(
272 272
 				"userid" => $id,
273 273
 				"username" => $newusername,
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
 		/*******************************************************************************/
285 285
 		// put the user in the user_groups he/ she should be in
286 286
 		// first, check that up_perms are switched on!
287
-		if($use_udperms == 1) {
287
+		if ($use_udperms == 1) {
288 288
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
289 289
 			$modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'");
290
-			if(!empty($user_groups)) {
291
-				for($i = 0; $i < count($user_groups); $i++) {
290
+			if (!empty($user_groups)) {
291
+				for ($i = 0; $i < count($user_groups); $i++) {
292 292
 					$field = array();
293
-					$field['user_group'] = (int)$user_groups[$i];
293
+					$field['user_group'] = (int) $user_groups[$i];
294 294
 					$field['member'] = $id;
295 295
 					$modx->getDatabase()->insert($field, $tbl_member_groups);
296 296
 				}
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
 		}
299 299
 		// end of user_groups stuff!
300 300
 		/*******************************************************************************/
301
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
301
+		if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
302 302
 			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
303 303
 		}
304
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
305
-			if($input['stay'] != '') {
304
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
305
+			if ($input['stay'] != '') {
306 306
 				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
307
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
307
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
308 308
 			} else {
309 309
 				$stayUrl = "index.php?a=75&r=2";
310 310
 			}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 				<div class="sectionHeader"><?php echo $_lang['user_title']; ?></div>
325 325
 				<div class="sectionBody">
326 326
 					<div id="disp">
327
-						<p><?php echo sprintf($_lang["password_msg"], $modx->getPhpCompat()->htmlspecialchars($newusername), $modx->getPhpCompat()->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p>
327
+						<p><?php echo sprintf($_lang["password_msg"], $modx->getPhpCompat()->htmlspecialchars($newusername), $modx->getPhpCompat()->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p>
328 328
 					</div>
329 329
 				</div>
330 330
 			</div>
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 
333 333
 			include_once "footer.inc.php";
334 334
 		} else {
335
-			if($input['stay'] != '') {
335
+			if ($input['stay'] != '') {
336 336
 				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
337
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
337
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
338 338
 				header($header);
339 339
 			} else {
340 340
 				$header = "Location: index.php?a=75&r=2";
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 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
 $tbl_manager_users = $modx->getDatabase()->getFullTableName('manager_users');
@@ -43,134 +43,134 @@  discard block
 block discarded – undo
43 43
 
44 44
 // verify password
45 45
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
46
-	webAlertAndQuit("Password typed is mismatched", 12);
46
+    webAlertAndQuit("Password typed is mismatched", 12);
47 47
 }
48 48
 
49 49
 // verify email
50 50
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
51
-	webAlertAndQuit("E-mail address doesn't seem to be valid!", 12);
51
+    webAlertAndQuit("E-mail address doesn't seem to be valid!", 12);
52 52
 }
53 53
 
54 54
 // verify admin security
55 55
 if($_SESSION['mgrRole'] != 1) {
56
-	// Check to see if user tried to spoof a "1" (admin) role
57
-	if(!$modx->hasPermission('save_user')) {
58
-		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12);
59
-	}
60
-	// Verify that the user being edited wasn't an admin and the user ID got spoofed
61
-	$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
62
-	$limit = $modx->getDatabase()->getValue($rs);
63
-	if($limit > 0) {
64
-		webAlertAndQuit("You cannot alter an administrative user.", 12);
65
-	}
56
+    // Check to see if user tried to spoof a "1" (admin) role
57
+    if(!$modx->hasPermission('save_user')) {
58
+        webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12);
59
+    }
60
+    // Verify that the user being edited wasn't an admin and the user ID got spoofed
61
+    $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
62
+    $limit = $modx->getDatabase()->getValue($rs);
63
+    if($limit > 0) {
64
+        webAlertAndQuit("You cannot alter an administrative user.", 12);
65
+    }
66 66
 
67 67
 }
68 68
 
69 69
 switch($input['mode']) {
70
-	case '11' : // new user
71
-		// check if this user name already exist
72
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername)));
73
-		$limit = $modx->getDatabase()->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("User name is already in use!", 12);
76
-		}
77
-
78
-		// check if the email address already exist
79
-		$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id));
80
-		$limit = $modx->getDatabase()->getValue($rs);
81
-		if($limit > 0) {
82
-			webAlertAndQuit("Email is already in use!", 12);
83
-		}
84
-
85
-		// generate a new password for this user
86
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
87
-			if(strlen($specifiedpassword) < 6) {
88
-				webAlertAndQuit("Password is too short!", 12);
89
-			} else {
90
-				$newpassword = $specifiedpassword;
91
-			}
92
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
93
-			webAlertAndQuit("You didn't specify a password for this user!", 12);
94
-		} elseif($passwordgenmethod == 'g') {
95
-			$newpassword = generate_password(8);
96
-		} else {
97
-			webAlertAndQuit("No password generation method specified!", 12);
98
-		}
99
-
100
-		// invoke OnBeforeUserFormSave event
101
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
102
-			"mode" => "new",
103
-		));
104
-
105
-		// create the user account
106
-		$internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users);
107
-
108
-		$field = array();
109
-		$field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
110
-		$modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'");
111
-
112
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
113
-		$field = $modx->getDatabase()->escape($field);
114
-		$modx->getDatabase()->insert($field, $tbl_user_attributes);
115
-
116
-		// Save user settings
70
+    case '11' : // new user
71
+        // check if this user name already exist
72
+        $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername)));
73
+        $limit = $modx->getDatabase()->getValue($rs);
74
+        if($limit > 0) {
75
+            webAlertAndQuit("User name is already in use!", 12);
76
+        }
77
+
78
+        // check if the email address already exist
79
+        $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id));
80
+        $limit = $modx->getDatabase()->getValue($rs);
81
+        if($limit > 0) {
82
+            webAlertAndQuit("Email is already in use!", 12);
83
+        }
84
+
85
+        // generate a new password for this user
86
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
87
+            if(strlen($specifiedpassword) < 6) {
88
+                webAlertAndQuit("Password is too short!", 12);
89
+            } else {
90
+                $newpassword = $specifiedpassword;
91
+            }
92
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
93
+            webAlertAndQuit("You didn't specify a password for this user!", 12);
94
+        } elseif($passwordgenmethod == 'g') {
95
+            $newpassword = generate_password(8);
96
+        } else {
97
+            webAlertAndQuit("No password generation method specified!", 12);
98
+        }
99
+
100
+        // invoke OnBeforeUserFormSave event
101
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
102
+            "mode" => "new",
103
+        ));
104
+
105
+        // create the user account
106
+        $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users);
107
+
108
+        $field = array();
109
+        $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
110
+        $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'");
111
+
112
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
113
+        $field = $modx->getDatabase()->escape($field);
114
+        $modx->getDatabase()->insert($field, $tbl_user_attributes);
115
+
116
+        // Save user settings
117 117
         saveManagerUserSettings($internalKey);
118 118
 
119
-		// invoke OnManagerSaveUser event
120
-		$modx->invokeEvent("OnManagerSaveUser", array(
121
-			"mode" => "new",
122
-			"userid" => $internalKey,
123
-			"username" => $newusername,
124
-			"userpassword" => $newpassword,
125
-			"useremail" => $email,
126
-			"userfullname" => $fullname,
127
-			"userroleid" => $role
128
-		));
129
-
130
-		// invoke OnUserFormSave event
131
-		$modx->invokeEvent("OnUserFormSave", array(
132
-			"mode" => "new",
133
-			"id" => $internalKey
134
-		));
135
-
136
-		// Set the item name for logger
137
-		$_SESSION['itemname'] = $newusername;
138
-
139
-		/*******************************************************************************/
140
-		// put the user in the user_groups he/ she should be in
141
-		// first, check that up_perms are switched on!
142
-		if($use_udperms == 1) {
143
-			if(!empty($user_groups)) {
144
-				for($i = 0; $i < count($user_groups); $i++) {
145
-					$f = array();
146
-					$f['user_group'] = (int)$user_groups[$i];
147
-					$f['member'] = $internalKey;
148
-					$modx->getDatabase()->insert($f, $tbl_member_groups);
149
-				}
150
-			}
151
-		}
152
-		// end of user_groups stuff!
153
-
154
-		if($passwordnotifymethod == 'e') {
119
+        // invoke OnManagerSaveUser event
120
+        $modx->invokeEvent("OnManagerSaveUser", array(
121
+            "mode" => "new",
122
+            "userid" => $internalKey,
123
+            "username" => $newusername,
124
+            "userpassword" => $newpassword,
125
+            "useremail" => $email,
126
+            "userfullname" => $fullname,
127
+            "userroleid" => $role
128
+        ));
129
+
130
+        // invoke OnUserFormSave event
131
+        $modx->invokeEvent("OnUserFormSave", array(
132
+            "mode" => "new",
133
+            "id" => $internalKey
134
+        ));
135
+
136
+        // Set the item name for logger
137
+        $_SESSION['itemname'] = $newusername;
138
+
139
+        /*******************************************************************************/
140
+        // put the user in the user_groups he/ she should be in
141
+        // first, check that up_perms are switched on!
142
+        if($use_udperms == 1) {
143
+            if(!empty($user_groups)) {
144
+                for($i = 0; $i < count($user_groups); $i++) {
145
+                    $f = array();
146
+                    $f['user_group'] = (int)$user_groups[$i];
147
+                    $f['member'] = $internalKey;
148
+                    $modx->getDatabase()->insert($f, $tbl_member_groups);
149
+                }
150
+            }
151
+        }
152
+        // end of user_groups stuff!
153
+
154
+        if($passwordnotifymethod == 'e') {
155 155
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
158
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-				header($header);
160
-			} else {
161
-				$header = "Location: index.php?a=75&r=2";
162
-				header($header);
163
-			}
164
-		} else {
165
-			if($input['stay'] != '') {
166
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
167
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
168
-			} else {
169
-				$stayUrl = "index.php?a=75&r=2";
170
-			}
171
-
172
-			include_once "header.inc.php";
173
-			?>
156
+            if($input['stay'] != '') {
157
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
158
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+                header($header);
160
+            } else {
161
+                $header = "Location: index.php?a=75&r=2";
162
+                header($header);
163
+            }
164
+        } else {
165
+            if($input['stay'] != '') {
166
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
167
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
168
+            } else {
169
+                $stayUrl = "index.php?a=75&r=2";
170
+            }
171
+
172
+            include_once "header.inc.php";
173
+            ?>
174 174
 
175 175
 			<h1><?php echo $_lang['user_title']; ?></h1>
176 176
 
@@ -192,125 +192,125 @@  discard block
 block discarded – undo
192 192
 			</div>
193 193
 			<?php
194 194
 
195
-			include_once "footer.inc.php";
196
-		}
197
-		break;
198
-	case '12' : // edit user
199
-		// generate a new password for this user
200
-		if($genpassword == 1) {
201
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
202
-				if(strlen($specifiedpassword) < 6) {
203
-					webAlertAndQuit("Password is too short!", 12);
204
-				} else {
205
-					$newpassword = $specifiedpassword;
206
-				}
207
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
208
-				webAlertAndQuit("You didn't specify a password for this user!", 12);
209
-			} elseif($passwordgenmethod == 'g') {
210
-				$newpassword = generate_password(8);
211
-			} else {
212
-				webAlertAndQuit("No password generation method specified!", 12);
213
-			}
214
-		}
215
-		if($passwordnotifymethod == 'e') {
195
+            include_once "footer.inc.php";
196
+        }
197
+        break;
198
+    case '12' : // edit user
199
+        // generate a new password for this user
200
+        if($genpassword == 1) {
201
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
202
+                if(strlen($specifiedpassword) < 6) {
203
+                    webAlertAndQuit("Password is too short!", 12);
204
+                } else {
205
+                    $newpassword = $specifiedpassword;
206
+                }
207
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
208
+                webAlertAndQuit("You didn't specify a password for this user!", 12);
209
+            } elseif($passwordgenmethod == 'g') {
210
+                $newpassword = generate_password(8);
211
+            } else {
212
+                webAlertAndQuit("No password generation method specified!", 12);
213
+            }
214
+        }
215
+        if($passwordnotifymethod == 'e') {
216 216
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
217
-		}
218
-
219
-		// check if the username already exist
220
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id));
221
-		$limit = $modx->getDatabase()->getValue($rs);
222
-		if($limit > 0) {
223
-			webAlertAndQuit("User name is already in use!", 12);
224
-		}
225
-
226
-		// check if the email address already exists
227
-		$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id));
228
-		$limit = $modx->getDatabase()->getValue($rs);
229
-		if($limit > 0) {
230
-			webAlertAndQuit("Email is already in use!", 12);
231
-		}
232
-
233
-		// invoke OnBeforeUserFormSave event
234
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
235
-			"mode" => "upd",
236
-			"id" => $id
237
-		));
238
-
239
-		// update user name and password
240
-		$field = array();
241
-		$field['username'] = $modx->getDatabase()->escape($newusername);
242
-		if($genpassword == 1) {
243
-			$field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
244
-		}
245
-		$modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'");
246
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
247
-		$field = $modx->getDatabase()->escape($field);
248
-		$modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'");
249
-
250
-		// Save user settings
217
+        }
218
+
219
+        // check if the username already exist
220
+        $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id));
221
+        $limit = $modx->getDatabase()->getValue($rs);
222
+        if($limit > 0) {
223
+            webAlertAndQuit("User name is already in use!", 12);
224
+        }
225
+
226
+        // check if the email address already exists
227
+        $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id));
228
+        $limit = $modx->getDatabase()->getValue($rs);
229
+        if($limit > 0) {
230
+            webAlertAndQuit("Email is already in use!", 12);
231
+        }
232
+
233
+        // invoke OnBeforeUserFormSave event
234
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
235
+            "mode" => "upd",
236
+            "id" => $id
237
+        ));
238
+
239
+        // update user name and password
240
+        $field = array();
241
+        $field['username'] = $modx->getDatabase()->escape($newusername);
242
+        if($genpassword == 1) {
243
+            $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword);
244
+        }
245
+        $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'");
246
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
247
+        $field = $modx->getDatabase()->escape($field);
248
+        $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'");
249
+
250
+        // Save user settings
251 251
         saveManagerUserSettings($id);
252 252
 
253
-		// Set the item name for logger
254
-		$_SESSION['itemname'] = $newusername;
255
-
256
-		// invoke OnManagerSaveUser event
257
-		$modx->invokeEvent("OnManagerSaveUser", array(
258
-			"mode" => "upd",
259
-			"userid" => $id,
260
-			"username" => $newusername,
261
-			"userpassword" => $newpassword,
262
-			"useremail" => $email,
263
-			"userfullname" => $fullname,
264
-			"userroleid" => $role,
265
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
266
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
267
-		));
268
-
269
-		// invoke OnManagerChangePassword event
270
-		if($genpassword == 1) {
271
-			$modx->invokeEvent("OnManagerChangePassword", array(
272
-				"userid" => $id,
273
-				"username" => $newusername,
274
-				"userpassword" => $newpassword
275
-			));
276
-		}
277
-
278
-		// invoke OnUserFormSave event
279
-		$modx->invokeEvent("OnUserFormSave", array(
280
-			"mode" => "upd",
281
-			"id" => $id
282
-		));
283
-
284
-		/*******************************************************************************/
285
-		// put the user in the user_groups he/ she should be in
286
-		// first, check that up_perms are switched on!
287
-		if($use_udperms == 1) {
288
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
289
-			$modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'");
290
-			if(!empty($user_groups)) {
291
-				for($i = 0; $i < count($user_groups); $i++) {
292
-					$field = array();
293
-					$field['user_group'] = (int)$user_groups[$i];
294
-					$field['member'] = $id;
295
-					$modx->getDatabase()->insert($field, $tbl_member_groups);
296
-				}
297
-			}
298
-		}
299
-		// end of user_groups stuff!
300
-		/*******************************************************************************/
301
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
302
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
303
-		}
304
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
305
-			if($input['stay'] != '') {
306
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
307
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
308
-			} else {
309
-				$stayUrl = "index.php?a=75&r=2";
310
-			}
311
-
312
-			include_once "header.inc.php";
313
-			?>
253
+        // Set the item name for logger
254
+        $_SESSION['itemname'] = $newusername;
255
+
256
+        // invoke OnManagerSaveUser event
257
+        $modx->invokeEvent("OnManagerSaveUser", array(
258
+            "mode" => "upd",
259
+            "userid" => $id,
260
+            "username" => $newusername,
261
+            "userpassword" => $newpassword,
262
+            "useremail" => $email,
263
+            "userfullname" => $fullname,
264
+            "userroleid" => $role,
265
+            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
266
+            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
267
+        ));
268
+
269
+        // invoke OnManagerChangePassword event
270
+        if($genpassword == 1) {
271
+            $modx->invokeEvent("OnManagerChangePassword", array(
272
+                "userid" => $id,
273
+                "username" => $newusername,
274
+                "userpassword" => $newpassword
275
+            ));
276
+        }
277
+
278
+        // invoke OnUserFormSave event
279
+        $modx->invokeEvent("OnUserFormSave", array(
280
+            "mode" => "upd",
281
+            "id" => $id
282
+        ));
283
+
284
+        /*******************************************************************************/
285
+        // put the user in the user_groups he/ she should be in
286
+        // first, check that up_perms are switched on!
287
+        if($use_udperms == 1) {
288
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
289
+            $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'");
290
+            if(!empty($user_groups)) {
291
+                for($i = 0; $i < count($user_groups); $i++) {
292
+                    $field = array();
293
+                    $field['user_group'] = (int)$user_groups[$i];
294
+                    $field['member'] = $id;
295
+                    $modx->getDatabase()->insert($field, $tbl_member_groups);
296
+                }
297
+            }
298
+        }
299
+        // end of user_groups stuff!
300
+        /*******************************************************************************/
301
+        if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
302
+            $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
303
+        }
304
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
305
+            if($input['stay'] != '') {
306
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
307
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
308
+            } else {
309
+                $stayUrl = "index.php?a=75&r=2";
310
+            }
311
+
312
+            include_once "header.inc.php";
313
+            ?>
314 314
 
315 315
 			<h1><?php echo $_lang['user_title']; ?></h1>
316 316
 
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
 			</div>
331 331
 			<?php
332 332
 
333
-			include_once "footer.inc.php";
334
-		} else {
335
-			if($input['stay'] != '') {
336
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
337
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
338
-				header($header);
339
-			} else {
340
-				$header = "Location: index.php?a=75&r=2";
341
-				header($header);
342
-			}
343
-		}
344
-		break;
345
-	default:
346
-		webAlertAndQuit("No operation set in request.", 12);
333
+            include_once "footer.inc.php";
334
+        } else {
335
+            if($input['stay'] != '') {
336
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
337
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
338
+                header($header);
339
+            } else {
340
+                $header = "Location: index.php?a=75&r=2";
341
+                header($header);
342
+            }
343
+        }
344
+        break;
345
+    default:
346
+        webAlertAndQuit("No operation set in request.", 12);
347 347
 }
Please login to merge, or discard this patch.
manager/processors/export_site.processor.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  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('export_static')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $maxtime = (is_numeric($_POST['maxtime'])) ? $_POST['maxtime'] : 30;
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 $modx->getExportSite()->targetDir = $export_dir;
16 16
 
17 17
 if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path'])))
18
-	return $_lang['export_site.static.php6'];
18
+    return $_lang['export_site.static.php6'];
19 19
 elseif($modx->config['rb_base_dir'] === $export_dir . '/')
20
-	return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
20
+    return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
21 21
 elseif(!is_writable($export_dir))
22
-	return $_lang['export_site_target_unwritable'];
22
+    return $_lang['export_site_target_unwritable'];
23 23
 
24 24
 $modx->getExportSite()->generate_mode = $_POST['generate_mode'];
25 25
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  ||$includenoncache!==$_POST['includenoncache']
36 36
  ||$repl_before!==$_POST['repl_before']
37 37
  ||$repl_after !==$_POST['repl_after']) {
38
-	$modx->clearCache('full');
38
+    $modx->clearCache('full');
39 39
 }
40 40
 
41 41
 $total = $modx->getExportSite()->getTotal($_POST['ignore_ids'], $modx->config['export_includenoncache']);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 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('export_static')) {
5
+if (!$modx->hasPermission('export_static')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
 @set_time_limit($maxtime);
11 11
 
12 12
 
13
-if(is_dir(MODX_BASE_PATH . 'temp'))       $export_dir = MODX_BASE_PATH . 'temp/export';
14
-elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export';
13
+if (is_dir(MODX_BASE_PATH.'temp'))       $export_dir = MODX_BASE_PATH.'temp/export';
14
+elseif (is_dir(MODX_BASE_PATH.'assets')) $export_dir = MODX_BASE_PATH.'assets/export';
15 15
 $modx->getExportSite()->targetDir = $export_dir;
16 16
 
17
-if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path'])))
17
+if (strpos($modx->config['base_path'], "{$export_dir}/") === 0 && 0 <= strlen(str_replace("{$export_dir}/", '', $modx->config['base_path'])))
18 18
 	return $_lang['export_site.static.php6'];
19
-elseif($modx->config['rb_base_dir'] === $export_dir . '/')
20
-	return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
21
-elseif(!is_writable($export_dir))
19
+elseif ($modx->config['rb_base_dir'] === $export_dir.'/')
20
+	return $modx->parsePlaceholder($_lang['export_site.static.php7'], 'rb_base_url='.$modx->config['base_url'].$modx->config['rb_base_url']);
21
+elseif (!is_writable($export_dir))
22 22
 	return $_lang['export_site_target_unwritable'];
23 23
 
24 24
 $modx->getExportSite()->generate_mode = $_POST['generate_mode'];
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 $repl_after      = $_POST['repl_after'];
32 32
 $includenoncache = $_POST['includenoncache'];
33 33
 
34
-if($ignore_ids!==$_POST['ignore_ids']
35
- ||$includenoncache!==$_POST['includenoncache']
36
- ||$repl_before!==$_POST['repl_before']
37
- ||$repl_after !==$_POST['repl_after']) {
34
+if ($ignore_ids !== $_POST['ignore_ids']
35
+ ||$includenoncache !== $_POST['includenoncache']
36
+ ||$repl_before !== $_POST['repl_before']
37
+ ||$repl_after !== $_POST['repl_after']) {
38 38
 	$modx->clearCache('full');
39 39
 }
40 40
 
@@ -50,5 +50,5 @@  discard block
 block discarded – undo
50 50
 
51 51
 $exportend = $modx->getExportSite()->get_mtime();
52 52
 $totaltime = ($exportend - $modx->getExportSite()->exportstart);
53
-$output .= sprintf ('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3));
53
+$output .= sprintf('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3));
54 54
 return $output;
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,16 +10,20 @@
 block discarded – undo
10 10
 @set_time_limit($maxtime);
11 11
 
12 12
 
13
-if(is_dir(MODX_BASE_PATH . 'temp'))       $export_dir = MODX_BASE_PATH . 'temp/export';
14
-elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export';
13
+if(is_dir(MODX_BASE_PATH . 'temp')) {
14
+    $export_dir = MODX_BASE_PATH . 'temp/export';
15
+} elseif(is_dir(MODX_BASE_PATH . 'assets')) {
16
+    $export_dir = MODX_BASE_PATH . 'assets/export';
17
+}
15 18
 $modx->getExportSite()->targetDir = $export_dir;
16 19
 
17
-if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path'])))
20
+if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) {
18 21
 	return $_lang['export_site.static.php6'];
19
-elseif($modx->config['rb_base_dir'] === $export_dir . '/')
22
+} elseif($modx->config['rb_base_dir'] === $export_dir . '/') {
20 23
 	return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
21
-elseif(!is_writable($export_dir))
24
+} elseif(!is_writable($export_dir)) {
22 25
 	return $_lang['export_site_target_unwritable'];
26
+}
23 27
 
24 28
 $modx->getExportSite()->generate_mode = $_POST['generate_mode'];
25 29
 
Please login to merge, or discard this patch.
manager/processors/save_module.processor.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  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
 if (!$modx->hasPermission('save_module')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $name = $modx->getDatabase()->escape(trim($_POST['name']));
11 11
 $description = $modx->getDatabase()->escape($_POST['description']);
12 12
 $resourcefile = $modx->getDatabase()->escape($_POST['resourcefile']);
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 
26 26
 //Kyle Jaebker - added category support
27 27
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
28
-    $categoryid = (int)$_POST['categoryid'];
28
+    $categoryid = (int) $_POST['categoryid'];
29 29
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
30 30
     $categoryid = 0;
31 31
 } else {
32
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
32
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
33 33
     $categoryid = checkCategory($_POST['newcategory']);
34 34
     if (!$categoryid) {
35 35
         $categoryid = newCategory($_POST['newcategory']);
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
     $name = isset($parsed['name']) ? $parsed['name'] : $name;
46 46
     $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties;
47 47
     $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid;
48
-    $enable_sharedparams = isset($parsed['shareparams']) ? (int)$parsed['shareparams'] : $enable_sharedparams;
48
+    $enable_sharedparams = isset($parsed['shareparams']) ? (int) $parsed['shareparams'] : $enable_sharedparams;
49 49
 
50 50
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
51
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
51
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
52 52
     if ($version) {
53
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
53
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
54 54
     }
55 55
     if (isset($parsed['modx_category'])) {
56
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
56
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
57 57
         $categoryid = getCategory($parsed['modx_category']);
58 58
     }
59 59
 }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         // finished emptying cache - redirect
112 112
         if ($_POST['stay'] != '') {
113 113
             $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
114
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
115 115
             header($header);
116 116
         } else {
117 117
             $header = "Location: index.php?a=106&r=2";
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         // finished emptying cache - redirect
169 169
         if ($_POST['stay'] != '') {
170 170
             $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
171
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
172 172
             header($header);
173 173
         } else {
174 174
             $modx->unlockElement(6, $id);
Please login to merge, or discard this patch.
Switch Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -59,123 +59,123 @@
 block discarded – undo
59 59
 }
60 60
 
61 61
 switch ($_POST['mode']) {
62
-    case '107':
63
-        // invoke OnBeforeModFormSave event
64
-        $modx->invokeEvent("OnBeforeModFormSave", array(
65
-                "mode" => "new",
66
-                "id" => $id
67
-            ));
68
-
69
-        // disallow duplicate names for new modules
70
-        $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}'");
71
-        $count = $modx->getDatabase()->getValue($rs);
72
-        if ($count > 0) {
73
-            $modx->getManagerApi()->saveFormValues(107);
74
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
-        }
76
-
77
-        // save the new module
78
-        $newid = $modx->getDatabase()->insert(array(
79
-            'name' => $name,
80
-            'description' => $description,
81
-            'disabled' => $disabled,
82
-            'wrap' => $wrap,
83
-            'locked' => $locked,
84
-            'icon' => $icon,
85
-            'resourcefile' => $resourcefile,
86
-            'enable_resource' => $enable_resource,
87
-            'category' => $categoryid,
88
-            'enable_sharedparams' => $enable_sharedparams,
89
-            'guid' => $guid,
90
-            'modulecode' => $modulecode,
91
-            'properties' => $properties,
92
-            'createdon' => $currentdate,
93
-            'editedon' => $currentdate
94
-        ), $modx->getDatabase()->getFullTableName('site_modules'));
95
-
96
-        // save user group access permissions
97
-        saveUserGroupAccessPermissons();
98
-
99
-        // invoke OnModFormSave event
100
-        $modx->invokeEvent("OnModFormSave", array(
101
-                "mode" => "new",
102
-                "id" => $newid
103
-            ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=106&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '108':
122
-        // invoke OnBeforeModFormSave event
123
-        $modx->invokeEvent("OnBeforeModFormSave", array(
124
-                "mode" => "upd",
125
-                "id" => $id
126
-            ));
127
-
128
-        // disallow duplicate names for new modules
129
-        $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->getDatabase()->getValue($rs) > 0) {
131
-            $modx->getManagerApi()->saveFormValues(108);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
-        }
134
-
135
-        // save the edited module
136
-        $modx->getDatabase()->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'icon' => $icon,
140
-            'enable_resource' => $enable_resource,
141
-            'resourcefile' => $resourcefile,
142
-            'disabled' => $disabled,
143
-            'wrap' => $wrap,
144
-            'locked' => $locked,
145
-            'category' => $categoryid,
146
-            'enable_sharedparams' => $enable_sharedparams,
147
-            'guid' => $guid,
148
-            'modulecode' => $modulecode,
149
-            'properties' => $properties,
150
-            'editedon' => $currentdate
151
-        ), $modx->getDatabase()->getFullTableName('site_modules'), "id='{$id}'");
152
-
153
-        // save user group access permissions
154
-        saveUserGroupAccessPermissons();
155
-
156
-        // invoke OnModFormSave event
157
-        $modx->invokeEvent("OnModFormSave", array(
158
-                "mode" => "upd",
159
-                "id" => $id
160
-            ));
161
-
162
-        // Set the item name for logger
163
-        $_SESSION['itemname'] = $name;
164
-
165
-        // empty cache
166
-        $modx->clearCache('full');
167
-
168
-        // finished emptying cache - redirect
169
-        if ($_POST['stay'] != '') {
170
-            $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
-            header($header);
173
-        } else {
174
-            $modx->unlockElement(6, $id);
175
-            $header = "Location: index.php?a=106&r=2";
176
-            header($header);
177
-        }
178
-        break;
179
-    default:
180
-        $modx->webAlertAndQuit("No operation set in request.");
62
+        case '107':
63
+            // invoke OnBeforeModFormSave event
64
+            $modx->invokeEvent("OnBeforeModFormSave", array(
65
+                    "mode" => "new",
66
+                    "id" => $id
67
+                ));
68
+
69
+            // disallow duplicate names for new modules
70
+            $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}'");
71
+            $count = $modx->getDatabase()->getValue($rs);
72
+            if ($count > 0) {
73
+                $modx->getManagerApi()->saveFormValues(107);
74
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
+            }
76
+
77
+            // save the new module
78
+            $newid = $modx->getDatabase()->insert(array(
79
+                'name' => $name,
80
+                'description' => $description,
81
+                'disabled' => $disabled,
82
+                'wrap' => $wrap,
83
+                'locked' => $locked,
84
+                'icon' => $icon,
85
+                'resourcefile' => $resourcefile,
86
+                'enable_resource' => $enable_resource,
87
+                'category' => $categoryid,
88
+                'enable_sharedparams' => $enable_sharedparams,
89
+                'guid' => $guid,
90
+                'modulecode' => $modulecode,
91
+                'properties' => $properties,
92
+                'createdon' => $currentdate,
93
+                'editedon' => $currentdate
94
+            ), $modx->getDatabase()->getFullTableName('site_modules'));
95
+
96
+            // save user group access permissions
97
+            saveUserGroupAccessPermissons();
98
+
99
+            // invoke OnModFormSave event
100
+            $modx->invokeEvent("OnModFormSave", array(
101
+                    "mode" => "new",
102
+                    "id" => $newid
103
+                ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=106&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '108':
122
+            // invoke OnBeforeModFormSave event
123
+            $modx->invokeEvent("OnBeforeModFormSave", array(
124
+                    "mode" => "upd",
125
+                    "id" => $id
126
+                ));
127
+
128
+            // disallow duplicate names for new modules
129
+            $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->getDatabase()->getValue($rs) > 0) {
131
+                $modx->getManagerApi()->saveFormValues(108);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
+            }
134
+
135
+            // save the edited module
136
+            $modx->getDatabase()->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'icon' => $icon,
140
+                'enable_resource' => $enable_resource,
141
+                'resourcefile' => $resourcefile,
142
+                'disabled' => $disabled,
143
+                'wrap' => $wrap,
144
+                'locked' => $locked,
145
+                'category' => $categoryid,
146
+                'enable_sharedparams' => $enable_sharedparams,
147
+                'guid' => $guid,
148
+                'modulecode' => $modulecode,
149
+                'properties' => $properties,
150
+                'editedon' => $currentdate
151
+            ), $modx->getDatabase()->getFullTableName('site_modules'), "id='{$id}'");
152
+
153
+            // save user group access permissions
154
+            saveUserGroupAccessPermissons();
155
+
156
+            // invoke OnModFormSave event
157
+            $modx->invokeEvent("OnModFormSave", array(
158
+                    "mode" => "upd",
159
+                    "id" => $id
160
+                ));
161
+
162
+            // Set the item name for logger
163
+            $_SESSION['itemname'] = $name;
164
+
165
+            // empty cache
166
+            $modx->clearCache('full');
167
+
168
+            // finished emptying cache - redirect
169
+            if ($_POST['stay'] != '') {
170
+                $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
+                header($header);
173
+            } else {
174
+                $modx->unlockElement(6, $id);
175
+                $header = "Location: index.php?a=106&r=2";
176
+                header($header);
177
+            }
178
+            break;
179
+        default:
180
+            $modx->webAlertAndQuit("No operation set in request.");
181 181
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 3 patches
Switch Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -60,110 +60,110 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->getDatabase()->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!", 88);
69
-		}
70
-
71
-		// check if the email address already exist
72
-		if ($modx->config['allow_multiple_emails'] != 1) {
73
-			$rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
-			$limit = $modx->getDatabase()->getValue($rs);
75
-			if($limit > 0) {
76
-				webAlertAndQuit("Email is already in use!", 88);
77
-			}
78
-		}
79
-
80
-		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
83
-				webAlertAndQuit("Password is too short!", 88);
84
-			} else {
85
-				$newpassword = $specifiedpassword;
86
-			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
-			webAlertAndQuit("You didn't specify a password for this user!", 88);
89
-		} elseif($passwordgenmethod == 'g') {
90
-			$newpassword = generate_password(8);
91
-		} else {
92
-			webAlertAndQuit("No password generation method specified!", 88);
93
-		}
94
-
95
-		// invoke OnBeforeWUsrFormSave event
96
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
-			"mode" => "new",
98
-		));
99
-
100
-		// create the user account
101
-		$field = array();
102
-		$field['username'] = $esc_newusername;
103
-		$field['password'] = md5($newpassword);
104
-		$internalKey = $modx->getDatabase()->insert($field, $tbl_web_users);
105
-
106
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
-		$field = $modx->getDatabase()->escape($field);
108
-		$modx->getDatabase()->insert($field, $tbl_web_user_attributes);
109
-
110
-		// Save User Settings
111
-        saveWebUserSettings($internalKey);
112
-
113
-		// Set the item name for logger
114
-		$_SESSION['itemname'] = $newusername;
115
-
116
-		/*******************************************************************************/
117
-		// put the user in the user_groups he/ she should be in
118
-		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
122
-					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
124
-					$f['webuser'] = $internalKey;
125
-					$modx->getDatabase()->insert($f, $tbl_web_groups);
126
-				}
127
-			}
128
-		}
129
-		// end of user_groups stuff!
130
-
131
-        // invoke OnWebSaveUser event
132
-        $modx->invokeEvent("OnWebSaveUser", array(
133
-            "mode" => "new",
134
-            "userid" => $internalKey,
135
-            "username" => $newusername,
136
-            "userpassword" => $newpassword,
137
-            "useremail" => $email,
138
-            "userfullname" => $fullname
139
-        ));
140
-
141
-        // invoke OnWUsrFormSave event
142
-        $modx->invokeEvent("OnWUsrFormSave", array(
143
-            "mode" => "new",
144
-            "id" => $internalKey
145
-        ));
146
-
147
-		if($passwordnotifymethod == 'e') {
148
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
-			if($input['stay'] != '') {
150
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
-				header($header);
153
-			} else {
154
-				$header = "Location: index.php?a=99&r=2";
155
-				header($header);
156
-			}
157
-		} else {
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-			} else {
162
-				$stayUrl = "index.php?a=99&r=2";
163
-			}
164
-
165
-			include_once "header.inc.php";
166
-			?>
63
+	    case '87' : // new user
64
+		    // check if this user name already exist
65
+		    $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+		    $limit = $modx->getDatabase()->getValue($rs);
67
+		    if($limit > 0) {
68
+			    webAlertAndQuit("User name is already in use!", 88);
69
+		    }
70
+
71
+		    // check if the email address already exist
72
+		    if ($modx->config['allow_multiple_emails'] != 1) {
73
+			    $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
+			    $limit = $modx->getDatabase()->getValue($rs);
75
+			    if($limit > 0) {
76
+				    webAlertAndQuit("Email is already in use!", 88);
77
+			    }
78
+		    }
79
+
80
+		    // generate a new password for this user
81
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+			    if(strlen($specifiedpassword) < 6) {
83
+				    webAlertAndQuit("Password is too short!", 88);
84
+			    } else {
85
+				    $newpassword = $specifiedpassword;
86
+			    }
87
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
+			    webAlertAndQuit("You didn't specify a password for this user!", 88);
89
+		    } elseif($passwordgenmethod == 'g') {
90
+			    $newpassword = generate_password(8);
91
+		    } else {
92
+			    webAlertAndQuit("No password generation method specified!", 88);
93
+		    }
94
+
95
+		    // invoke OnBeforeWUsrFormSave event
96
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
+			    "mode" => "new",
98
+		    ));
99
+
100
+		    // create the user account
101
+		    $field = array();
102
+		    $field['username'] = $esc_newusername;
103
+		    $field['password'] = md5($newpassword);
104
+		    $internalKey = $modx->getDatabase()->insert($field, $tbl_web_users);
105
+
106
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
+		    $field = $modx->getDatabase()->escape($field);
108
+		    $modx->getDatabase()->insert($field, $tbl_web_user_attributes);
109
+
110
+		    // Save User Settings
111
+            saveWebUserSettings($internalKey);
112
+
113
+		    // Set the item name for logger
114
+		    $_SESSION['itemname'] = $newusername;
115
+
116
+		    /*******************************************************************************/
117
+		    // put the user in the user_groups he/ she should be in
118
+		    // first, check that up_perms are switched on!
119
+		    if($use_udperms == 1) {
120
+			    if(!empty($user_groups)) {
121
+				    for($i = 0; $i < count($user_groups); $i++) {
122
+					    $f = array();
123
+					    $f['webgroup'] = (int)$user_groups[$i];
124
+					    $f['webuser'] = $internalKey;
125
+					    $modx->getDatabase()->insert($f, $tbl_web_groups);
126
+				    }
127
+			    }
128
+		    }
129
+		    // end of user_groups stuff!
130
+
131
+            // invoke OnWebSaveUser event
132
+            $modx->invokeEvent("OnWebSaveUser", array(
133
+                "mode" => "new",
134
+                "userid" => $internalKey,
135
+                "username" => $newusername,
136
+                "userpassword" => $newpassword,
137
+                "useremail" => $email,
138
+                "userfullname" => $fullname
139
+            ));
140
+
141
+            // invoke OnWUsrFormSave event
142
+            $modx->invokeEvent("OnWUsrFormSave", array(
143
+                "mode" => "new",
144
+                "id" => $internalKey
145
+            ));
146
+
147
+		    if($passwordnotifymethod == 'e') {
148
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
+			    if($input['stay'] != '') {
150
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
+				    header($header);
153
+			    } else {
154
+				    $header = "Location: index.php?a=99&r=2";
155
+				    header($header);
156
+			    }
157
+		    } else {
158
+			    if($input['stay'] != '') {
159
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+			    } else {
162
+				    $stayUrl = "index.php?a=99&r=2";
163
+			    }
164
+
165
+			    include_once "header.inc.php";
166
+			    ?>
167 167
 
168 168
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
169 169
 
@@ -185,124 +185,124 @@  discard block
 block discarded – undo
185 185
 			</div>
186 186
 			<?php
187 187
 
188
-			include_once "footer.inc.php";
189
-		}
190
-		break;
191
-	case '88' : // edit user
192
-		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
196
-					webAlertAndQuit("Password is too short!", 88);
197
-				} else {
198
-					$newpassword = $specifiedpassword;
199
-				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
-				webAlertAndQuit("You didn't specify a password for this user!", 88);
202
-			} elseif($passwordgenmethod == 'g') {
203
-				$newpassword = generate_password(8);
204
-			} else {
205
-				webAlertAndQuit("No password generation method specified!", 88);
206
-			}
207
-		}
208
-		if($passwordnotifymethod == 'e') {
209
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210
-		}
211
-
212
-		// check if the username already exist
213
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
-		$limit = $modx->getDatabase()->getValue($rs);
215
-		if($limit > 0) {
216
-			webAlertAndQuit("User name is already in use!", 88);
217
-		}
218
-
219
-		// check if the email address already exists
220
-		if ($modx->config['allow_multiple_emails'] != 1) {
221
-			$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
-			$limit = $modx->getDatabase()->getValue($rs);
223
-			if($limit > 0) {
224
-				webAlertAndQuit("Email is already in use!", 88);
225
-			}
226
-		}
227
-
228
-		// invoke OnBeforeWUsrFormSave event
229
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
-			"mode" => "upd",
231
-			"id" => $id
232
-		));
233
-
234
-		// update user name and password
235
-		$field = array();
236
-		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
238
-			$field['password'] = md5($newpassword);
239
-		}
240
-		$modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'");
241
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
-		$field = $modx->getDatabase()->escape($field);
243
-		$modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
-
245
-		// Save User Settings
246
-        saveWebUserSettings($id);
247
-
248
-		// Set the item name for logger
249
-		$_SESSION['itemname'] = $newusername;
250
-
251
-		/*******************************************************************************/
252
-		// put the user in the user_groups he/ she should be in
253
-		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
255
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
-			$modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
259
-					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
261
-					$field['webuser'] = $id;
262
-					$modx->getDatabase()->insert($field, $tbl_web_groups);
263
-				}
264
-			}
265
-		}
266
-		// end of user_groups stuff!
267
-		/*******************************************************************************/
268
-
269
-        // invoke OnWebSaveUser event
270
-        $modx->invokeEvent("OnWebSaveUser", array(
271
-            "mode" => "upd",
272
-            "userid" => $id,
273
-            "username" => $newusername,
274
-            "userpassword" => $newpassword,
275
-            "useremail" => $email,
276
-            "userfullname" => $fullname,
277
-            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
278
-            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
279
-        ));
280
-
281
-        // invoke OnWebChangePassword event
282
-        if($genpassword == 1) {
283
-            $modx->invokeEvent("OnWebChangePassword", array(
188
+			    include_once "footer.inc.php";
189
+		    }
190
+		    break;
191
+	    case '88' : // edit user
192
+		    // generate a new password for this user
193
+		    if($genpassword == 1) {
194
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+				    if(strlen($specifiedpassword) < 6) {
196
+					    webAlertAndQuit("Password is too short!", 88);
197
+				    } else {
198
+					    $newpassword = $specifiedpassword;
199
+				    }
200
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
+				    webAlertAndQuit("You didn't specify a password for this user!", 88);
202
+			    } elseif($passwordgenmethod == 'g') {
203
+				    $newpassword = generate_password(8);
204
+			    } else {
205
+				    webAlertAndQuit("No password generation method specified!", 88);
206
+			    }
207
+		    }
208
+		    if($passwordnotifymethod == 'e') {
209
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210
+		    }
211
+
212
+		    // check if the username already exist
213
+		    $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
+		    $limit = $modx->getDatabase()->getValue($rs);
215
+		    if($limit > 0) {
216
+			    webAlertAndQuit("User name is already in use!", 88);
217
+		    }
218
+
219
+		    // check if the email address already exists
220
+		    if ($modx->config['allow_multiple_emails'] != 1) {
221
+			    $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
+			    $limit = $modx->getDatabase()->getValue($rs);
223
+			    if($limit > 0) {
224
+				    webAlertAndQuit("Email is already in use!", 88);
225
+			    }
226
+		    }
227
+
228
+		    // invoke OnBeforeWUsrFormSave event
229
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
+			    "mode" => "upd",
231
+			    "id" => $id
232
+		    ));
233
+
234
+		    // update user name and password
235
+		    $field = array();
236
+		    $field['username'] = $esc_newusername;
237
+		    if($genpassword == 1) {
238
+			    $field['password'] = md5($newpassword);
239
+		    }
240
+		    $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'");
241
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
+		    $field = $modx->getDatabase()->escape($field);
243
+		    $modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
+
245
+		    // Save User Settings
246
+            saveWebUserSettings($id);
247
+
248
+		    // Set the item name for logger
249
+		    $_SESSION['itemname'] = $newusername;
250
+
251
+		    /*******************************************************************************/
252
+		    // put the user in the user_groups he/ she should be in
253
+		    // first, check that up_perms are switched on!
254
+		    if($use_udperms == 1) {
255
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
+			    $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'");
257
+			    if(!empty($user_groups)) {
258
+				    for($i = 0; $i < count($user_groups); $i++) {
259
+					    $field = array();
260
+					    $field['webgroup'] = (int)$user_groups[$i];
261
+					    $field['webuser'] = $id;
262
+					    $modx->getDatabase()->insert($field, $tbl_web_groups);
263
+				    }
264
+			    }
265
+		    }
266
+		    // end of user_groups stuff!
267
+		    /*******************************************************************************/
268
+
269
+            // invoke OnWebSaveUser event
270
+            $modx->invokeEvent("OnWebSaveUser", array(
271
+                "mode" => "upd",
284 272
                 "userid" => $id,
285 273
                 "username" => $newusername,
286
-                "userpassword" => $newpassword
274
+                "userpassword" => $newpassword,
275
+                "useremail" => $email,
276
+                "userfullname" => $fullname,
277
+                "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
278
+                "olduseremail" => (($oldemail != $email) ? $oldemail : "")
287 279
             ));
288
-        }
289 280
 
290
-        // invoke OnWUsrFormSave event
291
-        $modx->invokeEvent("OnWUsrFormSave", array(
292
-            "mode" => "upd",
293
-            "id" => $id
294
-        ));
281
+            // invoke OnWebChangePassword event
282
+            if($genpassword == 1) {
283
+                $modx->invokeEvent("OnWebChangePassword", array(
284
+                    "userid" => $id,
285
+                    "username" => $newusername,
286
+                    "userpassword" => $newpassword
287
+                ));
288
+            }
289
+
290
+            // invoke OnWUsrFormSave event
291
+            $modx->invokeEvent("OnWUsrFormSave", array(
292
+                "mode" => "upd",
293
+                "id" => $id
294
+            ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
298
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
-			} else {
301
-				$stayUrl = "index.php?a=99&r=2";
302
-			}
296
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
297
+			    if($input['stay'] != '') {
298
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
+			    } else {
301
+				    $stayUrl = "index.php?a=99&r=2";
302
+			    }
303 303
 
304
-			include_once "header.inc.php";
305
-			?>
304
+			    include_once "header.inc.php";
305
+			    ?>
306 306
 
307 307
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
308 308
 
@@ -322,18 +322,18 @@  discard block
 block discarded – undo
322 322
 			</div>
323 323
 			<?php
324 324
 
325
-			include_once "footer.inc.php";
326
-		} else {
327
-			if($input['stay'] != '') {
328
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
-				header($header);
331
-			} else {
332
-				$header = "Location: index.php?a=99&r=2";
333
-				header($header);
334
-			}
335
-		}
336
-		break;
337
-	default :
338
-		webAlertAndQuit("No operation set in request.", 88);
325
+			    include_once "footer.inc.php";
326
+		    } else {
327
+			    if($input['stay'] != '') {
328
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
+				    header($header);
331
+			    } else {
332
+				    $header = "Location: index.php?a=99&r=2";
333
+				    header($header);
334
+			    }
335
+		    }
336
+		    break;
337
+	    default :
338
+		    webAlertAndQuit("No operation set in request.", 88);
339 339
 }
Please login to merge, or discard this patch.
Indentation   +192 added lines, -192 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_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getDatabase()->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES);
17
-	}
18
-	$input[$k] = $v;
15
+    if($k !== 'comment') {
16
+        $v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES);
17
+    }
18
+    $input[$k] = $v;
19 19
 }
20 20
 
21 21
 $id = (int)$input['id'];
@@ -51,82 +51,82 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched", 88);
54
+    webAlertAndQuit("Password typed is mismatched", 88);
55 55
 }
56 56
 
57 57
 // verify email
58 58
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59
-	webAlertAndQuit("E-mail address doesn't seem to be valid!", 88);
59
+    webAlertAndQuit("E-mail address doesn't seem to be valid!", 88);
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->getDatabase()->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!", 88);
69
-		}
70
-
71
-		// check if the email address already exist
72
-		if ($modx->config['allow_multiple_emails'] != 1) {
73
-			$rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
-			$limit = $modx->getDatabase()->getValue($rs);
75
-			if($limit > 0) {
76
-				webAlertAndQuit("Email is already in use!", 88);
77
-			}
78
-		}
79
-
80
-		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
83
-				webAlertAndQuit("Password is too short!", 88);
84
-			} else {
85
-				$newpassword = $specifiedpassword;
86
-			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
-			webAlertAndQuit("You didn't specify a password for this user!", 88);
89
-		} elseif($passwordgenmethod == 'g') {
90
-			$newpassword = generate_password(8);
91
-		} else {
92
-			webAlertAndQuit("No password generation method specified!", 88);
93
-		}
94
-
95
-		// invoke OnBeforeWUsrFormSave event
96
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
-			"mode" => "new",
98
-		));
99
-
100
-		// create the user account
101
-		$field = array();
102
-		$field['username'] = $esc_newusername;
103
-		$field['password'] = md5($newpassword);
104
-		$internalKey = $modx->getDatabase()->insert($field, $tbl_web_users);
105
-
106
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
-		$field = $modx->getDatabase()->escape($field);
108
-		$modx->getDatabase()->insert($field, $tbl_web_user_attributes);
109
-
110
-		// Save User Settings
63
+    case '87' : // new user
64
+        // check if this user name already exist
65
+        $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+        $limit = $modx->getDatabase()->getValue($rs);
67
+        if($limit > 0) {
68
+            webAlertAndQuit("User name is already in use!", 88);
69
+        }
70
+
71
+        // check if the email address already exist
72
+        if ($modx->config['allow_multiple_emails'] != 1) {
73
+            $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
+            $limit = $modx->getDatabase()->getValue($rs);
75
+            if($limit > 0) {
76
+                webAlertAndQuit("Email is already in use!", 88);
77
+            }
78
+        }
79
+
80
+        // generate a new password for this user
81
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+            if(strlen($specifiedpassword) < 6) {
83
+                webAlertAndQuit("Password is too short!", 88);
84
+            } else {
85
+                $newpassword = $specifiedpassword;
86
+            }
87
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
+            webAlertAndQuit("You didn't specify a password for this user!", 88);
89
+        } elseif($passwordgenmethod == 'g') {
90
+            $newpassword = generate_password(8);
91
+        } else {
92
+            webAlertAndQuit("No password generation method specified!", 88);
93
+        }
94
+
95
+        // invoke OnBeforeWUsrFormSave event
96
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
+            "mode" => "new",
98
+        ));
99
+
100
+        // create the user account
101
+        $field = array();
102
+        $field['username'] = $esc_newusername;
103
+        $field['password'] = md5($newpassword);
104
+        $internalKey = $modx->getDatabase()->insert($field, $tbl_web_users);
105
+
106
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
+        $field = $modx->getDatabase()->escape($field);
108
+        $modx->getDatabase()->insert($field, $tbl_web_user_attributes);
109
+
110
+        // Save User Settings
111 111
         saveWebUserSettings($internalKey);
112 112
 
113
-		// Set the item name for logger
114
-		$_SESSION['itemname'] = $newusername;
115
-
116
-		/*******************************************************************************/
117
-		// put the user in the user_groups he/ she should be in
118
-		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
122
-					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
124
-					$f['webuser'] = $internalKey;
125
-					$modx->getDatabase()->insert($f, $tbl_web_groups);
126
-				}
127
-			}
128
-		}
129
-		// end of user_groups stuff!
113
+        // Set the item name for logger
114
+        $_SESSION['itemname'] = $newusername;
115
+
116
+        /*******************************************************************************/
117
+        // put the user in the user_groups he/ she should be in
118
+        // first, check that up_perms are switched on!
119
+        if($use_udperms == 1) {
120
+            if(!empty($user_groups)) {
121
+                for($i = 0; $i < count($user_groups); $i++) {
122
+                    $f = array();
123
+                    $f['webgroup'] = (int)$user_groups[$i];
124
+                    $f['webuser'] = $internalKey;
125
+                    $modx->getDatabase()->insert($f, $tbl_web_groups);
126
+                }
127
+            }
128
+        }
129
+        // end of user_groups stuff!
130 130
 
131 131
         // invoke OnWebSaveUser event
132 132
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -144,26 +144,26 @@  discard block
 block discarded – undo
144 144
             "id" => $internalKey
145 145
         ));
146 146
 
147
-		if($passwordnotifymethod == 'e') {
147
+        if($passwordnotifymethod == 'e') {
148 148
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
-			if($input['stay'] != '') {
150
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
-				header($header);
153
-			} else {
154
-				$header = "Location: index.php?a=99&r=2";
155
-				header($header);
156
-			}
157
-		} else {
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-			} else {
162
-				$stayUrl = "index.php?a=99&r=2";
163
-			}
164
-
165
-			include_once "header.inc.php";
166
-			?>
149
+            if($input['stay'] != '') {
150
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
+                header($header);
153
+            } else {
154
+                $header = "Location: index.php?a=99&r=2";
155
+                header($header);
156
+            }
157
+        } else {
158
+            if($input['stay'] != '') {
159
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+            } else {
162
+                $stayUrl = "index.php?a=99&r=2";
163
+            }
164
+
165
+            include_once "header.inc.php";
166
+            ?>
167 167
 
168 168
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
169 169
 
@@ -185,86 +185,86 @@  discard block
 block discarded – undo
185 185
 			</div>
186 186
 			<?php
187 187
 
188
-			include_once "footer.inc.php";
189
-		}
190
-		break;
191
-	case '88' : // edit user
192
-		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
196
-					webAlertAndQuit("Password is too short!", 88);
197
-				} else {
198
-					$newpassword = $specifiedpassword;
199
-				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
-				webAlertAndQuit("You didn't specify a password for this user!", 88);
202
-			} elseif($passwordgenmethod == 'g') {
203
-				$newpassword = generate_password(8);
204
-			} else {
205
-				webAlertAndQuit("No password generation method specified!", 88);
206
-			}
207
-		}
208
-		if($passwordnotifymethod == 'e') {
188
+            include_once "footer.inc.php";
189
+        }
190
+        break;
191
+    case '88' : // edit user
192
+        // generate a new password for this user
193
+        if($genpassword == 1) {
194
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+                if(strlen($specifiedpassword) < 6) {
196
+                    webAlertAndQuit("Password is too short!", 88);
197
+                } else {
198
+                    $newpassword = $specifiedpassword;
199
+                }
200
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
+                webAlertAndQuit("You didn't specify a password for this user!", 88);
202
+            } elseif($passwordgenmethod == 'g') {
203
+                $newpassword = generate_password(8);
204
+            } else {
205
+                webAlertAndQuit("No password generation method specified!", 88);
206
+            }
207
+        }
208
+        if($passwordnotifymethod == 'e') {
209 209
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210
-		}
211
-
212
-		// check if the username already exist
213
-		$rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
-		$limit = $modx->getDatabase()->getValue($rs);
215
-		if($limit > 0) {
216
-			webAlertAndQuit("User name is already in use!", 88);
217
-		}
218
-
219
-		// check if the email address already exists
220
-		if ($modx->config['allow_multiple_emails'] != 1) {
221
-			$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
-			$limit = $modx->getDatabase()->getValue($rs);
223
-			if($limit > 0) {
224
-				webAlertAndQuit("Email is already in use!", 88);
225
-			}
226
-		}
227
-
228
-		// invoke OnBeforeWUsrFormSave event
229
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
-			"mode" => "upd",
231
-			"id" => $id
232
-		));
233
-
234
-		// update user name and password
235
-		$field = array();
236
-		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
238
-			$field['password'] = md5($newpassword);
239
-		}
240
-		$modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'");
241
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
-		$field = $modx->getDatabase()->escape($field);
243
-		$modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
-
245
-		// Save User Settings
210
+        }
211
+
212
+        // check if the username already exist
213
+        $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
+        $limit = $modx->getDatabase()->getValue($rs);
215
+        if($limit > 0) {
216
+            webAlertAndQuit("User name is already in use!", 88);
217
+        }
218
+
219
+        // check if the email address already exists
220
+        if ($modx->config['allow_multiple_emails'] != 1) {
221
+            $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
+            $limit = $modx->getDatabase()->getValue($rs);
223
+            if($limit > 0) {
224
+                webAlertAndQuit("Email is already in use!", 88);
225
+            }
226
+        }
227
+
228
+        // invoke OnBeforeWUsrFormSave event
229
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
+            "mode" => "upd",
231
+            "id" => $id
232
+        ));
233
+
234
+        // update user name and password
235
+        $field = array();
236
+        $field['username'] = $esc_newusername;
237
+        if($genpassword == 1) {
238
+            $field['password'] = md5($newpassword);
239
+        }
240
+        $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'");
241
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
+        $field = $modx->getDatabase()->escape($field);
243
+        $modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
+
245
+        // Save User Settings
246 246
         saveWebUserSettings($id);
247 247
 
248
-		// Set the item name for logger
249
-		$_SESSION['itemname'] = $newusername;
250
-
251
-		/*******************************************************************************/
252
-		// put the user in the user_groups he/ she should be in
253
-		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
255
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
-			$modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
259
-					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
261
-					$field['webuser'] = $id;
262
-					$modx->getDatabase()->insert($field, $tbl_web_groups);
263
-				}
264
-			}
265
-		}
266
-		// end of user_groups stuff!
267
-		/*******************************************************************************/
248
+        // Set the item name for logger
249
+        $_SESSION['itemname'] = $newusername;
250
+
251
+        /*******************************************************************************/
252
+        // put the user in the user_groups he/ she should be in
253
+        // first, check that up_perms are switched on!
254
+        if($use_udperms == 1) {
255
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
+            $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'");
257
+            if(!empty($user_groups)) {
258
+                for($i = 0; $i < count($user_groups); $i++) {
259
+                    $field = array();
260
+                    $field['webgroup'] = (int)$user_groups[$i];
261
+                    $field['webuser'] = $id;
262
+                    $modx->getDatabase()->insert($field, $tbl_web_groups);
263
+                }
264
+            }
265
+        }
266
+        // end of user_groups stuff!
267
+        /*******************************************************************************/
268 268
 
269 269
         // invoke OnWebSaveUser event
270 270
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
             "id" => $id
294 294
         ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
298
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
-			} else {
301
-				$stayUrl = "index.php?a=99&r=2";
302
-			}
296
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
297
+            if($input['stay'] != '') {
298
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
+            } else {
301
+                $stayUrl = "index.php?a=99&r=2";
302
+            }
303 303
 
304
-			include_once "header.inc.php";
305
-			?>
304
+            include_once "header.inc.php";
305
+            ?>
306 306
 
307 307
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
308 308
 
@@ -322,18 +322,18 @@  discard block
 block discarded – undo
322 322
 			</div>
323 323
 			<?php
324 324
 
325
-			include_once "footer.inc.php";
326
-		} else {
327
-			if($input['stay'] != '') {
328
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
-				header($header);
331
-			} else {
332
-				$header = "Location: index.php?a=99&r=2";
333
-				header($header);
334
-			}
335
-		}
336
-		break;
337
-	default :
338
-		webAlertAndQuit("No operation set in request.", 88);
325
+            include_once "footer.inc.php";
326
+        } else {
327
+            if($input['stay'] != '') {
328
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
+                header($header);
331
+            } else {
332
+                $header = "Location: index.php?a=99&r=2";
333
+                header($header);
334
+            }
335
+        }
336
+        break;
337
+    default :
338
+        webAlertAndQuit("No operation set in request.", 88);
339 339
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 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_web_user')) {
5
+if (!$modx->hasPermission('save_web_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 $tbl_web_groups = $modx->getDatabase()->getFullTableName('web_groups');
12 12
 
13 13
 $input = $_POST;
14
-foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
14
+foreach ($input as $k => $v) {
15
+	if ($k !== 'comment') {
16 16
 		$v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES);
17 17
 	}
18 18
 	$input[$k] = $v;
19 19
 }
20 20
 
21
-$id = (int)$input['id'];
21
+$id = (int) $input['id'];
22 22
 $oldusername = $input['oldusername'];
23 23
 $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User";
24 24
 $esc_newusername = $modx->getDatabase()->escape($newusername);
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
 $user_groups = $input['user_groups'];
51 51
 
52 52
 // verify password
53
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
53
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54 54
 	webAlertAndQuit("Password typed is mismatched", 88);
55 55
 }
56 56
 
57 57
 // verify email
58
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
58
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59 59
 	webAlertAndQuit("E-mail address doesn't seem to be valid!", 88);
60 60
 }
61 61
 
62
-switch($input['mode']) {
62
+switch ($input['mode']) {
63 63
 	case '87' : // new user
64 64
 		// check if this user name already exist
65 65
 		$rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66 66
 		$limit = $modx->getDatabase()->getValue($rs);
67
-		if($limit > 0) {
67
+		if ($limit > 0) {
68 68
 			webAlertAndQuit("User name is already in use!", 88);
69 69
 		}
70 70
 
@@ -72,21 +72,21 @@  discard block
 block discarded – undo
72 72
 		if ($modx->config['allow_multiple_emails'] != 1) {
73 73
 			$rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74 74
 			$limit = $modx->getDatabase()->getValue($rs);
75
-			if($limit > 0) {
75
+			if ($limit > 0) {
76 76
 				webAlertAndQuit("Email is already in use!", 88);
77 77
 			}
78 78
 		}
79 79
 
80 80
 		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
81
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+			if (strlen($specifiedpassword) < 6) {
83 83
 				webAlertAndQuit("Password is too short!", 88);
84 84
 			} else {
85 85
 				$newpassword = $specifiedpassword;
86 86
 			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
87
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
88 88
 			webAlertAndQuit("You didn't specify a password for this user!", 88);
89
-		} elseif($passwordgenmethod == 'g') {
89
+		} elseif ($passwordgenmethod == 'g') {
90 90
 			$newpassword = generate_password(8);
91 91
 		} else {
92 92
 			webAlertAndQuit("No password generation method specified!", 88);
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 		/*******************************************************************************/
117 117
 		// put the user in the user_groups he/ she should be in
118 118
 		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
119
+		if ($use_udperms == 1) {
120
+			if (!empty($user_groups)) {
121
+				for ($i = 0; $i < count($user_groups); $i++) {
122 122
 					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
123
+					$f['webgroup'] = (int) $user_groups[$i];
124 124
 					$f['webuser'] = $internalKey;
125 125
 					$modx->getDatabase()->insert($f, $tbl_web_groups);
126 126
 				}
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
             "id" => $internalKey
145 145
         ));
146 146
 
147
-		if($passwordnotifymethod == 'e') {
147
+		if ($passwordnotifymethod == 'e') {
148 148
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
-			if($input['stay'] != '') {
149
+			if ($input['stay'] != '') {
150 150
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
151
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
152 152
 				header($header);
153 153
 			} else {
154 154
 				$header = "Location: index.php?a=99&r=2";
155 155
 				header($header);
156 156
 			}
157 157
 		} else {
158
-			if($input['stay'] != '') {
158
+			if ($input['stay'] != '') {
159 159
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
160
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
161 161
 			} else {
162 162
 				$stayUrl = "index.php?a=99&r=2";
163 163
 			}
@@ -190,29 +190,29 @@  discard block
 block discarded – undo
190 190
 		break;
191 191
 	case '88' : // edit user
192 192
 		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
193
+		if ($genpassword == 1) {
194
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+				if (strlen($specifiedpassword) < 6) {
196 196
 					webAlertAndQuit("Password is too short!", 88);
197 197
 				} else {
198 198
 					$newpassword = $specifiedpassword;
199 199
 				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
200
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
201 201
 				webAlertAndQuit("You didn't specify a password for this user!", 88);
202
-			} elseif($passwordgenmethod == 'g') {
202
+			} elseif ($passwordgenmethod == 'g') {
203 203
 				$newpassword = generate_password(8);
204 204
 			} else {
205 205
 				webAlertAndQuit("No password generation method specified!", 88);
206 206
 			}
207 207
 		}
208
-		if($passwordnotifymethod == 'e') {
208
+		if ($passwordnotifymethod == 'e') {
209 209
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210 210
 		}
211 211
 
212 212
 		// check if the username already exist
213 213
 		$rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214 214
 		$limit = $modx->getDatabase()->getValue($rs);
215
-		if($limit > 0) {
215
+		if ($limit > 0) {
216 216
 			webAlertAndQuit("User name is already in use!", 88);
217 217
 		}
218 218
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		if ($modx->config['allow_multiple_emails'] != 1) {
221 221
 			$rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222 222
 			$limit = $modx->getDatabase()->getValue($rs);
223
-			if($limit > 0) {
223
+			if ($limit > 0) {
224 224
 				webAlertAndQuit("Email is already in use!", 88);
225 225
 			}
226 226
 		}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		// update user name and password
235 235
 		$field = array();
236 236
 		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
237
+		if ($genpassword == 1) {
238 238
 			$field['password'] = md5($newpassword);
239 239
 		}
240 240
 		$modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'");
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 		/*******************************************************************************/
252 252
 		// put the user in the user_groups he/ she should be in
253 253
 		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
254
+		if ($use_udperms == 1) {
255 255
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256 256
 			$modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
257
+			if (!empty($user_groups)) {
258
+				for ($i = 0; $i < count($user_groups); $i++) {
259 259
 					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
260
+					$field['webgroup'] = (int) $user_groups[$i];
261 261
 					$field['webuser'] = $id;
262 262
 					$modx->getDatabase()->insert($field, $tbl_web_groups);
263 263
 				}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         ));
280 280
 
281 281
         // invoke OnWebChangePassword event
282
-        if($genpassword == 1) {
282
+        if ($genpassword == 1) {
283 283
             $modx->invokeEvent("OnWebChangePassword", array(
284 284
                 "userid" => $id,
285 285
                 "username" => $newusername,
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
             "id" => $id
294 294
         ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
296
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
297
+			if ($input['stay'] != '') {
298 298
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
299
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
300 300
 			} else {
301 301
 				$stayUrl = "index.php?a=99&r=2";
302 302
 			}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 
325 325
 			include_once "footer.inc.php";
326 326
 		} else {
327
-			if($input['stay'] != '') {
327
+			if ($input['stay'] != '') {
328 328
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
329
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
330 330
 				header($header);
331 331
 			} else {
332 332
 				$header = "Location: index.php?a=99&r=2";
Please login to merge, or discard this patch.