168 Commits
Author SHA1 Message Date
FusionPBX 8564133d7b Fix the domain when using Show ALL 2025-04-02 11:38:21 -06:00
FusionPBX 50e222b3e4 Add yealink_force_voice_ring_volume
Forced ringer volume: 0 - 15
2025-03-27 18:06:44 -06:00
frytimo fff4365b1c Fix call recordings maintenance path (#7335) 2025-03-25 14:56:20 -06:00
FusionPBX 9f7371659d Set enabled to true by default 2025-03-24 18:33:34 -06:00
FusionPBX 90bae99e3d Add div with class card 2025-03-24 18:32:32 -06:00
FusionPBX e0b8adf376 CDR http_enabled default to false
Using the file system by default instead of HTTP POST
2025-03-22 17:12:14 -06:00
FusionPBX 062c9ec8b8 Update xml_cdr.php 2025-03-22 17:02:05 -06:00
frytimo d546c30837 Use auth_id instead of user_id for pcode 36 (#7328) 2025-03-21 09:44:55 -06:00
frytimo d5c54fa4b0 Fix user id instead of auth id used in grandstream template (#7327) 2025-03-20 23:51:32 -06:00
fusionate 9cf8da5a4a Access Control - Edit: Escape submitted values in dig command. 2025-03-20 09:53:17 -06:00
FusionPBX bde4163c25 Add fax to the add fax_files table if the file exists 2025-03-19 13:27:29 -06:00
FusionPBX c75e573e84 Fix Call Detail Records with invalid xml 2025-03-13 10:13:54 -06:00
FusionPBX 3ddf6e4df5 Update login.htm 2025-03-07 12:35:27 -07:00
FusionPBX 3ffd58ce26 Fix server 2 server address and sip transport 2025-03-03 12:44:33 -07:00
FusionPBX 155875b6bf Minor version update 2025-03-01 21:00:19 -07:00
FusionPBX 0fd4f8ba00 Fix the status voicemail
Moved voicemail status after missed calls. This way, it will show the status of voicemail when it goes to voicemail.

There is still a field in the CDR for missed_call, and this will still be set to true for calls that go to voicemail.
2025-02-28 17:29:09 -07:00
FusionPBX 5fbc6dcc03 Add enable-rfc-5626 to the internal profile 2025-02-27 10:53:26 -07:00
FusionPBX db5dcf4a03 Fix a voicemail bug
Fix the voicemail link
Use only one keep local feature
Deprecate the voicemail_local_after_forward
2025-02-20 15:44:53 -07:00
FusionPBX e88c43c272 Add 922 as another emergency test number 2025-02-19 10:38:19 -07:00
FusionPBX cea56a7643 Allow the @ in caller_id_name 2025-02-17 11:57:05 -07:00
FusionPBX 5db8c82d11 Voicemail: Rename voicemail filesystem folder if Voicemail ID changes 2025-02-15 20:39:44 -07:00
FusionPBX 60d60a2b1d Fix invalid XML CDR 2025-02-15 19:07:35 -07:00
FusionPBX d490d6d5ab Send CDR with invalid xml to failed/invalid_xml 2025-02-15 18:24:46 -07:00
FusionPBX 6163d27962 Update app_config.php 2025-02-15 12:10:09 -07:00
FusionPBX 4604509bfd Do not save event_guard logs to transactions 2025-02-15 12:02:03 -07:00
FusionPBX a8f0c03746 Send the fax with primary and alternative routes 2025-02-14 15:52:03 -07:00
FusionPBX 181092d399 Add two fax variables 2025-02-14 13:39:13 -07:00
FusionPBX ff36efcb49 Add two fax variables 2025-02-14 13:10:19 -07:00
FusionPBX f1e981b824 Fix the fifo agent delete 2025-02-13 21:52:19 -07:00
FusionPBX a0c112bc7e Allow # and * in the sanitized caller ID 2025-02-11 13:29:26 -07:00
FusionPBX 9da6a9b19c Fix password when the permission is not assigned 2025-02-07 17:34:01 -07:00
FusionPBX 8ab4b2b6c2 Change value of yealink_voice_vad to 0
A value of 0 disables voice activity detection. VAD when enabled on a Yealink T54W made the audio at the beginning of the call start at the beginning of the call and sometimes took 1 to 30 seconds to start.

Recommend changing this value on all systems using Yealink to use 0 to disable voice activity detection. Currently yealink_voice_vad is used in t46s, t41s, and t54w
2025-02-06 12:14:04 -07:00
FusionPBX 76de2bee83 Fix the login destination alternate path 2025-02-05 18:10:15 -07:00
FusionPBX 7f2f0df9b8 Fax queue setting prefer_local default false
This allows control over whether to prefer sending to the voip provider or attempt local fax call.
2025-02-04 18:40:46 -07:00
FusionPBX 73c37b6562 Fix the call recording length 2025-02-02 18:27:28 -07:00
FusionPBX 97580a057a Fix the devices domain names column 2025-02-02 18:02:31 -07:00
FusionPBX b857f092fa Add uuid to the custom recording name 2025-02-01 00:24:18 -07:00
FusionPBX 1f456c5077 Use the settings class use database::new() 2025-01-31 21:41:05 -07:00
FusionPBX 62b9f692df Add setting call_recordings record_extension default value mp3
Call recording file format options: wav, mp3
2025-01-31 17:14:43 -07:00
FusionPBX ce114a4bb2 Update destination_edit.php
- Use one database connection
- Use the settings class
- Use setting call_recordings record_extension this fixes a problem where the recording extension may not be set.
2025-01-31 17:12:33 -07:00
FusionPBX 31ec917c64 Add record_stereo and record_stereo_swap 2025-01-31 16:46:49 -07:00
FusionPBX 0ac25b2769 Minor version update 2025-01-29 22:27:18 -07:00
FusionPBX 88197dd51b logged in direct to the dashboard 2025-01-27 13:58:39 -07:00
FusionPBX e0ebdaf2b6 Add forgot password translations 2025-01-27 12:51:04 -07:00
FusionPBX 07639f4cf2 Fix the forget password feature 2025-01-27 11:55:39 -07:00
FusionPBX 2f99b86917 Fix provision edit to use text type instead of numeric #7229 2025-01-24 16:11:14 -07:00
frytimo 4b75567ad8 use lowercase matching domain name (#7230)
When the domain name has upper and lower case letters. The domain UUID results in not found in app/provision
2025-01-24 15:57:15 -07:00
frytimo ba1dc820eb suppress access on null php notice in new is_connected method (#7228) 2025-01-23 13:44:36 -07:00
frytimo 5ef71889fe add is_connected method to database (#7226) 2025-01-23 11:52:44 -07:00
FusionPBX 5815699489 Add more debug details and return false 2025-01-22 20:36:29 -07:00
FusionPBX 5d4d7a0fd6 Enhance message array debug details 2025-01-22 20:08:59 -07:00
FusionPBX 9dbc493844 Replace exit; with return false; 2025-01-22 19:27:58 -07:00
fusionate 64476fa512 Voicemails - List: Restore search functionality. 2025-01-16 11:20:51 -07:00
FusionPBX e6c89018a1 Fix issue with sending local faxes
When sip_to_user or sip_req_user are used then we need to add these variables so that it can find the correct inbound route.
2025-01-15 19:47:43 -07:00
FusionPBX b869123e1c Fix server_address_primary
This was showing as a select box instead of input-type text .
2025-01-13 12:59:57 -07:00
FusionPBX df745a2838 Removed domain_enabled to fix a bug for those using BDR
An issue occurs if the domain_enabled data type is text rather than boolean. The upgrade schema data types will correct the data type except when using BDR. The alter table for changing data types doesn't work because of BDR.
2025-01-13 11:12:13 -07:00
FusionPBX ca28a06cea Remove the pdo.php include
The pdo.php file was replaced by the database class
2025-01-08 12:19:18 -07:00
FusionPBX 28040957bd Add the settings_array to the class constructor
- More efficient to pass in the database object
- Added an option to pass in the domain_name
2025-01-07 22:21:59 -07:00
FusionPBX 9ed10a4dec Add multi-cast settings to all yealinks 2025-01-07 19:47:58 -07:00
FusionPBX e1729aad3a Fix the device line default values and use the settings class 2025-01-07 19:47:57 -07:00
FusionPBX 2593b6bd6f Use the domain_name as the context 2025-01-07 19:47:48 -07:00
FusionPBX edac98d8c2 Update the context for the operator
Use the domain_name as the context.
2025-01-07 19:47:47 -07:00
FusionPBX d9cd2d84e7 Change the agent.contact size from 255 to 1024 2025-01-07 19:47:47 -07:00
FusionPBX 933d06d96d Show newest emails first 2025-01-07 19:47:39 -07:00
frytimo 44983289fa xml_cdr catch edge case of failed import when no start stamp is present (#7207)
* xml_cdr catch edge case of failed import when no start stamp is present

* xml_cdr catch edge case of failed import when no start stamp is present
2025-01-07 19:47:38 -07:00
chansizzle 8f24b921a9 update cpm_ans to be cpm_answered (#7204)
The sql aliases the calculation as cpm_answered. Without this change the CDR Statistics Call Per Minute will always be zero.
2025-01-07 19:47:38 -07:00
FusionPBX 3940fb8219 Fix the duration using the created_epoch 2024-12-26 10:58:59 -07:00
FusionPBX 303935b9d2 Fix greeting when using phrases
After saving a phrase for the greeting it would save but it wouldn't show the correct label. It would continue to play the phrase but show the UUID.
2024-12-23 12:25:22 -07:00
FusionPBX f0d2a80ab7 Fix greeting when using phrases
After saving a phrase for the greeting it would save but it wouldn't show the correct label. It would continue to play the phrase but show the UUID.
2024-12-23 12:19:23 -07:00
FusionPBX 0af94ee1e3 Sanitize the caller ID name and number 2024-12-20 11:08:47 -07:00
FusionPBX d463a7c5b3 Update app_languages.php 2024-12-17 12:50:13 -07:00
FusionPBX 9815d319e6 Fix the device ADD button.
Also, permission_exists function uses the permission::new() method and this made it efficient enough to continue to use the permission_exists function.
2024-12-13 10:40:03 -07:00
FusionPBX 312c8659af Fix a bug where transfer is part of recording name 2024-12-10 13:45:26 -07:00
FusionPBX c36455e28f Call Center responsive design update
Fix the display running out of the content area for different screen sizes.
2024-12-07 13:34:22 -07:00
FusionPBX 492b188d0d Use the PHP_BINARY constant 2024-12-02 18:00:54 -07:00
FusionPBX e6a1093a38 Use the PHP_BINARY constant 2024-12-02 17:59:29 -07:00
FusionPBX c3fd2bae2e Set the Yealink default to 4 PAI-RPID-FROM
Change to a better default value.
2024-12-02 11:57:55 -07:00
frytimo 31c8f87c80 fix voicemail message length and size display (#7188) 2024-11-30 12:10:40 -07:00
frytimo 152881e34c fix voicemail message count when viewing all domains (#7187) 2024-11-30 12:10:23 -07:00
FusionPBX 8b7bd29456 Fix temporary permissions 2024-11-29 14:06:08 -07:00
FusionPBX 1b675c1b56 Method new allow null
Needed to support temporary permissions
2024-11-29 14:03:49 -07:00
frytimo c836a3b226 parse windows 1256 encoding type in email to fax (#7183) 2024-11-27 14:21:57 -07:00
FusionPBX 80c2b9bab2 Fix permission handling
- Required when not using a $_SESSION
- Singleton permssion method named new
2024-11-27 13:33:00 -07:00
FusionPBX 2a9a1229dd Fix CSS missing characters
Disable the ob_gzhandler
2024-11-27 09:33:59 -07:00
FusionPBX bbc7dea2f1 Return an empty array if there are no groups 2024-11-20 13:53:51 -07:00
FusionPBX 28f94e1268 Fix ring group missed call to show in CDR 2024-11-19 13:45:39 -07:00
FusionPBX 3ef0f1d593 Fix the sql query 2024-11-15 14:33:17 -07:00
FusionPBX fbafcc438c Create three_way.lua 2024-11-15 14:16:45 -07:00
fusionate cc3637e248 Fax Server - Sent List: Fix Destination value. 2024-11-14 19:04:55 -07:00
FusionPBX ffd1bbd4fc Fixed Call Flow Summary for outbound calls 2024-11-14 17:14:33 -07:00
fusionate 6d37675273 Fax Server - Fax to Email: Remove unnecessary $included variable. 2024-11-14 13:50:17 -07:00
fusionate 8ca1b0d27b Fax Server - Fax to Email: Fix population of cover page labels. 2024-11-14 13:49:06 -07:00
FusionPBX 25c8b93423 Fix the voicemail transcribe title 2024-11-13 17:47:49 -07:00
FusionPBX c273c8021f IVR Menu direct_dial_digits_max set default to 8 2024-11-12 15:40:28 -07:00
FusionPBX 0aaa4829e7 Use include internal on answered, missed and voicemail
This hides local calls which could also be calls to feature codes. Only add these feature code calls to the count if directed to show internal calls.
2024-11-08 21:34:07 -07:00
FusionPBX 50d81556f5 Fix the destination summary when server using UTC
Set the PHP time zone to fix the destination summary report. Without the time zone set it would use the server operating system time zone.  If the time zone is set to UTC when it rolled over to a new date ahead of the local time zone it would make the report show 0 results.
2024-11-08 17:44:58 -07:00
FusionPBX 8dcebaabc9 Fix the extension summary and call flow summary
Set the time zone in PHP so that it is correct inside the class method for the extension summary and the call flow summary
2024-11-08 17:30:10 -07:00
FusionPBX ec208915f2 Yealink boolean and numeric use text
The provisioning template delivers the value as a string
2024-11-04 10:21:17 -07:00
FusionPBX 96d91dde9c Use the yealink_trust_certificate directly
Value should be 0 or 1
2024-11-04 10:10:07 -07:00
FusionPBX 5464b4451f Add missing $ 2024-11-04 08:19:15 -07:00
FusionPBX 9006dc408f Update http_auth to use boolean 2024-11-01 14:18:44 -06:00
FusionPBX 6bc2fccbb0 Fix for the device template
If the device vendor matches then use the alternate device template
2024-11-01 12:35:06 -06:00
FusionPBX b49ebeeaa9 Fix lua streamfile 2024-10-31 19:34:06 -06:00
FusionPBX 2c862bd97e Fix a typo on the database object name 2024-10-30 16:50:41 -06:00
FusionPBX bbf53595a7 Update extension_edit.php 2024-10-30 14:12:07 -06:00
FusionPBX 58b8ded449 Minor version update 5.3.4 2024-10-29 15:20:21 -06:00
FusionPBX 5d8980742b Fix page load time for call_recordings
The page load time was slow when there were no call recordings for the domain.

Remove domain_uuid is null as this isn't needed for call recordings.
2024-10-28 11:01:24 -06:00
FusionPBX 7f8ed9037b Remove the session when the password is changed 2024-10-27 18:05:06 -06:00
FusionPBX dcde377064 Replace the empty function with isset
Don't use empty when value can be 0
2024-10-27 11:09:06 -06:00
FusionPBX 1ef51535fb Fix the use of the settings object 2024-10-25 12:47:56 -06:00
frytimo 8f575fe555 Use boolean in conditional statement (#7171) 2024-10-24 14:56:38 -06:00
FusionPBX d68ffb65c7 Provision settings adjust types
If the type is boolean with a value of 0 or 1, use type text; if it is numeric, use type text.

The template default setting uses a string for the template values, and a boolean type is used with conditions.
2024-10-23 15:12:09 -06:00
frytimo 955439dea3 Use boolean in the if statement (#7169) 2024-10-23 14:04:06 -06:00
frytimo ae2679e97c update template to match new boolean in settings (#7168)
* update template to match new boolean in settings

* Update email.php
2024-10-23 12:14:54 -06:00
FusionPBX e54d10a4e9 provision enabled default to boolean 2024-10-23 12:12:13 -06:00
FusionPBX 273531302e Update provision enabled use boolean 2024-10-23 12:11:12 -06:00
FusionPBX 9a5271fa92 Update boolean provision.php 2024-10-23 12:09:47 -06:00
FusionPBX 6f4b522e9e Update boolean provision 2024-10-23 12:08:40 -06:00
FusionPBX 648385a85c Update boolean devices.php 2024-10-23 12:04:23 -06:00
frytimo 33a6a4cd01 update template to match new boolean in settings (#7167) 2024-10-23 12:01:13 -06:00
FusionPBX d91c7b4fe9 Update boolean settings
Settings of type boolean need to be set as boolean.
2024-10-23 12:00:01 -06:00
FusionPBX e83510c426 Fix the condition for smtp_from 2024-10-23 11:34:53 -06:00
FusionPBX d4b677ce6b Fix the databases.php file 2024-10-22 09:48:18 -06:00
FusionPBX 8d2aefa41e Fix local fax calls
Use loopback for sending local calls to other domains.
2024-10-21 16:53:10 -06:00
FusionPBX 55ba425b57 Fix a provisioning bug 2024-10-21 15:27:28 -06:00
FusionPBX 7308ae1a52 Update hangup_rx.lua 2024-10-17 13:11:27 -06:00
FusionPBX 2f16d2bc05 Add contact string to hover 2024-10-17 12:00:20 -06:00
FusionPBX 000a32ad01 Prevent a nil error 2024-10-17 02:33:29 -06:00
FusionPBX b9dd9af354 Update hangup_rx.lua
Prevent error if the value of x is nil.
2024-10-17 02:30:02 -06:00
FusionPBX 0a08b522f6 Fix play recording in CDR 2024-10-16 16:18:59 -06:00
FusionPBX 40fe1e8a43 fix waveform image background (#7160) 2024-10-16 15:52:51 -06:00
FusionPBX d4cc8600e6 Update app_defaults.php 2024-10-16 11:53:57 -06:00
FusionPBX 16515b1a81 Update fax sending order 2024-10-15 12:22:48 -06:00
FusionPBX e6772deec3 Update the condition for boolean 2024-10-10 17:24:17 -06:00
FusionPBX d4ca64c2d1 User logs fix failed 2024-10-10 16:28:59 -06:00
FusionPBX 8fe2199e82 Before using is_numeric cast the value to int
Without this cc_queue_joined_epoch, cc_queue_answered_epoch, and other values were seen as a string
2024-10-07 14:29:43 -06:00
FusionPBX e112cc0a63 Fix call center agent save 2024-10-07 13:07:39 -06:00
FusionPBX b490ce7cc0 Update authentication.php 2024-10-06 10:33:27 -06:00
FusionPBX 381fd03bd3 Fix the FIFO lag time
This is also known as the wrap-up time after the call ends with the agent.
2024-10-04 01:39:46 -06:00
FusionPBX 8ae86bca9f Re-use the database connection 2024-10-03 23:42:34 -06:00
FusionPBX 9cc6d45772 Fax - Sent: Add time sent to cover sheet. 2024-10-02 17:59:06 -06:00
FusionPBX aa4a4bf763 Fix valet_park use sip_refer_to
The referred-by domain can't be used as some phones use the domain of the tenant and some of their IP address. For this reason, replaced with sip_refer_to.
2024-10-02 13:39:10 -06:00
FusionPBX b1c24b3843 Removed for better backwards PHP compatibility 2024-10-02 11:37:10 -06:00
FusionPBX 33035d7af2 Fix valet park when call is sent to a different domain
When crossing domains we need to use park with the correct domain. This change uses the referred by to get the proper domain name.
2024-10-01 16:43:17 -06:00
FusionPBX 1b02aa0e05 Add permission call_recording_transcribe 2024-09-30 17:47:39 -06:00
FusionPBX 391f4c6322 Fix call screen to end recording with dtmf and silence 2024-09-30 10:05:49 -06:00
FusionPBX a9c37688f1 Fix provision auto_insert_enabled 2024-09-28 11:06:42 -06:00
Alex 24640276ea Add content card to voicemail greetings (#7143)
* Add content card to voicemail greetings

* Update voicemail_greeting_edit.php
2024-09-26 15:57:22 -06:00
FusionPBX 1393a29607 Allow right click open in new window 2024-09-26 09:47:54 -06:00
FusionPBX 3b61bb645a Add the domain_name variable
Without the domain_name variable in some cases the confirm option doesn't work.
2024-09-26 08:45:53 -06:00
FusionPBX d77e862ac1 More efficient use of the database object 2024-09-23 19:34:49 -06:00
FusionPBX 85d7c8e60c Fix voicemail greeting for base64
- Use the settings class
- Re-use the database object
- Update the indentation
2024-09-23 18:18:40 -06:00
FusionPBX 4b7e90c3ff Restore previous caller ID behavior
If the caller ID was updated then update the caller ID
2024-09-23 13:01:47 -06:00
FusionPBX 72470b5863 Fix permission_exists fax_file_edit 2024-09-21 21:13:40 -06:00
FusionPBX 52a320ec54 Fixed the registration count
- Fixed on the dashboard for those with superadmin group
- Fixed the count in the SIP status page
2024-09-21 12:39:10 -06:00
FusionPBX 91b845dc71 Default value for create recording should always be false 2024-09-20 23:10:00 -06:00
FusionPBX c2107802d8 Add ignore early media for external calls 2024-09-20 16:19:26 -06:00
FusionPBX 7ed752ef7a Get the domain_name with a different variable
Get the domain_name with a different variable if the domain_name is not set
2024-09-20 16:17:05 -06:00
FusionPBX 02ce497e5c Use ring group destination confirm true when call screen is enabled 2024-09-20 13:16:06 -06:00
markjcrane fbe358816f Remove the CSS card overflow it cut off the date-time picker 2024-09-20 10:57:56 -06:00
markjcrane 00c0fbe06d Remove carriage return per line and leave only line feeds 2024-09-19 17:24:16 -06:00
markjcrane 26530d6fe0 Fix end of file line only use one line feed at the end of the file 2024-09-19 16:44:08 -06:00
FusionPBX c766b5c634 Align SEARCH and other buttons to the right 2024-09-18 18:46:55 -06:00
FusionPBX 5b66aa1aa7 Show only default extension type
Hide virtual extensions
2024-09-18 11:53:42 -06:00
FusionPBX fca042e996 Update the border radius 2024-09-18 11:38:37 -06:00
FusionPBX 937b470630 FIFO Queues added to destination select list
- This was missed in the destination select list and  should be there by default.
- Also add a new permission fifo_destinations
2024-09-17 22:53:17 -06:00
FusionPBX 4490631485 Fix voicemail base64 greeting 2024-09-17 17:47:22 -06:00
FusionPBX bfa0046dd4 Add ring group call screen translations 2024-09-16 23:57:29 -06:00
403 changed files with 11740 additions and 9318 deletions
+1 -1
View File
@@ -202,7 +202,7 @@
//attempt digs
if (!empty($digs) && is_array($digs)) {
foreach ($digs as $dig) {
$response = shell_exec("dig +noall +answer ".$dig['value']." | awk '{ print $5 }'");
$response = shell_exec("dig +noall +answer ".escapeshellarg($dig['value'])." | awk '{ print $5 }'");
if (!empty($response)) {
$lines = explode("\n", $response);
foreach ($lines as $l => $line) {
+2 -2
View File
@@ -74,7 +74,7 @@
$array['access_controls'][0]['access_control_name'] = $access_control_name;
$array['access_controls'][0]['access_control_default'] = $access_control_default;
$p = new permissions;
$p = permissions::new();
$p->add('access_control_add', 'temp');
$database->app_name = 'access_controls';
@@ -106,7 +106,7 @@
$array['access_control_nodes'][0]['node_cidr'] = $node_cidr;
$array['access_control_nodes'][0]['node_description'] = $node_description;
$p = new permissions;
$p = permissions::new();
$p->add('access_control_node_add', 'temp');
$database->app_name = 'access_controls';
@@ -69,7 +69,7 @@ if (!class_exists('access_controls')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('access_control_node_delete', 'temp');
//execute delete
@@ -236,7 +236,7 @@ if (!class_exists('access_controls')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('access_control_node_add', 'temp');
//save the array
+2 -2
View File
@@ -65,7 +65,7 @@
//update the status
if (permission_exists("user_setting_edit")) {
//add the user_edit permission
$p = new permissions;
$p = permissions::new();
$p->add("user_edit", "temp");
//update the database user_status
@@ -153,7 +153,7 @@
}
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
//execute update
+1 -1
View File
@@ -166,7 +166,7 @@
$array['dialplans'][$index]['dialplan_enabled'] = 'true';
}
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
$database->save($array);
@@ -435,7 +435,7 @@ if (!class_exists('call_block')) {
unset($rows, $parameters);
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//save the array
+1 -1
View File
@@ -216,7 +216,7 @@
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_center";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "record_name";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "\${sip_from_user}-\${sip_to_user}-\${strftime(%Y)}\${strftime(%b)}\${strftime(%d)}.\${record_ext}";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "\${sip_from_user}-\${sip_to_user}-\${strftime(%Y)}\${strftime(%b)}\${strftime(%d)}-\${uuid}.\${record_ext}";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Custom name for call recording. Options: \${record_ext}, \${sip_from_user}, \${sip_to_user}, \${caller_id_number}, \${uuid}";
$y++;
+2 -2
View File
@@ -58,7 +58,7 @@ if ($domains_processed == 1) {
}
if (!empty($array)) {
$p = new permissions;
$p = permissions::new();
$p->add('call_center_tier_edit', 'temp');
$database->app_name = 'call_centers';
@@ -168,7 +168,7 @@ if ($domains_processed == 1) {
//save the array to the database
if (!empty($array)) {
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
+14 -91
View File
@@ -42,36 +42,14 @@
$language = new text;
$text = $language->get();
//connect to the database
$database = new database;
//set the defaults
$agent_id = '';
$agent_name = '';
$agent_password = '';
//check for duplicates
if (!empty($_GET["check"]) && $_GET["check"] == 'duplicate') {
//agent id
if (!empty($_GET["agent_id"])) {
$sql = "select agent_name ";
$sql .= "from v_call_center_agents ";
$sql .= "where agent_id = :agent_id ";
$sql .= "and domain_uuid = :domain_uuid ";
if (!empty($_GET["agent_uuid"]) && is_uuid($_GET["agent_uuid"])) {
$sql .= " and call_center_agent_uuid <> :call_center_agent_uuid ";
$parameters['call_center_agent_uuid'] = $_GET["agent_uuid"];
}
$parameters['agent_id'] = $_GET["agent_id"];
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row) && !empty($row['agent_name'])) {
echo $text['message-duplicate_agent_id'].(if_group("superadmin") ? ": ".$row["agent_name"] : null);
}
unset($sql, $parameters);
}
exit;
}
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
@@ -81,6 +59,14 @@
$action = "add";
}
//get the users array
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get http post variables and set them to php variables
if (!empty($_POST)) {
$call_center_agent_uuid = $_POST["call_center_agent_uuid"] ?? null;
@@ -151,15 +137,6 @@
$call_center_agent_uuid = uuid();
}
//get the users array
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//change the contact string to loopback - Not recommended added for backwards comptability causes multiple problems
if ($_SESSION['call_center']['agent_contact_method']['text'] == 'loopback') {
$agent_contact = str_replace("user/", "loopback/", $agent_contact);
@@ -193,11 +170,9 @@
}
//save to the data
$database = new database;
$database->app_name = 'call_center';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
//$message = $database->message;
//syncrhonize configuration
save_call_center_xml();
@@ -295,7 +270,6 @@
$sql .= "and call_center_agent_uuid = :call_center_agent_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['call_center_agent_uuid'] = $call_center_agent_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$call_center_agent_uuid = $row["call_center_agent_uuid"];
@@ -338,47 +312,12 @@
if ($action == "update") {
$document['title'] = $text['title-call_center_agent_edit'];
}
//include the header
require_once "resources/header.php";
//get the list of users for this domain
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and user_enabled = 'true' ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//javascript to check for duplicates
?>
<script language="javascript">
function check_duplicates() {
//check agent id
var agent_id = document.getElementById('agent_id').value;
$("#duplicate_agent_id_response").load("call_center_agent_edit.php?check=duplicate&agent_id="+agent_id+"&agent_uuid=<?php echo escape($call_center_agent_uuid ?? ''); ?>", function() {
var duplicate_agent_id = false;
if ($("#duplicate_agent_id_response").html() != '') {
$('#agent_id').addClass('formfld_highlight_bad');
display_message($("#duplicate_agent_id_response").html(), 'negative'<?php if (if_group("superadmin")) { echo ', 3000'; } ?>);
duplicate_agent_id = true;
}
else {
$("#duplicate_agent_id_response").html('');
$('#agent_id').removeClass('formfld_highlight_bad');
duplicate_agent_id = false;
}
if (duplicate_agent_id == false) {
document.getElementById('frm').submit();
}
});
}
</script>
<?php
//show the content
echo "<form method='post' name='frm' id='frm' onsubmit='check_duplicates(); return false;'>\n";
echo "<form method='post' name='frm' id='frm' onsubmit=''>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
@@ -404,21 +343,6 @@
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='agent_name' maxlength='255' value=\"".escape($agent_name)."\" />\n";
/*
echo "<select id=\"agent_name\" name=\"agent_name\" class='formfld'>\n";
echo "<option value=\"\"></option>\n";
if (is_array($users)) {
foreach($users as $field) {
if ($field[username] == $agent_name) {
echo "<option value='".escape($field[username])."' selected='selected'>".escape($field[username])."</option>\n";
}
else {
echo "<option value='".escape($field[username])."'>".escape($field[username])."</option>\n";
}
}
}
echo "</select>";
*/
echo "<br />\n";
echo $text['description-agent_name']."\n";
echo "</td>\n";
@@ -467,7 +391,6 @@
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='agent_id' id='agent_id' maxlength='255' min='1' step='1' value='".escape($agent_id)."'>\n";
echo " <div style='display: none;' id='duplicate_agent_id_response'></div>\n";
echo "<br />\n";
echo $text['description-agent_id']."\n";
echo "</td>\n";
@@ -172,7 +172,7 @@
$array['users'][0]['user_status'] = $row['agent_status'];
$array['users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$p = new permissions;
$p = permissions::new();
$p->add('user_edit', 'temp');
$database = new database;
+41 -47
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
Portions created by the Initial Developer are Copyright (C) 2008-2025
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -42,6 +42,10 @@
$language = new text;
$text = $language->get();
//initialize database and settings
$database = database::new();
$settings = new settings(['database' => $database, $_SESSION['domain_uuid'] ?? '', $_SESSION['user_uuid'] ?? '']);
//set the defaults
$queue_name = '';
$queue_extension = '';
@@ -61,24 +65,24 @@
$action = "add";
}
//get the domain_uuid
//get the domain details
$domain_uuid = $_SESSION['domain_uuid'];
$domain_name = $_SESSION['domain_name'];
//initialize the destinations object
//initialize the destination object
$destination = new destinations;
//get total call center queues count from the database, check limit, if defined
if ($action == 'add') {
if (!empty($_SESSION['limit']['call_center_queues']['numeric'])) {
if (!empty($settings->get('limit','call_center_queues', ''))) {
$sql = "select count(*) from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$total_call_center_queues = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
if ($total_call_center_queues >= $_SESSION['limit']['call_center_queues']['numeric']) {
message::add($text['message-maximum_queues'].' '.$_SESSION['limit']['call_center_queues']['numeric'], 'negative');
if ($total_call_center_queues >= $settings->get('limit','call_center_queues', 0)) {
message::add($text['message-maximum_queues'].' '.$settings->get('limit','call_center_queues', ''), 'negative');
header('Location: call_center_queues.php');
return;
}
@@ -124,7 +128,7 @@
$queue_context = $_POST["queue_context"];
}
else if ($action == 'add') {
$queue_context = $_SESSION['domain_name'];
$queue_context = $domain_name;
}
//remove invalid characters
@@ -149,7 +153,6 @@
$sql .= "and t.call_center_queue_uuid = q.call_center_queue_uuid; ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['call_center_tier_uuid'] = $call_center_tier_uuid;
$database = new database;
$tiers = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
@@ -168,7 +171,7 @@
if ($esl->is_connected()) {
//callcenter_config tier del [queue_name] [agent_name]
if (is_numeric($queue_extension) && is_uuid($call_center_agent_uuid)) {
$cmd = "callcenter_config tier del ".$queue_extension."@".$_SESSION['domain_name']." ".$call_center_agent_uuid;
$cmd = "callcenter_config tier del ".$queue_extension."@".$domain_name." ".$call_center_agent_uuid;
$response = event_socket::api($cmd);
}
}
@@ -178,10 +181,9 @@
$array['call_center_tiers'][0]['call_center_tier_uuid'] = $call_center_tier_uuid;
$array['call_center_tiers'][0]['domain_uuid'] = $domain_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('call_center_tier_delete', 'temp');
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->delete($array);
@@ -205,7 +207,6 @@
$sql = "select * from v_call_center_queues ";
$sql .= "where call_center_queue_uuid = :call_center_queue_uuid ";
$parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
//if (!permission_exists('call_center_queue_domain')) {
@@ -298,8 +299,8 @@
//add the recording path if needed
if (!empty($queue_greeting)) {
if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$queue_greeting)) {
$queue_greeting_path = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$queue_greeting;
if (file_exists($settings->get('switch','recordings', '').'/'.$domain_name.'/'.$queue_greeting)) {
$queue_greeting_path = $settings->get('switch','recordings', '').'/'.$domain_name.'/'.$queue_greeting;
}
else {
$queue_greeting_path = trim($queue_greeting);
@@ -371,8 +372,8 @@
//add definable export variables can be set in default settings
$export_variables = 'call_center_queue_uuid,sip_h_Alert-Info';
if (!empty($_SESSION['call_center']['export_vars'])) {
foreach ($_SESSION['call_center']['export_vars'] as $export_variable) {
if (!empty($settings->get('call_center','export_vars', []))) {
foreach ($settings->get('call_center','export_vars', []) as $export_variable) {
$export_variables .= ','.$export_variable;
}
}
@@ -413,7 +414,7 @@
if (!empty($queue_cc_exit_keys)) {
$dialplan_xml .= " <action application=\"set\" data=\"cc_exit_keys=".xml::sanitize($queue_cc_exit_keys)."\"/>\n";
}
$dialplan_xml .= " <action application=\"callcenter\" data=\"".xml::sanitize($queue_extension)."@".$_SESSION["domain_name"]."\"/>\n";
$dialplan_xml .= " <action application=\"callcenter\" data=\"".xml::sanitize($queue_extension)."@".$domain_name."\"/>\n";
if ($destination->valid($queue_timeout_app.':'.$queue_timeout_data)) {
$dialplan_xml .= " <action application=\"".xml::sanitize($queue_timeout_app)."\" data=\"".xml::sanitize($queue_timeout_data)."\"/>\n";
}
@@ -434,12 +435,11 @@
$array['dialplans'][0]["app_uuid"] = "95788e50-9500-079e-2807-fd530b0ea370";
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
//save to the data
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
@@ -457,7 +457,7 @@
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]);
$cache->delete("dialplan:".$domain_name);
//clear the destinations session array
if (isset($_SESSION['destinations']['array'])) {
@@ -496,19 +496,19 @@
*/
//add the agent
if (is_numeric($queue_extension) && is_uuid($call_center_agent_uuid) && is_numeric($tier_level) && is_numeric($tier_position)) {
$cmd = "callcenter_config tier add ".$queue_extension."@".$_SESSION["domain_name"]." ".$call_center_agent_uuid." ".$tier_level." ".$tier_position;
$cmd = "callcenter_config tier add ".$queue_extension."@".$domain_name." ".$call_center_agent_uuid." ".$tier_level." ".$tier_position;
$response = event_socket::api($cmd);
}
usleep(200);
//agent set level
if (is_numeric($queue_extension) && is_numeric($tier_level)) {
$cmd = "callcenter_config tier set level ".$queue_extension."@".$_SESSION["domain_name"]." ".$call_center_agent_uuid." ".$tier_level;
$cmd = "callcenter_config tier set level ".$queue_extension."@".$domain_name." ".$call_center_agent_uuid." ".$tier_level;
$response = event_socket::api($cmd);
}
usleep(200);
//agent set position
if (is_numeric($queue_extension) && is_numeric($tier_position)) {
$cmd = "callcenter_config tier set position ".$queue_extension."@".$_SESSION["domain_name"]." ".$tier_position;
$cmd = "callcenter_config tier set position ".$queue_extension."@".$domain_name." ".$tier_position;
$response = event_socket::api($cmd);
}
usleep(200);
@@ -538,7 +538,6 @@
$sql .= "and call_center_queue_uuid = :call_center_queue_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
$database = new database;
$call_center_queues = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
@@ -587,17 +586,16 @@
$sql .= "order by tier_level asc, tier_position asc, a.agent_name asc";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['call_center_queue_uuid'] = $call_center_queue_uuid ?? null;
$database = new database;
$tiers = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//add an empty row to the tiers array
if (count($tiers) == 0) {
$rows = $_SESSION['call_center']['agent_add_rows']['numeric'] ?? null;
$rows = $settings->get('call_center','agent_add_rows', null);
$id = 0;
}
if (count($tiers) > 0) {
$rows = $_SESSION['call_center']['agent_edit_rows']['numeric'];
$rows = $settings->get('call_center','agent_edit_rows', null);
$id = count($tiers)+1;
}
for ($x = 0; $x < $rows; $x++) {
@@ -615,7 +613,6 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by agent_name asc";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$agents = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
@@ -624,6 +621,7 @@
$audio_files[0] = $sounds->get();
unset($sounds);
//get the list of sounds
if (permission_exists('call_center_announce_sound')) {
$sounds = new sounds;
$sounds->sound_types = ['recordings'];
@@ -646,7 +644,7 @@
if (empty($queue_tier_rule_no_agent_no_wait)) { $queue_tier_rule_no_agent_no_wait = "true"; }
if (empty($queue_discard_abandoned_after)) { $queue_discard_abandoned_after = "900"; }
if (empty($queue_abandoned_resume_allowed)) { $queue_abandoned_resume_allowed = "false"; }
if (empty($queue_context)) { $queue_context = $_SESSION['domain_name']; }
if (empty($queue_context)) { $queue_context = $domain_name; }
//create token
$object = new token;
@@ -667,12 +665,8 @@
}
//set the record_template
if (empty($_SESSION['call_center']['record_name']['text'])) {
$record_template = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}/\${uuid}.\${record_ext}";
}
else {
$record_template = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".$_SESSION['call_center']['record_name']['text'];
}
$record_template = $settings->get('switch','recordings', '')."/".$domain_name."/archive/";
$record_template .= $settings->get('call_center','record_name', "\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}/\${uuid}.\${record_ext}");
//show the content
if (permission_exists('recording_play') || permission_exists('recording_download')) {
@@ -757,7 +751,7 @@
}
echo "</div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'call_center_queues.php']);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme','button_icon_back', ''),'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'call_center_queues.php']);
if ($action == "update") {
if (permission_exists('call_center_wallboard')) {
@@ -765,10 +759,10 @@
}
//echo button::create(['type'=>'button','label'=>$text['button-stop'],'icon'=>$_SESSION['theme']['button_icon_stop'],'link'=>'cmd.php?cmd=unload&id='.urlencode($call_center_queue_uuid)]);
//echo button::create(['type'=>'button','label'=>$text['button-start'],'icon'=>$_SESSION['theme']['button_icon_start'],'link'=>'cmd.php?cmd=load&id='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'link'=>'cmd.php?cmd=reload&id='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'style'=>'margin-right: 15px;','link'=>PROJECT_PATH.'/app/call_center_active/call_center_active.php?queue_name='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$settings->get('theme','button_icon_reload', ''),'link'=>'cmd.php?cmd=reload&id='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-view'],'icon'=>$settings->get('theme','button_icon_view', ''),'style'=>'margin-right: 15px;','link'=>PROJECT_PATH.'/app/call_center_active/call_center_active.php?queue_name='.urlencode($call_center_queue_uuid)]);
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme','button_icon_save', ''),'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
@@ -791,7 +785,7 @@
echo " ".$text['label-extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='queue_extension' maxlength='255' min='0' step='1' value=\"".escape($queue_extension)."\" required='required' placeholder=\"".($_SESSION['call_center']['extension_range']['text'] ?? '')."\">\n";
echo " <input class='formfld' type='number' name='queue_extension' maxlength='255' min='0' step='1' value=\"".escape($queue_extension)."\" required='required' placeholder=\"".$settings->get('call_center','extension_range', '')."\">\n";
echo "<br />\n";
echo $text['description-extension']."\n";
echo "</td>\n";
@@ -818,8 +812,8 @@
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
($instance_value == $row["value"] || $instance_value == $settings->get('switch','recordings', '')."/".$domain_name.'/'.$row["value"]) &&
file_exists($settings->get('switch','recordings', '')."/".$domain_name.'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
@@ -862,7 +856,7 @@
case 'ogg' : $mime_type = 'audio/ogg'; break;
}
echo "<audio id='recording_audio_".$instance_id."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$instance_id."')\" onended=\"recording_reset('".$instance_id."');\" src='".($playable ?? '')."' type='".($mime_type ?? '')."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme','button_icon_play', ''),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
unset($playable, $mime_type);
}
echo "<br />\n";
@@ -1318,8 +1312,8 @@
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
($instance_value == $row["value"] || $instance_value == $settings->get('switch','recordings', '')."/".$domain_name.'/'.$row["value"]) &&
file_exists($settings->get('switch','recordings', '')."/".$domain_name.'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
@@ -1362,7 +1356,7 @@
case 'ogg' : $mime_type = 'audio/ogg'; break;
}
echo "<audio id='recording_audio_".$instance_id."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$instance_id."')\" onended=\"recording_reset('".$instance_id."');\" src='".($playable ?? '')."' type='".($mime_type ?? '')."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme','button_icon_play', ''),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
unset($playable, $mime_type);
}
echo "<br />\n";
@@ -78,7 +78,7 @@
$array['dialplan_details'][0]['domain_uuid'] = $this->domain_uuid;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -216,7 +216,7 @@
$array["dialplans"][0] = $dialplan;
//add temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", 'temp');
$p->add("dialplan_detail_add", 'temp');
$p->add("dialplan_edit", 'temp');
@@ -242,7 +242,7 @@
$array['call_center_queues'][0]['dialplan_uuid'] = $this->dialplan_uuid;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('call_center_queue_edit', 'temp');
//execute update
@@ -349,7 +349,7 @@
}
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('call_center_tier_delete', 'temp');
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -446,7 +446,7 @@
}
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('call_center_tier_delete', 'temp');
//execute delete
@@ -578,7 +578,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('call_center_tier_add', 'temp');
$p->add('dialplan_add', 'temp');
+1 -1
View File
@@ -237,7 +237,7 @@
$array["call_flows"][$i]["call_flow_description"] = $call_flow_description;
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
@@ -121,7 +121,7 @@ if (!class_exists('call_flows')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -223,7 +223,7 @@ if (!class_exists('call_flows')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//save the array
@@ -374,7 +374,7 @@ if (!class_exists('call_flows')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
//save the array
+1 -1
View File
@@ -248,7 +248,7 @@
}
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("extension_edit", "temp");
//save the data
@@ -89,7 +89,7 @@
}
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_add', 'temp');
//execute update
@@ -214,7 +214,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
//save the array
@@ -95,7 +95,7 @@
$array['extensions'][0]['do_not_disturb'] = $this->enabled;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
//execute update
@@ -226,7 +226,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
//save the array
@@ -91,7 +91,7 @@
$array['follow_me'][0]['follow_me_enabled'] = $this->follow_me_enabled;
$array['follow_me'][0]['follow_me_ignore_busy'] = $this->follow_me_ignore_busy;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('follow_me_add', 'temp');
//execute insert
$database = new database;
@@ -115,7 +115,7 @@
$array['follow_me'][0]['follow_me_enabled'] = $this->follow_me_enabled;
$array['follow_me'][0]['follow_me_ignore_busy'] = $this->follow_me_ignore_busy;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('follow_me_add', 'temp');
//execute update
$database = new database;
@@ -135,7 +135,7 @@
//delete related follow me destinations
$array['follow_me_destinations'][0]['follow_me_uuid'] = $this->follow_me_uuid;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('follow_me_destination_delete', 'temp');
//execute delete
$database = new database;
@@ -210,7 +210,7 @@
}
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('follow_me_destination_add', 'temp');
//execute insert
$database = new database;
@@ -234,7 +234,7 @@
$extension_uuid = $result[0]['extension_uuid'];
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add("follow_me_edit", 'temp');
$p->add("extension_edit", 'temp');
@@ -389,7 +389,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
$p->add('follow_me_edit', 'temp');
+12
View File
@@ -34,6 +34,9 @@
$y++;
$apps[$x]['permissions'][$y]['name'] = 'call_recording_download';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'call_recording_transcribe';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y = 0;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "95cb740e-e377-4852-8894-06441c61e78b";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_recordings";
@@ -42,4 +45,13 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "90";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days to retain the maintenance logs in the database.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "e329db05-2967-422a-a71f-d0175b083828";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_recordings";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "record_extension";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "mp3";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Call recording file format options: wav, mp3";
?>
+334 -356
View File
@@ -1,356 +1,334 @@
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('call_recording_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
$transcribe_enabled = $settings->get('transcribe', 'enabled', 'false');
$transcribe_engine = $settings->get('transcribe', 'engine', '');
//set additional variables
$search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? '';
//get the http post data
if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_recordings = $_POST['call_recordings'];
}
//process the http post data by action
if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) {
switch ($action) {
case 'download':
if (permission_exists('call_recording_download')) {
$obj = new call_recordings;
$obj->download($call_recordings);
}
break;
case 'transcribe':
if (permission_exists('call_recording_download')) {
$obj = new call_recordings;
$obj->transcribe($call_recordings);
}
break;
case 'delete':
if (permission_exists('call_recording_delete')) {
$obj = new call_recordings;
$obj->delete($call_recordings);
}
break;
}
//redirect the user
header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search string
if (!empty($search)) {
$search = strtolower($_GET["search"]);
}
//set the time zone
if (!empty($_SESSION['domain']['time_zone']['name'])) {
$time_zone = $_SESSION['domain']['time_zone']['name'];
}
else {
$time_zone = date_default_timezone_get();
}
$parameters['time_zone'] = $time_zone;
//get the count
//$sql = "select count(*) ";
//$sql .= "from view_call_recordings ";
//$sql .= "where true ";
//if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) {
// $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
// $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
//}
//if (isset($search)) {
// $sql .= "and (";
// $sql .= " lower(call_recording_name) like :search ";
// $sql .= " or lower(call_recording_path) like :search ";
// $sql .= ") ";
// $parameters['search'] = '%'.$search.'%';
//}
//$database = new database;
//$num_rows = $database->select($sql, $parameters, 'column');
//prepare some of the paging values
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$offset = $rows_per_page * $page;
//get the list
$sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, ";
$sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, ";
$sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, ";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n";
$sql .= "from view_call_recordings as r, v_domains as d ";
//$sql .= "from v_call_recordings as r, v_domains as d ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('call_recording_all')) {
$sql .= "and (r.domain_uuid = :domain_uuid or r.domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$sql .= "and r.domain_uuid = d.domain_uuid ";
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(r.call_direction) like :search ";
$sql .= " or lower(r.caller_id_name) like :search ";
$sql .= " or lower(r.caller_id_number) like :search ";
$sql .= " or lower(r.caller_destination) like :search ";
$sql .= " or lower(r.destination_number) like :search ";
$sql .= " or lower(r.call_recording_name) like :search ";
$sql .= " or lower(r.call_recording_path) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$call_recordings = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//detect if any transcriptions available
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings) && is_array($call_recordings)) {
$transcriptions_exists = false;
foreach ($call_recordings as $row) {
if (!empty($row['call_recording_transcription'])) { $transcriptions_exists = true; }
}
}
//count the results
$result_count = is_array($call_recordings) ? sizeof($call_recordings) : 0;
//limit the number of results
if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
}
//prepare to page the results
$param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_recording_all')) {
$param .= "&show=all";
}
list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-call_recordings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-call_recordings']." </b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('call_recording_download') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'id'=>'btn_download','name'=>'btn_download','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]);
}
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('transcribe'); list_form_submit('form_list');"]);
}
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('call_recording_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-call_recordings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
$col_count = 8;
if ($show == "all" && permission_exists('call_recording_all')) {
$col_count++;
}
if (permission_exists('call_recording_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
$col_count++;
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='hide-sm-dn shrink'");
}
echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-15'");
echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='pct-10 hide-sm-dn'");
echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='pct-10'");
echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-20 hide-sm-dn'");
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo "<th class='shrink center'>".$text['label-recording']."</th>\n";
$col_count++;
}
echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'");
echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='pct-20 center'");
echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'");
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($call_recordings) && @sizeof($call_recordings) != 0) {
$x = 0;
foreach ($call_recordings as $row) {
//add padding to the call recording length
$call_recording_length_padding = (!empty($row['call_recording_length'])) ? str_pad($row['call_recording_length'], 2, '0', STR_PAD_LEFT) : '';
//playback progress bar
if (permission_exists('call_recording_play')) {
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;' onclick=\"recording_play('".escape($row['call_recording_uuid'])."')\"><td id='playback_progress_bar_background_".escape($row['call_recording_uuid'])."' class='playback_progress_bar_background' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
}
if (permission_exists('call_recording_play')) {
$list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');";
}
echo "<tr class='list-row' href=\"".$list_row_url."\">\n";
if (permission_exists('call_recording_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n";
echo " </td>\n";
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo " <td class='overflow hide-sm-dn shrink'>".escape($row['domain_name'])."</td>\n";
}
echo " <td class='hide-sm-dn shrink'>".escape($row['caller_id_name'])."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['caller_id_number'], 0, 20)))."</td>\n";
echo " <td class='hide-sm-dn shrink'>".escape(format_phone(substr($row['caller_destination'], 0, 20)))."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['destination_number'], 0, 20)))."</td>\n";
echo " <td class='overflow hide-sm-dn nowrap'>".escape($row['call_recording_name'])."</td>\n";
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo " <td class='middle button center no-link no-wrap'>";
if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) {
if (permission_exists('call_recording_play')) {
$recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]);
}
if (permission_exists('call_recording_download')) {
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']);
}
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && $transcriptions_exists === true) {
echo button::create(['type'=>'button','title'=>$text['label-transcription'],'icon'=>'quote-right','style'=>(empty($row['call_recording_transcription']) ? 'visibility:hidden;' : null),'onclick'=>"document.getElementById('transcription_".$row['call_recording_uuid']."').style.display = document.getElementById('transcription_".$row['call_recording_uuid']."').style.display == 'none' ? 'table-row' : 'none'; this.blur(); return false;"]);
}
}
echo " </td>\n";
}
echo " <td class='right overflow hide-sm-dn shrink'>".($row['call_recording_length'] <= 59 ? '0:' : null).escape($call_recording_length_padding)."</td>\n";
echo " <td class='overflow center no-wrap'>".escape($row['call_recording_date_formatted'])." <span class='hide-sm-dn'>".escape($row['call_recording_time_formatted'])."</span></td>\n";
echo " <td class='left hide-sm-dn shrink'>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n";
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]);
echo " </td>\n";
}
echo "</tr>\n";
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($row['call_recording_transcription'])) {
echo "<tr style='display: none;'><td></td></tr>\n"; // dummy row to maintain same background color for transcription row
echo "<tr id='transcription_".$row['call_recording_uuid']."' class='list-row' style='display: none;'>\n";
echo " <td style='padding: 10px 20px 15px 20px;' colspan='".$col_count."'>\n";
echo " <strong style='display: inline-block; font-size: 90%; margin-bottom: 10px;'>".$text['label-transcription']."...</strong><br />\n";
echo escape($row['call_recording_transcription'])."\n";
echo " </td>\n";
echo "</tr>\n";
}
$x++;
}
unset($call_recordings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('call_recording_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//create the database connection
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
$transcribe_enabled = $settings->get('transcribe', 'enabled', false);
$transcribe_engine = $settings->get('transcribe', 'engine', '');
//set additional variables
$search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? '';
//get the http post data
if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_recordings = $_POST['call_recordings'];
}
//process the http post data by action
if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) {
switch ($action) {
case 'download':
if (permission_exists('call_recording_download')) {
$obj = new call_recordings;
$obj->download($call_recordings);
}
break;
case 'transcribe':
if (permission_exists('call_recording_transcribe')) {
$obj = new call_recordings;
$obj->transcribe($call_recordings);
}
break;
case 'delete':
if (permission_exists('call_recording_delete')) {
$obj = new call_recordings;
$obj->delete($call_recordings);
}
break;
}
//redirect the user
header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search string
if (!empty($search)) {
$search = strtolower($_GET["search"]);
}
//set the time zone
if (!empty($_SESSION['domain']['time_zone']['name'])) {
$time_zone = $_SESSION['domain']['time_zone']['name'];
}
else {
$time_zone = date_default_timezone_get();
}
$parameters['time_zone'] = $time_zone;
//prepare some of the paging values
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$offset = $rows_per_page * $page;
//get the list
$sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, ";
$sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, ";
$sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, ";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n";
$sql .= "from view_call_recordings as r, v_domains as d ";
//$sql .= "from v_call_recordings as r, v_domains as d ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('call_recording_all')) {
$sql .= "and r.domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$sql .= "and r.domain_uuid = d.domain_uuid ";
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(r.call_direction) like :search ";
$sql .= " or lower(r.caller_id_name) like :search ";
$sql .= " or lower(r.caller_id_number) like :search ";
$sql .= " or lower(r.caller_destination) like :search ";
$sql .= " or lower(r.destination_number) like :search ";
$sql .= " or lower(r.call_recording_name) like :search ";
$sql .= " or lower(r.call_recording_path) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$call_recordings = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//detect if any transcriptions available
if ($transcribe_enabled && !empty($transcribe_engine) && !empty($call_recordings) && is_array($call_recordings)) {
$transcriptions_exists = false;
foreach ($call_recordings as $row) {
if (!empty($row['call_recording_transcription'])) { $transcriptions_exists = true; }
}
}
//limit the number of results
if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
}
//prepare to page the results
$param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_recording_all')) {
$param .= "&show=all";
}
list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-call_recordings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-call_recordings']." </b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('call_recording_download') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'id'=>'btn_download','name'=>'btn_download','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]);
}
if (permission_exists('call_recording_transcribe') && $transcribe_enabled && !empty($transcribe_engine) && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('transcribe'); list_form_submit('form_list');"]);
}
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('call_recording_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-call_recordings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
$col_count = 8;
if ($show == "all" && permission_exists('call_recording_all')) {
$col_count++;
}
if (permission_exists('call_recording_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
$col_count++;
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='hide-sm-dn shrink'");
}
echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-15'");
echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='pct-10 hide-sm-dn'");
echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='pct-10'");
echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-20 hide-sm-dn'");
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo "<th class='shrink center'>".$text['label-recording']."</th>\n";
$col_count++;
}
echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'");
echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='pct-20 center'");
echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'");
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($call_recordings) && @sizeof($call_recordings) != 0) {
$x = 0;
foreach ($call_recordings as $row) {
//playback progress bar
if (permission_exists('call_recording_play')) {
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;' onclick=\"recording_seek(event,'".escape($row['call_recording_uuid'])."')\"><td id='playback_progress_bar_background_".escape($row['call_recording_uuid'])."' class='playback_progress_bar_background' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
}
if (permission_exists('call_recording_play')) {
$list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');";
}
echo "<tr class='list-row' href=\"".$list_row_url."\">\n";
if (permission_exists('call_recording_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n";
echo " </td>\n";
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo " <td class='overflow hide-sm-dn shrink'>".escape($row['domain_name'])."</td>\n";
}
echo " <td class='hide-sm-dn shrink'>".escape($row['caller_id_name'])."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['caller_id_number'], 0, 20)))."</td>\n";
echo " <td class='hide-sm-dn shrink'>".escape(format_phone(substr($row['caller_destination'], 0, 20)))."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['destination_number'], 0, 20)))."</td>\n";
echo " <td class='overflow hide-sm-dn nowrap'>".escape($row['call_recording_name'])."</td>\n";
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo " <td class='middle button center no-link no-wrap'>";
if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) {
if (permission_exists('call_recording_play')) {
$recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]);
}
if (permission_exists('call_recording_download')) {
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']);
}
if (permission_exists('call_recording_transcribe') && $transcribe_enabled && !empty($transcribe_engine) && $transcriptions_exists === true) {
echo button::create(['type'=>'button','title'=>$text['label-transcription'],'icon'=>'quote-right','style'=>(empty($row['call_recording_transcription']) ? 'visibility:hidden;' : null),'onclick'=>"document.getElementById('transcription_".$row['call_recording_uuid']."').style.display = document.getElementById('transcription_".$row['call_recording_uuid']."').style.display == 'none' ? 'table-row' : 'none'; this.blur(); return false;"]);
}
}
echo " </td>\n";
}
echo " <td class='right overflow hide-sm-dn shrink'>".escape(gmdate("G:i:s", $row['call_recording_length']))."</td>\n";
echo " <td class='overflow center no-wrap'>".escape($row['call_recording_date_formatted'])." <span class='hide-sm-dn'>".escape($row['call_recording_time_formatted'])."</span></td>\n";
echo " <td class='left hide-sm-dn shrink'>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n";
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]);
echo " </td>\n";
}
echo "</tr>\n";
if (permission_exists('call_recording_transcribe') && $transcribe_enabled && !empty($transcribe_engine) && !empty($row['call_recording_transcription'])) {
echo "<tr style='display: none;'><td></td></tr>\n"; // dummy row to maintain same background color for transcription row
echo "<tr id='transcription_".$row['call_recording_uuid']."' class='list-row' style='display: none;'>\n";
echo " <td style='padding: 10px 20px 15px 20px;' colspan='".$col_count."'>\n";
echo " <strong style='display: inline-block; font-size: 90%; margin-bottom: 10px;'>".$text['label-transcription']."...</strong><br />\n";
echo escape($row['call_recording_transcription'])."\n";
echo " </td>\n";
echo "</tr>\n";
}
$x++;
}
unset($call_recordings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
+47 -47
View File
@@ -1,48 +1,48 @@
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permisions
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
//access granted
}
else {
echo "access denied";
exit;
}
//download
if (is_uuid($_GET['id'])) {
$obj = new call_recordings;
$obj->recording_uuid = $_GET['id'];
$obj->binary = isset($_GET['binary']) ? true : false;
$obj->download();
}
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permisions
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
//access granted
}
else {
echo "access denied";
exit;
}
//download
if (is_uuid($_GET['id'])) {
$obj = new call_recordings;
$obj->recording_uuid = $_GET['id'];
$obj->binary = isset($_GET['binary']) ? true : false;
$obj->download();
}
?>
File diff suppressed because it is too large Load Diff
+33 -6
View File
@@ -468,8 +468,8 @@ $text['label-domain']['zh-cn'] = "领域";
$text['label-domain']['ja-jp'] = "ドメイン";
$text['label-domain']['ko-kr'] = "도메인";
$text['label-destination']['en-us'] = "Dest";
$text['label-destination']['en-gb'] = "Dest";
$text['label-destination']['en-us'] = "Destination";
$text['label-destination']['en-gb'] = "Destination";
$text['label-destination']['ar-eg'] = "الوجهة";
$text['label-destination']['de-at'] = "Ziel";
$text['label-destination']['de-ch'] = "Ziel";
@@ -546,8 +546,8 @@ $text['label-codec']['zh-cn'] = "读/写编解码器";
$text['label-codec']['ja-jp'] = "読み取り/書き込みコーデック";
$text['label-codec']['ko-kr'] = "읽기/쓰기 코덱";
$text['label-cid-number']['en-us'] = "CID Number";
$text['label-cid-number']['en-gb'] = "CID Number";
$text['label-cid-number']['en-us'] = "Caller Number";
$text['label-cid-number']['en-gb'] = "Caller Number";
$text['label-cid-number']['ar-eg'] = "رقم CID";
$text['label-cid-number']['de-at'] = "Anrufer Nummer";
$text['label-cid-number']['de-ch'] = "Anrufer Nummer";
@@ -572,8 +572,8 @@ $text['label-cid-number']['zh-cn'] = "来电号码";
$text['label-cid-number']['ja-jp'] = "CID番号";
$text['label-cid-number']['ko-kr'] = "CID 번호";
$text['label-cid-name']['en-us'] = "CID Name";
$text['label-cid-name']['en-gb'] = "CID Name";
$text['label-cid-name']['en-us'] = "Caller Name";
$text['label-cid-name']['en-gb'] = "Caller Name";
$text['label-cid-name']['ar-eg'] = "اسم CID";
$text['label-cid-name']['de-at'] = "Anrufer Name";
$text['label-cid-name']['de-ch'] = "Anrufer Name";
@@ -650,6 +650,33 @@ $text['label-eavesdrop']['zh-cn'] = "窃听";
$text['label-eavesdrop']['ja-jp'] = "盗聴";
$text['label-eavesdrop']['ko-kr'] = "엿듣다";
$text['label-duration']['en-us'] = "Duration";
$text['label-duration']['en-gb'] = "Duration";
$text['label-duration']['ar-eg'] = "المدة";
$text['label-duration']['de-at'] = "Dauer";
$text['label-duration']['de-ch'] = "Dauer";
$text['label-duration']['de-de'] = "Dauer";
$text['label-duration']['el-gr'] = "Διάρκεια";
$text['label-duration']['es-cl'] = "Duración";
$text['label-duration']['es-mx'] = "Duración";
$text['label-duration']['fr-ca'] = "Durée";
$text['label-duration']['fr-fr'] = "Durée";
$text['label-duration']['he-il'] = "משך השיחה";
$text['label-duration']['it-it'] = "Durata";
$text['label-duration']['ka-ge'] = "ხანგრძლივობა";
$text['label-duration']['nl-nl'] = "Duur";
$text['label-duration']['pl-pl'] = "Czas trwania";
$text['label-duration']['pt-br'] = "Duração";
$text['label-duration']['pt-pt'] = "Duração";
$text['label-duration']['ro-ro'] = "Durată";
$text['label-duration']['ru-ru'] = "Продолжительность";
$text['label-duration']['sv-se'] = "Samtalstid";
$text['label-duration']['uk-ua'] = "Тривалість";
$text['label-duration']['tr-tr'] = "Süre";
$text['label-duration']['zh-cn'] = "期间";
$text['label-duration']['ja-jp'] = "間隔";
$text['label-duration']['ko-kr'] = "지속";
$text['description-2']['en-us'] = "Use this to view all extensions and monitor and interact with active calls.";
$text['description-2']['en-gb'] = "Use this to view all extensions and monitor and interact with active calls.";
$text['description-2']['ar-eg'] = "استخدم هذا لعرض جميع الملحقات ومراقبة المكالمات النشطة والتفاعل معها.";
+180 -157
View File
@@ -88,10 +88,8 @@
}
$num_rows = @sizeof($rows);
//if the connnection is available then run it and return the results
if (!$event_socket) {
$msg = "<div align='center'>".$text['confirm-socket']."<br /></div>";
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
@@ -103,172 +101,197 @@
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
return;
}
else {
//create token
$object = new token;
$token = $object->create('/app/calls_active/calls_active_inc.php');
//create token
$object = new token;
$token = $object->create('/app/calls_active/calls_active_inc.php');
//show content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo " <span id='refresh_state'>".button::create(['type'=>'button','title'=>$text['label-refresh_pause'],'icon'=>'sync-alt fa-spin','onclick'=>'refresh_stop()'])."</span>";
if (permission_exists('call_active_eavesdrop') && !empty($_SESSION['user']['extensions'])) {
if (sizeof($_SESSION['user']['extensions']) > 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".(($_REQUEST['eavesdrop_dest'] == '') ? $_SESSION['user']['extension'][0]['destination'] : escape($_REQUEST['eavesdrop_dest']))."\">\n";
echo " <i class='fas fa-headphones' style='margin-left: 15px; cursor: help;' title='".$text['description-eavesdrop_destination']."' align='absmiddle'></i>\n";
echo " <select class='formfld' style='margin-right: 5px;' align='absmiddle' onchange=\"document.getElementById('eavesdrop_dest').value = this.options[this.selectedIndex].value; refresh_start();\" onfocus='refresh_stop();'>\n";
if (is_array($_SESSION['user']['extensions'])) {
foreach ($_SESSION['user']['extensions'] as $user_extension) {
echo " <option value='".escape($user_extension)."' ".(($_REQUEST['eavesdrop_dest'] == $user_extension) ? "selected" : null).">".escape($user_extension)."</option>\n";
}
//add the style
echo "<style>\n";
echo " /* Small screens: Hide columns with class 'hide-small' */\n";
echo " @media (max-width: 600px) {\n";
echo " .hide-small {\n";
echo " display: none;\n";
echo " }\n";
echo " }\n";
echo "\n";
echo " /* Medium screens: Hide columns with class 'hide-medium' */\n";
echo "@media (max-width: 1023px) and (min-width: 601px) {\n";
echo " .hide-medium {\n";
echo " display: none;\n";
echo " }\n";
echo " }\n";
echo "\n";
echo "</style>\n";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo " <span id='refresh_state'>".button::create(['type'=>'button','title'=>$text['label-refresh_pause'],'icon'=>'sync-alt fa-spin','onclick'=>'refresh_stop()'])."</span>";
if (permission_exists('call_active_eavesdrop') && !empty($_SESSION['user']['extensions'])) {
if (sizeof($_SESSION['user']['extensions']) > 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".(($_REQUEST['eavesdrop_dest'] == '') ? $_SESSION['user']['extension'][0]['destination'] : escape($_REQUEST['eavesdrop_dest']))."\">\n";
echo " <i class='fas fa-headphones' style='margin-left: 15px; cursor: help;' title='".$text['description-eavesdrop_destination']."' align='absmiddle'></i>\n";
echo " <select class='formfld' style='margin-right: 5px;' align='absmiddle' onchange=\"document.getElementById('eavesdrop_dest').value = this.options[this.selectedIndex].value; refresh_start();\" onfocus='refresh_stop();'>\n";
if (is_array($_SESSION['user']['extensions'])) {
foreach ($_SESSION['user']['extensions'] as $user_extension) {
echo " <option value='".escape($user_extension)."' ".(($_REQUEST['eavesdrop_dest'] == $user_extension) ? "selected" : null).">".escape($user_extension)."</option>\n";
}
}
echo " </select>\n";
}
else if (sizeof($_SESSION['user']['extensions']) == 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".escape($_SESSION['user']['extension'][0]['destination'])."\">\n";
}
}
if (permission_exists('call_active_hangup') && $rows) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','id'=>'btn_delete','onclick'=>"refresh_stop(); modal_open('modal-hangup','btn_hangup');"]);
}
if (permission_exists('call_active_all')) {
if ($show == "all") {
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'calls_active.php','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'calls_active.php?show=all','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_active_hangup') && $rows) {
echo modal::create(['id'=>'modal-hangup','type'=>'general','message'=>$text['confirm-hangups'],'actions'=>button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'check','id'=>'btn_hangup','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('hangup'); list_form_submit('form_list');"])]);
}
echo $text['description']."\n";
echo "<br /><br />\n";
//show the results
echo "<div id='cmd_reponse'></div>\n";
echo "<form id='form_list' method='post' action='calls_exec.php'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<div class='card'>\n";
echo " <table class='list'>\n";
echo " <tr class='list-header'>\n";
if (permission_exists('call_active_hangup')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='if (this.checked) { refresh_stop(); } else { refresh_start(); } list_all_toggle();' ".(empty($rows) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
echo " <th class='hide-small'>".$text['label-profile']."</th>\n";
//echo" <th>".$text['label-created']."</th>\n";
echo " <th>".$text['label-duration']."</th>\n";
if ($show == 'all') {
echo " <th>".$text['label-domain']."</th>\n";
}
//echo " <th>".$text['label-number']."</th>\n";
echo " <th class='hide-small'>".$text['label-cid-name']."</th>\n";
echo " <th>".$text['label-cid-number']."</th>\n";
echo " <th>".$text['label-destination']."</th>\n";
echo " <th class='hide-small hide-medium'>".$text['label-app']."</th>\n";
echo " <th class='hide-small hide-medium'>".$text['label-codec']."</th>\n";
echo " <th class='hide-small hide-medium'>".$text['label-secure']."</th>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <th>&nbsp;</th>\n";
}
echo " </tr>\n";
if (is_array($rows)) {
$x = 0;
foreach ($rows as $row) {
//set the php variables
foreach ($row as $key => $value) {
$$key = $value;
}
//get the sip profile
$name_array = explode("/", $name);
$sip_profile = $name_array[1];
$sip_uri = $name_array[2];
//get the number
//$temp_array = explode("@", $sip_uri);
//$tmp_number = $temp_array[0];
//$tmp_number = str_replace("sip:", "", $tmp_number);
//remove the '+' because it breaks the call recording
$cid_num = str_replace("+", "", $cid_num);
//replace gateway uuid with name
if (is_array($_SESSION['gateways']) && sizeof($_SESSION['gateways']) > 0) {
foreach ($_SESSION['gateways'] as $gateway_uuid => $gateway_name) {
$application_data = str_replace($gateway_uuid, $gateway_name, $application_data);
}
echo " </select>\n";
}
else if (sizeof($_SESSION['user']['extensions']) == 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".escape($_SESSION['user']['extension'][0]['destination'])."\">\n";
//calculate elapsed seconds
$elapsed_seconds = time() - $created_epoch;
//convert seconds to hours, minutes, and seconds
$hours = floor($elapsed_seconds / 3600);
$minutes = floor(($elapsed_seconds % 3600) / 60);
$seconds = $elapsed_seconds % 60;
//format the elapsed time as HH:MM:SS
$elapsed_time = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
//reduce too long app data
if(strlen($application_data) > 80) {
$application_data = substr($application_data, 0, 80) . '...';
}
}
if (permission_exists('call_active_hangup') && $rows) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','id'=>'btn_delete','onclick'=>"refresh_stop(); modal_open('modal-hangup','btn_hangup');"]);
}
if (permission_exists('call_active_all')) {
if ($show == "all") {
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'calls_active.php','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
//send the html
echo " <tr class='list-row'>\n";
if (permission_exists('call_active_hangup')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='calls[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (this.checked) { refresh_stop(); } else { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='calls[$x][uuid]' value='".escape($uuid)."' />\n";
echo " </td>\n";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'calls_active.php?show=all','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
echo " <td class='hide-small'>".escape($sip_profile)."&nbsp;</td>\n";
//echo " <td>".escape($created)."&nbsp;</td>\n";
echo " <td>".escape($elapsed_time)."</td>\n";
if ($show == 'all') {
echo " <td>".escape($domain_name)."&nbsp;</td>\n";
}
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_active_hangup') && $rows) {
echo modal::create(['id'=>'modal-hangup','type'=>'general','message'=>$text['confirm-hangups'],'actions'=>button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'check','id'=>'btn_hangup','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('hangup'); list_form_submit('form_list');"])]);
}
echo $text['description']."\n";
echo "<br /><br />\n";
//show the results
echo "<div id='cmd_reponse'></div>\n";
echo "<form id='form_list' method='post' action='calls_exec.php'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('call_active_hangup')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='if (this.checked) { refresh_stop(); } else { refresh_start(); } list_all_toggle();' ".(empty($rows) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
echo " <th>".$text['label-profile']."</th>\n";
echo " <th>".$text['label-created']."</th>\n";
if ($show == 'all') {
echo " <th>".$text['label-domain']."</th>\n";
}
echo " <th>".$text['label-number']."</th>\n";
echo " <th>".$text['label-cid-name']."</th>\n";
echo " <th>".$text['label-cid-number']."</th>\n";
echo " <th>".$text['label-destination']."</th>\n";
echo " <th>".$text['label-app']."</th>\n";
echo " <th>".$text['label-codec']."</th>\n";
echo " <th>".$text['label-secure']."</th>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <th>&nbsp;</th>\n";
}
echo "</tr>\n";
if (is_array($rows)) {
$x = 0;
foreach ($rows as $row) {
//set the php variables
foreach ($row as $key => $value) {
$$key = $value;
}
//get the sip profile
$name_array = explode("/", $name);
$sip_profile = $name_array[1];
$sip_uri = $name_array[2];
//get the number
$temp_array = explode("@", $sip_uri);
$tmp_number = $temp_array[0];
$tmp_number = str_replace("sip:", "", $tmp_number);
//remove the '+' because it breaks the call recording
$cid_num = str_replace("+", "", $cid_num);
//replace gateway uuid with name
if (is_array($_SESSION['gateways']) && sizeof($_SESSION['gateways']) > 0) {
foreach ($_SESSION['gateways'] as $gateway_uuid => $gateway_name) {
$application_data = str_replace($gateway_uuid, $gateway_name, $application_data);
}
}
// reduce too long app data
if(strlen($application_data) > 512) {
$application_data = substr($application_data, 0, 512) . '...';
}
//send the html
echo "<tr class='list-row'>\n";
if (permission_exists('call_active_hangup')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='calls[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (this.checked) { refresh_stop(); } else { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='calls[$x][uuid]' value='".escape($uuid)."' />\n";
echo " </td>\n";
}
echo " <td>".escape($sip_profile)."&nbsp;</td>\n";
echo " <td>".escape($created)."&nbsp;</td>\n";
if ($show == 'all') {
echo " <td>".escape($domain_name)."&nbsp;</td>\n";
}
echo " <td>".escape($tmp_number)."&nbsp;</td>\n";
echo " <td>".escape($cid_name)."&nbsp;</td>\n";
echo " <td>".escape($cid_num)."&nbsp;</td>\n";
echo " <td>".escape($dest)."&nbsp;</td>\n";
echo " <td>".(!empty($application) ? escape($application).":".escape($application_data) : null)."&nbsp;</td>\n";
echo " <td>".escape($read_codec).":".escape($read_rate)." / ".escape($write_codec).":".escape($write_rate)."&nbsp;</td>\n";
echo " <td>".escape($secure)."&nbsp;</td>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <td class='button right' style='padding-right: 0;'>\n";
//eavesdrop
if (permission_exists('call_active_eavesdrop') && $callstate == 'ACTIVE' && !empty($_SESSION['user']['extensions']) && !in_array($cid_num, $_SESSION['user']['extensions'])) {
echo button::create(['type'=>'button','label'=>$text['label-eavesdrop'],'icon'=>'headphones','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-eavesdrop']."')) { eavesdrop_call('".escape($cid_num)."','".escape($uuid)."'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
//hangup
if (permission_exists('call_active_hangup')) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-hangup']."')) { list_self_check('checkbox_".$x."'); list_action_set('hangup'); list_form_submit('form_list'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
echo "</td>\n";
}
echo "</tr>\n";
//unset the domain name
unset($domain_name);
//increment counter
$x++;
//echo " <td>".escape($tmp_number)."&nbsp;</td>\n";
echo " <td class='hide-small'>".escape($cid_name)."&nbsp;</td>\n";
echo " <td>".escape($cid_num)."&nbsp;</td>\n";
echo " <td>".escape($dest)."&nbsp;</td>\n";
echo " <td class='hide-small hide-medium' style='max-width: 200px; word-wrap: break-word;'>".(!empty($application) ? escape($application).":".escape($application_data) : null)."&nbsp;</td>\n";
echo " <td class='hide-small hide-medium'>".escape($read_codec).":".escape($read_rate)." / ".escape($write_codec).":".escape($write_rate)."&nbsp;</td>\n";
echo " <td class='hide-small hide-medium'>".escape($secure)."&nbsp;</td>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <td class='button right' style='padding-right: 0;'>\n";
//eavesdrop
if (permission_exists('call_active_eavesdrop') && $callstate == 'ACTIVE' && !empty($_SESSION['user']['extensions']) && !in_array($cid_num, $_SESSION['user']['extensions'])) {
echo button::create(['type'=>'button','label'=>$text['label-eavesdrop'],'icon'=>'headphones','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-eavesdrop']."')) { eavesdrop_call('".escape($cid_num)."','".escape($uuid)."'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
//hangup
if (permission_exists('call_active_hangup')) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-hangup']."')) { list_self_check('checkbox_".$x."'); list_action_set('hangup'); list_form_submit('form_list'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
echo " </td>\n";
}
unset($rows);
}
echo " </tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//unset the domain name
unset($domain_name);
//increment counter
$x++;
}
}
echo " </table>\n";
echo "</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
?>
@@ -164,7 +164,7 @@
$array['dialplans'][0]["app_uuid"] = "b81412e8-7253-91f4-e48e-42fc2c9a38d9";
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
@@ -188,7 +188,7 @@
$array['conference_room_users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//un-assigne the users from the conference room
$p = new permissions;
$p = permissions::new();
$p->add('conference_room_user_delete', 'temp');
$database->app_name = 'conference_centers';
@@ -358,7 +358,7 @@
$array['conference_room_users'][0]['conference_room_uuid'] = $conference_room_uuid;
$array['conference_room_users'][0]['user_uuid'] = $_SESSION["user_uuid"];
$p = new permissions;
$p = permissions::new();
$p->add('conference_room_user_add', 'temp');
$database->app_name = 'conference_centers';
@@ -440,7 +440,7 @@
$array['conference_room_users'][0]['conference_room_uuid'] = $conference_room_uuid;
$array['conference_room_users'][0]['user_uuid'] = $user_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('conference_room_user_add', 'temp');
$database->app_name = 'conference_centers';
@@ -349,7 +349,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_detail_delete', 'temp');
$p->add('dialplan_delete', 'temp');
@@ -425,7 +425,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_room_user_delete', 'temp');
$p->add('conference_room_delete', 'temp');
@@ -489,7 +489,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_session_detail_delete', 'temp');
$p->add('conference_user_delete', 'temp');
@@ -578,7 +578,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_edit", "temp");
//save the array
+2 -2
View File
@@ -65,7 +65,7 @@
$array['conference_controls'][0]['control_name'] = $control_name;
$array['conference_controls'][0]['control_enabled'] = 'true';
$p = new permissions;
$p = permissions::new();
$p->add('conference_control_add', 'temp');
$database->app_name = 'conference_controls';
@@ -96,7 +96,7 @@
}
$array['conference_control_details'][0]['control_enabled'] = $control_enabled;
$p = new permissions;
$p = permissions::new();
$p->add('conference_control_detail_add', 'temp');
$database->app_name = 'conference_controls';
@@ -103,7 +103,7 @@ if (!class_exists('conference_controls')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_control_detail_delete', 'temp');
//execute delete
+2 -2
View File
@@ -65,7 +65,7 @@
$array['conference_profiles'][0]['profile_name'] = $profile_name;
$array['conference_profiles'][0]['profile_enabled'] = 'true';
$p = new permissions;
$p = permissions::new();
$p->add('conference_profile_add', 'temp');
$database->app_name = 'conference_profiles';
@@ -91,7 +91,7 @@
$array['conference_profile_params'][0]['profile_param_value'] = $profile_param_value;
$array['conference_profile_params'][0]['profile_param_enabled'] = $profile_param_enabled;
$p = new permissions;
$p = permissions::new();
$p->add('conference_profile_param_add', 'temp');
$database->app_name = 'conference_profiles';
@@ -103,7 +103,7 @@ if (!class_exists('conference_profiles')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_profile_param_delete', 'temp');
//execute delete
@@ -410,7 +410,7 @@ if (!class_exists('conference_profiles')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_profile_param_add', 'temp');
//save the array
+3 -3
View File
@@ -91,7 +91,7 @@
$user_uuid = $_REQUEST["user_uuid"];
$conference_uuid = $_REQUEST["id"];
$p = new permissions;
$p = permissions::new();
$p->add('conference_user_delete', 'temp');
$array['conference_users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
@@ -124,7 +124,7 @@
$array['conference_users'][0]['conference_uuid'] = $conference_uuid;
$array['conference_users'][0]['user_uuid'] = $user_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('conference_user_add', 'temp');
$database = new database;
@@ -239,7 +239,7 @@
$array['dialplans'][0]['dialplan_enabled'] = $conference_enabled;
$array['dialplans'][0]['dialplan_description'] = $conference_description;
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
$p->add('dialplan_edit', 'temp');
@@ -108,7 +108,7 @@ if (!class_exists('conferences')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_user_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
$p->add('dialplan_delete', 'temp');
@@ -203,7 +203,7 @@ if (!class_exists('conferences')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//save the array
@@ -341,7 +341,7 @@ if (!class_exists('conferences')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('conference_user_add', 'temp');
$p->add('dialplan_add', 'temp');
+1 -1
View File
@@ -131,7 +131,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -545,7 +545,7 @@
//save the data
if (!empty($array)) {
//add the permission object
$p = new permissions;
$p = permissions::new();
$p->add('contact_add', 'temp');
$p->add('contact_phone_add', 'temp');
$p->add('contact_address_add', 'temp');
+1 -1
View File
@@ -112,7 +112,7 @@ if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -107,7 +107,7 @@ if ($_POST['a'] == 'import') {
unset($duplicate_contact_uuid);
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('contact_delete', 'temp');
//delete duplicate contact
+1 -1
View File
@@ -102,7 +102,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -132,7 +132,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -110,7 +110,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -129,7 +129,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -102,7 +102,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -115,7 +115,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p = permissions::new();
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -108,7 +108,7 @@ if (!class_exists('contacts')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temp permissions
$p = new permissions;
$p = permissions::new();
$database = new database;
foreach ($this->tables as $table) {
$p->add(database::singular($table).'_delete', 'temp');
+2 -2
View File
@@ -83,7 +83,7 @@ if ($domains_processed == 1) {
//save to the data
if (!empty($array)) {
//add temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('destination_edit', 'temp');
//create the database object and save the data
@@ -109,7 +109,7 @@ if ($domains_processed == 1) {
if (!empty($array)) {
//add temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('destination_edit', 'temp');
//create the database object and save the data
-1
View File
@@ -73,4 +73,3 @@
$y++;
?>
+42 -21
View File
@@ -41,10 +41,13 @@
$language = new text;
$text = $language->get();
//initialize the database
$database = new database;
//initialize the database object
$database = database::new();
//initialize the destinations object
//initialize the settings object
$settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
//initialize the destination object
$destination = new destinations;
//initialize the ringbacks object
@@ -68,17 +71,20 @@
default: $destination_type = 'inbound';
}
//get the call recording extension
$record_extension = $settings->get('call_recordings', 'record_extension', 'mp3');
//get total destination count from the database, check limit, if defined
if (!permission_exists('destination_domain')) {
if ($action == 'add') {
if (!empty($_SESSION['limit']['destinations']['numeric'])) {
if (!empty($settings->get('limit', 'destinations', ''))) {
$sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$total_destinations = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
if ($total_destinations >= $_SESSION['limit']['destinations']['numeric']) {
message::add($text['message-maximum_destinations'].' '.$_SESSION['limit']['destinations']['numeric'], 'negative');
if ($total_destinations >= $settings->get('limit', 'destinations', '')) {
message::add($text['message-maximum_destinations'].' '.$settings->get('limit', 'destinations', ''), 'negative');
header('Location: destinations.php');
exit;
}
@@ -198,7 +204,7 @@
if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
//check for duplicates
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $_SESSION['destinations']['unique']['boolean'] == 'true') {
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $settings->get('destinations', 'unique', '')) {
$sql = "select count(*) from v_destinations ";
$sql .= "where (destination_number = :destination_number or destination_prefix || destination_number = :destination_number) ";
$sql .= "and destination_type = 'inbound' ";
@@ -444,15 +450,15 @@
if (!empty($destination_condition_field)) {
$dialplan_detail_type = $destination_condition_field;
}
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
$dialplan_detail_type = $settings->get('dialplan', 'destination', '');
}
else {
$dialplan_detail_type = "destination_number";
}
//authorized specific dialplan_detail_type that are safe, sanitize all other values
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
$dialplan_detail_type = $settings->get('dialplan', 'destination', '');
switch ($dialplan_detail_type) {
case 'destination_number':
break;
@@ -530,10 +536,11 @@
}
if (!empty($destination_record) && $destination_record == 'true') {
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_path=\${recordings_dir}/\${domain_name}/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_name=\${uuid}.\${record_ext}\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_name=\${uuid}.".$record_extension."\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_append=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_in_progress=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"recording_follow_transfer=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_stereo_swap=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"record_session\" data=\"\${record_path}/\${record_name}\" inline=\"false\"/>\n";
}
if (!empty($destination_hold_music)) {
@@ -592,7 +599,7 @@
$dialplan["dialplan_xml"] .= "</extension>\n";
//dialplan details
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "true") {
if ($settings->get('destinations', 'dialplan_details', '')) {
//set initial value of the row id
$y=0;
@@ -633,8 +640,8 @@
if (!empty($destination_condition_field)) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
}
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text'];
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', '');
}
else {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "regex";
@@ -693,8 +700,8 @@
if (!empty($destination_condition_field)) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
}
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text'];
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', '');
}
else {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
@@ -942,7 +949,7 @@
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.\${record_ext}";
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.".$record_extension;
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
@@ -979,6 +986,20 @@
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
//add a variable
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_stereo_swap=true";
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$y++;
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
//add a variable
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
@@ -1139,7 +1160,7 @@
}
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", 'temp');
$p->add("dialplan_detail_add", 'temp');
$p->add("dialplan_edit", 'temp');
@@ -1159,10 +1180,10 @@
//clear the cache
$cache = new cache;
if ($_SESSION['destinations']['dialplan_mode']['text'] == 'multiple') {
if ($settings->get('destinations', 'dialplan_mode', '') == 'multiple') {
$cache->delete("dialplan:".$destination_context);
}
if ($_SESSION['destinations']['dialplan_mode']['text'] == 'single') {
if ($settings->get('destinations', 'dialplan_mode', '') == 'single') {
if (isset($destination_prefix) && is_numeric($destination_prefix) && isset($destination_number) && is_numeric($destination_number)) {
$cache->delete("dialplan:".$destination_context.":".$destination_prefix.$destination_number);
$cache->delete("dialplan:".$destination_context.":+".$destination_prefix.$destination_number);
@@ -2046,7 +2067,7 @@
echo " ".$text['label-destination_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='destination_enabled' name='destination_enabled' value='true' ".($destination_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
File diff suppressed because it is too large Load Diff
@@ -402,7 +402,7 @@ if (!class_exists('destinations')) {
}
}
//application: hangup
if (!empty($data['application'])) {
if (!empty($data['application']) && $data['application'] === 'hangup') {
$select_value = str_replace("transfer", $data['application'], $select_value);
}
}
@@ -1081,7 +1081,7 @@ if (!class_exists('destinations')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -1134,6 +1134,9 @@ if (!class_exists('destinations')) {
$time_zone = date_default_timezone_get();
}
//set the time zone for php
date_default_timezone_set($time_zone);
//build the date range
if (!empty($this->start_stamp_begin) || !empty($this->start_stamp_end)) {
unset($this->quick_select);
@@ -1236,6 +1239,7 @@ if (!class_exists('destinations')) {
}
$sql .= " and direction = 'inbound' \n";
$sql .= " and caller_destination is not null \n";
$sql .= " and leg = 'a' \n";
$sql .= $sql_date_range ?? '';
$sql .= ") as c \n";
+4 -4
View File
@@ -62,7 +62,7 @@ if ($domains_processed == 1) {
$array['device_keys'][$index]['device_key_vendor'] = $row["device_vendor"];
}
if (is_array($array) && @sizeof($array)) {
$p = new permissions;
$p = permissions::new();
$p->add('device_key_edit', 'temp');
$database->app_name = 'devices';
@@ -106,7 +106,7 @@ if ($domains_processed == 1) {
//save the array
if (!empty($array)) {
$p = new permissions;
$p = permissions::new();
$p->add('device_profile_key_add', 'temp');
$database->app_name = 'devices';
@@ -144,7 +144,7 @@ if ($domains_processed == 1) {
//save the array
if (!empty($array)) {
$p = new permissions;
$p = permissions::new();
$p->add('device_profile_setting_add', 'temp');
$database->app_name = 'devices';
@@ -225,7 +225,7 @@ if ($domains_processed == 1) {
//execute
if (!empty($array)) {
$p = new permissions;
$p = permissions::new();
$p->add('device_vendor_add', 'temp');
$p->add('device_vendor_function_add', 'temp');
$p->add('device_vendor_function_group_add', 'temp');
-1
View File
@@ -7364,4 +7364,3 @@ $text['label-required']['ja-jp'] = "必要";
$text['label-required']['ko-kr'] = "필수의";
?>
+81 -89
View File
@@ -44,8 +44,9 @@
$device_firmware_version = '';
$device_template ='';
//get the domain uuid
//get the domain values
$domain_uuid = $_SESSION['domain_uuid'] ?? '';
$domain_name = $_SESSION['domain_name'] ?? '';
//initialize the database object
$database = database::new();
@@ -64,12 +65,12 @@
//get the total device count from the database, check the limit, if defined
if ($action == 'add') {
if (!empty($_SESSION['limit']['devices']['numeric']) && $_SESSION['limit']['devices']['numeric']) {
if (!empty($settings->get('limit', 'devices', ''))) {
$sql = "select count(*) from v_devices where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['domain_uuid'] = $domain_uuid;
$total_devices = $database->select($sql, $parameters, 'column');
if ($total_devices >= $_SESSION['limit']['devices']['numeric']) {
message::add($text['message-maximum_devices'].' '.$_SESSION['limit']['devices']['numeric'], 'negative');
if ($total_devices >= $settings->get('limit', 'devices', '')) {
message::add($text['message-maximum_devices'].' '.$settings->get('limit', 'devices', ''), 'negative');
header('Location: devices.php');
exit;
}
@@ -228,14 +229,14 @@
$sql .= " and d1.device_uuid <> :device_uuid ";
}
$parameters['device_address'] = $device_address;
$domain_name = $database->select($sql, $parameters, 'column');
if ($domain_name != '') {
$message = $text['message-duplicate'].(if_group("superadmin") && $_SESSION["domain_name"] != $domain_name ? ": ".$domain_name : null);
$device_domain_name = $database->select($sql, $parameters, 'column');
if ($device_domain_name != '') {
$message = $text['message-duplicate'].($device_domain_name != $domain_name ? ": ".$device_domain_name : null);
message::add($message,'negative');
header('Location: devices.php');
exit;
}
unset($sql, $parameters, $domain_name);
unset($sql, $parameters, $device_domain_name);
}
//add or update the database
@@ -304,6 +305,7 @@
$device_line_uuid = uuid();
$new_line = true;
}
$array['devices'][0]['device_lines'][$y]['domain_uuid'] = $domain_uuid;
$array['devices'][0]['device_lines'][$y]['device_uuid'] = $device_uuid;
$array['devices'][0]['device_lines'][$y]['device_line_uuid'] = $device_line_uuid;
@@ -311,23 +313,23 @@
$array['devices'][0]['device_lines'][$y]['server_address'] = $row["server_address"];
if (permission_exists('device_line_outbound_proxy_primary')) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $row["outbound_proxy_primary"];
} else if ($new_line && isset($_SESSION['provision']['outbound_proxy_primary'])) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'];
} else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_primary'))) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', '');
}
if (permission_exists('device_line_outbound_proxy_secondary')) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"];
} else if ($new_line && isset($_SESSION['provision']['outbound_proxy_secondary'])) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'];
} else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_secondary'))) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', '');
}
if (permission_exists('device_line_server_address_primary')) {
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $row["server_address_primary"];
} else if ($new_line && isset($_SESSION['provision']['server_address_primary'])) {
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $_SESSION['provision']['server_address_primary']['text'];
} else if ($new_line && !empty($settings->get('provision', 'server_address_primary'))) {
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $settings->get('provision', 'server_address_primary', '');
}
if (permission_exists('device_line_server_address_secondary')) {
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $row["server_address_secondary"];
} else if ($new_line && isset($_SESSION['provision']['server_address_secondary'])) {
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $_SESSION['provision']['server_address_secondary']['text'];
} else if ($new_line && !empty($settings->get('provision', 'server_address_secondary'))) {
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', '');
}
if (permission_exists('device_line_label')) {
$array['devices'][0]['device_lines'][$y]['label'] = $row["label"];
@@ -351,7 +353,7 @@
}
else {
if ($action == "add") {
$array['devices'][0]['device_lines'][$y]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
$array['devices'][0]['device_lines'][$y]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060');
}
}
if (permission_exists('device_line_transport')) {
@@ -359,7 +361,7 @@
}
else {
if ($action == "add") {
$array['devices'][0]['device_lines'][$y]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
$array['devices'][0]['device_lines'][$y]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp');
}
}
if (permission_exists('device_line_register_expires')) {
@@ -367,7 +369,7 @@
}
else {
if ($action == "add") {
$array['devices'][0]['device_lines'][$y]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
$array['devices'][0]['device_lines'][$y]['register_expires'] = $settings->get('provision', 'line_register_expires', '120');
}
}
$y++;
@@ -480,7 +482,7 @@
}
//write the provision files
if (!empty($_SESSION['provision']['path']['text'])) {
if (!empty($settings->get('provision', 'path'))) {
$prov = new provision(['settings' => $settings]);
$prov->domain_uuid = $domain_uuid;
$response = $prov->write();
@@ -509,7 +511,6 @@
$sql = "select * from v_devices ";
$sql .= "where device_uuid = :device_uuid ";
$parameters['device_uuid'] = $device_uuid;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$device_address = $row["device_address"];
@@ -533,6 +534,13 @@
unset($sql, $parameters, $row);
}
//get device lines
$sql = "select * ";
$sql .= "from v_domains ";
$sql .= "order by domain_name asc ";
$domains = $database->select($sql, null, 'all');
unset($sql, $parameters);
//set the defaults
if (empty($device_enabled)) { $device_enabled = 'true'; }
@@ -563,20 +571,22 @@
}
//get device lines
$sql = "select * from v_device_lines ";
$sql = "select l.*, d.domain_name ";
$sql .= "from v_device_lines as l, v_domains as d ";
$sql .= "where device_uuid = :device_uuid ";
$sql .= "and l.domain_uuid = d.domain_uuid ";
$sql .= "order by cast(line_number as int) asc ";
$parameters['device_uuid'] = $device_uuid ?? null;
$device_lines = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//set the new line defaults
$device_lines[$x]['line_number'] = '';
$device_lines[$x]['server_address'] = '';
$device_lines[$x]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'] ?? null;
$device_lines[$x]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'] ?? null;
$device_lines[$x]['server_address_primary'] = $_SESSION['provision']['server_address_primary']['text'] ?? null;
$device_lines[$x]['server_address_secondary'] = $_SESSION['provision']['server_address_secondary']['text'] ?? null;
$device_lines[$x]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', null);
$device_lines[$x]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', null);
$device_lines[$x]['server_address_primary'] = $settings->get('provision', 'server_address_primary', null);
$device_lines[$x]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', null);
$device_lines[$x]['label'] = '';
$device_lines[$x]['display_name'] = '';
$device_lines[$x]['user_id'] = '';
@@ -584,9 +594,9 @@
$device_lines[$x]['password'] = '';
$device_lines[$x]['shared_line'] = '';
$device_lines[$x]['enabled'] = '';
$device_lines[$x]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
$device_lines[$x]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
$device_lines[$x]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
$device_lines[$x]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060');
$device_lines[$x]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp');
$device_lines[$x]['register_expires'] = $settings->get('provision', 'line_register_expires', '120');
//get device keys
$sql = "select * from v_device_keys ";
@@ -612,11 +622,11 @@
//add empty device key row(s)
if (!is_uuid($device_uuid)) {
$rows = $_SESSION['devices']['key_add_rows']['numeric'] ?? 1;
$rows = $settings->get('devices', 'key_add_rows', '10');
$id = 0;
}
else {
$rows = $_SESSION['devices']['key_edit_rows']['numeric'] ?? 1;
$rows = $settings->get('devices', 'key_edit_rows', '3');
$id = count($device_keys) + 1;
}
for ($x = 0; $x < $rows; $x++) {
@@ -638,7 +648,6 @@
$sql .= "from v_device_vendors ";
$sql .= "where enabled = 'true' ";
$sql .= "order by name asc ";
$device_vendors = $database->select($sql, null, 'all');
unset($sql);
@@ -662,11 +671,11 @@
//add empty device setting row(s)
if (!is_uuid($device_uuid)) {
$rows = $_SESSION['devices']['setting_add_rows']['numeric'] ?? 1;
$rows = $settings->get('devices', 'key_add_rows', '10');
$id = 0;
}
else {
$rows = $_SESSION['devices']['setting_edit_rows']['numeric'] ?? 1;
$rows = $settings->get('devices', 'key_edit_rows', '3');
$id = count($device_settings) + 1;
}
for ($x = 0; $x < $rows; $x++) {
@@ -694,12 +703,7 @@
//get the first device line info (found on the local server) for the provision button
foreach ($device_lines as $row) {
if (
array_key_exists($row['domain_uuid'], $_SESSION['domains']) &&
$row['server_address'] == $_SESSION['domains'][$row['domain_uuid']]['domain_name'] &&
!empty($row['user_id']) &&
!empty($row['server_address'])
) {
if ($row['server_address'] == $row['domain_name'] && !empty($row['user_id']) && !empty($row['server_address'])) {
$user_id = $row['user_id'];
$server_address = $row['server_address'];
break;
@@ -731,14 +735,13 @@
echo " $('#target_file').fadeOut(fade_speed);\n";
echo " document.getElementById('target_file').selectedIndex = 0;\n";
echo " }\n";
echo " function download(d) {\n";
echo " if (d == '".$text['label-download']."') return;\n";
if ($_SESSION['provision']['http_domain_filter']['boolean'] == "false") {
$domain_name = $_SERVER["HTTP_HOST"];
if ($settings->get('provision', 'http_domain_filter', true)) {
$provision_domain_name = $domain_name;
}
else {
$domain_name = $_SESSION['domain_name'];
$provision_domain_name = $_SERVER["HTTP_HOST"];
}
if (!isset($_SERVER['HTTP_PROTOCOL'])) {
@@ -747,7 +750,7 @@
if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
}
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$domain_name.PROJECT_PATH."/app/provision/index.php?address=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$provision_domain_name.PROJECT_PATH."/app/provision/index.php?address=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
echo " }\n";
echo "\n";
@@ -793,16 +796,11 @@
//add the QR code
if (permission_exists("device_line_password") && !empty($device_template) && $qr_code_enabled) {
//set the mode
if (isset($_SESSION['theme']['qr_image'])) {
if (!empty($_SESSION['theme']['qr_image'])) {
$mode = '4';
}
else {
$mode = '0';
}
if (!empty($settings->get('theme', 'qr_image', ''))) {
$mode = '4';
}
else {
$mode = '4';
$mode = '0';
}
//get the device line settings
@@ -922,15 +920,10 @@
//build content for linphone
if ($device_template == "linphone/default") {
$auth_string = '';
if (
!empty($_SESSION['provision']['http_auth_enabled']['boolean']) &&
$_SESSION['provision']['http_auth_enabled']['boolean'] == 'true' &&
!empty($_SESSION['provision']['http_auth_username']['text']) &&
!empty($_SESSION['provision']['http_auth_password'][0])
) {
$auth_string = $_SESSION['provision']['http_auth_username']['text'].':'.$_SESSION['provision']['http_auth_password'][0].'@';
if ($settings->get('provision', 'http_auth_enabled', true) && !empty($settings->get('provision', 'http_auth_username', '')) && !empty($settings->get('provision', 'http_auth_password', ''))) {
$auth_string = $settings->get('provision', 'http_auth_username', '').':'.$settings->get('provision', 'http_auth_password', '').'@';
}
$content = "https://".$auth_string.$_SESSION['domain_name'].'/app/provision/index.php?address='.$device_address;
$content = "https://".$auth_string.$provision_domain_name.'/app/provision/index.php?address='.$device_address;
}
//stream the file
@@ -1001,16 +994,16 @@
echo " <img id='qr_code' src='data:image/jpeg;base64,".base64_encode($image)."'>\n";
echo "</div>\n";
}
/*
if (isset($_SESSION['theme']['qr_image'])) {
echo "<img id='img-buffer' src='".$_SESSION["theme"]["qr_image"]["text"]."' style='display: none;'>";
if (!empty($settings->get('theme', 'qr_image', ''))) {
echo "<img id='img-buffer' src='".$settings->get('theme', 'qr_image', '')."' style='display: none;'>";
}
else {
echo "<img id='img-buffer' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png' style='display: none;'>";
echo "<img id='img-buffer' src='".PROJECT_PATH."/themes/".$settings->get('domain', 'template', '')."/images/qr_code.png' style='display: none;'>";
}
*/
}
//show the content
@@ -1020,7 +1013,7 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-device']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'devices.php']);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back', ''),'id'=>'btn_back','link'=>'devices.php']);
if ($action == 'update') {
$button_margin = 'margin-left: 15px;';
if (permission_exists("device_line_password") && $qr_code_enabled) {
@@ -1038,7 +1031,7 @@
$template_dir = $prov->template_dir;
$files = glob($template_dir.'/'.$device_template.'/*');
//add file buttons and the file list
echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$_SESSION['theme']['button_icon_download'],'style'=>($button_margin ?? ''),'onclick'=>'show_files()']);
echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$settings->get('theme', 'button_icon_download', ''),'style'=>($button_margin ?? ''),'onclick'=>'show_files()']);
echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
echo " <option value=''>".$text['label-download']."</option>\n";
foreach ($files as $file) {
@@ -1054,7 +1047,7 @@
unset($button_margin);
}
if (permission_exists('device_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>($button_margin ?? ''),'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','new_address');"]);
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy', ''),'style'=>($button_margin ?? ''),'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','new_address');"]);
unset($button_margin);
}
if (
@@ -1063,11 +1056,11 @@
permission_exists('device_key_delete') ||
permission_exists('device_setting_delete')
) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'style'=>($button_margin ?? ''),'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete', ''),'style'=>($button_margin ?? ''),'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
unset($button_margin);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save', ''),'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
@@ -1289,11 +1282,11 @@
//set the defaults
if (!permission_exists('device_line_server_address')) {
if (empty($row['server_address'])) { $row['server_address'] = $_SESSION['domain_name']; }
if (empty($row['server_address'])) { $row['server_address'] = $domain_name; }
}
if (empty($row['sip_transport'])) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; }
if (!isset($row['sip_port'])) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
if (empty($row['register_expires'])) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; }
if (empty($row['sip_transport'])) { $row['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp'); }
if (!isset($row['sip_port'])) { $row['sip_port'] = $settings->get('provision', 'line_sip_port', '5060'); } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
if (empty($row['register_expires'])) { $row['register_expires'] = $settings->get('provision', 'line_register_expires', '120'); }
//add the primary key uuid
if (!empty($row['device_line_uuid']) && is_uuid($row['device_line_uuid'])) {
@@ -1323,10 +1316,10 @@
if (permission_exists('device_line_server_address_primary')) {
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
if (isset($_SESSION['provision']['server_address_primary']) && !isset($_SESSION['provision']['server_address_primary']['text'])) {
if (!empty($settings->get('provision', 'server_address_primary', '')) && is_array($settings->get('provision', 'server_address_primary', ''))) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_primary]'>\n";
echo " <option value=''></option>\n";
foreach($_SESSION['provision']['server_address_primary'] as $field) {
foreach($settings->get('provision', 'server_address_primary', '') as $field) {
echo " <option value='".$field."' ".(($row['server_address_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1339,10 +1332,10 @@
if (permission_exists('device_line_server_address_secondary')) {
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
if (isset($_SESSION['provision']['server_address_secondary']) && !isset($_SESSION['provision']['server_address_secondary']['text'])) {
if (!empty($settings->get('provision', 'server_address_secondary', '')) && is_array($settings->get('provision', 'server_address_secondary', ''))) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_secondary]'>\n";
echo " <option value=''></option>\n";
foreach($_SESSION['provision']['server_address_secondary'] as $field) {
foreach($settings->get('provision', 'server_address_secondary', '') as $field) {
echo " <option value='".$field."' ".(($row['server_address_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1355,10 +1348,10 @@
if (permission_exists('device_line_outbound_proxy_primary')) {
echo " <td align='left'>\n";
if (isset($_SESSION['provision']['outbound_proxy_primary']) && !isset($_SESSION['provision']['outbound_proxy_primary']['text'])) {
if (!empty($settings->get('provision', 'outbound_proxy_primary', ''))) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_primary]'>\n";
echo " <option value=''></option>\n";
foreach($_SESSION['provision']['outbound_proxy_primary'] as $field) {
foreach($settings->get('provision', 'outbound_proxy_primary', '') as $field) {
echo " <option value='".$field."' ".(($row['outbound_proxy_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1371,10 +1364,10 @@
if (permission_exists('device_line_outbound_proxy_secondary')) {
echo " <td align='left'>\n";
if (isset($_SESSION['provision']['outbound_proxy_secondary']) && !isset($_SESSION['provision']['outbound_proxy_secondary']['text'])) {
if (!empty($settings->get('provision', 'outbound_proxy_secondary', ''))) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_secondary]'>\n";
echo " <option value=''></option>\n";
foreach($_SESSION['provision']['outbound_proxy_secondary'] as $field) {
foreach($settings->get('provision', 'outbound_proxy_secondary', '') as $field) {
echo " <option value='".$field."' ".(($row['outbound_proxy_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1495,7 +1488,7 @@
foreach($device_profiles as $row) {
echo " <option value='".escape($row['device_profile_uuid'])."' ".(!empty($device_profile_uuid) && $row['device_profile_uuid'] == $device_profile_uuid ? "selected='selected'" : null).">".escape($row['device_profile_name'])." ".(($row['domain_uuid'] == '') ? "&nbsp;&nbsp;(".$text['select-global'].")" : null)."</option>\n";
}
echo " </select>\n";
echo " </select>\n";
}
else {
foreach($device_profiles as $row) {
@@ -1963,7 +1956,7 @@
else {
echo " <option value=''>".$text['select-global']."</option>\n";
}
foreach ($_SESSION['domains'] as $row) {
foreach ($domains as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
}
@@ -1978,7 +1971,7 @@
echo "</tr>\n";
}
else {
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$_SESSION['domain_uuid']."\"/>\n";
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$domain_uuid."\"/>\n";
}
if (permission_exists('device_enable')) {
@@ -1987,7 +1980,7 @@
echo " ".$text['label-device_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='device_enabled' name='device_enabled' value='true' ".($device_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
@@ -2054,4 +2047,3 @@
require_once "resources/footer.php";
?>
-1
View File
@@ -226,4 +226,3 @@
require_once "resources/footer.php";
?>
+2 -3
View File
@@ -44,7 +44,7 @@
//delete the device vendor function group
$array['device_vendor_function_groups'][0]['device_vendor_function_group_uuid'] = $device_vendor_function_group_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('device_vendor_function_group_delete', 'temp');
$database = new database;
@@ -183,7 +183,7 @@
$array['device_vendor_function_groups'][0]['group_name'] = $group_name;
$array['device_vendor_function_groups'][0]['group_uuid'] = $group_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('device_vendor_function_group_add', 'temp');
$database = new database;
@@ -403,4 +403,3 @@
require_once "resources/footer.php";
?>
+1 -2
View File
@@ -129,7 +129,7 @@
}
//assign temp permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_vendor_add', 'temp');
$p->add('device_vendor_function_add', 'temp');
$p->add('device_vendor_function_group_add', 'temp');
@@ -157,4 +157,3 @@
exit;
?>
+36 -61
View File
@@ -48,18 +48,6 @@
$database = database::new();
$settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]);
//set all permissions
$has_device_import = permission_exists('device_import');
$has_device_edit = permission_exists('device_edit');
$has_device_all = permission_exists('device_all');
$has_device_delete = permission_exists('device_delete');
$has_device_domain_all = permission_exists('device_domain_all');
$has_device_export = permission_exists('device_export');
$has_device_vendor_view = permission_exists('device_vendor_view');
$has_device_profile_view = permission_exists('device_profile_view');
$has_device_add = permission_exists('device_add');
$has_show_all = &$has_device_domain_all;
//add multi-lingual support
$language = new text;
$text = $language->get();
@@ -78,13 +66,13 @@
if (!empty($action) && !empty($devices) && is_array($devices) && @sizeof($devices) != 0) {
switch ($action) {
case 'toggle':
if ($has_device_edit) {
if (permission_exists('device_edit')) {
$obj = new device;
$obj->toggle($devices);
}
break;
case 'delete':
if ($has_device_delete) {
if (permission_exists('device_delete')) {
$obj = new device;
$obj->delete($devices);
}
@@ -105,7 +93,7 @@
//get total devices count from the database
$sql = "select count(*) from v_devices ";
$sql .= "where domain_uuid = :domain_uuid ";
if (!$has_device_all && !$has_device_domain_all) {
if (!permission_exists('device_all') && !permission_exists('device_domain_all')) {
$sql .= "and device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
@@ -113,23 +101,6 @@
$total_devices = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//update the has_device_add permission if the total device count is greater then set limit
$device_limit = $settings->get('limit', 'devices', null);
if ($has_device_add && $device_limit !== null) {
$has_device_add = $total_devices > $device_limit;
}
//get the domains if user has permission for show all
$domains = [];
if ($has_device_domain_all) {
$rows = $database->select("select domain_uuid, domain_name from v_domains where domain_enabled = 'true'");
if (!empty($rows)) {
foreach ($rows as $row) {
$domains[$row['domain_uuid']] = $row['domain_name'];
}
}
}
//get the devices profiles
$sql = "select * from v_device_profiles ";
$sql .= "where true ";
@@ -142,7 +113,7 @@
//prepare to page the results
$sql = "select count(*) from v_devices as d ";
if (isset($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (!empty($search)) {
$sql .= "where ";
}
@@ -150,7 +121,7 @@
else {
$sql .= "where (";
$sql .= " d.domain_uuid = :domain_uuid ";
if ($has_device_all) {
if (permission_exists('device_all')) {
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
@@ -205,7 +176,7 @@
$param = "&search=".$search;
$param .= "&fields=".$fields;
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$param .= "&show=all";
}
$page = $_GET['page'] ?? 0;
@@ -214,11 +185,15 @@
$offset = $rows_per_page * $page;
//get the list
$sql = "select d.*, d2.device_label as alternate_label, ";
$sql = "select ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= "d3.domain_name, ";
}
$sql .="d.*, d2.device_label as alternate_label, ";
$sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'DD Mon YYYY') as provisioned_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'HH12:MI:SS am') as provisioned_time_formatted \n";
$sql .= "from v_devices as d, v_devices as d2 ";
if (isset($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= ", v_domains as d3 ";
}
$sql .= "where ( ";
@@ -228,19 +203,19 @@
$sql .= " d.device_uuid = d2.device_uuid ";
$sql .= " ) ";
$sql .= ") ";
if (isset($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= " and d.domain_uuid = d3.domain_uuid ";
}
else {
$sql .= "and (";
$sql .= " d.domain_uuid = :domain_uuid ";
if ($has_device_all) {
if (permission_exists('device_all')) {
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
$parameters['domain_uuid'] = $domain_uuid;
}
if (!$has_device_all && !$has_device_domain_all) {
if (!permission_exists('device_all') && !permission_exists('device_domain_all')) {
$sql .= "and d.device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
@@ -314,33 +289,33 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-devices']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
if ($has_device_import) {
if (permission_exists('device_import')) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'link'=>'device_imports.php']);
}
if ($has_device_export) {
if (permission_exists('device_export')) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'link'=>'device_download.php']);
}
if ($has_device_vendor_view) {
if (permission_exists('device_vendor_view')) {
echo button::create(['type'=>'button','label'=>$text['button-vendors'],'icon'=>'fax','link'=>'device_vendors.php']);
}
if ($has_device_profile_view) {
if (permission_exists('device_profile_view')) {
echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','link'=>'device_profiles.php']);
}
$margin_left = $has_device_import || $has_device_export || $has_device_vendor_view || $has_device_profile_view ? "margin-left: 15px;" : null;
if ($has_device_add) {
$margin_left = permission_exists('device_import') || permission_exists('device_export') || permission_exists('device_vendor_view') || permission_exists('device_profile_view') ? "margin-left: 15px;" : null;
if (permission_exists('device_add') && (empty($_SESSION['limit']['devices']['numeric']) || ($total_devices < $_SESSION['limit']['devices']['numeric']))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'device_edit.php']);
unset($margin_left);
}
if ($has_device_edit && $devices) {
if (permission_exists('device_edit') && $devices) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none; '.($margin_left ?? null),'onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
unset($margin_left);
}
if ($has_device_delete && $devices) {
if (permission_exists('device_delete') && $devices) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; '.($margin_left ?? null),'onclick'=>"modal_open('modal-delete','btn_delete');"]);
unset($margin_left);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if ($has_device_all) {
if (permission_exists('device_all')) {
if (!empty($_GET['show']) && $_GET['show'] == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
@@ -369,10 +344,10 @@
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if ($has_device_edit && $devices) {
if (permission_exists('device_edit') && $devices) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if ($has_device_delete && $devices) {
if (permission_exists('device_delete') && $devices) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
@@ -387,12 +362,12 @@
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if ($has_device_edit || $has_device_delete) {
if (permission_exists('device_edit') || permission_exists('device_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($devices) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param);
}
echo th_order_by('device_address', $text['label-device_address'], $order_by, $order, null, null, $param ?? null);
@@ -406,7 +381,7 @@
echo th_order_by('device_enabled', $text['label-device_enabled'], $order_by, $order, null, "class='center'", $param ?? null);
echo th_order_by('device_provisioned_date', $text['label-device_status'], $order_by, $order, null, null, $param ?? null);
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order, null, "class='hide-sm-dn'", $param ?? null);
if ($has_device_edit && $settings->get('theme', 'list_row_edit_button', 'false') === 'true') {
if (permission_exists('device_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -422,7 +397,7 @@
}
}
if ($has_device_edit) {
if (permission_exists('device_edit')) {
$list_row_url = "device_edit.php?id=".urlencode($row['device_uuid']);
}
@@ -437,17 +412,17 @@
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if ($has_device_edit || $has_device_delete) {
if (permission_exists('device_edit') || permission_exists('device_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='devices[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='devices[$x][uuid]' value='".escape($row['device_uuid'])."' />\n";
echo " </td>\n";
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
echo " <td>".escape($domains[$row['domain_uuid']])."</td>\n";
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
echo " <td>".escape($row['domain_name'])."</td>\n";
}
echo " <td class='no-wrap'>";
echo $has_device_edit ? "<a href='".$list_row_url."'>".escape(format_device_address($row['device_address']))."</a>" : escape(format_device_address($row['device_address']));
echo permission_exists('device_edit') ? "<a href='".$list_row_url."'>".escape(format_device_address($row['device_address']))."</a>" : escape(format_device_address($row['device_address']));
echo " </td>\n";
echo " <td>".escape($row['device_label'])."&nbsp;</td>\n";
if ($device_alternate) {
@@ -463,7 +438,7 @@
echo " <td>".escape($row['device_vendor'])."&nbsp;</td>\n";
echo " <td>".escape($row['device_template'])."&nbsp;</td>\n";
echo " <td>".escape($device_profile_name)."&nbsp;</td>\n";
if ($has_device_edit) {
if (permission_exists('device_edit')) {
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['device_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
@@ -474,7 +449,7 @@
echo " </td>\n";
echo " <td class='no-link'><a title='".escape($row['device_provisioned_agent'])."' href='javascript:void(0)'>".escape($row['provisioned_date_formatted'])." ".escape($row['provisioned_time_formatted'])."</a> &nbsp; ".escape($device_provisioned_method)." &nbsp; <a href='".escape($device_provisioned_method)."://".escape($row['device_provisioned_ip'])."' target='_blank'>".escape($row['device_provisioned_ip'])."</a>&nbsp;</td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['device_description'])."&nbsp;</td>\n";
if ($has_device_edit && $settings->get('theme', 'list_row_edit_button', 'false') === 'true') {
if (permission_exists('device_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$settings->get('theme','button_icon_edit'),'link'=>$list_row_url]);
echo " </td>\n";
+6 -6
View File
@@ -512,7 +512,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_setting_delete', 'temp');
$p->add('device_line_delete', 'temp');
$p->add('device_key_delete', 'temp');
@@ -722,7 +722,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_vendor_function_delete', 'temp');
$p->add('device_vendor_function_group_delete', 'temp');
@@ -784,7 +784,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_vendor_function_group_delete', 'temp');
//execute delete
@@ -845,7 +845,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_profile_key_delete', 'temp');
$p->add('device_profile_setting_delete', 'temp');
@@ -1370,13 +1370,13 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_profile_key_add', 'temp');
$p->add('device_profile_setting_add', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->databasee->app_uuid = $this->app_uuid;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -77,4 +77,3 @@ $array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'admin';
$y++;
?>
@@ -259,7 +259,7 @@
}
if ($save) {
//add the temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('device_keys_add', 'temp');
$p->add('device_key_edit', 'temp');
@@ -402,7 +402,7 @@
//update the destination dialplan_uuid
if (is_uuid($destination_uuid)) {
$p = new permissions;
$p = permissions::new();
$p->add('destination_edit', 'temp');
$array['destinations'][0]['destination_uuid'] = $destination_uuid;
-2
View File
@@ -1648,5 +1648,3 @@ $text['description-accountcode']['ja-jp'] = "アカウントコードを入力
$text['description-accountcode']['ko-kr'] = "계정코드를 입력하세요.";
?>
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
Portions created by the Initial Developer are Copyright (C) 2008-2025
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -70,30 +70,37 @@
$toll_allow = $_POST["toll_allow"] ?? '';
$pin_numbers_enable = $_POST["pin_numbers_enabled"] ?? null;
if (empty($pin_numbers_enable)) { $pin_numbers_enable = "false"; }
//set the default type
$gateway_type = 'gateway';
$gateway_2_type = 'gateway';
$gateway_3_type = 'gateway';
//set the gateway type to bridge
if (strtolower(substr($gateway, 0, 6)) == "bridge") {
$gateway_type = 'bridge';
}
//set the type to enum
if (strtolower(substr($gateway, 0, 4)) == "enum") {
$gateway_type = 'enum';
}
//set the type to freetdm
if (strtolower(substr($gateway, 0, 7)) == "freetdm") {
$gateway_type = 'freetdm';
}
//set the type to transfer
if (strtolower(substr($gateway, 0, 8)) == "transfer") {
$gateway_type = 'transfer';
}
//set the type to dingaling
if (strtolower(substr($gateway, 0, 4)) == "xmpp") {
$gateway_type = 'xmpp';
}
//set the gateway_uuid and gateway_name
if ($gateway_type == "gateway") {
$gateway_array = explode(":",$gateway);
@@ -107,26 +114,32 @@
//set the gateway_2 variable
$gateway_2 = $_POST["gateway_2"];
//set the type to bridge
if (strtolower(substr($gateway_2, 0, 6)) == "bridge") {
$gateway_2_type = 'bridge';
}
//set type to enum
if (strtolower(substr($gateway_2, 0, 4)) == "enum") {
$gateway_2_type = 'enum';
}
//set the type to freetdm
if (strtolower(substr($gateway_2, 0, 7)) == "freetdm") {
$gateway_2_type = 'freetdm';
}
//set the type to transfer
if (strtolower(substr($gateway_2, 0, 8)) == "transfer") {
$gateway_type = 'transfer';
}
//set the type to dingaling
if (strtolower(substr($gateway_2, 0, 4)) == "xmpp") {
$gateway_2_type = 'xmpp';
}
//set the gateway_2_id and gateway_2_name
if ($gateway_2_type == "gateway" && !empty($_POST["gateway_2"])) {
$gateway_2_array = explode(":",$gateway_2);
@@ -140,26 +153,32 @@
//set the gateway_3 variable
$gateway_3 = $_POST["gateway_3"];
//set the type to bridge
if (strtolower(substr($gateway_3, 0, 6)) == "bridge") {
$gateway_3_type = 'bridge';
}
//set the type to enum
if (strtolower(substr($gateway_3, 0, 4)) == "enum") {
$gateway_3_type = 'enum';
}
//set the type to freetdm
if (strtolower(substr($gateway_3, 0, 7)) == "freetdm") {
$gateway_3_type = 'freetdm';
}
//set the type to dingaling
if (strtolower(substr($gateway_3, 0, 4)) == "xmpp") {
$gateway_3_type = 'xmpp';
}
//set the type to transfer
if (strtolower(substr($gateway_3, 0, 8)) == "transfer") {
$gateway_type = 'transfer';
}
//set the gateway_3_id and gateway_3_name
if ($gateway_3_type == "gateway" && !empty($_POST["gateway_3"])) {
$gateway_3_array = explode(":",$gateway_3);
@@ -170,6 +189,7 @@
$gateway_3_id = '';
$gateway_3_name = '';
}
//set additional variables
$dialplan_enabled = $_POST["dialplan_enabled"] ?? 'false';
$dialplan_description = $_POST["dialplan_description"];
@@ -318,7 +338,7 @@
$tmp_prefix == $dialplan_expression
? $outbound_prefix = ""
: $outbound_prefix = $tmp_prefix;
if ($gateway_type == "gateway") {
$dialplan_name = $gateway_name.".".$abbrv;
if ($abbrv == "988") {
@@ -815,7 +835,7 @@
}
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", "temp");
$p->add("dialplan_detail_add", "temp");
@@ -863,7 +883,7 @@
}
else {
$sql .= "and domain_uuid = :domain_uuid ";
}
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
@@ -881,6 +901,9 @@
unset($sql, $parameters);
}
//set defaults
if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
@@ -939,6 +962,7 @@ function type_onchange(dialplan_detail_type) {
echo $text['description-outbound-routes']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
@@ -1346,17 +1370,18 @@ function type_onchange(dialplan_detail_type) {
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br><br>";
echo "</table>\n";
echo "</div>\n";
echo "<br><br>\n";
if (!empty($action) && $action == "update") {
echo "<input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
echo "</form>\n";
//show the footer
require_once "resources/footer.php";
?>
?>
+1 -1
View File
@@ -170,7 +170,7 @@
$array['dialplan_details'][1]['dialplan_detail_data'] = 'WARNING [inbound routes] 404 not found \${sip_network_ip}';
$array['dialplan_details'][1]['dialplan_detail_order'] = '20';
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
$p->add('dialplan_detail_add', 'temp');
@@ -111,7 +111,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
//execute insert
@@ -144,7 +144,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//execute update
@@ -447,7 +447,7 @@
} //end foreach $xml_list
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
$p->add('dialplan_edit', 'temp');
$p->add('dialplan_detail_add', 'temp');
@@ -1007,7 +1007,7 @@
$array['dialplans'][$x]['dialplan_uuid'] = $key;
$array['dialplans'][$x]['dialplan_xml'] = $value;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//execute update
$database = new database;
@@ -1160,7 +1160,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -1264,7 +1264,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_detail_delete', 'temp');
//execute delete
@@ -1371,7 +1371,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//save the array
@@ -1525,7 +1525,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_detail_add', 'temp');
//save the array
+8 -8
View File
@@ -124,7 +124,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
//execute insert
@@ -156,7 +156,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//execute update
@@ -452,7 +452,7 @@
} //end foreach $xml_list
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_add', 'temp');
$p->add('dialplan_edit', 'temp');
$p->add('dialplan_detail_add', 'temp');
@@ -1065,7 +1065,7 @@
$array['dialplans'][$x]['dialplan_xml'] = $value;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//execute update
@@ -1188,7 +1188,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -1290,7 +1290,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_detail_delete', 'temp');
//execute delete
@@ -1395,7 +1395,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//save the array
@@ -1546,7 +1546,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_detail_add', 'temp');
//save the array
@@ -40,6 +40,18 @@
<condition field="${from_user_record}" expression="^local$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$"/>
<condition field="${call_direction}" expression="^inbound" break="never">
<action application="set" data="record_stereo_swap=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$"/>
<condition field="${call_direction}" expression="^outbound$" break="never">
<action application="set" data="record_stereo=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$"/>
<condition field="${call_direction}" expression="^local$" break="never">
<action application="set" data="record_stereo=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$">
<action application="set" data="record_path=${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}" inline="true" enabled="true"/>
<action application="set" data="record_name=${uuid}.${record_ext}" inline="true" enabled="true"/>
@@ -50,9 +62,8 @@
<action application="bind_digit_action" data="local,*6,api:uuid_record,${uuid} unmask ${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}/${uuid}.${record_ext},both,self" enabled="true"/>
<action application="set" data="record_append=true" inline="true" enabled="true"/>
<action application="set" data="record_in_progress=true" inline="true" enabled="true"/>
<action application="set" data="api_on_answer=uuid_record ${uuid} start ${record_path}/${record_name}" inline="false" enabled="false"/>
<action application="set" data="RECORD_ANSWER_REQ=true" enabled="true"/>
<action application="record_session" data="${record_path}/${record_name}" enabled="true"/>
<action application="set" data="api_on_answer=uuid_record ${uuid} start ${record_path}/${record_name}" inline="false" enabled="true"/>
<action application="set" data="record_answer_req=true" enabled="true"/>
<action application="record_session" data="${record_path}/${record_name}" enabled="false"/>
</condition>
</extension>
@@ -1,8 +1,17 @@
<extension name="valet_park" number="park+*5901-*5999" context="${domain_name}" continue="false" app_uuid="3cc8363d-5ce3-48aa-8ac1-143cf297c4f7" enabled="true" order="470">
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$" break="never"/>
<condition field="${sip_h_Referred-By}" expression="sip:(.*)@.*" break="never">
<condition field="${sip_refer_to}" expression="^.+$" break="never"/>
<condition field="${sip_refer_to}" expression="sip:(.*)@(.*?)(?::\d+)?\>" break="never">
<action application="set" data="referred_by_host=$2" inline="true"/>
</condition>
<condition field="${sip_h_Referred-By}" expression="sip:(.*)@(.*?)(?::\d+)?\>" break="never">
<action application="set" data="referred_by_user=$1" inline="true"/>
</condition>
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$" break="never"/>
<condition field="${referred_by_user}" expression="^.+$" break="never">
<action application="set" data="valet_context=${referred_by_host}" inline="true"/>
<anti-action application="set" data="valet_context=${domain_name}" inline="true"/>
</condition>
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$" break="never">
<action application="set" data="park_in_use=false" inline="true"/>
<action application="set" data="park_lot=$2" inline="true"/>
@@ -10,16 +19,16 @@
</condition>
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$"/>
<condition field="${referred_by_user}" expression="^.+$" break="never">
<action application="set" data="valet_info_park=${valet_info park@${domain_name}}|\*${park_lot}" inline="true"/>
<action application="set" data="park_in_use=${regex ${valet_info park@${domain_name}}|\*${park_lot}}" inline="true"/>
<action application="set" data="valet_info_park=${valet_info park@${valet_context}}|\*${park_lot}" inline="true"/>
<action application="set" data="park_in_use=${regex ${valet_info park@${valet_context}}|\*${park_lot}}" inline="true"/>
</condition>
<condition field="${park_in_use}" expression="true" break="never">
<action application="transfer" data="${referred_by_user} XML ${context}"/>
<action application="transfer" data="${referred_by_user} XML ${referred_by_host}"/>
<anti-action application="set" data="effective_caller_id_name=${cond ${regex ${direction} | inbound} == true ? 'park#${caller_id_name}' : 'park#${callee_id_name}'}" inline="true"/>
<anti-action application="set" data="valet_parking_timeout=900"/>
<anti-action application="set" data="valet_hold_music=${hold_music}"/>
<anti-action application="set" data="valet_parking_orbit_exten=${cond ${regex ${referred_by_user} | ^$} == true ? ${sip_from_user} : ${referred_by_user}}"/>
<anti-action application="answer" data=""/>
<anti-action application="valet_park" data="park@${domain_name} *${park_lot}"/>
<anti-action application="valet_park" data="park@${valet_context} *${park_lot}"/>
</condition>
</extension>
@@ -1,9 +1,9 @@
<extension name="operator" number="0" context="${domain_name}" continue="false" app_uuid="0e1cd2d7-9d84-4959-8b6c-0cb23de4de59" enabled="false" order="480">
<condition field="destination_number" expression="^0$|^operator$">
<action application="export" data="transfer_context={v_context}" enabled="true"/>
<action application="bind_meta_app" data="4 ab s execute_extension::att_xfer XML ${context}" enabled="false"/>
<action application="bind_meta_app" data="5 ab s execute_extension::xfer_vm XML ${context}" enabled="false"/>
<action application="set" data="domain_name={v_context}" enabled="true"/>
<action application="transfer" data="${operator} XML {v_context}" enabled="true"/>
<action application="export" data="transfer_context=${domain_name}" enabled="true"/>
<action application="bind_meta_app" data="4 ab s execute_extension::att_xfer XML ${domain_name}" enabled="false"/>
<action application="bind_meta_app" data="5 ab s execute_extension::xfer_vm XML ${domain_name}" enabled="false"/>
<action application="set" data="domain_name=${domain_name}" enabled="true"/>
<action application="transfer" data="${operator} XML ${domain_name}" enabled="true"/>
</condition>
</extension>
@@ -1,6 +1,6 @@
<extension name="operator-forward" number="*000" context="${domain_name}" continue="false" app_uuid="a90d3639-3b82-4905-a65d-85f58b6c4a19" enabled="true" order="485">
<condition field="destination_number" expression="^\*000$" >
<action application="set" data="dial_string=loopback/operator/${context}/XML" />
<action application="set" data="dial_string=loopback/operator/${domain_name}/XML" />
<action application="set" data="direction=both" />
<action application="set" data="extension=true" />
<action application="lua" data="dial_string.lua" />
-1
View File
@@ -414,4 +414,3 @@
require_once "resources/footer.php";
?>
@@ -138,9 +138,8 @@
//process the messages
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
$which_php = exec('which php');
foreach($email_queue as $row) {
$command = $which_php." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
@@ -148,7 +148,7 @@
//get the email settings
$retry_limit = $settings->get('email_queue', 'retry_limit');
$transcribe_enabled = $settings->get('transcribe', 'enabled');
$transcribe_enabled = $settings->get('transcribe', 'enabled', false);
$save_response = $settings->get('email_queue', 'save_response');
//set defaults
@@ -181,6 +181,9 @@
//$voicemail_description = $row["voicemail_description"];
//$voicemail_name_base64 = $row["voicemail_name_base64"];
//$voicemail_tutorial = $row["voicemail_tutorial"];
if (gettype($voicemail_transcription_enabled) === 'string') {
$voicemail_transcription_enabled = ($voicemail_transcription_enabled === 'true') ? true : false;
}
}
unset($parameters);
@@ -220,7 +223,7 @@
}
}
if (isset($transcribe_enabled) && $transcribe_enabled === 'true' && isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled === 'true') {
if ($transcribe_enabled && isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled) {
//debug message
echo "transcribe enabled: true\n";
@@ -440,7 +443,7 @@
$array['email_queue'][0]['email_status'] = 'sent';
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('email_queue_add', 'temp');
$p->add('email_queue_update', 'temp');
//execute insert
@@ -471,7 +474,7 @@
$array['email_queue'][0]['email_status'] = 'failed';
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('email_queue_add', 'temp');
//execute insert
@@ -525,7 +528,7 @@
$array['email_logs'][0]['status'] = 'failed';
$array['email_logs'][0]['email'] = str_replace("'", "''", $msg);
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('email_log_add', 'temp');
//execute insert
$database->app_name = 'v_mailto';
@@ -569,4 +572,3 @@
//fwrite($esl, $content);
//fclose($esl);
?>
@@ -141,7 +141,7 @@
$sql = "select * from v_email_queue ";
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
$sql .= "and hostname = :hostname ";
$sql .= "order by domain_uuid asc ";
$sql .= "order by domain_uuid, email_date desc ";
$sql .= "limit :limit ";
$parameters['hostname'] = $hostname;
$parameters['limit'] = $email_queue_limit;
@@ -152,7 +152,7 @@
//process the messages
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
foreach($email_queue as $row) {
$command = exec('which php')." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
+1 -1
View File
@@ -579,7 +579,7 @@
//add the missing email templates
if (!empty($array['email_templates'])) {
//add the temporary permission
$p = new permissions;
$p = permissions::new();
$p->add("email_template_add", 'temp');
$p->add("email_template_edit", 'temp');
+2 -2
View File
@@ -27,8 +27,8 @@ $text['title-emergency_logs']['zh-cn'] = "紧急日志";
$text['title-emergency_logs']['ja-jp'] = "緊急ログ";
$text['title-emergency_logs']['ko-kr'] = "비상 기록";
$text['title_description-emergency_logs']['en-us'] = "Track emergency calls includinng details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['en-gb'] = "Track emergency calls includinng details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['en-us'] = "Track emergency calls including details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['en-gb'] = "Track emergency calls including details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['ar-eg'] = "تتبع مكالمات الطوارئ بما في ذلك تفاصيل الوقت والتاريخ والامتداد الأصلي.";
$text['title_description-emergency_logs']['de-at'] = "Verfolgen Sie Notrufe mit Angaben zu Uhrzeit, Datum und Nebenstelle des Anrufers.";
$text['title_description-emergency_logs']['de-ch'] = "Verfolgen Sie Notrufe mit Angaben zu Uhrzeit, Datum und Nebenstelle des Anrufers.";
@@ -229,11 +229,11 @@
$x++;
}
if (is_array($array)) {
$p = new permissions;
$p = permissions::new();
$p->add('event_guard_log_edit', 'temp');
$database->app_name = 'event guard';
$database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
$database->save($array);
$database->save($array, false);
//$message = $database->message;
$p->delete('event_guard_log_edit', 'temp');
unset($array);
@@ -349,11 +349,11 @@
$array['event_guard_logs'][0]['extension'] = $event['to-user'].'@'.$event['to-host'];
$array['event_guard_logs'][0]['user_agent'] = $event['user-agent'];
$array['event_guard_logs'][0]['log_status'] = 'blocked';
$p = new permissions;
$p = permissions::new();
$p->add('event_guard_log_add', 'temp');
$database->app_name = 'event guard';
$database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
$database->save($array);
$database->save($array, false);
$p->delete('event_guard_log_add', 'temp');
//send debug information to the console
+384 -384
View File
@@ -1,384 +1,384 @@
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$extension_uuid = '';
$extension_setting_uuid = '';
$extension_setting_name = '';
$extension_setting_value = '';
$extension_setting_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$extension_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the extension id
if (!empty($_REQUEST["extension_setting_uuid"]) && is_uuid($_REQUEST["extension_setting_uuid"])) {
$extension_setting_uuid = $_REQUEST["extension_setting_uuid"];
}
if (!empty($_REQUEST["extension_uuid"]) && is_uuid($_REQUEST["extension_uuid"])) {
$extension_uuid = $_REQUEST["extension_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$domain_uuid = $_POST["domain_uuid"] ?? null;
$extension_setting_type = $_POST["extension_setting_type"];
$extension_setting_name = $_POST["extension_setting_name"];
$extension_setting_value = $_POST["extension_setting_value"];
$extension_setting_enabled = $_POST["extension_setting_enabled"] ?? 'false';
$extension_setting_description = $_POST["extension_setting_description"];
}
//process the user data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php?id='.$extension_uuid);
exit;
}
//process the http post data by submitted action
if (!empty($_POST['action'])) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('extension_setting_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) {
header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid);
exit;
}
}
//check for all required data
$msg = '';
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; }
if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; }
//if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; }
if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; }
//if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add the extension_setting_uuid
if (empty($extension_setting_uuid)) {
$extension_setting_uuid = uuid();
}
//prepare the array
$array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid;
$array['extension_settings'][0]['extension_uuid'] = $extension_uuid;
$array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//$array['extension_settings'][0]['domain_uuid'] = $domain_uuid;
$array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type;
$array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name;
$array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value;
$array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled;
$array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description;
//save the data
$database = new database;
$database->app_name = 'extension settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: extension_settings.php');
header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid);
return;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$sql = "select ";
//$sql .= "extension_uuid, ";
//$sql .= "domain_uuid, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_setting_uuid = :extension_setting_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_setting_uuid'] = $extension_setting_uuid ?? '';
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
if (!empty($row["extension_uuid"]) && is_uuid($row["extension_uuid"])) {
$extension_uuid = $row["extension_uuid"];
}
//$domain_uuid = $row["domain_uuid"];
$extension_setting_type = $row["extension_setting_type"];
$extension_setting_name = $row["extension_setting_name"];
$extension_setting_value = $row["extension_setting_value"];
$extension_setting_enabled = $row["extension_setting_enabled"];
$extension_setting_description = $row["extension_setting_description"];
}
unset($sql, $parameters, $row);
}
//set the defaults
if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-extension_setting'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_setting']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'extension_settings.php?id='.$extension_uuid]);
if ($action == 'update') {
if (permission_exists('_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('extension_setting_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('extension_setting_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-domain_uuid']."\n";
//echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <select class='formfld' name='domain_uuid'>\n";
//if (empty($domain_uuid)) {
// echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
//}
//else {
// echo " <option value=''>".$text['label-global']."</option>\n";
//}
//foreach ($_SESSION['domains'] as $row) {
// if ($row['domain_uuid'] == $domain_uuid) {
// echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
// }
// else {
// echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
// }
//}
//echo " </select>\n";
//echo "<br />\n";
//echo $text['description-domain_uuid']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_type']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_type'>\n";
echo " <option value=''></option>\n";
if (!empty($extension_setting_type) && $extension_setting_type == "param") {
echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n";
}
else {
echo " <option value='param'>".$text['label-param']."</option>\n";
}
if (!empty($extension_setting_type) && $extension_setting_type == "variable") {
echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n";
}
else {
echo " <option value='variable'>".$text['label-variable']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-extension_setting_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_value']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_value']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='extension_setting_enabled' name='extension_setting_enabled' value='true' ".($extension_setting_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='extension_setting_enabled' name='extension_setting_enabled'>\n";
echo " <option value='true' ".($extension_setting_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($extension_setting_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
echo $text['description-extension_setting_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$extension_uuid = '';
$extension_setting_uuid = '';
$extension_setting_name = '';
$extension_setting_value = '';
$extension_setting_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$extension_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the extension id
if (!empty($_REQUEST["extension_setting_uuid"]) && is_uuid($_REQUEST["extension_setting_uuid"])) {
$extension_setting_uuid = $_REQUEST["extension_setting_uuid"];
}
if (!empty($_REQUEST["extension_uuid"]) && is_uuid($_REQUEST["extension_uuid"])) {
$extension_uuid = $_REQUEST["extension_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$domain_uuid = $_POST["domain_uuid"] ?? null;
$extension_setting_type = $_POST["extension_setting_type"];
$extension_setting_name = $_POST["extension_setting_name"];
$extension_setting_value = $_POST["extension_setting_value"];
$extension_setting_enabled = $_POST["extension_setting_enabled"] ?? 'false';
$extension_setting_description = $_POST["extension_setting_description"];
}
//process the user data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php?id='.$extension_uuid);
exit;
}
//process the http post data by submitted action
if (!empty($_POST['action'])) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('extension_setting_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) {
header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid);
exit;
}
}
//check for all required data
$msg = '';
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; }
if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; }
//if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; }
if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; }
//if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add the extension_setting_uuid
if (empty($extension_setting_uuid)) {
$extension_setting_uuid = uuid();
}
//prepare the array
$array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid;
$array['extension_settings'][0]['extension_uuid'] = $extension_uuid;
$array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//$array['extension_settings'][0]['domain_uuid'] = $domain_uuid;
$array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type;
$array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name;
$array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value;
$array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled;
$array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description;
//save the data
$database = new database;
$database->app_name = 'extension settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: extension_settings.php');
header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid);
return;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$sql = "select ";
//$sql .= "extension_uuid, ";
//$sql .= "domain_uuid, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_setting_uuid = :extension_setting_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_setting_uuid'] = $extension_setting_uuid ?? '';
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
if (!empty($row["extension_uuid"]) && is_uuid($row["extension_uuid"])) {
$extension_uuid = $row["extension_uuid"];
}
//$domain_uuid = $row["domain_uuid"];
$extension_setting_type = $row["extension_setting_type"];
$extension_setting_name = $row["extension_setting_name"];
$extension_setting_value = $row["extension_setting_value"];
$extension_setting_enabled = $row["extension_setting_enabled"];
$extension_setting_description = $row["extension_setting_description"];
}
unset($sql, $parameters, $row);
}
//set the defaults
if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-extension_setting'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_setting']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'extension_settings.php?id='.$extension_uuid]);
if ($action == 'update') {
if (permission_exists('_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('extension_setting_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('extension_setting_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-domain_uuid']."\n";
//echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <select class='formfld' name='domain_uuid'>\n";
//if (empty($domain_uuid)) {
// echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
//}
//else {
// echo " <option value=''>".$text['label-global']."</option>\n";
//}
//foreach ($_SESSION['domains'] as $row) {
// if ($row['domain_uuid'] == $domain_uuid) {
// echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
// }
// else {
// echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
// }
//}
//echo " </select>\n";
//echo "<br />\n";
//echo $text['description-domain_uuid']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_type']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_type'>\n";
echo " <option value=''></option>\n";
if (!empty($extension_setting_type) && $extension_setting_type == "param") {
echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n";
}
else {
echo " <option value='param'>".$text['label-param']."</option>\n";
}
if (!empty($extension_setting_type) && $extension_setting_type == "variable") {
echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n";
}
else {
echo " <option value='variable'>".$text['label-variable']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-extension_setting_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_value']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_value']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='extension_setting_enabled' name='extension_setting_enabled' value='true' ".($extension_setting_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='extension_setting_enabled' name='extension_setting_enabled'>\n";
echo " <option value='true' ".($extension_setting_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($extension_setting_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
echo $text['description-extension_setting_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+334 -334
View File
@@ -1,334 +1,334 @@
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$search = '';
$paging_controls = '';
$id = '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the http post data
if (!empty($_POST['extension_settings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$extension_settings = $_POST['extension_settings'];
}
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$extension_uuid = $_REQUEST["id"];
}
//process the http post data by action
if (!empty($action) && !empty($extension_settings)) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php');
exit;
}
//prepare the database object
$obj = new extension_settings;
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj->copy($extension_settings);
}
break;
case 'toggle':
if (permission_exists('extension_setting_edit')) {
$obj->toggle($extension_settings);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj->extension_uuid = $extension_uuid;
$obj->delete($extension_settings);
}
break;
}
//redirect the user
header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the count
$sql = "select count(extension_setting_uuid) ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_uuid = :extension_uuid ";
if (isset($search)) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
else {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//get the list
$sql = "select ";
//$sql .= "d.domain_name, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings as e ";
//$sql .= ",v_domains as d ";
$sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) ";
//$sql .= "and d.domain_uuid = e.domain_uuid ";
if (isset($_GET["search"])) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'extension_setting_type', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$parameters['extension_uuid'] = $extension_uuid;
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$extension_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-extension_settings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_settings']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_add','name'=>'btn_add','style'=>'margin-right: 15px;','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]);
if (permission_exists('extension_setting_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]);
}
if (permission_exists('extension_setting_add') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
//if (permission_exists('extension_setting_all')) {
// if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n";
// }
// else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]);
// }
//}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'extension_settings.php?id='.$extension_uuid,'style'=>(empty($search) ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n";
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('extension_setting_add') && $extension_settings) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
if (!empty($extension_settings)) {
//define the variable
$previous_extension_setting_type = '';
//set the initial value
$x = 0;
//show the extension settings
foreach ($extension_settings as $row) {
$extension_setting_type = $row['extension_setting_type'];
$extension_setting_type = strtolower($extension_setting_type);
$label_extension_setting_type = $row['extension_setting_type'];
$label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type);
$label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type);
$label_extension_setting_type = ucwords($label_extension_setting_type);
if ($previous_extension_setting_type !== $row['extension_setting_type']) {
echo " <tr>";
echo " <td align='left' colspan='999'>&nbsp;</td>\n";
echo " </tr>";
echo " <tr>";
echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n";
echo " </tr>";
echo "<tr class='list-header'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n";
echo " </th>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//}
//echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order);
//echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order);
//echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order);
//echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'");
echo " <th>".$text['label-extension_setting_type']."</th>\n";
echo " <th>".$text['label-extension_setting_name']."</th>\n";
echo " <th>".$text['label-extension_setting_value']."</th>\n";
echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (permission_exists('extension_setting_edit')) {
$list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n";
echo " <input type='hidden' name='extension_settings[$x][uuid]' value='".escape($row['extension_setting_uuid'])."' />\n";
echo " </td>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo " <td>".escape($row['domain_name'])."</td>\n";
//}
echo " <td>".escape($row['extension_setting_type'])."</td>\n";
echo " <td>".escape($row['extension_setting_name'])."</td>\n";
echo " <td>".escape($row['extension_setting_value'])."</td>\n";
if (permission_exists('extension_setting_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['extension_setting_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
//set the previous category
$previous_extension_setting_type = $row['extension_setting_type'];
$x++;
}
unset($extension_settings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$search = '';
$paging_controls = '';
$id = '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the http post data
if (!empty($_POST['extension_settings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$extension_settings = $_POST['extension_settings'];
}
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$extension_uuid = $_REQUEST["id"];
}
//process the http post data by action
if (!empty($action) && !empty($extension_settings)) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php');
exit;
}
//prepare the database object
$obj = new extension_settings;
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj->copy($extension_settings);
}
break;
case 'toggle':
if (permission_exists('extension_setting_edit')) {
$obj->toggle($extension_settings);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj->extension_uuid = $extension_uuid;
$obj->delete($extension_settings);
}
break;
}
//redirect the user
header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the count
$sql = "select count(extension_setting_uuid) ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_uuid = :extension_uuid ";
if (isset($search)) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
else {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//get the list
$sql = "select ";
//$sql .= "d.domain_name, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings as e ";
//$sql .= ",v_domains as d ";
$sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) ";
//$sql .= "and d.domain_uuid = e.domain_uuid ";
if (isset($_GET["search"])) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'extension_setting_type', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$parameters['extension_uuid'] = $extension_uuid;
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$extension_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-extension_settings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_settings']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_add','name'=>'btn_add','style'=>'margin-right: 15px;','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]);
if (permission_exists('extension_setting_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]);
}
if (permission_exists('extension_setting_add') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
//if (permission_exists('extension_setting_all')) {
// if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n";
// }
// else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]);
// }
//}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'extension_settings.php?id='.$extension_uuid,'style'=>(empty($search) ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n";
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('extension_setting_add') && $extension_settings) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
if (!empty($extension_settings)) {
//define the variable
$previous_extension_setting_type = '';
//set the initial value
$x = 0;
//show the extension settings
foreach ($extension_settings as $row) {
$extension_setting_type = $row['extension_setting_type'];
$extension_setting_type = strtolower($extension_setting_type);
$label_extension_setting_type = $row['extension_setting_type'];
$label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type);
$label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type);
$label_extension_setting_type = ucwords($label_extension_setting_type);
if ($previous_extension_setting_type !== $row['extension_setting_type']) {
echo " <tr>";
echo " <td align='left' colspan='999'>&nbsp;</td>\n";
echo " </tr>";
echo " <tr>";
echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n";
echo " </tr>";
echo "<tr class='list-header'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n";
echo " </th>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//}
//echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order);
//echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order);
//echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order);
//echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'");
echo " <th>".$text['label-extension_setting_type']."</th>\n";
echo " <th>".$text['label-extension_setting_name']."</th>\n";
echo " <th>".$text['label-extension_setting_value']."</th>\n";
echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (permission_exists('extension_setting_edit')) {
$list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n";
echo " <input type='hidden' name='extension_settings[$x][uuid]' value='".escape($row['extension_setting_uuid'])."' />\n";
echo " </td>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo " <td>".escape($row['domain_name'])."</td>\n";
//}
echo " <td>".escape($row['extension_setting_type'])."</td>\n";
echo " <td>".escape($row['extension_setting_name'])."</td>\n";
echo " <td>".escape($row['extension_setting_value'])."</td>\n";
if (permission_exists('extension_setting_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['extension_setting_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
//set the previous category
$previous_extension_setting_type = $row['extension_setting_type'];
$x++;
}
unset($extension_settings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
+2 -2
View File
@@ -50,7 +50,7 @@
}
}
if (is_array($array) && @sizeof($array) != 0) {
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
$database->app_name = 'extensions';
@@ -69,7 +69,7 @@
$sql .= "where default_setting_category = 'security' ";
$sql .= "and default_setting_subcategory like 'password_%' ";
$p = new permissions;
$p = permissions::new();
$p->add('default_setting_edit', 'temp');
$database->execute($sql);
-1
View File
@@ -36,4 +36,3 @@
$y++;
?>
+19 -6
View File
@@ -39,7 +39,7 @@
}
//initialize the database object
$database = new database;
$database = database::new();
//add multi-lingual support
$language = new text;
@@ -261,7 +261,7 @@
$array['extension_users'][0]['user_uuid'] = $user_uuid;
//add temporary permission
$p = new permissions;
$p = permissions::new();
$p->add('extension_user_delete', 'temp');
//save the array
@@ -288,7 +288,7 @@
$array['device_lines'][0]['device_line_uuid'] = $device_line_uuid;
//add temporary permission
$p = new permissions;
$p = permissions::new();
$p->add('device_line_delete', 'temp');
//save the array
@@ -401,6 +401,19 @@
//extension exists
}
else {
//password permission not assigned get the password from the database
if ($action == "update" && !permission_exists('extension_password')) {
$sql = "select password from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['extension_uuid'] = $extension_uuid;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$password = $row["password"];
}
unset($sql, $parameters, $row);
}
//get the password length and strength
$password_length = $_SESSION["extension"]["password_length"]["numeric"];
@@ -658,9 +671,9 @@
$array["devices"][$j]["device_lines"][0]["auth_id"] = $extension;
$array["devices"][$j]["device_lines"][0]["password"] = $password;
$array["devices"][$j]["device_lines"][0]["line_number"] = is_numeric($line_numbers[$d]) ? $line_numbers[$d] : '1';
$array["devices"][$j]["device_lines"][0]["sip_port"] = $_SESSION['provision']['line_sip_port']['numeric'];
$array["devices"][$j]["device_lines"][0]["sip_port"] = $_SESSION['provision']['line_sip_port']['text'];
$array["devices"][$j]["device_lines"][0]["sip_transport"] = $_SESSION['provision']['line_sip_transport']['text'];
$array["devices"][$j]["device_lines"][0]["register_expires"] = $_SESSION['provision']['line_register_expires']['numeric'];
$array["devices"][$j]["device_lines"][0]["register_expires"] = $_SESSION['provision']['line_register_expires']['text'];
$array["devices"][$j]["device_lines"][0]["enabled"] = "true";
}
@@ -1766,7 +1779,7 @@
echo " ".$text['label-voicemail_mail_to']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='255' value=\"".escape($voicemail_mail_to ?? '')."\">\n";
echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='1024' value=\"".escape($voicemail_mail_to ?? '')."\">\n";
echo "<br />\n";
echo $text['description-voicemail_mail_to']."\n";
echo "</td>\n";
+464 -464
View File
@@ -1,464 +1,464 @@
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_import')) {
//access granted
}
else {
echo "access denied";
exit;
}
//initialize the database object
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fp = fopen("php://memory", 'r+');
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
fclose($fp);
return $data;
}
}
//get the http get values and set them as php variables
$action = $_POST["action"] ?? null;
$from_row = $_POST["from_row"] ?? null;
$delimiter = $_POST["data_delimiter"] ?? null;
$enclosure = $_POST["data_enclosure"] ?? null;
//save the data to the csv file
if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) {
if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file;
}
}
//get the schema
if (!empty($delimiter)) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
//get the schema
$x = 0;
include "app/extensions/app_config.php";
$i = 0;
foreach ($apps[0]['db'] as $table) {
//get the table name and parent name
$table_name = $table["table"]['name'];
$parent_name = $table["table"]['parent'];
//remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2);
}
if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2);
}
//filter for specific tables and build the schema array
if ($table_name == "extensions") {
$schema[$i]['table'] = $table_name;
$schema[$i]['parent'] = $parent_name;
foreach ($table['fields'] as $row) {
if (empty($row['deprecated']) || $row['deprecated'] !== 'true') {
if (is_array($row['name'])) {
$field_name = $row['name']['text'];
}
else {
$field_name = $row['name'];
}
$schema[$i]['fields'][] = $field_name;
}
}
$i++;
}
}
$i++;
$schema[$i]['table'] = 'extension_users';
$schema[$i]['parent'] = 'extensions';
$schema[$i]['fields'][] = 'username';
}
//match the column names to the field names
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extension_imports.php']);
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//loop through user columns
$x = 0;
foreach ($line_fields as $line_field) {
$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
echo "<tr>\n";
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n";
echo $line_field;
echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]'>\n";
echo " <option value=''></option>\n";
foreach($schema as $row) {
echo " <optgroup label='".$row['table']."'>\n";
if (!empty($row['fields'])) {
foreach($row['fields'] as $field) {
$selected = '';
if ($field == $line_field) {
$selected = "selected='selected'";
}
if ($field !== 'domain_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
}
}
}
echo " </optgroup>\n";
}
echo " </select>\n";
//echo "<br />\n";
//echo $text['description-zzz']."\n";
echo " </td>\n";
echo "</tr>\n";
$x++;
}
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input name='action' type='hidden' value='import'>\n";
echo "<input name='from_row' type='hidden' value='$from_row'>\n";
echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
require_once "resources/footer.php";
//normalize the column names
//$line = strtolower($line);
//$line = str_replace("-", "_", $line);
//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
//$line = str_replace("firstname", "name_given", $line);
//$line = str_replace("lastname", "name_family", $line);
//$line = str_replace("company", "organization", $line);
//$line = str_replace("company", "contact_email", $line);
//end the script
exit;
}
//get the parent table
function get_parent($schema,$table_name) {
foreach ($schema as $row) {
if ($row['table'] == $table_name) {
return $row['parent'];
}
}
}
//upload the csv
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//user selected fields
$fields = $_POST['fields'];
//set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
//get the users
$sql = "select * from v_users where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r");
if ($handle) {
//set the starting identifiers
$row_id = 0;
$row_number = 1;
//loop through the array
while (($line = fgets($handle, 4096)) !== false) {
if ($from_row <= $row_number) {
//format the data
$y = 0;
foreach ($fields as $key => $value) {
//get the line
$result = str_getcsv($line, $delimiter, $enclosure);
//get the table and field name
$field_array = explode(".",$value);
$table_name = $field_array[0];
$field_name = $field_array[1] ?? null;
//echo "value: $value<br />\n";
//echo "table_name: $table_name<br />\n";
//echo "field_name: $field_name<br />\n";
//get the parent table name
$parent = get_parent($schema, $table_name);
//remove formatting from the phone number
if ($field_name == "phone_number") {
$result[$key] = preg_replace('{\D}', '', $result[$key]);
}
//set various fields to lower case
if (in_array($field_name, array('enabled','directory_visible','directory_exten_visible','call_screen_enabled','user_record','do_not_disturb','forward_all_enabled','forward_busy_enabled','forward_no_answer_enabled','forward_user_not_registered_enabled'))) {
$result[$key] = strtolower($result[$key]);
}
//build the data array
if (!empty($table_name)) {
if (empty($parent)) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
}
elseif ($field_name != "username") {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
}
if ($field_name == "username") {
foreach ($users as $field) {
if ($field['username'] == $result[$key]) {
//$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid();
$array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid;
//$array[$parent][$row_id]['extension_users'] = $row['extension_uuid'];
$array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid'];
}
}
}
}
}
//process a chunk of the array
if ($row_id === 1000) {
//save to the data
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
//clear the array
unset($array);
//set the row id back to 0
$row_id = 0;
}
} //if ($from_row <= $row_number)
$row_number++;
$row_id++;
} //end while
fclose($handle);
//save to the data
if (!empty($array) && is_array($array)) {
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
unset($array);
}
//send the redirect header
header("Location: extensions.php");
exit;
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//show content
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extensions.php']);
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>".($data ?? null)."</textarea>\n";
echo "<br />\n";
echo $text['description-import_data']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-from_row']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='from_row'>\n";
$i=2;
while($i<=99) {
$selected = ($i == $from_row) ? "selected" : null;
echo " <option value='$i' ".$selected.">$i</option>\n";
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-from_row']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_delimiter']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
echo " <option value=','>,</option>\n";
echo " <option value='|'>|</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_delimiter']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_enclosure']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
echo " <option value='\"'>\"</option>\n";
echo " <option value=''></option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_enclosure']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br><br>";
echo "<input name='type' type='hidden' value='csv'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
<?php
/*
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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_import')) {
//access granted
}
else {
echo "access denied";
exit;
}
//initialize the database object
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fp = fopen("php://memory", 'r+');
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
fclose($fp);
return $data;
}
}
//get the http get values and set them as php variables
$action = $_POST["action"] ?? null;
$from_row = $_POST["from_row"] ?? null;
$delimiter = $_POST["data_delimiter"] ?? null;
$enclosure = $_POST["data_enclosure"] ?? null;
//save the data to the csv file
if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) {
if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file;
}
}
//get the schema
if (!empty($delimiter)) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
//get the schema
$x = 0;
include "app/extensions/app_config.php";
$i = 0;
foreach ($apps[0]['db'] as $table) {
//get the table name and parent name
$table_name = $table["table"]['name'];
$parent_name = $table["table"]['parent'];
//remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2);
}
if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2);
}
//filter for specific tables and build the schema array
if ($table_name == "extensions") {
$schema[$i]['table'] = $table_name;
$schema[$i]['parent'] = $parent_name;
foreach ($table['fields'] as $row) {
if (empty($row['deprecated']) || $row['deprecated'] !== 'true') {
if (is_array($row['name'])) {
$field_name = $row['name']['text'];
}
else {
$field_name = $row['name'];
}
$schema[$i]['fields'][] = $field_name;
}
}
$i++;
}
}
$i++;
$schema[$i]['table'] = 'extension_users';
$schema[$i]['parent'] = 'extensions';
$schema[$i]['fields'][] = 'username';
}
//match the column names to the field names
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extension_imports.php']);
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//loop through user columns
$x = 0;
foreach ($line_fields as $line_field) {
$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
echo "<tr>\n";
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n";
echo $line_field;
echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]'>\n";
echo " <option value=''></option>\n";
foreach($schema as $row) {
echo " <optgroup label='".$row['table']."'>\n";
if (!empty($row['fields'])) {
foreach($row['fields'] as $field) {
$selected = '';
if ($field == $line_field) {
$selected = "selected='selected'";
}
if ($field !== 'domain_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
}
}
}
echo " </optgroup>\n";
}
echo " </select>\n";
//echo "<br />\n";
//echo $text['description-zzz']."\n";
echo " </td>\n";
echo "</tr>\n";
$x++;
}
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input name='action' type='hidden' value='import'>\n";
echo "<input name='from_row' type='hidden' value='$from_row'>\n";
echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
require_once "resources/footer.php";
//normalize the column names
//$line = strtolower($line);
//$line = str_replace("-", "_", $line);
//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
//$line = str_replace("firstname", "name_given", $line);
//$line = str_replace("lastname", "name_family", $line);
//$line = str_replace("company", "organization", $line);
//$line = str_replace("company", "contact_email", $line);
//end the script
exit;
}
//get the parent table
function get_parent($schema,$table_name) {
foreach ($schema as $row) {
if ($row['table'] == $table_name) {
return $row['parent'];
}
}
}
//upload the csv
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//user selected fields
$fields = $_POST['fields'];
//set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
//get the users
$sql = "select * from v_users where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r");
if ($handle) {
//set the starting identifiers
$row_id = 0;
$row_number = 1;
//loop through the array
while (($line = fgets($handle, 4096)) !== false) {
if ($from_row <= $row_number) {
//format the data
$y = 0;
foreach ($fields as $key => $value) {
//get the line
$result = str_getcsv($line, $delimiter, $enclosure);
//get the table and field name
$field_array = explode(".",$value);
$table_name = $field_array[0];
$field_name = $field_array[1] ?? null;
//echo "value: $value<br />\n";
//echo "table_name: $table_name<br />\n";
//echo "field_name: $field_name<br />\n";
//get the parent table name
$parent = get_parent($schema, $table_name);
//remove formatting from the phone number
if ($field_name == "phone_number") {
$result[$key] = preg_replace('{\D}', '', $result[$key]);
}
//set various fields to lower case
if (in_array($field_name, array('enabled','directory_visible','directory_exten_visible','call_screen_enabled','user_record','do_not_disturb','forward_all_enabled','forward_busy_enabled','forward_no_answer_enabled','forward_user_not_registered_enabled'))) {
$result[$key] = strtolower($result[$key]);
}
//build the data array
if (!empty($table_name)) {
if (empty($parent)) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
}
elseif ($field_name != "username") {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
}
if ($field_name == "username") {
foreach ($users as $field) {
if ($field['username'] == $result[$key]) {
//$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid();
$array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid;
//$array[$parent][$row_id]['extension_users'] = $row['extension_uuid'];
$array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid'];
}
}
}
}
}
//process a chunk of the array
if ($row_id === 1000) {
//save to the data
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
//clear the array
unset($array);
//set the row id back to 0
$row_id = 0;
}
} //if ($from_row <= $row_number)
$row_number++;
$row_id++;
} //end while
fclose($handle);
//save to the data
if (!empty($array) && is_array($array)) {
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
unset($array);
}
//send the redirect header
header("Location: extensions.php");
exit;
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//show content
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extensions.php']);
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>".($data ?? null)."</textarea>\n";
echo "<br />\n";
echo $text['description-import_data']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-from_row']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='from_row'>\n";
$i=2;
while($i<=99) {
$selected = ($i == $from_row) ? "selected" : null;
echo " <option value='$i' ".$selected.">$i</option>\n";
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-from_row']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_delimiter']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
echo " <option value=','>,</option>\n";
echo " <option value='|'>|</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_delimiter']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_enclosure']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
echo " <option value='\"'>\"</option>\n";
echo " <option value=''></option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_enclosure']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br><br>";
echo "<input name='type' type='hidden' value='csv'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
@@ -153,7 +153,7 @@ if (!class_exists('extension')) {
//build update array
$array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('voicemail_edit', 'temp');
}
else {
@@ -161,7 +161,7 @@ if (!class_exists('extension')) {
$array['voicemails'][0]['voicemail_uuid'] = uuid();
$array['voicemails'][0]['domain_uuid'] = $this->domain_uuid;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('voicemail_add', 'temp');
}
if (is_array($array) && @sizeof($array) != 0) {
@@ -639,7 +639,7 @@ if (!class_exists('extension')) {
}
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_user_delete', 'temp');
$p->add('follow_me_delete', 'temp');
$p->add('follow_me_destination_delete', 'temp');
@@ -743,7 +743,7 @@ if (!class_exists('extension')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('extension_edit', 'temp');
//save the array
@@ -798,4 +798,3 @@ if (!class_exists('extension')) {
}
?>
@@ -89,7 +89,7 @@
$array_temp = $array;
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("extension_edit", "temp");
//save to the data
+1 -1
View File
@@ -202,7 +202,7 @@
//add the missing email templates
if (!empty($array['email_templates'])) {
//add the temporary permission
$p = new permissions;
$p = permissions::new();
$p->add("email_template_add", 'temp');
$p->add("email_template_edit", 'temp');
+1 -1
View File
@@ -135,7 +135,7 @@
//execute
if (isset($array) && is_array($array)) {
//assign temp permission
$p = new permissions;
$p = permissions::new();
$p->add('fax_add', 'temp');
$p->add('fax_edit', 'temp');
+1 -1
View File
@@ -107,7 +107,7 @@
$array['fax'][0]['fax_description'] = $fax_description;
//execute insert
$p = new permissions;
$p = permissions::new();
$p->add('fax_add', 'temp');
$database = new database;
+4 -4
View File
@@ -174,7 +174,7 @@
$array['fax_users'][0]['fax_uuid'] = $fax_uuid;
$array['fax_users'][0]['user_uuid'] = $user_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('fax_user_delete', 'temp');
$database = new database;
@@ -202,7 +202,7 @@
$array['fax_users'][0]['fax_uuid'] = $fax_uuid;
$array['fax_users'][0]['user_uuid'] = $user_uuid;
$p = new permissions;
$p = permissions::new();
$p->add('fax_user_add', 'temp');
$database = new database;
@@ -299,7 +299,7 @@
$array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
//assign temp permission
$p = new permissions;
$p = permissions::new();
$p->add('fax_add', 'temp');
//set the dialplan action
@@ -311,7 +311,7 @@
$array['fax'][0]['fax_uuid'] = $fax_uuid;
//assign temp permission
$p = new permissions;
$p = permissions::new();
$p->add('fax_edit', 'temp');
}
+1 -2
View File
@@ -266,8 +266,7 @@ if (!empty($result) && @sizeof($result) != 0) {
//send fax
$cwd = getcwd();
$included = true;
require("fax_send.php");
require "fax_send.php";
if($cwd){
chdir($cwd);
}
+1 -1
View File
@@ -518,7 +518,7 @@
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('fax_file_delete') || permission_exists['fax_file_edit']) {
if (permission_exists('fax_file_delete') || permission_exists('fax_file_edit')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='fax_files[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; } checkbox_on_change(this);\">\n";
echo " <input type='hidden' name='fax_files[$x][uuid]' value='".escape($row['fax_file_uuid'])."' />\n";
+26 -22
View File
@@ -28,14 +28,19 @@
Corey Moullas <cmoullas@emak.tech>
*/
//set included to boolean
if (!isset($included)) { $included = false; }
//check if windows
if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; }
//send email through browser
if (!$included) {
//executed via command line
if (defined('STDIN')) {
//add multi-lingual support
$language = new text;
$text = $language->get($setting->get('domain','language','en-us'), 'app/fax');
}
//executed via browser
else {
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
@@ -124,6 +129,7 @@ if (!$included) {
$fax_cover_font = $setting->get('fax','cover_font') ?? null;
}
//define function correct_path
if (!function_exists('correct_path')) {
function correct_path($p) {
global $IS_WINDOWS;
@@ -206,7 +212,7 @@ if (!function_exists('fax_split_dtmf')) {
//send the fax
$continue = false;
if (!$included) {
if (!defined('STDIN')) {
if (!empty($_POST['action']) && $_POST['action'] == "send" && $domain_enabled == true) {
//get the values from the HTTP POST
$fax_numbers = $_POST['fax_numbers'];
@@ -300,10 +306,10 @@ if (!function_exists('fax_split_dtmf')) {
//process uploaded or emailed files (if any)
$fax_page_count = 0;
$_files = (!$included) ? $_FILES['fax_files'] : $emailed_files;
$_files = (!defined('STDIN')) ? $_FILES['fax_files'] : $emailed_files;
unset($tif_files);
foreach ($_files['tmp_name'] as $index => $fax_tmp_name) {
$uploaded_file = (!$included) ? is_uploaded_file($fax_tmp_name) : true;
$uploaded_file = (!defined('STDIN')) ? is_uploaded_file($fax_tmp_name) : true;
if ( $uploaded_file && $_files['error'][$index] == 0 && $_files['size'][$index] > 0 ) {
//get the file extension
$fax_file_extension = strtolower(pathinfo($_files['name'][$index], PATHINFO_EXTENSION));
@@ -323,7 +329,7 @@ if (!function_exists('fax_split_dtmf')) {
}
unset($attachment_file_name);
if (!$included) {
if (!defined('STDIN')) {
//check if directory exists
if (!is_dir($dir_fax_temp)) {
mkdir($dir_fax_temp, 0770);
@@ -490,10 +496,9 @@ if (!function_exists('fax_split_dtmf')) {
//field values
$pdf->SetFont($pdf_font, "", 12);
$pdf->SetXY($x + 2.0, $y + 1.65);
if ($_REQUEST['submit'] != '' && $_REQUEST['submit'] != 'preview') {
$time_zone = isset($_SESSION['domain']['time_zone']['name']) ? $_SESSION['domain']['time_zone']['name'] : date_default_timezone_get();
$date = new DateTime('now', new DateTimeZone($time_zone) );
$pdf->Write(0.3, $date->format('d M Y'));
if (defined('STDIN') || ($_REQUEST['submit'] != '' && $_REQUEST['submit'] != 'preview')) {
$date = new DateTime('now', new DateTimeZone( $setting->get('domain','time_zone', date_default_timezone_get() ) ));
$pdf->Write(0.3, $date->format('d M Y @ h:i:s A'));
}
$pdf->SetXY($x + 2.0, $y + 1.95);
if ($fax_recipient != '') {
@@ -624,7 +629,7 @@ if (!function_exists('fax_split_dtmf')) {
@unlink($tif_file);
}
}
elseif (!$included) {
elseif (!defined('STDIN')) {
//nothing to send, redirect the browser
message::add($text['message-invalid-fax'], 'negative', 4000);
header("Location: fax_send.php?id=".$fax_uuid);
@@ -678,13 +683,10 @@ if (!function_exists('fax_split_dtmf')) {
unset($sql, $parameters, $row);
//for email to fax send email notification back to the email sender
if ($included) {
if (defined('STDIN')) {
//use email-to-fax from address
$mail_to_address = $sender_email;
}
else {
//send fax through the browser
}
//move the generated tif (and pdf) files to the sent directory
//if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".tif")) {
@@ -733,6 +735,8 @@ if (!function_exists('fax_split_dtmf')) {
if (!empty($provider_prefix)) {
$common_variables .= "provider_prefix='".$provider_prefix."',";
}
$common_variables .= "hangup_after_bridge=true,";
$common_variables .= "continue_on_fail=true,";
if (!empty($fax_numbers)) {
foreach ($fax_numbers as $fax_number) {
@@ -808,7 +812,7 @@ if (!function_exists('fax_split_dtmf')) {
$array['fax_queue'][0]['fax_command'] = 'originate '.$dial_string;
//add temporary permisison
$p = new permissions;
$p = permissions::new();
$p->add('fax_queue_add', 'temp');
//save the data
@@ -826,7 +830,7 @@ if (!function_exists('fax_split_dtmf')) {
}
//redirect the browser
if (!$included && is_uuid($fax_uuid)) {
if (!defined('STDIN') && is_uuid($fax_uuid)) {
header("Location: fax_files.php?id=".$fax_uuid."&box=sent");
//header("Location: fax_outbox.php?id=".$fax_uuid);
exit;
@@ -836,7 +840,7 @@ if (!function_exists('fax_split_dtmf')) {
//show content in the browser
if (!$included) {
if (!defined('STDIN')) {
//retrieve current user's assigned groups (uuids)
foreach ($_SESSION['groups'] as $group_data) {
@@ -861,7 +865,7 @@ if (!$included) {
$sql .= "and cp.phone_type_fax = 1 ";
$sql .= "and cp.phone_number is not null ";
$sql .= "and cp.phone_number <> '' ";
if ($setting->get('contact','permissions') == "true") {
if ($setting->get('contact','permissions', false)) {
if (is_array($user_group_uuids) && @sizeof($user_group_uuids) != 0) {
//only show contacts assigned to current user's group(s) and those not assigned to any group
$sql .= "and (";
+4 -4
View File
@@ -99,7 +99,7 @@ if (!class_exists('fax')) {
$array['dialplan_details'][0]['domain_uuid'] = $this->domain_uuid;
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('dialplan_detail_delete', 'temp');
//execute delete
@@ -166,7 +166,7 @@ if (!class_exists('fax')) {
$array['dialplans'][] = $dialplan;
//add the dialplan permission
$p = new permissions;
$p = permissions::new();
$p->add("dialplan_add", 'temp');
$p->add("dialplan_detail_add", 'temp');
$p->add("dialplan_edit", 'temp');
@@ -312,7 +312,7 @@ if (!class_exists('fax')) {
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('fax_delete', 'temp');
$p->add('fax_user_delete', 'temp');
$p->add('fax_file_delete', 'temp');
@@ -625,7 +625,7 @@ if (!class_exists('fax')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('fax_add', 'temp');
$p->add('dialplan_add', 'temp');
@@ -47,7 +47,11 @@ function parse_message_decode_text($connection, &$part, $message_number, $id, $o
}
}
if($charset){
$msg = mb_convert_encoding($msg, $to_charset, $charset);
if ($charset === 'windows-1256') {
$msg = iconv('windows-1256', 'utf-8', $msg);
} else {
$msg = mb_convert_encoding($msg, $to_charset, $charset);
}
}
$msg = trim($msg);
}
+8
View File
@@ -76,6 +76,14 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "30";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days to retain the fax queue logs in the database for the maintenance app.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "5506cf35-e19d-4f02-ab9d-43fd0f8460f7";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "fax_queue";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "prefer_local";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Determine whether fax calls should attempt to stay local or route to the provider.";
//$y++;
//$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "afd729d9-cf69-4793-a140-21093814d314";
//$apps[$x]['default_settings'][$y]['default_setting_category'] = "fax_queue";
+2 -2
View File
@@ -324,7 +324,7 @@
echo th_order_by('fax_retry_date', $text['label-fax_retry_date'], $order_by, $order);
echo th_order_by('fax_notify_date', $text['label-fax_notify_date'], $order_by, $order);
echo th_order_by('fax_retry_count', $text['label-fax_retry_count'], $order_by, $order);
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', 'false') == 'true') {
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -358,7 +358,7 @@
echo " <td>".escape($row['fax_retry_date_formatted'])." ".escape($row['fax_retry_time_formatted'])."</td>\n";
echo " <td>".escape($row['fax_notify_date_formatted'])." ".escape($row['fax_notify_time_formatted'])."</td>\n";
echo " <td>".escape($row['fax_retry_count'])."</td>\n";
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', 'false') == 'true') {
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon' => $settings->get('theme', 'button_icon_edit'),'link'=>$list_row_url]);
echo " </td>\n";
+1 -1
View File
@@ -151,7 +151,7 @@
//process the messages
if (is_array($fax_queue) && @sizeof($fax_queue) != 0) {
foreach($fax_queue as $row) {
$command = exec('which php')." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."&debug=true'";
if (isset($debug)) {
//run process inline to see debug info
+144 -63
View File
@@ -61,6 +61,9 @@
exit;
}
//connect to the database
$database = new database;
//shutdown call back function
function shutdown() {
//when the fax status is still sending
@@ -156,7 +159,6 @@
$sql .= "where fax_queue_uuid = :fax_queue_uuid ";
$sql .= "and q.domain_uuid = d.domain_uuid and f.fax_uuid = q.fax_uuid";
$parameters['fax_queue_uuid'] = $fax_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$fax_queue_uuid = $row['fax_queue_uuid'];
@@ -221,6 +223,23 @@
//sending the fax
if ($fax_status == 'waiting' || $fax_status == 'trying' || $fax_status == 'busy') {
//get the provider_prefix from the domain_variables dialplan
$sql = "select dialplan_detail_data from v_dialplan_details ";
$sql .= "where dialplan_uuid in ( ";
$sql .= " select dialplan_uuid from v_dialplans ";
$sql .= " where dialplan_name = 'domain-variables' ";
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= ") ";
$sql .= "and dialplan_detail_data like 'provider_prefix%' ";
$sql .= "and dialplan_detail_enabled = 'true' ";
$parameters['domain_uuid'] = $domain_uuid;
$row = $database->select($sql, $parameters, 'row');
$dialplan_detail_data = $row["dialplan_detail_data"];
unset($sql, $parameters, $row);
if (!empty($dialplan_detail_data)) {
$provider_prefix = explode('=', $dialplan_detail_data)[1];
}
//create event socket handle
$esl = event_socket::create();
if (!$esl->is_connected()) {
@@ -230,28 +249,70 @@
//fax options, first attempt use the fax variables from settings
if ($fax_retry_count == 0) {
$fax_options = '';
}
if ($fax_retry_count == 1) {
//use default settings or domain settings (defaults to t38)
$fax_options = '';
foreach($setting->get('fax','variable') as $variable) {
$fax_options .= $variable.",";
}
}
elseif ($fax_retry_count == 2) {
$fax_options = "fax_use_ecm=false,fax_enable_t38=true,fax_enable_t38_request=true";
}
elseif ($fax_retry_count == 3) {
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=false";
}
elseif ($fax_retry_count == 4) {
elseif ($fax_retry_count == 1) {
//send without t38 faster
$fax_options = "fax_use_ecm=true,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
}
elseif ($fax_retry_count == 2) {
//use t38 passthru
$fax_options = "fax_use_ecm=false,fax_enable_t38=true,t38_passthru=true";
}
elseif ($fax_retry_count == 3) {
//send without t38 slower
$fax_options = "fax_use_ecm=true,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=true";
}
elseif ($fax_retry_count == 4) {
//send with t38 no error correction
$fax_options = "fax_use_ecm=false,fax_enable_t38=true,fax_enable_t38_request=true";
}
elseif ($fax_retry_count == 5) {
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=true";
//send with t38 with error correction faster
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=false";
}
elseif ($fax_retry_count == 6) {
$fax_options = "fax_use_ecm=false,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
//send with t38 with error correction slower
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=true";
}
else {
//try the user definable method again
$fax_options = '';
foreach($setting->get('fax','variable') as $variable) {
$fax_options .= $variable.",";
}
}
//extract fax_dtmf from the fax number
fax_split_dtmf($fax_number, $fax_dtmf);
//get the fax toll allow
if (!empty($fax_toll_allow)) {
$channel_variables["toll_allow"] = $fax_toll_allow;
}
//check to see if the destination number is local
$local_destination = false;
if ($setting->get('fax_queue','prefer_local', false)) {
$sql = "select count(destination_uuid) ";
$sql .= "from v_destinations ";
$sql .= "where (";
$sql .= " destination_number = :destination_number ";
$sql .= " or concat(destination_prefix, destination_number) = :destination_number ";
$sql .= " or concat(destination_trunk_prefix, destination_number) = :destination_number ";
$sql .= " or concat(destination_area_code, destination_number) = :destination_number ";
$sql .= " or concat(destination_prefix, destination_area_code, destination_number) = :destination_number ";
$sql .= ") ";
$parameters['destination_number'] = $fax_number;
$destination_count = $database->select($sql, $parameters, 'column');
if ($destination_count > 0) {
$local_destination = true;
$route_array[] = 'loopback/'.$fax_number.'/public';
}
}
//define the fax file
@@ -262,34 +323,61 @@
$common_variables .= "domain_name=" . $domain_name . ",";
$common_variables .= "origination_caller_id_name='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "origination_caller_id_number=" . $fax_caller_id_number . ",";
$common_variables .= "fax_ident='" . escape_quote($fax_caller_id_number) . "',";
$common_variables .= "fax_header='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "fax_file='" . escape_quote($fax_file) . "',";
$common_variables .= "fax_ident='" . escape_quote($fax_caller_id_number) . "',";
$common_variables .= "fax_header='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "fax_file='" . escape_quote($fax_file) . "',";
$common_variables .= "hangup_after_bridge=true,";
$common_variables .= "continue_on_fail=true,";
//add the fax destination number variables
if ($local_destination) {
$common_variables .= "sip_to_user=".$fax_number.",";
$common_variables .= "sip_req_user=".$fax_number.",";
}
//extract fax_dtmf from the fax number
fax_split_dtmf($fax_number, $fax_dtmf);
//prepare the fax command
if (!empty($fax_toll_allow)) {
$channel_variables["toll_allow"] = $fax_toll_allow;
}
$channel_variables["toll_allow"] = !empty($fax_toll_allow) ? $fax_toll_allow : null;
$route_array = outbound_route_to_bridge($domain_uuid, $fax_prefix . $fax_number, $channel_variables);
if (count($route_array) == 0) {
//check for valid extension
$sql = "select count(extension_uuid) ";
$sql .= "from v_extensions ";
$sql .= "where extension = :fax_number ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_number'] = $fax_number;
$database = new database;
$extension_count = $database->select($sql, $parameters, 'column');
if ($extension_count > 0) {
//send the internal call to the registered extension
$route_array[] = "user/".$fax_number."@".$domain_name;
if (empty($route_array)) {
//send the internal call to the registered extension
if (count($route_array) == 0) {
//check for valid extension
$sql = "select count(extension_uuid) ";
$sql .= "from v_extensions ";
$sql .= "where extension = :fax_number ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_number'] = $fax_number;
$extension_count = $database->select($sql, $parameters, 'column');
if ($extension_count > 0) {
//send the internal call to the registered extension
$fax_uri = "user/".$fax_number."@".$domain_name;
}
else {
$fax_uri = '';
$fax_status = 'failed';
}
}
else {
$fax_status = 'failed';
}
else {
foreach($route_array as $key => $bridge) {
//add the bridge to the fax_uri, after first iteration add the delimiter
if ($key == 0) {
$fax_uri = $bridge;
}
else {
$fax_uri .= '|'.$bridge;
}
//add the provider_prefix
if (!empty($provider_prefix)) {
$fax_uri = preg_replace('/\${provider_prefix}/', $provider_prefix, $fax_uri);
}
//remove switch ${variables} from the bridge statement
$fax_uri = preg_replace('/\${[^}]+}/', '', $fax_uri);
}
}
@@ -299,13 +387,13 @@
//build a list of fax variables
$dial_string = $common_variables;
$dial_string .= $fax_options.",";
$dial_string .= "origination_uuid=" . $origination_uuid. ",";
$dial_string .= "fax_uuid=" . $fax_uuid. ",";
$dial_string .= "fax_queue_uuid=" . $fax_queue_uuid. ",";
$dial_string .= "mailto_address='" . $fax_email_address . "',";
$dial_string .= "origination_uuid=" . $origination_uuid . ",";
$dial_string .= "fax_uuid=" . $fax_uuid . ",";
$dial_string .= "fax_queue_uuid=" . $fax_queue_uuid . ",";
$dial_string .= "mailto_address='" . $fax_email_address . "',";
$dial_string .= "mailfrom_address='" . $email_from_address . "',";
$dial_string .= "fax_retry_attempts=" . $fax_retry_count . ",";
$dial_string .= "fax_retry_limit=" . $retry_limit . ",";
$dial_string .= "fax_retry_attempts=" . $fax_retry_count . ",";
$dial_string .= "fax_retry_limit=" . $retry_limit . ",";
//$dial_string .= "fax_retry_sleep=180,";
$dial_string .= "fax_verbose=true,";
//$dial_string .= "fax_use_ecm=off,";
@@ -315,21 +403,18 @@
//connect to event socket and send the command
if ($fax_status != 'failed' && file_exists($fax_file)) {
//send the fax and try another route if the fax fails
foreach($route_array as $route) {
$fax_command = "originate {" . $dial_string . ",fax_uri=".$route."}" . $route." &txfax('".$fax_file."')";
$fax_response = event_socket::api($fax_command);
$response = str_replace("\n", "", $fax_response);
$response = trim(str_replace("+OK", "", $response));
if (is_uuid($response)) {
//originate command accepted
$uuid = $response;
echo "uuid: ".$uuid."\n";
break;
}
else {
//originate command failed (-ERR INVALID_GATEWAY or other errors)
echo "response: ".$response."\n";
}
$fax_command = "originate {" . $dial_string . ",fax_uri=".$fax_uri."}" . $fax_uri." &txfax('".$fax_file."')";
$fax_response = event_socket::api($fax_command);
$response = str_replace("\n", "", $fax_response);
$response = trim(str_replace("+OK", "", $response));
if (is_uuid($response)) {
//originate command accepted
$uuid = $response;
echo "uuid: ".$uuid."\n";
}
else {
//originate command failed (-ERR INVALID_GATEWAY or other errors)
echo "response: ".$response."\n";
}
//set the fax file name without the extension
@@ -351,11 +436,10 @@
$array['fax_queue'][0]['fax_response'] = $fax_response;
//add temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('fax_queue_edit', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array, false);
@@ -399,7 +483,6 @@
$parameters['template_language'] = $language_code;
$parameters['template_category'] = 'fax';
$parameters['template_type'] = 'html';
$database = new database;
$fax_templates = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
}
@@ -451,7 +534,6 @@
$sql .= "from v_fax_logs ";
$sql .= "where fax_log_uuid = :fax_log_uuid ";
$parameters['fax_log_uuid'] = $fax_log_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$fax_success = $row['fax_success'];
@@ -569,11 +651,10 @@
$array['fax_queue'][0]['fax_notify_date'] = 'now()';
//add temporary permissions
$p = new permissions;
$p = permissions::new();
$p->add('fax_queue_edit', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array, false);
@@ -181,7 +181,7 @@
//process the messages
if (is_array($fax_queue) && @sizeof($fax_queue) != 0) {
foreach($fax_queue as $row) {
$command = exec('which php')." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
+21
View File
@@ -30,6 +30,23 @@
$apps[$x]['description']['sv-se'] = "";
$apps[$x]['description']['uk-ua'] = "";
//destination details
$y=0;
$apps[$x]['destinations'][$y]['type'] = "sql";
$apps[$x]['destinations'][$y]['label'] = "fifo";
$apps[$x]['destinations'][$y]['name'] = "fifo";
$apps[$x]['destinations'][$y]['sql'] = "select fifo_uuid as uuid, fifo_name as name, fifo_extension as extension, fifo_enabled from v_fifo ";
$apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and fifo_enabled = 'true' ";
$apps[$x]['destinations'][$y]['order_by'] = "natural_sort(fifo_extension) asc";
$apps[$x]['destinations'][$y]['field']['uuid'] = "uuid";
$apps[$x]['destinations'][$y]['field']['name'] = "name";
$apps[$x]['destinations'][$y]['field']['extension'] = "extension";
//$apps[$x]['destinations'][$y]['field']['context'] = "context";
$apps[$x]['destinations'][$y]['select_value']['dialplan'] = "transfer:\${extension} XML \${context}";
$apps[$x]['destinations'][$y]['select_value']['ivr'] = "menu-exec-app:transfer \${extension} XML \${context}";
$apps[$x]['destinations'][$y]['select_label'] = "\${extension} \${name}";
$y++;
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = 'fifo_view';
@@ -70,6 +87,10 @@
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_destinations';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
//queues
$y=0;
+27 -1
View File
@@ -135,6 +135,33 @@ $text['description-fifo_name']['zh-cn'] = "队列将被分配的名称。";
$text['description-fifo_name']['ja-jp'] = "キューに割り当てられる名前。";
$text['description-fifo_name']['ko-kr'] = "대기열에 할당될 이름입니다.";
$text['label-fifo']['en-us'] = "Queues";
$text['label-fifo']['en-gb'] = "Queues";
$text['label-fifo']['ar-eg'] = "الاستفسارات";
$text['label-fifo']['de-at'] = "Warteschlangen";
$text['label-fifo']['de-ch'] = "Warteschlangen";
$text['label-fifo']['de-de'] = "Warteschlangen";
$text['label-fifo']['el-gr'] = "Ουρές";
$text['label-fifo']['es-cl'] = "Colas";
$text['label-fifo']['es-mx'] = "Colas";
$text['label-fifo']['fr-ca'] = "Files d'attente";
$text['label-fifo']['fr-fr'] = "Files d'attente";
$text['label-fifo']['he-il'] = "תורים";
$text['label-fifo']['it-it'] = "Code";
$text['label-fifo']['ka-ge'] = "რიგები";
$text['label-fifo']['nl-nl'] = "Wachtrijen";
$text['label-fifo']['pl-pl'] = "Kolejki";
$text['label-fifo']['pt-br'] = "Filas";
$text['label-fifo']['pt-pt'] = "Filas";
$text['label-fifo']['ro-ro'] = "Cozi";
$text['label-fifo']['ru-ru'] = "Очереди";
$text['label-fifo']['sv-se'] = "Kö:er";
$text['label-fifo']['uk-ua'] = "Клей";
$text['label-fifo']['tr-tr'] = "Kuyruklar";
$text['label-fifo']['zh-cn'] = "尾巴";
$text['label-fifo']['ja-jp'] = "テイルス";
$text['label-fifo']['ko-kr'] = "꼬리";
$text['label-fifo_extension']['en-us'] = "Extension";
$text['label-fifo_extension']['en-gb'] = "Extension";
$text['label-fifo_extension']['ar-eg'] = "امتداد";
@@ -810,4 +837,3 @@ $text['label-member_enabled']['ja-jp'] = "有効";
$text['label-member_enabled']['ko-kr'] = "활성화됨";
?>

Some files were not shown because too many files have changed in this diff Show More