Groups.php
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace ACA\BP\Column\User;
use AC;
use AC\Collection;
use ACA\BP\Filtering;
use ACA\BP\Search;
use ACA\BP\Settings;
use ACP;
use ACP\ConditionalFormat\FormattableConfig;
class Groups extends AC\Column
implements ACP\Filtering\Filterable, ACP\Export\Exportable, AC\Column\AjaxValue, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
public function __construct() {
$this->set_type( 'column-buddypress_user_groups' )
->set_label( __( 'Groups', 'buddypress' ) )
->set_group( 'buddypress' );
}
public function get_value( $id ) {
$groups = $this->get_raw_value( $id );
if ( ! $groups ) {
return $this->get_empty_char();
}
return ac_helper()->html->get_ajax_toggle_box_link( $id, count( $groups ), $this->get_name() );
}
public function get_raw_value( $id ) {
$group_ids = groups_get_user_groups( $id );
return $group_ids['groups'];
}
public function get_ajax_value( $id ) {
$values = $this->get_formatted_value( new Collection( $this->get_raw_value( $id ) ) );
return implode( '<br>', $values->all() );
}
protected function register_settings() {
$this->add_setting( new Settings\Group( $this ) );
}
public function is_valid() {
return bp_is_active( 'groups' );
}
public function filtering() {
return new Filtering\User\Groups( $this );
}
public function export() {
return new ACP\Export\Model\StrippedValue( $this );
}
public function search() {
return new Search\User\Groups();
}
public function conditional_format(): ?FormattableConfig {
return new FormattableConfig(
new ACP\ConditionalFormat\Formatter\FilterHtmlFormatter(
new ACP\ConditionalFormat\Formatter\IntegerFormatter()
)
);
}
}