update template to match new boolean in settings (#7168)

* update template to match new boolean in settings

* Update email.php
This commit is contained in:
frytimo 2024-10-23 15:14:54 -03:00 committed by GitHub
parent e54d10a4e9
commit ae2679e97c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 63 additions and 43 deletions

View File

@ -861,7 +861,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 (";

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";

View File

@ -97,7 +97,7 @@ if (!class_exists('xml_cdr')) {
public function log($message) {
//save the log if enabled is true
if ($this->setting->get('log', 'enabled') == 'true') {
if ($this->setting->get('log', 'enabled', false)) {
//save the log to the php error log
if ($this->setting->get('log', 'type') == 'error_log') {
@ -999,7 +999,7 @@ if (!class_exists('xml_cdr')) {
}
//save the call log to the database
if ($this->setting->get('cdr', 'call_log_enabled') == 'true' && !empty($this->setting->get('switch', 'log')) && $this->setting->get('cdr', 'storage') == "db") {
if ($this->setting->get('cdr', 'call_log_enabled', false) && !empty($this->setting->get('switch', 'log')) && $this->setting->get('cdr', 'storage') == "db") {
//get the log content
$log_content = '';
$handle = @fopen($this->setting->get('switch', 'log').'/freeswitch.log', "r");
@ -1525,7 +1525,7 @@ if (!class_exists('xml_cdr')) {
//authentication for xml cdr http post
if (!defined('STDIN')) {
if ($this->setting->get('cdr', 'http_enabled') == "true") {
if ($this->setting->get('cdr', 'http_enabled')) {
//get the contents of xml_cdr.conf.xml
$conf_xml_string = file_get_contents($this->setting->get('switch', 'conf').'/autoload_configs/xml_cdr.conf.xml');
@ -1569,7 +1569,7 @@ if (!class_exists('xml_cdr')) {
//check for the correct username and password
if (!defined('STDIN')) {
if ($this->setting->get('cdr', 'http_enabled') == "true") {
if ($this->setting->get('cdr', 'http_enabled', true)) {
if ($auth_array[0] == $_SERVER["PHP_AUTH_USER"] && $auth_array[1] == $_SERVER["PHP_AUTH_PW"]) {
//echo "access granted\n";
$this->username = $auth_array[0];

View File

@ -45,10 +45,10 @@ if (!class_exists('email')) {
public $subject;
public $body;
public $from_address;
public $from_name;
public $from_name;
public $priority;
public $debug_level;
public $attachments;
public $debug_level;
public $attachments;
public $read_confirmation;
public $error;
public $response;
@ -56,7 +56,7 @@ if (!class_exists('email')) {
/**
* called when the object is created
*/
public function __construct() {
public function __construct($params = []) {
//assign the variables
$this->app_name = 'email';
$this->name = 'email';
@ -64,6 +64,29 @@ if (!class_exists('email')) {
$this->priority = 0;
$this->debug_level = 3;
$this->read_confirmation = false;
//set the domain_uuid
$this->domain_uuid = $params['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
if (isset($params['settings'])) {
$this->settings = $params['settings'];
}
//set the database from the settings object if available
if ($this->settings instanceof settings && !isset($this->database)) {
$this->database = $this->settings->database();
}
//ensure we have a valid database object
if (!($this->database instanceof database)) {
$this->database = $params['database'] ?? database::new();
}
//ensure we have a valid settings object
if (!($this->settings) instanceof settings) {
$this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid]);
}
}
/**
@ -126,7 +149,7 @@ if (!class_exists('email')) {
if (substr($body_content_type, 0, 9) == "text/html") {
$this->body = $row["Body"];
}
if (substr($body_content_type, 0, 10) == "text/plain") {
if (substr($body_content_type, 0, 10) == "text/plain") {
$body_plain = $row["Body"];
$this->body = $body_plain;
}
@ -156,7 +179,7 @@ if (!class_exists('email')) {
//testfax.tif
$file = $parts_array["FileName"];
//inline
//inline
$filedisposition = $parts_array["FileDisposition"];
$body_part = $parts_array["BodyPart"];
@ -193,7 +216,7 @@ if (!class_exists('email')) {
$this->attachments[$x]['type'] = 'string';
$this->attachments[$x]['name'] = $file;
$this->attachments[$x]['value'] = $parts_array["Body"];
//increment the id
$x++;
}
@ -207,17 +230,9 @@ if (!class_exists('email')) {
*/
public function send() {
//set the domain_uuid if not set
if (!isset($this->domain_uuid) && isset($_SESSION)) {
$this->domain_uuid = $_SESSION['domain_uuid'];
}
//get the email queue settings
$setting = new settings(["domain_uuid" => $this->domain_uuid]);
//set the send_method if not already set
if (!isset($this->method)) {
if ($setting->get('email_queue','enabled') == 'true') {
if ($setting->get('email_queue','enabled', true)) {
$this->method = 'queue';
}
else {
@ -324,17 +339,23 @@ if (!class_exists('email')) {
$p->add("email_queue_attachment_add", 'temp');
//save the dialplan
$database = new database;
$database->app_name = 'email';
$database->app_uuid = 'e24b5dab-3bcc-42e8-99c1-19b0c558c2d7';
$database->save($array);
//$dialplan_response = $database->message;
$this->database->app_name = 'email';
$this->database->app_uuid = 'e24b5dab-3bcc-42e8-99c1-19b0c558c2d7';
$this->database->save($array);
//$dialplan_response = $this->database->message;
unset($array);
//remove temporary permissions
$p->delete("dialplan_add", 'temp');
$p->delete("dialplan_detail_add", 'temp');
//return a human readable response for debugging
if ($this->database->message['message'] == 'OK') {
return "Added to queue";
} else {
//return the SQL server message
return $this->database->message['message'];
}
}
//send the email directly
@ -407,24 +428,24 @@ if (!class_exists('email')) {
include_once("resources/phpmailer/class.smtp.php");
//use the email default settings
if (!empty($setting->get('email','smtp_hostname'))) {
$smtp['hostname'] = $setting->get('email','smtp_hostname');
if (!empty($this->settings->get('email','smtp_hostname'))) {
$smtp['hostname'] = $this->settings->get('email','smtp_hostname');
}
$smtp['host'] = (!empty($setting->get('email','smtp_host')) ? $setting->get('email','smtp_host'): '127.0.0.1');
if (!empty($setting->get('email','smtp_port'))) {
$smtp['port'] = (int)$setting->get('email','smtp_port');
$smtp['host'] = (!empty($this->settings->get('email','smtp_host')) ? $this->settings->get('email','smtp_host'): '127.0.0.1');
if (!empty($this->settings->get('email','smtp_port'))) {
$smtp['port'] = (int)$this->settings->get('email','smtp_port');
}
else {
$smtp['port'] = 0;
}
$smtp['secure'] = $setting->get('email','smtp_secure');
$smtp['auth'] = $setting->get('email','smtp_auth');
$smtp['username'] = $setting->get('email','smtp_username');
$smtp['password'] = $setting->get('email','smtp_password');
$smtp['from'] = $setting->get('voicemail','smtp_from') ?? $setting->get('email','smtp_from');
$smtp['from_name'] = $setting->get('voicemail','smtp_from_name') ?? $setting->get('email','smtp_from_name');
$smtp['validate_certificate'] = $setting->get('email','smtp_validate_certificate');
$smtp['crypto_method'] = $setting->get('email','smtp_crypto_method') ?? null;
$smtp['secure'] = $this->settings->get('email','smtp_secure');
$smtp['auth'] = $this->settings->get('email','smtp_auth');
$smtp['username'] = $this->settings->get('email','smtp_username');
$smtp['password'] = $this->settings->get('email','smtp_password');
$smtp['from'] = $this->settings->get('voicemail','smtp_from') ?? $this->settings->get('email','smtp_from');
$smtp['from_name'] = $this->settings->get('voicemail','smtp_from_name') ?? $this->settings->get('email','smtp_from_name');
$smtp['validate_certificate'] = $this->settings->get('email','smtp_validate_certificate');
$smtp['crypto_method'] = $this->settings->get('email','smtp_crypto_method') ?? null;
//override the domain-specific smtp server settings, if any
$sql = "select domain_setting_subcategory, domain_setting_value ";
@ -433,8 +454,7 @@ if (!class_exists('email')) {
$sql .= "and (domain_setting_category = 'email' or domain_setting_category = 'voicemail') ";
$sql .= "and domain_setting_enabled = 'true' ";
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$result = $this->database->select($sql, $parameters, 'all');
if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($row['domain_setting_value'] != '') {