]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Fix bug #3468293: Delicious import does not preserve private links
authorChristian Weiske <cweiske@cweiske.de>
Fri, 20 Jan 2012 20:27:04 +0000 (21:27 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 20 Jan 2012 20:27:04 +0000 (21:27 +0100)
doc/ChangeLog
tests/data/BookmarkTest_deliciousbookmarks_private.xml [new file with mode: 0644]
www/import.php

index 629776469fa68dc8f26df8b0cc18edd5728177fd..8485802fef51a5c0b3b4c0d048dde2bc9caa1483 100644 (file)
@@ -17,6 +17,7 @@ ChangeLog for SemantiScuttle
 - Fix bug #3384416: Use URL with protocol in bookmarklet
 - Fix bug: Invalid HTML when website thumbnails are activated
 - Fix bug #3413459: Thumbnails not in one line
+- Fix bug #3468293: Delicious import does not preserve private links
 - Implement request #3403609: fr_CA translation update
 - Implement patch #3476011: PostgreSQL tables can not be initialized
   (Frédéric Fauberteau [triaxx])
diff --git a/tests/data/BookmarkTest_deliciousbookmarks_private.xml b/tests/data/BookmarkTest_deliciousbookmarks_private.xml
new file mode 100644 (file)
index 0000000..0ad8142
--- /dev/null
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><posts tag="" total="1" user="cweiske"><post description="Christians Tagebuch" extended="" hash="d82ca757a4583a24260a1126b5dafb0d" href="http://cweiske.de/tagebuch/" private="yes" shared="no" tag="private" time="2012-01-20T20:18:56Z"/></posts>
\ No newline at end of file
index 3aa2714623be6919c0eea71fc3f86bc2998ec449..1293a2fb51364c65ad8e2822dcbbf5838941a1e6 100644 (file)
@@ -27,7 +27,9 @@ require_once 'www-header.php';
 /* Managing all possible inputs */
 // First input is $_FILES
 // Other inputs
-isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
+isset($_POST['status'])
+    ? define('POST_STATUS', $_POST['status'])
+    : define('POST_STATUS', $GLOBALS['defaults']['privacy']);
 
 
 if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
@@ -54,6 +56,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
                }
        }
        xml_parser_free($xml_parser);
+       //FIXME: show errors and warnings
        header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
 } else {
        $templatename = 'importDelicious.tpl';
@@ -70,7 +73,8 @@ function startElement($parser, $name, $attrs) {
        $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
 
        if ($name == 'POST') {
-               while(list($attrTitle, $attrVal) = each($attrs)) {
+               $newstatus = $status;
+               while (list($attrTitle, $attrVal) = each($attrs)) {
                        switch ($attrTitle) {
                                case 'HREF':
                                        $bAddress = $attrVal;
@@ -87,6 +91,11 @@ function startElement($parser, $name, $attrs) {
                                case 'TAG':
                                        $tags = strtolower($attrVal);
                                        break;
+                               case 'PRIVATE':
+                                       if ($attrVal == 'yes') {
+                                               $newstatus = 2;
+                                       }
+                                       break;
                        }
                }
                if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
@@ -100,12 +109,20 @@ function startElement($parser, $name, $attrs) {
                                $bDatetime = gmdate('Y-m-d H:i:s');
                        }
 
-                       if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $status, $tags, null, $bDatetime, true, true))
-                       $tplVars['msg'] = T_('Bookmark imported.');
-                       else
-                       $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
+                       $res = $bookmarkservice->addBookmark(
+                               $bAddress, $bTitle, $bDescription, '', $newstatus, $tags,
+                               null, $bDatetime, true, true
+                       );
+                       if ($res) {
+                               $tplVars['msg'] = T_('Bookmark imported.');
+                       } else {
+                               $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
+                       }
                }
        }
+       if (!isset($depth[$parser])) {
+               $depth[$parser] = 0;
+       }
        $depth[$parser]++;
 }