From d45a24be28b2eb2d0c2731708b589788a5b87215 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 22 Aug 2010 21:11:36 +0000 Subject: Merged r6671:6683 from 1.7 branch to trunk git-svn-id: http://code.elgg.org/elgg/trunk@6847 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 21 +++++++++++++-------- engine/lib/metadata.php | 2 +- engine/lib/output.php | 20 +++++++------------- engine/lib/views.php | 38 ++++++++++++++++++++++++++------------ engine/lib/widgets.php | 15 +++++++-------- 5 files changed, 54 insertions(+), 42 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index b684ae822..1750f12e1 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -212,18 +212,23 @@ abstract class ElggEntity implements */ public function set($name, $value) { if (array_key_exists($name, $this->attributes)) { - // Check that we're not trying to change the guid! - if ((array_key_exists('guid', $this->attributes)) && ($name=='guid')) { - return false; + // Certain properties should not be manually changed! + switch ($name) { + case 'guid': + case 'time_created': + case 'time_updated': + case 'last_action': + return FALSE; + break; + default: + $this->attributes[$name] = $value; + break; } - - $this->attributes[$name] = $value; - } - else { + } else { return $this->setMetaData($name, $value); } - return true; + return TRUE; } /** diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 4d489178f..a6843e598 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -989,7 +989,7 @@ $count = FALSE, $case_sensitive = TRUE) { * @return string A list of entities suitable for display */ function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = ELGG_ENTITIES_ANY_VALUE, $entity_subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true, $case_sensitive = true ) { - elgg_deprecated_notice('get_entities_from_metadata_multi() was deprecated by elgg_get_entities_from_metadata()!', 1.8); + elgg_deprecated_notice('list_entities_from_metadata() was deprecated by elgg_list_entities_from_metadata()!', 1.8); $offset = (int) get_input('offset'); $limit = (int) $limit; diff --git a/engine/lib/output.php b/engine/lib/output.php index 3d08f2a28..640ada1cf 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -1,7 +1,7 @@ $time)); -} - /** * Strip tags and offer plugins the chance. * Plugins register for output:strip_tags plugin hook. @@ -268,4 +262,4 @@ function elgg_strip_tags($string) { $string = trigger_plugin_hook('format', 'strip_tags', $params, $string); return $string; -} \ No newline at end of file +} diff --git a/engine/lib/views.php b/engine/lib/views.php index 68ddf49e1..76d2a57da 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -3,6 +3,7 @@ * Provides interfaces for Elgg's views system * * @package Elgg + * @subpackage Core */ $CURRENT_SYSTEM_VIEWTYPE = ""; @@ -67,6 +68,7 @@ function elgg_get_viewtype() { * This is useful for alternate html viewtypes (such as for mobile devices) * * @param string $viewtype The viewtype to register + * @since 1.7.2 */ function elgg_register_viewtype_fallback($viewtype) { global $CONFIG; @@ -87,6 +89,7 @@ function elgg_register_viewtype_fallback($viewtype) { * * @param string $viewtype * @return boolean + * @since 1.7.2 */ function elgg_does_viewtype_fallback($viewtype) { global $CONFIG; @@ -351,8 +354,7 @@ function elgg_view_register_simplecache($viewname) { * Regenerates the simple cache. * * @param string $viewtype Optional viewtype to regenerate - * @see elgg_view_register_simplecache - * + * @see elgg_view_register_simplecache() */ function elgg_view_regenerate_simplecache($viewtype = NULL) { global $CONFIG; @@ -409,10 +411,8 @@ function elgg_view_regenerate_simplecache($viewtype = NULL) { /** * Enables the simple cache. * - * @see elgg_view_register_simplecache - * + * @see elgg_view_register_simplecache() */ - function elgg_view_enable_simplecache() { global $CONFIG; @@ -424,8 +424,7 @@ function elgg_view_enable_simplecache() { /** * Disables the simple cache. * - * @see elgg_view_register_simplecache - * + * @see elgg_view_register_simplecache() */ function elgg_view_disable_simplecache() { global $CONFIG; @@ -449,9 +448,10 @@ function elgg_view_disable_simplecache() { /** * Internal function for retrieving views used by elgg_view_tree * - * @param unknown_type $dir - * @param unknown_type $base - * @return unknown + * @param string $dir + * @param string $base + * @return array + * @since 1.7 */ function elgg_get_views($dir, $base) { $return = array(); @@ -802,6 +802,19 @@ function elgg_view_title($title, $submenu = false) { return $title; } +/** + * Displays a UNIX timestamp in a friendly way + * + * @see elgg_get_friendly_time() + * + * @param int $time A UNIX epoch timestamp + * @return string The friendly time HTML + * @since 1.7.2 + */ +function elgg_view_friendly_time($time) { + return elgg_view('output/friendlytime', array('time' => $time)); +} + /** * Automatically views comments and a comment form relating to the given entity @@ -848,7 +861,7 @@ function elgg_view_listing($icon, $info) { * * function my_template_function(string $view, array $vars = array()) * - * @see elgg_view + * @see elgg_view() * * @param string $function_name The name of the function to pass to. * @return true|false @@ -1013,7 +1026,8 @@ function autoregister_views($view_base, $folder, $base_location_path, $viewtype) } /** - * Outputs a representation of a full 'page' (which might be an HTML page, RSS file, etc, depending on the current view) + * Returns a representation of a full 'page' (which might be an HTML page, + * RSS file, etc, depending on the current viewtype) * * @param string $title * @param string $body diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index 7884f263a..1862ef7e4 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -201,9 +201,9 @@ function display_widget(ElggObject $widget) { } /** - * Add a new widget + * Add a new widget instance * - * @param int $user_guid User GUID to associate this widget with + * @param int $entity_guid GUID of entity that owns this widget * @param string $handler The handler for this widget * @param string $context The page context for this widget * @param int $order The order to display this widget in @@ -211,15 +211,15 @@ function display_widget(ElggObject $widget) { * @param int $access_id If not specified, it is set to the default access level * @return true|false Depending on success */ -function add_widget($user_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) { - if (empty($user_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) { +function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) { + if (empty($entity_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) { return false; } - if ($user = get_user($user_guid)) { + if ($entity = get_entity($entity_guid)) { $widget = new ElggWidget; - $widget->owner_guid = $user_guid; - $widget->container_guid = $user_guid; + $widget->owner_guid = $entity_guid; + $widget->container_guid = $entity_guid; if (isset($access_id)) { $widget->access_id = $access_id; } else { @@ -237,7 +237,6 @@ function add_widget($user_guid, $handler, $context, $order = 0, $column = 1, $ac // save_widget_location($widget, $order, $column); return true; - } return false; -- cgit v1.2.3