Index: trunk/calendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.bocalendar.inc.php	(revision 1720)
+++ trunk/calendar/inc/class.bocalendar.inc.php	(revision 1849)
@@ -1504,4 +1504,16 @@
 			return False;
 		}
+		
+		function participants_unanswered($participants,$event)
+		{
+			foreach($participants as $uid => $status)
+			{				
+				if (isset($event['participants'][$uid]) && $event['participants'][$uid] == 'U' && $status == 'U')
+				{
+					return False;
+				}
+			}
+			return True;
+		}
 
 		function overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False)
@@ -1613,5 +1625,5 @@
 								$temp_start_time >= $temp_event_start &&
 								$temp_end_time <= $temp_event_end) &&
-								$this->participants_not_rejected($participants,$event))
+								$this->participants_not_rejected($participants,$event) && $this->participants_unanswered($participants,$event))
 							{
 								if($this->debug)
@@ -3088,5 +3100,5 @@
 																		  		   </form>";
 														$lang2 = lang("To accept");
-														$varbuttom1 ="<input type='submit' value='$lang2' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=3&response=1\",\"frontpage\",\"height=100,width=400,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>";
+														$varbuttom1 ="<input type='submit' value='$lang2' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=3&response=1&user_id=$userid\",\"frontpage\",\"height=200,width=450,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>";
 
 														$lang3 = lang("To reject");
Index: trunk/calendar/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.uicalendar.inc.php	(revision 1720)
+++ trunk/calendar/inc/class.uicalendar.inc.php	(revision 1849)
@@ -1916,4 +1916,104 @@
 				$tmpbody1 = $body1->pfp('out','list');
 		}
+		
+		function confirm_conflict($user_id,$event,$overlapping_events)
+		{
+			if(!$overlapping_events){					
+				$notify_message = lang('Este evento entra em conflito com outro que você participa.');
+	
+				$action_ignore = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'response' => 1,'user_id' => $user_id, 'ignore_conflict' => 1));
+				$action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0));
+	
+				$body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+				$body1->set_file(Array('calendar' => 'conflict.tpl'));
+				$body1->set_block('calendar','list');
+				$var = Array( 'notify_message'	=> $notify_message,
+							'action_url' => $action_url,
+							'ignore_conflict' => 'Ignorar Conflito',
+							'reject_event' => 'Rejeitar Evento',
+							'action_reject' => $action_reject,
+							'action_ignore' => $action_ignore);
+				$body1->set_var($var);
+				$tmpbody1 = $body1->pfp('out','list');
+			}
+			else
+			{				
+				$month = $event['start']['month'];
+				$mday = $event['start']['mday'];
+				$year = $event['start']['year'];
+	
+				$start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset;
+				$end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
+	
+				$overlap = '';
+				for($i=0;$i<count($overlapping_events);$i++)
+				{
+					$overlapped_event = $this->bo->read_entry($overlapping_events[$i],True);
+					foreach($overlapped_event['participants'] as $id => $status)
+					{
+						$conflict = isset($event['participants'][$user_id]);
+						$overlap .= '<li>'.($conflict?'<b>':'').
+							$GLOBALS['phpgw']->common->grab_owner_name($id).
+							($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>";
+					}
+				 if ($this->bo->prefs['calendar']['hide_event_conflict'])
+					 $overlap .= '<ul><font size="1"><span>'.
+						 $this->normDec($overlapped_event['start']['hour']).":".
+						 $this->normDec($overlapped_event['start']['min'])."-".
+						 $this->normDec($overlapped_event['end']['hour']).":".
+						 $this->normDec($overlapped_event['end']['min']).
+						 '<br><b>'.lang('title').": ".lang("Hidden").
+						 '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>';
+				 else
+					 $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>";	
+				}
+	
+				unset($GLOBALS['phpgw_info']['flags']['noheader']);
+				unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+				$GLOBALS['phpgw_info']['flags']['noappheader'] = True;
+				$GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
+				$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict');
+				$GLOBALS['phpgw']->common->phpgw_header();
+	
+				$p = $GLOBALS['phpgw']->template;
+				$p->set_file(
+					Array(
+						'overlap'	=> 'overlap.tpl',
+	   					'form_button'	=> 'form_button_script.tpl'
+					)
+				);
+	
+				$var = Array(
+					'color'		=> $this->theme['bg_text'],
+					'overlap_title' => lang('Scheduling Conflict'),
+					'overlap_text'	=> lang('Your suggested time of <B> %1 - %2 </B> conflicts with the following existing calendar entries:',$GLOBALS['phpgw']->common->show_date($start),$GLOBALS['phpgw']->common->show_date($end)),
+					'overlap_list'	=> $overlap
+				);
+				$p->set_var($var);
+	
+				$date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday);
+				$var = Array(
+					'action_url_button'	=> $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'user_id' => $user_id, 'ignore_conflict' => 1)),
+					'action_text_button'	=> lang('Ignore Conflict'),
+					'action_confirm_button'	=> '',
+					'action_extra_field'	=> '',
+					'button_id'		=> 'ignore_button'
+				);				
+				$action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0));
+	
+				$this->output_template_array($p,'resubmit_button','form_button',$var);
+	
+				$var = Array(
+					'action_url_button'	=> $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0)),
+					'action_text_button'	=> lang('Reject'),
+					'action_confirm_button'	=> '',
+					'action_extra_field'	=> '',
+					'button_id'		=> 'redit_button'
+				);
+				$this->output_template_array($p,'reedit_button','form_button',$var);
+				$p->pparse('out','overlap');
+			}
+		}
+		
 		function set_action()
 		{
@@ -1924,13 +2024,42 @@
 			}
 			
-			$confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']);
+			$overlapping_events = false;
+			$event = $this->bo->read_entry((int)$_GET['cal_id']);
+			if((!$_GET['response'] == 0 && !$_GET['ignore_conflict'] == 1) || 
+				(!isset($_GET['response']) && $_GET['action'] == 3 && !$_GET['ignore_conflict'] == 1))
+			{
+				if($event['reference'])
+				{
+					$event_ids[] = $event['reference'];
+				}
+				$event['participants'] = Array($_GET['user_id'] => $event['participants'][$_GET['user_id']]);
+				$overlapping_events = $this->bo->overlap(
+					$this->bo->maketime($event['start']),
+					$this->bo->maketime($event['end']),
+					$event['participants'],
+					$event['owner'],
+					$event_ids
+				);
+			}
 
 			if(isset($_GET['response']))
 			{
+				if($overlapping_events)
+				{
+					$this->confirm_conflict($_GET['user_id'],$event);
+				}else
+				{
+					$confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']);
 					$this->confirm_action($confirm_status);
 					$GLOBALS['phpgw']->common->phpgw_exit(False);
-			}
-			else
-			{
+				}
+			}else
+			{
+				if($overlapping_events)
+				{					
+					$this->confirm_conflict($_GET['user_id'],$event,$overlapping_events);
+				}else
+				{
+				$confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']);
 					if ($this->bo->return_to)
 					{
@@ -1942,5 +2071,7 @@
 					}
 					$GLOBALS['phpgw']->common->phpgw_exit();
-			}
+				}
+			}
+			
 			
 		}
@@ -4719,5 +4850,5 @@
 			{
 				$var = Array(
-					'action_url_button'	=> $this->page('set_action','&cal_id='.$cal_id.'&action='.$param),
+					'action_url_button'	=> $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user_id='.$this->bo->owner),
 					'action_text_button'	=> '  '.$text.'  ',
 					'action_confirm_button'	=> '',
@@ -5037,5 +5168,5 @@
 									'field'	=> '
 									<script src="calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'>
-	<iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\'></iframe>
+	<iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe>
 </div>
 									'.lang('Participants'),
