Changeset 5952

Show
Ignore:
Timestamp:
07/07/08 15:24:13 (5 months ago)
Author:
seanmh
Message:

The module will no longer give errors if queues or conference rooms are disabled in FreePBX

Files:

Legend:

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

    r5883 r5952  
    44 *Author       : Michael Yara 
    55 *Created      : June 27, 2008 
    6  *Last Updated : July 1, 2008 
    7  *History      : 0.2 
     6 *Last Updated : July 7, 2008 
     7 *History      : 0.3 
    88 *Purpose      : FreePBX module that automatically updates the iSymphony configuration from the FreePBX configuration. 
    99 *Copyright    : 2008 HEHE Enterprises, LLC 
     
    5555                                                 
    5656                        //Check if a manager profile exists for iSymphony if not create it. 
    57                         if(($managers = manager_list()) !== null) { 
     57                        $managerFound = false; 
     58                        if((function_exists("manager_list")) && (($managers = manager_list()) !== null)) { 
    5859                                 
    5960                                //Search for iSymphony manager 
    60                                 $managerFound = false; 
    6161                                foreach($managers as $manager) { 
    6262                                        if($manager['name'] == "isymphony" ) { 
     
    6565                                        } 
    6666                                } 
    67                                  
    68                                 //If not found create a manager profile for iSymphony 
    69                                 if(!$managerFound) { 
    70                                         manager_add("isymphony", "ismanager*con", "0.0.0.0/0.0.0.0", "127.0.0.1/255.255.255.0", "system,call,log,verbose,command,agent,user", "system,call,log,verbose,command,agent,user"); 
    71                                         manager_gen_conf(); 
    72                                 } 
    73                         } else { 
    74                                 isymphony_write_to_file($errorLogFile,"Manager list call returned null.\n"); 
     67                        } 
     68 
     69                        //If not found create a manager profile for iSymphony 
     70                        if((function_exists("manager_add")) && (function_exists("manager_gen_conf")) && (!$managerFound)) { 
     71                                manager_add("isymphony", "ismanager*con", "0.0.0.0/0.0.0.0", "127.0.0.1/255.255.255.0", "system,call,log,verbose,command,agent,user", "system,call,log,verbose,command,agent,user"); 
     72                                manager_gen_conf(); 
    7573                        } 
    7674                 
     
    194192                         * any extensions and profiles that differ from the FreePBX config. 
    195193                         */                      
    196                         if(($freePBXUsers = core_users_list()) === null){ 
     194                        if((!function_exists("core_users_list")) || (($freePBXUsers = core_users_list()) === null)){ 
    197195                                $freePBXUsers = array(); 
    198196                        } 
     
    230228                                foreach($freePBXUsers as $freePBXUser) { 
    231229                                         
    232                                         $freePBXDeviceInfo = core_devices_get($freePBXUser[0]); 
    233                                         $extensionDispalyName = $freePBXUser[1] == "" ? $freePBXUser[0] : $freePBXUser[1]; 
     230                                        if(function_exists("core_devices_get") && function_exists("core_devices_getsip") && function_exists("core_devices_getiax2")) { 
    234231                                         
    235                                         //If extension does not exist add it 
    236                                         if(!in_array($freePBXUser[0], $iSymphonyExtensions)) { 
    237                                                  
    238                                                 //Add extension 
    239                                                 $object = new ISymphonyExtension; 
    240                                                 $object->extension_val = $freePBXUser[0]; 
    241                                                 $object->name = $extensionDispalyName; 
    242                                                 $object->peer = $freePBXDeviceInfo['dial']; 
    243                                                 $object->alt_origination_method = ""; 
    244                                                 $object->voice_mail = $freePBXUser[0]; 
    245                                                  
    246                                                 if($object->add("default","default")) { 
    247                                                         isymphony_write_to_file($debugLogFile, "Added extension {$freePBXUser[0]}\n"); 
    248                                                 } else { 
    249                                                         isymphony_write_to_file($errorLogFile, "(Add extension)" . $ISERROR . "\n"); 
    250                                                 } 
    251                                                  
    252                                         //If extension does exist update it      
    253                                         } else { 
    254                                                  
    255                                                 //Query extension configuration and update values 
    256                                                 if(($object = getISymphonyExtension("default", "default", $freePBXUser[0])) !== false) {                 
    257                                                                                                  
     232                                                $freePBXDeviceInfo = core_devices_get($freePBXUser[0]); 
     233                                                $extensionDispalyName = $freePBXUser[1] == "" ? $freePBXUser[0] : $freePBXUser[1]; 
     234                                                 
     235                                                //If extension does not exist add it 
     236                                                if(!in_array($freePBXUser[0], $iSymphonyExtensions)) { 
     237                                                         
     238                                                        //Add extension 
     239                                                        $object = new ISymphonyExtension; 
     240                                                        $object->extension_val = $freePBXUser[0]; 
    258241                                                        $object->name = $extensionDispalyName; 
     242                                                        $object->peer = $freePBXDeviceInfo['dial']; 
     243                                                        $object->alt_origination_method = ""; 
    259244                                                        $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                                                         }        
    267                                                 } else { 
    268                                                         isymphony_write_to_file($errorLogFile, "(Query extension)" . $ISERROR. "\n");  
    269                                                 } 
    270                                         }                                
    271                                          
    272                                         //If profile does not exist add it 
    273                                         if(!in_array($freePBXUser[0], $iSymphonyProfiles)) { 
    274                                                  
    275                                                 //Check sip and iax for a secret to use as a profile password 
    276                                                 $profilePassword = ""; 
    277                                                 if(($sipInfo = core_devices_getsip($freePBXUser[0])) != null) { 
    278                                                         $profilePassword = $sipInfo['secret']; 
    279                                                 } else if(($aixInfo = core_devices_getiax2($freePBXUser[0])) != null) { 
    280                                                         $profilePassword = $aixInfo['secret']; 
    281                                                 } 
    282                                                  
    283                                                 //If no password was found or secret value is blank set to 'secret' 
    284                                                 if($profilePassword == "") { 
    285                                                         $profilePassword = "secret"; 
    286                                                 } 
    287  
    288                                                 //Add profile 
    289                                                 $object = new ISymphonyProfile; 
    290                                                 $object->name = $freePBXUser[0]; 
    291                                                 $object->password = $profilePassword; 
    292                                                 $object->can_view_everyone_directory = "true"; 
    293                                                  
    294                                                 if($object->add("default","default")) { 
    295                                                         isymphony_write_to_file($debugLogFile, "Added profile {$freePBXUser[0]}\n"); 
    296                                                 } else { 
    297                                                         isymphony_write_to_file($errorLogFile, "(Add profile)" . $ISERROR . "\n"); 
    298                                                 } 
    299                                          
    300                                                 //Add extension to profiles managed list 
    301                                                 if(addISymphonyProfileManagedExtension("default","default",$freePBXUser[0],$freePBXUser[0])) { 
    302                                                         isymphony_write_to_file($debugLogFile, "Added profile managed extension {$freePBXUser[0]}\n"); 
    303                                                 } else { 
    304                                                         isymphony_write_to_file($errorLogFile, "(Add profile managed extension)" . $ISERROR . "\n"); 
    305                                                 } 
    306                                         }        
     245                                                         
     246                                                        if($object->add("default","default")) { 
     247                                                                isymphony_write_to_file($debugLogFile, "Added extension {$freePBXUser[0]}\n"); 
     248                                                        } else { 
     249                                                                isymphony_write_to_file($errorLogFile, "(Add extension)" . $ISERROR . "\n"); 
     250                                                        } 
     251                                                         
     252                                                //If extension does exist update it      
     253                                                } else { 
     254                                                         
     255                                                        //Query extension configuration and update values 
     256                                                        if(($object = getISymphonyExtension("default", "default", $freePBXUser[0])) !== false) {                 
     257                                                                                                         
     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                                                                }        
     267                                                        } else { 
     268                                                                isymphony_write_to_file($errorLogFile, "(Query extension)" . $ISERROR. "\n");  
     269                                                        } 
     270                                                }                                
     271                                                 
     272                                                //If profile does not exist add it 
     273                                                if(!in_array($freePBXUser[0], $iSymphonyProfiles)) { 
     274                                                         
     275                                                        //Check sip and iax for a secret to use as a profile password 
     276                                                        $profilePassword = ""; 
     277                                                        if(($sipInfo = core_devices_getsip($freePBXUser[0])) != null) { 
     278                                                                $profilePassword = $sipInfo['secret']; 
     279                                                        } else if(($aixInfo = core_devices_getiax2($freePBXUser[0])) != null) { 
     280                                                                $profilePassword = $aixInfo['secret']; 
     281                                                        } 
     282                                                         
     283                                                        //If no password was found or secret value is blank set to 'secret' 
     284                                                        if($profilePassword == "") { 
     285                                                                $profilePassword = "secret"; 
     286                                                        } 
     287         
     288                                                        //Add profile 
     289                                                        $object = new ISymphonyProfile; 
     290                                                        $object->name = $freePBXUser[0]; 
     291                                                        $object->password = $profilePassword; 
     292                                                        $object->can_view_everyone_directory = "true"; 
     293                                                         
     294                                                        if($object->add("default","default")) { 
     295                                                                isymphony_write_to_file($debugLogFile, "Added profile {$freePBXUser[0]}\n"); 
     296                                                        } else { 
     297                                                                isymphony_write_to_file($errorLogFile, "(Add profile)" . $ISERROR . "\n"); 
     298                                                        } 
     299                                                 
     300                                                        //Add extension to profiles managed list 
     301                                                        if(addISymphonyProfileManagedExtension("default","default",$freePBXUser[0],$freePBXUser[0])) { 
     302                                                                isymphony_write_to_file($debugLogFile, "Added profile managed extension {$freePBXUser[0]}\n"); 
     303                                                        } else { 
     304                                                                isymphony_write_to_file($errorLogFile, "(Add profile managed extension)" . $ISERROR . "\n"); 
     305                                                        } 
     306                                                }        
     307                                        } 
    307308                                } 
    308309                        } else { 
     
    315316                         * any queues that differ from the FreePBX config. 
    316317                         */      
    317                          if(($freePBXQueues = queues_list()) === null) { 
     318                         if((!function_exists("queues_list")) || (($freePBXQueues = queues_list()) === null)) { 
    318319                                $freePBXQueues = array(); 
    319320                         } 
     
    388389                         * any conference rooms that differ from the FreePBX config. 
    389390                         */      
    390                          if(($freePBXConferenceRooms = conferences_list()) === null) { 
     391                         if((!function_exists("conferences_list")) || (($freePBXConferenceRooms = conferences_list()) === null)) { 
    391392                                $freePBXConferenceRooms = array(); 
    392393                         } 
  • contributed_modules/modules/isymphony/module.xml

    r5886 r5952  
    22        <rawname>isymphony</rawname> 
    33        <name>iSymphony</name> 
    4         <version>0.2</version> 
     4        <version>0.3</version> 
    55        <type>setup</type> 
    66        <category>Modules</category> 
     
    1717        <md5sum>junk</md5sum> 
    1818        <changelog> 
    19                 0.1 First Release 
     19                0.3 Added checks for dependent module API functions(manager, queue, conferences) 
    2020                0.2 Added reload script to reload iSymphony config after dial plan reload. 
    2121                    Added menu item and info page. 
     22                0.1 First Release 
    2223        </changelog> 
    2324        <info>http://www.i9technologies.com/isymphony</info> 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads