@@ -14,8 +14,11 @@ |
||
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getDatabase()->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( |
@@ -13,8 +13,11 @@ |
||
| 13 | 13 | // count duplicates |
| 14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_modules'), "id='{$id}'")); |
| 15 | 15 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getDatabase()->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( |
@@ -14,8 +14,11 @@ |
||
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('templatename', $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('templatename', $modx->getDatabase()->getFullTableName('site_templates'), "templatename 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 template |
| 21 | 24 | $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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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 | } |
@@ -33,113 +33,113 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | switch ($_POST['mode']) { |
| 36 | - case '19': |
|
| 37 | - |
|
| 38 | - // invoke OnBeforeTempFormSave event |
|
| 39 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | - "mode" => "new", |
|
| 41 | - "id" => $id |
|
| 42 | - )); |
|
| 43 | - |
|
| 44 | - // disallow duplicate names for new templates |
|
| 45 | - $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 47 | - if ($count > 0) { |
|
| 48 | - $modx->getManagerApi()->saveFormValues(19); |
|
| 49 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - //do stuff to save the new doc |
|
| 53 | - $newid = $modx->getDatabase()->insert(array( |
|
| 54 | - 'templatename' => $templatename, |
|
| 55 | - 'description' => $description, |
|
| 56 | - 'content' => $template, |
|
| 57 | - 'locked' => $locked, |
|
| 58 | - 'selectable' => $selectable, |
|
| 59 | - 'category' => $categoryid, |
|
| 60 | - 'createdon' => $currentdate, |
|
| 61 | - 'editedon' => $currentdate |
|
| 62 | - ), $modx->getDatabase()->getFullTableName('site_templates')); |
|
| 63 | - |
|
| 64 | - // invoke OnTempFormSave event |
|
| 65 | - $modx->invokeEvent("OnTempFormSave", array( |
|
| 66 | - "mode" => "new", |
|
| 67 | - "id" => $newid |
|
| 68 | - )); |
|
| 69 | - // Set new assigned Tvs |
|
| 70 | - saveTemplateAccess($newid); |
|
| 71 | - |
|
| 72 | - // Set the item name for logger |
|
| 73 | - $_SESSION['itemname'] = $templatename; |
|
| 74 | - |
|
| 75 | - // empty cache |
|
| 76 | - $modx->clearCache('full'); |
|
| 77 | - |
|
| 78 | - // finished emptying cache - redirect |
|
| 79 | - if ($_POST['stay'] != '') { |
|
| 80 | - $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
| 81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 82 | - header($header); |
|
| 83 | - } else { |
|
| 84 | - $header = "Location: index.php?a=76&r=2"; |
|
| 85 | - header($header); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - break; |
|
| 89 | - case '16': |
|
| 90 | - |
|
| 91 | - // invoke OnBeforeTempFormSave event |
|
| 92 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 93 | - "mode" => "upd", |
|
| 94 | - "id" => $id |
|
| 95 | - )); |
|
| 96 | - |
|
| 97 | - // disallow duplicate names for templates |
|
| 98 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | - $count = $modx->getDatabase()->getValue($rs); |
|
| 100 | - if ($count > 0) { |
|
| 101 | - $modx->getManagerApi()->saveFormValues(16); |
|
| 102 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - //do stuff to save the edited doc |
|
| 106 | - $modx->getDatabase()->update(array( |
|
| 107 | - 'templatename' => $templatename, |
|
| 108 | - 'description' => $description, |
|
| 109 | - 'content' => $template, |
|
| 110 | - 'locked' => $locked, |
|
| 111 | - 'selectable' => $selectable, |
|
| 112 | - 'category' => $categoryid, |
|
| 113 | - 'editedon' => $currentdate |
|
| 114 | - ), $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'"); |
|
| 115 | - // Set new assigned Tvs |
|
| 116 | - saveTemplateAccess($id); |
|
| 117 | - |
|
| 118 | - // invoke OnTempFormSave event |
|
| 119 | - $modx->invokeEvent("OnTempFormSave", array( |
|
| 120 | - "mode" => "upd", |
|
| 121 | - "id" => $id |
|
| 122 | - )); |
|
| 123 | - |
|
| 124 | - // Set the item name for logger |
|
| 125 | - $_SESSION['itemname'] = $templatename; |
|
| 126 | - |
|
| 127 | - // first empty the cache |
|
| 128 | - $modx->clearCache('full'); |
|
| 129 | - |
|
| 130 | - // finished emptying cache - redirect |
|
| 131 | - if ($_POST['stay'] != '') { |
|
| 132 | - $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
| 133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 134 | - header($header); |
|
| 135 | - } else { |
|
| 136 | - $modx->unlockElement(1, $id); |
|
| 137 | - $header = "Location: index.php?a=76&r=2"; |
|
| 138 | - header($header); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - break; |
|
| 143 | - default: |
|
| 144 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 36 | + case '19': |
|
| 37 | + |
|
| 38 | + // invoke OnBeforeTempFormSave event |
|
| 39 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 40 | + "mode" => "new", |
|
| 41 | + "id" => $id |
|
| 42 | + )); |
|
| 43 | + |
|
| 44 | + // disallow duplicate names for new templates |
|
| 45 | + $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
| 46 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 47 | + if ($count > 0) { |
|
| 48 | + $modx->getManagerApi()->saveFormValues(19); |
|
| 49 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + //do stuff to save the new doc |
|
| 53 | + $newid = $modx->getDatabase()->insert(array( |
|
| 54 | + 'templatename' => $templatename, |
|
| 55 | + 'description' => $description, |
|
| 56 | + 'content' => $template, |
|
| 57 | + 'locked' => $locked, |
|
| 58 | + 'selectable' => $selectable, |
|
| 59 | + 'category' => $categoryid, |
|
| 60 | + 'createdon' => $currentdate, |
|
| 61 | + 'editedon' => $currentdate |
|
| 62 | + ), $modx->getDatabase()->getFullTableName('site_templates')); |
|
| 63 | + |
|
| 64 | + // invoke OnTempFormSave event |
|
| 65 | + $modx->invokeEvent("OnTempFormSave", array( |
|
| 66 | + "mode" => "new", |
|
| 67 | + "id" => $newid |
|
| 68 | + )); |
|
| 69 | + // Set new assigned Tvs |
|
| 70 | + saveTemplateAccess($newid); |
|
| 71 | + |
|
| 72 | + // Set the item name for logger |
|
| 73 | + $_SESSION['itemname'] = $templatename; |
|
| 74 | + |
|
| 75 | + // empty cache |
|
| 76 | + $modx->clearCache('full'); |
|
| 77 | + |
|
| 78 | + // finished emptying cache - redirect |
|
| 79 | + if ($_POST['stay'] != '') { |
|
| 80 | + $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
| 81 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 82 | + header($header); |
|
| 83 | + } else { |
|
| 84 | + $header = "Location: index.php?a=76&r=2"; |
|
| 85 | + header($header); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + break; |
|
| 89 | + case '16': |
|
| 90 | + |
|
| 91 | + // invoke OnBeforeTempFormSave event |
|
| 92 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
| 93 | + "mode" => "upd", |
|
| 94 | + "id" => $id |
|
| 95 | + )); |
|
| 96 | + |
|
| 97 | + // disallow duplicate names for templates |
|
| 98 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
| 99 | + $count = $modx->getDatabase()->getValue($rs); |
|
| 100 | + if ($count > 0) { |
|
| 101 | + $modx->getManagerApi()->saveFormValues(16); |
|
| 102 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + //do stuff to save the edited doc |
|
| 106 | + $modx->getDatabase()->update(array( |
|
| 107 | + 'templatename' => $templatename, |
|
| 108 | + 'description' => $description, |
|
| 109 | + 'content' => $template, |
|
| 110 | + 'locked' => $locked, |
|
| 111 | + 'selectable' => $selectable, |
|
| 112 | + 'category' => $categoryid, |
|
| 113 | + 'editedon' => $currentdate |
|
| 114 | + ), $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'"); |
|
| 115 | + // Set new assigned Tvs |
|
| 116 | + saveTemplateAccess($id); |
|
| 117 | + |
|
| 118 | + // invoke OnTempFormSave event |
|
| 119 | + $modx->invokeEvent("OnTempFormSave", array( |
|
| 120 | + "mode" => "upd", |
|
| 121 | + "id" => $id |
|
| 122 | + )); |
|
| 123 | + |
|
| 124 | + // Set the item name for logger |
|
| 125 | + $_SESSION['itemname'] = $templatename; |
|
| 126 | + |
|
| 127 | + // first empty the cache |
|
| 128 | + $modx->clearCache('full'); |
|
| 129 | + |
|
| 130 | + // finished emptying cache - redirect |
|
| 131 | + if ($_POST['stay'] != '') { |
|
| 132 | + $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
| 133 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
| 134 | + header($header); |
|
| 135 | + } else { |
|
| 136 | + $modx->unlockElement(1, $id); |
|
| 137 | + $header = "Location: index.php?a=76&r=2"; |
|
| 138 | + header($header); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + break; |
|
| 143 | + default: |
|
| 144 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 145 | 145 | } |
@@ -14,8 +14,11 @@ |
||
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_tmplvars'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_tmplvars'), "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 TV |
| 21 | 24 | $newid = $modx->getDatabase()->insert( |
@@ -4,7 +4,9 @@ |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if(!isset($_GET['id'])) { |
| 7 | - if(!$modx->hasPermission('remove_locks')) $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | + if(!$modx->hasPermission('remove_locks')) { |
|
| 8 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 9 | + } |
|
| 8 | 10 | |
| 9 | 11 | // Remove all locks |
| 10 | 12 | $modx->getDatabase()->truncate($modx->getDatabase()->getFullTableName('active_user_locks')); |
@@ -14,8 +14,11 @@ |
||
| 14 | 14 | // count duplicates |
| 15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_plugins'), "id='{$id}'")); |
| 16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_plugins'), "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 Plugin |
| 21 | 24 | $newid = $modx->getDatabase()->insert( |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // check if user has access permission, except admins |
| 15 | -if($_SESSION['mgrRole']!=1){ |
|
| 15 | +if($_SESSION['mgrRole']!=1) { |
|
| 16 | 16 | $rs = $modx->getDatabase()->select( |
| 17 | 17 | 'sma.usergroup,mg.member', |
| 18 | 18 | $modx->getDatabase()->getFullTableName("site_module_access")." sma |