]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
a little clean up of the groups edit form
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 2 Feb 2011 01:59:56 +0000 (01:59 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 2 Feb 2011 01:59:56 +0000 (01:59 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7986 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/groups/lib/groups.php
mod/groups/start.php
mod/groups/views/default/forms/groups/edit.php
mod/groups/views/default/groups/edit.php [new file with mode: 0644]

index 924ce5e2a5b957876f470664cf7b1d62f87583bf..cff7fe258cfae41c31567f7869276c378f499cb2 100644 (file)
@@ -124,7 +124,7 @@ function groups_handle_edit_page($page, $guid = 0) {
                elgg_set_page_owner_guid(get_loggedin_userid());
                $title = elgg_echo('groups:add');
                elgg_push_breadcrumb($title);
-               $content = elgg_view('forms/groups/edit');
+               $content = elgg_view('groups/edit');
        } else {
                $title = elgg_echo("groups:edit");
                $group = get_entity($guid);
@@ -133,7 +133,7 @@ function groups_handle_edit_page($page, $guid = 0) {
                        elgg_set_page_owner_guid($group->getGUID());
                        elgg_push_breadcrumb($group->name, $group->getURL());
                        elgg_push_breadcrumb($title);
-                       $content = elgg_view("forms/groups/edit", array('entity' => $group));
+                       $content = elgg_view("groups/edit", array('entity' => $group));
                } else {
                        $content = elgg_echo('groups:noaccess');
                }
index 72ea31480942b4aec3e109f17cc00fa28d168797..c0fc90135fdaa05c80eb655e43e159653aa88093 100644 (file)
@@ -7,6 +7,9 @@
 
 elgg_register_event_handler('init', 'system', 'groups_init');
 
+// Ensure this runs after other plugins
+elgg_register_event_handler('init', 'system', 'groups_fields_setup', 10000);
+
 /**
  * Initialize the groups plugin.
  */
@@ -82,11 +85,6 @@ function groups_init() {
 
        // Register a handler for delete groups
        elgg_register_event_handler('delete', 'group', 'groups_delete_event_listener');
-
-       // Make sure the groups initialisation function is called on initialisation
-
-       // Ensure this runs after other plugins
-       elgg_register_event_handler('init', 'system', 'groups_fields_setup', 10000);
        
        elgg_register_event_handler('join', 'group', 'groups_user_join_event_listener');
        elgg_register_event_handler('leave', 'group', 'groups_user_leave_event_listener');
@@ -95,14 +93,14 @@ function groups_init() {
 }
 
 /**
- * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
- * add and delete fields.
+ * This function loads a set of default fields into the profile, then triggers
+ * a hook letting other plugins to edit add and delete fields.
  *
- * Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all
- * other plugins have initialised.
+ * Note: This is a system:init event triggered function and is run at a super
+ * low priority to guarantee that it is called after all other plugins have
+ * initialized.
  */
 function groups_fields_setup() {
-       global $CONFIG;
 
        $profile_defaults = array(
                'name' => 'text',
@@ -112,14 +110,17 @@ function groups_fields_setup() {
                        //'website' => 'url',
        );
 
-       $CONFIG->group = elgg_trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults);
+       $profile_defaults = elgg_trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults);
+
+       elgg_set_config('group', $profile_defaults);
 
        // register any tag metadata names
-       foreach ($CONFIG->group as $name => $type) {
+       foreach ($profile_defaults as $name => $type) {
                if ($type == 'tags') {
                        elgg_register_tag_metadata_name($name);
 
-                       // register a tag name translation
+                       // only shows up in search but why not just set this in en.php as doing it here
+                       // means you cannot override it in a plugin
                        add_translation(get_current_language(), array("tag_names:$name" => elgg_echo("groups:$name")));
                }
        }
index 99ff92616af3f46bda1073420ccebc0e6f47462f..326ed388fca30c5be8e6d5f646e63b4734095142 100644 (file)
@@ -1,19 +1,19 @@
 <?php
-       /**
       * Elgg groups plugin
       
       * @package ElggGroups
       */
-
-       // new groups default to open membership
-       if (isset($vars['entity'])) {
-               $membership = $vars['entity']->membership;
-       } else {
-               $membership = ACCESS_PUBLIC;
-       }
+/**
+ * Elgg groups plugin
+ * 
+ * @package ElggGroups
+ */
+
+// new groups default to open membership
+if (isset($vars['entity'])) {
+       $membership = $vars['entity']->membership;
+} else {
+       $membership = ACCESS_PUBLIC;
+}
        
 ?>
-<form action="<?php echo elgg_get_site_url(); ?>action/groups/edit" id="edit_group" enctype="multipart/form-data" method="post" class="margin-top">
+<form action="<?php echo elgg_get_site_url(); ?>action/groups/edit" enctype="multipart/form-data" method="post">
 
        <?php echo elgg_view('input/securitytoken'); ?>
 
        </p>
 <?php
 
-//var_export($vars['profile']);
-if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
-       foreach($vars['config']->group as $shortname => $valtype) {
-       if ($shortname == 'description') {
+$group_profile_fields = elgg_get_config('group');
+if ($group_profile_fields > 0) {
+       foreach ($group_profile_fields as $shortname => $valtype) {
+               if ($shortname == 'description') {
 ?>
        <p><label>
        <?php echo elgg_echo("groups:{$shortname}") ?></label>
@@ -41,7 +41,7 @@ if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
                                                )); ?>
        </p>
 <?php                  
-       } else {
+               } else {
 ?>
        <p><label>
        <?php echo elgg_echo("groups:{$shortname}") ?><br />
@@ -51,6 +51,7 @@ if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
                                                )); ?>
        </label></p>
 <?php
+               }
        }
 }
 ?>
@@ -64,8 +65,7 @@ if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
        
        <?php
 
-       if (get_plugin_setting('hidden_groups', 'groups') == 'yes')
-       {
+if (get_plugin_setting('hidden_groups', 'groups') == 'yes') {
 ?>
 
        <p>
@@ -73,42 +73,40 @@ if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
                        <?php echo elgg_echo('groups:visibility'); ?><br />
                        <?php 
                        
-                       $this_owner = $vars['entity']->owner_guid;
-                       if (!$this_owner) {
-                               $this_owner = get_loggedin_userid();
-                       }
+       $this_owner = $vars['entity']->owner_guid;
+       if (!$this_owner) {
+               $this_owner = get_loggedin_userid();
+       }
                        
-                       $access = array(ACCESS_FRIENDS => elgg_echo("access:friends:label"), 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;
-                       }
+       $access = array(ACCESS_FRIENDS => elgg_echo("access:friends:label"), 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);
-                       echo elgg_view('input/access', array('internalname' => 'vis', 
+       $current_access = ($vars['entity']->access_id ? $vars['entity']->access_id : ACCESS_PUBLIC);
+       echo elgg_view('input/access', array('internalname' => 'vis', 
                                                                                                'value' =>  $current_access,
                                                                                                'options' => $access));
                        
                        
-                       ?>
+       ?>
                </label>
        </p>
 
 <?php  
-       }
-       
-       ?>
+}
        
-    <?php
-               if (isset($vars['config']->group_tool_options)) {
-                       foreach($vars['config']->group_tool_options as $group_option) {
-                               $group_option_toggle_name = $group_option->name."_enable";
-                               if ($group_option->default_on) {
-                                       $group_option_default_value = 'yes';
-                               } else {
-                                       $group_option_default_value = 'no';
-                               }
+if (isset($vars['config']->group_tool_options)) {
+       foreach($vars['config']->group_tool_options as $group_option) {
+               $group_option_toggle_name = $group_option->name."_enable";
+               if ($group_option->default_on) {
+                       $group_option_default_value = 'yes';
+               } else {
+                       $group_option_default_value = 'no';
+               }
 ?>     
     <p>
                        <label>
@@ -126,43 +124,22 @@ if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
                                ?>
                        </label>
        </p>
-       <?php
-               }
+<?php
        }
-       ?>
+}
+?>
        <div class="divider"></div>
        <p>
-               <?php
-                       if ($vars['entity'])
-                       { 
-               ?>
-               <input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
-               <?php
-                       }
-
-                       echo elgg_view('input/submit', array('value' => elgg_echo('save')));
-               ?>
-               
-       </p>
-
-</form>
-
 <?php
 if ($vars['entity']) {
 ?>
-<div class="delete_group">
-       <form action="<?php echo elgg_get_site_url() . "action/groups/delete"; ?>">
-               <?php
-                       echo elgg_view('input/securitytoken');
-                               $warning = elgg_echo("groups:deletewarning");
-                       ?>
-                       <input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
-                       <input type="submit" class="elgg-action-button disabled" name="delete" value="<?php echo elgg_echo('groups:delete'); ?>" onclick="javascript:return confirm('<?php echo $warning; ?>')"/><?php 
-               ?>
-       </form>
-</div>
+               <input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
 <?php
 }
-?>
 
+echo elgg_view('input/submit', array('value' => elgg_echo('save')));
+?>
+               
+       </p>
 
+</form>
diff --git a/mod/groups/views/default/groups/edit.php b/mod/groups/views/default/groups/edit.php
new file mode 100644 (file)
index 0000000..b18cf1e
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Edit/create a group
+ */
+
+$entity = elgg_get_array_value('entity', $vars, null);
+
+echo elgg_view('forms/groups/edit', array('entity' => $entity));
+
+if ($entity) {
+?>
+<div class="delete_group">
+       <form action="<?php echo elgg_get_site_url() . "action/groups/delete"; ?>">
+               <?php
+                       echo elgg_view('input/securitytoken');
+                               $warning = elgg_echo("groups:deletewarning");
+                       ?>
+                       <input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
+                       <input type="submit" class="elgg-action-button disabled" name="delete" value="<?php echo elgg_echo('groups:delete'); ?>" onclick="javascript:return confirm('<?php echo $warning; ?>')"/><?php
+               ?>
+       </form>
+</div>
+<?php
+}
+?>