Completed
Push — develop ( 053968...47dc8d )
by Maxim
12s
created
manager/processors/delete_content.processor.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('delete_document')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if ($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
     $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /*******ищем родителя чтобы к нему вернуться********/
15
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
-$pid=($content['parent']==0?$id:$content['parent']);
15
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
17 17
 
18 18
 /************ а заодно и путь возврата (сам путь внизу файла) **********/
19
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
20
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
21
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
22
-$add_path=$sd.$sb.$pg;
19
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
20
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
21
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
22
+$add_path = $sd.$sb.$pg;
23 23
 
24 24
 /*****************************/
25 25
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 $children = array();
28 28
 
29 29
 // check permissions on the document
30
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
31 31
 $udperms = new udperms();
32 32
 $udperms->user = $modx->getLoginUserID();
33 33
 $udperms->document = $id;
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
     $parent = $modx->db->escape($parent);
53 53
     $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent={$parent} AND deleted=0");
54 54
         // the document has children documents, we'll need to delete those too
55
-        while ($childid=$modx->db->getValue($rs)) {
56
-            if ($childid==$site_start) {
55
+        while ($childid = $modx->db->getValue($rs)) {
56
+            if ($childid == $site_start) {
57 57
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site start' document, and cannot be deleted. Please assign another document as your 'Site start' document and try again.");
58 58
             }
59
-            if ($childid==$site_unavailable_page) {
59
+            if ($childid == $site_unavailable_page) {
60 60
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unavailable page' document, and cannot be deleted. Please assign another document as your 'Site unavailable page' document and try again.");
61 61
             }
62
-            if ($childid==$error_page) {
62
+            if ($childid == $error_page) {
63 63
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site error page' document, and cannot be deleted. Please assign another document as your 'Site error page' document and try again.");
64 64
             }
65
-            if ($childid==$unauthorized_page) {
65
+            if ($childid == $unauthorized_page) {
66 66
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unauthorized page' document, and cannot be deleted. Please assign another document as your 'Site unauthorized page' document and try again.");
67 67
             }
68 68
             $children[] = $childid;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                             "children"=>$children
81 81
                         ));
82 82
 
83
-if (count($children)>0) {
83
+if (count($children) > 0) {
84 84
     $modx->db->update(
85 85
         array(
86 86
             'deleted'   => 1,
@@ -89,19 +89,19 @@  discard block
 block discarded – undo
89 89
         ), $modx->getFullTableName('site_content'), "id IN (".implode(", ", $children).")");
90 90
 }
91 91
 
92
-if ($site_start==$id) {
92
+if ($site_start == $id) {
93 93
     $modx->webAlertAndQuit("Document is 'Site start' and cannot be deleted!");
94 94
 }
95 95
 
96
-if ($site_unavailable_page==$id) {
96
+if ($site_unavailable_page == $id) {
97 97
     $modx->webAlertAndQuit("Document is used as the 'Site unavailable page' and cannot be deleted!");
98 98
 }
99 99
 
100
-if ($error_page==$id) {
100
+if ($error_page == $id) {
101 101
     $modx->webAlertAndQuit("Document is used as the 'Site error page' and cannot be deleted!");
102 102
 }
103 103
 
104
-if ($unauthorized_page==$id) {
104
+if ($unauthorized_page == $id) {
105 105
     $modx->webAlertAndQuit("Document is used as the 'Site unauthorized page' and cannot be deleted!");
106 106
 }
107 107
 
@@ -127,5 +127,5 @@  discard block
 block discarded – undo
127 127
 $modx->clearCache('full');
128 128
 
129 129
 // finished emptying cache - redirect
130
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
130
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
131 131
 header($header);
Please login to merge, or discard this patch.
manager/processors/undelete_content.processor.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('delete_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /************ webber ********/
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 $udperms->role = $_SESSION['mgrRole'];
33 33
 
34 34
 if(!$udperms->checkPermissions()) {
35
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
35
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
36 36
 }
37 37
 
38 38
 // get the timestamp on which the document was deleted.
39 39
 $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1");
40 40
 $deltime = $modx->db->getValue($rs);
41 41
 if(!$deltime) {
42
-	$modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!");
42
+    $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!");
43 43
 }
44 44
 
45 45
 $children = array();
@@ -49,36 +49,36 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function getChildren($parent) {
51 51
 
52
-	global $modx;
53
-	global $children;
54
-	global $deltime;
55
-
56
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'");
57
-		// the document has children documents, we'll need to delete those too
58
-		while ($row=$modx->db->getRow($rs)) {
59
-			$children[] = $row['id'];
60
-			getChildren($row['id']);
61
-			//echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
62
-		}
52
+    global $modx;
53
+    global $children;
54
+    global $deltime;
55
+
56
+    $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'");
57
+        // the document has children documents, we'll need to delete those too
58
+        while ($row=$modx->db->getRow($rs)) {
59
+            $children[] = $row['id'];
60
+            getChildren($row['id']);
61
+            //echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
62
+        }
63 63
 }
64 64
 
65 65
 getChildren($id);
66 66
 
67 67
 if(count($children)>0) {
68
-	$modx->db->update(
69
-		array(
70
-			'deleted'   => 0,
71
-			'deletedby' => 0,
72
-			'deletedon' => 0,
73
-		), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")");
68
+    $modx->db->update(
69
+        array(
70
+            'deleted'   => 0,
71
+            'deletedby' => 0,
72
+            'deletedon' => 0,
73
+        ), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")");
74 74
 }
75 75
 //'undelete' the document.
76 76
 $modx->db->update(
77
-	array(
78
-		'deleted'   => 0,
79
-		'deletedby' => 0,
80
-		'deletedon' => 0,
81
-	), $modx->getFullTableName('site_content'), "id='{$id}'");
77
+    array(
78
+        'deleted'   => 0,
79
+        'deletedby' => 0,
80
+        'deletedon' => 0,
81
+    ), $modx->getFullTableName('site_content'), "id='{$id}'");
82 82
 
83 83
 $modx->invokeEvent("OnDocFormUnDelete",
84 84
     array(
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('delete_document')) {
5
+if (!$modx->hasPermission('delete_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /************ webber ********/
15
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
-$pid=($content['parent']==0?$id:$content['parent']);
15
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
17 17
 
18 18
 /************** webber *************/
19
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
20
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
21
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
22
-$add_path=$sd.$sb.$pg;
19
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
20
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
21
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
22
+$add_path = $sd.$sb.$pg;
23 23
 
24 24
 /***********************************/
25 25
 
26 26
 
27 27
 // check permissions on the document
28
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
28
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
29 29
 $udperms = new udperms();
30 30
 $udperms->user = $modx->getLoginUserID();
31 31
 $udperms->document = $id;
32 32
 $udperms->role = $_SESSION['mgrRole'];
33 33
 
34
-if(!$udperms->checkPermissions()) {
34
+if (!$udperms->checkPermissions()) {
35 35
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
36 36
 }
37 37
 
38 38
 // get the timestamp on which the document was deleted.
39 39
 $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1");
40 40
 $deltime = $modx->db->getValue($rs);
41
-if(!$deltime) {
41
+if (!$deltime) {
42 42
 	$modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!");
43 43
 }
44 44
 
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 /**
48 48
  * @param int $parent
49 49
  */
50
-function getChildren($parent) {
50
+function getChildren($parent){
51 51
 
52 52
 	global $modx;
53 53
 	global $children;
54 54
 	global $deltime;
55 55
 
56
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'");
56
+	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int) $parent."' AND deleted=1 AND deletedon='".(int) $deltime."'");
57 57
 		// the document has children documents, we'll need to delete those too
58
-		while ($row=$modx->db->getRow($rs)) {
58
+		while ($row = $modx->db->getRow($rs)) {
59 59
 			$children[] = $row['id'];
60 60
 			getChildren($row['id']);
61 61
 			//echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 getChildren($id);
66 66
 
67
-if(count($children)>0) {
67
+if (count($children) > 0) {
68 68
 	$modx->db->update(
69 69
 		array(
70 70
 			'deleted'   => 0,
@@ -93,5 +93,5 @@  discard block
 block discarded – undo
93 93
 $modx->clearCache('full');
94 94
 
95 95
 // finished emptying cache - redirect
96
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
96
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
97 97
 header($header);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
 /**
48 48
  * @param int $parent
49 49
  */
50
-function getChildren($parent) {
50
+function getChildren($parent)
51
+{
51 52
 
52 53
 	global $modx;
53 54
 	global $children;
Please login to merge, or discard this patch.
manager/processors/remove_installer.processor.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 $pth = dirname(dirname(dirname(__FILE__)))."/install/";
17 17
 $pth = str_replace("\\","/",$pth);
18 18
 if(isset($_GET["rminstall"])) {
19
-	if(is_dir($pth)) {
20
-		if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
21
-	}
19
+    if(is_dir($pth)) {
20
+        if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
21
+    }
22 22
 }
23 23
 if($msg) echo "<script>alert('".addslashes($msg)."');</script>";
24 24
 echo "<script>window.location='../index.php?a=2';</script>";
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
  * @return bool
32 32
  */
33 33
 function rmdirRecursive($path, $followLinks=false) {
34
-   $dir = opendir($path) ;
35
-   while ($entry = readdir($dir)) {
36
-	   if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37
-		   @unlink( "$path/$entry" );
38
-	   }
39
-	   elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
40
-		   rmdirRecursive("$path/$entry"); // recursive
41
-	   }
42
-   }
43
-   closedir($dir);
44
-   return @rmdir($path);
34
+    $dir = opendir($path) ;
35
+    while ($entry = readdir($dir)) {
36
+        if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37
+            @unlink( "$path/$entry" );
38
+        }
39
+        elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
40
+            rmdirRecursive("$path/$entry"); // recursive
41
+        }
42
+    }
43
+    closedir($dir);
44
+    return @rmdir($path);
45 45
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
  *
13 13
  */
14 14
 
15
-$msg ='';
15
+$msg = '';
16 16
 $pth = dirname(dirname(dirname(__FILE__)))."/install/";
17
-$pth = str_replace("\\","/",$pth);
18
-if(isset($_GET["rminstall"])) {
19
-	if(is_dir($pth)) {
20
-		if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
17
+$pth = str_replace("\\", "/", $pth);
18
+if (isset($_GET["rminstall"])) {
19
+	if (is_dir($pth)) {
20
+		if (!rmdirRecursive($pth)) $msg = "An error occured while attempting to remove the install folder";
21 21
 	}
22 22
 }
23
-if($msg) echo "<script>alert('".addslashes($msg)."');</script>";
23
+if ($msg) echo "<script>alert('".addslashes($msg)."');</script>";
24 24
 echo "<script>window.location='../index.php?a=2';</script>";
25 25
 
26 26
 /**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
  * @param bool $followLinks
31 31
  * @return bool
32 32
  */
33
-function rmdirRecursive($path, $followLinks=false) {
34
-   $dir = opendir($path) ;
33
+function rmdirRecursive($path, $followLinks = false){
34
+   $dir = opendir($path);
35 35
    while ($entry = readdir($dir)) {
36 36
 	   if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37
-		   @unlink( "$path/$entry" );
37
+		   @unlink("$path/$entry");
38 38
 	   }
39
-	   elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
39
+	   elseif (is_dir("$path/$entry") && $entry != '.' && $entry != '..') {
40 40
 		   rmdirRecursive("$path/$entry"); // recursive
41 41
 	   }
42 42
    }
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,10 +17,14 @@  discard block
 block discarded – undo
17 17
 $pth = str_replace("\\","/",$pth);
18 18
 if(isset($_GET["rminstall"])) {
19 19
 	if(is_dir($pth)) {
20
-		if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
20
+		if(!rmdirRecursive($pth)) {
21
+		    $msg="An error occured while attempting to remove the install folder";
22
+		}
21 23
 	}
22 24
 }
23
-if($msg) echo "<script>alert('".addslashes($msg)."');</script>";
25
+if($msg) {
26
+    echo "<script>alert('".addslashes($msg)."');</script>";
27
+}
24 28
 echo "<script>window.location='../index.php?a=2';</script>";
25 29
 
26 30
 /**
@@ -30,13 +34,13 @@  discard block
 block discarded – undo
30 34
  * @param bool $followLinks
31 35
  * @return bool
32 36
  */
33
-function rmdirRecursive($path, $followLinks=false) {
37
+function rmdirRecursive($path, $followLinks=false)
38
+{
34 39
    $dir = opendir($path) ;
35 40
    while ($entry = readdir($dir)) {
36 41
 	   if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37 42
 		   @unlink( "$path/$entry" );
38
-	   }
39
-	   elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
43
+	   } elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
40 44
 		   rmdirRecursive("$path/$entry"); // recursive
41 45
 	   }
42 46
    }
Please login to merge, or discard this patch.
manager/processors/duplicate_content.processor.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $udperms->duplicateDoc = true;
23 23
 
24 24
 if(!$udperms->checkPermissions()) {
25
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
25
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
28 28
 // Run the duplicator
@@ -43,103 +43,103 @@  discard block
 block discarded – undo
43 43
  * @return int
44 44
  */
45 45
 function duplicateDocument($docid, $parent=null, $_toplevel=0) {
46
-	global $modx, $_lang;
47
-
48
-	// invoke OnBeforeDocDuplicate event
49
-	$evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
-		'id' => $docid
51
-	));
52
-
53
-	// if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
-	// TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
-	// [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
-
57
-	$userID = $modx->getLoginUserID();
58
-
59
-	$tblsc = $modx->getFullTableName('site_content');
60
-
61
-	// Grab the original document
62
-	$rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
-	$content = $modx->db->getRow($rs);
64
-
65
-	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
67
-	{
68
-		case '1':
69
-			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
-			$rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
-			$content['id'] = $modx->db->getValue($rs);
72
-			break;
73
-		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
75
-			$content['id'] = $modx->db->getValue($rs);
76
-			break;
77
-
78
-		default:
79
-			unset($content['id']); // remove the current id.
80
-	}
81
-
82
-	// Once we've grabbed the document object, start doing some modifications
83
-	if ($_toplevel == 0) {
84
-		// count duplicates
85
-		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
-		$pagetitle = $modx->db->escape($pagetitle);
87
-		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
89
-		else $count = '';
90
-
91
-		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
-		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
-		$content['alias'] = null;
95
-	}
96
-
97
-	// change the parent accordingly
98
-	if ($parent !== null) $content['parent'] = $parent;
99
-
100
-	// Change the author
101
-	$content['createdby'] = $userID;
102
-	$content['createdon'] = time();
103
-	// Remove other modification times
104
-	$content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
-
106
-	// [FS#922] Should the published status be honored? - sirlancelot
46
+    global $modx, $_lang;
47
+
48
+    // invoke OnBeforeDocDuplicate event
49
+    $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
+        'id' => $docid
51
+    ));
52
+
53
+    // if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
+    // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
+    // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
+
57
+    $userID = $modx->getLoginUserID();
58
+
59
+    $tblsc = $modx->getFullTableName('site_content');
60
+
61
+    // Grab the original document
62
+    $rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
+    $content = $modx->db->getRow($rs);
64
+
65
+    // Handle incremental ID
66
+    switch($modx->config['docid_incrmnt_method'])
67
+    {
68
+        case '1':
69
+            $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
+            $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
+            $content['id'] = $modx->db->getValue($rs);
72
+            break;
73
+        case '2':
74
+            $rs = $modx->db->select('MAX(id)+1',$tblsc);
75
+            $content['id'] = $modx->db->getValue($rs);
76
+            break;
77
+
78
+        default:
79
+            unset($content['id']); // remove the current id.
80
+    }
81
+
82
+    // Once we've grabbed the document object, start doing some modifications
83
+    if ($_toplevel == 0) {
84
+        // count duplicates
85
+        $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
+        $pagetitle = $modx->db->escape($pagetitle);
87
+        $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
+        if($count>=1) $count = ' '.($count+1);
89
+        else $count = '';
90
+
91
+        $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
+        $content['alias'] = null;
93
+    } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
+        $content['alias'] = null;
95
+    }
96
+
97
+    // change the parent accordingly
98
+    if ($parent !== null) $content['parent'] = $parent;
99
+
100
+    // Change the author
101
+    $content['createdby'] = $userID;
102
+    $content['createdon'] = time();
103
+    // Remove other modification times
104
+    $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
+
106
+    // [FS#922] Should the published status be honored? - sirlancelot
107 107
 //	if ($modx->hasPermission('publish_document')) {
108 108
 //		if ($modx->config['publish_default'])
109 109
 //			$content['pub_date'] = $content['pub_date']; // should this be changed to 1?
110 110
 //		else	$content['pub_date'] = 0;
111 111
 //	} else {
112
-		// User can't publish documents
112
+        // User can't publish documents
113 113
 //		$content['published'] = $content['pub_date'] = 0;
114 114
 //	}
115 115
 
116 116
     // Set the published status to unpublished by default (see above ... commit #3388)
117 117
     $content['published'] = $content['pub_date'] = 0;
118 118
 
119
-	// Escape the proper strings
120
-	$content = $modx->db->escape($content);
119
+    // Escape the proper strings
120
+    $content = $modx->db->escape($content);
121 121
 
122
-	// Duplicate the Document
123
-	$newparent = $modx->db->insert($content, $tblsc);
122
+    // Duplicate the Document
123
+    $newparent = $modx->db->insert($content, $tblsc);
124 124
 
125
-	// duplicate document's TVs
126
-	duplicateTVs($docid, $newparent);
127
-	duplicateAccess($docid, $newparent);
125
+    // duplicate document's TVs
126
+    duplicateTVs($docid, $newparent);
127
+    duplicateAccess($docid, $newparent);
128 128
 
129
-	// invoke OnDocDuplicate event
130
-	$evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
-		'id' => $docid,
132
-		'new_id' => $newparent
133
-	));
129
+    // invoke OnDocDuplicate event
130
+    $evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
+        'id' => $docid,
132
+        'new_id' => $newparent
133
+    ));
134 134
 
135
-	// Start duplicating all the child documents that aren't deleted.
136
-	$_toplevel++;
137
-	$rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
-		while ($row = $modx->db->getRow($rs))
139
-			duplicateDocument($row['id'], $newparent, $_toplevel);
135
+    // Start duplicating all the child documents that aren't deleted.
136
+    $_toplevel++;
137
+    $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
+        while ($row = $modx->db->getRow($rs))
139
+            duplicateDocument($row['id'], $newparent, $_toplevel);
140 140
 
141
-	// return the new doc id
142
-	return $newparent;
141
+    // return the new doc id
142
+    return $newparent;
143 143
 }
144 144
 
145 145
 /**
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
  * @param int $newid
150 150
  */
151 151
 function duplicateTVs($oldid, $newid){
152
-	global $modx;
152
+    global $modx;
153 153
 
154
-	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
154
+    $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156 156
     $newid = (int)$newid;
157 157
     $oldid = (int)$oldid;
158 158
 
159 159
     $modx->db->insert(
160
-		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
-		"{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
-	);
160
+        array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
+        "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
+    );
163 163
 }
164 164
 
165 165
 /**
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  * @param int $newid
170 170
  */
171 171
 function duplicateAccess($oldid, $newid){
172
-	global $modx;
172
+    global $modx;
173 173
 
174
-	$tbldg = $modx->getFullTableName('document_groups');
174
+    $tbldg = $modx->getFullTableName('document_groups');
175 175
 
176 176
     $newid = (int)$newid;
177 177
     $oldid = (int)$oldid;
178 178
 
179 179
     $modx->db->insert(
180
-		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
-		"{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
-	);
180
+        array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
+        "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
+    );
183 183
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
5
+if (!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
15 15
 
16 16
 // check permissions on the document
17
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
17
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
18 18
 $udperms = new udperms();
19 19
 $udperms->user = $modx->getLoginUserID();
20 20
 $udperms->document = $id;
21 21
 $udperms->role = $_SESSION['mgrRole'];
22 22
 $udperms->duplicateDoc = true;
23 23
 
24
-if(!$udperms->checkPermissions()) {
24
+if (!$udperms->checkPermissions()) {
25 25
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 $_SESSION['itemname'] = $name;
34 34
 
35 35
 // finish cloning - redirect
36
-$header="Location: index.php?r=1&a=3&id=$id";
36
+$header = "Location: index.php?r=1&a=3&id=$id";
37 37
 header($header);
38 38
 
39 39
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  * @param int $_toplevel
43 43
  * @return int
44 44
  */
45
-function duplicateDocument($docid, $parent=null, $_toplevel=0) {
45
+function duplicateDocument($docid, $parent = null, $_toplevel = 0){
46 46
 	global $modx, $_lang;
47 47
 
48 48
 	// invoke OnBeforeDocDuplicate event
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	$content = $modx->db->getRow($rs);
64 64
 
65 65
 	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
66
+	switch ($modx->config['docid_incrmnt_method'])
67 67
 	{
68 68
 		case '1':
69 69
 			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			$content['id'] = $modx->db->getValue($rs);
72 72
 			break;
73 73
 		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
74
+			$rs = $modx->db->select('MAX(id)+1', $tblsc);
75 75
 			$content['id'] = $modx->db->getValue($rs);
76 76
 			break;
77 77
 
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86 86
 		$pagetitle = $modx->db->escape($pagetitle);
87 87
 		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
88
+		if ($count >= 1) $count = ' '.($count + 1);
89 89
 		else $count = '';
90 90
 
91 91
 		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92 92
 		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
93
+	} elseif ($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94 94
 		$content['alias'] = null;
95 95
 	}
96 96
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 
154 154
 	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156
-    $newid = (int)$newid;
157
-    $oldid = (int)$oldid;
156
+    $newid = (int) $newid;
157
+    $oldid = (int) $oldid;
158 158
 
159 159
     $modx->db->insert(
160 160
 		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 
174 174
 	$tbldg = $modx->getFullTableName('document_groups');
175 175
 
176
-    $newid = (int)$newid;
177
-    $oldid = (int)$oldid;
176
+    $newid = (int) $newid;
177
+    $oldid = (int) $oldid;
178 178
 
179 179
     $modx->db->insert(
180 180
 		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
42 42
  * @param int $_toplevel
43 43
  * @return int
44 44
  */
45
-function duplicateDocument($docid, $parent=null, $_toplevel=0) {
45
+function duplicateDocument($docid, $parent=null, $_toplevel=0)
46
+{
46 47
 	global $modx, $_lang;
47 48
 
48 49
 	// invoke OnBeforeDocDuplicate event
@@ -63,8 +64,7 @@  discard block
 block discarded – undo
63 64
 	$content = $modx->db->getRow($rs);
64 65
 
65 66
 	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
67
-	{
67
+	switch($modx->config['docid_incrmnt_method']) {
68 68
 		case '1':
69 69
 			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70 70
 			$rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
@@ -85,8 +85,11 @@  discard block
 block discarded – undo
85 85
 		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86 86
 		$pagetitle = $modx->db->escape($pagetitle);
87 87
 		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
89
-		else $count = '';
88
+		if($count>=1) {
89
+		    $count = ' '.($count+1);
90
+		} else {
91
+		    $count = '';
92
+		}
90 93
 
91 94
 		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92 95
 		$content['alias'] = null;
@@ -95,7 +98,9 @@  discard block
 block discarded – undo
95 98
 	}
96 99
 
97 100
 	// change the parent accordingly
98
-	if ($parent !== null) $content['parent'] = $parent;
101
+	if ($parent !== null) {
102
+	    $content['parent'] = $parent;
103
+	}
99 104
 
100 105
 	// Change the author
101 106
 	$content['createdby'] = $userID;
@@ -135,8 +140,9 @@  discard block
 block discarded – undo
135 140
 	// Start duplicating all the child documents that aren't deleted.
136 141
 	$_toplevel++;
137 142
 	$rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
-		while ($row = $modx->db->getRow($rs))
139
-			duplicateDocument($row['id'], $newparent, $_toplevel);
143
+		while ($row = $modx->db->getRow($rs)) {
144
+					duplicateDocument($row['id'], $newparent, $_toplevel);
145
+		}
140 146
 
141 147
 	// return the new doc id
142 148
 	return $newparent;
@@ -148,7 +154,8 @@  discard block
 block discarded – undo
148 154
  * @param int $oldid
149 155
  * @param int $newid
150 156
  */
151
-function duplicateTVs($oldid, $newid){
157
+function duplicateTVs($oldid, $newid)
158
+{
152 159
 	global $modx;
153 160
 
154 161
 	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
@@ -168,7 +175,8 @@  discard block
 block discarded – undo
168 175
  * @param int $oldid
169 176
  * @param int $newid
170 177
  */
171
-function duplicateAccess($oldid, $newid){
178
+function duplicateAccess($oldid, $newid)
179
+{
172 180
 	global $modx;
173 181
 
174 182
 	$tbldg = $modx->getFullTableName('document_groups');
Please login to merge, or discard this patch.
manager/processors/execute_module.processor.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -3,51 +3,51 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('exec_module')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // check if user has access permission, except admins
15 15
 if($_SESSION['mgrRole']!=1){
16
-	$rs = $modx->db->select(
17
-		'sma.usergroup,mg.member',
18
-		$modx->getFullTableName("site_module_access")." sma
16
+    $rs = $modx->db->select(
17
+        'sma.usergroup,mg.member',
18
+        $modx->getFullTableName("site_module_access")." sma
19 19
 			LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'",
20
-		"sma.module = '{$id}'"
21
-		);
22
-	//initialize permission to -1, if it stays -1 no permissions
23
-	//attached so permission granted
24
-	$permissionAccessInt = -1;
20
+        "sma.module = '{$id}'"
21
+        );
22
+    //initialize permission to -1, if it stays -1 no permissions
23
+    //attached so permission granted
24
+    $permissionAccessInt = -1;
25 25
 
26
-	while ($row = $modx->db->getRow($rs)) {
27
-		if($row["usergroup"] && $row["member"]) {
28
-			//if there are permissions and this member has permission, ofcourse
29
-			//this is granted
30
-			$permissionAccessInt = 1;
31
-		} elseif ($permissionAccessInt==-1) {
32
-			//if there are permissions but this member has no permission and the
33
-			//variable was still in init state we set permission to 0; no permissions
34
-			$permissionAccessInt = 0;
35
-		}
36
-	}
26
+    while ($row = $modx->db->getRow($rs)) {
27
+        if($row["usergroup"] && $row["member"]) {
28
+            //if there are permissions and this member has permission, ofcourse
29
+            //this is granted
30
+            $permissionAccessInt = 1;
31
+        } elseif ($permissionAccessInt==-1) {
32
+            //if there are permissions but this member has no permission and the
33
+            //variable was still in init state we set permission to 0; no permissions
34
+            $permissionAccessInt = 0;
35
+        }
36
+    }
37 37
 
38
-	if($permissionAccessInt==0) {
39
-		$modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40
-	}
38
+    if($permissionAccessInt==0) {
39
+        $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40
+    }
41 41
 }
42 42
 
43 43
 // get module data
44 44
 $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'");
45 45
 $content = $modx->db->getRow($rs);
46 46
 if(!$content) {
47
-	$modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
47
+    $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
48 48
 }
49 49
 if($content['disabled']) {
50
-	$modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
50
+    $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
51 51
 }
52 52
 
53 53
 // Set the item name for logger
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
  * @return string
72 72
  */
73 73
 function evalModule($moduleCode,$params){
74
-	global $modx;
75
-	$modx->event->params = &$params; // store params inside event object
76
-	if(is_array($params)) {
77
-		extract($params, EXTR_SKIP);
78
-	}
79
-	ob_start();
80
-	$mod = eval($moduleCode);
81
-	$msg = ob_get_contents();
82
-	ob_end_clean();
83
-	if (isset($php_errormsg))
84
-	{
85
-		$error_info = error_get_last();
74
+    global $modx;
75
+    $modx->event->params = &$params; // store params inside event object
76
+    if(is_array($params)) {
77
+        extract($params, EXTR_SKIP);
78
+    }
79
+    ob_start();
80
+    $mod = eval($moduleCode);
81
+    $msg = ob_get_contents();
82
+    ob_end_clean();
83
+    if (isset($php_errormsg))
84
+    {
85
+        $error_info = error_get_last();
86 86
         switch($error_info['type'])
87 87
         {
88
-        	case E_NOTICE :
89
-        		$error_level = 1;
90
-        	case E_USER_NOTICE :
91
-        		break;
92
-        	case E_DEPRECATED :
93
-        	case E_USER_DEPRECATED :
94
-        	case E_STRICT :
95
-        		$error_level = 2;
96
-        		break;
97
-        	default:
98
-        		$error_level = 99;
88
+            case E_NOTICE :
89
+                $error_level = 1;
90
+            case E_USER_NOTICE :
91
+                break;
92
+            case E_DEPRECATED :
93
+            case E_USER_DEPRECATED :
94
+            case E_STRICT :
95
+                $error_level = 2;
96
+                break;
97
+            default:
98
+                $error_level = 99;
99
+        }
100
+        if($modx->config['error_reporting']==='99' || 2<$error_level)
101
+        {
102
+            $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103
+            $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
99 104
         }
100
-		if($modx->config['error_reporting']==='99' || 2<$error_level)
101
-		{
102
-			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103
-			$modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
104
-		}
105
-	}
106
-	unset($modx->event->params);
107
-	return $mod.$msg;
105
+    }
106
+    unset($modx->event->params);
107
+    return $mod.$msg;
108 108
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('exec_module')) {
5
+if (!$modx->hasPermission('exec_module')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // check if user has access permission, except admins
15
-if($_SESSION['mgrRole']!=1){
15
+if ($_SESSION['mgrRole'] != 1) {
16 16
 	$rs = $modx->db->select(
17 17
 		'sma.usergroup,mg.member',
18 18
 		$modx->getFullTableName("site_module_access")." sma
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 	$permissionAccessInt = -1;
25 25
 
26 26
 	while ($row = $modx->db->getRow($rs)) {
27
-		if($row["usergroup"] && $row["member"]) {
27
+		if ($row["usergroup"] && $row["member"]) {
28 28
 			//if there are permissions and this member has permission, ofcourse
29 29
 			//this is granted
30 30
 			$permissionAccessInt = 1;
31
-		} elseif ($permissionAccessInt==-1) {
31
+		} elseif ($permissionAccessInt == -1) {
32 32
 			//if there are permissions but this member has no permission and the
33 33
 			//variable was still in init state we set permission to 0; no permissions
34 34
 			$permissionAccessInt = 0;
35 35
 		}
36 36
 	}
37 37
 
38
-	if($permissionAccessInt==0) {
38
+	if ($permissionAccessInt == 0) {
39 39
 		$modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40 40
 	}
41 41
 }
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 // get module data
44 44
 $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'");
45 45
 $content = $modx->db->getRow($rs);
46
-if(!$content) {
46
+if (!$content) {
47 47
 	$modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
48 48
 }
49
-if($content['disabled']) {
49
+if ($content['disabled']) {
50 50
 	$modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
51 51
 }
52 52
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 // Set the item name for logger
60 60
 $_SESSION['itemname'] = $content['name'];
61 61
 
62
-$output = evalModule($content["modulecode"],$parameter);
62
+$output = evalModule($content["modulecode"], $parameter);
63 63
 echo $output;
64 64
 include MODX_MANAGER_PATH."includes/sysalert.display.inc.php";
65 65
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
  * @param array $params
71 71
  * @return string
72 72
  */
73
-function evalModule($moduleCode,$params){
73
+function evalModule($moduleCode, $params){
74 74
 	global $modx;
75 75
 	$modx->event->params = &$params; // store params inside event object
76
-	if(is_array($params)) {
76
+	if (is_array($params)) {
77 77
 		extract($params, EXTR_SKIP);
78 78
 	}
79 79
 	ob_start();
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	if (isset($php_errormsg))
84 84
 	{
85 85
 		$error_info = error_get_last();
86
-        switch($error_info['type'])
86
+        switch ($error_info['type'])
87 87
         {
88 88
         	case E_NOTICE :
89 89
         		$error_level = 1;
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         	default:
98 98
         		$error_level = 99;
99 99
         }
100
-		if($modx->config['error_reporting']==='99' || 2<$error_level)
100
+		if ($modx->config['error_reporting'] === '99' || 2 < $error_level)
101 101
 		{
102
-			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
102
+			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'].' - Module', $error_info['message'], $error_info['line'], $msg);
103 103
 			$modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
104 104
 		}
105 105
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 }
13 13
 
14 14
 // check if user has access permission, except admins
15
-if($_SESSION['mgrRole']!=1){
15
+if($_SESSION['mgrRole']!=1) {
16 16
 	$rs = $modx->db->select(
17 17
 		'sma.usergroup,mg.member',
18 18
 		$modx->getFullTableName("site_module_access")." sma
@@ -70,7 +70,8 @@  discard block
 block discarded – undo
70 70
  * @param array $params
71 71
  * @return string
72 72
  */
73
-function evalModule($moduleCode,$params){
73
+function evalModule($moduleCode,$params)
74
+{
74 75
 	global $modx;
75 76
 	$modx->event->params = &$params; // store params inside event object
76 77
 	if(is_array($params)) {
@@ -80,11 +81,9 @@  discard block
 block discarded – undo
80 81
 	$mod = eval($moduleCode);
81 82
 	$msg = ob_get_contents();
82 83
 	ob_end_clean();
83
-	if (isset($php_errormsg))
84
-	{
84
+	if (isset($php_errormsg)) {
85 85
 		$error_info = error_get_last();
86
-        switch($error_info['type'])
87
-        {
86
+        switch($error_info['type']) {
88 87
         	case E_NOTICE :
89 88
         		$error_level = 1;
90 89
         	case E_USER_NOTICE :
@@ -97,8 +96,7 @@  discard block
 block discarded – undo
97 96
         	default:
98 97
         		$error_level = 99;
99 98
         }
100
-		if($modx->config['error_reporting']==='99' || 2<$error_level)
101
-		{
99
+		if($modx->config['error_reporting']==='99' || 2<$error_level) {
102 100
 			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103 101
 			$modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
104 102
 		}
Please login to merge, or discard this patch.
manager/processors/save_template.processor.php 1 patch
Switch Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -33,115 +33,115 @@
 block discarded – undo
33 33
 }
34 34
 
35 35
 switch ($_POST['mode']) {
36
-    case '19':
37
-
38
-        // invoke OnBeforeTempFormSave event
39
-        $modx->invokeEvent("OnBeforeTempFormSave", array(
40
-            "mode" => "new",
41
-            "id" => $id
42
-        ));
43
-
44
-        // disallow duplicate names for new templates
45
-        $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'");
46
-        $count = $modx->db->getValue($rs);
47
-        if ($count > 0) {
48
-            $modx->manager->saveFormValues(19);
49
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19");
50
-        }
51
-
52
-        //do stuff to save the new doc
53
-        $newid = $modx->db->insert(array(
54
-            'templatename' => $templatename,
55
-            'description' => $description,
56
-            'content' => $template,
57
-            'locked' => $locked,
58
-            'selectable' => $selectable,
59
-            'category' => $categoryid,
60
-            'createdon' => $currentdate,
61
-            'editedon' => $currentdate
62
-        ), $modx->getFullTableName('site_templates'));
63
-
64
-        // invoke OnTempFormSave event
65
-        $modx->invokeEvent("OnTempFormSave", array(
66
-            "mode" => "new",
67
-            "id" => $newid
68
-        ));
69
-        // Set new assigned Tvs
70
-        saveTemplateAccess($newid);
71
-
72
-        // Set the item name for logger
73
-        $_SESSION['itemname'] = $templatename;
74
-
75
-        // empty cache
76
-        $modx->clearCache('full');
77
-
78
-        // finished emptying cache - redirect
79
-        if ($_POST['stay'] != '') {
80
-            $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
82
-            header($header);
83
-        } else {
84
-            $header = "Location: index.php?a=76&r=2";
85
-            header($header);
86
-        }
87
-
88
-        break;
89
-    case '16':
90
-
91
-        // invoke OnBeforeTempFormSave event
92
-        $modx->invokeEvent("OnBeforeTempFormSave", array(
93
-            "mode" => "upd",
94
-            "id" => $id
95
-        ));
96
-
97
-        // disallow duplicate names for templates
98
-        $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'");
99
-        $count = $modx->db->getValue($rs);
100
-        if ($count > 0) {
101
-            $modx->manager->saveFormValues(16);
102
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}");
103
-        }
104
-
105
-        //do stuff to save the edited doc
106
-        $modx->db->update(array(
107
-            'templatename' => $templatename,
108
-            'description' => $description,
109
-            'content' => $template,
110
-            'locked' => $locked,
111
-            'selectable' => $selectable,
112
-            'category' => $categoryid,
113
-            'editedon' => $currentdate
114
-        ), $modx->getFullTableName('site_templates'), "id='{$id}'");
115
-        // Set new assigned Tvs
116
-        saveTemplateAccess($id);
117
-
118
-        // invoke OnTempFormSave event
119
-        $modx->invokeEvent("OnTempFormSave", array(
120
-            "mode" => "upd",
121
-            "id" => $id
122
-        ));
123
-
124
-        // Set the item name for logger
125
-        $_SESSION['itemname'] = $templatename;
126
-
127
-        // first empty the cache
128
-        $modx->clearCache('full');
129
-
130
-        // finished emptying cache - redirect
131
-        if ($_POST['stay'] != '') {
132
-            $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
134
-            header($header);
135
-        } else {
136
-            $modx->unlockElement(1, $id);
137
-            $header = "Location: index.php?a=76&r=2";
138
-            header($header);
139
-        }
140
-
141
-
142
-        break;
143
-    default:
144
-        $modx->webAlertAndQuit("No operation set in request.");
36
+        case '19':
37
+
38
+            // invoke OnBeforeTempFormSave event
39
+            $modx->invokeEvent("OnBeforeTempFormSave", array(
40
+                "mode" => "new",
41
+                "id" => $id
42
+            ));
43
+
44
+            // disallow duplicate names for new templates
45
+            $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'");
46
+            $count = $modx->db->getValue($rs);
47
+            if ($count > 0) {
48
+                $modx->manager->saveFormValues(19);
49
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19");
50
+            }
51
+
52
+            //do stuff to save the new doc
53
+            $newid = $modx->db->insert(array(
54
+                'templatename' => $templatename,
55
+                'description' => $description,
56
+                'content' => $template,
57
+                'locked' => $locked,
58
+                'selectable' => $selectable,
59
+                'category' => $categoryid,
60
+                'createdon' => $currentdate,
61
+                'editedon' => $currentdate
62
+            ), $modx->getFullTableName('site_templates'));
63
+
64
+            // invoke OnTempFormSave event
65
+            $modx->invokeEvent("OnTempFormSave", array(
66
+                "mode" => "new",
67
+                "id" => $newid
68
+            ));
69
+            // Set new assigned Tvs
70
+            saveTemplateAccess($newid);
71
+
72
+            // Set the item name for logger
73
+            $_SESSION['itemname'] = $templatename;
74
+
75
+            // empty cache
76
+            $modx->clearCache('full');
77
+
78
+            // finished emptying cache - redirect
79
+            if ($_POST['stay'] != '') {
80
+                $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
82
+                header($header);
83
+            } else {
84
+                $header = "Location: index.php?a=76&r=2";
85
+                header($header);
86
+            }
87
+
88
+            break;
89
+        case '16':
90
+
91
+            // invoke OnBeforeTempFormSave event
92
+            $modx->invokeEvent("OnBeforeTempFormSave", array(
93
+                "mode" => "upd",
94
+                "id" => $id
95
+            ));
96
+
97
+            // disallow duplicate names for templates
98
+            $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'");
99
+            $count = $modx->db->getValue($rs);
100
+            if ($count > 0) {
101
+                $modx->manager->saveFormValues(16);
102
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}");
103
+            }
104
+
105
+            //do stuff to save the edited doc
106
+            $modx->db->update(array(
107
+                'templatename' => $templatename,
108
+                'description' => $description,
109
+                'content' => $template,
110
+                'locked' => $locked,
111
+                'selectable' => $selectable,
112
+                'category' => $categoryid,
113
+                'editedon' => $currentdate
114
+            ), $modx->getFullTableName('site_templates'), "id='{$id}'");
115
+            // Set new assigned Tvs
116
+            saveTemplateAccess($id);
117
+
118
+            // invoke OnTempFormSave event
119
+            $modx->invokeEvent("OnTempFormSave", array(
120
+                "mode" => "upd",
121
+                "id" => $id
122
+            ));
123
+
124
+            // Set the item name for logger
125
+            $_SESSION['itemname'] = $templatename;
126
+
127
+            // first empty the cache
128
+            $modx->clearCache('full');
129
+
130
+            // finished emptying cache - redirect
131
+            if ($_POST['stay'] != '') {
132
+                $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
134
+                header($header);
135
+            } else {
136
+                $modx->unlockElement(1, $id);
137
+                $header = "Location: index.php?a=76&r=2";
138
+                header($header);
139
+            }
140
+
141
+
142
+            break;
143
+        default:
144
+            $modx->webAlertAndQuit("No operation set in request.");
145 145
 }
146 146
 
147 147
 /**
Please login to merge, or discard this patch.
manager/processors/move_document.processor.php 3 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('edit_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0;
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 // check user has permission to move document to chosen location
26 26
 
27 27
 if ($use_udperms == 1) {
28
-	if ($oldparent != $newParentID) {
29
-		include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
-		$udperms = new udperms();
31
-		$udperms->user = $modx->getLoginUserID();
32
-		$udperms->document = $newParentID;
33
-		$udperms->role = $_SESSION['mgrRole'];
34
-
35
-		 if (!$udperms->checkPermissions()) {
36
-			$modx->webAlertAndQuit($_lang["access_permission_parent_denied"]);
37
-		 }
38
-	}
28
+    if ($oldparent != $newParentID) {
29
+        include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
+        $udperms = new udperms();
31
+        $udperms->user = $modx->getLoginUserID();
32
+        $udperms->document = $newParentID;
33
+        $udperms->role = $_SESSION['mgrRole'];
34
+
35
+            if (!$udperms->checkPermissions()) {
36
+            $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]);
37
+            }
38
+    }
39 39
 }
40 40
 
41 41
 /**
@@ -43,67 +43,67 @@  discard block
 block discarded – undo
43 43
  * @return array
44 44
  */
45 45
 function allChildren($currDocID) {
46
-	global $modx;
47
-	$children= array();
48
-	$currDocID = $modx->db->escape($currDocID);
49
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
-	while ($child= $modx->db->getRow($rs)) {
51
-		$children[]= $child['id'];
52
-		$children= array_merge($children, allChildren($child['id']));
53
-	}
54
-	return $children;
46
+    global $modx;
47
+    $children= array();
48
+    $currDocID = $modx->db->escape($currDocID);
49
+    $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
+    while ($child= $modx->db->getRow($rs)) {
51
+        $children[]= $child['id'];
52
+        $children= array_merge($children, allChildren($child['id']));
53
+    }
54
+    return $children;
55 55
 }
56 56
 
57 57
 $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array (
58
-	"id_document" => $documentID,
59
-	"old_parent" => $oldparent,
60
-	"new_parent" => $newParentID
58
+    "id_document" => $documentID,
59
+    "old_parent" => $oldparent,
60
+    "new_parent" => $newParentID
61 61
 ));
62 62
 if (is_array($evtOut) && count($evtOut) > 0){
63
-	$newParent = array_pop($evtOut);
64
-	if($newParent == $oldparent) {
65
-		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
67
-		$newParentID = $newParent;
68
-	}
63
+    $newParent = array_pop($evtOut);
64
+    if($newParent == $oldparent) {
65
+        $modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
+    }else{
67
+        $newParentID = $newParent;
68
+    }
69 69
 }
70 70
 
71 71
 $children = allChildren($documentID);
72 72
 if (!array_search($newParentID, $children)) {
73
-	$modx->db->update(array(
74
-		'isfolder' => 1,
75
-	), $modx->getFullTableName('site_content'), "id='{$newParentID}'");
76
-
77
-	$modx->db->update(array(
78
-		'parent'   => $newParentID,
79
-		'editedby' => $modx->getLoginUserID(),
80
-		'editedon' => time(),
81
-	), $modx->getFullTableName('site_content'), "id='{$documentID}'");
82
-
83
-	// finished moving the document, now check to see if the old_parent should no longer be a folder.
84
-	$rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85
-	$limit = $modx->db->getValue($rs);
86
-
87
-	if(!$limit>0) {
88
-		$modx->db->update(array(
89
-			'isfolder' => 0,
90
-		), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
91
-	}
92
-	// Set the item name for logger
93
-	$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94
-	$_SESSION['itemname'] = $pagetitle;
95
-
96
-	$modx->invokeEvent("onAfterMoveDocument", array (
97
-		"id_document" => $documentID,
98
-		"old_parent" => $oldparent,
99
-		"new_parent" => $newParentID
100
-	));
101
-
102
-	// empty cache & sync site
103
-	$modx->clearCache('full');
104
-
105
-	$header="Location: index.php?a=3&id={$documentID}&r=9";
106
-	header($header);
73
+    $modx->db->update(array(
74
+        'isfolder' => 1,
75
+    ), $modx->getFullTableName('site_content'), "id='{$newParentID}'");
76
+
77
+    $modx->db->update(array(
78
+        'parent'   => $newParentID,
79
+        'editedby' => $modx->getLoginUserID(),
80
+        'editedon' => time(),
81
+    ), $modx->getFullTableName('site_content'), "id='{$documentID}'");
82
+
83
+    // finished moving the document, now check to see if the old_parent should no longer be a folder.
84
+    $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85
+    $limit = $modx->db->getValue($rs);
86
+
87
+    if(!$limit>0) {
88
+        $modx->db->update(array(
89
+            'isfolder' => 0,
90
+        ), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
91
+    }
92
+    // Set the item name for logger
93
+    $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94
+    $_SESSION['itemname'] = $pagetitle;
95
+
96
+    $modx->invokeEvent("onAfterMoveDocument", array (
97
+        "id_document" => $documentID,
98
+        "old_parent" => $oldparent,
99
+        "new_parent" => $newParentID
100
+    ));
101
+
102
+    // empty cache & sync site
103
+    $modx->clearCache('full');
104
+
105
+    $header="Location: index.php?a=3&id={$documentID}&r=9";
106
+    header($header);
107 107
 } else {
108
-	$modx->webAlertAndQuit("You cannot move a document to a child document!");
108
+    $modx->webAlertAndQuit("You cannot move a document to a child document!");
109 109
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('edit_document')) {
5
+if (!$modx->hasPermission('edit_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0;
10
-$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
9
+$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0;
10
+$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
11 11
 
12 12
 // ok, two things to check.
13 13
 // first, document cannot be moved to itself
14 14
 // second, new parent must be a folder. If not, set it to folder.
15
-if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
-if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
-if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
15
+if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
+if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
+if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
18 18
 
19 19
 $parents = $modx->getParentIds($newParentID);
20 20
 if (in_array($documentID, $parents))  $modx->webAlertAndQuit($_lang["error_movedocument2"]);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 if ($use_udperms == 1) {
28 28
 	if ($oldparent != $newParentID) {
29
-		include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
29
+		include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
30 30
 		$udperms = new udperms();
31 31
 		$udperms->user = $modx->getLoginUserID();
32 32
 		$udperms->document = $newParentID;
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
  * @param int $currDocID
43 43
  * @return array
44 44
  */
45
-function allChildren($currDocID) {
45
+function allChildren($currDocID){
46 46
 	global $modx;
47
-	$children= array();
47
+	$children = array();
48 48
 	$currDocID = $modx->db->escape($currDocID);
49 49
 	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
-	while ($child= $modx->db->getRow($rs)) {
51
-		$children[]= $child['id'];
52
-		$children= array_merge($children, allChildren($child['id']));
50
+	while ($child = $modx->db->getRow($rs)) {
51
+		$children[] = $child['id'];
52
+		$children = array_merge($children, allChildren($child['id']));
53 53
 	}
54 54
 	return $children;
55 55
 }
56 56
 
57
-$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array (
57
+$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array(
58 58
 	"id_document" => $documentID,
59 59
 	"old_parent" => $oldparent,
60 60
 	"new_parent" => $newParentID
61 61
 ));
62
-if (is_array($evtOut) && count($evtOut) > 0){
62
+if (is_array($evtOut) && count($evtOut) > 0) {
63 63
 	$newParent = array_pop($evtOut);
64
-	if($newParent == $oldparent) {
64
+	if ($newParent == $oldparent) {
65 65
 		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
66
+	} else {
67 67
 		$newParentID = $newParent;
68 68
 	}
69 69
 }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	$rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85 85
 	$limit = $modx->db->getValue($rs);
86 86
 
87
-	if(!$limit>0) {
87
+	if (!$limit > 0) {
88 88
 		$modx->db->update(array(
89 89
 			'isfolder' => 0,
90 90
 		), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94 94
 	$_SESSION['itemname'] = $pagetitle;
95 95
 
96
-	$modx->invokeEvent("onAfterMoveDocument", array (
96
+	$modx->invokeEvent("onAfterMoveDocument", array(
97 97
 		"id_document" => $documentID,
98 98
 		"old_parent" => $oldparent,
99 99
 		"new_parent" => $newParentID
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	// empty cache & sync site
103 103
 	$modx->clearCache('full');
104 104
 
105
-	$header="Location: index.php?a=3&id={$documentID}&r=9";
105
+	$header = "Location: index.php?a=3&id={$documentID}&r=9";
106 106
 	header($header);
107 107
 } else {
108 108
 	$modx->webAlertAndQuit("You cannot move a document to a child document!");
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,12 +12,20 @@  discard block
 block discarded – undo
12 12
 // ok, two things to check.
13 13
 // first, document cannot be moved to itself
14 14
 // second, new parent must be a folder. If not, set it to folder.
15
-if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
-if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
-if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
15
+if($documentID==$newParentID) {
16
+    $modx->webAlertAndQuit($_lang["error_movedocument1"]);
17
+}
18
+if($documentID <= 0) {
19
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
20
+}
21
+if($newParentID < 0) {
22
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
23
+}
18 24
 
19 25
 $parents = $modx->getParentIds($newParentID);
20
-if (in_array($documentID, $parents))  $modx->webAlertAndQuit($_lang["error_movedocument2"]);
26
+if (in_array($documentID, $parents)) {
27
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
28
+}
21 29
 
22 30
 $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'");
23 31
 $oldparent = $modx->db->getValue($rs);
@@ -42,7 +50,8 @@  discard block
 block discarded – undo
42 50
  * @param int $currDocID
43 51
  * @return array
44 52
  */
45
-function allChildren($currDocID) {
53
+function allChildren($currDocID)
54
+{
46 55
 	global $modx;
47 56
 	$children= array();
48 57
 	$currDocID = $modx->db->escape($currDocID);
@@ -59,11 +68,11 @@  discard block
 block discarded – undo
59 68
 	"old_parent" => $oldparent,
60 69
 	"new_parent" => $newParentID
61 70
 ));
62
-if (is_array($evtOut) && count($evtOut) > 0){
71
+if (is_array($evtOut) && count($evtOut) > 0) {
63 72
 	$newParent = array_pop($evtOut);
64 73
 	if($newParent == $oldparent) {
65 74
 		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
75
+	} else {
67 76
 		$newParentID = $newParent;
68 77
 	}
69 78
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 4 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || 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_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = sanitize($v);
17
-	}
18
-	$input[$k] = $v;
15
+    if($k !== 'comment') {
16
+        $v = sanitize($v);
17
+    }
18
+    $input[$k] = $v;
19 19
 }
20 20
 
21 21
 $id = (int)$input['id'];
@@ -51,80 +51,80 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched");
54
+    webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58 58
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
59
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!");
69
-		}
70
-
71
-		// check if the email address already exist
72
-		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
-		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("Email is already in use!");
76
-		}
77
-
78
-		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
81
-				webAlertAndQuit("Password is too short!");
82
-			} else {
83
-				$newpassword = $specifiedpassword;
84
-			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
-			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
88
-			$newpassword = generate_password(8);
89
-		} else {
90
-			webAlertAndQuit("No password generation method specified!");
91
-		}
92
-
93
-		// invoke OnBeforeWUsrFormSave event
94
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
-			"mode" => "new",
96
-		));
97
-
98
-		// create the user account
99
-		$field = array();
100
-		$field['username'] = $esc_newusername;
101
-		$field['password'] = md5($newpassword);
102
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
103
-
104
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
-		$field = $modx->db->escape($field);
106
-		$modx->db->insert($field, $tbl_web_user_attributes);
107
-
108
-		// Save User Settings
109
-		saveUserSettings($internalKey);
110
-
111
-		// Set the item name for logger
112
-		$_SESSION['itemname'] = $newusername;
113
-
114
-		/*******************************************************************************/
115
-		// put the user in the user_groups he/ she should be in
116
-		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
120
-					$f = array();
121
-					$f['webgroup'] = (int)$user_groups[$i];
122
-					$f['webuser'] = $internalKey;
123
-					$modx->db->insert($f, $tbl_web_groups);
124
-				}
125
-			}
126
-		}
127
-		// end of user_groups stuff!
63
+    case '87' : // new user
64
+        // check if this user name already exist
65
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+        $limit = $modx->db->getValue($rs);
67
+        if($limit > 0) {
68
+            webAlertAndQuit("User name is already in use!");
69
+        }
70
+
71
+        // check if the email address already exist
72
+        $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
+        $limit = $modx->db->getValue($rs);
74
+        if($limit > 0) {
75
+            webAlertAndQuit("Email is already in use!");
76
+        }
77
+
78
+        // generate a new password for this user
79
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+            if(strlen($specifiedpassword) < 6) {
81
+                webAlertAndQuit("Password is too short!");
82
+            } else {
83
+                $newpassword = $specifiedpassword;
84
+            }
85
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
+            webAlertAndQuit("You didn't specify a password for this user!");
87
+        } elseif($passwordgenmethod == 'g') {
88
+            $newpassword = generate_password(8);
89
+        } else {
90
+            webAlertAndQuit("No password generation method specified!");
91
+        }
92
+
93
+        // invoke OnBeforeWUsrFormSave event
94
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
+            "mode" => "new",
96
+        ));
97
+
98
+        // create the user account
99
+        $field = array();
100
+        $field['username'] = $esc_newusername;
101
+        $field['password'] = md5($newpassword);
102
+        $internalKey = $modx->db->insert($field, $tbl_web_users);
103
+
104
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
+        $field = $modx->db->escape($field);
106
+        $modx->db->insert($field, $tbl_web_user_attributes);
107
+
108
+        // Save User Settings
109
+        saveUserSettings($internalKey);
110
+
111
+        // Set the item name for logger
112
+        $_SESSION['itemname'] = $newusername;
113
+
114
+        /*******************************************************************************/
115
+        // put the user in the user_groups he/ she should be in
116
+        // first, check that up_perms are switched on!
117
+        if($use_udperms == 1) {
118
+            if(!empty($user_groups)) {
119
+                for($i = 0; $i < count($user_groups); $i++) {
120
+                    $f = array();
121
+                    $f['webgroup'] = (int)$user_groups[$i];
122
+                    $f['webuser'] = $internalKey;
123
+                    $modx->db->insert($f, $tbl_web_groups);
124
+                }
125
+            }
126
+        }
127
+        // end of user_groups stuff!
128 128
 
129 129
         // invoke OnWebSaveUser event
130 130
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -142,26 +142,26 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
146
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
148
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
-				header($header);
151
-			} else {
152
-				$header = "Location: index.php?a=99&r=2";
153
-				header($header);
154
-			}
155
-		} else {
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-			} else {
160
-				$stayUrl = "index.php?a=99&r=2";
161
-			}
162
-
163
-			include_once "header.inc.php";
164
-			?>
145
+        if($passwordnotifymethod == 'e') {
146
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
147
+            if($input['stay'] != '') {
148
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
+                header($header);
151
+            } else {
152
+                $header = "Location: index.php?a=99&r=2";
153
+                header($header);
154
+            }
155
+        } else {
156
+            if($input['stay'] != '') {
157
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+            } else {
160
+                $stayUrl = "index.php?a=99&r=2";
161
+            }
162
+
163
+            include_once "header.inc.php";
164
+            ?>
165 165
 
166 166
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
167 167
 
@@ -183,84 +183,84 @@  discard block
 block discarded – undo
183 183
 			</div>
184 184
 			<?php
185 185
 
186
-			include_once "footer.inc.php";
187
-		}
188
-		break;
189
-	case '88' : // edit user
190
-		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
194
-					webAlertAndQuit("Password is too short!");
195
-				} else {
196
-					$newpassword = $specifiedpassword;
197
-				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
-				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
201
-				$newpassword = generate_password(8);
202
-			} else {
203
-				webAlertAndQuit("No password generation method specified!");
204
-			}
205
-		}
206
-		if($passwordnotifymethod == 'e') {
207
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
208
-		}
209
-
210
-		// check if the username already exist
211
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
-		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
214
-			webAlertAndQuit("User name is already in use!");
215
-		}
216
-
217
-		// check if the email address already exists
218
-		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
-		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
221
-			webAlertAndQuit("Email is already in use!");
222
-		}
223
-
224
-		// invoke OnBeforeWUsrFormSave event
225
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
-			"mode" => "upd",
227
-			"id" => $id
228
-		));
229
-
230
-		// update user name and password
231
-		$field = array();
232
-		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
234
-			$field['password'] = md5($newpassword);
235
-		}
236
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
-		$field = $modx->db->escape($field);
239
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
-
241
-		// Save User Settings
242
-		saveUserSettings($id);
243
-
244
-		// Set the item name for logger
245
-		$_SESSION['itemname'] = $newusername;
246
-
247
-		/*******************************************************************************/
248
-		// put the user in the user_groups he/ she should be in
249
-		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
251
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
255
-					$field = array();
256
-					$field['webgroup'] = (int)$user_groups[$i];
257
-					$field['webuser'] = $id;
258
-					$modx->db->insert($field, $tbl_web_groups);
259
-				}
260
-			}
261
-		}
262
-		// end of user_groups stuff!
263
-		/*******************************************************************************/
186
+            include_once "footer.inc.php";
187
+        }
188
+        break;
189
+    case '88' : // edit user
190
+        // generate a new password for this user
191
+        if($genpassword == 1) {
192
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+                if(strlen($specifiedpassword) < 6) {
194
+                    webAlertAndQuit("Password is too short!");
195
+                } else {
196
+                    $newpassword = $specifiedpassword;
197
+                }
198
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
+                webAlertAndQuit("You didn't specify a password for this user!");
200
+            } elseif($passwordgenmethod == 'g') {
201
+                $newpassword = generate_password(8);
202
+            } else {
203
+                webAlertAndQuit("No password generation method specified!");
204
+            }
205
+        }
206
+        if($passwordnotifymethod == 'e') {
207
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
208
+        }
209
+
210
+        // check if the username already exist
211
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
+        $limit = $modx->db->getValue($rs);
213
+        if($limit > 0) {
214
+            webAlertAndQuit("User name is already in use!");
215
+        }
216
+
217
+        // check if the email address already exists
218
+        $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
+        $limit = $modx->db->getValue($rs);
220
+        if($limit > 0) {
221
+            webAlertAndQuit("Email is already in use!");
222
+        }
223
+
224
+        // invoke OnBeforeWUsrFormSave event
225
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
+            "mode" => "upd",
227
+            "id" => $id
228
+        ));
229
+
230
+        // update user name and password
231
+        $field = array();
232
+        $field['username'] = $esc_newusername;
233
+        if($genpassword == 1) {
234
+            $field['password'] = md5($newpassword);
235
+        }
236
+        $modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
+        $field = $modx->db->escape($field);
239
+        $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
+
241
+        // Save User Settings
242
+        saveUserSettings($id);
243
+
244
+        // Set the item name for logger
245
+        $_SESSION['itemname'] = $newusername;
246
+
247
+        /*******************************************************************************/
248
+        // put the user in the user_groups he/ she should be in
249
+        // first, check that up_perms are switched on!
250
+        if($use_udperms == 1) {
251
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
+            $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
+            if(!empty($user_groups)) {
254
+                for($i = 0; $i < count($user_groups); $i++) {
255
+                    $field = array();
256
+                    $field['webgroup'] = (int)$user_groups[$i];
257
+                    $field['webuser'] = $id;
258
+                    $modx->db->insert($field, $tbl_web_groups);
259
+                }
260
+            }
261
+        }
262
+        // end of user_groups stuff!
263
+        /*******************************************************************************/
264 264
 
265 265
         // invoke OnWebSaveUser event
266 266
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
294
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
-			} else {
297
-				$stayUrl = "index.php?a=99&r=2";
298
-			}
292
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
293
+            if($input['stay'] != '') {
294
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
+            } else {
297
+                $stayUrl = "index.php?a=99&r=2";
298
+            }
299 299
 
300
-			include_once "header.inc.php";
301
-			?>
300
+            include_once "header.inc.php";
301
+            ?>
302 302
 
303 303
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
304 304
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 			</div>
319 319
 			<?php
320 320
 
321
-			include_once "footer.inc.php";
322
-		} else {
323
-			if($input['stay'] != '') {
324
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
-				header($header);
327
-			} else {
328
-				$header = "Location: index.php?a=99&r=2";
329
-				header($header);
330
-			}
331
-		}
332
-		break;
333
-	default :
334
-		webAlertAndQuit("No operation set in request.");
321
+            include_once "footer.inc.php";
322
+        } else {
323
+            if($input['stay'] != '') {
324
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
+                header($header);
327
+            } else {
328
+                $header = "Location: index.php?a=99&r=2";
329
+                header($header);
330
+            }
331
+        }
332
+        break;
333
+    default :
334
+        webAlertAndQuit("No operation set in request.");
335 335
 }
336 336
 
337 337
 /**
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
  * @return string
342 342
  */
343 343
 function save_user_quoted_printable($string) {
344
-	$crlf = "\n";
345
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346
-	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347
-	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
-	$f[] = '/([\011\040])' . $crlf . '/e';
349
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
350
-	$string = preg_replace($f, $r, $string);
351
-	return trim(wordwrap($string, 70, ' =' . $crlf));
344
+    $crlf = "\n";
345
+    $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346
+    $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347
+    $r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
+    $f[] = '/([\011\040])' . $crlf . '/e';
349
+    $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
350
+    $string = preg_replace($f, $r, $string);
351
+    return trim(wordwrap($string, 70, ' =' . $crlf));
352 352
 }
353 353
 
354 354
 /**
@@ -360,94 +360,94 @@  discard block
 block discarded – undo
360 360
  * @param string $ufn
361 361
  */
362 362
 function sendMailMessage($email, $uid, $pwd, $ufn) {
363
-	global $modx, $_lang, $websignupemail_message;
364
-	global $emailsubject, $emailsender;
365
-	global $site_name, $site_url;
366
-	$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
367
-	// replace placeholders
368
-	$message = str_replace("[+uid+]", $uid, $message);
369
-	$message = str_replace("[+pwd+]", $pwd, $message);
370
-	$message = str_replace("[+ufn+]", $ufn, $message);
371
-	$message = str_replace("[+sname+]", $site_name, $message);
372
-	$message = str_replace("[+saddr+]", $emailsender, $message);
373
-	$message = str_replace("[+semail+]", $emailsender, $message);
374
-	$message = str_replace("[+surl+]", $site_url, $message);
375
-
376
-	$param = array();
377
-	$param['from'] = "{$site_name}<{$emailsender}>";
378
-	$param['subject'] = $emailsubject;
379
-	$param['body'] = $message;
380
-	$param['to'] = $email;
381
-	$param['type'] = 'text';
382
-	$rs = $modx->sendmail($param);
383
-	if(!$rs) {
384
-		$modx->manager->saveFormValues();
385
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386
-	}
363
+    global $modx, $_lang, $websignupemail_message;
364
+    global $emailsubject, $emailsender;
365
+    global $site_name, $site_url;
366
+    $message = sprintf($websignupemail_message, $uid, $pwd); // use old method
367
+    // replace placeholders
368
+    $message = str_replace("[+uid+]", $uid, $message);
369
+    $message = str_replace("[+pwd+]", $pwd, $message);
370
+    $message = str_replace("[+ufn+]", $ufn, $message);
371
+    $message = str_replace("[+sname+]", $site_name, $message);
372
+    $message = str_replace("[+saddr+]", $emailsender, $message);
373
+    $message = str_replace("[+semail+]", $emailsender, $message);
374
+    $message = str_replace("[+surl+]", $site_url, $message);
375
+
376
+    $param = array();
377
+    $param['from'] = "{$site_name}<{$emailsender}>";
378
+    $param['subject'] = $emailsubject;
379
+    $param['body'] = $message;
380
+    $param['to'] = $email;
381
+    $param['type'] = 'text';
382
+    $rs = $modx->sendmail($param);
383
+    if(!$rs) {
384
+        $modx->manager->saveFormValues();
385
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386
+    }
387 387
 }
388 388
 
389 389
 // Save User Settings
390 390
 function saveUserSettings($id) {
391
-	global $modx;
392
-	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393
-
394
-	$settings = array(
395
-		"login_home",
396
-		"allowed_ip",
397
-		"allowed_days"
398
-	);
399
-
400
-	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401
-
402
-	foreach($settings as $n) {
403
-		$vl = $_POST[$n];
404
-		if(is_array($vl)) {
405
-			$vl = implode(",", $vl);
406
-		}
407
-		if($vl != '') {
408
-			$f = array();
409
-			$f['webuser'] = $id;
410
-			$f['setting_name'] = $n;
411
-			$f['setting_value'] = $vl;
412
-			$f = $modx->db->escape($f);
413
-			$modx->db->insert($f, $tbl_web_user_settings);
414
-		}
415
-	}
391
+    global $modx;
392
+    $tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393
+
394
+    $settings = array(
395
+        "login_home",
396
+        "allowed_ip",
397
+        "allowed_days"
398
+    );
399
+
400
+    $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401
+
402
+    foreach($settings as $n) {
403
+        $vl = $_POST[$n];
404
+        if(is_array($vl)) {
405
+            $vl = implode(",", $vl);
406
+        }
407
+        if($vl != '') {
408
+            $f = array();
409
+            $f['webuser'] = $id;
410
+            $f['setting_name'] = $n;
411
+            $f['setting_value'] = $vl;
412
+            $f = $modx->db->escape($f);
413
+            $modx->db->insert($f, $tbl_web_user_settings);
414
+        }
415
+    }
416 416
 }
417 417
 
418 418
 // Web alert -  sends an alert to web browser
419 419
 function webAlertAndQuit($msg) {
420
-	global $id, $modx;
421
-	$mode = $_POST['mode'];
422
-	$modx->manager->saveFormValues($mode);
423
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
420
+    global $id, $modx;
421
+    $mode = $_POST['mode'];
422
+    $modx->manager->saveFormValues($mode);
423
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
424 424
 }
425 425
 
426 426
 // Generate password
427 427
 function generate_password($length = 10) {
428
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429
-	$ps_len = strlen($allowable_characters);
430
-	mt_srand((double) microtime() * 1000000);
431
-	$pass = "";
432
-	for($i = 0; $i < $length; $i++) {
433
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434
-	}
435
-	return $pass;
428
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429
+    $ps_len = strlen($allowable_characters);
430
+    mt_srand((double) microtime() * 1000000);
431
+    $pass = "";
432
+    for($i = 0; $i < $length; $i++) {
433
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434
+    }
435
+    return $pass;
436 436
 }
437 437
 
438 438
 function sanitize($str = '', $safecount = 0) {
439
-	global $modx;
440
-	$safecount++;
441
-	if(1000 < $safecount) {
442
-		exit("error too many loops '{$safecount}'");
443
-	}
444
-	if(is_array($str)) {
445
-		foreach($str as $i => $v) {
446
-			$str[$i] = sanitize($v, $safecount);
447
-		}
448
-	} else {
449
-		// $str = strip_tags($str); // LEAVE < and > intact
450
-		$str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
451
-	}
452
-	return $str;
439
+    global $modx;
440
+    $safecount++;
441
+    if(1000 < $safecount) {
442
+        exit("error too many loops '{$safecount}'");
443
+    }
444
+    if(is_array($str)) {
445
+        foreach($str as $i => $v) {
446
+            $str[$i] = sanitize($v, $safecount);
447
+        }
448
+    } else {
449
+        // $str = strip_tags($str); // LEAVE < and > intact
450
+        $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
451
+    }
452
+    return $str;
453 453
 }
Please login to merge, or discard this patch.
Switch Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -60,108 +60,108 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!");
69
-		}
70
-
71
-		// check if the email address already exist
72
-		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
-		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("Email is already in use!");
76
-		}
63
+	    case '87' : // new user
64
+		    // check if this user name already exist
65
+		    $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+		    $limit = $modx->db->getValue($rs);
67
+		    if($limit > 0) {
68
+			    webAlertAndQuit("User name is already in use!");
69
+		    }
70
+
71
+		    // check if the email address already exist
72
+		    $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
+		    $limit = $modx->db->getValue($rs);
74
+		    if($limit > 0) {
75
+			    webAlertAndQuit("Email is already in use!");
76
+		    }
77
+
78
+		    // generate a new password for this user
79
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+			    if(strlen($specifiedpassword) < 6) {
81
+				    webAlertAndQuit("Password is too short!");
82
+			    } else {
83
+				    $newpassword = $specifiedpassword;
84
+			    }
85
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
+			    webAlertAndQuit("You didn't specify a password for this user!");
87
+		    } elseif($passwordgenmethod == 'g') {
88
+			    $newpassword = generate_password(8);
89
+		    } else {
90
+			    webAlertAndQuit("No password generation method specified!");
91
+		    }
92
+
93
+		    // invoke OnBeforeWUsrFormSave event
94
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
+			    "mode" => "new",
96
+		    ));
97
+
98
+		    // create the user account
99
+		    $field = array();
100
+		    $field['username'] = $esc_newusername;
101
+		    $field['password'] = md5($newpassword);
102
+		    $internalKey = $modx->db->insert($field, $tbl_web_users);
103
+
104
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
+		    $field = $modx->db->escape($field);
106
+		    $modx->db->insert($field, $tbl_web_user_attributes);
107
+
108
+		    // Save User Settings
109
+		    saveUserSettings($internalKey);
110
+
111
+		    // Set the item name for logger
112
+		    $_SESSION['itemname'] = $newusername;
113
+
114
+		    /*******************************************************************************/
115
+		    // put the user in the user_groups he/ she should be in
116
+		    // first, check that up_perms are switched on!
117
+		    if($use_udperms == 1) {
118
+			    if(!empty($user_groups)) {
119
+				    for($i = 0; $i < count($user_groups); $i++) {
120
+					    $f = array();
121
+					    $f['webgroup'] = (int)$user_groups[$i];
122
+					    $f['webuser'] = $internalKey;
123
+					    $modx->db->insert($f, $tbl_web_groups);
124
+				    }
125
+			    }
126
+		    }
127
+		    // end of user_groups stuff!
128
+
129
+            // invoke OnWebSaveUser event
130
+            $modx->invokeEvent("OnWebSaveUser", array(
131
+                "mode" => "new",
132
+                "userid" => $internalKey,
133
+                "username" => $newusername,
134
+                "userpassword" => $newpassword,
135
+                "useremail" => $email,
136
+                "userfullname" => $fullname
137
+            ));
77 138
 
78
-		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
81
-				webAlertAndQuit("Password is too short!");
82
-			} else {
83
-				$newpassword = $specifiedpassword;
84
-			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
-			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
88
-			$newpassword = generate_password(8);
89
-		} else {
90
-			webAlertAndQuit("No password generation method specified!");
91
-		}
139
+            // invoke OnWUsrFormSave event
140
+            $modx->invokeEvent("OnWUsrFormSave", array(
141
+                "mode" => "new",
142
+                "id" => $internalKey
143
+            ));
92 144
 
93
-		// invoke OnBeforeWUsrFormSave event
94
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
-			"mode" => "new",
96
-		));
97
-
98
-		// create the user account
99
-		$field = array();
100
-		$field['username'] = $esc_newusername;
101
-		$field['password'] = md5($newpassword);
102
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
103
-
104
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
-		$field = $modx->db->escape($field);
106
-		$modx->db->insert($field, $tbl_web_user_attributes);
107
-
108
-		// Save User Settings
109
-		saveUserSettings($internalKey);
110
-
111
-		// Set the item name for logger
112
-		$_SESSION['itemname'] = $newusername;
113
-
114
-		/*******************************************************************************/
115
-		// put the user in the user_groups he/ she should be in
116
-		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
120
-					$f = array();
121
-					$f['webgroup'] = (int)$user_groups[$i];
122
-					$f['webuser'] = $internalKey;
123
-					$modx->db->insert($f, $tbl_web_groups);
124
-				}
125
-			}
126
-		}
127
-		// end of user_groups stuff!
128
-
129
-        // invoke OnWebSaveUser event
130
-        $modx->invokeEvent("OnWebSaveUser", array(
131
-            "mode" => "new",
132
-            "userid" => $internalKey,
133
-            "username" => $newusername,
134
-            "userpassword" => $newpassword,
135
-            "useremail" => $email,
136
-            "userfullname" => $fullname
137
-        ));
138
-
139
-        // invoke OnWUsrFormSave event
140
-        $modx->invokeEvent("OnWUsrFormSave", array(
141
-            "mode" => "new",
142
-            "id" => $internalKey
143
-        ));
144
-
145
-		if($passwordnotifymethod == 'e') {
146
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
148
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
-				header($header);
151
-			} else {
152
-				$header = "Location: index.php?a=99&r=2";
153
-				header($header);
154
-			}
155
-		} else {
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-			} else {
160
-				$stayUrl = "index.php?a=99&r=2";
161
-			}
162
-
163
-			include_once "header.inc.php";
164
-			?>
145
+		    if($passwordnotifymethod == 'e') {
146
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
147
+			    if($input['stay'] != '') {
148
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
+				    header($header);
151
+			    } else {
152
+				    $header = "Location: index.php?a=99&r=2";
153
+				    header($header);
154
+			    }
155
+		    } else {
156
+			    if($input['stay'] != '') {
157
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+			    } else {
160
+				    $stayUrl = "index.php?a=99&r=2";
161
+			    }
162
+
163
+			    include_once "header.inc.php";
164
+			    ?>
165 165
 
166 166
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
167 167
 
@@ -183,122 +183,122 @@  discard block
 block discarded – undo
183 183
 			</div>
184 184
 			<?php
185 185
 
186
-			include_once "footer.inc.php";
187
-		}
188
-		break;
189
-	case '88' : // edit user
190
-		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
194
-					webAlertAndQuit("Password is too short!");
195
-				} else {
196
-					$newpassword = $specifiedpassword;
197
-				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
-				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
201
-				$newpassword = generate_password(8);
202
-			} else {
203
-				webAlertAndQuit("No password generation method specified!");
204
-			}
205
-		}
206
-		if($passwordnotifymethod == 'e') {
207
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
208
-		}
209
-
210
-		// check if the username already exist
211
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
-		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
214
-			webAlertAndQuit("User name is already in use!");
215
-		}
216
-
217
-		// check if the email address already exists
218
-		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
-		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
221
-			webAlertAndQuit("Email is already in use!");
222
-		}
223
-
224
-		// invoke OnBeforeWUsrFormSave event
225
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
-			"mode" => "upd",
227
-			"id" => $id
228
-		));
229
-
230
-		// update user name and password
231
-		$field = array();
232
-		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
234
-			$field['password'] = md5($newpassword);
235
-		}
236
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
-		$field = $modx->db->escape($field);
239
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
-
241
-		// Save User Settings
242
-		saveUserSettings($id);
243
-
244
-		// Set the item name for logger
245
-		$_SESSION['itemname'] = $newusername;
246
-
247
-		/*******************************************************************************/
248
-		// put the user in the user_groups he/ she should be in
249
-		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
251
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
255
-					$field = array();
256
-					$field['webgroup'] = (int)$user_groups[$i];
257
-					$field['webuser'] = $id;
258
-					$modx->db->insert($field, $tbl_web_groups);
259
-				}
260
-			}
261
-		}
262
-		// end of user_groups stuff!
263
-		/*******************************************************************************/
264
-
265
-        // invoke OnWebSaveUser event
266
-        $modx->invokeEvent("OnWebSaveUser", array(
267
-            "mode" => "upd",
268
-            "userid" => $id,
269
-            "username" => $newusername,
270
-            "userpassword" => $newpassword,
271
-            "useremail" => $email,
272
-            "userfullname" => $fullname,
273
-            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
274
-            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
275
-        ));
276
-
277
-        // invoke OnWebChangePassword event
278
-        if($genpassword == 1) {
279
-            $modx->invokeEvent("OnWebChangePassword", array(
186
+			    include_once "footer.inc.php";
187
+		    }
188
+		    break;
189
+	    case '88' : // edit user
190
+		    // generate a new password for this user
191
+		    if($genpassword == 1) {
192
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+				    if(strlen($specifiedpassword) < 6) {
194
+					    webAlertAndQuit("Password is too short!");
195
+				    } else {
196
+					    $newpassword = $specifiedpassword;
197
+				    }
198
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
+				    webAlertAndQuit("You didn't specify a password for this user!");
200
+			    } elseif($passwordgenmethod == 'g') {
201
+				    $newpassword = generate_password(8);
202
+			    } else {
203
+				    webAlertAndQuit("No password generation method specified!");
204
+			    }
205
+		    }
206
+		    if($passwordnotifymethod == 'e') {
207
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
208
+		    }
209
+
210
+		    // check if the username already exist
211
+		    $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
+		    $limit = $modx->db->getValue($rs);
213
+		    if($limit > 0) {
214
+			    webAlertAndQuit("User name is already in use!");
215
+		    }
216
+
217
+		    // check if the email address already exists
218
+		    $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
+		    $limit = $modx->db->getValue($rs);
220
+		    if($limit > 0) {
221
+			    webAlertAndQuit("Email is already in use!");
222
+		    }
223
+
224
+		    // invoke OnBeforeWUsrFormSave event
225
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
+			    "mode" => "upd",
227
+			    "id" => $id
228
+		    ));
229
+
230
+		    // update user name and password
231
+		    $field = array();
232
+		    $field['username'] = $esc_newusername;
233
+		    if($genpassword == 1) {
234
+			    $field['password'] = md5($newpassword);
235
+		    }
236
+		    $modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
+		    $field = $modx->db->escape($field);
239
+		    $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
+
241
+		    // Save User Settings
242
+		    saveUserSettings($id);
243
+
244
+		    // Set the item name for logger
245
+		    $_SESSION['itemname'] = $newusername;
246
+
247
+		    /*******************************************************************************/
248
+		    // put the user in the user_groups he/ she should be in
249
+		    // first, check that up_perms are switched on!
250
+		    if($use_udperms == 1) {
251
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
+			    $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
+			    if(!empty($user_groups)) {
254
+				    for($i = 0; $i < count($user_groups); $i++) {
255
+					    $field = array();
256
+					    $field['webgroup'] = (int)$user_groups[$i];
257
+					    $field['webuser'] = $id;
258
+					    $modx->db->insert($field, $tbl_web_groups);
259
+				    }
260
+			    }
261
+		    }
262
+		    // end of user_groups stuff!
263
+		    /*******************************************************************************/
264
+
265
+            // invoke OnWebSaveUser event
266
+            $modx->invokeEvent("OnWebSaveUser", array(
267
+                "mode" => "upd",
280 268
                 "userid" => $id,
281 269
                 "username" => $newusername,
282
-                "userpassword" => $newpassword
270
+                "userpassword" => $newpassword,
271
+                "useremail" => $email,
272
+                "userfullname" => $fullname,
273
+                "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
274
+                "olduseremail" => (($oldemail != $email) ? $oldemail : "")
283 275
             ));
284
-        }
285 276
 
286
-        // invoke OnWUsrFormSave event
287
-        $modx->invokeEvent("OnWUsrFormSave", array(
288
-            "mode" => "upd",
289
-            "id" => $id
290
-        ));
277
+            // invoke OnWebChangePassword event
278
+            if($genpassword == 1) {
279
+                $modx->invokeEvent("OnWebChangePassword", array(
280
+                    "userid" => $id,
281
+                    "username" => $newusername,
282
+                    "userpassword" => $newpassword
283
+                ));
284
+            }
285
+
286
+            // invoke OnWUsrFormSave event
287
+            $modx->invokeEvent("OnWUsrFormSave", array(
288
+                "mode" => "upd",
289
+                "id" => $id
290
+            ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
294
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
-			} else {
297
-				$stayUrl = "index.php?a=99&r=2";
298
-			}
292
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
293
+			    if($input['stay'] != '') {
294
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
+			    } else {
297
+				    $stayUrl = "index.php?a=99&r=2";
298
+			    }
299 299
 
300
-			include_once "header.inc.php";
301
-			?>
300
+			    include_once "header.inc.php";
301
+			    ?>
302 302
 
303 303
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
304 304
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 			</div>
319 319
 			<?php
320 320
 
321
-			include_once "footer.inc.php";
322
-		} else {
323
-			if($input['stay'] != '') {
324
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
-				header($header);
327
-			} else {
328
-				$header = "Location: index.php?a=99&r=2";
329
-				header($header);
330
-			}
331
-		}
332
-		break;
333
-	default :
334
-		webAlertAndQuit("No operation set in request.");
321
+			    include_once "footer.inc.php";
322
+		    } else {
323
+			    if($input['stay'] != '') {
324
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
+				    header($header);
327
+			    } else {
328
+				    $header = "Location: index.php?a=99&r=2";
329
+				    header($header);
330
+			    }
331
+		    }
332
+		    break;
333
+	    default :
334
+		    webAlertAndQuit("No operation set in request.");
335 335
 }
336 336
 
337 337
 /**
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('save_web_user')) {
5
+if (!$modx->hasPermission('save_web_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 $tbl_web_groups = $modx->getFullTableName('web_groups');
12 12
 
13 13
 $input = $_POST;
14
-foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
14
+foreach ($input as $k => $v) {
15
+	if ($k !== 'comment') {
16 16
 		$v = sanitize($v);
17 17
 	}
18 18
 	$input[$k] = $v;
19 19
 }
20 20
 
21
-$id = (int)$input['id'];
21
+$id = (int) $input['id'];
22 22
 $oldusername = $input['oldusername'];
23 23
 $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User";
24 24
 $esc_newusername = $modx->db->escape($newusername);
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
 $user_groups = $input['user_groups'];
51 51
 
52 52
 // verify password
53
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
53
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54 54
 	webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
58
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59 59
 	webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62
-switch($input['mode']) {
62
+switch ($input['mode']) {
63 63
 	case '87' : // new user
64 64
 		// check if this user name already exist
65 65
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66 66
 		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
67
+		if ($limit > 0) {
68 68
 			webAlertAndQuit("User name is already in use!");
69 69
 		}
70 70
 
71 71
 		// check if the email address already exist
72 72
 		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73 73
 		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
74
+		if ($limit > 0) {
75 75
 			webAlertAndQuit("Email is already in use!");
76 76
 		}
77 77
 
78 78
 		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
79
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+			if (strlen($specifiedpassword) < 6) {
81 81
 				webAlertAndQuit("Password is too short!");
82 82
 			} else {
83 83
 				$newpassword = $specifiedpassword;
84 84
 			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
85
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
86 86
 			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
87
+		} elseif ($passwordgenmethod == 'g') {
88 88
 			$newpassword = generate_password(8);
89 89
 		} else {
90 90
 			webAlertAndQuit("No password generation method specified!");
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 		/*******************************************************************************/
115 115
 		// put the user in the user_groups he/ she should be in
116 116
 		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
117
+		if ($use_udperms == 1) {
118
+			if (!empty($user_groups)) {
119
+				for ($i = 0; $i < count($user_groups); $i++) {
120 120
 					$f = array();
121
-					$f['webgroup'] = (int)$user_groups[$i];
121
+					$f['webgroup'] = (int) $user_groups[$i];
122 122
 					$f['webuser'] = $internalKey;
123 123
 					$modx->db->insert($f, $tbl_web_groups);
124 124
 				}
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
145
+		if ($passwordnotifymethod == 'e') {
146 146
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
147
+			if ($input['stay'] != '') {
148 148
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
149
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
150 150
 				header($header);
151 151
 			} else {
152 152
 				$header = "Location: index.php?a=99&r=2";
153 153
 				header($header);
154 154
 			}
155 155
 		} else {
156
-			if($input['stay'] != '') {
156
+			if ($input['stay'] != '') {
157 157
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
158
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
159 159
 			} else {
160 160
 				$stayUrl = "index.php?a=99&r=2";
161 161
 			}
@@ -188,36 +188,36 @@  discard block
 block discarded – undo
188 188
 		break;
189 189
 	case '88' : // edit user
190 190
 		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
191
+		if ($genpassword == 1) {
192
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+				if (strlen($specifiedpassword) < 6) {
194 194
 					webAlertAndQuit("Password is too short!");
195 195
 				} else {
196 196
 					$newpassword = $specifiedpassword;
197 197
 				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
198
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
199 199
 				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
200
+			} elseif ($passwordgenmethod == 'g') {
201 201
 				$newpassword = generate_password(8);
202 202
 			} else {
203 203
 				webAlertAndQuit("No password generation method specified!");
204 204
 			}
205 205
 		}
206
-		if($passwordnotifymethod == 'e') {
206
+		if ($passwordnotifymethod == 'e') {
207 207
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
208 208
 		}
209 209
 
210 210
 		// check if the username already exist
211 211
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212 212
 		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
213
+		if ($limit > 0) {
214 214
 			webAlertAndQuit("User name is already in use!");
215 215
 		}
216 216
 
217 217
 		// check if the email address already exists
218 218
 		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219 219
 		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
220
+		if ($limit > 0) {
221 221
 			webAlertAndQuit("Email is already in use!");
222 222
 		}
223 223
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		// update user name and password
231 231
 		$field = array();
232 232
 		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
233
+		if ($genpassword == 1) {
234 234
 			$field['password'] = md5($newpassword);
235 235
 		}
236 236
 		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 		/*******************************************************************************/
248 248
 		// put the user in the user_groups he/ she should be in
249 249
 		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
250
+		if ($use_udperms == 1) {
251 251
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252 252
 			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
253
+			if (!empty($user_groups)) {
254
+				for ($i = 0; $i < count($user_groups); $i++) {
255 255
 					$field = array();
256
-					$field['webgroup'] = (int)$user_groups[$i];
256
+					$field['webgroup'] = (int) $user_groups[$i];
257 257
 					$field['webuser'] = $id;
258 258
 					$modx->db->insert($field, $tbl_web_groups);
259 259
 				}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         ));
276 276
 
277 277
         // invoke OnWebChangePassword event
278
-        if($genpassword == 1) {
278
+        if ($genpassword == 1) {
279 279
             $modx->invokeEvent("OnWebChangePassword", array(
280 280
                 "userid" => $id,
281 281
                 "username" => $newusername,
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
292
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
293
+			if ($input['stay'] != '') {
294 294
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
295
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
296 296
 			} else {
297 297
 				$stayUrl = "index.php?a=99&r=2";
298 298
 			}
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 
321 321
 			include_once "footer.inc.php";
322 322
 		} else {
323
-			if($input['stay'] != '') {
323
+			if ($input['stay'] != '') {
324 324
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
325
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
326 326
 				header($header);
327 327
 			} else {
328 328
 				$header = "Location: index.php?a=99&r=2";
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
  * @param string $string
341 341
  * @return string
342 342
  */
343
-function save_user_quoted_printable($string) {
343
+function save_user_quoted_printable($string){
344 344
 	$crlf = "\n";
345
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
345
+	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf;
346 346
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347 347
 	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
-	$f[] = '/([\011\040])' . $crlf . '/e';
349
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
348
+	$f[] = '/([\011\040])'.$crlf.'/e';
349
+	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'";
350 350
 	$string = preg_replace($f, $r, $string);
351
-	return trim(wordwrap($string, 70, ' =' . $crlf));
351
+	return trim(wordwrap($string, 70, ' ='.$crlf));
352 352
 }
353 353
 
354 354
 /**
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
  * @param string $pwd
360 360
  * @param string $ufn
361 361
  */
362
-function sendMailMessage($email, $uid, $pwd, $ufn) {
362
+function sendMailMessage($email, $uid, $pwd, $ufn){
363 363
 	global $modx, $_lang, $websignupemail_message;
364 364
 	global $emailsubject, $emailsender;
365 365
 	global $site_name, $site_url;
@@ -380,14 +380,14 @@  discard block
 block discarded – undo
380 380
 	$param['to'] = $email;
381 381
 	$param['type'] = 'text';
382 382
 	$rs = $modx->sendmail($param);
383
-	if(!$rs) {
383
+	if (!$rs) {
384 384
 		$modx->manager->saveFormValues();
385 385
 		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386 386
 	}
387 387
 }
388 388
 
389 389
 // Save User Settings
390
-function saveUserSettings($id) {
390
+function saveUserSettings($id){
391 391
 	global $modx;
392 392
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 393
 
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
 
400 400
 	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401 401
 
402
-	foreach($settings as $n) {
402
+	foreach ($settings as $n) {
403 403
 		$vl = $_POST[$n];
404
-		if(is_array($vl)) {
404
+		if (is_array($vl)) {
405 405
 			$vl = implode(",", $vl);
406 406
 		}
407
-		if($vl != '') {
407
+		if ($vl != '') {
408 408
 			$f = array();
409 409
 			$f['webuser'] = $id;
410 410
 			$f['setting_name'] = $n;
@@ -416,33 +416,33 @@  discard block
 block discarded – undo
416 416
 }
417 417
 
418 418
 // Web alert -  sends an alert to web browser
419
-function webAlertAndQuit($msg) {
419
+function webAlertAndQuit($msg){
420 420
 	global $id, $modx;
421 421
 	$mode = $_POST['mode'];
422 422
 	$modx->manager->saveFormValues($mode);
423
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
423
+	$modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : ''));
424 424
 }
425 425
 
426 426
 // Generate password
427
-function generate_password($length = 10) {
427
+function generate_password($length = 10){
428 428
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429 429
 	$ps_len = strlen($allowable_characters);
430 430
 	mt_srand((double) microtime() * 1000000);
431 431
 	$pass = "";
432
-	for($i = 0; $i < $length; $i++) {
432
+	for ($i = 0; $i < $length; $i++) {
433 433
 		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434 434
 	}
435 435
 	return $pass;
436 436
 }
437 437
 
438
-function sanitize($str = '', $safecount = 0) {
438
+function sanitize($str = '', $safecount = 0){
439 439
 	global $modx;
440 440
 	$safecount++;
441
-	if(1000 < $safecount) {
441
+	if (1000 < $safecount) {
442 442
 		exit("error too many loops '{$safecount}'");
443 443
 	}
444
-	if(is_array($str)) {
445
-		foreach($str as $i => $v) {
444
+	if (is_array($str)) {
445
+		foreach ($str as $i => $v) {
446 446
 			$str[$i] = sanitize($v, $safecount);
447 447
 		}
448 448
 	} else {
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -340,7 +340,8 @@  discard block
 block discarded – undo
340 340
  * @param string $string
341 341
  * @return string
342 342
  */
343
-function save_user_quoted_printable($string) {
343
+function save_user_quoted_printable($string)
344
+{
344 345
 	$crlf = "\n";
345 346
 	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346 347
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
@@ -359,7 +360,8 @@  discard block
 block discarded – undo
359 360
  * @param string $pwd
360 361
  * @param string $ufn
361 362
  */
362
-function sendMailMessage($email, $uid, $pwd, $ufn) {
363
+function sendMailMessage($email, $uid, $pwd, $ufn)
364
+{
363 365
 	global $modx, $_lang, $websignupemail_message;
364 366
 	global $emailsubject, $emailsender;
365 367
 	global $site_name, $site_url;
@@ -387,7 +389,8 @@  discard block
 block discarded – undo
387 389
 }
388 390
 
389 391
 // Save User Settings
390
-function saveUserSettings($id) {
392
+function saveUserSettings($id)
393
+{
391 394
 	global $modx;
392 395
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 396
 
@@ -416,7 +419,8 @@  discard block
 block discarded – undo
416 419
 }
417 420
 
418 421
 // Web alert -  sends an alert to web browser
419
-function webAlertAndQuit($msg) {
422
+function webAlertAndQuit($msg)
423
+{
420 424
 	global $id, $modx;
421 425
 	$mode = $_POST['mode'];
422 426
 	$modx->manager->saveFormValues($mode);
@@ -424,7 +428,8 @@  discard block
 block discarded – undo
424 428
 }
425 429
 
426 430
 // Generate password
427
-function generate_password($length = 10) {
431
+function generate_password($length = 10)
432
+{
428 433
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429 434
 	$ps_len = strlen($allowable_characters);
430 435
 	mt_srand((double) microtime() * 1000000);
@@ -435,7 +440,8 @@  discard block
 block discarded – undo
435 440
 	return $pass;
436 441
 }
437 442
 
438
-function sanitize($str = '', $safecount = 0) {
443
+function sanitize($str = '', $safecount = 0)
444
+{
439 445
 	global $modx;
440 446
 	$safecount++;
441 447
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.
manager/processors/save_module.processor.php 1 patch
Switch Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -59,125 +59,125 @@
 block discarded – undo
59 59
 }
60 60
 
61 61
 switch ($_POST['mode']) {
62
-    case '107':
63
-        // invoke OnBeforeModFormSave event
64
-        $modx->invokeEvent("OnBeforeModFormSave", array(
65
-                "mode" => "new",
66
-                "id" => $id
67
-            ));
68
-
69
-        // disallow duplicate names for new modules
70
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
-        $count = $modx->db->getValue($rs);
72
-        if ($count > 0) {
73
-            $modx->manager->saveFormValues(107);
74
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
-        }
62
+        case '107':
63
+            // invoke OnBeforeModFormSave event
64
+            $modx->invokeEvent("OnBeforeModFormSave", array(
65
+                    "mode" => "new",
66
+                    "id" => $id
67
+                ));
68
+
69
+            // disallow duplicate names for new modules
70
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
+            $count = $modx->db->getValue($rs);
72
+            if ($count > 0) {
73
+                $modx->manager->saveFormValues(107);
74
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
+            }
76 76
 
77
-        // save the new module
78
-        $newid = $modx->db->insert(array(
79
-            'name' => $name,
80
-            'description' => $description,
81
-            'disabled' => $disabled,
82
-            'wrap' => $wrap,
83
-            'locked' => $locked,
84
-            'icon' => $icon,
85
-            'resourcefile' => $resourcefile,
86
-            'enable_resource' => $enable_resource,
87
-            'category' => $categoryid,
88
-            'enable_sharedparams' => $enable_sharedparams,
89
-            'guid' => $guid,
90
-            'modulecode' => $modulecode,
91
-            'properties' => $properties,
92
-            'createdon' => $currentdate,
93
-            'editedon' => $currentdate
94
-        ), $modx->getFullTableName('site_modules'));
95
-
96
-        // save user group access permissions
97
-        saveUserGroupAccessPermissons();
98
-
99
-        // invoke OnModFormSave event
100
-        $modx->invokeEvent("OnModFormSave", array(
101
-                "mode" => "new",
102
-                "id" => $newid
103
-            ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=106&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '108':
122
-        // invoke OnBeforeModFormSave event
123
-        $modx->invokeEvent("OnBeforeModFormSave", array(
124
-                "mode" => "upd",
125
-                "id" => $id
126
-            ));
127
-
128
-        // disallow duplicate names for new modules
129
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->db->getValue($rs) > 0) {
131
-            $modx->manager->saveFormValues(108);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
-        }
77
+            // save the new module
78
+            $newid = $modx->db->insert(array(
79
+                'name' => $name,
80
+                'description' => $description,
81
+                'disabled' => $disabled,
82
+                'wrap' => $wrap,
83
+                'locked' => $locked,
84
+                'icon' => $icon,
85
+                'resourcefile' => $resourcefile,
86
+                'enable_resource' => $enable_resource,
87
+                'category' => $categoryid,
88
+                'enable_sharedparams' => $enable_sharedparams,
89
+                'guid' => $guid,
90
+                'modulecode' => $modulecode,
91
+                'properties' => $properties,
92
+                'createdon' => $currentdate,
93
+                'editedon' => $currentdate
94
+            ), $modx->getFullTableName('site_modules'));
95
+
96
+            // save user group access permissions
97
+            saveUserGroupAccessPermissons();
98
+
99
+            // invoke OnModFormSave event
100
+            $modx->invokeEvent("OnModFormSave", array(
101
+                    "mode" => "new",
102
+                    "id" => $newid
103
+                ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=106&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '108':
122
+            // invoke OnBeforeModFormSave event
123
+            $modx->invokeEvent("OnBeforeModFormSave", array(
124
+                    "mode" => "upd",
125
+                    "id" => $id
126
+                ));
127
+
128
+            // disallow duplicate names for new modules
129
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->db->getValue($rs) > 0) {
131
+                $modx->manager->saveFormValues(108);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
+            }
134 134
 
135
-        // save the edited module
136
-        $modx->db->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'icon' => $icon,
140
-            'enable_resource' => $enable_resource,
141
-            'resourcefile' => $resourcefile,
142
-            'disabled' => $disabled,
143
-            'wrap' => $wrap,
144
-            'locked' => $locked,
145
-            'category' => $categoryid,
146
-            'enable_sharedparams' => $enable_sharedparams,
147
-            'guid' => $guid,
148
-            'modulecode' => $modulecode,
149
-            'properties' => $properties,
150
-            'editedon' => $currentdate
151
-        ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
-
153
-        // save user group access permissions
154
-        saveUserGroupAccessPermissons();
155
-
156
-        // invoke OnModFormSave event
157
-        $modx->invokeEvent("OnModFormSave", array(
158
-                "mode" => "upd",
159
-                "id" => $id
160
-            ));
161
-
162
-        // Set the item name for logger
163
-        $_SESSION['itemname'] = $name;
164
-
165
-        // empty cache
166
-        $modx->clearCache('full');
167
-
168
-        // finished emptying cache - redirect
169
-        if ($_POST['stay'] != '') {
170
-            $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
-            header($header);
173
-        } else {
174
-            $modx->unlockElement(6, $id);
175
-            $header = "Location: index.php?a=106&r=2";
176
-            header($header);
177
-        }
178
-        break;
179
-    default:
180
-        $modx->webAlertAndQuit("No operation set in request.");
135
+            // save the edited module
136
+            $modx->db->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'icon' => $icon,
140
+                'enable_resource' => $enable_resource,
141
+                'resourcefile' => $resourcefile,
142
+                'disabled' => $disabled,
143
+                'wrap' => $wrap,
144
+                'locked' => $locked,
145
+                'category' => $categoryid,
146
+                'enable_sharedparams' => $enable_sharedparams,
147
+                'guid' => $guid,
148
+                'modulecode' => $modulecode,
149
+                'properties' => $properties,
150
+                'editedon' => $currentdate
151
+            ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
+
153
+            // save user group access permissions
154
+            saveUserGroupAccessPermissons();
155
+
156
+            // invoke OnModFormSave event
157
+            $modx->invokeEvent("OnModFormSave", array(
158
+                    "mode" => "upd",
159
+                    "id" => $id
160
+                ));
161
+
162
+            // Set the item name for logger
163
+            $_SESSION['itemname'] = $name;
164
+
165
+            // empty cache
166
+            $modx->clearCache('full');
167
+
168
+            // finished emptying cache - redirect
169
+            if ($_POST['stay'] != '') {
170
+                $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
+                header($header);
173
+            } else {
174
+                $modx->unlockElement(6, $id);
175
+                $header = "Location: index.php?a=106&r=2";
176
+                header($header);
177
+            }
178
+            break;
179
+        default:
180
+            $modx->webAlertAndQuit("No operation set in request.");
181 181
 }
182 182
 
183 183
 /**
Please login to merge, or discard this patch.