summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-11-18 17:04:42 -0500
committerCraig Andrews <candrews@integralblue.com>2009-11-18 17:04:42 -0500
commitcac5a417f2a81b974781d4dbc40fd9d718a7a7f2 (patch)
treeac4798b1acd4abbe1674af08af99460374bda537 /classes
parenta00141a180d54cbcc244e0157c72f53ac53779b3 (diff)
parent199ccdb53fbd732eeced3edf734e39687729da9b (diff)
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'classes')
-rw-r--r--classes/User_group.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/classes/User_group.php b/classes/User_group.php
index b92638f7a..c86eadf8f 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -354,4 +354,66 @@ class User_group extends Memcached_DataObject
return $xs->getString();
}
+
+ static function register($fields) {
+
+ // MAGICALLY put fields into current scope
+
+ extract($fields);
+
+ $group = new User_group();
+
+ $group->query('BEGIN');
+
+ $group->nickname = $nickname;
+ $group->fullname = $fullname;
+ $group->homepage = $homepage;
+ $group->description = $description;
+ $group->location = $location;
+ $group->created = common_sql_now();
+
+ $result = $group->insert();
+
+ if (!$result) {
+ common_log_db_error($group, 'INSERT', __FILE__);
+ $this->serverError(
+ _('Could not create group.'),
+ 500,
+ $this->format
+ );
+ return;
+ }
+ $result = $group->setAliases($aliases);
+
+ if (!$result) {
+ $this->serverError(
+ _('Could not create aliases.'),
+ 500,
+ $this->format
+ );
+ return;
+ }
+
+ $member = new Group_member();
+
+ $member->group_id = $group->id;
+ $member->profile_id = $userid;
+ $member->is_admin = 1;
+ $member->created = $group->created;
+
+ $result = $member->insert();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ $this->serverError(
+ _('Could not set group membership.'),
+ 500,
+ $this->format
+ );
+ return;
+ }
+
+ $group->query('COMMIT');
+ return $group;
+ }
}