aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-17 10:44:26 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-17 10:44:26 +0000
commitaf2e2ae369e0ab13a99b83a928363f6d7f48f715 (patch)
tree373850213656c96cb07a726f00509f2c5e774f7f /engine/lib/entities.php
parentddbe1c9698031a8017e073048bc48d5268129c78 (diff)
downloadelgg-af2e2ae369e0ab13a99b83a928363f6d7f48f715.tar.gz
elgg-af2e2ae369e0ab13a99b83a928363f6d7f48f715.tar.bz2
Closes #160
git-svn-id: https://code.elgg.org/elgg/trunk@1452 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index c93b1c2c7..57578362c 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1289,6 +1289,45 @@
return true;
}
+
+ /**
+ * A plugin hook to get certain volitile (generated on the fly) attributes about an entity in order to export them.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params The parameters, passed 'guid' and 'varname'
+ * @return unknown
+ */
+ function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ $guid = (int)$params['guid'];
+ $variable_name = sanitise_string($params['varname']);
+
+ if (($hook == 'volatile') && ($entity_type == 'metadata'))
+ {
+ if (($guid) && ($variable_name))
+ {
+ switch ($variable_name)
+ {
+ case 'renderedentity' :
+ elgg_set_viewtype('default');
+ $view = elgg_view_entity(get_entity($guid));
+ elgg_set_viewtype();
+
+ $tmp = new ElggMetadata();
+ $tmp->type = 'volatile';
+ $tmp->name = 'renderedentity';
+ $tmp->value = $view;
+ $tmp->entity_guid = $guid;
+
+ return $tmp;
+
+ break;
+ }
+ }
+ }
+ }
/**
* Handler called by trigger_plugin_hook on the "export" event.
@@ -1563,6 +1602,9 @@
/** Register the hook, ensuring entities are serialised first */
register_plugin_hook("export", "all", "export_entity_plugin_hook", 0);
+ /** Hook to get certain named bits of volatile data about an entity */
+ register_plugin_hook('volatile', 'metadata', 'volatile_data_export_plugin_hook');
+
/** Register init system event **/
register_elgg_event_handler('init','system','entities_init');