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