diff options
author | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-03 14:00:33 +0000 |
---|---|---|
committer | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-03 14:00:33 +0000 |
commit | 29422fa55379aa61a61019b832c83dab6d450264 (patch) | |
tree | e5884ce6fed2cf1d02165a1b5667b99cd80262e5 /www/api/posts_add.php | |
parent | b8b1d06b2d899658fae64d0de506439ca0ea067c (diff) | |
download | semanticscuttle-29422fa55379aa61a61019b832c83dab6d450264.tar.gz semanticscuttle-29422fa55379aa61a61019b832c83dab6d450264.tar.bz2 |
move files to new locations
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@386 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'www/api/posts_add.php')
-rw-r--r-- | www/api/posts_add.php | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/www/api/posts_add.php b/www/api/posts_add.php new file mode 100644 index 0000000..ba3e02c --- /dev/null +++ b/www/api/posts_add.php @@ -0,0 +1,83 @@ +<?php +// Implements the del.icio.us API request to add a new post. + +// del.icio.us behavior: +// - tags can't have spaces +// - address and description are mandatory + +// Scuttle behavior: +// - Additional 'status' variable for privacy +// - No support for 'replace' variable + +// Force HTTP authentication +require_once('httpauth.inc.php'); +require_once('../header.inc.php'); + +/* Service creation: only useful services are created */ +$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService'); + +// Get all the bookmark's passed-in information +if (isset($_REQUEST['url']) && (trim($_REQUEST['url']) != '')) + $url = trim(urldecode($_REQUEST['url'])); +else + $url = NULL; + +if (isset($_REQUEST['description']) && (trim($_REQUEST['description']) != '')) + $description = trim($_REQUEST['description']); +else + $description = NULL; + +if (isset($_REQUEST['extended']) && (trim($_REQUEST['extended']) != "")) + $extended = trim($_REQUEST['extended']); +else + $extended = NULL; + +if (isset($_REQUEST['tags']) && (trim($_REQUEST['tags']) != '') && (trim($_REQUEST['tags']) != ',')) + $tags = trim($_REQUEST['tags']); +else + $tags = NULL; + +if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != '')) + $dt = trim($_REQUEST['dt']); +else + $dt = NULL; + +$status = 0; +if (isset($_REQUEST['status'])) { + $status_str = trim($_REQUEST['status']); + if (is_numeric($status_str)) { + $status = intval($status_str); + if($status < 0 || $status > 2) { + $status = 0; + } + } else { + switch ($status_str) { + case 'private': + $status = 2; + break; + case 'shared': + $status = 1; + break; + default: + $status = 0; + break; + } + } +} + +// Error out if there's no address or description +if (is_null($url) || is_null($description)) { + $added = false; +} else { +// We're good with info; now insert it! + if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId())) + $added = false; + else + $added = $bookmarkservice->addBookmark($url, $description, $extended, '', $status, $tags, $dt, true); +} + +// Set up the XML file and output the result. +header('Content-Type: text/xml'); +echo '<?xml version="1.0" standalone="yes" ?'.">\r\n"; +echo '<result code="'. ($added ? 'done' : 'something went wrong') .'" />'; +?>
\ No newline at end of file |