From 97b4576c115b86612a2ded6fbd800b6b5350d7a4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 2 Nov 2009 17:28:03 -0500 Subject: [PATCH 1/4] script to register a user --- scripts/registeruser.php | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 scripts/registeruser.php diff --git a/scripts/registeruser.php b/scripts/registeruser.php new file mode 100644 index 0000000000..9857f5aeea --- /dev/null +++ b/scripts/registeruser.php @@ -0,0 +1,81 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'n:w:f:e:'; +$longoptions = array('nickname=', 'password=', 'fullname=', 'email='); + +$helptext = << $nickname, + 'password' => $password, + 'fullname' => $fullname)); + + if (empty($user)) { + throw new Exception("Can't register user '$nickname' with password '$password' and fullname '$fullname'."); + } + + if (!empty($email)) { + + $orig = clone($user); + + $user->email = $email; + + if (!$user->updateKeys($orig)) { + print "Failed!\n"; + throw new Exception("Can't update email address."); + } + } + +} catch (Exception $e) { + print $e->getMessage() . "\n"; + exit(1); +} From 8e4bc78204e65589cebd5abab67db0f3b5fd8932 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 2 Nov 2009 18:06:09 -0500 Subject: [PATCH 2/4] correct name in registeruser --- scripts/registeruser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/registeruser.php b/scripts/registeruser.php index 9857f5aeea..5d9c8862da 100644 --- a/scripts/registeruser.php +++ b/scripts/registeruser.php @@ -24,8 +24,8 @@ $shortoptions = 'n:w:f:e:'; $longoptions = array('nickname=', 'password=', 'fullname=', 'email='); $helptext = << Date: Mon, 2 Nov 2009 18:06:27 -0500 Subject: [PATCH 3/4] script to make someone a group admin --- scripts/makegroupadmin.php | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 scripts/makegroupadmin.php 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); +} From f757ba3ca2f3c7cd647a6cd4421e98c1e310483e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 2 Nov 2009 18:10:01 -0500 Subject: [PATCH 4/4] notes about registeruser and makegroupadmin scripts --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index b4c37e3aba..a10628ac7f 100644 --- a/README +++ b/README @@ -150,6 +150,8 @@ released Aug 26 2009. Notable changes this version: - Use the NICKNAME_FMT constant for detecting nicknames. - Check for site servername config'd. - Compatibility fix for empty status updates with Twitter API. +- a script to register a new user. +- a script to make a user admin of a group. Prerequisites =============