Completed
Push — develop ( 4a389e...d0bb9b )
by Maxim
15s
created
manager/processors/duplicate_content.processor.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $udperms->duplicateDoc = true;
23 23
 
24 24
 if(!$udperms->checkPermissions()) {
25
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
25
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
28 28
 // Run the duplicator
@@ -43,103 +43,103 @@  discard block
 block discarded – undo
43 43
  * @return int
44 44
  */
45 45
 function duplicateDocument($docid, $parent=null, $_toplevel=0) {
46
-	$modx = evolutionCMS(); global $_lang;
47
-
48
-	// invoke OnBeforeDocDuplicate event
49
-	$evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
-		'id' => $docid
51
-	));
52
-
53
-	// if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
-	// TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
-	// [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
-
57
-	$userID = $modx->getLoginUserID();
58
-
59
-	$tblsc = $modx->getFullTableName('site_content');
60
-
61
-	// Grab the original document
62
-	$rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
-	$content = $modx->db->getRow($rs);
64
-
65
-	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
67
-	{
68
-		case '1':
69
-			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
-			$rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
-			$content['id'] = $modx->db->getValue($rs);
72
-			break;
73
-		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
75
-			$content['id'] = $modx->db->getValue($rs);
76
-			break;
77
-
78
-		default:
79
-			unset($content['id']); // remove the current id.
80
-	}
81
-
82
-	// Once we've grabbed the document object, start doing some modifications
83
-	if ($_toplevel == 0) {
84
-		// count duplicates
85
-		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
-		$pagetitle = $modx->db->escape($pagetitle);
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 = '';
90
-
91
-		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
-		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
-		$content['alias'] = null;
95
-	}
96
-
97
-	// change the parent accordingly
98
-	if ($parent !== null) $content['parent'] = $parent;
99
-
100
-	// Change the author
101
-	$content['createdby'] = $userID;
102
-	$content['createdon'] = time();
103
-	// Remove other modification times
104
-	$content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
-
106
-	// [FS#922] Should the published status be honored? - sirlancelot
46
+    $modx = evolutionCMS(); global $_lang;
47
+
48
+    // invoke OnBeforeDocDuplicate event
49
+    $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
+        'id' => $docid
51
+    ));
52
+
53
+    // if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
+    // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
+    // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
+
57
+    $userID = $modx->getLoginUserID();
58
+
59
+    $tblsc = $modx->getFullTableName('site_content');
60
+
61
+    // Grab the original document
62
+    $rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
+    $content = $modx->db->getRow($rs);
64
+
65
+    // Handle incremental ID
66
+    switch($modx->config['docid_incrmnt_method'])
67
+    {
68
+        case '1':
69
+            $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
+            $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
+            $content['id'] = $modx->db->getValue($rs);
72
+            break;
73
+        case '2':
74
+            $rs = $modx->db->select('MAX(id)+1',$tblsc);
75
+            $content['id'] = $modx->db->getValue($rs);
76
+            break;
77
+
78
+        default:
79
+            unset($content['id']); // remove the current id.
80
+    }
81
+
82
+    // Once we've grabbed the document object, start doing some modifications
83
+    if ($_toplevel == 0) {
84
+        // count duplicates
85
+        $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
+        $pagetitle = $modx->db->escape($pagetitle);
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 = '';
90
+
91
+        $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
+        $content['alias'] = null;
93
+    } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
+        $content['alias'] = null;
95
+    }
96
+
97
+    // change the parent accordingly
98
+    if ($parent !== null) $content['parent'] = $parent;
99
+
100
+    // Change the author
101
+    $content['createdby'] = $userID;
102
+    $content['createdon'] = time();
103
+    // Remove other modification times
104
+    $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
+
106
+    // [FS#922] Should the published status be honored? - sirlancelot
107 107
 //	if ($modx->hasPermission('publish_document')) {
108 108
 //		if ($modx->config['publish_default'])
109 109
 //			$content['pub_date'] = $content['pub_date']; // should this be changed to 1?
110 110
 //		else	$content['pub_date'] = 0;
111 111
 //	} else {
112
-		// User can't publish documents
112
+        // User can't publish documents
113 113
 //		$content['published'] = $content['pub_date'] = 0;
114 114
 //	}
115 115
 
116 116
     // Set the published status to unpublished by default (see above ... commit #3388)
117 117
     $content['published'] = $content['pub_date'] = 0;
118 118
 
119
-	// Escape the proper strings
120
-	$content = $modx->db->escape($content);
119
+    // Escape the proper strings
120
+    $content = $modx->db->escape($content);
121 121
 
122
-	// Duplicate the Document
123
-	$newparent = $modx->db->insert($content, $tblsc);
122
+    // Duplicate the Document
123
+    $newparent = $modx->db->insert($content, $tblsc);
124 124
 
125
-	// duplicate document's TVs
126
-	duplicateTVs($docid, $newparent);
127
-	duplicateAccess($docid, $newparent);
125
+    // duplicate document's TVs
126
+    duplicateTVs($docid, $newparent);
127
+    duplicateAccess($docid, $newparent);
128 128
 
129
-	// invoke OnDocDuplicate event
130
-	$evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
-		'id' => $docid,
132
-		'new_id' => $newparent
133
-	));
129
+    // invoke OnDocDuplicate event
130
+    $evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
+        'id' => $docid,
132
+        'new_id' => $newparent
133
+    ));
134 134
 
135
-	// Start duplicating all the child documents that aren't deleted.
136
-	$_toplevel++;
137
-	$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);
135
+    // Start duplicating all the child documents that aren't deleted.
136
+    $_toplevel++;
137
+    $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);
140 140
 
141
-	// return the new doc id
142
-	return $newparent;
141
+    // return the new doc id
142
+    return $newparent;
143 143
 }
144 144
 
145 145
 /**
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
  * @param int $newid
150 150
  */
151 151
 function duplicateTVs($oldid, $newid){
152
-	$modx = evolutionCMS();
152
+    $modx = evolutionCMS();
153 153
 
154
-	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
154
+    $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156 156
     $newid = (int)$newid;
157 157
     $oldid = (int)$oldid;
158 158
 
159 159
     $modx->db->insert(
160
-		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
-		"{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
-	);
160
+        array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
+        "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
+    );
163 163
 }
164 164
 
165 165
 /**
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  * @param int $newid
170 170
  */
171 171
 function duplicateAccess($oldid, $newid){
172
-	$modx = evolutionCMS();
172
+    $modx = evolutionCMS();
173 173
 
174
-	$tbldg = $modx->getFullTableName('document_groups');
174
+    $tbldg = $modx->getFullTableName('document_groups');
175 175
 
176 176
     $newid = (int)$newid;
177 177
     $oldid = (int)$oldid;
178 178
 
179 179
     $modx->db->insert(
180
-		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
-		"{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
-	);
180
+        array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
+        "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
+    );
183 183
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
5
+if (!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
15 15
 
16 16
 // check permissions on the document
17
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
17
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
18 18
 $udperms = new udperms();
19 19
 $udperms->user = $modx->getLoginUserID();
20 20
 $udperms->document = $id;
21 21
 $udperms->role = $_SESSION['mgrRole'];
22 22
 $udperms->duplicateDoc = true;
23 23
 
24
-if(!$udperms->checkPermissions()) {
24
+if (!$udperms->checkPermissions()) {
25 25
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 $_SESSION['itemname'] = $name;
34 34
 
35 35
 // finish cloning - redirect
36
-$header="Location: index.php?r=1&a=3&id=$id";
36
+$header = "Location: index.php?r=1&a=3&id=$id";
37 37
 header($header);
38 38
 
39 39
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
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
 	$modx = evolutionCMS(); global $_lang;
47 47
 
48 48
 	// invoke OnBeforeDocDuplicate event
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	$content = $modx->db->getRow($rs);
64 64
 
65 65
 	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
66
+	switch ($modx->config['docid_incrmnt_method'])
67 67
 	{
68 68
 		case '1':
69 69
 			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			$content['id'] = $modx->db->getValue($rs);
72 72
 			break;
73 73
 		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
74
+			$rs = $modx->db->select('MAX(id)+1', $tblsc);
75 75
 			$content['id'] = $modx->db->getValue($rs);
76 76
 			break;
77 77
 
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
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);
88
+		if ($count >= 1) $count = ' '.($count + 1);
89 89
 		else $count = '';
90 90
 
91 91
 		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92 92
 		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
93
+	} elseif ($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94 94
 		$content['alias'] = null;
95 95
 	}
96 96
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 
154 154
 	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156
-    $newid = (int)$newid;
157
-    $oldid = (int)$oldid;
156
+    $newid = (int) $newid;
157
+    $oldid = (int) $oldid;
158 158
 
159 159
     $modx->db->insert(
160 160
 		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 
174 174
 	$tbldg = $modx->getFullTableName('document_groups');
175 175
 
176
-    $newid = (int)$newid;
177
-    $oldid = (int)$oldid;
176
+    $newid = (int) $newid;
177
+    $oldid = (int) $oldid;
178 178
 
179 179
     $modx->db->insert(
180 180
 		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
manager/processors/execute_module.processor.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -3,51 +3,51 @@  discard block
 block discarded – undo
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('exec_module')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // check if user has access permission, except admins
15 15
 if($_SESSION['mgrRole']!=1){
16
-	$rs = $modx->db->select(
17
-		'sma.usergroup,mg.member',
18
-		$modx->getFullTableName("site_module_access")." sma
16
+    $rs = $modx->db->select(
17
+        'sma.usergroup,mg.member',
18
+        $modx->getFullTableName("site_module_access")." sma
19 19
 			LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'",
20
-		"sma.module = '{$id}'"
21
-		);
22
-	//initialize permission to -1, if it stays -1 no permissions
23
-	//attached so permission granted
24
-	$permissionAccessInt = -1;
20
+        "sma.module = '{$id}'"
21
+        );
22
+    //initialize permission to -1, if it stays -1 no permissions
23
+    //attached so permission granted
24
+    $permissionAccessInt = -1;
25 25
 
26
-	while ($row = $modx->db->getRow($rs)) {
27
-		if($row["usergroup"] && $row["member"]) {
28
-			//if there are permissions and this member has permission, ofcourse
29
-			//this is granted
30
-			$permissionAccessInt = 1;
31
-		} elseif ($permissionAccessInt==-1) {
32
-			//if there are permissions but this member has no permission and the
33
-			//variable was still in init state we set permission to 0; no permissions
34
-			$permissionAccessInt = 0;
35
-		}
36
-	}
26
+    while ($row = $modx->db->getRow($rs)) {
27
+        if($row["usergroup"] && $row["member"]) {
28
+            //if there are permissions and this member has permission, ofcourse
29
+            //this is granted
30
+            $permissionAccessInt = 1;
31
+        } elseif ($permissionAccessInt==-1) {
32
+            //if there are permissions but this member has no permission and the
33
+            //variable was still in init state we set permission to 0; no permissions
34
+            $permissionAccessInt = 0;
35
+        }
36
+    }
37 37
 
38
-	if($permissionAccessInt==0) {
39
-		$modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40
-	}
38
+    if($permissionAccessInt==0) {
39
+        $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40
+    }
41 41
 }
42 42
 
43 43
 // get module data
44 44
 $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'");
45 45
 $content = $modx->db->getRow($rs);
46 46
 if(!$content) {
47
-	$modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
47
+    $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
48 48
 }
49 49
 if($content['disabled']) {
50
-	$modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
50
+    $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
51 51
 }
52 52
 
53 53
 // Set the item name for logger
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
  * @return string
72 72
  */
73 73
 function evalModule($moduleCode,$params){
74
-	$modx = evolutionCMS();
75
-	$modx->event->params = &$params; // store params inside event object
76
-	if(is_array($params)) {
77
-		extract($params, EXTR_SKIP);
78
-	}
79
-	ob_start();
80
-	$mod = eval($moduleCode);
81
-	$msg = ob_get_contents();
82
-	ob_end_clean();
83
-	if (isset($php_errormsg))
84
-	{
85
-		$error_info = error_get_last();
74
+    $modx = evolutionCMS();
75
+    $modx->event->params = &$params; // store params inside event object
76
+    if(is_array($params)) {
77
+        extract($params, EXTR_SKIP);
78
+    }
79
+    ob_start();
80
+    $mod = eval($moduleCode);
81
+    $msg = ob_get_contents();
82
+    ob_end_clean();
83
+    if (isset($php_errormsg))
84
+    {
85
+        $error_info = error_get_last();
86 86
         switch($error_info['type'])
87 87
         {
88
-        	case E_NOTICE :
89
-        		$error_level = 1;
90
-        	case E_USER_NOTICE :
91
-        		break;
92
-        	case E_DEPRECATED :
93
-        	case E_USER_DEPRECATED :
94
-        	case E_STRICT :
95
-        		$error_level = 2;
96
-        		break;
97
-        	default:
98
-        		$error_level = 99;
88
+            case E_NOTICE :
89
+                $error_level = 1;
90
+            case E_USER_NOTICE :
91
+                break;
92
+            case E_DEPRECATED :
93
+            case E_USER_DEPRECATED :
94
+            case E_STRICT :
95
+                $error_level = 2;
96
+                break;
97
+            default:
98
+                $error_level = 99;
99
+        }
100
+        if($modx->config['error_reporting']==='99' || 2<$error_level)
101
+        {
102
+            $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103
+            $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
99 104
         }
100
-		if($modx->config['error_reporting']==='99' || 2<$error_level)
101
-		{
102
-			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103
-			$modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
104
-		}
105
-	}
106
-	unset($modx->event->params);
107
-	return $mod.$msg;
105
+    }
106
+    unset($modx->event->params);
107
+    return $mod.$msg;
108 108
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('exec_module')) {
5
+if (!$modx->hasPermission('exec_module')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
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
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 	$permissionAccessInt = -1;
25 25
 
26 26
 	while ($row = $modx->db->getRow($rs)) {
27
-		if($row["usergroup"] && $row["member"]) {
27
+		if ($row["usergroup"] && $row["member"]) {
28 28
 			//if there are permissions and this member has permission, ofcourse
29 29
 			//this is granted
30 30
 			$permissionAccessInt = 1;
31
-		} elseif ($permissionAccessInt==-1) {
31
+		} elseif ($permissionAccessInt == -1) {
32 32
 			//if there are permissions but this member has no permission and the
33 33
 			//variable was still in init state we set permission to 0; no permissions
34 34
 			$permissionAccessInt = 0;
35 35
 		}
36 36
 	}
37 37
 
38
-	if($permissionAccessInt==0) {
38
+	if ($permissionAccessInt == 0) {
39 39
 		$modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40 40
 	}
41 41
 }
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 // get module data
44 44
 $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'");
45 45
 $content = $modx->db->getRow($rs);
46
-if(!$content) {
46
+if (!$content) {
47 47
 	$modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
48 48
 }
49
-if($content['disabled']) {
49
+if ($content['disabled']) {
50 50
 	$modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
51 51
 }
52 52
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 // Set the item name for logger
60 60
 $_SESSION['itemname'] = $content['name'];
61 61
 
62
-$output = evalModule($content["modulecode"],$parameter);
62
+$output = evalModule($content["modulecode"], $parameter);
63 63
 echo $output;
64 64
 include MODX_MANAGER_PATH."includes/sysalert.display.inc.php";
65 65
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
  * @param array $params
71 71
  * @return string
72 72
  */
73
-function evalModule($moduleCode,$params){
73
+function evalModule($moduleCode, $params){
74 74
 	$modx = evolutionCMS();
75 75
 	$modx->event->params = &$params; // store params inside event object
76
-	if(is_array($params)) {
76
+	if (is_array($params)) {
77 77
 		extract($params, EXTR_SKIP);
78 78
 	}
79 79
 	ob_start();
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	if (isset($php_errormsg))
84 84
 	{
85 85
 		$error_info = error_get_last();
86
-        switch($error_info['type'])
86
+        switch ($error_info['type'])
87 87
         {
88 88
         	case E_NOTICE :
89 89
         		$error_level = 1;
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         	default:
98 98
         		$error_level = 99;
99 99
         }
100
-		if($modx->config['error_reporting']==='99' || 2<$error_level)
100
+		if ($modx->config['error_reporting'] === '99' || 2 < $error_level)
101 101
 		{
102
-			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
102
+			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'].' - Module', $error_info['message'], $error_info['line'], $msg);
103 103
 			$modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
104 104
 		}
105 105
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.