<?php
$conversation_uid='';
$top_c_id=$Mat->Conversation_Insert($uid,$conversation_uid);
$last_time='';
if($last_time=='') {
   $last_time=0;
  }
  $cupdatesarray=$Mat->Conversation($uid,$last_time,$conversation_uid);
?>
<?php 
if($cupdatesarray) {
	// For each array conversation user details
   foreach($cupdatesarray as $data) {
     $c_id=$data['c_id'];
     $message_username=$data['username'];
     $email=$data['email'];
     $cuser_id=$data['uid'];
     $maintime=$data['time'];
     $cupdatesarray=$Mat->Conversation_List($c_id,$uid);
     if($c_id==$top_c_id ) { 
	    // If the conversation user id loged in user id
		// Then show the this color from the conversation style
		// If you want to change the color and also if you want to add an image the style
		// You need to add css code in the $style
        $style='background-color:#a7d8ec';
      }
      if($cupdatesarray) {
		  // For each for the conversation detail
         foreach($cupdatesarray as $data)
           {
			 // If reply is a link then the hide link element
             $reply=htmlcode_nolink($data['reply']);
			 // Strlen the reply message text
             $str_length = strlen($reply);       
             if($str_length > 40) {         
			    // If the reply message greater then 40 then  
                $reply= substr($reply, 0, 40) . "..." ; // do dot dot dot
              }
			  $reply_uid=$data['user_id_fk'];
              $ctime=$data['time'];  // Reply message time
              $read_status=$data['read_status'];  // Reply message status read or not
              $mtime=date("c", $ctime); // Reply message time for data with working jquery.time.js
              if($read_status && $reply_uid!=$uid) { 	
			     // If red status and replyed user id is not equal the show the 
				 // following style background color
                 $style='background-color:#dedede';
               }
			   // Conversation message user profile image
			$cface=$Mat->User_Profilepic($cuser_id,$base_url);
?>
<a href="<?php echo $base_url.'messages/'.$message_username; ?>" class="mesaj_a">
<div class="message_wrap">
  <div class="message_user_image"><img src="<?php echo $cface; ?>"/></div>
    <div class="MessageDetails">
      <div class="MessageUserName"><?php echo $cu=htmlspecialchars($Mat->UserFullName($message_username)); ?> <span  class="smtime timeago con_time" title="<?php echo $mtime; ?>"></span></div>
      <div class="UserMessage"><?php echo htmlspecialchars($reply); ?></div>
    </div>
  </div>
</a>
<?php 
}
} 
$style=''; 
} 
} 
?>