@@ -33,113 +33,113 @@ |
||
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->getDatabase()->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
46 | - $count = $modx->getDatabase()->getValue($rs); |
|
47 | - if ($count > 0) { |
|
48 | - $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
99 | - $count = $modx->getDatabase()->getValue($rs); |
|
100 | - if ($count > 0) { |
|
101 | - $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); |
|
46 | + $count = $modx->getDatabase()->getValue($rs); |
|
47 | + if ($count > 0) { |
|
48 | + $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); |
|
99 | + $count = $modx->getDatabase()->getValue($rs); |
|
100 | + if ($count > 0) { |
|
101 | + $modx->getManagerApi()->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->getDatabase()->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 | } |
@@ -1,27 +1,27 @@ discard block |
||
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('save_template')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $template = $modx->getDatabase()->escape($_POST['post']); |
11 | 11 | $templatename = $modx->getDatabase()->escape(trim($_POST['templatename'])); |
12 | 12 | $description = $modx->getDatabase()->escape($_POST['description']); |
13 | 13 | $locked = $_POST['locked'] == 'on' ? 1 : 0; |
14 | -$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
14 | +$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
15 | 15 | $_POST['selectable'] == 'on' ? 1 : 0; |
16 | 16 | $currentdate = time() + $modx->config['server_offset_time']; |
17 | 17 | |
18 | 18 | //Kyle Jaebker - added category support |
19 | 19 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
20 | - $categoryid = (int)$_POST['categoryid']; |
|
20 | + $categoryid = (int) $_POST['categoryid']; |
|
21 | 21 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
22 | 22 | $categoryid = 0; |
23 | 23 | } else { |
24 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
24 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
25 | 25 | $categoryid = checkCategory($_POST['newcategory']); |
26 | 26 | if (!$categoryid) { |
27 | 27 | $categoryid = newCategory($_POST['newcategory']); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // finished emptying cache - redirect |
79 | 79 | if ($_POST['stay'] != '') { |
80 | 80 | $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
81 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
82 | 82 | header($header); |
83 | 83 | } else { |
84 | 84 | $header = "Location: index.php?a=76&r=2"; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // finished emptying cache - redirect |
131 | 131 | if ($_POST['stay'] != '') { |
132 | 132 | $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
133 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
134 | 134 | header($header); |
135 | 135 | } else { |
136 | 136 | $modx->unlockElement(1, $id); |
@@ -3,12 +3,12 @@ discard block |
||
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('save_document')||!$modx->hasPermission('publish_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,20 +32,20 @@ discard block |
||
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 | // update the document |
39 | 39 | $modx->getDatabase()->update( |
40 | - array( |
|
41 | - 'published' => 0, |
|
42 | - 'pub_date' => 0, |
|
43 | - 'unpub_date' => 0, |
|
44 | - 'editedby' => $modx->getLoginUserID(), |
|
45 | - 'editedon' => time(), |
|
46 | - 'publishedby' => 0, |
|
47 | - 'publishedon' => 0, |
|
48 | - ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
40 | + array( |
|
41 | + 'published' => 0, |
|
42 | + 'pub_date' => 0, |
|
43 | + 'unpub_date' => 0, |
|
44 | + 'editedby' => $modx->getLoginUserID(), |
|
45 | + 'editedon' => time(), |
|
46 | + 'publishedby' => 0, |
|
47 | + 'publishedon' => 0, |
|
48 | + ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
49 | 49 | |
50 | 50 | // invoke OnDocUnPublished event |
51 | 51 | $modx->invokeEvent("OnDocUnPublished",array("docid"=>$id)); |
@@ -1,25 +1,25 @@ discard block |
||
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_document')||!$modx->hasPermission('publish_document')) { |
|
5 | +if (!$modx->hasPermission('save_document') || !$modx->hasPermission('publish_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->getDatabase()->getRow($modx->getDatabase()->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
15 | +$content = $modx->getDatabase()->getRow($modx->getDatabase()->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 | |
@@ -31,7 +31,7 @@ discard block |
||
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 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
49 | 49 | |
50 | 50 | // invoke OnDocUnPublished event |
51 | -$modx->invokeEvent("OnDocUnPublished",array("docid"=>$id)); |
|
51 | +$modx->invokeEvent("OnDocUnPublished", array("docid"=>$id)); |
|
52 | 52 | |
53 | 53 | // Set the item name for logger |
54 | 54 | $_SESSION['itemname'] = $content['pagetitle']; |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | // empty cache |
57 | 57 | $modx->clearCache('full'); |
58 | 58 | |
59 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
59 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
60 | 60 | |
61 | 61 | header($header); |
@@ -1,9 +1,9 @@ discard block |
||
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_user')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $tbl_manager_users = $modx->getFullTableName('manager_users'); |
@@ -43,134 +43,134 @@ discard block |
||
43 | 43 | |
44 | 44 | // verify password |
45 | 45 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
46 | - webAlertAndQuit("Password typed is mismatched", 12); |
|
46 | + webAlertAndQuit("Password typed is mismatched", 12); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // verify email |
50 | 50 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
51 | - webAlertAndQuit("E-mail address doesn't seem to be valid!", 12); |
|
51 | + webAlertAndQuit("E-mail address doesn't seem to be valid!", 12); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // verify admin security |
55 | 55 | if($_SESSION['mgrRole'] != 1) { |
56 | - // Check to see if user tried to spoof a "1" (admin) role |
|
57 | - if(!$modx->hasPermission('save_user')) { |
|
58 | - webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12); |
|
59 | - } |
|
60 | - // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
61 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
62 | - $limit = $modx->getDatabase()->getValue($rs); |
|
63 | - if($limit > 0) { |
|
64 | - webAlertAndQuit("You cannot alter an administrative user.", 12); |
|
65 | - } |
|
56 | + // Check to see if user tried to spoof a "1" (admin) role |
|
57 | + if(!$modx->hasPermission('save_user')) { |
|
58 | + webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12); |
|
59 | + } |
|
60 | + // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
61 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
62 | + $limit = $modx->getDatabase()->getValue($rs); |
|
63 | + if($limit > 0) { |
|
64 | + webAlertAndQuit("You cannot alter an administrative user.", 12); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | 69 | switch($input['mode']) { |
70 | - case '11' : // new user |
|
71 | - // check if this user name already exist |
|
72 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | - $limit = $modx->getDatabase()->getValue($rs); |
|
74 | - if($limit > 0) { |
|
75 | - webAlertAndQuit("User name is already in use!", 12); |
|
76 | - } |
|
77 | - |
|
78 | - // check if the email address already exist |
|
79 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | - $limit = $modx->getDatabase()->getValue($rs); |
|
81 | - if($limit > 0) { |
|
82 | - webAlertAndQuit("Email is already in use!", 12); |
|
83 | - } |
|
84 | - |
|
85 | - // generate a new password for this user |
|
86 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | - if(strlen($specifiedpassword) < 6) { |
|
88 | - webAlertAndQuit("Password is too short!", 12); |
|
89 | - } else { |
|
90 | - $newpassword = $specifiedpassword; |
|
91 | - } |
|
92 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | - } elseif($passwordgenmethod == 'g') { |
|
95 | - $newpassword = generate_password(8); |
|
96 | - } else { |
|
97 | - webAlertAndQuit("No password generation method specified!", 12); |
|
98 | - } |
|
99 | - |
|
100 | - // invoke OnBeforeUserFormSave event |
|
101 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | - "mode" => "new", |
|
103 | - )); |
|
104 | - |
|
105 | - // create the user account |
|
106 | - $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | - |
|
108 | - $field = array(); |
|
109 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | - |
|
112 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | - $field = $modx->getDatabase()->escape($field); |
|
114 | - $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | - |
|
116 | - // Save user settings |
|
70 | + case '11' : // new user |
|
71 | + // check if this user name already exist |
|
72 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | + $limit = $modx->getDatabase()->getValue($rs); |
|
74 | + if($limit > 0) { |
|
75 | + webAlertAndQuit("User name is already in use!", 12); |
|
76 | + } |
|
77 | + |
|
78 | + // check if the email address already exist |
|
79 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | + $limit = $modx->getDatabase()->getValue($rs); |
|
81 | + if($limit > 0) { |
|
82 | + webAlertAndQuit("Email is already in use!", 12); |
|
83 | + } |
|
84 | + |
|
85 | + // generate a new password for this user |
|
86 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | + if(strlen($specifiedpassword) < 6) { |
|
88 | + webAlertAndQuit("Password is too short!", 12); |
|
89 | + } else { |
|
90 | + $newpassword = $specifiedpassword; |
|
91 | + } |
|
92 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | + } elseif($passwordgenmethod == 'g') { |
|
95 | + $newpassword = generate_password(8); |
|
96 | + } else { |
|
97 | + webAlertAndQuit("No password generation method specified!", 12); |
|
98 | + } |
|
99 | + |
|
100 | + // invoke OnBeforeUserFormSave event |
|
101 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | + "mode" => "new", |
|
103 | + )); |
|
104 | + |
|
105 | + // create the user account |
|
106 | + $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | + |
|
108 | + $field = array(); |
|
109 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | + |
|
112 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | + $field = $modx->getDatabase()->escape($field); |
|
114 | + $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | + |
|
116 | + // Save user settings |
|
117 | 117 | saveManagerUserSettings($internalKey); |
118 | 118 | |
119 | - // invoke OnManagerSaveUser event |
|
120 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | - "mode" => "new", |
|
122 | - "userid" => $internalKey, |
|
123 | - "username" => $newusername, |
|
124 | - "userpassword" => $newpassword, |
|
125 | - "useremail" => $email, |
|
126 | - "userfullname" => $fullname, |
|
127 | - "userroleid" => $role |
|
128 | - )); |
|
129 | - |
|
130 | - // invoke OnUserFormSave event |
|
131 | - $modx->invokeEvent("OnUserFormSave", array( |
|
132 | - "mode" => "new", |
|
133 | - "id" => $internalKey |
|
134 | - )); |
|
135 | - |
|
136 | - // Set the item name for logger |
|
137 | - $_SESSION['itemname'] = $newusername; |
|
138 | - |
|
139 | - /*******************************************************************************/ |
|
140 | - // put the user in the user_groups he/ she should be in |
|
141 | - // first, check that up_perms are switched on! |
|
142 | - if($use_udperms == 1) { |
|
143 | - if(!empty($user_groups)) { |
|
144 | - for($i = 0; $i < count($user_groups); $i++) { |
|
145 | - $f = array(); |
|
146 | - $f['user_group'] = (int)$user_groups[$i]; |
|
147 | - $f['member'] = $internalKey; |
|
148 | - $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - // end of user_groups stuff! |
|
153 | - |
|
154 | - if($passwordnotifymethod == 'e') { |
|
119 | + // invoke OnManagerSaveUser event |
|
120 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | + "mode" => "new", |
|
122 | + "userid" => $internalKey, |
|
123 | + "username" => $newusername, |
|
124 | + "userpassword" => $newpassword, |
|
125 | + "useremail" => $email, |
|
126 | + "userfullname" => $fullname, |
|
127 | + "userroleid" => $role |
|
128 | + )); |
|
129 | + |
|
130 | + // invoke OnUserFormSave event |
|
131 | + $modx->invokeEvent("OnUserFormSave", array( |
|
132 | + "mode" => "new", |
|
133 | + "id" => $internalKey |
|
134 | + )); |
|
135 | + |
|
136 | + // Set the item name for logger |
|
137 | + $_SESSION['itemname'] = $newusername; |
|
138 | + |
|
139 | + /*******************************************************************************/ |
|
140 | + // put the user in the user_groups he/ she should be in |
|
141 | + // first, check that up_perms are switched on! |
|
142 | + if($use_udperms == 1) { |
|
143 | + if(!empty($user_groups)) { |
|
144 | + for($i = 0; $i < count($user_groups); $i++) { |
|
145 | + $f = array(); |
|
146 | + $f['user_group'] = (int)$user_groups[$i]; |
|
147 | + $f['member'] = $internalKey; |
|
148 | + $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + // end of user_groups stuff! |
|
153 | + |
|
154 | + if($passwordnotifymethod == 'e') { |
|
155 | 155 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
156 | - if($input['stay'] != '') { |
|
157 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | - header($header); |
|
160 | - } else { |
|
161 | - $header = "Location: index.php?a=75&r=2"; |
|
162 | - header($header); |
|
163 | - } |
|
164 | - } else { |
|
165 | - if($input['stay'] != '') { |
|
166 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | - } else { |
|
169 | - $stayUrl = "index.php?a=75&r=2"; |
|
170 | - } |
|
171 | - |
|
172 | - include_once "header.inc.php"; |
|
173 | - ?> |
|
156 | + if($input['stay'] != '') { |
|
157 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | + header($header); |
|
160 | + } else { |
|
161 | + $header = "Location: index.php?a=75&r=2"; |
|
162 | + header($header); |
|
163 | + } |
|
164 | + } else { |
|
165 | + if($input['stay'] != '') { |
|
166 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | + } else { |
|
169 | + $stayUrl = "index.php?a=75&r=2"; |
|
170 | + } |
|
171 | + |
|
172 | + include_once "header.inc.php"; |
|
173 | + ?> |
|
174 | 174 | |
175 | 175 | <h1><?php echo $_lang['user_title']; ?></h1> |
176 | 176 | |
@@ -192,125 +192,125 @@ discard block |
||
192 | 192 | </div> |
193 | 193 | <?php |
194 | 194 | |
195 | - include_once "footer.inc.php"; |
|
196 | - } |
|
197 | - break; |
|
198 | - case '12' : // edit user |
|
199 | - // generate a new password for this user |
|
200 | - if($genpassword == 1) { |
|
201 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | - if(strlen($specifiedpassword) < 6) { |
|
203 | - webAlertAndQuit("Password is too short!", 12); |
|
204 | - } else { |
|
205 | - $newpassword = $specifiedpassword; |
|
206 | - } |
|
207 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | - } elseif($passwordgenmethod == 'g') { |
|
210 | - $newpassword = generate_password(8); |
|
211 | - } else { |
|
212 | - webAlertAndQuit("No password generation method specified!", 12); |
|
213 | - } |
|
214 | - } |
|
215 | - if($passwordnotifymethod == 'e') { |
|
195 | + include_once "footer.inc.php"; |
|
196 | + } |
|
197 | + break; |
|
198 | + case '12' : // edit user |
|
199 | + // generate a new password for this user |
|
200 | + if($genpassword == 1) { |
|
201 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | + if(strlen($specifiedpassword) < 6) { |
|
203 | + webAlertAndQuit("Password is too short!", 12); |
|
204 | + } else { |
|
205 | + $newpassword = $specifiedpassword; |
|
206 | + } |
|
207 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | + } elseif($passwordgenmethod == 'g') { |
|
210 | + $newpassword = generate_password(8); |
|
211 | + } else { |
|
212 | + webAlertAndQuit("No password generation method specified!", 12); |
|
213 | + } |
|
214 | + } |
|
215 | + if($passwordnotifymethod == 'e') { |
|
216 | 216 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
217 | - } |
|
218 | - |
|
219 | - // check if the username already exist |
|
220 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | - $limit = $modx->getDatabase()->getValue($rs); |
|
222 | - if($limit > 0) { |
|
223 | - webAlertAndQuit("User name is already in use!", 12); |
|
224 | - } |
|
225 | - |
|
226 | - // check if the email address already exists |
|
227 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | - $limit = $modx->getDatabase()->getValue($rs); |
|
229 | - if($limit > 0) { |
|
230 | - webAlertAndQuit("Email is already in use!", 12); |
|
231 | - } |
|
232 | - |
|
233 | - // invoke OnBeforeUserFormSave event |
|
234 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | - "mode" => "upd", |
|
236 | - "id" => $id |
|
237 | - )); |
|
238 | - |
|
239 | - // update user name and password |
|
240 | - $field = array(); |
|
241 | - $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | - if($genpassword == 1) { |
|
243 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | - } |
|
245 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | - $field = $modx->getDatabase()->escape($field); |
|
248 | - $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | - |
|
250 | - // Save user settings |
|
217 | + } |
|
218 | + |
|
219 | + // check if the username already exist |
|
220 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | + $limit = $modx->getDatabase()->getValue($rs); |
|
222 | + if($limit > 0) { |
|
223 | + webAlertAndQuit("User name is already in use!", 12); |
|
224 | + } |
|
225 | + |
|
226 | + // check if the email address already exists |
|
227 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | + $limit = $modx->getDatabase()->getValue($rs); |
|
229 | + if($limit > 0) { |
|
230 | + webAlertAndQuit("Email is already in use!", 12); |
|
231 | + } |
|
232 | + |
|
233 | + // invoke OnBeforeUserFormSave event |
|
234 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | + "mode" => "upd", |
|
236 | + "id" => $id |
|
237 | + )); |
|
238 | + |
|
239 | + // update user name and password |
|
240 | + $field = array(); |
|
241 | + $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | + if($genpassword == 1) { |
|
243 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | + } |
|
245 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | + $field = $modx->getDatabase()->escape($field); |
|
248 | + $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | + |
|
250 | + // Save user settings |
|
251 | 251 | saveManagerUserSettings($id); |
252 | 252 | |
253 | - // Set the item name for logger |
|
254 | - $_SESSION['itemname'] = $newusername; |
|
255 | - |
|
256 | - // invoke OnManagerSaveUser event |
|
257 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | - "mode" => "upd", |
|
259 | - "userid" => $id, |
|
260 | - "username" => $newusername, |
|
261 | - "userpassword" => $newpassword, |
|
262 | - "useremail" => $email, |
|
263 | - "userfullname" => $fullname, |
|
264 | - "userroleid" => $role, |
|
265 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | - )); |
|
268 | - |
|
269 | - // invoke OnManagerChangePassword event |
|
270 | - if($genpassword == 1) { |
|
271 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | - "userid" => $id, |
|
273 | - "username" => $newusername, |
|
274 | - "userpassword" => $newpassword |
|
275 | - )); |
|
276 | - } |
|
277 | - |
|
278 | - // invoke OnUserFormSave event |
|
279 | - $modx->invokeEvent("OnUserFormSave", array( |
|
280 | - "mode" => "upd", |
|
281 | - "id" => $id |
|
282 | - )); |
|
283 | - |
|
284 | - /*******************************************************************************/ |
|
285 | - // put the user in the user_groups he/ she should be in |
|
286 | - // first, check that up_perms are switched on! |
|
287 | - if($use_udperms == 1) { |
|
288 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | - $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | - if(!empty($user_groups)) { |
|
291 | - for($i = 0; $i < count($user_groups); $i++) { |
|
292 | - $field = array(); |
|
293 | - $field['user_group'] = (int)$user_groups[$i]; |
|
294 | - $field['member'] = $id; |
|
295 | - $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | - } |
|
297 | - } |
|
298 | - } |
|
299 | - // end of user_groups stuff! |
|
300 | - /*******************************************************************************/ |
|
301 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | - } |
|
304 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | - if($input['stay'] != '') { |
|
306 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | - } else { |
|
309 | - $stayUrl = "index.php?a=75&r=2"; |
|
310 | - } |
|
311 | - |
|
312 | - include_once "header.inc.php"; |
|
313 | - ?> |
|
253 | + // Set the item name for logger |
|
254 | + $_SESSION['itemname'] = $newusername; |
|
255 | + |
|
256 | + // invoke OnManagerSaveUser event |
|
257 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | + "mode" => "upd", |
|
259 | + "userid" => $id, |
|
260 | + "username" => $newusername, |
|
261 | + "userpassword" => $newpassword, |
|
262 | + "useremail" => $email, |
|
263 | + "userfullname" => $fullname, |
|
264 | + "userroleid" => $role, |
|
265 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | + )); |
|
268 | + |
|
269 | + // invoke OnManagerChangePassword event |
|
270 | + if($genpassword == 1) { |
|
271 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | + "userid" => $id, |
|
273 | + "username" => $newusername, |
|
274 | + "userpassword" => $newpassword |
|
275 | + )); |
|
276 | + } |
|
277 | + |
|
278 | + // invoke OnUserFormSave event |
|
279 | + $modx->invokeEvent("OnUserFormSave", array( |
|
280 | + "mode" => "upd", |
|
281 | + "id" => $id |
|
282 | + )); |
|
283 | + |
|
284 | + /*******************************************************************************/ |
|
285 | + // put the user in the user_groups he/ she should be in |
|
286 | + // first, check that up_perms are switched on! |
|
287 | + if($use_udperms == 1) { |
|
288 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | + $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | + if(!empty($user_groups)) { |
|
291 | + for($i = 0; $i < count($user_groups); $i++) { |
|
292 | + $field = array(); |
|
293 | + $field['user_group'] = (int)$user_groups[$i]; |
|
294 | + $field['member'] = $id; |
|
295 | + $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | + } |
|
297 | + } |
|
298 | + } |
|
299 | + // end of user_groups stuff! |
|
300 | + /*******************************************************************************/ |
|
301 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | + } |
|
304 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | + if($input['stay'] != '') { |
|
306 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | + } else { |
|
309 | + $stayUrl = "index.php?a=75&r=2"; |
|
310 | + } |
|
311 | + |
|
312 | + include_once "header.inc.php"; |
|
313 | + ?> |
|
314 | 314 | |
315 | 315 | <h1><?php echo $_lang['user_title']; ?></h1> |
316 | 316 | |
@@ -330,18 +330,18 @@ discard block |
||
330 | 330 | </div> |
331 | 331 | <?php |
332 | 332 | |
333 | - include_once "footer.inc.php"; |
|
334 | - } else { |
|
335 | - if($input['stay'] != '') { |
|
336 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | - header($header); |
|
339 | - } else { |
|
340 | - $header = "Location: index.php?a=75&r=2"; |
|
341 | - header($header); |
|
342 | - } |
|
343 | - } |
|
344 | - break; |
|
345 | - default: |
|
346 | - webAlertAndQuit("No operation set in request.", 12); |
|
333 | + include_once "footer.inc.php"; |
|
334 | + } else { |
|
335 | + if($input['stay'] != '') { |
|
336 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | + header($header); |
|
339 | + } else { |
|
340 | + $header = "Location: index.php?a=75&r=2"; |
|
341 | + header($header); |
|
342 | + } |
|
343 | + } |
|
344 | + break; |
|
345 | + default: |
|
346 | + webAlertAndQuit("No operation set in request.", 12); |
|
347 | 347 | } |
@@ -67,110 +67,110 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | switch($input['mode']) { |
70 | - case '11' : // new user |
|
71 | - // check if this user name already exist |
|
72 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | - $limit = $modx->getDatabase()->getValue($rs); |
|
74 | - if($limit > 0) { |
|
75 | - webAlertAndQuit("User name is already in use!", 12); |
|
76 | - } |
|
77 | - |
|
78 | - // check if the email address already exist |
|
79 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | - $limit = $modx->getDatabase()->getValue($rs); |
|
81 | - if($limit > 0) { |
|
82 | - webAlertAndQuit("Email is already in use!", 12); |
|
83 | - } |
|
84 | - |
|
85 | - // generate a new password for this user |
|
86 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | - if(strlen($specifiedpassword) < 6) { |
|
88 | - webAlertAndQuit("Password is too short!", 12); |
|
89 | - } else { |
|
90 | - $newpassword = $specifiedpassword; |
|
91 | - } |
|
92 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | - } elseif($passwordgenmethod == 'g') { |
|
95 | - $newpassword = generate_password(8); |
|
96 | - } else { |
|
97 | - webAlertAndQuit("No password generation method specified!", 12); |
|
98 | - } |
|
99 | - |
|
100 | - // invoke OnBeforeUserFormSave event |
|
101 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | - "mode" => "new", |
|
103 | - )); |
|
104 | - |
|
105 | - // create the user account |
|
106 | - $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | - |
|
108 | - $field = array(); |
|
109 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | - |
|
112 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | - $field = $modx->getDatabase()->escape($field); |
|
114 | - $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | - |
|
116 | - // Save user settings |
|
117 | - saveManagerUserSettings($internalKey); |
|
118 | - |
|
119 | - // invoke OnManagerSaveUser event |
|
120 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | - "mode" => "new", |
|
122 | - "userid" => $internalKey, |
|
123 | - "username" => $newusername, |
|
124 | - "userpassword" => $newpassword, |
|
125 | - "useremail" => $email, |
|
126 | - "userfullname" => $fullname, |
|
127 | - "userroleid" => $role |
|
128 | - )); |
|
129 | - |
|
130 | - // invoke OnUserFormSave event |
|
131 | - $modx->invokeEvent("OnUserFormSave", array( |
|
132 | - "mode" => "new", |
|
133 | - "id" => $internalKey |
|
134 | - )); |
|
135 | - |
|
136 | - // Set the item name for logger |
|
137 | - $_SESSION['itemname'] = $newusername; |
|
138 | - |
|
139 | - /*******************************************************************************/ |
|
140 | - // put the user in the user_groups he/ she should be in |
|
141 | - // first, check that up_perms are switched on! |
|
142 | - if($use_udperms == 1) { |
|
143 | - if(!empty($user_groups)) { |
|
144 | - for($i = 0; $i < count($user_groups); $i++) { |
|
145 | - $f = array(); |
|
146 | - $f['user_group'] = (int)$user_groups[$i]; |
|
147 | - $f['member'] = $internalKey; |
|
148 | - $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - // end of user_groups stuff! |
|
153 | - |
|
154 | - if($passwordnotifymethod == 'e') { |
|
155 | - sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
156 | - if($input['stay'] != '') { |
|
157 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | - header($header); |
|
160 | - } else { |
|
161 | - $header = "Location: index.php?a=75&r=2"; |
|
162 | - header($header); |
|
163 | - } |
|
164 | - } else { |
|
165 | - if($input['stay'] != '') { |
|
166 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | - } else { |
|
169 | - $stayUrl = "index.php?a=75&r=2"; |
|
170 | - } |
|
171 | - |
|
172 | - include_once "header.inc.php"; |
|
173 | - ?> |
|
70 | + case '11' : // new user |
|
71 | + // check if this user name already exist |
|
72 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | + $limit = $modx->getDatabase()->getValue($rs); |
|
74 | + if($limit > 0) { |
|
75 | + webAlertAndQuit("User name is already in use!", 12); |
|
76 | + } |
|
77 | + |
|
78 | + // check if the email address already exist |
|
79 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | + $limit = $modx->getDatabase()->getValue($rs); |
|
81 | + if($limit > 0) { |
|
82 | + webAlertAndQuit("Email is already in use!", 12); |
|
83 | + } |
|
84 | + |
|
85 | + // generate a new password for this user |
|
86 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | + if(strlen($specifiedpassword) < 6) { |
|
88 | + webAlertAndQuit("Password is too short!", 12); |
|
89 | + } else { |
|
90 | + $newpassword = $specifiedpassword; |
|
91 | + } |
|
92 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | + } elseif($passwordgenmethod == 'g') { |
|
95 | + $newpassword = generate_password(8); |
|
96 | + } else { |
|
97 | + webAlertAndQuit("No password generation method specified!", 12); |
|
98 | + } |
|
99 | + |
|
100 | + // invoke OnBeforeUserFormSave event |
|
101 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | + "mode" => "new", |
|
103 | + )); |
|
104 | + |
|
105 | + // create the user account |
|
106 | + $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | + |
|
108 | + $field = array(); |
|
109 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | + |
|
112 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | + $field = $modx->getDatabase()->escape($field); |
|
114 | + $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | + |
|
116 | + // Save user settings |
|
117 | + saveManagerUserSettings($internalKey); |
|
118 | + |
|
119 | + // invoke OnManagerSaveUser event |
|
120 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | + "mode" => "new", |
|
122 | + "userid" => $internalKey, |
|
123 | + "username" => $newusername, |
|
124 | + "userpassword" => $newpassword, |
|
125 | + "useremail" => $email, |
|
126 | + "userfullname" => $fullname, |
|
127 | + "userroleid" => $role |
|
128 | + )); |
|
129 | + |
|
130 | + // invoke OnUserFormSave event |
|
131 | + $modx->invokeEvent("OnUserFormSave", array( |
|
132 | + "mode" => "new", |
|
133 | + "id" => $internalKey |
|
134 | + )); |
|
135 | + |
|
136 | + // Set the item name for logger |
|
137 | + $_SESSION['itemname'] = $newusername; |
|
138 | + |
|
139 | + /*******************************************************************************/ |
|
140 | + // put the user in the user_groups he/ she should be in |
|
141 | + // first, check that up_perms are switched on! |
|
142 | + if($use_udperms == 1) { |
|
143 | + if(!empty($user_groups)) { |
|
144 | + for($i = 0; $i < count($user_groups); $i++) { |
|
145 | + $f = array(); |
|
146 | + $f['user_group'] = (int)$user_groups[$i]; |
|
147 | + $f['member'] = $internalKey; |
|
148 | + $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + // end of user_groups stuff! |
|
153 | + |
|
154 | + if($passwordnotifymethod == 'e') { |
|
155 | + sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
156 | + if($input['stay'] != '') { |
|
157 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | + header($header); |
|
160 | + } else { |
|
161 | + $header = "Location: index.php?a=75&r=2"; |
|
162 | + header($header); |
|
163 | + } |
|
164 | + } else { |
|
165 | + if($input['stay'] != '') { |
|
166 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | + } else { |
|
169 | + $stayUrl = "index.php?a=75&r=2"; |
|
170 | + } |
|
171 | + |
|
172 | + include_once "header.inc.php"; |
|
173 | + ?> |
|
174 | 174 | |
175 | 175 | <h1><?php echo $_lang['user_title']; ?></h1> |
176 | 176 | |
@@ -192,125 +192,125 @@ discard block |
||
192 | 192 | </div> |
193 | 193 | <?php |
194 | 194 | |
195 | - include_once "footer.inc.php"; |
|
196 | - } |
|
197 | - break; |
|
198 | - case '12' : // edit user |
|
199 | - // generate a new password for this user |
|
200 | - if($genpassword == 1) { |
|
201 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | - if(strlen($specifiedpassword) < 6) { |
|
203 | - webAlertAndQuit("Password is too short!", 12); |
|
204 | - } else { |
|
205 | - $newpassword = $specifiedpassword; |
|
206 | - } |
|
207 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | - } elseif($passwordgenmethod == 'g') { |
|
210 | - $newpassword = generate_password(8); |
|
211 | - } else { |
|
212 | - webAlertAndQuit("No password generation method specified!", 12); |
|
213 | - } |
|
214 | - } |
|
215 | - if($passwordnotifymethod == 'e') { |
|
216 | - sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
217 | - } |
|
218 | - |
|
219 | - // check if the username already exist |
|
220 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | - $limit = $modx->getDatabase()->getValue($rs); |
|
222 | - if($limit > 0) { |
|
223 | - webAlertAndQuit("User name is already in use!", 12); |
|
224 | - } |
|
225 | - |
|
226 | - // check if the email address already exists |
|
227 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | - $limit = $modx->getDatabase()->getValue($rs); |
|
229 | - if($limit > 0) { |
|
230 | - webAlertAndQuit("Email is already in use!", 12); |
|
231 | - } |
|
232 | - |
|
233 | - // invoke OnBeforeUserFormSave event |
|
234 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | - "mode" => "upd", |
|
236 | - "id" => $id |
|
237 | - )); |
|
238 | - |
|
239 | - // update user name and password |
|
240 | - $field = array(); |
|
241 | - $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | - if($genpassword == 1) { |
|
243 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | - } |
|
245 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | - $field = $modx->getDatabase()->escape($field); |
|
248 | - $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | - |
|
250 | - // Save user settings |
|
251 | - saveManagerUserSettings($id); |
|
252 | - |
|
253 | - // Set the item name for logger |
|
254 | - $_SESSION['itemname'] = $newusername; |
|
255 | - |
|
256 | - // invoke OnManagerSaveUser event |
|
257 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | - "mode" => "upd", |
|
259 | - "userid" => $id, |
|
260 | - "username" => $newusername, |
|
261 | - "userpassword" => $newpassword, |
|
262 | - "useremail" => $email, |
|
263 | - "userfullname" => $fullname, |
|
264 | - "userroleid" => $role, |
|
265 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | - )); |
|
268 | - |
|
269 | - // invoke OnManagerChangePassword event |
|
270 | - if($genpassword == 1) { |
|
271 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | - "userid" => $id, |
|
273 | - "username" => $newusername, |
|
274 | - "userpassword" => $newpassword |
|
275 | - )); |
|
276 | - } |
|
277 | - |
|
278 | - // invoke OnUserFormSave event |
|
279 | - $modx->invokeEvent("OnUserFormSave", array( |
|
280 | - "mode" => "upd", |
|
281 | - "id" => $id |
|
282 | - )); |
|
283 | - |
|
284 | - /*******************************************************************************/ |
|
285 | - // put the user in the user_groups he/ she should be in |
|
286 | - // first, check that up_perms are switched on! |
|
287 | - if($use_udperms == 1) { |
|
288 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | - $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | - if(!empty($user_groups)) { |
|
291 | - for($i = 0; $i < count($user_groups); $i++) { |
|
292 | - $field = array(); |
|
293 | - $field['user_group'] = (int)$user_groups[$i]; |
|
294 | - $field['member'] = $id; |
|
295 | - $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | - } |
|
297 | - } |
|
298 | - } |
|
299 | - // end of user_groups stuff! |
|
300 | - /*******************************************************************************/ |
|
301 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | - } |
|
304 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | - if($input['stay'] != '') { |
|
306 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | - } else { |
|
309 | - $stayUrl = "index.php?a=75&r=2"; |
|
310 | - } |
|
311 | - |
|
312 | - include_once "header.inc.php"; |
|
313 | - ?> |
|
195 | + include_once "footer.inc.php"; |
|
196 | + } |
|
197 | + break; |
|
198 | + case '12' : // edit user |
|
199 | + // generate a new password for this user |
|
200 | + if($genpassword == 1) { |
|
201 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | + if(strlen($specifiedpassword) < 6) { |
|
203 | + webAlertAndQuit("Password is too short!", 12); |
|
204 | + } else { |
|
205 | + $newpassword = $specifiedpassword; |
|
206 | + } |
|
207 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | + } elseif($passwordgenmethod == 'g') { |
|
210 | + $newpassword = generate_password(8); |
|
211 | + } else { |
|
212 | + webAlertAndQuit("No password generation method specified!", 12); |
|
213 | + } |
|
214 | + } |
|
215 | + if($passwordnotifymethod == 'e') { |
|
216 | + sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
217 | + } |
|
218 | + |
|
219 | + // check if the username already exist |
|
220 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | + $limit = $modx->getDatabase()->getValue($rs); |
|
222 | + if($limit > 0) { |
|
223 | + webAlertAndQuit("User name is already in use!", 12); |
|
224 | + } |
|
225 | + |
|
226 | + // check if the email address already exists |
|
227 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | + $limit = $modx->getDatabase()->getValue($rs); |
|
229 | + if($limit > 0) { |
|
230 | + webAlertAndQuit("Email is already in use!", 12); |
|
231 | + } |
|
232 | + |
|
233 | + // invoke OnBeforeUserFormSave event |
|
234 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | + "mode" => "upd", |
|
236 | + "id" => $id |
|
237 | + )); |
|
238 | + |
|
239 | + // update user name and password |
|
240 | + $field = array(); |
|
241 | + $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | + if($genpassword == 1) { |
|
243 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | + } |
|
245 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | + $field = $modx->getDatabase()->escape($field); |
|
248 | + $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | + |
|
250 | + // Save user settings |
|
251 | + saveManagerUserSettings($id); |
|
252 | + |
|
253 | + // Set the item name for logger |
|
254 | + $_SESSION['itemname'] = $newusername; |
|
255 | + |
|
256 | + // invoke OnManagerSaveUser event |
|
257 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | + "mode" => "upd", |
|
259 | + "userid" => $id, |
|
260 | + "username" => $newusername, |
|
261 | + "userpassword" => $newpassword, |
|
262 | + "useremail" => $email, |
|
263 | + "userfullname" => $fullname, |
|
264 | + "userroleid" => $role, |
|
265 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | + )); |
|
268 | + |
|
269 | + // invoke OnManagerChangePassword event |
|
270 | + if($genpassword == 1) { |
|
271 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | + "userid" => $id, |
|
273 | + "username" => $newusername, |
|
274 | + "userpassword" => $newpassword |
|
275 | + )); |
|
276 | + } |
|
277 | + |
|
278 | + // invoke OnUserFormSave event |
|
279 | + $modx->invokeEvent("OnUserFormSave", array( |
|
280 | + "mode" => "upd", |
|
281 | + "id" => $id |
|
282 | + )); |
|
283 | + |
|
284 | + /*******************************************************************************/ |
|
285 | + // put the user in the user_groups he/ she should be in |
|
286 | + // first, check that up_perms are switched on! |
|
287 | + if($use_udperms == 1) { |
|
288 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | + $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | + if(!empty($user_groups)) { |
|
291 | + for($i = 0; $i < count($user_groups); $i++) { |
|
292 | + $field = array(); |
|
293 | + $field['user_group'] = (int)$user_groups[$i]; |
|
294 | + $field['member'] = $id; |
|
295 | + $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | + } |
|
297 | + } |
|
298 | + } |
|
299 | + // end of user_groups stuff! |
|
300 | + /*******************************************************************************/ |
|
301 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | + } |
|
304 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | + if($input['stay'] != '') { |
|
306 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | + } else { |
|
309 | + $stayUrl = "index.php?a=75&r=2"; |
|
310 | + } |
|
311 | + |
|
312 | + include_once "header.inc.php"; |
|
313 | + ?> |
|
314 | 314 | |
315 | 315 | <h1><?php echo $_lang['user_title']; ?></h1> |
316 | 316 | |
@@ -330,18 +330,18 @@ discard block |
||
330 | 330 | </div> |
331 | 331 | <?php |
332 | 332 | |
333 | - include_once "footer.inc.php"; |
|
334 | - } else { |
|
335 | - if($input['stay'] != '') { |
|
336 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | - header($header); |
|
339 | - } else { |
|
340 | - $header = "Location: index.php?a=75&r=2"; |
|
341 | - header($header); |
|
342 | - } |
|
343 | - } |
|
344 | - break; |
|
345 | - default: |
|
346 | - webAlertAndQuit("No operation set in request.", 12); |
|
333 | + include_once "footer.inc.php"; |
|
334 | + } else { |
|
335 | + if($input['stay'] != '') { |
|
336 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | + header($header); |
|
339 | + } else { |
|
340 | + $header = "Location: index.php?a=75&r=2"; |
|
341 | + header($header); |
|
342 | + } |
|
343 | + } |
|
344 | + break; |
|
345 | + default: |
|
346 | + webAlertAndQuit("No operation set in request.", 12); |
|
347 | 347 | } |
@@ -1,8 +1,8 @@ discard block |
||
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_user')) { |
|
5 | +if (!$modx->hasPermission('save_user')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | 14 | |
15 | -$id = (int)$input['id']; |
|
15 | +$id = (int) $input['id']; |
|
16 | 16 | $oldusername = $input['oldusername']; |
17 | 17 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
18 | 18 | $fullname = $input['fullname']; |
@@ -42,56 +42,56 @@ discard block |
||
42 | 42 | $user_groups = $input['user_groups']; |
43 | 43 | |
44 | 44 | // verify password |
45 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
45 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
46 | 46 | webAlertAndQuit("Password typed is mismatched", 12); |
47 | 47 | } |
48 | 48 | |
49 | 49 | // verify email |
50 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
50 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
51 | 51 | webAlertAndQuit("E-mail address doesn't seem to be valid!", 12); |
52 | 52 | } |
53 | 53 | |
54 | 54 | // verify admin security |
55 | -if($_SESSION['mgrRole'] != 1) { |
|
55 | +if ($_SESSION['mgrRole'] != 1) { |
|
56 | 56 | // Check to see if user tried to spoof a "1" (admin) role |
57 | - if(!$modx->hasPermission('save_user')) { |
|
57 | + if (!$modx->hasPermission('save_user')) { |
|
58 | 58 | webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12); |
59 | 59 | } |
60 | 60 | // Verify that the user being edited wasn't an admin and the user ID got spoofed |
61 | 61 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
62 | 62 | $limit = $modx->getDatabase()->getValue($rs); |
63 | - if($limit > 0) { |
|
63 | + if ($limit > 0) { |
|
64 | 64 | webAlertAndQuit("You cannot alter an administrative user.", 12); |
65 | 65 | } |
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | -switch($input['mode']) { |
|
69 | +switch ($input['mode']) { |
|
70 | 70 | case '11' : // new user |
71 | 71 | // check if this user name already exist |
72 | 72 | $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
73 | 73 | $limit = $modx->getDatabase()->getValue($rs); |
74 | - if($limit > 0) { |
|
74 | + if ($limit > 0) { |
|
75 | 75 | webAlertAndQuit("User name is already in use!", 12); |
76 | 76 | } |
77 | 77 | |
78 | 78 | // check if the email address already exist |
79 | 79 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
80 | 80 | $limit = $modx->getDatabase()->getValue($rs); |
81 | - if($limit > 0) { |
|
81 | + if ($limit > 0) { |
|
82 | 82 | webAlertAndQuit("Email is already in use!", 12); |
83 | 83 | } |
84 | 84 | |
85 | 85 | // generate a new password for this user |
86 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | - if(strlen($specifiedpassword) < 6) { |
|
86 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | + if (strlen($specifiedpassword) < 6) { |
|
88 | 88 | webAlertAndQuit("Password is too short!", 12); |
89 | 89 | } else { |
90 | 90 | $newpassword = $specifiedpassword; |
91 | 91 | } |
92 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
92 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | 93 | webAlertAndQuit("You didn't specify a password for this user!", 12); |
94 | - } elseif($passwordgenmethod == 'g') { |
|
94 | + } elseif ($passwordgenmethod == 'g') { |
|
95 | 95 | $newpassword = generate_password(8); |
96 | 96 | } else { |
97 | 97 | webAlertAndQuit("No password generation method specified!", 12); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | /*******************************************************************************/ |
140 | 140 | // put the user in the user_groups he/ she should be in |
141 | 141 | // first, check that up_perms are switched on! |
142 | - if($use_udperms == 1) { |
|
143 | - if(!empty($user_groups)) { |
|
144 | - for($i = 0; $i < count($user_groups); $i++) { |
|
142 | + if ($use_udperms == 1) { |
|
143 | + if (!empty($user_groups)) { |
|
144 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
145 | 145 | $f = array(); |
146 | - $f['user_group'] = (int)$user_groups[$i]; |
|
146 | + $f['user_group'] = (int) $user_groups[$i]; |
|
147 | 147 | $f['member'] = $internalKey; |
148 | 148 | $modx->getDatabase()->insert($f, $tbl_member_groups); |
149 | 149 | } |
@@ -151,20 +151,20 @@ discard block |
||
151 | 151 | } |
152 | 152 | // end of user_groups stuff! |
153 | 153 | |
154 | - if($passwordnotifymethod == 'e') { |
|
154 | + if ($passwordnotifymethod == 'e') { |
|
155 | 155 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
156 | - if($input['stay'] != '') { |
|
156 | + if ($input['stay'] != '') { |
|
157 | 157 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
158 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
158 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
159 | 159 | header($header); |
160 | 160 | } else { |
161 | 161 | $header = "Location: index.php?a=75&r=2"; |
162 | 162 | header($header); |
163 | 163 | } |
164 | 164 | } else { |
165 | - if($input['stay'] != '') { |
|
165 | + if ($input['stay'] != '') { |
|
166 | 166 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
167 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
167 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
168 | 168 | } else { |
169 | 169 | $stayUrl = "index.php?a=75&r=2"; |
170 | 170 | } |
@@ -197,36 +197,36 @@ discard block |
||
197 | 197 | break; |
198 | 198 | case '12' : // edit user |
199 | 199 | // generate a new password for this user |
200 | - if($genpassword == 1) { |
|
201 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | - if(strlen($specifiedpassword) < 6) { |
|
200 | + if ($genpassword == 1) { |
|
201 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | + if (strlen($specifiedpassword) < 6) { |
|
203 | 203 | webAlertAndQuit("Password is too short!", 12); |
204 | 204 | } else { |
205 | 205 | $newpassword = $specifiedpassword; |
206 | 206 | } |
207 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
207 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | 208 | webAlertAndQuit("You didn't specify a password for this user!", 12); |
209 | - } elseif($passwordgenmethod == 'g') { |
|
209 | + } elseif ($passwordgenmethod == 'g') { |
|
210 | 210 | $newpassword = generate_password(8); |
211 | 211 | } else { |
212 | 212 | webAlertAndQuit("No password generation method specified!", 12); |
213 | 213 | } |
214 | 214 | } |
215 | - if($passwordnotifymethod == 'e') { |
|
215 | + if ($passwordnotifymethod == 'e') { |
|
216 | 216 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
217 | 217 | } |
218 | 218 | |
219 | 219 | // check if the username already exist |
220 | 220 | $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
221 | 221 | $limit = $modx->getDatabase()->getValue($rs); |
222 | - if($limit > 0) { |
|
222 | + if ($limit > 0) { |
|
223 | 223 | webAlertAndQuit("User name is already in use!", 12); |
224 | 224 | } |
225 | 225 | |
226 | 226 | // check if the email address already exists |
227 | 227 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
228 | 228 | $limit = $modx->getDatabase()->getValue($rs); |
229 | - if($limit > 0) { |
|
229 | + if ($limit > 0) { |
|
230 | 230 | webAlertAndQuit("Email is already in use!", 12); |
231 | 231 | } |
232 | 232 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // update user name and password |
240 | 240 | $field = array(); |
241 | 241 | $field['username'] = $modx->getDatabase()->escape($newusername); |
242 | - if($genpassword == 1) { |
|
242 | + if ($genpassword == 1) { |
|
243 | 243 | $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
244 | 244 | } |
245 | 245 | $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | )); |
268 | 268 | |
269 | 269 | // invoke OnManagerChangePassword event |
270 | - if($genpassword == 1) { |
|
270 | + if ($genpassword == 1) { |
|
271 | 271 | $modx->invokeEvent("OnManagerChangePassword", array( |
272 | 272 | "userid" => $id, |
273 | 273 | "username" => $newusername, |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | /*******************************************************************************/ |
285 | 285 | // put the user in the user_groups he/ she should be in |
286 | 286 | // first, check that up_perms are switched on! |
287 | - if($use_udperms == 1) { |
|
287 | + if ($use_udperms == 1) { |
|
288 | 288 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
289 | 289 | $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
290 | - if(!empty($user_groups)) { |
|
291 | - for($i = 0; $i < count($user_groups); $i++) { |
|
290 | + if (!empty($user_groups)) { |
|
291 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
292 | 292 | $field = array(); |
293 | - $field['user_group'] = (int)$user_groups[$i]; |
|
293 | + $field['user_group'] = (int) $user_groups[$i]; |
|
294 | 294 | $field['member'] = $id; |
295 | 295 | $modx->getDatabase()->insert($field, $tbl_member_groups); |
296 | 296 | } |
@@ -298,13 +298,13 @@ discard block |
||
298 | 298 | } |
299 | 299 | // end of user_groups stuff! |
300 | 300 | /*******************************************************************************/ |
301 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
301 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | 302 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
303 | 303 | } |
304 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | - if($input['stay'] != '') { |
|
304 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | + if ($input['stay'] != '') { |
|
306 | 306 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
307 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
307 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
308 | 308 | } else { |
309 | 309 | $stayUrl = "index.php?a=75&r=2"; |
310 | 310 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
325 | 325 | <div class="sectionBody"> |
326 | 326 | <div id="disp"> |
327 | - <p><?php echo sprintf($_lang["password_msg"], $modx->getPhpCompat()->htmlspecialchars($newusername), $modx->getPhpCompat()->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
327 | + <p><?php echo sprintf($_lang["password_msg"], $modx->getPhpCompat()->htmlspecialchars($newusername), $modx->getPhpCompat()->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
328 | 328 | </div> |
329 | 329 | </div> |
330 | 330 | </div> |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | |
333 | 333 | include_once "footer.inc.php"; |
334 | 334 | } else { |
335 | - if($input['stay'] != '') { |
|
335 | + if ($input['stay'] != '') { |
|
336 | 336 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
337 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
337 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
338 | 338 | header($header); |
339 | 339 | } else { |
340 | 340 | $header = "Location: index.php?a=75&r=2"; |
@@ -3,7 +3,7 @@ discard block |
||
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('export_static')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $maxtime = (is_numeric($_POST['maxtime'])) ? $_POST['maxtime'] : 30; |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | $modx->getExportSite()->targetDir = $export_dir; |
16 | 16 | |
17 | 17 | if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) |
18 | - return $_lang['export_site.static.php6']; |
|
18 | + return $_lang['export_site.static.php6']; |
|
19 | 19 | elseif($modx->config['rb_base_dir'] === $export_dir . '/') |
20 | - return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
|
20 | + return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
|
21 | 21 | elseif(!is_writable($export_dir)) |
22 | - return $_lang['export_site_target_unwritable']; |
|
22 | + return $_lang['export_site_target_unwritable']; |
|
23 | 23 | |
24 | 24 | $modx->getExportSite()->generate_mode = $_POST['generate_mode']; |
25 | 25 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ||$includenoncache!==$_POST['includenoncache'] |
36 | 36 | ||$repl_before!==$_POST['repl_before'] |
37 | 37 | ||$repl_after !==$_POST['repl_after']) { |
38 | - $modx->clearCache('full'); |
|
38 | + $modx->clearCache('full'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $total = $modx->getExportSite()->getTotal($_POST['ignore_ids'], $modx->config['export_includenoncache']); |
@@ -1,8 +1,8 @@ discard block |
||
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('export_static')) { |
|
5 | +if (!$modx->hasPermission('export_static')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -10,15 +10,15 @@ discard block |
||
10 | 10 | @set_time_limit($maxtime); |
11 | 11 | |
12 | 12 | |
13 | -if(is_dir(MODX_BASE_PATH . 'temp')) $export_dir = MODX_BASE_PATH . 'temp/export'; |
|
14 | -elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export'; |
|
13 | +if (is_dir(MODX_BASE_PATH.'temp')) $export_dir = MODX_BASE_PATH.'temp/export'; |
|
14 | +elseif (is_dir(MODX_BASE_PATH.'assets')) $export_dir = MODX_BASE_PATH.'assets/export'; |
|
15 | 15 | $modx->getExportSite()->targetDir = $export_dir; |
16 | 16 | |
17 | -if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) |
|
17 | +if (strpos($modx->config['base_path'], "{$export_dir}/") === 0 && 0 <= strlen(str_replace("{$export_dir}/", '', $modx->config['base_path']))) |
|
18 | 18 | return $_lang['export_site.static.php6']; |
19 | -elseif($modx->config['rb_base_dir'] === $export_dir . '/') |
|
20 | - return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
|
21 | -elseif(!is_writable($export_dir)) |
|
19 | +elseif ($modx->config['rb_base_dir'] === $export_dir.'/') |
|
20 | + return $modx->parsePlaceholder($_lang['export_site.static.php7'], 'rb_base_url='.$modx->config['base_url'].$modx->config['rb_base_url']); |
|
21 | +elseif (!is_writable($export_dir)) |
|
22 | 22 | return $_lang['export_site_target_unwritable']; |
23 | 23 | |
24 | 24 | $modx->getExportSite()->generate_mode = $_POST['generate_mode']; |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $repl_after = $_POST['repl_after']; |
32 | 32 | $includenoncache = $_POST['includenoncache']; |
33 | 33 | |
34 | -if($ignore_ids!==$_POST['ignore_ids'] |
|
35 | - ||$includenoncache!==$_POST['includenoncache'] |
|
36 | - ||$repl_before!==$_POST['repl_before'] |
|
37 | - ||$repl_after !==$_POST['repl_after']) { |
|
34 | +if ($ignore_ids !== $_POST['ignore_ids'] |
|
35 | + ||$includenoncache !== $_POST['includenoncache'] |
|
36 | + ||$repl_before !== $_POST['repl_before'] |
|
37 | + ||$repl_after !== $_POST['repl_after']) { |
|
38 | 38 | $modx->clearCache('full'); |
39 | 39 | } |
40 | 40 | |
@@ -50,5 +50,5 @@ discard block |
||
50 | 50 | |
51 | 51 | $exportend = $modx->getExportSite()->get_mtime(); |
52 | 52 | $totaltime = ($exportend - $modx->getExportSite()->exportstart); |
53 | -$output .= sprintf ('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3)); |
|
53 | +$output .= sprintf('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3)); |
|
54 | 54 | return $output; |
@@ -10,16 +10,20 @@ |
||
10 | 10 | @set_time_limit($maxtime); |
11 | 11 | |
12 | 12 | |
13 | -if(is_dir(MODX_BASE_PATH . 'temp')) $export_dir = MODX_BASE_PATH . 'temp/export'; |
|
14 | -elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export'; |
|
13 | +if(is_dir(MODX_BASE_PATH . 'temp')) { |
|
14 | + $export_dir = MODX_BASE_PATH . 'temp/export'; |
|
15 | +} elseif(is_dir(MODX_BASE_PATH . 'assets')) { |
|
16 | + $export_dir = MODX_BASE_PATH . 'assets/export'; |
|
17 | +} |
|
15 | 18 | $modx->getExportSite()->targetDir = $export_dir; |
16 | 19 | |
17 | -if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) |
|
20 | +if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) { |
|
18 | 21 | return $_lang['export_site.static.php6']; |
19 | -elseif($modx->config['rb_base_dir'] === $export_dir . '/') |
|
22 | +} elseif($modx->config['rb_base_dir'] === $export_dir . '/') { |
|
20 | 23 | return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
21 | -elseif(!is_writable($export_dir)) |
|
24 | +} elseif(!is_writable($export_dir)) { |
|
22 | 25 | return $_lang['export_site_target_unwritable']; |
26 | +} |
|
23 | 27 | |
24 | 28 | $modx->getExportSite()->generate_mode = $_POST['generate_mode']; |
25 | 29 |
@@ -1,26 +1,26 @@ discard block |
||
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('delete_template')) { |
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 | $forced = isset($_GET['force']) ? $_GET['force'] : 0; |
15 | 15 | |
16 | 16 | // check for relations |
17 | 17 | if(!$forced) { |
18 | - $drs = $modx->getDatabase()->select('sc.id, sc.pagetitle,sc.description', $modx->getFullTableName('site_content') . " AS sc |
|
18 | + $drs = $modx->getDatabase()->select('sc.id, sc.pagetitle,sc.description', $modx->getFullTableName('site_content') . " AS sc |
|
19 | 19 | INNER JOIN " . $modx->getFullTableName('site_tmplvar_contentvalues') . " AS stcv ON stcv.contentid=sc.id", "stcv.tmplvarid='{$id}'"); |
20 | - $count = $modx->getDatabase()->getRecordCount($drs); |
|
21 | - if($count > 0) { |
|
22 | - include_once "header.inc.php"; |
|
23 | - ?> |
|
20 | + $count = $modx->getDatabase()->getRecordCount($drs); |
|
21 | + if($count > 0) { |
|
22 | + include_once "header.inc.php"; |
|
23 | + ?> |
|
24 | 24 | <script> |
25 | 25 | var actions = { |
26 | 26 | delete: function() { |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | <p><?= $_lang['tmplvar_inuse'] ?></p> |
43 | 43 | <ul> |
44 | 44 | <?php |
45 | - while($row = $modx->getDatabase()->getRow($drs)) { |
|
46 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['description'] != '' ? ' - ' . $row['description'] : '') . '</li>'; |
|
47 | - } |
|
48 | - ?> |
|
45 | + while($row = $modx->getDatabase()->getRow($drs)) { |
|
46 | + echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['description'] != '' ? ' - ' . $row['description'] : '') . '</li>'; |
|
47 | + } |
|
48 | + ?> |
|
49 | 49 | </ul> |
50 | 50 | </div> |
51 | 51 | </div> |
52 | 52 | <?php |
53 | - include_once "footer.inc.php"; |
|
54 | - exit; |
|
55 | - } |
|
53 | + include_once "footer.inc.php"; |
|
54 | + exit; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Set the item name for logger |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | // invoke OnBeforeTVFormDelete event |
63 | 63 | $modx->invokeEvent("OnBeforeTVFormDelete", array( |
64 | - "id" => $id |
|
64 | + "id" => $id |
|
65 | 65 | )); |
66 | 66 | |
67 | 67 | // delete variable |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | // invoke OnTVFormDelete event |
80 | 80 | $modx->invokeEvent("OnTVFormDelete", array( |
81 | - "id" => $id |
|
81 | + "id" => $id |
|
82 | 82 | )); |
83 | 83 | |
84 | 84 | // empty cache |
@@ -1,24 +1,24 @@ discard block |
||
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_template')) { |
|
5 | +if (!$modx->hasPermission('delete_template')) { |
|
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 | $forced = isset($_GET['force']) ? $_GET['force'] : 0; |
15 | 15 | |
16 | 16 | // check for relations |
17 | -if(!$forced) { |
|
18 | - $drs = $modx->getDatabase()->select('sc.id, sc.pagetitle,sc.description', $modx->getFullTableName('site_content') . " AS sc |
|
19 | - INNER JOIN " . $modx->getFullTableName('site_tmplvar_contentvalues') . " AS stcv ON stcv.contentid=sc.id", "stcv.tmplvarid='{$id}'"); |
|
17 | +if (!$forced) { |
|
18 | + $drs = $modx->getDatabase()->select('sc.id, sc.pagetitle,sc.description', $modx->getFullTableName('site_content')." AS sc |
|
19 | + INNER JOIN " . $modx->getFullTableName('site_tmplvar_contentvalues')." AS stcv ON stcv.contentid=sc.id", "stcv.tmplvarid='{$id}'"); |
|
20 | 20 | $count = $modx->getDatabase()->getRecordCount($drs); |
21 | - if($count > 0) { |
|
21 | + if ($count > 0) { |
|
22 | 22 | include_once "header.inc.php"; |
23 | 23 | ?> |
24 | 24 | <script> |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | <p><?= $_lang['tmplvar_inuse'] ?></p> |
43 | 43 | <ul> |
44 | 44 | <?php |
45 | - while($row = $modx->getDatabase()->getRow($drs)) { |
|
46 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['description'] != '' ? ' - ' . $row['description'] : '') . '</li>'; |
|
45 | + while ($row = $modx->getDatabase()->getRow($drs)) { |
|
46 | + echo '<li><span style="width: 200px"><a href="index.php?id='.$row['id'].'&a=27">'.$row['pagetitle'].'</a></span>'.($row['description'] != '' ? ' - '.$row['description'] : '').'</li>'; |
|
47 | 47 | } |
48 | 48 | ?> |
49 | 49 | </ul> |
@@ -1,13 +1,13 @@ discard block |
||
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('messages')) { |
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 | |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | $modx->webAlertAndQuit("Wrong number of messages returned!"); |
19 | 19 | } |
20 | 20 | |
21 | -if ($message['recipient']!=$modx->getLoginUserID()) { |
|
21 | +if ($message['recipient'] != $modx->getLoginUserID()) { |
|
22 | 22 | $modx->webAlertAndQuit("You are not allowed to delete this message!"); |
23 | 23 | } |
24 | 24 | |
25 | 25 | // delete message |
26 | 26 | $modx->getDatabase()->delete($modx->getFullTableName('user_messages'), "id='{$id}'"); |
27 | 27 | |
28 | -$header="Location: index.php?a=10"; |
|
28 | +$header = "Location: index.php?a=10"; |
|
29 | 29 | header($header); |
@@ -3,12 +3,12 @@ discard block |
||
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_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 | // count duplicates |
14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
@@ -18,40 +18,40 @@ discard block |
||
18 | 18 | |
19 | 19 | // duplicate module |
20 | 20 | $newid = $modx->getDatabase()->insert( |
21 | - array( |
|
22 | - 'name'=>'', |
|
23 | - 'description'=>'', |
|
24 | - 'disabled'=>'', |
|
25 | - 'category'=>'', |
|
26 | - 'wrap'=>'', |
|
27 | - 'icon'=>'', |
|
28 | - 'enable_resource'=>'', |
|
29 | - 'resourcefile'=>'', |
|
30 | - 'createdon'=>'', |
|
31 | - 'editedon'=>'', |
|
32 | - 'guid'=>'', |
|
33 | - 'enable_sharedparams'=>'', |
|
34 | - 'properties'=>'', |
|
35 | - 'modulecode'=>'', |
|
36 | - ), $modx->getFullTableName('site_modules'), // Insert into |
|
37 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
21 | + array( |
|
22 | + 'name'=>'', |
|
23 | + 'description'=>'', |
|
24 | + 'disabled'=>'', |
|
25 | + 'category'=>'', |
|
26 | + 'wrap'=>'', |
|
27 | + 'icon'=>'', |
|
28 | + 'enable_resource'=>'', |
|
29 | + 'resourcefile'=>'', |
|
30 | + 'createdon'=>'', |
|
31 | + 'editedon'=>'', |
|
32 | + 'guid'=>'', |
|
33 | + 'enable_sharedparams'=>'', |
|
34 | + 'properties'=>'', |
|
35 | + 'modulecode'=>'', |
|
36 | + ), $modx->getFullTableName('site_modules'), // Insert into |
|
37 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
38 | 38 | |
39 | 39 | // duplicate module dependencies |
40 | 40 | $modx->getDatabase()->insert( |
41 | - array( |
|
42 | - 'module'=>'', |
|
43 | - 'resource'=>'', |
|
44 | - 'type'=>'', |
|
45 | - ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
46 | - "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
41 | + array( |
|
42 | + 'module'=>'', |
|
43 | + 'resource'=>'', |
|
44 | + 'type'=>'', |
|
45 | + ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
46 | + "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
47 | 47 | |
48 | 48 | // duplicate module user group access |
49 | 49 | $modx->getDatabase()->insert( |
50 | - array( |
|
51 | - 'module'=>'', |
|
52 | - 'usergroup'=>'', |
|
53 | - ), $modx->getFullTableName('site_module_access'), // Insert into |
|
54 | - "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
50 | + array( |
|
51 | + 'module'=>'', |
|
52 | + 'usergroup'=>'', |
|
53 | + ), $modx->getFullTableName('site_module_access'), // Insert into |
|
54 | + "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
55 | 55 | |
56 | 56 | // Set the item name for logger |
57 | 57 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'")); |
@@ -1,19 +1,19 @@ discard block |
||
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_module')) { |
|
5 | +if (!$modx->hasPermission('new_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 | // count duplicates |
14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
15 | 15 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
16 | -if($count>=1) $count = ' '.($count+1); |
|
16 | +if ($count >= 1) $count = ' '.($count + 1); |
|
17 | 17 | else $count = ''; |
18 | 18 | |
19 | 19 | // duplicate module |
@@ -58,5 +58,5 @@ discard block |
||
58 | 58 | $_SESSION['itemname'] = $name; |
59 | 59 | |
60 | 60 | // finish duplicating - redirect to new module |
61 | -$header="Location: index.php?r=2&a=108&id=$newid"; |
|
61 | +$header = "Location: index.php?r=2&a=108&id=$newid"; |
|
62 | 62 | header($header); |
@@ -13,8 +13,11 @@ |
||
13 | 13 | // count duplicates |
14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
15 | 15 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
16 | -if($count>=1) $count = ' '.($count+1); |
|
17 | -else $count = ''; |
|
16 | +if($count>=1) { |
|
17 | + $count = ' '.($count+1); |
|
18 | +} else { |
|
19 | + $count = ''; |
|
20 | +} |
|
18 | 21 | |
19 | 22 | // duplicate module |
20 | 23 | $newid = $modx->getDatabase()->insert( |
@@ -59,123 +59,123 @@ |
||
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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
71 | - $count = $modx->getDatabase()->getValue($rs); |
|
72 | - if ($count > 0) { |
|
73 | - $modx->getManagerApi()->saveFormValues(107); |
|
74 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
75 | - } |
|
76 | - |
|
77 | - // save the new module |
|
78 | - $newid = $modx->getDatabase()->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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
130 | - if ($modx->getDatabase()->getValue($rs) > 0) { |
|
131 | - $modx->getManagerApi()->saveFormValues(108); |
|
132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
133 | - } |
|
134 | - |
|
135 | - // save the edited module |
|
136 | - $modx->getDatabase()->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."); |
|
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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); |
|
71 | + $count = $modx->getDatabase()->getValue($rs); |
|
72 | + if ($count > 0) { |
|
73 | + $modx->getManagerApi()->saveFormValues(107); |
|
74 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); |
|
75 | + } |
|
76 | + |
|
77 | + // save the new module |
|
78 | + $newid = $modx->getDatabase()->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->getDatabase()->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
130 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
131 | + $modx->getManagerApi()->saveFormValues(108); |
|
132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); |
|
133 | + } |
|
134 | + |
|
135 | + // save the edited module |
|
136 | + $modx->getDatabase()->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 | } |
@@ -1,12 +1,12 @@ discard block |
||
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('save_module')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
11 | 11 | $description = $modx->getDatabase()->escape($_POST['description']); |
12 | 12 | $resourcefile = $modx->getDatabase()->escape($_POST['resourcefile']); |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | //Kyle Jaebker - added category support |
27 | 27 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
28 | - $categoryid = (int)$_POST['categoryid']; |
|
28 | + $categoryid = (int) $_POST['categoryid']; |
|
29 | 29 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
30 | 30 | $categoryid = 0; |
31 | 31 | } else { |
32 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
32 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
33 | 33 | $categoryid = checkCategory($_POST['newcategory']); |
34 | 34 | if (!$categoryid) { |
35 | 35 | $categoryid = newCategory($_POST['newcategory']); |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | $name = isset($parsed['name']) ? $parsed['name'] : $name; |
46 | 46 | $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; |
47 | 47 | $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid; |
48 | - $enable_sharedparams = isset($parsed['shareparams']) ? (int)$parsed['shareparams'] : $enable_sharedparams; |
|
48 | + $enable_sharedparams = isset($parsed['shareparams']) ? (int) $parsed['shareparams'] : $enable_sharedparams; |
|
49 | 49 | |
50 | 50 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
51 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
51 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
52 | 52 | if ($version) { |
53 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
53 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
54 | 54 | } |
55 | 55 | if (isset($parsed['modx_category'])) { |
56 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
56 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
57 | 57 | $categoryid = getCategory($parsed['modx_category']); |
58 | 58 | } |
59 | 59 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // finished emptying cache - redirect |
112 | 112 | if ($_POST['stay'] != '') { |
113 | 113 | $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
114 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
115 | 115 | header($header); |
116 | 116 | } else { |
117 | 117 | $header = "Location: index.php?a=106&r=2"; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | // finished emptying cache - redirect |
169 | 169 | if ($_POST['stay'] != '') { |
170 | 170 | $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
171 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
171 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
172 | 172 | header($header); |
173 | 173 | } else { |
174 | 174 | $modx->unlockElement(6, $id); |
@@ -3,12 +3,12 @@ discard block |
||
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_chunk')) { |
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 | // count duplicates |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | |
20 | 20 | // duplicate htmlsnippet |
21 | 21 | $newid = $modx->getDatabase()->insert( |
22 | - array( |
|
23 | - 'name'=>'', |
|
24 | - 'description'=>'', |
|
25 | - 'snippet'=>'', |
|
26 | - 'category'=>'', |
|
27 | - ), $modx->getFullTableName('site_htmlsnippets'), // Insert into |
|
28 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from |
|
22 | + array( |
|
23 | + 'name'=>'', |
|
24 | + 'description'=>'', |
|
25 | + 'snippet'=>'', |
|
26 | + 'category'=>'', |
|
27 | + ), $modx->getFullTableName('site_htmlsnippets'), // Insert into |
|
28 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, category", $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); // Copy from |
|
29 | 29 | |
30 | 30 | // Set the item name for logger |
31 | 31 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$newid}'")); |
@@ -1,20 +1,20 @@ discard block |
||
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_chunk')) { |
|
5 | +if (!$modx->hasPermission('new_chunk')) { |
|
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 | // count duplicates |
15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
17 | -if($count>=1) $count = ' '.($count+1); |
|
17 | +if ($count >= 1) $count = ' '.($count + 1); |
|
18 | 18 | else $count = ''; |
19 | 19 | |
20 | 20 | // duplicate htmlsnippet |
@@ -32,5 +32,5 @@ discard block |
||
32 | 32 | $_SESSION['itemname'] = $name; |
33 | 33 | |
34 | 34 | // finish duplicating - redirect to new chunk |
35 | -$header="Location: index.php?r=2&a=78&id=$newid"; |
|
35 | +$header = "Location: index.php?r=2&a=78&id=$newid"; |
|
36 | 36 | header($header); |
@@ -14,8 +14,11 @@ |
||
14 | 14 | // count duplicates |
15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
17 | -if($count>=1) $count = ' '.($count+1); |
|
18 | -else $count = ''; |
|
17 | +if($count>=1) { |
|
18 | + $count = ' '.($count+1); |
|
19 | +} else { |
|
20 | + $count = ''; |
|
21 | +} |
|
19 | 22 | |
20 | 23 | // duplicate htmlsnippet |
21 | 24 | $newid = $modx->getDatabase()->insert( |