Code

Added mysql_persistent connections, and missing mysql_close ()
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Sep 2005 05:57:44 +0000 (05:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Sep 2005 05:57:44 +0000 (05:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1348 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/FAI/class_askClassName.inc
plugins/admin/FAI/class_faiHook.inc
plugins/admin/ogroups/class_phonequeue.inc
plugins/admin/users/class_userManagement.inc
plugins/gofon/conference/class_phoneConferenceGeneric.inc
plugins/gofon/macro/class_gofonMacro.inc
plugins/gofon/phoneaccount/class_phoneAccount.inc

index 7e0433bfb1a8455c5c75f98631940393efcc365f..65cce88d352d32fd1e1d67ce9e68e63242518530 100644 (file)
@@ -27,7 +27,7 @@ class askClassName extends plugin
   function execute()
   {
     /* Fill templating stuff */
-    $smarty= get_smarty();
+    $smarty = get_smarty();
     $display= "";
 
     /* The faifilter contais 
@@ -39,16 +39,17 @@ class askClassName extends plugin
      * With a second search detect all object that belong to the different ous. 
      */
     $ldap = $this->config->get_ldap_link();
-    $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $faifilter['base'], array("cn","description","objectClass"),TRUE);
-    $used=array();
+    $res  = get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $faifilter['base'], array("cn","description","objectClass"),TRUE);
+    $used = array();
 
     $delete = array();
     foreach($res as $objecttypes){
       $res2 = get_list2($this->ui->subtreeACL, "(objectClass=*)",
           FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
+
       foreach($res2 as $object){
-       
-        /* skip class names with this type of object */ 
+      
+        /* skip class names with this name */ 
         if(in_array($this->objectClass,$object['objectClass'])){
           $delete[] = $object['cn'][0];
         }
@@ -85,8 +86,8 @@ class askClassName extends plugin
       unset($used[$del]);
     }
    
-    /* if there is no class name which is missing the type 
-     *  of objectClass wew want to create now, disable selectBox 
+    /* if there is no class name which is missing for this type 
+     *  of objectClass, we only can create a new one, disable selectBox 
      */
     if(count ($used)==0){
       $smarty->assign("ClassNamesAvailable", " disabled ");
@@ -116,7 +117,6 @@ class askClassName extends plugin
 
 
   /* Check given class name 
-   * A class name For each object type, 
    */
   function check()
   {
index 662f837e13979399a396bf403aff1d6d8eea1f52..5aa6423b873214c02dee66690426413a52deecba 100644 (file)
@@ -41,7 +41,6 @@ class faiHook extends plugin
 
     /* If "dn==new" we try to create a new entry
      * Else we must read all objects from ldap which belong to this entry.
-     * First read SubObjects from ldap ... and then the partition definitions for the SubObjects.
      */
     if($dn != "new"){
       $this->dn =$dn;
@@ -103,15 +102,25 @@ class faiHook extends plugin
 
     /* Save Dialog */
     if(isset($_POST['SaveSubObject'])){
+
+      /* Perform post check*/
       $this->dialog->save_object();
+
+      /* Get messages */
       $msgs = $this->dialog->check();
+
+      /* print errors */
       if(count($msgs)>0){
         foreach($msgs as $msg){
           print_red($msg);
         }
       }else{
+
+        /* Get return object */
         $obj = $this->dialog->save();
         if(isset($obj['remove'])){
+
+          /* Depending on status, set new status */
           if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){
             $this->SubObjects[$obj['remove']['from']]['status'] = "delete";
           }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){
index c5fb59f7e3ff720560ef8297eea19773daefac64..058cddade033c248d50af03d5d406aaf4aedeaf7 100644 (file)
@@ -480,6 +480,7 @@ class phonequeue extends plugin
       }
 
     }
+    @mysql_close($r_con);
     return(false);
   }
 
index 5b77b007519e4c4f6e0cd1454497c962f9f8d68f..fe485e2a922fde56be44ab3aafafb516d4cc6196 100644 (file)
@@ -751,7 +751,7 @@ class userManagement extends plugin
       /* 
         If you want to disable the status pictures, just comment out the next line
       */
-      $r_con= @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+      $r_con= @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
       // Check if we are  connected correctly
       if($r_con){
         $r_db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
@@ -788,11 +788,14 @@ class userManagement extends plugin
               $fonac = preg_replace("/%title%/", $connected, $fonac);
             }
           }
+        mysql_close($r_con);
         }
       }else{
         $fonac=$empty;
       }
 
+    
+
       // Specify Pics for Extensions  
       if(in_array("posixAccount"    ,$val['objectClass'])){ 
         $posix = preg_replace("/%KEY%/", "$key", $posiximg);
index a119c495dbdbef6d7e4483f969bfb5c2cb6b0a19..6d306b32b5fc92879dfb7d027165e6d8bbd9be02 100644 (file)
@@ -219,7 +219,7 @@ class conference extends plugin
     $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
 
     // Connect to DB server
-    $r_con =  @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+    $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
 
     // Check if we are  connected correctly
     if(!$r_con){
@@ -317,7 +317,7 @@ class conference extends plugin
     } 
 
 
-
+    @mysql_close($r_con);
     return(true);
   }
 
@@ -328,7 +328,7 @@ class conference extends plugin
       $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
 
       // Connect to DB server
-      $r_con =  @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+      $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
 
       // Check if we are  connected correctly
       if(!$r_con){
@@ -359,6 +359,7 @@ class conference extends plugin
       } 
 
     }//ENDE  old num availiable ...
+    @mysql_close($r_con);
     return(true);
   }
 
index 6ac7d11dc3c330c44ebd3b2d472f29b49be96bb7..a44a489959e716df974fedd3f49428a344f7f09f 100755 (executable)
@@ -174,7 +174,7 @@ class macro extends plugin
     $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
 
     // Connect to DB server
-    $r_con =  @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); 
+    $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); 
   
     // Check if we are  connected correctly 
     if(!$r_con){
@@ -285,9 +285,10 @@ class macro extends plugin
         } 
       }    
     }
-
-  return true;
-
+    if((isset($r_con))&&($r_con)){
+      @mysql_close($r_con);
+    }
+    return true;
   }
 
 
index 73b6d9db229f3fcbdf2304b077474d37d3a2355c..5b88dc73352450402dccd64aa6f4a41fe2bb7bf3 100644 (file)
@@ -219,7 +219,7 @@ class phoneAccount extends plugin
    */
     // Connect to DB server
     if((isset($a_SETUP))&&(isset($a_SETUP['SERVER']))&&(isset($a_SETUP['LOGIN']))&&(isset($a_SETUP['PASSWORD']))){
-      $r_con =  @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+      $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
       if($r_con){
         $r_db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
         $vp = mysql_fetch_row(mysql_query("SELECT ".$a_SETUP['VOICE_TABLE'].".password FROM  ".$a_SETUP['VOICE_TABLE'].", ".$a_SETUP['SIP_TABLE']."  WHERE customer_id = sip_users.mailbox AND name='".$this->uid."'"));
@@ -227,8 +227,12 @@ class phoneAccount extends plugin
         if((isset($vp[0]))&&(!empty($vp[0]))){
           $this->goFonPINVoice = $vp[0];
         }
+        @mysql_close($r_con);
       }
+
     }
+
+  
   }
 
 
@@ -266,7 +270,7 @@ class phoneAccount extends plugin
 
 
     // Connect to DB server
-    $r_con =  @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+    $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
 
     // Check if we are  connected correctly
     if(!$r_con){
@@ -518,10 +522,12 @@ class phoneAccount extends plugin
       foreach($SQL as $query){
         if(!@mysql_query($query,$r_con)){
           print_red(_("Error while performing query ".mysql_error()));
+          @mysql_close($r_con);
           return false;
         }
       }
     }
+    @mysql_close($r_con);
     return true;
   }
 
@@ -1030,6 +1036,7 @@ class phoneAccount extends plugin
     show_ldap_error($ldap->get_error());
 
     /* Optionally execute a command after we're done */
+    @mysql_close($r_con);
     $this->handle_post_events('remove');
   }