@@ -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_plugin')) { |
| 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 | $locked = $_POST['locked'] == 'on' ? '1' : '0'; |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | //Kyle Jaebker - added category support |
| 22 | 22 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
| 23 | - $categoryid = (int)$_POST['categoryid']; |
|
| 23 | + $categoryid = (int) $_POST['categoryid']; |
|
| 24 | 24 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
| 25 | 25 | $categoryid = 0; |
| 26 | 26 | } else { |
| 27 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 27 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 28 | 28 | $categoryid = getCategory($_POST['newcategory']); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; |
| 41 | 41 | |
| 42 | 42 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
| 43 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
| 43 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
| 44 | 44 | if ($version) { |
| 45 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 45 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($parsed['modx_category'])) { |
| 48 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 48 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 49 | 49 | $categoryid = getCategory($parsed['modx_category']); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | // finished emptying cache - redirect |
| 104 | 104 | if ($_POST['stay'] != '') { |
| 105 | 105 | $a = ($_POST['stay'] == '2') ? "102&id=$newid" : '101'; |
| 106 | - $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay']; |
|
| 106 | + $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay']; |
|
| 107 | 107 | header($header); |
| 108 | 108 | } else { |
| 109 | 109 | $header = 'Location: index.php?a=76&r=2'; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // finished emptying cache - redirect |
| 159 | 159 | if ($_POST['stay'] != '') { |
| 160 | 160 | $a = ($_POST['stay'] == '2') ? "102&id=$id" : '101'; |
| 161 | - $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay']; |
|
| 161 | + $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay']; |
|
| 162 | 162 | header($header); |
| 163 | 163 | } else { |
| 164 | 164 | $modx->unlockElement(5, $id); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $modx->webAlertAndQuit('No operation set in request.'); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -if(!function_exists('saveEventListeners')) { |
|
| 173 | +if (!function_exists('saveEventListeners')) { |
|
| 174 | 174 | # Save Plugin Event Listeners |
| 175 | 175 | function saveEventListeners($id, $sysevents, $mode) |
| 176 | 176 | { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | -if(!function_exists('getEventIdByName')) { |
|
| 226 | +if (!function_exists('getEventIdByName')) { |
|
| 227 | 227 | /** |
| 228 | 228 | * @param string $name |
| 229 | 229 | * @return string|int |
@@ -1,25 +1,25 @@ 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 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $udperms->document = $id; |
| 32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
| 33 | 33 | |
| 34 | -if(!$udperms->checkPermissions()) { |
|
| 34 | +if (!$udperms->checkPermissions()) { |
|
| 35 | 35 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
| 49 | 49 | |
| 50 | 50 | // invoke OnDocPublished event |
| 51 | -$modx->invokeEvent("OnDocPublished",array("docid"=>$id)); |
|
| 51 | +$modx->invokeEvent("OnDocPublished", array("docid"=>$id)); |
|
| 52 | 52 | |
| 53 | 53 | // Set the item name for logger |
| 54 | 54 | $_SESSION['itemname'] = $content['pagetitle']; |
@@ -56,6 +56,6 @@ discard block |
||
| 56 | 56 | // empty cache |
| 57 | 57 | $modx->clearCache('full'); |
| 58 | 58 | |
| 59 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 59 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 60 | 60 | |
| 61 | 61 | header($header); |
@@ -33,115 +33,115 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | switch ($_POST['mode']) { |
| 36 | - case '19': |
|
| 37 | - |
|
| 38 | - // invoke OnBeforeTempFormSave event |
|
| 39 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | - "mode" => "new", |
|
| 41 | - "id" => $id |
|
| 42 | - )); |
|
| 43 | - |
|
| 44 | - // disallow duplicate names for new templates |
|
| 45 | - $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | - $count = $modx->db->getValue($rs); |
|
| 47 | - if ($count > 0) { |
|
| 48 | - $modx->manager->saveFormValues(19); |
|
| 49 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
| 50 | - } |
|
| 36 | + case '19': |
|
| 37 | + |
|
| 38 | + // invoke OnBeforeTempFormSave event |
|
| 39 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | + "mode" => "new", |
|
| 41 | + "id" => $id |
|
| 42 | + )); |
|
| 43 | + |
|
| 44 | + // disallow duplicate names for new templates |
|
| 45 | + $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | + $count = $modx->db->getValue($rs); |
|
| 47 | + if ($count > 0) { |
|
| 48 | + $modx->manager->saveFormValues(19); |
|
| 49 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - //do stuff to save the new doc |
|
| 53 | - $newid = $modx->db->insert(array( |
|
| 54 | - 'templatename' => $templatename, |
|
| 55 | - 'description' => $description, |
|
| 56 | - 'content' => $template, |
|
| 57 | - 'locked' => $locked, |
|
| 58 | - 'selectable' => $selectable, |
|
| 59 | - 'category' => $categoryid, |
|
| 60 | - 'createdon' => $currentdate, |
|
| 61 | - 'editedon' => $currentdate |
|
| 62 | - ), $modx->getFullTableName('site_templates')); |
|
| 63 | - |
|
| 64 | - // invoke OnTempFormSave event |
|
| 65 | - $modx->invokeEvent("OnTempFormSave", array( |
|
| 66 | - "mode" => "new", |
|
| 67 | - "id" => $newid |
|
| 68 | - )); |
|
| 69 | - // Set new assigned Tvs |
|
| 70 | - saveTemplateAccess($newid); |
|
| 71 | - |
|
| 72 | - // Set the item name for logger |
|
| 73 | - $_SESSION['itemname'] = $templatename; |
|
| 74 | - |
|
| 75 | - // empty cache |
|
| 76 | - $modx->clearCache('full'); |
|
| 77 | - |
|
| 78 | - // finished emptying cache - redirect |
|
| 79 | - if ($_POST['stay'] != '') { |
|
| 80 | - $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
| 81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 82 | - header($header); |
|
| 83 | - } else { |
|
| 84 | - $header = "Location: index.php?a=76&r=2"; |
|
| 85 | - header($header); |
|
| 86 | - } |
|
| 52 | + //do stuff to save the new doc |
|
| 53 | + $newid = $modx->db->insert(array( |
|
| 54 | + 'templatename' => $templatename, |
|
| 55 | + 'description' => $description, |
|
| 56 | + 'content' => $template, |
|
| 57 | + 'locked' => $locked, |
|
| 58 | + 'selectable' => $selectable, |
|
| 59 | + 'category' => $categoryid, |
|
| 60 | + 'createdon' => $currentdate, |
|
| 61 | + 'editedon' => $currentdate |
|
| 62 | + ), $modx->getFullTableName('site_templates')); |
|
| 63 | + |
|
| 64 | + // invoke OnTempFormSave event |
|
| 65 | + $modx->invokeEvent("OnTempFormSave", array( |
|
| 66 | + "mode" => "new", |
|
| 67 | + "id" => $newid |
|
| 68 | + )); |
|
| 69 | + // Set new assigned Tvs |
|
| 70 | + saveTemplateAccess($newid); |
|
| 71 | + |
|
| 72 | + // Set the item name for logger |
|
| 73 | + $_SESSION['itemname'] = $templatename; |
|
| 74 | + |
|
| 75 | + // empty cache |
|
| 76 | + $modx->clearCache('full'); |
|
| 77 | + |
|
| 78 | + // finished emptying cache - redirect |
|
| 79 | + if ($_POST['stay'] != '') { |
|
| 80 | + $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
| 81 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 82 | + header($header); |
|
| 83 | + } else { |
|
| 84 | + $header = "Location: index.php?a=76&r=2"; |
|
| 85 | + header($header); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - break; |
|
| 89 | - case '16': |
|
| 90 | - |
|
| 91 | - // invoke OnBeforeTempFormSave event |
|
| 92 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 93 | - "mode" => "upd", |
|
| 94 | - "id" => $id |
|
| 95 | - )); |
|
| 96 | - |
|
| 97 | - // disallow duplicate names for templates |
|
| 98 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | - $count = $modx->db->getValue($rs); |
|
| 100 | - if ($count > 0) { |
|
| 101 | - $modx->manager->saveFormValues(16); |
|
| 102 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
| 103 | - } |
|
| 88 | + break; |
|
| 89 | + case '16': |
|
| 90 | + |
|
| 91 | + // invoke OnBeforeTempFormSave event |
|
| 92 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 93 | + "mode" => "upd", |
|
| 94 | + "id" => $id |
|
| 95 | + )); |
|
| 96 | + |
|
| 97 | + // disallow duplicate names for templates |
|
| 98 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | + $count = $modx->db->getValue($rs); |
|
| 100 | + if ($count > 0) { |
|
| 101 | + $modx->manager->saveFormValues(16); |
|
| 102 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - //do stuff to save the edited doc |
|
| 106 | - $modx->db->update(array( |
|
| 107 | - 'templatename' => $templatename, |
|
| 108 | - 'description' => $description, |
|
| 109 | - 'content' => $template, |
|
| 110 | - 'locked' => $locked, |
|
| 111 | - 'selectable' => $selectable, |
|
| 112 | - 'category' => $categoryid, |
|
| 113 | - 'editedon' => $currentdate |
|
| 114 | - ), $modx->getFullTableName('site_templates'), "id='{$id}'"); |
|
| 115 | - // Set new assigned Tvs |
|
| 116 | - saveTemplateAccess($id); |
|
| 117 | - |
|
| 118 | - // invoke OnTempFormSave event |
|
| 119 | - $modx->invokeEvent("OnTempFormSave", array( |
|
| 120 | - "mode" => "upd", |
|
| 121 | - "id" => $id |
|
| 122 | - )); |
|
| 123 | - |
|
| 124 | - // Set the item name for logger |
|
| 125 | - $_SESSION['itemname'] = $templatename; |
|
| 126 | - |
|
| 127 | - // first empty the cache |
|
| 128 | - $modx->clearCache('full'); |
|
| 129 | - |
|
| 130 | - // finished emptying cache - redirect |
|
| 131 | - if ($_POST['stay'] != '') { |
|
| 132 | - $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
| 133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 134 | - header($header); |
|
| 135 | - } else { |
|
| 136 | - $modx->unlockElement(1, $id); |
|
| 137 | - $header = "Location: index.php?a=76&r=2"; |
|
| 138 | - header($header); |
|
| 139 | - } |
|
| 105 | + //do stuff to save the edited doc |
|
| 106 | + $modx->db->update(array( |
|
| 107 | + 'templatename' => $templatename, |
|
| 108 | + 'description' => $description, |
|
| 109 | + 'content' => $template, |
|
| 110 | + 'locked' => $locked, |
|
| 111 | + 'selectable' => $selectable, |
|
| 112 | + 'category' => $categoryid, |
|
| 113 | + 'editedon' => $currentdate |
|
| 114 | + ), $modx->getFullTableName('site_templates'), "id='{$id}'"); |
|
| 115 | + // Set new assigned Tvs |
|
| 116 | + saveTemplateAccess($id); |
|
| 117 | + |
|
| 118 | + // invoke OnTempFormSave event |
|
| 119 | + $modx->invokeEvent("OnTempFormSave", array( |
|
| 120 | + "mode" => "upd", |
|
| 121 | + "id" => $id |
|
| 122 | + )); |
|
| 123 | + |
|
| 124 | + // Set the item name for logger |
|
| 125 | + $_SESSION['itemname'] = $templatename; |
|
| 126 | + |
|
| 127 | + // first empty the cache |
|
| 128 | + $modx->clearCache('full'); |
|
| 129 | + |
|
| 130 | + // finished emptying cache - redirect |
|
| 131 | + if ($_POST['stay'] != '') { |
|
| 132 | + $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
| 133 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 134 | + header($header); |
|
| 135 | + } else { |
|
| 136 | + $modx->unlockElement(1, $id); |
|
| 137 | + $header = "Location: index.php?a=76&r=2"; |
|
| 138 | + header($header); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | - break; |
|
| 143 | - default: |
|
| 144 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 142 | + break; |
|
| 143 | + default: |
|
| 144 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if(!function_exists('saveTemplateAccess')) { |
@@ -1,27 +1,27 @@ 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 | $template = $modx->db->escape($_POST['post']); |
| 11 | 11 | $templatename = $modx->db->escape(trim($_POST['templatename'])); |
| 12 | 12 | $description = $modx->db->escape($_POST['description']); |
| 13 | 13 | $locked = $_POST['locked'] == 'on' ? 1 : 0; |
| 14 | -$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
| 14 | +$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
| 15 | 15 | $_POST['selectable'] == 'on' ? 1 : 0; |
| 16 | 16 | $currentdate = time() + $modx->config['server_offset_time']; |
| 17 | 17 | |
| 18 | 18 | //Kyle Jaebker - added category support |
| 19 | 19 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
| 20 | - $categoryid = (int)$_POST['categoryid']; |
|
| 20 | + $categoryid = (int) $_POST['categoryid']; |
|
| 21 | 21 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
| 22 | 22 | $categoryid = 0; |
| 23 | 23 | } else { |
| 24 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 24 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 25 | 25 | $categoryid = checkCategory($_POST['newcategory']); |
| 26 | 26 | if (!$categoryid) { |
| 27 | 27 | $categoryid = newCategory($_POST['newcategory']); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | // finished emptying cache - redirect |
| 79 | 79 | if ($_POST['stay'] != '') { |
| 80 | 80 | $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
| 81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 81 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 82 | 82 | header($header); |
| 83 | 83 | } else { |
| 84 | 84 | $header = "Location: index.php?a=76&r=2"; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | // finished emptying cache - redirect |
| 131 | 131 | if ($_POST['stay'] != '') { |
| 132 | 132 | $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
| 133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 133 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 134 | 134 | header($header); |
| 135 | 135 | } else { |
| 136 | 136 | $modx->unlockElement(1, $id); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $modx->webAlertAndQuit("No operation set in request."); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -if(!function_exists('saveTemplateAccess')) { |
|
| 147 | +if (!function_exists('saveTemplateAccess')) { |
|
| 148 | 148 | /** |
| 149 | 149 | * @param int $id |
| 150 | 150 | */ |
@@ -1,25 +1,25 @@ 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 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $udperms->document = $id; |
| 32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
| 33 | 33 | |
| 34 | -if(!$udperms->checkPermissions()) { |
|
| 34 | +if (!$udperms->checkPermissions()) { |
|
| 35 | 35 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
| 49 | 49 | |
| 50 | 50 | // invoke OnDocUnPublished event |
| 51 | -$modx->invokeEvent("OnDocUnPublished",array("docid"=>$id)); |
|
| 51 | +$modx->invokeEvent("OnDocUnPublished", array("docid"=>$id)); |
|
| 52 | 52 | |
| 53 | 53 | // Set the item name for logger |
| 54 | 54 | $_SESSION['itemname'] = $content['pagetitle']; |
@@ -56,6 +56,6 @@ discard block |
||
| 56 | 56 | // empty cache |
| 57 | 57 | $modx->clearCache('full'); |
| 58 | 58 | |
| 59 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 59 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 60 | 60 | |
| 61 | 61 | 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,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 | if(!function_exists('sendMailMessage')) { |
@@ -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 | if(!function_exists('sendMailMessage')) { |
@@ -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"; |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | webAlertAndQuit("No operation set in request."); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | -if(!function_exists('sendMailMessage')) { |
|
| 351 | +if (!function_exists('sendMailMessage')) { |
|
| 352 | 352 | /** |
| 353 | 353 | * Send an email to the user |
| 354 | 354 | * |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | -if(!function_exists('saveUserSettings')) { |
|
| 391 | +if (!function_exists('saveUserSettings')) { |
|
| 392 | 392 | /** |
| 393 | 393 | * Save User Settings |
| 394 | 394 | * |
@@ -456,10 +456,10 @@ discard block |
||
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | foreach ($defaults as $k) { |
| 459 | - if (isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 459 | + if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') { |
|
| 460 | 460 | unset($settings[$k]); |
| 461 | 461 | } |
| 462 | - unset($settings['default_' . $k]); |
|
| 462 | + unset($settings['default_'.$k]); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | -if(!function_exists('webAlertAndQuit')) { |
|
| 483 | +if (!function_exists('webAlertAndQuit')) { |
|
| 484 | 484 | /** |
| 485 | 485 | * Web alert - sends an alert to web browser |
| 486 | 486 | * |
@@ -491,11 +491,11 @@ discard block |
||
| 491 | 491 | global $id, $modx; |
| 492 | 492 | $mode = $_POST['mode']; |
| 493 | 493 | $modx->manager->saveFormValues($mode); |
| 494 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 494 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : '')); |
|
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | -if(!function_exists('generate_password')) { |
|
| 498 | +if (!function_exists('generate_password')) { |
|
| 499 | 499 | /** |
| 500 | 500 | * Generate password |
| 501 | 501 | * |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | { |
| 507 | 507 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 508 | 508 | $ps_len = strlen($allowable_characters); |
| 509 | - mt_srand((double)microtime() * 1000000); |
|
| 509 | + mt_srand((double) microtime() * 1000000); |
|
| 510 | 510 | $pass = ""; |
| 511 | 511 | for ($i = 0; $i < $length; $i++) { |
| 512 | 512 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
@@ -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_module')) { |
| 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 | if(!function_exists('createGUID')) { |
@@ -36,40 +36,40 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | // duplicate module |
| 38 | 38 | $newid = $modx->db->insert( |
| 39 | - array( |
|
| 40 | - 'name'=>'', |
|
| 41 | - 'description'=>'', |
|
| 42 | - 'disabled'=>'', |
|
| 43 | - 'category'=>'', |
|
| 44 | - 'wrap'=>'', |
|
| 45 | - 'icon'=>'', |
|
| 46 | - 'enable_resource'=>'', |
|
| 47 | - 'resourcefile'=>'', |
|
| 48 | - 'createdon'=>'', |
|
| 49 | - 'editedon'=>'', |
|
| 50 | - 'guid'=>'', |
|
| 51 | - 'enable_sharedparams'=>'', |
|
| 52 | - 'properties'=>'', |
|
| 53 | - 'modulecode'=>'', |
|
| 54 | - ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 55 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
| 39 | + array( |
|
| 40 | + 'name'=>'', |
|
| 41 | + 'description'=>'', |
|
| 42 | + 'disabled'=>'', |
|
| 43 | + 'category'=>'', |
|
| 44 | + 'wrap'=>'', |
|
| 45 | + 'icon'=>'', |
|
| 46 | + 'enable_resource'=>'', |
|
| 47 | + 'resourcefile'=>'', |
|
| 48 | + 'createdon'=>'', |
|
| 49 | + 'editedon'=>'', |
|
| 50 | + 'guid'=>'', |
|
| 51 | + 'enable_sharedparams'=>'', |
|
| 52 | + 'properties'=>'', |
|
| 53 | + 'modulecode'=>'', |
|
| 54 | + ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 55 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
| 56 | 56 | |
| 57 | 57 | // duplicate module dependencies |
| 58 | 58 | $modx->db->insert( |
| 59 | - array( |
|
| 60 | - 'module'=>'', |
|
| 61 | - 'resource'=>'', |
|
| 62 | - 'type'=>'', |
|
| 63 | - ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 64 | - "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 59 | + array( |
|
| 60 | + 'module'=>'', |
|
| 61 | + 'resource'=>'', |
|
| 62 | + 'type'=>'', |
|
| 63 | + ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 64 | + "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 65 | 65 | |
| 66 | 66 | // duplicate module user group access |
| 67 | 67 | $modx->db->insert( |
| 68 | - array( |
|
| 69 | - 'module'=>'', |
|
| 70 | - 'usergroup'=>'', |
|
| 71 | - ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 72 | - "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 68 | + array( |
|
| 69 | + 'module'=>'', |
|
| 70 | + 'usergroup'=>'', |
|
| 71 | + ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 72 | + "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 73 | 73 | |
| 74 | 74 | // Set the item name for logger |
| 75 | 75 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'")); |
@@ -1,17 +1,17 @@ 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_module')) { |
|
| 5 | +if (!$modx->hasPermission('new_module')) { |
|
| 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 | -if(!function_exists('createGUID')) { |
|
| 14 | +if (!function_exists('createGUID')) { |
|
| 15 | 15 | /** |
| 16 | 16 | * create globally unique identifiers (guid) |
| 17 | 17 | * |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function createGUID() |
| 21 | 21 | { |
| 22 | - srand((double)microtime() * 1000000); |
|
| 22 | + srand((double) microtime() * 1000000); |
|
| 23 | 23 | $r = rand(); |
| 24 | - $u = uniqid(getmypid() . $r . (double)microtime() * 1000000, 1); |
|
| 24 | + $u = uniqid(getmypid().$r.(double) microtime() * 1000000, 1); |
|
| 25 | 25 | $m = md5($u); |
| 26 | 26 | |
| 27 | 27 | return $m; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | // count duplicates |
| 32 | 32 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
| 33 | 33 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 34 | -if($count>=1) $count = ' '.($count+1); |
|
| 34 | +if ($count >= 1) $count = ' '.($count + 1); |
|
| 35 | 35 | else $count = ''; |
| 36 | 36 | |
| 37 | 37 | // duplicate module |
@@ -76,5 +76,5 @@ discard block |
||
| 76 | 76 | $_SESSION['itemname'] = $name; |
| 77 | 77 | |
| 78 | 78 | // finish duplicating - redirect to new module |
| 79 | -$header="Location: index.php?r=2&a=108&id=$newid"; |
|
| 79 | +$header = "Location: index.php?r=2&a=108&id=$newid"; |
|
| 80 | 80 | header($header); |
@@ -31,8 +31,11 @@ |
||
| 31 | 31 | // count duplicates |
| 32 | 32 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
| 33 | 33 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 34 | -if($count>=1) $count = ' '.($count+1); |
|
| 35 | -else $count = ''; |
|
| 34 | +if($count>=1) { |
|
| 35 | + $count = ' '.($count+1); |
|
| 36 | +} else { |
|
| 37 | + $count = ''; |
|
| 38 | +} |
|
| 36 | 39 | |
| 37 | 40 | // duplicate module |
| 38 | 41 | $newid = $modx->db->insert( |
@@ -59,125 +59,125 @@ |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | switch ($_POST['mode']) { |
| 62 | - case '107': |
|
| 63 | - // invoke OnBeforeModFormSave event |
|
| 64 | - $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 65 | - "mode" => "new", |
|
| 66 | - "id" => $id |
|
| 67 | - )); |
|
| 68 | - |
|
| 69 | - // disallow duplicate names for new modules |
|
| 70 | - $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | - $count = $modx->db->getValue($rs); |
|
| 72 | - if ($count > 0) { |
|
| 73 | - $modx->manager->saveFormValues(107); |
|
| 74 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | - } |
|
| 62 | + case '107': |
|
| 63 | + // invoke OnBeforeModFormSave event |
|
| 64 | + $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 65 | + "mode" => "new", |
|
| 66 | + "id" => $id |
|
| 67 | + )); |
|
| 68 | + |
|
| 69 | + // disallow duplicate names for new modules |
|
| 70 | + $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | + $count = $modx->db->getValue($rs); |
|
| 72 | + if ($count > 0) { |
|
| 73 | + $modx->manager->saveFormValues(107); |
|
| 74 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - // save the new module |
|
| 78 | - $newid = $modx->db->insert(array( |
|
| 79 | - 'name' => $name, |
|
| 80 | - 'description' => $description, |
|
| 81 | - 'disabled' => $disabled, |
|
| 82 | - 'wrap' => $wrap, |
|
| 83 | - 'locked' => $locked, |
|
| 84 | - 'icon' => $icon, |
|
| 85 | - 'resourcefile' => $resourcefile, |
|
| 86 | - 'enable_resource' => $enable_resource, |
|
| 87 | - 'category' => $categoryid, |
|
| 88 | - 'enable_sharedparams' => $enable_sharedparams, |
|
| 89 | - 'guid' => $guid, |
|
| 90 | - 'modulecode' => $modulecode, |
|
| 91 | - 'properties' => $properties, |
|
| 92 | - 'createdon' => $currentdate, |
|
| 93 | - 'editedon' => $currentdate |
|
| 94 | - ), $modx->getFullTableName('site_modules')); |
|
| 95 | - |
|
| 96 | - // save user group access permissions |
|
| 97 | - saveUserGroupAccessPermissons(); |
|
| 98 | - |
|
| 99 | - // invoke OnModFormSave event |
|
| 100 | - $modx->invokeEvent("OnModFormSave", array( |
|
| 101 | - "mode" => "new", |
|
| 102 | - "id" => $newid |
|
| 103 | - )); |
|
| 104 | - |
|
| 105 | - // Set the item name for logger |
|
| 106 | - $_SESSION['itemname'] = $name; |
|
| 107 | - |
|
| 108 | - // empty cache |
|
| 109 | - $modx->clearCache('full'); |
|
| 110 | - |
|
| 111 | - // finished emptying cache - redirect |
|
| 112 | - if ($_POST['stay'] != '') { |
|
| 113 | - $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
|
| 114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 115 | - header($header); |
|
| 116 | - } else { |
|
| 117 | - $header = "Location: index.php?a=106&r=2"; |
|
| 118 | - header($header); |
|
| 119 | - } |
|
| 120 | - break; |
|
| 121 | - case '108': |
|
| 122 | - // invoke OnBeforeModFormSave event |
|
| 123 | - $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 124 | - "mode" => "upd", |
|
| 125 | - "id" => $id |
|
| 126 | - )); |
|
| 127 | - |
|
| 128 | - // disallow duplicate names for new modules |
|
| 129 | - $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | - if ($modx->db->getValue($rs) > 0) { |
|
| 131 | - $modx->manager->saveFormValues(108); |
|
| 132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | - } |
|
| 77 | + // save the new module |
|
| 78 | + $newid = $modx->db->insert(array( |
|
| 79 | + 'name' => $name, |
|
| 80 | + 'description' => $description, |
|
| 81 | + 'disabled' => $disabled, |
|
| 82 | + 'wrap' => $wrap, |
|
| 83 | + 'locked' => $locked, |
|
| 84 | + 'icon' => $icon, |
|
| 85 | + 'resourcefile' => $resourcefile, |
|
| 86 | + 'enable_resource' => $enable_resource, |
|
| 87 | + 'category' => $categoryid, |
|
| 88 | + 'enable_sharedparams' => $enable_sharedparams, |
|
| 89 | + 'guid' => $guid, |
|
| 90 | + 'modulecode' => $modulecode, |
|
| 91 | + 'properties' => $properties, |
|
| 92 | + 'createdon' => $currentdate, |
|
| 93 | + 'editedon' => $currentdate |
|
| 94 | + ), $modx->getFullTableName('site_modules')); |
|
| 95 | + |
|
| 96 | + // save user group access permissions |
|
| 97 | + saveUserGroupAccessPermissons(); |
|
| 98 | + |
|
| 99 | + // invoke OnModFormSave event |
|
| 100 | + $modx->invokeEvent("OnModFormSave", array( |
|
| 101 | + "mode" => "new", |
|
| 102 | + "id" => $newid |
|
| 103 | + )); |
|
| 104 | + |
|
| 105 | + // Set the item name for logger |
|
| 106 | + $_SESSION['itemname'] = $name; |
|
| 107 | + |
|
| 108 | + // empty cache |
|
| 109 | + $modx->clearCache('full'); |
|
| 110 | + |
|
| 111 | + // finished emptying cache - redirect |
|
| 112 | + if ($_POST['stay'] != '') { |
|
| 113 | + $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
|
| 114 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 115 | + header($header); |
|
| 116 | + } else { |
|
| 117 | + $header = "Location: index.php?a=106&r=2"; |
|
| 118 | + header($header); |
|
| 119 | + } |
|
| 120 | + break; |
|
| 121 | + case '108': |
|
| 122 | + // invoke OnBeforeModFormSave event |
|
| 123 | + $modx->invokeEvent("OnBeforeModFormSave", array( |
|
| 124 | + "mode" => "upd", |
|
| 125 | + "id" => $id |
|
| 126 | + )); |
|
| 127 | + |
|
| 128 | + // disallow duplicate names for new modules |
|
| 129 | + $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | + if ($modx->db->getValue($rs) > 0) { |
|
| 131 | + $modx->manager->saveFormValues(108); |
|
| 132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - // save the edited module |
|
| 136 | - $modx->db->update(array( |
|
| 137 | - 'name' => $name, |
|
| 138 | - 'description' => $description, |
|
| 139 | - 'icon' => $icon, |
|
| 140 | - 'enable_resource' => $enable_resource, |
|
| 141 | - 'resourcefile' => $resourcefile, |
|
| 142 | - 'disabled' => $disabled, |
|
| 143 | - 'wrap' => $wrap, |
|
| 144 | - 'locked' => $locked, |
|
| 145 | - 'category' => $categoryid, |
|
| 146 | - 'enable_sharedparams' => $enable_sharedparams, |
|
| 147 | - 'guid' => $guid, |
|
| 148 | - 'modulecode' => $modulecode, |
|
| 149 | - 'properties' => $properties, |
|
| 150 | - 'editedon' => $currentdate |
|
| 151 | - ), $modx->getFullTableName('site_modules'), "id='{$id}'"); |
|
| 152 | - |
|
| 153 | - // save user group access permissions |
|
| 154 | - saveUserGroupAccessPermissons(); |
|
| 155 | - |
|
| 156 | - // invoke OnModFormSave event |
|
| 157 | - $modx->invokeEvent("OnModFormSave", array( |
|
| 158 | - "mode" => "upd", |
|
| 159 | - "id" => $id |
|
| 160 | - )); |
|
| 161 | - |
|
| 162 | - // Set the item name for logger |
|
| 163 | - $_SESSION['itemname'] = $name; |
|
| 164 | - |
|
| 165 | - // empty cache |
|
| 166 | - $modx->clearCache('full'); |
|
| 167 | - |
|
| 168 | - // finished emptying cache - redirect |
|
| 169 | - if ($_POST['stay'] != '') { |
|
| 170 | - $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
|
| 171 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 172 | - header($header); |
|
| 173 | - } else { |
|
| 174 | - $modx->unlockElement(6, $id); |
|
| 175 | - $header = "Location: index.php?a=106&r=2"; |
|
| 176 | - header($header); |
|
| 177 | - } |
|
| 178 | - break; |
|
| 179 | - default: |
|
| 180 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 135 | + // save the edited module |
|
| 136 | + $modx->db->update(array( |
|
| 137 | + 'name' => $name, |
|
| 138 | + 'description' => $description, |
|
| 139 | + 'icon' => $icon, |
|
| 140 | + 'enable_resource' => $enable_resource, |
|
| 141 | + 'resourcefile' => $resourcefile, |
|
| 142 | + 'disabled' => $disabled, |
|
| 143 | + 'wrap' => $wrap, |
|
| 144 | + 'locked' => $locked, |
|
| 145 | + 'category' => $categoryid, |
|
| 146 | + 'enable_sharedparams' => $enable_sharedparams, |
|
| 147 | + 'guid' => $guid, |
|
| 148 | + 'modulecode' => $modulecode, |
|
| 149 | + 'properties' => $properties, |
|
| 150 | + 'editedon' => $currentdate |
|
| 151 | + ), $modx->getFullTableName('site_modules'), "id='{$id}'"); |
|
| 152 | + |
|
| 153 | + // save user group access permissions |
|
| 154 | + saveUserGroupAccessPermissons(); |
|
| 155 | + |
|
| 156 | + // invoke OnModFormSave event |
|
| 157 | + $modx->invokeEvent("OnModFormSave", array( |
|
| 158 | + "mode" => "upd", |
|
| 159 | + "id" => $id |
|
| 160 | + )); |
|
| 161 | + |
|
| 162 | + // Set the item name for logger |
|
| 163 | + $_SESSION['itemname'] = $name; |
|
| 164 | + |
|
| 165 | + // empty cache |
|
| 166 | + $modx->clearCache('full'); |
|
| 167 | + |
|
| 168 | + // finished emptying cache - redirect |
|
| 169 | + if ($_POST['stay'] != '') { |
|
| 170 | + $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
|
| 171 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 172 | + header($header); |
|
| 173 | + } else { |
|
| 174 | + $modx->unlockElement(6, $id); |
|
| 175 | + $header = "Location: index.php?a=106&r=2"; |
|
| 176 | + header($header); |
|
| 177 | + } |
|
| 178 | + break; |
|
| 179 | + default: |
|
| 180 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if(!function_exists('saveUserGroupAccessPermissons')) { |
@@ -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_module')) { |
| 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 | $resourcefile = $modx->db->escape($_POST['resourcefile']); |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | //Kyle Jaebker - added category support |
| 27 | 27 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
| 28 | - $categoryid = (int)$_POST['categoryid']; |
|
| 28 | + $categoryid = (int) $_POST['categoryid']; |
|
| 29 | 29 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
| 30 | 30 | $categoryid = 0; |
| 31 | 31 | } else { |
| 32 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 32 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 33 | 33 | $categoryid = checkCategory($_POST['newcategory']); |
| 34 | 34 | if (!$categoryid) { |
| 35 | 35 | $categoryid = newCategory($_POST['newcategory']); |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | $name = isset($parsed['name']) ? $parsed['name'] : $name; |
| 46 | 46 | $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; |
| 47 | 47 | $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid; |
| 48 | - $enable_sharedparams = isset($parsed['shareparams']) ? (int)$parsed['shareparams'] : $enable_sharedparams; |
|
| 48 | + $enable_sharedparams = isset($parsed['shareparams']) ? (int) $parsed['shareparams'] : $enable_sharedparams; |
|
| 49 | 49 | |
| 50 | 50 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
| 51 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
| 51 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
| 52 | 52 | if ($version) { |
| 53 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 53 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 54 | 54 | } |
| 55 | 55 | if (isset($parsed['modx_category'])) { |
| 56 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 56 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 57 | 57 | $categoryid = getCategory($parsed['modx_category']); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | // finished emptying cache - redirect |
| 112 | 112 | if ($_POST['stay'] != '') { |
| 113 | 113 | $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
| 114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 114 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 115 | 115 | header($header); |
| 116 | 116 | } else { |
| 117 | 117 | $header = "Location: index.php?a=106&r=2"; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | // finished emptying cache - redirect |
| 169 | 169 | if ($_POST['stay'] != '') { |
| 170 | 170 | $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
| 171 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 171 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 172 | 172 | header($header); |
| 173 | 173 | } else { |
| 174 | 174 | $modx->unlockElement(6, $id); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $modx->webAlertAndQuit("No operation set in request."); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | -if(!function_exists('saveUserGroupAccessPermissons')) { |
|
| 183 | +if (!function_exists('saveUserGroupAccessPermissons')) { |
|
| 184 | 184 | /** |
| 185 | 185 | * saves module user group access |
| 186 | 186 | */ |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('edit_document')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | // check user has permission to move document to chosen location |
| 26 | 26 | |
| 27 | 27 | if ($use_udperms == 1) { |
| 28 | - if ($oldparent != $newParentID) { |
|
| 29 | - $udperms = new EvolutionCMS\Legacy\Permissions(); |
|
| 30 | - $udperms->user = $modx->getLoginUserID(); |
|
| 31 | - $udperms->document = $newParentID; |
|
| 32 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 33 | - |
|
| 34 | - if (!$udperms->checkPermissions()) { |
|
| 35 | - $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
| 36 | - } |
|
| 37 | - } |
|
| 28 | + if ($oldparent != $newParentID) { |
|
| 29 | + $udperms = new EvolutionCMS\Legacy\Permissions(); |
|
| 30 | + $udperms->user = $modx->getLoginUserID(); |
|
| 31 | + $udperms->document = $newParentID; |
|
| 32 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 33 | + |
|
| 34 | + if (!$udperms->checkPermissions()) { |
|
| 35 | + $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | if(!function_exists('allChildren')) { |
@@ -58,55 +58,55 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
| 61 | - "id_document" => $documentID, |
|
| 62 | - "old_parent" => $oldparent, |
|
| 63 | - "new_parent" => $newParentID |
|
| 61 | + "id_document" => $documentID, |
|
| 62 | + "old_parent" => $oldparent, |
|
| 63 | + "new_parent" => $newParentID |
|
| 64 | 64 | )); |
| 65 | 65 | if (is_array($evtOut) && count($evtOut) > 0){ |
| 66 | - $newParent = array_pop($evtOut); |
|
| 67 | - if($newParent == $oldparent) { |
|
| 68 | - $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 69 | - }else{ |
|
| 70 | - $newParentID = $newParent; |
|
| 71 | - } |
|
| 66 | + $newParent = array_pop($evtOut); |
|
| 67 | + if($newParent == $oldparent) { |
|
| 68 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 69 | + }else{ |
|
| 70 | + $newParentID = $newParent; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $children = allChildren($documentID); |
| 75 | 75 | if (!array_search($newParentID, $children)) { |
| 76 | - $modx->db->update(array( |
|
| 77 | - 'isfolder' => 1, |
|
| 78 | - ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
| 79 | - |
|
| 80 | - $modx->db->update(array( |
|
| 81 | - 'parent' => $newParentID, |
|
| 82 | - 'editedby' => $modx->getLoginUserID(), |
|
| 83 | - 'editedon' => time(), |
|
| 84 | - ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
| 85 | - |
|
| 86 | - // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
| 87 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
| 88 | - $limit = $modx->db->getValue($rs); |
|
| 89 | - |
|
| 90 | - if(!$limit>0) { |
|
| 91 | - $modx->db->update(array( |
|
| 92 | - 'isfolder' => 0, |
|
| 93 | - ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
| 94 | - } |
|
| 95 | - // Set the item name for logger |
|
| 96 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
| 97 | - $_SESSION['itemname'] = $pagetitle; |
|
| 98 | - |
|
| 99 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 100 | - "id_document" => $documentID, |
|
| 101 | - "old_parent" => $oldparent, |
|
| 102 | - "new_parent" => $newParentID |
|
| 103 | - )); |
|
| 104 | - |
|
| 105 | - // empty cache & sync site |
|
| 106 | - $modx->clearCache('full'); |
|
| 107 | - |
|
| 108 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 109 | - header($header); |
|
| 76 | + $modx->db->update(array( |
|
| 77 | + 'isfolder' => 1, |
|
| 78 | + ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
| 79 | + |
|
| 80 | + $modx->db->update(array( |
|
| 81 | + 'parent' => $newParentID, |
|
| 82 | + 'editedby' => $modx->getLoginUserID(), |
|
| 83 | + 'editedon' => time(), |
|
| 84 | + ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
| 85 | + |
|
| 86 | + // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
| 87 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
| 88 | + $limit = $modx->db->getValue($rs); |
|
| 89 | + |
|
| 90 | + if(!$limit>0) { |
|
| 91 | + $modx->db->update(array( |
|
| 92 | + 'isfolder' => 0, |
|
| 93 | + ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
| 94 | + } |
|
| 95 | + // Set the item name for logger |
|
| 96 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
| 97 | + $_SESSION['itemname'] = $pagetitle; |
|
| 98 | + |
|
| 99 | + $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 100 | + "id_document" => $documentID, |
|
| 101 | + "old_parent" => $oldparent, |
|
| 102 | + "new_parent" => $newParentID |
|
| 103 | + )); |
|
| 104 | + |
|
| 105 | + // empty cache & sync site |
|
| 106 | + $modx->clearCache('full'); |
|
| 107 | + |
|
| 108 | + $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 109 | + header($header); |
|
| 110 | 110 | } else { |
| 111 | - $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
| 111 | + $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
| 112 | 112 | } |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('edit_document')) { |
|
| 5 | +if (!$modx->hasPermission('edit_document')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
|
| 10 | -$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 9 | +$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0; |
|
| 10 | +$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 11 | 11 | |
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | +if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | +if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 18 | 18 | |
| 19 | 19 | $parents = $modx->getParentIds($newParentID); |
| 20 | 20 | if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | -if(!function_exists('allChildren')) { |
|
| 40 | +if (!function_exists('allChildren')) { |
|
| 41 | 41 | /** |
| 42 | 42 | * @param int $currDocID |
| 43 | 43 | * @return array |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
|
| 60 | +$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array( |
|
| 61 | 61 | "id_document" => $documentID, |
| 62 | 62 | "old_parent" => $oldparent, |
| 63 | 63 | "new_parent" => $newParentID |
| 64 | 64 | )); |
| 65 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 65 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 66 | 66 | $newParent = array_pop($evtOut); |
| 67 | - if($newParent == $oldparent) { |
|
| 67 | + if ($newParent == $oldparent) { |
|
| 68 | 68 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 69 | - }else{ |
|
| 69 | + } else { |
|
| 70 | 70 | $newParentID = $newParent; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
| 88 | 88 | $limit = $modx->db->getValue($rs); |
| 89 | 89 | |
| 90 | - if(!$limit>0) { |
|
| 90 | + if (!$limit > 0) { |
|
| 91 | 91 | $modx->db->update(array( |
| 92 | 92 | 'isfolder' => 0, |
| 93 | 93 | ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
| 97 | 97 | $_SESSION['itemname'] = $pagetitle; |
| 98 | 98 | |
| 99 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 99 | + $modx->invokeEvent("onAfterMoveDocument", array( |
|
| 100 | 100 | "id_document" => $documentID, |
| 101 | 101 | "old_parent" => $oldparent, |
| 102 | 102 | "new_parent" => $newParentID |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // empty cache & sync site |
| 106 | 106 | $modx->clearCache('full'); |
| 107 | 107 | |
| 108 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 108 | + $header = "Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 109 | 109 | header($header); |
| 110 | 110 | } else { |
| 111 | 111 | $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
@@ -12,12 +12,20 @@ discard block |
||
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if($documentID==$newParentID) { |
|
| 16 | + $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 17 | +} |
|
| 18 | +if($documentID <= 0) { |
|
| 19 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 20 | +} |
|
| 21 | +if($newParentID < 0) { |
|
| 22 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 23 | +} |
|
| 18 | 24 | |
| 19 | 25 | $parents = $modx->getParentIds($newParentID); |
| 20 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 26 | +if (in_array($documentID, $parents)) { |
|
| 27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 28 | +} |
|
| 21 | 29 | |
| 22 | 30 | $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
| 23 | 31 | $oldparent = $modx->db->getValue($rs); |
@@ -62,11 +70,11 @@ discard block |
||
| 62 | 70 | "old_parent" => $oldparent, |
| 63 | 71 | "new_parent" => $newParentID |
| 64 | 72 | )); |
| 65 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 73 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 66 | 74 | $newParent = array_pop($evtOut); |
| 67 | 75 | if($newParent == $oldparent) { |
| 68 | 76 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 69 | - }else{ |
|
| 77 | + } else { |
|
| 70 | 78 | $newParentID = $newParent; |
| 71 | 79 | } |
| 72 | 80 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('save_web_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $tbl_web_users = $modx->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | 14 | foreach($input as $k => $v) { |
| 15 | - if($k !== 'comment') { |
|
| 16 | - $v = sanitize($v); |
|
| 17 | - } |
|
| 18 | - $input[$k] = $v; |
|
| 15 | + if($k !== 'comment') { |
|
| 16 | + $v = sanitize($v); |
|
| 17 | + } |
|
| 18 | + $input[$k] = $v; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $id = (int)$input['id']; |
@@ -51,82 +51,82 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 54 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 54 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | - $limit = $modx->db->getValue($rs); |
|
| 75 | - if($limit > 0) { |
|
| 76 | - webAlertAndQuit("Email is already in use!"); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // generate a new password for this user |
|
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 83 | - webAlertAndQuit("Password is too short!"); |
|
| 84 | - } else { |
|
| 85 | - $newpassword = $specifiedpassword; |
|
| 86 | - } |
|
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 90 | - $newpassword = generate_password(8); |
|
| 91 | - } else { |
|
| 92 | - webAlertAndQuit("No password generation method specified!"); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // invoke OnBeforeWUsrFormSave event |
|
| 96 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | - "mode" => "new", |
|
| 98 | - )); |
|
| 99 | - |
|
| 100 | - // create the user account |
|
| 101 | - $field = array(); |
|
| 102 | - $field['username'] = $esc_newusername; |
|
| 103 | - $field['password'] = md5($newpassword); |
|
| 104 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 105 | - |
|
| 106 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | - $field = $modx->db->escape($field); |
|
| 108 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 109 | - |
|
| 110 | - // Save User Settings |
|
| 111 | - saveUserSettings($internalKey); |
|
| 112 | - |
|
| 113 | - // Set the item name for logger |
|
| 114 | - $_SESSION['itemname'] = $newusername; |
|
| 115 | - |
|
| 116 | - /*******************************************************************************/ |
|
| 117 | - // put the user in the user_groups he/ she should be in |
|
| 118 | - // first, check that up_perms are switched on! |
|
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | - $f = array(); |
|
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | - $f['webuser'] = $internalKey; |
|
| 125 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - // end of user_groups stuff! |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | + $limit = $modx->db->getValue($rs); |
|
| 75 | + if($limit > 0) { |
|
| 76 | + webAlertAndQuit("Email is already in use!"); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // generate a new password for this user |
|
| 81 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if(strlen($specifiedpassword) < 6) { |
|
| 83 | + webAlertAndQuit("Password is too short!"); |
|
| 84 | + } else { |
|
| 85 | + $newpassword = $specifiedpassword; |
|
| 86 | + } |
|
| 87 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 89 | + } elseif($passwordgenmethod == 'g') { |
|
| 90 | + $newpassword = generate_password(8); |
|
| 91 | + } else { |
|
| 92 | + webAlertAndQuit("No password generation method specified!"); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // invoke OnBeforeWUsrFormSave event |
|
| 96 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | + "mode" => "new", |
|
| 98 | + )); |
|
| 99 | + |
|
| 100 | + // create the user account |
|
| 101 | + $field = array(); |
|
| 102 | + $field['username'] = $esc_newusername; |
|
| 103 | + $field['password'] = md5($newpassword); |
|
| 104 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 105 | + |
|
| 106 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | + $field = $modx->db->escape($field); |
|
| 108 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 109 | + |
|
| 110 | + // Save User Settings |
|
| 111 | + saveUserSettings($internalKey); |
|
| 112 | + |
|
| 113 | + // Set the item name for logger |
|
| 114 | + $_SESSION['itemname'] = $newusername; |
|
| 115 | + |
|
| 116 | + /*******************************************************************************/ |
|
| 117 | + // put the user in the user_groups he/ she should be in |
|
| 118 | + // first, check that up_perms are switched on! |
|
| 119 | + if($use_udperms == 1) { |
|
| 120 | + if(!empty($user_groups)) { |
|
| 121 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | + $f = array(); |
|
| 123 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | + $f['webuser'] = $internalKey; |
|
| 125 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + // end of user_groups stuff! |
|
| 130 | 130 | |
| 131 | 131 | // invoke OnWebSaveUser event |
| 132 | 132 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -144,26 +144,26 @@ discard block |
||
| 144 | 144 | "id" => $internalKey |
| 145 | 145 | )); |
| 146 | 146 | |
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 148 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 149 | - if($input['stay'] != '') { |
|
| 150 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | - header($header); |
|
| 153 | - } else { |
|
| 154 | - $header = "Location: index.php?a=99&r=2"; |
|
| 155 | - header($header); |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - } else { |
|
| 162 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - include_once "header.inc.php"; |
|
| 166 | - ?> |
|
| 147 | + if($passwordnotifymethod == 'e') { |
|
| 148 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 149 | + if($input['stay'] != '') { |
|
| 150 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | + header($header); |
|
| 153 | + } else { |
|
| 154 | + $header = "Location: index.php?a=99&r=2"; |
|
| 155 | + header($header); |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + } else { |
|
| 162 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + include_once "header.inc.php"; |
|
| 166 | + ?> |
|
| 167 | 167 | |
| 168 | 168 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 169 | 169 | |
@@ -185,86 +185,86 @@ discard block |
||
| 185 | 185 | </div> |
| 186 | 186 | <?php |
| 187 | 187 | |
| 188 | - include_once "footer.inc.php"; |
|
| 189 | - } |
|
| 190 | - break; |
|
| 191 | - case '88' : // edit user |
|
| 192 | - // generate a new password for this user |
|
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 196 | - webAlertAndQuit("Password is too short!"); |
|
| 197 | - } else { |
|
| 198 | - $newpassword = $specifiedpassword; |
|
| 199 | - } |
|
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 203 | - $newpassword = generate_password(8); |
|
| 204 | - } else { |
|
| 205 | - webAlertAndQuit("No password generation method specified!"); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 209 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // check if the username already exist |
|
| 213 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | - $limit = $modx->db->getValue($rs); |
|
| 215 | - if($limit > 0) { |
|
| 216 | - webAlertAndQuit("User name is already in use!"); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // check if the email address already exists |
|
| 220 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | - $limit = $modx->db->getValue($rs); |
|
| 223 | - if($limit > 0) { |
|
| 224 | - webAlertAndQuit("Email is already in use!"); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // invoke OnBeforeWUsrFormSave event |
|
| 229 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | - "mode" => "upd", |
|
| 231 | - "id" => $id |
|
| 232 | - )); |
|
| 233 | - |
|
| 234 | - // update user name and password |
|
| 235 | - $field = array(); |
|
| 236 | - $field['username'] = $esc_newusername; |
|
| 237 | - if($genpassword == 1) { |
|
| 238 | - $field['password'] = md5($newpassword); |
|
| 239 | - } |
|
| 240 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | - $field = $modx->db->escape($field); |
|
| 243 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | - |
|
| 245 | - // Save User Settings |
|
| 246 | - saveUserSettings($id); |
|
| 247 | - |
|
| 248 | - // Set the item name for logger |
|
| 249 | - $_SESSION['itemname'] = $newusername; |
|
| 250 | - |
|
| 251 | - /*******************************************************************************/ |
|
| 252 | - // put the user in the user_groups he/ she should be in |
|
| 253 | - // first, check that up_perms are switched on! |
|
| 254 | - if($use_udperms == 1) { |
|
| 255 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | - $field = array(); |
|
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | - $field['webuser'] = $id; |
|
| 262 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - // end of user_groups stuff! |
|
| 267 | - /*******************************************************************************/ |
|
| 188 | + include_once "footer.inc.php"; |
|
| 189 | + } |
|
| 190 | + break; |
|
| 191 | + case '88' : // edit user |
|
| 192 | + // generate a new password for this user |
|
| 193 | + if($genpassword == 1) { |
|
| 194 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if(strlen($specifiedpassword) < 6) { |
|
| 196 | + webAlertAndQuit("Password is too short!"); |
|
| 197 | + } else { |
|
| 198 | + $newpassword = $specifiedpassword; |
|
| 199 | + } |
|
| 200 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 202 | + } elseif($passwordgenmethod == 'g') { |
|
| 203 | + $newpassword = generate_password(8); |
|
| 204 | + } else { |
|
| 205 | + webAlertAndQuit("No password generation method specified!"); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + if($passwordnotifymethod == 'e') { |
|
| 209 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // check if the username already exist |
|
| 213 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | + $limit = $modx->db->getValue($rs); |
|
| 215 | + if($limit > 0) { |
|
| 216 | + webAlertAndQuit("User name is already in use!"); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // check if the email address already exists |
|
| 220 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | + $limit = $modx->db->getValue($rs); |
|
| 223 | + if($limit > 0) { |
|
| 224 | + webAlertAndQuit("Email is already in use!"); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // invoke OnBeforeWUsrFormSave event |
|
| 229 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | + "mode" => "upd", |
|
| 231 | + "id" => $id |
|
| 232 | + )); |
|
| 233 | + |
|
| 234 | + // update user name and password |
|
| 235 | + $field = array(); |
|
| 236 | + $field['username'] = $esc_newusername; |
|
| 237 | + if($genpassword == 1) { |
|
| 238 | + $field['password'] = md5($newpassword); |
|
| 239 | + } |
|
| 240 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | + $field = $modx->db->escape($field); |
|
| 243 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | + |
|
| 245 | + // Save User Settings |
|
| 246 | + saveUserSettings($id); |
|
| 247 | + |
|
| 248 | + // Set the item name for logger |
|
| 249 | + $_SESSION['itemname'] = $newusername; |
|
| 250 | + |
|
| 251 | + /*******************************************************************************/ |
|
| 252 | + // put the user in the user_groups he/ she should be in |
|
| 253 | + // first, check that up_perms are switched on! |
|
| 254 | + if($use_udperms == 1) { |
|
| 255 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | + if(!empty($user_groups)) { |
|
| 258 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | + $field = array(); |
|
| 260 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | + $field['webuser'] = $id; |
|
| 262 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + // end of user_groups stuff! |
|
| 267 | + /*******************************************************************************/ |
|
| 268 | 268 | |
| 269 | 269 | // invoke OnWebSaveUser event |
| 270 | 270 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -293,16 +293,16 @@ discard block |
||
| 293 | 293 | "id" => $id |
| 294 | 294 | )); |
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 298 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | - } else { |
|
| 301 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | - } |
|
| 296 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if($input['stay'] != '') { |
|
| 298 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | + } else { |
|
| 301 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - include_once "header.inc.php"; |
|
| 305 | - ?> |
|
| 304 | + include_once "header.inc.php"; |
|
| 305 | + ?> |
|
| 306 | 306 | |
| 307 | 307 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 308 | 308 | |
@@ -322,20 +322,20 @@ discard block |
||
| 322 | 322 | </div> |
| 323 | 323 | <?php |
| 324 | 324 | |
| 325 | - include_once "footer.inc.php"; |
|
| 326 | - } else { |
|
| 327 | - if($input['stay'] != '') { |
|
| 328 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | - header($header); |
|
| 331 | - } else { |
|
| 332 | - $header = "Location: index.php?a=99&r=2"; |
|
| 333 | - header($header); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - break; |
|
| 337 | - default : |
|
| 338 | - webAlertAndQuit("No operation set in request."); |
|
| 325 | + include_once "footer.inc.php"; |
|
| 326 | + } else { |
|
| 327 | + if($input['stay'] != '') { |
|
| 328 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | + header($header); |
|
| 331 | + } else { |
|
| 332 | + $header = "Location: index.php?a=99&r=2"; |
|
| 333 | + header($header); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | + default : |
|
| 338 | + webAlertAndQuit("No operation set in request."); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | if(!function_exists('save_user_quoted_printable')) { |
@@ -60,110 +60,110 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | - $limit = $modx->db->getValue($rs); |
|
| 75 | - if($limit > 0) { |
|
| 76 | - webAlertAndQuit("Email is already in use!"); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // generate a new password for this user |
|
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 83 | - webAlertAndQuit("Password is too short!"); |
|
| 84 | - } else { |
|
| 85 | - $newpassword = $specifiedpassword; |
|
| 86 | - } |
|
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 90 | - $newpassword = generate_password(8); |
|
| 91 | - } else { |
|
| 92 | - webAlertAndQuit("No password generation method specified!"); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // invoke OnBeforeWUsrFormSave event |
|
| 96 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | - "mode" => "new", |
|
| 98 | - )); |
|
| 99 | - |
|
| 100 | - // create the user account |
|
| 101 | - $field = array(); |
|
| 102 | - $field['username'] = $esc_newusername; |
|
| 103 | - $field['password'] = md5($newpassword); |
|
| 104 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 105 | - |
|
| 106 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | - $field = $modx->db->escape($field); |
|
| 108 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 109 | - |
|
| 110 | - // Save User Settings |
|
| 111 | - saveUserSettings($internalKey); |
|
| 112 | - |
|
| 113 | - // Set the item name for logger |
|
| 114 | - $_SESSION['itemname'] = $newusername; |
|
| 115 | - |
|
| 116 | - /*******************************************************************************/ |
|
| 117 | - // put the user in the user_groups he/ she should be in |
|
| 118 | - // first, check that up_perms are switched on! |
|
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | - $f = array(); |
|
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | - $f['webuser'] = $internalKey; |
|
| 125 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - // end of user_groups stuff! |
|
| 130 | - |
|
| 131 | - // invoke OnWebSaveUser event |
|
| 132 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 133 | - "mode" => "new", |
|
| 134 | - "userid" => $internalKey, |
|
| 135 | - "username" => $newusername, |
|
| 136 | - "userpassword" => $newpassword, |
|
| 137 | - "useremail" => $email, |
|
| 138 | - "userfullname" => $fullname |
|
| 139 | - )); |
|
| 140 | - |
|
| 141 | - // invoke OnWUsrFormSave event |
|
| 142 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 143 | - "mode" => "new", |
|
| 144 | - "id" => $internalKey |
|
| 145 | - )); |
|
| 146 | - |
|
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 148 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 149 | - if($input['stay'] != '') { |
|
| 150 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | - header($header); |
|
| 153 | - } else { |
|
| 154 | - $header = "Location: index.php?a=99&r=2"; |
|
| 155 | - header($header); |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - } else { |
|
| 162 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - include_once "header.inc.php"; |
|
| 166 | - ?> |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | + $limit = $modx->db->getValue($rs); |
|
| 75 | + if($limit > 0) { |
|
| 76 | + webAlertAndQuit("Email is already in use!"); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // generate a new password for this user |
|
| 81 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if(strlen($specifiedpassword) < 6) { |
|
| 83 | + webAlertAndQuit("Password is too short!"); |
|
| 84 | + } else { |
|
| 85 | + $newpassword = $specifiedpassword; |
|
| 86 | + } |
|
| 87 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 89 | + } elseif($passwordgenmethod == 'g') { |
|
| 90 | + $newpassword = generate_password(8); |
|
| 91 | + } else { |
|
| 92 | + webAlertAndQuit("No password generation method specified!"); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // invoke OnBeforeWUsrFormSave event |
|
| 96 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | + "mode" => "new", |
|
| 98 | + )); |
|
| 99 | + |
|
| 100 | + // create the user account |
|
| 101 | + $field = array(); |
|
| 102 | + $field['username'] = $esc_newusername; |
|
| 103 | + $field['password'] = md5($newpassword); |
|
| 104 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 105 | + |
|
| 106 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | + $field = $modx->db->escape($field); |
|
| 108 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 109 | + |
|
| 110 | + // Save User Settings |
|
| 111 | + saveUserSettings($internalKey); |
|
| 112 | + |
|
| 113 | + // Set the item name for logger |
|
| 114 | + $_SESSION['itemname'] = $newusername; |
|
| 115 | + |
|
| 116 | + /*******************************************************************************/ |
|
| 117 | + // put the user in the user_groups he/ she should be in |
|
| 118 | + // first, check that up_perms are switched on! |
|
| 119 | + if($use_udperms == 1) { |
|
| 120 | + if(!empty($user_groups)) { |
|
| 121 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | + $f = array(); |
|
| 123 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | + $f['webuser'] = $internalKey; |
|
| 125 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + // end of user_groups stuff! |
|
| 130 | + |
|
| 131 | + // invoke OnWebSaveUser event |
|
| 132 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 133 | + "mode" => "new", |
|
| 134 | + "userid" => $internalKey, |
|
| 135 | + "username" => $newusername, |
|
| 136 | + "userpassword" => $newpassword, |
|
| 137 | + "useremail" => $email, |
|
| 138 | + "userfullname" => $fullname |
|
| 139 | + )); |
|
| 140 | + |
|
| 141 | + // invoke OnWUsrFormSave event |
|
| 142 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 143 | + "mode" => "new", |
|
| 144 | + "id" => $internalKey |
|
| 145 | + )); |
|
| 146 | + |
|
| 147 | + if($passwordnotifymethod == 'e') { |
|
| 148 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 149 | + if($input['stay'] != '') { |
|
| 150 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | + header($header); |
|
| 153 | + } else { |
|
| 154 | + $header = "Location: index.php?a=99&r=2"; |
|
| 155 | + header($header); |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + } else { |
|
| 162 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + include_once "header.inc.php"; |
|
| 166 | + ?> |
|
| 167 | 167 | |
| 168 | 168 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 169 | 169 | |
@@ -185,124 +185,124 @@ discard block |
||
| 185 | 185 | </div> |
| 186 | 186 | <?php |
| 187 | 187 | |
| 188 | - include_once "footer.inc.php"; |
|
| 189 | - } |
|
| 190 | - break; |
|
| 191 | - case '88' : // edit user |
|
| 192 | - // generate a new password for this user |
|
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 196 | - webAlertAndQuit("Password is too short!"); |
|
| 197 | - } else { |
|
| 198 | - $newpassword = $specifiedpassword; |
|
| 199 | - } |
|
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 203 | - $newpassword = generate_password(8); |
|
| 204 | - } else { |
|
| 205 | - webAlertAndQuit("No password generation method specified!"); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 209 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // check if the username already exist |
|
| 213 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | - $limit = $modx->db->getValue($rs); |
|
| 215 | - if($limit > 0) { |
|
| 216 | - webAlertAndQuit("User name is already in use!"); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // check if the email address already exists |
|
| 220 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | - $limit = $modx->db->getValue($rs); |
|
| 223 | - if($limit > 0) { |
|
| 224 | - webAlertAndQuit("Email is already in use!"); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // invoke OnBeforeWUsrFormSave event |
|
| 229 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | - "mode" => "upd", |
|
| 231 | - "id" => $id |
|
| 232 | - )); |
|
| 233 | - |
|
| 234 | - // update user name and password |
|
| 235 | - $field = array(); |
|
| 236 | - $field['username'] = $esc_newusername; |
|
| 237 | - if($genpassword == 1) { |
|
| 238 | - $field['password'] = md5($newpassword); |
|
| 239 | - } |
|
| 240 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | - $field = $modx->db->escape($field); |
|
| 243 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | - |
|
| 245 | - // Save User Settings |
|
| 246 | - saveUserSettings($id); |
|
| 247 | - |
|
| 248 | - // Set the item name for logger |
|
| 249 | - $_SESSION['itemname'] = $newusername; |
|
| 250 | - |
|
| 251 | - /*******************************************************************************/ |
|
| 252 | - // put the user in the user_groups he/ she should be in |
|
| 253 | - // first, check that up_perms are switched on! |
|
| 254 | - if($use_udperms == 1) { |
|
| 255 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | - $field = array(); |
|
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | - $field['webuser'] = $id; |
|
| 262 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - // end of user_groups stuff! |
|
| 267 | - /*******************************************************************************/ |
|
| 268 | - |
|
| 269 | - // invoke OnWebSaveUser event |
|
| 270 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 271 | - "mode" => "upd", |
|
| 272 | - "userid" => $id, |
|
| 273 | - "username" => $newusername, |
|
| 274 | - "userpassword" => $newpassword, |
|
| 275 | - "useremail" => $email, |
|
| 276 | - "userfullname" => $fullname, |
|
| 277 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 278 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 279 | - )); |
|
| 280 | - |
|
| 281 | - // invoke OnWebChangePassword event |
|
| 282 | - if($genpassword == 1) { |
|
| 283 | - $modx->invokeEvent("OnWebChangePassword", array( |
|
| 188 | + include_once "footer.inc.php"; |
|
| 189 | + } |
|
| 190 | + break; |
|
| 191 | + case '88' : // edit user |
|
| 192 | + // generate a new password for this user |
|
| 193 | + if($genpassword == 1) { |
|
| 194 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if(strlen($specifiedpassword) < 6) { |
|
| 196 | + webAlertAndQuit("Password is too short!"); |
|
| 197 | + } else { |
|
| 198 | + $newpassword = $specifiedpassword; |
|
| 199 | + } |
|
| 200 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 202 | + } elseif($passwordgenmethod == 'g') { |
|
| 203 | + $newpassword = generate_password(8); |
|
| 204 | + } else { |
|
| 205 | + webAlertAndQuit("No password generation method specified!"); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + if($passwordnotifymethod == 'e') { |
|
| 209 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // check if the username already exist |
|
| 213 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | + $limit = $modx->db->getValue($rs); |
|
| 215 | + if($limit > 0) { |
|
| 216 | + webAlertAndQuit("User name is already in use!"); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // check if the email address already exists |
|
| 220 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | + $limit = $modx->db->getValue($rs); |
|
| 223 | + if($limit > 0) { |
|
| 224 | + webAlertAndQuit("Email is already in use!"); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // invoke OnBeforeWUsrFormSave event |
|
| 229 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | + "mode" => "upd", |
|
| 231 | + "id" => $id |
|
| 232 | + )); |
|
| 233 | + |
|
| 234 | + // update user name and password |
|
| 235 | + $field = array(); |
|
| 236 | + $field['username'] = $esc_newusername; |
|
| 237 | + if($genpassword == 1) { |
|
| 238 | + $field['password'] = md5($newpassword); |
|
| 239 | + } |
|
| 240 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | + $field = $modx->db->escape($field); |
|
| 243 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | + |
|
| 245 | + // Save User Settings |
|
| 246 | + saveUserSettings($id); |
|
| 247 | + |
|
| 248 | + // Set the item name for logger |
|
| 249 | + $_SESSION['itemname'] = $newusername; |
|
| 250 | + |
|
| 251 | + /*******************************************************************************/ |
|
| 252 | + // put the user in the user_groups he/ she should be in |
|
| 253 | + // first, check that up_perms are switched on! |
|
| 254 | + if($use_udperms == 1) { |
|
| 255 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | + if(!empty($user_groups)) { |
|
| 258 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | + $field = array(); |
|
| 260 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | + $field['webuser'] = $id; |
|
| 262 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + // end of user_groups stuff! |
|
| 267 | + /*******************************************************************************/ |
|
| 268 | + |
|
| 269 | + // invoke OnWebSaveUser event |
|
| 270 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 271 | + "mode" => "upd", |
|
| 284 | 272 | "userid" => $id, |
| 285 | 273 | "username" => $newusername, |
| 286 | - "userpassword" => $newpassword |
|
| 274 | + "userpassword" => $newpassword, |
|
| 275 | + "useremail" => $email, |
|
| 276 | + "userfullname" => $fullname, |
|
| 277 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 278 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 287 | 279 | )); |
| 288 | - } |
|
| 289 | 280 | |
| 290 | - // invoke OnWUsrFormSave event |
|
| 291 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 292 | - "mode" => "upd", |
|
| 293 | - "id" => $id |
|
| 294 | - )); |
|
| 281 | + // invoke OnWebChangePassword event |
|
| 282 | + if($genpassword == 1) { |
|
| 283 | + $modx->invokeEvent("OnWebChangePassword", array( |
|
| 284 | + "userid" => $id, |
|
| 285 | + "username" => $newusername, |
|
| 286 | + "userpassword" => $newpassword |
|
| 287 | + )); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + // invoke OnWUsrFormSave event |
|
| 291 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 292 | + "mode" => "upd", |
|
| 293 | + "id" => $id |
|
| 294 | + )); |
|
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 298 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | - } else { |
|
| 301 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | - } |
|
| 296 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if($input['stay'] != '') { |
|
| 298 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | + } else { |
|
| 301 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - include_once "header.inc.php"; |
|
| 305 | - ?> |
|
| 304 | + include_once "header.inc.php"; |
|
| 305 | + ?> |
|
| 306 | 306 | |
| 307 | 307 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 308 | 308 | |
@@ -322,20 +322,20 @@ discard block |
||
| 322 | 322 | </div> |
| 323 | 323 | <?php |
| 324 | 324 | |
| 325 | - include_once "footer.inc.php"; |
|
| 326 | - } else { |
|
| 327 | - if($input['stay'] != '') { |
|
| 328 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | - header($header); |
|
| 331 | - } else { |
|
| 332 | - $header = "Location: index.php?a=99&r=2"; |
|
| 333 | - header($header); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - break; |
|
| 337 | - default : |
|
| 338 | - webAlertAndQuit("No operation set in request."); |
|
| 325 | + include_once "footer.inc.php"; |
|
| 326 | + } else { |
|
| 327 | + if($input['stay'] != '') { |
|
| 328 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | + header($header); |
|
| 331 | + } else { |
|
| 332 | + $header = "Location: index.php?a=99&r=2"; |
|
| 333 | + header($header); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | + default : |
|
| 338 | + webAlertAndQuit("No operation set in request."); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | if(!function_exists('save_user_quoted_printable')) { |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('save_web_user')) { |
|
| 5 | +if (!$modx->hasPermission('save_web_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | $tbl_web_groups = $modx->getFullTableName('web_groups'); |
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | -foreach($input as $k => $v) { |
|
| 15 | - if($k !== 'comment') { |
|
| 14 | +foreach ($input as $k => $v) { |
|
| 15 | + if ($k !== 'comment') { |
|
| 16 | 16 | $v = sanitize($v); |
| 17 | 17 | } |
| 18 | 18 | $input[$k] = $v; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -$id = (int)$input['id']; |
|
| 21 | +$id = (int) $input['id']; |
|
| 22 | 22 | $oldusername = $input['oldusername']; |
| 23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
| 24 | 24 | $esc_newusername = $modx->db->escape($newusername); |
@@ -50,21 +50,21 @@ discard block |
||
| 50 | 50 | $user_groups = $input['user_groups']; |
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 53 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 54 | 54 | webAlertAndQuit("Password typed is mismatched"); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 58 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 59 | 59 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -switch($input['mode']) { |
|
| 62 | +switch ($input['mode']) { |
|
| 63 | 63 | case '87' : // new user |
| 64 | 64 | // check if this user name already exist |
| 65 | 65 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
| 66 | 66 | $limit = $modx->db->getValue($rs); |
| 67 | - if($limit > 0) { |
|
| 67 | + if ($limit > 0) { |
|
| 68 | 68 | webAlertAndQuit("User name is already in use!"); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,21 +72,21 @@ discard block |
||
| 72 | 72 | if ($modx->config['allow_multiple_emails'] != 1) { |
| 73 | 73 | $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
| 74 | 74 | $limit = $modx->db->getValue($rs); |
| 75 | - if($limit > 0) { |
|
| 75 | + if ($limit > 0) { |
|
| 76 | 76 | webAlertAndQuit("Email is already in use!"); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // generate a new password for this user |
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if (strlen($specifiedpassword) < 6) { |
|
| 83 | 83 | webAlertAndQuit("Password is too short!"); |
| 84 | 84 | } else { |
| 85 | 85 | $newpassword = $specifiedpassword; |
| 86 | 86 | } |
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 87 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | 88 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 89 | + } elseif ($passwordgenmethod == 'g') { |
|
| 90 | 90 | $newpassword = generate_password(8); |
| 91 | 91 | } else { |
| 92 | 92 | webAlertAndQuit("No password generation method specified!"); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | /*******************************************************************************/ |
| 117 | 117 | // put the user in the user_groups he/ she should be in |
| 118 | 118 | // first, check that up_perms are switched on! |
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 119 | + if ($use_udperms == 1) { |
|
| 120 | + if (!empty($user_groups)) { |
|
| 121 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | 122 | $f = array(); |
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 123 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
| 124 | 124 | $f['webuser'] = $internalKey; |
| 125 | 125 | $modx->db->insert($f, $tbl_web_groups); |
| 126 | 126 | } |
@@ -144,20 +144,20 @@ discard block |
||
| 144 | 144 | "id" => $internalKey |
| 145 | 145 | )); |
| 146 | 146 | |
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 147 | + if ($passwordnotifymethod == 'e') { |
|
| 148 | 148 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 149 | - if($input['stay'] != '') { |
|
| 149 | + if ($input['stay'] != '') { |
|
| 150 | 150 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 152 | 152 | header($header); |
| 153 | 153 | } else { |
| 154 | 154 | $header = "Location: index.php?a=99&r=2"; |
| 155 | 155 | header($header); |
| 156 | 156 | } |
| 157 | 157 | } else { |
| 158 | - if($input['stay'] != '') { |
|
| 158 | + if ($input['stay'] != '') { |
|
| 159 | 159 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 161 | 161 | } else { |
| 162 | 162 | $stayUrl = "index.php?a=99&r=2"; |
| 163 | 163 | } |
@@ -190,29 +190,29 @@ discard block |
||
| 190 | 190 | break; |
| 191 | 191 | case '88' : // edit user |
| 192 | 192 | // generate a new password for this user |
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 193 | + if ($genpassword == 1) { |
|
| 194 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if (strlen($specifiedpassword) < 6) { |
|
| 196 | 196 | webAlertAndQuit("Password is too short!"); |
| 197 | 197 | } else { |
| 198 | 198 | $newpassword = $specifiedpassword; |
| 199 | 199 | } |
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 200 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | 201 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 202 | + } elseif ($passwordgenmethod == 'g') { |
|
| 203 | 203 | $newpassword = generate_password(8); |
| 204 | 204 | } else { |
| 205 | 205 | webAlertAndQuit("No password generation method specified!"); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 208 | + if ($passwordnotifymethod == 'e') { |
|
| 209 | 209 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // check if the username already exist |
| 213 | 213 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
| 214 | 214 | $limit = $modx->db->getValue($rs); |
| 215 | - if($limit > 0) { |
|
| 215 | + if ($limit > 0) { |
|
| 216 | 216 | webAlertAndQuit("User name is already in use!"); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | if ($modx->config['allow_multiple_emails'] != 1) { |
| 221 | 221 | $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
| 222 | 222 | $limit = $modx->db->getValue($rs); |
| 223 | - if($limit > 0) { |
|
| 223 | + if ($limit > 0) { |
|
| 224 | 224 | webAlertAndQuit("Email is already in use!"); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // update user name and password |
| 235 | 235 | $field = array(); |
| 236 | 236 | $field['username'] = $esc_newusername; |
| 237 | - if($genpassword == 1) { |
|
| 237 | + if ($genpassword == 1) { |
|
| 238 | 238 | $field['password'] = md5($newpassword); |
| 239 | 239 | } |
| 240 | 240 | $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | /*******************************************************************************/ |
| 252 | 252 | // put the user in the user_groups he/ she should be in |
| 253 | 253 | // first, check that up_perms are switched on! |
| 254 | - if($use_udperms == 1) { |
|
| 254 | + if ($use_udperms == 1) { |
|
| 255 | 255 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 256 | 256 | $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 257 | + if (!empty($user_groups)) { |
|
| 258 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | 259 | $field = array(); |
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 260 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
| 261 | 261 | $field['webuser'] = $id; |
| 262 | 262 | $modx->db->insert($field, $tbl_web_groups); |
| 263 | 263 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | )); |
| 280 | 280 | |
| 281 | 281 | // invoke OnWebChangePassword event |
| 282 | - if($genpassword == 1) { |
|
| 282 | + if ($genpassword == 1) { |
|
| 283 | 283 | $modx->invokeEvent("OnWebChangePassword", array( |
| 284 | 284 | "userid" => $id, |
| 285 | 285 | "username" => $newusername, |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | "id" => $id |
| 294 | 294 | )); |
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 296 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if ($input['stay'] != '') { |
|
| 298 | 298 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 300 | 300 | } else { |
| 301 | 301 | $stayUrl = "index.php?a=99&r=2"; |
| 302 | 302 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | include_once "footer.inc.php"; |
| 326 | 326 | } else { |
| 327 | - if($input['stay'] != '') { |
|
| 327 | + if ($input['stay'] != '') { |
|
| 328 | 328 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 330 | 330 | header($header); |
| 331 | 331 | } else { |
| 332 | 332 | $header = "Location: index.php?a=99&r=2"; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | webAlertAndQuit("No operation set in request."); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | -if(!function_exists('save_user_quoted_printable')) { |
|
| 341 | +if (!function_exists('save_user_quoted_printable')) { |
|
| 342 | 342 | /** |
| 343 | 343 | * in case any plugins include a quoted_printable function |
| 344 | 344 | * |
@@ -348,18 +348,18 @@ discard block |
||
| 348 | 348 | function save_user_quoted_printable($string) |
| 349 | 349 | { |
| 350 | 350 | $crlf = "\n"; |
| 351 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 351 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
| 352 | 352 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
| 353 | 353 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
| 354 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 355 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 354 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
| 355 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
| 356 | 356 | $string = preg_replace($f, $r, $string); |
| 357 | 357 | |
| 358 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 358 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | -if(!function_exists('sendMailMessage')) { |
|
| 362 | +if (!function_exists('sendMailMessage')) { |
|
| 363 | 363 | /** |
| 364 | 364 | * Send an email to the user |
| 365 | 365 | * |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | -if(!function_exists('saveUserSettings')) { |
|
| 401 | +if (!function_exists('saveUserSettings')) { |
|
| 402 | 402 | // Save User Settings |
| 403 | 403 | function saveUserSettings($id) |
| 404 | 404 | { |
@@ -430,24 +430,24 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | -if(!function_exists('webAlertAndQuit')) { |
|
| 433 | +if (!function_exists('webAlertAndQuit')) { |
|
| 434 | 434 | // Web alert - sends an alert to web browser |
| 435 | 435 | function webAlertAndQuit($msg) |
| 436 | 436 | { |
| 437 | 437 | global $id, $modx; |
| 438 | 438 | $mode = $_POST['mode']; |
| 439 | 439 | $modx->manager->saveFormValues($mode); |
| 440 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 440 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | -if(!function_exists('generate_password')) { |
|
| 444 | +if (!function_exists('generate_password')) { |
|
| 445 | 445 | // Generate password |
| 446 | 446 | function generate_password($length = 10) |
| 447 | 447 | { |
| 448 | 448 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 449 | 449 | $ps_len = strlen($allowable_characters); |
| 450 | - mt_srand((double)microtime() * 1000000); |
|
| 450 | + mt_srand((double) microtime() * 1000000); |
|
| 451 | 451 | $pass = ""; |
| 452 | 452 | for ($i = 0; $i < $length; $i++) { |
| 453 | 453 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | -if(!function_exists('sanitize')) { |
|
| 460 | +if (!function_exists('sanitize')) { |
|
| 461 | 461 | function sanitize($str = '', $safecount = 0) |
| 462 | 462 | { |
| 463 | 463 | $modx = evolutionCMS(); |