Automatically log in into Phorum from GO

Discuss about Group-Office development here

Moderator: Developers

hansvd
Posts: 24
Joined: Fri Oct 03, 2008 10:17 am

Automatically log in into Phorum from GO

Postby hansvd » Fri Jan 02, 2009 5:28 pm

Phorum has --IMHO-- a nice way of accepting sessions that are authenticated in another application. My aim is to allow users to go to Phorum once they are logged in in GO.

The only thing I need to do, is write some code that fetches user_id of user that is currently logged in. I thought I could make it simple by doing:

Code: Select all

require_once("Group-Office.php");

global $GO_USERS,$GO_SECURITY;
if (isset($GO_SECURITY->user_id) && $GO_SECURITY->user_id > 0)
{
	$gebruiker=$GO_USERS->get_user($GO_SECURITY->user_id);	
	print $gebruiker['username']; //for debug
}
While this is running nicely as a stand-alone script, it fails during the execution of Group-Office.php as soon as I include it in another script.

Fatal error: require() [function.require]: Failed opening required '' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\go\Group-Office.php on line 103

I assume I am doing something terribly stupid here, but I am too new to PHP to really understand how I am supposed to do this right. All paths are OK, both GO and Phorum are running perfectly. So don't suggest that there is something wrong with paths or privileges.

Thanks for any help.
Last edited by hansvd on Wed Jan 07, 2009 8:19 pm, edited 1 time in total.
hansvd
Posts: 24
Joined: Fri Oct 03, 2008 10:17 am

Re: Automatically log in into Phorum from GO

Postby hansvd » Fri Jan 02, 2009 7:49 pm

I got the thing working. I am now testing the interface and as soon as it proves to be working reliably, I will document the interface.
mschering
Site Admin
Site Admin
Posts: 8284
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Automatically log in into Phorum from GO

Postby mschering » Mon Jan 05, 2009 9:42 am

I'd like to see it. I might build a similar thing for PhpBB3 soon for a customer.
Best regards,

Merijn Schering
Intermesh
hansvd
Posts: 24
Joined: Fri Oct 03, 2008 10:17 am

Re: Automatically log in into Phorum from GO

Postby hansvd » Tue Jan 06, 2009 10:16 pm

The Phorum people have accepted my plugin. Your can read all about it at http://www.phorum.org/phorum5/read.php?62,134494. You can download the plugin from that forum page.

The concept is, in fact, fairly simple. In Phorum, you can use a certain hook "user_session_restore" which is called each time Phorum needs to authenticate a user. In that way, you can override the standard auth mechanism of Phorum with a custom made routine. In my case, I just had to pick up some information from the group-office $_SESSION and hand it over to Phorum. The neat thing is that users are created automatically it Phorum the first time they click through from GO.

To me, this concept felt a bit strange at the beginning. I had been thinking about writing event handlers in GO that pushed information to Phorum whenever necessary (upon creation of a user, upon login of a user, upon logout of a user, etc..). But looking at it the other way (ie. let the forum app pull information from GO) seems more elegant to me now.

In a next version of the plugin, I would consider to pass group membership from GO to Phorum. In that way, we could have separated forums per user group. For this to happen, I need to find a way to extract this information. Merijn, would you consider putting more information (like group membership for a logged in user) in the session, or would you prefer another way for an external application to pull information from GO?
mschering
Site Admin
Site Admin
Posts: 8284
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Automatically log in into Phorum from GO

Postby mschering » Wed Jan 07, 2009 9:35 am

Your module that connects Phorum could add the necessary info to the session. I don;t know how Phorum works but can it use Group-Office code so it can just use $GO_GROUPS->get_groups() etc.?
Best regards,

Merijn Schering
Intermesh
hansvd
Posts: 24
Joined: Fri Oct 03, 2008 10:17 am

Re: Automatically log in into Phorum from GO

Postby hansvd » Wed Jan 07, 2009 8:23 pm

For this to work, I need to get GO classes instantiated in a function. So far, I haven't managed to do this. Like I said in my post of Jan 2nd, require-ing Group-Office.php from a php script is working fine. As soon as I try to do exactly the same from within a function, I only get errors like reported above.

Again, this may be due to my lack of experience in PHP. I would really appreciate any help here.
mschering
Site Admin
Site Admin
Posts: 8284
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Automatically log in into Phorum from GO

Postby mschering » Thu Jan 08, 2009 8:57 am

The path to Group-Office.php is incorrect when this error occurs:

require_once("Group-Office.php");

for example you must use: require_once("../../groupoffice/Group-Office.php");
Best regards,

Merijn Schering
Intermesh
ZedBel
Posts: 8
Joined: Tue Aug 27, 2013 11:53 am

Re: Automatically log in into Phorum from GO

Postby ZedBel » Sun Nov 03, 2013 10:24 am

Hi. Your code doesnt work for me b/c the $GO_USERS object is not defined in the Group-Office.php class and after some inspection i have this one working

Code: Select all

<?php
require_once("/usr/share/groupoffice/Group-Office.php");
require_once("/usr/share/groupoffice/classes/base/users.class.inc.php");
global $GO_SECURITY,$GO_EVENTS;
$user = new GO_USERS();
if (isset($GO_SECURITY->user_id) && $GO_SECURITY->user_id > 0)
{
   $test=$user->get_user($GO_SECURITY->user_id);
   print $test['username'];
}
mschering
Site Admin
Site Admin
Posts: 8284
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Automatically log in into Phorum from GO

Postby mschering » Mon Nov 04, 2013 8:20 am

This is old code. Check the code I posted in your other topic.
Best regards,

Merijn Schering
Intermesh

Who is online

Users browsing this forum: No registered users and 2 guests

cron