]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/settag.php
Merge remote-tracking branch 'upstream/master'
[quix0rs-gnu-social.git] / scripts / settag.php
old mode 100644 (file)
new mode 100755 (executable)
index 1d7b60b..3c234f2
@@ -31,51 +31,50 @@ With -d, delete the tag.
 
 END_OF_SETTAG_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
 
-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();
 
-$i = array_search($tags, $tag);
+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);