invitationrequests.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /**
  3. * A user"s group invitations
  4. *
  5. * @uses $vars["invitations"] Array of ElggGroups
  6. */
  7. $user = elgg_extract("user", $vars);
  8. $invitations = elgg_extract("invitations", $vars);
  9. $email_invites = elgg_extract("email_invitations", $vars, false);
  10. if ((!empty($invitations) && is_array($invitations)) || (!empty($email_invites) && is_array($email_invites))) {
  11. echo "<ul class='elgg-list mbm'>";
  12. // normal invites
  13. if (!empty($invitations)) {
  14. foreach ($invitations as $group) {
  15. if ($group instanceof ElggGroup) {
  16. $icon = elgg_view_entity_icon($group, "tiny", array("use_hover" => "true"));
  17. $group_title = elgg_view("output/url", array(
  18. "href" => $group->getURL(),
  19. "text" => $group->name,
  20. "is_trusted" => true,
  21. ));
  22. $url = "action/groups/join?user_guid=" . $user->getGUID() . "&group_guid=" . $group->getGUID();
  23. $accept_button = elgg_view("output/url", array(
  24. "href" => $url,
  25. "text" => elgg_echo("accept"),
  26. "class" => "elgg-button elgg-button-submit",
  27. "is_trusted" => true,
  28. "is_action" => true
  29. ));
  30. $url = "action/groups/killinvitation?user_guid=" . $user->getGUID() . "&group_guid=" . $group->getGUID();
  31. $delete_button = elgg_view("output/url", array(
  32. "href" => $url,
  33. "confirm" => elgg_echo("groups:invite:remove:check"),
  34. "text" => elgg_echo("delete"),
  35. "class" => "elgg-button elgg-button-delete mlm",
  36. ));
  37. $body = "<h4>$group_title</h4>";
  38. $body .= "<p class='elgg-subtext'>$group->briefdescription</p>";
  39. $alt = $accept_button . $delete_button;
  40. echo "<li class='pvs'>";
  41. echo elgg_view_image_block($icon, $body, array("image_alt" => $alt));
  42. echo "</li>";
  43. }
  44. }
  45. }
  46. // auto detected email invitations
  47. if (!empty($email_invites)) {
  48. foreach ($email_invites as $group) {
  49. $icon = elgg_view_entity_icon($group, "tiny", array("use_hover" => "true"));
  50. $group_title = elgg_view("output/url", array(
  51. "href" => $group->getURL(),
  52. "text" => $group->name,
  53. "is_trusted" => true,
  54. ));
  55. $url = "action/groups/email_invitation?invitecode=" . group_tools_generate_email_invite_code($group->getGUID(), $user->email);
  56. $accept_button = elgg_view("output/url", array(
  57. "href" => $url,
  58. "text" => elgg_echo("accept"),
  59. "class" => "elgg-button elgg-button-submit",
  60. "is_trusted" => true,
  61. "is_action" => true
  62. ));
  63. $url = "action/groups/decline_email_invitation?invitecode=" . group_tools_generate_email_invite_code($group->getGUID(), $user->email);
  64. $delete_button = elgg_view("output/url", array(
  65. "href" => $url,
  66. "confirm" => elgg_echo("groups:invite:remove:check"),
  67. "text" => elgg_echo("delete"),
  68. "class" => "elgg-button elgg-button-delete mlm",
  69. ));
  70. $body = "<h4>$group_title</h4>";
  71. $body .= "<p class='elgg-subtext'>$group->briefdescription</p>";
  72. $alt = $accept_button . $delete_button;
  73. echo "<li class='pvs'>";
  74. echo elgg_view_image_block($icon, $body, array("image_alt" => $alt));
  75. echo "</li>";
  76. }
  77. }
  78. echo "</ul>";
  79. } else {
  80. echo "<p class='mtm'>" . elgg_echo("groups:invitations:none") . "</p>";
  81. }
  82. // list membership requests
  83. if (elgg_get_context() == "groups") {
  84. // get requests
  85. $requests = elgg_extract("requests", $vars);
  86. $title = elgg_echo("group_tools:group:invitations:request");
  87. if (!empty($requests) && is_array($requests)) {
  88. $content = "<ul class='elgg-list'>";
  89. foreach ($requests as $group) {
  90. $icon = elgg_view_entity_icon($group, "tiny", array("use_hover" => "true"));
  91. $group_title = elgg_view("output/url", array(
  92. "href" => $group->getURL(),
  93. "text" => $group->name,
  94. "is_trusted" => true,
  95. ));
  96. $url = "action/groups/killrequest?user_guid=" . $user->getGUID() . "&group_guid=" . $group->getGUID();
  97. $delete_button = elgg_view("output/url", array(
  98. "href" => $url,
  99. "confirm" => elgg_echo("group_tools:group:invitations:request:revoke:confirm"),
  100. "text" => elgg_echo("group_tools:revoke"),
  101. "class" => "elgg-button elgg-button-delete mlm",
  102. ));
  103. $body = "<h4>$group_title</h4>";
  104. $body .= "<p class='elgg-subtext'>$group->briefdescription</p>";
  105. $alt = $delete_button;
  106. $content .= "<li class='pvs'>";
  107. $content .= elgg_view_image_block($icon, $body, array("image_alt" => $alt));
  108. $content .= "</li>";
  109. }
  110. $content .= "</ul>";
  111. } else {
  112. $content = elgg_echo("group_tools:group:invitations:request:non_found");
  113. }
  114. echo elgg_view_module("info", $title, $content);
  115. // show e-mail invitation form
  116. if (elgg_extract("invite_email", $vars, false)) {
  117. // make the form for the email invitations
  118. $form_body = "<div>" . elgg_echo("group_tools:groups:invitation:code:description") . "</div>";
  119. $form_body .= elgg_view("input/text", array(
  120. "name" => "invitecode",
  121. "value" => get_input("invitecode"),
  122. "class" => "mbm"
  123. ));
  124. $form_body .= "<div>";
  125. $form_body .= elgg_view("input/submit", array("value" => elgg_echo("submit")));
  126. $form_body .= "</div>";
  127. $form = elgg_view("input/form", array(
  128. "body" => $form_body,
  129. "action" => "action/groups/email_invitation"
  130. ));
  131. echo elgg_view_module("info", elgg_echo("group_tools:groups:invitation:code:title"), $form);
  132. }
  133. }