Restructure repository
[scuttle] / api / tags_rename.php
1 <?php
2 // Implements the del.icio.us API request to rename a user's tag.
3
4 // del.icio.us behavior:
5 // - oddly, returns an entirely different result (<result></result>) than the other API calls.
6
7 // Force HTTP authentication first!
8 require_once('httpauth.inc.php');
9 require_once('../header.inc.php');
10
11 $tagservice =& ServiceFactory::getServiceInstance('TagService');
12 $userservice =& ServiceFactory::getServiceInstance('UserService');
13
14 // Get the tag info.
15 if (isset($_REQUEST['old']) && (trim($_REQUEST['old']) != ''))
16     $old = trim($_REQUEST['old']);
17 else
18     $old = NULL;
19
20 if (isset($_REQUEST['new']) && (trim($_REQUEST['new']) != ''))
21     $new = trim($_REQUEST['new']);
22 else
23     $new = NULL;
24
25 if (is_null($old) || is_null($new)) {
26     $renamed = false;
27 } else {
28     // Rename the tag.
29     $result = $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new, true);
30     $renamed = $result;
31 }
32
33 // Set up the XML file and output the result.
34 header('Content-Type: text/xml');
35 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
36 echo '<result>'. ($renamed ? 'done' : 'something went wrong') .'</result>';
37 ?>

Benjamin Mako Hill || Want to submit a patch?