Improved getComplexLoggedInAs()

Now shows both links if both private namespace and public page exist or
defaults back to a simple link to the one that exist or standard string
if none exist
This commit is contained in:
Simon DELAGE 2014-09-19 18:29:51 +02:00
parent e21925e236
commit 242ee4b4eb
2 changed files with 16 additions and 2 deletions

View file

@ -56,7 +56,21 @@ class helper_plugin_userhomepage extends DokuWiki_Plugin {
function getComplexLoggedInAs() {
global $INFO;
global $lang;
return '<li>'.$lang['loggedinas'].' : <a href="'.wl($this->getPrivateID()).'" class="uhp_private" rel="nofollow" title="'.$this->getLang('privatenamespace').'">'.$INFO['userinfo']['name'].'</a> (<a href="'.wl($this->getPublicID()).'" class="uhp_public" rel="nofollow" title="'.$this->getLang('publicpage').'">'.$_SERVER['REMOTE_USER'].'</a>)</li>';
// If user's private namespace and public page exist, return a 'Logged in as' string with both style links)
if ((page_exists($this->getPrivateID())) && (page_exists($this->getPublicID()))) {
return '<li>'.$lang['loggedinas'].' : <a href="'.wl($this->getPrivateID()).'" class="uhp_private" rel="nofollow" title="'.$this->getLang('privatenamespace').'">'.$INFO['userinfo']['name'].'</a> (<a href="'.wl($this->getPublicID()).'" class="uhp_public" rel="nofollow" title="'.$this->getLang('publicpage').'">'.$_SERVER['REMOTE_USER'].'</a>)</li>';
// Else if only private namespace exists, return 'Logged in as' string with private namespace link
} elseif (page_exists($this->getPrivateID())) {
return $this->getPrivateLink("loggedinas");
// Else if only ppublic page exists, return 'Logged in as' string with public page link
} elseif (page_exists($this->getPublicID())) {
return $this->getPublicLink("loggedinas");
// Else default back to standard string
} else {
echo '<li class="user">';
tpl_userinfo(); /* 'Logged in as ...' */
echo '</li>';
}
}
function getButton($type="private") {

View file

@ -1,7 +1,7 @@
base userhomepage
author Simon Delage
email simon.geekitude@gmail.com
date 2014-09-19
date 2014-09-20
name User Homepage
desc Automatically create user's private namespace and/or public page and redirects users to private namespace on login.
url https://www.dokuwiki.org/plugin:userhomepage