From: Evan Prodromou Date: Mon, 2 Nov 2009 23:06:27 +0000 (-0500) Subject: script to make someone a group admin X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f0fc12b0a73ffb39abe7531affb8943f3615a478;p=quix0rs-gnu-social.git script to make someone a group admin --- diff --git a/scripts/makegroupadmin.php b/scripts/makegroupadmin.php new file mode 100644 index 0000000000..a68798451c --- /dev/null +++ b/scripts/makegroupadmin.php @@ -0,0 +1,89 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'g:n:'; +$longoptions = array('nickname=', 'group='); + +$helptext = << $group->id, + 'profile_id' => $user->id)); + + if (empty($member)) { + $member = new Group_member(); + + $member->group_id = $group->id; + $member->profile_id = $user->id; + $member->created = common_sql_now(); + + if (!$member->insert()) { + throw new Exception("Can't add '$nickname' to '$groupname'."); + } + } + + if ($member->is_admin) { + throw new Exception("'$nickname' is already an admin of '$groupname'."); + } + + $orig = clone($member); + + $member->is_admin = 1; + + if (!$member->update($orig)) { + throw new Exception("Can't make '$nickname' admin of '$groupname'."); + } + +} catch (Exception $e) { + print $e->getMessage() . "\n"; + exit(1); +}