Index: /trunk/prototype/config/label.ini
===================================================================
--- /trunk/prototype/config/label.ini	(revision 5533)
+++ /trunk/prototype/config/label.ini	(revision 5881)
@@ -8,4 +8,7 @@
 clearAllLabeledsOfLabel = modules/mail/interceptors/Helpers.php
 
+[before.create]
+verifyNameLabel = modules/mail/interceptors/Helpers.php
+
 [PostgreSQL.mapping]
 id = id
Index: /trunk/prototype/modules/mail/interceptors/Helpers.php
===================================================================
--- /trunk/prototype/modules/mail/interceptors/Helpers.php	(revision 5817)
+++ /trunk/prototype/modules/mail/interceptors/Helpers.php	(revision 5881)
@@ -298,4 +298,16 @@
 		//$result = Controller::update($imap_uri, $params, $criteria);
 	}
+	
+		
+	//label:before.create
+	public function verifyNameLabel(&$uri , &$params , &$criteria , $original){
+		$nameLabel = $params['name'];
+		$Labels = Controller::find(array('concept' => 'label'), false, array('filter' => array('=', 'name', $nameLabel) ));
+		if($Labels){
+			//Throw new Exception('Marcador existe');
+			//$params['id'] = 'Marcador existe';
+			return false;
+		}
+	}
 
 }
Index: /trunk/prototype/modules/mail/js/label.js
===================================================================
--- /trunk/prototype/modules/mail/js/label.js	(revision 5824)
+++ /trunk/prototype/modules/mail/js/label.js	(revision 5881)
@@ -134,25 +134,35 @@
 			});
 			DataLayer.put('label', labelEdited.id, labelEdited);
-			DataLayer.commit(false, false, function(){
-				
-				winElement.find(".insert-label").val("");
-				$.Watermark.ShowAll();
-				
-				$(".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(deleteLabel);
-				
-				draw_tree_labels();
-				updateMessageLabels(labelEdited.id);
-				
-				/**
-				* 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();
+			DataLayer.commit(false, false, function(data){
+				var hasLabel = true;
+					for(var i in data){
+						if(parseInt(data[i].id))
+							hasLabel = false;
+					}
+					if(!hasLabel){
+						winElement.find(".insert-label").val("");
+						$.Watermark.ShowAll();
+						
+						$(".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(deleteLabel);
+						
+						draw_tree_labels();
+						updateMessageLabels(labelEdited.id);
+						
+						/**
+						* 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();
+					}else{
+						$(".add-label-button").empty()
+						.addClass("ui-icon ui-icon-plus");
+						alert('Problema ao salvar marcador.');
+					}
 			});
 		// criar marcador
@@ -231,55 +241,66 @@
 	.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,
-			bgColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(),
-			fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(),
-			borderColor : !!isNew ? '#000000' : winElement.find("input[name='borderColor']").val()
-		};
-		
-		/** Marca as mensagens selecionadas com o marcador criado*/
-		if(apply){
-			labeledMessages(newLabel.id)
-		}
-		
-		$(".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);
-		
-		draw_tree_labels();
-
-		$(".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});
-		
-		//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(deleteLabel);
-		
-		$(".my-labels").show();
-		
-		$.contextMenu( 'destroy', ".table_box tbody tr");
-		loadMenu();
-		
-		$(".add-label-button").empty()
-		.addClass("ui-icon ui-icon-plus");
+	DataLayer.commit(false, false, function(data){
+	var hasLabel = true;
+		for(var i in data){
+			if(parseInt(data[i].id))
+				hasLabel = false;
+		}
+		if(!hasLabel){
+			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 : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(),
+				fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(),
+				borderColor : !!isNew ? '#000000' : winElement.find("input[name='borderColor']").val()
+				
+			};
+		
+			/** Marca as mensagens selecionadas com o marcador criado*/
+			if(apply){
+				labeledMessages(newLabel.id)
+			}
+			
+			$(".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);
+			
+			draw_tree_labels();
+
+			$(".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});
+			
+			//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(deleteLabel);
+			
+			$(".my-labels").show();
+			
+			$.contextMenu( 'destroy', ".table_box tbody tr");
+			loadMenu();
+			
+			$(".add-label-button").empty()
+			.addClass("ui-icon ui-icon-plus");
+		}else{
+			$(".add-label-button").empty()
+			.addClass("ui-icon ui-icon-plus");
+			alert('Problema ao salvar marcador.');
+		}
 	});
 }
