| 1 |
<?php |
|---|
| 2 |
/* |
|---|
| 3 |
*Name : functions.inc.php |
|---|
| 4 |
*Author : Michael Yara |
|---|
| 5 |
*Created : June 27, 2008 |
|---|
| 6 |
*Last Updated : May 27, 2009 |
|---|
| 7 |
*History : 1.1 |
|---|
| 8 |
*Purpose : FreePBX module that automatically updates the iSymphony configuration from the FreePBX configuration. |
|---|
| 9 |
*Copyright : 2008 HEHE Enterprises, LLC |
|---|
| 10 |
*/ |
|---|
| 11 |
|
|---|
| 12 |
//Build include path for iSymphony library |
|---|
| 13 |
$inc_path = __FILE__; |
|---|
| 14 |
$pos = strrpos($inc_path, "/"); |
|---|
| 15 |
$inc_path = substr($inc_path, 0, $pos) . "/"; |
|---|
| 16 |
|
|---|
| 17 |
//Include iSymphony library |
|---|
| 18 |
require_once($inc_path . "/isymphony-php-library/isymphony.php"); |
|---|
| 19 |
|
|---|
| 20 |
//ParkAndAnnounce Class |
|---|
| 21 |
class ext_isymphony_parkandannounce { |
|---|
| 22 |
var $template; |
|---|
| 23 |
var $timeout; |
|---|
| 24 |
var $dial; |
|---|
| 25 |
var $return_context; |
|---|
| 26 |
|
|---|
| 27 |
function ext_isymphony_parkandannounce($template, $timeout, $dial, $return_context) { |
|---|
| 28 |
$this->template = $template; |
|---|
| 29 |
$this->timeout = $timeout; |
|---|
| 30 |
$this->dial = $dial; |
|---|
| 31 |
$this->return_context = $return_context; |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
function output() { |
|---|
| 35 |
return "ParkAndAnnounce(" . $this->template . "|" . $this->timeout . "|" . $this->dial . "|" . $this->return_context . ")"; |
|---|
| 36 |
} |
|---|
| 37 |
} |
|---|
| 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 |
|
|---|
| 64 |
//If check box GUI element does not exist add it |
|---|
| 65 |
if(!class_exists("gui_checkbox")) { |
|---|
| 66 |
class gui_checkbox extends guiinput { |
|---|
| 67 |
function gui_checkbox($elemname, $checked=false, $prompttext='', $helptext='', $value='on', $post_text = '', $jsonclick = '', $disable=false) { |
|---|
| 68 |
$parent_class = get_parent_class($this); |
|---|
| 69 |
parent::$parent_class($elemname, '', $prompttext, $helptext); |
|---|
| 70 |
|
|---|
| 71 |
$itemchecked = $checked ? 'checked' : ''; |
|---|
| 72 |
$disable_state = $disable ? 'disabled="true"' : ''; |
|---|
| 73 |
$js_onclick_include = ($jsonclick != '') ? 'onclick="' . $jsonclick. '"' : ''; |
|---|
| 74 |
$tabindex = function_exists("guielement::gettabindex") ? "tabindex=" . guielement::gettabindex() : ""; |
|---|
| 75 |
|
|---|
| 76 |
$this->html_input = "<input type=\"checkbox\" name=\"$this->_elemname\" id=\"$this->_elemname\" $disable_state $tabindex value=\"$value\" $js_onclick_include $itemchecked/>$post_text\n"; |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
//Main contributing module function------------------------------------------------------------------------------------------------------------------ |
|---|
| 82 |
function isymphony_get_config($engine) { |
|---|
| 83 |
|
|---|
| 84 |
global $ext, $ISERROR, $amp_conf; |
|---|
| 85 |
|
|---|
| 86 |
switch($engine) { |
|---|
| 87 |
case 'asterisk': |
|---|
| 88 |
|
|---|
| 89 |
ob_start(); |
|---|
| 90 |
|
|---|
| 91 |
$runningTimeStart = microtime(true); |
|---|
| 92 |
|
|---|
| 93 |
//Open file for error log |
|---|
| 94 |
$errorLogFile = fopen("/var/www/html/admin/modules/isymphony/error.txt", 'w'); |
|---|
| 95 |
|
|---|
| 96 |
//Open debug log |
|---|
| 97 |
if(($debugLogFile = fopen("/var/www/html/admin/modules/isymphony/debug.txt", 'w')) === false) { |
|---|
| 98 |
isymphony_write_to_file($errorLogFile, "Could not open debug log for writing.\n"); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
//Check if a manager profile exists for iSymphony if not create it. |
|---|
| 102 |
$managerFound = false; |
|---|
| 103 |
if((function_exists("manager_list")) && (($managers = manager_list()) !== null)) { |
|---|
| 104 |
|
|---|
| 105 |
//Search for iSymphony manager |
|---|
| 106 |
foreach($managers as $manager) { |
|---|
| 107 |
if($manager['name'] == "isymphony" ) { |
|---|
| 108 |
$managerFound = true; |
|---|
| 109 |
break; |
|---|
| 110 |
} |
|---|
| 111 |
} |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
//If not found create a manager profile for iSymphony |
|---|
| 115 |
if((function_exists("manager_add")) && (function_exists("manager_gen_conf")) && (!$managerFound)) { |
|---|
| 116 |
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"); |
|---|
| 117 |
manager_gen_conf(); |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 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 |
} |
|---|
| 209 |
|
|---|
| 210 |
//Connect to iSymphony server to query and submit information |
|---|
| 211 |
if(iSymphonyConnect()) { |
|---|
| 212 |
|
|---|
| 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 |
} |
|---|
| 259 |
} else { |
|---|
| 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 |
} |
|---|
| 285 |
} |
|---|
| 286 |
} else { |
|---|
| 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)) { |
|---|
| 319 |
|
|---|
| 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 |
} |
|---|
| 330 |
} |
|---|
| 331 |
} else { |
|---|
| 332 |
isymphony_write_to_file($errorLogFile, "(Query tenant)" . $ISERROR. "\n"); |
|---|
| 333 |
} |
|---|
| 334 |
} |
|---|
| 335 |
} else { |
|---|
| 336 |
isymphony_write_to_file($errorLogFile, "(List tenants)" . $ISERROR. "\n"); |
|---|
| 337 |
} |
|---|
| 338 |
} else { |
|---|
| 339 |
isymphony_write_to_file($errorLogFile, "Failed to grab location information". "\n"); |
|---|
| 340 |
} |
|---|
| 341 |
|
|---|
| 342 |
//Grab list of configured extensions from the database |
|---|
| 343 |
$freePBXTempUsers = isymphony_user_list(); |
|---|
| 344 |
|
|---|
| 345 |
//Filter list to exclude extensions that are not marked for addition |
|---|
| 346 |
$freePBXUsers = array(); |
|---|
| 347 |
foreach($freePBXTempUsers as $freePBXTempUser) { |
|---|
| 348 |
if($freePBXTempUser["add_extension"] == "1") { |
|---|
| 349 |
array_push($freePBXUsers, $freePBXTempUser); |
|---|
| 350 |
} |
|---|
| 351 |
} |
|---|
| 352 |
|
|---|
| 353 |
//Filter the previous list for profiles excluding ones not marked for profile addition |
|---|
| 354 |
$freePBXProfiles = array(); |
|---|
| 355 |
foreach($freePBXUsers as $freePBXUser) { |
|---|
| 356 |
if($freePBXUser["add_profile"] == "1") { |
|---|
| 357 |
array_push($freePBXProfiles, $freePBXUser); |
|---|
| 358 |
} |
|---|
| 359 |
} |
|---|
| 360 |
|
|---|
| 361 |
//Add, edit and remove extensions and profiles |
|---|
| 362 |
if((($iSymphonyExtensions = getISymphonyExtensionList("default", "default")) !== false) && (($iSymphonyProfiles = getISymphonyProfileList("default", "default")) !== false)) { |
|---|
| 363 |
|
|---|
| 364 |
//Build array of freePBX extensions to compare to iSymphony list for deletes |
|---|
| 365 |
$freePBXExtensionCheckDeleteArray = array(); |
|---|
| 366 |
foreach($freePBXUsers as $freePBXUser) { |
|---|
| 367 |
array_push($freePBXExtensionCheckDeleteArray, $freePBXUser["user_id"]); |
|---|
| 368 |
} |
|---|
| 369 |
|
|---|
| 370 |
//Delete appropriate extensions |
|---|
| 371 |
$deleteExtensionArray = array_diff($iSymphonyExtensions, $freePBXExtensionCheckDeleteArray); |
|---|
| 372 |
foreach($deleteExtensionArray as $val) { |
|---|
| 373 |
if(removeISymphonyExtension("default", "default", $val)) { |
|---|
| 374 |
isymphony_write_to_file($debugLogFile, "Deleted extension {$val}\n"); |
|---|
| 375 |
$iSymphonyExtensions = isymphony_remove_array_item($iSymphonyExtensions, $val); |
|---|
| 376 |
} else { |
|---|
| 377 |
isymphony_write_to_file($errorLogFile, "(Delete extension)" . $ISERROR. "\n"); |
|---|
| 378 |
} |
|---|
| 379 |
} |
|---|
| 380 |
|
|---|
| 381 |
//Add and update extensions |
|---|
| 382 |
foreach($freePBXUsers as $freePBXUser) { |
|---|
| 383 |
|
|---|
| 384 |
//Mask auto answer flag |
|---|
| 385 |
$maskedAutoAnswerFlag = ($freePBXUser["auto_answer"] == 1) ? "true" : "false"; |
|---|
| 386 |
|
|---|
| 387 |
//If extension does not exist add it else update it |
|---|
| 388 |
if(!in_array($freePBXUser["user_id"], $iSymphonyExtensions)) { |
|---|
| 389 |
|
|---|
| 390 |
//Add extension |
|---|
| 391 |
$object = new ISymphonyExtension; |
|---|
| 392 |
$object->extension_val = $freePBXUser["user_id"]; |
|---|
| 393 |
$object->name = $freePBXUser["display_name"]; |
|---|
| 394 |
$object->peer = $freePBXUser["peer"]; |
|---|
| 395 |
$object->alt_origination_method = ""; |
|---|
| 396 |
$object->voice_mail = $freePBXUser["user_id"]; |
|---|
| 397 |
$object->cell_phone = $freePBXUser["cell_phone"]; |
|---|
| 398 |
$object->email = $freePBXUser["email"]; |
|---|
| 399 |
$object->auto_answer = $maskedAutoAnswerFlag; |
|---|
| 400 |
|
|---|
| 401 |
if($object->add("default","default")) { |
|---|
| 402 |
isymphony_write_to_file($debugLogFile, "Added extension {$freePBXUser['user_id']}\n"); |
|---|
| 403 |
} else { |
|---|
| 404 |
isymphony_write_to_file($errorLogFile, "(Add extension)" . $ISERROR . "\n"); |
|---|
| 405 |
} |
|---|
| 406 |
} else { |
|---|
| 407 |
|
|---|
| 408 |
//Query extension configuration and update values |
|---|
| 409 |
if(($object = getISymphonyExtension("default", "default", $freePBXUser["user_id"])) !== false) { |
|---|
| 410 |
|
|---|
| 411 |
//Check if update needs to occur |
|---|
| 412 |
if(isymphony_extension_update_check($serverRevision, $freePBXUser, $maskedAutoAnswerFlag, $object)) { |
|---|
| 413 |
|
|---|
| 414 |
$object->name = $freePBXUser["display_name"]; |
|---|
| 415 |
$object->voice_mail = $freePBXUser["user_id"]; |
|---|
| 416 |
$object->peer = $freePBXUser["peer"]; |
|---|
| 417 |
$object->cell_phone = $freePBXUser["cell_phone"]; |
|---|
| 418 |
$object->email = $freePBXUser["email"]; |
|---|
| 419 |
$object->auto_answer = $maskedAutoAnswerFlag; |
|---|
| 420 |
|
|---|
| 421 |
if($object->update()) { |
|---|
| 422 |
isymphony_write_to_file($debugLogFile, "Updated extension {$freePBXUser['user_id']}\n"); |
|---|
| 423 |
} else { |
|---|
| 424 |
isymphony_write_to_file($errorLogFile, "(Update extension)" . $ISERROR. "\n"); |
|---|
| 425 |
} |
|---|
| 426 |
} |
|---|
| 427 |
} else { |
|---|
| 428 |
isymphony_write_to_file($errorLogFile, "(Query extension)" . $ISERROR. "\n"); |
|---|
| 429 |
} |
|---|
| 430 |
} |
|---|
| 431 |
} |
|---|
| 432 |
|
|---|
| 433 |
//Build array of freePBX extensions to compare to iSymphony list for deletes |
|---|
| 434 |
$freePBXProfileCheckDeleteArray = array(); |
|---|
| 435 |
foreach($freePBXProfiles as $freePBXProfile) { |
|---|
| 436 |
array_push($freePBXProfileCheckDeleteArray, $freePBXProfile["user_id"]); |
|---|
| 437 |
} |
|---|
| 438 |
|
|---|
| 439 |
//Delete appropriate profiles |
|---|
| 440 |
$deleteProfileArray = array_diff($iSymphonyProfiles, $freePBXProfileCheckDeleteArray); |
|---|
| 441 |
foreach($deleteProfileArray as $val) { |
|---|
| 442 |
if(removeISymphonyProfile("default", "default", $val)) { |
|---|
| 443 |
isymphony_write_to_file($debugLogFile, "Deleted profile {$val}\n"); |
|---|
| 444 |
$iSymphonyProfiles = isymphony_remove_array_item($iSymphonyProfiles, $val); |
|---|
| 445 |
} else { |
|---|
| 446 |
isymphony_write_to_file($errorLogFile, "(Delete profile)" . $ISERROR. "\n"); |
|---|
| 447 |
} |
|---|
| 448 |
} |
|---|
| 449 |
|
|---|
| 450 |
//Add and update profiles |
|---|
| 451 |
foreach($freePBXProfiles as $freePBXProfile) { |
|---|
| 452 |
|
|---|
| 453 |
//If profile does not exist add it else update it |
|---|
| 454 |
if(!in_array($freePBXProfile["user_id"], $iSymphonyProfiles)) { |
|---|
| 455 |
|
|---|
| 456 |
//Add profile |
|---|
| 457 |
$object = new ISymphonyProfile; |
|---|
| 458 |
$object->name = $freePBXProfile["user_id"]; |
|---|
| 459 |
$object->password = $freePBXProfile["password"]; |
|---|
| 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"]; |
|---|
| 467 |
|
|---|
| 468 |
if($object->add("default","default")) { |
|---|
| 469 |
isymphony_write_to_file($debugLogFile, "Added profile {$freePBXProfile['user_id']}\n"); |
|---|
| 470 |
} else { |
|---|
| 471 |
isymphony_write_to_file($errorLogFile, "(Add profile)" . $ISERROR . "\n"); |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
//Add extension to profiles managed list |
|---|
| 475 |
if(addISymphonyProfileManagedExtension("default","default",$freePBXProfile["user_id"],$freePBXProfile["user_id"])) { |
|---|
| 476 |
isymphony_write_to_file($debugLogFile, "Added profile managed extension {$freePBXProfile['user_id']}\n"); |
|---|
| 477 |
} else { |
|---|
| 478 |
isymphony_write_to_file($errorLogFile, "(Add profile managed extension)" . $ISERROR . "\n"); |
|---|
| 479 |
} |
|---|
| 480 |
} else { |
|---|
| 481 |
|
|---|
| 482 |
//Query profile configuration and update values |
|---|
| 483 |
if(($object = getISymphonyProfile("default", "default", $freePBXProfile["user_id"])) !== false) { |
|---|
| 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 |
|
|---|
| 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"]; |
|---|
| 498 |
|
|---|
| 499 |
if($object->update()) { |
|---|
| 500 |
isymphony_write_to_file($debugLogFile, "Updated profile {$freePBXProfile['user_id']}\n"); |
|---|
| 501 |
} else { |
|---|
| 502 |
isymphony_write_to_file($errorLogFile, "(Update profile)" . $ISERROR. "\n"); |
|---|
| 503 |
} |
|---|
| 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 |
|
|---|
| 511 |
} else { |
|---|
| 512 |
isymphony_write_to_file($errorLogFile, "(Query profile)" . $ISERROR. "\n"); |
|---|
| 513 |
} |
|---|
| 514 |
} |
|---|
| 515 |
} |
|---|
| 516 |
} else { |
|---|
| 517 |
isymphony_write_to_file($errorLogFile, "(List extensions/profiles)" . $ISERROR. "\n"); |
|---|
| 518 |
} |
|---|
| 519 |
|
|---|
| 520 |
//Grab list of configured queues from the database |
|---|
| 521 |
$freePBXTempQueues = isymphony_queue_list(); |
|---|
| 522 |
|
|---|
| 523 |
//Filter list to exclude queues that are not marked for addition |
|---|
| 524 |
$freePBXQueues = array(); |
|---|
| 525 |
foreach($freePBXTempQueues as $freePBXTempQueue) { |
|---|
| 526 |
if($freePBXTempQueue["add_queue"] == "1") { |
|---|
| 527 |
array_push($freePBXQueues, $freePBXTempQueue); |
|---|
| 528 |
} |
|---|
| 529 |
} |
|---|
| 530 |
|
|---|
| 531 |
//Add, edit and remove queues |
|---|
| 532 |
if(($iSymphonyQueues = getISymphonyQueueList("default", "default")) !== false) { |
|---|
| 533 |
|
|---|
| 534 |
//Build array of freePBX queues to compare to iSymphony list for deletes |
|---|
| 535 |
$freePBXQueueCheckDeleteArray = array(); |
|---|
| 536 |
foreach($freePBXQueues as $freePBXQueue) { |
|---|
| 537 |
array_push($freePBXQueueCheckDeleteArray, $freePBXQueue["display_name"]); |
|---|
| 538 |
} |
|---|
| 539 |
|
|---|
| 540 |
//Delete appropriate queues |
|---|
| 541 |
$deleteQueueArray = array_diff($iSymphonyQueues, $freePBXQueueCheckDeleteArray); |
|---|
| 542 |
foreach($deleteQueueArray as $val) { |
|---|
| 543 |
if(removeISymphonyQueue("default", "default", $val)) { |
|---|
| 544 |
isymphony_write_to_file($debugLogFile, "Deleted queue {$val}\n"); |
|---|
| 545 |
$iSymphonyQueues = isymphony_remove_array_item($iSymphonyQueues, $val); |
|---|
| 546 |
} else { |
|---|
| 547 |
isymphony_write_to_file($errorLogFile, "(Delete queue)" . $ISERROR. "\n"); |
|---|
| 548 |
} |
|---|
| 549 |
} |
|---|
| 550 |
|
|---|
| 551 |
//Add and update queues |
|---|
| 552 |
foreach($freePBXQueues as $freePBXQueue) { |
|---|
| 553 |
|
|---|
| 554 |
//If queue does not exist add it |
|---|
| 555 |
if(!in_array($freePBXQueue["display_name"], $iSymphonyQueues)) { |
|---|
| 556 |
|
|---|
| 557 |
//Add queue |
|---|
| 558 |
$object = new ISymphonyQueue; |
|---|
| 559 |
$object->name = $freePBXQueue["display_name"]; |
|---|
| 560 |
$object->queue_val = $freePBXQueue["queue_id"]; |
|---|
| 561 |
$object->extension_val = $freePBXQueue["queue_id"]; |
|---|
| 562 |
$object->context = "from-internal"; |
|---|
| 563 |
|
|---|
| 564 |
if($object->add("default","default")) { |
|---|
| 565 |
isymphony_write_to_file($debugLogFile, "Added queue {$freePBXQueue['display_name']}\n"); |
|---|
| 566 |
} else { |
|---|
| 567 |
isymphony_write_to_file($errorLogFile, "(Add queue)" . $ISERROR . "\n"); |
|---|
| 568 |
} |
|---|
| 569 |
|
|---|
| 570 |
//If queue does exist update it |
|---|
| 571 |
} else { |
|---|
| 572 |
|
|---|
| 573 |
//Query queue configuration and update values |
|---|
| 574 |
if(($object = getISymphonyQueue("default", "default", $freePBXQueue["display_name"])) !== false) { |
|---|
| 575 |
|
|---|
| 576 |
//Check if update needs to occur |
|---|
| 577 |
if(($object->name != $freePBXQueue["display_name"]) || ($object->queue_val != $freePBXQueue["queue_id"]) || ($object->extension_val != $freePBXQueue["queue_id"]) || ($object->context != "from-internal")) { |
|---|
| 578 |
|
|---|
| 579 |
$object->name = $freePBXQueue["display_name"]; |
|---|
| 580 |
$object->queue_val = $freePBXQueue["queue_id"]; |
|---|
| 581 |
$object->extension_val = $freePBXQueue["queue_id"]; |
|---|
| 582 |
$object->context = "from-internal"; |
|---|
| 583 |
|
|---|
| 584 |
if($object->update()) { |
|---|
| 585 |
isymphony_write_to_file($debugLogFile, "Updated queue {$freePBXQueue['display_name']}\n"); |
|---|
| 586 |
} else { |
|---|
| 587 |
isymphony_write_to_file($errorLogFile, "(Update queue)" . $ISERROR. "\n"); |
|---|
| 588 |
} |
|---|
| 589 |
} |
|---|
| 590 |
} else { |
|---|
| 591 |
isymphony_write_to_file($errorLogFile, "(Query queue)" . $ISERROR. "\n"); |
|---|
| 592 |
} |
|---|
| 593 |
} |
|---|
| 594 |
} |
|---|
| 595 |
} else { |
|---|
| 596 |
isymphony_write_to_file($errorLogFile, "(List queues)" . $ISERROR. "\n"); |
|---|
| 597 |
} |
|---|
| 598 |
|
|---|
| 599 |
//Grab list of configured conference rooms from the database |
|---|
| 600 |
$freePBXTempConferenceRooms = isymphony_conference_room_list(); |
|---|
| 601 |
|
|---|
| 602 |
//Filter list to exclude conference rooms that are not marked for addition |
|---|
| 603 |
$freePBXConferenceRooms = array(); |
|---|
| 604 |
foreach($freePBXTempConferenceRooms as $freePBXTempConferenceRoom) { |
|---|
| 605 |
if($freePBXTempConferenceRoom["add_conference_room"] == "1") { |
|---|
| 606 |
array_push($freePBXConferenceRooms, $freePBXTempConferenceRoom); |
|---|
| 607 |
} |
|---|
| 608 |
} |
|---|
| 609 |
|
|---|
| 610 |
//Add, edit and remove conference rooms |
|---|
| 611 |
if(($iSymphonyConferenceRooms = getISymphonyConferenceRoomList("default", "default")) !== false) { |
|---|
| 612 |
|
|---|
| 613 |
//Build array of freePBX conference rooms to compare to iSymphony list for deletes |
|---|
| 614 |
$freePBXConferenceRoomCheckDeleteArray = array(); |
|---|
| 615 |
foreach($freePBXConferenceRooms as $freePBXConferenceRoom) { |
|---|
| 616 |
array_push($freePBXConferenceRoomCheckDeleteArray, $freePBXConferenceRoom["display_name"]); |
|---|
| 617 |
} |
|---|
| 618 |
|
|---|
| 619 |
//Delete appropriate conference rooms |
|---|
| 620 |
$deleteConferenceRoomArray = array_diff($iSymphonyConferenceRooms, $freePBXConferenceRoomCheckDeleteArray); |
|---|
| 621 |
foreach($deleteConferenceRoomArray as $val) { |
|---|
| 622 |
if(removeISymphonyConferenceRoom("default", "default", $val)) { |
|---|
| 623 |
isymphony_write_to_file($debugLogFile, "Deleted conference room {$val}\n"); |
|---|
| 624 |
$iSymphonyConferenceRooms = isymphony_remove_array_item($iSymphonyConferenceRooms, $val); |
|---|
| 625 |
} else { |
|---|
| 626 |
isymphony_write_to_file($errorLogFile, "(Delete conference room)" . $ISERROR. "\n"); |
|---|
| 627 |
} |
|---|
| 628 |
} |
|---|
| 629 |
|
|---|
| 630 |
//Add and update conference rooms |
|---|
| 631 |
foreach($freePBXConferenceRooms as $freePBXConferenceRoom) { |
|---|
| 632 |
|
|---|
| 633 |
//If conference room does not exist add it |
|---|
| 634 |
if(!in_array($freePBXConferenceRoom["display_name"], $iSymphonyConferenceRooms)) { |
|---|
| 635 |
|
|---|
| 636 |
//Add conference room |
|---|
| 637 |
$object = new ISymphonyConferenceRoom; |
|---|
| 638 |
$object->name = $freePBXConferenceRoom["display_name"]; |
|---|
| 639 |
$object->predefined = "true"; |
|---|
| 640 |
$object->room_number = $freePBXConferenceRoom["conference_room_id"]; |
|---|
| 641 |
$object->extension_val = $freePBXConferenceRoom["conference_room_id"]; |
|---|
| 642 |
$object->context = "from-internal"; |
|---|
| 643 |
$object->announce_user_count = "false"; |
|---|
| 644 |
$object->music_on_hold_for_single_user = "false"; |
|---|
| 645 |
$object->exit_room_via_pound = "false"; |
|---|
| 646 |
$object->present_menu_via_star = "false"; |
|---|
| 647 |
$object->announce_user_join_leave = "false"; |
|---|
| 648 |
$object->disable_join_leave_notification = "false"; |
|---|
| 649 |
$object->record = "false"; |
|---|
| 650 |
|
|---|
| 651 |
if($object->add("default","default")) { |
|---|
| 652 |
isymphony_write_to_file($debugLogFile, "Added conference room {$freePBXConferenceRoom['display_name']}\n"); |
|---|
| 653 |
} else { |
|---|
| 654 |
isymphony_write_to_file($errorLogFile, "(Add conference room)" . $ISERROR . "\n"); |
|---|
| 655 |
} |
|---|
| 656 |
|
|---|
| 657 |
//If conference room does exist update it |
|---|
| 658 |
} else { |
|---|
| 659 |
|
|---|
| 660 |
//Query conference room configuration and update values |
|---|
| 661 |
if(($object = getISymphonyConferenceRoom("default", "default", $freePBXConferenceRoom["display_name"])) !== false) { |
|---|
| 662 |
|
|---|
| 663 |
//Check if update needs to occur |
|---|
| 664 |
if(($object->name != $freePBXConferenceRoom["display_name"]) || ($object->predefined != "true") || ($object->room_number != $freePBXConferenceRoom["conference_room_id"]) || ($object->extension_val != $freePBXConferenceRoom["conference_room_id"]) || ($object->context != "from-internal")) { |
|---|
| 665 |
|
|---|
| 666 |
$object->name = $freePBXConferenceRoom["display_name"]; |
|---|
| 667 |
$object->predefined = "true"; |
|---|
| 668 |
$object->room_number = $freePBXConferenceRoom["conference_room_id"]; |
|---|
| 669 |
$object->extension_val = $freePBXConferenceRoom["conference_room_id"]; |
|---|
| 670 |
$object->context = "from-internal"; |
|---|
| 671 |
|
|---|
| 672 |
if($object->update()) { |
|---|
| 673 |
isymphony_write_to_file($debugLogFile, "Updated conference room {$freePBXConferenceRoom['display_name']}\n"); |
|---|
| 674 |
} else { |
|---|
| 675 |
isymphony_write_to_file($errorLogFile, "(Update conference room)" . $ISERROR. "\n"); |
|---|
| 676 |
} |
|---|
| 677 |
} |
|---|
| 678 |
} else { |
|---|
| 679 |
isymphony_write_to_file($errorLogFile, "(Query conference room)" . $ISERROR. "\n"); |
|---|
| 680 |
} |
|---|
| 681 |
} |
|---|
| 682 |
} |
|---|
| 683 |
} else { |
|---|
| 684 |
isymphony_write_to_file($errorLogFile, "(List conference rooms)" . $ISERROR. "\n"); |
|---|
| 685 |
} |
|---|
| 686 |
|
|---|
| 687 |
//Close iSymphony connection |
|---|
| 688 |
iSymphonyDisconnect(); |
|---|
| 689 |
|
|---|
| 690 |
} else { |
|---|
| 691 |
isymphony_write_to_file($errorLogFile, $ISERROR. "\n"); |
|---|
| 692 |
} |
|---|
| 693 |
|
|---|
| 694 |
$runningTimeStop = microtime(true); |
|---|
| 695 |
isymphony_write_to_file($debugLogFile, "Total Running Time:" . ($runningTimeStop - $runningTimeStart) . "s\n"); |
|---|
| 696 |
|
|---|
| 697 |
//Close file handlers |
|---|
| 698 |
fclose($debugLogFile); |
|---|
| 699 |
fclose($errorLogFile); |
|---|
| 700 |
|
|---|
| 701 |
ob_end_clean(); |
|---|
| 702 |
break; |
|---|
| 703 |
} |
|---|
| 704 |
} |
|---|
| 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 |
|
|---|
| 729 |
//iSymphony module API user functions---------------------------------------------------------------------------------------------------------------- |
|---|
| 730 |
function isymphony_user_add($userId, $addExtension, $addProfile, $password, $displayName, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword) { |
|---|
| 731 |
global $db; |
|---|
| 732 |
$addProfile = $addProfile ? "1" : "0"; |
|---|
| 733 |
$addExtension = $addExtension ? "1" : "0"; |
|---|
| 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); |
|---|
| 737 |
$db->execute($prepStatement, $values); |
|---|
| 738 |
} |
|---|
| 739 |
|
|---|
| 740 |
function isymphony_user_update($userId, $addExtension, $addProfile, $password, $displayName, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword) { |
|---|
| 741 |
global $db; |
|---|
| 742 |
$addProfile = $addProfile ? "1" : "0"; |
|---|
| 743 |
$addExtension = $addExtension ? "1" : "0"; |
|---|
| 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); |
|---|
| 747 |
$db->execute($prepStatement, $values); |
|---|
| 748 |
} |
|---|
| 749 |
|
|---|
| 750 |
function isymphony_user_del($userId) { |
|---|
| 751 |
global $db; |
|---|
| 752 |
$query = "DELETE FROM isymphony_users WHERE user_id = '$userId'"; |
|---|
| 753 |
$db->query($query); |
|---|
| 754 |
} |
|---|
| 755 |
|
|---|
| 756 |
function isymphony_user_list() { |
|---|
| 757 |
global $db; |
|---|
| 758 |
$query = "SELECT * FROM isymphony_users"; |
|---|
| 759 |
$results = sql($query, "getAll", DB_FETCHMODE_ASSOC); |
|---|
| 760 |
if((DB::IsError($results)) || (empty($results))) { |
|---|
| 761 |
return array(); |
|---|
| 762 |
} else { |
|---|
| 763 |
return $results; |
|---|
| 764 |
} |
|---|
| 765 |
} |
|---|
| 766 |
|
|---|
| 767 |
function isymphony_user_get($userId) { |
|---|
| 768 |
global $db; |
|---|
| 769 |
$query = "SELECT * FROM isymphony_users WHERE user_id = '$userId'"; |
|---|
| 770 |
$results = sql($query, "getRow", DB_FETCHMODE_ASSOC); |
|---|
| 771 |
if((DB::IsError($results)) || (empty($results))) { |
|---|
| 772 |
return null; |
|---|
| 773 |
} else { |
|---|
| 774 |
return $results; |
|---|
| 775 |
} |
|---|
| 776 |
} |
|---|
| 777 |
|
|---|
| 778 |
//iSymphony module API queue functions--------------------------------------------------------------------------------------------------------------- |
|---|
| 779 |
function isymphony_queue_add($queueId, $addQueue, $displayName) { |
|---|
| 780 |
global $db; |
|---|
| 781 |
$addQueue = $addQueue ? "1" : "0"; |
|---|
| 782 |
$prepStatement = $db->prepare("INSERT INTO isymphony_queues (queue_id, add_queue, display_name) VALUES (?, ?, ?)"); |
|---|
| 783 |
$values = array($queueId, $addQueue, $displayName); |
|---|
| 784 |
$db->execute($prepStatement, $values); |
|---|
| 785 |
} |
|---|
| 786 |
|
|---|
| 787 |
function isymphony_queue_update($queueId, $addQueue, $displayName) { |
|---|
| 788 |
global $db; |
|---|
| 789 |
$addQueue = $addQueue ? "1" : "0"; |
|---|
| 790 |
$prepStatement = $db->prepare("UPDATE isymphony_queues SET add_queue = ?, display_name = ? WHERE queue_id = $queueId"); |
|---|
| 791 |
$values = array($addQueue, $displayName); |
|---|
| 792 |
$db->execute($prepStatement, $values); |
|---|
| 793 |
} |
|---|
| 794 |
|
|---|
| 795 |
function isymphony_queue_del($queueId) { |
|---|
| 796 |
global $db; |
|---|
| 797 |
$query = "DELETE FROM isymphony_queues WHERE queue_id = '$queueId'"; |
|---|
| 798 |
$db->query($query); |
|---|
| 799 |
} |
|---|
| 800 |
|
|---|
| 801 |
function isymphony_queue_list() { |
|---|
| 802 |
global $db; |
|---|
| 803 |
$query = "SELECT * FROM isymphony_queues"; |
|---|
| 804 |
$results = sql($query, "getAll", DB_FETCHMODE_ASSOC); |
|---|
| 805 |
if((DB::IsError($results)) || (empty($results))) { |
|---|
| 806 |
return array(); |
|---|
| 807 |
} else { |
|---|
| 808 |
return $results; |
|---|
| 809 |
} |
|---|
| 810 |
} |
|---|
| 811 |
|
|---|
| 812 |
function isymphony_queue_get($queueId) { |
|---|
| 813 |
global $db; |
|---|
| 814 |
$query = "SELECT * FROM isymphony_queues WHERE queue_id = '$queueId'"; |
|---|
| 815 |
$results = sql($query, "getRow", DB_FETCHMODE_ASSOC); |
|---|
| 816 |
if((DB::IsError($results)) || (empty($results))) { |
|---|
| 817 |
return null; |
|---|
| 818 |
} else { |
|---|
| 819 |
return $results; |
|---|
| 820 |
} |
|---|
| 821 |
} |
|---|
| 822 |
|
|---|
| 823 |
//iSymphony module API conference room functions----------------------------------------------------------------------------------------------------- |
|---|
| 824 |
function isymphony_conference_room_add($conferenceRoomId, $addConferenceRoom, $displayName) { |
|---|
| 825 |
global $db; |
|---|
| 826 |
$addConferenceRoom = $addConferenceRoom ? "1" : "0"; |
|---|
| 827 |
$prepStatement = $db->prepare("INSERT INTO isymphony_conference_rooms (conference_room_id, add_conference_room, display_name) VALUES (?, ?, ?)"); |
|---|
| 828 |
$values = array($conferenceRoomId, $addConferenceRoom, $displayName); |
|---|
| 829 |
$db->execute($prepStatement, $values); |
|---|
| 830 |
} |
|---|
| 831 |
|
|---|
| 832 |
function isymphony_conference_room_update($conferenceRoomId, $addConferenceRoom, $displayName) { |
|---|
| 833 |
global $db; |
|---|
| 834 |
$addConferenceRoom = $addConferenceRoom ? "1" : "0"; |
|---|
| 835 |
$prepStatement = $db->prepare("UPDATE isymphony_conference_rooms SET add_conference_room = ?, display_name = ? WHERE conference_room_id = $conferenceRoomId"); |
|---|
| 836 |
$values = array($addConferenceRoom, $displayName); |
|---|
| 837 |
$db->execute($prepStatement, $values); |
|---|
| 838 |
} |
|---|
| 839 |
|
|---|
| 840 |
function isymphony_conference_room_del($conferenceRoomId) { |
|---|
| 841 |
global $db; |
|---|
| 842 |
$query = "DELETE FROM isymphony_conference_rooms WHERE conference_room_id = '$conferenceRoomId'"; |
|---|
| 843 |
$db->query($query); |
|---|
| 844 |
} |
|---|
| 845 |
|
|---|
| 846 |
function isymphony_conference_room_list() { |
|---|
| 847 |
global $db; |
|---|
| 848 |
$query = "SELECT * FROM isymphony_conference_rooms"; |
|---|
| 849 |
$results = sql($query, "getAll", DB_FETCHMODE_ASSOC); |
|---|
| 850 |
if((DB::IsError($results)) || (empty($results))) { |
|---|
| 851 |
return array(); |
|---|
| 852 |
} else { |
|---|
| 853 |
return $results; |
|---|
| 854 |
} |
|---|
| 855 |
} |
|---|
| 856 |
|
|---|
| 857 |
function isymphony_conference_room_get($conferenceRoomId) { |
|---|
| 858 |
global $db; |
|---|
| 859 |
$query = "SELECT * FROM isymphony_conference_rooms WHERE conference_room_id = '$conferenceRoomId'"; |
|---|
| 860 |
$results = sql($query, "getRow", DB_FETCHMODE_ASSOC); |
|---|
| 861 |
if((DB::IsError($results)) || (empty($results))) { |
|---|
| 862 |
return null; |
|---|
| 863 |
} else { |
|---|
| 864 |
return $results; |
|---|
| 865 |
} |
|---|
| 866 |
} |
|---|
| 867 |
|
|---|
| 868 |
//Extension/User page hooks-------------------------------------------------------------------------------------------------------------------------- |
|---|
| 869 |
function isymphony_configpageinit($pagename) { |
|---|
| 870 |
global $currentcomponent; |
|---|
| 871 |
|
|---|
| 872 |
//Query page state |
|---|
| 873 |
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : null; |
|---|
| 874 |
$extdisplay = isset($_REQUEST["extdisplay"]) ? $_REQUEST["extdisplay"] : null; |
|---|
| 875 |
$extension = isset($_REQUEST["extension"]) ? $_REQUEST["extension"] : null; |
|---|
| 876 |
$tech_hardware = isset($_REQUEST["tech_hardware"]) ? $_REQUEST["tech_hardware"] : null; |
|---|
| 877 |
|
|---|
| 878 |
//Based on the page state determine if the display or process functions should be added |
|---|
| 879 |
if (($pagename != "users") && ($pagename != "extensions")) { |
|---|
| 880 |
return; |
|---|
| 881 |
} else if ($tech_hardware != null || $pagename == "users") { |
|---|
| 882 |
isymphony_extension_applyhooks(); |
|---|
| 883 |
$currentcomponent->addprocessfunc('isymphony_extension_configprocess', 8); |
|---|
| 884 |
} elseif ($action == "add" || $action == "edit") { |
|---|
| 885 |
$currentcomponent->addprocessfunc('isymphony_extension_configprocess', 8); |
|---|
| 886 |
} elseif ($extdisplay != '') { |
|---|
| 887 |
isymphony_extension_applyhooks(); |
|---|
| 888 |
$currentcomponent->addprocessfunc('isymphony_extension_configprocess', 8); |
|---|
| 889 |
} |
|---|
| 890 |
} |
|---|
| 891 |
|
|---|
| 892 |
function isymphony_extension_applyhooks() { |
|---|
| 893 |
global $currentcomponent; |
|---|
| 894 |
$currentcomponent->addguifunc("isymphony_extension_configpageload"); |
|---|
| 895 |
} |
|---|
| 896 |
|
|---|
| 897 |
function isymphony_extension_configpageload() { |
|---|
| 898 |
global $currentcomponent; |
|---|
| 899 |
|
|---|
| 900 |
//Query page state |
|---|
| 901 |
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : null; |
|---|
| 902 |
$display = isset($_REQUEST["display"]) ? $_REQUEST["display"] : null; |
|---|
| 903 |
$extension = isset($_REQUEST["extdisplay"]) ? $_REQUEST["extdisplay"] : null; |
|---|
| 904 |
|
|---|
| 905 |
//Attempt to query element if not found set defaults |
|---|
| 906 |
if(($extension !== null) && (($iSymphonyUser = isymphony_user_get($extension)) !== null)) { |
|---|
| 907 |
$added = ($iSymphonyUser["add_extension"] == "1"); |
|---|
| 908 |
$userProfile = ($iSymphonyUser["add_profile"] == "1"); |
|---|
| 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"]; |
|---|
| 919 |
|
|---|
| 920 |
} else { |
|---|
| 921 |
$added = true; |
|---|
| 922 |
$userProfile = true; |
|---|
| 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 = ""; |
|---|
| 933 |
} |
|---|
| 934 |
|
|---|
| 935 |
//Create GIU elements if not on delete page |
|---|
| 936 |
if ($action != "del") { |
|---|
| 937 |
$section = _("iSymphony Profile Settings"); |
|---|
| 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)); |
|---|
| 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")); |
|---|
| 954 |
} |
|---|
| 955 |
} |
|---|
| 956 |
|
|---|
| 957 |
function isymphony_extension_configprocess() { |
|---|
| 958 |
|
|---|
| 959 |
//Query page state |
|---|
| 960 |
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : null; |
|---|
| 961 |
$ext = isset($_REQUEST["extdisplay"]) ? $_REQUEST["extdisplay"] : null; |
|---|
| 962 |
$extn = isset($_REQUEST["extension"]) ? $_REQUEST["extension"]: null; |
|---|
| 963 |
$name = isset($_REQUEST["name"]) ? $_REQUEST["name"] : null; |
|---|
| 964 |
$extension = ($ext === "") ? $extn : $ext; |
|---|
| 965 |
|
|---|
| 966 |
//Determine peer |
|---|
| 967 |
if(isset($_REQUEST["devinfo_dial"]) && ($_REQUEST["devinfo_dial"] != "")) { |
|---|
| 968 |
$peer = $_REQUEST["devinfo_dial"]; |
|---|
| 969 |
} else if (isset($_REQUEST["tech"])){ |
|---|
| 970 |
$peer = strtoupper($_REQUEST["tech"]) . "/" . $extension; |
|---|
| 971 |
} else { |
|---|
| 972 |
$peer = "SIP/$extension"; |
|---|
| 973 |
} |
|---|
| 974 |
|
|---|
| 975 |
//Query iSymphony options |
|---|
| 976 |
$addExtension = isset($_REQUEST["isymphony_add_extension"]); |
|---|
| 977 |
$addProfile = isset($_REQUEST["isymphony_add_profile"]); |
|---|
| 978 |
$autoAnswer = isset($_REQUEST["isymphony_auto_answer"]); |
|---|
| 979 |
$password = isset($_REQUEST["isymphony_profile_password"]) ? $_REQUEST["isymphony_profile_password"]: null; |
|---|
| 980 |
$password = (($password === null) || (trim($password) == "")) ? "secret" : trim($password); |
|---|
| 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 |
|
|---|
| 996 |
//Modify DB |
|---|
| 997 |
if(($extension !== null) && ($extension != "") && ($action !== null)) { |
|---|
| 998 |
|
|---|
| 999 |
//Check if this extension needs to be deleted, updated, or added |
|---|
| 1000 |
if($action == "del") { |
|---|
| 1001 |
isymphony_user_del($extension); |
|---|
| 1002 |
} else if(($action == "add") || ($action == "edit") && ($name !== null)) { |
|---|
| 1003 |
if(isymphony_user_get($extension) === null) { |
|---|
| 1004 |
isymphony_user_add($extension, $addExtension, $addProfile, $password, $name, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword); |
|---|
| 1005 |
} else { |
|---|
| 1006 |
isymphony_user_update($extension, $addExtension, $addProfile, $password, $name, $peer, $cell_phone, $email, $autoAnswer, $jabberHost, $jabberDomain, $jabberResource, $jabberPort, $jabberUserName, $jabberPassword); |
|---|
| 1007 |
} |
|---|
| 1008 |
} |
|---|
| 1009 |
} |
|---|
| 1010 |
} |
|---|
| 1011 |
|
|---|
| 1012 |
//Queue page hooks----------------------------------------------------------------------------------------------------------------------------------- |
|---|
| 1013 |
function isymphony_hook_queues($viewing_itemid, $target_menuid) { |
|---|
| 1014 |
|
|---|
| 1015 |
//Query page state |
|---|
| 1016 |
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : null; |
|---|
| 1017 |
$display = ""; |
|---|
| 1018 |
|
|---|
| 1019 |
//Only hook queues page |
|---|
| 1020 |
if(($target_menuid == "queues") && ($action != "delete")) { |
|---|
| 1021 |
|
|---|
| 1022 |
//Query queue info |
|---|
| 1023 |
if(($viewing_itemid != null) && ($iSymphonyQueue = isymphony_queue_get($viewing_itemid))) { |
|---|
| 1024 |
$checked = ($iSymphonyQueue["add_queue"] == "1") ? "checked" : ""; |
|---|
| 1025 |
} else { |
|---|
| 1026 |
$checked = "checked"; |
|---|
| 1027 |
} |
|---|
| 1028 |
|
|---|
| 1029 |
//Build display |
|---|
| 1030 |
$display = " <tr><td colspan=\"2\"><h5>iSymphony<hr></h5></td></tr> |
|---|
| 1031 |
<tr> |
|---|
| 1032 |
<td><a href=\"#\" class=\"info\">" . _("Add to iSymphony") . "<span>" . _("Makes this queue available in iSymphony") . "</span></a></td> |
|---|
| 1033 |
<td><input type=\"checkbox\" name=\"isymphony_add_queue\" id=\"isymphony_add_queue\" value=\"on\" $checked/></td> |
|---|
| 1034 |
</tr>"; |
|---|
| 1035 |
} |
|---|
| 1036 |
|
|---|
| 1037 |
return $display; |
|---|
| 1038 |
} |
|---|
| 1039 |
|
|---|
| 1040 |
function isymphony_hookProcess_queues($viewing_itemid, $request) { |
|---|
| 1041 |
|
|---|
| 1042 |
//Query page state |
|---|
| 1043 |
$queue = isset($request["extdisplay"]) ? $request["extdisplay"] : null; |
|---|
| 1044 |
$account = isset($request["account"]) ? $request["account"] : null; |
|---|
| 1045 |
$action = isset($request["action"]) ? $request["action"] : null; |
|---|
| 1046 |
$name = isset($request["name"]) ? $request["name"] : null; |
|---|
| 1047 |
$queue = ($queue == null) ? $account : $queue; |
|---|
| 1048 |
|
|---|
| 1049 |
//Query iSymphony option |
|---|
| 1050 |
$addQueue = isset($request["isymphony_add_queue"]); |
|---|
| 1051 |
|
|---|
| 1052 |
//Update DB |
|---|
| 1053 |
if(($queue != null) && ($queue != "") && ($action != null)) { |
|---|
| 1054 |
|
|---|
| 1055 |
//Check if this queue needs to be deleted, updated, or added |
|---|
| 1056 |
if($action == "delete") { |
|---|
| 1057 |
isymphony_queue_del($queue); |
|---|
| 1058 |
} else if(($action == "add") || ($action == "edit") && ($name !== null)) { |
|---|
| 1059 |
if(isymphony_queue_get($queue) === null) { |
|---|
| 1060 |
isymphony_queue_add($queue, $addQueue, $name); |
|---|
| 1061 |
} else { |
|---|
| 1062 |
isymphony_queue_update($queue, $addQueue, $name); |
|---|
| 1063 |
} |
|---|
| 1064 |
} |
|---|
| 1065 |
} |
|---|
| 1066 |
} |
|---|
| 1067 |
|
|---|
| 1068 |
//Conference Room page hooks------------------------------------------------------------------------------------------------------------------------- |
|---|
| 1069 |
function isymphony_hook_conferences($viewing_itemid, $target_menuid) { |
|---|
| 1070 |
|
|---|
| 1071 |
//Query page state |
|---|
| 1072 |
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : null; |
|---|
| 1073 |
$display = ""; |
|---|
| 1074 |
|
|---|
| 1075 |
//Only hook conferences page |
|---|
| 1076 |
if(($target_menuid == "conferences") && ($action != "delete")) { |
|---|
| 1077 |
|
|---|
| 1078 |
//Query conference info |
|---|
| 1079 |
if(($viewing_itemid != null) && ($iSymphonyConferenceRoom = isymphony_conference_room_get($viewing_itemid))) { |
|---|
| 1080 |
$checked = ($iSymphonyConferenceRoom["add_conference_room"] == "1") ? "checked" : ""; |
|---|
| 1081 |
} else { |
|---|
| 1082 |
$checked = "checked"; |
|---|
| 1083 |
} |
|---|
| 1084 |
|
|---|
| 1085 |
//Build display |
|---|
| 1086 |
$display = " <tr><td colspan=\"2\"><h5>iSymphony<hr></h5></td></tr> |
|---|
| 1087 |
<tr> |
|---|
| 1088 |
<td><a href=\"#\" class=\"info\">" . _("Add to iSymphony") . "<span>" . _("Makes this conference room available in iSymphony") . "</span></a></td> |
|---|
| 1089 |
<td><input type=\"checkbox\" name=\"isymphony_add_conference_room\" id=\"isymphony_add_conference_room\" value=\"on\" $checked/></td> |
|---|
| 1090 |
</tr>"; |
|---|
| 1091 |
} |
|---|
| 1092 |
|
|---|
| 1093 |
return $display; |
|---|
| 1094 |
} |
|---|
| 1095 |
|
|---|
| 1096 |
function isymphony_hookProcess_conferences($viewing_itemid, $request) { |
|---|
| 1097 |
|
|---|
| 1098 |
//Query page state |
|---|
| 1099 |
$conferenceRoom = isset($request["extdisplay"]) ? $request["extdisplay"] : null; |
|---|
| 1100 |
$account = isset($request["account"]) ? $request["account"] : null; |
|---|
| 1101 |
$action = isset($request["action"]) ? $request["action"] : null; |
|---|
| 1102 |
$name = isset($request["name"]) ? $request["name"] : null; |
|---|
| 1103 |
$conferenceRoom = ($conferenceRoom == null) ? $account : $conferenceRoom; |
|---|
| 1104 |
|
|---|
| 1105 |
//Query iSymphony option |
|---|
| 1106 |
$addConferenceRoom = isset($request["isymphony_add_conference_room"]); |
|---|
| 1107 |
|
|---|
| 1108 |
//Update DB |
|---|
| 1109 |
if(($conferenceRoom != null) && ($conferenceRoom != "") && ($action != null)) { |
|---|
| 1110 |
|
|---|
| 1111 |
//Check if this conference room needs to be deleted, updated, or added |
|---|
| 1112 |
if($action == "delete") { |
|---|
| 1113 |
isymphony_conference_room_del($conferenceRoom); |
|---|
| 1114 |
} else if(($action == "add") || ($action == "edit") && ($name !== null)) { |
|---|
| 1115 |
if(isymphony_conference_room_get($conferenceRoom) === null) { |
|---|
| 1116 |
isymphony_conference_room_add($conferenceRoom, $addConferenceRoom, $name); |
|---|
| 1117 |
} else { |
|---|
| 1118 |
isymphony_conference_room_update($conferenceRoom, $addConferenceRoom, $name); |
|---|
| 1119 |
} |
|---|
| 1120 |
} |
|---|
| 1121 |
} |
|---|
| 1122 |
} |
|---|
| 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 |
|
|---|
| 1221 |
//Helper functions----------------------------------------------------------------------------------------------------------------------------------- |
|---|
| 1222 |
function isymphony_write_to_file($file, $content) { |
|---|
| 1223 |
if($file) { |
|---|
| 1224 |
fwrite($file,$content); |
|---|
| 1225 |
} |
|---|
| 1226 |
} |
|---|
| 1227 |
|
|---|
| 1228 |
function isymphony_remove_array_item($array, $item) { |
|---|
| 1229 |
return explode(',',str_replace($item.',','',(join(',',$array)))); |
|---|
| 1230 |
} |
|---|
| 1231 |
?> |
|---|