Completed
Push — develop ( cb7ecf...5e631f )
by Dmytro
17s
created
manager/processors/save_module.processor.php 1 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->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->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->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->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->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->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->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->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_content.processor.php 1 patch
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -279,19 +279,19 @@
 block discarded – undo
279 279
             // invoke OnBeforeDocFormSave event
280 280
             switch($modx->config['docid_incrmnt_method'])
281 281
             {
282
-            case '1':
283
-                $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id";
284
-                $where = "T1.id IS NULL";
285
-                $rs = $modx->getDatabase()->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
286
-                $id = $modx->getDatabase()->getValue($rs);
282
+                case '1':
283
+                    $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id";
284
+                    $where = "T1.id IS NULL";
285
+                    $rs = $modx->getDatabase()->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
286
+                    $id = $modx->getDatabase()->getValue($rs);
287
+                    break;
288
+                case '2':
289
+                    $rs = $modx->getDatabase()->select('MAX(id)+1', $tbl_site_content);
290
+                    $id = $modx->getDatabase()->getValue($rs);
287 291
                 break;
288
-            case '2':
289
-                $rs = $modx->getDatabase()->select('MAX(id)+1', $tbl_site_content);
290
-                $id = $modx->getDatabase()->getValue($rs);
291
-            break;
292 292
 
293
-            default:
294
-                $id = '';
293
+                default:
294
+                    $id = '';
295 295
             }
296 296
 
297 297
         $modx->invokeEvent("OnBeforeDocFormSave", array(
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
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.
manager/processors/save_snippet.processor.php 1 patch
Switch Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -66,111 +66,111 @@
 block discarded – undo
66 66
 }
67 67
 
68 68
 switch ($_POST['mode']) {
69
-    case '23': // Save new snippet
70
-
71
-        // invoke OnBeforeSnipFormSave event
72
-        $modx->invokeEvent("OnBeforeSnipFormSave", array(
73
-            "mode" => "new",
74
-            "id" => $id
75
-        ));
76
-
77
-        // disallow duplicate names for new snippets
78
-        $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
79
-        $count = $modx->getDatabase()->getValue($rs);
80
-        if ($count > 0) {
81
-            $modx->getManagerApi()->saveFormValues(23);
82
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23");
83
-        }
84
-
85
-        //do stuff to save the new doc
86
-        $newid = $modx->getDatabase()->insert(array(
87
-            'name' => $name,
88
-            'description' => $description,
89
-            'snippet' => $snippet,
90
-            'moduleguid' => $moduleguid,
91
-            'locked' => $locked,
92
-            'properties' => $properties,
93
-            'category' => $categoryid,
94
-            'disabled' => $disabled,
95
-            'createdon' => $currentdate,
96
-            'editedon' => $currentdate
97
-        ), $modx->getFullTableName('site_snippets'));
98
-
99
-        // invoke OnSnipFormSave event
100
-        $modx->invokeEvent("OnSnipFormSave", 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') ? "22&id=$newid" : "23";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=76&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '22': // Save existing snippet
122
-        // invoke OnBeforeSnipFormSave event
123
-        $modx->invokeEvent("OnBeforeSnipFormSave", array(
124
-            "mode" => "upd",
125
-            "id" => $id
126
-        ));
127
-
128
-        // disallow duplicate names for snippets
129
-        $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->getDatabase()->getValue($rs) > 0) {
131
-            $modx->getManagerApi()->saveFormValues(22);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}");
133
-        }
134
-
135
-        //do stuff to save the edited doc
136
-        $modx->getDatabase()->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'snippet' => $snippet,
140
-            'moduleguid' => $moduleguid,
141
-            'locked' => $locked,
142
-            'properties' => $properties,
143
-            'category' => $categoryid,
144
-            'disabled' => $disabled,
145
-            'editedon' => $currentdate
146
-        ), $modx->getFullTableName('site_snippets'), "id='{$id}'");
147
-
148
-        // invoke OnSnipFormSave event
149
-        $modx->invokeEvent("OnSnipFormSave", array(
150
-            "mode" => "upd",
151
-            "id" => $id
152
-        ));
153
-
154
-        // Set the item name for logger
155
-        $_SESSION['itemname'] = $name;
156
-
157
-        // empty cache
158
-        $modx->clearCache('full');
159
-
160
-        if ($_POST['runsnippet']) {
161
-            run_snippet($snippet);
162
-        }
163
-        // finished emptying cache - redirect
164
-        if ($_POST['stay'] != '') {
165
-            $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
167
-            header($header);
168
-        } else {
169
-            $modx->unlockElement(4, $id);
170
-            $header = "Location: index.php?a=76&r=2";
171
-            header($header);
172
-        }
173
-        break;
174
-    default:
175
-        $modx->webAlertAndQuit("No operation set in request.");
69
+        case '23': // Save new snippet
70
+
71
+            // invoke OnBeforeSnipFormSave event
72
+            $modx->invokeEvent("OnBeforeSnipFormSave", array(
73
+                "mode" => "new",
74
+                "id" => $id
75
+            ));
76
+
77
+            // disallow duplicate names for new snippets
78
+            $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
79
+            $count = $modx->getDatabase()->getValue($rs);
80
+            if ($count > 0) {
81
+                $modx->getManagerApi()->saveFormValues(23);
82
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23");
83
+            }
84
+
85
+            //do stuff to save the new doc
86
+            $newid = $modx->getDatabase()->insert(array(
87
+                'name' => $name,
88
+                'description' => $description,
89
+                'snippet' => $snippet,
90
+                'moduleguid' => $moduleguid,
91
+                'locked' => $locked,
92
+                'properties' => $properties,
93
+                'category' => $categoryid,
94
+                'disabled' => $disabled,
95
+                'createdon' => $currentdate,
96
+                'editedon' => $currentdate
97
+            ), $modx->getFullTableName('site_snippets'));
98
+
99
+            // invoke OnSnipFormSave event
100
+            $modx->invokeEvent("OnSnipFormSave", 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') ? "22&id=$newid" : "23";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=76&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '22': // Save existing snippet
122
+            // invoke OnBeforeSnipFormSave event
123
+            $modx->invokeEvent("OnBeforeSnipFormSave", array(
124
+                "mode" => "upd",
125
+                "id" => $id
126
+            ));
127
+
128
+            // disallow duplicate names for snippets
129
+            $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->getDatabase()->getValue($rs) > 0) {
131
+                $modx->getManagerApi()->saveFormValues(22);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}");
133
+            }
134
+
135
+            //do stuff to save the edited doc
136
+            $modx->getDatabase()->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'snippet' => $snippet,
140
+                'moduleguid' => $moduleguid,
141
+                'locked' => $locked,
142
+                'properties' => $properties,
143
+                'category' => $categoryid,
144
+                'disabled' => $disabled,
145
+                'editedon' => $currentdate
146
+            ), $modx->getFullTableName('site_snippets'), "id='{$id}'");
147
+
148
+            // invoke OnSnipFormSave event
149
+            $modx->invokeEvent("OnSnipFormSave", array(
150
+                "mode" => "upd",
151
+                "id" => $id
152
+            ));
153
+
154
+            // Set the item name for logger
155
+            $_SESSION['itemname'] = $name;
156
+
157
+            // empty cache
158
+            $modx->clearCache('full');
159
+
160
+            if ($_POST['runsnippet']) {
161
+                run_snippet($snippet);
162
+            }
163
+            // finished emptying cache - redirect
164
+            if ($_POST['stay'] != '') {
165
+                $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
167
+                header($header);
168
+            } else {
169
+                $modx->unlockElement(4, $id);
170
+                $header = "Location: index.php?a=76&r=2";
171
+                header($header);
172
+            }
173
+            break;
174
+        default:
175
+            $modx->webAlertAndQuit("No operation set in request.");
176 176
 }
Please login to merge, or discard this patch.