diff options
-rw-r--r-- | engine/lib/dummy.php | 29 | ||||
-rw-r--r-- | engine/lib/pageowner.php | 4 | ||||
-rw-r--r-- | engine/lib/sessions.php | 14 | ||||
-rw-r--r-- | views/default/page_elements/title.php | 2 |
4 files changed, 41 insertions, 8 deletions
diff --git a/engine/lib/dummy.php b/engine/lib/dummy.php new file mode 100644 index 000000000..a7f8760e0 --- /dev/null +++ b/engine/lib/dummy.php @@ -0,0 +1,29 @@ +<?php + /** + * Dummy class. + * This function contains dummy functions and classes which return safe dummy values. Essentially this is + * to make sure that things like calling echo page_owner_entity()->name don't cause a WSoD. + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + /** + * Dummy class. + * For every function call, get and set this function returns false. + */ + class ElggDummy { + + public function __call($method, $args) { + return false; + } + + function __get($name) { return false; } + + function __set($name, $value) { return false; } + } +?>
\ No newline at end of file diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php index 3f867e750..46394c8c9 100644 --- a/engine/lib/pageowner.php +++ b/engine/lib/pageowner.php @@ -67,8 +67,8 @@ if ($page_owner > 0)
return get_entity($page_owner);
- return false;
-
+ //return false;
+ return new ElggDummy();
}
/**
diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index 87e2f931d..5b08a6e5b 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -184,14 +184,16 @@ $code = $_COOKIE['elggperm'];
$code = md5($code);
$_SESSION['guid'] = 0;
- $_SESSION['id'] = 0;
+ $_SESSION['id'] = 0; + $_SESSION['user'] = new ElggDummy();
if ($user = get_user_by_code($code)) {
$_SESSION['user'] = $user;
$_SESSION['id'] = $user->getGUID();
$_SESSION['guid'] = $_SESSION['id'];
$_SESSION['code'] = $_COOKIE['elggperm'];
}
- } else {
+ } else { + $_SESSION['user'] = new ElggDummy();
$_SESSION['id'] = 0;
$_SESSION['guid'] = 0;
}
@@ -201,11 +203,13 @@ if ($user = get_user_by_code($code)) {
$_SESSION['user'] = $user;
} else {
- unset($_SESSION['user']);
+ //unset($_SESSION['user']); + $_SESSION['user'] = new ElggDummy();
$_SESSION['guid'] = 0;
$_SESSION['id'] = 0;
}
- } else {
+ } else { + $_SESSION['user'] = new ElggDummy();
$_SESSION['guid'] = 0;
$_SESSION['id'] = 0;
}
@@ -213,7 +217,7 @@ if ($_SESSION['id'] > 0) {
set_last_action($_SESSION['id']);
}
-
+ print_r($_SESSION);
register_action("login",true);
register_action("logout");
diff --git a/views/default/page_elements/title.php b/views/default/page_elements/title.php index 2e8e3e4b7..845b47dc7 100644 --- a/views/default/page_elements/title.php +++ b/views/default/page_elements/title.php @@ -19,7 +19,7 @@ $submenu = get_submenu(); // elgg_view('canvas_header/submenu'); if (!empty($submenu)) $submenu = "<ul>" . $submenu . "</ul>"; - if ((!$_SESSION['user']) || ($page_owner && $page_owner_user->guid != $_SESSION['user']->getGUID())) { + if ($page_owner && $page_owner_user->guid != $_SESSION['user']->getGUID()) { $info = "<h2>" . $vars['title'] . "</h2>"; if($page_owner_user instanceOf ElggGroup) { $display = "<div id=\"content_area_group_title\">" . $info . "</div>"; |