@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
3 | 3 | if(!$modx->hasPermission('delete_document')) { |
4 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
4 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "deleted=1"); |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | |
10 | 10 | // invoke OnBeforeEmptyTrash event |
11 | 11 | $modx->invokeEvent("OnBeforeEmptyTrash", |
12 | - array( |
|
13 | - "ids"=>$ids |
|
14 | - )); |
|
12 | + array( |
|
13 | + "ids"=>$ids |
|
14 | + )); |
|
15 | 15 | |
16 | 16 | // remove the document groups link. |
17 | 17 | $sql = "DELETE document_groups |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | //'undelete' the document. |
31 | 31 | $modx->db->delete($modx->getFullTableName('site_content'), "deleted=1"); |
32 | 32 | |
33 | - // invoke OnEmptyTrash event |
|
34 | - $modx->invokeEvent("OnEmptyTrash", |
|
35 | - array( |
|
36 | - "ids"=>$ids |
|
37 | - )); |
|
33 | + // invoke OnEmptyTrash event |
|
34 | + $modx->invokeEvent("OnEmptyTrash", |
|
35 | + array( |
|
36 | + "ids"=>$ids |
|
37 | + )); |
|
38 | 38 | |
39 | - // empty cache |
|
40 | - $modx->clearCache('full'); |
|
39 | + // empty cache |
|
40 | + $modx->clearCache('full'); |
|
41 | 41 | |
42 | - // finished emptying cache - redirect |
|
43 | - $header="Location: index.php?a=2&r=1"; |
|
44 | - header($header); |
|
42 | + // finished emptying cache - redirect |
|
43 | + $header="Location: index.php?a=2&r=1"; |
|
44 | + header($header); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | -if(!$modx->hasPermission('delete_document')) { |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | +if (!$modx->hasPermission('delete_document')) { |
|
4 | 4 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 5 | } |
6 | 6 | |
@@ -40,5 +40,5 @@ discard block |
||
40 | 40 | $modx->clearCache('full'); |
41 | 41 | |
42 | 42 | // finished emptying cache - redirect |
43 | - $header="Location: index.php?a=2&r=1"; |
|
43 | + $header = "Location: index.php?a=2&r=1"; |
|
44 | 44 | header($header); |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if(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."); |
|
4 | +} |
|
3 | 5 | if(!$modx->hasPermission('delete_document')) { |
4 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 7 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
25 | 25 | $categoryid = 0; |
26 | 26 | } else { |
27 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
27 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
28 | 28 | $categoryid = getCategory($_POST['newcategory']); |
29 | 29 | } |
30 | 30 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; |
41 | 41 | |
42 | 42 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
43 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
43 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
44 | 44 | if ($version) { |
45 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
45 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
46 | 46 | } |
47 | 47 | if (isset($parsed['modx_category'])) { |
48 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
48 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
49 | 49 | $categoryid = getCategory($parsed['modx_category']); |
50 | 50 | } |
51 | 51 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // finished emptying cache - redirect |
104 | 104 | if ($_POST['stay'] != '') { |
105 | 105 | $a = ($_POST['stay'] == '2') ? "102&id=$newid" : '101'; |
106 | - $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay']; |
|
106 | + $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay']; |
|
107 | 107 | header($header); |
108 | 108 | } else { |
109 | 109 | $header = 'Location: index.php?a=76&r=2'; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // finished emptying cache - redirect |
159 | 159 | if ($_POST['stay'] != '') { |
160 | 160 | $a = ($_POST['stay'] == '2') ? "102&id=$id" : '101'; |
161 | - $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay']; |
|
161 | + $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay']; |
|
162 | 162 | header($header); |
163 | 163 | } else { |
164 | 164 | $modx->unlockElement(5, $id); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // save selected system events |
178 | 178 | $formEventList = array(); |
179 | 179 | foreach ($sysevents as $evtId) { |
180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
180 | + if (!preg_match('@^[1-9][0-9]*$@', $evtId)) $evtId = getEventIdByName($evtId); |
|
181 | 181 | if ($mode == '101') { |
182 | 182 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
183 | 183 | } else { |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | $rs = $modx->db->select('*', '[+prefix+]site_plugin_events', sprintf("pluginid='%s'", $id)); |
203 | 203 | $dbEventList = array(); |
204 | 204 | $del = array(); |
205 | - while($row = $modx->db->getRow($rs)) { |
|
206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
205 | + while ($row = $modx->db->getRow($rs)) { |
|
206 | + if (!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
207 | 207 | } |
208 | 208 | |
209 | - if(!$del) return; |
|
209 | + if (!$del) return; |
|
210 | 210 | |
211 | - foreach($del as $delid) { |
|
211 | + foreach ($del as $delid) { |
|
212 | 212 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
213 | 213 | } |
214 | 214 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | function getEventIdByName($name) |
217 | 217 | { |
218 | 218 | global $modx; |
219 | - static $eventIds=array(); |
|
219 | + static $eventIds = array(); |
|
220 | 220 | |
221 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
221 | + if (isset($eventIds[$name])) return $eventIds[$name]; |
|
222 | 222 | |
223 | 223 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
224 | 224 | while ($row = $modx->db->getRow($rs)) { |
@@ -177,7 +177,9 @@ discard block |
||
177 | 177 | // save selected system events |
178 | 178 | $formEventList = array(); |
179 | 179 | foreach ($sysevents as $evtId) { |
180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
180 | + if(!preg_match('@^[1-9][0-9]*$@',$evtId)) { |
|
181 | + $evtId = getEventIdByName($evtId); |
|
182 | + } |
|
181 | 183 | if ($mode == '101') { |
182 | 184 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
183 | 185 | } else { |
@@ -203,10 +205,14 @@ discard block |
||
203 | 205 | $dbEventList = array(); |
204 | 206 | $del = array(); |
205 | 207 | while($row = $modx->db->getRow($rs)) { |
206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
208 | + if(!in_array($row['evtid'], $evtids)) { |
|
209 | + $del[] = $row['evtid']; |
|
210 | + } |
|
207 | 211 | } |
208 | 212 | |
209 | - if(!$del) return; |
|
213 | + if(!$del) { |
|
214 | + return; |
|
215 | + } |
|
210 | 216 | |
211 | 217 | foreach($del as $delid) { |
212 | 218 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
@@ -218,7 +224,9 @@ discard block |
||
218 | 224 | global $modx; |
219 | 225 | static $eventIds=array(); |
220 | 226 | |
221 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
227 | + if(isset($eventIds[$name])) { |
|
228 | + return $eventIds[$name]; |
|
229 | + } |
|
222 | 230 | |
223 | 231 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
224 | 232 | while ($row = $modx->db->getRow($rs)) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
28 | 28 | $categoryid = 0; |
29 | 29 | } else { |
30 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
30 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
31 | 31 | $categoryid = checkCategory($_POST['newcategory']); |
32 | 32 | if (!$categoryid) { |
33 | 33 | $categoryid = newCategory($_POST['newcategory']); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // finished emptying cache - redirect |
100 | 100 | if ($_POST['stay'] != '') { |
101 | 101 | $a = ($_POST['stay'] == '2') ? "301&id=$newid" : "300"; |
102 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
102 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
103 | 103 | header($header); |
104 | 104 | } else { |
105 | 105 | $header = "Location: index.php?a=76&r=2"; |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | // finished emptying cache - redirect |
161 | 161 | if ($_POST['stay'] != '') { |
162 | 162 | $a = ($_POST['stay'] == '2') ? "301&id=$id" : "300"; |
163 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'] . "&or=" . $origin . "&oid=" . $originId; |
|
163 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']."&or=".$origin."&oid=".$originId; |
|
164 | 164 | header($header); |
165 | 165 | } else { |
166 | 166 | $modx->unlockElement(2, $id); |
167 | - $header = "Location: index.php?a=" . $origin . "&r=2" . ($originId != null ? '&id=' . $originId : ''); |
|
167 | + $header = "Location: index.php?a=".$origin."&r=2".($originId != null ? '&id='.$originId : ''); |
|
168 | 168 | header($header); |
169 | 169 | } |
170 | 170 |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | -if (IN_MANAGER_MODE!="true") { |
|
2 | +if (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('delete_document')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? intval($_GET['id']) : 0; |
|
10 | -if ($id==0) { |
|
9 | +$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /*******ищем родителя чтобы к нему вернуться********/ |
15 | -$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
15 | +$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
17 | 17 | |
18 | 18 | /************ а заодно и путь возврата (сам путь внизу файла) **********/ |
19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
22 | -$add_path=$sd.$sb.$pg; |
|
19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
22 | +$add_path = $sd.$sb.$pg; |
|
23 | 23 | |
24 | 24 | /*****************************/ |
25 | 25 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $children = array(); |
28 | 28 | |
29 | 29 | // check permissions on the document |
30 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
30 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
31 | 31 | $udperms = new udperms(); |
32 | 32 | $udperms->user = $modx->getLoginUserID(); |
33 | 33 | $udperms->document = $id; |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | |
49 | 49 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent={$parent} AND deleted=0"); |
50 | 50 | // the document has children documents, we'll need to delete those too |
51 | - while ($childid=$modx->db->getValue($rs)) { |
|
52 | - if ($childid==$site_start) { |
|
51 | + while ($childid = $modx->db->getValue($rs)) { |
|
52 | + if ($childid == $site_start) { |
|
53 | 53 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site start' document, and cannot be deleted. Please assign another document as your 'Site start' document and try again."); |
54 | 54 | } |
55 | - if ($childid==$site_unavailable_page) { |
|
55 | + if ($childid == $site_unavailable_page) { |
|
56 | 56 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unavailable page' document, and cannot be deleted. Please assign another document as your 'Site unavailable page' document and try again."); |
57 | 57 | } |
58 | - if ($childid==$error_page) { |
|
58 | + if ($childid == $error_page) { |
|
59 | 59 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site error page' document, and cannot be deleted. Please assign another document as your 'Site error page' document and try again."); |
60 | 60 | } |
61 | - if ($childid==$unauthorized_page) { |
|
61 | + if ($childid == $unauthorized_page) { |
|
62 | 62 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unauthorized page' document, and cannot be deleted. Please assign another document as your 'Site unauthorized page' document and try again."); |
63 | 63 | } |
64 | 64 | $children[] = $childid; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | "children"=>$children |
77 | 77 | )); |
78 | 78 | |
79 | -if (count($children)>0) { |
|
79 | +if (count($children) > 0) { |
|
80 | 80 | $modx->db->update( |
81 | 81 | array( |
82 | 82 | 'deleted' => 1, |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | ), $modx->getFullTableName('site_content'), "id IN (".implode(", ", $children).")"); |
86 | 86 | } |
87 | 87 | |
88 | -if ($site_start==$id) { |
|
88 | +if ($site_start == $id) { |
|
89 | 89 | $modx->webAlertAndQuit("Document is 'Site start' and cannot be deleted!"); |
90 | 90 | } |
91 | 91 | |
92 | -if ($site_unavailable_page==$id) { |
|
92 | +if ($site_unavailable_page == $id) { |
|
93 | 93 | $modx->webAlertAndQuit("Document is used as the 'Site unavailable page' and cannot be deleted!"); |
94 | 94 | } |
95 | 95 | |
96 | -if ($error_page==$id) { |
|
96 | +if ($error_page == $id) { |
|
97 | 97 | $modx->webAlertAndQuit("Document is used as the 'Site error page' and cannot be deleted!"); |
98 | 98 | } |
99 | 99 | |
100 | -if ($unauthorized_page==$id) { |
|
100 | +if ($unauthorized_page == $id) { |
|
101 | 101 | $modx->webAlertAndQuit("Document is used as the 'Site unauthorized page' and cannot be deleted!"); |
102 | 102 | } |
103 | 103 | |
@@ -123,5 +123,5 @@ discard block |
||
123 | 123 | $modx->clearCache('full'); |
124 | 124 | |
125 | 125 | // finished emptying cache - redirect |
126 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
126 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
127 | 127 | header($header); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
3 | 3 | if(!$modx->hasPermission('delete_web_user')) { |
4 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
4 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | $id = isset($_GET['id'])? intval($_GET['id']) : 0; |
8 | 8 | if($id==0) { |
9 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
9 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // Set the item name for logger |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | // invoke OnBeforeWUsrFormDelete event |
17 | 17 | $modx->invokeEvent("OnBeforeWUsrFormDelete", |
18 | - array( |
|
19 | - "id" => $id |
|
20 | - )); |
|
18 | + array( |
|
19 | + "id" => $id |
|
20 | + )); |
|
21 | 21 | |
22 | 22 | // delete the user. |
23 | 23 | $modx->db->delete($modx->getFullTableName('web_users'), "id='{$id}'"); |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | |
31 | 31 | // invoke OnWebDeleteUser event |
32 | 32 | $modx->invokeEvent("OnWebDeleteUser", |
33 | - array( |
|
34 | - "userid" => $id, |
|
35 | - "username" => $username |
|
36 | - )); |
|
33 | + array( |
|
34 | + "userid" => $id, |
|
35 | + "username" => $username |
|
36 | + )); |
|
37 | 37 | |
38 | 38 | // invoke OnWUsrFormDelete event |
39 | 39 | $modx->invokeEvent("OnWUsrFormDelete", |
40 | - array( |
|
41 | - "id" => $id |
|
42 | - )); |
|
40 | + array( |
|
41 | + "id" => $id |
|
42 | + )); |
|
43 | 43 | |
44 | 44 | $header="Location: index.php?a=99"; |
45 | 45 | header($header); |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | -if(!$modx->hasPermission('delete_web_user')) { |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | +if (!$modx->hasPermission('delete_web_user')) { |
|
4 | 4 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 5 | } |
6 | 6 | |
7 | -$id = isset($_GET['id'])? intval($_GET['id']) : 0; |
|
8 | -if($id==0) { |
|
7 | +$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
8 | +if ($id == 0) { |
|
9 | 9 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
10 | 10 | } |
11 | 11 | |
@@ -41,5 +41,5 @@ discard block |
||
41 | 41 | "id" => $id |
42 | 42 | )); |
43 | 43 | |
44 | -$header="Location: index.php?a=99"; |
|
44 | +$header = "Location: index.php?a=99"; |
|
45 | 45 | header($header); |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if(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."); |
|
4 | +} |
|
3 | 5 | if(!$modx->hasPermission('delete_web_user')) { |
4 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 7 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
3 | 3 | if(!$modx->hasPermission('delete_plugin')) { |
4 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
4 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | $id = isset($_GET['id'])? intval($_GET['id']) : 0; |
8 | 8 | if($id==0) { |
9 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
9 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // Set the item name for logger |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | // invoke OnBeforePluginFormDelete event |
17 | 17 | $modx->invokeEvent("OnBeforePluginFormDelete", |
18 | - array( |
|
19 | - "id" => $id |
|
20 | - )); |
|
18 | + array( |
|
19 | + "id" => $id |
|
20 | + )); |
|
21 | 21 | |
22 | 22 | // delete the plugin. |
23 | 23 | $modx->db->delete($modx->getFullTableName('site_plugins'), "id='{$id}'"); |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | // invoke OnPluginFormDelete event |
29 | 29 | $modx->invokeEvent("OnPluginFormDelete", |
30 | - array( |
|
31 | - "id" => $id |
|
32 | - )); |
|
30 | + array( |
|
31 | + "id" => $id |
|
32 | + )); |
|
33 | 33 | |
34 | 34 | // empty cache |
35 | 35 | $modx->clearCache('full'); |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | -if(!$modx->hasPermission('delete_plugin')) { |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | +if (!$modx->hasPermission('delete_plugin')) { |
|
4 | 4 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 5 | } |
6 | 6 | |
7 | -$id = isset($_GET['id'])? intval($_GET['id']) : 0; |
|
8 | -if($id==0) { |
|
7 | +$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
8 | +if ($id == 0) { |
|
9 | 9 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
10 | 10 | } |
11 | 11 | |
@@ -35,5 +35,5 @@ discard block |
||
35 | 35 | $modx->clearCache('full'); |
36 | 36 | |
37 | 37 | // finished emptying cache - redirect |
38 | -$header="Location: index.php?a=76&r=2"; |
|
38 | +$header = "Location: index.php?a=76&r=2"; |
|
39 | 39 | header($header); |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if(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."); |
|
4 | +} |
|
3 | 5 | if(!$modx->hasPermission('delete_plugin')) { |
4 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 7 | } |
@@ -33,115 +33,115 @@ |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | switch ($_POST['mode']) { |
36 | - case '19': |
|
37 | - |
|
38 | - // invoke OnBeforeTempFormSave event |
|
39 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
40 | - "mode" => "new", |
|
41 | - "id" => $id |
|
42 | - )); |
|
43 | - |
|
44 | - // disallow duplicate names for new templates |
|
45 | - $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
46 | - $count = $modx->db->getValue($rs); |
|
47 | - if ($count > 0) { |
|
48 | - $modx->manager->saveFormValues(19); |
|
49 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
50 | - } |
|
51 | - |
|
52 | - //do stuff to save the new doc |
|
53 | - $newid = $modx->db->insert(array( |
|
54 | - 'templatename' => $templatename, |
|
55 | - 'description' => $description, |
|
56 | - 'content' => $template, |
|
57 | - 'locked' => $locked, |
|
58 | - 'selectable' => $selectable, |
|
59 | - 'category' => $categoryid, |
|
60 | - 'createdon' => $currentdate, |
|
61 | - 'editedon' => $currentdate |
|
62 | - ), $modx->getFullTableName('site_templates')); |
|
63 | - |
|
64 | - // invoke OnTempFormSave event |
|
65 | - $modx->invokeEvent("OnTempFormSave", array( |
|
66 | - "mode" => "new", |
|
67 | - "id" => $newid |
|
68 | - )); |
|
69 | - // Set new assigned Tvs |
|
70 | - saveTemplateAccess($newid); |
|
71 | - |
|
72 | - // Set the item name for logger |
|
73 | - $_SESSION['itemname'] = $templatename; |
|
74 | - |
|
75 | - // empty cache |
|
76 | - $modx->clearCache('full'); |
|
77 | - |
|
78 | - // finished emptying cache - redirect |
|
79 | - if ($_POST['stay'] != '') { |
|
80 | - $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
82 | - header($header); |
|
83 | - } else { |
|
84 | - $header = "Location: index.php?a=76&r=2"; |
|
85 | - header($header); |
|
86 | - } |
|
87 | - |
|
88 | - break; |
|
89 | - case '16': |
|
90 | - |
|
91 | - // invoke OnBeforeTempFormSave event |
|
92 | - $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
93 | - "mode" => "upd", |
|
94 | - "id" => $id |
|
95 | - )); |
|
96 | - |
|
97 | - // disallow duplicate names for templates |
|
98 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
99 | - $count = $modx->db->getValue($rs); |
|
100 | - if ($count > 0) { |
|
101 | - $modx->manager->saveFormValues(16); |
|
102 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
103 | - } |
|
104 | - |
|
105 | - //do stuff to save the edited doc |
|
106 | - $modx->db->update(array( |
|
107 | - 'templatename' => $templatename, |
|
108 | - 'description' => $description, |
|
109 | - 'content' => $template, |
|
110 | - 'locked' => $locked, |
|
111 | - 'selectable' => $selectable, |
|
112 | - 'category' => $categoryid, |
|
113 | - 'editedon' => $currentdate |
|
114 | - ), $modx->getFullTableName('site_templates'), "id='{$id}'"); |
|
115 | - // Set new assigned Tvs |
|
116 | - saveTemplateAccess($id); |
|
117 | - |
|
118 | - // invoke OnTempFormSave event |
|
119 | - $modx->invokeEvent("OnTempFormSave", array( |
|
120 | - "mode" => "upd", |
|
121 | - "id" => $id |
|
122 | - )); |
|
123 | - |
|
124 | - // Set the item name for logger |
|
125 | - $_SESSION['itemname'] = $templatename; |
|
126 | - |
|
127 | - // first empty the cache |
|
128 | - $modx->clearCache('full'); |
|
129 | - |
|
130 | - // finished emptying cache - redirect |
|
131 | - if ($_POST['stay'] != '') { |
|
132 | - $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
134 | - header($header); |
|
135 | - } else { |
|
136 | - $modx->unlockElement(1, $id); |
|
137 | - $header = "Location: index.php?a=76&r=2"; |
|
138 | - header($header); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - break; |
|
143 | - default: |
|
144 | - $modx->webAlertAndQuit("No operation set in request."); |
|
36 | + case '19': |
|
37 | + |
|
38 | + // invoke OnBeforeTempFormSave event |
|
39 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
40 | + "mode" => "new", |
|
41 | + "id" => $id |
|
42 | + )); |
|
43 | + |
|
44 | + // disallow duplicate names for new templates |
|
45 | + $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
46 | + $count = $modx->db->getValue($rs); |
|
47 | + if ($count > 0) { |
|
48 | + $modx->manager->saveFormValues(19); |
|
49 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); |
|
50 | + } |
|
51 | + |
|
52 | + //do stuff to save the new doc |
|
53 | + $newid = $modx->db->insert(array( |
|
54 | + 'templatename' => $templatename, |
|
55 | + 'description' => $description, |
|
56 | + 'content' => $template, |
|
57 | + 'locked' => $locked, |
|
58 | + 'selectable' => $selectable, |
|
59 | + 'category' => $categoryid, |
|
60 | + 'createdon' => $currentdate, |
|
61 | + 'editedon' => $currentdate |
|
62 | + ), $modx->getFullTableName('site_templates')); |
|
63 | + |
|
64 | + // invoke OnTempFormSave event |
|
65 | + $modx->invokeEvent("OnTempFormSave", array( |
|
66 | + "mode" => "new", |
|
67 | + "id" => $newid |
|
68 | + )); |
|
69 | + // Set new assigned Tvs |
|
70 | + saveTemplateAccess($newid); |
|
71 | + |
|
72 | + // Set the item name for logger |
|
73 | + $_SESSION['itemname'] = $templatename; |
|
74 | + |
|
75 | + // empty cache |
|
76 | + $modx->clearCache('full'); |
|
77 | + |
|
78 | + // finished emptying cache - redirect |
|
79 | + if ($_POST['stay'] != '') { |
|
80 | + $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
|
81 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
82 | + header($header); |
|
83 | + } else { |
|
84 | + $header = "Location: index.php?a=76&r=2"; |
|
85 | + header($header); |
|
86 | + } |
|
87 | + |
|
88 | + break; |
|
89 | + case '16': |
|
90 | + |
|
91 | + // invoke OnBeforeTempFormSave event |
|
92 | + $modx->invokeEvent("OnBeforeTempFormSave", array( |
|
93 | + "mode" => "upd", |
|
94 | + "id" => $id |
|
95 | + )); |
|
96 | + |
|
97 | + // disallow duplicate names for templates |
|
98 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
99 | + $count = $modx->db->getValue($rs); |
|
100 | + if ($count > 0) { |
|
101 | + $modx->manager->saveFormValues(16); |
|
102 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); |
|
103 | + } |
|
104 | + |
|
105 | + //do stuff to save the edited doc |
|
106 | + $modx->db->update(array( |
|
107 | + 'templatename' => $templatename, |
|
108 | + 'description' => $description, |
|
109 | + 'content' => $template, |
|
110 | + 'locked' => $locked, |
|
111 | + 'selectable' => $selectable, |
|
112 | + 'category' => $categoryid, |
|
113 | + 'editedon' => $currentdate |
|
114 | + ), $modx->getFullTableName('site_templates'), "id='{$id}'"); |
|
115 | + // Set new assigned Tvs |
|
116 | + saveTemplateAccess($id); |
|
117 | + |
|
118 | + // invoke OnTempFormSave event |
|
119 | + $modx->invokeEvent("OnTempFormSave", array( |
|
120 | + "mode" => "upd", |
|
121 | + "id" => $id |
|
122 | + )); |
|
123 | + |
|
124 | + // Set the item name for logger |
|
125 | + $_SESSION['itemname'] = $templatename; |
|
126 | + |
|
127 | + // first empty the cache |
|
128 | + $modx->clearCache('full'); |
|
129 | + |
|
130 | + // finished emptying cache - redirect |
|
131 | + if ($_POST['stay'] != '') { |
|
132 | + $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
|
133 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
134 | + header($header); |
|
135 | + } else { |
|
136 | + $modx->unlockElement(1, $id); |
|
137 | + $header = "Location: index.php?a=76&r=2"; |
|
138 | + header($header); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + break; |
|
143 | + default: |
|
144 | + $modx->webAlertAndQuit("No operation set in request."); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | function saveTemplateAccess($id) |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | $templatename = $modx->db->escape(trim($_POST['templatename'])); |
12 | 12 | $description = $modx->db->escape($_POST['description']); |
13 | 13 | $locked = $_POST['locked'] == 'on' ? 1 : 0; |
14 | -$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
14 | +$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
15 | 15 | $_POST['selectable'] == 'on' ? 1 : 0; |
16 | 16 | $currentdate = time() + $modx->config['server_offset_time']; |
17 | 17 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
22 | 22 | $categoryid = 0; |
23 | 23 | } else { |
24 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
24 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
25 | 25 | $categoryid = checkCategory($_POST['newcategory']); |
26 | 26 | if (!$categoryid) { |
27 | 27 | $categoryid = newCategory($_POST['newcategory']); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // finished emptying cache - redirect |
79 | 79 | if ($_POST['stay'] != '') { |
80 | 80 | $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
81 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
82 | 82 | header($header); |
83 | 83 | } else { |
84 | 84 | $header = "Location: index.php?a=76&r=2"; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // finished emptying cache - redirect |
131 | 131 | if ($_POST['stay'] != '') { |
132 | 132 | $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
133 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
134 | 134 | header($header); |
135 | 135 | } else { |
136 | 136 | $modx->unlockElement(1, $id); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
3 | 3 | if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
4 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
4 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | $id = isset($_GET['id'])? intval($_GET['id']) : 0; |
8 | 8 | if($id==0) { |
9 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
9 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | $children = array(); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $udperms->duplicateDoc = true; |
21 | 21 | |
22 | 22 | if(!$udperms->checkPermissions()) { |
23 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
23 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // Run the duplicator |
@@ -35,125 +35,125 @@ discard block |
||
35 | 35 | header($header); |
36 | 36 | |
37 | 37 | function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
38 | - global $modx, $_lang; |
|
39 | - |
|
40 | - // invoke OnBeforeDocDuplicate event |
|
41 | - $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array( |
|
42 | - 'id' => $docid |
|
43 | - )); |
|
44 | - |
|
45 | - // if( !in_array( 'false', array_values( $evtOut ) ) ){} |
|
46 | - // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication |
|
47 | - // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false'); |
|
48 | - |
|
49 | - $userID = $modx->getLoginUserID(); |
|
50 | - |
|
51 | - $tblsc = $modx->getFullTableName('site_content'); |
|
52 | - |
|
53 | - // Grab the original document |
|
54 | - $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); |
|
55 | - $content = $modx->db->getRow($rs); |
|
56 | - |
|
57 | - // Handle incremental ID |
|
58 | - switch($modx->config['docid_incrmnt_method']) |
|
59 | - { |
|
60 | - case '1': |
|
61 | - $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
|
62 | - $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
63 | - $content['id'] = $modx->db->getValue($rs); |
|
64 | - break; |
|
65 | - case '2': |
|
66 | - $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
67 | - $content['id'] = $modx->db->getValue($rs); |
|
68 | - break; |
|
69 | - |
|
70 | - default: |
|
71 | - unset($content['id']); // remove the current id. |
|
72 | - } |
|
73 | - |
|
74 | - // Once we've grabbed the document object, start doing some modifications |
|
75 | - if ($_toplevel == 0) { |
|
76 | - // count duplicates |
|
77 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
|
78 | - $pagetitle = $modx->db->escape($pagetitle); |
|
79 | - $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
|
80 | - if($count>=1) $count = ' '.($count+1); |
|
81 | - else $count = ''; |
|
38 | + global $modx, $_lang; |
|
39 | + |
|
40 | + // invoke OnBeforeDocDuplicate event |
|
41 | + $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array( |
|
42 | + 'id' => $docid |
|
43 | + )); |
|
44 | + |
|
45 | + // if( !in_array( 'false', array_values( $evtOut ) ) ){} |
|
46 | + // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication |
|
47 | + // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false'); |
|
48 | + |
|
49 | + $userID = $modx->getLoginUserID(); |
|
50 | + |
|
51 | + $tblsc = $modx->getFullTableName('site_content'); |
|
52 | + |
|
53 | + // Grab the original document |
|
54 | + $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); |
|
55 | + $content = $modx->db->getRow($rs); |
|
56 | + |
|
57 | + // Handle incremental ID |
|
58 | + switch($modx->config['docid_incrmnt_method']) |
|
59 | + { |
|
60 | + case '1': |
|
61 | + $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
|
62 | + $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
63 | + $content['id'] = $modx->db->getValue($rs); |
|
64 | + break; |
|
65 | + case '2': |
|
66 | + $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
67 | + $content['id'] = $modx->db->getValue($rs); |
|
68 | + break; |
|
69 | + |
|
70 | + default: |
|
71 | + unset($content['id']); // remove the current id. |
|
72 | + } |
|
73 | + |
|
74 | + // Once we've grabbed the document object, start doing some modifications |
|
75 | + if ($_toplevel == 0) { |
|
76 | + // count duplicates |
|
77 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
|
78 | + $pagetitle = $modx->db->escape($pagetitle); |
|
79 | + $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
|
80 | + if($count>=1) $count = ' '.($count+1); |
|
81 | + else $count = ''; |
|
82 | 82 | |
83 | - $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
|
84 | - $content['alias'] = null; |
|
85 | - } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
86 | - $content['alias'] = null; |
|
87 | - } |
|
88 | - |
|
89 | - // change the parent accordingly |
|
90 | - if ($parent !== null) $content['parent'] = $parent; |
|
91 | - |
|
92 | - // Change the author |
|
93 | - $content['createdby'] = $userID; |
|
94 | - $content['createdon'] = time(); |
|
95 | - // Remove other modification times |
|
96 | - $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0; |
|
97 | - |
|
98 | - // [FS#922] Should the published status be honored? - sirlancelot |
|
83 | + $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
|
84 | + $content['alias'] = null; |
|
85 | + } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
86 | + $content['alias'] = null; |
|
87 | + } |
|
88 | + |
|
89 | + // change the parent accordingly |
|
90 | + if ($parent !== null) $content['parent'] = $parent; |
|
91 | + |
|
92 | + // Change the author |
|
93 | + $content['createdby'] = $userID; |
|
94 | + $content['createdon'] = time(); |
|
95 | + // Remove other modification times |
|
96 | + $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0; |
|
97 | + |
|
98 | + // [FS#922] Should the published status be honored? - sirlancelot |
|
99 | 99 | // if ($modx->hasPermission('publish_document')) { |
100 | 100 | // if ($modx->config['publish_default']) |
101 | 101 | // $content['pub_date'] = $content['pub_date']; // should this be changed to 1? |
102 | 102 | // else $content['pub_date'] = 0; |
103 | 103 | // } else { |
104 | - // User can't publish documents |
|
104 | + // User can't publish documents |
|
105 | 105 | // $content['published'] = $content['pub_date'] = 0; |
106 | 106 | // } |
107 | 107 | |
108 | 108 | // Set the published status to unpublished by default (see above ... commit #3388) |
109 | 109 | $content['published'] = $content['pub_date'] = 0; |
110 | 110 | |
111 | - // Escape the proper strings |
|
112 | - $content = $modx->db->escape($content); |
|
111 | + // Escape the proper strings |
|
112 | + $content = $modx->db->escape($content); |
|
113 | 113 | |
114 | - // Duplicate the Document |
|
115 | - $newparent = $modx->db->insert($content, $tblsc); |
|
114 | + // Duplicate the Document |
|
115 | + $newparent = $modx->db->insert($content, $tblsc); |
|
116 | 116 | |
117 | - // duplicate document's TVs |
|
118 | - duplicateTVs($docid, $newparent); |
|
119 | - duplicateAccess($docid, $newparent); |
|
117 | + // duplicate document's TVs |
|
118 | + duplicateTVs($docid, $newparent); |
|
119 | + duplicateAccess($docid, $newparent); |
|
120 | 120 | |
121 | - // invoke OnDocDuplicate event |
|
122 | - $evtOut = $modx->invokeEvent('OnDocDuplicate', array( |
|
123 | - 'id' => $docid, |
|
124 | - 'new_id' => $newparent |
|
125 | - )); |
|
126 | - |
|
127 | - // Start duplicating all the child documents that aren't deleted. |
|
128 | - $_toplevel++; |
|
129 | - $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
|
130 | - while ($row = $modx->db->getRow($rs)) |
|
131 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
132 | - |
|
133 | - // return the new doc id |
|
134 | - return $newparent; |
|
121 | + // invoke OnDocDuplicate event |
|
122 | + $evtOut = $modx->invokeEvent('OnDocDuplicate', array( |
|
123 | + 'id' => $docid, |
|
124 | + 'new_id' => $newparent |
|
125 | + )); |
|
126 | + |
|
127 | + // Start duplicating all the child documents that aren't deleted. |
|
128 | + $_toplevel++; |
|
129 | + $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
|
130 | + while ($row = $modx->db->getRow($rs)) |
|
131 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
132 | + |
|
133 | + // return the new doc id |
|
134 | + return $newparent; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // Duplicate Document TVs |
138 | 138 | function duplicateTVs($oldid,$newid){ |
139 | - global $modx; |
|
139 | + global $modx; |
|
140 | 140 | |
141 | - $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
|
141 | + $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
|
142 | 142 | |
143 | - $modx->db->insert( |
|
144 | - array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
|
145 | - "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from |
|
146 | - ); |
|
143 | + $modx->db->insert( |
|
144 | + array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
|
145 | + "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from |
|
146 | + ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Duplicate Document Access Permissions |
150 | 150 | function duplicateAccess($oldid,$newid){ |
151 | - global $modx; |
|
151 | + global $modx; |
|
152 | 152 | |
153 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
153 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
154 | 154 | |
155 | - $modx->db->insert( |
|
156 | - array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
|
157 | - "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from |
|
158 | - ); |
|
155 | + $modx->db->insert( |
|
156 | + array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
|
157 | + "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from |
|
158 | + ); |
|
159 | 159 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | -if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | +if (!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
|
4 | 4 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 5 | } |
6 | 6 | |
7 | -$id = isset($_GET['id'])? intval($_GET['id']) : 0; |
|
8 | -if($id==0) { |
|
7 | +$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
8 | +if ($id == 0) { |
|
9 | 9 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
10 | 10 | } |
11 | 11 | |
12 | 12 | $children = array(); |
13 | 13 | |
14 | 14 | // check permissions on the document |
15 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
15 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
16 | 16 | $udperms = new udperms(); |
17 | 17 | $udperms->user = $modx->getLoginUserID(); |
18 | 18 | $udperms->document = $id; |
19 | 19 | $udperms->role = $_SESSION['mgrRole']; |
20 | 20 | $udperms->duplicateDoc = true; |
21 | 21 | |
22 | -if(!$udperms->checkPermissions()) { |
|
22 | +if (!$udperms->checkPermissions()) { |
|
23 | 23 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
24 | 24 | } |
25 | 25 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $_SESSION['itemname'] = $name; |
32 | 32 | |
33 | 33 | // finish cloning - redirect |
34 | -$header="Location: index.php?r=1&a=3&id=$id"; |
|
34 | +$header = "Location: index.php?r=1&a=3&id=$id"; |
|
35 | 35 | header($header); |
36 | 36 | |
37 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
37 | +function duplicateDocument($docid, $parent = null, $_toplevel = 0){ |
|
38 | 38 | global $modx, $_lang; |
39 | 39 | |
40 | 40 | // invoke OnBeforeDocDuplicate event |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $content = $modx->db->getRow($rs); |
56 | 56 | |
57 | 57 | // Handle incremental ID |
58 | - switch($modx->config['docid_incrmnt_method']) |
|
58 | + switch ($modx->config['docid_incrmnt_method']) |
|
59 | 59 | { |
60 | 60 | case '1': |
61 | 61 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $content['id'] = $modx->db->getValue($rs); |
64 | 64 | break; |
65 | 65 | case '2': |
66 | - $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
66 | + $rs = $modx->db->select('MAX(id)+1', $tblsc); |
|
67 | 67 | $content['id'] = $modx->db->getValue($rs); |
68 | 68 | break; |
69 | 69 | |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
78 | 78 | $pagetitle = $modx->db->escape($pagetitle); |
79 | 79 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
80 | - if($count>=1) $count = ' '.($count+1); |
|
80 | + if ($count >= 1) $count = ' '.($count + 1); |
|
81 | 81 | else $count = ''; |
82 | 82 | |
83 | 83 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
84 | 84 | $content['alias'] = null; |
85 | - } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
85 | + } elseif ($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
86 | 86 | $content['alias'] = null; |
87 | 87 | } |
88 | 88 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | // Duplicate Document TVs |
138 | -function duplicateTVs($oldid,$newid){ |
|
138 | +function duplicateTVs($oldid, $newid){ |
|
139 | 139 | global $modx; |
140 | 140 | |
141 | 141 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | // Duplicate Document Access Permissions |
150 | -function duplicateAccess($oldid,$newid){ |
|
150 | +function duplicateAccess($oldid, $newid){ |
|
151 | 151 | global $modx; |
152 | 152 | |
153 | 153 | $tbldg = $modx->getFullTableName('document_groups'); |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if(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."); |
|
4 | +} |
|
3 | 5 | if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
4 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 7 | } |
@@ -34,7 +36,8 @@ discard block |
||
34 | 36 | $header="Location: index.php?r=1&a=3&id=$id"; |
35 | 37 | header($header); |
36 | 38 | |
37 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
39 | +function duplicateDocument($docid, $parent=null, $_toplevel=0) |
|
40 | +{ |
|
38 | 41 | global $modx, $_lang; |
39 | 42 | |
40 | 43 | // invoke OnBeforeDocDuplicate event |
@@ -55,8 +58,7 @@ discard block |
||
55 | 58 | $content = $modx->db->getRow($rs); |
56 | 59 | |
57 | 60 | // Handle incremental ID |
58 | - switch($modx->config['docid_incrmnt_method']) |
|
59 | - { |
|
61 | + switch($modx->config['docid_incrmnt_method']) { |
|
60 | 62 | case '1': |
61 | 63 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
62 | 64 | $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
@@ -77,8 +79,11 @@ discard block |
||
77 | 79 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
78 | 80 | $pagetitle = $modx->db->escape($pagetitle); |
79 | 81 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
80 | - if($count>=1) $count = ' '.($count+1); |
|
81 | - else $count = ''; |
|
82 | + if($count>=1) { |
|
83 | + $count = ' '.($count+1); |
|
84 | + } else { |
|
85 | + $count = ''; |
|
86 | + } |
|
82 | 87 | |
83 | 88 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
84 | 89 | $content['alias'] = null; |
@@ -87,7 +92,9 @@ discard block |
||
87 | 92 | } |
88 | 93 | |
89 | 94 | // change the parent accordingly |
90 | - if ($parent !== null) $content['parent'] = $parent; |
|
95 | + if ($parent !== null) { |
|
96 | + $content['parent'] = $parent; |
|
97 | + } |
|
91 | 98 | |
92 | 99 | // Change the author |
93 | 100 | $content['createdby'] = $userID; |
@@ -127,15 +134,17 @@ discard block |
||
127 | 134 | // Start duplicating all the child documents that aren't deleted. |
128 | 135 | $_toplevel++; |
129 | 136 | $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
130 | - while ($row = $modx->db->getRow($rs)) |
|
131 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
137 | + while ($row = $modx->db->getRow($rs)) { |
|
138 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
139 | + } |
|
132 | 140 | |
133 | 141 | // return the new doc id |
134 | 142 | return $newparent; |
135 | 143 | } |
136 | 144 | |
137 | 145 | // Duplicate Document TVs |
138 | -function duplicateTVs($oldid,$newid){ |
|
146 | +function duplicateTVs($oldid,$newid) |
|
147 | +{ |
|
139 | 148 | global $modx; |
140 | 149 | |
141 | 150 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
@@ -147,7 +156,8 @@ discard block |
||
147 | 156 | } |
148 | 157 | |
149 | 158 | // Duplicate Document Access Permissions |
150 | -function duplicateAccess($oldid,$newid){ |
|
159 | +function duplicateAccess($oldid,$newid) |
|
160 | +{ |
|
151 | 161 | global $modx; |
152 | 162 | |
153 | 163 | $tbldg = $modx->getFullTableName('document_groups'); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
3 | 3 | if(!$modx->hasPermission('edit_document')) { |
4 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
4 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
@@ -23,82 +23,82 @@ discard block |
||
23 | 23 | // check user has permission to move document to chosen location |
24 | 24 | |
25 | 25 | if ($use_udperms == 1) { |
26 | - if ($oldparent != $newParentID) { |
|
27 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
28 | - $udperms = new udperms(); |
|
29 | - $udperms->user = $modx->getLoginUserID(); |
|
30 | - $udperms->document = $newParentID; |
|
31 | - $udperms->role = $_SESSION['mgrRole']; |
|
32 | - |
|
33 | - if (!$udperms->checkPermissions()) { |
|
34 | - $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
35 | - } |
|
36 | - } |
|
26 | + if ($oldparent != $newParentID) { |
|
27 | + include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
28 | + $udperms = new udperms(); |
|
29 | + $udperms->user = $modx->getLoginUserID(); |
|
30 | + $udperms->document = $newParentID; |
|
31 | + $udperms->role = $_SESSION['mgrRole']; |
|
32 | + |
|
33 | + if (!$udperms->checkPermissions()) { |
|
34 | + $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function allChildren($currDocID) { |
40 | - global $modx; |
|
41 | - $children= array(); |
|
42 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
|
43 | - while ($child= $modx->db->getRow($rs)) { |
|
44 | - $children[]= $child['id']; |
|
45 | - $nextgen= array(); |
|
46 | - $nextgen= allChildren($child['id']); |
|
47 | - $children= array_merge($children, $nextgen); |
|
48 | - } |
|
49 | - return $children; |
|
40 | + global $modx; |
|
41 | + $children= array(); |
|
42 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
|
43 | + while ($child= $modx->db->getRow($rs)) { |
|
44 | + $children[]= $child['id']; |
|
45 | + $nextgen= array(); |
|
46 | + $nextgen= allChildren($child['id']); |
|
47 | + $children= array_merge($children, $nextgen); |
|
48 | + } |
|
49 | + return $children; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
53 | - "id_document" => $documentID, |
|
54 | - "old_parent" => $oldparent, |
|
55 | - "new_parent" => $newParentID |
|
53 | + "id_document" => $documentID, |
|
54 | + "old_parent" => $oldparent, |
|
55 | + "new_parent" => $newParentID |
|
56 | 56 | )); |
57 | 57 | if (is_array($evtOut) && count($evtOut) > 0){ |
58 | - $newParent = array_pop($evtOut); |
|
59 | - if($newParent == $oldparent) { |
|
60 | - $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
61 | - }else{ |
|
62 | - $newParentID = $newParent; |
|
63 | - } |
|
58 | + $newParent = array_pop($evtOut); |
|
59 | + if($newParent == $oldparent) { |
|
60 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
61 | + }else{ |
|
62 | + $newParentID = $newParent; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $children = allChildren($documentID); |
67 | 67 | if (!array_search($newParentID, $children)) { |
68 | - $modx->db->update(array( |
|
69 | - 'isfolder' => 1, |
|
70 | - ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
71 | - |
|
72 | - $modx->db->update(array( |
|
73 | - 'parent' => $newParentID, |
|
74 | - 'editedby' => $modx->getLoginUserID(), |
|
75 | - 'editedon' => time(), |
|
76 | - ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
77 | - |
|
78 | - // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
79 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
80 | - $limit = $modx->db->getValue($rs); |
|
81 | - |
|
82 | - if(!$limit>0) { |
|
83 | - $modx->db->update(array( |
|
84 | - 'isfolder' => 0, |
|
85 | - ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
86 | - } |
|
87 | - // Set the item name for logger |
|
88 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
89 | - $_SESSION['itemname'] = $pagetitle; |
|
90 | - |
|
91 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
92 | - "id_document" => $documentID, |
|
93 | - "old_parent" => $oldparent, |
|
94 | - "new_parent" => $newParentID |
|
95 | - )); |
|
96 | - |
|
97 | - // empty cache & sync site |
|
98 | - $modx->clearCache('full'); |
|
99 | - |
|
100 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
101 | - header($header); |
|
68 | + $modx->db->update(array( |
|
69 | + 'isfolder' => 1, |
|
70 | + ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
71 | + |
|
72 | + $modx->db->update(array( |
|
73 | + 'parent' => $newParentID, |
|
74 | + 'editedby' => $modx->getLoginUserID(), |
|
75 | + 'editedon' => time(), |
|
76 | + ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
77 | + |
|
78 | + // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
79 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
80 | + $limit = $modx->db->getValue($rs); |
|
81 | + |
|
82 | + if(!$limit>0) { |
|
83 | + $modx->db->update(array( |
|
84 | + 'isfolder' => 0, |
|
85 | + ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
86 | + } |
|
87 | + // Set the item name for logger |
|
88 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
89 | + $_SESSION['itemname'] = $pagetitle; |
|
90 | + |
|
91 | + $modx->invokeEvent("onAfterMoveDocument", array ( |
|
92 | + "id_document" => $documentID, |
|
93 | + "old_parent" => $oldparent, |
|
94 | + "new_parent" => $newParentID |
|
95 | + )); |
|
96 | + |
|
97 | + // empty cache & sync site |
|
98 | + $modx->clearCache('full'); |
|
99 | + |
|
100 | + $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
101 | + header($header); |
|
102 | 102 | } else { |
103 | - $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
103 | + $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
104 | 104 | } |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | -if(!$modx->hasPermission('edit_document')) { |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | +if (!$modx->hasPermission('edit_document')) { |
|
4 | 4 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 5 | } |
6 | 6 | |
7 | -$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
|
8 | -$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
7 | +$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0; |
|
8 | +$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
9 | 9 | |
10 | 10 | // ok, two things to check. |
11 | 11 | // first, document cannot be moved to itself |
12 | 12 | // second, new parent must be a folder. If not, set it to folder. |
13 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
14 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
15 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
13 | +if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
14 | +if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
15 | +if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
16 | 16 | |
17 | 17 | $parents = $modx->getParentIds($newParentID); |
18 | 18 | if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | if ($use_udperms == 1) { |
26 | 26 | if ($oldparent != $newParentID) { |
27 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
27 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
28 | 28 | $udperms = new udperms(); |
29 | 29 | $udperms->user = $modx->getLoginUserID(); |
30 | 30 | $udperms->document = $newParentID; |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -function allChildren($currDocID) { |
|
39 | +function allChildren($currDocID){ |
|
40 | 40 | global $modx; |
41 | - $children= array(); |
|
41 | + $children = array(); |
|
42 | 42 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
43 | - while ($child= $modx->db->getRow($rs)) { |
|
44 | - $children[]= $child['id']; |
|
45 | - $nextgen= array(); |
|
46 | - $nextgen= allChildren($child['id']); |
|
47 | - $children= array_merge($children, $nextgen); |
|
43 | + while ($child = $modx->db->getRow($rs)) { |
|
44 | + $children[] = $child['id']; |
|
45 | + $nextgen = array(); |
|
46 | + $nextgen = allChildren($child['id']); |
|
47 | + $children = array_merge($children, $nextgen); |
|
48 | 48 | } |
49 | 49 | return $children; |
50 | 50 | } |
51 | 51 | |
52 | -$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
|
52 | +$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array( |
|
53 | 53 | "id_document" => $documentID, |
54 | 54 | "old_parent" => $oldparent, |
55 | 55 | "new_parent" => $newParentID |
56 | 56 | )); |
57 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
57 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
58 | 58 | $newParent = array_pop($evtOut); |
59 | - if($newParent == $oldparent) { |
|
59 | + if ($newParent == $oldparent) { |
|
60 | 60 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
61 | - }else{ |
|
61 | + } else { |
|
62 | 62 | $newParentID = $newParent; |
63 | 63 | } |
64 | 64 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
80 | 80 | $limit = $modx->db->getValue($rs); |
81 | 81 | |
82 | - if(!$limit>0) { |
|
82 | + if (!$limit > 0) { |
|
83 | 83 | $modx->db->update(array( |
84 | 84 | 'isfolder' => 0, |
85 | 85 | ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
89 | 89 | $_SESSION['itemname'] = $pagetitle; |
90 | 90 | |
91 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
91 | + $modx->invokeEvent("onAfterMoveDocument", array( |
|
92 | 92 | "id_document" => $documentID, |
93 | 93 | "old_parent" => $oldparent, |
94 | 94 | "new_parent" => $newParentID |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | // empty cache & sync site |
98 | 98 | $modx->clearCache('full'); |
99 | 99 | |
100 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
100 | + $header = "Location: index.php?a=3&id={$documentID}&r=9"; |
|
101 | 101 | header($header); |
102 | 102 | } else { |
103 | 103 | $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if(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."); |
|
4 | +} |
|
3 | 5 | if(!$modx->hasPermission('edit_document')) { |
4 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
5 | 7 | } |
@@ -10,12 +12,20 @@ discard block |
||
10 | 12 | // ok, two things to check. |
11 | 13 | // first, document cannot be moved to itself |
12 | 14 | // second, new parent must be a folder. If not, set it to folder. |
13 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
14 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
15 | -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 | +} |
|
16 | 24 | |
17 | 25 | $parents = $modx->getParentIds($newParentID); |
18 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
26 | +if (in_array($documentID, $parents)) { |
|
27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
28 | +} |
|
19 | 29 | |
20 | 30 | $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
21 | 31 | $oldparent = $modx->db->getValue($rs); |
@@ -36,7 +46,8 @@ discard block |
||
36 | 46 | } |
37 | 47 | } |
38 | 48 | |
39 | -function allChildren($currDocID) { |
|
49 | +function allChildren($currDocID) |
|
50 | +{ |
|
40 | 51 | global $modx; |
41 | 52 | $children= array(); |
42 | 53 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
@@ -54,11 +65,11 @@ discard block |
||
54 | 65 | "old_parent" => $oldparent, |
55 | 66 | "new_parent" => $newParentID |
56 | 67 | )); |
57 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
68 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
58 | 69 | $newParent = array_pop($evtOut); |
59 | 70 | if($newParent == $oldparent) { |
60 | 71 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
61 | - }else{ |
|
72 | + } else { |
|
62 | 73 | $newParentID = $newParent; |
63 | 74 | } |
64 | 75 | } |