mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
notifications, WIP: new lib defined
Former-commit-id: 430ac2e090f91403fc074d2a9b37ab36de10d5a9
This commit is contained in:
parent
dc3d7cc5e2
commit
fa6c4d5bc9
@ -1,321 +1,451 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
/**
|
||||||
// ==================================================
|
* Extension to manage a list of gateways and the node address where they should
|
||||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
* point to.
|
||||||
// Please see http://pandorafms.org for full contribution list
|
*
|
||||||
|
* @category Extensions
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
require_once $config['homedir'].'/include/functions_users.php';
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
require_once $config['homedir'].'/include/functions_groups.php';
|
||||||
// as published by the Free Software Foundation; version 2
|
require_once $config['homedir'].'/include/functions_notifications.php';
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package Include
|
|
||||||
* @subpackage Messages
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once($config['homedir'] . "/include/functions_users.php");
|
|
||||||
require_once ($config['homedir'].'/include/functions_groups.php');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a private message to be forwarded to other people
|
* Creates a private message to be forwarded to other people
|
||||||
*
|
|
||||||
* @param string $usuario_origen The sender of the message
|
|
||||||
* @param string $usuario_destino The receiver of the message
|
|
||||||
* @param string $subject Subject of the message (much like E-Mail)
|
|
||||||
* @param string $mensaje The actual message. This message will be cleaned by io_safe_input
|
|
||||||
* (html is allowed but loose html chars will be translated)
|
|
||||||
*
|
*
|
||||||
* @return bool true when delivered, false in case of error
|
* @param string $usuario_origen The sender of the message.
|
||||||
|
* @param string $usuario_destino The receiver of the message.
|
||||||
|
* @param string $subject Subject of the message (much like E-Mail).
|
||||||
|
* @param string $mensaje The actual message. This message will be
|
||||||
|
* cleaned by io_safe_input (html is allowed but
|
||||||
|
* loose html chars will be translated).
|
||||||
|
*
|
||||||
|
* @return boolean true when delivered, false in case of error
|
||||||
*/
|
*/
|
||||||
function messages_create_message ($usuario_origen, $usuario_destino, $subject, $mensaje) {
|
function messages_create_message(
|
||||||
$users = users_get_info ();
|
string $usuario_origen,
|
||||||
|
string $usuario_destino,
|
||||||
if (!array_key_exists ($usuario_origen, $users) || !array_key_exists ($usuario_destino, $users)) {
|
string $subject,
|
||||||
return false; //Users don't exist so don't send to them
|
string $mensaje
|
||||||
}
|
) {
|
||||||
|
$users = users_get_info();
|
||||||
$values = array ();
|
|
||||||
$values["id_usuario_origen"] = $usuario_origen;
|
if (!array_key_exists($usuario_origen, $users)
|
||||||
$values["id_usuario_destino"] = $usuario_destino;
|
|| !array_key_exists($usuario_destino, $users)
|
||||||
$values["subject"] = $subject;
|
) {
|
||||||
$values["mensaje"] = $mensaje;
|
return false;
|
||||||
$values["timestamp"] = get_system_time ();
|
// Users don't exist so don't send to them.
|
||||||
|
}
|
||||||
$return = db_process_sql_insert ("tmensajes", $values);
|
|
||||||
|
// Create message.
|
||||||
if ($return === false) {
|
$message_id = db_process_sql_insert(
|
||||||
return false;
|
'tmensajes',
|
||||||
}
|
[
|
||||||
else {
|
'id_usuario_origen' => $usuario_origen,
|
||||||
return true;
|
'subject' => $subject,
|
||||||
}
|
'mensaje' => $mensaje,
|
||||||
|
'id_source' => get_notification_source_id('message'),
|
||||||
|
'timestamp' => get_system_time(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update URL
|
||||||
|
// Update targets.
|
||||||
|
if ($message_id !== false) {
|
||||||
|
$return = db_process_sql_insert(
|
||||||
|
'tnotification_user',
|
||||||
|
[
|
||||||
|
'id_mensaje' => $message_id,
|
||||||
|
'id_user' => $usuario_destino,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Creates private messages to be forwarded to groups
|
* Creates private messages to be forwarded to groups
|
||||||
*
|
|
||||||
* @param string The sender of the message
|
|
||||||
* @param string The receivers (group) of the message
|
|
||||||
* @param string Subject of the message (much like E-Mail)
|
|
||||||
* @param string The actual message. This message will be cleaned by io_safe_input
|
|
||||||
* (html is allowed but loose html chars will be translated)
|
|
||||||
*
|
*
|
||||||
* @return bool true when delivered, false in case of error
|
* @param string $usuario_origen The sender of the message.
|
||||||
|
* @param string $dest_group The receivers (group) of the message.
|
||||||
|
* @param string $subject Subject of the message (much like E-Mail).
|
||||||
|
* @param string $mensaje The actual message. This message will be
|
||||||
|
* cleaned by io_safe_input (html is allowed but
|
||||||
|
* loose html chars will be translated).
|
||||||
|
*
|
||||||
|
* @return boolean true when delivered, false in case of error
|
||||||
*/
|
*/
|
||||||
function messages_create_group ($usuario_origen, $dest_group, $subject, $mensaje) {
|
function messages_create_group(
|
||||||
$users = users_get_info ();
|
string $usuario_origen,
|
||||||
$group_users = groups_get_users ($dest_group);
|
string $dest_group,
|
||||||
|
string $subject,
|
||||||
if (! array_key_exists ($usuario_origen, $users)) {
|
string $mensaje
|
||||||
//Users don't exist in the system
|
) {
|
||||||
return false;
|
$users = users_get_info();
|
||||||
}
|
$group_users = groups_get_users($dest_group);
|
||||||
elseif (empty ($group_users)) {
|
|
||||||
//There are no users in the group, so it hasn't failed although it hasn't done anything.
|
if (! array_key_exists($usuario_origen, $users)) {
|
||||||
return true;
|
// Users don't exist in the system.
|
||||||
}
|
return false;
|
||||||
|
} else if (empty($group_users)) {
|
||||||
// array unique
|
/*
|
||||||
foreach ($group_users as $user) {
|
There are no users in the group, so it hasn't failed
|
||||||
foreach ($user as $key=>$us) {
|
although it hasn't done anything.
|
||||||
if ($key == 'id_user') {
|
*/
|
||||||
$group_user[$us] = $us;
|
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Array unique.
|
||||||
foreach ($group_user as $user) {
|
foreach ($group_users as $user) {
|
||||||
$return = messages_create_message ($usuario_origen, get_user_id ($user), $subject, $mensaje);
|
foreach ($user as $key => $us) {
|
||||||
if ($return === false) {
|
if ($key == 'id_user') {
|
||||||
//Error sending message
|
$group_user[$us] = $us;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
foreach ($group_user as $user) {
|
||||||
|
$return = messages_create_message(
|
||||||
|
$usuario_origen,
|
||||||
|
get_user_id($user),
|
||||||
|
$subject,
|
||||||
|
$mensaje
|
||||||
|
);
|
||||||
|
if ($return === false) {
|
||||||
|
// Error sending message.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Deletes a private message
|
* Deletes a private message
|
||||||
*
|
|
||||||
* @param int $id_message
|
|
||||||
*
|
*
|
||||||
* @return bool true when deleted, false in case of error
|
* @param integer $id_message Message to be deleted.
|
||||||
|
*
|
||||||
|
* @return boolean true when deleted, false in case of error
|
||||||
*/
|
*/
|
||||||
function messages_delete_message ($id_message) {
|
function messages_delete_message(int $id_message)
|
||||||
global $config;
|
{
|
||||||
|
global $config;
|
||||||
$where = array(
|
// 'id_usuario_destino' => $config["id_user"],
|
||||||
//'id_usuario_destino' => $config["id_user"],
|
$where = ['id_mensaje' => $id_message];
|
||||||
'id_mensaje' => $id_message);
|
return (bool) db_process_sql_delete('tmensajes', $where);
|
||||||
return (bool)db_process_sql_delete('tmensajes', $where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Marks a private message as read/unread
|
* Marks a private message as read/unread
|
||||||
*
|
|
||||||
* @param int $message_id The message to modify
|
|
||||||
* @param bool $read To set unread pass 0, false or empty value
|
|
||||||
*
|
*
|
||||||
* @return bool true when marked, false in case of error
|
* @param integer $message_id The message to modify.
|
||||||
|
* @param boolean $read To set unread pass 0, false or empty value.
|
||||||
|
*
|
||||||
|
* @return boolean true when marked, false in case of error
|
||||||
*/
|
*/
|
||||||
function messages_process_read ($message_id, $read = true) {
|
function messages_process_read(
|
||||||
if (empty ($read)) {
|
int $message_id,
|
||||||
$read = 0;
|
bool $read=true
|
||||||
}
|
) {
|
||||||
else {
|
if (empty($read)) {
|
||||||
$read = 1;
|
$read = 0;
|
||||||
}
|
} else {
|
||||||
|
$read = 1;
|
||||||
return (bool) db_process_sql_update('tmensajes', array('estado' => $read), array('id_mensaje' => $message_id));
|
}
|
||||||
|
|
||||||
|
return (bool) db_process_sql_update(
|
||||||
|
'tmensajes',
|
||||||
|
['estado' => $read],
|
||||||
|
['id_mensaje' => $message_id]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Gets a private message
|
* Gets a private message
|
||||||
*
|
*
|
||||||
* This function abstracts the database backend so it can simply be replaced with another system
|
* This function abstracts the database backend so it can simply be
|
||||||
*
|
* replaced with another system
|
||||||
* @param int $message_id
|
*
|
||||||
|
* @param integer $message_id Message to be retrieved.
|
||||||
*
|
*
|
||||||
* @return mixed False if it doesn't exist or a filled array otherwise
|
* @return mixed False if it doesn't exist or a filled array otherwise
|
||||||
*/
|
*/
|
||||||
function messages_get_message ($message_id) {
|
function messages_get_message(int $message_id)
|
||||||
global $config;
|
{
|
||||||
|
global $config;
|
||||||
$sql = sprintf("SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
|
||||||
FROM tmensajes
|
$sql = sprintf(
|
||||||
WHERE id_usuario_destino='%s' AND id_mensaje=%d" , $config["id_user"], $message_id);
|
"SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
||||||
$row = db_get_row_sql ($sql);
|
FROM tmensajes
|
||||||
|
WHERE id_usuario_destino='%s' AND id_mensaje=%d",
|
||||||
if (empty ($row)) {
|
$config['id_user'],
|
||||||
return false;
|
$message_id
|
||||||
}
|
);
|
||||||
|
$row = db_get_row_sql($sql);
|
||||||
return $row;
|
|
||||||
|
if (empty($row)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Gets a sent message
|
* Gets a sent message
|
||||||
*
|
*
|
||||||
* This function abstracts the database backend so it can simply be replaced with another system
|
* This function abstracts the database backend so it can simply be
|
||||||
*
|
* replaced with another system
|
||||||
* @param int $message_id
|
*
|
||||||
|
* @param integer $message_id Message to be retrieved.
|
||||||
*
|
*
|
||||||
* @return mixed False if it doesn't exist or a filled array otherwise
|
* @return mixed False if it doesn't exist or a filled array otherwise
|
||||||
*/
|
*/
|
||||||
function messages_get_message_sent ($message_id) {
|
function messages_get_message_sent(int $message_id)
|
||||||
global $config;
|
{
|
||||||
|
global $config;
|
||||||
$sql = sprintf("SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
|
||||||
FROM tmensajes
|
$sql = sprintf(
|
||||||
WHERE id_usuario_origen='%s' AND id_mensaje=%d" , $config["id_user"], $message_id);
|
"SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
||||||
$row = db_get_row_sql ($sql);
|
FROM tmensajes
|
||||||
|
WHERE id_usuario_origen='%s' AND id_mensaje=%d",
|
||||||
if (empty ($row)) {
|
$config['id_user'],
|
||||||
return false;
|
$message_id
|
||||||
}
|
);
|
||||||
|
$row = db_get_row_sql($sql);
|
||||||
return $row;
|
|
||||||
|
if (empty($row)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts private messages
|
* Counts private messages
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user Target user.
|
||||||
* @param bool $incl_read Whether or not to include read messages
|
* @param boolean $incl_read Whether or not to include read messages.
|
||||||
*
|
*
|
||||||
* @return int The number of messages this user has
|
* @return integer The number of messages this user has
|
||||||
*/
|
*/
|
||||||
function messages_get_count ($user = false, $incl_read = false) {
|
function messages_get_count(
|
||||||
if (empty ($user)) {
|
string $user='',
|
||||||
global $config;
|
bool $incl_read=false
|
||||||
$user = $config["id_user"];
|
) {
|
||||||
}
|
if (empty($user)) {
|
||||||
|
global $config;
|
||||||
if (empty ($incl_read)) {
|
$user = $config['id_user'];
|
||||||
$filter = "AND estado = 0";
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
$filter = "";
|
|
||||||
}
|
|
||||||
$sql = sprintf("SELECT COUNT(*)
|
|
||||||
FROM tmensajes WHERE id_usuario_destino='%s' %s", $user, $filter);
|
|
||||||
|
|
||||||
return (int) db_get_sql ($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (!empty($incl_read)) {
|
||||||
* Counts sended messages
|
// Retrieve only unread messages.
|
||||||
*
|
$filter = 'AND nu.uptimestap_read == NULL';
|
||||||
* @param string $user
|
} else {
|
||||||
*
|
// Do not filter.
|
||||||
* @return int The number of messages this user has sent
|
$filter = '';
|
||||||
*/
|
}
|
||||||
function messages_get_count_sent ($user = false) {
|
|
||||||
if (empty ($user)) {
|
$sql = sprintf(
|
||||||
global $config;
|
"SELECT count(*) FROM tmensajes tm
|
||||||
$user = $config["id_user"];
|
left join tnotification_user nu
|
||||||
}
|
ON tm.id_mensaje=nu.id_mensaje
|
||||||
$sql = sprintf("SELECT COUNT(*)
|
left join tnotification_group ng
|
||||||
FROM tmensajes WHERE id_usuario_origen='%s'", $user);
|
ON tm.id_mensaje=ng.id_mensaje
|
||||||
|
left join tusuario_perfil up
|
||||||
return (int) db_get_sql ($sql);
|
ON tm.id_mensaje=ng.id_mensaje
|
||||||
|
AND ng.id_group=up.id_grupo
|
||||||
|
WHERE (nu.id_user='%s' OR ng.id_group=0 OR up.id_grupo=ng.id_group)
|
||||||
|
%s",
|
||||||
|
$config['id_user'],
|
||||||
|
$filter
|
||||||
|
);
|
||||||
|
|
||||||
|
return (int) db_get_sql($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Counts messages sent.
|
||||||
|
*
|
||||||
|
* @param string $user Target user.
|
||||||
|
*
|
||||||
|
* @return integer The number of messages this user has sent
|
||||||
|
*/
|
||||||
|
function messages_get_count_sent(string $user='')
|
||||||
|
{
|
||||||
|
if (empty($user)) {
|
||||||
|
global $config;
|
||||||
|
$user = $config['id_user'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = sprintf(
|
||||||
|
"SELECT COUNT(*)
|
||||||
|
FROM tmensajes WHERE id_usuario_origen='%s'",
|
||||||
|
$user
|
||||||
|
);
|
||||||
|
|
||||||
|
return (int) db_get_sql($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* Get message overview in array
|
* Get message overview in array
|
||||||
*
|
*
|
||||||
* @param string $order How to order them valid:
|
* @param string $order How to order them valid:
|
||||||
* (status (default), subject, timestamp, sender)
|
* (status (default), subject, timestamp, sender).
|
||||||
* @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending)
|
* @param string $order_dir Direction of order
|
||||||
|
* (ASC = Ascending, DESC = Descending).
|
||||||
*
|
*
|
||||||
* @return int The number of messages this user has
|
* @return integer The number of messages this user has
|
||||||
*/
|
*/
|
||||||
function messages_get_overview ($order = "status", $order_dir = "ASC") {
|
function messages_get_overview(
|
||||||
global $config;
|
string $order='status',
|
||||||
|
string $order_dir='ASC'
|
||||||
switch ($order) {
|
) {
|
||||||
case "timestamp":
|
global $config;
|
||||||
case "sender":
|
|
||||||
case "subject":
|
switch ($order) {
|
||||||
break;
|
case 'timestamp':{
|
||||||
case "status":
|
}
|
||||||
default:
|
case 'sender':{
|
||||||
$order = "estado, timestamp";
|
}
|
||||||
break;
|
case 'subject':{
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
if ($order_dir != "ASC") {
|
|
||||||
$order .= " DESC";
|
case 'status':
|
||||||
}
|
default:
|
||||||
|
$order = 'estado, timestamp';
|
||||||
$result = array ();
|
break;
|
||||||
$return = db_get_all_rows_field_filter ('tmensajes', 'id_usuario_destino', $config["id_user"], $order);
|
}
|
||||||
|
|
||||||
if ($return === false) {
|
if ($order_dir != 'ASC') {
|
||||||
return $result;
|
$order .= ' DESC';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($return as $message) {
|
$sql = sprintf(
|
||||||
$result[$message["id_mensaje"]]["sender"] = $message["id_usuario_origen"];
|
"SELECT * FROM tmensajes tm
|
||||||
$result[$message["id_mensaje"]]["subject"] = $message["subject"];
|
left join tnotification_user nu
|
||||||
$result[$message["id_mensaje"]]["timestamp"] = $message["timestamp"];
|
ON tm.id_mensaje=nu.id_mensaje
|
||||||
$result[$message["id_mensaje"]]["status"] = $message["estado"];
|
left join tnotification_group ng
|
||||||
}
|
ON tm.id_mensaje=ng.id_mensaje
|
||||||
|
left join tusuario_perfil up
|
||||||
return $result;
|
ON tm.id_mensaje=ng.id_mensaje
|
||||||
|
AND ng.id_group=up.id_grupo
|
||||||
|
WHERE (nu.id_user='%s' OR ng.id_group=0 OR up.id_grupo=ng.id_group)
|
||||||
|
ORDER BY %s",
|
||||||
|
$config['id_user'],
|
||||||
|
$order
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
$return = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($return as $message) {
|
||||||
|
$id_message = $message['id_mensaje'];
|
||||||
|
$result[$id_message]['sender'] = $message['id_usuario_origen'];
|
||||||
|
$result[$id_message]['subject'] = $message['subject'];
|
||||||
|
$result[$id_message]['timestamp'] = $message['timestamp'];
|
||||||
|
$result[$id_message]['status'] = $message['estado'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Get sent message overview in array
|
* Get sent message overview in array
|
||||||
*
|
*
|
||||||
* @param string $order How to order them valid:
|
* @param string $order How to order them valid:
|
||||||
* (status (default), subject, timestamp, sender)
|
* (status (default), subject, timestamp, sender).
|
||||||
* @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending)
|
* @param string $order_dir Direction of order
|
||||||
|
* (ASC = Ascending, DESC = Descending).
|
||||||
*
|
*
|
||||||
* @return int The number of messages this user has
|
* @return integer The number of messages this user has
|
||||||
*/
|
*/
|
||||||
function messages_get_overview_sent ($order = "timestamp", $order_dir = "ASC") {
|
function messages_get_overview_sent(
|
||||||
global $config;
|
string $order='timestamp',
|
||||||
|
string $order_dir='ASC'
|
||||||
switch ($order) {
|
) {
|
||||||
case "timestamp":
|
global $config;
|
||||||
case "sender":
|
|
||||||
case "subject":
|
|
||||||
break;
|
|
||||||
case "status":
|
|
||||||
default:
|
|
||||||
$order = "estado, timestamp";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($order_dir != "ASC") {
|
|
||||||
$order .= " DESC";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = array ();
|
|
||||||
$return = db_get_all_rows_field_filter ('tmensajes', 'id_usuario_origen', $config["id_user"], $order);
|
|
||||||
|
|
||||||
if ($return === false) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($return as $message) {
|
|
||||||
$result[$message["id_mensaje"]]["dest"] = $message["id_usuario_destino"];
|
|
||||||
$result[$message["id_mensaje"]]["subject"] = $message["subject"];
|
|
||||||
$result[$message["id_mensaje"]]["timestamp"] = $message["timestamp"];
|
|
||||||
$result[$message["id_mensaje"]]["status"] = $message["estado"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
switch ($order) {
|
||||||
|
case 'timestamp':{
|
||||||
|
}
|
||||||
|
case 'sender':{
|
||||||
|
}
|
||||||
|
case 'subject':{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'status':
|
||||||
|
default:
|
||||||
|
$order = 'estado, timestamp';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_dir != 'ASC') {
|
||||||
|
$order .= ' DESC';
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
$return = db_get_all_rows_field_filter(
|
||||||
|
'tmensajes',
|
||||||
|
'id_usuario_origen',
|
||||||
|
$config['id_user'],
|
||||||
|
$order
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($return as $message) {
|
||||||
|
$id_message = $message['id_mensaje'];
|
||||||
|
$result[$id_message]['dest'] = $message['id_usuario_destino'];
|
||||||
|
$result[$id_message]['subject'] = $message['subject'];
|
||||||
|
$result[$id_message]['timestamp'] = $message['timestamp'];
|
||||||
|
$result[$id_message]['status'] = $message['estado'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
53
pandora_console/include/functions_notifications.php
Normal file
53
pandora_console/include/functions_notifications.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension to manage a list of gateways and the node address where they should
|
||||||
|
* point to.
|
||||||
|
*
|
||||||
|
* @category Extensions
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves source ID for given source.
|
||||||
|
*
|
||||||
|
* @param string $source Source.
|
||||||
|
*
|
||||||
|
* @return integer source's id.
|
||||||
|
*/
|
||||||
|
function get_notification_source_id(string $source)
|
||||||
|
{
|
||||||
|
if (empty($source) === true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return db_get_value_sql(
|
||||||
|
sprintf(
|
||||||
|
'SELECT id
|
||||||
|
FROM `tnotification_source`
|
||||||
|
WHERE lower(`description`) = lower("%s")',
|
||||||
|
$source
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
@ -1,257 +1,295 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Extension to manage a list of gateways and the node address where they should
|
||||||
|
* point to.
|
||||||
|
*
|
||||||
|
* @category Extensions
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
require_once 'include/functions_messages.php';
|
||||||
// ==================================================
|
|
||||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
|
||||||
// Please see http://pandorafms.org for full contribution list
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
$delete_msg = get_parameter('delete_message', 0);
|
||||||
// modify it under the terms of the GNU General Public License
|
$multiple_delete = get_parameter('multiple_delete', 0);
|
||||||
// as published by the Free Software Foundation for version 2.
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
|
|
||||||
include_once ('include/functions_messages.php');
|
|
||||||
|
|
||||||
$delete_msg = get_parameter('delete_message',0);
|
|
||||||
$multiple_delete = get_parameter('multiple_delete',0);
|
|
||||||
$show_sent = get_parameter('show_sent', 0);
|
$show_sent = get_parameter('show_sent', 0);
|
||||||
$mark_unread = get_parameter('mark_unread', 0);
|
$mark_unread = get_parameter('mark_unread', 0);
|
||||||
|
|
||||||
$active_list = true;
|
$active_list = true;
|
||||||
$active_sent = false;
|
$active_sent = false;
|
||||||
if ($show_sent) {
|
if ($show_sent !== 0) {
|
||||||
$active_list = false;
|
$active_list = false;
|
||||||
$active_sent = true;
|
$active_sent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$buttons['message_list'] = array('active' => $active_list,
|
$buttons['message_list'] = [
|
||||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">' .
|
'active' => $active_list,
|
||||||
html_print_image("images/email_inbox.png", true, array ("title" => __('Received messages'))) .'</a>');
|
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">'.html_print_image('images/email_inbox.png', true, ['title' => __('Received messages')]).'</a>',
|
||||||
|
];
|
||||||
|
|
||||||
$buttons['sent_messages'] = array('active' => $active_sent,
|
$buttons['sent_messages'] = [
|
||||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">' .
|
'active' => $active_sent,
|
||||||
html_print_image("images/email_outbox.png", true, array ("title" => __('Sent messages'))) .'</a>');
|
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'.html_print_image('images/email_outbox.png', true, ['title' => __('Sent messages')]).'</a>',
|
||||||
|
];
|
||||||
|
|
||||||
$buttons['create_message'] = array('active' => false,
|
$buttons['create_message'] = [
|
||||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">' .
|
'active' => false,
|
||||||
html_print_image("images/new_message.png", true, array ("title" => __('Create message'))) .'</a>');
|
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image(
|
||||||
|
'images/new_message.png',
|
||||||
|
true,
|
||||||
|
['title' => __('Create message')]
|
||||||
|
).'</a>',
|
||||||
|
];
|
||||||
|
|
||||||
if (!is_ajax ()) {
|
if (!is_ajax()) {
|
||||||
ui_print_page_header (__('Messages'), "images/email_mc.png", false, "", false, $buttons);
|
ui_print_page_header(
|
||||||
|
__('Messages'),
|
||||||
|
'images/email_mc.png',
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
$buttons
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mark_unread) {
|
if ($mark_unread) {
|
||||||
$message_id = get_parameter('id_message');
|
$message_id = get_parameter('id_message');
|
||||||
messages_process_read ($message_id, false);
|
messages_process_read($message_id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($delete_msg) {
|
if ($delete_msg) {
|
||||||
$id = (int) get_parameter ("id");
|
$id = (int) get_parameter('id');
|
||||||
$result = messages_delete_message ($id); //Delete message function will actually check the credentials
|
$result = messages_delete_message($id);
|
||||||
|
// Delete message function will actually check the credentials.
|
||||||
ui_print_result_message ($result,
|
ui_print_result_message(
|
||||||
__('Successfully deleted'),
|
$result,
|
||||||
__('Could not be deleted'));
|
__('Successfully deleted'),
|
||||||
|
__('Could not be deleted')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($multiple_delete) {
|
if ($multiple_delete) {
|
||||||
$ids = (array)get_parameter('delete_multiple', array());
|
$ids = (array) get_parameter('delete_multiple', []);
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$result = db_process_sql_delete ('tmensajes',
|
$result = db_process_sql_delete(
|
||||||
array ('id_mensaje' => $id));
|
'tmensajes',
|
||||||
|
['id_mensaje' => $id]
|
||||||
if ($result === false) {
|
);
|
||||||
break;
|
|
||||||
}
|
if ($result === false) {
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
ui_print_result_message ($result,
|
}
|
||||||
__('Successfully deleted'),
|
|
||||||
__('Not deleted. Error deleting messages'));
|
ui_print_result_message(
|
||||||
|
$result,
|
||||||
|
__('Successfully deleted'),
|
||||||
|
__('Not deleted. Error deleting messages')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($show_sent) { //sent view
|
if ($show_sent) {
|
||||||
$num_messages = messages_get_count_sent($config['id_user']);
|
// Sent view.
|
||||||
if ($num_messages > 0 && !is_ajax()) {
|
$num_messages = messages_get_count_sent($config['id_user']);
|
||||||
echo '<p>' . __('You have') . ' <b>' . $num_messages . '</b> ' .
|
if ($num_messages > 0 && !is_ajax()) {
|
||||||
' ' . __('sent message(s)') . '.</p>';
|
echo '<p>'.__('You have').' <b>'.$num_messages.'</b>'.__('sent message(s)').'.</p>';
|
||||||
}
|
}
|
||||||
$messages = messages_get_overview_sent ('', 'DESC');
|
|
||||||
}
|
$messages = messages_get_overview_sent('', 'DESC');
|
||||||
else { //messages received
|
} else {
|
||||||
$num_messages = messages_get_count ($config["id_user"]);
|
// Messages received.
|
||||||
if ($num_messages > 0 && !is_ajax()) {
|
$num_messages = messages_get_count($config['id_user']);
|
||||||
echo '<p>' . __('You have') . ' <b>' . $num_messages . '</b> ' .
|
if ($num_messages > 0 && !is_ajax()) {
|
||||||
' ' . __('unread message(s)') . '.</p>';
|
echo '<p>'.__('You have').' <b>'.$num_messages.'</b>'.__('unread message(s)').'.</p>';
|
||||||
}
|
}
|
||||||
$messages = messages_get_overview ();
|
|
||||||
|
$messages = messages_get_overview();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty ($messages)) {
|
if (empty($messages)) {
|
||||||
ui_print_info_message (
|
ui_print_info_message(
|
||||||
array('no_close'=>true,
|
[
|
||||||
'message'=> __('There are no messages.') ) );
|
'no_close' => true,
|
||||||
}
|
'message' => __('There are no messages.'),
|
||||||
else {
|
]
|
||||||
$table = new stdClass();
|
);
|
||||||
$table->width = '100%';
|
} else {
|
||||||
$table->class = 'databox data';
|
$table = new stdClass();
|
||||||
$table->cellpadding = 4;
|
$table->width = '100%';
|
||||||
$table->cellspacing = 4;
|
$table->class = 'databox data';
|
||||||
$table->head = array ();
|
$table->cellpadding = 4;
|
||||||
$table->data = array ();
|
$table->cellspacing = 4;
|
||||||
$table->align = array ();
|
$table->head = [];
|
||||||
$table->size = array ();
|
$table->data = [];
|
||||||
|
$table->align = [];
|
||||||
$table->align[0] = "left";
|
$table->size = [];
|
||||||
$table->align[1] = "left";
|
|
||||||
$table->align[2] = "left";
|
$table->align[0] = 'left';
|
||||||
$table->align[3] = "left";
|
$table->align[1] = 'left';
|
||||||
$table->align[4] = "right";
|
$table->align[2] = 'left';
|
||||||
|
$table->align[3] = 'left';
|
||||||
$table->size[0] = "20px";
|
$table->align[4] = 'right';
|
||||||
$table->size[1] = "100px";
|
|
||||||
$table->size[3] = "80px";
|
$table->size[0] = '20px';
|
||||||
$table->size[4] = "60px";
|
$table->size[1] = '100px';
|
||||||
|
$table->size[3] = '80px';
|
||||||
$table->head[0] = __('Status');
|
$table->size[4] = '60px';
|
||||||
if ($show_sent)
|
|
||||||
$table->head[1] = __('Destination');
|
$table->head[0] = __('Status');
|
||||||
else
|
if ($show_sent) {
|
||||||
$table->head[1] = __('Sender');
|
$table->head[1] = __('Destination');
|
||||||
$table->head[2] = __('Subject');
|
} else {
|
||||||
$table->head[3] = __('Timestamp');
|
$table->head[1] = __('Sender');
|
||||||
$table->head[4] = __('Delete'). html_print_checkbox('all_delete_messages', 0, false, true, false);
|
}
|
||||||
|
|
||||||
foreach ($messages as $message_id => $message) {
|
$table->head[2] = __('Subject');
|
||||||
$data = array ();
|
$table->head[3] = __('Timestamp');
|
||||||
$data[0] = '';
|
$table->head[4] = __('Delete').html_print_checkbox('all_delete_messages', 0, false, true, false);
|
||||||
if ($message["status"] == 1) {
|
|
||||||
if ($show_sent) {
|
foreach ($messages as $message_id => $message) {
|
||||||
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
$data = [];
|
||||||
$data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Click to read')));
|
$data[0] = '';
|
||||||
$data[0] .= '</a>';
|
if ($message['status'] == 1) {
|
||||||
}
|
if ($show_sent) {
|
||||||
else {
|
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||||
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&mark_unread=1&id_message='.$message_id.'">';
|
$data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Click to read')]);
|
||||||
$data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Mark as unread')));
|
$data[0] .= '</a>';
|
||||||
$data[0] .= '</a>';
|
} else {
|
||||||
}
|
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&mark_unread=1&id_message='.$message_id.'">';
|
||||||
}
|
$data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Mark as unread')]);
|
||||||
else {
|
$data[0] .= '</a>';
|
||||||
if ($show_sent) {
|
}
|
||||||
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
} else {
|
||||||
$data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read')));
|
if ($show_sent) {
|
||||||
$data[0] .= '</a>';
|
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||||
}
|
$data[0] .= html_print_image('images/email.png', true, ['border' => 0, 'title' => __('Message unread - click to read')]);
|
||||||
else {
|
$data[0] .= '</a>';
|
||||||
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">';
|
} else {
|
||||||
$data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read')));
|
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">';
|
||||||
$data[0] .= '</a>';
|
$data[0] .= html_print_image('images/email.png', true, ['border' => 0, 'title' => __('Message unread - click to read')]);
|
||||||
}
|
$data[0] .= '</a>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($show_sent) {
|
|
||||||
$dest_user = get_user_fullname ($message["dest"]);
|
if ($show_sent) {
|
||||||
if (!$dest_user) {
|
$dest_user = get_user_fullname($message['dest']);
|
||||||
$dest_user = $message["dest"];
|
if (!$dest_user) {
|
||||||
}
|
$dest_user = $message['dest'];
|
||||||
$data[1] = $dest_user;
|
}
|
||||||
}
|
|
||||||
else {
|
$data[1] = $dest_user;
|
||||||
$orig_user = get_user_fullname ($message["sender"]);
|
} else {
|
||||||
if (!$orig_user) {
|
$orig_user = get_user_fullname($message['sender']);
|
||||||
$orig_user = $message["sender"];
|
if (!$orig_user) {
|
||||||
}
|
$orig_user = $message['sender'];
|
||||||
$data[1] = $orig_user;
|
}
|
||||||
}
|
|
||||||
|
$data[1] = $orig_user;
|
||||||
if ($show_sent) {
|
}
|
||||||
$data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
|
||||||
}
|
if ($show_sent) {
|
||||||
else {
|
$data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||||
$data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">';
|
} else {
|
||||||
}
|
$data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">';
|
||||||
if ($message["subject"] == "") {
|
}
|
||||||
$data[2] .= __('No Subject');
|
|
||||||
}
|
if ($message['subject'] == '') {
|
||||||
else {
|
$data[2] .= __('No Subject');
|
||||||
$data[2] .= $message["subject"];
|
} else {
|
||||||
}
|
$data[2] .= $message['subject'];
|
||||||
$data[2] .= '</a>';
|
}
|
||||||
|
|
||||||
$data[3] = ui_print_timestamp(
|
$data[2] .= '</a>';
|
||||||
$message["timestamp"], true,
|
|
||||||
array ("prominent" => "timestamp"));
|
$data[3] = ui_print_timestamp(
|
||||||
|
$message['timestamp'],
|
||||||
if ($show_sent) {
|
true,
|
||||||
$data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'"
|
['prominent' => 'timestamp']
|
||||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">' .
|
);
|
||||||
html_print_image ('images/cross.png', true, array("title" => __('Delete'))) . '</a>'.
|
|
||||||
html_print_checkbox_extended ('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
if ($show_sent) {
|
||||||
}
|
$data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'"
|
||||||
else {
|
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
||||||
$data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'"
|
} else {
|
||||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">' .
|
$data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'"
|
||||||
html_print_image ('images/cross.png', true, array("title" => __('Delete'))) . '</a>'.
|
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
||||||
html_print_checkbox_extended ('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
}
|
||||||
}
|
|
||||||
array_push ($table->data, $data);
|
array_push($table->data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($messages)) {
|
if (!empty($messages)) {
|
||||||
if ($show_sent) {
|
if ($show_sent) {
|
||||||
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">';
|
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">';
|
||||||
}
|
} else {
|
||||||
else {
|
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list">';
|
||||||
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list">';
|
}
|
||||||
}
|
|
||||||
html_print_input_hidden('multiple_delete', 1);
|
html_print_input_hidden('multiple_delete', 1);
|
||||||
html_print_table($table);
|
html_print_table($table);
|
||||||
echo "<div style='float: right;'>";
|
echo "<div style='float: right;'>";
|
||||||
html_print_submit_button(__('Delete'), 'delete_btn',
|
html_print_submit_button(
|
||||||
false, 'class="sub delete"');
|
__('Delete'),
|
||||||
echo "</div>";
|
'delete_btn',
|
||||||
echo "</form>";
|
false,
|
||||||
|
'class="sub delete"'
|
||||||
|
);
|
||||||
|
echo '</div>';
|
||||||
|
echo '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<div style='float: right;'>";
|
echo "<div style='float: right;'>";
|
||||||
echo '<form method="post" style="float:right;" action="index.php?sec=message_list&sec2=operation/messages/message_edit">';
|
echo '<form method="post" style="float:right;" action="index.php?sec=message_list&sec2=operation/messages/message_edit">';
|
||||||
html_print_submit_button (__('Create message'), 'create', false, 'class="sub next" style="margin-right:5px;"');
|
html_print_submit_button(__('Create message'), 'create', false, 'class="sub next" style="margin-right:5px;"');
|
||||||
echo "</form>";
|
echo '</form>';
|
||||||
echo "</div>";
|
echo '</div>';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
|
|
||||||
$('[id^=checkbox-delete_multiple_messages]').change(function(){
|
$('[id^=checkbox-delete_multiple_messages]').change(function(){
|
||||||
if($(this).parent().parent().hasClass('checkselected')){
|
if($(this).parent().parent().hasClass('checkselected')){
|
||||||
$(this).parent().parent().removeClass('checkselected');
|
$(this).parent().parent().removeClass('checkselected');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$(this).parent().parent().addClass('checkselected');
|
$(this).parent().parent().addClass('checkselected');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[id^=checkbox-all_delete_messages]').change(function(){
|
$('[id^=checkbox-all_delete_messages]').change(function(){
|
||||||
if ($("#checkbox-all_delete_messages").prop("checked")) {
|
if ($("#checkbox-all_delete_messages").prop("checked")) {
|
||||||
$('[id^=checkbox-delete_multiple_messages]').parent().parent().addClass('checkselected');
|
$('[id^=checkbox-delete_multiple_messages]').parent().parent().addClass('checkselected');
|
||||||
$(".check_delete_messages").prop("checked", true);
|
$(".check_delete_messages").prop("checked", true);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$('[id^=checkbox-delete_multiple_messages]').parent().parent().removeClass('checkselected');
|
$('[id^=checkbox-delete_multiple_messages]').parent().parent().removeClass('checkselected');
|
||||||
$(".check_delete_messages").prop("checked", false);
|
$(".check_delete_messages").prop("checked", false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user