summaryrefslogtreecommitdiff
path: root/update.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-10-28 18:43:47 +0300
committerAndrew Dolgov <[email protected]>2023-10-28 18:45:09 +0300
commit855695a8620a3a5ffada836fd28e04bb912bbd3a (patch)
treec1e3a4ae29ec9ad7c6180499f28b9f93ed77fac0 /update.php
parent0ac8710ea1b1426bf19bb502ba4921ef35cd1db6 (diff)
add stuff necessary to run integration tests using phpunit
Diffstat (limited to 'update.php')
-rwxr-xr-xupdate.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/update.php b/update.php
index 4fd517701..4c10e3072 100755
--- a/update.php
+++ b/update.php
@@ -104,6 +104,7 @@
"user-check-password:" => ["USER:PASSWORD", "returns 0 if user has specified PASSWORD"],
"user-set-password:" => ["USER:PASSWORD", "sets PASSWORD of specified USER"],
"user-set-access-level:" => ["USER:LEVEL", "sets access LEVEL of specified USER"],
+ "user-enable-api:" => ["USER:BOOL", "enables or disables API access of specified USER"],
"user-exists:" => ["USER", "returns 0 if specified USER exists in the database"],
"force-yes" => "assume 'yes' to all queries",
"help" => "",
@@ -500,6 +501,35 @@
}
}
+ if (isset($options["user-enable-api"])) {
+ list ($login, $enable) = explode(":", $options["user-enable-api"], 2);
+
+ $uid = UserHelper::find_user_by_login($login);
+ $enable = Handler::_param_to_bool($enable);
+
+ if (!$uid) {
+ Debug::log("Error: User not found: $login");
+ exit(1);
+ }
+
+ $rc = -1;
+
+ if ($enable) {
+ Debug::log("Enabling API access for user $login...");
+ $rc = Prefs::set(Prefs::ENABLE_API_ACCESS, true, $uid, null);
+ } else {
+ Debug::log("Disabling API access for user $login...");
+ $rc = Prefs::set(Prefs::ENABLE_API_ACCESS, false, $uid, null);
+ }
+
+ if ($rc) {
+ Debug::log("Success.");
+ } else {
+ Debug::log("Operation failed, check the logs for more information.");
+ exit(1);
+ }
+ }
+
if (isset($options["user-remove"])) {
$login = $options["user-remove"];