aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/pageowner.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-11 12:33:48 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-11 12:33:48 +0000
commit7b83d607a33cd2c258da20ea59dc9777f7cf50eb (patch)
tree2b8e1ba28c23cf9242fd4311ca0edb5bd6095e4d /engine/lib/pageowner.php
parent2d61fca50b21d7536bead7f833c716b8009c60a8 (diff)
downloadelgg-7b83d607a33cd2c258da20ea59dc9777f7cf50eb.tar.gz
elgg-7b83d607a33cd2c258da20ea59dc9777f7cf50eb.tar.bz2
Et voila: page ownership!
git-svn-id: https://code.elgg.org/elgg/trunk@160 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/pageowner.php')
-rw-r--r--engine/lib/pageowner.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php
new file mode 100644
index 000000000..af158db88
--- /dev/null
+++ b/engine/lib/pageowner.php
@@ -0,0 +1,62 @@
+<?php
+
+ /**
+ * Elgg page owner library
+ * Contains functions for managing page ownership
+ *
+ * @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/
+ */
+
+ /**
+ * Gets the page owner for the current page.
+ * @uses $CONFIG
+ * @return id The ID of the current page owner (-1 if none).
+ */
+
+ function page_owner() {
+
+ global $CONFIG;
+ if ($username = get_input("username")) {
+ $user = user_from_username($username);
+ return $user->id;
+ }
+ if ($owner = get_input("owner_id")) {
+ return (int) $owner;
+ }
+ if (!empty($CONFIG->page_owner_handlers) && is_array($CONFIG->page_owner_handlers)) {
+ foreach($CONFIG->page_owner_handlers as $handler) {
+ if ($id = $handler()) {
+ return $id;
+ }
+ }
+ }
+ return -1;
+
+ }
+
+ /**
+ * Adds a page owner handler - a function that will
+ * return the page owner 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_handler($functionname) {
+
+ global $CONFIG;
+ if (empty($CONFIG->page_owner_handlers)) {
+ $CONFIG->page_owner_handlers = array();
+ }
+ if (is_callable($functionname)) {
+ $CONFIG->page_owner_handlers[] = $functionname;
+ }
+
+ }
+
+?> \ No newline at end of file