| @@ -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.1 | |
| 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 |
| @@ -35,10 +35,11 @@ | ||
| 35 | 35 | define('DB_ACCESSGROUP_TO_ROLE', $wpdb->prefix.'uam_accessgroup_to_role'); |
| 36 | 36 | |
| 37 | 37 | //PATH |
| 38 | 38 | define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/' ); |
| 39 | -//define('UAM_URLPATH', WP_CONTENT_URL.'/plugins/user-access-manager/' ); //Localhost DEBUG | |
| 40 | 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() |
| @@ -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')); |
| @@ -295,11 +291,8 @@ | ||
| 295 | 291 | global $wpdb; |
| 296 | 292 | $uam_db_version = $this->uam_db_version; |
| 297 | 293 | $installed_ver = get_option( "uam_db_version" ); |
| 298 | 294 | |
| 299 | - if(empty($installed_ver)) | |
| 300 | - $this->install(); | |
| 301 | - | |
| 302 | 295 | if($installed_ver != $uam_db_version) |
| 303 | 296 | { |
| 304 | 297 | if($installed_ver == '1.0') |
| 305 | 298 | { |
| @@ -310,14 +303,11 @@ | ||
| 310 | 303 | update_option("uam_db_version", $uam_db_version); |
| 311 | 304 | } |
| 312 | 305 | } |
| 313 | 306 | } |
| 314 | - 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') | |
| 315 | 308 | { |
| 316 | - if($wpdb->get_var("show columns from ".DB_ACCESSGROUP." like 'ip_range'") != 'ip_range') | |
| 317 | - { | |
| 318 | - $wpdb->query("ALTER TABLE ".DB_ACCESSGROUP." ADD ip_range MEDIUMTEXT NULL DEFAULT ''"); | |
| 319 | - } | |
| 309 | + $wpdb->query("ALTER TABLE ".DB_ACCESSGROUP." ADD ip_range MEDIUMTEXT NULL DEFAULT ''"); | |
| 320 | 310 | } |
| 321 | 311 | } |
| 322 | 312 | |
| 323 | 313 | function uninstall() |
| @@ -500,10 +490,9 @@ | ||
| 500 | 490 | 'not_locked_file_types' => 'gif,jpg,jpeg,png', |
| 501 | 491 | 'blog_admin_hint' => 'true', |
| 502 | 492 | 'blog_admin_hint_text' => '[L]', |
| 503 | 493 | 'core_mod' => 'false', |
| 504 | - 'hide_empty_categories' => 'true', | |
| 505 | - 'protect_feed' => 'true'); | |
| 494 | + 'hide_empty_categories' => 'true'); | |
| 506 | 495 | |
| 507 | 496 | $uamOptions = get_option($this->adminOptionsName); |
| 508 | 497 | if (!empty($uamOptions)) { |
| 509 | 498 | foreach ($uamOptions as $key => $option) |
| @@ -531,12 +520,8 @@ | ||
| 531 | 520 | if (isset($_POST['uam_post_title'])) |
| 532 | 521 | { |
| 533 | 522 | $uamOptions['post_title'] = $_POST['uam_post_title']; |
| 534 | 523 | } |
| 535 | - if (isset($_POST['uam_show_post_content_before_more'])) | |
| 536 | - { | |
| 537 | - $uamOptions['show_post_content_before_more'] = $_POST['uam_show_post_content_before_more']; | |
| 538 | - } | |
| 539 | 524 | if (isset($_POST['uam_post_content'])) |
| 540 | 525 | { |
| 541 | 526 | $uamOptions['post_content'] = $_POST['uam_post_content']; |
| 542 | 527 | } |
| @@ -571,12 +556,8 @@ | ||
| 571 | 556 | if (isset($_POST['uam_hide_page'])) |
| 572 | 557 | { |
| 573 | 558 | $uamOptions['hide_page'] = $_POST['uam_hide_page']; |
| 574 | 559 | } |
| 575 | - if (isset($_POST['uam_protect_feed'])) | |
| 576 | - { | |
| 577 | - $uamOptions['protect_feed'] = $_POST['uam_protect_feed']; | |
| 578 | - } | |
| 579 | 560 | if (isset($_POST['uam_hide_empty_categories'])) |
| 580 | 561 | { |
| 581 | 562 | $uamOptions['hide_empty_categories'] = $_POST['uam_hide_empty_categories']; |
| 582 | 563 | } |
| @@ -881,25 +862,8 @@ | ||
| 881 | 862 | </td> |
| 882 | 863 | </tr> |
| 883 | 864 | <tr valign="top"> |
| 884 | 865 | <th scope="row"> |
| 885 | - <?php echo TXT_SHOW_POST_CONTENT_BEFORE_MORE; ?> | |
| 886 | - </th> | |
| 887 | - <td> | |
| 888 | - <label for="uam_show_post_content_before_more_yes"> | |
| 889 | - <input type="radio" id="uam_hide_post_title_yes" name="uam_show_post_content_before_more" value="true" <?php if ($uamOptions['show_post_content_before_more'] == "true") { echo 'checked="checked"'; }?> /> | |
| 890 | - <?php echo TXT_YES; ?> | |
| 891 | - </label> | |
| 892 | - <label for="uam_show_post_content_before_more_no"> | |
| 893 | - <input type="radio" id="uam_hide_post_title_no" name="uam_show_post_content_before_more" value="false" <?php if ($uamOptions['show_post_content_before_more'] == "false") { echo 'checked="checked"'; }?>/> | |
| 894 | - <?php echo TXT_NO; ?> | |
| 895 | - </label> | |
| 896 | - <br /> | |
| 897 | - <?php echo TXT_SHOW_POST_CONTENT_BEFORE_MORE_DESC; ?> | |
| 898 | - </td> | |
| 899 | - </tr> | |
| 900 | - <tr valign="top"> | |
| 901 | - <th scope="row"> | |
| 902 | 866 | <?php echo TXT_POST_CONTENT; ?> |
| 903 | 867 | </th> |
| 904 | 868 | <td> |
| 905 | 869 | <textarea name="uam_post_content" style="width: 80%; height: 100px;"><?php echo apply_filters('format_to_edit',$uamOptions['post_content']); ?></textarea> |
| @@ -1104,25 +1068,8 @@ | ||
| 1104 | 1068 | <table class="form-table"> |
| 1105 | 1069 | <tbody> |
| 1106 | 1070 | <tr> |
| 1107 | 1071 | <th> |
| 1108 | - <?php echo TXT_PROTECT_FEED; ?> | |
| 1109 | - </th> | |
| 1110 | - <td> | |
| 1111 | - <label for="uam_protect_feed_yes"> | |
| 1112 | - <input type="radio" id="uam_protect_feed_yes" name="uam_protect_feed" value="true" <?php if ($uamOptions['protect_feed'] == "true") { echo 'checked="checked"'; }?> /> | |
| 1113 | - <?php echo TXT_YES; ?> | |
| 1114 | - </label> | |
| 1115 | - <label for="uam_protect_feed_no"> | |
| 1116 | - <input type="radio" id="uam_protect_feed_no" name="uam_protect_feed" value="false" <?php if ($uamOptions['protect_feed'] == "false") { echo 'checked="checked"'; }?>/> | |
| 1117 | - <?php echo TXT_NO; ?> | |
| 1118 | - </label> | |
| 1119 | - <br /> | |
| 1120 | - <?php echo TXT_PROTECT_FEED_DESC; ?> | |
| 1121 | - </td> | |
| 1122 | - </tr> | |
| 1123 | - <tr> | |
| 1124 | - <th> | |
| 1125 | 1072 | <?php echo TXT_HIDE_EMPTY_CATEGORIES; ?> |
| 1126 | 1073 | </th> |
| 1127 | 1074 | <td> |
| 1128 | 1075 | <label for="uam_hide_empty_categories_yes"> |
| @@ -1770,11 +1717,8 @@ | ||
| 1770 | 1717 | function get_usergroups_for_post($ID) |
| 1771 | 1718 | { |
| 1772 | 1719 | global $wpdb; |
| 1773 | 1720 | |
| 1774 | - if(isset($this->postUserGroup[$ID])) | |
| 1775 | - return $this->postUserGroup[$ID]; | |
| 1776 | - | |
| 1777 | 1721 | $access = $this->get_access($ID); |
| 1778 | 1722 | |
| 1779 | 1723 | $post_usergroups = array(); |
| 1780 | 1724 | |
| @@ -1807,9 +1751,9 @@ | ||
| 1807 | 1751 | if(isset($cur_usergroup->posts)) |
| 1808 | 1752 | $posts = $cur_usergroup->posts; |
| 1809 | 1753 | |
| 1810 | 1754 | $lock_post = & get_post($cur_id); |
| 1811 | - $posts[$lock_post->ID] = $lock_post->ID; | |
| 1755 | + $posts[] = $lock_post->ID; | |
| 1812 | 1756 | $cur_usergroup->posts = $posts; |
| 1813 | 1757 | } |
| 1814 | 1758 | else |
| 1815 | 1759 | { |
| @@ -1847,9 +1791,9 @@ | ||
| 1847 | 1791 | if(isset($cur_usergroup->categorie)) |
| 1848 | 1792 | $categories = $cur_usergroup->categories; |
| 1849 | 1793 | |
| 1850 | 1794 | $lock_cat = & get_category($cur_id); |
| 1851 | - $categories[$lock_cat->term_id] = $lock_cat->term_id; | |
| 1795 | + $categories[] = $lock_cat->term_id; | |
| 1852 | 1796 | $cur_usergroup->categories = $categories; |
| 1853 | 1797 | |
| 1854 | 1798 | $post_usergroups[$usergroup['ID']] = $cur_usergroup; |
| 1855 | 1799 | } |
| @@ -1859,10 +1803,8 @@ | ||
| 1859 | 1803 | } |
| 1860 | 1804 | } |
| 1861 | 1805 | } |
| 1862 | 1806 | |
| 1863 | - $this->postUserGroup[$ID] = $post_usergroups; | |
| 1864 | - | |
| 1865 | 1807 | return $post_usergroups; |
| 1866 | 1808 | } |
| 1867 | 1809 | |
| 1868 | 1810 | function get_usergroup_info($groupid) |
| @@ -1881,8 +1823,13 @@ | ||
| 1881 | 1823 | FROM ".DB_ACCESSGROUP_TO_USER." |
| 1882 | 1824 | WHERE group_id = ".$groupid." |
| 1883 | 1825 | ORDER BY user_id", ARRAY_A); |
| 1884 | 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 | + | |
| 1885 | 1832 | $db_categories = $wpdb->get_results(" SELECT * |
| 1886 | 1833 | FROM ".DB_ACCESSGROUP_TO_CATEGORY." |
| 1887 | 1834 | WHERE group_id = ".$groupid." |
| 1888 | 1835 | ORDER BY category_id", ARRAY_A); |
| @@ -1895,52 +1842,32 @@ | ||
| 1895 | 1842 | FROM $wpdb->users |
| 1896 | 1843 | ORDER BY user_nicename", ARRAY_A); |
| 1897 | 1844 | |
| 1898 | 1845 | |
| 1899 | - $args = array( 'numberposts' => -1, | |
| 1900 | - 'post_type' => 'any'); | |
| 1901 | - | |
| 1902 | - $posts = get_posts($args); | |
| 1903 | - | |
| 1904 | - if(isset($posts)) | |
| 1846 | + if(isset($db_posts)) | |
| 1905 | 1847 | { |
| 1906 | - foreach($posts as $post) | |
| 1907 | - { | |
| 1908 | - $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); | |
| 1909 | 1852 | |
| 1910 | - if(isset($groupinfo[$groupid])) | |
| 1853 | + if(isset($cur_post->post_type)) | |
| 1911 | 1854 | { |
| 1912 | - if($post->post_type == 'post') | |
| 1855 | + if($cur_post->post_type == 'post') | |
| 1913 | 1856 | { |
| 1914 | - $info->posts[$post->ID] = $post; | |
| 1857 | + $info->posts[$cur_id] = $cur_post; | |
| 1915 | 1858 | } |
| 1916 | - elseif($post->post_type == 'page') | |
| 1859 | + elseif($cur_post->post_type == 'page') | |
| 1917 | 1860 | { |
| 1918 | - $info->pages[$post->ID] = $post; | |
| 1861 | + $info->pages[$cur_id] = $cur_post; | |
| 1919 | 1862 | } |
| 1920 | - elseif($post->post_type == 'attachment') | |
| 1863 | + elseif($cur_post->post_type == 'attachment') | |
| 1921 | 1864 | { |
| 1922 | - $info->files[$post->ID] = $post; | |
| 1865 | + $info->files[$cur_id] = $cur_post; | |
| 1923 | 1866 | } |
| 1924 | 1867 | } |
| 1925 | 1868 | } |
| 1926 | 1869 | } |
| 1927 | - | |
| 1928 | - $args = array( 'numberposts' => -1, | |
| 1929 | - 'post_type' => 'attachment'); | |
| 1930 | - | |
| 1931 | - $files = get_posts($args); | |
| 1932 | - | |
| 1933 | - if(isset($files)) | |
| 1934 | - { | |
| 1935 | - foreach($files as $file) | |
| 1936 | - { | |
| 1937 | - $groupinfo = $this->get_usergroups_for_post($file->ID); | |
| 1938 | - | |
| 1939 | - if(isset($groupinfo[$groupid])) | |
| 1940 | - $info->files[$file->ID] = $file; | |
| 1941 | - } | |
| 1942 | - } | |
| 1943 | 1870 | |
| 1944 | 1871 | if(isset($db_categories)) |
| 1945 | 1872 | { |
| 1946 | 1873 | foreach($db_categories as $db_categorie) |
| @@ -2004,8 +1931,142 @@ | ||
| 2004 | 1931 | } |
| 2005 | 1932 | } |
| 2006 | 1933 | } |
| 2007 | 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 | + | |
| 2008 | 2069 | return $info; |
| 2009 | 2070 | } |
| 2010 | 2071 | |
| 2011 | 2072 | function get_usergroup_info_html($group_id, $style = null) |
| @@ -2248,43 +2309,12 @@ | ||
| 2248 | 2309 | } |
| 2249 | 2310 | |
| 2250 | 2311 | function save_postdata($post_id) |
| 2251 | 2312 | { |
| 2252 | - global $current_user, $wpdb; | |
| 2253 | - $cur_userdata = get_userdata($current_user->ID); | |
| 2313 | + global $wpdb; | |
| 2314 | + if(isset($_POST['accessgroups'])) | |
| 2315 | + $accessgroups = $_POST['accessgroups']; | |
| 2254 | 2316 | |
| 2255 | - if(empty($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 2256 | - { | |
| 2257 | - $uamOptions = $this->getAdminOptions(); | |
| 2258 | - | |
| 2259 | - $cur_categories = wp_get_post_categories($post_id); | |
| 2260 | - | |
| 2261 | - $allowded_categories = get_categories(); | |
| 2262 | - | |
| 2263 | - foreach($cur_categories as $category) | |
| 2264 | - { | |
| 2265 | - foreach($allowded_categories as $allowded_category) | |
| 2266 | - { | |
| 2267 | - if($allowded_category->term_id == $category) | |
| 2268 | - { | |
| 2269 | - $post_categories[] = $allowded_category->term_id; | |
| 2270 | - break; | |
| 2271 | - } | |
| 2272 | - } | |
| 2273 | - } | |
| 2274 | - | |
| 2275 | - if(!isset($post_categories)) | |
| 2276 | - { | |
| 2277 | - $last_category = array_pop($allowded_categories); | |
| 2278 | - $post_categories[] = $last_category->term_id; | |
| 2279 | - } | |
| 2280 | - | |
| 2281 | - wp_set_post_categories($post_id, $post_categories); | |
| 2282 | - } | |
| 2283 | - | |
| 2284 | - if(isset($_POST['accessgroups'])) | |
| 2285 | - $accessgroups = $_POST['accessgroups']; | |
| 2286 | - | |
| 2287 | 2317 | $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_POST." WHERE post_id = $post_id"); |
| 2288 | 2318 | if(isset($accessgroups)) |
| 2289 | 2319 | { |
| 2290 | 2320 | foreach($accessgroups as $accessgroup) |
| @@ -2639,41 +2669,8 @@ | ||
| 2639 | 2669 | |
| 2640 | 2670 | $wpdb->query("DELETE FROM ".DB_ACCESSGROUP_TO_CATEGORY." WHERE category_id = $category_id"); |
| 2641 | 2671 | } |
| 2642 | 2672 | |
| 2643 | - function get_login_bar() | |
| 2644 | - { | |
| 2645 | - if(!is_user_logged_in()) | |
| 2646 | - { | |
| 2647 | - if(!is_single()) | |
| 2648 | - { | |
| 2649 | - $output = '<a href="' . get_bloginfo ( 'url' ) . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']) . '">'.__('Login').'</a>'; | |
| 2650 | - } | |
| 2651 | - else | |
| 2652 | - { | |
| 2653 | - if(! isset ($user_login)) | |
| 2654 | - $user_login = ''; | |
| 2655 | - // login form | |
| 2656 | - $output = '<form action="'. get_bloginfo ( 'url' ) . '/wp-login.php" method="post" >'; | |
| 2657 | - $output .= '<p><label for="user_login">'.__('Username:').'<input name="log" value="'.wp_specialchars(stripslashes($user_login), 1).'" class="input" id="user_login" type="text" /></label></p>'; | |
| 2658 | - $output .= '<p><label for="user_pass">'.__('Password:').'<input name="pwd" class="imput" id="user_pass" type="password" /></label></p>'; | |
| 2659 | - $output .= '<p class="forgetmenot"><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> '. __('Remember me').'</label></p>'; | |
| 2660 | - $output .= '<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="'.__('Login').' »" />'; | |
| 2661 | - $output .= '<input type="hidden" name="redirect_to" value="' . $_SERVER['REQUEST_URI'] . '" />'; | |
| 2662 | - $output .= '</form>'; | |
| 2663 | - | |
| 2664 | - $output .= '<p>'; | |
| 2665 | - if (get_option('users_can_register')) | |
| 2666 | - $output .= '<a href="'.get_bloginfo('wpurl').'/wp-login.php?action=register">'.__('Register').'</a></br>'; | |
| 2667 | - $output .= '<a href="'.get_bloginfo('wpurl').'/wp-login.php?action=lostpassword" title="'. __('Password Lost and Found').'">'. __('Lost your password?').'</a>'; | |
| 2668 | - $output .= '</p>'; | |
| 2669 | - } | |
| 2670 | - | |
| 2671 | - return $output; | |
| 2672 | - } | |
| 2673 | - return null; | |
| 2674 | - } | |
| 2675 | - | |
| 2676 | 2673 | function get_access($post_id = null) |
| 2677 | 2674 | { |
| 2678 | 2675 | global $wpdb; |
| 2679 | 2676 | |
| @@ -3000,63 +2997,47 @@ | ||
| 3000 | 2997 | { |
| 3001 | 2998 | $show_posts = null; |
| 3002 | 2999 | $uamOptions = $this->getAdminOptions(); |
| 3003 | 3000 | |
| 3004 | - if(!is_feed() || ($uamOptions['protect_feed'] == 'true' && is_feed())) | |
| 3001 | + foreach($posts as $post) | |
| 3005 | 3002 | { |
| 3006 | - foreach($posts as $post) | |
| 3003 | + if( ($uamOptions['hide_post'] == 'true' && $post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $post->post_type == "page") || $this->atAdminPanel) | |
| 3007 | 3004 | { |
| 3008 | - 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)) | |
| 3009 | 3006 | { |
| 3010 | - 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") | |
| 3011 | 3016 | { |
| 3012 | - $post->post_title .= $this->admin_output($post->ID); | |
| 3013 | - $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'; | |
| 3014 | 3024 | } |
| 3015 | - } | |
| 3016 | - else | |
| 3017 | - { | |
| 3018 | - if(!$this->check_access($post->ID)) | |
| 3025 | + elseif($post->post_type == "page") | |
| 3019 | 3026 | { |
| 3020 | - if($post->post_type == "post") | |
| 3021 | - { | |
| 3022 | - $uam_post_content = $uamOptions['post_content']; | |
| 3023 | - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content); | |
| 3024 | - | |
| 3025 | - if($uamOptions['hide_post_title'] == 'true') | |
| 3026 | - $post->post_title = $uamOptions['post_title']; | |
| 3027 | - | |
| 3028 | - if($uamOptions['show_post_content_before_more'] == 'true' && preg_match('/<!--more(.*?)?-->/', $post->post_content, $matches)) | |
| 3029 | - { | |
| 3030 | - $post->post_content = explode($matches[0], $post->post_content, 2); | |
| 3031 | - $post->post_content = $post->post_content[0]." ".$uam_post_content; | |
| 3032 | - } | |
| 3033 | - else | |
| 3034 | - { | |
| 3035 | - $post->post_content = $uam_post_content; | |
| 3036 | - } | |
| 3037 | - | |
| 3038 | - if($uamOptions['allow_comments_locked'] == 'false') | |
| 3039 | - $post->comment_status = 'close'; | |
| 3040 | - } | |
| 3041 | - elseif($post->post_type == "page") | |
| 3042 | - { | |
| 3043 | - if($uamOptions['hide_page_title'] == 'true') | |
| 3044 | - $post->post_title = $uamOptions['page_title']; | |
| 3045 | - | |
| 3046 | - $uam_post_content = $uamOptions['page_content']; | |
| 3047 | - $uam_post_content = str_replace("[LOGIN_FORM]", $this->get_login_bar(), $uam_post_content); | |
| 3048 | - | |
| 3049 | - $post->post_content = $uam_post_content; | |
| 3050 | - } | |
| 3027 | + if($uamOptions['hide_page_title'] == 'true') | |
| 3028 | + $post->post_title = $uamOptions['page_title']; | |
| 3029 | + | |
| 3030 | + $post->post_content = $uamOptions['page_content']; | |
| 3051 | 3031 | } |
| 3052 | - $post->post_title .= $this->admin_output($post->ID); | |
| 3053 | - $show_posts[] = $post; | |
| 3054 | 3032 | } |
| 3033 | + $post->post_title .= $this->admin_output($post->ID); | |
| 3034 | + $show_posts[] = $post; | |
| 3055 | 3035 | } |
| 3036 | + } | |
| 3037 | + | |
| 3038 | + $posts = $show_posts; | |
| 3056 | 3039 | |
| 3057 | - $posts = $show_posts; | |
| 3058 | - } | |
| 3059 | 3040 | return $posts; |
| 3060 | 3041 | } |
| 3061 | 3042 | |
| 3062 | 3043 | function show_comment($comments = array()) |
| @@ -3065,9 +3046,9 @@ | ||
| 3065 | 3046 | $uamOptions = $this->getAdminOptions(); |
| 3066 | 3047 | |
| 3067 | 3048 | foreach($comments as $comment) |
| 3068 | 3049 | { |
| 3069 | - if($uamOptions['hide_post_comment'] == 'true' || $uamOptions['hide_post'] == 'true' ||$this->atAdminPanel) | |
| 3050 | + if($uamOptions['hide_post_comment'] == 'true' || $this->atAdminPanel) | |
| 3070 | 3051 | { |
| 3071 | 3052 | if($this->check_access($comment->comment_post_ID)) |
| 3072 | 3053 | { |
| 3073 | 3054 | $show_comments[] = $comment; |
| @@ -3126,53 +3107,75 @@ | ||
| 3126 | 3107 | function show_category($categories = array()) |
| 3127 | 3108 | { |
| 3128 | 3109 | global $current_user, $wpdb; |
| 3129 | 3110 | $cur_userdata = get_userdata($current_user->ID); |
| 3130 | - | |
| 3111 | + | |
| 3131 | 3112 | if(empty($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) |
| 3132 | 3113 | { |
| 3133 | 3114 | $uamOptions = $this->getAdminOptions(); |
| 3134 | - | |
| 3135 | - if($this->atAdminPanel) | |
| 3115 | + if($uamOptions['hide_post'] == 'true' || $uamOptions['hide_page'] == 'true' || $this->atAdminPanel) | |
| 3136 | 3116 | { |
| 3137 | - $accesscategories = $wpdb->get_results("SELECT agtc.category_id | |
| 3138 | - FROM ".DB_ACCESSGROUP_TO_USER." agtu, ".DB_ACCESSGROUP_TO_CATEGORY." agtc | |
| 3139 | - WHERE agtu.user_id = ".$current_user->ID." | |
| 3140 | - AND agtu.group_id = agtc.group_id", ARRAY_A); | |
| 3117 | + $args = array( 'numberposts' => -1); | |
| 3118 | + $posts = get_posts($args); | |
| 3141 | 3119 | |
| 3142 | - if(isset($accesscategories)) | |
| 3120 | + foreach($categories as $category) | |
| 3143 | 3121 | { |
| 3144 | - foreach($accesscategories as $accesscategory) | |
| 3145 | - { | |
| 3146 | - foreach($categories as $category) | |
| 3122 | + $count = 0; | |
| 3123 | + | |
| 3124 | + if(isset($posts)) | |
| 3125 | + { | |
| 3126 | + foreach($posts as $cur_post) | |
| 3147 | 3127 | { |
| 3148 | - if($accesscategory['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) | |
| 3149 | 3131 | { |
| 3150 | - $show_categories[$category->term_id] = $category; | |
| 3151 | - | |
| 3152 | - if(isset($empty_categories[$category->term_id])) | |
| 3153 | - unset($empty_categories[$category->term_id]); | |
| 3132 | + $post_cat_ids[] = $post_cat->term_id; | |
| 3154 | 3133 | } |
| 3155 | - else | |
| 3134 | + | |
| 3135 | + if(in_array($category->term_id, $post_cat_ids) ) | |
| 3156 | 3136 | { |
| 3157 | - if(empty($show_categories[$category->term_id])) | |
| 3158 | - $empty_categories[$category->term_id] = $category; | |
| 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 | + } | |
| 3159 | 3146 | } |
| 3160 | 3147 | } |
| 3161 | 3148 | } |
| 3162 | 3149 | |
| 3163 | - if(isset($empty_categories) && $uamOptions['lock_recursive'] == 'true') | |
| 3150 | + if($count != 0 || $uamOptions['hide_empty_categories'] == 'false') | |
| 3164 | 3151 | { |
| 3165 | - foreach($empty_categories as $empty_category) | |
| 3152 | + $category->count = $count; | |
| 3153 | + $cur_show_categories[$category->term_id] = $category; | |
| 3154 | + } | |
| 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 | + } | |
| 3163 | + } | |
| 3164 | + | |
| 3165 | + if($uamOptions['hide_empty_categories'] == 'true') | |
| 3166 | + { | |
| 3167 | + if(isset($cur_show_categories)) | |
| 3168 | + { | |
| 3169 | + foreach($cur_show_categories as $cur_show_category) | |
| 3166 | 3170 | { |
| 3167 | - $cur_cat = $empty_category; | |
| 3168 | - 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)) | |
| 3169 | 3175 | { |
| 3170 | - if(isset($show_categories[$cur_cat->parent])) | |
| 3171 | - { | |
| 3172 | - $show_categories[$empty_category->term_id] = $empty_category; | |
| 3173 | - break; | |
| 3174 | - } | |
| 3176 | + if(empty($show_categories[$cur_cat->parent])) | |
| 3177 | + $show_categories[$cur_cat->parent] = $empty_categories[$cur_cat->parent]; | |
| 3175 | 3178 | |
| 3176 | 3179 | $cur_id = $cur_cat->parent; |
| 3177 | 3180 | $cur_cat = & get_category($cur_id); |
| 3178 | 3181 | } |
| @@ -3184,107 +3187,8 @@ | ||
| 3184 | 3187 | $categories = $show_categories; |
| 3185 | 3188 | else |
| 3186 | 3189 | $categories = null; |
| 3187 | 3190 | } |
| 3188 | - else | |
| 3189 | - { | |
| 3190 | - if($uamOptions['hide_post'] == 'true' || $uamOptions['hide_page'] == 'true') | |
| 3191 | - { | |
| 3192 | - $args = array( 'numberposts' => -1); | |
| 3193 | - $posts = get_posts($args); | |
| 3194 | - | |
| 3195 | - foreach($categories as $category) | |
| 3196 | - { | |
| 3197 | - $count = 0; | |
| 3198 | - | |
| 3199 | - if(isset($posts)) | |
| 3200 | - { | |
| 3201 | - foreach($posts as $cur_post) | |
| 3202 | - { | |
| 3203 | - $post_cat_ids = array(); | |
| 3204 | - $post_cats = get_the_category($cur_post->ID); | |
| 3205 | - foreach($post_cats as $post_cat) | |
| 3206 | - { | |
| 3207 | - $post_cat_ids[] = $post_cat->term_id; | |
| 3208 | - } | |
| 3209 | - | |
| 3210 | - if(in_array($category->term_id, $post_cat_ids) ) | |
| 3211 | - { | |
| 3212 | - if( ($uamOptions['hide_post'] == 'true' && $cur_post->post_type == "post") || ($uamOptions['hide_page'] == 'true' && $cur_post->post_type == "page")) | |
| 3213 | - { | |
| 3214 | - if($this->check_access($cur_post->ID)) | |
| 3215 | - $count++; | |
| 3216 | - } | |
| 3217 | - else | |
| 3218 | - { | |
| 3219 | - $count++; | |
| 3220 | - } | |
| 3221 | - } | |
| 3222 | - } | |
| 3223 | - } | |
| 3224 | - | |
| 3225 | - if(($count != 0 || ($uamOptions['hide_empty_categories'] == 'false' && !$this->atAdminPanel ))) | |
| 3226 | - { | |
| 3227 | - $category->count = $count; | |
| 3228 | - $cur_show_categories[$category->term_id] = $category; | |
| 3229 | - } | |
| 3230 | - elseif($category->taxonomy == "link_category" || $category->taxonomy == "post_tag") | |
| 3231 | - { | |
| 3232 | - $show_categories[$category->term_id] = $category; | |
| 3233 | - } | |
| 3234 | - elseif($count == 0) | |
| 3235 | - { | |
| 3236 | - $category->count = $count; | |
| 3237 | - $empty_categories[$category->term_id] = $category; | |
| 3238 | - } | |
| 3239 | - } | |
| 3240 | - | |
| 3241 | - if($uamOptions['hide_empty_categories'] == 'true') | |
| 3242 | - { | |
| 3243 | - if(isset($cur_show_categories)) | |
| 3244 | - { | |
| 3245 | - foreach($cur_show_categories as $cur_show_category) | |
| 3246 | - { | |
| 3247 | - $cur_count = $cur_show_category->count; | |
| 3248 | - $show_categories[$cur_show_category->term_id] = $cur_show_category; | |
| 3249 | - | |
| 3250 | - $cur_cat = $cur_show_category; | |
| 3251 | - while($cur_cat->parent != 0 && isset($empty_categories)) | |
| 3252 | - { | |
| 3253 | - if(empty($show_categories[$cur_cat->parent])) | |
| 3254 | - { | |
| 3255 | - if(isset( $empty_categories[$cur_cat->parent])) | |
| 3256 | - { | |
| 3257 | - $cur_empty_cat = $empty_categories[$cur_cat->parent]; | |
| 3258 | - $cur_empty_cat->count = $cur_count; | |
| 3259 | - $show_categories[$cur_cat->parent] = $cur_empty_cat; | |
| 3260 | - } | |
| 3261 | - } | |
| 3262 | - | |
| 3263 | - $cur_id = $cur_cat->parent; | |
| 3264 | - $cur_cat = & get_category($cur_id); | |
| 3265 | - } | |
| 3266 | - } | |
| 3267 | - } | |
| 3268 | - } | |
| 3269 | - else | |
| 3270 | - { | |
| 3271 | - if(isset($cur_show_categories)) | |
| 3272 | - { | |
| 3273 | - foreach($cur_show_categories as $cur_show_category) | |
| 3274 | - { | |
| 3275 | - $show_categories[$cur_show_category->term_id] = $cur_show_category; | |
| 3276 | - } | |
| 3277 | - } | |
| 3278 | - } | |
| 3279 | - | |
| 3280 | - if(isset($show_categories)) | |
| 3281 | - $categories = $show_categories; | |
| 3282 | - else | |
| 3283 | - $categories = null; | |
| 3284 | - } | |
| 3285 | - } | |
| 3286 | - | |
| 3287 | 3191 | } |
| 3288 | 3192 | |
| 3289 | 3193 | return $categories; |
| 3290 | 3194 | } |
| @@ -3311,50 +3215,22 @@ | ||
| 3311 | 3215 | function show_next_previous_post($sql) |
| 3312 | 3216 | { |
| 3313 | 3217 | $uamOptions = $this->getAdminOptions(); |
| 3314 | 3218 | |
| 3315 | - if($uamOptions['hide_post'] == 'true') | |
| 3219 | + $posts = get_posts(); | |
| 3220 | + if(isset($posts)) | |
| 3316 | 3221 | { |
| 3317 | - $posts = get_posts(); | |
| 3318 | - if(isset($posts)) | |
| 3222 | + foreach($posts as $post) | |
| 3319 | 3223 | { |
| 3320 | - foreach($posts as $post) | |
| 3321 | - { | |
| 3322 | - if(!$this->check_access($post->ID)) | |
| 3323 | - $excluded_posts[] = $post->ID; | |
| 3324 | - } | |
| 3325 | - if(isset($excluded_posts)) | |
| 3326 | - { | |
| 3327 | - $excluded_posts_str = implode(",", $excluded_posts); | |
| 3328 | - $sql .= "AND ID NOT IN($excluded_posts_str)"; | |
| 3329 | - } | |
| 3330 | - } | |
| 3331 | - } | |
| 3332 | - | |
| 3333 | - return $sql; | |
| 3334 | - } | |
| 3335 | - | |
| 3336 | - function show_post_sql($sql) | |
| 3337 | - { | |
| 3338 | - $uamOptions = $this->getAdminOptions(); | |
| 3339 | - | |
| 3340 | - if(($uamOptions['hide_post'] == 'true' && !is_feed()) || (is_feed() && $uamOptions['protect_feed'] == 'true')) | |
| 3341 | - { | |
| 3342 | - $posts = get_posts(); | |
| 3343 | - if(isset($posts)) | |
| 3224 | + if(!$this->check_access($post->ID)) | |
| 3225 | + $excluded_posts[] = $post->ID; | |
| 3226 | + } | |
| 3227 | + if(isset($excluded_posts)) | |
| 3344 | 3228 | { |
| 3345 | - foreach($posts as $post) | |
| 3346 | - { | |
| 3347 | - if(!$this->check_access($post->ID)) | |
| 3348 | - $excluded_posts[] = $post->ID; | |
| 3349 | - } | |
| 3350 | - if(isset($excluded_posts)) | |
| 3351 | - { | |
| 3352 | - $excluded_posts_str = implode(",", $excluded_posts); | |
| 3353 | - $sql .= "AND ID NOT IN($excluded_posts_str)"; | |
| 3354 | - } | |
| 3355 | - } | |
| 3356 | - } | |
| 3229 | + $excluded_posts_str = implode(",", $excluded_posts); | |
| 3230 | + $sql .= "AND ID NOT IN($excluded_posts_str)"; | |
| 3231 | + } | |
| 3232 | + } | |
| 3357 | 3233 | |
| 3358 | 3234 | return $sql; |
| 3359 | 3235 | } |
| 3360 | 3236 | |
| @@ -3436,9 +3312,9 @@ | ||
| 3436 | 3312 | { |
| 3437 | 3313 | $cur_url = explode("?", "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
| 3438 | 3314 | $file = str_replace($cur_url[0], "", $cur_post->guid); |
| 3439 | 3315 | $filename = basename($file); |
| 3440 | - | |
| 3316 | + | |
| 3441 | 3317 | if(file_exists($file)) |
| 3442 | 3318 | { |
| 3443 | 3319 | $len = filesize($file); |
| 3444 | 3320 | header('content-type: '.$cur_post->post_mime_type); |
| @@ -3536,9 +3412,9 @@ | ||
| 3536 | 3412 | //Initialize the admin panel |
| 3537 | 3413 | if(!function_exists("UserAccessManager_AP")) { |
| 3538 | 3414 | function UserAccessManager_AP() |
| 3539 | 3415 | { |
| 3540 | - global $userAccessManager, $wp_version, $current_user, $wpdb; | |
| 3416 | + global $userAccessManager, $wp_version; | |
| 3541 | 3417 | |
| 3542 | 3418 | $userAccessManager->atAdminPanel = true; |
| 3543 | 3419 | |
| 3544 | 3420 | if (!isset($userAccessManager)) |
| @@ -3546,9 +3422,9 @@ | ||
| 3546 | 3422 | return; |
| 3547 | 3423 | } |
| 3548 | 3424 | if (function_exists('add_menu_page')) |
| 3549 | 3425 | { |
| 3550 | - add_menu_page('User Access Manager', 'Access Manager', 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"); | |
| 3551 | 3427 | } |
| 3552 | 3428 | if (function_exists('add_submenu_page')) |
| 3553 | 3429 | { |
| 3554 | 3430 | add_submenu_page('uam_usergroup', TXT_MANAGE_GROUP, TXT_MANAGE_GROUP, 9, 'uam_usergroup', array(&$userAccessManager, 'printAdminPage')); |
| @@ -3555,19 +3431,12 @@ | ||
| 3555 | 3431 | add_submenu_page('uam_usergroup', TXT_SETTINGS, TXT_SETTINGS, 9, 'uam_settings', array(&$userAccessManager, 'printAdminPage')); |
| 3556 | 3432 | } |
| 3557 | 3433 | if( function_exists( 'add_meta_box' )) |
| 3558 | 3434 | { |
| 3559 | - get_currentuserinfo(); | |
| 3560 | - $cur_userdata = get_userdata($current_user->ID); | |
| 3561 | - | |
| 3562 | - if(isset($cur_userdata->{$wpdb->prefix."capabilities"}['administrator'])) | |
| 3563 | - { | |
| 3564 | - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'post', 'side' ); | |
| 3565 | - add_meta_box( 'uma_post_access', 'Access', array(&$userAccessManager, 'edit_post_content'), 'page', 'side' ); | |
| 3566 | - } | |
| 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' ); | |
| 3567 | 3437 | } |
| 3568 | 3438 | |
| 3569 | - | |
| 3570 | 3439 | //Admin actions |
| 3571 | 3440 | |
| 3572 | 3441 | $userAccessManager->update(); |
| 3573 | 3442 | |
| @@ -3592,9 +3461,8 @@ | ||
| 3592 | 3461 | add_action('wp_print_styles', array(&$userAccessManager, 'add_styles') ); |
| 3593 | 3462 | |
| 3594 | 3463 | |
| 3595 | 3464 | //Admin filters |
| 3596 | - | |
| 3597 | 3465 | add_filter('manage_posts_columns', array(&$userAccessManager, 'add_post_columns_header')); |
| 3598 | 3466 | add_filter('manage_pages_columns', array(&$userAccessManager, 'add_post_columns_header')); |
| 3599 | 3467 | |
| 3600 | 3468 | $uamOptions = $userAccessManager->getAdminOptions(); |
| @@ -3619,9 +3487,9 @@ | ||
| 3619 | 3487 | if(isset($userAccessManager)) |
| 3620 | 3488 | { |
| 3621 | 3489 | add_action('init', array(&$userAccessManager, 'init')); |
| 3622 | 3490 | $uamOptions = $userAccessManager->getAdminOptions(); |
| 3623 | - | |
| 3491 | + | |
| 3624 | 3492 | //install |
| 3625 | 3493 | if(function_exists('register_activation_hook')) |
| 3626 | 3494 | register_activation_hook(__FILE__, array(&$userAccessManager, 'install')); |
| 3627 | 3495 | |
| @@ -3631,9 +3499,9 @@ | ||
| 3631 | 3499 | register_deactivation_hook(__FILE__, array(&$userAccessManager, 'uninstall')); |
| 3632 | 3500 | |
| 3633 | 3501 | if(function_exists('register_deactivation_hook')) |
| 3634 | 3502 | register_deactivation_hook(__FILE__, array(&$userAccessManager, 'deactivate')); |
| 3635 | - | |
| 3503 | + | |
| 3636 | 3504 | //Actions |
| 3637 | 3505 | add_action('admin_menu', 'UserAccessManager_AP'); |
| 3638 | 3506 | |
| 3639 | 3507 | if($uamOptions['redirect'] != 'false' || isset($_GET['getfile'])) |
| @@ -3648,7 +3516,7 @@ | ||
| 3648 | 3516 | add_filter('get_next_post_where', array(&$userAccessManager, 'show_next_previous_post')); |
| 3649 | 3517 | add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post')); |
| 3650 | 3518 | add_filter('get_previous_post_where', array(&$userAccessManager, 'show_next_previous_post')); |
| 3651 | 3519 | add_filter('the_title', array(&$userAccessManager, 'show_title'), 10, 2); |
| 3652 | - add_filter('posts_where', array(&$userAccessManager, 'show_post_sql')); | |
| 3653 | 3520 | } |
| 3654 | -?> | |
| 3521 | + | |
| 3522 | +?> | |