function blogs() { $where = "blog_parent_id = " . $this->id; require_once 'class.mt_blog.php'; $blog = new Blog(); $blogs = $blog->Find($where); return $blogs; }
function blogs() { if ($this->class == 'blog') { return null; } $where = "blog_parent_id = " . $this->id; $blog = new Blog(); $blogs = $blog->Find($where); return $blogs; }
public function fetch_blogs($args = null) { if ($blog_ids = $this->include_exclude_blogs($args)) { $blog_filter = 'blog_id ' . $blog_ids; } else { $blog_filter = '1 = 1'; } if (!isset($args['class'])) { $args['class'] = 'blog'; } $where = $blog_filter; $where .= $args['class'] == '*' ? "" : " and blog_class = '" . $args['class'] . "'"; $where .= ' order by blog_name'; require_once 'class.mt_blog.php'; $blogs = null; $blog = new Blog(); $blogs = $blog->Find($where); return $blogs; }
function multiblog_filter_blogs(&$ctx, $is_include, $blogs) { # Set flag to indicate whether @blogs are to be included or excluded $is_include = $is_include == 'include_blogs' ? 1 : 0; # Set local blog $this_blog = $ctx->stash('blog_id'); $multiblog_system_config = multiblog_fetch_system_config(); # Get the MultiBlog system config for default access and overrides if (isset($multiblog_system_config['default_access_allowed'])) { $default_access_allowed = $multiblog_system_config['default_access_allowed']; } else { $default_access_allowed = 1; } $access_overrides = $multiblog_system_config['access_overrides']; if (!$access_overrides) { $access_overrides = array(); } # System setting allows access by default if ($default_access_allowed) { # include_blogs="all" if ($is_include && $blogs[0] == "all") { # Check for any deny overrides. # If found, switch to exclude_blogs="..." $deny = array(); foreach (array_keys($access_overrides) as $o) { if ($o != $this_blog && (isset($access_overrides[$o]) && $access_overrides[$o] == MULTIBLOG_ACCESS_DENIED)) { $deny[] = $o; } } return count($deny) ? array('exclude_blogs', $deny) : array('include_blogs', array('all')); } elseif ($blogs[0] == 'site' || $blogs[0] == 'children' || $blogs[0] == 'siblings') { $mt = MT::get_instance(); $ctx = $mt->context(); $blog = $ctx->stash('blog'); if (!empty($blog)) { $website = $blog->class == 'blog' ? $blog->website() : $blog; $blogs = $website->blogs(); if (empty($blogs)) { $blogs = array(); } $allow = array(); foreach ($blogs as $b) { if ($b->id == $this_blog || !isset($access_overrides[$b->id]) || $access_overrides[$b->id] == MULTIBLOG_ACCESS_ALLOWED) { array_push($allow, $b->id); } } } return count($allow) ? array('include_blogs', $allow) : null; } elseif ($is_include && count($blogs)) { # Remove any included blogs that are specifically deny override # Return undef is all specified blogs are deny override $allow = array(); foreach ($blogs as $b) { if ($b == $this_blog || !isset($access_overrides[$b]) || $access_overrides[$b] == MULTIBLOG_ACCESS_ALLOWED) { $allow[] = $b; } } return count($allow) ? array('include_blogs', $allow) : null; } else { # Add any deny overrides blogs to the list and de-dupe foreach (array_keys($access_overrides) as $o) { if ($o != $this_blog && (isset($access_overrides[$o]) && $access_overrides[$o] == MULTIBLOG_ACCESS_DENIED)) { $blogs[] = $o; } } $seen = array(); foreach ($blogs as $b) { $seen[$b] = 1; } $blogs = array_keys($seen); return array('exclude_blogs', $blogs); } } else { # include_blogs="all" if ($is_include && $blogs[0] == "all") { # Enumerate blogs from allow override # Hopefully this is significantly smaller than @all_blogs $allow = array(); foreach (array_keys($access_overrides) as $o) { if ($o == $this_blog || isset($access_overrides[$o]) && $access_overrides[$o] == MULTIBLOG_ACCESS_ALLOWED) { $allow[] = $o; } } if (!isset($access_overrides[$this_blog])) { $allow[] = $this_blog; } return count($allow) ? array('include_blogs', $allow) : null; } elseif ($blogs[0] == 'site' || $blogs[0] == 'children' || $blogs[0] == 'siblings') { $mt = MT::get_instance(); $ctx = $mt->context(); $blog = $ctx->stash('blog'); if (!empty($blog) && $blog->class == 'blog') { require_once 'class.mt_blog.php'; $blog_class = new Blog(); $blogs = $blog_class->Find("blog_parent_id = " . $blog->parent_id); $allow = array(); foreach ($blogs as $b) { if ($b->id == $this_blog || isset($access_overrides[$b->id]) && $access_overrides[$b->id] == MULTIBLOG_ACCESS_ALLOWED) { array_push($allow, $b->id); } } } return count($allow) ? array('include_blogs', $allow) : null; } elseif ($is_include && count($blogs)) { # Filter @blogs returning only those with allow override $allow = array(); foreach ($blogs as $b) { if ($b == $this_blog || isset($access_overrides[$b]) && $access_overrides[$b] == MULTIBLOG_ACCESS_ALLOWED) { $allow[] = $b; } } return count($allow) ? array('include_blogs', $allow) : null; } else { # Get allow override blogs and then omit # the specified excluded blogs. $allow = array(); foreach (array_keys($access_overrides) as $o) { if ($o == $this_blog || isset($access_overrides[$o]) && $access_overrides[$o] == MULTIBLOG_ACCESS_ALLOWED) { $allow[] = $o; } } if (!isset($access_overrides[$this_blog])) { $allow[] = $this_blog; } $seen = array(); foreach ($blogs as $b) { $seen[$b] = 1; } $blogs = array(); foreach ($allow as $a) { if (!isset($seen[$a])) { $blogs[] = $a; } } return count($blogs) ? array('include_blogs', $blogs) : null; } } }