@ -1,4 +1,4 @@
<?php // $Id: new_message.php 10204 2006-11-26 20:46:53Z pco ol $
<?php // $Id: new_message.php 10675 2007-01-11 13:03:10Z bm ol $
/*
==============================================================================
Dokeos - elearning and course management software
@ -75,11 +75,8 @@ $nameTools = get_lang('ComposeMessage');
*/
function show_compose_to_any($user_id)
{
$online_user_list = get_online_user_list($user_id,$_name,$width,$size);
$default['title'] = "Please enter a title";
$default['user_list'] = $receiver_id;
$online_user_list = get_online_user_list($user_id);
$default['user_list'] = $user_id;
manage_form($default, $online_user_list);
}
@ -95,25 +92,25 @@ function show_compose_reply_to_message($message_id, $receiver_id)
die();
}
echo get_lang('To').': < strong > '. GetFullUserName($row[1],$mysqlMainDb ).'< / strong > ';
echo get_lang('To').': < strong > '. GetFullUserName($row[1]).'< / strong > ';
$default['title'] = "Please enter a title";
$default['user_list'] = $row[1];
manage_form($default, $select_from_user_list );
manage_form($default);
}
function show_compose_to_user($receiver_id)
{
echo get_lang('To').': < strong > '. GetFullUserName($receiver_id,$mysqlMainDb ).'< / strong > ';
echo get_lang('To').': < strong > '. GetFullUserName($receiver_id).'< / strong > ';
$default['title'] = "Please enter a title";
$default['user_list'] = $receiver_id;
manage_form($default, $select_from_user_list );
manage_form($default);
}
function manage_form($default, $select_from_user_list)
function manage_form($default, $select_from_user_list = null )
{
$form = new FormValidator('compose_message');
if (isset($select_from_user_list))
@ -131,19 +128,24 @@ function manage_form($default, $select_from_user_list)
if( $form->validate() )
{
$values = $form->exportValues();
$receiver_user_id = $values['user_list'];
$title = mysql_real_escape_string($values['title']);
$content = mysql_real_escape_string($values['content']);
//all is well, send the message
$id_tmp = $_SESSION['_uid'].$_POST['user_list'].date('d-D-w-m-Y-H-s').
microtime().rand();
$id_tmp = api_get_user_id().$receiver_user_id.date('d-D-w-m-Y-H-s').microtime().rand();
$id_msg = md5($id_tmp);
$query = "INSERT INTO `".MESSAGES_DATABASE."` ( `id`, `id_sender`, `id_receiver`, `status`, `date`, `title`, `content` ) ".
" VALUES (".
"' ".$id_msg ."' , '".$_SESSION['_uid']."', '".$_POST['user_list'] ."', '1', '".date('Y-m-d H:i:s')."','".$_POST[' title'] ."','".$_POST[' content'] ."'".
"' ".$id_msg ."' , '".api_get_user_id()."', '".$receiver_user_id ."', '1', '".date('Y-m-d H:i:s')."','".$title."','".$content."'".
");";
@api_sql_query($query,__FILE__,__LINE__);
display_success_message($_POST['user_list']);
display_success_message($receiver_user_id);
}
else
{
$form->display();
}
$form->display();
}
/*
@ -159,7 +161,7 @@ if(!isset($_POST['compose']))
if(isset($_GET['re_id']))
{
$message_id = $_GET['re_id'];
$receiver_id = $_SESSION['_uid'] ;
$receiver_id = api_get_user_id() ;
show_compose_reply_to_message($message_id, $receiver_id);
}
else if(isset($_GET['send_to_user']))
@ -173,7 +175,7 @@ if(!isset($_POST['compose']))
}
else
{
if(isset($_SESSION['_uid'] ) & & isset($_POST['user_list']) & & isset($_POST['content']))
if(api_get_user_id( ) & & isset($_POST['user_list']) & & isset($_POST['content']))
{
$default['title'] = $_POST['title'];
$default['user_list'] = $_POST['user_list'];