@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('edit_document')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
@@ -25,17 +25,17 @@ discard block |
||
| 25 | 25 | // check user has permission to move document to chosen location |
| 26 | 26 | |
| 27 | 27 | if ($use_udperms == 1) { |
| 28 | - if ($oldparent != $newParentID) { |
|
| 29 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
| 30 | - $udperms = new udperms(); |
|
| 31 | - $udperms->user = $modx->getLoginUserID(); |
|
| 32 | - $udperms->document = $newParentID; |
|
| 33 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 34 | - |
|
| 35 | - if (!$udperms->checkPermissions()) { |
|
| 36 | - $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
| 37 | - } |
|
| 38 | - } |
|
| 28 | + if ($oldparent != $newParentID) { |
|
| 29 | + include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
| 30 | + $udperms = new udperms(); |
|
| 31 | + $udperms->user = $modx->getLoginUserID(); |
|
| 32 | + $udperms->document = $newParentID; |
|
| 33 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 34 | + |
|
| 35 | + if (!$udperms->checkPermissions()) { |
|
| 36 | + $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -43,67 +43,67 @@ discard block |
||
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | 45 | function allChildren($currDocID) { |
| 46 | - global $modx; |
|
| 47 | - $children= array(); |
|
| 48 | - $currDocID = $modx->db->escape($currDocID); |
|
| 49 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
|
| 50 | - while ($child= $modx->db->getRow($rs)) { |
|
| 51 | - $children[]= $child['id']; |
|
| 52 | - $children= array_merge($children, allChildren($child['id'])); |
|
| 53 | - } |
|
| 54 | - return $children; |
|
| 46 | + global $modx; |
|
| 47 | + $children= array(); |
|
| 48 | + $currDocID = $modx->db->escape($currDocID); |
|
| 49 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
|
| 50 | + while ($child= $modx->db->getRow($rs)) { |
|
| 51 | + $children[]= $child['id']; |
|
| 52 | + $children= array_merge($children, allChildren($child['id'])); |
|
| 53 | + } |
|
| 54 | + return $children; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
| 58 | - "id_document" => $documentID, |
|
| 59 | - "old_parent" => $oldparent, |
|
| 60 | - "new_parent" => $newParentID |
|
| 58 | + "id_document" => $documentID, |
|
| 59 | + "old_parent" => $oldparent, |
|
| 60 | + "new_parent" => $newParentID |
|
| 61 | 61 | )); |
| 62 | 62 | if (is_array($evtOut) && count($evtOut) > 0){ |
| 63 | - $newParent = array_pop($evtOut); |
|
| 64 | - if($newParent == $oldparent) { |
|
| 65 | - $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 66 | - }else{ |
|
| 67 | - $newParentID = $newParent; |
|
| 68 | - } |
|
| 63 | + $newParent = array_pop($evtOut); |
|
| 64 | + if($newParent == $oldparent) { |
|
| 65 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 66 | + }else{ |
|
| 67 | + $newParentID = $newParent; |
|
| 68 | + } |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $children = allChildren($documentID); |
| 72 | 72 | if (!array_search($newParentID, $children)) { |
| 73 | - $modx->db->update(array( |
|
| 74 | - 'isfolder' => 1, |
|
| 75 | - ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
| 76 | - |
|
| 77 | - $modx->db->update(array( |
|
| 78 | - 'parent' => $newParentID, |
|
| 79 | - 'editedby' => $modx->getLoginUserID(), |
|
| 80 | - 'editedon' => time(), |
|
| 81 | - ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
| 82 | - |
|
| 83 | - // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
| 84 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
| 85 | - $limit = $modx->db->getValue($rs); |
|
| 86 | - |
|
| 87 | - if(!$limit>0) { |
|
| 88 | - $modx->db->update(array( |
|
| 89 | - 'isfolder' => 0, |
|
| 90 | - ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
| 91 | - } |
|
| 92 | - // Set the item name for logger |
|
| 93 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
| 94 | - $_SESSION['itemname'] = $pagetitle; |
|
| 95 | - |
|
| 96 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 97 | - "id_document" => $documentID, |
|
| 98 | - "old_parent" => $oldparent, |
|
| 99 | - "new_parent" => $newParentID |
|
| 100 | - )); |
|
| 101 | - |
|
| 102 | - // empty cache & sync site |
|
| 103 | - $modx->clearCache('full'); |
|
| 104 | - |
|
| 105 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 106 | - header($header); |
|
| 73 | + $modx->db->update(array( |
|
| 74 | + 'isfolder' => 1, |
|
| 75 | + ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
| 76 | + |
|
| 77 | + $modx->db->update(array( |
|
| 78 | + 'parent' => $newParentID, |
|
| 79 | + 'editedby' => $modx->getLoginUserID(), |
|
| 80 | + 'editedon' => time(), |
|
| 81 | + ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
| 82 | + |
|
| 83 | + // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
| 84 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
| 85 | + $limit = $modx->db->getValue($rs); |
|
| 86 | + |
|
| 87 | + if(!$limit>0) { |
|
| 88 | + $modx->db->update(array( |
|
| 89 | + 'isfolder' => 0, |
|
| 90 | + ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
| 91 | + } |
|
| 92 | + // Set the item name for logger |
|
| 93 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
| 94 | + $_SESSION['itemname'] = $pagetitle; |
|
| 95 | + |
|
| 96 | + $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 97 | + "id_document" => $documentID, |
|
| 98 | + "old_parent" => $oldparent, |
|
| 99 | + "new_parent" => $newParentID |
|
| 100 | + )); |
|
| 101 | + |
|
| 102 | + // empty cache & sync site |
|
| 103 | + $modx->clearCache('full'); |
|
| 104 | + |
|
| 105 | + $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 106 | + header($header); |
|
| 107 | 107 | } else { |
| 108 | - $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
| 108 | + $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
| 109 | 109 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('save_web_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $tbl_web_users = $modx->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | 14 | foreach($input as $k => $v) { |
| 15 | - if($k !== 'comment') { |
|
| 16 | - $v = sanitize($v); |
|
| 17 | - } |
|
| 18 | - $input[$k] = $v; |
|
| 15 | + if($k !== 'comment') { |
|
| 16 | + $v = sanitize($v); |
|
| 17 | + } |
|
| 18 | + $input[$k] = $v; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $id = (int)$input['id']; |
@@ -51,80 +51,80 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 54 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 54 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 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 | - } |
|
| 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! |
|
| 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 | 128 | |
| 129 | 129 | // invoke OnWebSaveUser event |
| 130 | 130 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -142,26 +142,26 @@ discard block |
||
| 142 | 142 | "id" => $internalKey |
| 143 | 143 | )); |
| 144 | 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,84 +183,84 @@ 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 | - /*******************************************************************************/ |
|
| 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 | 264 | |
| 265 | 265 | // invoke OnWebSaveUser event |
| 266 | 266 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -289,16 +289,16 @@ discard block |
||
| 289 | 289 | "id" => $id |
| 290 | 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 | /** |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | * @return string |
| 342 | 342 | */ |
| 343 | 343 | function save_user_quoted_printable($string) { |
| 344 | - $crlf = "\n"; |
|
| 345 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 346 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 347 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 348 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 349 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 350 | - $string = preg_replace($f, $r, $string); |
|
| 351 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 344 | + $crlf = "\n"; |
|
| 345 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 346 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 347 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 348 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 349 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 350 | + $string = preg_replace($f, $r, $string); |
|
| 351 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -360,94 +360,94 @@ discard block |
||
| 360 | 360 | * @param string $ufn |
| 361 | 361 | */ |
| 362 | 362 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 363 | - global $modx, $_lang, $websignupemail_message; |
|
| 364 | - global $emailsubject, $emailsender; |
|
| 365 | - global $site_name, $site_url; |
|
| 366 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 367 | - // replace placeholders |
|
| 368 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 369 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 370 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 371 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 372 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 373 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 374 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
| 375 | - |
|
| 376 | - $param = array(); |
|
| 377 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 378 | - $param['subject'] = $emailsubject; |
|
| 379 | - $param['body'] = $message; |
|
| 380 | - $param['to'] = $email; |
|
| 381 | - $param['type'] = 'text'; |
|
| 382 | - $rs = $modx->sendmail($param); |
|
| 383 | - if(!$rs) { |
|
| 384 | - $modx->manager->saveFormValues(); |
|
| 385 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 386 | - } |
|
| 363 | + global $modx, $_lang, $websignupemail_message; |
|
| 364 | + global $emailsubject, $emailsender; |
|
| 365 | + global $site_name, $site_url; |
|
| 366 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 367 | + // replace placeholders |
|
| 368 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 369 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 370 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 371 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 372 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 373 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 374 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
| 375 | + |
|
| 376 | + $param = array(); |
|
| 377 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 378 | + $param['subject'] = $emailsubject; |
|
| 379 | + $param['body'] = $message; |
|
| 380 | + $param['to'] = $email; |
|
| 381 | + $param['type'] = 'text'; |
|
| 382 | + $rs = $modx->sendmail($param); |
|
| 383 | + if(!$rs) { |
|
| 384 | + $modx->manager->saveFormValues(); |
|
| 385 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 386 | + } |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Save User Settings |
| 390 | 390 | function saveUserSettings($id) { |
| 391 | - global $modx; |
|
| 392 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 393 | - |
|
| 394 | - $settings = array( |
|
| 395 | - "login_home", |
|
| 396 | - "allowed_ip", |
|
| 397 | - "allowed_days" |
|
| 398 | - ); |
|
| 399 | - |
|
| 400 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 401 | - |
|
| 402 | - foreach($settings as $n) { |
|
| 403 | - $vl = $_POST[$n]; |
|
| 404 | - if(is_array($vl)) { |
|
| 405 | - $vl = implode(",", $vl); |
|
| 406 | - } |
|
| 407 | - if($vl != '') { |
|
| 408 | - $f = array(); |
|
| 409 | - $f['webuser'] = $id; |
|
| 410 | - $f['setting_name'] = $n; |
|
| 411 | - $f['setting_value'] = $vl; |
|
| 412 | - $f = $modx->db->escape($f); |
|
| 413 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
| 414 | - } |
|
| 415 | - } |
|
| 391 | + global $modx; |
|
| 392 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 393 | + |
|
| 394 | + $settings = array( |
|
| 395 | + "login_home", |
|
| 396 | + "allowed_ip", |
|
| 397 | + "allowed_days" |
|
| 398 | + ); |
|
| 399 | + |
|
| 400 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 401 | + |
|
| 402 | + foreach($settings as $n) { |
|
| 403 | + $vl = $_POST[$n]; |
|
| 404 | + if(is_array($vl)) { |
|
| 405 | + $vl = implode(",", $vl); |
|
| 406 | + } |
|
| 407 | + if($vl != '') { |
|
| 408 | + $f = array(); |
|
| 409 | + $f['webuser'] = $id; |
|
| 410 | + $f['setting_name'] = $n; |
|
| 411 | + $f['setting_value'] = $vl; |
|
| 412 | + $f = $modx->db->escape($f); |
|
| 413 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Web alert - sends an alert to web browser |
| 419 | 419 | function webAlertAndQuit($msg) { |
| 420 | - global $id, $modx; |
|
| 421 | - $mode = $_POST['mode']; |
|
| 422 | - $modx->manager->saveFormValues($mode); |
|
| 423 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 420 | + global $id, $modx; |
|
| 421 | + $mode = $_POST['mode']; |
|
| 422 | + $modx->manager->saveFormValues($mode); |
|
| 423 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | // Generate password |
| 427 | 427 | function generate_password($length = 10) { |
| 428 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 429 | - $ps_len = strlen($allowable_characters); |
|
| 430 | - mt_srand((double) microtime() * 1000000); |
|
| 431 | - $pass = ""; |
|
| 432 | - for($i = 0; $i < $length; $i++) { |
|
| 433 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 434 | - } |
|
| 435 | - return $pass; |
|
| 428 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 429 | + $ps_len = strlen($allowable_characters); |
|
| 430 | + mt_srand((double) microtime() * 1000000); |
|
| 431 | + $pass = ""; |
|
| 432 | + for($i = 0; $i < $length; $i++) { |
|
| 433 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 434 | + } |
|
| 435 | + return $pass; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | function sanitize($str = '', $safecount = 0) { |
| 439 | - global $modx; |
|
| 440 | - $safecount++; |
|
| 441 | - if(1000 < $safecount) { |
|
| 442 | - exit("error too many loops '{$safecount}'"); |
|
| 443 | - } |
|
| 444 | - if(is_array($str)) { |
|
| 445 | - foreach($str as $i => $v) { |
|
| 446 | - $str[$i] = sanitize($v, $safecount); |
|
| 447 | - } |
|
| 448 | - } else { |
|
| 449 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
| 450 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 451 | - } |
|
| 452 | - return $str; |
|
| 439 | + global $modx; |
|
| 440 | + $safecount++; |
|
| 441 | + if(1000 < $safecount) { |
|
| 442 | + exit("error too many loops '{$safecount}'"); |
|
| 443 | + } |
|
| 444 | + if(is_array($str)) { |
|
| 445 | + foreach($str as $i => $v) { |
|
| 446 | + $str[$i] = sanitize($v, $safecount); |
|
| 447 | + } |
|
| 448 | + } else { |
|
| 449 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
| 450 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 451 | + } |
|
| 452 | + return $str; |
|
| 453 | 453 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 10 | 10 | if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
| 11 | - $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
|
| 11 | + $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
|
| 12 | 12 | return $modx->mergeSettingsContent($load_script); |
| 13 | 13 | } |
| 14 | 14 | |