aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-04-09 17:07:27 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-04-09 17:07:27 +0000
commiteeb7616c61cc38af026a39bf9a6932801675c0c9 (patch)
tree50ba1151c0ca19cc272de3aeacc3f5df24de4be1 /engine/lib
parent1a0b866ce9db77abdd49c65def81a4c40393dbe0 (diff)
downloadelgg-eeb7616c61cc38af026a39bf9a6932801675c0c9.tar.gz
elgg-eeb7616c61cc38af026a39bf9a6932801675c0c9.tar.bz2
Forward user if a page owner is inaccessible (Refs #969)
git-svn-id: https://code.elgg.org/elgg/trunk@3200 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/pageowner.php49
1 files changed, 35 insertions, 14 deletions
diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php
index d78aa3301..c2b98c284 100644
--- a/engine/lib/pageowner.php
+++ b/engine/lib/pageowner.php
@@ -20,37 +20,58 @@
function page_owner() {
- global $CONFIG;
+ global $CONFIG;
+
+ $returnval = NULL;
$setpageowner = set_page_owner();
if ($setpageowner !== false) {
return $setpageowner;
}
- if ($username = get_input("username")) {
+ if ((!isset($returnval)) && ($username = get_input("username"))) {
if (substr_count($username,'group:')) {
preg_match('/group\:([0-9]+)/i',$username,$matches);
$guid = $matches[1];
- if ($entity = get_entity($guid)) {
- return $entity->getGUID();
+ if ($entity = get_entity($guid)) {
+ $returnval = $entity->getGUID();
}
}
- if ($user = get_user_by_username($username)) {
- return $user->getGUID();
+ if ((!isset($returnval)) && ($user = get_user_by_username($username))) {
+ $returnval = $user->getGUID();
}
- }
- if ($owner = get_input("owner_guid")) {
+ }
+
+
+ if ((!isset($returnval)) && ($owner = get_input("owner_guid"))) {
if ($user = get_entity($owner)) {
- return $user->getGUID();
+ $returnval = $user->getGUID();
}
- }
- if (!empty($CONFIG->page_owner_handlers) && is_array($CONFIG->page_owner_handlers)) {
+ }
+
+
+ if ((!isset($returnval)) && (!empty($CONFIG->page_owner_handlers) && is_array($CONFIG->page_owner_handlers))) {
foreach($CONFIG->page_owner_handlers as $handler) {
- if ($guid = $handler()) {
- return $guid;
+ if ((!isset($returnval)) && ($guid = $handler())) {
+ $returnval = $guid;
}
}
- }
+ }
+
+ if (isset($returnval)) {
+
+ // Check if this is obtainable, forwarding if not.
+ /*
+ * If the owner entity has been set, but is inaccessible then we forward to the dashboard. This
+ * catches a bunch of WSoDs. It doesn't have much of a performance hit since 99.999% of the time the next thing
+ * a page does after calling this function is to retrieve the owner entity - which is of course cashed.
+ */
+ $owner_entity = get_entity($returnval);
+ if (!$owner_entity) forward();
+
+ return $returnval;
+ }
+
return 0;
}