@@ -4,18 +4,18 @@ |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | switch ($modx->manager->action) { |
| 7 | - case 22: |
|
| 8 | - if (!$modx->hasPermission('edit_snippet')) { |
|
| 9 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 10 | - } |
|
| 11 | - break; |
|
| 12 | - case 23: |
|
| 13 | - if (!$modx->hasPermission('new_snippet')) { |
|
| 7 | + case 22: |
|
| 8 | + if (!$modx->hasPermission('edit_snippet')) { |
|
| 9 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 10 | + } |
|
| 11 | + break; |
|
| 12 | + case 23: |
|
| 13 | + if (!$modx->hasPermission('new_snippet')) { |
|
| 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; |
@@ -69,110 +69,110 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | switch($input['mode']) { |
| 72 | - case '11' : // new user |
|
| 73 | - // check if this user name already exist |
|
| 74 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | - $limit = $modx->db->getValue($rs); |
|
| 76 | - if($limit > 0) { |
|
| 77 | - webAlertAndQuit("User name is already in use!"); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // check if the email address already exist |
|
| 81 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | - $limit = $modx->db->getValue($rs); |
|
| 83 | - if($limit > 0) { |
|
| 84 | - webAlertAndQuit("Email is already in use!"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // generate a new password for this user |
|
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 90 | - webAlertAndQuit("Password is too short!"); |
|
| 91 | - } else { |
|
| 92 | - $newpassword = $specifiedpassword; |
|
| 93 | - } |
|
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 97 | - $newpassword = generate_password(8); |
|
| 98 | - } else { |
|
| 99 | - webAlertAndQuit("No password generation method specified!"); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // invoke OnBeforeUserFormSave event |
|
| 103 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | - "mode" => "new", |
|
| 105 | - )); |
|
| 106 | - |
|
| 107 | - // create the user account |
|
| 108 | - $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | - |
|
| 110 | - $field = array(); |
|
| 111 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | - $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | - |
|
| 114 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | - $field = $modx->db->escape($field); |
|
| 116 | - $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | - |
|
| 118 | - // Save user settings |
|
| 119 | - saveUserSettings($internalKey); |
|
| 120 | - |
|
| 121 | - // invoke OnManagerSaveUser event |
|
| 122 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | - "mode" => "new", |
|
| 124 | - "userid" => $internalKey, |
|
| 125 | - "username" => $newusername, |
|
| 126 | - "userpassword" => $newpassword, |
|
| 127 | - "useremail" => $email, |
|
| 128 | - "userfullname" => $fullname, |
|
| 129 | - "userroleid" => $role |
|
| 130 | - )); |
|
| 131 | - |
|
| 132 | - // invoke OnUserFormSave event |
|
| 133 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | - "mode" => "new", |
|
| 135 | - "id" => $internalKey |
|
| 136 | - )); |
|
| 137 | - |
|
| 138 | - // Set the item name for logger |
|
| 139 | - $_SESSION['itemname'] = $newusername; |
|
| 140 | - |
|
| 141 | - /*******************************************************************************/ |
|
| 142 | - // put the user in the user_groups he/ she should be in |
|
| 143 | - // first, check that up_perms are switched on! |
|
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | - $f = array(); |
|
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | - $f['member'] = $internalKey; |
|
| 150 | - $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // end of user_groups stuff! |
|
| 155 | - |
|
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 157 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - header($header); |
|
| 162 | - } else { |
|
| 163 | - $header = "Location: index.php?a=75&r=2"; |
|
| 164 | - header($header); |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if($input['stay'] != '') { |
|
| 168 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | - } else { |
|
| 171 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - include_once "header.inc.php"; |
|
| 175 | - ?> |
|
| 72 | + case '11' : // new user |
|
| 73 | + // check if this user name already exist |
|
| 74 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | + $limit = $modx->db->getValue($rs); |
|
| 76 | + if($limit > 0) { |
|
| 77 | + webAlertAndQuit("User name is already in use!"); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // check if the email address already exist |
|
| 81 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | + $limit = $modx->db->getValue($rs); |
|
| 83 | + if($limit > 0) { |
|
| 84 | + webAlertAndQuit("Email is already in use!"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // generate a new password for this user |
|
| 88 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if(strlen($specifiedpassword) < 6) { |
|
| 90 | + webAlertAndQuit("Password is too short!"); |
|
| 91 | + } else { |
|
| 92 | + $newpassword = $specifiedpassword; |
|
| 93 | + } |
|
| 94 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | + } elseif($passwordgenmethod == 'g') { |
|
| 97 | + $newpassword = generate_password(8); |
|
| 98 | + } else { |
|
| 99 | + webAlertAndQuit("No password generation method specified!"); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // invoke OnBeforeUserFormSave event |
|
| 103 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | + "mode" => "new", |
|
| 105 | + )); |
|
| 106 | + |
|
| 107 | + // create the user account |
|
| 108 | + $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | + |
|
| 110 | + $field = array(); |
|
| 111 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | + $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | + |
|
| 114 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | + $field = $modx->db->escape($field); |
|
| 116 | + $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | + |
|
| 118 | + // Save user settings |
|
| 119 | + saveUserSettings($internalKey); |
|
| 120 | + |
|
| 121 | + // invoke OnManagerSaveUser event |
|
| 122 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | + "mode" => "new", |
|
| 124 | + "userid" => $internalKey, |
|
| 125 | + "username" => $newusername, |
|
| 126 | + "userpassword" => $newpassword, |
|
| 127 | + "useremail" => $email, |
|
| 128 | + "userfullname" => $fullname, |
|
| 129 | + "userroleid" => $role |
|
| 130 | + )); |
|
| 131 | + |
|
| 132 | + // invoke OnUserFormSave event |
|
| 133 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | + "mode" => "new", |
|
| 135 | + "id" => $internalKey |
|
| 136 | + )); |
|
| 137 | + |
|
| 138 | + // Set the item name for logger |
|
| 139 | + $_SESSION['itemname'] = $newusername; |
|
| 140 | + |
|
| 141 | + /*******************************************************************************/ |
|
| 142 | + // put the user in the user_groups he/ she should be in |
|
| 143 | + // first, check that up_perms are switched on! |
|
| 144 | + if($use_udperms == 1) { |
|
| 145 | + if(!empty($user_groups)) { |
|
| 146 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | + $f = array(); |
|
| 148 | + $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | + $f['member'] = $internalKey; |
|
| 150 | + $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // end of user_groups stuff! |
|
| 155 | + |
|
| 156 | + if($passwordnotifymethod == 'e') { |
|
| 157 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + header($header); |
|
| 162 | + } else { |
|
| 163 | + $header = "Location: index.php?a=75&r=2"; |
|
| 164 | + header($header); |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if($input['stay'] != '') { |
|
| 168 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | + } else { |
|
| 171 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + include_once "header.inc.php"; |
|
| 175 | + ?> |
|
| 176 | 176 | |
| 177 | 177 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 178 | 178 | |
@@ -194,125 +194,125 @@ discard block |
||
| 194 | 194 | </div> |
| 195 | 195 | <?php |
| 196 | 196 | |
| 197 | - include_once "footer.inc.php"; |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - case '12' : // edit user |
|
| 201 | - // generate a new password for this user |
|
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 205 | - webAlertAndQuit("Password is too short!"); |
|
| 206 | - } else { |
|
| 207 | - $newpassword = $specifiedpassword; |
|
| 208 | - } |
|
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 212 | - $newpassword = generate_password(8); |
|
| 213 | - } else { |
|
| 214 | - webAlertAndQuit("No password generation method specified!"); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 218 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // check if the username already exist |
|
| 222 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | - $limit = $modx->db->getValue($rs); |
|
| 224 | - if($limit > 0) { |
|
| 225 | - webAlertAndQuit("User name is already in use!"); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // check if the email address already exists |
|
| 229 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | - $limit = $modx->db->getValue($rs); |
|
| 231 | - if($limit > 0) { |
|
| 232 | - webAlertAndQuit("Email is already in use!"); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // invoke OnBeforeUserFormSave event |
|
| 236 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | - "mode" => "upd", |
|
| 238 | - "id" => $id |
|
| 239 | - )); |
|
| 240 | - |
|
| 241 | - // update user name and password |
|
| 242 | - $field = array(); |
|
| 243 | - $field['username'] = $modx->db->escape($newusername); |
|
| 244 | - if($genpassword == 1) { |
|
| 245 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | - } |
|
| 247 | - $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | - $field = $modx->db->escape($field); |
|
| 250 | - $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | - |
|
| 252 | - // Save user settings |
|
| 253 | - saveUserSettings($id); |
|
| 254 | - |
|
| 255 | - // Set the item name for logger |
|
| 256 | - $_SESSION['itemname'] = $newusername; |
|
| 257 | - |
|
| 258 | - // invoke OnManagerSaveUser event |
|
| 259 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | - "mode" => "upd", |
|
| 261 | - "userid" => $id, |
|
| 262 | - "username" => $newusername, |
|
| 263 | - "userpassword" => $newpassword, |
|
| 264 | - "useremail" => $email, |
|
| 265 | - "userfullname" => $fullname, |
|
| 266 | - "userroleid" => $role, |
|
| 267 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | - )); |
|
| 270 | - |
|
| 271 | - // invoke OnManagerChangePassword event |
|
| 272 | - if($genpassword == 1) { |
|
| 273 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | - "userid" => $id, |
|
| 275 | - "username" => $newusername, |
|
| 276 | - "userpassword" => $newpassword |
|
| 277 | - )); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // invoke OnUserFormSave event |
|
| 281 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | - "mode" => "upd", |
|
| 283 | - "id" => $id |
|
| 284 | - )); |
|
| 285 | - |
|
| 286 | - /*******************************************************************************/ |
|
| 287 | - // put the user in the user_groups he/ she should be in |
|
| 288 | - // first, check that up_perms are switched on! |
|
| 289 | - if($use_udperms == 1) { |
|
| 290 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | - $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | - $field = array(); |
|
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | - $field['member'] = $id; |
|
| 297 | - $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - // end of user_groups stuff! |
|
| 302 | - /*******************************************************************************/ |
|
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | - } |
|
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 308 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | - } else { |
|
| 311 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - include_once "header.inc.php"; |
|
| 315 | - ?> |
|
| 197 | + include_once "footer.inc.php"; |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + case '12' : // edit user |
|
| 201 | + // generate a new password for this user |
|
| 202 | + if($genpassword == 1) { |
|
| 203 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if(strlen($specifiedpassword) < 6) { |
|
| 205 | + webAlertAndQuit("Password is too short!"); |
|
| 206 | + } else { |
|
| 207 | + $newpassword = $specifiedpassword; |
|
| 208 | + } |
|
| 209 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | + } elseif($passwordgenmethod == 'g') { |
|
| 212 | + $newpassword = generate_password(8); |
|
| 213 | + } else { |
|
| 214 | + webAlertAndQuit("No password generation method specified!"); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + if($passwordnotifymethod == 'e') { |
|
| 218 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // check if the username already exist |
|
| 222 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | + $limit = $modx->db->getValue($rs); |
|
| 224 | + if($limit > 0) { |
|
| 225 | + webAlertAndQuit("User name is already in use!"); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // check if the email address already exists |
|
| 229 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | + $limit = $modx->db->getValue($rs); |
|
| 231 | + if($limit > 0) { |
|
| 232 | + webAlertAndQuit("Email is already in use!"); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // invoke OnBeforeUserFormSave event |
|
| 236 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | + "mode" => "upd", |
|
| 238 | + "id" => $id |
|
| 239 | + )); |
|
| 240 | + |
|
| 241 | + // update user name and password |
|
| 242 | + $field = array(); |
|
| 243 | + $field['username'] = $modx->db->escape($newusername); |
|
| 244 | + if($genpassword == 1) { |
|
| 245 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | + } |
|
| 247 | + $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | + $field = $modx->db->escape($field); |
|
| 250 | + $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | + |
|
| 252 | + // Save user settings |
|
| 253 | + saveUserSettings($id); |
|
| 254 | + |
|
| 255 | + // Set the item name for logger |
|
| 256 | + $_SESSION['itemname'] = $newusername; |
|
| 257 | + |
|
| 258 | + // invoke OnManagerSaveUser event |
|
| 259 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | + "mode" => "upd", |
|
| 261 | + "userid" => $id, |
|
| 262 | + "username" => $newusername, |
|
| 263 | + "userpassword" => $newpassword, |
|
| 264 | + "useremail" => $email, |
|
| 265 | + "userfullname" => $fullname, |
|
| 266 | + "userroleid" => $role, |
|
| 267 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | + )); |
|
| 270 | + |
|
| 271 | + // invoke OnManagerChangePassword event |
|
| 272 | + if($genpassword == 1) { |
|
| 273 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | + "userid" => $id, |
|
| 275 | + "username" => $newusername, |
|
| 276 | + "userpassword" => $newpassword |
|
| 277 | + )); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // invoke OnUserFormSave event |
|
| 281 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | + "mode" => "upd", |
|
| 283 | + "id" => $id |
|
| 284 | + )); |
|
| 285 | + |
|
| 286 | + /*******************************************************************************/ |
|
| 287 | + // put the user in the user_groups he/ she should be in |
|
| 288 | + // first, check that up_perms are switched on! |
|
| 289 | + if($use_udperms == 1) { |
|
| 290 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | + $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | + if(!empty($user_groups)) { |
|
| 293 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | + $field = array(); |
|
| 295 | + $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -33,115 +33,115 @@ |
||
| 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->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | - $count = $modx->db->getValue($rs); |
|
| 47 | - if ($count > 0) { |
|
| 48 | - $modx->manager->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->db->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->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->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | - $count = $modx->db->getValue($rs); |
|
| 100 | - if ($count > 0) { |
|
| 101 | - $modx->manager->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->db->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->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->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | + $count = $modx->db->getValue($rs); |
|
| 47 | + if ($count > 0) { |
|
| 48 | + $modx->manager->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->db->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->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->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | + $count = $modx->db->getValue($rs); |
|
| 100 | + if ($count > 0) { |
|
| 101 | + $modx->manager->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->db->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->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 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -60,108 +60,108 @@ discard block |
||
| 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->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | - $limit = $modx->db->getValue($rs); |
|
| 74 | - if($limit > 0) { |
|
| 75 | - webAlertAndQuit("Email is already in use!"); |
|
| 76 | - } |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | + $limit = $modx->db->getValue($rs); |
|
| 74 | + if($limit > 0) { |
|
| 75 | + webAlertAndQuit("Email is already in use!"); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // generate a new password for this user |
|
| 79 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | + if(strlen($specifiedpassword) < 6) { |
|
| 81 | + webAlertAndQuit("Password is too short!"); |
|
| 82 | + } else { |
|
| 83 | + $newpassword = $specifiedpassword; |
|
| 84 | + } |
|
| 85 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | + } elseif($passwordgenmethod == 'g') { |
|
| 88 | + $newpassword = generate_password(8); |
|
| 89 | + } else { |
|
| 90 | + webAlertAndQuit("No password generation method specified!"); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // invoke OnBeforeWUsrFormSave event |
|
| 94 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | + "mode" => "new", |
|
| 96 | + )); |
|
| 97 | + |
|
| 98 | + // create the user account |
|
| 99 | + $field = array(); |
|
| 100 | + $field['username'] = $esc_newusername; |
|
| 101 | + $field['password'] = md5($newpassword); |
|
| 102 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | + |
|
| 104 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | + $field = $modx->db->escape($field); |
|
| 106 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | + |
|
| 108 | + // Save User Settings |
|
| 109 | + saveUserSettings($internalKey); |
|
| 110 | + |
|
| 111 | + // Set the item name for logger |
|
| 112 | + $_SESSION['itemname'] = $newusername; |
|
| 113 | + |
|
| 114 | + /*******************************************************************************/ |
|
| 115 | + // put the user in the user_groups he/ she should be in |
|
| 116 | + // first, check that up_perms are switched on! |
|
| 117 | + if($use_udperms == 1) { |
|
| 118 | + if(!empty($user_groups)) { |
|
| 119 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | + $f = array(); |
|
| 121 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 122 | + $f['webuser'] = $internalKey; |
|
| 123 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + // end of user_groups stuff! |
|
| 128 | + |
|
| 129 | + // invoke OnWebSaveUser event |
|
| 130 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 131 | + "mode" => "new", |
|
| 132 | + "userid" => $internalKey, |
|
| 133 | + "username" => $newusername, |
|
| 134 | + "userpassword" => $newpassword, |
|
| 135 | + "useremail" => $email, |
|
| 136 | + "userfullname" => $fullname |
|
| 137 | + )); |
|
| 77 | 138 | |
| 78 | - // generate a new password for this user |
|
| 79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | - webAlertAndQuit("Password is too short!"); |
|
| 82 | - } else { |
|
| 83 | - $newpassword = $specifiedpassword; |
|
| 84 | - } |
|
| 85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | - } elseif($passwordgenmethod == 'g') { |
|
| 88 | - $newpassword = generate_password(8); |
|
| 89 | - } else { |
|
| 90 | - webAlertAndQuit("No password generation method specified!"); |
|
| 91 | - } |
|
| 139 | + // invoke OnWUsrFormSave event |
|
| 140 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 141 | + "mode" => "new", |
|
| 142 | + "id" => $internalKey |
|
| 143 | + )); |
|
| 92 | 144 | |
| 93 | - // invoke OnBeforeWUsrFormSave event |
|
| 94 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | - "mode" => "new", |
|
| 96 | - )); |
|
| 97 | - |
|
| 98 | - // create the user account |
|
| 99 | - $field = array(); |
|
| 100 | - $field['username'] = $esc_newusername; |
|
| 101 | - $field['password'] = md5($newpassword); |
|
| 102 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | - |
|
| 104 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | - $field = $modx->db->escape($field); |
|
| 106 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | - |
|
| 108 | - // Save User Settings |
|
| 109 | - saveUserSettings($internalKey); |
|
| 110 | - |
|
| 111 | - // Set the item name for logger |
|
| 112 | - $_SESSION['itemname'] = $newusername; |
|
| 113 | - |
|
| 114 | - /*******************************************************************************/ |
|
| 115 | - // put the user in the user_groups he/ she should be in |
|
| 116 | - // first, check that up_perms are switched on! |
|
| 117 | - if($use_udperms == 1) { |
|
| 118 | - if(!empty($user_groups)) { |
|
| 119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | - $f = array(); |
|
| 121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 122 | - $f['webuser'] = $internalKey; |
|
| 123 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - // end of user_groups stuff! |
|
| 128 | - |
|
| 129 | - // invoke OnWebSaveUser event |
|
| 130 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 131 | - "mode" => "new", |
|
| 132 | - "userid" => $internalKey, |
|
| 133 | - "username" => $newusername, |
|
| 134 | - "userpassword" => $newpassword, |
|
| 135 | - "useremail" => $email, |
|
| 136 | - "userfullname" => $fullname |
|
| 137 | - )); |
|
| 138 | - |
|
| 139 | - // invoke OnWUsrFormSave event |
|
| 140 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 141 | - "mode" => "new", |
|
| 142 | - "id" => $internalKey |
|
| 143 | - )); |
|
| 144 | - |
|
| 145 | - if($passwordnotifymethod == 'e') { |
|
| 146 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | - if($input['stay'] != '') { |
|
| 148 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | - header($header); |
|
| 151 | - } else { |
|
| 152 | - $header = "Location: index.php?a=99&r=2"; |
|
| 153 | - header($header); |
|
| 154 | - } |
|
| 155 | - } else { |
|
| 156 | - if($input['stay'] != '') { |
|
| 157 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | - } else { |
|
| 160 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - include_once "header.inc.php"; |
|
| 164 | - ?> |
|
| 145 | + if($passwordnotifymethod == 'e') { |
|
| 146 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | + if($input['stay'] != '') { |
|
| 148 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | + header($header); |
|
| 151 | + } else { |
|
| 152 | + $header = "Location: index.php?a=99&r=2"; |
|
| 153 | + header($header); |
|
| 154 | + } |
|
| 155 | + } else { |
|
| 156 | + if($input['stay'] != '') { |
|
| 157 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | + } else { |
|
| 160 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + include_once "header.inc.php"; |
|
| 164 | + ?> |
|
| 165 | 165 | |
| 166 | 166 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 167 | 167 | |
@@ -183,122 +183,122 @@ discard block |
||
| 183 | 183 | </div> |
| 184 | 184 | <?php |
| 185 | 185 | |
| 186 | - include_once "footer.inc.php"; |
|
| 187 | - } |
|
| 188 | - break; |
|
| 189 | - case '88' : // edit user |
|
| 190 | - // generate a new password for this user |
|
| 191 | - if($genpassword == 1) { |
|
| 192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | - if(strlen($specifiedpassword) < 6) { |
|
| 194 | - webAlertAndQuit("Password is too short!"); |
|
| 195 | - } else { |
|
| 196 | - $newpassword = $specifiedpassword; |
|
| 197 | - } |
|
| 198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | - } elseif($passwordgenmethod == 'g') { |
|
| 201 | - $newpassword = generate_password(8); |
|
| 202 | - } else { |
|
| 203 | - webAlertAndQuit("No password generation method specified!"); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - if($passwordnotifymethod == 'e') { |
|
| 207 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // check if the username already exist |
|
| 211 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | - $limit = $modx->db->getValue($rs); |
|
| 213 | - if($limit > 0) { |
|
| 214 | - webAlertAndQuit("User name is already in use!"); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // check if the email address already exists |
|
| 218 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | - $limit = $modx->db->getValue($rs); |
|
| 220 | - if($limit > 0) { |
|
| 221 | - webAlertAndQuit("Email is already in use!"); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // invoke OnBeforeWUsrFormSave event |
|
| 225 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | - "mode" => "upd", |
|
| 227 | - "id" => $id |
|
| 228 | - )); |
|
| 229 | - |
|
| 230 | - // update user name and password |
|
| 231 | - $field = array(); |
|
| 232 | - $field['username'] = $esc_newusername; |
|
| 233 | - if($genpassword == 1) { |
|
| 234 | - $field['password'] = md5($newpassword); |
|
| 235 | - } |
|
| 236 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | - $field = $modx->db->escape($field); |
|
| 239 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | - |
|
| 241 | - // Save User Settings |
|
| 242 | - saveUserSettings($id); |
|
| 243 | - |
|
| 244 | - // Set the item name for logger |
|
| 245 | - $_SESSION['itemname'] = $newusername; |
|
| 246 | - |
|
| 247 | - /*******************************************************************************/ |
|
| 248 | - // put the user in the user_groups he/ she should be in |
|
| 249 | - // first, check that up_perms are switched on! |
|
| 250 | - if($use_udperms == 1) { |
|
| 251 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | - if(!empty($user_groups)) { |
|
| 254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | - $field = array(); |
|
| 256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 257 | - $field['webuser'] = $id; |
|
| 258 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - // end of user_groups stuff! |
|
| 263 | - /*******************************************************************************/ |
|
| 264 | - |
|
| 265 | - // invoke OnWebSaveUser event |
|
| 266 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 267 | - "mode" => "upd", |
|
| 268 | - "userid" => $id, |
|
| 269 | - "username" => $newusername, |
|
| 270 | - "userpassword" => $newpassword, |
|
| 271 | - "useremail" => $email, |
|
| 272 | - "userfullname" => $fullname, |
|
| 273 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 274 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 275 | - )); |
|
| 276 | - |
|
| 277 | - // invoke OnWebChangePassword event |
|
| 278 | - if($genpassword == 1) { |
|
| 279 | - $modx->invokeEvent("OnWebChangePassword", array( |
|
| 186 | + include_once "footer.inc.php"; |
|
| 187 | + } |
|
| 188 | + break; |
|
| 189 | + case '88' : // edit user |
|
| 190 | + // generate a new password for this user |
|
| 191 | + if($genpassword == 1) { |
|
| 192 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | + if(strlen($specifiedpassword) < 6) { |
|
| 194 | + webAlertAndQuit("Password is too short!"); |
|
| 195 | + } else { |
|
| 196 | + $newpassword = $specifiedpassword; |
|
| 197 | + } |
|
| 198 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | + } elseif($passwordgenmethod == 'g') { |
|
| 201 | + $newpassword = generate_password(8); |
|
| 202 | + } else { |
|
| 203 | + webAlertAndQuit("No password generation method specified!"); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + if($passwordnotifymethod == 'e') { |
|
| 207 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // check if the username already exist |
|
| 211 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | + $limit = $modx->db->getValue($rs); |
|
| 213 | + if($limit > 0) { |
|
| 214 | + webAlertAndQuit("User name is already in use!"); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // check if the email address already exists |
|
| 218 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | + $limit = $modx->db->getValue($rs); |
|
| 220 | + if($limit > 0) { |
|
| 221 | + webAlertAndQuit("Email is already in use!"); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // invoke OnBeforeWUsrFormSave event |
|
| 225 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | + "mode" => "upd", |
|
| 227 | + "id" => $id |
|
| 228 | + )); |
|
| 229 | + |
|
| 230 | + // update user name and password |
|
| 231 | + $field = array(); |
|
| 232 | + $field['username'] = $esc_newusername; |
|
| 233 | + if($genpassword == 1) { |
|
| 234 | + $field['password'] = md5($newpassword); |
|
| 235 | + } |
|
| 236 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | + $field = $modx->db->escape($field); |
|
| 239 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | + |
|
| 241 | + // Save User Settings |
|
| 242 | + saveUserSettings($id); |
|
| 243 | + |
|
| 244 | + // Set the item name for logger |
|
| 245 | + $_SESSION['itemname'] = $newusername; |
|
| 246 | + |
|
| 247 | + /*******************************************************************************/ |
|
| 248 | + // put the user in the user_groups he/ she should be in |
|
| 249 | + // first, check that up_perms are switched on! |
|
| 250 | + if($use_udperms == 1) { |
|
| 251 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | + if(!empty($user_groups)) { |
|
| 254 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | + $field = array(); |
|
| 256 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 257 | + $field['webuser'] = $id; |
|
| 258 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + // end of user_groups stuff! |
|
| 263 | + /*******************************************************************************/ |
|
| 264 | + |
|
| 265 | + // invoke OnWebSaveUser event |
|
| 266 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 267 | + "mode" => "upd", |
|
| 280 | 268 | "userid" => $id, |
| 281 | 269 | "username" => $newusername, |
| 282 | - "userpassword" => $newpassword |
|
| 270 | + "userpassword" => $newpassword, |
|
| 271 | + "useremail" => $email, |
|
| 272 | + "userfullname" => $fullname, |
|
| 273 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 274 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 283 | 275 | )); |
| 284 | - } |
|
| 285 | 276 | |
| 286 | - // invoke OnWUsrFormSave event |
|
| 287 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 288 | - "mode" => "upd", |
|
| 289 | - "id" => $id |
|
| 290 | - )); |
|
| 277 | + // invoke OnWebChangePassword event |
|
| 278 | + if($genpassword == 1) { |
|
| 279 | + $modx->invokeEvent("OnWebChangePassword", array( |
|
| 280 | + "userid" => $id, |
|
| 281 | + "username" => $newusername, |
|
| 282 | + "userpassword" => $newpassword |
|
| 283 | + )); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + // invoke OnWUsrFormSave event |
|
| 287 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 288 | + "mode" => "upd", |
|
| 289 | + "id" => $id |
|
| 290 | + )); |
|
| 291 | 291 | |
| 292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | - if($input['stay'] != '') { |
|
| 294 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | - } else { |
|
| 297 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | - } |
|
| 292 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | + if($input['stay'] != '') { |
|
| 294 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | + } else { |
|
| 297 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - include_once "header.inc.php"; |
|
| 301 | - ?> |
|
| 300 | + include_once "header.inc.php"; |
|
| 301 | + ?> |
|
| 302 | 302 | |
| 303 | 303 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 304 | 304 | |
@@ -318,20 +318,20 @@ discard block |
||
| 318 | 318 | </div> |
| 319 | 319 | <?php |
| 320 | 320 | |
| 321 | - include_once "footer.inc.php"; |
|
| 322 | - } else { |
|
| 323 | - if($input['stay'] != '') { |
|
| 324 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | - header($header); |
|
| 327 | - } else { |
|
| 328 | - $header = "Location: index.php?a=99&r=2"; |
|
| 329 | - header($header); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - break; |
|
| 333 | - default : |
|
| 334 | - webAlertAndQuit("No operation set in request."); |
|
| 321 | + include_once "footer.inc.php"; |
|
| 322 | + } else { |
|
| 323 | + if($input['stay'] != '') { |
|
| 324 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | + header($header); |
|
| 327 | + } else { |
|
| 328 | + $header = "Location: index.php?a=99&r=2"; |
|
| 329 | + header($header); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + break; |
|
| 333 | + default : |
|
| 334 | + webAlertAndQuit("No operation set in request."); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -59,125 +59,125 @@ |
||
| 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->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | - $count = $modx->db->getValue($rs); |
|
| 72 | - if ($count > 0) { |
|
| 73 | - $modx->manager->saveFormValues(107); |
|
| 74 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | - } |
|
| 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->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | + $count = $modx->db->getValue($rs); |
|
| 72 | + if ($count > 0) { |
|
| 73 | + $modx->manager->saveFormValues(107); |
|
| 74 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - // save the new module |
|
| 78 | - $newid = $modx->db->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->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | - if ($modx->db->getValue($rs) > 0) { |
|
| 131 | - $modx->manager->saveFormValues(108); |
|
| 132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | - } |
|
| 77 | + // save the new module |
|
| 78 | + $newid = $modx->db->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->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | + if ($modx->db->getValue($rs) > 0) { |
|
| 131 | + $modx->manager->saveFormValues(108); |
|
| 132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - // save the edited module |
|
| 136 | - $modx->db->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."); |
|
| 135 | + // save the edited module |
|
| 136 | + $modx->db->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 | } |
| 182 | 182 | |
| 183 | 183 | /** |