Ejemplo n.º 1
0
function pleio_api_get_group($group_id = 0, $offset = 0)
{
    $user = elgg_get_logged_in_user_entity();
    $user_id = $user !== false ? $user->guid : 0;
    if ($user) {
        $group_id = intval($group_id);
        $options = array('site_guid' => ELGG_ENTITIES_ANY_VALUE, 'type' => 'group', 'relationship' => 'member', 'relationship_guid' => $user->guid, 'count' => false, "wheres" => array(" guid = {$group_id} "));
        $groups = elgg_get_entities_from_relationship($options);
        if (sizeof($groups)) {
            $group = pleio_api_format_group($groups[0], $user_id);
            $list = array();
            $offset = intval($offset);
            foreach (get_group_members($group_id, 20, $offset) as $member) {
                $list[] = pleio_api_format_user($member);
            }
            $group["offset"] = $offset;
            $group["members"] = $list;
            return $group;
        }
    }
    return new ErrorResult("Groep niet gevonden of geen lid");
}
Ejemplo n.º 2
0
function pleio_api_format_groups($groups, $total, $offset, $user_id)
{
    $list = array();
    $total = intval($total);
    $offset = intval($offset);
    foreach ($groups as $group) {
        $list[] = pleio_api_format_group($group, $user_id);
    }
    return array("total" => $total, "list" => $list, "offset" => $offset);
}