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