From e3100d350c27804f80de3321b00be9dfc23c6d2a Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 23 Dec 2011 19:26:08 -0500 Subject: Fixes #682 not deleting metadata when update, metadata event handlers return false --- engine/lib/metadata.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 050e69526..4908b3e88 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -216,12 +216,11 @@ function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_i $result = update_data($query); if ($result !== false) { + // @todo this event tells you the metadata has been updated, but does not + // let you do anything about it. What is needed is a plugin hook before + // the update that passes old and new values. $obj = elgg_get_metadata_from_id($id); - if (elgg_trigger_event('update', 'metadata', $obj)) { - return true; - } else { - elgg_delete_metadata_by_id($id); - } + elgg_trigger_event('update', 'metadata', $obj); } return $result; -- cgit v1.2.3 From c4b49227819624b14b61e6eedbfa6779cd794d45 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 8 Jan 2012 19:33:21 -0500 Subject: most of the comments in the engine now past the sniffer --- engine/classes/ElggExtender.php | 11 +++++++++-- engine/classes/ElggMenuBuilder.php | 3 +-- engine/classes/ElggMenuItem.php | 8 +++----- engine/classes/ElggMetadata.php | 7 +++++++ engine/classes/ElggUser.php | 21 ++++++++++----------- engine/classes/SuccessResult.php | 2 +- engine/lib/annotations.php | 2 +- engine/lib/cache.php | 7 ++++--- engine/lib/metadata.php | 2 +- engine/lib/output.php | 8 ++++---- engine/lib/pagehandler.php | 1 + engine/lib/pageowner.php | 7 ++++--- engine/lib/plugins.php | 7 ++++--- engine/lib/users.php | 8 ++++---- 14 files changed, 54 insertions(+), 40 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php index bc2d67ae2..d94bad837 100644 --- a/engine/classes/ElggExtender.php +++ b/engine/classes/ElggExtender.php @@ -24,8 +24,15 @@ * @property mixed $value The value of the extender (int or string) * @property int $time_created A UNIX timestamp of when the extender was created (read-only, set on first save) */ -abstract class ElggExtender extends ElggData -{ +abstract class ElggExtender extends ElggData { + + /** + * (non-PHPdoc) + * + * @see ElggData::initializeAttributes() + * + * @return void + */ protected function initializeAttributes() { parent::initializeAttributes(); diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php index 6f4ac702e..de0017599 100644 --- a/engine/classes/ElggMenuBuilder.php +++ b/engine/classes/ElggMenuBuilder.php @@ -4,8 +4,7 @@ * * @package Elgg.Core * @subpackage Navigation - * - * @since 1.8.0 + * @since 1.8.0 */ class ElggMenuBuilder { diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 2512392ad..4bc9144d4 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -4,10 +4,9 @@ * * To create a menu item that is not a link, pass false for $href. * - * @since 1.8.0 - * * @package Elgg.Core * @subpackage Navigation + * @since 1.8.0 */ class ElggMenuItem { @@ -549,10 +548,9 @@ class ElggMenuItem { /** * Get the menu item content (usually a link) * - * @todo View code in a model. How do we feel about that? - * - * @params array $vars Options to pass to output/url if a link + * @param array $vars Options to pass to output/url if a link * @return string + * @todo View code in a model. How do we feel about that? */ public function getContent(array $vars = array()) { diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php index 32e7b32f1..634a122e5 100644 --- a/engine/classes/ElggMetadata.php +++ b/engine/classes/ElggMetadata.php @@ -9,6 +9,13 @@ */ class ElggMetadata extends ElggExtender { + /** + * (non-PHPdoc) + * + * @see ElggData::initializeAttributes() + * + * @return void + */ protected function initializeAttributes() { parent::initializeAttributes(); diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index ab0610ac0..bdf57c2c3 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -105,7 +105,7 @@ class ElggUser extends ElggEntity * * @param int $guid ElggUser GUID * - * @return true|false + * @return bool */ protected function load($guid) { // Test to see if we have the generic stuff @@ -141,7 +141,7 @@ class ElggUser extends ElggEntity /** * Saves this user to the database. * - * @return true|false + * @return bool */ public function save() { // Save generic stuff @@ -261,7 +261,7 @@ class ElggUser extends ElggEntity * @param int $limit The number of results to return * @param int $offset Any indexing offset * - * @return bool + * @return array */ function getSites($subtype = "", $limit = 10, $offset = 0) { return get_user_sites($this->getGUID(), $subtype, $limit, $offset); @@ -272,7 +272,7 @@ class ElggUser extends ElggEntity * * @param int $site_guid The guid of the site to add it to * - * @return true|false + * @return bool */ function addToSite($site_guid) { return add_site_user($site_guid, $this->getGUID()); @@ -283,7 +283,7 @@ class ElggUser extends ElggEntity * * @param int $site_guid The guid of the site to remove it from * - * @return true|false + * @return bool */ function removeFromSite($site_guid) { return remove_site_user($site_guid, $this->getGUID()); @@ -294,7 +294,7 @@ class ElggUser extends ElggEntity * * @param int $friend_guid The GUID of the user to add * - * @return true|false Depending on success + * @return bool */ function addFriend($friend_guid) { return user_add_friend($this->getGUID(), $friend_guid); @@ -305,7 +305,7 @@ class ElggUser extends ElggEntity * * @param int $friend_guid The GUID of the user to remove * - * @return true|false Depending on success + * @return bool */ function removeFriend($friend_guid) { return user_remove_friend($this->getGUID(), $friend_guid); @@ -314,8 +314,7 @@ class ElggUser extends ElggEntity /** * Determines whether or not this user is a friend of the currently logged in user * - * - * @return true|false + * @return bool */ function isFriend() { return $this->isFriendOf(elgg_get_logged_in_user_guid()); @@ -326,7 +325,7 @@ class ElggUser extends ElggEntity * * @param int $user_guid The GUID of the user to check against * - * @return true|false + * @return bool */ function isFriendsWith($user_guid) { return user_is_friend($this->getGUID(), $user_guid); @@ -337,7 +336,7 @@ class ElggUser extends ElggEntity * * @param int $user_guid The GUID of the user to check against * - * @return true|false + * @return bool */ function isFriendOf($user_guid) { return user_is_friend($user_guid, $this->getGUID()); diff --git a/engine/classes/SuccessResult.php b/engine/classes/SuccessResult.php index c8578a2cf..ab5468ad8 100644 --- a/engine/classes/SuccessResult.php +++ b/engine/classes/SuccessResult.php @@ -15,7 +15,7 @@ class SuccessResult extends GenericResult { * * @param string $result The result */ - public function SuccessResult($result) { + public function __construct($result) { $this->setResult($result); $this->setStatusCode(SuccessResult::$RESULT_SUCCESS); } diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index bb7d836cc..30ef7f17b 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -549,8 +549,8 @@ function elgg_comment_url_handler(ElggAnnotation $comment) { /** * Register an annotation url handler. * - * @param string $function_name The function. * @param string $extender_name The name, default 'all'. + * @param string $function_name The function. * * @return string */ diff --git a/engine/lib/cache.php b/engine/lib/cache.php index a6ebe2a30..e71ef332d 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -34,8 +34,9 @@ function elgg_get_filepath_cache() { } /** - * Function which resets the file path cache. + * Reset the file path cache. * + * @return bool */ function elgg_filepath_cache_reset() { $cache = elgg_get_filepath_cache(); @@ -47,8 +48,8 @@ function elgg_filepath_cache_reset() { /** * Saves a filepath cache. * - * @param string $type - * @param string $data + * @param string $type The type or identifier of the cache + * @param string $data The data to be saved * @return bool */ function elgg_filepath_cache_save($type, $data) { diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 4908b3e88..352e98a61 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -871,8 +871,8 @@ function metadata_update($event, $object_type, $object) { /** * Register a metadata url handler. * - * @param string $function_name The function. * @param string $extender_name The name, default 'all'. + * @param string $function The function name. * * @return bool */ diff --git a/engine/lib/output.php b/engine/lib/output.php index 6554481f5..65f51f854 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -81,10 +81,10 @@ function autop($pee, $br = 1) { } $pee = preg_replace('!(]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*]*>)!', '$1', $pee); -// if (strpos($pee, '. Only there because of the comment. -// $pee = preg_replace_callback('!()(.*?)!is', 'clean_pre', $pee ); -// } + //if (strpos($pee, '. Only there because of the comment. + // $pee = preg_replace_callback('!()(.*?)!is', 'clean_pre', $pee ); + //} $pee = preg_replace( "|\n

$|", '

', $pee ); return $pee; diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index ffcfc5b6a..a675d976a 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -120,6 +120,7 @@ function elgg_unregister_page_handler($handler) { * @param string $type The type of the hook * @param bool $result The current value of the hook * @param array $params Parameters related to the hook + * @return void */ function elgg_error_page_handler($hook, $type, $result, $params) { if (elgg_view_exists("errors/$type")) { diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php index 9d41d74c1..0cf0e0625 100644 --- a/engine/lib/pageowner.php +++ b/engine/lib/pageowner.php @@ -54,7 +54,7 @@ function elgg_get_page_owner_entity() { * Set the guid of the entity that owns this page * * @param int $guid The guid of the page owner - * + * @return void * @since 1.8.0 */ function elgg_set_page_owner_guid($guid) { @@ -173,7 +173,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params) * @warning The context is not available until the page_handler runs (after * the 'init, system' event processing has completed). * - * @param string $context The context of the page + * @param string $context The context of the page * @return bool * @since 1.8.0 */ @@ -216,6 +216,7 @@ function elgg_get_context() { * Push a context onto the top of the stack * * @param string $context The context string to add to the context stack + * @return void * @since 1.8.0 */ function elgg_push_context($context) { @@ -244,7 +245,7 @@ function elgg_pop_context() { * itself differently based on being on the dashboard or profile pages, it * can check the stack. * - * @param string $context The context string to check for + * @param string $context The context string to check for * @return bool * @since 1.8.0 */ diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 026bc171b..7968f4a6e 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -480,9 +480,10 @@ function elgg_reindex_plugin_priorities() { */ function elgg_namespace_plugin_private_setting($type, $name, $id = null) { switch ($type) { -// case 'setting': -// $name = ELGG_PLUGIN_SETTING_PREFIX . $name; -// break; + // commented out because it breaks $plugin->$name access to variables + //case 'setting': + // $name = ELGG_PLUGIN_SETTING_PREFIX . $name; + // break; case 'user_setting': if (!$id) { diff --git a/engine/lib/users.php b/engine/lib/users.php index 362488718..c03052172 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -630,10 +630,10 @@ function get_user_by_email($email) { * A function that returns a maximum of $limit users who have done something within the last * $seconds seconds or the total count of active users. * - * @param int $seconds Number of seconds (default 600 = 10min) - * @param int $limit Limit, default 10. - * @param int $offset Offset, default 0. - * @param bool $count Count, default false. + * @param int $seconds Number of seconds (default 600 = 10min) + * @param int $limit Limit, default 10. + * @param int $offset Offset, default 0. + * @param bool $count Count, default false. * * @return mixed */ -- cgit v1.2.3 From 66953a2148bb7a19ac79c1a4ccda2852ee87501e Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Mon, 9 Jan 2012 18:53:19 -0500 Subject: coding standard fixes to engine --- engine/classes/ElggBatch.php | 8 +++----- engine/classes/ElggEntity.php | 28 ++++++++++++++-------------- engine/classes/ElggMemcache.php | 24 ++++-------------------- engine/classes/ElggWidget.php | 2 +- engine/classes/XMLRPCCall.php | 4 ++-- engine/handlers/export_handler.php | 6 ++++-- engine/lib/actions.php | 3 +-- engine/lib/configuration.php | 2 +- engine/lib/filestore.php | 2 +- engine/lib/metadata.php | 16 ++++++++-------- engine/lib/navigation.php | 2 +- engine/lib/output.php | 4 ++-- engine/lib/private_settings.php | 2 +- engine/lib/users.php | 2 +- engine/lib/views.php | 13 ++++++------- 15 files changed, 50 insertions(+), 68 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/classes/ElggBatch.php b/engine/classes/ElggBatch.php index 2a97f9ff5..3d01133fa 100644 --- a/engine/classes/ElggBatch.php +++ b/engine/classes/ElggBatch.php @@ -236,13 +236,11 @@ class ElggBatch } // if original limit < chunk size, set limit to original limit + // else if the number of results we'll fetch if greater than the original limit if ($this->limit < $this->chunkSize) { $limit = $this->limit; - } - - // if the number of results we'll fetch is greater than the original limit, - // set the limit to the number of results remaining in the original limit - elseif ($this->retrievedResults + $this->chunkSize > $this->limit) { + } elseif ($this->retrievedResults + $this->chunkSize > $this->limit) { + // set the limit to the number of results remaining in the original limit $limit = $this->limit - $this->retrievedResults; } } diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index df87082fe..2fa8e9939 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -1583,36 +1583,36 @@ abstract class ElggEntity extends ElggData implements foreach ($this->attributes as $k => $v) { $meta = NULL; - if (in_array( $k, $exportable_values)) { + if (in_array($k, $exportable_values)) { switch ($k) { - case 'guid' : // Dont use guid in OpenDD - case 'type' : // Type and subtype already taken care of - case 'subtype' : - break; + case 'guid': // Dont use guid in OpenDD + case 'type': // Type and subtype already taken care of + case 'subtype': + break; - case 'time_created' : // Created = published + case 'time_created': // Created = published $odd->setAttribute('published', date("r", $v)); - break; + break; - case 'site_guid' : // Container + case 'site_guid': // Container $k = 'site_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; + break; - case 'container_guid' : // Container + case 'container_guid': // Container $k = 'container_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; + break; - case 'owner_guid' : // Convert owner guid to uuid, this will be stored in metadata + case 'owner_guid': // Convert owner guid to uuid, this will be stored in metadata $k = 'owner_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; + break; - default : + default: $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); } diff --git a/engine/classes/ElggMemcache.php b/engine/classes/ElggMemcache.php index a54c29723..f27b017d0 100644 --- a/engine/classes/ElggMemcache.php +++ b/engine/classes/ElggMemcache.php @@ -110,22 +110,6 @@ class ElggMemcache extends ElggSharedMemoryCache { $this->expires = $expires; } - /** - * Combine a key with the namespace. - * Memcache can only accept <250 char key. If the given key is too long it is shortened. - * - * @deprecated 1.8 Use ElggMemcache::_makeMemcacheKey() - * - * @param string $key The key - * - * @return string The new key. - */ - private function make_memcache_key($key) { - elgg_deprecated_notice('ElggMemcache::make_memcache_key() is deprecated by ::_makeMemcacheKey()', 1.8); - - return $this->_makeMemcacheKey($key); - } - /** * Combine a key with the namespace. * Memcache can only accept <250 char key. If the given key is too long it is shortened. @@ -134,7 +118,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * * @return string The new key. */ - private function _makeMemcacheKey($key) { + private function makeMemcacheKey($key) { $prefix = $this->getNamespace() . ":"; if (strlen($prefix . $key) > 250) { @@ -154,7 +138,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * @return bool */ public function save($key, $data, $expires = null) { - $key = $this->_makeMemcacheKey($key); + $key = $this->makeMemcacheKey($key); if ($expires === null) { $expires = $this->expires; @@ -178,7 +162,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * @return mixed */ public function load($key, $offset = 0, $limit = null) { - $key = $this->_makeMemcacheKey($key); + $key = $this->makeMemcacheKey($key); $result = $this->memcache->get($key); if ($result === false) { @@ -196,7 +180,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * @return bool */ public function delete($key) { - $key = $this->_makeMemcacheKey($key); + $key = $this->makeMemcacheKey($key); return $this->memcache->delete($key, 0); } diff --git a/engine/classes/ElggWidget.php b/engine/classes/ElggWidget.php index 70eaf8a73..e703b84cb 100644 --- a/engine/classes/ElggWidget.php +++ b/engine/classes/ElggWidget.php @@ -133,7 +133,7 @@ class ElggWidget extends ElggObject { if ($rank == 0) { // top of the column $this->order = $widgets[0]->order - 10; - } elseif ($rank == (count($widgets)-1)) { + } elseif ($rank == (count($widgets) - 1)) { // bottom of the column $this->order = end($widgets)->order + 10; } else { diff --git a/engine/classes/XMLRPCCall.php b/engine/classes/XMLRPCCall.php index 8eeba0c29..fd28f1e3e 100644 --- a/engine/classes/XMLRPCCall.php +++ b/engine/classes/XMLRPCCall.php @@ -18,7 +18,7 @@ class XMLRPCCall { * @param string $xml XML */ function __construct($xml) { - $this->_parse($xml); + $this->parse($xml); } /** @@ -45,7 +45,7 @@ class XMLRPCCall { * * @return void */ - private function _parse($xml) { + private function parse($xml) { $xml = xml_to_object($xml); // sanity check diff --git a/engine/handlers/export_handler.php b/engine/handlers/export_handler.php index b91a037e8..aa5214c23 100644 --- a/engine/handlers/export_handler.php +++ b/engine/handlers/export_handler.php @@ -72,8 +72,10 @@ if (($guid != "") && ($type == "") && ($id_or_name == "")) { $r = get_relationship($id_or_name); break; case 'volatile' : - $m = elgg_trigger_plugin_hook('volatile', 'metadata', - array('guid' => $guid, 'varname' => $id_or_name)); + $m = elgg_trigger_plugin_hook('volatile', 'metadata', array( + 'guid' => $guid, + 'varname' => $id_or_name, + )); break; default : diff --git a/engine/lib/actions.php b/engine/lib/actions.php index f415842ab..c6613e6d6 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -459,8 +459,7 @@ function ajax_forward_hook($hook, $type, $reason, $params) { // however some browsers will not accept the JSON MIME type. if (stripos($_SERVER['HTTP_ACCEPT'], 'application/json') === FALSE) { header("Content-type: text/plain"); - } - else { + } else { header("Content-type: application/json"); } diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php index 615063f3d..3fade8155 100644 --- a/engine/lib/configuration.php +++ b/engine/lib/configuration.php @@ -555,7 +555,7 @@ function set_default_config() { 'path' => "$install_root/", 'view_path' => "$install_root/views/", 'plugins_path' => "$install_root/mod/", - 'wwwroot' => $www_root, + 'wwwroot' => $www_root, 'url' => $www_root, 'site_name' => 'New Elgg site', 'language' => 'en', diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index a13d8aa27..86f6d9baa 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -18,7 +18,7 @@ */ function get_dir_size($dir, $totalsize = 0) { $handle = @opendir($dir); - while ($file = @readdir ($handle)) { + while ($file = @readdir($handle)) { if (eregi("^\.{1,2}$", $file)) { continue; } diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 352e98a61..6e1b8b39c 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -402,15 +402,15 @@ function elgg_enable_metadata(array $options) { */ function elgg_get_entities_from_metadata(array $options = array()) { $defaults = array( - 'metadata_names' => ELGG_ENTITIES_ANY_VALUE, - 'metadata_values' => ELGG_ENTITIES_ANY_VALUE, - 'metadata_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE, + 'metadata_names' => ELGG_ENTITIES_ANY_VALUE, + 'metadata_values' => ELGG_ENTITIES_ANY_VALUE, + 'metadata_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE, - 'metadata_name_value_pairs_operator'=> 'AND', - 'metadata_case_sensitive' => TRUE, - 'order_by_metadata' => array(), + 'metadata_name_value_pairs_operator' => 'AND', + 'metadata_case_sensitive' => TRUE, + 'order_by_metadata' => array(), - 'metadata_owner_guids' => ELGG_ENTITIES_ANY_VALUE, + 'metadata_owner_guids' => ELGG_ENTITIES_ANY_VALUE, ); $options = array_merge($defaults, $options); @@ -633,7 +633,7 @@ $owner_guids = NULL) { $i++; } - if ($where = implode (" $pair_operator ", $pair_wheres)) { + if ($where = implode(" $pair_operator ", $pair_wheres)) { $wheres[] = "($where)"; } } diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index 956ca220a..dcbd7b397 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -301,7 +301,7 @@ function elgg_site_menu_setup($hook, $type, $return, $params) { // if only one item on more menu, stick it with the rest $num_menu_items = count($return['default']); if ($num_menu_items > ($max_display_items + 1)) { - $return['more'] = array_splice($return['default'], $max_display_items); + $return['more'] = array_splice($return['default'], $max_display_items); } } diff --git a/engine/lib/output.php b/engine/lib/output.php index 65f51f854..b96cf354c 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -67,7 +67,7 @@ function autop($pee, $br = 1) { $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "

$1

\n", $pee); // make paragraphs, including one at the end $pee = preg_replace('|

\s*?

|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('!

([^<]+)\s*?(]*>)!', "

$1

$2", $pee); - $pee = preg_replace( '|

|', "$1

", $pee ); + $pee = preg_replace('|

|', "$1

", $pee); $pee = preg_replace('!

\s*(]*>)\s*

!', "$1", $pee); // don't pee all over a tag $pee = preg_replace("|

(|", "$1", $pee); // problem with nested lists $pee = preg_replace('|

]*)>|i', "

", $pee); @@ -85,7 +85,7 @@ function autop($pee, $br = 1) { // mind the space between the ? and >. Only there because of the comment. // $pee = preg_replace_callback('!()(.*?)!is', 'clean_pre', $pee ); //} - $pee = preg_replace( "|\n

$|", '

', $pee ); + $pee = preg_replace("|\n

$|", '

', $pee); return $pee; } diff --git a/engine/lib/private_settings.php b/engine/lib/private_settings.php index 386af5279..1fa9bdb66 100644 --- a/engine/lib/private_settings.php +++ b/engine/lib/private_settings.php @@ -240,7 +240,7 @@ $pairs = NULL, $pair_operator = 'AND', $name_prefix = '') { $i++; } - $where = implode (" $pair_operator ", $pair_wheres); + $where = implode(" $pair_operator ", $pair_wheres); if ($where) { $wheres[] = "($where)"; } diff --git a/engine/lib/users.php b/engine/lib/users.php index c03052172..c38bb676e 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1486,7 +1486,7 @@ function users_pagesetup() { if ($viewer) { elgg_register_menu_item('topbar', array( 'name' => 'profile', - 'href' => $viewer->getURL(), + 'href' => $viewer->getURL(), 'text' => elgg_view('output/img', array( 'src' => $viewer->getIconURL('topbar'), 'alt' => $viewer->name, diff --git a/engine/lib/views.php b/engine/lib/views.php index b938dd60e..85319b2d7 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -415,7 +415,6 @@ function elgg_view($view, $vars = array(), $bypass = false, $debug = false, $vie if (isset($vars['internalname']) && !isset($vars['__ignoreInternalname']) && !isset($vars['name'])) { elgg_deprecated_notice('You should pass $vars[\'name\'] now instead of $vars[\'internalname\']', 1.8, 2); $vars['name'] = $vars['internalname']; - $test=false; } elseif (isset($vars['name'])) { if (!isset($vars['internalname'])) { $vars['__ignoreInternalname'] = ''; @@ -1628,12 +1627,12 @@ function elgg_views_boot() { // set default icon sizes - can be overridden in settings.php or with plugin if (!elgg_get_config('icon_sizes')) { $icon_sizes = array( - 'topbar' => array('w'=>16, 'h'=>16, 'square'=>TRUE, 'upscale'=>TRUE), - 'tiny' => array('w'=>25, 'h'=>25, 'square'=>TRUE, 'upscale'=>TRUE), - 'small' => array('w'=>40, 'h'=>40, 'square'=>TRUE, 'upscale'=>TRUE), - 'medium' => array('w'=>100, 'h'=>100, 'square'=>TRUE, 'upscale'=>TRUE), - 'large' => array('w'=>200, 'h'=>200, 'square'=>FALSE, 'upscale'=>FALSE), - 'master' => array('w'=>550, 'h'=>550, 'square'=>FALSE, 'upscale'=>FALSE), + 'topbar' => array('w' => 16, 'h' => 16, 'square' => TRUE, 'upscale' => TRUE), + 'tiny' => array('w' => 25, 'h' => 25, 'square' => TRUE, 'upscale' => TRUE), + 'small' => array('w' => 40, 'h' => 40, 'square' => TRUE, 'upscale' => TRUE), + 'medium' => array('w' => 100, 'h' => 100, 'square' => TRUE, 'upscale' => TRUE), + 'large' => array('w' => 200, 'h' => 200, 'square' => FALSE, 'upscale' => FALSE), + 'master' => array('w' => 550, 'h' => 550, 'square' => FALSE, 'upscale' => FALSE), ); elgg_set_config('icon_sizes', $icon_sizes); } -- cgit v1.2.3 From 0fe0f9d6dc6577d39bf0615c0e714c7fa7d2ebf3 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Mon, 9 Jan 2012 17:29:04 -0800 Subject: Fixes #4243. Added docs for metadata_calculation option to elgg_get_metadata(). --- engine/lib/annotations.php | 16 ++++++++-------- engine/lib/metadata.php | 27 ++++++++++++--------------- engine/lib/metastrings.php | 11 +++++------ 3 files changed, 25 insertions(+), 29 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index 30ef7f17b..7eb72612f 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -179,14 +179,14 @@ function update_annotation($annotation_id, $name, $value, $value_type, $owner_gu * * @param array $options Array in format: * - * annotation_names => NULL|ARR Annotation names - * annotation_values => NULL|ARR Annotation values - * annotation_ids => NULL|ARR annotation ids - * annotation_case_sensitive => BOOL Overall Case sensitive - * annotation_owner_guids => NULL|ARR guids for annotation owners - * annotation_created_time_lower => INT Lower limit for created time. - * annotation_created_time_upper => INT Upper limit for created time. - * annotation_calculation => STR Perform the MySQL function on the annotation values returned. + * annotation_names => NULL|ARR Annotation names + * annotation_values => NULL|ARR Annotation values + * annotation_ids => NULL|ARR annotation ids + * annotation_case_sensitive => BOOL Overall Case sensitive + * annotation_owner_guids => NULL|ARR guids for annotation owners + * annotation_created_time_lower => INT Lower limit for created time. + * annotation_created_time_upper => INT Upper limit for created time. + * annotation_calculation => STR Perform the MySQL function on the annotation values returned. * Do not confuse this "annotation_calculation" option with the * "calculation" option to elgg_get_entities_from_annotation_calculation(). * The "annotation_calculation" option causes this function to diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 6e1b8b39c..a097cd3ef 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -269,21 +269,18 @@ $access_id = ACCESS_PRIVATE, $allow_multiple = false) { * * @param array $options Array in format: * - * metadata_names => NULL|ARR metadata names - * - * metadata_values => NULL|ARR metadata values - * -* metadata_ids => NULL|ARR metadata ids - * - * metadata_case_sensitive => BOOL Overall Case sensitive - * - * metadata_owner_guids => NULL|ARR guids for metadata owners - * - * metadata_created_time_lower => INT Lower limit for created time. - * - * metadata_created_time_upper => INT Upper limit for created time. - * - * metadata_calculation => STR Perform the MySQL function on the metadata values returned. + * metadata_names => NULL|ARR metadata names + * metadata_values => NULL|ARR metadata values + * metadata_ids => NULL|ARR metadata ids + * metadata_case_sensitive => BOOL Overall Case sensitive + * metadata_owner_guids => NULL|ARR guids for metadata owners + * metadata_created_time_lower => INT Lower limit for created time. + * metadata_created_time_upper => INT Upper limit for created time. + * metadata_calculation => STR Perform the MySQL function on the metadata values returned. + * The "metadata_calculation" option causes this function to + * return the result of performing a mathematical calculation on + * all metadata that match the query instead of returning + * ElggMetadata objects. * * @return mixed * @since 1.8.0 diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 9fe9b4bff..d8fef6f1c 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -609,8 +609,7 @@ function elgg_get_metastring_sql($table, $names = null, $values = null, } /** - * Normalizes metadata / annotation option names to their - * corresponding metastrings name. + * Normalizes metadata / annotation option names to their corresponding metastrings name. * * @param array $options An options array * @since 1.8.0 @@ -631,10 +630,10 @@ function elgg_normalize_metastrings_options(array $options = array()) { // map the metadata_* options to metastring_* options $map = array( - 'names' => 'metastring_names', - 'values' => 'metastring_values', - 'case_sensitive' => 'metastring_case_sensitive', - 'owner_guids' => 'metastring_owner_guids', + 'names' => 'metastring_names', + 'values' => 'metastring_values', + 'case_sensitive' => 'metastring_case_sensitive', + 'owner_guids' => 'metastring_owner_guids', 'created_time_lower' => 'metastring_created_time_lower', 'created_time_upper' => 'metastring_created_time_upper', 'calculation' => 'metastring_calculation', -- cgit v1.2.3 From a3f0353600e749a16abbdab3cbc75b3469d6fd69 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Tue, 10 Jan 2012 16:54:49 -0800 Subject: Fixes #4269. Not using ElggBatch to delete metadata / annotations. Added unit tests for deleting annotations/md. Fixed an annoying inconsistency with "metastring/s" option in private functions. --- engine/lib/annotations.php | 2 +- engine/lib/metadata.php | 2 +- engine/lib/metastrings.php | 32 ++++++++++++++++++++++++++++++-- engine/tests/api/annotations.php | 24 ++++++++++++++++++++++++ engine/tests/api/metadata.php | 25 +++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 4 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index 7eb72612f..5049d455b 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -237,7 +237,7 @@ function elgg_disable_annotations(array $options) { return false; } - $options['metastrings_type'] = 'annotations'; + $options['metastring_type'] = 'annotations'; return elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback'); } diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index a097cd3ef..19e8aa3c8 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -324,7 +324,7 @@ function elgg_disable_metadata(array $options) { return false; } - $options['metastrings_type'] = 'metadata'; + $options['metastring_type'] = 'metadata'; return elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback'); } diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index d8fef6f1c..62b60e279 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -727,10 +727,38 @@ function elgg_batch_metastring_based_objects(array $options, $callback) { return false; } - $batch = new ElggBatch('elgg_get_metastring_based_objects', $options, $callback); - $r = $batch->callbackResult; + switch($options['metastring_type']) { + case 'metadata': + $objects = elgg_get_metadata($options); + break; + + case 'annotations': + $objects = elgg_get_annotations($options); + break; + + default: + return false; + } + + if (!is_array($objects)) { + $r = false; + } elseif (empty($objects)) { + // ElggBatch returns null if the results are an empty array + $r = null; + } else { + $r = true; + foreach($objects as $object) { + $r = $r && $callback($object); + } + } return $r; + +// // @todo restore once ElggBatch supports callbacks that delete rows. +// $batch = new ElggBatch('elgg_get_metastring_based_objects', $options, $callback); +// $r = $batch->callbackResult; +// +// return $r; } /** diff --git a/engine/tests/api/annotations.php b/engine/tests/api/annotations.php index d7551a0fa..947292970 100644 --- a/engine/tests/api/annotations.php +++ b/engine/tests/api/annotations.php @@ -43,4 +43,28 @@ class ElggCoreAnnotationAPITest extends ElggCoreUnitTest { $this->object->delete(); } + + public function testElggDeleteAnnotations() { + $e = new ElggObject(); + $e->save(); + + for ($i=0; $i<30; $i++) { + $e->annotate('test_annotation', rand(0,10000)); + } + + $options = array( + 'guid' => $e->getGUID(), + 'limit' => 0 + ); + + $annotations = elgg_get_annotations($options); + $this->assertIdentical(30, count($annotations)); + + $this->assertTrue(elgg_delete_annotations($options)); + + $annotations = elgg_get_annotations($options); + $this->assertTrue(empty($annotations)); + + $this->assertTrue($e->delete()); + } } diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php index f5b615ca8..be8ac269c 100644 --- a/engine/tests/api/metadata.php +++ b/engine/tests/api/metadata.php @@ -99,6 +99,31 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { $this->object->delete(); } + public function testElggDeleteMetadata() { + $e = new ElggObject(); + $e->save(); + + for ($i=0; $i<30; $i++) { + $name = "test_metadata" . rand(0, 10000); + $e->$name = rand(0, 10000); + } + + $options = array( + 'guid' => $e->getGUID(), + 'limit' => 0 + ); + + $md = elgg_get_metadata($options); + $this->assertIdentical(30, count($md)); + + $this->assertTrue(elgg_delete_metadata($options)); + + $md = elgg_get_metadata($options); + $this->assertTrue(empty($md)); + + $e->delete(); + } + protected function create_metastring($string) { global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; -- cgit v1.2.3