X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_acl.inc;h=c79a7f2876dd4fa1344e67d1abbfa47127236b95;hb=534bedd511854e012e6453f3c1a97e947fdbd139;hp=ad4c41fe338ec8f76184513916f88c0acb88fd7d;hpb=da1b35b1343f11e46bed8f993c57d1f779e0d1f2;p=gosa.git diff --git a/gosa-core/include/class_acl.inc b/gosa-core/include/class_acl.inc index ad4c41fe3..c79a7f287 100644 --- a/gosa-core/include/class_acl.inc +++ b/gosa-core/include/class_acl.inc @@ -20,6 +20,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*! \brief ACL management plugin */ class acl extends plugin { /* Definitions */ @@ -87,7 +88,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); @@ -105,6 +117,7 @@ class acl extends plugin } $this->groups['G:'.$attrs['dn']]= $attrs['cn'][0].' ['.$dsc.']'; } + $this->groups['G:*']= _("All users"); ksort($this->groups); /* Roles */ @@ -132,7 +145,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){ @@ -230,7 +243,7 @@ class acl extends plugin /* Call parent execute */ plugin::execute(); - $tmp= session::get('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; /* Handle posts */ @@ -245,20 +258,31 @@ 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... */ - if (preg_match('/^acl_edit_.*_x/', $name)){ + if (preg_match('/^acl_edit_[0-9]*$/', $name)){ $this->dialogState= 'create'; $firstedit= TRUE; $this->dialog= TRUE; - $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name); + $this->currentIndex= preg_replace('/^acl_edit_([0-9]*)$/', '\1', $name); $this->loadAclEntry(); continue; } - if (preg_match('/^cat_edit_.*_x/', $name)){ - $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name); + if (preg_match('/^cat_edit_.*$/', $name)){ + $this->aclObject= preg_replace('/^cat_edit_(.*)$/', '\1', $name); $this->dialogState= 'edit'; foreach ($this->ocMapping[$this->aclObject] as $oc){ if (isset($this->aclContents[$oc])){ @@ -273,22 +297,25 @@ class acl extends plugin continue; } - if (preg_match('/^acl_del_.*_x/', $name)){ - unset($this->gosaAclEntry[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]); + if (preg_match('/^acl_del_[0-9]*$/', $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); + if (preg_match('/^cat_del_.*$/', $name)){ + $idx= preg_replace('/^cat_del_(.*)$/', '\1', $name); foreach ($this->ocMapping[$idx] as $key){ - unset($this->aclContents["$idx/$key"]); + if(isset($this->aclContents[$idx])) + unset($this->aclContents[$idx]); + if(isset($this->aclContents["$idx/$key"])) + unset($this->aclContents["$idx/$key"]); } continue; } /* Sorting... */ - if (preg_match('/^sortup_.*_x/', $name)){ - $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name); + if (preg_match('/^sortup_[0-9]*$/', $name)){ + $index= preg_replace('/^sortup_([0-9]*)$/', '\1', $name); if ($index > 0){ $tmp= $this->gosaAclEntry[$index]; $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index-1]; @@ -296,8 +323,8 @@ class acl extends plugin } continue; } - if (preg_match('/^sortdown_.*_x/', $name)){ - $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name); + if (preg_match('/^sortdown_[0-9]*$/', $name)){ + $index= preg_replace('/^sortdown_([0-9]*)$/', '\1', $name); if ($index < count($this->gosaAclEntry)-1){ $tmp= $this->gosaAclEntry[$index]; $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index+1]; @@ -308,7 +335,7 @@ class acl extends plugin /* ACL saving... */ if (preg_match('/^acl_.*_[^xy]$/', $name)){ - list($dummy, $object, $attribute, $value)= split('_', $name); + list($dummy, $object, $attribute, $value)= explode('_', $name); /* Skip for detection entry */ if ($object == 'dummy') { @@ -326,7 +353,8 @@ class acl extends plugin } } - if(isset($_POST['selected_role'])){ + // Remember the selected ACL role. + if(isset($_POST['selected_role']) && $_POST['aclType'] == 'role'){ $this->aclContents = ""; $this->aclContents = base64_decode($_POST['selected_role']); } @@ -456,24 +484,26 @@ 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.= ""; - $action.= ""; + $action.= image('images/lists/sort-up.png', 'sortup_'.$key); + $action.= image('images/lists/sort-down.png', 'sortdown_'.$key); } if($this->acl_is_readable("")){ - $action.= ""; + $action.= image('images/lists/edit.png','acl_edit_'.$key,msgPool::editButton(_("ACL"))); } if($this->acl_is_removeable("")){ - $action.= ""; + $action.= image('images/lists/trash.png','acl_del_'.$key,msgPool::delButton(_("ACL"))); } $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); @@ -516,12 +546,10 @@ class acl extends plugin $actions =""; if($this->acl_is_readable("")){ - $actions= ""; + $actions.= image('images/lists/edit.png','cat_edit_'.$section, msgPool::editButton(_("category ACL"))); } if($this->acl_is_removeable()){ - $actions.= ""; + $actions.= image('images/lists/trash.png','cat_del_'.$section, msgPool::delButton(_("category ACL"))); } $field1= array("string" => $dsc, "attach" => "style='width:100px'"); @@ -546,6 +574,9 @@ class acl extends plugin /* Generate list */ $tmp= array(); + if ($this->target == "group" && !isset($this->recipients["G:*"])){ + $tmp["G:*"]= _("All users"); + } foreach (array("user" => "users", "group" => "groups") as $field => $arr){ if ($this->target == $field){ foreach ($this->$arr as $key => $value){ @@ -607,7 +638,7 @@ class acl extends plugin function sort_by_priority($list) { - $tmp= session::get('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; asort($plist); $newSort = array(); @@ -664,7 +695,7 @@ class acl extends plugin { $display= ""; $cols= 3; - $tmp= session::get('plist'); + $tmp= session::global_get('plist'); $plist= $tmp->info; asort($plist); @@ -672,33 +703,33 @@ class acl extends plugin $style = "style='width:100px;'"; if($this->acl_is_writeable("")){ - $display .= ""; - $display .= ""; - $display .= " - "; - $display .= ""; - $display .= " - "; + $display .= ""; + $display .= ""; + $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 .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; } /* Build general objects */ @@ -708,8 +739,11 @@ 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 @@ -719,52 +753,49 @@ class acl extends plugin $overall_acl = $currentAcl[0]; } + // Detect configured plugins + $expand = count($currentAcl) > 1 || $currentAcl[0] != ""; + /* Object header */ $tname= preg_replace("/[^a-z0-9]/i","_",$name); - if(session::get('js')) { - if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) { - $display.= "\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
". - "\n ". - "\n ". - "\n ". - "\n "; - } else { - $display.= "\n
"._("Object").": $name". - "\n
". - "\n ". - "\n ". - "\n "; - } + + if($expand){ + $back_color = "#C8C8FF"; + }else{ + $back_color = "#C8C8C8"; + } + + if(isset($_SERVER['HTTP_USER_AGENT']) && + (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || + (preg_match("/presto/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 "; + $display.= "\n
"._("Object").": $name
". + "\n ". + "\n ". + "\n "; } /* 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; @@ -778,20 +809,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'])) { + 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
"._("Object").": $name
". - "\n