Code

Added Mimetype acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 8 Sep 2006 03:28:01 +0000 (03:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 8 Sep 2006 03:28:01 +0000 (03:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4618 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/mimetypes/class_divListMimeTypes.inc
plugins/admin/mimetypes/class_mimetypeGeneric.inc
plugins/admin/mimetypes/class_mimetypeManagement.inc
plugins/admin/mimetypes/tabs_mimetypes.inc

index 2fd85ecb3cd627485b77ad8b819b843319bbb680..da7850468fe0c8e31c25cb70be7881352c9d9e4e 100755 (executable)
@@ -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 = "<div style='background:#F0F0F9;padding:5px;'>".
       " <input class='center' type='image' src='images/list_root.png' align='middle' ".
       "title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
@@ -114,8 +117,13 @@ class divListMimeTypes extends MultiSelectWindow
       "title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
     $listhead .= $this->get_snapshot_header($this->selectedBase);
-    $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_mime.png' alt='"._("new").
-      "' title='"._("Create new mime type")."' name='mime_new'>&nbsp;".
+    
+    if(preg_match("/c/",$acl)){
+      $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_mime.png' alt='"._("new").
+        "' title='"._("Create new mime type")."' name='mime_new'>&nbsp;";
+    }
+  
+    $listhead .= 
       $Copy_Paste.
       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
@@ -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.= "<input class='center' type='image'
-          src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+
+        /* Only add cut icon, if we are allowed to move this user */
+        if(preg_match("/m/",$acl)){
+          $actions.= "<input class='center' type='image'
+            src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+        }else{
+          $actions.= "<img src='images/empty.png' alt='&nbsp;'>";
+        }
+
+        /* Copy is allowed everytime */
         $actions.= "<input class='center' type='image'
           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
       }
+
+      /* Add edit button */
       $actions.= "<input class='center' type='image'
         src='images/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
-      $actions.= "<input class='center' type='image'
-        src='images/edittrash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
+
+      /* Add delete button */
+      if(preg_match("/d/",$acl)){
+        $actions.= "<input class='center' type='image'
+          src='images/edittrash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
+      }else{
+        $actions.= "<img src='images/empty.png' alt='&nbsp;'>";
+      }
 
       $title = "title='".preg_replace('/ /', '&nbsp;', @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()
index f5d7f3ae10c4b04a774c890aa372488fea9d00d3..f200bca2650920c6a1669f73ab33c576892f773e 100644 (file)
@@ -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= " <input type='image' src='images/sort_up.png'         class='center'  name='Pattern_SortUp_%s' >&nbsp;
       <input type='image' src='images/sort_down.png'   class='center'  name='Pattern_SortDown_%s'>&nbsp;
       <input type='image' src='images/edittrash.png'   class='center'  name='Pattern_Remove_%s'>";
@@ -268,7 +279,7 @@ class mimetype extends plugin
       $Pattern_Actions= "";    
     }
 
-    if(chkacl($this->acl,"gotoMimeApplication") == ""){
+    if($this->acl_is_writeable("gotoMimeApplication")){
       $Apps_Actions    = " <input type='image' src='images/sort_up.png'        class='center'  name='Apps_SortUp_%s' >&nbsp;
       <input type='image' src='images/sort_down.png'   class='center'  name='Apps_SortDown_%s'>&nbsp;
       <input type='image' src='images/edittrash.png'   class='center'  name='Apps_Remove_%s'>";
@@ -276,7 +287,7 @@ class mimetype extends plugin
       $Apps_Actions= "";       
     }
 
-    if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){
+    if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
       $EApps_Actions   = " <input type='image' src='images/sort_up.png'        class='center'  name='EApps_SortUp_%s' >&nbsp;
       <input type='image' src='images/sort_down.png'   class='center'  name='EApps_SortDown_%s'>&nbsp;
       <input type='image' src='images/edittrash.png'   class='center'  name='EApps_Remove_%s'>";
@@ -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'.");
     }
 
index a4da4d430fb733be84339de8230e682380f997b0..c18cae801722f1206d8f4b7d6310ee231423cc03 100755 (executable)
@@ -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;
     }
index 57026421c3577fb10533a25a8fd8521edfe880c2..4d09f39f25b88b17be2ff96cb9dd15a84fad1233 100755 (executable)
@@ -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();