function au_staff_options($pageowner)
{
    $user = elgg_get_logged_in_user_entity();
    $group = elgg_get_page_owner_entity();
    if (elgg_instanceof($group, 'group')) {
        //check group attributes - ignore if au staff
        if ($group->staff_only_enable == 'yes') {
            elgg_extend_view('group/default', 'groups/sidebar/staff_only', 502);
            //do stuff if this is a staff-only group
            //system_message("AU staff-only group: only AU staff members can join this group");
            if (elgg_is_logged_in()) {
                $invited = check_entity_relationship($group->getGUID(), "invited", $user->getGUID());
                //allow invited users in
                if (is_au_staff_member($user) || elgg_is_admin_logged_in() || $group->canEdit() || $invited) {
                    //do other stuff - welcome here
                } else {
                    //remove buttons for non staff members who are not members of the group and not invited
                    if (!$group->isMember($user)) {
                        elgg_register_plugin_hook_handler('register', 'menu:title', 'au_landing_remove_group_join_button', 9999);
                        //remove the link we added in groups_ux to allow joining from discussion forum
                        elgg_unextend_view('discussion/replies', 'discussion/replies/join');
                    }
                }
            }
        } else {
            //this is a normal group
        }
    } else {
        //not a group, do nothing
    }
}
Esempio n. 2
0
function au_landing_init()
{
    elgg_extend_view('css/elgg', 'css/au_landing');
    elgg_extend_view('page/elements/footer', 'au_landing/messages_count');
    elgg_extend_view('groups/edit', 'au_landing/gcl');
    // fix title link in event_calendar widget
    elgg_register_plugin_hook_handler('widget_url', 'widget_manager', 'au_landing_widget_manager_titles');
    // add group acls back as access options
    // also make some logical fixes for invisible groups
    elgg_register_plugin_hook_handler('access:collections:write', 'all', 'au_landing_group_acls', 1000);
    // prevent users from seeing online users
    elgg_register_plugin_hook_handler('members:config', 'tabs', 'au_landing_remove_online_tab', 1000);
    elgg_register_plugin_hook_handler('route', 'members', 'au_landing_remove_online_users', 1000);
    // change the page menu
    elgg_register_plugin_hook_handler('register', 'menu:page', 'au_landing_pagemenu', 1000);
    // add in missing group forum topics widget
    elgg_register_widget_type("index_groups", elgg_echo("widget_manager:widgets:index_groups:name"), elgg_echo("widget_manager:widgets:index_groups:description"), array("index"), true);
    // new notification handlers to append subscription modification info
    elgg_register_plugin_hook_handler('email', 'system', 'au_landing_email_append', 0);
    // modify some routing
    elgg_register_plugin_hook_handler('route', 'all', 'au_landing_router');
    //get rid of ugly embed code on side bars from gallielggembed
    elgg_unextend_view('page/elements/sidebar', 'galliElggEmbed/share');
    //handle staff-only options
    elgg_register_event_handler('pagesetup', 'system', 'au_staff_options');
    // only allow AU staff to make groups staff-only
    $user = elgg_get_logged_in_user_entity();
    if (is_au_staff_member($user)) {
        add_group_tool_option("staff_only", elgg_echo("AU staff-only group"), false);
    } else {
        elgg_register_plugin_hook_handler('action', 'groups/join', 'au_landing_prevent_group_join', 9999);
    }
    // move the mail members button to the top
    elgg_register_plugin_hook_handler('register', 'menu:title', 'au_landing_title_menu');
    // set group widgets to display by default (if group is closed)
    elgg_register_event_handler('create', 'group', 'au_landing_group_create');
    // send notification when someone other than the owner edits a page
    elgg_register_event_handler('update', 'object', 'au_landing_page_update');
    // make sure users have email addresses
    elgg_register_event_handler('login:after', 'user', 'au_landing_user_login');
}
Esempio n. 3
0
function au_landing_prevent_group_join($hook, $type, $return, $params)
{
    //bit of an irritating hack thanks to Elgg not sending this stuff in params
    $groupid = get_input('group_guid');
    $group = get_entity($groupid);
    $user = elgg_get_logged_in_user_entity();
    if (elgg_instanceof($group, 'group')) {
        $invited = check_entity_relationship($group->getGUID(), "invited", $user->getGUID());
        //allow invited users in
        if ($group->staff_only_enable == 'yes' && !is_au_staff_member($user) && !$group->canEdit() && !$invited) {
            register_error(elgg_echo("groups:cantjoin") . " - this is a staff-only group. Contact the Landing if you <em>are</em> a staff member!");
            return false;
        }
    }
    return true;
}