Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions controllers/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class TagsController extends ApiController {
public function tags() {
$this->allowMethods(['HEAD', 'GET', 'DELETE']);
$this->allowMethods(['HEAD', 'GET', 'DELETE', 'POST']);

if (!$this->permissions->canAccess($this->objectLibraryID)) {
$this->e403();
Expand Down Expand Up @@ -66,7 +66,7 @@ public function tags() {
}
// All tags
else {
$this->allowMethods(array('GET', 'DELETE'));
$this->allowMethods(array('GET', 'DELETE', 'POST'));

if ($this->scopeObject) {
$this->allowMethods(array('GET'));
Expand Down Expand Up @@ -197,6 +197,28 @@ public function tags() {
Zotero_DB::commit();
$this->e204();
}
else if ($this->method == 'POST') {
if (empty($this->queryParams['tag']) || empty($this->queryParams['tagName']) ) {
$this->e400("tag and tagName are required query parameters.");
}

$oldTagName = $this->queryParams['tag'];
$newTagName = $this->queryParams['tagName'];

$tagID = Zotero_Tags::getIDs($this->objectLibraryID, $oldTagName);
$tagCount = count($tagID);

// Make sure only one tag has been fetched
if ($tagCount != 1) {
$this->e400("Only one tag should be found to be renamed. Found: $tagCount");
}

$tag = Zotero_Tags::get($this->objectLibraryID, $tagID[0], true);
$tag->name = $newTagName;
$tag -> save();

$this->e204();
}
else {
$title = "Tags";
$results = Zotero_Tags::search($this->objectLibraryID, $this->queryParams);
Expand Down
1 change: 1 addition & 0 deletions model/API.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Zotero_API {
'collectionKey' => [],
'searchKey' => [],
'tag' => '',
'tagName' => '',
'tagType' => '',
'since' => false,
'sincetime' => false,
Expand Down