aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-02 09:43:55 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-02 09:43:55 +0000
commite0d9fa933f8e33ff65492876c4bbbe7c93e9e2f4 (patch)
tree51a766c86f3d0de794426365a765e59816607bbe /engine
parenteeb50301199b9e1370e3686ac45b2a80f4d84e5a (diff)
downloadelgg-e0d9fa933f8e33ff65492876c4bbbe7c93e9e2f4.tar.gz
elgg-e0d9fa933f8e33ff65492876c4bbbe7c93e9e2f4.tar.bz2
Introducing page_owner_entity
git-svn-id: https://code.elgg.org/elgg/trunk@328 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/pageowner.php54
1 files changed, 53 insertions, 1 deletions
diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php
index 3cc0130f4..9d6231082 100644
--- a/engine/lib/pageowner.php
+++ b/engine/lib/pageowner.php
@@ -15,7 +15,7 @@
/**
* Gets the page owner for the current page.
* @uses $CONFIG
- * @return int|false The current page owner guid (false if none).
+ * @return int|false The current page owner guid (0 if none).
*/
function page_owner() {
@@ -46,6 +46,39 @@
}
+ /**
+ * Gets the page owner for the current page.
+ * @uses $CONFIG
+ * @return ElggUser|false The current page owner (false if none).
+ */
+ function page_owner_entity() {
+
+ global $CONFIG;
+ if ($username = get_input("username")) {
+ if ($user = get_user_by_username($username)) {
+ return $user;
+ } else {
+ return false;
+ }
+ }
+ if ($owner = get_input("owner_id")) {
+ if ($user = get_user($owner)) {
+ return $user;
+ } else {
+ return false;
+ }
+ }
+ if (!empty($CONFIG->page_owner_entity_handlers) && is_array($CONFIG->page_owner_entity_handlers)) {
+ foreach($CONFIG->page_owner_entity_handlers as $handler) {
+ if ($user = $handler()) {
+ return $user;
+ }
+ }
+ }
+ return false;
+
+ }
+
/**
* Adds a page owner handler - a function that will
* return the page owner if required
@@ -66,4 +99,23 @@
}
+ /**
+ * Adds a page owner entity handler - a function that will
+ * return the page owner ElggUser if required
+ * (Such functions are required to return false if they don't know)
+ * @uses $CONFIG
+ * @param string $functionname The name of the function to call
+ */
+ function add_page_owner_entity_handler($functionname) {
+
+ global $CONFIG;
+ if (empty($CONFIG->page_owner_entity_handlers)) {
+ $CONFIG->page_owner_entity_handlers = array();
+ }
+ if (is_callable($functionname)) {
+ $CONFIG->page_owner_entity_handlers[] = $functionname;
+ }
+
+ }
+
?> \ No newline at end of file