2012-02-03 21:32:06 +01:00
|
|
|
<?php
|
|
|
|
class OC_Migrate_Provider_Bookmarks extends OC_Migrate_Provider{
|
2012-03-03 14:22:45 +01:00
|
|
|
|
2012-02-03 21:32:06 +01:00
|
|
|
// Create the xml for the user supplied
|
2012-03-10 16:52:38 +01:00
|
|
|
function export( $uid ){
|
2012-03-11 23:09:16 +01:00
|
|
|
OC_Log::write('migration','starting export for bookmarks',OC_Log::INFO);
|
2012-03-10 16:52:38 +01:00
|
|
|
$options = array(
|
|
|
|
'table'=>'bookmarks',
|
|
|
|
'matchcol'=>'user_id',
|
|
|
|
'matchval'=>$uid,
|
|
|
|
'idcol'=>'id'
|
|
|
|
);
|
|
|
|
$ids = OC_Migrate::copyRows( $options );
|
2012-03-11 23:09:16 +01:00
|
|
|
|
2012-03-10 16:52:38 +01:00
|
|
|
$options = array(
|
|
|
|
'table'=>'bookmarks_tags',
|
2012-03-10 19:18:58 +01:00
|
|
|
'matchcol'=>'bookmark_id',
|
2012-03-10 16:52:38 +01:00
|
|
|
'matchval'=>$ids
|
|
|
|
);
|
2012-03-03 14:22:45 +01:00
|
|
|
|
2012-03-10 16:52:38 +01:00
|
|
|
// Export tags
|
|
|
|
OC_Migrate::copyRows( $options );
|
2012-03-03 14:22:45 +01:00
|
|
|
|
2012-02-03 21:32:06 +01:00
|
|
|
}
|
2012-03-03 14:22:45 +01:00
|
|
|
|
2012-03-03 18:30:21 +01:00
|
|
|
// Import function for bookmarks
|
2012-03-10 16:52:38 +01:00
|
|
|
function import( $data, $uid ){
|
|
|
|
|
|
|
|
// new id mapping
|
|
|
|
$newids = array();
|
|
|
|
|
|
|
|
// Import bookmarks
|
|
|
|
foreach($data['bookmarks'] as $bookmark){
|
|
|
|
$bookmark['user_id'] = $uid;
|
|
|
|
// import to the db now
|
|
|
|
$newids[$bookmark['id']] = OC_DB::insertid();
|
|
|
|
}
|
2012-03-03 18:30:21 +01:00
|
|
|
|
2012-03-10 16:52:38 +01:00
|
|
|
// Import tags
|
|
|
|
foreach($data['bookmarks_tags'] as $tag){
|
|
|
|
// Map the new ids
|
|
|
|
$tag['id'] = $newids[$tag['id']];
|
|
|
|
// Import to the db now using OC_DB
|
2012-03-03 18:30:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 21:32:06 +01:00
|
|
|
}
|
2012-03-03 14:22:45 +01:00
|
|
|
|
2012-03-10 16:52:38 +01:00
|
|
|
new OC_Migrate_Provider_Bookmarks( 'bookmarks' );
|