X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fuserrole.php;h=a5eddeae5fc3dd5a1525ff6d12bdd2d1b4863b6e;hb=ee23dc8ccfea2fec1c8061b0e7de52cc2aa42864;hp=7b6a9b3fd8f97e4d2e4b9a365cf2864cebad8287;hpb=9d026600a9525ab78a6031b2acbfd388cbde48ff;p=quix0rs-gnu-social.git diff --git a/scripts/userrole.php b/scripts/userrole.php index 7b6a9b3fd8..a5eddeae5f 100644 --- a/scripts/userrole.php +++ b/scripts/userrole.php @@ -34,22 +34,27 @@ modifies a role for the given user END_OF_USERROLE_HELP; -require_once INSTALLDIR.'/scripts/commandline.inc'; +require_once INSTALLDIR.'/scripts/commandline.inc.php'; if (have_option('i', 'id')) { $id = get_option_value('i', 'id'); - $user = User::staticGet('id', $id); - if (empty($user)) { + $profile = Profile::getKV('id', $id); + if (empty($profile)) { 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); } + $profile = $user->getProfile(); + if (empty($profile)) { + print "User with ID $id has no profile\n"; + exit(1); + } } else { print "You must provide either an ID or a nickname.\n"; exit(1); @@ -63,9 +68,9 @@ if (empty($role)) { } if (have_option('d', 'delete')) { - print "Revoking role '$role' from user '$user->nickname' ($user->id)..."; + print "Revoking role '$role' from user '$profile->nickname' ($profile->id)..."; try { - $user->revokeRole($role); + $profile->revokeRole($role); print "OK\n"; } catch (Exception $e) { print "FAIL\n"; @@ -73,9 +78,9 @@ if (have_option('d', 'delete')) { print "\n"; } } else { - print "Granting role '$role' to user '$user->nickname' ($user->id)..."; + print "Granting role '$role' to user '$profile->nickname' ($profile->id)..."; try { - $user->grantRole($role); + $profile->grantRole($role); print "OK\n"; } catch (Exception $e) { print "FAIL\n";