X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_acl.inc;h=01165904c669b232eaf1b168b54a55c6dc7b5cb2;hb=7b9eac53d0a01b7a79fc31199e8983c333c86a43;hp=f5b26e32f21effdef7c567bee067226cc8355290;hpb=894aa86d1d4d57416d43052ea7b781ff680f03c9;p=gosa.git diff --git a/gosa-core/include/class_acl.inc b/gosa-core/include/class_acl.inc index f5b26e32f..01165904c 100644 --- a/gosa-core/include/class_acl.inc +++ b/gosa-core/include/class_acl.inc @@ -1,10 +1,30 @@ search('(&(objectClass=gosaAccount)(gosaUnitTag='.$tag.'))', array('uid', 'cn')); } while ($attrs= $ldap->fetch()){ - $this->users['U:'.$attrs['dn']]= $attrs['cn'][0].' ['.$attrs['uid'][0].']'; + + // Allow objects without cn to be listed without causing an error. + if(!isset($attrs['cn'][0]) && isset($attrs['uid'][0])){ + $this->users['U:'.$attrs['dn']]= $attrs['uid'][0]; + }elseif(!isset($attrs['uid'][0]) && isset($attrs['cn'][0])){ + $this->users['U:'.$attrs['dn']]= $attrs['cn'][0]; + }elseif(!isset($attrs['uid'][0]) && !isset($attrs['cn'][0])){ + $this->users['U:'.$attrs['dn']]= $attrs['dn']; + }else{ + $this->users['U:'.$attrs['dn']]= $attrs['cn'][0].' ['.$attrs['uid'][0].']'; + } + } ksort($this->users); /* Groups */ $ldap->cd($config->current['BASE']); - if ($tag == ""){ +# if ($tag == ""){ $ldap->search('(objectClass=posixGroup)', array('cn', 'description')); - } else { - $ldap->search('(&(objectClass=posixGroup)(gosaUnitTag='.$tag.'))', array('cn', 'description')); - } +# } else { +# $ldap->search('(&(objectClass=posixGroup)(gosaUnitTag='.$tag.'))', array('cn', 'description')); +# } while ($attrs= $ldap->fetch()){ $dsc= ""; if (isset($attrs['description'][0])){ @@ -87,11 +120,11 @@ class acl extends plugin /* Roles */ $ldap->cd($config->current['BASE']); - if ($tag == ""){ +# if ($tag == ""){ $ldap->search('(objectClass=gosaRole)', array('cn', 'description','gosaAclTemplate','dn')); - } else { - $ldap->search('(&(objectClass=gosaRole)(gosaUnitTag='.$tag.'))', array('cn', 'description','gosaAclTemplate','dn')); - } +# } else { +# $ldap->search('(&(objectClass=gosaRole)(gosaUnitTag='.$tag.'))', array('cn', 'description','gosaAclTemplate','dn')); +# } while ($attrs= $ldap->fetch()){ $dsc= ""; if (isset($attrs['description'][0])){ @@ -110,7 +143,7 @@ class acl extends plugin } /* Objects */ - $tmp= get_global('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; $cats = array(); if (isset($this->parent) && $this->parent !== NULL){ @@ -118,7 +151,8 @@ class acl extends plugin foreach ($this->parent->by_object as $key => $obj){ $oc= array_merge($oc, $obj->objectclasses); if(isset($obj->acl_category)){ - $cats[preg_replace("/\//","",$obj->acl_category)] = preg_replace("/\//","",$obj->acl_category); + $tmp= str_replace("/","",$obj->acl_category); + $cats[$tmp] = $tmp; } } if (in_array_ics('organizationalUnit', $oc)){ @@ -139,13 +173,14 @@ class acl extends plugin /* 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'; } if(isset($cats[$data])){ - $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; + $this->myAclObjects[$data.'/'.$class]= $acls['plDescription']; } $this->ocMapping[$data][]= $class; } else { @@ -205,8 +240,8 @@ class acl extends plugin { /* Call parent execute */ plugin::execute(); - - $tmp= get_global('plist'); + + $tmp= session::global_get('plist'); $plist= $tmp->info; /* Handle posts */ @@ -220,6 +255,18 @@ class acl extends plugin $new_acl= array(); $aclDialog= FALSE; $firstedit= FALSE; + + /* Act on HTML post and gets here. + */ + if(isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit"){ + $id = trim($_GET['id']); + $this->dialogState= 'create'; + $firstedit= TRUE; + $this->dialog= TRUE; + $this->currentIndex= $id; + $this->loadAclEntry(); + } + foreach($_POST as $name => $post){ /* Actions... */ @@ -231,10 +278,6 @@ class acl extends plugin $this->loadAclEntry(); continue; } - if (preg_match('/^acl_del_.*_x/', $name)){ - unset($this->gosaAclEntry[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]); - continue; - } if (preg_match('/^cat_edit_.*_x/', $name)){ $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name); @@ -246,6 +289,17 @@ class acl extends plugin } continue; } + + /* Only handle posts, if we allowed to modify ACLs */ + if(!$this->acl_is_writeable("")){ + continue; + } + + if (preg_match('/^acl_del_.*_x/', $name)){ + unset($this->gosaAclEntry[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]); + continue; + } + if (preg_match('/^cat_del_.*_x/', $name)){ $idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name); foreach ($this->ocMapping[$idx] as $key){ @@ -276,7 +330,6 @@ class acl extends plugin /* ACL saving... */ if (preg_match('/^acl_.*_[^xy]$/', $name)){ - $aclDialog= TRUE; list($dummy, $object, $attribute, $value)= split('_', $name); /* Skip for detection entry */ @@ -300,25 +353,38 @@ class acl extends plugin $this->aclContents = base64_decode($_POST['selected_role']); } } - - /* Only be interested in new acl's, if we're in the right _POST place */ - if ($aclDialog && $this->aclObject != "" && is_array($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]; + if(isset($_POST['acl_dummy_0_0_0'])){ + $aclDialog= TRUE; + } + + if($this->acl_is_writeable("")){ + + /* Only be interested in new acl's, if we're in the right _POST place */ + if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){ + + foreach ($this->ocMapping[$this->aclObject] as $oc){ + + if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){ + unset($this->aclContents[$oc]); + }elseif(isset($this->aclContents[$this->aclObject.'/'.$oc]) && is_array($this->aclContents)){ + unset($this->aclContents[$this->aclObject.'/'.$oc]); + }else{ +# trigger_error("Huhm?"); + } + if (isset($new_acl[$oc]) && is_array($new_acl)){ + $this->aclContents[$oc]= $new_acl[$oc]; + } + if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){ + $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc]; + } } } - } - /* Save new acl in case of base edit mode */ - if ($this->aclType == 'base' && !$firstedit){ - $this->aclContents= $new_acl; + /* Save new acl in case of base edit mode */ + if ($this->aclType == 'base' && !$firstedit){ + $this->aclContents= $new_acl; + } } /* Cancel new acl? */ @@ -330,11 +396,21 @@ class acl extends plugin } } + /* Save common values */ + if($this->acl_is_writeable("")){ + foreach (array("aclType","aclFilter", "aclObject", "target") as $key){ + if (isset($_POST[$key])){ + $this->$key= validate($_POST[$key]); + } + } + } + /* Store ACL in main object? */ if (isset($_POST['submit_new_acl'])){ $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType; $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients; $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents; + $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter; $this->dialogState= 'head'; $this->dialog= FALSE; } @@ -385,15 +461,12 @@ class acl extends plugin } } - /* Save common values */ - foreach (array("aclType", "aclObject", "target") as $key){ - if (isset($_POST[$key])){ - $this->$key= validate($_POST[$key]); - } - } - /* Create templating instance */ $smarty= get_smarty(); + $smarty->assign("acl_readable",$this->acl_is_readable("")); + if(!$this->acl_is_readable("")){ + return ($smarty->fetch (get_template_path('acl.tpl'))); + } if ($this->dialogState == 'head'){ /* Draw list */ @@ -402,12 +475,34 @@ class acl extends plugin /* Fill in entries */ foreach ($this->gosaAclEntry as $key => $entry){ + if(!$this->acl_is_readable("")) continue; + + $action =""; + + if($this->acl_is_readable("")){ + $link = "".$this->assembleAclSummary($entry).""; + }else{ + $link = $this->assembleAclSummary($entry); + } + $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'"); - $field2= array("string" => $this->assembleAclSummary($entry)); - $action= ""; - $action.= ""; - $action.= ""; - $action.= ""; + $field2= array("string" => $link); + + if($this->acl_is_writeable("")){ + $action.= ""; + $action.= ""; + } + + if($this->acl_is_readable("")){ + $action.= ""; + } + if($this->acl_is_removeable("")){ + $action.= ""; + } $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); $aclList->AddEntry(array($field1, $field2, $field3)); @@ -431,9 +526,7 @@ class acl extends plugin $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] != ""){ - + if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){ $summary.= "$oc, "; continue; } @@ -444,21 +537,30 @@ class acl extends plugin /* Set summary... */ if ($summary == ""){ - $summary= ''._("No ACL settings for this category").''; + $summary= ''._("No ACL settings for this category!").''; } else { $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary)); } + $actions =""; + if($this->acl_is_readable("")){ + $actions= ""; + } + if($this->acl_is_removeable()){ + $actions.= ""; + } + $field1= array("string" => $dsc, "attach" => "style='width:100px'"); $field2= array("string" => $summary); - $action= ""; - $action.= ""; - $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px'"); + $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'"); $aclList->AddEntry(array($field1, $field2, $field3)); } $smarty->assign("aclList", $aclList->DrawList()); $smarty->assign("aclType", $this->aclType); + $smarty->assign("aclFilter", $this->aclFilter); $smarty->assign("aclTypes", $this->aclTypes); $smarty->assign("target", $this->target); $smarty->assign("targets", $this->targets); @@ -497,7 +599,7 @@ class acl extends plugin } if ($this->dialogState == 'edit'){ - $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType])); + $smarty->assign('headline', sprintf(_("Edit ACL for '%s' - scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType])); /* Collect objects for selected category */ foreach ($this->ocMapping[$this->aclObject] as $idx => $class){ @@ -520,6 +622,12 @@ class acl extends plugin /* Show main page */ $smarty->assign("dialogState", $this->dialogState); + + /* Assign acls */ + $smarty->assign("acl_createable",$this->acl_is_createable()); + $smarty->assign("acl_writeable" ,$this->acl_is_writeable("")); + $smarty->assign("acl_readable" ,$this->acl_is_readable("")); + $smarty->assign("acl_removeable",$this->acl_is_removeable()); return ($smarty->fetch (get_template_path('acl.tpl'))); } @@ -527,7 +635,7 @@ class acl extends plugin function sort_by_priority($list) { - $tmp= get_global('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; asort($plist); $newSort = array(); @@ -584,40 +692,42 @@ class acl extends plugin { $display= ""; $cols= 3; - $tmp= get_global('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; asort($plist); /* Add select all/none buttons */ $style = "style='width:100px;'"; - $display .= ""; - $display .= ""; - $display .= " - "; - $display .= ""; - $display .= " - "; - - $display .= ""; - $display .= ""; - - $display .= "
"; - - $style = "style='width:50px;'"; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= " - "; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= " - "; - - $display .= ""; - $display .= ""; - $display .= ""; - $display .= ""; + if($this->acl_is_writeable("")){ + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + + $display .= "
"; + + $style = "style='width:50px;'"; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + } /* Build general objects */ $list =$this->sort_by_priority($list); @@ -626,25 +736,48 @@ class acl extends plugin /* 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]; + /* Get the overall plugin acls + */ + $overall_acl =""; + if(isset($currentAcl[0])){ + $overall_acl = $currentAcl[0]; + } + + // Detect configured plugins + $expand = count($currentAcl) > 1 || $currentAcl[0] != ""; + /* Object header */ - if($_SESSION['js']) { - if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) { + $tname= preg_replace("/[^a-z0-9]/i","_",$name); + + if($expand){ + $back_color = "#C8C8FF"; + }else{ + $back_color = "#C8C8C8"; + } + + if(session::global_get('js')) { + if(isset($_SERVER['HTTP_USER_AGENT']) && + (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || + (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) { $display.= "\n". "\n ". - "\n ". - "\n ". + "\n ". + "\n ". "\n "; } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) { $display.= "\n
"._("Object").": $name". - "\n "._("Object").": $name". + "\n
". "\n ". "\n ". "\n ". + "\n ". "\n "; } else { $display.= "\n
"._("Object").": $name". - "\n
". @@ -661,24 +794,16 @@ class acl extends plugin /* Generate options */ $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[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[preg_replace('%^.*/%', '', $key)]['plSelfModify']){ - $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc; - } + $options= $this->mkchkbx($key."_0_c", _("Create objects"), preg_match('/c/', $overall_acl)).$spc; + $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc; + $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc; + if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){ + $options.= $this->mkchkbx($key."_0_s", _("Grant permission to owner"), preg_match('/s/', $overall_acl)).$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])); + $more_options= $this->mkchkbx($key."_0_r", _("read"), preg_match('/r/', $overall_acl)).$spc; + $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl)); $display.= "\n ". "\n ". @@ -688,20 +813,23 @@ class acl extends plugin /* Walk through the list of attributes */ $cnt= 1; $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 ". + if(session::global_get('js')) { + if(isset($_SERVER['HTTP_USER_AGENT']) && + (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) { + $display.= "\n ". "\n
$options
". - "\n