blob: af158db88fa5edb8a8d109a17ca2daa3a45eae85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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;
}
}
?>
|