Skip to content

Commit

Permalink
Site template visibility settings, ported from CBOX-OL.
Browse files Browse the repository at this point in the history
Some monkey patching is required, particularly in the front-end
query for site templates. This is because in CBOX-OL, the site
template selector appears during a step of group creation when the
group exists, while on the OpenLab, it's on the first (pre-group-
creation) step.

See #3247. See cuny-academic-commons/commons-in-a-box#472.
  • Loading branch information
boonebgorges committed Jul 8, 2024
1 parent e634513 commit 7999085
Show file tree
Hide file tree
Showing 14 changed files with 1,179 additions and 17 deletions.
2 changes: 2 additions & 0 deletions wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
define( 'BP_GROUP_DOCUMENTS_SLUG', 'files' );
define( 'BP_USE_WP_ADMIN_BAR', true );

define( 'CBOXOL_ASSET_VER', OL_VERSION );

define( 'NGG_JQUERY_CONFLICT_DETECTION', false );

// Don't let Neve show its onboarding panel.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

class CBOX_Academic_Unit_Type {
protected $slug;
protected $name;
protected $parent;
protected $group_types = [];

public function __construct( $args ) {
$string_keys = [ 'slug', 'name', 'parent' ];
foreach ( $string_keys as $key ) {
if ( isset( $args[ $key ] ) ) {
$this->$key = (string) $args[ $key ];
}
}

if ( isset( $args['group_types'] ) ) {
$this->group_types = (array) $args['group_types'];
}
}

public function get_slug() {
return $this->slug;
}

public function get_name() {
return $this->name;
}

public function get_parent() {
return $this->parent;
}

public function get_group_types() {
return $this->group_types;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

class CBOX_Academic_Unit {
protected $name;
protected $parent;
protected $slug;
protected $type;

public function __construct( $args ) {
$string_keys = [ 'name', 'parent', 'slug', 'type' ];
foreach ( $string_keys as $key ) {
if ( isset( $args[ $key ] ) ) {
$this->$key = (string) $args[ $key ];
}
}
}

public function get_name() {
return $this->name;
}

public function get_parent() {
return $this->parent;
}

public function get_slug() {
return $this->slug;
}

public function get_type() {
return $this->type;
}

public function get_wp_post_id() {
return $this->get_slug();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

class CBOX_Group_Type {
public $slug;
public $name;

public function get_slug() {
return $this->slug;
}

public function get_name() {
return $this->name;
}

public function get_label() {
switch ( $this->slug ) {
case 'course' :
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

class CBOX_Member_Type {
protected $slug;
protected $name;
protected $can_create_courses;

public function __construct( $args ) {
$string_keys = [ 'slug', 'name' ];
foreach ( $string_keys as $key ) {
if ( isset( $args[ $key ] ) ) {
$this->$key = (string) $args[ $key ];
}
}

$bool_keys = [ 'can_create_courses' ];
foreach ( $bool_keys as $key ) {
if ( isset( $args[ $key ] ) ) {
$this->$key = (bool) $args[ $key ];
}
}
}

public function get_slug() {
return $this->slug;
}

public function get_name() {
return $this->name;
}

public function get_label() {
return $this->name;
}

public function get_can_create_courses() {
return $this->can_create_courses;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function get_items( $request ) {
$q = $params['search'];
$page = $params['page'];

$per_page = 25;
$per_page = 10;

// Filter to match blogname.
add_filter( 'sites_clauses', [ $this, 'filter_sites_clauses' ], 10, 2 );
Expand All @@ -49,7 +49,7 @@ public function get_items( $request ) {
]
);

remove_filter( 'sites_clauses', [ $this, 'filter_sites_clauses' ], 10 );
remove_filter( 'sites_clauses', [ $this, 'filter_sites_clauses' ], 10, 2 );

Check failure on line 52 in wp-content/plugins/wds-citytech/includes/cbox-polyfills/class-cbox-sites-endpoint.php

View workflow job for this annotation

GitHub Actions / phpstan

Function remove_filter invoked with 4 parameters, 2-3 required.

$retval = [
'results' => [],
Expand Down
Loading

0 comments on commit 7999085

Please sign in to comment.