Fix bug #3468293: Delicious import does not preserve private links

This commit is contained in:
Christian Weiske 2012-01-20 21:27:04 +01:00
parent 22eaa812bf
commit a9df65da08
3 changed files with 25 additions and 6 deletions

View file

@ -17,6 +17,7 @@ ChangeLog for SemantiScuttle
- Fix bug #3384416: Use URL with protocol in bookmarklet - Fix bug #3384416: Use URL with protocol in bookmarklet
- Fix bug: Invalid HTML when website thumbnails are activated - Fix bug: Invalid HTML when website thumbnails are activated
- Fix bug #3413459: Thumbnails not in one line - 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 request #3403609: fr_CA translation update
- Implement patch #3476011: PostgreSQL tables can not be initialized - Implement patch #3476011: PostgreSQL tables can not be initialized
(Frédéric Fauberteau [triaxx]) (Frédéric Fauberteau [triaxx])

View file

@ -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>

View file

@ -27,7 +27,9 @@ require_once 'www-header.php';
/* Managing all possible inputs */ /* Managing all possible inputs */
// First input is $_FILES // First input is $_FILES
// Other inputs // 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) { 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); xml_parser_free($xml_parser);
//FIXME: show errors and warnings
header('Location: '. createURL('bookmarks', $userinfo->getUsername())); header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
} else { } else {
$templatename = 'importDelicious.tpl'; $templatename = 'importDelicious.tpl';
@ -70,7 +73,8 @@ function startElement($parser, $name, $attrs) {
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark'); $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
if ($name == 'POST') { if ($name == 'POST') {
while(list($attrTitle, $attrVal) = each($attrs)) { $newstatus = $status;
while (list($attrTitle, $attrVal) = each($attrs)) {
switch ($attrTitle) { switch ($attrTitle) {
case 'HREF': case 'HREF':
$bAddress = $attrVal; $bAddress = $attrVal;
@ -87,6 +91,11 @@ function startElement($parser, $name, $attrs) {
case 'TAG': case 'TAG':
$tags = strtolower($attrVal); $tags = strtolower($attrVal);
break; break;
case 'PRIVATE':
if ($attrVal == 'yes') {
$newstatus = 2;
}
break;
} }
} }
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) { if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
@ -100,12 +109,20 @@ function startElement($parser, $name, $attrs) {
$bDatetime = gmdate('Y-m-d H:i:s'); $bDatetime = gmdate('Y-m-d H:i:s');
} }
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $status, $tags, null, $bDatetime, true, true)) $res = $bookmarkservice->addBookmark(
$tplVars['msg'] = T_('Bookmark imported.'); $bAddress, $bTitle, $bDescription, '', $newstatus, $tags,
else null, $bDatetime, true, true
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.'); );
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]++; $depth[$parser]++;
} }