mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Use a link mode for space button "Join" from space header (#5150)
This commit is contained in:
parent
09b1dd060f
commit
59dfc9c2a0
@ -4,6 +4,7 @@
|
||||
- Fix #5128: Prerequisites: Increase PHP Min version to 7.3
|
||||
- Fix #5136: Fix get value of user profile fields with types "Checkbox List" and "Checkbox"
|
||||
- Fix #5137: Fix convert to short integer on PHP 8
|
||||
- Fix #5149: Use a link mode for space button "Join" from space header
|
||||
|
||||
|
||||
1.9.0-beta.1 (June 15, 2021)
|
||||
|
@ -47,6 +47,8 @@ class MembershipButton extends Widget
|
||||
],
|
||||
'becomeMember' => [
|
||||
'title' => Yii::t('SpaceModule.base', 'Join'),
|
||||
'mode' => 'ajax', // 'ajax' - to use data-action-* options for AJAX request, 'link' - to use button as simple <a> link
|
||||
'url' => '#',
|
||||
'attrs' => [
|
||||
'data-action-click' => 'content.container.relationship',
|
||||
'data-action-url' => $this->space->createUrl('/space/membership/request-membership'),
|
||||
@ -128,10 +130,20 @@ class MembershipButton extends Widget
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
|
||||
if ($options['becomeMember']['mode'] == 'link') {
|
||||
// Switch button "Join" to link mode
|
||||
$options['becomeMember']['url'] = $options['becomeMember']['attrs']['data-action-url'];
|
||||
$options['becomeMember']['attrs']['data-method'] = 'POST';
|
||||
unset($options['becomeMember']['attrs']['data-action-click']);
|
||||
unset($options['becomeMember']['attrs']['data-action-url']);
|
||||
}
|
||||
|
||||
return $this->render('membershipButton', [
|
||||
'space' => $this->space,
|
||||
'membership' => $this->space->getMembership(),
|
||||
'options' => $this->getOptions(),
|
||||
'options' => $options,
|
||||
'canCancelMembership' => !$this->space->isSpaceOwner() && $this->space->canLeave(),
|
||||
]);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ if ($membership === null) {
|
||||
if ($space->join_policy == Space::JOIN_POLICY_APPLICATION) {
|
||||
echo Html::a($options['requestMembership']['title'], $options['requestMembership']['url'], $options['requestMembership']['attrs']);
|
||||
} else {
|
||||
echo Html::a($options['becomeMember']['title'], '#', $options['becomeMember']['attrs']);
|
||||
echo Html::a($options['becomeMember']['title'], $options['becomeMember']['url'], $options['becomeMember']['attrs']);
|
||||
}
|
||||
}
|
||||
} elseif ($membership->status == Membership::STATUS_INVITED) {
|
||||
|
@ -21,7 +21,10 @@ use humhub\modules\space\widgets\MembershipButton;
|
||||
<div class="controls controls-header pull-right">
|
||||
<?= HeaderControls::widget(['widgets' => [
|
||||
[InviteButton::class, ['space' => $container], ['sortOrder' => 10]],
|
||||
[MembershipButton::class, ['space' => $container], ['sortOrder' => 20]],
|
||||
[MembershipButton::class, [
|
||||
'space' => $container,
|
||||
'options' => ['becomeMember' => ['mode' => 'link']],
|
||||
], ['sortOrder' => 20]],
|
||||
[FollowButton::class, [
|
||||
'space' => $container,
|
||||
'followOptions' => ['class' => 'btn btn-primary'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user