my_status.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Group status for logged in user
  4. *
  5. * @package ElggGroups
  6. *
  7. * @uses $vars["entity"] Group entity
  8. */
  9. $group = elgg_extract("entity", $vars);
  10. $user = elgg_get_logged_in_user_entity();
  11. $subscribed = elgg_extract("subscribed", $vars);
  12. if (!elgg_is_logged_in()) {
  13. return true;
  14. }
  15. if (!empty($group) && elgg_instanceof($group, "group")) {
  16. if ($group->getPrivateSetting("group_tools:cleanup:my_status") != "yes") {
  17. // membership status
  18. $is_member = $group->isMember($user);
  19. $is_owner = $group->getOwnerEntity() == $user;
  20. if ($is_owner) {
  21. elgg_register_menu_item("groups:my_status", array(
  22. "name" => "membership_status",
  23. "text" => elgg_echo("groups:my_status:group_owner"),
  24. "href" => "#"
  25. ));
  26. } elseif ($is_member) {
  27. elgg_register_menu_item("groups:my_status", array(
  28. "name" => "membership_status",
  29. "text" => elgg_echo("groups:my_status:group_member"),
  30. "href" => "#"
  31. ));
  32. } else {
  33. if ($group->getPrivateSetting("group_tools:cleanup:actions") != "yes") {
  34. elgg_register_menu_item("groups:my_status", array(
  35. "name" => "membership_status",
  36. "text" => elgg_echo("groups:join"),
  37. "href" => "action/groups/join?group_guid=" . $group->getGUID(),
  38. "is_action" => true
  39. ));
  40. }
  41. }
  42. // notification info
  43. if (elgg_is_active_plugin("notifications") && $is_member) {
  44. if ($subscribed) {
  45. elgg_register_menu_item("groups:my_status", array(
  46. "name" => "subscription_status",
  47. "text" => elgg_echo("groups:subscribed"),
  48. "href" => "notifications/group/$user->username",
  49. ));
  50. } else {
  51. elgg_register_menu_item("groups:my_status", array(
  52. "name" => "subscription_status",
  53. "text" => elgg_echo("groups:unsubscribed"),
  54. "href" => "notifications/group/$user->username"
  55. ));
  56. }
  57. }
  58. $body = elgg_view_menu("groups:my_status");
  59. if (!empty($body)) {
  60. echo elgg_view_module("aside", elgg_echo("groups:my_status"), $body);
  61. }
  62. }
  63. }