From 91d4f93869290e5f671e744859e82f4bc42615a2 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 8 Sep 2006 03:28:01 +0000 Subject: [PATCH] Added Mimetype acls git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4618 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../mimetypes/class_divListMimeTypes.inc | 44 ++++++++++++++++--- .../admin/mimetypes/class_mimetypeGeneric.inc | 37 ++++++++++------ .../mimetypes/class_mimetypeManagement.inc | 31 +++++-------- plugins/admin/mimetypes/tabs_mimetypes.inc | 4 +- 4 files changed, 74 insertions(+), 42 deletions(-) diff --git a/plugins/admin/mimetypes/class_divListMimeTypes.inc b/plugins/admin/mimetypes/class_divListMimeTypes.inc index 2fd85ecb3..da7850468 100755 --- a/plugins/admin/mimetypes/class_divListMimeTypes.inc +++ b/plugins/admin/mimetypes/class_divListMimeTypes.inc @@ -103,6 +103,9 @@ class divListMimeTypes extends MultiSelectWindow /* Create listhead, it will be shown on top of the divlist. * It provides general navigation and object creation */ + $ui = get_userinfo(); + $acl = $ui->get_permissions("cn=dummy,ou=mimetypes,".$this->selectedBase,"mimetypes/mimetype"); + $listhead = "
". "  ". @@ -114,8 +117,13 @@ class divListMimeTypes extends MultiSelectWindow "title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ". "  "; $listhead .= $this->get_snapshot_header($this->selectedBase); - $listhead .= "  ". + + if(preg_match("/c/",$acl)){ + $listhead .= "  "; + } + + $listhead .= $Copy_Paste. "  ". _("Base")." ". @@ -158,20 +166,43 @@ class divListMimeTypes extends MultiSelectWindow Attach objects ********************/ + $ui = get_userinfo(); + $acl = $ui->get_permissions("cn=dummy,ou=mimetypes,".$this->selectedBase,"mimetypes/mimetype"); + + print_a($list); foreach($list as $key => $val){ /* Create action icons */ $actions = $this->GetSnapShotActions($val['dn']); + + + /* Get copy Paste icons */ if($this->parent->CopyPasteHandler){ - $actions.= " "; + + /* Only add cut icon, if we are allowed to move this user */ + if(preg_match("/m/",$acl)){ + $actions.= " "; + }else{ + $actions.= " "; + } + + /* Copy is allowed everytime */ $actions.= " "; } + + /* Add edit button */ $actions.= ""; - $actions.= ""; + + /* Add delete button */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + }else{ + $actions.= " "; + } $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; @@ -185,7 +216,6 @@ class divListMimeTypes extends MultiSelectWindow $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); $this->AddElement(array($field1,$field2,$field3)); } - } function Save() diff --git a/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/plugins/admin/mimetypes/class_mimetypeGeneric.inc index f5d7f3ae1..f200bca26 100644 --- a/plugins/admin/mimetypes/class_mimetypeGeneric.inc +++ b/plugins/admin/mimetypes/class_mimetypeGeneric.inc @@ -12,7 +12,6 @@ class mimetype extends plugin "gotoMimeGroup"); /* Class vars */ - var $acl; var $ui; var $cn = ""; var $gotoMimeLeftClickAction = "I"; @@ -149,6 +148,18 @@ class mimetype extends plugin { $smarty = get_smarty(); + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Assign base ACL */ + $baseACL = $this->getacl("base"); + if(!$this->acl_is_moveable()) { + $baseACL = preg_replace("/w/","",$baseACL); + } + $smarty->assign("baseACL", $baseACL); + /* Base select dialog */ $once = true; foreach($_POST as $name => $value){ @@ -209,7 +220,7 @@ class mimetype extends plugin /* Execute a command with the given attribute and entry e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */ - if(chkacl($this->acl,$attr) == ""){ + if($this->acl_is_writeable($attr)){ $this->$attr= $this->$func($s_entry,$this->$attr,true); } } @@ -223,7 +234,7 @@ class mimetype extends plugin /* Add gotoMimeFilePattern */ if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){ - if(chkacl($this->acl,"gotoMimeFilePattern") == ""){ + if($this->acl_is_writeable("gotoMimeFilePattern")){ $str = $_POST['NewFilePattern']; if(!empty($str)){ $this->use_gotoMimeFilePattern[] = $str; @@ -233,7 +244,7 @@ class mimetype extends plugin /* Add gotoMimeFilePattern */ if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){ - if(chkacl($this->acl,"gotoMimeApplication") == ""){ + if($this->acl_is_writeable("gotoMimeApplication")){ $str = $_POST['NewApplication']; if(!empty($str)){ $this->use_gotoMimeApplication[] = $str; @@ -243,7 +254,7 @@ class mimetype extends plugin /* Add gotoMimeFilePattern */ if(isset($_POST['AddNewEmbeddedApplication']) && isset($_POST['NewEmbeddedApplication'])){ - if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){ + if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ $str = $_POST['NewEmbeddedApplication']; if(!empty($str)){ $this->use_gotoMimeEmbeddedApplication[] = $str; @@ -260,7 +271,7 @@ class mimetype extends plugin $DivEApps -> SetHeight(100); - if(chkacl($this->acl,"gotoMimeFilePattern") == ""){ + if($this->acl_is_writeable("gotoMimeFilePattern")){ $Pattern_Actions= "     "; @@ -268,7 +279,7 @@ class mimetype extends plugin $Pattern_Actions= ""; } - if(chkacl($this->acl,"gotoMimeApplication") == ""){ + if($this->acl_is_writeable("gotoMimeApplication")){ $Apps_Actions = "     "; @@ -276,7 +287,7 @@ class mimetype extends plugin $Apps_Actions= ""; } - if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){ + if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ $EApps_Actions = "     "; @@ -302,7 +313,6 @@ class mimetype extends plugin $fields = array($field1,$field2); $DivEApps -> AddEntry($fields); } - $smarty->assign("baseACL", chkacl($this->acl,"base")); $smarty->assign("bases", $this->config->idepartments); $smarty->assign("base_select", $this->base); $smarty->assign("isReleaseMimeType", $this->isReleaseMimeType); @@ -313,7 +323,6 @@ class mimetype extends plugin /* Assign class vars to smarty */ foreach($this->attributes as $attr){ $smarty->assign($attr,$this->$attr); - $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); } /* Assign additional vars that are not included in attributes*/ @@ -332,7 +341,9 @@ class mimetype extends plugin { if(isset($_POST['MimeGeneric'])){ plugin::save_object(); - + + print_a($this); + /* Only save base if we are not in release mode */ if(!$this->isReleaseMimeType){ if(isset($_POST['base'])){ @@ -341,7 +352,7 @@ class mimetype extends plugin } /* Save radio buttons */ - if(chkacl($this->acl,"gotoMimeLeftClickAction")== ""){ + if($this->acl_is_writeable("gotoMimeLeftClickAction")){ if(isset($_POST['gotoMimeLeftClickAction_IE'])){ $chr = $_POST['gotoMimeLeftClickAction_IE']; if($chr == "E"){ @@ -497,7 +508,7 @@ class mimetype extends plugin } else { $new_dn= $this->dn; } - if (chkacl($this->acl, "create") != ""){ + if (!$this->acl_is_createable() && $this->dn == "new"){ $message[]= _("You have no permissions to create a mime type on this 'Base'."); } diff --git a/plugins/admin/mimetypes/class_mimetypeManagement.inc b/plugins/admin/mimetypes/class_mimetypeManagement.inc index a4da4d430..c18cae801 100755 --- a/plugins/admin/mimetypes/class_mimetypeManagement.inc +++ b/plugins/admin/mimetypes/class_mimetypeManagement.inc @@ -32,7 +32,6 @@ class mimetypeManagement extends plugin var $enableReleaseManagement = false; var $mimetabs = NULL; var $snapDialog = NULL; - var $acl = NULL; var $CopyPasteHandler = NULL; function mimetypeManagement ($config, $ui) @@ -58,9 +57,6 @@ class mimetypeManagement extends plugin $this->DivListMimeTypes->DisableCheckBox("SubSearch"); } - /* Get acls */ - $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $this->acl= get_module_permission($acl, "mimetype", $ui->dn); } @@ -169,12 +165,9 @@ class mimetypeManagement extends plugin $this->dn= "new"; /* Create new usertab object */ - $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn); - - /* set acl */ - $acl= get_permissions ($this->DivListMimeTypes->selectedBase, $this->ui->subtreeACL); - $this->mimetabs->set_acl($acl); - } + $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes/mimetype"); + $this->mimetabs->set_acl_base($this->DivListMimeTypes->selectedBase); + } /**************** @@ -249,11 +242,8 @@ class mimetypeManagement extends plugin /* Register mimetabs to trigger edit dialog */ - $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn); - - /* Set up the users ACL's for this 'dn' */ - $acl= get_permissions ($this->dn, $this->ui->subtreeACL); - $this->mimetabs->set_acl($acl); + $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes/mimetype"); + $this->mimetabs->set_acl_base($this->dn); $_SESSION['objectinfo']= $this->dn; } @@ -270,7 +260,7 @@ class mimetypeManagement extends plugin /* Load permissions for selected 'dn' and check if we're allowed to remove this 'dn' */ - if (chkacl($this->acl, "delete") == ""){ + if ($this->acl_is_removeable()){ /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ @@ -301,12 +291,11 @@ class mimetypeManagement extends plugin /* Some nice guy may send this as POST, so we've to check for the permissions again. */ - if (chkacl($this->acl, "delete") == ""){ + if ($this->acl_is_removeable()){ /* Delete request is permitted, perform LDAP action */ - $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn); - $acl= get_permissions ($this->dn, $this->ui->subtreeACL); - $this->mimetabs->set_acl($acl); + $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes/mimetype"); + $this->mimetabs->set_acl_base($this->dn); $this->mimetabs->delete (); gosa_log ("Mime type object'".$this->dn."' has been removed"); unset ($this->mimetabs); @@ -416,6 +405,8 @@ class mimetypeManagement extends plugin /* Get results and create index */ $res= get_list($Filter, "mimetypes", $use_base, array("cn","description","dn","objectClass"), $Flags); + echo $Filter; + print_a(array($res)); foreach ($res as $val){ $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; } diff --git a/plugins/admin/mimetypes/tabs_mimetypes.inc b/plugins/admin/mimetypes/tabs_mimetypes.inc index 57026421c..4d09f39f2 100755 --- a/plugins/admin/mimetypes/tabs_mimetypes.inc +++ b/plugins/admin/mimetypes/tabs_mimetypes.inc @@ -4,9 +4,9 @@ class mimetabs extends tabs { var $Release= ""; - function mimetabs($config, $data, $dn) + function mimetabs($config, $data, $dn,$category) { - tabs::tabs($config, $data, $dn); + tabs::tabs($config, $data, $dn,$category); /* Add references/acls/snapshots */ $this->addSpecialTabs(); -- 2.30.2