Added checkboxes to notifications global configuration

Former-commit-id: 79df159f003292dfef697773fe8daa25b77f04c2
This commit is contained in:
fermin831 2019-01-31 19:43:13 +01:00
parent 01bc0775bc
commit 75eaa875c9
2 changed files with 19 additions and 3 deletions

View File

@ -32,10 +32,14 @@ if (get_parameter('update_config', 0)) {
$id = notifications_desc_to_id($source['description']); $id = notifications_desc_to_id($source['description']);
if (empty($id)) return false; if (empty($id)) return false;
$enable_value = switch_to_int(get_parameter("enable-$id")); $enable_value = switch_to_int(get_parameter("enable-$id"));
$mail_value = (int)get_parameter("mail-{$id}", 0);
$user_value = (int)get_parameter("user-{$id}", 0);
$res = mysql_db_process_sql_update( $res = mysql_db_process_sql_update(
'tnotification_source', 'tnotification_source',
array( array(
'enabled' => $enable_value), 'enabled' => $enable_value,
'user_editable' => $user_value,
'also_mail' => $mail_value),
array('id' => $source['id']) array('id' => $source['id'])
); );
return $res && $carry; return $res && $carry;

View File

@ -192,8 +192,9 @@ function notifications_print_ball() {
function notifications_print_global_source_configuration($source) { function notifications_print_global_source_configuration($source) {
// Get some values to generate the title // Get some values to generate the title
$id = notifications_desc_to_id($source['description']);
$switch_values = array ( $switch_values = array (
'name' => "enable-" . notifications_desc_to_id($source['description']), 'name' => "enable-" . $id,
'value' => $source['enabled'] 'value' => $source['enabled']
); );
// Generate the title // Generate the title
@ -202,6 +203,17 @@ function notifications_print_global_source_configuration($source) {
$html_title .= "<h2>{$source['description']}</h2>"; $html_title .= "<h2>{$source['description']}</h2>";
$html_title .= "</div>"; $html_title .= "</div>";
// Generate the checkboxes and time select
$html_checkboxes = "<div class='global-config-notification-checkboxes'>";
$html_checkboxes .= " <span>";
$html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true);
$html_checkboxes .= __('Also email users with notification content');
$html_checkboxes .= " </span><br><span>";
$html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true);
$html_checkboxes .= __('Users cannot modify notification preferences');
$html_checkboxes .= " </span>";
$html_checkboxes .= "</div>";
// Return all html // Return all html
return $html_title; return $html_title . $html_checkboxes;
} }