RoundCube Webmail Forum  

Go Back   RoundCube Webmail Forum > Third Party Contributions > Old Style Plug-Ins

For more information about the ads and why they're here, please see the FAQ

Reply
  2 links from elsewhere to this Post. Click to view. #1  
Old 10-18-2006, 02:00 PM
Registered User
 
Join Date: Oct 2006
Posts: 4
Default Import Address Book from Squirrelmail Table

This is what I did to insert my email addresses from Squirrelmail into roundmail, providing yuor squirrelmail address are saved into a MySQL table


Just change your owner name from Michael to <your owner name> and your user_id to <your roundcube user_id>
Code:
INSERT INTO roundcube.contacts(
name,
firstname,
surname,
email,
user_id
)
SELECT nickname, firstname, lastname, email, '2'
FROM squirrelmail.address
WHERE owner = 'michael'
ORDER BY lastname ASC
Hope this helps someone.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 03-05-2009, 10:29 AM
lacri's Avatar
Registered User
 
Join Date: Jan 2009
Location: Leipzig, Germany
Posts: 160
Send a message via ICQ to lacri
Cool

Thanks for the solution, I have the solution modified for RoundCube 0.2 stable that the Squirrelmail Address Book with the first login users after to put on automatically adapted is imported.

Importantly the Squirrelmail and RoundCube tables must lie in the same data base on the same MySQL server.

serach in /program/include/rcube_user.php in the static function create

PHP Code:
if ($user_id $dbh->insert_id(get_sequence_name('users')))

and insert behind it

PHP Code:
//Import Users Squirrelmail Address Book on first login start
$dbh->query(
      
"INSERT INTO ".get_table_name('contacts')."
          (name, firstname, surname, email, user_id)
             SELECT nickname, firstname, lastname, email, '"
.$user_id."'
             FROM address
             WHERE owner = '"
.strip_newlines($user)."'
       ORDER BY lastname ASC"
);
//Import Users Squirrelmail Address Book on first login end 
so it should look then

PHP Code:
if ($user_id $dbh->insert_id(get_sequence_name('users')))
{
//Import Users Squirrelmail Address Book on first login start
    
$dbh->query(
      
"INSERT INTO ".get_table_name('contacts')."
          (name, firstname, surname, email, user_id)
             SELECT nickname, firstname, lastname, email, '"
.$user_id."'
             FROM address
             WHERE owner = '"
.strip_newlines($user)."'
       ORDER BY lastname ASC"
);
//Import Users Squirrelmail Address Book on first login end 
Additionally one can arrange also over the configurable over main.inc.php

inserts for this into /config/main.inc.php

PHP Code:
// Import SquirrelMail Address Book after Auto Create User
// The Squirrelmail and RoundCube Tables must on the same DB
$rcmail_config['import_squirrel_addresses'] = TRUE//or FALSE 
and modifie the /program/include/rcube_user.php in the static function create

so it should look then

PHP Code:
if ($user_id $dbh->insert_id(get_sequence_name('users')))
    {
      
//Import Users Squirrelmail Address Book on first login start
      
if($rcmail->config->get('import_squirrel_addresses')) {
      
$dbh->query(
        
"INSERT INTO ".get_table_name('contacts')."
            (name, firstname, surname, email, user_id)
               SELECT nickname, firstname, lastname, email, '"
.$user_id."'
               FROM address
               WHERE owner = '"
.strip_newlines($user)."'
         ORDER BY lastname ASC"
);
      }
      
//Import Users Squirrelmail Address Book on first login end 

Last edited by lacri; 03-05-2009 at 10:44 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 03-08-2009, 07:16 AM
Registered User
 
Join Date: Jul 2007
Posts: 13
Default

Quote:
Originally Posted by lacri View Post

Importantly the Squirrelmail and RoundCube tables must lie in the same data base on the same MySQL server.
It would be nice if it can import from different database. Are u planning on an update for this? If yes, i'm looking forward to testing it.

One more thing, does it run for the first time only or everytime a user logged?

Last edited by zamri; 03-08-2009 at 09:48 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 03-09-2009, 08:26 AM
lacri's Avatar
Registered User
 
Join Date: Jan 2009
Location: Leipzig, Germany
Posts: 160
Send a message via ICQ to lacri
Default

No with each login, only with the first login the Address Book is not imported, then additional modifications are overwritten and are not put on not doubly contacts. A small fast solution is like that without large checking of the input.

If the data base server is the same and the Squirrelmail tables should be appropriate in another railways it also to function the railways before the name to indicate… so long the RoundCube entrance also for vintage right in the Squirrelmail table has.

PHP Code:
if ($user_id $dbh->insert_id(get_sequence_name('users'))) 
    { 
      
//Import Users Squirrelmail Address Book on first login start 
      //Insert for squirrelmail the name of the squirrelmail DB
      
if($rcmail->config->get('import_squirrel_addresses')) { 
      
$dbh->query
        
"INSERT INTO ".get_table_name('contacts').
            (name, firstname, surname, email, user_id) 
               SELECT nickname, firstname, lastname, email, '"
.$user_id."' 
               FROM squirrelmail.address 
               WHERE owner = '"
.strip_newlines($user)."' 
         ORDER BY lastname ASC"
); 
      } 
      
//Import Users Squirrelmail Address Book on first login end 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 03-10-2009, 08:55 AM
Registered User
 
Join Date: Jul 2007
Posts: 13
Default

Thanks lacri. It's simple.

Can i put the code for inserting data into contacts before or after this line in rcube_user.php?

$mail_domain = $rcmail->config->mail_domain($host);

I got blank page after logged in for the first time. Refreshing the page didn't help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 03-10-2009, 01:17 PM
lacri's Avatar
Registered User
 
Join Date: Jan 2009
Location: Leipzig, Germany
Posts: 160
Send a message via ICQ to lacri
Default

the code must placed in the static function create (rcube_user.php)
before $mail_domain = $rcmail->config->mail_domain($host);

show in the RC log folder what says the error logfile or show on you server in the php_error logfile to resolve the Problem with the blank page.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.roundcubeforum.net/7-third-party-contributions/25-old-style-plug-ins/726-import-address-book-squirrelmail-table.html
Posted By For Type Date
Re: [RCD] squirrelmail addressbook to roundcube This thread Refback 09-14-2009 05:14 AM
pdadmin-forum | Anwendung | squirrel und roundcube Adressbuch-Abgleich This thread Refback 05-26-2009 10:38 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2006-2008 RoundCube Webmail Community