]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Merged [6223] - [6228] into trunk.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 29 May 2010 02:16:50 +0000 (02:16 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 29 May 2010 02:16:50 +0000 (02:16 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6283 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/upgrades/2010052601.php [new file with mode: 0644]
mod/groups/actions/edit.php
mod/groups/views/default/forms/groups/edit.php
version.php

diff --git a/engine/lib/upgrades/2010052601.php b/engine/lib/upgrades/2010052601.php
new file mode 100644 (file)
index 0000000..5b47791
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+// Upgrade to fix encoding issues on group data: #1963
+
+elgg_set_ignore_access(TRUE);
+
+$params = array('type' => 'group',
+                               'limit' => 0);
+$groups = elgg_get_entities($params);
+if ($groups) {
+       foreach ($groups as $group) {
+               $group->name = html_entity_decode($group->name, ENT_COMPAT, 'UTF-8');
+               $group->description = html_entity_decode($group->description, ENT_COMPAT, 'UTF-8');
+               $group->briefdescription = html_entity_decode($group->briefdescription, ENT_COMPAT, 'UTF-8');
+               $group->website = html_entity_decode($group->website, ENT_COMPAT, 'UTF-8');
+               if ($group->interests) {
+                       $tags = $group->interests;
+                       foreach ($tags as $index=>$tag) {
+                               $tags[$index] = html_entity_decode($tag, ENT_COMPAT, 'UTF-8');
+                       }
+                       $group->interests = $tags;
+               }
+
+               $group->save();
+       }
+}
+elgg_set_ignore_access(FALSE);
index 72cc66e85275b562520801c2999e2b02ce5d2110..361f81757e9e25466fde17cb47bfcee937c92d9c 100644 (file)
 <?php
-       /**
-        * Elgg groups plugin edit action.
-        * 
-        * @package ElggGroups
-        * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
-        * @author Curverider Ltd
-        * @copyright Curverider Ltd 2008-2010
-        * @link http://elgg.com/
-        */
-
-       // Load configuration
-       global $CONFIG;
-       
-       // Get group fields
-       $input = array();
-       foreach($CONFIG->group as $shortname => $valuetype) {
-               $input[$shortname] = get_input($shortname);
-               if ($shortname == 'name') {
-                       $input[$shortname] = strip_tags($input[$shortname]);
-               }
-               if ($valuetype == 'tags')
-                       $input[$shortname] = string_to_tag_array($input[$shortname]);
-       }
-       
-       $user_guid = get_input('user_guid');
-       $user = NULL;
-       if (!$user_guid) $user = $_SESSION['user'];
-       else
-               $user = get_entity($user_guid);
-               
-       $group_guid = get_input('group_guid');
-       
-       $group = new ElggGroup($group_guid); // load if present, if not create a new group
-       if (($group_guid) && (!$group->canEdit()))
-       {
-               register_error(elgg_echo("groups:cantedit"));
-               
-               forward($_SERVER['HTTP_REFERER']);
-               exit;
-       }
-       
-       // Assume we can edit or this is a new group
-       if (sizeof($input) > 0)
-       {
-               foreach($input as $shortname => $value) {
-                       $group->$shortname = $value;
-               }
-       }
-       
-       // Validate create
-       if (!$group->name)
-       {
-               register_error(elgg_echo("groups:notitle"));
-               
-               forward($_SERVER['HTTP_REFERER']);
-               exit;
+/**
+ * Elgg groups plugin edit action.
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
+
+// Load configuration
+global $CONFIG;
+
+// Get group fields
+$input = array();
+foreach ($CONFIG->group as $shortname => $valuetype) {
+       $input[$shortname] = get_input($shortname);
+       // another work around for Elgg's encoding problems: #561, #1963
+       $input[$shortname] = html_entity_decode($input[$shortname], ENT_COMPAT, 'UTF-8');
+       if ($shortname == 'name') {
+               $input[$shortname] = strip_tags($input[$shortname]);
        }
-       
-       // 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 ($valuetype == 'tags') {
+               $input[$shortname] = string_to_tag_array($input[$shortname]);
        }
-       
-       // Set access - all groups are public from elgg's point of view, unless the override is in place
-
-       if (get_plugin_setting('hidden_groups', 'groups') == 'yes')
-       {
-               $visibility = (int)get_input('vis','',false);
-               
-               $group->access_id = $visibility;
+}
+
+$user = get_loggedin_user();
+
+$group_guid = (int)get_input('group_guid');
+$new_group_flag = $group_guid == 0;
+
+$group = new ElggGroup($group_guid); // load if present, if not create a new group
+if (($group_guid) && (!$group->canEdit())) {
+       register_error(elgg_echo("groups:cantedit"));
+
+       forward($_SERVER['HTTP_REFERER']);
+       exit;
+}
+
+// Assume we can edit or this is a new group
+if (sizeof($input) > 0) {
+       foreach($input as $shortname => $value) {
+               $group->$shortname = $value;
        }
-       else
-               $group->access_id = ACCESS_PUBLIC;
-       
-       // Set group tool options
-       //$group->files_enable = get_input('files_enable', 'yes');
-       //$group->pages_enable = get_input('pages_enable', 'yes');
-       //$group->forum_enable = get_input('forum_enable', 'yes');
-       
-       // Set group tool options
-       if (isset($CONFIG->group_tool_options)) {
-               foreach($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';
-                       }
-                       $group->$group_option_toggle_name = get_input($group_option_toggle_name, $group_option_default_value);
-               }
-       }       
-
-       $group->save();
-       
-       if (!$group->isMember($user))
-               $group->join($user); // Creator always a member
-       
-       
-       // Now see if we have a file icon
-       if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/')))
-       {
-               $prefix = "groups/".$group->guid;
-               
-               $filehandler = new ElggFile();
-               $filehandler->owner_guid = $group->owner_guid;
-               $filehandler->setFilename($prefix . ".jpg");
-               $filehandler->open("write");
-               $filehandler->write(get_uploaded_file('icon'));
-               $filehandler->close();
-               
-               $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),25,25, true);
-               $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),40,40, true);
-               $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),100,100, true);
-               $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),200,200, false);
-               if ($thumbtiny) {
-                       
-                       $thumb = new ElggFile();
-                       $thumb->owner_guid = $group->owner_guid;
-                       $thumb->setMimeType('image/jpeg');
-                       
-                       $thumb->setFilename($prefix."tiny.jpg");
-                       $thumb->open("write");
-                       $thumb->write($thumbtiny);
-                       $thumb->close();
-                       
-                       $thumb->setFilename($prefix."small.jpg");
-                       $thumb->open("write");
-                       $thumb->write($thumbsmall);
-                       $thumb->close();
-                       
-                       $thumb->setFilename($prefix."medium.jpg");
-                       $thumb->open("write");
-                       $thumb->write($thumbmedium);
-                       $thumb->close();
-                       
-                       $thumb->setFilename($prefix."large.jpg");
-                       $thumb->open("write");
-                       $thumb->write($thumblarge);
-                       $thumb->close();
-                       
-                       $group->icontime = time();
+}
+
+// Validate create
+if (!$group->name) {
+       register_error(elgg_echo("groups:notitle"));
+
+       forward($_SERVER['HTTP_REFERER']);
+       exit;
+}
+
+// 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 (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
+//$group->files_enable = get_input('files_enable', 'yes');
+//$group->pages_enable = get_input('pages_enable', 'yes');
+//$group->forum_enable = get_input('forum_enable', 'yes');
+
+// Set group tool options
+if (isset($CONFIG->group_tool_options)) {
+       foreach($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';
                }
+               $group->$group_option_toggle_name = get_input($group_option_toggle_name, $group_option_default_value);
        }
-       
-       system_message(elgg_echo("groups:saved"));
-       
-       // Forward to the user's profile
-       forward($group->getUrl());
-       exit;
-?>
+}      
+
+$group->save();
+
+// group creator needs to be member of new group
+if ($new_group_flag) {
+       $group->join($user);
+}
+
+
+
+// Now see if we have a file icon
+if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))) {
+       $prefix = "groups/".$group->guid;
+
+       $filehandler = new ElggFile();
+       $filehandler->owner_guid = $group->owner_guid;
+       $filehandler->setFilename($prefix . ".jpg");
+       $filehandler->open("write");
+       $filehandler->write(get_uploaded_file('icon'));
+       $filehandler->close();
+
+       $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),25,25, true);
+       $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),40,40, true);
+       $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),100,100, true);
+       $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),200,200, false);
+       if ($thumbtiny) {
+
+               $thumb = new ElggFile();
+               $thumb->owner_guid = $group->owner_guid;
+               $thumb->setMimeType('image/jpeg');
+
+               $thumb->setFilename($prefix."tiny.jpg");
+               $thumb->open("write");
+               $thumb->write($thumbtiny);
+               $thumb->close();
+
+               $thumb->setFilename($prefix."small.jpg");
+               $thumb->open("write");
+               $thumb->write($thumbsmall);
+               $thumb->close();
+
+               $thumb->setFilename($prefix."medium.jpg");
+               $thumb->open("write");
+               $thumb->write($thumbmedium);
+               $thumb->close();
+
+               $thumb->setFilename($prefix."large.jpg");
+               $thumb->open("write");
+               $thumb->write($thumblarge);
+               $thumb->close();
+
+               $group->icontime = time();
+       }
+}
+
+system_message(elgg_echo("groups:saved"));
+
+
+forward($group->getUrl());
+
index c0c9591f396b17f50ceccd1f21178513aaafaf12..fbc8c0777093fdca14eb1b29fcb3e9532a098820 100644 (file)
@@ -132,11 +132,13 @@ if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0)
        ?>
        <p>
                <?php
-                       if ($vars['entity']) { 
-                               ?><input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" /><?php 
+                       if ($vars['entity'])
+                       { 
+               ?>
+               <input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
+               <?php
                        }
                ?>
-               <input type="hidden" name="user_guid" value="<?php echo page_owner_entity()->guid; ?>" />
                <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" />
                
        </p>
index 62fb107ef7a9663f4bd5191809cc152632370b41..bfa62f449ff2d76b1991ca496f6fcc61dd2a418e 100644 (file)
@@ -12,7 +12,7 @@
 
 // YYYYMMDD = Elgg Date
 // XX = Interim incrementer
-$version = 2010050701;
+$version = 2010052601;
 
 // Human-friendly version name
 $release = '1.8-svn';