@@ -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,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('edit_document')) { |
|
| 5 | +if (!$modx->hasPermission('edit_document')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
|
| 10 | -$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 9 | +$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0; |
|
| 10 | +$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 11 | 11 | |
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | +if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | +if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 18 | 18 | |
| 19 | 19 | $parents = $modx->getParentIds($newParentID); |
| 20 | 20 | if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | if ($use_udperms == 1) { |
| 28 | 28 | if ($oldparent != $newParentID) { |
| 29 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
| 29 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
| 30 | 30 | $udperms = new udperms(); |
| 31 | 31 | $udperms->user = $modx->getLoginUserID(); |
| 32 | 32 | $udperms->document = $newParentID; |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | * @param int $currDocID |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | -function allChildren($currDocID) { |
|
| 45 | +function allChildren($currDocID){ |
|
| 46 | 46 | global $modx; |
| 47 | - $children= array(); |
|
| 47 | + $children = array(); |
|
| 48 | 48 | $currDocID = $modx->db->escape($currDocID); |
| 49 | 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'])); |
|
| 50 | + while ($child = $modx->db->getRow($rs)) { |
|
| 51 | + $children[] = $child['id']; |
|
| 52 | + $children = array_merge($children, allChildren($child['id'])); |
|
| 53 | 53 | } |
| 54 | 54 | return $children; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
|
| 57 | +$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array( |
|
| 58 | 58 | "id_document" => $documentID, |
| 59 | 59 | "old_parent" => $oldparent, |
| 60 | 60 | "new_parent" => $newParentID |
| 61 | 61 | )); |
| 62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 62 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 63 | 63 | $newParent = array_pop($evtOut); |
| 64 | - if($newParent == $oldparent) { |
|
| 64 | + if ($newParent == $oldparent) { |
|
| 65 | 65 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 66 | - }else{ |
|
| 66 | + } else { |
|
| 67 | 67 | $newParentID = $newParent; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
| 85 | 85 | $limit = $modx->db->getValue($rs); |
| 86 | 86 | |
| 87 | - if(!$limit>0) { |
|
| 87 | + if (!$limit > 0) { |
|
| 88 | 88 | $modx->db->update(array( |
| 89 | 89 | 'isfolder' => 0, |
| 90 | 90 | ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
| 94 | 94 | $_SESSION['itemname'] = $pagetitle; |
| 95 | 95 | |
| 96 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 96 | + $modx->invokeEvent("onAfterMoveDocument", array( |
|
| 97 | 97 | "id_document" => $documentID, |
| 98 | 98 | "old_parent" => $oldparent, |
| 99 | 99 | "new_parent" => $newParentID |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | // empty cache & sync site |
| 103 | 103 | $modx->clearCache('full'); |
| 104 | 104 | |
| 105 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 105 | + $header = "Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 106 | 106 | header($header); |
| 107 | 107 | } else { |
| 108 | 108 | $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
@@ -12,12 +12,20 @@ discard block |
||
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if($documentID==$newParentID) { |
|
| 16 | + $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 17 | +} |
|
| 18 | +if($documentID <= 0) { |
|
| 19 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 20 | +} |
|
| 21 | +if($newParentID < 0) { |
|
| 22 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 23 | +} |
|
| 18 | 24 | |
| 19 | 25 | $parents = $modx->getParentIds($newParentID); |
| 20 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 26 | +if (in_array($documentID, $parents)) { |
|
| 27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 28 | +} |
|
| 21 | 29 | |
| 22 | 30 | $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
| 23 | 31 | $oldparent = $modx->db->getValue($rs); |
@@ -42,7 +50,8 @@ discard block |
||
| 42 | 50 | * @param int $currDocID |
| 43 | 51 | * @return array |
| 44 | 52 | */ |
| 45 | -function allChildren($currDocID) { |
|
| 53 | +function allChildren($currDocID) |
|
| 54 | +{ |
|
| 46 | 55 | global $modx; |
| 47 | 56 | $children= array(); |
| 48 | 57 | $currDocID = $modx->db->escape($currDocID); |
@@ -59,11 +68,11 @@ discard block |
||
| 59 | 68 | "old_parent" => $oldparent, |
| 60 | 69 | "new_parent" => $newParentID |
| 61 | 70 | )); |
| 62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 71 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 63 | 72 | $newParent = array_pop($evtOut); |
| 64 | 73 | if($newParent == $oldparent) { |
| 65 | 74 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 66 | - }else{ |
|
| 75 | + } else { |
|
| 67 | 76 | $newParentID = $newParent; |
| 68 | 77 | } |
| 69 | 78 | } |
@@ -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 | } |
@@ -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 | /** |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('save_web_user')) { |
|
| 5 | +if (!$modx->hasPermission('save_web_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | $tbl_web_groups = $modx->getFullTableName('web_groups'); |
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | -foreach($input as $k => $v) { |
|
| 15 | - if($k !== 'comment') { |
|
| 14 | +foreach ($input as $k => $v) { |
|
| 15 | + if ($k !== 'comment') { |
|
| 16 | 16 | $v = sanitize($v); |
| 17 | 17 | } |
| 18 | 18 | $input[$k] = $v; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -$id = (int)$input['id']; |
|
| 21 | +$id = (int) $input['id']; |
|
| 22 | 22 | $oldusername = $input['oldusername']; |
| 23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
| 24 | 24 | $esc_newusername = $modx->db->escape($newusername); |
@@ -50,41 +50,41 @@ discard block |
||
| 50 | 50 | $user_groups = $input['user_groups']; |
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 53 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 54 | 54 | webAlertAndQuit("Password typed is mismatched"); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 58 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 59 | 59 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -switch($input['mode']) { |
|
| 62 | +switch ($input['mode']) { |
|
| 63 | 63 | case '87' : // new user |
| 64 | 64 | // check if this user name already exist |
| 65 | 65 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
| 66 | 66 | $limit = $modx->db->getValue($rs); |
| 67 | - if($limit > 0) { |
|
| 67 | + if ($limit > 0) { |
|
| 68 | 68 | webAlertAndQuit("User name is already in use!"); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // check if the email address already exist |
| 72 | 72 | $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
| 73 | 73 | $limit = $modx->db->getValue($rs); |
| 74 | - if($limit > 0) { |
|
| 74 | + if ($limit > 0) { |
|
| 75 | 75 | webAlertAndQuit("Email is already in use!"); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // generate a new password for this user |
| 79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | - if(strlen($specifiedpassword) < 6) { |
|
| 79 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | + if (strlen($specifiedpassword) < 6) { |
|
| 81 | 81 | webAlertAndQuit("Password is too short!"); |
| 82 | 82 | } else { |
| 83 | 83 | $newpassword = $specifiedpassword; |
| 84 | 84 | } |
| 85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 85 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | 86 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 87 | - } elseif($passwordgenmethod == 'g') { |
|
| 87 | + } elseif ($passwordgenmethod == 'g') { |
|
| 88 | 88 | $newpassword = generate_password(8); |
| 89 | 89 | } else { |
| 90 | 90 | webAlertAndQuit("No password generation method specified!"); |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | /*******************************************************************************/ |
| 115 | 115 | // put the user in the user_groups he/ she should be in |
| 116 | 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++) { |
|
| 117 | + if ($use_udperms == 1) { |
|
| 118 | + if (!empty($user_groups)) { |
|
| 119 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | 120 | $f = array(); |
| 121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 121 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
| 122 | 122 | $f['webuser'] = $internalKey; |
| 123 | 123 | $modx->db->insert($f, $tbl_web_groups); |
| 124 | 124 | } |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | "id" => $internalKey |
| 143 | 143 | )); |
| 144 | 144 | |
| 145 | - if($passwordnotifymethod == 'e') { |
|
| 145 | + if ($passwordnotifymethod == 'e') { |
|
| 146 | 146 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 147 | - if($input['stay'] != '') { |
|
| 147 | + if ($input['stay'] != '') { |
|
| 148 | 148 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 149 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 150 | 150 | header($header); |
| 151 | 151 | } else { |
| 152 | 152 | $header = "Location: index.php?a=99&r=2"; |
| 153 | 153 | header($header); |
| 154 | 154 | } |
| 155 | 155 | } else { |
| 156 | - if($input['stay'] != '') { |
|
| 156 | + if ($input['stay'] != '') { |
|
| 157 | 157 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 158 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 159 | 159 | } else { |
| 160 | 160 | $stayUrl = "index.php?a=99&r=2"; |
| 161 | 161 | } |
@@ -188,36 +188,36 @@ discard block |
||
| 188 | 188 | break; |
| 189 | 189 | case '88' : // edit user |
| 190 | 190 | // generate a new password for this user |
| 191 | - if($genpassword == 1) { |
|
| 192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | - if(strlen($specifiedpassword) < 6) { |
|
| 191 | + if ($genpassword == 1) { |
|
| 192 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | + if (strlen($specifiedpassword) < 6) { |
|
| 194 | 194 | webAlertAndQuit("Password is too short!"); |
| 195 | 195 | } else { |
| 196 | 196 | $newpassword = $specifiedpassword; |
| 197 | 197 | } |
| 198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 198 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | 199 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 200 | - } elseif($passwordgenmethod == 'g') { |
|
| 200 | + } elseif ($passwordgenmethod == 'g') { |
|
| 201 | 201 | $newpassword = generate_password(8); |
| 202 | 202 | } else { |
| 203 | 203 | webAlertAndQuit("No password generation method specified!"); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | - if($passwordnotifymethod == 'e') { |
|
| 206 | + if ($passwordnotifymethod == 'e') { |
|
| 207 | 207 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // check if the username already exist |
| 211 | 211 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
| 212 | 212 | $limit = $modx->db->getValue($rs); |
| 213 | - if($limit > 0) { |
|
| 213 | + if ($limit > 0) { |
|
| 214 | 214 | webAlertAndQuit("User name is already in use!"); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // check if the email address already exists |
| 218 | 218 | $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
| 219 | 219 | $limit = $modx->db->getValue($rs); |
| 220 | - if($limit > 0) { |
|
| 220 | + if ($limit > 0) { |
|
| 221 | 221 | webAlertAndQuit("Email is already in use!"); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | // update user name and password |
| 231 | 231 | $field = array(); |
| 232 | 232 | $field['username'] = $esc_newusername; |
| 233 | - if($genpassword == 1) { |
|
| 233 | + if ($genpassword == 1) { |
|
| 234 | 234 | $field['password'] = md5($newpassword); |
| 235 | 235 | } |
| 236 | 236 | $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -247,13 +247,13 @@ discard block |
||
| 247 | 247 | /*******************************************************************************/ |
| 248 | 248 | // put the user in the user_groups he/ she should be in |
| 249 | 249 | // first, check that up_perms are switched on! |
| 250 | - if($use_udperms == 1) { |
|
| 250 | + if ($use_udperms == 1) { |
|
| 251 | 251 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 252 | 252 | $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
| 253 | - if(!empty($user_groups)) { |
|
| 254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 253 | + if (!empty($user_groups)) { |
|
| 254 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | 255 | $field = array(); |
| 256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 256 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
| 257 | 257 | $field['webuser'] = $id; |
| 258 | 258 | $modx->db->insert($field, $tbl_web_groups); |
| 259 | 259 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | )); |
| 276 | 276 | |
| 277 | 277 | // invoke OnWebChangePassword event |
| 278 | - if($genpassword == 1) { |
|
| 278 | + if ($genpassword == 1) { |
|
| 279 | 279 | $modx->invokeEvent("OnWebChangePassword", array( |
| 280 | 280 | "userid" => $id, |
| 281 | 281 | "username" => $newusername, |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | "id" => $id |
| 290 | 290 | )); |
| 291 | 291 | |
| 292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | - if($input['stay'] != '') { |
|
| 292 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | + if ($input['stay'] != '') { |
|
| 294 | 294 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 295 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 296 | 296 | } else { |
| 297 | 297 | $stayUrl = "index.php?a=99&r=2"; |
| 298 | 298 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | include_once "footer.inc.php"; |
| 322 | 322 | } else { |
| 323 | - if($input['stay'] != '') { |
|
| 323 | + if ($input['stay'] != '') { |
|
| 324 | 324 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 325 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 326 | 326 | header($header); |
| 327 | 327 | } else { |
| 328 | 328 | $header = "Location: index.php?a=99&r=2"; |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | * @param string $string |
| 341 | 341 | * @return string |
| 342 | 342 | */ |
| 343 | -function save_user_quoted_printable($string) { |
|
| 343 | +function save_user_quoted_printable($string){ |
|
| 344 | 344 | $crlf = "\n"; |
| 345 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 345 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
| 346 | 346 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
| 347 | 347 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
| 348 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 349 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 348 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
| 349 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
| 350 | 350 | $string = preg_replace($f, $r, $string); |
| 351 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 351 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @param string $pwd |
| 360 | 360 | * @param string $ufn |
| 361 | 361 | */ |
| 362 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 362 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
| 363 | 363 | global $modx, $_lang, $websignupemail_message; |
| 364 | 364 | global $emailsubject, $emailsender; |
| 365 | 365 | global $site_name, $site_url; |
@@ -380,14 +380,14 @@ discard block |
||
| 380 | 380 | $param['to'] = $email; |
| 381 | 381 | $param['type'] = 'text'; |
| 382 | 382 | $rs = $modx->sendmail($param); |
| 383 | - if(!$rs) { |
|
| 383 | + if (!$rs) { |
|
| 384 | 384 | $modx->manager->saveFormValues(); |
| 385 | 385 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Save User Settings |
| 390 | -function saveUserSettings($id) { |
|
| 390 | +function saveUserSettings($id){ |
|
| 391 | 391 | global $modx; |
| 392 | 392 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
| 393 | 393 | |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
| 401 | 401 | |
| 402 | - foreach($settings as $n) { |
|
| 402 | + foreach ($settings as $n) { |
|
| 403 | 403 | $vl = $_POST[$n]; |
| 404 | - if(is_array($vl)) { |
|
| 404 | + if (is_array($vl)) { |
|
| 405 | 405 | $vl = implode(",", $vl); |
| 406 | 406 | } |
| 407 | - if($vl != '') { |
|
| 407 | + if ($vl != '') { |
|
| 408 | 408 | $f = array(); |
| 409 | 409 | $f['webuser'] = $id; |
| 410 | 410 | $f['setting_name'] = $n; |
@@ -416,33 +416,33 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Web alert - sends an alert to web browser |
| 419 | -function webAlertAndQuit($msg) { |
|
| 419 | +function webAlertAndQuit($msg){ |
|
| 420 | 420 | global $id, $modx; |
| 421 | 421 | $mode = $_POST['mode']; |
| 422 | 422 | $modx->manager->saveFormValues($mode); |
| 423 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 423 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | // Generate password |
| 427 | -function generate_password($length = 10) { |
|
| 427 | +function generate_password($length = 10){ |
|
| 428 | 428 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 429 | 429 | $ps_len = strlen($allowable_characters); |
| 430 | 430 | mt_srand((double) microtime() * 1000000); |
| 431 | 431 | $pass = ""; |
| 432 | - for($i = 0; $i < $length; $i++) { |
|
| 432 | + for ($i = 0; $i < $length; $i++) { |
|
| 433 | 433 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
| 434 | 434 | } |
| 435 | 435 | return $pass; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | -function sanitize($str = '', $safecount = 0) { |
|
| 438 | +function sanitize($str = '', $safecount = 0){ |
|
| 439 | 439 | global $modx; |
| 440 | 440 | $safecount++; |
| 441 | - if(1000 < $safecount) { |
|
| 441 | + if (1000 < $safecount) { |
|
| 442 | 442 | exit("error too many loops '{$safecount}'"); |
| 443 | 443 | } |
| 444 | - if(is_array($str)) { |
|
| 445 | - foreach($str as $i => $v) { |
|
| 444 | + if (is_array($str)) { |
|
| 445 | + foreach ($str as $i => $v) { |
|
| 446 | 446 | $str[$i] = sanitize($v, $safecount); |
| 447 | 447 | } |
| 448 | 448 | } else { |
@@ -340,7 +340,8 @@ discard block |
||
| 340 | 340 | * @param string $string |
| 341 | 341 | * @return string |
| 342 | 342 | */ |
| 343 | -function save_user_quoted_printable($string) { |
|
| 343 | +function save_user_quoted_printable($string) |
|
| 344 | +{ |
|
| 344 | 345 | $crlf = "\n"; |
| 345 | 346 | $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
| 346 | 347 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
@@ -359,7 +360,8 @@ discard block |
||
| 359 | 360 | * @param string $pwd |
| 360 | 361 | * @param string $ufn |
| 361 | 362 | */ |
| 362 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 363 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
| 364 | +{ |
|
| 363 | 365 | global $modx, $_lang, $websignupemail_message; |
| 364 | 366 | global $emailsubject, $emailsender; |
| 365 | 367 | global $site_name, $site_url; |
@@ -387,7 +389,8 @@ discard block |
||
| 387 | 389 | } |
| 388 | 390 | |
| 389 | 391 | // Save User Settings |
| 390 | -function saveUserSettings($id) { |
|
| 392 | +function saveUserSettings($id) |
|
| 393 | +{ |
|
| 391 | 394 | global $modx; |
| 392 | 395 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
| 393 | 396 | |
@@ -416,7 +419,8 @@ discard block |
||
| 416 | 419 | } |
| 417 | 420 | |
| 418 | 421 | // Web alert - sends an alert to web browser |
| 419 | -function webAlertAndQuit($msg) { |
|
| 422 | +function webAlertAndQuit($msg) |
|
| 423 | +{ |
|
| 420 | 424 | global $id, $modx; |
| 421 | 425 | $mode = $_POST['mode']; |
| 422 | 426 | $modx->manager->saveFormValues($mode); |
@@ -424,7 +428,8 @@ discard block |
||
| 424 | 428 | } |
| 425 | 429 | |
| 426 | 430 | // Generate password |
| 427 | -function generate_password($length = 10) { |
|
| 431 | +function generate_password($length = 10) |
|
| 432 | +{ |
|
| 428 | 433 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 429 | 434 | $ps_len = strlen($allowable_characters); |
| 430 | 435 | mt_srand((double) microtime() * 1000000); |
@@ -435,7 +440,8 @@ discard block |
||
| 435 | 440 | return $pass; |
| 436 | 441 | } |
| 437 | 442 | |
| 438 | -function sanitize($str = '', $safecount = 0) { |
|
| 443 | +function sanitize($str = '', $safecount = 0) |
|
| 444 | +{ |
|
| 439 | 445 | global $modx; |
| 440 | 446 | $safecount++; |
| 441 | 447 | if(1000 < $safecount) { |
@@ -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 | |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 2 | +class DATEPICKER{ |
|
| 3 | 3 | /** |
| 4 | 4 | * @return string |
| 5 | 5 | */ |
| 6 | - public function getDP() { |
|
| 6 | + public function getDP(){ |
|
| 7 | 7 | global $modx; |
| 8 | 8 | |
| 9 | 9 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 10 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 10 | + if (!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 11 | 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 | } |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @return string |
| 17 | 17 | */ |
| 18 | - public function getLangCode() { |
|
| 18 | + public function getLangCode(){ |
|
| 19 | 19 | global $modx, $modx_lang_attribute; |
| 20 | 20 | |
| 21 | - if(!$modx_lang_attribute) return 'en'; |
|
| 21 | + if (!$modx_lang_attribute) return 'en'; |
|
| 22 | 22 | |
| 23 | 23 | $lc = $modx_lang_attribute; |
| 24 | - if($lc === 'uk') return 'ru'; |
|
| 25 | - $dp_path = str_replace('\\','/',dirname(__FILE__)); |
|
| 24 | + if ($lc === 'uk') return 'ru'; |
|
| 25 | + $dp_path = str_replace('\\', '/', dirname(__FILE__)); |
|
| 26 | 26 | |
| 27 | 27 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |
| 28 | 28 | } |
@@ -1,13 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 2 | +class DATEPICKER |
|
| 3 | +{ |
|
| 3 | 4 | /** |
| 4 | 5 | * @return string |
| 5 | 6 | */ |
| 6 | - public function getDP() { |
|
| 7 | + public function getDP() |
|
| 8 | + { |
|
| 7 | 9 | global $modx; |
| 8 | 10 | |
| 9 | 11 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 10 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 12 | + if(!isset($modx->config['lang_code'])) { |
|
| 13 | + $modx->config['lang_code'] = $this->getLangCode(); |
|
| 14 | + } |
|
| 11 | 15 | $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
| 12 | 16 | return $modx->mergeSettingsContent($load_script); |
| 13 | 17 | } |
@@ -15,13 +19,18 @@ discard block |
||
| 15 | 19 | /** |
| 16 | 20 | * @return string |
| 17 | 21 | */ |
| 18 | - public function getLangCode() { |
|
| 22 | + public function getLangCode() |
|
| 23 | + { |
|
| 19 | 24 | global $modx, $modx_lang_attribute; |
| 20 | 25 | |
| 21 | - if(!$modx_lang_attribute) return 'en'; |
|
| 26 | + if(!$modx_lang_attribute) { |
|
| 27 | + return 'en'; |
|
| 28 | + } |
|
| 22 | 29 | |
| 23 | 30 | $lc = $modx_lang_attribute; |
| 24 | - if($lc === 'uk') return 'ru'; |
|
| 31 | + if($lc === 'uk') { |
|
| 32 | + return 'ru'; |
|
| 33 | + } |
|
| 25 | 34 | $dp_path = str_replace('\\','/',dirname(__FILE__)); |
| 26 | 35 | |
| 27 | 36 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | foreach ($_ as $collation=>$selected) { |
| 51 | 51 | $collation = htmlentities($collation); |
| 52 | 52 | // if(substr($collation,0,4)!=='utf8') continue; |
| 53 | - if (strpos($collation, 'sjis')===0) { |
|
| 53 | + if (strpos($collation, 'sjis') === 0) { |
|
| 54 | 54 | continue; |
| 55 | 55 | } |
| 56 | - if ($collation=='recommend') { |
|
| 56 | + if ($collation == 'recommend') { |
|
| 57 | 57 | $output .= '<optgroup label="recommend">'; |
| 58 | - } elseif ($collation=='unrecommend') { |
|
| 58 | + } elseif ($collation == 'unrecommend') { |
|
| 59 | 59 | $output .= '</optgroup><optgroup label="unrecommend">'; |
| 60 | 60 | } else { |
| 61 | 61 | $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation); |
@@ -67,18 +67,18 @@ discard block |
||
| 67 | 67 | echo $output; |
| 68 | 68 | exit; |
| 69 | 69 | |
| 70 | -function sortItem($array=array(), $order='utf8mb4,utf8') |
|
| 70 | +function sortItem($array = array(), $order = 'utf8mb4,utf8') |
|
| 71 | 71 | { |
| 72 | 72 | $rs = array('recommend'=>''); |
| 73 | 73 | $order = explode(',', $order); |
| 74 | 74 | foreach ($order as $v) { |
| 75 | 75 | foreach ($array as $name=>$sel) { |
| 76 | - if (strpos($name, $v)!==false) { |
|
| 76 | + if (strpos($name, $v) !== false) { |
|
| 77 | 77 | $rs[$name] = $array[$name]; |
| 78 | 78 | unset($array[$name]); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | - $rs['unrecommend']=''; |
|
| 82 | + $rs['unrecommend'] = ''; |
|
| 83 | 83 | return $rs + $array; |
| 84 | 84 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | $_ = crc32(__FILE__); |
| 12 | 12 | $_ = sprintf('%u', $_);
|
| 13 | 13 | |
| 14 | - return 'evo' . base_convert($_, 10, 36); |
|
| 14 | + return 'evo'.base_convert($_, 10, 36); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | function startCMSSession() |
| 21 | 21 | {
|
| 22 | 22 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
| 23 | - if(MODX_CLI) return; |
|
| 23 | + if (MODX_CLI) return; |
|
| 24 | 24 | |
| 25 | 25 | session_name($site_sessionname); |
| 26 | 26 | removeInvalidCmsSessionIds($site_sessionname); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | session_start(); |
| 33 | 33 | $key = "modx.mgr.session.cookie.lifetime"; |
| 34 | 34 | if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
| 35 | - $cookieLifetime = (int)$_SESSION[$key]; |
|
| 35 | + $cookieLifetime = (int) $_SESSION[$key]; |
|
| 36 | 36 | if ($cookieLifetime) {
|
| 37 | 37 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 38 | 38 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function removeInvalidCmsSessionIds($session_name) |
| 63 | 63 | {
|
| 64 | - if(MODX_CLI) return; |
|
| 64 | + if (MODX_CLI) return; |
|
| 65 | 65 | // session ids is invalid iff it is empty string |
| 66 | 66 | // storage priorioty can see in PHP source ext/session/session.c |
| 67 | 67 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | /** |
| 7 | 7 | * @return string |
| 8 | 8 | */ |
| 9 | -function genEvoSessionName() |
|
| 10 | -{
|
|
| 9 | +function genEvoSessionName() |
|
| 10 | +{ |
|
| 11 | 11 | $_ = crc32(__FILE__); |
| 12 | 12 | $_ = sprintf('%u', $_);
|
| 13 | 13 | |
@@ -17,10 +17,12 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @return void |
| 19 | 19 | */ |
| 20 | -function startCMSSession() |
|
| 21 | -{
|
|
| 20 | +function startCMSSession() |
|
| 21 | +{ |
|
| 22 | 22 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
| 23 | - if(MODX_CLI) return; |
|
| 23 | + if(MODX_CLI) { |
|
| 24 | + return; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | session_name($site_sessionname); |
| 26 | 28 | removeInvalidCmsSessionIds($site_sessionname); |
@@ -31,14 +33,14 @@ discard block |
||
| 31 | 33 | session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 32 | 34 | session_start(); |
| 33 | 35 | $key = "modx.mgr.session.cookie.lifetime"; |
| 34 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
|
| 36 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
| 35 | 37 | $cookieLifetime = (int)$_SESSION[$key]; |
| 36 | - if ($cookieLifetime) {
|
|
| 38 | + if ($cookieLifetime) { |
|
| 37 | 39 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 38 | 40 | } |
| 39 | 41 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 40 | 42 | } |
| 41 | - if (!isset($_SESSION['modx.session.created.time'])) {
|
|
| 43 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
| 42 | 44 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
| 43 | 45 | } |
| 44 | 46 | } |
@@ -48,9 +50,9 @@ discard block |
||
| 48 | 50 | * @param $session_name |
| 49 | 51 | * @return void |
| 50 | 52 | */ |
| 51 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 52 | -{
|
|
| 53 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
|
|
| 53 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 54 | +{ |
|
| 55 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
| 54 | 56 | unset($storage[$session_name]); |
| 55 | 57 | } |
| 56 | 58 | } |
@@ -59,9 +61,11 @@ discard block |
||
| 59 | 61 | * @param $session_name |
| 60 | 62 | * @return void |
| 61 | 63 | */ |
| 62 | -function removeInvalidCmsSessionIds($session_name) |
|
| 63 | -{
|
|
| 64 | - if(MODX_CLI) return; |
|
| 64 | +function removeInvalidCmsSessionIds($session_name) |
|
| 65 | +{ |
|
| 66 | + if(MODX_CLI) { |
|
| 67 | + return; |
|
| 68 | + } |
|
| 65 | 69 | // session ids is invalid iff it is empty string |
| 66 | 70 | // storage priorioty can see in PHP source ext/session/session.c |
| 67 | 71 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -18,9 +18,9 @@ |
||
| 18 | 18 | exit('send some data'); |
| 19 | 19 | } //?? |
| 20 | 20 | |
| 21 | -$indent = (int)$_REQUEST['indent']; |
|
| 22 | -$parent = (int)$_REQUEST['parent']; |
|
| 23 | -$expandAll = (int)$_REQUEST['expandAll']; |
|
| 21 | +$indent = (int) $_REQUEST['indent']; |
|
| 22 | +$parent = (int) $_REQUEST['parent']; |
|
| 23 | +$expandAll = (int) $_REQUEST['expandAll']; |
|
| 24 | 24 | $output = ''; |
| 25 | 25 | $hereid = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? $_REQUEST['id'] : ''; |
| 26 | 26 | |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | case 'publishedon': |
| 39 | 39 | case 'pub_date': |
| 40 | 40 | case 'unpub_date': |
| 41 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 41 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']); |
|
| 42 | 42 | break; |
| 43 | 43 | default: |
| 44 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 44 | + $sortby = 'sc.'.$_SESSION['tree_sortby']; |
|
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 47 | + $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']); |
|
| 48 | 48 | |
| 49 | 49 | // Folder sorting gets special setup ;) Add menuindex and pagetitle |
| 50 | 50 | if ($_SESSION['tree_sortby'] == 'isfolder') { |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
| 59 | 59 | $showProtected = false; |
| 60 | 60 | if (isset ($modx->config['tree_show_protected'])) { |
| 61 | - $showProtected = (boolean)$modx->config['tree_show_protected']; |
|
| 61 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
| 62 | 62 | } |
| 63 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string)$_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 63 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 64 | 64 | if ($showProtected == false) { |
| 65 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 65 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 66 | 66 | } else { |
| 67 | 67 | $access = ''; |
| 68 | 68 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
| 101 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 101 | + $pageIdDisplay = '<small>('.($modx_textdir ? '‏' : '').$row['id'].')</small>'; |
|
| 102 | 102 | |
| 103 | 103 | // Prepare displaying user-locks |
| 104 | 104 | $lockedByUser = ''; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | 'element_type' => $_lang["lock_element_type_7"], |
| 110 | 110 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 111 | 111 | )); |
| 112 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 112 | + $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>'; |
|
| 113 | 113 | } else { |
| 114 | 114 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
| 115 | 115 | 'element_type' => $_lang["lock_element_type_7"], |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 118 | 118 | )); |
| 119 | 119 | if ($modx->hasPermission('remove_locks')) { |
| 120 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 120 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
| 121 | 121 | } else { |
| 122 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 122 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -128,22 +128,22 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $title = ''; |
| 130 | 130 | if (isDateNode($nodeNameSource)) { |
| 131 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 131 | + $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]'; |
|
| 132 | 132 | } |
| 133 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 134 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 135 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 136 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 137 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 138 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 139 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 140 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 141 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 142 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 143 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 144 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 133 | + $title .= $_lang['id'].': '.$row['id']; |
|
| 134 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle']; |
|
| 135 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex']; |
|
| 136 | + $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 137 | + $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename']; |
|
| 138 | + $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']); |
|
| 139 | + $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']); |
|
| 140 | + $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 141 | + $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 142 | + $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 143 | + $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 144 | + $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 145 | 145 | $title = $modx->htmlspecialchars($title); |
| 146 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 146 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 147 | 147 | |
| 148 | 148 | $data = array( |
| 149 | 149 | 'id' => $row['id'], |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ($ph['contextmenu']) { |
| 230 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 230 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | if ($_SESSION['tree_show_only_folders']) { |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | if ($ph['contextmenu']) { |
| 288 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 288 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $node .= $modx->parseText($tpl, $ph); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | if ($ph['contextmenu']) { |
| 326 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 326 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $node .= $modx->parseText($tpl, $ph); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | if ($ph['contextmenu']) { |
| 377 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 377 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | $node .= $modx->parseText($tpl, $ph); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | if ($ph['contextmenu']) { |
| 419 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 419 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $node .= $modx->parseText($tpl, $ph); |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $nodetitle .= $modx->config['friendly_url_suffix']; |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 496 | + $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle; |
|
| 497 | 497 | break; |
| 498 | 498 | case 'pagetitle': |
| 499 | 499 | $nodetitle = $row['pagetitle']; |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | { |
| 554 | 554 | global $modx; |
| 555 | 555 | |
| 556 | - return (int)$modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 556 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' ')); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Determine upgradeability |
| 3 | 3 | $upgradeable = 0; |
| 4 | -if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity |
|
| 5 | - include_once $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
| 4 | +if (is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { // Include the file so we can test its validity |
|
| 5 | + include_once $base_path.MGR_DIR.'/includes/config.inc.php'; |
|
| 6 | 6 | // We need to have all connection settings - tho prefix may be empty so we have to ignore it |
| 7 | 7 | if (isset($dbase)) { |
| 8 | 8 | if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $ph['moduleName'] = $moduleName; |
| 20 | -$ph['displayNew'] = ($upgradeable!=0) ? 'display:none;' : ''; |
|
| 21 | -$ph['displayUpg'] = ($upgradeable==0) ? 'display:none;' : ''; |
|
| 20 | +$ph['displayNew'] = ($upgradeable != 0) ? 'display:none;' : ''; |
|
| 21 | +$ph['displayUpg'] = ($upgradeable == 0) ? 'display:none;' : ''; |
|
| 22 | 22 | $ph['displayAdvUpg'] = $ph['displayUpg']; |
| 23 | -$ph['checkedNew'] = !$upgradeable ? 'checked' : ''; |
|
| 24 | -$ph['checkedUpg'] = ($_POST['installmode']==1 || $upgradeable==1) ? 'checked' : ''; |
|
| 25 | -$ph['checkedAdvUpg'] = ($_POST['installmode']==2 || $upgradeable==2) ? 'checked' : ''; |
|
| 23 | +$ph['checkedNew'] = !$upgradeable ? 'checked' : ''; |
|
| 24 | +$ph['checkedUpg'] = ($_POST['installmode'] == 1 || $upgradeable == 1) ? 'checked' : ''; |
|
| 25 | +$ph['checkedAdvUpg'] = ($_POST['installmode'] == 2 || $upgradeable == 2) ? 'checked' : ''; |
|
| 26 | 26 | $ph['install_language'] = $install_language; |
| 27 | -$ph['disabledUpg'] = ($upgradeable!=1) ? 'disabled' : ''; |
|
| 28 | -$ph['disabledAdvUpg'] = ($upgradeable==0) ? 'disabled' : ''; |
|
| 27 | +$ph['disabledUpg'] = ($upgradeable != 1) ? 'disabled' : ''; |
|
| 28 | +$ph['disabledAdvUpg'] = ($upgradeable == 0) ? 'disabled' : ''; |
|
| 29 | 29 | |
| 30 | -$tpl = file_get_contents($base_path . 'install/actions/tpl_mode.html'); |
|
| 30 | +$tpl = file_get_contents($base_path.'install/actions/tpl_mode.html'); |
|
| 31 | 31 | $content = parse($tpl, $ph); |
| 32 | -echo parse($content, $_lang,'[%','%]'); |
|
| 32 | +echo parse($content, $_lang, '[%', '%]'); |
|
@@ -1,20 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Determine upgradeability |
| 3 | 3 | $upgradeable = 0; |
| 4 | -if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity |
|
| 4 | +if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { |
|
| 5 | +// Include the file so we can test its validity |
|
| 5 | 6 | include_once $base_path . MGR_DIR . '/includes/config.inc.php'; |
| 6 | 7 | // We need to have all connection settings - tho prefix may be empty so we have to ignore it |
| 7 | 8 | if (isset($dbase)) { |
| 8 | - if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) |
|
| 9 | - $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
| 10 | - elseif (!@mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 11 | - $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
| 12 | - else |
|
| 13 | - $upgradeable = 1; |
|
| 9 | + if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) { |
|
| 10 | + $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
| 11 | + } elseif (!@mysqli_select_db($conn, trim($dbase, '`'))) { |
|
| 12 | + $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
| 13 | + } else { |
|
| 14 | + $upgradeable = 1; |
|
| 15 | + } |
|
| 16 | + } else { |
|
| 17 | + $upgradeable = 2; |
|
| 18 | + } |
|
| 14 | 19 | } |
| 15 | - else |
|
| 16 | - $upgradeable = 2; |
|
| 17 | -} |
|
| 18 | 20 | |
| 19 | 21 | $ph['moduleName'] = $moduleName; |
| 20 | 22 | $ph['displayNew'] = ($upgradeable!=0) ? 'display:none;' : ''; |
@@ -492,7 +492,7 @@ |
||
| 492 | 492 | }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
| 493 | 493 | $publishedon = $pub_date; |
| 494 | 494 | $publishedby = $modx->getLoginUserID(); |
| 495 | - }elseif ($was_published && !$published) { |
|
| 495 | + }elseif ($was_published && !$published) { |
|
| 496 | 496 | $publishedon = 0; |
| 497 | 497 | $publishedby = 0; |
| 498 | 498 | } else { |
@@ -280,19 +280,19 @@ |
||
| 280 | 280 | // invoke OnBeforeDocFormSave event |
| 281 | 281 | switch($modx->config['docid_incrmnt_method']) |
| 282 | 282 | { |
| 283 | - case '1': |
|
| 284 | - $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
|
| 285 | - $where = "T1.id IS NULL"; |
|
| 286 | - $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
| 287 | - $id = $modx->db->getValue($rs); |
|
| 283 | + case '1': |
|
| 284 | + $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
|
| 285 | + $where = "T1.id IS NULL"; |
|
| 286 | + $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
| 287 | + $id = $modx->db->getValue($rs); |
|
| 288 | + break; |
|
| 289 | + case '2': |
|
| 290 | + $rs = $modx->db->select('MAX(id)+1', $tbl_site_content); |
|
| 291 | + $id = $modx->db->getValue($rs); |
|
| 288 | 292 | break; |
| 289 | - case '2': |
|
| 290 | - $rs = $modx->db->select('MAX(id)+1', $tbl_site_content); |
|
| 291 | - $id = $modx->db->getValue($rs); |
|
| 292 | - break; |
|
| 293 | 293 | |
| 294 | - default: |
|
| 295 | - $id = ''; |
|
| 294 | + default: |
|
| 295 | + $id = ''; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | $modx->invokeEvent("OnBeforeDocFormSave", array( |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | case 'new' : |
| 279 | 279 | |
| 280 | 280 | // invoke OnBeforeDocFormSave event |
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 281 | + switch ($modx->config['docid_incrmnt_method']) |
|
| 282 | 282 | { |
| 283 | 283 | case '1': |
| 284 | 284 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | if (!$was_published && $published) { |
| 490 | 490 | $publishedon = $currentdate; |
| 491 | 491 | $publishedby = $modx->getLoginUserID(); |
| 492 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 492 | + }elseif ((!empty($pub_date) && $pub_date <= $currentdate && $published)) { |
|
| 493 | 493 | $publishedon = $pub_date; |
| 494 | 494 | $publishedby = $modx->getLoginUserID(); |
| 495 | 495 | }elseif ($was_published && !$published) { |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | // invoke OnBeforeDocFormSave event |
| 504 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 504 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
| 505 | 505 | "mode" => "upd", |
| 506 | 506 | "id" => $id |
| 507 | 507 | )); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | . "menuindex={$menuindex}, " |
| 527 | 527 | . "searchable={$searchable}, " |
| 528 | 528 | . "cacheable={$cacheable}, " |
| 529 | - . "editedby=" . $modx->getLoginUserID() . ", " |
|
| 529 | + . "editedby=".$modx->getLoginUserID().", " |
|
| 530 | 530 | . "editedon={$currentdate}, " |
| 531 | 531 | . "publishedon={$publishedon}, " |
| 532 | 532 | . "publishedby={$publishedby}, " |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | |
| 541 | 541 | // update template variables |
| 542 | 542 | $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
| 543 | - $tvIds = array (); |
|
| 543 | + $tvIds = array(); |
|
| 544 | 544 | while ($row = $modx->db->getRow($rs)) { |
| 545 | 545 | $tvIds[$row['tmplvarid']] = $row['id']; |
| 546 | 546 | } |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | 'groups.id, groups.document_group', |
| 594 | 594 | "{$tbl_document_groups} AS groups |
| 595 | 595 | LEFT JOIN {$tbl_documentgroup_names} AS dgn ON dgn.id = groups.document_group", |
| 596 | - "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 596 | + "((1=".(int) $isManager." AND dgn.private_memgroup) OR (1=".(int) $isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 597 | 597 | ); |
| 598 | 598 | $old_groups = array(); |
| 599 | 599 | while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | unset($old_groups[$group]); |
| 606 | 606 | continue; |
| 607 | 607 | } elseif ($link_id == 'new') { |
| 608 | - $insertions[] = '('.(int)$group.','.$id.')'; |
|
| 608 | + $insertions[] = '('.(int) $group.','.$id.')'; |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | if (!empty($insertions)) { |
@@ -637,17 +637,17 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | |
| 639 | 639 | // invoke OnDocFormSave event |
| 640 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
| 640 | + $modx->invokeEvent("OnDocFormSave", array( |
|
| 641 | 641 | "mode" => "upd", |
| 642 | 642 | "id" => $id |
| 643 | 643 | )); |
| 644 | 644 | |
| 645 | 645 | // secure web documents - flag as private |
| 646 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 646 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
| 647 | 647 | secureWebDocument($id); |
| 648 | 648 | |
| 649 | 649 | // secure manager documents - flag as private |
| 650 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 650 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
| 651 | 651 | secureMgrDocument($id); |
| 652 | 652 | |
| 653 | 653 | // Set the item name for logger |
@@ -673,13 +673,13 @@ discard block |
||
| 673 | 673 | // document |
| 674 | 674 | $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
| 675 | 675 | } |
| 676 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
| 676 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay'].$add_path; |
|
| 677 | 677 | } else { |
| 678 | 678 | $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | if (headers_sent()) { |
| 682 | - $header = str_replace('Location: ','',$header); |
|
| 682 | + $header = str_replace('Location: ', '', $header); |
|
| 683 | 683 | echo "<script>document.location.href='$header';</script>\n"; |
| 684 | 684 | } else { |
| 685 | 685 | header($header); |
@@ -134,8 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | //end webber |
| 136 | 136 | } |
| 137 | -} |
|
| 138 | -elseif ($alias) { |
|
| 137 | +} elseif ($alias) { |
|
| 139 | 138 | $alias = $modx->stripAlias($alias); |
| 140 | 139 | } |
| 141 | 140 | |
@@ -149,8 +148,7 @@ discard block |
||
| 149 | 148 | |
| 150 | 149 | if ($pub_date < $currentdate) { |
| 151 | 150 | $published = 1; |
| 152 | - } |
|
| 153 | - elseif ($pub_date > $currentdate) { |
|
| 151 | + } elseif ($pub_date > $currentdate) { |
|
| 154 | 152 | $published = 0; |
| 155 | 153 | } |
| 156 | 154 | } |
@@ -278,8 +276,7 @@ discard block |
||
| 278 | 276 | case 'new' : |
| 279 | 277 | |
| 280 | 278 | // invoke OnBeforeDocFormSave event |
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 282 | - { |
|
| 279 | + switch($modx->config['docid_incrmnt_method']) { |
|
| 283 | 280 | case '1': |
| 284 | 281 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
| 285 | 282 | $where = "T1.id IS NULL"; |
@@ -347,8 +344,9 @@ discard block |
||
| 347 | 344 | "alias_visible" => $aliasvisible |
| 348 | 345 | ); |
| 349 | 346 | |
| 350 | - if ($id != '') |
|
| 351 | - $dbInsert["id"] = $id; |
|
| 347 | + if ($id != '') { |
|
| 348 | + $dbInsert["id"] = $id; |
|
| 349 | + } |
|
| 352 | 350 | |
| 353 | 351 | $key = $modx->db->insert($dbInsert, $tbl_site_content); |
| 354 | 352 | |
@@ -424,11 +422,13 @@ discard block |
||
| 424 | 422 | // redirect/stay options |
| 425 | 423 | if ($_POST['stay'] != '') { |
| 426 | 424 | // weblink |
| 427 | - if ($_POST['mode'] == "72") |
|
| 428 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
| 425 | + if ($_POST['mode'] == "72") { |
|
| 426 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
| 427 | + } |
|
| 429 | 428 | // document |
| 430 | - if ($_POST['mode'] == "4") |
|
| 431 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
| 429 | + if ($_POST['mode'] == "4") { |
|
| 430 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
| 431 | + } |
|
| 432 | 432 | $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay']; |
| 433 | 433 | } else { |
| 434 | 434 | $header = "Location: index.php?a=3&id=$key&r=1"; |
@@ -489,10 +489,10 @@ discard block |
||
| 489 | 489 | if (!$was_published && $published) { |
| 490 | 490 | $publishedon = $currentdate; |
| 491 | 491 | $publishedby = $modx->getLoginUserID(); |
| 492 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 492 | + } elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 493 | 493 | $publishedon = $pub_date; |
| 494 | 494 | $publishedby = $modx->getLoginUserID(); |
| 495 | - }elseif ($was_published && !$published) { |
|
| 495 | + } elseif ($was_published && !$published) { |
|
| 496 | 496 | $publishedon = 0; |
| 497 | 497 | $publishedby = 0; |
| 498 | 498 | } else { |
@@ -548,7 +548,9 @@ discard block |
||
| 548 | 548 | $tvChanges = array(); |
| 549 | 549 | foreach ($tmplvars as $field => $value) { |
| 550 | 550 | if (!is_array($value)) { |
| 551 | - if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 551 | + if (isset($tvIds[$value])) { |
|
| 552 | + $tvDeletions[] = $tvIds[$value]; |
|
| 553 | + } |
|
| 552 | 554 | } else { |
| 553 | 555 | $tvId = $value[0]; |
| 554 | 556 | $tvVal = $value[1]; |
@@ -596,7 +598,9 @@ discard block |
||
| 596 | 598 | "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
| 597 | 599 | ); |
| 598 | 600 | $old_groups = array(); |
| 599 | - while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 601 | + while ($row = $modx->db->getRow($rs)) { |
|
| 602 | + $old_groups[$row['document_group']] = $row['id']; |
|
| 603 | + } |
|
| 600 | 604 | |
| 601 | 605 | // update the permissions in the database |
| 602 | 606 | $insertions = $deletions = array(); |
@@ -658,9 +662,9 @@ discard block |
||
| 658 | 662 | $modx->clearCache('full'); |
| 659 | 663 | } |
| 660 | 664 | |
| 661 | - if ($_POST['refresh_preview'] == '1') |
|
| 662 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 663 | - else { |
|
| 665 | + if ($_POST['refresh_preview'] == '1') { |
|
| 666 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 667 | + } else { |
|
| 664 | 668 | if ($_POST['stay'] != '2' && $id > 0) { |
| 665 | 669 | $modx->unlockElement(7, $id); |
| 666 | 670 | } |