Added getAnyPublicLink()

This commit is contained in:
Simon DELAGE 2015-02-23 03:01:03 +01:00
parent 1e30b8bfc0
commit 4a101dedff
2 changed files with 26 additions and 4 deletions

View file

@ -24,9 +24,13 @@ class helper_plugin_userhomepage extends DokuWiki_Plugin {
return $this->private_page = $this->private_ns.':'.$this->privateStart();
}
// Returns the ID of current user's public page (even if it doesn't exist)
function getPublicID() {
return $this->public_page = cleanID($this->getConf('public_pages_ns').':'. $_SERVER['REMOTE_USER']);
// Returns the ID of any (or current) user's public page (even if it doesn't exist)
function getPublicID($userLogin=null) {
if ($user) {
return $this->public_page = cleanID($this->getConf('public_pages_ns').':'.$userLogin);
} else {
return $this->public_page = cleanID($this->getConf('public_pages_ns').':'.$_SERVER['REMOTE_USER']);
}
}
function getPrivateLink($param=null) {
@ -71,6 +75,24 @@ class helper_plugin_userhomepage extends DokuWiki_Plugin {
}
}
function getAnyPublicLink($userLogin) {
// global $INFO;
global $lang;
if ($userLogin != null) {
$publicID = $this->getPublicID($userLogin);
$result = '<a href="'.wl($publicID).'" class="uhp_public ';
if (page_exists($publicID)) {
$result = $result.'wikilink1';
} else {
$result = $result.'wikilink2';
}
$result = $result.'" rel="nofollow" title="'.$this->getLang('publicpage').'">'.editorinfo($userLogin, true).'</a>';
return $result;
} else {
return false;
}
}
function getButton($type="private") {
global $INFO;
global $lang;

View file

@ -1,7 +1,7 @@
base userhomepage
author Simon Delage
email simon.geekitude@gmail.com
date 2015-02-11
date 2015-02-23
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