2012-03-28 Vanessa Gil <vanessa.gil@artica.es>
* pandoradb.sql pandoradb.postgreSQL.sql pandoradb.oracle.sql, extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql, extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql, extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: added 'created_by' to tusuario table and modify 'mensaje' field to tmensajes. * general/header.php godmode/users/configure_user.php include/functions_groups.php include/functions_messages.php include/javascript/jquery.pandora.js operation/menu.php: Added operation: Fixed several bugs and modify sending and receiving messages. * images/email_go.png images/email_edit.png operation/messages/message_list.php operation/messages/message_edit.php: Added files. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5844 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
15d750a69f
commit
51907a0a9b
|
@ -1,3 +1,26 @@
|
|||
2012-03-28 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* pandoradb.sql
|
||||
pandoradb.postgreSQL.sql
|
||||
pandoradb.oracle.sql,
|
||||
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql,
|
||||
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql,
|
||||
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: added 'created_by'
|
||||
to tusuario table and modify 'mensaje' field to tmensajes.
|
||||
|
||||
* general/header.php
|
||||
godmode/users/configure_user.php
|
||||
include/functions_groups.php
|
||||
include/functions_messages.php
|
||||
include/javascript/jquery.pandora.js
|
||||
operation/menu.php: Added operation: Fixed several bugs and
|
||||
modify sending and receiving messages.
|
||||
|
||||
* images/email_go.png
|
||||
images/email_edit.png
|
||||
operation/messages/message_list.php
|
||||
operation/messages/message_edit.php: Added files.
|
||||
|
||||
2012-03-28 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/styles/images/ui-bg_gloss-wave_35_f6a828_500x100.png
|
||||
|
|
|
@ -192,3 +192,13 @@ ALTER TABLE `tusuario` ADD COLUMN `data_section` TEXT NOT NULL;
|
|||
-- Table `treport_content_item`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `treport_content_item` ADD COLUMN `operation` TEXT DEFAULT '';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tusuario`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `tusuario` ADD COLUMN `created_by` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `tmensajes` MODIFY COLUMN `mensaje` TEXT NOT NULL DEFAULT '';
|
||||
|
|
|
@ -187,4 +187,14 @@ ALTER TABLE tusuario ADD (data_section VARCHAR2(255) NOT NULL);
|
|||
-- -----------------------------------------------------
|
||||
-- Table `treport_content_item`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `treport_content_item` ADD (operation` CLOB default '');
|
||||
ALTER TABLE treport_content_item ADD (operation CLOB default '');
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tusuario`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE tusuario ADD (created_by VARCHAR2(255) NOT NULL DEFAULT '';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE tmensajes MODIFY mensaje VARCHAR2(255) NOT NULL DEFAULT '';
|
||||
|
|
|
@ -181,3 +181,12 @@ ALTER TABLE "tusuario" ADD COLUMN "data_section" varchar(255) NOT NULL DEFAULT '
|
|||
-- -----------------------------------------------------
|
||||
ALTER TABLE "treport_content_item" ADD COLUMN "operation" text default '';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tusuario`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE "tusuario" ADD COLUMN "created_by" varchar(255) NOT NULL DEFAULT '';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE "tmensajes" ALTER COLUMN "mensaje" TYPE TEXT;
|
||||
|
|
|
@ -61,7 +61,7 @@ config_check();
|
|||
echo '<div id="dialog_messages" style="display: none"></div>';
|
||||
ui_require_css_file ('dialog');
|
||||
|
||||
echo '<a href="ajax.php?page=operation/messages/message" title="' . __("Message overview") . '" id="show_messages_dialog">';
|
||||
echo '<a href="ajax.php?page=operation/messages/message_list" title="' . __("Message overview") . '" id="show_messages_dialog">';
|
||||
html_print_image ("images/email.png", false,
|
||||
array ("title" => __('You have %d unread message(s)', $msg_cnt), "id" => "yougotmail", "class" => "bot"));
|
||||
echo '</a>';
|
||||
|
|
|
@ -125,6 +125,7 @@ if ($create_user) {
|
|||
$values['comments'] = (string) get_parameter ('comments');
|
||||
$values['is_admin'] = (int) get_parameter ('is_admin', 0);
|
||||
$values['language'] = get_parameter ('language', 'default');
|
||||
$values['created by'] = $config['id_user'];
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
$values['id_skin'] = (int) get_parameter ('skin', 0);
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 763 B |
Binary file not shown.
After Width: | Height: | Size: 720 B |
|
@ -565,9 +565,16 @@ function groups_get_name ($id_group, $returnAllGroup = false) {
|
|||
* @return array An array with all the users or an empty array
|
||||
*/
|
||||
function groups_get_users ($id_group, $filter = false) {
|
||||
global $config;
|
||||
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
|
||||
//Users created by user
|
||||
$filter['created_by'] = $config['id_user'];
|
||||
$users_created = db_get_all_rows_filter ("tusuario", $filter);
|
||||
unset($filter['created_by']);
|
||||
|
||||
$filter['id_grupo'] = $id_group;
|
||||
|
||||
$resulta = array();
|
||||
|
@ -588,7 +595,12 @@ function groups_get_users ($id_group, $filter = false) {
|
|||
$result = array_merge($resulta,$resultb);
|
||||
|
||||
if ($result === false)
|
||||
return array ();
|
||||
return array ();
|
||||
else {
|
||||
if ($users_created !== false) {
|
||||
$result = array_merge($result, $users_created);
|
||||
}
|
||||
}
|
||||
|
||||
//This removes stale users from the list. This can happen if switched to another auth scheme
|
||||
//(internal users still exist) or external auth has users removed/inactivated from the list (eg. LDAP)
|
||||
|
|
|
@ -108,7 +108,7 @@ function messages_delete_message ($id_message) {
|
|||
global $config;
|
||||
|
||||
$where = array(
|
||||
'id_usuario_destino' => $config["id_user"],
|
||||
//'id_usuario_destino' => $config["id_user"],
|
||||
'id_mensaje' => $id_message);
|
||||
return (bool)db_process_sql_delete('tmensajes', $where);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ function messages_process_read ($message_id, $read = true) {
|
|||
function messages_get_message ($message_id) {
|
||||
global $config;
|
||||
|
||||
$sql = sprintf("SELECT id_usuario_origen, subject, mensaje, timestamp
|
||||
$sql = sprintf("SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
||||
FROM tmensajes
|
||||
WHERE id_usuario_destino='%s' AND id_mensaje=%d" , $config["id_user"], $message_id);
|
||||
$row = db_get_row_sql ($sql);
|
||||
|
@ -153,14 +153,34 @@ function messages_get_message ($message_id) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$return["sender"] = $row["id_usuario_origen"];
|
||||
$return["subject"] = $row["subject"];
|
||||
$return["message"] = $row["mensaje"];
|
||||
$return["timestamp"] = $row["timestamp"];
|
||||
|
||||
return $return;
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sent message
|
||||
*
|
||||
* This function abstracts the database backend so it can simply be replaced with another system
|
||||
*
|
||||
* @param int $message_id
|
||||
*
|
||||
* @return mixed False if it doesn't exist or a filled array otherwise
|
||||
*/
|
||||
function messages_get_message_sent ($message_id) {
|
||||
global $config;
|
||||
|
||||
$sql = sprintf("SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
||||
FROM tmensajes
|
||||
WHERE id_usuario_origen='%s' AND id_mensaje=%d" , $config["id_user"], $message_id);
|
||||
$row = db_get_row_sql ($sql);
|
||||
|
||||
if (empty ($row)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Counts private messages
|
||||
*
|
||||
|
@ -185,6 +205,25 @@ function messages_get_count ($user = false, $incl_read = false) {
|
|||
return (int) db_get_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts sended messages
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @return int The number of messages this user has sent
|
||||
*/
|
||||
function messages_get_count_sent ($user = false) {
|
||||
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
|
||||
*
|
||||
|
@ -229,4 +268,48 @@ function messages_get_overview ($order = "status", $order_dir = "ASC") {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sent message overview in array
|
||||
*
|
||||
* @param string $order How to order them valid:
|
||||
* (status (default), subject, timestamp, sender)
|
||||
* @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending)
|
||||
*
|
||||
* @return int The number of messages this user has
|
||||
*/
|
||||
function messages_get_overview_sent ($order = "timestamp", $order_dir = "ASC") {
|
||||
global $config;
|
||||
|
||||
switch ($order) {
|
||||
case "timestamp":
|
||||
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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
$(document).ready (function () {
|
||||
$("a#show_messages_dialog").click (function () {
|
||||
jQuery.get ("ajax.php",
|
||||
{"page": "operation/messages/message"},
|
||||
{"page": "operation/messages/message_list"},
|
||||
function (data, status) {
|
||||
$("#dialog_messages").hide ()
|
||||
.empty ()
|
||||
|
|
|
@ -286,11 +286,11 @@ if (check_acl ($config['id_user'], 0, "AR")) {
|
|||
// Messages
|
||||
$menu["messages"]["text"] = __('Messages');
|
||||
$menu["messages"]["refr"] = 0;
|
||||
$menu["messages"]["sec2"] = "operation/messages/message";
|
||||
$menu["messages"]["sec2"] = "operation/messages/message_list";
|
||||
$menu["messages"]["id"] = "oper-messages";
|
||||
|
||||
$sub = array ();
|
||||
$sub["operation/messages/message&new_msg=1"]["text"] = __('New message');
|
||||
$sub["operation/messages/message_edit&new_msg=1"]["text"] = __('New message');
|
||||
|
||||
$menu["messages"]["sub"] = $sub;
|
||||
|
||||
|
|
|
@ -1,273 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// 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
|
||||
// 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.
|
||||
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
require_once ("include/functions_messages.php");
|
||||
require_once ('include/functions_users.php');
|
||||
require_once ('include/functions_groups.php');
|
||||
|
||||
//First Queries - also inits the variables so it can be passed along
|
||||
$dest_user = get_parameter ("dest_user");
|
||||
$dest_group = get_parameter ("dest_group");
|
||||
$subject = get_parameter ("subject");
|
||||
$message = get_parameter ("mensaje");
|
||||
$send_message = (bool)get_parameter('send_mes', false);
|
||||
|
||||
if (isset ($_GET["new_msg"]))
|
||||
ui_print_page_header (__('Messages'). " » ".__('New message'), "images/email.png", false, "", false, "" );
|
||||
elseif (isset ($_GET["read_message"]))
|
||||
ui_print_page_header (__('Messages'). " » ".__('Read message'), "images/email.png", false, "", false, "" );
|
||||
else
|
||||
if (empty ($config["pure"]) && !is_ajax ())
|
||||
ui_print_page_header (__('Messages'). " » ".__('Message overview'), "images/email.png", false, "", false, "" );
|
||||
|
||||
if (isset ($_GET["delete_message"])) {
|
||||
$id = (int) get_parameter ("id");
|
||||
$result = messages_delete_message ($id); //Delete message function will actually check the credentials
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
$message_sended = false;
|
||||
|
||||
if (!empty ($dest_user) && isset ($_GET["send_message"])) {
|
||||
// Create message
|
||||
$return = messages_create_message ($config["id_user"], $dest_user, $subject, $message);
|
||||
|
||||
if ($return) {
|
||||
$message_sended = true;
|
||||
}
|
||||
|
||||
ui_print_result_message ($return,
|
||||
__('Message successfully sent to user %s', get_user_fullname ($dest_user)),
|
||||
__('Error sending message to user %s', get_user_fullname ($dest_user)));
|
||||
}
|
||||
|
||||
if (!empty ($dest_group) && isset ($_GET["send_message"])) {
|
||||
// Create message to groups
|
||||
$return = messages_create_group ($config["id_user"], $dest_group, $subject, $message);
|
||||
|
||||
if ($return) {
|
||||
$message_sended = true;
|
||||
}
|
||||
|
||||
ui_print_result_message ($return,
|
||||
__('Message successfully sent'),
|
||||
__('Error sending message to group %s', groups_get_name ($dest_group)));
|
||||
}
|
||||
|
||||
$new_msg = (bool) get_parameter("new_msg");
|
||||
|
||||
if ($send_message && !$message_sended && !$new_msg) {
|
||||
ui_print_error_message("Error sending message, please choose group or user.");
|
||||
}
|
||||
|
||||
if (isset ($_GET["mark_read"]) || isset ($_GET["mark_unread"])) {
|
||||
$id_r = (int) get_parameter ("mark_read");
|
||||
$id_u = (int) get_parameter ("mark_unread");
|
||||
if (!empty ($id_r)) {
|
||||
//Set to read
|
||||
messages_process_read ($id_r);
|
||||
} elseif (!empty ($id_u)) {
|
||||
//Set to unread
|
||||
messages_process_read ($id_u, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset ($_GET["new_msg"]) || ($send_message && !$message_sended)) { //create message
|
||||
|
||||
// Header
|
||||
// ui_print_page_header (__('Messages'). " » ".__('New message'), "images/email.png", false, "", false, "" );
|
||||
|
||||
echo '<form method="POST" action="index.php?sec=messages&sec2=operation/messages/message&send_message=1">
|
||||
<table width="98%" class="databox_color" cellpadding="4" cellspacing="4">
|
||||
<tr>
|
||||
<td class="datos">'.__('Message from').':</td>
|
||||
<td class="datos"><b>' . ui_print_username ($config["id_user"], true).'</b></td>
|
||||
</tr><tr>
|
||||
<td class="datos2">'.__('Message to').':</td>
|
||||
<td class="datos2">';
|
||||
|
||||
$users_full = groups_get_users(array_keys(users_get_groups()));
|
||||
|
||||
$users = array();
|
||||
foreach ($users_full as $user_id => $user_info) {
|
||||
$users[$user_info['id_user']] = $user_info['fullname'];
|
||||
}
|
||||
|
||||
$groups = users_get_groups ($config["id_user"], "AR"); //Get a list of all groups
|
||||
|
||||
html_print_select ($users, "dest_user", $dest_user, '', __('-Select user-'), false, false, false, '', false);
|
||||
echo ' - '.__('OR').' - ';
|
||||
html_print_select_groups($config["id_user"], "AR", true, "dest_group", $dest_group, '', __('-Select group-'), false, false, false, '', false);
|
||||
|
||||
echo '</td></tr><tr><td class="datos">'.__('Subject').':</td><td class="datos">';
|
||||
html_print_input_text ("subject", urldecode($subject), '', 50, 70, false);
|
||||
|
||||
echo '</td></tr><tr><td class="datos2">'.__('Message').':</td><td class="datos">';
|
||||
|
||||
html_print_textarea ("mensaje", 15, 70, $message, '', false);
|
||||
|
||||
echo '</td></tr><tr><td></td><td colspan="3">';
|
||||
|
||||
html_print_submit_button (__('Send message'), 'send_mes', false, 'class="sub wand"', false);
|
||||
|
||||
echo '</td></tr></table></form>';
|
||||
|
||||
} elseif (isset ($_GET["read_message"])) {
|
||||
|
||||
// ui_print_page_header (__('Messages'). " » ".__('Read message'), "images/email.png", false, "", false, "" );
|
||||
|
||||
$message_id = (int) get_parameter ("read_message");
|
||||
$message = messages_get_message ($message_id);
|
||||
|
||||
if ($message == false) {
|
||||
echo '<div>'.__('This message does not exist in the system').'</div>';
|
||||
return; //Move out of this page and go processing other pages
|
||||
}
|
||||
|
||||
messages_process_read ($message_id);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message&new_msg=1">
|
||||
<table class="databox_color" width="98%" cellpadding="4" cellspacing="4">
|
||||
<tr><td class="datos">'.__('Message from').':</td>
|
||||
<td class="datos"><b>' . ui_print_username ($message["sender"], true).' '.__('at').' ' . ui_print_timestamp ($message["timestamp"], true, array ("prominent" => "timestamp")).'</b></td></tr>';
|
||||
|
||||
// Subject
|
||||
echo '<tr><td class="datos2">'.__('Subject').':</td>
|
||||
<td class="datos2" valign="top"><b>'.$message["subject"].'</b></td></tr>';
|
||||
|
||||
// text
|
||||
|
||||
$order = array("\r\n", "\n", "\r");
|
||||
$replace = '<br />';
|
||||
$parsed_message = str_replace($order, $replace, $message["message"]);
|
||||
|
||||
echo '<tr><td class="datos" valign="top">'.__('Message').':</td>
|
||||
<td class="datos">'.$parsed_message.'</td></tr></table>';
|
||||
|
||||
//Prevent RE: RE: RE:
|
||||
if (strstr ($message["subject"], "RE:")) {
|
||||
$new_subj = $message["subject"];
|
||||
} else {
|
||||
$new_subj = "RE: ".$message["subject"];
|
||||
}
|
||||
|
||||
|
||||
//Start the message much like an e-mail reply
|
||||
$new_msg = "\n\n\nOn ".date ($config["date_format"], $message["timestamp"]).' '.get_user_fullname ($message["sender"]).' '.__('wrote').":\n\n".$message["message"];
|
||||
|
||||
html_print_input_hidden ("dest_user", $message["sender"]);
|
||||
html_print_input_hidden ("subject", urlencode ($new_subj));
|
||||
html_print_input_hidden ("message", urlencode ($new_msg));
|
||||
|
||||
echo '<div style="text-align:right; width:98%;">';
|
||||
html_print_submit_button (__('Reply'), "reply_btn", false, 'class="sub next"');
|
||||
echo '</div></form>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset ($_GET["read_message"]) || !isset ($_GET["new_msg"]) && !($send_message && !$message_sended)) {
|
||||
// if (empty ($config["pure"]) && !is_ajax ()) {
|
||||
// ui_print_page_header (__('Messages'). " » ".__('Message overview'), "images/email.png", false, "", false, "" );
|
||||
// }
|
||||
|
||||
//Get number of messages
|
||||
$num_messages = messages_get_count ($config["id_user"]);
|
||||
|
||||
$order = get_parameter ("msg_overview_order", "status");
|
||||
$order_dir = get_parameter ("msg_overview_orddir", "ASC");
|
||||
|
||||
$messages = messages_get_overview ($order, $order_dir);
|
||||
|
||||
if ($num_messages > 0 && empty ($config["pure"]) && !is_ajax ()) {
|
||||
echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.html_print_image ("images/email.png", true).' '.__('unread message(s)').'.</p>';
|
||||
}
|
||||
|
||||
if (empty ($messages)) {
|
||||
echo '<div class="nf">'.__('There are no messages').'</div>';
|
||||
} else {
|
||||
$table->width = "98%";
|
||||
$table->class = "databox";
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->head = array ();
|
||||
$table->data = array ();
|
||||
$table->align = array ();
|
||||
$table->size = array ();
|
||||
|
||||
$table->head[0] = __('Status');
|
||||
$table->head[1] = __('Sender');
|
||||
$table->head[2] = __('Subject');
|
||||
$table->head[3] = __('Timestamp');
|
||||
$table->head[4] = __('Delete');
|
||||
|
||||
$table->align[0] = "center";
|
||||
$table->align[1] = "center";
|
||||
$table->align[2] = "center";
|
||||
$table->align[3] = "center";
|
||||
$table->align[4] = "center";
|
||||
|
||||
$table->size[0] = "20px";
|
||||
$table->size[1] = "120px";
|
||||
$table->size[3] = "80px";
|
||||
$table->size[4] = "20px";
|
||||
|
||||
foreach ($messages as $message_id => $message) {
|
||||
$data = array ();
|
||||
$data[0] = '';
|
||||
if ($message["status"] == 1) {
|
||||
$data[0] .= '<a href="index.php?sec=messages&sec2=operation/messages/message&mark_unread='.$message_id.'">';
|
||||
$data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Mark as unread')));
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] .= '<a href="index.php?sec=messages&sec2=operation/messages/message&read_message='.$message_id.'">';
|
||||
$data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read')));
|
||||
$data[0] .= '</a>';
|
||||
}
|
||||
|
||||
$data[1] = ui_print_username ($message["sender"], true);
|
||||
|
||||
$data[2] = '<a href="index.php?sec=messages&sec2=operation/messages/message&read_message='.$message_id.'">';
|
||||
if ($message["subject"] == "") {
|
||||
$data[2] .= __('No Subject');
|
||||
} else {
|
||||
$data[2] .= $message["subject"];
|
||||
}
|
||||
$data[2] .= '</a>';
|
||||
|
||||
$data[3] = ui_print_timestamp ($message["timestamp"], true, array ("prominent" => "timestamp"));
|
||||
|
||||
$data[4] = '<a href="index.php?sec=messages&sec2=operation/messages/message&delete_message=1&id='.$message_id.'"
|
||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">' .
|
||||
html_print_image ('images/cross.png', true, array("title" => __('Delete'))) . '</a>'; //"delete_message", "images/cross.png", $message_id, 'border:0px;', true);
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message">';
|
||||
html_print_table ($table);
|
||||
echo '</form>';
|
||||
}
|
||||
echo '<div class="action-buttons" style="width:98%">';
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message&new_msg=1">';
|
||||
html_print_submit_button (__('New message'), "send_mes", false, 'class="sub next"');
|
||||
echo '</form></div>';
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// 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
|
||||
// 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.
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
require_once ('include/functions_users.php');
|
||||
require_once ('include/functions_groups.php');
|
||||
require_once ('include/functions_io.php');
|
||||
|
||||
//params
|
||||
$new_msg = get_parameter('new_msg', 0);
|
||||
$dst_user = get_parameter('dst_user');
|
||||
$dst_group = get_parameter('dst_group');
|
||||
$subject = get_parameter('subject', '');
|
||||
$message = get_parameter('message');
|
||||
$read_message = get_parameter('read_message', 0);
|
||||
$reply = get_parameter('reply', 0);
|
||||
$show_sent = get_parameter('show_sent', 0);
|
||||
|
||||
$buttons['message_list'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=message&sec2=operation/messages/message_list">' .
|
||||
html_print_image("images/email.png", true, array ("title" => __('Message list'))) .'</a>');
|
||||
|
||||
$buttons['sent_messages'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=message&sec2=operation/messages/message_list&show_sent=1">' .
|
||||
html_print_image("images/email_go.png", true, array ("title" => __('Sent messages'))) .'</a>');
|
||||
|
||||
$buttons['create_message'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=message&sec2=operation/messages/message_edit">' .
|
||||
html_print_image("images/email_edit.png", true, array ("title" => __('Create message'))) .'</a>');
|
||||
|
||||
// Header
|
||||
ui_print_page_header (__('Messages'), "images/email.png", false, "", false, $buttons);
|
||||
|
||||
//read a message
|
||||
if ($read_message) {
|
||||
$message_id = (int) get_parameter ("id_message");
|
||||
if ($show_sent) {
|
||||
$message = messages_get_message_sent ($message_id);
|
||||
} else {
|
||||
$message = messages_get_message ($message_id);
|
||||
messages_process_read ($message_id);
|
||||
}
|
||||
|
||||
if ($message == false) {
|
||||
echo '<div>'.__('This message does not exist in the system').'</div>';
|
||||
return; //Move out of this page and go processing other pages
|
||||
}
|
||||
|
||||
$user_name = get_user_fullname ($message["id_usuario_origen"]);
|
||||
if (!$user_name) {
|
||||
$user_name = $message["id_usuario_origen"];
|
||||
}
|
||||
|
||||
$table->width = '98%';
|
||||
$table->data = array();
|
||||
|
||||
$table->data[0][0] = __('From:');
|
||||
$table->data[0][1] = $user_name.' '.__('at').' ' . ui_print_timestamp ($message["timestamp"], true, array ("prominent" => "timestamp"));
|
||||
|
||||
$table->data[1][0] = __('To:');
|
||||
$table->data[1][1] = $message["id_usuario_destino"];
|
||||
|
||||
$table->data[2][0] = __('Subject');
|
||||
$table->data[2][1] = html_print_input_text_extended ("subject", $message["subject"], 'text-subject', '', 50, 70, true, false, '', 'readonly');
|
||||
|
||||
$order = array("\r\n", "\n", "\r");
|
||||
$replace = '<br />';
|
||||
$parsed_message = str_replace($order, $replace, $message["mensaje"]);
|
||||
|
||||
$table->data[3][0] = __('Message');
|
||||
$table->data[3][1] = html_print_textarea ("message", 15, 255, $message["mensaje"], 'readonly', true);
|
||||
|
||||
//Prevent RE: RE: RE:
|
||||
if (strstr ($message["subject"], "RE:")) {
|
||||
$new_subj = $message["subject"];
|
||||
} else {
|
||||
$new_subj = "RE: ".$message["subject"];
|
||||
}
|
||||
|
||||
//Start the message much like an e-mail reply
|
||||
$new_msg = "\n\n\nOn ".date ($config["date_format"], $message["timestamp"]).' '.$user_name.' '.__('wrote').":\n\n".$message["mensaje"];
|
||||
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'">';
|
||||
html_print_table($table);
|
||||
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
|
||||
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message_edit&new_msg=1&reply=1">';
|
||||
html_print_input_hidden ("dst_user", $message["id_usuario_origen"]);
|
||||
html_print_input_hidden ("subject", $new_subj);
|
||||
html_print_input_hidden ("message", $new_msg);
|
||||
html_print_input_hidden ("orig_user", $message["id_usuario_destino"]);
|
||||
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
|
||||
html_print_submit_button (__('Reply'), 'reply', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Create message (destination user)
|
||||
if (($new_msg) && (!empty ($dst_user)) && (!$reply)) {
|
||||
$return = messages_create_message ($config["id_user"], $dst_user, $subject, $message);
|
||||
|
||||
$user_name = get_user_fullname ($dst_user);
|
||||
if (!$user_name) {
|
||||
$user_name = $dst_user;
|
||||
}
|
||||
ui_print_result_message ($return,
|
||||
__('Message successfully sent to user %s', $user_name),
|
||||
__('Error sending message to user %s', $user_name));
|
||||
}
|
||||
|
||||
// Create message (destination group)
|
||||
if (($new_msg) && (!empty ($dst_group)) && (!$reply)) {
|
||||
$return = messages_create_group ($config["id_user"], $dst_group, $subject, $message);
|
||||
|
||||
ui_print_result_message ($return,
|
||||
__('Message successfully sent'),
|
||||
__('Error sending message to group %s', groups_get_name ($dst_group)));
|
||||
}
|
||||
|
||||
//message creation form
|
||||
|
||||
//user info
|
||||
$own_info = get_user_info ($config['id_user']);
|
||||
|
||||
$table->width = '98%';
|
||||
|
||||
$table->data = array();
|
||||
|
||||
$table->data[0][0] = __('From:');
|
||||
|
||||
if (!empty($own_info['fullname'])) {
|
||||
$table->data[0][1] = $own_info['fullname'];
|
||||
} else {
|
||||
$table->data[0][1] = $config['id_user'];
|
||||
}
|
||||
|
||||
$table->data[1][0] = __('To:');
|
||||
|
||||
$users_full = groups_get_users (array_keys(users_get_groups()));
|
||||
$users = array();
|
||||
foreach ($users_full as $user_id => $user_info) {
|
||||
$users[$user_info['id_user']] = $user_info['fullname'];
|
||||
}
|
||||
|
||||
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
|
||||
$return_all_groups = true;
|
||||
else
|
||||
$return_all_groups = false;
|
||||
|
||||
$groups = users_get_groups ($config["id_user"], "AR"); //Get a list of all groups
|
||||
|
||||
$table->data[1][1] = html_print_select ($users, "dst_user", $dst_user, '', __('Select user'), false, true, false, '', false);
|
||||
$table->data[1][1] .= ' '.__('OR').' ';
|
||||
$table->data[1][1] .= html_print_select_groups($config['id_user'], "AR", $return_all_groups, 'dst_group', $dst_group, '', __('Select group'), '', true);
|
||||
|
||||
$table->data[2][0] = __('Subject');
|
||||
$table->data[2][1] = html_print_input_text ("subject", $subject, '', 50, 70, true);
|
||||
|
||||
$table->data[3][0] = __('Message');
|
||||
$table->data[3][1] = html_print_textarea ("message", 15, 255, $message, '', true);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message_edit&new_msg=1">';
|
||||
html_print_table($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button (__('Send message'), 'send_mes', false, 'class="sub wand"');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// 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
|
||||
// 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.
|
||||
|
||||
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);
|
||||
$mark_unread = get_parameter('mark_unread', 0);
|
||||
|
||||
$active_list = true;
|
||||
$active_sent = false;
|
||||
if ($show_sent) {
|
||||
$active_list = false;
|
||||
$active_sent = true;
|
||||
}
|
||||
|
||||
$buttons['message_list'] = array('active' => $active_list,
|
||||
'text' => '<a href="index.php?sec=message&sec2=operation/messages/message_list">' .
|
||||
html_print_image("images/email.png", true, array ("title" => __('Message list'))) .'</a>');
|
||||
|
||||
$buttons['sent_messages'] = array('active' => $active_sent,
|
||||
'text' => '<a href="index.php?sec=message&sec2=operation/messages/message_list&show_sent=1">' .
|
||||
html_print_image("images/email_go.png", true, array ("title" => __('Sent messages'))) .'</a>');
|
||||
|
||||
$buttons['create_message'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=message&sec2=operation/messages/message_edit">' .
|
||||
html_print_image("images/email_edit.png", true, array ("title" => __('Create message'))) .'</a>');
|
||||
|
||||
if (!is_ajax ()) {
|
||||
ui_print_page_header (__('Messages'), "images/email.png", false, "", false, $buttons);
|
||||
}
|
||||
|
||||
if ($mark_unread) {
|
||||
$message_id = get_parameter('id_message');
|
||||
messages_process_read ($message_id, false);
|
||||
}
|
||||
|
||||
if ($delete_msg) {
|
||||
$id = (int) get_parameter ("id");
|
||||
$result = messages_delete_message ($id); //Delete message function will actually check the credentials
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = db_process_sql_delete ('tmensajes',
|
||||
array ('id_mensaje' => $id));
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Not deleted. Error deleting messages'));
|
||||
}
|
||||
|
||||
if ($show_sent) { //sent view
|
||||
$num_messages = messages_get_count_sent($config['id_user']);
|
||||
if ($num_messages > 0 && !is_ajax()) {
|
||||
echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.' '.__('sent message(s)').'.</p>';
|
||||
}
|
||||
$messages = messages_get_overview_sent ('', 'DESC');
|
||||
} else { //messages received
|
||||
$num_messages = messages_get_count ($config["id_user"]);
|
||||
if ($num_messages > 0 && !is_ajax()) {
|
||||
echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.' '.__('unread message(s)').'.</p>';
|
||||
}
|
||||
$messages = messages_get_overview ();
|
||||
}
|
||||
|
||||
if (empty ($messages)) {
|
||||
echo '<div class="nf">'.__('There are no messages').'</div>';
|
||||
} else {
|
||||
$table->width = "98%";
|
||||
$table->class = "databox";
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->head = array ();
|
||||
$table->data = array ();
|
||||
$table->align = array ();
|
||||
$table->size = array ();
|
||||
|
||||
$table->align[0] = "center";
|
||||
$table->align[1] = "center";
|
||||
$table->align[2] = "center";
|
||||
$table->align[3] = "center";
|
||||
$table->align[4] = "center";
|
||||
|
||||
$table->size[0] = "20px";
|
||||
$table->size[1] = "100px";
|
||||
$table->size[3] = "80px";
|
||||
$table->size[4] = "60px";
|
||||
|
||||
$table->head[0] = __('Status');
|
||||
if ($show_sent)
|
||||
$table->head[1] = __('To');
|
||||
else
|
||||
$table->head[1] = __('From');
|
||||
$table->head[2] = __('Subject');
|
||||
$table->head[3] = __('Timestamp');
|
||||
$table->head[4] = __('Delete'). html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
|
||||
|
||||
foreach ($messages as $message_id => $message) {
|
||||
$data = array ();
|
||||
$data[0] = '';
|
||||
if ($message["status"] == 1) {
|
||||
if ($show_sent) {
|
||||
$data[0] .= '<a href="index.php?sec=messages&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||
$data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Click to read')));
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] .= '<a href="index.php?sec=messages&sec2=operation/messages/message_list&mark_unread=1&id_message='.$message_id.'">';
|
||||
$data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Mark as unread')));
|
||||
$data[0] .= '</a>';
|
||||
}
|
||||
} else {
|
||||
if ($show_sent) {
|
||||
$data[0] .= '<a href="index.php?sec=messages&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||
$data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read')));
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] .= '<a href="index.php?sec=messages&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">';
|
||||
$data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read')));
|
||||
$data[0] .= '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($show_sent) {
|
||||
$dest_user = get_user_fullname ($message["dest"]);
|
||||
if (!$dest_user) {
|
||||
$dest_user = $message["dest"];
|
||||
}
|
||||
$data[1] = $dest_user;
|
||||
} else {
|
||||
$orig_user = get_user_fullname ($message["sender"]);
|
||||
if (!$orig_user) {
|
||||
$orig_user = $message["sender"];
|
||||
}
|
||||
$data[1] = $orig_user;
|
||||
}
|
||||
|
||||
if ($show_sent) {
|
||||
$data[2] = '<a href="index.php?sec=messages&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||
} else {
|
||||
$data[2] = '<a href="index.php?sec=messages&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">';
|
||||
}
|
||||
if ($message["subject"] == "") {
|
||||
$data[2] .= __('No Subject');
|
||||
} else {
|
||||
$data[2] .= $message["subject"];
|
||||
}
|
||||
$data[2] .= '</a>';
|
||||
|
||||
$data[3] = ui_print_timestamp ($message["timestamp"], true, array ("prominent" => "timestamp"));
|
||||
|
||||
if ($show_sent) {
|
||||
$data[4] = '<a href="index.php?sec=messages&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'"
|
||||
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[]', $message_id, false, false, '', 'class="check_delete"', true);
|
||||
} else {
|
||||
$data[4] = '<a href="index.php?sec=messages&sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'"
|
||||
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[]', $message_id, false, false, '', 'class="check_delete"', true);
|
||||
}
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
if ($show_sent)
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message_list&show_sent=1&multiple_delete=1">';
|
||||
else
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message_list&multiple_delete=1">';
|
||||
html_print_table($table);
|
||||
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
|
||||
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo '<form method="post" action="index.php?sec=messages&sec2=operation/messages/message_edit">';
|
||||
echo '<div class="action-buttons" style="width: 98%;">';
|
||||
html_print_submit_button (__('Create message'), 'create', false, 'class="sub next"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
|
@ -516,7 +516,7 @@ CREATE TABLE IF NOT EXISTS `tmensajes` (
|
|||
`id_mensaje` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_usuario_origen` varchar(60) NOT NULL default '',
|
||||
`id_usuario_destino` varchar(60) NOT NULL default '',
|
||||
`mensaje` tinytext NOT NULL,
|
||||
`mensaje` text NOT NULL DEFAULT '',
|
||||
`timestamp` bigint (20) unsigned NOT NULL default '0',
|
||||
`subject` varchar(255) NOT NULL default '',
|
||||
`estado` int(4) unsigned NOT NULL default '0',
|
||||
|
@ -777,6 +777,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
|
|||
`shortcut_data` text default '',
|
||||
`section` TEXT NOT NULL,
|
||||
`data_section` TEXT NOT NULL,
|
||||
`created_by` TEXT NOT NULL,
|
||||
UNIQUE KEY `id_user` (`id_user`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue