Switch things from calling Group_member::join & leave & calling events manually to running through Profile::joinGroup() && Profile::leaveGroup(), with the events encapsulated.

This commit is contained in:
Brion Vibber
2011-03-21 14:35:29 -07:00
parent 0bec9cfdbc
commit 541dfa04fe
17 changed files with 81 additions and 70 deletions

View File

@@ -68,6 +68,9 @@ class User extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
/**
* @return Profile
*/
function getProfile()
{
$profile = Profile::staticGet('id', $this->id);
@@ -596,6 +599,30 @@ class User extends Memcached_DataObject
return $profile->getGroups($offset, $limit);
}
/**
* Request to join the given group.
* May throw exceptions on failure.
*
* @param User_group $group
* @return Group_member
*/
function joinGroup(User_group $group)
{
$profile = $this->getProfile();
return $profile->joinGroup($group);
}
/**
* Leave a group that this user is a member of.
*
* @param User_group $group
*/
function leaveGroup(User_group $group)
{
$profile = $this->getProfile();
return $profile->leaveGroup($group);
}
function getSubscriptions($offset=0, $limit=null)
{
$profile = $this->getProfile();