Index: trunk/prototype/services/ImapServiceAdapter.php
===================================================================
--- trunk/prototype/services/ImapServiceAdapter.php	(revision 5416)
+++ trunk/prototype/services/ImapServiceAdapter.php	(revision 5533)
@@ -7,160 +7,419 @@
     public function open( $config )
     {
-	$this->init();
+		$this->init();
     }
 
 //     public function connect( $config )
 //     {
-// 	$this->init();
+// 			$this->init();
 //     }
 	
     public function find( $URI, $justthese = false, $criteria = false )
 	{ 
-	$context = $justthese['context'];
-	    $URI = $URI['concept'];
-
-	switch( $URI )
-	{
-	    case 'folder':
-	    {
-		$result = $this->to_utf8($this->get_folders_list());
-
-		foreach ($result as $res) {
-
-		    $response[] = array(
-				    'id' => $res['folder_id'],
-				    'commonName' => $res['folder_name'],
-				    'parentFolder' => $res['folder_parent'],
-				    'messageCount' => array('unseen' => isset($res['folder_unseen']) ? $res['folder_unseen'] : null, 'total' => null)
-			    );
+		$context = $justthese['context'];
+		$URI = $URI['concept'];
+
+		switch( $URI )
+		{
+			case 'folder':
+			{
+				$result = $this->to_utf8($this->get_folders_list());
+
+				foreach ($result as $res) {
+
+					$response[] = array(
+							'id' => $res['folder_id'],
+							'commonName' => $res['folder_name'],
+							'parentFolder' => $res['folder_parent'],
+							'messageCount' => array('unseen' => isset($res['folder_unseen']) ? $res['folder_unseen'] : null, 'total' => null)
+						);
+				}
+
+				return $response;
+			}
+			case 'message':
+			{
+				//begin: for grid	
+				$page  = $criteria['page']; //{1}    get the requested page
+				$limit = $criteria['rows']; //{10}   get how many rows we want to have into the grid
+				$sidx  = $criteria['sidx']; //{id}   get index row - i.e. user click to sort
+				$sord  = $criteria['sord']; //{desc} get the direction
+
+				$filter = $criteria['filter'];
+
+				if( !$sidx ) $sidx = 1;
+
+				$folder_name = str_replace( '.', $this->imap_delimiter, $context['folder'] );
+				
+				$count = imap_num_msg( $this->open_mbox( $folder_name ) );
+
+				$total_pages = $count > 0 ? ceil( $count/$limit ) : 0;
+
+				if( $page > $total_pages )
+					$page = $total_pages;
+
+				$start = $limit * $page - $limit;
+
+				// do not put $limit*($page - 1)
+				//end: for grid
+
+				if( $filter )
+				{
+					if( $filter[0] !== 'msgNumber' )
+					{
+					for( $i = 0; $i < count($filter); $i++ )
+					{
+						if( count( $filter[$i] ) === 4 )
+						$criteria['isExact'] = ( array_shift( $filter[$i] ) === 'AND' );
+
+						$criteria[ $filter[$i][0] ] = array( 'criteria' => $filter[$i][2], 'filter' => $filter[$i][1] );
+					}
+
+					return $this->searchSieveRule($criteria);
+					}
+
+					$msgNumber = array();
+
+					for( $i = $start; $i < $start + $limit && isset( $filter[2][$i] ); $i++ )
+					  $msgNumber[] = $filter[2][$i];
+
+					if( empty( $msgNumber ) )
+					return( false );
+
+					$result = $this->get_info_msgs( array( 'folder' => $folder_name, 
+									   'msgs_number' => implode( ',', $msgNumber ) ) );
+
+					foreach( $result as $i => $val )
+					$result[$i] = unserialize( $val );
+
+				}
+				else
+				{
+					$result = $this->get_range_msgs2( 
+						array( 
+							'folder' => $folder_name, //INBOX
+							'msg_range_begin' => $start + 1, //??
+							'msg_range_end' => $start + $limit, //$limit = $_GET['rows']; // get how many rows we want to have into the grid
+							'sort_box_type' => 'SORTARRIVAL', 
+							'search_box_type' => 'ALL',
+							'sort_box_reverse' => 1 
+						) 
+					);
+				}
+				//return var_export($result);
+
+				$response = array( "page" => $page, "total" => $total_pages, "records" => $count );
+				
+				for ($i=0; $i<count($result); $i++)
+				{
+					$flags_enum = array('Recent', 'Unseen',  'Answered',  'Draft',  'Deleted', 'Flagged');
+
+					foreach ($flags_enum as $key => $flag)
+					{
+						if ( !isset($result[$i][$flag]) || !trim($result[$i][$flag]) || trim($result[$i][$flag]) == '') 
+							unset($flags_enum[$key]);
+
+						unset($result[$i][$flag]);
+					}
+
+					if (array_key_exists($i, $result))
+					{
+						$response["rows"][$i] = $result[$i];
+						$response["rows"][$i]['timestamp'] = ( ( $result[$i]['udate'] + $this->functions->CalculateDateOffset() ) * 1000 );
+						$response["rows"][$i]['flags'] = implode(',', $flags_enum);
+						$response["rows"][$i]['size'] = $response["rows"][$i]['Size'];
+						//$response["rows"][$i]['udate'] = ( $result[$i]['udate'] + $this->functions->CalculateDateOffset()  * 1000 );
+						unset($response["rows"][$i]['Size']);
+					}
+				 }
+
+				return $this->to_utf8($response);
+			}
+			
+			/**
+			 * Filtros suportados:
+			 * - ['=', 'folderName', $X]
+			 * - [
+			 * 		'AND',
+			 * 		[
+			 * 			'AND',
+			 * 			['=', 'folderName', $X],
+			 * 			['IN', 'messageNumber', $Ys]
+			 * 		],
+			 * 		['IN', 'labelId', $Zs]
+			 * ]
+			 * - ['=', 'labelId', $X]
+			 * - [
+			 * 		'AND',
+			 * 		['=', 'folderName', $X],
+			 * 		['=', 'labelId', $Y]
+			 * ]
+			 * - ['IN', 'labelId', $Ys]
+			 * - [
+			 * 		'AND',
+			 * 		['=', 'folderName', $X],
+			 * 		['IN', 'labelId', $Ys]
+			 * ]			
+			 */
+			case 'labeled':
+			{
+				$result = array ( );
+				if (isset($criteria["filter"]) && is_array($criteria['filter'])) {
+					//melhorar o tratamento do filter com a lista de todos os labelIds dado pelo interceptor
+					$map = array(
+						'id' => array(),
+						'folderName' => array(),
+						'messageNumber' => array(),
+						'labelId' => array()
+					);
+					
+					self::parseFilter($criteria["filter"], &$map);
+					
+					if (count($map['folderName']) == 0) {
+						$folders = $this->get_folders_list();
+						foreach ($folders as $folder)
+							if (isset($folder['folder_id'])) 
+								$map['folderName'][] = $folder['folder_id'];
+					}
+
+					foreach ($map['folderName'] as $folder) {
+						$this->mbox = $this->open_mbox($folder);
+						
+						foreach ($map['labelId'] as $label) {
+							$messagesLabeleds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Label'.$label.'"', SE_UID);
+							
+							foreach ($messagesLabeleds as $messageLabeled) {
+								if (count($map['messageNumber']) > 0 && !in_array($messageLabeled, $map['messageNumber']))
+									continue;
+									
+								$result[] = array (
+									'id' => $folder . '/' . $messageLabeled . '#' . $label, 
+									'folderName' => $folder,
+									'messageNumber' => $messageLabeled,
+									'labelId' => $label
+								);
+							}
+						}
+						
+						imap_close($this->mbox);
+						$this->mbox = false;
+					}
+				}
+				
+				return $result;
+			}
+			
+			case 'followupflagged':
+			{
+			
+				$result = array ( );
+				if (isset($criteria["filter"]) && is_array($criteria['filter'])) {
+					//melhorar o tratamento do filter com a lista de todos os labelIds dado pelo interceptor
+					$map = array(
+						'id' => array(),
+						'folderName' => array(),
+						'messageNumber' => array()
+					);
+					
+					self::parseFilter($criteria["filter"], &$map);
+					
+					if (empty($map['folderName'])) {
+						$folders = $this->get_folders_list();
+						foreach ($folders as $folder)
+							if (isset($folder['folder_id'])) 
+								$map['folderName'][] = $folder['folder_id'];
+					}
+
+					foreach ($map['folderName'] as $folder) {
+						$this->mbox = $this->open_mbox($folder);
+						
+						foreach ($map['id'] as $followupflagged) {
+							$messagesFlaggeds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflag'.$followupflagged.'"', SE_UID);
+							
+							foreach ($messagesFlaggeds as $messageFlagged) {
+								if (count($map['messageNumber']) > 0 && !in_array($messageFlagged, $map['messageNumber']))
+									continue;
+									
+								$result[] = array (
+									'id' => $folder . '/' . $messageFlagged . '#' . $followupflagged, 
+									'folderName' => $folder,
+									'messageNumber' => $messageFlagged
+								);
+							}
+						}
+						
+						imap_close($this->mbox);
+						$this->mbox = false;
+					}
+				}
+						
+				return $result;				
+			}
 		}
-
-		break;
-	    }
-	    case 'message':
-	    {
-		//begin: for grid	
-		$page  = $criteria['page']; //{1}    get the requested page
-		$limit = $criteria['rows']; //{10}   get how many rows we want to have into the grid
-		$sidx  = $criteria['sidx']; //{id}   get index row - i.e. user click to sort
-		$sord  = $criteria['sord']; //{desc} get the direction
-
-		$filter = $criteria['filter'];
-
-		if( !$sidx ) $sidx = 1;
-
-		$folder_name = str_replace( '.', $this->imap_delimiter, $context['folder'] );
-		
-		$count = imap_num_msg( $this->open_mbox( $folder_name ) );
-
-		$total_pages = $count > 0 ? ceil( $count/$limit ) : 0;
-
-		if( $page > $total_pages )
-		    $page = $total_pages;
-
-		$start = $limit * $page - $limit;
-
-		// do not put $limit*($page - 1)
-		//end: for grid
-
-		if( $filter )
+    }
+
+    public function read( $URI, $justthese = false )
+    {
+
+		switch( $URI['concept'] )
 		{
-		    if( $filter[0] !== 'msgNumber' )
-		    {
-			for( $i = 0; $i < count($filter); $i++ )
-			{
-			    if( count( $filter[$i] ) === 4 )
-				$criteria['isExact'] = ( array_shift( $filter[$i] ) === 'AND' );
-
-			    $criteria[ $filter[$i][0] ] = array( 'criteria' => $filter[$i][2], 'filter' => $filter[$i][1] );
-			}
-
-			return $this->searchSieveRule($criteria);
-		    }
-
-		    $msgNumber = array();
-
-		    for( $i = $start; $i < $start + $limit && isset( $filter[2][$i] ); $i++ )
-			  $msgNumber[] = $filter[2][$i];
-
-		    if( empty( $msgNumber ) )
-			return( false );
-
-		    $result = $this->get_info_msgs( array( 'folder' => $folder_name, 
-							   'msgs_number' => implode( ',', $msgNumber ) ) );
-
-		    foreach( $result as $i => $val )
-			$result[$i] = unserialize( $val );
-
+			case 'message':
+			{
+				return $this->to_utf8( 
+					$this->get_info_msg( array('msg_number'=>$URI['id'],
+					'msg_folder'=>str_replace( '.', $this->imap_delimiter, $justthese['context']['folder'] )) ) 
+				);
+			}
+			case 'labeled':
+			{
+				/**
+				 * id looks like 'folder/subfolder/subsubfolder/65#13', meaning messageId#labelId
+				 */
+				list($messageId, $labelId) = explode('#', $URI['id']);
+				$folderName = basename($messageId);
+				$messageNumber = dirname($messageId);
+				
+				$result = array();
+
+				if ($folderName && $messageNumber && $labelId) {
+					$this->mbox = $this->open_mbox($folderName);
+					$messagesLabeleds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Label'.$labelId.'"', SE_UID);
+					
+					if (in_array($messageNumber, $messagesLabeleds)) {
+						$result = array (
+							'id' => $URI['id'], 
+							'folderName' => $folderName,
+							'messageNumber' => $messageNumber,
+							'labelId' => $labelId
+						);
+					}
+					imap_close($this->mbox);
+					$this->mbox = false;
+				}
+				
+				return $result;
+			}
+			
+			case 'followupflagged':
+			{
+				/**
+				 * id looks like 'folder/subfolder/subsubfolder/65#13', meaning messageId#followupflaggedId
+				 */
+				list($messageId, $followupflaggedId) = explode('#', $URI['id']);
+				$folderName = basename($messageId);
+				$messageNumber = dirname($messageId);
+				
+				$result = array();
+
+				if ($folderName && $messageNumber && $followupflaggedId) {
+					$this->mbox = $this->open_mbox($folderName);
+					$messagesFlaggeds = imap_search($this->mbox, 'UNDELETED KEYWORD "$Followupflag'.$followupflaggedId.'"', SE_UID);
+					
+					if (in_array($messageNumber, $messagesFlaggeds)) {
+						$result = array (
+							'id' => $URI['id'], 
+							'folderName' => $folderName,
+							'messageNumber' => $messageNumber
+						);
+					}
+					imap_close($this->mbox);
+					$this->mbox = false;
+				}
+				
+				return $result;
+			}
 		}
-		else
+    }
+
+    public function create( $URI, $data)
+    {
+
+		switch( $URI['concept'] )
 		{
-		    $result = $this->get_range_msgs2( array( 'folder' => $folder_name, //INBOX
-					 'msg_range_begin' => $start + 1, //??
-					 'msg_range_end' => $start + $limit, //$limit = $_GET['rows']; // get how many rows we want to have into the grid
-					 'sort_box_type' => 'SORTARRIVAL', 
-					 'search_box_type' => 'ALL',
-							     'sort_box_reverse' => 1 ) );
+			case 'labeled':
+			{
+				if (isset($data['folderName']) && isset($data['messageNumber']) && isset($data['labelId'])) {
+					$this->mbox = $this->open_mbox($data['folderName']);
+					imap_setflag_full($this->mbox, $data['messageNumber'], '$Label' . $data['labelId'], ST_UID);
+
+					imap_close($this->mbox);
+					$this->mbox = false;
+
+					return array ('id' => $data['folderName'].'/'.$data['messageNumber'].'#'.$data['labelId']);
+				}
+				return array ();
+			}
+			case 'followupflagged':
+			{
+				//tem que gravar no banco primeiro, obter o id e depois mandar gravar no imap passando o id no data
+				if (isset($data['folderName']) && isset($data['messageNumber']) && isset($data['id'])) {
+					list($messageId, $followupflaggedId) = explode('#', $data['id']);
+					
+					$this->mbox = $this->open_mbox($data['folderName']);
+					imap_setflag_full($this->mbox, $data['messageNumber'], '$Followupflag' . $followupflaggedId, ST_UID);
+
+					imap_close($this->mbox);
+					$this->mbox = false;
+
+					return array ('id' => $data['id']);
+				}
+				return array ();
+			}
 		}
-		//return var_export($result);
-
-		$response = array( "page" => $page, "total" => $total_pages, "records" => $count );
-		
-		for ($i=0; $i<count($result); $i++)
+	}
+
+    public function delete( $URI, $justthese = false, $criteria = false )
+    {
+		switch( $URI['concept'] )
 		{
-		    $flags_enum = array('Recent', 'Unseen',  'Answered',  'Draft',  'Deleted', 'Flagged');
-
-		    foreach ($flags_enum as $key => $flag)
-		    {
-			if ( !isset($result[$i][$flag]) || !trim($result[$i][$flag]) || trim($result[$i][$flag]) == '') 
-				unset($flags_enum[$key]);
-			unset($result[$i][$flag]);
-		    }
-
-		    if (array_key_exists($i, $result))
-		    {
-				$response["rows"][$i] = $result[$i];
-			$response["rows"][$i]['timestamp'] = ( ( $result[$i]['udate'] + $this->functions->CalculateDateOffset() ) * 1000 );
-				$response["rows"][$i]['flags'] = implode(',', $flags_enum);
-				$response["rows"][$i]['size'] = $response["rows"][$i]['Size'];
-// 			$response["rows"][$i]['udate'] = ( $result[$i]['udate'] + $this->functions->CalculateDateOffset()  * 1000 );
-				unset($response["rows"][$i]['Size']);
-		    }
-		 }
-
-		$response = $this->to_utf8($response);
-
-		break;
-	    }
+			case 'labeled':
+			{
+				list($messageId, $labelId) = explode('#', $URI['id']);
+				$folderName = basename($messageId);
+				$messageNumber = dirname($messageId);
+			
+				if ($folderName && $messageNumber && $labelId) {
+					$this->mbox = $this->open_mbox($folderName);
+					imap_clearflag_full($this->mbox, $messageNumber, '$Label' . $labelId, ST_UID);
+
+					imap_close($this->mbox);
+					$this->mbox = false;
+				}
+			}
+			case 'followupflagged':
+			{
+				list($messageId, $followupflaggedId) = explode('#', $URI['id']);
+				$folderName = basename($messageId);
+				$messageNumber = dirname($messageId);
+			
+				if ($folderName && $messageNumber && $followupflaggedId) {
+					$this->mbox = $this->open_mbox($folderName);
+					imap_clearflag_full($this->mbox, $messageNumber, '$Followupflag' . $followupflaggedId, ST_UID);
+
+					imap_close($this->mbox);
+					$this->mbox = false;
+				}
+			}
+		}
+
+		//TODO - return
 	}
-	return $response;
-    }
+
+    public function deleteAll( $URI, $justthese = false, $criteria = false ) // avaliar
+    {}
+
+    public function update( $URI, $data, $criteria = false )
+    {
+		//TODO - remove
+		//TODO - create
+	}
 
 //     public function retrieve( $concept, $id, $parents, $justthese = false, $criteria = false )
 //     {
-// 	return $this->read( array( 'id' => $id, 
+// 			return $this->read( array( 'id' => $id, 
 // 			    'concept' => $concept, 
 // 			    'context' => $parents ), $justthese );
 //     }
 
-    public function read( $URI, $justthese = false )
-    {
-
-	return $this->to_utf8( $this->get_info_msg( array('msg_number'=>$URI['id'],
-													  'msg_folder'=>str_replace( '.', $this->imap_delimiter, $justthese['context']['folder'] )) ) );
-    }
-
-    public function create( $URI, $data )
-    {}
-
-    public function delete( $URI, $justthese = false, $criteria = false )
-    {}
-
-    public function deleteAll( $URI, $justthese = false, $criteria = false ) // avaliar
-    {}
-
-    public function update( $URI, $data, $criteria = false )
-    {}
-
     public function replace( $URI, $data, $criteria = false )
     {}
@@ -187,15 +446,38 @@
     function to_utf8($in) 
     { 
-	if (is_array($in)) { 
-		foreach ($in as $key => $value) { 
-			$out[$this->to_utf8($key)] = $this->to_utf8($value); 
+		if (is_array($in)) { 
+			foreach ($in as $key => $value) { 
+				$out[$this->to_utf8($key)] = $this->to_utf8($value); 
+			} 
+		} elseif(is_string($in)) { 
+				return mb_convert_encoding( $in , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 
+		} else { 
+			return $in; 
 		} 
-	} elseif(is_string($in)) { 
-			return mb_convert_encoding( $in , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 
-	} else { 
-		return $in; 
-	} 
-	return $out; 
+		return $out; 
     }
-
+	
+	    
+    private static function parseFilter( $filter ,&$map){
+		
+		if( !is_array( $filter ) || count($filter) <= 0) return null;
+					
+		$op = array_shift( $filter );
+		switch(strtolower($op))
+		{
+			case 'and': {
+				foreach ($filter as $term)
+					self::parseFilter($term ,&$map);
+				return;
+			}
+			case 'in': {
+				$map[$filter[0]] = array_merge($map[$filter[0]], $filter[1]);
+				return;
+			}
+			case '=': {
+				$map[$filter[0]][] = $filter[1];
+			}
+		}
+	}
+	
 }
Index: trunk/prototype/config/followupflag.ini
===================================================================
--- trunk/prototype/config/followupflag.ini	(revision 5533)
+++ trunk/prototype/config/followupflag.ini	(revision 5533)
@@ -0,0 +1,17 @@
+service = PostgreSQL
+PostgreSQL.concept = expressomail_followupflag
+
+[before.find]
+addVerifyOwnerFilter = modules/mail/interceptors/FollowupflagSecure.php
+addDefaultElementsFilter = modules/mail/interceptors/FollowupflagSecure.php
+
+;[after.find]
+;addDefaultFollowupflags = modules/mail/interceptors/Helpers.php
+
+;[before.delete]
+;clearAllFlaggedOfFollowupflag = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.mapping]
+id = id
+uid = user_id
+name = name
Index: trunk/prototype/config/label.ini
===================================================================
--- trunk/prototype/config/label.ini	(revision 5533)
+++ trunk/prototype/config/label.ini	(revision 5533)
@@ -0,0 +1,17 @@
+service = PostgreSQL
+PostgreSQL.concept = expressomail_label
+
+[before.find]
+addVerifyOwnerFilter = modules/mail/interceptors/LabelSecure.php
+
+[before.delete]
+clearAllLabeledsOfLabel = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.mapping]
+id = id
+uid = user_id
+name = name
+borderColor = border_color
+backgroundColor = background_color
+fontColor = font_color
+
Index: trunk/prototype/config/followupflagged.ini
===================================================================
--- trunk/prototype/config/followupflagged.ini	(revision 5533)
+++ trunk/prototype/config/followupflagged.ini	(revision 5533)
@@ -0,0 +1,50 @@
+service = PostgreSQL
+
+PostgreSQL.concept = expressomail_message_followupflag
+;Imap.concept = followupflag
+
+[before.find]
+addVerifyOwnerFilter = modules/mail/interceptors/FollowupflagSecure.php
+
+[after.find]
+deepnessFollowupflaggeds = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.before.create]
+letFollowupflaggedKeepUnique = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.after.create]
+doImapCreate = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.before.find]
+doImapFind = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.before.read]
+doImapRead = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.before.delete]
+doImapDelete = modules/mail/interceptors/Helpers.php
+
+[PostgreSQL.before.update]
+doImapUpdate = modules/mail/interceptors/Helpers.php
+
+
+[PostgreSQL.mapping]
+id = id
+uid = user_id
+followupflagId = followupflag_id
+;TODO - retirar folderName e messageNumber do banco
+folderName = folder_name
+messageNumber = message_id
+alarmDeadline = alarm_deadline
+doneDeadline = done_deadline
+isDone = is_done
+borderColor = border_color
+backgroundColor = background_color
+fontColor = font_color
+
+[Imap.mapping]
+id = id
+followupflagId = followupflag_id
+folderName = folder_name
+messageNumber = message_id
+
Index: trunk/prototype/config/labeled.ini
===================================================================
--- trunk/prototype/config/labeled.ini	(revision 5533)
+++ trunk/prototype/config/labeled.ini	(revision 5533)
@@ -0,0 +1,19 @@
+;service = PostgreSQL
+;PostgreSQL.concept = expressomail_message_label
+service = Imap
+Imap.concept = label
+
+
+[before.find]
+makeLabelListFilter = modules/mail/interceptors/Helpers.php
+
+[after.find]
+deepnessLabeleds = modules/mail/interceptors/Helpers.php
+
+[Imap.mapping]
+id = id
+labelId = label_id
+folderName = folder_name
+messageNumber = message_id
+
+;TODO - interceptor para evitar que existam mais de um entrada com os campos "folderName", "messageNumber" e "labelId" identicos
Index: trunk/prototype/config/OpenLDAP.srv
===================================================================
--- trunk/prototype/config/OpenLDAP.srv	(revision 5399)
+++ trunk/prototype/config/OpenLDAP.srv	(revision 5533)
@@ -5,5 +5,5 @@
 host = 127.0.0.1
 
-;context = dc=exemplo.com
+context = "dc=prognus"
 ;user = 
 ;password = 
Index: trunk/prototype/config/PostgreSQL.srv
===================================================================
--- trunk/prototype/config/PostgreSQL.srv	(revision 5523)
+++ trunk/prototype/config/PostgreSQL.srv	(revision 5533)
@@ -3,10 +3,10 @@
 [config]
 port = 5432
-dbname= expresso
+dbname= expresso24douglasz
 user=postgres
 host = /var/run/postgresql
-;conexão via tcp
+;conexï¿œo via tcp
 ;host = 127.0.0.1
 
-;user=
-;password=
+user = expressodev
+password = prognus
Index: trunk/prototype/modules/mail/interceptors/Helpers.php
===================================================================
--- trunk/prototype/modules/mail/interceptors/Helpers.php	(revision 5533)
+++ trunk/prototype/modules/mail/interceptors/Helpers.php	(revision 5533)
@@ -0,0 +1,195 @@
+<?php
+include_once ROOTPATH."/../expressoMail1_2/inc/class.imap_functions.inc.php";
+
+class Helpers {    
+
+/**
+ * LABELS
+ */ 
+	public function deepnessLabeleds( &$uri , &$result , &$criteria , $original ){                
+
+		if(isset($original['criteria']['deepness']))
+		{
+			foreach ($result as $i => $v)
+			{
+				if(isset($v['labelId']))
+				{
+					$labels = Controller::find( array( 'concept' => 'label' ) , false, array( 'filter' => array('=', 'id'  ,  $v['labelId']) ));     
+					$result[$i]['label'] = $labels[0];
+				}              
+
+			}
+		}
+
+		return $result;
+	}
+	
+	/**
+	 * MÃ©todo a ser chamado na exclusÃ£o de um label, procedendo com a
+	 * desvinculaÃ§Ã£o deste label com todas as mensagens a que estava vinculado
+	 */
+	public function clearAllLabeledsOfLabel( &$uri , &$result , &$criteria , $original ){
+		
+		$labeleds = Controller::find( array( 'concept' => 'labeled' ) , false, array( 'filter' => array('=', 'labelId'  ,  $uri['id']) ));
+		if (empty($labeleds))
+			return;
+		
+		$labeledsIds = array();
+		foreach ($labeleds as $e) {
+				$labeledsIds[] = $e['id'];
+		}
+		
+		Controller::delete( array( 'concept' => 'labeled' ), false, array( 'filter' => array( 'IN', 'id', $labeledsIds )) );
+
+		//return $result;
+	}
+	/**
+	 * MÃ©todo a ser chamado ao listar os labeleds, uma vez que as funÃ§Ã£o de IMAP do PHP nÃ£o sÃ£o capazes de 
+	 * obter a lista de todos os labels e nem sÃ£o capazes de obter os labels de uma dada mensagem
+	 */
+	public function makeLabelListFilter( &$uri , &$result , &$criteria , $original ){
+
+		if (!isset($criteria['filter']) || !self::in_arrayr('labelId', $criteria['filter'])) {
+			$labels = Controller::find( array( 'concept' => 'label' ) );
+
+			$list = array();
+			foreach ($labels as $label)
+				$list[] = $label['id'];
+				
+			$filter = array( 'IN' , 'labelId' , $list );
+			
+			if (isset($criteria['filter']) && $criteria['filter']!=NULL && count($criteria['filter']) != 0)
+				$criteria['filter'] = array( 'AND', $criteria['filter'], $filter );
+			else
+				$criteria['filter'] =  $filter;
+		}
+	}
+	
+	public static function in_arrayr($needle, $haystack) {
+		foreach ($haystack as $v) {
+				if ($needle == $v) return true;
+				elseif (is_array($v)) return self::in_arrayr($needle, $v);
+		}
+		return false;
+	} 
+		
+	
+/**
+ * FOLLOWUPFLAGS
+ */ 
+
+	public function deepnessFollowupflaggeds( &$uri , &$result , &$criteria , $original ){                
+	
+		if(isset($original['criteria']['deepness']))
+		{
+			foreach ($result as $i => $v)
+			{
+				if(isset($v['followupflagId']))
+				{
+					$followupflag = Controller::find( array( 'concept' => 'followupflag' ) , false, array( 'filter' => array('=', 'id'  ,  $v['followupflagId']) ));     
+					$result[$i]['followupflag'] = $followupflag[0];
+				}
+				
+				if(isset($v['messageNumber']) && isset($v['folderName']))
+				{
+					$details = $criteria['deepness'] == '1' ? 'headers' : 'all';
+					
+					$imapService = new imap_functions();
+					$message = $imapService->getMessages(array('messages' => array($v['folderName'] => array($v['messageNumber'])), 'details' => $details));
+					$result[$i]['message'] = $message[$v['folderName']][0];				
+				}     
+			}
+		}
+
+		return $result;
+	}	
+
+	public function letFollowupflaggedKeepUnique (&$uri , &$params , &$criteria , $original ){
+		if (isset($params['folderName']) && isset($params['messageNumber'])) {
+			$filter = array ( 'AND', array('=', 'folderName', $params['folderName']), array('=', 'messageNumber', $params['messageNumber']) );
+			Controller::delete( array( 'concept' => 'followupflagged' ), false, array( 'filter' => $filter));
+		}
+	}
+
+/*	
+	public function clearAllFlaggedOfFollowupflag( &$uri , &$result , &$criteria , $original ){
+		//TODO - filter
+		return $result;
+	}
+*/	
+
+	//PostgreSQL.after.create
+	public function doImapCreate( &$uri , &$params , &$criteria , $original ) {
+	
+		$imap_uri = $uri;
+		$imap_uri['service'] = 'Imap';
+		
+		$imap_params = $params + $original['properties'];
+		if ($imap_params['folderName'] && $imap_params['messageNumber'] && $imap_params['id']) {
+			$imap_uri['id'] = $imap_params['folderName'] . '/' . $imap_params['messageNumber'] . '#' . $imap_params['id']; 
+			$imap_params['id'] = $imap_params['folderName'] . '/' . $imap_params['messageNumber'] . '#' . $imap_params['id']; 
+			$result = Controller::create($imap_uri, $imap_params);
+		}
+		
+	}
+	
+	//PostgreSQL.before.find
+	public function doImapFind( &$uri , &$params , &$criteria , $original ) {
+		$imap_uri = $uri;
+		$imap_uri['service'] = 'Imap';
+		$result = Controller::find($imap_uri, $params, $criteria);
+		
+		if($result) {
+			/** TODO:
+			 *	- se achar no Imap, passar as referencias para o PostgresSQL para que
+			 *  seja conferida a consistÃªncia dos dados no postgres (Nota: os dados podem
+			 *  ficar inconsistentes no postgres se a mensagem for movida no Imap, assim
+			 *  messageNumber e/ou folderName podem estar desatualizados no postgres)
+			 */
+		}
+	}
+	
+	//PostgreSQL.before.read
+	public function doImapRead( &$uri , &$params , &$criteria , $original ) {
+		$imap_uri = $uri;
+		$imap_uri['service'] = 'Imap';
+		$result = Controller::read($imap_uri, $params, $criteria);
+	}
+	
+	//PostgreSQL.before.delete
+	public function doImapDelete( &$uri , &$params , &$criteria , $original ) {
+		$toGetURI = $uri;
+		$flagged = Controller::read($toGetURI);
+
+		//assumindo que $criteria['filter'] venha sempre vazio no delete
+		$imap_criteria['filter'] = array();
+		foreach ($flagged as $key => $value) {
+			$imap_criteria['filter'][] = array('=', $key, $value); 
+		}
+		if($imap_criteria['filter']) array_unshift($imap_criteria['filter'], 'AND');
+		
+		$imap_uri = $uri;
+		$imap_uri['service'] = 'Imap';
+		if ($flagged && $flagged['id']) {
+			$flagged['id']  = $flagged['folderName'] . '/' . $flagged['messageNumber'] . '#' . $flagged['id']; 
+			$imap_uri['id'] = $flagged['id']; 
+		}
+
+		$result = Controller::delete($imap_uri, $params, $imap_criteria);		
+	}
+	
+	//PostgreSQL.before.update
+	public function doImapUpdate( &$uri , &$params , &$criteria , $original ) {
+		//TODO - update
+		//$imap_uri = $uri;
+		//$imap_uri['service'] = 'Imap';
+		//$result = Controller::update($imap_uri, $params, $criteria);
+	}
+	/*
+    public function createCalendarToSchedulable( &$uri , &$result , &$criteria , $original ){
+		Controller::create(array('concept' => 'calendarToSchedulable'), array('calendar' => $original['properties']['calendar'], 'schedulable' => $result['id'] ));
+	}
+	*/
+}
+
+?>
Index: trunk/prototype/modules/mail/interceptors/LabelSecure.php
===================================================================
--- trunk/prototype/modules/mail/interceptors/LabelSecure.php	(revision 5533)
+++ trunk/prototype/modules/mail/interceptors/LabelSecure.php	(revision 5533)
@@ -0,0 +1,17 @@
+<?php
+class LabelSecure {	
+
+	public function addVerifyOwnerFilter (&$uri , &$params , &$criteria , $original ){
+		
+		$ownerFilter = array( '=' , 'uid' , Config::me('uidNumber') );
+		
+		if (isset($criteria['filter']) && $criteria['filter']!=NULL && count($criteria['filter']) != 0)
+			$criteria['filter'] = array( 'AND', $criteria['filter'], $ownerFilter );
+		else
+			$criteria['filter'] =  $ownerFilter;
+			
+	}  
+
+}
+
+?>
Index: trunk/prototype/modules/mail/interceptors/FollowupflagSecure.php
===================================================================
--- trunk/prototype/modules/mail/interceptors/FollowupflagSecure.php	(revision 5533)
+++ trunk/prototype/modules/mail/interceptors/FollowupflagSecure.php	(revision 5533)
@@ -0,0 +1,28 @@
+<?php
+class FollowupflagSecure {	
+	
+	public function addVerifyOwnerFilter (&$uri , &$params , &$criteria , $original ){
+		
+		$ownerFilter = array( '=' , 'uid' , Config::me('uidNumber') );
+		
+		if (isset($criteria['filter']) && $criteria['filter']!=NULL && count($criteria['filter']) != 0)
+			$criteria['filter'] = array( 'AND', $criteria['filter'], $ownerFilter );
+		else
+			$criteria['filter'] =  $ownerFilter;
+			
+	}  
+
+	public function addDefaultElementsFilter (&$uri , &$params , &$criteria , $original ){
+		
+		$defaultsFilter = array( 'IN' , 'id' , array('1','2','3','4','5','6') );
+		
+		if (isset($criteria['filter']) && $criteria['filter']!=NULL && count($criteria['filter']) != 0)
+			$criteria['filter'] = array( 'OR', $criteria['filter'], $defaultsFilter );
+		else
+			$criteria['filter'] =  $defaultsFilter;
+		
+	}  
+     
+}
+
+?>
Index: trunk/prototype/modules/mail/css/label.css
===================================================================
--- trunk/prototype/modules/mail/css/label.css	(revision 5533)
+++ trunk/prototype/modules/mail/css/label.css	(revision 5533)
@@ -0,0 +1,102 @@
+.label-configure-win fieldset { border: 1px solid #CCC; border-radius:5px; margin:5px;}
+.label-configure-win legend { color: #707070; }
+.label-configure-win ul{text-align:left; margin: 0; padding: 0;}
+
+.label-configure-win { margin: 5px;}
+.label-configure-win .input-nome { width: 200px; outline:0; background:#FFF; }
+.label-configure-win .lebals-colorpicker { border: 1px solid #CCC; height: 210px; } 
+.label-configure-win .label-conf { float: left;}
+.label-configure-win .buttons { float:right; margin:5px 5px 0 0; }
+.label-configure-win .button-close-window { float:right; margin:6px 5px 0 0; }
+.label-configure-win .colorpicker { float: right; margin: 0 30px 0 0; } 
+.label-configure-win .preview-label-inner { margin: 2px 0 0 10px; float: left; }
+
+.label-configure-win .preview-label-outer { 
+	margin: 5px; 
+	float:left; 
+	width: 151px; 
+	height: 20px;  
+	margin: 20px 0 0 130px; 
+	-moz-border-radius: 4px; 
+	-webkit-border-radius: 4px; 
+	border: 1px solid #333;
+}
+.label-configure-win .colorwell { margin: 0; outline: 0; width: 151px; }
+.label-configure-win .label-cor { float:left; width: 130px;} 
+.label-configure-win .imgTriangle { width: 5px; height: 5px; background: #333;}
+
+.acc-list {
+	font-family: "Trebuchet MS", Tahoma, Verdana, Arial, sans-serif; 
+	font-size:11px;
+	color:#555; 
+}
+
+.acc-list h3{
+	font-family: "Trebuchet MS", Tahoma, Verdana, Arial, sans-serif; 
+	font-size:11px; 
+	color:#555; 
+	margin:0; 
+	padding:5px 3px; 
+	background-color:#fff;
+}
+
+.acc-list ul{ margin:5px 0;}
+.acc-list ul li{ border-radius:3px; padding:3px;}
+.label-configure-win .acc-list ul li:hover {background-color:#DDD;}
+.label-configure-win .acc-list ul li.active {background-color:#EB8F00;}
+.label-configure-win .acc-list ul li strong {display:block;}
+.label-configure-win .acc-list ul li em {display:block;}
+
+.label-configure-win .configure-label-content {
+	width:590px;
+	height:335px;
+	float:right;
+	border: 1px solid #A6C9E2; 
+	margin:2px 5px 0 0;
+	-moz-border-radius: 5px; 
+	-webkit-border-radius: 5px;
+}
+.label-configure-win .acc-list.list-label-content{
+	width:190px;
+	height:368px;
+	float:left;
+	margin:2px 10px 0 5px;
+	border: 1px solid #A6C9E2;
+	-moz-border-radius: 5px; 
+	-webkit-border-radius: 5px;
+}
+.label-configure-win .acc-list.list-label{
+	width:150px; 
+	height:70%; 
+	-moz-border-radius: 5px; 
+	-webkit-border-radius: 5px; 
+	margin:10px 0 0 0;
+}
+
+.label-configure-win .label-list-container .label-list { overflow: auto; height: 293px; margin:0px;}
+.label-configure-win .label-list-container .label-list li{ background: #FFF; margin:3px 2px 0 2px; border:1px solid #CCC; width: 162px; height:18px;}
+.label-configure-win .label-list-container .label-list .acc-list ul li{ border-radius:3px; padding:2px;}
+.label-configure-win .label-list-container .label-list li:hover { cursor:pointer; background:#ECEDFF}
+.label-configure-win .label-list-container .label-list li.empty-item { border:0px;}
+.label-configure-win .label-list-container .label-list li.empty-item:hover { cursor : auto; background:white;}
+.label-configure-win .label-list li .button { display:none;}
+.label-configure-win .label-list li:hover .button { display:block; }
+
+#MyMarckersList.list-label .my-labels {margin: 10px 0 0 20px; text-align:left; position: relative;}
+#MyMarckersList.list-label .title-my-labels{margin:0 0 0 5px;}
+#MyMarckersList.list-label .status-list-labels{display:inline-block; position: absolute;}
+#MyMarckersList.list-label ul {height: 60%; margin: 5px 0 0 6px; padding:0; list-style:none; }
+#MyMarckersList.list-label.acc-list ul li{ border-radius:3px;  padding:2px 2px 3px 2px;}
+#MyMarckersList.list-label li{ background: #FFF; margin:2px 2px 0 12px; border:1px solid #CCC; width: 150px; height:13px; }
+#MyMarckersList.list-label li:hover { cursor:pointer; background:#ECEDFF}
+
+.label-configure-win .insert-label{width: 200px; outline:0; background:#FFF;}
+.label-configure-win .attendee-list-add fieldset { height:15px; width: 178px; background:#FFF; margin:5px 2px 20px 2px;}
+.label-configure-win .attendee-list-add fieldset .insert-label{ width:130px; border:#FFF; outline: 0 none; margin:0; }
+.label-configure-win .color-suggestions { margin: 10px 0 30px 0; }
+.label-configure-win .form-item { margin: 5px 0;}
+.label-configure-win .selectedDefault { background: #fed4b4; border: 1px solid #fb8c37; -moz-border-radius: 5px; -webkit-border-radius:5px; }
+.label-configure-win .edit-value-list { opacity:0.65; margin-top:0; width:125px;}
+
+#listMarkers{width: 800px !important;}
+.label-configure-win .add-label-button { float:right; cursor: pointer; }
Index: trunk/prototype/modules/mail/css/followupflag.css
===================================================================
--- trunk/prototype/modules/mail/css/followupflag.css	(revision 5533)
+++ trunk/prototype/modules/mail/css/followupflag.css	(revision 5533)
@@ -0,0 +1,72 @@
+.ZebraDialog_Body .footerMais,.footerMenos {cursor: pointer; color: #0f1dff;}
+.ZebraDialog_Body .footerMais2,.footerMenos2 {cursor: pointer; color: #0f1dff;}
+.ZebraDialog_Body .alert-flags a{ cursor: pointer;}
+.ZebraDialog_Body .alert-flags li:hover{ text-decoration: underline;}
+
+.followupflag-configure-win { width:543px; height:412px !important;  } 
+.followupflag-container { 
+	width:530px; 
+	height:398px; 
+	border: 1px solid #A6C9E2; 
+	float:left; 
+	-moz-border-radius: 5px; 
+	-webkit-border-radius: 5px; 
+	margin:5px;
+}
+
+.followupflag-configure-win .followupflag-container  fieldset{border: 1px solid #CCC; border-radius:5px; margin:5px;}
+.followupflag-configure-win .followupflag-container  legend {color: #707070; font-weight:bold;}
+
+.followupflag-configure-win .followupflag-configure button { height:20px; margin: 0; top:4px; }
+.followupflag-container .followupflag-configure { float: left; width: 270px }
+.followupflag-container .followupflag-configure .label-name{display: block;}
+
+.followupflag-container .alarm-fields{ display: block; margin-top:15px; width:265px;}
+.followupflag-container .date,
+.followupflag-container .time{ -moz-border-radius: 5px; -webkit-border-radius: 5px; outline: 0; }
+.followupflag-container .alarm-datetime-fields {float:right;}
+.followupflag-container .completed-followup{margin-top:6px;}
+
+.followupflag-container .right-data {margin: 5px 0; width: 195px; float: right;}
+.followupflag-container .right-data label {display: block;}
+
+.followupflag-container .date-begin { 
+	margin: 0 0 5px 44px; 
+	-moz-border-radius: 5px; 
+	-webkit-border-radius: 5px; 
+	outline: 0; 
+}
+
+.followupflag-container .date-conclusion { 
+	margin: 0 0 0 16px; 
+	-moz-border-radius: 5px;
+	-webkit-border-radius: 5px; 
+	 outline: 0; 
+ }
+.followupflag-container .followupflag-color.sample-list .sample-item { padding: 5px; margin:0 5px; }
+
+.followupflag-container .followupflag-color.sample-list .sample-item.selected { 
+	background: #fed4b4; 
+	border: 1px solid #fb8c37; 
+	-moz-border-radius: 5px; 
+	-webkit-border-radius:5px; 
+}
+
+.left-seletor-flag { float: left; margin: 3px 20px 3px 0; }
+.color-followup-flag { float: left; width: 400px; }
+.form-item { margin: 5px 0;}
+.flag-label { float: left; margin: 0 5px 0 0; } 
+.followupflag-container .background-color  {margin:0; outline: 0; width: 100px; -moz-border-radius: 5px; -webkit-border-radius:5px; float: left; }
+.flag-edit { background: #00820F; width: 8px; height: 6px; float:left; margin: 4px 0 -3px 5px; }
+.flag-edited{ width: 8px; height: 6px;}
+.colorpicker { float: right; margin: -15px 0 0 0; }
+
+.followupflag-configure-win .followupflag-container .menu-configure-followupflag{ 
+	position:absolute; 
+	bottom:14px; 
+	right:11px; 
+	background:transparent; 
+	width:auto; 
+	margin:0;
+	padding:0;
+}
Index: trunk/prototype/modules/mail/js/label.js
===================================================================
--- trunk/prototype/modules/mail/js/label.js	(revision 5533)
+++ trunk/prototype/modules/mail/js/label.js	(revision 5533)
@@ -0,0 +1,533 @@
+function colors_suggestions(){
+	return [
+				{name:'Padrão', border:'#3366cc', font:'#ffffff', background:'#3366cc'},
+				{name:'Coala', border:'#123456', font:'#ffffff', background:'#385c80'},
+				{name:'Tomate', border:'#d5130b', font:'#111111', background:'#e36d76'},
+				{name:'Limão', border:'#32ed21', font:'#1f3f1c', background:'#b2f1ac'},
+				{name:'Alto contraste', border:'#000000', font:'#ffffff', background:'#222222'}
+			]		
+}
+function rgb2hex(rgb){
+ rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
+ return "#" +
+  ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
+  ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
+  ("0" + parseInt(rgb[3],10).toString(16)).slice(-2);
+}
+
+function init_label(data){
+
+	winElement = data.window;
+
+	var configureLabel = function(event, ui){
+		var idmarkernow = $(this).find('[name="labelItemId"]').val();
+		winElement.find('.edit-label').val(idmarkernow);
+		winElement.find('.input-nome').val($(this).find("span").text());
+		
+		var colorpicker = winElement.find('.lebals-colorpicker');
+		colorpicker.find('input[name="backgroundColor"]').val(rgb2hex($(this).css("backgroundColor")))
+		.css("background-color", $(this).css("backgroundColor")).focus().end()
+		.find('input[name="fontColor"]').val(rgb2hex($(this).css("color"))).css("background-color", $(this).css("color")).focus().end()
+		.find('input[name="borderColor"]').val(rgb2hex($(this).css("border-left-color"))).css("background-color", $(this).css("border-left-color")).focus().end()
+		.find('.preview-label-outer').css({
+			'background-color':$(this).css("backgroundColor"),
+			'color':$(this).css("color"),
+			'border-color':$(this).css("border-left-color")
+		})		
+		winElement.find(".preview-label-inner").text($(this).text());
+	}
+	//TODO Mudar quando API abstrair atualizações no cache
+	DataLayer.remove('label',false);
+	labels = DataLayer.get('label',{criteria:{order: 'name'}});
+	
+	if(labels){
+		Label_List = winElement
+		.find(".label-list-container").html(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels: labels}));
+		
+	}else{
+		/**
+		* Quando não existir marcadores cadastrados
+		* exibe a mensagem informando o usuário de que não há
+		* nenhum marcador cadastrado.
+		*/
+		Label_List = winElement
+		.find(".label-list-container").html('<ul class="label-list"><li class="empty-item">Nenhum Marcador Cadastrado.</li></ul>');
+		
+	}
+	Label_List.end()
+	.find('.button').button()
+	.filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end()
+	.filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); 	
+	
+	var editLabel = function(){	
+		var conteudoSpan = $(this).parent().find(".text-list").text();
+		var span = $(this).parent().find(".text-list");
+		$(this).parent().trigger('click').unbind('click', configureLabel).find("span.text-list")
+		.html('<input name="edit-value-list" class="edit-value-list" type="text" value="'+conteudoSpan+'">').find("input[name='edit-value-list']").keydown(function(event){
+			event.stopPropagation();
+			$("input.edit-value-list").keyup(function () {
+				var value = $(this).val();
+				winElement.find('.input-nome').val(value);
+			}).keyup();
+			if(event.keyCode == 13){
+				$(span).html($(".label-list").find(".edit-value-list").val())
+				.parent().find('.edit').removeClass("hidden").parents("li").click(configureLabel).trigger("click");
+				winElement.find(".buttons .save-label").trigger("click");
+			}else if( event.keyCode == 27){
+				$(this).trigger("focusout");
+			}
+		}).focusout(function(){
+			$(span).html(conteudoSpan)
+			.parent().find('.edit').removeClass("hidden").parents("li").click(configureLabel);
+		}).focus();
+		$(this).addClass("hidden");
+	}
+	
+	winElement.find('.edit').click(editLabel);
+	winElement.find('.close').click(function(event){
+		var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
+		confirmDelete(id);
+		event.stopImmediatePropagation();
+	});
+	/**
+	* Testa novamente se existem marcadores cadastrados, 
+	* pois nesse momento os botões Excluir, Desfazer e Salvar já existem
+	* e os marcadores já estão listados na tela,
+	* então é possível alterar o text do Salvar para Criar,
+	* caso não exista nenhum marcador cadastrado e listado na tela de configuração dos marcadores,
+	* ou "marcar" o primeiro marcador listado com o "triangulo", caracterizando que o mesmo está selecionado.
+	*/
+	
+	//marca 'd agua e adicionar label na lista.
+	winElement.find(".insert-label").Watermark(winElement.find(".insert-label").val());
+	
+	$("input.insert-label").keyup(function () {
+		$.Watermark.HideAll();
+		var value = $(this).val();
+		winElement.find('.input-nome').val(value);
+	}).keyup();
+	
+	if (!(labels)){
+		winElement.find(".buttons .save-label .ui-button-text").text('Criar');
+		$(".delete-label").button("disable");
+	}else{
+		winElement.find(".label-list li:first").addClass("selected").prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>");
+	}
+	$(".save-label").button("disable");
+	/**
+	* seta a ação de click para os marcadores listados na tela
+	*/
+	winElement.find(".label-list li").not(".empty-item").click(configureLabel);
+	
+	if (data.selectedItem)
+		winElement.find(".label-list li.label-item-"+data.selectedItem).trigger("click");
+	else
+		winElement.find(".label-list li:first").trigger("click");
+		
+	var dataColorPicker = {
+		colorsSuggestions: colors_suggestions()
+	};
+	
+	winElement.find('select.color-suggestions').change(function() {
+		$(".save-label").button("enable");
+		var colorpicker = winElement.find('.lebals-colorpicker');
+		var colors;
+		if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) {	
+			colorpicker
+			.find('input[name="fontColor"]').val(colors.font).focus().end()	
+			.find('input[name="backgroundColor"]').val(colors.background).focus().end()
+			.find('input[name="borderColor"]').val(colors.border).focus().end()
+
+			.find('.preview-label-outer').css({
+				'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background,
+				'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border,
+				'color':dataColorPicker.colorsSuggestions[$(this).val()].font 
+			});
+		}					
+	});
+	var colorpickerPreviewChange = function(color) {
+			
+		var pickedup = winElement.find('.colorwell-selected').val(color).css('background-color', color);
+
+		$(".save-label").button("enable");
+		
+		var colorpicker = winElement.find('.lebals-colorpicker');			
+
+		if (pickedup.is('input[name="backgroundColor"]')) {
+			colorpicker.find('.preview-label-outer').css('background-color',color);
+		} else if (pickedup.is('input[name="fontColor"]')) {
+			colorpicker.find('.preview-label-outer').css('color',color);
+		} else if (pickedup.is('input[name="borderColor"]')) {
+			colorpicker.find('.preview-label-outer').css('border-color',color);
+		}		
+	} 
+		
+	var f = $.farbtastic(winElement.find('.colorpicker'), colorpickerPreviewChange);
+	var selected;
+				
+	winElement.find('.colorwell').each(function () {
+		f.linkTo(this);
+	})
+	.focus(function() {
+		if (selected) {
+			$(selected).removeClass('colorwell-selected');
+		}
+		$(selected = this).addClass('colorwell-selected');
+		f.linkTo(this, colorpickerPreviewChange);
+		f.linkTo(colorpickerPreviewChange);
+	});
+	
+
+	
+	winElement.find(".add-label-button").click(function (event) {
+		$.Watermark.HideAll();
+		var name = winElement.find(".insert-label").val();
+		if(name.length >= 2){
+			DataLayer.put('label', {name: name, uid: User.me.id});
+			
+			$(".add-label-button").removeClass("ui-icon ui-icon-plus")
+			.html('<img alt="Carregando" title="Carregando" style="margin-left:10px;" src="../prototype/modules/mail/img/loader.gif" />');
+			
+			DataLayer.commit(false, false, function(){
+
+				labels = DataLayer.get('label',{criteria:{order: 'id'}}, true);
+				newLabel = {
+					id: labels[labels.length -1 ].id, 
+					name : labels[labels.length -1].name,
+					uid: User.me.id
+				};
+
+				$(".label-list-container ul").find(".empty-item").css("display","none");
+				
+				$(".label-list-container ul, .list-label ul")
+				.prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel))
+				.find("li:first")
+				.fadeIn("slow").click(configureLabel);
+				
+				$(".label-list-container .label-list li").not(".empty-item").click(function(){
+					$(".save-label").button("disable");
+					$(".label-list-container .label-list li").find("img").remove();
+					$(".label-list-container .label-list li.label-item").removeClass("selected");
+					$(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>");
+					$(this).addClass("selected");
+				});
+				
+				$(".label-list-container .label-list li").find('.button').button()
+				.filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end()
+				.filter('.close').button({icons:{primary:'ui-icon-close'}, text:false});
+					
+				winElement.find('.edit').unbind("click").click(editLabel);
+				
+				winElement.find('.close').click(function(event){
+					var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
+					confirmDelete(id);
+					event.stopImmediatePropagation();
+				});
+				
+				$.Watermark.ShowAll();
+				winElement.find(".insert-label").val("");
+				
+				//posiciona para edição o label inserido			
+				winElement.find("ul.label-list li:first").trigger("click");			
+				winElement.find(".buttons .save-label .ui-button-text").text('Salvar');
+				$(".delete-label").button("enable");		
+
+				//Remove o título da lista de Marcadores da tela principal do módulo
+				$(".my-labels").removeClass("hidden");
+				/**
+				* atualiza menu
+				* Remove o menu presente em cada mensagem listada em uma pasta 
+				* e carrega novamente para que os dados sejam atualizados
+				*/
+				$.contextMenu( 'destroy', ".table_box tbody tr");
+				loadMenu();
+				$(".add-label-button").empty()
+				.addClass("ui-icon ui-icon-plus");
+			});
+			} else {
+				alert("Mínimo 2 caracteres");
+			}
+
+		event.stopImmediatePropagation();
+	});
+	
+	winElement.find('.insert-label').keydown(function(event, ui) {
+		if (event.keyCode == 13)
+			winElement.find(".add-label-button").trigger('click');
+	});
+
+	function confirmDelete(id){
+
+		$.Zebra_Dialog('<strong>Deseja excluir esse marcador?</strong>', {
+			'type':     'question',
+			'title':    'Atenção',
+			'buttons': ['Sim','Não'],	
+			'onClose':  function(caption) {
+				if(caption == 'Sim'){
+					deleteLabel(id);
+				}
+			}
+		});	
+	}	
+		
+	function deleteLabel(id){
+		$(".label-list li").each(function () {
+			var regex_match = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+			if (regex_match && regex_match[1] && regex_match[1] == id) {	
+				$(this).remove();
+			}
+		});
+		DataLayer.remove('label', id);
+		DataLayer.commit();
+		winElement.find(".label-list li:first").trigger("click");
+		
+		if($(".label-list li").length == 0){
+			winElement.find(".label-list-container").html('<ul class="label-list"><li class="empty-item">Nenhum Marcador Cadastrado.</li></ul>');			
+		} 
+		var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length;
+		if (qtdLi == 0){
+			$(".my-labels").addClass("hidden");
+			$(".label-list-container ul").find(".empty-item").css("display","");
+			winElement.find(".buttons .save-label .ui-button-text").text('Criar');
+			$(".delete-label").button("disable");	
+					
+			winElement.find('.input-nome').val("");
+			winElement.find(".preview-label-inner").text("");
+		
+			var colorpicker = winElement.find('.lebals-colorpicker');
+			colorpicker.find('input[name="backgroundColor"]').val("#ffffff")
+			.css("background-color", "#ffffff").focus().end()
+			.find('input[name="fontColor"]').val("#444444").css("background-color", "#000000").focus().end()
+			.find('input[name="borderColor"]').val("#cccccc").css("background-color", "#000000").focus().end()
+			.find('.preview-label-outer').css({
+				'background-color':"#ffffff",
+				'color':"#444444",
+				'border-color':"#cccccc"
+			});
+			$(".input-nome").keyup(function () {
+				var value = $(this).val();
+				winElement.find('.preview-label-inner').text(value);
+			}).keyup();				
+		}		
+	}
+	//excluir marcador {deve ser para o botão grande na janela de edição e nao o pequeno da lista}
+	winElement.find(".buttons .delete-label").click(function(event){
+		var id = winElement.find(".edit-label").val();
+		confirmDelete(id);
+		event.stopImmediatePropagation();
+	});
+	$(".label-list-container .label-list li").not(".empty-item").click(function(){
+		$(".label-list-container .label-list li").find("img").remove();
+		$(".label-list-container .label-list li.label-item").removeClass("selected");
+		$(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>");
+		$(this).addClass("selected");
+	});
+		
+	//salvar/criar marcador
+	winElement.find(".buttons .save-label").click(function(){
+		$(".save-label").button("disable");
+		var labelEdited = {
+			id : winElement.find(".edit-label").val(),
+			uid: User.me.id,
+			name : winElement.find('.input-nome').val(),
+			backgroundColor : winElement.find("input[name='backgroundColor']").val(),
+			fontColor : winElement.find("input[name='fontColor']").val(),
+			borderColor : winElement.find("input[name='borderColor']").val()
+		}
+		var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length;	
+		// salvar marcador
+		if(qtdLi > 0){
+			$(".label-list-container .label-list li").each(function(){
+				var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+				
+				 if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){
+				   $(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span class='text-list'>"+labelEdited.name+"</span><div class='button close tiny' style='float: right'></div><div class='button edit tiny' style='float: right'></div>").css({
+					"background" : labelEdited.backgroundColor,
+					"color" : labelEdited.fontColor, 
+					"border-color" : labelEdited.borderColor	
+				   });
+				 }	
+			});
+			
+			$("#MyMarckersList .label-list li").each(function(){
+				var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+				
+				if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){
+					$(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span>"+labelEdited.name+"</span>");
+					$(this).find(".square-color").css('background', labelEdited.backgroundColor);
+				}	
+			});
+			DataLayer.put('label', labelEdited.id, labelEdited);
+			DataLayer.commit(false, false, function(){
+				$("#MyMarckersList")
+				.html(
+					"<div class='my-labels'>" +
+						"<img src='../prototype/modules/mail/img/tag.png'/>" +
+						"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='Meus marcadores'>Meus marcadores</a>" +
+						
+						"<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" +
+					"</div>"
+				)
+				.append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels:DataLayer.get('label', true)} ))
+				.find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"})
+				.find(".square-color").css("display","").click(function(){
+					$(this).parent(".label-item").each(function(){
+						configureLabels({selectedItem: $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]});
+					});
+				});
+				
+				$("#MyMarckersList a.title-my-labels").click(function() {
+					$("#MyMarckersList ul.label-list").toggleClass("hidden")
+					$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s");
+					$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n");
+				 });
+	 
+				$.Watermark.ShowAll();
+				winElement.find(".insert-label").val("");
+				$(".label-list-container .label-list li").find('.button').button()
+					.filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end()
+					.filter('.close').button({icons:{primary:'ui-icon-close'}, text:false});
+				winElement.find('.edit').unbind("click").click(editLabel);
+				
+				winElement.find('.close').click(function(event){
+					var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
+					confirmDelete(id);
+					event.stopImmediatePropagation();
+				});
+			});
+		// criar marcador
+		} else{
+			var nameLabel = winElement.find(".input-nome").val();
+			var labelCreated = {
+				uid: User.me.id,
+				name : nameLabel,
+				backgroundColor : winElement.find("input[name='backgroundColor']").val(),
+				fontColor : winElement.find("input[name='fontColor']").val(),
+				borderColor : winElement.find("input[name='borderColor']").val()
+			}
+			
+			if(nameLabel.length >= 2){
+				DataLayer.put('label', labelCreated);
+				DataLayer.commit(false, false, function(){
+
+					labels = DataLayer.get('label',{criteria:{order: 'id'}}, true);
+					newLabel = {
+						id: labels[labels.length - 1].id, 
+						name : labels[labels.length- 1].name,
+						uid: User.me.id,
+						bgColor : winElement.find("input[name='backgroundColor']").val(),
+						fontColor : winElement.find("input[name='fontColor']").val(),
+						borderColor : winElement.find("input[name='borderColor']").val()
+					};
+
+					$(".label-list-container ul").find(".empty-item").css("display","none");
+					$(".label-list-container ul")
+					.prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel))
+					.find("li:first")
+					.fadeIn("slow").click(configureLabel);
+					
+					$("#MyMarckersList")
+					.html(
+						"<div class='my-labels'>" +
+							"<img src='../prototype/modules/mail/img/tag.png'/>" +
+							"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='Meus marcadores'>Meus marcadores</a>" +
+							
+							"<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" +
+						"</div>"
+					)
+					
+					.append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels:DataLayer.get('label', true)} ))
+					.find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"})
+					.find(".square-color").css("display","").click(function(){
+						$(this).parent(".label-item").each(function(){
+							configureLabels({selectedItem: $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]});
+						});
+					});
+					$("#MyMarckersList a.title-my-labels").click(function() {
+						$("#MyMarckersList ul.label-list").toggleClass("hidden")
+						$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s");
+						$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n");
+					 });
+	 
+					$(".label-list-container .label-list li").not(".empty-item").click(function(){
+						$(".label-list-container .label-list li").find("img").remove();
+						$(".label-list-container .label-list li.label-item").removeClass("selected");
+						$(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>");
+						$(this).addClass("selected");
+					});
+					
+					$(".label-list-container .label-list li").find('.button').button()
+					.filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end()
+					.filter('.close').button({icons:{primary:'ui-icon-close'}, text:false});
+					$.Watermark.ShowAll();
+					winElement.find(".insert-label").val("");
+					
+					//posiciona para edição o label inserido			
+					winElement.find("ul.label-list li:first").trigger("click");			
+					winElement.find(".buttons .save-label .ui-button-text").text('Salvar');
+					$(".delete-label").button("enable");
+					
+					winElement.find('.edit').unbind("click").click(editLabel);
+				
+					winElement.find('.close').click(function(event){
+						var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
+						confirmDelete(id);
+						event.stopImmediatePropagation();
+					});
+					
+					$(".my-labels").removeClass("hidden");
+				});
+			} else {
+				alert("Mínimo 2 caracteres");
+			}		
+		}		
+		/**
+		* atualiza menu
+		* Remove o menu presente em cada mensagem listada em uma pasta 
+		* e carrega novamente para que os dados sejam atualizados
+		*/
+		$.contextMenu( 'destroy', ".table_box tbody tr");
+		loadMenu();
+		
+		$(".label-list-container .label-list").find(".label-item-"+labelEdited.id).trigger("click");
+	});	
+	//desfazer marcador
+	winElement.find(".buttons .undo-label").click(function(event){
+		var edit = winElement.find(".edit-label").val();		
+		$(".label-list-container .label-list li").each(function(){
+			var regex_match_3 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+			if(regex_match_3 && regex_match_3[1] && regex_match_3[1] == edit){
+				$(this).trigger("click");
+			}
+		});
+	});
+	
+	//fechar
+	$(".button-close-window .close-window").click(function(){
+		$(".label-configure-win").dialog("close");
+	});	
+			
+	$(".configure-label-content").find("input[type='text']").focus(function () {
+		$(this).keyup(function(){
+			var value = $(this).val();
+			if(value){
+				$(".save-label").button("enable");	
+			}else{
+				$(".save-label").button("disable");	
+			}
+		});
+
+	});	
+	
+	$(".input-nome").keyup(function () {
+				var value = $(this).val();
+				winElement.find('.preview-label-inner').text(value);
+	}).keyup();
+	
+}
+
+/**
+ * TODO:
+ * * Qunado excluir um marcador deve ser removido das mensagens sem que seja necessario atualizar o Expresso.
+ * * Fazer abrir a configuração do Marcador pela lista do modulo principal apenas quando criado um marcador sem clicar no botão "salvar".
+ */
Index: trunk/prototype/modules/mail/js/followupflag.js
===================================================================
--- trunk/prototype/modules/mail/js/followupflag.js	(revision 5533)
+++ trunk/prototype/modules/mail/js/followupflag.js	(revision 5533)
@@ -0,0 +1,418 @@
+//se  caso não existir nenhuma mensagem concluida para o dia atual, ele não mostra a modal.
+ if($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")){
+	var alarmInRange = DataLayer.get('followupflagged', {filter: ['AND', ['>', 'alarmDeadline', (new Date()).set({hour:0, minute:0, second:0}).toString('yyyy-MM-dd 00:00:00')], ['<', 'alarmDeadline', (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}});
+	if(alarmInRange.length > 0){
+		for(var i=0; i<alarmInRange.length; i++){
+			var date = Date.parseExact(alarmInRange[i].alarmDeadline, 'yyyy-MM-dd hh:mm:ss');
+			alarmInRange[i].alarmDeadline = date.toString('hh:mm');
+		}
+		var data = {alarmInRange : alarmInRange};
+		var valueZebra = DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs", data);
+		
+		new $.Zebra_Dialog(valueZebra, {
+		'buttons':  ['Ok'],
+		'modal': false,
+		'position': ['right - 20', 'bottom - 30'],
+		'custom_class': 'zebraClass2',
+		});	
+		
+	$(".ZebraDialog_Body .footerMenos").hide()
+
+		$(".ZebraDialog_Body .footerMais").click(function(){
+			$('.ZebraDialog').css('visibility','hidden');
+			$(this).parents('.ZebraDialog').css("visibility","visible");
+			$(this).parents('.ZebraDialog').animate( { top: '-=300px' } , 280)
+			.find("ul.alert-flags").animate( { height: 375 } , 300);
+			$(".ZebraDialog_Body .footerMais").hide();
+			$(".ZebraDialog_Body .footerMenos").show();
+		});
+		$(".ZebraDialog_Body .footermenos").click(function(){
+			$('.ZebraDialog').css('visibility','visible');
+			$(this).parents('.ZebraDialog').animate( { top: '+=300px' } , 280)
+			.find("ul.alert-flags").animate( { height: 70 } , 300);
+			
+			$(this).parents('.ZebraDialog').css({
+			});
+			$(".ZebraDialog_Body .footerMenos").hide();
+			$(".ZebraDialog_Body .footerMais").show();
+		});
+		
+		
+		$("ul.alert-flags li").css({
+			'width': '270px',
+			'white-space': 'nowrap',
+			'overflow': 'hidden',
+			'text-overflow': 'ellipsis'
+		});
+		
+		$("span.exc-ocul").css({
+			'float' : 'right',
+			'margin-right' : '0',
+			'color' : '#2363a4',
+			'cursor' : 'pointer'
+		}).parent("ul").css();
+		
+		$(".zebraClass2 .ZebraDialog_Buttons .ZebraDialog_Button0").click(function(){
+			var countCheckbox2 = $("input:checked").length;
+
+			if(countCheckbox2 == 1){
+				date2 = (new Date).toString("dd/MM/yyyy");
+				$.cookie("fadeAlarm", date2 , { expires: 1 });
+			}
+		});
+	}		
+}
+
+if($.cookie("fadeCompleted") != (new Date).toString("dd/MM/yyyy")){	
+	var doneInRange = DataLayer.get('followupflagged', {filter: ['AND', ['>', 'doneDeadline', (new Date()).set({hour:0, minute:0, second:0}).toString('yyyy-MM-dd 00:00:00')], ['<', 'doneDeadline', (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}});
+	if(doneInRange.length > 0){
+		for(var i=0; i<doneInRange.length; i++){
+			var date = Date.parseExact(doneInRange[i].doneDeadline, 'yyyy-MM-dd hh:mm:ss');
+			doneInRange[i].doneDeadline = date.toString('hh:mm');
+		}
+		var data = {doneInRange : doneInRange};
+		var valueZebra = DataLayer.render("../prototype/modules/mail/templates/followupflag_completed_list.ejs", data);
+		
+		//verificando se a primeira "model de alarme" está oculta ou não..
+		//caso ela esteja caira nesse primeiro if, que coloca a model de "concluidos" no lugar da model de alarme.
+		if($(".zebraClass2").length == 0){
+			new $.Zebra_Dialog(valueZebra, {
+				'buttons':  ['Ok'],
+				'modal': false,
+				'position': ['right - 20', 'bottom - 30' ],
+				'custom_class': 'zebraClass',
+				});	 	 
+		}else{
+			new $.Zebra_Dialog(valueZebra, {
+				'buttons':  ['Ok'],
+				'modal': false,
+				'position': ['right - 20', 'bottom - 275' ],
+				'custom_class': 'zebraClass',
+				});	
+		}
+		
+	$(".ZebraDialog_Body .footerMenos2").hide()
+
+		$(".ZebraDialog_Body .footerMais2").click(function(){
+			$('.ZebraDialog').css('visibility','hidden');
+			$(this).parents('.ZebraDialog').css("visibility","visible");
+			if($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")){
+				$(this).parents('.ZebraDialog').animate( { top: '-=60px' } , 280)
+				.find("ul.alert-flags").animate( { height: 360 } , 300);
+			} else {
+				$(this).parents('.ZebraDialog').animate( { top: '-=300px' } , 280)
+				.find("ul.alert-flags").animate( { height: 360 } , 300);
+			}
+			
+			$(".ZebraDialog_Body .footerMais2").hide();
+			$(".ZebraDialog_Body .footerMenos2").show();
+		});
+		$(".ZebraDialog_Body .footermenos2").click(function(){
+			$('.ZebraDialog').css('visibility','visible');
+			if($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")){
+				$(this).parents('.ZebraDialog').animate( { top: '+=60px' } , 280)
+				.find("ul.alert-flags").animate( { height: 70 } , 300);
+			} else {
+				$(this).parents('.ZebraDialog').animate( { top: '+=300px' } , 280)
+				.find("ul.alert-flags").animate( { height: 70 } , 300);
+			}
+			$(this).parents('.ZebraDialog').css({
+			});
+			$(".ZebraDialog_Body .footerMenos2").hide();
+			$(".ZebraDialog_Body .footerMais2").show();
+		});
+		
+		
+		$("ul.alert-flags li").css({
+			'width': '270px',
+			'white-space': 'nowrap',
+			'overflow': 'hidden',
+			'text-overflow': 'ellipsis'
+		});
+		
+		$("span.exc-ocul").css({
+			'float' : 'right',
+			'margin-right' : '0',
+			'color' : '#2363a4',
+			'cursor' : 'pointer'
+		}).parent("ul").css();
+		
+		$(".zebraClass .ZebraDialog_Buttons .ZebraDialog_Button0").click(function(){
+		
+			var countCheckbox1 = $("input:checked").length;
+
+			if(countCheckbox1 == 1){
+				date1 = (new Date).toString("dd/MM/yyyy");
+				$.cookie("fadeCompleted", date1 , { expires: 1 });
+			}
+		});
+	}		
+}
+function init_followup(data){
+
+	winElement = data.window;
+	selectedMessageIds = data.selectedMessages;
+	folder = current_folder;
+
+	/**
+	 * Implementação do widget de input-combobox
+	 */
+	(function( $ ) {
+		$.widget( "ui.combobox", {
+			_create: function() {
+				var self = this,
+					select = this.element.hide(),
+					selected = select.children( ":selected" ),
+					value = selected.val() ? selected.text() : "";
+				var input = this.input = $( "<input>" )
+					.insertAfter( select )
+					.val( value )
+					.autocomplete({
+						delay: 0,
+						minLength: 0,
+						source: function( request, response ) {
+							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
+							response( select.children( "option" ).map(function() {
+								var text = $( this ).text();
+								if ( this.value && ( !request.term || matcher.test(text) ) )
+									return {
+										label: text.replace(
+											new RegExp(
+												"(?![^&;]+;)(?!<[^<>]*)(" +
+												$.ui.autocomplete.escapeRegex(request.term) +
+												")(?![^<>]*>)(?![^&;]+;)", "gi"
+											), "<strong>$1</strong>" ),
+										value: text,
+										option: this
+									};
+							}) );
+						},
+						select: function( event, ui ) {
+							ui.item.option.selected = true;
+							self._trigger( "selected", event, {
+								item: ui.item.option
+							});
+						},
+						change: function( event, ui ) {
+							if ( !ui.item ) {
+								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+									valid = false;
+								select.children( "option" ).each(function() {
+									if ( $( this ).text().match( matcher ) ) {
+										this.selected = valid = true;
+										return false;
+									}
+								});
+								if ( !valid ) {
+									// remove invalid value, as it didn't match anything
+									$( this ).val( "" );
+									select.val( "" );
+									input.data( "autocomplete" ).term = "";
+									return false;
+								}
+							}
+						}
+					})
+					.addClass( "ui-widget ui-widget-content ui-corner-left" );
+
+				input.data( "autocomplete" )._renderItem = function( ul, item ) {
+					return $( "<li></li>" )
+						.data( "item.autocomplete", item )
+						.append( "<a>" + item.label + "</a>" )
+						.appendTo( ul );
+				};
+
+				this.button = $( "<button type='button'>&nbsp;</button>" )
+					.attr( "tabIndex", -1 )
+					.attr( "title", "Show All Items" )
+					.insertAfter( input )
+					.button({
+						icons: {
+							primary: "ui-icon-triangle-1-s"
+						},
+						text: false
+					})
+					.removeClass( "ui-corner-all" )
+					.addClass( "ui-corner-right ui-button-icon" )
+					.click(function() {
+						// close if already visible
+						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
+							input.autocomplete( "close" );
+							return;
+						}
+
+						// work around a bug (likely same cause as #5265)
+						$( this ).blur();
+
+						// pass empty string as value to search for, displaying all results
+						input.autocomplete( "search", "" );
+						input.focus();
+					});
+			},
+
+			destroy: function() {
+				this.input.remove();
+				this.button.remove();
+				this.element.show();
+				$.Widget.prototype.destroy.call( this );
+			}
+		});
+	})( jQuery );
+	/**
+	 * #END: Implementação do widget de input-combobox
+	 */
+
+	winElement.find('.button').button()
+	.filter('.menu-configure-followupflag .cancel').click(function(){
+		winElement.dialog("close");
+	}).end()
+	
+	.filter('.menu-configure-followupflag .save').click(function(){	
+				
+		var backgroundColor = winElement.find('[name="backgroundColor"]').val();
+		var followupflagId  = winElement.find('[name="name"] option:selected').val();
+		var isDone = winElement.find('[name="done"]').is(':checked') ? 1 : 0;
+		var alarmDate = false;
+		var doneDate  = false;
+		
+		for (var i=0; i < selectedMessageIds.length; i++ ){
+			var messageNumber   = selectedMessageIds[i];
+			//var followupflag = DataLayer.get('followupflag', followupflagId.toString()),
+			var followupflagged = {
+				uid : User.me.id,
+				followupflagId : followupflagId, 
+				folderName : current_folder, 
+				messageNumber : messageNumber, 
+				//alarmDeadline : winElement.find('[name="alarmDate"]').datepicker("getDate"), 
+				//doneDeadline: winElement.find('[name="doneDate"]').datepicker("getDate"),
+				isDone: isDone,
+				backgroundColor : backgroundColor
+			}
+			
+			if (alarmDate = winElement.find('[name="alarmDate"]').datepicker("getDate")) {
+				if (alarmTime = winElement.find('[name="alarmTime"]').datepicker("getDate")) {
+					alarmDate.set({hour:alarmTime.getHours(), minute:alarmTime.getMinutes()});
+				}
+				followupflagged.alarmDeadline = alarmDate.toString('yyyy-MM-dd hh:mm:ss');
+			}
+
+			if (doneDate = winElement.find('[name="doneDate"]').datepicker("getDate")) {
+				if (doneTime = winElement.find('[name="doneTime"]').datepicker("getDate")) {
+					doneDate.set({hour:doneTime.getHours(), minute:doneTime.getMinutes()});
+				}
+				followupflagged.doneDeadline = doneDate.toString('yyyy-MM-dd hh:mm:ss');
+			}
+			
+			if(isDone){
+				$('#td_message_followup_' + messageNumber + ', ' + 
+				'#td_message_followup_search_' + messageNumber).find(".flag-edited")
+				.find("img").attr("src", "../prototype/modules/mail/img/flagChecked.png")
+				.css("margin-left","-3px");
+			}
+			
+			$('#td_message_followup_' + messageNumber + ', ' + 
+			  '#td_message_followup_search_' + messageNumber).find(".flag-edited").css("background", backgroundColor);
+			  
+			DataLayer.put('followupflagged', followupflagged);
+		}
+		DataLayer.commit();
+		
+		//onceOpenedHeadersMessages[current_folder][followupflagged.messageNumber]['followupflagged']['followupflag'] = {};
+		var extend = DataLayer.get('followupflagged', {
+		filter: ['AND', ['IN', 'messageNumber', selectedMessageIds], ['=', 'folderName', current_folder]],criteria: {deepness: 1}});
+		if(extend != "" || extend != 'undefined' || extend != []){
+			for(var ex = 0; ex < extend.length; ex++){
+				onceOpenedHeadersMessages[current_folder][extend[ex].messageNumber]['followupflagged'] = {};
+				DataLayer.merge(onceOpenedHeadersMessages[current_folder][extend[ex].messageNumber]['followupflagged'], extend[ex]);
+			}
+		} else {
+			alert('erro ao salvar');
+		}
+	}).end()
+	
+	.filter('.menu-configure-followupflag .delete').click(function(){
+		for(i = 0; i < selectedMessageIds.length; i++){
+			var messageNumber   = selectedMessageIds[i];
+			var flag_id = onceOpenedHeadersMessages[current_folder][messageNumber]['followupflagged'].id;
+			DataLayer.remove('followupflagged', flag_id);
+			$('#td_message_followup_' + messageNumber + ', ' + 
+			  '#td_message_followup_search_' + messageNumber).find(".flag-edited").css("background", '#CCC');
+			$('#td_message_followup_' + messageNumber + ', ' + 
+				'#td_message_followup_search_' + messageNumber).find(".flag-edited")
+				.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");;
+		}
+		DataLayer.commit();
+		winElement.dialog("close");
+	});
+
+	winElement.find('.date').datepicker();
+	winElement.find('.time').timepicker({});
+	winElement.find('[name="name"]').combobox();
+	
+	
+	winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled");
+	winElement.find('[name="alarm"]').click(function(){
+		if($(this).is(":checked")){
+			winElement.find('[name="alarmDate"],[name="alarmTime"]').removeAttr("disabled");			
+		}else{
+			winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled");
+		}
+	});	
+	winElement.find('[name="done"]').click(function(){
+		if($(this).is(":checked")){
+			winElement.find(".input-done input").attr("disabled","disabled");
+		}else{
+			winElement.find(".input-done input").removeAttr("disabled");
+		}
+	});
+
+
+	winElement.find(".followupflag-color-fields").hide();
+	winElement.find(".followupflag-color.sample-list .sample-item").click(function(){
+		winElement.find(".followupflag-color.sample-list .sample-item").removeClass("selected");
+		$(this).addClass("selected");
+		var color = $(this).attr('alt');
+		winElement.find('[name="backgroundColor"]').css('background-color', color).val(color)
+	});
+	
+	winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger('click');
+				
+	winElement.find('[name="setColor"]').change(function(){		
+		if(winElement.find('[name="setColor"]').val() == "default"){
+			winElement.find(".followupflag-color.sample-list").show("fast");
+			winElement.find(".followupflag-color-fields").hide();
+			winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger('click');
+		} else if(winElement.find('[name="setColor"]').val() == "custom"){
+			winElement.find(".followupflag-color-fields").show("fast");
+			winElement.find(".followupflag-color.sample-list").hide();
+			winElement.find(".colorwell").focus();
+		}		
+	});
+	
+	if(winElement.find("#selectCor option:selected").val() == "custom"){
+		winElement.find("#selectCor").trigger("change");
+	}
+
+	var colorpickerPreviewChange = function(color) {
+		winElement.find('.colorwell-selected').val(color).css('background-color', color);
+		winElement.find('.flag-color-preview').css('background',color);
+	} 
+
+	var f = $.farbtastic(winElement.find('.colorpicker'), colorpickerPreviewChange);
+	var selected;					
+	winElement.find('.colorwell').each(function () {
+		f.linkTo(this);
+	}).focus(function() {
+		if (selected) {
+			$(selected).removeClass('colorwell-selected');
+		}
+		$(selected = this).addClass('colorwell-selected');
+		f.linkTo(this, colorpickerPreviewChange);
+		f.linkTo(colorpickerPreviewChange);
+		
+	});
+	if(winElement.find("#selectCor option:selected").val() == "custom"){
+		winElement.find(".colorwell").focus();
+	}
+
+}
Index: trunk/prototype/modules/mail/templates/label_configure.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/label_configure.ejs	(revision 5533)
+++ trunk/prototype/modules/mail/templates/label_configure.ejs	(revision 5533)
@@ -0,0 +1,55 @@
+<link rel="stylesheet" href="../prototype/modules/mail/css/label.css" type="text/css" />	
+<link rel="stylesheet" href='../prototype/plugins/farbtastic/farbtastic.css' type="text/css" >
+
+<div class="acc-list list-label-content">
+	<h3>Meus marcadores</h3>
+		<div class="attendee-list-add">
+			<fieldset class="add-attendee-search search-field ui-corner-all">
+					<span class="ui-icon ui-icon-plus add-label-button"></span>
+					<input class="insert-label" type="text" value="Adicionar Marcador" maxlength="15" >
+			</fieldset>
+		</div>
+		<div class="label-list-container"></div>
+</div>
+<div class="configure-label-content">
+	<fieldset>
+	<legend>Básico</legend>
+		Nome do marcador: <input type="text" class="input-nome" value="" name="marcador">
+		<input type="hidden" class="edit-label" value="" name="marcador">
+	</fieldset>
+	  <fieldset class="lebals-colorpicker">
+	  <legend>Cor do marcador</legend>
+		<div class="label-conf">
+			<select class="color-suggestions">		
+				  <option value="0">Padrão</option>		
+				  <option value="1">Coala</option>		
+				  <option value="2">Tomate</option>		
+				  <option value="3">Limão</option>		
+				  <option value="4">Alto contraste</option>		
+				  <option value="custom" selected="selected">Personalizada</option>
+			</select>
+			<div class="form-item">
+			  <label for="backgroundColor" class="label-cor">Cor do marcador:</label>
+			  <input type="text" name="backgroundColor" id="background" class="colorwell" value="#ffffff" />
+			</div>
+			<div class="form-item">
+			  <label for="fontColor" class="label-cor">Cor do texto:</label>
+			  <input type="text" name="fontColor" class="colorwell" value="#444444" />
+			</div>
+			<div class="form-item">
+			  <label for="borderColor" class="label-cor">Cor da borda:</label>
+			  <input type="text" name="borderColor" class="colorwell" value="#ccccccc" />
+			</div>			  
+			<div class="preview-label-outer">
+			  <span class="preview-label-inner"></span>
+			</div>
+		</div>				
+		<div class="colorpicker"></div>				  
+	  </fieldset>
+	<div class="buttons">
+		<span class="button delete-label">Excluir</span><span class="button undo-label">Desfazer</span><span class="button save-label">Salvar</span>
+	</div>
+</div>
+<div class="button-close-window">
+	<span class="button close-window">Fechar</span>
+</div>
Index: trunk/prototype/modules/mail/templates/followupflag_configure.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/followupflag_configure.ejs	(revision 5533)
+++ trunk/prototype/modules/mail/templates/followupflag_configure.ejs	(revision 5533)
@@ -0,0 +1,121 @@
+
+<%
+	if (data.messages.length == 1) {
+		var followupflagged = data.messages[0].followupflagged ? data.messages[0].followupflagged : followupflagged = { followupflag: {} };
+		if (followupflagged.doneDeadline)
+			followupflagged.doneDeadline = Date.parseExact(followupflagged.doneDeadline, 'yyyy-MM-dd hh:mm:ss');
+		if (followupflagged.alarmDeadline)
+			followupflagged.alarmDeadline = Date.parseExact(followupflagged.alarmDeadline, 'yyyy-MM-dd hh:mm:ss');
+			
+	} else if (data.messages.length > 1) {
+		var followupflagged = {
+			followupflag: {name: true},
+			isDone: true,
+			doneDeadline: true,
+			alarmDeadline: true,
+			backgroundColor: true
+		}
+		/**
+		 * O campo só fica preenchido se o valor for igual para todas as mensagens
+		 */
+		for (var i=1; i<data.messages.length; i++) {
+			if (!data.messages[i].followupflagged) {
+				followupflagged = { followupflag: {} };
+				break;
+			}
+			followupflagged.followupflag.name = (followupflagged.followupflag.name && data.messages[i].followupflagged.followupflag.name == data.messages[i-1].followupflagged.followupflag.name) ?
+				data.messages[i].followupflagged.followupflag.name : false;
+				
+			followupflagged.isDone = (followupflagged.isDone && data.messages[i].followupflagged.followupflag.isDone == data.messages[i-1].followupflagged.followupflag.isDone) ?
+				data.messages[i].followupflagged.followupflag.isDone : false;
+				
+			followupflagged.doneDeadline = (followupflagged.doneDeadline && data.messages[i].followupflagged.followupflag.doneDeadline == data.messages[i-1].followupflagged.followupflag.doneDeadline) ?
+				Date.parseExact(data.messages[i].followupflagged.followupflag.doneDeadline, 'yyyy-MM-dd hh:mm:ss') : false;
+				
+			followupflagged.alarmDeadline = (followupflagged.alarmDeadline && data.messages[i].followupflagged.followupflag.alarmDeadline == data.messages[i-1].followupflagged.followupflag.alarmDeadline) ?
+				Date.parseExact(data.messages[i].followupflagged.followupflag.alarmDeadline, 'yyyy-MM-dd hh:mm:ss') : false;
+				
+			followupflagged.backgroundColor = (followupflagged.backgroundColor && data.messages[i].followupflagged.followupflag.backgroundColor == data.messages[i-1].followupflagged.followupflag.backgroundColor) ?
+				data.messages[i].followupflagged.followupflag.backgroundColor : false;
+		}
+	}
+//typeFlag = DataLayer.get("followupflag", id = data.messages[0].followupflagged.followupflagId ).name;
+//followupflagged.followupflag.name
+%>
+<div class="followupflag-container">
+	<fieldset class="basic-fields">
+		<legend>Básico</legend>
+		<div class="followupflag-configure">
+			<label class="label-name">Sinalizar como:</label> 
+			<select name="name">
+				<% for(var i=0; i<data.followupflags.length; i++) {  %>
+					
+					<% var selected = (data.followupflags[i].name == followupflagged.followupflag.name ) ? 'selected="selected"' : '' %> 
+					<option value="<%= data.followupflags[i].id %>" <%= selected %>><%= data.followupflags[i].name %></option>
+				<% } %>
+			</select>
+			<div class="alarm-fields">
+				<input type="checkbox" name="alarm" <%=(followupflagged.alarmDeadline) ? 'checked="checked"' : '' %> /><label>Alarme: </label>
+				<input type="text" name="alarmDate" class="date" size="9" value="<%=(followupflagged.alarmDeadline) ? followupflagged.alarmDeadline.toString('dd/MM/yyyy') : '' %>" /> ás 
+				<input type="text" name="alarmTime" class="time" size="8" value="<%=(followupflagged.alarmDeadline) ? followupflagged.alarmDeadline.toString('hh:mm') : '' %>" />
+			</div>		
+		   <div class="completed-followup">
+				<input type="checkbox" name="done" <%=(followupflagged.isDone && followupflagged.isDone != '0') ? 'checked="checked"' : '' %> /><label>Concluido</label>
+		   </div>		
+		</div>
+		<div class="right-data input-done">
+			<label>Conclusão:</label>
+			<input <%=(followupflagged.isDone && followupflagged.isDone != '0') ? 'disabled="disabled"' : '' %> type="text" name="doneDate" class="date" size="8" value="<%=(followupflagged.doneDeadline) ? followupflagged.doneDeadline.toString('dd/MM/yyyy') : '' %>" /> ás 
+			<input <%=(followupflagged.isDone && followupflagged.isDone != '0') ? 'disabled="disabled"' : '' %> type="text" name="doneTime" class="time" size="8" value="<%=(followupflagged.doneDeadline) ? followupflagged.doneDeadline.toString('hh:mm') : '' %>" />
+		</div> 
+	</fieldset>
+
+	<fieldset class="followups-colorpicker color-fields">
+		<legend>Cor do sinalizador</legend>
+		<div class="left-seletor-flag">
+			<% 
+				var defaultColor = false;
+				var a = ["#00820F", "#E4D000", "#004DD6", "#FF2016", "#F96300"];
+				if (followupflagged.backgroundColor) {
+					for(var i = 0; i < a.length; i++) {
+						if(a[i] == followupflagged.backgroundColor) {
+							defaultColor = a[i];
+							break;
+						}
+					}
+				}
+			%>
+			<select id="selectCor" name="setColor">
+				<option value="default" <%= (defaultColor) ? 'selected="selected"' : ''%> >Padrão</option>
+				<option value="custom" <%= (!defaultColor) ? 'selected="selected"' : ''%> >Personalizado</option>
+			</select>
+		</div>
+		<div class="followupflag-color sample-list">
+			<img src="../prototype/modules/mail/img/flagDefault1.png" alt="#00820F" class="sample-item <%= (!followupflagged.backgroundColor || followupflagged.backgroundColor == '#00820F') ? 'selected' : '' %>"">
+			<img src="../prototype/modules/mail/img/flagDefault2.png" alt="#E4D000" class="sample-item <%= (followupflagged.backgroundColor == '#E4D000') ? 'selected' : '' %>"">
+			<img src="../prototype/modules/mail/img/flagDefault3.png" alt="#004DD6" class="sample-item <%= (followupflagged.backgroundColor == '#004DD6') ? 'selected' : '' %>"">
+			<img src="../prototype/modules/mail/img/flagDefault4.png" alt="#FF2016" class="sample-item <%= (followupflagged.backgroundColor == '#FF2016') ? 'selected' : '' %>"">
+			<img src="../prototype/modules/mail/img/flagDefault5.png" alt="#F96300" class="sample-item <%= (followupflagged.backgroundColor == '#F96300') ? 'selected' : '' %>"">
+		</div>
+		<div class="followupflag-color-fields">
+			<div class="form-item">
+				<label class="flag-label">Cor: </label>
+				<input type="text" name="backgroundColor" class="colorwell background-color" value="<%=(followupflagged.backgroundColor) ? followupflagged.backgroundColor : '#00820F' %>"/>
+				<div class="flag-edit flag-color-preview" style="background: <%=(followupflagged.backgroundColor) ? followupflagged.backgroundColor : '#00820F' %>">
+					<img src="../prototype/modules/mail/img/flagEditor.png">
+				</div>
+			</div>
+			<div class="colorpicker"></div>
+		</div>
+	</fieldset>
+	<div class="menu-container footer-container menu-configure-followupflag">
+		<span class="button delete">Remover</span>
+		<span class="button save">Aplicar</span>
+		<span class="button cancel">Cancelar</span>
+	</div>
+</div> 
+
+<!--
+	TODO
+	** Vai ter que ser arrumado a parte de buscar o tipo do sinalizador atual.
+-->
Index: trunk/prototype/modules/mail/templates/detailedfoldertree.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/detailedfoldertree.ejs	(revision 5500)
+++ trunk/prototype/modules/mail/templates/detailedfoldertree.ejs	(revision 5533)
@@ -52,3 +52,5 @@
   </li>
   <%}%>
+  <li><span class="folder head_folder all_accomp">Para acompanhamento</span>
+  </li>
 </ul>
Index: trunk/prototype/modules/mail/templates/followupflag_alarm_list.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/followupflag_alarm_list.ejs	(revision 5533)
+++ trunk/prototype/modules/mail/templates/followupflag_alarm_list.ejs	(revision 5533)
@@ -0,0 +1,17 @@
+<p class="title"><strong>Você tem <%= data.alarmInRange.length %> <%= (data.alarmInRange.length == 1) ? 'mensagem sinalizada para hoje.' : 'mensagens sinalizadas para hoje.'%> </p></strong>
+					<ul class="alert-flags" style="overflow: hidden; height: 70px;">
+	
+<%
+for(var i=0; i<data.alarmInRange.length; i++){
+%>
+
+	<li><a onclick="cExecute('$this.imap_functions.get_info_msg&msg_number=<%=data.alarmInRange[i].messageNumber %>&msg_folder=<%= data.alarmInRange[i].folderName %>', show_msg);"><%= data.alarmInRange[i].alarmDeadline %> - <%= data.alarmInRange[i].followupflag.name %> - <%= data.alarmInRange[i].message.headers.subject %></a></li>
+<%
+}
+%>
+					</ul> 
+					
+<br>
+<a class="footerMais">ver mais</a><a class="footerMenos">ver menos</a>
+<br><br>
+	<input type="checkbox" name="fadeModel2"> Não mostrar essa janela por hoje.
Index: trunk/prototype/modules/mail/templates/label_listitem.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/label_listitem.ejs	(revision 5533)
+++ trunk/prototype/modules/mail/templates/label_listitem.ejs	(revision 5533)
@@ -0,0 +1,11 @@
+	<li class="label-item label-item-<%= data.id%>" style="background: <%= (data.bgColor) ? data.bgColor : '#ffffff' %>; 
+		color: <%= (data.fontColor) ? data.fontColor : '#444444' %>;
+		border: 1px solid <%= (data.borderColor) ? data.borderColor : '#cccccc' %>;">		
+		
+		<input type="hidden" value="<%= data.id%>" name="labelItemId" class="id-item-list" />
+		<span class="text-list"><%= data.name %></span>
+		<div class="button close tiny" style="float: right"></div>
+		<div class="button edit tiny" style="float: right"></div>
+					
+	</li>
+	
Index: trunk/prototype/modules/mail/templates/label_list.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/label_list.ejs	(revision 5533)
+++ trunk/prototype/modules/mail/templates/label_list.ejs	(revision 5533)
@@ -0,0 +1,21 @@
+	<ul class="label-list">
+		<%for (var i=0; i<data.labels.length; i++){ %>
+			
+			<li class="label-item label-item-<%= (data.labels[i].id) ? data.labels[i].id : ''%>" style="
+				background: <%= (data.labels[i].backgroundColor) ? data.labels[i].backgroundColor : '#ffffff' %>;
+				color: <%= (data.labels[i].fontColor) ? data.labels[i].fontColor : '#000000' %>;
+				border-color: <%= (data.labels[i].borderColor) ? data.labels[i].borderColor : '#CCCCCC' %>;">
+			   
+				<span class="text-list"><%= (data.labels[i].name) ? data.labels[i].name : '' %></span>
+				<!--<input type="hidden" value="<%= (data.labels[i].id) ? data.labels[i].id : ''%>" name="labelItemId" class="id-item-list" />-->
+				<input type="hidden" value="<%= data.labels[i].id%>" name="labelItemId" class="id-item-list" />
+				
+				<div class="square-color" style="display:none;width:17px;height:12px;margin-top:1px;-moz-border-radius:3px;-webkit-border-radius:3px;
+						background: <%= (data.labels[i].backgroundColor) ? data.labels[i].backgroundColor : '#ffffff' %>; float:right;"></div>
+
+				<div class="button close tiny" style="float: right"></div>
+				<div class="button edit tiny" style="float: right"></div>
+			</li>
+		<%}%>
+	</ul>
+
Index: trunk/prototype/modules/attach_message/attach_message.js
===================================================================
--- trunk/prototype/modules/attach_message/attach_message.js	(revision 5399)
+++ trunk/prototype/modules/attach_message/attach_message.js	(revision 5533)
@@ -319,5 +319,5 @@
 			datatype: "json",
 			mtype: 'GET',
-			colNames:['#', ' ', 'De', 'Assunto', 'Data', 'Tamanho'],
+			colNames:['#',' ', 'De', 'Assunto', 'Data', 'Tamanho'],
 			colModel:[
 				{name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false},
