access.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * Group edit form
  4. *
  5. * This view contains everything related to group access.
  6. * eg: how can people join this group, who can see the group, etc
  7. *
  8. * @package ElggGroups
  9. */
  10. $entity = elgg_extract("entity", $vars, false);
  11. $membership = elgg_extract("membership", $vars);
  12. $visibility = elgg_extract("vis", $vars);
  13. $owner_guid = elgg_extract("owner_guid", $vars);
  14. $content_access_mode = elgg_extract("content_access_mode", $vars);
  15. $default_access = elgg_extract("group_default_access", $vars, ACCESS_DEFAULT);
  16. ?>
  17. <div>
  18. <label for="groups-membership"><?php echo elgg_echo("groups:membership"); ?></label><br />
  19. <?php echo elgg_view("input/select", array(
  20. "name" => "membership",
  21. "id" => "groups-membership",
  22. "value" => $membership,
  23. "options_values" => array(
  24. ACCESS_PRIVATE => elgg_echo("groups:access:private"),
  25. ACCESS_PUBLIC => elgg_echo("groups:access:public"),
  26. )
  27. ));
  28. ?>
  29. </div>
  30. <?php if (elgg_get_plugin_setting("hidden_groups", "groups") == "yes") { ?>
  31. <div>
  32. <label for="groups-vis"><?php echo elgg_echo("groups:visibility"); ?></label><br />
  33. <?php
  34. $vis_options = array(
  35. ACCESS_PRIVATE => elgg_echo("groups:access:group"),
  36. ACCESS_LOGGED_IN => elgg_echo("LOGGED_IN"),
  37. ACCESS_PUBLIC => elgg_echo("PUBLIC"),
  38. );
  39. if (elgg_get_config("walled_garden")) {
  40. unset($vis_options[ACCESS_PUBLIC]);
  41. if ($visibility == ACCESS_PUBLIC) {
  42. $visibility = ACCESS_LOGGED_IN;
  43. }
  44. }
  45. echo elgg_view("input/access", array(
  46. "name" => "vis",
  47. "id" => "groups-vis",
  48. "value" => $visibility,
  49. "options_values" => $vis_options
  50. ));
  51. ?>
  52. </div>
  53. <?php }
  54. $access_mode_params = array(
  55. "name" => "content_access_mode",
  56. "id" => "groups-content-access-mode",
  57. "value" => $content_access_mode,
  58. "options_values" => array(
  59. ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED => elgg_echo("groups:content_access_mode:unrestricted"),
  60. ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY => elgg_echo("groups:content_access_mode:membersonly"),
  61. )
  62. );
  63. if ($entity) {
  64. // Disable content_access_mode field for hidden groups because the setting
  65. // will be forced to members_only regardless of the entered value
  66. if ($entity->access_id === $entity->group_acl) {
  67. $access_mode_params['disabled'] = 'disabled';
  68. }
  69. }
  70. ?>
  71. <div>
  72. <label for="groups-content-access-mode"><?php echo elgg_echo("groups:content_access_mode"); ?></label><br />
  73. <?php
  74. echo elgg_view("input/select", $access_mode_params);
  75. if ($entity && $entity->getContentAccessMode() == ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED) {
  76. // Warn the user that changing the content access mode to more
  77. // restrictive will not affect the existing group content
  78. $access_mode_warning = elgg_echo("groups:content_access_mode:warning");
  79. echo "<span class='elgg-text-help'>$access_mode_warning</span>";
  80. }
  81. ?>
  82. </div>
  83. <?php
  84. // default group access
  85. if ($entity && ($default_access === ACCESS_DEFAULT)) {
  86. $new_default_access = $entity->getPrivateSetting("elgg_default_access");
  87. if ($new_default_access !== null) {
  88. $default_access = (int) $new_default_access;
  89. }
  90. }
  91. ?>
  92. <div>
  93. <label for="groups-default-access"><?php echo elgg_echo("group_tools:default_access:title"); ?></label><br />
  94. <?php
  95. // make sure the full list can be shown
  96. $ga = false;
  97. if ($entity) {
  98. $ga = $entity->getContentAccessMode();
  99. $entity->setContentAccessMode(ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED);
  100. }
  101. echo elgg_view("input/access", array("name" => "group_default_access", "value" => $default_access, "id" => "groups-default-access", "class" => "mtn"));
  102. if ($ga !== false) {
  103. $entity->setContentAccessMode($ga);
  104. }
  105. echo "<span class='elgg-text-help'>" . elgg_echo("group_tools:default_access:description") . "</span>";
  106. ?>
  107. </div>
  108. <?php
  109. // transfer owner
  110. if ($entity) {
  111. // who can transfer
  112. $admin_transfer = elgg_get_plugin_setting("admin_transfer", "group_tools");
  113. $transfer_allowed = false;
  114. if (($admin_transfer == "admin") && elgg_is_admin_logged_in()) {
  115. $transfer_allowed = true;
  116. } elseif (($admin_transfer == "owner") && (($entity->getOwnerGUID() == elgg_get_logged_in_user_guid()) || elgg_is_admin_logged_in())) {
  117. $transfer_allowed = true;
  118. }
  119. if ($transfer_allowed) {
  120. echo elgg_view("group_tools/forms/admin_transfer", array("entity" => $entity));
  121. }
  122. }