public function GroupSubscribeForm::isStateActive in Organic groups 8
Determine if the membership state should be active.
Return value
bool True if the state is active.
3 calls to GroupSubscribeForm::isStateActive()
- GroupSubscribeForm::buildForm in src/
Form/ GroupSubscribeForm.php - GroupSubscribeForm::getConfirmText in src/
Form/ GroupSubscribeForm.php - Get confirmation text, according to the membership state.
- GroupSubscribeForm::getQuestion in src/
Form/ GroupSubscribeForm.php - Get the question to present to the user according to the membership state.
File
- src/
Form/ GroupSubscribeForm.php, line 195
Class
- GroupSubscribeForm
- Provides a form for subscribing to a group.
Namespace
Drupal\og\FormCode
public function isStateActive() {
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $this
->getEntity();
/** @var EntityInterface $group */
$group = $membership
->getGroup();
$user = $membership
->getOwner();
$skip_approval = $this->ogAccess
->userAccess($group, 'subscribe without approval', $user)
->isAllowed();
$state = $skip_approval ? OgMembershipInterface::STATE_ACTIVE : OgMembershipInterface::STATE_PENDING;
if (!$group
->access('view', $user) && $state === OgMembershipInterface::STATE_ACTIVE) {
// Determine with which state a user can subscribe to a group they don't
// have access to.
// By default, for security reasons, if the group is private, then the
// state would be pending, regardless if the "subscribe without approval"
// is enabled.
$state = $this
->config('og.settings')
->get('deny_subscribe_without_approval') ? OgMembershipInterface::STATE_PENDING : OgMembershipInterface::STATE_ACTIVE;
}
return $state === OgMembershipInterface::STATE_ACTIVE;
}