Code

The setStatus function expects that the service was already saved.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Jun 2006 04:50:05 +0000 (04:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Jun 2006 04:50:05 +0000 (04:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3687 594d385d-05f5-0310-b6e9-bd551577e9d8

15 files changed:
plugins/admin/systems/class_goCupsServer.inc
plugins/admin/systems/class_goFaxServer.inc
plugins/admin/systems/class_goFonServer.inc
plugins/admin/systems/class_goGlpiServer.inc
plugins/admin/systems/class_goImapServer.inc
plugins/admin/systems/class_goKrbServer.inc
plugins/admin/systems/class_goLdapServer.inc
plugins/admin/systems/class_goLogDBServer.inc
plugins/admin/systems/class_goMailServer.inc
plugins/admin/systems/class_goNtpServer.inc
plugins/admin/systems/class_goShareServer.inc
plugins/admin/systems/class_goSyslogServer.inc
plugins/admin/systems/class_goTerminalServer.inc
plugins/admin/systems/goImapServer.tpl
plugins/admin/systems/goMailServer.tpl

index c926db6e1f1d7a0bf160eae14f30c5b9f6be5a67..8d3c0065f71a6b167a827990f464e2d0230cf250 100644 (file)
@@ -90,29 +90,25 @@ class goCupsServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->cat($this->dn,array("objectClass"));
-      
     if($ldap->count()){
-      $attrs =array();
+
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goCupsServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goCupsServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
-  
+
   function check()
   { 
     $message = plugin::check();
index ff8805b10f9bd6eb36e3adbbd28131fbf70324d3..2fec5525977e5dc8b7597af6dd272e88f847e070 100644 (file)
@@ -92,38 +92,22 @@ class goFaxServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goFaxAdmin", "goFaxPassword"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goFaxAdmin", "goFaxPassword") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goFaxServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goFaxServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
   
index adb0d55f8b45efa950366a006c785b9346b82e30..cdb123bde763191c7e70db472b3b409743a6ffcf 100644 (file)
@@ -95,41 +95,25 @@ class goFonServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goFonAdmin", "goFonAreaCode", "goFonCountryCode","goFonPassword"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goFonAdmin", "goFonAreaCode", "goFonCountryCode","goFonPassword") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goFonServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goFonServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
-  
+
   function check()
   { 
     $message = plugin::check();
index 36caf5c92820010fe00f4f6a2c6307bf3a63f5e5..ce7569dfeb53b94043b8e0e65b324334d71cd556 100644 (file)
@@ -94,38 +94,22 @@ class goGlpiServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goGlpiAdmin","goGlpiDatabase"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goGlpiAdmin","goGlpiDatabase") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goGlpiServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goGlpiServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
   
index 301a2dd8721b49258e180e4344cafde733554c1a..56d658bab5cbb17314c802bb3e3c15ab9460f1ce 100644 (file)
@@ -72,6 +72,7 @@ class goImapServer extends plugin{
     }
     $smarty->assign("Actions",$this->Actions);
     $smarty->assign("is_new",$this->dn);
+    $smarty->assign("is_acc",$this->initially_was_account);
     return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__))));
   }
 
@@ -126,33 +127,16 @@ class goImapServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goImapName","goImapConnect","goImapAdmin","goImapPassword"));
-
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
 
-      $attrs =array();
-      foreach(array("goImapName","goImapConnect","goImapAdmin","goImapPassword") as $required){
-        if(!isset($attrs[$required])){
-          if(empty($this->$required)){
-            print_red(_("Can't set new status while there are blank option within generic configuration part."));
-            return;
-          }else{
-            $attrs[$required] = $this->$required;
-          }
-        }else{
-          $attrs[$required] = $attrs[$required][0];
-        }
-      }
-
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
       }
-      if(!in_array("goImapServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goImapServer";
-      }
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
index ca2bc66f58465cb56bce350bc2122af5d64e370b..34dd98309bf6bd40a1cfe7334fca303095048119 100644 (file)
@@ -93,41 +93,25 @@ class goKrbServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goKrbRealm","goKrbAdmin","goKrbPassword"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goKrbRealm","goKrbAdmin","goKrbPassword") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goKrbServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goKrbServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
-
-  
   function check()
   { 
     $message = plugin::check();
index f5a28488279f392a2ba41abfb1267ebc6ca3c4d4..885970ac03bfdbc20dd5c014d424f9980fddec48 100644 (file)
@@ -91,38 +91,22 @@ class goLdapServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goLdapBase"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goLdapBase") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goLdapServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goLdapServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
   
index a857050092163844dcccf2fa15dbf223fefa4c0d..47d132b199e95e55e486e586b6167907e6434994 100644 (file)
@@ -93,41 +93,25 @@ class goLogDBServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goLogAdmin","goLogPassword"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goLogAdmin","goLogPassword") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goLogDBServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goLogDBServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
-  
+
   function check()
   { 
     $message = plugin::check();
index 8afd4dda024a3274e20c69e5f30dc16a50b1d751..701428b02831b8900dd6dc1e0b98c8ebd3d0a2b7 100644 (file)
@@ -46,8 +46,7 @@ class goMailServer extends plugin{
 
     $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
                             SERVICE_STARTED => SERVICE_STARTED,
-                            SERVICE_RESTARTED=>SERVICE_RESTARTED, 
-                            "mailqueue"=>"mailqueue");
+                            SERVICE_RESTARTED=>SERVICE_RESTARTED); 
 
     /* Fill  RestrictionFilters   TransportProtocols  from external hooks */
     $str = $this->config->data['TABS']['SERVERSERVICE'];
@@ -426,6 +425,7 @@ class goMailServer extends plugin{
 
 
     $smarty->assign("is_new",                       $this->dn);
+    $smarty->assign("is_acc",                       $this->initially_was_account);
     $smarty->assign("TransportProtocols",           $this->TransportProtocols);
     $smarty->assign("Actions",                      $this->Actions);
     $smarty->assign("RestrictionFilters",           $this->RestrictionFilters);
@@ -573,21 +573,16 @@ class goMailServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->cat($this->dn,array("objectClass"));
-
     if($ldap->count()){
 
-      $attrs =array();
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
       }
-      if(!in_array("goMailServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goMailServer";
-      }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
index 9188acf3fa6e5e4487f6eecadc49d737029875cd..fa6e11c072eddfef8b5f9071b937bfa7f227f118 100644 (file)
@@ -118,28 +118,25 @@ class goNtpServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->cat($this->dn,array("objectClass"));
-      
     if($ldap->count()){
-      $attrs =array();
+
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goNtpServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goNtpServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
-  
+
+
   function check(){ return array();}
   
 function save_object(){;}
index 7911dcb0e4687ae4fe5c2f71f257617e8b94fece..3a00600e66a5e40ce855e5401e96ba69061cf61c 100644 (file)
@@ -208,38 +208,22 @@ class goShareServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->cat($this->dn,array("objectClass"));
-
     if($ldap->count()){
-      $attrs =array();
-      foreach(array() as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goShareServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goShareServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
 
index f3481a47c0f55c5e9a65b0b54aefe841d2abd9e1..7bb179adf80410898a025e22603e5b9c675342cc 100644 (file)
@@ -90,29 +90,25 @@ class goSyslogServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->cat($this->dn,array("objectClass"));
-      
     if($ldap->count()){
-      $attrs =array();
+
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goSyslogServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goSyslogServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
-  
+
   function check()
   { 
     $message = plugin::check();
index a9d2d59637e8c68c3c8a81cb4ec6e3b3e5e562e3..48f01b4f765868962df2c575d053ef6e9c8c4bbe 100644 (file)
@@ -93,41 +93,25 @@ class goTerminalServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goXdmcpIsEnabled", "goFontPath"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goXdmcpIsEnabled", "goFontPath") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goTerminalServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goTerminalServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
-  
+
   function check()
   { 
     $message = plugin::check();
index 6c2e1fce94b55bb1f96bc3b3adf405a035c22b61..8381540be9d65a1375e5c745f7d9c925adb901d9 100644 (file)
 </table>
 <p class='seperator'>&nbsp;</p>
 <br>
+<h2><img class="center" alt="" src="images/rocket.png" align="middle"> Action</h2>
 {if $is_new == "new"}
     {t}The server must be saved before you can use the status flag.{/t}
+{elseif !$is_acc}
+    {t}The service must be saved before you can use the status flag.{/t}
 {/if}
 <br>
-<h2><img class="center" alt="" src="images/rocket.png" align="middle"> Action</h2>
-<select name="action" title='{t}{/t}' {if $is_new =="new"} disabled {/if}>
+<select name="action" title='{t}{/t}' 
+       {if $is_new =="new" || !$is_acc} disabled {/if}
+>
        <option value="none">&nbsp;</option>
     {html_options options=$Actions}
 </select>
-<input type='submit' name='ExecAction' title='{t}Set status{/t}' value='{t}Execute{/t}' {if $is_new == "new"} disabled {/if}>
+<input type='submit' name='ExecAction' title='{t}Set status{/t}' value='{t}Execute{/t}' 
+       {if $is_new == "new" | !$is_acc} disabled {/if}
+>
 
 <p class="seperator">&nbsp;</p>
 <p>
index a53e0a83d7883ca015c256c658a7f54b1b7f955d..edd533f200a52f544a1e1eacbd5bde3f48723f9c 100644 (file)
 
 <p class='seperator'>&nbsp;</p>
 <br>
+<h2><img class="center" alt="" src="images/rocket.png" align="middle"> Action</h2>
 {if $is_new == "new"}
        {t}The server must be saved before you can use the status flag.{/t}
+{elseif !$is_acc}
+       {t}The service must be saved before you can use the status flag.{/t}
 {/if}
 <br>
-<h2><img class="center" alt="" src="images/rocket.png" align="middle"> Action</h2>
-<select name="action" title='{t}{/t}' {if $is_new == "new"} disabled {/if}>
+<select name="action" title='{t}{/t}' 
+       {if $is_new == "new" || $is_acc == false} disabled {/if}
+>
        <option value="none">&nbsp;</option>
        {html_options options=$Actions} 
 </select>
-<input type='submit' name='ExecAction' title='{t}Set status{/t}' value='{t}Execute{/t}' {if $is_new == "new"} disabled {/if}>
+<input type='submit' name='ExecAction' title='{t}Set status{/t}' value='{t}Execute{/t}' 
+       {if $is_new == "new" || $is_acc == false} disabled {/if}
+>
 
 <p class="seperator">&nbsp;</p>
 <p>