summaryrefslogtreecommitdiffstats
path: root/apps/bookmarks/lib
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-03-03 13:22:45 +0000
committerTom Needham <needham.thomas@gmail.com>2012-03-03 13:22:45 +0000
commit6906988b4ec795d5d33367cd192b47d061f1c906 (patch)
tree188995b43ace97fbcce509d77fbb94fea0b12be1 /apps/bookmarks/lib
parent86fed4c226f2ca20e3924e1b9483aeea4073fc3b (diff)
downloadnextcloud-server-6906988b4ec795d5d33367cd192b47d061f1c906.tar.gz
nextcloud-server-6906988b4ec795d5d33367cd192b47d061f1c906.zip
Update bookmarks migration provider.
Diffstat (limited to 'apps/bookmarks/lib')
-rw-r--r--apps/bookmarks/lib/migrate.php68
1 files changed, 63 insertions, 5 deletions
diff --git a/apps/bookmarks/lib/migrate.php b/apps/bookmarks/lib/migrate.php
index af76a4ef4de..86a5b957257 100644
--- a/apps/bookmarks/lib/migrate.php
+++ b/apps/bookmarks/lib/migrate.php
@@ -1,14 +1,72 @@
<?php
class OC_Migrate_Provider_Bookmarks extends OC_Migrate_Provider{
+
// Create the xml for the user supplied
function export($uid){
- $xml = 'test';
+
+ $doc = new DOMDocument();
+ $doc->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