| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Ext1: |
|---|
| 5 | * - enable_nav_item: public |
|---|
| 6 | * - access: inferred |
|---|
| 7 | * - show_tab: inferred |
|---|
| 8 | * |
|---|
| 9 | * To test: |
|---|
| 10 | * - Public group: tab and access should be visible to all |
|---|
| 11 | * - Private group: tab should be visible to all, access only to group members |
|---|
| 12 | */ |
|---|
| 13 | class BP4785_Ext1 extends BP_Group_Extension { |
|---|
| 14 | public function __construct() { |
|---|
| 15 | parent::init( array( |
|---|
| 16 | 'name' => 'Ext1', |
|---|
| 17 | 'slug' => 'ext1', |
|---|
| 18 | 'enable_nav_item' => true, |
|---|
| 19 | ) ); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | public function display() { |
|---|
| 23 | echo 'Yes'; |
|---|
| 24 | } |
|---|
| 25 | } |
|---|
| 26 | bp_register_group_extension( 'BP4785_Ext1' ); |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * Ext2: |
|---|
| 30 | * - access: anyone |
|---|
| 31 | * - show_tab: inferred |
|---|
| 32 | * |
|---|
| 33 | * To test: |
|---|
| 34 | * - Public group: tab and access should be visible to all |
|---|
| 35 | * - Private group: tab and access should be visible to all |
|---|
| 36 | */ |
|---|
| 37 | class BP4785_Ext2 extends BP_Group_Extension { |
|---|
| 38 | public function __construct() { |
|---|
| 39 | parent::init( array( |
|---|
| 40 | 'name' => 'Ext2', |
|---|
| 41 | 'slug' => 'ext2', |
|---|
| 42 | 'access' => 'anyone', |
|---|
| 43 | ) ); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | public function display() { |
|---|
| 47 | echo 'Yes'; |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | bp_register_group_extension( 'BP4785_Ext2' ); |
|---|
| 51 | |
|---|
| 52 | /** |
|---|
| 53 | * Ext3: |
|---|
| 54 | * - access: anyone |
|---|
| 55 | * - show_tab: inferred |
|---|
| 56 | * |
|---|
| 57 | * To test: |
|---|
| 58 | * - Public group: tab and access should be visible to all |
|---|
| 59 | * - Private group: tab and access should be visible to all |
|---|
| 60 | */ |
|---|
| 61 | class BP4785_Ext3 extends BP_Group_Extension { |
|---|
| 62 | public function __construct() { |
|---|
| 63 | parent::init( array( |
|---|
| 64 | 'name' => 'Ext3', |
|---|
| 65 | 'slug' => 'ext3', |
|---|
| 66 | 'access' => 'anyone', |
|---|
| 67 | ) ); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | public function display() { |
|---|
| 71 | echo 'Yes'; |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | bp_register_group_extension( 'BP4785_Ext3' ); |
|---|
| 75 | |
|---|
| 76 | /** |
|---|
| 77 | * Ext4: |
|---|
| 78 | * - access: member |
|---|
| 79 | * - show_tab: anyone |
|---|
| 80 | * |
|---|
| 81 | * To test: |
|---|
| 82 | * - All groups: tab should be visible to all, access only to members |
|---|
| 83 | */ |
|---|
| 84 | class BP4785_Ext4 extends BP_Group_Extension { |
|---|
| 85 | public function __construct() { |
|---|
| 86 | parent::init( array( |
|---|
| 87 | 'name' => 'Ext4', |
|---|
| 88 | 'slug' => 'ext4', |
|---|
| 89 | 'access' => 'member', |
|---|
| 90 | 'show_tab' => 'anyone', |
|---|
| 91 | ) ); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | public function display() { |
|---|
| 95 | echo 'Yes'; |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | bp_register_group_extension( 'BP4785_Ext4' ); |
|---|
| 99 | |
|---|
| 100 | /** |
|---|
| 101 | * Ext5: |
|---|
| 102 | * - access: default |
|---|
| 103 | * - show_tab: default |
|---|
| 104 | * |
|---|
| 105 | * To test: |
|---|
| 106 | * - Public groups: All users can visit |
|---|
| 107 | * - Private groups: Tab and visit only available to members |
|---|
| 108 | */ |
|---|
| 109 | class BP4785_Ext5 extends BP_Group_Extension { |
|---|
| 110 | public function __construct() { |
|---|
| 111 | parent::init( array( |
|---|
| 112 | 'name' => 'Ext5', |
|---|
| 113 | 'slug' => 'ext5', |
|---|
| 114 | ) ); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | public function display() { |
|---|
| 118 | echo 'Yes'; |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | bp_register_group_extension( 'BP4785_Ext5' ); |
|---|
| 122 | |
|---|
| 123 | /** |
|---|
| 124 | * Ext6: |
|---|
| 125 | * - Custom access function |
|---|
| 126 | * |
|---|
| 127 | * To test: |
|---|
| 128 | * - Tab is visible/visitable when ?foo=bar |
|---|
| 129 | */ |
|---|
| 130 | class BP4785_Ext6 extends BP_Group_Extension { |
|---|
| 131 | public function __construct() { |
|---|
| 132 | parent::init( array( |
|---|
| 133 | 'name' => 'Ext6', |
|---|
| 134 | 'slug' => 'ext6', |
|---|
| 135 | ) ); |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | public function user_can_visit( $user_can_visit = false ) { |
|---|
| 139 | return isset( $_GET['foo'] ) && 'bar' == $_GET['foo']; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | public function user_can_see_nav_item( $user_can_visit = false ) { |
|---|
| 143 | return isset( $_GET['foo'] ) && 'bar' == $_GET['foo']; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | public function display() { |
|---|
| 147 | echo 'Yes'; |
|---|
| 148 | } |
|---|
| 149 | } |
|---|
| 150 | bp_register_group_extension( 'BP4785_Ext6' ); |
|---|