X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fsettag.php;h=19abce43c8018a5d1de97ca83e5740f730c2c294;hb=1c478768ad2558dd0f789d3941da2162fdb34a76;hp=e91d5eb505045e4ab3d8157b7957565ccf5e48e9;hpb=057ec1fceacbfec1f755a5bc6700a188aa70e33f;p=quix0rs-gnu-social.git diff --git a/scripts/settag.php b/scripts/settag.php index e91d5eb505..19abce43c8 100644 --- a/scripts/settag.php +++ b/scripts/settag.php @@ -33,49 +33,48 @@ END_OF_SETTAG_HELP; require_once INSTALLDIR.'/scripts/commandline.inc'; -if (count($args) != 2) { +if (count($args) < 1) { show_help(); exit(1); } $nickname = $args[0]; -$tag = strtolower($args[1]); - $sn = Status_network::memGet('nickname', $nickname); if (empty($sn)) { - print "No such site.\n"; + print "No such site ($nickname).\n"; exit(-1); } $tags = $sn->getTags(); +if (count($args) == 1) { + print(implode(', ', $tags) . "\n"); + exit(0); +} +$tag = $args[1]; $i = array_search($tag, $tags); if ($i !== false) { if (have_option('d', 'delete')) { // Delete unset($tags[$i]); - $orig = clone($sn); - $sn->tags = implode('|', $tags); - $result = $sn->update($orig); + $result = $sn->setTags($tags); if (!$result) { print "Couldn't update.\n"; exit(-1); } } else { print "Already set.\n"; - exit(-1); + exit(0); } } else { if (have_option('d', 'delete')) { // Delete print "No such tag.\n"; - exit(-1); + exit(0); } else { $tags[] = $tag; - $orig = clone($sn); - $sn->tags = implode('|', $tags); - $result = $sn->update($orig); + $result = $sn->setTags($tags); if (!$result) { print "Couldn't update.\n"; exit(-1);