| 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(); |
|---|
| 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]; |
|---|
| 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 | } |
|---|