Response::done($Tag); case 'del': $AppearanceID = Appearances::validateAppearancePageID(); $tid = !empty($Tag['synonym_of']) ? $Tag['synonym_of'] : $Tag['tid']; $Uses = $CGDb->where('tid', $tid)->get('tagged', null, 'ponyid'); $UseCount = count($Uses); if (!isset($_POST['sanitycheck'])) { if ($UseCount > 0) { Response::fail('<p>This tag is currently used on ' . CoreUtils::makePlural('appearance', $UseCount, PREPEND_NUMBER) . '</p><p>Deleting will <strong class="color-red">permanently remove</strong> the tag from those appearances!</p><p>Are you <em class="color-red">REALLY</em> sure about this?</p>', array('confirm' => true)); } } if (!$CGDb->where('tid', $Tag['tid'])->delete('tags')) { Response::dbError(); } if (!empty(CGUtils::GROUP_TAG_IDS_ASSOC[$Tag['tid']])) { Appearances::getSortReorder($EQG); } foreach ($Uses as $use) { Appearances::updateIndex($use['ponyid']); } Response::success('Tag deleted successfully', isset($AppearanceID) && $Tag['type'] === 'ep' ? array('needupdate' => true, 'eps' => Appearances::getRelatedEpisodesHTML($AppearanceID, $EQG)) : null); break; case 'unsynon': if (empty($Tag['synonym_of'])) { Response::done(); } $keep_tagged = isset($_POST['keep_tagged']); $uses = 0; $Target = $CGDb->where('tid', $Tag['synonym_of'])->getOne('tags', 'tid'); if (!empty($Target)) { $TargetTagged = $CGDb->where('tid', $Target['tid'])->get('tagged', null, 'ponyid');