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