@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('messages')) { |
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if ($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | $modx->webAlertAndQuit("Wrong number of messages returned!"); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -if ($message['recipient']!=$modx->getLoginUserID()) { |
|
| 21 | +if ($message['recipient'] != $modx->getLoginUserID()) { |
|
| 22 | 22 | $modx->webAlertAndQuit("You are not allowed to delete this message!"); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // delete message |
| 26 | 26 | $modx->getDatabase()->delete($modx->getFullTableName('user_messages'), "id='{$id}'"); |
| 27 | 27 | |
| 28 | -$header="Location: index.php?a=10"; |
|
| 28 | +$header = "Location: index.php?a=10"; |
|
| 29 | 29 | header($header); |
@@ -3,12 +3,12 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('new_module')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | // count duplicates |
| 14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
@@ -18,40 +18,40 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | // duplicate module |
| 20 | 20 | $newid = $modx->getDatabase()->insert( |
| 21 | - array( |
|
| 22 | - 'name'=>'', |
|
| 23 | - 'description'=>'', |
|
| 24 | - 'disabled'=>'', |
|
| 25 | - 'category'=>'', |
|
| 26 | - 'wrap'=>'', |
|
| 27 | - 'icon'=>'', |
|
| 28 | - 'enable_resource'=>'', |
|
| 29 | - 'resourcefile'=>'', |
|
| 30 | - 'createdon'=>'', |
|
| 31 | - 'editedon'=>'', |
|
| 32 | - 'guid'=>'', |
|
| 33 | - 'enable_sharedparams'=>'', |
|
| 34 | - 'properties'=>'', |
|
| 35 | - 'modulecode'=>'', |
|
| 36 | - ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 37 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
| 21 | + array( |
|
| 22 | + 'name'=>'', |
|
| 23 | + 'description'=>'', |
|
| 24 | + 'disabled'=>'', |
|
| 25 | + 'category'=>'', |
|
| 26 | + 'wrap'=>'', |
|
| 27 | + 'icon'=>'', |
|
| 28 | + 'enable_resource'=>'', |
|
| 29 | + 'resourcefile'=>'', |
|
| 30 | + 'createdon'=>'', |
|
| 31 | + 'editedon'=>'', |
|
| 32 | + 'guid'=>'', |
|
| 33 | + 'enable_sharedparams'=>'', |
|
| 34 | + 'properties'=>'', |
|
| 35 | + 'modulecode'=>'', |
|
| 36 | + ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 37 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
| 38 | 38 | |
| 39 | 39 | // duplicate module dependencies |
| 40 | 40 | $modx->getDatabase()->insert( |
| 41 | - array( |
|
| 42 | - 'module'=>'', |
|
| 43 | - 'resource'=>'', |
|
| 44 | - 'type'=>'', |
|
| 45 | - ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 46 | - "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 41 | + array( |
|
| 42 | + 'module'=>'', |
|
| 43 | + 'resource'=>'', |
|
| 44 | + 'type'=>'', |
|
| 45 | + ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 46 | + "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 47 | 47 | |
| 48 | 48 | // duplicate module user group access |
| 49 | 49 | $modx->getDatabase()->insert( |
| 50 | - array( |
|
| 51 | - 'module'=>'', |
|
| 52 | - 'usergroup'=>'', |
|
| 53 | - ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 54 | - "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 50 | + array( |
|
| 51 | + 'module'=>'', |
|
| 52 | + 'usergroup'=>'', |
|
| 53 | + ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 54 | + "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 55 | 55 | |
| 56 | 56 | // Set the item name for logger |
| 57 | 57 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'")); |
@@ -1,19 +1,19 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('new_module')) { |
|
| 5 | +if (!$modx->hasPermission('new_module')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | // count duplicates |
| 14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
| 15 | 15 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 16 | -if($count>=1) $count = ' '.($count+1); |
|
| 16 | +if ($count >= 1) $count = ' '.($count + 1); |
|
| 17 | 17 | else $count = ''; |
| 18 | 18 | |
| 19 | 19 | // duplicate module |
@@ -58,5 +58,5 @@ discard block |
||
| 58 | 58 | $_SESSION['itemname'] = $name; |
| 59 | 59 | |
| 60 | 60 | // finish duplicating - redirect to new module |
| 61 | -$header="Location: index.php?r=2&a=108&id=$newid"; |
|
| 61 | +$header = "Location: index.php?r=2&a=108&id=$newid"; |
|
| 62 | 62 | header($header); |
@@ -13,8 +13,11 @@ |
||
| 13 | 13 | // count duplicates |
| 14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
| 15 | 15 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 16 | -if($count>=1) $count = ' '.($count+1); |
|
| 17 | -else $count = ''; |
|
| 16 | +if($count>=1) { |
|
| 17 | + $count = ' '.($count+1); |
|
| 18 | +} else { |
|
| 19 | + $count = ''; |
|
| 20 | +} |
|
| 18 | 21 | |
| 19 | 22 | // duplicate module |
| 20 | 23 | $newid = $modx->getDatabase()->insert( |
@@ -59,123 +59,123 @@ |
||
| 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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 72 | - if ($count > 0) { |
|
| 73 | - $modx->getManagerApi()->saveFormValues(107); |
|
| 74 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // save the new module |
|
| 78 | - $newid = $modx->getDatabase()->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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | - if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 131 | - $modx->getManagerApi()->saveFormValues(108); |
|
| 132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // save the edited module |
|
| 136 | - $modx->getDatabase()->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."); |
|
| 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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
| 71 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 72 | + if ($count > 0) { |
|
| 73 | + $modx->getManagerApi()->saveFormValues(107); |
|
| 74 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // save the new module |
|
| 78 | + $newid = $modx->getDatabase()->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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 131 | + $modx->getManagerApi()->saveFormValues(108); |
|
| 132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // save the edited module |
|
| 136 | + $modx->getDatabase()->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 | } |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('save_module')) { |
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = (int)$_POST['id']; |
|
| 9 | +$id = (int) $_POST['id']; |
|
| 10 | 10 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
| 11 | 11 | $description = $modx->getDatabase()->escape($_POST['description']); |
| 12 | 12 | $resourcefile = $modx->getDatabase()->escape($_POST['resourcefile']); |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | //Kyle Jaebker - added category support |
| 27 | 27 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
| 28 | - $categoryid = (int)$_POST['categoryid']; |
|
| 28 | + $categoryid = (int) $_POST['categoryid']; |
|
| 29 | 29 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
| 30 | 30 | $categoryid = 0; |
| 31 | 31 | } else { |
| 32 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 32 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 33 | 33 | $categoryid = checkCategory($_POST['newcategory']); |
| 34 | 34 | if (!$categoryid) { |
| 35 | 35 | $categoryid = newCategory($_POST['newcategory']); |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | $name = isset($parsed['name']) ? $parsed['name'] : $name; |
| 46 | 46 | $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; |
| 47 | 47 | $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid; |
| 48 | - $enable_sharedparams = isset($parsed['shareparams']) ? (int)$parsed['shareparams'] : $enable_sharedparams; |
|
| 48 | + $enable_sharedparams = isset($parsed['shareparams']) ? (int) $parsed['shareparams'] : $enable_sharedparams; |
|
| 49 | 49 | |
| 50 | 50 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
| 51 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
| 51 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
| 52 | 52 | if ($version) { |
| 53 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 53 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 54 | 54 | } |
| 55 | 55 | if (isset($parsed['modx_category'])) { |
| 56 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 56 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 57 | 57 | $categoryid = getCategory($parsed['modx_category']); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | // finished emptying cache - redirect |
| 112 | 112 | if ($_POST['stay'] != '') { |
| 113 | 113 | $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
| 114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 114 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 115 | 115 | header($header); |
| 116 | 116 | } else { |
| 117 | 117 | $header = "Location: index.php?a=106&r=2"; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | // finished emptying cache - redirect |
| 169 | 169 | if ($_POST['stay'] != '') { |
| 170 | 170 | $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
| 171 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 171 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 172 | 172 | header($header); |
| 173 | 173 | } else { |
| 174 | 174 | $modx->unlockElement(6, $id); |
@@ -3,12 +3,12 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('new_chunk')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // count duplicates |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // duplicate htmlsnippet |
| 21 | 21 | $newid = $modx->getDatabase()->insert( |
| 22 | - array( |
|
| 23 | - 'name'=>'', |
|
| 24 | - 'description'=>'', |
|
| 25 | - 'snippet'=>'', |
|
| 26 | - 'category'=>'', |
|
| 27 | - ), $modx->getFullTableName('site_htmlsnippets'), // Insert into |
|
| 28 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from |
|
| 22 | + array( |
|
| 23 | + 'name'=>'', |
|
| 24 | + 'description'=>'', |
|
| 25 | + 'snippet'=>'', |
|
| 26 | + 'category'=>'', |
|
| 27 | + ), $modx->getFullTableName('site_htmlsnippets'), // Insert into |
|
| 28 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from |
|
| 29 | 29 | |
| 30 | 30 | // Set the item name for logger |
| 31 | 31 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$newid}'")); |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('new_chunk')) { |
|
| 5 | +if (!$modx->hasPermission('new_chunk')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 17 | -if($count>=1) $count = ' '.($count+1); |
|
| 17 | +if ($count >= 1) $count = ' '.($count + 1); |
|
| 18 | 18 | else $count = ''; |
| 19 | 19 | |
| 20 | 20 | // duplicate htmlsnippet |
@@ -32,5 +32,5 @@ discard block |
||
| 32 | 32 | $_SESSION['itemname'] = $name; |
| 33 | 33 | |
| 34 | 34 | // finish duplicating - redirect to new chunk |
| 35 | -$header="Location: index.php?r=2&a=78&id=$newid"; |
|
| 35 | +$header = "Location: index.php?r=2&a=78&id=$newid"; |
|
| 36 | 36 | header($header); |
@@ -14,8 +14,11 @@ |
||
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 17 | -if($count>=1) $count = ' '.($count+1); |
|
| 18 | -else $count = ''; |
|
| 17 | +if($count>=1) { |
|
| 18 | + $count = ' '.($count+1); |
|
| 19 | +} else { |
|
| 20 | + $count = ''; |
|
| 21 | +} |
|
| 19 | 22 | |
| 20 | 23 | // duplicate htmlsnippet |
| 21 | 24 | $newid = $modx->getDatabase()->insert( |
@@ -1,135 +1,135 @@ |
||
| 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_role')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | extract($_POST); |
| 10 | 10 | |
| 11 | 11 | if($name == '' || !isset ($name)) { |
| 12 | - $modx->webAlertAndQuit("Please enter a name for this role!", "index.php?a={$mode}" . ($mode = 35 ? "&id={$id}" : "")); |
|
| 12 | + $modx->webAlertAndQuit("Please enter a name for this role!", "index.php?a={$mode}" . ($mode = 35 ? "&id={$id}" : "")); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // setup fields |
| 16 | 16 | $fields = array( |
| 17 | - 'name' => $name, |
|
| 18 | - 'description' => $description, |
|
| 19 | - 'frames' => $frames, |
|
| 20 | - 'home' => $home, |
|
| 21 | - 'view_document' => $view_document, |
|
| 22 | - 'new_document' => $new_document, |
|
| 23 | - 'save_document' => $save_document, |
|
| 24 | - 'publish_document' => $publish_document, |
|
| 25 | - 'delete_document' => $delete_document, |
|
| 26 | - 'empty_trash' => $empty_trash, |
|
| 27 | - 'action_ok' => $action_ok, |
|
| 28 | - 'logout' => $logout, |
|
| 29 | - 'help' => $help, |
|
| 30 | - 'messages' => $messages, |
|
| 31 | - 'new_user' => $new_user, |
|
| 32 | - 'edit_user' => $edit_user, |
|
| 33 | - 'logs' => $logs, |
|
| 34 | - 'edit_parser' => (isset ($edit_parser)) ? $edit_parser : '0', |
|
| 35 | - 'save_parser' => (isset ($save_parser)) ? $save_parser : '0', |
|
| 36 | - 'edit_template' => $edit_template, |
|
| 37 | - 'settings' => $settings, |
|
| 38 | - 'credits' => $credits, |
|
| 39 | - 'new_template' => $new_template, |
|
| 40 | - 'save_template' => $save_template, |
|
| 41 | - 'delete_template' => $delete_template, |
|
| 42 | - 'edit_snippet' => $edit_snippet, |
|
| 43 | - 'new_snippet' => $new_snippet, |
|
| 44 | - 'save_snippet' => $save_snippet, |
|
| 45 | - 'delete_snippet' => $delete_snippet, |
|
| 46 | - 'edit_chunk' => $edit_chunk, |
|
| 47 | - 'new_chunk' => $new_chunk, |
|
| 48 | - 'save_chunk' => $save_chunk, |
|
| 49 | - 'delete_chunk' => $delete_chunk, |
|
| 50 | - 'empty_cache' => $empty_cache, |
|
| 51 | - 'edit_document' => $edit_document, |
|
| 52 | - 'change_password' => $change_password, |
|
| 53 | - 'error_dialog' => $error_dialog, |
|
| 54 | - 'about' => $about, |
|
| 55 | - 'file_manager' => $file_manager, |
|
| 56 | - 'assets_files' => $assets_files, |
|
| 57 | - 'assets_images' => $assets_images, |
|
| 58 | - 'save_user' => $save_user, |
|
| 59 | - 'delete_user' => $delete_user, |
|
| 60 | - 'save_password' => $save_password, |
|
| 61 | - 'edit_role' => $edit_role, |
|
| 62 | - 'save_role' => $save_role, |
|
| 63 | - 'delete_role' => $delete_role, |
|
| 64 | - 'new_role' => $new_role, |
|
| 65 | - 'access_permissions' => $access_permissions, |
|
| 66 | - 'bk_manager' => $bk_manager, |
|
| 67 | - 'new_plugin' => $new_plugin, |
|
| 68 | - 'edit_plugin' => $edit_plugin, |
|
| 69 | - 'save_plugin' => $save_plugin, |
|
| 70 | - 'delete_plugin' => $delete_plugin, |
|
| 71 | - 'new_module' => $new_module, |
|
| 72 | - 'edit_module' => $edit_module, |
|
| 73 | - 'save_module' => $save_module, |
|
| 74 | - 'delete_module' => $delete_module, |
|
| 75 | - 'exec_module' => $exec_module, |
|
| 76 | - 'view_eventlog' => $view_eventlog, |
|
| 77 | - 'delete_eventlog' => $delete_eventlog, |
|
| 78 | - 'new_web_user' => $new_web_user, |
|
| 79 | - 'edit_web_user' => $edit_web_user, |
|
| 80 | - 'save_web_user' => $save_web_user, |
|
| 81 | - 'delete_web_user' => $delete_web_user, |
|
| 82 | - 'web_access_permissions' => $web_access_permissions, |
|
| 83 | - 'view_unpublished' => $view_unpublished, |
|
| 84 | - 'import_static' => $import_static, |
|
| 85 | - 'export_static' => $export_static, |
|
| 86 | - 'remove_locks' => $remove_locks, |
|
| 87 | - 'display_locks' => $display_locks, |
|
| 88 | - 'change_resourcetype' => $change_resourcetype, |
|
| 89 | - 'category_manager' => $category_manager |
|
| 17 | + 'name' => $name, |
|
| 18 | + 'description' => $description, |
|
| 19 | + 'frames' => $frames, |
|
| 20 | + 'home' => $home, |
|
| 21 | + 'view_document' => $view_document, |
|
| 22 | + 'new_document' => $new_document, |
|
| 23 | + 'save_document' => $save_document, |
|
| 24 | + 'publish_document' => $publish_document, |
|
| 25 | + 'delete_document' => $delete_document, |
|
| 26 | + 'empty_trash' => $empty_trash, |
|
| 27 | + 'action_ok' => $action_ok, |
|
| 28 | + 'logout' => $logout, |
|
| 29 | + 'help' => $help, |
|
| 30 | + 'messages' => $messages, |
|
| 31 | + 'new_user' => $new_user, |
|
| 32 | + 'edit_user' => $edit_user, |
|
| 33 | + 'logs' => $logs, |
|
| 34 | + 'edit_parser' => (isset ($edit_parser)) ? $edit_parser : '0', |
|
| 35 | + 'save_parser' => (isset ($save_parser)) ? $save_parser : '0', |
|
| 36 | + 'edit_template' => $edit_template, |
|
| 37 | + 'settings' => $settings, |
|
| 38 | + 'credits' => $credits, |
|
| 39 | + 'new_template' => $new_template, |
|
| 40 | + 'save_template' => $save_template, |
|
| 41 | + 'delete_template' => $delete_template, |
|
| 42 | + 'edit_snippet' => $edit_snippet, |
|
| 43 | + 'new_snippet' => $new_snippet, |
|
| 44 | + 'save_snippet' => $save_snippet, |
|
| 45 | + 'delete_snippet' => $delete_snippet, |
|
| 46 | + 'edit_chunk' => $edit_chunk, |
|
| 47 | + 'new_chunk' => $new_chunk, |
|
| 48 | + 'save_chunk' => $save_chunk, |
|
| 49 | + 'delete_chunk' => $delete_chunk, |
|
| 50 | + 'empty_cache' => $empty_cache, |
|
| 51 | + 'edit_document' => $edit_document, |
|
| 52 | + 'change_password' => $change_password, |
|
| 53 | + 'error_dialog' => $error_dialog, |
|
| 54 | + 'about' => $about, |
|
| 55 | + 'file_manager' => $file_manager, |
|
| 56 | + 'assets_files' => $assets_files, |
|
| 57 | + 'assets_images' => $assets_images, |
|
| 58 | + 'save_user' => $save_user, |
|
| 59 | + 'delete_user' => $delete_user, |
|
| 60 | + 'save_password' => $save_password, |
|
| 61 | + 'edit_role' => $edit_role, |
|
| 62 | + 'save_role' => $save_role, |
|
| 63 | + 'delete_role' => $delete_role, |
|
| 64 | + 'new_role' => $new_role, |
|
| 65 | + 'access_permissions' => $access_permissions, |
|
| 66 | + 'bk_manager' => $bk_manager, |
|
| 67 | + 'new_plugin' => $new_plugin, |
|
| 68 | + 'edit_plugin' => $edit_plugin, |
|
| 69 | + 'save_plugin' => $save_plugin, |
|
| 70 | + 'delete_plugin' => $delete_plugin, |
|
| 71 | + 'new_module' => $new_module, |
|
| 72 | + 'edit_module' => $edit_module, |
|
| 73 | + 'save_module' => $save_module, |
|
| 74 | + 'delete_module' => $delete_module, |
|
| 75 | + 'exec_module' => $exec_module, |
|
| 76 | + 'view_eventlog' => $view_eventlog, |
|
| 77 | + 'delete_eventlog' => $delete_eventlog, |
|
| 78 | + 'new_web_user' => $new_web_user, |
|
| 79 | + 'edit_web_user' => $edit_web_user, |
|
| 80 | + 'save_web_user' => $save_web_user, |
|
| 81 | + 'delete_web_user' => $delete_web_user, |
|
| 82 | + 'web_access_permissions' => $web_access_permissions, |
|
| 83 | + 'view_unpublished' => $view_unpublished, |
|
| 84 | + 'import_static' => $import_static, |
|
| 85 | + 'export_static' => $export_static, |
|
| 86 | + 'remove_locks' => $remove_locks, |
|
| 87 | + 'display_locks' => $display_locks, |
|
| 88 | + 'change_resourcetype' => $change_resourcetype, |
|
| 89 | + 'category_manager' => $category_manager |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | 92 | $fields = $modx->getDatabase()->escape($fields); |
| 93 | 93 | |
| 94 | 94 | switch($_POST['mode']) { |
| 95 | - case '38' : |
|
| 96 | - $tbl = $modx->getFullTableName("user_roles"); |
|
| 95 | + case '38' : |
|
| 96 | + $tbl = $modx->getFullTableName("user_roles"); |
|
| 97 | 97 | |
| 98 | - // disallow duplicate names for role |
|
| 99 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}'"); |
|
| 100 | - if($modx->getDatabase()->getValue($rs) > 0) { |
|
| 101 | - $modx->getManagerApi()->saveFormValues(38); |
|
| 102 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=38"); |
|
| 103 | - } |
|
| 98 | + // disallow duplicate names for role |
|
| 99 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}'"); |
|
| 100 | + if($modx->getDatabase()->getValue($rs) > 0) { |
|
| 101 | + $modx->getManagerApi()->saveFormValues(38); |
|
| 102 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=38"); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - $modx->getDatabase()->insert($fields, $tbl); |
|
| 105 | + $modx->getDatabase()->insert($fields, $tbl); |
|
| 106 | 106 | |
| 107 | - // Set the item name for logger |
|
| 108 | - $_SESSION['itemname'] = $_POST['name']; |
|
| 107 | + // Set the item name for logger |
|
| 108 | + $_SESSION['itemname'] = $_POST['name']; |
|
| 109 | 109 | |
| 110 | - $header = "Location: index.php?a=86&r=2"; |
|
| 111 | - header($header); |
|
| 112 | - break; |
|
| 113 | - case '35' : |
|
| 114 | - $tbl = $modx->getFullTableName("user_roles"); |
|
| 110 | + $header = "Location: index.php?a=86&r=2"; |
|
| 111 | + header($header); |
|
| 112 | + break; |
|
| 113 | + case '35' : |
|
| 114 | + $tbl = $modx->getFullTableName("user_roles"); |
|
| 115 | 115 | |
| 116 | - // disallow duplicate names for role |
|
| 117 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}' AND id!='{$id}'"); |
|
| 118 | - if($modx->getDatabase()->getValue($rs) > 0) { |
|
| 119 | - $modx->getManagerApi()->saveFormValues(35); |
|
| 120 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=35&id={$id}"); |
|
| 121 | - } |
|
| 116 | + // disallow duplicate names for role |
|
| 117 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}' AND id!='{$id}'"); |
|
| 118 | + if($modx->getDatabase()->getValue($rs) > 0) { |
|
| 119 | + $modx->getManagerApi()->saveFormValues(35); |
|
| 120 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=35&id={$id}"); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - $modx->getDatabase()->update($fields, $tbl, "id='{$id}'"); |
|
| 123 | + $modx->getDatabase()->update($fields, $tbl, "id='{$id}'"); |
|
| 124 | 124 | |
| 125 | - // Set the item name for logger |
|
| 126 | - $_SESSION['itemname'] = $_POST['name']; |
|
| 125 | + // Set the item name for logger |
|
| 126 | + $_SESSION['itemname'] = $_POST['name']; |
|
| 127 | 127 | |
| 128 | - $header = "Location: index.php?a=86&r=2"; |
|
| 129 | - header($header); |
|
| 130 | - break; |
|
| 131 | - default : |
|
| 132 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 128 | + $header = "Location: index.php?a=86&r=2"; |
|
| 129 | + header($header); |
|
| 130 | + break; |
|
| 131 | + default : |
|
| 132 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $modx->unlockElement(8, $id); |
@@ -1,15 +1,15 @@ 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_role')) { |
|
| 5 | +if (!$modx->hasPermission('save_role')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | extract($_POST); |
| 10 | 10 | |
| 11 | -if($name == '' || !isset ($name)) { |
|
| 12 | - $modx->webAlertAndQuit("Please enter a name for this role!", "index.php?a={$mode}" . ($mode = 35 ? "&id={$id}" : "")); |
|
| 11 | +if ($name == '' || !isset ($name)) { |
|
| 12 | + $modx->webAlertAndQuit("Please enter a name for this role!", "index.php?a={$mode}".($mode = 35 ? "&id={$id}" : "")); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // setup fields |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $fields = $modx->getDatabase()->escape($fields); |
| 93 | 93 | |
| 94 | -switch($_POST['mode']) { |
|
| 94 | +switch ($_POST['mode']) { |
|
| 95 | 95 | case '38' : |
| 96 | 96 | $tbl = $modx->getFullTableName("user_roles"); |
| 97 | 97 | |
| 98 | 98 | // disallow duplicate names for role |
| 99 | 99 | $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}'"); |
| 100 | - if($modx->getDatabase()->getValue($rs) > 0) { |
|
| 100 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 101 | 101 | $modx->getManagerApi()->saveFormValues(38); |
| 102 | 102 | $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=38"); |
| 103 | 103 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | // disallow duplicate names for role |
| 117 | 117 | $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}' AND id!='{$id}'"); |
| 118 | - if($modx->getDatabase()->getValue($rs) > 0) { |
|
| 118 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 119 | 119 | $modx->getManagerApi()->saveFormValues(35); |
| 120 | 120 | $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=35&id={$id}"); |
| 121 | 121 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('edit_document')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
@@ -25,68 +25,68 @@ discard block |
||
| 25 | 25 | // check user has permission to move document to chosen location |
| 26 | 26 | |
| 27 | 27 | if ($use_udperms == 1) { |
| 28 | - if ($oldparent != $newParentID) { |
|
| 29 | - $udperms = new EvolutionCMS\Legacy\Permissions(); |
|
| 30 | - $udperms->user = $modx->getLoginUserID(); |
|
| 31 | - $udperms->document = $newParentID; |
|
| 32 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 28 | + if ($oldparent != $newParentID) { |
|
| 29 | + $udperms = new EvolutionCMS\Legacy\Permissions(); |
|
| 30 | + $udperms->user = $modx->getLoginUserID(); |
|
| 31 | + $udperms->document = $newParentID; |
|
| 32 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 33 | 33 | |
| 34 | - if (!$udperms->checkPermissions()) { |
|
| 35 | - $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
| 36 | - } |
|
| 37 | - } |
|
| 34 | + if (!$udperms->checkPermissions()) { |
|
| 35 | + $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
| 41 | - "id_document" => $documentID, |
|
| 42 | - "old_parent" => $oldparent, |
|
| 43 | - "new_parent" => $newParentID |
|
| 41 | + "id_document" => $documentID, |
|
| 42 | + "old_parent" => $oldparent, |
|
| 43 | + "new_parent" => $newParentID |
|
| 44 | 44 | )); |
| 45 | 45 | if (is_array($evtOut) && count($evtOut) > 0){ |
| 46 | - $newParent = array_pop($evtOut); |
|
| 47 | - if($newParent == $oldparent) { |
|
| 48 | - $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 49 | - }else{ |
|
| 50 | - $newParentID = $newParent; |
|
| 51 | - } |
|
| 46 | + $newParent = array_pop($evtOut); |
|
| 47 | + if($newParent == $oldparent) { |
|
| 48 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 49 | + }else{ |
|
| 50 | + $newParentID = $newParent; |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $children = allChildren($documentID); |
| 55 | 55 | if (!array_search($newParentID, $children)) { |
| 56 | - $modx->getDatabase()->update(array( |
|
| 57 | - 'isfolder' => 1, |
|
| 58 | - ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
| 56 | + $modx->getDatabase()->update(array( |
|
| 57 | + 'isfolder' => 1, |
|
| 58 | + ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
| 59 | 59 | |
| 60 | - $modx->getDatabase()->update(array( |
|
| 61 | - 'parent' => $newParentID, |
|
| 62 | - 'editedby' => $modx->getLoginUserID(), |
|
| 63 | - 'editedon' => time(), |
|
| 64 | - ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
| 60 | + $modx->getDatabase()->update(array( |
|
| 61 | + 'parent' => $newParentID, |
|
| 62 | + 'editedby' => $modx->getLoginUserID(), |
|
| 63 | + 'editedon' => time(), |
|
| 64 | + ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
| 65 | 65 | |
| 66 | - // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
| 67 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
| 68 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 66 | + // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
| 67 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
| 68 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 69 | 69 | |
| 70 | - if(!$limit>0) { |
|
| 71 | - $modx->getDatabase()->update(array( |
|
| 72 | - 'isfolder' => 0, |
|
| 73 | - ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
| 74 | - } |
|
| 75 | - // Set the item name for logger |
|
| 76 | - $pagetitle = $modx->getDatabase()->getValue($modx->getDatabase()->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
| 77 | - $_SESSION['itemname'] = $pagetitle; |
|
| 70 | + if(!$limit>0) { |
|
| 71 | + $modx->getDatabase()->update(array( |
|
| 72 | + 'isfolder' => 0, |
|
| 73 | + ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
| 74 | + } |
|
| 75 | + // Set the item name for logger |
|
| 76 | + $pagetitle = $modx->getDatabase()->getValue($modx->getDatabase()->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
| 77 | + $_SESSION['itemname'] = $pagetitle; |
|
| 78 | 78 | |
| 79 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 80 | - "id_document" => $documentID, |
|
| 81 | - "old_parent" => $oldparent, |
|
| 82 | - "new_parent" => $newParentID |
|
| 83 | - )); |
|
| 79 | + $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 80 | + "id_document" => $documentID, |
|
| 81 | + "old_parent" => $oldparent, |
|
| 82 | + "new_parent" => $newParentID |
|
| 83 | + )); |
|
| 84 | 84 | |
| 85 | - // empty cache & sync site |
|
| 86 | - $modx->clearCache('full'); |
|
| 85 | + // empty cache & sync site |
|
| 86 | + $modx->clearCache('full'); |
|
| 87 | 87 | |
| 88 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 89 | - header($header); |
|
| 88 | + $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 89 | + header($header); |
|
| 90 | 90 | } else { |
| 91 | - $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
| 91 | + $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
| 92 | 92 | } |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('edit_document')) { |
|
| 5 | +if (!$modx->hasPermission('edit_document')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
|
| 10 | -$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 9 | +$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0; |
|
| 10 | +$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 11 | 11 | |
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | +if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | +if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 18 | 18 | |
| 19 | 19 | $parents = $modx->getParentIds($newParentID); |
| 20 | 20 | if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | -$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
|
| 40 | +$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array( |
|
| 41 | 41 | "id_document" => $documentID, |
| 42 | 42 | "old_parent" => $oldparent, |
| 43 | 43 | "new_parent" => $newParentID |
| 44 | 44 | )); |
| 45 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 45 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 46 | 46 | $newParent = array_pop($evtOut); |
| 47 | - if($newParent == $oldparent) { |
|
| 47 | + if ($newParent == $oldparent) { |
|
| 48 | 48 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 49 | - }else{ |
|
| 49 | + } else { |
|
| 50 | 50 | $newParentID = $newParent; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
| 68 | 68 | $limit = $modx->getDatabase()->getValue($rs); |
| 69 | 69 | |
| 70 | - if(!$limit>0) { |
|
| 70 | + if (!$limit > 0) { |
|
| 71 | 71 | $modx->getDatabase()->update(array( |
| 72 | 72 | 'isfolder' => 0, |
| 73 | 73 | ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $pagetitle = $modx->getDatabase()->getValue($modx->getDatabase()->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
| 77 | 77 | $_SESSION['itemname'] = $pagetitle; |
| 78 | 78 | |
| 79 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
| 79 | + $modx->invokeEvent("onAfterMoveDocument", array( |
|
| 80 | 80 | "id_document" => $documentID, |
| 81 | 81 | "old_parent" => $oldparent, |
| 82 | 82 | "new_parent" => $newParentID |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | // empty cache & sync site |
| 86 | 86 | $modx->clearCache('full'); |
| 87 | 87 | |
| 88 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 88 | + $header = "Location: index.php?a=3&id={$documentID}&r=9"; |
|
| 89 | 89 | header($header); |
| 90 | 90 | } else { |
| 91 | 91 | $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
@@ -12,12 +12,20 @@ discard block |
||
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if($documentID==$newParentID) { |
|
| 16 | + $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 17 | +} |
|
| 18 | +if($documentID <= 0) { |
|
| 19 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 20 | +} |
|
| 21 | +if($newParentID < 0) { |
|
| 22 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 23 | +} |
|
| 18 | 24 | |
| 19 | 25 | $parents = $modx->getParentIds($newParentID); |
| 20 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 26 | +if (in_array($documentID, $parents)) { |
|
| 27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 28 | +} |
|
| 21 | 29 | |
| 22 | 30 | $rs = $modx->getDatabase()->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
| 23 | 31 | $oldparent = $modx->getDatabase()->getValue($rs); |
@@ -42,11 +50,11 @@ discard block |
||
| 42 | 50 | "old_parent" => $oldparent, |
| 43 | 51 | "new_parent" => $newParentID |
| 44 | 52 | )); |
| 45 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 53 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 46 | 54 | $newParent = array_pop($evtOut); |
| 47 | 55 | if($newParent == $oldparent) { |
| 48 | 56 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 49 | - }else{ |
|
| 57 | + } else { |
|
| 50 | 58 | $newParentID = $newParent; |
| 51 | 59 | } |
| 52 | 60 | } |
@@ -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 = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES); |
|
| 17 | - } |
|
| 18 | - $input[$k] = $v; |
|
| 15 | + if($k !== 'comment') { |
|
| 16 | + $v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES); |
|
| 17 | + } |
|
| 18 | + $input[$k] = $v; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $id = (int)$input['id']; |
@@ -51,82 +51,82 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 54 | - webAlertAndQuit("Password typed is mismatched", 88); |
|
| 54 | + webAlertAndQuit("Password typed is mismatched", 88); |
|
| 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!", 88); |
|
| 59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!", 88); |
|
| 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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!", 88); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 75 | - if($limit > 0) { |
|
| 76 | - webAlertAndQuit("Email is already in use!", 88); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // generate a new password for this user |
|
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 83 | - webAlertAndQuit("Password is too short!", 88); |
|
| 84 | - } else { |
|
| 85 | - $newpassword = $specifiedpassword; |
|
| 86 | - } |
|
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | - webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 90 | - $newpassword = generate_password(8); |
|
| 91 | - } else { |
|
| 92 | - webAlertAndQuit("No password generation method specified!", 88); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // invoke OnBeforeWUsrFormSave event |
|
| 96 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | - "mode" => "new", |
|
| 98 | - )); |
|
| 99 | - |
|
| 100 | - // create the user account |
|
| 101 | - $field = array(); |
|
| 102 | - $field['username'] = $esc_newusername; |
|
| 103 | - $field['password'] = md5($newpassword); |
|
| 104 | - $internalKey = $modx->getDatabase()->insert($field, $tbl_web_users); |
|
| 105 | - |
|
| 106 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | - $field = $modx->getDatabase()->escape($field); |
|
| 108 | - $modx->getDatabase()->insert($field, $tbl_web_user_attributes); |
|
| 109 | - |
|
| 110 | - // Save User Settings |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!", 88); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 75 | + if($limit > 0) { |
|
| 76 | + webAlertAndQuit("Email is already in use!", 88); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // generate a new password for this user |
|
| 81 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if(strlen($specifiedpassword) < 6) { |
|
| 83 | + webAlertAndQuit("Password is too short!", 88); |
|
| 84 | + } else { |
|
| 85 | + $newpassword = $specifiedpassword; |
|
| 86 | + } |
|
| 87 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | + webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 89 | + } elseif($passwordgenmethod == 'g') { |
|
| 90 | + $newpassword = generate_password(8); |
|
| 91 | + } else { |
|
| 92 | + webAlertAndQuit("No password generation method specified!", 88); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // invoke OnBeforeWUsrFormSave event |
|
| 96 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | + "mode" => "new", |
|
| 98 | + )); |
|
| 99 | + |
|
| 100 | + // create the user account |
|
| 101 | + $field = array(); |
|
| 102 | + $field['username'] = $esc_newusername; |
|
| 103 | + $field['password'] = md5($newpassword); |
|
| 104 | + $internalKey = $modx->getDatabase()->insert($field, $tbl_web_users); |
|
| 105 | + |
|
| 106 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | + $field = $modx->getDatabase()->escape($field); |
|
| 108 | + $modx->getDatabase()->insert($field, $tbl_web_user_attributes); |
|
| 109 | + |
|
| 110 | + // Save User Settings |
|
| 111 | 111 | saveWebUserSettings($internalKey); |
| 112 | 112 | |
| 113 | - // Set the item name for logger |
|
| 114 | - $_SESSION['itemname'] = $newusername; |
|
| 115 | - |
|
| 116 | - /*******************************************************************************/ |
|
| 117 | - // put the user in the user_groups he/ she should be in |
|
| 118 | - // first, check that up_perms are switched on! |
|
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | - $f = array(); |
|
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | - $f['webuser'] = $internalKey; |
|
| 125 | - $modx->getDatabase()->insert($f, $tbl_web_groups); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - // end of user_groups stuff! |
|
| 113 | + // Set the item name for logger |
|
| 114 | + $_SESSION['itemname'] = $newusername; |
|
| 115 | + |
|
| 116 | + /*******************************************************************************/ |
|
| 117 | + // put the user in the user_groups he/ she should be in |
|
| 118 | + // first, check that up_perms are switched on! |
|
| 119 | + if($use_udperms == 1) { |
|
| 120 | + if(!empty($user_groups)) { |
|
| 121 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | + $f = array(); |
|
| 123 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | + $f['webuser'] = $internalKey; |
|
| 125 | + $modx->getDatabase()->insert($f, $tbl_web_groups); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + // end of user_groups stuff! |
|
| 130 | 130 | |
| 131 | 131 | // invoke OnWebSaveUser event |
| 132 | 132 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -144,26 +144,26 @@ discard block |
||
| 144 | 144 | "id" => $internalKey |
| 145 | 145 | )); |
| 146 | 146 | |
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 147 | + if($passwordnotifymethod == 'e') { |
|
| 148 | 148 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
| 149 | - if($input['stay'] != '') { |
|
| 150 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | - header($header); |
|
| 153 | - } else { |
|
| 154 | - $header = "Location: index.php?a=99&r=2"; |
|
| 155 | - header($header); |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - } else { |
|
| 162 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - include_once "header.inc.php"; |
|
| 166 | - ?> |
|
| 149 | + if($input['stay'] != '') { |
|
| 150 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | + header($header); |
|
| 153 | + } else { |
|
| 154 | + $header = "Location: index.php?a=99&r=2"; |
|
| 155 | + header($header); |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + } else { |
|
| 162 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + include_once "header.inc.php"; |
|
| 166 | + ?> |
|
| 167 | 167 | |
| 168 | 168 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 169 | 169 | |
@@ -185,86 +185,86 @@ discard block |
||
| 185 | 185 | </div> |
| 186 | 186 | <?php |
| 187 | 187 | |
| 188 | - include_once "footer.inc.php"; |
|
| 189 | - } |
|
| 190 | - break; |
|
| 191 | - case '88' : // edit user |
|
| 192 | - // generate a new password for this user |
|
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 196 | - webAlertAndQuit("Password is too short!", 88); |
|
| 197 | - } else { |
|
| 198 | - $newpassword = $specifiedpassword; |
|
| 199 | - } |
|
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | - webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 203 | - $newpassword = generate_password(8); |
|
| 204 | - } else { |
|
| 205 | - webAlertAndQuit("No password generation method specified!", 88); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 188 | + include_once "footer.inc.php"; |
|
| 189 | + } |
|
| 190 | + break; |
|
| 191 | + case '88' : // edit user |
|
| 192 | + // generate a new password for this user |
|
| 193 | + if($genpassword == 1) { |
|
| 194 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if(strlen($specifiedpassword) < 6) { |
|
| 196 | + webAlertAndQuit("Password is too short!", 88); |
|
| 197 | + } else { |
|
| 198 | + $newpassword = $specifiedpassword; |
|
| 199 | + } |
|
| 200 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | + webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 202 | + } elseif($passwordgenmethod == 'g') { |
|
| 203 | + $newpassword = generate_password(8); |
|
| 204 | + } else { |
|
| 205 | + webAlertAndQuit("No password generation method specified!", 88); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + if($passwordnotifymethod == 'e') { |
|
| 209 | 209 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
| 210 | - } |
|
| 211 | - |
|
| 212 | - // check if the username already exist |
|
| 213 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 215 | - if($limit > 0) { |
|
| 216 | - webAlertAndQuit("User name is already in use!", 88); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // check if the email address already exists |
|
| 220 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 223 | - if($limit > 0) { |
|
| 224 | - webAlertAndQuit("Email is already in use!", 88); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // invoke OnBeforeWUsrFormSave event |
|
| 229 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | - "mode" => "upd", |
|
| 231 | - "id" => $id |
|
| 232 | - )); |
|
| 233 | - |
|
| 234 | - // update user name and password |
|
| 235 | - $field = array(); |
|
| 236 | - $field['username'] = $esc_newusername; |
|
| 237 | - if($genpassword == 1) { |
|
| 238 | - $field['password'] = md5($newpassword); |
|
| 239 | - } |
|
| 240 | - $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | - $field = $modx->getDatabase()->escape($field); |
|
| 243 | - $modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | - |
|
| 245 | - // Save User Settings |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // check if the username already exist |
|
| 213 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 215 | + if($limit > 0) { |
|
| 216 | + webAlertAndQuit("User name is already in use!", 88); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // check if the email address already exists |
|
| 220 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 223 | + if($limit > 0) { |
|
| 224 | + webAlertAndQuit("Email is already in use!", 88); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // invoke OnBeforeWUsrFormSave event |
|
| 229 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | + "mode" => "upd", |
|
| 231 | + "id" => $id |
|
| 232 | + )); |
|
| 233 | + |
|
| 234 | + // update user name and password |
|
| 235 | + $field = array(); |
|
| 236 | + $field['username'] = $esc_newusername; |
|
| 237 | + if($genpassword == 1) { |
|
| 238 | + $field['password'] = md5($newpassword); |
|
| 239 | + } |
|
| 240 | + $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | + $field = $modx->getDatabase()->escape($field); |
|
| 243 | + $modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | + |
|
| 245 | + // Save User Settings |
|
| 246 | 246 | saveWebUserSettings($id); |
| 247 | 247 | |
| 248 | - // Set the item name for logger |
|
| 249 | - $_SESSION['itemname'] = $newusername; |
|
| 250 | - |
|
| 251 | - /*******************************************************************************/ |
|
| 252 | - // put the user in the user_groups he/ she should be in |
|
| 253 | - // first, check that up_perms are switched on! |
|
| 254 | - if($use_udperms == 1) { |
|
| 255 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | - $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | - $field = array(); |
|
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | - $field['webuser'] = $id; |
|
| 262 | - $modx->getDatabase()->insert($field, $tbl_web_groups); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - // end of user_groups stuff! |
|
| 267 | - /*******************************************************************************/ |
|
| 248 | + // Set the item name for logger |
|
| 249 | + $_SESSION['itemname'] = $newusername; |
|
| 250 | + |
|
| 251 | + /*******************************************************************************/ |
|
| 252 | + // put the user in the user_groups he/ she should be in |
|
| 253 | + // first, check that up_perms are switched on! |
|
| 254 | + if($use_udperms == 1) { |
|
| 255 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | + $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | + if(!empty($user_groups)) { |
|
| 258 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | + $field = array(); |
|
| 260 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | + $field['webuser'] = $id; |
|
| 262 | + $modx->getDatabase()->insert($field, $tbl_web_groups); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + // end of user_groups stuff! |
|
| 267 | + /*******************************************************************************/ |
|
| 268 | 268 | |
| 269 | 269 | // invoke OnWebSaveUser event |
| 270 | 270 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -293,16 +293,16 @@ discard block |
||
| 293 | 293 | "id" => $id |
| 294 | 294 | )); |
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 298 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | - } else { |
|
| 301 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | - } |
|
| 296 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if($input['stay'] != '') { |
|
| 298 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | + } else { |
|
| 301 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - include_once "header.inc.php"; |
|
| 305 | - ?> |
|
| 304 | + include_once "header.inc.php"; |
|
| 305 | + ?> |
|
| 306 | 306 | |
| 307 | 307 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 308 | 308 | |
@@ -322,18 +322,18 @@ discard block |
||
| 322 | 322 | </div> |
| 323 | 323 | <?php |
| 324 | 324 | |
| 325 | - include_once "footer.inc.php"; |
|
| 326 | - } else { |
|
| 327 | - if($input['stay'] != '') { |
|
| 328 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | - header($header); |
|
| 331 | - } else { |
|
| 332 | - $header = "Location: index.php?a=99&r=2"; |
|
| 333 | - header($header); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - break; |
|
| 337 | - default : |
|
| 338 | - webAlertAndQuit("No operation set in request.", 88); |
|
| 325 | + include_once "footer.inc.php"; |
|
| 326 | + } else { |
|
| 327 | + if($input['stay'] != '') { |
|
| 328 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | + header($header); |
|
| 331 | + } else { |
|
| 332 | + $header = "Location: index.php?a=99&r=2"; |
|
| 333 | + header($header); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | + default : |
|
| 338 | + webAlertAndQuit("No operation set in request.", 88); |
|
| 339 | 339 | } |
@@ -60,110 +60,110 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!", 88); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 75 | - if($limit > 0) { |
|
| 76 | - webAlertAndQuit("Email is already in use!", 88); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // generate a new password for this user |
|
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 83 | - webAlertAndQuit("Password is too short!", 88); |
|
| 84 | - } else { |
|
| 85 | - $newpassword = $specifiedpassword; |
|
| 86 | - } |
|
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | - webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 90 | - $newpassword = generate_password(8); |
|
| 91 | - } else { |
|
| 92 | - webAlertAndQuit("No password generation method specified!", 88); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // invoke OnBeforeWUsrFormSave event |
|
| 96 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | - "mode" => "new", |
|
| 98 | - )); |
|
| 99 | - |
|
| 100 | - // create the user account |
|
| 101 | - $field = array(); |
|
| 102 | - $field['username'] = $esc_newusername; |
|
| 103 | - $field['password'] = md5($newpassword); |
|
| 104 | - $internalKey = $modx->getDatabase()->insert($field, $tbl_web_users); |
|
| 105 | - |
|
| 106 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | - $field = $modx->getDatabase()->escape($field); |
|
| 108 | - $modx->getDatabase()->insert($field, $tbl_web_user_attributes); |
|
| 109 | - |
|
| 110 | - // Save User Settings |
|
| 111 | - saveWebUserSettings($internalKey); |
|
| 112 | - |
|
| 113 | - // Set the item name for logger |
|
| 114 | - $_SESSION['itemname'] = $newusername; |
|
| 115 | - |
|
| 116 | - /*******************************************************************************/ |
|
| 117 | - // put the user in the user_groups he/ she should be in |
|
| 118 | - // first, check that up_perms are switched on! |
|
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | - $f = array(); |
|
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | - $f['webuser'] = $internalKey; |
|
| 125 | - $modx->getDatabase()->insert($f, $tbl_web_groups); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - // end of user_groups stuff! |
|
| 130 | - |
|
| 131 | - // invoke OnWebSaveUser event |
|
| 132 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 133 | - "mode" => "new", |
|
| 134 | - "userid" => $internalKey, |
|
| 135 | - "username" => $newusername, |
|
| 136 | - "userpassword" => $newpassword, |
|
| 137 | - "useremail" => $email, |
|
| 138 | - "userfullname" => $fullname |
|
| 139 | - )); |
|
| 140 | - |
|
| 141 | - // invoke OnWUsrFormSave event |
|
| 142 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 143 | - "mode" => "new", |
|
| 144 | - "id" => $internalKey |
|
| 145 | - )); |
|
| 146 | - |
|
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 148 | - sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
|
| 149 | - if($input['stay'] != '') { |
|
| 150 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | - header($header); |
|
| 153 | - } else { |
|
| 154 | - $header = "Location: index.php?a=99&r=2"; |
|
| 155 | - header($header); |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - } else { |
|
| 162 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - include_once "header.inc.php"; |
|
| 166 | - ?> |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!", 88); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 73 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 74 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 75 | + if($limit > 0) { |
|
| 76 | + webAlertAndQuit("Email is already in use!", 88); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // generate a new password for this user |
|
| 81 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if(strlen($specifiedpassword) < 6) { |
|
| 83 | + webAlertAndQuit("Password is too short!", 88); |
|
| 84 | + } else { |
|
| 85 | + $newpassword = $specifiedpassword; |
|
| 86 | + } |
|
| 87 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | + webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 89 | + } elseif($passwordgenmethod == 'g') { |
|
| 90 | + $newpassword = generate_password(8); |
|
| 91 | + } else { |
|
| 92 | + webAlertAndQuit("No password generation method specified!", 88); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // invoke OnBeforeWUsrFormSave event |
|
| 96 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 97 | + "mode" => "new", |
|
| 98 | + )); |
|
| 99 | + |
|
| 100 | + // create the user account |
|
| 101 | + $field = array(); |
|
| 102 | + $field['username'] = $esc_newusername; |
|
| 103 | + $field['password'] = md5($newpassword); |
|
| 104 | + $internalKey = $modx->getDatabase()->insert($field, $tbl_web_users); |
|
| 105 | + |
|
| 106 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 107 | + $field = $modx->getDatabase()->escape($field); |
|
| 108 | + $modx->getDatabase()->insert($field, $tbl_web_user_attributes); |
|
| 109 | + |
|
| 110 | + // Save User Settings |
|
| 111 | + saveWebUserSettings($internalKey); |
|
| 112 | + |
|
| 113 | + // Set the item name for logger |
|
| 114 | + $_SESSION['itemname'] = $newusername; |
|
| 115 | + |
|
| 116 | + /*******************************************************************************/ |
|
| 117 | + // put the user in the user_groups he/ she should be in |
|
| 118 | + // first, check that up_perms are switched on! |
|
| 119 | + if($use_udperms == 1) { |
|
| 120 | + if(!empty($user_groups)) { |
|
| 121 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | + $f = array(); |
|
| 123 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 124 | + $f['webuser'] = $internalKey; |
|
| 125 | + $modx->getDatabase()->insert($f, $tbl_web_groups); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + // end of user_groups stuff! |
|
| 130 | + |
|
| 131 | + // invoke OnWebSaveUser event |
|
| 132 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 133 | + "mode" => "new", |
|
| 134 | + "userid" => $internalKey, |
|
| 135 | + "username" => $newusername, |
|
| 136 | + "userpassword" => $newpassword, |
|
| 137 | + "useremail" => $email, |
|
| 138 | + "userfullname" => $fullname |
|
| 139 | + )); |
|
| 140 | + |
|
| 141 | + // invoke OnWUsrFormSave event |
|
| 142 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 143 | + "mode" => "new", |
|
| 144 | + "id" => $internalKey |
|
| 145 | + )); |
|
| 146 | + |
|
| 147 | + if($passwordnotifymethod == 'e') { |
|
| 148 | + sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
|
| 149 | + if($input['stay'] != '') { |
|
| 150 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 152 | + header($header); |
|
| 153 | + } else { |
|
| 154 | + $header = "Location: index.php?a=99&r=2"; |
|
| 155 | + header($header); |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + } else { |
|
| 162 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + include_once "header.inc.php"; |
|
| 166 | + ?> |
|
| 167 | 167 | |
| 168 | 168 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 169 | 169 | |
@@ -185,124 +185,124 @@ discard block |
||
| 185 | 185 | </div> |
| 186 | 186 | <?php |
| 187 | 187 | |
| 188 | - include_once "footer.inc.php"; |
|
| 189 | - } |
|
| 190 | - break; |
|
| 191 | - case '88' : // edit user |
|
| 192 | - // generate a new password for this user |
|
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 196 | - webAlertAndQuit("Password is too short!", 88); |
|
| 197 | - } else { |
|
| 198 | - $newpassword = $specifiedpassword; |
|
| 199 | - } |
|
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | - webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 203 | - $newpassword = generate_password(8); |
|
| 204 | - } else { |
|
| 205 | - webAlertAndQuit("No password generation method specified!", 88); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 209 | - sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // check if the username already exist |
|
| 213 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 215 | - if($limit > 0) { |
|
| 216 | - webAlertAndQuit("User name is already in use!", 88); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // check if the email address already exists |
|
| 220 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | - $limit = $modx->getDatabase()->getValue($rs); |
|
| 223 | - if($limit > 0) { |
|
| 224 | - webAlertAndQuit("Email is already in use!", 88); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // invoke OnBeforeWUsrFormSave event |
|
| 229 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | - "mode" => "upd", |
|
| 231 | - "id" => $id |
|
| 232 | - )); |
|
| 233 | - |
|
| 234 | - // update user name and password |
|
| 235 | - $field = array(); |
|
| 236 | - $field['username'] = $esc_newusername; |
|
| 237 | - if($genpassword == 1) { |
|
| 238 | - $field['password'] = md5($newpassword); |
|
| 239 | - } |
|
| 240 | - $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | - $field = $modx->getDatabase()->escape($field); |
|
| 243 | - $modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | - |
|
| 245 | - // Save User Settings |
|
| 246 | - saveWebUserSettings($id); |
|
| 247 | - |
|
| 248 | - // Set the item name for logger |
|
| 249 | - $_SESSION['itemname'] = $newusername; |
|
| 250 | - |
|
| 251 | - /*******************************************************************************/ |
|
| 252 | - // put the user in the user_groups he/ she should be in |
|
| 253 | - // first, check that up_perms are switched on! |
|
| 254 | - if($use_udperms == 1) { |
|
| 255 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | - $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | - $field = array(); |
|
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | - $field['webuser'] = $id; |
|
| 262 | - $modx->getDatabase()->insert($field, $tbl_web_groups); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - // end of user_groups stuff! |
|
| 267 | - /*******************************************************************************/ |
|
| 268 | - |
|
| 269 | - // invoke OnWebSaveUser event |
|
| 270 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
| 271 | - "mode" => "upd", |
|
| 272 | - "userid" => $id, |
|
| 273 | - "username" => $newusername, |
|
| 274 | - "userpassword" => $newpassword, |
|
| 275 | - "useremail" => $email, |
|
| 276 | - "userfullname" => $fullname, |
|
| 277 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 278 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 279 | - )); |
|
| 280 | - |
|
| 281 | - // invoke OnWebChangePassword event |
|
| 282 | - if($genpassword == 1) { |
|
| 283 | - $modx->invokeEvent("OnWebChangePassword", array( |
|
| 188 | + include_once "footer.inc.php"; |
|
| 189 | + } |
|
| 190 | + break; |
|
| 191 | + case '88' : // edit user |
|
| 192 | + // generate a new password for this user |
|
| 193 | + if($genpassword == 1) { |
|
| 194 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if(strlen($specifiedpassword) < 6) { |
|
| 196 | + webAlertAndQuit("Password is too short!", 88); |
|
| 197 | + } else { |
|
| 198 | + $newpassword = $specifiedpassword; |
|
| 199 | + } |
|
| 200 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | + webAlertAndQuit("You didn't specify a password for this user!", 88); |
|
| 202 | + } elseif($passwordgenmethod == 'g') { |
|
| 203 | + $newpassword = generate_password(8); |
|
| 204 | + } else { |
|
| 205 | + webAlertAndQuit("No password generation method specified!", 88); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + if($passwordnotifymethod == 'e') { |
|
| 209 | + sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // check if the username already exist |
|
| 213 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 214 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 215 | + if($limit > 0) { |
|
| 216 | + webAlertAndQuit("User name is already in use!", 88); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // check if the email address already exists |
|
| 220 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
| 221 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 222 | + $limit = $modx->getDatabase()->getValue($rs); |
|
| 223 | + if($limit > 0) { |
|
| 224 | + webAlertAndQuit("Email is already in use!", 88); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // invoke OnBeforeWUsrFormSave event |
|
| 229 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 230 | + "mode" => "upd", |
|
| 231 | + "id" => $id |
|
| 232 | + )); |
|
| 233 | + |
|
| 234 | + // update user name and password |
|
| 235 | + $field = array(); |
|
| 236 | + $field['username'] = $esc_newusername; |
|
| 237 | + if($genpassword == 1) { |
|
| 238 | + $field['password'] = md5($newpassword); |
|
| 239 | + } |
|
| 240 | + $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 241 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 242 | + $field = $modx->getDatabase()->escape($field); |
|
| 243 | + $modx->getDatabase()->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 244 | + |
|
| 245 | + // Save User Settings |
|
| 246 | + saveWebUserSettings($id); |
|
| 247 | + |
|
| 248 | + // Set the item name for logger |
|
| 249 | + $_SESSION['itemname'] = $newusername; |
|
| 250 | + |
|
| 251 | + /*******************************************************************************/ |
|
| 252 | + // put the user in the user_groups he/ she should be in |
|
| 253 | + // first, check that up_perms are switched on! |
|
| 254 | + if($use_udperms == 1) { |
|
| 255 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 256 | + $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 257 | + if(!empty($user_groups)) { |
|
| 258 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | + $field = array(); |
|
| 260 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 261 | + $field['webuser'] = $id; |
|
| 262 | + $modx->getDatabase()->insert($field, $tbl_web_groups); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + // end of user_groups stuff! |
|
| 267 | + /*******************************************************************************/ |
|
| 268 | + |
|
| 269 | + // invoke OnWebSaveUser event |
|
| 270 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
| 271 | + "mode" => "upd", |
|
| 284 | 272 | "userid" => $id, |
| 285 | 273 | "username" => $newusername, |
| 286 | - "userpassword" => $newpassword |
|
| 274 | + "userpassword" => $newpassword, |
|
| 275 | + "useremail" => $email, |
|
| 276 | + "userfullname" => $fullname, |
|
| 277 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 278 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 287 | 279 | )); |
| 288 | - } |
|
| 289 | 280 | |
| 290 | - // invoke OnWUsrFormSave event |
|
| 291 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 292 | - "mode" => "upd", |
|
| 293 | - "id" => $id |
|
| 294 | - )); |
|
| 281 | + // invoke OnWebChangePassword event |
|
| 282 | + if($genpassword == 1) { |
|
| 283 | + $modx->invokeEvent("OnWebChangePassword", array( |
|
| 284 | + "userid" => $id, |
|
| 285 | + "username" => $newusername, |
|
| 286 | + "userpassword" => $newpassword |
|
| 287 | + )); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + // invoke OnWUsrFormSave event |
|
| 291 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
| 292 | + "mode" => "upd", |
|
| 293 | + "id" => $id |
|
| 294 | + )); |
|
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 298 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | - } else { |
|
| 301 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | - } |
|
| 296 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if($input['stay'] != '') { |
|
| 298 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 300 | + } else { |
|
| 301 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - include_once "header.inc.php"; |
|
| 305 | - ?> |
|
| 304 | + include_once "header.inc.php"; |
|
| 305 | + ?> |
|
| 306 | 306 | |
| 307 | 307 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 308 | 308 | |
@@ -322,18 +322,18 @@ discard block |
||
| 322 | 322 | </div> |
| 323 | 323 | <?php |
| 324 | 324 | |
| 325 | - include_once "footer.inc.php"; |
|
| 326 | - } else { |
|
| 327 | - if($input['stay'] != '') { |
|
| 328 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | - header($header); |
|
| 331 | - } else { |
|
| 332 | - $header = "Location: index.php?a=99&r=2"; |
|
| 333 | - header($header); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - break; |
|
| 337 | - default : |
|
| 338 | - webAlertAndQuit("No operation set in request.", 88); |
|
| 325 | + include_once "footer.inc.php"; |
|
| 326 | + } else { |
|
| 327 | + if($input['stay'] != '') { |
|
| 328 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 330 | + header($header); |
|
| 331 | + } else { |
|
| 332 | + $header = "Location: index.php?a=99&r=2"; |
|
| 333 | + header($header); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | + default : |
|
| 338 | + webAlertAndQuit("No operation set in request.", 88); |
|
| 339 | 339 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('save_web_user')) { |
|
| 5 | +if (!$modx->hasPermission('save_web_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | $tbl_web_groups = $modx->getFullTableName('web_groups'); |
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | -foreach($input as $k => $v) { |
|
| 15 | - if($k !== 'comment') { |
|
| 14 | +foreach ($input as $k => $v) { |
|
| 15 | + if ($k !== 'comment') { |
|
| 16 | 16 | $v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES); |
| 17 | 17 | } |
| 18 | 18 | $input[$k] = $v; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -$id = (int)$input['id']; |
|
| 21 | +$id = (int) $input['id']; |
|
| 22 | 22 | $oldusername = $input['oldusername']; |
| 23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
| 24 | 24 | $esc_newusername = $modx->getDatabase()->escape($newusername); |
@@ -50,21 +50,21 @@ discard block |
||
| 50 | 50 | $user_groups = $input['user_groups']; |
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 53 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 54 | 54 | webAlertAndQuit("Password typed is mismatched", 88); |
| 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!", 88); |
| 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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
| 66 | 66 | $limit = $modx->getDatabase()->getValue($rs); |
| 67 | - if($limit > 0) { |
|
| 67 | + if ($limit > 0) { |
|
| 68 | 68 | webAlertAndQuit("User name is already in use!", 88); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,21 +72,21 @@ discard block |
||
| 72 | 72 | if ($modx->config['allow_multiple_emails'] != 1) { |
| 73 | 73 | $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
| 74 | 74 | $limit = $modx->getDatabase()->getValue($rs); |
| 75 | - if($limit > 0) { |
|
| 75 | + if ($limit > 0) { |
|
| 76 | 76 | webAlertAndQuit("Email is already in use!", 88); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // generate a new password for this user |
| 81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 82 | + if (strlen($specifiedpassword) < 6) { |
|
| 83 | 83 | webAlertAndQuit("Password is too short!", 88); |
| 84 | 84 | } else { |
| 85 | 85 | $newpassword = $specifiedpassword; |
| 86 | 86 | } |
| 87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 87 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 88 | 88 | webAlertAndQuit("You didn't specify a password for this user!", 88); |
| 89 | - } elseif($passwordgenmethod == 'g') { |
|
| 89 | + } elseif ($passwordgenmethod == 'g') { |
|
| 90 | 90 | $newpassword = generate_password(8); |
| 91 | 91 | } else { |
| 92 | 92 | webAlertAndQuit("No password generation method specified!", 88); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | /*******************************************************************************/ |
| 117 | 117 | // put the user in the user_groups he/ she should be in |
| 118 | 118 | // first, check that up_perms are switched on! |
| 119 | - if($use_udperms == 1) { |
|
| 120 | - if(!empty($user_groups)) { |
|
| 121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 119 | + if ($use_udperms == 1) { |
|
| 120 | + if (!empty($user_groups)) { |
|
| 121 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 122 | 122 | $f = array(); |
| 123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 123 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
| 124 | 124 | $f['webuser'] = $internalKey; |
| 125 | 125 | $modx->getDatabase()->insert($f, $tbl_web_groups); |
| 126 | 126 | } |
@@ -144,20 +144,20 @@ discard block |
||
| 144 | 144 | "id" => $internalKey |
| 145 | 145 | )); |
| 146 | 146 | |
| 147 | - if($passwordnotifymethod == 'e') { |
|
| 147 | + if ($passwordnotifymethod == 'e') { |
|
| 148 | 148 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
| 149 | - if($input['stay'] != '') { |
|
| 149 | + if ($input['stay'] != '') { |
|
| 150 | 150 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 151 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 152 | 152 | header($header); |
| 153 | 153 | } else { |
| 154 | 154 | $header = "Location: index.php?a=99&r=2"; |
| 155 | 155 | header($header); |
| 156 | 156 | } |
| 157 | 157 | } else { |
| 158 | - if($input['stay'] != '') { |
|
| 158 | + if ($input['stay'] != '') { |
|
| 159 | 159 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
| 160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 160 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 161 | 161 | } else { |
| 162 | 162 | $stayUrl = "index.php?a=99&r=2"; |
| 163 | 163 | } |
@@ -190,29 +190,29 @@ discard block |
||
| 190 | 190 | break; |
| 191 | 191 | case '88' : // edit user |
| 192 | 192 | // generate a new password for this user |
| 193 | - if($genpassword == 1) { |
|
| 194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | - if(strlen($specifiedpassword) < 6) { |
|
| 193 | + if ($genpassword == 1) { |
|
| 194 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 195 | + if (strlen($specifiedpassword) < 6) { |
|
| 196 | 196 | webAlertAndQuit("Password is too short!", 88); |
| 197 | 197 | } else { |
| 198 | 198 | $newpassword = $specifiedpassword; |
| 199 | 199 | } |
| 200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 200 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 201 | 201 | webAlertAndQuit("You didn't specify a password for this user!", 88); |
| 202 | - } elseif($passwordgenmethod == 'g') { |
|
| 202 | + } elseif ($passwordgenmethod == 'g') { |
|
| 203 | 203 | $newpassword = generate_password(8); |
| 204 | 204 | } else { |
| 205 | 205 | webAlertAndQuit("No password generation method specified!", 88); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if($passwordnotifymethod == 'e') { |
|
| 208 | + if ($passwordnotifymethod == 'e') { |
|
| 209 | 209 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // check if the username already exist |
| 213 | 213 | $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
| 214 | 214 | $limit = $modx->getDatabase()->getValue($rs); |
| 215 | - if($limit > 0) { |
|
| 215 | + if ($limit > 0) { |
|
| 216 | 216 | webAlertAndQuit("User name is already in use!", 88); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | if ($modx->config['allow_multiple_emails'] != 1) { |
| 221 | 221 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
| 222 | 222 | $limit = $modx->getDatabase()->getValue($rs); |
| 223 | - if($limit > 0) { |
|
| 223 | + if ($limit > 0) { |
|
| 224 | 224 | webAlertAndQuit("Email is already in use!", 88); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // update user name and password |
| 235 | 235 | $field = array(); |
| 236 | 236 | $field['username'] = $esc_newusername; |
| 237 | - if($genpassword == 1) { |
|
| 237 | + if ($genpassword == 1) { |
|
| 238 | 238 | $field['password'] = md5($newpassword); |
| 239 | 239 | } |
| 240 | 240 | $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | /*******************************************************************************/ |
| 252 | 252 | // put the user in the user_groups he/ she should be in |
| 253 | 253 | // first, check that up_perms are switched on! |
| 254 | - if($use_udperms == 1) { |
|
| 254 | + if ($use_udperms == 1) { |
|
| 255 | 255 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 256 | 256 | $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'"); |
| 257 | - if(!empty($user_groups)) { |
|
| 258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 257 | + if (!empty($user_groups)) { |
|
| 258 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 259 | 259 | $field = array(); |
| 260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 260 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
| 261 | 261 | $field['webuser'] = $id; |
| 262 | 262 | $modx->getDatabase()->insert($field, $tbl_web_groups); |
| 263 | 263 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | )); |
| 280 | 280 | |
| 281 | 281 | // invoke OnWebChangePassword event |
| 282 | - if($genpassword == 1) { |
|
| 282 | + if ($genpassword == 1) { |
|
| 283 | 283 | $modx->invokeEvent("OnWebChangePassword", array( |
| 284 | 284 | "userid" => $id, |
| 285 | 285 | "username" => $newusername, |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | "id" => $id |
| 294 | 294 | )); |
| 295 | 295 | |
| 296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | - if($input['stay'] != '') { |
|
| 296 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 297 | + if ($input['stay'] != '') { |
|
| 298 | 298 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 299 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 300 | 300 | } else { |
| 301 | 301 | $stayUrl = "index.php?a=99&r=2"; |
| 302 | 302 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | include_once "footer.inc.php"; |
| 326 | 326 | } else { |
| 327 | - if($input['stay'] != '') { |
|
| 327 | + if ($input['stay'] != '') { |
|
| 328 | 328 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
| 329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 329 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 330 | 330 | header($header); |
| 331 | 331 | } else { |
| 332 | 332 | $header = "Location: index.php?a=99&r=2"; |
@@ -1,22 +1,22 @@ 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('delete_template')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id == 0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // delete the template, but first check it doesn't have any documents using it |
| 15 | 15 | $rs = $modx->getDatabase()->select('id, pagetitle,introtext', $modx->getFullTableName('site_content'), "template='{$id}' AND deleted=0"); |
| 16 | 16 | $limit = $modx->getDatabase()->getRecordCount($rs); |
| 17 | 17 | if($limit > 0) { |
| 18 | - include "header.inc.php"; |
|
| 19 | - ?> |
|
| 18 | + include "header.inc.php"; |
|
| 19 | + ?> |
|
| 20 | 20 | |
| 21 | 21 | <h1><?php echo $_lang['manage_templates']; ?></h1> |
| 22 | 22 | |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | <p>Documents using this template:</p> |
| 29 | 29 | <ul> |
| 30 | 30 | <?php |
| 31 | - while($row = $modx->getDatabase()->getRow($rs)) { |
|
| 32 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
| 33 | - } |
|
| 34 | - ?> |
|
| 31 | + while($row = $modx->getDatabase()->getRow($rs)) { |
|
| 32 | + echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
| 33 | + } |
|
| 34 | + ?> |
|
| 35 | 35 | </ul> |
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <?php |
| 39 | - include_once "footer.inc.php"; |
|
| 40 | - exit; |
|
| 39 | + include_once "footer.inc.php"; |
|
| 40 | + exit; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if($id == $default_template) { |
| 44 | - $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
|
| 44 | + $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Set the item name for logger |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // invoke OnBeforeTempFormDelete event |
| 52 | 52 | $modx->invokeEvent("OnBeforeTempFormDelete", array( |
| 53 | - "id" => $id |
|
| 54 | - )); |
|
| 53 | + "id" => $id |
|
| 54 | + )); |
|
| 55 | 55 | |
| 56 | 56 | // delete the document. |
| 57 | 57 | $modx->getDatabase()->delete($modx->getFullTableName('site_templates'), "id='{$id}'"); |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // invoke OnTempFormDelete event |
| 62 | 62 | $modx->invokeEvent("OnTempFormDelete", array( |
| 63 | - "id" => $id |
|
| 64 | - )); |
|
| 63 | + "id" => $id |
|
| 64 | + )); |
|
| 65 | 65 | |
| 66 | 66 | // empty cache |
| 67 | 67 | $modx->clearCache('full'); |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('delete_template')) { |
|
| 5 | +if (!$modx->hasPermission('delete_template')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 10 | -if($id == 0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // delete the template, but first check it doesn't have any documents using it |
| 15 | 15 | $rs = $modx->getDatabase()->select('id, pagetitle,introtext', $modx->getFullTableName('site_content'), "template='{$id}' AND deleted=0"); |
| 16 | 16 | $limit = $modx->getDatabase()->getRecordCount($rs); |
| 17 | -if($limit > 0) { |
|
| 17 | +if ($limit > 0) { |
|
| 18 | 18 | include "header.inc.php"; |
| 19 | 19 | ?> |
| 20 | 20 | |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | <p>Documents using this template:</p> |
| 29 | 29 | <ul> |
| 30 | 30 | <?php |
| 31 | - while($row = $modx->getDatabase()->getRow($rs)) { |
|
| 32 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
| 31 | + while ($row = $modx->getDatabase()->getRow($rs)) { |
|
| 32 | + echo '<li><span style="width: 200px"><a href="index.php?id='.$row['id'].'&a=27">'.$row['pagetitle'].'</a></span>'.($row['introtext'] != '' ? ' - '.$row['introtext'] : '').'</li>'; |
|
| 33 | 33 | } |
| 34 | 34 | ?> |
| 35 | 35 | </ul> |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | exit; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -if($id == $default_template) { |
|
| 43 | +if ($id == $default_template) { |
|
| 44 | 44 | $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -66,111 +66,111 @@ |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | switch ($_POST['mode']) { |
| 69 | - case '23': // Save new snippet |
|
| 70 | - |
|
| 71 | - // invoke OnBeforeSnipFormSave event |
|
| 72 | - $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
| 73 | - "mode" => "new", |
|
| 74 | - "id" => $id |
|
| 75 | - )); |
|
| 76 | - |
|
| 77 | - // disallow duplicate names for new snippets |
|
| 78 | - $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'"); |
|
| 79 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 80 | - if ($count > 0) { |
|
| 81 | - $modx->getManagerApi()->saveFormValues(23); |
|
| 82 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23"); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - //do stuff to save the new doc |
|
| 86 | - $newid = $modx->getDatabase()->insert(array( |
|
| 87 | - 'name' => $name, |
|
| 88 | - 'description' => $description, |
|
| 89 | - 'snippet' => $snippet, |
|
| 90 | - 'moduleguid' => $moduleguid, |
|
| 91 | - 'locked' => $locked, |
|
| 92 | - 'properties' => $properties, |
|
| 93 | - 'category' => $categoryid, |
|
| 94 | - 'disabled' => $disabled, |
|
| 95 | - 'createdon' => $currentdate, |
|
| 96 | - 'editedon' => $currentdate |
|
| 97 | - ), $modx->getFullTableName('site_snippets')); |
|
| 98 | - |
|
| 99 | - // invoke OnSnipFormSave event |
|
| 100 | - $modx->invokeEvent("OnSnipFormSave", 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') ? "22&id=$newid" : "23"; |
|
| 114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 115 | - header($header); |
|
| 116 | - } else { |
|
| 117 | - $header = "Location: index.php?a=76&r=2"; |
|
| 118 | - header($header); |
|
| 119 | - } |
|
| 120 | - break; |
|
| 121 | - case '22': // Save existing snippet |
|
| 122 | - // invoke OnBeforeSnipFormSave event |
|
| 123 | - $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
| 124 | - "mode" => "upd", |
|
| 125 | - "id" => $id |
|
| 126 | - )); |
|
| 127 | - |
|
| 128 | - // disallow duplicate names for snippets |
|
| 129 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | - if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 131 | - $modx->getManagerApi()->saveFormValues(22); |
|
| 132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}"); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - //do stuff to save the edited doc |
|
| 136 | - $modx->getDatabase()->update(array( |
|
| 137 | - 'name' => $name, |
|
| 138 | - 'description' => $description, |
|
| 139 | - 'snippet' => $snippet, |
|
| 140 | - 'moduleguid' => $moduleguid, |
|
| 141 | - 'locked' => $locked, |
|
| 142 | - 'properties' => $properties, |
|
| 143 | - 'category' => $categoryid, |
|
| 144 | - 'disabled' => $disabled, |
|
| 145 | - 'editedon' => $currentdate |
|
| 146 | - ), $modx->getFullTableName('site_snippets'), "id='{$id}'"); |
|
| 147 | - |
|
| 148 | - // invoke OnSnipFormSave event |
|
| 149 | - $modx->invokeEvent("OnSnipFormSave", array( |
|
| 150 | - "mode" => "upd", |
|
| 151 | - "id" => $id |
|
| 152 | - )); |
|
| 153 | - |
|
| 154 | - // Set the item name for logger |
|
| 155 | - $_SESSION['itemname'] = $name; |
|
| 156 | - |
|
| 157 | - // empty cache |
|
| 158 | - $modx->clearCache('full'); |
|
| 159 | - |
|
| 160 | - if ($_POST['runsnippet']) { |
|
| 161 | - run_snippet($snippet); |
|
| 162 | - } |
|
| 163 | - // finished emptying cache - redirect |
|
| 164 | - if ($_POST['stay'] != '') { |
|
| 165 | - $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; |
|
| 166 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 167 | - header($header); |
|
| 168 | - } else { |
|
| 169 | - $modx->unlockElement(4, $id); |
|
| 170 | - $header = "Location: index.php?a=76&r=2"; |
|
| 171 | - header($header); |
|
| 172 | - } |
|
| 173 | - break; |
|
| 174 | - default: |
|
| 175 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 69 | + case '23': // Save new snippet |
|
| 70 | + |
|
| 71 | + // invoke OnBeforeSnipFormSave event |
|
| 72 | + $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
| 73 | + "mode" => "new", |
|
| 74 | + "id" => $id |
|
| 75 | + )); |
|
| 76 | + |
|
| 77 | + // disallow duplicate names for new snippets |
|
| 78 | + $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'"); |
|
| 79 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 80 | + if ($count > 0) { |
|
| 81 | + $modx->getManagerApi()->saveFormValues(23); |
|
| 82 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23"); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + //do stuff to save the new doc |
|
| 86 | + $newid = $modx->getDatabase()->insert(array( |
|
| 87 | + 'name' => $name, |
|
| 88 | + 'description' => $description, |
|
| 89 | + 'snippet' => $snippet, |
|
| 90 | + 'moduleguid' => $moduleguid, |
|
| 91 | + 'locked' => $locked, |
|
| 92 | + 'properties' => $properties, |
|
| 93 | + 'category' => $categoryid, |
|
| 94 | + 'disabled' => $disabled, |
|
| 95 | + 'createdon' => $currentdate, |
|
| 96 | + 'editedon' => $currentdate |
|
| 97 | + ), $modx->getFullTableName('site_snippets')); |
|
| 98 | + |
|
| 99 | + // invoke OnSnipFormSave event |
|
| 100 | + $modx->invokeEvent("OnSnipFormSave", 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') ? "22&id=$newid" : "23"; |
|
| 114 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 115 | + header($header); |
|
| 116 | + } else { |
|
| 117 | + $header = "Location: index.php?a=76&r=2"; |
|
| 118 | + header($header); |
|
| 119 | + } |
|
| 120 | + break; |
|
| 121 | + case '22': // Save existing snippet |
|
| 122 | + // invoke OnBeforeSnipFormSave event |
|
| 123 | + $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
| 124 | + "mode" => "upd", |
|
| 125 | + "id" => $id |
|
| 126 | + )); |
|
| 127 | + |
|
| 128 | + // disallow duplicate names for snippets |
|
| 129 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'"); |
|
| 130 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
| 131 | + $modx->getManagerApi()->saveFormValues(22); |
|
| 132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}"); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + //do stuff to save the edited doc |
|
| 136 | + $modx->getDatabase()->update(array( |
|
| 137 | + 'name' => $name, |
|
| 138 | + 'description' => $description, |
|
| 139 | + 'snippet' => $snippet, |
|
| 140 | + 'moduleguid' => $moduleguid, |
|
| 141 | + 'locked' => $locked, |
|
| 142 | + 'properties' => $properties, |
|
| 143 | + 'category' => $categoryid, |
|
| 144 | + 'disabled' => $disabled, |
|
| 145 | + 'editedon' => $currentdate |
|
| 146 | + ), $modx->getFullTableName('site_snippets'), "id='{$id}'"); |
|
| 147 | + |
|
| 148 | + // invoke OnSnipFormSave event |
|
| 149 | + $modx->invokeEvent("OnSnipFormSave", array( |
|
| 150 | + "mode" => "upd", |
|
| 151 | + "id" => $id |
|
| 152 | + )); |
|
| 153 | + |
|
| 154 | + // Set the item name for logger |
|
| 155 | + $_SESSION['itemname'] = $name; |
|
| 156 | + |
|
| 157 | + // empty cache |
|
| 158 | + $modx->clearCache('full'); |
|
| 159 | + |
|
| 160 | + if ($_POST['runsnippet']) { |
|
| 161 | + run_snippet($snippet); |
|
| 162 | + } |
|
| 163 | + // finished emptying cache - redirect |
|
| 164 | + if ($_POST['stay'] != '') { |
|
| 165 | + $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; |
|
| 166 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 167 | + header($header); |
|
| 168 | + } else { |
|
| 169 | + $modx->unlockElement(4, $id); |
|
| 170 | + $header = "Location: index.php?a=76&r=2"; |
|
| 171 | + header($header); |
|
| 172 | + } |
|
| 173 | + break; |
|
| 174 | + default: |
|
| 175 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 176 | 176 | } |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('save_snippet')) { |
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = (int)$_POST['id']; |
|
| 9 | +$id = (int) $_POST['id']; |
|
| 10 | 10 | $snippet = trim($_POST['post']); |
| 11 | 11 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
| 12 | 12 | $description = $modx->getDatabase()->escape($_POST['description']); |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | //Kyle Jaebker - added category support |
| 35 | 35 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
| 36 | - $categoryid = (int)$_POST['categoryid']; |
|
| 36 | + $categoryid = (int) $_POST['categoryid']; |
|
| 37 | 37 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
| 38 | 38 | $categoryid = 0; |
| 39 | 39 | } else { |
| 40 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 40 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 41 | 41 | $categoryid = checkCategory($_POST['newcategory']); |
| 42 | 42 | if (!$categoryid) { |
| 43 | 43 | $categoryid = newCategory($_POST['newcategory']); |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; |
| 56 | 56 | |
| 57 | 57 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
| 58 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
| 58 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
| 59 | 59 | if ($version) { |
| 60 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 60 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
| 61 | 61 | } |
| 62 | 62 | if (isset($parsed['modx_category'])) { |
| 63 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 63 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 64 | 64 | $categoryid = getCategory($parsed['modx_category']); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | // finished emptying cache - redirect |
| 112 | 112 | if ($_POST['stay'] != '') { |
| 113 | 113 | $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23"; |
| 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=76&r=2"; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | // finished emptying cache - redirect |
| 164 | 164 | if ($_POST['stay'] != '') { |
| 165 | 165 | $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; |
| 166 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 166 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
| 167 | 167 | header($header); |
| 168 | 168 | } else { |
| 169 | 169 | $modx->unlockElement(4, $id); |