From 64aafb5ca73d329663a93f80ac9cf3e68a082866 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 21 Aug 2010 20:51:26 +0000 Subject: Merged r6534-6559 from 1.7 branch to trunk git-svn-id: http://code.elgg.org/elgg/trunk@6840 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 17 +++++------------ engine/lib/metadata.php | 24 ++++++++++++------------ engine/lib/output.php | 2 +- engine/lib/relationships.php | 5 ++++- engine/lib/upgrades/2010062301.php | 21 +++++++++++++++++++++ engine/lib/upgrades/2010062302.php | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 engine/lib/upgrades/2010062301.php create mode 100644 engine/lib/upgrades/2010062302.php (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index f74fbec09..3d08227e4 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1624,22 +1624,15 @@ function is_not_null($string) { function elgg_normalise_plural_options_array($options, $singulars) { foreach ($singulars as $singular) { $plural = $singular . 's'; - - // normalize the singular to plural - // isset() returns FALSE for array values of NULL, so they are ignored. - // everything else falsy is included. - //if (isset($options[$singular]) && $options[$singular] !== NULL && $options[$singular] !== FALSE) { - if (isset($options[$singular])) { - if (isset($options[$plural])) { - if (is_array($options[$plural])) { - $options[$plural][] = $options[$singlar]; - } else { - $options[$plural] = array($options[$plural], $options[$singular]); - } + + if (array_key_exists($singular, $options)) { + if ($options[$singular] === ELGG_ENTITIES_ANY_VALUE) { + $options[$plural] = $options[$singular]; } else { $options[$plural] = array($options[$singular]); } } + unset($options[$singular]); } diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 74ea6858a..6e849cdd9 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -186,10 +186,11 @@ function remove_metadata($entity_guid, $name, $value = "") { * @param int $entity_guid The entity to attach the metadata to * @param string $name Name of the metadata * @param string $value Value of the metadata (cannot be associative array) - * @param string $value_type - * @param int $owner_guid - * @param int $access_id - * @param bool $allow_multiple + * @param string $value_type 'text', 'integer', or '' for automatic detection + * @param int $owner_guid GUID of entity that owns the metadata + * @param int $access_id Default is ACCESS_PRIVATE + * @param bool $allow_multiple Allow multiple values for one key. Default is FALSE + * @return bool */ function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false) { global $CONFIG; @@ -218,8 +219,7 @@ function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, if (!$result) { return false; } - } - else if (isset($value)) { + } else if (isset($value)) { // Support boolean types if (is_bool($value)) { if ($value) { @@ -343,12 +343,12 @@ function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_i /** * This function creates metadata from an associative array of "key => value" pairs. * - * @param int $entity_guid - * @param string $name_and_values - * @param string $value_type - * @param int $owner_guid - * @param int $access_id - * @param bool $allow_multiple + * @param int $entity_guid The entity to attach the metadata to + * @param string $name_and_values Associative array + * @param string $value_type 'text', 'integer', or '' for automatic detection + * @param int $owner_guid GUID of entity that owns the metadata + * @param int $access_id Default is ACCESS_PRIVATE + * @param bool $allow_multiple Allow multiple values for one key. Default is FALSE */ function create_metadata_from_array($entity_guid, array $name_and_values, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false) { foreach ($name_and_values as $k => $v) { diff --git a/engine/lib/output.php b/engine/lib/output.php index 70c3821d6..3b82447b0 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -116,7 +116,7 @@ function elgg_make_excerpt($text, $num_chars = 250) { $excerpt = trim(elgg_substr($excerpt, 0, $space)); if ($string_length != elgg_strlen($excerpt)) { - $excerpt .= '…'; + $excerpt .= '...'; } return $excerpt; diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index f813cacba..f1d119452 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -358,13 +358,16 @@ function add_entity_relationship($guid_one, $relationship, $guid_two) { $guid_one = (int)$guid_one; $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; + $time = time(); // Check for duplicates if (check_entity_relationship($guid_one, $relationship, $guid_two)) { return false; } - $result = insert_data("INSERT into {$CONFIG->dbprefix}entity_relationships (guid_one, relationship, guid_two) values ($guid_one, '$relationship', $guid_two)"); + $result = insert_data("INSERT into {$CONFIG->dbprefix}entity_relationships + (guid_one, relationship, guid_two, time_created) + values ($guid_one, '$relationship', $guid_two, $time)"); if ($result!==false) { $obj = get_relationship($result); diff --git a/engine/lib/upgrades/2010062301.php b/engine/lib/upgrades/2010062301.php new file mode 100644 index 000000000..96fd6c810 --- /dev/null +++ b/engine/lib/upgrades/2010062301.php @@ -0,0 +1,21 @@ + 'group', + 'limit' => 0); +$groups = elgg_get_entities($params); +if ($groups) { + foreach ($groups as $group) { + $acl = $group->group_acl; + + $query = "UPDATE {$CONFIG->dbprefix}access_collections SET owner_guid = $group->guid WHERE id = $acl"; + update_data($query); + } +} +elgg_set_ignore_access(FALSE); + diff --git a/engine/lib/upgrades/2010062302.php b/engine/lib/upgrades/2010062302.php new file mode 100644 index 000000000..fe33e12ea --- /dev/null +++ b/engine/lib/upgrades/2010062302.php @@ -0,0 +1,33 @@ + 'group', 'limit' => 0); +$groups = elgg_get_entities($params); +if ($groups) { + foreach ($groups as $group) { + $acl = $group->group_acl; + + $query = "SELECT u.guid FROM {$CONFIG->dbprefix}users_entity u + JOIN {$CONFIG->dbprefix}entity_relationships r + ON u.guid = r.guid_one AND r.relationship = 'member' AND r.guid_two = $group->guid + LEFT JOIN {$CONFIG->dbprefix}access_collection_membership a + ON u.guid = a.user_guid AND a.access_collection_id = $acl + WHERE a.user_guid IS NULL"; + + $results = get_data($query); + if ($results != FALSE) { + foreach ($results as $user) { + $insert = "INSERT INTO {$CONFIG->dbprefix}access_collection_membership + (user_guid, access_collection_id) VALUES ($user->guid, $acl)"; + insert_data($insert); + } + } + } +} +elgg_set_ignore_access(FALSE); -- cgit v1.2.3