Short IMAP Login

Discuss about Group-Office development here

Moderator: Developers

blubyte
Posts: 11
Joined: Mon Mar 02, 2009 4:37 pm

Short IMAP Login

Postby blubyte » Tue Mar 23, 2010 5:15 pm

Hi,

i'm using Group-Office as webmail for multiple domains. eg http://www.test1.de, http://www.test2.de ...
Webmail can be accessed by go.domainname.de.

When a (IMAP)User logs in he has to use the username@domain.de. I changed the auth.class.inc.php, so that users just have to use username and password without @domainname.de
My script gets the domainname from the URL and adds it with an @ to the username.
Works fine.

Now i want to create a module because i don't want to change auth.class.inc.php after each update.
There's an event fired 'before_login' with username and password.
How can I manipulate the username an send it back to auth.class.inc.php.

Here's the structure of my module:

Code: Select all

class bb_auth {

        public function __on_load_listeners($events){
                $events->add_listener('before_login',__FILE__, 'bb_auth', 'before_login'); //fetch the event

        }

        public function before_login($p_user, $p_password) {
                // some code to manipulate username
                // how can i send the new username back to auth.class.inc.php ???

        }
}
Regards
C.G.
mschering
Site Admin
Site Admin
Posts: 8284
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Short IMAP Login

Postby mschering » Wed Mar 24, 2010 1:41 pm

Try modifying auth.class.inc.php line 243:

$args = array(&$username, &$password);


Then in your listener function:

Code: Select all

public function before_login(&$p_user, $p_password) {
                // some code to manipulate username
                // how can i send the new username back to auth.class.inc.php ???

$p_user='somethingelse';

        }
Best regards,

Merijn Schering
Intermesh
blubyte
Posts: 11
Joined: Mon Mar 02, 2009 4:37 pm

Re: Short IMAP Login

Postby blubyte » Thu Mar 25, 2010 8:57 am

ATM i modify auth.class.inc.php to get my short IMAP login done.
But I want to write the module and use the events because it's ugly to edit the core code. I'm looking for an options to send the vars I modified in my module back to the point in auth.class.inc.php where the event was fired.

Code: Select all

$params = array('username'=>$username, 'password'=>$password);
$GO_MODULES->fire_event('before_login', $params); # Here the event sends my module the vars $username and $password
Normaly in PHP OOP the vars would be passed by reference, so that I can edit the original vars in my module and not a copy of them.
Something like that:

Code: Select all

# before the event is $username="test"
$GO_MODULES->fire_event('before_login', &$username, &$password); # The event is fired and $username is passed by reference to my module
# my Module adds '@domain.de' to $username
# so after the event-call $username is 'test@domain.de' 
# so there would be no module code in auth.class.inc.php and after an update I only need to install the module
This way there wouldn't be the problem of sending the modified vars back to auth.class.inc.php because I edited the original $username and $password in my module.

Is there a way to improve the hook function to make this possible in the future? (Wordpress and Typo3 for example have really powerful hookfunctionality)
Regards
C.G.
mschering
Site Admin
Site Admin
Posts: 8284
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Short IMAP Login

Postby mschering » Thu Mar 25, 2010 4:23 pm

That's what i suggested. To modify auth.class.inc.php to pass them by reference. I've also modified this in the sources of GO.
Best regards,

Merijn Schering
Intermesh
blubyte
Posts: 11
Joined: Mon Mar 02, 2009 4:37 pm

Re: Short IMAP Login

Postby blubyte » Sat Apr 17, 2010 4:19 pm

I'm sorry, overread the "&".

I added the final module as an attachment.
Attachments
bb_auth.tar
Short IMAP Login Module
(20 KiB) Downloaded 260 times
Regards
C.G.

Who is online

Users browsing this forum: No registered users and 3 guests

cron