Skip to main content
Topic: Social Login (Read 9020 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Social Login

I intend to conver this mod to Elkarte since it seems easy enough.

Do advice if there is anything I need to watch for.

The sharing of this addon later will depend on its current license.
Last Edit: August 13, 2016, 04:50:10 am by ahrasis

Re: Social Login

Reply #1

Wrong link. :P
At sm.org, if you want to link the parsing you have to copy&paste the url linked in the text "Installation Instructions for x.x.xx". ;)
Anyway the link to the mod page is enough. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Social Login

Reply #2

Fixed it. Anyway it is at http://custom.simplemachines.org/mods/index.php?mod=3580

The license seems to be GPL2: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. I think the code may be modified and its modification may be re-distributed.

I am also going to do this step by step and post what file that has been modified in here, so that everybody can follow and correct any mistakes, if any.
Last Edit: August 13, 2016, 06:11:52 am by ahrasis


Re: Social Login

Reply #4

Ever considered Hybridauth?
I'm not sure how many people are willing to pay at least 8€/month to have social logins.
Bugs creator.
Features destroyer.
Template killer.

Re: Social Login

Reply #5

QuoteWe also have a Free Plan which includes the core features, basic support by email, all social networks and up to 2,500 unique users per year
They are free as above only. I am actually revising my skill in converting the code to Elkarte.

Any clue on how to start with that?

Re: Social Login

Reply #6

Ohhh... okay, I didn't notice it. lol

I could tell you to pick ideas from Ant59 addon, but I wouldn't influence the way you'll build it (mainly because his addon is not open source and so you should not take it verbatim).
Bugs creator.
Features destroyer.
Template killer.

Re: Social Login

Reply #7

May be I'll just finish with this social login first. I just need to check something up in converting modification.xml to hooks whenever possible. Original modification.xml file is attached together with unfinished package for reference.
Code: [Select]
[b][u]First modification[/u][/b]
<file name="$languagedir/Modifications.english.php">
<operation>
<search position="end" />
<add><![CDATA[
// OneAll Social Login (https://docs.oneall.com/plugins/)
$txt['oasl_title'] = 'OneAll Social Login';
$txt['oasl_config'] = 'Configuration';
$txt['oasl_settings_descr'] = 'OneAll Social Login Settings';
$txt['oasl_user_does_not_exist'] = "<strong>This social network has not yet been linked to an account.</strong><br /><br />Please use the registration form to create a new account. If you already have an account, open your profile settings to connect the social network to it.";
$txt['oasl_user_may_not_register'] = 'Sorry, but the admistration has disabled the registration for new users.';
$txt['oasl_user_require_activation'] = 'Your account has been created but it needs to be verified. Please check your mailbox and click on the link in the verification email.';

]]></add>
</operation>
</file>

The first modification is to add languages for the addon settings itself, so I will move the texts are move to the language file and load it via integrate_admin_areas. This will be done together with the fourth modification that will add menu in admin page.  
Code: [Select]
[b][u]Fourth modification[/u][/b]
<file name="$sourcedir/Admin.php">
<operation>
<search position="after"><![CDATA['layout' => array(
'title' => $txt['layout_controls'],]]></search>
<add><![CDATA[
// OneAll Social Login (https://docs.oneall.com/plugins/)
'oasl' => array(
'title' => $txt['oasl_title'],
'permission' => array('admin_forum'),
'areas' => array(
'oasl' => array(
'label' => $txt['oasl_config'],
'file' => 'Subs-OneallSocialLogin.php',
'function' => 'oneall_social_login_config',
'custom_url' => $scripturl . '?action=admin;area=oasl;sa=settings;sesc=' . $sc,
'icon' => 'server.gif'
)
)
),
]]></add>
</operation>
</file>

For the time being the menu will be put under members areas. The above two modifications will be in 1ASL.subs.php as follows:
Code: [Select]
function 1ASL_AdminMenu(&$menudata)
{
global $scripturl, $txt;

// Load language(s)
loadLanguage('1ASL/1ASL');

// Insert 1ASL inside layout menu instead of having its main admin menu.
$menudata['members']['areas'] = array_merge(
array(
'oasl' => array(
'label' => $txt['oasl_config'],
'file' => '1ASL.subs.php',
'function' => '1ASL_config',
'custom_url' => $scripturl . '?action=admin;area=oasl;sa=settings;sesc=' . $sc,
'icon' => 'server.gif' ,
'subsections' => array(
),
),
),
$menudata['members']['areas']
);
}

The second modification can be converted to hook but the third one seems not possible to the same so it will stay as it is.
Code: [Select]
[b][u]Second and third modification[/u][/b]
<file name="$boarddir/index.php">
<operation>
<search position="before"><![CDATA[
'editpoll2' => array('Poll.php', 'EditPoll2'),]]></search>
<add><![CDATA[
'oasl' => array('Subs-OneallSocialLogin.php', 'oneall_social_login_config'),
'oasl_registration' => array('Subs-OneallSocialLogin.php', 'oneall_social_login_registration'),
'oasl_callback' => array('Subs-OneallSocialLogin.php', 'oneall_social_login_callback'),]]></add>
</operation>
</file>

<file name="$boarddir/index.php">
<operation>
<search position="after"><![CDATA['coppa', 'login',]]></search>
<add><![CDATA['oasl_registration', 'oasl_callback', ]]></add>
</operation>
</file>

I think in 1ASL.subs.php, as a hook using integrate_actions, the second modification should look something like this:
Code: [Select]
function 1ASL_Action(&$actionArray, &$adminActions)
{
$actionArray = array(
'oasl' => array('BOARDDIR/addons/1ASL/1ASL.subs.php', '1ASL_login_config'),
'oasl_registration' => array('BOARDDIR/addons/1ASL/', '1ASL_login_registration'),
'oasl_callback' => array('BOARDDIR/addons/1ASL/', '1ASL_login_callback'),
);

return $actionArray;
}

I am not so sure about the fifth modification below:
Code: [Select]
[b][u]Fifth modification[/u][/b]
<file name="$sourcedir/Load.php">
<operation>
<search position="before"><![CDATA[// Some basic information...
if (!isset($context['html_headers']))
$context['html_headers'] = '';]]></search>
<add><![CDATA[

// OneAll Social Login (https://docs.oneall.com/plugins/)
if ( ! empty ($modSettings['oasl_api_subdomain']))
{
$context['html_headers'] .= "\n<!-- OneAll.com / Social Login for SMF //-->\n";
$context['html_headers'] .= '<script type="text/javascript" src="//' . htmlspecialchars ($modSettings['oasl_api_subdomain']) . '.api.oneall.com/socialize/library.js"></script>';
}]]></add>
</operation>
</file>

I am thinking to load this as early as intergrate_pre_load or during integrate_theme_load. May be the later is more appropriate.
Code: [Select]
function 1ASL_PreLoad(&$actionArray, &$adminActions)
{
global $context, $modSettings;

if (!empty($modSettings['oasl_api_subdomain']))
$context['html_headers'] .= '<script type="text/javascript" src="//' . htmlspecialchars ($modSettings['oasl_api_subdomain']) . '.api.oneall.com/socialize/library.js"></script>';

}

Just few more lines to be converted and then finish this up for a good test. Any supports, feedbacks and comments on the above and other converted files[1] are appreciated.
All files, I think, are duly converted except few more things in modification.xml discussed above and they are packaged and attached below.

Re: Social Login

Reply #8

Social log in is an awesome concept. Especially in these days.

Re: Social Login

Reply #9

Quote
Code: [Select]
function 1ASL_
http://php.net/manual/en/functions.user-defined.php
QuoteA valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
You cannot use 1 as first letter of a function name.
Bugs creator.
Features destroyer.
Template killer.

Re: Social Login

Reply #10

I think I converted everything as it installed fine now but its settings menu do not appear. Nothing in the error log. I attached the packaged file.


Re: Social Login

Reply #12

Where did you put the files?
Code: [Select]
add_integration_function('integrate_pre_include', 'SOURCEDIR/OASL.subs.php');
add_integration_function('integrate_pre_load', 'OASL_PreLoad');
add_integration_function('integrate_actions', 'OASL_Action');
add_integration_function('integrate_admin_areas', 'OASL_Admin_Menu');
in SOURCEDIR or in ADDONSDIR?
And are you coding it for 1.1 or 1.0?
Bugs creator.
Features destroyer.
Template killer.

Re: Social Login

Reply #13

Noted that. I think I have moved it to ADDONSDIR. Anyway, there are lots of bugs in this package. May be I'll redo it again later.

Re: Social Login

Reply #14

@ahrasis

Glad you took this on, but it isn't visible in the addon area.  Did you get this to work, or give up on in?  Sure would be a great thing to have!