| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | class BP_Groups_Template { |
|---|
| 4 | var $current_group = -1; |
|---|
| 5 | var $group_count; |
|---|
| 6 | var $groups; |
|---|
| 7 | var $group; |
|---|
| 8 | |
|---|
| 9 | var $in_the_loop; |
|---|
| 10 | |
|---|
| 11 | var $pag_page; |
|---|
| 12 | var $pag_num; |
|---|
| 13 | var $pag_links; |
|---|
| 14 | var $total_group_count; |
|---|
| 15 | |
|---|
| 16 | var $single_group = false; |
|---|
| 17 | |
|---|
| 18 | var $sort_by; |
|---|
| 19 | var $order; |
|---|
| 20 | |
|---|
| 21 | function bp_groups_template( $user_id = null, $group_slug = null, $groups_per_page = 10 ) { |
|---|
| 22 | global $bp, $current_user; |
|---|
| 23 | |
|---|
| 24 | if ( !$user_id ) |
|---|
| 25 | $user_id = $current_user->id; |
|---|
| 26 | |
|---|
| 27 | $this->pag_page = isset( $_REQUEST['fpage'] ) ? intval( $_REQUEST['fpage'] ) : 1; |
|---|
| 28 | $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $groups_per_page; |
|---|
| 29 | |
|---|
| 30 | if ( ( $bp['current_action'] == 'my-groups' && $_REQUEST['group-filter-box'] == '' ) || ( !$bp['current_action'] && !isset($_REQUEST['page']) && $_REQUEST['group-filter-box'] == '' ) ) { |
|---|
| 31 | |
|---|
| 32 | $order = $bp['action_variables'][0]; |
|---|
| 33 | |
|---|
| 34 | if ( $order == 'recently-joined' ) { |
|---|
| 35 | $this->groups = groups_get_recently_joined_for_user( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 36 | } else if ( $order == 'most-popular' ) { |
|---|
| 37 | $this->groups = groups_get_most_popular_for_user( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 38 | } else if ( $order == 'admin-of' ) { |
|---|
| 39 | $this->groups = groups_get_user_is_admin_of( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 40 | } else if ( $order == 'mod-of' ) { |
|---|
| 41 | $this->groups = groups_get_user_is_mod_of( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 42 | } else if ( $order == 'alphabetically' ) { |
|---|
| 43 | $this->groups = groups_get_alphabetically_for_user( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 44 | } else { |
|---|
| 45 | $this->groups = groups_get_recently_active_for_user( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | $this->total_group_count = (int)$this->groups['total']; |
|---|
| 49 | $this->groups = $this->groups['groups']; |
|---|
| 50 | $this->group_count = count($this->groups); |
|---|
| 51 | |
|---|
| 52 | } else if ( ( $bp['current_action'] == 'my-groups' && $_REQUEST['group-filter-box'] != '' ) || ( !$bp['current_action'] && !isset($_REQUEST['page']) && $_REQUEST['group-filter-box'] != '' ) ) { |
|---|
| 53 | |
|---|
| 54 | $this->groups = groups_filter_user_groups( $_REQUEST['group-filter-box'], $this->pag_num, $this->pag_page ); |
|---|
| 55 | $this->total_group_count = (int)$this->groups['total']; |
|---|
| 56 | $this->groups = $this->groups['groups']; |
|---|
| 57 | $this->group_count = count($this->groups); |
|---|
| 58 | |
|---|
| 59 | } else if ( $bp['current_action'] == 'invites' ) { |
|---|
| 60 | |
|---|
| 61 | $this->groups = groups_get_invites_for_user(); |
|---|
| 62 | $this->total_group_count = count($this->groups); |
|---|
| 63 | $this->group_count = count($this->groups); |
|---|
| 64 | |
|---|
| 65 | } else if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'groups_admin_settings' ) { |
|---|
| 66 | |
|---|
| 67 | $this->sort_by = $_REQUEST['sortby']; |
|---|
| 68 | $this->order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'ASC'; |
|---|
| 69 | |
|---|
| 70 | if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { |
|---|
| 71 | $this->groups = groups_search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page, $this->sort_by, $this->order ); |
|---|
| 72 | $this->total_group_count = (int)$this->groups['total']; |
|---|
| 73 | $this->groups = $this->groups['groups']; |
|---|
| 74 | $this->group_count = count($this->groups); |
|---|
| 75 | } else { |
|---|
| 76 | $this->groups = groups_get_all( $this->pag_num, $this->pag_page, false, $this->sort_by, $this->order ); |
|---|
| 77 | $this->total_group_count = count( groups_get_all() ); // TODO: not ideal |
|---|
| 78 | $this->group_count = count($this->groups); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | } else if ( $group_slug ) { |
|---|
| 82 | |
|---|
| 83 | $this->single_group = true; |
|---|
| 84 | |
|---|
| 85 | $group = new stdClass(); |
|---|
| 86 | $group->group_id = BP_Groups_Group::get_id_from_slug($group_slug); |
|---|
| 87 | |
|---|
| 88 | $this->groups = array( $group ); |
|---|
| 89 | $this->total_group_count = 1; |
|---|
| 90 | $this->group_count = 1; |
|---|
| 91 | |
|---|
| 92 | } else { |
|---|
| 93 | |
|---|
| 94 | $this->groups = groups_get_user_groups( $bp['current_userid'], $this->pag_num, $this->pag_page ); |
|---|
| 95 | $this->total_group_count = (int)$this->groups['total']; |
|---|
| 96 | $this->groups = $this->groups['groups']; |
|---|
| 97 | $this->group_count = count($this->groups); |
|---|
| 98 | |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | $this->pag_links = paginate_links( array( |
|---|
| 102 | 'base' => add_query_arg( array( 'fpage' => '%#%', 'num' => $this->pag_num, 's' => $_REQUEST['s'], 'sortby' => $this->sort_by, 'order' => $this->order ) ), |
|---|
| 103 | 'format' => '', |
|---|
| 104 | 'total' => ceil($this->total_group_count / $this->pag_num), |
|---|
| 105 | 'current' => $this->pag_page, |
|---|
| 106 | 'prev_text' => '«', |
|---|
| 107 | 'next_text' => '»', |
|---|
| 108 | 'mid_size' => 1 |
|---|
| 109 | )); |
|---|
| 110 | |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | function has_groups() { |
|---|
| 114 | if ( $this->group_count ) |
|---|
| 115 | return true; |
|---|
| 116 | |
|---|
| 117 | return false; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | function next_group() { |
|---|
| 121 | $this->current_group++; |
|---|
| 122 | $this->group = $this->groups[$this->current_group]; |
|---|
| 123 | |
|---|
| 124 | return $this->group; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | function rewind_groups() { |
|---|
| 128 | $this->current_group = -1; |
|---|
| 129 | if ( $this->group_count > 0 ) { |
|---|
| 130 | $this->group = $this->groups[0]; |
|---|
| 131 | } |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | function user_groups() { |
|---|
| 135 | if ( $this->current_group + 1 < $this->group_count ) { |
|---|
| 136 | return true; |
|---|
| 137 | } elseif ( $this->current_group + 1 == $this->group_count ) { |
|---|
| 138 | do_action('loop_end'); |
|---|
| 139 | // Do some cleaning up after the loop |
|---|
| 140 | $this->rewind_groups(); |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | $this->in_the_loop = false; |
|---|
| 144 | return false; |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | function the_group() { |
|---|
| 148 | global $group; |
|---|
| 149 | |
|---|
| 150 | $this->in_the_loop = true; |
|---|
| 151 | $this->group = $this->next_group(); |
|---|
| 152 | |
|---|
| 153 | // If this is a single group then instantiate group meta when creating the object. |
|---|
| 154 | if ( $this->single_group ) |
|---|
| 155 | $this->group = new BP_Groups_Group( $this->group->group_id, true ); |
|---|
| 156 | else |
|---|
| 157 | $this->group = new BP_Groups_Group( $this->group->group_id, false ); |
|---|
| 158 | |
|---|
| 159 | if ( $this->current_group == 0 ) // loop has just started |
|---|
| 160 | do_action('loop_start'); |
|---|
| 161 | } |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | function bp_has_groups( $groups_per_page = 10 ) { |
|---|
| 165 | global $groups_template, $bp; |
|---|
| 166 | global $is_single_group, $group_obj; |
|---|
| 167 | |
|---|
| 168 | if ( !$is_single_group ) { |
|---|
| 169 | $groups_template = new BP_Groups_Template( $bp['current_userid'], false, $groups_per_page ); |
|---|
| 170 | } else { |
|---|
| 171 | $groups_template = new BP_Groups_Template( $bp['current_userid'], $group_obj->slug, $groups_per_page ); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | return $groups_template->has_groups(); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | function bp_groups() { |
|---|
| 178 | global $groups_template; |
|---|
| 179 | return $groups_template->user_groups(); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | function bp_the_group() { |
|---|
| 183 | global $groups_template; |
|---|
| 184 | return $groups_template->the_group(); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | function bp_group_is_visible() { |
|---|
| 188 | global $bp, $groups_template; |
|---|
| 189 | |
|---|
| 190 | if ( $groups_template->group->status == 'public' ) { |
|---|
| 191 | return true; |
|---|
| 192 | } else { |
|---|
| 193 | if ( groups_is_user_member( $bp['loggedin_userid'], $groups_template->group->id ) ) { |
|---|
| 194 | return true; |
|---|
| 195 | } |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | return false; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | function bp_group_has_news() { |
|---|
| 202 | global $groups_template; |
|---|
| 203 | |
|---|
| 204 | if ( $groups_template->group->news == '' ) |
|---|
| 205 | return false; |
|---|
| 206 | |
|---|
| 207 | return true; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | function bp_group_id( $echo = true ) { |
|---|
| 211 | global $groups_template; |
|---|
| 212 | |
|---|
| 213 | if ( $echo ) |
|---|
| 214 | echo apply_filters( 'bp_group_id', $groups_template->group->id ); |
|---|
| 215 | else |
|---|
| 216 | return apply_filters( 'bp_group_id', $groups_template->group->id ); |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | function bp_group_name( $echo = true ) { |
|---|
| 220 | global $groups_template; |
|---|
| 221 | |
|---|
| 222 | if ( $echo ) |
|---|
| 223 | echo apply_filters( 'bp_group_name', $groups_template->group->name ); |
|---|
| 224 | else |
|---|
| 225 | return apply_filters( 'bp_group_name', $groups_template->group->name ); |
|---|
| 226 | } |
|---|
| 227 | |
|---|
| 228 | function bp_group_type() { |
|---|
| 229 | global $groups_template; |
|---|
| 230 | |
|---|
| 231 | if ( $groups_template->group->status == 'public' ) { |
|---|
| 232 | $type = __( "Public Group", "buddypress" ); |
|---|
| 233 | } else if ( $groups_template->group->status == 'hidden' ) { |
|---|
| 234 | $type = __( "Hidden Group", "buddypress" ); |
|---|
| 235 | } else if ( $groups_template->group->status == 'private' ) { |
|---|
| 236 | $type = __( "Private Group", "buddypress" ); |
|---|
| 237 | } else { |
|---|
| 238 | $type = ucwords( $groups_template->group->status ) . ' ' . __( 'Group', 'buddypress' ); |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | echo apply_filters( 'bp_group_type', $type ); |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | function bp_group_avatar() { |
|---|
| 245 | global $groups_template; |
|---|
| 246 | |
|---|
| 247 | ?><img src="<?php echo $groups_template->group->avatar_full ?>" class="avatar" alt="<?php echo $groups_template->group->name ?> Avatar" /><?php |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | function bp_group_avatar_thumb() { |
|---|
| 251 | global $groups_template; |
|---|
| 252 | |
|---|
| 253 | ?><img src="<?php echo $groups_template->group->avatar_thumb ?>" class="avatar" alt="<?php echo $groups_template->group->name ?> Avatar" /><?php |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | function bp_group_avatar_mini() { |
|---|
| 257 | global $groups_template; |
|---|
| 258 | |
|---|
| 259 | ?><img src="<?php echo $groups_template->group->avatar_thumb ?>" width="30" height="30" class="avatar" alt="<?php echo $groups_template->group->name ?> Avatar" /><?php |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | function bp_group_last_active( $echo = true ) { |
|---|
| 263 | global $groups_template; |
|---|
| 264 | |
|---|
| 265 | $last_active = groups_get_groupmeta( $groups_template->group->id, 'last_activity' ); |
|---|
| 266 | |
|---|
| 267 | if ( $last_active == '' ) |
|---|
| 268 | _e( 'not yet active', 'buddypress' ); |
|---|
| 269 | else |
|---|
| 270 | echo apply_filters( 'bp_group_last_active', bp_core_time_since( $last_active ) ); |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | function bp_group_permalink( $group_obj = false, $echo = true ) { |
|---|
| 274 | global $groups_template, $bp, $current_blog; |
|---|
| 275 | |
|---|
| 276 | if ( !$group_obj ) |
|---|
| 277 | $group_obj = $groups_template->group; |
|---|
| 278 | |
|---|
| 279 | if ( $echo ) |
|---|
| 280 | echo apply_filters( 'bp_group_permalink', $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug ); |
|---|
| 281 | else |
|---|
| 282 | return apply_filters( 'bp_group_permalink', $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug ); |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | function bp_group_admin_permalink( $group_obj = false, $echo = true ) { |
|---|
| 286 | global $groups_template, $bp, $current_blog; |
|---|
| 287 | |
|---|
| 288 | if ( !$group_obj ) |
|---|
| 289 | $group_obj = $groups_template->group; |
|---|
| 290 | |
|---|
| 291 | if ( $echo ) |
|---|
| 292 | echo apply_filters( 'bp_group_admin_permalink', $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug . '/admin' ); |
|---|
| 293 | else |
|---|
| 294 | return apply_filters( 'bp_group_admin_permalink', $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug . '/admin' ); |
|---|
| 295 | } |
|---|
| 296 | |
|---|
| 297 | function bp_group_slug() { |
|---|
| 298 | global $groups_template; |
|---|
| 299 | echo apply_filters( 'bp_group_slug', $groups_template->group->slug ); |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | function bp_group_description() { |
|---|
| 303 | global $groups_template; |
|---|
| 304 | |
|---|
| 305 | echo apply_filters( 'bp_group_description', stripslashes($groups_template->group->description) ); |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | function bp_group_description_editable() { |
|---|
| 309 | global $groups_template; |
|---|
| 310 | |
|---|
| 311 | echo apply_filters( 'bp_group_description_editable', $groups_template->group->description ); |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | function bp_group_description_excerpt() { |
|---|
| 315 | global $groups_template; |
|---|
| 316 | |
|---|
| 317 | echo apply_filters( 'bp_group_description_excerpt', bp_create_excerpt( $groups_template->group->description, 20 ) ); |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | function bp_group_news() { |
|---|
| 321 | global $groups_template; |
|---|
| 322 | |
|---|
| 323 | echo apply_filters( 'bp_group_news', stripslashes($groups_template->group->news) ); |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | function bp_group_news_editable() { |
|---|
| 327 | global $groups_template; |
|---|
| 328 | |
|---|
| 329 | echo apply_filters( 'bp_group_news_editable', $groups_template->group->news ); |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | function bp_group_public_status() { |
|---|
| 333 | global $groups_template; |
|---|
| 334 | |
|---|
| 335 | if ( $groups_template->group->is_public ) { |
|---|
| 336 | _e('Public', 'buddypress'); |
|---|
| 337 | } else { |
|---|
| 338 | _e('Private', 'buddypress'); |
|---|
| 339 | } |
|---|
| 340 | } |
|---|
| 341 | function bp_group_is_public() { |
|---|
| 342 | global $groups_template; |
|---|
| 343 | return apply_filters( 'bp_group_is_public', $groups_template->group->is_public ); |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | function bp_group_date_created() { |
|---|
| 348 | global $groups_template; |
|---|
| 349 | |
|---|
| 350 | echo apply_filters( 'bp_group_date_created', date( get_option( 'date_format' ), $groups_template->group->date_created ) ); |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | function bp_group_list_admins( $full_list = true ) { |
|---|
| 354 | global $groups_template; |
|---|
| 355 | |
|---|
| 356 | if ( !$admins = &$groups_template->group->admins ) |
|---|
| 357 | $admins = $groups_template->group->get_administrators(); |
|---|
| 358 | |
|---|
| 359 | if ( $admins ) { |
|---|
| 360 | if ( $full_list ) { ?> |
|---|
| 361 | <ul id="group-admins"> |
|---|
| 362 | <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> |
|---|
| 363 | <li> |
|---|
| 364 | <?php echo $admins[$i]->user->avatar_thumb ?> |
|---|
| 365 | <h5><?php echo $admins[$i]->user->user_link ?></h5> |
|---|
| 366 | <span class="activity"><?php echo $admins[$i]->user_title ?></span> |
|---|
| 367 | <hr /> |
|---|
| 368 | </li> |
|---|
| 369 | <?php } ?> |
|---|
| 370 | </ul> |
|---|
| 371 | <?php } else { ?> |
|---|
| 372 | <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> |
|---|
| 373 | <?php echo $admins[$i]->user->user_link ?> |
|---|
| 374 | <?php } ?> |
|---|
| 375 | <?php } ?> |
|---|
| 376 | <?php } else { ?> |
|---|
| 377 | <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> |
|---|
| 378 | <?php } ?> |
|---|
| 379 | |
|---|
| 380 | <?php |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | function bp_group_list_mods( $full_list = true ) { |
|---|
| 384 | global $groups_template; |
|---|
| 385 | |
|---|
| 386 | $group_mods = groups_get_group_mods( $groups_template->group->id ); |
|---|
| 387 | |
|---|
| 388 | if ( $group_mods ) { |
|---|
| 389 | if ( $full_list ) { ?> |
|---|
| 390 | <ul id="group-mods" class="mods-list"> |
|---|
| 391 | <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?> |
|---|
| 392 | <li> |
|---|
| 393 | <?php echo bp_core_get_avatar( $group_mods[$i]->user_id, 1, 50, 50 ) ?> |
|---|
| 394 | <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5> |
|---|
| 395 | <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span> |
|---|
| 396 | <div class="clear"></div> |
|---|
| 397 | </li> |
|---|
| 398 | <?php } ?> |
|---|
| 399 | </ul> |
|---|
| 400 | <?php } else { ?> |
|---|
| 401 | <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> |
|---|
| 402 | <?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?> |
|---|
| 403 | <?php } ?> |
|---|
| 404 | <?php } ?> |
|---|
| 405 | <?php } else { ?> |
|---|
| 406 | <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> |
|---|
| 407 | <?php } ?> |
|---|
| 408 | |
|---|
| 409 | <?php |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | function bp_group_all_members_permalink( $echo = true ) { |
|---|
| 413 | global $groups_template, $bp; |
|---|
| 414 | |
|---|
| 415 | if ( $echo ) |
|---|
| 416 | echo apply_filters( 'bp_group_all_members_permalink', bp_group_permalink( false, true ) . '/' . MEMBERS_SLUG ); |
|---|
| 417 | else |
|---|
| 418 | return apply_filters( 'bp_group_all_members_permalink', bp_group_permalink( false, false ) . '/' . MEMBERS_SLUG ); |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | function bp_group_random_members() { |
|---|
| 422 | global $groups_template; |
|---|
| 423 | |
|---|
| 424 | $members = &$groups_template->group->random_members; |
|---|
| 425 | ?> |
|---|
| 426 | <ul class="horiz-gallery"> |
|---|
| 427 | <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?> |
|---|
| 428 | <li> |
|---|
| 429 | <a href="<?php echo $members[$i]->user->user_url ?>"><?php echo $members[$i]->user->avatar_thumb ?></a> |
|---|
| 430 | <h5><?php echo $members[$i]->user->user_link ?></h5> |
|---|
| 431 | </li> |
|---|
| 432 | <?php } ?> |
|---|
| 433 | </ul> |
|---|
| 434 | <div class="clear"></div> |
|---|
| 435 | <?php |
|---|
| 436 | } |
|---|
| 437 | |
|---|
| 438 | function bp_group_active_forum_topics( $total_topics = 3 ) { |
|---|
| 439 | global $groups_template, $forum_template; |
|---|
| 440 | |
|---|
| 441 | $forum_id = groups_get_groupmeta( $groups_template->group->id, 'forum_id' ); |
|---|
| 442 | |
|---|
| 443 | if ( $forum_id && $forum_id != '' ) { |
|---|
| 444 | if ( function_exists( 'bp_forums_setup' ) ) { |
|---|
| 445 | $latest_topics = bp_forums_get_topics( $forum_id, $total_topics, 1 ); |
|---|
| 446 | |
|---|
| 447 | if ( $latest_topics ) { ?> |
|---|
| 448 | <ul class="item-list" id="recent-forum-topics"><?php |
|---|
| 449 | foreach( $latest_topics as $topic ) { |
|---|
| 450 | $forum_template->topic = (object)$topic; ?> |
|---|
| 451 | <li> |
|---|
| 452 | <div class="avatar"> |
|---|
| 453 | <?php bp_the_topic_poster_avatar() ?> |
|---|
| 454 | </div> |
|---|
| 455 | |
|---|
| 456 | <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> |
|---|
| 457 | <span class="small">- <?php bp_the_topic_total_post_count() ?> </span> |
|---|
| 458 | <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p> |
|---|
| 459 | |
|---|
| 460 | <div class="latest-post"> |
|---|
| 461 | <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>: |
|---|
| 462 | <?php bp_the_topic_latest_post_excerpt() ?> |
|---|
| 463 | </div> |
|---|
| 464 | </li> |
|---|
| 465 | <?php } ?> |
|---|
| 466 | </ul> |
|---|
| 467 | <?php |
|---|
| 468 | } else { |
|---|
| 469 | ?> |
|---|
| 470 | <div id="message" class="info"> |
|---|
| 471 | <p><?php _e( 'There are no active forum topics for this group', 'buddypress' ) ?></p> |
|---|
| 472 | </div> |
|---|
| 473 | <?php |
|---|
| 474 | } |
|---|
| 475 | } |
|---|
| 476 | } |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | function bp_group_search_form() { |
|---|
| 480 | global $groups_template, $bp; |
|---|
| 481 | |
|---|
| 482 | if ( $bp['current_action'] == 'my-groups' || !$bp['current_action'] ) { |
|---|
| 483 | $action = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/my-groups/search/'; |
|---|
| 484 | $label = __('Filter Groups', 'buddypress'); |
|---|
| 485 | $name = 'group-filter-box'; |
|---|
| 486 | } else { |
|---|
| 487 | $action = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/group-finder/search/'; |
|---|
| 488 | $label = __('Find a Group', 'buddypress'); |
|---|
| 489 | $name = 'groupfinder-search-box'; |
|---|
| 490 | $value = $bp['action_variables'][0]; |
|---|
| 491 | } |
|---|
| 492 | ?> |
|---|
| 493 | <form action="<?php echo $action ?>" id="group-search-form" method="post"> |
|---|
| 494 | <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?> <img id="ajax-loader" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></label> |
|---|
| 495 | <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> /> |
|---|
| 496 | <?php if ( function_exists('wp_nonce_field') ) |
|---|
| 497 | wp_nonce_field( $name ); |
|---|
| 498 | ?> |
|---|
| 499 | </form> |
|---|
| 500 | <?php |
|---|
| 501 | } |
|---|
| 502 | |
|---|
| 503 | function bp_group_show_no_groups_message() { |
|---|
| 504 | global $bp; |
|---|
| 505 | |
|---|
| 506 | if ( !groups_total_groups_for_user( $bp['current_userid'] ) ) |
|---|
| 507 | return true; |
|---|
| 508 | |
|---|
| 509 | return false; |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | function bp_group_pagination() { |
|---|
| 513 | global $groups_template; |
|---|
| 514 | echo apply_filters( 'bp_group_pagination', $groups_template->pag_links ); |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | function bp_total_group_count() { |
|---|
| 518 | global $groups_template; |
|---|
| 519 | |
|---|
| 520 | echo apply_filters( 'bp_total_group_count', $groups_template->total_group_count ); |
|---|
| 521 | } |
|---|
| 522 | |
|---|
| 523 | function bp_group_total_members( $echo = true ) { |
|---|
| 524 | global $groups_template; |
|---|
| 525 | |
|---|
| 526 | if ( $echo ) |
|---|
| 527 | echo apply_filters( 'groups_template', $groups_template->group->total_member_count ); |
|---|
| 528 | else |
|---|
| 529 | return apply_filters( 'groups_template', $groups_template->group->total_member_count ); |
|---|
| 530 | } |
|---|
| 531 | |
|---|
| 532 | function bp_group_is_photos_enabled() { |
|---|
| 533 | global $groups_template; |
|---|
| 534 | |
|---|
| 535 | if ( $groups_template->group->enable_photos ) |
|---|
| 536 | return true; |
|---|
| 537 | |
|---|
| 538 | return false; |
|---|
| 539 | } |
|---|
| 540 | |
|---|
| 541 | function bp_group_show_wire_setting() { |
|---|
| 542 | global $groups_template; |
|---|
| 543 | |
|---|
| 544 | if ( $groups_template->group->enable_wire ) |
|---|
| 545 | echo ' checked="checked"'; |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | function bp_group_is_wire_enabled() { |
|---|
| 549 | global $groups_template; |
|---|
| 550 | |
|---|
| 551 | if ( $groups_template->group->enable_wire ) |
|---|
| 552 | return true; |
|---|
| 553 | |
|---|
| 554 | return false; |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | function bp_group_forum_permalink() { |
|---|
| 558 | global $groups_template; |
|---|
| 559 | |
|---|
| 560 | echo bp_group_permalink( $groups_template->group, false ) . '/forum'; |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | function bp_group_is_forum_enabled() { |
|---|
| 564 | global $groups_template; |
|---|
| 565 | |
|---|
| 566 | if ( function_exists( 'bp_forums_is_installed_correctly' ) ) { |
|---|
| 567 | if ( bp_forums_is_installed_correctly() ) { |
|---|
| 568 | if ( $groups_template->group->enable_forum ) |
|---|
| 569 | return true; |
|---|
| 570 | |
|---|
| 571 | return false; |
|---|
| 572 | } else { |
|---|
| 573 | return false; |
|---|
| 574 | } |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | return false; |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | function bp_group_show_forum_setting() { |
|---|
| 581 | global $groups_template; |
|---|
| 582 | |
|---|
| 583 | if ( $groups_template->group->enable_forum ) |
|---|
| 584 | echo ' checked="checked"'; |
|---|
| 585 | } |
|---|
| 586 | |
|---|
| 587 | function bp_group_show_photos_setting() { |
|---|
| 588 | global $groups_template; |
|---|
| 589 | |
|---|
| 590 | if ( $groups_template->group->enable_photos ) |
|---|
| 591 | echo ' checked="checked"'; |
|---|
| 592 | } |
|---|
| 593 | |
|---|
| 594 | function bp_group_show_photos_upload_setting( $permission ) { |
|---|
| 595 | global $groups_template; |
|---|
| 596 | |
|---|
| 597 | if ( $permission == 'admin' && $groups_template->group->photos_admin_only ) |
|---|
| 598 | echo ' checked="checked"'; |
|---|
| 599 | |
|---|
| 600 | if ( $permission == 'member' && !$groups_template->group->photos_admin_only ) |
|---|
| 601 | echo ' checked="checked"'; |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | function bp_group_show_status_setting( $setting ) { |
|---|
| 605 | global $groups_template; |
|---|
| 606 | |
|---|
| 607 | if ( $setting == $groups_template->group->status ) |
|---|
| 608 | echo ' checked="checked"'; |
|---|
| 609 | } |
|---|
| 610 | |
|---|
| 611 | function bp_group_admin_memberlist( $admin_list = false ) { |
|---|
| 612 | global $groups_template; |
|---|
| 613 | |
|---|
| 614 | $admins = groups_get_group_admins( $groups_template->group->id ); |
|---|
| 615 | ?> |
|---|
| 616 | <?php if ( $admins ) { ?> |
|---|
| 617 | <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> |
|---|
| 618 | <?php foreach ( $admins as $admin ) { ?> |
|---|
| 619 | <?php if ( $admin_list ) { ?> |
|---|
| 620 | <li> |
|---|
| 621 | <?php echo bp_core_get_avatar( $admin->user_id, 1, 30, 30 ) ?> |
|---|
| 622 | <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> |
|---|
| 623 | </li> |
|---|
| 624 | <?php } else { ?> |
|---|
| 625 | <li> |
|---|
| 626 | <?php echo bp_core_get_avatar( $admin->user_id, 1 ) ?> |
|---|
| 627 | <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> |
|---|
| 628 | <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> |
|---|
| 629 | |
|---|
| 630 | <?php if ( function_exists( 'friends_install' ) ) : ?> |
|---|
| 631 | <div class="action"> |
|---|
| 632 | <?php bp_add_friend_button( $admin->user_id ) ?> |
|---|
| 633 | </div> |
|---|
| 634 | <?php endif; ?> |
|---|
| 635 | </li> |
|---|
| 636 | <?php } ?> |
|---|
| 637 | <?php } ?> |
|---|
| 638 | </ul> |
|---|
| 639 | <?php } else { ?> |
|---|
| 640 | <div id="message" class="info"> |
|---|
| 641 | <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p> |
|---|
| 642 | </div> |
|---|
| 643 | <?php } |
|---|
| 644 | } |
|---|
| 645 | |
|---|
| 646 | function bp_group_mod_memberlist( $admin_list = false ) { |
|---|
| 647 | global $groups_template, $group_mods; |
|---|
| 648 | |
|---|
| 649 | $group_mods = groups_get_group_mods( $groups_template->group->id ); |
|---|
| 650 | ?> |
|---|
| 651 | <?php if ( $group_mods ) { ?> |
|---|
| 652 | <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> |
|---|
| 653 | <?php foreach ( $group_mods as $mod ) { ?> |
|---|
| 654 | <?php if ( $admin_list ) { ?> |
|---|
| 655 | <li> |
|---|
| 656 | <?php echo bp_core_get_avatar( $mod->user_id, 1, 30, 30 ) ?> |
|---|
| 657 | <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?> <span class="small"> — <a href="<?php bp_group_member_ban_link() ?>"><?php _e( 'Kick & Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5> |
|---|
| 658 | </li> |
|---|
| 659 | <?php } else { ?> |
|---|
| 660 | <li> |
|---|
| 661 | <?php echo bp_core_get_avatar( $mod->user_id, 1 ) ?> |
|---|
| 662 | <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> |
|---|
| 663 | <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> |
|---|
| 664 | |
|---|
| 665 | <?php if ( function_exists( 'friends_install' ) ) : ?> |
|---|
| 666 | <div class="action"> |
|---|
| 667 | <?php bp_add_friend_button( $mod->user_id ) ?> |
|---|
| 668 | </div> |
|---|
| 669 | <?php endif; ?> |
|---|
| 670 | </li> |
|---|
| 671 | <?php } ?> |
|---|
| 672 | <?php } ?> |
|---|
| 673 | </ul> |
|---|
| 674 | <?php } else { ?> |
|---|
| 675 | <div id="message" class="info"> |
|---|
| 676 | <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p> |
|---|
| 677 | </div> |
|---|
| 678 | <?php } |
|---|
| 679 | } |
|---|
| 680 | |
|---|
| 681 | function bp_group_has_moderators() { |
|---|
| 682 | global $group_mods, $groups_template; |
|---|
| 683 | |
|---|
| 684 | return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $groups_template->group->id ) ); |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | function bp_group_member_promote_link() { |
|---|
| 688 | global $members_template, $groups_template, $bp; |
|---|
| 689 | |
|---|
| 690 | echo apply_filters( 'bp_group_member_promote_link', bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/promote/' . $members_template->member->user_id ); |
|---|
| 691 | } |
|---|
| 692 | |
|---|
| 693 | function bp_group_member_demote_link( $user_id = false) { |
|---|
| 694 | global $members_template, $groups_template, $bp; |
|---|
| 695 | |
|---|
| 696 | if ( !$user_id ) |
|---|
| 697 | $user_id = $members_template->member->user_id; |
|---|
| 698 | |
|---|
| 699 | echo apply_filters( 'bp_group_member_demote_link', bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/demote/' . $user_id ); |
|---|
| 700 | } |
|---|
| 701 | |
|---|
| 702 | function bp_group_member_ban_link() { |
|---|
| 703 | global $members_template, $groups_template, $bp; |
|---|
| 704 | |
|---|
| 705 | echo apply_filters( 'bp_group_member_ban_link', bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/ban/' . $members_template->member->user_id ); |
|---|
| 706 | } |
|---|
| 707 | |
|---|
| 708 | function bp_group_member_unban_link() { |
|---|
| 709 | global $members_template, $groups_template, $bp; |
|---|
| 710 | |
|---|
| 711 | echo apply_filters( 'bp_group_member_unban_link', bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/unban/' . $members_template->member->user_id ); |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | function bp_group_admin_tabs() { |
|---|
| 715 | global $bp, $groups_template; |
|---|
| 716 | |
|---|
| 717 | $current_tab = $bp['action_variables'][0]; |
|---|
| 718 | ?> |
|---|
| 719 | <?php if ( $bp['is_item_admin'] || $bp['is_item_mod'] ) { ?> |
|---|
| 720 | <li<?php if ( $current_tab == 'edit-details' || $current_tab == '' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> |
|---|
| 721 | <?php } ?> |
|---|
| 722 | |
|---|
| 723 | <?php if ( $bp['is_item_admin'] ) { ?> |
|---|
| 724 | <li<?php if ( $current_tab == 'group-settings' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li> |
|---|
| 725 | <?php } ?> |
|---|
| 726 | |
|---|
| 727 | <?php if ( $bp['is_item_admin'] ) { ?> |
|---|
| 728 | <li<?php if ( $current_tab == 'group-avatar' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li> |
|---|
| 729 | <?php } ?> |
|---|
| 730 | |
|---|
| 731 | <?php if ( $bp['is_item_admin'] ) { ?> |
|---|
| 732 | <li<?php if ( $current_tab == 'manage-members' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li> |
|---|
| 733 | <?php } ?> |
|---|
| 734 | |
|---|
| 735 | <?php if ( $bp['is_item_admin'] && $groups_template->group->status == 'private' ) : ?> |
|---|
| 736 | <li<?php if ( $current_tab == 'membership-requests' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> |
|---|
| 737 | <?php endif; ?> |
|---|
| 738 | |
|---|
| 739 | <?php if ( $bp['is_item_admin'] ) { ?> |
|---|
| 740 | <li<?php if ( $current_tab == 'delete-group' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> |
|---|
| 741 | <?php } ?> |
|---|
| 742 | |
|---|
| 743 | <?php |
|---|
| 744 | do_action( 'groups_admin_tabs' ); |
|---|
| 745 | } |
|---|
| 746 | |
|---|
| 747 | function bp_group_form_action( $page ) { |
|---|
| 748 | global $bp, $groups_template; |
|---|
| 749 | |
|---|
| 750 | echo apply_filters( 'bp_group_form_action', bp_group_permalink( $group, false ) . '/' . $page ); |
|---|
| 751 | } |
|---|
| 752 | |
|---|
| 753 | function bp_group_admin_form_action( $page ) { |
|---|
| 754 | global $bp, $groups_template; |
|---|
| 755 | |
|---|
| 756 | echo apply_filters( 'bp_group_admin_form_action', bp_group_permalink( $group, false ) . '/admin/' . $page ); |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | function bp_group_has_requested_membership( $group = false ) { |
|---|
| 760 | global $bp, $groups_template; |
|---|
| 761 | |
|---|
| 762 | if ( !$group ) |
|---|
| 763 | $group = $groups_template->group; |
|---|
| 764 | |
|---|
| 765 | if ( groups_check_for_membership_request( $bp['loggedin_userid'], $group->id ) ) |
|---|
| 766 | return true; |
|---|
| 767 | |
|---|
| 768 | return false; |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | function bp_group_creation_tabs() { |
|---|
| 772 | global $bp, $create_group_step, $completed_to_step; |
|---|
| 773 | ?> |
|---|
| 774 | <li<?php if ( $create_group_step == '1' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/create/step/1">1. <?php _e('Group Details', 'buddypress') ?></a></li> |
|---|
| 775 | <li<?php if ( $create_group_step == '2' ) : ?> class="current"<?php endif; ?>><?php if ( $completed_to_step > 0 ) { ?><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/create/step/2">2. <?php _e('Group Settings', 'buddypress') ?></a><?php } else { ?><span>2. <?php _e('Group Settings', 'buddypress') ?></span><?php } ?></li> |
|---|
| 776 | <li<?php if ( $create_group_step == '3' ) : ?> class="current"<?php endif; ?>><?php if ( $completed_to_step > 1 ) { ?><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/create/step/3">3. <?php _e('Group Avatar', 'buddypress') ?></a><?php } else { ?><span>3. <?php _e('Group Avatar', 'buddypress') ?></span><?php } ?></li> |
|---|
| 777 | <li<?php if ( $create_group_step == '4' ) : ?> class="current"<?php endif; ?>><?php if ( $completed_to_step > 2 ) { ?><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/create/step/4">4. <?php _e('Invite Members', 'buddypress') ?></a><?php } else { ?><span>4. <?php _e('Invite Members', 'buddypress') ?></span><?php } ?></li> |
|---|
| 778 | <?php |
|---|
| 779 | do_action( 'groups_creation_tabs' ); |
|---|
| 780 | } |
|---|
| 781 | |
|---|
| 782 | function bp_group_creation_stage_title() { |
|---|
| 783 | global $create_group_step; |
|---|
| 784 | |
|---|
| 785 | switch( $create_group_step ) { |
|---|
| 786 | case '1': |
|---|
| 787 | echo '<span>— ' . __('Group Details', 'buddypress') . '</span>'; |
|---|
| 788 | break; |
|---|
| 789 | |
|---|
| 790 | case '2': |
|---|
| 791 | echo '<span>— ' . __('Group Settings', 'buddypress') . '</span>'; |
|---|
| 792 | break; |
|---|
| 793 | |
|---|
| 794 | case '3': |
|---|
| 795 | echo '<span>— ' . __('Group Avatar', 'buddypress') . '</span>'; |
|---|
| 796 | break; |
|---|
| 797 | |
|---|
| 798 | case '4': |
|---|
| 799 | echo '<span>— ' . __('Invite Members', 'buddypress') . '</span>'; |
|---|
| 800 | break; |
|---|
| 801 | } |
|---|
| 802 | } |
|---|
| 803 | |
|---|
| 804 | function bp_group_create_form() { |
|---|
| 805 | global $bp, $create_group_step, $completed_to_step; |
|---|
| 806 | global $group_obj, $invites; |
|---|
| 807 | |
|---|
| 808 | ?> |
|---|
| 809 | <form action="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/create/step/<?php echo $create_group_step ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data"> |
|---|
| 810 | <?php switch( $create_group_step ) { |
|---|
| 811 | case '1': ?> |
|---|
| 812 | <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label> |
|---|
| 813 | <input type="text" name="group-name" id="group-name" value="<?php echo ( $group_obj ) ? $group_obj->name : $_POST['group-name']; ?>" /> |
|---|
| 814 | |
|---|
| 815 | <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label> |
|---|
| 816 | <textarea name="group-desc" id="group-desc"><?php echo ( $group_obj ) ? $group_obj->description : $_POST['group-desc']; ?></textarea> |
|---|
| 817 | |
|---|
| 818 | <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label> |
|---|
| 819 | <textarea name="group-news" id="group-news"><?php echo ( $group_obj ) ? $group_obj->news : $_POST['group-news']; ?></textarea> |
|---|
| 820 | |
|---|
| 821 | <?php bp_custom_group_fields_editable() ?> |
|---|
| 822 | |
|---|
| 823 | <p><input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> »" id="save" name="save"/></p> |
|---|
| 824 | <?php break; ?> |
|---|
| 825 | |
|---|
| 826 | <?php case '2': ?> |
|---|
| 827 | <?php if ( $completed_to_step > 0 ) { ?> |
|---|
| 828 | <?php if ( function_exists('bp_wire_install') ) : ?> |
|---|
| 829 | <div class="checkbox"> |
|---|
| 830 | <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $group_obj->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label> |
|---|
| 831 | </div> |
|---|
| 832 | <?php endif; ?> |
|---|
| 833 | |
|---|
| 834 | <?php if ( function_exists('bp_forums_setup') ) : ?> |
|---|
| 835 | <?php if ( bp_forums_is_installed_correctly() ) { ?> |
|---|
| 836 | <div class="checkbox"> |
|---|
| 837 | <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( $group_obj->enable_forum ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label> |
|---|
| 838 | </div> |
|---|
| 839 | <?php } else { |
|---|
| 840 | if ( is_site_admin() ) { |
|---|
| 841 | ?> |
|---|
| 842 | <div class="checkbox"> |
|---|
| 843 | <label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php _e('<strong>Attention Site Admin:</strong> Group forums require correct setup and configuration of a bbPress installation.', 'buddypress') ?></label> |
|---|
| 844 | </div> |
|---|
| 845 | <?php |
|---|
| 846 | } |
|---|
| 847 | }?> |
|---|
| 848 | <?php endif; ?> |
|---|
| 849 | |
|---|
| 850 | <?php if ( function_exists('bp_albums_install') ) : ?> |
|---|
| 851 | <div class="checkbox with-suboptions"> |
|---|
| 852 | <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $group_obj->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label> |
|---|
| 853 | <div class="sub-options"<?php if ( !$group_obj->enable_photos ) { ?> style="display: none;"<?php } ?>> |
|---|
| 854 | <label><input type="radio" name="group-photos-status" value="all"<?php if ( !$group_obj->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('All members can upload photos', 'buddypress') ?></label> |
|---|
| 855 | <label><input type="radio" name="group-photos-status" value="admins"<?php if ( $group_obj->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('Only group admins can upload photos', 'buddypress') ?></label> |
|---|
| 856 | </div> |
|---|
| 857 | </div> |
|---|
| 858 | <?php endif; ?> |
|---|
| 859 | |
|---|
| 860 | <h3><?php _e('Privacy Options', 'buddypress'); ?></h3> |
|---|
| 861 | |
|---|
| 862 | <div class="radio"> |
|---|
| 863 | <label><input type="radio" name="group-status" value="public"<?php if ( $group_obj->status == 'public' ) { ?> checked="checked"<?php } ?> /> <strong><?php _e('This is an open group', 'buddypress') ?></strong><br /><?php _e('This group will be free to join and will appear in group search results.', 'buddypress'); ?></label> |
|---|
| 864 | <label><input type="radio" name="group-status" value="private"<?php if ( $group_obj->status == 'private' ) { ?> checked="checked"<?php } ?> /> <strong><?php _e('This is an private group', 'buddypress') ?></strong><br /><?php _e('This group will require an invite to join but will still appear in group search results.', 'buddypress'); ?></label> |
|---|
| 865 | <label><input type="radio" name="group-status" value="hidden"<?php if ( $group_obj->status == 'hidden' ) { ?> checked="checked"<?php } ?> /> <strong><?php _e('This is a hidden group', 'buddypress') ?></strong><br /><?php _e('This group will require an invite to join and will only be visible to invited members. It will not appear in search results or on member profiles.', 'buddypress'); ?></label> |
|---|
| 866 | </div> |
|---|
| 867 | |
|---|
| 868 | <p><input type="submit" value="<?php _e('Save and Continue', 'buddypress') ?> »" id="save" name="save"/></p> |
|---|
| 869 | <?php } else { ?> |
|---|
| 870 | <div id="message" class="info"> |
|---|
| 871 | <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p> |
|---|
| 872 | </div> |
|---|
| 873 | <?php } ?> |
|---|
| 874 | <?php break; ?> |
|---|
| 875 | |
|---|
| 876 | <?php case '3': ?> |
|---|
| 877 | <?php if ( $completed_to_step > 1 ) { ?> |
|---|
| 878 | <div class="left-menu"> |
|---|
| 879 | <?php bp_group_current_avatar() ?> |
|---|
| 880 | </div> |
|---|
| 881 | |
|---|
| 882 | <div class="main-column"> |
|---|
| 883 | <p><?php _e("Upload an image to use as an avatar for this group. The image will be shown on the main group page, and in search results.", 'buddypress') ?></p> |
|---|
| 884 | |
|---|
| 885 | <?php |
|---|
| 886 | if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) { |
|---|
| 887 | groups_avatar_upload($_FILES); |
|---|
| 888 | } else { |
|---|
| 889 | bp_core_render_avatar_upload_form( '', true ); |
|---|
| 890 | } |
|---|
| 891 | ?> |
|---|
| 892 | |
|---|
| 893 | <div id="skip-continue"> |
|---|
| 894 | <input type="submit" value="<?php _e('Skip', 'buddypress') ?> »" id="skip" name="skip"/> |
|---|
| 895 | </div> |
|---|
| 896 | </div> |
|---|
| 897 | <?php } else { ?> |
|---|
| 898 | <div id="message" class="info"> |
|---|
| 899 | <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p> |
|---|
| 900 | </div> |
|---|
| 901 | <?php } ?> |
|---|
| 902 | <?php break; ?> |
|---|
| 903 | <?php case '4': ?> |
|---|
| 904 | <?php |
|---|
| 905 | if ( $completed_to_step > 2 ) { |
|---|
| 906 | $group_link = bp_group_permalink( $group_obj, false ); |
|---|
| 907 | |
|---|
| 908 | if ( function_exists('friends_install') ) { |
|---|
| 909 | if ( friends_get_friend_count_for_user( $bp['loggedin_userid'] ) ) { |
|---|
| 910 | bp_group_send_invite_form( $group_obj ); |
|---|
| 911 | } else { |
|---|
| 912 | ?> |
|---|
| 913 | <div id="message" class="info"> |
|---|
| 914 | <p><?php _e( 'Once you build up your friends list you will be able to invite friends to join your group.', 'buddypress' ) ?></p> |
|---|
| 915 | </div> |
|---|
| 916 | <?php |
|---|
| 917 | } |
|---|
| 918 | } ?> |
|---|
| 919 | |
|---|
| 920 | <p class="clear"><input type="button" value="<?php _e('Finish', 'buddypress') ?> »" id="save" name="save" onclick="location.href='<?php echo $group_link ?>'" /></p> |
|---|
| 921 | <?php |
|---|
| 922 | } else { ?> |
|---|
| 923 | <div id="message" class="info"> |
|---|
| 924 | <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p> |
|---|
| 925 | </div> |
|---|
| 926 | <?php } ?> |
|---|
| 927 | <?php break; ?> |
|---|
| 928 | <?php } ?> |
|---|
| 929 | </form> |
|---|
| 930 | <?php |
|---|
| 931 | } |
|---|
| 932 | function bp_group_list_invite_friends() { |
|---|
| 933 | global $bp, $group_obj, $invites; |
|---|
| 934 | |
|---|
| 935 | if ( !function_exists('friends_install') ) |
|---|
| 936 | return false; |
|---|
| 937 | |
|---|
| 938 | $friends = friends_get_friends_invite_list( $bp['loggedin_userid'], $group_obj->id ); |
|---|
| 939 | |
|---|
| 940 | if ( $friends ) { |
|---|
| 941 | $invites = groups_get_invites_for_group( $bp['loggedin_userid'], $group_obj->id ); |
|---|
| 942 | |
|---|
| 943 | ?> |
|---|
| 944 | <div id="invite-list"> |
|---|
| 945 | <ul> |
|---|
| 946 | <?php |
|---|
| 947 | for ( $i = 0; $i < count( $friends ); $i++ ) { |
|---|
| 948 | if ( $invites ) { |
|---|
| 949 | if ( in_array( $friends[$i]['id'], $invites ) ) { |
|---|
| 950 | $checked = ' checked="checked"'; |
|---|
| 951 | } else { |
|---|
| 952 | $checked = ''; |
|---|
| 953 | } |
|---|
| 954 | } |
|---|
| 955 | ?> |
|---|
| 956 | |
|---|
| 957 | <li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo $friends[$i]['id'] ?>" /> <?php echo $friends[$i]['full_name']; ?></li> |
|---|
| 958 | <?php } ?> |
|---|
| 959 | </ul> |
|---|
| 960 | </div> |
|---|
| 961 | <?php |
|---|
| 962 | } else { |
|---|
| 963 | _e( 'No friends to invite.', 'buddypress' ); |
|---|
| 964 | } |
|---|
| 965 | } |
|---|
| 966 | |
|---|
| 967 | function bp_groups_header_tabs() { |
|---|
| 968 | global $bp, $create_group_step, $completed_to_step; |
|---|
| 969 | ?> |
|---|
| 970 | <li<?php if ( !isset($bp['action_variables'][0]) || $bp['action_variables'][0] == 'recently-active' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li> |
|---|
| 971 | <li<?php if ( $bp['action_variables'][0] == 'recently-joined' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li> |
|---|
| 972 | <li<?php if ( $bp['action_variables'][0] == 'most-popular' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li> |
|---|
| 973 | <li<?php if ( $bp['action_variables'][0] == 'admin-of' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li> |
|---|
| 974 | <li<?php if ( $bp['action_variables'][0] == 'mod-of' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li> |
|---|
| 975 | <li<?php if ( $bp['action_variables'][0] == 'alphabetically' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li> |
|---|
| 976 | |
|---|
| 977 | <?php |
|---|
| 978 | do_action( 'groups_header_tabs' ); |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | function bp_groups_filter_title() { |
|---|
| 982 | global $bp; |
|---|
| 983 | |
|---|
| 984 | $current_filter = $bp['action_variables'][0]; |
|---|
| 985 | |
|---|
| 986 | switch ( $current_filter ) { |
|---|
| 987 | case 'recently-active': default: |
|---|
| 988 | _e( 'Recently Active', 'buddypress' ); |
|---|
| 989 | break; |
|---|
| 990 | case 'recently-joined': |
|---|
| 991 | _e( 'Recently Joined', 'buddypress' ); |
|---|
| 992 | break; |
|---|
| 993 | case 'most-popular': |
|---|
| 994 | _e( 'Most Popular', 'buddypress' ); |
|---|
| 995 | break; |
|---|
| 996 | case 'admin-of': |
|---|
| 997 | _e( 'Administrator Of', 'buddypress' ); |
|---|
| 998 | break; |
|---|
| 999 | case 'mod-of': |
|---|
| 1000 | _e( 'Moderator Of', 'buddypress' ); |
|---|
| 1001 | break; |
|---|
| 1002 | case 'alphabetically': |
|---|
| 1003 | _e( 'Alphabetically', 'buddypress' ); |
|---|
| 1004 | break; |
|---|
| 1005 | } |
|---|
| 1006 | } |
|---|
| 1007 | |
|---|
| 1008 | function bp_group_is_member() { |
|---|
| 1009 | global $bp, $groups_template; |
|---|
| 1010 | |
|---|
| 1011 | if ( groups_is_user_member( $bp['loggedin_userid'], $groups_template->group->id ) ) |
|---|
| 1012 | return true; |
|---|
| 1013 | |
|---|
| 1014 | return false; |
|---|
| 1015 | } |
|---|
| 1016 | |
|---|
| 1017 | function bp_group_accept_invite_link() { |
|---|
| 1018 | global $groups_template, $bp; |
|---|
| 1019 | |
|---|
| 1020 | echo apply_filters( 'bp_group_accept_invite_link', $bp['loggedin_domain'] . $bp['groups']['slug'] . '/invites/accept/' . $groups_template->group->id ); |
|---|
| 1021 | } |
|---|
| 1022 | |
|---|
| 1023 | function bp_group_reject_invite_link() { |
|---|
| 1024 | global $groups_template, $bp; |
|---|
| 1025 | |
|---|
| 1026 | echo apply_filters( 'bp_group_reject_invite_link', $bp['loggedin_domain'] . $bp['groups']['slug'] . '/invites/reject/' . $groups_template->group->id ); |
|---|
| 1027 | } |
|---|
| 1028 | |
|---|
| 1029 | function bp_has_friends_to_invite() { |
|---|
| 1030 | global $groups_template, $bp; |
|---|
| 1031 | |
|---|
| 1032 | if ( !function_exists('friends_install') ) |
|---|
| 1033 | return false; |
|---|
| 1034 | |
|---|
| 1035 | if ( !friends_check_user_has_friends( $bp['loggedin_userid'] ) || !friends_count_invitable_friends( $bp['loggedin_userid'], $groups_template->group->id ) ) |
|---|
| 1036 | return false; |
|---|
| 1037 | |
|---|
| 1038 | return true; |
|---|
| 1039 | } |
|---|
| 1040 | |
|---|
| 1041 | function bp_group_leave_confirm_link() { |
|---|
| 1042 | global $groups_template, $bp; |
|---|
| 1043 | |
|---|
| 1044 | echo apply_filters( 'bp_group_leave_confirm_link', bp_group_permalink( false, true ) . '/leave-group/yes' ); |
|---|
| 1045 | } |
|---|
| 1046 | |
|---|
| 1047 | function bp_group_leave_reject_link() { |
|---|
| 1048 | global $groups_template, $bp; |
|---|
| 1049 | |
|---|
| 1050 | echo apply_filters( 'bp_group_leave_reject_link', bp_group_permalink( false, true ) ); |
|---|
| 1051 | } |
|---|
| 1052 | |
|---|
| 1053 | function bp_group_send_invite_form( $group_obj = null ) { |
|---|
| 1054 | global $bp, $groups_template, $invites; |
|---|
| 1055 | |
|---|
| 1056 | if ( !$group_obj ) |
|---|
| 1057 | $group_obj =& $groups_template->group; |
|---|
| 1058 | ?> |
|---|
| 1059 | <div class="left-menu"> |
|---|
| 1060 | <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4> |
|---|
| 1061 | <?php bp_group_list_invite_friends() ?> |
|---|
| 1062 | <?php wp_nonce_field( 'invite_user' ) ?> |
|---|
| 1063 | <input type="hidden" name="group_id" id="group_id" value="<?php echo $group_obj->id ?>" /> |
|---|
| 1064 | </div> |
|---|
| 1065 | |
|---|
| 1066 | <div class="main-column"> |
|---|
| 1067 | |
|---|
| 1068 | <div id="message" class="info"> |
|---|
| 1069 | <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p> |
|---|
| 1070 | </div> |
|---|
| 1071 | |
|---|
| 1072 | <?php $invites = groups_get_invites_for_group( $bp['loggedin_userid'], $group_obj->id ) ?> |
|---|
| 1073 | |
|---|
| 1074 | <ul id="friend-list" class="item-list"> |
|---|
| 1075 | <?php for( $i = 0; $i < count($invites); $i++ ) { |
|---|
| 1076 | $user = new BP_Core_User( $invites[$i] ); ?> |
|---|
| 1077 | |
|---|
| 1078 | <li id="uid-<?php echo $user->id ?>"> |
|---|
| 1079 | <?php echo $user->avatar_thumb ?> |
|---|
| 1080 | <h4><?php echo $user->user_link ?></h4> |
|---|
| 1081 | <span class="activity"><?php echo $user->last_active ?></span> |
|---|
| 1082 | <div class="action"> |
|---|
| 1083 | <a class="remove" href="<?php echo site_url() . $bp['groups']['slug'] . '/' . $group_obj->id . '/invites/remove/' . $user->id ?>" id="uid-<?php echo $user->id ?>">Remove Invite</a> |
|---|
| 1084 | </div> |
|---|
| 1085 | </li> |
|---|
| 1086 | <?php } // end for ?> |
|---|
| 1087 | </ul> |
|---|
| 1088 | |
|---|
| 1089 | </div> |
|---|
| 1090 | <?php |
|---|
| 1091 | } |
|---|
| 1092 | |
|---|
| 1093 | function bp_group_current_avatar() { |
|---|
| 1094 | global $group_obj; |
|---|
| 1095 | |
|---|
| 1096 | if ( $group_obj->avatar_full ) { ?> |
|---|
| 1097 | <img src="<?php echo $group_obj->avatar_full ?>" alt="Group Avatar" class="avatar" /> |
|---|
| 1098 | <?php } else { ?> |
|---|
| 1099 | <img src="<?php echo $bp['groups']['image_base'] . '/none.gif' ?>" alt="No Group Avatar" class="avatar" /> |
|---|
| 1100 | <?php } |
|---|
| 1101 | } |
|---|
| 1102 | |
|---|
| 1103 | function bp_group_avatar_edit_form() { |
|---|
| 1104 | if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) { |
|---|
| 1105 | groups_avatar_upload($_FILES); |
|---|
| 1106 | } else { |
|---|
| 1107 | bp_core_render_avatar_upload_form( '', true ); |
|---|
| 1108 | } |
|---|
| 1109 | } |
|---|
| 1110 | |
|---|
| 1111 | function bp_group_send_invite_form_action() { |
|---|
| 1112 | global $groups_template, $bp; |
|---|
| 1113 | |
|---|
| 1114 | echo apply_filters( 'bp_group_send_invite_form_action', bp_group_permalink( false, true ) . '/send-invites/send' ); |
|---|
| 1115 | } |
|---|
| 1116 | |
|---|
| 1117 | function bp_group_join_button( $group = false ) { |
|---|
| 1118 | global $bp, $groups_template; |
|---|
| 1119 | |
|---|
| 1120 | if ( !$group ) |
|---|
| 1121 | $group =& $groups_template->group; |
|---|
| 1122 | |
|---|
| 1123 | // If they're not logged in or are banned from the group, no join button. |
|---|
| 1124 | if ( !is_user_logged_in() || groups_is_user_banned( $bp['loggedin_userid'], $group->id ) ) |
|---|
| 1125 | return false; |
|---|
| 1126 | |
|---|
| 1127 | echo '<div class="group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; |
|---|
| 1128 | |
|---|
| 1129 | switch ( $group->status ) { |
|---|
| 1130 | case 'public': |
|---|
| 1131 | if ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group->id ) ) |
|---|
| 1132 | echo '<a class="leave-group" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __('Leave Group', 'buddypress') . '</a>'; |
|---|
| 1133 | else |
|---|
| 1134 | echo '<a class="join-group" href="' . bp_group_permalink( $group, false ) . '/join">' . __('Join Group', 'buddypress') . '</a>'; |
|---|
| 1135 | break; |
|---|
| 1136 | |
|---|
| 1137 | case 'private': |
|---|
| 1138 | if ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group->id ) ) { |
|---|
| 1139 | echo '<a class="leave-group" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __('Leave Group', 'buddypress') . '</a>'; |
|---|
| 1140 | } else { |
|---|
| 1141 | if ( !bp_group_has_requested_membership( $group ) ) |
|---|
| 1142 | echo '<a class="request-membership" href="' . bp_group_permalink( $group, false ) . '/request-membership">' . __('Request Membership', 'buddypress') . '</a>'; |
|---|
| 1143 | else |
|---|
| 1144 | echo '<a class="membership-requested" href="' . bp_group_permalink( $group, false ) . '">' . __('Membership Requested', 'buddypress') . '</a>'; |
|---|
| 1145 | } |
|---|
| 1146 | break; |
|---|
| 1147 | } |
|---|
| 1148 | |
|---|
| 1149 | echo '</div>'; |
|---|
| 1150 | } |
|---|
| 1151 | |
|---|
| 1152 | function bp_group_status_message() { |
|---|
| 1153 | global $groups_template; |
|---|
| 1154 | |
|---|
| 1155 | if ( $groups_template->group->status == 'private' ) { |
|---|
| 1156 | if ( !bp_group_has_requested_membership() ) |
|---|
| 1157 | if ( is_user_logged_in() ) |
|---|
| 1158 | _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' ); |
|---|
| 1159 | else |
|---|
| 1160 | _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); |
|---|
| 1161 | else |
|---|
| 1162 | _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); |
|---|
| 1163 | } else { |
|---|
| 1164 | _e( 'This is a hidden group and only invited members can join.', 'buddypress' ); |
|---|
| 1165 | } |
|---|
| 1166 | } |
|---|
| 1167 | |
|---|
| 1168 | function bp_groups_random_selection( $total_groups = 5 ) { |
|---|
| 1169 | global $bp; |
|---|
| 1170 | |
|---|
| 1171 | $group_ids = BP_Groups_Group::get_random( $total_groups, 1 ); |
|---|
| 1172 | ?> |
|---|
| 1173 | <?php if ( $group_ids['groups'] ) { ?> |
|---|
| 1174 | <ul class="item-list" id="random-groups-list"> |
|---|
| 1175 | <?php for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) { ?> |
|---|
| 1176 | <?php $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false ); ?> |
|---|
| 1177 | <li> |
|---|
| 1178 | <div class="item-avatar"> |
|---|
| 1179 | <a href="<?php echo bp_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" /></a> |
|---|
| 1180 | </div> |
|---|
| 1181 | |
|---|
| 1182 | <div class="item"> |
|---|
| 1183 | <div class="item-title"><a href="<?php echo bp_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div> |
|---|
| 1184 | <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __('active %s ago', 'buddypress') ) ?></span></div> |
|---|
| 1185 | <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div> |
|---|
| 1186 | </div> |
|---|
| 1187 | |
|---|
| 1188 | <div class="action"> |
|---|
| 1189 | <?php bp_group_join_button( $group ) ?> |
|---|
| 1190 | <div class="meta"> |
|---|
| 1191 | <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?> |
|---|
| 1192 | <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> / |
|---|
| 1193 | <?php if ( $member_count == 1 ) : ?> |
|---|
| 1194 | <?php _e( sprintf( '%d member', $member_count ), 'buddypress' ) ?> |
|---|
| 1195 | <?php else : ?> |
|---|
| 1196 | <?php _e( sprintf( '%d members', $member_count ), 'buddypress' ) ?> |
|---|
| 1197 | <?php endif; ?> |
|---|
| 1198 | </div> |
|---|
| 1199 | </div> |
|---|
| 1200 | |
|---|
| 1201 | <div class="clear"></div> |
|---|
| 1202 | </li> |
|---|
| 1203 | <?php } ?> |
|---|
| 1204 | </ul> |
|---|
| 1205 | <?php } else { ?> |
|---|
| 1206 | <div id="message" class="info"> |
|---|
| 1207 | <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p> |
|---|
| 1208 | </div> |
|---|
| 1209 | <?php } ?> |
|---|
| 1210 | <?php |
|---|
| 1211 | } |
|---|
| 1212 | |
|---|
| 1213 | function bp_groups_random_groups() { |
|---|
| 1214 | global $bp; |
|---|
| 1215 | |
|---|
| 1216 | $group_ids = BP_Groups_Member::get_random_groups( $bp['current_userid'] ); |
|---|
| 1217 | ?> |
|---|
| 1218 | <div class="info-group"> |
|---|
| 1219 | <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] ?>"><?php _e('See All', 'buddypress') ?> »</a></h4> |
|---|
| 1220 | <?php if ( $group_ids ) { ?> |
|---|
| 1221 | <ul class="horiz-gallery"> |
|---|
| 1222 | <?php for ( $i = 0; $i < count( $group_ids ); $i++ ) { ?> |
|---|
| 1223 | <?php $group = new BP_Groups_Group( $group_ids[$i], false, false ); ?> |
|---|
| 1224 | <li> |
|---|
| 1225 | <a href="<?php echo bp_group_permalink( $group, false ) ?>"><img src="<?php echo $group->avatar_thumb; ?>" class="avatar" alt="Group Avatar" /></a> |
|---|
| 1226 | <h5><a href="<?php echo bp_group_permalink( $group, false ) ?>"><?php echo $group->name ?></a></h5> |
|---|
| 1227 | </li> |
|---|
| 1228 | <?php } ?> |
|---|
| 1229 | </ul> |
|---|
| 1230 | <?php } else { ?> |
|---|
| 1231 | <div id="message" class="info"> |
|---|
| 1232 | <p><?php bp_word_or_name( __( "You haven't joined any groups yet.", 'buddypress' ), __( "%s hasn't joined any groups yet.", 'buddypress' ) ) ?></p> |
|---|
| 1233 | </div> |
|---|
| 1234 | <?php } ?> |
|---|
| 1235 | <div class="clear"></div> |
|---|
| 1236 | </div> |
|---|
| 1237 | <?php |
|---|
| 1238 | } |
|---|
| 1239 | |
|---|
| 1240 | function bp_custom_group_boxes() { |
|---|
| 1241 | do_action( 'groups_custom_group_boxes' ); |
|---|
| 1242 | } |
|---|
| 1243 | |
|---|
| 1244 | function bp_custom_group_admin_tabs() { |
|---|
| 1245 | do_action( 'groups_custom_group_admin_tabs' ); |
|---|
| 1246 | } |
|---|
| 1247 | |
|---|
| 1248 | function bp_custom_group_fields_editable() { |
|---|
| 1249 | do_action( 'groups_custom_group_fields_editable' ); |
|---|
| 1250 | } |
|---|
| 1251 | |
|---|
| 1252 | function bp_custom_group_fields() { |
|---|
| 1253 | do_action( 'groups_custom_group_fields' ); |
|---|
| 1254 | } |
|---|
| 1255 | |
|---|
| 1256 | /**** |
|---|
| 1257 | * Group Members Template Tags |
|---|
| 1258 | **/ |
|---|
| 1259 | |
|---|
| 1260 | class BP_Groups_Group_Members_Template { |
|---|
| 1261 | var $current_member = -1; |
|---|
| 1262 | var $member_count; |
|---|
| 1263 | var $members; |
|---|
| 1264 | var $member; |
|---|
| 1265 | |
|---|
| 1266 | var $in_the_loop; |
|---|
| 1267 | |
|---|
| 1268 | var $pag_page; |
|---|
| 1269 | var $pag_num; |
|---|
| 1270 | var $pag_links; |
|---|
| 1271 | var $total_member_count; |
|---|
| 1272 | |
|---|
| 1273 | function bp_groups_group_members_template( $group_id, $num_per_page, $exclude_admins_mods, $exclude_banned ) { |
|---|
| 1274 | global $bp; |
|---|
| 1275 | |
|---|
| 1276 | $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; |
|---|
| 1277 | $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $num_per_page; |
|---|
| 1278 | |
|---|
| 1279 | $members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned ); |
|---|
| 1280 | |
|---|
| 1281 | $this->total_member_count = $members['count']; |
|---|
| 1282 | $this->members = $members['members']; |
|---|
| 1283 | |
|---|
| 1284 | $this->member_count = count($this->members); |
|---|
| 1285 | |
|---|
| 1286 | $this->pag_links = paginate_links( array( |
|---|
| 1287 | 'base' => add_query_arg( 'mlpage', '%#%' ), |
|---|
| 1288 | 'format' => '', |
|---|
| 1289 | 'total' => ceil( $this->total_member_count / $this->pag_num ), |
|---|
| 1290 | 'current' => $this->pag_page, |
|---|
| 1291 | 'prev_text' => '«', |
|---|
| 1292 | 'next_text' => '»', |
|---|
| 1293 | 'mid_size' => 1 |
|---|
| 1294 | )); |
|---|
| 1295 | |
|---|
| 1296 | } |
|---|
| 1297 | |
|---|
| 1298 | function has_members() { |
|---|
| 1299 | if ( $this->member_count ) |
|---|
| 1300 | return true; |
|---|
| 1301 | |
|---|
| 1302 | return false; |
|---|
| 1303 | } |
|---|
| 1304 | |
|---|
| 1305 | function next_member() { |
|---|
| 1306 | $this->current_member++; |
|---|
| 1307 | $this->member = $this->members[$this->current_member]; |
|---|
| 1308 | |
|---|
| 1309 | return $this->member; |
|---|
| 1310 | } |
|---|
| 1311 | |
|---|
| 1312 | function rewind_members() { |
|---|
| 1313 | $this->current_member = -1; |
|---|
| 1314 | if ( $this->member_count > 0 ) { |
|---|
| 1315 | $this->member = $this->members[0]; |
|---|
| 1316 | } |
|---|
| 1317 | } |
|---|
| 1318 | |
|---|
| 1319 | function members() { |
|---|
| 1320 | if ( $this->current_member + 1 < $this->member_count ) { |
|---|
| 1321 | return true; |
|---|
| 1322 | } elseif ( $this->current_member + 1 == $this->member_count ) { |
|---|
| 1323 | do_action('loop_end'); |
|---|
| 1324 | // Do some cleaning up after the loop |
|---|
| 1325 | $this->rewind_members(); |
|---|
| 1326 | } |
|---|
| 1327 | |
|---|
| 1328 | $this->in_the_loop = false; |
|---|
| 1329 | return false; |
|---|
| 1330 | } |
|---|
| 1331 | |
|---|
| 1332 | function the_member() { |
|---|
| 1333 | global $member; |
|---|
| 1334 | |
|---|
| 1335 | $this->in_the_loop = true; |
|---|
| 1336 | $this->member = $this->next_member(); |
|---|
| 1337 | |
|---|
| 1338 | if ( $this->current_member == 0 ) // loop has just started |
|---|
| 1339 | do_action('loop_start'); |
|---|
| 1340 | } |
|---|
| 1341 | } |
|---|
| 1342 | |
|---|
| 1343 | function bp_group_has_members( $group_id = false, $num_per_page = 10, $exclude_admins_mods = true, $exclude_banned = true ) { |
|---|
| 1344 | global $members_template, $groups_template; |
|---|
| 1345 | |
|---|
| 1346 | if ( !$groups_template ) |
|---|
| 1347 | $groups_template->group = new BP_Groups_Group( $group_id ); |
|---|
| 1348 | |
|---|
| 1349 | $members_template = new BP_Groups_Group_Members_Template( $groups_template->group->id, $num_per_page, $exclude_admins_mods, $exclude_banned ); |
|---|
| 1350 | |
|---|
| 1351 | return $members_template->has_members(); |
|---|
| 1352 | } |
|---|
| 1353 | |
|---|
| 1354 | function bp_group_members() { |
|---|
| 1355 | global $members_template; |
|---|
| 1356 | |
|---|
| 1357 | return $members_template->members(); |
|---|
| 1358 | } |
|---|
| 1359 | |
|---|
| 1360 | function bp_group_the_member() { |
|---|
| 1361 | global $members_template; |
|---|
| 1362 | |
|---|
| 1363 | return $members_template->the_member(); |
|---|
| 1364 | } |
|---|
| 1365 | |
|---|
| 1366 | function bp_group_member_avatar() { |
|---|
| 1367 | global $members_template; |
|---|
| 1368 | |
|---|
| 1369 | echo apply_filters( 'bp_group_member_avatar', bp_core_get_avatar( $members_template->member->user_id, 1 ) ); |
|---|
| 1370 | } |
|---|
| 1371 | |
|---|
| 1372 | function bp_group_member_avatar_mini( $width = 30, $height = 30 ) { |
|---|
| 1373 | global $members_template; |
|---|
| 1374 | |
|---|
| 1375 | echo apply_filters( 'bp_group_member_avatar_mini', bp_core_get_avatar( $members_template->member->user_id, 1, $width, $height ) ); |
|---|
| 1376 | } |
|---|
| 1377 | |
|---|
| 1378 | function bp_group_member_link() { |
|---|
| 1379 | global $members_template; |
|---|
| 1380 | |
|---|
| 1381 | echo apply_filters( 'bp_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) ); |
|---|
| 1382 | } |
|---|
| 1383 | |
|---|
| 1384 | function bp_group_member_is_banned() { |
|---|
| 1385 | global $members_template, $groups_template; |
|---|
| 1386 | |
|---|
| 1387 | return apply_filters( 'bp_group_member_is_banned', groups_is_user_banned( $members_template->member->user_id, $groups_template->group->id ) ); |
|---|
| 1388 | } |
|---|
| 1389 | |
|---|
| 1390 | function bp_group_member_joined_since() { |
|---|
| 1391 | global $members_template; |
|---|
| 1392 | |
|---|
| 1393 | echo apply_filters( 'bp_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) ); |
|---|
| 1394 | } |
|---|
| 1395 | |
|---|
| 1396 | function bp_group_member_id() { |
|---|
| 1397 | global $members_template; |
|---|
| 1398 | return apply_filters( 'bp_group_member_id', $members_template->member->user_id ); |
|---|
| 1399 | } |
|---|
| 1400 | |
|---|
| 1401 | function bp_group_member_needs_pagination() { |
|---|
| 1402 | global $members_template; |
|---|
| 1403 | |
|---|
| 1404 | if ( $members_template->total_member_count > $members_template->pag_num ) |
|---|
| 1405 | return true; |
|---|
| 1406 | |
|---|
| 1407 | return false; |
|---|
| 1408 | } |
|---|
| 1409 | |
|---|
| 1410 | function bp_group_pag_id() { |
|---|
| 1411 | global $bp; |
|---|
| 1412 | |
|---|
| 1413 | if ( $bp['current_action'] == 'group-finder' ) |
|---|
| 1414 | echo apply_filters( 'bp_group_reject_invite_link', 'groupfinder-pag' ); |
|---|
| 1415 | else |
|---|
| 1416 | echo apply_filters( 'bp_group_reject_invite_link', 'pag' ); |
|---|
| 1417 | } |
|---|
| 1418 | |
|---|
| 1419 | |
|---|
| 1420 | function bp_group_member_pagination() { |
|---|
| 1421 | global $members_template; |
|---|
| 1422 | echo $members_template->pag_links; |
|---|
| 1423 | wp_nonce_field( 'bp_groups_member_list', '_member_pag_nonce' ); |
|---|
| 1424 | } |
|---|
| 1425 | |
|---|
| 1426 | function bp_group_member_pagination_count() { |
|---|
| 1427 | global $members_template; |
|---|
| 1428 | |
|---|
| 1429 | $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; |
|---|
| 1430 | $to_num = ( $from_num + 4 > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + 4; |
|---|
| 1431 | |
|---|
| 1432 | echo apply_filters( 'bp_group_reject_invite_link', sprintf( __( 'Viewing members %d to %d (%d total members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) ); |
|---|
| 1433 | } |
|---|
| 1434 | |
|---|
| 1435 | function bp_group_member_admin_pagination() { |
|---|
| 1436 | global $members_template; |
|---|
| 1437 | echo $members_template->pag_links; |
|---|
| 1438 | wp_nonce_field( 'bp_groups_member_admin_list', '_member_admin_pag_nonce' ); |
|---|
| 1439 | } |
|---|
| 1440 | |
|---|
| 1441 | |
|---|
| 1442 | /**** |
|---|
| 1443 | * Membership Requests Template Tags |
|---|
| 1444 | **/ |
|---|
| 1445 | |
|---|
| 1446 | class BP_Groups_Membership_Requests_Template { |
|---|
| 1447 | var $current_request = -1; |
|---|
| 1448 | var $request_count; |
|---|
| 1449 | var $requests; |
|---|
| 1450 | var $request; |
|---|
| 1451 | |
|---|
| 1452 | var $in_the_loop; |
|---|
| 1453 | |
|---|
| 1454 | var $pag_page; |
|---|
| 1455 | var $pag_num; |
|---|
| 1456 | var $pag_links; |
|---|
| 1457 | var $total_request_count; |
|---|
| 1458 | |
|---|
| 1459 | function bp_groups_membership_requests_template( $group_id, $num_per_page ) { |
|---|
| 1460 | global $bp; |
|---|
| 1461 | |
|---|
| 1462 | $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1; |
|---|
| 1463 | $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $num_per_page; |
|---|
| 1464 | |
|---|
| 1465 | $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); |
|---|
| 1466 | |
|---|
| 1467 | $this->total_request_count = $this->requests['total']; |
|---|
| 1468 | $this->requests = $this->requests['requests']; |
|---|
| 1469 | $this->request_count = count($this->requests); |
|---|
| 1470 | |
|---|
| 1471 | $this->pag_links = paginate_links( array( |
|---|
| 1472 | 'base' => add_query_arg( 'mrpage', '%#%' ), |
|---|
| 1473 | 'format' => '', |
|---|
| 1474 | 'total' => ceil( $this->total_request_count / $this->pag_num ), |
|---|
| 1475 | 'current' => $this->pag_page, |
|---|
| 1476 | 'prev_text' => '«', |
|---|
| 1477 | 'next_text' => '»', |
|---|
| 1478 | 'mid_size' => 1 |
|---|
| 1479 | )); |
|---|
| 1480 | |
|---|
| 1481 | } |
|---|
| 1482 | |
|---|
| 1483 | function has_requests() { |
|---|
| 1484 | if ( $this->request_count ) |
|---|
| 1485 | return true; |
|---|
| 1486 | |
|---|
| 1487 | return false; |
|---|
| 1488 | } |
|---|
| 1489 | |
|---|
| 1490 | function next_request() { |
|---|
| 1491 | $this->current_request++; |
|---|
| 1492 | $this->request = $this->requests[$this->current_request]; |
|---|
| 1493 | |
|---|
| 1494 | return $this->request; |
|---|
| 1495 | } |
|---|
| 1496 | |
|---|
| 1497 | function rewind_requests() { |
|---|
| 1498 | $this->current_request = -1; |
|---|
| 1499 | if ( $this->request_count > 0 ) { |
|---|
| 1500 | $this->request = $this->requests[0]; |
|---|
| 1501 | } |
|---|
| 1502 | } |
|---|
| 1503 | |
|---|
| 1504 | function requests() { |
|---|
| 1505 | if ( $this->current_request + 1 < $this->request_count ) { |
|---|
| 1506 | return true; |
|---|
| 1507 | } elseif ( $this->current_request + 1 == $this->request_count ) { |
|---|
| 1508 | do_action('loop_end'); |
|---|
| 1509 | // Do some cleaning up after the loop |
|---|
| 1510 | $this->rewind_requests(); |
|---|
| 1511 | } |
|---|
| 1512 | |
|---|
| 1513 | $this->in_the_loop = false; |
|---|
| 1514 | return false; |
|---|
| 1515 | } |
|---|
| 1516 | |
|---|
| 1517 | function the_request() { |
|---|
| 1518 | global $request; |
|---|
| 1519 | |
|---|
| 1520 | $this->in_the_loop = true; |
|---|
| 1521 | $this->request = $this->next_request(); |
|---|
| 1522 | |
|---|
| 1523 | if ( $this->current_request == 0 ) // loop has just started |
|---|
| 1524 | do_action('loop_start'); |
|---|
| 1525 | } |
|---|
| 1526 | } |
|---|
| 1527 | |
|---|
| 1528 | function bp_group_has_membership_requests( $num_per_page = 10 ) { |
|---|
| 1529 | global $requests_template, $groups_template; |
|---|
| 1530 | |
|---|
| 1531 | $requests_template = new BP_Groups_Membership_Requests_Template( $groups_template->group->id, $num_per_page ); |
|---|
| 1532 | |
|---|
| 1533 | return $requests_template->has_requests(); |
|---|
| 1534 | } |
|---|
| 1535 | |
|---|
| 1536 | function bp_group_membership_requests() { |
|---|
| 1537 | global $requests_template; |
|---|
| 1538 | |
|---|
| 1539 | return $requests_template->requests(); |
|---|
| 1540 | } |
|---|
| 1541 | |
|---|
| 1542 | function bp_group_the_membership_request() { |
|---|
| 1543 | global $requests_template; |
|---|
| 1544 | |
|---|
| 1545 | return $requests_template->the_request(); |
|---|
| 1546 | } |
|---|
| 1547 | |
|---|
| 1548 | function bp_group_request_user_avatar_thumb() { |
|---|
| 1549 | global $requests_template; |
|---|
| 1550 | |
|---|
| 1551 | echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_get_avatar( $requests_template->request->user_id, 1 ) ); |
|---|
| 1552 | } |
|---|
| 1553 | |
|---|
| 1554 | function bp_group_request_reject_link() { |
|---|
| 1555 | global $requests_template, $groups_template; |
|---|
| 1556 | |
|---|
| 1557 | echo apply_filters( 'bp_group_request_reject_link', bp_group_permalink( $groups_template->group, false ) . '/admin/membership-requests/reject/' . $requests_template->request->id ); |
|---|
| 1558 | } |
|---|
| 1559 | |
|---|
| 1560 | function bp_group_request_accept_link() { |
|---|
| 1561 | global $requests_template, $groups_template; |
|---|
| 1562 | |
|---|
| 1563 | echo apply_filters( 'bp_group_request_accept_link', bp_group_permalink( $groups_template->group, false ) . '/admin/membership-requests/accept/' . $requests_template->request->id ); |
|---|
| 1564 | } |
|---|
| 1565 | |
|---|
| 1566 | function bp_group_request_time_since_requested() { |
|---|
| 1567 | global $requests_template; |
|---|
| 1568 | |
|---|
| 1569 | echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) ); |
|---|
| 1570 | } |
|---|
| 1571 | |
|---|
| 1572 | function bp_group_request_comment() { |
|---|
| 1573 | global $requests_template; |
|---|
| 1574 | |
|---|
| 1575 | echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) ); |
|---|
| 1576 | } |
|---|
| 1577 | |
|---|
| 1578 | function bp_group_request_user_link() { |
|---|
| 1579 | global $requests_template; |
|---|
| 1580 | |
|---|
| 1581 | echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) ); |
|---|
| 1582 | } |
|---|
| 1583 | |
|---|
| 1584 | ?> |
|---|