diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
index e62e76efd5..482fcb8f4e 100644
--- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
@@ -1953,6 +1953,25 @@ CREATE TABLE `tnotification_source_group` (
`id_source` BIGINT(20) UNSIGNED NOT NULL,
`id_group` mediumint(4) unsigned NOT NULL,
PRIMARY KEY (`id_source`,`id_group`),
+ INDEX (`id_group`),
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------------------------------------------------
+-- Table `tnotification_source_user`
+-- ----------------------------------------------------------------------
+CREATE TABLE `tnotification_source_group_user` (
+ `id_source` BIGINT(20) UNSIGNED NOT NULL,
+ `id_group` mediumint(4) unsigned NOT NULL,
+ `id_user` VARCHAR(60),
+ `enabled` INT(1) DEFAULT NULL,
+ `also_mail` INT(1) DEFAULT NULL,
+ PRIMARY KEY (`id_source`,`id_user`),
+ FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php
index c26bed8762..1edcf76b77 100644
--- a/pandora_console/general/header.php
+++ b/pandora_console/general/header.php
@@ -16,6 +16,7 @@
require_once ("include/functions_messages.php");
require_once ('include/functions_servers.php');
+require_once ('include/functions_notifications.php');
// Check permissions
@@ -65,6 +66,7 @@ config_check();
$table->style[8] =
$table->style[9] =
$table->style['qr'] =
+ $table->style['notifications'] =
'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;';
$table->style[7] = 'width: 20px; padding-right: 9px;';
$table->style['searchbar'] = 'width: 180px; min-width: 180px;';
@@ -360,7 +362,7 @@ config_check();
$table->data[0][9] .= '';
}
-
+ $table->data[0]['notifications'] = notifications_print_ball();
html_print_table($table);
diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php
index 8ad895ff35..854a897349 100644
--- a/pandora_console/godmode/menu.php
+++ b/pandora_console/godmode/menu.php
@@ -271,7 +271,10 @@ if (check_acl ($config['id_user'], 0, "PM")) {
$sub2["godmode/setup/setup§ion=ehorus"]["text"] = __('eHorus');
$sub2["godmode/setup/setup§ion=ehorus"]["refr"] = 0;
-
+
+ $sub2["godmode/setup/setup§ion=notifications"]["text"] = __('Notifications');
+ $sub2["godmode/setup/setup§ion=notifications"]["refr"] = 0;
+
if ($config['activate_gis']) {
$sub2["godmode/setup/gis"]["text"] = __('Map conections GIS');
}
diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php
index 1b4f2a208c..59652d6f1a 100644
--- a/pandora_console/godmode/setup/setup.php
+++ b/pandora_console/godmode/setup/setup.php
@@ -101,6 +101,11 @@ $buttons['ehorus'] = array('active' => false,
'text' => '' .
html_print_image("images/ehorus/ehorus.png", true, array ("title" => __('eHorus'))) . '');
+// FIXME: Not definitive icon
+$buttons['notifications'] = array('active' => false,
+ 'text' => '' .
+ html_print_image("images/alerts_template.png", true, array ("title" => __('Notifications'))) . '');
+
$help_header = '';
if (enterprise_installed()) {
$subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header);
@@ -132,6 +137,10 @@ switch ($section) {
$buttons['ehorus']['active'] = true;
$subpage = ' » ' . __('eHorus');
break;
+ case 'notifications':
+ $buttons['notifications']['active'] = true;
+ $subpage = ' » ' . __('Notifications');
+ break;
}
// Header
@@ -167,6 +176,9 @@ switch ($section) {
case "ehorus":
require_once($config['homedir'] . "/godmode/setup/setup_ehorus.php");
break;
+ case "notifications":
+ require_once($config['homedir'] . "/godmode/setup/setup_notifications.php");
+ break;
default:
enterprise_hook('setup_enterprise_select_tab', array($section));
break;
diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php
new file mode 100644
index 0000000000..bf842951aa
--- /dev/null
+++ b/pandora_console/godmode/setup/setup_notifications.php
@@ -0,0 +1,271 @@
+ $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);
+ $result = array(
+ 'result' => $res
+ );
+ echo json_encode($result);
+ return;
+}
+
+// Form actions.
+if (get_parameter('update_config', 0)) {
+ $res_global = array_reduce(notifications_get_all_sources(), function($carry, $source){
+ $id = notifications_desc_to_id($source['description']);
+ if (empty($id)) return false;
+ $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);
+ $postpone_value = (int)get_parameter("postpone-{$id}", 0);
+ $all_users = (int)get_parameter("all-{$id}", 0);
+ $res = db_process_sql_update(
+ 'tnotification_source',
+ array(
+ 'enabled' => $enable_value,
+ 'user_editable' => $user_value,
+ 'also_mail' => $mail_value,
+ 'max_postpone_time' => $postpone_value
+ ),
+ array('id' => $source['id'])
+ );
+ $all_users_res = $all_users
+ ? notifications_add_group_to_source($source['id'], array(0))
+ : notifications_remove_group_from_source($source['id'], array(0));
+ return $all_users_res && $res && $carry;
+ }, true);
+}
+
+// Notification table. It is just a wrapper.
+$table_content = new StdClass();
+$table_content->data = array();
+$table_content->width = '100%';
+$table_content->id = 'notifications-wrapper';
+$table_content->class = 'databox filters';
+$table_content->size['name'] = '30%';
+$table_remote->style['name'] = 'font-weight: bold';
+
+// Print each source configuration
+$table_content->data = array_map(function ($source) {
+ return notifications_print_global_source_configuration($source);
+}, notifications_get_all_sources());
+$table_content->data[] = html_print_submit_button(
+ __('Update'), 'update_button', false, 'class="sub upd" style="display: flex; "', true
+);
+
+echo '
';
+
+?>
+
diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php
index 71fed08dd9..092b01af2d 100644
--- a/pandora_console/include/db/mysql.php
+++ b/pandora_console/include/db/mysql.php
@@ -616,6 +616,7 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
$i = 1;
$max = count ($values);
foreach ($values as $field => $value) {
+ $negative = false;
if (is_numeric ($field)) {
/* User provide the exact operation to do */
$query .= $value;
@@ -626,7 +627,10 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
$i++;
continue;
}
-
+ if ($field[0] == "!") {
+ $negative = true;
+ $field = substr($field, 1);
+ }
if ($field[0] != "`") {
//If the field is as ., don't scape.
if (strstr($field, '.') === false)
@@ -643,7 +647,8 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
$query .= sprintf ("%s = %f", $field, $value);
}
elseif (is_array ($value)) {
- $query .= sprintf ('%s IN ("%s")', $field, implode ('", "', $value));
+ $not = $negative ? ' NOT ' : '';
+ $query .= sprintf ('%s %sIN ("%s")', $field, $not, implode ('", "', $value));
}
else {
if ($value === "") {
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 6741f08bc1..bce19cadda 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -3516,4 +3516,15 @@ function mask2cidr($mask){
return 32-log(($long ^ $base)+1,2);
}
+/**
+ * Convert the checkbox result to 1 or 0
+ *
+ * @param string $value Param returned by swith fomulary.
+ *
+ * @return int 1 if value is "on". 0 otherwise.
+ */
+function switch_to_int(string $value) {
+ return $value === "on" ? 1 : 0;
+}
+
?>
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index a3e3358c82..8510b5e259 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -2580,4 +2580,23 @@ function html_print_csrf_error () {
);
return true;
}
+
+/**
+ * Print an swith button
+ *
+ * @param array $atributes. Valid params:
+ * name: Usefull to handle in forms
+ * value: If is checked or not
+ * @return string with HTML of button
+ */
+function html_print_switch ($attributes = array()) {
+
+ $name_html = isset($attributes['name']) ? "name = {$attributes['name']}" : '';
+ $checked_html = (bool)$attributes['value'] ? 'checked' : '';
+ return
+ "";
+}
?>
diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php
index 3005e9a47c..9467c0ff92 100644
--- a/pandora_console/include/functions_notifications.php
+++ b/pandora_console/include/functions_notifications.php
@@ -27,6 +27,7 @@
* ============================================================================
*/
+define('NOTIFICATIONS_POSTPONE_FOREVER', -1);
/**
* Retrieves source ID for given source.
@@ -42,15 +43,24 @@ function get_notification_source_id(string $source)
}
return db_get_value_sql(
- sprintf(
- 'SELECT id
- FROM `tnotification_source`
- WHERE lower(`description`) = lower("%s")',
- $source
- )
+ "SELECT id
+ FROM `tnotification_source`
+ WHERE `description` LIKE '{$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.
@@ -147,3 +157,340 @@ function check_notification_readable(int $id_message)
return (bool) db_get_value_sql($sql);
}
+
+/**
+ * Return all info from tnotification_source
+ *
+ * @return array with sources info
+ */
+function notifications_get_all_sources() {
+ return mysql_db_get_all_rows_in_table('tnotification_source');
+}
+
+/**
+ * Return the user sources to be inserted into a select
+ *
+ * @param int $source_id Source database identificator
+ *
+ * @return array with the user id in keys and user id in value too
+ */
+function notifications_get_user_sources_for_select($source_id) {
+ $users = db_get_all_rows_filter(
+ 'tnotification_source_user',
+ array('id_source' => $source_id),
+ 'id_user'
+ );
+ // If fails or no one is selected, return empty array
+ if ($users === false) return array();
+
+ return index_array($users, 'id_user', 'id_user');
+}
+
+
+/**
+ * Return the groups sources to be inserted into a select
+ *
+ * @param int $source_id Source database identificator
+ *
+ * @return array with the group id in keys and group name in value
+ */
+function notifications_get_group_sources_for_select($source_id) {
+ $groups = notifications_get_group_sources (
+ array('id_source' => $source_id),
+ array('id_group')
+ );
+ return index_array($groups, 'id_group', 'name');
+}
+
+/**
+ * Get the group sources
+ *
+ * @param array $filter Filter of sql query.
+ */
+function notifications_get_group_sources ($filter = array(), $fields = array()) {
+ // Get only the tnotifications_source_group fields in addition to group name.
+ if (empty($fields)) $fields[] = "tnsg.*";
+ $fields = array_map(function($field) {
+ if (!preg_match("/^tnsg./", $field)) $field = "tnsg.{$field}";
+ return $field;
+ }, $fields);
+
+ // Get groups.
+ $groups = db_get_all_rows_filter(
+ 'tnotification_source_group tnsg
+ LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo',
+ $filter,
+ array_merge ($fields, array('IFNULL(tg.nombre, "All") AS name'))
+ );
+
+ // If fails or no one is selected, return empty array
+ if ($groups === false) return array();
+ return $groups;
+}
+
+/**
+ * Delete a set of groups from notification source
+ *
+ * @param int Source id
+ * @param array Id of groups to be deleted
+ *
+ * @return bool True if success. False otherwise.
+ */
+function notifications_remove_group_from_source ($source_id, $groups) {
+ // Source id is mandatory
+ if (!isset($source_id)) return false;
+
+ // Delete from database
+ return db_process_sql_delete (
+ 'tnotification_source_group',
+ array(
+ 'id_group' => $groups,
+ 'id_source' => $source_id
+ )
+ ) !== false;
+}
+
+/**
+ * Delete a set of users from notification source
+ *
+ * @param int Source id
+ * @param array Id of users to be deleted
+ *
+ * @return bool True if success. False otherwise.
+ */
+function notifications_remove_users_from_source ($source_id, $users) {
+ // Source id is mandatory
+ if (!isset($source_id)) return false;
+
+ // Delete from database
+ return db_process_sql_delete (
+ 'tnotification_source_user',
+ array(
+ 'id_user' => $users,
+ 'id_source' => $source_id
+ )
+ ) !== false;
+}
+
+/**
+ * Insert a set of groups to notification source
+ *
+ * @param int Source id
+ * @param array Id of groups to be deleted
+ *
+ * @return bool True if success. False otherwise.
+ */
+function notifications_add_group_to_source ($source_id, $groups) {
+ // Source id is mandatory
+ if (!isset($source_id)) return false;
+
+ // Insert into database all groups passed
+ $res = true;
+ foreach ($groups as $group) {
+ if (empty($group)) continue;
+ $res = $res && db_process_sql_insert(
+ 'tnotification_source_group',
+ array(
+ 'id_group' => $group,
+ 'id_source' => $source_id)
+ ) !== false;
+ }
+ return $res;
+}
+
+/**
+ * Insert a set of users to notification source
+ *
+ * @param int Source id
+ * @param array Id of users to be deleted
+ *
+ * @return bool True if success. False otherwise.
+ */
+ function notifications_add_users_to_source ($source_id, $users) {
+ // Source id is mandatory
+ if (!isset($source_id)) return false;
+
+ // Insert into database all groups passed
+ $res = true;
+ foreach ($users as $user) {
+ if (empty($user)) continue;
+ $res = $res && db_process_sql_insert(
+ 'tnotification_source_user',
+ array(
+ 'id_user' => $user,
+ 'id_source' => $source_id)
+ ) !== false;
+ }
+ return $res;
+}
+
+/**
+ * Get the groups that not own to a source and, for that reason, they can be
+ * added to the source.
+ *
+ * @param int $source_id Source id.
+ * @return array Indexed by id group all selectable groups.
+ */
+function notifications_get_group_source_not_configured ($source_id) {
+ $groups_selected = notifications_get_group_sources_for_select($source_id);
+ $all_groups = users_get_groups_for_select(false, "AR", false, true, $groups_selected);
+ return array_diff($all_groups, $groups_selected);
+}
+
+/**
+ * Get the users that not own to a source and, for that reason, they can be
+ * added to the source.
+ *
+ * @param int $source_id
+ * @return array Indexed by id user, all selectable users.
+ */
+function notifications_get_user_source_not_configured ($source_id) {
+ $users_selected = array_keys(notifications_get_user_sources_for_select($source_id));
+ $users = get_users(
+ 'id_user',
+ array('!id_user' => $users_selected),
+ array('id_user')
+ );
+ return index_array($users, 'id_user', 'id_user');
+}
+
+/**
+ * Print the notification ball to see unread messages
+ *
+ * @return string with HTML code of notification ball
+ */
+function notifications_print_ball() {
+ $num_notifications = messages_get_count();
+ $class_status = $num_notifications == 0
+ ? 'notification-ball-no-messages'
+ : 'notification-ball-new-messages';
+ return
+ "";
+}
+
+/**
+ * Print notification configuration global
+ *
+ * @param array notification source data
+ *
+ * @return string with HTML of source configuration
+ */
+function notifications_print_global_source_configuration($source) {
+
+ // Get some values to generate the title
+ $id = notifications_desc_to_id($source['description']);
+ $switch_values = array (
+ 'name' => "enable-" . $id,
+ 'value' => $source['enabled']
+ );
+
+ // Search if group all is set and handle that situation
+ $source_groups = notifications_get_group_sources_for_select($source['id']);
+ $is_group_all = isset($source_groups["0"]);
+ if($is_group_all) unset($source_groups["0"]);
+
+ // Generate the title
+ $html_title = "";
+ $html_title .= html_print_switch($switch_values);
+ $html_title .= "
{$source['description']}
";
+ $html_title .= "";
+
+ // Generate the html for title
+ $html_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 .= "
";
+
+ // Generate the checkboxes and time select
+ $html_checkboxes = "";
+ $html_checkboxes .= " ";
+ $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)');
+ $html_checkboxes .= __('Notify all users');
+ $html_checkboxes .= "
";
+ $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true);
+ $html_checkboxes .= __('Also email users with notification content');
+ $html_checkboxes .= "
";
+ $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true);
+ $html_checkboxes .= __('Users cannot modify notification preferences');
+ $html_checkboxes .= " ";
+ $html_checkboxes .= "
";
+
+ // Generate the select with the time
+ $html_select_pospone = __('Users can postpone notifications up to');
+ $html_select_pospone .= html_print_select (
+ array(
+ SECONDS_5MINUTES => __('5 minutes'),
+ SECONDS_15MINUTES => __('15 minutes'),
+ SECONDS_12HOURS => __('12 hours'),
+ SECONDS_1DAY => __('1 day'),
+ SECONDS_1WEEK => __('1 week'),
+ SECONDS_15DAYS => __('15 days'),
+ SECONDS_1MONTH => __('1 month'),
+ NOTIFICATIONS_POSTPONE_FOREVER => __('forever')),
+ "postpone-{$id}",
+ $source['max_postpone_time'],
+ '',
+ '',
+ 0,
+ true
+ );
+
+ // Return all html
+ return $html_title . $html_selectors . $html_checkboxes . $html_select_pospone;
+}
+
+/**
+ * Print select boxes of notified users or groups
+ *
+ * @param array $info_selec All info required for build the selector
+ * @param string $id users|groups
+ * @param string $source_id Id of source
+ * @param bool $disabled Disable the selectors
+ *
+ * @return string HTML with the generated selector
+ */
+function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled) {
+
+ $title = $id == "users" ? __('Notified users') : __('Notified groups');
+ $add_title = $id == "users" ? __('Add users') : __('Add groups');
+ $delete_title = $id == "users" ? __('Delete users') : __('Delete groups');
+
+ // Generate the HTML
+ $html_select = "";
+ $html_select .= "
";
+ $html_select .= "
$title
";
+ // Put a true if empty sources to avoid to sow the 'None' value
+ $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true,'', $disabled);
+ $html_select .= " ";
+ $html_select .= "
";
+ $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')"));
+ $html_select .= html_print_image('images/input_delete.png', true, array('title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')"));
+ $html_select .= "
";
+ $html_select .= "
";
+ return $html_select;
+}
+
+/**
+ * Print the select with right and left arrows to select new sources
+ * (groups or users).
+ *
+ * @param array $info_selec Array with source info.
+ * @param string $users users|groups.
+ * @param source $source_id Source id.
+ * @return string HTML with the select code.
+ */
+function notifications_print_two_ways_select($info_selec, $users, $source_id) {
+ $html_select = "";
+ $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true,'');
+ $html_select .= "
";
+ $html_select .= html_print_image('images/darrowright.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')"));
+ $html_select .= html_print_image('images/darrowleft.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')"));
+ $html_select .= "
";
+ $html_select .= html_print_select(true, "selected-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, '');
+ $html_select .= "
";
+ $html_select .= html_print_button(__('Add'), 'Add', false, "notifications_add_source_element_to_database('$users', '$source_id')", "class='sub add'", true);
+
+ return $html_select;
+}
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index f42c64f70a..1d4e4af4c0 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -4912,6 +4912,83 @@ div#dialog_messages table th:last-child {
text-align: right;
}
+.notification-ball {
+ border: white solid 2px;
+ border-radius: 50px;
+ width: 18px;
+ height: 18px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.notification-ball-no-messages {
+ background-color: #82b92e;
+}
+.notification-ball-new-messages {
+ background-color: #fc4444;
+}
+
+.global-config-notification-title {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+}
+
+.global-config-notification-title h2 {
+ margin-left: 10px;
+}
+
+.global-config-notification-checkboxes :first-child {
+ font-weight: bold;
+}
+
+.global-config-notification-selectors {
+ display: flex;
+ flex-direction: row;
+ margin-bottom: 10px;
+}
+
+.global-config-notification-selectors h4 {
+ margin: 0;
+}
+
+.global-config-notification-single-selector,
+.global_config_notifications_dialog_add select {
+ display: flex;
+ width: 100%;
+ padding: 0 10px;
+}
+
+.global-config-notification-single-selector :first-child,
+.global-config-notification-single-selector :first-child select {
+ width: 99%;
+}
+
+.global-config-notification-single-selector :last-child,
+.global_config_notifications_dialog_add_wrapper {
+ flex-direction: column;
+ display: flex;
+ justify-content: flex-end;
+}
+
+.global_config_notifications_dialog_add {
+ display: flex;
+ flex-direction: row;
+ margin: 8px;
+}
+
+.global_config_notifications_two_ways_form_arrows {
+ display: flex;
+ flex-flow: column;
+ justify-content: center;
+ margin: 0 5px;
+}
+
+.global_config_notifications_two_ways_form_arrows img {
+ margin: 15px 0;
+}
+
/* --- JQUERY-UI --- */
.ui-button-text-only .ui-button-text {
font-family: "nunito", sans-serif;
@@ -5158,3 +5235,59 @@ input[type="submit"].ui-button-dialog {
width: 90px !important;
}
/* --- END - JQUERY-UI --- */
+
+/* --- SWITCH --- */
+.p-switch {
+ position: relative;
+ display: inline-block;
+ width: 30px;
+ height: 17px;
+}
+
+.p-switch input {
+ opacity: 0;
+ width: 0;
+ height: 0;
+}
+
+.p-slider {
+ position: absolute;
+ cursor: pointer;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: #ccc;
+ -webkit-transition: 0.4s;
+ transition: 0.4s;
+ border-radius: 34px;
+}
+
+.p-slider:before {
+ position: absolute;
+ content: "";
+ height: 13px;
+ width: 13px;
+ left: 2px;
+ bottom: 2px;
+ background-color: white;
+ -webkit-transition: 0.4s;
+ transition: 0.4s;
+ border-radius: 50%;
+}
+
+input:checked + .p-slider {
+ background-color: #82b92e;
+}
+
+input:focus + .p-slider {
+ box-shadow: 0 0 1px #82b92e;
+}
+
+input:checked + .p-slider:before {
+ -webkit-transform: translateX(13px);
+ -ms-transform: translateX(13px);
+ transform: translateX(13px);
+}
+
+/* --- END SWITCH --- */
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index c70650c70b..daae31bf5d 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -1246,10 +1246,29 @@ CREATE TABLE `tnotification_source_group` (
`id_source` BIGINT(20) UNSIGNED NOT NULL,
`id_group` mediumint(4) unsigned NOT NULL,
PRIMARY KEY (`id_source`,`id_group`),
+ INDEX (`id_group`),
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+-- ----------------------------------------------------------------------
+-- Table `tnotification_source_user`
+-- ----------------------------------------------------------------------
+CREATE TABLE `tnotification_source_group_user` (
+ `id_source` BIGINT(20) UNSIGNED NOT NULL,
+ `id_group` mediumint(4) unsigned NOT NULL,
+ `id_user` VARCHAR(60),
+ `enabled` INT(1) DEFAULT NULL,
+ `also_mail` INT(1) DEFAULT NULL,
+ PRIMARY KEY (`id_source`,`id_user`),
+ FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
-- ----------------------------------------------------------------------
-- Table `tnews`
-- ----------------------------------------------------------------------