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