| @@ 521-569 (lines=49) @@ | ||
| 518 | * |
|
| 519 | * @param ElggGroup $group |
|
| 520 | */ |
|
| 521 | function groups_register_profile_buttons($group) { |
|
| 522 | ||
| 523 | $actions = array(); |
|
| 524 | ||
| 525 | // group owners |
|
| 526 | if ($group->canEdit()) { |
|
| 527 | // edit and invite |
|
| 528 | $url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}"; |
|
| 529 | $actions[$url] = 'groups:edit'; |
|
| 530 | $url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}"; |
|
| 531 | $actions[$url] = 'groups:invite'; |
|
| 532 | } |
|
| 533 | ||
| 534 | // group members |
|
| 535 | if ($group->isMember(elgg_get_logged_in_user_entity())) { |
|
| 536 | if ($group->getOwnerGUID() != elgg_get_logged_in_user_guid()) { |
|
| 537 | // leave |
|
| 538 | $url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}"; |
|
| 539 | $url = elgg_add_action_tokens_to_url($url); |
|
| 540 | $actions[$url] = 'groups:leave'; |
|
| 541 | } |
|
| 542 | ||
| 543 | if( strpos(elgg_get_site_entity()->name, 'collab') !== false ){ |
|
| 544 | $url = elgg_get_site_url() . "groups/stats/{$group->getGUID()}"; |
|
| 545 | $actions[$url] = 'groups:stats'; |
|
| 546 | } |
|
| 547 | } elseif (elgg_is_logged_in()) { |
|
| 548 | // join - admins can always join. |
|
| 549 | $url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}"; |
|
| 550 | $url = elgg_add_action_tokens_to_url($url); |
|
| 551 | if ($group->isPublicMembership() || $group->canEdit()) { |
|
| 552 | $actions[$url] = 'groups:join'; |
|
| 553 | } else { |
|
| 554 | // request membership |
|
| 555 | $actions[$url] = 'groups:joinrequest'; |
|
| 556 | } |
|
| 557 | } |
|
| 558 | ||
| 559 | if ($actions) { |
|
| 560 | foreach ($actions as $url => $text) { |
|
| 561 | elgg_register_menu_item('title', array( |
|
| 562 | 'name' => $text, |
|
| 563 | 'href' => $url, |
|
| 564 | 'text' => elgg_echo($text), |
|
| 565 | 'link_class' => 'elgg-button elgg-button-action', |
|
| 566 | )); |
|
| 567 | } |
|
| 568 | } |
|
| 569 | } |
|
| 570 | ||
| 571 | /** |
|
| 572 | * Prepares variables for the group edit form view. |
|
| @@ 542-591 (lines=50) @@ | ||
| 539 | * |
|
| 540 | * @param ElggGroup $group |
|
| 541 | */ |
|
| 542 | function groups_register_profile_buttons($group) { |
|
| 543 | ||
| 544 | $actions = array(); |
|
| 545 | ||
| 546 | // group owners |
|
| 547 | if ($group->canEdit()) { |
|
| 548 | // edit and invite |
|
| 549 | $url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}"; |
|
| 550 | $actions[$url] = 'groups:edit'; |
|
| 551 | $url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}"; |
|
| 552 | $actions[$url] = 'groups:invite'; |
|
| 553 | } |
|
| 554 | ||
| 555 | // group members |
|
| 556 | if ($group->isMember(elgg_get_logged_in_user_entity())) { |
|
| 557 | if ($group->getOwnerGUID() != elgg_get_logged_in_user_guid()) { |
|
| 558 | // leave |
|
| 559 | $url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}"; |
|
| 560 | $url = elgg_add_action_tokens_to_url($url); |
|
| 561 | $actions[$url] = 'groups:leave'; |
|
| 562 | } |
|
| 563 | ||
| 564 | if( strpos(elgg_get_site_entity()->name, 'collab') !== false ){ |
|
| 565 | $url = elgg_get_site_url() . "groups/stats/{$group->getGUID()}"; |
|
| 566 | $actions[$url] = 'groups:stats'; |
|
| 567 | } |
|
| 568 | } elseif (elgg_is_logged_in()) { |
|
| 569 | // join - admins can always join. |
|
| 570 | $url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}"; |
|
| 571 | $url = elgg_add_action_tokens_to_url($url); |
|
| 572 | if ($group->isPublicMembership() || $group->canEdit()) { |
|
| 573 | $actions[$url] = 'groups:join'; |
|
| 574 | } else { |
|
| 575 | // request membership |
|
| 576 | $actions[$url] = 'groups:joinrequest'; |
|
| 577 | } |
|
| 578 | } |
|
| 579 | ||
| 580 | if ($actions) { |
|
| 581 | foreach ($actions as $url => $text) { |
|
| 582 | elgg_register_menu_item('group_ddb', array( |
|
| 583 | 'name' => $text, |
|
| 584 | 'href' => $url, |
|
| 585 | 'text' => elgg_echo($text), |
|
| 586 | 'link_class' => 'elgg-button elgg-button-action', |
|
| 587 | )); |
|
| 588 | } |
|
| 589 | } |
|
| 590 | ||
| 591 | } |
|
| 592 | ||
| 593 | /** |
|
| 594 | * Prepares variables for the group edit form view. |
|