aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/pageowner.php62
-rw-r--r--engine/lib/users.php13
2 files changed, 75 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
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 24ded8ce5..7a0de2af0 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -343,6 +343,19 @@
}
/**
+ * Gets a user with a particular username, if they exist
+ *
+ * @param string $username The user's username
+ * @return ElggUser or false
+ */
+ function get_user_from_username($username) {
+ global $CONFIG;
+ $username = (int) sanitise_string($username);
+ return row_to_elgguser(get_data_row("select * from {$CONFIG->dbprefix}users where username = '{$username}'"));
+
+ }
+
+ /**
* Enter description here...
*
* @param unknown_type $criteria