From 6906988b4ec795d5d33367cd192b47d061f1c906 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sat, 3 Mar 2012 13:22:45 +0000 Subject: [PATCH] Update bookmarks migration provider. --- apps/bookmarks/lib/migrate.php | 68 +++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/apps/bookmarks/lib/migrate.php b/apps/bookmarks/lib/migrate.php index af76a4ef4d..86a5b95725 100644 --- a/apps/bookmarks/lib/migrate.php +++ b/apps/bookmarks/lib/migrate.php @@ -1,14 +1,72 @@ formatOutput = true; + $bookmarks = $doc->createElement('bookmarks'); + $bookmarks = $doc->appendChild($bookmarks); + $query = OC_DB::prepare("SELECT * FROM *PREFIX*bookmarks WHERE *PREFIX*bookmarks.user_id = ?"); - $bookmarks =& $query->execute(array($uid)); - while ($row = $bookmarks->fetchRow()) { - $xml .= $row[0] . "\n"; + $bookmarksdata =& $query->execute(array($uid)); + + + // Foreach bookmark + while ($row = $bookmarksdata->fetchRow()) { + $bookmark = $doc->createElement('bookmark'); + $bookmark = $bookmarks->appendChild($bookmark); + + $attr = $doc->createElement('title'); + $attr = $bookmark->appendChild($attr); + $value = $doc->createTextNode($row['title']); + $attr->appendChild($value); + + $attr = $doc->createElement('url'); + $attr = $bookmark->appendChild($attr); + $value = $doc->createTextNode($row['url']); + $attr->appendChild($value); + + $attr = $doc->createElement('added'); + $attr = $bookmark->appendChild($attr); + $value = $doc->createTextNode($row['added']); + $attr->appendChild($value); + + $attr = $doc->createElement('lastmodified'); + $attr = $bookmark->appendChild($attr); + $value = $doc->createTextNode($row['lastmodified']); + $attr->appendChild($value); + + $attr = $doc->createElement('public'); + $attr = $bookmark->appendChild($attr); + $value = $doc->createTextNode($row['public']); + $attr->appendChild($value); + + $attr = $doc->createElement('clickcount'); + $attr = $bookmark->appendChild($attr); + $value = $doc->createTextNode($row['clickcount']); + $attr->appendChild($value); + + $attr = $doc->createElement('tags'); + $tags = $bookmark->appendChild($attr); + + $query = OC_DB::prepare("SELECT * FROM *PREFIX*bookmarks_tags WHERE *PREFIX*bookmarks_tags.bookmark_id = ?"); + $tagsdata =& $query->execute(array($row['id'])); + + // Foreach tag + while ($row = $tagsdata->fetchRow()) { + $attr = $doc->createElement('tag'); + $attr = $tags->appendChild($attr); + $value = $doc->createTextNode($row['tag']); + $attr->appendChild($value); + } } - return $xml; + + return $bookmarks; + } + } + new OC_Migrate_Provider_Bookmarks('bookmarks'); \ No newline at end of file