PluginProbe
User Access Manager / 2.3.2
User Access Manager v2.3.2
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | user-access-manager.php +68 -3786 0.9.1.32.3.2 View file →
@@ -1,3798 +1,80 @@
1 1 <?php
2 -/*
3 -Plugin Name: User Access Manager
4 -Plugin URI: http://www.gm-alex.de/projects/wordpress/plugins/user-access-manager/
5 -Author URI: http://www.gm-alex.de/
6 -Version: 0.9.1.3
7 -Author: Alexander Schneider
8 -Description: Manage the access to your posts and pages. <strong>Note:</strong> <em>If you activate the plugin your upload dir will protect by a '.htaccess' with a random password and all old media files insert in a previous post/page will not work anymore. You have to update your posts/pages. If you use already a '.htaccess' file to protect your files the plugin will <strong>overwrite</strong> the '.htaccess'. You can disabel the file locking and set up an other password for the '.htaccess' file at the UAM setting page.</em>
9 -
10 -Copyright 2008 Alexander Schneider (email : alexanderschneider85 [at] gmail DOT com)
2 +/**
3 + * Plugin Name: User Access Manager
4 + * Plugin URI: https://wordpress.org/plugins/user-access-manager/
5 + * Author URI: https://twitter.com/GM_Alex
6 + * Version: 2.3.2
7 + * Requires PHP: 8.0
8 + * Author: Alexander Schneider
9 + * Description: Manage the access to your posts, pages, categories and files.
10 + * Text Domain: user-access-manager
11 + *
12 + * user-access-manager.php
13 + *
14 + * The user access manager main file.
15 + *
16 + * PHP versions 5
17 + *
18 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
19 + * @copyright 2008-2017 Alexander Schneider
20 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
21 + * @version SVN: $id$
22 + * @link http://wordpress.org/extend/plugins/user-access-manager/
23 + */
11 24
12 - This program is free software; you can redistribute it and/or modify
13 - it under the terms of the GNU General Public License as published by
14 - the Free Software Foundation; either version 2 of the License, or
15 - (at your option) any later version.
25 +function initUam() {
26 + $basePath = __DIR__ . DIRECTORY_SEPARATOR;
16 27
17 - This program is distributed in the hope that it will be useful,
18 - but WITHOUT ANY WARRANTY; without even the implied warranty of
19 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 - GNU General Public License for more details.
28 + //Load language
29 + require_once $basePath . 'includes' . DIRECTORY_SEPARATOR . 'language.php';
30 + $locale = apply_filters('plugin_locale', get_locale(), 'user-access-manager');
31 + load_textdomain(
32 + 'user-access-manager',
33 + WP_LANG_DIR . DIRECTORY_SEPARATOR . 'user-access-manager' . DIRECTORY_SEPARATOR . 'user-access-manager-' . $locale . '.mo'
34 + );
35 + load_plugin_textdomain(
36 + 'user-access-manager',
37 + false,
38 + plugin_basename(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'languages'
39 + );
21 40
22 - You should have received a copy of the GNU General Public License
23 - along with this program; if not, write to the Free Software
24 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41 + //--- Check requirements ---
25 42
26 -Uses an Image by: Everaldo Coelho - http://www.everaldo.com/
27 -*/
43 + //Check php version
44 + if (version_compare((string)phpversion(), '7.2') === -1) {
45 + add_action(
46 + 'admin_notices',
47 + function () {
48 + echo '<div id="message" class="error"><p><strong>'
49 + . sprintf(TXT_UAM_PHP_VERSION_TO_LOW, phpversion())
50 + . '</strong></p></div>';
51 + }
52 + );
28 53
29 -//DB
30 -global $wpdb;
31 -define('DB_ACCESSGROUP', $wpdb->prefix.'uam_accessgroups');
32 -define('DB_ACCESSGROUP_TO_POST', $wpdb->prefix.'uam_accessgroup_to_post');
33 -define('DB_ACCESSGROUP_TO_USER', $wpdb->prefix.'uam_accessgroup_to_user');
34 -define('DB_ACCESSGROUP_TO_CATEGORY', $wpdb->prefix.'uam_accessgroup_to_category');
35 -define('DB_ACCESSGROUP_TO_ROLE', $wpdb->prefix.'uam_accessgroup_to_role');
54 + return;
55 + }
36 56
37 -//PATH
38 -//define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/' );
39 -define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/user-access-manager/' ); //Localhost DEBUG
57 + //Check WordPress version
58 + global $wp_version;
40 59
41 -if (!class_exists("UserAccessManager"))
42 -{
43 - class UserAccessManager
44 - {
45 - var $adminOptionsName = "uamAdminOptions";
46 - var $atAdminPanel = false;
47 - var $restrictedPost = array();
48 - var $postAccess = array();
49 - var $postUserGroup = array();
50 - var $uam_db_version = "1.1";
51 - var $adminOptions;
52 -
53 - function UserAccessManager()
54 - { //constructor
55 -
56 - }
57 -
58 - function init()
59 - {
60 - load_plugin_textdomain('user-access-manager', 'wp-content/plugins/user-access-manager');
61 -
62 - //---Lang Settings---
63 - define('TXT_SETTINGS', __('Settings', 'user-access-manager'));
64 -
65 - define('TXT_POST_SETTING', __('Post settings', 'user-access-manager'));
66 - define('TXT_POST_SETTING_DESC', __('Set up the behaviour of locked posts', 'user-access-manager'));
67 - define('TXT_POST_TITLE', __('Post title', 'user-access-manager'));
68 - define('TXT_POST_TITLE_DESC', __('Displayed text as post title if user has no access', 'user-access-manager'));
69 - define('TXT_DISPLAY_POST_TITLE', __('Hide post titel', 'user-access-manager'));
70 - define('TXT_DISPLAY_POST_TITLE_DESC', sprintf(__('Selecting "Yes" will show the text which is defined at "%s" if user has no access.', 'user-access-manager'), TXT_POST_TITLE));
71 - define('TXT_POST_CONTENT', __('Post content', 'user-access-manager'));
72 - define('TXT_POST_CONTENT_DESC', __('Content displayed if user has no access. You can add an login-form by adding the keyword <b>[LOGIN_FORM]</b>. This form will shown on single posts, otherwise a link will shown.', 'user-access-manager'));
73 - define('TXT_SHOW_POST_CONTENT_BEFORE_MORE', __('Show post content before &lt;!--more--&gt; tag', 'user-access-manager'));
74 - define('TXT_SHOW_POST_CONTENT_BEFORE_MORE_DESC', sprintf(__('Shows the post content before the &lt;!--more--&gt; tag and after that the defined text at "%s". If no &lt;!--more--&gt; is set he defined text at "%s" will shown.', 'user-access-manager'), TXT_POST_CONTENT, TXT_POST_CONTENT));
75 - define('TXT_HIDE_POST', __('Hide complete posts', 'user-access-manager'));
76 - define('TXT_HIDE_POST_DESC', __('Selecting "Yes" will hide posts if the user has no access.', 'user-access-manager'));
77 - define('TXT_POST_COMMENT_CONTENT', __('Post commtent text', 'user-access-manager'));
78 - define('TXT_POST_COMMENT_CONTENT_DESC', __('Displayed text as post comment text if user has no access', 'user-access-manager'));
79 - define('TXT_DISPLAY_POST_COMMENT', __('Hide post comments', 'user-access-manager'));
80 - define('TXT_DISPLAY_POST_COMMENT_DESC', sprintf(__('Selecting "Yes" will show the text which is defined at "%s" if user has no access.', 'user-access-manager'), TXT_POST_COMMENT_CONTENT) );
81 - define('TXT_ALLOW_COMMENTS_LOCKED', __('Allow comments', 'user-access-manager'));
82 - define('TXT_ALLOW_COMMENTS_LOCKED_DESC', __('Selecting "yes" allows users to comment on locked posts', 'user-access-manager'));
83 -
84 - define('TXT_PAGE_SETTING', __('Page settings', 'user-access-manager'));
85 - define('TXT_PAGE_SETTING_DESC', __('Set up the behaviour of locked pages', 'user-access-manager'));
86 - define('TXT_PAGE_TITLE', __('Page title', 'user-access-manager'));
87 - define('TXT_PAGE_TITLE_DESC', __('Displayed text as page title if user has no access', 'user-access-manager'));
88 - define('TXT_DISPLAY_PAGE_TITLE', __('Hide page titel', 'user-access-manager'));
89 - define('TXT_DISPLAY_PAGE_TITLE_DESC', sprintf(__('Selecting "Yes" will show the text which is defined at "%s" if user has no access.', 'user-access-manager'), TXT_POST_TITLE));
90 - define('TXT_PAGE_CONTENT', __('Page content', 'user-access-manager'));
91 - define('TXT_PAGE_CONTENT_DESC', __('Content displayed if user has no access. You can add an login-form by adding the keyword <b>[LOGIN_FORM]</b>. This form will shown on single pages, otherwise a link will shown.', 'user-access-manager'));
92 - define('TXT_HIDE_PAGE', __('Hide complete pages', 'user-access-manager'));
93 - define('TXT_HIDE_PAGE_DESC', __('Selecting "Yes" will hide pages if the user has no access. Pages will also hide in the navigation.', 'user-access-manager'));
94 -
95 - define('TXT_FILE_SETTING', __('File settings', 'user-access-manager'));
96 - define('TXT_FILE_SETTING_DESC', __('Set up the behaviour of files', 'user-access-manager'));
97 - define('TXT_LOCK_FILE', __('Lock files', 'user-access-manager'));
98 - define('TXT_LOCK_FILE_DESC', __('If you select "Yes" all files will locked by a .htaccess file and only users with access can download files.', 'user-access-manager'));
99 - define('TXT_SELECTED_FILE_TYPES', __('Filetypes to lock: ', 'user-access-manager'));
100 - define('TXT_NOT_SELECTED_FILE_TYPES', __('Filetypes not to lock: ', 'user-access-manager'));
101 - define('TXT_DOWNLOAD_FILE_TYPE', __('Locked file types', 'user-access-manager'));
102 - define('TXT_DOWNLOAD_FILE_TYPE_DESC', __('Lock all files, type in file types which you will lock if the post/page is locked or define file types which will not be locked. <b>Note:</b> If you have no problems use all to get the maximum security.', 'user-access-manager'));
103 - define('TXT_FILE_PASS_TYPE', __('.htaccess password', 'user-access-manager'));
104 - define('TXT_FILE_PASS_TYPE_DESC', __('Set up the password for the .htaccess access. This password is only needed if you need a direct access to your files.', 'user-access-manager'));
105 - define('TXT_RANDOM_PASS', __('Use a random generated pass word.', 'user-access-manager'));
106 - define('TXT_CURRENT_LOGGEDIN_ADMIN_PASS', __('Use the password of the current logged in admin.', 'user-access-manager'));
107 - define('TXT_DOWNLOAD_TYPE', __('Download type', 'user-access-manager'));
108 - define('TXT_DOWNLOAD_TYPE_DESC', __('Selecting the type for downloading. <strong>Note:</strong> For using fopen you need "safe_mode = off".', 'user-access-manager'));
109 - define('TXT_NORMAL', __('Normal', 'user-access-manager'));
110 - define('TXT_FOPEN', __('fopen', 'user-access-manager'));
111 -
112 - define('TXT_OTHER_SETTING', __('Other settings', 'user-access-manager'));
113 - define('TXT_OTHER_SETTING_DESC', __('Here you will find all other settings', 'user-access-manager'));
114 - define('TXT_PROTECT_FEED', __('Protect Feed', 'user-access-manager'));
115 - define('TXT_PROTECT_FEED_DESC', __('Selecting "Yes" will also protect your feed entries.', 'user-access-manager'));
116 - define('TXT_HIDE_EMPTY_CATEGORIES', __('Hide empty categories', 'user-access-manager'));
117 - define('TXT_HIDE_EMPTY_CATEGORIES_DESC', __('Selecting "Yes" will hide empty categories which are containing only empty childs or no childs.', 'user-access-manager'));
118 - define('TXT_REDIRECT', __('Redirect user', 'user-access-manager'));
119 - define('TXT_REDIRECT_DESC', __('Setup what happen if a user visit a post/page with no access.', 'user-access-manager'));
120 - define('TXT_REDIRECT_TO_BOLG', __('To blog startpage', 'user-access-manager'));
121 - define('TXT_REDIRECT_TO_PAGE', __('Custom page: ', 'user-access-manager'));
122 - define('TXT_REDIRECT_TO_URL', __('Custom URL: ', 'user-access-manager'));
123 - define('TXT_LOCK_RECURSIVE', __('Lock recursive', 'user-access-manager'));
124 - define('TXT_LOCK_RECURSIVE_DESC', __('Selecting "Yes" will lock all child posts/pages of a post/page if a user has no access to the parent page. Note: Setting this option to "No" could result in display errors relating to the hierarchy.', 'user-access-manager'));
125 - define('TXT_BLOG_ADMIN_HINT_TEXT', __('Admin hint text', 'user-access-manager'));
126 - define('TXT_BLOG_ADMIN_HINT_TEXT_DESC', __('The text which will shown behinde the post/page.', 'user-access-manager'));
127 - define('TXT_BLOG_ADMIN_HINT', __('Show admin hint at Posts', 'user-access-manager'));
128 - define('TXT_BLOG_ADMIN_HINT_DESC', sprintf(__('Selecting "Yes" will show the defined text at "%s" behinde the post/page to an logged in admin to show him which posts/pages are locked if he visits his blog.', 'user-access-manager'), TXT_BLOG_ADMIN_HINT_TEXT));
129 - define('TXT_FULL_ACCESS_LEVEL', __('Access Level with full access', 'user-access-manager'));
130 - define('TXT_FULL_ACCESS_LEVEL_DESC', __('All user with access level equal or higher to this has full access. <b>Note: 10 is the highest value.</b>', 'user-access-manager'));
131 - define('TXT_CORE_MOD', __('Core modifications installed?', 'user-access-manager'));
132 - define('TXT_CORE_MOD_DESC', __('If you installed the core modifications activated this option.', 'user-access-manager'));
133 -
134 - define('TXT_YES', __('Yes', 'user-access-manager'));
135 - define('TXT_NO', __('No', 'user-access-manager'));
136 -
137 - define('TXT_UPDATE_SETTING', __('Update settings', 'user-access-manager'));
138 - define('TXT_UPDATE_SETTINGS', __('Settings updated.', 'user-access-manager'));
139 -
140 - //---Access groups---
141 -
142 - define('TXT_MANAGE_GROUP', __('Manage user access groups', 'user-access-manager'));
143 - define('TXT_GROUP_ROLE', __('Role affiliation', 'user-access-manager'));
144 - define('TXT_NAME', __('Name', 'user-access-manager'));
145 - define('TXT_DESCRIPTION', __('Description', 'user-access-manager'));
146 - define('TXT_READ_ACCESS', __('Read access', 'user-access-manager'));
147 - define('TXT_WRITE_ACCESS', __('Write access', 'user-access-manager'));
148 - define('TXT_POSTS', __('Posts', 'user-access-manager'));
149 - define('TXT_PAGES', __('Pages', 'user-access-manager'));
150 - define('TXT_FILES', __('Files', 'user-access-manager'));
151 - define('TXT_CATEGORY', __('Categories', 'user-access-manager'));
152 - define('TXT_USERS', __('Users', 'user-access-manager'));
153 - define('TXT_DELETE', __('Delete', 'user-access-manager'));
154 - define('TXT_UPDATE_GROUP', __('Update group', 'user-access-manager'));
155 - define('TXT_ADD', __('Add', 'user-access-manager'));
156 - define('TXT_ADD_GROUP', __('Add access group', 'user-access-manager'));
157 - define('TXT_GROUP_NAME', __('Access group name', 'user-access-manager'));
158 - define('TXT_GROUP_NAME_DESC', __('The name is used to identify the access user group.', 'user-access-manager'));
159 - define('TXT_GROUP_DESC', __('Access group description', 'user-access-manager'));
160 - define('TXT_GROUP_DESC_DESC', __('The description of the group.', 'user-access-manager'));
161 - define('TXT_GROUP_IP_RANGE', __('IP range', 'user-access-manager'));
162 - define('TXT_GROUP_IP_RANGE_DESC', __('Type in the IP ranges of users which are join these groups by there IP address without loggin. Set ranges like "BEGIN"-"END", seperate ranges by using ";", single IPs are also allowded. Example: 192.168.0.1-192.168.0.10;192.168.0.20-192.168.0.30', 'user-access-manager'));
163 - define('TXT_GROUP_READ_ACCESS', __('Read access', 'user-access-manager'));
164 - define('TXT_GROUP_READ_ACCESS_DESC', __('The read access.', 'user-access-manager'));
165 - define('TXT_GROUP_WRITE_ACCESS', __('Write access', 'user-access-manager'));
166 - define('TXT_GROUP_WRITE_ACCESS_DESC', __('The write access.', 'user-access-manager'));
167 - define('TXT_GROUP_ADDED', __('Group was added successfully.', 'user-access-manager'));
168 - define('TXT_DEL_GROUP', __('Group(s) was deleted successfully.', 'user-access-manager'));
169 - define('TXT_NONE', __('none', 'user-access-manager'));
170 - define('TXT_ACCESS_GROUP_EDIT_SUC', __('Access group edit successfully.', 'user-access-manager'));
171 - define('TXT_CONTAIN_POSTS', __('Contains %1$s of %2$s posts', 'user-access-manager'));
172 - define('TXT_CONTAIN_PAGES', __('Contains %1$s of %2$s pages', 'user-access-manager'));
173 - define('TXT_CONTAIN_FILES', __('Contains %1$s of %2$s files', 'user-access-manager'));
174 - define('TXT_CONTAIN_CATEGORIES', __('Contains %1$s of %2$s categories', 'user-access-manager'));
175 - define('TXT_CONTAIN_USERS', __('Contains %1$s of %2$s users', 'user-access-manager'));
176 - define('TXT_IP_RANGE', __('IP range', 'user-access-manager'));
177 -
178 - //---Misc---
179 - define('TXT_FULL_ACCESS', __('Full access', 'user-access-manager'));
180 - define('TXT_FULL_ACCESS_ADMIN', __('Full access (Administrator)', 'user-access-manager'));
181 - define('TXT_NO_GROUP', __('No group', 'user-access-manager'));
182 - define('TXT_SET_ACCESS', __('Set access', 'user-access-manager'));
183 -
184 - define('TXT_DATE', __('Date', 'user-access-manager'));
185 - define('TXT_TITLE', __('Title', 'user-access-manager'));
186 - define('TXT_GROUP_ACCESS', __('Group access', 'user-access-manager'));
187 - define('TXT_USERNAME', __('Username', 'user-access-manager'));
188 -
189 - define('TXT_MAIL', __('E-mail', 'user-access-manager'));
190 - define('TXT_ACCESS', __('Access', 'user-access-manager'));
191 - define('TXT_ADMIN_HINT', __('<strong>Note:</strong> An administrator has allways access to all posts/pages.', 'user-access-manager'));
192 -
193 - define('TXT_SET_POST_ACCESS', __('Set post access', 'user-access-manager'));
194 - define('TXT_SET_PAGE_ACCESS', __('Set page access', 'user-access-manager'));
195 - define('TXT_GROUPS', __('Access Groups', 'user-access-manager'));
196 - define('TXT_CREATE_GROUP_FIRST', __('Please create a access group first.', 'user-access-manager'));
197 - define('TXT_SET_USER_ACCESS', __('Set user access', 'user-access-manager'));
198 -
199 - define('TXT_SET_UP_USERGROUPS', __('Set up usergroups', 'user-access-manager'));
200 -
201 - define('TXT_ITSELF', __('itself', 'user-access-manager'));
202 - define('TXT_INFO', __('Info', 'user-access-manager'));
203 - define('TXT_GROUP_INFO', __('Group infos', 'user-access-manager'));
204 - define('TXT_GROUP_LOCK_INFO', __('Locked by', 'user-access-manager'));
205 - define('TXT_IS_ADMIN', __('User is Admin. Full access.', 'user-access-manager'));
206 - define('TXT_EXPAND', __('expand', 'user-access-manager'));
207 - define('TXT_EXPAND_ALL', __('expand all', 'user-access-manager'));
208 - define('TXT_COLLAPS', __('collaps', 'user-access-manager'));
209 - define('TXT_COLLAPS_ALL', __('collaps all', 'user-access-manager'));
210 - define('TXT_ALL', __('all', 'user-access-manager'));
211 - define('TXT_ONLY_GROUP_USERS', __('only group users', 'user-access-manager'));
212 -
213 - define('TXT_SETUP', __('Setup', 'user-access-manager'));
214 - define('TXT_RESET_UAM', __('Reset User Access Manager', 'user-access-manager'));
215 - define('TXT_RESET_UAM_DESC', __('Warning: The reset of the User Access Manager can not be undone. All settings and user groups will permanently lost.', 'user-access-manager'));
216 - define('TXT_RESET', __('reset', 'user-access-manager'));
217 - define('TXT_UAM_RESET_SUC', __('User Access Manager was reset successfully', 'user-access-manager'));
218 - }
219 -
220 - function install()
221 - {
222 - $this->create_htaccess();
223 - $this->create_htpasswd();
224 -
225 - global $wpdb;
226 - $uam_db_version = $this->uam_db_version;
227 - require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
228 -
229 - $charset_collate = '';
60 + if (version_compare((string)$wp_version, '4.6') === -1) {
61 + add_action(
62 + 'admin_notices',
63 + function () use ($wp_version) {
64 + echo '<div id="message" class="error"><p><strong>'
65 + . sprintf(TXT_UAM_WORDPRESS_VERSION_TO_LOW, $wp_version)
66 + . '</strong></p></div>';
67 + }
68 + );
230 69
231 - if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
232 - {
233 - if ( ! empty($wpdb->charset) )
234 - $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
235 - if ( ! empty($wpdb->collate) )
236 - $charset_collate .= " COLLATE $wpdb->collate";
237 - }
238 -
239 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP."'") != DB_ACCESSGROUP)
240 - {
241 - $sql = "CREATE TABLE " . DB_ACCESSGROUP . " (
242 - ID int(11) NOT NULL auto_increment,
243 - groupname tinytext NOT NULL,
244 - groupdesc text NOT NULL,
245 - read_access tinytext NOT NULL,
246 - write_access tinytext NOT NULL,
247 - ip_range mediumtext NULL,
248 - PRIMARY KEY (ID)
249 - ) $charset_collate;";
250 -
251 - dbDelta($sql);
252 - }
253 -
254 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP_TO_POST."'") != DB_ACCESSGROUP_TO_POST)
255 - {
256 - $sql = "CREATE TABLE " . DB_ACCESSGROUP_TO_POST . " (
257 - post_id int(11) NOT NULL,
258 - group_id int(11) NOT NULL,
259 - PRIMARY KEY (post_id,group_id)
260 - ) $charset_collate;";
261 -
262 - dbDelta($sql);
263 - }
264 -
265 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP_TO_USER."'") != DB_ACCESSGROUP_TO_USER)
266 - {
267 - $sql = "CREATE TABLE " . DB_ACCESSGROUP_TO_USER . " (
268 - user_id int(11) NOT NULL,
269 - group_id int(11) NOT NULL,
270 - PRIMARY KEY (user_id,group_id)
271 - ) $charset_collate;";
272 -
273 - dbDelta($sql);
274 - }
275 -
276 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP_TO_CATEGORY."'") != DB_ACCESSGROUP_TO_CATEGORY)
277 - {
278 - $sql = "CREATE TABLE " . DB_ACCESSGROUP_TO_CATEGORY . " (
279 - category_id int(11) NOT NULL,
280 - group_id int(11) NOT NULL,
281 - PRIMARY KEY (category_id,group_id)
282 - ) $charset_collate;";
283 -
284 - dbDelta($sql);
285 - }
286 -
287 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP_TO_ROLE."'") != DB_ACCESSGROUP_TO_ROLE)
288 - {
289 - $sql = "CREATE TABLE " . DB_ACCESSGROUP_TO_ROLE . " (
290 - role_name varchar(255) NOT NULL,
291 - group_id int(11) NOT NULL,
292 - PRIMARY KEY (role_name,group_id)
293 - ) $charset_collate;";
294 -
295 - dbDelta($sql);
296 - }
297 -
298 - add_option("uam_db_version", $uam_db_version);
299 - }
300 -
301 - function update()
302 - {
303 - global $wpdb;
304 - $uam_db_version = $this->uam_db_version;
305 - $installed_ver = get_option( "uam_db_version" );
306 -
307 - if(empty($installed_ver))
308 - $this->install();
309 -
310 - if($installed_ver != $uam_db_version)
311 - {
312 - if($installed_ver == '1.0')
313 - {
314 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP."'") == DB_ACCESSGROUP)
315 - {
316 - $wpdb->query("ALTER TABLE ".DB_ACCESSGROUP." ADD read_access TINYTEXT NOT NULL DEFAULT '', ADD write_access TINYTEXT NOT NULL DEFAULT '', ADD ip_range MEDIUMTEXT NULL DEFAULT ''");
317 - $wpdb->query("UPDATE ".DB_ACCESSGROUP." SET read_access = 'group', write_access = 'group'");
318 - update_option("uam_db_version", $uam_db_version);
319 - }
320 - }
321 - }
322 - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP."'") == DB_ACCESSGROUP)
323 - {
324 - if($wpdb->get_var("show columns from ".DB_ACCESSGROUP." like 'ip_range'") != 'ip_range')
325 - {
326 - $wpdb->query("ALTER TABLE ".DB_ACCESSGROUP." ADD ip_range MEDIUMTEXT NULL DEFAULT ''");
327 - }
328 - }
329 - }
330 -
331 - function uninstall()
332 - {
333 - global $wpdb;
334 - $wpdb->query("DROP TABLE ".DB_ACCESSGROUP.", ".DB_ACCESSGROUP_TO_POST.", ".DB_ACCESSGROUP_TO_USER.", ".DB_ACCESSGROUP_TO_CATEGORY.", ".DB_ACCESSGROUP_TO_ROLE);
335 - delete_option($this->adminOptionsName);
336 - delete_option("uam_db_version");
337 - $this->delete_htaccess_files();
338 - }
339 -
340 - function deactivate()
341 - {
342 - $this->delete_htaccess_files();
343 - }
344 -
345 - function create_htaccess()
346 - {
347 - // Make .htaccess file to protect data
348 -
349 - // get url
350 - $wud = wp_upload_dir();
351 - if(empty($wud['error']))
352 - {
353 - $url = $wud['basedir']."/";
354 -
355 - $areaname = "WP-Files";
356 -
357 - $uamOptions = $this->getAdminOptions();
70 + return;
71 + }
358 72
359 - if($uamOptions['lock_file_types'] == 'selected')
360 - $file_types = $uamOptions['locked_file_types'];
361 - elseif($uamOptions['lock_file_types'] == 'not_selected')
362 - $file_types = $uamOptions['not_locked_file_types'];
363 -
364 - if(isset($file_types))
365 - $file_types = str_replace(",", "|", $file_types);
366 -
367 - // make .htaccess and .htpasswd
368 -
369 - $htaccess_txt = "";
370 -
371 - if($uamOptions['lock_file_types'] == 'selected')
372 - $htaccess_txt .= "<FilesMatch '\.(".$file_types.")'>\n";
373 -
374 - if($uamOptions['lock_file_types'] == 'not_selected')
375 - $htaccess_txt .= "<FilesMatch '^\.(".$file_types.")'>\n";
376 -
377 - $htaccess_txt .= "AuthType Basic"."\n";
378 - $htaccess_txt .= "AuthName \"".$areaname."\""."\n";
379 - $htaccess_txt .= "AuthUserFile ".$url.".htpasswd"."\n";
380 - $htaccess_txt .= "require valid-user"."\n";
381 -
382 - if($uamOptions['lock_file_types'] == 'selected' || $uamOptions['lock_file_types'] == 'not_selected')
383 - $htaccess_txt .= "</FilesMatch>\n";
384 -
385 - // save files
386 - $htaccess = fopen($url.".htaccess", "w");
387 - fwrite($htaccess, $htaccess_txt);
388 - fclose($htaccess);
389 - }
390 - }
391 -
392 - function create_htpasswd($create_new = false)
393 - {
394 - global $current_user;
395 -
396 - $uamOptions = $this->getAdminOptions();
397 -
398 - // get url
399 - $wud = wp_upload_dir();
400 -
401 - if(empty($wud['error']))
402 - {
403 - $url = $wud['basedir']."/";
404 - $cur_userdata = get_userdata($current_user->ID);
405 -
406 - $user = $cur_userdata->user_login;
407 -
408 - if(!file_exists($url.".htpasswd") || $create_new)
409 - {
410 - if($uamOptions['file_pass_type'] == 'random')
411 - {
412 - # create password
413 - $array = array();
414 -
415 - $length = 10;
416 - $capitals = true;
417 - $specialSigns = false;
418 -
419 - if($length < 8)
420 - $length = mt_rand(8,20);
421 -
422 - # numbers
423 - for($i=48;$i<58;$i++)
424 - $array[] = chr($i);
425 -
426 - # small
427 - for($i=97;$i<122;$i++)
428 - $array[] = chr($i);
429 -
430 - # capitals
431 - if($capitals)
432 - for($i=65;$i<90;$i++)
433 - $array[] = chr($i);
434 -
435 - # specialchar:
436 - if($specialSigns)
437 - {
438 - for($i=33;$i<47;$i++)
439 - $array[] = chr($i);
440 - for($i=59;$i<64;$i++)
441 - $array[] = chr($i);
442 - for($i=91;$i<96;$i++)
443 - $array[] = chr($i);
444 - for($i=123;$i<126;$i++)
445 - $array[] = chr($i);
446 - }
447 -
448 - mt_srand((double)microtime()*1000000);
449 - $password = '';
450 -
451 - for ($i=1; $i<=$length; $i++)
452 - {
453 - $rnd = mt_rand( 0, count($array)-1 );
454 - $password .= $array[$rnd];
455 - $password = md5($password);
456 - }
457 - }
458 - elseif($uamOptions['file_pass_type'] == 'admin')
459 - {
460 - $password = $cur_userdata->user_pass;
461 - }
462 -
463 - // make .htpasswd
464 - $htpasswd_txt = "$user:".$password."\n";
465 -
466 - // save file
467 - $htpasswd = fopen($url.".htpasswd", "w");
468 - fwrite($htpasswd, $htpasswd_txt);
469 - fclose($htpasswd);
470 - }
471 - }
472 - }
473 -
474 - function delete_htaccess_files()
475 - {
476 - $wud = wp_upload_dir();
477 - if(empty($wud['error']))
478 - {
479 - $url = $wud['basedir']."/";
480 - unlink($url.".htaccess");
481 - unlink($url.".htpasswd");
482 - }
483 - }
484 -
485 - //Returns an array of admin options
486 - function getAdminOptions()
487 - {
488 - if($this->atAdminPanel || empty($this->adminOptions))
489 - {
490 - $uamAdminOptions = array( 'hide_post_title' => 'false',
491 - 'post_title' => __('No rights!', 'user-access-manager'),
492 - 'hide_post_comment' => 'false',
493 - 'post_comment_content' => __('Sorry no rights to view comments!', 'user-access-manager'),
494 - 'allow_comments_locked' => 'false',
495 - 'post_content' => 'Sorry no rights!',
496 - 'hide_post' => 'false',
497 - 'hide_page_title' => 'false',
498 - 'page_title' => 'No rights!',
499 - 'page_content' => __('Sorry you have no rights to view this page!', 'user-access-manager'),
500 - 'hide_page' => 'false',
501 - 'redirect' => 'false',
502 - 'redirect_custom_page' => '',
503 - 'redirect_custom_url' => '',
504 - 'lock_recursive' => 'true',
505 - 'lock_file' => 'true',
506 - 'file_pass_type' => 'random',
507 - 'lock_file_types' => 'all',
508 - 'download_type' => 'fopen',
509 - 'locked_file_types' => 'zip,rar,tar,gz,bz2',
510 - 'not_locked_file_types' => 'gif,jpg,jpeg,png',
511 - 'blog_admin_hint' => 'true',
512 - 'blog_admin_hint_text' => '[L]',
513 - 'core_mod' => 'false',
514 - 'hide_empty_categories' => 'true',
515 - 'protect_feed' => 'true',
516 - 'show_post_content_before_more' => 'false',
517 - 'full_access_level' => 10);
518 -
519 - $uamOptions = get_option($this->adminOptionsName);
520 - if (!empty($uamOptions)) {
521 - foreach ($uamOptions as $key => $option)
522 - $uamAdminOptions[$key] = $option;
523 - }
524 - update_option($this->adminOptionsName, $uamAdminOptions);
525 - $this->adminOptions = $uamAdminOptions;
526 - }
527 - return $this->adminOptions;
528 - }
529 -
530 - //Prints out the admin page
531 - function printAdminPage()
532 - {
533 - global $wpdb;
534 -
535 - $uamOptions = $this->getAdminOptions();
536 -
537 - if (isset($_POST['update_uam_settings']))
538 - {
539 - if (isset($_POST['uam_hide_post_title']))
540 - {
541 - $uamOptions['hide_post_title'] = $_POST['uam_hide_post_title'];
542 - }
543 - if (isset($_POST['uam_post_title']))
544 - {
545 - $uamOptions['post_title'] = $_POST['uam_post_title'];
546 - }
547 - if (isset($_POST['uam_show_post_content_before_more']))
548 - {
549 - $uamOptions['show_post_content_before_more'] = $_POST['uam_show_post_content_before_more'];
550 - }
551 - if (isset($_POST['uam_post_content']))
552 - {
553 - $uamOptions['post_content'] = $_POST['uam_post_content'];
554 - }
555 - if (isset($_POST['uam_hide_post']))
556 - {
557 - $uamOptions['hide_post'] = $_POST['uam_hide_post'];
558 - }
559 - if (isset($_POST['uam_hide_post_comment']))
560 - {
561 - $uamOptions['hide_post_comment'] = $_POST['uam_hide_post_comment'];
562 - }
563 - if (isset($_POST['uam_post_comment_content']))
564 - {
565 - $uamOptions['post_comment_content'] = $_POST['uam_post_comment_content'];
566 - }
567 - if (isset($_POST['uam_allow_comments_locked']))
568 - {
569 - $uamOptions['allow_comments_locked'] = $_POST['uam_allow_comments_locked'];
570 - }
571 - if (isset($_POST['uam_hide_page_title']))
572 - {
573 - $uamOptions['hide_page_title'] = $_POST['uam_hide_page_title'];
574 - }
575 - if (isset($_POST['uam_page_title']))
576 - {
577 - $uamOptions['page_title'] = $_POST['uam_page_title'];
578 - }
579 - if (isset($_POST['uam_page_content']))
580 - {
581 - $uamOptions['page_content'] = $_POST['uam_page_content'];
582 - }
583 - if (isset($_POST['uam_hide_page']))
584 - {
585 - $uamOptions['hide_page'] = $_POST['uam_hide_page'];
586 - }
587 - if (isset($_POST['uam_protect_feed']))
588 - {
589 - $uamOptions['protect_feed'] = $_POST['uam_protect_feed'];
590 - }
591 - if (isset($_POST['uam_hide_empty_categories']))
592 - {
593 - $uamOptions['hide_empty_categories'] = $_POST['uam_hide_empty_categories'];
594 - }
595 - if (isset($_POST['uam_redirect']))
596 - {
597 - $uamOptions['redirect'] = $_POST['uam_redirect'];
598 - }
599 - if (isset($_POST['uam_redirect_custom_page']))
600 - {
601 - $uamOptions['redirect_custom_page'] = $_POST['uam_redirect_custom_page'];
602 - }
603 - if (isset($_POST['uam_redirect_custom_url']))
604 - {
605 - $uamOptions['redirect_custom_url'] = $_POST['uam_redirect_custom_url'];
606 - }
607 - if (isset($_POST['uam_lock_recursive']))
608 - {
609 - $uamOptions['lock_recursive'] = $_POST['uam_lock_recursive'];
610 - }
611 - if (isset($_POST['uam_blog_admin_hint']))
612 - {
613 - $uamOptions['blog_admin_hint'] = $_POST['uam_blog_admin_hint'];
614 - }
615 - if (isset($_POST['uam_blog_admin_hint_text']))
616 - {
617 - $uamOptions['blog_admin_hint_text'] = $_POST['uam_blog_admin_hint_text'];
618 - }
619 - if (isset($_POST['uam_core_mod']))
620 - {
621 - $uamOptions['core_mod'] = $_POST['uam_core_mod'];
622 - }
623 - if (isset($_POST['uam_full_access_level']) && is_numeric($_POST['uam_full_access_level']) && $_POST['uam_full_access_level'] <= 10)
624 - {
625 - $uamOptions['full_access_level'] = $_POST['uam_full_access_level'];
626 - }
627 - if (isset($_POST['uam_lock_file']))
628 - {
629 - if($_POST['uam_lock_file'] == 'false')
630 - {
631 - if($uamOptions['lock_file'] != $_POST['uam_lock_file'])
632 - $this->delete_htaccess_files();
633 - }
634 - else
635 - {
636 - if($uamOptions['lock_file'] != $_POST['uam_lock_file'])
637 - $lock_file_changed = true;
638 - }
639 - $uamOptions['lock_file'] = $_POST['uam_lock_file'];
640 - }
641 -
642 - if (isset($_POST['uam_file_pass_type']))
643 - {
644 - if($uamOptions['file_pass_type'] != $_POST['uam_file_pass_type'])
645 - $file_pass_changed = true;
646 - else
647 - $file_pass_changed = false;
648 -
649 - $uamOptions['file_pass_type'] = $_POST['uam_file_pass_type'];
650 - }
651 - if (isset($_POST['uam_download_type']))
652 - {
653 - $uamOptions['download_type'] = $_POST['uam_download_type'];
654 - }
655 - if (isset($_POST['uam_locked_file_types']))
656 - {
657 - if($uamOptions['locked_file_types'] != $_POST['uam_locked_file_types'])
658 - $locked_file_types_changed = true;
659 - else
660 - $locked_file_types_changed = false;
661 -
662 - $uamOptions['locked_file_types'] = $_POST['uam_locked_file_types'];
663 - }
664 - if (isset($_POST['uam_not_locked_file_types']))
665 - {
666 - if($uamOptions['not_locked_file_types'] != $_POST['uam_not_locked_file_types'])
667 - $not_locked_file_types_changed = true;
668 - else
669 - $not_locked_file_types_changed = false;
670 -
671 - $uamOptions['not_locked_file_types'] = $_POST['uam_not_locked_file_types'];
672 - }
673 - if (isset($_POST['uam_lock_file_types']))
674 - {
675 - if($uamOptions['lock_file_types'] != $_POST['uam_lock_file_types'])
676 - $locked_file_types_changed = true;
677 -
678 - $uamOptions['lock_file_types'] = $_POST['uam_lock_file_types'];
679 - }
680 -
681 - update_option($this->adminOptionsName, $uamOptions);
682 -
683 - if(($locked_file_types_changed || $not_locked_file_types_changed || isset($lock_file_changed) || $file_pass_changed) && $uamOptions['lock_file'] != 'false')
684 - {
685 - $this->create_htaccess();
686 - $this->create_htpasswd(true);
687 - }
688 - ?>
689 - <div class="updated"><p><strong><?php echo TXT_UPDATE_SETTINGS; ?></strong></p></div>
690 - <?php
691 - }
692 -
693 - if(isset($_GET['page']))
694 - $cur_admin_page = $_GET['page'];
695 -
696 - if(isset($_GET['action']))
697 - $action = $_GET['action'];
698 - else
699 - $action = null;
700 -
701 - if(isset($_POST['action']))
702 - $post_action = $_POST['action'];
703 - else
704 - $post_action = null;
705 -
706 - if($post_action == 'delgroup')
707 - {
708 - if(isset($_POST['delete']))
709 - $del_ids = $_POST['delete'];
710 -
711 - if(isset($del_ids))
712 - {
713 - foreach($del_ids as $del_id)
714 - {
715 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP." WHERE ID = $del_id LIMIT 1");
716 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE group_id = $del_id");
717 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_USER." WHERE group_id = $del_id");
718 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_CATEGORY." WHERE group_id = $del_id");
719 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_ROLE." WHERE group_id = $del_id");
720 - }
721 - ?>
722 - <div class="updated"><p><strong><?php echo TXT_DEL_GROUP; ?></strong></p></div>
723 - <?php
724 - }
725 - }
726 -
727 - if($post_action == 'update_group' || $post_action == 'addgroup')
728 - {
729 - if($post_action == 'addgroup')
730 - {
731 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP." (ID, groupname, groupdesc, read_access, write_access, ip_range) VALUES(NULL, '".$_POST['access_group_name']."', '".$_POST['access_group_description']."', '".$_POST['read_access']."', '".$_POST['write_access']."', '".$_POST['ip_range']."')");
732 -
733 - $group_id = $wpdb->insert_id;
734 - }
735 - elseif($post_action == 'update_group')
736 - {
737 - $wpdb->query(" UPDATE ".DB_ACCESSGROUP."
738 - SET groupname = '".$_POST['access_group_name']."', groupdesc = '".$_POST['access_group_description']."', read_access = '".$_POST['read_access']."', write_access = '".$_POST['write_access']."', ip_range = '".$_POST['ip_range']."'
739 - WHERE ID = ".$_POST['access_group_id']);
740 -
741 - $group_id = $_POST['access_group_id'];
742 -
743 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_ROLE." WHERE group_id = ".$group_id);
744 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE group_id = ".$group_id);
745 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_CATEGORY." WHERE group_id = ".$group_id);
746 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_USER." WHERE group_id = ".$group_id);
747 - }
748 -
749 - if(isset($_POST['roles']))
750 - $roles = $_POST['roles'];
751 - else
752 - $roles = null;
753 -
754 - if($roles)
755 - {
756 - foreach($roles as $role)
757 - {
758 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_ROLE." (group_id, role_name) VALUES('".$group_id."', '".$role."')");
759 - }
760 - }
761 -
762 - if(isset($_POST['post']))
763 - $posts = $_POST['post'];
764 - else
765 - $posts = null;
766 -
767 - if($posts)
768 - {
769 - foreach($posts as $post)
770 - {
771 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_POST." (group_id, post_id) VALUES('".$group_id."', '".$post."')");
772 - }
773 - }
774 -
775 - if(isset($_POST['page']))
776 - $pages = $_POST['page'];
777 - else
778 - $pages = null;
779 -
780 - if($pages)
781 - {
782 - foreach($pages as $page)
783 - {
784 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_POST." (group_id, post_id) VALUES('".$group_id."', '".$page."')");
785 - }
786 - }
787 -
788 - if(isset($_POST['file']))
789 - $files = $_POST['file'];
790 - else
791 - $files = null;
792 -
793 - if($files)
794 - {
795 - foreach($files as $file)
796 - {
797 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_POST." (group_id, post_id) VALUES('".$group_id."', '".$file."')");
798 - }
799 - }
800 -
801 - if(isset($_POST['category']))
802 - $categories = $_POST['category'];
803 - else
804 - $categories = null;
805 -
806 - if($categories)
807 - {
808 - foreach($categories as $category)
809 - {
810 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_CATEGORY." (group_id, category_id) VALUES('".$group_id."', '".$category."')");
811 - }
812 - }
813 -
814 - if(isset($_POST['user']))
815 - $users = $_POST['user'];
816 - else
817 - $users = null;
818 -
819 - if($users)
820 - {
821 - foreach($users as $user)
822 - {
823 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_USER." (group_id, user_id) VALUES('".$group_id."', '".$user."')");
824 - }
825 - }
826 -
827 - if($post_action == 'addgroup')
828 - {
829 - ?>
830 - <div class="updated"><p><strong><?php echo TXT_GROUP_ADDED; ?></strong></p></div>
831 - <?php
832 - }
833 - elseif($post_action == 'update_group')
834 - {
835 - ?>
836 - <div class="updated"><p><strong><?php echo TXT_ACCESS_GROUP_EDIT_SUC; ?></strong></p></div>
837 - <?php
838 - }
839 - }
840 -
841 - if($post_action == 'reset_uam')
842 - {
843 - if(isset($_POST['uam_reset']))
844 - $reset = $_POST['uam_reset'];
845 - else
846 - $reset = null;
847 -
848 - if($reset == 'true')
849 - {
850 - $this->uninstall();
851 - $this->install();
852 - ?>
853 - <div class="updated"><p><strong><?php echo TXT_UAM_RESET_SUC; ?></strong></p></div>
854 - <?php
855 - }
856 - }
857 -
858 - if($cur_admin_page == 'uam_settings')
859 - {
860 - ?>
861 - <div class=wrap>
862 - <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
863 - <h2><?php echo TXT_SETTINGS; ?></h2>
864 - <h3><?php echo TXT_POST_SETTING; ?></h3>
865 - <p><?php echo TXT_POST_SETTING_DESC; ?></p>
866 - <table class="form-table">
867 - <tbody>
868 - <tr valign="top">
869 - <th scope="row">
870 - <?php echo TXT_HIDE_POST; ?>
871 - </th>
872 - <td>
873 - <label for="uam_hide_post_yes">
874 - <input type="radio" id="uam_hide_post_yes" class="uam_hide_post" name="uam_hide_post" value="true" <?php if ($uamOptions['hide_post'] == "true") { echo 'checked="checked"'; }?> />
875 - <?php echo TXT_YES; ?>
876 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
877 - <label for="uam_hide_post_no">
878 - <input type="radio" id="uam_hide_post_no" class="uam_hide_post" name="uam_hide_post" value="false" <?php if ($uamOptions['hide_post'] == "false") { echo 'checked="checked"'; }?>/>
879 - <?php echo TXT_NO; ?>
880 - </label>
881 - <br />
882 - <?php echo TXT_HIDE_POST_DESC; ?>
883 - </td>
884 - </tr>
885 - </tbody>
886 - </table>
887 - <table class="form-table" id="uam_post_settings">
888 - <tbody>
889 - <tr valign="top">
890 - <th scope="row">
891 - <?php echo TXT_DISPLAY_POST_TITLE; ?>
892 - </th>
893 - <td>
894 - <label for="uam_hide_post_title_yes">
895 - <input type="radio" id="uam_hide_post_title_yes" name="uam_hide_post_title" value="true" <?php if ($uamOptions['hide_post_title'] == "true") { echo 'checked="checked"'; }?> />
896 - <?php echo TXT_YES; ?>
897 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
898 - <label for="uam_hide_post_title_no">
899 - <input type="radio" id="uam_hide_post_title_no" name="uam_hide_post_title" value="false" <?php if ($uamOptions['hide_post_title'] == "false") { echo 'checked="checked"'; }?>/>
900 - <?php echo TXT_NO; ?>
901 - </label>
902 - <br />
903 - <?php echo TXT_DISPLAY_POST_TITLE_DESC; ?>
904 - </td>
905 - </tr>
906 - <tr valign="top">
907 - <th scope="row">
908 - <?php echo TXT_POST_TITLE; ?>
909 - </th>
910 - <td>
911 - <input name="uam_post_title" value="<?php echo $uamOptions['post_title']; ?>" />
912 - <br />
913 - <?php echo TXT_POST_TITLE_DESC; ?>
914 - </td>
915 - </tr>
916 - <tr valign="top">
917 - <th scope="row">
918 - <?php echo TXT_SHOW_POST_CONTENT_BEFORE_MORE; ?>
919 - </th>
920 - <td>
921 - <label for="uam_show_post_content_before_more_yes">
922 - <input type="radio" id="uam_hide_post_title_yes" name="uam_show_post_content_before_more" value="true" <?php if ($uamOptions['show_post_content_before_more'] == "true") { echo 'checked="checked"'; }?> />
923 - <?php echo TXT_YES; ?>
924 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
925 - <label for="uam_show_post_content_before_more_no">
926 - <input type="radio" id="uam_hide_post_title_no" name="uam_show_post_content_before_more" value="false" <?php if ($uamOptions['show_post_content_before_more'] == "false") { echo 'checked="checked"'; }?>/>
927 - <?php echo TXT_NO; ?>
928 - </label>
929 - <br />
930 - <?php echo TXT_SHOW_POST_CONTENT_BEFORE_MORE_DESC; ?>
931 - </td>
932 - </tr>
933 - <tr valign="top">
934 - <th scope="row">
935 - <?php echo TXT_POST_CONTENT; ?>
936 - </th>
937 - <td>
938 - <textarea name="uam_post_content" style="width: 80%; height: 100px;"><?php echo apply_filters('format_to_edit',$uamOptions['post_content']); ?></textarea>
939 - <br />
940 - <?php echo TXT_POST_CONTENT_DESC; ?>
941 - </td>
942 - </tr>
943 - <tr valign="top">
944 - <th scope="row">
945 - <?php echo TXT_DISPLAY_POST_COMMENT; ?>
946 - </th>
947 - <td>
948 - <label for="uam_hide_post_comment_yes">
949 - <input type="radio" name="uam_hide_post_comment" value="true" <?php if ($uamOptions['hide_post_comment'] == "true") { echo 'checked="checked"'; }?> />
950 - <?php echo TXT_YES; ?>
951 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
952 - <label for="uam_hide_post_comment_no">
953 - <input type="radio"name="uam_hide_post_comment" value="false" <?php if ($uamOptions['hide_post_comment'] == "false") { echo 'checked="checked"'; }?>/>
954 - <?php echo TXT_NO; ?>
955 - </label>
956 - <br />
957 - <?php echo TXT_DISPLAY_POST_COMMENT_DESC; ?>
958 - </td>
959 - </tr>
960 - <tr valign="top">
961 - <th scope="row">
962 - <?php echo TXT_POST_COMMENT_CONTENT; ?>
963 - </th>
964 - <td>
965 - <input name="uam_post_comment_content" value="<?php echo $uamOptions['post_comment_content']; ?>" />
966 - <br />
967 - <?php echo TXT_POST_COMMENT_CONTENT_DESC; ?>
968 - </td>
969 - </tr>
970 - <tr valign="top">
971 - <th scope="row">
972 - <?php echo TXT_ALLOW_COMMENTS_LOCKED; ?>
973 - </th>
974 - <td>
975 - <label for="uam_allow_comments_locked_yes">
976 - <input type="radio" name="uam_allow_comments_locked" value="true" <?php if ($uamOptions['allow_comments_locked'] == "true") { echo 'checked="checked"'; }?> />
977 - <?php echo TXT_YES; ?>
978 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
979 - <label for="uam_allow_comments_locked_no">
980 - <input type="radio"name="uam_allow_comments_locked" value="false" <?php if ($uamOptions['allow_comments_locked'] == "false") { echo 'checked="checked"'; }?>/>
981 - <?php echo TXT_NO; ?>
982 - </label>
983 - <br />
984 - <?php echo TXT_ALLOW_COMMENTS_LOCKED_DESC; ?>
985 - </td>
986 - </tr>
987 - </tbody>
988 - </table>
989 - <h3><?php echo TXT_PAGE_SETTING; ?></h3>
990 - <p><?php echo TXT_PAGE_SETTING_DESC; ?></p>
991 - <table class="form-table">
992 - <tbody>
993 - <tr>
994 - <th>
995 - <?php echo TXT_HIDE_PAGE; ?>
996 - </th>
997 - <td>
998 - <label for="uam_hide_page_yes">
999 - <input type="radio" id="uam_hide_page_yes" class="uam_hide_page" name="uam_hide_page" value="true" <?php if ($uamOptions['hide_page'] == "true") { echo 'checked="checked"'; }?> />
1000 - <?php echo TXT_YES; ?>
1001 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1002 - <label for="uam_hide_page_no">
1003 - <input type="radio" id="uam_hide_page_no" class="uam_hide_page" name="uam_hide_page" value="false" <?php if ($uamOptions['hide_page'] == "false") { echo 'checked="checked"'; }?>/>
1004 - <?php echo TXT_NO; ?>
1005 - </label>
1006 - <br />
1007 - <?php echo TXT_HIDE_PAGE_DESC; ?>
1008 - </td>
1009 - </tr>
1010 - </tbody>
1011 - </table>
1012 - <table class="form-table" id="uam_page_settings">
1013 - <tbody>
1014 - <tr valign="top">
1015 - <th scope="row">
1016 - <?php echo TXT_DISPLAY_PAGE_TITLE; ?>
1017 - </th>
1018 - <td>
1019 - <label for="uam_hide_page_title_yes">
1020 - <input type="radio" id="uam_hide_page_title_yes" name="uam_hide_page_title" value="true" <?php if ($uamOptions['hide_page_title'] == "true") { echo 'checked="checked"'; }?> />
1021 - <?php echo TXT_YES; ?>
1022 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1023 - <label for="uam_hide_page_title_no">
1024 - <input type="radio" id="uam_hide_page_title_no" name="uam_hide_page_title" value="false" <?php if ($uamOptions['hide_page_title'] == "false") { echo 'checked="checked"'; }?>/>
1025 - <?php echo TXT_NO; ?>
1026 - </label>
1027 - <br />
1028 - <?php echo TXT_DISPLAY_PAGE_TITLE_DESC; ?>
1029 - </td>
1030 - </tr>
1031 - <tr>
1032 - <th>
1033 - <?php echo TXT_PAGE_TITLE; ?>
1034 - </th>
1035 - <td>
1036 - <input name="uam_page_title" value="<?php echo $uamOptions['page_title']; ?>" />
1037 - <br />
1038 - <?php echo TXT_PAGE_TITLE_DESC; ?>
1039 - </td>
1040 - </tr>
1041 - <tr>
1042 - <th>
1043 - <?php echo TXT_PAGE_CONTENT; ?>
1044 - </th>
1045 - <td>
1046 - <textarea name="uam_page_content" style="width: 80%; height: 100px;"><?php echo apply_filters('format_to_edit',$uamOptions['page_content']); ?></textarea>
1047 - <br />
1048 - <?php echo TXT_PAGE_CONTENT_DESC; ?>
1049 - </td>
1050 - </tr>
1051 - </tbody>
1052 - </table>
1053 - <h3><?php echo TXT_FILE_SETTING; ?></h3>
1054 - <p><?php echo TXT_FILE_SETTING_DESC; ?></p>
1055 - <table class="form-table">
1056 - <tbody>
1057 - <tr>
1058 - <th>
1059 - <?php echo TXT_LOCK_FILE; ?>
1060 - </th>
1061 - <td>
1062 - <label for="uam_lock_file_yes">
1063 - <input type="radio" id="uam_lock_file_yes" class="uam_lock_file" name="uam_lock_file" value="true" <?php if ($uamOptions['lock_file'] == "true") { echo 'checked="checked"'; }?> />
1064 - <?php echo TXT_YES; ?>
1065 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1066 - <label for="uam_lock_file_no">
1067 - <input type="radio" id="uam_lock_file_no" class="uam_lock_file" name="uam_lock_file" value="false" <?php if ($uamOptions['lock_file'] == "false") { echo 'checked="checked"'; }?>/>
1068 - <?php echo TXT_NO; ?>
1069 - </label>
1070 - <br />
1071 - <?php echo TXT_LOCK_FILE_DESC; ?>
1072 - </td>
1073 - </tr>
1074 - </tbody>
1075 - </table>
1076 - <table class="form-table" id="uam_file_settings">
1077 - <tbody>
1078 - <tr>
1079 - <th>
1080 - <?php echo TXT_DOWNLOAD_FILE_TYPE; ?>
1081 - </th>
1082 - <td>
1083 - <label for="uam_lock_file_types_all">
1084 - <input type="radio" id="uam_lock_file_types_all" name="uam_lock_file_types" value="all" <?php if ($uamOptions['lock_file_types'] == "all") { echo 'checked="checked"'; }?> />
1085 - <?php echo TXT_ALL; ?>
1086 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1087 - <label for="uam_lock_file_types_selected">
1088 - <input type="radio" id="uam_lock_file_types_selected" name="uam_lock_file_types" value="selected" <?php if ($uamOptions['lock_file_types'] == "selected") { echo 'checked="checked"'; }?> />
1089 - <?php echo TXT_SELECTED_FILE_TYPES; ?>
1090 - </label><input name="uam_locked_file_types" value="<?php echo $uamOptions['locked_file_types']; ?>" />
1091 - <label for="uam_lock_file_types_not_selected">
1092 - <input type="radio" id="uam_lock_file_types_not_selected" name="uam_lock_file_types" value="not_selected" <?php if ($uamOptions['lock_file_types'] == "not_selected") { echo 'checked="checked"'; }?> />
1093 - <?php echo TXT_NOT_SELECTED_FILE_TYPES; ?>
1094 - </label><input name="uam_not_locked_file_types" value="<?php echo $uamOptions['not_locked_file_types']; ?>" />
1095 - <br />
1096 - <?php echo TXT_DOWNLOAD_FILE_TYPE_DESC; ?>
1097 - </td>
1098 - </tr>
1099 - <tr>
1100 - <th>
1101 - <?php echo TXT_FILE_PASS_TYPE; ?>
1102 - </th>
1103 - <td>
1104 - <label for="uam_file_pass_type_admin">
1105 - <input type="radio" id="uam_file_pass_type_admin" name="uam_file_pass_type" value="admin" <?php if ($uamOptions['file_pass_type'] == "admin") { echo 'checked="checked"'; }?> />
1106 - <?php echo TXT_CURRENT_LOGGEDIN_ADMIN_PASS; ?>
1107 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1108 - <label for="uam_file_pass_type_random">
1109 - <input type="radio" id="uam_file_pass_type_random" name="uam_file_pass_type" value="random" <?php if ($uamOptions['file_pass_type'] == "random") { echo 'checked="checked"'; }?>/>
1110 - <?php echo TXT_RANDOM_PASS; ?>
1111 - </label>
1112 - <br />
1113 - <?php echo TXT_FILE_PASS_TYPE_DESC; ?>
1114 - </td>
1115 - </tr>
1116 - <tr>
1117 - <th>
1118 - <?php echo TXT_DOWNLOAD_TYPE; ?>
1119 - </th>
1120 - <td>
1121 - <label for="uam_download_type_normal">
1122 - <input type="radio" id="uam_download_type_normal" name="uam_download_type" value="normal" <?php if ($uamOptions['download_type'] == "normal") { echo 'checked="checked"'; }?> />
1123 - <?php echo TXT_NORMAL; ?>
1124 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1125 - <label for="uam_download_type_fopen">
1126 - <input type="radio" id="uam_download_type_fopen" name="uam_download_type" value="fopen" <?php if ($uamOptions['download_type'] == "fopen") { echo 'checked="checked"'; }?>/>
1127 - <?php echo TXT_FOPEN; ?>
1128 - </label>
1129 - <br />
1130 - <?php echo TXT_DOWNLOAD_TYPE_DESC; ?>
1131 - </td>
1132 - </tr>
1133 - </tbody>
1134 - </table>
1135 - <h3><?php echo TXT_OTHER_SETTING; ?></h3>
1136 - <p><?php echo TXT_OTHER_SETTING_DESC; ?></p>
1137 - <table class="form-table">
1138 - <tbody>
1139 - <tr>
1140 - <th>
1141 - <?php echo TXT_PROTECT_FEED; ?>
1142 - </th>
1143 - <td>
1144 - <label for="uam_protect_feed_yes">
1145 - <input type="radio" id="uam_protect_feed_yes" name="uam_protect_feed" value="true" <?php if ($uamOptions['protect_feed'] == "true") { echo 'checked="checked"'; }?> />
1146 - <?php echo TXT_YES; ?>
1147 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1148 - <label for="uam_protect_feed_no">
1149 - <input type="radio" id="uam_protect_feed_no" name="uam_protect_feed" value="false" <?php if ($uamOptions['protect_feed'] == "false") { echo 'checked="checked"'; }?>/>
1150 - <?php echo TXT_NO; ?>
1151 - </label>
1152 - <br />
1153 - <?php echo TXT_PROTECT_FEED_DESC; ?>
1154 - </td>
1155 - </tr>
1156 - <tr>
1157 - <th>
1158 - <?php echo TXT_HIDE_EMPTY_CATEGORIES; ?>
1159 - </th>
1160 - <td>
1161 - <label for="uam_hide_empty_categories_yes">
1162 - <input type="radio" id="uam_hide_empty_categories_yes" name="uam_hide_empty_categories" value="true" <?php if ($uamOptions['hide_empty_categories'] == "true") { echo 'checked="checked"'; }?> />
1163 - <?php echo TXT_YES; ?>
1164 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1165 - <label for="uam_hide_empty_categories_no">
1166 - <input type="radio" id="uam_hide_empty_categories_no" name="uam_hide_empty_categories" value="false" <?php if ($uamOptions['hide_empty_categories'] == "false") { echo 'checked="checked"'; }?>/>
1167 - <?php echo TXT_NO; ?>
1168 - </label>
1169 - <br />
1170 - <?php echo TXT_HIDE_EMPTY_CATEGORIES_DESC; ?>
1171 - </td>
1172 - </tr>
1173 - <tr>
1174 - <th>
1175 - <?php echo TXT_REDIRECT; ?>
1176 - </th>
1177 - <td>
1178 - <label for="uam_redirect_no">
1179 - <input type="radio" id="uam_redirect_no" name="uam_redirect" value="false" <?php if ($uamOptions['redirect'] == "false") { echo 'checked="checked"'; }?> />
1180 - <?php echo TXT_NO; ?>
1181 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1182 - <label for="uam_redirect_blog">
1183 - <input type="radio" id="uam_redirect_blog" name="uam_redirect" value="blog" <?php if ($uamOptions['redirect'] == "blog") { echo 'checked="checked"'; }?> />
1184 - <?php echo TXT_REDIRECT_TO_BOLG; ?>
1185 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1186 - <label for="uam_redirect_custom_page">
1187 - <input type="radio" id="uam_redirect_custom_p" name="uam_redirect" value="custom_page" <?php if ($uamOptions['redirect'] == "custom_page") { echo 'checked="checked"'; }?>/>
1188 - <?php echo TXT_REDIRECT_TO_PAGE; ?>
1189 - </label><select name="uam_redirect_custom_page">
1190 - <?php
1191 - $pages = get_pages('sort_column=menu_order');
1192 -
1193 - if(isset($pages))
1194 - {
1195 - foreach($pages as $page)
1196 - {
1197 - echo '<option value="'.$page->ID;
1198 -
1199 - if($uamOptions['redirect_custom_page'] == $page->ID)
1200 - echo ' selected = "selected"';
1201 -
1202 - echo '>'.$page->post_title.'</option>';
1203 - }
1204 - }
1205 - ?></select>&nbsp;&nbsp;&nbsp;&nbsp;
1206 - <label for="uam_redirect_custom_url">
1207 - <input type="radio" id="uam_redirect_custom_u" name="uam_redirect" value="custom_url" <?php if ($uamOptions['redirect'] == "custom_url") { echo 'checked="checked"'; }?>/>
1208 - <?php echo TXT_REDIRECT_TO_URL; ?>
1209 - </label><input name="uam_redirect_custom_url" value="<?php echo $uamOptions['redirect_custom_url']; ?>" />
1210 - <br />
1211 - <?php echo TXT_REDIRECT_DESC; ?>
1212 - </td>
1213 - </tr>
1214 - <tr>
1215 - <th>
1216 - <?php echo TXT_LOCK_RECURSIVE; ?>
1217 - </th>
1218 - <td>
1219 - <label for="uam_lock_recursive_yes">
1220 - <input type="radio" id="uam_lock_recursive_yes" name="uam_lock_recursive" value="true" <?php if ($uamOptions['lock_recursive'] == "true") { echo 'checked="checked"'; }?> />
1221 - <?php echo TXT_YES; ?>
1222 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1223 - <label for="uam_lock_recursive_no">
1224 - <input type="radio" id="uam_lock_recursive_no" name="uam_lock_recursive" value="false" <?php if ($uamOptions['lock_recursive'] == "false") { echo 'checked="checked"'; }?>/>
1225 - <?php echo TXT_NO; ?>
1226 - </label>
1227 - <br />
1228 - <?php echo TXT_LOCK_RECURSIVE_DESC; ?>
1229 - </td>
1230 - </tr>
1231 - <tr>
1232 - <th>
1233 - <?php echo TXT_BLOG_ADMIN_HINT; ?>
1234 - </th>
1235 - <td>
1236 - <label for="uam_blog_admin_hint_yes">
1237 - <input type="radio" id="uam_blog_admin_hint_yes" name="uam_blog_admin_hint" value="true" <?php if ($uamOptions['blog_admin_hint'] == "true") { echo 'checked="checked"'; }?> />
1238 - <?php echo TXT_YES; ?>
1239 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1240 - <label for="uam_blog_admin_hint_no">
1241 - <input type="radio" id="uam_blog_admin_hint_no" name="uam_blog_admin_hint" value="false" <?php if ($uamOptions['blog_admin_hint'] == "false") { echo 'checked="checked"'; }?>/>
1242 - <?php echo TXT_NO; ?>
1243 - </label>
1244 - <br />
1245 - <?php echo TXT_BLOG_ADMIN_HINT_DESC; ?>
1246 - </td>
1247 - </tr>
1248 - <tr>
1249 - <th>
1250 - <?php echo TXT_BLOG_ADMIN_HINT_TEXT; ?>
1251 - </th>
1252 - <td>
1253 - <input name="uam_blog_admin_hint_text" value="<?php echo $uamOptions['blog_admin_hint_text']; ?>" />
1254 - <br />
1255 - <?php echo TXT_BLOG_ADMIN_HINT_TEXT_DESC; ?>
1256 - </td>
1257 - </tr>
1258 - <tr>
1259 - <th>
1260 - <?php echo TXT_FULL_ACCESS_LEVEL; ?>
1261 - </th>
1262 - <td>
1263 - <input name="uam_full_access_level" value="<?php echo $uamOptions['full_access_level']; ?>" />
1264 - <br />
1265 - <?php echo TXT_FULL_ACCESS_LEVEL_DESC; ?>
1266 - </td>
1267 - </tr>
1268 - <?php
1269 - global $wp_version;
1270 -
1271 - if($wp_version < 2.8)
1272 - {
1273 - ?>
1274 - <tr>
1275 - <th>
1276 - <?php echo TXT_CORE_MOD; ?>
1277 - </th>
1278 - <td>
1279 - <label for="uam_core_mod_yes">
1280 - <input type="radio" id="uam_core_mod_yes" name="uam_core_mod" value="true" <?php if ($uamOptions['core_mod'] == "true") { echo 'checked="checked"'; }?> />
1281 - <?php echo TXT_YES; ?>
1282 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1283 - <label for="uam_core_mod_no">
1284 - <input type="radio" id="uam_core_mod_no" name="uam_core_mod" value="false" <?php if ($uamOptions['core_mod'] == "false") { echo 'checked="checked"'; }?>/>
1285 - <?php echo TXT_NO; ?>
1286 - </label>
1287 - <br />
1288 - <?php echo TXT_CORE_MOD_DESC; ?>
1289 - </td>
1290 - </tr>
1291 - <?php
1292 - }
1293 - ?>
1294 - </tbody>
1295 - </table>
1296 - <div class="submit">
1297 - <input type="submit" name="update_uam_settings" value="<?php echo TXT_UPDATE_SETTING; ?>" />
1298 - </div>
1299 - </form>
1300 - </div>
1301 - <?php
1302 - }
1303 - elseif($action == 'edit_group' && isset($_GET['id']))
1304 - {
1305 - $group_id = $_GET['id'];
1306 - $accessgroup = $wpdb->get_row(" SELECT *
1307 - FROM ".DB_ACCESSGROUP."
1308 - WHERE ID = ".$group_id."
1309 - LIMIT 1", ARRAY_A);
1310 - ?>
1311 - <div class="wrap">
1312 - <?php $this->get_print_edit_group($group_id); ?>
1313 - </div>
1314 - <?php
1315 - }
1316 - elseif($cur_admin_page == 'uam_usergroup')
1317 - {
1318 - $accessgroups = $wpdb->get_results("SELECT *
1319 - FROM ".DB_ACCESSGROUP."
1320 - ORDER BY ID", ARRAY_A);
1321 - ?>
1322 - <div class=wrap>
1323 - <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
1324 - <input type="hidden" value="delgroup" name="action"/>
1325 - <h2><?php echo TXT_MANAGE_GROUP; ?></h2>
1326 - <div class="tablenav">
1327 - <div class="alignleft">
1328 - <input type="submit" class="button-secondary delete" name="deleteit" value="<?php echo TXT_DELETE; ?>"/>
1329 - <input type="hidden" id="TXT_COLLAPS_ALL" name="deleteit" value="<?php echo TXT_COLLAPS_ALL; ?>"/>
1330 - <input type="hidden" id="TXT_EXPAND_ALL" name="deleteit" value="<?php echo TXT_EXPAND_ALL; ?>"/>
1331 - </div>
1332 - <br class="clear"/>
1333 - </div>
1334 - <br class="clear"/>
1335 - <table class="widefat">
1336 - <thead>
1337 - <tr class="thead">
1338 - <th scope="col"></th>
1339 - <th scope="col"><?php echo TXT_NAME; ?></th>
1340 - <th scope="col"><?php echo TXT_DESCRIPTION; ?></th>
1341 - <th scope="col"><?php echo TXT_READ_ACCESS; ?></th>
1342 - <th scope="col"><?php echo TXT_WRITE_ACCESS; ?></th>
1343 - <th scope="col"><?php echo TXT_IP_RANGE; ?></th>
1344 - <th scope="col"><?php echo TXT_POSTS; ?></th>
1345 - <th scope="col"><?php echo TXT_PAGES; ?></th>
1346 - <th scope="col"><?php echo TXT_FILES; ?></th>
1347 - <th scope="col"><?php echo TXT_CATEGORY; ?></th>
1348 - <th scope="col"><?php echo TXT_USERS; ?></th>
1349 - <th></th>
1350 - </tr>
1351 - </thead>
1352 - <tbody>
1353 - <?php
1354 - if(isset($accessgroups))
1355 - {
1356 - foreach($accessgroups as $accessgroup)
1357 - {
1358 - $group_info = $this->get_usergroup_info($accessgroup['ID']);
1359 - ?>
1360 - <tr class="alternate" id="group-<?php echo $accessgroup['ID']; ?>">
1361 - <th class="check-column" scope="row"><input type="checkbox" value="<?php echo $accessgroup['ID']; ?>" name="delete[]"/></th>
1362 - <td><strong><a href="?page=<?php echo $cur_admin_page; ?>&action=edit_group&id=<?php echo $accessgroup['ID']; ?>"><?php echo $accessgroup['groupname']; ?></a></strong></td>
1363 - <td><?php echo $accessgroup['groupdesc']; ?></td>
1364 - <td><?php if($accessgroup['read_access'] == "all"){ echo TXT_ALL;}elseif($accessgroup['read_access'] == "group"){ echo TXT_ONLY_GROUP_USERS;} ?></td>
1365 - <td><?php if($accessgroup['write_access'] == "all"){ echo TXT_ALL;}elseif($accessgroup['write_access'] == "group"){ echo TXT_ONLY_GROUP_USERS;} ?></td>
1366 - <td><?php if(isset($accessgroup['ip_range'])){ echo $accessgroup['ip_range']; }else{ echo TXT_NONE; }?></td>
1367 - <td>
1368 - <?php
1369 - if(isset($group_info->posts))
1370 - {
1371 - $expandcontent = null;
1372 - foreach($group_info->posts as $post)
1373 - {
1374 - $expandcontent .= "<li>".$post->post_title."</li>";
1375 - }
1376 - echo "<a class='uam_info_link'>".count($group_info->posts)." ".TXT_POSTS."</a>";;
1377 - echo "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul>";
1378 - }
1379 - else
1380 - {
1381 - echo TXT_NONE;
1382 - }
1383 - ?>
1384 - </td>
1385 - <td>
1386 - <?php
1387 - if(isset($group_info->pages))
1388 - {
1389 - $expandcontent = null;
1390 - foreach($group_info->pages as $page)
1391 - {
1392 - $expandcontent .= "<li>".$page->post_title."</li>";
1393 - }
1394 - echo "<a class='uam_info_link'>".count($group_info->pages)." ".TXT_PAGES."</a>";
1395 - echo "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul>";
1396 - }
1397 - else
1398 - {
1399 - echo TXT_NONE;
1400 - }
1401 - ?>
1402 - </td>
1403 - <td>
1404 - <?php
1405 - if(isset($group_info->files))
1406 - {
1407 - $expandcontent = null;
1408 - foreach($group_info->files as $file)
1409 - {
1410 - $expandcontent .= "<li>".$file->post_title."</li>";
1411 - }
1412 - echo "<a class='uam_info_link'>".count($group_info->files)." ".TXT_FILES."</a>";
1413 - echo "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul>";
1414 - }
1415 - else
1416 - {
1417 - echo TXT_NONE;
1418 - }
1419 - ?>
1420 - </td>
1421 - <td>
1422 - <?php
1423 - if(isset($group_info->categories))
1424 - {
1425 - $expandcontent = null;
1426 - foreach($group_info->categories as $categorie)
1427 - {
1428 - $expandcontent .= "<li>".$categorie->cat_name."</li>";
1429 - }
1430 - echo "<a class='uam_info_link'>".count($group_info->categories)." ".TXT_CATEGORY."</a>";
1431 - echo "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul>";
1432 - }
1433 - else
1434 - {
1435 - echo TXT_NONE;
1436 - }
1437 - ?>
1438 - </td>
1439 - <td>
1440 - <?php
1441 - if(isset($group_info->users))
1442 - {
1443 - $expandcontent = null;
1444 - foreach($group_info->users as $user)
1445 - {
1446 - $expandcontent .= "<li>".$user->nickname."</li>";
1447 - }
1448 - echo "<a class='uam_info_link'>".count($group_info->users)." ".TXT_USERS."</a>";
1449 - echo "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul>";
1450 - }
1451 - else
1452 - {
1453 - echo TXT_NONE;
1454 - }
1455 - ?>
1456 - </td>
1457 - <td>
1458 - <a class="uam_info_link_all" href="#"><?php echo TXT_EXPAND_ALL; ?></a>
1459 - </td>
1460 - </tr>
1461 - <?php
1462 - }
1463 - }
1464 - ?>
1465 - </tbody>
1466 - </table>
1467 - </form>
1468 - </div>
1469 - <div class="wrap">
1470 - <h2><?php echo TXT_ADD_GROUP; ?></h2>
1471 - <div id="ajax-response"/>
1472 - <?php $this->get_print_edit_group(); ?>
1473 - </div>
1474 - <?php
1475 - }
1476 - elseif($cur_admin_page == 'uam_setup')
1477 - {
1478 - ?>
1479 - <div class=wrap>
1480 - <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
1481 - <input type="hidden" value="reset_uam" name="action"/>
1482 - <h2><?php echo TXT_SETUP; ?></h2>
1483 - <table class="form-table">
1484 - <tbody>
1485 - <tr valign="top">
1486 - <th scope="row">
1487 - <?php echo TXT_RESET_UAM; ?>
1488 - </th>
1489 - <td>
1490 - <label for="uam_reset_yes">
1491 - <input type="radio" id="uam_reset_yes" class="uam_reset_yes" name="uam_reset" value="true" />
1492 - <?php echo TXT_YES; ?>
1493 - </label>&nbsp;&nbsp;&nbsp;&nbsp;
1494 - <label for="uam_reset_no">
1495 - <input type="radio" id="uam_reset_no" class="uam_reset_no" name="uam_reset" value="false" checked="checked" />
1496 - <?php echo TXT_NO; ?>
1497 - </label>&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="uam_reset_submit" value="<?php echo TXT_RESET; ?>" />
1498 - <br />
1499 - <p style="color:red; font-size: 12px; font-weight: bold;"><?php echo TXT_RESET_UAM_DESC; ?></p>
1500 - </td>
1501 - </tr>
1502 - </tbody>
1503 - </table>
1504 - </form>
1505 - </div>
1506 - <?php
1507 - }
1508 - }//End function printAdminPage()
1509 -
1510 - function get_print_edit_group($group_id = null)
1511 - {
1512 - global $wpdb;
1513 - $uamOptions = $this->getAdminOptions();
1514 -
1515 - if(isset($group_id))
1516 - $group_info = $this->get_usergroup_info($group_id);
1517 - ?>
1518 - <form method="post" action="<?php echo reset(explode("?", $_SERVER["REQUEST_URI"]))."?page=".$_GET['page']; ?>">
1519 - <input type="hidden" id="TXT_COLLAPS" name="deleteit" value="<?php echo TXT_COLLAPS; ?>"/>
1520 - <input type="hidden" id="TXT_EXPAND" name="deleteit" value="<?php echo TXT_EXPAND; ?>"/>
1521 - <?php
1522 - if(isset($group_id))
1523 - {
1524 - ?>
1525 - <input type="hidden" value="update_group" name="action"/>
1526 - <input type="hidden" value="<?php echo $group_id; ?>" name="access_group_id"/>
1527 - <?php
1528 - }
1529 - else
1530 - {
1531 - ?>
1532 - <input type="hidden" value="addgroup" name="action"/>
1533 - <?php
1534 - }
1535 - ?>
1536 - <input type="hidden" value="<?php echo $uamOptions['lock_recursive']; ?>" name="uam_lock_recursive" id="uam_set_lock_recursive"/>
1537 - <table class="form-table">
1538 - <tbody>
1539 - <tr class="form-field form-required">
1540 - <th valign="top" scope="row"><?php echo TXT_GROUP_NAME; ?></th>
1541 - <td><input type="text" size="40" value="<?php if(isset($group_id)){echo $group_info->group["groupname"]; }?>" id="access_group_name" name="access_group_name"/><br/>
1542 - <?php echo TXT_GROUP_NAME_DESC; ?></td>
1543 - </tr>
1544 - <tr class="form-field form-required">
1545 - <th valign="top" scope="row"><?php echo TXT_GROUP_DESC; ?></th>
1546 - <td><input type="text" size="40" value="<?php if(isset($group_id)){ echo $group_info->group["groupdesc"]; }?>" id="access_group_description" name="access_group_description"/><br/>
1547 - <?php echo TXT_GROUP_DESC_DESC; ?></td>
1548 - </tr>
1549 - <tr class="form-field form-required">
1550 - <th valign="top" scope="row"><?php echo TXT_GROUP_IP_RANGE; ?></th>
1551 - <td><input type="text" size="40" value="<?php if(isset($group_id)){ echo $group_info->group["ip_range"]; }?>" id="ip_range" name="ip_range"/><br/>
1552 - <?php echo TXT_GROUP_IP_RANGE_DESC; ?></td>
1553 - </tr>
1554 - <tr class="form-field form-required">
1555 - <th valign="top" scope="row"><?php echo TXT_GROUP_READ_ACCESS; ?></th>
1556 - <td><select name="read_access">
1557 - <option value="group" <?php if(isset($group_id)){ if($group_info->group["read_access"] == "group"){ echo 'selected="selected"'; }} ?> ><?php echo TXT_ONLY_GROUP_USERS ?></option>
1558 - <option value="all" <?php if(isset($group_id)){ if($group_info->group["read_access"] == "all"){ echo 'selected="selected"'; }} ?> ><?php echo TXT_ALL ?></option>
1559 - </select><br />
1560 - <?php echo TXT_GROUP_READ_ACCESS_DESC; ?></td>
1561 - </tr>
1562 - <tr class="form-field form-required">
1563 - <th valign="top" scope="row"><?php echo TXT_GROUP_WRITE_ACCESS; ?></th>
1564 - <td><select name="write_access">
1565 - <option value="group" <?php if(isset($group_id)){ if($group_info->group["write_access"] == "group"){ echo 'selected="selected"'; }} ?> ><?php echo TXT_ONLY_GROUP_USERS ?></option>
1566 - <option value="all" <?php if(isset($group_id)){ if($group_info->group["write_access"] == "all"){ echo 'selected="selected"'; }} ?> ><?php echo TXT_ALL ?></option>
1567 - </select><br />
1568 - <?php echo TXT_GROUP_WRITE_ACCESS_DESC; ?></td>
1569 - </tr>
1570 - <tr>
1571 - <th valign="top" scope="row"><?php echo TXT_GROUP_ROLE; ?></th>
1572 - <td>
1573 - <ul class='uam_role'>
1574 - <?php
1575 - global $wp_roles;
1576 -
1577 - foreach($wp_roles->role_names as $role => $name)
1578 - {
1579 - if($role != "administrator")
1580 - {
1581 - ?>
1582 - <li class="selectit">
1583 - <input id="role-<?php echo $role; ?>" type="checkbox" <?php if(isset($group_info->posts[$role])){ echo 'checked="checked"'; } ?> value="<?php echo $role; ?>" name="roles[]"/>
1584 - <label for="role-<?php echo $role; ?>"><?php echo $role ?></label>
1585 - </li>
1586 - <?php
1587 - }
1588 - }
1589 - ?>
1590 - </ul>
1591 - </td>
1592 - </tr>
1593 - <tr>
1594 - <?php
1595 - $args = array('numberposts' => -1);
1596 - $posts = get_posts($args);
1597 - ?>
1598 - <th valign="top" scope="row"><?php echo TXT_POSTS; if(count($posts) > 0){ echo " <label>(<a class='selectit uam_group_stuff_link'>".TXT_EXPAND."</a>)</label>"; }?></th>
1599 - <td>
1600 - <?php
1601 - if(isset($group_info->posts))
1602 - $posts_in_group = count($group_info->posts);
1603 - else
1604 - $posts_in_group = 0;
1605 -
1606 - echo "<strong>".sprintf(TXT_CONTAIN_POSTS, "<span class='uam_element_count'>".$posts_in_group."</span>", count($posts))."</strong>";
1607 -
1608 - if(isset($posts))
1609 - {
1610 - echo "<ul class='uam_group_stuff'>";
1611 - foreach($posts as $post)
1612 - {
1613 - $cur_categories = get_the_category($post->ID);
1614 - ?>
1615 - <li class="selectit <?php foreach($cur_categories as $cur_cat){ echo "cat-".$cur_cat->term_id." "; }?>">
1616 - <input id="post-<?php echo $post->ID; ?>" type="checkbox" value="<?php echo $post->ID;?>" <?php if(isset($group_info->posts[$post->ID])){ echo 'checked="checked"'; } ?> name="post[]"/>
1617 - <label for="post-<?php echo $post->ID; ?>"><strong><?php echo $post->post_title; ?></strong> - <?php echo $post->post_date; ?></label>
1618 - <?php
1619 -
1620 - ?>
1621 - </li>
1622 - <?php
1623 - }
1624 - echo "</ul>";
1625 - }
1626 - ?>
1627 - </td>
1628 - </tr>
1629 - <tr>
1630 - <?php
1631 - $pages = get_pages('sort_column=menu_order');
1632 - ?>
1633 - <th valign="top" scope="row"><?php echo TXT_PAGES; if(count($pages) > 0){ echo " <label>(<a class='selectit uam_group_stuff_link'>".TXT_EXPAND."</a>)</label>"; } ?></th>
1634 - <td>
1635 - <?php
1636 - if(isset($group_info->pages))
1637 - $pages_in_group = count($group_info->pages);
1638 - else
1639 - $pages_in_group = 0;
1640 -
1641 - echo "<strong>".sprintf(TXT_CONTAIN_PAGES, "<span class='uam_element_count'>".$pages_in_group."</span>", count($pages))."</strong>";
1642 -
1643 - if(isset($pages))
1644 - {
1645 - echo "<ul class='uam_group_stuff'>";
1646 - $deepness = 0;
1647 -
1648 - foreach($pages as $page)
1649 - {
1650 - $old_deepness = $deepness;
1651 - $deepness = 0;
1652 -
1653 - if($page->post_parent != 0)
1654 - {
1655 - $cur_page = $page;
1656 - $cur_id = $page->ID;
1657 - while($cur_page->post_parent != 0)
1658 - {
1659 - $deepness++;
1660 - $cur_parent_id = $cur_page->post_parent;
1661 - $cur_page = & get_post($cur_parent_id);
1662 - }
1663 - }
1664 -
1665 - if($old_deepness > $deepness)
1666 - {
1667 - $count = abs($old_deepness - $deepness);
1668 - for($i = 0; $i < $count; $i++)
1669 - echo "</ul>";
1670 - }
1671 - elseif($old_deepness < $deepness)
1672 - {
1673 - $count = abs($old_deepness - $deepness);
1674 - for($i = 0; $i < $count; $i++)
1675 - echo "<ul class='uam_group_stuff_child'>";
1676 - }
1677 -
1678 - ?>
1679 - <li class="selectit">
1680 - <input id="post-<?php echo $page->ID; ?>" type="checkbox" value="<?php echo $page->ID;?>" <?php if(isset($group_info->pages[$page->ID])){ echo 'checked="checked"'; } ?> name="page[]"/>
1681 - <label for="post-<?php echo $page->ID; ?>"><strong><?php echo $page->post_title; ?></strong> - <?php echo $page->post_date; ?></label>
1682 - </li>
1683 - <?php
1684 - }
1685 - echo "</ul>";
1686 - }
1687 - ?>
1688 - </td>
1689 - </tr>
1690 - <tr>
1691 - <?php
1692 - $args = array( 'numberposts' => -1,
1693 - 'post_type' => 'attachment');
1694 - $files = get_posts($args);
1695 - ?>
1696 - <th valign="top" scope="row"><?php echo TXT_FILES; if(count($files) > 0){ echo " <label>(<a class='selectit uam_group_stuff_link'>".TXT_EXPAND."</a>)</label>"; }?></th>
1697 - <td>
1698 - <?php
1699 - if(isset($group_info->files))
1700 - $files_in_group = count($group_info->files);
1701 - else
1702 - $files_in_group = 0;
1703 -
1704 - echo "<strong>".sprintf(TXT_CONTAIN_FILES, "<span class='uam_element_count'>".$files_in_group."</span>", count($files))."</strong>";
1705 -
1706 - if(isset($files))
1707 - {
1708 - echo "<ul class='uam_group_stuff'>";
1709 - foreach($files as $file)
1710 - {
1711 - $cur_categories = get_the_category($file->ID);
1712 - ?>
1713 - <li class="selectit <?php foreach($cur_categories as $cur_cat){ echo "cat-".$cur_cat->term_id." "; } echo "parent_post-".$file->post_parent." ";?>">
1714 - <input id="post-<?php echo $file->ID; ?>" type="checkbox" value="<?php echo $file->ID;?>" <?php if(isset($group_info->files[$file->ID])){ echo 'checked="checked"'; } ?> name="file[]"/>
1715 - <label for="post-<?php echo $file->ID; ?>"><strong><?php echo $file->post_title; ?></strong> - <?php echo $file->post_date; ?></label>
1716 - </li>
1717 - <?php
1718 - }
1719 - echo "</ul>";
1720 - }
1721 - ?>
1722 - </td>
1723 - </tr>
1724 - <tr>
1725 - <?php
1726 - $args = array('hide_empty' => 0);
1727 - $categories = get_categories($args);
1728 - ?>
1729 - <th valign="top" scope="row"><?php echo TXT_CATEGORY; if(count($categories) > 0){ echo " <label>(<a class='selectit uam_group_stuff_link'>".TXT_EXPAND."</a>)</label>"; } ?></th>
1730 - <td>
1731 - <?php
1732 - if(isset($group_info->categories))
1733 - $categories_in_group = count($group_info->categories);
1734 - else
1735 - $categories_in_group = 0;
1736 -
1737 - echo "<strong>".sprintf(TXT_CONTAIN_CATEGORIES, "<span class='uam_element_count'>".$categories_in_group."</span>", count($categories))."</strong>";
1738 -
1739 - function print_elements($group_id, $group_info = null, $category = 0, $deepness = 0)
1740 - {
1741 - global $wpdb;
1742 -
1743 - $args = array('child_of' => $category);
1744 - $categories = get_categories($args);
1745 -
1746 - if(isset($categories))
1747 - {
1748 - $first_round = true;
1749 - foreach($categories as $cat)
1750 - {
1751 -
1752 - if($cat->parent == $category)
1753 - {
1754 - if($first_round == true)
1755 - {
1756 - if($category == 0)
1757 - echo "<ul class='uam_group_stuff uam_category'>";
1758 - else
1759 - echo "<ul class='uam_group_stuff_child uam_category'>";
1760 -
1761 - $first_round = false;
1762 - }
1763 - ?>
1764 - <li class="selectit">
1765 - <input id="category-<?php echo $cat->term_id; ?>" type="checkbox" name="category[]" value="<?php echo $cat->term_id;?>" <?php if(isset($group_info[$cat->term_id])){ echo 'checked="checked"'; } ?> />
1766 - <label for="category-<?php echo $cat->term_id; ?>"><strong><?php echo $cat->cat_name; ?></strong></label>
1767 - </li>
1768 - <?php
1769 - print_elements($group_id, $group_info, $cat->term_id, $deepness++);
1770 - }
1771 - }
1772 - if($first_round == false)
1773 - {
1774 - echo "</ul>";
1775 - }
1776 - }
1777 - }
1778 -
1779 - $callFkt = "print_elements";
1780 -
1781 - if(isset($group_info->categories))
1782 - echo $callFkt($group_id, $group_info->categories);
1783 - else
1784 - echo $callFkt($group_id);
1785 - ?>
1786 - </td>
1787 - </tr>
1788 - <tr>
1789 - <?php
1790 - $users = $wpdb->get_results(" SELECT ID
1791 - FROM $wpdb->users
1792 - ORDER BY ID", ARRAY_A);
1793 - ?>
1794 - <th valign="top" scope="row"><?php echo TXT_USERS; if(count($users) > 0){ echo " <label>(<a class='selectit uam_group_stuff_link'>".TXT_EXPAND."</a>)</label>"; } ?></th>
1795 - <td>
1796 - <?php
1797 - if(isset($group_info))
1798 - $users_in_group = count($group_info->users);
1799 - else
1800 - $users_in_group = 0;
1801 -
1802 - echo "<strong>".sprintf(TXT_CONTAIN_USERS, "<span class='uam_element_count'>".$users_in_group."</span>", count($users))."</strong>";
1803 -
1804 - if(isset($users))
1805 - {
1806 - echo "<ul class='uam_group_stuff'>";
1807 - foreach($users as $user)
1808 - {
1809 - $cur_user = get_userdata($user['ID']);
1810 - $user_capabilities = array_keys($cur_user->{$wpdb->prefix."capabilities"})
1811 - ?>
1812 - <li class="selectit <?php foreach($user_capabilities as $user_capability){ echo "usercap_".$user_capability." "; } ?>">
1813 - <?php
1814 - if($cur_user->user_level < $uamOptions['full_access_level'])
1815 - {
1816 - ?>
1817 - <input id="user-<?php echo $cur_user->ID; ?>" type="checkbox" value="<?php echo $cur_user->ID; ?>" <?php if(isset($group_info->users[$cur_user->ID])){ echo 'checked="checked"'; } ?> name="user[]"/>
1818 - <label for="user-<?php echo $cur_user->ID; ?>"><strong><?php echo $cur_user->nickname; ?></strong> - <?php echo $cur_user->user_firstname." ".$cur_user->user_lastname; ?>
1819 - <?php
1820 - }
1821 - else
1822 - {
1823 - ?>
1824 - <input id="user-<?php echo $cur_user->ID; ?>" type="checkbox" value="<?php echo $cur_user->ID; ?>" checked="checked" disabled="disabled" name="user[]"/>
1825 - <label for="user-<?php echo $cur_user->ID; ?>"><strong><?php echo $cur_user->nickname; ?></strong> - <?php echo $cur_user->user_firstname." ".$cur_user->user_lastname; ?>
1826 - <?php
1827 - echo "(".TXT_IS_ADMIN.")";
1828 - }
1829 - ?>
1830 -
1831 - </li>
1832 - <?php
1833 - }
1834 - echo "</ul>";
1835 - }
1836 - ?>
1837 - </td>
1838 - </tr>
1839 - </tbody>
1840 - </table>
1841 - <p class="submit"><input type="submit" value="<?php if(isset($group_id)) { echo TXT_UPDATE_GROUP; }else{ echo TXT_ADD_GROUP;} ?>" name="submit" class="button"/></p>
1842 - </form>
1843 - <?php
1844 - }
1845 -
1846 - function get_usergroups_for_post($ID)
1847 - {
1848 - global $wpdb;
1849 -
1850 - if(isset($this->postUserGroup[$ID]))
1851 - return $this->postUserGroup[$ID];
1852 -
1853 - $access = $this->get_access($ID);
1854 -
1855 - $post_usergroups = array();
1856 -
1857 - if(isset($access->restricted_by_posts) || isset($access->restricted_by_categories))
1858 - {
1859 - if(isset($access->restricted_by_posts))
1860 - {
1861 - foreach($access->restricted_by_posts as $cur_id)
1862 - {
1863 - $usergroups = $wpdb->get_results(" SELECT ag.ID, ag.groupname
1864 - FROM ".DB_ACCESSGROUP." ag, ".DB_ACCESSGROUP_TO_POST." agtp
1865 - WHERE agtp.post_id = ".$cur_id."
1866 - AND ag.ID = agtp.group_id
1867 - GROUP BY ag.groupname", ARRAY_A);
1868 -
1869 - if(isset($usergroups))
1870 - {
1871 - foreach($usergroups as $usergroup)
1872 - {
1873 - $cur_usergroup = null;
1874 -
1875 - if(isset($post_usergroups[$usergroup['ID']]))
1876 - $cur_usergroup = $post_usergroups[$usergroup['ID']];
1877 -
1878 - $cur_usergroup->ID = $usergroup['ID'];
1879 - $cur_usergroup->name = $usergroup['groupname'];
1880 -
1881 - if($cur_id != $ID)
1882 - {
1883 - if(isset($cur_usergroup->posts))
1884 - $posts = $cur_usergroup->posts;
1885 -
1886 - $lock_post = & get_post($cur_id);
1887 - $posts[$lock_post->ID] = $lock_post->ID;
1888 - $cur_usergroup->posts = $posts;
1889 - }
1890 - else
1891 - {
1892 - $cur_usergroup->itself = true;
1893 - }
1894 -
1895 - $post_usergroups[$usergroup['ID']] = $cur_usergroup;
1896 - }
1897 - }
1898 - }
1899 - }
1900 -
1901 - if(isset($access->restricted_by_categories))
1902 - {
1903 - foreach($access->restricted_by_categories as $cur_id)
1904 - {
1905 - $usergroups = $wpdb->get_results(" SELECT ag.ID, ag.groupname
1906 - FROM ".DB_ACCESSGROUP." ag, ".DB_ACCESSGROUP_TO_CATEGORY." agtc
1907 - WHERE agtc.category_id = ".$cur_id."
1908 - AND ag.ID = agtc.group_id
1909 - GROUP BY ag.groupname", ARRAY_A);
1910 -
1911 - if(isset($usergroups))
1912 - {
1913 - foreach($usergroups as $usergroup)
1914 - {
1915 - $cur_usergroup = null;
1916 -
1917 - if(isset($post_usergroups[$usergroup['ID']]))
1918 - $cur_usergroup = $post_usergroups[$usergroup['ID']];
1919 -
1920 - $cur_usergroup->ID = $usergroup['ID'];
1921 - $cur_usergroup->name = $usergroup['groupname'];
1922 -
1923 - if(isset($cur_usergroup->categorie))
1924 - $categories = $cur_usergroup->categories;
1925 -
1926 - $lock_cat = & get_category($cur_id);
1927 - $categories[$lock_cat->term_id] = $lock_cat->term_id;
1928 - $cur_usergroup->categories = $categories;
1929 -
1930 - $post_usergroups[$usergroup['ID']] = $cur_usergroup;
1931 - }
1932 - }
1933 -
1934 -
1935 - }
1936 - }
1937 - }
1938 -
1939 - $this->postUserGroup[$ID] = $post_usergroups;
1940 -
1941 - return $post_usergroups;
1942 - }
1943 -
1944 - function get_usergroup_info($groupid)
1945 - {
1946 - global $wpdb;
1947 -
1948 - $uamOptions = $this->getAdminOptions();
1949 -
1950 - $cur_group = $wpdb->get_results(" SELECT *
1951 - FROM ".DB_ACCESSGROUP."
1952 - WHERE ID = ".$groupid, ARRAY_A);
1953 -
1954 - $info->group = $cur_group[0];
1955 -
1956 - $db_users = $wpdb->get_results(" SELECT *
1957 - FROM ".DB_ACCESSGROUP_TO_USER."
1958 - WHERE group_id = ".$groupid."
1959 - ORDER BY user_id", ARRAY_A);
1960 -
1961 - $db_categories = $wpdb->get_results(" SELECT *
1962 - FROM ".DB_ACCESSGROUP_TO_CATEGORY."
1963 - WHERE group_id = ".$groupid."
1964 - ORDER BY category_id", ARRAY_A);
1965 -
1966 - $db_roles = $wpdb->get_results(" SELECT *
1967 - FROM ".DB_ACCESSGROUP_TO_ROLE."
1968 - WHERE group_id = ".$groupid, ARRAY_A);
1969 -
1970 - $wp_users = $wpdb->get_results(" SELECT ID, user_nicename
1971 - FROM $wpdb->users
1972 - ORDER BY user_nicename", ARRAY_A);
1973 -
1974 -
1975 - $args = array( 'numberposts' => -1,
1976 - 'post_type' => 'any');
1977 -
1978 - $posts = get_posts($args);
1979 -
1980 - if(isset($posts))
1981 - {
1982 - foreach($posts as $post)
1983 - {
1984 - $groupinfo = $this->get_usergroups_for_post($post->ID);
1985 -
1986 - if(isset($groupinfo[$groupid]))
1987 - {
1988 - if($post->post_type == 'post')
1989 - {
1990 - $info->posts[$post->ID] = $post;
1991 - }
1992 - elseif($post->post_type == 'page')
1993 - {
1994 - $info->pages[$post->ID] = $post;
1995 - }
1996 - elseif($post->post_type == 'attachment')
1997 - {
1998 - $info->files[$post->ID] = $post;
1999 - }
2000 - }
2001 - }
2002 - }
2003 -
2004 - $args = array( 'numberposts' => -1,
2005 - 'post_type' => 'attachment');
2006 -
2007 - $files = get_posts($args);
2008 -
2009 - if(isset($files))
2010 - {
2011 - foreach($files as $file)
2012 - {
2013 - $groupinfo = $this->get_usergroups_for_post($file->ID);
2014 -
2015 - if(isset($groupinfo[$groupid]))
2016 - $info->files[$file->ID] = $file;
2017 - }
2018 - }
2019 -
2020 - if(isset($db_categories))
2021 - {
2022 - foreach($db_categories as $db_categorie)
2023 - {
2024 - $cur_category = get_category($db_categorie['category_id']);
2025 -
2026 - $info->categories[$db_categorie['category_id']] = $cur_category;
2027 -
2028 - if($uamOptions['lock_recursive'] == 'true')
2029 - {
2030 - $cur_categories = get_categories('child_of='.$db_categorie['category_id']);
2031 - if(isset($cur_categories))
2032 - {
2033 - foreach($cur_categories as $cur_category)
2034 - {
2035 - $cur_category->recursive_lock_by_category[$db_categorie['category_id']] = $db_categorie['category_id'];
2036 - $info->categories[$cur_category->term_id] = $cur_category;
2037 - }
2038 - }
2039 - }
2040 - }
2041 - }
2042 -
2043 - if(isset($db_users))
2044 - {
2045 - $expandcontent = null;
2046 - foreach($db_users as $db_user)
2047 - {
2048 - $info->users[$db_user['user_id']] = get_userdata($db_user['user_id']);
2049 - }
2050 - }
2051 -
2052 - if(isset($db_roles))
2053 - {
2054 - foreach($db_roles as $db_role)
2055 - {
2056 - $info->roles[$db_role['role_name']] = $db_role;
2057 - }
2058 - }
2059 -
2060 - if(isset($wp_users))
2061 - {
2062 - foreach($wp_users as $wp_user)
2063 - {
2064 - $cur_userdata = get_userdata($wp_user['ID']);
2065 -
2066 - if($cur_userdata->user_level >= $uamOptions['full_access_level'])
2067 - {
2068 - $info->users[$wp_user['ID']] = $cur_userdata;
2069 - }
2070 - elseif(isset($db_roles) && $cur_userdata->user_level < $uamOptions['full_access_level'])
2071 - {
2072 - foreach($db_roles as $db_role)
2073 - {
2074 - if(isset($cur_userdata->{$wpdb->prefix."capabilities"}[$db_role['role_name']]))
2075 - {
2076 - $info->users[$wp_user['ID']] = $cur_userdata;
2077 - break;
2078 - }
2079 - }
2080 - }
2081 - }
2082 - }
2083 -
2084 - return $info;
2085 - }
2086 -
2087 - function get_usergroup_info_html($group_id, $style = null)
2088 - {
2089 - $link = '<a class="uam_group_info_link">('.TXT_INFO.')</a>';
2090 -
2091 - $group_info = $this->get_usergroup_info($group_id);
2092 -
2093 - $content = "<ul class='uam_group_info'";
2094 -
2095 - if($style != null)
2096 - $content .= " style='".$style."' ";
2097 -
2098 - $content .= "><li class='uam_group_info_head'>".TXT_GROUP_INFO.":</li>";
2099 -
2100 - $content .= "<li>".TXT_READ_ACCESS.": ";
2101 - if($group_info->group['read_access'] == "all")
2102 - $content .= TXT_ALL;
2103 - elseif($group_info->group['read_access'] == "group")
2104 - $content .= TXT_ONLY_GROUP_USERS;
2105 - $content .= "</li>";
2106 -
2107 - $content .= "<li>".TXT_WRITE_ACCESS.": ";
2108 - if($group_info->group['write_access'] == "all")
2109 - $content .= TXT_ALL;
2110 - elseif($group_info->group['write_access'] == "group")
2111 - $content .= TXT_ONLY_GROUP_USERS;
2112 - $content .= "</li>";
2113 -
2114 - if(isset($group_info->posts))
2115 - {
2116 - $expandcontent = null;
2117 - foreach($group_info->posts as $post)
2118 - {
2119 - $expandcontent .= "<li>".$post->post_title."</li>";
2120 - }
2121 - $content .= "<li><a class='uam_info_link'>".count($group_info->posts)." ".TXT_POSTS."</a>";
2122 - $content .= "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul></li>";
2123 - }
2124 - else
2125 - {
2126 - $content .= "<li>".TXT_NONE." ".TXT_POSTS."</li>";
2127 - }
2128 -
2129 - if(isset($group_info->pages))
2130 - {
2131 - $expandcontent = null;
2132 - foreach($group_info->pages as $page)
2133 - {
2134 - $expandcontent .= "<li>".$page->post_title."</li>";
2135 - }
2136 - $content .= "<li><a class='uam_info_link'>".count($group_info->pages)." ".TXT_PAGES."</a>";
2137 - $content .= "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul></li>";
2138 - }
2139 - else
2140 - {
2141 - $content .= "<li>".TXT_NONE." ".TXT_PAGES."</li>";
2142 - }
2143 -
2144 - if(isset($group_info->categories))
2145 - {
2146 - $expandcontent = null;
2147 - foreach($group_info->categories as $categorie)
2148 - {
2149 - $expandcontent .= "<li>".$categorie->cat_name."</li>";
2150 - }
2151 - $content .= "<li><a class='uam_info_link'>".count($group_info->categories)." ".TXT_CATEGORY."</a>";
2152 - $content .= "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul></li>";
2153 - }
2154 - else
2155 - {
2156 - $content .= "<li>".TXT_NONE." ".TXT_CATEGORY."</li>";
2157 - }
2158 - if(isset($group_info->users))
2159 - {
2160 - $expandcontent = null;
2161 - foreach($group_info->users as $user)
2162 - {
2163 - $expandcontent .= "<li>".$user->nickname."</li>";
2164 - }
2165 - $content .= "<li><a class='uam_info_link'>".count($group_info->users)." ".TXT_USERS."</a>";
2166 - $content .= "<ul class='uam_info_content expand_deactive'>".$expandcontent."</ul></li>";
2167 - }
2168 - else
2169 - {
2170 - $content .= "<li>".TXT_NONE." ".TXT_USERS."</li>";
2171 - }
2172 - $content .= "</ul>";
2173 -
2174 - $result->link = $link;
2175 - $result->content = $content;
2176 -
2177 - return $result;
2178 - }
2179 -
2180 - function get_post_info_html($id)
2181 - {
2182 - $usergroups = $this->get_usergroups_for_post($id);
2183 -
2184 - if(isset($usergroups) && $usergroups != null)
2185 - {
2186 - $output = "<ul>";
2187 - foreach($usergroups as $usergroup)
2188 - {
2189 - $output .= "<li><a class='uma_user_access_group'>".$usergroup->name."</a>";
2190 - $output .= "<ul class='uma_user_access_group_from'>";
2191 -
2192 - if(isset($usergroup->itself))
2193 - $output .= "<li>".TXT_ITSELF."</li>";
2194 -
2195 - if(isset($usergroup->posts))
2196 - {
2197 - foreach($usergroup->posts as $cur_id)
2198 - {
2199 - $cur_post = & get_post($cur_id);
2200 - $output .= "<li>$cur_post->post_title [$cur_post->post_type]</li>";
2201 - }
2202 - }
2203 -
2204 - if(isset($usergroup->categories))
2205 - {
2206 - foreach($usergroup->categories as $cur_id)
2207 - {
2208 - $cur_category = & get_category($cur_id);
2209 - $output .= "<li>$cur_category->name [category]</li>";
2210 - }
2211 - }
2212 -
2213 - $output = substr($output, 0, -2);
2214 -
2215 - $output .= "</ul></li>";
2216 - }
2217 - $output .= "</ul>";
2218 - }
2219 - else
2220 - {
2221 - $output = TXT_FULL_ACCESS;
2222 - }
2223 - return $output;
2224 - }
2225 - function add_post_columns_header($defaults)
2226 - {
2227 - $defaults['uam_access'] = __('Access');
2228 - return $defaults;
2229 - }
2230 -
2231 - function get_post_edit_info_html($id , $style = null)
2232 - {
2233 - global $wpdb;
2234 - $accessgroups = $wpdb->get_results("SELECT *
2235 - FROM ".DB_ACCESSGROUP."
2236 - ORDER BY groupname", ARRAY_A);
2237 -
2238 - $recursive_set = $this->get_usergroups_for_post($id);
2239 -
2240 - if(isset($accessgroups))
2241 - {
2242 - $content = "";
2243 -
2244 - foreach($accessgroups as $accessgroup)
2245 - {
2246 - $checked = $wpdb->get_results(" SELECT *
2247 - FROM ".DB_ACCESSGROUP_TO_POST."
2248 - WHERE post_id = ".$id."
2249 - AND group_id = ".$accessgroup['ID'], ARRAY_A);
2250 -
2251 - $set_recursive = null;
2252 - if(isset($recursive_set[$accessgroup['ID']]))
2253 - $set_recursive = $recursive_set[$accessgroup['ID']];
2254 -
2255 - $content .= '<p><label for="uam_accesssgroup-'.$accessgroup['ID'].'" class="selectit" style="display:inline;" >';
2256 - $content .= '<input type="checkbox" id="uam_accesssgroup-'.$accessgroup['ID'].'"';
2257 - if(isset($checked) || isset($set_recursive->posts) || isset($set_recursive->categories))
2258 - $content .= 'checked="checked"';
2259 - if(isset($set_recursive->posts) || isset($set_recursive->categories))
2260 - $content .= 'disabled=""';
2261 - $content .= 'value="'.$accessgroup['ID'].'" name="accessgroups[]"/>';
2262 - $content .= $accessgroup['groupname'];
2263 - $content .= "</label>";
2264 -
2265 - $group_info_html = $this->get_usergroup_info_html($accessgroup['ID'], $style);
2266 -
2267 - $content .= $group_info_html->link;
2268 -
2269 - if(isset($set_recursive->posts) || isset($set_recursive->categories))
2270 - $content .= '&nbsp;<a class="uam_group_lock_info_link">[LR]</a>';
2271 -
2272 - $content .= $group_info_html->content;
2273 -
2274 - if(isset($set_recursive->posts) || isset($set_recursive->categories))
2275 - {
2276 - $recursive_info = '<ul class="uam_group_lock_info" ';
2277 - if($style != null)
2278 - $recursive_info .= " style='".$style."' ";
2279 - $recursive_info .= '><li class="uam_group_lock_info_head">'.TXT_GROUP_LOCK_INFO.':</li>';
2280 -
2281 - if(isset($set_recursive->posts))
2282 - {
2283 - foreach($set_recursive->posts as $cur_id)
2284 - {
2285 - $cur_post = & get_post($cur_id);
2286 - $recursive_info .= "<li>$cur_post->post_title [$cur_post->post_type]</li>";
2287 - }
2288 - }
2289 -
2290 - if(isset($set_recursive->categories))
2291 - {
2292 - foreach($set_recursive->categories as $cur_id)
2293 - {
2294 - $cur_category = & get_category($cur_id);
2295 - $recursive_info .= "<li>$cur_category->name [".TXT_CATEGORY."]</li>";
2296 - }
2297 - }
2298 - $recursive_info .= "</ul>";
2299 - $content .= $recursive_info;
2300 - }
2301 - $content .= "</p>";
2302 - }
2303 - }
2304 - else
2305 - {
2306 - $content = "<a href='admin.php?page=uam_usergroup'>";
2307 - $content .= TXT_CREATE_GROUP_FIRST;
2308 - $content .= "</a>";
2309 - }
2310 -
2311 - return $content;
2312 - }
2313 - function add_post_column($column_name, $id)
2314 - {
2315 - if( $column_name == 'uam_access' )
2316 - {
2317 - echo $this->get_post_info_html($id);
2318 - }
2319 - }
2320 -
2321 - function edit_post_content($post)
2322 - {
2323 - echo $this->get_post_edit_info_html($post->ID, "padding:0 0 0 36px;");
2324 - }
2325 -
2326 - function save_postdata($post_id)
2327 - {
2328 - global $current_user, $wpdb;
2329 - $cur_userdata = get_userdata($current_user->ID);
2330 - $uamOptions = $this->getAdminOptions();
2331 -
2332 - if($cur_userdata->user_level < $uamOptions['full_access_level'])
2333 - {
2334 - $uamOptions = $this->getAdminOptions();
2335 -
2336 - $cur_categories = wp_get_post_categories($post_id);
2337 -
2338 - $allowded_categories = get_categories();
2339 -
2340 - foreach($cur_categories as $category)
2341 - {
2342 - foreach($allowded_categories as $allowded_category)
2343 - {
2344 - if($allowded_category->term_id == $category)
2345 - {
2346 - $post_categories[] = $allowded_category->term_id;
2347 - break;
2348 - }
2349 - }
2350 - }
2351 -
2352 - if(!isset($post_categories))
2353 - {
2354 - $last_category = array_pop($allowded_categories);
2355 - $post_categories[] = $last_category->term_id;
2356 - }
2357 -
2358 - wp_set_post_categories($post_id, $post_categories);
2359 - }
2360 -
2361 - if(isset($_POST['accessgroups']))
2362 - $accessgroups = $_POST['accessgroups'];
2363 -
2364 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE post_id = $post_id");
2365 - if(isset($accessgroups))
2366 - {
2367 - foreach($accessgroups as $accessgroup)
2368 - {
2369 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_POST." (post_id,group_id) VALUES(".$post_id.", ".$accessgroup.")");
2370 - }
2371 - }
2372 - }
2373 -
2374 - function save_attachmentdata($post)
2375 - {
2376 - global $wpdb;
2377 -
2378 - if(isset($post['ID']))
2379 - {
2380 - $post_id = $post['ID'];
2381 -
2382 - if(isset($_POST['accessgroups']))
2383 - $accessgroups = $_POST['accessgroups'];
2384 -
2385 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE post_id = $post_id");
2386 - if(isset($accessgroups))
2387 - {
2388 - foreach($accessgroups as $accessgroup)
2389 - {
2390 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_POST." (post_id,group_id) VALUES(".$post_id.", ".$accessgroup.")");
2391 - }
2392 - }
2393 - }
2394 -
2395 - return $post;
2396 - }
2397 -
2398 - function remove_postdata($post_id)
2399 - {
2400 - global $wpdb;
2401 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE post_id = $post_id");
2402 - }
2403 -
2404 - function add_user_columns_header($defaults)
2405 - {
2406 - $defaults['uam_access'] = __('Access');
2407 - return $defaults;
2408 - }
2409 -
2410 - function add_user_column($column_name, $id)
2411 - {
2412 - global $wpdb;
2413 -
2414 - if( $column_name == 'uam_access' )
2415 - {
2416 - $usergroups = $wpdb->get_results(" SELECT ag.groupname
2417 - FROM ".DB_ACCESSGROUP." ag, ".DB_ACCESSGROUP_TO_USER." agtp
2418 - WHERE agtp.user_id = ".$id."
2419 - AND ag.ID = agtp.group_id
2420 - GROUP BY ag.groupname", ARRAY_A);
2421 -
2422 - if(isset($usergroups))
2423 - {
2424 - $content .= "<ul>";
2425 - foreach($usergroups as $usergroup)
2426 - {
2427 - $content .= "<li>".$usergroup['groupname']."</li>";
2428 - }
2429 - $content .= "</ul>";
2430 - }
2431 - else
2432 - {
2433 - $content = TXT_NO_GROUP;
2434 - }
2435 - return $content;
2436 - }
2437 - }
2438 -
2439 - function show_user_profile()
2440 - {
2441 - global $wpdb, $current_user;
2442 -
2443 - $user_id = $_GET['user_id'];
2444 - $cur_userdata = get_userdata($current_user->ID);
2445 - $cur_edit_userdata = get_userdata($user_id);
2446 - $uamOptions = $this->getAdminOptions();
2447 -
2448 - if($cur_userdata->user_level >= $uamOptions['full_access_level'])
2449 - {
2450 - $accessgroups = $wpdb->get_results("SELECT *
2451 - FROM ".DB_ACCESSGROUP."
2452 - ORDER BY groupname", ARRAY_A);
2453 -
2454 - ?>
2455 - <h3><?php echo TXT_GROUPS; ?></h3>
2456 - <table class="form-table">
2457 - <tbody>
2458 - <tr>
2459 - <th>
2460 - <label for="usergroups"><?php echo TXT_SET_UP_USERGROUPS; ?></label>
2461 - </th>
2462 - <td>
2463 - <?php
2464 - if(empty($cur_edit_userdata->{$wpdb->prefix."capabilities"}['administrator']))
2465 - {
2466 - if(isset($accessgroups))
2467 - {
2468 - foreach($accessgroups as $accessgroup)
2469 - {
2470 - $checked = $wpdb->get_results(" SELECT *
2471 - FROM ".DB_ACCESSGROUP_TO_USER."
2472 - WHERE user_id = ".$user_id."
2473 - AND group_id = ".$accessgroup['ID'], ARRAY_A)
2474 - ?>
2475 - <p style="margin:6px 0;">
2476 - <label for="uam_accesssgroup-<?php echo $accessgroup['ID'];?>" class="selectit" >
2477 - <input type="checkbox" id="uam_accesssgroup-<?php echo $accessgroup['ID'];?>" <?php if(isset($checked)){ echo 'checked="checked"'; } ?> value="<?php echo $accessgroup['ID']; ?>" name="accessgroups[]"/>
2478 - <?php echo $accessgroup['groupname']; ?>
2479 - </label>
2480 - <?php
2481 - $group_info_html = $this->get_usergroup_info_html($accessgroup['ID'], "padding: 0 0 0 32px");
2482 -
2483 - echo $group_info_html->link;
2484 - echo $group_info_html->content;
2485 - echo "</p>";
2486 - }
2487 - }
2488 - else
2489 - {
2490 - echo "<a href='admin.php?page=uam_usergroup'>";
2491 - echo TXT_CREATE_GROUP_FIRST;
2492 - echo "</a>";
2493 - }
2494 - }
2495 - else
2496 - {
2497 - echo TXT_ADMIN_HINT;
2498 - }
2499 - ?>
2500 - </td>
2501 - </tr>
2502 - </tbody>
2503 - </table>
2504 - <?php
2505 - }
2506 - }
2507 -
2508 - function show_media_file($meta = '', $post)
2509 - {
2510 - $content = $meta;
2511 - $content .= '</td></tr><tr><th class="label"><label>'.TXT_SET_UP_USERGROUPS.'</label></th><td class="field">';
2512 - $content .= $this->get_post_edit_info_html($post->ID, "padding:0 0 0 38px;top:-12px;");
2513 -
2514 - return $content;
2515 - }
2516 -
2517 - function save_userdata($user_id)
2518 - {
2519 - global $wpdb, $current_user;
2520 -
2521 - $cur_userdata = get_userdata($current_user->ID);
2522 - $uamOptions = $this->getAdminOptions();
2523 -
2524 - if($cur_userdata->user_level >= $uamOptions['full_access_level'])
2525 - {
2526 - $accessgroups = $_POST['accessgroups'];
2527 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_USER." WHERE user_id = $user_id");
2528 - if(isset($accessgroups))
2529 - {
2530 - foreach($accessgroups as $accessgroup)
2531 - {
2532 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_USER." (user_id,group_id) VALUES(".$user_id.", ".$accessgroup.")");
2533 - }
2534 - }
2535 - }
2536 - }
2537 -
2538 - function remove_userdata($user_id)
2539 - {
2540 - global $wpdb, $current_user;
2541 -
2542 - $cur_userdata = get_userdata($current_user->ID);
2543 - $uamOptions = $this->getAdminOptions();
2544 -
2545 - if($cur_userdata->user_level >= $uamOptions['full_access_level'])
2546 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_USER." WHERE user_id = $user_id");
2547 - }
2548 -
2549 - function add_category_columns_header($defaults)
2550 - {
2551 - $defaults['uam_access'] = __('Access');
2552 - return $defaults;
2553 - }
2554 -
2555 - function add_category_column($column_name, $id)
2556 - {
2557 - global $wpdb;
2558 -
2559 - if( $column_name == 'uam_access' )
2560 - {
2561 - $usergroups = $wpdb->get_results(" SELECT ag.groupname
2562 - FROM ".DB_ACCESSGROUP." ag, ".DB_ACCESSGROUP_TO_CATEGORY." agtc
2563 - WHERE agtc.category_id = ".$id."
2564 - AND ag.ID = agtc.group_id
2565 - GROUP BY ag.groupname", ARRAY_A);
2566 -
2567 - if(isset($usergroups))
2568 - {
2569 - $content = "<ul>";
2570 - foreach($usergroups as $usergroup)
2571 - {
2572 - $content .= "<li>".$usergroup['groupname']."</li>";
2573 - }
2574 - $content .= "</ul>";
2575 - }
2576 - else
2577 - {
2578 - $content = TXT_NO_GROUP;
2579 - }
2580 - return $content;
2581 - }
2582 - }
2583 -
2584 - function show_cat_edit_form($cat)
2585 - {
2586 - global $wpdb, $current_user;
2587 -
2588 - if(isset($cat->cat_ID))
2589 - $cat_id = $cat->cat_ID;
2590 -
2591 - $accessgroups = $wpdb->get_results("SELECT *
2592 - FROM ".DB_ACCESSGROUP."
2593 - ORDER BY groupname", ARRAY_A);
2594 -
2595 - if(isset($_GET['action']))
2596 - $action = $_GET['action'];
2597 - else
2598 - $action = null;
2599 -
2600 - if($action == 'edit')
2601 - {
2602 - ?>
2603 - <table class="form-table">
2604 - <tbody>
2605 - <tr>
2606 - <th>
2607 - <label for="description"><?php echo TXT_SET_UP_USERGROUPS; ?></label>
2608 - </th>
2609 - <td>
2610 - <?php
2611 - if(isset($accessgroups))
2612 - {
2613 - $recursive_set = $this->get_usergroups_for_post($cat_id);
2614 -
2615 - foreach($accessgroups as $accessgroup)
2616 - {
2617 - $checked = $wpdb->get_results(" SELECT *
2618 - FROM ".DB_ACCESSGROUP_TO_CATEGORY."
2619 - WHERE category_id = ".$cat_id."
2620 - AND group_id = ".$accessgroup['ID'], ARRAY_A)
2621 -
2622 - //$set_recursive = $recursive_set[$accessgroup['groupname']];
2623 - ?>
2624 - <p style="margin:6px 0;">
2625 - <label for="uam_accesssgroup-<?php echo $accessgroup['ID'];?>" class="selectit" >
2626 - <input type="checkbox" id="uam_accesssgroup-<?php echo $accessgroup['ID'];?>" <?php if(isset($checked)){ echo 'checked="checked"'; } ?> value="<?php echo $accessgroup['ID']; ?>" name="accessgroups[]"/>
2627 - <?php echo $accessgroup['groupname']; ?>
2628 - </label>
2629 - <?php
2630 - $group_info_html = $this->get_usergroup_info_html($accessgroup['ID'], "padding:0 0 0 32px;");
2631 -
2632 - echo $group_info_html->link;
2633 -
2634 - if(isset($set_recursive->posts) || isset($set_recursive->categories))
2635 - echo '&nbsp;<a class="uam_group_lock_info_link">[LR]</a>';
2636 -
2637 - echo $group_info_html->content;
2638 -
2639 - if(isset($set_recursive->posts) || isset($set_recursive->categories))
2640 - {
2641 - $recursive_info = '<ul class="uam_group_lock_info" style="padding:0 0 0 32px;"><li class="uam_group_lock_info_head">'.TXT_GROUP_LOCK_INFO.':</li>';
2642 - if(isset($set_recursive->posts))
2643 - {
2644 - foreach($set_recursive->posts as $cur_id)
2645 - {
2646 - $cur_post = & get_post($cur_id);
2647 - $recursive_info .= "<li>$cur_post->post_title [$cur_post->post_type]</li>";
2648 - }
2649 - }
2650 -
2651 - if(isset($set_recursive->categories))
2652 - {
2653 - foreach($set_recursive->categories as $cur_id)
2654 - {
2655 - $cur_category = & get_category($cur_id);
2656 - $recursive_info .= "<li>$cur_category->name [".TXT_CATEGORY."]</li>";
2657 - }
2658 - }
2659 - $recursive_info .= "</ul>";
2660 - echo $recursive_info;
2661 - }
2662 - echo "</p>";
2663 - }
2664 - }
2665 - else
2666 - {
2667 - echo "<a href='admin.php?page=uam_usergroup'>";
2668 - echo TXT_CREATE_GROUP_FIRST;
2669 - echo "</a>";
2670 - }
2671 - ?>
2672 - </td>
2673 - </tr>
2674 - </tbody>
2675 - </table>
2676 - <style type="text/css">
2677 - .submit {
2678 - display: none;
2679 - position: relative;
2680 - }
2681 - </style>
2682 - <p class="submit" style="display:block;position:relative;">
2683 - <input class="button-primary" type="submit" value="Update Category" name="submit"/>
2684 - </p>
2685 - <?php
2686 - }
2687 - }
2688 -
2689 - function add_styles()
2690 - {
2691 - wp_enqueue_style('UserAccessManager', UAM_URLPATH."css/uma_admin.css", false, '1.0', 'screen' );
2692 - }
2693 -
2694 - function add_scripts()
2695 - {
2696 - wp_enqueue_script('UserAccessManager', UAM_URLPATH .'js/functions.js', array('jquery'), '1.0' );
2697 - }
2698 -
2699 - function save_categorydata($category_id)
2700 - {
2701 - global $wpdb;
2702 -
2703 - if(isset($_POST['accessgroups']))
2704 - $accessgroups = $_POST['accessgroups'];
2705 -
2706 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_CATEGORY." WHERE category_id = $category_id");
2707 - if(isset($accessgroups))
2708 - {
2709 - foreach($accessgroups as $accessgroup)
2710 - {
2711 - $wpdb->query("INSERT INTO ".DB_ACCESSGROUP_TO_CATEGORY." (category_id,group_id) VALUES(".$category_id.", ".$accessgroup.")");
2712 - }
2713 - }
2714 - }
2715 -
2716 - function remove_categorydata($category_id)
2717 - {
2718 - global $wpdb;
2719 -
2720 - $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_CATEGORY." WHERE category_id = $category_id");
2721 - }
2722 -
2723 - function get_login_bar()
2724 - {
2725 - if(!is_user_logged_in())
2726 - {
2727 - if(!is_single())
2728 - {
2729 - $output = '<a href="'.get_bloginfo('wpurl').'/wp-login.php?redirect_to='.urlencode($_SERVER['REQUEST_URI']).'">'.__('Login', 'user-access-manager').'</a>';
2730 - }
2731 - else
2732 - {
2733 - if(! isset ($user_login))
2734 - $user_login = '';
2735 - // login form
2736 - $output = '<form action="'.get_bloginfo('wpurl').'/wp-login.php" method="post" >';
2737 - $output .= '<p><label for="user_login">'.__('Username:', 'user-access-manager').'<input name="log" value="'.wp_specialchars(stripslashes($user_login), 1).'" class="input" id="user_login" type="text" /></label></p>';
2738 - $output .= '<p><label for="user_pass">'.__('Password:', 'user-access-manager').'<input name="pwd" class="imput" id="user_pass" type="password" /></label></p>';
2739 - $output .= '<p class="forgetmenot"><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> '. __('Remember me', 'user-access-manager').'</label></p>';
2740 - $output .= '<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="'.__('Login', 'user-access-manager').' &raquo;" />';
2741 - $output .= '<input type="hidden" name="redirect_to" value="' . $_SERVER['REQUEST_URI'] . '" />';
2742 - $output .= '</form>';
2743 -
2744 - $output .= '<p>';
2745 - if (get_option('users_can_register'))
2746 - $output .= '<a href="'.get_bloginfo('wpurl').'/wp-login.php?action=register">'.__('Register', 'user-access-manager').'</a></br>';
2747 - $output .= '<a href="'.get_bloginfo('wpurl').'/wp-login.php?action=lostpassword" title="'. __('Password Lost and Found', 'user-access-manager').'">'. __('Lost your password?', 'user-access-manager').'</a>';
2748 - $output .= '</p>';
2749 - }
2750 -
2751 - return $output;
2752 - }
2753 - return null;
2754 - }
2755 -
2756 - function get_access($post_id = null)
2757 - {
2758 - global $wpdb;
2759 -
2760 - if(isset($this->restrictedPost[$post_id]))
2761 - return $this->restrictedPost[$post_id];
2762 -
2763 - $access = null;
2764 - $cur_id = $post_id;
2765 - $cur_post = & get_post($cur_id);
2766 - if(isset($cur_post->ID))
2767 - $cur_categories = get_the_category($cur_post->ID);
2768 -
2769 - $uamOptions = $this->getAdminOptions();
2770 -
2771 - if($this->atAdminPanel)
2772 - $sqlCheckLocation = "ag.write_access != 'all'";
2773 - else
2774 - $sqlCheckLocation = "ag.read_access != 'all'";
2775 -
2776 - $restricted_by_categories = array();
2777 - $restricted_by_posts = array();
2778 -
2779 - //check categories access
2780 - if(isset($cur_categories))
2781 - {
2782 - foreach($cur_categories as $cur_category)
2783 - {
2784 - if($cur_post->post_type == "post" || $cur_post->post_type == "attachment")
2785 - {
2786 - $restricted_access_by_cat = $wpdb->get_results(" SELECT *
2787 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag
2788 - WHERE atc.category_id = ".$cur_category->term_id."
2789 - AND atc.group_id = ag.ID
2790 - AND ".$sqlCheckLocation, ARRAY_A);
2791 - if(isset($restricted_access_by_cat))
2792 - $restricted_by_categories[$cur_category->term_id] = $cur_category->term_id;
2793 -
2794 - if($uamOptions['lock_recursive'] == 'true')
2795 - {
2796 - $cur_id = $cur_category->parent;
2797 - while($cur_id != 0)
2798 - {
2799 - $restricted_access_by_cat = $wpdb->get_results(" SELECT *
2800 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag
2801 - WHERE atc.category_id = ".$cur_id."
2802 - AND atc.group_id = ag.ID
2803 - AND ".$sqlCheckLocation, ARRAY_A);
2804 -
2805 - if(isset($cur_category->term_id) && isset($restricted_access_by_cat))
2806 - $restricted_by_categories[$cur_category->term_id] = $cur_category->term_id;
2807 -
2808 - if(isset($cur_category->parent))
2809 - {
2810 - $cur_id = $cur_category->parent;
2811 - $cur_category = & get_category($cur_id);
2812 - }
2813 - else
2814 - {
2815 - $cur_id = 0;
2816 - }
2817 - }
2818 - }
2819 - }
2820 - }
2821 - }
2822 -
2823 - //check posts access
2824 - if(isset($cur_post->ID))
2825 - {
2826 - $restricted_access_by_post = $wpdb->get_results(" SELECT *
2827 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP." ag
2828 - WHERE atp.post_id = ".$cur_post->ID."
2829 - AND atp.group_id = ag.ID
2830 - AND ".$sqlCheckLocation, ARRAY_A);
2831 - if(isset($restricted_access_by_post))
2832 - $restricted_by_posts[$cur_post->ID] = $cur_post->ID;
2833 -
2834 - if($uamOptions['lock_recursive'] == 'true')
2835 - {
2836 - if(isset($cur_post->post_parent))
2837 - $cur_id = $cur_post->post_parent;
2838 -
2839 - if($cur_id != 0 && isset($cur_id))
2840 - {
2841 - $restricted_access = $this->get_access($cur_id);
2842 -
2843 - if(isset($restricted_access->restricted_by_categories))
2844 - $restricted_by_categories = array_unique(array_merge($restricted_by_categories, $restricted_access->restricted_by_categories));
2845 -
2846 - if(isset($restricted_access->restricted_by_posts))
2847 - $restricted_by_posts = array_unique(array_merge($restricted_by_posts, $restricted_access->restricted_by_posts));
2848 - }
2849 - }
2850 - elseif($uamOptions['lock_recursive'] == 'false' && $cur_post->post_type == "attachment")
2851 - {
2852 - if(isset($cur_post->post_parent))
2853 - $cur_id = $cur_post->post_parent;
2854 -
2855 - if($cur_id != 0 && isset($cur_id))
2856 - {
2857 - $restricted_access = $this->get_access($cur_id);
2858 -
2859 - if(isset($restricted_access->restricted_by_categories))
2860 - $restricted_by_categories = array_unique(array_merge($restricted_by_categories, $restricted_access->restricted_by_categories));
2861 -
2862 - if(isset($restricted_access->restricted_by_posts))
2863 - $restricted_by_posts = array_unique(array_merge($restricted_by_posts, $restricted_access->restricted_by_posts));
2864 - }
2865 - }
2866 - }
2867 -
2868 - if(isset($restricted_by_categories) && count($restricted_by_categories) != 0)
2869 - $access->restricted_by_categories = $restricted_by_categories;
2870 - if(isset($restricted_by_posts) && count($restricted_by_posts) != 0)
2871 - $access->restricted_by_posts = $restricted_by_posts;
2872 -
2873 - if(empty($access))
2874 - $access = -1;
2875 -
2876 - $this->restrictedPost[$post_id] = $access;
2877 -
2878 - return $access;
2879 - }
2880 -
2881 - function check_access($post_id = null)
2882 - {
2883 - global $wpdb, $current_user;
2884 -
2885 - if(isset($this->postAccess[$post_id]))
2886 - return $this->postAccess[$post_id];
2887 -
2888 - $access = $this->get_access($post_id);
2889 - $cur_user_ip = explode(".", $_SERVER['REMOTE_ADDR']);
2890 - $uamOptions = $this->getAdminOptions();
2891 -
2892 - if(isset($access->restricted_by_posts) || isset($access->restricted_by_categories))
2893 - {
2894 - if(is_user_logged_in())
2895 - {
2896 - $cur_userdata = get_userdata($current_user->ID);
2897 -
2898 - if($cur_userdata->user_level < $uamOptions['full_access_level'])
2899 - {
2900 - if(isset($access->restricted_by_categories))
2901 - {
2902 - foreach($access->restricted_by_categories as $cur_cat_id)
2903 - {
2904 - $user_access = $wpdb->get_results(" SELECT *
2905 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP_TO_USER." atu
2906 - WHERE atc.category_id = ".$cur_cat_id."
2907 - AND atc.group_id = atu.group_id
2908 - AND atu.user_id = ".$current_user->ID, ARRAY_A);
2909 - if(isset($user_access))
2910 - {
2911 - $this->postAccess[$post_id] = true;
2912 - return true;
2913 - }
2914 -
2915 - $access_roles = $wpdb->get_results("SELECT atr.role_name
2916 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP_TO_ROLE." atr
2917 - WHERE atc.category_id = ".$cur_cat_id."
2918 - AND atc.group_id = atr.group_id", ARRAY_A);
2919 -
2920 - if(isset($access_roles))
2921 - {
2922 - foreach($access_roles as $access_role)
2923 - {
2924 - if(isset($cur_userdata->wp_capabilities[$access_role['role_name']]))
2925 - {
2926 - $this->postAccess[$post_id] = true;
2927 - return true;
2928 - }
2929 - }
2930 - }
2931 -
2932 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
2933 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag
2934 - WHERE atc.category_id = ".$cur_cat_id."
2935 - AND atc.group_id = ag.ID", ARRAY_A);
2936 -
2937 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
2938 - {
2939 - $this->postAccess[$post_id] = true;
2940 - return true;
2941 - }
2942 - }
2943 - }
2944 -
2945 - if(isset($access->restricted_by_posts))
2946 - {
2947 - foreach($access->restricted_by_posts as $cur_post_id)
2948 - {
2949 - $user_access = $wpdb->get_results(" SELECT *
2950 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP_TO_USER." atu
2951 - WHERE atp.post_id = ".$cur_post_id."
2952 - AND atp.group_id = atu.group_id
2953 - AND atu.user_id = ".$current_user->ID, ARRAY_A);
2954 - if(isset($user_access))
2955 - {
2956 - $this->postAccess[$post_id] = true;
2957 - return true;
2958 - }
2959 -
2960 - $access_roles = $wpdb->get_results("SELECT atr.role_name
2961 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP_TO_ROLE." atr
2962 - WHERE atp.post_id = ".$cur_post_id."
2963 - AND atp.group_id = atr.group_id", ARRAY_A);
2964 - if(isset($access_roles))
2965 - {
2966 - foreach($access_roles as $access_role)
2967 - {
2968 - if(isset($cur_userdata->wp_capabilities[$access_role['role_name']]))
2969 - {
2970 - $this->postAccess[$post_id] = true;
2971 - return true;
2972 - }
2973 - }
2974 - }
2975 -
2976 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
2977 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP." ag
2978 - WHERE atp.post_id = ".$cur_post_id."
2979 - AND atp.group_id = ag.ID", ARRAY_A);
2980 -
2981 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
2982 - {
2983 - $this->postAccess[$post_id] = true;
2984 - return true;
2985 - }
2986 - }
2987 - }
2988 -
2989 - if(empty($user_access))
2990 - {
2991 - $this->postAccess[$post_id] = false;
2992 - return false;
2993 - }
2994 - }
2995 - else
2996 - {
2997 - $this->postAccess[$post_id] = true;
2998 - return true;
2999 - }
3000 - }
3001 - else
3002 - {
3003 - if(isset($access->restricted_by_categories))
3004 - {
3005 - foreach($access->restricted_by_categories as $cur_cat_id)
3006 - {
3007 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
3008 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag
3009 - WHERE atc.category_id = ".$cur_cat_id."
3010 - AND atc.group_id = ag.ID");
3011 -
3012 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
3013 - {
3014 - $this->postAccess[$post_id] = true;
3015 - return true;
3016 - }
3017 - }
3018 - }
3019 -
3020 - if(isset($access->restricted_by_posts))
3021 - {
3022 - foreach($access->restricted_by_posts as $cur_post_id)
3023 - {
3024 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
3025 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP." ag
3026 - WHERE atp.post_id = ".$cur_post_id."
3027 - AND atp.group_id = ag.ID");
3028 -
3029 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
3030 - {
3031 - $this->postAccess[$post_id] = true;
3032 - return true;
3033 - }
3034 - }
3035 - }
3036 -
3037 - $this->postAccess[$post_id] = false;
3038 - return false;
3039 - }
3040 - }
3041 - else
3042 - {
3043 - $this->postAccess[$post_id] = true;
3044 - return true;
3045 - }
3046 - }
3047 -
3048 - function check_user_ip($cur_user_ip, $db_ip_ranges)
3049 - {
3050 - if(isset($db_ip_ranges))
3051 - {
3052 - $ip_ranges = explode(";", $db_ip_ranges);
3053 -
3054 - if(isset($ip_ranges))
3055 - {
3056 - foreach($ip_ranges as $ip_range)
3057 - {
3058 - $ip_range = explode("-", $ip_range);
3059 -
3060 - $range_begin = explode(".",$ip_range[0]);
3061 -
3062 - if(isset($ip_range[1]))
3063 - $range_end = explode(".",$ip_range[1]);
3064 - else
3065 - $range_end = explode(".",$ip_range[0]);
3066 -
3067 - if( $range_begin[0] <= $cur_user_ip[0] && $cur_user_ip[0] <= $range_end[0] &&
3068 - $range_begin[1] <= $cur_user_ip[1] && $cur_user_ip[1] <= $range_end[1] &&
3069 - $range_begin[2] <= $cur_user_ip[2] && $cur_user_ip[2] <= $range_end[2] &&
3070 - $range_begin[3] <= $cur_user_ip[3] && $cur_user_ip[3] <= $range_end[3])
3071 - {
3072 - return true;
3073 - }
3074 - }
3075 - }
3076 - }
3077 - return false;
3078 - }
3079 -
3080 - function show_post($posts = array())
3081 - {
3082 - $show_posts = null;
3083 - $uamOptions = $this->getAdminOptions();
3084 -
3085 - if(!is_feed() || ($uamOptions['protect_feed'] == 'true' && is_feed()))
3086 - {
3087 - foreach($posts as $post)
3088 - {
3089 - if( ($uamOptions['hide_post'] == 'true' && $post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $post->post_type == "page") || $this->atAdminPanel)
3090 - {
3091 - if($this->check_access($post->ID))
3092 - {
3093 - $post->post_title .= $this->admin_output($post->ID);
3094 - $show_posts[] = $post;
3095 - }
3096 - }
3097 - else
3098 - {
3099 - if(!$this->check_access($post->ID))
3100 - {
3101 - if($post->post_type == "post")
3102 - {
3103 - $uam_post_content = $uamOptions['post_content'];
3104 - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content);
3105 -
3106 - if($uamOptions['hide_post_title'] == 'true')
3107 - $post->post_title = $uamOptions['post_title'];
3108 -
3109 - if($uamOptions['show_post_content_before_more'] == 'true' && preg_match('/<!--more(.*?)?-->/', $post->post_content, $matches))
3110 - {
3111 - $post->post_content = explode($matches[0], $post->post_content, 2);
3112 - $post->post_content = $post->post_content[0]." ".$uam_post_content;
3113 - }
3114 - else
3115 - {
3116 - $post->post_content = $uam_post_content;
3117 - }
3118 -
3119 - if($uamOptions['allow_comments_locked'] == 'false')
3120 - $post->comment_status = 'close';
3121 - }
3122 - elseif($post->post_type == "page")
3123 - {
3124 - if($uamOptions['hide_page_title'] == 'true')
3125 - $post->post_title = $uamOptions['page_title'];
3126 -
3127 - $uam_post_content = $uamOptions['page_content'];
3128 - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content);
3129 -
3130 - $post->post_content = $uam_post_content;
3131 - }
3132 - }
3133 - $post->post_title .= $this->admin_output($post->ID);
3134 - $show_posts[] = $post;
3135 - }
3136 - }
3137 -
3138 - $posts = $show_posts;
3139 - }
3140 - return $posts;
3141 - }
3142 -
3143 - function show_comment($comments = array())
3144 - {
3145 - $show_comments = null;
3146 - $uamOptions = $this->getAdminOptions();
3147 -
3148 - foreach($comments as $comment)
3149 - {
3150 - if($uamOptions['hide_post_comment'] == 'true' || $uamOptions['hide_post'] == 'true' || $this->atAdminPanel)
3151 - {
3152 - if($this->check_access($comment->comment_post_ID))
3153 - $show_comments[] = $comment;
3154 - }
3155 - else
3156 - {
3157 - if(!$this->check_access($comment->comment_post_ID))
3158 - {
3159 - $comment->comment_content = $uamOptions['post_comment_content'];
3160 - }
3161 - $show_comments[] = $comment;
3162 - }
3163 -
3164 - }
3165 -
3166 - $comments = $show_comments;
3167 -
3168 - return $comments;
3169 - }
3170 -
3171 - function show_page($pages = array())
3172 - {
3173 - $show_pages = null;
3174 - $uamOptions = $this->getAdminOptions();
3175 -
3176 - foreach($pages as $page)
3177 - {
3178 - if($uamOptions['hide_page'] == 'true' || $this->atAdminPanel)
3179 - {
3180 - if($this->check_access($page->ID))
3181 - {
3182 - $page->post_title .= $this->admin_output($page->ID);
3183 - $show_pages[] = $page;
3184 - }
3185 - }
3186 - else
3187 - {
3188 - if(!$this->check_access($page->ID))
3189 - {
3190 - if($uamOptions['hide_page_title'] == 'true')
3191 - $page->post_title = $uamOptions['page_title'];
3192 -
3193 - $page->post_content = $uamOptions['page_content'];
3194 - }
3195 - $page->post_title .= $this->admin_output($page->ID);
3196 - $show_pages[] = $page;
3197 - }
3198 - }
3199 -
3200 - $pages = $show_pages;
3201 -
3202 - return $pages;
3203 - }
3204 -
3205 - function show_category($categories = array())
3206 - {
3207 - global $current_user, $wpdb;
3208 - $cur_userdata = get_userdata($current_user->ID);
3209 - $uamOptions = $this->getAdminOptions();
3210 -
3211 - if(!isset($cur_userdata->user_level))
3212 - $cur_userdata->user_level = null;
3213 -
3214 - if($cur_userdata->user_level < $uamOptions['full_access_level'])
3215 - {
3216 - $uamOptions = $this->getAdminOptions();
3217 -
3218 - if($this->atAdminPanel)
3219 - {
3220 - $restrictedcategories = $wpdb->get_results("SELECT category_id
3221 - FROM ".DB_ACCESSGROUP_TO_CATEGORY, ARRAY_A);
3222 -
3223 - if(isset($restrictedcategories))
3224 - {
3225 - foreach($categories as $category)
3226 - {
3227 - foreach($restrictedcategories as $restrictedcategory)
3228 - {
3229 - $has_access = true;
3230 -
3231 - if($restrictedcategory['category_id'] == $category->term_id)
3232 - {
3233 - $has_access = false;
3234 -
3235 - $access = $wpdb->get_results(" SELECT category_id
3236 - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc
3237 - WHERE agtu.user_id = ".$current_user->ID."
3238 - AND agtu.group_id = agtc.group_id
3239 - AND agtc.category_id = ".$category->term_id, ARRAY_A);
3240 -
3241 - if(isset($access))
3242 - $has_access = true;
3243 -
3244 - if(empty($show_categories[$category->term_id]) && !$has_access)
3245 - $restrict_categories[$category->term_id] = $category;
3246 - }
3247 -
3248 - if($has_access)
3249 - {
3250 - $show_categories[$category->term_id] = $category;
3251 -
3252 - if(isset($restrict_categories[$category->term_id]))
3253 - unset($restrict_categories[$category->term_id]);
3254 - }
3255 - }
3256 - }
3257 -
3258 -
3259 - if(isset($restrict_categories) && $uamOptions['lock_recursive'] == 'true')
3260 - {
3261 - foreach($restrict_categories as $restrict_category)
3262 - {
3263 - $args = array('child_of' => $restrict_category->term_id);
3264 - $child_categories = get_categories($args);
3265 -
3266 - foreach($child_categories as $child_category)
3267 - unset($show_categories[$child_category->term_id]);
3268 - }
3269 - }
3270 -
3271 - if(isset($show_categories))
3272 - $categories = $show_categories;
3273 - else
3274 - $categories = null;
3275 - }
3276 -
3277 - /*$accesscategories = $wpdb->get_results("SELECT agtc.category_id
3278 - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc
3279 - WHERE agtu.user_id = ".$current_user->ID."
3280 - AND agtu.group_id = agtc.group_id", ARRAY_A);
3281 -
3282 - if(isset($accesscategories))
3283 - {
3284 - foreach($accesscategories as $accesscategory)
3285 - {
3286 - foreach($categories as $category)
3287 - {
3288 - if($accesscategory['category_id'] == $category->term_id)
3289 - {
3290 - $show_categories[$category->term_id] = $category;
3291 -
3292 - if(isset($empty_categories[$category->term_id]))
3293 - unset($empty_categories[$category->term_id]);
3294 - }
3295 - else
3296 - {
3297 - if(empty($show_categories[$category->term_id]))
3298 - $empty_categories[$category->term_id] = $category;
3299 - }
3300 - }
3301 - }
3302 -
3303 - if(isset($empty_categories) && $uamOptions['lock_recursive'] == 'true')
3304 - {
3305 - foreach($empty_categories as $empty_category)
3306 - {
3307 - $cur_cat = $empty_category;
3308 - while($cur_cat->parent != 0 && isset($show_categories))
3309 - {
3310 - if(isset($show_categories[$cur_cat->parent]))
3311 - {
3312 - $show_categories[$empty_category->term_id] = $empty_category;
3313 - break;
3314 - }
3315 -
3316 - $cur_id = $cur_cat->parent;
3317 - $cur_cat = & get_category($cur_id);
3318 - }
3319 - }
3320 - }
3321 - }
3322 -
3323 - if(isset($show_categories))
3324 - $categories = $show_categories;
3325 - else
3326 - $categories = null;*/
3327 - }
3328 - else
3329 - {
3330 - if($uamOptions['hide_post'] == 'true' || $uamOptions['hide_page'] == 'true')
3331 - {
3332 - $args = array( 'numberposts' => -1);
3333 - $posts = get_posts($args);
3334 -
3335 - foreach($categories as $category)
3336 - {
3337 - $count = 0;
3338 -
3339 - if(isset($posts))
3340 - {
3341 - foreach($posts as $cur_post)
3342 - {
3343 - $post_cat_ids = array();
3344 - $post_cats = get_the_category($cur_post->ID);
3345 - foreach($post_cats as $post_cat)
3346 - {
3347 - $post_cat_ids[] = $post_cat->term_id;
3348 - }
3349 -
3350 - if(in_array($category->term_id, $post_cat_ids) )
3351 - {
3352 - if( ($uamOptions['hide_post'] == 'true' && $cur_post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $cur_post->post_type == "page"))
3353 - {
3354 - if($this->check_access($cur_post->ID))
3355 - $count++;
3356 - }
3357 - else
3358 - {
3359 - $count++;
3360 - }
3361 - }
3362 - }
3363 - }
3364 -
3365 - if(($count != 0 || ($uamOptions['hide_empty_categories'] == 'false' && !$this->atAdminPanel )))
3366 - {
3367 - $category->count = $count;
3368 - $cur_show_categories[$category->term_id] = $category;
3369 - }
3370 - elseif($category->taxonomy == "link_category" || $category->taxonomy == "post_tag")
3371 - {
3372 - $show_categories[$category->term_id] = $category;
3373 - }
3374 - elseif($count == 0)
3375 - {
3376 - $category->count = $count;
3377 - $empty_categories[$category->term_id] = $category;
3378 - }
3379 - }
3380 -
3381 - if($uamOptions['hide_empty_categories'] == 'true')
3382 - {
3383 - if(isset($cur_show_categories))
3384 - {
3385 - foreach($cur_show_categories as $cur_show_category)
3386 - {
3387 - $cur_count = $cur_show_category->count;
3388 - $show_categories[$cur_show_category->term_id] = $cur_show_category;
3389 -
3390 - $cur_cat = $cur_show_category;
3391 - while($cur_cat->parent != 0 && isset($empty_categories))
3392 - {
3393 - if(empty($show_categories[$cur_cat->parent]))
3394 - {
3395 - if(isset( $empty_categories[$cur_cat->parent]))
3396 - {
3397 - $cur_empty_cat = $empty_categories[$cur_cat->parent];
3398 - $cur_empty_cat->count = $cur_count;
3399 - $show_categories[$cur_cat->parent] = $cur_empty_cat;
3400 - }
3401 - }
3402 -
3403 - $cur_id = $cur_cat->parent;
3404 - $cur_cat = & get_category($cur_id);
3405 - }
3406 - }
3407 - }
3408 - }
3409 - else
3410 - {
3411 - if(isset($cur_show_categories))
3412 - {
3413 - foreach($cur_show_categories as $cur_show_category)
3414 - {
3415 - $show_categories[$cur_show_category->term_id] = $cur_show_category;
3416 - }
3417 - }
3418 - }
3419 -
3420 - if(isset($show_categories))
3421 - $categories = $show_categories;
3422 - else
3423 - $categories = null;
3424 - }
3425 - }
3426 -
3427 - }
3428 -
3429 - return $categories;
3430 - }
3431 -
3432 - function show_title($title, $post = null)
3433 - {
3434 - $uamOptions = $this->getAdminOptions();
3435 -
3436 - if(isset($post))
3437 - $post_id = $post->ID;
3438 - else
3439 - $post_id = null;
3440 -
3441 - if(!$this->check_access($post_id) && $post != null)
3442 - {
3443 - if($post->post_type == "post")
3444 - $title = $uamOptions['post_title'];
3445 - elseif($post->post_type == "page")
3446 - $title = $uamOptions['page_title'];
3447 - }
3448 - return $title;
3449 - }
3450 -
3451 - function show_next_previous_post($sql)
3452 - {
3453 - $uamOptions = $this->getAdminOptions();
3454 -
3455 - if($uamOptions['hide_post'] == 'true')
3456 - {
3457 - $posts = get_posts();
3458 - if(isset($posts))
3459 - {
3460 - foreach($posts as $post)
3461 - {
3462 - if(!$this->check_access($post->ID))
3463 - $excluded_posts[] = $post->ID;
3464 - }
3465 - if(isset($excluded_posts))
3466 - {
3467 - $excluded_posts_str = implode(",", $excluded_posts);
3468 - $sql .= "AND ID NOT IN($excluded_posts_str)";
3469 - }
3470 - }
3471 - }
3472 -
3473 - return $sql;
3474 - }
3475 -
3476 - function show_post_sql($sql)
3477 - {
3478 - $uamOptions = $this->getAdminOptions();
3479 -
3480 - if(($uamOptions['hide_post'] == 'true' && !is_feed()) || (is_feed() && $uamOptions['protect_feed'] == 'true'))
3481 - {
3482 - $posts = get_posts();
3483 - if(isset($posts))
3484 - {
3485 - foreach($posts as $post)
3486 - {
3487 - if(!$this->check_access($post->ID))
3488 - $excluded_posts[] = $post->ID;
3489 - }
3490 - if(isset($excluded_posts))
3491 - {
3492 - $excluded_posts_str = implode(",", $excluded_posts);
3493 - $sql .= "AND ID NOT IN($excluded_posts_str)";
3494 - }
3495 - }
3496 - }
3497 -
3498 - return $sql;
3499 - }
3500 -
3501 - function admin_output($post_id)
3502 - {
3503 - global $wpdb;
3504 - if(!$this->atAdminPanel)
3505 - {
3506 - $uamOptions = $this->getAdminOptions();
3507 -
3508 - if($uamOptions['blog_admin_hint'] == 'true')
3509 - {
3510 - global $current_user;
3511 - $cur_userdata = get_userdata($current_user->ID);
3512 -
3513 - $output = "";
3514 -
3515 - $access = $this->get_access($post_id);
3516 -
3517 - if(!isset($cur_userdata->user_level))
3518 - $cur_userdata->user_level = null;
3519 -
3520 - if($cur_userdata->user_level >= $uamOptions['full_access_level'] && (isset($access->restricted_by_posts) || isset($access->restricted_by_categories)))
3521 - $output = "&nbsp;".$uamOptions['blog_admin_hint_text'];
3522 -
3523 - return $output;
3524 - }
3525 - }
3526 - return null;
3527 - }
3528 -
3529 - function redirect_user()
3530 - {
3531 - global $wp_query;
3532 -
3533 - $uamOptions = $this->getAdminOptions();
3534 -
3535 - if(isset($_GET['getfile']))
3536 - $cur_file_id = $_GET['getfile'];
3537 -
3538 - if( $uamOptions['redirect'] != 'false' && ( ( !$this->check_access() && !$this->atAdminPanel && empty($cur_file_id) ) ||
3539 - ( !$this->check_access($cur_file_id) && !wp_attachment_is_image($cur_file_id) && isset($cur_file_id) )) )
3540 - {
3541 - $cur_id = null;
3542 - $cur_post = & get_post($cur_id);
3543 -
3544 - if($uamOptions['redirect'] == 'blog')
3545 - $url = get_option('siteurl');
3546 - elseif($uamOptions['redirect'] == 'custom_page')
3547 - {
3548 - $post_to_go = & get_post($uamOptions['redirect_custom_page']);
3549 - $url = $post_to_go->guid;
3550 - }
3551 - elseif( $uamOptions['redirect'] == 'custom_url')
3552 - $url = $uamOptions['redirect_custom_url'];
3553 -
3554 - $cur_posts = $wp_query->get_posts();
3555 - if(isset($cur_posts))
3556 - {
3557 - foreach($cur_posts as $cur_post)
3558 - {
3559 - if($this->check_access($cur_post->ID))
3560 - {
3561 - $post_to_show = true;
3562 - break;
3563 - }
3564 - }
3565 - }
3566 -
3567 - if($url != "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"] && empty($post_to_show))
3568 - {
3569 - header("Location: $url");
3570 - exit;
3571 - }
3572 - }
3573 - elseif(isset($_GET['getfile']))
3574 - {
3575 - $cur_id = $_GET['getfile'];
3576 - $cur_post = & get_post($cur_id);
3577 -
3578 - if($cur_post->post_type == 'attachment' && $this->check_access($cur_post->ID))
3579 - {
3580 - $file = str_replace(get_option('siteurl').'/', "", $cur_post->guid);
3581 - $filename = basename($file);
3582 -
3583 - if(file_exists($file))
3584 - {
3585 - $len = filesize($file);
3586 - header('content-type: '.$cur_post->post_mime_type);
3587 - header('content-length: '.$len);
3588 -
3589 - if(wp_attachment_is_image($cur_id))
3590 - {
3591 - readfile($file);
3592 - exit;
3593 - }
3594 - else
3595 - {
3596 - header('content-disposition: attachment; filename='.basename($file));
3597 - if($uamOptions['download_type'] == 'fopen')
3598 - {
3599 - $fp=fopen($file, 'rb');
3600 -
3601 - while ( ! feof($fp) )
3602 - {
3603 - set_time_limit(30);
3604 - $buffer = fread($fp, 1024);
3605 - echo $buffer;
3606 - }
3607 - exit;
3608 - }
3609 - else
3610 - {
3611 - readfile($file);
3612 - exit;
3613 - }
3614 - }
3615 - }
3616 - else
3617 - {
3618 - echo 'Error: File not found';
3619 - }
3620 - }
3621 - elseif(wp_attachment_is_image($cur_id))
3622 - {
3623 - $file = UAM_URLPATH .'gfx/no_access_pic.png';
3624 - $filename = basename($file);
3625 -
3626 - if(file_exists($file))
3627 - {
3628 - $len = filesize($file);
3629 - header('content-type: '.$cur_post->post_mime_type);
3630 - header('content-length: '.$len);
3631 -
3632 - readfile($file);
3633 - exit;
3634 - }
3635 - else
3636 - {
3637 - echo 'Error: File not found';
3638 - }
3639 - }
3640 - }
3641 - }
3642 -
3643 - function get_file($URL, $ID)
3644 - {
3645 - $uamOptions = $this->getAdminOptions();
3646 -
3647 - if($uamOptions['lock_file'] == 'true')
3648 - {
3649 - $cur_id = $ID;
3650 - $cur_post = & get_post($cur_id);
3651 - $cur_parent_id = $cur_post->post_parent;
3652 - $cur_parent = & get_post($cur_parent_id);
3653 -
3654 - $type = explode("/", $cur_post->post_mime_type);
3655 - $type = $type[1];
3656 -
3657 - $file_types = $uamOptions['locked_file_types'];
3658 - $file_types = explode(",", $file_types);
3659 -
3660 - if(in_array($type, $file_types) || $uamOptions['lock_file_types'] == 'all')
3661 - {
3662 - $cur_guid = get_bloginfo('url');
3663 -
3664 - $URL = $cur_guid.'?getfile='.$cur_post->ID;
3665 - }
3666 - }
3667 - return $URL;
3668 - }
3669 - }
73 + //Defines
74 + require_once $basePath.'vendor/autoload.php';
75 + require_once $basePath.'init.php';
76 + global $userAccessManager;
77 + $userAccessManager = initUserAccessManger();
3670 78 }
3671 79
3672 -if(class_exists("UserAccessManager"))
3673 -{
3674 - $userAccessManager = new UserAccessManager();
3675 -}
3676 -
3677 -//Initialize the admin panel
3678 -if(!function_exists("UserAccessManager_AP")) {
3679 - function UserAccessManager_AP()
3680 - {
3681 - global $userAccessManager, $wp_version, $current_user, $wpdb;
3682 -
3683 - $userAccessManager->atAdminPanel = true;
3684 - $uamOptions = $userAccessManager->getAdminOptions();
3685 -
3686 - if (!isset($userAccessManager))
3687 - {
3688 - return;
3689 - }
3690 - if (function_exists('add_menu_page'))
3691 - {
3692 - add_menu_page('User Access Manager', 'UAM', 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage'), UAM_URLPATH."gfx/icon.png");
3693 - }
3694 - if (function_exists('add_submenu_page'))
3695 - {
3696 - add_submenu_page('uam_usergroup', TXT_MANAGE_GROUP, TXT_MANAGE_GROUP, 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage'));
3697 - add_submenu_page('uam_usergroup', TXT_SETTINGS, TXT_SETTINGS, 9, 'uam_settings', array(&$userAccessManager, 'printAdminPage'));
3698 - add_submenu_page('uam_usergroup', TXT_SETUP, TXT_SETUP, 9, 'uam_setup', array(&$userAccessManager, 'printAdminPage'));
3699 - }
3700 - if( function_exists( 'add_meta_box' ))
3701 - {
3702 - get_currentuserinfo();
3703 - $cur_userdata = get_userdata($current_user->ID);
3704 -
3705 - if($cur_userdata->user_level == $uamOptions['full_access_level'])
3706 - {
3707 - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'post', 'side' );
3708 - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'page', 'side' );
3709 - }
3710 - }
3711 -
3712 -
3713 - //Admin actions
3714 -
3715 - $userAccessManager->update();
3716 -
3717 - add_action('manage_posts_custom_column', array(&$userAccessManager, 'add_post_column'), 10, 2);
3718 - add_action('manage_pages_custom_column', array(&$userAccessManager, 'add_post_column'), 10, 2);
3719 - add_action('manage_media_custom_column', array(&$userAccessManager, 'add_post_column'), 10, 2);
3720 - add_action('save_post', array(&$userAccessManager, 'save_postdata'));
3721 - add_action('add_attachment', array(&$userAccessManager, 'save_postdata'));
3722 - add_action('attachment_fields_to_save', array(&$userAccessManager, 'save_attachmentdata'));
3723 - add_action('delete_post', array(&$userAccessManager, 'remove_postdata'));
3724 - add_action('delete_attachment', array(&$userAccessManager, 'remove_postdata'));
3725 -
3726 - add_action('edit_user_profile', array(&$userAccessManager, 'show_user_profile'));
3727 - add_action('profile_update', array(&$userAccessManager, 'save_userdata'));
3728 - add_action('delete_user', array(&$userAccessManager, 'remove_userdata'));
3729 -
3730 - add_action('edit_category_form', array(&$userAccessManager, 'show_cat_edit_form'));
3731 - add_action('edit_category', array(&$userAccessManager, 'save_categorydata'));
3732 - add_action('delete_category', array(&$userAccessManager, 'remove_categorydata'));
3733 -
3734 - add_action('wp_print_scripts', array(&$userAccessManager, 'add_scripts') );
3735 - add_action('wp_print_styles', array(&$userAccessManager, 'add_styles') );
3736 -
3737 -
3738 - //Admin filters
3739 -
3740 - add_filter('manage_posts_columns', array(&$userAccessManager, 'add_post_columns_header'));
3741 - add_filter('manage_pages_columns', array(&$userAccessManager, 'add_post_columns_header'));
3742 -
3743 - $uamOptions = $userAccessManager->getAdminOptions();
3744 -
3745 - if($uamOptions['lock_file'] == 'true')
3746 - {
3747 - add_action('media_meta', array(&$userAccessManager, 'show_media_file'), 10 , 2);
3748 - add_filter('manage_media_columns', array(&$userAccessManager, 'add_post_columns_header'));
3749 - }
3750 -
3751 - if($wp_version >= 2.8 || $uamOptions['core_mod'] == 'true')
3752 - {
3753 - add_filter('manage_users_columns', array(&$userAccessManager, 'add_user_columns_header'), 10);
3754 - add_filter('manage_users_custom_column', array(&$userAccessManager, 'add_user_column'), 10, 2);
3755 - add_filter('manage_categories_columns', array(&$userAccessManager, 'add_category_columns_header'));
3756 - add_filter('manage_categories_custom_column', array(&$userAccessManager, 'add_category_column'), 10, 2);
3757 - }
3758 - }
3759 -}
3760 -
3761 -//Actions and Filters
3762 -if(isset($userAccessManager))
3763 -{
3764 - add_action('init', array(&$userAccessManager, 'init'));
3765 - $uamOptions = $userAccessManager->getAdminOptions();
3766 -
3767 - //install
3768 - if(function_exists('register_activation_hook'))
3769 - register_activation_hook(__FILE__, array(&$userAccessManager, 'install'));
3770 -
3771 - if(function_exists('register_uninstall_hook'))
3772 - register_uninstall_hook(__FILE__, array(&$userAccessManager, 'uninstall'));
3773 - elseif(function_exists('register_deactivation_hook'))
3774 - register_deactivation_hook(__FILE__, array(&$userAccessManager, 'uninstall'));
3775 -
3776 - if(function_exists('register_deactivation_hook'))
3777 - register_deactivation_hook(__FILE__, array(&$userAccessManager, 'deactivate'));
3778 -
3779 - //Actions
3780 - add_action('admin_menu', 'UserAccessManager_AP');
3781 -
3782 - if($uamOptions['redirect'] != 'false' || isset($_GET['getfile']))
3783 - add_action('template_redirect', array(&$userAccessManager, 'redirect_user'));
3784 -
3785 - //Filters
3786 - add_filter('wp_get_attachment_thumb_url', array(&$userAccessManager, 'get_file'), 10, 2);
3787 - add_filter('wp_get_attachment_url', array(&$userAccessManager, 'get_file'), 10, 2);
3788 - add_filter('the_posts', array(&$userAccessManager, 'show_post'));
3789 - add_filter('comments_array', array(&$userAccessManager, 'show_comment'));
3790 - add_filter('get_pages', array(&$userAccessManager, 'show_page'));
3791 - add_filter('get_terms', array(&$userAccessManager, 'show_category'));
3792 - add_filter('get_next_post_where', array(&$userAccessManager, 'show_next_previous_post'));
3793 - add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post'));
3794 - add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post'));
3795 - add_filter('the_title', array(&$userAccessManager, 'show_title'), 10, 2);
3796 - add_filter('posts_where', array(&$userAccessManager, 'show_post_sql'));
3797 -}
3798 -?>
80 +add_action('init', 'initUam', 0);