From 049580fd3012e7ca61dd6f0499d7baa636926e86 Mon Sep 17 00:00:00 2001 From: koldoa Date: Tue, 1 Sep 2015 18:33:26 +0200 Subject: [PATCH 001/174] Random strategy for ring groups --- app/ring_groups/app_languages.php | 11 ++++++++ app/ring_groups/ring_group_edit.php | 1 + .../install/scripts/app/ring_groups/index.lua | 27 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/ring_groups/app_languages.php b/app/ring_groups/app_languages.php index 41e87e22f2..4ce8421826 100644 --- a/app/ring_groups/app_languages.php +++ b/app/ring_groups/app_languages.php @@ -88,6 +88,17 @@ $text['option-rollover']['uk'] = ""; $text['option-rollover']['de-at'] = "Überrollen"; $text['option-rollover']['he'] = ""; +$text['option-random']['en-us'] = "Random"; +$text['option-random']['es-cl'] = "Aleatorio"; +$text['option-random']['pt-pt'] = ""; +$text['option-random']['fr-fr'] = ""; +$text['option-random']['pt-br'] = ""; +$text['option-random']['pl'] = ""; +$text['option-random']['sv-se'] = ""; +$text['option-random']['uk'] = ""; +$text['option-random']['de-at'] = ""; +$text['option-random']['he'] = ""; + $text['option-ptring']['en-us'] = "pt-ring"; $text['option-ptring']['es-cl'] = "pt-ring"; $text['option-ptring']['fr-fr'] = "Portugal"; diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 9d7083e70e..929f7086d6 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -499,6 +499,7 @@ else { echo " \n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo "
\n"; echo $text['description-strategy']."\n"; diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 336f5ace28..b122bc371a 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -160,6 +160,28 @@ --forward the ring group session:execute("transfer", ring_group_forward_destination.." XML "..context); else + --get the strategy of the ring group, if random, we use random() to order the destinations + sql = [[ + SELECT + r.ring_group_strategy + FROM + v_ring_groups as r, v_ring_group_destinations as d + WHERE + d.ring_group_uuid = r.ring_group_uuid + AND d.ring_group_uuid = ']]..ring_group_uuid..[[' + AND r.domain_uuid = ']]..domain_uuid..[[' + AND r.ring_group_enabled = 'true' + ]]; + + --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + assert(dbh:query(sql, function(row) + if (row.ring_group_strategy == "random") then + sql_order = 'random()' + else + sql_order='d.destination_delay, d.destination_number asc' + end + end)); + --get the ring group destinations sql = [[ SELECT @@ -174,7 +196,7 @@ AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ORDER BY - d.destination_delay, d.destination_number asc + ]]..sql_order..[[ ]]; --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); destinations = {}; @@ -293,6 +315,9 @@ if (ring_group_strategy == "sequence") then delimiter = "|"; end + if (ring_group_strategy == "random") then + delimiter = "|"; + end if (ring_group_strategy == "simultaneous") then delimiter = ","; end From 28e967f01c2d9879b0f87b05569d74dfcca89c8f Mon Sep 17 00:00:00 2001 From: koldoa Date: Wed, 2 Sep 2015 14:24:47 +0200 Subject: [PATCH 002/174] Translation typo --- app/devices/app_languages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index 75ecf92aa3..577792fd96 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -1690,7 +1690,7 @@ $text['label-blf']['ar-eg'] = ""; $text['label-blf']['he'] = ""; $text['label-callers']['en-us'] = "Callers"; -$text['label-callers']['es-cl'] = "Llaamadas"; +$text['label-callers']['es-cl'] = "Llamadas"; $text['label-callers']['pt-pt'] = ""; $text['label-callers']['fr-fr'] = ""; $text['label-callers']['pt-br'] = ""; From b2cbcdfc97c01723f717a0d4892dfb34370bbaa7 Mon Sep 17 00:00:00 2001 From: koldoa Date: Thu, 3 Sep 2015 11:53:28 +0200 Subject: [PATCH 003/174] Detection of SQL backend for random functions --- .../install/scripts/app/ring_groups/index.lua | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index b122bc371a..dee8542206 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -160,6 +160,16 @@ --forward the ring group session:execute("transfer", ring_group_forward_destination.." XML "..context); else + --first we check what version of SQL are we using + sql = "SELECT version() as version"; + assert(dbh:query(sql, function(row) + if (string.find(row.version, "PostgreSQL")) then + sql_verion = 'postgresql' + else + sql_verion = 'mysql' + end + end)); + --get the strategy of the ring group, if random, we use random() to order the destinations sql = [[ SELECT @@ -172,16 +182,21 @@ AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ]]; - - --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + + assert(dbh:query(sql, function(row) if (row.ring_group_strategy == "random") then - sql_order = 'random()' + if (sql_verion == "postgresql") then + sql_order = 'random()' + end + if (sql_verion == "mysql") then + sql_order = 'rand()' + end else sql_order='d.destination_delay, d.destination_number asc' end end)); - + --get the ring group destinations sql = [[ SELECT @@ -196,7 +211,7 @@ AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ORDER BY - ]]..sql_order..[[ + ]]..sql_order..[[ ]]; --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); destinations = {}; From bbcda4e9bfdf1c3b98bf2460d4e66e324bce8866 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Fri, 4 Sep 2015 09:44:51 -0700 Subject: [PATCH 004/174] y000000000037.cfg --- .../provision/yealink/cp860/y000000000037.cfg | 1533 +++++++++++++++++ 1 file changed, 1533 insertions(+) create mode 100644 resources/templates/provision/yealink/cp860/y000000000037.cfg diff --git a/resources/templates/provision/yealink/cp860/y000000000037.cfg b/resources/templates/provision/yealink/cp860/y000000000037.cfg new file mode 100644 index 0000000000..fb31296b2e --- /dev/null +++ b/resources/templates/provision/yealink/cp860/y000000000037.cfg @@ -0,0 +1,1533 @@ +#!version:1.0.0.1 + +##File header "#!version:1.0.0.1" can not be edited or deleted, and must be placed in the first line.## + +####################################################################################### +## Hostname ## +####################################################################################### +network.dhcp_host_name = + +####################################################################################### +## PPPOE ## +####################################################################################### +#Configure the username and password for PPPOE connection. +#Require reboot; +network.pppoe.user = +network.pppoe.password = + +####################################################################################### +## Network Advanced ## +####################################################################################### +#Configure the duplex mode and the speed of the WAN port. +#0-Auto negotiate (default), 1-Full duplex 10Mbps, 2-Full duplex 100Mbps, 3-Half duplex 10Mbps, 4-Half duplex 100Mbps; +network.internet_port.speed_duplex = +network.pc_port.speed_duplex = + +network.pc_port.dhcp_server = 1 +network.static_dns_enable = 1 + +####################################################################################### +## VLAN ## +####################################################################################### +network.vlan.internet_port_enable = 0 + +#Configure the VLAN ID, it ranges from 1 to 4094, the default value is 1. +#Require reboot; +network.vlan.internet_port_vid = + +#Configure the VLAN priority, it ranges from 0 (default) to 7. +#Require reboot; +network.vlan.internet_port_priority = + +#Enable or disable the VLAN of PC port; 0-Disabled (default), 1-Enabled; +#Require reboot; +network.vlan.pc_port_enable = + +#Configure the VLAN ID, it ranges from 1 to 4094, the default value is 1. +#Require reboot; +network.vlan.pc_port_vid = + +#Configure the VLAN priority, it ranges from 0 (default) to 7. +#Require reboot; +network.vlan.pc_port_priority = + +#Enable or disable the DHCP to obtain the information of the VLAN; 0-Disabled; 1-Enabled (default); +#Require reboot; +network.vlan.dhcp_enable = + +#Configure the DHCP option to obtain the information of the VLAN. It ranges from 0 to 255. +#Multiple options separated by a comma. It supports up to 5 options in all. +#Require reboot; +network.vlan.dhcp_option = + +####################################################################################### +## WEB Port ## +####################################################################################### +#Configure the HTTP port (80 by default) and the HTTPS port (443 by default) of the web server. Both range from 1 to 65535. +#Require reboot; +network.port.http = +network.port.https = + +####################################################################################### +## QOS ## +####################################################################################### +#Configure the voice QOS. It ranges from 0 to 63, the default value is 46. +#Require reboot; +network.qos.rtptos = + +#Configure the SIP QOS. It ranges from 0 to 63, the default value is 26. +#Require reboot; +network.qos.signaltos = + +####################################################################################### +## 802.1X ## +####################################################################################### +#Configure the 802.1x mode; 0-Disabled (default), 1-EAP-MD5, 2-EAP-TLS, 3-PEAP-MSCHAPV2, 4:EAP-TTLS/EAP-MSCHAPv2; +#Require reboot; +network.802_1x.mode = +network.802_1x.identity = +network.802_1x.md5_password = +network.802_1x.root_cert_url = +network.802_1x.client_cert_url = + +####################################################################################### +## VPN ## +####################################################################################### +#Enable or disable the VPN feature; 0-Disabled (default), 1-Enabled; +#Require reboot; +network.vpn_enable = + +####################################################################################### +## LLDP ## +####################################################################################### +#Enable or disable the LLDP feature; 0-Disabled, 1-Enabled (default); +#Require reboot; +network.lldp.enable = + +#Configure the interval(in seconds) the phone broadcasts the LLDP request. It ranges from 1 to 3600, the default value is 60. +#Require reboot; +network.lldp.packet_interval = + +####################################################################################### +## SNMP ## +####################################################################################### +#Enable or disable the SNMP feature; 0-Disabled (default), 1-Enabled; +#Require reboot; +network.snmp.enable = +network.snmp.port = + +#Configure the IP address(es) of the trusted SNMP server,multiple IP addresses must be separated by a space. +#Require reboot; +network.snmp.trust_ip = + +####################################################################################### +## Span to PC ## +####################################################################################### +#Enable or disable the span from WAN port to PC port feature; 0-Disabled (default), 1-Enabled; +#Require reboot; +network.span_to_pc_port = + +####################################################################################### +## RTP Port ## +####################################################################################### +#Configure the maximum local RTP port. It ranges from 0 to 65535, the default value is 11800. +#Require reboot; +network.port.max_rtpport = + +#Configure the minimum local RTP port. It ranges from 0 to 65535, the default value is 11780. +#Require reboot; +network.port.min_rtpport = + +####################################################################################### +## SYSLOG ## +####################################################################################### +#Configure the IP address of the syslog server. +#Require reboot; +syslog.server = + +#Configure the syslog level. It ranges from 0 to 6, the default value is 3. +#Require reboot; +syslog.log_level = + +####################################################################################### +## Redirect ## +####################################################################################### +#Enable or disable the redirect feature; 0-Disabled (default), 1-Enabled; +redirect.enable = + +####################################################################################### +## TR069 ## +####################################################################################### +#The TR069 feature is only applicable to some designated firmware version. +#All settings of TR069 require reboot. +#Enable or disable the TR069 feature; 0-Disabled (default), 1-Enabled; +managementserver.enable = +managementserver.username = +managementserver.password = +managementserver.url = +managementserver.connection_request_username = +managementserver.connection_request_password = +managementserver.periodic_inform_enable = 0 +managementserver.periodic_inform_interval = 60 + +####################################################################################### +## Autop Mode ## +####################################################################################### +#Configure the auto provision mode; +#0-Disabled , 1-Power on (default); +auto_provision.mode = + +####################################################################################### +## Autop PNP ## +####################################################################################### +#Enable or disable the Plug and Play feature; 0-Disabled, 1-Enabled (default); +auto_provision.pnp_enable = + +####################################################################################### +## Autop DHCP ## +####################################################################################### +#Enable or disable DHCP option mode; 0-Disabled, 1-Enabled (default); +auto_provision.dhcp_option.enable = + +#Configure the custom DHCP option number. It ranges from 128 to 254. +auto_provision.dhcp_option.list_user_options = + +####################################################################################### +## Autop Repeat ## +####################################################################################### +auto_provision.repeat.enable = 0 + +#Configure the interval (in minutes) for the phone to check new configuration files. It ranges from 1 to 43200, the default value is 1440. +#It is only applicable to "Repeatedly". +auto_provision.repeat.minutes = + +####################################################################################### +## Autop Weekly ## +####################################################################################### +auto_provision.weekly.enable = 0 + +#Configure the day of week for the phone to check new configuration files. The default vaule is 0123456. +#0-Sunday,1-Monday,2-Tuesday,3-Wednesday,4-Thursday,5-Friday,6-Saturday; +#It is only applicable to "Weekly" and "Power on + Weekly" modes. +#If the desired week is Monday, Tuesday and Wednesday, the value format is 012. +auto_provision.weekly.mask = + +#Configure the start time of the day for the phone to check new configuration files. The default value is 00:00. +#It is only applicable to "Weekly" and "Power on + Weekly" modes. +#If the desired start time of the day is seven forty-five a.m., the value format is 07:45. +auto_provision.weekly.begin_time = + +#Configure the end time of the day for the phone to check new configuration files. The default time is 00:00. +#It is only applicable to "Weekly" and "Power on + Weekly" modes. +#If the desired end time of the day is seven forty-five p.m., the value format is 19:45. +auto_provision.weekly.end_time = + +####################################################################################### +## Autop URL ## +####################################################################################### +auto_provision.server.url = {$yealink_provision_url} +auto_provision.server.username = +auto_provision.server.password = + +####################################################################################### +## Autop Aes Key ## +####################################################################################### +#Configure AES key (16 characters) for decrypting the common CFG file. +auto_provision.aes_key_16.com = + +#Configure AES key (16 characters) for decrypting the MAC-Oriented CFG file. +auto_provision.aes_key_16.mac = + +custom_mac_cfg.url = + +#Configure the value (manufacturer of the device) of DHCP option 60. The default is yealink +auto_provision.dhcp_option.option60_value = + +####################################################################################### +## Autop Code ## +####################################################################################### +#This feature allows user to trigger the auto provisioning by pressing a predefined string on the phone. +#Require reboot; +#"X" ranges from 1 to 50 + +#Configure the auto provisioning name. +#The valid value is a string, the maximum length is 100. +autoprovision.X.name = + + +#Configure the auto provisioning code; +#The valid value is a string, the maximum length is 100. +autoprovision.X.code = + +#Configure the URL of the auto provisioning server. +#The valid value is a string, the maximum length is 511. +autoprovision.X.url = + +#Configure the username and password for downloading. +#The valid value is a string, the maximum length is 100. +autoprovision.X.user = +autoprovision.X.password = + +#Configure AES key (16 characters) for decrypting the common CFG file and MAC-Oriented CFG file. +autoprovision.X.com_aes = +autoprovision.X.mac_aes = + +####################################################################################### +## Watch Dog ## +####################################################################################### +#Enable or disable the WatchDog feature; 0-Disabled, 1-Enabled (default); +watch_dog.enable = + +####################################################################################### +## SIP Advanced ## +####################################################################################### +#Enable or disable the phone to escape the pound key as percent sign followed by 23 when dialing out; 0-Disabled, 1-Enabled (default); +sip.use_23_as_pound = + +#Enable or disable the RFC2543 Hold feature; 0-Disabled (default), 1-Enabled; +sip.rfc2543_hold = + +#Enable or disable the phone to keep sending the SIP messages to the outbound server; 0-Disabled, 1-Enabled (default); +sip.use_out_bound_in_dialog = + +#Configure the registration random time (in seconds). It ranges from 0 (default) to 60. +sip.reg_surge_prevention = + +####################################################################################### +## Echo Cancellation ## +####################################################################################### +#Enable or disable the voice activity detection feature; 0-Disbaled (default), 1-Enabled; +voice.vad = + +#Enable or disable the comfortable noise generator; 0-Disabled, 1-Enabled (default); +voice.cng = + +#Enable or disable the echo canceller; 0-Disabled, 1-Enabled (default); +voice.echo_cancellation = + +#Configure the volume of the side tone. It ranges from -48 to 0, the default value is -3. +voice.side_tone= + +#configure the preview call mode; 1-Ignore:the mixed of tone and RTP (default), 2-Force: discard the RTP and play the tone, 3-Skip: skip the tone to play the RTP; +voice.call_preview_mode= + +####################################################################################### +## Jitter Buffer ## +####################################################################################### +#Configure the type of jitter buffer; 0-Fixed, 1-Adaptive (default); +voice.jib.adaptive = + +#Configure the minimum delay, maximum delay and normal delay. The default values are 0, 300, 120. +voice.jib.min = +voice.jib.max = +voice.jib.normal = + +####################################################################################### +## Tones ## +####################################################################################### +#Define the voice tone, the valid values can be Custom (default) or voice tone of different countries. For example, United States, France, Germany and so on. +#voice.tone.country = Custom +voice.tone.country = +voice.tone.dial = +voice.tone.ring = +voice.tone.busy = +voice.tone.congestion = +voice.tone.callwaiting = +voice.tone.dialrecall = +voice.tone.record= +voice.tone.info = +voice.tone.stutter = +voice.tone.message = +voice.tone.autoanswer = + +####################################################################################### +## Volume ## +####################################################################################### +#Configure the receiving volume of Speaker, Handset and Headset. It ranges from 0 to 15, the default value is 8. +voice.handfree.spk_vol = +voice.handfree.tone_vol = +voice.handset.spk_vol = +voice.handset.tone_vol = +voice.headset.spk_vol = +voice.headset.tone_vol = +voice.ring_vol= + +####################################################################################### +## WEB HTTP(S) ## +####################################################################################### +wui.https_enable = +wui.http_enable = + +####################################################################################### +## Transfer ## +####################################################################################### +#Enable or disable the transferee to display the missed call prompt when receiving a semi_attended transfer call; +#0-Disabled, 1-Enabled (default); +transfer.semi_attend_tran_enable = + +#Enable or disable the phone to complete the blind or attended transfer through on-hook; +#0-Disabled,1-Enabled(default); +transfer.blind_tran_on_hook_enable = + +#Enable or disable the conference initiator to transfer the call when hanging up. +#0-Disabled(default),1-Enabled; +transfer.tran_others_after_conf_enable = + +#Enable or disable the phone to complete the blind or attended transfer through on-hook; +#0-Disabled,1-Enabled(default); +transfer.on_hook_trans_enable = + +#Define the way of DSS key when configuring as a transfer key; 0-Display Number, 1-Attended Transfer, 2-Blind Transfer (default); +transfer.dsskey_deal_type = + +####################################################################################### +## Web Language ## +####################################################################################### +#Specify the web language, the valid values are: English, Chinese_S, Turkish, Portuguese, Spanish, Italian, French, Russian, Deutsch and Czech. +lang.wui = + +#Specify the LCD language, the valid values are: English (default), Chinese_S, Chinese_T, German, French, Turkish, Italian, Polish, Spanish and Portuguese. +lang.gui = English + +####################################################################################### +## Time ## +####################################################################################### +#Configure the domain name or the IP address of the NTP server. The default value is cn.pool.ntp.org. +local_time.ntp_server1 = cn.pool.ntp.org +local_time.ntp_server2 = cn.pool.ntp.org + +#Configure the update interval (in seconds) when using the NTP server. The default value is 1000. +local_time.interval = + +#Configure the daylight saving time feature; 0-Disabled, 1-Enabled, 2-Automatic (default); +local_time.summer_time = + +#Configure the DST type when the DST feature is enabled; 0-By Date (default), 1-By Week; +local_time.dst_time_type = + +#Configure the start time of DST. The default value is 1/1/0. +#If the DST type is configured as By Date, the value format is Month/Day/Hour. For example, the value 5/20/10 means the start time is at 10:00 on May 20. +#If the DST type is configured as By Week, the value format is Month/Day of Week/Day of Week Last in Month/Hour of Day. +#For example, the value 1/4/2/5 means the start time is at 5 o'clock on Tuesday of the 4th week in January. +local_time.start_time = + +#Configure the end time of DST. The default value is 12/31/23. The value format is the same to the start time. +local_time.end_time = + +#Configure the offset time (in seconds). It ranges from -300 to 300, the default value is 60. +local_time.offset_time = + +#Configure the time format; 0-12 Hour, 1-24 Hour (default); +local_time.time_format = + +#Configure the date format; 0-WWW MMM DD (default), 1-DD-MMM-YY, 2-YYYY-MM-DD, 3-DD/MM/YYYY, 4-MM/DD/YY, 5-DD MMM YYYY, 6-WWW DD MMM; +local_time.date_format = + +#Enable or disable the DHCP Time; 0-Disabled (default), 1-Enabled; +local_time.dhcp_time = + +local_time.manual_time_enable = 0 + +####################################################################################### +## Auto Redial ## +####################################################################################### +#Enable or disable the auto redial feature; 0-Disabled (default), 1-Enabled; +auto_redial.enable = + +#Configure the interval (in seconds) to wait before redial. It ranges from 1 to 300. The default value is 10. +auto_redial.interval = + +#Configure the auto redial times. It ranges from 1 to 300. The default value is 10. +auto_redial.times = + +####################################################################################### +## Zero Touch ## +####################################################################################### +#Enable or disable the Zero Touch feature; 0-Disabled (default), 1-Enabled; +zero_touch.enable = + +#Configure the waiting time (in seconds) before canceling the Zero Touch. It ranges from 0 to 100, the default value is 5. +zero_touch.wait_time = + +####################################################################################### +## Push XML ## +####################################################################################### +push_xml.server = + +#Enable or disable the phone to display the push XML interface when receiving an incoming call; 0-Disabled (default), 1-Enabled; +push_xml.block_in_calling= + +#Enable or disable the phone to use the push XML via SIP Notify message; 0-Disabled (default), 1-Enabled; +push_xml.sip_notify= + +####################################################################################### +## Dial Plan ## +####################################################################################### +dialplan.area_code.code = +dialplan.area_code.min_len = 1 +dialplan.area_code.max_len = 15 + +#When applying the rule to multiple lines, each line ID separated by a comma. +#e.g. dialplan.area_code.line_id = 1,2,3 +dialplan.area_code.line_id = + +#Configure the block out number. X ranges from 1 to 10. +#dialplan.block_out.number.x = +dialplan.block_out.number.1 = + +#When applying the rule to multiple lines, mutiple lines must be separated by a comma. E.g. 1,2,3. +#dialplan.block_out.line_id.X = 1,2,3 +dialplan.block_out.line_id.1 = + +# X ranges from 1 to 100. +dialplan.dialnow.rule.X = +dialplan.dialnow.line_id.X = + +# X ranges from 1 to 100. +dialplan.replace.prefix.X = +dialplan.replace.replace.X = +dialplan.replace.line_id.X = + +#Configure the dialnow rule. X ranges from 1 to 20. +#dialnow.item.X = Dial-now rule,Line ID +#Dial-now rule: Specify the numbers that need replacing; +#Line ID:Specify the line ID to apply the replace rule,multiple lines must be separated by a comma; +dialnow.item.1 = + +#Configure the replace rule. X ranges from 1 to 20. +#dialplan.item.X = Enabled,Prefix,Replaced,LineID +#Enabled: Enable or disable the replace rule. 0-Disabled, 1-Enabled; Prefix: Specify the numbers that need replacing; +#Replaced: Specify the alternate numbers; +#LineID: Specify the line ID to apply the replace rule,multiple lines ID must be separated by a comma; +dialplan.item.1 = + +####################################################################################### +## Remote Phonebook ## +####################################################################################### +#Configure the access URL and dispaly name of the remote phonebook. X ranges from 1 to 5. +#remote_phonebook.data.X.url = +#remote_phonebook.data.X.name = + +remote_phonebook.data.1.url = +remote_phonebook.data.1.name = + +####################################################################################### +## Network Directory ## +####################################################################################### +directory.update_time_interval = +directory.incoming_call_match_enable = 1 +bw.directory_enable = 0 + +####################################################################################### +## LDAP ## +####################################################################################### +#Configure the search criteria for name and number lookups. +ldap.enable = {$ldap_enable} +ldap.name_filter = {$ldap_namefilter} +ldap.number_filter = {$ldap_numberfilter} +ldap.host = {$ldap_host} +ldap.port = {$ldap_port} +ldap.base = {$ldap_base} +ldap.user = {$ldap_user} +ldap.password = {$ldap_password} + +#Specify the maximum of the displayed search results. It ranges from 1 to 32000, the default value is 50. +ldap.max_hits = {$ldap_max_hits} +ldap.name_attr = {$ldap_name_attr} +ldap.numb_attr = {$ldap_numb_attr} +ldap.display_name = {$ldap_display_name} + +#Configure the LDAP version. The valid value is 2 or 3 (default). +ldap.version = {$ldap_version} + +#Enable or disable the phone to query the contact name from the LDAP server when receiving an incoming call; 0-Disabled (default), 1-Enabled; +ldap.call_in_lookup = {$ldap_call_in_lookup} + +#Enable or disable the phone to sort the search results in alphabetical order; 0-Disabled (default), 1-Enabled; +ldap.ldap_sort = {$ldap_sort} + +####################################################################################### +## Features ## +####################################################################################### +#Configure the return code when activating DND; 404-No Found, 480-Temporarily not available (default), 486-Busy here; +#features.dnd_refuse_code = 480 +features.dnd_refuse_code = + +#Configure the return code when refusing a call. The valid values are 404, 480, 486 (default). +features.normal_refuse_code = + +#Configure the delay time (in seconds)of auto answer. The time ranges from 1 to 4, the default value is 1. +features.auto_answer_delay = + +#Enable or disable the transfer DSS key to perform the blind transfer; 0-Disabled, 1-Enabled (default); +features.dsskey_blind_tran = + +#Enable or disable the phone to mute the call during an active call; 0-Disabled, 1-Enabled (default); +features.allow_mute = + +features.group_listen_in_talking_enable = + +#Enable or disable the call completion feature; 0-Disabled (default), 1-Enabled; +features.call_completion_enable = + +#Enable or disable the phone to dial the IP address directly; 0-Disabled, 1-Enabled (default); +features.direct_ip_call_enable = + +#Configure the power Indicator LED to turn on or turn off; 0-On (default), 1-Off; +features.power_led_on = 1 + +#Configure the overtime (in minutes) of logging web user interface. It ranges from 1 to 1000, the default value is 5. +features.relog_offtime = + +#Specify the ring device when the phone is in the Headset mode; 0-use Speaker (default), 1-use Headset, 2- Use Headset& Speaker; +features.ringer_device.is_use_headset = + +#Enable or disable to enter the password when long pressing the OK key to reset to factory; 0-Disabled (default), 1-Enabled; +#features.factory_pwd_enable = 1 + +features.idle_talk_power_led_flash_enable = + +#Enbale or disable the server to release the BLA line automatically; 0-Disabled (default), 1-Enabled; +features.auto_release_bla_line = + + +####################################################################################### +## Features FWD ## +####################################################################################### +#Configure the call forward key mode; 0-Phone mode (default), 1-Custom mode. +features.fwd_mode = + +#0-Disabled , 1-Enabled (default) +features.fwd_diversion_enable = + +####################################################################################### +## Features DND ## +####################################################################################### +#Configure the DND key mode; 0-Phone mode (default), 1-Custom mode. +features.dnd_mode = +features.dnd.on_code = +features.dnd.off_code = +features.dnd.emergency_enable = 1 +features.dnd.emergency_authorized_number = + +####################################################################################### +## Features BLF ## +####################################################################################### +#Configure the LED flashing mode of the BLF key (line key). The value is 0(default) or 1. +features.blf_led_mode = + +features.blf_list_version = 0 +features.blf_and_callpark_idle_led_enable = 0 + +####################################################################################### +## Features Intercom ## +####################################################################################### +#Enable or disable the intercom feature; 0-Disabled, 1-Enabled (default); +features.intercom.allow = + +#Enable or disable the phone to mute the Speaker when answering an intercom call; 0-Disabled (default), 1-Enabled; +features.intercom.mute = + +#Enable or disable the phone to play the intercom warning tone; 0-Disabled, 1-Enabled (default); +features.intercom.tone = + +#Enable or disable the phone to barge in an intercom call; 0-Disabled (default), 1-Enabled; +features.intercom.barge = + +####################################################################################### +## Features Hotline ## +####################################################################################### +#Configure the hotline number and delay time (in seconds). It ranges from 0 to 180, the default value is 4. +features.hotline_number = +features.hotline_delay = + +####################################################################################### +## Features DTMF ## +####################################################################################### +#Enable or disable the phone to suppress the display of DTMF digits; 0-Disabled (default), 1-Enabled; +features.dtmf.hide = + +#Enables or disables the IP phone to display the DTMF digits for a short period before displaying as asterisks; 0-Disabled (default), 1-Enabled; +features.dtmf.hide_delay = + +#Configure the repetition times of DTMF end packet. The valid values are 1, 2, 3 (default). +features.dtmf.repetition = + +#Configure DTMF sequences. It can be consisted of digits, alphabets, * and #. +features.dtmf.transfer = + +#Enable or disable the phone to send DTMF sequences during a call when pressing the transfer soft key or the TRAN key; 0-Disabled (default), 1-Enabled; +features.dtmf.replace_tran = + +####################################################################################### +## Features Audio Settings ## +####################################################################################### +#Enable or disable the headset prior feature; 0-Disabled (default), 1-Enabled; +features.headset_prior = + +#Enable or disable the dual headset feature; 0-Disabled (default), 1-Enabled; +features.headset_training = + +features.alert_info_tone = + +#Enable or disable the phone to play the warning tone when receiving a vocie mail. 0-Disabled; 1-Enabled(default). +features.voice_mail_tone_enable = + +#Configure the delay time (in seconds) of playing busy tone when rejecting a call. The valid values are 0 (default), 3 and 5. +features.busy_tone_delay = + +#Configure the phone whether to send a pound key when pressing double pound keys; 0-Send one pound key (default), 1-Do not send any pound key; +features.send_pound_key = + +#Define the "#" or "*" key as the send key; 0-Disabled, 1-# key(default), 2-* key; +features.pound_key.mode = + +#Enable or disable the phone to play tone when pressing the digit key; 0-Disabled, 1-Enabled (default); +features.send_key_tone = +features.key_tone = + +#Enable or disable the phone to play a warning tone when there is a held call; 0-Disabled, 1-Enabled (default); +features.play_hold_tone.enable = + +#Configure the interval of playing a warning tone. The default value is 30s. +features.play_hold_tone.delay = + +features.redial_tone = + +#Enable or disable the phone with active accounts to play tones in the dialing interface differently from the phone with no active accounts; 0-Disabled (default), 1-Enbaled; +features.partition_tone = + +#Configure the delay time (in milliseconds) before transfering a call. The default value is 0. +features.hold_trans_delay = + +#Enbale or disable the phone to play a local DTMF tone; 0-Disabled, 1-Enabled (default); +features.play_local_dtmf_tone_enable= + +####################################################################################### +## Features Remote Phonebook ## +####################################################################################### +#Enables or disables the IP phone to query the contact names from the remote phonebook when receiving incoming calls; 0-Disabled (default), 1-Enabled; +features.remote_phonebook.enable = + +#Set the interval (in seconds) for the phone to update the information of the remote phonebook. The default value is 3600. +features.remote_phonebook.flash_time = + +####################################################################################### +## Features Action ## +####################################################################################### +#Specific the address(es) or enters 'any' from which Action URI will be accepted. +#For discontinuous IP addresses, each IP address is separated by comma, for example: 192.168.1.20,10.2.1.30 +#For continuous IP addresses, the format likes *.*.*.* and the '*' stands for the values 0~255. For example: 10.10.*.* stands for the IP addresses that range from 10.10.0.0~10.10.255.255. +#If left blank, the IP phone cannot receive or handle any HTTP GET request. +#If set to 'any', the IP phone accepts and handles HTTP GET requests from any IP address. +features.action_uri_limit_ip = + +features.action_uri_reboot_now = 0 + +####################################################################################### +## Features Prefix ## +####################################################################################### +#Enable or disable the phone to encrypt the digits of the dialed number. The encrypted digits are displayed as asterisks on the LCD screen; 0-Disabled (default), 1-Enabled; +features.password_dial.enable = + +#Configure the prefix numbers displayed before the encrypted digits. +features.password_dial.prefix = + +#Configure the length of encrypted digits. +features.password_dial.length = + +####################################################################################### +## Features History ## +####################################################################################### +#Enable or disable the phone to save the call history; 0-Disabled, 1-Enabled (default); +features.save_call_history = + +####################################################################################### +## Features Pickup ## +####################################################################################### +#Enable or disable the phone to pick up the call using the group pickup soft key; 0-Disabled (default), 1-Enabled; +features.pickup.group_pickup_enable = + +features.pickup.group_pickup_code = + +#Enable or disable the phone to pick up the call using the directed pickup soft key; 0-Disabled (default), 1-Enabled; +features.pickup.direct_pickup_enable = + +features.pickup.direct_pickup_code = + +#Specify the way to notify the phone of the incoming call of the monitored user by visual or audio indicator; +#0-Disabled (default), 1-Enabled; +features.pickup.blf_visual_enable = +features.pickup.blf_audio_enable = + +####################################################################################### +## Phone Setting ## +####################################################################################### +#Configure the time (in seconds) the phone automatically dials out the dialed digits. It ranges from 1 to 14, the default value is 4. +phone_setting.inter_digit_time = + +#Configure the ring tone when the transfer fails. The valid values are: Ring1.wav.... Ring8.wav. +#If you set the custom ring tone (Busy.wav) for the phone, the value is: phone_setting.ring_type = Config:Busy.wav +#If you set the system ring tone (Ring2.wav) for the phone, the value is: phone_setting.ring_type = Resource:Ring2.wav +#phone_setting.ring_type = Resource:Ring1.wav +phone_setting.ring_type = +phone_setting.ring_for_tranfailed = + +#Enable or disable the phone to deal the 180 SIP message after the 183 SIP message; 0-Disabled, 1-Enabled (default); +phone_setting.is_deal180 = +phone_setting.show_code403 = + +#Configure the delay time (in seconds) for the dialnow rule. It ranges from 1 to 14, the default value is 1. +phone_setting.dialnow_delay = + +#Configure the emergency number, each separated by a comma. The default value is 112,911,110. +phone_setting.emergency.number = + +#Configure the using mode of the headset key. The value is 0 or 1(default). +phone_setting.page_tip = + +#Enable or disable the phone to show the logon wizard during startup; 0-Disabled (default), 1-Enabled; +phone_setting.logon_wizard = + +#Enable or disable the phone to automatically dial out the dialed digits in the pre-dial interface; 0-Disabled (default), 1-Enabled; +phone_setting.predial_autodial = 1 + +#Enable or disable customizing the softkey layout; 0-Disabled (default), 1-Enabled; +phone_setting.custom_softkey_enable = + +#Configure the using mode of the headset key. The value is 0 or 1(default). +phone_setting.headsetkey_mode = + +#Enable or disabled mail power led flash. 0-Disabled, 1-Enabled. +phone_setting.mail_power_led_flash_enable = 1 + +####################################################################################### +## Phone Setting UI ## +####################################################################################### +#Configure the active backlight level. It ranges from 1 to 3, the default value is 2. +#The same level for different phones may result in different backlight intensities. +phone_setting.active_backlight_level = +phone_setting.inactive_backlight_level = 1 + +####################################################################################### +## Phone Setting BLF ## +####################################################################################### +phone_setting.blf_list_enable = 1 +phone_setting.auto_blf_list_enable = 1 + +#Specify the prior of the line keys and EXP keys when automatically configure the blf list 0-Configure the line keys first, 1-Configure the EXP keys first; +phone_setting.blf_list_sequence_type = + +####################################################################################### +## Key Lock ## +####################################################################################### +#Configure the keypad lock type; 0-Disabled (default), 1-Enable +phone_setting.lock = + +#Configure the unlock password for the phone. The default value is 123. +phone_setting.phone_lock.unlock_pin = + + +#Configures the interval (in seconds) to automatically lock the IP phone. It ranges from 0 to 3600, the default value is 0. +phone_setting.phone_lock.lock_time_out = + +#Configure the keypad lock type;0-All Keys(default), 1-Function Key, 2-Menu Key +phone_setting.phone_lock.lock_key_type = + +#Configure the backlight time (in seconds). The valid values are: 0-Always on, 1-Always off, 15-15s, 30-30s (default), 60-60s, 120-120s. +phone_setting.backlight_time = 0 + +####################################################################################### +## Wallpaper ## +####################################################################################### +wallpaper_upload.url = {$yealink_cp860_wallpaper} + +####################################################################################### +## Multicast ## +####################################################################################### +#Configure the codec of multicast paging. +multicast.codec = + +#Enbale or diable the phone to handle the incoming multicast paging calls when there is a multicast paging call on the phone; 0-Disabled, 1-Enabled (default); +#If enabled, the phone will answer the incoming multicast paging call with a higher priority and ignore that with a lower priority. +multicast.receive_priority.enable = + +#Configure the priority of multicast paging calls. It ranges from 0 to 10. +multicast.receive_priority.priority = + +#Configure the lable displayed on the LCD screen when receiving the multicast paging. X ranges from 1 to 10. +multicast.listen_address.X.label = + +#Configure the listening multicast IP address and port number for the phone. X ranges from 1 to 10. +multicast.listen_address.X.ip_address = + +####################################################################################### +## Super Search ## +####################################################################################### +super_search.recent_call = 1 + +####################################################################################### +## Broadsoft Phonebook ## +####################################################################################### +bw_phonebook.group_enable = 1 +bw_phonebook.personal_enable = 1 +bw_phonebook.group_common_enable = 0 +bw_phonebook.group_common_displayname = +bw_phonebook.enterprise_enable = 0 +bw_phonebook.enterprise_common_enable = 0 +bw_phonebook.enterprise_common_displayname = +bw_phonebook.call_log_enable = 1 +bw_phonebook.server_search_enable = 1 +bw_phonebook.group_displayname = +bw_phonebook.enterprise_displayname = +bw_phonebook.common_displayname = +bw_phonebook.personal_displayname = + +####################################################################################### +## Broadsoft ## +####################################################################################### +#Enable or disable the phone to access the BSFT call log/phonebook directly when pressing the History/Directory soft keys; +#0-Disabled (default), 1-Enabled; +#Require reboot; +bw.calllog_and_dir = + +#Enable or disable the feature key synchronization; 0-Disabled (default), 1-Enabled; +bw.feature_key_sync = 0 + +####################################################################################### +## Security ## +####################################################################################### +#Enable or disable the phone to only accept the certificates in the Trusted Certificates list; +#0-Disabled, 1-Enabled (default); +security.trust_certificates = + +#Define the login username and password of the user, var and administrator. +#If you change the username of the administrator from "admin" to "admin1", your new administrator's username should be configured as: security.user_name.admin = admin1. +#If you change the password of the administrator from "admin" to "admin1pwd", your new administrator's password should be configured as: security.user_password = admin1:admin1pwd. + +#The following examples change the user's username to "user23" and the user's password to "user23pwd". +#security.user_name.user = user23 +#security.user_password = user23:user23pwd +#The following examples change the var's username to "var55" and the var's password to "var55pwd". +{if isset($user_name) } +security.user_name.user = {$user_name} +security.user_password = {$user_name}:{$user_password} +{/if} +{if isset($admin_name) } +security.user_name.admin = {$admin_name} +security.user_password = {$admin_name}:{$admin_password} +{/if} +{if isset($var_name) } +security.user_name.var = {$var_name} +security.user_password = {$var_name}:{$var_password} +{/if} + +#Enable or disable the 3-level permissions (open var); 0-Disabled (default), 1-Enabled; +#Require reboot; +security.var_enable = +security.ca_cert = +security.dev_cert = +security.cn_validation = + + +####################################################################################### +## Linekey ## +####################################################################################### +#The x of the parameter "linekey.x.line" ranges from 1 to 27. +#The default value equals to the value of x. For example, the default value of the parameter "linekey.1.line" is 1. +#linekey.x.lable--Define the label for each line key. + +#Configure Line Key1 +linekey.1.line = +linekey.1.value = +linekey.1.extension = +linekey.1.type = +linekey.1.label = +linekey.1.xml_phonebook = + +#Configure Line Key2 +linekey.2.line = +linekey.2.value = +linekey.2.extension = +linekey.2.type = +linekey.2.label = +linekey.2.xml_phonebook = + +linekey.3.line = +linekey.3.value = +linekey.3.extension = +linekey.3.type = +linekey.3.label = +linekey.3.xml_phonebook = + +linekey.4.line = +linekey.4.value = +linekey.4.extension = +linekey.4.type = +linekey.4.label = +linekey.4.xml_phonebook = + +linekey.5.line = +linekey.5.value = +linekey.5.extension = +linekey.5.type = +linekey.5.label = +linekey.5.xml_phonebook = + +linekey.6.line = +linekey.6.value = +linekey.6.extension = +linekey.6.type = +linekey.6.label = +linekey.6.xml_phonebook = + +linekey.7.line = +linekey.7.value = +linekey.7.extension = +linekey.7.type = +linekey.7.label = +linekey.7.xml_phonebook = + +linekey.8.line = +linekey.8.value = +linekey.8.extension = +linekey.8.type = +linekey.8.label = +linekey.8.xml_phonebook = + +linekey.9.line = +linekey.9.value = +linekey.9.extension = +linekey.9.type = +linekey.9.label = +linekey.9.xml_phonebook = + +linekey.10.line = +linekey.10.value = +linekey.10.extension = +linekey.10.type = +linekey.10.label = +linekey.10.xml_phonebook = + +linekey.11.line = +linekey.11.value = +linekey.11.extension = +linekey.11.type = +linekey.11.label = +linekey.11.xml_phonebook = + +linekey.12.line = +linekey.12.value = +linekey.12.extension = +linekey.12.type = +linekey.12.label = +linekey.12.xml_phonebook = + +linekey.13.line = +linekey.13.value = +linekey.13.extension = +linekey.13.type = +linekey.13.label = +linekey.13.xml_phonebook = + +linekey.14.line = +linekey.14.value = +linekey.14.extension = +linekey.14.type = +linekey.14.label = +linekey.14.xml_phonebook = + +linekey.15.line = +linekey.15.value = +linekey.15.extension = +linekey.15.type = +linekey.15.xml_phonebook = +linekey.15.label = + +linekey.16.line = +linekey.16.value = +linekey.16.extension = +linekey.16.type = +linekey.16.xml_phonebook = +linekey.16.label = + +linekey.17.line = +linekey.17.value = +linekey.17.extension = +linekey.17.type = +linekey.17.xml_phonebook = +linekey.17.label = + +linekey.18.line = +linekey.18.value = +linekey.18.extension = +linekey.18.type = +linekey.18.xml_phonebook = +linekey.18.label = + +linekey.19.line = +linekey.19.value = +linekey.19.extension = +linekey.19.type = +linekey.19.xml_phonebook = +linekey.19.label = + +linekey.20.line = +linekey.20.value = +linekey.20.extension = +linekey.20.type = +linekey.20.xml_phonebook = +linekey.20.label = + + +linekey.21.line = +linekey.21.value = +linekey.21.extension = +linekey.21.type = +linekey.21.xml_phonebook = +linekey.21.label = + + +linekey.22.line = +linekey.22.value = +linekey.22.extension = +linekey.22.type = +linekey.22.xml_phonebook = +linekey.22.label = + +linekey.23.line = +linekey.23.value = +linekey.23.extension = +linekey.23.type = +linekey.23.xml_phonebook = +linekey.23.label = + +linekey.24.line = +linekey.24.value = +linekey.24.extension = +linekey.24.type = +linekey.24.xml_phonebook = +linekey.24.label = + +linekey.25.line = +linekey.25.value = +linekey.25.extension = +linekey.25.type = +linekey.25.xml_phonebook = +linekey.25.label = + +linekey.26.line = +linekey.26.value = +linekey.26.extension = +linekey.26.type = +linekey.26.xml_phonebook = +linekey.26.label = + +linekey.27.line = +linekey.27.value = +linekey.27.extension = +linekey.27.type = +linekey.27.xml_phonebook = +linekey.27.label = +####################################################################################### +## Programablekey ## +####################################################################################### +#X ranges from 1 to 13. +#programablekey.x.type--Customize the programmable key type. +#The valid types are: +#0-N/A 2-Forward 5-DND 6-Redial 7-Call Return 8-SMS 9-Direct Pickup 13-Spead Dial +#22-XML Group 23-Group Pickup 27-XML Browser 28-History 29-Directory 30-Menu 31-Switch Account 32-New SMS +#33-Status 40-PTT 43-Local Phonebook 44-Broadsoft Phonebook 45-Local Group 46-Broadsoft Group 47-XML Phonebook 50-Keypad Lock +#PTT-add a specified prefix number before the dialed number. +#programablekey.x.line--Configure the desired line to apply the key feature. It ranges from 0 to 6. +#The value 0 of the "proramablekey.x.line" stands for Auto, it means the first available line. +#But, when the programmable key is configured as Pick Up, the value 0 stands for line 1. + +#programablekey.x.value = +#programablekey.x.xml_phonebook--Specify the desired remote phonebook/local group/BSFT phonebook for the programmable key. This parameter is only appilicable to the feature XML Group/Local Group/Broadsoft Group. +#programablekey.x.history_type = + +#programablekey.x.label--This parameter is only available to the key 1 to key 4. +programablekey.1.type = +programablekey.1.line = +programablekey.1.value = +programablekey.1.xml_phonebook = +programablekey.1.history_type = +programablekey.1.label = +programablekey.1.pickup_value = + +########################################################################################## +## Expansion Key ## +########################################################################################## +#X ranges from 1 to 16, Y ranges from 1 to 40. +#expansion_module.x.key.y.type = 37 (Switch by default) +#expansion_module.x.key.y.line = 0 +#expansion_module.x.key.y.value = +#expansion_module.x.key.y.pickup_value = +#expansion_module.x.key.y.label = +#expansion_module.X.key.Y.xml_phonebook = + +#Each expansion module1 key1 +expansion_module.1.key.1.type = +expansion_module.1.key.1.line = +expansion_module.1.key.1.value = +expansion_module.1.key.1.pickup_value = +expansion_module.1.key.1.label = +expansion_module.1.key.1.xml_phonebook = + +#Each expansion module1 key2 +expansion_module.1.key.2.type = +expansion_module.1.key.2.line = +expansion_module.1.key.2.value = +expansion_module.1.key.2.pickup_value = +expansion_module.1.key.2.label = +expansion_module.1.key.2.xml_phonebook = + +#Each expansion module2 key1 +expansion_module.2.key.1.type = +expansion_module.2.key.1.line = +expansion_module.2.key.1.value = +expansion_module.2.key.1.pickup_value = +expansion_module.2.key.1.label = +expansion_module.2.key.1.xml_phonebook = + +####################################################################################### +## Forward Always ## +####################################################################################### +#Enable or disable the always forward feature; 0-Disabled (default), 1-Enabled; +forward.always.enable = +forward.always.target = +forward.always.on_code = +forward.always.off_code = + +####################################################################################### +## Forward Busy ## +####################################################################################### +#Enable or disable the busy forward feature; 0-Disabled (default), 1-Enabled; +forward.busy.enable = +forward.busy.target = +forward.busy.on_code = +forward.busy.off_code = + +####################################################################################### +## Forward No Answer ## +####################################################################################### +#Enable or disable the no answer forward feature; 0-Disabled (default), 1-Enabled; +#Configure the waiting ring times before forwarding. It ranges from 0 to 20, the default value is 2. +forward.no_answer.enable = +forward.no_answer.target = +forward.no_answer.timeout = +forward.no_answer.on_code = +forward.no_answer.off_code = + +####################################################################################### +## Forward International ## +####################################################################################### +#Enable or disable the phone to forward the call to the international number (the prefix is 00); 0-Disabled (default), 1-Enabled; +forward.international.enable = + +####################################################################################### +## ACD ## +####################################################################################### +#Enable or disable the phone to automatically change the phone status to available; 0-Disabled (default), 1-Enabled; +acd.auto_available = + +#Configure the interval (in seconds) to automatically turn the state of the ACD agent to available. It ranges from 0 to 120, the default value is 60. +acd.auto_available_timer = +acd.bw = + +####################################################################################### +## Hotdesking Startup ## +####################################################################################### +#Enable or disable the phone to show the following items on the login wizard during startup; 0-Disabled, 1-Enabled; +#hotdesking.startup_register_name_enable = 1 (default) +#hotdesking.startup_username_enable = 1 (default) +#hotdesking.startup_password_enable = 0 (default) +#hotdesking.startup_sip_server_enable = 0 (default) +#hotdesking.startup_outbound_enable = 0 (default) + +hotdesking.startup_register_name_enable = +hotdesking.startup_username_enable = +hotdesking.startup_password_enable = +hotdesking.startup_sip_server_enable = +hotdesking.startup_outbound_enable = + +####################################################################################### +## Hotdesking Dsskey ## +####################################################################################### +#Enable or disable the phone to show the following items on the login wizard when pressing the Hot Desking DSS key; +#0-Disabled, 1-Enabled; +#hotdesking.dsskey_register_name_enable = 1 (default) +#hotdesking.dsskey_username_enable = 1 (default) +#hotdesking.dsskey_password_enable = 0 (default) +#hotdesking.dsskey_sip_server_enable = 0 (default) +#hotdesking.dsskey_outbound_enable = 0 (default) + +hotdesking.dsskey_register_name_enable = +hotdesking.dsskey_username_enable = +hotdesking.dsskey_password_enable = +hotdesking.dsskey_sip_server_enable = +hotdesking.dsskey_outbound_enable = + +####################################################################################### +## Alert Info ## +####################################################################################### +#"X" ranges from 1 to 10; +#Configure the text to map the keywords contained in the "Alert-info" header. +#distinctive_ring_tones.alert_info.X.text = family +distinctive_ring_tones.alert_info.1.text = + +#Specify the ring tone for each text. It ranges from 1 to 8. The default value 1 stands for Ring1.wav. +#1-Ring1.wav, 2-Ring2.wav, 3-Ring3.wav, 4-Ring4.wav, 5-Ring5.wav, 6-Ring6.wav, 7-Ring7.wav, 8-Ring8.wav. +#distinctive_ring_tones.alert_info.X.ringer = 1 +distinctive_ring_tones.alert_info.1.ringer = + +####################################################################################### +## Call Waiting ## +####################################################################################### +#Enable or disable the call waiting feature; 0-Disabled, 1-Enabled (default); +call_waiting.enable = +#Enable or disable the playing of call waiting tone; 0-Disabled, 1-Enabled (default); +call_waiting.tone = + +call_waiting.on_code = +call_waiting.off_code = + +####################################################################################### +## Call Park ## +####################################################################################### +call_park.enable = 0 +call_park.group_enable = 0 +call_park.park_ring = +call_park.park_visual_notify_enable = + +####################################################################################### +## Action URL ## +####################################################################################### +#action_url.setup_completed--Inform the server that the phone has completed the startup. +#action_url.dnd_on-- Inform the server that the DND is activated on the phone. +#The value format is: http://IP address of server/help.xml?variable name=variable value. +#The valid variable values are: $mac--MAC address of phone, $ip--The current IP address of phone, $model--Phone model, $firmware--Phone firmware version. +#$active_url--The SIP URI of the current account when the phone is in the incoming state, outgoing state or during conversation. +#$active_user--The username of the current account when the phone is in the incoming state, outgoing state or during conversation. +#$active_host--The host name of the current account when the phone is in the incoming state, the outgoing state or during conversation. +#$local--The SIP URI of the caller when outgoing calls or the SIP URI of the callee when receiving calls. +#$remote--The SIP URI of the callee when outgoing calls or the SIP URI of the caller when receiving calls. +#$display_local--The display name of the caller when outgoing calls or the display name of the callee when receiving calls. +#$display_remote--The display name of the callee when outgoing calls or the display name of the caller when receiving calls. +#$call_id--The caller ID when in the incoming state, the outgoing state or during conversation. +#For example, action_url.log_on = http://192.168.1.20/help.xml?mac=$mac + +action_url.setup_completed = +action_url.log_on = +action_url.log_off = +action_url.register_failed = +action_url.off_hook = +action_url.on_hook = +action_url.incoming_call = +action_url.outgoing_call = +action_url.call_established = +action_url.dnd_on = +action_url.dnd_off = +action_url.always_fwd_on = +action_url.always_fwd_off = +action_url.busy_fwd_on = +action_url.busy_fwd_off = +action_url.no_answer_fwd_on = +action_url.no_answer_fwd_off = +action_url.transfer_call = +action_url.blind_transfer_call = +action_url.attended_transfer_call = +action_url.hold = +action_url.unhold = +action_url.mute = +action_url.unmute = +action_url.missed_call = +action_url.call_terminated = +action_url.busy_to_idle = +action_url.idle_to_busy = +action_url.ip_change = +action_url.forward_incoming_call = +action_url.reject_incoming_call = +action_url.answer_new_incoming_call = +action_url.transfer_finished = +action_url.transfer_failed = + +####################################################################################### +## Ringtone ## +####################################################################################### +#Before using this parameter, you should store the desired ring tone (x.wav) to the provisioning server. +#For more information, refer to Yealink Auto Provisioning User Guide. +ringtone.url = + +#ringtone.delete = http://localhost/all,delete all the customized ring tones. +ringtone.delete = + +####################################################################################### +## UI Language ## +####################################################################################### +#Before using this parameter, you should store the desired language pack to the provisioning server. +#For more information, refer to Yealink Auto Provisioning User Guide. +gui_lang.url = + +#gui_lang.delete = http://localhost/all, delete all the customized languages. +gui_lang.delete = + +####################################################################################### +## Time Settings ## +####################################################################################### + +#Configure the time zone and time zone name. The time zone ranges from -11 to +12, the default value is +8. +#The default time zone name is China(Beijing). +#local_time.time_zone = +8 +#local_time.time_zone_name = China(Beijing) +local_time.time_zone = {$yealink_time_zone} +local_time.time_zone_name = {$yealink_time_zone_name} + +#Configure the domain name or the IP address of the NTP server. The default value is cn.pool.ntp.org. +local_time.ntp_server1 = {$ntp_server_1} +local_time.ntp_server2 = {$ntp_server_2} + +#Configure the update interval (in seconds) when using the NTP server. The default value is 1000. +local_time.interval = + +#Configure the daylight saving time feature; 0-Disabled, 1-Enabled, 2-Automatic (default); +local_time.summer_time = + +#Configure the DST type when the DST feature is enabled; 0-By Date (default), 1-By Week; +local_time.dst_time_type = + +#Configure the start time of DST. The default value is 1/1/0. +#If the DST type is configured as By Date, the value format is Month/Day/Hour. For example, the value 5/20/10 means the start time is at 10:00 on May 20. +#If the DST type is configured as By Week, the value format is Month/Day of Week/Day of Week Last in Month/Hour of Day. +#For example, the value 1/4/2/5 means the start time is at 5 o'clock on Tuesday of the 4th week in January. +local_time.start_time = {$yealink_time_zone_start_time} + +#Configure the end time of DST. The default value is 12/31/23. The value format is the same to the start time. +local_time.end_time = {$yealink_time_zone_end_time} + +#Configure the offset time (in seconds). It ranges from -300 to 300, the default value is blank. +local_time.offset_time = {$yealink_offset_time} + +#Configure the time format; 0-12 Hour, 1-24 Hour (default); +local_time.time_format = {$yealink_time_format} + +#Configure the date format; 0-WWW MMM DD (default), 1-DD-MMM-YY, 2-YYYY-MM-DD, 3-DD/MM/YYYY, 4-MM/DD/YY, 5-DD MMM YYYY, 6-WWW DD MMM; +local_time.date_format = {$yealink_date_format} + +#Enable or disable the DHCP Time; 0-Disabled (default), 1-Enabled; +local_time.dhcp_time = + +#Enable or disable the manual time; 0-NTP time, 1-manual time. The default value is 0. +local_time.manual_time_enable = + +####################################################################################### +## Trusted Certificates ## +####################################################################################### +#Before using this parameter, you should store the desired certificate to the provisioning server. +trusted_certificates.url = + +#trusted_certificates.delete = http://localhost/all,delete all the trusted certificates. +trusted_certificates.delete = + +####################################################################################### +## Server Certificates ## +####################################################################################### +#Before using this parameter, you should store the desired certificate to the provisioning server. +server_certificates.url = + +#server_certificates.delete = http://localhost/all, delete the server certificate. +server_certificates.delete = + +####################################################################################### +## Contact ## +####################################################################################### +#Before using these parameters, you should store the desired resource files to the provisioning server. +#For more information, refer to Yealink SIP-T46G IP Phone Family Administrator Guide. +local_contact.data.url = + +####################################################################################### +## Auto DST ## +####################################################################################### +auto_dst.url = + +####################################################################################### +## Dialplan Now ## +####################################################################################### +dialplan_dialnow.url = + +####################################################################################### +## Dialplan Replace ## +####################################################################################### +dialplan_replace_rule.url = + +####################################################################################### +## Custom Factory Configuration ## +####################################################################################### +#Configure the access URL for downloading the customized factory configurations. +#Before using this parameter, you should store the desired factory configuration file to the provisioning server. +custom_factory_configuration.url = + +####################################################################################### +## Custom Configuration ## +####################################################################################### +#Configure the access URL for downloading the configurations. +#Before using this parameter, you should store the desired configuration file to the provisioning server. +configuration.url = + +####################################################################################### +## Custom Softkey ## +####################################################################################### +#Customize the softkeys presented on the phone LCD screen when Callfailed, Callin, Connecting, Dialing, Ringback and Talking. +#Before using these parameters, you should store the desired XML files to the provisioning server. +custom_softkey_call_failed.url = +custom_softkey_call_in.url = +custom_softkey_connecting.url = +custom_softkey_dialing.url = +custom_softkey_ring_back.url = +custom_softkey_talking.url = + +####################################################################################### +## Local Contact Photo ## +####################################################################################### +local_contact.data_photo_tar.url = + +####################################################################################### +## Call List ## +####################################################################################### +#Configure the access URL for downloading the call list. +#Before using this parameter, you should store the desired call list file to the provisioning server. +#Require reboot +call_list.url = + +####################################################################################### +## Open VPN ## +####################################################################################### +#Configure the access URL for downloading the open VPN tar. +#Before using this parameter, you should store the desired VPN file to the provisioning server +openvpn.url = + +####################################################################################### +## Level ## +####################################################################################### +#Configure the access URL for downloading the files for var. +#Before using this parameter, you should store the desired files to the provisioning server. +#Require reboot +web_item_level.url = + +####################################################################################### +## Super Search URL ## +####################################################################################### +super_search.url = + +####################################################################################### +## Directory Setting ## +####################################################################################### +#Configure the access URL of the directory setting file. +directory_setting.url = {$yealink_directory_settingurl} + +####################################################################################### +## Configure the access URL of firmware ## +####################################################################################### +#Before using this parameter, you should store the desired firmware (x.71.x.x.rom) to the provisioning server. +firmware.url = {$yealink_cp860_firmware_url} From 4e9c06901ab458952d5307fb4719d0bf5ed2ebb0 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 21:51:51 -0600 Subject: [PATCH 005/174] Show the number of users and move the registration count to the front. --- .../status_registrations_inc.php | 4 +- core/users/app_languages.php | 2 +- core/users/users.php | 71 ++++++++++--------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/app/registrations/status_registrations_inc.php b/app/registrations/status_registrations_inc.php index e4efaba3ac..36843301e9 100644 --- a/app/registrations/status_registrations_inc.php +++ b/app/registrations/status_registrations_inc.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2014 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -127,7 +127,7 @@ require_once "resources/check_auth.php"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; - if ($result_count > 0) { - foreach($result as $row) { + if ($num_rows > 0) { + foreach($extensions as $row) { $tr_link = (permission_exists('extension_edit')) ? " href='extension_edit.php?id=".$row['extension_uuid']."'" : null; echo "\n"; echo " \n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $extensions, $row_count); } //end if results echo "\n"; @@ -205,7 +204,6 @@ require_once "resources/paging.php"; echo "
\n"; - echo " ".$text['header-registrations'].": ".count($registrations)."\n"; + echo " ".count($registrations)." ".$text['header-registrations']."\n"; echo ""; echo " \"".$text['label-refresh_pause']."\""; diff --git a/core/users/app_languages.php b/core/users/app_languages.php index 6d0316c86b..c7f1235c8d 100644 --- a/core/users/app_languages.php +++ b/core/users/app_languages.php @@ -1,6 +1,6 @@ - Portions created by the Initial Developer are Copyright (C) 2008-2013 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -34,6 +34,7 @@ else { exit; } +//additional includes require_once "resources/paging.php"; //set the variables @@ -41,35 +42,6 @@ else { $order = check_str($_GET["order"]); $search_value = check_str($_REQUEST["search_value"]); -//page title and description - echo "\n"; - echo ""; - echo "\n"; - echo "\n"; - echo ""; - echo "\n"; - echo ""; - - echo "\n"; - echo "\n"; - echo "\n"; - //get the list of superadmins $superadmins = superadmin_list($db); @@ -157,10 +129,39 @@ else { $sql .= " limit ".$rows_per_page." offset ".$offset." "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); + $users = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $user_count = count($users); unset ($prep_statement, $sql); +//page title and description + echo "
".$text['header-user_manager'].""; - if (permission_exists('user_all')) { - if ($_GET['showall'] == 'true') { - echo "\n"; - echo ""; - } - else { - echo "\n"; - } - } - echo ""; - echo ""; - echo "
\n"; - echo $text['description-user_manager']."\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + //alternate the row style $c = 0; $row_style["0"] = "row_style0"; @@ -185,8 +186,8 @@ else { echo "\n"; echo "\n"; - if ($result_count > 0) { - foreach($result as $row) { + if ($user_count > 0) { + foreach($users as $row) { if (if_superadmin($superadmins, $row['user_uuid']) && !if_group("superadmin")) { //hide } else { @@ -233,7 +234,7 @@ else { if ($c==0) { $c=1; } else { $c=0; } } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $users, $user_count); } //end if results echo "\n"; From 7cfd5da36967016601b20dca74b05b58fb2911a2 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 22:06:09 -0600 Subject: [PATCH 006/174] Change the format to display the count. --- app/registrations/status_registrations_inc.php | 2 +- core/users/app_languages.php | 4 ++-- core/users/users.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/registrations/status_registrations_inc.php b/app/registrations/status_registrations_inc.php index 36843301e9..03fedb8c5e 100644 --- a/app/registrations/status_registrations_inc.php +++ b/app/registrations/status_registrations_inc.php @@ -127,7 +127,7 @@ require_once "resources/check_auth.php"; echo "
".$user_count." ".$text['header-user_manager'].""; + if (permission_exists('user_all')) { + if ($_GET['showall'] == 'true') { + echo "\n"; + echo ""; + } + else { + echo "\n"; + } + } + echo ""; + echo ""; + echo "
\n"; + echo $text['description-user_manager']."\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; echo "\n"; echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; - if ($result_count > 0) { - foreach($result as $row) { + if ($num_rows > 0) { + foreach($fax_files as $row) { $file = basename($row['fax_file_path']); if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") { $file_name = substr($file, 0, (strlen($file) -4)); @@ -382,7 +381,7 @@ else { echo "\n"; $c = ($c) ? 0 : 1; } //end foreach - unset($sql, $result, $row_count); + unset($sql, $fax_files); } //end if results //show the paging controls From 4cfe899919b95d6de9989d5a3a5d5c70f08fffd9 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 23:05:08 -0600 Subject: [PATCH 011/174] A few more minor adjustments. --- app/fax/app_languages.php | 2 +- app/voicemails/voicemail_messages.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index f56a1089cc..93ad7aa319 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -1,6 +1,6 @@ ".$text['title-voicemail_messages']." (".count($voicemails).")"; + echo "".$text['title-voicemail_messages'].""; echo "

"; echo $text['description-voicemail_message']; echo "

"; From b34f8baeb8c1e43731ce716678ec820801632ffc Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 23:12:36 -0600 Subject: [PATCH 012/174] Add extension count. --- app/extensions/extensions.php | 44 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/app/extensions/extensions.php b/app/extensions/extensions.php index 6f225149c7..a2d7b28597 100644 --- a/app/extensions/extensions.php +++ b/app/extensions/extensions.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -50,22 +50,6 @@ $document['title'] = $text['title-extensions']; require_once "resources/paging.php"; -//show the content - echo "
\n"; - echo " ".count($registrations)." ".$text['header-registrations']."\n"; + echo " ".$text['header-registrations']." (".count($registrations).")\n"; echo ""; echo " \"".$text['label-refresh_pause']."\""; diff --git a/core/users/app_languages.php b/core/users/app_languages.php index c7f1235c8d..8c7a342be3 100644 --- a/core/users/app_languages.php +++ b/core/users/app_languages.php @@ -1,6 +1,6 @@ \n"; echo "
"; echo "
".$user_count." ".$text['header-user_manager']."".$text['header-user_manager']." (".$num_rows.")"; if (permission_exists('user_all')) { if ($_GET['showall'] == 'true') { From 0900c143cdb3baf13195153ec27f5832ddca82cf Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 22:19:11 -0600 Subject: [PATCH 007/174] Add device count. --- app/devices/devices.php | 211 ++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 105 deletions(-) diff --git a/app/devices/devices.php b/app/devices/devices.php index 264a9d1464..c215fd432c 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -44,6 +44,111 @@ else { $order = check_str($_GET["order"]); } +//get total devices count from the database + $sql = "select count(*) as num_rows from v_devices where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + $total_devices = $row['num_rows']; + } + unset($sql, $prep_statement, $row); + +//prepare to page the results + $sql = "select count(*) as num_rows from v_devices as d "; + if ($_GET['showall'] && permission_exists('device_all')) { + if (strlen($search) > 0) { + $sql .= "where "; + } + } else { + $sql .= "where ("; + $sql .= " d.domain_uuid = '$domain_uuid' "; + if (permission_exists('device_all')) { + $sql .= " or d.domain_uuid is null "; + } + $sql .= ") "; + if (strlen($search) > 0) { + $sql .= "and "; + } + } + if (strlen($search) > 0) { + $sql .= "("; + $sql .= " d.device_mac_address like '%".$search."%' "; + $sql .= " or d.device_label like '%".$search."%' "; + $sql .= " or d.device_vendor like '%".$search."%' "; + $sql .= " or d.device_provision_enable like '%".$search."%' "; + $sql .= " or d.device_template like '%".$search."%' "; + $sql .= " or d.device_description like '%".$search."%' "; + $sql .= ") "; + } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = 150; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select d.*, d2.device_label as alternate_label "; + $sql .= "from v_devices as d, v_devices as d2 "; + $sql .= "where ( "; + $sql .= " d.device_uuid_alternate = d2.device_uuid "; + $sql .= " or d.device_uuid_alternate is null and d.device_uuid = d2.device_uuid "; + $sql .= ") "; + if ($_GET['showall'] && permission_exists('device_all')) { + //echo __line__."
\n"; + } else { + $sql .= "and ("; + $sql .= " d.domain_uuid = '$domain_uuid' "; + if (permission_exists('device_all')) { + $sql .= " or d.domain_uuid is null "; + } + $sql .= ") "; + } + if (strlen($search) > 0) { + $sql .= "and ("; + $sql .= " d.device_mac_address like '%".$search."%' "; + $sql .= " or d.device_label like '%".$search."%' "; + $sql .= " or d.device_vendor like '%".$search."%' "; + $sql .= " or d.device_provision_enable like '%".$search."%' "; + $sql .= " or d.device_template like '%".$search."%' "; + $sql .= " or d.device_description like '%".$search."%' "; + $sql .= ") "; + } + if (strlen($order_by) == 0) { + $sql .= "order by d.device_label, d.device_description asc "; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $devices = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate_found + $device_alternate = false; + foreach($devices as $row) { + if (strlen($row['device_uuid_alternate']) > 0) { + $device_alternate = true; + break; + } + } + //additional includes require_once "resources/header.php"; require_once "resources/paging.php"; @@ -52,7 +157,7 @@ else { echo "\n"; echo " \n"; echo " \n"; @@ -77,114 +182,10 @@ else { echo "
"; - echo " ".$text['header-devices'].""; + echo " ".$text['header-devices']." (".$num_rows.")"; echo "

"; echo " ".$text['description-devices']; echo "
\n"; echo "
"; - //get total devices count from the database - $sql = "select count(*) as num_rows from v_devices where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - $total_devices = $row['num_rows']; - } - unset($sql, $prep_statement, $row); - - //prepare to page the results - $sql = "select count(*) as num_rows from v_devices as d "; - if ($_GET['showall'] && permission_exists('device_all')) { - if (strlen($search) > 0) { - $sql .= "where "; - } - } else { - $sql .= "where ("; - $sql .= " d.domain_uuid = '$domain_uuid' "; - if (permission_exists('device_all')) { - $sql .= " or d.domain_uuid is null "; - } - $sql .= ") "; - if (strlen($search) > 0) { - $sql .= "and "; - } - } - if (strlen($search) > 0) { - $sql .= "("; - $sql .= " d.device_mac_address like '%".$search."%' "; - $sql .= " or d.device_label like '%".$search."%' "; - $sql .= " or d.device_vendor like '%".$search."%' "; - $sql .= " or d.device_provision_enable like '%".$search."%' "; - $sql .= " or d.device_template like '%".$search."%' "; - $sql .= " or d.device_description like '%".$search."%' "; - $sql .= ") "; - } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - - //prepare to page the results - $rows_per_page = 150; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - - //get the list - $sql = "select d.*, d2.device_label as alternate_label "; - $sql .= "from v_devices as d, v_devices as d2 "; - $sql .= "where ( "; - $sql .= " d.device_uuid_alternate = d2.device_uuid "; - $sql .= " or d.device_uuid_alternate is null and d.device_uuid = d2.device_uuid "; - $sql .= ") "; - if ($_GET['showall'] && permission_exists('device_all')) { - //echo __line__."
\n"; - } else { - $sql .= "and ("; - $sql .= " d.domain_uuid = '$domain_uuid' "; - if (permission_exists('device_all')) { - $sql .= " or d.domain_uuid is null "; - } - $sql .= ") "; - } - if (strlen($search) > 0) { - $sql .= "and ("; - $sql .= " d.device_mac_address like '%".$search."%' "; - $sql .= " or d.device_label like '%".$search."%' "; - $sql .= " or d.device_vendor like '%".$search."%' "; - $sql .= " or d.device_provision_enable like '%".$search."%' "; - $sql .= " or d.device_template like '%".$search."%' "; - $sql .= " or d.device_description like '%".$search."%' "; - $sql .= ") "; - } - if (strlen($order_by) == 0) { - $sql .= "order by d.device_label, d.device_description asc "; - } - else { - $sql .= "order by $order_by $order "; - } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $devices = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - //alternate_found - $device_alternate = false; - foreach($devices as $row) { - if (strlen($row['device_uuid_alternate']) > 0) { - $device_alternate = true; - break; - } - } echo "\n"; echo "\n"; if ($_GET['showall'] && permission_exists('device_all')) { From 04521659b6eb6d5e5a8e79aa16361f8a3fcde5d2 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 22:23:01 -0600 Subject: [PATCH 008/174] Move the includes in devices. --- app/devices/devices.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/devices/devices.php b/app/devices/devices.php index c215fd432c..cc466bc5b8 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -33,6 +33,10 @@ else { exit; } +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + //add multi-lingual support $language = new text; $text = $language->get(); @@ -149,10 +153,6 @@ else { } } -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - //show the content echo "
\n"; echo " \n"; From 6f389eedd8c5b565719576e91e41e0f94aa5b9da Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 22:38:48 -0600 Subject: [PATCH 009/174] Add count to voice mails and voice mail messages. --- app/voicemails/voicemail_messages.php | 6 +- app/voicemails/voicemails.php | 133 +++++++++++++------------- 2 files changed, 67 insertions(+), 72 deletions(-) diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 13942dabdb..852cc1de4a 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -86,7 +86,7 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] require_once "resources/paging.php"; //show the content - echo "".$text['title-voicemail_messages'].""; + echo "".$text['title-voicemail_messages']." (".count($voicemails).")"; echo "

"; echo $text['description-voicemail_message']; echo "

"; @@ -185,17 +185,13 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] $previous_voicemail_id = $field['voicemail_id']; unset($sql, $result, $result_count); - } - echo "
"; echo "

"; - } else { echo "
".$text['message-messages_not_found']."

"; } - echo "
"; //autoplay message diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index c4cb62fc62..4224259456 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -57,11 +57,73 @@ else { require_once "resources/header.php"; require_once "resources/paging.php"; +//prepare to page the results + $sql = "select count(*) as num_rows from v_voicemails "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($search) > 0) { + $sql .= "and ("; + $sql .= " voicemail_id like '%".$search."%' "; + $sql .= " or voicemail_mail_to like '%".$search."%' "; + $sql .= " or voicemail_local_after_email like '%".$search."%' "; + $sql .= " or voicemail_enabled like '%".$search."%' "; + $sql .= " or voicemail_description like '%".$search."%' "; + $sql .= ") "; + } + if (!permission_exists('voicemail_delete')) { + $x = 0; + if (count($voicemail_uuids) > 0) { + $sql .= "and ("; + foreach($voicemail_uuids as $row) { + if ($x == 0) { + $sql .= "voicemail_uuid = '".$row['voicemail_uuid']."' "; + } + else { + $sql .= " or voicemail_uuid = '".$row['voicemail_uuid']."'"; + } + $x++; + } + $sql .= ")"; + } + else { + $sql .= "and voicemail_uuid is null "; + } + } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = 150; + $param = ""; + if ($search != '') { $param .= "&search=".$search; } + if ($order_by != '') { $param .= "&order_by=".$order_by."&order=".$order; } + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = str_replace('count(*) as num_rows', '*', $sql); + $sql .= ($order_by != '') ? "order by ".$order_by." ".$order." " : "order by voicemail_id asc "; + $sql .= "limit ".$rows_per_page." offset ".$offset." "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $voicemails = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + //show the content echo "\n"; echo " \n"; echo " \n"; echo "
"; - echo " ".$text['title-voicemails'].""; + echo " ".$text['title-voicemails']." (".$num_rows.")"; echo "

"; echo " ".$text['description-voicemail']; echo "

"; @@ -75,74 +137,11 @@ else { echo "
\n"; - //prepare to page the results - $sql = "select count(*) as num_rows from v_voicemails "; - $sql .= "where domain_uuid = '$domain_uuid' "; - if (strlen($search) > 0) { - $sql .= "and ("; - $sql .= " voicemail_id like '%".$search."%' "; - $sql .= " or voicemail_mail_to like '%".$search."%' "; - $sql .= " or voicemail_local_after_email like '%".$search."%' "; - $sql .= " or voicemail_enabled like '%".$search."%' "; - $sql .= " or voicemail_description like '%".$search."%' "; - $sql .= ") "; - } - if (!permission_exists('voicemail_delete')) { - $x = 0; - if (count($voicemail_uuids) > 0) { - $sql .= "and ("; - foreach($voicemail_uuids as $row) { - if ($x == 0) { - $sql .= "voicemail_uuid = '".$row['voicemail_uuid']."' "; - } - else { - $sql .= " or voicemail_uuid = '".$row['voicemail_uuid']."'"; - } - $x++; - } - $sql .= ")"; - } - else { - $sql .= "and voicemail_uuid is null "; - } - } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - - //prepare to page the results - $rows_per_page = 150; - $param = ""; - if ($search != '') { $param .= "&search=".$search; } - if ($order_by != '') { $param .= "&order_by=".$order_by."&order=".$order; } - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - - //get the list - $sql = str_replace('count(*) as num_rows', '*', $sql); - $sql .= ($order_by != '') ? "order by ".$order_by." ".$order." " : "order by voicemail_id asc "; - $sql .= "limit ".$rows_per_page." offset ".$offset." "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); - unset ($prep_statement, $sql); - $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - if ($result_count > 0) { + if ($num_rows > 0) { echo "\n"; echo "\n"; @@ -165,7 +164,7 @@ else { echo "\n"; echo "\n"; - foreach($result as $row) { + foreach($voicemails as $row) { $tr_link = (permission_exists('voicemail_edit')) ? "href='voicemail_edit.php?id=".$row['voicemail_uuid']."'" : null; echo "\n"; echo " \n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $voicemails, $row_count); echo "\n"; echo "\n"; echo "\n"; - if ($result_count > 0) { + if ($num_rows > 0) { foreach($result as $row) { //remove the backslash $row['fax_email'] = str_replace("\\", "", $row['fax_email']); @@ -182,7 +184,7 @@ require_once "resources/paging.php"; //alternate the CSS class if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $result); } //end if results echo "\n"; diff --git a/app/fax/fax_files.php b/app/fax/fax_files.php index b79431d31f..8f83b675dd 100644 --- a/app/fax/fax_files.php +++ b/app/fax/fax_files.php @@ -172,24 +172,6 @@ else { require_once "resources/header.php"; require_once "resources/paging.php"; -//show the header - echo "
"; @@ -202,7 +201,7 @@ else { echo "
\n"; From 2a3240c7c418a2836dccfd2131d960ead3fc3604 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 22:59:13 -0600 Subject: [PATCH 010/174] Add a fax server count. --- app/fax/fax.php | 36 ++++++++++++++++++---------------- app/fax/fax_files.php | 45 +++++++++++++++++++++---------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/app/fax/fax.php b/app/fax/fax.php index 2601ca7662..81af0c8441 100644 --- a/app/fax/fax.php +++ b/app/fax/fax.php @@ -33,8 +33,10 @@ else { echo "access denied"; exit; } -require_once "resources/header.php"; -require_once "resources/paging.php"; + +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; //add multi-lingual support $language = new text; @@ -44,18 +46,7 @@ require_once "resources/paging.php"; $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); -//show the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['title-fax'].""; - echo "

\n"; - echo " ".$text['description']."\n"; - echo "
\n"; - echo "
\n"; - +//get the fax extensions if (if_group("superadmin") || if_group("admin")) { //show all fax extensions $sql = "select count(*) as num_rows from v_fax "; @@ -109,9 +100,20 @@ require_once "resources/paging.php"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); - $result_count = count($result); unset ($prep_statement, $sql); +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['title-fax']." (".$num_rows.")"; + echo "

\n"; + echo " ".$text['description']."\n"; + echo "
\n"; + echo "
\n"; + $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; @@ -130,7 +132,7 @@ require_once "resources/paging.php"; echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) { - echo " ".$text['header-inbox'].": ".$fax_name." (".$fax_extension.")\n"; - } - if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) { - echo " ".$text['header-sent'].": ".$fax_name." (".$fax_extension.")\n"; - } - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - //prepare to page the results $sql = "select count(*) as num_rows from v_fax_files "; $sql .= "where fax_uuid = '$fax_uuid' "; @@ -234,10 +216,27 @@ else { $sql .= "limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); + $fax_files = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); +//show the header + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) { + echo " ".$text['header-inbox'].": ".$fax_name." (".$fax_extension.")\n"; + } + if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) { + echo " ".$text['header-sent'].": ".$fax_name." (".$fax_extension.")\n"; + } + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + //show the table and content $c = 0; $row_style["0"] = "row_style0"; @@ -255,8 +254,8 @@ else { echo th_order_by('fax_date', $text['label-fax_date'], $order_by, $order, "&id=".$_GET['id']."&box=".$_GET['box']."&page=".$_GET['page']); echo "
 
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['header-extensions']."
\n"; - echo " ".$text['description-extensions']."\n"; - echo "
\n"; - echo " "; - echo " "; - echo "
\n"; - echo "
"; - //get total extension count from the database $sql = "select count(*) as num_rows from v_extensions where domain_uuid = '".$_SESSION['domain_uuid']."' "; $prep_statement = $db->prepare($sql); @@ -128,10 +112,25 @@ require_once "resources/paging.php"; $sql .= " limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); + $extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['header-extensions']." (".$num_rows.")
\n"; + echo " ".$text['description-extensions']."\n"; + echo "
\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; @@ -153,8 +152,8 @@ require_once "resources/paging.php"; echo "
"; @@ -181,7 +180,7 @@ require_once "resources/paging.php"; echo "
"; echo "

"; - //show the footer require_once "resources/footer.php"; ?> \ No newline at end of file From 31d727cab533be0ab02133a77c18644769adbb49 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 23:18:13 -0600 Subject: [PATCH 013/174] Count the destinations. --- app/destinations/destinations.php | 148 +++++++++++++++--------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index 79384d6794..e145543397 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -50,10 +50,81 @@ else { $document['title'] = $text['title-destinations']; require_once "resources/paging.php"; +//get total destination count from the database + $sql = "select count(*) as num_rows from v_destinations "; + if ($_GET['showall'] && permission_exists('destination_all')) { + if (strlen($search) > 0) { + $sql .= "where "; + } + } else { + $sql .= "where domain_uuid = '".$domain_uuid."' "; + if (strlen($search) > 0) { + $sql .= "and "; + } + } + if (strlen($search) > 0) { + $sql .= "("; + $sql .= " destination_type like '%".$search."%' "; + $sql .= " or destination_number like '%".$search."%' "; + $sql .= " or destination_context like '%".$search."%' "; + $sql .= " or destination_enabled like '%".$search."%' "; + $sql .= " or destination_description like '%".$search."%' "; + $sql .= ") "; + } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + $total_destinations = $row['num_rows']; + } + else { + $num_rows = 0; + } + +//prepare to page the results + $rows_per_page = 150; + $param = "&search=".$search; + if ($_GET['showall'] && permission_exists('destination_all')) { + $param .= "&showall=true"; + } + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($total_destinations, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_destinations "; + if ($_GET['showall'] && permission_exists('destination_all')) { + if (strlen($search) > 0) { + $sql .= " where "; + } + } else { + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($search) > 0) { + $sql .= " and "; + } + } + if (strlen($search) > 0) { + $sql .= " ("; + $sql .= " destination_type like '%".$search."%' "; + $sql .= " or destination_number like '%".$search."%' "; + $sql .= " or destination_context like '%".$search."%' "; + $sql .= " or destination_enabled like '%".$search."%' "; + $sql .= " or destination_description like '%".$search."%' "; + $sql .= ") "; + } + if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $destinations = $prep_statement->fetchAll(); + $destination_count = count($destination); + unset ($prep_statement, $sql); + //show the content echo "\n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "
".$text['header-destinations']."".$text['header-destinations']." (".$total_destinations.")
\n"; if (permission_exists('destination_all')) { @@ -76,77 +147,6 @@ else { echo "
\n"; - //get total destination count from the database - $sql = "select count(*) as num_rows from v_destinations "; - if ($_GET['showall'] && permission_exists('destination_all')) { - if (strlen($search) > 0) { - $sql .= "where "; - } - } else { - $sql .= "where domain_uuid = '".$domain_uuid."' "; - if (strlen($search) > 0) { - $sql .= "and "; - } - } - if (strlen($search) > 0) { - $sql .= "("; - $sql .= " destination_type like '%".$search."%' "; - $sql .= " or destination_number like '%".$search."%' "; - $sql .= " or destination_context like '%".$search."%' "; - $sql .= " or destination_enabled like '%".$search."%' "; - $sql .= " or destination_description like '%".$search."%' "; - $sql .= ") "; - } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - $total_destinations = $row['num_rows']; - } - else { - $num_rows = 0; - } - - //prepare to page the results - $rows_per_page = 150; - $param = "&search=".$search; - if ($_GET['showall'] && permission_exists('destination_all')) { - $param .= "&showall=true"; - } - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($total_destinations, $param, $rows_per_page); - $offset = $rows_per_page * $page; - - //get the list - $sql = "select * from v_destinations "; - if ($_GET['showall'] && permission_exists('destination_all')) { - if (strlen($search) > 0) { - $sql .= " where "; - } - } else { - $sql .= "where domain_uuid = '$domain_uuid' "; - if (strlen($search) > 0) { - $sql .= " and "; - } - } - if (strlen($search) > 0) { - $sql .= " ("; - $sql .= " destination_type like '%".$search."%' "; - $sql .= " or destination_number like '%".$search."%' "; - $sql .= " or destination_context like '%".$search."%' "; - $sql .= " or destination_enabled like '%".$search."%' "; - $sql .= " or destination_description like '%".$search."%' "; - $sql .= ") "; - } - if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $destination = $prep_statement->fetchAll(); - $destination_count = count($destination); - unset ($prep_statement, $sql); - $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; @@ -171,7 +171,7 @@ else { echo "\n"; if ($destination_count > 0) { - foreach($destination as $row) { + foreach($destinations as $row) { $tr_link = "href='destination_edit.php?id=".$row['destination_uuid']."'"; echo "\n"; if ($_GET['showall'] && permission_exists('destination_all')) { @@ -193,7 +193,7 @@ else { echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $destination, $row_count); + unset($sql, $destinations, $row_count); } //end if results echo "\n"; From f8c2ea5b22d216483cb27b477890c4a37a302534 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Sep 2015 23:23:15 -0600 Subject: [PATCH 014/174] Make the destinations more consistent. --- app/destinations/destinations.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index e145543397..a8b6e99cf5 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -75,7 +75,7 @@ else { if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - $total_destinations = $row['num_rows']; + $num_rows = $row['num_rows']; } else { $num_rows = 0; @@ -89,7 +89,7 @@ else { } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($total_destinations, $param, $rows_per_page); + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; //get the list @@ -118,13 +118,12 @@ else { $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $destinations = $prep_statement->fetchAll(); - $destination_count = count($destination); unset ($prep_statement, $sql); //show the content echo "\n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "\n"; - if ($destination_count > 0) { + if ($num_rows > 0) { foreach($destinations as $row) { $tr_link = "href='destination_edit.php?id=".$row['destination_uuid']."'"; echo "\n"; @@ -204,7 +203,7 @@ else { echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; } - else { - echo " \n"; - } - if ($device_provision_enable == "false") { - echo " \n"; - } - else { - echo " \n"; - } - echo " \n"; - echo "
\n"; - echo $text['description-device_provision_enable']."\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "\n"; echo "\n"; - if (permission_exists('device_line_view') { + if (permission_exists('device_line_view')) { echo " "; echo " "; echo " \n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; + echo "\n"; + echo "
\n"; + echo $text['description-device_template']."\n"; + echo "\n"; + echo "\n"; + } if (permission_exists('device_line_view')) { echo " "; @@ -1198,38 +1211,44 @@ require_once "resources/require.php"; echo "\n"; } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_vendor')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_model')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_firmware')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } if (permission_exists('device_domain')) { echo "\n"; @@ -1292,7 +1311,12 @@ require_once "resources/require.php"; echo " ".$text['label-device_description']."\n"; echo "\n"; echo "\n"; From 2750163d6dcdfcd8f3a8e34a8cd6572b1efb519e Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 12:05:49 -0700 Subject: [PATCH 166/174] Move the description inside the permission condition and adjust 2 of the permissions. --- app/devices/device_edit.php | 570 ++++++++++++++++++------------------ 1 file changed, 286 insertions(+), 284 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 5d32adfa04..f26e2ff17f 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -528,13 +528,13 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; @@ -546,12 +546,13 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; @@ -753,7 +754,9 @@ require_once "resources/require.php"; echo " "; echo " "; } + } + if (permission_exists('device_key_edit')) { $vendor_count = 0; foreach($device_keys as $row) { if ($previous_vendor != $row['device_key_vendor']) { @@ -779,63 +782,85 @@ require_once "resources/require.php"; echo " \n"; } - if (permission_exists('device_profile_view')) { - $x = 0; - foreach($device_keys as $row) { - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor']) { - echo " \n"; - echo " \n"; - echo " \n"; - if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { - echo " \n"; - } else { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { - echo " \n"; - } - //show all the rows in the array + $x = 0; + foreach($device_keys as $row) { + //set the column names + if ($previous_device_key_vendor != $row['device_key_vendor']) { echo " \n"; - echo "\n"; + echo " \n"; + if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { + echo " \n"; + } else { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + //show all the rows in the array + echo " \n"; + echo "\n"; + } + echo " \n"; + echo "\n"; - echo "\n"; + echo "\n"; - echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + //echo " \n"; + echo " \n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - //echo " \n"; - echo " \n"; - echo " \n"; - //set the previous vendor - $previous_device_key_vendor = $row['device_key_vendor']; - //increment the array key - $x++; - } - echo "
".$text['header-destinations']." (".$total_destinations.")".$text['header-destinations']." (".$num_rows.")\n"; if (permission_exists('destination_all')) { @@ -163,14 +162,14 @@ else { echo th_order_by('destination_description', $text['label-destination_description'], $order_by, $order, '', '', $param); echo ""; if (permission_exists('destination_add')) { - if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $total_destinations < $_SESSION['limit']['destinations']['numeric'])) { + if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $num_rows < $_SESSION['limit']['destinations']['numeric'])) { echo "".$v_link_label_add.""; } } echo "
\n"; } if (permission_exists('destination_add')) { - if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $total_destinations < $_SESSION['limit']['destinations']['numeric'])) { + if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $num_rows < $_SESSION['limit']['destinations']['numeric'])) { echo "".$v_link_label_add.""; } } From ceafff2a9afe87e3e769a0f3a1bf6430a650cd20 Mon Sep 17 00:00:00 2001 From: Len Date: Sat, 5 Sep 2015 11:49:42 -0400 Subject: [PATCH 015/174] Update README.md Small edits made to Line 9 and 28 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 386578b474..6e4104093d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ It provides the functionality your business needs and brings corporate-level pho In addition to providing all of the usual PBX functionality, FusionPBX allows you to configure: -- Multi-Tenancy +- Multi-Tenant - Unlimited Extensions - Voicemail-to-Email - Music on Hold @@ -25,7 +25,7 @@ We provide several avenues for you to get your system up and running on your own 1. [Current Documentation](http://wiki.fusionpbx.com/index.php?title=Main_Page) 2. [New Documentation](http://fusionpbx-docs.readthedocs.org/en/latest/) COMING SOON 3. [How to Contribute](http://fusionpbx.com) COMING SOON -4. [IRC](http://webchat.freenode.net/) in the fusionpbx channel +4. [IRC](http://webchat.freenode.net/) in the #fusionpbx channel Commercial Support -------------------------------------- From 06ed8f2998dcc3e6a513a6ecdc53b8c9b12e45c3 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 5 Sep 2015 10:05:43 -0600 Subject: [PATCH 016/174] When *78 or *79 are used for DND update the user status and agent status. --- resources/install/scripts/do_not_disturb.lua | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/resources/install/scripts/do_not_disturb.lua b/resources/install/scripts/do_not_disturb.lua index 8e067860af..97af20b2c4 100644 --- a/resources/install/scripts/do_not_disturb.lua +++ b/resources/install/scripts/do_not_disturb.lua @@ -142,6 +142,37 @@ end dbh:query(sql); + --determine whether to update the dial string + sql = "select * from v_extension_users as e, v_users as u "; + sql = sql .. "where e.extension_uuid = '"..extension_uuid.."' "; + sql = sql .. "and e.user_uuid = u.user_uuid "; + sql = sql .. "and e.domain_uuid = '"..domain_uuid.."' "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n"); + end + status = dbh:query(sql, function(row) + --update the call center status + if (enabled == "true") then + user_status = "Logged Out"; + api:execute("callcenter_config", "agent set status "..row.username.."@"..domain_name.." '"..user_status.."'"); + end + + --update the database user_status + if (enabled == "true") then + user_status = "Do Not Disturb"; + else + user_status = "Available"; + end + sql = sql .. "update v_users set "; + sql = sql .. "user_status = '"..user_status.."' "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and username = '"..row.user_uuid.."' "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n"); + end + dbh:query(sql); + end); + --clear the cache if (extension ~= nil) then api:execute("memcache", "delete directory:"..extension.."@"..domain_name); From 84ee674f814d899e36670e9da020fa312043222a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 5 Sep 2015 10:42:22 -0600 Subject: [PATCH 017/174] Fix the sql in the do_not_disturb.lua. --- resources/install/scripts/do_not_disturb.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/do_not_disturb.lua b/resources/install/scripts/do_not_disturb.lua index 97af20b2c4..2664d40c29 100644 --- a/resources/install/scripts/do_not_disturb.lua +++ b/resources/install/scripts/do_not_disturb.lua @@ -163,7 +163,7 @@ else user_status = "Available"; end - sql = sql .. "update v_users set "; + sql = "update v_users set "; sql = sql .. "user_status = '"..user_status.."' "; sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; sql = sql .. "and username = '"..row.user_uuid.."' "; From be564502df73a93edd09b0a8b11a05f49382dfcd Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 5 Sep 2015 11:26:13 -0600 Subject: [PATCH 018/174] This last change will enable do not disturb to update the user status which will then show in the operator panel. --- resources/install/scripts/do_not_disturb.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/do_not_disturb.lua b/resources/install/scripts/do_not_disturb.lua index 2664d40c29..7c0fccefc9 100644 --- a/resources/install/scripts/do_not_disturb.lua +++ b/resources/install/scripts/do_not_disturb.lua @@ -166,7 +166,7 @@ sql = "update v_users set "; sql = sql .. "user_status = '"..user_status.."' "; sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and username = '"..row.user_uuid.."' "; + sql = sql .. "and user_uuid = '"..row.user_uuid.."' "; if (debug["sql"]) then freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n"); end From 2047fa7859702ad70e9c4031cf7d0803c8805743 Mon Sep 17 00:00:00 2001 From: koldoa Date: Tue, 1 Sep 2015 18:33:26 +0200 Subject: [PATCH 019/174] Random strategy for ring groups --- app/ring_groups/app_languages.php | 11 ++++++++ app/ring_groups/ring_group_edit.php | 1 + .../install/scripts/app/ring_groups/index.lua | 27 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/ring_groups/app_languages.php b/app/ring_groups/app_languages.php index 41e87e22f2..4ce8421826 100644 --- a/app/ring_groups/app_languages.php +++ b/app/ring_groups/app_languages.php @@ -88,6 +88,17 @@ $text['option-rollover']['uk'] = ""; $text['option-rollover']['de-at'] = "Überrollen"; $text['option-rollover']['he'] = ""; +$text['option-random']['en-us'] = "Random"; +$text['option-random']['es-cl'] = "Aleatorio"; +$text['option-random']['pt-pt'] = ""; +$text['option-random']['fr-fr'] = ""; +$text['option-random']['pt-br'] = ""; +$text['option-random']['pl'] = ""; +$text['option-random']['sv-se'] = ""; +$text['option-random']['uk'] = ""; +$text['option-random']['de-at'] = ""; +$text['option-random']['he'] = ""; + $text['option-ptring']['en-us'] = "pt-ring"; $text['option-ptring']['es-cl'] = "pt-ring"; $text['option-ptring']['fr-fr'] = "Portugal"; diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 9d7083e70e..929f7086d6 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -499,6 +499,7 @@ else { echo " \n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo "
\n"; echo $text['description-strategy']."\n"; diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 0cbc8832f5..69076397ab 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -158,6 +158,28 @@ --forward the ring group session:execute("transfer", ring_group_forward_destination.." XML "..context); else + --get the strategy of the ring group, if random, we use random() to order the destinations + sql = [[ + SELECT + r.ring_group_strategy + FROM + v_ring_groups as r, v_ring_group_destinations as d + WHERE + d.ring_group_uuid = r.ring_group_uuid + AND d.ring_group_uuid = ']]..ring_group_uuid..[[' + AND r.domain_uuid = ']]..domain_uuid..[[' + AND r.ring_group_enabled = 'true' + ]]; + + --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + assert(dbh:query(sql, function(row) + if (row.ring_group_strategy == "random") then + sql_order = 'random()' + else + sql_order='d.destination_delay, d.destination_number asc' + end + end)); + --get the ring group destinations sql = [[ SELECT @@ -172,7 +194,7 @@ AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ORDER BY - d.destination_delay, d.destination_number asc + ]]..sql_order..[[ ]]; --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); destinations = {}; @@ -291,6 +313,9 @@ if (ring_group_strategy == "sequence") then delimiter = "|"; end + if (ring_group_strategy == "random") then + delimiter = "|"; + end if (ring_group_strategy == "simultaneous") then delimiter = ","; end From a4ab8ca633cc1796df2e3ed4b94d32114842acfe Mon Sep 17 00:00:00 2001 From: koldoa Date: Wed, 2 Sep 2015 14:24:47 +0200 Subject: [PATCH 020/174] Translation typo --- app/devices/app_languages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index 75ecf92aa3..577792fd96 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -1690,7 +1690,7 @@ $text['label-blf']['ar-eg'] = ""; $text['label-blf']['he'] = ""; $text['label-callers']['en-us'] = "Callers"; -$text['label-callers']['es-cl'] = "Llaamadas"; +$text['label-callers']['es-cl'] = "Llamadas"; $text['label-callers']['pt-pt'] = ""; $text['label-callers']['fr-fr'] = ""; $text['label-callers']['pt-br'] = ""; From 4799974811e9c84425649a7d798943ebbcc08f22 Mon Sep 17 00:00:00 2001 From: koldoa Date: Thu, 3 Sep 2015 11:53:28 +0200 Subject: [PATCH 021/174] Detection of SQL backend for random functions --- .../install/scripts/app/ring_groups/index.lua | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 69076397ab..9e6134f554 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -158,6 +158,16 @@ --forward the ring group session:execute("transfer", ring_group_forward_destination.." XML "..context); else + --first we check what version of SQL are we using + sql = "SELECT version() as version"; + assert(dbh:query(sql, function(row) + if (string.find(row.version, "PostgreSQL")) then + sql_verion = 'postgresql' + else + sql_verion = 'mysql' + end + end)); + --get the strategy of the ring group, if random, we use random() to order the destinations sql = [[ SELECT @@ -170,16 +180,21 @@ AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ]]; - - --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + + assert(dbh:query(sql, function(row) if (row.ring_group_strategy == "random") then - sql_order = 'random()' + if (sql_verion == "postgresql") then + sql_order = 'random()' + end + if (sql_verion == "mysql") then + sql_order = 'rand()' + end else sql_order='d.destination_delay, d.destination_number asc' end end)); - + --get the ring group destinations sql = [[ SELECT @@ -194,7 +209,7 @@ AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ORDER BY - ]]..sql_order..[[ + ]]..sql_order..[[ ]]; --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); destinations = {}; From 319ee702ce77372f4eca9f1a59b07fb71307e2ae Mon Sep 17 00:00:00 2001 From: koldoa Date: Mon, 7 Sep 2015 08:51:22 +0200 Subject: [PATCH 022/174] Script for enterling/leaving a ring group, based on the fifo code --- resources/install/scripts/ring_member.lua | 145 ++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 resources/install/scripts/ring_member.lua diff --git a/resources/install/scripts/ring_member.lua b/resources/install/scripts/ring_member.lua new file mode 100644 index 0000000000..6fc0cedc62 --- /dev/null +++ b/resources/install/scripts/ring_member.lua @@ -0,0 +1,145 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- All Rights Reserved. +-- +-- Contributor(s): +-- Koldo A. Marcos + + +--include config.lua + require "resources.functions.config"; + +--connect to the database + require "resources.functions.database_handle"; + dbh = database_handle('system'); + +sounds_dir = ""; +recordings_dir = ""; +pin_number = ""; +max_tries = "3"; +digit_timeout = "3000"; + + +local random = math.random +local function uuid() + local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' + return string.gsub(template, '[xy]', function (c) + local v = (c == 'x') and random(0, 0xf) or random(8, 0xb) + return string.format('%x', v) + end) +end + +if ( session:ready() ) then + session:answer(); + --session:execute("info", ""); + destination_number = session:getVariable("user_name"); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + ring_group_uuid = session:getVariable("ring_group_uuid"); + + --get info for the ring group + sql = "SELECT * FROM v_ring_groups "; + sql = sql .. "where ring_group_uuid = '"..ring_group_uuid.."' "; + status = dbh:query(sql, function(row) + domain_uuid = row["domain_uuid"]; + end); + + destination_timeout = 15; + destination_delay = 0; + + + + ring_group_destination_uuid = uuid(); + + --pin number is not required + + --press 1 to login and 2 to logout + menu_selection = session:playAndGetDigits(1, 1, max_tries, digit_timeout, "#", "ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+"); + freeswitch.consoleLog("NOTICE", "menu_selection: "..menu_selection.."\n"); + if (menu_selection == "1") then + --first, check to see if is already in that ring group + sql = [[ + SELECT COUNT(*) AS in_group FROM + v_ring_group_destinations + WHERE + domain_uuid = ']]..domain_uuid..[[' + AND ring_group_uuid = ']]..ring_group_uuid..[[' + AND destination_number = ']]..destination_number..[[' + ]]; + + --freeswitch.consoleLog("NOTICE", "ring_group_member: SQL "..sql.."\n"); + + assert(dbh:query(sql, function(row) + if (row.in_group == "0") then + sql = [[ + INSERT INTO + v_ring_group_destinations + ( ring_group_destination_uuid, + domain_uuid, + ring_group_uuid, + destination_number, + destination_delay, + destination_timeout) + VALUES + ( ']]..ring_group_destination_uuid..[[', + ']]..domain_uuid..[[', + ']]..ring_group_uuid..[[', + ']]..destination_number..[[', + ]]..destination_delay..[[, + ]]..destination_timeout..[[) + + ]]; + + --freeswitch.consoleLog("NOTICE", "ring_group_member: SQL "..sql.."\n"); + dbh:query(sql); + + freeswitch.consoleLog("NOTICE", "ring_group_member: LOG IN\n"); + session:streamFile("ivr/ivr-you_are_now_logged_in.wav"); + + else + freeswitch.consoleLog("NOTICE", "ring_group_member: ALREADY LOGGED IN\n"); + session:streamFile("ivr/ivr-you_are_now_logged_in.wav"); + end + end)); + + + end + if (menu_selection == "2") then + sql = [[ + DELETE FROM + v_ring_group_destinations + WHERE + domain_uuid =']]..domain_uuid..[[' + AND ring_group_uuid=']]..ring_group_uuid..[[' + AND destination_number=']]..destination_number..[[' + ]]; + freeswitch.consoleLog("NOTICE", "ring_group_member: SQL "..sql.."\n"); + dbh:query(sql); + + freeswitch.consoleLog("NOTICE", "ring_group_member: LOG OUT\n"); + session:streamFile("ivr/ivr-you_are_now_logged_out.wav"); + end + + --wait for the file to be written before proceeding + --session:sleep(1000); + + --hangup + session:hangup(); +end From 26459f7895c6657489f8ec51f7c2bd91baebf9db Mon Sep 17 00:00:00 2001 From: koldoa Date: Mon, 7 Sep 2015 10:47:57 +0200 Subject: [PATCH 023/174] This should fix some of the group permissions issues from issue #1065 --- app/calls/call_edit.php | 2 +- app/voicemail_greetings/voicemail_greetings.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/calls/call_edit.php b/app/calls/call_edit.php index b9b149b954..33934c39dd 100644 --- a/app/calls/call_edit.php +++ b/app/calls/call_edit.php @@ -63,7 +63,7 @@ else { $sql = "select * from v_extensions "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and extension_uuid = '$extension_uuid' "; - if (!(if_group("admin") || if_group("superadmin"))) { + if (!(permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb'))) { if (count($_SESSION['user']['extension']) > 0) { $sql .= "and ("; $x = 0; diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index 623a832287..865c66353a 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -46,7 +46,7 @@ require_once "resources/check_auth.php"; } //deny access if the user extension is not assigned - if (!(if_group("superadmin") || if_group("admin"))) { + if (!permission_exists('voicemail_greeting_view')) { if (!is_extension_assigned($voicemail_id)) { echo "access denied"; return; From b5e0708599c4248127f56f32ce35eb93952de7eb Mon Sep 17 00:00:00 2001 From: koldoa Date: Mon, 7 Sep 2015 11:48:10 +0200 Subject: [PATCH 024/174] Better code for ring groups --- .../install/scripts/app/ring_groups/index.lua | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 9e6134f554..7a9b596058 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -158,36 +158,25 @@ --forward the ring group session:execute("transfer", ring_group_forward_destination.." XML "..context); else - --first we check what version of SQL are we using - sql = "SELECT version() as version"; - assert(dbh:query(sql, function(row) - if (string.find(row.version, "PostgreSQL")) then - sql_verion = 'postgresql' - else - sql_verion = 'mysql' - end - end)); - --get the strategy of the ring group, if random, we use random() to order the destinations sql = [[ SELECT r.ring_group_strategy FROM - v_ring_groups as r, v_ring_group_destinations as d + v_ring_groups as r WHERE - d.ring_group_uuid = r.ring_group_uuid - AND d.ring_group_uuid = ']]..ring_group_uuid..[[' + ring_group_uuid = ']]..ring_group_uuid..[[' AND r.domain_uuid = ']]..domain_uuid..[[' AND r.ring_group_enabled = 'true' ]]; - + assert(dbh:query(sql, function(row) if (row.ring_group_strategy == "random") then - if (sql_verion == "postgresql") then + if (database["type"] == "postgresql") then sql_order = 'random()' end - if (sql_verion == "mysql") then + if (database["type"] == "mysql") then sql_order = 'rand()' end else From 4bba1c1faf7dc9d7dbcfab11bad933c0381979ba Mon Sep 17 00:00:00 2001 From: koldoa Date: Mon, 7 Sep 2015 12:51:12 +0200 Subject: [PATCH 025/174] This should add better compatibility for more database backends --- resources/install/scripts/app/ring_groups/index.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 7a9b596058..a8c0b8e266 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -173,11 +173,10 @@ assert(dbh:query(sql, function(row) if (row.ring_group_strategy == "random") then - if (database["type"] == "postgresql") then - sql_order = 'random()' - end if (database["type"] == "mysql") then sql_order = 'rand()' + else + sql_order = 'random()' --both postgresql and sqlite uses random() instead of rand() end else sql_order='d.destination_delay, d.destination_number asc' From b1746acb9754c7c7f856f7e2f44450f056d5a030 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 7 Sep 2015 14:52:15 -0600 Subject: [PATCH 026/174] Remove v_conference_center_users as v_meeting_users was used instead. --- app/conference_centers/app_config.php | 39 -- .../conference_center_edit.php | 351 ++++++++---------- 2 files changed, 151 insertions(+), 239 deletions(-) diff --git a/app/conference_centers/app_config.php b/app/conference_centers/app_config.php index bd9078f5f6..464bc6fd51 100644 --- a/app/conference_centers/app_config.php +++ b/app/conference_centers/app_config.php @@ -418,43 +418,4 @@ $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "end_epoch"; $z++; - /* - $y = 4; //table array index - $z = 0; //field array index - $apps[$x]['db'][$y]['table'] = "v_conference_center_users"; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "conference_user_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; - $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; - $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "conference_center_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; - $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_conference_centers"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "conference_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "user_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; - $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; - $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_users"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "user_uuid"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - */ - ?> \ No newline at end of file diff --git a/app/conference_centers/conference_center_edit.php b/app/conference_centers/conference_center_edit.php index 296d504631..0c50504f45 100644 --- a/app/conference_centers/conference_center_edit.php +++ b/app/conference_centers/conference_center_edit.php @@ -62,218 +62,169 @@ else { $conference_center_name = str_replace(" ", "-", $conference_center_name); } -/* -//delete the user from the v_conference_center_users - if ($_GET["a"] == "delete" && permission_exists("conference_center_delete")) { - //set the variables - $user_uuid = check_str($_REQUEST["user_uuid"]); - $conference_center_uuid = check_str($_REQUEST["id"]); - //delete the group from the users - $sql = "delete from v_conference_center_users "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and conference_center_uuid = '".$conference_center_uuid."' "; - $sql .= "and user_uuid = '".$user_uuid."' "; - $db->exec(check_sql($sql)); - //redirect the browser - require_once "resources/header.php"; - echo "\n"; - echo "
Delete Complete
"; - require_once "resources/footer.php"; - return; - } +//process user data + if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { -//add the user to the v_conference_center_users - if (strlen($_REQUEST["user_uuid"]) > 0 && strlen($_REQUEST["id"]) > 0 && $_GET["a"] != "delete") { - //set the variables - $user_uuid = check_str($_REQUEST["user_uuid"]); - $conference_center_uuid = check_str($_REQUEST["id"]); - //assign the user to the extension - $sql_insert = "insert into v_conference_center_users "; - $sql_insert .= "("; - $sql_insert .= "conference_user_uuid, "; - $sql_insert .= "domain_uuid, "; - $sql_insert .= "conference_center_uuid, "; - $sql_insert .= "user_uuid "; - $sql_insert .= ")"; - $sql_insert .= "values "; - $sql_insert .= "("; - $sql_insert .= "'".uuid()."', "; - $sql_insert .= "'".$_SESSION['domain_uuid']."', "; - $sql_insert .= "'".$conference_center_uuid."', "; - $sql_insert .= "'".$user_uuid."' "; - $sql_insert .= ")"; - $db->exec($sql_insert); - //redirect the browser - require_once "resources/header.php"; - echo "\n"; - echo "
Add Complete
"; - require_once "resources/footer.php"; - return; - } -*/ - -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { - - $msg = ''; - if ($action == "update") { - $conference_center_uuid = check_str($_POST["conference_center_uuid"]); - } - - //check for all required data - //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } - if (strlen($conference_center_name) == 0) { $msg .= "Please provide: Name
\n"; } - if (strlen($conference_center_extension) == 0) { $msg .= "Please provide: Extension
\n"; } - if (strlen($conference_center_pin_length) == 0) { $msg .= "Please provide: PIN Length
\n"; } - //if (strlen($conference_center_order) == 0) { $msg .= "Please provide: Order
\n"; } - //if (strlen($conference_center_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($conference_center_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; + $msg = ''; + if ($action == "update") { + $conference_center_uuid = check_str($_POST["conference_center_uuid"]); } - //add or update the database - if ($_POST["persistformvar"] != "true") { - if ($action == "add") { - //prepare the uuids - $conference_center_uuid = uuid(); - $dialplan_uuid = uuid(); - //add the conference - $sql = "insert into v_conference_centers "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "conference_center_uuid, "; - $sql .= "dialplan_uuid, "; - $sql .= "conference_center_name, "; - $sql .= "conference_center_extension, "; - $sql .= "conference_center_pin_length, "; - $sql .= "conference_center_greeting, "; - $sql .= "conference_center_description, "; - $sql .= "conference_center_enabled "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'$domain_uuid', "; - $sql .= "'$conference_center_uuid', "; - $sql .= "'$dialplan_uuid', "; - $sql .= "'$conference_center_name', "; - $sql .= "'$conference_center_extension', "; - $sql .= "'$conference_center_pin_length', "; - $sql .= "'$conference_center_greeting', "; - $sql .= "'$conference_center_description', "; - $sql .= "'$conference_center_enabled' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - //create the dialplan entry - $dialplan_name = $conference_center_name; - $dialplan_order ='333'; - $dialplan_context = $_SESSION['context']; - $dialplan_enabled = 'true'; - $dialplan_description = $conference_center_description; - $app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; - dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); - - // - $dialplan_detail_tag = 'condition'; //condition, action, antiaction - $dialplan_detail_type = 'destination_number'; - $dialplan_detail_data = '^'.$conference_center_extension.'$'; - $dialplan_detail_order = '010'; - $dialplan_detail_group = '2'; - dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); - - // - $dialplan_detail_tag = 'action'; //condition, action, antiaction - $dialplan_detail_type = 'lua'; - $dialplan_detail_data = 'app.lua conference_center'; - $dialplan_detail_order = '020'; - $dialplan_detail_group = '2'; - dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); - - //save the xml - save_dialplan_xml(); - - $_SESSION["message"] = $text['message-add']; - header("Location: conference_centers.php"); + //check for all required data + //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } + if (strlen($conference_center_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($conference_center_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($conference_center_pin_length) == 0) { $msg .= "Please provide: PIN Length
\n"; } + //if (strlen($conference_center_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($conference_center_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($conference_center_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; return; - } //if ($action == "add") + } - if ($action == "update") { - //update the conference center extension - $sql = "update v_conference_centers set "; - $sql .= "conference_center_name = '$conference_center_name', "; - $sql .= "conference_center_extension = '$conference_center_extension', "; - $sql .= "conference_center_pin_length = '$conference_center_pin_length', "; - $sql .= "conference_center_greeting = '$conference_center_greeting', "; - $sql .= "conference_center_description = '$conference_center_description', "; - $sql .= "conference_center_enabled = '$conference_center_enabled' "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and conference_center_uuid = '$conference_center_uuid'"; - $db->exec(check_sql($sql)); - unset($sql); + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //prepare the uuids + $conference_center_uuid = uuid(); + $dialplan_uuid = uuid(); + //add the conference + $sql = "insert into v_conference_centers "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "conference_center_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "conference_center_name, "; + $sql .= "conference_center_extension, "; + $sql .= "conference_center_pin_length, "; + $sql .= "conference_center_greeting, "; + $sql .= "conference_center_description, "; + $sql .= "conference_center_enabled "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$conference_center_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$conference_center_name', "; + $sql .= "'$conference_center_extension', "; + $sql .= "'$conference_center_pin_length', "; + $sql .= "'$conference_center_greeting', "; + $sql .= "'$conference_center_description', "; + $sql .= "'$conference_center_enabled' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); - //udpate the conference center dialplan - $sql = "update v_dialplans set "; - $sql .= "dialplan_name = '$conference_center_name', "; - if (strlen($dialplan_order) > 0) { - $sql .= "dialplan_order = '333', "; - } - $sql .= "dialplan_context = '".$_SESSION['context']."', "; - $sql .= "dialplan_enabled = 'true', "; - $sql .= "dialplan_description = '$conference_center_description' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_uuid = '$dialplan_uuid' "; - $db->query($sql); - unset($sql); + //create the dialplan entry + $dialplan_name = $conference_center_name; + $dialplan_order ='333'; + $dialplan_context = $_SESSION['context']; + $dialplan_enabled = 'true'; + $dialplan_description = $conference_center_description; + $app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; + dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); - //update dialplan detail condition - $sql = "update v_dialplan_details set "; - $sql .= "dialplan_detail_data = '^".$conference_center_extension."$' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_detail_tag = 'condition' "; - $sql .= "and dialplan_detail_type = 'destination_number' "; - $sql .= "and dialplan_uuid = '$dialplan_uuid' "; - $db->query($sql); - unset($sql); + // + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$conference_center_extension.'$'; + $dialplan_detail_order = '010'; + $dialplan_detail_group = '2'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); - //update dialplan detail action - $dialplan_detail_type = 'lua'; - $dialplan_detail_data = 'app.lua conference_center'; - $sql = "update v_dialplan_details set "; - $sql .= "dialplan_detail_type = '".$dialplan_detail_type."', "; - $sql .= "dialplan_detail_data = '".$dialplan_detail_data."' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_detail_tag = 'action' "; - $sql .= "and dialplan_detail_type = 'lua' "; - $sql .= "and dialplan_uuid = '$dialplan_uuid' "; - $db->query($sql); + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'lua'; + $dialplan_detail_data = 'app.lua conference_center'; + $dialplan_detail_order = '020'; + $dialplan_detail_group = '2'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); - //syncrhonize configuration - save_dialplan_xml(); + //save the xml + save_dialplan_xml(); - //apply settings reminder - $_SESSION["reload_xml"] = true; - - //clear the cache - $cache = new cache; - $cache->delete("dialplan:".$_SESSION["context"]); - - //redirect the browser - $_SESSION["message"] = $text['message-update']; + $_SESSION["message"] = $text['message-add']; header("Location: conference_centers.php"); return; - } //if ($action == "update") - } //if ($_POST["persistformvar"] != "true") -} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + } //if ($action == "add") + + if ($action == "update") { + //update the conference center extension + $sql = "update v_conference_centers set "; + $sql .= "conference_center_name = '$conference_center_name', "; + $sql .= "conference_center_extension = '$conference_center_extension', "; + $sql .= "conference_center_pin_length = '$conference_center_pin_length', "; + $sql .= "conference_center_greeting = '$conference_center_greeting', "; + $sql .= "conference_center_description = '$conference_center_description', "; + $sql .= "conference_center_enabled = '$conference_center_enabled' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and conference_center_uuid = '$conference_center_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //udpate the conference center dialplan + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '$conference_center_name', "; + if (strlen($dialplan_order) > 0) { + $sql .= "dialplan_order = '333', "; + } + $sql .= "dialplan_context = '".$_SESSION['context']."', "; + $sql .= "dialplan_enabled = 'true', "; + $sql .= "dialplan_description = '$conference_center_description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //update dialplan detail condition + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '^".$conference_center_extension."$' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'condition' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //update dialplan detail action + $dialplan_detail_type = 'lua'; + $dialplan_detail_data = 'app.lua conference_center'; + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_type = '".$dialplan_detail_type."', "; + $sql .= "dialplan_detail_data = '".$dialplan_detail_data."' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'lua' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + + //redirect the browser + $_SESSION["message"] = $text['message-update']; + header("Location: conference_centers.php"); + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //function to show the list of sound files // moved to functions.php From f9a7759a9ff5b915340b5e40396e7e187615a189 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 7 Sep 2015 23:14:39 -0600 Subject: [PATCH 027/174] Update the domain code separate the domain code from the presentation. --- core/domain_settings/domains.php | 43 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/core/domain_settings/domains.php b/core/domain_settings/domains.php index 7ddf64c420..d3bb0121ae 100644 --- a/core/domain_settings/domains.php +++ b/core/domain_settings/domains.php @@ -75,7 +75,7 @@ else { $domain->db = $db; $domain->set(); - // on domain change, redirect user + //redirect the user if ($_SESSION["login"]["destination"] != '') { // to default, or domain specific, login destination header("Location: ".PROJECT_PATH.$_SESSION["login"]["destination"]["url"]); @@ -90,7 +90,6 @@ else { //includes require_once "resources/header.php"; $document['title'] = $text['title-domains']; - require_once "resources/paging.php"; //get the http values and set them as variables @@ -100,24 +99,6 @@ else { $order = check_str($_GET["order"]); } -//show the header and the search - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['header-domains']."\n"; - echo " \n"; - echo " "; - echo " "; - echo " \n"; - echo "
\n"; - echo " ".$text['description-domains']."

\n"; - echo "
\n"; - //prepare to page the results $sql = "select count(*) as num_rows from v_domains "; if (strlen($search) > 0) { @@ -146,7 +127,7 @@ else { list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; -//get the list +//get the domains $sql = "select * from v_domains "; if (strlen($search) > 0) { $sql .= "where ("; @@ -177,6 +158,24 @@ else { $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; +//show the header and the search + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['header-domains']."\n"; + echo "
\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
\n"; + echo " ".$text['description-domains']."

\n"; + echo "
\n"; + echo "\n"; echo "\n"; echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); @@ -190,7 +189,6 @@ else { echo "\n"; if (count($domains) > 0) { - global $c, $row_style, $text, $v_link_label_edit, $v_link_label_delete; foreach ($domains as $domain_uuid => $domain) { $tr_link = (permission_exists('domain_edit')) ? "href='domain_edit.php?id=".$domain_uuid."'" : null; echo "\n"; @@ -245,4 +243,5 @@ else { //include the footer require_once "resources/footer.php"; + ?> \ No newline at end of file From bde805bd4c76f8bb576ad2776b3fb32a93947255 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 8 Sep 2015 14:12:01 -0600 Subject: [PATCH 028/174] Fix DND use error/user_busy instead of loopback/*99[extension] --- app/calls/resources/classes/do_not_disturb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/calls/resources/classes/do_not_disturb.php b/app/calls/resources/classes/do_not_disturb.php index 37fcef5e29..0b675867d8 100644 --- a/app/calls/resources/classes/do_not_disturb.php +++ b/app/calls/resources/classes/do_not_disturb.php @@ -96,7 +96,7 @@ include "root.php"; //set the dial string if ($this->enabled == "true") { - $this->dial_string = "loopback/*99".$this->extension; + $this->dial_string = "error/user_busy"; } else { $this->dial_string = ''; From 0bf97e79bde92658bdf163b9fbfa2fac2c0097c7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 8 Sep 2015 14:38:46 -0600 Subject: [PATCH 029/174] Change DND from loopback/*99[ext] to error/user_busy. --- resources/install/scripts/do_not_disturb.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/do_not_disturb.lua b/resources/install/scripts/do_not_disturb.lua index 7c0fccefc9..085ecedb68 100644 --- a/resources/install/scripts/do_not_disturb.lua +++ b/resources/install/scripts/do_not_disturb.lua @@ -92,7 +92,7 @@ --set the dial string if (enabled == "true") then local user = (number_alias and #number_alias > 0) and number_alias or extension; - dial_string = "loopback/*99"..user; + dial_string = "error/user_busy"; end --set do not disturb From 4cb99be806a244afe2d42aa0676f08824a4992f2 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Sep 2015 10:22:14 +0400 Subject: [PATCH 030/174] Add. Basic cache class Fix. When memcache stopped and mod_memcache loaded dialplan did not build from DB. --- .../resources/scripts/dialplan/dialplan.lua | 30 ++++----- .../scripts/resources/functions/cache.lua | 63 +++++++++++++++++++ 2 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 resources/install/scripts/resources/functions/cache.lua diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index c838fcf782..232612118d 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -24,15 +24,21 @@ -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. + local cache = require"resources.functions.cache" + --get the cache - if (trim(api:execute("module_exists", "mod_memcache")) == "true") then - XML_STRING = trim(api:execute("memcache", "get dialplan:" .. call_context)); - else - XML_STRING = "-ERR NOT FOUND"; + XML_STRING, err = cache.get("dialplan:" .. call_context) + + if debug['cache'] then + if XML_STRING then + freeswitch.consoleLog("notice", "[xml_handler] dialplan:"..call_context.." source: memcache\n"); + elseif err ~= 'NOT FOUND' then + freeswitch.consoleLog("notice", "[xml_handler] error get element form cache: " .. err .. "\n"); + end end --set the cache - if (XML_STRING == "-ERR NOT FOUND") then + if not XML_STRING then --connect to the database require "resources.functions.database_handle"; @@ -287,8 +293,9 @@ XML_STRING = table.concat(xml, "\n"); --set the cache - tmp = XML_STRING:gsub("\\", "\\\\"); - result = trim(api:execute("memcache", "set dialplan:" .. call_context .. " '"..tmp:gsub("'", "'").."' "..expire["dialplan"])); + if cache.support() then + cache.set("dialplan:" .. call_context, XML_STRING, expire["dialplan"]) + end --send the xml to the console if (debug["xml_string"]) then @@ -304,12 +311,5 @@ --close the database connection dbh:release(); - else - --replace the ' back to a single quote - XML_STRING = XML_STRING:gsub("'", "'"); - - --send to the console - if (debug["cache"]) then - freeswitch.consoleLog("notice", "[xml_handler] dialplan:"..call_context.." source: memcache\n"); - end end + diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua new file mode 100644 index 0000000000..458328a82d --- /dev/null +++ b/resources/install/scripts/resources/functions/cache.lua @@ -0,0 +1,63 @@ +-- @usage cache = require "resources.functions.cache" +-- value = cache.get(key) +-- if not value then +-- ... +-- cache.set(key, value, expire) +-- end +-- + +require "resources.functions.trim"; + +local api = api or freeswitch.API(); + +local Cache = {} + +local function check_error(result) + result = trim(result or '') + + if result and result:sub(1, 4) == '-ERR' then + return nil, trim(result:sub(5)) + end + + if result == 'INVALID COMMAND!' and not Cache.support() then + return nil, 'INVALID COMMAND' + end + + return result +end + +function Cache.support() + -- assume it is not unloadable + if Cache._support then + return true + end + Cache._support = (trim(api:execute('module_exists', 'mod_memcache')) == 'true') + return Cache._support +end + +--- Get element from cache +-- +-- @tparam key string +-- @return[1] string value +-- @return[2] nil +-- @return[2] error string `e.g. 'NOT FOUND' +-- @note error string does not contain `-ERR` prefix +function Cache.get(key) + local result, err = check_error(api:execute('memcache', 'get ' .. key)) + if not result then return nil, err end + return (result:gsub("'", "'")) +end + +function Cache.set(key, value, expire) + value = value:gsub("'", "'"):gsub("\\", "\\\\") + expire = expire and tostring(expire) or "" + return check_error(api:execute("memcache", "set " .. key .. " '" .. value .. "' " .. expire)) +end + +function Cache.del(key) + local result, err = check_error(api:execute("memcache", "set " .. key .. " '" .. value .. "' " .. expire)) + if not result then return nil, err end + return result == '+OK' +end + +return Cache From 528d04b942db624c26a6232af0e5b6161c3c1ce0 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Sep 2015 10:45:49 +0400 Subject: [PATCH 031/174] Add. Basic log class. --- .../resources/scripts/dialplan/dialplan.lua | 9 +-- .../scripts/resources/functions/log.lua | 70 +++++++++++++++++++ 2 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 resources/install/scripts/resources/functions/log.lua diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index 232612118d..5ccc18f06b 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -25,15 +25,16 @@ -- POSSIBILITY OF SUCH DAMAGE. local cache = require"resources.functions.cache" + local log = require"resources.functions.log"["xml_handler"] --get the cache XML_STRING, err = cache.get("dialplan:" .. call_context) if debug['cache'] then if XML_STRING then - freeswitch.consoleLog("notice", "[xml_handler] dialplan:"..call_context.." source: memcache\n"); + log.notice("dialplan:"..call_context.." source: memcache"); elseif err ~= 'NOT FOUND' then - freeswitch.consoleLog("notice", "[xml_handler] error get element form cache: " .. err .. "\n"); + log.notice("error get element form cache: " .. err); end end @@ -105,7 +106,7 @@ sql = sql .. "ELSE 100 END, "; sql = sql .. "s.dialplan_detail_order asc "; if (debug["sql"]) then - freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); + log.notice("SQL: " .. sql); end x = 0; dbh:query(sql, function(row) @@ -306,7 +307,7 @@ --send to the console if (debug["cache"]) then - freeswitch.consoleLog("notice", "[xml_handler] dialplan:"..call_context.." source: database\n"); + log.notice("dialplan:"..call_context.." source: database"); end --close the database connection diff --git a/resources/install/scripts/resources/functions/log.lua b/resources/install/scripts/resources/functions/log.lua new file mode 100644 index 0000000000..b6cb59652b --- /dev/null +++ b/resources/install/scripts/resources/functions/log.lua @@ -0,0 +1,70 @@ +-- @usage local log = require"resources.functions.log"["xml_handler"] +-- log.notice("hello world") +-- log.noticef("%s %s", "hello", "world") +-- -- log if debug.SQL or debug.xml_handler.SQL then +-- log.tracef("SQL", "SQL is %s", sql) + +local function log(name, level, msg) + freeswitch.consoleLog(level, "[" .. name .. "] " .. msg .. "\n") +end + +local function logf(name, level, ...) + return log(name, level, string.format(...)) +end + +local function trace(type, name, ...) + local t = debug[name] + if t and t[type] ~= nil then + if t[type] then + return log(name, ...) + end + end + if debug[type] then + log(name, ...) + end +end + +local function tracef(type, name, level, ...) + local t = debug[name] + if t and t[type] ~= nil then + if t[type] then + return logf(name, ...) + end + end + if debug[type] then + logf(name, ...) + end +end + +local LEVELS = { + 'error', + 'warning', + 'notice', + 'info', +} + +local TRACE_LEVEL = 'notice' + +local function make_log(name) + local logger = {} + for i = 1, #LEVELS do + logger[ LEVELS[i] ] = function(...) return log(name, LEVELS[i], ...) end; + logger[ LEVELS[i] .. "f" ] = function(...) return logf(name, LEVELS[i], ...) end; + end + + logger.trace = function(type, ...) + trace(type, name, TRACE_LEVEL, ...) + end + + logger.tracef = function(type, ...) + tracef(type, name, TRACE_LEVEL, ...) + end + + return logger +end + +return setmetatable({}, {__index = function(self, name) + local logger = make_log(name) + self[name] = logger + return logger +end}) \ No newline at end of file From 8391e996f0757330c5c9696355448ebabe1304bf Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Sep 2015 16:26:41 +0400 Subject: [PATCH 032/174] Fix. Allow change Call Forward number without enable it. --- app/calls/resources/classes/call_forward.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/calls/resources/classes/call_forward.php b/app/calls/resources/classes/call_forward.php index 74688572ed..3825ec3304 100644 --- a/app/calls/resources/classes/call_forward.php +++ b/app/calls/resources/classes/call_forward.php @@ -136,15 +136,17 @@ include "root.php"; //update the extension $sql = "update v_extensions set "; + if (strlen($this->forward_all_destination) == 0) { + $sql .= "forward_all_destination = null, "; + } + else { + $sql .= "forward_all_destination = '$this->forward_all_destination', "; + } if (strlen($this->forward_all_destination) == 0 || $this->forward_all_enabled == "false") { - if (strlen($this->forward_all_destination) == 0) { - $sql .= "forward_all_destination = null, "; - } $sql .= "dial_string = null, "; $sql .= "forward_all_enabled = 'false' "; } else { - $sql .= "forward_all_destination = '$this->forward_all_destination', "; $sql .= "dial_string = '".check_str($this->dial_string)."', "; $sql .= "forward_all_enabled = 'true' "; } From dcc08a22650210c319999269f5a1dbc00ea1078b Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Sep 2015 16:52:52 +0400 Subject: [PATCH 033/174] Fix. Not found is treat as success for delete operation. --- resources/install/scripts/resources/functions/cache.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua index 458328a82d..29c1b9d57e 100644 --- a/resources/install/scripts/resources/functions/cache.lua +++ b/resources/install/scripts/resources/functions/cache.lua @@ -56,7 +56,12 @@ end function Cache.del(key) local result, err = check_error(api:execute("memcache", "set " .. key .. " '" .. value .. "' " .. expire)) - if not result then return nil, err end + if not result then + if err == 'NOT FOUND' then + return true + end + return nil, err + end return result == '+OK' end From 1319723eae0c1f6e2cbded2e626ada645d0fcebb Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 9 Sep 2015 09:43:00 -0600 Subject: [PATCH 034/174] Remove a space and replace with a tab. --- core/domain_settings/domains.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/domain_settings/domains.php b/core/domain_settings/domains.php index d3bb0121ae..0fd58dd893 100644 --- a/core/domain_settings/domains.php +++ b/core/domain_settings/domains.php @@ -131,8 +131,8 @@ else { $sql = "select * from v_domains "; if (strlen($search) > 0) { $sql .= "where ("; - $sql .= " domain_name like '%".$search."%' "; - $sql .= " or domain_description like '%".$search."%' "; + $sql .= " domain_name like '%".$search."%' "; + $sql .= " or domain_description like '%".$search."%' "; $sql .= ") "; } if (strlen($order_by) == 0) { From 42229e0738c36829c8bb05bba9bb08bd9ea087e9 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 9 Sep 2015 10:01:00 -0600 Subject: [PATCH 035/174] This will hide outbound route toll allow lua from those wihtout the outbound_route_toll_allow_lua permission. This feature works only for countries that are hard coded in the toll allow code. So at this time preferred method of toll allow is via the dialplan. --- app/dialplan_outbound/app_config.php | 2 ++ .../dialplan_outbound_add.php | 28 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/dialplan_outbound/app_config.php b/app/dialplan_outbound/app_config.php index d6809327f9..86d4512543 100644 --- a/app/dialplan_outbound/app_config.php +++ b/app/dialplan_outbound/app_config.php @@ -41,4 +41,6 @@ $apps[$x]['permissions'][5]['groups'][] = "superadmin"; $apps[$x]['permissions'][5]['description'] = "Add outbound routes for any gateways on any domain."; + $apps[$x]['permissions'][6]['name'] = "outbound_route_toll_allow_lua"; + ?> \ No newline at end of file diff --git a/app/dialplan_outbound/dialplan_outbound_add.php b/app/dialplan_outbound/dialplan_outbound_add.php index 5029f7f899..7a9c4a48e1 100644 --- a/app/dialplan_outbound/dialplan_outbound_add.php +++ b/app/dialplan_outbound/dialplan_outbound_add.php @@ -937,19 +937,21 @@ function type_onchange(dialplan_detail_type) { echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + if (permission_exists('outbound_route_toll_allow_lua')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } echo "\n"; echo ""; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; From 6e11352ff7b7472dca6ee5f460e575d287945ace Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 19 Sep 2015 17:51:16 -0600 Subject: [PATCH 048/174] Another case where autocomplete creates a problem. New user account creation does not benefit from autocomplete. It assumes the user is the currently logged in user which is not what you want on a form to add new users. This code adds an autocomplete honey pot to defeat the browser developers poor assumption. --- core/users/signup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/users/signup.php b/core/users/signup.php index 458dac1b8e..c15e757fc0 100644 --- a/core/users/signup.php +++ b/core/users/signup.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -298,16 +298,16 @@ if (count($_POST) > 0 && check_str($_POST["persistform"]) != "1") { echo "
\n"; - echo " ".$text['label-toll_allow']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-enable-toll_allow']."\n"; - echo "
\n"; + echo " ".$text['label-toll_allow']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-enable-toll_allow']."\n"; + echo "
\n"; From ebb61f955c38a0de48a558e3fa06ba02a08c9351 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 10 Sep 2015 14:23:11 +0400 Subject: [PATCH 036/174] Add. database class ```Lua local Database = require "resources.functions.database" local dbh = Database.new('system') --get the domain_uuid if (domain_uuid == nil) and (domain_name ~= nil) then local sql = "SELECT domain_uuid FROM v_domains " sql = sql .. "WHERE domain_name='" .. domain_name .. "';" domain_uuid = dbh:first_value(sql) end local dbh_switch = Database.new('switch') -- check also SQLite file. local row = dbh_switch:first_row(sql) if row then ... end ``` --- .../scripts/resources/functions/database.lua | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 resources/install/scripts/resources/functions/database.lua diff --git a/resources/install/scripts/resources/functions/database.lua b/resources/install/scripts/resources/functions/database.lua new file mode 100644 index 0000000000..a8f7f662c6 --- /dev/null +++ b/resources/install/scripts/resources/functions/database.lua @@ -0,0 +1,107 @@ +require 'resources.config' +require 'resources.functions.database_handle' + +local unpack = unpack or table.unpack + +local Database = {} do + +Database.__index = Database + +function Database.new(name) + local dbh = assert(name) + if type(name) == 'string' then + if name == 'switch' and file_exists(database_dir.."/core.db") then + dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db") + else + dbh = database_handle(name) + end + end + assert(dbh:connected()) + + local self = setmetatable({ + _dbh = dbh; + }, Database) + + return self +end + +function Database:query(sql, fn) + return self._dbh:query(sql, fn) +end + +function Database:first_row(sql) + local result + local ok, err = self:query(sql, function(row) + result = row + return 1 + end) + if not ok then return nil, err end + return result +end + +function Database:first_value(sql) + local result, err = self:first_row(sql) + if not result then return nil, err end + local k, v = next(result) + return v +end + +function Database:first(sql, ...) + local result, err = self:first_row(sql) + if not result then return nil, err end + local t, n = {}, select('#', ...) + for i = 1, n do + t[i] = result[(select(i, ...))] + end + return unpack(t, 1, n) +end + +function Database:fetch_all(sql) + local result = {} + local ok, err = self:query(sql, function(row) + result[#result + 1] = row + end) + if not ok then return nil, err end + return result +end + +function Database:release(sql) + if self._dbh then + self._dbh:release() + self._dbh = nil + end +end + +function Database:connected(sql) + return self._dbh and self._dbh:connected() +end + +function Database.__self_test__() + local db = Database.new('system') + assert(db:connected()) + + assert("1" == db:first_value("select 1 as v")) + + local t = assert(db:first_row("select 1 as v")) + assert(t.v == "1") + + t = assert(db:fetch_all("select 1 as v union all select 2 as v")) + assert(#t == 2) + assert(t[1].v == "1") + assert(t[2].v == "2") + + local a, b = assert(db:first("select 1 as b, 2 as a", 'a', 'b')) + assert(a == "2") + assert(b == "1") + + -- assert(nil == db:first_value("some non sql query")) + + db:release() + assert(not db:connected()) +end + +end + +-- Database.__self_test__() + +return Database \ No newline at end of file From 6304c470cfdfe39c8eb5a693fcb44e70c805c348 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 10 Sep 2015 14:36:30 +0400 Subject: [PATCH 037/174] Fix. load `file_exists` function --- resources/install/scripts/resources/functions/database.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/resources/functions/database.lua b/resources/install/scripts/resources/functions/database.lua index a8f7f662c6..50349b1b14 100644 --- a/resources/install/scripts/resources/functions/database.lua +++ b/resources/install/scripts/resources/functions/database.lua @@ -1,4 +1,5 @@ require 'resources.config' +require 'resources.functions.file_exists' require 'resources.functions.database_handle' local unpack = unpack or table.unpack @@ -76,8 +77,8 @@ function Database:connected(sql) return self._dbh and self._dbh:connected() end -function Database.__self_test__() - local db = Database.new('system') +function Database.__self_test__(name) + local db = Database.new(name or 'system') assert(db:connected()) assert("1" == db:first_value("select 1 as v")) From c21657cc7f286d6a85d1f2cd4eb76245aa6caa74 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 11 Sep 2015 14:04:38 -0600 Subject: [PATCH 038/174] Change the directory.lua xml parameter from sip_force_contact to sip-force-contact. --- .../app/xml_handler/resources/scripts/directory/directory.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua index 0b0d601ad9..cf50cd5de6 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua @@ -437,7 +437,7 @@ table.insert(xml, [[ ]]); end if (string.len(sip_force_contact) > 0) then - table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); end if (string.len(sip_force_expires) > 0) then table.insert(xml, [[ ]]); From b65d0b20539faa2e1d7cced38bfac7360d849c4d Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 11 Sep 2015 15:20:31 -0600 Subject: [PATCH 039/174] Hide the email body from the email log. --- secure/v_mailto.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/secure/v_mailto.php b/secure/v_mailto.php index dbc74d26f7..e81de0c6b1 100644 --- a/secure/v_mailto.php +++ b/secure/v_mailto.php @@ -18,7 +18,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -275,7 +275,7 @@ //add the body to the email $body_plain = rip_tags($body); - echo "body_plain = $body_plain\n"; + //echo "body_plain = $body_plain\n"; if ((substr($body, 0, 5) == "ContentType = "text/html"; $mail->Body = $body; @@ -361,4 +361,4 @@ fwrite($fp, $content); fclose($fp); */ -?> +?> \ No newline at end of file From b3c53ae6f55ac2ca0d45d35c80726e2d7fc16d7a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 11 Sep 2015 16:18:40 -0600 Subject: [PATCH 040/174] Email template add indentation to make it more readable. --- .../resources/templates/de/at/email_body.tpl | 118 +++++++++--------- .../resources/templates/de/de/email_body.tpl | 118 +++++++++--------- .../resources/templates/en/us/email_body.tpl | 118 +++++++++--------- 3 files changed, 177 insertions(+), 177 deletions(-) diff --git a/resources/install/scripts/app/voicemail/resources/templates/de/at/email_body.tpl b/resources/install/scripts/app/voicemail/resources/templates/de/at/email_body.tpl index 3d459931aa..7430f13f03 100644 --- a/resources/install/scripts/app/voicemail/resources/templates/de/at/email_body.tpl +++ b/resources/install/scripts/app/voicemail/resources/templates/de/at/email_body.tpl @@ -1,61 +1,61 @@ - - - - - - - -
-Neue Sprachnachricht -
- - - - - - - - - - - - - - - - - - -
-Nebenstelle - -${account}@${domain_name} -
-Anrufer - -${caller_id_number} -
-Nachricht - -${message} -
-Länge - -${message_duration} -
-
+ + + + + + + +
+ Neue Sprachnachricht +
+ + + + + + + + + + + + + + + + + + +
+ Nebenstelle + + ${account} +
+ Anrufer + + ${caller_id_number} +
+ Nachricht + + ${message} +
+ Länge + + ${message_duration} +
+
diff --git a/resources/install/scripts/app/voicemail/resources/templates/de/de/email_body.tpl b/resources/install/scripts/app/voicemail/resources/templates/de/de/email_body.tpl index 3d459931aa..82275cbc2b 100644 --- a/resources/install/scripts/app/voicemail/resources/templates/de/de/email_body.tpl +++ b/resources/install/scripts/app/voicemail/resources/templates/de/de/email_body.tpl @@ -1,61 +1,61 @@ - - - - - - - -
-Neue Sprachnachricht -
- - - - - - - - - - - - - - - - - - -
-Nebenstelle - -${account}@${domain_name} -
-Anrufer - -${caller_id_number} -
-Nachricht - -${message} -
-Länge - -${message_duration} -
-
+ + + + + + + +
+ Neue Sprachnachricht +
+ + + + + + + + + + + + + + + + + + +
+ Nebenstelle + + ${account} +
+ Anrufer + + ${caller_id_number} +
+ Nachricht + + ${message} +
+ Länge + + ${message_duration} +
+
diff --git a/resources/install/scripts/app/voicemail/resources/templates/en/us/email_body.tpl b/resources/install/scripts/app/voicemail/resources/templates/en/us/email_body.tpl index 4c1d78b5f9..34cb21aaf7 100644 --- a/resources/install/scripts/app/voicemail/resources/templates/en/us/email_body.tpl +++ b/resources/install/scripts/app/voicemail/resources/templates/en/us/email_body.tpl @@ -1,61 +1,61 @@ - - - - - - - -
-New Voicemail -
- - - - - - - - - - - - - - - - - - -
-To - -${account}@${domain_name} -
-From - -${caller_id_number} -
-Message - -${message} -
-Length - -${message_duration} -
-
+ + + + + + + +
+ New Voicemail +
+ + + + + + + + + + + + + + + + + + +
+ To + + ${account} +
+ From + + ${caller_id_number} +
+ Message + + ${message} +
+ Length + + ${message_duration} +
+
\ No newline at end of file From e0f9865d7179f69866a0203b04c1931dee81cd1f Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 14 Sep 2015 19:08:06 -0600 Subject: [PATCH 041/174] Fix the redirect for the ACL. --- app/access_controls/access_control_node_delete.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/access_controls/access_control_node_delete.php b/app/access_controls/access_control_node_delete.php index 57e1696d6c..473913808e 100644 --- a/app/access_controls/access_control_node_delete.php +++ b/app/access_controls/access_control_node_delete.php @@ -33,6 +33,6 @@ else { //redirect the user $_SESSION['message'] = $text['message-delete']; - header('Location: access_control_node_edit.php?id='.$access_control_uuid); + header('Location: access_control_edit.php?id='.$access_control_uuid); ?> \ No newline at end of file From 7191eae559c53d89bc88a5141f9b67b423c2abd4 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 15 Sep 2015 18:02:46 +0400 Subject: [PATCH 042/174] Fix. `cache.del` method. Fix. cache.set returns boolean value. Add. basic self_test --- .../scripts/resources/functions/cache.lua | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua index 29c1b9d57e..974e327dd9 100644 --- a/resources/install/scripts/resources/functions/cache.lua +++ b/resources/install/scripts/resources/functions/cache.lua @@ -51,11 +51,13 @@ end function Cache.set(key, value, expire) value = value:gsub("'", "'"):gsub("\\", "\\\\") expire = expire and tostring(expire) or "" - return check_error(api:execute("memcache", "set " .. key .. " '" .. value .. "' " .. expire)) + local ok, err = check_error(api:execute("memcache", "set " .. key .. " '" .. value .. "' " .. expire)) + if not ok then return nil, err end + return ok == '+OK' end function Cache.del(key) - local result, err = check_error(api:execute("memcache", "set " .. key .. " '" .. value .. "' " .. expire)) + local result, err = check_error(api:execute("memcache", "delete " .. key)) if not result then if err == 'NOT FOUND' then return true @@ -65,4 +67,23 @@ function Cache.del(key) return result == '+OK' end +function Cache._self_test() + assert(Cache.support()) + Cache.del("a") + + local ok, err = Cache.get("a") + assert(nil == ok) + assert(err == "NOT FOUND") + + local s = "hello \\ ' world" + assert(true == Cache.set("a", s)) + assert(s == Cache.get("a")) + + assert(true == Cache.del("a")) +end + +-- if debug.self_test then +-- Cache._self_test() +-- end + return Cache From 94749f105d508349c6ca8086397830009bb59ac1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 15 Sep 2015 08:49:37 -0600 Subject: [PATCH 043/174] Add multi-lingual support to the missed call emails. --- .../scripts/app/failure_handler/index.lua | 84 ++++++++++++------- .../install/scripts/app/hangup/index.lua | 82 +++++++++++------- .../resources/templates/en/us/email_body.tpl | 1 + .../templates/en/us/email_subject.tpl | 1 + .../install/scripts/app/ring_groups/index.lua | 79 +++++++++++------ 5 files changed, 164 insertions(+), 83 deletions(-) create mode 100644 resources/install/scripts/app/missed_calls/resources/templates/en/us/email_body.tpl create mode 100644 resources/install/scripts/app/missed_calls/resources/templates/en/us/email_subject.tpl diff --git a/resources/install/scripts/app/failure_handler/index.lua b/resources/install/scripts/app/failure_handler/index.lua index 6e174911ce..72410b3ddf 100644 --- a/resources/install/scripts/app/failure_handler/index.lua +++ b/resources/install/scripts/app/failure_handler/index.lua @@ -31,43 +31,69 @@ require "resources.functions.config"; require "resources.functions.explode"; require "resources.functions.trim"; + require "resources.functions.base64"; --check the missed calls function missed() if (missed_call_app ~= nil and missed_call_data ~= nil) then if (missed_call_app == "email") then - headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; - headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; - headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; - headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end - subject = "Missed Call from ${caller_id_name} <${caller_id_number}>"; - subject = subject:gsub("${caller_id_name}", caller_id_name); - subject = subject:gsub("${caller_id_number}", caller_id_number); - subject = subject:gsub("${sip_to_user}", sip_to_user); - subject = subject:gsub("${dialed_user}", dialed_user); + --prepare the files + file_subject = scripts_dir.."/app/missed_calls/resources/templates/"..default_language.."/"..default_dialect.."/email_subject.tpl"; + file_body = scripts_dir.."/app/missed_calls/resources/templates/"..default_language.."/"..default_dialect.."/email_body.tpl"; + if (not file_exists(file_subject)) then + file_subject = scripts_dir.."/app/missed_calls/resources/templates/en/us/email_subject.tpl"; + file_body = scripts_dir.."/app/missed_calls/resources/templates/en/us/email_body.tpl"; + end + + --prepare the headers + headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; + headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; + headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; + headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; - body = "Missed Call from ${caller_id_name} <${caller_id_number}> to ${sip_to_user} ext ${dialed_user}"; - body = body:gsub("${caller_id_name}", caller_id_name); - body = body:gsub("${caller_id_number}", caller_id_number); - body = body:gsub("${sip_to_user}", sip_to_user); - body = body:gsub("${dialed_user}", dialed_user); + --prepare the subject + local f = io.open(file_subject, "r"); + local subject = f:read("*all"); + f:close(); + subject = subject:gsub("${caller_id_name}", caller_id_name); + subject = subject:gsub("${caller_id_number}", caller_id_number); + subject = subject:gsub("${sip_to_user}", sip_to_user); + subject = subject:gsub("${dialed_user}", dialed_user); + subject = trim(subject); + subject = '=?utf-8?B?'..base64.encode(subject)..'?='; - body = body:gsub(" ", " "); - body = body:gsub("%s+", ""); - body = body:gsub(" ", " "); - body = body:gsub("\n", ""); - body = body:gsub("\n", ""); - body = body:gsub("'", "'"); - body = body:gsub([["]], """); - body = trim(body); - - cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; - if (debug["info"]) then - freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); - end - api = freeswitch.API(); - result = api:executeString(cmd); + --prepare the body + local f = io.open(file_body, "r"); + local body = f:read("*all"); + f:close(); + body = body:gsub("${caller_id_name}", caller_id_name); + body = body:gsub("${caller_id_number}", caller_id_number); + body = body:gsub("${sip_to_user}", sip_to_user); + body = body:gsub("${dialed_user}", dialed_user); + body = body:gsub(" ", " "); + body = body:gsub("%s+", ""); + body = body:gsub(" ", " "); + body = body:gsub("\n", ""); + body = body:gsub("\n", ""); + body = body:gsub("'", "'"); + body = body:gsub([["]], """); + body = trim(body); + + --send the email + cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; + if (debug["info"]) then + freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); + end + api = freeswitch.API(); + result = api:executeString(cmd); end end end diff --git a/resources/install/scripts/app/hangup/index.lua b/resources/install/scripts/app/hangup/index.lua index 9a77d819cc..425f2f2f52 100644 --- a/resources/install/scripts/app/hangup/index.lua +++ b/resources/install/scripts/app/hangup/index.lua @@ -28,7 +28,8 @@ require "resources.functions.config"; require "resources.functions.explode"; require "resources.functions.trim"; - -- require "resources.functions.file_exists"; + require "resources.functions.base64"; + require "resources.functions.file_exists"; --create the api object api = freeswitch.API(); @@ -37,37 +38,62 @@ function missed() if (missed_call_app ~= nil and missed_call_data ~= nil) then if (missed_call_app == "email") then - headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; - headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; - headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; - headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end - subject = "Missed Call from ${caller_id_name} <${caller_id_number}>"; - subject = subject:gsub("${caller_id_name}", caller_id_name); - subject = subject:gsub("${caller_id_number}", caller_id_number); - subject = subject:gsub("${sip_to_user}", sip_to_user); - subject = subject:gsub("${dialed_user}", dialed_user); + --prepare the files + file_subject = scripts_dir.."/app/missed_calls/resources/templates/"..default_language.."/"..default_dialect.."/email_subject.tpl"; + file_body = scripts_dir.."/app/missed_calls/resources/templates/"..default_language.."/"..default_dialect.."/email_body.tpl"; + if (not file_exists(file_subject)) then + file_subject = scripts_dir.."/app/missed_calls/resources/templates/en/us/email_subject.tpl"; + file_body = scripts_dir.."/app/missed_calls/resources/templates/en/us/email_body.tpl"; + end - body = "Missed Call from ${caller_id_name} <${caller_id_number}> to ${sip_to_user} ext ${dialed_user}"; - body = body:gsub("${caller_id_name}", caller_id_name); - body = body:gsub("${caller_id_number}", caller_id_number); - body = body:gsub("${sip_to_user}", sip_to_user); - body = body:gsub("${dialed_user}", dialed_user); + --prepare the headers + headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; + headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; + headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; + headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; - body = body:gsub(" ", " "); - body = body:gsub("%s+", ""); - body = body:gsub(" ", " "); - body = body:gsub("\n", ""); - body = body:gsub("\n", ""); - body = body:gsub("'", "'"); - body = body:gsub([["]], """); - body = trim(body); + --prepare the subject + local f = io.open(file_subject, "r"); + local subject = f:read("*all"); + f:close(); + subject = subject:gsub("${caller_id_name}", caller_id_name); + subject = subject:gsub("${caller_id_number}", caller_id_number); + subject = subject:gsub("${sip_to_user}", sip_to_user); + subject = subject:gsub("${dialed_user}", dialed_user); + subject = trim(subject); + subject = '=?utf-8?B?'..base64.encode(subject)..'?='; - cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; - if (debug["info"]) then - freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); - end - result = api:executeString(cmd); + --prepare the body + local f = io.open(file_body, "r"); + local body = f:read("*all"); + f:close(); + body = body:gsub("${caller_id_name}", caller_id_name); + body = body:gsub("${caller_id_number}", caller_id_number); + body = body:gsub("${sip_to_user}", sip_to_user); + body = body:gsub("${dialed_user}", dialed_user); + body = body:gsub(" ", " "); + body = body:gsub("%s+", ""); + body = body:gsub(" ", " "); + body = body:gsub("\n", ""); + body = body:gsub("\n", ""); + body = body:gsub("'", "'"); + body = body:gsub([["]], """); + body = trim(body); + + --send the emails + cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; + if (debug["info"]) then + freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); + end + result = api:executeString(cmd); end end end diff --git a/resources/install/scripts/app/missed_calls/resources/templates/en/us/email_body.tpl b/resources/install/scripts/app/missed_calls/resources/templates/en/us/email_body.tpl new file mode 100644 index 0000000000..cde2b1bac3 --- /dev/null +++ b/resources/install/scripts/app/missed_calls/resources/templates/en/us/email_body.tpl @@ -0,0 +1 @@ +Missed Call from ${caller_id_name} <${caller_id_number}> to ${sip_to_user} ext ${dialed_user} \ No newline at end of file diff --git a/resources/install/scripts/app/missed_calls/resources/templates/en/us/email_subject.tpl b/resources/install/scripts/app/missed_calls/resources/templates/en/us/email_subject.tpl new file mode 100644 index 0000000000..0b961e6975 --- /dev/null +++ b/resources/install/scripts/app/missed_calls/resources/templates/en/us/email_subject.tpl @@ -0,0 +1 @@ +Missed Call from ${caller_id_name} <${caller_id_number}> \ No newline at end of file diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index a8c0b8e266..31a31ee532 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -34,6 +34,8 @@ --include functions require "resources.functions.trim"; require "resources.functions.explode"; + require "resources.functions.base64"; + require "resources.functions.file_exists"; --get the variables domain_name = session:getVariable("domain_name"); @@ -119,36 +121,61 @@ function missed() if (missed_call_app ~= nil and missed_call_data ~= nil) then if (missed_call_app == "email") then - headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; - headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; - headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; - headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end - subject = "Missed Call from ${caller_id_name} <${caller_id_number}> ${ring_group_name}"; - subject = subject:gsub("${caller_id_name}", caller_id_name); - subject = subject:gsub("${caller_id_number}", caller_id_number); - subject = subject:gsub("${ring_group_name}", ring_group_name); + --prepare the files + file_subject = scripts_dir.."/app/missed_calls/resources/templates/"..default_language.."/"..default_dialect.."/email_subject.tpl"; + file_body = scripts_dir.."/app/missed_calls/resources/templates/"..default_language.."/"..default_dialect.."/email_body.tpl"; + if (not file_exists(file_subject)) then + file_subject = scripts_dir.."/app/missed_calls/resources/templates/en/us/email_subject.tpl"; + file_body = scripts_dir.."/app/missed_calls/resources/templates/en/us/email_body.tpl"; + end - body = "Missed Call from ${caller_id_name} <${caller_id_number}> to ${ring_group_name}"; - body = body:gsub("${caller_id_name}", caller_id_name); - body = body:gsub("${caller_id_number}", caller_id_number); - body = body:gsub("${ring_group_name}", ring_group_name); + --prepare the headers + headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; + headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; + headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; + headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; - body = body:gsub(" ", " "); - body = body:gsub("%s+", ""); - body = body:gsub(" ", " "); - body = body:gsub("\n", ""); - body = body:gsub("\n", ""); - body = body:gsub("'", "'"); - body = body:gsub([["]], """); - body = trim(body); + --prepare the subject + local f = io.open(file_subject, "r"); + local subject = f:read("*all"); + f:close(); + subject = subject:gsub("${caller_id_name}", caller_id_name); + subject = subject:gsub("${caller_id_number}", caller_id_number); + subject = subject:gsub("${ring_group_name}", ring_group_name); + subject = trim(subject); + subject = '=?utf-8?B?'..base64.encode(subject)..'?='; - cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; - if (debug["info"]) then - freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); - end - api = freeswitch.API(); - result = api:executeString(cmd); + --prepare the body + local f = io.open(file_body, "r"); + local body = f:read("*all"); + f:close(); + body = body:gsub("${caller_id_name}", caller_id_name); + body = body:gsub("${caller_id_number}", caller_id_number); + body = body:gsub("${ring_group_name}", ring_group_name); + body = body:gsub(" ", " "); + body = body:gsub("%s+", ""); + body = body:gsub(" ", " "); + body = body:gsub("\n", ""); + body = body:gsub("\n", ""); + body = body:gsub("'", "'"); + body = body:gsub([["]], """); + body = trim(body); + + --send the email + cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; + if (debug["info"]) then + freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); + end + api = freeswitch.API(); + result = api:executeString(cmd); end end end From cd0c777f6bf407be5284f80a452da5be904d1ce8 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 15 Sep 2015 10:09:16 -0600 Subject: [PATCH 044/174] Get the channel variable in a way that will work with hangup. --- resources/install/scripts/app/hangup/index.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/app/hangup/index.lua b/resources/install/scripts/app/hangup/index.lua index 425f2f2f52..fa15e2f520 100644 --- a/resources/install/scripts/app/hangup/index.lua +++ b/resources/install/scripts/app/hangup/index.lua @@ -39,9 +39,9 @@ if (missed_call_app ~= nil and missed_call_data ~= nil) then if (missed_call_app == "email") then --set the sounds path for the language, dialect and voice - default_language = session:getVariable("default_language"); - default_dialect = session:getVariable("default_dialect"); - default_voice = session:getVariable("default_voice"); + default_language = env:getHeader("default_language"); + default_dialect = env:getHeader("default_dialect"); + default_voice = env:getHeader("default_voice"); if (not default_language) then default_language = 'en'; end if (not default_dialect) then default_dialect = 'us'; end if (not default_voice) then default_voice = 'callie'; end From aebea2c55d116782e8dce9d85f2653bac82617b1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 15 Sep 2015 21:53:14 -0600 Subject: [PATCH 045/174] Remove the is_numeric on format_phone. --- core/domain_settings/domains.php | 5 +++++ resources/functions.php | 16 +++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/core/domain_settings/domains.php b/core/domain_settings/domains.php index 0fd58dd893..47bc275265 100644 --- a/core/domain_settings/domains.php +++ b/core/domain_settings/domains.php @@ -87,6 +87,11 @@ else { } } +//redirect the user + if (file_exists($_SERVER["DOCUMENT_ROOT"]."/app/domains/domains.php")) { + $href = '/app/domains/domains.php'; + } + //includes require_once "resources/header.php"; $document['title'] = $text['title-domains']; diff --git a/resources/functions.php b/resources/functions.php index faffbe9bf5..8ae34eb285 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -771,15 +771,13 @@ function format_string ($format, $data) { //get the format and use it to format the phone number function format_phone($phone_number) { - if (is_numeric($phone_number)) { - foreach ($_SESSION["format"]["phone"] as &$format) { - $format_count = substr_count($format, 'x'); - $format_count = $format_count + substr_count($format, 'R'); - $format_count = $format_count + substr_count($format, 'r'); - if ($format_count == strlen($phone_number)) { - //format the number - $phone_number = format_string($format, $phone_number); - } + foreach ($_SESSION["format"]["phone"] as &$format) { + $format_count = substr_count($format, 'x'); + $format_count = $format_count + substr_count($format, 'R'); + $format_count = $format_count + substr_count($format, 'r'); + if ($format_count == strlen($phone_number)) { + //format the number + $phone_number = format_string($format, $phone_number); } } return $phone_number; From 1d4e62b2f5884a555cd6f9cb42bda2f53a8255f0 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 18 Sep 2015 12:04:52 +0400 Subject: [PATCH 046/174] Fix. Show CDR details when set `showall` --- app/xml_cdr/xml_cdr_details.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 2009380b4a..aca8978688 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -47,7 +47,7 @@ else { //get the cdr string from the database $sql = "select * from v_xml_cdr "; if ($_GET['showall'] && permission_exists('xml_cdr_all')) { - if ($sql_where) { $sql .= "where uuid = '$uuid' "; } + $sql .= "where uuid = '$uuid' "; } else { $sql .= "where uuid = '$uuid' and domain_uuid = '$domain_uuid' "; } From f8aa2ec2071ae1ae30ab67780796605ccb7f793a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 19 Sep 2015 17:42:02 -0600 Subject: [PATCH 047/174] Browser developers disabled autocomplete in most browser. A move that makes an assumption that autocomplete is always good. In this particular case it creates a bug. There are a few legitimate reasons to disable autocomplete. In this case I'm disabling it as we are only updating the password when its provided by the user. In this case the user may be and administrator changing a user a password in this case autocomplete would offer the wrong password. Another case have two password fields that must match if both passwords are empty then the passwords are not updated allowing for other user settings to be updated. --- core/users/usersupdate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/users/usersupdate.php b/core/users/usersupdate.php index 56857dc39d..10bab4cc32 100644 --- a/core/users/usersupdate.php +++ b/core/users/usersupdate.php @@ -462,7 +462,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") { echo "
".$text['label-username'].""; if (if_group("admin") || if_group("superadmin")) { - echo " "; + echo " "; } else { echo " ".$username; @@ -472,7 +472,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") { echo "
".$text['label-password']."
".$text['label-confirm_password']."
"; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; From ba83a0f99e0569465cbf1d95333ba5c4afbae5f3 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 19 Sep 2015 17:59:07 -0600 Subject: [PATCH 049/174] Another situation where autocomplete=off prevented a bug. Provisioning a devcie by adding sip registration information for device provisioning in this case autocomplete always fills in incorrect information. --- app/devices/device_edit.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index cc2f8ddcb7..a9861e6422 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -217,6 +217,7 @@ require_once "resources/require.php"; //array cleanup $x = 0; + unset($_POST["autocomplete"][$x]); foreach ($_POST["device_lines"] as $row) { //unset the empty row if (strlen($row["line_number"]) == 0) { @@ -502,6 +503,7 @@ require_once "resources/require.php"; \n"; + echo ""; echo "
".$text['label-username']."
".$text['label-password']."
".$text['label-confirm_password']."
".$text['label-email']."
\n"; echo "\n"; echo ""; - echo " "; } //device settings - if (permission_exists('device_setting_add')) { + if (permission_exists('device_setting_edit')) { echo " "; echo " "; echo " \n"; } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_username_password')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; } - else { - $label = $device_alternate[0]['device_label']; - if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; } - if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; } - echo "
"; From a7079e337c4262f4aedd499df29da039b331baa4 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 19 Sep 2015 18:02:31 -0600 Subject: [PATCH 050/174] Adding autocomplete="off" back in case browser developers realize there are legitimate reasons to use it. --- core/users/signup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/users/signup.php b/core/users/signup.php index c15e757fc0..9d00b2d919 100644 --- a/core/users/signup.php +++ b/core/users/signup.php @@ -298,16 +298,16 @@ if (count($_POST) > 0 && check_str($_POST["persistform"]) != "1") { echo ""; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; echo " "; From 969e02328e8b384da0128e0ac17ff71931f9f1b9 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 19 Sep 2015 18:13:15 -0600 Subject: [PATCH 051/174] Fix the removal of the autocomplete field. --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index a9861e6422..84c101e1ad 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -217,7 +217,7 @@ require_once "resources/require.php"; //array cleanup $x = 0; - unset($_POST["autocomplete"][$x]); + unset($_POST["autocomplete"]); foreach ($_POST["device_lines"] as $row) { //unset the empty row if (strlen($row["line_number"]) == 0) { From a4b7af35603d5d0f55f4ada238fe3ebf463e7f65 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 19 Sep 2015 18:19:23 -0600 Subject: [PATCH 052/174] Another case where automcomplete bombs. Accounts -> Extensions password is used for registration not for a login. In FusionPBX if the password is left empty it would automatically create a new password. However auto complete instead puts in the login password this is an undesirable bug that this update fixes by adding a honey pot for the password. --- app/extensions/extension_edit.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index 882809e939..9d1739a0ea 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -982,7 +982,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "}\n"; echo ""; - echo "
\n"; + echo "\n"; + echo ""; echo "
".$text['label-username']."
".$text['label-password']."
".$text['label-confirm_password']."
".$text['label-email']."
\n"; echo "\n"; if ($action == "add") { @@ -1042,7 +1043,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-password']."\n"; echo "\n"; echo "\n"; From e5a0134ec6c36e44d0828301b20c9c194c25cd78 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 22 Sep 2015 19:33:41 +0400 Subject: [PATCH 053/174] Fix. Intercept enterprise ring group. With enterprise call each outbound channel has its own call_uuid. But we have to use `intercept` for call_uuid of inbound channel. --- .../install/scripts/app/ring_groups/index.lua | 15 ++++++++++++++ resources/install/scripts/intercept.lua | 11 +++++++--- resources/install/scripts/intercept_group.lua | 18 +++++++++++++---- .../resources/functions/channel_utils.lua | 20 +++++++++++++++++++ 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 resources/install/scripts/resources/functions/channel_utils.lua diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 31a31ee532..3a99d108af 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -27,6 +27,8 @@ -- Mark J Crane -- Luis Daniel Lucio Qurioz +local log = require "resources.functions.log".ring_group + --connect to the database require "resources.functions.database_handle"; dbh = database_handle('system'); @@ -618,10 +620,23 @@ end freeswitch.consoleLog("NOTICE", "[ring group] app_data: "..app_data.."\n"); session:execute("bridge", app_data); + -- log.noticef("bridge done: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false") end --timeout destination if (app_data ~= nil) then + if ring_group_strategy == "enterprise" + and ( true + --- I see 2 errors here `failure` and `PICKED_OFF` + --- but they be more. I think check `answered` is enough. + -- or session:getVariable("originate_disposition") == "failure" + -- or session:getVariable("originate_disposition") == "PICKED_OFF" + ) + and session:answered() then + -- for enterprise calls when intercept we get "failure" but session answered + return + end + if (session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT" or session:getVariable("originate_disposition") == "NO_ANSWER" or session:getVariable("originate_disposition") == "NO_USER_RESPONSE" diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index d6845a940b..a18f0d17b5 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -48,6 +48,7 @@ --add the function require "resources.functions.trim"; + require "resources.functions.channel_utils"; --exits the script if we didn't connect properly assert(dbh:connected()); @@ -119,7 +120,7 @@ if ( session:ready() ) then callee_num = ''; --check the database to get the uuid of a ringing call - sql = "select call_uuid as uuid, hostname, callee_num, ip_addr from channels "; + sql = "select uuid, call_uuid, hostname, callee_num, ip_addr from channels "; sql = sql .. "where callstate in ('RINGING', 'EARLY') "; --sql = sql .. "AND direction = 'outbound' "; if (extension) then @@ -132,11 +133,15 @@ if ( session:ready() ) then if (debug["sql"]) then freeswitch.consoleLog("NOTICE", "sql "..sql.."\n"); end - dbh:query(sql, function(result) + dbh:query(sql, function(result) --for key, val in pairs(result) do -- freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); --end - uuid = result.uuid; + if result.uuid == result.call_uuid then + uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or row.uuid + else + uuid = result.call_uuid; + end call_hostname = result.hostname; callee_num = result.callee_num; end); diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index 32b1f4ef17..4db4e8793b 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -35,11 +35,19 @@ --add the function require "resources.functions.explode"; + require "resources.functions.trim"; + require "resources.functions.channel_utils"; + +--prepare the api object + api = freeswitch.API(); --connect to the database require "resources.functions.database_handle"; dbh = database_handle('system'); +--get the hostname + hostname = trim(api:execute("switchname", "")); + --check if the session is ready if ( session:ready() ) then --answer the session @@ -163,7 +171,7 @@ --check the database to get the uuid of a ringing call call_hostname = ""; - sql = "SELECT call_uuid AS uuid, hostname, ip_addr FROM channels "; + sql = "SELECT uuid, call_uuid, hostname, ip_addr FROM channels "; sql = sql .. "WHERE callstate in ('RINGING', 'EARLY') "; --sql = sql .. "AND direction = 'outbound' "; sql = sql .. "AND ("; @@ -189,14 +197,16 @@ --for key, val in pairs(row) do -- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n"); --end - uuid = row.uuid; + if row.uuid == row.call_uuid then + uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or row.uuid + else + uuid = row.call_uuid; + end call_hostname = row.hostname; ip_addr = row.ip_addr; end); end ---get the hostname - hostname = freeswitch.getGlobalVariable("hostname"); freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n"); --intercept a call that is ringing diff --git a/resources/install/scripts/resources/functions/channel_utils.lua b/resources/install/scripts/resources/functions/channel_utils.lua new file mode 100644 index 0000000000..a078939d2e --- /dev/null +++ b/resources/install/scripts/resources/functions/channel_utils.lua @@ -0,0 +1,20 @@ + +local api = api or freeswitch.API() + +function channel_variable(uuid, name) + local result = api:executeString("uuid_getvar " .. uuid .. " " .. name) + + if result:sub(1, 4) == '-ERR' then return nil, result end + if result == '_undef_' then return false end + + return result +end + +function channel_evalute(uuid, cmd) + local result = api:executeString("eval uuid:" .. uuid .. " " .. cmd) + + if result:sub(1, 4) == '-ERR' then return nil, result end + if result == '_undef_' then return false end + + return result +end From d0c42fff378f349854ea863e1abc283577afe3e1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 22 Sep 2015 18:35:20 -0600 Subject: [PATCH 054/174] Comment out unset autocomplete for the moment. --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 84c101e1ad..ea3dc1788a 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -217,7 +217,7 @@ require_once "resources/require.php"; //array cleanup $x = 0; - unset($_POST["autocomplete"]); + //unset($_POST["autocomplete"]); foreach ($_POST["device_lines"] as $row) { //unset the empty row if (strlen($row["line_number"]) == 0) { From 6a796d37e07de3cfcbda7d289136ccffb04d6e66 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 22 Sep 2015 18:36:09 -0600 Subject: [PATCH 055/174] Add comment out the hidden field for now. --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index ea3dc1788a..26bf7d747c 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -503,7 +503,7 @@ require_once "resources/require.php"; \n"; - echo ""; + //echo ""; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " ".$text['description-password']."\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; } + echo th_order_by('hostname', $text['label-hostname'], $order_by, $order); echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order); echo "\n"; echo " \n"; + echo " \n"; if ($fp) { if ($row["enabled"] == "true") { $response = switch_gateway_status($row["gateway_uuid"]); diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua index 6656f619f3..52e70dc563 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua @@ -119,6 +119,7 @@ sql = "select * from v_gateways "; sql = sql .. "where enabled = 'true' and profile = '"..sip_profile_name.."' "; end + sql = sql .. "and (g.hostname = '" .. hostname.. "' or g.hostname is null or g.hostname = '') "; if (debug["sql"]) then freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); end From 1c0f05fa6c6c87c34c21b458acfcf6098dd5ae15 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 4 Oct 2015 10:50:05 -0600 Subject: [PATCH 079/174] Fix the gateways list so it displays the hostname in the right place. --- app/gateways/gateways.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index 8ee5d35354..f517fd5354 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -136,7 +136,7 @@ else { } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); $rows_per_page = 150; @@ -172,7 +172,7 @@ else { echo "\n"; if ($num_rows > 0) { - foreach($result as $row) { + foreach($gateways as $row) { $tr_link = (permission_exists('gateway_edit')) ? "href='gateway_edit.php?id=".$row['gateway_uuid']."'" : null; echo "\n"; echo " \n"; echo " \n"; - echo " \n"; if ($fp) { if ($row["enabled"] == "true") { $response = switch_gateway_status($row["gateway_uuid"]); @@ -213,6 +212,7 @@ else { echo " \n"; echo " \n"; } + echo " \n"; if ($row["enabled"] == "true") { echo " \n"; } @@ -232,11 +232,11 @@ else { } if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $gateways, $row_count); } //end if results echo "\n"; - echo ""; + echo " "; } - echo "
"; From 8976d5e5b31a56db4d911473dd25cf1303e2d075 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 23 Sep 2015 13:08:22 +0400 Subject: [PATCH 056/174] Add. intercept for call center calls --- resources/install/scripts/intercept.lua | 4 +++- resources/install/scripts/intercept_group.lua | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index a18f0d17b5..7f0d8bdca3 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -138,7 +138,9 @@ if ( session:ready() ) then -- freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); --end if result.uuid == result.call_uuid then - uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or row.uuid + uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or + channel_variable(result.uuid, 'cc_member_session_uuid') or + result.uuid else uuid = result.call_uuid; end diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index 4db4e8793b..4ba42b71be 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -198,7 +198,9 @@ -- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n"); --end if row.uuid == row.call_uuid then - uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or row.uuid + uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or + channel_variable(row.uuid, 'cc_member_session_uuid') or + row.uuid else uuid = row.call_uuid; end From 92baa64183625fdc118a75c98216e948df705d2a Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 23 Sep 2015 14:40:05 +0400 Subject: [PATCH 057/174] Add. intercept for fifo calls --- resources/install/scripts/intercept.lua | 1 + resources/install/scripts/intercept_group.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index 7f0d8bdca3..a7a6695731 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -140,6 +140,7 @@ if ( session:ready() ) then if result.uuid == result.call_uuid then uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or channel_variable(result.uuid, 'cc_member_session_uuid') or + channel_variable(result.uuid, 'fifo_bridge_uuid') or result.uuid else uuid = result.call_uuid; diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index 4ba42b71be..845666c96e 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -200,6 +200,7 @@ if row.uuid == row.call_uuid then uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or channel_variable(row.uuid, 'cc_member_session_uuid') or + channel_variable(row.uuid, 'fifo_bridge_uuid') or row.uuid else uuid = row.call_uuid; From 5d9bb1b9d17e373b496b51a96ca514e7ce55fa20 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 23 Sep 2015 20:09:16 -0600 Subject: [PATCH 058/174] Allow a device that is logged in already to be replaced with a new alternate device. --- .../install/scripts/app/provision/index.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/app/provision/index.lua b/resources/install/scripts/app/provision/index.lua index 5eba2c844a..0173356e3b 100644 --- a/resources/install/scripts/app/provision/index.lua +++ b/resources/install/scripts/app/provision/index.lua @@ -121,7 +121,22 @@ result = session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-fail_auth.wav"); end ---remove the previous device and send a sync command to it +--this device already has an alternate find the correct device_uuid and then override current one + if (authorized == 'true' and action == "login" and device_uuid_alternate ~= nil) then + sql = [[SELECT * FROM v_devices ]]; + sql = sql .. [[WHERE device_uuid_alternate = ']]..device_uuid..[[' ]]; + sql = sql .. [[AND domain_uuid = ']]..domain_uuid..[[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n"); + end + dbh:query(sql, function(row) + if (row.device_uuid_alternate ~= nil) then + device_uuid = row.device_uuid; + end + end); + end + +--remove the alternate device from another device so that it can be added to this device if (authorized == 'true' and action == "login") then sql = [[SELECT * FROM v_device_lines ]]; sql = sql .. [[WHERE device_uuid = ']]..device_uuid_alternate..[[' ]]; @@ -135,7 +150,7 @@ sql = sql .. [[WHERE device_uuid_alternate = ']]..device_uuid_alternate..[[' ]]; sql = sql .. [[AND domain_uuid = ']]..domain_uuid..[[' ]]; if (debug["sql"]) then - --freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n"); + freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n"); end dbh:query(sql); --send a sync command to the previous device From af4e06ecd9a278990332a21a408c8cec594ab78c Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 00:09:58 +0200 Subject: [PATCH 059/174] do not display voicemail sql debug messages --- .../app/voicemail/resources/functions/message_waiting.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua index 176910f5a6..7143b7625d 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua @@ -32,7 +32,7 @@ sql = [[SELECT extension, number_alias from v_extensions WHERE domain_uuid = ']] .. domain_uuid ..[[' AND (mwi_account = ']]..voicemail_id..[[' or mwi_account = ']]..voicemail_id..[[@]]..domain_name..[[')]]; - --if (debug["sql"]) then + if (debug["sql"]) then freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n"); --end status = dbh:query(sql, function(row) @@ -74,4 +74,4 @@ event:addHeader("MWI-Voice-Message", message_count.."/0 ("..message_count.."/0)"); event:fire(); end - end \ No newline at end of file + end From e8b79cb783238917be6e23dc8c61ae16d899cbfd Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 13:13:55 +0200 Subject: [PATCH 060/174] forgot commenting out end --- .../app/voicemail/resources/functions/message_waiting.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua index 7143b7625d..b1225075bc 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua @@ -34,7 +34,7 @@ AND (mwi_account = ']]..voicemail_id..[[' or mwi_account = ']]..voicemail_id..[[@]]..domain_name..[[')]]; if (debug["sql"]) then freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n"); - --end + end status = dbh:query(sql, function(row) if (string.len(row["number_alias"]) > 0) then table.insert(accounts, row["number_alias"]); From 180ee43f0f7dca19fa19fd8ea5f9022d74b15cde Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 00:11:38 +0200 Subject: [PATCH 061/174] prepared img tag for high resolution (retina) images --- app/xml_cdr/xml_cdr.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 83a15eb7ad..a667148085 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -471,21 +471,21 @@ else { switch ($row['direction']) { case "inbound" : if ($row['billsec'] == 0) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; break; case "outbound" : if ($row['billsec'] == 0) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; break; case "local" : if ($row['billsec'] == 0) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; break; default: echo " "; From 6b5384330469a58672249c46e4d4aa52b449e081 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 01:09:29 +0200 Subject: [PATCH 062/174] fixed fax destination with * or + in number --- resources/switch.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/switch.php b/resources/switch.php index ff873d1ca7..a6b97eb273 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -500,7 +500,8 @@ function outbound_route_to_bridge ($domain_uuid, $destination_number) { global $db; $destination_number = trim($destination_number); - if (is_numeric($destination_number)) { + preg_match('/^[\*\+0-9]*$/', $destination_number, $matches, PREG_OFFSET_CAPTURE); + if (count($matches) > 0) { //not found, continue to process the function } else { @@ -1442,4 +1443,4 @@ if (!function_exists('save_switch_xml')) { } } -?> \ No newline at end of file +?> From ae4ec80038a52874d075ea1103795b37b4e0cd00 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 00:21:23 +0200 Subject: [PATCH 063/174] fixed provisioning with http_domain_filter off --- app/provision/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/provision/index.php b/app/provision/index.php index edd3b02cc2..fa20304c10 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -77,6 +77,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); $domain_uuid = $row["domain_uuid"]; } unset($result, $prep_statement); + $_SESSION['domain_uuid'] = $domain_uuid; //get the domain name $domain_name = $_SESSION['domains'][$domain_uuid]['domain_name']; @@ -311,4 +312,4 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); return $needed_parts ? false : $data; } -?> \ No newline at end of file +?> From c633065798bd60de7c2d2d467bd606420c9f82d3 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Thu, 24 Sep 2015 09:00:51 +0200 Subject: [PATCH 064/174] latest german translations --- app/fifo/app_menu.php | 8 ++++---- app/follow_me/app_menu.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/fifo/app_menu.php b/app/fifo/app_menu.php index 136a9c66a7..23d13ed651 100644 --- a/app/fifo/app_menu.php +++ b/app/fifo/app_menu.php @@ -3,9 +3,9 @@ $apps[$x]['menu'][0]['title']['en-us'] = "Queues"; $apps[$x]['menu'][0]['title']['es-cl'] = "Colas"; $apps[$x]['menu'][0]['title']['es-mx'] = "Colas"; -$apps[$x]['menu'][0]['title']['de-de'] = ""; -$apps[$x]['menu'][0]['title']['de-ch'] = ""; -$apps[$x]['menu'][0]['title']['de-at'] = ""; +$apps[$x]['menu'][0]['title']['de-de'] = "Warteschlangen"; +$apps[$x]['menu'][0]['title']['de-ch'] = "Warteschlangen"; +$apps[$x]['menu'][0]['title']['de-at'] = "Warteschlangen"; $apps[$x]['menu'][0]['title']['fr-fr'] = "Queues"; $apps[$x]['menu'][0]['title']['fr-ca'] = ""; $apps[$x]['menu'][0]['title']['fr-ch'] = ""; @@ -19,4 +19,4 @@ $apps[$x]['menu'][0]['path'] = "/app/dialplan/dialplans.php?app_uuid=16589224-c8 $apps[$x]['menu'][0]['groups'][] = "admin"; $apps[$x]['menu'][0]['groups'][] = "superadmin"; -?> \ No newline at end of file +?> diff --git a/app/follow_me/app_menu.php b/app/follow_me/app_menu.php index 15e922e343..6054e217f0 100644 --- a/app/follow_me/app_menu.php +++ b/app/follow_me/app_menu.php @@ -2,9 +2,9 @@ $apps[$x]['menu'][0]['title']['en-us'] = "Follow Me"; $apps[$x]['menu'][0]['title']['es-mx'] = "Sígueme"; - $apps[$x]['menu'][0]['title']['de-de'] = ""; - $apps[$x]['menu'][0]['title']['de-ch'] = ""; - $apps[$x]['menu'][0]['title']['de-at'] = ""; + $apps[$x]['menu'][0]['title']['de-de'] = "Follow Me"; + $apps[$x]['menu'][0]['title']['de-ch'] = "Follow Me"; + $apps[$x]['menu'][0]['title']['de-at'] = "Follow Me"; $apps[$x]['menu'][0]['title']['fr-fr'] = "Follow Me"; $apps[$x]['menu'][0]['title']['fr-ca'] = ""; $apps[$x]['menu'][0]['title']['fr-ch'] = ""; @@ -18,4 +18,4 @@ $apps[$x]['menu'][0]['groups'][] = "admin"; $apps[$x]['menu'][0]['groups'][] = "superadmin"; -?> \ No newline at end of file +?> From 63383196365eef8361279e67d45dedf8878722e7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Sep 2015 08:56:44 -0600 Subject: [PATCH 065/174] Dialplan page add mute=true back again. --- app/dialplan/resources/switch/conf/dialplan/240_page.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/dialplan/resources/switch/conf/dialplan/240_page.xml b/app/dialplan/resources/switch/conf/dialplan/240_page.xml index 0c080a2213..35b75b6470 100644 --- a/app/dialplan/resources/switch/conf/dialplan/240_page.xml +++ b/app/dialplan/resources/switch/conf/dialplan/240_page.xml @@ -6,6 +6,7 @@ + From 24652e393fdc6dfe5d5d04e7a3e8edd8a1dea216 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Sep 2015 08:59:36 -0600 Subject: [PATCH 066/174] After event socket class was added it created a bug in FAX email and forward. It was unable to find the new EventSocket class adding the include resolves the problem. --- .../install/scripts/app/fax/resources/scripts/hangup_rx.lua | 3 +++ secure/fax_to_email.php | 1 + 2 files changed, 4 insertions(+) diff --git a/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua b/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua index d70db541e9..81ac0ffd13 100644 --- a/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua +++ b/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua @@ -22,6 +22,9 @@ -- Contributor(s): -- Mark J. Crane +--set the debug options + debug["sql"] = false; + --create the api object api = freeswitch.API(); diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index a9d4269836..415428e10d 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -40,6 +40,7 @@ if (defined('STDIN')) { //includes if (!defined('STDIN')) { include "root.php"; } require_once "resources/require.php"; + include "resources/classes/EventSocket.php"; include "resources/phpmailer/class.phpmailer.php"; include "resources/phpmailer/class.smtp.php"; // optional, gets called from within class.phpmailer.php if not already loaded From b5f581fbfd97da99525515c98c8174944087be04 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Sep 2015 11:39:16 -0600 Subject: [PATCH 067/174] Update domain setting handling in fax to email. --- secure/fax_to_email.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index 415428e10d..6972b225b9 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -132,7 +132,14 @@ if (defined('STDIN')) { $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as &$row) { - $_SESSION["domain_uuid"] = $row["domain_uuid"]; + //set the domain variables + $domain_uuid = $row["domain_uuid"]; + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $domain_name; + //set the setting arrays + $domain = new domains(); + $domain->db = $db; + $domain->set(); } unset ($prep_statement); From 36db4dcee4bcd6115056f62538550a5c5596faff Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 27 Sep 2015 00:52:47 -0600 Subject: [PATCH 068/174] Fix the ring group missed call email body. --- resources/install/scripts/app/ring_groups/index.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 3a99d108af..545f5ecc68 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -12,7 +12,7 @@ -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- --- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +-- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, @@ -101,6 +101,7 @@ local log = require "resources.functions.log".ring_group status = dbh:query(sql, function(row) domain_uuid = row["domain_uuid"]; ring_group_name = row["ring_group_name"]; + ring_group_extension = row["ring_group_extension"]; ring_group_forward_enabled = row["ring_group_forward_enabled"]; ring_group_forward_destination = row["ring_group_forward_destination"]; ring_group_cid_name_prefix = row["ring_group_cid_name_prefix"]; @@ -152,6 +153,9 @@ local log = require "resources.functions.log".ring_group subject = subject:gsub("${caller_id_name}", caller_id_name); subject = subject:gsub("${caller_id_number}", caller_id_number); subject = subject:gsub("${ring_group_name}", ring_group_name); + subject = subject:gsub("${ring_group_extension}", ring_group_extension); + subject = subject:gsub("${sip_to_user}", ring_group_name); + subject = subject:gsub("${dialed_user}", ring_group_extension); subject = trim(subject); subject = '=?utf-8?B?'..base64.encode(subject)..'?='; @@ -162,6 +166,9 @@ local log = require "resources.functions.log".ring_group body = body:gsub("${caller_id_name}", caller_id_name); body = body:gsub("${caller_id_number}", caller_id_number); body = body:gsub("${ring_group_name}", ring_group_name); + body = body:gsub("${ring_group_extension}", ring_group_extension); + body = body:gsub("${sip_to_user}", ring_group_name); + body = body:gsub("${dialed_user}", ring_group_extension); body = body:gsub(" ", " "); body = body:gsub("%s+", ""); body = body:gsub(" ", " "); From 40356e4063661fd4a2eeb02d1e05f7cccbd916d9 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 28 Sep 2015 12:10:31 +0400 Subject: [PATCH 069/174] Fix. Clear the cache when callcenter config changed. --- app/call_centers/call_center_agent_delete.php | 1 + app/call_centers/call_center_agent_edit.php | 4 +++- app/call_centers/call_center_queue_delete.php | 2 ++ app/call_centers/call_center_queue_edit.php | 3 +++ app/call_centers/call_center_tier_edit.php | 3 ++- resources/switch.php | 9 +++++++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/call_centers/call_center_agent_delete.php b/app/call_centers/call_center_agent_delete.php index ecbdd74ff6..d7703ec81f 100644 --- a/app/call_centers/call_center_agent_delete.php +++ b/app/call_centers/call_center_agent_delete.php @@ -86,6 +86,7 @@ if (count($_GET)>0) { //synchronize configuration save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); //redirect the browser $_SESSION["message"] = $text['message-delete']; diff --git a/app/call_centers/call_center_agent_edit.php b/app/call_centers/call_center_agent_edit.php index 5ff7915723..e72dc42c19 100644 --- a/app/call_centers/call_center_agent_edit.php +++ b/app/call_centers/call_center_agent_edit.php @@ -264,6 +264,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //syncrhonize configuration save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); $_SESSION["message"] = $text['message-add']; header("Location: call_center_agents.php"); @@ -291,7 +292,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { unset($sql); //syncrhonize configuration - save_call_center_xml(); + save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); $_SESSION["message"] = $text['message-update']; header("Location: call_center_agents.php"); diff --git a/app/call_centers/call_center_queue_delete.php b/app/call_centers/call_center_queue_delete.php index bad7ad96cc..5abb84093f 100644 --- a/app/call_centers/call_center_queue_delete.php +++ b/app/call_centers/call_center_queue_delete.php @@ -87,9 +87,11 @@ if (strlen($id) > 0) { //clear the cache $cache = new cache; $cache->delete("dialplan:".$_SESSION["context"]); + remove_config_from_cache('configuration:callcenter.conf'); //synchronize configuration save_dialplan_xml(); + save_call_center_xml(); //apply settings reminder $_SESSION["reload_xml"] = true; diff --git a/app/call_centers/call_center_queue_edit.php b/app/call_centers/call_center_queue_edit.php index 05f82c1580..e37cf5f245 100644 --- a/app/call_centers/call_center_queue_edit.php +++ b/app/call_centers/call_center_queue_edit.php @@ -257,6 +257,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //syncrhonize the configuration save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); //delete the dialplan context from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); @@ -326,6 +327,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //synchronize the configuration save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); //clear the cache $cache = new cache; @@ -393,6 +395,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //syncrhonize configuration save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); } //redirect diff --git a/app/call_centers/call_center_tier_edit.php b/app/call_centers/call_center_tier_edit.php index 5f25536092..a8c5d2d4ac 100644 --- a/app/call_centers/call_center_tier_edit.php +++ b/app/call_centers/call_center_tier_edit.php @@ -111,7 +111,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { unset($sql); //syncrhonize configuration - save_call_center_xml(); + save_call_center_xml(); + remove_config_from_cache('configuration:callcenter.conf'); //look up queue uuid by queue name (ugh) $sql = "select call_center_queue_uuid from v_call_center_queues where queue_name = '".$queue_name."'"; diff --git a/resources/switch.php b/resources/switch.php index a37727a9d6..e4eb04c532 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -158,6 +158,15 @@ function byte_convert($bytes, $decimals = 2) { return $formattedbytes; } +function remove_config_from_cache($name) { + $cache = new cache; + $cache->delete($name); + $hostname = trim(event_socket_request_cmd('api switchname')); + if($hostname){ + $cache->delete($name . ':' . $hostname); + } +} + function ListFiles($dir) { if($dh = opendir($dir)) { $files = Array(); From 67159897dc217e4b8b0dfef41318dbecce4dccfe Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 29 Sep 2015 14:28:48 -0600 Subject: [PATCH 070/174] Set content lenght to prevent chunking when providing HTTP 401. This should fix Yealink provisioning for the new firmware changes. --- app/provision/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/provision/index.php b/app/provision/index.php index fa20304c10..73f2f73915 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -241,7 +241,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); header('WWW-Authenticate: Basic realm="'.$_SESSION['domain_name']." ".date('r').'"'); header('HTTP/1.0 401 Unauthorized'); header("Content-Type: text/plain"); - echo 'Authorization Required'; + header("Content-Length: 0"); exit; } else { if ($_SERVER['PHP_AUTH_USER'] == $provision["http_auth_username"] && $_SERVER['PHP_AUTH_PW'] == $provision["http_auth_password"]) { @@ -252,7 +252,9 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); header('WWW-Authenticate: Basic realm="'.$_SESSION['domain_name']." ".date('r').'"'); unset($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']); usleep(rand(1000000,3000000));//1-3 seconds. - echo 'Authorization Required'; + $content = 'Authorization Required'; + header("Content-Length: ".strval(strlen($content))); + echo $content; exit; } } From 81917bd977f37504f16c5ed50d5b4e01ae458a29 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 30 Sep 2015 20:56:59 -0600 Subject: [PATCH 071/174] Remove absolute_codec_string='PCMU,PCMA' as it failed to allow PCMA. --- app/fax/fax_send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index cbd205bb87..e134e37bbe 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -608,7 +608,7 @@ function gs_cmd($args) { $fax_uri = $route_array[0]; $t38 = "fax_enable_t38=true,fax_enable_t38_request=true,"; } - $cmd = "api originate {for_fax=1,absolute_codec_string='PCMU,PCMA',accountcode='".$fax_accountcode."',sip_h_X-accountcode='".$fax_accountcode."',domain_uuid=".$_SESSION["domain_uuid"].",domain_name=".$_SESSION["domain_name"].",mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')"; + $cmd = "api originate {for_fax=1,accountcode='".$fax_accountcode."',sip_h_X-accountcode='".$fax_accountcode."',domain_uuid=".$_SESSION["domain_uuid"].",domain_name=".$_SESSION["domain_name"].",mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')"; //send the command to event socket $response = event_socket_request($fp, $cmd); $response = str_replace("\n", "", $response); From 0bf4e1b79413fc9e647051dd575cb0fbd148373a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 30 Sep 2015 21:01:17 -0600 Subject: [PATCH 072/174] Remove absolute_codec_string='PCMU,PCMA' from fax_retry.lua as it is not allowing PCMA. --- resources/install/scripts/fax_retry.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/fax_retry.lua b/resources/install/scripts/fax_retry.lua index 652c4c4180..a6f2ce6fad 100644 --- a/resources/install/scripts/fax_retry.lua +++ b/resources/install/scripts/fax_retry.lua @@ -391,7 +391,7 @@ --email_cmd = "/bin/echo '"..email_message_fail.."' | /usr/bin/mail -s 'Fax to: "..number_dialed.." FAILED' -r "..from_address.." -a '"..fax_file.."' "..email_address; --to keep the originate command shorter these are things we always send. One place to adjust for all. - originate_same = "for_fax=1,absolute_codec_string='PCMU,PCMA',accountcode='"..accountcode.."',domain_uuid="..domain_uuid..",domain_name="..domain_name..",mailto_address='"..email_address.."',mailfrom_address='"..from_address.."',origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."'"; + originate_same = "for_fax=1,accountcode='"..accountcode.."',domain_uuid="..domain_uuid..",domain_name="..domain_name..",mailto_address='"..email_address.."',mailfrom_address='"..from_address.."',origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."'"; if (fax_retry_attempts < fax_retry_limit) then From 5cf2e9acd02c87c4fdce2e37542cde427d8739b0 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 2 Oct 2015 14:02:13 +0400 Subject: [PATCH 073/174] Fix small bags and clear code in call_flow. Move code to turn on/off BLF to separate function. ```Lua presence_in.turn_lamp( toggle == "false", call_flow_feature_code.."@"..domain_name, call_flow_uuid ); ``` Close temp file in call_flow_monitor because on Windows it prevent to remove it. Connect/release to database inside call_flow_monitor loop. Check successful connection to database in call_flow_monitor loop so monitor did not crash if connection temporary lost. --- resources/install/scripts/call_flow.lua | 108 ++++++------------ .../install/scripts/call_flow_monitor.lua | 107 ++++++++--------- .../resources/functions/presence_in.lua | 23 ++++ 3 files changed, 106 insertions(+), 132 deletions(-) create mode 100644 resources/install/scripts/resources/functions/presence_in.lua diff --git a/resources/install/scripts/call_flow.lua b/resources/install/scripts/call_flow.lua index a8298a067c..2b51b6d33b 100644 --- a/resources/install/scripts/call_flow.lua +++ b/resources/install/scripts/call_flow.lua @@ -35,6 +35,10 @@ require "resources.functions.database_handle"; dbh = database_handle('system'); + local log = require "resources.functions.log".call_flow + + local presence_in = require "resources.functions.presence_in" + if (session:ready()) then --get the variables domain_name = session:getVariable("domain_name"); @@ -51,11 +55,9 @@ if (session:ready()) then if (not default_voice) then default_voice = 'callie'; end --get the extension list - sql = [[SELECT * FROM v_call_flows - where call_flow_uuid = ']]..call_flow_uuid..[[']] - --and call_flow_enabled = 'true' - --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); - app_data = ""; + sql = "SELECT * FROM v_call_flows where call_flow_uuid = '"..call_flow_uuid.."'" + -- .. "and call_flow_enabled = 'true'" + --log.notice("SQL: %s", sql); x = 0; dbh:query(sql, function(row) @@ -68,17 +70,15 @@ if (session:ready()) then call_flow_label = row.call_flow_label; call_flow_anti_label = row.call_flow_anti_label; - if (string.len(call_flow_status) == 0) then + if #call_flow_status == 0 then + call_flow_status = "true"; + end + if (call_flow_status == "true") then app = row.call_flow_app; data = row.call_flow_data else - if (call_flow_status == "true") then - app = row.call_flow_app; - data = row.call_flow_data - else - app = row.call_flow_anti_app; - data = row.call_flow_anti_data - end + app = row.call_flow_anti_app; + data = row.call_flow_anti_data end end); @@ -99,70 +99,34 @@ if (session:ready()) then end --feature code - toggle the status - if (string.len(call_flow_status) == 0) then - toggle = "false"; - else - if (call_flow_status == "true") then - toggle = "false"; - else - toggle = "true"; - end - end - if (toggle == "true") then - --set the presence to terminated - turn the lamp off: - event = freeswitch.Event("PRESENCE_IN"); - event:addHeader("proto", "sip"); - event:addHeader("event_type", "presence"); - event:addHeader("alt_event_type", "dialog"); - event:addHeader("Presence-Call-Direction", "outbound"); - event:addHeader("state", "Active (1 waiting)"); - event:addHeader("from", call_flow_feature_code.."@"..domain_name); - event:addHeader("login", call_flow_feature_code.."@"..domain_name); - event:addHeader("unique-id", call_flow_uuid); - event:addHeader("answer-state", "terminated"); - event:fire(); - --answer and play a tone - session:answer(); - if (string.len(call_flow_label) > 0) then - api = freeswitch.API(); - reply = api:executeString("uuid_display "..session:get_uuid().." "..call_flow_label); - end - session:execute("sleep", "2000"); - session:execute("playback", "tone_stream://%(200,0,500,600,700)"); - --show in the console - freeswitch.consoleLog("notice", "Call Flow: label="..call_flow_label..",status=true,uuid="..call_flow_uuid.."\n"); - else - --set presence in - turn lamp on - event = freeswitch.Event("PRESENCE_IN"); - event:addHeader("proto", "sip"); - event:addHeader("login", call_flow_feature_code.."@"..domain_name); - event:addHeader("from", call_flow_feature_code.."@"..domain_name); - event:addHeader("status", "Active (1 waiting)"); - event:addHeader("rpid", "unknown"); - event:addHeader("event_type", "presence"); - event:addHeader("alt_event_type", "dialog"); - event:addHeader("event_count", "1"); - event:addHeader("unique-id", call_flow_uuid); - event:addHeader("Presence-Call-Direction", "outbound") - event:addHeader("answer-state", "confirmed"); - event:fire(); - --answer and play a tone - session:answer(); - if (string.len(call_flow_anti_label) > 0) then - api = freeswitch.API(); - reply = api:executeString("uuid_display "..session:get_uuid().." "..call_flow_anti_label); - end - session:execute("sleep", "2000"); - session:execute("playback", "tone_stream://%(500,0,300,200,100,50,25)"); - --show in the console - freeswitch.consoleLog("notice", "Call Flow: label="..call_flow_anti_label..",status=false,uuid="..call_flow_uuid.."\n"); + toggle = (call_flow_status == "true") and "false" or "true" + + -- turn the lamp + presence_in.turn_lamp( toggle == "false", + call_flow_feature_code.."@"..domain_name, + call_flow_uuid + ); + + local active_flow_label = (toggle == "true") and call_flow_label or call_flow_anti_label + --answer and play a tone + session:answer(); + if #active_flow_label > 0 then + api = freeswitch.API(); + reply = api:executeString("uuid_display "..session:get_uuid().." "..active_flow_label); end + session:execute("sleep", "2000"); + session:execute("playback", "tone_stream://%(200,0,500,600,700)"); + + --show in the console + log.noticef("label=%s,status=%s,uuid=%s", active_flow_label, toggle, call_flow_uuid); + + --store in database dbh:query("UPDATE v_call_flows SET call_flow_status = '"..toggle.."' WHERE call_flow_uuid = '"..call_flow_uuid.."'"); + --hangup the call session:hangup(); else - --app_data - freeswitch.consoleLog("notice", "Call Flow: " .. app .. " " .. data .. "\n"); + log.notice("execute " .. app .. " " .. data); --exucute the application session:execute(app, data); diff --git a/resources/install/scripts/call_flow_monitor.lua b/resources/install/scripts/call_flow_monitor.lua index 5be5ccf4bb..f79a48eae8 100644 --- a/resources/install/scripts/call_flow_monitor.lua +++ b/resources/install/scripts/call_flow_monitor.lua @@ -38,9 +38,11 @@ require "resources.functions.file_exists"; require "resources.functions.mkdir"; ---connect to the database require "resources.functions.database_handle"; - dbh = database_handle('system'); + + local log = require "resources.functions.log".call_flow_monitor + + local presence_in = require "resources.functions.presence_in" --make sure the scripts/run dir exists mkdir(scripts_dir .. "/run"); @@ -61,69 +63,52 @@ --used to stop the lua service local file = assert(io.open(run_file, "w")); file:write("remove this file to stop the script"); + file:close() + log.notice("Start") --monitor the call flows status - x = 0 + local sql = "select d.domain_name, f.call_flow_uuid, f.call_flow_extension, f.call_flow_feature_code," .. + "f.call_flow_status, f.call_flow_label, f.call_flow_anti_label ".. + "from v_call_flows as f, v_domains as d " .. + "where f.domain_uuid = d.domain_uuid " -- and call_flow_enabled = 'true' while true do - --get the extension list - sql = [[select d.domain_name, f.call_flow_uuid, f.call_flow_extension, f.call_flow_feature_code, f.call_flow_status, f.call_flow_label, f.call_flow_anti_label - from v_call_flows as f, v_domains as d - where f.domain_uuid = d.domain_uuid]] - --and call_flow_enabled = 'true' + -- debug print if (debug["sql"]) then - freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + log.notice("SQL:" .. sql); end - x = 0; - dbh:query(sql, function(row) - domain_name = row.domain_name; - call_flow_uuid = row.call_flow_uuid; - --call_flow_name = row.call_flow_name; - call_flow_extension = row.call_flow_extension; - call_flow_feature_code = row.call_flow_feature_code; - --call_flow_context = row.call_flow_context; - call_flow_status = row.call_flow_status; - --pin_number = row.call_flow_pin_number; - call_flow_label = row.call_flow_label; - call_flow_anti_label = row.call_flow_anti_label; - if (call_flow_status == "true") then - --set the presence to terminated - turn the lamp off: - event = freeswitch.Event("PRESENCE_IN"); - event:addHeader("proto", "sip"); - event:addHeader("event_type", "presence"); - event:addHeader("alt_event_type", "dialog"); - event:addHeader("Presence-Call-Direction", "outbound"); - event:addHeader("state", "Active (1 waiting)"); - event:addHeader("from", call_flow_feature_code.."@"..domain_name); - event:addHeader("login", call_flow_feature_code.."@"..domain_name); - event:addHeader("unique-id", call_flow_uuid); - event:addHeader("answer-state", "terminated"); - event:fire(); - --show in the console - if (debug["log"]) then - freeswitch.consoleLog("notice", "Call Flow: label="..call_flow_label..",status=true,uuid="..call_flow_uuid.."\n"); - end - else - --set presence in - turn lamp on - event = freeswitch.Event("PRESENCE_IN"); - event:addHeader("proto", "sip"); - event:addHeader("login", call_flow_feature_code.."@"..domain_name); - event:addHeader("from", call_flow_feature_code.."@"..domain_name); - event:addHeader("status", "Active (1 waiting)"); - event:addHeader("rpid", "unknown"); - event:addHeader("event_type", "presence"); - event:addHeader("alt_event_type", "dialog"); - event:addHeader("event_count", "1"); - event:addHeader("unique-id", call_flow_uuid); - event:addHeader("Presence-Call-Direction", "outbound"); - event:addHeader("answer-state", "confirmed"); - event:fire(); - --show in the console - if (debug["log"]) then - freeswitch.consoleLog("notice", "Call Flow: label="..call_flow_anti_label..",status=false,uuid="..call_flow_uuid.."\n"); - end - end - end); + --connect to the database + local dbh = database_handle('system'); + + --get the extension list + if dbh:connected() then + dbh:query(sql, function(row) + local domain_name = row.domain_name; + local call_flow_uuid = row.call_flow_uuid; + --local call_flow_name = row.call_flow_name; + --local call_flow_extension = row.call_flow_extension; + local call_flow_feature_code = row.call_flow_feature_code; + --local call_flow_context = row.call_flow_context; + local call_flow_status = row.call_flow_status; + --local pin_number = row.call_flow_pin_number; + local call_flow_label = row.call_flow_label; + local call_flow_anti_label = row.call_flow_anti_label; + + -- turn the lamp + presence_in.turn_lamp( call_flow_status == "false", + call_flow_feature_code.."@"..domain_name, + call_flow_uuid + ); + + if (debug["log"]) then + local label = (call_flow_status == "true") and call_flow_label or call_flow_anti_label + log.noticef("label=%s,status=%s,uuid=%s", label, call_flow_status, call_flow_uuid); + end + end); + end + + -- release dbh + dbh:release() --exit the loop when the file does not exist if (not file_exists(run_file)) then @@ -132,4 +117,6 @@ --sleep a moment to prevent using unecessary resources freeswitch.msleep(sleep*1000); - end \ No newline at end of file + end + + log.notice("Stop") diff --git a/resources/install/scripts/resources/functions/presence_in.lua b/resources/install/scripts/resources/functions/presence_in.lua new file mode 100644 index 0000000000..b8369f9b17 --- /dev/null +++ b/resources/install/scripts/resources/functions/presence_in.lua @@ -0,0 +1,23 @@ +local function turn_lamp(on, user, uuid) + local event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("Presence-Call-Direction", "outbound"); + event:addHeader("from", user); + event:addHeader("login", user); + event:addHeader("unique-id", uuid); + event:addHeader("status", "Active (1 waiting)"); + if on then + event:addHeader("answer-state", "confirmed"); + event:addHeader("rpid", "unknown"); + event:addHeader("event_count", "1"); + else + event:addHeader("answer-state", "terminated"); + end + event:fire(); +end + +return { + turn_lamp = turn_lamp; +} \ No newline at end of file From aeb147e4bb54e53f0d731ad36e7134c23104419f Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 2 Oct 2015 17:23:52 -0600 Subject: [PATCH 074/174] Update functions.php Minor version update to 4.0.1 --- resources/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index 8ae34eb285..c1bd498810 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -27,7 +27,7 @@ if (!function_exists('software_version')) { function software_version() { - return '4.0.0'; + return '4.0.1'; } } @@ -1326,4 +1326,4 @@ function number_pad($number,$n) { } } -?> \ No newline at end of file +?> From d56eeab72911b2d4470773d7710597fb06aa680e Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 2 Oct 2015 17:46:39 -0600 Subject: [PATCH 075/174] Fix sip_to_user and dialed_user for voicemail. --- .../scripts/app/voicemail/resources/functions/send_email.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua index f00cb942a5..7009932369 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua @@ -131,6 +131,8 @@ body = body:gsub("${message_duration}", message_length_formatted); body = body:gsub("${account}", id); body = body:gsub("${domain_name}", domain_name); + body = body:gsub("${sip_to_user}", id); + body = body:gsub("${dialed_user}", id); if (voicemail_file == "attach") then body = body:gsub("${message}", text['label-attached'][default_language.."-"..default_dialect]); elseif (voicemail_file == "link") then From f69728befcf44b1ef8224ac71feb2c151d4e8fed Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 2 Oct 2015 23:39:12 -0600 Subject: [PATCH 076/174] Force the device_key_vendor to lower case so the key vendor can be case insenstive. --- app/provision/resources/classes/provision.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 237de12212..d2a4a6f562 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -465,7 +465,7 @@ include "root.php"; $sql .= "or device_profile_uuid = '".$device_profile_uuid."' "; } $sql .= ") "; - $sql .= "AND (device_key_vendor = '".$device_vendor."' or device_key_vendor is null) "; + $sql .= "AND (lower(device_key_vendor) = '".$device_vendor."' or device_key_vendor is null) "; $sql .= "ORDER BY device_key_category asc, device_key_id asc, device_uuid desc"; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); From 49e1c6113bafc90c53d6494f11efa4bfd20b6b00 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Sat, 3 Oct 2015 08:58:41 -0700 Subject: [PATCH 077/174] Update {$mac}.cfg added support for second expansion module and tested the changes. --- .../provision/yealink/t46g/{$mac}.cfg | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/resources/templates/provision/yealink/t46g/{$mac}.cfg b/resources/templates/provision/yealink/t46g/{$mac}.cfg index d5a65ef413..82e6c3ebfc 100644 --- a/resources/templates/provision/yealink/t46g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t46g/{$mac}.cfg @@ -3013,16 +3013,26 @@ programablekey.1.label = #expansion_module.x.key.y.label = #expansion_module.X.key.Y.xml_phonebook = +{$rownum = 1} + {foreach $keys as $row} {if $row.device_key_category == "expansion"} -#Expansion module 1 key {$row.device_key_id} +{if $rownum <= 40} expansion_module.1.key.{$row.device_key_id}.type = {$row.device_key_type} expansion_module.1.key.{$row.device_key_id}.line = {$row.device_key_line} expansion_module.1.key.{$row.device_key_id}.value = {$row.device_key_value} expansion_module.1.key.{$row.device_key_id}.extension = {$row.device_key_extension} expansion_module.1.key.{$row.device_key_id}.label = {$row.device_key_label} -expansion_module.1.key.{$row.device_key_id}.xml_phonebook = - +expansion_module.1.key.{$row.device_key_id}.xml_phonebook = +{else} +expansion_module.2.key.{$row.device_key_id - 40}.type = {$row.device_key_type} +expansion_module.2.key.{$row.device_key_id - 40}.line = {$row.device_key_line} +expansion_module.2.key.{$row.device_key_id - 40}.value = {$row.device_key_value} +expansion_module.2.key.{$row.device_key_id - 40}.extension = {$row.device_key_extension} +expansion_module.2.key.{$row.device_key_id - 40}.label = {$row.device_key_label} +expansion_module.2.key.{$row.device_key_id - 40}.xml_phonebook = +{/if} +{$rownum = $rownum + 1} {/if} {/foreach} @@ -3038,4 +3048,4 @@ expansion_module.1.key.{$row.device_key_id}.xml_phonebook = #expansion_module.2.key.1.label = #expansion_module.2.key.1.xml_phonebook = #expansion_module.2.key.1.type = -#expansion_module.2.key.1.label = \ No newline at end of file +#expansion_module.2.key.1.label = From c0d758be8600d40c6a0171761d72fa0843e857e2 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 4 Oct 2015 01:29:03 -0600 Subject: [PATCH 078/174] Add h hostname to option for the gateways. --- app/gateways/app_config.php | 5 ++++ app/gateways/app_languages.php | 18 +++++++++++++ app/gateways/gateway_edit.php | 26 +++++++++++++++++++ app/gateways/gateways.php | 2 ++ .../scripts/configuration/sofia.conf.lua | 1 + 5 files changed, 52 insertions(+) diff --git a/app/gateways/app_config.php b/app/gateways/app_config.php index 049daf4f95..672be36cc3 100644 --- a/app/gateways/app_config.php +++ b/app/gateways/app_config.php @@ -189,6 +189,11 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "hostname"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(255)"; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "enabled"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; diff --git a/app/gateways/app_languages.php b/app/gateways/app_languages.php index 414807c343..4af02a678b 100644 --- a/app/gateways/app_languages.php +++ b/app/gateways/app_languages.php @@ -442,6 +442,15 @@ $text['label-expire_seconds']['de-at'] = "Expire Seconds"; $text['label-expire_seconds']['ar-eg'] = ""; $text['label-expire_seconds']['he'] = ""; +$text['label-hostname']['en-us'] = "Hostname"; +$text['label-hostname']['pt-pt'] = "Hostname"; +$text['label-hostname']['fr-fr'] = "Nom d'hôte"; +$text['label-hostname']['pt-br'] = "Hostname"; +$text['label-hostname']['pl'] = "Nazwa hosta"; +$text['label-hostname']['sv-se'] = "Hostname"; +$text['label-hostname']['uk'] = "Назва хоста"; +$text['label-hostname']['de-at'] = "Hostname"; + $text['label-enabled']['en-us'] = "Enabled"; $text['label-enabled']['es-cl'] = "Activado"; $text['label-enabled']['pt-pt'] = "Habilitado"; @@ -870,6 +879,15 @@ $text['description-expire_seconds']['de-at'] = "Geben Sie an, nach wie vielen Se $text['description-expire_seconds']['ar-eg'] = ""; $text['description-expire_seconds']['he'] = ""; +$text['description-hostname']['en-us'] = "Enter the hostname / switchname."; +$text['description-hostname']['pt-pt'] = "Introduza o hostname"; +$text['description-hostname']['fr-fr'] = "Entrer le nom de l'hôte / du switch."; +$text['description-hostname']['pt-br'] = "Insira o hostname"; +$text['description-hostname']['pl'] = "Wprowadź nazwę hosta / PBXu."; +$text['description-hostname']['sv-se'] = "Fyll i hostname / switchname."; +$text['description-hostname']['uk'] = "Введіть назву хоста / switchname."; +$text['description-hostname']['de-at'] = "Geben Sie den Hostnamen / Switchnamen an."; + $text['description-enabled']['en-us'] = "Enable or Disable the Gateway"; $text['description-enabled']['es-cl'] = "Activar o Desactivar la Pasarela"; $text['description-enabled']['pt-pt'] = "Habilitar ou Desabilitar o Gateway"; diff --git a/app/gateways/gateway_edit.php b/app/gateways/gateway_edit.php index 0ddb0a4f9a..a60a801163 100644 --- a/app/gateways/gateway_edit.php +++ b/app/gateways/gateway_edit.php @@ -95,6 +95,7 @@ else { $extension_in_contact = check_str($_POST["extension_in_contact"]); $context = check_str($_POST["context"]); $profile = check_str($_POST["profile"]); + $hostname = check_str($_POST["hostname"]); $enabled = check_str($_POST["enabled"]); $description = check_str($_POST["description"]); } @@ -198,6 +199,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "extension_in_contact, "; $sql .= "context, "; $sql .= "profile, "; + $sql .= "hostname, "; $sql .= "enabled, "; $sql .= "description "; $sql .= ")"; @@ -232,6 +234,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$extension_in_contact', "; $sql .= "'$context', "; $sql .= "'$profile', "; + if (strlen($hostname) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$hostname', "; + } $sql .= "'$enabled', "; $sql .= "'$description' "; $sql .= ")"; @@ -278,6 +286,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { else { $sql .= "domain_uuid = '$domain_uuid', "; } + if (strlen($hostname) == 0) { + $sql .= "hostname = null, "; + } + else { + $sql .= "hostname = '$hostname', "; + } $sql .= "enabled = '$enabled', "; $sql .= "description = '$description' "; $sql .= "where gateway_uuid = '$gateway_uuid'"; @@ -374,6 +388,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $extension_in_contact = $row["extension_in_contact"]; $context = $row["context"]; $profile = $row["profile"]; + $hostname = $row["hostname"]; $enabled = $row["enabled"]; $description = $row["description"]; } @@ -871,6 +886,17 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo " ".$text['label-hostname']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-hostname']."\n"; + echo "
\n"; echo " ".$text['label-enabled']."\n"; diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index bc890546dc..8ee5d35354 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -159,6 +159,7 @@ else { echo "".$text['label-action']."".$text['label-state'].""; @@ -183,6 +184,7 @@ else { } echo "".$row["context"]."".$row["hostname"]."
"; @@ -184,7 +184,6 @@ else { } echo "".$row["context"]."".$row["hostname"]."  ".$row["hostname"]."".$text['label-true']."
\n"; + echo "\n"; echo " \n"; echo " \n"; echo " \n"; From dcd382817b3c2c015378002a7d921b70d86dc817 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 6 Oct 2015 11:05:15 +0400 Subject: [PATCH 080/174] Fix. use timeout handler in Enterprise ring group see https://github.com/moteus/fusionpbx/commit/e5a0134ec6c36e44d0828301b20c9c194c25cd78#commitcomment-13601198 --- .../install/scripts/app/ring_groups/index.lua | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 545f5ecc68..bebe6817db 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -626,36 +626,27 @@ local log = require "resources.functions.log".ring_group app_data = app_data:gsub("%]", "}"); end freeswitch.consoleLog("NOTICE", "[ring group] app_data: "..app_data.."\n"); + -- log.noticef("bridge begin: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false") session:execute("bridge", app_data); -- log.noticef("bridge done: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false") end --timeout destination if (app_data ~= nil) then - if ring_group_strategy == "enterprise" - and ( true - --- I see 2 errors here `failure` and `PICKED_OFF` - --- but they be more. I think check `answered` is enough. - -- or session:getVariable("originate_disposition") == "failure" - -- or session:getVariable("originate_disposition") == "PICKED_OFF" - ) - and session:answered() then - -- for enterprise calls when intercept we get "failure" but session answered - return - end - - if (session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT" + if session:ready() and ( + session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT" or session:getVariable("originate_disposition") == "NO_ANSWER" or session:getVariable("originate_disposition") == "NO_USER_RESPONSE" or session:getVariable("originate_disposition") == "USER_NOT_REGISTERED" or session:getVariable("originate_disposition") == "NORMAL_TEMPORARY_FAILURE" or session:getVariable("originate_disposition") == "NO_ROUTE_DESTINATION" or session:getVariable("originate_disposition") == "USER_BUSY" - or session:getVariable("originate_disposition") == "failure") then - --send missed call notification - missed(); - --execute the time out action - session:execute(ring_group_timeout_app, ring_group_timeout_data); + or session:getVariable("originate_disposition") == "failure" + ) then + --send missed call notification + missed(); + --execute the time out action + session:execute(ring_group_timeout_app, ring_group_timeout_data); end else if (ring_group_timeout_app ~= nil) then From 8afafe6beb4461cc60608138f5d858a453fbc58e Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 6 Oct 2015 16:01:24 +0400 Subject: [PATCH 081/174] Add. `cache` class emit MEMCACHE events. --- .../install/scripts/resources/functions/cache.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua index 974e327dd9..5969bf20ef 100644 --- a/resources/install/scripts/resources/functions/cache.lua +++ b/resources/install/scripts/resources/functions/cache.lua @@ -10,6 +10,16 @@ require "resources.functions.trim"; local api = api or freeswitch.API(); +local function send_event(action, key) + -- we need send event only if we use load_balance=true + -- but since this option set only in directory we can not + -- check it here. + local event = freeswitch.Event("MEMCACHE", action); + event:addHeader("API-Command", "memcache"); + event:addHeader("API-Command-Argument", action .. " " .. key); + event:fire() +end + local Cache = {} local function check_error(result) @@ -57,6 +67,7 @@ function Cache.set(key, value, expire) end function Cache.del(key) + send_event('delete', key) local result, err = check_error(api:execute("memcache", "delete " .. key)) if not result then if err == 'NOT FOUND' then From c2a4b78b79e287d4d72e96e8867b1dcdbde3c4e0 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 6 Oct 2015 19:28:57 -0700 Subject: [PATCH 082/174] Fix Gateways and SIP profiles for single tenant systems. --- .../resources/scripts/configuration/sofia.conf.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua index 52e70dc563..a05f14188c 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua @@ -1,6 +1,6 @@ -- xml_handler.lua -- Part of FusionPBX --- Copyright (C) 2013 Mark J Crane +-- Copyright (C) 2013 - 2015 Mark J Crane -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -116,8 +116,8 @@ sql = sql .. "and g.enabled = 'true' "; sql = sql .. "and (g.domain_uuid = d.domain_uuid or g.domain_uuid is null) "; else - sql = "select * from v_gateways "; - sql = sql .. "where enabled = 'true' and profile = '"..sip_profile_name.."' "; + sql = "select * from v_gateways as g "; + sql = sql .. "where g.enabled = 'true' and g.profile = '"..sip_profile_name.."' "; end sql = sql .. "and (g.hostname = '" .. hostname.. "' or g.hostname is null or g.hostname = '') "; if (debug["sql"]) then From 3e533e968e7e62693297d79a30ce65c4cdd24c90 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 7 Oct 2015 10:45:28 -0700 Subject: [PATCH 083/174] Add default settings -> domain -> bridge -> text -> outbound to avoide loopback however loopback is also an option. --- core/default_settings/app_defaults.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/default_settings/app_defaults.php b/core/default_settings/app_defaults.php index 70ef5f0caf..a058969777 100644 --- a/core/default_settings/app_defaults.php +++ b/core/default_settings/app_defaults.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2010 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -30,12 +30,26 @@ if ($domains_processed == 1) { //define array of settings $x = 0; $array[$x]['default_setting_category'] = 'domain'; + $array[$x]['default_setting_subcategory'] = 'time_zone'; + $array[$x]['default_setting_name'] = 'name'; + $array[$x]['default_setting_value'] = ''; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = ''; + $x++; + $array[$x]['default_setting_category'] = 'domain'; $array[$x]['default_setting_subcategory'] = 'language'; $array[$x]['default_setting_name'] = 'code'; $array[$x]['default_setting_value'] = 'en-us'; $array[$x]['default_setting_enabled'] = 'true'; $array[$x]['default_setting_description'] = ''; $x++; + $array[$x]['default_setting_category'] = 'domain'; + $array[$x]['default_setting_subcategory'] = 'bridge'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'outbound'; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = 'outbound,loopback,lcr'; + $x++; $array[$x]['default_setting_category'] = 'security'; $array[$x]['default_setting_subcategory'] = 'password_length'; $array[$x]['default_setting_name'] = 'var'; From c307c48a72553ed3cf8602c310373f7b55489a82 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 7 Oct 2015 11:52:06 -0700 Subject: [PATCH 084/174] Set presence-hosts as disabled by default. --- resources/templates/conf/sip_profiles/internal.xml.noload | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/conf/sip_profiles/internal.xml.noload b/resources/templates/conf/sip_profiles/internal.xml.noload index 012c50e59a..86452a2282 100644 --- a/resources/templates/conf/sip_profiles/internal.xml.noload +++ b/resources/templates/conf/sip_profiles/internal.xml.noload @@ -150,7 +150,7 @@ - + From 6ae87d5ff4b6af7683bef3180fdd1472f7892814 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Wed, 7 Oct 2015 13:41:17 -0700 Subject: [PATCH 085/174] {$mac}.cfg fix the port # for yealink DNS SRV --- resources/templates/provision/yealink/t42g/{$mac}.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/templates/provision/yealink/t42g/{$mac}.cfg b/resources/templates/provision/yealink/t42g/{$mac}.cfg index f61d7bfe92..a8541361af 100644 --- a/resources/templates/provision/yealink/t42g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t42g/{$mac}.cfg @@ -44,7 +44,11 @@ account.1.naptr_build = 0 account.1.fallback.redundancy_type = 0 account.1.fallback.timeout = 120 account.1.sip_server.1.address = +{if $sip_transport_1 == 'dns srv'} +account.1.sip_server.1.port = 0 +{else} account.1.sip_server.1.port = 5060 +{/if} #Configure the register expiry time (in seconds), the default value is 3600. account.1.sip_server.1.expires = {$register_expires_1} account.1.sip_server.1.retry_counts = 3 From 584309afb5497d50a9284a11d9c50faf7d429009 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Wed, 7 Oct 2015 13:43:17 -0700 Subject: [PATCH 086/174] Update {$mac}.cfg fix for yealink dns srv to work. --- resources/templates/provision/yealink/t46g/{$mac}.cfg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/templates/provision/yealink/t46g/{$mac}.cfg b/resources/templates/provision/yealink/t46g/{$mac}.cfg index d5a65ef413..a8541361af 100644 --- a/resources/templates/provision/yealink/t46g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t46g/{$mac}.cfg @@ -44,7 +44,11 @@ account.1.naptr_build = 0 account.1.fallback.redundancy_type = 0 account.1.fallback.timeout = 120 account.1.sip_server.1.address = +{if $sip_transport_1 == 'dns srv'} +account.1.sip_server.1.port = 0 +{else} account.1.sip_server.1.port = 5060 +{/if} #Configure the register expiry time (in seconds), the default value is 3600. account.1.sip_server.1.expires = {$register_expires_1} account.1.sip_server.1.retry_counts = 3 @@ -3038,4 +3042,4 @@ expansion_module.1.key.{$row.device_key_id}.xml_phonebook = #expansion_module.2.key.1.label = #expansion_module.2.key.1.xml_phonebook = #expansion_module.2.key.1.type = -#expansion_module.2.key.1.label = \ No newline at end of file +#expansion_module.2.key.1.label = From 0fbeb697e7ac4a7a1bdda5a4224e6abe7d838f14 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 8 Oct 2015 08:33:34 -0700 Subject: [PATCH 087/174] Enable aggressive nat detection and rport by default. --- resources/templates/conf/sip_profiles/internal.xml.noload | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/templates/conf/sip_profiles/internal.xml.noload b/resources/templates/conf/sip_profiles/internal.xml.noload index 86452a2282..787fde8f95 100644 --- a/resources/templates/conf/sip_profiles/internal.xml.noload +++ b/resources/templates/conf/sip_profiles/internal.xml.noload @@ -97,7 +97,7 @@ - + - + Enterprise http://{$domain_name}/app/provision?file=directory-enterprise&mac={$mac} - Speed Dials + Speed Dial http://{$domain_name}/app/provision/?file=directory-speed_dial&mac={$mac} From 9429de42be9adb76eccad5f667afe82c169cb3b7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 29 Oct 2015 09:43:57 -0600 Subject: [PATCH 141/174] Update translation for de-at. --- app/calls/app_languages.php | 28 ++++++++++++++-------------- core/user_settings/app_languages.php | 8 ++++---- core/user_settings/app_menu.php | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/calls/app_languages.php b/app/calls/app_languages.php index 981ca16dd8..d475fee621 100644 --- a/app/calls/app_languages.php +++ b/app/calls/app_languages.php @@ -101,17 +101,6 @@ $text['label-on-busy']['sv-se'] = "Vid Upptaget "; $text['label-on-busy']['uk'] = "Якщо зайнято"; $text['label-on-busy']['de-at'] = "Bei Besetzt"; -$text['label-ignore-busy']['en-us'] = "Ignore Busy"; -$text['label-ignore-busy']['es-cl'] = ""; -$text['label-ignore-busy']['pt-pt'] = ""; -$text['label-ignore-busy']['fr-fr'] = ""; -$text['label-ignore-busy']['it-it'] = ""; -$text['label-ignore-busy']['pt-br'] = ""; -$text['label-ignore-busy']['pl'] = ""; -$text['label-ignore-busy']['sv-se'] = ""; -$text['label-ignore-busy']['uk'] = ""; -$text['label-ignore-busy']['de-at'] = ""; - $text['label-number']['en-us'] = "Number"; $text['label-number']['es-cl'] = "Número"; $text['label-number']['pt-pt'] = "Número"; @@ -133,6 +122,17 @@ $text['label-no_answer']['sv-se'] = "Inget Svar "; $text['label-no_answer']['uk'] = "Без відповіді"; $text['label-no_answer']['de-at'] = "Keine Antwort"; +$text['label-ignore-busy']['en-us'] = "Ignore Busy"; +$text['label-ignore-busy']['es-cl'] = ""; +$text['label-ignore-busy']['pt-pt'] = ""; +$text['label-ignore-busy']['fr-fr'] = ""; +$text['label-ignore-busy']['it-it'] = ""; +$text['label-ignore-busy']['pt-br'] = ""; +$text['label-ignore-busy']['pl'] = ""; +$text['label-ignore-busy']['sv-se'] = ""; +$text['label-ignore-busy']['uk'] = ""; +$text['label-ignore-busy']['de-at'] = "Ignorieren bei Besetzt"; + $text['label-follow-me']['en-us'] = "Follow Me"; $text['label-follow-me']['es-cl'] = "Sígueme"; $text['label-follow-me']['pt-pt'] = "Segue-me"; @@ -141,7 +141,7 @@ $text['label-follow-me']['pt-br'] = "Siga-me"; $text['label-follow-me']['pl'] = "Podążaj za mną"; $text['label-follow-me']['sv-se'] = "Följ Mig "; $text['label-follow-me']['uk'] = ""; -$text['label-follow-me']['de-at'] = "Follow Me"; +$text['label-follow-me']['de-at'] = "Anrufweiterschaltung"; $text['label-enabled']['en-us'] = "Enabled"; $text['label-enabled']['es-cl'] = "Activo"; @@ -311,7 +311,7 @@ $text['label-call-forward']['pt-br'] = "Encaminhamento de chamadas"; $text['label-call-forward']['pl'] = "Przekierowanie"; $text['label-call-forward']['sv-se'] = "Vidarekoppling "; $text['label-call-forward']['uk'] = "Переадресація"; -$text['label-call-forward']['de-at'] = "Ruf Weiterleitung"; +$text['label-call-forward']['de-at'] = "Rufumleitung"; $text['description-on-busy']['en-us'] = "If enabled, it overrides the value of voicemail enabling in extension."; $text['description-on-busy']['es-cl'] = "Si está habilitada, anula el valor del correo de voz que permite en la extensión."; @@ -383,7 +383,7 @@ $text['description-2']['pt-br'] = "A informação contem a origem, destino, dura $text['description-2']['pl'] = "Za pomocą poniższych linków można skonfigurować przekierowania, usługę „Podążaj z mną” lub „Nie przeszkadzać” (DnD)."; $text['description-2']['sv-se'] = "Använd länkarna för att konfigurera Vidarekoppling, Följ Mig och Stör Ej. "; $text['description-2']['uk'] = ""; -$text['description-2']['de-at'] = "Benutzen Sie die Funktionen um Weiterleitung, Follow Me oder Bitte nicht stören zu konfigurieren."; +$text['description-2']['de-at'] = "Benutzen Sie die Funktionen um Rufumleitung, Anrufweiterschaltung oder Nicht stören zu konfigurieren."; $text['description']['en-us'] = "Directs incoming calls for extension:"; $text['description']['es-cl'] = "Dirige las llamadas entrantes hacia una extensión:"; diff --git a/core/user_settings/app_languages.php b/core/user_settings/app_languages.php index 10c282542e..8eee3f3dc0 100644 --- a/core/user_settings/app_languages.php +++ b/core/user_settings/app_languages.php @@ -9,7 +9,7 @@ $text['title-user_dashboard']['pl'] = "Panel użytkowników"; $text['title-user_dashboard']['he'] = "ממשק משתמש"; $text['title-user_dashboard']['uk'] = "Панель користувача"; $text['title-user_dashboard']['sv-se'] = "Användarpanel"; -$text['title-user_dashboard']['de-at'] = "Benutzer-Übersichtsseite"; +$text['title-user_dashboard']['de-at'] = "Benutzerübersicht"; $text['title-user_dashboard']['ro'] = "Panou control utilizator"; $text['title-user_dashboard']['fa'] = ""; $text['title-user_dashboard']['ar-eg'] = "الصفحه الرئيسيه للمستخدم"; @@ -359,7 +359,7 @@ $text['label-followme']['pl'] = "Podążaj za mną"; $text['label-followme']['he'] = "עקוב אחרי"; $text['label-followme']['uk'] = "Follow Me"; $text['label-followme']['sv-se'] = "Följ Mig"; -$text['label-followme']['de-at'] = "Follow Me"; +$text['label-followme']['de-at'] = "Anrufweiterschaltung"; $text['label-followme']['ro'] = "Urmează-mă"; $text['label-followme']['fa'] = ""; $text['label-followme']['ar-eg'] = "خدمة اتبعني"; @@ -457,7 +457,7 @@ $text['label-callforward']['pl'] = "Przekierowanie rozmowy"; $text['label-callforward']['he'] = "עקוב אחרי"; $text['label-callforward']['uk'] = "Переадресація дзвінків"; $text['label-callforward']['sv-se'] = "Vidarekoppling"; -$text['label-callforward']['de-at'] = "Anrufweiterleitung"; +$text['label-callforward']['de-at'] = "Rufumleitung"; $text['label-callforward']['ro'] = "Redirecționare apel"; $text['label-callforward']['fa'] = ""; $text['label-callforward']['ar-eg'] = "تحويل المكالمات"; @@ -471,7 +471,7 @@ $text['header-user_dashboard']['pl'] = "Panel użytkowników"; $text['header-user_dashboard']['he'] = "ממשק משתמש"; $text['header-user_dashboard']['uk'] = "Панель користувача"; $text['header-user_dashboard']['sv-se'] = "Användarpanel"; -$text['header-user_dashboard']['de-at'] = "Benutzer-Übersichtsseite"; +$text['header-user_dashboard']['de-at'] = "Benutzerübersicht"; $text['header-user_dashboard']['ro'] = "Panou control utilizator"; $text['header-user_dashboard']['fa'] = ""; $text['header-user_dashboard']['ar-eg'] = "الصفحه الرئيسيه للمستخدم"; diff --git a/core/user_settings/app_menu.php b/core/user_settings/app_menu.php index 900b3e5024..9f663d7579 100644 --- a/core/user_settings/app_menu.php +++ b/core/user_settings/app_menu.php @@ -29,7 +29,7 @@ $apps[$x]['menu'][1]['title']['pl'] = "Panel użytkowników"; $apps[$x]['menu'][1]['title']['he'] = "ממשק משתמש"; $apps[$x]['menu'][1]['title']['uk'] = "Панель користувача"; $apps[$x]['menu'][1]['title']['sv-se'] = "Användarpanel"; -$apps[$x]['menu'][1]['title']['de-at'] = "Benutzer-Übersichtsseite"; +$apps[$x]['menu'][1]['title']['de-at'] = "Benutzerübersicht"; $apps[$x]['menu'][1]['title']['ro'] = "Panou control utilizator"; $apps[$x]['menu'][1]['title']['ar-eg'] = "الصفحه الرئيسيه للمستخدم"; $apps[$x]['menu'][1]['uuid'] = "92c8ffdb-3c82-4f08-aec0-82421ec41bb5"; From 080d136968a9af9d455e684f33ed545f1b65312d Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Thu, 29 Oct 2015 12:22:40 -0700 Subject: [PATCH 142/174] Update app_config.php --- app/extensions/app_config.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/extensions/app_config.php b/app/extensions/app_config.php index e66d930253..77a68de9ea 100644 --- a/app/extensions/app_config.php +++ b/app/extensions/app_config.php @@ -118,6 +118,9 @@ $apps[$x]['permissions'][$y]['name'] = "extension_user_context"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = "extension_absolute_codec_string"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; //schema details $y = 0; //table array index @@ -384,6 +387,14 @@ $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "absolute_codec_string"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + + $y = 1; //table array index $z = 0; //field array index From 89410fafa652065b451000f4475d37481645e260 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Thu, 29 Oct 2015 12:23:49 -0700 Subject: [PATCH 143/174] Update app_languages.php --- app/extensions/app_languages.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/extensions/app_languages.php b/app/extensions/app_languages.php index 7f16108a30..d70072975a 100644 --- a/app/extensions/app_languages.php +++ b/app/extensions/app_languages.php @@ -468,6 +468,19 @@ $text['label-sip_bypass_media']['ro'] = "SIP Bypass Media"; $text['label-sip_bypass_media']['ar-eg'] = ""; $text['label-sip_bypass_media']['he'] = ""; +$text['label-absolute_codec_string']['en-us'] = "Absolute Codec String"; +$text['label-absolute_codec_string']['es-cl'] = ""; +$text['label-absolute_codec_string']['pt-pt'] = ""; +$text['label-absolute_codec_string']['fr-fr'] = ""; +$text['label-absolute_codec_string']['pt-br'] = ""; +$text['label-absolute_codec_string']['pl'] = ""; +$text['label-absolute_codec_string']['uk'] = ""; +$text['label-absolute_codec_string']['sv-se'] = ""; +$text['label-absolute_codec_string']['de-at'] = ""; +$text['label-absolute_codec_string']['ro'] = ""; +$text['label-absolute_codec_string']['ar-eg'] = ""; +$text['label-absolute_codec_string']['he'] = ""; + $text['label-rewrite_tls_contact_port']['en-us'] = "Rewrite TLS Contact Port"; $text['label-rewrite_tls_contact_port']['es-cl'] = "Reescribir Contacto Puerto TLS"; $text['label-rewrite_tls_contact_port']['pt-pt'] = "Reescreva Contacto Porto TLS"; @@ -1339,6 +1352,19 @@ $text['description-mwi_account']['ro'] = "Contul MWI cu utilizator@domeniu al me $text['description-mwi_account']['ar-eg'] = ""; $text['description-mwi_account']['he'] = ""; +$text['description-absolute_codec_string']['en-us'] = "Absolute Codec String for the extension"; +$text['description-absolute_codec_string']['es-cl'] = ""; +$text['description-absolute_codec_string']['pt-pt'] = ""; +$text['description-absolute_codec_string']['fr-fr'] = ""; +$text['description-absolute_codec_string']['pt-br'] = ""; +$text['description-absolute_codec_string']['pl'] = ""; +$text['description-absolute_codec_string']['uk'] = ""; +$text['description-absolute_codec_string']['sv-se'] = ""; +$text['description-absolute_codec_string']['de-at'] = ""; +$text['description-absolute_codec_string']['ro'] = ""; +$text['description-absolute_codec_string']['ar-eg'] = ""; +$text['description-absolute_codec_string']['he'] = ""; + $text['description-missed_call']['en-us'] = "Select the notification type, and enter the appropriate destination."; $text['description-missed_call']['es-cl'] = "Seleccione el tipo de notificación, y entrar en el destino apropiado."; $text['description-missed_call']['pt-pt'] = "Selecione o tipo de notificação e digite o destino apropriado."; @@ -1793,4 +1819,4 @@ $text['button-add']['ro'] = "Adaugă"; $text['button-add']['ar-eg'] = "اضافة"; $text['button-add']['he'] = "הוספה"; -?> \ No newline at end of file +?> From 9a47dc93fd2112a799e85d4350953d1574058d3f Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Thu, 29 Oct 2015 12:24:24 -0700 Subject: [PATCH 144/174] Update extension_edit.php --- app/extensions/extension_edit.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index a5dcaab29b..a31b0d5b29 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -135,6 +135,7 @@ else { $nibble_account = check_str($_POST["nibble_account"]); $mwi_account = check_str($_POST["mwi_account"]); $sip_bypass_media = check_str($_POST["sip_bypass_media"]); + $absolute_codec_string = check_str($_POST["absolute_codec_string"]); $dial_string = check_str($_POST["dial_string"]); $enabled = check_str($_POST["enabled"]); $description = check_str($_POST["description"]); @@ -462,6 +463,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "mwi_account, "; } $sql .= "sip_bypass_media, "; + if (permission_exists('extension_absolute_codec_string')) { + $sql .= "absolute_codec_string, "; + } if (permission_exists('extension_dial_string')) { $sql .= "dial_string, "; } @@ -527,6 +531,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$mwi_account', "; } $sql .= "'$sip_bypass_media', "; + if (permission_exists('extension_absolute_codec_string')) { + $sql .= "'$absolute_codec_string', "; + } if (permission_exists('extension_dial_string')) { $sql .= "'$dial_string', "; } @@ -680,6 +687,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } $sql .= "mwi_account = '$mwi_account', "; $sql .= "sip_bypass_media = '$sip_bypass_media', "; + if (permission_exists('extension_absolute_codec_string')) { + $sql .= "absolute_codec_string = '$absolute_codec_string', "; + } if (permission_exists('extension_dial_string')) { $sql .= "dial_string = '$dial_string', "; } @@ -841,6 +851,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $nibble_account = $row["nibble_account"]; $mwi_account = $row["mwi_account"]; $sip_bypass_media = $row["sip_bypass_media"]; + $absolute_codec_string = $row["absolute_codec_string"]; $dial_string = $row["dial_string"]; $enabled = $row["enabled"]; $description = $row["description"]; @@ -1879,6 +1890,19 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + if (permission_exists('extension_absolute_codec_string')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (permission_exists('extension_domain')) { echo "\n"; echo "\n"; echo "\n"; - echo " "; - echo " "; - echo " "; + echo " "; + } + + if (permission_exists('device_profile_edit')) { //device profile $sql = "select * from v_device_profiles "; $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; @@ -764,85 +766,63 @@ require_once "resources/require.php"; echo " \n"; } - $x = 0; - foreach($device_keys as $row) { - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor']) { + if (permission_exists('device_profile_view')) { + $x = 0; + foreach($device_keys as $row) { + //set the column names + if ($previous_device_key_vendor != $row['device_key_vendor']) { + echo " \n"; + echo " \n"; + echo " \n"; + if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { + echo " \n"; + } else { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + //show all the rows in the array echo " \n"; - echo " \n"; - echo " \n"; - if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { - echo " \n"; - } else { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { - echo " \n"; - } - //show all the rows in the array - echo " \n"; - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - //echo " \n"; - echo " \n"; - echo " \n"; - //set the previous vendor - $previous_device_key_vendor = $row['device_key_vendor']; - //increment the array key - $x++; + echo " \n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + //echo " \n"; + echo " \n"; + echo " \n"; + //set the previous vendor + $previous_device_key_vendor = $row['device_key_vendor']; + //increment the array key + $x++; + } + echo "
 
\n"; + echo " ".$text['label-absolute_codec_string']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-absolute_codec_string']."\n"; + echo "
\n"; @@ -1980,4 +2004,4 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> From 5bc43a3fbd54d2674617097812e71f16fe4c6b91 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Thu, 29 Oct 2015 12:24:55 -0700 Subject: [PATCH 145/174] Update extension.php --- app/extensions/resources/classes/extension.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/extensions/resources/classes/extension.php b/app/extensions/resources/classes/extension.php index 488236303a..78f09074ed 100644 --- a/app/extensions/resources/classes/extension.php +++ b/app/extensions/resources/classes/extension.php @@ -65,6 +65,7 @@ public $nibble_account; public $mwi_account; public $sip_bypass_media; + public $absolute_codec_string; public $dial_string; public $enabled; public $description; @@ -360,6 +361,9 @@ $xml .= " \n"; break; } + if (strlen($row['absolute_codec_string']) > 0) { + $xml .= " \n"; + } if (strlen($row['forward_all_enabled']) > 0) { $xml .= " \n"; } @@ -494,4 +498,4 @@ } } -?> \ No newline at end of file +?> From f8388cc8f44b63198242c611fb9792c219a3fe70 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Thu, 29 Oct 2015 12:26:06 -0700 Subject: [PATCH 146/174] Update directory.lua --- .../xml_handler/resources/scripts/directory/directory.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua index 5e653be5f6..325a2685e5 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua @@ -244,6 +244,7 @@ sip_force_expires = row.sip_force_expires; nibble_account = row.nibble_account; sip_bypass_media = row.sip_bypass_media; + absolute_codec_string = row.absolute_codec_string; forward_all_enabled = row.forward_all_enabled; forward_all_destination = row.forward_all_destination; forward_busy_enabled = row.forward_busy_enabled; @@ -445,9 +446,13 @@ if (string.len(nibble_account) > 0) then table.insert(xml, [[ ]]); end + if (string.len(absolute_codec_string) > 0) then + table.insert(xml, [[ ]]); + end if (sip_bypass_media == "bypass-media") then table.insert(xml, [[ ]]); end + if (sip_bypass_media == "bypass-media-after-bridge") then table.insert(xml, [[ ]]); end From 1c6f58ca03eb85de4b83fd270d801c78f533f281 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 29 Oct 2015 17:34:39 -0600 Subject: [PATCH 147/174] MWI only turn on the light for new messages. --- .../install/scripts/app/voicemail/resources/scripts/mwi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/app/voicemail/resources/scripts/mwi.lua b/resources/install/scripts/app/voicemail/resources/scripts/mwi.lua index 82d9d17973..33d48e8068 100644 --- a/resources/install/scripts/app/voicemail/resources/scripts/mwi.lua +++ b/resources/install/scripts/app/voicemail/resources/scripts/mwi.lua @@ -99,7 +99,7 @@ --send the message waiting event local event = freeswitch.Event("message_waiting"); - if (row["message_count"] == "0") then + if (new_messages == "0") then event:addHeader("MWI-Messages-Waiting", "no"); else event:addHeader("MWI-Messages-Waiting", "yes"); From ec162d4238bd63cdf07690b3326859cb3512496c Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 30 Oct 2015 17:33:26 +0300 Subject: [PATCH 148/174] Fix. Get DTMF in IVR when using phrases. --- resources/install/scripts/ivr_menu.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/install/scripts/ivr_menu.lua b/resources/install/scripts/ivr_menu.lua index 02131a283d..554bcdc2f7 100644 --- a/resources/install/scripts/ivr_menu.lua +++ b/resources/install/scripts/ivr_menu.lua @@ -358,8 +358,7 @@ pos = string.find(ivr_menu_greet_long, ":", 0, true); if (pos ~= nil and string.sub(ivr_menu_greet_long, 0, pos-1) == 'phrase') then freeswitch.consoleLog("notice", "[ivr_menu] phrase detected\n"); - session:playAndGetDigits(min_digits, ivr_menu_digit_len, 1, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_long, "", ".*"); - dtmf_digits = session:getVariable("dtmf_digits"); + dtmf_digits = session:playAndGetDigits(min_digits, ivr_menu_digit_len, 1, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_long, "", ".*"); session:setVariable("slept", "false"); else dtmf_digits = session:playAndGetDigits(min_digits, ivr_menu_digit_len, 1, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_long, "", ".*"); From 8793159dad50a165517b7795d116e4f34f15c9ed Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Fri, 30 Oct 2015 16:16:56 +0000 Subject: [PATCH 149/174] Fix. use settings for the phrases path rather than assuming --- .../resources/scripts/languages/languages.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua index 86047db948..c607d699b3 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua @@ -142,16 +142,25 @@ table.insert(xml, [[ ]]);; end + require "resources.functions.settings"; + settings = settings(domain_uuid); + lang_path = "/usr/local/freeswitch/conf/lang/"; + if (settings['switch']['phrases'] ~= nil) then + if (settings['switch']['phrases']['dir'] ~= nil) then + lang_path = settings['switch']['phrases']['dir']; + end + end + --read root xml language file, parse included xml files local xml_file_paths = {} - local file_handle = io.open("/usr/local/freeswitch/conf/lang/"..language.."/"..language..".xml", "r"); + local file_handle = io.open(lang_path.."/"..language.."/"..language..".xml", "r"); if (file_handle ~= nil) then for file_line in file_handle:lines() do if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then pos_beg = string.find(file_line, 'cmd="include" data="', 0, true) + 20; pos_end = string.find(file_line, '"/>', 0, true) - 1; xml_file_path = string.sub(file_line, pos_beg, pos_end); - table.insert(xml_file_paths, "/usr/local/freeswitch/conf/lang/"..language.."/"..xml_file_path); + table.insert(xml_file_paths, lang_path.."/"..language.."/"..xml_file_path); --freeswitch.consoleLog("notice", "file path = "..xml_file_path.."\n"); end end From fee216cc133053166ee3122af289307c3ef5d5ef Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 2 Nov 2015 09:53:42 +0000 Subject: [PATCH 150/174] changed phrases_dir to be dealt with inside app_defaults.php so it is retrieved once like the other paths --- core/databases/app_defaults.php | 3 +++ .../resources/scripts/languages/languages.lua | 11 +---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/databases/app_defaults.php b/core/databases/app_defaults.php index dbd68274fe..ea4d04d6c9 100644 --- a/core/databases/app_defaults.php +++ b/core/databases/app_defaults.php @@ -131,6 +131,9 @@ if ($domains_processed == 1) { if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { $tmp .= correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n"); } + if (strlen($_SESSION['switch']['phrases']['dir']) > 0) { + $tmp .= correct_path(" phrases_dir = [[".$_SESSION['switch']['phrases']['dir']."]];\n"); + } if (strlen($_SESSION['switch']['db']['dir']) > 0) { $tmp .= correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n"); } diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua index c607d699b3..6254bff9de 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua @@ -142,18 +142,9 @@ table.insert(xml, [[ ]]);; end - require "resources.functions.settings"; - settings = settings(domain_uuid); - lang_path = "/usr/local/freeswitch/conf/lang/"; - if (settings['switch']['phrases'] ~= nil) then - if (settings['switch']['phrases']['dir'] ~= nil) then - lang_path = settings['switch']['phrases']['dir']; - end - end - --read root xml language file, parse included xml files local xml_file_paths = {} - local file_handle = io.open(lang_path.."/"..language.."/"..language..".xml", "r"); + local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r"); if (file_handle ~= nil) then for file_line in file_handle:lines() do if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then From 8337af0fd457eb5a9aa205ee60f8c7bf82c1dd59 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 2 Nov 2015 17:22:13 +0000 Subject: [PATCH 151/174] corrected references to voicemail_dir changed from $_SESSION['switch']['storage']['dir'].'/voicemail/' to correctly use $_SESSION['switch']['voicemail']['dir'] added missing storage_type to app_defaults.php --- app/voicemails/app_defaults.php | 7 +++++++ app/voicemails/resources/classes/voicemail.php | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/voicemails/app_defaults.php b/app/voicemails/app_defaults.php index d81acb5140..0fab2304d7 100644 --- a/app/voicemails/app_defaults.php +++ b/app/voicemails/app_defaults.php @@ -48,6 +48,13 @@ if ($domains_processed == 1) { $array[$x]['default_setting_enabled'] = 'true'; $array[$x]['default_setting_description'] = 'Define whether to keep voicemail files on the local system after sending attached via email.'; $x++; + $array[$x]['default_setting_category'] = 'voicemail'; + $array[$x]['default_setting_subcategory'] = 'storage_type'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'base64'; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Define which storage type (base_64 stores in the database).'; + $x++; //iterate and add each, if necessary foreach ($array as $index => $default_settings) { diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index ca5b55ba00..27f7e304af 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -161,7 +161,7 @@ if ($result_count > 0) { foreach($result as &$row) { //set the greeting directory - $path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id']; + $path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id']; if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.wav')) { $row['file_path'] = $path.'/msg_'.$row['voicemail_message_uuid'].'.wav'; } @@ -239,7 +239,7 @@ } //delete the recording - $file_path = $_SESSION['switch']['storage']['dir']."/voicemail/default/".$_SESSION['domain_name']."/".$this->voicemail_id; + $file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id; foreach (glob($file_path."/msg_".$this->voicemail_message_uuid.".*") as $file_name) { unlink($file_name); } @@ -278,7 +278,7 @@ session_cache_limiter('public'); //set source folder path - $path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$this->voicemail_id; + $path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$this->voicemail_id; //prepare base64 content from db, if enabled if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') { From 35762486e16cc832d7b0eb87fd9fce8c5cf9aef8 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 2 Nov 2015 17:32:43 +0000 Subject: [PATCH 152/174] reverted so branch is consistent for patch --- core/databases/app_defaults.php | 3 --- .../resources/scripts/languages/languages.lua | 11 ++++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/databases/app_defaults.php b/core/databases/app_defaults.php index ea4d04d6c9..dbd68274fe 100644 --- a/core/databases/app_defaults.php +++ b/core/databases/app_defaults.php @@ -131,9 +131,6 @@ if ($domains_processed == 1) { if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { $tmp .= correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n"); } - if (strlen($_SESSION['switch']['phrases']['dir']) > 0) { - $tmp .= correct_path(" phrases_dir = [[".$_SESSION['switch']['phrases']['dir']."]];\n"); - } if (strlen($_SESSION['switch']['db']['dir']) > 0) { $tmp .= correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n"); } diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua index 6254bff9de..c607d699b3 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua @@ -142,9 +142,18 @@ table.insert(xml, [[ ]]);; end + require "resources.functions.settings"; + settings = settings(domain_uuid); + lang_path = "/usr/local/freeswitch/conf/lang/"; + if (settings['switch']['phrases'] ~= nil) then + if (settings['switch']['phrases']['dir'] ~= nil) then + lang_path = settings['switch']['phrases']['dir']; + end + end + --read root xml language file, parse included xml files local xml_file_paths = {} - local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r"); + local file_handle = io.open(lang_path.."/"..language.."/"..language..".xml", "r"); if (file_handle ~= nil) then for file_line in file_handle:lines() do if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then From b073d792d55bf22182891e2e28b8962e8d1386e5 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 3 Nov 2015 11:16:05 +0000 Subject: [PATCH 153/174] fix to use phrases_dir changed phrases_dir to be dealt with inside app_defaults.php so it is retrieved once like the other paths --- core/databases/app_defaults.php | 3 +++ .../resources/scripts/languages/languages.lua | 11 +---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/databases/app_defaults.php b/core/databases/app_defaults.php index dbd68274fe..ea4d04d6c9 100644 --- a/core/databases/app_defaults.php +++ b/core/databases/app_defaults.php @@ -131,6 +131,9 @@ if ($domains_processed == 1) { if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { $tmp .= correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n"); } + if (strlen($_SESSION['switch']['phrases']['dir']) > 0) { + $tmp .= correct_path(" phrases_dir = [[".$_SESSION['switch']['phrases']['dir']."]];\n"); + } if (strlen($_SESSION['switch']['db']['dir']) > 0) { $tmp .= correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n"); } diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua index c607d699b3..6254bff9de 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua @@ -142,18 +142,9 @@ table.insert(xml, [[ ]]);; end - require "resources.functions.settings"; - settings = settings(domain_uuid); - lang_path = "/usr/local/freeswitch/conf/lang/"; - if (settings['switch']['phrases'] ~= nil) then - if (settings['switch']['phrases']['dir'] ~= nil) then - lang_path = settings['switch']['phrases']['dir']; - end - end - --read root xml language file, parse included xml files local xml_file_paths = {} - local file_handle = io.open(lang_path.."/"..language.."/"..language..".xml", "r"); + local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r"); if (file_handle ~= nil) then for file_line in file_handle:lines() do if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then From f53cf0ec411bc5987b8a60d783ff689b5b61581b Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 3 Nov 2015 14:23:52 +0000 Subject: [PATCH 154/174] initial rewrite of time_conditions --- app/time_conditions/app_defaults.php | 124 +++++++++++++------- app/time_conditions/time_condition_edit.php | 6 +- 2 files changed, 86 insertions(+), 44 deletions(-) diff --git a/app/time_conditions/app_defaults.php b/app/time_conditions/app_defaults.php index 249ed0f0f5..e829c460a6 100644 --- a/app/time_conditions/app_defaults.php +++ b/app/time_conditions/app_defaults.php @@ -3,54 +3,61 @@ if ($domains_processed == 1) { //define holiday presets - $preset[] = json_encode(array("new_years_day" => array("mday" => "1", "mon" => "1"))); - $preset[] = json_encode(array("martin_luther_king_jr_day" => array("wday" => "2", "mon" => "1", "mweek" => "3"))); - $preset[] = json_encode(array("presidents_day" => array("wday" => "2", "mon" => "2", "mweek" => "3"))); - $preset[] = json_encode(array("memorial_day" => array("mday" => "25-31", "wday" => "2", "mon" => "5"))); - $preset[] = json_encode(array("independence_day" => array("mday" => "4", "mon" => "7"))); - $preset[] = json_encode(array("labor_day" => array("wday" => "2", "mon" => "9", "mweek" => "1"))); - $preset[] = json_encode(array("columbus_day" => array("wday" => "2", "mon" => "10", "mweek" => "2"))); - $preset[] = json_encode(array("veterans_day" => array("mday" => "11", "mon" => "11"))); - $preset[] = json_encode(array("thanksgiving_day" => array("wday" => "5-6", "mon" => "11", "mweek" => "4"))); - $preset[] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12"))); + $preset['usa'][] = json_encode(array("new_years_day" => array("mday" => "1", "mon" => "1"))); + $preset['usa'][] = json_encode(array("martin_luther_king_jr_day" => array("wday" => "2", "mon" => "1", "mweek" => "3"))); + $preset['usa'][] = json_encode(array("presidents_day" => array("wday" => "2", "mon" => "2", "mweek" => "3"))); + $preset['usa'][] = json_encode(array("memorial_day" => array("mday" => "25-31", "wday" => "2", "mon" => "5"))); + $preset['usa'][] = json_encode(array("independence_day" => array("mday" => "4", "mon" => "7"))); + $preset['usa'][] = json_encode(array("labor_day" => array("wday" => "2", "mon" => "9", "mweek" => "1"))); + $preset['usa'][] = json_encode(array("columbus_day" => array("wday" => "2", "mon" => "10", "mweek" => "2"))); + $preset['usa'][] = json_encode(array("veterans_day" => array("mday" => "11", "mon" => "11"))); + $preset['usa'][] = json_encode(array("thanksgiving_day" => array("wday" => "5-6", "mon" => "11", "mweek" => "4"))); + $preset['usa'][] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12"))); - //define array of settings - $x = 0; - foreach ($preset as $json) { - $array[$x]['default_setting_category'] = 'time_conditions'; - $array[$x]['default_setting_subcategory'] = 'preset'; - $array[$x]['default_setting_name'] = 'array'; - $array[$x]['default_setting_value'] = $json; - $array[$x]['default_setting_enabled'] = 'true'; - $array[$x]['default_setting_description'] = 'Holiday'; - $x++; - } - - //get an array of the default settings - $sql = "select * from v_default_settings "; + //iterate and migrate old presets first + $sql = "update v_default_settings "; + $sql .= "set default_setting_subcategory = 'preset_usa' "; + $sql .= ", default_setting_description = 'usa Holiday' "; $sql .= "where default_setting_category = 'time_conditions' "; $sql .= "and default_setting_subcategory = 'preset' "; - $sql .= "and default_setting_name = 'array' "; $prep_statement = $db->prepare($sql); - $prep_statement->execute(); - $default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - - //find the missing default settings - $x = 0; - foreach ($array as $setting) { - $found = false; - $missing[$x] = $setting; - foreach ($default_settings as $row) { - if (trim($row['default_setting_value']) == trim($setting['default_setting_value'])) { - $found = true; - //remove items from the array that were found - unset($missing[$x]); - } - } - $x++; + if ($prep_statement) { + $prep_statement->execute(); + unset ($prep_statement, $sql); } + //iterate and add each, if necessary + $x = 0; + foreach ($preset as $region => $data) { + $sql = "select * from v_default_settings "; + $sql .= "where default_setting_category = 'time_conditions' "; + $sql .= "and default_setting_subcategory = 'preset_$region' "; + $sql .= "and default_setting_name = 'array' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + foreach ($data as $json) { + $found = false; + $missing[$x]['default_setting_category'] = 'time_conditions'; + $missing[$x]['default_setting_subcategory'] = "preset_$region"; + $missing[$x]['default_setting_name'] = 'array'; + $missing[$x]['default_setting_value'] = $json; + $missing[$x]['default_setting_enabled'] = 'true'; + $missing[$x]['default_setting_description'] = "$region Holiday"; + foreach ($default_settings as $row) { + if (trim($row['default_setting_value']) == trim($json)) { + $found = true; + //remove items from the array that were found + unset($missing[$x]); + } + } + $x++; + } + } + } + //add the missing default settings foreach ($missing as $row) { //add the default settings @@ -63,6 +70,39 @@ if ($domains_processed == 1) { } unset($missing); + $array[$x]['default_setting_category'] = 'time_conditions'; + $array[$x]['default_setting_subcategory'] = 'region'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'usa'; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = 'What region to use by default when choosing Time Conditions'; + $x++; + + //iterate and add each, if necessary + foreach ($array as $index => $default_settings) { + + //add the default setting + $sql = "select count(*) as num_rows from v_default_settings "; + $sql .= "where default_setting_category = '".$default_settings['default_setting_category']."' "; + $sql .= "and default_setting_subcategory = '".$default_settings['default_setting_subcategory']."' "; + $sql .= "and default_setting_name = '".$default_settings['default_setting_name']."' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset($prep_statement); + if ($row['num_rows'] == 0) { + $orm = new orm; + $orm->name('default_settings'); + $orm->save($array[$index]); + $message = $orm->message; + //print_r($message); + } + unset($row); + } + + } + //unset the array variable unset($array); } diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index 1be14bd414..96a6e8d019 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -44,10 +44,12 @@ require_once "resources/header.php"; $destination = new destinations; //load available presets - foreach ($_SESSION['time_conditions']['preset'] as $json) { + $preset_region = "preset_".$_SESSION['time_conditions']['region']; + foreach ($_SESSION['time_conditions'][$preset_region] as $json) { $available_presets[] = json_decode($json, true); } - + unset($preset_region); + //set the action as an add or an update if (isset($_REQUEST["id"])) { $action = "update"; From 8e9c961a18f4b13af5ab40f3bc5de2abfce665b8 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 3 Nov 2015 14:34:29 +0000 Subject: [PATCH 155/174] bugfix when retrieving region --- app/time_conditions/time_condition_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index 96a6e8d019..f3e70b9f77 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -44,7 +44,7 @@ require_once "resources/header.php"; $destination = new destinations; //load available presets - $preset_region = "preset_".$_SESSION['time_conditions']['region']; + $preset_region = "preset_".$_SESSION['time_conditions']['region']['text']; foreach ($_SESSION['time_conditions'][$preset_region] as $json) { $available_presets[] = json_decode($json, true); } From b3937d9410ec1bee94e16e9b5af09c92e142a8b8 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 3 Nov 2015 15:15:33 +0000 Subject: [PATCH 156/174] added England bank holidays currently it is not possible to integrate floating days (Christmas falling on a Sunday causing Tuesday to become holiday) or Easter, as it isn't a fixed rule for what day --- app/time_conditions/app_defaults.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/time_conditions/app_defaults.php b/app/time_conditions/app_defaults.php index e829c460a6..2fa4411a74 100644 --- a/app/time_conditions/app_defaults.php +++ b/app/time_conditions/app_defaults.php @@ -14,6 +14,13 @@ if ($domains_processed == 1) { $preset['usa'][] = json_encode(array("thanksgiving_day" => array("wday" => "5-6", "mon" => "11", "mweek" => "4"))); $preset['usa'][] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12"))); + $preset['england'][] = json_encode(array("new_years_day" => array("mday" => "1", "mon" => "1"))); + $preset['england'][] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12"))); + $preset['england'][] = json_encode(array("boxing_day" => array("mday" => "26", "mon" => "12"))); + $preset['england'][] = json_encode(array("may_day" => array("mon" => "5", "mweek" => "1", "wday" => "2"))); + $preset['england'][] = json_encode(array("spring_bank_holiday" => array("mon" => "5", "mday" => "25-31", "wday" => "2"))); + $preset['england'][] = json_encode(array("august_bank_holiday" => array("mon" => "8", "mday" => "25-31", "wday" => "2"))); + //iterate and migrate old presets first $sql = "update v_default_settings "; $sql .= "set default_setting_subcategory = 'preset_usa' "; From 758d6b9f532b86043269ea1d51cc298587fc4135 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 3 Nov 2015 16:41:59 -0700 Subject: [PATCH 157/174] Add functions to the config require 'resources.functions.config' --- resources/install/scripts/resources/functions/database.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/resources/functions/database.lua b/resources/install/scripts/resources/functions/database.lua index 50349b1b14..3cb9580d86 100644 --- a/resources/install/scripts/resources/functions/database.lua +++ b/resources/install/scripts/resources/functions/database.lua @@ -1,4 +1,4 @@ -require 'resources.config' +require 'resources.functions.config' require 'resources.functions.file_exists' require 'resources.functions.database_handle' From e7530d8bec284948176c28d2b92cbc90867b8e75 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 3 Nov 2015 16:44:51 -0700 Subject: [PATCH 158/174] Add the functions to the path for channel_utils. --- resources/install/scripts/resources/functions/channel_utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/resources/functions/channel_utils.lua b/resources/install/scripts/resources/functions/channel_utils.lua index 5cf33c5f8f..a94ceffe62 100644 --- a/resources/install/scripts/resources/functions/channel_utils.lua +++ b/resources/install/scripts/resources/functions/channel_utils.lua @@ -1,4 +1,4 @@ -require 'resources.config' +require 'resources.functions.config' require 'resources.functions.trim' local Database = require 'resources.functions.database' From d3d62295d6929697ed1279051d2e5d6e5d57de2a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 3 Nov 2015 19:28:10 -0700 Subject: [PATCH 159/174] This renables polycom line key value of 2 would use 2 keys or a value of 3 would be 3 keys. --- resources/templates/provision/polycom/4.x/{$mac}.cfg | 2 ++ resources/templates/provision/polycom/5.x/{$mac}.cfg | 2 ++ 2 files changed, 4 insertions(+) diff --git a/resources/templates/provision/polycom/4.x/{$mac}.cfg b/resources/templates/provision/polycom/4.x/{$mac}.cfg index 0326802b6e..b5d9431b66 100644 --- a/resources/templates/provision/polycom/4.x/{$mac}.cfg +++ b/resources/templates/provision/polycom/4.x/{$mac}.cfg @@ -4,8 +4,10 @@ {foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.user_id}" reg.{$row.line_number}.address="{$row.user_id}" reg.{$row.line_number}.label="{$row.user_id}" + reg.{$row.line_number}.type="private" reg.{$row.line_number}.auth.userId="{$row.user_id}" reg.{$row.line_number}.auth.password="{$row.password}" + reg.{$row.line_number}.lineKeys="{$line_key_value_{$row.line_number}}" {if isset($row.outbound_proxy)}reg.{$row.line_number}.outboundProxy.address = "{$row.outbound_proxy}"{/if} {if isset($row.sip_port)}reg.{$row.line_number}.outboundProxy.port="{$row.sip_port}"{else}reg.{$row.line_number}.server.1.port="5060"{/if} diff --git a/resources/templates/provision/polycom/5.x/{$mac}.cfg b/resources/templates/provision/polycom/5.x/{$mac}.cfg index 0326802b6e..b5d9431b66 100755 --- a/resources/templates/provision/polycom/5.x/{$mac}.cfg +++ b/resources/templates/provision/polycom/5.x/{$mac}.cfg @@ -4,8 +4,10 @@ {foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.user_id}" reg.{$row.line_number}.address="{$row.user_id}" reg.{$row.line_number}.label="{$row.user_id}" + reg.{$row.line_number}.type="private" reg.{$row.line_number}.auth.userId="{$row.user_id}" reg.{$row.line_number}.auth.password="{$row.password}" + reg.{$row.line_number}.lineKeys="{$line_key_value_{$row.line_number}}" {if isset($row.outbound_proxy)}reg.{$row.line_number}.outboundProxy.address = "{$row.outbound_proxy}"{/if} {if isset($row.sip_port)}reg.{$row.line_number}.outboundProxy.port="{$row.sip_port}"{else}reg.{$row.line_number}.server.1.port="5060"{/if} From 503461fca15a9ccf095e236b8a424e99200a9447 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 4 Nov 2015 19:59:27 -0700 Subject: [PATCH 160/174] Change switch.provision.dir to provision.path.text. This indicates where to save the provisioning files on the file system. --- app/devices/device_edit.php | 2 +- app/devices/device_profile_edit.php | 2 +- app/provision/resources/classes/provision.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 85885a9467..3ff97b01d8 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -288,7 +288,7 @@ require_once "resources/require.php"; } //write the provision files - if (strlen($_SESSION['switch']['provision']['dir']) > 0) { + if (strlen($_SESSION['provision']['path']['text']) > 0) { require_once "app/provision/provision_write.php"; } diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php index 092fa5e6eb..db58b6063a 100644 --- a/app/devices/device_profile_edit.php +++ b/app/devices/device_profile_edit.php @@ -138,7 +138,7 @@ require_once "resources/require.php"; } //write the provision files - if (strlen($_SESSION['switch']['provision']['dir']) > 0) { + if (strlen($_SESSION['provision']['path']['text']) > 0) { require_once "app/provision/provision_write.php"; } diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index d2a4a6f562..66fa4645cb 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -822,8 +822,8 @@ include "root.php"; //$file_size = round(filesize($new_path)/1024, 2); //echo $this->template_dir."/".$device_template."/".$file_name." $file_size\n"; //write the configuration to the directory - if (strlen($_SESSION['switch']['provision']['dir']) > 0) { - $dir_array = explode(";", $_SESSION['switch']['provision']['dir']); + if (strlen($provision["path"]) > 0) { + $dir_array = explode(";", $provision["path"]); foreach($dir_array as $directory) { if (file_exists($this->template_dir."/".$device_template."/".$file_name)) { From f87195204c29588339f6b665318667524e1e8791 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 4 Nov 2015 20:01:11 -0700 Subject: [PATCH 161/174] Add the provision.path.text to default settings. --- app/provision/app_defaults.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/provision/app_defaults.php b/app/provision/app_defaults.php index 942c228efd..7e80fd2e59 100644 --- a/app/provision/app_defaults.php +++ b/app/provision/app_defaults.php @@ -103,6 +103,13 @@ $array[$x]['default_setting_description'] = ''; $x++; $array[$x]['default_setting_category'] = 'provision'; + $array[$x]['default_setting_subcategory'] = 'path'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = ''; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = ''; + $x++; + $array[$x]['default_setting_category'] = 'provision'; $array[$x]['default_setting_subcategory'] = 'voicemail_number'; $array[$x]['default_setting_name'] = 'text'; $array[$x]['default_setting_value'] = '*97'; From ddaae7eec592cc55002b5846ae374a7d32e111ad Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 5 Nov 2015 18:02:08 +0300 Subject: [PATCH 162/174] Update follow_me.lua 1. Use `cache` class so now it generates memcache events. 2. Do not use nested if (simplify code) 3. Use local variables. 4. Remove redundant checks. --- resources/install/scripts/follow_me.lua | 270 ++++++++---------- .../resources/functions/channel_utils.lua | 8 + 2 files changed, 134 insertions(+), 144 deletions(-) diff --git a/resources/install/scripts/follow_me.lua b/resources/install/scripts/follow_me.lua index 5dce059ae0..ee1a267672 100644 --- a/resources/install/scripts/follow_me.lua +++ b/resources/install/scripts/follow_me.lua @@ -22,158 +22,140 @@ -- Contributor(s): -- Mark J Crane ---set default variables - min_digits = "1"; - max_digits = "11"; - max_tries = "3"; - digit_timeout = "3000"; - ---debug - debug["sql"] = true; - ---define the trim function - require "resources.functions.trim"; - ---define the explode function - require "resources.functions.explode"; +--include config.lua + require "resources.functions.config"; --create the api object api = freeswitch.API(); ---include config.lua - require "resources.functions.config"; + require "resources.functions.channel_utils"; + local log = require "resources.functions.log".follow_me + local cache = require "resources.functions.cache" + local Database = require "resources.functions.database" --check if the session is ready - if ( session:ready() ) then - --answer the call - session:answer(); - - --get the variables - pin_number = session:getVariable("pin_number"); - sounds_dir = session:getVariable("sounds_dir"); - domain_uuid = session:getVariable("domain_uuid"); - domain_name = session:getVariable("domain_name"); - extension_uuid = session:getVariable("extension_uuid"); - context = session:getVariable("context"); - if (not context ) then context = 'default'; end - - --set the sounds path for the language, dialect and voice - default_language = session:getVariable("default_language"); - default_dialect = session:getVariable("default_dialect"); - default_voice = session:getVariable("default_voice"); - if (not default_language) then default_language = 'en'; end - if (not default_dialect) then default_dialect = 'us'; end - if (not default_voice) then default_voice = 'callie'; end - - --a moment to sleep - session:sleep(1000); - - --connect to the database - require "resources.functions.database_handle"; - dbh = database_handle('system'); - - --determine whether to update the dial string - sql = "select * from v_extensions "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n"); - end - status = dbh:query(sql, function(row) - extension = row.extension; - number_alias = row.number_alias or ''; - accountcode = row.accountcode; - follow_me_uuid = row.follow_me_uuid; - --freeswitch.consoleLog("NOTICE", "[call forward] extension "..row.extension.."\n"); - --freeswitch.consoleLog("NOTICE", "[call forward] accountcode "..row.accountcode.."\n"); - end); + if not session:ready() then return end - --determine whether to update the dial string - enabled = "false"; - sql = "select * from v_follow_me "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n"); - end - status = dbh:query(sql, function(row) - enabled = row.follow_me_enabled; - call_prompt = row.call_prompt; - cid_name_prefix = row.cid_name_prefix; - cid_number_prefix = row.cid_number_prefix; - dial_string = row.dial_string; - end); - - --set follow me - if (enabled == "false") then - --answer and play a tone - session:answer(); - api = freeswitch.API(); - reply = api:executeString("uuid_display "..session:get_uuid().." Activated "); +--answer the call + session:answer(); - session:execute("sleep", "2000"); - session:execute("playback", "tone_stream://%(200,0,500,600,700)"); - --notify the caller - --session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav"); - end - - --unset follow me - if (enabled == "true") then - --answer and play a tone - session:answer(); - api = freeswitch.API(); - reply = api:executeString("uuid_display "..session:get_uuid().." Cancelled "); +--get the variables + local domain_uuid = session:getVariable("domain_uuid"); + local domain_name = session:getVariable("domain_name"); + local extension_uuid = session:getVariable("extension_uuid"); - session:execute("sleep", "2000"); - session:execute("playback", "tone_stream://%(500,0,300,200,100,50,25)"); - --notify the caller - --session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav"); - end +--set the sounds path for the language, dialect and voice + local sounds_dir = session:getVariable("sounds_dir"); + local default_language = session:getVariable("default_language") or 'en'; + local default_dialect = session:getVariable("default_dialect") or 'us'; + local default_voice = session:getVariable("default_voice") or 'callie'; - --enable or disable follow me - if (follow_me_uuid ~= nil) then - sql = "update v_follow_me set "; - if (enabled == "true") then - sql = sql .. "follow_me_enabled = 'false' "; - else - sql = sql .. "follow_me_enabled = 'true' "; - end - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n"); - end - dbh:query(sql); - end - - --update the extension - sql = "update v_extensions set "; - if (enabled == "true") then - sql = sql .. "dial_string = null, "; - else - sql = sql .. "dial_string = '"..dial_string.."', "; - end - sql = sql .. "do_not_disturb = 'false', "; - sql = sql .. "forward_all_enabled= 'false' "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n"); - end - dbh:query(sql); - - --clear the cache - if (extension ~= nil) then - api:execute("memcache", "delete directory:"..extension.."@"..domain_name); - if #number_alias > 0 then - api:execute("memcache", "delete directory:"..number_alias.."@"..domain_name); - end - end - - --wait for the file to be written before proceeding - session:sleep(1000); - - --end the call - session:hangup(); - +--a moment to sleep + session:sleep(1000); + +--check if the session is ready + if not session:ready() then return end + +--connect to the database + local dbh = Database.new('system'); + +--determine whether to update the dial string + local sql = "select extension, number_alias, accountcode, follow_me_uuid "; + sql = sql .. "from v_extensions "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; + if (debug["sql"]) then + log.notice(sql); end + + local row = dbh:first_row(sql) + if not row then return end + + local extension = row.extension; + local number_alias = row.number_alias or ''; + local accountcode = row.accountcode; + local follow_me_uuid = row.follow_me_uuid; + +--determine whether to update the dial string + sql = "select follow_me_enabled, call_prompt, cid_name_prefix, cid_number_prefix, dial_string " + sql = sql .. "from v_follow_me "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' "; + if (debug["sql"]) then + log.notice(sql); + end + + row = dbh:first_row(sql) + if not row then return end + + local enabled = row.follow_me_enabled; + local call_prompt = row.call_prompt; + local cid_name_prefix = row.cid_name_prefix; + local cid_number_prefix = row.cid_number_prefix; + local dial_string = row.dial_string; + +--set follow me + if (enabled == "false") then + --play a tone + channel_display(session:get_uuid(), "Activated") + + session:execute("sleep", "2000"); + session:execute("playback", "tone_stream://%(200,0,500,600,700)"); + --notify the caller + --session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav"); + end + +--unset follow me + if (enabled == "true") then + --play a tone + channel_display(session:get_uuid(), "Cancelled") + + session:execute("sleep", "2000"); + session:execute("playback", "tone_stream://%(500,0,300,200,100,50,25)"); + --notify the caller + --session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav"); + end + +--enable or disable follow me + sql = "update v_follow_me set "; + if (enabled == "true") then + sql = sql .. "follow_me_enabled = 'false' "; + else + sql = sql .. "follow_me_enabled = 'true' "; + end + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' "; + if (debug["sql"]) then + log.notice(sql); + end + dbh:query(sql); + +--update the extension + sql = "update v_extensions set "; + if (enabled == "true") then + sql = sql .. "dial_string = null, "; + else + sql = sql .. "dial_string = '"..dial_string:gsub("'", "''").."', "; + end + sql = sql .. "do_not_disturb = 'false', "; + sql = sql .. "forward_all_enabled= 'false' "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; + if (debug["sql"]) then + log.notice(sql); + end + dbh:query(sql); + +--clear the cache + if (extension ~= nil) and cache.support() then + cache.del("directory:"..extension.."@"..domain_name); + if #number_alias > 0 then + cache.del("directory:"..number_alias.."@"..domain_name); + end + end + +--wait for the file to be written before proceeding + session:sleep(1000); + +--end the call + session:hangup(); diff --git a/resources/install/scripts/resources/functions/channel_utils.lua b/resources/install/scripts/resources/functions/channel_utils.lua index a94ceffe62..3676f87d7d 100644 --- a/resources/install/scripts/resources/functions/channel_utils.lua +++ b/resources/install/scripts/resources/functions/channel_utils.lua @@ -23,6 +23,14 @@ function channel_evalute(uuid, cmd) return result end +function channel_display(uuid, text) + local cmd = ("uuid_display %s '%s'"):format(uuid, text) + local result = trim(api:executeString(cmd)) + if result:sub(1, 4) == '-ERR' then return nil, result end + if result == '_undef_' then return false end + return result +end + local _switchname local function switchname() if _switchname then return _switchname end From 78b65831ec4057b8ee1362dca0ccebad9be18e69 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 11:19:22 -0700 Subject: [PATCH 163/174] Add new device permissions device_username_password, device_alternate, device_enable. --- app/devices/app_config.php | 14 + app/devices/device_edit.php | 932 ++++++++++++++++++------------------ 2 files changed, 485 insertions(+), 461 deletions(-) diff --git a/app/devices/app_config.php b/app/devices/app_config.php index d8f6591886..3e9a9c836e 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -105,6 +105,15 @@ $y++; $apps[$x]['permissions'][$y]['name'] = 'device_domain'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_username_password'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_alternate'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; $y++; $apps[$x]['permissions'][$y]['name'] = "device_profile_view"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; @@ -127,6 +136,11 @@ $y++; $apps[$x]['permissions'][$y]['name'] = 'device_all'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_enable'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; //schema details $y = 0; //table array index diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 3ff97b01d8..949411d2a0 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -590,131 +590,133 @@ require_once "resources/require.php"; echo "
".$text['label-lines'].""; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (permission_exists('device_line_password')) { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - $x = 0; - foreach($device_lines as $row) { - //determine whether to hide the element - if (strlen($device_line_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_line_uuid']) > 0) { - echo " \n"; - } - //show each row in the array - echo " \n"; - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - if (permission_exists('device_line_password')) { - echo " \n"; - } - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " "; + echo " "; + echo " "; - echo " "; - if (permission_exists('device_key_add') || permission_exists('device_key_edit')) { + $x = 0; + foreach($device_lines as $row) { + //determine whether to hide the element + if (strlen($device_line_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_line_uuid']) > 0) { + echo " \n"; + } + //show each row in the array + echo " \n"; + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + if (permission_exists('device_line_password')) { + echo " \n"; + } + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + echo " \n"; + $x++; + } + echo "
".$text['label-line']."".$text['label-server_address']."".$text['label-outbound_proxy']."".$text['label-display_name']."".$text['label-user_id']."".$text['label-auth_id']."".$text['label-password']."".$text['label-sip_port']."".$text['label-sip_transport']."".$text['label-register_expires']."".$text['label-enabled']." 
\n"; - $selected = "selected=\"selected\" "; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (strlen($row['device_line_uuid']) > 0) { - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; - } + if (permission_exists('device_line_view') { + echo "
".$text['label-lines'].""; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('device_line_password')) { + echo " \n"; } - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; - $x++; - } - echo "
".$text['label-line']."".$text['label-server_address']."".$text['label-outbound_proxy']."".$text['label-display_name']."".$text['label-user_id']."".$text['label-auth_id']."".$text['label-password']."".$text['label-sip_port']."".$text['label-sip_transport']."".$text['label-register_expires']."".$text['label-enabled']." 
\n"; - if (strlen($text['description-lines']) > 0) { - echo "
".$text['description-lines']."\n"; - } - echo "
\n"; + $selected = "selected=\"selected\" "; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (strlen($row['device_line_uuid']) > 0) { + if (permission_exists('device_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo "
\n"; + if (strlen($text['description-lines']) > 0) { + echo "
".$text['description-lines']."\n"; + } + echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
".$text['label-device_key_category']."".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
\n"; - echo " \n"; + echo " \n"; - echo "\n"; - $selected = "selected='selected'"; - echo " \n"; - echo "\n"; - //echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { - $device_key_vendor = $row['device_key_vendor']; - } - else { - $device_key_vendor = $device_vendor; - } - ?> - - - - - - \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - //echo " \n"; - //echo " \n"; - if (strlen($row['device_key_uuid']) > 0) { - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; } - } - echo "
\n"; + $selected = "selected='selected'"; + echo " \n"; + echo "\n"; + //echo " \n"; + if (strlen($row['device_key_vendor']) > 0) { + $device_key_vendor = $row['device_key_vendor']; + } + else { + $device_key_vendor = $device_vendor; + } + ?> + + + + + + \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + //echo " \n"; + //echo " \n"; + if (strlen($row['device_key_uuid']) > 0) { + if (permission_exists('device_key_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo "
\n"; + if (strlen($text['description-keys']) > 0) { + echo "
".$text['description-keys']."\n"; + } + echo "
\n"; - if (strlen($text['description-keys']) > 0) { - echo "
".$text['description-keys']."\n"; - } - echo "
".$text['label-settings'].""; @@ -1153,42 +1157,46 @@ require_once "resources/require.php"; echo "
\n"; - echo " ".$text['label-device']."\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo $text['description-device']."\n"; - echo "
\n"; + echo " ".$text['label-device']."\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-device']."\n"; + echo "
\n"; - echo " ".$text['label-device_uuid_alternate']."\n"; - echo "\n"; - if (strlen($device_uuid_alternate) == 0) { - echo " "; + if (permission_exists('device_alternate')) { + echo "
\n"; + echo " ".$text['label-device_uuid_alternate']."\n"; + echo "\n"; + if (strlen($device_uuid_alternate) == 0) { + echo " "; + } + else { + $label = $device_alternate[0]['device_label']; + if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; } + if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; } + echo " \n"; + echo " \n"; + echo " "; + echo " \n"; + echo " \n"; + echo "
$label $v_link_label_delete
\n"; + unset($label); + } + echo $text['description-device_uuid_alternate']."\n"; + echo "
\n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo "
$label $v_link_label_delete
\n"; - unset($label); - } - echo $text['description-device_uuid_alternate']."\n"; - echo "
\n"; @@ -1253,29 +1261,31 @@ require_once "resources/require.php"; echo " \n"; } - echo "
\n"; - echo " ".$text['label-device_provision_enable']."\n"; - echo "\n"; - echo "
\n"; + echo " ".$text['label-device_provision_enable']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_provision_enable']."\n"; + echo "
\n"; From 5f7fd707c2ec4858792ce0c9252e8988e8d9703d Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 11:24:28 -0700 Subject: [PATCH 164/174] Fix the syntax by adding a missing ). --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 949411d2a0..b69081b6b1 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -590,7 +590,7 @@ require_once "resources/require.php"; echo "
".$text['label-lines'].""; From ef5a1eb4553eb5ffba832cbe29c3824cd0a6642a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 11:56:50 -0700 Subject: [PATCH 165/174] Add new device permissions for mac address, template, label, vendor, model, firmware, and description. --- app/devices/app_config.php | 26 ++++++ app/devices/device_edit.php | 160 +++++++++++++++++++++--------------- 2 files changed, 118 insertions(+), 68 deletions(-) diff --git a/app/devices/app_config.php b/app/devices/app_config.php index 3e9a9c836e..6f3f3cfaac 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -39,6 +39,18 @@ $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_mac_address'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_label'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_template'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; $apps[$x]['permissions'][$y]['name'] = "device_extension_view"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; @@ -137,10 +149,24 @@ $apps[$x]['permissions'][$y]['name'] = 'device_all'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_vendor'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_model'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_firmware'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; $apps[$x]['permissions'][$y]['name'] = 'device_enable'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $apps[$x]['permissions'][$y]['groups'][] = 'admin'; $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_description'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; //schema details $y = 0; //table array index diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index b69081b6b1..5d32adfa04 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -526,69 +526,82 @@ require_once "resources/require.php"; echo " ".$text['label-device_mac_address']."\n"; echo "\n"; - echo " \n"; + if (permission_exists('device_mac_address')) { + echo " \n"; + } + else { + echo $device_mac_address; + } echo " \n"; echo "
\n"; echo $text['description-device_mac_address']."\n"; echo "
\n"; echo " ".$text['label-device_label']."\n"; echo "\n"; - echo " \n"; + if (permission_exists('device_label')) { + echo " \n"; + } + else { + echo $device_label; + } echo "
\n"; echo $text['description-device_label']."\n"; echo "
\n"; - echo " ".$text['label-device_template']."\n"; - echo "\n"; - $device = new device; - $template_dir = $device->get_template_dir(); + if (permission_exists('device_template')) { + echo "
\n"; + echo " ".$text['label-device_template']."\n"; + echo "\n"; + $device = new device; + $template_dir = $device->get_template_dir(); - echo "\n"; + echo "\n"; - if (is_dir($template_dir)) { - $templates = scandir($template_dir); - foreach($templates as $dir) { - if($file != "." && $dir != ".." && $dir[0] != '.') { - if(is_dir($template_dir . "/" . $dir)) { - echo ""; - $dh_sub=$template_dir . "/" . $dir; - if(is_dir($dh_sub)) { - $templates_sub = scandir($dh_sub); - foreach($templates_sub as $dir_sub) { - if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') { - if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) { - if ($device_template == $dir."/".$dir_sub) { - echo "\n"; - } - else { - echo "\n"; + if (is_dir($template_dir)) { + $templates = scandir($template_dir); + foreach($templates as $dir) { + if($file != "." && $dir != ".." && $dir[0] != '.') { + if(is_dir($template_dir . "/" . $dir)) { + echo ""; + $dh_sub=$template_dir . "/" . $dir; + if(is_dir($dh_sub)) { + $templates_sub = scandir($dh_sub); + foreach($templates_sub as $dir_sub) { + if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') { + if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) { + if ($device_template == $dir."/".$dir_sub) { + echo "\n"; + } + else { + echo "\n"; + } } } } + closedir($dh_sub); } - closedir($dh_sub); + echo ""; } - echo ""; } } + closedir($dh); } - closedir($dh); - } - echo "\n"; - echo "
\n"; - echo $text['description-device_template']."\n"; - echo "
\n"; - echo " ".$text['label-device_vendor']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_vendor']."\n"; - echo "
\n"; + echo " ".$text['label-device_vendor']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_vendor']."\n"; + echo "
\n"; - echo " ".$text['label-device_model']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_model']."\n"; - echo "
\n"; + echo " ".$text['label-device_model']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_model']."\n"; + echo "
\n"; - echo " ".$text['label-device_firmware_version']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_firmware_version']."\n"; - echo "
\n"; + echo " ".$text['label-device_firmware_version']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_firmware_version']."\n"; + echo "
\n"; - echo " \n"; + if (permission_exists('device_description')) { + echo " \n"; + } + else { + echo $device_description."\n"; + } echo "
\n"; echo $text['description-device_description']."\n"; echo "
\n"; if (permission_exists('device_mac_address')) { echo " \n"; + echo "
\n"; + echo $text['description-device_mac_address']."\n"; } else { echo $device_mac_address; } echo " \n"; - echo "
\n"; - echo $text['description-device_mac_address']."\n"; echo "
\n"; if (permission_exists('device_label')) { echo " \n"; + echo "
\n"; + echo $text['description-device_label']."\n"; } else { echo $device_label; } - echo "
\n"; - echo $text['description-device_label']."\n"; + echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
\n"; - echo " ".$text['label-device_key_category']."".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
\n"; + echo " \n"; - echo "\n"; - $selected = "selected='selected'"; - echo " \n"; - echo "\n"; + $selected = "selected='selected'"; + echo " \n"; + echo "\n"; - //echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { - $device_key_vendor = $row['device_key_vendor']; - } - else { - $device_key_vendor = $device_vendor; - } + echo "\n"; + //echo " \n"; + if (strlen($row['device_key_vendor']) > 0) { + $device_key_vendor = $row['device_key_vendor']; + } + else { + $device_key_vendor = $device_vendor; + } + ?> + + + + - - - + + + \n"; - echo "\n"; - echo " + + \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + //echo " \n"; + //echo " \n"; + if (strlen($row['device_key_uuid']) > 0) { + if (permission_exists('device_key_delete')) { + echo " $v_link_label_delete\n"; } - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - //echo " \n"; - //echo " \n"; - if (strlen($row['device_key_uuid']) > 0) { - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; - } - } - echo "
\n"; - if (strlen($text['description-keys']) > 0) { - echo "
".$text['description-keys']."\n"; - } - echo " "; - echo " "; + } + echo " \n"; + echo " \n"; + //set the previous vendor + $previous_device_key_vendor = $row['device_key_vendor']; + //increment the array key + $x++; } + echo " \n"; + if (strlen($text['description-keys']) > 0) { + echo "
".$text['description-keys']."\n"; + } + echo " "; + echo " "; } //device settings @@ -1313,12 +1314,13 @@ require_once "resources/require.php"; echo "\n"; if (permission_exists('device_description')) { echo " \n"; + echo "
\n"; + echo $text['description-device_description']."\n"; } else { echo $device_description."\n"; } - echo "
\n"; - echo $text['description-device_description']."\n"; + echo "\n"; echo "\n"; echo " \n"; From d39d58e6f6c7027c3450392d9bc78d0f0a80b172 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 12:11:53 -0700 Subject: [PATCH 167/174] Show device copy when user has device_add permission. --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index f26e2ff17f..12b4bfc0b2 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -514,7 +514,7 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; echo " \n"; - if ($action != "add") { + if (permission_exists('device_add') && $action != "add") { echo " \n"; } echo " \n"; From cca5c118df17b9a1ef57bf08fdd503ce32908767 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 12:25:30 -0700 Subject: [PATCH 168/174] Secure the device mac address when the user doesn't have permission to change it. --- app/devices/device_edit.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 12b4bfc0b2..af2231ef23 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -128,10 +128,25 @@ require_once "resources/require.php"; //get http post variables and set them to php variables if (count($_POST) > 0) { + //device mac address + if (permission_exists('device_mac_address')) { + $device_mac_address = check_str($_POST["device_mac_address"]); + $device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address)); + $_POST["device_mac_address"] = $device_mac_address; + } + else { + $orm = new orm; + $orm->name('devices'); + $orm->uuid($device_uuid); + $result = $orm->find()->get(); + //$message = $orm->message; + foreach ($result as &$row) { + $device_mac_address = $row["device_mac_address"]; + $_POST["device_mac_address"] = $device_mac_address; + } + unset ($prep_statement); + } //devices - $device_mac_address = check_str($_POST["device_mac_address"]); - $device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address)); - $_POST["device_mac_address"] = $device_mac_address; $device_label = check_str($_POST["device_label"]); $device_vendor = check_str($_POST["device_vendor"]); $device_uuid_alternate = check_str($_POST["device_uuid_alternate"]); From 7cda301460c5e6c85a678c704a070df9a2f641f1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 8 Nov 2015 07:30:29 -0700 Subject: [PATCH 169/174] Add the following to all yealink provisioning templates. account.1.nat.udp_update_enable = 3 In order to setup keep alive with sip notify. --- resources/templates/provision/yealink/t22p/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t23g/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t23p/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t26p/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t27p/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t28p/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t29g/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t32g/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t38g/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t41p/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t42g/{$mac}.cfg | 2 +- resources/templates/provision/yealink/vp530/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/w52p/{$mac}.cfg | 4 ++-- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/resources/templates/provision/yealink/t22p/{$mac}.cfg b/resources/templates/provision/yealink/t22p/{$mac}.cfg index 7fef6e9bfc..ce904e36e6 100644 --- a/resources/templates/provision/yealink/t22p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t22p/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t23g/{$mac}.cfg b/resources/templates/provision/yealink/t23g/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t23g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t23g/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t23p/{$mac}.cfg b/resources/templates/provision/yealink/t23p/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t23p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t23p/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t26p/{$mac}.cfg b/resources/templates/provision/yealink/t26p/{$mac}.cfg index ecc4c4997b..2761774eaa 100644 --- a/resources/templates/provision/yealink/t26p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t26p/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t27p/{$mac}.cfg b/resources/templates/provision/yealink/t27p/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t27p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t27p/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t28p/{$mac}.cfg b/resources/templates/provision/yealink/t28p/{$mac}.cfg index ecc4c4997b..2761774eaa 100644 --- a/resources/templates/provision/yealink/t28p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t28p/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t29g/{$mac}.cfg b/resources/templates/provision/yealink/t29g/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t29g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t29g/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t32g/{$mac}.cfg b/resources/templates/provision/yealink/t32g/{$mac}.cfg index b7de551e22..a7f7534e5e 100644 --- a/resources/templates/provision/yealink/t32g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t32g/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t38g/{$mac}.cfg b/resources/templates/provision/yealink/t38g/{$mac}.cfg index e2f464c29b..cffa4df9dc 100644 --- a/resources/templates/provision/yealink/t38g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t38g/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t41p/{$mac}.cfg b/resources/templates/provision/yealink/t41p/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t41p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t41p/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t42g/{$mac}.cfg b/resources/templates/provision/yealink/t42g/{$mac}.cfg index 94d6cc28a1..70c98e9022 100644 --- a/resources/templates/provision/yealink/t42g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t42g/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/vp530/{$mac}.cfg b/resources/templates/provision/yealink/vp530/{$mac}.cfg index a380a3f81d..b35405d03e 100644 --- a/resources/templates/provision/yealink/vp530/{$mac}.cfg +++ b/resources/templates/provision/yealink/vp530/{$mac}.cfg @@ -253,8 +253,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/w52p/{$mac}.cfg b/resources/templates/provision/yealink/w52p/{$mac}.cfg index a6bc0d586a..2509a41fbf 100644 --- a/resources/templates/provision/yealink/w52p/{$mac}.cfg +++ b/resources/templates/provision/yealink/w52p/{$mac}.cfg @@ -147,8 +147,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = From 4ef7b049b0a3e162cae714cc7d2bbd1a9aa6a5ab Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 8 Nov 2015 07:44:45 -0700 Subject: [PATCH 170/174] Change base_dir to script_dir in --- resources/templates/conf/autoload_configs/lua.conf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/conf/autoload_configs/lua.conf.xml b/resources/templates/conf/autoload_configs/lua.conf.xml index 0758bb6762..a5d861e812 100644 --- a/resources/templates/conf/autoload_configs/lua.conf.xml +++ b/resources/templates/conf/autoload_configs/lua.conf.xml @@ -13,7 +13,7 @@ These entries will be pre-pended to the LUA_PATH environment variable --> - + From a01a61e02cd6634e2a0567dd5539a6fbba5f7f17 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 8 Nov 2015 13:40:08 -0700 Subject: [PATCH 171/174] Remove /scripts from the path as it is redundant. --- resources/templates/conf/autoload_configs/lua.conf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/conf/autoload_configs/lua.conf.xml b/resources/templates/conf/autoload_configs/lua.conf.xml index a5d861e812..534505dc3b 100644 --- a/resources/templates/conf/autoload_configs/lua.conf.xml +++ b/resources/templates/conf/autoload_configs/lua.conf.xml @@ -13,7 +13,7 @@ These entries will be pre-pended to the LUA_PATH environment variable --> - + From 131954137ae9e4da85e16ee7fde2dc7f5738b1b1 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 9 Nov 2015 11:47:15 +0000 Subject: [PATCH 172/174] Bugfix for destinations_edit.php the tr_fax_detecion segment is optional so causes the onchange_type javascript to stop when it can't find it. --- app/destinations/destination_edit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index f2f446510a..c09cc5d6ac 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -543,7 +543,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " if (document.getElementById('tr_caller_id_name')) { document.getElementById('tr_caller_id_name').style.display = 'none'; }\n"; echo " if (document.getElementById('tr_caller_id_number')) { document.getElementById('tr_caller_id_number').style.display = 'none'; }\n"; echo " document.getElementById('tr_actions').style.display = 'none';\n"; - echo " document.getElementById('tr_fax_detection').style.display = 'none';\n"; + echo " if (document.getElementById('tr_fax_detection')) { document.getElementById('tr_fax_detection').style.display = ''; }\n"; echo " document.getElementById('tr_cid_name_prefix').style.display = 'none';\n"; echo " if (document.getElementById('tr_sell')) { document.getElementById('tr_sell').style.display = 'none'; }\n"; echo " if (document.getElementById('tr_buy')) { document.getElementById('tr_buy').style.display = 'none'; }\n"; @@ -555,7 +555,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " if (document.getElementById('tr_caller_id_name')) { document.getElementById('tr_caller_id_name').style.display = ''; }\n"; echo " if (document.getElementById('tr_caller_id_number')) { document.getElementById('tr_caller_id_number').style.display = ''; }\n"; echo " document.getElementById('tr_actions').style.display = '';\n"; - echo " document.getElementById('tr_fax_detection').style.display = '';\n"; + echo " if (document.getElementById('tr_fax_detection')) { document.getElementById('tr_fax_detection').style.display = ''; }\n"; echo " document.getElementById('tr_cid_name_prefix').style.display = '';\n"; echo " if (document.getElementById('tr_sell')) { document.getElementById('tr_sell').style.display = ''; }\n"; echo " if (document.getElementById('tr_buy')) { document.getElementById('tr_buy').style.display = ''; }\n"; From b3133f1eb11e22629aa787ba7b0c4f75a9843ad8 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 9 Nov 2015 11:49:09 +0000 Subject: [PATCH 173/174] missed none when pasting new code --- app/destinations/destination_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index c09cc5d6ac..d6051689c1 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -543,7 +543,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " if (document.getElementById('tr_caller_id_name')) { document.getElementById('tr_caller_id_name').style.display = 'none'; }\n"; echo " if (document.getElementById('tr_caller_id_number')) { document.getElementById('tr_caller_id_number').style.display = 'none'; }\n"; echo " document.getElementById('tr_actions').style.display = 'none';\n"; - echo " if (document.getElementById('tr_fax_detection')) { document.getElementById('tr_fax_detection').style.display = ''; }\n"; + echo " if (document.getElementById('tr_fax_detection')) { document.getElementById('tr_fax_detection').style.display = 'none'; }\n"; echo " document.getElementById('tr_cid_name_prefix').style.display = 'none';\n"; echo " if (document.getElementById('tr_sell')) { document.getElementById('tr_sell').style.display = 'none'; }\n"; echo " if (document.getElementById('tr_buy')) { document.getElementById('tr_buy').style.display = 'none'; }\n"; From 0e5b10d265808e867d8e2a1e17fd2f1ef16e69bb Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 9 Nov 2015 16:55:35 +0300 Subject: [PATCH 174/174] Update. call_forward.lua script Fix. Set outbound caller id Remove. Nested if Use. cache class Use. database class --- resources/install/scripts/call_forward.lua | 485 ++++++++++++--------- 1 file changed, 272 insertions(+), 213 deletions(-) diff --git a/resources/install/scripts/call_forward.lua b/resources/install/scripts/call_forward.lua index 553a883c20..fc4f693f38 100644 --- a/resources/install/scripts/call_forward.lua +++ b/resources/install/scripts/call_forward.lua @@ -28,250 +28,309 @@ max_tries = "3"; digit_timeout = "3000"; ---debug - debug["sql"] = false; - --define the trim function require "resources.functions.trim" ---define the explode function - require "resources.functions.explode" - --create the api object api = freeswitch.API(); --include config.lua require "resources.functions.config"; +--include config.lua + require "resources.functions.settings"; + + require "resources.functions.channel_utils"; + + local log = require "resources.functions.log".call_forward + local cache = require "resources.functions.cache" + local Database = require "resources.functions.database" + + local function opt(t, ...) + if select('#', ...) == 0 then + return t + end + if type(t) ~= 'table' then + return nil + end + return opt(t[...], select(2, ...)) + end + + local function empty(t) + return (not t) or (#t == 0) + end + --check if the session is ready - if (session:ready()) then - --answer the call - session:answer(); + if not session:ready() then return end - --get the variables - enabled = session:getVariable("enabled"); - pin_number = session:getVariable("pin_number"); - sounds_dir = session:getVariable("sounds_dir"); - domain_uuid = session:getVariable("domain_uuid"); - domain_name = session:getVariable("domain_name"); - extension_uuid = session:getVariable("extension_uuid"); - context = session:getVariable("context"); - if (not context ) then context = 'default'; end - request_id = session:getVariable("request_id"); +--answer the call + session:answer(); - --set the sounds path for the language, dialect and voice - default_language = session:getVariable("default_language"); - default_dialect = session:getVariable("default_dialect"); - default_voice = session:getVariable("default_voice"); - if (not default_language) then default_language = 'en'; end - if (not default_dialect) then default_dialect = 'us'; end - if (not default_voice) then default_voice = 'callie'; end +--get the variables + local enabled = session:getVariable("enabled"); + local pin_number = session:getVariable("pin_number"); + local sounds_dir = session:getVariable("sounds_dir"); + local domain_uuid = session:getVariable("domain_uuid"); + local domain_name = session:getVariable("domain_name"); + local extension_uuid = session:getVariable("extension_uuid"); + local request_id = session:getVariable("request_id"); + local extension, dial_string - --a moment to sleep - session:sleep(1000); +--set the sounds path for the language, dialect and voice + local default_language = session:getVariable("default_language") or 'en'; + local default_dialect = session:getVariable("default_dialect") or 'us'; + local default_voice = session:getVariable("default_voice") or 'callie'; - --connect to the database - require "resources.functions.database_handle"; - dbh = database_handle('system'); +--a moment to sleep + session:sleep(1000); - --request id is true - if (request_id == "true") then - --unset extension uuid - extension_uuid = nil; +--connect to the database + dbh = Database.new('system'); - --get the id - if (session:ready()) then - min_digits = 2; - max_digits = 20; - id = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_id:#", "", "\\d+"); - end +--request id is true + if (request_id == "true") then + --unset extension uuid + extension_uuid = nil; - --get the pin number - if (session:ready()) then - min_digits = 3; - max_digits = 20; - caller_pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+"); - end + --get the extension + if not session:ready() then return end + local min_digits = 2; + local max_digits = 20; + extension = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_id:#", "", "\\d+"); + if empty(extension) then return end - --check to see if the pin number is correct - if (session:ready()) then - sql = "SELECT * FROM v_voicemails "; - sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' "; - sql = sql .. "AND voicemail_id = '" .. id .."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[call_forward] "..sql .."\n"); - end - dbh:query(sql, function(row) - voicemail_password = row.voicemail_password; - --freeswitch.consoleLog("notice", "[call_forward] "..voicemail_password .."\n"); - end); - if (voicemail_password ~= caller_pin_number) then - --access denied - session:streamFile("phrase:voicemail_fail_auth:#"); - session:hangup("NORMAL_CLEARING"); - end - end + --get the pin number + if not session:ready() then return end + min_digits = 3; + max_digits = 20; + local caller_pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+"); + if empty(caller_pin_number) then return end + + --check to see if the pin number is correct + if not session:ready() then return end + local sql = "SELECT * FROM v_voicemails "; + sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' "; + sql = sql .. "AND voicemail_id = '" .. extension .."' "; + if (debug["sql"]) then + log.notice(sql); + end + local voicemail_password = dbh:first_value(sql) + if (voicemail_password ~= caller_pin_number) then + --access denied + session:streamFile("phrase:voicemail_fail_auth:#"); + return session:hangup("NORMAL_CLEARING"); + end + end + +--determine whether to update the dial string + if not session:ready() then return end + + local sql = "select * from v_extensions "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + if (extension_uuid ~= nil) then + sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; + else + sql = sql .. "and (extension = '"..extension.."' or number_alias = '"..extension.."') "; + end + if (debug["sql"]) then + log.notice(sql); + end + local row = dbh:first_row(sql) + if not row then return end + + extension_uuid = row.extension_uuid; + extension = row.extension; + local number_alias = row.number_alias or ''; + local accountcode = row.accountcode; + local forward_all_enabled = row.forward_all_enabled; + local forward_all_destination = row.forward_all_destination; + local follow_me_uuid = row.follow_me_uuid; + local toll_allow = row.toll_allow or ''; + local forward_caller_id_uuid = row.forward_caller_id_uuid; + +--toggle enabled + if enabled == "toggle" then + enabled = (forward_all_enabled == "true") and "false" or "true"; + end + + if not session:ready() then return end + +--get the forward destination + if enabled == "true" and empty(forward_all_destination) then + forward_all_destination = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+"); + if empty(forward_all_destination) then return end + end + +--set call forward + if enabled == "true" then + --set forward_all_enabled + forward_all_enabled = "true"; + channel_display(session:get_uuid(), "Activated") + --say the destination number + session:say(forward_all_destination, default_language, "number", "iterated"); + --notify the caller + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav"); + end + +--get the caller_id for outbound call + local forward_caller_id = "" + if enabled == "true" and not empty(forward_caller_id_uuid) then + local sql = "select destination_number, destination_description,".. + "destination_caller_id_number, destination_caller_id_name " .. + "from v_destinations where domain_uuid = '" .. domain_uuid .. "' and " .. + "destination_type = 'inbound' and destination_uuid = '" .. forward_caller_id_uuid .. "'"; + local row = dbh:first_row(sql) + if row then + local caller_id_number = row.destination_caller_id_number + if empty(caller_id_number) then + caller_id_number = row.destination_number end - --determine whether to update the dial string - if (session:ready()) then - sql = "select * from v_extensions "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - if (extension_uuid ~= nil) then - sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; - else - sql = sql .. "and (extension = '"..id.."' or number_alias = '"..id.."') "; - end - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[call_forward] "..sql.."\n"); - end - status = dbh:query(sql, function(row) - extension_uuid = row.extension_uuid; - extension = row.extension; - number_alias = row.number_alias or ''; - accountcode = row.accountcode; - forward_all_enabled = row.forward_all_enabled; - forward_all_destination = row.forward_all_destination; - follow_me_uuid = row.follow_me_uuid; - toll_allow = row.toll_allow or ''; - --freeswitch.consoleLog("NOTICE", "[call forward] extension "..row.extension.."\n"); - --freeswitch.consoleLog("NOTICE", "[call forward] accountcode "..row.accountcode.."\n"); - end); + local caller_id_name = row.destination_caller_id_name + if empty(caller_id_name) then + caller_id_name = row.destination_description end - --toggle enabled - if (session:ready() and enabled == "toggle") then - if (forward_all_enabled == "true") then - enabled = "false"; - else - enabled = "true"; - end + if not empty(caller_id_number) then + forward_caller_id = forward_caller_id .. + ",outbound_caller_id_number=" .. caller_id_number .. + ",origination_caller_id_number=" .. caller_id_number end - --get the forward destination - if (session:ready() and (enabled == "true" or enabled == "toggle") ) then - if (string.len(forward_all_destination) == 0) then - forward_all_destination = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+"); - end + if not empty(caller_id_name) then + forward_caller_id = forward_caller_id .. + ",outbound_caller_id_name=" .. caller_id_name .. + ",origination_caller_id_name=" .. caller_id_name end + end + end - --set the dial string - if (session:ready() and enabled == "true") then - --used for number_alias to get the correct user - sql = "select * from v_extensions "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and number_alias = '"..forward_all_destination.."' "; - status = dbh:query(sql, function(row) - destination_user = row.extension; - end); +--set the dial string + if enabled == "true" then + local destination_extension, destination_number_alias - --set the dial_string - dial_string = "{presence_id="..forward_all_destination.."@"..domain_name; - dial_string = dial_string .. ",instant_ringback=true"; - dial_string = dial_string .. ",domain_uuid="..domain_uuid; - dial_string = dial_string .. ",sip_invite_domain="..domain_name; - dial_string = dial_string .. ",domain_name="..domain_name; - dial_string = dial_string .. ",domain="..domain_name; - dial_string = dial_string .. ",toll_allow='"..toll_allow.."'"; - if (accountcode ~= nil) then - dial_string = dial_string .. ",accountcode="..accountcode; - end - dial_string = dial_string .. "}"; + --used for number_alias to get the correct user + local sql = "select extension, number_alias from v_extensions "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and number_alias = '"..forward_all_destination.."' "; + dbh:query(sql, function(row) + destination_user = row.extension; + destination_extension = row.extension; + destination_number_alias = row.number_alias or ''; + end); - if (destination_user ~= nil) then - cmd = "user_exists id ".. destination_user .." "..domain_name; - else - cmd = "user_exists id ".. forward_all_destination .." "..domain_name; - end - user_exists = trim(api:executeString(cmd)); - if (user_exists == "true") then - if (destination_user ~= nil) then - dial_string = dial_string .. "user/"..destination_user.."@"..domain_name; - else - dial_string = dial_string .. "user/"..forward_all_destination.."@"..domain_name; - end - else - dial_string = dial_string .. "loopback/"..forward_all_destination; - end - end - - --set call forward - if (session:ready() and enabled == "true") then - --set forward_all_enabled - forward_all_enabled = "true"; - --say the destination number - session:say(forward_all_destination, default_language, "number", "iterated"); - --notify the caller - session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav"); - end - - --unset call forward - if (session:ready() and enabled == "false") then - --set forward_all_enabled - forward_all_enabled = "false"; - --notify the caller - session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav"); - end - - --disable the follow me - if (session:ready() and enabled == "true" and follow_me_uuid ~= nil) then - if (string.len(follow_me_uuid) > 0) then - sql = "update v_follow_me set "; - sql = sql .. "follow_me_enabled = 'false' "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[call_forward] "..sql.."\n"); - end - dbh:query(sql); - end - end - - --check the destination - if (forward_all_destination == nil) then - enabled = false; - forward_all_enabled = "false"; + local presence_id + if destination_extension then + if (#destination_number_alias > 0) and (opt(settings(domain_uuid), 'provision', 'number_as_presence_id', 'boolean') == 'true') then + presence_id = destination_number_alias else - if (string.len(forward_all_destination) == 0) then - enabled = false; - forward_all_enabled = "false"; - end + presence_id = destination_extension end - - --update the extension - if (session:ready()) then - sql = "update v_extensions set "; - if (enabled == "true") then - sql = sql .. "forward_all_destination = '"..forward_all_destination.."', "; - sql = sql .. "dial_string = '"..dial_string:gsub("'", "''").."', "; - sql = sql .. "do_not_disturb = 'false', "; - else - sql = sql .. "forward_all_destination = null, "; - sql = sql .. "dial_string = null, "; - end - sql = sql .. "forward_all_enabled = '"..forward_all_enabled.."' "; - sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; - sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[call_forward] "..sql.."\n"); - end - dbh:query(sql); - - --clear the cache - if (extension ~= nil) then - api:execute("memcache", "delete directory:"..extension.."@"..domain_name); - if #number_alias > 0 then - api:execute("memcache", "delete directory:"..number_alias.."@"..domain_name); - end - end + elseif extension then + -- setting here presence_id equal extension not dialed number allows work BLF and intercept. + -- $presence_id = extension_presence_id($this->extension, $this->number_alias); + if (#number_alias > 0) and (opt(settings(domain_uuid), 'provision', 'number_as_presence_id', 'boolean') == 'true') then + presence_id = number_alias + else + presence_id = extension end + else + presence_id = forward_all_destination + end - -- hangup - if (session:ready()) then - --wait for the file to be written before proceeding - session:sleep(100); + --set the dial_string + dial_string = "{presence_id="..presence_id.."@"..domain_name; + dial_string = dial_string .. ",instant_ringback=true"; + dial_string = dial_string .. ",domain_uuid="..domain_uuid; + dial_string = dial_string .. ",sip_invite_domain="..domain_name; + dial_string = dial_string .. ",domain_name="..domain_name; + dial_string = dial_string .. ",domain="..domain_name; + dial_string = dial_string .. ",toll_allow='"..toll_allow.."'"; + if (accountcode ~= nil) then + dial_string = dial_string .. ",accountcode="..accountcode; + end + dial_string = dial_string .. forward_caller_id + dial_string = dial_string .. "}"; - --end the call - session:hangup(); + if (destination_user ~= nil) then + cmd = "user_exists id ".. destination_user .." "..domain_name; + else + cmd = "user_exists id ".. forward_all_destination .." "..domain_name; + end + user_exists = trim(api:executeString(cmd)); + if (user_exists == "true") then + if (destination_user ~= nil) then + dial_string = dial_string .. "user/"..destination_user.."@"..domain_name; + else + dial_string = dial_string .. "user/"..forward_all_destination.."@"..domain_name; end - end \ No newline at end of file + else + dial_string = dial_string .. "loopback/"..forward_all_destination; + end + end + +--unset call forward + if session:ready() and enabled == "false" then + --set forward_all_enabled + forward_all_enabled = "false"; + channel_display(session:get_uuid(), "Cancelled") + --notify the caller + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav"); + end + +--disable the follow me + if enabled == "true" and not empty(follow_me_uuid) then + local sql = "update v_follow_me set "; + sql = sql .. "follow_me_enabled = 'false' "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' "; + if (debug["sql"]) then + log.notice(sql); + end + dbh:query(sql); + end + +--check the destination + if empty(forward_all_destination) then + enabled = "false"; + forward_all_enabled = "false"; + end + +--update the extension + do + local sql = "update v_extensions set "; + if (enabled == "true") then + sql = sql .. "forward_all_destination = '"..forward_all_destination.."', "; + sql = sql .. "dial_string = '"..dial_string:gsub("'", "''").."', "; + sql = sql .. "do_not_disturb = 'false', "; + else + sql = sql .. "forward_all_destination = null, "; + sql = sql .. "dial_string = null, "; + end + sql = sql .. "forward_all_enabled = '"..forward_all_enabled.."' "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and extension_uuid = '"..extension_uuid.."' "; + if (debug["sql"]) then + log.notice(sql); + end + dbh:query(sql); + end + +--disconnect from database + dbh:release() + +--clear the cache + if extension and #extension > 0 and cache.support() then + cache.del("directory:"..extension.."@"..domain_name); + if #number_alias > 0 then + cache.del("directory:"..number_alias.."@"..domain_name); + end + end + +--hangup + if (session:ready()) then + --wait for the file to be written before proceeding + session:sleep(100); + --end the call + session:hangup(); + end