Use real ids instead fake ids
Former-commit-id: 2360a14d1865f918247d23b2f3181626052cad60
This commit is contained in:
parent
7fa344c2a4
commit
04b2cb8665
|
@ -26,38 +26,36 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
|
|||
}
|
||||
|
||||
// AJAX actions.
|
||||
$source_id = get_parameter('source_id', '');
|
||||
$source = get_parameter('source', '');
|
||||
$users = get_parameter('users', '');
|
||||
$elements = get_parameter('elements', []);
|
||||
$id = empty($source_id) ? 0 : get_notification_source_id($source_id);
|
||||
$is_users = $users === 'users';
|
||||
if (get_parameter('get_selection_two_ways_form', 0)) {
|
||||
$info_selec = $is_users ? notifications_get_user_source_not_configured($id) : notifications_get_group_source_not_configured($id);
|
||||
$info_selec = $is_users ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source);
|
||||
|
||||
echo notifications_print_two_ways_select(
|
||||
$info_selec,
|
||||
$users,
|
||||
$source_id
|
||||
$source
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('add_source_to_database', 0)) {
|
||||
$res = $is_users ? notifications_add_users_to_source($id, $elements) : notifications_add_group_to_source($id, $elements);
|
||||
$res = $is_users ? notifications_add_users_to_source($source, $elements) : notifications_add_group_to_source($source, $elements);
|
||||
$result = ['result' => $res];
|
||||
echo json_encode($result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('remove_source_on_database', 0)) {
|
||||
$res = $is_users ? notifications_remove_users_from_source($id, $elements) : notifications_remove_group_from_source($id, $elements);
|
||||
$res = $is_users ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements);
|
||||
$result = ['result' => $res];
|
||||
echo json_encode($result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('update_config', 0)) {
|
||||
$source = (int) get_parameter('source', 0);
|
||||
$element = (string) get_parameter('element', '');
|
||||
$value = (int) get_parameter('value', 0);
|
||||
|
||||
|
@ -159,7 +157,7 @@ function add_source_dialog(users, source_id) {
|
|||
{"page" : "godmode/setup/setup_notifications",
|
||||
"get_selection_two_ways_form" : 1,
|
||||
"users" : users,
|
||||
"source_id" : source_id
|
||||
"source" : source_id
|
||||
},
|
||||
function (data, status) {
|
||||
not_dialog.innerHTML = data
|
||||
|
@ -198,7 +196,7 @@ function notifications_add_source_element_to_database(id, source_id) {
|
|||
{"page" : "godmode/setup/setup_notifications",
|
||||
"add_source_to_database" : 1,
|
||||
"users" : id,
|
||||
"source_id" : source_id,
|
||||
"source" : source_id,
|
||||
"elements": selected
|
||||
},
|
||||
function (data, status) {
|
||||
|
@ -236,13 +234,13 @@ function remove_source_elements(id, source_id) {
|
|||
{"page" : "godmode/setup/setup_notifications",
|
||||
"remove_source_on_database" : 1,
|
||||
"users" : id,
|
||||
"source_id" : source_id,
|
||||
"source" : source_id,
|
||||
"elements": selected
|
||||
},
|
||||
function (data, status) {
|
||||
if (data.result) {
|
||||
// Append to other element
|
||||
for (var i = selected_index.length - 1; i >= 0; i--) {
|
||||
for (var i = 0; i < selected_index.length; i++) {
|
||||
select.remove(selected_index[i]);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -51,21 +51,6 @@ function get_notification_source_id(string $source)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts description into a handable identifier
|
||||
*
|
||||
* @param string $desc Full description
|
||||
*
|
||||
* @return string First word in lowercase. Empty string if no word detected.
|
||||
*/
|
||||
function notifications_desc_to_id(string $desc)
|
||||
{
|
||||
preg_match('/^[a-zA-Z]*/', $desc, $matches);
|
||||
$match = $matches[0];
|
||||
return isset($match) ? $match : '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all targets for given message.
|
||||
*
|
||||
|
@ -348,7 +333,9 @@ function notifications_add_group_to_source($source_id, $groups)
|
|||
// Insert into database all groups passed.
|
||||
$res = true;
|
||||
foreach ($groups as $group) {
|
||||
if (!isset($group)) continue;
|
||||
if (!isset($group)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$res = $res && db_process_sql_insert(
|
||||
'tnotification_source_group',
|
||||
|
@ -559,9 +546,8 @@ function notifications_print_ball()
|
|||
function notifications_print_global_source_configuration($source)
|
||||
{
|
||||
// Get some values to generate the title.
|
||||
$id = notifications_desc_to_id($source['description']);
|
||||
$switch_values = [
|
||||
'name' => 'enable-'.$id,
|
||||
'name' => 'enable-'.$source['id'],
|
||||
'value' => $source['enabled'],
|
||||
'id' => 'nt-'.$source['id'].'-enabled',
|
||||
'class' => 'elem-clickable',
|
||||
|
@ -582,19 +568,19 @@ function notifications_print_global_source_configuration($source)
|
|||
|
||||
// Generate the html for title
|
||||
$html_selectors = "<div class='global-config-notification-selectors'>";
|
||||
$html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all);
|
||||
$html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all);
|
||||
$html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $source['id'], $is_group_all);
|
||||
$html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $source['id'], $is_group_all);
|
||||
$html_selectors .= '</div>';
|
||||
// Generate the checkboxes and time select
|
||||
$html_checkboxes = "<div class='global-config-notification-checkboxes'>";
|
||||
$html_checkboxes .= ' <span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended("all-$id", 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"');
|
||||
$html_checkboxes .= html_print_checkbox_extended('all-'.$source['id'], 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"');
|
||||
$html_checkboxes .= __('Notify all users');
|
||||
$html_checkboxes .= ' </span><br><span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended("mail-$id", 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"');
|
||||
$html_checkboxes .= html_print_checkbox_extended('mail-'.$source['id'], 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"');
|
||||
$html_checkboxes .= __('Also email users with notification content');
|
||||
$html_checkboxes .= ' </span><br><span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended("user-$id", 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"');
|
||||
$html_checkboxes .= html_print_checkbox_extended('user-'.$source['id'], 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"');
|
||||
$html_checkboxes .= __('Users can modify notification preferences');
|
||||
$html_checkboxes .= ' </span>';
|
||||
$html_checkboxes .= '</div>';
|
||||
|
|
Loading…
Reference in New Issue