@@ -1,135 +1,135 @@ |
||
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_role')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | extract($_POST); |
10 | 10 | |
11 | 11 | if($name == '' || !isset ($name)) { |
12 | - $modx->webAlertAndQuit("Please enter a name for this role!", "index.php?a={$mode}" . ($mode = 35 ? "&id={$id}" : "")); |
|
12 | + $modx->webAlertAndQuit("Please enter a name for this role!", "index.php?a={$mode}" . ($mode = 35 ? "&id={$id}" : "")); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | // setup fields |
16 | 16 | $fields = array( |
17 | - 'name' => $name, |
|
18 | - 'description' => $description, |
|
19 | - 'frames' => $frames, |
|
20 | - 'home' => $home, |
|
21 | - 'view_document' => $view_document, |
|
22 | - 'new_document' => $new_document, |
|
23 | - 'save_document' => $save_document, |
|
24 | - 'publish_document' => $publish_document, |
|
25 | - 'delete_document' => $delete_document, |
|
26 | - 'empty_trash' => $empty_trash, |
|
27 | - 'action_ok' => $action_ok, |
|
28 | - 'logout' => $logout, |
|
29 | - 'help' => $help, |
|
30 | - 'messages' => $messages, |
|
31 | - 'new_user' => $new_user, |
|
32 | - 'edit_user' => $edit_user, |
|
33 | - 'logs' => $logs, |
|
34 | - 'edit_parser' => (isset ($edit_parser)) ? $edit_parser : '0', |
|
35 | - 'save_parser' => (isset ($save_parser)) ? $save_parser : '0', |
|
36 | - 'edit_template' => $edit_template, |
|
37 | - 'settings' => $settings, |
|
38 | - 'credits' => $credits, |
|
39 | - 'new_template' => $new_template, |
|
40 | - 'save_template' => $save_template, |
|
41 | - 'delete_template' => $delete_template, |
|
42 | - 'edit_snippet' => $edit_snippet, |
|
43 | - 'new_snippet' => $new_snippet, |
|
44 | - 'save_snippet' => $save_snippet, |
|
45 | - 'delete_snippet' => $delete_snippet, |
|
46 | - 'edit_chunk' => $edit_chunk, |
|
47 | - 'new_chunk' => $new_chunk, |
|
48 | - 'save_chunk' => $save_chunk, |
|
49 | - 'delete_chunk' => $delete_chunk, |
|
50 | - 'empty_cache' => $empty_cache, |
|
51 | - 'edit_document' => $edit_document, |
|
52 | - 'change_password' => $change_password, |
|
53 | - 'error_dialog' => $error_dialog, |
|
54 | - 'about' => $about, |
|
55 | - 'file_manager' => $file_manager, |
|
56 | - 'assets_files' => $assets_files, |
|
57 | - 'assets_images' => $assets_images, |
|
58 | - 'save_user' => $save_user, |
|
59 | - 'delete_user' => $delete_user, |
|
60 | - 'save_password' => $save_password, |
|
61 | - 'edit_role' => $edit_role, |
|
62 | - 'save_role' => $save_role, |
|
63 | - 'delete_role' => $delete_role, |
|
64 | - 'new_role' => $new_role, |
|
65 | - 'access_permissions' => $access_permissions, |
|
66 | - 'bk_manager' => $bk_manager, |
|
67 | - 'new_plugin' => $new_plugin, |
|
68 | - 'edit_plugin' => $edit_plugin, |
|
69 | - 'save_plugin' => $save_plugin, |
|
70 | - 'delete_plugin' => $delete_plugin, |
|
71 | - 'new_module' => $new_module, |
|
72 | - 'edit_module' => $edit_module, |
|
73 | - 'save_module' => $save_module, |
|
74 | - 'delete_module' => $delete_module, |
|
75 | - 'exec_module' => $exec_module, |
|
76 | - 'view_eventlog' => $view_eventlog, |
|
77 | - 'delete_eventlog' => $delete_eventlog, |
|
78 | - 'new_web_user' => $new_web_user, |
|
79 | - 'edit_web_user' => $edit_web_user, |
|
80 | - 'save_web_user' => $save_web_user, |
|
81 | - 'delete_web_user' => $delete_web_user, |
|
82 | - 'web_access_permissions' => $web_access_permissions, |
|
83 | - 'view_unpublished' => $view_unpublished, |
|
84 | - 'import_static' => $import_static, |
|
85 | - 'export_static' => $export_static, |
|
86 | - 'remove_locks' => $remove_locks, |
|
87 | - 'display_locks' => $display_locks, |
|
88 | - 'change_resourcetype' => $change_resourcetype, |
|
89 | - 'category_manager' => $category_manager |
|
17 | + 'name' => $name, |
|
18 | + 'description' => $description, |
|
19 | + 'frames' => $frames, |
|
20 | + 'home' => $home, |
|
21 | + 'view_document' => $view_document, |
|
22 | + 'new_document' => $new_document, |
|
23 | + 'save_document' => $save_document, |
|
24 | + 'publish_document' => $publish_document, |
|
25 | + 'delete_document' => $delete_document, |
|
26 | + 'empty_trash' => $empty_trash, |
|
27 | + 'action_ok' => $action_ok, |
|
28 | + 'logout' => $logout, |
|
29 | + 'help' => $help, |
|
30 | + 'messages' => $messages, |
|
31 | + 'new_user' => $new_user, |
|
32 | + 'edit_user' => $edit_user, |
|
33 | + 'logs' => $logs, |
|
34 | + 'edit_parser' => (isset ($edit_parser)) ? $edit_parser : '0', |
|
35 | + 'save_parser' => (isset ($save_parser)) ? $save_parser : '0', |
|
36 | + 'edit_template' => $edit_template, |
|
37 | + 'settings' => $settings, |
|
38 | + 'credits' => $credits, |
|
39 | + 'new_template' => $new_template, |
|
40 | + 'save_template' => $save_template, |
|
41 | + 'delete_template' => $delete_template, |
|
42 | + 'edit_snippet' => $edit_snippet, |
|
43 | + 'new_snippet' => $new_snippet, |
|
44 | + 'save_snippet' => $save_snippet, |
|
45 | + 'delete_snippet' => $delete_snippet, |
|
46 | + 'edit_chunk' => $edit_chunk, |
|
47 | + 'new_chunk' => $new_chunk, |
|
48 | + 'save_chunk' => $save_chunk, |
|
49 | + 'delete_chunk' => $delete_chunk, |
|
50 | + 'empty_cache' => $empty_cache, |
|
51 | + 'edit_document' => $edit_document, |
|
52 | + 'change_password' => $change_password, |
|
53 | + 'error_dialog' => $error_dialog, |
|
54 | + 'about' => $about, |
|
55 | + 'file_manager' => $file_manager, |
|
56 | + 'assets_files' => $assets_files, |
|
57 | + 'assets_images' => $assets_images, |
|
58 | + 'save_user' => $save_user, |
|
59 | + 'delete_user' => $delete_user, |
|
60 | + 'save_password' => $save_password, |
|
61 | + 'edit_role' => $edit_role, |
|
62 | + 'save_role' => $save_role, |
|
63 | + 'delete_role' => $delete_role, |
|
64 | + 'new_role' => $new_role, |
|
65 | + 'access_permissions' => $access_permissions, |
|
66 | + 'bk_manager' => $bk_manager, |
|
67 | + 'new_plugin' => $new_plugin, |
|
68 | + 'edit_plugin' => $edit_plugin, |
|
69 | + 'save_plugin' => $save_plugin, |
|
70 | + 'delete_plugin' => $delete_plugin, |
|
71 | + 'new_module' => $new_module, |
|
72 | + 'edit_module' => $edit_module, |
|
73 | + 'save_module' => $save_module, |
|
74 | + 'delete_module' => $delete_module, |
|
75 | + 'exec_module' => $exec_module, |
|
76 | + 'view_eventlog' => $view_eventlog, |
|
77 | + 'delete_eventlog' => $delete_eventlog, |
|
78 | + 'new_web_user' => $new_web_user, |
|
79 | + 'edit_web_user' => $edit_web_user, |
|
80 | + 'save_web_user' => $save_web_user, |
|
81 | + 'delete_web_user' => $delete_web_user, |
|
82 | + 'web_access_permissions' => $web_access_permissions, |
|
83 | + 'view_unpublished' => $view_unpublished, |
|
84 | + 'import_static' => $import_static, |
|
85 | + 'export_static' => $export_static, |
|
86 | + 'remove_locks' => $remove_locks, |
|
87 | + 'display_locks' => $display_locks, |
|
88 | + 'change_resourcetype' => $change_resourcetype, |
|
89 | + 'category_manager' => $category_manager |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | $fields = $modx->db->escape($fields); |
93 | 93 | |
94 | 94 | switch($_POST['mode']) { |
95 | - case '38' : |
|
96 | - $tbl = $modx->getFullTableName("user_roles"); |
|
95 | + case '38' : |
|
96 | + $tbl = $modx->getFullTableName("user_roles"); |
|
97 | 97 | |
98 | - // disallow duplicate names for role |
|
99 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}'"); |
|
100 | - if($modx->db->getValue($rs) > 0) { |
|
101 | - $modx->manager->saveFormValues(38); |
|
102 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=38"); |
|
103 | - } |
|
98 | + // disallow duplicate names for role |
|
99 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}'"); |
|
100 | + if($modx->db->getValue($rs) > 0) { |
|
101 | + $modx->manager->saveFormValues(38); |
|
102 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=38"); |
|
103 | + } |
|
104 | 104 | |
105 | - $modx->db->insert($fields, $tbl); |
|
105 | + $modx->db->insert($fields, $tbl); |
|
106 | 106 | |
107 | - // Set the item name for logger |
|
108 | - $_SESSION['itemname'] = $_POST['name']; |
|
107 | + // Set the item name for logger |
|
108 | + $_SESSION['itemname'] = $_POST['name']; |
|
109 | 109 | |
110 | - $header = "Location: index.php?a=86&r=2"; |
|
111 | - header($header); |
|
112 | - break; |
|
113 | - case '35' : |
|
114 | - $tbl = $modx->getFullTableName("user_roles"); |
|
110 | + $header = "Location: index.php?a=86&r=2"; |
|
111 | + header($header); |
|
112 | + break; |
|
113 | + case '35' : |
|
114 | + $tbl = $modx->getFullTableName("user_roles"); |
|
115 | 115 | |
116 | - // disallow duplicate names for role |
|
117 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}' AND id!='{$id}'"); |
|
118 | - if($modx->db->getValue($rs) > 0) { |
|
119 | - $modx->manager->saveFormValues(35); |
|
120 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=35&id={$id}"); |
|
121 | - } |
|
116 | + // disallow duplicate names for role |
|
117 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('user_roles'), "name='{$fields['name']}' AND id!='{$id}'"); |
|
118 | + if($modx->db->getValue($rs) > 0) { |
|
119 | + $modx->manager->saveFormValues(35); |
|
120 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['role'], $name), "index.php?a=35&id={$id}"); |
|
121 | + } |
|
122 | 122 | |
123 | - $modx->db->update($fields, $tbl, "id='{$id}'"); |
|
123 | + $modx->db->update($fields, $tbl, "id='{$id}'"); |
|
124 | 124 | |
125 | - // Set the item name for logger |
|
126 | - $_SESSION['itemname'] = $_POST['name']; |
|
125 | + // Set the item name for logger |
|
126 | + $_SESSION['itemname'] = $_POST['name']; |
|
127 | 127 | |
128 | - $header = "Location: index.php?a=86&r=2"; |
|
129 | - header($header); |
|
130 | - break; |
|
131 | - default : |
|
132 | - $modx->webAlertAndQuit("No operation set in request."); |
|
128 | + $header = "Location: index.php?a=86&r=2"; |
|
129 | + header($header); |
|
130 | + break; |
|
131 | + default : |
|
132 | + $modx->webAlertAndQuit("No operation set in request."); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $modx->unlockElement(8, $id); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | } |
5 | 5 | |
6 | 6 | if(!$modx->hasPermission('delete_plugin')) { |
7 | - $e->setError(3); |
|
8 | - $e->dumpError(); |
|
7 | + $e->setError(3); |
|
8 | + $e->dumpError(); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | $tbl_site_plugins = $modx->getFullTablename('site_plugins'); |
@@ -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('delete_document')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "deleted=1"); |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | |
12 | 12 | // invoke OnBeforeEmptyTrash event |
13 | 13 | $modx->invokeEvent("OnBeforeEmptyTrash", |
14 | - array( |
|
15 | - "ids"=>$ids |
|
16 | - )); |
|
14 | + array( |
|
15 | + "ids"=>$ids |
|
16 | + )); |
|
17 | 17 | |
18 | 18 | // remove the document groups link. |
19 | 19 | $sql = "DELETE document_groups |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | //'undelete' the document. |
33 | 33 | $modx->db->delete($modx->getFullTableName('site_content'), "deleted=1"); |
34 | 34 | |
35 | - // invoke OnEmptyTrash event |
|
36 | - $modx->invokeEvent("OnEmptyTrash", |
|
37 | - array( |
|
38 | - "ids"=>$ids |
|
39 | - )); |
|
35 | + // invoke OnEmptyTrash event |
|
36 | + $modx->invokeEvent("OnEmptyTrash", |
|
37 | + array( |
|
38 | + "ids"=>$ids |
|
39 | + )); |
|
40 | 40 | |
41 | - // empty cache |
|
42 | - $modx->clearCache('full'); |
|
41 | + // empty cache |
|
42 | + $modx->clearCache('full'); |
|
43 | 43 | |
44 | - // finished emptying cache - redirect |
|
45 | - $header="Location: index.php?a=2&r=1"; |
|
46 | - header($header); |
|
44 | + // finished emptying cache - redirect |
|
45 | + $header="Location: index.php?a=2&r=1"; |
|
46 | + header($header); |
@@ -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('save_password')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = $_POST['id']; |
@@ -11,26 +11,26 @@ discard block |
||
11 | 11 | $pass2 = $_POST['pass2']; |
12 | 12 | |
13 | 13 | if($pass1!=$pass2){ |
14 | - $modx->webAlertAndQuit("Passwords don't match!"); |
|
14 | + $modx->webAlertAndQuit("Passwords don't match!"); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | if(strlen($pass1)<6){ |
18 | - $modx->webAlertAndQuit("Password is too short. Please specify a password of at least 6 characters."); |
|
18 | + $modx->webAlertAndQuit("Password is too short. Please specify a password of at least 6 characters."); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $pass1 = $modx->htmlspecialchars($pass1, ENT_NOQUOTES); |
22 | - $tbl_manager_users = $modx->getFullTableName('manager_users'); |
|
23 | - $uid = $modx->getLoginUserID(); |
|
24 | - $modx->loadExtension('phpass'); |
|
25 | - $f['password'] = $modx->phpass->HashPassword($pass1); |
|
26 | - $modx->db->update($f,$tbl_manager_users,"id='{$uid}'"); |
|
22 | + $tbl_manager_users = $modx->getFullTableName('manager_users'); |
|
23 | + $uid = $modx->getLoginUserID(); |
|
24 | + $modx->loadExtension('phpass'); |
|
25 | + $f['password'] = $modx->phpass->HashPassword($pass1); |
|
26 | + $modx->db->update($f,$tbl_manager_users,"id='{$uid}'"); |
|
27 | 27 | |
28 | - // invoke OnManagerChangePassword event |
|
29 | - $modx->invokeEvent('OnManagerChangePassword', array ( |
|
30 | - 'userid' => $uid, |
|
31 | - 'username' => $_SESSION['mgrShortname'], |
|
32 | - 'userpassword' => $pass1 |
|
33 | - )); |
|
28 | + // invoke OnManagerChangePassword event |
|
29 | + $modx->invokeEvent('OnManagerChangePassword', array ( |
|
30 | + 'userid' => $uid, |
|
31 | + 'username' => $_SESSION['mgrShortname'], |
|
32 | + 'userpassword' => $pass1 |
|
33 | + )); |
|
34 | 34 | |
35 | 35 | $header="Location: index.php?a=2"; |
36 | 36 | header($header); |
@@ -3,7 +3,7 @@ |
||
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('settings')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $modx->db->truncate($modx->getFullTableName('manager_log')); |
@@ -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('messages')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $sendto = $_REQUEST['sendto']; |
@@ -16,55 +16,55 @@ discard block |
||
16 | 16 | $postdate = time(); |
17 | 17 | |
18 | 18 | if($sendto=='u') { |
19 | - if($userid==0) { |
|
20 | - $modx->webAlertAndQuit($_lang["error_no_user_selected"]); |
|
21 | - } |
|
22 | - $modx->db->insert( |
|
23 | - array( |
|
24 | - 'recipient' => $userid, |
|
25 | - 'sender' => $modx->getLoginUserID(), |
|
26 | - 'subject' => $subject, |
|
27 | - 'message' => $message, |
|
28 | - 'postdate' => $postdate, |
|
29 | - 'type' => 'Message', |
|
30 | - 'private' => 1, |
|
31 | - ), $modx->getFullTableName('user_messages')); |
|
19 | + if($userid==0) { |
|
20 | + $modx->webAlertAndQuit($_lang["error_no_user_selected"]); |
|
21 | + } |
|
22 | + $modx->db->insert( |
|
23 | + array( |
|
24 | + 'recipient' => $userid, |
|
25 | + 'sender' => $modx->getLoginUserID(), |
|
26 | + 'subject' => $subject, |
|
27 | + 'message' => $message, |
|
28 | + 'postdate' => $postdate, |
|
29 | + 'type' => 'Message', |
|
30 | + 'private' => 1, |
|
31 | + ), $modx->getFullTableName('user_messages')); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | if($sendto=='g') { |
35 | - if($groupid==0) { |
|
36 | - $modx->webAlertAndQuit($_lang["error_no_group_selected"]); |
|
37 | - } |
|
38 | - $rs = $modx->db->select('internalKey', $modx->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'"); |
|
39 | - while ($row=$modx->db->getRow($rs)) { |
|
40 | - $modx->db->insert( |
|
41 | - array( |
|
42 | - 'recipient' => $row['internalKey'], |
|
43 | - 'sender' => $modx->getLoginUserID(), |
|
44 | - 'subject' => $subject, |
|
45 | - 'message' => $message, |
|
46 | - 'postdate' => $postdate, |
|
47 | - 'type' => 'Message', |
|
48 | - 'private' => 0, |
|
49 | - ), $modx->getFullTableName('user_messages')); |
|
50 | - } |
|
35 | + if($groupid==0) { |
|
36 | + $modx->webAlertAndQuit($_lang["error_no_group_selected"]); |
|
37 | + } |
|
38 | + $rs = $modx->db->select('internalKey', $modx->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'"); |
|
39 | + while ($row=$modx->db->getRow($rs)) { |
|
40 | + $modx->db->insert( |
|
41 | + array( |
|
42 | + 'recipient' => $row['internalKey'], |
|
43 | + 'sender' => $modx->getLoginUserID(), |
|
44 | + 'subject' => $subject, |
|
45 | + 'message' => $message, |
|
46 | + 'postdate' => $postdate, |
|
47 | + 'type' => 'Message', |
|
48 | + 'private' => 0, |
|
49 | + ), $modx->getFullTableName('user_messages')); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | if($sendto=='a') { |
55 | - $rs = $modx->db->select('id', $modx->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'"); |
|
56 | - while ($row=$modx->db->getRow($rs)) { |
|
57 | - $modx->db->insert( |
|
58 | - array( |
|
59 | - 'recipient' => $row['id'], |
|
60 | - 'sender' => $modx->getLoginUserID(), |
|
61 | - 'subject' => $subject, |
|
62 | - 'message' => $message, |
|
63 | - 'postdate' => $postdate, |
|
64 | - 'type' => 'Message', |
|
65 | - 'private' => 0, |
|
66 | - ), $modx->getFullTableName('user_messages')); |
|
67 | - } |
|
55 | + $rs = $modx->db->select('id', $modx->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'"); |
|
56 | + while ($row=$modx->db->getRow($rs)) { |
|
57 | + $modx->db->insert( |
|
58 | + array( |
|
59 | + 'recipient' => $row['id'], |
|
60 | + 'sender' => $modx->getLoginUserID(), |
|
61 | + 'subject' => $subject, |
|
62 | + 'message' => $message, |
|
63 | + 'postdate' => $postdate, |
|
64 | + 'type' => 'Message', |
|
65 | + 'private' => 0, |
|
66 | + ), $modx->getFullTableName('user_messages')); |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $header = "Location: index.php?a=10"; |
@@ -1,12 +1,12 @@ 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 | |
6 | 6 | // invoke OnManagerTreeInit event |
7 | 7 | $evtOut = $modx->invokeEvent('OnManagerTreeInit', $_REQUEST); |
8 | 8 | if(is_array($evtOut)) { |
9 | - echo implode("\n", $evtOut); |
|
9 | + echo implode("\n", $evtOut); |
|
10 | 10 | } |
11 | 11 | ?> |
12 | 12 | |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | <div id="treeHolder"> |
54 | 54 | <?php |
55 | - // invoke OnManagerTreePrerender event |
|
56 | - $evtOut = $modx->invokeEvent('OnManagerTreePrerender', $modx->db->escape($_REQUEST)); |
|
57 | - if(is_array($evtOut)) { |
|
58 | - echo implode("\n", $evtOut); |
|
59 | - } |
|
60 | - ?> |
|
55 | + // invoke OnManagerTreePrerender event |
|
56 | + $evtOut = $modx->invokeEvent('OnManagerTreePrerender', $modx->db->escape($_REQUEST)); |
|
57 | + if(is_array($evtOut)) { |
|
58 | + echo implode("\n", $evtOut); |
|
59 | + } |
|
60 | + ?> |
|
61 | 61 | <div id="node0" class="rootNode"><a class="node" onclick="modx.tree.treeAction(event, 0)" data-id="0" data-title-esc="<?php $site_name = htmlspecialchars($site_name, ENT_QUOTES, $modx->config['modx_charset']); |
62 | - echo $site_name; ?>"><span class="icon"><?php echo $_style['tree_showtree']; ?></span><span class="title"><?php echo $site_name; ?></span></a> |
|
62 | + echo $site_name; ?>"><span class="icon"><?php echo $_style['tree_showtree']; ?></span><span class="title"><?php echo $site_name; ?></span></a> |
|
63 | 63 | <div id="treeloader"><i class="fa fa-cog fa-spin fa-3x fa-fw"></i></div> |
64 | 64 | </div> |
65 | 65 | <div id="treeRoot"></div> |
66 | 66 | <?php |
67 | - // invoke OnManagerTreeRender event |
|
68 | - $evtOut = $modx->invokeEvent('OnManagerTreeRender', $modx->db->escape($_REQUEST)); |
|
69 | - if(is_array($evtOut)) { |
|
70 | - echo implode("\n", $evtOut); |
|
71 | - } |
|
72 | - ?> |
|
67 | + // invoke OnManagerTreeRender event |
|
68 | + $evtOut = $modx->invokeEvent('OnManagerTreeRender', $modx->db->escape($_REQUEST)); |
|
69 | + if(is_array($evtOut)) { |
|
70 | + echo implode("\n", $evtOut); |
|
71 | + } |
|
72 | + ?> |
|
73 | 73 | </div> |
74 | 74 | </div> |
@@ -1,6 +1,6 @@ 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 | |
6 | 6 | /** |
@@ -11,575 +11,575 @@ discard block |
||
11 | 11 | * @param string $hereid |
12 | 12 | */ |
13 | 13 | function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
14 | - global $modx; |
|
15 | - global $icons, $iconsPrivate, $_style; |
|
16 | - global $_lang, $opened, $opened2, $closed2; //added global vars |
|
17 | - global $modx_textdir; |
|
18 | - |
|
19 | - $output = ''; |
|
20 | - |
|
21 | - // setup spacer |
|
22 | - $level = 0; |
|
23 | - $spacer = '<span class="indent">'; |
|
24 | - for($i = 2; $i <= $indent; $i++) { |
|
25 | - $spacer .= '<i></i>'; |
|
26 | - $level++; |
|
27 | - } |
|
28 | - $spacer .= '</span>'; |
|
29 | - |
|
30 | - // manage order-by |
|
31 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
32 | - // This is the first startup, set default sort order |
|
33 | - $_SESSION['tree_sortby'] = 'menuindex'; |
|
34 | - $_SESSION['tree_sortdir'] = 'ASC'; |
|
35 | - } |
|
36 | - |
|
37 | - switch($_SESSION['tree_sortby']) { |
|
38 | - case 'createdon': |
|
39 | - case 'editedon': |
|
40 | - case 'publishedon': |
|
41 | - case 'pub_date': |
|
42 | - case 'unpub_date': |
|
43 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
44 | - break; |
|
45 | - default: |
|
46 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
47 | - }; |
|
48 | - |
|
49 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
50 | - |
|
51 | - // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
52 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
53 | - $orderby .= ', menuindex ASC, pagetitle'; |
|
54 | - } |
|
55 | - |
|
56 | - $tblsc = $modx->getFullTableName('site_content'); |
|
57 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
58 | - $tblst = $modx->getFullTableName('site_templates'); |
|
59 | - // get document groups for current user |
|
60 | - $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
61 | - $showProtected = false; |
|
62 | - if(isset ($modx->config['tree_show_protected'])) { |
|
63 | - $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
64 | - } |
|
65 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
66 | - if($showProtected == false) { |
|
67 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
68 | - } else { |
|
69 | - $access = ''; |
|
70 | - } |
|
71 | - $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
72 | - $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
14 | + global $modx; |
|
15 | + global $icons, $iconsPrivate, $_style; |
|
16 | + global $_lang, $opened, $opened2, $closed2; //added global vars |
|
17 | + global $modx_textdir; |
|
18 | + |
|
19 | + $output = ''; |
|
20 | + |
|
21 | + // setup spacer |
|
22 | + $level = 0; |
|
23 | + $spacer = '<span class="indent">'; |
|
24 | + for($i = 2; $i <= $indent; $i++) { |
|
25 | + $spacer .= '<i></i>'; |
|
26 | + $level++; |
|
27 | + } |
|
28 | + $spacer .= '</span>'; |
|
29 | + |
|
30 | + // manage order-by |
|
31 | + if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
32 | + // This is the first startup, set default sort order |
|
33 | + $_SESSION['tree_sortby'] = 'menuindex'; |
|
34 | + $_SESSION['tree_sortdir'] = 'ASC'; |
|
35 | + } |
|
36 | + |
|
37 | + switch($_SESSION['tree_sortby']) { |
|
38 | + case 'createdon': |
|
39 | + case 'editedon': |
|
40 | + case 'publishedon': |
|
41 | + case 'pub_date': |
|
42 | + case 'unpub_date': |
|
43 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
44 | + break; |
|
45 | + default: |
|
46 | + $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
47 | + }; |
|
48 | + |
|
49 | + $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
50 | + |
|
51 | + // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
52 | + if($_SESSION['tree_sortby'] == 'isfolder') { |
|
53 | + $orderby .= ', menuindex ASC, pagetitle'; |
|
54 | + } |
|
55 | + |
|
56 | + $tblsc = $modx->getFullTableName('site_content'); |
|
57 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
58 | + $tblst = $modx->getFullTableName('site_templates'); |
|
59 | + // get document groups for current user |
|
60 | + $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
61 | + $showProtected = false; |
|
62 | + if(isset ($modx->config['tree_show_protected'])) { |
|
63 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
64 | + } |
|
65 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
66 | + if($showProtected == false) { |
|
67 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
68 | + } else { |
|
69 | + $access = ''; |
|
70 | + } |
|
71 | + $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
72 | + $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
73 | 73 | MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$docgrp_cond}, 1, 0)) AS hasAccess, GROUP_CONCAT(document_group SEPARATOR ',') AS roles"; |
74 | - $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
75 | - $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
76 | - $result = $modx->db->select($field, $from, $where, $orderby); |
|
77 | - if($modx->db->getRecordCount($result) == 0) { |
|
78 | - $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
79 | - } |
|
80 | - |
|
81 | - $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
82 | - |
|
83 | - while($row = $modx->db->getRow($result)) { |
|
84 | - $node = ''; |
|
85 | - |
|
86 | - $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
87 | - $nodetitleDisplay = $nodetitle; |
|
88 | - |
|
89 | - $treeNodeClass = 'node'; |
|
90 | - $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
91 | - |
|
92 | - if($row['deleted'] == 1) { |
|
93 | - $treeNodeClass .= ' deleted'; |
|
94 | - //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
95 | - } elseif($row['published'] == 0) { |
|
96 | - $treeNodeClass .= ' unpublished'; |
|
97 | - //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
98 | - } elseif($row['hidemenu'] == 1) { |
|
99 | - $treeNodeClass .= ' hidemenu'; |
|
100 | - //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
101 | - } else { |
|
102 | - //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
103 | - } |
|
104 | - |
|
105 | - if($row['id'] == $hereid) { |
|
106 | - $treeNodeClass .= ' current'; |
|
107 | - } |
|
108 | - |
|
109 | - $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
110 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
111 | - |
|
112 | - // Prepare displaying user-locks |
|
113 | - $lockedByUser = ''; |
|
114 | - $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
115 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
116 | - if($rowLock['sid'] == $modx->sid) { |
|
117 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
118 | - 'element_type' => $_lang["lock_element_type_7"], |
|
119 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
120 | - )); |
|
121 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
122 | - } else { |
|
123 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
124 | - 'element_type' => $_lang["lock_element_type_7"], |
|
125 | - 'username' => $rowLock['username'], |
|
126 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
127 | - )); |
|
128 | - if($modx->hasPermission('remove_locks')) { |
|
129 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
130 | - } else { |
|
131 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - $url = $modx->makeUrl($row['id']); |
|
137 | - |
|
138 | - $title = ''; |
|
139 | - if(isDateNode($nodeNameSource)) { |
|
140 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
141 | - } |
|
142 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
143 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
145 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
146 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
147 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
148 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
149 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
150 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
151 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
152 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | - $title = $modx->htmlspecialchars($title); |
|
155 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
156 | - |
|
157 | - $data = array( |
|
158 | - 'id' => $row['id'], |
|
159 | - 'pagetitle' => $row['pagetitle'], |
|
160 | - 'longtitle' => $row['longtitle'], |
|
161 | - 'menutitle' => $row['menutitle'], |
|
162 | - 'parent' => $parent, |
|
163 | - 'isfolder' => $row['isfolder'], |
|
164 | - 'published' => $row['published'], |
|
165 | - 'deleted' => $row['deleted'], |
|
166 | - 'type' => $row['type'], |
|
167 | - 'menuindex' => $row['menuindex'], |
|
168 | - 'donthit' => $row['donthit'], |
|
169 | - 'hidemenu' => $row['hidemenu'], |
|
170 | - 'alias' => $row['alias'], |
|
171 | - 'contenttype' => $row['contentType'], |
|
172 | - 'privateweb' => $row['privateweb'], |
|
173 | - 'privatemgr' => $row['privatemgr'], |
|
174 | - 'hasAccess' => $row['hasAccess'], |
|
175 | - 'template' => $row['template'], |
|
176 | - 'nodetitle' => $nodetitle, |
|
177 | - 'url' => $url, |
|
178 | - 'title' => $title, |
|
179 | - 'nodetitleDisplay' => $nodetitleDisplay, |
|
180 | - 'weblinkDisplay' => $weblinkDisplay, |
|
181 | - 'pageIdDisplay' => $pageIdDisplay, |
|
182 | - 'lockedByUser' => $lockedByUser, |
|
183 | - 'treeNodeClass' => $treeNodeClass, |
|
184 | - 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
185 | - 'tree_page_click' => $modx->config['tree_page_click'], |
|
186 | - 'showChildren' => 1, |
|
187 | - 'openFolder' => 1, |
|
188 | - 'contextmenu' => '', |
|
189 | - 'tree_minusnode' => $_style['tree_minusnode'], |
|
190 | - 'tree_plusnode' => $_style['tree_plusnode'], |
|
191 | - 'spacer' => $spacer, |
|
192 | - 'subMenuState' => '', |
|
193 | - 'level' => $level, |
|
194 | - 'isPrivate' => 0, |
|
195 | - 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
196 | - ); |
|
197 | - |
|
198 | - $ph = $data; |
|
199 | - $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
200 | - $ph['indent'] = $indent + 1; |
|
201 | - $ph['expandAll'] = $expandAll; |
|
202 | - $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
203 | - |
|
204 | - if(!$row['isfolder']) { |
|
205 | - $tpl = getTplSingleNode(); |
|
206 | - switch($row['id']) { |
|
207 | - case $modx->config['site_start'] : |
|
208 | - $icon = $_style['tree_page_home']; |
|
209 | - break; |
|
210 | - case $modx->config['error_page'] : |
|
211 | - $icon = $_style['tree_page_404']; |
|
212 | - break; |
|
213 | - case $modx->config['site_unavailable_page'] : |
|
214 | - $icon = $_style['tree_page_hourglass']; |
|
215 | - break; |
|
216 | - case $modx->config['unauthorized_page'] : |
|
217 | - $icon = $_style['tree_page_info']; |
|
218 | - break; |
|
219 | - default: |
|
220 | - if(isset($icons[$row['contentType']])) { |
|
221 | - $icon = $icons[$row['contentType']]; |
|
222 | - } else { |
|
223 | - $icon = $_style['tree_page']; |
|
224 | - } |
|
225 | - } |
|
226 | - $ph['icon'] = $icon; |
|
227 | - |
|
228 | - // invoke OnManagerNodePrerender event |
|
229 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
230 | - if(is_array($prenode)) { |
|
231 | - $phnew = array(); |
|
232 | - foreach($prenode as $pnode) { |
|
233 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
234 | - } |
|
235 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
236 | - } |
|
237 | - |
|
238 | - if($ph['contextmenu']) { |
|
239 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
240 | - } |
|
241 | - |
|
242 | - if($_SESSION['tree_show_only_folders']) { |
|
243 | - if($row['parent'] == 0) { |
|
244 | - $node .= $modx->parseText($tpl, $ph); |
|
245 | - } else { |
|
246 | - $node .= ''; |
|
247 | - } |
|
248 | - } else { |
|
249 | - $node .= $modx->parseText($tpl, $ph); |
|
250 | - } |
|
251 | - |
|
252 | - } else { |
|
253 | - $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
254 | - $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
255 | - |
|
256 | - if($_SESSION['tree_show_only_folders']) { |
|
257 | - $tpl = getTplFolderNodeNotChildren(); |
|
258 | - $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
259 | - $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
260 | - $ph['tree_page_click'] = 3; |
|
261 | - |
|
262 | - // expandAll: two type for partial expansion |
|
263 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
264 | - if($expandAll == 1) { |
|
265 | - $opened2[] = $row['id']; |
|
266 | - } |
|
267 | - $ph['icon'] = $ph['icon_folder_open']; |
|
268 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
269 | - $ph['node_toggle'] = 1; |
|
270 | - $ph['subMenuState'] = ' open'; |
|
271 | - |
|
272 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
273 | - $ph['showChildren'] = 1; |
|
274 | - $ph['icon_node_toggle'] = ''; |
|
275 | - $ph['icon'] = $ph['icon_folder_close']; |
|
276 | - } elseif(!$checkDocs && $checkFolders) { |
|
277 | - $ph['showChildren'] = 0; |
|
278 | - $ph['openFolder'] = 2; |
|
279 | - } else { |
|
280 | - $ph['openFolder'] = 2; |
|
281 | - } |
|
282 | - |
|
283 | - // invoke OnManagerNodePrerender event |
|
284 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
285 | - 'ph' => $ph, |
|
286 | - 'opened' => '1' |
|
287 | - )); |
|
288 | - if(is_array($prenode)) { |
|
289 | - $phnew = array(); |
|
290 | - foreach($prenode as $pnode) { |
|
291 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
292 | - } |
|
293 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
294 | - } |
|
295 | - |
|
296 | - if($ph['contextmenu']) { |
|
297 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
298 | - } |
|
299 | - |
|
300 | - $node .= $modx->parseText($tpl, $ph); |
|
301 | - if($checkFolders) { |
|
302 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
303 | - } |
|
304 | - $node .= '</div></div>'; |
|
305 | - } else { |
|
306 | - $closed2[] = $row['id']; |
|
307 | - $ph['icon'] = $ph['icon_folder_close']; |
|
308 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
309 | - $ph['node_toggle'] = 0; |
|
310 | - |
|
311 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
312 | - $ph['showChildren'] = 1; |
|
313 | - $ph['icon_node_toggle'] = ''; |
|
314 | - } elseif(!$checkDocs && $checkFolders) { |
|
315 | - $ph['showChildren'] = 0; |
|
316 | - $ph['openFolder'] = 2; |
|
317 | - } else { |
|
318 | - $ph['openFolder'] = 2; |
|
319 | - } |
|
320 | - |
|
321 | - // invoke OnManagerNodePrerender event |
|
322 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
323 | - 'ph' => $ph, |
|
324 | - 'opened' => '0' |
|
325 | - )); |
|
326 | - if(is_array($prenode)) { |
|
327 | - $phnew = array(); |
|
328 | - foreach($prenode as $pnode) { |
|
329 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
330 | - } |
|
331 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
332 | - } |
|
333 | - |
|
334 | - if($ph['contextmenu']) { |
|
335 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
336 | - } |
|
337 | - |
|
338 | - $node .= $modx->parseText($tpl, $ph); |
|
339 | - $node .= '</div></div>'; |
|
340 | - } |
|
341 | - } else { |
|
342 | - $tpl = getTplFolderNode(); |
|
343 | - // expandAll: two type for partial expansion |
|
344 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
345 | - if($expandAll == 1) { |
|
346 | - $opened2[] = $row['id']; |
|
347 | - } |
|
348 | - $ph['icon'] = $ph['icon_folder_open']; |
|
349 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
350 | - $ph['node_toggle'] = 1; |
|
351 | - $ph['subMenuState'] = ' open'; |
|
352 | - |
|
353 | - if($ph['donthit'] == 1) { |
|
354 | - $ph['tree_page_click'] = 3; |
|
355 | - $ph['icon_node_toggle'] = ''; |
|
356 | - $ph['icon'] = $ph['icon_folder_close']; |
|
357 | - $ph['showChildren'] = 0; |
|
358 | - } |
|
359 | - |
|
360 | - // invoke OnManagerNodePrerender event |
|
361 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
362 | - 'ph' => $ph, |
|
363 | - 'opened' => '1' |
|
364 | - )); |
|
365 | - if(is_array($prenode)) { |
|
366 | - $phnew = array(); |
|
367 | - foreach($prenode as $pnode) { |
|
368 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
369 | - } |
|
370 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
371 | - if($ph['showChildren'] == 0) { |
|
372 | - unset($opened2[$row['id']]); |
|
373 | - $ph['node_toggle'] = 0; |
|
374 | - $ph['subMenuState'] = ''; |
|
375 | - } |
|
376 | - } |
|
377 | - |
|
378 | - if($ph['showChildren'] == 0) { |
|
379 | - $ph['icon_node_toggle'] = ''; |
|
380 | - $ph['donthit'] = 1; |
|
381 | - $ph['icon'] = $ph['icon_folder_close']; |
|
382 | - $tpl = getTplFolderNodeNotChildren(); |
|
383 | - } |
|
384 | - |
|
385 | - if($ph['contextmenu']) { |
|
386 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
387 | - } |
|
388 | - |
|
389 | - $node .= $modx->parseText($tpl, $ph); |
|
390 | - if($ph['donthit'] == 0) { |
|
391 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
392 | - } |
|
393 | - $node .= '</div></div>'; |
|
394 | - } else { |
|
395 | - $closed2[] = $row['id']; |
|
396 | - $ph['icon'] = $ph['icon_folder_close']; |
|
397 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
398 | - $ph['node_toggle'] = 0; |
|
399 | - |
|
400 | - if($ph['donthit'] == 1) { |
|
401 | - $ph['tree_page_click'] = 3; |
|
402 | - $ph['icon_node_toggle'] = ''; |
|
403 | - $ph['icon'] = $ph['icon_folder_close']; |
|
404 | - $ph['showChildren'] = 0; |
|
405 | - } |
|
406 | - |
|
407 | - // invoke OnManagerNodePrerender event |
|
408 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
409 | - 'ph' => $ph, |
|
410 | - 'opened' => '0' |
|
411 | - )); |
|
412 | - if(is_array($prenode)) { |
|
413 | - $phnew = array(); |
|
414 | - foreach($prenode as $pnode) { |
|
415 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
416 | - } |
|
417 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
418 | - } |
|
419 | - |
|
420 | - if($ph['showChildren'] == 0) { |
|
421 | - $ph['icon_node_toggle'] = ''; |
|
422 | - $ph['donthit'] = 1; |
|
423 | - $ph['icon'] = $ph['icon_folder_close']; |
|
424 | - $tpl = getTplFolderNodeNotChildren(); |
|
425 | - } |
|
426 | - |
|
427 | - if($ph['contextmenu']) { |
|
428 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
429 | - } |
|
430 | - |
|
431 | - $node .= $modx->parseText($tpl, $ph); |
|
432 | - $node .= '</div></div>'; |
|
433 | - } |
|
434 | - } |
|
435 | - } |
|
436 | - |
|
437 | - // invoke OnManagerNodeRender event |
|
438 | - $data['node'] = $node; |
|
439 | - $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
440 | - if(is_array($evtOut)) { |
|
441 | - $evtOut = implode("\n", $evtOut); |
|
442 | - } |
|
443 | - if($evtOut != '') { |
|
444 | - $node = trim($evtOut); |
|
445 | - } |
|
446 | - |
|
447 | - $output .= $node; |
|
448 | - } |
|
449 | - |
|
450 | - return $output; |
|
74 | + $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
75 | + $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
76 | + $result = $modx->db->select($field, $from, $where, $orderby); |
|
77 | + if($modx->db->getRecordCount($result) == 0) { |
|
78 | + $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
79 | + } |
|
80 | + |
|
81 | + $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
82 | + |
|
83 | + while($row = $modx->db->getRow($result)) { |
|
84 | + $node = ''; |
|
85 | + |
|
86 | + $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
87 | + $nodetitleDisplay = $nodetitle; |
|
88 | + |
|
89 | + $treeNodeClass = 'node'; |
|
90 | + $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
91 | + |
|
92 | + if($row['deleted'] == 1) { |
|
93 | + $treeNodeClass .= ' deleted'; |
|
94 | + //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
95 | + } elseif($row['published'] == 0) { |
|
96 | + $treeNodeClass .= ' unpublished'; |
|
97 | + //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
98 | + } elseif($row['hidemenu'] == 1) { |
|
99 | + $treeNodeClass .= ' hidemenu'; |
|
100 | + //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
101 | + } else { |
|
102 | + //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
103 | + } |
|
104 | + |
|
105 | + if($row['id'] == $hereid) { |
|
106 | + $treeNodeClass .= ' current'; |
|
107 | + } |
|
108 | + |
|
109 | + $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
110 | + $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
111 | + |
|
112 | + // Prepare displaying user-locks |
|
113 | + $lockedByUser = ''; |
|
114 | + $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
115 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
116 | + if($rowLock['sid'] == $modx->sid) { |
|
117 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
118 | + 'element_type' => $_lang["lock_element_type_7"], |
|
119 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
120 | + )); |
|
121 | + $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
122 | + } else { |
|
123 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
124 | + 'element_type' => $_lang["lock_element_type_7"], |
|
125 | + 'username' => $rowLock['username'], |
|
126 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
127 | + )); |
|
128 | + if($modx->hasPermission('remove_locks')) { |
|
129 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
130 | + } else { |
|
131 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + $url = $modx->makeUrl($row['id']); |
|
137 | + |
|
138 | + $title = ''; |
|
139 | + if(isDateNode($nodeNameSource)) { |
|
140 | + $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
141 | + } |
|
142 | + $title .= $_lang['id'] . ': ' . $row['id']; |
|
143 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
144 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
145 | + $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
146 | + $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
147 | + $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
148 | + $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
149 | + $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
150 | + $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
151 | + $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
152 | + $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | + $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | + $title = $modx->htmlspecialchars($title); |
|
155 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
156 | + |
|
157 | + $data = array( |
|
158 | + 'id' => $row['id'], |
|
159 | + 'pagetitle' => $row['pagetitle'], |
|
160 | + 'longtitle' => $row['longtitle'], |
|
161 | + 'menutitle' => $row['menutitle'], |
|
162 | + 'parent' => $parent, |
|
163 | + 'isfolder' => $row['isfolder'], |
|
164 | + 'published' => $row['published'], |
|
165 | + 'deleted' => $row['deleted'], |
|
166 | + 'type' => $row['type'], |
|
167 | + 'menuindex' => $row['menuindex'], |
|
168 | + 'donthit' => $row['donthit'], |
|
169 | + 'hidemenu' => $row['hidemenu'], |
|
170 | + 'alias' => $row['alias'], |
|
171 | + 'contenttype' => $row['contentType'], |
|
172 | + 'privateweb' => $row['privateweb'], |
|
173 | + 'privatemgr' => $row['privatemgr'], |
|
174 | + 'hasAccess' => $row['hasAccess'], |
|
175 | + 'template' => $row['template'], |
|
176 | + 'nodetitle' => $nodetitle, |
|
177 | + 'url' => $url, |
|
178 | + 'title' => $title, |
|
179 | + 'nodetitleDisplay' => $nodetitleDisplay, |
|
180 | + 'weblinkDisplay' => $weblinkDisplay, |
|
181 | + 'pageIdDisplay' => $pageIdDisplay, |
|
182 | + 'lockedByUser' => $lockedByUser, |
|
183 | + 'treeNodeClass' => $treeNodeClass, |
|
184 | + 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
185 | + 'tree_page_click' => $modx->config['tree_page_click'], |
|
186 | + 'showChildren' => 1, |
|
187 | + 'openFolder' => 1, |
|
188 | + 'contextmenu' => '', |
|
189 | + 'tree_minusnode' => $_style['tree_minusnode'], |
|
190 | + 'tree_plusnode' => $_style['tree_plusnode'], |
|
191 | + 'spacer' => $spacer, |
|
192 | + 'subMenuState' => '', |
|
193 | + 'level' => $level, |
|
194 | + 'isPrivate' => 0, |
|
195 | + 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
196 | + ); |
|
197 | + |
|
198 | + $ph = $data; |
|
199 | + $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
200 | + $ph['indent'] = $indent + 1; |
|
201 | + $ph['expandAll'] = $expandAll; |
|
202 | + $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
203 | + |
|
204 | + if(!$row['isfolder']) { |
|
205 | + $tpl = getTplSingleNode(); |
|
206 | + switch($row['id']) { |
|
207 | + case $modx->config['site_start'] : |
|
208 | + $icon = $_style['tree_page_home']; |
|
209 | + break; |
|
210 | + case $modx->config['error_page'] : |
|
211 | + $icon = $_style['tree_page_404']; |
|
212 | + break; |
|
213 | + case $modx->config['site_unavailable_page'] : |
|
214 | + $icon = $_style['tree_page_hourglass']; |
|
215 | + break; |
|
216 | + case $modx->config['unauthorized_page'] : |
|
217 | + $icon = $_style['tree_page_info']; |
|
218 | + break; |
|
219 | + default: |
|
220 | + if(isset($icons[$row['contentType']])) { |
|
221 | + $icon = $icons[$row['contentType']]; |
|
222 | + } else { |
|
223 | + $icon = $_style['tree_page']; |
|
224 | + } |
|
225 | + } |
|
226 | + $ph['icon'] = $icon; |
|
227 | + |
|
228 | + // invoke OnManagerNodePrerender event |
|
229 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
230 | + if(is_array($prenode)) { |
|
231 | + $phnew = array(); |
|
232 | + foreach($prenode as $pnode) { |
|
233 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
234 | + } |
|
235 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
236 | + } |
|
237 | + |
|
238 | + if($ph['contextmenu']) { |
|
239 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
240 | + } |
|
241 | + |
|
242 | + if($_SESSION['tree_show_only_folders']) { |
|
243 | + if($row['parent'] == 0) { |
|
244 | + $node .= $modx->parseText($tpl, $ph); |
|
245 | + } else { |
|
246 | + $node .= ''; |
|
247 | + } |
|
248 | + } else { |
|
249 | + $node .= $modx->parseText($tpl, $ph); |
|
250 | + } |
|
251 | + |
|
252 | + } else { |
|
253 | + $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
254 | + $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
255 | + |
|
256 | + if($_SESSION['tree_show_only_folders']) { |
|
257 | + $tpl = getTplFolderNodeNotChildren(); |
|
258 | + $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
259 | + $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
260 | + $ph['tree_page_click'] = 3; |
|
261 | + |
|
262 | + // expandAll: two type for partial expansion |
|
263 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
264 | + if($expandAll == 1) { |
|
265 | + $opened2[] = $row['id']; |
|
266 | + } |
|
267 | + $ph['icon'] = $ph['icon_folder_open']; |
|
268 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
269 | + $ph['node_toggle'] = 1; |
|
270 | + $ph['subMenuState'] = ' open'; |
|
271 | + |
|
272 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
273 | + $ph['showChildren'] = 1; |
|
274 | + $ph['icon_node_toggle'] = ''; |
|
275 | + $ph['icon'] = $ph['icon_folder_close']; |
|
276 | + } elseif(!$checkDocs && $checkFolders) { |
|
277 | + $ph['showChildren'] = 0; |
|
278 | + $ph['openFolder'] = 2; |
|
279 | + } else { |
|
280 | + $ph['openFolder'] = 2; |
|
281 | + } |
|
282 | + |
|
283 | + // invoke OnManagerNodePrerender event |
|
284 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
285 | + 'ph' => $ph, |
|
286 | + 'opened' => '1' |
|
287 | + )); |
|
288 | + if(is_array($prenode)) { |
|
289 | + $phnew = array(); |
|
290 | + foreach($prenode as $pnode) { |
|
291 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
292 | + } |
|
293 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
294 | + } |
|
295 | + |
|
296 | + if($ph['contextmenu']) { |
|
297 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
298 | + } |
|
299 | + |
|
300 | + $node .= $modx->parseText($tpl, $ph); |
|
301 | + if($checkFolders) { |
|
302 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
303 | + } |
|
304 | + $node .= '</div></div>'; |
|
305 | + } else { |
|
306 | + $closed2[] = $row['id']; |
|
307 | + $ph['icon'] = $ph['icon_folder_close']; |
|
308 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
309 | + $ph['node_toggle'] = 0; |
|
310 | + |
|
311 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
312 | + $ph['showChildren'] = 1; |
|
313 | + $ph['icon_node_toggle'] = ''; |
|
314 | + } elseif(!$checkDocs && $checkFolders) { |
|
315 | + $ph['showChildren'] = 0; |
|
316 | + $ph['openFolder'] = 2; |
|
317 | + } else { |
|
318 | + $ph['openFolder'] = 2; |
|
319 | + } |
|
320 | + |
|
321 | + // invoke OnManagerNodePrerender event |
|
322 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
323 | + 'ph' => $ph, |
|
324 | + 'opened' => '0' |
|
325 | + )); |
|
326 | + if(is_array($prenode)) { |
|
327 | + $phnew = array(); |
|
328 | + foreach($prenode as $pnode) { |
|
329 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
330 | + } |
|
331 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
332 | + } |
|
333 | + |
|
334 | + if($ph['contextmenu']) { |
|
335 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
336 | + } |
|
337 | + |
|
338 | + $node .= $modx->parseText($tpl, $ph); |
|
339 | + $node .= '</div></div>'; |
|
340 | + } |
|
341 | + } else { |
|
342 | + $tpl = getTplFolderNode(); |
|
343 | + // expandAll: two type for partial expansion |
|
344 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
345 | + if($expandAll == 1) { |
|
346 | + $opened2[] = $row['id']; |
|
347 | + } |
|
348 | + $ph['icon'] = $ph['icon_folder_open']; |
|
349 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
350 | + $ph['node_toggle'] = 1; |
|
351 | + $ph['subMenuState'] = ' open'; |
|
352 | + |
|
353 | + if($ph['donthit'] == 1) { |
|
354 | + $ph['tree_page_click'] = 3; |
|
355 | + $ph['icon_node_toggle'] = ''; |
|
356 | + $ph['icon'] = $ph['icon_folder_close']; |
|
357 | + $ph['showChildren'] = 0; |
|
358 | + } |
|
359 | + |
|
360 | + // invoke OnManagerNodePrerender event |
|
361 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
362 | + 'ph' => $ph, |
|
363 | + 'opened' => '1' |
|
364 | + )); |
|
365 | + if(is_array($prenode)) { |
|
366 | + $phnew = array(); |
|
367 | + foreach($prenode as $pnode) { |
|
368 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
369 | + } |
|
370 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
371 | + if($ph['showChildren'] == 0) { |
|
372 | + unset($opened2[$row['id']]); |
|
373 | + $ph['node_toggle'] = 0; |
|
374 | + $ph['subMenuState'] = ''; |
|
375 | + } |
|
376 | + } |
|
377 | + |
|
378 | + if($ph['showChildren'] == 0) { |
|
379 | + $ph['icon_node_toggle'] = ''; |
|
380 | + $ph['donthit'] = 1; |
|
381 | + $ph['icon'] = $ph['icon_folder_close']; |
|
382 | + $tpl = getTplFolderNodeNotChildren(); |
|
383 | + } |
|
384 | + |
|
385 | + if($ph['contextmenu']) { |
|
386 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
387 | + } |
|
388 | + |
|
389 | + $node .= $modx->parseText($tpl, $ph); |
|
390 | + if($ph['donthit'] == 0) { |
|
391 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
392 | + } |
|
393 | + $node .= '</div></div>'; |
|
394 | + } else { |
|
395 | + $closed2[] = $row['id']; |
|
396 | + $ph['icon'] = $ph['icon_folder_close']; |
|
397 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
398 | + $ph['node_toggle'] = 0; |
|
399 | + |
|
400 | + if($ph['donthit'] == 1) { |
|
401 | + $ph['tree_page_click'] = 3; |
|
402 | + $ph['icon_node_toggle'] = ''; |
|
403 | + $ph['icon'] = $ph['icon_folder_close']; |
|
404 | + $ph['showChildren'] = 0; |
|
405 | + } |
|
406 | + |
|
407 | + // invoke OnManagerNodePrerender event |
|
408 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
409 | + 'ph' => $ph, |
|
410 | + 'opened' => '0' |
|
411 | + )); |
|
412 | + if(is_array($prenode)) { |
|
413 | + $phnew = array(); |
|
414 | + foreach($prenode as $pnode) { |
|
415 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
416 | + } |
|
417 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
418 | + } |
|
419 | + |
|
420 | + if($ph['showChildren'] == 0) { |
|
421 | + $ph['icon_node_toggle'] = ''; |
|
422 | + $ph['donthit'] = 1; |
|
423 | + $ph['icon'] = $ph['icon_folder_close']; |
|
424 | + $tpl = getTplFolderNodeNotChildren(); |
|
425 | + } |
|
426 | + |
|
427 | + if($ph['contextmenu']) { |
|
428 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
429 | + } |
|
430 | + |
|
431 | + $node .= $modx->parseText($tpl, $ph); |
|
432 | + $node .= '</div></div>'; |
|
433 | + } |
|
434 | + } |
|
435 | + } |
|
436 | + |
|
437 | + // invoke OnManagerNodeRender event |
|
438 | + $data['node'] = $node; |
|
439 | + $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
440 | + if(is_array($evtOut)) { |
|
441 | + $evtOut = implode("\n", $evtOut); |
|
442 | + } |
|
443 | + if($evtOut != '') { |
|
444 | + $node = trim($evtOut); |
|
445 | + } |
|
446 | + |
|
447 | + $output .= $node; |
|
448 | + } |
|
449 | + |
|
450 | + return $output; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | function getIconInfo($_style) { |
454 | - if(!isset($_style['tree_page_gif'])) { |
|
455 | - $_style['tree_page_gif'] = $_style['tree_page']; |
|
456 | - } |
|
457 | - if(!isset($_style['tree_page_jpg'])) { |
|
458 | - $_style['tree_page_jpg'] = $_style['tree_page']; |
|
459 | - } |
|
460 | - if(!isset($_style['tree_page_png'])) { |
|
461 | - $_style['tree_page_png'] = $_style['tree_page']; |
|
462 | - } |
|
463 | - $icons = array( |
|
464 | - 'text/html' => $_style['tree_page_html'], |
|
465 | - 'text/plain' => $_style['tree_page'], |
|
466 | - 'text/xml' => $_style['tree_page_xml'], |
|
467 | - 'text/css' => $_style['tree_page_css'], |
|
468 | - 'text/javascript' => $_style['tree_page_js'], |
|
469 | - 'application/rss+xml' => $_style['tree_page_rss'], |
|
470 | - 'application/pdf' => $_style['tree_page_pdf'], |
|
471 | - 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
472 | - 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
473 | - 'image/gif' => $_style['tree_page_gif'], |
|
474 | - 'image/jpg' => $_style['tree_page_jpg'], |
|
475 | - 'image/png' => $_style['tree_page_png'] |
|
476 | - ); |
|
477 | - return $icons; |
|
454 | + if(!isset($_style['tree_page_gif'])) { |
|
455 | + $_style['tree_page_gif'] = $_style['tree_page']; |
|
456 | + } |
|
457 | + if(!isset($_style['tree_page_jpg'])) { |
|
458 | + $_style['tree_page_jpg'] = $_style['tree_page']; |
|
459 | + } |
|
460 | + if(!isset($_style['tree_page_png'])) { |
|
461 | + $_style['tree_page_png'] = $_style['tree_page']; |
|
462 | + } |
|
463 | + $icons = array( |
|
464 | + 'text/html' => $_style['tree_page_html'], |
|
465 | + 'text/plain' => $_style['tree_page'], |
|
466 | + 'text/xml' => $_style['tree_page_xml'], |
|
467 | + 'text/css' => $_style['tree_page_css'], |
|
468 | + 'text/javascript' => $_style['tree_page_js'], |
|
469 | + 'application/rss+xml' => $_style['tree_page_rss'], |
|
470 | + 'application/pdf' => $_style['tree_page_pdf'], |
|
471 | + 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
472 | + 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
473 | + 'image/gif' => $_style['tree_page_gif'], |
|
474 | + 'image/jpg' => $_style['tree_page_jpg'], |
|
475 | + 'image/png' => $_style['tree_page_png'] |
|
476 | + ); |
|
477 | + return $icons; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | function getPrivateIconInfo($_style) { |
481 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
482 | - $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
483 | - } |
|
484 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
485 | - $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
486 | - } |
|
487 | - if(!isset($_style['tree_page_png_secure'])) { |
|
488 | - $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
489 | - } |
|
490 | - $iconsPrivate = array( |
|
491 | - 'text/html' => $_style['tree_page_html_secure'], |
|
492 | - 'text/plain' => $_style['tree_page_secure'], |
|
493 | - 'text/xml' => $_style['tree_page_xml_secure'], |
|
494 | - 'text/css' => $_style['tree_page_css_secure'], |
|
495 | - 'text/javascript' => $_style['tree_page_js_secure'], |
|
496 | - 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
497 | - 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
498 | - 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
499 | - 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
500 | - 'image/gif' => $_style['tree_page_gif_secure'], |
|
501 | - 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
502 | - 'image/png' => $_style['tree_page_png_secure'] |
|
503 | - ); |
|
504 | - return $iconsPrivate; |
|
481 | + if(!isset($_style['tree_page_gif_secure'])) { |
|
482 | + $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
483 | + } |
|
484 | + if(!isset($_style['tree_page_jpg_secure'])) { |
|
485 | + $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
486 | + } |
|
487 | + if(!isset($_style['tree_page_png_secure'])) { |
|
488 | + $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
489 | + } |
|
490 | + $iconsPrivate = array( |
|
491 | + 'text/html' => $_style['tree_page_html_secure'], |
|
492 | + 'text/plain' => $_style['tree_page_secure'], |
|
493 | + 'text/xml' => $_style['tree_page_xml_secure'], |
|
494 | + 'text/css' => $_style['tree_page_css_secure'], |
|
495 | + 'text/javascript' => $_style['tree_page_js_secure'], |
|
496 | + 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
497 | + 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
498 | + 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
499 | + 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
500 | + 'image/gif' => $_style['tree_page_gif_secure'], |
|
501 | + 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
502 | + 'image/png' => $_style['tree_page_png_secure'] |
|
503 | + ); |
|
504 | + return $iconsPrivate; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | function getNodeTitle($nodeNameSource, $row) { |
508 | - global $modx; |
|
509 | - |
|
510 | - switch($nodeNameSource) { |
|
511 | - case 'menutitle': |
|
512 | - $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
513 | - break; |
|
514 | - case 'alias': |
|
515 | - $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
516 | - if(strpos($row['alias'], '.') === false) { |
|
517 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
518 | - $nodetitle .= $modx->config['friendly_url_suffix']; |
|
519 | - } |
|
520 | - } |
|
521 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
522 | - break; |
|
523 | - case 'pagetitle': |
|
524 | - $nodetitle = $row['pagetitle']; |
|
525 | - break; |
|
526 | - case 'longtitle': |
|
527 | - $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
528 | - break; |
|
529 | - case 'createdon': |
|
530 | - case 'editedon': |
|
531 | - case 'publishedon': |
|
532 | - case 'pub_date': |
|
533 | - case 'unpub_date': |
|
534 | - $doc = $modx->getDocumentObject('id', $row['id']); |
|
535 | - $date = $doc[$nodeNameSource]; |
|
536 | - if(!empty($date)) { |
|
537 | - $nodetitle = $modx->toDateFormat($date); |
|
538 | - } else { |
|
539 | - $nodetitle = '- - -'; |
|
540 | - } |
|
541 | - break; |
|
542 | - default: |
|
543 | - $nodetitle = $row['pagetitle']; |
|
544 | - } |
|
545 | - $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
546 | - "\r\n", |
|
547 | - "\n", |
|
548 | - "\r" |
|
549 | - ), ' ', $nodetitle), ENT_COMPAT); |
|
550 | - return $nodetitle; |
|
508 | + global $modx; |
|
509 | + |
|
510 | + switch($nodeNameSource) { |
|
511 | + case 'menutitle': |
|
512 | + $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
513 | + break; |
|
514 | + case 'alias': |
|
515 | + $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
516 | + if(strpos($row['alias'], '.') === false) { |
|
517 | + if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
518 | + $nodetitle .= $modx->config['friendly_url_suffix']; |
|
519 | + } |
|
520 | + } |
|
521 | + $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
522 | + break; |
|
523 | + case 'pagetitle': |
|
524 | + $nodetitle = $row['pagetitle']; |
|
525 | + break; |
|
526 | + case 'longtitle': |
|
527 | + $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
528 | + break; |
|
529 | + case 'createdon': |
|
530 | + case 'editedon': |
|
531 | + case 'publishedon': |
|
532 | + case 'pub_date': |
|
533 | + case 'unpub_date': |
|
534 | + $doc = $modx->getDocumentObject('id', $row['id']); |
|
535 | + $date = $doc[$nodeNameSource]; |
|
536 | + if(!empty($date)) { |
|
537 | + $nodetitle = $modx->toDateFormat($date); |
|
538 | + } else { |
|
539 | + $nodetitle = '- - -'; |
|
540 | + } |
|
541 | + break; |
|
542 | + default: |
|
543 | + $nodetitle = $row['pagetitle']; |
|
544 | + } |
|
545 | + $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
546 | + "\r\n", |
|
547 | + "\n", |
|
548 | + "\r" |
|
549 | + ), ' ', $nodetitle), ENT_COMPAT); |
|
550 | + return $nodetitle; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | function isDateNode($nodeNameSource) { |
554 | - switch($nodeNameSource) { |
|
555 | - case 'createdon': |
|
556 | - case 'editedon': |
|
557 | - case 'publishedon': |
|
558 | - case 'pub_date': |
|
559 | - case 'unpub_date': |
|
560 | - return true; |
|
561 | - default: |
|
562 | - return false; |
|
563 | - } |
|
554 | + switch($nodeNameSource) { |
|
555 | + case 'createdon': |
|
556 | + case 'editedon': |
|
557 | + case 'publishedon': |
|
558 | + case 'pub_date': |
|
559 | + case 'unpub_date': |
|
560 | + return true; |
|
561 | + default: |
|
562 | + return false; |
|
563 | + } |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | function checkIsFolder($parent = 0, $isfolder = 1) { |
567 | - global $modx; |
|
567 | + global $modx; |
|
568 | 568 | |
569 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
569 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | function _htmlentities($array) { |
573 | - global $modx; |
|
573 | + global $modx; |
|
574 | 574 | |
575 | - $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
576 | - $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
575 | + $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
576 | + $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
577 | 577 | |
578 | - return $array; |
|
578 | + return $array; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | function getTplSingleNode() { |
582 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
582 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
583 | 583 | onclick="modx.tree.treeAction(event,[+id+]);" |
584 | 584 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
585 | 585 | data-id="[+id+]" |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | } |
604 | 604 | |
605 | 605 | function getTplFolderNode() { |
606 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
606 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
607 | 607 | onclick="modx.tree.treeAction(event,[+id+]);" |
608 | 608 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
609 | 609 | data-id="[+id+]" |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | } |
640 | 640 | |
641 | 641 | function getTplFolderNodeNotChildren() { |
642 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
642 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
643 | 643 | onclick="modx.tree.treeAction(event,[+id+]);" |
644 | 644 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
645 | 645 | data-id="[+id+]" |
@@ -671,10 +671,10 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | function dbug($str, $flag = false) { |
674 | - print('<pre>'); |
|
675 | - print_r($str); |
|
676 | - print('</pre>'); |
|
677 | - if($flag) { |
|
678 | - exit; |
|
679 | - } |
|
674 | + print('<pre>'); |
|
675 | + print_r($str); |
|
676 | + print('</pre>'); |
|
677 | + if($flag) { |
|
678 | + exit; |
|
679 | + } |
|
680 | 680 | } |
@@ -4,141 +4,141 @@ |
||
4 | 4 | // SNUFFKIN/ Alex 2004 |
5 | 5 | |
6 | 6 | class SqlParser { |
7 | - public $host; |
|
8 | - public $dbname; |
|
9 | - public $prefix; |
|
10 | - public $user; |
|
11 | - public $password; |
|
12 | - public $mysqlErrors; |
|
13 | - public $conn; |
|
14 | - public $installFailed; |
|
15 | - public $sitename; |
|
16 | - public $adminname; |
|
17 | - public $adminemail; |
|
18 | - public $adminpass; |
|
19 | - public $managerlanguage; |
|
20 | - public $mode; |
|
21 | - public $fileManagerPath; |
|
22 | - public $imgPath; |
|
23 | - public $imgUrl; |
|
24 | - public $dbMODx; |
|
25 | - public $dbVersion; |
|
7 | + public $host; |
|
8 | + public $dbname; |
|
9 | + public $prefix; |
|
10 | + public $user; |
|
11 | + public $password; |
|
12 | + public $mysqlErrors; |
|
13 | + public $conn; |
|
14 | + public $installFailed; |
|
15 | + public $sitename; |
|
16 | + public $adminname; |
|
17 | + public $adminemail; |
|
18 | + public $adminpass; |
|
19 | + public $managerlanguage; |
|
20 | + public $mode; |
|
21 | + public $fileManagerPath; |
|
22 | + public $imgPath; |
|
23 | + public $imgUrl; |
|
24 | + public $dbMODx; |
|
25 | + public $dbVersion; |
|
26 | 26 | public $connection_charset; |
27 | 27 | public $connection_method; |
28 | 28 | public $ignoreDuplicateErrors; |
29 | 29 | public $autoTemplateLogic; |
30 | 30 | |
31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
32 | - $this->host = $host; |
|
33 | - $this->dbname = $db; |
|
34 | - $this->prefix = $prefix; |
|
35 | - $this->user = $user; |
|
36 | - $this->password = $password; |
|
37 | - $this->adminpass = $adminpass; |
|
38 | - $this->adminname = $adminname; |
|
39 | - $this->adminemail = $adminemail; |
|
40 | - $this->connection_charset = $connection_charset; |
|
41 | - $this->connection_method = $connection_method; |
|
42 | - $this->ignoreDuplicateErrors = false; |
|
43 | - $this->managerlanguage = $managerlanguage; |
|
31 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
32 | + $this->host = $host; |
|
33 | + $this->dbname = $db; |
|
34 | + $this->prefix = $prefix; |
|
35 | + $this->user = $user; |
|
36 | + $this->password = $password; |
|
37 | + $this->adminpass = $adminpass; |
|
38 | + $this->adminname = $adminname; |
|
39 | + $this->adminemail = $adminemail; |
|
40 | + $this->connection_charset = $connection_charset; |
|
41 | + $this->connection_method = $connection_method; |
|
42 | + $this->ignoreDuplicateErrors = false; |
|
43 | + $this->managerlanguage = $managerlanguage; |
|
44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - public function connect() { |
|
48 | - $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
49 | - mysqli_select_db($this->conn, $this->dbname); |
|
50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
47 | + public function connect() { |
|
48 | + $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
49 | + mysqli_select_db($this->conn, $this->dbname); |
|
50 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
51 | 51 | |
52 | - $this->dbVersion = 3.23; // assume version 3.23 |
|
53 | - if(function_exists("mysqli_get_server_info")) { |
|
54 | - $ver = mysqli_get_server_info($this->conn); |
|
55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
56 | - $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
57 | - } |
|
52 | + $this->dbVersion = 3.23; // assume version 3.23 |
|
53 | + if(function_exists("mysqli_get_server_info")) { |
|
54 | + $ver = mysqli_get_server_info($this->conn); |
|
55 | + $this->dbMODx = version_compare($ver,"4.0.2"); |
|
56 | + $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
57 | + } |
|
58 | 58 | |
59 | 59 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | public function process($filename) { |
63 | - global $custom_placeholders; |
|
64 | - |
|
65 | - // check to make sure file exists |
|
66 | - if (!file_exists($filename)) { |
|
67 | - $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
68 | - $this->installFailed = true ; |
|
69 | - return false; |
|
70 | - } |
|
71 | - |
|
72 | - $fh = fopen($filename, 'r'); |
|
73 | - $idata = ''; |
|
74 | - |
|
75 | - while (!feof($fh)) { |
|
76 | - $idata .= fread($fh, 1024); |
|
77 | - } |
|
78 | - |
|
79 | - fclose($fh); |
|
80 | - $idata = str_replace("\r", '', $idata); |
|
81 | - |
|
82 | - // check if in upgrade mode |
|
83 | - if ($this->mode === 'upd') { |
|
84 | - // remove non-upgradeable parts |
|
85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
87 | - if($s && $e) { |
|
88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
63 | + global $custom_placeholders; |
|
64 | + |
|
65 | + // check to make sure file exists |
|
66 | + if (!file_exists($filename)) { |
|
67 | + $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
68 | + $this->installFailed = true ; |
|
69 | + return false; |
|
70 | + } |
|
71 | + |
|
72 | + $fh = fopen($filename, 'r'); |
|
73 | + $idata = ''; |
|
74 | + |
|
75 | + while (!feof($fh)) { |
|
76 | + $idata .= fread($fh, 1024); |
|
77 | + } |
|
78 | + |
|
79 | + fclose($fh); |
|
80 | + $idata = str_replace("\r", '', $idata); |
|
81 | + |
|
82 | + // check if in upgrade mode |
|
83 | + if ($this->mode === 'upd') { |
|
84 | + // remove non-upgradeable parts |
|
85 | + $s = strpos($idata,'non-upgrade-able[['); |
|
86 | + $e = strpos($idata,']]non-upgrade-able') + 17; |
|
87 | + if($s && $e) { |
|
88 | + $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
89 | 89 | } |
90 | - } |
|
91 | - |
|
92 | - // replace {} tags |
|
93 | - $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
94 | - $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
95 | - $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
96 | - $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
97 | - $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
98 | - $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
99 | - $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
100 | - $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
101 | - $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
102 | - /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
103 | - |
|
104 | - // Replace custom placeholders |
|
105 | - foreach($custom_placeholders as $key=>$val) { |
|
106 | - if (strpos($idata, '{'.$key.'}') !== false) { |
|
107 | - $idata = str_replace('{'.$key.'}', $val, $idata); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - $sql_array = explode("\n\n", $idata); |
|
112 | - |
|
113 | - $num = 0; |
|
114 | - foreach($sql_array as $sql_entry) { |
|
115 | - $sql_do = trim($sql_entry, "\r\n; "); |
|
116 | - |
|
117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
118 | - |
|
119 | - // strip out comments and \n for mysql 3.x |
|
120 | - if ($this->dbVersion <4.0) { |
|
121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
122 | - $sql_do = str_replace('\r', "", $sql_do); |
|
123 | - $sql_do = str_replace('\n', "", $sql_do); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - $num = $num + 1; |
|
128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
129 | - if(mysqli_error($this->conn)) { |
|
130 | - // Ignore duplicate and drop errors - Raymond |
|
131 | - if ($this->ignoreDuplicateErrors){ |
|
132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
133 | - } |
|
134 | - // End Ignore duplicate |
|
135 | - $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
136 | - $this->installFailed = true; |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
90 | + } |
|
91 | + |
|
92 | + // replace {} tags |
|
93 | + $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
94 | + $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
95 | + $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
96 | + $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
97 | + $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
98 | + $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
99 | + $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
100 | + $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
101 | + $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
102 | + /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
103 | + |
|
104 | + // Replace custom placeholders |
|
105 | + foreach($custom_placeholders as $key=>$val) { |
|
106 | + if (strpos($idata, '{'.$key.'}') !== false) { |
|
107 | + $idata = str_replace('{'.$key.'}', $val, $idata); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + $sql_array = explode("\n\n", $idata); |
|
112 | + |
|
113 | + $num = 0; |
|
114 | + foreach($sql_array as $sql_entry) { |
|
115 | + $sql_do = trim($sql_entry, "\r\n; "); |
|
116 | + |
|
117 | + if (preg_match('/^\#/', $sql_do)) continue; |
|
118 | + |
|
119 | + // strip out comments and \n for mysql 3.x |
|
120 | + if ($this->dbVersion <4.0) { |
|
121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
122 | + $sql_do = str_replace('\r', "", $sql_do); |
|
123 | + $sql_do = str_replace('\n', "", $sql_do); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + $num = $num + 1; |
|
128 | + if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
129 | + if(mysqli_error($this->conn)) { |
|
130 | + // Ignore duplicate and drop errors - Raymond |
|
131 | + if ($this->ignoreDuplicateErrors){ |
|
132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
133 | + } |
|
134 | + // End Ignore duplicate |
|
135 | + $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
136 | + $this->installFailed = true; |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | public function close() { |
142 | - mysqli_close($this->conn); |
|
143 | - } |
|
142 | + mysqli_close($this->conn); |
|
143 | + } |
|
144 | 144 | } |