X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_acl.inc;h=a25ea05a90b85fcc1ac1a50a758580e32b78f42f;hb=895712accc11cf9defc13cdbc64a6b3c7e7e548a;hp=91a5dc5695c4d65ad7a487d40d35692269b8b807;hpb=fe030b22bb09d7a717b8baab13e2c113d1443f2f;p=gosa.git diff --git a/include/class_acl.inc b/include/class_acl.inc index 91a5dc569..a25ea05a9 100644 --- a/include/class_acl.inc +++ b/include/class_acl.inc @@ -87,7 +87,7 @@ class acl extends plugin /* Objects */ $tmp= get_global('plist'); $plist= $tmp->info; - if (isset($this->parent)){ + if (isset($this->parent) && $this->parent != NULL){ $oc= array(); foreach ($this->parent->by_object as $key => $obj){ $oc= array_merge($oc, $obj->objectclasses); @@ -98,58 +98,56 @@ class acl extends plugin } else { $oc= $this->attrs['objectClass']; } + + + /* Extract available categories from plugin info list */ foreach ($plist as $class => $acls){ - if (isset($acls['plDescription'])){ - /* Only feed categories */ - if (isset($acls['plDepends']['description'])){ - if (is_array($acls['plDepends']['objectClass'])){ - foreach($acls['plDepends']['objectClass'] as $oc){ - $this->aclObjects[$oc]= $acls['plDepends']['description']; + + /* Only feed categories */ + if (isset($acls['plCategory'])){ + + /* Walk through supplied list and feed only translated categories */ + foreach($acls['plCategory'] as $idx => $data){ + + /* Non numeric index means -> base object containing more informations */ + if (preg_match('/^[0-9]+$/', $idx)){ + if (!isset($this->ocMapping[$data])){ + $this->ocMapping[$data]= array(); + $this->ocMapping[$data][]= '0'; } + $this->ocMapping[$data][]= $class; } else { - $this->aclObjects[$acls['plDepends']['objectClass']]= $acls['plDepends']['description']; - } - } - - /* Additionally filter the classes we're interested in in "self edit" mode */ - if (is_array($acls['plDepends']['objectClass'])){ - foreach($acls['plDepends']['objectClass'] as $hoc){ - if (in_array_ics($hoc, $oc)){ - $this->myAclObjects[$class]= $acls['plDescription']; - break; + if (!isset($this->ocMapping[$idx])){ + $this->ocMapping[$idx]= array(); + $this->ocMapping[$idx][]= '0'; + } + $this->ocMapping[$idx][]= $class; + $this->aclObjects[$idx]= $data['description']; + + /* Additionally filter the classes we're interested in in "self edit" mode */ + if (is_array($data['objectClass'])){ + foreach($data['objectClass'] as $objectClass){ + if (in_array_ics($objectClass, $oc)){ + $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; + break; + } + } + } else { + if (in_array_ics($data['objectClass'], $oc)){ + $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; + } } } - } else { - if (in_array_ics($acls['plDepends']['objectClass'], $oc)){ - $this->myAclObjects[$class]= $acls['plDescription']; - } + } } } + $this->aclObjects['all']= '* '._("All categories"); + $this->ocMapping['all']= array('0' => 'all'); - /* Add category for all objects */ + /* Sort categories */ asort($this->aclObjects); - /* Generate mapping object */ - foreach ($plist as $oc => $pl){ - if (isset($pl['plDepends']['objectClass'])){ - if (is_array($pl['plDepends']['objectClass'])){ - foreach($pl['plDepends']['objectClass'] as $class){ - if (!isset($this->ocMapping[$class])){ - $this->ocMapping[$class]= array(); - } - $this->ocMapping[$class][]= $oc; - } - } else { - $class= $pl['plDepends']['objectClass']; - if (!isset($this->ocMapping[$class])){ - $this->ocMapping[$class]= array(); - } - $this->ocMapping[$class][]= $oc; - } - } - } - /* Fill acl types */ if ($this->isContainer){ $this->aclTypes= array("reset" => _("Reset ACLs"), @@ -263,9 +261,13 @@ class acl extends plugin if ($aclDialog && isset($this->ocMapping[$this->aclObject])){ foreach ($this->ocMapping[$this->aclObject] as $oc){ unset($this->aclContents[$oc]); + unset($this->aclContents[$this->aclObject.'/'.$oc]); if (isset($new_acl[$oc])){ $this->aclContents[$oc]= $new_acl[$oc]; } + if (isset($new_acl[$this->aclObject.'/'.$oc])){ + $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc]; + } } } @@ -362,7 +364,7 @@ class acl extends plugin $action.= ""; $action.= ""; - $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px';text-align:right"); + $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); $aclList->AddEntry(array($field1, $field2, $field3)); } @@ -375,19 +377,23 @@ class acl extends plugin $aclList->SetHeight(150); /* Add settings for all categories to the (permanent) list */ - foreach ($this->aclObjects as $oc => $dsc){ + foreach ($this->aclObjects as $section => $dsc){ $summary= ""; - foreach ($plist as $key => $plugin){ - if (isset($plugin['plDepends']['objectClass']) && $plugin['plDepends']['objectClass'] == $oc && - isset($this->aclContents[$key])){ - if (count($this->aclContents[$key]) && isset($this->aclContents[$key][0]) && - $this->aclContents[$key][0] != ""){ - $summary.= "$key, "; - continue; - } - if (!isset($this->aclContents[$key][0]) && count($this->aclContents[$key])){ - $summary.= "$key, "; - } + foreach($this->ocMapping[$section] as $oc){ + if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) && + $this->aclContents[$oc][0] != ""){ + + $summary.= "$oc, "; + continue; + } + if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"]) && isset($this->aclContents["$section/$oc"][0]) && + $this->aclContents["$section/$oc"][0] != ""){ + + $summary.= "$oc, "; + continue; + } + if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){ + $summary.= "$oc, "; } } @@ -400,8 +406,8 @@ class acl extends plugin $field1= array("string" => $dsc, "attach" => "style='width:100px'"); $field2= array("string" => $summary); - $action= ""; - $action.= ""; + $action= ""; + $action.= ""; $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px'"); $aclList->AddEntry(array($field1, $field2, $field3)); } @@ -443,25 +449,15 @@ class acl extends plugin $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType])); /* Collect objects for selected category */ - $aclObjects= array(); - - foreach ($plist as $class => $acls){ - if (isset($acls['plDepends']['objectClass'])){ - if (is_array($acls['plDepends']['objectClass'])){ - foreach($acls['plDepends']['objectClass'] as $coc){ - if ($coc == $this->aclObject){ - $aclObjects[$class]= $acls['plDescription']; - break; - } - } - } else { - if ($acls['plDepends']['objectClass'] == $this->aclObject){ - $aclObjects[$class]= $acls['plDescription']; - } - } + foreach ($this->ocMapping[$this->aclObject] as $idx => $class){ + if ($idx == 0){ + continue; } + $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription']; + } + if ($this->aclObject == 'all'){ + $aclObjects['all']= _("All objects in current subtree"); } - $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects)); } @@ -480,46 +476,44 @@ class acl extends plugin $plist= $tmp->info; asort($plist); - /* Generate global options */ -# $key= "global"; -# $display.= ""; -# -# $spc= "  "; -# if ($this->isContainer && $this->aclType != 'base'){ -# $options= $this->mkchkbx($key."_0_c", _("Create objects"), preg_match('/c/', $currentAcl[0])).$spc; -# $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $currentAcl[0])).$spc; -# $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $currentAcl[0])).$spc; -# if ($plist[$key]['plSelfModify']){ -# $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc; -# } -# } else { -# $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $currentAcl[0])).$spc; -# $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $currentAcl[0])).$spc; -# if ($plist[$key]['plSelfModify']){ -# $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc; -# } -# } -# -# /* Global options */ -# $more_options= $this->mkchkbx($key."_0_r", _("read"), preg_match('/r/', $currentAcl[0])).$spc; -# $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $currentAcl[0])); -# -# $display.= "
"._("All objects of this category")."
$options ".("Complete object:")." $more_options

"; - /* Build general objects */ foreach ($list as $key => $name){ /* Create sub acl if it does not exist */ if (!isset($this->aclContents[$key])){ $this->aclContents[$key]= array(); - } - if (!isset($this->aclContents[$key][0])){ $this->aclContents[$key][0]= ''; } $currentAcl= $this->aclContents[$key]; /* Object header */ - $display.= ""; + if($_SESSION['js']) { + if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) { + $display.= "\n
"._("Object").": $name
". + "\n ". + "\n ". + "\n ". + "\n "; + } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) { + $display.= "\n
"._("Object").": $name". + "\n
". + "\n ". + "\n ". + "\n ". + "\n "; + } else { + $display.= "\n
"._("Object").": $name". + "\n
". + "\n ". + "\n ". + "\n "; + } + } else { + $display.= "\n
"._("Object").": $name
". + "\n ". + "\n ". + "\n "; + } /* Generate options */ $spc= "  "; @@ -527,13 +521,13 @@ class acl extends plugin $options= $this->mkchkbx($key."_0_c", _("Create objects"), preg_match('/c/', $currentAcl[0])).$spc; $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $currentAcl[0])).$spc; $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $currentAcl[0])).$spc; - if ($plist[$key]['plSelfModify']){ + if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){ $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc; } } else { $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $currentAcl[0])).$spc; $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $currentAcl[0])).$spc; - if ($plist[$key]['plSelfModify']){ + if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){ $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc; } } @@ -542,12 +536,28 @@ class acl extends plugin $more_options= $this->mkchkbx($key."_0_r", _("read"), preg_match('/r/', $currentAcl[0])).$spc; $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $currentAcl[0])); - $display.= ""; + $display.= "\n ". + "\n ". + "\n ". + "\n "; /* Walk through the list of attributes */ $cnt= 1; - $splist= $plist[$key]; + $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls']; asort($splist); + if($_SESSION['js']) { + if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) { + $display.= "\n ". + "\n
"._("Object").": $name
$options ".("Complete object:")." $more_options
$options ".("Complete object:")." $more_options
". + "\n

\n"; } return ($display); @@ -594,7 +614,8 @@ class acl extends plugin function mkchkbx($name, $text, $state= FALSE) { $state= $state?"checked":""; - return ""; + return "\n ". + "\n "; } @@ -602,8 +623,10 @@ class acl extends plugin { $rstate= preg_match('/r/', $state)?'checked':''; $wstate= preg_match('/w/', $state)?'checked':''; - return ("". - ""); + return ("\n ". + "\n ". + "\n ". + "\n "); } @@ -855,6 +878,11 @@ class acl extends plugin $ldap->modify ($this->attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving ACLs with dn '%s' failed."),$this->dn)); + + /* Refresh users ACLs */ + $ui= get_userinfo(); + $ui->loadACL(); + $_SESSION['ui']= $ui; }