@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | * @param int $_toplevel |
43 | 43 | * @return int |
44 | 44 | */ |
45 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
45 | +function duplicateDocument($docid, $parent=null, $_toplevel=0) |
|
46 | +{ |
|
46 | 47 | $modx = evolutionCMS(); global $_lang; |
47 | 48 | |
48 | 49 | // invoke OnBeforeDocDuplicate event |
@@ -63,8 +64,7 @@ discard block |
||
63 | 64 | $content = $modx->db->getRow($rs); |
64 | 65 | |
65 | 66 | // Handle incremental ID |
66 | - switch($modx->config['docid_incrmnt_method']) |
|
67 | - { |
|
67 | + switch($modx->config['docid_incrmnt_method']) { |
|
68 | 68 | case '1': |
69 | 69 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
70 | 70 | $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
@@ -85,8 +85,11 @@ discard block |
||
85 | 85 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
86 | 86 | $pagetitle = $modx->db->escape($pagetitle); |
87 | 87 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
88 | - if($count>=1) $count = ' '.($count+1); |
|
89 | - else $count = ''; |
|
88 | + if($count>=1) { |
|
89 | + $count = ' '.($count+1); |
|
90 | + } else { |
|
91 | + $count = ''; |
|
92 | + } |
|
90 | 93 | |
91 | 94 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
92 | 95 | $content['alias'] = null; |
@@ -95,7 +98,9 @@ discard block |
||
95 | 98 | } |
96 | 99 | |
97 | 100 | // change the parent accordingly |
98 | - if ($parent !== null) $content['parent'] = $parent; |
|
101 | + if ($parent !== null) { |
|
102 | + $content['parent'] = $parent; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Change the author |
101 | 106 | $content['createdby'] = $userID; |
@@ -135,8 +140,9 @@ discard block |
||
135 | 140 | // Start duplicating all the child documents that aren't deleted. |
136 | 141 | $_toplevel++; |
137 | 142 | $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
138 | - while ($row = $modx->db->getRow($rs)) |
|
139 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
143 | + while ($row = $modx->db->getRow($rs)) { |
|
144 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
145 | + } |
|
140 | 146 | |
141 | 147 | // return the new doc id |
142 | 148 | return $newparent; |
@@ -148,7 +154,8 @@ discard block |
||
148 | 154 | * @param int $oldid |
149 | 155 | * @param int $newid |
150 | 156 | */ |
151 | -function duplicateTVs($oldid, $newid){ |
|
157 | +function duplicateTVs($oldid, $newid) |
|
158 | +{ |
|
152 | 159 | $modx = evolutionCMS(); |
153 | 160 | |
154 | 161 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
@@ -168,7 +175,8 @@ discard block |
||
168 | 175 | * @param int $oldid |
169 | 176 | * @param int $newid |
170 | 177 | */ |
171 | -function duplicateAccess($oldid, $newid){ |
|
178 | +function duplicateAccess($oldid, $newid) |
|
179 | +{ |
|
172 | 180 | $modx = evolutionCMS(); |
173 | 181 | |
174 | 182 | $tbldg = $modx->getFullTableName('document_groups'); |
@@ -12,7 +12,7 @@ discard block |
||
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->db->select( |
17 | 17 | 'sma.usergroup,mg.member', |
18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function evalModule($moduleCode,$params){ |
|
73 | +function evalModule($moduleCode,$params) |
|
74 | +{ |
|
74 | 75 | $modx = evolutionCMS(); |
75 | 76 | $modx->event->params = &$params; // store params inside event object |
76 | 77 | if(is_array($params)) { |
@@ -80,11 +81,9 @@ discard block |
||
80 | 81 | $mod = eval($moduleCode); |
81 | 82 | $msg = ob_get_contents(); |
82 | 83 | ob_end_clean(); |
83 | - if (isset($php_errormsg)) |
|
84 | - { |
|
84 | + if (isset($php_errormsg)) { |
|
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
87 | - { |
|
86 | + switch($error_info['type']) { |
|
88 | 87 | case E_NOTICE : |
89 | 88 | $error_level = 1; |
90 | 89 | case E_USER_NOTICE : |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | default: |
98 | 97 | $error_level = 99; |
99 | 98 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | - { |
|
99 | + if($modx->config['error_reporting']==='99' || 2<$error_level) { |
|
102 | 100 | $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
103 | 101 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 102 | } |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
5 | 5 | |
6 | 6 | |
7 | -if( ! function_exists('evolutionCMS')) { |
|
7 | +if( ! function_exists('evolutionCMS')) { |
|
8 | 8 | /** |
9 | 9 | * @return DocumentParser |
10 | 10 | */ |
11 | - function evolutionCMS() |
|
12 | - { |
|
13 | - if( ! defined('MODX_CLASS')) { |
|
14 | - if( ! class_exists('DocumentParser')) { |
|
11 | + function evolutionCMS() |
|
12 | + { |
|
13 | + if( ! defined('MODX_CLASS')) { |
|
14 | + if( ! class_exists('DocumentParser')) { |
|
15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists'); |
16 | 16 | } |
17 | 17 | define('MODX_CLASS', 'DocumentParser'); |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @return string |
26 | 26 | */ |
27 | -function genEvoSessionName() |
|
28 | -{ |
|
27 | +function genEvoSessionName() |
|
28 | +{ |
|
29 | 29 | $_ = crc32(__FILE__); |
30 | 30 | $_ = sprintf('%u', $_); |
31 | 31 | |
@@ -35,10 +35,12 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @return void |
37 | 37 | */ |
38 | -function startCMSSession() |
|
39 | -{ |
|
38 | +function startCMSSession() |
|
39 | +{ |
|
40 | 40 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
41 | - if(MODX_CLI) return; |
|
41 | + if(MODX_CLI) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | session_name($site_sessionname); |
44 | 46 | removeInvalidCmsSessionIds($site_sessionname); |
@@ -49,14 +51,14 @@ discard block |
||
49 | 51 | session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
50 | 52 | session_start(); |
51 | 53 | $key = "modx.mgr.session.cookie.lifetime"; |
52 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
54 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
53 | 55 | $cookieLifetime = (int)$_SESSION[$key]; |
54 | - if ($cookieLifetime) { |
|
56 | + if ($cookieLifetime) { |
|
55 | 57 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
56 | 58 | } |
57 | 59 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
58 | 60 | } |
59 | - if (!isset($_SESSION['modx.session.created.time'])) { |
|
61 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
60 | 62 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
61 | 63 | } |
62 | 64 | } |
@@ -66,9 +68,9 @@ discard block |
||
66 | 68 | * @param $session_name |
67 | 69 | * @return void |
68 | 70 | */ |
69 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
70 | -{ |
|
71 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
71 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
72 | +{ |
|
73 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
72 | 74 | unset($storage[$session_name]); |
73 | 75 | } |
74 | 76 | } |
@@ -77,9 +79,11 @@ discard block |
||
77 | 79 | * @param $session_name |
78 | 80 | * @return void |
79 | 81 | */ |
80 | -function removeInvalidCmsSessionIds($session_name) |
|
81 | -{ |
|
82 | - if(MODX_CLI) return; |
|
82 | +function removeInvalidCmsSessionIds($session_name) |
|
83 | +{ |
|
84 | + if(MODX_CLI) { |
|
85 | + return; |
|
86 | + } |
|
83 | 87 | // session ids is invalid iff it is empty string |
84 | 88 | // storage priorioty can see in PHP source ext/session/session.c |
85 | 89 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |