X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_acl.inc;h=01165904c669b232eaf1b168b54a55c6dc7b5cb2;hb=7b9eac53d0a01b7a79fc31199e8983c333c86a43;hp=193b9b519717f39d110cf593df4247bad75efad2;hpb=717279bff579021ce037544e92d276731bf1a6b3;p=gosa.git diff --git a/gosa-core/include/class_acl.inc b/gosa-core/include/class_acl.inc index 193b9b519..01165904c 100644 --- a/gosa-core/include/class_acl.inc +++ b/gosa-core/include/class_acl.inc @@ -87,7 +87,18 @@ class acl extends plugin $ldap->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); @@ -132,7 +143,7 @@ class acl extends plugin } /* Objects */ - $tmp= session::get('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; $cats = array(); if (isset($this->parent) && $this->parent !== NULL){ @@ -140,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)){ @@ -229,7 +241,7 @@ class acl extends plugin /* Call parent execute */ plugin::execute(); - $tmp= session::get('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; /* Handle posts */ @@ -244,6 +256,17 @@ class acl extends plugin $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... */ @@ -267,8 +290,7 @@ class acl extends plugin continue; } - /* Only handle posts, if we allowed to modify ACLs - */ + /* Only handle posts, if we allowed to modify ACLs */ if(!$this->acl_is_writeable("")){ continue; } @@ -306,48 +328,57 @@ class acl extends plugin continue; } + /* ACL saving... */ + if (preg_match('/^acl_.*_[^xy]$/', $name)){ + list($dummy, $object, $attribute, $value)= split('_', $name); + + /* Skip for detection entry */ + if ($object == 'dummy') { + continue; + } + + /* Ordinary ACLs */ + if (!isset($new_acl[$object])){ + $new_acl[$object]= array(); + } + if (isset($new_acl[$object][$attribute])){ + $new_acl[$object][$attribute].= $value; + } else { + $new_acl[$object][$attribute]= $value; + } + } + if(isset($_POST['selected_role'])){ $this->aclContents = ""; $this->aclContents = base64_decode($_POST['selected_role']); } } - - /* Check Posts - */ if(isset($_POST['acl_dummy_0_0_0'])){ $aclDialog= TRUE; - $tmp= session::get('plist'); - $plist= $tmp->info; - $list = $this->ocMapping[$this->aclObject]; - foreach($list as $plugin){ - foreach(array("r","w","c","d","s","m") as $acl){ - $overall = "acl_{$this->aclObject}/{$plugin}_0_{$acl}"; - if(isset($_POST[$overall])){ - if(!isset($new_acl["{$this->aclObject}/{$plugin}"][0])) { - $new_acl["{$this->aclObject}/{$plugin}"][0] = ""; - } - $new_acl["{$this->aclObject}/{$plugin}"][0] .= $acl; - } - if(!isset($plist[$plugin]) || !is_array($plist[$plugin])) continue; - foreach($plist[$plugin]['plProvidedAcls'] as $attribute => $description){ - $aclstr = "acl_{$this->aclObject}/{$plugin}_{$attribute}_{$acl}"; - if(isset($_POST[$aclstr])){ - if(!isset($new_acl["{$this->aclObject}/{$plugin}"][$attribute])) { - $new_acl["{$this->aclObject}/{$plugin}"][$attribute] = ""; - } - $new_acl["{$this->aclObject}/{$plugin}"][$attribute] .= $acl; - } - } - } - } } 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])){ - $this->aclContents = $new_acl; + + 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 */ @@ -447,9 +478,15 @@ class acl extends plugin 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)); + $field2= array("string" => $link); if($this->acl_is_writeable("")){ $action.= "info; asort($plist); $newSort = array(); @@ -653,11 +690,9 @@ class acl extends plugin function buildAclSelector($list) { - /* Do not change the dummy, it is used to detect whether the dialog was opnened or not - */ $display= ""; $cols= 3; - $tmp= session::get('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; asort($plist); @@ -699,11 +734,15 @@ class acl extends plugin foreach ($list as $key => $name){ /* Create sub acl if it does not exist */ - $currentAcl = array("0" => ""); - if (isset($this->aclContents[$key])){ - $currentAcl= $this->aclContents[$key]; + 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 =""; @@ -711,21 +750,34 @@ class acl extends plugin $overall_acl = $currentAcl[0]; } + // Detect configured plugins + $expand = count($currentAcl) > 1 || $currentAcl[0] != ""; + /* Object header */ - if(session::get('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
". @@ -742,20 +794,12 @@ class acl extends plugin /* Generate options */ $spc= "  "; -# if ($this->isContainer && $this->aclType != 'base'){ - $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", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$spc; - } - # } else { - # $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $overall_acl)).$spc; - # $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $overall_acl)).$spc; - # if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){ - # $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $overall_acl)).$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/', $overall_acl)).$spc; @@ -769,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::get('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
". - "\n