aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-16 14:45:16 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-16 14:45:16 +0000
commitcdabdd5951626da5b1bd184dca50716248f32c31 (patch)
tree045225c7beb2d007fa25b2b431b9d0e64f3eda13
parent2216b3352edd95a4df2745996e7d3c741efc3284 (diff)
downloadelgg-cdabdd5951626da5b1bd184dca50716248f32c31.tar.gz
elgg-cdabdd5951626da5b1bd184dca50716248f32c31.tar.bz2
Generic entity view system
git-svn-id: https://code.elgg.org/elgg/trunk@474 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/entities.php26
-rw-r--r--engine/lib/users.php4
-rw-r--r--entities/index.php37
-rw-r--r--languages/en.php4
4 files changed, 67 insertions, 4 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 3fbd6587c..2cbdc2e73 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -900,11 +900,35 @@
return trigger_plugin_hook('permissions_check',$entity->type,array('entity' => $entity, 'user' => $user),false);
}
+
+ /**
+ * Page handler for generic entities view system
+ *
+ * @param array $page Page elements from pain page handler
+ */
+ function entities_page_handler($page) {
+ if (isset($page[0])) {
+ global $CONFIG;
+ set_input('guid',$page[0]);
+ @include($CONFIG->path . "entities/index.php");
+ }
+ }
+
+ /**
+ * Entities init function; establishes the page handler
+ *
+ */
+ function entities_init() {
+ register_page_handler('view','entities_page_handler');
+ }
/** Register the import hook */
register_plugin_hook("import", "all", "import_entity_plugin_hook", 0);
/** Register the hook, ensuring entities are serialised first */
- register_plugin_hook("export", "all", "export_entity_plugin_hook", 0);
+ register_plugin_hook("export", "all", "export_entity_plugin_hook", 0);
+
+ /** Register init system event **/
+ register_event_handler('init','system','entities_init');
?> \ No newline at end of file
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 166225b9e..5669da06d 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -491,10 +491,10 @@
if (!empty($guid)) // Fixes "Exception thrown without stack frame" when db_select fails
$result = get_entity($guid);
- if (($result) && (!($result instanceof ElggUser)))
+ if ((!empty($result)) && (!($result instanceof ElggUser)))
throw new InvalidParameterException("GUID:$guid is not an ElggUser");
- if ($result)
+ if (!empty($result))
return $result;
return false;
diff --git a/entities/index.php b/entities/index.php
new file mode 100644
index 000000000..6c2d4fd0d
--- /dev/null
+++ b/entities/index.php
@@ -0,0 +1,37 @@
+<?php
+
+ /**
+ * Generic entity viewer
+ * Given a GUID, this page will try and display any entity
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+ // Get the GUID of the entity we want to view
+ $guid = (int) get_input('guid');
+
+ // Get the entity, if possible
+ if ($entity = get_entity($guid)) {
+
+ // Set the body to be the full view of the entity, and the title to be its title
+ $body = elgg_view_entity($entity,"",true);
+
+ // Otherwise?
+ } else {
+
+ $body = elgg_echo('notfound');
+
+ }
+
+ // Display the page
+ page_draw("", $body);
+
+?> \ No newline at end of file
diff --git a/languages/en.php b/languages/en.php
index f584b56a6..4339d9be9 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -21,6 +21,8 @@
'actionundefined' => "The requested action (%s) was not defined in the system.",
'actionloggedout' => "Sorry, you cannot perform this action while logged out.",
+ 'notfound' => "The requested resource could not be found, or you do not have access to it.",
+
/**
* User details
*/
@@ -61,7 +63,7 @@
'update' => "Update",
'edit' => "Edit",
'delete' => "Delete",
- 'Load' => "Load",
+ 'load' => "Load",
/**
* Generic data words