diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-29 14:06:38 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-29 14:06:38 +0000 |
commit | f73298eacabf0745598ddc24af0e5679bed6d6cc (patch) | |
tree | 3162a30403a91caa5105363dffd617c4168ca437 /mod/blog/lib/blog.php | |
parent | 084a6003976c4fe7b1fa3f72186eff5098e0a478 (diff) | |
download | elgg-f73298eacabf0745598ddc24af0e5679bed6d6cc.tar.gz elgg-f73298eacabf0745598ddc24af0e5679bed6d6cc.tar.bz2 |
more clean up of the blog plugin - removed unused functions and moved the url forwarder into library
git-svn-id: http://code.elgg.org/elgg/trunk@7741 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/lib/blog.php')
-rw-r--r-- | mod/blog/lib/blog.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php index c79c863d3..4f401ed23 100644 --- a/mod/blog/lib/blog.php +++ b/mod/blog/lib/blog.php @@ -419,3 +419,55 @@ function blog_get_blog_months($user_guid = NULL, $container_guid = NULL) { return get_data($q); } + +/** + * Forward to the new style of URLs + * + * @param string $page + */ +function blog_url_forwarder($page) { + global $CONFIG; + + // group usernames + if (substr_count($page[0], 'group:')) { + preg_match('/group\:([0-9]+)/i', $page[0], $matches); + $guid = $matches[1]; + $entity = get_entity($guid); + if ($entity) { + $url = "{$CONFIG->wwwroot}pg/blog/group/$guid/owner"; + register_error(elgg_echo("changebookmark")); + forward($url); + } + } + + // user usernames + $user = get_user_by_username($page[0]); + if (!$user) { + return; + } + + if (!isset($page[1])) { + $page[1] = 'owner'; + } + + switch ($page[1]) { + case "read": + $url = "{$CONFIG->wwwroot}pg/blog/view/{$page[2]}/{$page[3]}"; + break; + case "archive": + $url = "{$CONFIG->wwwroot}pg/blog/archive/{$page[0]}/{$page[2]}/{$page[3]}"; + break; + case "friends": + $url = "{$CONFIG->wwwroot}pg/blog/friends/{$page[0]}"; + break; + case "new": + $url = "{$CONFIG->wwwroot}pg/blog/new/$user->guid"; + break; + case "owner": + $url = "{$CONFIG->wwwroot}pg/blog/owner/{$page[0]}"; + break; + } + + register_error(elgg_echo("changebookmark")); + forward($url); +} |