| @@ -2,11 +2,11 @@ | ||
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: User Access Manager |
| 4 | 4 | Plugin URI: http://www.gm-alex.de/projects/wordpress/plugins/user-access-manager/ |
| 5 | 5 | Author URI: http://www.gm-alex.de/ |
| 6 | -Version: 0.9.1.4 | |
| 6 | +Version: 0.8.0.2 | |
| 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 media files insert in a previous post/page will not work anymore. You have to update your posts/pages. If you use already a '.htaccess' file to protect your files the plugin will <strong>overwrite</strong> the '.htaccess'. You can disabel the file locking and set up an other password for the '.htaccess' file at the UAM setting page.</em> | |
| 8 | +Description: Manage the access to your posts and pages. <strong>Note:</strong> <em>If you activate the plugin your upload dir will protect by a '.htaccess' with a random password and all old downloads insert in a previous post/page will not work anymore. You have to update your posts/pages. If you use already a '.htaccess' file to protect your files the plugin will <strong>overwrite</strong> the '.htaccess'. You can disabel the file locking and set up an other password for the '.htaccess' file at the UAM setting page.</em> | |
| 9 | 9 | |
| 10 | 10 | Copyright 2008 Alexander Schneider (email : alexanderschneider85 [at] gmail DOT com) |
| 11 | 11 | |
| 12 | 12 | This program is free software; you can redistribute it and/or modify |
| @@ -34,11 +34,12 @@ | ||
| 34 | 34 | define('DB_ACCESSGROUP_TO_CATEGORY', $wpdb->prefix.'uam_accessgroup_to_category'); |
| 35 | 35 | define('DB_ACCESSGROUP_TO_ROLE', $wpdb->prefix.'uam_accessgroup_to_role'); |
| 36 | 36 | |
| 37 | 37 | //PATH |
| 38 | -//define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/' ); | |
| 39 | -define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/user-access-manager/' ); //Localhost DEBUG | |
| 38 | +define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/' ); | |
| 40 | 39 | |
| 40 | +//###Lang### | |
| 41 | + | |
| 41 | 42 | if (!class_exists("UserAccessManager")) |
| 42 | 43 | { |
| 43 | 44 | class UserAccessManager |
| 44 | 45 | { |
| @@ -45,9 +46,8 @@ | ||
| 45 | 46 | var $adminOptionsName = "uamAdminOptions"; |
| 46 | 47 | var $atAdminPanel = false; |
| 47 | 48 | var $restrictedPost = array(); |
| 48 | 49 | var $postAccess = array(); |
| 49 | - var $postUserGroup = array(); | |
| 50 | 50 | var $uam_db_version = "1.1"; |
| 51 | 51 | var $adminOptions; |
| 52 | 52 | |
| 53 | 53 | function UserAccessManager() |
| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function init() |
| 59 | 59 | { |
| 60 | - load_plugin_textdomain('user-access-manager', 'wp-content/plugins/user-access-manager'); | |
| 60 | + echo load_plugin_textdomain('user-access-manager', 'wp-content/plugins/user-access-manager'); | |
| 61 | 61 | |
| 62 | 62 | //---Lang Settings--- |
| 63 | 63 | define('TXT_SETTINGS', __('Settings', 'user-access-manager')); |
| 64 | 64 | |
| @@ -68,11 +68,9 @@ | ||
| 68 | 68 | define('TXT_POST_TITLE_DESC', __('Displayed text as post title if user has no access', 'user-access-manager')); |
| 69 | 69 | define('TXT_DISPLAY_POST_TITLE', __('Hide post titel', 'user-access-manager')); |
| 70 | 70 | define('TXT_DISPLAY_POST_TITLE_DESC', sprintf(__('Selecting "Yes" will show the text which is defined at "%s" if user has no access.', 'user-access-manager'), TXT_POST_TITLE)); |
| 71 | 71 | define('TXT_POST_CONTENT', __('Post content', 'user-access-manager')); |
| 72 | - define('TXT_POST_CONTENT_DESC', __('Content displayed if user has no access. You can add an login-form by adding the keyword <b>[LOGIN_FORM]</b>. This form will shown on single posts, otherwise a link will shown.', 'user-access-manager')); | |
| 73 | - define('TXT_SHOW_POST_CONTENT_BEFORE_MORE', __('Show post content before <!--more--> tag', 'user-access-manager')); | |
| 74 | - define('TXT_SHOW_POST_CONTENT_BEFORE_MORE_DESC', sprintf(__('Shows the post content before the <!--more--> tag and after that the defined text at "%s". If no <!--more--> is set he defined text at "%s" will shown.', 'user-access-manager'), TXT_POST_CONTENT, TXT_POST_CONTENT)); | |
| 72 | + define('TXT_POST_CONTENT_DESC', __('Content displayed if user has no access', 'user-access-manager')); | |
| 75 | 73 | define('TXT_HIDE_POST', __('Hide complete posts', 'user-access-manager')); |
| 76 | 74 | define('TXT_HIDE_POST_DESC', __('Selecting "Yes" will hide posts if the user has no access.', 'user-access-manager')); |
| 77 | 75 | define('TXT_POST_COMMENT_CONTENT', __('Post commtent text', 'user-access-manager')); |
| 78 | 76 | define('TXT_POST_COMMENT_CONTENT_DESC', __('Displayed text as post comment text if user has no access', 'user-access-manager')); |
| @@ -87,9 +85,9 @@ | ||
| 87 | 85 | define('TXT_PAGE_TITLE_DESC', __('Displayed text as page title if user has no access', 'user-access-manager')); |
| 88 | 86 | define('TXT_DISPLAY_PAGE_TITLE', __('Hide page titel', 'user-access-manager')); |
| 89 | 87 | define('TXT_DISPLAY_PAGE_TITLE_DESC', sprintf(__('Selecting "Yes" will show the text which is defined at "%s" if user has no access.', 'user-access-manager'), TXT_POST_TITLE)); |
| 90 | 88 | define('TXT_PAGE_CONTENT', __('Page content', 'user-access-manager')); |
| 91 | - define('TXT_PAGE_CONTENT_DESC', __('Content displayed if user has no access. You can add an login-form by adding the keyword <b>[LOGIN_FORM]</b>. This form will shown on single pages, otherwise a link will shown.', 'user-access-manager')); | |
| 89 | + define('TXT_PAGE_CONTENT_DESC', __('Content displayed if user has no access', 'user-access-manager')); | |
| 92 | 90 | define('TXT_HIDE_PAGE', __('Hide complete pages', 'user-access-manager')); |
| 93 | 91 | define('TXT_HIDE_PAGE_DESC', __('Selecting "Yes" will hide pages if the user has no access. Pages will also hide in the navigation.', 'user-access-manager')); |
| 94 | 92 | |
| 95 | 93 | define('TXT_FILE_SETTING', __('File settings', 'user-access-manager')); |
| @@ -110,10 +108,8 @@ | ||
| 110 | 108 | define('TXT_FOPEN', __('fopen', 'user-access-manager')); |
| 111 | 109 | |
| 112 | 110 | define('TXT_OTHER_SETTING', __('Other settings', 'user-access-manager')); |
| 113 | 111 | define('TXT_OTHER_SETTING_DESC', __('Here you will find all other settings', 'user-access-manager')); |
| 114 | - define('TXT_PROTECT_FEED', __('Protect Feed', 'user-access-manager')); | |
| 115 | - define('TXT_PROTECT_FEED_DESC', __('Selecting "Yes" will also protect your feed entries.', 'user-access-manager')); | |
| 116 | 112 | define('TXT_HIDE_EMPTY_CATEGORIES', __('Hide empty categories', 'user-access-manager')); |
| 117 | 113 | define('TXT_HIDE_EMPTY_CATEGORIES_DESC', __('Selecting "Yes" will hide empty categories which are containing only empty childs or no childs.', 'user-access-manager')); |
| 118 | 114 | define('TXT_REDIRECT', __('Redirect user', 'user-access-manager')); |
| 119 | 115 | define('TXT_REDIRECT_DESC', __('Setup what happen if a user visit a post/page with no access.', 'user-access-manager')); |
| @@ -125,10 +121,8 @@ | ||
| 125 | 121 | define('TXT_BLOG_ADMIN_HINT_TEXT', __('Admin hint text', 'user-access-manager')); |
| 126 | 122 | define('TXT_BLOG_ADMIN_HINT_TEXT_DESC', __('The text which will shown behinde the post/page.', 'user-access-manager')); |
| 127 | 123 | define('TXT_BLOG_ADMIN_HINT', __('Show admin hint at Posts', 'user-access-manager')); |
| 128 | 124 | define('TXT_BLOG_ADMIN_HINT_DESC', sprintf(__('Selecting "Yes" will show the defined text at "%s" behinde the post/page to an logged in admin to show him which posts/pages are locked if he visits his blog.', 'user-access-manager'), TXT_BLOG_ADMIN_HINT_TEXT)); |
| 129 | - define('TXT_FULL_ACCESS_LEVEL', __('Access Level with full access', 'user-access-manager')); | |
| 130 | - define('TXT_FULL_ACCESS_LEVEL_DESC', __('All user with access level equal or higher to this has full access. <b>Note: 10 is the highest value.</b>', 'user-access-manager')); | |
| 131 | 125 | define('TXT_CORE_MOD', __('Core modifications installed?', 'user-access-manager')); |
| 132 | 126 | define('TXT_CORE_MOD_DESC', __('If you installed the core modifications activated this option.', 'user-access-manager')); |
| 133 | 127 | |
| 134 | 128 | define('TXT_YES', __('Yes', 'user-access-manager')); |
| @@ -208,14 +202,8 @@ | ||
| 208 | 202 | define('TXT_COLLAPS', __('collaps', 'user-access-manager')); |
| 209 | 203 | define('TXT_COLLAPS_ALL', __('collaps all', 'user-access-manager')); |
| 210 | 204 | define('TXT_ALL', __('all', 'user-access-manager')); |
| 211 | 205 | define('TXT_ONLY_GROUP_USERS', __('only group users', 'user-access-manager')); |
| 212 | - | |
| 213 | - define('TXT_SETUP', __('Setup', 'user-access-manager')); | |
| 214 | - define('TXT_RESET_UAM', __('Reset User Access Manager', 'user-access-manager')); | |
| 215 | - define('TXT_RESET_UAM_DESC', __('Warning: The reset of the User Access Manager can not be undone. All settings and user groups will permanently lost.', 'user-access-manager')); | |
| 216 | - define('TXT_RESET', __('reset', 'user-access-manager')); | |
| 217 | - define('TXT_UAM_RESET_SUC', __('User Access Manager was reset successfully', 'user-access-manager')); | |
| 218 | 206 | } |
| 219 | 207 | |
| 220 | 208 | function install() |
| 221 | 209 | { |
| @@ -303,11 +291,8 @@ | ||
| 303 | 291 | global $wpdb; |
| 304 | 292 | $uam_db_version = $this->uam_db_version; |
| 305 | 293 | $installed_ver = get_option( "uam_db_version" ); |
| 306 | 294 | |
| 307 | - if(empty($installed_ver)) | |
| 308 | - $this->install(); | |
| 309 | - | |
| 310 | 295 | if($installed_ver != $uam_db_version) |
| 311 | 296 | { |
| 312 | 297 | if($installed_ver == '1.0') |
| 313 | 298 | { |
| @@ -318,14 +303,11 @@ | ||
| 318 | 303 | update_option("uam_db_version", $uam_db_version); |
| 319 | 304 | } |
| 320 | 305 | } |
| 321 | 306 | } |
| 322 | - if($wpdb->get_var("show tables like '".DB_ACCESSGROUP."'") == DB_ACCESSGROUP) | |
| 307 | + if($wpdb->get_var("show columns from ".DB_ACCESSGROUP." like 'ip_range'") != 'ip_range') | |
| 323 | 308 | { |
| 324 | - if($wpdb->get_var("show columns from ".DB_ACCESSGROUP." like 'ip_range'") != 'ip_range') | |
| 325 | - { | |
| 326 | - $wpdb->query("ALTER TABLE ".DB_ACCESSGROUP." ADD ip_range MEDIUMTEXT NULL DEFAULT ''"); | |
| 327 | - } | |
| 309 | + $wpdb->query("ALTER TABLE ".DB_ACCESSGROUP." ADD ip_range MEDIUMTEXT NULL DEFAULT ''"); | |
| 328 | 310 | } |
| 329 | 311 | } |
| 330 | 312 | |
| 331 | 313 | function uninstall() |
| @@ -331,10 +313,8 @@ | ||
| 331 | 313 | function uninstall() |
| 332 | 314 | { |
| 333 | 315 | global $wpdb; |
| 334 | 316 | $wpdb->query("DROP TABLE ".DB_ACCESSGROUP.", ".DB_ACCESSGROUP_TO_POST.", ".DB_ACCESSGROUP_TO_USER.", ".DB_ACCESSGROUP_TO_CATEGORY.", ".DB_ACCESSGROUP_TO_ROLE); |
| 335 | - delete_option($this->adminOptionsName); | |
| 336 | - delete_option("uam_db_version"); | |
| 337 | 317 | $this->delete_htaccess_files(); |
| 338 | 318 | } |
| 339 | 319 | |
| 340 | 320 | function deactivate() |
| @@ -510,12 +490,9 @@ | ||
| 510 | 490 | 'not_locked_file_types' => 'gif,jpg,jpeg,png', |
| 511 | 491 | 'blog_admin_hint' => 'true', |
| 512 | 492 | 'blog_admin_hint_text' => '[L]', |
| 513 | 493 | 'core_mod' => 'false', |
| 514 | - 'hide_empty_categories' => 'true', | |
| 515 | - 'protect_feed' => 'true', | |
| 516 | - 'show_post_content_before_more' => 'false', | |
| 517 | - 'full_access_level' => 10); | |
| 494 | + 'hide_empty_categories' => 'true'); | |
| 518 | 495 | |
| 519 | 496 | $uamOptions = get_option($this->adminOptionsName); |
| 520 | 497 | if (!empty($uamOptions)) { |
| 521 | 498 | foreach ($uamOptions as $key => $option) |
| @@ -543,12 +520,8 @@ | ||
| 543 | 520 | if (isset($_POST['uam_post_title'])) |
| 544 | 521 | { |
| 545 | 522 | $uamOptions['post_title'] = $_POST['uam_post_title']; |
| 546 | 523 | } |
| 547 | - if (isset($_POST['uam_show_post_content_before_more'])) | |
| 548 | - { | |
| 549 | - $uamOptions['show_post_content_before_more'] = $_POST['uam_show_post_content_before_more']; | |
| 550 | - } | |
| 551 | 524 | if (isset($_POST['uam_post_content'])) |
| 552 | 525 | { |
| 553 | 526 | $uamOptions['post_content'] = $_POST['uam_post_content']; |
| 554 | 527 | } |
| @@ -583,12 +556,8 @@ | ||
| 583 | 556 | if (isset($_POST['uam_hide_page'])) |
| 584 | 557 | { |
| 585 | 558 | $uamOptions['hide_page'] = $_POST['uam_hide_page']; |
| 586 | 559 | } |
| 587 | - if (isset($_POST['uam_protect_feed'])) | |
| 588 | - { | |
| 589 | - $uamOptions['protect_feed'] = $_POST['uam_protect_feed']; | |
| 590 | - } | |
| 591 | 560 | if (isset($_POST['uam_hide_empty_categories'])) |
| 592 | 561 | { |
| 593 | 562 | $uamOptions['hide_empty_categories'] = $_POST['uam_hide_empty_categories']; |
| 594 | 563 | } |
| @@ -619,12 +588,8 @@ | ||
| 619 | 588 | if (isset($_POST['uam_core_mod'])) |
| 620 | 589 | { |
| 621 | 590 | $uamOptions['core_mod'] = $_POST['uam_core_mod']; |
| 622 | 591 | } |
| 623 | - if (isset($_POST['uam_full_access_level']) && is_numeric($_POST['uam_full_access_level']) && $_POST['uam_full_access_level'] <= 10) | |
| 624 | - { | |
| 625 | - $uamOptions['full_access_level'] = $_POST['uam_full_access_level']; | |
| 626 | - } | |
| 627 | 592 | if (isset($_POST['uam_lock_file'])) |
| 628 | 593 | { |
| 629 | 594 | if($_POST['uam_lock_file'] == 'false') |
| 630 | 595 | { |
| @@ -836,25 +801,8 @@ | ||
| 836 | 801 | <div class="updated"><p><strong><?php echo TXT_ACCESS_GROUP_EDIT_SUC; ?></strong></p></div> |
| 837 | 802 | <?php |
| 838 | 803 | } |
| 839 | 804 | } |
| 840 | - | |
| 841 | - if($post_action == 'reset_uam') | |
| 842 | - { | |
| 843 | - if(isset($_POST['uam_reset'])) | |
| 844 | - $reset = $_POST['uam_reset']; | |
| 845 | - else | |
| 846 | - $reset = null; | |
| 847 | - | |
| 848 | - if($reset == 'true') | |
| 849 | - { | |
| 850 | - $this->uninstall(); | |
| 851 | - $this->install(); | |
| 852 | - ?> | |
| 853 | - <div class="updated"><p><strong><?php echo TXT_UAM_RESET_SUC; ?></strong></p></div> | |
| 854 | - <?php | |
| 855 | - } | |
| 856 | - } | |
| 857 | 805 | |
| 858 | 806 | if($cur_admin_page == 'uam_settings') |
| 859 | 807 | { |
| 860 | 808 | ?> |
| @@ -914,25 +862,8 @@ | ||
| 914 | 862 | </td> |
| 915 | 863 | </tr> |
| 916 | 864 | <tr valign="top"> |
| 917 | 865 | <th scope="row"> |
| 918 | - <?php echo TXT_SHOW_POST_CONTENT_BEFORE_MORE; ?> | |
| 919 | - </th> | |
| 920 | - <td> | |
| 921 | - <label for="uam_show_post_content_before_more_yes"> | |
| 922 | - <input type="radio" id="uam_hide_post_title_yes" name="uam_show_post_content_before_more" value="true" <?php if ($uamOptions['show_post_content_before_more'] == "true") { echo 'checked="checked"'; }?> /> | |
| 923 | - <?php echo TXT_YES; ?> | |
| 924 | - </label> | |
| 925 | - <label for="uam_show_post_content_before_more_no"> | |
| 926 | - <input type="radio" id="uam_hide_post_title_no" name="uam_show_post_content_before_more" value="false" <?php if ($uamOptions['show_post_content_before_more'] == "false") { echo 'checked="checked"'; }?>/> | |
| 927 | - <?php echo TXT_NO; ?> | |
| 928 | - </label> | |
| 929 | - <br /> | |
| 930 | - <?php echo TXT_SHOW_POST_CONTENT_BEFORE_MORE_DESC; ?> | |
| 931 | - </td> | |
| 932 | - </tr> | |
| 933 | - <tr valign="top"> | |
| 934 | - <th scope="row"> | |
| 935 | 866 | <?php echo TXT_POST_CONTENT; ?> |
| 936 | 867 | </th> |
| 937 | 868 | <td> |
| 938 | 869 | <textarea name="uam_post_content" style="width: 80%; height: 100px;"><?php echo apply_filters('format_to_edit',$uamOptions['post_content']); ?></textarea> |
| @@ -1137,25 +1068,8 @@ | ||
| 1137 | 1068 | <table class="form-table"> |
| 1138 | 1069 | <tbody> |
| 1139 | 1070 | <tr> |
| 1140 | 1071 | <th> |
| 1141 | - <?php echo TXT_PROTECT_FEED; ?> | |
| 1142 | - </th> | |
| 1143 | - <td> | |
| 1144 | - <label for="uam_protect_feed_yes"> | |
| 1145 | - <input type="radio" id="uam_protect_feed_yes" name="uam_protect_feed" value="true" <?php if ($uamOptions['protect_feed'] == "true") { echo 'checked="checked"'; }?> /> | |
| 1146 | - <?php echo TXT_YES; ?> | |
| 1147 | - </label> | |
| 1148 | - <label for="uam_protect_feed_no"> | |
| 1149 | - <input type="radio" id="uam_protect_feed_no" name="uam_protect_feed" value="false" <?php if ($uamOptions['protect_feed'] == "false") { echo 'checked="checked"'; }?>/> | |
| 1150 | - <?php echo TXT_NO; ?> | |
| 1151 | - </label> | |
| 1152 | - <br /> | |
| 1153 | - <?php echo TXT_PROTECT_FEED_DESC; ?> | |
| 1154 | - </td> | |
| 1155 | - </tr> | |
| 1156 | - <tr> | |
| 1157 | - <th> | |
| 1158 | 1072 | <?php echo TXT_HIDE_EMPTY_CATEGORIES; ?> |
| 1159 | 1073 | </th> |
| 1160 | 1074 | <td> |
| 1161 | 1075 | <label for="uam_hide_empty_categories_yes"> |
| @@ -1254,18 +1168,8 @@ | ||
| 1254 | 1168 | <br /> |
| 1255 | 1169 | <?php echo TXT_BLOG_ADMIN_HINT_TEXT_DESC; ?> |
| 1256 | 1170 | </td> |
| 1257 | 1171 | </tr> |
| 1258 | - <tr> | |
| 1259 | - <th> | |
| 1260 | - <?php echo TXT_FULL_ACCESS_LEVEL; ?> | |
| 1261 | - </th> | |
| 1262 | - <td> | |
| 1263 | - <input name="uam_full_access_level" value="<?php echo $uamOptions['full_access_level']; ?>" /> | |
| 1264 | - <br /> | |
| 1265 | - <?php echo TXT_FULL_ACCESS_LEVEL_DESC; ?> | |
| 1266 | - </td> | |
| 1267 | - </tr> | |
| 1268 | 1172 | <?php |
| 1269 | 1173 | global $wp_version; |
| 1270 | 1174 | |
| 1271 | 1175 | if($wp_version < 2.8) |
| @@ -1472,40 +1376,8 @@ | ||
| 1472 | 1376 | <?php $this->get_print_edit_group(); ?> |
| 1473 | 1377 | </div> |
| 1474 | 1378 | <?php |
| 1475 | 1379 | } |
| 1476 | - elseif($cur_admin_page == 'uam_setup') | |
| 1477 | - { | |
| 1478 | - ?> | |
| 1479 | - <div class=wrap> | |
| 1480 | - <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>"> | |
| 1481 | - <input type="hidden" value="reset_uam" name="action"/> | |
| 1482 | - <h2><?php echo TXT_SETUP; ?></h2> | |
| 1483 | - <table class="form-table"> | |
| 1484 | - <tbody> | |
| 1485 | - <tr valign="top"> | |
| 1486 | - <th scope="row"> | |
| 1487 | - <?php echo TXT_RESET_UAM; ?> | |
| 1488 | - </th> | |
| 1489 | - <td> | |
| 1490 | - <label for="uam_reset_yes"> | |
| 1491 | - <input type="radio" id="uam_reset_yes" class="uam_reset_yes" name="uam_reset" value="true" /> | |
| 1492 | - <?php echo TXT_YES; ?> | |
| 1493 | - </label> | |
| 1494 | - <label for="uam_reset_no"> | |
| 1495 | - <input type="radio" id="uam_reset_no" class="uam_reset_no" name="uam_reset" value="false" checked="checked" /> | |
| 1496 | - <?php echo TXT_NO; ?> | |
| 1497 | - </label> <input type="submit" class="button" name="uam_reset_submit" value="<?php echo TXT_RESET; ?>" /> | |
| 1498 | - <br /> | |
| 1499 | - <p style="color:red; font-size: 12px; font-weight: bold;"><?php echo TXT_RESET_UAM_DESC; ?></p> | |
| 1500 | - </td> | |
| 1501 | - </tr> | |
| 1502 | - </tbody> | |
| 1503 | - </table> | |
| 1504 | - </form> | |
| 1505 | - </div> | |
| 1506 | - <?php | |
| 1507 | - } | |
| 1508 | 1380 | }//End function printAdminPage() |
| 1509 | 1381 | |
| 1510 | 1382 | function get_print_edit_group($group_id = null) |
| 1511 | 1383 | { |
| @@ -1721,11 +1593,10 @@ | ||
| 1721 | 1593 | ?> |
| 1722 | 1594 | </td> |
| 1723 | 1595 | </tr> |
| 1724 | 1596 | <tr> |
| 1725 | - <?php | |
| 1726 | - $args = array('hide_empty' => 0); | |
| 1727 | - $categories = get_categories($args); | |
| 1597 | + <?php | |
| 1598 | + $categories = get_categories(); | |
| 1728 | 1599 | ?> |
| 1729 | 1600 | <th valign="top" scope="row"><?php echo TXT_CATEGORY; if(count($categories) > 0){ echo " <label>(<a class='selectit uam_group_stuff_link'>".TXT_EXPAND."</a>)</label>"; } ?></th> |
| 1730 | 1601 | <td> |
| 1731 | 1602 | <?php |
| @@ -1810,9 +1681,9 @@ | ||
| 1810 | 1681 | $user_capabilities = array_keys($cur_user->{$wpdb->prefix."capabilities"}) |
| 1811 | 1682 | ?> |
| 1812 | 1683 | <li class="selectit <?php foreach($user_capabilities as $user_capability){ echo "usercap_".$user_capability." "; } ?>"> |
| 1813 | 1684 | <?php |
| 1814 | - if($cur_user->user_level < $uamOptions['full_access_level']) | |
| 1685 | + if(empty($cur_user->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 1815 | 1686 | { |
| 1816 | 1687 | ?> |
| 1817 | 1688 | <input id="user-<?php echo $cur_user->ID; ?>" type="checkbox" value="<?php echo $cur_user->ID; ?>" <?php if(isset($group_info->users[$cur_user->ID])){ echo 'checked="checked"'; } ?> name="user[]"/> |
| 1818 | 1689 | <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; ?> |
| @@ -1846,11 +1717,8 @@ | ||
| 1846 | 1717 | function get_usergroups_for_post($ID) |
| 1847 | 1718 | { |
| 1848 | 1719 | global $wpdb; |
| 1849 | 1720 | |
| 1850 | - if(isset($this->postUserGroup[$ID])) | |
| 1851 | - return $this->postUserGroup[$ID]; | |
| 1852 | - | |
| 1853 | 1721 | $access = $this->get_access($ID); |
| 1854 | 1722 | |
| 1855 | 1723 | $post_usergroups = array(); |
| 1856 | 1724 | |
| @@ -1883,9 +1751,9 @@ | ||
| 1883 | 1751 | if(isset($cur_usergroup->posts)) |
| 1884 | 1752 | $posts = $cur_usergroup->posts; |
| 1885 | 1753 | |
| 1886 | 1754 | $lock_post = & get_post($cur_id); |
| 1887 | - $posts[$lock_post->ID] = $lock_post->ID; | |
| 1755 | + $posts[] = $lock_post->ID; | |
| 1888 | 1756 | $cur_usergroup->posts = $posts; |
| 1889 | 1757 | } |
| 1890 | 1758 | else |
| 1891 | 1759 | { |
| @@ -1923,9 +1791,9 @@ | ||
| 1923 | 1791 | if(isset($cur_usergroup->categorie)) |
| 1924 | 1792 | $categories = $cur_usergroup->categories; |
| 1925 | 1793 | |
| 1926 | 1794 | $lock_cat = & get_category($cur_id); |
| 1927 | - $categories[$lock_cat->term_id] = $lock_cat->term_id; | |
| 1795 | + $categories[] = $lock_cat->term_id; | |
| 1928 | 1796 | $cur_usergroup->categories = $categories; |
| 1929 | 1797 | |
| 1930 | 1798 | $post_usergroups[$usergroup['ID']] = $cur_usergroup; |
| 1931 | 1799 | } |
| @@ -1935,10 +1803,8 @@ | ||
| 1935 | 1803 | } |
| 1936 | 1804 | } |
| 1937 | 1805 | } |
| 1938 | 1806 | |
| 1939 | - $this->postUserGroup[$ID] = $post_usergroups; | |
| 1940 | - | |
| 1941 | 1807 | return $post_usergroups; |
| 1942 | 1808 | } |
| 1943 | 1809 | |
| 1944 | 1810 | function get_usergroup_info($groupid) |
| @@ -1957,8 +1823,13 @@ | ||
| 1957 | 1823 | FROM ".DB_ACCESSGROUP_TO_USER." |
| 1958 | 1824 | WHERE group_id = ".$groupid." |
| 1959 | 1825 | ORDER BY user_id", ARRAY_A); |
| 1960 | 1826 | |
| 1827 | + $db_posts = $wpdb->get_results(" SELECT * | |
| 1828 | + FROM ".DB_ACCESSGROUP_TO_POST." | |
| 1829 | + WHERE group_id = ".$groupid." | |
| 1830 | + ORDER BY post_id", ARRAY_A); | |
| 1831 | + | |
| 1961 | 1832 | $db_categories = $wpdb->get_results(" SELECT * |
| 1962 | 1833 | FROM ".DB_ACCESSGROUP_TO_CATEGORY." |
| 1963 | 1834 | WHERE group_id = ".$groupid." |
| 1964 | 1835 | ORDER BY category_id", ARRAY_A); |
| @@ -1971,52 +1842,32 @@ | ||
| 1971 | 1842 | FROM $wpdb->users |
| 1972 | 1843 | ORDER BY user_nicename", ARRAY_A); |
| 1973 | 1844 | |
| 1974 | 1845 | |
| 1975 | - $args = array( 'numberposts' => -1, | |
| 1976 | - 'post_type' => 'any'); | |
| 1977 | - | |
| 1978 | - $posts = get_posts($args); | |
| 1979 | - | |
| 1980 | - if(isset($posts)) | |
| 1846 | + if(isset($db_posts)) | |
| 1981 | 1847 | { |
| 1982 | - foreach($posts as $post) | |
| 1983 | - { | |
| 1984 | - $groupinfo = $this->get_usergroups_for_post($post->ID); | |
| 1848 | + foreach($db_posts as $db_post) | |
| 1849 | + { | |
| 1850 | + $cur_id = $db_post['post_id']; | |
| 1851 | + $cur_post = & get_post($cur_id); | |
| 1985 | 1852 | |
| 1986 | - if(isset($groupinfo[$groupid])) | |
| 1853 | + if(isset($cur_post->post_type)) | |
| 1987 | 1854 | { |
| 1988 | - if($post->post_type == 'post') | |
| 1855 | + if($cur_post->post_type == 'post') | |
| 1989 | 1856 | { |
| 1990 | - $info->posts[$post->ID] = $post; | |
| 1857 | + $info->posts[$cur_id] = $cur_post; | |
| 1991 | 1858 | } |
| 1992 | - elseif($post->post_type == 'page') | |
| 1859 | + elseif($cur_post->post_type == 'page') | |
| 1993 | 1860 | { |
| 1994 | - $info->pages[$post->ID] = $post; | |
| 1861 | + $info->pages[$cur_id] = $cur_post; | |
| 1995 | 1862 | } |
| 1996 | - elseif($post->post_type == 'attachment') | |
| 1863 | + elseif($cur_post->post_type == 'attachment') | |
| 1997 | 1864 | { |
| 1998 | - $info->files[$post->ID] = $post; | |
| 1865 | + $info->files[$cur_id] = $cur_post; | |
| 1999 | 1866 | } |
| 2000 | 1867 | } |
| 2001 | 1868 | } |
| 2002 | 1869 | } |
| 2003 | - | |
| 2004 | - $args = array( 'numberposts' => -1, | |
| 2005 | - 'post_type' => 'attachment'); | |
| 2006 | - | |
| 2007 | - $files = get_posts($args); | |
| 2008 | - | |
| 2009 | - if(isset($files)) | |
| 2010 | - { | |
| 2011 | - foreach($files as $file) | |
| 2012 | - { | |
| 2013 | - $groupinfo = $this->get_usergroups_for_post($file->ID); | |
| 2014 | - | |
| 2015 | - if(isset($groupinfo[$groupid])) | |
| 2016 | - $info->files[$file->ID] = $file; | |
| 2017 | - } | |
| 2018 | - } | |
| 2019 | 1870 | |
| 2020 | 1871 | if(isset($db_categories)) |
| 2021 | 1872 | { |
| 2022 | 1873 | foreach($db_categories as $db_categorie) |
| @@ -2062,13 +1913,13 @@ | ||
| 2062 | 1913 | foreach($wp_users as $wp_user) |
| 2063 | 1914 | { |
| 2064 | 1915 | $cur_userdata = get_userdata($wp_user['ID']); |
| 2065 | 1916 | |
| 2066 | - if($cur_userdata->user_level >= $uamOptions['full_access_level']) | |
| 1917 | + if(isset($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2067 | 1918 | { |
| 2068 | 1919 | $info->users[$wp_user['ID']] = $cur_userdata; |
| 2069 | 1920 | } |
| 2070 | - elseif(isset($db_roles) && $cur_userdata->user_level < $uamOptions['full_access_level']) | |
| 1921 | + elseif(isset($db_roles) && empty($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2071 | 1922 | { |
| 2072 | 1923 | foreach($db_roles as $db_role) |
| 2073 | 1924 | { |
| 2074 | 1925 | if(isset($cur_userdata->{$wpdb->prefix."capabilities"}[$db_role['role_name']])) |
| @@ -2080,8 +1931,142 @@ | ||
| 2080 | 1931 | } |
| 2081 | 1932 | } |
| 2082 | 1933 | } |
| 2083 | 1934 | |
| 1935 | + | |
| 1936 | + if(isset($info->categories)) | |
| 1937 | + { | |
| 1938 | + foreach($info->categories as $group_category) | |
| 1939 | + { | |
| 1940 | + $cur_posts = get_posts('category='.$group_category->term_id); | |
| 1941 | + if(isset($cur_posts)) | |
| 1942 | + { | |
| 1943 | + foreach($cur_posts as $cur_post) | |
| 1944 | + { | |
| 1945 | + if($uamOptions['lock_recursive'] == 'false') | |
| 1946 | + { | |
| 1947 | + $cur_categories = get_the_category($cur_post->ID); | |
| 1948 | + foreach($cur_categories as $cur_cat) | |
| 1949 | + { | |
| 1950 | + if($cur_cat->term_id == $group_category->term_id) | |
| 1951 | + { | |
| 1952 | + $add = true; | |
| 1953 | + break; | |
| 1954 | + } | |
| 1955 | + } | |
| 1956 | + } | |
| 1957 | + | |
| 1958 | + if(isset($add) || $uamOptions['lock_recursive'] == 'true') | |
| 1959 | + { | |
| 1960 | + if(isset($info->posts[$cur_post->ID])) | |
| 1961 | + $cur_post = $info->posts[$cur_post->ID]; | |
| 1962 | + | |
| 1963 | + $cur_post->recursive_lock_by_category[$group_category->term_id] = $group_category->term_id; | |
| 1964 | + $info->posts[$cur_post->ID] = $cur_post; | |
| 1965 | + } | |
| 1966 | + } | |
| 1967 | + } | |
| 1968 | + | |
| 1969 | + $cur_files = get_posts('category='.$group_category->term_id.'&post_type=attachment'); | |
| 1970 | + if(isset($cur_files)) | |
| 1971 | + { | |
| 1972 | + foreach($cur_files as $cur_file) | |
| 1973 | + { | |
| 1974 | + if($uamOptions['lock_recursive'] == 'false') | |
| 1975 | + { | |
| 1976 | + $cur_categories = get_the_category($cur_post->ID); | |
| 1977 | + foreach($cur_categories as $cur_cat) | |
| 1978 | + { | |
| 1979 | + if($cur_cat->term_id == $group_category->term_id) | |
| 1980 | + { | |
| 1981 | + $add = true; | |
| 1982 | + break; | |
| 1983 | + } | |
| 1984 | + } | |
| 1985 | + } | |
| 1986 | + | |
| 1987 | + if(isset($add) || $uamOptions['lock_recursive'] == 'true') | |
| 1988 | + { | |
| 1989 | + if(isset($info->files[$cur_file->ID])) | |
| 1990 | + $cur_file = $info->files[$cur_file->ID]; | |
| 1991 | + | |
| 1992 | + $cur_file->recursive_lock_by_category[$group_category->term_id] = $group_category->term_id; | |
| 1993 | + $info->files[$cur_file->ID] = $cur_file; | |
| 1994 | + } | |
| 1995 | + } | |
| 1996 | + } | |
| 1997 | + } | |
| 1998 | + } | |
| 1999 | + | |
| 2000 | + if(isset($info->posts)) | |
| 2001 | + { | |
| 2002 | + foreach($info->posts as $group_post) | |
| 2003 | + { | |
| 2004 | + if($uamOptions['lock_recursive'] == 'true') | |
| 2005 | + { | |
| 2006 | + $cur_posts = get_posts('post_parent='.$group_post->ID); | |
| 2007 | + if(isset($cur_posts)) | |
| 2008 | + { | |
| 2009 | + foreach($cur_posts as $cur_post) | |
| 2010 | + { | |
| 2011 | + if(isset($info->posts[$cur_post->ID])) | |
| 2012 | + $cur_post = $info->posts[$cur_post->ID]; | |
| 2013 | + | |
| 2014 | + $cur_post->recursive_lock_by_post[$group_post->ID] = $group_post->ID; | |
| 2015 | + $info->posts[$cur_post->ID] = $cur_post; | |
| 2016 | + } | |
| 2017 | + } | |
| 2018 | + } | |
| 2019 | + $cur_files = get_posts('post_parent='.$group_post->ID.'&post_type=attachment'); | |
| 2020 | + if(isset($cur_files)) | |
| 2021 | + { | |
| 2022 | + foreach($cur_files as $cur_file) | |
| 2023 | + { | |
| 2024 | + if(isset($info->files[$cur_file->ID])) | |
| 2025 | + $cur_file = $info->files[$cur_file->ID]; | |
| 2026 | + | |
| 2027 | + $cur_file->recursive_lock_by_post[$group_post->ID] = $group_post->ID; | |
| 2028 | + $info->files[$cur_file->ID] = $cur_file; | |
| 2029 | + } | |
| 2030 | + } | |
| 2031 | + } | |
| 2032 | + } | |
| 2033 | + | |
| 2034 | + if(isset($info->pages)) | |
| 2035 | + { | |
| 2036 | + foreach($info->pages as $group_page) | |
| 2037 | + { | |
| 2038 | + if($uamOptions['lock_recursive'] == 'true') | |
| 2039 | + { | |
| 2040 | + $cur_pages = get_pages('child_of='.$group_page->ID); | |
| 2041 | + if(isset($cur_pages)) | |
| 2042 | + { | |
| 2043 | + foreach($cur_pages as $cur_page) | |
| 2044 | + { | |
| 2045 | + if(isset($info->posts[$cur_post->ID])) | |
| 2046 | + $cur_post = $info->posts[$cur_post->ID]; | |
| 2047 | + | |
| 2048 | + $cur_post->recursive_lock_by_post[$group_page->ID] = $group_page->ID; | |
| 2049 | + $info->pages[$cur_page->ID] = $cur_page; | |
| 2050 | + } | |
| 2051 | + } | |
| 2052 | + } | |
| 2053 | + | |
| 2054 | + $cur_files = get_posts('post_parent='.$group_page->ID.'&post_type=attachment'); | |
| 2055 | + if(isset($cur_files)) | |
| 2056 | + { | |
| 2057 | + foreach($cur_files as $cur_file) | |
| 2058 | + { | |
| 2059 | + if(isset($info->files[$cur_file->ID])) | |
| 2060 | + $cur_file = $info->files[$cur_file->ID]; | |
| 2061 | + | |
| 2062 | + $cur_file->recursive_lock_by_post[$group_post->ID] = $group_post->ID; | |
| 2063 | + $info->files[$cur_file->ID] = $cur_file; | |
| 2064 | + } | |
| 2065 | + } | |
| 2066 | + } | |
| 2067 | + } | |
| 2068 | + | |
| 2084 | 2069 | return $info; |
| 2085 | 2070 | } |
| 2086 | 2071 | |
| 2087 | 2072 | function get_usergroup_info_html($group_id, $style = null) |
| @@ -2324,44 +2309,12 @@ | ||
| 2324 | 2309 | } |
| 2325 | 2310 | |
| 2326 | 2311 | function save_postdata($post_id) |
| 2327 | 2312 | { |
| 2328 | - global $current_user, $wpdb; | |
| 2329 | - $cur_userdata = get_userdata($current_user->ID); | |
| 2330 | - $uamOptions = $this->getAdminOptions(); | |
| 2313 | + global $wpdb; | |
| 2314 | + if(isset($_POST['accessgroups'])) | |
| 2315 | + $accessgroups = $_POST['accessgroups']; | |
| 2331 | 2316 | |
| 2332 | - if($cur_userdata->user_level < $uamOptions['full_access_level']) | |
| 2333 | - { | |
| 2334 | - $uamOptions = $this->getAdminOptions(); | |
| 2335 | - | |
| 2336 | - $cur_categories = wp_get_post_categories($post_id); | |
| 2337 | - | |
| 2338 | - $allowded_categories = get_categories(); | |
| 2339 | - | |
| 2340 | - foreach($cur_categories as $category) | |
| 2341 | - { | |
| 2342 | - foreach($allowded_categories as $allowded_category) | |
| 2343 | - { | |
| 2344 | - if($allowded_category->term_id == $category) | |
| 2345 | - { | |
| 2346 | - $post_categories[] = $allowded_category->term_id; | |
| 2347 | - break; | |
| 2348 | - } | |
| 2349 | - } | |
| 2350 | - } | |
| 2351 | - | |
| 2352 | - if(!isset($post_categories)) | |
| 2353 | - { | |
| 2354 | - $last_category = array_pop($allowded_categories); | |
| 2355 | - $post_categories[] = $last_category->term_id; | |
| 2356 | - } | |
| 2357 | - | |
| 2358 | - wp_set_post_categories($post_id, $post_categories); | |
| 2359 | - } | |
| 2360 | - | |
| 2361 | - if(isset($_POST['accessgroups'])) | |
| 2362 | - $accessgroups = $_POST['accessgroups']; | |
| 2363 | - | |
| 2364 | 2317 | $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE post_id = $post_id"); |
| 2365 | 2318 | if(isset($accessgroups)) |
| 2366 | 2319 | { |
| 2367 | 2320 | foreach($accessgroups as $accessgroup) |
| @@ -2442,11 +2395,10 @@ | ||
| 2442 | 2395 | |
| 2443 | 2396 | $user_id = $_GET['user_id']; |
| 2444 | 2397 | $cur_userdata = get_userdata($current_user->ID); |
| 2445 | 2398 | $cur_edit_userdata = get_userdata($user_id); |
| 2446 | - $uamOptions = $this->getAdminOptions(); | |
| 2447 | 2399 | |
| 2448 | - if($cur_userdata->user_level >= $uamOptions['full_access_level']) | |
| 2400 | + if(isset($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2449 | 2401 | { |
| 2450 | 2402 | $accessgroups = $wpdb->get_results("SELECT * |
| 2451 | 2403 | FROM ".DB_ACCESSGROUP." |
| 2452 | 2404 | ORDER BY groupname", ARRAY_A); |
| @@ -2517,12 +2469,11 @@ | ||
| 2517 | 2469 | function save_userdata($user_id) |
| 2518 | 2470 | { |
| 2519 | 2471 | global $wpdb, $current_user; |
| 2520 | 2472 | |
| 2521 | - $cur_userdata = get_userdata($current_user->ID); | |
| 2522 | - $uamOptions = $this->getAdminOptions(); | |
| 2473 | + $cur_userdata = get_userdata($current_user->ID); | |
| 2523 | 2474 | |
| 2524 | - if($cur_userdata->user_level >= $uamOptions['full_access_level']) | |
| 2475 | + if(isset($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2525 | 2476 | { |
| 2526 | 2477 | $accessgroups = $_POST['accessgroups']; |
| 2527 | 2478 | $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_USER." WHERE user_id = $user_id"); |
| 2528 | 2479 | if(isset($accessgroups)) |
| @@ -2538,12 +2489,11 @@ | ||
| 2538 | 2489 | function remove_userdata($user_id) |
| 2539 | 2490 | { |
| 2540 | 2491 | global $wpdb, $current_user; |
| 2541 | 2492 | |
| 2542 | - $cur_userdata = get_userdata($current_user->ID); | |
| 2543 | - $uamOptions = $this->getAdminOptions(); | |
| 2493 | + $cur_userdata = get_userdata($current_user->ID); | |
| 2544 | 2494 | |
| 2545 | - if($cur_userdata->user_level >= $uamOptions['full_access_level']) | |
| 2495 | + if(isset($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2546 | 2496 | $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_USER." WHERE user_id = $user_id"); |
| 2547 | 2497 | } |
| 2548 | 2498 | |
| 2549 | 2499 | function add_category_columns_header($defaults) |
| @@ -2719,41 +2669,8 @@ | ||
| 2719 | 2669 | |
| 2720 | 2670 | $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_CATEGORY." WHERE category_id = $category_id"); |
| 2721 | 2671 | } |
| 2722 | 2672 | |
| 2723 | - function get_login_bar() | |
| 2724 | - { | |
| 2725 | - if(!is_user_logged_in()) | |
| 2726 | - { | |
| 2727 | - if(!is_single()) | |
| 2728 | - { | |
| 2729 | - $output = '<a href="'.get_bloginfo('wpurl').'/wp-login.php?redirect_to='.urlencode($_SERVER['REQUEST_URI']).'">'.__('Login', 'user-access-manager').'</a>'; | |
| 2730 | - } | |
| 2731 | - else | |
| 2732 | - { | |
| 2733 | - if(! isset ($user_login)) | |
| 2734 | - $user_login = ''; | |
| 2735 | - // login form | |
| 2736 | - $output = '<form action="'.get_bloginfo('wpurl').'/wp-login.php" method="post" >'; | |
| 2737 | - $output .= '<p><label for="user_login">'.__('Username:', 'user-access-manager').'<input name="log" value="'.wp_specialchars(stripslashes($user_login), 1).'" class="input" id="user_login" type="text" /></label></p>'; | |
| 2738 | - $output .= '<p><label for="user_pass">'.__('Password:', 'user-access-manager').'<input name="pwd" class="imput" id="user_pass" type="password" /></label></p>'; | |
| 2739 | - $output .= '<p class="forgetmenot"><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> '. __('Remember me', 'user-access-manager').'</label></p>'; | |
| 2740 | - $output .= '<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="'.__('Login', 'user-access-manager').' »" />'; | |
| 2741 | - $output .= '<input type="hidden" name="redirect_to" value="' . $_SERVER['REQUEST_URI'] . '" />'; | |
| 2742 | - $output .= '</form>'; | |
| 2743 | - | |
| 2744 | - $output .= '<p>'; | |
| 2745 | - if (get_option('users_can_register')) | |
| 2746 | - $output .= '<a href="'.get_bloginfo('wpurl').'/wp-login.php?action=register">'.__('Register', 'user-access-manager').'</a></br>'; | |
| 2747 | - $output .= '<a href="'.get_bloginfo('wpurl').'/wp-login.php?action=lostpassword" title="'. __('Password Lost and Found', 'user-access-manager').'">'. __('Lost your password?', 'user-access-manager').'</a>'; | |
| 2748 | - $output .= '</p>'; | |
| 2749 | - } | |
| 2750 | - | |
| 2751 | - return $output; | |
| 2752 | - } | |
| 2753 | - return null; | |
| 2754 | - } | |
| 2755 | - | |
| 2756 | 2673 | function get_access($post_id = null) |
| 2757 | 2674 | { |
| 2758 | 2675 | global $wpdb; |
| 2759 | 2676 | |
| @@ -2787,9 +2704,9 @@ | ||
| 2787 | 2704 | FROM ".DB_ACCESSGROUP_TO_CATEGORY." atc, ".DB_ACCESSGROUP." ag |
| 2788 | 2705 | WHERE atc.category_id = ".$cur_category->term_id." |
| 2789 | 2706 | AND atc.group_id = ag.ID |
| 2790 | 2707 | AND ".$sqlCheckLocation, ARRAY_A); |
| 2791 | - if($restricted_access_by_cat != Array()) | |
| 2708 | + if(isset($restricted_access_by_cat)) | |
| 2792 | 2709 | $restricted_by_categories[$cur_category->term_id] = $cur_category->term_id; |
| 2793 | 2710 | |
| 2794 | 2711 | if($uamOptions['lock_recursive'] == 'true') |
| 2795 | 2712 | { |
| @@ -2801,9 +2718,9 @@ | ||
| 2801 | 2718 | WHERE atc.category_id = ".$cur_id." |
| 2802 | 2719 | AND atc.group_id = ag.ID |
| 2803 | 2720 | AND ".$sqlCheckLocation, ARRAY_A); |
| 2804 | 2721 | |
| 2805 | - if(isset($cur_category->term_id) && $restricted_access_by_cat != Array()) | |
| 2722 | + if(isset($cur_category->term_id) && isset($restricted_access_by_cat)) | |
| 2806 | 2723 | $restricted_by_categories[$cur_category->term_id] = $cur_category->term_id; |
| 2807 | 2724 | |
| 2808 | 2725 | if(isset($cur_category->parent)) |
| 2809 | 2726 | { |
| @@ -2827,10 +2744,9 @@ | ||
| 2827 | 2744 | FROM ".DB_ACCESSGROUP_TO_POST." atp, ".DB_ACCESSGROUP." ag |
| 2828 | 2745 | WHERE atp.post_id = ".$cur_post->ID." |
| 2829 | 2746 | AND atp.group_id = ag.ID |
| 2830 | 2747 | AND ".$sqlCheckLocation, ARRAY_A); |
| 2831 | - | |
| 2832 | - if($restricted_access_by_post != Array()) | |
| 2748 | + if(isset($restricted_access_by_post)) | |
| 2833 | 2749 | $restricted_by_posts[$cur_post->ID] = $cur_post->ID; |
| 2834 | 2750 | |
| 2835 | 2751 | if($uamOptions['lock_recursive'] == 'true') |
| 2836 | 2752 | { |
| @@ -2872,9 +2788,9 @@ | ||
| 2872 | 2788 | $access->restricted_by_posts = $restricted_by_posts; |
| 2873 | 2789 | |
| 2874 | 2790 | if(empty($access)) |
| 2875 | 2791 | $access = -1; |
| 2876 | - | |
| 2792 | + | |
| 2877 | 2793 | $this->restrictedPost[$post_id] = $access; |
| 2878 | 2794 | |
| 2879 | 2795 | return $access; |
| 2880 | 2796 | } |
| @@ -2887,9 +2803,8 @@ | ||
| 2887 | 2803 | return $this->postAccess[$post_id]; |
| 2888 | 2804 | |
| 2889 | 2805 | $access = $this->get_access($post_id); |
| 2890 | 2806 | $cur_user_ip = explode(".", $_SERVER['REMOTE_ADDR']); |
| 2891 | - $uamOptions = $this->getAdminOptions(); | |
| 2892 | 2807 | |
| 2893 | 2808 | if(isset($access->restricted_by_posts) || isset($access->restricted_by_categories)) |
| 2894 | 2809 | { |
| 2895 | 2810 | if(is_user_logged_in()) |
| @@ -2895,9 +2810,9 @@ | ||
| 2895 | 2810 | if(is_user_logged_in()) |
| 2896 | 2811 | { |
| 2897 | 2812 | $cur_userdata = get_userdata($current_user->ID); |
| 2898 | 2813 | |
| 2899 | - if($cur_userdata->user_level < $uamOptions['full_access_level']) | |
| 2814 | + if(empty($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2900 | 2815 | { |
| 2901 | 2816 | if(isset($access->restricted_by_categories)) |
| 2902 | 2817 | { |
| 2903 | 2818 | foreach($access->restricted_by_categories as $cur_cat_id) |
| @@ -3082,63 +2997,47 @@ | ||
| 3082 | 2997 | { |
| 3083 | 2998 | $show_posts = null; |
| 3084 | 2999 | $uamOptions = $this->getAdminOptions(); |
| 3085 | 3000 | |
| 3086 | - if(!is_feed() || ($uamOptions['protect_feed'] == 'true' && is_feed())) | |
| 3001 | + foreach($posts as $post) | |
| 3087 | 3002 | { |
| 3088 | - foreach($posts as $post) | |
| 3003 | + if( ($uamOptions['hide_post'] == 'true' && $post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $post->post_type == "page") || $this->atAdminPanel) | |
| 3089 | 3004 | { |
| 3090 | - if( ($uamOptions['hide_post'] == 'true' && $post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $post->post_type == "page") || $this->atAdminPanel) | |
| 3005 | + if($this->check_access($post->ID)) | |
| 3091 | 3006 | { |
| 3092 | - if($this->check_access($post->ID)) | |
| 3007 | + $post->post_title .= $this->admin_output($post->ID); | |
| 3008 | + $show_posts[] = $post; | |
| 3009 | + } | |
| 3010 | + } | |
| 3011 | + else | |
| 3012 | + { | |
| 3013 | + if(!$this->check_access($post->ID)) | |
| 3014 | + { | |
| 3015 | + if($post->post_type == "post") | |
| 3093 | 3016 | { |
| 3094 | - $post->post_title .= $this->admin_output($post->ID); | |
| 3095 | - $show_posts[] = $post; | |
| 3017 | + if($uamOptions['hide_post_title'] == 'true') | |
| 3018 | + $post->post_title = $uamOptions['post_title']; | |
| 3019 | + | |
| 3020 | + $post->post_content = $uamOptions['post_content']; | |
| 3021 | + | |
| 3022 | + if($uamOptions['allow_comments_locked'] == 'false') | |
| 3023 | + $post->comment_status = 'close'; | |
| 3096 | 3024 | } |
| 3097 | - } | |
| 3098 | - else | |
| 3099 | - { | |
| 3100 | - if(!$this->check_access($post->ID)) | |
| 3025 | + elseif($post->post_type == "page") | |
| 3101 | 3026 | { |
| 3102 | - if($post->post_type == "post") | |
| 3103 | - { | |
| 3104 | - $uam_post_content = $uamOptions['post_content']; | |
| 3105 | - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content); | |
| 3106 | - | |
| 3107 | - if($uamOptions['hide_post_title'] == 'true') | |
| 3108 | - $post->post_title = $uamOptions['post_title']; | |
| 3109 | - | |
| 3110 | - if($uamOptions['show_post_content_before_more'] == 'true' && preg_match('/<!--more(.*?)?-->/', $post->post_content, $matches)) | |
| 3111 | - { | |
| 3112 | - $post->post_content = explode($matches[0], $post->post_content, 2); | |
| 3113 | - $post->post_content = $post->post_content[0]." ".$uam_post_content; | |
| 3114 | - } | |
| 3115 | - else | |
| 3116 | - { | |
| 3117 | - $post->post_content = $uam_post_content; | |
| 3118 | - } | |
| 3119 | - | |
| 3120 | - if($uamOptions['allow_comments_locked'] == 'false') | |
| 3121 | - $post->comment_status = 'close'; | |
| 3122 | - } | |
| 3123 | - elseif($post->post_type == "page") | |
| 3124 | - { | |
| 3125 | - if($uamOptions['hide_page_title'] == 'true') | |
| 3126 | - $post->post_title = $uamOptions['page_title']; | |
| 3127 | - | |
| 3128 | - $uam_post_content = $uamOptions['page_content']; | |
| 3129 | - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content); | |
| 3130 | - | |
| 3131 | - $post->post_content = $uam_post_content; | |
| 3132 | - } | |
| 3027 | + if($uamOptions['hide_page_title'] == 'true') | |
| 3028 | + $post->post_title = $uamOptions['page_title']; | |
| 3029 | + | |
| 3030 | + $post->post_content = $uamOptions['page_content']; | |
| 3133 | 3031 | } |
| 3134 | - $post->post_title .= $this->admin_output($post->ID); | |
| 3135 | - $show_posts[] = $post; | |
| 3136 | 3032 | } |
| 3033 | + $post->post_title .= $this->admin_output($post->ID); | |
| 3034 | + $show_posts[] = $post; | |
| 3137 | 3035 | } |
| 3036 | + } | |
| 3037 | + | |
| 3038 | + $posts = $show_posts; | |
| 3138 | 3039 | |
| 3139 | - $posts = $show_posts; | |
| 3140 | - } | |
| 3141 | 3040 | return $posts; |
| 3142 | 3041 | } |
| 3143 | 3042 | |
| 3144 | 3043 | function show_comment($comments = array()) |
| @@ -3147,12 +3046,14 @@ | ||
| 3147 | 3046 | $uamOptions = $this->getAdminOptions(); |
| 3148 | 3047 | |
| 3149 | 3048 | foreach($comments as $comment) |
| 3150 | 3049 | { |
| 3151 | - if($uamOptions['hide_post_comment'] == 'true' || $uamOptions['hide_post'] == 'true' || $this->atAdminPanel) | |
| 3050 | + if($uamOptions['hide_post_comment'] == 'true' || $this->atAdminPanel) | |
| 3152 | 3051 | { |
| 3153 | 3052 | if($this->check_access($comment->comment_post_ID)) |
| 3053 | + { | |
| 3154 | 3054 | $show_comments[] = $comment; |
| 3055 | + } | |
| 3155 | 3056 | } |
| 3156 | 3057 | else |
| 3157 | 3058 | { |
| 3158 | 3059 | if(!$this->check_access($comment->comment_post_ID)) |
| @@ -3206,114 +3107,75 @@ | ||
| 3206 | 3107 | function show_category($categories = array()) |
| 3207 | 3108 | { |
| 3208 | 3109 | global $current_user, $wpdb; |
| 3209 | 3110 | $cur_userdata = get_userdata($current_user->ID); |
| 3210 | - $uamOptions = $this->getAdminOptions(); | |
| 3211 | - | |
| 3212 | - if(!isset($cur_userdata->user_level)) | |
| 3213 | - $cur_userdata->user_level = null; | |
| 3214 | - | |
| 3215 | - if($cur_userdata->user_level < $uamOptions['full_access_level']) | |
| 3111 | + | |
| 3112 | + if(empty($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 3216 | 3113 | { |
| 3217 | 3114 | $uamOptions = $this->getAdminOptions(); |
| 3218 | - | |
| 3219 | - if($this->atAdminPanel) | |
| 3115 | + if($uamOptions['hide_post'] == 'true' || $uamOptions['hide_page'] == 'true' || $this->atAdminPanel) | |
| 3220 | 3116 | { |
| 3221 | - $restrictedcategories = $wpdb->get_results("SELECT category_id | |
| 3222 | - FROM ".DB_ACCESSGROUP_TO_CATEGORY, ARRAY_A); | |
| 3117 | + $args = array( 'numberposts' => -1); | |
| 3118 | + $posts = get_posts($args); | |
| 3223 | 3119 | |
| 3224 | - if(isset($restrictedcategories)) | |
| 3120 | + foreach($categories as $category) | |
| 3225 | 3121 | { |
| 3226 | - foreach($categories as $category) | |
| 3122 | + $count = 0; | |
| 3123 | + | |
| 3124 | + if(isset($posts)) | |
| 3227 | 3125 | { |
| 3228 | - foreach($restrictedcategories as $restrictedcategory) | |
| 3126 | + foreach($posts as $cur_post) | |
| 3229 | 3127 | { |
| 3230 | - $has_access = true; | |
| 3231 | - | |
| 3232 | - if($restrictedcategory['category_id'] == $category->term_id) | |
| 3128 | + $post_cat_ids = array(); | |
| 3129 | + $post_cats = get_the_category($cur_post->ID); | |
| 3130 | + foreach($post_cats as $post_cat) | |
| 3233 | 3131 | { |
| 3234 | - $has_access = false; | |
| 3235 | - | |
| 3236 | - $access = $wpdb->get_results(" SELECT category_id | |
| 3237 | - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc | |
| 3238 | - WHERE agtu.user_id = ".$current_user->ID." | |
| 3239 | - AND agtu.group_id = agtc.group_id | |
| 3240 | - AND agtc.category_id = ".$category->term_id, ARRAY_A); | |
| 3241 | - | |
| 3242 | - if(isset($access)) | |
| 3243 | - $has_access = true; | |
| 3244 | - | |
| 3245 | - if(empty($show_categories[$category->term_id]) && !$has_access) | |
| 3246 | - $restrict_categories[$category->term_id] = $category; | |
| 3132 | + $post_cat_ids[] = $post_cat->term_id; | |
| 3247 | 3133 | } |
| 3248 | 3134 | |
| 3249 | - if($has_access) | |
| 3135 | + if(in_array($category->term_id, $post_cat_ids) ) | |
| 3250 | 3136 | { |
| 3251 | - $show_categories[$category->term_id] = $category; | |
| 3252 | - | |
| 3253 | - if(isset($restrict_categories[$category->term_id])) | |
| 3254 | - unset($restrict_categories[$category->term_id]); | |
| 3137 | + if( ($uamOptions['hide_post'] == 'true' && $cur_post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $cur_post->post_type == "page") ) | |
| 3138 | + { | |
| 3139 | + if($this->check_access($cur_post->ID)) | |
| 3140 | + $count++; | |
| 3141 | + } | |
| 3142 | + else | |
| 3143 | + { | |
| 3144 | + $count++; | |
| 3145 | + } | |
| 3255 | 3146 | } |
| 3256 | 3147 | } |
| 3257 | 3148 | } |
| 3258 | - | |
| 3259 | 3149 | |
| 3260 | - if(isset($restrict_categories) && $uamOptions['lock_recursive'] == 'true') | |
| 3150 | + if($count != 0 || $uamOptions['hide_empty_categories'] == 'false') | |
| 3261 | 3151 | { |
| 3262 | - foreach($restrict_categories as $restrict_category) | |
| 3263 | - { | |
| 3264 | - $args = array('child_of' => $restrict_category->term_id); | |
| 3265 | - $child_categories = get_categories($args); | |
| 3266 | - | |
| 3267 | - foreach($child_categories as $child_category) | |
| 3268 | - unset($show_categories[$child_category->term_id]); | |
| 3269 | - } | |
| 3152 | + $category->count = $count; | |
| 3153 | + $cur_show_categories[$category->term_id] = $category; | |
| 3270 | 3154 | } |
| 3271 | - | |
| 3272 | - if(isset($show_categories)) | |
| 3273 | - $categories = $show_categories; | |
| 3274 | - else | |
| 3275 | - $categories = null; | |
| 3155 | + elseif($category->taxonomy == "link_category" || $category->taxonomy == "post_tag") | |
| 3156 | + { | |
| 3157 | + $show_categories[] = $category; | |
| 3158 | + } | |
| 3159 | + elseif($count == 0) | |
| 3160 | + { | |
| 3161 | + $empty_categories[$category->term_id] = $category; | |
| 3162 | + } | |
| 3276 | 3163 | } |
| 3277 | 3164 | |
| 3278 | - /*$accesscategories = $wpdb->get_results("SELECT agtc.category_id | |
| 3279 | - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc | |
| 3280 | - WHERE agtu.user_id = ".$current_user->ID." | |
| 3281 | - AND agtu.group_id = agtc.group_id", ARRAY_A); | |
| 3282 | - | |
| 3283 | - if(isset($accesscategories)) | |
| 3165 | + if($uamOptions['hide_empty_categories'] == 'true') | |
| 3284 | 3166 | { |
| 3285 | - foreach($accesscategories as $accesscategory) | |
| 3286 | - { | |
| 3287 | - foreach($categories as $category) | |
| 3288 | - { | |
| 3289 | - if($accesscategory['category_id'] == $category->term_id) | |
| 3290 | - { | |
| 3291 | - $show_categories[$category->term_id] = $category; | |
| 3292 | - | |
| 3293 | - if(isset($empty_categories[$category->term_id])) | |
| 3294 | - unset($empty_categories[$category->term_id]); | |
| 3295 | - } | |
| 3296 | - else | |
| 3297 | - { | |
| 3298 | - if(empty($show_categories[$category->term_id])) | |
| 3299 | - $empty_categories[$category->term_id] = $category; | |
| 3300 | - } | |
| 3301 | - } | |
| 3302 | - } | |
| 3303 | - | |
| 3304 | - if(isset($empty_categories) && $uamOptions['lock_recursive'] == 'true') | |
| 3167 | + if(isset($cur_show_categories)) | |
| 3305 | 3168 | { |
| 3306 | - foreach($empty_categories as $empty_category) | |
| 3169 | + foreach($cur_show_categories as $cur_show_category) | |
| 3307 | 3170 | { |
| 3308 | - $cur_cat = $empty_category; | |
| 3309 | - while($cur_cat->parent != 0 && isset($show_categories)) | |
| 3171 | + $show_categories[$cur_show_category->term_id] = $cur_show_category; | |
| 3172 | + | |
| 3173 | + $cur_cat = $cur_show_category; | |
| 3174 | + while($cur_cat->parent != 0 && isset($empty_categories)) | |
| 3310 | 3175 | { |
| 3311 | - if(isset($show_categories[$cur_cat->parent])) | |
| 3312 | - { | |
| 3313 | - $show_categories[$empty_category->term_id] = $empty_category; | |
| 3314 | - break; | |
| 3315 | - } | |
| 3176 | + if(empty($show_categories[$cur_cat->parent])) | |
| 3177 | + $show_categories[$cur_cat->parent] = $empty_categories[$cur_cat->parent]; | |
| 3316 | 3178 | |
| 3317 | 3179 | $cur_id = $cur_cat->parent; |
| 3318 | 3180 | $cur_cat = & get_category($cur_id); |
| 3319 | 3181 | } |
| @@ -3323,109 +3185,10 @@ | ||
| 3323 | 3185 | |
| 3324 | 3186 | if(isset($show_categories)) |
| 3325 | 3187 | $categories = $show_categories; |
| 3326 | 3188 | else |
| 3327 | - $categories = null;*/ | |
| 3189 | + $categories = null; | |
| 3328 | 3190 | } |
| 3329 | - else | |
| 3330 | - { | |
| 3331 | - if($uamOptions['hide_post'] == 'true' || $uamOptions['hide_page'] == 'true') | |
| 3332 | - { | |
| 3333 | - $args = array( 'numberposts' => -1); | |
| 3334 | - $posts = get_posts($args); | |
| 3335 | - | |
| 3336 | - foreach($categories as $category) | |
| 3337 | - { | |
| 3338 | - $count = 0; | |
| 3339 | - | |
| 3340 | - if(isset($posts)) | |
| 3341 | - { | |
| 3342 | - foreach($posts as $cur_post) | |
| 3343 | - { | |
| 3344 | - $post_cat_ids = array(); | |
| 3345 | - $post_cats = get_the_category($cur_post->ID); | |
| 3346 | - foreach($post_cats as $post_cat) | |
| 3347 | - { | |
| 3348 | - $post_cat_ids[] = $post_cat->term_id; | |
| 3349 | - } | |
| 3350 | - | |
| 3351 | - if(in_array($category->term_id, $post_cat_ids) ) | |
| 3352 | - { | |
| 3353 | - if( ($uamOptions['hide_post'] == 'true' && $cur_post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $cur_post->post_type == "page")) | |
| 3354 | - { | |
| 3355 | - if($this->check_access($cur_post->ID)) | |
| 3356 | - $count++; | |
| 3357 | - } | |
| 3358 | - else | |
| 3359 | - { | |
| 3360 | - $count++; | |
| 3361 | - } | |
| 3362 | - } | |
| 3363 | - } | |
| 3364 | - } | |
| 3365 | - | |
| 3366 | - if(($count != 0 || ($uamOptions['hide_empty_categories'] == 'false' && !$this->atAdminPanel ))) | |
| 3367 | - { | |
| 3368 | - $category->count = $count; | |
| 3369 | - $cur_show_categories[$category->term_id] = $category; | |
| 3370 | - } | |
| 3371 | - elseif($category->taxonomy == "link_category" || $category->taxonomy == "post_tag") | |
| 3372 | - { | |
| 3373 | - $show_categories[$category->term_id] = $category; | |
| 3374 | - } | |
| 3375 | - elseif($count == 0) | |
| 3376 | - { | |
| 3377 | - $category->count = $count; | |
| 3378 | - $empty_categories[$category->term_id] = $category; | |
| 3379 | - } | |
| 3380 | - } | |
| 3381 | - | |
| 3382 | - if($uamOptions['hide_empty_categories'] == 'true') | |
| 3383 | - { | |
| 3384 | - if(isset($cur_show_categories)) | |
| 3385 | - { | |
| 3386 | - foreach($cur_show_categories as $cur_show_category) | |
| 3387 | - { | |
| 3388 | - $cur_count = $cur_show_category->count; | |
| 3389 | - $show_categories[$cur_show_category->term_id] = $cur_show_category; | |
| 3390 | - | |
| 3391 | - $cur_cat = $cur_show_category; | |
| 3392 | - while($cur_cat->parent != 0 && isset($empty_categories)) | |
| 3393 | - { | |
| 3394 | - if(empty($show_categories[$cur_cat->parent])) | |
| 3395 | - { | |
| 3396 | - if(isset( $empty_categories[$cur_cat->parent])) | |
| 3397 | - { | |
| 3398 | - $cur_empty_cat = $empty_categories[$cur_cat->parent]; | |
| 3399 | - $cur_empty_cat->count = $cur_count; | |
| 3400 | - $show_categories[$cur_cat->parent] = $cur_empty_cat; | |
| 3401 | - } | |
| 3402 | - } | |
| 3403 | - | |
| 3404 | - $cur_id = $cur_cat->parent; | |
| 3405 | - $cur_cat = & get_category($cur_id); | |
| 3406 | - } | |
| 3407 | - } | |
| 3408 | - } | |
| 3409 | - } | |
| 3410 | - else | |
| 3411 | - { | |
| 3412 | - if(isset($cur_show_categories)) | |
| 3413 | - { | |
| 3414 | - foreach($cur_show_categories as $cur_show_category) | |
| 3415 | - { | |
| 3416 | - $show_categories[$cur_show_category->term_id] = $cur_show_category; | |
| 3417 | - } | |
| 3418 | - } | |
| 3419 | - } | |
| 3420 | - | |
| 3421 | - if(isset($show_categories)) | |
| 3422 | - $categories = $show_categories; | |
| 3423 | - else | |
| 3424 | - $categories = null; | |
| 3425 | - } | |
| 3426 | - } | |
| 3427 | - | |
| 3428 | 3191 | } |
| 3429 | 3192 | |
| 3430 | 3193 | return $categories; |
| 3431 | 3194 | } |
| @@ -3452,50 +3215,22 @@ | ||
| 3452 | 3215 | function show_next_previous_post($sql) |
| 3453 | 3216 | { |
| 3454 | 3217 | $uamOptions = $this->getAdminOptions(); |
| 3455 | 3218 | |
| 3456 | - if($uamOptions['hide_post'] == 'true') | |
| 3219 | + $posts = get_posts(); | |
| 3220 | + if(isset($posts)) | |
| 3457 | 3221 | { |
| 3458 | - $posts = get_posts(); | |
| 3459 | - if(isset($posts)) | |
| 3222 | + foreach($posts as $post) | |
| 3460 | 3223 | { |
| 3461 | - foreach($posts as $post) | |
| 3462 | - { | |
| 3463 | - if(!$this->check_access($post->ID)) | |
| 3464 | - $excluded_posts[] = $post->ID; | |
| 3465 | - } | |
| 3466 | - if(isset($excluded_posts)) | |
| 3467 | - { | |
| 3468 | - $excluded_posts_str = implode(",", $excluded_posts); | |
| 3469 | - $sql .= "AND ID NOT IN($excluded_posts_str)"; | |
| 3470 | - } | |
| 3471 | - } | |
| 3472 | - } | |
| 3473 | - | |
| 3474 | - return $sql; | |
| 3475 | - } | |
| 3476 | - | |
| 3477 | - function show_post_sql($sql) | |
| 3478 | - { | |
| 3479 | - $uamOptions = $this->getAdminOptions(); | |
| 3480 | - | |
| 3481 | - if(($uamOptions['hide_post'] == 'true' && !is_feed()) || (is_feed() && $uamOptions['protect_feed'] == 'true')) | |
| 3482 | - { | |
| 3483 | - $posts = get_posts(); | |
| 3484 | - if(isset($posts)) | |
| 3224 | + if(!$this->check_access($post->ID)) | |
| 3225 | + $excluded_posts[] = $post->ID; | |
| 3226 | + } | |
| 3227 | + if(isset($excluded_posts)) | |
| 3485 | 3228 | { |
| 3486 | - foreach($posts as $post) | |
| 3487 | - { | |
| 3488 | - if(!$this->check_access($post->ID)) | |
| 3489 | - $excluded_posts[] = $post->ID; | |
| 3490 | - } | |
| 3491 | - if(isset($excluded_posts)) | |
| 3492 | - { | |
| 3493 | - $excluded_posts_str = implode(",", $excluded_posts); | |
| 3494 | - $sql .= "AND ID NOT IN($excluded_posts_str)"; | |
| 3495 | - } | |
| 3496 | - } | |
| 3497 | - } | |
| 3229 | + $excluded_posts_str = implode(",", $excluded_posts); | |
| 3230 | + $sql .= "AND ID NOT IN($excluded_posts_str)"; | |
| 3231 | + } | |
| 3232 | + } | |
| 3498 | 3233 | |
| 3499 | 3234 | return $sql; |
| 3500 | 3235 | } |
| 3501 | 3236 | |
| @@ -3513,15 +3248,12 @@ | ||
| 3513 | 3248 | |
| 3514 | 3249 | $output = ""; |
| 3515 | 3250 | |
| 3516 | 3251 | $access = $this->get_access($post_id); |
| 3517 | - | |
| 3518 | - if(!isset($cur_userdata->user_level)) | |
| 3519 | - $cur_userdata->user_level = null; | |
| 3520 | - | |
| 3521 | - if($cur_userdata->user_level >= $uamOptions['full_access_level'] && (isset($access->restricted_by_posts) || isset($access->restricted_by_categories))) | |
| 3522 | - $output = " ".$uamOptions['blog_admin_hint_text']; | |
| 3523 | - | |
| 3252 | + if(isset($cur_userdata->{$wpdb->prefix."capabilities"}['administrator']) && (isset($access->restricted_by_posts) || isset($access->restricted_by_categories))) | |
| 3253 | + { | |
| 3254 | + $output = " ".$uamOptions['blog_admin_hint_text']; | |
| 3255 | + } | |
| 3524 | 3256 | return $output; |
| 3525 | 3257 | } |
| 3526 | 3258 | } |
| 3527 | 3259 | return null; |
| @@ -3577,11 +3309,12 @@ | ||
| 3577 | 3309 | $cur_post = & get_post($cur_id); |
| 3578 | 3310 | |
| 3579 | 3311 | if($cur_post->post_type == 'attachment' && $this->check_access($cur_post->ID)) |
| 3580 | 3312 | { |
| 3581 | - $file = str_replace(get_option('siteurl').'/', "", $cur_post->guid); | |
| 3313 | + $cur_url = explode("?", "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); | |
| 3314 | + $file = str_replace($cur_url[0], "", $cur_post->guid); | |
| 3582 | 3315 | $filename = basename($file); |
| 3583 | - | |
| 3316 | + | |
| 3584 | 3317 | if(file_exists($file)) |
| 3585 | 3318 | { |
| 3586 | 3319 | $len = filesize($file); |
| 3587 | 3320 | header('content-type: '.$cur_post->post_mime_type); |
| @@ -3620,9 +3353,10 @@ | ||
| 3620 | 3353 | } |
| 3621 | 3354 | } |
| 3622 | 3355 | elseif(wp_attachment_is_image($cur_id)) |
| 3623 | 3356 | { |
| 3624 | - $file = UAM_URLPATH .'gfx/no_access_pic.png'; | |
| 3357 | + $cur_url = explode("?", "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); | |
| 3358 | + $file = str_replace($cur_url[0], "", UAM_URLPATH .'gfx/no_access_pic.png'); | |
| 3625 | 3359 | $filename = basename($file); |
| 3626 | 3360 | |
| 3627 | 3361 | if(file_exists($file)) |
| 3628 | 3362 | { |
| @@ -3659,9 +3393,9 @@ | ||
| 3659 | 3393 | $file_types = explode(",", $file_types); |
| 3660 | 3394 | |
| 3661 | 3395 | if(in_array($type, $file_types) || $uamOptions['lock_file_types'] == 'all') |
| 3662 | 3396 | { |
| 3663 | - $cur_guid = get_bloginfo('url'); | |
| 3397 | + $cur_guid = get_option('siteurl'); | |
| 3664 | 3398 | |
| 3665 | 3399 | $URL = $cur_guid.'?getfile='.$cur_post->ID; |
| 3666 | 3400 | } |
| 3667 | 3401 | } |
| @@ -3678,12 +3412,11 @@ | ||
| 3678 | 3412 | //Initialize the admin panel |
| 3679 | 3413 | if(!function_exists("UserAccessManager_AP")) { |
| 3680 | 3414 | function UserAccessManager_AP() |
| 3681 | 3415 | { |
| 3682 | - global $userAccessManager, $wp_version, $current_user, $wpdb; | |
| 3416 | + global $userAccessManager, $wp_version; | |
| 3683 | 3417 | |
| 3684 | 3418 | $userAccessManager->atAdminPanel = true; |
| 3685 | - $uamOptions = $userAccessManager->getAdminOptions(); | |
| 3686 | 3419 | |
| 3687 | 3420 | if (!isset($userAccessManager)) |
| 3688 | 3421 | { |
| 3689 | 3422 | return; |
| @@ -3689,29 +3422,21 @@ | ||
| 3689 | 3422 | return; |
| 3690 | 3423 | } |
| 3691 | 3424 | if (function_exists('add_menu_page')) |
| 3692 | 3425 | { |
| 3693 | - add_menu_page('User Access Manager', 'UAM', 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage'), UAM_URLPATH."gfx/icon.png"); | |
| 3426 | + add_menu_page('User Access Manager', 'Access Manager', 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage'), UAM_URLPATH."/gfx/icon.png"); | |
| 3694 | 3427 | } |
| 3695 | 3428 | if (function_exists('add_submenu_page')) |
| 3696 | 3429 | { |
| 3697 | 3430 | add_submenu_page('uam_usergroup', TXT_MANAGE_GROUP, TXT_MANAGE_GROUP, 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage')); |
| 3698 | 3431 | add_submenu_page('uam_usergroup', TXT_SETTINGS, TXT_SETTINGS, 9, 'uam_settings', array(&$userAccessManager, 'printAdminPage')); |
| 3699 | - add_submenu_page('uam_usergroup', TXT_SETUP, TXT_SETUP, 9, 'uam_setup', array(&$userAccessManager, 'printAdminPage')); | |
| 3700 | 3432 | } |
| 3701 | 3433 | if( function_exists( 'add_meta_box' )) |
| 3702 | 3434 | { |
| 3703 | - get_currentuserinfo(); | |
| 3704 | - $cur_userdata = get_userdata($current_user->ID); | |
| 3705 | - | |
| 3706 | - if($cur_userdata->user_level == $uamOptions['full_access_level']) | |
| 3707 | - { | |
| 3708 | - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'post', 'side' ); | |
| 3709 | - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'page', 'side' ); | |
| 3710 | - } | |
| 3435 | + add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'post', 'side' ); | |
| 3436 | + add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'page', 'side' ); | |
| 3711 | 3437 | } |
| 3712 | 3438 | |
| 3713 | - | |
| 3714 | 3439 | //Admin actions |
| 3715 | 3440 | |
| 3716 | 3441 | $userAccessManager->update(); |
| 3717 | 3442 | |
| @@ -3736,9 +3461,8 @@ | ||
| 3736 | 3461 | add_action('wp_print_styles', array(&$userAccessManager, 'add_styles') ); |
| 3737 | 3462 | |
| 3738 | 3463 | |
| 3739 | 3464 | //Admin filters |
| 3740 | - | |
| 3741 | 3465 | add_filter('manage_posts_columns', array(&$userAccessManager, 'add_post_columns_header')); |
| 3742 | 3466 | add_filter('manage_pages_columns', array(&$userAccessManager, 'add_post_columns_header')); |
| 3743 | 3467 | |
| 3744 | 3468 | $uamOptions = $userAccessManager->getAdminOptions(); |
| @@ -3763,9 +3487,9 @@ | ||
| 3763 | 3487 | if(isset($userAccessManager)) |
| 3764 | 3488 | { |
| 3765 | 3489 | add_action('init', array(&$userAccessManager, 'init')); |
| 3766 | 3490 | $uamOptions = $userAccessManager->getAdminOptions(); |
| 3767 | - | |
| 3491 | + | |
| 3768 | 3492 | //install |
| 3769 | 3493 | if(function_exists('register_activation_hook')) |
| 3770 | 3494 | register_activation_hook(__FILE__, array(&$userAccessManager, 'install')); |
| 3771 | 3495 | |
| @@ -3775,9 +3499,9 @@ | ||
| 3775 | 3499 | register_deactivation_hook(__FILE__, array(&$userAccessManager, 'uninstall')); |
| 3776 | 3500 | |
| 3777 | 3501 | if(function_exists('register_deactivation_hook')) |
| 3778 | 3502 | register_deactivation_hook(__FILE__, array(&$userAccessManager, 'deactivate')); |
| 3779 | - | |
| 3503 | + | |
| 3780 | 3504 | //Actions |
| 3781 | 3505 | add_action('admin_menu', 'UserAccessManager_AP'); |
| 3782 | 3506 | |
| 3783 | 3507 | if($uamOptions['redirect'] != 'false' || isset($_GET['getfile'])) |
| @@ -3783,9 +3507,8 @@ | ||
| 3783 | 3507 | if($uamOptions['redirect'] != 'false' || isset($_GET['getfile'])) |
| 3784 | 3508 | add_action('template_redirect', array(&$userAccessManager, 'redirect_user')); |
| 3785 | 3509 | |
| 3786 | 3510 | //Filters |
| 3787 | - add_filter('wp_get_attachment_thumb_url', array(&$userAccessManager, 'get_file'), 10, 2); | |
| 3788 | 3511 | add_filter('wp_get_attachment_url', array(&$userAccessManager, 'get_file'), 10, 2); |
| 3789 | 3512 | add_filter('the_posts', array(&$userAccessManager, 'show_post')); |
| 3790 | 3513 | add_filter('comments_array', array(&$userAccessManager, 'show_comment')); |
| 3791 | 3514 | add_filter('get_pages', array(&$userAccessManager, 'show_page')); |
| @@ -3793,7 +3516,7 @@ | ||
| 3793 | 3516 | add_filter('get_next_post_where', array(&$userAccessManager, 'show_next_previous_post')); |
| 3794 | 3517 | add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post')); |
| 3795 | 3518 | add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post')); |
| 3796 | 3519 | add_filter('the_title', array(&$userAccessManager, 'show_title'), 10, 2); |
| 3797 | - add_filter('posts_where', array(&$userAccessManager, 'show_post_sql')); | |
| 3798 | 3520 | } |
| 3799 | -?> | |
| 3521 | + | |
| 3522 | +?> | |