+ Reply to Thread
Results 1 to 6 of 6

Thread: Import Address Book from Squirrelmail Table

  1. #1
    daddyfix is offline Registered User
    Join Date
    Oct 2006
    Posts
    4
    Downloads
    0
    Uploads
    0

    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.


  2. #2
    lacri's Avatar
    lacri is offline Registered User
    Join Date
    Jan 2009
    Location
    Lutherstadt Wittenberg, Germany
    Posts
    179
    Downloads
    5
    Uploads
    0

    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 11:44 AM.

  3. #3
    zamri is offline Registered User
    Join Date
    Jul 2007
    Posts
    15
    Downloads
    0
    Uploads
    0

    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 10:48 AM.

  4. #4
    lacri's Avatar
    lacri is offline Registered User
    Join Date
    Jan 2009
    Location
    Lutherstadt Wittenberg, Germany
    Posts
    179
    Downloads
    5
    Uploads
    0

    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 

  5. #5
    zamri is offline Registered User
    Join Date
    Jul 2007
    Posts
    15
    Downloads
    0
    Uploads
    0

    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.

  6. #6
    lacri's Avatar
    lacri is offline Registered User
    Join Date
    Jan 2009
    Location
    Lutherstadt Wittenberg, Germany
    Posts
    179
    Downloads
    5
    Uploads
    0

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts