Example #1
0
function groups_from_members_member_can_invite($hook_name, $entity_type, $return_value, $parameters)
{
    if (get_context() == 'groupsfrommembers' && $entity_type == 'group') {
        $group = $parameters['entity'];
        $user = $parameters['user'];
        if ($group->members_invite_enable != 'no') {
            if (is_group_member($group->getGUID(), $user->getGUID())) {
                return true;
            }
        }
    }
    return $return_value;
}
Example #2
0
<?php

admin_gatekeeper();
// this could take a while ;)
set_time_limit(0);
$group_guid = (int) get_input("group_guid");
if (!empty($group_guid)) {
    if (($group = get_entity($group_guid)) && $group instanceof ElggGroup) {
        // set counters
        $already = 0;
        $new = 0;
        $failure = 0;
        $options = array("type" => "user", "relationship" => "member_of_site", "relationship_guid" => elgg_get_site_entity()->getGUID(), "inverse_relationship" => true, "limit" => false, "callback" => "group_tools_guid_only_callback");
        if ($user_guids = elgg_get_entities_from_relationship($options)) {
            foreach ($user_guids as $user_guid) {
                if (!is_group_member($group->getGUID(), $user_guid)) {
                    if (join_group($group->getGUID(), $user_guid)) {
                        $new++;
                    } else {
                        $failure++;
                    }
                } else {
                    $already++;
                }
                // cleanup cache, to be sure
                invalidate_cache_for_entity($user_guid);
            }
        }
        system_message(elgg_echo("group_tools:action:fix_auto_join:success", array($new, $already, $failure)));
    } else {
        register_error(elgg_echo("group_tools:action:error:entity"));
Example #3
0
        $group->{$option_toggle_name} = get_input($option_toggle_name, $option_default);
    }
}
// Group membership - should these be treated with same constants as access permissions?
$is_public_membership = get_input('membership') == ACCESS_PUBLIC;
$group->membership = $is_public_membership ? ACCESS_PUBLIC : ACCESS_PRIVATE;
if ($is_new_group) {
    $group->access_id = ACCESS_PUBLIC;
}
$old_owner_guid = $is_new_group ? 0 : $group->owner_guid;
$new_owner_guid = (int) get_input('owner_guid');
$owner_has_changed = false;
$old_icontime = null;
if (!$is_new_group && $new_owner_guid && $new_owner_guid != $old_owner_guid) {
    // verify new owner is member and old owner/admin is logged in
    if (is_group_member($group_guid, $new_owner_guid) && ($old_owner_guid == $user->guid || $user->isAdmin())) {
        $group->owner_guid = $new_owner_guid;
        $group->container_guid = $new_owner_guid;
        $metadata = elgg_get_metadata(array('guid' => $group_guid, 'limit' => false));
        if ($metadata) {
            foreach ($metadata as $md) {
                if ($md->owner_guid == $old_owner_guid) {
                    $md->owner_guid = $new_owner_guid;
                    $md->save();
                }
            }
        }
        // @todo Remove this when #4683 fixed
        $owner_has_changed = true;
        $old_icontime = $group->icontime;
    }
Example #4
0
                 
    }); // end of the main click function
        
}); //end of the document .ready function   
</script>

<div id="mb_input_wrapper"><!-- start of mb_input_wrapper div -->

    <h2><?php 
echo elgg_echo("messageboard:board");
?>
</h2>
  
<?php 
//if not a member don't display the add comment to messageboard
if (is_group_member($entity->guid, $_SESSION['guid'])) {
    ?>

    <!-- message textarea -->
    <textarea name="message_content" id="testing" value="" class="input_textarea" /></textarea>
   
    <!-- the person posting an item on the message board -->
    <input type="hidden" name="guid" value="<?php 
    echo $_SESSION['guid'];
    ?>
" class="guid"  />
   
    <!-- the page owner, this will be the profile owner -->
    <input type="hidden" name="pageOwner" value="<?php 
    echo page_owner();
    ?>
Example #5
0
 /**
  * Return whether a given user is a member of this group or not.
  *
  * @param ElggUser $user The user
  *
  * @return bool
  */
 public function isMember($user = null)
 {
     if (!$user instanceof ElggUser) {
         $user = elgg_get_logged_in_user_entity();
     }
     if (!$user instanceof ElggUser) {
         return false;
     }
     return is_group_member($this->getGUID(), $user->getGUID());
 }
Example #6
0
function create_groupuser_list($users, $group)
{
    $user_list = '';
    foreach ($users as $i => $value) {
        if (is_group_member($users[$i]['account_id'], $group)) {
            $user_list .= '<option value="' . $users[$i]['account_id'] . '" selected>' . $users[$i]['account_uname'] . ' (' . $users[$i]['account_lid'] . ')</option>';
        } else {
            $user_list .= '<option value="' . $users[$i]['account_id'] . '">' . $users[$i]['account_uname'] . ' (' . $users[$i]['account_lid'] . ')</option>';
        }
    }
    //echo $user_list;
    return $user_list;
}
Example #7
0
// Load configuration
global $CONFIG;
gatekeeper();
/* We cannot call action_gatekeeper until the groups code gets updated */
// action_gatekeeper();
$user_guid = get_input('user_guid');
if (!is_array($user_guid)) {
    $user_guid = array($user_guid);
}
$group_guid = get_input('group_guid');
if (sizeof($user_guid)) {
    foreach ($user_guid as $u_id) {
        $user = get_entity($u_id);
        $group = get_entity($group_guid);
        if ($user && $group) {
            if (get_loggedin_userid() == $group->owner_guid || $group->members_invite_enable != 'no' && is_group_member($group->getGUID(), get_loggedin_userid())) {
                if (!check_entity_relationship($group->guid, 'invited', $user->guid)) {
                    // Create relationship
                    add_entity_relationship($group->guid, 'invited', $user->guid);
                    // Send email
                    if (notify_user($user->getGUID(), $group->owner_guid, sprintf(elgg_echo('groups:invite:subject'), $user->name, $group->name), sprintf(elgg_echo('groups:invite:body'), $user->name, $group->name, "{$CONFIG->url}action/groups/join?user_guid={$user->guid}&group_guid={$group->guid}"), NULL)) {
                        system_message(elgg_echo("groups:userinvited"));
                    } else {
                        register_error(elgg_echo("groups:usernotinvited"));
                    }
                } else {
                    register_error(elgg_echo("groups:useralreadyinvited"));
                }
            } else {
                register_error(elgg_echo("groups:notowner"));
            }
Example #8
0
 /**
  * Return whether a given user is a member of this group or not.
  *
  * @param ElggUser $user The user
  * @return bool
  */
 public function isMember($user = 0)
 {
     if (!$user instanceof ElggUser) {
         $user = get_loggedin_user();
     }
     if (!$user instanceof ElggUser) {
         return false;
     }
     return is_group_member($this->getGUID(), $user->getGUID());
 }
Example #9
0
         }
         break;
 }
 $subgroup->save();
 //now we need to make sure that all members of the new subgroup are
 // members of the parent group
 // get all members of the subgroup - any members of subgroups have to be in this anyway
 global $AU_SUBGROUPS_ALL_MEMBERS;
 $AU_SUBGROUPS_ALL_MEMBERS = array();
 $options = array('relationship' => 'member', 'relationship_guid' => $subgroup->guid, 'inverse_relationship' => TRUE, 'type' => 'user', 'limit' => false);
 $batch = new ElggBatch('elgg_get_entities_from_relationship', $options, 'au_subgroups_get_all_members', 25);
 $AU_SUBGROUPS_ALL_MEMBERS = array_unique($AU_SUBGROUPS_ALL_MEMBERS);
 // array of user guids we need to invite back into the group
 $invite = array();
 foreach ($AU_SUBGROUPS_ALL_MEMBERS as $member_guid) {
     if (!is_group_member($parent_guid, $member_guid)) {
         join_group($parent_guid, $member_guid);
         $user = get_user($member_guid);
         if ($user) {
             // notify the user
             $url = elgg_normalize_url("groups/invitations/{$user->username}");
             notify_user($member_guid, $parent->owner_guid, elgg_echo('au_subgroups:moveto:subject', array($user->name, $subgroup->name, $parent->name, $parent->name)), elgg_echo('au_subgroups:moveto:body', array($user->name, $subgroup->name, $parent->name, $parent->name, $url)));
         }
         /*$invite[] = $member_guid;
         	// the user isn't a member of the parent group
         	// so we have to remove them from this subgroup, and all subgroups of this subgroup
         	// and send them an invitation
         	// we'll set a plugin setting on the user, which we'll monitor for when they accept the invitation
         	$groups_left = array($subgroup_guid);
         	
         	foreach ($child_groups as $child_guid) {
Example #10
0
$row_style["1"] = "row_style1";
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "\t<tr>\n";
echo "\t\t<td width='100%' align='left' valign='top'>\n";
echo "\t\t\t<b>" . $text['header-group_members'] . $group_name . "</b>\n";
echo "\t\t</td>\n";
echo "\t\t<td align='right' nowrap='nowrap' valign='middle'>\n";
echo "\t\t\t<input type='button' class='btn' style='margin-right: 15px;' alt='" . $text['button-back'] . "' onclick=\"window.location='groups.php'\" value='" . $text['button-back'] . "'>";
echo "\t\t</td>";
if (permission_exists('group_member_add')) {
    echo "\t\t<td align='right' nowrap='nowrap' valign='top'>\n";
    echo "\t\t\t<form method='post' action='groupmemberadd.php'>";
    echo "\t\t\t<select name='user_uuid' style='width: 200px;' class='formfld'>\n";
    echo "\t\t\t\t<option value=''></option>\n";
    foreach ($users as $field) {
        if (is_group_member($group_uuid, $field['user_uuid'])) {
            echo "\t\t<option value='" . $field['user_uuid'] . "'>" . $field['username'] . "</option>\n";
        }
    }
    unset($sql, $users);
    echo "\t\t\t</select>";
    echo "\t\t\t<input type='hidden' name='domain_uuid' value='" . ($domain_uuid != '' ? $domain_uuid : $_SESSION['domain_uuid']) . "'>";
    echo "\t\t\t<input type='hidden' name='group_uuid' value='" . $group_uuid . "'>";
    echo "\t\t\t<input type='hidden' name='group_name' value='" . $group_name . "'>";
    echo "\t\t\t<input type='submit' class='btn' value='" . $text['button-add_member'] . "'>";
    echo "\t\t\t</form>";
    echo "\t\t</td>\n";
}
echo "\t</tr>\n";
echo "</table>\n";
echo "<br>";
Example #11
0
$AU_SUBGROUPS_ALL_MEMBERS = array();
$options = array('relationship' => 'member', 'relationship_guid' => $subgroup->guid, 'inverse_relationship' => TRUE, 'type' => 'user', 'limit' => false);
$batch = new ElggBatch('elgg_get_entities_from_relationship', $options, 'au_subgroups_get_all_members', 25);
$AU_SUBGROUPS_ALL_MEMBERS = array_unique($AU_SUBGROUPS_ALL_MEMBERS);
// array of user guids we need to invite back into the group
$invite = array();
foreach ($AU_SUBGROUPS_ALL_MEMBERS as $member_guid) {
    if (!is_group_member($parent_guid, $member_guid)) {
        $invite[] = $member_guid;
        // the user isn't a member of the parent group
        // so we have to remove them from this subgroup, and all subgroups of this subgroup
        // and send them an invitation
        // we'll set a plugin setting on the user, which we'll monitor for when they accept the invitation
        $groups_left = array($subgroup_guid);
        foreach ($child_groups as $child_guid) {
            if (is_group_member($child_guid, $member_guid)) {
                $groups_left[] = $child_guid;
            }
        }
        leave_group($subgroup_guid, $member_guid);
        // now we need to set a plugin user setting for this user that we can monitor
        elgg_set_plugin_user_setting('invitation_' . $subgroup_guid, serialize($groups_left), $member_guid, 'au_subgroups');
        // invite the user
        add_entity_relationship($subgroup_guid, 'invited', $member_guid);
        $user = get_user($member_guid);
        if ($user) {
            // notify the user
            $url = elgg_normalize_url("groups/invitations/{$user->username}");
            notify_user($member_guid, $subgroup->owner_guid, elgg_echo('groups:invite:subject', array($user->name, $subgroup->name)), elgg_echo('au_subgroups:invite:body', array($user->name, $subgroup->name, $parent->name, $url)));
        }
    }
Example #12
0
function pleio_api_format_group(ElggGroup $group, $user_guid)
{
    $g = pleio_api_export($group, explode(",", "guid,owner_guid,site_guid,name,description"));
    $metadata = pleio_api_get_metadata($group->guid);
    if ($metadata["swordfish_group"]) {
        $g["swordfish"] = $metadata["swordfish_group"];
        $g["name"] .= " [SwordFish]";
    }
    $g["avatar"] = $metadata["icontime"] ? "1" : "0";
    $g["owner_name"] = get_entity($group->owner_guid)->name;
    $g["public"] = $group->membership == ACCESS_PUBLIC ? 1 : 0;
    $g["member"] = is_group_member($g["guid"], $user_guid) ? 1 : 0;
    $g["description"] = trim(strip_tags($g["description"]));
    $g["member_total"] = get_group_members($g["guid"], 0, 0, 0, true);
    $g["has_invitation"] = 0;
    $g["has_pending_membership_request"] = 0;
    if (!$g["member"]) {
        $g["has_invitation"] = check_entity_relationship($group->guid, 'invited', $user_guid) ? 1 : 0;
        $g["has_pending_membership_request"] = check_entity_relationship($user_guid, 'membership_request', $group->guid) ? 1 : 0;
    }
    return $g;
}