]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/commandinterpreter.php
* Allow setting single user site profile
[quix0rs-gnu-social.git] / lib / commandinterpreter.php
index 2e79fb27ee0a44061061f3399b7aef4de770300f..d1574c55fda95dca5bd4ef01abe62f9899351cbf 100644 (file)
@@ -35,13 +35,16 @@ class CommandInterpreter
         // There are a few compatibility commands from earlier versions of
         // StatusNet
 
+        $cmd = strtolower($cmd);
+
         if (Event::handle('StartIntepretCommand', array($cmd, $arg, $user, &$result))) {
-            switch(strtolower($cmd)) {
+            switch($cmd) {
             case 'help':
                 if ($arg) {
                     $result = null;
+                } else {
+                    $result = new HelpCommand($user);
                 }
-                $result = new HelpCommand($user);
                 break;
             case 'login':
                 if ($arg) {
@@ -118,49 +121,51 @@ class CommandInterpreter
             case 'join':
                 if (!$arg) {
                     $result = null;
-                }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new JoinCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new JoinCommand($user, $other);
+                    }
                 }
                 break;
             case 'drop':
                 if (!$arg) {
                     $result = null;
-                }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new DropCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new DropCommand($user, $other);
+                    }
                 }
                 break;
             case 'follow':
             case 'sub':
                 if (!$arg) {
                     $result = null;
-                }
-
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new SubCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new SubCommand($user, $other);
+                    }
                 }
                 break;
             case 'leave':
             case 'unsub':
                 if (!$arg) {
                     $result = null;
-                }
-
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new UnsubCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new UnsubCommand($user, $other);
+                    }
                 }
                 break;
             case 'get':
@@ -205,102 +210,137 @@ class CommandInterpreter
             case 'rd':
                 if (!$arg) {
                     $result = null;
-                }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new RepeatCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new RepeatCommand($user, $other);
+                    }
                 }
                 break;
             case 'whois':
                 if (!$arg) {
                     $result = null;
-                }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new WhoisCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new WhoisCommand($user, $other);
+                    }
                 }
                 break;
             case 'fav':
                 if (!$arg) {
                     $result = null;
-                }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new FavCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new FavCommand($user, $other);
+                    }
                 }
                 break;
             case 'nudge':
                 if (!$arg) {
                     $result = null;
-                }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
-                    $result = null;
                 } else {
-                    $result = new NudgeCommand($user, $other);
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new NudgeCommand($user, $other);
+                    }
                 }
                 break;
             case 'stats':
                 if ($arg) {
                     $result = null;
+                } else {
+                    $result = new StatsCommand($user);
                 }
-                $result = new StatsCommand($user);
                 break;
             case 'invite':
                 if (!$arg) {
                     $result = null;
+                } else {
+                    list($other, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else {
+                        $result = new InviteCommand($user, $other);
+                    }
+                }
+                break;
+             case 'list':
+             case 'tag':
+                if (!$arg) {
+                    $result = null;
+                    break;
                 }
-                list($other, $extra) = $this->split_arg($arg);
-                if ($extra) {
+                list($other, $tags) = $this->split_arg($arg);
+                if (!$tags) {
                     $result = null;
                 } else {
-                    $result = new InviteCommand($user, $other);
+                    $result = new TagCommand($user, $other, $tags);
                 }
                 break;
-            case 'track':
+             case 'unlist':
+             case 'untag':
                 if (!$arg) {
                     $result = null;
+                    break;
                 }
-                list($word, $extra) = $this->split_arg($arg);
-                if ($extra) {
+                list($other, $tags) = $this->split_arg($arg);
+                if (!$tags) {
                     $result = null;
-                } else if ($word == 'off') {
-                    $result = new TrackOffCommand($user);
                 } else {
-                    $result = new TrackCommand($user, $word);
+                    $result = new UntagCommand($user, $other, $tags);
                 }
                 break;
-            case 'untrack':
+            case 'track':
                 if (!$arg) {
                     $result = null;
+                } else {
+                    list($word, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else if ($word == 'off') {
+                        $result = new TrackOffCommand($user);
+                    } else {
+                        $result = new TrackCommand($user, $word);
+                    }
                 }
-                list($word, $extra) = $this->split_arg($arg);
-                if ($extra) {
+                break;
+            case 'untrack':
+                if (!$arg) {
                     $result = null;
-                } else if ($word == 'all') {
-                    $result = new TrackOffCommand($user);
                 } else {
-                    $result = new UntrackCommand($user, $word);
+                    list($word, $extra) = $this->split_arg($arg);
+                    if ($extra) {
+                        $result = null;
+                    } else if ($word == 'all') {
+                        $result = new TrackOffCommand($user);
+                    } else {
+                        $result = new UntrackCommand($user, $word);
+                    }
                 }
                 break;
             case 'tracks':
             case 'tracking':
                 if ($arg) {
                     $result = null;
+                } else {
+                    $result = new TrackingCommand($user);
                 }
-                $result = new TrackingCommand($user);
                 break;
             default:
                 $result = false;
             }
-                
-            Event::handle('EndInterpretCommand', array($cmd, $arg, $user, $result));
+
+            Event::handle('EndInterpretCommand', array($cmd, $arg, $user, &$result));
         }
 
         return $result;