PluginProbe
User Access Manager / 1.2.6.9
User Access Manager v1.2.6.9
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 +306 -3752 0.9.1.41.2.6.9 View file →
@@ -1,3799 +1,353 @@
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.4
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)
11 -
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.
16 -
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.
21 -
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
25 -
26 -Uses an Image by: Everaldo Coelho - http://www.everaldo.com/
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: 1.2.6.9
7 + * Author: Alexander Schneider
8 + * Description: Manage the access to your posts, pages, categories and files.
9 + *
10 + * user-access-manager.php
11 + *
12 + * PHP versions 5
13 + *
14 + * @category UserAccessManager
15 + * @package UserAccessManager
16 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
17 + * @copyright 2008-2013 Alexander Schneider
18 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
19 + * @version SVN: $Id$
20 + * @link http://wordpress.org/extend/plugins/user-access-manager/
27 21 */
28 22
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');
23 +//Paths
24 +load_plugin_textdomain('user-access-manager', false, 'user-access-manager/lang');
25 +define('UAM_URLPATH', plugins_url('', __FILE__).'/');
36 26
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
27 +if (defined('UAM_LOCAL_DEBUG')) {
28 + define('UAM_REALPATH', plugin_basename(dirname(__FILE__)).'/'); //ONLY FOR MY LOCAL DEBUG
29 +} else {
30 + define('UAM_REALPATH', WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/');
31 +}
40 32
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 = '';
230 33
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();
34 +//Defines
35 +require_once 'includes/database.define.php';
36 +require_once 'includes/language.define.php';
358 37
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 38
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";
39 +//Check requirements
40 +$blStop = false;
376 41
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";
42 +//Check php version
43 +$sPhpVersion = phpversion();
384 44
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 - }
45 +if (version_compare($sPhpVersion, "5.0") === -1) {
46 + add_action(
47 + 'admin_notices',
48 + create_function(
49 + '',
50 + 'echo \'<div id="message" class="error"><p><strong>'.
51 + sprintf(TXT_UAM_PHP_VERSION_TO_LOW, $sPhpVersion).
52 + '</strong></p></div>\';'
53 + )
54 + );
55 +
56 + $blStop = true;
57 +}
840 58
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"';
59 +//Check wordpress version
60 +global $wp_version;
1201 61
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'];
62 +if (version_compare($wp_version, "3.0") === -1) {
63 + add_action(
64 + 'admin_notices',
65 + create_function(
66 + '',
67 + 'echo \'<div id="message" class="error"><p><strong>'.
68 + sprintf(TXT_UAM_WORDPRESS_VERSION_TO_LOW, $wp_version).
69 + '</strong></p></div>\';'
70 + )
71 + );
72 +
73 + $blStop = true;
74 +}
1922 75
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;
76 +//If we have a error stop plugin.
77 +if ($blStop) {
78 + return;
79 +}
1929 80
1930 - $post_usergroups[$usergroup['ID']] = $cur_usergroup;
1931 - }
1932 - }
1933 81
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 -
82 +//Classes
83 +require_once 'class/UserAccessManager.class.php';
84 +require_once 'class/UamUserGroup.class.php';
85 +require_once 'class/UamAccessHandler.class.php';
1974 86
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 - }
87 +if (class_exists("UserAccessManager")) {
88 + $oUserAccessManager = new UserAccessManager();
89 +}
2019 90
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 - }
91 +//Initialize the admin panel
92 +if (!function_exists("userAccessManagerAP")) {
93 + /**
94 + * Creates the filters and actions for the admin panel
95 + *
96 + * @return null;
97 + */
98 + function userAccessManagerAP()
99 + {
100 + global $oUserAccessManager;
101 + $oCurrentUser = $oUserAccessManager->getCurrentUser();
2042 102
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 - }
103 + if (!isset($oUserAccessManager)) {
104 + return;
105 + }
2051 106
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);
107 + $oUserAccessManager->setAtAdminPanel();
108 + $aUamOptions = $oUserAccessManager->getAdminOptions();
2092 109
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>";
110 + if ($oUserAccessManager->isDatabaseUpdateNecessary()) {
111 + $sLink = 'admin.php?page=uam_setup';
2099 112
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 - }
113 + add_action(
114 + 'admin_notices',
115 + create_function(
116 + '',
117 + 'echo \'<div id="message" class="error"><p><strong>'.
118 + sprintf(TXT_UAM_NEED_DATABASE_UPDATE, $sLink).
119 + '</strong></p></div>\';'
120 + )
121 + );
122 + }
2128 123
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 - }
124 + get_currentuserinfo();
125 + $oCurUserData = wp_get_current_user();
126 + $oUamAccessHandler = $oUserAccessManager->getAccessHandler();
127 + $aTaxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
2143 128
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>";
129 + if ($oUamAccessHandler->checkUserAccess()
130 + || $aUamOptions['authors_can_add_posts_to_groups'] == 'true'
131 + ) {
132 + //Admin actions
133 + if (function_exists('add_action')) {
134 + add_action('admin_print_styles', array($oUserAccessManager, 'addStyles'));
135 + add_action('wp_print_scripts', array($oUserAccessManager, 'addScripts'));
2173 136
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);
137 + add_action('manage_posts_custom_column', array($oUserAccessManager, 'addPostColumn'), 10, 2);
138 + add_action('manage_pages_custom_column', array($oUserAccessManager, 'addPostColumn'), 10, 2);
139 + add_action('save_post', array($oUserAccessManager, 'savePostData'));
2183 140
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);
141 + add_action('manage_media_custom_column', array($oUserAccessManager, 'addPostColumn'), 10, 2);
2239 142
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']];
143 + //Actions are only called when the attachment content is modified so we can't use it.
144 + //add_action('add_attachment', array($oUserAccessManager, 'savePostData'));
145 + //add_action('edit_attachment', array($oUserAccessManager, 'savePostData'));
2254 146
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>";
147 + add_action('edit_user_profile', array($oUserAccessManager, 'showUserProfile'));
148 + add_action('profile_update', array($oUserAccessManager, 'saveUserData'));
2264 149
2265 - $group_info_html = $this->get_usergroup_info_html($accessgroup['ID'], $style);
150 + add_action('edit_category_form', array($oUserAccessManager, 'showCategoryEditForm'));
151 + add_action('create_category', array($oUserAccessManager, 'saveCategoryData'));
152 + add_action('edit_category', array($oUserAccessManager, 'saveCategoryData'));
2266 153
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;
154 + add_action('bulk_edit_custom_box', array($oUserAccessManager, 'addBulkAction'));
2273 155
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 156
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();
157 + //Taxonomies
158 + foreach ($aTaxonomies as $sTaxonomy) {
159 + add_filter('manage_edit-'.$sTaxonomy.'_columns', array($oUserAccessManager, 'addCategoryColumnsHeader'));
160 + add_action('manage_'.$sTaxonomy.'_custom_column', array($oUserAccessManager, 'addCategoryColumn'), 10, 3);
161 + add_action($sTaxonomy.'_add_form_fields', array($oUserAccessManager, 'showCategoryEditForm'));
162 + add_action($sTaxonomy.'_edit_form_fields', array($oUserAccessManager, 'showCategoryEditForm'));
163 + add_action('create_'.$sTaxonomy, array($oUserAccessManager, 'saveCategoryData'));
164 + add_action('edit_'.$sTaxonomy, array($oUserAccessManager, 'saveCategoryData'));
165 + }
166 + }
2523 167
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();
168 + //Admin filters
169 + if (function_exists('add_filter')) {
170 + //The filter we use instead of add|edit_attachment action, reason see top
171 + add_filter('attachment_fields_to_save', array($oUserAccessManager, 'saveAttachmentData'));
2544 172
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;
173 + add_filter('manage_posts_columns', array($oUserAccessManager, 'addPostColumnsHeader'));
174 + add_filter('manage_pages_columns', array($oUserAccessManager, 'addPostColumnsHeader'));
2587 175
2588 - if(isset($cat->cat_ID))
2589 - $cat_id = $cat->cat_ID;
176 + add_filter('manage_users_columns', array($oUserAccessManager, 'addUserColumnsHeader'), 10);
177 + add_filter('manage_users_custom_column', array($oUserAccessManager, 'addUserColumn'), 10, 3);
2590 178
2591 - $accessgroups = $wpdb->get_results("SELECT *
2592 - FROM ".DB_ACCESSGROUP."
2593 - ORDER BY groupname", ARRAY_A);
179 + add_filter('manage_edit-category_columns', array($oUserAccessManager, 'addCategoryColumnsHeader'));
180 + add_filter('manage_category_custom_column', array($oUserAccessManager, 'addCategoryColumn'), 10, 3);
181 + }
2594 182
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 - }
183 + if ($aUamOptions['lock_file'] == 'true') {
184 + add_action('media_meta', array($oUserAccessManager, 'showMediaFile'), 10, 2);
185 + add_filter('manage_media_columns', array($oUserAccessManager, 'addPostColumnsHeader'));
186 + }
187 + }
2698 188
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($restricted_access_by_cat != Array())
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) && $restricted_access_by_cat != Array())
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 -
2832 - if($restricted_access_by_post != Array())
2833 - $restricted_by_posts[$cur_post->ID] = $cur_post->ID;
2834 -
2835 - if($uamOptions['lock_recursive'] == 'true')
2836 - {
2837 - if(isset($cur_post->post_parent))
2838 - $cur_id = $cur_post->post_parent;
2839 -
2840 - if($cur_id != 0 && isset($cur_id))
2841 - {
2842 - $restricted_access = $this->get_access($cur_id);
189 + //Clean up at deleting should always be done.
190 + if (function_exists('add_action')) {
191 + add_action('update_option_permalink_structure', array($oUserAccessManager, 'updatePermalink'));
192 + add_action('wp_dashboard_setup', array($oUserAccessManager, 'setupAdminDashboard'));
193 + add_action('delete_post', array($oUserAccessManager, 'removePostData'));
194 + add_action('delete_attachment', array($oUserAccessManager, 'removePostData'));
195 + add_action('delete_user', array($oUserAccessManager, 'removeUserData'));
196 + add_action('delete_category', array($oUserAccessManager, 'removeCategoryData'), 10, 2);
2843 197
2844 - if(isset($restricted_access->restricted_by_categories))
2845 - $restricted_by_categories = array_unique(array_merge($restricted_by_categories, $restricted_access->restricted_by_categories));
2846 -
2847 - if(isset($restricted_access->restricted_by_posts))
2848 - $restricted_by_posts = array_unique(array_merge($restricted_by_posts, $restricted_access->restricted_by_posts));
2849 - }
2850 - }
2851 - elseif($uamOptions['lock_recursive'] == 'false' && $cur_post->post_type == "attachment")
2852 - {
2853 - if(isset($cur_post->post_parent))
2854 - $cur_id = $cur_post->post_parent;
198 + // taxonomies
2855 199
2856 - if($cur_id != 0 && isset($cur_id))
2857 - {
2858 - $restricted_access = $this->get_access($cur_id);
2859 -
2860 - if(isset($restricted_access->restricted_by_categories))
2861 - $restricted_by_categories = array_unique(array_merge($restricted_by_categories, $restricted_access->restricted_by_categories));
2862 -
2863 - if(isset($restricted_access->restricted_by_posts))
2864 - $restricted_by_posts = array_unique(array_merge($restricted_by_posts, $restricted_access->restricted_by_posts));
2865 - }
2866 - }
2867 - }
2868 -
2869 - if(isset($restricted_by_categories) && count($restricted_by_categories) != 0)
2870 - $access->restricted_by_categories = $restricted_by_categories;
2871 - if(isset($restricted_by_posts) && count($restricted_by_posts) != 0)
2872 - $access->restricted_by_posts = $restricted_by_posts;
200 + foreach ($aTaxonomies as $sTaxonomy) {
201 + add_action('delete_'.$sTaxonomy, array($oUserAccessManager, 'removeCategoryData'));
202 + }
203 + }
204 +
205 + $oUserAccessManager->noRightsToEditContent();
206 + }
207 +}
2873 208
2874 - if(empty($access))
2875 - $access = -1;
2876 -
2877 - $this->restrictedPost[$post_id] = $access;
2878 -
2879 - return $access;
2880 - }
2881 -
2882 - function check_access($post_id = null)
2883 - {
2884 - global $wpdb, $current_user;
2885 -
2886 - if(isset($this->postAccess[$post_id]))
2887 - return $this->postAccess[$post_id];
2888 -
2889 - $access = $this->get_access($post_id);
2890 - $cur_user_ip = explode(".", $_SERVER['REMOTE_ADDR']);
2891 - $uamOptions = $this->getAdminOptions();
2892 -
2893 - if(isset($access->restricted_by_posts) || isset($access->restricted_by_categories))
2894 - {
2895 - if(is_user_logged_in())
2896 - {
2897 - $cur_userdata = get_userdata($current_user->ID);
2898 -
2899 - if($cur_userdata->user_level < $uamOptions['full_access_level'])
2900 - {
2901 - if(isset($access->restricted_by_categories))
2902 - {
2903 - foreach($access->restricted_by_categories as $cur_cat_id)
2904 - {
2905 - $user_access = $wpdb->get_results(" SELECT *
2906 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP_TO_USER." atu
2907 - WHERE atc.category_id = ".$cur_cat_id."
2908 - AND atc.group_id = atu.group_id
2909 - AND atu.user_id = ".$current_user->ID, ARRAY_A);
2910 - if(isset($user_access))
2911 - {
2912 - $this->postAccess[$post_id] = true;
2913 - return true;
2914 - }
2915 -
2916 - $access_roles = $wpdb->get_results("SELECT atr.role_name
2917 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP_TO_ROLE." atr
2918 - WHERE atc.category_id = ".$cur_cat_id."
2919 - AND atc.group_id = atr.group_id", ARRAY_A);
2920 -
2921 - if(isset($access_roles))
2922 - {
2923 - foreach($access_roles as $access_role)
2924 - {
2925 - if(isset($cur_userdata->wp_capabilities[$access_role['role_name']]))
2926 - {
2927 - $this->postAccess[$post_id] = true;
2928 - return true;
2929 - }
2930 - }
2931 - }
2932 -
2933 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
2934 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag
2935 - WHERE atc.category_id = ".$cur_cat_id."
2936 - AND atc.group_id = ag.ID", ARRAY_A);
2937 -
2938 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
2939 - {
2940 - $this->postAccess[$post_id] = true;
2941 - return true;
2942 - }
2943 - }
2944 - }
2945 -
2946 - if(isset($access->restricted_by_posts))
2947 - {
2948 - foreach($access->restricted_by_posts as $cur_post_id)
2949 - {
2950 - $user_access = $wpdb->get_results(" SELECT *
2951 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP_TO_USER." atu
2952 - WHERE atp.post_id = ".$cur_post_id."
2953 - AND atp.group_id = atu.group_id
2954 - AND atu.user_id = ".$current_user->ID, ARRAY_A);
2955 - if(isset($user_access))
2956 - {
2957 - $this->postAccess[$post_id] = true;
2958 - return true;
2959 - }
2960 -
2961 - $access_roles = $wpdb->get_results("SELECT atr.role_name
2962 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP_TO_ROLE." atr
2963 - WHERE atp.post_id = ".$cur_post_id."
2964 - AND atp.group_id = atr.group_id", ARRAY_A);
2965 - if(isset($access_roles))
2966 - {
2967 - foreach($access_roles as $access_role)
2968 - {
2969 - if(isset($cur_userdata->wp_capabilities[$access_role['role_name']]))
2970 - {
2971 - $this->postAccess[$post_id] = true;
2972 - return true;
2973 - }
2974 - }
2975 - }
2976 -
2977 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
2978 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP." ag
2979 - WHERE atp.post_id = ".$cur_post_id."
2980 - AND atp.group_id = ag.ID", ARRAY_A);
2981 -
2982 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
2983 - {
2984 - $this->postAccess[$post_id] = true;
2985 - return true;
2986 - }
2987 - }
2988 - }
2989 -
2990 - if(empty($user_access))
2991 - {
2992 - $this->postAccess[$post_id] = false;
2993 - return false;
2994 - }
2995 - }
2996 - else
2997 - {
2998 - $this->postAccess[$post_id] = true;
2999 - return true;
3000 - }
3001 - }
3002 - else
3003 - {
3004 - if(isset($access->restricted_by_categories))
3005 - {
3006 - foreach($access->restricted_by_categories as $cur_cat_id)
3007 - {
3008 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
3009 - FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag
3010 - WHERE atc.category_id = ".$cur_cat_id."
3011 - AND atc.group_id = ag.ID");
3012 -
3013 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
3014 - {
3015 - $this->postAccess[$post_id] = true;
3016 - return true;
3017 - }
3018 - }
3019 - }
3020 -
3021 - if(isset($access->restricted_by_posts))
3022 - {
3023 - foreach($access->restricted_by_posts as $cur_post_id)
3024 - {
3025 - $db_ip_ranges = $wpdb->get_var("SELECT ag.ip_range
3026 - FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP." ag
3027 - WHERE atp.post_id = ".$cur_post_id."
3028 - AND atp.group_id = ag.ID");
3029 -
3030 - if($this->check_user_ip($cur_user_ip, $db_ip_ranges))
3031 - {
3032 - $this->postAccess[$post_id] = true;
3033 - return true;
3034 - }
3035 - }
3036 - }
3037 -
3038 - $this->postAccess[$post_id] = false;
3039 - return false;
3040 - }
3041 - }
3042 - else
3043 - {
3044 - $this->postAccess[$post_id] = true;
3045 - return true;
3046 - }
3047 - }
3048 -
3049 - function check_user_ip($cur_user_ip, $db_ip_ranges)
3050 - {
3051 - if(isset($db_ip_ranges))
3052 - {
3053 - $ip_ranges = explode(";", $db_ip_ranges);
3054 -
3055 - if(isset($ip_ranges))
3056 - {
3057 - foreach($ip_ranges as $ip_range)
3058 - {
3059 - $ip_range = explode("-", $ip_range);
3060 -
3061 - $range_begin = explode(".",$ip_range[0]);
3062 -
3063 - if(isset($ip_range[1]))
3064 - $range_end = explode(".",$ip_range[1]);
3065 - else
3066 - $range_end = explode(".",$ip_range[0]);
3067 -
3068 - if( $range_begin[0] <= $cur_user_ip[0] && $cur_user_ip[0] <= $range_end[0] &&
3069 - $range_begin[1] <= $cur_user_ip[1] && $cur_user_ip[1] <= $range_end[1] &&
3070 - $range_begin[2] <= $cur_user_ip[2] && $cur_user_ip[2] <= $range_end[2] &&
3071 - $range_begin[3] <= $cur_user_ip[3] && $cur_user_ip[3] <= $range_end[3])
3072 - {
3073 - return true;
3074 - }
3075 - }
3076 - }
3077 - }
3078 - return false;
3079 - }
3080 -
3081 - function show_post($posts = array())
3082 - {
3083 - $show_posts = null;
3084 - $uamOptions = $this->getAdminOptions();
3085 -
3086 - if(!is_feed() || ($uamOptions['protect_feed'] == 'true' && is_feed()))
3087 - {
3088 - foreach($posts as $post)
3089 - {
3090 - if( ($uamOptions['hide_post'] == 'true' && $post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $post->post_type == "page") || $this->atAdminPanel)
3091 - {
3092 - if($this->check_access($post->ID))
3093 - {
3094 - $post->post_title .= $this->admin_output($post->ID);
3095 - $show_posts[] = $post;
3096 - }
3097 - }
3098 - else
3099 - {
3100 - if(!$this->check_access($post->ID))
3101 - {
3102 - if($post->post_type == "post")
3103 - {
3104 - $uam_post_content = $uamOptions['post_content'];
3105 - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content);
3106 -
3107 - if($uamOptions['hide_post_title'] == 'true')
3108 - $post->post_title = $uamOptions['post_title'];
3109 -
3110 - if($uamOptions['show_post_content_before_more'] == 'true' && preg_match('/<!--more(.*?)?-->/', $post->post_content, $matches))
3111 - {
3112 - $post->post_content = explode($matches[0], $post->post_content, 2);
3113 - $post->post_content = $post->post_content[0]." ".$uam_post_content;
3114 - }
3115 - else
3116 - {
3117 - $post->post_content = $uam_post_content;
3118 - }
3119 -
3120 - if($uamOptions['allow_comments_locked'] == 'false')
3121 - $post->comment_status = 'close';
3122 - }
3123 - elseif($post->post_type == "page")
3124 - {
3125 - if($uamOptions['hide_page_title'] == 'true')
3126 - $post->post_title = $uamOptions['page_title'];
3127 -
3128 - $uam_post_content = $uamOptions['page_content'];
3129 - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content);
3130 -
3131 - $post->post_content = $uam_post_content;
3132 - }
3133 - }
3134 - $post->post_title .= $this->admin_output($post->ID);
3135 - $show_posts[] = $post;
3136 - }
3137 - }
3138 -
3139 - $posts = $show_posts;
3140 - }
3141 - return $posts;
3142 - }
3143 -
3144 - function show_comment($comments = array())
3145 - {
3146 - $show_comments = null;
3147 - $uamOptions = $this->getAdminOptions();
3148 -
3149 - foreach($comments as $comment)
3150 - {
3151 - if($uamOptions['hide_post_comment'] == 'true' || $uamOptions['hide_post'] == 'true' || $this->atAdminPanel)
3152 - {
3153 - if($this->check_access($comment->comment_post_ID))
3154 - $show_comments[] = $comment;
3155 - }
3156 - else
3157 - {
3158 - if(!$this->check_access($comment->comment_post_ID))
3159 - {
3160 - $comment->comment_content = $uamOptions['post_comment_content'];
3161 - }
3162 - $show_comments[] = $comment;
3163 - }
3164 -
3165 - }
3166 -
3167 - $comments = $show_comments;
3168 -
3169 - return $comments;
3170 - }
3171 -
3172 - function show_page($pages = array())
3173 - {
3174 - $show_pages = null;
3175 - $uamOptions = $this->getAdminOptions();
3176 -
3177 - foreach($pages as $page)
3178 - {
3179 - if($uamOptions['hide_page'] == 'true' || $this->atAdminPanel)
3180 - {
3181 - if($this->check_access($page->ID))
3182 - {
3183 - $page->post_title .= $this->admin_output($page->ID);
3184 - $show_pages[] = $page;
3185 - }
3186 - }
3187 - else
3188 - {
3189 - if(!$this->check_access($page->ID))
3190 - {
3191 - if($uamOptions['hide_page_title'] == 'true')
3192 - $page->post_title = $uamOptions['page_title'];
3193 -
3194 - $page->post_content = $uamOptions['page_content'];
3195 - }
3196 - $page->post_title .= $this->admin_output($page->ID);
3197 - $show_pages[] = $page;
3198 - }
3199 - }
3200 -
3201 - $pages = $show_pages;
3202 -
3203 - return $pages;
3204 - }
3205 -
3206 - function show_category($categories = array())
3207 - {
3208 - global $current_user, $wpdb;
3209 - $cur_userdata = get_userdata($current_user->ID);
3210 - $uamOptions = $this->getAdminOptions();
3211 -
3212 - if(!isset($cur_userdata->user_level))
3213 - $cur_userdata->user_level = null;
3214 -
3215 - if($cur_userdata->user_level < $uamOptions['full_access_level'])
3216 - {
3217 - $uamOptions = $this->getAdminOptions();
3218 -
3219 - if($this->atAdminPanel)
3220 - {
3221 - $restrictedcategories = $wpdb->get_results("SELECT category_id
3222 - FROM ".DB_ACCESSGROUP_TO_CATEGORY, ARRAY_A);
3223 -
3224 - if(isset($restrictedcategories))
3225 - {
3226 - foreach($categories as $category)
3227 - {
3228 - foreach($restrictedcategories as $restrictedcategory)
3229 - {
3230 - $has_access = true;
3231 -
3232 - if($restrictedcategory['category_id'] == $category->term_id)
3233 - {
3234 - $has_access = false;
3235 -
3236 - $access = $wpdb->get_results(" SELECT category_id
3237 - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc
3238 - WHERE agtu.user_id = ".$current_user->ID."
3239 - AND agtu.group_id = agtc.group_id
3240 - AND agtc.category_id = ".$category->term_id, ARRAY_A);
3241 -
3242 - if(isset($access))
3243 - $has_access = true;
3244 -
3245 - if(empty($show_categories[$category->term_id]) && !$has_access)
3246 - $restrict_categories[$category->term_id] = $category;
3247 - }
3248 -
3249 - if($has_access)
3250 - {
3251 - $show_categories[$category->term_id] = $category;
3252 -
3253 - if(isset($restrict_categories[$category->term_id]))
3254 - unset($restrict_categories[$category->term_id]);
3255 - }
3256 - }
3257 - }
3258 -
3259 -
3260 - if(isset($restrict_categories) && $uamOptions['lock_recursive'] == 'true')
3261 - {
3262 - foreach($restrict_categories as $restrict_category)
3263 - {
3264 - $args = array('child_of' => $restrict_category->term_id);
3265 - $child_categories = get_categories($args);
3266 -
3267 - foreach($child_categories as $child_category)
3268 - unset($show_categories[$child_category->term_id]);
3269 - }
3270 - }
3271 -
3272 - if(isset($show_categories))
3273 - $categories = $show_categories;
3274 - else
3275 - $categories = null;
3276 - }
3277 -
3278 - /*$accesscategories = $wpdb->get_results("SELECT agtc.category_id
3279 - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc
3280 - WHERE agtu.user_id = ".$current_user->ID."
3281 - AND agtu.group_id = agtc.group_id", ARRAY_A);
3282 -
3283 - if(isset($accesscategories))
3284 - {
3285 - foreach($accesscategories as $accesscategory)
3286 - {
3287 - foreach($categories as $category)
3288 - {
3289 - if($accesscategory['category_id'] == $category->term_id)
3290 - {
3291 - $show_categories[$category->term_id] = $category;
3292 -
3293 - if(isset($empty_categories[$category->term_id]))
3294 - unset($empty_categories[$category->term_id]);
3295 - }
3296 - else
3297 - {
3298 - if(empty($show_categories[$category->term_id]))
3299 - $empty_categories[$category->term_id] = $category;
3300 - }
3301 - }
3302 - }
3303 -
3304 - if(isset($empty_categories) && $uamOptions['lock_recursive'] == 'true')
3305 - {
3306 - foreach($empty_categories as $empty_category)
3307 - {
3308 - $cur_cat = $empty_category;
3309 - while($cur_cat->parent != 0 && isset($show_categories))
3310 - {
3311 - if(isset($show_categories[$cur_cat->parent]))
3312 - {
3313 - $show_categories[$empty_category->term_id] = $empty_category;
3314 - break;
3315 - }
3316 -
3317 - $cur_id = $cur_cat->parent;
3318 - $cur_cat = & get_category($cur_id);
3319 - }
3320 - }
3321 - }
3322 - }
3323 -
3324 - if(isset($show_categories))
3325 - $categories = $show_categories;
3326 - else
3327 - $categories = null;*/
3328 - }
3329 - else
3330 - {
3331 - if($uamOptions['hide_post'] == 'true' || $uamOptions['hide_page'] == 'true')
3332 - {
3333 - $args = array( 'numberposts' => -1);
3334 - $posts = get_posts($args);
3335 -
3336 - foreach($categories as $category)
3337 - {
3338 - $count = 0;
3339 -
3340 - if(isset($posts))
3341 - {
3342 - foreach($posts as $cur_post)
3343 - {
3344 - $post_cat_ids = array();
3345 - $post_cats = get_the_category($cur_post->ID);
3346 - foreach($post_cats as $post_cat)
3347 - {
3348 - $post_cat_ids[] = $post_cat->term_id;
3349 - }
3350 -
3351 - if(in_array($category->term_id, $post_cat_ids) )
3352 - {
3353 - if( ($uamOptions['hide_post'] == 'true' && $cur_post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $cur_post->post_type == "page"))
3354 - {
3355 - if($this->check_access($cur_post->ID))
3356 - $count++;
3357 - }
3358 - else
3359 - {
3360 - $count++;
3361 - }
3362 - }
3363 - }
3364 - }
3365 -
3366 - if(($count != 0 || ($uamOptions['hide_empty_categories'] == 'false' && !$this->atAdminPanel )))
3367 - {
3368 - $category->count = $count;
3369 - $cur_show_categories[$category->term_id] = $category;
3370 - }
3371 - elseif($category->taxonomy == "link_category" || $category->taxonomy == "post_tag")
3372 - {
3373 - $show_categories[$category->term_id] = $category;
3374 - }
3375 - elseif($count == 0)
3376 - {
3377 - $category->count = $count;
3378 - $empty_categories[$category->term_id] = $category;
3379 - }
3380 - }
3381 -
3382 - if($uamOptions['hide_empty_categories'] == 'true')
3383 - {
3384 - if(isset($cur_show_categories))
3385 - {
3386 - foreach($cur_show_categories as $cur_show_category)
3387 - {
3388 - $cur_count = $cur_show_category->count;
3389 - $show_categories[$cur_show_category->term_id] = $cur_show_category;
3390 -
3391 - $cur_cat = $cur_show_category;
3392 - while($cur_cat->parent != 0 && isset($empty_categories))
3393 - {
3394 - if(empty($show_categories[$cur_cat->parent]))
3395 - {
3396 - if(isset( $empty_categories[$cur_cat->parent]))
3397 - {
3398 - $cur_empty_cat = $empty_categories[$cur_cat->parent];
3399 - $cur_empty_cat->count = $cur_count;
3400 - $show_categories[$cur_cat->parent] = $cur_empty_cat;
3401 - }
3402 - }
3403 -
3404 - $cur_id = $cur_cat->parent;
3405 - $cur_cat = & get_category($cur_id);
3406 - }
3407 - }
3408 - }
3409 - }
3410 - else
3411 - {
3412 - if(isset($cur_show_categories))
3413 - {
3414 - foreach($cur_show_categories as $cur_show_category)
3415 - {
3416 - $show_categories[$cur_show_category->term_id] = $cur_show_category;
3417 - }
3418 - }
3419 - }
3420 -
3421 - if(isset($show_categories))
3422 - $categories = $show_categories;
3423 - else
3424 - $categories = null;
3425 - }
3426 - }
3427 -
3428 - }
3429 -
3430 - return $categories;
3431 - }
3432 -
3433 - function show_title($title, $post = null)
3434 - {
3435 - $uamOptions = $this->getAdminOptions();
3436 -
3437 - if(isset($post))
3438 - $post_id = $post->ID;
3439 - else
3440 - $post_id = null;
3441 -
3442 - if(!$this->check_access($post_id) && $post != null)
3443 - {
3444 - if($post->post_type == "post")
3445 - $title = $uamOptions['post_title'];
3446 - elseif($post->post_type == "page")
3447 - $title = $uamOptions['page_title'];
3448 - }
3449 - return $title;
3450 - }
3451 -
3452 - function show_next_previous_post($sql)
3453 - {
3454 - $uamOptions = $this->getAdminOptions();
3455 -
3456 - if($uamOptions['hide_post'] == 'true')
3457 - {
3458 - $posts = get_posts();
3459 - if(isset($posts))
3460 - {
3461 - foreach($posts as $post)
3462 - {
3463 - if(!$this->check_access($post->ID))
3464 - $excluded_posts[] = $post->ID;
3465 - }
3466 - if(isset($excluded_posts))
3467 - {
3468 - $excluded_posts_str = implode(",", $excluded_posts);
3469 - $sql .= "AND ID NOT IN($excluded_posts_str)";
3470 - }
3471 - }
3472 - }
3473 -
3474 - return $sql;
3475 - }
3476 -
3477 - function show_post_sql($sql)
3478 - {
3479 - $uamOptions = $this->getAdminOptions();
3480 -
3481 - if(($uamOptions['hide_post'] == 'true' && !is_feed()) || (is_feed() && $uamOptions['protect_feed'] == 'true'))
3482 - {
3483 - $posts = get_posts();
3484 - if(isset($posts))
3485 - {
3486 - foreach($posts as $post)
3487 - {
3488 - if(!$this->check_access($post->ID))
3489 - $excluded_posts[] = $post->ID;
3490 - }
3491 - if(isset($excluded_posts))
3492 - {
3493 - $excluded_posts_str = implode(",", $excluded_posts);
3494 - $sql .= "AND ID NOT IN($excluded_posts_str)";
3495 - }
3496 - }
3497 - }
3498 -
3499 - return $sql;
3500 - }
3501 -
3502 - function admin_output($post_id)
3503 - {
3504 - global $wpdb;
3505 - if(!$this->atAdminPanel)
3506 - {
3507 - $uamOptions = $this->getAdminOptions();
3508 -
3509 - if($uamOptions['blog_admin_hint'] == 'true')
3510 - {
3511 - global $current_user;
3512 - $cur_userdata = get_userdata($current_user->ID);
3513 -
3514 - $output = "";
3515 -
3516 - $access = $this->get_access($post_id);
3517 -
3518 - if(!isset($cur_userdata->user_level))
3519 - $cur_userdata->user_level = null;
3520 -
3521 - if($cur_userdata->user_level >= $uamOptions['full_access_level'] && (isset($access->restricted_by_posts) || isset($access->restricted_by_categories)))
3522 - $output = "&nbsp;".$uamOptions['blog_admin_hint_text'];
3523 -
3524 - return $output;
3525 - }
3526 - }
3527 - return null;
3528 - }
3529 -
3530 - function redirect_user()
3531 - {
3532 - global $wp_query;
3533 -
3534 - $uamOptions = $this->getAdminOptions();
3535 -
3536 - if(isset($_GET['getfile']))
3537 - $cur_file_id = $_GET['getfile'];
3538 -
3539 - if( $uamOptions['redirect'] != 'false' && ( ( !$this->check_access() && !$this->atAdminPanel && empty($cur_file_id) ) ||
3540 - ( !$this->check_access($cur_file_id) && !wp_attachment_is_image($cur_file_id) && isset($cur_file_id) )) )
3541 - {
3542 - $cur_id = null;
3543 - $cur_post = & get_post($cur_id);
3544 -
3545 - if($uamOptions['redirect'] == 'blog')
3546 - $url = get_option('siteurl');
3547 - elseif($uamOptions['redirect'] == 'custom_page')
3548 - {
3549 - $post_to_go = & get_post($uamOptions['redirect_custom_page']);
3550 - $url = $post_to_go->guid;
3551 - }
3552 - elseif( $uamOptions['redirect'] == 'custom_url')
3553 - $url = $uamOptions['redirect_custom_url'];
3554 -
3555 - $cur_posts = $wp_query->get_posts();
3556 - if(isset($cur_posts))
3557 - {
3558 - foreach($cur_posts as $cur_post)
3559 - {
3560 - if($this->check_access($cur_post->ID))
3561 - {
3562 - $post_to_show = true;
3563 - break;
3564 - }
3565 - }
3566 - }
3567 -
3568 - if($url != "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"] && empty($post_to_show))
3569 - {
3570 - header("Location: $url");
3571 - exit;
3572 - }
3573 - }
3574 - elseif(isset($_GET['getfile']))
3575 - {
3576 - $cur_id = $_GET['getfile'];
3577 - $cur_post = & get_post($cur_id);
3578 -
3579 - if($cur_post->post_type == 'attachment' && $this->check_access($cur_post->ID))
3580 - {
3581 - $file = str_replace(get_option('siteurl').'/', "", $cur_post->guid);
3582 - $filename = basename($file);
3583 -
3584 - if(file_exists($file))
3585 - {
3586 - $len = filesize($file);
3587 - header('content-type: '.$cur_post->post_mime_type);
3588 - header('content-length: '.$len);
3589 -
3590 - if(wp_attachment_is_image($cur_id))
3591 - {
3592 - readfile($file);
3593 - exit;
3594 - }
3595 - else
3596 - {
3597 - header('content-disposition: attachment; filename='.basename($file));
3598 - if($uamOptions['download_type'] == 'fopen')
3599 - {
3600 - $fp=fopen($file, 'rb');
3601 -
3602 - while ( ! feof($fp) )
3603 - {
3604 - set_time_limit(30);
3605 - $buffer = fread($fp, 1024);
3606 - echo $buffer;
3607 - }
3608 - exit;
3609 - }
3610 - else
3611 - {
3612 - readfile($file);
3613 - exit;
3614 - }
3615 - }
3616 - }
3617 - else
3618 - {
3619 - echo 'Error: File not found';
3620 - }
3621 - }
3622 - elseif(wp_attachment_is_image($cur_id))
3623 - {
3624 - $file = UAM_URLPATH .'gfx/no_access_pic.png';
3625 - $filename = basename($file);
3626 -
3627 - if(file_exists($file))
3628 - {
3629 - $len = filesize($file);
3630 - header('content-type: '.$cur_post->post_mime_type);
3631 - header('content-length: '.$len);
3632 -
3633 - readfile($file);
3634 - exit;
3635 - }
3636 - else
3637 - {
3638 - echo 'Error: File not found';
3639 - }
3640 - }
3641 - }
3642 - }
3643 -
3644 - function get_file($URL, $ID)
3645 - {
3646 - $uamOptions = $this->getAdminOptions();
3647 -
3648 - if($uamOptions['lock_file'] == 'true')
3649 - {
3650 - $cur_id = $ID;
3651 - $cur_post = & get_post($cur_id);
3652 - $cur_parent_id = $cur_post->post_parent;
3653 - $cur_parent = & get_post($cur_parent_id);
3654 -
3655 - $type = explode("/", $cur_post->post_mime_type);
3656 - $type = $type[1];
3657 -
3658 - $file_types = $uamOptions['locked_file_types'];
3659 - $file_types = explode(",", $file_types);
3660 -
3661 - if(in_array($type, $file_types) || $uamOptions['lock_file_types'] == 'all')
3662 - {
3663 - $cur_guid = get_bloginfo('url');
3664 -
3665 - $URL = $cur_guid.'?getfile='.$cur_post->ID;
3666 - }
3667 - }
3668 - return $URL;
3669 - }
3670 - }
209 +if (!function_exists("userAccessManagerAPMenu")) {
210 + /**
211 + * Creates the menu at the admin panel
212 + *
213 + * @return null;
214 + */
215 + function userAccessManagerAPMenu()
216 + {
217 + global $oUserAccessManager;
218 + $oCurrentUser = $oUserAccessManager->getCurrentUser();
219 +
220 + if (!isset($oUserAccessManager)) {
221 + return;
222 + }
223 +
224 + $aUamOptions = $oUserAccessManager->getAdminOptions();
225 +
226 + if (ini_get('safe_mode')
227 + && $aUamOptions['download_type'] == 'fopen'
228 + ) {
229 + add_action(
230 + 'admin_notices',
231 + create_function(
232 + '',
233 + 'echo \'<div id="message" class="error"><p><strong>'.
234 + TXT_UAM_FOPEN_WITHOUT_SAVEMODE_OFF.
235 + '</strong></p></div>\';'
236 + )
237 + );
238 + }
239 +
240 + $oCurUserData = get_userdata($oCurrentUser->ID);
241 + $oUamAccessHandler = $oUserAccessManager->getAccessHandler();
242 +
243 + if ($oUamAccessHandler->checkUserAccess()) {
244 + //TODO
245 + /**
246 + * --- BOF ---
247 + * Not the best way to handle full user access capabilities seems
248 + * to be the right way, but it is way difficult.
249 + */
250 +
251 + //Admin main menu
252 + if (function_exists('add_menu_page')) {
253 + add_menu_page('User Access Manager', 'UAM', 'manage_options', 'uam_usergroup', array($oUserAccessManager, 'printAdminPage'), 'div');
254 + }
255 +
256 + //Admin sub menus
257 + if (function_exists('add_submenu_page')) {
258 + add_submenu_page('uam_usergroup', TXT_UAM_MANAGE_GROUP, TXT_UAM_MANAGE_GROUP, 'read', 'uam_usergroup', array($oUserAccessManager, 'printAdminPage'));
259 + add_submenu_page('uam_usergroup', TXT_UAM_SETTINGS, TXT_UAM_SETTINGS, 'read', 'uam_settings', array($oUserAccessManager, 'printAdminPage'));
260 + add_submenu_page('uam_usergroup', TXT_UAM_SETUP, TXT_UAM_SETUP, 'read', 'uam_setup', array($oUserAccessManager, 'printAdminPage'));
261 + add_submenu_page('uam_usergroup', TXT_UAM_ABOUT, TXT_UAM_ABOUT, 'read', 'uam_about', array($oUserAccessManager, 'printAdminPage'));
262 +
263 + do_action('uam_add_submenu');
264 + }
265 + /**
266 + * --- EOF ---
267 + */
268 + }
269 +
270 + if ($oUamAccessHandler->checkUserAccess()
271 + || $aUamOptions['authors_can_add_posts_to_groups'] == 'true'
272 + ) {
273 + //Admin meta boxes
274 + if (function_exists('add_meta_box')) {
275 + $aPostableTypes = $oUamAccessHandler->getPostableTypes();
276 +
277 + foreach ($aPostableTypes as $sPostableType) {
278 + add_meta_box('uma_post_access', 'Access', array($oUserAccessManager, 'editPostContent'), $sPostableType, 'side');
279 + }
280 +
281 + /*add_meta_box('uma_post_access', 'Access', array($oUserAccessManager, 'editPostContent'), 'post', 'side');
282 + add_meta_box('uma_post_access', 'Access', array($oUserAccessManager, 'editPostContent'), 'page', 'side');*/
283 + }
284 + }
285 + }
3671 286 }
3672 287
3673 -if(class_exists("UserAccessManager"))
3674 -{
3675 - $userAccessManager = new UserAccessManager();
288 +if (!function_exists("userAccessManagerUninstall")) {
289 + function userAccessManagerUninstall() {
290 + $oUserAccessManager = new UserAccessManager();
291 + $oUserAccessManager->uninstall();
292 + }
3676 293 }
3677 294
3678 -//Initialize the admin panel
3679 -if(!function_exists("UserAccessManager_AP")) {
3680 - function UserAccessManager_AP()
3681 - {
3682 - global $userAccessManager, $wp_version, $current_user, $wpdb;
3683 -
3684 - $userAccessManager->atAdminPanel = true;
3685 - $uamOptions = $userAccessManager->getAdminOptions();
3686 -
3687 - if (!isset($userAccessManager))
3688 - {
3689 - return;
3690 - }
3691 - if (function_exists('add_menu_page'))
3692 - {
3693 - add_menu_page('User Access Manager', 'UAM', 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage'), UAM_URLPATH."gfx/icon.png");
3694 - }
3695 - if (function_exists('add_submenu_page'))
3696 - {
3697 - add_submenu_page('uam_usergroup', TXT_MANAGE_GROUP, TXT_MANAGE_GROUP, 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage'));
3698 - add_submenu_page('uam_usergroup', TXT_SETTINGS, TXT_SETTINGS, 9, 'uam_settings', array(&$userAccessManager, 'printAdminPage'));
3699 - add_submenu_page('uam_usergroup', TXT_SETUP, TXT_SETUP, 9, 'uam_setup', array(&$userAccessManager, 'printAdminPage'));
3700 - }
3701 - if( function_exists( 'add_meta_box' ))
3702 - {
3703 - get_currentuserinfo();
3704 - $cur_userdata = get_userdata($current_user->ID);
295 +if (isset($oUserAccessManager)) {
296 + //install
297 + if (function_exists('register_activation_hook')) {
298 + register_activation_hook(__FILE__, array($oUserAccessManager, 'install'));
299 + }
300 +
301 + //uninstall
302 + if (function_exists('register_uninstall_hook')) {
303 + register_uninstall_hook(__FILE__, 'userAccessManagerUninstall');
304 + } elseif (function_exists('register_deactivation_hook')) {
305 + //Fallback
306 + register_deactivation_hook(__FILE__, array($oUserAccessManager, 'uninstall'));
307 + }
308 +
309 + //deactivation
310 + if (function_exists('register_deactivation_hook')) {
311 + register_deactivation_hook(__FILE__, array($oUserAccessManager, 'deactivate'));
312 + }
313 +
314 + //Redirect
315 + $aUamOptions = $oUserAccessManager->getAdminOptions();
316 +
317 + if ($aUamOptions['redirect'] != 'false' || isset($_GET['uamgetfile'])) {
318 + add_filter('wp_headers', array($oUserAccessManager, 'redirect'), 10, 2);
319 + }
3705 320
3706 - if($cur_userdata->user_level == $uamOptions['full_access_level'])
3707 - {
3708 - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'post', 'side' );
3709 - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'page', 'side' );
3710 - }
3711 - }
3712 -
3713 -
3714 - //Admin actions
3715 -
3716 - $userAccessManager->update();
3717 -
3718 - add_action('manage_posts_custom_column', array(&$userAccessManager, 'add_post_column'), 10, 2);
3719 - add_action('manage_pages_custom_column', array(&$userAccessManager, 'add_post_column'), 10, 2);
3720 - add_action('manage_media_custom_column', array(&$userAccessManager, 'add_post_column'), 10, 2);
3721 - add_action('save_post', array(&$userAccessManager, 'save_postdata'));
3722 - add_action('add_attachment', array(&$userAccessManager, 'save_postdata'));
3723 - add_action('attachment_fields_to_save', array(&$userAccessManager, 'save_attachmentdata'));
3724 - add_action('delete_post', array(&$userAccessManager, 'remove_postdata'));
3725 - add_action('delete_attachment', array(&$userAccessManager, 'remove_postdata'));
3726 -
3727 - add_action('edit_user_profile', array(&$userAccessManager, 'show_user_profile'));
3728 - add_action('profile_update', array(&$userAccessManager, 'save_userdata'));
3729 - add_action('delete_user', array(&$userAccessManager, 'remove_userdata'));
3730 -
3731 - add_action('edit_category_form', array(&$userAccessManager, 'show_cat_edit_form'));
3732 - add_action('edit_category', array(&$userAccessManager, 'save_categorydata'));
3733 - add_action('delete_category', array(&$userAccessManager, 'remove_categorydata'));
3734 -
3735 - add_action('wp_print_scripts', array(&$userAccessManager, 'add_scripts') );
3736 - add_action('wp_print_styles', array(&$userAccessManager, 'add_styles') );
3737 -
3738 -
3739 - //Admin filters
3740 -
3741 - add_filter('manage_posts_columns', array(&$userAccessManager, 'add_post_columns_header'));
3742 - add_filter('manage_pages_columns', array(&$userAccessManager, 'add_post_columns_header'));
3743 -
3744 - $uamOptions = $userAccessManager->getAdminOptions();
3745 -
3746 - if($uamOptions['lock_file'] == 'true')
3747 - {
3748 - add_action('media_meta', array(&$userAccessManager, 'show_media_file'), 10 , 2);
3749 - add_filter('manage_media_columns', array(&$userAccessManager, 'add_post_columns_header'));
3750 - }
3751 -
3752 - if($wp_version >= 2.8 || $uamOptions['core_mod'] == 'true')
3753 - {
3754 - add_filter('manage_users_columns', array(&$userAccessManager, 'add_user_columns_header'), 10);
3755 - add_filter('manage_users_custom_column', array(&$userAccessManager, 'add_user_column'), 10, 2);
3756 - add_filter('manage_categories_columns', array(&$userAccessManager, 'add_category_columns_header'));
3757 - add_filter('manage_categories_custom_column', array(&$userAccessManager, 'add_category_column'), 10, 2);
3758 - }
3759 - }
321 + //Actions
322 + if (function_exists('add_action')) {
323 + add_action('wp_print_scripts', array($oUserAccessManager, 'addScripts'));
324 + add_action('wp_print_styles', array($oUserAccessManager, 'addStyles'));
325 + add_action('admin_init', 'userAccessManagerAP');
326 + add_action('admin_menu', 'userAccessManagerAPMenu');
327 + }
328 +
329 + //Filters
330 + if (function_exists('add_filter')) {
331 + add_filter('wp_get_attachment_thumb_url', array($oUserAccessManager, 'getFileUrl'), 10, 2);
332 + add_filter('wp_get_attachment_url', array($oUserAccessManager, 'getFileUrl'), 10, 2);
333 + add_filter('the_posts', array($oUserAccessManager, 'showPost'));
334 + add_filter('posts_where_paged', array($oUserAccessManager, 'showPostSql'));
335 + add_filter('wp_get_nav_menu_items', array($oUserAccessManager, 'showCustomMenu'));
336 + add_filter('comments_array', array($oUserAccessManager, 'showComment'));
337 + add_filter('the_comments', array($oUserAccessManager, 'showComment'));
338 + add_filter('get_pages', array($oUserAccessManager, 'showPage'));
339 + add_filter('get_terms', array($oUserAccessManager, 'showTerms'), 10, 2);
340 + add_filter('get_next_post_where', array($oUserAccessManager, 'showNextPreviousPost'));
341 + add_filter('get_previous_post_where', array($oUserAccessManager, 'showNextPreviousPost'));
342 + add_filter('post_link', array($oUserAccessManager, 'cachePostLinks'), 10, 2);
343 + add_filter('edit_post_link', array($oUserAccessManager, 'showGroupMembership'), 10, 2);
344 + add_filter('parse_query', array($oUserAccessManager, 'parseQuery'));
345 + add_filter('getarchives_where', array($oUserAccessManager, 'showPostSql'));
346 + add_filter('wpseo_sitemap_entry', array($oUserAccessManager, 'wp_seo_url'), 1, 3); // Yaost Sitemap Plugin
347 + }
3760 348 }
3761 349
3762 -//Actions and Filters
3763 -if(isset($userAccessManager))
3764 -{
3765 - add_action('init', array(&$userAccessManager, 'init'));
3766 - $uamOptions = $userAccessManager->getAdminOptions();
3767 -
3768 - //install
3769 - if(function_exists('register_activation_hook'))
3770 - register_activation_hook(__FILE__, array(&$userAccessManager, 'install'));
3771 -
3772 - if(function_exists('register_uninstall_hook'))
3773 - register_uninstall_hook(__FILE__, array(&$userAccessManager, 'uninstall'));
3774 - elseif(function_exists('register_deactivation_hook'))
3775 - register_deactivation_hook(__FILE__, array(&$userAccessManager, 'uninstall'));
3776 -
3777 - if(function_exists('register_deactivation_hook'))
3778 - register_deactivation_hook(__FILE__, array(&$userAccessManager, 'deactivate'));
3779 -
3780 - //Actions
3781 - add_action('admin_menu', 'UserAccessManager_AP');
3782 -
3783 - if($uamOptions['redirect'] != 'false' || isset($_GET['getfile']))
3784 - add_action('template_redirect', array(&$userAccessManager, 'redirect_user'));
3785 -
3786 - //Filters
3787 - add_filter('wp_get_attachment_thumb_url', array(&$userAccessManager, 'get_file'), 10, 2);
3788 - add_filter('wp_get_attachment_url', array(&$userAccessManager, 'get_file'), 10, 2);
3789 - add_filter('the_posts', array(&$userAccessManager, 'show_post'));
3790 - add_filter('comments_array', array(&$userAccessManager, 'show_comment'));
3791 - add_filter('get_pages', array(&$userAccessManager, 'show_page'));
3792 - add_filter('get_terms', array(&$userAccessManager, 'show_category'));
3793 - add_filter('get_next_post_where', array(&$userAccessManager, 'show_next_previous_post'));
3794 - add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post'));
3795 - add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post'));
3796 - add_filter('the_title', array(&$userAccessManager, 'show_title'), 10, 2);
3797 - add_filter('posts_where', array(&$userAccessManager, 'show_post_sql'));
3798 -}
3799 -?>
350 +//Add the cli interface to the known commands
351 +if (defined('WP_CLI') && WP_CLI) {
352 + include __DIR__.'/includes/wp-cli.php';
353 +}