Skip to content

Commit

Permalink
'Allow any OpenLab member to join' should default to false for portfo…
Browse files Browse the repository at this point in the history
…li.s

See #3401.
  • Loading branch information
boonebgorges committed Jul 8, 2024
1 parent 4c8444a commit e634513
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions wp-content/themes/openlab/lib/group-funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,24 @@ function openlab_group_privacy_membership_save( $group ) {

switch ( $group->status ) {
case 'public' :
if ( empty( $_POST['allow-joining-public'] ) ) {
groups_update_groupmeta( $group->id, 'disable_public_group_joining', 1 );
$group_type = openlab_get_group_type( $group->id );

$allow_raw = ! empty( $_POST['allow-joining-public'] );

if ( openlab_is_portfolio( $group->id ) ) {
if ( $allow_raw ) {
groups_update_groupmeta( $group->id, 'enable_public_group_joining', 1 );
} else {
groups_delete_groupmeta( $group->id, 'enable_public_group_joining' );
}
} else {
groups_delete_groupmeta( $group->id, 'disable_public_group_joining' );
if ( $allow_raw ) {
groups_delete_groupmeta( $group->id, 'disable_public_group_joining' );
} else {
groups_update_groupmeta( $group->id, 'disable_public_group_joining', 1 );
}
}

break;

case 'private' :
Expand Down Expand Up @@ -342,7 +355,12 @@ function openlab_add_to_my_portfolio_settings( $group_type = null ) {
* @return bool
*/
function openlab_public_group_has_disabled_joining( $group_id ) {
$disabled = ! empty( groups_get_groupmeta( $group_id, 'disable_public_group_joining', true ) );
// Portfolios default to 'disabled', so we store an 'enable' flag.
if ( openlab_is_portfolio( $group_id ) ) {
$disabled = empty( groups_get_groupmeta( $group_id, 'enable_public_group_joining', true ) );
} else {
$disabled = ! empty( groups_get_groupmeta( $group_id, 'disable_public_group_joining', true ) );
}

if ( ! $disabled && ! openlab_group_is_active( $group_id ) ) {
$disabled = true;
Expand Down

0 comments on commit e634513

Please sign in to comment.