Example #1
0
/**
 * Clones the custom layout of a parent group, for a newly created subgroup
 * @param type $group
 * @param type $parent
 */
function au_subgroups_clone_layout($group, $parent)
{
    if (!elgg_is_active_plugin('group_custom_layout') || !group_custom_layout_allow($parent)) {
        return false;
    }
    // get the layout object for the parent
    if ($parent->countEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION) <= 0) {
        return false;
    }
    $parentlayout = $parent->getEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION);
    $parentlayout = $parentlayout[0];
    $layout = new ElggObject();
    $layout->subtype = GROUP_CUSTOM_LAYOUT_SUBTYPE;
    $layout->owner_guid = $group->getGUID();
    $layout->container_guid = $group->getGUID();
    $layout->access_id = ACCESS_PUBLIC;
    $layout->save();
    // background image
    $layout->enable_background = $parentlayout->enable_background;
    $parentimg = elgg_get_config('dataroot') . 'group_custom_layout/backgrounds/' . $parent->getGUID() . '.jpg';
    $groupimg = elgg_get_config('dataroot') . 'group_custom_layout/backgrounds/' . $group->getGUID() . '.jpg';
    if (file_exists($parentimg)) {
        copy($parentimg, $groupimg);
    }
    $layout->enable_colors = $parentlayout->enable_colors;
    $layout->background_color = $parentlayout->background_color;
    $layout->border_color = $parentlayout->border_color;
    $layout->title_color = $parentlayout->title_color;
    $group->addRelationship($layout->getGUID(), GROUP_CUSTOM_LAYOUT_RELATION);
}
Example #2
0
function group_custom_layout_get_layout(ElggGroup $group)
{
    $result = false;
    if (!empty($group) && elgg_instanceof($group, "group")) {
        if (group_custom_layout_allow($group)) {
            if ($layouts = $group->getEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION)) {
                $result = $layouts[0];
            }
        }
    }
    return $result;
}
Example #3
0
function group_custom_layout_pagesetup()
{
    $group = elgg_get_page_owner_entity();
    if (!empty($group) && elgg_instanceof($group, "group")) {
        if (group_custom_layout_allow($group) && $group->canEdit()) {
            // add menu item for group admins to edit layout
            elgg_register_menu_item("page", array("name" => "group_layout", "text" => elgg_echo("group_custom_layout:edit"), "href" => "group_custom_layout/" . $group->getGUID(), "context" => "group_profile"));
        }
        if ($layout = group_custom_layout_get_layout($group)) {
            elgg_register_css("custom_group_layout", "group_custom_layout/group_css/" . $layout->getGUID() . "/" . $layout->time_updated . ".css");
            elgg_load_css("custom_group_layout");
        }
    }
}



</script>	



</div>

<div id="usermenubranding" >  <!-- open user menu -->
	<?php 
        if (elgg_is_logged_in()) {
            $group = elgg_get_page_owner_entity();
            if (!empty($group) && elgg_instanceof($group, "group")) {
                if (group_custom_layout_allow($group) && $group->canEdit()) {
                    // add menu item for group admins to edit layout
                    elgg_register_menu_item("page", array('class' => 'homepage_profile_link tom-button tom-button-special', 'name' => 'group_layout', 'href' => "group_custom_layout/" . $group->getGUID(), 'text' => elgg_view_icon('users') . elgg_echo('group_custom_layout:edit'), 'contexts' => array('groups'), 'priority' => 1));
                }
            }
        }
        // Our shearch bar
        //	echo elgg_view('search/header',array(
        ?>

 </div>  <!-- close user buttons   -->