Topic-icon Is user logged into facebook

Support Specialist
8 years 6 months ago #55130 by alzander
Just tested. There's 2 issues I found:
* The class name *must* be plgSocialProfilesSonetwifiredir , since that's what you named the plugin
* In the constructor is the following line:
$this->_componentFolder = JPATH_SITE . '/components/com_kunena';
If you're not using Kunena, then JFBConnect will ignore this plugin. Update that to a folder that exists. It could be as simple as JPATH_SITE to make sure it always loads.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
8 years 6 months ago #55135 by fb_100000532508192
Still no joy. class names are correct. kunena is installed, but thought i'd change to what you suggested but still not working. Created a simpler plugin: would love to get users feedback if it works for them:
//xml
<?xml version="1.0" encoding="utf-8"?>
<extension version="1.0.0" type="plugin" group="socialprofiles" method="upgrade" client="site">
<name>Sonet Wifi Redir - jfbconnect</name>
<version>1.0.0</version>
<creationDate>06/10/2015</creationDate>
<author>Southamptonnetwork | www.southamptonnetwork.com
<authorEmail>This email address is being protected from spambots. You need JavaScript enabled to view it.
<authorUrl>www.southamptonnetwork.com
<copyright>Copyright (C) 2010-2015 southamptonnetwork. All rights reserved.</copyright>
<license>www.gnu.org/licenses/gpl-2.0.html GNU/GPL
<description>login detection for facebook and redirect to ap</description>
<files>
<filename plugin="sonetwifiredirtest">sonetwifiredirtest.php</filename>
</files>

<config>
<fields name="params">
<fieldset name="basic">
<field name="secretkey" type="text"
description="secret key needed to communicate with access point"
label="SOwifi Secret key"
size="40"
/>
</fieldset>
</fields>
</config>
</extension>
//end

//php code
/**
* @package JFBConnect
* @copyright (c) 2009-2014 by SourceCoast - All Rights Reserved
* @license www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @build-date 2014/07/14
*/

defined('_JEXEC') or die('Restricted access');

jimport('joomla.utilities.date');
jimport('sourcecoast.plugins.socialprofile');
jimport('sourcecoast.utilities');
//require_once JPATH_ROOT.DS.'components'.DS.'com_jfbconnect'.DS.'libraries'.DS.'facebook.php';


class plgSocialProfilesSonetWifiRedirTest extends SocialProfilePlugin
{
function __construct(&$subject, $params)
{
$this->_componentFolder = JPATH_SITE ;

parent::__construct($subject, $params);
//$this->defaultSettings->set('import_avatar', '1');
//$this->defaultSettings->set('import_always', '0');
}

/* After the user has logged in we then get the ball rolling
* 1st have the gets (ip/port/challenge) been sent if yes then.
* get secret key from param.
* get logged in users id
* then redir to ap with
*/
function onLogin() {
echo 'wtf';
JFactory::getApplication()->enqueueMessage(JText::_('sonet wifi test seems to be working'));
}
}
//end
sonetwifiredirtest.xml
sonetwifiredirtest.php

Thanks in advanced
The topic has been locked.
Support Specialist
8 years 6 months ago #55137 by alzander
I'm not sure what the difference is then. The enqueuemessage from your original code you sent displayed properly for me.

I'd recommend putting a similar enqueuemessage in the constructor to see if that displays on every page load. If not, the plugin isn't even being loaded for some reason and that's a coding or Joomla issue. If it does display, let us know and we can help investigate where the JFBConnect portion of the code may not be working.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
8 years 6 months ago #55169 by fb_100000532508192
Works in the constructor but nothing fires when in the onLogin.
The topic has been locked.
Support Specialist
8 years 6 months ago #55196 by alzander
I'm unsure what's different. Your code worked on my test site.

The parent class for our plugins can be found at /libraries/sourcecoast/plugins/socialprofile.php . In there, here's where I'd add additional testing code:
*In the constructor*
// Don't even fully construct this plugin if the component isn't found
        if ($this->componentLoaded())
            parent::__construct($subject, $params);
Add an enqueueMessage inside the check to make sure the componentLoaded function is returning true and the plugin is actually being loaded. That's based on the componentDirectory value you've set in your plugin

*socialProfilesOnLogin*
This is called when the user logs in. It immediately triggers onLogin, which you are overriding in your plugin

Also note that there is a socialProfilesOnRegister function. You have only mentioned logins, so I'm assuming that's all you wanted. You may want to play with the onRegister function (call from socialProfilesOnRegister) which is called on the first registration.

Let us know what code is, or isn't, being called and we'll gladly help diagnose things further from there.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
8 years 6 months ago #55206 by fb_100000532508192
finally narrowed down the problem.

Some mix up with importing profiles to the wrong user was to blame. When i deleted that user in jfbconnect component and logged back in again. the system message was displayed.

thank you for all your help!
The topic has been locked.
Active Subscriptions:

None
8 years 6 months ago #55207 by fb_100000532508192
last issue. Using:

$app->redirect(blabla.com);

takes me to a blank screen. how do you implement your redirect(what code do you use).

Many thanks
The topic has been locked.
Support Specialist
8 years 6 months ago #55217 by alzander
I'm glad to hear you got things going.

For redirects, what you mention is what I'd recommend:
$app = JFactory::getApplication();
$app->redirect(...);

If you're getting a blank page, enable error reporting in the Global Configuration area and let us know what the message is on that page.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
8 years 6 months ago #55224 by fb_100000532508192
Got it.

Almost there now. Lastly how do i pass variables to jfbconnect login?

so user a lands on page index.php?abc=1&123=2

if a user then clicks on facebook login

index.php is sent to fb redirect but not the extra variables.

How can i get jfbconnect to keep the variables and send them back to the referring page?

thanks
The topic has been locked.
Support Specialist
8 years 6 months ago #55237 by alzander
We don't have a way to pass those variables. All I can recommend is that you store any unique tracking or landing URL variables in the user session and then load those after the login occurs. Otherwise, you can use the redirection setting within JFBConnect of "Same Page" which stores the original URL that the user clicks on in the session and returns them to that page already.

I hope that helps explain,
Alex
The topic has been locked.