diff --git a/public_html/conf/LSauth/config.LSauthMethod_anonymous.php b/public_html/conf/LSauth/config.LSauthMethod_anonymous.php new file mode 100644 index 00000000..e8e8a5a6 --- /dev/null +++ b/public_html/conf/LSauth/config.LSauthMethod_anonymous.php @@ -0,0 +1,32 @@ + diff --git a/public_html/includes/class/class.LSauth.php b/public_html/includes/class/class.LSauth.php index 27274204..dd16be5b 100644 --- a/public_html/includes/class/class.LSauth.php +++ b/public_html/includes/class/class.LSauth.php @@ -36,7 +36,8 @@ class LSauth { static private $params = array ( 'displayLoginForm' => true, - 'displayLogoutBtn' => true + 'displayLogoutBtn' => true, + 'displaySelfAccess' => true ); function start() { @@ -115,6 +116,24 @@ class LSauth { return self :: $params['displayLogoutBtn']; } + /** + * Disable self access + * + * @retval void + **/ + public function disableSelfAccess() { + self :: $params['displaySelfAccess'] = false; + } + + /** + * Can display or not self access + * + * @retval boolean + **/ + public function displaySelfAccess() { + return self :: $params['displaySelfAccess']; + } + /* * For compatibillity until loginForm is migrated in LSauth */ diff --git a/public_html/includes/class/class.LSauthMethod_anonymous.php b/public_html/includes/class/class.LSauthMethod_anonymous.php new file mode 100644 index 00000000..02343a48 --- /dev/null +++ b/public_html/includes/class/class.LSauthMethod_anonymous.php @@ -0,0 +1,66 @@ + + */ +class LSauthMethod_anonymous extends LSauthMethod { + + function LSauthMethod_anonymous() { + LSauth :: disableLoginForm(); + LSauth :: disableLogoutBtn(); + LSauth :: disableSelfAccess(); + + if (!parent :: LSauthMethod()) + return; + + if ( (!defined('LSAUTHMETHOD_ANONYMOUS_USER')) || (constant('LSAUTHMETHOD_ANONYMOUS_USER') == "")) { + LSerror :: addErrorCode('LSauthMethod_anonymous_01'); + return; + } + return true; + } + + /** + * Check Auth Data + * + * Return authentication data or false + * + * @retval Array|false Array of authentication data or False + **/ + public function getAuthData() { + $this -> authData = array( + 'username' => LSAUTHMETHOD_ANONYMOUS_USER + ); + return $this -> authData; + } + +} +/* + * Error Codes + */ +LSerror :: defineError('LSauthMethod_anonymous_01', +_("LSauthMethod_anonymous : You must define the LSAUTHMETHOD_ANONYMOUS_USER contant in the configuration file.") +); +?> diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 110e047c..1596f75a 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -1372,6 +1372,7 @@ class LSsession { $GLOBALS['Smarty'] -> assign('lang_label',_('Language')); $GLOBALS['Smarty'] -> assign('displayLogoutBtn',LSauth :: displayLogoutBtn()); + $GLOBALS['Smarty'] -> assign('displaySelfAccess',LSauth :: displaySelfAccess()); // Infos if((!empty($_SESSION['LSsession_infos']))&&(is_array($_SESSION['LSsession_infos']))) { @@ -1627,13 +1628,15 @@ class LSsession { $LSaccess[self :: $topDn] = $access; } } - foreach($LSaccess as $dn => $access) { - $LSaccess[$dn] = array_merge( - array( - 'SELF' => 'My account' - ), - $access - ); + if (LSauth :: displaySelfAccess()) { + foreach($LSaccess as $dn => $access) { + $LSaccess[$dn] = array_merge( + array( + 'SELF' => 'My account' + ), + $access + ); + } } self :: $LSaccess = $LSaccess; diff --git a/public_html/templates/default/top.tpl b/public_html/templates/default/top.tpl index 29b2b238..887d27a9 100644 --- a/public_html/templates/default/top.tpl +++ b/public_html/templates/default/top.tpl @@ -45,7 +45,7 @@ - {$connected_as} {$LSsession_username}{if $displayLogoutBtn} {/if} + {if $displaySelfAccess}{$connected_as} {$LSsession_username}{/if}{if $displayLogoutBtn} {/if}