summaryrefslogtreecommitdiffstats
path: root/apps/bookmarks
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-03-13 21:24:07 +0000
committerTom Needham <needham.thomas@gmail.com>2012-03-13 21:24:07 +0000
commita919a136c418f99bded289034090b4e8d4e23533 (patch)
tree2fe2c13bc34b7345f25c24108dfce09246e9a2c1 /apps/bookmarks
parentcd2f75fdad6629f850bb07f07cd45e04d75de97d (diff)
downloadnextcloud-server-a919a136c418f99bded289034090b4e8d4e23533.tar.gz
nextcloud-server-a919a136c418f99bded289034090b4e8d4e23533.zip
Finish import function for bookmarks
Diffstat (limited to 'apps/bookmarks')
-rw-r--r--apps/bookmarks/lib/migrate.php42
1 files changed, 27 insertions, 15 deletions
diff --git a/apps/bookmarks/lib/migrate.php b/apps/bookmarks/lib/migrate.php
index 8387f706038..4f11bc5bdea 100644
--- a/apps/bookmarks/lib/migrate.php
+++ b/apps/bookmarks/lib/migrate.php
@@ -32,24 +32,36 @@ class OC_Migrate_Provider_Bookmarks extends OC_Migrate_Provider{
}
// Import function for bookmarks
- function import( $data, $uid ){
+ function import( $info ){
- // 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();
+ switch( $info['appversion'] ){
+ default:
+ // All versions of the app have had the same db structure, so all can use the same import function
+ $query = OC_Migrate::prepare( "SELECT * FROM bookmarks WHERE user_id LIKE ?" );
+ $results = $query->execute( array( $info['olduid'] ) );
+ $idmap = array();
+ while( $row = $data->fetchRow() ){
+ // Import each bookmark, saving its id into the map
+ $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
+ $query->execute( array( $row['url'], $row['title'], $info['newuid'], $row['public'], $row['added'], $row['lastmodified'] ) );
+ // Map the id
+ $idmap[$row['id']] = OC_DB::insertid();
+ }
+ // Now tags
+ foreach($idmap as $oldid => $newid){
+ $query = OC_Migrate::prepare( "SELECT * FROM bookmarks_tags WHERE user_id LIKE ?" );
+ $results = $query->execute( array( $oldid ) );
+ while( $row = $data->fetchRow() ){
+ // Import the tags for this bookmark, using the new bookmark id
+ $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
+ $query->execute( array( $newid, $row['tag'] ) );
+ }
+ }
+ // All done!
+ break;
}
- // 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
- }
+ return true;
}
}