RoundCube Webmail Forum  

Go Back   RoundCube Webmail Forum > Release Support > Requests

For more information about the ads and why they're here, please see the FAQ
Reply
  #1  
Old 12-28-2006, 12:10 PM
Registered User
 
Join Date: Dec 2006
Posts: 1
Downloads: 0
Uploads: 0
Default Horde address book migration

Does anybody have script, that imports horde address book (stored in MySQL) to roundcube address book (MySQL too) ? Thnx in advance!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 12-28-2006, 01:36 PM
Registered User
 
Join Date: Oct 2006
Posts: 84
Downloads: 0
Uploads: 0
Default Re: Horde address book migration


a. You could download horde contents via phpmyadmin = table dump to txt file.

b. Then do the same for roundcube.

You then have a. the content and b. the format. Alter file a to match the format of file b and import into roundcube table via phpmyadmin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 10-08-2008, 09:26 PM
Registered User
 
Join Date: Jul 2008
Posts: 10
Downloads: 0
Uploads: 0
Talking RE: Horde Addressbook Migration

ugly script, but it does the job well. I named the file import.php, placed it in my install root, and added a link to it in my addressbook file (skins/default/templates/addressbook.html)

import.php
PHP Code:
<?php
/* ************************************ */
/* Roundcube DB connection data         */
/* ************************************ */
$host "****"//edit this
$user "****"//edit this
$password "****"//edit this
$db "****"//edit this
/* ************************************ */
/* END Roundcube DB connection data     */
/* ************************************ */
$domain "@domain.com"//change this, and make sure to leave the "@"




$link mysql_connect($host$user$password);
mysql_select_db($db$link);
session_start();
$session $_COOKIE['roundcube_sessid'];
$sql "SELECT `vars` FROM `session` WHERE `sess_id`='$session' LIMIT 1;";
$result mysql_query($sql);
$row mysql_fetch_assoc($result);
$data $row['vars'];
$data_array explode(";"$data);
foreach (
$data_array as $value){
    if (
strstr($value"username")){
        
$temp_array explode("\""$value);
        
$username2 $temp_array[1];
    }
    if (
strstr($value"user_id")){
        
$temp_array explode("\""$value);
        
$userid $temp_array[1]; 
    }
}

mysql_close($link);
/* ************************************ */
/* Horde DB connection data             */
/* ************************************ */
$username "****"//edit this
$password "****"//edit this
$host "****"//edit this
$db "****"//edit this
/* ************************************ */
/* END Horde DB connection data         */
/* ************************************ */




$link2 mysql_connect($host$username$password) or die("connection error");
mysql_select_db($db$link2);
$user $username2;
if (
strstr($user$domain)){
    
$user str_replace($domain""$user);
}
$sql "select object_name, object_alias, object_email from turba_objects where owner_id = '$user';";
$result mysql_query($sql);
$sql2 "INSERT INTO `contacts`(`contact_id`, `user_id`, `email`, `firstname`, `surname`) VALUES";
$count 0;
while (
$row mysql_fetch_assoc($result)){
    
$name $row['object_name'];
    if (
strstr($name" ")){
        
$temp_array explode(" "$name);
        if (
count($temp_array) == 2){
            
$name $temp_array[0];
            
$last_name $temp_array[1];
        }
        else{
            
$name $temp_array[0];
            
$last_name array_pop($temp_array);
        }
    }
    else{
        
$last_name "";
    }
    
$alias $row['object_alias'];
    
$email $row['object_email'];
    if (
$count == 0){
        
$sql2 .= "('', '$userid', '$email', '$name', '$last_name')";
        
$count++;
    }
    else{
        
$sql2 .= ", ('', '$userid', '$email', '$name', '$last_name')";
    }
}
$sql2 .= ";";
mysql_close($link2);



/* ************************************ */
/* Roundcube DB connection data         */
/* ************************************ */
$host "****"//edit this
$user "****"//edit this
$password "****"//edit this
$db "*****"//edit this
/* ************************************ */
/* END Roundcube DB connection data     */
/* ************************************ */




$link mysql_connect($host$user$password);
mysql_select_db("roundcube"$link);
$sql3 "SELECT * FROM `users` WHERE `imported`!=1 AND `user_id`='$userid' LIMIT 1;";
$result3 mysql_query($sql3);
if (
mysql_num_rows($result3) != 1){
    
header("location:./?_task=addressbook");
    exit();
}
mysql_query($sql2);
$sql "UPDATE `users` SET `imported`='1' WHERE `user_id`='$userid' LIMIT 1;";
mysql_query($sql);
header("location:./?_task=addressbook");
exit();
?>
oh, and run this SQL string on your users table:
Code:
ALTER TABLE `users` ADD `imported` TINYINT( 1 ) NOT NULL ;

Last edited by jonsjava; 10-08-2008 at 09:28 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

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

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

All times are GMT. The time now is 08:04 AM.


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