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 --- alltags.php | 86 +++++++++++++++++++++++++++++-------------------------------- 1 file changed, 41 insertions(+), 45 deletions(-) (limited to 'alltags.php') diff --git a/alltags.php b/alltags.php index dc84cf3..45b13ab 100644 --- a/alltags.php +++ b/alltags.php @@ -1,23 +1,23 @@ isLoggedOn()) { - $hashtext .= $userservice->getCurrentUserID(); - } - $hash = md5($hashtext); - - // Cache for an hour - $cacheservice->Start($hash, 3600); + // Generate hash for caching on + $hashtext = $_SERVER['REQUEST_URI']; + if ($userservice->isLoggedOn()) { + $hashtext .= $userservice->getCurrentUserID(); + } + $hash = md5($hashtext); + + // Cache for an hour + $cacheservice->Start($hash, 3600); } // Header variables $pagetitle = T_('All Tags'); if (isset($user) && $user != '') { - if (is_int($user)) { - $userid = intval($user); - } else { - if ($userinfo = $userservice->getObjectUserByUsername($user)) { - $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); + exit(); + } + + $pagetitle .= ': '. ucfirst($user); } else { - $userid = NULL; + $userid = NULL; } $tags =& $b2tservice->getTags($userid); -$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder()); +$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder()); $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'); @@ -84,7 +80,7 @@ $tplVars['subtitle'] = $pagetitle; $templateservice->loadTemplate('tags.tpl', $tplVars); if ($usecache) { - // Cache output if existing copy has expired - $cacheservice->End($hash); + // Cache output if existing copy has expired + $cacheservice->End($hash); } ?> -- cgit v1.2.3-54-g00ecf