X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_acl.inc;h=9302fbeb316651713be2a29278356909163f5a86;hb=2c35405295520149cdfb7a21cc9d7e73b4fb7442;hp=52656353583afeff7b2a4af197b5cee48bf3e5bd;hpb=322d034fa6dcc44054b95686916dcc6ffc83963e;p=gosa.git diff --git a/gosa-core/include/class_acl.inc b/gosa-core/include/class_acl.inc index 526563535..9302fbeb3 100644 --- a/gosa-core/include/class_acl.inc +++ b/gosa-core/include/class_acl.inc @@ -54,6 +54,10 @@ class acl extends plugin var $myAclObjects = array(); var $acl_category = "acl/"; + var $list =NULL; + + var $sectionList = NULL; + function acl (&$config, $parent, $dn= NULL) { /* Include config object */ @@ -117,6 +121,7 @@ class acl extends plugin } $this->groups['G:'.$attrs['dn']]= $attrs['cn'][0].' ['.$dsc.']'; } + $this->groups['G:*']= _("All users"); ksort($this->groups); /* Roles */ @@ -234,8 +239,54 @@ class acl extends plugin /* Finally - we want to get saved... */ $this->is_account= TRUE; + + $this->updateList(); + + // Prepare lists + $this->sectionList = new sortableListing(); + $this->sectionList->setDeleteable(false); + $this->sectionList->setEditable(false); + $this->sectionList->setWidth("100%"); + $this->sectionList->setHeight("120px"); + $this->sectionList->setColspecs(array('200px','*')); + $this->sectionList->setHeader(array(_("Section"),_("Description"))); + $this->sectionList->setDefaultSortColumn(1); + $this->sectionList->setAcl('rwcdm'); // All ACLs, we filter on our own here. } + + function updateList() + { + if(!$this->list){ + $this->list = new sortableListing($this->gosaAclEntry,array(),TRUE); + $this->list->setDeleteable(true); + $this->list->setEditable(true); + $this->list->setColspecs(array('*')); + $this->list->setWidth("100%"); + $this->list->setHeight("400px"); + $this->list->setAcl("rwcdm"); + $this->list->setHeader(array(_("Member"),_("Permissions"),_("Type"))); + } + + + // Add ACL entries to the listing + $lData = array(); + foreach($this->gosaAclEntry as $id => $entry){ + $lData[] = $this->convertForListing($entry); + } + $this->list->setListData($this->gosaAclEntry, $lData); + } + + + function convertForListing($entry) + { + $member = implode($entry['members'],", "); + $acl = implode(array_keys($entry['acl']),", "); + $type = implode(array_keys($entry['acl']),", "); + return(array('data' => array($member, $acl, $this->aclTypes[$entry['type']]))); + } + + function execute() { @@ -257,31 +308,35 @@ class acl extends plugin $aclDialog= FALSE; $firstedit= FALSE; + // Get listing actions. Delete or Edit. + $this->list->save_object(); + $lAction = $this->list->getAction(); + $this->gosaAclEntry = $this->list->getMaintainedData(); + /* 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(); + if($lAction['action'] == "edit"){ + $this->currentIndex = $this->list->getKey($lAction['targets'][0]); + $this->dialogState= 'create'; + $firstedit= TRUE; + $this->dialog= TRUE; + $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])){ @@ -296,35 +351,18 @@ 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"]); - } - continue; - } - - /* Sorting... */ - if (preg_match('/^sortup_.*_x/', $name)){ - $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name); - if ($index > 0){ - $tmp= $this->gosaAclEntry[$index]; - $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index-1]; - $this->gosaAclEntry[$index-1]= $tmp; - } - continue; - } - if (preg_match('/^sortdown_.*_x/', $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]; - $this->gosaAclEntry[$index+1]= $tmp; + if(isset($this->aclContents[$idx])) + unset($this->aclContents[$idx]); + if(isset($this->aclContents["$idx/$key"])) + unset($this->aclContents["$idx/$key"]); } continue; } @@ -349,7 +387,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']); } @@ -464,102 +503,73 @@ class acl extends plugin /* Create templating instance */ $smarty= get_smarty(); + $smarty->assign("usePrototype", "true"); $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 */ - $aclList= new divSelectBox("aclList"); - $aclList->SetHeight(450); - - /* 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" => $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)); - } - - $smarty->assign("aclList", $aclList->DrawList()); + $this->updateList(); + $smarty->assign("aclList", $this->list->render()); } if ($this->dialogState == 'create'){ - /* Draw list */ - $aclList= new divSelectBox("aclList"); - $aclList->SetHeight(150); - - /* Add settings for all categories to the (permanent) list */ - foreach ($this->aclObjects as $section => $dsc){ - $summary= ""; - 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"])){ - $summary.= "$oc, "; - continue; - } - if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){ - $summary.= "$oc, "; - } - } - /* Set summary... */ - if ($summary == ""){ - $summary= ''._("No ACL settings for this category!").''; - } else { - $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary)); - } + // Create a map of all used sections, this allows us to simply hide the remove button + // if no acl is configured for the given section + // e.g. ';all;department/country;users/user; + $usedList = ";".implode(array_keys($this->aclContents),';').";"; + + /* Add settings for all categories to the (permanent) list */ + $data = $lData = array(); + foreach ($this->aclObjects as $section => $dsc){ + $summary= ""; + 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"])){ + $summary.= "$oc, "; + continue; + } + if (isset($this->aclContents[$oc]) && + !isset($this->aclContents[$oc][0]) && + count($this->aclContents[$oc])){ + $summary.= "$oc, "; + } + } - $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); - $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'"); - $aclList->AddEntry(array($field1, $field2, $field3)); - } + /* Set summary... */ + if ($summary == ""){ + $summary= ''._("No ACL settings for this category!").''; + } else { + $summary= trim($summary,", "); + $summary= " ".sprintf(_("Contains ACLs for these objects: %s"), $summary); + } - $smarty->assign("aclList", $aclList->DrawList()); + $actions =""; + if($this->acl_is_readable("")){ + $actions.= image('images/lists/edit.png','cat_edit_'.$section, + msgPool::editButton(_("category ACL"))); + } + if($this->acl_is_removeable() && preg_match("/;".$section."(;|\/)/", $usedList)){ + $actions.= image('images/lists/trash.png','cat_del_'.$section, + msgPool::delButton(_("category ACL"))); + } + $data[] = $section; + $lData[] = array('data'=>array($dsc, $summary, $actions)); + } + $this->sectionList->setListData($data,$lData); + $this->sectionList->update(); + $smarty->assign("aclList", $this->sectionList->render()); + $smarty->assign("aclType", $this->aclType); $smarty->assign("aclFilter", $this->aclFilter); $smarty->assign("aclTypes", $this->aclTypes); @@ -575,6 +585,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){ @@ -701,38 +714,37 @@ 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 */ $list =$this->sort_by_priority($list); - $this->aclContents= array(); foreach ($list as $key => $name){ /* Create sub acl if it does not exist */ @@ -764,34 +776,27 @@ class acl extends plugin $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 "; - } 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(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 */ @@ -821,12 +826,12 @@ class acl extends plugin $display.= "\n ". "\n
"._("Object").": $name
". "\n