]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/command.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / scripts / command.php
index 6041b02eb150cc1a3018e8d9f52bf50c72055085..5ffa5bda0de9e0611cc402d0c69da82869782828 100755 (executable)
@@ -20,8 +20,8 @@
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
 
-$shortoptions = 'i:n:';
-$longoptions = array('id=', 'nickname=');
+$shortoptions = 'i:n:o';
+$longoptions = array('id=', 'nickname=', 'owner');
 
 $helptext = <<<END_OF_USERROLE_HELP
 command.php [options] [command line]
@@ -29,12 +29,11 @@ Perform commands on behalf of a user, such as sub, unsub, join, drop
 
   -i --id       ID of the user
   -n --nickname nickname of the user
+  -o --owner    use the site owner
 
 END_OF_USERROLE_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
-
-
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
 
 function interpretCommand($user, $body)
 {
@@ -50,22 +49,27 @@ function interpretCommand($user, $body)
     }
 }
 
-
-
 if (have_option('i', 'id')) {
     $id = get_option_value('i', 'id');
-    $user = User::staticGet('id', $id);
+    $user = User::getKV('id', $id);
     if (empty($user)) {
         print "Can't find user with ID $id\n";
         exit(1);
     }
 } else if (have_option('n', 'nickname')) {
     $nickname = get_option_value('n', 'nickname');
-    $user = User::staticGet('nickname', $nickname);
+    $user = User::getKV('nickname', $nickname);
     if (empty($user)) {
         print "Can't find user with nickname '$nickname'\n";
         exit(1);
     }
+} else if (have_option('o', 'owner')) {
+    try {
+        $user = User::siteOwner();
+    } catch (ServerException $e) {
+        print "Site has no owner.\n";
+        exit(1);
+    }
 } else {
     print "You must provide either an ID or a nickname.\n\n";
     print $helptext;