aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/pageowner.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/pageowner.php')
-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