Module: nagvis
Branch: master
Commit: c796f510b72aedaf517df449f9f8ea70dd7638da
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=c796f510b72aedaf517df449f9f8ea70dd7638da

Author: LaMi <[email protected]>
Date:   Wed Nov 11 15:29:10 2009 +0100

#170 added supported feature check for authentication modules

---

 .../nagvis-js/classes/GlobalHeaderMenu.php         |    4 +++-
 share/server/core/classes/CoreAuthHandler.php      |   10 ++++++++++
 share/server/core/classes/CoreAuthModSQLite.php    |   17 +++++++++++++++++
 share/server/core/classes/CoreAuthModSession.php   |   14 ++++++++++++++
 share/server/core/classes/CoreAuthModule.php       |   14 ++++++++++++++
 .../userfiles/templates/pages/default.header.html  |    4 ++--
 6 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php 
b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php
index b887030..41d1059 100644
--- a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php
+++ b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php
@@ -272,7 +272,9 @@ class GlobalHeaderMenu {
                        'lang_instance' => 
$this->CORE->getLang()->getText('instance'),
                        'lang_logout' => 
$this->CORE->getLang()->getText('Logout'),
                        'lang_rotation_start' => 
$this->CORE->getLang()->getText('rotationStart'),
-                       'lang_rotation_stop' => 
$this->CORE->getLang()->getText('rotationStop'));
+                       'lang_rotation_stop' => 
$this->CORE->getLang()->getText('rotationStop'),
+                       'authChangePasswordSupported' => 
$this->AUTHORISATION->getAuthentication()->checkFeature('changePassword'),
+                       'authCreateUserSupported' => 
$this->AUTHORISATION->getAuthentication()->checkFeature('createUser'));
                
                return $aReturn;
        }
diff --git a/share/server/core/classes/CoreAuthHandler.php 
b/share/server/core/classes/CoreAuthHandler.php
index cb3e516..5efde4d 100644
--- a/share/server/core/classes/CoreAuthHandler.php
+++ b/share/server/core/classes/CoreAuthHandler.php
@@ -48,6 +48,16 @@ class CoreAuthHandler {
                $this->MOD = new $sModule($CORE);
        }
        
+       public function checkFeature($name) {
+               $a = $this->MOD->getSupportedFeatures();
+               
+               if(isset($a[$name])) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+       
        public function getModule() {
                return $this->sModuleName;
        }
diff --git a/share/server/core/classes/CoreAuthModSQLite.php 
b/share/server/core/classes/CoreAuthModSQLite.php
index 4a3af7b..d9485f3 100644
--- a/share/server/core/classes/CoreAuthModSQLite.php
+++ b/share/server/core/classes/CoreAuthModSQLite.php
@@ -37,6 +37,23 @@ class CoreAuthModSQLite extends CoreAuthModule {
        
        public function __construct(GlobalCore $CORE) {
                $this->CORE = $CORE;
+       
+               parent::$aFeatures = Array(
+                       // General functions for authentication
+                       'passCredentials' => true,
+                       'getCredentials' => true,
+                       'isAuthenticated' => true,
+                       'getUser' => true,
+                       'getUserId' => true,
+                       
+                       // Changing passwords
+                       'passNewPassword' => true,
+                       'changePassword' => true,
+                       'passNewPassword' => true,
+                       
+                       // Managing users
+                       'createUser' => true,
+               );
                
                $this->DB = new CoreSQLiteHandler();
                
diff --git a/share/server/core/classes/CoreAuthModSession.php 
b/share/server/core/classes/CoreAuthModSession.php
index 496d06f..159c165 100644
--- a/share/server/core/classes/CoreAuthModSession.php
+++ b/share/server/core/classes/CoreAuthModSession.php
@@ -40,6 +40,20 @@ class CoreAuthModSession extends CoreAuthModule {
        public function __construct(GlobalCore $CORE) {
                $this->CORE = $CORE;
                
+               parent::$aFeatures = Array(
+                       // General functions for authentication
+                       'passCredentials' => true,
+                       'getCredentials' => true,
+                       'isAuthenticated' => true,
+                       'getUser' => true,
+                       'getUserId' => true,
+                       
+                       // Changing passwordss
+                       'passNewPassword' => true,
+                       'changePassword' => true,
+                       'passNewPassword' => true
+               );
+               
                $this->SHANDLER = new 
CoreSessionHandler($this->CORE->getMainCfg()->getValue('global', 
'sesscookiedomain'), 
                                                         
$this->CORE->getMainCfg()->getValue('global', 'sesscookiepath'),
                                                         
$this->CORE->getMainCfg()->getValue('global', 'sesscookieduration'));
diff --git a/share/server/core/classes/CoreAuthModule.php 
b/share/server/core/classes/CoreAuthModule.php
index b18ec2f..c2a00f6 100644
--- a/share/server/core/classes/CoreAuthModule.php
+++ b/share/server/core/classes/CoreAuthModule.php
@@ -29,6 +29,20 @@
  * @author Lars Michelsen <[email protected]>
  */
 abstract class CoreAuthModule {
+       protected static $aFeatures;
+       
+       /**
+        * PUBLIC Method getSupportedFeatures
+        * 
+        * Returns a list of supported features
+        *
+        * @return      Array
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function getSupportedFeatures() {
+               return self::$aFeatures;
+       }
+       
        abstract public function passCredentials($aData);
        abstract public function passNewPassword($aData);
        abstract public function changePassword();
diff --git a/share/userfiles/templates/pages/default.header.html 
b/share/userfiles/templates/pages/default.header.html
index 3bcdff0..ef371fb 100644
--- a/share/userfiles/templates/pages/default.header.html
+++ b/share/userfiles/templates/pages/default.header.html
@@ -40,8 +40,8 @@
                  <dd id="user-ddcontent" onmouseover="cancelHide('user')" 
onmouseout="ddMenu('user',-1)">
                    <ul>
                        <li><a href="#">{$lang_logged_in}: 
{$current_user}</a></li>
-                       <li><a 
href="javascript:showChangePassword('{$lang_change_password}');">{$lang_change_password}</a></li>
-                       <li><a 
href="javascript:showUserAdd('{$langUserAdd}');">{$langUserAdd}</a></li>
+                       {if $authChangePasswordSupported == true}<li><a 
href="javascript:showChangePassword('{$lang_change_password}');">{$lang_change_password}</a></li>{/if}
+                       {if $authCreateUserSupported == true}<li><a 
href="javascript:showUserAdd('{$langUserAdd}');">{$langUserAdd}</a></li>{/if}
                        <li><a href="#" 
onclick="getSyncRequest('{$html_base}/server/core/ajax_handler.php?mod=Auth&amp;act=logout');return
 false;" class="underline">{$lang_logout}</a></li>
                    </ul>
                  </dd>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to