<?php require_once('includes/requirelogin.inc.php'); require_once('includes/message.inc.php'); $msg_id_replyto=0+TGET("msg_id_replyto"); $pool=TGET('pool'); $mb_id=current_mb_id(); list($offset,$pagesize,$pageno)=decide_page_range(TGET("p"),TGET("ps")); if (is_valid_compere()) $USE_THEME_BY_USER_ID=$mb_id; $DBConn->connect(true); $list_msg_params=array(); if ($msg_id_replyto) $list_msg_params['msg_id_replyto']=$msg_id_replyto; else if ($pool=='outbox') $list_msg_params['mb_id_from']=$mb_id; else $list_msg_params['mb_id_to']=$mb_id; $messages=db_list_messages($DBConn,$list_msg_params,$pagesize+1,$offset); if ($msg_id_replyto && sizeof($messages)==1) { redirect("qx-cmd-message-msg_id-".$messages[0]['msg_id'].".html"); return; } $dataset+=prepare_paging_dataset($pageno,$pagesize,$messages); if ($pool=='outbox') { $dataset['OUTBOX']=array(0); $dataset['pool']='outbox'; $dataset['msg_id_first_unread']=db_load_unread_message_neighbour_id($DBConn,$mb_id,0,true,null,$mb_id); } else { $dataset['INBOX']=array(0); $dataset['pool']='inbox'; $dataset['msg_id_first_unread']=db_load_unread_message_neighbour_id($DBConn,$mb_id,0,true,$mb_id); } $dataset['UNREAD-EXISTS']=$dataset['msg_id_first_unread']?array(0):array(); $dataset['MESSAGE-ROW']=$messages; $msg_ids=array_projection($messages,'msg_id'); $msg_attrib=db_get_message_attrib($DBConn,$msg_ids); $msg2attrib=rowset2multimap($msg_attrib,'msg_id'); $rowcount=0; foreach ($dataset['MESSAGE-ROW'] as &$msg) { if (!$rowcount) $msg['HEADER']=array(0); if ($pool=='outbox') $msg+=get_message_receiver_name_dataset($msg,$msg2attrib[$msg['msg_id']]); else $msg+=get_message_sender_name_dataset($msg,$msg2attrib[$msg['msg_id']]); $msg+=prepare_message_from_display_type($msg,$mb_id); if (isset($msg2attrib[$msg['msg_id']])) foreach ($msg2attrib[$msg['msg_id']] as $attrib) $msg[$attrib['msga_prop']]=$attrib['msga_value']; $rowcount=($rowcount+1)%$Config->LIST_PAGE_LENGTH_DEFAULT; } $dataset['MESSAGE-NONE']=$messages?array():array(0); ?>