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