function set_migas($guid_actual)
{
    global $CONFIG;
    $group = get_entity($guid_actual);
    if (!$group || !elgg_instanceof($group, "group")) {
        //forward(REFERER);
        return;
        //TODO: ver que es mejor en este caso
    }
    //GUARDAMOS EL ARRAY DEL GRUPO ACTUAL
    $link_group = $group->getURL();
    $title_group = $group->name;
    $guid_group = $group->guid;
    $CONFIG->array_migas[] = array($guid_group, $title_group, $link_group);
    //var_dump($CONFIG->array_migas); // esta vacio
    //GUARDAMOS EL ARRAY DEL GRUPO PADRE
    get_parent_group($guid_actual);
    $group_padre = get_entity($CONFIG->padre->guid);
    if ($group_padre != NULL) {
        $title_padre = $group_padre->name;
        $contexto = elgg_get_context();
        switch ($contexto) {
            case "discussion":
                $link_padre = elgg_get_site_url() . "discussion/owner/" . $CONFIG->padre->guid;
                break;
            case "pages":
                $link_padre = elgg_get_site_url() . "pages/groups/" . $CONFIG->padre->guid;
            default:
                $link_padre = $group_padre->getURL();
        }
        $CONFIG->array_migas[] = array($CONFIG->padre->guid, $title_padre, $link_padre);
        //var_dump($CONFIG->array_migas); // un 49 como una catedral
    }
    //GUARDAMOS LOS ARRAYS DEL RESTO DE ASCENDENCIA
    while (isset($CONFIG->padre)) {
        $abuelo = get_parent_group($CONFIG->padre->guid);
        if ($abuelo != NULL) {
            //var_dump($abuelo->guid);
            $link_abuelo = $abuelo->getURL();
            $title_abuelo = $abuelo->name;
            $CONFIG->array_migas[] = array($abuelo->guid, $title_abuelo, $link_abuelo);
        }
        // echo $CONFIG->array_migas[0];
        //cuando no haya padre será igual a NULL
        $CONFIG->padre = $abuelo;
    }
    //var_dump($CONFIG->array_migas);
}
Example #2
0
 *
 * @uses $vars['entity']     The entity the icon represents - uses getIconURL() method
 * @uses $vars['size']       topbar, tiny, small, medium (default), large, master
 * @uses $vars['href']       Optional override for link
 * @uses $vars['img_class']  Optional CSS class added to img
 * @uses $vars['link_class'] Optional CSS class for the link
 */
$entity = $vars['entity'];
$sizes = array('small', 'medium', 'large', 'tiny', 'master', 'topbar');
// Get size
if (!in_array($vars['size'], $sizes)) {
    $vars['size'] = "medium";
}
$class = elgg_extract('img_class', $vars, '');
$span = '';
$parent = get_parent_group($entity);
if ($parent) {
    if ($class) {
        $class .= ' ';
    }
    $class .= 'au_subgroup_icon ';
    $span = '<span class="au_subgroup au_subgroup_icon-' . $vars['size'] . '">' . elgg_echo('au_subgroups:subgroup') . '</span>';
}
if (isset($entity->name)) {
    $title = $entity->name;
} else {
    $title = $entity->title;
}
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false);
$url = $entity->getURL();
if (isset($vars['href'])) {
Example #3
0
<?php

namespace AU\SubGroups;

$group = elgg_get_page_owner_entity();
$parent = get_parent_group($group);
// radio buttons use label => value
$options_values = array(elgg_echo('au_subgroups:deleteoption:delete') => 'delete', elgg_echo('au_subgroups:deleteoption:owner') => 'owner');
if ($parent) {
    $options_values[elgg_echo('au_subgroups:deleteoption:parent')] = 'parent';
}
echo "<label>" . elgg_echo('au_subgroups:delete:label') . "</label><br><br>";
echo elgg_view('input/radio', array('name' => 'au_subgroups_content_policy', 'value' => 'delete', 'options' => $options_values));
echo "<br><br>";
echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $group->guid));
echo elgg_view('input/submit', array('value' => elgg_echo('submit')));
Example #4
0
function titlemenu($h, $t, $r, $p)
{
    if (in_array(elgg_get_context(), array('group_profile', 'groups'))) {
        $group = elgg_get_page_owner_entity();
        // make sure we're dealing with a group
        if (!elgg_instanceof($group, 'group')) {
            return $r;
        }
        // make sure the group is a subgroup
        $parent = get_parent_group($group);
        if (!$parent) {
            return $r;
        }
        // see if we're a member of the parent group
        if ($parent->isMember()) {
            return $r;
        }
        $actions = array();
        $url = elgg_get_site_url() . "action/groups/join?group_guid={$parent->getGUID()}";
        $url = elgg_add_action_tokens_to_url($url);
        if ($parent->isPublicMembership() || $parent->canEdit()) {
            $actions[$url] = 'groups:join';
        } else {
            // request membership
            $actions[$url] = 'groups:joinrequest';
        }
        // we're not a member, so we need to remove any 'join'/'request membership' links
        foreach ($r as $key => $item) {
            if (in_array($item->getName(), array('groups:join', 'groups:joinrequest'))) {
                $r[$key]->setHref($url);
                $r[$key]->setText(elgg_echo('subgroups:parent:need_join'));
            }
        }
        return $r;
    }
}
Example #5
0
/**
 * Determines if a subgroup could potentially be moved
 * To a parent group
 * Makes sure permissions are in order, and that the subgroup isn't already a parent
 * of the parent or anything weird like that
 * 
 * @param type $user ElggUser
 * @param type $subgroup_guid
 * @param type $parentgroup_guid
 */
function can_move_subgroup($subgroup, $parent, $user = NULL)
{
    if (!elgg_instanceof($user, 'user')) {
        $user = elgg_get_logged_in_user_entity();
    }
    if (!$user) {
        return false;
    }
    // make sure they're really groups
    if (!elgg_instanceof($subgroup, 'group') || !elgg_instanceof($parent, 'group')) {
        return false;
    }
    // make sure we can edit them
    if (!$subgroup->canEdit($user->guid) || !$parent->canEdit($user->guid)) {
        return false;
    }
    // make sure we can edit all the way up, and we're not trying to move a group into itself
    if (!can_edit_recursive($subgroup) || $subgroup->guid == $parent->guid) {
        return false;
    }
    // make sure we're not moving a group into it's existing parent
    $current_parent = get_parent_group($subgroup);
    if ($current_parent && $current_parent->guid == $parent->guid) {
        return false;
    }
    // also make sure the potential parent isn't a subgroup of the subgroup
    $children = get_all_children_guids($subgroup);
    if (in_array($parent->guid, $children)) {
        return false;
    }
    return true;
}
Example #6
0
<?php

namespace AU\SubGroups;

$subgroup_guid = get_input('subgroup_guid');
$parent_guid = get_input('parent_guid');
$subgroup = get_entity($subgroup_guid);
$parent = get_entity($parent_guid);
$oldparent = get_parent_group($subgroup);
$child_groups = get_all_children_guids($subgroup);
//sanity check
if (!elgg_instanceof($subgroup, 'group') || !elgg_instanceof($parent, 'group')) {
    register_error(elgg_echo('au_subgroups:error:invalid:group'));
    forward(REFERER);
}
// we need to have edit permissions all the way up
if (!can_move_subgroup($subgroup, $parent)) {
    register_error(elgg_echo('au_subgroups:error:permissions'));
    forward(REFERER);
}
// remove any existing parent relationships
remove_parent_group($subgroup->guid);
set_parent_group($subgroup->guid, $parent->guid);
// determine the access_id of the new group, must be equal or more restrictive than the parent
switch ($parent->access_id) {
    case ACCESS_PUBLIC:
        // only need to check that subgroup wasn't to old parent only
        if ($subgroup->access_id == $oldparent->group_acl) {
            $subgroup->access_id = $parent->group_acl;
        }
        break;
Example #7
0
function delete_group_event($event, $type, $group)
{
    $content_policy = get_input('au_subgroups_content_policy', false);
    if (!$content_policy) {
        return true;
    }
    $guid = get_input('guid');
    if (!$guid) {
        $guid = get_input('group_guid');
    }
    // protects against recursion on the group/delete action
    if (!$guid || $group->guid != $guid) {
        return true;
    }
    $parent = get_parent_group($group);
    // this is the top level to delete, so if transferring content to parent, it's the parent of this
    // apply content policy recursively, then delete all subgroups recursively
    // this could take a while...
    set_time_limit(0);
    $guids = get_all_children_guids($group);
    $guids[] = $group->guid;
    if (is_array($guids) && count($guids)) {
        if ($content_policy != 'delete' && is_array($guids) && count($guids)) {
            $options = array('container_guids' => $guids, 'au_subgroups_content_policy' => $content_policy, 'au_subgroups_parent_guid' => $parent->guid, 'limit' => 0);
            $batch = new \ElggBatch('elgg_get_entities', $options, null, 25);
            $ia = elgg_set_ignore_access(true);
            foreach ($batch as $content) {
                if ($content_policy == 'owner') {
                    $container_guid = $content->owner_guid;
                } else {
                    $container_guid = $parent->guid;
                }
                $content->container_guid = $container_guid;
                $content->save();
            }
            elgg_set_ignore_access($ia);
        }
        // now delete the groups themselves
        $options = array('guids' => $guids, 'types' => array('group'), 'limit' => 0);
        $batch = new \ElggBatch('elgg_get_entities', $options, null, 25, false);
        foreach ($batch as $e) {
            if ($e->guid == $group->guid) {
                continue;
                // the action itself will take care of this
            }
            $e->delete();
        }
    }
}