@@ -3,12 +3,12 @@ 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('save_document')||!$modx->hasPermission('publish_document')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /************webber ********/ |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | $udperms->role = $_SESSION['mgrRole']; |
| 34 | 34 | |
| 35 | 35 | if(!$udperms->checkPermissions()) { |
| 36 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 36 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // update the document |
| 40 | 40 | $modx->db->update( |
| 41 | - array( |
|
| 42 | - 'published' => 1, |
|
| 43 | - 'pub_date' => 0, |
|
| 44 | - 'unpub_date' => 0, |
|
| 45 | - 'editedby' => $modx->getLoginUserID(), |
|
| 46 | - 'editedon' => time(), |
|
| 47 | - 'publishedby' => $modx->getLoginUserID(), |
|
| 48 | - 'publishedon' => time(), |
|
| 49 | - ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
| 41 | + array( |
|
| 42 | + 'published' => 1, |
|
| 43 | + 'pub_date' => 0, |
|
| 44 | + 'unpub_date' => 0, |
|
| 45 | + 'editedby' => $modx->getLoginUserID(), |
|
| 46 | + 'editedon' => time(), |
|
| 47 | + 'publishedby' => $modx->getLoginUserID(), |
|
| 48 | + 'publishedon' => time(), |
|
| 49 | + ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
| 50 | 50 | |
| 51 | 51 | // invoke OnDocPublished event |
| 52 | 52 | $modx->invokeEvent("OnDocPublished",array("docid"=>$id)); |
@@ -1,38 +1,38 @@ 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_document')||!$modx->hasPermission('publish_document')) { |
|
| 5 | +if (!$modx->hasPermission('save_document') || !$modx->hasPermission('publish_document')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /************webber ********/ |
| 15 | -$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
| 16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
| 15 | +$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
| 16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
| 17 | 17 | |
| 18 | 18 | /************** webber *************/ |
| 19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
| 20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
| 21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
| 22 | -$add_path=$sd.$sb.$pg; |
|
| 19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
| 20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
| 21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
| 22 | +$add_path = $sd.$sb.$pg; |
|
| 23 | 23 | |
| 24 | 24 | /***********************************/ |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | // check permissions on the document |
| 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 = $id; |
| 33 | 33 | $udperms->role = $_SESSION['mgrRole']; |
| 34 | 34 | |
| 35 | -if(!$udperms->checkPermissions()) { |
|
| 35 | +if (!$udperms->checkPermissions()) { |
|
| 36 | 36 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
| 50 | 50 | |
| 51 | 51 | // invoke OnDocPublished event |
| 52 | -$modx->invokeEvent("OnDocPublished",array("docid"=>$id)); |
|
| 52 | +$modx->invokeEvent("OnDocPublished", array("docid"=>$id)); |
|
| 53 | 53 | |
| 54 | 54 | // Set the item name for logger |
| 55 | 55 | $_SESSION['itemname'] = $content['pagetitle']; |
@@ -57,6 +57,6 @@ discard block |
||
| 57 | 57 | // empty cache |
| 58 | 58 | $modx->clearCache('full'); |
| 59 | 59 | |
| 60 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 60 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 61 | 61 | |
| 62 | 62 | header($header); |
@@ -3,12 +3,12 @@ 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('new_chunk')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // count duplicates |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // duplicate htmlsnippet |
| 21 | 21 | $newid = $modx->db->insert( |
| 22 | - array( |
|
| 23 | - 'name'=>'', |
|
| 24 | - 'description'=>'', |
|
| 25 | - 'snippet'=>'', |
|
| 26 | - 'category'=>'', |
|
| 27 | - ), $modx->getFullTableName('site_htmlsnippets'), // Insert into |
|
| 28 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from |
|
| 22 | + array( |
|
| 23 | + 'name'=>'', |
|
| 24 | + 'description'=>'', |
|
| 25 | + 'snippet'=>'', |
|
| 26 | + 'category'=>'', |
|
| 27 | + ), $modx->getFullTableName('site_htmlsnippets'), // Insert into |
|
| 28 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from |
|
| 29 | 29 | |
| 30 | 30 | // Set the item name for logger |
| 31 | 31 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$newid}'")); |
@@ -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('new_chunk')) { |
|
| 5 | +if (!$modx->hasPermission('new_chunk')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 17 | -if($count>=1) $count = ' '.($count+1); |
|
| 17 | +if ($count >= 1) $count = ' '.($count + 1); |
|
| 18 | 18 | else $count = ''; |
| 19 | 19 | |
| 20 | 20 | // duplicate htmlsnippet |
@@ -32,5 +32,5 @@ discard block |
||
| 32 | 32 | $_SESSION['itemname'] = $name; |
| 33 | 33 | |
| 34 | 34 | // finish duplicating - redirect to new chunk |
| 35 | -$header="Location: index.php?r=2&a=78&id=$newid"; |
|
| 35 | +$header = "Location: index.php?r=2&a=78&id=$newid"; |
|
| 36 | 36 | header($header); |
@@ -1,13 +1,13 @@ 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 | 5 | if (!$modx->hasPermission('messages')) { |
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if ($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | $modx->webAlertAndQuit("Wrong number of messages returned!"); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -if ($message['recipient']!=$modx->getLoginUserID()) { |
|
| 21 | +if ($message['recipient'] != $modx->getLoginUserID()) { |
|
| 22 | 22 | $modx->webAlertAndQuit("You are not allowed to delete this message!"); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // delete message |
| 26 | 26 | $modx->db->delete($modx->getFullTableName('user_messages'), "id='{$id}'"); |
| 27 | 27 | |
| 28 | -$header="Location: index.php?a=10"; |
|
| 28 | +$header = "Location: index.php?a=10"; |
|
| 29 | 29 | header($header); |
@@ -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('web_access_permissions')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // web access group processor. |
@@ -20,111 +20,111 @@ discard block |
||
| 20 | 20 | $operation = $_REQUEST['operation']; |
| 21 | 21 | |
| 22 | 22 | switch ($operation) { |
| 23 | - case "add_user_group" : |
|
| 24 | - $newgroup = $_REQUEST['newusergroup']; |
|
| 25 | - if(empty($newgroup)) { |
|
| 26 | - $modx->webAlertAndQuit("No group name specified."); |
|
| 27 | - } else { |
|
| 28 | - $id = $modx->db->insert(array('name'=>$modx->db->escape($newgroup)), $tbl_webgroup_names); |
|
| 23 | + case "add_user_group" : |
|
| 24 | + $newgroup = $_REQUEST['newusergroup']; |
|
| 25 | + if(empty($newgroup)) { |
|
| 26 | + $modx->webAlertAndQuit("No group name specified."); |
|
| 27 | + } else { |
|
| 28 | + $id = $modx->db->insert(array('name'=>$modx->db->escape($newgroup)), $tbl_webgroup_names); |
|
| 29 | 29 | |
| 30 | - // invoke OnWebCreateGroup event |
|
| 31 | - $modx->invokeEvent('OnWebCreateGroup', array( |
|
| 32 | - 'groupid' => $id, |
|
| 33 | - 'groupname' => $newgroup, |
|
| 34 | - )); |
|
| 35 | - } |
|
| 36 | - break; |
|
| 37 | - case "add_document_group" : |
|
| 38 | - $newgroup = $_REQUEST['newdocgroup']; |
|
| 39 | - if(empty($newgroup)) { |
|
| 40 | - $modx->webAlertAndQuit("No group name specified."); |
|
| 41 | - } else { |
|
| 42 | - $id = $modx->db->insert(array('name'=>$modx->db->escape($newgroup)), $tbl_documentgroup_names); |
|
| 30 | + // invoke OnWebCreateGroup event |
|
| 31 | + $modx->invokeEvent('OnWebCreateGroup', array( |
|
| 32 | + 'groupid' => $id, |
|
| 33 | + 'groupname' => $newgroup, |
|
| 34 | + )); |
|
| 35 | + } |
|
| 36 | + break; |
|
| 37 | + case "add_document_group" : |
|
| 38 | + $newgroup = $_REQUEST['newdocgroup']; |
|
| 39 | + if(empty($newgroup)) { |
|
| 40 | + $modx->webAlertAndQuit("No group name specified."); |
|
| 41 | + } else { |
|
| 42 | + $id = $modx->db->insert(array('name'=>$modx->db->escape($newgroup)), $tbl_documentgroup_names); |
|
| 43 | 43 | |
| 44 | - // invoke OnCreateDocGroup event |
|
| 45 | - $modx->invokeEvent('OnCreateDocGroup', array( |
|
| 46 | - 'groupid' => $id, |
|
| 47 | - 'groupname' => $newgroup, |
|
| 48 | - )); |
|
| 49 | - } |
|
| 50 | - break; |
|
| 51 | - case "delete_user_group" : |
|
| 52 | - $updategroupaccess = true; |
|
| 53 | - $usergroup = (int)$_REQUEST['usergroup']; |
|
| 54 | - if(empty($usergroup)) { |
|
| 55 | - $modx->webAlertAndQuit("No user group id specified for deletion."); |
|
| 56 | - } else { |
|
| 57 | - $modx->db->delete($tbl_webgroup_names, "id='{$usergroup}'"); |
|
| 44 | + // invoke OnCreateDocGroup event |
|
| 45 | + $modx->invokeEvent('OnCreateDocGroup', array( |
|
| 46 | + 'groupid' => $id, |
|
| 47 | + 'groupname' => $newgroup, |
|
| 48 | + )); |
|
| 49 | + } |
|
| 50 | + break; |
|
| 51 | + case "delete_user_group" : |
|
| 52 | + $updategroupaccess = true; |
|
| 53 | + $usergroup = (int)$_REQUEST['usergroup']; |
|
| 54 | + if(empty($usergroup)) { |
|
| 55 | + $modx->webAlertAndQuit("No user group id specified for deletion."); |
|
| 56 | + } else { |
|
| 57 | + $modx->db->delete($tbl_webgroup_names, "id='{$usergroup}'"); |
|
| 58 | 58 | |
| 59 | - $modx->db->delete($tbl_webgroup_access, "webgroup='{$usergroup}'"); |
|
| 59 | + $modx->db->delete($tbl_webgroup_access, "webgroup='{$usergroup}'"); |
|
| 60 | 60 | |
| 61 | - $modx->db->delete($tbl_web_groups, "webuser='{$usergroup}'"); |
|
| 62 | - } |
|
| 63 | - break; |
|
| 64 | - case "delete_document_group" : |
|
| 65 | - $group = (int)$_REQUEST['documentgroup']; |
|
| 66 | - if(empty($group)) { |
|
| 67 | - $modx->webAlertAndQuit("No document group id specified for deletion."); |
|
| 68 | - } else { |
|
| 69 | - $modx->db->delete($tbl_documentgroup_names, "id='{$group}'"); |
|
| 61 | + $modx->db->delete($tbl_web_groups, "webuser='{$usergroup}'"); |
|
| 62 | + } |
|
| 63 | + break; |
|
| 64 | + case "delete_document_group" : |
|
| 65 | + $group = (int)$_REQUEST['documentgroup']; |
|
| 66 | + if(empty($group)) { |
|
| 67 | + $modx->webAlertAndQuit("No document group id specified for deletion."); |
|
| 68 | + } else { |
|
| 69 | + $modx->db->delete($tbl_documentgroup_names, "id='{$group}'"); |
|
| 70 | 70 | |
| 71 | - $modx->db->delete($tbl_webgroup_access, "documentgroup='{$group}'"); |
|
| 71 | + $modx->db->delete($tbl_webgroup_access, "documentgroup='{$group}'"); |
|
| 72 | 72 | |
| 73 | - $modx->db->delete($tbl_document_groups, "document_group='{$group}'"); |
|
| 74 | - } |
|
| 75 | - break; |
|
| 76 | - case "rename_user_group" : |
|
| 77 | - $newgroupname = $_REQUEST['newgroupname']; |
|
| 78 | - if(empty($newgroupname)) { |
|
| 79 | - $modx->webAlertAndQuit("No group name specified."); |
|
| 80 | - } |
|
| 81 | - $groupid = (int)$_REQUEST['groupid']; |
|
| 82 | - if(empty($groupid)) { |
|
| 83 | - $modx->webAlertAndQuit("No user group id specified for rename."); |
|
| 84 | - } |
|
| 85 | - $modx->db->update(array('name' => $modx->db->escape($newgroupname)), $tbl_webgroup_names, "id='{$groupid}'"); |
|
| 86 | - break; |
|
| 87 | - case "rename_document_group" : |
|
| 88 | - $newgroupname = $_REQUEST['newgroupname']; |
|
| 89 | - if(empty($newgroupname)) { |
|
| 90 | - $modx->webAlertAndQuit("No group name specified."); |
|
| 91 | - } |
|
| 92 | - $groupid = (int)$_REQUEST['groupid']; |
|
| 93 | - if(empty($groupid)) { |
|
| 94 | - $modx->webAlertAndQuit("No document group id specified for rename."); |
|
| 95 | - } |
|
| 96 | - $modx->db->update(array('name' => $modx->db->escape($newgroupname)), $tbl_documentgroup_names, "id='{$groupid}'"); |
|
| 97 | - break; |
|
| 98 | - case "add_document_group_to_user_group" : |
|
| 99 | - $updategroupaccess = true; |
|
| 100 | - $usergroup = (int)$_REQUEST['usergroup']; |
|
| 101 | - $docgroup = (int)$_REQUEST['docgroup']; |
|
| 102 | - $rs = $modx->db->select('COUNT(*)', $tbl_webgroup_access, "webgroup='{$usergroup}' AND documentgroup='{$docgroup}'"); |
|
| 103 | - $limit = $modx->db->getValue($rs); |
|
| 104 | - if($limit<=0) { |
|
| 105 | - $modx->db->insert(array('webgroup'=>$usergroup, 'documentgroup'=>$docgroup), $tbl_webgroup_access); |
|
| 106 | - } else { |
|
| 107 | - //alert user that coupling already exists? |
|
| 108 | - } |
|
| 109 | - break; |
|
| 110 | - case "remove_document_group_from_user_group" : |
|
| 111 | - $updategroupaccess = true; |
|
| 112 | - $coupling = (int)$_REQUEST['coupling']; |
|
| 113 | - $modx->db->delete($tbl_webgroup_access, "id='{$coupling}'"); |
|
| 114 | - break; |
|
| 115 | - default : |
|
| 116 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 73 | + $modx->db->delete($tbl_document_groups, "document_group='{$group}'"); |
|
| 74 | + } |
|
| 75 | + break; |
|
| 76 | + case "rename_user_group" : |
|
| 77 | + $newgroupname = $_REQUEST['newgroupname']; |
|
| 78 | + if(empty($newgroupname)) { |
|
| 79 | + $modx->webAlertAndQuit("No group name specified."); |
|
| 80 | + } |
|
| 81 | + $groupid = (int)$_REQUEST['groupid']; |
|
| 82 | + if(empty($groupid)) { |
|
| 83 | + $modx->webAlertAndQuit("No user group id specified for rename."); |
|
| 84 | + } |
|
| 85 | + $modx->db->update(array('name' => $modx->db->escape($newgroupname)), $tbl_webgroup_names, "id='{$groupid}'"); |
|
| 86 | + break; |
|
| 87 | + case "rename_document_group" : |
|
| 88 | + $newgroupname = $_REQUEST['newgroupname']; |
|
| 89 | + if(empty($newgroupname)) { |
|
| 90 | + $modx->webAlertAndQuit("No group name specified."); |
|
| 91 | + } |
|
| 92 | + $groupid = (int)$_REQUEST['groupid']; |
|
| 93 | + if(empty($groupid)) { |
|
| 94 | + $modx->webAlertAndQuit("No document group id specified for rename."); |
|
| 95 | + } |
|
| 96 | + $modx->db->update(array('name' => $modx->db->escape($newgroupname)), $tbl_documentgroup_names, "id='{$groupid}'"); |
|
| 97 | + break; |
|
| 98 | + case "add_document_group_to_user_group" : |
|
| 99 | + $updategroupaccess = true; |
|
| 100 | + $usergroup = (int)$_REQUEST['usergroup']; |
|
| 101 | + $docgroup = (int)$_REQUEST['docgroup']; |
|
| 102 | + $rs = $modx->db->select('COUNT(*)', $tbl_webgroup_access, "webgroup='{$usergroup}' AND documentgroup='{$docgroup}'"); |
|
| 103 | + $limit = $modx->db->getValue($rs); |
|
| 104 | + if($limit<=0) { |
|
| 105 | + $modx->db->insert(array('webgroup'=>$usergroup, 'documentgroup'=>$docgroup), $tbl_webgroup_access); |
|
| 106 | + } else { |
|
| 107 | + //alert user that coupling already exists? |
|
| 108 | + } |
|
| 109 | + break; |
|
| 110 | + case "remove_document_group_from_user_group" : |
|
| 111 | + $updategroupaccess = true; |
|
| 112 | + $coupling = (int)$_REQUEST['coupling']; |
|
| 113 | + $modx->db->delete($tbl_webgroup_access, "id='{$coupling}'"); |
|
| 114 | + break; |
|
| 115 | + default : |
|
| 116 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // secure web documents - flag as private |
| 120 | 120 | if($updategroupaccess==true){ |
| 121 | - include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
| 122 | - secureWebDocument(); |
|
| 121 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
| 122 | + secureWebDocument(); |
|
| 123 | 123 | |
| 124 | - // Update the private group column |
|
| 125 | - $modx->db->update( |
|
| 126 | - 'dgn.private_webgroup = (wga.webgroup IS NOT NULL)', |
|
| 127 | - "{$tbl_documentgroup_names} AS dgn LEFT JOIN {$tbl_webgroup_access} AS wga ON wga.documentgroup = dgn.id"); |
|
| 124 | + // Update the private group column |
|
| 125 | + $modx->db->update( |
|
| 126 | + 'dgn.private_webgroup = (wga.webgroup IS NOT NULL)', |
|
| 127 | + "{$tbl_documentgroup_names} AS dgn LEFT JOIN {$tbl_webgroup_access} AS wga ON wga.documentgroup = dgn.id"); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | $header = "Location: index.php?a=91"; |
@@ -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('web_access_permissions')) { |
|
| 5 | +if (!$modx->hasPermission('web_access_permissions')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | switch ($operation) { |
| 23 | 23 | case "add_user_group" : |
| 24 | 24 | $newgroup = $_REQUEST['newusergroup']; |
| 25 | - if(empty($newgroup)) { |
|
| 25 | + if (empty($newgroup)) { |
|
| 26 | 26 | $modx->webAlertAndQuit("No group name specified."); |
| 27 | 27 | } else { |
| 28 | 28 | $id = $modx->db->insert(array('name'=>$modx->db->escape($newgroup)), $tbl_webgroup_names); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | break; |
| 37 | 37 | case "add_document_group" : |
| 38 | 38 | $newgroup = $_REQUEST['newdocgroup']; |
| 39 | - if(empty($newgroup)) { |
|
| 39 | + if (empty($newgroup)) { |
|
| 40 | 40 | $modx->webAlertAndQuit("No group name specified."); |
| 41 | 41 | } else { |
| 42 | 42 | $id = $modx->db->insert(array('name'=>$modx->db->escape($newgroup)), $tbl_documentgroup_names); |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | break; |
| 51 | 51 | case "delete_user_group" : |
| 52 | 52 | $updategroupaccess = true; |
| 53 | - $usergroup = (int)$_REQUEST['usergroup']; |
|
| 54 | - if(empty($usergroup)) { |
|
| 53 | + $usergroup = (int) $_REQUEST['usergroup']; |
|
| 54 | + if (empty($usergroup)) { |
|
| 55 | 55 | $modx->webAlertAndQuit("No user group id specified for deletion."); |
| 56 | 56 | } else { |
| 57 | 57 | $modx->db->delete($tbl_webgroup_names, "id='{$usergroup}'"); |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | break; |
| 64 | 64 | case "delete_document_group" : |
| 65 | - $group = (int)$_REQUEST['documentgroup']; |
|
| 66 | - if(empty($group)) { |
|
| 65 | + $group = (int) $_REQUEST['documentgroup']; |
|
| 66 | + if (empty($group)) { |
|
| 67 | 67 | $modx->webAlertAndQuit("No document group id specified for deletion."); |
| 68 | 68 | } else { |
| 69 | 69 | $modx->db->delete($tbl_documentgroup_names, "id='{$group}'"); |
@@ -75,33 +75,33 @@ discard block |
||
| 75 | 75 | break; |
| 76 | 76 | case "rename_user_group" : |
| 77 | 77 | $newgroupname = $_REQUEST['newgroupname']; |
| 78 | - if(empty($newgroupname)) { |
|
| 78 | + if (empty($newgroupname)) { |
|
| 79 | 79 | $modx->webAlertAndQuit("No group name specified."); |
| 80 | 80 | } |
| 81 | - $groupid = (int)$_REQUEST['groupid']; |
|
| 82 | - if(empty($groupid)) { |
|
| 81 | + $groupid = (int) $_REQUEST['groupid']; |
|
| 82 | + if (empty($groupid)) { |
|
| 83 | 83 | $modx->webAlertAndQuit("No user group id specified for rename."); |
| 84 | 84 | } |
| 85 | 85 | $modx->db->update(array('name' => $modx->db->escape($newgroupname)), $tbl_webgroup_names, "id='{$groupid}'"); |
| 86 | 86 | break; |
| 87 | 87 | case "rename_document_group" : |
| 88 | 88 | $newgroupname = $_REQUEST['newgroupname']; |
| 89 | - if(empty($newgroupname)) { |
|
| 89 | + if (empty($newgroupname)) { |
|
| 90 | 90 | $modx->webAlertAndQuit("No group name specified."); |
| 91 | 91 | } |
| 92 | - $groupid = (int)$_REQUEST['groupid']; |
|
| 93 | - if(empty($groupid)) { |
|
| 92 | + $groupid = (int) $_REQUEST['groupid']; |
|
| 93 | + if (empty($groupid)) { |
|
| 94 | 94 | $modx->webAlertAndQuit("No document group id specified for rename."); |
| 95 | 95 | } |
| 96 | 96 | $modx->db->update(array('name' => $modx->db->escape($newgroupname)), $tbl_documentgroup_names, "id='{$groupid}'"); |
| 97 | 97 | break; |
| 98 | 98 | case "add_document_group_to_user_group" : |
| 99 | 99 | $updategroupaccess = true; |
| 100 | - $usergroup = (int)$_REQUEST['usergroup']; |
|
| 101 | - $docgroup = (int)$_REQUEST['docgroup']; |
|
| 100 | + $usergroup = (int) $_REQUEST['usergroup']; |
|
| 101 | + $docgroup = (int) $_REQUEST['docgroup']; |
|
| 102 | 102 | $rs = $modx->db->select('COUNT(*)', $tbl_webgroup_access, "webgroup='{$usergroup}' AND documentgroup='{$docgroup}'"); |
| 103 | 103 | $limit = $modx->db->getValue($rs); |
| 104 | - if($limit<=0) { |
|
| 104 | + if ($limit <= 0) { |
|
| 105 | 105 | $modx->db->insert(array('webgroup'=>$usergroup, 'documentgroup'=>$docgroup), $tbl_webgroup_access); |
| 106 | 106 | } else { |
| 107 | 107 | //alert user that coupling already exists? |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | break; |
| 110 | 110 | case "remove_document_group_from_user_group" : |
| 111 | 111 | $updategroupaccess = true; |
| 112 | - $coupling = (int)$_REQUEST['coupling']; |
|
| 112 | + $coupling = (int) $_REQUEST['coupling']; |
|
| 113 | 113 | $modx->db->delete($tbl_webgroup_access, "id='{$coupling}'"); |
| 114 | 114 | break; |
| 115 | 115 | default : |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // secure web documents - flag as private |
| 120 | -if($updategroupaccess==true){ |
|
| 120 | +if ($updategroupaccess == true) { |
|
| 121 | 121 | include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
| 122 | 122 | secureWebDocument(); |
| 123 | 123 | |
@@ -3,12 +3,12 @@ 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('delete_web_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Set the item name for logger |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // invoke OnBeforeWUsrFormDelete event |
| 19 | 19 | $modx->invokeEvent("OnBeforeWUsrFormDelete", |
| 20 | - array( |
|
| 21 | - "id" => $id |
|
| 22 | - )); |
|
| 20 | + array( |
|
| 21 | + "id" => $id |
|
| 22 | + )); |
|
| 23 | 23 | |
| 24 | 24 | // delete the user. |
| 25 | 25 | $modx->db->delete($modx->getFullTableName('web_users'), "id='{$id}'"); |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // invoke OnWebDeleteUser event |
| 34 | 34 | $modx->invokeEvent("OnWebDeleteUser", |
| 35 | - array( |
|
| 36 | - "userid" => $id, |
|
| 37 | - "username" => $username |
|
| 38 | - )); |
|
| 35 | + array( |
|
| 36 | + "userid" => $id, |
|
| 37 | + "username" => $username |
|
| 38 | + )); |
|
| 39 | 39 | |
| 40 | 40 | // invoke OnWUsrFormDelete event |
| 41 | 41 | $modx->invokeEvent("OnWUsrFormDelete", |
| 42 | - array( |
|
| 43 | - "id" => $id |
|
| 44 | - )); |
|
| 42 | + array( |
|
| 43 | + "id" => $id |
|
| 44 | + )); |
|
| 45 | 45 | |
| 46 | 46 | $header="Location: index.php?a=99"; |
| 47 | 47 | header($header); |
@@ -1,13 +1,13 @@ 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('delete_web_user')) { |
|
| 5 | +if (!$modx->hasPermission('delete_web_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -43,5 +43,5 @@ discard block |
||
| 43 | 43 | "id" => $id |
| 44 | 44 | )); |
| 45 | 45 | |
| 46 | -$header="Location: index.php?a=99"; |
|
| 46 | +$header = "Location: index.php?a=99"; |
|
| 47 | 47 | header($header); |
@@ -1,12 +1,12 @@ 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 | 5 | if (!$modx->hasPermission('save_template')) { |
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = (int)$_POST['id']; |
|
| 9 | +$id = (int) $_POST['id']; |
|
| 10 | 10 | $name = $modx->db->escape(trim($_POST['name'])); |
| 11 | 11 | $description = $modx->db->escape($_POST['description']); |
| 12 | 12 | $caption = $modx->db->escape($_POST['caption']); |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | $display = $modx->db->escape($_POST['display']); |
| 18 | 18 | $params = $modx->db->escape($_POST['params']); |
| 19 | 19 | $locked = $_POST['locked'] == 'on' ? 1 : 0; |
| 20 | -$origin = isset($_REQUEST['or']) ? (int)$_REQUEST['or'] : 76; |
|
| 21 | -$originId = isset($_REQUEST['oid']) ? (int)$_REQUEST['oid'] : null; |
|
| 20 | +$origin = isset($_REQUEST['or']) ? (int) $_REQUEST['or'] : 76; |
|
| 21 | +$originId = isset($_REQUEST['oid']) ? (int) $_REQUEST['oid'] : null; |
|
| 22 | 22 | $currentdate = time() + $modx->config['server_offset_time']; |
| 23 | 23 | |
| 24 | 24 | //Kyle Jaebker - added category support |
| 25 | 25 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
| 26 | - $categoryid = (int)$_POST['categoryid']; |
|
| 26 | + $categoryid = (int) $_POST['categoryid']; |
|
| 27 | 27 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
| 28 | 28 | $categoryid = 0; |
| 29 | 29 | } else { |
| 30 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 30 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 31 | 31 | $categoryid = checkCategory($_POST['newcategory']); |
| 32 | 32 | if (!$categoryid) { |
| 33 | 33 | $categoryid = newCategory($_POST['newcategory']); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // finished emptying cache - redirect |
| 100 | 100 | if ($_POST['stay'] != '') { |
| 101 | 101 | $a = ($_POST['stay'] == '2') ? "301&id=$newid" : "300"; |
| 102 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 102 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 103 | 103 | header($header); |
| 104 | 104 | } else { |
| 105 | 105 | $header = "Location: index.php?a=76&r=2"; |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | // finished emptying cache - redirect |
| 161 | 161 | if ($_POST['stay'] != '') { |
| 162 | 162 | $a = ($_POST['stay'] == '2') ? "301&id=$id" : "300"; |
| 163 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'] . "&or=" . $origin . "&oid=" . $originId; |
|
| 163 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']."&or=".$origin."&oid=".$originId; |
|
| 164 | 164 | header($header); |
| 165 | 165 | } else { |
| 166 | 166 | $modx->unlockElement(2, $id); |
| 167 | - $header = "Location: index.php?a=" . $origin . "&r=2" . (empty($originId) ? '' : '&id=' . $originId); |
|
| 167 | + $header = "Location: index.php?a=".$origin."&r=2".(empty($originId) ? '' : '&id='.$originId); |
|
| 168 | 168 | header($header); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -3,17 +3,17 @@ |
||
| 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('delete_eventlog')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | if (isset($_GET['cls']) && $_GET['cls']==1) { |
| 10 | - $where = ''; |
|
| 10 | + $where = ''; |
|
| 11 | 11 | } else { |
| 12 | - $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 13 | - if($id==0) { |
|
| 14 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 15 | - } |
|
| 16 | - $where = "id='{$id}'"; |
|
| 12 | + $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 13 | + if($id==0) { |
|
| 14 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 15 | + } |
|
| 16 | + $where = "id='{$id}'"; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // delete event log |
@@ -1,16 +1,16 @@ 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('delete_eventlog')) { |
|
| 5 | +if (!$modx->hasPermission('delete_eventlog')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -if (isset($_GET['cls']) && $_GET['cls']==1) { |
|
| 9 | +if (isset($_GET['cls']) && $_GET['cls'] == 1) { |
|
| 10 | 10 | $where = ''; |
| 11 | 11 | } else { |
| 12 | - $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 13 | - if($id==0) { |
|
| 12 | + $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 13 | + if ($id == 0) { |
|
| 14 | 14 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 15 | 15 | } |
| 16 | 16 | $where = "id='{$id}'"; |
@@ -19,5 +19,5 @@ discard block |
||
| 19 | 19 | // delete event log |
| 20 | 20 | $modx->db->delete($modx->getFullTableName('event_log'), $where); |
| 21 | 21 | |
| 22 | -$header="Location: index.php?a=114"; |
|
| 22 | +$header = "Location: index.php?a=114"; |
|
| 23 | 23 | header($header); |
@@ -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_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $modx->loadExtension('phpass'); |
@@ -45,134 +45,134 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // verify password |
| 47 | 47 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 48 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 48 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // verify email |
| 52 | 52 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 53 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 53 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // verify admin security |
| 57 | 57 | if($_SESSION['mgrRole'] != 1) { |
| 58 | - // Check to see if user tried to spoof a "1" (admin) role |
|
| 59 | - if(!$modx->hasPermission('save_role')) { |
|
| 60 | - webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
|
| 61 | - } |
|
| 62 | - // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
| 63 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
| 64 | - $limit = $modx->db->getValue($rs); |
|
| 65 | - if($limit > 0) { |
|
| 66 | - webAlertAndQuit("You cannot alter an administrative user."); |
|
| 67 | - } |
|
| 58 | + // Check to see if user tried to spoof a "1" (admin) role |
|
| 59 | + if(!$modx->hasPermission('save_role')) { |
|
| 60 | + webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
|
| 61 | + } |
|
| 62 | + // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
| 63 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
| 64 | + $limit = $modx->db->getValue($rs); |
|
| 65 | + if($limit > 0) { |
|
| 66 | + webAlertAndQuit("You cannot alter an administrative user."); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | switch($input['mode']) { |
| 72 | - case '11' : // new user |
|
| 73 | - // check if this user name already exist |
|
| 74 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | - $limit = $modx->db->getValue($rs); |
|
| 76 | - if($limit > 0) { |
|
| 77 | - webAlertAndQuit("User name is already in use!"); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // check if the email address already exist |
|
| 81 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | - $limit = $modx->db->getValue($rs); |
|
| 83 | - if($limit > 0) { |
|
| 84 | - webAlertAndQuit("Email is already in use!"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // generate a new password for this user |
|
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 90 | - webAlertAndQuit("Password is too short!"); |
|
| 91 | - } else { |
|
| 92 | - $newpassword = $specifiedpassword; |
|
| 93 | - } |
|
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 97 | - $newpassword = generate_password(8); |
|
| 98 | - } else { |
|
| 99 | - webAlertAndQuit("No password generation method specified!"); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // invoke OnBeforeUserFormSave event |
|
| 103 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | - "mode" => "new", |
|
| 105 | - )); |
|
| 106 | - |
|
| 107 | - // create the user account |
|
| 108 | - $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | - |
|
| 110 | - $field = array(); |
|
| 111 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | - $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | - |
|
| 114 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | - $field = $modx->db->escape($field); |
|
| 116 | - $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | - |
|
| 118 | - // Save user settings |
|
| 119 | - saveUserSettings($internalKey); |
|
| 120 | - |
|
| 121 | - // invoke OnManagerSaveUser event |
|
| 122 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | - "mode" => "new", |
|
| 124 | - "userid" => $internalKey, |
|
| 125 | - "username" => $newusername, |
|
| 126 | - "userpassword" => $newpassword, |
|
| 127 | - "useremail" => $email, |
|
| 128 | - "userfullname" => $fullname, |
|
| 129 | - "userroleid" => $role |
|
| 130 | - )); |
|
| 131 | - |
|
| 132 | - // invoke OnUserFormSave event |
|
| 133 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | - "mode" => "new", |
|
| 135 | - "id" => $internalKey |
|
| 136 | - )); |
|
| 137 | - |
|
| 138 | - // Set the item name for logger |
|
| 139 | - $_SESSION['itemname'] = $newusername; |
|
| 140 | - |
|
| 141 | - /*******************************************************************************/ |
|
| 142 | - // put the user in the user_groups he/ she should be in |
|
| 143 | - // first, check that up_perms are switched on! |
|
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | - $f = array(); |
|
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | - $f['member'] = $internalKey; |
|
| 150 | - $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // end of user_groups stuff! |
|
| 155 | - |
|
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 157 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - header($header); |
|
| 162 | - } else { |
|
| 163 | - $header = "Location: index.php?a=75&r=2"; |
|
| 164 | - header($header); |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if($input['stay'] != '') { |
|
| 168 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | - } else { |
|
| 171 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - include_once "header.inc.php"; |
|
| 175 | - ?> |
|
| 72 | + case '11' : // new user |
|
| 73 | + // check if this user name already exist |
|
| 74 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | + $limit = $modx->db->getValue($rs); |
|
| 76 | + if($limit > 0) { |
|
| 77 | + webAlertAndQuit("User name is already in use!"); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // check if the email address already exist |
|
| 81 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | + $limit = $modx->db->getValue($rs); |
|
| 83 | + if($limit > 0) { |
|
| 84 | + webAlertAndQuit("Email is already in use!"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // generate a new password for this user |
|
| 88 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if(strlen($specifiedpassword) < 6) { |
|
| 90 | + webAlertAndQuit("Password is too short!"); |
|
| 91 | + } else { |
|
| 92 | + $newpassword = $specifiedpassword; |
|
| 93 | + } |
|
| 94 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | + } elseif($passwordgenmethod == 'g') { |
|
| 97 | + $newpassword = generate_password(8); |
|
| 98 | + } else { |
|
| 99 | + webAlertAndQuit("No password generation method specified!"); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // invoke OnBeforeUserFormSave event |
|
| 103 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | + "mode" => "new", |
|
| 105 | + )); |
|
| 106 | + |
|
| 107 | + // create the user account |
|
| 108 | + $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | + |
|
| 110 | + $field = array(); |
|
| 111 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | + $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | + |
|
| 114 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | + $field = $modx->db->escape($field); |
|
| 116 | + $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | + |
|
| 118 | + // Save user settings |
|
| 119 | + saveUserSettings($internalKey); |
|
| 120 | + |
|
| 121 | + // invoke OnManagerSaveUser event |
|
| 122 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | + "mode" => "new", |
|
| 124 | + "userid" => $internalKey, |
|
| 125 | + "username" => $newusername, |
|
| 126 | + "userpassword" => $newpassword, |
|
| 127 | + "useremail" => $email, |
|
| 128 | + "userfullname" => $fullname, |
|
| 129 | + "userroleid" => $role |
|
| 130 | + )); |
|
| 131 | + |
|
| 132 | + // invoke OnUserFormSave event |
|
| 133 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | + "mode" => "new", |
|
| 135 | + "id" => $internalKey |
|
| 136 | + )); |
|
| 137 | + |
|
| 138 | + // Set the item name for logger |
|
| 139 | + $_SESSION['itemname'] = $newusername; |
|
| 140 | + |
|
| 141 | + /*******************************************************************************/ |
|
| 142 | + // put the user in the user_groups he/ she should be in |
|
| 143 | + // first, check that up_perms are switched on! |
|
| 144 | + if($use_udperms == 1) { |
|
| 145 | + if(!empty($user_groups)) { |
|
| 146 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | + $f = array(); |
|
| 148 | + $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | + $f['member'] = $internalKey; |
|
| 150 | + $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // end of user_groups stuff! |
|
| 155 | + |
|
| 156 | + if($passwordnotifymethod == 'e') { |
|
| 157 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + header($header); |
|
| 162 | + } else { |
|
| 163 | + $header = "Location: index.php?a=75&r=2"; |
|
| 164 | + header($header); |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if($input['stay'] != '') { |
|
| 168 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | + } else { |
|
| 171 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + include_once "header.inc.php"; |
|
| 175 | + ?> |
|
| 176 | 176 | |
| 177 | 177 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 178 | 178 | |
@@ -194,125 +194,125 @@ discard block |
||
| 194 | 194 | </div> |
| 195 | 195 | <?php |
| 196 | 196 | |
| 197 | - include_once "footer.inc.php"; |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - case '12' : // edit user |
|
| 201 | - // generate a new password for this user |
|
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 205 | - webAlertAndQuit("Password is too short!"); |
|
| 206 | - } else { |
|
| 207 | - $newpassword = $specifiedpassword; |
|
| 208 | - } |
|
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 212 | - $newpassword = generate_password(8); |
|
| 213 | - } else { |
|
| 214 | - webAlertAndQuit("No password generation method specified!"); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 218 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // check if the username already exist |
|
| 222 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | - $limit = $modx->db->getValue($rs); |
|
| 224 | - if($limit > 0) { |
|
| 225 | - webAlertAndQuit("User name is already in use!"); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // check if the email address already exists |
|
| 229 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | - $limit = $modx->db->getValue($rs); |
|
| 231 | - if($limit > 0) { |
|
| 232 | - webAlertAndQuit("Email is already in use!"); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // invoke OnBeforeUserFormSave event |
|
| 236 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | - "mode" => "upd", |
|
| 238 | - "id" => $id |
|
| 239 | - )); |
|
| 240 | - |
|
| 241 | - // update user name and password |
|
| 242 | - $field = array(); |
|
| 243 | - $field['username'] = $modx->db->escape($newusername); |
|
| 244 | - if($genpassword == 1) { |
|
| 245 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | - } |
|
| 247 | - $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | - $field = $modx->db->escape($field); |
|
| 250 | - $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | - |
|
| 252 | - // Save user settings |
|
| 253 | - saveUserSettings($id); |
|
| 254 | - |
|
| 255 | - // Set the item name for logger |
|
| 256 | - $_SESSION['itemname'] = $newusername; |
|
| 257 | - |
|
| 258 | - // invoke OnManagerSaveUser event |
|
| 259 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | - "mode" => "upd", |
|
| 261 | - "userid" => $id, |
|
| 262 | - "username" => $newusername, |
|
| 263 | - "userpassword" => $newpassword, |
|
| 264 | - "useremail" => $email, |
|
| 265 | - "userfullname" => $fullname, |
|
| 266 | - "userroleid" => $role, |
|
| 267 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | - )); |
|
| 270 | - |
|
| 271 | - // invoke OnManagerChangePassword event |
|
| 272 | - if($genpassword == 1) { |
|
| 273 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | - "userid" => $id, |
|
| 275 | - "username" => $newusername, |
|
| 276 | - "userpassword" => $newpassword |
|
| 277 | - )); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // invoke OnUserFormSave event |
|
| 281 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | - "mode" => "upd", |
|
| 283 | - "id" => $id |
|
| 284 | - )); |
|
| 285 | - |
|
| 286 | - /*******************************************************************************/ |
|
| 287 | - // put the user in the user_groups he/ she should be in |
|
| 288 | - // first, check that up_perms are switched on! |
|
| 289 | - if($use_udperms == 1) { |
|
| 290 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | - $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | - $field = array(); |
|
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | - $field['member'] = $id; |
|
| 297 | - $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - // end of user_groups stuff! |
|
| 302 | - /*******************************************************************************/ |
|
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | - } |
|
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 308 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | - } else { |
|
| 311 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - include_once "header.inc.php"; |
|
| 315 | - ?> |
|
| 197 | + include_once "footer.inc.php"; |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + case '12' : // edit user |
|
| 201 | + // generate a new password for this user |
|
| 202 | + if($genpassword == 1) { |
|
| 203 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if(strlen($specifiedpassword) < 6) { |
|
| 205 | + webAlertAndQuit("Password is too short!"); |
|
| 206 | + } else { |
|
| 207 | + $newpassword = $specifiedpassword; |
|
| 208 | + } |
|
| 209 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | + } elseif($passwordgenmethod == 'g') { |
|
| 212 | + $newpassword = generate_password(8); |
|
| 213 | + } else { |
|
| 214 | + webAlertAndQuit("No password generation method specified!"); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + if($passwordnotifymethod == 'e') { |
|
| 218 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // check if the username already exist |
|
| 222 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | + $limit = $modx->db->getValue($rs); |
|
| 224 | + if($limit > 0) { |
|
| 225 | + webAlertAndQuit("User name is already in use!"); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // check if the email address already exists |
|
| 229 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | + $limit = $modx->db->getValue($rs); |
|
| 231 | + if($limit > 0) { |
|
| 232 | + webAlertAndQuit("Email is already in use!"); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // invoke OnBeforeUserFormSave event |
|
| 236 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | + "mode" => "upd", |
|
| 238 | + "id" => $id |
|
| 239 | + )); |
|
| 240 | + |
|
| 241 | + // update user name and password |
|
| 242 | + $field = array(); |
|
| 243 | + $field['username'] = $modx->db->escape($newusername); |
|
| 244 | + if($genpassword == 1) { |
|
| 245 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | + } |
|
| 247 | + $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | + $field = $modx->db->escape($field); |
|
| 250 | + $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | + |
|
| 252 | + // Save user settings |
|
| 253 | + saveUserSettings($id); |
|
| 254 | + |
|
| 255 | + // Set the item name for logger |
|
| 256 | + $_SESSION['itemname'] = $newusername; |
|
| 257 | + |
|
| 258 | + // invoke OnManagerSaveUser event |
|
| 259 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | + "mode" => "upd", |
|
| 261 | + "userid" => $id, |
|
| 262 | + "username" => $newusername, |
|
| 263 | + "userpassword" => $newpassword, |
|
| 264 | + "useremail" => $email, |
|
| 265 | + "userfullname" => $fullname, |
|
| 266 | + "userroleid" => $role, |
|
| 267 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | + )); |
|
| 270 | + |
|
| 271 | + // invoke OnManagerChangePassword event |
|
| 272 | + if($genpassword == 1) { |
|
| 273 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | + "userid" => $id, |
|
| 275 | + "username" => $newusername, |
|
| 276 | + "userpassword" => $newpassword |
|
| 277 | + )); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // invoke OnUserFormSave event |
|
| 281 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | + "mode" => "upd", |
|
| 283 | + "id" => $id |
|
| 284 | + )); |
|
| 285 | + |
|
| 286 | + /*******************************************************************************/ |
|
| 287 | + // put the user in the user_groups he/ she should be in |
|
| 288 | + // first, check that up_perms are switched on! |
|
| 289 | + if($use_udperms == 1) { |
|
| 290 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | + $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | + if(!empty($user_groups)) { |
|
| 293 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | + $field = array(); |
|
| 295 | + $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,151 +332,151 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
| 352 | 352 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 353 | - global $modx, $_lang, $signupemail_message; |
|
| 354 | - global $emailsubject, $emailsender; |
|
| 355 | - global $site_name; |
|
| 356 | - $manager_url = MODX_MANAGER_URL; |
|
| 357 | - $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
| 358 | - // replace placeholders |
|
| 359 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 360 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 361 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 362 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 363 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 364 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 365 | - $message = str_replace("[+surl+]", $manager_url, $message); |
|
| 366 | - |
|
| 367 | - $param = array(); |
|
| 368 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 369 | - $param['subject'] = $emailsubject; |
|
| 370 | - $param['body'] = $message; |
|
| 371 | - $param['to'] = $email; |
|
| 372 | - $param['type'] = 'text'; |
|
| 373 | - $rs = $modx->sendmail($param); |
|
| 374 | - if(!$rs) { |
|
| 375 | - $modx->manager->saveFormValues(); |
|
| 376 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 377 | - } |
|
| 353 | + global $modx, $_lang, $signupemail_message; |
|
| 354 | + global $emailsubject, $emailsender; |
|
| 355 | + global $site_name; |
|
| 356 | + $manager_url = MODX_MANAGER_URL; |
|
| 357 | + $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
| 358 | + // replace placeholders |
|
| 359 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 360 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 361 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 362 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 363 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 364 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 365 | + $message = str_replace("[+surl+]", $manager_url, $message); |
|
| 366 | + |
|
| 367 | + $param = array(); |
|
| 368 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 369 | + $param['subject'] = $emailsubject; |
|
| 370 | + $param['body'] = $message; |
|
| 371 | + $param['to'] = $email; |
|
| 372 | + $param['type'] = 'text'; |
|
| 373 | + $rs = $modx->sendmail($param); |
|
| 374 | + if(!$rs) { |
|
| 375 | + $modx->manager->saveFormValues(); |
|
| 376 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 377 | + } |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Save User Settings |
| 381 | 381 | function saveUserSettings($id) { |
| 382 | - global $modx; |
|
| 383 | - $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
| 384 | - |
|
| 385 | - $ignore = array( |
|
| 386 | - 'id', |
|
| 387 | - 'oldusername', |
|
| 388 | - 'oldemail', |
|
| 389 | - 'newusername', |
|
| 390 | - 'fullname', |
|
| 391 | - 'newpassword', |
|
| 392 | - 'newpasswordcheck', |
|
| 393 | - 'passwordgenmethod', |
|
| 394 | - 'passwordnotifymethod', |
|
| 395 | - 'specifiedpassword', |
|
| 396 | - 'confirmpassword', |
|
| 397 | - 'email', |
|
| 398 | - 'phone', |
|
| 399 | - 'mobilephone', |
|
| 400 | - 'fax', |
|
| 401 | - 'dob', |
|
| 402 | - 'country', |
|
| 403 | - 'street', |
|
| 404 | - 'city', |
|
| 405 | - 'state', |
|
| 406 | - 'zip', |
|
| 407 | - 'gender', |
|
| 408 | - 'photo', |
|
| 409 | - 'comment', |
|
| 410 | - 'role', |
|
| 411 | - 'failedlogincount', |
|
| 412 | - 'blocked', |
|
| 413 | - 'blockeduntil', |
|
| 414 | - 'blockedafter', |
|
| 415 | - 'user_groups', |
|
| 416 | - 'mode', |
|
| 417 | - 'blockedmode', |
|
| 418 | - 'stay', |
|
| 419 | - 'save', |
|
| 420 | - 'theme_refresher' |
|
| 421 | - ); |
|
| 422 | - |
|
| 423 | - // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
| 424 | - $defaults = array( |
|
| 425 | - 'upload_images', |
|
| 426 | - 'upload_media', |
|
| 427 | - 'upload_flash', |
|
| 428 | - 'upload_files' |
|
| 429 | - ); |
|
| 430 | - |
|
| 431 | - // get user setting field names |
|
| 432 | - $settings = array(); |
|
| 433 | - foreach($_POST as $n => $v) { |
|
| 434 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 435 | - continue; |
|
| 436 | - } // ignore blacklist and empties |
|
| 437 | - $settings[$n] = $v; // this value should be saved |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - foreach($defaults as $k) { |
|
| 441 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 442 | - unset($settings[$k]); |
|
| 443 | - } |
|
| 444 | - unset($settings['default_' . $k]); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
| 448 | - |
|
| 449 | - foreach($settings as $n => $vl) { |
|
| 450 | - if(is_array($vl)) { |
|
| 451 | - $vl = implode(",", $vl); |
|
| 452 | - } |
|
| 453 | - if($vl != '') { |
|
| 454 | - $f = array(); |
|
| 455 | - $f['user'] = $id; |
|
| 456 | - $f['setting_name'] = $n; |
|
| 457 | - $f['setting_value'] = $vl; |
|
| 458 | - $f = $modx->db->escape($f); |
|
| 459 | - $modx->db->insert($f, $tbl_user_settings); |
|
| 460 | - } |
|
| 461 | - } |
|
| 382 | + global $modx; |
|
| 383 | + $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
| 384 | + |
|
| 385 | + $ignore = array( |
|
| 386 | + 'id', |
|
| 387 | + 'oldusername', |
|
| 388 | + 'oldemail', |
|
| 389 | + 'newusername', |
|
| 390 | + 'fullname', |
|
| 391 | + 'newpassword', |
|
| 392 | + 'newpasswordcheck', |
|
| 393 | + 'passwordgenmethod', |
|
| 394 | + 'passwordnotifymethod', |
|
| 395 | + 'specifiedpassword', |
|
| 396 | + 'confirmpassword', |
|
| 397 | + 'email', |
|
| 398 | + 'phone', |
|
| 399 | + 'mobilephone', |
|
| 400 | + 'fax', |
|
| 401 | + 'dob', |
|
| 402 | + 'country', |
|
| 403 | + 'street', |
|
| 404 | + 'city', |
|
| 405 | + 'state', |
|
| 406 | + 'zip', |
|
| 407 | + 'gender', |
|
| 408 | + 'photo', |
|
| 409 | + 'comment', |
|
| 410 | + 'role', |
|
| 411 | + 'failedlogincount', |
|
| 412 | + 'blocked', |
|
| 413 | + 'blockeduntil', |
|
| 414 | + 'blockedafter', |
|
| 415 | + 'user_groups', |
|
| 416 | + 'mode', |
|
| 417 | + 'blockedmode', |
|
| 418 | + 'stay', |
|
| 419 | + 'save', |
|
| 420 | + 'theme_refresher' |
|
| 421 | + ); |
|
| 422 | + |
|
| 423 | + // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
| 424 | + $defaults = array( |
|
| 425 | + 'upload_images', |
|
| 426 | + 'upload_media', |
|
| 427 | + 'upload_flash', |
|
| 428 | + 'upload_files' |
|
| 429 | + ); |
|
| 430 | + |
|
| 431 | + // get user setting field names |
|
| 432 | + $settings = array(); |
|
| 433 | + foreach($_POST as $n => $v) { |
|
| 434 | + if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 435 | + continue; |
|
| 436 | + } // ignore blacklist and empties |
|
| 437 | + $settings[$n] = $v; // this value should be saved |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + foreach($defaults as $k) { |
|
| 441 | + if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 442 | + unset($settings[$k]); |
|
| 443 | + } |
|
| 444 | + unset($settings['default_' . $k]); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
| 448 | + |
|
| 449 | + foreach($settings as $n => $vl) { |
|
| 450 | + if(is_array($vl)) { |
|
| 451 | + $vl = implode(",", $vl); |
|
| 452 | + } |
|
| 453 | + if($vl != '') { |
|
| 454 | + $f = array(); |
|
| 455 | + $f['user'] = $id; |
|
| 456 | + $f['setting_name'] = $n; |
|
| 457 | + $f['setting_value'] = $vl; |
|
| 458 | + $f = $modx->db->escape($f); |
|
| 459 | + $modx->db->insert($f, $tbl_user_settings); |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Web alert - sends an alert to web browser |
| 465 | 465 | function webAlertAndQuit($msg) { |
| 466 | - global $id, $modx; |
|
| 467 | - $mode = $_POST['mode']; |
|
| 468 | - $modx->manager->saveFormValues($mode); |
|
| 469 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 466 | + global $id, $modx; |
|
| 467 | + $mode = $_POST['mode']; |
|
| 468 | + $modx->manager->saveFormValues($mode); |
|
| 469 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // Generate password |
| 473 | 473 | function generate_password($length = 10) { |
| 474 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 475 | - $ps_len = strlen($allowable_characters); |
|
| 476 | - mt_srand((double) microtime() * 1000000); |
|
| 477 | - $pass = ""; |
|
| 478 | - for($i = 0; $i < $length; $i++) { |
|
| 479 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 480 | - } |
|
| 481 | - return $pass; |
|
| 474 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 475 | + $ps_len = strlen($allowable_characters); |
|
| 476 | + mt_srand((double) microtime() * 1000000); |
|
| 477 | + $pass = ""; |
|
| 478 | + for($i = 0; $i < $length; $i++) { |
|
| 479 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 480 | + } |
|
| 481 | + return $pass; |
|
| 482 | 482 | } |
@@ -69,110 +69,110 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | switch($input['mode']) { |
| 72 | - case '11' : // new user |
|
| 73 | - // check if this user name already exist |
|
| 74 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | - $limit = $modx->db->getValue($rs); |
|
| 76 | - if($limit > 0) { |
|
| 77 | - webAlertAndQuit("User name is already in use!"); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // check if the email address already exist |
|
| 81 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | - $limit = $modx->db->getValue($rs); |
|
| 83 | - if($limit > 0) { |
|
| 84 | - webAlertAndQuit("Email is already in use!"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // generate a new password for this user |
|
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 90 | - webAlertAndQuit("Password is too short!"); |
|
| 91 | - } else { |
|
| 92 | - $newpassword = $specifiedpassword; |
|
| 93 | - } |
|
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 97 | - $newpassword = generate_password(8); |
|
| 98 | - } else { |
|
| 99 | - webAlertAndQuit("No password generation method specified!"); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // invoke OnBeforeUserFormSave event |
|
| 103 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | - "mode" => "new", |
|
| 105 | - )); |
|
| 106 | - |
|
| 107 | - // create the user account |
|
| 108 | - $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | - |
|
| 110 | - $field = array(); |
|
| 111 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | - $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | - |
|
| 114 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | - $field = $modx->db->escape($field); |
|
| 116 | - $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | - |
|
| 118 | - // Save user settings |
|
| 119 | - saveUserSettings($internalKey); |
|
| 120 | - |
|
| 121 | - // invoke OnManagerSaveUser event |
|
| 122 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | - "mode" => "new", |
|
| 124 | - "userid" => $internalKey, |
|
| 125 | - "username" => $newusername, |
|
| 126 | - "userpassword" => $newpassword, |
|
| 127 | - "useremail" => $email, |
|
| 128 | - "userfullname" => $fullname, |
|
| 129 | - "userroleid" => $role |
|
| 130 | - )); |
|
| 131 | - |
|
| 132 | - // invoke OnUserFormSave event |
|
| 133 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | - "mode" => "new", |
|
| 135 | - "id" => $internalKey |
|
| 136 | - )); |
|
| 137 | - |
|
| 138 | - // Set the item name for logger |
|
| 139 | - $_SESSION['itemname'] = $newusername; |
|
| 140 | - |
|
| 141 | - /*******************************************************************************/ |
|
| 142 | - // put the user in the user_groups he/ she should be in |
|
| 143 | - // first, check that up_perms are switched on! |
|
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | - $f = array(); |
|
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | - $f['member'] = $internalKey; |
|
| 150 | - $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // end of user_groups stuff! |
|
| 155 | - |
|
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 157 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - header($header); |
|
| 162 | - } else { |
|
| 163 | - $header = "Location: index.php?a=75&r=2"; |
|
| 164 | - header($header); |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if($input['stay'] != '') { |
|
| 168 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | - } else { |
|
| 171 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - include_once "header.inc.php"; |
|
| 175 | - ?> |
|
| 72 | + case '11' : // new user |
|
| 73 | + // check if this user name already exist |
|
| 74 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | + $limit = $modx->db->getValue($rs); |
|
| 76 | + if($limit > 0) { |
|
| 77 | + webAlertAndQuit("User name is already in use!"); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // check if the email address already exist |
|
| 81 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | + $limit = $modx->db->getValue($rs); |
|
| 83 | + if($limit > 0) { |
|
| 84 | + webAlertAndQuit("Email is already in use!"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // generate a new password for this user |
|
| 88 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if(strlen($specifiedpassword) < 6) { |
|
| 90 | + webAlertAndQuit("Password is too short!"); |
|
| 91 | + } else { |
|
| 92 | + $newpassword = $specifiedpassword; |
|
| 93 | + } |
|
| 94 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | + } elseif($passwordgenmethod == 'g') { |
|
| 97 | + $newpassword = generate_password(8); |
|
| 98 | + } else { |
|
| 99 | + webAlertAndQuit("No password generation method specified!"); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // invoke OnBeforeUserFormSave event |
|
| 103 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | + "mode" => "new", |
|
| 105 | + )); |
|
| 106 | + |
|
| 107 | + // create the user account |
|
| 108 | + $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | + |
|
| 110 | + $field = array(); |
|
| 111 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | + $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | + |
|
| 114 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | + $field = $modx->db->escape($field); |
|
| 116 | + $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | + |
|
| 118 | + // Save user settings |
|
| 119 | + saveUserSettings($internalKey); |
|
| 120 | + |
|
| 121 | + // invoke OnManagerSaveUser event |
|
| 122 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | + "mode" => "new", |
|
| 124 | + "userid" => $internalKey, |
|
| 125 | + "username" => $newusername, |
|
| 126 | + "userpassword" => $newpassword, |
|
| 127 | + "useremail" => $email, |
|
| 128 | + "userfullname" => $fullname, |
|
| 129 | + "userroleid" => $role |
|
| 130 | + )); |
|
| 131 | + |
|
| 132 | + // invoke OnUserFormSave event |
|
| 133 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | + "mode" => "new", |
|
| 135 | + "id" => $internalKey |
|
| 136 | + )); |
|
| 137 | + |
|
| 138 | + // Set the item name for logger |
|
| 139 | + $_SESSION['itemname'] = $newusername; |
|
| 140 | + |
|
| 141 | + /*******************************************************************************/ |
|
| 142 | + // put the user in the user_groups he/ she should be in |
|
| 143 | + // first, check that up_perms are switched on! |
|
| 144 | + if($use_udperms == 1) { |
|
| 145 | + if(!empty($user_groups)) { |
|
| 146 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | + $f = array(); |
|
| 148 | + $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | + $f['member'] = $internalKey; |
|
| 150 | + $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // end of user_groups stuff! |
|
| 155 | + |
|
| 156 | + if($passwordnotifymethod == 'e') { |
|
| 157 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + header($header); |
|
| 162 | + } else { |
|
| 163 | + $header = "Location: index.php?a=75&r=2"; |
|
| 164 | + header($header); |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if($input['stay'] != '') { |
|
| 168 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | + } else { |
|
| 171 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + include_once "header.inc.php"; |
|
| 175 | + ?> |
|
| 176 | 176 | |
| 177 | 177 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 178 | 178 | |
@@ -194,125 +194,125 @@ discard block |
||
| 194 | 194 | </div> |
| 195 | 195 | <?php |
| 196 | 196 | |
| 197 | - include_once "footer.inc.php"; |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - case '12' : // edit user |
|
| 201 | - // generate a new password for this user |
|
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 205 | - webAlertAndQuit("Password is too short!"); |
|
| 206 | - } else { |
|
| 207 | - $newpassword = $specifiedpassword; |
|
| 208 | - } |
|
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 212 | - $newpassword = generate_password(8); |
|
| 213 | - } else { |
|
| 214 | - webAlertAndQuit("No password generation method specified!"); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 218 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // check if the username already exist |
|
| 222 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | - $limit = $modx->db->getValue($rs); |
|
| 224 | - if($limit > 0) { |
|
| 225 | - webAlertAndQuit("User name is already in use!"); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // check if the email address already exists |
|
| 229 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | - $limit = $modx->db->getValue($rs); |
|
| 231 | - if($limit > 0) { |
|
| 232 | - webAlertAndQuit("Email is already in use!"); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // invoke OnBeforeUserFormSave event |
|
| 236 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | - "mode" => "upd", |
|
| 238 | - "id" => $id |
|
| 239 | - )); |
|
| 240 | - |
|
| 241 | - // update user name and password |
|
| 242 | - $field = array(); |
|
| 243 | - $field['username'] = $modx->db->escape($newusername); |
|
| 244 | - if($genpassword == 1) { |
|
| 245 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | - } |
|
| 247 | - $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | - $field = $modx->db->escape($field); |
|
| 250 | - $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | - |
|
| 252 | - // Save user settings |
|
| 253 | - saveUserSettings($id); |
|
| 254 | - |
|
| 255 | - // Set the item name for logger |
|
| 256 | - $_SESSION['itemname'] = $newusername; |
|
| 257 | - |
|
| 258 | - // invoke OnManagerSaveUser event |
|
| 259 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | - "mode" => "upd", |
|
| 261 | - "userid" => $id, |
|
| 262 | - "username" => $newusername, |
|
| 263 | - "userpassword" => $newpassword, |
|
| 264 | - "useremail" => $email, |
|
| 265 | - "userfullname" => $fullname, |
|
| 266 | - "userroleid" => $role, |
|
| 267 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | - )); |
|
| 270 | - |
|
| 271 | - // invoke OnManagerChangePassword event |
|
| 272 | - if($genpassword == 1) { |
|
| 273 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | - "userid" => $id, |
|
| 275 | - "username" => $newusername, |
|
| 276 | - "userpassword" => $newpassword |
|
| 277 | - )); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // invoke OnUserFormSave event |
|
| 281 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | - "mode" => "upd", |
|
| 283 | - "id" => $id |
|
| 284 | - )); |
|
| 285 | - |
|
| 286 | - /*******************************************************************************/ |
|
| 287 | - // put the user in the user_groups he/ she should be in |
|
| 288 | - // first, check that up_perms are switched on! |
|
| 289 | - if($use_udperms == 1) { |
|
| 290 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | - $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | - $field = array(); |
|
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | - $field['member'] = $id; |
|
| 297 | - $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - // end of user_groups stuff! |
|
| 302 | - /*******************************************************************************/ |
|
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | - } |
|
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 308 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | - } else { |
|
| 311 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - include_once "header.inc.php"; |
|
| 315 | - ?> |
|
| 197 | + include_once "footer.inc.php"; |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + case '12' : // edit user |
|
| 201 | + // generate a new password for this user |
|
| 202 | + if($genpassword == 1) { |
|
| 203 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if(strlen($specifiedpassword) < 6) { |
|
| 205 | + webAlertAndQuit("Password is too short!"); |
|
| 206 | + } else { |
|
| 207 | + $newpassword = $specifiedpassword; |
|
| 208 | + } |
|
| 209 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | + } elseif($passwordgenmethod == 'g') { |
|
| 212 | + $newpassword = generate_password(8); |
|
| 213 | + } else { |
|
| 214 | + webAlertAndQuit("No password generation method specified!"); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + if($passwordnotifymethod == 'e') { |
|
| 218 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // check if the username already exist |
|
| 222 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | + $limit = $modx->db->getValue($rs); |
|
| 224 | + if($limit > 0) { |
|
| 225 | + webAlertAndQuit("User name is already in use!"); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // check if the email address already exists |
|
| 229 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | + $limit = $modx->db->getValue($rs); |
|
| 231 | + if($limit > 0) { |
|
| 232 | + webAlertAndQuit("Email is already in use!"); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // invoke OnBeforeUserFormSave event |
|
| 236 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | + "mode" => "upd", |
|
| 238 | + "id" => $id |
|
| 239 | + )); |
|
| 240 | + |
|
| 241 | + // update user name and password |
|
| 242 | + $field = array(); |
|
| 243 | + $field['username'] = $modx->db->escape($newusername); |
|
| 244 | + if($genpassword == 1) { |
|
| 245 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | + } |
|
| 247 | + $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | + $field = $modx->db->escape($field); |
|
| 250 | + $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | + |
|
| 252 | + // Save user settings |
|
| 253 | + saveUserSettings($id); |
|
| 254 | + |
|
| 255 | + // Set the item name for logger |
|
| 256 | + $_SESSION['itemname'] = $newusername; |
|
| 257 | + |
|
| 258 | + // invoke OnManagerSaveUser event |
|
| 259 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | + "mode" => "upd", |
|
| 261 | + "userid" => $id, |
|
| 262 | + "username" => $newusername, |
|
| 263 | + "userpassword" => $newpassword, |
|
| 264 | + "useremail" => $email, |
|
| 265 | + "userfullname" => $fullname, |
|
| 266 | + "userroleid" => $role, |
|
| 267 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | + )); |
|
| 270 | + |
|
| 271 | + // invoke OnManagerChangePassword event |
|
| 272 | + if($genpassword == 1) { |
|
| 273 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | + "userid" => $id, |
|
| 275 | + "username" => $newusername, |
|
| 276 | + "userpassword" => $newpassword |
|
| 277 | + )); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // invoke OnUserFormSave event |
|
| 281 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | + "mode" => "upd", |
|
| 283 | + "id" => $id |
|
| 284 | + )); |
|
| 285 | + |
|
| 286 | + /*******************************************************************************/ |
|
| 287 | + // put the user in the user_groups he/ she should be in |
|
| 288 | + // first, check that up_perms are switched on! |
|
| 289 | + if($use_udperms == 1) { |
|
| 290 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | + $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | + if(!empty($user_groups)) { |
|
| 293 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | + $field = array(); |
|
| 295 | + $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
@@ -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_user')) { |
|
| 5 | +if (!$modx->hasPermission('save_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $input = $_POST; |
| 16 | 16 | |
| 17 | -$id = (int)$input['id']; |
|
| 17 | +$id = (int) $input['id']; |
|
| 18 | 18 | $oldusername = $input['oldusername']; |
| 19 | 19 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
| 20 | 20 | $fullname = $input['fullname']; |
@@ -44,56 +44,56 @@ discard block |
||
| 44 | 44 | $user_groups = $input['user_groups']; |
| 45 | 45 | |
| 46 | 46 | // verify password |
| 47 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 47 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 48 | 48 | webAlertAndQuit("Password typed is mismatched"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // verify email |
| 52 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 52 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 53 | 53 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // verify admin security |
| 57 | -if($_SESSION['mgrRole'] != 1) { |
|
| 57 | +if ($_SESSION['mgrRole'] != 1) { |
|
| 58 | 58 | // Check to see if user tried to spoof a "1" (admin) role |
| 59 | - if(!$modx->hasPermission('save_role')) { |
|
| 59 | + if (!$modx->hasPermission('save_role')) { |
|
| 60 | 60 | webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
| 61 | 61 | } |
| 62 | 62 | // Verify that the user being edited wasn't an admin and the user ID got spoofed |
| 63 | 63 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
| 64 | 64 | $limit = $modx->db->getValue($rs); |
| 65 | - if($limit > 0) { |
|
| 65 | + if ($limit > 0) { |
|
| 66 | 66 | webAlertAndQuit("You cannot alter an administrative user."); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -switch($input['mode']) { |
|
| 71 | +switch ($input['mode']) { |
|
| 72 | 72 | case '11' : // new user |
| 73 | 73 | // check if this user name already exist |
| 74 | 74 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
| 75 | 75 | $limit = $modx->db->getValue($rs); |
| 76 | - if($limit > 0) { |
|
| 76 | + if ($limit > 0) { |
|
| 77 | 77 | webAlertAndQuit("User name is already in use!"); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // check if the email address already exist |
| 81 | 81 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
| 82 | 82 | $limit = $modx->db->getValue($rs); |
| 83 | - if($limit > 0) { |
|
| 83 | + if ($limit > 0) { |
|
| 84 | 84 | webAlertAndQuit("Email is already in use!"); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // generate a new password for this user |
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 88 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if (strlen($specifiedpassword) < 6) { |
|
| 90 | 90 | webAlertAndQuit("Password is too short!"); |
| 91 | 91 | } else { |
| 92 | 92 | $newpassword = $specifiedpassword; |
| 93 | 93 | } |
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 94 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | 95 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 96 | + } elseif ($passwordgenmethod == 'g') { |
|
| 97 | 97 | $newpassword = generate_password(8); |
| 98 | 98 | } else { |
| 99 | 99 | webAlertAndQuit("No password generation method specified!"); |
@@ -141,11 +141,11 @@ discard block |
||
| 141 | 141 | /*******************************************************************************/ |
| 142 | 142 | // put the user in the user_groups he/ she should be in |
| 143 | 143 | // first, check that up_perms are switched on! |
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 144 | + if ($use_udperms == 1) { |
|
| 145 | + if (!empty($user_groups)) { |
|
| 146 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | 147 | $f = array(); |
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 148 | + $f['user_group'] = (int) $user_groups[$i]; |
|
| 149 | 149 | $f['member'] = $internalKey; |
| 150 | 150 | $modx->db->insert($f, $tbl_member_groups); |
| 151 | 151 | } |
@@ -153,20 +153,20 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | // end of user_groups stuff! |
| 155 | 155 | |
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 156 | + if ($passwordnotifymethod == 'e') { |
|
| 157 | 157 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 158 | - if($input['stay'] != '') { |
|
| 158 | + if ($input['stay'] != '') { |
|
| 159 | 159 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 161 | 161 | header($header); |
| 162 | 162 | } else { |
| 163 | 163 | $header = "Location: index.php?a=75&r=2"; |
| 164 | 164 | header($header); |
| 165 | 165 | } |
| 166 | 166 | } else { |
| 167 | - if($input['stay'] != '') { |
|
| 167 | + if ($input['stay'] != '') { |
|
| 168 | 168 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 170 | 170 | } else { |
| 171 | 171 | $stayUrl = "index.php?a=75&r=2"; |
| 172 | 172 | } |
@@ -199,36 +199,36 @@ discard block |
||
| 199 | 199 | break; |
| 200 | 200 | case '12' : // edit user |
| 201 | 201 | // generate a new password for this user |
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 202 | + if ($genpassword == 1) { |
|
| 203 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if (strlen($specifiedpassword) < 6) { |
|
| 205 | 205 | webAlertAndQuit("Password is too short!"); |
| 206 | 206 | } else { |
| 207 | 207 | $newpassword = $specifiedpassword; |
| 208 | 208 | } |
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 209 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | 210 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 211 | + } elseif ($passwordgenmethod == 'g') { |
|
| 212 | 212 | $newpassword = generate_password(8); |
| 213 | 213 | } else { |
| 214 | 214 | webAlertAndQuit("No password generation method specified!"); |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 217 | + if ($passwordnotifymethod == 'e') { |
|
| 218 | 218 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // check if the username already exist |
| 222 | 222 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
| 223 | 223 | $limit = $modx->db->getValue($rs); |
| 224 | - if($limit > 0) { |
|
| 224 | + if ($limit > 0) { |
|
| 225 | 225 | webAlertAndQuit("User name is already in use!"); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // check if the email address already exists |
| 229 | 229 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
| 230 | 230 | $limit = $modx->db->getValue($rs); |
| 231 | - if($limit > 0) { |
|
| 231 | + if ($limit > 0) { |
|
| 232 | 232 | webAlertAndQuit("Email is already in use!"); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | // update user name and password |
| 242 | 242 | $field = array(); |
| 243 | 243 | $field['username'] = $modx->db->escape($newusername); |
| 244 | - if($genpassword == 1) { |
|
| 244 | + if ($genpassword == 1) { |
|
| 245 | 245 | $field['password'] = $modx->phpass->HashPassword($newpassword); |
| 246 | 246 | } |
| 247 | 247 | $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | )); |
| 270 | 270 | |
| 271 | 271 | // invoke OnManagerChangePassword event |
| 272 | - if($genpassword == 1) { |
|
| 272 | + if ($genpassword == 1) { |
|
| 273 | 273 | $modx->invokeEvent("OnManagerChangePassword", array( |
| 274 | 274 | "userid" => $id, |
| 275 | 275 | "username" => $newusername, |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | /*******************************************************************************/ |
| 287 | 287 | // put the user in the user_groups he/ she should be in |
| 288 | 288 | // first, check that up_perms are switched on! |
| 289 | - if($use_udperms == 1) { |
|
| 289 | + if ($use_udperms == 1) { |
|
| 290 | 290 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 291 | 291 | $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 292 | + if (!empty($user_groups)) { |
|
| 293 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | 294 | $field = array(); |
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 295 | + $field['user_group'] = (int) $user_groups[$i]; |
|
| 296 | 296 | $field['member'] = $id; |
| 297 | 297 | $modx->db->insert($field, $tbl_member_groups); |
| 298 | 298 | } |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | // end of user_groups stuff! |
| 302 | 302 | /*******************************************************************************/ |
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 303 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | 304 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
| 305 | 305 | } |
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 306 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if ($input['stay'] != '') { |
|
| 308 | 308 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 310 | 310 | } else { |
| 311 | 311 | $stayUrl = "index.php?a=75&r=2"; |
| 312 | 312 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
| 327 | 327 | <div class="sectionBody"> |
| 328 | 328 | <div id="disp"> |
| 329 | - <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
| 329 | + <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
| 330 | 330 | </div> |
| 331 | 331 | </div> |
| 332 | 332 | </div> |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | include_once "footer.inc.php"; |
| 336 | 336 | } else { |
| 337 | - if($input['stay'] != '') { |
|
| 337 | + if ($input['stay'] != '') { |
|
| 338 | 338 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 340 | 340 | header($header); |
| 341 | 341 | } else { |
| 342 | 342 | $header = "Location: index.php?a=75&r=2"; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
| 352 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 352 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
| 353 | 353 | global $modx, $_lang, $signupemail_message; |
| 354 | 354 | global $emailsubject, $emailsender; |
| 355 | 355 | global $site_name; |
@@ -371,14 +371,14 @@ discard block |
||
| 371 | 371 | $param['to'] = $email; |
| 372 | 372 | $param['type'] = 'text'; |
| 373 | 373 | $rs = $modx->sendmail($param); |
| 374 | - if(!$rs) { |
|
| 374 | + if (!$rs) { |
|
| 375 | 375 | $modx->manager->saveFormValues(); |
| 376 | 376 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Save User Settings |
| 381 | -function saveUserSettings($id) { |
|
| 381 | +function saveUserSettings($id){ |
|
| 382 | 382 | global $modx; |
| 383 | 383 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
| 384 | 384 | |
@@ -430,27 +430,27 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // get user setting field names |
| 432 | 432 | $settings = array(); |
| 433 | - foreach($_POST as $n => $v) { |
|
| 434 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 433 | + foreach ($_POST as $n => $v) { |
|
| 434 | + if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 435 | 435 | continue; |
| 436 | 436 | } // ignore blacklist and empties |
| 437 | 437 | $settings[$n] = $v; // this value should be saved |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - foreach($defaults as $k) { |
|
| 441 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 440 | + foreach ($defaults as $k) { |
|
| 441 | + if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') { |
|
| 442 | 442 | unset($settings[$k]); |
| 443 | 443 | } |
| 444 | - unset($settings['default_' . $k]); |
|
| 444 | + unset($settings['default_'.$k]); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
| 448 | 448 | |
| 449 | - foreach($settings as $n => $vl) { |
|
| 450 | - if(is_array($vl)) { |
|
| 449 | + foreach ($settings as $n => $vl) { |
|
| 450 | + if (is_array($vl)) { |
|
| 451 | 451 | $vl = implode(",", $vl); |
| 452 | 452 | } |
| 453 | - if($vl != '') { |
|
| 453 | + if ($vl != '') { |
|
| 454 | 454 | $f = array(); |
| 455 | 455 | $f['user'] = $id; |
| 456 | 456 | $f['setting_name'] = $n; |
@@ -462,20 +462,20 @@ discard block |
||
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Web alert - sends an alert to web browser |
| 465 | -function webAlertAndQuit($msg) { |
|
| 465 | +function webAlertAndQuit($msg){ |
|
| 466 | 466 | global $id, $modx; |
| 467 | 467 | $mode = $_POST['mode']; |
| 468 | 468 | $modx->manager->saveFormValues($mode); |
| 469 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 469 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : '')); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // Generate password |
| 473 | -function generate_password($length = 10) { |
|
| 473 | +function generate_password($length = 10){ |
|
| 474 | 474 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 475 | 475 | $ps_len = strlen($allowable_characters); |
| 476 | 476 | mt_srand((double) microtime() * 1000000); |
| 477 | 477 | $pass = ""; |
| 478 | - for($i = 0; $i < $length; $i++) { |
|
| 478 | + for ($i = 0; $i < $length; $i++) { |
|
| 479 | 479 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
| 480 | 480 | } |
| 481 | 481 | return $pass; |
@@ -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('settings')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | $data = $_POST; |
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
@@ -11,41 +11,41 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
| 13 | 13 | { |
| 14 | - $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | - $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | - $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | - if(is_file($htaccess)) |
|
| 18 | - { |
|
| 19 | - $_ = file_get_contents($htaccess); |
|
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 21 | - { |
|
| 22 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 23 | - } |
|
| 24 | - elseif(is_writable($htaccess)) |
|
| 25 | - { |
|
| 26 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 28 | - { |
|
| 29 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 34 | - { |
|
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 14 | + $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | + $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | + $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | + if(is_file($htaccess)) |
|
| 18 | + { |
|
| 19 | + $_ = file_get_contents($htaccess); |
|
| 20 | + if(strpos($_,'RewriteBase')===false) |
|
| 36 | 21 | { |
| 37 | - $warnings[] = $_lang["settings_friendlyurls_alert"]; |
|
| 38 | - } |
|
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 40 | - { |
|
| 41 | - $_ = file_get_contents($htaccess); |
|
| 42 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 44 | - { |
|
| 45 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 22 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 23 | + } |
|
| 24 | + elseif(is_writable($htaccess)) |
|
| 25 | + { |
|
| 26 | + $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | + if(!@file_put_contents($htaccess,$_)) |
|
| 28 | + { |
|
| 29 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + elseif(is_file($sample_htaccess)) |
|
| 34 | + { |
|
| 35 | + if(!@rename($sample_htaccess,$htaccess)) |
|
| 36 | + { |
|
| 37 | + $warnings[] = $_lang["settings_friendlyurls_alert"]; |
|
| 38 | + } |
|
| 39 | + elseif($modx->config['base_url']!=='/') |
|
| 40 | + { |
|
| 41 | + $_ = file_get_contents($htaccess); |
|
| 42 | + $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | + if(!@file_put_contents($htaccess,$_)) |
|
| 44 | + { |
|
| 45 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | $data['rb_base_dir'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['rb_base_dir']); |
| 57 | 57 | |
| 58 | 58 | if (isset($data) && count($data) > 0) { |
| 59 | - if(isset($data['manager_language'])) { |
|
| 60 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | - if(is_file($lang_path)) { |
|
| 62 | - include($lang_path); |
|
| 59 | + if(isset($data['manager_language'])) { |
|
| 60 | + $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | + if(is_file($lang_path)) { |
|
| 62 | + include($lang_path); |
|
| 63 | 63 | global $modx_lang_attribute; |
| 64 | 64 | $data['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; |
| 65 | - } |
|
| 66 | - } |
|
| 67 | - $savethese = array(); |
|
| 68 | - $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
|
| 69 | - $data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | - foreach ($data as $k => $v) { |
|
| 71 | - switch ($k) { |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + $savethese = array(); |
|
| 68 | + $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
|
| 69 | + $data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | + foreach ($data as $k => $v) { |
|
| 71 | + switch ($k) { |
|
| 72 | 72 | case 'settings_version':{ |
| 73 | 73 | if($modx->getVersionData('version')!=$data['settings_version']){ |
| 74 | 74 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
@@ -76,24 +76,24 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | break; |
| 78 | 78 | } |
| 79 | - case 'error_page': |
|
| 80 | - case 'unauthorized_page': |
|
| 81 | - if (trim($v) == '' || !is_numeric($v)) { |
|
| 82 | - $v = $data['site_start']; |
|
| 83 | - } |
|
| 84 | - break; |
|
| 79 | + case 'error_page': |
|
| 80 | + case 'unauthorized_page': |
|
| 81 | + if (trim($v) == '' || !is_numeric($v)) { |
|
| 82 | + $v = $data['site_start']; |
|
| 83 | + } |
|
| 84 | + break; |
|
| 85 | 85 | |
| 86 | - case 'lst_custom_contenttype': |
|
| 87 | - case 'txt_custom_contenttype': |
|
| 88 | - // Skip these |
|
| 89 | - $k = ''; |
|
| 90 | - break; |
|
| 91 | - case 'rb_base_dir': |
|
| 92 | - case 'rb_base_url': |
|
| 93 | - case 'filemanager_path': |
|
| 94 | - $v = trim($v); |
|
| 95 | - $v = rtrim($v,'/') . '/'; |
|
| 96 | - break; |
|
| 86 | + case 'lst_custom_contenttype': |
|
| 87 | + case 'txt_custom_contenttype': |
|
| 88 | + // Skip these |
|
| 89 | + $k = ''; |
|
| 90 | + break; |
|
| 91 | + case 'rb_base_dir': |
|
| 92 | + case 'rb_base_url': |
|
| 93 | + case 'filemanager_path': |
|
| 94 | + $v = trim($v); |
|
| 95 | + $v = rtrim($v,'/') . '/'; |
|
| 96 | + break; |
|
| 97 | 97 | case 'manager_language': |
| 98 | 98 | $langDir = realpath(MODX_MANAGER_PATH . 'includes/lang'); |
| 99 | 99 | $langFile = realpath(MODX_MANAGER_PATH . 'includes/lang/' . $v . '.inc.php'); |
@@ -101,56 +101,56 @@ discard block |
||
| 101 | 101 | if($langDir !== $langFileDir || !file_exists($langFile)) { |
| 102 | 102 | $v = 'english'; |
| 103 | 103 | } |
| 104 | - break; |
|
| 105 | - case 'smtppw': |
|
| 106 | - if ($v !== '********************' && $v !== '') { |
|
| 107 | - $v = trim($v); |
|
| 108 | - $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | - $v = str_replace('=','%',$v); |
|
| 110 | - } elseif ($v === '********************') { |
|
| 111 | - $k = ''; |
|
| 112 | - } |
|
| 113 | - break; |
|
| 104 | + break; |
|
| 105 | + case 'smtppw': |
|
| 106 | + if ($v !== '********************' && $v !== '') { |
|
| 107 | + $v = trim($v); |
|
| 108 | + $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | + $v = str_replace('=','%',$v); |
|
| 110 | + } elseif ($v === '********************') { |
|
| 111 | + $k = ''; |
|
| 112 | + } |
|
| 113 | + break; |
|
| 114 | 114 | case 'valid_hostnames': |
| 115 | - $v = str_replace(array(' ,', ', '), ',', $v); |
|
| 116 | - if ($v !== ',') { |
|
| 117 | - $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
|
| 118 | - $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | - @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 120 | - } |
|
| 121 | - $k = ''; |
|
| 122 | - break; |
|
| 123 | - case 'session_timeout': |
|
| 124 | - $mail_check_timeperiod = $data['mail_check_timeperiod']; |
|
| 125 | - $v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | - break; |
|
| 127 | - default: |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - $v = is_array($v) ? implode(",", $v) : $v; |
|
| 115 | + $v = str_replace(array(' ,', ', '), ',', $v); |
|
| 116 | + if ($v !== ',') { |
|
| 117 | + $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
|
| 118 | + $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | + @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 120 | + } |
|
| 121 | + $k = ''; |
|
| 122 | + break; |
|
| 123 | + case 'session_timeout': |
|
| 124 | + $mail_check_timeperiod = $data['mail_check_timeperiod']; |
|
| 125 | + $v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | + break; |
|
| 127 | + default: |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + $v = is_array($v) ? implode(",", $v) : $v; |
|
| 131 | 131 | |
| 132 | - $modx->config[$k] = $v; |
|
| 132 | + $modx->config[$k] = $v; |
|
| 133 | 133 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | - } |
|
| 134 | + if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - // Run a single query to save all the values |
|
| 138 | - $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) |
|
| 137 | + // Run a single query to save all the values |
|
| 138 | + $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) |
|
| 139 | 139 | VALUES ".implode(', ', $savethese); |
| 140 | - $modx->db->query($sql); |
|
| 140 | + $modx->db->query($sql); |
|
| 141 | 141 | |
| 142 | - // Reset Template Pages |
|
| 143 | - if (isset($data['reset_template'])) { |
|
| 144 | - $newtemplate = (int)$data['default_template']; |
|
| 145 | - $oldtemplate = (int)$data['old_template']; |
|
| 146 | - $tbl = $modx->getFullTableName('site_content'); |
|
| 147 | - $reset = $data['reset_template']; |
|
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | - } |
|
| 142 | + // Reset Template Pages |
|
| 143 | + if (isset($data['reset_template'])) { |
|
| 144 | + $newtemplate = (int)$data['default_template']; |
|
| 145 | + $oldtemplate = (int)$data['old_template']; |
|
| 146 | + $tbl = $modx->getFullTableName('site_content'); |
|
| 147 | + $reset = $data['reset_template']; |
|
| 148 | + if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | + else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - // empty cache |
|
| 153 | - $modx->clearCache('full'); |
|
| 152 | + // empty cache |
|
| 153 | + $modx->clearCache('full'); |
|
| 154 | 154 | } |
| 155 | 155 | $header="Location: index.php?a=7&r=10"; |
| 156 | 156 | header($header); |
@@ -1,46 +1,46 @@ 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('settings')) { |
|
| 5 | +if (!$modx->hasPermission('settings')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | $data = $_POST; |
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
| 10 | 10 | unset($_POST); |
| 11 | 11 | |
| 12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
| 12 | +if ($data['friendly_urls'] === '1' && strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') === false) |
|
| 13 | 13 | { |
| 14 | - $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | - $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | - $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | - if(is_file($htaccess)) |
|
| 14 | + $htaccess = $modx->config['base_path'].'.htaccess'; |
|
| 15 | + $sample_htaccess = $modx->config['base_path'].'ht.access'; |
|
| 16 | + $dir = '/'.trim($modx->config['base_url'], '/'); |
|
| 17 | + if (is_file($htaccess)) |
|
| 18 | 18 | { |
| 19 | 19 | $_ = file_get_contents($htaccess); |
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 20 | + if (strpos($_, 'RewriteBase') === false) |
|
| 21 | 21 | { |
| 22 | 22 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 23 | 23 | } |
| 24 | - elseif(is_writable($htaccess)) |
|
| 24 | + elseif (is_writable($htaccess)) |
|
| 25 | 25 | { |
| 26 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 26 | + $_ = preg_replace('@RewriteBase.+@', "RewriteBase {$dir}", $_); |
|
| 27 | + if (!@file_put_contents($htaccess, $_)) |
|
| 28 | 28 | { |
| 29 | 29 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 33 | + elseif (is_file($sample_htaccess)) |
|
| 34 | 34 | { |
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 35 | + if (!@rename($sample_htaccess, $htaccess)) |
|
| 36 | 36 | { |
| 37 | 37 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
| 38 | 38 | } |
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 39 | + elseif ($modx->config['base_url'] !== '/') |
|
| 40 | 40 | { |
| 41 | 41 | $_ = file_get_contents($htaccess); |
| 42 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 42 | + $_ = preg_replace('@RewriteBase.+@', "RewriteBase {$dir}", $_); |
|
| 43 | + if (!@file_put_contents($htaccess, $_)) |
|
| 44 | 44 | { |
| 45 | 45 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 46 | 46 | } |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
| 52 | - unlink(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css'); |
|
| 51 | +if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css')) { |
|
| 52 | + unlink(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -$data['filemanager_path'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['filemanager_path']); |
|
| 56 | -$data['rb_base_dir'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['rb_base_dir']); |
|
| 55 | +$data['filemanager_path'] = str_replace('[(base_path)]', MODX_BASE_PATH, $data['filemanager_path']); |
|
| 56 | +$data['rb_base_dir'] = str_replace('[(base_path)]', MODX_BASE_PATH, $data['rb_base_dir']); |
|
| 57 | 57 | |
| 58 | 58 | if (isset($data) && count($data) > 0) { |
| 59 | - if(isset($data['manager_language'])) { |
|
| 60 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | - if(is_file($lang_path)) { |
|
| 59 | + if (isset($data['manager_language'])) { |
|
| 60 | + $lang_path = MODX_MANAGER_PATH.'includes/lang/'.$data['manager_language'].'.inc.php'; |
|
| 61 | + if (is_file($lang_path)) { |
|
| 62 | 62 | include($lang_path); |
| 63 | 63 | global $modx_lang_attribute; |
| 64 | 64 | $data['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | $savethese = array(); |
| 68 | 68 | $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
| 69 | - $data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 69 | + $data['mail_check_timeperiod'] = (int) $data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | 70 | foreach ($data as $k => $v) { |
| 71 | 71 | switch ($k) { |
| 72 | 72 | case 'settings_version':{ |
| 73 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
| 74 | - $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
|
| 73 | + if ($modx->getVersionData('version') != $data['settings_version']) { |
|
| 74 | + $modx->logEvent(17, 2, '<pre>'.var_export($data['settings_version'], true).'</pre>', 'fake settings_version'); |
|
| 75 | 75 | $v = $modx->getVersionData('version'); |
| 76 | 76 | } |
| 77 | 77 | break; |
@@ -92,21 +92,21 @@ discard block |
||
| 92 | 92 | case 'rb_base_url': |
| 93 | 93 | case 'filemanager_path': |
| 94 | 94 | $v = trim($v); |
| 95 | - $v = rtrim($v,'/') . '/'; |
|
| 95 | + $v = rtrim($v, '/').'/'; |
|
| 96 | 96 | break; |
| 97 | 97 | case 'manager_language': |
| 98 | - $langDir = realpath(MODX_MANAGER_PATH . 'includes/lang'); |
|
| 99 | - $langFile = realpath(MODX_MANAGER_PATH . 'includes/lang/' . $v . '.inc.php'); |
|
| 98 | + $langDir = realpath(MODX_MANAGER_PATH.'includes/lang'); |
|
| 99 | + $langFile = realpath(MODX_MANAGER_PATH.'includes/lang/'.$v.'.inc.php'); |
|
| 100 | 100 | $langFileDir = dirname($langFile); |
| 101 | - if($langDir !== $langFileDir || !file_exists($langFile)) { |
|
| 101 | + if ($langDir !== $langFileDir || !file_exists($langFile)) { |
|
| 102 | 102 | $v = 'english'; |
| 103 | 103 | } |
| 104 | 104 | break; |
| 105 | 105 | case 'smtppw': |
| 106 | 106 | if ($v !== '********************' && $v !== '') { |
| 107 | 107 | $v = trim($v); |
| 108 | - $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | - $v = str_replace('=','%',$v); |
|
| 108 | + $v = base64_encode($v).substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | + $v = str_replace('=', '%', $v); |
|
| 110 | 110 | } elseif ($v === '********************') { |
| 111 | 111 | $k = ''; |
| 112 | 112 | } |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | $v = str_replace(array(' ,', ', '), ',', $v); |
| 116 | 116 | if ($v !== ',') { |
| 117 | 117 | $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
| 118 | - $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | - @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 118 | + $configString = '<?php'."\n".'define(\'MODX_SITE_HOSTNAMES\', \''.$v.'\');'."\n"; |
|
| 119 | + @file_put_contents(MODX_BASE_PATH.'assets/cache/siteHostnames.php', $configString); |
|
| 120 | 120 | } |
| 121 | 121 | $k = ''; |
| 122 | 122 | break; |
| 123 | 123 | case 'session_timeout': |
| 124 | 124 | $mail_check_timeperiod = $data['mail_check_timeperiod']; |
| 125 | - $v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 125 | + $v = (int) $v < ($data['mail_check_timeperiod'] / 60 + 1) ? ($data['mail_check_timeperiod'] / 60 + 1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | 126 | break; |
| 127 | 127 | default: |
| 128 | 128 | break; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $modx->config[$k] = $v; |
| 133 | 133 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 134 | + if (!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Run a single query to save all the values |
@@ -141,16 +141,16 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | // Reset Template Pages |
| 143 | 143 | if (isset($data['reset_template'])) { |
| 144 | - $newtemplate = (int)$data['default_template']; |
|
| 145 | - $oldtemplate = (int)$data['old_template']; |
|
| 144 | + $newtemplate = (int) $data['default_template']; |
|
| 145 | + $oldtemplate = (int) $data['old_template']; |
|
| 146 | 146 | $tbl = $modx->getFullTableName('site_content'); |
| 147 | 147 | $reset = $data['reset_template']; |
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 148 | + if ($reset == 1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | + else if ($reset == 2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // empty cache |
| 153 | 153 | $modx->clearCache('full'); |
| 154 | 154 | } |
| 155 | -$header="Location: index.php?a=7&r=10"; |
|
| 155 | +$header = "Location: index.php?a=7&r=10"; |
|
| 156 | 156 | header($header); |
@@ -9,39 +9,27 @@ discard block |
||
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
| 10 | 10 | unset($_POST); |
| 11 | 11 | |
| 12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
| 13 | -{ |
|
| 12 | +if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) { |
|
| 14 | 13 | $htaccess = $modx->config['base_path'] . '.htaccess'; |
| 15 | 14 | $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
| 16 | 15 | $dir = '/' . trim($modx->config['base_url'],'/'); |
| 17 | - if(is_file($htaccess)) |
|
| 18 | - { |
|
| 16 | + if(is_file($htaccess)) { |
|
| 19 | 17 | $_ = file_get_contents($htaccess); |
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 21 | - { |
|
| 18 | + if(strpos($_,'RewriteBase')===false) { |
|
| 22 | 19 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 23 | - } |
|
| 24 | - elseif(is_writable($htaccess)) |
|
| 25 | - { |
|
| 20 | + } elseif(is_writable($htaccess)) { |
|
| 26 | 21 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 28 | - { |
|
| 22 | + if(!@file_put_contents($htaccess,$_)) { |
|
| 29 | 23 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 30 | 24 | } |
| 31 | 25 | } |
| 32 | - } |
|
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 34 | - { |
|
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 36 | - { |
|
| 26 | + } elseif(is_file($sample_htaccess)) { |
|
| 27 | + if(!@rename($sample_htaccess,$htaccess)) { |
|
| 37 | 28 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
| 38 | - } |
|
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 40 | - { |
|
| 29 | + } elseif($modx->config['base_url']!=='/') { |
|
| 41 | 30 | $_ = file_get_contents($htaccess); |
| 42 | 31 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 44 | - { |
|
| 32 | + if(!@file_put_contents($htaccess,$_)) { |
|
| 45 | 33 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 46 | 34 | } |
| 47 | 35 | } |
@@ -70,7 +58,7 @@ discard block |
||
| 70 | 58 | foreach ($data as $k => $v) { |
| 71 | 59 | switch ($k) { |
| 72 | 60 | case 'settings_version':{ |
| 73 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
| 61 | + if($modx->getVersionData('version')!=$data['settings_version']) { |
|
| 74 | 62 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
| 75 | 63 | $v = $modx->getVersionData('version'); |
| 76 | 64 | } |
@@ -131,7 +119,9 @@ discard block |
||
| 131 | 119 | |
| 132 | 120 | $modx->config[$k] = $v; |
| 133 | 121 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 122 | + if(!empty($k)) { |
|
| 123 | + $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 124 | + } |
|
| 135 | 125 | } |
| 136 | 126 | |
| 137 | 127 | // Run a single query to save all the values |
@@ -145,8 +135,11 @@ discard block |
||
| 145 | 135 | $oldtemplate = (int)$data['old_template']; |
| 146 | 136 | $tbl = $modx->getFullTableName('site_content'); |
| 147 | 137 | $reset = $data['reset_template']; |
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 138 | + if($reset==1) { |
|
| 139 | + $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 140 | + } else if($reset==2) { |
|
| 141 | + $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 142 | + } |
|
| 150 | 143 | } |
| 151 | 144 | |
| 152 | 145 | // empty cache |