Changeset 6242

Show
Ignore:
Timestamp:
08/01/08 10:49:50 (4 years ago)
Author:
seanmh
Message:

Modified core module code to be more efficient.
Removed disconnect call from post reload script.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/isymphony/functions.inc.php

    r5952 r6242  
    44 *Author       : Michael Yara 
    55 *Created      : June 27, 2008 
    6  *Last Updated : July 7, 2008 
    7  *History      : 0.3 
     6 *Last Updated : July 28, 2008 
     7 *History      : 0.4 
    88 *Purpose      : FreePBX module that automatically updates the iSymphony configuration from the FreePBX configuration. 
    99 *Copyright    : 2008 HEHE Enterprises, LLC 
     
    4646      ob_start();  
    4747             
     48      $runningTimeStart = microtime(true);       
     49             
    4850      //Open file for error log 
    4951      $errorLogFile = fopen("/var/www/html/admin/modules/isymphony/error.txt", 'w'); 
     
    133135        } else { 
    134136          if(($object = getISymphonyLocation("default")) !== false) { 
    135             $object->asterisk_host = "localhost"; 
    136             $object->asterisk_port = "5038"; 
    137             $object->asterisk_login = "isymphony"; 
    138             $object->asterisk_password = "ismanager*con"; 
    139              
    140             if($object->update()) { 
    141               isymphony_write_to_file($debugLogFile, "Updated location default\n"); 
    142             } else { 
    143               isymphony_write_to_file($errorLogFile, "(Update location)" . $ISERROR. "\n");  
     137             
     138            //Check if update needs to occur 
     139            if(($object->asterisk_host != "localhost") || ($object->asterisk_port != "5038") || ($object->asterisk_login != "isymphony") || ($object->asterisk_password != "ismanager*con")) {     
     140                 
     141              $object->asterisk_host = "localhost"; 
     142              $object->asterisk_port = "5038"; 
     143              $object->asterisk_login = "isymphony"; 
     144              $object->asterisk_password = "ismanager*con"; 
     145               
     146              if($object->update()) { 
     147                isymphony_write_to_file($debugLogFile, "Updated location default\n"); 
     148              } else { 
     149                isymphony_write_to_file($errorLogFile, "(Update location)" . $ISERROR. "\n");  
     150              } 
    144151            }  
    145152          } else { 
     
    171178        } else { 
    172179          if(($object = getISymphonyTenant("default", "default")) !== false) { 
    173             $object->originating_context = "from-internal"; 
    174             $object->redirecting_context = "from-internal"; 
    175              
    176             if($object->update()) { 
    177               isymphony_write_to_file($debugLogFile, "Updated tenant default\n"); 
    178             } else { 
    179               isymphony_write_to_file($errorLogFile, "(Update tenant)" . $ISERROR. "\n");  
    180             }  
     180             
     181            //Check if update needs to occur 
     182            if(($object->originating_context != "from-internal") || ($object->redirecting_context != "from-internal")) { 
     183               
     184              $object->originating_context = "from-internal"; 
     185              $object->redirecting_context = "from-internal"; 
     186               
     187              if($object->update()) { 
     188                isymphony_write_to_file($debugLogFile, "Updated tenant default\n"); 
     189              } else { 
     190                isymphony_write_to_file($errorLogFile, "(Update tenant)" . $ISERROR. "\n");  
     191              }  
     192            } 
    181193          } else { 
    182194            isymphony_write_to_file($errorLogFile, "(Query tenant)" . $ISERROR. "\n"); 
     
    256268              if(($object = getISymphonyExtension("default", "default", $freePBXUser[0])) !== false) {     
    257269                           
    258                 $object->name = $extensionDispalyName; 
    259                 $object->voice_mail = $freePBXUser[0]; 
    260                 $object->peer = $freePBXDeviceInfo['dial']; 
    261                  
    262                 if($object->update()) { 
    263                   isymphony_write_to_file($debugLogFile, "Updated extension {$freePBXUser[0]}\n"); 
    264                 } else { 
    265                   isymphony_write_to_file($errorLogFile, "(Update extension)" . $ISERROR. "\n");   
    266                 }  
     270                //Check if update needs to occur 
     271                if(($object->name != $extensionDispalyName) || ($object->voice_mail != $freePBXUser[0]) || ($object->peer != $freePBXDeviceInfo['dial'])) {    
     272                       
     273                  $object->name = $extensionDispalyName; 
     274                  $object->voice_mail = $freePBXUser[0]; 
     275                  $object->peer = $freePBXDeviceInfo['dial']; 
     276                   
     277                  if($object->update()) { 
     278                    isymphony_write_to_file($debugLogFile, "Updated extension {$freePBXUser[0]}\n"); 
     279                  } else { 
     280                    isymphony_write_to_file($errorLogFile, "(Update extension)" . $ISERROR. "\n");   
     281                  }  
     282                } 
    267283              } else { 
    268284                isymphony_write_to_file($errorLogFile, "(Query extension)" . $ISERROR. "\n");  
     
    365381            if(($object = getISymphonyQueue("default", "default", $queueDispalyName)) !== false) {     
    366382                         
    367               $object->name = $queueDispalyName; 
    368               $object->queue_val = $freePBXQueue[0]; 
    369               $object->extension_val = $freePBXQueue[0]; 
    370               $object->context = "from-internal"; 
    371                
    372               if($object->update()) { 
    373                 isymphony_write_to_file($debugLogFile, "Updated queue {$queueDispalyName}\n"); 
    374               } else { 
    375                 isymphony_write_to_file($errorLogFile, "(Update queue)" . $ISERROR. "\n");   
    376               }  
     383              //Check if update needs to occur 
     384              if(($object->name != $queueDispalyName) || ($object->queue_val != $freePBXQueue[0]) || ($object->extension_val != $freePBXQueue[0]) || ($object->context != "from-internal")) {          
     385                         
     386                $object->name = $queueDispalyName; 
     387                $object->queue_val = $freePBXQueue[0]; 
     388                $object->extension_val = $freePBXQueue[0]; 
     389                $object->context = "from-internal"; 
     390                 
     391                if($object->update()) { 
     392                  isymphony_write_to_file($debugLogFile, "Updated queue {$queueDispalyName}\n"); 
     393                } else { 
     394                  isymphony_write_to_file($errorLogFile, "(Update queue)" . $ISERROR. "\n");   
     395                }  
     396              } 
    377397            } else { 
    378398              isymphony_write_to_file($errorLogFile, "(Query queue)" . $ISERROR. "\n");  
     
    445465            //Query conference room configuration and update values 
    446466            if(($object = getISymphonyConferenceRoom("default", "default", $conferenceRoomsDispalyName)) !== false) {    
    447                                
    448               $object->name = $conferenceRoomsDispalyName; 
    449               $object->predefined = "true"; 
    450               $object->room_number = $freePBXConferenceRoom[0]; 
    451               $object->extension_val = $freePBXConferenceRoom[0]; 
    452               $object->context = "from-internal"; 
    453                
    454               if($object->update()) { 
    455                 isymphony_write_to_file($debugLogFile, "Updated conference room {$conferenceRoomsDispalyName}\n"); 
    456               } else { 
    457                 isymphony_write_to_file($errorLogFile, "(Update conference room)" . $ISERROR. "\n");   
     467                       
     468              //Check if update needs to occur 
     469              if(($object->name != $conferenceRoomsDispalyName) || ($object->predefined != "true") || ($object->room_number != $freePBXConferenceRoom[0]) || ($object->extension_val != $freePBXConferenceRoom[0]) || ($object->context != "from-internal")) { 
     470                   
     471                $object->name = $conferenceRoomsDispalyName; 
     472                $object->predefined = "true"; 
     473                $object->room_number = $freePBXConferenceRoom[0]; 
     474                $object->extension_val = $freePBXConferenceRoom[0]; 
     475                $object->context = "from-internal"; 
     476                 
     477                if($object->update()) { 
     478                  isymphony_write_to_file($debugLogFile, "Updated conference room {$conferenceRoomsDispalyName}\n"); 
     479                } else { 
     480                  isymphony_write_to_file($errorLogFile, "(Update conference room)" . $ISERROR. "\n");   
     481                } 
    458482              }  
    459483            } else { 
     
    469493      iSymphonyDisconnect(); 
    470494       
     495      $runningTimeStop = microtime(true); 
     496      isymphony_write_to_file($debugLogFile, "Total Running Time:" . ($runningTimeStop - $runningTimeStart) . "s\n"); 
     497       
    471498      //Close file handlers 
    472499      fclose($debugLogFile); 
  • contributed_modules/modules/isymphony/module.xml

    r6150 r6242  
    22  <rawname>isymphony</rawname> 
    33  <name>iSymphony</name> 
    4   <version>0.4</version> 
     4  <version>0.5</version> 
    55  <type>setup</type> 
    66  <category>Modules</category> 
     
    1717  <md5sum>junk</md5sum> 
    1818  <changelog> 
     19    0.5 Modified core module code to be more efficient. 
     20      Removed disconnect call from post reload script. 
    1921    0.4 Added bash script wrapper for post reload script(See new config instructions under the iSymphony menu item). 
    2022    0.3 Added checks for dependent module API functions(manager, queue, conferences) 
  • contributed_modules/modules/isymphony/post_reload.php

    r5883 r6242  
    44 *Author       : Michael Yara 
    55 *Created      : June 27, 2008 
    6  *Last Updated : July 1, 2008 
    7  *History      : 0.1 
     6 *Last Updated : July 28, 2008 
     7 *History      : 0.2 
    88 *Purpose      : Script that is called once FreePBX dial plan reload has occurred to reload the iSymphony server. Called via the POST_RELOAD variable in amportal.conf. 
    99 *Copyright    : 2008 HEHE Enterprises, LLC 
     
    2222  reloadISymphonyServer(); 
    2323} 
    24  
    25 //Close iSymphony connection 
    26 iSymphonyDisconnect(); 
    2724?>