@@ -60,110 +60,110 @@ 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->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 |
||
| 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 |
||
| 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 | } |
@@ -59,123 +59,123 @@ |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | switch ($_POST['mode']) { |
| 62 | - case '107': |
|
| 63 | - // invoke OnBeforeModFormSave event |
|
| 64 | - $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 65 | - "mode" => "new", |
|
| 66 | - "id" => $id |
|
| 67 | - )); |
|
| 68 | - |
|
| 69 | - // disallow duplicate names for new modules |
|
| 70 | - $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 72 | - if ($count > 0) { |
|
| 73 | - $modx->getManagerApi()->saveFormValues(107); |
|
| 74 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // save the new module |
|
| 78 | - $newid = $modx->getDatabase()->insert(array( |
|
| 79 | - 'name' => $name, |
|
| 80 | - 'description' => $description, |
|
| 81 | - 'disabled' => $disabled, |
|
| 82 | - 'wrap' => $wrap, |
|
| 83 | - 'locked' => $locked, |
|
| 84 | - 'icon' => $icon, |
|
| 85 | - 'resourcefile' => $resourcefile, |
|
| 86 | - 'enable_resource' => $enable_resource, |
|
| 87 | - 'category' => $categoryid, |
|
| 88 | - 'enable_sharedparams' => $enable_sharedparams, |
|
| 89 | - 'guid' => $guid, |
|
| 90 | - 'modulecode' => $modulecode, |
|
| 91 | - 'properties' => $properties, |
|
| 92 | - 'createdon' => $currentdate, |
|
| 93 | - 'editedon' => $currentdate |
|
| 94 | - ), $modx->getDatabase()->getFullTableName('site_modules')); |
|
| 95 | - |
|
| 96 | - // save user group access permissions |
|
| 97 | - saveUserGroupAccessPermissons(); |
|
| 98 | - |
|
| 99 | - // invoke OnModFormSave event |
|
| 100 | - $modx->invokeEvent("OnModFormSave", array( |
|
| 101 | - "mode" => "new", |
|
| 102 | - "id" => $newid |
|
| 103 | - )); |
|
| 104 | - |
|
| 105 | - // Set the item name for logger |
|
| 106 | - $_SESSION['itemname'] = $name; |
|
| 107 | - |
|
| 108 | - // empty cache |
|
| 109 | - $modx->clearCache('full'); |
|
| 110 | - |
|
| 111 | - // finished emptying cache - redirect |
|
| 112 | - if ($_POST['stay'] != '') { |
|
| 113 | - $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
|
| 114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 115 | - header($header); |
|
| 116 | - } else { |
|
| 117 | - $header = "Location: index.php?a=106&r=2"; |
|
| 118 | - header($header); |
|
| 119 | - } |
|
| 120 | - break; |
|
| 121 | - case '108': |
|
| 122 | - // invoke OnBeforeModFormSave event |
|
| 123 | - $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 124 | - "mode" => "upd", |
|
| 125 | - "id" => $id |
|
| 126 | - )); |
|
| 127 | - |
|
| 128 | - // disallow duplicate names for new modules |
|
| 129 | - $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | - if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 131 | - $modx->getManagerApi()->saveFormValues(108); |
|
| 132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // save the edited module |
|
| 136 | - $modx->getDatabase()->update(array( |
|
| 137 | - 'name' => $name, |
|
| 138 | - 'description' => $description, |
|
| 139 | - 'icon' => $icon, |
|
| 140 | - 'enable_resource' => $enable_resource, |
|
| 141 | - 'resourcefile' => $resourcefile, |
|
| 142 | - 'disabled' => $disabled, |
|
| 143 | - 'wrap' => $wrap, |
|
| 144 | - 'locked' => $locked, |
|
| 145 | - 'category' => $categoryid, |
|
| 146 | - 'enable_sharedparams' => $enable_sharedparams, |
|
| 147 | - 'guid' => $guid, |
|
| 148 | - 'modulecode' => $modulecode, |
|
| 149 | - 'properties' => $properties, |
|
| 150 | - 'editedon' => $currentdate |
|
| 151 | - ), $modx->getDatabase()->getFullTableName('site_modules'), "id='{$id}'"); |
|
| 152 | - |
|
| 153 | - // save user group access permissions |
|
| 154 | - saveUserGroupAccessPermissons(); |
|
| 155 | - |
|
| 156 | - // invoke OnModFormSave event |
|
| 157 | - $modx->invokeEvent("OnModFormSave", array( |
|
| 158 | - "mode" => "upd", |
|
| 159 | - "id" => $id |
|
| 160 | - )); |
|
| 161 | - |
|
| 162 | - // Set the item name for logger |
|
| 163 | - $_SESSION['itemname'] = $name; |
|
| 164 | - |
|
| 165 | - // empty cache |
|
| 166 | - $modx->clearCache('full'); |
|
| 167 | - |
|
| 168 | - // finished emptying cache - redirect |
|
| 169 | - if ($_POST['stay'] != '') { |
|
| 170 | - $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
|
| 171 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 172 | - header($header); |
|
| 173 | - } else { |
|
| 174 | - $modx->unlockElement(6, $id); |
|
| 175 | - $header = "Location: index.php?a=106&r=2"; |
|
| 176 | - header($header); |
|
| 177 | - } |
|
| 178 | - break; |
|
| 179 | - default: |
|
| 180 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 62 | + case '107': |
|
| 63 | + // invoke OnBeforeModFormSave event |
|
| 64 | + $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 65 | + "mode" => "new", |
|
| 66 | + "id" => $id |
|
| 67 | + )); |
|
| 68 | + |
|
| 69 | + // disallow duplicate names for new modules |
|
| 70 | + $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 72 | + if ($count > 0) { |
|
| 73 | + $modx->getManagerApi()->saveFormValues(107); |
|
| 74 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // save the new module |
|
| 78 | + $newid = $modx->getDatabase()->insert(array( |
|
| 79 | + 'name' => $name, |
|
| 80 | + 'description' => $description, |
|
| 81 | + 'disabled' => $disabled, |
|
| 82 | + 'wrap' => $wrap, |
|
| 83 | + 'locked' => $locked, |
|
| 84 | + 'icon' => $icon, |
|
| 85 | + 'resourcefile' => $resourcefile, |
|
| 86 | + 'enable_resource' => $enable_resource, |
|
| 87 | + 'category' => $categoryid, |
|
| 88 | + 'enable_sharedparams' => $enable_sharedparams, |
|
| 89 | + 'guid' => $guid, |
|
| 90 | + 'modulecode' => $modulecode, |
|
| 91 | + 'properties' => $properties, |
|
| 92 | + 'createdon' => $currentdate, |
|
| 93 | + 'editedon' => $currentdate |
|
| 94 | + ), $modx->getDatabase()->getFullTableName('site_modules')); |
|
| 95 | + |
|
| 96 | + // save user group access permissions |
|
| 97 | + saveUserGroupAccessPermissons(); |
|
| 98 | + |
|
| 99 | + // invoke OnModFormSave event |
|
| 100 | + $modx->invokeEvent("OnModFormSave", array( |
|
| 101 | + "mode" => "new", |
|
| 102 | + "id" => $newid |
|
| 103 | + )); |
|
| 104 | + |
|
| 105 | + // Set the item name for logger |
|
| 106 | + $_SESSION['itemname'] = $name; |
|
| 107 | + |
|
| 108 | + // empty cache |
|
| 109 | + $modx->clearCache('full'); |
|
| 110 | + |
|
| 111 | + // finished emptying cache - redirect |
|
| 112 | + if ($_POST['stay'] != '') { |
|
| 113 | + $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
|
| 114 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 115 | + header($header); |
|
| 116 | + } else { |
|
| 117 | + $header = "Location: index.php?a=106&r=2"; |
|
| 118 | + header($header); |
|
| 119 | + } |
|
| 120 | + break; |
|
| 121 | + case '108': |
|
| 122 | + // invoke OnBeforeModFormSave event |
|
| 123 | + $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 124 | + "mode" => "upd", |
|
| 125 | + "id" => $id |
|
| 126 | + )); |
|
| 127 | + |
|
| 128 | + // disallow duplicate names for new modules |
|
| 129 | + $rs = $modx->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 131 | + $modx->getManagerApi()->saveFormValues(108); |
|
| 132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // save the edited module |
|
| 136 | + $modx->getDatabase()->update(array( |
|
| 137 | + 'name' => $name, |
|
| 138 | + 'description' => $description, |
|
| 139 | + 'icon' => $icon, |
|
| 140 | + 'enable_resource' => $enable_resource, |
|
| 141 | + 'resourcefile' => $resourcefile, |
|
| 142 | + 'disabled' => $disabled, |
|
| 143 | + 'wrap' => $wrap, |
|
| 144 | + 'locked' => $locked, |
|
| 145 | + 'category' => $categoryid, |
|
| 146 | + 'enable_sharedparams' => $enable_sharedparams, |
|
| 147 | + 'guid' => $guid, |
|
| 148 | + 'modulecode' => $modulecode, |
|
| 149 | + 'properties' => $properties, |
|
| 150 | + 'editedon' => $currentdate |
|
| 151 | + ), $modx->getDatabase()->getFullTableName('site_modules'), "id='{$id}'"); |
|
| 152 | + |
|
| 153 | + // save user group access permissions |
|
| 154 | + saveUserGroupAccessPermissons(); |
|
| 155 | + |
|
| 156 | + // invoke OnModFormSave event |
|
| 157 | + $modx->invokeEvent("OnModFormSave", array( |
|
| 158 | + "mode" => "upd", |
|
| 159 | + "id" => $id |
|
| 160 | + )); |
|
| 161 | + |
|
| 162 | + // Set the item name for logger |
|
| 163 | + $_SESSION['itemname'] = $name; |
|
| 164 | + |
|
| 165 | + // empty cache |
|
| 166 | + $modx->clearCache('full'); |
|
| 167 | + |
|
| 168 | + // finished emptying cache - redirect |
|
| 169 | + if ($_POST['stay'] != '') { |
|
| 170 | + $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
|
| 171 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 172 | + header($header); |
|
| 173 | + } else { |
|
| 174 | + $modx->unlockElement(6, $id); |
|
| 175 | + $header = "Location: index.php?a=106&r=2"; |
|
| 176 | + header($header); |
|
| 177 | + } |
|
| 178 | + break; |
|
| 179 | + default: |
|
| 180 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 181 | 181 | } |
@@ -33,113 +33,113 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | switch ($_POST['mode']) { |
| 36 | - case '19': |
|
| 37 | - |
|
| 38 | - // invoke OnBeforeTempFormSave event |
|
| 39 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | - "mode" => "new", |
|
| 41 | - "id" => $id |
|
| 42 | - )); |
|
| 43 | - |
|
| 44 | - // disallow duplicate names for new templates |
|
| 45 | - $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 47 | - if ($count > 0) { |
|
| 48 | - $modx->getManagerApi()->saveFormValues(19); |
|
| 49 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - //do stuff to save the new doc |
|
| 53 | - $newid = $modx->getDatabase()->insert(array( |
|
| 54 | - 'templatename' => $templatename, |
|
| 55 | - 'description' => $description, |
|
| 56 | - 'content' => $template, |
|
| 57 | - 'locked' => $locked, |
|
| 58 | - 'selectable' => $selectable, |
|
| 59 | - 'category' => $categoryid, |
|
| 60 | - 'createdon' => $currentdate, |
|
| 61 | - 'editedon' => $currentdate |
|
| 62 | - ), $modx->getDatabase()->getFullTableName('site_templates')); |
|
| 63 | - |
|
| 64 | - // invoke OnTempFormSave event |
|
| 65 | - $modx->invokeEvent("OnTempFormSave", array( |
|
| 66 | - "mode" => "new", |
|
| 67 | - "id" => $newid |
|
| 68 | - )); |
|
| 69 | - // Set new assigned Tvs |
|
| 70 | - saveTemplateAccess($newid); |
|
| 71 | - |
|
| 72 | - // Set the item name for logger |
|
| 73 | - $_SESSION['itemname'] = $templatename; |
|
| 74 | - |
|
| 75 | - // empty cache |
|
| 76 | - $modx->clearCache('full'); |
|
| 77 | - |
|
| 78 | - // finished emptying cache - redirect |
|
| 79 | - if ($_POST['stay'] != '') { |
|
| 80 | - $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
| 81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 82 | - header($header); |
|
| 83 | - } else { |
|
| 84 | - $header = "Location: index.php?a=76&r=2"; |
|
| 85 | - header($header); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - break; |
|
| 89 | - case '16': |
|
| 90 | - |
|
| 91 | - // invoke OnBeforeTempFormSave event |
|
| 92 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 93 | - "mode" => "upd", |
|
| 94 | - "id" => $id |
|
| 95 | - )); |
|
| 96 | - |
|
| 97 | - // disallow duplicate names for templates |
|
| 98 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 100 | - if ($count > 0) { |
|
| 101 | - $modx->getManagerApi()->saveFormValues(16); |
|
| 102 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - //do stuff to save the edited doc |
|
| 106 | - $modx->getDatabase()->update(array( |
|
| 107 | - 'templatename' => $templatename, |
|
| 108 | - 'description' => $description, |
|
| 109 | - 'content' => $template, |
|
| 110 | - 'locked' => $locked, |
|
| 111 | - 'selectable' => $selectable, |
|
| 112 | - 'category' => $categoryid, |
|
| 113 | - 'editedon' => $currentdate |
|
| 114 | - ), $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'"); |
|
| 115 | - // Set new assigned Tvs |
|
| 116 | - saveTemplateAccess($id); |
|
| 117 | - |
|
| 118 | - // invoke OnTempFormSave event |
|
| 119 | - $modx->invokeEvent("OnTempFormSave", array( |
|
| 120 | - "mode" => "upd", |
|
| 121 | - "id" => $id |
|
| 122 | - )); |
|
| 123 | - |
|
| 124 | - // Set the item name for logger |
|
| 125 | - $_SESSION['itemname'] = $templatename; |
|
| 126 | - |
|
| 127 | - // first empty the cache |
|
| 128 | - $modx->clearCache('full'); |
|
| 129 | - |
|
| 130 | - // finished emptying cache - redirect |
|
| 131 | - if ($_POST['stay'] != '') { |
|
| 132 | - $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
| 133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 134 | - header($header); |
|
| 135 | - } else { |
|
| 136 | - $modx->unlockElement(1, $id); |
|
| 137 | - $header = "Location: index.php?a=76&r=2"; |
|
| 138 | - header($header); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - break; |
|
| 143 | - default: |
|
| 144 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 36 | + case '19': |
|
| 37 | + |
|
| 38 | + // invoke OnBeforeTempFormSave event |
|
| 39 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | + "mode" => "new", |
|
| 41 | + "id" => $id |
|
| 42 | + )); |
|
| 43 | + |
|
| 44 | + // disallow duplicate names for new templates |
|
| 45 | + $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 47 | + if ($count > 0) { |
|
| 48 | + $modx->getManagerApi()->saveFormValues(19); |
|
| 49 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + //do stuff to save the new doc |
|
| 53 | + $newid = $modx->getDatabase()->insert(array( |
|
| 54 | + 'templatename' => $templatename, |
|
| 55 | + 'description' => $description, |
|
| 56 | + 'content' => $template, |
|
| 57 | + 'locked' => $locked, |
|
| 58 | + 'selectable' => $selectable, |
|
| 59 | + 'category' => $categoryid, |
|
| 60 | + 'createdon' => $currentdate, |
|
| 61 | + 'editedon' => $currentdate |
|
| 62 | + ), $modx->getDatabase()->getFullTableName('site_templates')); |
|
| 63 | + |
|
| 64 | + // invoke OnTempFormSave event |
|
| 65 | + $modx->invokeEvent("OnTempFormSave", array( |
|
| 66 | + "mode" => "new", |
|
| 67 | + "id" => $newid |
|
| 68 | + )); |
|
| 69 | + // Set new assigned Tvs |
|
| 70 | + saveTemplateAccess($newid); |
|
| 71 | + |
|
| 72 | + // Set the item name for logger |
|
| 73 | + $_SESSION['itemname'] = $templatename; |
|
| 74 | + |
|
| 75 | + // empty cache |
|
| 76 | + $modx->clearCache('full'); |
|
| 77 | + |
|
| 78 | + // finished emptying cache - redirect |
|
| 79 | + if ($_POST['stay'] != '') { |
|
| 80 | + $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
| 81 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 82 | + header($header); |
|
| 83 | + } else { |
|
| 84 | + $header = "Location: index.php?a=76&r=2"; |
|
| 85 | + header($header); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + break; |
|
| 89 | + case '16': |
|
| 90 | + |
|
| 91 | + // invoke OnBeforeTempFormSave event |
|
| 92 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 93 | + "mode" => "upd", |
|
| 94 | + "id" => $id |
|
| 95 | + )); |
|
| 96 | + |
|
| 97 | + // disallow duplicate names for templates |
|
| 98 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 100 | + if ($count > 0) { |
|
| 101 | + $modx->getManagerApi()->saveFormValues(16); |
|
| 102 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + //do stuff to save the edited doc |
|
| 106 | + $modx->getDatabase()->update(array( |
|
| 107 | + 'templatename' => $templatename, |
|
| 108 | + 'description' => $description, |
|
| 109 | + 'content' => $template, |
|
| 110 | + 'locked' => $locked, |
|
| 111 | + 'selectable' => $selectable, |
|
| 112 | + 'category' => $categoryid, |
|
| 113 | + 'editedon' => $currentdate |
|
| 114 | + ), $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'"); |
|
| 115 | + // Set new assigned Tvs |
|
| 116 | + saveTemplateAccess($id); |
|
| 117 | + |
|
| 118 | + // invoke OnTempFormSave event |
|
| 119 | + $modx->invokeEvent("OnTempFormSave", array( |
|
| 120 | + "mode" => "upd", |
|
| 121 | + "id" => $id |
|
| 122 | + )); |
|
| 123 | + |
|
| 124 | + // Set the item name for logger |
|
| 125 | + $_SESSION['itemname'] = $templatename; |
|
| 126 | + |
|
| 127 | + // first empty the cache |
|
| 128 | + $modx->clearCache('full'); |
|
| 129 | + |
|
| 130 | + // finished emptying cache - redirect |
|
| 131 | + if ($_POST['stay'] != '') { |
|
| 132 | + $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
| 133 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 134 | + header($header); |
|
| 135 | + } else { |
|
| 136 | + $modx->unlockElement(1, $id); |
|
| 137 | + $header = "Location: index.php?a=76&r=2"; |
|
| 138 | + header($header); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + break; |
|
| 143 | + default: |
|
| 144 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 145 | 145 | } |
@@ -66,111 +66,111 @@ |
||
| 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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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 | } |