@@ -177,7 +177,9 @@ discard block |
||
| 177 | 177 | // save selected system events |
| 178 | 178 | $formEventList = array(); |
| 179 | 179 | foreach ($sysevents as $evtId) { |
| 180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
| 180 | + if(!preg_match('@^[1-9][0-9]*$@',$evtId)) { |
|
| 181 | + $evtId = getEventIdByName($evtId); |
|
| 182 | + } |
|
| 181 | 183 | if ($mode == '101') { |
| 182 | 184 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
| 183 | 185 | } else { |
@@ -203,10 +205,14 @@ discard block |
||
| 203 | 205 | $dbEventList = array(); |
| 204 | 206 | $del = array(); |
| 205 | 207 | while($row = $modx->db->getRow($rs)) { |
| 206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
| 208 | + if(!in_array($row['evtid'], $evtids)) { |
|
| 209 | + $del[] = $row['evtid']; |
|
| 210 | + } |
|
| 207 | 211 | } |
| 208 | 212 | |
| 209 | - if(!$del) return; |
|
| 213 | + if(!$del) { |
|
| 214 | + return; |
|
| 215 | + } |
|
| 210 | 216 | |
| 211 | 217 | foreach($del as $delid) { |
| 212 | 218 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
@@ -218,7 +224,9 @@ discard block |
||
| 218 | 224 | global $modx; |
| 219 | 225 | static $eventIds=array(); |
| 220 | 226 | |
| 221 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
| 227 | + if(isset($eventIds[$name])) { |
|
| 228 | + return $eventIds[$name]; |
|
| 229 | + } |
|
| 222 | 230 | |
| 223 | 231 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
| 224 | 232 | while ($row = $modx->db->getRow($rs)) { |
@@ -1,5 +1,5 @@ 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')) { |
@@ -24,7 +24,7 @@ discard block |
||
| 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); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | // save selected system events |
| 178 | 178 | $formEventList = array(); |
| 179 | 179 | foreach ($sysevents as $evtId) { |
| 180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
| 180 | + if (!preg_match('@^[1-9][0-9]*$@', $evtId)) $evtId = getEventIdByName($evtId); |
|
| 181 | 181 | if ($mode == '101') { |
| 182 | 182 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
| 183 | 183 | } else { |
@@ -202,13 +202,13 @@ discard block |
||
| 202 | 202 | $rs = $modx->db->select('*', '[+prefix+]site_plugin_events', sprintf("pluginid='%s'", $id)); |
| 203 | 203 | $dbEventList = array(); |
| 204 | 204 | $del = array(); |
| 205 | - while($row = $modx->db->getRow($rs)) { |
|
| 206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
| 205 | + while ($row = $modx->db->getRow($rs)) { |
|
| 206 | + if (!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if(!$del) return; |
|
| 209 | + if (!$del) return; |
|
| 210 | 210 | |
| 211 | - foreach($del as $delid) { |
|
| 211 | + foreach ($del as $delid) { |
|
| 212 | 212 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | function getEventIdByName($name) |
| 217 | 217 | { |
| 218 | 218 | global $modx; |
| 219 | - static $eventIds=array(); |
|
| 219 | + static $eventIds = array(); |
|
| 220 | 220 | |
| 221 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
| 221 | + if (isset($eventIds[$name])) return $eventIds[$name]; |
|
| 222 | 222 | |
| 223 | 223 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
| 224 | 224 | while ($row = $modx->db->getRow($rs)) { |
@@ -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 | - } |
|
| 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 | - } |
|
| 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 | - } |
|
| 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 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - break; |
|
| 143 | - default: |
|
| 144 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 36 | + case '19': |
|
| 37 | + |
|
| 38 | + // invoke OnBeforeTempFormSave event |
|
| 39 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | + "mode" => "new", |
|
| 41 | + "id" => $id |
|
| 42 | + )); |
|
| 43 | + |
|
| 44 | + // disallow duplicate names for new templates |
|
| 45 | + $rs = $modx->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 | + |
|
| 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 | + |
|
| 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 | + |
|
| 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 | + |
|
| 141 | + |
|
| 142 | + break; |
|
| 143 | + default: |
|
| 144 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | function saveTemplateAccess($id) |
@@ -1,5 +1,5 @@ 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')) { |
@@ -11,7 +11,7 @@ discard block |
||
| 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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 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); |
@@ -2,43 +2,43 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class udperms{ |
| 4 | 4 | |
| 5 | - var $user; |
|
| 6 | - var $document; |
|
| 7 | - var $role; |
|
| 8 | - var $duplicateDoc = false; |
|
| 5 | + var $user; |
|
| 6 | + var $document; |
|
| 7 | + var $role; |
|
| 8 | + var $duplicateDoc = false; |
|
| 9 | 9 | |
| 10 | - function checkPermissions() { |
|
| 10 | + function checkPermissions() { |
|
| 11 | 11 | |
| 12 | - global $udperms_allowroot; |
|
| 13 | - global $modx; |
|
| 12 | + global $udperms_allowroot; |
|
| 13 | + global $modx; |
|
| 14 | 14 | |
| 15 | - $tblsc = $modx->getFullTableName('site_content'); |
|
| 16 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
| 17 | - $tbldgn = $modx->getFullTableName('documentgroup_names'); |
|
| 15 | + $tblsc = $modx->getFullTableName('site_content'); |
|
| 16 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
| 17 | + $tbldgn = $modx->getFullTableName('documentgroup_names'); |
|
| 18 | 18 | |
| 19 | - $document = $this->document; |
|
| 20 | - $role = $this->role; |
|
| 19 | + $document = $this->document; |
|
| 20 | + $role = $this->role; |
|
| 21 | 21 | |
| 22 | - if($role==1) { |
|
| 23 | - return true; // administrator - grant all document permissions |
|
| 24 | - } |
|
| 22 | + if($role==1) { |
|
| 23 | + return true; // administrator - grant all document permissions |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
| 27 | - return true; // permissions aren't in use |
|
| 28 | - } |
|
| 26 | + if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
| 27 | + return true; // permissions aren't in use |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
|
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | - if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
| 33 | - return false; // deny duplicate || create new document at root if Allow Root is No |
|
| 34 | - } |
|
| 30 | + $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
|
| 31 | + if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | + if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
| 33 | + return false; // deny duplicate || create new document at root if Allow Root is No |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - // get document groups for current user |
|
| 37 | - if($_SESSION['mgrDocgroups']) { |
|
| 38 | - $docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']); |
|
| 39 | - } |
|
| 36 | + // get document groups for current user |
|
| 37 | + if($_SESSION['mgrDocgroups']) { |
|
| 38 | + $docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /* Note: |
|
| 41 | + /* Note: |
|
| 42 | 42 | A document is flagged as private whenever the document group that it |
| 43 | 43 | belongs to is assigned or links to a user group. In other words if |
| 44 | 44 | the document is assigned to a document group that is not yet linked |
@@ -46,18 +46,18 @@ discard block |
||
| 46 | 46 | are private to the manager users will not be private to web users if the |
| 47 | 47 | document group is not assigned to a web user group and visa versa. |
| 48 | 48 | */ |
| 49 | - $permissionsok = false; // set permissions to false |
|
| 49 | + $permissionsok = false; // set permissions to false |
|
| 50 | 50 | |
| 51 | - $rs = $modx->db->select( |
|
| 52 | - 'count(DISTINCT sc.id)', |
|
| 53 | - "{$tblsc} AS sc |
|
| 51 | + $rs = $modx->db->select( |
|
| 52 | + 'count(DISTINCT sc.id)', |
|
| 53 | + "{$tblsc} AS sc |
|
| 54 | 54 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
| 55 | 55 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
| 56 | - "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
| 57 | - ); |
|
| 58 | - $limit = $modx->db->getValue($rs); |
|
| 59 | - if($limit==1) $permissionsok = true; |
|
| 56 | + "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
| 57 | + ); |
|
| 58 | + $limit = $modx->db->getValue($rs); |
|
| 59 | + if($limit==1) $permissionsok = true; |
|
| 60 | 60 | |
| 61 | - return $permissionsok; |
|
| 62 | - } |
|
| 61 | + return $permissionsok; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | var $role; |
| 8 | 8 | var $duplicateDoc = false; |
| 9 | 9 | |
| 10 | - function checkPermissions() { |
|
| 10 | + function checkPermissions(){ |
|
| 11 | 11 | |
| 12 | 12 | global $udperms_allowroot; |
| 13 | 13 | global $modx; |
@@ -19,23 +19,23 @@ discard block |
||
| 19 | 19 | $document = $this->document; |
| 20 | 20 | $role = $this->role; |
| 21 | 21 | |
| 22 | - if($role==1) { |
|
| 23 | - return true; // administrator - grant all document permissions |
|
| 22 | + if ($role == 1) { |
|
| 23 | + return true; // administrator - grant all document permissions |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
| 26 | + if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) { |
|
| 27 | 27 | return true; // permissions aren't in use |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | - if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
| 31 | + if ($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | + if (($this->duplicateDoc == true || $document == 0) && $parent == 0 && $udperms_allowroot == 0) { |
|
| 33 | 33 | return false; // deny duplicate || create new document at root if Allow Root is No |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // get document groups for current user |
| 37 | - if($_SESSION['mgrDocgroups']) { |
|
| 38 | - $docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']); |
|
| 37 | + if ($_SESSION['mgrDocgroups']) { |
|
| 38 | + $docgrp = implode(" || dg.document_group = ", $_SESSION['mgrDocgroups']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /* Note: |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | are private to the manager users will not be private to web users if the |
| 47 | 47 | document group is not assigned to a web user group and visa versa. |
| 48 | 48 | */ |
| 49 | - $permissionsok = false; // set permissions to false |
|
| 49 | + $permissionsok = false; // set permissions to false |
|
| 50 | 50 | |
| 51 | 51 | $rs = $modx->db->select( |
| 52 | 52 | 'count(DISTINCT sc.id)', |
| 53 | 53 | "{$tblsc} AS sc |
| 54 | 54 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
| 55 | 55 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
| 56 | - "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
| 56 | + "sc.id='{$this->document}' AND (".((!$docgrp) ? null : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)" |
|
| 57 | 57 | ); |
| 58 | 58 | $limit = $modx->db->getValue($rs); |
| 59 | - if($limit==1) $permissionsok = true; |
|
| 59 | + if ($limit == 1) $permissionsok = true; |
|
| 60 | 60 | |
| 61 | 61 | return $permissionsok; |
| 62 | 62 | } |
@@ -1,13 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class udperms{ |
|
| 3 | +class udperms |
|
| 4 | +{ |
|
| 4 | 5 | |
| 5 | 6 | var $user; |
| 6 | 7 | var $document; |
| 7 | 8 | var $role; |
| 8 | 9 | var $duplicateDoc = false; |
| 9 | 10 | |
| 10 | - function checkPermissions() { |
|
| 11 | + function checkPermissions() |
|
| 12 | + { |
|
| 11 | 13 | |
| 12 | 14 | global $udperms_allowroot; |
| 13 | 15 | global $modx; |
@@ -28,7 +30,10 @@ discard block |
||
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 33 | + if($document == 0 && $parent == NULL && $udperms_allowroot == 1) { |
|
| 34 | + return true; |
|
| 35 | + } |
|
| 36 | + // User is allowed to create new document in root |
|
| 32 | 37 | if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
| 33 | 38 | return false; // deny duplicate || create new document at root if Allow Root is No |
| 34 | 39 | } |
@@ -56,7 +61,9 @@ discard block |
||
| 56 | 61 | "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
| 57 | 62 | ); |
| 58 | 63 | $limit = $modx->db->getValue($rs); |
| 59 | - if($limit==1) $permissionsok = true; |
|
| 64 | + if($limit==1) { |
|
| 65 | + $permissionsok = true; |
|
| 66 | + } |
|
| 60 | 67 | |
| 61 | 68 | return $permissionsok; |
| 62 | 69 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 31 | + if($document == 0 && $parent == null && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | 32 | if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
| 33 | 33 | return false; // deny duplicate || create new document at root if Allow Root is No |
| 34 | 34 | } |
@@ -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'] = intval($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'] = intval($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'] = intval($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'] = intval($user_groups[$i]); |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
@@ -349,7 +349,8 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
| 352 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 352 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
| 353 | +{ |
|
| 353 | 354 | global $modx, $_lang, $signupemail_message; |
| 354 | 355 | global $emailsubject, $emailsender; |
| 355 | 356 | global $site_name; |
@@ -378,7 +379,8 @@ discard block |
||
| 378 | 379 | } |
| 379 | 380 | |
| 380 | 381 | // Save User Settings |
| 381 | -function saveUserSettings($id) { |
|
| 382 | +function saveUserSettings($id) |
|
| 383 | +{ |
|
| 382 | 384 | global $modx; |
| 383 | 385 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
| 384 | 386 | |
@@ -462,7 +464,8 @@ discard block |
||
| 462 | 464 | } |
| 463 | 465 | |
| 464 | 466 | // Web alert - sends an alert to web browser |
| 465 | -function webAlertAndQuit($msg) { |
|
| 467 | +function webAlertAndQuit($msg) |
|
| 468 | +{ |
|
| 466 | 469 | global $id, $modx; |
| 467 | 470 | $mode = $_POST['mode']; |
| 468 | 471 | $modx->manager->saveFormValues($mode); |
@@ -470,7 +473,8 @@ discard block |
||
| 470 | 473 | } |
| 471 | 474 | |
| 472 | 475 | // Generate password |
| 473 | -function generate_password($length = 10) { |
|
| 476 | +function generate_password($length = 10) |
|
| 477 | +{ |
|
| 474 | 478 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 475 | 479 | $ps_len = strlen($allowable_characters); |
| 476 | 480 | mt_srand((double) microtime() * 1000000); |
@@ -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'] = intval($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'] = intval($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'] = intval($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'] = intval($user_groups[$i]); |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,151 +332,151 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
| 352 | 352 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 353 | - global $modx, $_lang, $signupemail_message; |
|
| 354 | - global $emailsubject, $emailsender; |
|
| 355 | - global $site_name; |
|
| 356 | - $manager_url = MODX_MANAGER_URL; |
|
| 357 | - $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
| 358 | - // replace placeholders |
|
| 359 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 360 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 361 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 362 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 363 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 364 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 365 | - $message = str_replace("[+surl+]", $manager_url, $message); |
|
| 366 | - |
|
| 367 | - $param = array(); |
|
| 368 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 369 | - $param['subject'] = $emailsubject; |
|
| 370 | - $param['body'] = $message; |
|
| 371 | - $param['to'] = $email; |
|
| 372 | - $param['type'] = 'text'; |
|
| 373 | - $rs = $modx->sendmail($param); |
|
| 374 | - if(!$rs) { |
|
| 375 | - $modx->manager->saveFormValues(); |
|
| 376 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 377 | - } |
|
| 353 | + global $modx, $_lang, $signupemail_message; |
|
| 354 | + global $emailsubject, $emailsender; |
|
| 355 | + global $site_name; |
|
| 356 | + $manager_url = MODX_MANAGER_URL; |
|
| 357 | + $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
| 358 | + // replace placeholders |
|
| 359 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 360 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 361 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 362 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 363 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 364 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 365 | + $message = str_replace("[+surl+]", $manager_url, $message); |
|
| 366 | + |
|
| 367 | + $param = array(); |
|
| 368 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 369 | + $param['subject'] = $emailsubject; |
|
| 370 | + $param['body'] = $message; |
|
| 371 | + $param['to'] = $email; |
|
| 372 | + $param['type'] = 'text'; |
|
| 373 | + $rs = $modx->sendmail($param); |
|
| 374 | + if(!$rs) { |
|
| 375 | + $modx->manager->saveFormValues(); |
|
| 376 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 377 | + } |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Save User Settings |
| 381 | 381 | function saveUserSettings($id) { |
| 382 | - global $modx; |
|
| 383 | - $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
| 384 | - |
|
| 385 | - $ignore = array( |
|
| 386 | - 'id', |
|
| 387 | - 'oldusername', |
|
| 388 | - 'oldemail', |
|
| 389 | - 'newusername', |
|
| 390 | - 'fullname', |
|
| 391 | - 'newpassword', |
|
| 392 | - 'newpasswordcheck', |
|
| 393 | - 'passwordgenmethod', |
|
| 394 | - 'passwordnotifymethod', |
|
| 395 | - 'specifiedpassword', |
|
| 396 | - 'confirmpassword', |
|
| 397 | - 'email', |
|
| 398 | - 'phone', |
|
| 399 | - 'mobilephone', |
|
| 400 | - 'fax', |
|
| 401 | - 'dob', |
|
| 402 | - 'country', |
|
| 403 | - 'street', |
|
| 404 | - 'city', |
|
| 405 | - 'state', |
|
| 406 | - 'zip', |
|
| 407 | - 'gender', |
|
| 408 | - 'photo', |
|
| 409 | - 'comment', |
|
| 410 | - 'role', |
|
| 411 | - 'failedlogincount', |
|
| 412 | - 'blocked', |
|
| 413 | - 'blockeduntil', |
|
| 414 | - 'blockedafter', |
|
| 415 | - 'user_groups', |
|
| 416 | - 'mode', |
|
| 417 | - 'blockedmode', |
|
| 418 | - 'stay', |
|
| 419 | - 'save', |
|
| 420 | - 'theme_refresher' |
|
| 421 | - ); |
|
| 422 | - |
|
| 423 | - // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
| 424 | - $defaults = array( |
|
| 425 | - 'upload_images', |
|
| 426 | - 'upload_media', |
|
| 427 | - 'upload_flash', |
|
| 428 | - 'upload_files' |
|
| 429 | - ); |
|
| 430 | - |
|
| 431 | - // get user setting field names |
|
| 432 | - $settings = array(); |
|
| 433 | - foreach($_POST as $n => $v) { |
|
| 434 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 435 | - continue; |
|
| 436 | - } // ignore blacklist and empties |
|
| 437 | - $settings[$n] = $v; // this value should be saved |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - foreach($defaults as $k) { |
|
| 441 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 442 | - unset($settings[$k]); |
|
| 443 | - } |
|
| 444 | - unset($settings['default_' . $k]); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
| 448 | - |
|
| 449 | - foreach($settings as $n => $vl) { |
|
| 450 | - if(is_array($vl)) { |
|
| 451 | - $vl = implode(",", $vl); |
|
| 452 | - } |
|
| 453 | - if($vl != '') { |
|
| 454 | - $f = array(); |
|
| 455 | - $f['user'] = $id; |
|
| 456 | - $f['setting_name'] = $n; |
|
| 457 | - $f['setting_value'] = $vl; |
|
| 458 | - $f = $modx->db->escape($f); |
|
| 459 | - $modx->db->insert($f, $tbl_user_settings); |
|
| 460 | - } |
|
| 461 | - } |
|
| 382 | + global $modx; |
|
| 383 | + $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
| 384 | + |
|
| 385 | + $ignore = array( |
|
| 386 | + 'id', |
|
| 387 | + 'oldusername', |
|
| 388 | + 'oldemail', |
|
| 389 | + 'newusername', |
|
| 390 | + 'fullname', |
|
| 391 | + 'newpassword', |
|
| 392 | + 'newpasswordcheck', |
|
| 393 | + 'passwordgenmethod', |
|
| 394 | + 'passwordnotifymethod', |
|
| 395 | + 'specifiedpassword', |
|
| 396 | + 'confirmpassword', |
|
| 397 | + 'email', |
|
| 398 | + 'phone', |
|
| 399 | + 'mobilephone', |
|
| 400 | + 'fax', |
|
| 401 | + 'dob', |
|
| 402 | + 'country', |
|
| 403 | + 'street', |
|
| 404 | + 'city', |
|
| 405 | + 'state', |
|
| 406 | + 'zip', |
|
| 407 | + 'gender', |
|
| 408 | + 'photo', |
|
| 409 | + 'comment', |
|
| 410 | + 'role', |
|
| 411 | + 'failedlogincount', |
|
| 412 | + 'blocked', |
|
| 413 | + 'blockeduntil', |
|
| 414 | + 'blockedafter', |
|
| 415 | + 'user_groups', |
|
| 416 | + 'mode', |
|
| 417 | + 'blockedmode', |
|
| 418 | + 'stay', |
|
| 419 | + 'save', |
|
| 420 | + 'theme_refresher' |
|
| 421 | + ); |
|
| 422 | + |
|
| 423 | + // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
| 424 | + $defaults = array( |
|
| 425 | + 'upload_images', |
|
| 426 | + 'upload_media', |
|
| 427 | + 'upload_flash', |
|
| 428 | + 'upload_files' |
|
| 429 | + ); |
|
| 430 | + |
|
| 431 | + // get user setting field names |
|
| 432 | + $settings = array(); |
|
| 433 | + foreach($_POST as $n => $v) { |
|
| 434 | + if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 435 | + continue; |
|
| 436 | + } // ignore blacklist and empties |
|
| 437 | + $settings[$n] = $v; // this value should be saved |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + foreach($defaults as $k) { |
|
| 441 | + if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 442 | + unset($settings[$k]); |
|
| 443 | + } |
|
| 444 | + unset($settings['default_' . $k]); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
| 448 | + |
|
| 449 | + foreach($settings as $n => $vl) { |
|
| 450 | + if(is_array($vl)) { |
|
| 451 | + $vl = implode(",", $vl); |
|
| 452 | + } |
|
| 453 | + if($vl != '') { |
|
| 454 | + $f = array(); |
|
| 455 | + $f['user'] = $id; |
|
| 456 | + $f['setting_name'] = $n; |
|
| 457 | + $f['setting_value'] = $vl; |
|
| 458 | + $f = $modx->db->escape($f); |
|
| 459 | + $modx->db->insert($f, $tbl_user_settings); |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Web alert - sends an alert to web browser |
| 465 | 465 | function webAlertAndQuit($msg) { |
| 466 | - global $id, $modx; |
|
| 467 | - $mode = $_POST['mode']; |
|
| 468 | - $modx->manager->saveFormValues($mode); |
|
| 469 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 466 | + global $id, $modx; |
|
| 467 | + $mode = $_POST['mode']; |
|
| 468 | + $modx->manager->saveFormValues($mode); |
|
| 469 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // Generate password |
| 473 | 473 | function generate_password($length = 10) { |
| 474 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 475 | - $ps_len = strlen($allowable_characters); |
|
| 476 | - mt_srand((double) microtime() * 1000000); |
|
| 477 | - $pass = ""; |
|
| 478 | - for($i = 0; $i < $length; $i++) { |
|
| 479 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 480 | - } |
|
| 481 | - return $pass; |
|
| 474 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 475 | + $ps_len = strlen($allowable_characters); |
|
| 476 | + mt_srand((double) microtime() * 1000000); |
|
| 477 | + $pass = ""; |
|
| 478 | + for($i = 0; $i < $length; $i++) { |
|
| 479 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 480 | + } |
|
| 481 | + return $pass; |
|
| 482 | 482 | } |
@@ -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 | |
@@ -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,9 +141,9 @@ 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 | 148 | $f['user_group'] = intval($user_groups[$i]); |
| 149 | 149 | $f['member'] = $internalKey; |
@@ -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,11 +286,11 @@ 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 | 295 | $field['user_group'] = intval($user_groups[$i]); |
| 296 | 296 | $field['member'] = $id; |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | // end of user_groups stuff! |
| 302 | 302 | /*******************************************************************************/ |
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 303 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | 304 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
| 305 | 305 | } |
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 306 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if ($input['stay'] != '') { |
|
| 308 | 308 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 310 | 310 | } else { |
| 311 | 311 | $stayUrl = "index.php?a=75&r=2"; |
| 312 | 312 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
| 327 | 327 | <div class="sectionBody"> |
| 328 | 328 | <div id="disp"> |
| 329 | - <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
| 329 | + <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
| 330 | 330 | </div> |
| 331 | 331 | </div> |
| 332 | 332 | </div> |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | include_once "footer.inc.php"; |
| 336 | 336 | } else { |
| 337 | - if($input['stay'] != '') { |
|
| 337 | + if ($input['stay'] != '') { |
|
| 338 | 338 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 340 | 340 | header($header); |
| 341 | 341 | } else { |
| 342 | 342 | $header = "Location: index.php?a=75&r=2"; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
| 352 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 352 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
| 353 | 353 | global $modx, $_lang, $signupemail_message; |
| 354 | 354 | global $emailsubject, $emailsender; |
| 355 | 355 | global $site_name; |
@@ -371,14 +371,14 @@ discard block |
||
| 371 | 371 | $param['to'] = $email; |
| 372 | 372 | $param['type'] = 'text'; |
| 373 | 373 | $rs = $modx->sendmail($param); |
| 374 | - if(!$rs) { |
|
| 374 | + if (!$rs) { |
|
| 375 | 375 | $modx->manager->saveFormValues(); |
| 376 | 376 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Save User Settings |
| 381 | -function saveUserSettings($id) { |
|
| 381 | +function saveUserSettings($id){ |
|
| 382 | 382 | global $modx; |
| 383 | 383 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
| 384 | 384 | |
@@ -430,27 +430,27 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // get user setting field names |
| 432 | 432 | $settings = array(); |
| 433 | - foreach($_POST as $n => $v) { |
|
| 434 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 433 | + foreach ($_POST as $n => $v) { |
|
| 434 | + if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 435 | 435 | continue; |
| 436 | 436 | } // ignore blacklist and empties |
| 437 | 437 | $settings[$n] = $v; // this value should be saved |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - foreach($defaults as $k) { |
|
| 441 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 440 | + foreach ($defaults as $k) { |
|
| 441 | + if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') { |
|
| 442 | 442 | unset($settings[$k]); |
| 443 | 443 | } |
| 444 | - unset($settings['default_' . $k]); |
|
| 444 | + unset($settings['default_'.$k]); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
| 448 | 448 | |
| 449 | - foreach($settings as $n => $vl) { |
|
| 450 | - if(is_array($vl)) { |
|
| 449 | + foreach ($settings as $n => $vl) { |
|
| 450 | + if (is_array($vl)) { |
|
| 451 | 451 | $vl = implode(",", $vl); |
| 452 | 452 | } |
| 453 | - if($vl != '') { |
|
| 453 | + if ($vl != '') { |
|
| 454 | 454 | $f = array(); |
| 455 | 455 | $f['user'] = $id; |
| 456 | 456 | $f['setting_name'] = $n; |
@@ -462,20 +462,20 @@ discard block |
||
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Web alert - sends an alert to web browser |
| 465 | -function webAlertAndQuit($msg) { |
|
| 465 | +function webAlertAndQuit($msg){ |
|
| 466 | 466 | global $id, $modx; |
| 467 | 467 | $mode = $_POST['mode']; |
| 468 | 468 | $modx->manager->saveFormValues($mode); |
| 469 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 469 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : '')); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // Generate password |
| 473 | -function generate_password($length = 10) { |
|
| 473 | +function generate_password($length = 10){ |
|
| 474 | 474 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 475 | 475 | $ps_len = strlen($allowable_characters); |
| 476 | 476 | mt_srand((double) microtime() * 1000000); |
| 477 | 477 | $pass = ""; |
| 478 | - for($i = 0; $i < $length; $i++) { |
|
| 478 | + for ($i = 0; $i < $length; $i++) { |
|
| 479 | 479 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
| 480 | 480 | } |
| 481 | 481 | return $pass; |
@@ -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 | // saves module user group access |
@@ -1,5 +1,5 @@ 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')) { |
@@ -29,7 +29,7 @@ discard block |
||
| 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']); |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | $enable_sharedparams = isset($parsed['shareparams']) ? intval($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); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | } |
| 22 | 22 | elseif(is_writable($htaccess)) |
| 23 | 23 | { |
| 24 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 24 | + $_ = preg_replace('@RewriteBase.+@',"rewritebase {$dir}", $_); |
|
| 25 | 25 | if(!@file_put_contents($htaccess,$_)) |
| 26 | 26 | { |
| 27 | 27 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | elseif($modx->config['base_url']!=='/') |
| 38 | 38 | { |
| 39 | 39 | $_ = file_get_contents($htaccess); |
| 40 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 40 | + $_ = preg_replace('@RewriteBase.+@',"rewritebase {$dir}", $_); |
|
| 41 | 41 | if(!@file_put_contents($htaccess,$_)) |
| 42 | 42 | { |
| 43 | 43 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('settings')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | $data = $_POST; |
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
@@ -11,41 +11,41 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
| 13 | 13 | { |
| 14 | - $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | - $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | - $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | - if(is_file($htaccess)) |
|
| 18 | - { |
|
| 19 | - $_ = file_get_contents($htaccess); |
|
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 21 | - { |
|
| 22 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 23 | - } |
|
| 24 | - elseif(is_writable($htaccess)) |
|
| 25 | - { |
|
| 26 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 28 | - { |
|
| 29 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 34 | - { |
|
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 14 | + $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | + $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | + $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | + if(is_file($htaccess)) |
|
| 18 | + { |
|
| 19 | + $_ = file_get_contents($htaccess); |
|
| 20 | + if(strpos($_,'RewriteBase')===false) |
|
| 36 | 21 | { |
| 37 | - $warnings[] = $_lang["settings_friendlyurls_alert"]; |
|
| 38 | - } |
|
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 40 | - { |
|
| 41 | - $_ = file_get_contents($htaccess); |
|
| 42 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 44 | - { |
|
| 45 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 22 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 23 | + } |
|
| 24 | + elseif(is_writable($htaccess)) |
|
| 25 | + { |
|
| 26 | + $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | + if(!@file_put_contents($htaccess,$_)) |
|
| 28 | + { |
|
| 29 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + elseif(is_file($sample_htaccess)) |
|
| 34 | + { |
|
| 35 | + if(!@rename($sample_htaccess,$htaccess)) |
|
| 36 | + { |
|
| 37 | + $warnings[] = $_lang["settings_friendlyurls_alert"]; |
|
| 38 | + } |
|
| 39 | + elseif($modx->config['base_url']!=='/') |
|
| 40 | + { |
|
| 41 | + $_ = file_get_contents($htaccess); |
|
| 42 | + $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | + if(!@file_put_contents($htaccess,$_)) |
|
| 44 | + { |
|
| 45 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | $data['rb_base_dir'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['rb_base_dir']); |
| 57 | 57 | |
| 58 | 58 | if (isset($data) && count($data) > 0) { |
| 59 | - if(isset($data['manager_language'])) { |
|
| 60 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | - if(is_file($lang_path)) { |
|
| 62 | - include($lang_path); |
|
| 59 | + if(isset($data['manager_language'])) { |
|
| 60 | + $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | + if(is_file($lang_path)) { |
|
| 62 | + include($lang_path); |
|
| 63 | 63 | global $modx_lang_attribute; |
| 64 | 64 | $data['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; |
| 65 | - } |
|
| 66 | - } |
|
| 67 | - $savethese = array(); |
|
| 68 | - $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
|
| 69 | - $data['mail_check_timeperiod'] = intval($data['mail_check_timeperiod']) < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | - foreach ($data as $k => $v) { |
|
| 71 | - switch ($k) { |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + $savethese = array(); |
|
| 68 | + $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
|
| 69 | + $data['mail_check_timeperiod'] = intval($data['mail_check_timeperiod']) < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | + foreach ($data as $k => $v) { |
|
| 71 | + switch ($k) { |
|
| 72 | 72 | case 'settings_version':{ |
| 73 | 73 | if($modx->getVersionData('version')!=$data['settings_version']){ |
| 74 | 74 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
@@ -76,24 +76,24 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | break; |
| 78 | 78 | } |
| 79 | - case 'error_page': |
|
| 80 | - case 'unauthorized_page': |
|
| 81 | - if (trim($v) == '' || !is_numeric($v)) { |
|
| 82 | - $v = $data['site_start']; |
|
| 83 | - } |
|
| 84 | - break; |
|
| 79 | + case 'error_page': |
|
| 80 | + case 'unauthorized_page': |
|
| 81 | + if (trim($v) == '' || !is_numeric($v)) { |
|
| 82 | + $v = $data['site_start']; |
|
| 83 | + } |
|
| 84 | + break; |
|
| 85 | 85 | |
| 86 | - case 'lst_custom_contenttype': |
|
| 87 | - case 'txt_custom_contenttype': |
|
| 88 | - // Skip these |
|
| 89 | - $k = ''; |
|
| 90 | - break; |
|
| 91 | - case 'rb_base_dir': |
|
| 92 | - case 'rb_base_url': |
|
| 93 | - case 'filemanager_path': |
|
| 94 | - $v = trim($v); |
|
| 95 | - $v = rtrim($v,'/') . '/'; |
|
| 96 | - break; |
|
| 86 | + case 'lst_custom_contenttype': |
|
| 87 | + case 'txt_custom_contenttype': |
|
| 88 | + // Skip these |
|
| 89 | + $k = ''; |
|
| 90 | + break; |
|
| 91 | + case 'rb_base_dir': |
|
| 92 | + case 'rb_base_url': |
|
| 93 | + case 'filemanager_path': |
|
| 94 | + $v = trim($v); |
|
| 95 | + $v = rtrim($v,'/') . '/'; |
|
| 96 | + break; |
|
| 97 | 97 | case 'manager_language': |
| 98 | 98 | $langDir = realpath(MODX_MANAGER_PATH . 'includes/lang'); |
| 99 | 99 | $langFile = realpath(MODX_MANAGER_PATH . 'includes/lang/' . $v . '.inc.php'); |
@@ -101,56 +101,56 @@ discard block |
||
| 101 | 101 | if($langDir !== $langFileDir || !file_exists($langFile)) { |
| 102 | 102 | $v = 'english'; |
| 103 | 103 | } |
| 104 | - break; |
|
| 105 | - case 'smtppw': |
|
| 106 | - if ($v !== '********************' && $v !== '') { |
|
| 107 | - $v = trim($v); |
|
| 108 | - $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | - $v = str_replace('=','%',$v); |
|
| 110 | - } elseif ($v === '********************') { |
|
| 111 | - $k = ''; |
|
| 112 | - } |
|
| 113 | - break; |
|
| 104 | + break; |
|
| 105 | + case 'smtppw': |
|
| 106 | + if ($v !== '********************' && $v !== '') { |
|
| 107 | + $v = trim($v); |
|
| 108 | + $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | + $v = str_replace('=','%',$v); |
|
| 110 | + } elseif ($v === '********************') { |
|
| 111 | + $k = ''; |
|
| 112 | + } |
|
| 113 | + break; |
|
| 114 | 114 | case 'valid_hostnames': |
| 115 | - $v = str_replace(array(' ,', ', '), ',', $v); |
|
| 116 | - if ($v !== ',') { |
|
| 117 | - $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
|
| 118 | - $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | - @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 120 | - } |
|
| 121 | - $k = ''; |
|
| 122 | - break; |
|
| 123 | - case 'session_timeout': |
|
| 124 | - $mail_check_timeperiod = $data['mail_check_timeperiod']; |
|
| 125 | - $v = intval($v) < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | - break; |
|
| 127 | - default: |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - $v = is_array($v) ? implode(",", $v) : $v; |
|
| 115 | + $v = str_replace(array(' ,', ', '), ',', $v); |
|
| 116 | + if ($v !== ',') { |
|
| 117 | + $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
|
| 118 | + $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | + @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 120 | + } |
|
| 121 | + $k = ''; |
|
| 122 | + break; |
|
| 123 | + case 'session_timeout': |
|
| 124 | + $mail_check_timeperiod = $data['mail_check_timeperiod']; |
|
| 125 | + $v = intval($v) < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | + break; |
|
| 127 | + default: |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + $v = is_array($v) ? implode(",", $v) : $v; |
|
| 131 | 131 | |
| 132 | - $modx->config[$k] = $v; |
|
| 132 | + $modx->config[$k] = $v; |
|
| 133 | 133 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | - } |
|
| 134 | + if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - // Run a single query to save all the values |
|
| 138 | - $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) |
|
| 137 | + // Run a single query to save all the values |
|
| 138 | + $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) |
|
| 139 | 139 | VALUES ".implode(', ', $savethese); |
| 140 | - $modx->db->query($sql); |
|
| 140 | + $modx->db->query($sql); |
|
| 141 | 141 | |
| 142 | - // Reset Template Pages |
|
| 143 | - if (isset($data['reset_template'])) { |
|
| 144 | - $newtemplate = intval($data['default_template']); |
|
| 145 | - $oldtemplate = intval($data['old_template']); |
|
| 146 | - $tbl = $modx->getFullTableName('site_content'); |
|
| 147 | - $reset = $data['reset_template']; |
|
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | - } |
|
| 142 | + // Reset Template Pages |
|
| 143 | + if (isset($data['reset_template'])) { |
|
| 144 | + $newtemplate = intval($data['default_template']); |
|
| 145 | + $oldtemplate = intval($data['old_template']); |
|
| 146 | + $tbl = $modx->getFullTableName('site_content'); |
|
| 147 | + $reset = $data['reset_template']; |
|
| 148 | + if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | + else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - // empty cache |
|
| 153 | - $modx->clearCache('full'); |
|
| 152 | + // empty cache |
|
| 153 | + $modx->clearCache('full'); |
|
| 154 | 154 | } |
| 155 | 155 | $header="Location: index.php?a=7&r=10"; |
| 156 | 156 | header($header); |
@@ -1,46 +1,46 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('settings')) { |
|
| 5 | +if (!$modx->hasPermission('settings')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | $data = $_POST; |
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
| 10 | 10 | unset($_POST); |
| 11 | 11 | |
| 12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
| 12 | +if ($data['friendly_urls'] === '1' && strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') === false) |
|
| 13 | 13 | { |
| 14 | - $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | - $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | - $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | - if(is_file($htaccess)) |
|
| 14 | + $htaccess = $modx->config['base_path'].'.htaccess'; |
|
| 15 | + $sample_htaccess = $modx->config['base_path'].'ht.access'; |
|
| 16 | + $dir = '/'.trim($modx->config['base_url'], '/'); |
|
| 17 | + if (is_file($htaccess)) |
|
| 18 | 18 | { |
| 19 | 19 | $_ = file_get_contents($htaccess); |
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 20 | + if (strpos($_, 'RewriteBase') === false) |
|
| 21 | 21 | { |
| 22 | 22 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 23 | 23 | } |
| 24 | - elseif(is_writable($htaccess)) |
|
| 24 | + elseif (is_writable($htaccess)) |
|
| 25 | 25 | { |
| 26 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 26 | + $_ = preg_replace('@RewriteBase.+@', "RewriteBase {$dir}", $_); |
|
| 27 | + if (!@file_put_contents($htaccess, $_)) |
|
| 28 | 28 | { |
| 29 | 29 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 33 | + elseif (is_file($sample_htaccess)) |
|
| 34 | 34 | { |
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 35 | + if (!@rename($sample_htaccess, $htaccess)) |
|
| 36 | 36 | { |
| 37 | 37 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
| 38 | 38 | } |
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 39 | + elseif ($modx->config['base_url'] !== '/') |
|
| 40 | 40 | { |
| 41 | 41 | $_ = file_get_contents($htaccess); |
| 42 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 42 | + $_ = preg_replace('@RewriteBase.+@', "RewriteBase {$dir}", $_); |
|
| 43 | + if (!@file_put_contents($htaccess, $_)) |
|
| 44 | 44 | { |
| 45 | 45 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 46 | 46 | } |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
| 52 | - unlink(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css'); |
|
| 51 | +if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css')) { |
|
| 52 | + unlink(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -$data['filemanager_path'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['filemanager_path']); |
|
| 56 | -$data['rb_base_dir'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['rb_base_dir']); |
|
| 55 | +$data['filemanager_path'] = str_replace('[(base_path)]', MODX_BASE_PATH, $data['filemanager_path']); |
|
| 56 | +$data['rb_base_dir'] = str_replace('[(base_path)]', MODX_BASE_PATH, $data['rb_base_dir']); |
|
| 57 | 57 | |
| 58 | 58 | if (isset($data) && count($data) > 0) { |
| 59 | - if(isset($data['manager_language'])) { |
|
| 60 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | - if(is_file($lang_path)) { |
|
| 59 | + if (isset($data['manager_language'])) { |
|
| 60 | + $lang_path = MODX_MANAGER_PATH.'includes/lang/'.$data['manager_language'].'.inc.php'; |
|
| 61 | + if (is_file($lang_path)) { |
|
| 62 | 62 | include($lang_path); |
| 63 | 63 | global $modx_lang_attribute; |
| 64 | 64 | $data['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | foreach ($data as $k => $v) { |
| 71 | 71 | switch ($k) { |
| 72 | 72 | case 'settings_version':{ |
| 73 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
| 74 | - $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
|
| 73 | + if ($modx->getVersionData('version') != $data['settings_version']) { |
|
| 74 | + $modx->logEvent(17, 2, '<pre>'.var_export($data['settings_version'], true).'</pre>', 'fake settings_version'); |
|
| 75 | 75 | $v = $modx->getVersionData('version'); |
| 76 | 76 | } |
| 77 | 77 | break; |
@@ -92,21 +92,21 @@ discard block |
||
| 92 | 92 | case 'rb_base_url': |
| 93 | 93 | case 'filemanager_path': |
| 94 | 94 | $v = trim($v); |
| 95 | - $v = rtrim($v,'/') . '/'; |
|
| 95 | + $v = rtrim($v, '/').'/'; |
|
| 96 | 96 | break; |
| 97 | 97 | case 'manager_language': |
| 98 | - $langDir = realpath(MODX_MANAGER_PATH . 'includes/lang'); |
|
| 99 | - $langFile = realpath(MODX_MANAGER_PATH . 'includes/lang/' . $v . '.inc.php'); |
|
| 98 | + $langDir = realpath(MODX_MANAGER_PATH.'includes/lang'); |
|
| 99 | + $langFile = realpath(MODX_MANAGER_PATH.'includes/lang/'.$v.'.inc.php'); |
|
| 100 | 100 | $langFileDir = dirname($langFile); |
| 101 | - if($langDir !== $langFileDir || !file_exists($langFile)) { |
|
| 101 | + if ($langDir !== $langFileDir || !file_exists($langFile)) { |
|
| 102 | 102 | $v = 'english'; |
| 103 | 103 | } |
| 104 | 104 | break; |
| 105 | 105 | case 'smtppw': |
| 106 | 106 | if ($v !== '********************' && $v !== '') { |
| 107 | 107 | $v = trim($v); |
| 108 | - $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | - $v = str_replace('=','%',$v); |
|
| 108 | + $v = base64_encode($v).substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | + $v = str_replace('=', '%', $v); |
|
| 110 | 110 | } elseif ($v === '********************') { |
| 111 | 111 | $k = ''; |
| 112 | 112 | } |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | $v = str_replace(array(' ,', ', '), ',', $v); |
| 116 | 116 | if ($v !== ',') { |
| 117 | 117 | $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
| 118 | - $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | - @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 118 | + $configString = '<?php'."\n".'define(\'MODX_SITE_HOSTNAMES\', \''.$v.'\');'."\n"; |
|
| 119 | + @file_put_contents(MODX_BASE_PATH.'assets/cache/siteHostnames.php', $configString); |
|
| 120 | 120 | } |
| 121 | 121 | $k = ''; |
| 122 | 122 | break; |
| 123 | 123 | case 'session_timeout': |
| 124 | 124 | $mail_check_timeperiod = $data['mail_check_timeperiod']; |
| 125 | - $v = intval($v) < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 125 | + $v = intval($v) < ($data['mail_check_timeperiod'] / 60 + 1) ? ($data['mail_check_timeperiod'] / 60 + 1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | 126 | break; |
| 127 | 127 | default: |
| 128 | 128 | break; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $modx->config[$k] = $v; |
| 133 | 133 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 134 | + if (!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Run a single query to save all the values |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | $oldtemplate = intval($data['old_template']); |
| 146 | 146 | $tbl = $modx->getFullTableName('site_content'); |
| 147 | 147 | $reset = $data['reset_template']; |
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 148 | + if ($reset == 1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | + else if ($reset == 2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // empty cache |
| 153 | 153 | $modx->clearCache('full'); |
| 154 | 154 | } |
| 155 | -$header="Location: index.php?a=7&r=10"; |
|
| 155 | +$header = "Location: index.php?a=7&r=10"; |
|
| 156 | 156 | header($header); |
@@ -9,39 +9,27 @@ discard block |
||
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
| 10 | 10 | unset($_POST); |
| 11 | 11 | |
| 12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
| 13 | -{ |
|
| 12 | +if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) { |
|
| 14 | 13 | $htaccess = $modx->config['base_path'] . '.htaccess'; |
| 15 | 14 | $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
| 16 | 15 | $dir = '/' . trim($modx->config['base_url'],'/'); |
| 17 | - if(is_file($htaccess)) |
|
| 18 | - { |
|
| 16 | + if(is_file($htaccess)) { |
|
| 19 | 17 | $_ = file_get_contents($htaccess); |
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 21 | - { |
|
| 18 | + if(strpos($_,'RewriteBase')===false) { |
|
| 22 | 19 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 23 | - } |
|
| 24 | - elseif(is_writable($htaccess)) |
|
| 25 | - { |
|
| 20 | + } elseif(is_writable($htaccess)) { |
|
| 26 | 21 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 28 | - { |
|
| 22 | + if(!@file_put_contents($htaccess,$_)) { |
|
| 29 | 23 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 30 | 24 | } |
| 31 | 25 | } |
| 32 | - } |
|
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 34 | - { |
|
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 36 | - { |
|
| 26 | + } elseif(is_file($sample_htaccess)) { |
|
| 27 | + if(!@rename($sample_htaccess,$htaccess)) { |
|
| 37 | 28 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
| 38 | - } |
|
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 40 | - { |
|
| 29 | + } elseif($modx->config['base_url']!=='/') { |
|
| 41 | 30 | $_ = file_get_contents($htaccess); |
| 42 | 31 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 44 | - { |
|
| 32 | + if(!@file_put_contents($htaccess,$_)) { |
|
| 45 | 33 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 46 | 34 | } |
| 47 | 35 | } |
@@ -70,7 +58,7 @@ discard block |
||
| 70 | 58 | foreach ($data as $k => $v) { |
| 71 | 59 | switch ($k) { |
| 72 | 60 | case 'settings_version':{ |
| 73 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
| 61 | + if($modx->getVersionData('version')!=$data['settings_version']) { |
|
| 74 | 62 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
| 75 | 63 | $v = $modx->getVersionData('version'); |
| 76 | 64 | } |
@@ -131,7 +119,9 @@ discard block |
||
| 131 | 119 | |
| 132 | 120 | $modx->config[$k] = $v; |
| 133 | 121 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 122 | + if(!empty($k)) { |
|
| 123 | + $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 124 | + } |
|
| 135 | 125 | } |
| 136 | 126 | |
| 137 | 127 | // Run a single query to save all the values |
@@ -145,8 +135,11 @@ discard block |
||
| 145 | 135 | $oldtemplate = intval($data['old_template']); |
| 146 | 136 | $tbl = $modx->getFullTableName('site_content'); |
| 147 | 137 | $reset = $data['reset_template']; |
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 138 | + if($reset==1) { |
|
| 139 | + $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 140 | + } else if($reset==2) { |
|
| 141 | + $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 142 | + } |
|
| 150 | 143 | } |
| 151 | 144 | |
| 152 | 145 | // empty cache |
@@ -16,24 +16,24 @@ |
||
| 16 | 16 | $pth = dirname(dirname(dirname(__FILE__)))."/install/"; |
| 17 | 17 | $pth = str_replace("\\","/",$pth); |
| 18 | 18 | if(isset($_GET["rminstall"])) { |
| 19 | - if(is_dir($pth)) { |
|
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 21 | - } |
|
| 19 | + if(is_dir($pth)) { |
|
| 20 | + if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 21 | + } |
|
| 22 | 22 | } |
| 23 | 23 | if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
| 24 | 24 | echo "<script>window.location='../index.php?a=2';</script>"; |
| 25 | 25 | |
| 26 | 26 | // rmdirRecursive - detects symbollic links on unix |
| 27 | 27 | function rmdirRecursive($path,$followLinks=false) { |
| 28 | - $dir = opendir($path) ; |
|
| 29 | - while ($entry = readdir($dir)) { |
|
| 30 | - if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
|
| 31 | - @unlink( "$path/$entry" ); |
|
| 32 | - } |
|
| 33 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 34 | - rmdirRecursive("$path/$entry"); // recursive |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - closedir($dir); |
|
| 38 | - return @rmdir($path); |
|
| 28 | + $dir = opendir($path) ; |
|
| 29 | + while ($entry = readdir($dir)) { |
|
| 30 | + if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
|
| 31 | + @unlink( "$path/$entry" ); |
|
| 32 | + } |
|
| 33 | + elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 34 | + rmdirRecursive("$path/$entry"); // recursive |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + closedir($dir); |
|
| 38 | + return @rmdir($path); |
|
| 39 | 39 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -$msg =''; |
|
| 15 | +$msg = ''; |
|
| 16 | 16 | $pth = dirname(dirname(dirname(__FILE__)))."/install/"; |
| 17 | -$pth = str_replace("\\","/",$pth); |
|
| 18 | -if(isset($_GET["rminstall"])) { |
|
| 19 | - if(is_dir($pth)) { |
|
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 17 | +$pth = str_replace("\\", "/", $pth); |
|
| 18 | +if (isset($_GET["rminstall"])) { |
|
| 19 | + if (is_dir($pth)) { |
|
| 20 | + if (!rmdirRecursive($pth)) $msg = "An error occured while attempting to remove the install folder"; |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | -if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 23 | +if ($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 24 | 24 | echo "<script>window.location='../index.php?a=2';</script>"; |
| 25 | 25 | |
| 26 | 26 | // rmdirRecursive - detects symbollic links on unix |
| 27 | -function rmdirRecursive($path,$followLinks=false) { |
|
| 28 | - $dir = opendir($path) ; |
|
| 27 | +function rmdirRecursive($path, $followLinks = false){ |
|
| 28 | + $dir = opendir($path); |
|
| 29 | 29 | while ($entry = readdir($dir)) { |
| 30 | 30 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
| 31 | - @unlink( "$path/$entry" ); |
|
| 31 | + @unlink("$path/$entry"); |
|
| 32 | 32 | } |
| 33 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 33 | + elseif (is_dir("$path/$entry") && $entry != '.' && $entry != '..') { |
|
| 34 | 34 | rmdirRecursive("$path/$entry"); // recursive |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -17,20 +17,24 @@ |
||
| 17 | 17 | $pth = str_replace("\\","/",$pth); |
| 18 | 18 | if(isset($_GET["rminstall"])) { |
| 19 | 19 | if(is_dir($pth)) { |
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 20 | + if(!rmdirRecursive($pth)) { |
|
| 21 | + $msg="An error occured while attempting to remove the install folder"; |
|
| 22 | + } |
|
| 21 | 23 | } |
| 22 | 24 | } |
| 23 | -if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 25 | +if($msg) { |
|
| 26 | + echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 27 | +} |
|
| 24 | 28 | echo "<script>window.location='../index.php?a=2';</script>"; |
| 25 | 29 | |
| 26 | 30 | // rmdirRecursive - detects symbollic links on unix |
| 27 | -function rmdirRecursive($path,$followLinks=false) { |
|
| 31 | +function rmdirRecursive($path,$followLinks=false) |
|
| 32 | +{ |
|
| 28 | 33 | $dir = opendir($path) ; |
| 29 | - while ($entry = readdir($dir)) { |
|
| 34 | + while ($entry = readdir($dir)) { |
|
| 30 | 35 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
| 31 | 36 | @unlink( "$path/$entry" ); |
| 32 | - } |
|
| 33 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 37 | + } elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 34 | 38 | rmdirRecursive("$path/$entry"); // recursive |
| 35 | 39 | } |
| 36 | 40 | } |
@@ -491,7 +491,7 @@ |
||
| 491 | 491 | }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
| 492 | 492 | $publishedon = $pub_date; |
| 493 | 493 | $publishedby = $modx->getLoginUserID(); |
| 494 | - }elseif ($was_published && !$published) { |
|
| 494 | + }elseif ($was_published && !$published) { |
|
| 495 | 495 | $publishedon = 0; |
| 496 | 496 | $publishedby = 0; |
| 497 | 497 | } else { |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | switch ($actionToTake) { |
| 278 | - case 'new' : |
|
| 278 | + case 'new' : |
|
| 279 | 279 | |
| 280 | - // invoke OnBeforeDocFormSave event |
|
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 282 | - { |
|
| 280 | + // invoke OnBeforeDocFormSave event |
|
| 281 | + switch($modx->config['docid_incrmnt_method']) |
|
| 282 | + { |
|
| 283 | 283 | case '1': |
| 284 | 284 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
| 285 | 285 | $where = "T1.id IS NULL"; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | default: |
| 295 | 295 | $id = ''; |
| 296 | - } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | 298 | $modx->invokeEvent("OnBeforeDocFormSave", array ( |
| 299 | 299 | "mode" => "new", |
@@ -444,256 +444,256 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | |
| 446 | 446 | break; |
| 447 | - case 'edit' : |
|
| 448 | - |
|
| 449 | - // get the document's current parent |
|
| 450 | - $oldparent = $existingDocument['parent']; |
|
| 451 | - $doctype = $existingDocument['type']; |
|
| 452 | - |
|
| 453 | - if ($id == $site_start && $published == 0) { |
|
| 454 | - $modx->manager->saveFormValues(27); |
|
| 455 | - $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!"); |
|
| 456 | - } |
|
| 457 | - $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; |
|
| 458 | - if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) { |
|
| 459 | - $modx->manager->saveFormValues(27); |
|
| 460 | - $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!"); |
|
| 461 | - } |
|
| 462 | - if ($parent == $id) { |
|
| 463 | - $modx->manager->saveFormValues(27); |
|
| 464 | - $modx->webAlertAndQuit("Document can not be it's own parent!"); |
|
| 465 | - } |
|
| 447 | + case 'edit' : |
|
| 466 | 448 | |
| 467 | - $parents = $modx->getParentIds($parent); |
|
| 468 | - if (in_array($id, $parents)) { |
|
| 469 | - $modx->webAlertAndQuit("Document descendant can not be it's parent!"); |
|
| 470 | - } |
|
| 449 | + // get the document's current parent |
|
| 450 | + $oldparent = $existingDocument['parent']; |
|
| 451 | + $doctype = $existingDocument['type']; |
|
| 471 | 452 | |
| 472 | - // check to see document is a folder |
|
| 473 | - $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'"); |
|
| 474 | - $count = $modx->db->getValue($rs); |
|
| 475 | - if ($count > 0) { |
|
| 476 | - $isfolder = 1; |
|
| 477 | - } |
|
| 453 | + if ($id == $site_start && $published == 0) { |
|
| 454 | + $modx->manager->saveFormValues(27); |
|
| 455 | + $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!"); |
|
| 456 | + } |
|
| 457 | + $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; |
|
| 458 | + if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) { |
|
| 459 | + $modx->manager->saveFormValues(27); |
|
| 460 | + $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!"); |
|
| 461 | + } |
|
| 462 | + if ($parent == $id) { |
|
| 463 | + $modx->manager->saveFormValues(27); |
|
| 464 | + $modx->webAlertAndQuit("Document can not be it's own parent!"); |
|
| 465 | + } |
|
| 478 | 466 | |
| 479 | - // set publishedon and publishedby |
|
| 480 | - $was_published = $existingDocument['published']; |
|
| 467 | + $parents = $modx->getParentIds($parent); |
|
| 468 | + if (in_array($id, $parents)) { |
|
| 469 | + $modx->webAlertAndQuit("Document descendant can not be it's parent!"); |
|
| 470 | + } |
|
| 481 | 471 | |
| 482 | - // keep original publish state, if change is not permitted |
|
| 483 | - if (!$modx->hasPermission('publish_document')) { |
|
| 484 | - $published = $was_published; |
|
| 485 | - $pub_date = 'pub_date'; |
|
| 486 | - $unpub_date = 'unpub_date'; |
|
| 487 | - } |
|
| 472 | + // check to see document is a folder |
|
| 473 | + $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'"); |
|
| 474 | + $count = $modx->db->getValue($rs); |
|
| 475 | + if ($count > 0) { |
|
| 476 | + $isfolder = 1; |
|
| 477 | + } |
|
| 488 | 478 | |
| 489 | - // if it was changed from unpublished to published |
|
| 490 | - if (!$was_published && $published) { |
|
| 491 | - $publishedon = $currentdate; |
|
| 492 | - $publishedby = $modx->getLoginUserID(); |
|
| 493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 494 | - $publishedon = $pub_date; |
|
| 495 | - $publishedby = $modx->getLoginUserID(); |
|
| 496 | - }elseif ($was_published && !$published) { |
|
| 497 | - $publishedon = 0; |
|
| 498 | - $publishedby = 0; |
|
| 499 | - } else { |
|
| 500 | - $publishedon = 'publishedon'; |
|
| 501 | - $publishedby = 'publishedby'; |
|
| 502 | - } |
|
| 479 | + // set publishedon and publishedby |
|
| 480 | + $was_published = $existingDocument['published']; |
|
| 503 | 481 | |
| 504 | - // invoke OnBeforeDocFormSave event |
|
| 505 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 506 | - "mode" => "upd", |
|
| 507 | - "id" => $id |
|
| 508 | - )); |
|
| 482 | + // keep original publish state, if change is not permitted |
|
| 483 | + if (!$modx->hasPermission('publish_document')) { |
|
| 484 | + $published = $was_published; |
|
| 485 | + $pub_date = 'pub_date'; |
|
| 486 | + $unpub_date = 'unpub_date'; |
|
| 487 | + } |
|
| 509 | 488 | |
| 510 | - // update the document |
|
| 511 | - $modx->db->update( |
|
| 512 | - "introtext='{$introtext}', " |
|
| 513 | - . "content='{$content}', " |
|
| 514 | - . "pagetitle='{$pagetitle}', " |
|
| 515 | - . "longtitle='{$longtitle}', " |
|
| 516 | - . "type='{$type}', " |
|
| 517 | - . "description='{$description}', " |
|
| 518 | - . "alias='{$alias}', " |
|
| 519 | - . "link_attributes='{$link_attributes}', " |
|
| 520 | - . "isfolder={$isfolder}, " |
|
| 521 | - . "richtext={$richtext}, " |
|
| 522 | - . "published={$published}, " |
|
| 523 | - . "pub_date={$pub_date}, " |
|
| 524 | - . "unpub_date={$unpub_date}, " |
|
| 525 | - . "parent={$parent}, " |
|
| 526 | - . "template={$template}, " |
|
| 527 | - . "menuindex={$menuindex}, " |
|
| 528 | - . "searchable={$searchable}, " |
|
| 529 | - . "cacheable={$cacheable}, " |
|
| 530 | - . "editedby=" . $modx->getLoginUserID() . ", " |
|
| 531 | - . "editedon={$currentdate}, " |
|
| 532 | - . "publishedon={$publishedon}, " |
|
| 533 | - . "publishedby={$publishedby}, " |
|
| 534 | - . "contentType='{$contentType}', " |
|
| 535 | - . "content_dispo={$contentdispo}, " |
|
| 536 | - . "donthit={$donthit}, " |
|
| 537 | - . "menutitle='{$menutitle}', " |
|
| 538 | - . "hidemenu={$hidemenu}, " |
|
| 539 | - . "alias_visible={$aliasvisible}" |
|
| 540 | - , $tbl_site_content, "id='{$id}'"); |
|
| 541 | - |
|
| 542 | - // update template variables |
|
| 543 | - $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
|
| 544 | - $tvIds = array (); |
|
| 545 | - while ($row = $modx->db->getRow($rs)) { |
|
| 546 | - $tvIds[$row['tmplvarid']] = $row['id']; |
|
| 547 | - } |
|
| 548 | - $tvDeletions = array(); |
|
| 549 | - $tvChanges = array(); |
|
| 550 | - foreach ($tmplvars as $field => $value) { |
|
| 551 | - if (!is_array($value)) { |
|
| 552 | - if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 489 | + // if it was changed from unpublished to published |
|
| 490 | + if (!$was_published && $published) { |
|
| 491 | + $publishedon = $currentdate; |
|
| 492 | + $publishedby = $modx->getLoginUserID(); |
|
| 493 | + }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 494 | + $publishedon = $pub_date; |
|
| 495 | + $publishedby = $modx->getLoginUserID(); |
|
| 496 | + }elseif ($was_published && !$published) { |
|
| 497 | + $publishedon = 0; |
|
| 498 | + $publishedby = 0; |
|
| 553 | 499 | } else { |
| 554 | - $tvId = $value[0]; |
|
| 555 | - $tvVal = $value[1]; |
|
| 500 | + $publishedon = 'publishedon'; |
|
| 501 | + $publishedby = 'publishedby'; |
|
| 502 | + } |
|
| 556 | 503 | |
| 557 | - if (isset($tvIds[$tvId])) { |
|
| 558 | - $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId])); |
|
| 504 | + // invoke OnBeforeDocFormSave event |
|
| 505 | + $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 506 | + "mode" => "upd", |
|
| 507 | + "id" => $id |
|
| 508 | + )); |
|
| 509 | + |
|
| 510 | + // update the document |
|
| 511 | + $modx->db->update( |
|
| 512 | + "introtext='{$introtext}', " |
|
| 513 | + . "content='{$content}', " |
|
| 514 | + . "pagetitle='{$pagetitle}', " |
|
| 515 | + . "longtitle='{$longtitle}', " |
|
| 516 | + . "type='{$type}', " |
|
| 517 | + . "description='{$description}', " |
|
| 518 | + . "alias='{$alias}', " |
|
| 519 | + . "link_attributes='{$link_attributes}', " |
|
| 520 | + . "isfolder={$isfolder}, " |
|
| 521 | + . "richtext={$richtext}, " |
|
| 522 | + . "published={$published}, " |
|
| 523 | + . "pub_date={$pub_date}, " |
|
| 524 | + . "unpub_date={$unpub_date}, " |
|
| 525 | + . "parent={$parent}, " |
|
| 526 | + . "template={$template}, " |
|
| 527 | + . "menuindex={$menuindex}, " |
|
| 528 | + . "searchable={$searchable}, " |
|
| 529 | + . "cacheable={$cacheable}, " |
|
| 530 | + . "editedby=" . $modx->getLoginUserID() . ", " |
|
| 531 | + . "editedon={$currentdate}, " |
|
| 532 | + . "publishedon={$publishedon}, " |
|
| 533 | + . "publishedby={$publishedby}, " |
|
| 534 | + . "contentType='{$contentType}', " |
|
| 535 | + . "content_dispo={$contentdispo}, " |
|
| 536 | + . "donthit={$donthit}, " |
|
| 537 | + . "menutitle='{$menutitle}', " |
|
| 538 | + . "hidemenu={$hidemenu}, " |
|
| 539 | + . "alias_visible={$aliasvisible}" |
|
| 540 | + , $tbl_site_content, "id='{$id}'"); |
|
| 541 | + |
|
| 542 | + // update template variables |
|
| 543 | + $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
|
| 544 | + $tvIds = array (); |
|
| 545 | + while ($row = $modx->db->getRow($rs)) { |
|
| 546 | + $tvIds[$row['tmplvarid']] = $row['id']; |
|
| 547 | + } |
|
| 548 | + $tvDeletions = array(); |
|
| 549 | + $tvChanges = array(); |
|
| 550 | + foreach ($tmplvars as $field => $value) { |
|
| 551 | + if (!is_array($value)) { |
|
| 552 | + if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 559 | 553 | } else { |
| 560 | - $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)); |
|
| 554 | + $tvId = $value[0]; |
|
| 555 | + $tvVal = $value[1]; |
|
| 556 | + |
|
| 557 | + if (isset($tvIds[$tvId])) { |
|
| 558 | + $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId])); |
|
| 559 | + } else { |
|
| 560 | + $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)); |
|
| 561 | + } |
|
| 561 | 562 | } |
| 562 | 563 | } |
| 563 | - } |
|
| 564 | 564 | |
| 565 | - if (!empty($tvDeletions)) { |
|
| 566 | - $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')'); |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - if (!empty($tvAdded)) { |
|
| 570 | - foreach ($tvAdded as $tv) { |
|
| 571 | - $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues); |
|
| 565 | + if (!empty($tvDeletions)) { |
|
| 566 | + $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')'); |
|
| 572 | 567 | } |
| 573 | - } |
|
| 574 | 568 | |
| 575 | - if (!empty($tvChanges)) { |
|
| 576 | - foreach ($tvChanges as $tv) { |
|
| 577 | - $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'"); |
|
| 569 | + if (!empty($tvAdded)) { |
|
| 570 | + foreach ($tvAdded as $tv) { |
|
| 571 | + $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues); |
|
| 572 | + } |
|
| 578 | 573 | } |
| 579 | - } |
|
| 580 | 574 | |
| 581 | - // set document permissions |
|
| 582 | - if ($use_udperms == 1 && is_array($document_groups)) { |
|
| 583 | - $new_groups = array(); |
|
| 584 | - // process the new input |
|
| 585 | - foreach ($document_groups as $value_pair) { |
|
| 586 | - list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
|
| 587 | - $new_groups[$group] = $link_id; |
|
| 575 | + if (!empty($tvChanges)) { |
|
| 576 | + foreach ($tvChanges as $tv) { |
|
| 577 | + $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'"); |
|
| 578 | + } |
|
| 588 | 579 | } |
| 589 | 580 | |
| 590 | - // grab the current set of permissions on this document the user can access |
|
| 591 | - $isManager = $modx->hasPermission('access_permissions'); |
|
| 592 | - $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 593 | - $rs = $modx->db->select( |
|
| 594 | - 'groups.id, groups.document_group', |
|
| 595 | - "{$tbl_document_groups} AS groups |
|
| 581 | + // set document permissions |
|
| 582 | + if ($use_udperms == 1 && is_array($document_groups)) { |
|
| 583 | + $new_groups = array(); |
|
| 584 | + // process the new input |
|
| 585 | + foreach ($document_groups as $value_pair) { |
|
| 586 | + list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
|
| 587 | + $new_groups[$group] = $link_id; |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + // grab the current set of permissions on this document the user can access |
|
| 591 | + $isManager = $modx->hasPermission('access_permissions'); |
|
| 592 | + $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 593 | + $rs = $modx->db->select( |
|
| 594 | + 'groups.id, groups.document_group', |
|
| 595 | + "{$tbl_document_groups} AS groups |
|
| 596 | 596 | LEFT JOIN {$tbl_documentgroup_names} AS dgn ON dgn.id = groups.document_group", |
| 597 | - "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 598 | - ); |
|
| 599 | - $old_groups = array(); |
|
| 600 | - while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 601 | - |
|
| 602 | - // update the permissions in the database |
|
| 603 | - $insertions = $deletions = array(); |
|
| 604 | - foreach ($new_groups as $group => $link_id) { |
|
| 605 | - if (array_key_exists($group, $old_groups)) { |
|
| 606 | - unset($old_groups[$group]); |
|
| 607 | - continue; |
|
| 608 | - } elseif ($link_id == 'new') { |
|
| 609 | - $insertions[] = '('.(int)$group.','.$id.')'; |
|
| 597 | + "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 598 | + ); |
|
| 599 | + $old_groups = array(); |
|
| 600 | + while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 601 | + |
|
| 602 | + // update the permissions in the database |
|
| 603 | + $insertions = $deletions = array(); |
|
| 604 | + foreach ($new_groups as $group => $link_id) { |
|
| 605 | + if (array_key_exists($group, $old_groups)) { |
|
| 606 | + unset($old_groups[$group]); |
|
| 607 | + continue; |
|
| 608 | + } elseif ($link_id == 'new') { |
|
| 609 | + $insertions[] = '('.(int)$group.','.$id.')'; |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + if (!empty($insertions)) { |
|
| 613 | + $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions)); |
|
| 614 | + } |
|
| 615 | + if (!empty($old_groups)) { |
|
| 616 | + $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")"); |
|
| 617 | + } |
|
| 618 | + // necessary to remove all permissions as document is public |
|
| 619 | + if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) { |
|
| 620 | + $modx->db->delete($tbl_document_groups, "document='{$id}'"); |
|
| 610 | 621 | } |
| 611 | 622 | } |
| 612 | - if (!empty($insertions)) { |
|
| 613 | - $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions)); |
|
| 614 | - } |
|
| 615 | - if (!empty($old_groups)) { |
|
| 616 | - $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")"); |
|
| 617 | - } |
|
| 618 | - // necessary to remove all permissions as document is public |
|
| 619 | - if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) { |
|
| 620 | - $modx->db->delete($tbl_document_groups, "document='{$id}'"); |
|
| 623 | + |
|
| 624 | + // do the parent stuff |
|
| 625 | + if ($parent != 0) { |
|
| 626 | + $fields = array('isfolder' => 1); |
|
| 627 | + $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'"); |
|
| 621 | 628 | } |
| 622 | - } |
|
| 623 | 629 | |
| 624 | - // do the parent stuff |
|
| 625 | - if ($parent != 0) { |
|
| 626 | - $fields = array('isfolder' => 1); |
|
| 627 | - $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'"); |
|
| 628 | - } |
|
| 630 | + // finished moving the document, now check to see if the old_parent should no longer be a folder |
|
| 631 | + $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'"); |
|
| 632 | + $limit = $modx->db->getValue($rs); |
|
| 629 | 633 | |
| 630 | - // finished moving the document, now check to see if the old_parent should no longer be a folder |
|
| 631 | - $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'"); |
|
| 632 | - $limit = $modx->db->getValue($rs); |
|
| 634 | + if ($limit == 0) { |
|
| 635 | + $fields = array('isfolder' => 0); |
|
| 636 | + $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'"); |
|
| 637 | + } |
|
| 633 | 638 | |
| 634 | - if ($limit == 0) { |
|
| 635 | - $fields = array('isfolder' => 0); |
|
| 636 | - $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'"); |
|
| 637 | - } |
|
| 638 | 639 | |
| 640 | + // invoke OnDocFormSave event |
|
| 641 | + $modx->invokeEvent("OnDocFormSave", array ( |
|
| 642 | + "mode" => "upd", |
|
| 643 | + "id" => $id |
|
| 644 | + )); |
|
| 639 | 645 | |
| 640 | - // invoke OnDocFormSave event |
|
| 641 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
| 642 | - "mode" => "upd", |
|
| 643 | - "id" => $id |
|
| 644 | - )); |
|
| 646 | + // secure web documents - flag as private |
|
| 647 | + include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 648 | + secureWebDocument($id); |
|
| 645 | 649 | |
| 646 | - // secure web documents - flag as private |
|
| 647 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 648 | - secureWebDocument($id); |
|
| 649 | - |
|
| 650 | - // secure manager documents - flag as private |
|
| 651 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 652 | - secureMgrDocument($id); |
|
| 650 | + // secure manager documents - flag as private |
|
| 651 | + include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 652 | + secureMgrDocument($id); |
|
| 653 | 653 | |
| 654 | - // Set the item name for logger |
|
| 655 | - $_SESSION['itemname'] = $no_esc_pagetitle; |
|
| 654 | + // Set the item name for logger |
|
| 655 | + $_SESSION['itemname'] = $no_esc_pagetitle; |
|
| 656 | 656 | |
| 657 | - if ($syncsite == 1) { |
|
| 658 | - // empty cache |
|
| 659 | - $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
|
| 660 | - $flag = ''; |
|
| 661 | - foreach($keys as $key) { |
|
| 662 | - if ($existingDocument[$key]===$_POST[$key]) continue; |
|
| 663 | - $flag = 'full'; |
|
| 664 | - break; |
|
| 657 | + if ($syncsite == 1) { |
|
| 658 | + // empty cache |
|
| 659 | + $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
|
| 660 | + $flag = ''; |
|
| 661 | + foreach($keys as $key) { |
|
| 662 | + if ($existingDocument[$key]===$_POST[$key]) continue; |
|
| 663 | + $flag = 'full'; |
|
| 664 | + break; |
|
| 665 | + } |
|
| 666 | + if($flag==='full') $modx->clearCache('full'); |
|
| 667 | + else $modx->clearCache($id); |
|
| 665 | 668 | } |
| 666 | - if($flag==='full') $modx->clearCache('full'); |
|
| 667 | - else $modx->clearCache($id); |
|
| 668 | - } |
|
| 669 | 669 | |
| 670 | - if ($_POST['refresh_preview'] == '1') |
|
| 671 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 672 | - else { |
|
| 673 | - if ($_POST['stay'] != '2' && $id > 0) { |
|
| 674 | - $modx->unlockElement(7, $id); |
|
| 675 | - } |
|
| 676 | - if ($_POST['stay'] != '') { |
|
| 677 | - $id = $_REQUEST['id']; |
|
| 678 | - if ($type == "reference") { |
|
| 679 | - // weblink |
|
| 680 | - $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent"; |
|
| 670 | + if ($_POST['refresh_preview'] == '1') |
|
| 671 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 672 | + else { |
|
| 673 | + if ($_POST['stay'] != '2' && $id > 0) { |
|
| 674 | + $modx->unlockElement(7, $id); |
|
| 675 | + } |
|
| 676 | + if ($_POST['stay'] != '') { |
|
| 677 | + $id = $_REQUEST['id']; |
|
| 678 | + if ($type == "reference") { |
|
| 679 | + // weblink |
|
| 680 | + $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent"; |
|
| 681 | + } else { |
|
| 682 | + // document |
|
| 683 | + $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
|
| 684 | + } |
|
| 685 | + $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
| 681 | 686 | } else { |
| 682 | - // document |
|
| 683 | - $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
|
| 687 | + $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
|
| 684 | 688 | } |
| 685 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
| 689 | + } |
|
| 690 | + if (headers_sent()) { |
|
| 691 | + $header = str_replace('Location: ','',$header); |
|
| 692 | + echo "<script>document.location.href='$header';</script>\n"; |
|
| 686 | 693 | } else { |
| 687 | - $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
|
| 694 | + header($header); |
|
| 688 | 695 | } |
| 689 | - } |
|
| 690 | - if (headers_sent()) { |
|
| 691 | - $header = str_replace('Location: ','',$header); |
|
| 692 | - echo "<script>document.location.href='$header';</script>\n"; |
|
| 693 | - } else { |
|
| 694 | - header($header); |
|
| 695 | - } |
|
| 696 | - break; |
|
| 697 | - default : |
|
| 698 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 696 | + break; |
|
| 697 | + default : |
|
| 698 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 699 | 699 | } |
@@ -1,5 +1,5 @@ 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_document')) { |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | $aliasvisible = $_POST['alias_visible']; |
| 37 | 37 | |
| 38 | 38 | /************* webber ********/ |
| 39 | -$sd=isset($_POST['dir'])?'&dir='.$_POST['dir']:'&dir=DESC'; |
|
| 40 | -$sb=isset($_POST['sort'])?'&sort='.$_POST['sort']:'&sort=pub_date'; |
|
| 41 | -$pg=isset($_POST['page'])?'&page='.(int)$_POST['page']:''; |
|
| 42 | -$add_path=$sd.$sb.$pg; |
|
| 39 | +$sd = isset($_POST['dir']) ? '&dir='.$_POST['dir'] : '&dir=DESC'; |
|
| 40 | +$sb = isset($_POST['sort']) ? '&sort='.$_POST['sort'] : '&sort=pub_date'; |
|
| 41 | +$pg = isset($_POST['page']) ? '&page='.(int) $_POST['page'] : ''; |
|
| 42 | +$add_path = $sd.$sb.$pg; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // auto assign alias |
| 74 | 74 | if (!$alias && $automatic_alias) { |
| 75 | 75 | $alias = strtolower($modx->stripAlias(trim($pagetitle))); |
| 76 | - if(!$allow_duplicate_alias) { |
|
| 76 | + if (!$allow_duplicate_alias) { |
|
| 77 | 77 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND alias='$alias'")) != 0) { |
| 78 | 78 | $cnt = 1; |
| 79 | 79 | $tempAlias = $alias; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | $alias = $tempAlias; |
| 86 | 86 | } |
| 87 | - }else{ |
|
| 87 | + } else { |
|
| 88 | 88 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND parent=$parent AND alias='$alias'")) != 0) { |
| 89 | 89 | $cnt = 1; |
| 90 | 90 | $tempAlias = $alias; |
@@ -165,19 +165,19 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // get document groups for current user |
| 168 | -$tmplvars = array (); |
|
| 168 | +$tmplvars = array(); |
|
| 169 | 169 | if ($_SESSION['mgrDocgroups']) { |
| 170 | 170 | $docgrp = implode(",", $_SESSION['mgrDocgroups']); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // ensure that user has not made this document inaccessible to themselves |
| 174 | -if($_SESSION['mgrRole'] != 1 && is_array($document_groups)) { |
|
| 174 | +if ($_SESSION['mgrRole'] != 1 && is_array($document_groups)) { |
|
| 175 | 175 | $document_group_list = implode(',', $document_groups); |
| 176 | - $document_group_list = implode(',', array_filter(explode(',',$document_group_list), 'is_numeric')); |
|
| 177 | - if(!empty($document_group_list)) { |
|
| 176 | + $document_group_list = implode(',', array_filter(explode(',', $document_group_list), 'is_numeric')); |
|
| 177 | + if (!empty($document_group_list)) { |
|
| 178 | 178 | $rs = $modx->db->select('COUNT(mg.id)', "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg", "mga.membergroup = mg.user_group AND mga.documentgroup IN({$document_group_list}) AND mg.member = {$_SESSION['mgrInternalKey']}"); |
| 179 | 179 | $count = $modx->db->getValue($rs); |
| 180 | - if($count == 0) { |
|
| 180 | + if ($count == 0) { |
|
| 181 | 181 | if ($actionToTake == 'edit') { |
| 182 | 182 | $modx->manager->saveFormValues(27); |
| 183 | 183 | $modx->webAlertAndQuit(sprintf($_lang["resource_permissions_error"]), "index.php?a=27&id={$id}"); |
@@ -195,45 +195,45 @@ discard block |
||
| 195 | 195 | INNER JOIN {$tbl_site_tmplvar_templates} AS tvtpl ON tvtpl.tmplvarid = tv.id |
| 196 | 196 | LEFT JOIN {$tbl_site_tmplvar_contentvalues} AS tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$id}' |
| 197 | 197 | LEFT JOIN {$tbl_site_tmplvar_access} AS tva ON tva.tmplvarid=tv.id", |
| 198 | - "tvtpl.templateid = '{$template}' AND (1='{$_SESSION['mgrRole']}' OR ISNULL(tva.documentgroup)" . ((!$docgrp) ? "" : " OR tva.documentgroup IN ($docgrp)") . ")", |
|
| 198 | + "tvtpl.templateid = '{$template}' AND (1='{$_SESSION['mgrRole']}' OR ISNULL(tva.documentgroup)".((!$docgrp) ? "" : " OR tva.documentgroup IN ($docgrp)").")", |
|
| 199 | 199 | "tv.rank" |
| 200 | 200 | ); |
| 201 | 201 | while ($row = $modx->db->getRow($rs)) { |
| 202 | 202 | $tmplvar = ''; |
| 203 | 203 | switch ($row['type']) { |
| 204 | 204 | case 'url': |
| 205 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
| 206 | - if ($_POST["tv" . $row['id'] . '_prefix'] != '--') { |
|
| 207 | - $tmplvar = str_replace(array ( |
|
| 205 | + $tmplvar = $_POST["tv".$row['id']]; |
|
| 206 | + if ($_POST["tv".$row['id'].'_prefix'] != '--') { |
|
| 207 | + $tmplvar = str_replace(array( |
|
| 208 | 208 | "feed://", |
| 209 | 209 | "ftp://", |
| 210 | 210 | "http://", |
| 211 | 211 | "https://", |
| 212 | 212 | "mailto:" |
| 213 | 213 | ), "", $tmplvar); |
| 214 | - $tmplvar = $_POST["tv" . $row['id'] . '_prefix'] . $tmplvar; |
|
| 214 | + $tmplvar = $_POST["tv".$row['id'].'_prefix'].$tmplvar; |
|
| 215 | 215 | } |
| 216 | 216 | break; |
| 217 | 217 | case 'file': |
| 218 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
| 218 | + $tmplvar = $_POST["tv".$row['id']]; |
|
| 219 | 219 | break; |
| 220 | 220 | default: |
| 221 | - if (is_array($_POST["tv" . $row['id']])) { |
|
| 221 | + if (is_array($_POST["tv".$row['id']])) { |
|
| 222 | 222 | // handles checkboxes & multiple selects elements |
| 223 | - $feature_insert = array (); |
|
| 224 | - $lst = $_POST["tv" . $row['id']]; |
|
| 223 | + $feature_insert = array(); |
|
| 224 | + $lst = $_POST["tv".$row['id']]; |
|
| 225 | 225 | while (list ($featureValue, $feature_item) = each($lst)) { |
| 226 | 226 | $feature_insert[count($feature_insert)] = $feature_item; |
| 227 | 227 | } |
| 228 | 228 | $tmplvar = implode("||", $feature_insert); |
| 229 | 229 | } else { |
| 230 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
| 230 | + $tmplvar = $_POST["tv".$row['id']]; |
|
| 231 | 231 | } |
| 232 | 232 | break; |
| 233 | 233 | } |
| 234 | 234 | // save value if it was modified |
| 235 | 235 | if (strlen($tmplvar) > 0 && $tmplvar != $row['default_text']) { |
| 236 | - $tmplvars[$row['id']] = array ( |
|
| 236 | + $tmplvars[$row['id']] = array( |
|
| 237 | 237 | $row['id'], |
| 238 | 238 | $tmplvar |
| 239 | 239 | ); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // check to see if the user is allowed to save the document in the place he wants to save it in |
| 257 | 257 | if ($use_udperms == 1) { |
| 258 | 258 | if ($existingDocument['parent'] != $parent) { |
| 259 | - include_once MODX_MANAGER_PATH ."processors/user_documents_permissions.class.php"; |
|
| 259 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
| 260 | 260 | $udperms = new udperms(); |
| 261 | 261 | $udperms->user = $modx->getLoginUserID(); |
| 262 | 262 | $udperms->document = $parent; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | case 'new' : |
| 279 | 279 | |
| 280 | 280 | // invoke OnBeforeDocFormSave event |
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 281 | + switch ($modx->config['docid_incrmnt_method']) |
|
| 282 | 282 | { |
| 283 | 283 | case '1': |
| 284 | 284 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $id = $modx->db->getValue($rs); |
| 288 | 288 | break; |
| 289 | 289 | case '2': |
| 290 | - $rs = $modx->db->select('MAX(id)+1',$tbl_site_content); |
|
| 290 | + $rs = $modx->db->select('MAX(id)+1', $tbl_site_content); |
|
| 291 | 291 | $id = $modx->db->getValue($rs); |
| 292 | 292 | break; |
| 293 | 293 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | $id = ''; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 298 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
| 299 | 299 | "mode" => "new", |
| 300 | 300 | "id" => $id |
| 301 | 301 | )); |
@@ -310,48 +310,47 @@ discard block |
||
| 310 | 310 | $publishedon = ($published ? $currentdate : 0); |
| 311 | 311 | $publishedby = ($published ? $modx->getLoginUserID() : 0); |
| 312 | 312 | |
| 313 | - if ((!empty($pub_date))&&($published)){ |
|
| 314 | - $publishedon=$pub_date; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - $dbInsert = array |
|
| 318 | - ( |
|
| 319 | - "introtext" => $introtext , |
|
| 320 | - "content" => $content , |
|
| 321 | - "pagetitle" => $pagetitle , |
|
| 322 | - "longtitle" => $longtitle , |
|
| 323 | - "type" => $type , |
|
| 324 | - "description" => $description , |
|
| 325 | - "alias" => $alias , |
|
| 326 | - "link_attributes" => $link_attributes , |
|
| 327 | - "isfolder" => $isfolder , |
|
| 328 | - "richtext" => $richtext , |
|
| 329 | - "published" => $published , |
|
| 330 | - "parent" => $parent , |
|
| 331 | - "template" => $template , |
|
| 332 | - "menuindex" => $menuindex , |
|
| 333 | - "searchable" => $searchable , |
|
| 334 | - "cacheable" => $cacheable , |
|
| 335 | - "createdby" => $modx->getLoginUserID() , |
|
| 336 | - "createdon" => $currentdate , |
|
| 337 | - "editedby" => $modx->getLoginUserID() , |
|
| 338 | - "editedon" => $currentdate , |
|
| 339 | - "publishedby" => $publishedby , |
|
| 340 | - "publishedon" => $publishedon , |
|
| 341 | - "pub_date" => $pub_date , |
|
| 342 | - "unpub_date" => $unpub_date , |
|
| 343 | - "contentType" => $contentType , |
|
| 344 | - "content_dispo" => $contentdispo , |
|
| 345 | - "donthit" => $donthit , |
|
| 346 | - "menutitle" => $menutitle , |
|
| 347 | - "hidemenu" => $hidemenu , |
|
| 313 | + if ((!empty($pub_date)) && ($published)) { |
|
| 314 | + $publishedon = $pub_date; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + $dbInsert = array( |
|
| 318 | + "introtext" => $introtext, |
|
| 319 | + "content" => $content, |
|
| 320 | + "pagetitle" => $pagetitle, |
|
| 321 | + "longtitle" => $longtitle, |
|
| 322 | + "type" => $type, |
|
| 323 | + "description" => $description, |
|
| 324 | + "alias" => $alias, |
|
| 325 | + "link_attributes" => $link_attributes, |
|
| 326 | + "isfolder" => $isfolder, |
|
| 327 | + "richtext" => $richtext, |
|
| 328 | + "published" => $published, |
|
| 329 | + "parent" => $parent, |
|
| 330 | + "template" => $template, |
|
| 331 | + "menuindex" => $menuindex, |
|
| 332 | + "searchable" => $searchable, |
|
| 333 | + "cacheable" => $cacheable, |
|
| 334 | + "createdby" => $modx->getLoginUserID(), |
|
| 335 | + "createdon" => $currentdate, |
|
| 336 | + "editedby" => $modx->getLoginUserID(), |
|
| 337 | + "editedon" => $currentdate, |
|
| 338 | + "publishedby" => $publishedby, |
|
| 339 | + "publishedon" => $publishedon, |
|
| 340 | + "pub_date" => $pub_date, |
|
| 341 | + "unpub_date" => $unpub_date, |
|
| 342 | + "contentType" => $contentType, |
|
| 343 | + "content_dispo" => $contentdispo, |
|
| 344 | + "donthit" => $donthit, |
|
| 345 | + "menutitle" => $menutitle, |
|
| 346 | + "hidemenu" => $hidemenu, |
|
| 348 | 347 | "alias_visible" => $aliasvisible |
| 349 | 348 | ); |
| 350 | 349 | |
| 351 | 350 | if ($id != '') |
| 352 | 351 | $dbInsert["id"] = $id; |
| 353 | 352 | |
| 354 | - $key = $modx->db->insert( $dbInsert, $tbl_site_content); |
|
| 353 | + $key = $modx->db->insert($dbInsert, $tbl_site_content); |
|
| 355 | 354 | |
| 356 | 355 | $tvChanges = array(); |
| 357 | 356 | foreach ($tmplvars as $field => $value) { |
@@ -373,7 +372,7 @@ discard block |
||
| 373 | 372 | foreach ($document_groups as $value_pair) { |
| 374 | 373 | // first, split the pair (this is a new document, so ignore the second value |
| 375 | 374 | list($group) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
| 376 | - $new_groups[] = '('.(int)$group.','.$key.')'; |
|
| 375 | + $new_groups[] = '('.(int) $group.','.$key.')'; |
|
| 377 | 376 | } |
| 378 | 377 | $saved = true; |
| 379 | 378 | if (!empty($new_groups)) { |
@@ -382,7 +381,7 @@ discard block |
||
| 382 | 381 | } else { |
| 383 | 382 | $isManager = $modx->hasPermission('access_permissions'); |
| 384 | 383 | $isWeb = $modx->hasPermission('web_access_permissions'); |
| 385 | - if($use_udperms && !($isManager || $isWeb) && $parent != 0) { |
|
| 384 | + if ($use_udperms && !($isManager || $isWeb) && $parent != 0) { |
|
| 386 | 385 | // inherit document access permissions |
| 387 | 386 | $modx->db->insert( |
| 388 | 387 | array( |
@@ -401,17 +400,17 @@ discard block |
||
| 401 | 400 | } |
| 402 | 401 | |
| 403 | 402 | // invoke OnDocFormSave event |
| 404 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
| 403 | + $modx->invokeEvent("OnDocFormSave", array( |
|
| 405 | 404 | "mode" => "new", |
| 406 | 405 | "id" => $key |
| 407 | 406 | )); |
| 408 | 407 | |
| 409 | 408 | // secure web documents - flag as private |
| 410 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 409 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
| 411 | 410 | secureWebDocument($key); |
| 412 | 411 | |
| 413 | 412 | // secure manager documents - flag as private |
| 414 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 413 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
| 415 | 414 | secureMgrDocument($key); |
| 416 | 415 | |
| 417 | 416 | // Set the item name for logger |
@@ -430,13 +429,13 @@ discard block |
||
| 430 | 429 | // document |
| 431 | 430 | if ($_POST['mode'] == "4") |
| 432 | 431 | $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
| 433 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay']; |
|
| 432 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay']; |
|
| 434 | 433 | } else { |
| 435 | 434 | $header = "Location: index.php?a=3&id=$key&r=1"; |
| 436 | 435 | } |
| 437 | 436 | |
| 438 | 437 | if (headers_sent()) { |
| 439 | - $header = str_replace('Location: ','',$header); |
|
| 438 | + $header = str_replace('Location: ', '', $header); |
|
| 440 | 439 | echo "<script>document.location.href='$header';</script>\n"; |
| 441 | 440 | } else { |
| 442 | 441 | header($header); |
@@ -490,7 +489,7 @@ discard block |
||
| 490 | 489 | if (!$was_published && $published) { |
| 491 | 490 | $publishedon = $currentdate; |
| 492 | 491 | $publishedby = $modx->getLoginUserID(); |
| 493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 492 | + }elseif ((!empty($pub_date) && $pub_date <= $currentdate && $published)) { |
|
| 494 | 493 | $publishedon = $pub_date; |
| 495 | 494 | $publishedby = $modx->getLoginUserID(); |
| 496 | 495 | }elseif ($was_published && !$published) { |
@@ -502,7 +501,7 @@ discard block |
||
| 502 | 501 | } |
| 503 | 502 | |
| 504 | 503 | // invoke OnBeforeDocFormSave event |
| 505 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 504 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
| 506 | 505 | "mode" => "upd", |
| 507 | 506 | "id" => $id |
| 508 | 507 | )); |
@@ -527,7 +526,7 @@ discard block |
||
| 527 | 526 | . "menuindex={$menuindex}, " |
| 528 | 527 | . "searchable={$searchable}, " |
| 529 | 528 | . "cacheable={$cacheable}, " |
| 530 | - . "editedby=" . $modx->getLoginUserID() . ", " |
|
| 529 | + . "editedby=".$modx->getLoginUserID().", " |
|
| 531 | 530 | . "editedon={$currentdate}, " |
| 532 | 531 | . "publishedon={$publishedon}, " |
| 533 | 532 | . "publishedby={$publishedby}, " |
@@ -541,7 +540,7 @@ discard block |
||
| 541 | 540 | |
| 542 | 541 | // update template variables |
| 543 | 542 | $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
| 544 | - $tvIds = array (); |
|
| 543 | + $tvIds = array(); |
|
| 545 | 544 | while ($row = $modx->db->getRow($rs)) { |
| 546 | 545 | $tvIds[$row['tmplvarid']] = $row['id']; |
| 547 | 546 | } |
@@ -594,7 +593,7 @@ discard block |
||
| 594 | 593 | 'groups.id, groups.document_group', |
| 595 | 594 | "{$tbl_document_groups} AS groups |
| 596 | 595 | LEFT JOIN {$tbl_documentgroup_names} AS dgn ON dgn.id = groups.document_group", |
| 597 | - "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 596 | + "((1=".(int) $isManager." AND dgn.private_memgroup) OR (1=".(int) $isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 598 | 597 | ); |
| 599 | 598 | $old_groups = array(); |
| 600 | 599 | while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
@@ -606,7 +605,7 @@ discard block |
||
| 606 | 605 | unset($old_groups[$group]); |
| 607 | 606 | continue; |
| 608 | 607 | } elseif ($link_id == 'new') { |
| 609 | - $insertions[] = '('.(int)$group.','.$id.')'; |
|
| 608 | + $insertions[] = '('.(int) $group.','.$id.')'; |
|
| 610 | 609 | } |
| 611 | 610 | } |
| 612 | 611 | if (!empty($insertions)) { |
@@ -638,17 +637,17 @@ discard block |
||
| 638 | 637 | |
| 639 | 638 | |
| 640 | 639 | // invoke OnDocFormSave event |
| 641 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
| 640 | + $modx->invokeEvent("OnDocFormSave", array( |
|
| 642 | 641 | "mode" => "upd", |
| 643 | 642 | "id" => $id |
| 644 | 643 | )); |
| 645 | 644 | |
| 646 | 645 | // secure web documents - flag as private |
| 647 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 646 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
| 648 | 647 | secureWebDocument($id); |
| 649 | 648 | |
| 650 | 649 | // secure manager documents - flag as private |
| 651 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 650 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
| 652 | 651 | secureMgrDocument($id); |
| 653 | 652 | |
| 654 | 653 | // Set the item name for logger |
@@ -656,14 +655,14 @@ discard block |
||
| 656 | 655 | |
| 657 | 656 | if ($syncsite == 1) { |
| 658 | 657 | // empty cache |
| 659 | - $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
|
| 658 | + $keys = array('alias', 'parent', 'published', 'isfolder', 'menuindex', 'alias_visible'); |
|
| 660 | 659 | $flag = ''; |
| 661 | - foreach($keys as $key) { |
|
| 662 | - if ($existingDocument[$key]===$_POST[$key]) continue; |
|
| 660 | + foreach ($keys as $key) { |
|
| 661 | + if ($existingDocument[$key] === $_POST[$key]) continue; |
|
| 663 | 662 | $flag = 'full'; |
| 664 | 663 | break; |
| 665 | 664 | } |
| 666 | - if($flag==='full') $modx->clearCache('full'); |
|
| 665 | + if ($flag === 'full') $modx->clearCache('full'); |
|
| 667 | 666 | else $modx->clearCache($id); |
| 668 | 667 | } |
| 669 | 668 | |
@@ -682,13 +681,13 @@ discard block |
||
| 682 | 681 | // document |
| 683 | 682 | $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
| 684 | 683 | } |
| 685 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
| 684 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay'].$add_path; |
|
| 686 | 685 | } else { |
| 687 | 686 | $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
| 688 | 687 | } |
| 689 | 688 | } |
| 690 | 689 | if (headers_sent()) { |
| 691 | - $header = str_replace('Location: ','',$header); |
|
| 690 | + $header = str_replace('Location: ', '', $header); |
|
| 692 | 691 | echo "<script>document.location.href='$header';</script>\n"; |
| 693 | 692 | } else { |
| 694 | 693 | header($header); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | $alias = $tempAlias; |
| 86 | 86 | } |
| 87 | - }else{ |
|
| 87 | + } else { |
|
| 88 | 88 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND parent=$parent AND alias='$alias'")) != 0) { |
| 89 | 89 | $cnt = 1; |
| 90 | 90 | $tempAlias = $alias; |
@@ -134,8 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | //end webber |
| 136 | 136 | } |
| 137 | -} |
|
| 138 | -elseif ($alias) { |
|
| 137 | +} elseif ($alias) { |
|
| 139 | 138 | $alias = $modx->stripAlias($alias); |
| 140 | 139 | } |
| 141 | 140 | |
@@ -149,8 +148,7 @@ discard block |
||
| 149 | 148 | |
| 150 | 149 | if ($pub_date < $currentdate) { |
| 151 | 150 | $published = 1; |
| 152 | - } |
|
| 153 | - elseif ($pub_date > $currentdate) { |
|
| 151 | + } elseif ($pub_date > $currentdate) { |
|
| 154 | 152 | $published = 0; |
| 155 | 153 | } |
| 156 | 154 | } |
@@ -278,8 +276,7 @@ discard block |
||
| 278 | 276 | case 'new' : |
| 279 | 277 | |
| 280 | 278 | // invoke OnBeforeDocFormSave event |
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 282 | - { |
|
| 279 | + switch($modx->config['docid_incrmnt_method']) { |
|
| 283 | 280 | case '1': |
| 284 | 281 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
| 285 | 282 | $where = "T1.id IS NULL"; |
@@ -310,7 +307,7 @@ discard block |
||
| 310 | 307 | $publishedon = ($published ? $currentdate : 0); |
| 311 | 308 | $publishedby = ($published ? $modx->getLoginUserID() : 0); |
| 312 | 309 | |
| 313 | - if ((!empty($pub_date))&&($published)){ |
|
| 310 | + if ((!empty($pub_date))&&($published)) { |
|
| 314 | 311 | $publishedon=$pub_date; |
| 315 | 312 | } |
| 316 | 313 | |
@@ -348,8 +345,9 @@ discard block |
||
| 348 | 345 | "alias_visible" => $aliasvisible |
| 349 | 346 | ); |
| 350 | 347 | |
| 351 | - if ($id != '') |
|
| 352 | - $dbInsert["id"] = $id; |
|
| 348 | + if ($id != '') { |
|
| 349 | + $dbInsert["id"] = $id; |
|
| 350 | + } |
|
| 353 | 351 | |
| 354 | 352 | $key = $modx->db->insert( $dbInsert, $tbl_site_content); |
| 355 | 353 | |
@@ -425,11 +423,13 @@ discard block |
||
| 425 | 423 | // redirect/stay options |
| 426 | 424 | if ($_POST['stay'] != '') { |
| 427 | 425 | // weblink |
| 428 | - if ($_POST['mode'] == "72") |
|
| 429 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
| 426 | + if ($_POST['mode'] == "72") { |
|
| 427 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
| 428 | + } |
|
| 430 | 429 | // document |
| 431 | - if ($_POST['mode'] == "4") |
|
| 432 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
| 430 | + if ($_POST['mode'] == "4") { |
|
| 431 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
| 432 | + } |
|
| 433 | 433 | $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay']; |
| 434 | 434 | } else { |
| 435 | 435 | $header = "Location: index.php?a=3&id=$key&r=1"; |
@@ -490,10 +490,10 @@ discard block |
||
| 490 | 490 | if (!$was_published && $published) { |
| 491 | 491 | $publishedon = $currentdate; |
| 492 | 492 | $publishedby = $modx->getLoginUserID(); |
| 493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 493 | + } elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 494 | 494 | $publishedon = $pub_date; |
| 495 | 495 | $publishedby = $modx->getLoginUserID(); |
| 496 | - }elseif ($was_published && !$published) { |
|
| 496 | + } elseif ($was_published && !$published) { |
|
| 497 | 497 | $publishedon = 0; |
| 498 | 498 | $publishedby = 0; |
| 499 | 499 | } else { |
@@ -549,7 +549,9 @@ discard block |
||
| 549 | 549 | $tvChanges = array(); |
| 550 | 550 | foreach ($tmplvars as $field => $value) { |
| 551 | 551 | if (!is_array($value)) { |
| 552 | - if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 552 | + if (isset($tvIds[$value])) { |
|
| 553 | + $tvDeletions[] = $tvIds[$value]; |
|
| 554 | + } |
|
| 553 | 555 | } else { |
| 554 | 556 | $tvId = $value[0]; |
| 555 | 557 | $tvVal = $value[1]; |
@@ -597,7 +599,9 @@ discard block |
||
| 597 | 599 | "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
| 598 | 600 | ); |
| 599 | 601 | $old_groups = array(); |
| 600 | - while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 602 | + while ($row = $modx->db->getRow($rs)) { |
|
| 603 | + $old_groups[$row['document_group']] = $row['id']; |
|
| 604 | + } |
|
| 601 | 605 | |
| 602 | 606 | // update the permissions in the database |
| 603 | 607 | $insertions = $deletions = array(); |
@@ -659,17 +663,22 @@ discard block |
||
| 659 | 663 | $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
| 660 | 664 | $flag = ''; |
| 661 | 665 | foreach($keys as $key) { |
| 662 | - if ($existingDocument[$key]===$_POST[$key]) continue; |
|
| 666 | + if ($existingDocument[$key]===$_POST[$key]) { |
|
| 667 | + continue; |
|
| 668 | + } |
|
| 663 | 669 | $flag = 'full'; |
| 664 | 670 | break; |
| 665 | 671 | } |
| 666 | - if($flag==='full') $modx->clearCache('full'); |
|
| 667 | - else $modx->clearCache($id); |
|
| 672 | + if($flag==='full') { |
|
| 673 | + $modx->clearCache('full'); |
|
| 674 | + } else { |
|
| 675 | + $modx->clearCache($id); |
|
| 676 | + } |
|
| 668 | 677 | } |
| 669 | 678 | |
| 670 | - if ($_POST['refresh_preview'] == '1') |
|
| 671 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 672 | - else { |
|
| 679 | + if ($_POST['refresh_preview'] == '1') { |
|
| 680 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 681 | + } else { |
|
| 673 | 682 | if ($_POST['stay'] != '2' && $id > 0) { |
| 674 | 683 | $modx->unlockElement(7, $id); |
| 675 | 684 | } |
@@ -60,108 +60,108 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | - $limit = $modx->db->getValue($rs); |
|
| 74 | - if($limit > 0) { |
|
| 75 | - webAlertAndQuit("Email is already in use!"); |
|
| 76 | - } |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | + $limit = $modx->db->getValue($rs); |
|
| 74 | + if($limit > 0) { |
|
| 75 | + webAlertAndQuit("Email is already in use!"); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // generate a new password for this user |
|
| 79 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | + if(strlen($specifiedpassword) < 6) { |
|
| 81 | + webAlertAndQuit("Password is too short!"); |
|
| 82 | + } else { |
|
| 83 | + $newpassword = $specifiedpassword; |
|
| 84 | + } |
|
| 85 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | + } elseif($passwordgenmethod == 'g') { |
|
| 88 | + $newpassword = generate_password(8); |
|
| 89 | + } else { |
|
| 90 | + webAlertAndQuit("No password generation method specified!"); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // invoke OnBeforeWUsrFormSave event |
|
| 94 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | + "mode" => "new", |
|
| 96 | + )); |
|
| 97 | + |
|
| 98 | + // create the user account |
|
| 99 | + $field = array(); |
|
| 100 | + $field['username'] = $esc_newusername; |
|
| 101 | + $field['password'] = md5($newpassword); |
|
| 102 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | + |
|
| 104 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | + $field = $modx->db->escape($field); |
|
| 106 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | + |
|
| 108 | + // Save User Settings |
|
| 109 | + saveUserSettings($internalKey); |
|
| 110 | + |
|
| 111 | + // Set the item name for logger |
|
| 112 | + $_SESSION['itemname'] = $newusername; |
|
| 113 | + |
|
| 114 | + /*******************************************************************************/ |
|
| 115 | + // put the user in the user_groups he/ she should be in |
|
| 116 | + // first, check that up_perms are switched on! |
|
| 117 | + if($use_udperms == 1) { |
|
| 118 | + if(!empty($user_groups)) { |
|
| 119 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | + $f = array(); |
|
| 121 | + $f['webgroup'] = intval($user_groups[$i]); |
|
| 122 | + $f['webuser'] = $internalKey; |
|
| 123 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + // end of user_groups stuff! |
|
| 128 | + |
|
| 129 | + // invoke OnWebSaveUser event |
|
| 130 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 131 | + "mode" => "new", |
|
| 132 | + "userid" => $internalKey, |
|
| 133 | + "username" => $newusername, |
|
| 134 | + "userpassword" => $newpassword, |
|
| 135 | + "useremail" => $email, |
|
| 136 | + "userfullname" => $fullname |
|
| 137 | + )); |
|
| 77 | 138 | |
| 78 | - // generate a new password for this user |
|
| 79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | - webAlertAndQuit("Password is too short!"); |
|
| 82 | - } else { |
|
| 83 | - $newpassword = $specifiedpassword; |
|
| 84 | - } |
|
| 85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | - } elseif($passwordgenmethod == 'g') { |
|
| 88 | - $newpassword = generate_password(8); |
|
| 89 | - } else { |
|
| 90 | - webAlertAndQuit("No password generation method specified!"); |
|
| 91 | - } |
|
| 139 | + // invoke OnWUsrFormSave event |
|
| 140 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 141 | + "mode" => "new", |
|
| 142 | + "id" => $internalKey |
|
| 143 | + )); |
|
| 92 | 144 | |
| 93 | - // invoke OnBeforeWUsrFormSave event |
|
| 94 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | - "mode" => "new", |
|
| 96 | - )); |
|
| 97 | - |
|
| 98 | - // create the user account |
|
| 99 | - $field = array(); |
|
| 100 | - $field['username'] = $esc_newusername; |
|
| 101 | - $field['password'] = md5($newpassword); |
|
| 102 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | - |
|
| 104 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | - $field = $modx->db->escape($field); |
|
| 106 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | - |
|
| 108 | - // Save User Settings |
|
| 109 | - saveUserSettings($internalKey); |
|
| 110 | - |
|
| 111 | - // Set the item name for logger |
|
| 112 | - $_SESSION['itemname'] = $newusername; |
|
| 113 | - |
|
| 114 | - /*******************************************************************************/ |
|
| 115 | - // put the user in the user_groups he/ she should be in |
|
| 116 | - // first, check that up_perms are switched on! |
|
| 117 | - if($use_udperms == 1) { |
|
| 118 | - if(!empty($user_groups)) { |
|
| 119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | - $f = array(); |
|
| 121 | - $f['webgroup'] = intval($user_groups[$i]); |
|
| 122 | - $f['webuser'] = $internalKey; |
|
| 123 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - // end of user_groups stuff! |
|
| 128 | - |
|
| 129 | - // invoke OnWebSaveUser event |
|
| 130 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 131 | - "mode" => "new", |
|
| 132 | - "userid" => $internalKey, |
|
| 133 | - "username" => $newusername, |
|
| 134 | - "userpassword" => $newpassword, |
|
| 135 | - "useremail" => $email, |
|
| 136 | - "userfullname" => $fullname |
|
| 137 | - )); |
|
| 138 | - |
|
| 139 | - // invoke OnWUsrFormSave event |
|
| 140 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 141 | - "mode" => "new", |
|
| 142 | - "id" => $internalKey |
|
| 143 | - )); |
|
| 144 | - |
|
| 145 | - if($passwordnotifymethod == 'e') { |
|
| 146 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | - if($input['stay'] != '') { |
|
| 148 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | - header($header); |
|
| 151 | - } else { |
|
| 152 | - $header = "Location: index.php?a=99&r=2"; |
|
| 153 | - header($header); |
|
| 154 | - } |
|
| 155 | - } else { |
|
| 156 | - if($input['stay'] != '') { |
|
| 157 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | - } else { |
|
| 160 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - include_once "header.inc.php"; |
|
| 164 | - ?> |
|
| 145 | + if($passwordnotifymethod == 'e') { |
|
| 146 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | + if($input['stay'] != '') { |
|
| 148 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | + header($header); |
|
| 151 | + } else { |
|
| 152 | + $header = "Location: index.php?a=99&r=2"; |
|
| 153 | + header($header); |
|
| 154 | + } |
|
| 155 | + } else { |
|
| 156 | + if($input['stay'] != '') { |
|
| 157 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | + } else { |
|
| 160 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + include_once "header.inc.php"; |
|
| 164 | + ?> |
|
| 165 | 165 | |
| 166 | 166 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 167 | 167 | |
@@ -183,122 +183,122 @@ discard block |
||
| 183 | 183 | </div> |
| 184 | 184 | <?php |
| 185 | 185 | |
| 186 | - include_once "footer.inc.php"; |
|
| 187 | - } |
|
| 188 | - break; |
|
| 189 | - case '88' : // edit user |
|
| 190 | - // generate a new password for this user |
|
| 191 | - if($genpassword == 1) { |
|
| 192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | - if(strlen($specifiedpassword) < 6) { |
|
| 194 | - webAlertAndQuit("Password is too short!"); |
|
| 195 | - } else { |
|
| 196 | - $newpassword = $specifiedpassword; |
|
| 197 | - } |
|
| 198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | - } elseif($passwordgenmethod == 'g') { |
|
| 201 | - $newpassword = generate_password(8); |
|
| 202 | - } else { |
|
| 203 | - webAlertAndQuit("No password generation method specified!"); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - if($passwordnotifymethod == 'e') { |
|
| 207 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // check if the username already exist |
|
| 211 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | - $limit = $modx->db->getValue($rs); |
|
| 213 | - if($limit > 0) { |
|
| 214 | - webAlertAndQuit("User name is already in use!"); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // check if the email address already exists |
|
| 218 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | - $limit = $modx->db->getValue($rs); |
|
| 220 | - if($limit > 0) { |
|
| 221 | - webAlertAndQuit("Email is already in use!"); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // invoke OnBeforeWUsrFormSave event |
|
| 225 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | - "mode" => "upd", |
|
| 227 | - "id" => $id |
|
| 228 | - )); |
|
| 229 | - |
|
| 230 | - // update user name and password |
|
| 231 | - $field = array(); |
|
| 232 | - $field['username'] = $esc_newusername; |
|
| 233 | - if($genpassword == 1) { |
|
| 234 | - $field['password'] = md5($newpassword); |
|
| 235 | - } |
|
| 236 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | - $field = $modx->db->escape($field); |
|
| 239 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | - |
|
| 241 | - // Save User Settings |
|
| 242 | - saveUserSettings($id); |
|
| 243 | - |
|
| 244 | - // Set the item name for logger |
|
| 245 | - $_SESSION['itemname'] = $newusername; |
|
| 246 | - |
|
| 247 | - /*******************************************************************************/ |
|
| 248 | - // put the user in the user_groups he/ she should be in |
|
| 249 | - // first, check that up_perms are switched on! |
|
| 250 | - if($use_udperms == 1) { |
|
| 251 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | - if(!empty($user_groups)) { |
|
| 254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | - $field = array(); |
|
| 256 | - $field['webgroup'] = intval($user_groups[$i]); |
|
| 257 | - $field['webuser'] = $id; |
|
| 258 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - // end of user_groups stuff! |
|
| 263 | - /*******************************************************************************/ |
|
| 264 | - |
|
| 265 | - // invoke OnWebSaveUser event |
|
| 266 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 267 | - "mode" => "upd", |
|
| 268 | - "userid" => $id, |
|
| 269 | - "username" => $newusername, |
|
| 270 | - "userpassword" => $newpassword, |
|
| 271 | - "useremail" => $email, |
|
| 272 | - "userfullname" => $fullname, |
|
| 273 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 274 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 275 | - )); |
|
| 276 | - |
|
| 277 | - // invoke OnWebChangePassword event |
|
| 278 | - if($genpassword == 1) { |
|
| 279 | - $modx->invokeEvent("OnWebChangePassword", array( |
|
| 186 | + include_once "footer.inc.php"; |
|
| 187 | + } |
|
| 188 | + break; |
|
| 189 | + case '88' : // edit user |
|
| 190 | + // generate a new password for this user |
|
| 191 | + if($genpassword == 1) { |
|
| 192 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | + if(strlen($specifiedpassword) < 6) { |
|
| 194 | + webAlertAndQuit("Password is too short!"); |
|
| 195 | + } else { |
|
| 196 | + $newpassword = $specifiedpassword; |
|
| 197 | + } |
|
| 198 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | + } elseif($passwordgenmethod == 'g') { |
|
| 201 | + $newpassword = generate_password(8); |
|
| 202 | + } else { |
|
| 203 | + webAlertAndQuit("No password generation method specified!"); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + if($passwordnotifymethod == 'e') { |
|
| 207 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // check if the username already exist |
|
| 211 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | + $limit = $modx->db->getValue($rs); |
|
| 213 | + if($limit > 0) { |
|
| 214 | + webAlertAndQuit("User name is already in use!"); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // check if the email address already exists |
|
| 218 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | + $limit = $modx->db->getValue($rs); |
|
| 220 | + if($limit > 0) { |
|
| 221 | + webAlertAndQuit("Email is already in use!"); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // invoke OnBeforeWUsrFormSave event |
|
| 225 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | + "mode" => "upd", |
|
| 227 | + "id" => $id |
|
| 228 | + )); |
|
| 229 | + |
|
| 230 | + // update user name and password |
|
| 231 | + $field = array(); |
|
| 232 | + $field['username'] = $esc_newusername; |
|
| 233 | + if($genpassword == 1) { |
|
| 234 | + $field['password'] = md5($newpassword); |
|
| 235 | + } |
|
| 236 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | + $field = $modx->db->escape($field); |
|
| 239 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | + |
|
| 241 | + // Save User Settings |
|
| 242 | + saveUserSettings($id); |
|
| 243 | + |
|
| 244 | + // Set the item name for logger |
|
| 245 | + $_SESSION['itemname'] = $newusername; |
|
| 246 | + |
|
| 247 | + /*******************************************************************************/ |
|
| 248 | + // put the user in the user_groups he/ she should be in |
|
| 249 | + // first, check that up_perms are switched on! |
|
| 250 | + if($use_udperms == 1) { |
|
| 251 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | + if(!empty($user_groups)) { |
|
| 254 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | + $field = array(); |
|
| 256 | + $field['webgroup'] = intval($user_groups[$i]); |
|
| 257 | + $field['webuser'] = $id; |
|
| 258 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + // end of user_groups stuff! |
|
| 263 | + /*******************************************************************************/ |
|
| 264 | + |
|
| 265 | + // invoke OnWebSaveUser event |
|
| 266 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 267 | + "mode" => "upd", |
|
| 280 | 268 | "userid" => $id, |
| 281 | 269 | "username" => $newusername, |
| 282 | - "userpassword" => $newpassword |
|
| 270 | + "userpassword" => $newpassword, |
|
| 271 | + "useremail" => $email, |
|
| 272 | + "userfullname" => $fullname, |
|
| 273 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 274 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 283 | 275 | )); |
| 284 | - } |
|
| 285 | 276 | |
| 286 | - // invoke OnWUsrFormSave event |
|
| 287 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 288 | - "mode" => "upd", |
|
| 289 | - "id" => $id |
|
| 290 | - )); |
|
| 277 | + // invoke OnWebChangePassword event |
|
| 278 | + if($genpassword == 1) { |
|
| 279 | + $modx->invokeEvent("OnWebChangePassword", array( |
|
| 280 | + "userid" => $id, |
|
| 281 | + "username" => $newusername, |
|
| 282 | + "userpassword" => $newpassword |
|
| 283 | + )); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + // invoke OnWUsrFormSave event |
|
| 287 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 288 | + "mode" => "upd", |
|
| 289 | + "id" => $id |
|
| 290 | + )); |
|
| 291 | 291 | |
| 292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | - if($input['stay'] != '') { |
|
| 294 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | - } else { |
|
| 297 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | - } |
|
| 292 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | + if($input['stay'] != '') { |
|
| 294 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | + } else { |
|
| 297 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - include_once "header.inc.php"; |
|
| 301 | - ?> |
|
| 300 | + include_once "header.inc.php"; |
|
| 301 | + ?> |
|
| 302 | 302 | |
| 303 | 303 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 304 | 304 | |
@@ -318,20 +318,20 @@ discard block |
||
| 318 | 318 | </div> |
| 319 | 319 | <?php |
| 320 | 320 | |
| 321 | - include_once "footer.inc.php"; |
|
| 322 | - } else { |
|
| 323 | - if($input['stay'] != '') { |
|
| 324 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | - header($header); |
|
| 327 | - } else { |
|
| 328 | - $header = "Location: index.php?a=99&r=2"; |
|
| 329 | - header($header); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - break; |
|
| 333 | - default : |
|
| 334 | - webAlertAndQuit("No operation set in request."); |
|
| 321 | + include_once "footer.inc.php"; |
|
| 322 | + } else { |
|
| 323 | + if($input['stay'] != '') { |
|
| 324 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | + header($header); |
|
| 327 | + } else { |
|
| 328 | + $header = "Location: index.php?a=99&r=2"; |
|
| 329 | + header($header); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + break; |
|
| 333 | + default : |
|
| 334 | + webAlertAndQuit("No operation set in request."); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // in case any plugins include a quoted_printable function |
@@ -335,7 +335,8 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // in case any plugins include a quoted_printable function |
| 338 | -function save_user_quoted_printable($string) { |
|
| 338 | +function save_user_quoted_printable($string) |
|
| 339 | +{ |
|
| 339 | 340 | $crlf = "\n"; |
| 340 | 341 | $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
| 341 | 342 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
@@ -347,7 +348,8 @@ discard block |
||
| 347 | 348 | } |
| 348 | 349 | |
| 349 | 350 | // Send an email to the user |
| 350 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 351 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
| 352 | +{ |
|
| 351 | 353 | global $modx, $_lang, $websignupemail_message; |
| 352 | 354 | global $emailsubject, $emailsender; |
| 353 | 355 | global $site_name, $site_url; |
@@ -375,7 +377,8 @@ discard block |
||
| 375 | 377 | } |
| 376 | 378 | |
| 377 | 379 | // Save User Settings |
| 378 | -function saveUserSettings($id) { |
|
| 380 | +function saveUserSettings($id) |
|
| 381 | +{ |
|
| 379 | 382 | global $modx; |
| 380 | 383 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
| 381 | 384 | |
@@ -404,7 +407,8 @@ discard block |
||
| 404 | 407 | } |
| 405 | 408 | |
| 406 | 409 | // Web alert - sends an alert to web browser |
| 407 | -function webAlertAndQuit($msg) { |
|
| 410 | +function webAlertAndQuit($msg) |
|
| 411 | +{ |
|
| 408 | 412 | global $id, $modx; |
| 409 | 413 | $mode = $_POST['mode']; |
| 410 | 414 | $modx->manager->saveFormValues($mode); |
@@ -412,7 +416,8 @@ discard block |
||
| 412 | 416 | } |
| 413 | 417 | |
| 414 | 418 | // Generate password |
| 415 | -function generate_password($length = 10) { |
|
| 419 | +function generate_password($length = 10) |
|
| 420 | +{ |
|
| 416 | 421 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 417 | 422 | $ps_len = strlen($allowable_characters); |
| 418 | 423 | mt_srand((double) microtime() * 1000000); |
@@ -423,7 +428,8 @@ discard block |
||
| 423 | 428 | return $pass; |
| 424 | 429 | } |
| 425 | 430 | |
| 426 | -function sanitize($str = '', $safecount = 0) { |
|
| 431 | +function sanitize($str = '', $safecount = 0) |
|
| 432 | +{ |
|
| 427 | 433 | global $modx; |
| 428 | 434 | $safecount++; |
| 429 | 435 | if(1000 < $safecount) { |
@@ -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 = intval($input['id']); |
@@ -51,80 +51,80 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 54 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 54 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | - $limit = $modx->db->getValue($rs); |
|
| 74 | - if($limit > 0) { |
|
| 75 | - webAlertAndQuit("Email is already in use!"); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // generate a new password for this user |
|
| 79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | - webAlertAndQuit("Password is too short!"); |
|
| 82 | - } else { |
|
| 83 | - $newpassword = $specifiedpassword; |
|
| 84 | - } |
|
| 85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | - } elseif($passwordgenmethod == 'g') { |
|
| 88 | - $newpassword = generate_password(8); |
|
| 89 | - } else { |
|
| 90 | - webAlertAndQuit("No password generation method specified!"); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // invoke OnBeforeWUsrFormSave event |
|
| 94 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | - "mode" => "new", |
|
| 96 | - )); |
|
| 97 | - |
|
| 98 | - // create the user account |
|
| 99 | - $field = array(); |
|
| 100 | - $field['username'] = $esc_newusername; |
|
| 101 | - $field['password'] = md5($newpassword); |
|
| 102 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | - |
|
| 104 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | - $field = $modx->db->escape($field); |
|
| 106 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | - |
|
| 108 | - // Save User Settings |
|
| 109 | - saveUserSettings($internalKey); |
|
| 110 | - |
|
| 111 | - // Set the item name for logger |
|
| 112 | - $_SESSION['itemname'] = $newusername; |
|
| 113 | - |
|
| 114 | - /*******************************************************************************/ |
|
| 115 | - // put the user in the user_groups he/ she should be in |
|
| 116 | - // first, check that up_perms are switched on! |
|
| 117 | - if($use_udperms == 1) { |
|
| 118 | - if(!empty($user_groups)) { |
|
| 119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | - $f = array(); |
|
| 121 | - $f['webgroup'] = intval($user_groups[$i]); |
|
| 122 | - $f['webuser'] = $internalKey; |
|
| 123 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - // end of user_groups stuff! |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | + $limit = $modx->db->getValue($rs); |
|
| 74 | + if($limit > 0) { |
|
| 75 | + webAlertAndQuit("Email is already in use!"); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // generate a new password for this user |
|
| 79 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | + if(strlen($specifiedpassword) < 6) { |
|
| 81 | + webAlertAndQuit("Password is too short!"); |
|
| 82 | + } else { |
|
| 83 | + $newpassword = $specifiedpassword; |
|
| 84 | + } |
|
| 85 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | + } elseif($passwordgenmethod == 'g') { |
|
| 88 | + $newpassword = generate_password(8); |
|
| 89 | + } else { |
|
| 90 | + webAlertAndQuit("No password generation method specified!"); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // invoke OnBeforeWUsrFormSave event |
|
| 94 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | + "mode" => "new", |
|
| 96 | + )); |
|
| 97 | + |
|
| 98 | + // create the user account |
|
| 99 | + $field = array(); |
|
| 100 | + $field['username'] = $esc_newusername; |
|
| 101 | + $field['password'] = md5($newpassword); |
|
| 102 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | + |
|
| 104 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | + $field = $modx->db->escape($field); |
|
| 106 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | + |
|
| 108 | + // Save User Settings |
|
| 109 | + saveUserSettings($internalKey); |
|
| 110 | + |
|
| 111 | + // Set the item name for logger |
|
| 112 | + $_SESSION['itemname'] = $newusername; |
|
| 113 | + |
|
| 114 | + /*******************************************************************************/ |
|
| 115 | + // put the user in the user_groups he/ she should be in |
|
| 116 | + // first, check that up_perms are switched on! |
|
| 117 | + if($use_udperms == 1) { |
|
| 118 | + if(!empty($user_groups)) { |
|
| 119 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | + $f = array(); |
|
| 121 | + $f['webgroup'] = intval($user_groups[$i]); |
|
| 122 | + $f['webuser'] = $internalKey; |
|
| 123 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + // end of user_groups stuff! |
|
| 128 | 128 | |
| 129 | 129 | // invoke OnWebSaveUser event |
| 130 | 130 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -142,26 +142,26 @@ discard block |
||
| 142 | 142 | "id" => $internalKey |
| 143 | 143 | )); |
| 144 | 144 | |
| 145 | - if($passwordnotifymethod == 'e') { |
|
| 146 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | - if($input['stay'] != '') { |
|
| 148 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | - header($header); |
|
| 151 | - } else { |
|
| 152 | - $header = "Location: index.php?a=99&r=2"; |
|
| 153 | - header($header); |
|
| 154 | - } |
|
| 155 | - } else { |
|
| 156 | - if($input['stay'] != '') { |
|
| 157 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | - } else { |
|
| 160 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - include_once "header.inc.php"; |
|
| 164 | - ?> |
|
| 145 | + if($passwordnotifymethod == 'e') { |
|
| 146 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | + if($input['stay'] != '') { |
|
| 148 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | + header($header); |
|
| 151 | + } else { |
|
| 152 | + $header = "Location: index.php?a=99&r=2"; |
|
| 153 | + header($header); |
|
| 154 | + } |
|
| 155 | + } else { |
|
| 156 | + if($input['stay'] != '') { |
|
| 157 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | + } else { |
|
| 160 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + include_once "header.inc.php"; |
|
| 164 | + ?> |
|
| 165 | 165 | |
| 166 | 166 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 167 | 167 | |
@@ -183,84 +183,84 @@ discard block |
||
| 183 | 183 | </div> |
| 184 | 184 | <?php |
| 185 | 185 | |
| 186 | - include_once "footer.inc.php"; |
|
| 187 | - } |
|
| 188 | - break; |
|
| 189 | - case '88' : // edit user |
|
| 190 | - // generate a new password for this user |
|
| 191 | - if($genpassword == 1) { |
|
| 192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | - if(strlen($specifiedpassword) < 6) { |
|
| 194 | - webAlertAndQuit("Password is too short!"); |
|
| 195 | - } else { |
|
| 196 | - $newpassword = $specifiedpassword; |
|
| 197 | - } |
|
| 198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | - } elseif($passwordgenmethod == 'g') { |
|
| 201 | - $newpassword = generate_password(8); |
|
| 202 | - } else { |
|
| 203 | - webAlertAndQuit("No password generation method specified!"); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - if($passwordnotifymethod == 'e') { |
|
| 207 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // check if the username already exist |
|
| 211 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | - $limit = $modx->db->getValue($rs); |
|
| 213 | - if($limit > 0) { |
|
| 214 | - webAlertAndQuit("User name is already in use!"); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // check if the email address already exists |
|
| 218 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | - $limit = $modx->db->getValue($rs); |
|
| 220 | - if($limit > 0) { |
|
| 221 | - webAlertAndQuit("Email is already in use!"); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // invoke OnBeforeWUsrFormSave event |
|
| 225 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | - "mode" => "upd", |
|
| 227 | - "id" => $id |
|
| 228 | - )); |
|
| 229 | - |
|
| 230 | - // update user name and password |
|
| 231 | - $field = array(); |
|
| 232 | - $field['username'] = $esc_newusername; |
|
| 233 | - if($genpassword == 1) { |
|
| 234 | - $field['password'] = md5($newpassword); |
|
| 235 | - } |
|
| 236 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | - $field = $modx->db->escape($field); |
|
| 239 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | - |
|
| 241 | - // Save User Settings |
|
| 242 | - saveUserSettings($id); |
|
| 243 | - |
|
| 244 | - // Set the item name for logger |
|
| 245 | - $_SESSION['itemname'] = $newusername; |
|
| 246 | - |
|
| 247 | - /*******************************************************************************/ |
|
| 248 | - // put the user in the user_groups he/ she should be in |
|
| 249 | - // first, check that up_perms are switched on! |
|
| 250 | - if($use_udperms == 1) { |
|
| 251 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | - if(!empty($user_groups)) { |
|
| 254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | - $field = array(); |
|
| 256 | - $field['webgroup'] = intval($user_groups[$i]); |
|
| 257 | - $field['webuser'] = $id; |
|
| 258 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - // end of user_groups stuff! |
|
| 263 | - /*******************************************************************************/ |
|
| 186 | + include_once "footer.inc.php"; |
|
| 187 | + } |
|
| 188 | + break; |
|
| 189 | + case '88' : // edit user |
|
| 190 | + // generate a new password for this user |
|
| 191 | + if($genpassword == 1) { |
|
| 192 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | + if(strlen($specifiedpassword) < 6) { |
|
| 194 | + webAlertAndQuit("Password is too short!"); |
|
| 195 | + } else { |
|
| 196 | + $newpassword = $specifiedpassword; |
|
| 197 | + } |
|
| 198 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | + } elseif($passwordgenmethod == 'g') { |
|
| 201 | + $newpassword = generate_password(8); |
|
| 202 | + } else { |
|
| 203 | + webAlertAndQuit("No password generation method specified!"); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + if($passwordnotifymethod == 'e') { |
|
| 207 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // check if the username already exist |
|
| 211 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | + $limit = $modx->db->getValue($rs); |
|
| 213 | + if($limit > 0) { |
|
| 214 | + webAlertAndQuit("User name is already in use!"); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // check if the email address already exists |
|
| 218 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | + $limit = $modx->db->getValue($rs); |
|
| 220 | + if($limit > 0) { |
|
| 221 | + webAlertAndQuit("Email is already in use!"); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // invoke OnBeforeWUsrFormSave event |
|
| 225 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | + "mode" => "upd", |
|
| 227 | + "id" => $id |
|
| 228 | + )); |
|
| 229 | + |
|
| 230 | + // update user name and password |
|
| 231 | + $field = array(); |
|
| 232 | + $field['username'] = $esc_newusername; |
|
| 233 | + if($genpassword == 1) { |
|
| 234 | + $field['password'] = md5($newpassword); |
|
| 235 | + } |
|
| 236 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | + $field = $modx->db->escape($field); |
|
| 239 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | + |
|
| 241 | + // Save User Settings |
|
| 242 | + saveUserSettings($id); |
|
| 243 | + |
|
| 244 | + // Set the item name for logger |
|
| 245 | + $_SESSION['itemname'] = $newusername; |
|
| 246 | + |
|
| 247 | + /*******************************************************************************/ |
|
| 248 | + // put the user in the user_groups he/ she should be in |
|
| 249 | + // first, check that up_perms are switched on! |
|
| 250 | + if($use_udperms == 1) { |
|
| 251 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | + if(!empty($user_groups)) { |
|
| 254 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | + $field = array(); |
|
| 256 | + $field['webgroup'] = intval($user_groups[$i]); |
|
| 257 | + $field['webuser'] = $id; |
|
| 258 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + // end of user_groups stuff! |
|
| 263 | + /*******************************************************************************/ |
|
| 264 | 264 | |
| 265 | 265 | // invoke OnWebSaveUser event |
| 266 | 266 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -289,16 +289,16 @@ discard block |
||
| 289 | 289 | "id" => $id |
| 290 | 290 | )); |
| 291 | 291 | |
| 292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | - if($input['stay'] != '') { |
|
| 294 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | - } else { |
|
| 297 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | - } |
|
| 292 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | + if($input['stay'] != '') { |
|
| 294 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | + } else { |
|
| 297 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - include_once "header.inc.php"; |
|
| 301 | - ?> |
|
| 300 | + include_once "header.inc.php"; |
|
| 301 | + ?> |
|
| 302 | 302 | |
| 303 | 303 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 304 | 304 | |
@@ -318,124 +318,124 @@ discard block |
||
| 318 | 318 | </div> |
| 319 | 319 | <?php |
| 320 | 320 | |
| 321 | - include_once "footer.inc.php"; |
|
| 322 | - } else { |
|
| 323 | - if($input['stay'] != '') { |
|
| 324 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | - header($header); |
|
| 327 | - } else { |
|
| 328 | - $header = "Location: index.php?a=99&r=2"; |
|
| 329 | - header($header); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - break; |
|
| 333 | - default : |
|
| 334 | - webAlertAndQuit("No operation set in request."); |
|
| 321 | + include_once "footer.inc.php"; |
|
| 322 | + } else { |
|
| 323 | + if($input['stay'] != '') { |
|
| 324 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | + header($header); |
|
| 327 | + } else { |
|
| 328 | + $header = "Location: index.php?a=99&r=2"; |
|
| 329 | + header($header); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + break; |
|
| 333 | + default : |
|
| 334 | + webAlertAndQuit("No operation set in request."); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // in case any plugins include a quoted_printable function |
| 338 | 338 | function save_user_quoted_printable($string) { |
| 339 | - $crlf = "\n"; |
|
| 340 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 341 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 342 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 343 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 344 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 345 | - $string = preg_replace($f, $r, $string); |
|
| 346 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 339 | + $crlf = "\n"; |
|
| 340 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 341 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 342 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 343 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 344 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 345 | + $string = preg_replace($f, $r, $string); |
|
| 346 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | // Send an email to the user |
| 350 | 350 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 351 | - global $modx, $_lang, $websignupemail_message; |
|
| 352 | - global $emailsubject, $emailsender; |
|
| 353 | - global $site_name, $site_url; |
|
| 354 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 355 | - // replace placeholders |
|
| 356 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 357 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 358 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 359 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 360 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 361 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 362 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
| 363 | - |
|
| 364 | - $param = array(); |
|
| 365 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 366 | - $param['subject'] = $emailsubject; |
|
| 367 | - $param['body'] = $message; |
|
| 368 | - $param['to'] = $email; |
|
| 369 | - $param['type'] = 'text'; |
|
| 370 | - $rs = $modx->sendmail($param); |
|
| 371 | - if(!$rs) { |
|
| 372 | - $modx->manager->saveFormValues(); |
|
| 373 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 374 | - } |
|
| 351 | + global $modx, $_lang, $websignupemail_message; |
|
| 352 | + global $emailsubject, $emailsender; |
|
| 353 | + global $site_name, $site_url; |
|
| 354 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 355 | + // replace placeholders |
|
| 356 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 357 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 358 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 359 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 360 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 361 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 362 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
| 363 | + |
|
| 364 | + $param = array(); |
|
| 365 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 366 | + $param['subject'] = $emailsubject; |
|
| 367 | + $param['body'] = $message; |
|
| 368 | + $param['to'] = $email; |
|
| 369 | + $param['type'] = 'text'; |
|
| 370 | + $rs = $modx->sendmail($param); |
|
| 371 | + if(!$rs) { |
|
| 372 | + $modx->manager->saveFormValues(); |
|
| 373 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 374 | + } |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Save User Settings |
| 378 | 378 | function saveUserSettings($id) { |
| 379 | - global $modx; |
|
| 380 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 381 | - |
|
| 382 | - $settings = array( |
|
| 383 | - "login_home", |
|
| 384 | - "allowed_ip", |
|
| 385 | - "allowed_days" |
|
| 386 | - ); |
|
| 387 | - |
|
| 388 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 389 | - |
|
| 390 | - foreach($settings as $n) { |
|
| 391 | - $vl = $_POST[$n]; |
|
| 392 | - if(is_array($vl)) { |
|
| 393 | - $vl = implode(",", $vl); |
|
| 394 | - } |
|
| 395 | - if($vl != '') { |
|
| 396 | - $f = array(); |
|
| 397 | - $f['webuser'] = $id; |
|
| 398 | - $f['setting_name'] = $n; |
|
| 399 | - $f['setting_value'] = $vl; |
|
| 400 | - $f = $modx->db->escape($f); |
|
| 401 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
| 402 | - } |
|
| 403 | - } |
|
| 379 | + global $modx; |
|
| 380 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 381 | + |
|
| 382 | + $settings = array( |
|
| 383 | + "login_home", |
|
| 384 | + "allowed_ip", |
|
| 385 | + "allowed_days" |
|
| 386 | + ); |
|
| 387 | + |
|
| 388 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 389 | + |
|
| 390 | + foreach($settings as $n) { |
|
| 391 | + $vl = $_POST[$n]; |
|
| 392 | + if(is_array($vl)) { |
|
| 393 | + $vl = implode(",", $vl); |
|
| 394 | + } |
|
| 395 | + if($vl != '') { |
|
| 396 | + $f = array(); |
|
| 397 | + $f['webuser'] = $id; |
|
| 398 | + $f['setting_name'] = $n; |
|
| 399 | + $f['setting_value'] = $vl; |
|
| 400 | + $f = $modx->db->escape($f); |
|
| 401 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // Web alert - sends an alert to web browser |
| 407 | 407 | function webAlertAndQuit($msg) { |
| 408 | - global $id, $modx; |
|
| 409 | - $mode = $_POST['mode']; |
|
| 410 | - $modx->manager->saveFormValues($mode); |
|
| 411 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 408 | + global $id, $modx; |
|
| 409 | + $mode = $_POST['mode']; |
|
| 410 | + $modx->manager->saveFormValues($mode); |
|
| 411 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // Generate password |
| 415 | 415 | function generate_password($length = 10) { |
| 416 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 417 | - $ps_len = strlen($allowable_characters); |
|
| 418 | - mt_srand((double) microtime() * 1000000); |
|
| 419 | - $pass = ""; |
|
| 420 | - for($i = 0; $i < $length; $i++) { |
|
| 421 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 422 | - } |
|
| 423 | - return $pass; |
|
| 416 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 417 | + $ps_len = strlen($allowable_characters); |
|
| 418 | + mt_srand((double) microtime() * 1000000); |
|
| 419 | + $pass = ""; |
|
| 420 | + for($i = 0; $i < $length; $i++) { |
|
| 421 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 422 | + } |
|
| 423 | + return $pass; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | function sanitize($str = '', $safecount = 0) { |
| 427 | - global $modx; |
|
| 428 | - $safecount++; |
|
| 429 | - if(1000 < $safecount) { |
|
| 430 | - exit("error too many loops '{$safecount}'"); |
|
| 431 | - } |
|
| 432 | - if(is_array($str)) { |
|
| 433 | - foreach($str as $i => $v) { |
|
| 434 | - $str[$i] = sanitize($v, $safecount); |
|
| 435 | - } |
|
| 436 | - } else { |
|
| 437 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
| 438 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 439 | - } |
|
| 440 | - return $str; |
|
| 427 | + global $modx; |
|
| 428 | + $safecount++; |
|
| 429 | + if(1000 < $safecount) { |
|
| 430 | + exit("error too many loops '{$safecount}'"); |
|
| 431 | + } |
|
| 432 | + if(is_array($str)) { |
|
| 433 | + foreach($str as $i => $v) { |
|
| 434 | + $str[$i] = sanitize($v, $safecount); |
|
| 435 | + } |
|
| 436 | + } else { |
|
| 437 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
| 438 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 439 | + } |
|
| 440 | + return $str; |
|
| 441 | 441 | } |
@@ -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,8 +11,8 @@ 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; |
@@ -50,41 +50,41 @@ discard block |
||
| 50 | 50 | $user_groups = $input['user_groups']; |
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 53 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 54 | 54 | webAlertAndQuit("Password typed is mismatched"); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 58 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 59 | 59 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -switch($input['mode']) { |
|
| 62 | +switch ($input['mode']) { |
|
| 63 | 63 | case '87' : // new user |
| 64 | 64 | // check if this user name already exist |
| 65 | 65 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
| 66 | 66 | $limit = $modx->db->getValue($rs); |
| 67 | - if($limit > 0) { |
|
| 67 | + if ($limit > 0) { |
|
| 68 | 68 | webAlertAndQuit("User name is already in use!"); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // check if the email address already exist |
| 72 | 72 | $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
| 73 | 73 | $limit = $modx->db->getValue($rs); |
| 74 | - if($limit > 0) { |
|
| 74 | + if ($limit > 0) { |
|
| 75 | 75 | webAlertAndQuit("Email is already in use!"); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // generate a new password for this user |
| 79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | - if(strlen($specifiedpassword) < 6) { |
|
| 79 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | + if (strlen($specifiedpassword) < 6) { |
|
| 81 | 81 | webAlertAndQuit("Password is too short!"); |
| 82 | 82 | } else { |
| 83 | 83 | $newpassword = $specifiedpassword; |
| 84 | 84 | } |
| 85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 85 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | 86 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 87 | - } elseif($passwordgenmethod == 'g') { |
|
| 87 | + } elseif ($passwordgenmethod == 'g') { |
|
| 88 | 88 | $newpassword = generate_password(8); |
| 89 | 89 | } else { |
| 90 | 90 | webAlertAndQuit("No password generation method specified!"); |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | /*******************************************************************************/ |
| 115 | 115 | // put the user in the user_groups he/ she should be in |
| 116 | 116 | // first, check that up_perms are switched on! |
| 117 | - if($use_udperms == 1) { |
|
| 118 | - if(!empty($user_groups)) { |
|
| 119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 117 | + if ($use_udperms == 1) { |
|
| 118 | + if (!empty($user_groups)) { |
|
| 119 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | 120 | $f = array(); |
| 121 | 121 | $f['webgroup'] = intval($user_groups[$i]); |
| 122 | 122 | $f['webuser'] = $internalKey; |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | "id" => $internalKey |
| 143 | 143 | )); |
| 144 | 144 | |
| 145 | - if($passwordnotifymethod == 'e') { |
|
| 145 | + if ($passwordnotifymethod == 'e') { |
|
| 146 | 146 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 147 | - if($input['stay'] != '') { |
|
| 147 | + if ($input['stay'] != '') { |
|
| 148 | 148 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 149 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 150 | 150 | header($header); |
| 151 | 151 | } else { |
| 152 | 152 | $header = "Location: index.php?a=99&r=2"; |
| 153 | 153 | header($header); |
| 154 | 154 | } |
| 155 | 155 | } else { |
| 156 | - if($input['stay'] != '') { |
|
| 156 | + if ($input['stay'] != '') { |
|
| 157 | 157 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 158 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 159 | 159 | } else { |
| 160 | 160 | $stayUrl = "index.php?a=99&r=2"; |
| 161 | 161 | } |
@@ -188,36 +188,36 @@ discard block |
||
| 188 | 188 | break; |
| 189 | 189 | case '88' : // edit user |
| 190 | 190 | // generate a new password for this user |
| 191 | - if($genpassword == 1) { |
|
| 192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | - if(strlen($specifiedpassword) < 6) { |
|
| 191 | + if ($genpassword == 1) { |
|
| 192 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | + if (strlen($specifiedpassword) < 6) { |
|
| 194 | 194 | webAlertAndQuit("Password is too short!"); |
| 195 | 195 | } else { |
| 196 | 196 | $newpassword = $specifiedpassword; |
| 197 | 197 | } |
| 198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 198 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | 199 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 200 | - } elseif($passwordgenmethod == 'g') { |
|
| 200 | + } elseif ($passwordgenmethod == 'g') { |
|
| 201 | 201 | $newpassword = generate_password(8); |
| 202 | 202 | } else { |
| 203 | 203 | webAlertAndQuit("No password generation method specified!"); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | - if($passwordnotifymethod == 'e') { |
|
| 206 | + if ($passwordnotifymethod == 'e') { |
|
| 207 | 207 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // check if the username already exist |
| 211 | 211 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
| 212 | 212 | $limit = $modx->db->getValue($rs); |
| 213 | - if($limit > 0) { |
|
| 213 | + if ($limit > 0) { |
|
| 214 | 214 | webAlertAndQuit("User name is already in use!"); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // check if the email address already exists |
| 218 | 218 | $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
| 219 | 219 | $limit = $modx->db->getValue($rs); |
| 220 | - if($limit > 0) { |
|
| 220 | + if ($limit > 0) { |
|
| 221 | 221 | webAlertAndQuit("Email is already in use!"); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | // update user name and password |
| 231 | 231 | $field = array(); |
| 232 | 232 | $field['username'] = $esc_newusername; |
| 233 | - if($genpassword == 1) { |
|
| 233 | + if ($genpassword == 1) { |
|
| 234 | 234 | $field['password'] = md5($newpassword); |
| 235 | 235 | } |
| 236 | 236 | $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | /*******************************************************************************/ |
| 248 | 248 | // put the user in the user_groups he/ she should be in |
| 249 | 249 | // first, check that up_perms are switched on! |
| 250 | - if($use_udperms == 1) { |
|
| 250 | + if ($use_udperms == 1) { |
|
| 251 | 251 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 252 | 252 | $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
| 253 | - if(!empty($user_groups)) { |
|
| 254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 253 | + if (!empty($user_groups)) { |
|
| 254 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | 255 | $field = array(); |
| 256 | 256 | $field['webgroup'] = intval($user_groups[$i]); |
| 257 | 257 | $field['webuser'] = $id; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | )); |
| 276 | 276 | |
| 277 | 277 | // invoke OnWebChangePassword event |
| 278 | - if($genpassword == 1) { |
|
| 278 | + if ($genpassword == 1) { |
|
| 279 | 279 | $modx->invokeEvent("OnWebChangePassword", array( |
| 280 | 280 | "userid" => $id, |
| 281 | 281 | "username" => $newusername, |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | "id" => $id |
| 290 | 290 | )); |
| 291 | 291 | |
| 292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | - if($input['stay'] != '') { |
|
| 292 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | + if ($input['stay'] != '') { |
|
| 294 | 294 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 295 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 296 | 296 | } else { |
| 297 | 297 | $stayUrl = "index.php?a=99&r=2"; |
| 298 | 298 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | include_once "footer.inc.php"; |
| 322 | 322 | } else { |
| 323 | - if($input['stay'] != '') { |
|
| 323 | + if ($input['stay'] != '') { |
|
| 324 | 324 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 325 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 326 | 326 | header($header); |
| 327 | 327 | } else { |
| 328 | 328 | $header = "Location: index.php?a=99&r=2"; |
@@ -335,19 +335,19 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // in case any plugins include a quoted_printable function |
| 338 | -function save_user_quoted_printable($string) { |
|
| 338 | +function save_user_quoted_printable($string){ |
|
| 339 | 339 | $crlf = "\n"; |
| 340 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 340 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
| 341 | 341 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
| 342 | 342 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
| 343 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 344 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 343 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
| 344 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
| 345 | 345 | $string = preg_replace($f, $r, $string); |
| 346 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 346 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | // Send an email to the user |
| 350 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 350 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
| 351 | 351 | global $modx, $_lang, $websignupemail_message; |
| 352 | 352 | global $emailsubject, $emailsender; |
| 353 | 353 | global $site_name, $site_url; |
@@ -368,14 +368,14 @@ discard block |
||
| 368 | 368 | $param['to'] = $email; |
| 369 | 369 | $param['type'] = 'text'; |
| 370 | 370 | $rs = $modx->sendmail($param); |
| 371 | - if(!$rs) { |
|
| 371 | + if (!$rs) { |
|
| 372 | 372 | $modx->manager->saveFormValues(); |
| 373 | 373 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Save User Settings |
| 378 | -function saveUserSettings($id) { |
|
| 378 | +function saveUserSettings($id){ |
|
| 379 | 379 | global $modx; |
| 380 | 380 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
| 381 | 381 | |
@@ -387,12 +387,12 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
| 389 | 389 | |
| 390 | - foreach($settings as $n) { |
|
| 390 | + foreach ($settings as $n) { |
|
| 391 | 391 | $vl = $_POST[$n]; |
| 392 | - if(is_array($vl)) { |
|
| 392 | + if (is_array($vl)) { |
|
| 393 | 393 | $vl = implode(",", $vl); |
| 394 | 394 | } |
| 395 | - if($vl != '') { |
|
| 395 | + if ($vl != '') { |
|
| 396 | 396 | $f = array(); |
| 397 | 397 | $f['webuser'] = $id; |
| 398 | 398 | $f['setting_name'] = $n; |
@@ -404,33 +404,33 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // Web alert - sends an alert to web browser |
| 407 | -function webAlertAndQuit($msg) { |
|
| 407 | +function webAlertAndQuit($msg){ |
|
| 408 | 408 | global $id, $modx; |
| 409 | 409 | $mode = $_POST['mode']; |
| 410 | 410 | $modx->manager->saveFormValues($mode); |
| 411 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 411 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // Generate password |
| 415 | -function generate_password($length = 10) { |
|
| 415 | +function generate_password($length = 10){ |
|
| 416 | 416 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 417 | 417 | $ps_len = strlen($allowable_characters); |
| 418 | 418 | mt_srand((double) microtime() * 1000000); |
| 419 | 419 | $pass = ""; |
| 420 | - for($i = 0; $i < $length; $i++) { |
|
| 420 | + for ($i = 0; $i < $length; $i++) { |
|
| 421 | 421 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
| 422 | 422 | } |
| 423 | 423 | return $pass; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | -function sanitize($str = '', $safecount = 0) { |
|
| 426 | +function sanitize($str = '', $safecount = 0){ |
|
| 427 | 427 | global $modx; |
| 428 | 428 | $safecount++; |
| 429 | - if(1000 < $safecount) { |
|
| 429 | + if (1000 < $safecount) { |
|
| 430 | 430 | exit("error too many loops '{$safecount}'"); |
| 431 | 431 | } |
| 432 | - if(is_array($str)) { |
|
| 433 | - foreach($str as $i => $v) { |
|
| 432 | + if (is_array($str)) { |
|
| 433 | + foreach ($str as $i => $v) { |
|
| 434 | 434 | $str[$i] = sanitize($v, $safecount); |
| 435 | 435 | } |
| 436 | 436 | } else { |