<?php require_once('includes/requirelogin.inc.php'); require_once('includes/message.inc.php'); $msg_id=0+TGET('msg_id'); $mb_id=current_mb_id(); $pool=TGET('pool'); $op=TGET('op'); $timezone_bias_seconds=get_user_time_zone()*60; $dataset['ENTERING']=array(0); if (is_valid_compere()) $USE_THEME_BY_USER_ID=$mb_id; $DBConn->connect(); $msgs=db_load_messages($DBConn,$msg_id); $msg=$msgs[0]; if (!$msgs || ($msg['mb_id_to']!=$mb_id && $msg['mb_id_from']!=$mb_id)) { redirect("qx-cmd-message.list.html"); return; } $msg_attrib=db_get_message_attrib($DBConn,$msg['msg_id']); $dataset+=get_message_sender_name_dataset($msg,$msg_attribs); $dataset+=get_message_receiver_name_dataset($msg,$msg_attribs); if (!$pool) { if ($msg['mb_id_to']==$msg['mb_id_from']) $pool='inbox'; else if ($msg['mb_id_to']==$mb_id) $pool='inbox'; else if ($msg['mb_id_from']==$mb_id) $pool='outbox'; else $pool='inbox'; } $dataset['pool']=$pool; $dataset['otherpool']=$pool=='inbox'?'outbox':'inbox'; if ($pool=='inbox' && $msg['mb_id_to']==$mb_id) { $dataset['INBOX']=array(0); $dataset['msg_id_prev']=db_load_message_neighbour_id($DBConn,$msg_id,false,$mb_id); $dataset['msg_id_next']=db_load_message_neighbour_id($DBConn,$msg_id,true,$mb_id); $dataset['msg_id_prev_unread']=db_load_unread_message_neighbour_id($DBConn,$mb_id,$msg_id,false,$mb_id); $dataset['msg_id_next_unread']=db_load_unread_message_neighbour_id($DBConn,$mb_id,$msg_id,true,$mb_id); } if ($pool=='outbox' && $msg['mb_id_from']==$mb_id) { $dataset['OUTBOX']=array(0); $dataset['msg_id_prev']=db_load_message_neighbour_id($DBConn,$msg_id,false,null,$mb_id); $dataset['msg_id_next']=db_load_message_neighbour_id($DBConn,$msg_id,true,null,$mb_id); $dataset['msg_id_prev_unread']=db_load_unread_message_neighbour_id($DBConn,$mb_id,$msg_id,false,null,$mb_id); $dataset['msg_id_next_unread']=db_load_unread_message_neighbour_id($DBConn,$mb_id,$msg_id,true,null,$mb_id); } $dataset['PAGING-PANEL']=array(0); $dataset['HAS-PREV']=$dataset['msg_id_prev']?array(0):array(); $dataset['HAS-NEXT']=$dataset['msg_id_next']?array(0):array(); $dataset['HAS-PREV-UNREAD']=$dataset['msg_id_prev_unread']?array(0):array(); $dataset['HAS-NEXT-UNREAD']=$dataset['msg_id_next_unread']?array(0):array(); $msg+=prepare_message_from_display_type($msg,$mb_id); switch ($msg['msg_type']) { case 'RESERVE': $msg['RESERVE']=array(0); $reservation=db_load_reservation( $DBConn, $msg['msg_lctr_id'], $msg['msg_st_id'], $msg['mb_id_from'] ); if ($reservation && !$reservation['rsv_timestamp_confirmed']) $msg['DECIDING']=array(0); break; } $dataset+=array_key_prepend(split_datetime($msg['fh_timestamp'],$timezone_bias_seconds),'msgtime_'); foreach ($msg_attrib as $attr) $dataset[$attr['msga_prop']]=$attr['msga_value']; if ($msg['msg_lctr_id']) { $lecture=db_load_lecture_by_id($DBConn,$msg['msg_lctr_id']); if ($lecture) { $dataset['LECTURE']=array(0); $dataset+=$lecture; $dataset+=array_key_prepend(split_datetime($lecture['lctr_since'],$timezone_bias_seconds),'since_'); $dataset+=array_key_prepend(split_datetime($lecture['lctr_expire'],$timezone_bias_seconds),'expire_'); $dataset['since_weekday']=datetime_to_weekday($lecture['lctr_since'],$timezone_bias_seconds); $dataset['expire_weekday']=datetime_to_weekday($lecture['lctr_expire'],$timezone_bias_seconds); if (datetime_same_date($lecture['lctr_since'],$lecture['lctr_expire'],$timezone_bias_seconds)) $dataset['LECTURE-DAY-SAME']=array(0); else $dataset['LECTURE-DAY-DIFFERRED']=array(0); } } if ($msg['msg_cs_id']) { $course=db_load_course_by_id($DBConn,$msg['msg_cs_id']); if ($course) { $dataset['COURSE']=array(0); $dataset+=$course; } } $replycount=db_count_message_replies($DBConn,$msg_id); $dataset['THREAD']=$replycount || $msg['msg_id_replyto']?array(0):array(); $dataset['THREAD-REPLYTO']=$msg['msg_id_replyto']?array(0):array(); $dataset['THREAD-NEXT']=$replycount?array(0):array(); $dataset['TITLE']=$msg['fh_brief']?array(0):array(); $dataset+=$msg; if ($op=='revise' && $_SESSION['reserv.inputcache.domain']=='message.reply') { $dataset+=$_SESSION['reserv.inputcache.data']; $dataset+=$_SESSION['reserv.inputcache.errorareas']; $dataset['USER-REPLY']=array(0); } else { $dataset['DEFAULT-REPLY']=array(0); $dataset['replytitle']=mb_substr($msg['fh_brief'],0,80,'UTF-8'); } $dataset['REPLY-OK']=$op=='reply.ok'?array(0):array(); if (!$msg['msg_read']) db_set_message_read($DBConn,$msg_id,$mb_id); if ($pool=='inbox') update_unread_message_count($DBConn,$mb_id); ?>