summaryrefslogtreecommitdiff
path: root/classes/Group_member.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-01-13 19:17:49 +0000
committerZach Copley <zach@status.net>2010-01-13 19:17:49 +0000
commitc3188fd1fece2be7f7c4211d28f4a3d3a59c8fa1 (patch)
treeaa8018e132936b00fc63224e75ca134d68999b4e /classes/Group_member.php
parent43170b3d18153b3dfd8675bd77ae1133eed8148a (diff)
parent0e1f2d4b47e5e340679c4245b62e1d64c6b9c9b9 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'classes/Group_member.php')
-rw-r--r--classes/Group_member.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/classes/Group_member.php b/classes/Group_member.php
index 069b2c7a1..7b1760f76 100644
--- a/classes/Group_member.php
+++ b/classes/Group_member.php
@@ -25,4 +25,41 @@ class Group_member extends Memcached_DataObject
{
return Memcached_DataObject::pkeyGet('Group_member', $kv);
}
+
+ static function join($group_id, $profile_id)
+ {
+ $member = new Group_member();
+
+ $member->group_id = $group_id;
+ $member->profile_id = $profile_id;
+ $member->created = common_sql_now();
+
+ $result = $member->insert();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ throw new Exception(_("Group join failed."));
+ }
+
+ return true;
+ }
+
+ static function leave($group_id, $profile_id)
+ {
+ $member = Group_member::pkeyGet(array('group_id' => $group_id,
+ 'profile_id' => $profile_id));
+
+ if (empty($member)) {
+ throw new Exception(_("Not part of group."));
+ }
+
+ $result = $member->delete();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ throw new Exception(_("Group leave failed."));
+ }
+
+ return true;
+ }
}