Added functionality to keep privacy settings when bookmarks exported via API.
[scuttle] / api / posts_all.php
index 4f05d39e94e7f66069000d45a5fd60ca39395994..747741a695b94f0bf28f01a419a7976fa1f67335 100644 (file)
@@ -8,6 +8,9 @@
 require_once 'httpauth.inc.php';
 require_once '../header.inc.php';
 
+// set user as logged in so private bookmarks are exported
+$loggedon = true;
+
 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
 $userservice     =& ServiceFactory::getServiceInstance('UserService');
 
@@ -42,8 +45,14 @@ foreach($bookmarks['bookmarks'] as $row) {
     } else {
         $taglist = 'system:unfiled';
     }
+    // The privacy setting in scuttle is to set bStatus to 2 in the database.
+    if(trim($row['bStatus']) == '2') {
+        $shared = "no";
+    } else {
+        $shared = "yes";
+    }
 
-    echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. md5($row['bAddress']) .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
+    echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" shared="' . $shared . '" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. md5($row['bAddress']) . ($row['bStatus'] ? '" shared="no' : '') .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
 }
 
 echo '</posts>';

Benjamin Mako Hill || Want to submit a patch?