From 24ab0f6487d7a3883af126cc22f5d9d08acf3a80 Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 15 Jan 2009 18:05:08 +0000 Subject: Minor Refactoring: add getIdFromUser() git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@238 b3834d28-1941-0410-a4f8-b48e95affb8f --- populartags.php | 92 +++++++++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 48 deletions(-) (limited to 'populartags.php') diff --git a/populartags.php b/populartags.php index c20cabc..7938027 100644 --- a/populartags.php +++ b/populartags.php @@ -1,23 +1,23 @@ isLoggedOn()) { - $hashtext .= $currentUser->getId(); - if ($currentUser->getUsername() == $user) { - $hashtext .= $user; - } - } - $hash = md5($hashtext); - - // Cache for an hour - $cacheservice->Start($hash, 3600); + // Generate hash for caching on + $hashtext = $_SERVER['REQUEST_URI']; + if ($userservice->isLoggedOn()) { + $hashtext .= $currentUser->getId(); + if ($currentUser->getUsername() == $user) { + $hashtext .= $user; + } + } + $hash = md5($hashtext); + + // Cache for an hour + $cacheservice->Start($hash, 3600); } // Header variables $pagetitle = T_('Popular Tags'); if (isset($user) && $user != '') { - if (is_int($user)) { - $userid = intval($user); - } else { - $userinfo = $userservice->getObjectUserByUsername($user); - if ($userinfo != '') { - $userid = $userinfo->getId(); - } else { - $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); - $templateservice->loadTemplate('error.404.tpl', $tplVars); - //throw a 404 error - exit(); - } - } - $pagetitle .= ': '. ucfirst($user); + + $userid = $userservice->getIdFromUser($user); + if($userid == NULL) { + $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); + $templateservice->loadTemplate('error.404.tpl', $tplVars); + //throw a 404 error + exit(); + } + + $pagetitle .= ': '. ucfirst($user); } else { - $userid = NULL; + $userid = NULL; } $tags = $b2tservice->getPopularTags($userid, 150); -$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc')); +$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc')); $tplVars['user'] = $user; if (isset($userid)) { - $tplVars['cat_url'] = createURL('bookmarks', '%s/%s'); + $tplVars['cat_url'] = createURL('bookmarks', '%s/%s'); } else { - $tplVars['cat_url'] = createURL('tags', '%2$s'); + $tplVars['cat_url'] = createURL('tags', '%2$s'); } $tplVars['sidebar_blocks'] = array('linked'); @@ -81,8 +77,8 @@ $tplVars['loadjs'] = true; $templateservice->loadTemplate('tags.tpl', $tplVars); -if ($usecache) { - // Cache output if existing copy has expired - $cacheservice->End($hash); +if ($usecache) { + // Cache output if existing copy has expired + $cacheservice->End($hash); } ?> -- cgit v1.2.3