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