function removeTag() { global $user; if ($user === false) { return json_encode(array('success' => false, 'message' => 'Sorry, you must be logged in to remove tags.')); } require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php'; $id = $_REQUEST['id']; $tag = $_REQUEST['tag']; $userTag = new UserTag(); $userTag->tag = $tag; $userTag->userId = $user->id; $userTag->groupedRecordPermanentId = $id; if ($userTag->find(true)) { //This is a new tag $userTag->delete(); return json_encode(array('success' => true, 'message' => 'Removed your tag from the title. Refresh to view updated tag list.')); } else { //This tag has already been added return json_encode(array('success' => true, 'message' => 'We could not find that tag for this record.')); } }
function removeTag() { global $user; $tagToRemove = $_REQUEST['tag']; require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php'; $userTag = new UserTag(); $userTag->tag = $tagToRemove; $userTag->userId = $user->id; $numDeleted = $userTag->delete(); $result = array('result' => true, 'message' => "Removed tag '{$tagToRemove}' from {$numDeleted} titles."); return $result; }