]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
trying to make support for invisible groups a little saner
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Mar 2011 02:03:33 +0000 (02:03 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Mar 2011 02:03:33 +0000 (02:03 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8575 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/groups/actions/groups/edit.php
mod/groups/languages/en.php
mod/groups/views/default/forms/groups/edit.php

index b3c39c46133176eddb375636fa31f73198c3ca86..331c80be0831eaaed8e46d71c18040b3e87430ff 100644 (file)
@@ -60,23 +60,6 @@ if (!$group->name) {
        forward(REFERER);
 }
 
-// Group membership - should these be treated with same constants as access permissions?
-switch (get_input('membership')) {
-       case ACCESS_PUBLIC:
-               $group->membership = ACCESS_PUBLIC;
-               break;
-       default:
-               $group->membership = ACCESS_PRIVATE;
-}
-
-// Set access - all groups are public from elgg's point of view, unless the override is in place
-if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
-       $visibility = (int)get_input('vis', '', false);
-
-       $group->access_id = $visibility;
-} else {
-       $group->access_id = ACCESS_PUBLIC;
-}
 
 // Set group tool options
 if (isset($CONFIG->group_tool_options)) {
@@ -89,7 +72,20 @@ if (isset($CONFIG->group_tool_options)) {
                }
                $group->$group_option_toggle_name = get_input($group_option_toggle_name, $group_option_default_value);
        }
-}      
+}
+
+// Group membership - should these be treated with same constants as access permissions?
+switch (get_input('membership')) {
+       case ACCESS_PUBLIC:
+               $group->membership = ACCESS_PUBLIC;
+               break;
+       default:
+               $group->membership = ACCESS_PRIVATE;
+}
+
+if ($new_group_flag) {
+       $group->access_id = ACCESS_PUBLIC;
+}
 
 $group->save();
 
@@ -100,7 +96,18 @@ if ($new_group_flag) {
        add_to_river('river/group/create', 'create', $user->guid, $group->guid);
 }
 
+// Invisible group support
+if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
+       $visibility = (int)get_input('vis', '', false);
+       if ($visibility != ACCESS_PUBLIC || $visibility != ACCESS_LOGGED_IN) {
+               $visibility = $group->group_acl;
+       }
 
+       if ($group->access_id != $visibility) {
+               $group->access_id = $visibility;
+               $group->save();
+       }
+}
 
 // Now see if we have a file icon
 if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))) {
index 91f9f0cb61307654e9d9f6b3cb1b749826307432..b798dbf2d2a19ce02f2d495275049033e6c92cc6 100644 (file)
@@ -87,6 +87,7 @@ $english = array(
         */
        'groups:access:private' => 'Closed - Users must be invited',
        'groups:access:public' => 'Open - Any user may join',
+       'groups:access:group' => 'Group members only',
        'groups:closedgroup' => 'This group has a closed membership.',
        'groups:closedgroup:request' => 'To ask to be added, click the "request membership" menu link.',
        'groups:visibility' => 'Who can see this group?',
index 3993e750d13d1211e17c09ee7b8e78188e00bdac..8b5a3c33e4502e91153a4424e59bd82586059f97 100644 (file)
@@ -8,8 +8,14 @@
 // new groups default to open membership
 if (isset($vars['entity'])) {
        $membership = $vars['entity']->membership;
+       $access = $vars['entity']->access_id;
+       if ($access != ACCESS_PUBLIC || ACCESS_LOGGED_IN) {
+               // group only - this is done to handle access not created when group is created
+               $access = ACCESS_PRIVATE;
+       }
 } else {
        $membership = ACCESS_PUBLIC;
+       $access = ACCESS_PUBLIC;
 }
 
 ?>
@@ -52,7 +58,7 @@ if ($group_profile_fields > 0) {
                <?php echo elgg_view('input/access', array(
                        'name' => 'membership',
                        'value' => $membership,
-                       'options' => array(
+                       'options_values' => array(
                                ACCESS_PRIVATE => elgg_echo('groups:access:private'),
                                ACCESS_PUBLIC => elgg_echo('groups:access:public')
                        )
@@ -68,19 +74,11 @@ if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
        if (!$this_owner) {
                $this_owner = elgg_get_logged_in_user_guid();
        }
-       $access = array(
-               ACCESS_FRIENDS => elgg_echo("access:friends:label"),
+       $access_options = array(
+               ACCESS_PRIVATE => elgg_echo('groups:access:group'),
                ACCESS_LOGGED_IN => elgg_echo("LOGGED_IN"),
                ACCESS_PUBLIC => elgg_echo("PUBLIC")
        );
-       $collections = get_user_access_collections($vars['entity']->guid);
-       if (is_array($collections)) {
-               foreach ($collections as $c) {
-                       $access[$c->id] = $c->name;
-               }
-       }
-
-       $current_access = $vars['entity']->access_id ? $vars['entity']->access_id : ACCESS_PUBLIC;
 ?>
 
 <div>
@@ -88,8 +86,8 @@ if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
                        <?php echo elgg_echo('groups:visibility'); ?><br />
                        <?php echo elgg_view('input/access', array(
                                'name' => 'vis',
-                               'value' =>  $current_access,
-                               'options' => $access,
+                               'value' =>  $access,
+                               'options_values' => $access_options,
                        ));
                        ?>
        </label>