From 6957b2ea013b27781cc1ccce8b94267006cb917d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 27 Jun 2007 21:49:10 +0200 Subject: check for auth object at certain functions This is a follow up on the previous patch to disable authtentication without disabling ACL on backend problems. It fixes a few errors that might occour in this rare situation. darcs-hash:20070627194910-7ad00-de5ac10e0d36ecf8906c080e1d3dc1b2fd85b45d.gz --- inc/html.php | 4 ++-- inc/infoutils.php | 2 +- inc/template.php | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 42457670b..7c7d78ee7 100644 --- a/inc/html.php +++ b/inc/html.php @@ -82,14 +82,14 @@ function html_login(){ canDo('addUser') && actionOK('register')){ + if($auth && $auth->canDo('addUser') && actionOK('register')){ print '

'; print $lang['reghere']; print ': '.$lang['register'].''; print '

'; } - if ($auth->canDo('modPass') && actionOK('resendpwd')) { + if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { print '

'; print $lang['pwdforget']; print ': '.$lang['btn_resendpwd'].''; diff --git a/inc/infoutils.php b/inc/infoutils.php index 255b49ed4..6da344d81 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -168,7 +168,7 @@ function check(){ global $auth; msg('You are currently logged in as '.$_SESSION[DOKU_COOKIE]['auth']['user'].' ('.$INFO['userinfo']['name'].')',0); - $info = $auth->getUserData($_SESSION[DOKU_COOKIE]['auth']['user']); + if($auth) $info = $auth->getUserData($_SESSION[DOKU_COOKIE]['auth']['user']); msg('You are part of the groups '.implode($info['grps'],', '),0); }else{ msg('You are currently not logged in',0); diff --git a/inc/template.php b/inc/template.php index 3bf9be114..c941a64f4 100644 --- a/inc/template.php +++ b/inc/template.php @@ -435,7 +435,7 @@ function tpl_button($type){ print html_topbtn(); return true; case 'login': - if($conf['useacl']){ + if($conf['useacl'] && $auth){ if($_SERVER['REMOTE_USER']){ print html_btn('logout',$ID,'',array('do' => 'logout',)); }else{ @@ -451,7 +451,7 @@ function tpl_button($type){ } return false; case 'subscription': - if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){ + if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ if($_SERVER['REMOTE_USER']){ if($INFO['subscribed']){ print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); @@ -466,7 +466,7 @@ function tpl_button($type){ print html_btn('backlink',$ID,'',array('do' => 'backlink')); return true; case 'profile': - if($conf['useacl'] && $_SERVER['REMOTE_USER'] && + if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $auth && $auth->canDo('Profile') && ($ACT!='profile')){ print html_btn('profile',$ID,'',array('do' => 'profile')); return true; @@ -564,7 +564,7 @@ function tpl_actionlink($type,$pre='',$suf=''){ } return false; case 'login': - if($conf['useacl']){ + if($conf['useacl'] && $auth){ if($_SERVER['REMOTE_USER']){ tpl_link(wl($ID,'do=logout'),$pre.$lang['btn_logout'].$suf,'class="action logout" rel="nofollow"'); }else{ @@ -581,7 +581,7 @@ function tpl_actionlink($type,$pre='',$suf=''){ return false; case 'subscribe': case 'subscription': - if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){ + if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ if($_SERVER['REMOTE_USER']){ if($INFO['subscribed']) { tpl_link(wl($ID,'do=unsubscribe'),$pre.$lang['btn_unsubscribe'].$suf,'class="action unsubscribe" rel="nofollow"'); @@ -596,7 +596,7 @@ function tpl_actionlink($type,$pre='',$suf=''){ tpl_link(wl($ID,'do=backlink'),$pre.$lang['btn_backlink'].$suf, 'class="action backlink" rel="nofollow"'); return true; case 'profile': - if($conf['useacl'] && $_SERVER['REMOTE_USER'] && + if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && $auth->canDo('Profile') && ($ACT!='profile')){ tpl_link(wl($ID,'do=profile'),$pre.$lang['btn_profile'].$suf, 'class="action profile" rel="nofollow"'); return true; -- cgit v1.2.3