Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5689)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5740)
@@ -158,4 +158,5 @@
 	function get_range_msgs2($params)
 	{ 	
+		include '../prototype/api/controller.php';
             // Free others requests
             session_write_close();
@@ -194,4 +195,73 @@
                                             
                                     $return[$i] = $this->get_info_head_msg( $msg_number , $sample );
+									
+									
+				$filter = array('AND', array('=', 'folderName', $folder), array('=','messageNumber', $msg_number));
+				$followupflagged = Controller::find(
+					array('concept' => 'followupflagged'),
+					false, 
+					array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+				);
+
+				if(isset($followupflagged[0]['followupflagId']))
+				{
+					$followupflag = Controller::read( array( 'concept' => 'followupflag', 'id' => $followupflagged[0]['followupflagId'] ));     
+					$followupflagged[0]['followupflag'] = $followupflag;
+					$return[$i]['followupflagged'] = $followupflagged[0];
+
+				}
+
+				$labeleds = Controller::find(
+					array('concept' => 'labeled'),
+					false, 
+					array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+				);
+				
+				ob_start();
+				var_dump($labeleds);
+
+				$output = ob_get_clean();
+				file_put_contents( "/tmp/thiago.log", $output , FILE_APPEND);
+
+				
+				if(isset($labeleds) && count($labeleds) > 0 && $labeleds){
+					$return[$i]['labels'] = array();
+
+					foreach ($labeleds as $e){
+					
+						$labels = Controller::read( array( 'concept' => 'label', 'id' =>  $e['labelId']));     
+						$return[$i]['labels'][] = $labels;
+					}	
+				}
+/*					
+									
+									
+ 									$filter = array(array('=','messageNumber', $msg_number));
+									$followupflagged = Controller::find(
+										array('concept' => 'followupflagged'),
+										false, 
+										array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+									);
+ob_start();
+print_r(var_export($followupflagged));
+
+$output = ob_get_clean();
+file_put_contents( "/tmp/thiago.log", $output , FILE_APPEND);
+
+									if(isset($followupflagged[0]['followupflagId']))
+									{
+										$followupflag = Controller::read( array( 'concept' => 'followupflag', 'id' => $followupflagged[0]['followupflagId'] ));     
+										$return[$i]['followupflag'] = $followupflag;
+									}
+
+									$labeleds = Controller::find(
+										array('concept' => 'labeled'),
+										false, 
+										array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+									);
+									foreach ($labeleds as $e){
+										$labels = Controller::read( array( 'concept' => 'label', 'id' =>  $e['labelId']));     
+										$return[$i]['labels'] = $labels;
+									} */
                                     $i++;
                             }
@@ -226,5 +296,4 @@
       			$return['num_msgs'] = count($sort_array_msg)+($msg_range_begin-1);
                 }
-
                 return $return;
     }
@@ -4842,6 +4911,5 @@
 					$return['msgs'][$i]['followupflagged'] = $followupflagged[0];
 
-				}
-
+				}	
 				$labeleds = Controller::find(
 					array('concept' => 'labeled'),
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 5738)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 5740)
@@ -1012,4 +1012,6 @@
 // Draw the inbox and another folders
 function draw_box(headers_msgs, msg_folder, alternate){
+
+//console.log(headers_msgs);
 	/*
 	 * When the paging response is not in the correct folder you need to change folder
@@ -1043,5 +1045,5 @@
 	 * into message array 
 	 */
-	var messageNumbers = new Array();
+/*  	var messageNumbers = new Array();
 	for (var i=0; i<headers_msgs.length; i++) {
 		messageNumbers.push(headers_msgs[i].msg_number);
@@ -1062,11 +1064,11 @@
 			}
 		}
-	}
-	
+	} */
+ 	
 	/**
 	 * Get the followupflags applied to the messages and saves the information 
 	 * into message array 
 	 */
-	var followupflaggeds = DataLayer.get('followupflagged', {
+/* 	var followupflaggeds = DataLayer.get('followupflagged', {
 			criteria: {
 				filter: ['AND', ['IN', 'messageNumber', messageNumbers], ['=', 'folderName', msg_folder]],
@@ -1085,5 +1087,5 @@
 			}
 		}
-	}
+	} */
 	
 	/**
Index: trunk/expressoMail1_2/js/doiMenuData.js
===================================================================
--- trunk/expressoMail1_2/js/doiMenuData.js	(revision 5738)
+++ trunk/expressoMail1_2/js/doiMenuData.js	(revision 5740)
@@ -218,4 +218,13 @@
 	var menuItems = {};
 	if (messageInfo.labels) {
+		if($.isArray(messageInfo.labels)){
+			var labels = messageInfo.labels;
+			messageInfo.labels = {};
+			for(var i in labels)
+				messageInfo.labels[labels[i].id] = {backgroundColor: labels[i]['backgroundColor'],
+					borderColor: labels[i]['borderColor'],
+					fontColor: labels[i]['fontColor'], id: labels[i]['id'], name: labels[i]['name'], 
+					uid: labels[i]['uid'] }
+		}	
 		menuItems = messageInfo.labels;
 	} else {
