<?php 
if($cupdatesarray) {
	// For each array conversation user details
   foreach($cupdatesarray as $data) {
	 $loggedTime=time()-120;	//2 minutes
     $loginTime=$data['last_login'];
     if($loginTime>$loggedTime) {
	    $online='#1de9b6';
        } else {
	    $online='#9e9e9e';
     }
    $c_id=$data['c_id'];
    $username=$data['username'];
    $email=$data['email'];
    $cuser_id=$data['uid'];
    $maintime=$data['time'];
    $top_c_id=$Mat->Conversation_Insert($uid,$conversation_uid);
    $cupdatesarray=$Mat->Conversation_List($c_id,$uid);
    $style='background-color:#eeeeee';
    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:#eeeeee;';
     } else {
        $style='';	
     }
     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']);
       $uploaded=$data['upload'];
	   // 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) . "..." ;
        }
        $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);
        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:#eeeeee;';
          } else {
		      $style='';	
		  }
		  // Conversation message user profile image
         $cface=$Mat->User_MiniProfilepic($cuser_id,$base_url);
		 $CheckBlockUser =$Mat->Friends_block_Check($cuser_id,$uid);
		 $CheckBlockUserMe =$Mat->Friends_block_Check($uid,$cuser_id);
?>
<?php if($CheckBlockUser == '1' || $CheckBlockUserMe == '1'){?>
	<?php } else {?>
<div class="incoming-message md-ripple md-ripple-yellow wow bounceInLeft" style="<?php echo $style;?>" data-wow-offset="300" id='chatbody<?php echo $c_id;?>' rel='<?php echo $maintime;?>'>
  <div class="delete_conversation" id="<?php echo $c_id; ?>" style="<?php echo $style;?>"><div class="icon-delete-conversation icon-x-alt"></div></div>
  <a href="<?php echo $base_url.'messages/'.$username;?>" class='con_name'><div class="incoming-message-user-image"><img src="<?php echo $cface; ?>" /><div class="user_status" style="background-color:<?php echo $online;?>"></div></div></a>
  <div class="incoming-message-time"><span class='cname'><?php echo $cu=$Mat->UserFullName($username);?><span class="message-time-style sttime timeago" title="<?php echo $mtime;?>"></span></div>
  <div class="incoming-reply-text"><?php echo $reply;?><?php if(!empty($uploaded)){echo 'Image';}?></div>
</div>

<?php 
}
}
} 
$style=''; 
}
}
?>
