false));
}
function allow_getCategory() {
static $cats;
if (!isset($cats)) {
global $user_ID;
$user = Allow_Category::allow_getUser($user_ID);
$public = Allow_Category::allow_getPublic();
$loggedin = Allow_Category::allow_getLoggedIn();
if ($user && $public && $loggedin) {
$cats = array_merge($user,$public,$loggedin);
} elseif ($user && $public) {
$cats = array_merge($user,$public);
} elseif ($user && $loggedin) {
$cats = array_merge($user,$loggedin);
} elseif ($public && $loggedin) {
$cats = array_merge($public,$loggedin);
} elseif ($user) {
$cats = $user;
} elseif ($loggedin) {
$cats = $loggedin;
} else {
$cats = $public;
}
}
return $cats;
}
function allow_getCategoryString() {
return implode(",",Allow_Category::allow_getCategory());
}
function allow_getCategoryIncludeString() {
return "include=" . Allow_Category::allow_getCategoryString();
}
function allow_getCategoryDetails() {
return get_categories(Allow_Category::allow_getCategoryIncludeString());
}
function allow_getUser($user) {
$opts = get_option("allow_option");
$keys = array_keys($opts);
$sid = (string)$user;
if (in_array($sid, $keys)) {
return $opts[$sid];
}
return false;
}
function allow_getPublic() {
return Allow_Category::allow_getUser("public");
}
function allow_getLoggedIn() {
if (Allow_Category::allow_loggedIn()) {
return Allow_Category::allow_getUser("loggedin");
}
}
function allow_removeCategorySelection($page) {
global $catUserPreg;
$cats = Allow_Category::allow_getAllCategories();
foreach ($cats as $cat){
$keep = false;
if ($catUserPreg) {
//might need to add code here, to make sure old categories remain, even if user doesn't have permission
if (in_array($cat->cat_ID,$catUserPreg)) {
$keep = true;
}
}
if (!$keep) {
$page2=preg_replace('#id="in-category-'. $cat->cat_ID .'" checked="checked"#', 'id="in-category-'. $cat->cat_ID .'" checked="checked" disabled', $page);
if($page == $page2) {
if ( count(get_categories(array('child_of' => $cat->cat_ID))) ) {
$page=preg_replace("#
cat_ID\".*?#sim", "", $page);
}else{
$page=preg_replace("#cat_ID\".*?#sim", "", $page);
}
} else {
$page = $page2;
}
}
}
return $page;
}
function allow_wpversion_cat() {
global $wp_version;
$version = explode (".", $wp_version);
return ($version[0] > 2 || ($version[0] == 2 && $version[1] >= 3));
}
function allow_wpversion_user() {
global $wp_version;
$version = explode (".", $wp_version);
return ($version[0] > 2 || ($version[0] == 2 && $version[1] >= 5));
}
function allow_where($where) {
global $wpdb;
global $userdata;
$show_titles = get_option("allow_show_titles");
$pages_public = get_option("allow_pages_public");
$redirect_notperm = get_option("allow_redirect_notperm");
get_currentuserinfo();
try{ // 0.6.7: Added by flogiston.net
//If we know its a page, and the user can see pages, no point to do the following
if (Allow_Category::allow_notAdmin() && !($redirect_notperm && !Allow_Category::allow_loggedIn() && (is_single() || is_category())) && !($show_titles && is_feed()) && !(($pages_public || Allow_Category::allow_loggedIn()) && is_page())) {
$catUser = Allow_Category::allow_getCategory();
if (Allow_Category::allow_wpversion_cat()) {
$ids = get_objects_in_term($catUser, 'category');
if (is_wp_error($ids)) {
return $ids;
}
} else {
$query = 'SELECT p.ID FROM $wpdb->posts p, $wpdb->post2cat p2c, $wpdb->categories c WHERE p.ID = p2c.post_id AND p2c.category_id = c.cat_ID';
$query .= ' AND category_id in (' . implode(', ', $catUser) . ')';
$ids = $wpdb->get_col($query . ';');
}
if ( count($ids) <= 0 ) {
//No Permissions, remove all posts
$ids = array(-1);
}
$out_posts = implode(', ', $ids);
if ($pages_public || Allow_Category::allow_loggedIn()) {
$includepages = " OR $wpdb->posts.post_type = 'page'";
}
if (Allow_Category::allow_loggedIn()) {
$draftsbyauthor = " OR ($wpdb->posts.post_status = 'draft' AND $wpdb->posts.post_author = $userdata->ID)";
}
$where .= " AND ($wpdb->posts.ID IN ($out_posts)$draftsbyauthor$includepages)";
}
// 0.6.7: Added by flogiston.net
} catch(GlobalException $e){
error_log("allowcat err:".$e->getMessage());
}
return $where;
}
function allow_notAllowed($page) {
return preg_replace("#