false,
'text' => '' .
html_print_image("images/email.png", true, array ("title" => __('Message list'))) .'');
$buttons['sent_messages'] = array('active' => false,
'text' => '' .
html_print_image("images/email_go.png", true, array ("title" => __('Sent messages'))) .'');
$buttons['create_message'] = array('active' => true,
'text' => '' .
html_print_image("images/email_edit.png", true, array ("title" => __('Create message'))) .'');
// 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 '
'.__('This message does not exist in the system').'
';
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 = '
';
$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 '";
echo '';
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 '