Module: nagvis Branch: master Commit: 0b06d72b5d698fce1f7f21c5bc5d05a02e3ec43e URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=0b06d72b5d698fce1f7f21c5bc5d05a02e3ec43e
Author: LaMi <[email protected]> Date: Tue Apr 6 22:36:03 2010 +0200 #236 automatically deleting map permissions on map deletions now --- .../core/classes/CoreAuthorisationHandler.php | 4 ++++ .../core/classes/CoreAuthorisationModSQLite.php | 18 ++++++++++++++++++ share/server/core/classes/CoreSQLiteHandler.php | 12 ++++++++++++ share/server/core/classes/WuiMapCfg.php | 2 ++ 4 files changed, 36 insertions(+), 0 deletions(-) diff --git a/share/server/core/classes/CoreAuthorisationHandler.php b/share/server/core/classes/CoreAuthorisationHandler.php index e2b2fde..f5b2b47 100644 --- a/share/server/core/classes/CoreAuthorisationHandler.php +++ b/share/server/core/classes/CoreAuthorisationHandler.php @@ -102,6 +102,10 @@ class CoreAuthorisationHandler { return $this->MOD->createPermission($mod, $name); } + public function deletePermission($mod, $name) { + return $this->MOD->deletePermission($mod, $name); + } + public function getAuthentication() { return $this->AUTHENTICATION; } diff --git a/share/server/core/classes/CoreAuthorisationModSQLite.php b/share/server/core/classes/CoreAuthorisationModSQLite.php index a5a4107..10752fe 100644 --- a/share/server/core/classes/CoreAuthorisationModSQLite.php +++ b/share/server/core/classes/CoreAuthorisationModSQLite.php @@ -48,6 +48,24 @@ class CoreAuthorisationModSQLite extends CoreAuthorisationModule { } } + public function deletePermission($mod, $name) { + if($name === '') { + // FIXME: Errorhandling + return false; + } + + switch($mod) { + case 'Map': + case 'AutoMap': + case 'Rotation': + return $this->DB->deletePermissions($mod, $name); + default: + // FIXME: Errorhandling + return false; + break; + } + } + public function createPermission($mod, $name) { if($name === '') { // FIXME: Errorhandling diff --git a/share/server/core/classes/CoreSQLiteHandler.php b/share/server/core/classes/CoreSQLiteHandler.php index 3672646..1faf5ef 100644 --- a/share/server/core/classes/CoreSQLiteHandler.php +++ b/share/server/core/classes/CoreSQLiteHandler.php @@ -95,6 +95,18 @@ class CoreSQLiteHandler { return true; } } + + public function deletePermissions($mod, $name) { + // Only create when not existing + if($this->count('SELECT COUNT(*) AS num FROM perms WHERE mod='.$this->escape($mod).' AND act=\'view\' AND obj='.$this->escape($name)) > 0) { + if(DEBUG&&DEBUGLEVEL&2) debug('auth.db: delete permissions for '.$mod.' '.$name); + $this->DB->query('DELETE FROM perms WHERE mod='.$this->escape($mod).' AND obj='.$this->escape($name).''); + $this->DB->query('DELETE FROM roles2perms WHERE permId=(SELECT permId FROM perms WHERE mod='.$this->escape($mod).' AND obj='.$this->escape($name).')'); + } else { + if(DEBUG&&DEBUGLEVEL&2) debug('auth.db: won\'t delete '.$mod.' permissions '.$name); + } + } + public function createMapPermissions($name) { // Only create when not existing diff --git a/share/server/core/classes/WuiMapCfg.php b/share/server/core/classes/WuiMapCfg.php index 350d745..8dd0747 100644 --- a/share/server/core/classes/WuiMapCfg.php +++ b/share/server/core/classes/WuiMapCfg.php @@ -117,6 +117,8 @@ class WuiMapCfg extends GlobalMapCfg { if(file_exists($this->cacheFile)) { unlink($this->cacheFile); } + // And also remove the permission + GlobalCore::getInstance()->getAuthorization()->deletePermission('Map', $this->name); return TRUE; } else { ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
