Index: branches/2.2/mobile/inc/class.ui_mobilecalendar.inc.php
===================================================================
--- branches/2.2/mobile/inc/class.ui_mobilecalendar.inc.php	(revision 623)
+++ branches/2.2/mobile/inc/class.ui_mobilecalendar.inc.php	(revision 3590)
@@ -2,918 +2,275 @@
     class ui_mobilecalendar {
 		
-		var $bo;
+		var $bocalendar;
 		var $cat;
 		var $link_tpl;		
+		var $common;
+		var $template;		
+		var $daysOfWeek;
+		var $shortDaysOfWeek;
 		
 		var $public_functions = array(
-			'add' => true,
-			'init_schedule' => true,
-			'add_participants' => true,
-			'add_participant' => true,
-			'edit' => true,
-			'update' =>true,
-			'overlap' => true,
 			'index' => true
 		);
 		
 		function ui_mobilecalendar() {
-			$this->bo = CreateObject('calendar.bocalendar',1);			
+			$this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
+			$this->common	= CreateObject('mobile.common_functions');
+			$this->bocalendar = CreateObject('calendar.bocalendar',1);			
 			$this->cat = &$this->bo->cat;
+			$this->daysOfWeek = array(lang('Sunday'), lang('Monday'),lang('Tuesday'),lang('Wednesday'),lang('Thursday'),lang('Friday'),lang('Saturday'));
+			$this->shortDaysOfWeek = array(lang('short Sunday'), lang('short Monday'),lang('short Tuesday'),lang('short Wednesday'),lang('short Thursday'),lang('short Friday'),lang('short Saturday'));
+			
 			$GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
-	
-			$this->link_tpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-			$this->link_tpl->set_unknowns('remove');
-			$this->link_tpl->set_file(
-				Array(
-					'link_picture'	=> 'link_pict.tpl'
-				)
-			);
-			$this->link_tpl->set_block('link_picture','link_pict','link_pict');
-			$this->link_tpl->set_block('link_picture','pict','pict');
-			$this->link_tpl->set_block('link_picture','link_open','link_open');
-			$this->link_tpl->set_block('link_picture','link_close','link_close');
-			$this->link_tpl->set_block('link_picture','link_text','link_text');
 		}
 		
-		function index() {
+		function index($params) {
+			$this->template->set_file(array('calendar' => 'calendar.tpl'));
+			$this->template->set_block("calendar","page");
+			$this->template->set_block('calendar','event_block');
+			$this->template->set_block('calendar','day_event_block');
+			$this->template->set_block('calendar','no_event_block');
+			$this->template->set_block('calendar','type_option_block');
+			$this->template->set_block('calendar','bar_block');
+			$this->template->set_var('lang_back',lang("back"));
+			$this->template->set_var('lang_calendar',lang("Calendar"));
+			$this->template->set_var('lang_search',lang("search"));
+			
+			if(!function_exists("get_events")){
+				function get_events($self, $accountId, $begin, $end) {
+					$self->bocalendar->so->owner = $accountId;
+					$self->bocalendar->so->open_box($accountId);
+					$self->bocalendar->store_to_cache(
+						array(
+							'owner'	=> $accountId,
+							'syear'  => date('Y',$begin),
+							'smonth' => date('m',$begin),
+							'sday'   => date('d',$begin),
+							'eyear'  => date('Y',$end),
+							'emonth' => date('m',$end),
+							'eday'   => date('d',$end)
+						)
+					);
+					
+					$events = $self->bocalendar->cached_events;
+					ksort($events);
+				
+					return $events;
+				}
+			}
+			
+			if(!function_exists("print_events")){	
+				function print_events($self, $events) {
+					foreach($events as $index=>$event)
+					{
+						$self->template->set_var('dd_class', (($index%2==0) ? "par" : "reset-dt") );	
+						$vars = $self->bocalendar->event2array($event);
+						$data = array (
+							"title_field"		=> $vars['title']['field'],
+							"title_data"		=> $vars['title']['data'],
+							"startdate_data" 	=> substr($vars['startdate']['data'],13, 17),
+							"enddate_data" 		=> substr($vars['enddate']['data'],13, 17),
+							"description_data"	=> $vars['description']['data'] ? $vars['description']['data'] : "&nbsp;"
+						);
+			
+		    	 	$self->template->set_var($data);
+						$self->template->parse('events_box','event_block',true);
+					}				
+				}
+			}	
+			
+			if(!function_exists("print_events_header")){	
+				function print_events_header($self, $day, $month, $year) {
+					$day_of_week = $self->daysOfWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)];
+					$self->template->set_var("day",$day_of_week." - ".$day."/".$month."/".$year);
+					$self->template->parse('events_box','day_event_block',true);
+				}
+			}
+				
+			$type = $_GET["type"];
+			if(!$type) $type = "dia";
+			$types = array("dia" => lang("view day"),"semana" => lang("view week"),"calendario" => lang("view calendar")); 
+			
+			foreach($types as $value=>$label)	{
+				$this->template->set_var("value",$value);
+				$this->template->set_var("label",$label);
+				
+				if($type == $value)
+					$this->template->set_var("selected", "selected");
+				else
+					$this->template->set_var("selected", null);
+					
+				$this->template->parse('type_option_box','type_option_block',true);
+			}
+			
 			$accountId = $GLOBALS['phpgw_info']['user']['account_id'];
-			$uicalendar = CreateObject("calendar.uicalendar");
-			$daysofWeek = array(lang('Sunday'), lang('Monday'),lang('Tuesday'),lang('Wednesday'),lang('Thursday'),lang('Friday'),lang('Saturday'));
-			$year = $uicalendar->bo->year;
-			$month = $uicalendar->bo->month;
-			$day = $uicalendar->bo->day;
-			$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset;
-			$tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset;
-			$tstop = $tstart + 604800;
-			$uicalendar->bo->so->owner = $accountId;
-			$uicalendar->bo->so->open_box($accountId);
-			$uicalendar->bo->store_to_cache(
-				Array(
-					'syear'  => date('Y',$tstart),
-					'owner'	=> $accountId,
-					'smonth' => date('m',$tstart),
-					'sday'   => date('d',$tstart),
-					'eyear'  => date('Y',$tstop),
-					'emonth' => date('m',$tstop),
-					'eday'   => date('d',$tstop)
-				)
-			);
-			$daily = $uicalendar->bo->cached_events;
-			$p = CreateObject('phpgwapi.Template', "../mobile/templates/".$GLOBALS['phpgw_info']['server']['template_set']);
-			$p->set_file(Array('view' => 'calendar.tpl'));
-			$data[] = array();
-			@ksort($daily);
-			$p->set_block("view","body");
-			if($daily){
-				$p->set_block('view','view_event');
-				foreach($daily as $date => $day_params)	{
-					$year  = (int)substr($date,0,4);
-					$month = (int)substr($date,4,2);
-					$day   = (int)substr($date,6,2);
-					$day_of_week = $daysofWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)];
-					$p->set_var("header_date",$day_of_week." - ".$day."/".$month."/".$year);
-					for($i = 0; $i < count($day_params);$i++)
-					{
-		
-						//Verifica se o usuario conectado é o dono do agendamento, se for não serão exibidos os links
-						//Aceitar e Rejeitar
-						$display = "";
-						if($accountId == $day_params[$i]['owner'])
-						{
-							$display = "none";
-						}
-		
-						$vars = $uicalendar->bo->event2array($day_params[$i]);
-						$data  = array (
-									"title_field"		=> $vars['title']['field'],
-									"title_data"		=> $vars['title']['data'],
-									"location_field"	=> $vars['location']['field'],
-									"location_data"		=> $vars['location']['data'] ? $vars['location']['data'] : "&nbsp;",
-									"startdate_field"	=> $vars['startdate']['field'],
-									"startdate_data" 	=> substr($vars['startdate']['data'],13, 17),
-									"enddate_field" 	=> $vars['enddate']['field'],
-									"enddate_data" 		=> substr($vars['enddate']['data'],13, 17),
-									"description_field"	=> $vars['description']['field'],
-									"description_data"	=> $vars['description']['data'] ? $vars['description']['data'] : "&nbsp;",
-									//Links Aceitar e Rejeitar o compromisso
-									"accept_title"		=> lang("Accept"),
-									"accept_data"		=> "index.php?menuaction=mobile.ui_mobilemail.set_action&cal_id=" . $day_params[$i]['id'] . "&action=3",
-									"reject_title"		=> lang("Reject"),
-									"reject_data"		=> "index.php?menuaction=mobile.ui_mobilemail.set_action&cal_id=" . $day_params[$i]['id'] . "&action=0",
-									"display"		=> $display
-									);
-		
-			//			print_r($vars);
-				    	 	$p->set_var($data);
-				    	 	$p->parse('views','view_event',True);
+
+			$day = $_GET["dia"];
+			if(!$day) $day = $this->bocalendar->day;
+
+			$month = $_GET["mes"];
+			if(!$month) $month = $this->bocalendar->month;
+			
+			$year = $_GET["ano"];
+			if(!$year) $year = $this->bocalendar->year;
+			
+			$this->template->set_var("lang_today", lang("today"));
+			$this->template->set_var("today_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia");
+			
+			if($type==="semana") {
+				$tstart = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset;
+				$tstart -= $GLOBALS['phpgw']->datetime->tz_offset;
+				$tstop = $tstart + 604800;
+				$events = get_events($this, $accountId, $tstart, $tstop);
+				$current_day_of_week = $GLOBALS['phpgw']->datetime->day_of_week($year, $month, $day);
+				
+				//descobrindo a semana anterior e a pŽroxima
+				$last_week = date("d-m-Y", strtotime("-7 day", mktime(0,0,0,$month,$day,$year) ) );
+				$last_week = split("-",$last_week);
+				$next_week = date("d-m-Y", strtotime("+7 day", mktime(0,0,0,$month,$day,$year) ) );
+				$next_week = split("-",$next_week);
+				
+				//descobrind o primeiro dia da semana e o último
+				$first_week_day = date("d-m-Y", strtotime("-".$current_day_of_week." day", mktime(0,0,0,$month,$day,$year) ) );
+				$first_week_day = split("-",$first_week_day);
+				$last_week_day = date("d-m-Y", strtotime("+".(6-$current_day_of_week)." day", mktime(0,0,0,$month,$day,$year) ) );
+				$last_week_day = split("-",$last_week_day);
+				
+				//definindo a barra de navegação do calandário
+				$this->template->set_var("before_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=semana&dia=".$last_week[0]."&mes=".$last_week[1]."&ano=".$last_week[2]);
+				$this->template->set_var("current_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=semana&dia=".$day."&mes=".$month."&ano=".$year);
+				$this->template->set_var("next_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=semana&dia=".$next_week[0]."&mes=".$next_week[1]."&ano=".$next_week[2]);
+				$this->template->set_var("current_label", $first_week_day[0]."/".$first_week_day[1]."/".$first_week_day[2]." à ".$last_week_day[0]."/".$last_week_day[1]."/".$last_week_day[2]);
+				$this->template->parse('events_box','bar_block',true);
+				
+				if(!empty($events)) {
+					foreach($events as $index=>$event)	{
+						$event_year  = (int) substr($index,0,4);
+						$event_month = (int) substr($index,4,2);
+						$event_day   = (int) substr($index,6,2);
+						print_events_header($this, $event_day, $event_month, $event_year);
+						print_events($this, $events[$event_year.$this->common->complete_string($event_month,2,"R","0").$this->common->complete_string($event_day,2,"R","0")]);	
+					}		
+				} else {
+					$this->template->set_var("msg_no_event", lang("Dont have event that week"));
+					$this->template->parse('events_box','no_event_block',true);
+				}				
+						
+			} elseif($type==="calendario") {
+				$day_of_week_first_day = $GLOBALS['phpgw']->datetime->day_of_week($year, $month, "01");
+				$last_day_of_month = date('t', mktime(0,0,0,$month,"01",$year));
+				$last_day_of_before_month = date('t', mktime(0,0,0,$month-1,"01",$year));
+				$last_month_year = date("m-Y", strtotime("-1 month", mktime(0,0,0,$month,"01",$year) ) );
+				$last_month_year = split("-",$last_month_year);
+				$next_month_year = date("m-Y", strtotime("+1 month", mktime(0,0,0,$month,"01",$year) ) );
+				$next_month_year = split("-",$next_month_year);
+				$today = date("d-m-Y");
+				
+				$days_of_calendar = array();
+				
+				//identificando os dias do mês anterior
+				for($i = 0; $i < $day_of_week_first_day; $i++) {
+					$days_of_calendar[$i] = array("day" => ($last_day_of_before_month-$day_of_week_first_day+$i+1), "month" => $last_month_year[0], "year" => $last_month_year[1], "other_month" => true);					
+				}
+				
+				//adicionando os dias do mês especificado
+				for($i = 0; $i < ($last_day_of_month ); $i++) {
+					$days_of_calendar[$i+$day_of_week_first_day] = array("day" => $i+1, "month" => $month, "year" => $year, "other_month" => false);
+				}
+				
+				//pegando todos os eventos a partir o menor dia visível do mês anterior
+				$tstart = mktime(0,0,0,$last_month_year[0],($last_day_of_before_month-$day_of_week_first_day),$last_month_year[1]);
+				$tstart -= $GLOBALS['phpgw']->datetime->tz_offset;
+				$tstop = $tstart + (86400*sizeof($days_of_calendar)); //(24horas*60min*60seg*total de dias exibidos)
+				$events = get_events($this, $accountId, $tstart, $tstop);
+				
+				//definindo os blocos a serem utilizados
+				$this->template->set_block('calendar','calendar_header_begin_block');
+				$this->template->set_block('calendar','calendar_header_end_block');
+				$this->template->set_block('calendar','calendar_header_block');
+				$this->template->set_block('calendar','calendar_day_block');
+				$this->template->set_block('calendar','calendar_day_begin_block');
+				$this->template->set_block('calendar','calendar_day_end_block');
+				
+				//definindo a barra de navegação do calandário
+				$this->template->set_var("before_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=calendario&mes=".$last_month_year[0]."&ano=".$last_month_year[1]);
+				$this->template->set_var("current_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=calendario&mes=".$month."&ano=".$year);
+				$this->template->set_var("next_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=calendario&mes=".$next_month_year[0]."&ano=".$next_month_year[1]);
+				$this->template->set_var("current_label", $month." / ".$year);
+				$this->template->parse('events_box','bar_block',true);
+				
+				for($i = 0; $i < 7; $i++) {
+					$this->template->set_var("week_day", $this->shortDaysOfWeek[$i]);
+					$this->template->parse('week_day_box','calendar_header_block',true);
+				}
+								
+				$this->template->parse('calendar_box','calendar_header_begin_block',true);
+				$this->template->parse('calendar_box','calendar_day_begin_block',true);
+				
+				foreach($days_of_calendar as $index=>$value) {
+					$extra_class = "";
+					$calendar_day = $value["day"];
+
+					if($today === $value["day"]."-".$value["month"]."-".$value["year"])
+						$extra_class .= " hoje";
+
+					if($value["other_month"])
+						$extra_class .= " outro_mes";
+					
+					$key = $value["year"].$this->common->complete_string($value["month"],2,"R","0").$this->common->complete_string($value["day"],2,"R","0");
+					
+					if( array_key_exists($key, $events ) ) {
+						$this->template->set_var("qtd_commitment", sizeof($events[$key]));
+					} else {
+						$this->template->set_var("qtd_commitment", null);
 					}
-				}
-				$p->parse('events','views');
-				//$p->pfp('out','views');
-			}
-			else {
-				$p->set_block('view','no_event');
-				$syear  = date('Y',$tstart);
-				$smonth = date('m',$tstart);
-				$sday   = date('d',$tstart);
-				$eyear  = date('Y',$tstop);
-				$emonth = date('m',$tstop);
-				$eday	= date('d',$tstop);
-				$p->set_var("start_date",$sday."/".$smonth."/".$syear);
-				$p->set_var("end_date", $eday."/".$emonth."/".$eyear);
-				$p->parse('events','no_event');
-		//		$p->pfp('out','no_event');
-			}
-			$p->set_var("lang_schedule",lang("schedule"));
-			//$p->pfp('out','body');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','body'));
+
+					$this->template->set_var("calendar_day", $calendar_day);
+					
+					$this->template->set_var("calendar_day_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia=".$value["day"]."&mes=".$value["month"]."&ano=".$value["year"]);
+					$this->template->set_var("extra_class", $extra_class);					
+					$this->template->parse('calendar_box','calendar_day_block',true);
+					
+					if(($index+1)%7==0) {
+						$this->template->parse('calendar_box','calendar_day_end_block',true);
+						$this->template->parse('calendar_box','calendar_day_begin_block',true);
+					}
+				}
+				$this->template->parse('calendar_box','calendar_day_end_block',true);
+				$this->template->parse('calendar_box','calendar_header_end_block',true);
+			
+			} else 	{
+				$tstart = mktime(0,0,0,$month,$day,$year);
+				$tstart -= $GLOBALS['phpgw']->datetime->tz_offset;
+				$tstop = $tstart + 86400; //(24horas*60min*60seg*1dia)
+				$events = get_events($this, $accountId, $tstart, $tstop);
+				
+				$day = $this->common->complete_string($day,2,"R","0");
+				$month = $this->common->complete_string($month,2,"R","0");
+				
+				//descobrind o primeiro dia da semana e o último
+				$before_day = date("d-m-Y", strtotime("-1 day", mktime(0,0,0,$month,$day,$year) ) );
+				$before_day = split("-",$before_day);
+				$next_day = date("d-m-Y", strtotime("+1 day", mktime(0,0,0,$month,$day,$year) ) );
+				$next_day = split("-",$next_day);				
+				
+				//definindo a barra de navegação do calandário
+				$this->template->set_var("before_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia=".$before_day[0]."&mes=".$before_day[1]."&ano=".$before_day[2]);
+				$this->template->set_var("current_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia=".$day."&mes=".$month."&ano=".$year);
+				$this->template->set_var("next_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia=".$next_day[0]."&mes=".$next_day[1]."&ano=".$next_day[2]);
+				$this->template->set_var("current_label", $this->daysOfWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)]." - ".$day."/".$month."/".$year);
+				$this->template->parse('events_box','bar_block',true);				
+				
+				if(!empty($events[$year.$month.$day]))
+					print_events($this, $events[$year.$month.$day]);
+				else {
+					$this->template->set_var("msg_no_event", lang("Dont have event that day"));
+					$this->template->parse('events_box','no_event_block',true);
+				}
+			}
+			
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','page'));
 		}
-		
-		function page($_page='',$params='')
-		{
-			if($_page == '')
-			{
-				$page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']);
-				$_page = $page_[0];
-
-				if ($_page=='planner_cat' || $_page=='planner_user')
-				{
-					$_page = 'planner';
-				}
-				elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner'))
-				{
-					$_page = 'month';
-					$GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month');
-					$GLOBALS['phpgw']->preferences->save_repository();
-				}
-			}
-			if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' ||
-				strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))	// email, felamimail, ...
-			{
-				$page_app = 'calendar';
-			}
-			else
-			{
-				$page_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
-			}
-			if (is_array($params))
-			{
-				$params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page;
-			}
-			else
-			{
-				$params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params;
-			}
-			return $GLOBALS['phpgw']->link('/index.php',$params);
-		}
-		
-		function init_schedule() {
-			$_SESSION['mobile_calendar'] = NULL;
-			$this->add_participants();
-		}
-		
-		function add_participants() {
-
-			$ui_cc = CreateObject('mobile.ui_mobilecc');
-			$ui_cc->contacts_list(true);
-		}
-		
-		function add_participant() {
-			
-			$participants = $_SESSION["mobile_calendar"];
-			
-			if(!is_array($participants))
-				$participants = array();
-				
-			$participants[$_GET['user']] = $_GET['cn'];
-			
-			$_SESSION["mobile_calendar"] = $participants;
-				
-			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-			$p->set_file(Array('continue' => 'keep_add_participants.tpl'));
-			$p->set_block('continue','body');
-			$p->set_var('lang_add_participants',lang('keep add participants'));
-			$p->set_var('lang_continue',lang('continue scheduling'));
-			//$p->pfp('out','body');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','body'));
-		}
-		
-		function add($cd=0,$readsess=0)
-		{
-			if(!$this->bo->check_perms(PHPGW_ACL_ADD))
-			{
-				$this->index();
-			}
-			
-			if($readsess)
-			{
-				$event = $this->bo->restore_from_appsession;
-				if(!$event['owner'])
-				{
-					$this->bo->add_attribute('owner',$this->bo->owner);
-				}
-				$can_edit = True;
-			}
-			else
-			{
-				$this->bo->event_init();
-				$this->bo->add_attribute('id',0);
-
-				$can_edit = True;
-				$participants = (string)(get_var('participants',array('GET'),FALSE));
-				$starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts']));
-				$startmin  = (int)(get_var('minute',array('GET'),0));
-				$endmin    = $startmin + (int)$this->bo->prefs['calendar']['defaultlength'];
-				$endhour   = $starthour + $this->bo->normalizeminutes($endmin);
-				
-				$subject	= (string)(get_var('title',array('GET'),0));
-				if ($subject != '0')
-				{
-					$description	= (string)(get_var('description',array('GET'),0));
-					$location	= (string)(get_var('location',array('GET'),0));
-				}
-				else
-					unset($subject);
-				
-				$this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
-				$this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0);
-				$this->bo->set_title($subject);
-				$this->bo->set_description($description);
-				$this->bo->add_attribute('location',$location);
-				$this->bo->set_ex_participants('');
-				$this->bo->add_attribute('uid','');
-				$this->bo->add_attribute('priority',2);
-				if(@$this->bo->prefs['calendar']['default_private'])
-				{
-					$this->bo->set_class(False);
-				}
-				else
-				{
-					$this->bo->set_class(True);
-				}
-
-				$this->bo->add_attribute('participants','A',$this->bo->owner);
-				$this->bo->set_recur_none();
-				$event = $this->bo->get_cached_event();
-				
-			}
-			$this->edit_form(
-				Array(
-					'event' => $event,
-					'cd' => $cd
-				)
-			);
-			//$GLOBALS['phpgw']->common->phpgw_footer();
-		}
-		
-		function edit($params='')
-		{
-			if($this->debug)
-			{
-				echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n";
-				echo '<!-- params[cd] = '.$params['cd'].' -->'."\n";
-			}
-
-			if(isset($_GET['readsess']))
-			{
-				$params['readsess'] = $_GET['readsess'];
-				$params['cd'] = 0;
-			}
-
-			if($this->debug)
-			{
-				echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n";
-				echo '<!-- params[cd] = '.$params['cd'].' -->'."\n";
-			}
-
-			if($params != '' && @is_array($params) && @isset($params['readsess']))
-			{
-				$can_edit = True;
-				$this->edit_form(
-					Array(
-						'event' => $this->bo->restore_from_appsession(),
-						'cd' => $params['cd']
-					)
-				);
-			}
-			elseif(isset($_GET['cal_id']))
-			{
-				$cal_id = (int)$_GET['cal_id'];
-				$event = $this->bo->read_entry($cal_id);
-
-				if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event))
-				{
-					Header('Location: '.$this->page('view','&cal_id='.$cal_id));
-					$GLOBALS['phpgw']->common->phpgw_exit();
-				}
-				if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single')
-				{
-					$event['id'] = 0;
-					$this->bo->set_recur_date($event,$_POST['date']);
-					$event['recur_type'] = MCAL_RECUR_NONE;
-					$event['recur_interval'] = 0;
-					$event['recur_data'] = 0;
-					$event['recur_enddate']['month'] = 0;
-					$event['recur_enddate']['mday'] = 0;
-					$event['recur_enddate']['year'] = 0;
-					$event['recur_exception'] = array();
-				}
-				$this->edit_form(
-					Array(
-						'event' => $event,
-						'cd'	=> $cd
-					)
-				);
-			}
- 		}
-		
-		function update() {
-			$params = array();
-			$params['from_mobile'] = true;
-			$this->bo->update($params);
-		}
-		
-		function edit_form($param)
-		{
-			if(!is_array($param))
-			{
-				$this->index();
-			}
-			
-			if(isset($param['event']))
-			{
-				$event = $param['event'];
-			}
-			
-			$hourformat = substr($this->bo->users_timeformat,0,1);
-			
-			// $sb = CreateObject('phpgwapi.sbox');
-			$sb = CreateObject('phpgwapi.sbox2');
-			$jscal = CreateObject('phpgwapi.jscalendar');	// before phpgw_header() !!!
-			
-			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'] = $event['id'] ? lang('Editing event') : lang('Adding event');
-			//$GLOBALS['phpgw']->common->phpgw_header();
-
-			$p = &$GLOBALS['phpgw']->template;
-			$p->set_file(
-				Array(
-					'edit'		=> 'edit.tpl',
-					'form_button'	=> 'form_button_script.tpl'
-				)
-			);
-			$p->set_block('edit','edit_entry','edit_entry');
-			$p->set_block('edit','list','list');
-			$p->set_block('edit','hr','hr');
-			
-			$vars = Array(
-				'font'			=> $this->theme['font'],
-				'bg_color'		=> $this->theme['bg_text'],
-				'action_url'		=> $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.update')),
-				'accounts_link'		=> $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'),
-				'common_hidden'	=> '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n"
-					. '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n"
-					. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
-					. ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n":
-					(@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":''))
-					. (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']?
-					'<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
-				'errormsg'		=> ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):''),
-				'row_owner'		=> '<input type="hidden" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'">'
-			);
-			
-			$p->set_var($vars);
-
-// Brief Description
-			$var['title'] = Array(
-				'tr_color' => $this->theme['th_bg'],
-				'field'	=> lang('Title'),
-				'data'	=> '<input name="cal[title]" size="15" maxlength="80" value="'.$event['title'].'">'
-			);
-
-// Location
-			$var['location'] = Array(
-				'field'	=> lang('Location'),
-				'data'	=> '<input name="cal[location]" size="15" maxlength="255" value="'.$event['location'].'">'
-			);
-
-// Date
-
-			$start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
-			$var['startdate'] = Array(
-				'field'	=> lang('Start Date'),
-
-				'data'	=> $GLOBALS['phpgw']->common->dateformatorder(
-				   $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')),
-				   $sb->getMonths('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')),
-				   $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')),
-				   true
-				)
-
-//				'data' => $jscal->input('start[str]',$start)
-			);
-
-// Time
-			if ($this->bo->prefs['common']['timeformat'] == '12')
-			{
-				$str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n"
-					. '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n";
-			}
-			$var['starttime'] = Array(
-				'field'	=> lang('Start Time'),
-				'data'	=> '<input name="start[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$str
-			);
-
-// End Date
-			$end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
-			$var['enddate'] = Array(
-				'field'	=> lang('End Date'),
-
-				'data'	=> $GLOBALS['phpgw']->common->dateformatorder(
-				   $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')),
-				   $sb->getMonths('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')),
-				   $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')),true
-				)
-
-//				'data' => $jscal->input('end[str]',$end)
-			);
-
-// End Time
-			if ($this->bo->prefs['common']['timeformat'] == '12')
-			{
-				$str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n"
-					. '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n";
-			}
-			$var['endtime'] = Array(
-				'field'	=> lang('End Time'),
-				'data'	=> '<input name="end[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$str
-			);
-
-
-			$participants = $_SESSION['mobile_calendar'];
-			$str = " ";
-			foreach($participants as $id => $nome) {
-				$str.="<option value='$id' selected>$nome</option>";
-			}
-			
-			
-			$var['participants'] = array
-						(
-							'field'	=> lang('Participants'),							
-							'data'	=> "
-							<select id='user_list' name='participants[]' style='width: 220px' multiple size='5'>".$str."</select></center>
-									<script src='../calendar/templates/celepar/js/edit.js' type='text/javascript'></script>
-									"
-						);
-			
-
-			/*$var['owner'] = Array(
-					'field'	=> $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'),
-					'data'	=> '<input type="checkbox" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'" checked read-only="true">'
-				);*/
-
-
-			if (!isset($this->fields))
-			{
-				$this->custom_fields = CreateObject('calendar.bocustom_fields');
-				$this->fields = &$this->custom_fields->fields;
-				$this->stock_fields = &$this->custom_fields->stock_fields;
-			}
-			$preserved = False;
-			foreach($this->fields as $field => $data)
-			{
-				/*if($field=='owner')
-					$p->set_var('display',"visibility:hidden");
-				else
-					$p->set_var('display'," ");*/
-				if (!$data['disabled'])
-				{
-					if (isset($var[$field]))
-					{
-						switch($field)
-						{
-							case 'startdate':
-								$this->output_template_array($p,'row','list',$var['startdate']);
-								$this->output_template_array($p,'row','list',$var['starttime']);
-								break;
-							case 'enddate':
-								$this->output_template_array($p,'row','list',$var['enddate']);
-								$this->output_template_array($p,'row','list',$var['endtime']);
-								break;
-							default:
-								$this->output_template_array($p,'row','list',$var[$field]);
-						}
-					}
-					elseif (!isset($this->stock_fields[$field]))	// Custom field
-					{
-						$lang = lang($name = substr($field,1));
-						$size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
-							' MAXLENGTH='.($data['length'] ? $data['length'] : 255);
-						$v = array(
-							'field'	=> $lang == $name.'*' ? $name : $lang,
-							'data'	=> '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">'
-						);
-						if ($data['title'])
-						{
-							$v['tr_color'] = $this->theme['th_bg'];
-						}
-						if (!$data['length'] && $data['title'])
-						{
-							$p->set_var('tr_color',$this->theme['th_bg']);
-							$p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>');
-							$p->parse('row','hr',True);
-						}
-						else
-						{
-							$this->output_template_array($p,'row','list',$v);
-						}
-					}
-				}
-				else	// preserve disabled fields
-				{
-					switch ($field)
-					{
-						case 'owner':
-							$preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A';
-							break;
-						case 'recure_type':
-							foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field)
-							{
-								$preserved[$field] = $event[$field];
-							}
-							break;
-						case 'startdate':
-						case 'enddate':
-							$field = substr($field,0,-4);
-						default:
-							$preserved[$field] = $event[$field];
-					}
-				}
-			}
-			unset($var);
-			if (is_array($preserved))
-			{
-				//echo "preserving<pre>"; print_r($preserved); echo "</pre>\n";
-				$p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n");
-			}
-			$p->set_var('submit_button',lang('Save'));
-			
-			
-
-			$delete_button = $cancel_button = '';
-			if ($event['id'] > 0)
-			{
-				$var = Array(
-					'action_url_button'	=> $this->page('delete','&cal_id='.$event['id']),
-					'action_text_button'	=> lang('Delete'),
-					'action_confirm_button'	=> "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"",
-					'action_extra_field'	=> ''
-				);
-				$p->set_var($var);
-				$delete_button = $p->fp('out','form_button');
-				
-			}
-			$p->set_var('delete_button',$delete_button);
-
-			if ($this->bo->return_to)
-			{
-				$var = Array(
-					'action_url_button'	=> $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to),
-					'action_text_button'	=> lang('Cancel'),
-					'action_confirm_button'	=> '',
-					'action_extra_field'	=> ''
-				);
-				$p->set_var($var);
-				$cancel_button = $p->fp('out','form_button');
-			}
-			
-			$p->set_var('lang_add_participants',lang("keep add participants"));
-			
-			$p->set_var('cancel_button',$cancel_button);
-			$p->pparse('out','edit_entry');
-			
-		}
-		
-		function get_organizations($context, $selected='', $recursive = false)
-		{
-			$s = CreateObject('phpgwapi.sector_search_ldap');
-						
-			return ($recursive ? 
-				$s->get_organizations($context, $selected, false ,false) :
-				$s->get_sectors($selected, false, false));
-		}		
-		
-		function output_template_array(&$p,$row,$list,$var)
-		{
-			if (!isset($var['hidden_vars']))
-			{
-				$var['hidden_vars'] = '';
-			}
-			if (!isset($var['tr_color']))
-			{
-				$var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color();
-			}
-			$p->set_var($var);
-			$p->parse($row,$list,True);
-		}
-		
-		function overlap($params) {
-			ini_set("display_errors","1");
-			if(!is_array($params))
-			{
-			}
-			else
-			{
-				$overlapping_events = $params['o_events'];
-				$event = $params['this_event'];
-			}
-
-			$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);
-				$overlap .= '<li>'.$this->link_to_entry($overlapped_event,$month,$mday,$year);
-				$overlap .= '<ul>';
-				foreach($overlapped_event['participants'] as $id => $status)
-				{
-					$conflict = isset($event['participants'][$id]);
-					$overlap .= '<li>'.($conflict?'<b>':'').
-						$GLOBALS['phpgw']->common->grab_owner_name($id).
-						($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>\n";
-				}
-				$overlap .= "</ul>\n";
-			}
-
-			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('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.update','readsess'=>1)),
-				'action_text_button'	=> lang('Ignore Conflict'),
-				'action_confirm_button'	=> '',
-				'action_extra_field'	=> ''
-			);
-			$this->output_template_array($p,'resubmit_button','form_button',$var);
-
-			$var = Array(
-				'action_url_button'	=> $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.edit','readsess'=>1,'date'=>$date)),
-				'action_text_button'	=> lang('Re-Edit Event'),
-				'action_confirm_button'	=> '',
-				'action_extra_field'	=> ''
-			);
-			$this->output_template_array($p,'reedit_button','form_button',$var);
-			$p->pparse('out','overlap');
-		}
-		
-		function link_to_entry($event,$month,$day,$year)
-		{
-			$str = '';
-			$is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event);
-			$viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event);
-
-			$starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
-			$endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
-			$rawdate = mktime(0,0,0,$month,$day,$year);
-			$rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset;
-			$nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset;
-			if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime)
-			{
-				$time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
-			}
-			elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60)
-			{
-				$time = '[ '.lang('All Day').' ]';
-			}
-			elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime)
-			{
-				if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE)
-				{
-					$start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat);
-				}
-				else
-				{
-					$start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
-				}
-
-				if($endtime >= ($rawdate_offset + 86400))
-				{
-					$end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat);
-				}
-				else
-				{
-					$end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat);
-				}
-				$time = $start_time.'-'.$end_time;
-			}
-			else
-			{
-				$time = '';
-			}
-			
-			$texttitle = $texttime = $textdesc = $textlocation = $textstatus = '';
-
-			
-			
-			if(!$is_private)
-			{
-				//$text .= $this->bo->display_status($event['users_status']);
-				
-				// split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation	
-				$textstatus=$this->bo->display_status($event['users_status']); 
-				
-			}
-
-			/*
-			$text = '<nobr>&nbsp;'.$time.'&nbsp;</nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text.
-				(!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':'').
-				$GLOBALS['phpgw']->browser->br;
-			*/
-			
-			$texttime=$time;
-			$texttitle=$this->bo->get_short_field($event,$is_private,'title');
-			$textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):'');
-			// added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set
-			$textlocation=$this->bo->get_short_field($event,$is_private,'location');
-
-			if ($viewable)
-			{
-				$date = sprintf('%04d%02d%02d',$year,$month,$day);
-				$this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date));
-				$this->link_tpl->set_var('lang_view',lang('View this entry'));
-				$this->link_tpl->set_var('desc', $textdesc);
-				$this->link_tpl->set_var('location', $textlocation);
-				$this->link_tpl->parse('picture','link_open',True);
-			}
-			if (!$is_private)
-			{
-				if($event['priority'] == 3)
-				{
-					$picture[] = Array(
-						'pict'	=> $GLOBALS['phpgw']->common->image('calendar','high'),
-						'width'	=> 16,
-						'height'=> 16,
-						'title' => lang('high priority')
-					);
-				}
-				if($event['recur_type'] == MCAL_RECUR_NONE)
-				{
-					$picture[] = Array(
-						'pict'	=> $GLOBALS['phpgw']->common->image('calendar','circle'),
-						'width'	=> 9,
-						'height'=> 9,
-						'title' => lang('single event')
-					);
-				}
-				else
-				{
-					$picture[] = Array(
-						'pict'	=> $GLOBALS['phpgw']->common->image('calendar','recur'),
-						'width'	=> 12,
-						'height'=> 12,
-						'title' => lang('recurring event')
-					);
-				}
-			}
-			$participants = $this->planner_participants($event['participants']);
-			if(count($event['participants']) > 1)
-			{
-				$picture[] = Array(
-					'pict'	=> $GLOBALS['phpgw']->common->image('calendar','multi_3'),
-					'width'	=> 14,
-					'height'=> 14,
-					'title' => $participants
-				);
-			}
-			else
-			{
-				$picture[] = Array(
-					'pict'	=>  $GLOBALS['phpgw']->common->image('calendar','single'),
-					'width'	=> 14,
-					'height'=> 14,
-					'title' => $participants
-				);
-			}
-			if($event['public'] == 0)
-			{
-				$picture[] = Array(
-					'pict'	=> $GLOBALS['phpgw']->common->image('calendar','private'),
-					'width'	=> 13,
-					'height'=> 13,
-					'title' => lang('private')
-				);
-			}
-			if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
-			{
-				// if the alarm is to go off the day before the event
-				// the icon does not show up because of 'alarm_today'
-				// - TOM
-				if($this->bo->alarm_today($event,$rawdate_offset,$starttime))
-				{
-					$picture[] = Array(
-						'pict'  => $GLOBALS['phpgw']->common->image('calendar','alarm'),
-						'width' => 13,
-						'height'=> 13,
-						'title' => lang('alarm')
-					);
-				}
-			}
-
-			$description = $this->bo->get_short_field($event,$is_private,'description');
-			for($i=0;$i<count($picture);$i++)
-			{
-				$var = Array(
-					'pic_image' => $picture[$i]['pict'],
-					'width'     => $picture[$i]['width'],
-					'height'    => $picture[$i]['height'],
-					'title'     => $picture[$i]['title']
-				);
-				$this->output_template_array($this->link_tpl,'picture','pict',$var);
-			}
-			if ($texttitle)
-			{
-				$var = Array(
-			//		'text' => $text,
-					'time'=> $texttime,
-					'title'=> $texttitle,
-					'users_status'=>$textstatus,
-					'desc'=> $textdesc,
-					'location'=> "<br><b>Local:</b> ".$textlocation
-				);
-				$this->output_template_array($this->link_tpl,'picture','link_text',$var);
-			}
-
-			if ($viewable)
-			{
-				$this->link_tpl->parse('picture','link_close',True);
-			}
-			$str = $this->link_tpl->fp('out','link_pict');
-			$this->link_tpl->set_var('picture','');
-			$this->link_tpl->set_var('out','');
-//			unset($p);
-			return $str;
-		}
-		
-		
-		function planner_participants($parts)
-		{
-			static $id2lid;
-
-			$names = '';
-			while (list($id,$status) = each($parts))
-			{
-				$status = substr($this->bo->get_long_status($status),0,1);
-
-				if (!isset($id2lid[$id]))
-				{
-					$id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id);
-				}
-				if (strlen($names))
-				{
-					$names .= ",\n";
-				}
-				$names .= $id2lid[$id]." ($status)";
-			}
-			if($this->debug)
-			{
-				echo '<!-- Inside participants() : '.$names.' -->'."\n";
-			}
-			return $names;
-		}
-		
-		
 	}
 	
-
-	
 ?>
Index: branches/2.2/mobile/inc/class.ui_mobilemail.inc.php
===================================================================
--- branches/2.2/mobile/inc/class.ui_mobilemail.inc.php	(revision 3589)
+++ branches/2.2/mobile/inc/class.ui_mobilemail.inc.php	(revision 3590)
@@ -475,7 +475,7 @@
 						continue;
 					if($message['from']['name'])
-						$from_name = $functions->strach_string($message['from']['name'],20);
+						$from_name = $message['from']['name'];
 					else
-						$from_name = $functions->strach_string($message['from']['email'],20);
+						$from_name = $message['from']['email'];
 					
 					$p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par");
@@ -866,7 +866,5 @@
 				$this->new_msg( $params );
 			}else {
-				$ui_home = CreateObject('mobile.ui_home');
-				$params["success_message"] = lang("draft saved");
-				$ui_home->index( $params );
+				header('Location: index.php?menuaction=menuaction=mobile.ui_home.index&success_message='.lang("draft saved"));
 			}				
 		}
@@ -940,7 +938,5 @@
 				$this->new_msg( $params );
 			}else {
-				$ui_home = CreateObject('mobile.ui_home');
-				$params["success_message"] = lang("Message sent successfully");
-				$ui_home->index($params);
+				header('Location: index.php?menuaction=menuaction=mobile.ui_home.index&success_message='.lang("Message sent successfully"));
 			}
 		}
