/** * Since we don't always have access to the params passed to BP_Groups_Template * we have to wait until after constructor has run to fill in details */ function synchronize() { global $bp; if (isset($this->params) && array_key_exists('parent_id', $this->params)) { /** * Fill in requests by parent_id for tree traversal on admin side */ $this->groups = bp_group_hierarchy_get_by_hierarchy($this->params); $this->total_group_count = $this->groups['total']; $this->groups = $this->groups['groups']; $this->group_count = count($this->groups); // Re-build pagination links with new group counts if ((int) $this->total_group_count && (int) $this->pag_num) { $this->pag_links = paginate_links(array('base' => add_query_arg(array('grpage' => '%#%', 'num' => $this->pag_num, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1)); } } else { if ($this->single_group && $bp->groups->current_group) { /** * Groups with multi-level slugs are missed by the parent. * Fill them in from $bp->groups->current_group */ $this->groups = array((object) array('group_id' => $bp->groups->current_group->id)); $this->group_count = 1; } } }
/** * Restrict group listing to top-level groups */ function bp_group_hierarchy_get_groups_tree($groups, $params, $parent_id = 0) { global $bp, $groups_template; if (isset($_POST['scope']) && $_POST['object'] == 'tree' && $_POST['scope'] != 'all') { $parent_id = substr($_POST['scope'], 8); $parent_id = (int) $parent_id; } /** * Replace retrieved list with toplevel groups * unless on a group page (member groups list) or viewing "My Groups" */ if (!isset($bp->groups->current_group->id) && !$params['user_id']) { /** remove search placeholder text for BP 1.5 */ if (function_exists('bp_get_search_default_text') && trim($params['search_terms']) == bp_get_search_default_text('groups')) { $params['search_terms'] = ''; } if (empty($params['search_terms'])) { $params['parent_id'] = $parent_id; $toplevel_groups = bp_group_hierarchy_get_by_hierarchy($params); $groups = $toplevel_groups; } } return $groups; }