arckinteractive / elgg_hybridauth

HybridAuth Client for Elgg
10 stars 9 forks source link

Feature request: Support group invitation registration #19

Open oseg opened 8 years ago

oseg commented 8 years ago

Group invitation registration is a feature of group_tools plugin that can be enabled in: Settings/Group tools/Group invitation options/Allow all users to be invited by e-mail address

I don't know if this plugin is still maintained: last release 1 year ago & last commit 8 months ago

For those who are interested in, I Implemented a working solution in the following context: elgg v1.12 group_tools v6.0.3 elgg_hybridauth master Jan 28, 2016 commit (not released v1.4.1)

by modifying 3 files:

In start.php:

function elgg_hybridauth_page_handler($segments, $identifier) {

    if (!isset($_SESSION['hybridauth'])) {
                $invitecode = get_input('invitecode');
                $group_invitecode = get_input('group_invitecode');
                if (!empty($invitecode) || !empty($group_invitecode)) {
                    $_SESSION['hybridauth'] = array(
                            'friend_guid' => get_input('friend_guid'),
                            'invitecode' => $invitecode,
                            'group_invitecode' => $group_invitecode
                    );                    
                }
    }

    switch ($segments[0]) {

In views/default/hybridauth/login.php

echo '<ul class="hybridauth-form-icons">';

$other_params = "";
$friend_guid = get_input('friend_guid');
if (!empty($friend_guid)) {
    $other_params .= "&friend_guid=$friend_guid";
}
$invitecode = get_input('invitecode');
if (!empty($invitecode)) {
    $other_params .= "&invitecode=$invitecode";
}
$group_invitecode = get_input('group_invitecode');
if (!empty($group_invitecode)) {
    $other_params .= "&group_invitecode=$group_invitecode";
}

foreach ($providers as $provider) {
    $name = $provider->getName();
    echo '<li>';
    echo elgg_view('output/url', array(
        'text' => elgg_view_icon(strtolower("auth-$name-large")),
        'href' => "hybridauth/authenticate?provider=$name$other_params",
        'title' => $name,
        'class' => 'hybridauth-start-authentication'
    ));
    echo '</li>';
}

echo '</ul>';

In views/default/resources/hybridauth/authenticate.php

} else {

    if (!elgg_get_config('allow_registration')) {
        register_error(elgg_echo('registerdisabled'));
        forward('', '403');
    }

    $title = elgg_echo('hybridauth:register');
    $content = elgg_view_form('hybridauth/register', array(), array(
        'provider' => $provider->getName(),
        'profile' => $profile,
        'invitecode' => $_SESSION['hybridauth']['invitecode'],
        'friend_guid' => $_SESSION['hybridauth']['friend_guid'],
                'group_invitecode' => $_SESSION['hybridauth']['group_invitecode']
    ));
}