From 62ad49f8d5c4b6c3d4b5d58b379ba75cfbf75f67 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 21 Apr 2010 14:34:38 +0000 Subject: [PATCH] Cleaned up aclResolver git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17780 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../generic/references/class_aclResolver.inc | 130 +++++++++++------- .../generic/references/class_reference.inc | 4 +- .../plugins/generic/references/contents.tpl | 38 +++-- 3 files changed, 107 insertions(+), 65 deletions(-) diff --git a/gosa-core/plugins/generic/references/class_aclResolver.inc b/gosa-core/plugins/generic/references/class_aclResolver.inc index d3c16f5f8..9e178f422 100644 --- a/gosa-core/plugins/generic/references/class_aclResolver.inc +++ b/gosa-core/plugins/generic/references/class_aclResolver.inc @@ -1,40 +1,57 @@ config = &$config; $this->dn = $dn; - $this->parent = &$parent; - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($dn); - $this->attrs = $ldap->fetch(); - - if(isset($this->parent->acl_category) && !empty($this->parent->acl_category)){ - $this->acl_category = preg_replace("/\/$/","",$this->parent->acl_category); - } - - if(isset($attrs['uid'][0])){ - $this->uid = $attrs['uid'][0]; + + // Get ACL category for the current object. + if(isset($parent->acl_category) && !empty($parent->acl_category)){ + $this->acl_category = preg_replace("/\/$/","",$parent->acl_category); } - - $this->ignoreACL = ($this->config->get_cfg_value("ignoreAcl") == $this->dn); - $this->reset_acl_cache(); - $this->loadACL(); + // Build class mapping + if(!session::is_set('aclConverter::classMapping')){ + $tmp= session::global_get('plist'); + $plist= $tmp->info; + $map = array(); + $map['all']= _("All categories"); + foreach($plist as $class => $plInfo){ + if(isset($plInfo['plCategory']) && is_array($plInfo['plCategory'])){ + foreach($plInfo['plCategory'] as $category => $desc){ + if(!is_numeric($category)){ + $map[$category] = $desc['description']; + } + } + } + } + foreach($plist as $class => $plInfo){ + if(isset($plInfo['plCategory']) && is_array($plInfo['plCategory'])){ + foreach($plInfo['plCategory'] as $category => $desc){ + if(!is_numeric($category)){ + $map[$category."/".$class] = $map[$category]." - ".$plInfo['plDescription']; + }else{ + $map[$desc."/".$class] = $map[$desc]." - ".$plInfo['plDescription']; + } + } + } + } + session::set('aclConverter::classMapping', $map); + } + $this->classMapping = session::get('aclConverter::classMapping'); - foreach($this->allACLs as $dn => $acls){ + // Go through all ACLs and get those matching out DN. + $ui = get_userinfo(); + foreach($ui->allACLs as $dn => $acls){ if(preg_match("/".preg_quote($dn,'/')."$/i", $this->dn)){ - foreach($acls as $prio => $acl){ if($acl['type'] == "reset"){ $this->affectingACLs[$dn][$prio] = $acl; @@ -51,33 +68,34 @@ class aclResolver extends userinfo } } } + + // Define ACL type translations + $this->aclTypes= array("reset" => _("Reset ACLs"), + "one" => _("One level"), + "base" => _("Current object"), + "sub" => _("Complete subtree"), + "psub" => _("Complete subtree (permanent)"), + "role" => _("Use ACL defined in role")); } - + + /*! \brief Create a human readable HTML result + */ function getReadableACL() { $str = ""; - foreach($this->affectingACLs as $dn => $acls){ - foreach($acls as $acl){ - $str.=""; if(isset($this->config->idepartments[$dn])){ $image= image("images/select_department.png"); }else{ $image= image("images/lists/element.png"); } - $aclTypes= array("reset" => _("Reset ACLs"), - "one" => _("One level"), - "base" => _("Current object"), - "sub" => _("Complete subtree"), - "psub" => _("Complete subtree (permanent)"), - "role" => _("Use ACL defined in role")); $str.=""; $str.=""; - $str.=""; + $str.=""; $str.=""; $str.=""; - $str.=""; - + $str .= ""; + if($acl['type']!='reset'){ $str.=""; $str .= ""; + }else{ + $str .= ""; } $str .= ""; } } - $str .= "
".$image."".$dn."".$aclTypes[$acl['type']]."".$this->aclTypes[$acl['type']]."
"._("Members")."
    "; foreach($acl['members'] as $type => $name){ @@ -85,36 +103,52 @@ class aclResolver extends userinfo } $str .= "
"; $str .= "
"._("Acls")."
    "; - foreach($acl['acl'] as $type => $name){ - $str .= "
  • ".$type.": ".$this->aclToString(implode(array_unique($name)))."
  • "; + foreach($acl['acl'] as $type => $acl){ + + if(isset($this->classMapping[$type])){ + $str .= "
  • ".$this->classMapping[$type].": ".$this->aclToString($acl)."
  • "; + }else{ + $str .= "
  • ".$type.": ".$this->aclToString($acl)."
  • "; + } } $str .= "
"; $str .= "

"; + $str .= ""; return($str); } - function aclToString($acl) + function aclToString($acls) { - $str =""; - if(preg_match("/r/", $acl)) $str.= _("read").', '; - if(preg_match("/w/", $acl)) $str.= _("write").', '; - if(preg_match("/c/", $acl)) $str.= _("Create").', '; - if(preg_match("/d/", $acl)) $str.= _("Remove").', '; - if(preg_match("/m/", $acl)) $str.= _("Move").', '; - if(preg_match("/s/", $acl)) $str.= _("Owner").', '; - return(trim($str,', ')); + $str =""); } } ?> - + diff --git a/gosa-core/plugins/generic/references/class_reference.inc b/gosa-core/plugins/generic/references/class_reference.inc index 1c36e1b10..db662408c 100644 --- a/gosa-core/plugins/generic/references/class_reference.inc +++ b/gosa-core/plugins/generic/references/class_reference.inc @@ -83,8 +83,6 @@ class reference extends plugin $ui = get_userinfo(); - $r = new aclResolver($this->config, $this->dn, $this); - return($r->getReadableACL()); /* Set government mode */ $smarty= get_smarty(); @@ -101,6 +99,8 @@ class reference extends plugin /* Fill array */ $this->reload(); $smarty->assign("objectList", $this->objectlist); + $r = new aclResolver($this->config, $this->dn, $this); + $smarty->assign("acls",$r->getReadableACL()); /* Show main page */ return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__)))); diff --git a/gosa-core/plugins/generic/references/contents.tpl b/gosa-core/plugins/generic/references/contents.tpl index c97cfbbf3..6550d8b60 100644 --- a/gosa-core/plugins/generic/references/contents.tpl +++ b/gosa-core/plugins/generic/references/contents.tpl @@ -1,20 +1,28 @@ -{if $objectList ne ""} - +
+ + + +
+ {if $objectList ne ""} + + + + + + - - - - - + + + - - - - - {$objectList} + {$objectList} +
{t}Object name{/t}{t}Description{/t}{t}Contents{/t}
{t}Object name{/t}{t}Description{/t}{t}Contents{/t}
+ {else} + {t}This object has no relationship to other objects.{/t} + {/if} +
+ {$acls} +
-{else} -{t}This object has no relationship to other objects.{/t} -{/if} -- 2.30.2