aboutsummaryrefslogtreecommitdiffstats
path: root/util/admins
diff options
context:
space:
mode:
authorManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-02-19 12:15:59 +0100
committerManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-02-19 12:15:59 +0100
commitc5bb0745737432c6d27e9468e56ad0bd33698462 (patch)
tree7d6b7a364941b9325ea319e6564e9f6123f059f2 /util/admins
parent4e8fc6d19851b6d05a49d5151aaa1f0f1fcfb5c0 (diff)
parentcead10b9af6ff9d8b1bc702ca21d27af7c2112f0 (diff)
downloadvolse-hubzilla-c5bb0745737432c6d27e9468e56ad0bd33698462.tar.gz
volse-hubzilla-c5bb0745737432c6d27e9468e56ad0bd33698462.tar.bz2
volse-hubzilla-c5bb0745737432c6d27e9468e56ad0bd33698462.zip
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat (limited to 'util/admins')
-rwxr-xr-xutil/admins60
1 files changed, 60 insertions, 0 deletions
diff --git a/util/admins b/util/admins
new file mode 100755
index 000000000..3c7f0e83e
--- /dev/null
+++ b/util/admins
@@ -0,0 +1,60 @@
+#!/usr/bin/env php
+<?php
+
+if(!file_exists('include/cli_startup.php')) {
+ echo 'Run admins from the top level Hubzilla web directory, as util/admins <args>' . PHP_EOL;
+ exit(1);
+}
+
+
+
+require_once('include/cli_startup.php');
+
+cli_startup();
+
+$helpArgs = getopt('h', array('help'));
+if (count($helpArgs) === 1) {
+ echo <<<'EndOfOutput'
+adds, removes, or lists admins
+
+Usage: util/admins
+ util/admins list
+ util/admins add <account_id>
+ util/admins remove <account_id>
+
+EndOfOutput;
+ return;
+}
+
+if($argc == 1) {
+ $r = q("select account_id, account_roles, account_email from account");
+ if($r) {
+ foreach($r as $rr) {
+ echo sprintf('%4u %s %s', $rr['account_id'], $rr['account_email'],(($rr['account_roles'] & 4096) ? '*' : '')) . PHP_EOL;
+ }
+ }
+}
+
+
+
+if($argc > 1 && $argv[1] === 'list') {
+ $r = q("select account_id, account_roles, account_email from account where (account_roles & 4096) > 0");
+ if($r) {
+ foreach($r as $rr) {
+ echo sprintf('%4u %s %s', $rr['account_id'], $rr['account_email'],(($rr['account_roles'] & 4096) ? '*' : '')) . PHP_EOL;
+ }
+ }
+}
+
+
+if($argc > 2 && $argv[1] === 'add' && intval($argv[2])) {
+ $r = q("update account set account_roles = (account_roles | 4096) where account_id = %d",
+ intval($argv[2])
+ );
+}
+
+if($argc > 2 && $argv[1] === 'remove' && intval($argv[2])) {
+ $r = q("update account set account_roles = (account_roles - 4096) where account_id = %d and (account_roles & 4096) > 0",
+ intval($argv[2])
+ );
+}