Code

Mimetypes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jul 2008 13:43:32 +0000 (13:43 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jul 2008 13:43:32 +0000 (13:43 +0000)
-Added freeze handling

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11707 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc
gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc
gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc

index 23c76196c0db4a4666a3a629e0a5fe64d58e8420..7c80b55ed5c53e33785bfd51bc71912689c00d7f 100644 (file)
@@ -164,6 +164,10 @@ class divListMimeTypes extends MultiSelectWindow
 
     foreach($list as $key => $val){
 
+      /* Check FAI state 
+       */  
+      $FAIstate = $val['FAIstate'][0];
+
       $ui       = get_userinfo();
       $acl      = $ui->get_permissions($val['dn'],"mimetypes/mimetype");
       $acl_all  = $ui->has_complete_category_acls($val['dn'],"mimetypes") ;
@@ -171,16 +175,28 @@ class divListMimeTypes extends MultiSelectWindow
       $action = "";
 
       /* Add copy & cut functionality */
-      $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype");
+      if(!preg_match("/freeze/i",$FAIstate)){
+        $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype");
+      }else{
+        $action.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
+        $action.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
+      }
 
       $action.= "<input class='center' type='image'
         src='images/lists/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
 
       /* Add snapshot icon */
-      $action.= $this->parent->get_snapshot_action($val['dn'],$this->module);
+      if(!preg_match("/freeze/i",$FAIstate)){
+        $action.= $this->parent->get_snapshot_action($val['dn'],$this->module);
+      }else{
+        $action.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
+        $action.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
+      }
 
       /* Add delete button */
-      if(preg_match("/d/",$acl)){
+      if(preg_match("/freeze/i",$FAIstate)){
+        $action .= "<img src='images/freeze.png' class='center' alt='!' title='"._("Freezed")."'>";
+      }elseif(preg_match("/d/",$acl)){
         $action.= "<input class='center' type='image'
           src='images/lists/trash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
       }else{
index f5cb4d0aad5278ecfc7f5b429c34332211d3dd6a..0e51158e6fcf146b2cb1a9dd440ec7f65c0600c8 100644 (file)
@@ -37,6 +37,8 @@ class mimetype extends plugin
   var $DivApps                                                             = NULL;
   var $DivEApps                                                                    = NULL;
 
+  var $FAIstate ="";
+
   /* These vars will be copied too, if you use copy&paste mode */
   var $CopyPasteVars        = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData",
                                     "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon");
@@ -127,7 +129,7 @@ class mimetype extends plugin
         $this->base= dn2base($ui->dn);
       }
     } else {
-      $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
+      $this->base= preg_replace ("/^.*,".normalizePreg(get_ou("mimetypeou"))."/", "", $this->dn);
     }
 
     /* Get icon data */
@@ -156,13 +158,13 @@ class mimetype extends plugin
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translation){
-      $smarty->assign($name."ACL",$this->getacl($name));
+      $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/i",$this->FAIstate)));
     }
 
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once){
+      if(preg_match("/^chooseBase/",$name) && $once && !preg_match("/freeze/i",$this->FAIstate)){
         $once = false;
         $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
         $this->dialog->setCurrentBase($this->base);
@@ -205,81 +207,83 @@ class mimetype extends plugin
     $once = true;
 
     /* Walk through posts and try to find some commands for us. */
-    foreach($_POST as $name => $value){
+    if(!preg_match("/freeze/i",$this->FAIstate)){
+      foreach($_POST as $name => $value){
 
-      /* Walk through possible commands */
-      foreach($posts as $regex => $action){
+        /* Walk through possible commands */
+        foreach($posts as $regex => $action){
 
-        /* Check if there is a command posted */
-        if(preg_match($regex,$name) && $once){
-          $once = false;
+          /* Check if there is a command posted */
+          if(preg_match($regex,$name) && $once){
+            $once = false;
 
-          /* Get action vars */
-          $func                = $action['Func'];              // Get function name 
-          $attr                = $action['Attr'];              // Get attribute name
+            /* Get action vars */
+            $func              = $action['Func'];              // Get function name 
+            $attr              = $action['Attr'];              // Get attribute name
 
-          /* Get entry id */
-          $s_entry     = preg_replace($regex,"",$name);
-          $s_entry     = preg_replace("/_[xy]$/","",$s_entry); 
+            /* Get entry id */
+            $s_entry   = preg_replace($regex,"",$name);
+            $s_entry   = preg_replace("/_[xy]$/","",$s_entry); 
 
-          /* Execute a command with the given attribute and entry 
-             e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
-          if($this->acl_is_writeable($attr)){
-            $this->$attr= $this->$func($s_entry,$this->$attr,true);                                     
+            /* Execute a command with the given attribute and entry 
+               e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
+            if($this->acl_is_writeable($attr)){
+              $this->$attr= $this->$func($s_entry,$this->$attr,true);                                   
+            }
           }
         }
       }
-    }
 
-    /* Set a new icon was requested */
-    if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
-      $this->set_new_picture($_FILES['picture_file']['tmp_name']);             
-    }
-
-    /* Add gotoMimeFilePattern */
-    if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
-      if($this->acl_is_writeable("gotoMimeFilePattern")){
-        $str = $_POST['NewFilePattern'];
-        if(!empty($str)){
-          $this->use_gotoMimeFilePattern[] = $str;
-        }
-      }
-    }  
-
-    /* Add gotoMimeFilePattern */
-    if(isset($_POST['AddNewApplication']) && 
-            (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){
-      if($this->acl_is_writeable("gotoMimeApplication")){
-        $str = "";
-        if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){
-          $str = get_post("NewApplicationSelect");
-        }
-        if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){
-          $str = get_post("NewApplication");
-        }
-        if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){
-          $this->use_gotoMimeApplication[] = $str;
-        }
+      /* Set a new icon was requested */
+      if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
+        $this->set_new_picture($_FILES['picture_file']['tmp_name']);           
       }
-    }  
 
-    /* Add embedded application 
-     *  - From input or from select box 
-     */
-    if(isset($_POST['AddNewEmbeddedApplication']) && 
-            (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){
-      if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
-        $str = "";
-        if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){
-          $str = get_post('NewEmbeddedApplicationSelect');
+      /* Add gotoMimeFilePattern */
+      if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
+        if($this->acl_is_writeable("gotoMimeFilePattern")){
+          $str = $_POST['NewFilePattern'];
+          if(!empty($str)){
+            $this->use_gotoMimeFilePattern[] = $str;
+          }
         }
-        if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){
-          $str = get_post('NewEmbeddedApplication');
+      }        
+
+      /* Add gotoMimeFilePattern */
+      if(isset($_POST['AddNewApplication']) && 
+          (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){
+        if($this->acl_is_writeable("gotoMimeApplication")){
+          $str = "";
+          if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){
+            $str = get_post("NewApplicationSelect");
+          }
+          if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){
+            $str = get_post("NewApplication");
+          }
+          if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){
+            $this->use_gotoMimeApplication[] = $str;
+          }
         }
-        if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){
-          $this->use_gotoMimeEmbeddedApplication[] = $str;
+      }        
+
+      /* Add embedded application 
+       *  - From input or from select box 
+       */
+      if(isset($_POST['AddNewEmbeddedApplication']) && 
+          (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){
+        if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
+          $str = "";
+          if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){
+            $str = get_post('NewEmbeddedApplicationSelect');
+          }
+          if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){
+            $str = get_post('NewEmbeddedApplication');
+          }
+          if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){
+            $this->use_gotoMimeEmbeddedApplication[] = $str;
+          }
         }
-      }
+      }        
     }  
 
     /* Create divlists */
@@ -291,7 +295,7 @@ class mimetype extends plugin
     $DivEApps          -> SetHeight(100);
 
 
-    if($this->acl_is_writeable("gotoMimeFilePattern")){
+    if($this->acl_is_writeable("gotoMimeFilePattern") && !preg_match("/freeze/i",$this->FAIstate)){
       $Pattern_Actions= " <input type='image' src='images/lists/sort-up.png'   class='center'  name='Pattern_SortUp_%s' >&nbsp;
       <input type='image' src='images/lists/sort-down.png'     class='center'  name='Pattern_SortDown_%s'>&nbsp;
       <input type='image' src='images/lists/trash.png' class='center'  name='Pattern_Remove_%s'>";
@@ -299,7 +303,7 @@ class mimetype extends plugin
       $Pattern_Actions= "";    
     }
 
-    if($this->acl_is_writeable("gotoMimeApplication")){
+    if($this->acl_is_writeable("gotoMimeApplication") && !preg_match("/freeze/i",$this->FAIstate)){
       $Apps_Actions    = " <input type='image' src='images/lists/sort-up.png'  class='center'  name='Apps_SortUp_%s' >&nbsp;
       <input type='image' src='images/lists/sort-down.png'     class='center'  name='Apps_SortDown_%s'>&nbsp;
       <input type='image' src='images/lists/trash.png' class='center'  name='Apps_Remove_%s'>";
@@ -307,7 +311,7 @@ class mimetype extends plugin
       $Apps_Actions= "";       
     }
 
-    if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
+    if($this->acl_is_writeable("gotoMimeEmbeddedApplication") && !preg_match("/freeze/i",$this->FAIstate)){
       $EApps_Actions   = " <input type='image' src='images/lists/sort-up.png'  class='center'  name='EApps_SortUp_%s' >&nbsp;
       <input type='image' src='images/lists/sort-down.png'     class='center'  name='EApps_SortDown_%s'>&nbsp;
       <input type='image' src='images/lists/trash.png' class='center'  name='EApps_Remove_%s'>";
@@ -369,7 +373,7 @@ class mimetype extends plugin
 
   function save_object()
   {
-    if(isset($_POST['MimeGeneric'])){
+    if(isset($_POST['MimeGeneric']) && !preg_match("/freeze/i",$this->FAIstate)){
 
       /* Create a base backup and reset the
          base directly after calling plugin::save_object();
index c8f4adb73824e11f7eda5ecbe73880d2e7909857..080c596a231f72950f02da80a507bee326753579 100644 (file)
@@ -306,6 +306,9 @@ class mimetypeManagement extends plugin
 
       /* Register mimetabs to trigger edit dialog */
       $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
+      if($this->IsReleaseManagementActivated()){
+        $this->mimetabs->set_FAIstate($this->mimetypes[$s_entry]['FAIstate'][0]);
+      }
       $this->mimetabs->parent = &$this;
       $this->mimetabs->set_acl_base($this->dn);
       session::set('objectinfo',$this->dn);
@@ -496,12 +499,16 @@ class mimetypeManagement extends plugin
       /* Don't show buttons if tab dialog requests this */
       if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){
         $display.= "<p style=\"text-align:right\">\n";
-        $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
-        $display.= "&nbsp;\n";
-        if ($this->dn != "new"){
-          $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
+
+        if(isset($this->mimetabs->FAIstate) && !preg_match("/freeze/i",$this->mimetabs->FAIstate)){
+          $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
           $display.= "&nbsp;\n";
+          if ($this->dn != "new"){
+            $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
+            $display.= "&nbsp;\n";
+          }
         }
+      
         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
         $display.= "</p>";
       }
@@ -568,15 +575,24 @@ class mimetypeManagement extends plugin
       $SubSearch= FALSE;
     }
 
+    /* Add FAIstate to the search attributes */
+    $search_attrs = array("cn","description","dn","objectClass");
+    if($this->IsReleaseManagementActivated()) {
+      $search_attrs[] = "FAIstate";
+    }
+
     if($SubSearch){
-      $res= get_sub_list($Filter, "mimetypes",get_ou("mimeou"), $use_base, array("cn","description","dn","objectClass"), $Flags);
+      $res= get_sub_list($Filter, "mimetypes",get_ou("mimeou"), $use_base, $search_attrs, $Flags);
     }else{
-      $res= get_list($Filter, "mimetypes",$use_base, array("cn","description","dn","objectClass"), $Flags);
+      $res= get_list($Filter, "mimetypes",$use_base, $search_attrs, $Flags);
     }
 
 
     $tmp2 = array();
     foreach ($res as $val){
+      if(!isset($val['FAIstate'])){
+        $val['FAIstate'][0] = "";
+      }
       $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val;
       $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn'];
     }
index a2fc2bb40569000ae178b841c9e138260f246ef8..45a8f99dd55f374f4cd70daa98459fa022168ae3 100644 (file)
@@ -2,7 +2,8 @@
 
 class mimetabs extends tabs
 {
-  var $parent = FALSE;
+  var $parent   = FALSE;
+  var $FAIstate = "";  
 
   function mimetabs($config, $data, $dn,$category)
   {
@@ -12,6 +13,14 @@ class mimetabs extends tabs
     $this->addSpecialTabs();
   }
 
+  function set_FAIstate($state)
+  {
+    $this->FAIstate = $state;
+    foreach($this->by_name as $name => $desc){
+      $this->by_object[$name]->FAIstate = $state;
+    }
+  }
+
   function save($ignore_account= FALSE)
   {
     $baseobject= $this->by_object['mimetype'];