aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-11-15 00:56:51 -0500
committerSteve Clay <steve@mrclay.org>2012-11-15 00:56:51 -0500
commit5cce825ba165da9430b514a9c11532968e6c5af8 (patch)
tree8732d636ab291855f6fb2c82836d8675efd4f7e3
parent4f01b88b9fc1fe476189d53df7a34303502ba17e (diff)
downloadelgg-5cce825ba165da9430b514a9c11532968e6c5af8.tar.gz
elgg-5cce825ba165da9430b514a9c11532968e6c5af8.tar.bz2
Blog forwarder cleanup & viewtype propagation
-rw-r--r--mod/blog/lib/blog.php38
1 files changed, 22 insertions, 16 deletions
diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php
index 4dcc7d56e..db6b7846f 100644
--- a/mod/blog/lib/blog.php
+++ b/mod/blog/lib/blog.php
@@ -408,25 +408,31 @@ function blog_prepare_form_vars($post = NULL, $revision = NULL) {
* @param string $page
*/
function blog_url_forwarder($page) {
- global $CONFIG;
+
+ $viewtype = elgg_get_viewtype();
+ $qs = ($viewtype === 'default') ? "" : "?view=$viewtype";
+
+ $url = "blog/all";
+
+ // easier to work with & no notices
+ $page = array_pad($page, 4, "");
// group usernames
- if (substr_count(implode('/', $page), 'group:')) {
- preg_match('/group\:([0-9]+)/i', implode('/', $page), $matches);
+ if (preg_match('~/group\:([0-9]+)/~', "/{$page[0]}/{$page[1]}/", $matches)) {
$guid = $matches[1];
$entity = get_entity($guid);
- if ($entity) {
- if (isset($page[2])) {
- $url = "{$CONFIG->wwwroot}blog/view/$page[2]/?view=" . elgg_get_viewtype();
+ if (elgg_instanceof($entity, 'group')) {
+ if (!empty($page[2])) {
+ $url = "blog/view/$page[2]/";
} else {
- $url = "{$CONFIG->wwwroot}blog/group/$guid/all?view=" . elgg_get_viewtype();
+ $url = "blog/group/$guid/all";
}
register_error(elgg_echo("changebookmark"));
- forward($url);
+ forward($url . $qs);
}
}
- if (!isset($page[0])) {
+ if (empty($page[0])) {
return;
}
@@ -436,28 +442,28 @@ function blog_url_forwarder($page) {
return;
}
- if (!isset($page[1])) {
+ if (empty($page[1])) {
$page[1] = 'owner';
}
switch ($page[1]) {
case "read":
- $url = "{$CONFIG->wwwroot}blog/view/{$page[2]}/{$page[3]}";
+ $url = "blog/view/{$page[2]}/{$page[3]}";
break;
case "archive":
- $url = "{$CONFIG->wwwroot}blog/archive/{$page[0]}/{$page[2]}/{$page[3]}";
+ $url = "blog/archive/{$page[0]}/{$page[2]}/{$page[3]}";
break;
case "friends":
- $url = "{$CONFIG->wwwroot}blog/friends/{$page[0]}";
+ $url = "blog/friends/{$page[0]}";
break;
case "new":
- $url = "{$CONFIG->wwwroot}blog/add/$user->guid";
+ $url = "blog/add/$user->guid";
break;
case "owner":
- $url = "{$CONFIG->wwwroot}blog/owner/{$page[0]}";
+ $url = "blog/owner/{$page[0]}";
break;
}
register_error(elgg_echo("changebookmark"));
- forward($url);
+ forward($url . $qs);
}