Code

Fixed phone plugin removal.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Mar 2006 05:08:41 +0000 (05:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Mar 2006 05:08:41 +0000 (05:08 +0000)
Added some more checks for dns.
Fixed undefined index for groupGeneric.

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

TODO
plugins/admin/groups/class_groupGeneric.inc
plugins/admin/systems/class_servDNSeditZoneEntries.inc
plugins/gofon/phoneaccount/class_phoneAccount.inc

diff --git a/TODO b/TODO
index 4fff769d7da205ce7a76589ee0cccdb3a4ad2a2f..982b7c91f288c0f1b3ea39ea7fcfbe39de4e4310 100644 (file)
--- a/TODO
+++ b/TODO
@@ -12,10 +12,6 @@ Target for 2.4.1:
   LDAP-Error: Cannot modify object class (structural object class modification from 'person' to 'inetOrgPerson' not allowed)
 
 * Test DNS plugin. Add some more checks 
-  Fix slang! Woha - what are "free hand entries"?
-
-* Phone account is not removable if the mysql database is not reachable.
-  This is no real problem, but I'd like to see the hint message for it.
 
 * Enhance the export xls to export the whole three with a maximum of attributes in each sheet ( OpenSides )
 
index de07e7d4c1c6487f3bdcf5881e3cb329c23a9a0f..b693f7064ca554ff3d3ab658004e34ab287e18f4 100644 (file)
@@ -142,7 +142,7 @@ class group extends plugin
     $gufilter= get_global('gufilter');
 
     $gufilter['SubSearchGroup'] = false;
-    $gufilter['dselect'] = $_SESSION['groupfilter']['depselect'];  
+    $gufilter['dselect'] = $_SESSION['gufilter']['dselect'];  
 
     register_global('gufilter',$gufilter);
   
index faf29d198257ca3f5c207d4da2ea9425193a4483..9265bf61d975d9c78fbd61a62d2618f2fcc7dc54 100644 (file)
@@ -15,14 +15,11 @@ class servDNSeditZoneEntries extends plugin
   var $Devices      = array();
   var $InitDevices  = array();
 
-  var $FreeHosts    = array();
-  var $InitFreeHosts= array();
-
   var $zoneName       = "";   // ZoneName of currently edited Zone
   var $reverseName    = "";   // ReverseZone of the currently edited Zone
+
   var $RecordTypes= array();  // Possible record type. They will be set in contrucktor
-                              //  and some types will be added later  (cName/Ptr)
+  //  and some types will be added later  (cName/Ptr)
 
   function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes)
   {
@@ -33,13 +30,13 @@ class servDNSeditZoneEntries extends plugin
     $this->zoneName     = $zoneName;
     $this->reverseName  = $reverseName;
     $this->RecordTypes  = $RTypes;
-  
+
     /* Add records types which are not allowed in zones 
      */
     $this->RecordTypes['cNAMERecord']  = "relativeDomainName";
     $this->RecordTypes['pTRRecord']    = "relativeDomainName";
     $this->RecordTypes['tXTRecord']    = "tXTRecord";
+
     /* Get ldap connection 
      */
     $ldap = $this->config->get_ldap_link();
@@ -60,7 +57,7 @@ class servDNSeditZoneEntries extends plugin
         }
       }
     }
-   
+
     /* Add additional informations 
        to all catched objects ( ObjectInformations)
      */
@@ -70,23 +67,23 @@ class servDNSeditZoneEntries extends plugin
       $this->Devices[$dn]['OrigCn'] = $attrs['cn'][0];
     }
 
-    /* Add Free Hand  entries
-     * Free hand entries are entries which are not directly assigned
+    /* Add free entries
+     * Free entries are entries which are not directly assigned
      *  to an existing network object like a WS or a Terminal.
-     * They will be found in a subtree within this zone.
+     * They will be found in a subtrees within a zone.
      * For example : 
-     *  The object name is FreeHand1, 
+     *  The object name is free1, 
      *                                                             zoneName=test.de,cn=server ...
      *                                // ObjectContainer
-     *                                relativeDomainName=FreeHand1,zoneName=....
+     *                                relativeDomainName=Free1,zoneName=....
      * // Dns entry
-     * relativeDomainName=FreeHand1,  relativeDomainName=FreeHand1,zoneName=....
+     * relativeDomainName=Free1,  relativeDomainName=Free1,zoneName=....
      * // cName entry .... 
-     * relativeDomainName=terminal12, relativeDomainName=FreeHand1,zone...
+     * relativeDomainName=terminal12, relativeDomainName=Free1,zone...
      */
     $ldap->cd ("zoneName=".$this->zoneName.",".$this->dn);
     $ldap->ls ("(&(objectClass=dNSZone)(!(relativeDomainName=@)))","zoneName=".$this->zoneName.",".$this->dn,array("*"));
-   
+
     $GetSubInformations = array();
     while($attrs = $ldap->fetch()){
 
@@ -117,16 +114,16 @@ class servDNSeditZoneEntries extends plugin
 
       $GetSubInformations [] = $dn;
     }
-    
+
     /* Get sub informations 
        CName or pTR records are stored in a sub entry.
-    
-        // The base entry with aRecords/tXTrecords/....
-        relativeDomainName=Keks, relativeDomainName=Keks, zoneName=....
 
-        // And the sub entries like this one
-        relativeDomainName=10.2.64.in-addr.arpa, relativeDomainName=Keks, zoneName =...
-        (  They can't be stored in a single entry, so i decided to store them this way  ).
+    // The base entry with aRecords/tXTrecords/....
+    relativeDomainName=Keks, relativeDomainName=Keks, zoneName=....
+
+    // And the sub entries like this one
+    relativeDomainName=10.2.64.in-addr.arpa, relativeDomainName=Keks, zoneName =...
+    (  They can't be stored in a single entry, so i decided to store them this way  ).
      */ 
     foreach($GetSubInformations as $dn){
       $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("*"));
@@ -139,20 +136,20 @@ class servDNSeditZoneEntries extends plugin
         }
       } 
     }
-    
+
     $this->Devices;
     $this->InitDevices = $this->Devices;
   }
 
   function execute()
   {
-         plugin::execute();
+    plugin::execute();
 
     /* Check posts for operations ...  
      */
     $once = true;
     foreach($_POST as $name => $value){
-    
+
       /* Add a new Record in given object  
        */
       if((preg_match("/^AddRecord_/",$name)) && ($once)){
@@ -160,14 +157,14 @@ class servDNSeditZoneEntries extends plugin
         $tmp    = preg_replace("/^AddRecord_/","",$name);
         $tmp    = preg_replace("/_.*$/","",$tmp);
         $tmp2   = split("\|",$tmp);
-      
+
         $dn     = base64_decode($tmp2[0]);
         $record = $tmp2[1];
         $numrec = $tmp2[2];        
-     
+
         $this->Devices[$dn]['RECORDS'][$record][] = ""; 
       }
-      
+
       /* Remove record from given dn
        */
       if((preg_match("/^RemoveRecord_/",$name)) && ($once)){
@@ -175,13 +172,13 @@ class servDNSeditZoneEntries extends plugin
         $tmp    = preg_replace("/^RemoveRecord_/","",$name);
         $tmp    = preg_replace("/_.*$/","",$tmp);
         $tmp2   = split("\|",$tmp);
-      
+
         $dn     = base64_decode($tmp2[0]);
         $record = $tmp2[1];
         $numrec = $tmp2[2];        
-     
-         unset($this->Devices[$dn]['RECORDS'][$record][$numrec]); 
-  
+
+        unset($this->Devices[$dn]['RECORDS'][$record][$numrec]); 
+
         if(count($this->Devices[$dn]['RECORDS'][$record]) == 0){
           unset($this->Devices[$dn]['RECORDS'][$record]);
           if(count($this->Devices[$dn]['RECORDS']) ==0){
@@ -190,8 +187,8 @@ class servDNSeditZoneEntries extends plugin
         }
 
       }
-    
-      /* Don't know how i should implement this ...
+
+      /* Add new host entry
        */
       if((preg_match("/^UserRecord_/",$name)) && ($once)){
         $once = false;
@@ -215,7 +212,7 @@ class servDNSeditZoneEntries extends plugin
     $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE));
     return($display);
   }
-  
+
 
   /* Create html table out of given entry 
    */
@@ -233,7 +230,7 @@ class servDNSeditZoneEntries extends plugin
     }else{
       $str = "<h3>".sprintf(_("Settings for '%s'"),$obj_dn)." : </h3>";
     }
-    
+
     $hostNameOnce = true;
     /* Walk through all defined records 
      */
@@ -250,33 +247,33 @@ class servDNSeditZoneEntries extends plugin
 
         $str .= "<tr>
           <td style='width:80px;'>";
-          
+
         if($hostNameOnce){
           $hostNameOnce = false;  
           $str .="<input type='text' name='RenameHost_".$name."' value='".$objectName."'>";
         }else{
           $str .=$objectName;
         }  
-      
+
         $str .="
           </td>
           <td style='width:80px;'>
-            ".$this->createRecordTypeSelection($id,$name)."
+          ".$this->createRecordTypeSelection($id,$name)."
           </td>
           <td>
-            <input type='text'  value='".$type."' name='ValueSelection_".$name."' style='width:250px;'>
+          <input type='text'  value='".$type."' name='ValueSelection_".$name."' style='width:250px;'>
           </td>
           <td style='width:30px;text-align:right;'>
-            <input type='image' name='AddRecord_".$name."'   src='images/crossref.png' alt='"._("Add")."' title='"._("Add")."'>
+          <input type='image' name='AddRecord_".$name."'   src='images/crossref.png' alt='"._("Add")."' title='"._("Add")."'>
           </td>
           <td style='width:60px;text-align:right;'>
-            <input type='image' name='UserRecord_".$name."'   src='images/select_default.png' alt='"._("New")."' title='"._("New")."'>
-            <input type='image' name='RemoveRecord_".$name."' src='images/edittrash.png'      alt='"._("Remove")."' title='"._("Remove")."'>
+          <input type='image' name='UserRecord_".$name."'   src='images/select_default.png' alt='"._("New")."' title='"._("New")."'>
+          <input type='image' name='RemoveRecord_".$name."' src='images/edittrash.png'      alt='"._("Remove")."' title='"._("Remove")."'>
           </td>
-         </tr>";
+          </tr>";
       }
     }
-      $str .="</table>";
+    $str .="</table>";
     return($str); 
   }
 
@@ -345,7 +342,7 @@ class servDNSeditZoneEntries extends plugin
               $n2 = strtolower($dev['OBJECT']['cn'][0]);
               $tmp[$n2] = $n2;
             }
-    
+
             if(!isset($tmp[strtolower($value)])){
               $this->Devices[$dn]['OBJECT']['cn'][0] = $value;
             }
@@ -384,13 +381,14 @@ class servDNSeditZoneEntries extends plugin
   function check()
   {
     $message= array();
+
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
+
+    $names = array();
     foreach($this->Devices as $devDN => $device){
 
-      /* check: if given name for Free Hand entry is valid.
+      /* check: if given name for host entry is valid.
        * cn exists ? invalid characters ? ...
        */
       if($device['Type'] == "Free"){
@@ -406,7 +404,6 @@ class servDNSeditZoneEntries extends plugin
        */
       if(!is_uid($device['OBJECT']['cn'][0])){
         $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $device['OBJECT']['cn'][0]);
-
       }      
 
       /* Check if we have renamed the server, hich we are currently editing.
@@ -415,7 +412,7 @@ class servDNSeditZoneEntries extends plugin
       if(strcmp($devDN,$this->dn) ==0 ){  
         $new = $device['OBJECT']['cn'][0];
         $old = $this->InitDevices[$devDN]['OBJECT']['cn'][0];
-     
+
         if($new != $old){
           $message[] = sprintf(_("Can't rename the server '%s' to '%s', the server contains this zone."),$old,$new); 
         }
@@ -431,19 +428,33 @@ class servDNSeditZoneEntries extends plugin
         if($ldap->count()){
           $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$cn);
         }
-    
+
         if(!is_uid($cn)){
           $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name contains invalid characters."),$device['OrigCn'],$cn);
         }      
       }
 
+      /* Check names 
+       */
+      if(!isset($names[$device['OBJECT']['cn'][0]])){
+        $names[$device['OBJECT']['cn'][0]] = "";
+      }else{
+        $message[] = sprintf(_("The name '%s' is used more than once."),$device['OBJECT']['cn'][0]);
+      }
+
+      /* Names should be written in lowercase
+       */
+      if(strtolower($device['OBJECT']['cn'][0]) != $device['OBJECT']['cn'][0]){
+        $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $device['OBJECT']['cn'][0]);
+      }
+
       /* Check records
        */                 
       $singleEntries = array("cNAMERecord","pTRRecord");
 
       $tmp2 = array();
       foreach($device['RECORDS'] as $type => $entries){
-   
+
         /* Check for multiple use of unique record types
          */
         if((in_array($type,$singleEntries)) && (count($entries) > 1)){
@@ -451,7 +462,7 @@ class servDNSeditZoneEntries extends plugin
         }
 
         /* Check for empty / duplicate entries in record array 
-        */
+         */
         $tmp = array();
         foreach($entries as $entry){
 
@@ -478,7 +489,7 @@ class servDNSeditZoneEntries extends plugin
   {
     /* Set all initial records to array()
        This means they will be removed from the entry
-        if they won't be overwritten
+       if they won't be overwritten
      */
     foreach($this->InitDevices as $dn => $obj){
       $attrs[$dn]= array();
@@ -534,9 +545,9 @@ class servDNSeditZoneEntries extends plugin
         echo $key;
       }
     }
-   
+
     /* Rename entries 
-        !! Terminals / WS / etc will be renamed too
+       !! Terminals / WS / etc will be renamed too
      */
     foreach($tmp['rename'] as $old => $new){
       $ldap->cat($old);
@@ -592,7 +603,7 @@ class servDNSeditZoneEntries extends plugin
       if($obj != NULL){  
 
         /*  Both type must be handled different 
-         *  Free / Exists 
+         *  free / Exists 
          */
         if($obj["Type"] == "Free"){
           $objectName = $obj['OBJECT']['cn'][0];
@@ -600,8 +611,8 @@ class servDNSeditZoneEntries extends plugin
           $objectName = $obj['OrigCn'];
         }
 
-      
-        /* If type is Free, check 
+
+        /* If type is free, check 
          */
         if($obj['Type'] == "Free"){
 
@@ -655,7 +666,7 @@ class servDNSeditZoneEntries extends plugin
             if($obj['Type'] == "Free"){
               $useDn = $dn2;
             }
-             
+
             if(isset($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'])){
               foreach($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'] as $warmal){
                 $delete['relativeDomainName='.$warmal.','.$useDn] = "";
@@ -674,7 +685,7 @@ class servDNSeditZoneEntries extends plugin
           /* Special handling for ptrrecord
            */ 
           if($type == "pTRRecord"){
-          
+
             $useDn = $dn;
             if($obj['Type'] == "Free"){
               $useDn = $dn2;
index f67504caeea04325ff1502cf997052adb8fa5a48..47a221067c92a1d7018b05286ad8aade4513a821 100644 (file)
@@ -1022,7 +1022,8 @@ $ldap->modify ($this->attrs);
 
     if(array_key_exists('config', $_SESSION) &&
        array_key_exists('SERVERS', $_SESSION['config']->data) &&
-       array_key_exists('FON', $_SESSION['config']->data['SERVERS'])) {
+       array_key_exists('FON', $_SESSION['config']->data['SERVERS']) &&
+        is_callable("mysql_pconnect")) {
       // Get Configuration for Mysql database Server
       $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
       $s_parameter  ="";
@@ -1078,6 +1079,9 @@ $ldap->modify ($this->attrs);
           return false;
         }
       }
+    }else{
+      print_red(_("Can't remove phone account, the mysql extension is not present in php configuration."));
+      return false;
     }
 
     /* unset macro attr, it will cause an error */
@@ -1099,6 +1103,7 @@ $ldap->modify ($this->attrs);
       $this->attrs['telephoneNumber']= array();
     }
 
+
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(objectClass=goFonQueue)", array("member"));
@@ -1119,6 +1124,7 @@ $ldap->modify ($this->attrs);
 
     /* Optionally execute a command after we're done */
     @mysql_close($r_con);
+    echo "was successfull";
     $this->handle_post_events('remove');
   }