Completed
Pull Request — develop (#518)
by Agel_Nash
05:24
created
manager/processors/duplicate_template.processor.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
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_template')) {
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
 // count duplicates
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 
18 18
 // duplicate template
19 19
 $newid = $modx->db->insert(
20
-	array(
21
-		'templatename'=>'',
22
-		'description'=>'',
23
-		'content'=>'',
24
-		'category'=>'',
25
-		), $modx->getFullTableName('site_templates'), // Insert into
26
-	"CONCAT(templatename, ' {$_lang['duplicated_el_suffix']}{$count}') AS templatename, description, content, category", $modx->getFullTableName('site_templates'), "id='{$id}'"); // Copy from
20
+    array(
21
+        'templatename'=>'',
22
+        'description'=>'',
23
+        'content'=>'',
24
+        'category'=>'',
25
+        ), $modx->getFullTableName('site_templates'), // Insert into
26
+    "CONCAT(templatename, ' {$_lang['duplicated_el_suffix']}{$count}') AS templatename, description, content, category", $modx->getFullTableName('site_templates'), "id='{$id}'"); // Copy from
27 27
 
28 28
 // duplicate TV values
29 29
 $modx->db->insert(
30
-	array(
31
-		'tmplvarid'=>'',
32
-		'templateid'=>'',
33
-		'rank'=>'',
34
-		), $modx->getFullTableName('site_tmplvar_templates'), // Insert into
35
-	"tmplvarid, '{$newid}', rank", $modx->getFullTableName('site_tmplvar_templates'), "templateid='{$id}'"); // Copy from
30
+    array(
31
+        'tmplvarid'=>'',
32
+        'templateid'=>'',
33
+        'rank'=>'',
34
+        ), $modx->getFullTableName('site_tmplvar_templates'), // Insert into
35
+    "tmplvarid, '{$newid}', rank", $modx->getFullTableName('site_tmplvar_templates'), "templateid='{$id}'"); // Copy from
36 36
 
37 37
 // Set the item name for logger
38 38
 $name = $modx->db->getValue($modx->db->select('templatename', $modx->getFullTableName('site_templates'), "id='{$newid}'"));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
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_template')) {
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_template')) {
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
 // count duplicates
13 13
 $name = $modx->db->getValue($modx->db->select('templatename', $modx->getFullTableName('site_templates'), "id='{$id}'"));
14 14
 $count = $modx->db->getRecordCount($modx->db->select('templatename', $modx->getFullTableName('site_templates'), "templatename LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
15
+if ($count >= 1) $count = ' '.($count + 1);
16 16
 else $count = '';
17 17
 
18 18
 // duplicate template
@@ -39,5 +39,5 @@  discard block
 block discarded – undo
39 39
 $_SESSION['itemname'] = $name;
40 40
 
41 41
 // finish duplicating - redirect to new template
42
-$header="Location: index.php?r=2&a=16&id=$newid";
42
+$header = "Location: index.php?r=2&a=16&id=$newid";
43 43
 header($header);
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
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_template')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -12,8 +14,11 @@  discard block
 block discarded – undo
12 14
 // count duplicates
13 15
 $name = $modx->db->getValue($modx->db->select('templatename', $modx->getFullTableName('site_templates'), "id='{$id}'"));
14 16
 $count = $modx->db->getRecordCount($modx->db->select('templatename', $modx->getFullTableName('site_templates'), "templatename LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
16
-else $count = '';
17
+if($count>=1) {
18
+    $count = ' '.($count+1);
19
+} else {
20
+    $count = '';
21
+}
17 22
 
18 23
 // duplicate template
19 24
 $newid = $modx->db->insert(
Please login to merge, or discard this patch.
manager/processors/duplicate_snippet.processor.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
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_snippet')) {
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
 // count duplicates
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 
18 18
 // duplicate Snippet
19 19
 $newid = $modx->db->insert(
20
-	array(
21
-		'name'=>'',
22
-		'description'=>'',
23
-		'snippet'=>'',
24
-		'properties'=>'',
25
-		'category'=>'',
26
-		), $modx->getFullTableName('site_snippets'), // Insert into
27
-	"CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, properties, category", $modx->getFullTableName('site_snippets'), "id='{$id}'"); // Copy from
20
+    array(
21
+        'name'=>'',
22
+        'description'=>'',
23
+        'snippet'=>'',
24
+        'properties'=>'',
25
+        'category'=>'',
26
+        ), $modx->getFullTableName('site_snippets'), // Insert into
27
+    "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, properties, category", $modx->getFullTableName('site_snippets'), "id='{$id}'"); // Copy from
28 28
 
29 29
 // Set the item name for logger
30 30
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_snippets'), "id='{$newid}'"));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
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_snippet')) {
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_snippet')) {
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
 // count duplicates
13 13
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_snippets'), "id='{$id}'"));
14 14
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_snippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
15
+if ($count >= 1) $count = ' '.($count + 1);
16 16
 else $count = '';
17 17
 
18 18
 // duplicate Snippet
@@ -31,5 +31,5 @@  discard block
 block discarded – undo
31 31
 $_SESSION['itemname'] = $name;
32 32
 
33 33
 // finish duplicating - redirect to new snippet
34
-$header="Location: index.php?r=2&a=22&id=$newid";
34
+$header = "Location: index.php?r=2&a=22&id=$newid";
35 35
 header($header);
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
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_snippet')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -12,8 +14,11 @@  discard block
 block discarded – undo
12 14
 // count duplicates
13 15
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_snippets'), "id='{$id}'"));
14 16
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_snippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
16
-else $count = '';
17
+if($count>=1) {
18
+    $count = ' '.($count+1);
19
+} else {
20
+    $count = '';
21
+}
17 22
 
18 23
 // duplicate Snippet
19 24
 $newid = $modx->db->insert(
Please login to merge, or discard this patch.
manager/processors/duplicate_htmlsnippet.processor.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
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_chunk')) {
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
 // count duplicates
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 
18 18
 // duplicate htmlsnippet
19 19
 $newid = $modx->db->insert(
20
-	array(
21
-		'name'=>'',
22
-		'description'=>'',
23
-		'snippet'=>'',
24
-		'category'=>'',
25
-		), $modx->getFullTableName('site_htmlsnippets'), // Insert into
26
-	"CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from
20
+    array(
21
+        'name'=>'',
22
+        'description'=>'',
23
+        'snippet'=>'',
24
+        'category'=>'',
25
+        ), $modx->getFullTableName('site_htmlsnippets'), // Insert into
26
+    "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from
27 27
 
28 28
 // Set the item name for logger
29 29
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$newid}'"));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
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_chunk')) {
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_chunk')) {
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
 // count duplicates
13 13
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"));
14 14
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
15
+if ($count >= 1) $count = ' '.($count + 1);
16 16
 else $count = '';
17 17
 
18 18
 // duplicate htmlsnippet
@@ -30,5 +30,5 @@  discard block
 block discarded – undo
30 30
 $_SESSION['itemname'] = $name;
31 31
 
32 32
 // finish duplicating - redirect to new chunk
33
-$header="Location: index.php?r=2&a=78&id=$newid";
33
+$header = "Location: index.php?r=2&a=78&id=$newid";
34 34
 header($header);
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
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_chunk')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -12,8 +14,11 @@  discard block
 block discarded – undo
12 14
 // count duplicates
13 15
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"));
14 16
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
16
-else $count = '';
17
+if($count>=1) {
18
+    $count = ' '.($count+1);
19
+} else {
20
+    $count = '';
21
+}
17 22
 
18 23
 // duplicate htmlsnippet
19 24
 $newid = $modx->db->insert(
Please login to merge, or discard this patch.
manager/processors/user_documents_permissions.class.php 4 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -2,43 +2,43 @@  discard block
 block discarded – undo
2 2
 
3 3
 class udperms{
4 4
 
5
-	var $user;
6
-	var $document;
7
-	var $role;
8
-	var $duplicateDoc = false;
5
+    var $user;
6
+    var $document;
7
+    var $role;
8
+    var $duplicateDoc = false;
9 9
 	
10
-	function checkPermissions() {
10
+    function checkPermissions() {
11 11
 		
12
-		global $udperms_allowroot;
13
-		global $modx;
12
+        global $udperms_allowroot;
13
+        global $modx;
14 14
 
15
-		$tblsc = $modx->getFullTableName('site_content');
16
-		$tbldg = $modx->getFullTableName('document_groups');
17
-		$tbldgn = $modx->getFullTableName('documentgroup_names');
15
+        $tblsc = $modx->getFullTableName('site_content');
16
+        $tbldg = $modx->getFullTableName('document_groups');
17
+        $tbldgn = $modx->getFullTableName('documentgroup_names');
18 18
 
19
-		$document = $this->document;
20
-		$role = $this->role;
19
+        $document = $this->document;
20
+        $role = $this->role;
21 21
 
22
-		if($role==1) {
23
-			return true;  // administrator - grant all document permissions
24
-		}
22
+        if($role==1) {
23
+            return true;  // administrator - grant all document permissions
24
+        }
25 25
 		
26
-		if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) {
27
-			return true; // permissions aren't in use
28
-		}
26
+        if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) {
27
+            return true; // permissions aren't in use
28
+        }
29 29
 		
30
-		$parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'"));
31
-		if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
32
-		if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) {
33
-			return false; // deny duplicate || create new document at root if Allow Root is No
34
-		}
30
+        $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'"));
31
+        if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
32
+        if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) {
33
+            return false; // deny duplicate || create new document at root if Allow Root is No
34
+        }
35 35
 		
36
-		// get document groups for current user
37
-		if($_SESSION['mgrDocgroups']) {
38
-			$docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']);
39
-		}
36
+        // get document groups for current user
37
+        if($_SESSION['mgrDocgroups']) {
38
+            $docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']);
39
+        }
40 40
 
41
-		/* Note:
41
+        /* Note:
42 42
 			A document is flagged as private whenever the document group that it
43 43
 			belongs to is assigned or links to a user group. In other words if 
44 44
 			the document is assigned to a document group that is not yet linked 
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
 			are private to the manager users will not be private to web users if the 
47 47
 			document group is not assigned to a web user group and visa versa.
48 48
 		 */
49
-		$permissionsok = false;  // set permissions to false
49
+        $permissionsok = false;  // set permissions to false
50 50
 		
51
-		$rs = $modx->db->select(
52
-			'count(DISTINCT sc.id)',
53
-			"{$tblsc} AS sc 
51
+        $rs = $modx->db->select(
52
+            'count(DISTINCT sc.id)',
53
+            "{$tblsc} AS sc 
54 54
 				LEFT JOIN {$tbldg} AS dg on dg.document = sc.id 
55 55
 				LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group",
56
-			"sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)"
57
-			);
58
-		$limit = $modx->db->getValue($rs);
59
-		if($limit==1) $permissionsok = true;
56
+            "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)"
57
+            );
58
+        $limit = $modx->db->getValue($rs);
59
+        if($limit==1) $permissionsok = true;
60 60
 		
61
-		return $permissionsok;
62
-	}
61
+        return $permissionsok;
62
+    }
63 63
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	var $role;
8 8
 	var $duplicateDoc = false;
9 9
 	
10
-	function checkPermissions() {
10
+	function checkPermissions(){
11 11
 		
12 12
 		global $udperms_allowroot;
13 13
 		global $modx;
@@ -19,23 +19,23 @@  discard block
 block discarded – undo
19 19
 		$document = $this->document;
20 20
 		$role = $this->role;
21 21
 
22
-		if($role==1) {
23
-			return true;  // administrator - grant all document permissions
22
+		if ($role == 1) {
23
+			return true; // administrator - grant all document permissions
24 24
 		}
25 25
 		
26
-		if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) {
26
+		if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) {
27 27
 			return true; // permissions aren't in use
28 28
 		}
29 29
 		
30 30
 		$parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'"));
31
-		if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
32
-		if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) {
31
+		if ($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
32
+		if (($this->duplicateDoc == true || $document == 0) && $parent == 0 && $udperms_allowroot == 0) {
33 33
 			return false; // deny duplicate || create new document at root if Allow Root is No
34 34
 		}
35 35
 		
36 36
 		// get document groups for current user
37
-		if($_SESSION['mgrDocgroups']) {
38
-			$docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']);
37
+		if ($_SESSION['mgrDocgroups']) {
38
+			$docgrp = implode(" || dg.document_group = ", $_SESSION['mgrDocgroups']);
39 39
 		}
40 40
 
41 41
 		/* Note:
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
 			are private to the manager users will not be private to web users if the 
47 47
 			document group is not assigned to a web user group and visa versa.
48 48
 		 */
49
-		$permissionsok = false;  // set permissions to false
49
+		$permissionsok = false; // set permissions to false
50 50
 		
51 51
 		$rs = $modx->db->select(
52 52
 			'count(DISTINCT sc.id)',
53 53
 			"{$tblsc} AS sc 
54 54
 				LEFT JOIN {$tbldg} AS dg on dg.document = sc.id 
55 55
 				LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group",
56
-			"sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)"
56
+			"sc.id='{$this->document}' AND (".((!$docgrp) ? null : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)"
57 57
 			);
58 58
 		$limit = $modx->db->getValue($rs);
59
-		if($limit==1) $permissionsok = true;
59
+		if ($limit == 1) $permissionsok = true;
60 60
 		
61 61
 		return $permissionsok;
62 62
 	}
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,13 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class udperms{
3
+class udperms
4
+{
4 5
 
5 6
 	var $user;
6 7
 	var $document;
7 8
 	var $role;
8 9
 	var $duplicateDoc = false;
9 10
 	
10
-	function checkPermissions() {
11
+	function checkPermissions()
12
+	{
11 13
 		
12 14
 		global $udperms_allowroot;
13 15
 		global $modx;
@@ -28,7 +30,10 @@  discard block
 block discarded – undo
28 30
 		}
29 31
 		
30 32
 		$parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'"));
31
-		if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
33
+		if($document == 0 && $parent == NULL && $udperms_allowroot == 1) {
34
+		    return true;
35
+		}
36
+		// User is allowed to create new document in root
32 37
 		if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) {
33 38
 			return false; // deny duplicate || create new document at root if Allow Root is No
34 39
 		}
@@ -56,7 +61,9 @@  discard block
 block discarded – undo
56 61
 			"sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)"
57 62
 			);
58 63
 		$limit = $modx->db->getValue($rs);
59
-		if($limit==1) $permissionsok = true;
64
+		if($limit==1) {
65
+		    $permissionsok = true;
66
+		}
60 67
 		
61 68
 		return $permissionsok;
62 69
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 		}
29 29
 		
30 30
 		$parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'"));
31
-		if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
31
+		if($document == 0 && $parent == null && $udperms_allowroot == 1) return true; // User is allowed to create new document in root
32 32
 		if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) {
33 33
 			return false; // deny duplicate || create new document at root if Allow Root is No
34 34
 		}
Please login to merge, or discard this patch.
manager/processors/save_user.processor.php 4 patches
Indentation   +368 added lines, -368 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 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.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('save_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $modx->loadExtension('phpass');
@@ -45,134 +45,134 @@  discard block
 block discarded – undo
45 45
 
46 46
 // verify password
47 47
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
48
-	webAlertAndQuit("Password typed is mismatched");
48
+    webAlertAndQuit("Password typed is mismatched");
49 49
 }
50 50
 
51 51
 // verify email
52 52
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
53
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
53
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
54 54
 }
55 55
 
56 56
 // verify admin security
57 57
 if($_SESSION['mgrRole'] != 1) {
58
-	// Check to see if user tried to spoof a "1" (admin) role
59
-	if(!$modx->hasPermission('save_role')) {
60
-		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61
-	}
62
-	// Verify that the user being edited wasn't an admin and the user ID got spoofed
63
-	$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64
-	$limit = $modx->db->getValue($rs);
65
-	if($limit > 0) {
66
-		webAlertAndQuit("You cannot alter an administrative user.");
67
-	}
58
+    // Check to see if user tried to spoof a "1" (admin) role
59
+    if(!$modx->hasPermission('save_role')) {
60
+        webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61
+    }
62
+    // Verify that the user being edited wasn't an admin and the user ID got spoofed
63
+    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64
+    $limit = $modx->db->getValue($rs);
65
+    if($limit > 0) {
66
+        webAlertAndQuit("You cannot alter an administrative user.");
67
+    }
68 68
 
69 69
 }
70 70
 
71 71
 switch($input['mode']) {
72
-	case '11' : // new user
73
-		// check if this user name already exist
74
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
-		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
77
-			webAlertAndQuit("User name is already in use!");
78
-		}
79
-
80
-		// check if the email address already exist
81
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
-		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
84
-			webAlertAndQuit("Email is already in use!");
85
-		}
86
-
87
-		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
90
-				webAlertAndQuit("Password is too short!");
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!");
100
-		}
101
-
102
-		// invoke OnBeforeUserFormSave event
103
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
104
-			"mode" => "new",
105
-		));
106
-
107
-		// create the user account
108
-		$internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
-
110
-		$field = array();
111
-		$field['password'] = $modx->phpass->HashPassword($newpassword);
112
-		$modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
-
114
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
-		$field = $modx->db->escape($field);
116
-		$modx->db->insert($field, $tbl_user_attributes);
117
-
118
-		// Save user settings
119
-		saveUserSettings($internalKey);
120
-
121
-		// invoke OnManagerSaveUser event
122
-		$modx->invokeEvent("OnManagerSaveUser", array(
123
-			"mode" => "new",
124
-			"userid" => $internalKey,
125
-			"username" => $newusername,
126
-			"userpassword" => $newpassword,
127
-			"useremail" => $email,
128
-			"userfullname" => $fullname,
129
-			"userroleid" => $role
130
-		));
131
-
132
-		// invoke OnUserFormSave event
133
-		$modx->invokeEvent("OnUserFormSave", array(
134
-			"mode" => "new",
135
-			"id" => $internalKey
136
-		));
137
-
138
-		// Set the item name for logger
139
-		$_SESSION['itemname'] = $newusername;
140
-
141
-		/*******************************************************************************/
142
-		// put the user in the user_groups he/ she should be in
143
-		// first, check that up_perms are switched on!
144
-		if($use_udperms == 1) {
145
-			if(!empty($user_groups)) {
146
-				for($i = 0; $i < count($user_groups); $i++) {
147
-					$f = array();
148
-					$f['user_group'] = intval($user_groups[$i]);
149
-					$f['member'] = $internalKey;
150
-					$modx->db->insert($f, $tbl_member_groups);
151
-				}
152
-			}
153
-		}
154
-		// end of user_groups stuff!
155
-
156
-		if($passwordnotifymethod == 'e') {
157
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-				header($header);
162
-			} else {
163
-				$header = "Location: index.php?a=75&r=2";
164
-				header($header);
165
-			}
166
-		} else {
167
-			if($input['stay'] != '') {
168
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
-			} else {
171
-				$stayUrl = "index.php?a=75&r=2";
172
-			}
173
-
174
-			include_once "header.inc.php";
175
-			?>
72
+    case '11' : // new user
73
+        // check if this user name already exist
74
+        $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
+        $limit = $modx->db->getValue($rs);
76
+        if($limit > 0) {
77
+            webAlertAndQuit("User name is already in use!");
78
+        }
79
+
80
+        // check if the email address already exist
81
+        $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
+        $limit = $modx->db->getValue($rs);
83
+        if($limit > 0) {
84
+            webAlertAndQuit("Email is already in use!");
85
+        }
86
+
87
+        // generate a new password for this user
88
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+            if(strlen($specifiedpassword) < 6) {
90
+                webAlertAndQuit("Password is too short!");
91
+            } else {
92
+                $newpassword = $specifiedpassword;
93
+            }
94
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+            webAlertAndQuit("You didn't specify a password for this user!");
96
+        } elseif($passwordgenmethod == 'g') {
97
+            $newpassword = generate_password(8);
98
+        } else {
99
+            webAlertAndQuit("No password generation method specified!");
100
+        }
101
+
102
+        // invoke OnBeforeUserFormSave event
103
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
104
+            "mode" => "new",
105
+        ));
106
+
107
+        // create the user account
108
+        $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
+
110
+        $field = array();
111
+        $field['password'] = $modx->phpass->HashPassword($newpassword);
112
+        $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
+
114
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
+        $field = $modx->db->escape($field);
116
+        $modx->db->insert($field, $tbl_user_attributes);
117
+
118
+        // Save user settings
119
+        saveUserSettings($internalKey);
120
+
121
+        // invoke OnManagerSaveUser event
122
+        $modx->invokeEvent("OnManagerSaveUser", array(
123
+            "mode" => "new",
124
+            "userid" => $internalKey,
125
+            "username" => $newusername,
126
+            "userpassword" => $newpassword,
127
+            "useremail" => $email,
128
+            "userfullname" => $fullname,
129
+            "userroleid" => $role
130
+        ));
131
+
132
+        // invoke OnUserFormSave event
133
+        $modx->invokeEvent("OnUserFormSave", array(
134
+            "mode" => "new",
135
+            "id" => $internalKey
136
+        ));
137
+
138
+        // Set the item name for logger
139
+        $_SESSION['itemname'] = $newusername;
140
+
141
+        /*******************************************************************************/
142
+        // put the user in the user_groups he/ she should be in
143
+        // first, check that up_perms are switched on!
144
+        if($use_udperms == 1) {
145
+            if(!empty($user_groups)) {
146
+                for($i = 0; $i < count($user_groups); $i++) {
147
+                    $f = array();
148
+                    $f['user_group'] = intval($user_groups[$i]);
149
+                    $f['member'] = $internalKey;
150
+                    $modx->db->insert($f, $tbl_member_groups);
151
+                }
152
+            }
153
+        }
154
+        // end of user_groups stuff!
155
+
156
+        if($passwordnotifymethod == 'e') {
157
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
158
+            if($input['stay'] != '') {
159
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+                header($header);
162
+            } else {
163
+                $header = "Location: index.php?a=75&r=2";
164
+                header($header);
165
+            }
166
+        } else {
167
+            if($input['stay'] != '') {
168
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
+            } else {
171
+                $stayUrl = "index.php?a=75&r=2";
172
+            }
173
+
174
+            include_once "header.inc.php";
175
+            ?>
176 176
 
177 177
 			<h1><?php echo $_lang['user_title']; ?></h1>
178 178
 
@@ -194,125 +194,125 @@  discard block
 block discarded – undo
194 194
 			</div>
195 195
 			<?php
196 196
 
197
-			include_once "footer.inc.php";
198
-		}
199
-		break;
200
-	case '12' : // edit user
201
-		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
205
-					webAlertAndQuit("Password is too short!");
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!");
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
218
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
219
-		}
220
-
221
-		// check if the username already exist
222
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
-		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
225
-			webAlertAndQuit("User name is already in use!");
226
-		}
227
-
228
-		// check if the email address already exists
229
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
-		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
232
-			webAlertAndQuit("Email is already in use!");
233
-		}
234
-
235
-		// invoke OnBeforeUserFormSave event
236
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
237
-			"mode" => "upd",
238
-			"id" => $id
239
-		));
240
-
241
-		// update user name and password
242
-		$field = array();
243
-		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
245
-			$field['password'] = $modx->phpass->HashPassword($newpassword);
246
-		}
247
-		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
-		$field = $modx->db->escape($field);
250
-		$modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
-
252
-		// Save user settings
253
-		saveUserSettings($id);
254
-
255
-		// Set the item name for logger
256
-		$_SESSION['itemname'] = $newusername;
257
-
258
-		// invoke OnManagerSaveUser event
259
-		$modx->invokeEvent("OnManagerSaveUser", array(
260
-			"mode" => "upd",
261
-			"userid" => $id,
262
-			"username" => $newusername,
263
-			"userpassword" => $newpassword,
264
-			"useremail" => $email,
265
-			"userfullname" => $fullname,
266
-			"userroleid" => $role,
267
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
-		));
270
-
271
-		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
273
-			$modx->invokeEvent("OnManagerChangePassword", array(
274
-				"userid" => $id,
275
-				"username" => $newusername,
276
-				"userpassword" => $newpassword
277
-			));
278
-		}
279
-
280
-		// invoke OnUserFormSave event
281
-		$modx->invokeEvent("OnUserFormSave", array(
282
-			"mode" => "upd",
283
-			"id" => $id
284
-		));
285
-
286
-		/*******************************************************************************/
287
-		// put the user in the user_groups he/ she should be in
288
-		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
290
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
-			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
294
-					$field = array();
295
-					$field['user_group'] = intval($user_groups[$i]);
296
-					$field['member'] = $id;
297
-					$modx->db->insert($field, $tbl_member_groups);
298
-				}
299
-			}
300
-		}
301
-		// end of user_groups stuff!
302
-		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
-		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
308
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
-			} else {
311
-				$stayUrl = "index.php?a=75&r=2";
312
-			}
313
-
314
-			include_once "header.inc.php";
315
-			?>
197
+            include_once "footer.inc.php";
198
+        }
199
+        break;
200
+    case '12' : // edit user
201
+        // generate a new password for this user
202
+        if($genpassword == 1) {
203
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+                if(strlen($specifiedpassword) < 6) {
205
+                    webAlertAndQuit("Password is too short!");
206
+                } else {
207
+                    $newpassword = $specifiedpassword;
208
+                }
209
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+                webAlertAndQuit("You didn't specify a password for this user!");
211
+            } elseif($passwordgenmethod == 'g') {
212
+                $newpassword = generate_password(8);
213
+            } else {
214
+                webAlertAndQuit("No password generation method specified!");
215
+            }
216
+        }
217
+        if($passwordnotifymethod == 'e') {
218
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
219
+        }
220
+
221
+        // check if the username already exist
222
+        $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
+        $limit = $modx->db->getValue($rs);
224
+        if($limit > 0) {
225
+            webAlertAndQuit("User name is already in use!");
226
+        }
227
+
228
+        // check if the email address already exists
229
+        $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
+        $limit = $modx->db->getValue($rs);
231
+        if($limit > 0) {
232
+            webAlertAndQuit("Email is already in use!");
233
+        }
234
+
235
+        // invoke OnBeforeUserFormSave event
236
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
237
+            "mode" => "upd",
238
+            "id" => $id
239
+        ));
240
+
241
+        // update user name and password
242
+        $field = array();
243
+        $field['username'] = $modx->db->escape($newusername);
244
+        if($genpassword == 1) {
245
+            $field['password'] = $modx->phpass->HashPassword($newpassword);
246
+        }
247
+        $modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
+        $field = $modx->db->escape($field);
250
+        $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
+
252
+        // Save user settings
253
+        saveUserSettings($id);
254
+
255
+        // Set the item name for logger
256
+        $_SESSION['itemname'] = $newusername;
257
+
258
+        // invoke OnManagerSaveUser event
259
+        $modx->invokeEvent("OnManagerSaveUser", array(
260
+            "mode" => "upd",
261
+            "userid" => $id,
262
+            "username" => $newusername,
263
+            "userpassword" => $newpassword,
264
+            "useremail" => $email,
265
+            "userfullname" => $fullname,
266
+            "userroleid" => $role,
267
+            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
+            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
+        ));
270
+
271
+        // invoke OnManagerChangePassword event
272
+        if($genpassword == 1) {
273
+            $modx->invokeEvent("OnManagerChangePassword", array(
274
+                "userid" => $id,
275
+                "username" => $newusername,
276
+                "userpassword" => $newpassword
277
+            ));
278
+        }
279
+
280
+        // invoke OnUserFormSave event
281
+        $modx->invokeEvent("OnUserFormSave", array(
282
+            "mode" => "upd",
283
+            "id" => $id
284
+        ));
285
+
286
+        /*******************************************************************************/
287
+        // put the user in the user_groups he/ she should be in
288
+        // first, check that up_perms are switched on!
289
+        if($use_udperms == 1) {
290
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
+            $modx->db->delete($tbl_member_groups, "member='{$id}'");
292
+            if(!empty($user_groups)) {
293
+                for($i = 0; $i < count($user_groups); $i++) {
294
+                    $field = array();
295
+                    $field['user_group'] = intval($user_groups[$i]);
296
+                    $field['member'] = $id;
297
+                    $modx->db->insert($field, $tbl_member_groups);
298
+                }
299
+            }
300
+        }
301
+        // end of user_groups stuff!
302
+        /*******************************************************************************/
303
+        if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
+            $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
+        }
306
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
307
+            if($input['stay'] != '') {
308
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
+            } else {
311
+                $stayUrl = "index.php?a=75&r=2";
312
+            }
313
+
314
+            include_once "header.inc.php";
315
+            ?>
316 316
 
317 317
 			<h1><?php echo $_lang['user_title']; ?></h1>
318 318
 
@@ -332,151 +332,151 @@  discard block
 block discarded – undo
332 332
 			</div>
333 333
 			<?php
334 334
 
335
-			include_once "footer.inc.php";
336
-		} else {
337
-			if($input['stay'] != '') {
338
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
-				header($header);
341
-			} else {
342
-				$header = "Location: index.php?a=75&r=2";
343
-				header($header);
344
-			}
345
-		}
346
-		break;
347
-	default:
348
-		webAlertAndQuit("No operation set in request.");
335
+            include_once "footer.inc.php";
336
+        } else {
337
+            if($input['stay'] != '') {
338
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
+                header($header);
341
+            } else {
342
+                $header = "Location: index.php?a=75&r=2";
343
+                header($header);
344
+            }
345
+        }
346
+        break;
347
+    default:
348
+        webAlertAndQuit("No operation set in request.");
349 349
 }
350 350
 
351 351
 // Send an email to the user
352 352
 function sendMailMessage($email, $uid, $pwd, $ufn) {
353
-	global $modx, $_lang, $signupemail_message;
354
-	global $emailsubject, $emailsender;
355
-	global $site_name;
356
-	$manager_url = MODX_MANAGER_URL;
357
-	$message = sprintf($signupemail_message, $uid, $pwd); // use old method
358
-	// replace placeholders
359
-	$message = str_replace("[+uid+]", $uid, $message);
360
-	$message = str_replace("[+pwd+]", $pwd, $message);
361
-	$message = str_replace("[+ufn+]", $ufn, $message);
362
-	$message = str_replace("[+sname+]", $site_name, $message);
363
-	$message = str_replace("[+saddr+]", $emailsender, $message);
364
-	$message = str_replace("[+semail+]", $emailsender, $message);
365
-	$message = str_replace("[+surl+]", $manager_url, $message);
366
-
367
-	$param = array();
368
-	$param['from'] = "{$site_name}<{$emailsender}>";
369
-	$param['subject'] = $emailsubject;
370
-	$param['body'] = $message;
371
-	$param['to'] = $email;
372
-	$param['type'] = 'text';
373
-	$rs = $modx->sendmail($param);
374
-	if(!$rs) {
375
-		$modx->manager->saveFormValues();
376
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
377
-	}
353
+    global $modx, $_lang, $signupemail_message;
354
+    global $emailsubject, $emailsender;
355
+    global $site_name;
356
+    $manager_url = MODX_MANAGER_URL;
357
+    $message = sprintf($signupemail_message, $uid, $pwd); // use old method
358
+    // replace placeholders
359
+    $message = str_replace("[+uid+]", $uid, $message);
360
+    $message = str_replace("[+pwd+]", $pwd, $message);
361
+    $message = str_replace("[+ufn+]", $ufn, $message);
362
+    $message = str_replace("[+sname+]", $site_name, $message);
363
+    $message = str_replace("[+saddr+]", $emailsender, $message);
364
+    $message = str_replace("[+semail+]", $emailsender, $message);
365
+    $message = str_replace("[+surl+]", $manager_url, $message);
366
+
367
+    $param = array();
368
+    $param['from'] = "{$site_name}<{$emailsender}>";
369
+    $param['subject'] = $emailsubject;
370
+    $param['body'] = $message;
371
+    $param['to'] = $email;
372
+    $param['type'] = 'text';
373
+    $rs = $modx->sendmail($param);
374
+    if(!$rs) {
375
+        $modx->manager->saveFormValues();
376
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
377
+    }
378 378
 }
379 379
 
380 380
 // Save User Settings
381 381
 function saveUserSettings($id) {
382
-	global $modx;
383
-	$tbl_user_settings = $modx->getFullTableName('user_settings');
384
-
385
-	$ignore = array(
386
-		'id',
387
-		'oldusername',
388
-		'oldemail',
389
-		'newusername',
390
-		'fullname',
391
-		'newpassword',
392
-		'newpasswordcheck',
393
-		'passwordgenmethod',
394
-		'passwordnotifymethod',
395
-		'specifiedpassword',
396
-		'confirmpassword',
397
-		'email',
398
-		'phone',
399
-		'mobilephone',
400
-		'fax',
401
-		'dob',
402
-		'country',
403
-		'street',
404
-		'city',
405
-		'state',
406
-		'zip',
407
-		'gender',
408
-		'photo',
409
-		'comment',
410
-		'role',
411
-		'failedlogincount',
412
-		'blocked',
413
-		'blockeduntil',
414
-		'blockedafter',
415
-		'user_groups',
416
-		'mode',
417
-		'blockedmode',
418
-		'stay',
419
-		'save',
420
-		'theme_refresher'
421
-	);
422
-
423
-	// determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values)
424
-	$defaults = array(
425
-		'upload_images',
426
-		'upload_media',
427
-		'upload_flash',
428
-		'upload_files'
429
-	);
430
-
431
-	// get user setting field names
432
-	$settings = array();
433
-	foreach($_POST as $n => $v) {
434
-		if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
435
-			continue;
436
-		} // ignore blacklist and empties
437
-		$settings[$n] = $v; // this value should be saved
438
-	}
439
-
440
-	foreach($defaults as $k) {
441
-		if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
442
-			unset($settings[$k]);
443
-		}
444
-		unset($settings['default_' . $k]);
445
-	}
446
-
447
-	$modx->db->delete($tbl_user_settings, "user='{$id}'");
448
-
449
-	foreach($settings as $n => $vl) {
450
-		if(is_array($vl)) {
451
-			$vl = implode(",", $vl);
452
-		}
453
-		if($vl != '') {
454
-			$f = array();
455
-			$f['user'] = $id;
456
-			$f['setting_name'] = $n;
457
-			$f['setting_value'] = $vl;
458
-			$f = $modx->db->escape($f);
459
-			$modx->db->insert($f, $tbl_user_settings);
460
-		}
461
-	}
382
+    global $modx;
383
+    $tbl_user_settings = $modx->getFullTableName('user_settings');
384
+
385
+    $ignore = array(
386
+        'id',
387
+        'oldusername',
388
+        'oldemail',
389
+        'newusername',
390
+        'fullname',
391
+        'newpassword',
392
+        'newpasswordcheck',
393
+        'passwordgenmethod',
394
+        'passwordnotifymethod',
395
+        'specifiedpassword',
396
+        'confirmpassword',
397
+        'email',
398
+        'phone',
399
+        'mobilephone',
400
+        'fax',
401
+        'dob',
402
+        'country',
403
+        'street',
404
+        'city',
405
+        'state',
406
+        'zip',
407
+        'gender',
408
+        'photo',
409
+        'comment',
410
+        'role',
411
+        'failedlogincount',
412
+        'blocked',
413
+        'blockeduntil',
414
+        'blockedafter',
415
+        'user_groups',
416
+        'mode',
417
+        'blockedmode',
418
+        'stay',
419
+        'save',
420
+        'theme_refresher'
421
+    );
422
+
423
+    // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values)
424
+    $defaults = array(
425
+        'upload_images',
426
+        'upload_media',
427
+        'upload_flash',
428
+        'upload_files'
429
+    );
430
+
431
+    // get user setting field names
432
+    $settings = array();
433
+    foreach($_POST as $n => $v) {
434
+        if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
435
+            continue;
436
+        } // ignore blacklist and empties
437
+        $settings[$n] = $v; // this value should be saved
438
+    }
439
+
440
+    foreach($defaults as $k) {
441
+        if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
442
+            unset($settings[$k]);
443
+        }
444
+        unset($settings['default_' . $k]);
445
+    }
446
+
447
+    $modx->db->delete($tbl_user_settings, "user='{$id}'");
448
+
449
+    foreach($settings as $n => $vl) {
450
+        if(is_array($vl)) {
451
+            $vl = implode(",", $vl);
452
+        }
453
+        if($vl != '') {
454
+            $f = array();
455
+            $f['user'] = $id;
456
+            $f['setting_name'] = $n;
457
+            $f['setting_value'] = $vl;
458
+            $f = $modx->db->escape($f);
459
+            $modx->db->insert($f, $tbl_user_settings);
460
+        }
461
+    }
462 462
 }
463 463
 
464 464
 // Web alert -  sends an alert to web browser
465 465
 function webAlertAndQuit($msg) {
466
-	global $id, $modx;
467
-	$mode = $_POST['mode'];
468
-	$modx->manager->saveFormValues($mode);
469
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
466
+    global $id, $modx;
467
+    $mode = $_POST['mode'];
468
+    $modx->manager->saveFormValues($mode);
469
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
470 470
 }
471 471
 
472 472
 // Generate password
473 473
 function generate_password($length = 10) {
474
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
475
-	$ps_len = strlen($allowable_characters);
476
-	mt_srand((double) microtime() * 1000000);
477
-	$pass = "";
478
-	for($i = 0; $i < $length; $i++) {
479
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
480
-	}
481
-	return $pass;
474
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
475
+    $ps_len = strlen($allowable_characters);
476
+    mt_srand((double) microtime() * 1000000);
477
+    $pass = "";
478
+    for($i = 0; $i < $length; $i++) {
479
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
480
+    }
481
+    return $pass;
482 482
 }
Please login to merge, or discard this patch.
Switch Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -69,110 +69,110 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 switch($input['mode']) {
72
-	case '11' : // new user
73
-		// check if this user name already exist
74
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
-		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
77
-			webAlertAndQuit("User name is already in use!");
78
-		}
79
-
80
-		// check if the email address already exist
81
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
-		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
84
-			webAlertAndQuit("Email is already in use!");
85
-		}
86
-
87
-		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
90
-				webAlertAndQuit("Password is too short!");
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!");
100
-		}
101
-
102
-		// invoke OnBeforeUserFormSave event
103
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
104
-			"mode" => "new",
105
-		));
106
-
107
-		// create the user account
108
-		$internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
-
110
-		$field = array();
111
-		$field['password'] = $modx->phpass->HashPassword($newpassword);
112
-		$modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
-
114
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
-		$field = $modx->db->escape($field);
116
-		$modx->db->insert($field, $tbl_user_attributes);
117
-
118
-		// Save user settings
119
-		saveUserSettings($internalKey);
120
-
121
-		// invoke OnManagerSaveUser event
122
-		$modx->invokeEvent("OnManagerSaveUser", array(
123
-			"mode" => "new",
124
-			"userid" => $internalKey,
125
-			"username" => $newusername,
126
-			"userpassword" => $newpassword,
127
-			"useremail" => $email,
128
-			"userfullname" => $fullname,
129
-			"userroleid" => $role
130
-		));
131
-
132
-		// invoke OnUserFormSave event
133
-		$modx->invokeEvent("OnUserFormSave", array(
134
-			"mode" => "new",
135
-			"id" => $internalKey
136
-		));
137
-
138
-		// Set the item name for logger
139
-		$_SESSION['itemname'] = $newusername;
140
-
141
-		/*******************************************************************************/
142
-		// put the user in the user_groups he/ she should be in
143
-		// first, check that up_perms are switched on!
144
-		if($use_udperms == 1) {
145
-			if(!empty($user_groups)) {
146
-				for($i = 0; $i < count($user_groups); $i++) {
147
-					$f = array();
148
-					$f['user_group'] = intval($user_groups[$i]);
149
-					$f['member'] = $internalKey;
150
-					$modx->db->insert($f, $tbl_member_groups);
151
-				}
152
-			}
153
-		}
154
-		// end of user_groups stuff!
155
-
156
-		if($passwordnotifymethod == 'e') {
157
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-				header($header);
162
-			} else {
163
-				$header = "Location: index.php?a=75&r=2";
164
-				header($header);
165
-			}
166
-		} else {
167
-			if($input['stay'] != '') {
168
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
-			} else {
171
-				$stayUrl = "index.php?a=75&r=2";
172
-			}
173
-
174
-			include_once "header.inc.php";
175
-			?>
72
+	    case '11' : // new user
73
+		    // check if this user name already exist
74
+		    $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
+		    $limit = $modx->db->getValue($rs);
76
+		    if($limit > 0) {
77
+			    webAlertAndQuit("User name is already in use!");
78
+		    }
79
+
80
+		    // check if the email address already exist
81
+		    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
+		    $limit = $modx->db->getValue($rs);
83
+		    if($limit > 0) {
84
+			    webAlertAndQuit("Email is already in use!");
85
+		    }
86
+
87
+		    // generate a new password for this user
88
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+			    if(strlen($specifiedpassword) < 6) {
90
+				    webAlertAndQuit("Password is too short!");
91
+			    } else {
92
+				    $newpassword = $specifiedpassword;
93
+			    }
94
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+			    webAlertAndQuit("You didn't specify a password for this user!");
96
+		    } elseif($passwordgenmethod == 'g') {
97
+			    $newpassword = generate_password(8);
98
+		    } else {
99
+			    webAlertAndQuit("No password generation method specified!");
100
+		    }
101
+
102
+		    // invoke OnBeforeUserFormSave event
103
+		    $modx->invokeEvent("OnBeforeUserFormSave", array(
104
+			    "mode" => "new",
105
+		    ));
106
+
107
+		    // create the user account
108
+		    $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
+
110
+		    $field = array();
111
+		    $field['password'] = $modx->phpass->HashPassword($newpassword);
112
+		    $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
+
114
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
+		    $field = $modx->db->escape($field);
116
+		    $modx->db->insert($field, $tbl_user_attributes);
117
+
118
+		    // Save user settings
119
+		    saveUserSettings($internalKey);
120
+
121
+		    // invoke OnManagerSaveUser event
122
+		    $modx->invokeEvent("OnManagerSaveUser", array(
123
+			    "mode" => "new",
124
+			    "userid" => $internalKey,
125
+			    "username" => $newusername,
126
+			    "userpassword" => $newpassword,
127
+			    "useremail" => $email,
128
+			    "userfullname" => $fullname,
129
+			    "userroleid" => $role
130
+		    ));
131
+
132
+		    // invoke OnUserFormSave event
133
+		    $modx->invokeEvent("OnUserFormSave", array(
134
+			    "mode" => "new",
135
+			    "id" => $internalKey
136
+		    ));
137
+
138
+		    // Set the item name for logger
139
+		    $_SESSION['itemname'] = $newusername;
140
+
141
+		    /*******************************************************************************/
142
+		    // put the user in the user_groups he/ she should be in
143
+		    // first, check that up_perms are switched on!
144
+		    if($use_udperms == 1) {
145
+			    if(!empty($user_groups)) {
146
+				    for($i = 0; $i < count($user_groups); $i++) {
147
+					    $f = array();
148
+					    $f['user_group'] = intval($user_groups[$i]);
149
+					    $f['member'] = $internalKey;
150
+					    $modx->db->insert($f, $tbl_member_groups);
151
+				    }
152
+			    }
153
+		    }
154
+		    // end of user_groups stuff!
155
+
156
+		    if($passwordnotifymethod == 'e') {
157
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
158
+			    if($input['stay'] != '') {
159
+				    $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+				    header($header);
162
+			    } else {
163
+				    $header = "Location: index.php?a=75&r=2";
164
+				    header($header);
165
+			    }
166
+		    } else {
167
+			    if($input['stay'] != '') {
168
+				    $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
+			    } else {
171
+				    $stayUrl = "index.php?a=75&r=2";
172
+			    }
173
+
174
+			    include_once "header.inc.php";
175
+			    ?>
176 176
 
177 177
 			<h1><?php echo $_lang['user_title']; ?></h1>
178 178
 
@@ -194,125 +194,125 @@  discard block
 block discarded – undo
194 194
 			</div>
195 195
 			<?php
196 196
 
197
-			include_once "footer.inc.php";
198
-		}
199
-		break;
200
-	case '12' : // edit user
201
-		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
205
-					webAlertAndQuit("Password is too short!");
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!");
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
218
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
219
-		}
220
-
221
-		// check if the username already exist
222
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
-		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
225
-			webAlertAndQuit("User name is already in use!");
226
-		}
227
-
228
-		// check if the email address already exists
229
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
-		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
232
-			webAlertAndQuit("Email is already in use!");
233
-		}
234
-
235
-		// invoke OnBeforeUserFormSave event
236
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
237
-			"mode" => "upd",
238
-			"id" => $id
239
-		));
240
-
241
-		// update user name and password
242
-		$field = array();
243
-		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
245
-			$field['password'] = $modx->phpass->HashPassword($newpassword);
246
-		}
247
-		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
-		$field = $modx->db->escape($field);
250
-		$modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
-
252
-		// Save user settings
253
-		saveUserSettings($id);
254
-
255
-		// Set the item name for logger
256
-		$_SESSION['itemname'] = $newusername;
257
-
258
-		// invoke OnManagerSaveUser event
259
-		$modx->invokeEvent("OnManagerSaveUser", array(
260
-			"mode" => "upd",
261
-			"userid" => $id,
262
-			"username" => $newusername,
263
-			"userpassword" => $newpassword,
264
-			"useremail" => $email,
265
-			"userfullname" => $fullname,
266
-			"userroleid" => $role,
267
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
-		));
270
-
271
-		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
273
-			$modx->invokeEvent("OnManagerChangePassword", array(
274
-				"userid" => $id,
275
-				"username" => $newusername,
276
-				"userpassword" => $newpassword
277
-			));
278
-		}
279
-
280
-		// invoke OnUserFormSave event
281
-		$modx->invokeEvent("OnUserFormSave", array(
282
-			"mode" => "upd",
283
-			"id" => $id
284
-		));
285
-
286
-		/*******************************************************************************/
287
-		// put the user in the user_groups he/ she should be in
288
-		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
290
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
-			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
294
-					$field = array();
295
-					$field['user_group'] = intval($user_groups[$i]);
296
-					$field['member'] = $id;
297
-					$modx->db->insert($field, $tbl_member_groups);
298
-				}
299
-			}
300
-		}
301
-		// end of user_groups stuff!
302
-		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
-		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
308
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
-			} else {
311
-				$stayUrl = "index.php?a=75&r=2";
312
-			}
313
-
314
-			include_once "header.inc.php";
315
-			?>
197
+			    include_once "footer.inc.php";
198
+		    }
199
+		    break;
200
+	    case '12' : // edit user
201
+		    // generate a new password for this user
202
+		    if($genpassword == 1) {
203
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+				    if(strlen($specifiedpassword) < 6) {
205
+					    webAlertAndQuit("Password is too short!");
206
+				    } else {
207
+					    $newpassword = $specifiedpassword;
208
+				    }
209
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+				    webAlertAndQuit("You didn't specify a password for this user!");
211
+			    } elseif($passwordgenmethod == 'g') {
212
+				    $newpassword = generate_password(8);
213
+			    } else {
214
+				    webAlertAndQuit("No password generation method specified!");
215
+			    }
216
+		    }
217
+		    if($passwordnotifymethod == 'e') {
218
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
219
+		    }
220
+
221
+		    // check if the username already exist
222
+		    $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
+		    $limit = $modx->db->getValue($rs);
224
+		    if($limit > 0) {
225
+			    webAlertAndQuit("User name is already in use!");
226
+		    }
227
+
228
+		    // check if the email address already exists
229
+		    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
+		    $limit = $modx->db->getValue($rs);
231
+		    if($limit > 0) {
232
+			    webAlertAndQuit("Email is already in use!");
233
+		    }
234
+
235
+		    // invoke OnBeforeUserFormSave event
236
+		    $modx->invokeEvent("OnBeforeUserFormSave", array(
237
+			    "mode" => "upd",
238
+			    "id" => $id
239
+		    ));
240
+
241
+		    // update user name and password
242
+		    $field = array();
243
+		    $field['username'] = $modx->db->escape($newusername);
244
+		    if($genpassword == 1) {
245
+			    $field['password'] = $modx->phpass->HashPassword($newpassword);
246
+		    }
247
+		    $modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
+		    $field = $modx->db->escape($field);
250
+		    $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
+
252
+		    // Save user settings
253
+		    saveUserSettings($id);
254
+
255
+		    // Set the item name for logger
256
+		    $_SESSION['itemname'] = $newusername;
257
+
258
+		    // invoke OnManagerSaveUser event
259
+		    $modx->invokeEvent("OnManagerSaveUser", array(
260
+			    "mode" => "upd",
261
+			    "userid" => $id,
262
+			    "username" => $newusername,
263
+			    "userpassword" => $newpassword,
264
+			    "useremail" => $email,
265
+			    "userfullname" => $fullname,
266
+			    "userroleid" => $role,
267
+			    "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
+			    "olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
+		    ));
270
+
271
+		    // invoke OnManagerChangePassword event
272
+		    if($genpassword == 1) {
273
+			    $modx->invokeEvent("OnManagerChangePassword", array(
274
+				    "userid" => $id,
275
+				    "username" => $newusername,
276
+				    "userpassword" => $newpassword
277
+			    ));
278
+		    }
279
+
280
+		    // invoke OnUserFormSave event
281
+		    $modx->invokeEvent("OnUserFormSave", array(
282
+			    "mode" => "upd",
283
+			    "id" => $id
284
+		    ));
285
+
286
+		    /*******************************************************************************/
287
+		    // put the user in the user_groups he/ she should be in
288
+		    // first, check that up_perms are switched on!
289
+		    if($use_udperms == 1) {
290
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
+			    $modx->db->delete($tbl_member_groups, "member='{$id}'");
292
+			    if(!empty($user_groups)) {
293
+				    for($i = 0; $i < count($user_groups); $i++) {
294
+					    $field = array();
295
+					    $field['user_group'] = intval($user_groups[$i]);
296
+					    $field['member'] = $id;
297
+					    $modx->db->insert($field, $tbl_member_groups);
298
+				    }
299
+			    }
300
+		    }
301
+		    // end of user_groups stuff!
302
+		    /*******************************************************************************/
303
+		    if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
+			    $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
+		    }
306
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
307
+			    if($input['stay'] != '') {
308
+				    $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
+			    } else {
311
+				    $stayUrl = "index.php?a=75&r=2";
312
+			    }
313
+
314
+			    include_once "header.inc.php";
315
+			    ?>
316 316
 
317 317
 			<h1><?php echo $_lang['user_title']; ?></h1>
318 318
 
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
 			</div>
333 333
 			<?php
334 334
 
335
-			include_once "footer.inc.php";
336
-		} else {
337
-			if($input['stay'] != '') {
338
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
-				header($header);
341
-			} else {
342
-				$header = "Location: index.php?a=75&r=2";
343
-				header($header);
344
-			}
345
-		}
346
-		break;
347
-	default:
348
-		webAlertAndQuit("No operation set in request.");
335
+			    include_once "footer.inc.php";
336
+		    } else {
337
+			    if($input['stay'] != '') {
338
+				    $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
+				    header($header);
341
+			    } else {
342
+				    $header = "Location: index.php?a=75&r=2";
343
+				    header($header);
344
+			    }
345
+		    }
346
+		    break;
347
+	    default:
348
+		    webAlertAndQuit("No operation set in request.");
349 349
 }
350 350
 
351 351
 // Send an email to the user
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
-if(!$modx->hasPermission('save_user')) {
5
+if (!$modx->hasPermission('save_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -44,56 +44,56 @@  discard block
 block discarded – undo
44 44
 $user_groups = $input['user_groups'];
45 45
 
46 46
 // verify password
47
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
47
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
48 48
 	webAlertAndQuit("Password typed is mismatched");
49 49
 }
50 50
 
51 51
 // verify email
52
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
52
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
53 53
 	webAlertAndQuit("E-mail address doesn't seem to be valid!");
54 54
 }
55 55
 
56 56
 // verify admin security
57
-if($_SESSION['mgrRole'] != 1) {
57
+if ($_SESSION['mgrRole'] != 1) {
58 58
 	// Check to see if user tried to spoof a "1" (admin) role
59
-	if(!$modx->hasPermission('save_role')) {
59
+	if (!$modx->hasPermission('save_role')) {
60 60
 		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61 61
 	}
62 62
 	// Verify that the user being edited wasn't an admin and the user ID got spoofed
63 63
 	$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64 64
 	$limit = $modx->db->getValue($rs);
65
-	if($limit > 0) {
65
+	if ($limit > 0) {
66 66
 		webAlertAndQuit("You cannot alter an administrative user.");
67 67
 	}
68 68
 
69 69
 }
70 70
 
71
-switch($input['mode']) {
71
+switch ($input['mode']) {
72 72
 	case '11' : // new user
73 73
 		// check if this user name already exist
74 74
 		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75 75
 		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
76
+		if ($limit > 0) {
77 77
 			webAlertAndQuit("User name is already in use!");
78 78
 		}
79 79
 
80 80
 		// check if the email address already exist
81 81
 		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82 82
 		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
83
+		if ($limit > 0) {
84 84
 			webAlertAndQuit("Email is already in use!");
85 85
 		}
86 86
 
87 87
 		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
88
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+			if (strlen($specifiedpassword) < 6) {
90 90
 				webAlertAndQuit("Password is too short!");
91 91
 			} else {
92 92
 				$newpassword = $specifiedpassword;
93 93
 			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
94
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
95 95
 			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
96
+		} elseif ($passwordgenmethod == 'g') {
97 97
 			$newpassword = generate_password(8);
98 98
 		} else {
99 99
 			webAlertAndQuit("No password generation method specified!");
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		/*******************************************************************************/
142 142
 		// put the user in the user_groups he/ she should be in
143 143
 		// first, check that up_perms are switched on!
144
-		if($use_udperms == 1) {
145
-			if(!empty($user_groups)) {
146
-				for($i = 0; $i < count($user_groups); $i++) {
144
+		if ($use_udperms == 1) {
145
+			if (!empty($user_groups)) {
146
+				for ($i = 0; $i < count($user_groups); $i++) {
147 147
 					$f = array();
148 148
 					$f['user_group'] = intval($user_groups[$i]);
149 149
 					$f['member'] = $internalKey;
@@ -153,20 +153,20 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 		// end of user_groups stuff!
155 155
 
156
-		if($passwordnotifymethod == 'e') {
156
+		if ($passwordnotifymethod == 'e') {
157 157
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
158
+			if ($input['stay'] != '') {
159 159
 				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
160
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
161 161
 				header($header);
162 162
 			} else {
163 163
 				$header = "Location: index.php?a=75&r=2";
164 164
 				header($header);
165 165
 			}
166 166
 		} else {
167
-			if($input['stay'] != '') {
167
+			if ($input['stay'] != '') {
168 168
 				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
169
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
170 170
 			} else {
171 171
 				$stayUrl = "index.php?a=75&r=2";
172 172
 			}
@@ -199,36 +199,36 @@  discard block
 block discarded – undo
199 199
 		break;
200 200
 	case '12' : // edit user
201 201
 		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
202
+		if ($genpassword == 1) {
203
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+				if (strlen($specifiedpassword) < 6) {
205 205
 					webAlertAndQuit("Password is too short!");
206 206
 				} else {
207 207
 					$newpassword = $specifiedpassword;
208 208
 				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
209
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
210 210
 				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
211
+			} elseif ($passwordgenmethod == 'g') {
212 212
 				$newpassword = generate_password(8);
213 213
 			} else {
214 214
 				webAlertAndQuit("No password generation method specified!");
215 215
 			}
216 216
 		}
217
-		if($passwordnotifymethod == 'e') {
217
+		if ($passwordnotifymethod == 'e') {
218 218
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
219 219
 		}
220 220
 
221 221
 		// check if the username already exist
222 222
 		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223 223
 		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
224
+		if ($limit > 0) {
225 225
 			webAlertAndQuit("User name is already in use!");
226 226
 		}
227 227
 
228 228
 		// check if the email address already exists
229 229
 		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230 230
 		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
231
+		if ($limit > 0) {
232 232
 			webAlertAndQuit("Email is already in use!");
233 233
 		}
234 234
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		// update user name and password
242 242
 		$field = array();
243 243
 		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
244
+		if ($genpassword == 1) {
245 245
 			$field['password'] = $modx->phpass->HashPassword($newpassword);
246 246
 		}
247 247
 		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		));
270 270
 
271 271
 		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
272
+		if ($genpassword == 1) {
273 273
 			$modx->invokeEvent("OnManagerChangePassword", array(
274 274
 				"userid" => $id,
275 275
 				"username" => $newusername,
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 		/*******************************************************************************/
287 287
 		// put the user in the user_groups he/ she should be in
288 288
 		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
289
+		if ($use_udperms == 1) {
290 290
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291 291
 			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
292
+			if (!empty($user_groups)) {
293
+				for ($i = 0; $i < count($user_groups); $i++) {
294 294
 					$field = array();
295 295
 					$field['user_group'] = intval($user_groups[$i]);
296 296
 					$field['member'] = $id;
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 		// end of user_groups stuff!
302 302
 		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
303
+		if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304 304
 			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305 305
 		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
306
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
307
+			if ($input['stay'] != '') {
308 308
 				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
309
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
310 310
 			} else {
311 311
 				$stayUrl = "index.php?a=75&r=2";
312 312
 			}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 				<div class="sectionHeader"><?php echo $_lang['user_title']; ?></div>
327 327
 				<div class="sectionBody">
328 328
 					<div id="disp">
329
-						<p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p>
329
+						<p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p>
330 330
 					</div>
331 331
 				</div>
332 332
 			</div>
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 
335 335
 			include_once "footer.inc.php";
336 336
 		} else {
337
-			if($input['stay'] != '') {
337
+			if ($input['stay'] != '') {
338 338
 				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
339
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
340 340
 				header($header);
341 341
 			} else {
342 342
 				$header = "Location: index.php?a=75&r=2";
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 }
350 350
 
351 351
 // Send an email to the user
352
-function sendMailMessage($email, $uid, $pwd, $ufn) {
352
+function sendMailMessage($email, $uid, $pwd, $ufn){
353 353
 	global $modx, $_lang, $signupemail_message;
354 354
 	global $emailsubject, $emailsender;
355 355
 	global $site_name;
@@ -371,14 +371,14 @@  discard block
 block discarded – undo
371 371
 	$param['to'] = $email;
372 372
 	$param['type'] = 'text';
373 373
 	$rs = $modx->sendmail($param);
374
-	if(!$rs) {
374
+	if (!$rs) {
375 375
 		$modx->manager->saveFormValues();
376 376
 		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
377 377
 	}
378 378
 }
379 379
 
380 380
 // Save User Settings
381
-function saveUserSettings($id) {
381
+function saveUserSettings($id){
382 382
 	global $modx;
383 383
 	$tbl_user_settings = $modx->getFullTableName('user_settings');
384 384
 
@@ -430,27 +430,27 @@  discard block
 block discarded – undo
430 430
 
431 431
 	// get user setting field names
432 432
 	$settings = array();
433
-	foreach($_POST as $n => $v) {
434
-		if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
433
+	foreach ($_POST as $n => $v) {
434
+		if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) {
435 435
 			continue;
436 436
 		} // ignore blacklist and empties
437 437
 		$settings[$n] = $v; // this value should be saved
438 438
 	}
439 439
 
440
-	foreach($defaults as $k) {
441
-		if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
440
+	foreach ($defaults as $k) {
441
+		if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') {
442 442
 			unset($settings[$k]);
443 443
 		}
444
-		unset($settings['default_' . $k]);
444
+		unset($settings['default_'.$k]);
445 445
 	}
446 446
 
447 447
 	$modx->db->delete($tbl_user_settings, "user='{$id}'");
448 448
 
449
-	foreach($settings as $n => $vl) {
450
-		if(is_array($vl)) {
449
+	foreach ($settings as $n => $vl) {
450
+		if (is_array($vl)) {
451 451
 			$vl = implode(",", $vl);
452 452
 		}
453
-		if($vl != '') {
453
+		if ($vl != '') {
454 454
 			$f = array();
455 455
 			$f['user'] = $id;
456 456
 			$f['setting_name'] = $n;
@@ -462,20 +462,20 @@  discard block
 block discarded – undo
462 462
 }
463 463
 
464 464
 // Web alert -  sends an alert to web browser
465
-function webAlertAndQuit($msg) {
465
+function webAlertAndQuit($msg){
466 466
 	global $id, $modx;
467 467
 	$mode = $_POST['mode'];
468 468
 	$modx->manager->saveFormValues($mode);
469
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
469
+	$modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : ''));
470 470
 }
471 471
 
472 472
 // Generate password
473
-function generate_password($length = 10) {
473
+function generate_password($length = 10){
474 474
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
475 475
 	$ps_len = strlen($allowable_characters);
476 476
 	mt_srand((double) microtime() * 1000000);
477 477
 	$pass = "";
478
-	for($i = 0; $i < $length; $i++) {
478
+	for ($i = 0; $i < $length; $i++) {
479 479
 		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
480 480
 	}
481 481
 	return $pass;
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -349,7 +349,8 @@  discard block
 block discarded – undo
349 349
 }
350 350
 
351 351
 // Send an email to the user
352
-function sendMailMessage($email, $uid, $pwd, $ufn) {
352
+function sendMailMessage($email, $uid, $pwd, $ufn)
353
+{
353 354
 	global $modx, $_lang, $signupemail_message;
354 355
 	global $emailsubject, $emailsender;
355 356
 	global $site_name;
@@ -378,7 +379,8 @@  discard block
 block discarded – undo
378 379
 }
379 380
 
380 381
 // Save User Settings
381
-function saveUserSettings($id) {
382
+function saveUserSettings($id)
383
+{
382 384
 	global $modx;
383 385
 	$tbl_user_settings = $modx->getFullTableName('user_settings');
384 386
 
@@ -462,7 +464,8 @@  discard block
 block discarded – undo
462 464
 }
463 465
 
464 466
 // Web alert -  sends an alert to web browser
465
-function webAlertAndQuit($msg) {
467
+function webAlertAndQuit($msg)
468
+{
466 469
 	global $id, $modx;
467 470
 	$mode = $_POST['mode'];
468 471
 	$modx->manager->saveFormValues($mode);
@@ -470,7 +473,8 @@  discard block
 block discarded – undo
470 473
 }
471 474
 
472 475
 // Generate password
473
-function generate_password($length = 10) {
476
+function generate_password($length = 10)
477
+{
474 478
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
475 479
 	$ps_len = strlen($allowable_characters);
476 480
 	mt_srand((double) microtime() * 1000000);
Please login to merge, or discard this patch.
manager/processors/publish_content.processor.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
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('save_document')||!$modx->hasPermission('publish_document')) {
4
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7 7
 $id = isset($_REQUEST['id'])? intval($_REQUEST['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
 /************webber ********/
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 $udperms->role = $_SESSION['mgrRole'];
32 32
 
33 33
 if(!$udperms->checkPermissions()) {
34
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
34
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
35 35
 }
36 36
 
37 37
 // update the document
38 38
 $modx->db->update(
39
-	array(
40
-		'published'   => 1,
41
-		'pub_date'    => 0,
42
-		'unpub_date'  => 0,
43
-		'editedby'    => $modx->getLoginUserID(),
44
-		'editedon'    => time(),
45
-		'publishedby' => $modx->getLoginUserID(),
46
-		'publishedon' => time(),
47
-	), $modx->getFullTableName('site_content'), "id='{$id}'");
39
+    array(
40
+        'published'   => 1,
41
+        'pub_date'    => 0,
42
+        'unpub_date'  => 0,
43
+        'editedby'    => $modx->getLoginUserID(),
44
+        'editedon'    => time(),
45
+        'publishedby' => $modx->getLoginUserID(),
46
+        'publishedon' => time(),
47
+    ), $modx->getFullTableName('site_content'), "id='{$id}'");
48 48
 
49 49
 // invoke OnDocPublished  event
50 50
 $modx->invokeEvent("OnDocPublished",array("docid"=>$id));
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@  discard block
 block discarded – undo
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('save_document')||!$modx->hasPermission('publish_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('save_document') || !$modx->hasPermission('publish_document')) {
4 4
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7
-$id = isset($_REQUEST['id'])? intval($_REQUEST['id']) : 0;
8
-if($id==0) {
7
+$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
8
+if ($id == 0) {
9 9
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
10 10
 }
11 11
 
12 12
 /************webber ********/
13
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
14
-$pid=($content['parent']==0?$id:$content['parent']);
13
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
14
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
15 15
 
16 16
 /************** webber *************/
17
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
18
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
19
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
20
-$add_path=$sd.$sb.$pg;
17
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
18
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
19
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
20
+$add_path = $sd.$sb.$pg;
21 21
 
22 22
 /***********************************/
23 23
 
24 24
 
25 25
 
26 26
 // check permissions on the document
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 = $id;
31 31
 $udperms->role = $_SESSION['mgrRole'];
32 32
 
33
-if(!$udperms->checkPermissions()) {
33
+if (!$udperms->checkPermissions()) {
34 34
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
35 35
 }
36 36
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	), $modx->getFullTableName('site_content'), "id='{$id}'");
48 48
 
49 49
 // invoke OnDocPublished  event
50
-$modx->invokeEvent("OnDocPublished",array("docid"=>$id));
50
+$modx->invokeEvent("OnDocPublished", array("docid"=>$id));
51 51
 
52 52
 // Set the item name for logger
53 53
 $_SESSION['itemname'] = $content['pagetitle'];
@@ -55,6 +55,6 @@  discard block
 block discarded – undo
55 55
 // empty cache
56 56
 $modx->clearCache('full');
57 57
 
58
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
58
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
59 59
 
60 60
 header($header);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
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('save_document')||!$modx->hasPermission('publish_document')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
Please login to merge, or discard this patch.
manager/processors/remove_locks.processor.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,23 +2,23 @@
 block discarded – undo
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
 
4 4
 if(!isset($_GET['id'])) {
5
-	if(!$modx->hasPermission('remove_locks')) $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5
+    if(!$modx->hasPermission('remove_locks')) $modx->webAlertAndQuit($_lang["error_no_privileges"]);
6 6
 	
7
-	// Remove all locks
8
-	$modx->db->truncate($modx->getFullTableName('active_user_locks'));
7
+    // Remove all locks
8
+    $modx->db->truncate($modx->getFullTableName('active_user_locks'));
9 9
 
10
-	$header = "Location: index.php?a=2";
11
-	header($header);
10
+    $header = "Location: index.php?a=2";
11
+    header($header);
12 12
 } else {
13
-	// Remove single locks via AJAX / window.onbeforeunload
14
-	$type = intval($_GET['type']);
15
-	$id = intval($_GET['id']);
16
-	$includeAllUsers = $modx->hasPermission('remove_locks'); // Enables usage of "unlock"-ajax-button
17
-	if($type && $id) {
18
-		$modx->unlockElement($type, $id, $includeAllUsers);
19
-		echo '1';
20
-		exit;
21
-	} else {
22
-		echo 'No type or id sent with request.';
23
-	}
13
+    // Remove single locks via AJAX / window.onbeforeunload
14
+    $type = intval($_GET['type']);
15
+    $id = intval($_GET['id']);
16
+    $includeAllUsers = $modx->hasPermission('remove_locks'); // Enables usage of "unlock"-ajax-button
17
+    if($type && $id) {
18
+        $modx->unlockElement($type, $id, $includeAllUsers);
19
+        echo '1';
20
+        exit;
21
+    } else {
22
+        echo 'No type or id sent with request.';
23
+    }
24 24
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3 3
 
4
-if(!isset($_GET['id'])) {
5
-	if(!$modx->hasPermission('remove_locks')) $modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+if (!isset($_GET['id'])) {
5
+	if (!$modx->hasPermission('remove_locks')) $modx->webAlertAndQuit($_lang["error_no_privileges"]);
6 6
 	
7 7
 	// Remove all locks
8 8
 	$modx->db->truncate($modx->getFullTableName('active_user_locks'));
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	$type = intval($_GET['type']);
15 15
 	$id = intval($_GET['id']);
16 16
 	$includeAllUsers = $modx->hasPermission('remove_locks'); // Enables usage of "unlock"-ajax-button
17
-	if($type && $id) {
17
+	if ($type && $id) {
18 18
 		$modx->unlockElement($type, $id, $includeAllUsers);
19 19
 		echo '1';
20 20
 		exit;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,12 @@
 block discarded – undo
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
 
4 6
 if(!isset($_GET['id'])) {
5
-	if(!$modx->hasPermission('remove_locks')) $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7
+	if(!$modx->hasPermission('remove_locks')) {
8
+	    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
9
+	}
6 10
 	
7 11
 	// Remove all locks
8 12
 	$modx->db->truncate($modx->getFullTableName('active_user_locks'));
Please login to merge, or discard this patch.
manager/processors/duplicate_plugin.processor.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
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_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
 // count duplicates
@@ -17,25 +17,25 @@  discard block
 block discarded – undo
17 17
 
18 18
 // duplicate Plugin
19 19
 $newid = $modx->db->insert(
20
-	array(
21
-		'name'=>'',
22
-		'description'=>'',
23
-		'disabled'=>'',
24
-		'moduleguid'=>'',
25
-		'plugincode'=>'',
26
-		'properties'=>'',
27
-		'category'=>'',
28
-		), $modx->getFullTableName('site_plugins'), // Insert into
29
-	"CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, moduleguid, plugincode, properties, category", $modx->getFullTableName('site_plugins'), "id='{$id}'"); // Copy from
20
+    array(
21
+        'name'=>'',
22
+        'description'=>'',
23
+        'disabled'=>'',
24
+        'moduleguid'=>'',
25
+        'plugincode'=>'',
26
+        'properties'=>'',
27
+        'category'=>'',
28
+        ), $modx->getFullTableName('site_plugins'), // Insert into
29
+    "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, moduleguid, plugincode, properties, category", $modx->getFullTableName('site_plugins'), "id='{$id}'"); // Copy from
30 30
 
31 31
 // duplicate Plugin Event Listeners
32 32
 $modx->db->insert(
33
-	array(
34
-		'pluginid'=>'',
35
-		'evtid'=>'',
36
-		'priority'=>'',
37
-		), $modx->getFullTableName('site_plugin_events'), // Insert into
38
-	"'{$newid}', evtid, priority", $modx->getFullTableName('site_plugin_events'), "pluginid='{$id}'"); // Copy from
33
+    array(
34
+        'pluginid'=>'',
35
+        'evtid'=>'',
36
+        'priority'=>'',
37
+        ), $modx->getFullTableName('site_plugin_events'), // Insert into
38
+    "'{$newid}', evtid, priority", $modx->getFullTableName('site_plugin_events'), "pluginid='{$id}'"); // Copy from
39 39
 
40 40
 // Set the item name for logger
41 41
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_plugins'), "id='{$newid}'"));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
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_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('new_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
 
12 12
 // count duplicates
13 13
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_plugins'), "id='{$id}'"));
14 14
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_plugins'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
15
+if ($count >= 1) $count = ' '.($count + 1);
16 16
 else $count = '';
17 17
 
18 18
 // duplicate Plugin
@@ -42,5 +42,5 @@  discard block
 block discarded – undo
42 42
 $_SESSION['itemname'] = $name;
43 43
 
44 44
 // finish duplicating - redirect to new plugin
45
-$header="Location: index.php?r=2&a=102&id=$newid";
45
+$header = "Location: index.php?r=2&a=102&id=$newid";
46 46
 header($header);
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
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_plugin')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -12,8 +14,11 @@  discard block
 block discarded – undo
12 14
 // count duplicates
13 15
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_plugins'), "id='{$id}'"));
14 16
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_plugins'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
16
-else $count = '';
17
+if($count>=1) {
18
+    $count = ' '.($count+1);
19
+} else {
20
+    $count = '';
21
+}
17 22
 
18 23
 // duplicate Plugin
19 24
 $newid = $modx->db->insert(
Please login to merge, or discard this patch.
manager/processors/optimize_table.processor.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,33 +1,33 @@
 block discarded – undo
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('settings') && ($modx->hasPermission('logs')||$modx->hasPermission('bk_manager')))) {	
4
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7 7
 if (isset($_REQUEST['t'])) {
8 8
 
9
-	if (empty($_REQUEST['t'])) {
10
-		$modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]);
11
-	}
9
+    if (empty($_REQUEST['t'])) {
10
+        $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]);
11
+    }
12 12
 
13
-	// Set the item name for logger
14
-	$_SESSION['itemname'] = $_REQUEST['t'];
13
+    // Set the item name for logger
14
+    $_SESSION['itemname'] = $_REQUEST['t'];
15 15
 
16
-	$modx->db->optimize($_REQUEST['t']);
16
+    $modx->db->optimize($_REQUEST['t']);
17 17
 
18 18
 } elseif (isset($_REQUEST['u'])) {
19 19
 
20
-	if (empty($_REQUEST['u'])) {
21
-		$modx->webAlertAndQuit($_lang["error_no_truncate_tablename"]);
22
-	}
20
+    if (empty($_REQUEST['u'])) {
21
+        $modx->webAlertAndQuit($_lang["error_no_truncate_tablename"]);
22
+    }
23 23
 
24
-	// Set the item name for logger
25
-	$_SESSION['itemname'] = $_REQUEST['u'];
24
+    // Set the item name for logger
25
+    $_SESSION['itemname'] = $_REQUEST['u'];
26 26
 
27
-	$modx->db->truncate($_REQUEST['u']);
27
+    $modx->db->truncate($_REQUEST['u']);
28 28
 
29 29
 } else {
30
-	$modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]);
30
+    $modx->webAlertAndQuit($_lang["error_no_optimise_tablename"]);
31 31
 }
32 32
 
33 33
 $mode = intval($_REQUEST['mode']);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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('settings') && ($modx->hasPermission('logs')||$modx->hasPermission('bk_manager')))) {	
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('settings') && ($modx->hasPermission('logs') || $modx->hasPermission('bk_manager')))) {	
4 4
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
@@ -31,5 +31,5 @@  discard block
 block discarded – undo
31 31
 }
32 32
 
33 33
 $mode = intval($_REQUEST['mode']);
34
-$header="Location: index.php?a={$mode}&s=4";
34
+$header = "Location: index.php?a={$mode}&s=4";
35 35
 header($header);
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
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('settings') && ($modx->hasPermission('logs')||$modx->hasPermission('bk_manager')))) {	
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
+}
5
+if(!($modx->hasPermission('settings') && ($modx->hasPermission('logs')||$modx->hasPermission('bk_manager')))) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
6 8
 
Please login to merge, or discard this patch.