Work in progress: subscription approval policy field in place on user, hooked up to settings. Queue not 100% tidied up, no UI for queue or management yet.

This commit is contained in:
Brion Vibber
2011-03-28 15:13:59 -07:00
parent 11b40ddb1b
commit df5def8ce4
10 changed files with 145 additions and 110 deletions

View File

@@ -56,6 +56,71 @@ class Group_join_queue extends Managed_DataObject
return $rq;
}
function getMember()
{
$member = Profile::staticGet('id', $this->profile_id);
if (empty($member)) {
// TRANS: Exception thrown providing an invalid profile ID.
// TRANS: %s is the invalid profile ID.
throw new Exception(sprintf(_("Profile ID %s is invalid."),$this->profile_id));
}
return $member;
}
function getGroup()
{
$group = User_group::staticGet('id', $this->group_id);
if (empty($group)) {
// TRANS: Exception thrown providing an invalid group ID.
// TRANS: %s is the invalid group ID.
throw new Exception(sprintf(_("Group ID %s is invalid."),$this->group_id));
}
return $group;
}
/**
* Abort the pending group join...
*
* @param User_group $group
*/
function abort()
{
$profile = $this->getMember();
$group = $this->getGroup();
if ($request) {
if (Event::handle('StartCancelJoinGroup', array($profile, $group))) {
$this->delete();
Event::handle('EndCancelJoinGroup', array($profile, $group));
}
}
}
/**
* Complete a pending group join...
*
* @return Group_member object on success
*/
function complete(User_group $group)
{
$join = null;
$profile = $this->getMember();
$group = $this->getGroup();
if (Event::handle('StartJoinGroup', array($profile, $group))) {
$join = Group_member::join($group->id, $profile->id);
$this->delete();
Event::handle('EndJoinGroup', array($profile, $group));
}
if (!$join) {
throw new Exception('Internal error: group join failed.');
}
$join->notify();
return $join;
}
/**
* Send notifications via email etc to group administrators about
* this exciting new pending moderation queue item!