Changeset 7772 for contributed_modules/modules/isymphony/functions.inc.php
- Timestamp:
- 05/29/09 14:01:54 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/isymphony/functions.inc.php
r6771 r7772 4 4 *Author : Michael Yara 5 5 *Created : June 27, 2008 6 *Last Updated : September 17, 20087 *History : 0.76 *Last Updated : May 27, 2009 7 *History : 1.1 8 8 *Purpose : FreePBX module that automatically updates the iSymphony configuration from the FreePBX configuration. 9 9 *Copyright : 2008 HEHE Enterprises, LLC … … 37 37 } 38 38 39 //Control 40 class ext_isymphony_controlplayback { 41 var $fileName; 42 var $skipMinutes; 43 var $ff; 44 var $rew; 45 var $stop; 46 var $pause; 47 var $restart; 48 49 function ext_isymphony_controlplayback($fileName, $skipMinutes, $ff, $rew, $stop, $pause, $restart) { 50 $this->fileName = $fileName; 51 $this->skipMinutes = $skipMinutes; 52 $this->ff = $ff; 53 $this->rew = $rew; 54 $this->stop = $stop; 55 $this->pause = $pause; 56 $this->restart = $restart; 57 } 58 59 function output() { 60 return "ControlPlayback(" . $this->fileName . "," . $this->skipMinutes . "," . $this->ff . "," . $this->rew . "," . $this->stop . "," . $this->pause . "," . $this->restart . ")"; 61 } 62 } 63 39 64 //If check box GUI element does not exist add it 40 65 if(!class_exists("gui_checkbox")) { … … 53 78 } 54 79 } 55 56 80 57 81 //Main contributing module function------------------------------------------------------------------------------------------------------------------ … … 94 118 } 95 119 96 //Add custom iSymphony contexts 97 $id = "musiconhold"; 98 $c = '1000'; 99 $ext->add($id, $c, '', new ext_answer("")); 100 $ext->add($id, $c, '', new ext_setvar("isHoldContext", "\${DB(iSymphonyChannelHoldContexts/\${CHANNEL})}")); 101 $ext->add($id, $c, '', new ext_musiconhold("\${isHoldContext}")); 102 $ext->add($id, $c, '', new ext_dbdel("iSymphonyChannelHoldContexts/\${CHANNEL}")); 103 104 $id = "xfer-2-vm"; 105 $c = "_."; 106 $ext->add($id, $c, '', new ext_goto("1", "\${VM_PREFIX}\${EXTEN}", "from-internal")); 107 $ext->add($id, $c, '', new ext_hangup()); 108 109 $id = "ibarge"; 110 $ext->add($id, "_1X.", '', new ext_meetme("\${EXTEN:1}", "qd", "271721")); 111 $ext->add($id, "_1X.", '', new ext_hangup()); 112 $ext->add($id, "_2X.", '', new ext_meetme("\${EXTEN:1}", "aq", "271721")); 113 $ext->add($id, "_2X.", '', new ext_hangup()); 114 115 $id = "imeetme"; 116 $c = "_."; 117 $ext->add($id, "h", '', new ext_hangup()); 118 $ext->add($id, $c, '', new ext_setvar("roomOptions", "\${DB(iSymphonyMeetMeOptions/\${EXTEN})}")); 119 $ext->add($id, $c, '', new ext_meetme("\${EXTEN}", "\${roomOptions}", "271721")); 120 $ext->add($id, $c, '', new ext_hangup()); 121 122 $id = "ipark"; 123 $c = "_."; 124 $ext->add($id, "h", '', new ext_hangup()); 125 $ext->add($id, $c, '', new ext_setvar("parkContext", "\${DB(iSymphonyParkContexts/\${EXTEN})}")); 126 $ext->add($id, $c, '', new ext_answer("")); 127 $ext->add($id, $c, '', new ext_wait("1")); 128 $ext->add($id, $c, '', new ext_isymphony_parkandannounce("", "", "", "\${parkContext},\${EXTEN},1")); 129 $ext->add($id, $c, '', new ext_dbdel("iSymphonyParkContexts/\${EXTEN}")); 120 //Grab server version and revision 121 $serverVersion = "2.0"; 122 $serverRevision = "1104"; 123 if(iSymphonyConnect()) { 124 if((($serverVersionCheck = getiSymphonyServerVersion()) !== false)) { 125 $serverVersion = $serverVersionCheck; 126 } else { 127 isymphony_write_to_file($errorLogFile, "Could not get server version. $ISERROR \n"); 128 } 129 130 if((($serverRevisonCheck = getiSymphonyServerRevision()) !== false)) { 131 $serverRevision = $serverRevisonCheck; 132 } else { 133 isymphony_write_to_file($errorLogFile, "Could not get server revision. $ISERROR \n"); 134 } 135 136 iSymphonyDisconnect(); 137 } else { 138 isymphony_write_to_file($errorLogFile, "Could not get server version/revision. $ISERROR \n"); 139 } 140 141 isymphony_write_to_file($debugLogFile, "Server Version:" . $serverVersion . " Server Revision:" . $serverRevision . "\n"); 142 143 //Check if server version is 2.0 or 2.1 and add appropriate contexts 144 if(strstr($serverVersion, "2.1") !== false) { 145 isymphony_write_to_file($debugLogFile, "Using 2.1 contexts\n"); 146 147 $id = "isymphony-hold"; 148 $c = '432111'; 149 $ext->add($id, $c, '', new ext_musiconhold("\${iSymphonyMusicOnHoldClass}")); 150 $ext->add($id, $c, '', new ext_hangup()); 151 152 $id = "isymphony-voice-mail"; 153 $c = '432112'; 154 $ext->add($id, $c, '', new ext_vm("u\${iSymphonyVoiceMailBox}@\${iSymphonyVoiceMailBoxContext}")); 155 $ext->add($id, $c, '', new ext_hangup()); 156 157 $id = "isymphony-meetme"; 158 $c = '432113'; 159 $ext->add($id, $c, '', new ext_meetme("\${iSymphonyMeetMeRoomNumber}", "\${iSymphonyMeetMeRoomOptions}", "")); 160 $ext->add($id, $c, '', new ext_hangup()); 161 162 $id = "isymphony-park"; 163 $c = '432114'; 164 $ext->add($id, $c, '', new ext_isymphony_parkandannounce("", "", "", "\${iSymphonyParkContext},\${iSymphonyParkExtension},1")); 165 $ext->add($id, $c, '', new ext_hangup()); 166 167 $id = "isymphony-listen-to-voice-mail"; 168 $c = '432115'; 169 $ext->add($id, $c, '', new ext_isymphony_controlplayback("\${iSymphonyVoiceMailPath}", "1000", "*", "#", "7", "8" , "9")); 170 $ext->add($id, $c, '', new ext_hangup()); 171 172 } else { 173 isymphony_write_to_file($debugLogFile, "Using 2.0 contexts\n"); 174 175 $id = "musiconhold"; 176 $c = '1000'; 177 $ext->add($id, $c, '', new ext_answer("")); 178 $ext->add($id, $c, '', new ext_setvar("isHoldContext", "\${DB(iSymphonyChannelHoldContexts/\${CHANNEL})}")); 179 $ext->add($id, $c, '', new ext_musiconhold("\${isHoldContext}")); 180 $ext->add($id, $c, '', new ext_dbdel("iSymphonyChannelHoldContexts/\${CHANNEL}")); 181 182 $id = "xfer-2-vm"; 183 $c = "_."; 184 $ext->add($id, $c, '', new ext_goto("1", "\${VM_PREFIX}\${EXTEN}", "from-internal")); 185 $ext->add($id, $c, '', new ext_hangup()); 186 187 $id = "ibarge"; 188 $ext->add($id, "_1X.", '', new ext_meetme("\${EXTEN:1}", "qd", "271721")); 189 $ext->add($id, "_1X.", '', new ext_hangup()); 190 $ext->add($id, "_2X.", '', new ext_meetme("\${EXTEN:1}", "aq", "271721")); 191 $ext->add($id, "_2X.", '', new ext_hangup()); 192 193 $id = "imeetme"; 194 $c = "_."; 195 $ext->add($id, "h", '', new ext_hangup()); 196 $ext->add($id, $c, '', new ext_setvar("roomOptions", "\${DB(iSymphonyMeetMeOptions/\${EXTEN})}")); 197 $ext->add($id, $c, '', new ext_meetme("\${EXTEN}", "\${roomOptions}", "271721")); 198 $ext->add($id, $c, '', new ext_hangup()); 199 200 $id = "ipark"; 201 $c = "_."; 202 $ext->add($id, "h", '', new ext_hangup()); 203 $ext->add($id, $c, '', new ext_setvar("parkContext", "\${DB(iSymphonyParkContexts/\${EXTEN})}")); 204 $ext->add($id, $c, '', new ext_answer("")); 205 $ext->add($id, $c, '', new ext_wait("1")); 206 $ext->add($id, $c, '', new ext_isymphony_parkandannounce("", "", "", "\${parkContext},\${EXTEN},1")); 207 $ext->add($id, $c, '', new ext_dbdel("iSymphonyParkContexts/\${EXTEN}")); 208 } 130 209 131 210 //Connect to iSymphony server to query and submit information 132 211 if(iSymphonyConnect()) { 133 212 134 //Check for device user mode 135 $deviceUserMode = ($amp_conf["AMPEXTENSIONS"] == "deviceanduser") ? "true" : "false"; 136 137 //Check if default location exists if not create it else update manager connection values to stay consistent 138 if(($iSymphonyLocations = getISymphonyLocationList()) !== false) { 139 if(!in_array("default", $iSymphonyLocations)) { 140 $object = new ISymphonyLocation; 141 $object->name = "default"; 142 $object->admin_password = "secret"; 143 $object->asterisk_host = "localhost"; 144 $object->asterisk_port = "5038"; 145 $object->asterisk_login = "isymphony"; 146 $object->asterisk_password = "ismanager*con"; 147 $object->originate_timeout = "30000"; 148 $object->jabber_host = ""; 149 $object->jabber_port = "5222"; 150 $object->device_user_mode = $deviceUserMode; 151 if($object->add()) { 152 isymphony_write_to_file($debugLogFile, "Added location default\n"); 213 //Grab location Information 214 if(($locationInformation = isymphony_location_get()) !== null) { 215 216 //Check if server properties need to be updated. 217 if(($object = getISymphonyServer()) !== false) { 218 219 if(($object->username != $locationInformation["admin_user_name"]) || (($object->password != $locationInformation["admin_password"]))) { 220 $object->username = $locationInformation["admin_user_name"]; 221 $object->password = $locationInformation["admin_password"]; 222 223 if($object->update()) { 224 isymphony_write_to_file($debugLogFile, "Updated server\n"); 225 } else { 226 isymphony_write_to_file($debugLogFile, "(Update server) . $ISERROR . \n"); 227 } 228 } 229 230 } else { 231 isymphony_write_to_file($errorLogFile, "(Query server)" . $ISERROR. "\n"); 232 } 233 234 //Check if default location exists if not create it else update manager connection values to stay consistent 235 if(($iSymphonyLocations = getISymphonyLocationList()) !== false) { 236 237 $maskedAutoReloadFlag = ($locationInformation["auto_reload"] == 1) ? "true" : "false"; 238 239 if(!in_array("default", $iSymphonyLocations)) { 240 $object = new ISymphonyLocation; 241 $object->name = "default"; 242 $object->admin_password = "secret"; 243 $object->asterisk_host = "localhost"; 244 $object->asterisk_port = "5038"; 245 $object->asterisk_login = "isymphony"; 246 $object->asterisk_password = "ismanager*con"; 247 $object->originate_timeout = $locationInformation["originate_timeout"]; 248 $object->reload_on_dial_plan_reload = $maskedAutoReloadFlag; 249 $object->jabber_host = $locationInformation["jabber_host"]; 250 $object->jabber_domain = $locationInformation["jabber_domain"]; 251 $object->jabber_resource = $locationInformation["jabber_resource"]; 252 $object->jabber_port = $locationInformation["jabber_port"]; 253 $object->device_user_mode = "true"; 254 if($object->add()) { 255 isymphony_write_to_file($debugLogFile, "Added location default\n"); 256 } else { 257 isymphony_write_to_file($errorLogFile, "(Add location)" . $ISERROR . "\n"); 258 } 153 259 } else { 154 isymphony_write_to_file($errorLogFile, "(Add location)" . $ISERROR. "\n"); 260 if(($object = getISymphonyLocation("default")) !== false) { 261 262 //Check if update needs to occur 263 if(isymphony_location_update_check($serverRevision, $locationInformation, $maskedAutoReloadFlag, $object)) { 264 $object->asterisk_host = "localhost"; 265 $object->asterisk_port = "5038"; 266 $object->asterisk_login = "isymphony"; 267 $object->asterisk_password = "ismanager*con"; 268 $object->originate_timeout = $locationInformation["originate_timeout"]; 269 $object->reload_on_dial_plan_reload = $maskedAutoReloadFlag; 270 $object->jabber_host = $locationInformation["jabber_host"]; 271 $object->jabber_domain = $locationInformation["jabber_domain"]; 272 $object->jabber_resource = $locationInformation["jabber_resource"]; 273 $object->jabber_port = $locationInformation["jabber_port"]; 274 $object->device_user_mode = "true"; 275 276 if($object->update()) { 277 isymphony_write_to_file($debugLogFile, "Updated location default\n"); 278 } else { 279 isymphony_write_to_file($errorLogFile, "(Update location)" . $ISERROR. "\n"); 280 } 281 } 282 } else { 283 isymphony_write_to_file($errorLogFile, "(Query location)" . $ISERROR. "\n"); 284 } 155 285 } 156 286 } else { 157 if(($object = getISymphonyLocation("default")) !== false) { 158 159 //Check if update needs to occur 160 if(($object->asterisk_host != "localhost") || ($object->asterisk_port != "5038") || ($object->asterisk_login != "isymphony") || ($object->asterisk_password != "ismanager*con") || ($object->device_user_mode != $deviceUserMode)) { 287 isymphony_write_to_file($errorLogFile, "(List locations)" . $ISERROR. "\n"); 288 } 289 290 //Check if default tenant exists if not create it else update context values to stay consistent 291 if(($iSymphonyTenants = getISymphonyTenantList("default")) !== false) { 292 293 //Mask auto answer flag 294 $maskedPagedStatusEnabledFlag = ($locationInformation["page_status_enabled"] == 1) ? "true" : "false"; 295 296 if(!in_array("default", $iSymphonyTenants)) { 297 $object = new ISymphonyTenant; 298 $object->name = "default"; 299 $object->admin_password = "secret"; 300 $object->originating_context = "from-internal"; 301 $object->redirecting_context = "from-internal"; 302 $object->music_on_hold_class = "default"; 303 $object->page_status_enabled = $maskedPagedStatusEnabledFlag; 304 $object->page_context = "ext-paging"; 305 $object->outside_line_number = ""; 306 $object->record_file_name = "%EXT%-%NAME%-%CID_NAME%-%CID_NUMBER%-%DATE%-%TIME%"; 307 $object->record_file_extension = "wav"; 308 $object->mix_mode = "true"; 309 if($object->add("default")) { 310 isymphony_write_to_file($debugLogFile, "Added tenant default\n"); 311 } else { 312 isymphony_write_to_file($errorLogFile, "(Add tenant)" . $ISERROR. "\n"); 313 } 314 } else { 315 if(($object = getISymphonyTenant("default", "default")) !== false) { 316 317 //Check if update needs to occur 318 if(isymphony_tenant_update_check($serverRevision, $locationInformation, $maskedPagedStatusEnabledFlag, $object)) { 161 319 162 $object->asterisk_host = "localhost";163 $object->asterisk_port = "5038";164 $object->asterisk_login = "isymphony";165 $object->asterisk_password = "ismanager*con";166 $object->device_user_mode = $deviceUserMode;167 168 if($object->update()) {169 isymphony_write_to_file($debugLogFile, "Updated location default\n");170 } else {171 isymphony_write_to_file($errorLogFile, "(Update location)" . $ISERROR. "\n");320 $object->originating_context = "from-internal"; 321 $object->redirecting_context = "from-internal"; 322 $object->page_status_enabled = $maskedPagedStatusEnabledFlag; 323 $object->page_context = "ext-paging"; 324 325 if($object->update()) { 326 isymphony_write_to_file($debugLogFile, "Updated tenant default\n"); 327 } else { 328 isymphony_write_to_file($errorLogFile, "(Update tenant)" . $ISERROR. "\n"); 329 } 172 330 } 173 } 174 } else { 175 isymphony_write_to_file($errorLogFile, "(Query location)" . $ISERROR. "\n"); 176 } 177 } 178 } else { 179 isymphony_write_to_file($errorLogFile, "(List locations)" . $ISERROR. "\n"); 180 } 181 182 //Check if default tenant exists if not create it else update context values to stay consistent 183 if(($iSymphonyTenants = getISymphonyTenantList("default")) !== false) { 184 if(!in_array("default", $iSymphonyTenants)) { 185 $object = new ISymphonyTenant; 186 $object->name = "default"; 187 $object->admin_password = "secret"; 188 $object->originating_context = "from-internal"; 189 $object->redirecting_context = "from-internal"; 190 $object->music_on_hold_class = "default"; 191 $object->outside_line_number = ""; 192 $object->record_file_name = "%EXT%-%NAME%-%CID_NAME%-%CID_NUMBER%-%DATE%-%TIME%"; 193 $object->record_file_extension = "wav"; 194 $object->mix_mode = "true"; 195 if($object->add("default")) { 196 isymphony_write_to_file($debugLogFile, "Added tenant default\n"); 197 } else { 198 isymphony_write_to_file($errorLogFile, "(Add tenant)" . $ISERROR. "\n"); 331 } else { 332 isymphony_write_to_file($errorLogFile, "(Query tenant)" . $ISERROR. "\n"); 333 } 199 334 } 200 335 } else { 201 if(($object = getISymphonyTenant("default", "default")) !== false) { 202 203 //Check if update needs to occur 204 if(($object->originating_context != "from-internal") || ($object->redirecting_context != "from-internal")) { 205 206 $object->originating_context = "from-internal"; 207 $object->redirecting_context = "from-internal"; 208 209 if($object->update()) { 210 isymphony_write_to_file($debugLogFile, "Updated tenant default\n"); 211 } else { 212 isymphony_write_to_file($errorLogFile, "(Update tenant)" . $ISERROR. "\n"); 213 } 214 } 215 } else { 216 isymphony_write_to_file($errorLogFile, "(Query tenant)" . $ISERROR. "\n"); 217 } 336 isymphony_write_to_file($errorLogFile, "(List tenants)" . $ISERROR. "\n"); 218 337 } 219 338 } else { 220 isymphony_write_to_file($errorLogFile, " (List tenants)" . $ISERROR. "\n");339 isymphony_write_to_file($errorLogFile, "Failed to grab location information". "\n"); 221 340 } 222 341 … … 262 381 //Add and update extensions 263 382 foreach($freePBXUsers as $freePBXUser) { 383 384 //Mask auto answer flag 385 $maskedAutoAnswerFlag = ($freePBXUser["auto_answer"] == 1) ? "true" : "false"; 264 386 265 387 //If extension does not exist add it else update it … … 273 395 $object->alt_origination_method = ""; 274 396 $object->voice_mail = $freePBXUser["user_id"]; 397 $object->cell_phone = $freePBXUser["cell_phone"]; 398 $object->email = $freePBXUser["email"]; 399 $object->auto_answer = $maskedAutoAnswerFlag; 275 400 276 401 if($object->add("default","default")) { … … 285 410 286 411 //Check if update needs to occur 287 if( ($object->name != $freePBXUser["display_name"]) || ($object->voice_mail != $freePBXUser["user_id"]) || ($object->peer != $freePBXUser["peer"])) {412 if(isymphony_extension_update_check($serverRevision, $freePBXUser, $maskedAutoAnswerFlag, $object)) { 288 413 289 414 $object->name = $freePBXUser["display_name"]; 290 415 $object->voice_mail = $freePBXUser["user_id"]; 291 416 $object->peer = $freePBXUser["peer"]; 417 $object->cell_phone = $freePBXUser["cell_phone"]; 418 $object->email = $freePBXUser["email"]; 419 $object->auto_answer = $maskedAutoAnswerFlag; 292 420 293 421 if($object->update()) { … … 322 450 //Add and update profiles 323 451 foreach($freePBXProfiles as $freePBXProfile) { 324 452 325 453 //If profile does not exist add it else update it 326 454 if(!in_array($freePBXProfile["user_id"], $iSymphonyProfiles)) { … … 331 459 $object->password = $freePBXProfile["password"]; 332 460 $object->can_view_everyone_directory = "true"; 461 $object->jabber_host = $freePBXProfile["jabber_host"]; 462 $object->jabber_domain = $freePBXProfile["jabber_domain"]; 463 $object->jabber_resource = $freePBXProfile["jabber_resource"]; 464 $object->jabber_port = $freePBXProfile["jabber_port"]; 465 $object->jabber_user_name = $freePBXProfile["jabber_user_name"]; 466 $object->jabber_password = $freePBXProfile["jabber_password"]; 333 467 334 468 if($object->add("default","default")) { … … 348 482 //Query profile configuration and update values 349 483 if(($object = getISymphonyProfile("default", "default", $freePBXProfile["user_id"])) !== false) { 350 351 //Check if update needs to occur 352 if($object->password != $freePBXProfile["password"]) { 353 484 485 //If jabber port is set to blank in the db rewrite with a -1 to prevent this profile from always being updated. Since the server will store a -1 as the port value if none is set. 486 $maskedJabberPort = ($object->jabber_port == -1) ? "" : $object->jabber_port; 487 488 //Check if update needs to occur 489 if(isymphony_profile_update_check($serverRevision, $freePBXProfile, $maskedJabberPort, $object)) { 490 354 491 $object->password = $freePBXProfile["password"]; 492 $object->jabber_host = $freePBXProfile["jabber_host"]; 493 $object->jabber_domain = $freePBXProfile["jabber_domain"]; 494 $object->jabber_resource = $freePBXProfile["jabber_resource"]; 495 $object->jabber_port = $freePBXProfile["jabber_port"]; 496 $object->jabber_user_name = $freePBXProfile["jabber_user_name"]; 497 $object->jabber_password = $freePBXProfile["jabber_password"]; 355 498 356 499 if($object->update()) { … … 360 503 } 361 504 } 505 506 //Attempt to add relative extension to profile 507 if(addISymphonyProfileManagedExtension("default","default",$freePBXProfile["user_id"],$freePBXProfile["user_id"])) { 508 isymphony_write_to_file($debugLogFile, "Added profile managed extension {$freePBXProfile['user_id']}\n"); 509 } 510 362 511 } else { 363 512 isymphony_write_to_file($errorLogFile, "(Query profile)" . $ISERROR. "\n"); … … 555 704 } 556 705 706 707 708 //iSymphony module API location functions------------------------------------------------------------------------------------------------------------ 709 function isymphony_location_update($adminUserName, $adminPassword, $originateTimeout, $autoReload, $pageStatusEnabled, $jabberHost, $jabberDomain, $jabberResource, $jabberPort) { 710 global $db; 711 $autoReload = $autoReload ? "1" : "0"; 712 $pageStatusEnabled = $pageStatusEnabled ? "1" : "0"; 713 $prepStatement = $db->prepare("UPDATE isymphony_location SET admin_user_name = ?, admin_password = ?, originate_timeout = ?, auto_reload = ?, page_status_enabled = ?, jabber_host = ?, jabber_domain = ?, jabber_resource = ?, jabber_port = ?"); 714 $values = array($adminUserName, $adminPassword, $originateTimeout, $autoReload, $pageStatusEnabled, $jabberHost, $jabberDomain, $jabberResource, $jabberPort); 715 $db->execute($prepStatement, $values); 716 } 717 718 function isymphony_location_get() { 719 global $db; 720 $query = "SELECT * FROM isymphony_location"; 721 $results = sql($query, "getRow", DB_FETCHMODE_ASSOC); 722 if((DB::IsError($results)) || (empty($results))) { 723 return null; 724 } else { 725 return $results; 726 } 727 } 728 557 729 //iSymphony module API user functions---------------------------------------------------------------------------------------------------------------- 558 function isymphony_user_add($userId, $addExtension, $addProfile, $password, $displayName, $peer ) {730 function isymphony_user_add($userId, $addExtension, $addProfile, $password, $displayName, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword) { 559 731 global $db; 560 732 $addProfile = $addProfile ? "1" : "0"; 561 733 $addExtension = $addExtension ? "1" : "0"; 562 $prepStatement = $db->prepare("INSERT INTO isymphony_users (user_id, add_extension, add_profile, password, display_name, peer) VALUES (?, ?, ?, ?, ?, ?)"); 563 $values = array($userId, $addExtension, $addProfile, $password, $displayName, $peer); 734 $autoAnswer = $autoAnswer ? "1" : "0"; 735 $prepStatement = $db->prepare("INSERT INTO isymphony_users (user_id, add_extension, add_profile, password, display_name, peer, cell_phone, email, auto_answer, jabber_host, jabber_domain, jabber_resource, jabber_port, jabber_user_name, jabber_password) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?)"); 736 $values = array($userId, $addExtension, $addProfile, $password, $displayName, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword); 564 737 $db->execute($prepStatement, $values); 565 738 } 566 739 567 function isymphony_user_update($userId, $addExtension, $addProfile, $password, $displayName, $peer ) {740 function isymphony_user_update($userId, $addExtension, $addProfile, $password, $displayName, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword) { 568 741 global $db; 569 742 $addProfile = $addProfile ? "1" : "0"; 570 743 $addExtension = $addExtension ? "1" : "0"; 571 $prepStatement = $db->prepare("UPDATE isymphony_users SET add_extension = ?, add_profile = ?, password = ?, display_name = ?, peer = ? WHERE user_id = $userId"); 572 $values = array($addExtension, $addProfile, $password, $displayName, $peer); 744 $autoAnswer = $autoAnswer ? "1" : "0"; 745 $prepStatement = $db->prepare("UPDATE isymphony_users SET add_extension = ?, add_profile = ?, password = ?, display_name = ?, peer = ?, cell_phone = ?, email = ?, auto_answer = ?, jabber_host = ?, jabber_domain = ?, jabber_resource = ?, jabber_port = ?, jabber_user_name = ?, jabber_password = ? WHERE user_id = $userId"); 746 $values = array($addExtension, $addProfile, $password, $displayName, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword); 573 747 $db->execute($prepStatement, $values); 574 748 } … … 734 908 $userProfile = ($iSymphonyUser["add_profile"] == "1"); 735 909 $password = $iSymphonyUser["password"]; 910 $email = $iSymphonyUser["email"]; 911 $cell_phone = $iSymphonyUser["cell_phone"]; 912 $autoAnswer = $iSymphonyUser["auto_answer"]; 913 $jabberHost = $iSymphonyUser["jabber_host"]; 914 $jabberDomain = $iSymphonyUser["jabber_domain"]; 915 $jabberResource = $iSymphonyUser["jabber_resource"]; 916 $jabberPort = $iSymphonyUser["jabber_port"]; 917 $jabberUserName = $iSymphonyUser["jabber_user_name"]; 918 $jabberPassword = $iSymphonyUser["jabber_password"]; 736 919 737 920 } else { 738 921 $added = true; 739 922 $userProfile = true; 740 $password = "secret"; 923 $password = "secret"; 924 $email = ""; 925 $cell_phone = ""; 926 $autoAnswer = false; 927 $jabberHost = ""; 928 $jabberDomain = ""; 929 $jabberResource = "iSymphony"; 930 $jabberPort = "5222"; 931 $jabberUserName = ""; 932 $jabberPassword = ""; 741 933 } 742 934 743 935 //Create GIU elements if not on delete page 744 936 if ($action != "del") { 745 $section = _("iSymphony"); 746 $currentcomponent->addguielem($section, new gui_checkbox("isymphony_add_extension", $added, "Add to iSymphony", "Makes this Extension/User available in iSymphony.", "on", "", "", false)); 937 $section = _("iSymphony Profile Settings"); 747 938 $currentcomponent->addguielem($section, new gui_checkbox("isymphony_add_profile", $userProfile, "Create Profile", "Creates an iSymphony login profile which is associated with this extension.", "on", "", "", false)); 748 939 $currentcomponent->addguielem($section, new gui_textbox("isymphony_profile_password", $password, "Profile Password", "Specifies the password to be used for this profile.", "", "", true, "100", false)); 940 941 $section = _("iSymphony Extension Settings"); 942 $currentcomponent->addguielem($section, new gui_checkbox("isymphony_add_extension", $added, "Add to iSymphony", "Makes this Extension/User available in iSymphony.", "on", "", "", false)); 943 $currentcomponent->addguielem($section, new gui_checkbox("isymphony_auto_answer", $autoAnswer, "Auto Answer", "Makes this extension automatically answer the initial call received from the system when performing an origination within the panel. Only works with Aastra, Grandstream, Linksys, Polycom, and Snom phones.", "on", "", "", false)); 944 $currentcomponent->addguielem($section, new gui_textbox("isymphony_add_email", $email, "Email Address", "The email address entered here will be used whenever someone clicks the email icon for this extension.", "", "", true, "100")); 945 $currentcomponent->addguielem($section, new gui_textbox("isymphony_add_cell_phone", $cell_phone, "Cell Phone", "The number entered here will be used whenever someone clicks the cell phone icon for this extension.", "", "", true, "100")); 946 947 $section = _("iSymphony Jabber Settings"); 948 $currentcomponent->addguielem($section, new gui_textbox("isymphony_jabber_host", $jabberHost, "Host", "Host or IP of jabber server this extension will connect to.", "", "", true, "100")); 949 $currentcomponent->addguielem($section, new gui_textbox("isymphony_jabber_domain", $jabberDomain, "Domain", "Domain this extension will connect to the jabber server with.", "", "", true, "100")); 950 $currentcomponent->addguielem($section, new gui_textbox("isymphony_jabber_resource", $jabberResource, "Resource", "Resource this extension will connect to the jabber server with.", "", "", true, "100")); 951 $currentcomponent->addguielem($section, new gui_textbox("isymphony_jabber_port", $jabberPort, "Port", "Port this extension will connect to the jabber server with.", "", "", true, "100")); 952 $currentcomponent->addguielem($section, new gui_textbox("isymphony_jabber_user_name", $jabberUserName, "UserName", "UserName this extension will connect to the jabber server with.", "", "", true, "100")); 953 $currentcomponent->addguielem($section, new gui_textbox("isymphony_jabber_password", $jabberPassword, "Password", "Password this extension will connect to the jabber server with.", "", "", true, "100")); 749 954 } 750 955 } … … 771 976 $addExtension = isset($_REQUEST["isymphony_add_extension"]); 772 977 $addProfile = isset($_REQUEST["isymphony_add_profile"]); 978 $autoAnswer = isset($_REQUEST["isymphony_auto_answer"]); 773 979 $password = isset($_REQUEST["isymphony_profile_password"]) ? $_REQUEST["isymphony_profile_password"]: null; 774 980 $password = (($password === null) || (trim($password) == "")) ? "secret" : trim($password); 775 981 982 // Cell Phone 983 $cell_phone = isset($_REQUEST["isymphony_add_cell_phone"]) ? $_REQUEST["isymphony_add_cell_phone"] : null; 984 985 // Email 986 $email = isset($_REQUEST["isymphony_add_email"]) ? $_REQUEST["isymphony_add_email"] : null; 987 988 //Jabber info 989 $jabberHost = isset($_REQUEST["isymphony_jabber_host"]) ? $_REQUEST["isymphony_jabber_host"] : null; 990 $jabberDomain = isset($_REQUEST["isymphony_jabber_domain"]) ? $_REQUEST["isymphony_jabber_domain"] : null; 991 $jabberResource = isset($_REQUEST["isymphony_jabber_resource"]) ? $_REQUEST["isymphony_jabber_resource"] : "iSymphony"; 992 $jabberPort = (isset($_REQUEST["isymphony_jabber_port"]) && is_numeric($_REQUEST["isymphony_jabber_port"])) ? $_REQUEST["isymphony_jabber_port"] : "5222"; 993 $jabberUserName = isset($_REQUEST["isymphony_jabber_user_name"]) ? $_REQUEST["isymphony_jabber_user_name"] : null; 994 $jabberPassword = isset($_REQUEST["isymphony_jabber_password"]) ? $_REQUEST["isymphony_jabber_password"] : null; 995 776 996 //Modify DB 777 997 if(($extension !== null) && ($extension != "") && ($action !== null)) { … … 782 1002 } else if(($action == "add") || ($action == "edit") && ($name !== null)) { 783 1003 if(isymphony_user_get($extension) === null) { 784 isymphony_user_add($extension, $addExtension, $addProfile, $password, $name, $peer );1004 isymphony_user_add($extension, $addExtension, $addProfile, $password, $name, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword); 785 1005 } else { 786 isymphony_user_update($extension, $addExtension, $addProfile, $password, $name, $peer );1006 isymphony_user_update($extension, $addExtension, $addProfile, $password, $name, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword); 787 1007 } 788 1008 } … … 902 1122 } 903 1123 1124 //Update checks-------------------------------------------------------------------------------------------------------------------------------------- 1125 function isymphony_location_update_check($serverRevision, $databaseValues, $maskedAutoReloadFlag, $object) { 1126 1127 //Checks for revision 1489 and up 1128 if($serverRevision >= 1489) { 1129 return (($object->asterisk_host != "localhost") || 1130 ($object->asterisk_port != "5038") || 1131 ($object->asterisk_login != "isymphony") || 1132 ($object->asterisk_password != "ismanager*con") || 1133 ($object->originate_timeout != $databaseValues["originate_timeout"]) || 1134 ($object->reload_on_dial_plan_reload != $maskedAutoReloadFlag) || 1135 ($object->jabber_host != $databaseValues["jabber_host"]) || 1136 ($object->jabber_domain != $databaseValues["jabber_domain"]) || 1137 ($object->jabber_resource != $databaseValues["jabber_resource"]) || 1138 ($object->jabber_port != $databaseValues["jabber_port"]) || 1139 ($object->device_user_mode != "true")); 1140 1141 //Checks for 1105-1488 1142 } else if($serverRevision > 1104) { 1143 return (($object->asterisk_host != "localhost") || 1144 ($object->asterisk_port != "5038") || 1145 ($object->asterisk_login != "isymphony") || 1146 ($object->asterisk_password != "ismanager*con") || 1147 ($object->originate_timeout != $databaseValues["originate_timeout"]) || 1148 ($object->jabber_host != $databaseValues["jabber_host"]) || 1149 ($object->jabber_port != $databaseValues["jabber_port"]) || 1150 ($object->device_user_mode != "true")); 1151 1152 //Checks for rev 1104 and below 1153 } else { 1154 1155 return (($object->asterisk_host != "localhost") || 1156 ($object->asterisk_port != "5038") || 1157 ($object->asterisk_login != "isymphony") || 1158 ($object->asterisk_password != "ismanager*con") || 1159 ($object->originate_timeout != $databaseValues["originate_timeout"]) || 1160 ($object->jabber_host != $databaseValues["jabber_host"]) || 1161 ($object->jabber_port != $databaseValues["jabber_port"])); 1162 } 1163 } 1164 1165 function isymphony_tenant_update_check($serverRevision, $databaseValues, $maskedPagedStatusEnabledFlag, $object) { 1166 1167 //Checks for 1105 and above 1168 if($serverRevision > 1104) { 1169 return (($object->originating_context != "from-internal") || 1170 ($object->redirecting_context != "from-internal") || 1171 ($object->page_status_enabled != $maskedPagedStatusEnabledFlag) || 1172 ($object->page_context != "ext-paging")); 1173 1174 //Checks for 1104 and below 1175 } else { 1176 return ($object->originating_context != "from-internal") || ($object->redirecting_context != "from-internal"); 1177 } 1178 } 1179 1180 function isymphony_extension_update_check($serverRevision, $databaseValues, $maskedAutoAnswerFlag, $object) { 1181 1182 //Checks for 1493 and above 1183 if($serverRevision >= 1493) { 1184 return (($object->cell_phone != $databaseValues["cell_phone"]) || 1185 ($object->email != $databaseValues["email"]) || 1186 ($object->name != $databaseValues["display_name"]) || 1187 ($object->voice_mail != $databaseValues["user_id"]) || 1188 ($object->peer != $databaseValues["peer"]) || 1189 ($object->auto_answer != $maskedAutoAnswerFlag)); 1190 1191 //Checks for 1492 and below 1192 } else { 1193 return (($object->cell_phone != $databaseValues["cell_phone"]) || 1194 ($object->email != $databaseValues["email"]) || 1195 ($object->name != $databaseValues["display_name"]) || 1196 ($object->voice_mail != $databaseValues["user_id"]) || 1197 ($object->peer != $databaseValues["peer"])); 1198 } 1199 } 1200 1201 function isymphony_profile_update_check($serverRevision, $databaseValues, $maskedJabberPort, $object) { 1202 1203 //Checks for revision 1489 and up 1204 if($serverRevision >= 1489) { 1205 return (($object->password != $databaseValues["password"]) || 1206 ($object->jabber_host != $databaseValues["jabber_host"]) || 1207 ($object->jabber_domain != $databaseValues["jabber_domain"]) || 1208 ($object->jabber_resource != $databaseValues["jabber_resource"]) || 1209 ($maskedJabberPort != $databaseValues["jabber_port"]) || 1210 ($object->jabber_user_name != $databaseValues["jabber_user_name"]) || 1211 ($object->jabber_password != $databaseValues["jabber_password"])); 1212 1213 //Checks for revision 1488 and below 1214 } else { 1215 return (($object->password != $databaseValues["password"]) || 1216 ($object->jabber_user_name != $databaseValues["jabber_user_name"]) || 1217 ($object->jabber_password != $databaseValues["jabber_password"])); 1218 } 1219 } 1220 904 1221 //Helper functions----------------------------------------------------------------------------------------------------------------------------------- 905 1222 function isymphony_write_to_file($file, $content) {
