Ignore:
Timestamp:
12/14/10 16:32:05 (13 years ago)
Author:
eduardoalex
Message:

Ticket #1410 - Modificado o layout da tela de visualizacao de compromissos.

Location:
branches/2.2/mobile/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/mobile/inc/class.ui_mobilecalendar.inc.php

    r623 r3590  
    22    class ui_mobilecalendar { 
    33                 
    4                 var $bo; 
     4                var $bocalendar; 
    55                var $cat; 
    66                var $link_tpl;           
     7                var $common; 
     8                var $template;           
     9                var $daysOfWeek; 
     10                var $shortDaysOfWeek; 
    711                 
    812                var $public_functions = array( 
    9                         'add' => true, 
    10                         'init_schedule' => true, 
    11                         'add_participants' => true, 
    12                         'add_participant' => true, 
    13                         'edit' => true, 
    14                         'update' =>true, 
    15                         'overlap' => true, 
    1613                        'index' => true 
    1714                ); 
    1815                 
    1916                function ui_mobilecalendar() { 
    20                         $this->bo = CreateObject('calendar.bocalendar',1);                       
     17                        $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); 
     18                        $this->common   = CreateObject('mobile.common_functions'); 
     19                        $this->bocalendar = CreateObject('calendar.bocalendar',1);                       
    2120                        $this->cat = &$this->bo->cat; 
     21                        $this->daysOfWeek = array(lang('Sunday'), lang('Monday'),lang('Tuesday'),lang('Wednesday'),lang('Thursday'),lang('Friday'),lang('Saturday')); 
     22                        $this->shortDaysOfWeek = array(lang('short Sunday'), lang('short Monday'),lang('short Tuesday'),lang('short Wednesday'),lang('short Thursday'),lang('short Friday'),lang('short Saturday')); 
     23                         
    2224                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); 
    23          
    24                         $this->link_tpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    25                         $this->link_tpl->set_unknowns('remove'); 
    26                         $this->link_tpl->set_file( 
    27                                 Array( 
    28                                         'link_picture'  => 'link_pict.tpl' 
    29                                 ) 
    30                         ); 
    31                         $this->link_tpl->set_block('link_picture','link_pict','link_pict'); 
    32                         $this->link_tpl->set_block('link_picture','pict','pict'); 
    33                         $this->link_tpl->set_block('link_picture','link_open','link_open'); 
    34                         $this->link_tpl->set_block('link_picture','link_close','link_close'); 
    35                         $this->link_tpl->set_block('link_picture','link_text','link_text'); 
    3625                } 
    3726                 
    38                 function index() { 
     27                function index($params) { 
     28                        $this->template->set_file(array('calendar' => 'calendar.tpl')); 
     29                        $this->template->set_block("calendar","page"); 
     30                        $this->template->set_block('calendar','event_block'); 
     31                        $this->template->set_block('calendar','day_event_block'); 
     32                        $this->template->set_block('calendar','no_event_block'); 
     33                        $this->template->set_block('calendar','type_option_block'); 
     34                        $this->template->set_block('calendar','bar_block'); 
     35                        $this->template->set_var('lang_back',lang("back")); 
     36                        $this->template->set_var('lang_calendar',lang("Calendar")); 
     37                        $this->template->set_var('lang_search',lang("search")); 
     38                         
     39                        if(!function_exists("get_events")){ 
     40                                function get_events($self, $accountId, $begin, $end) { 
     41                                        $self->bocalendar->so->owner = $accountId; 
     42                                        $self->bocalendar->so->open_box($accountId); 
     43                                        $self->bocalendar->store_to_cache( 
     44                                                array( 
     45                                                        'owner' => $accountId, 
     46                                                        'syear'  => date('Y',$begin), 
     47                                                        'smonth' => date('m',$begin), 
     48                                                        'sday'   => date('d',$begin), 
     49                                                        'eyear'  => date('Y',$end), 
     50                                                        'emonth' => date('m',$end), 
     51                                                        'eday'   => date('d',$end) 
     52                                                ) 
     53                                        ); 
     54                                         
     55                                        $events = $self->bocalendar->cached_events; 
     56                                        ksort($events); 
     57                                 
     58                                        return $events; 
     59                                } 
     60                        } 
     61                         
     62                        if(!function_exists("print_events")){    
     63                                function print_events($self, $events) { 
     64                                        foreach($events as $index=>$event) 
     65                                        { 
     66                                                $self->template->set_var('dd_class', (($index%2==0) ? "par" : "reset-dt") );     
     67                                                $vars = $self->bocalendar->event2array($event); 
     68                                                $data = array ( 
     69                                                        "title_field"           => $vars['title']['field'], 
     70                                                        "title_data"            => $vars['title']['data'], 
     71                                                        "startdate_data"        => substr($vars['startdate']['data'],13, 17), 
     72                                                        "enddate_data"          => substr($vars['enddate']['data'],13, 17), 
     73                                                        "description_data"      => $vars['description']['data'] ? $vars['description']['data'] : " " 
     74                                                ); 
     75                         
     76                                $self->template->set_var($data); 
     77                                                $self->template->parse('events_box','event_block',true); 
     78                                        }                                
     79                                } 
     80                        }        
     81                         
     82                        if(!function_exists("print_events_header")){     
     83                                function print_events_header($self, $day, $month, $year) { 
     84                                        $day_of_week = $self->daysOfWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)]; 
     85                                        $self->template->set_var("day",$day_of_week." - ".$day."/".$month."/".$year); 
     86                                        $self->template->parse('events_box','day_event_block',true); 
     87                                } 
     88                        } 
     89                                 
     90                        $type = $_GET["type"]; 
     91                        if(!$type) $type = "dia"; 
     92                        $types = array("dia" => lang("view day"),"semana" => lang("view week"),"calendario" => lang("view calendar"));  
     93                         
     94                        foreach($types as $value=>$label)       { 
     95                                $this->template->set_var("value",$value); 
     96                                $this->template->set_var("label",$label); 
     97                                 
     98                                if($type == $value) 
     99                                        $this->template->set_var("selected", "selected"); 
     100                                else 
     101                                        $this->template->set_var("selected", null); 
     102                                         
     103                                $this->template->parse('type_option_box','type_option_block',true); 
     104                        } 
     105                         
    39106                        $accountId = $GLOBALS['phpgw_info']['user']['account_id']; 
    40                         $uicalendar = CreateObject("calendar.uicalendar"); 
    41                         $daysofWeek = array(lang('Sunday'), lang('Monday'),lang('Tuesday'),lang('Wednesday'),lang('Thursday'),lang('Friday'),lang('Saturday')); 
    42                         $year = $uicalendar->bo->year; 
    43                         $month = $uicalendar->bo->month; 
    44                         $day = $uicalendar->bo->day; 
    45                         $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; 
    46                         $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; 
    47                         $tstop = $tstart + 604800; 
    48                         $uicalendar->bo->so->owner = $accountId; 
    49                         $uicalendar->bo->so->open_box($accountId); 
    50                         $uicalendar->bo->store_to_cache( 
    51                                 Array( 
    52                                         'syear'  => date('Y',$tstart), 
    53                                         'owner' => $accountId, 
    54                                         'smonth' => date('m',$tstart), 
    55                                         'sday'   => date('d',$tstart), 
    56                                         'eyear'  => date('Y',$tstop), 
    57                                         'emonth' => date('m',$tstop), 
    58                                         'eday'   => date('d',$tstop) 
    59                                 ) 
    60                         ); 
    61                         $daily = $uicalendar->bo->cached_events; 
    62                         $p = CreateObject('phpgwapi.Template', "../mobile/templates/".$GLOBALS['phpgw_info']['server']['template_set']); 
    63                         $p->set_file(Array('view' => 'calendar.tpl')); 
    64                         $data[] = array(); 
    65                         @ksort($daily); 
    66                         $p->set_block("view","body"); 
    67                         if($daily){ 
    68                                 $p->set_block('view','view_event'); 
    69                                 foreach($daily as $date => $day_params) { 
    70                                         $year  = (int)substr($date,0,4); 
    71                                         $month = (int)substr($date,4,2); 
    72                                         $day   = (int)substr($date,6,2); 
    73                                         $day_of_week = $daysofWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)]; 
    74                                         $p->set_var("header_date",$day_of_week." - ".$day."/".$month."/".$year); 
    75                                         for($i = 0; $i < count($day_params);$i++) 
    76                                         { 
    77                  
    78                                                 //Verifica se o usuario conectado é o dono do agendamento, se for não serão exibidos os links 
    79                                                 //Aceitar e Rejeitar 
    80                                                 $display = ""; 
    81                                                 if($accountId == $day_params[$i]['owner']) 
    82                                                 { 
    83                                                         $display = "none"; 
    84                                                 } 
    85                  
    86                                                 $vars = $uicalendar->bo->event2array($day_params[$i]); 
    87                                                 $data  = array ( 
    88                                                                         "title_field"           => $vars['title']['field'], 
    89                                                                         "title_data"            => $vars['title']['data'], 
    90                                                                         "location_field"        => $vars['location']['field'], 
    91                                                                         "location_data"         => $vars['location']['data'] ? $vars['location']['data'] : "&nbsp;", 
    92                                                                         "startdate_field"       => $vars['startdate']['field'], 
    93                                                                         "startdate_data"        => substr($vars['startdate']['data'],13, 17), 
    94                                                                         "enddate_field"         => $vars['enddate']['field'], 
    95                                                                         "enddate_data"          => substr($vars['enddate']['data'],13, 17), 
    96                                                                         "description_field"     => $vars['description']['field'], 
    97                                                                         "description_data"      => $vars['description']['data'] ? $vars['description']['data'] : "&nbsp;", 
    98                                                                         //Links Aceitar e Rejeitar o compromisso 
    99                                                                         "accept_title"          => lang("Accept"), 
    100                                                                         "accept_data"           => "index.php?menuaction=mobile.ui_mobilemail.set_action&cal_id=" . $day_params[$i]['id'] . "&action=3", 
    101                                                                         "reject_title"          => lang("Reject"), 
    102                                                                         "reject_data"           => "index.php?menuaction=mobile.ui_mobilemail.set_action&cal_id=" . $day_params[$i]['id'] . "&action=0", 
    103                                                                         "display"               => $display 
    104                                                                         ); 
    105                  
    106                         //                      print_r($vars); 
    107                                                 $p->set_var($data); 
    108                                                 $p->parse('views','view_event',True); 
     107 
     108                        $day = $_GET["dia"]; 
     109                        if(!$day) $day = $this->bocalendar->day; 
     110 
     111                        $month = $_GET["mes"]; 
     112                        if(!$month) $month = $this->bocalendar->month; 
     113                         
     114                        $year = $_GET["ano"]; 
     115                        if(!$year) $year = $this->bocalendar->year; 
     116                         
     117                        $this->template->set_var("lang_today", lang("today")); 
     118                        $this->template->set_var("today_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia"); 
     119                         
     120                        if($type==="semana") { 
     121                                $tstart = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; 
     122                                $tstart -= $GLOBALS['phpgw']->datetime->tz_offset; 
     123                                $tstop = $tstart + 604800; 
     124                                $events = get_events($this, $accountId, $tstart, $tstop); 
     125                                $current_day_of_week = $GLOBALS['phpgw']->datetime->day_of_week($year, $month, $day); 
     126                                 
     127                                //descobrindo a semana anterior e a pŽroxima 
     128                                $last_week = date("d-m-Y", strtotime("-7 day", mktime(0,0,0,$month,$day,$year) ) ); 
     129                                $last_week = split("-",$last_week); 
     130                                $next_week = date("d-m-Y", strtotime("+7 day", mktime(0,0,0,$month,$day,$year) ) ); 
     131                                $next_week = split("-",$next_week); 
     132                                 
     133                                //descobrind o primeiro dia da semana e o último 
     134                                $first_week_day = date("d-m-Y", strtotime("-".$current_day_of_week." day", mktime(0,0,0,$month,$day,$year) ) ); 
     135                                $first_week_day = split("-",$first_week_day); 
     136                                $last_week_day = date("d-m-Y", strtotime("+".(6-$current_day_of_week)." day", mktime(0,0,0,$month,$day,$year) ) ); 
     137                                $last_week_day = split("-",$last_week_day); 
     138                                 
     139                                //definindo a barra de navegação do calandário 
     140                                $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]); 
     141                                $this->template->set_var("current_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=semana&dia=".$day."&mes=".$month."&ano=".$year); 
     142                                $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]); 
     143                                $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]); 
     144                                $this->template->parse('events_box','bar_block',true); 
     145                                 
     146                                if(!empty($events)) { 
     147                                        foreach($events as $index=>$event)      { 
     148                                                $event_year  = (int) substr($index,0,4); 
     149                                                $event_month = (int) substr($index,4,2); 
     150                                                $event_day   = (int) substr($index,6,2); 
     151                                                print_events_header($this, $event_day, $event_month, $event_year); 
     152                                                print_events($this, $events[$event_year.$this->common->complete_string($event_month,2,"R","0").$this->common->complete_string($event_day,2,"R","0")]);   
     153                                        }                
     154                                } else { 
     155                                        $this->template->set_var("msg_no_event", lang("Dont have event that week")); 
     156                                        $this->template->parse('events_box','no_event_block',true); 
     157                                }                                
     158                                                 
     159                        } elseif($type==="calendario") { 
     160                                $day_of_week_first_day = $GLOBALS['phpgw']->datetime->day_of_week($year, $month, "01"); 
     161                                $last_day_of_month = date('t', mktime(0,0,0,$month,"01",$year)); 
     162                                $last_day_of_before_month = date('t', mktime(0,0,0,$month-1,"01",$year)); 
     163                                $last_month_year = date("m-Y", strtotime("-1 month", mktime(0,0,0,$month,"01",$year) ) ); 
     164                                $last_month_year = split("-",$last_month_year); 
     165                                $next_month_year = date("m-Y", strtotime("+1 month", mktime(0,0,0,$month,"01",$year) ) ); 
     166                                $next_month_year = split("-",$next_month_year); 
     167                                $today = date("d-m-Y"); 
     168                                 
     169                                $days_of_calendar = array(); 
     170                                 
     171                                //identificando os dias do mês anterior 
     172                                for($i = 0; $i < $day_of_week_first_day; $i++) { 
     173                                        $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);                                   
     174                                } 
     175                                 
     176                                //adicionando os dias do mês especificado 
     177                                for($i = 0; $i < ($last_day_of_month ); $i++) { 
     178                                        $days_of_calendar[$i+$day_of_week_first_day] = array("day" => $i+1, "month" => $month, "year" => $year, "other_month" => false); 
     179                                } 
     180                                 
     181                                //pegando todos os eventos a partir o menor dia visível do mês anterior 
     182                                $tstart = mktime(0,0,0,$last_month_year[0],($last_day_of_before_month-$day_of_week_first_day),$last_month_year[1]); 
     183                                $tstart -= $GLOBALS['phpgw']->datetime->tz_offset; 
     184                                $tstop = $tstart + (86400*sizeof($days_of_calendar)); //(24horas*60min*60seg*total de dias exibidos) 
     185                                $events = get_events($this, $accountId, $tstart, $tstop); 
     186                                 
     187                                //definindo os blocos a serem utilizados 
     188                                $this->template->set_block('calendar','calendar_header_begin_block'); 
     189                                $this->template->set_block('calendar','calendar_header_end_block'); 
     190                                $this->template->set_block('calendar','calendar_header_block'); 
     191                                $this->template->set_block('calendar','calendar_day_block'); 
     192                                $this->template->set_block('calendar','calendar_day_begin_block'); 
     193                                $this->template->set_block('calendar','calendar_day_end_block'); 
     194                                 
     195                                //definindo a barra de navegação do calandário 
     196                                $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]); 
     197                                $this->template->set_var("current_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=calendario&mes=".$month."&ano=".$year); 
     198                                $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]); 
     199                                $this->template->set_var("current_label", $month." / ".$year); 
     200                                $this->template->parse('events_box','bar_block',true); 
     201                                 
     202                                for($i = 0; $i < 7; $i++) { 
     203                                        $this->template->set_var("week_day", $this->shortDaysOfWeek[$i]); 
     204                                        $this->template->parse('week_day_box','calendar_header_block',true); 
     205                                } 
     206                                                                 
     207                                $this->template->parse('calendar_box','calendar_header_begin_block',true); 
     208                                $this->template->parse('calendar_box','calendar_day_begin_block',true); 
     209                                 
     210                                foreach($days_of_calendar as $index=>$value) { 
     211                                        $extra_class = ""; 
     212                                        $calendar_day = $value["day"]; 
     213 
     214                                        if($today === $value["day"]."-".$value["month"]."-".$value["year"]) 
     215                                                $extra_class .= " hoje"; 
     216 
     217                                        if($value["other_month"]) 
     218                                                $extra_class .= " outro_mes"; 
     219                                         
     220                                        $key = $value["year"].$this->common->complete_string($value["month"],2,"R","0").$this->common->complete_string($value["day"],2,"R","0"); 
     221                                         
     222                                        if( array_key_exists($key, $events ) ) { 
     223                                                $this->template->set_var("qtd_commitment", sizeof($events[$key])); 
     224                                        } else { 
     225                                                $this->template->set_var("qtd_commitment", null); 
    109226                                        } 
    110                                 } 
    111                                 $p->parse('events','views'); 
    112                                 //$p->pfp('out','views'); 
    113                         } 
    114                         else { 
    115                                 $p->set_block('view','no_event'); 
    116                                 $syear  = date('Y',$tstart); 
    117                                 $smonth = date('m',$tstart); 
    118                                 $sday   = date('d',$tstart); 
    119                                 $eyear  = date('Y',$tstop); 
    120                                 $emonth = date('m',$tstop); 
    121                                 $eday   = date('d',$tstop); 
    122                                 $p->set_var("start_date",$sday."/".$smonth."/".$syear); 
    123                                 $p->set_var("end_date", $eday."/".$emonth."/".$eyear); 
    124                                 $p->parse('events','no_event'); 
    125                 //              $p->pfp('out','no_event'); 
    126                         } 
    127                         $p->set_var("lang_schedule",lang("schedule")); 
    128                         //$p->pfp('out','body'); 
    129                         $GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','body')); 
     227 
     228                                        $this->template->set_var("calendar_day", $calendar_day); 
     229                                         
     230                                        $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"]); 
     231                                        $this->template->set_var("extra_class", $extra_class);                                   
     232                                        $this->template->parse('calendar_box','calendar_day_block',true); 
     233                                         
     234                                        if(($index+1)%7==0) { 
     235                                                $this->template->parse('calendar_box','calendar_day_end_block',true); 
     236                                                $this->template->parse('calendar_box','calendar_day_begin_block',true); 
     237                                        } 
     238                                } 
     239                                $this->template->parse('calendar_box','calendar_day_end_block',true); 
     240                                $this->template->parse('calendar_box','calendar_header_end_block',true); 
     241                         
     242                        } else  { 
     243                                $tstart = mktime(0,0,0,$month,$day,$year); 
     244                                $tstart -= $GLOBALS['phpgw']->datetime->tz_offset; 
     245                                $tstop = $tstart + 86400; //(24horas*60min*60seg*1dia) 
     246                                $events = get_events($this, $accountId, $tstart, $tstop); 
     247                                 
     248                                $day = $this->common->complete_string($day,2,"R","0"); 
     249                                $month = $this->common->complete_string($month,2,"R","0"); 
     250                                 
     251                                //descobrind o primeiro dia da semana e o último 
     252                                $before_day = date("d-m-Y", strtotime("-1 day", mktime(0,0,0,$month,$day,$year) ) ); 
     253                                $before_day = split("-",$before_day); 
     254                                $next_day = date("d-m-Y", strtotime("+1 day", mktime(0,0,0,$month,$day,$year) ) ); 
     255                                $next_day = split("-",$next_day);                                
     256                                 
     257                                //definindo a barra de navegação do calandário 
     258                                $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]); 
     259                                $this->template->set_var("current_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia=".$day."&mes=".$month."&ano=".$year); 
     260                                $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]); 
     261                                $this->template->set_var("current_label", $this->daysOfWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)]." - ".$day."/".$month."/".$year); 
     262                                $this->template->parse('events_box','bar_block',true);                           
     263                                 
     264                                if(!empty($events[$year.$month.$day])) 
     265                                        print_events($this, $events[$year.$month.$day]); 
     266                                else { 
     267                                        $this->template->set_var("msg_no_event", lang("Dont have event that day")); 
     268                                        $this->template->parse('events_box','no_event_block',true); 
     269                                } 
     270                        } 
     271                         
     272                        $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','page')); 
    130273                } 
    131                  
    132                 function page($_page='',$params='') 
    133                 { 
    134                         if($_page == '') 
    135                         { 
    136                                 $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); 
    137                                 $_page = $page_[0]; 
    138  
    139                                 if ($_page=='planner_cat' || $_page=='planner_user') 
    140                                 { 
    141                                         $_page = 'planner'; 
    142                                 } 
    143                                 elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) 
    144                                 { 
    145                                         $_page = 'month'; 
    146                                         $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); 
    147                                         $GLOBALS['phpgw']->preferences->save_repository(); 
    148                                 } 
    149                         } 
    150                         if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || 
    151                                 strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))   // email, felamimail, ... 
    152                         { 
    153                                 $page_app = 'calendar'; 
    154                         } 
    155                         else 
    156                         { 
    157                                 $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; 
    158                         } 
    159                         if (is_array($params)) 
    160                         { 
    161                                 $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; 
    162                         } 
    163                         else 
    164                         { 
    165                                 $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; 
    166                         } 
    167                         return $GLOBALS['phpgw']->link('/index.php',$params); 
    168                 } 
    169                  
    170                 function init_schedule() { 
    171                         $_SESSION['mobile_calendar'] = NULL; 
    172                         $this->add_participants(); 
    173                 } 
    174                  
    175                 function add_participants() { 
    176  
    177                         $ui_cc = CreateObject('mobile.ui_mobilecc'); 
    178                         $ui_cc->contacts_list(true); 
    179                 } 
    180                  
    181                 function add_participant() { 
    182                          
    183                         $participants = $_SESSION["mobile_calendar"]; 
    184                          
    185                         if(!is_array($participants)) 
    186                                 $participants = array(); 
    187                                  
    188                         $participants[$_GET['user']] = $_GET['cn']; 
    189                          
    190                         $_SESSION["mobile_calendar"] = $participants; 
    191                                  
    192                         $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    193                         $p->set_file(Array('continue' => 'keep_add_participants.tpl')); 
    194                         $p->set_block('continue','body'); 
    195                         $p->set_var('lang_add_participants',lang('keep add participants')); 
    196                         $p->set_var('lang_continue',lang('continue scheduling')); 
    197                         //$p->pfp('out','body'); 
    198                         $GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','body')); 
    199                 } 
    200                  
    201                 function add($cd=0,$readsess=0) 
    202                 { 
    203                         if(!$this->bo->check_perms(PHPGW_ACL_ADD)) 
    204                         { 
    205                                 $this->index(); 
    206                         } 
    207                          
    208                         if($readsess) 
    209                         { 
    210                                 $event = $this->bo->restore_from_appsession; 
    211                                 if(!$event['owner']) 
    212                                 { 
    213                                         $this->bo->add_attribute('owner',$this->bo->owner); 
    214                                 } 
    215                                 $can_edit = True; 
    216                         } 
    217                         else 
    218                         { 
    219                                 $this->bo->event_init(); 
    220                                 $this->bo->add_attribute('id',0); 
    221  
    222                                 $can_edit = True; 
    223                                 $participants = (string)(get_var('participants',array('GET'),FALSE)); 
    224                                 $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); 
    225                                 $startmin  = (int)(get_var('minute',array('GET'),0)); 
    226                                 $endmin    = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; 
    227                                 $endhour   = $starthour + $this->bo->normalizeminutes($endmin); 
    228                                  
    229                                 $subject        = (string)(get_var('title',array('GET'),0)); 
    230                                 if ($subject != '0') 
    231                                 { 
    232                                         $description    = (string)(get_var('description',array('GET'),0)); 
    233                                         $location       = (string)(get_var('location',array('GET'),0)); 
    234                                 } 
    235                                 else 
    236                                         unset($subject); 
    237                                  
    238                                 $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); 
    239                                 $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); 
    240                                 $this->bo->set_title($subject); 
    241                                 $this->bo->set_description($description); 
    242                                 $this->bo->add_attribute('location',$location); 
    243                                 $this->bo->set_ex_participants(''); 
    244                                 $this->bo->add_attribute('uid',''); 
    245                                 $this->bo->add_attribute('priority',2); 
    246                                 if(@$this->bo->prefs['calendar']['default_private']) 
    247                                 { 
    248                                         $this->bo->set_class(False); 
    249                                 } 
    250                                 else 
    251                                 { 
    252                                         $this->bo->set_class(True); 
    253                                 } 
    254  
    255                                 $this->bo->add_attribute('participants','A',$this->bo->owner); 
    256                                 $this->bo->set_recur_none(); 
    257                                 $event = $this->bo->get_cached_event(); 
    258                                  
    259                         } 
    260                         $this->edit_form( 
    261                                 Array( 
    262                                         'event' => $event, 
    263                                         'cd' => $cd 
    264                                 ) 
    265                         ); 
    266                         //$GLOBALS['phpgw']->common->phpgw_footer(); 
    267                 } 
    268                  
    269                 function edit($params='') 
    270                 { 
    271                         if($this->debug) 
    272                         { 
    273                                 echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; 
    274                                 echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; 
    275                         } 
    276  
    277                         if(isset($_GET['readsess'])) 
    278                         { 
    279                                 $params['readsess'] = $_GET['readsess']; 
    280                                 $params['cd'] = 0; 
    281                         } 
    282  
    283                         if($this->debug) 
    284                         { 
    285                                 echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; 
    286                                 echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; 
    287                         } 
    288  
    289                         if($params != '' && @is_array($params) && @isset($params['readsess'])) 
    290                         { 
    291                                 $can_edit = True; 
    292                                 $this->edit_form( 
    293                                         Array( 
    294                                                 'event' => $this->bo->restore_from_appsession(), 
    295                                                 'cd' => $params['cd'] 
    296                                         ) 
    297                                 ); 
    298                         } 
    299                         elseif(isset($_GET['cal_id'])) 
    300                         { 
    301                                 $cal_id = (int)$_GET['cal_id']; 
    302                                 $event = $this->bo->read_entry($cal_id); 
    303  
    304                                 if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) 
    305                                 { 
    306                                         Header('Location: '.$this->page('view','&cal_id='.$cal_id)); 
    307                                         $GLOBALS['phpgw']->common->phpgw_exit(); 
    308                                 } 
    309                                 if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') 
    310                                 { 
    311                                         $event['id'] = 0; 
    312                                         $this->bo->set_recur_date($event,$_POST['date']); 
    313                                         $event['recur_type'] = MCAL_RECUR_NONE; 
    314                                         $event['recur_interval'] = 0; 
    315                                         $event['recur_data'] = 0; 
    316                                         $event['recur_enddate']['month'] = 0; 
    317                                         $event['recur_enddate']['mday'] = 0; 
    318                                         $event['recur_enddate']['year'] = 0; 
    319                                         $event['recur_exception'] = array(); 
    320                                 } 
    321                                 $this->edit_form( 
    322                                         Array( 
    323                                                 'event' => $event, 
    324                                                 'cd'    => $cd 
    325                                         ) 
    326                                 ); 
    327                         } 
    328                 } 
    329                  
    330                 function update() { 
    331                         $params = array(); 
    332                         $params['from_mobile'] = true; 
    333                         $this->bo->update($params); 
    334                 } 
    335                  
    336                 function edit_form($param) 
    337                 { 
    338                         if(!is_array($param)) 
    339                         { 
    340                                 $this->index(); 
    341                         } 
    342                          
    343                         if(isset($param['event'])) 
    344                         { 
    345                                 $event = $param['event']; 
    346                         } 
    347                          
    348                         $hourformat = substr($this->bo->users_timeformat,0,1); 
    349                          
    350                         // $sb = CreateObject('phpgwapi.sbox'); 
    351                         $sb = CreateObject('phpgwapi.sbox2'); 
    352                         $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!! 
    353                          
    354                         unset($GLOBALS['phpgw_info']['flags']['noheader']); 
    355                         unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
    356                         $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
    357                         $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
    358                         $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); 
    359                         //$GLOBALS['phpgw']->common->phpgw_header(); 
    360  
    361                         $p = &$GLOBALS['phpgw']->template; 
    362                         $p->set_file( 
    363                                 Array( 
    364                                         'edit'          => 'edit.tpl', 
    365                                         'form_button'   => 'form_button_script.tpl' 
    366                                 ) 
    367                         ); 
    368                         $p->set_block('edit','edit_entry','edit_entry'); 
    369                         $p->set_block('edit','list','list'); 
    370                         $p->set_block('edit','hr','hr'); 
    371                          
    372                         $vars = Array( 
    373                                 'font'                  => $this->theme['font'], 
    374                                 'bg_color'              => $this->theme['bg_text'], 
    375                                 'action_url'            => $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.update')), 
    376                                 'accounts_link'         => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), 
    377                                 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" 
    378                                         . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" 
    379                                         . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" 
    380                                         . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": 
    381                                         (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) 
    382                                         . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? 
    383                                         '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), 
    384                                 'errormsg'              => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):''), 
    385                                 'row_owner'             => '<input type="hidden" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'">' 
    386                         ); 
    387                          
    388                         $p->set_var($vars); 
    389  
    390 // Brief Description 
    391                         $var['title'] = Array( 
    392                                 'tr_color' => $this->theme['th_bg'], 
    393                                 'field' => lang('Title'), 
    394                                 'data'  => '<input name="cal[title]" size="15" maxlength="80" value="'.$event['title'].'">' 
    395                         ); 
    396  
    397 // Location 
    398                         $var['location'] = Array( 
    399                                 'field' => lang('Location'), 
    400                                 'data'  => '<input name="cal[location]" size="15" maxlength="255" value="'.$event['location'].'">' 
    401                         ); 
    402  
    403 // Date 
    404  
    405                         $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    406                         $var['startdate'] = Array( 
    407                                 'field' => lang('Start Date'), 
    408  
    409                                 'data'  => $GLOBALS['phpgw']->common->dateformatorder( 
    410                                    $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), 
    411                                    $sb->getMonths('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), 
    412                                    $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')), 
    413                                    true 
    414                                 ) 
    415  
    416 //                              'data' => $jscal->input('start[str]',$start) 
    417                         ); 
    418  
    419 // Time 
    420                         if ($this->bo->prefs['common']['timeformat'] == '12') 
    421                         { 
    422                                 $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" 
    423                                         . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; 
    424                         } 
    425                         $var['starttime'] = Array( 
    426                                 'field' => lang('Start Time'), 
    427                                 '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 
    428                         ); 
    429  
    430 // End Date 
    431                         $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    432                         $var['enddate'] = Array( 
    433                                 'field' => lang('End Date'), 
    434  
    435                                 'data'  => $GLOBALS['phpgw']->common->dateformatorder( 
    436                                    $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), 
    437                                    $sb->getMonths('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), 
    438                                    $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')),true 
    439                                 ) 
    440  
    441 //                              'data' => $jscal->input('end[str]',$end) 
    442                         ); 
    443  
    444 // End Time 
    445                         if ($this->bo->prefs['common']['timeformat'] == '12') 
    446                         { 
    447                                 $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" 
    448                                         . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; 
    449                         } 
    450                         $var['endtime'] = Array( 
    451                                 'field' => lang('End Time'), 
    452                                 '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 
    453                         ); 
    454  
    455  
    456                         $participants = $_SESSION['mobile_calendar']; 
    457                         $str = " "; 
    458                         foreach($participants as $id => $nome) { 
    459                                 $str.="<option value='$id' selected>$nome</option>"; 
    460                         } 
    461                          
    462                          
    463                         $var['participants'] = array 
    464                                                 ( 
    465                                                         'field' => lang('Participants'),                                                         
    466                                                         'data'  => " 
    467                                                         <select id='user_list' name='participants[]' style='width: 220px' multiple size='5'>".$str."</select></center> 
    468                                                                         <script src='../calendar/templates/celepar/js/edit.js' type='text/javascript'></script> 
    469                                                                         " 
    470                                                 ); 
    471                          
    472  
    473                         /*$var['owner'] = Array( 
    474                                         'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), 
    475                                         'data'  => '<input type="checkbox" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'" checked read-only="true">' 
    476                                 );*/ 
    477  
    478  
    479                         if (!isset($this->fields)) 
    480                         { 
    481                                 $this->custom_fields = CreateObject('calendar.bocustom_fields'); 
    482                                 $this->fields = &$this->custom_fields->fields; 
    483                                 $this->stock_fields = &$this->custom_fields->stock_fields; 
    484                         } 
    485                         $preserved = False; 
    486                         foreach($this->fields as $field => $data) 
    487                         { 
    488                                 /*if($field=='owner') 
    489                                         $p->set_var('display',"visibility:hidden"); 
    490                                 else 
    491                                         $p->set_var('display'," ");*/ 
    492                                 if (!$data['disabled']) 
    493                                 { 
    494                                         if (isset($var[$field])) 
    495                                         { 
    496                                                 switch($field) 
    497                                                 { 
    498                                                         case 'startdate': 
    499                                                                 $this->output_template_array($p,'row','list',$var['startdate']); 
    500                                                                 $this->output_template_array($p,'row','list',$var['starttime']); 
    501                                                                 break; 
    502                                                         case 'enddate': 
    503                                                                 $this->output_template_array($p,'row','list',$var['enddate']); 
    504                                                                 $this->output_template_array($p,'row','list',$var['endtime']); 
    505                                                                 break; 
    506                                                         default: 
    507                                                                 $this->output_template_array($p,'row','list',$var[$field]); 
    508                                                 } 
    509                                         } 
    510                                         elseif (!isset($this->stock_fields[$field]))    // Custom field 
    511                                         { 
    512                                                 $lang = lang($name = substr($field,1)); 
    513                                                 $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). 
    514                                                         ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); 
    515                                                 $v = array( 
    516                                                         'field' => $lang == $name.'*' ? $name : $lang, 
    517                                                         'data'  => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' 
    518                                                 ); 
    519                                                 if ($data['title']) 
    520                                                 { 
    521                                                         $v['tr_color'] = $this->theme['th_bg']; 
    522                                                 } 
    523                                                 if (!$data['length'] && $data['title']) 
    524                                                 { 
    525                                                         $p->set_var('tr_color',$this->theme['th_bg']); 
    526                                                         $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); 
    527                                                         $p->parse('row','hr',True); 
    528                                                 } 
    529                                                 else 
    530                                                 { 
    531                                                         $this->output_template_array($p,'row','list',$v); 
    532                                                 } 
    533                                         } 
    534                                 } 
    535                                 else    // preserve disabled fields 
    536                                 { 
    537                                         switch ($field) 
    538                                         { 
    539                                                 case 'owner': 
    540                                                         $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; 
    541                                                         break; 
    542                                                 case 'recure_type': 
    543                                                         foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) 
    544                                                         { 
    545                                                                 $preserved[$field] = $event[$field]; 
    546                                                         } 
    547                                                         break; 
    548                                                 case 'startdate': 
    549                                                 case 'enddate': 
    550                                                         $field = substr($field,0,-4); 
    551                                                 default: 
    552                                                         $preserved[$field] = $event[$field]; 
    553                                         } 
    554                                 } 
    555                         } 
    556                         unset($var); 
    557                         if (is_array($preserved)) 
    558                         { 
    559                                 //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; 
    560                                 $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); 
    561                         } 
    562                         $p->set_var('submit_button',lang('Save')); 
    563                          
    564                          
    565  
    566                         $delete_button = $cancel_button = ''; 
    567                         if ($event['id'] > 0) 
    568                         { 
    569                                 $var = Array( 
    570                                         'action_url_button'     => $this->page('delete','&cal_id='.$event['id']), 
    571                                         'action_text_button'    => lang('Delete'), 
    572                                         'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", 
    573                                         'action_extra_field'    => '' 
    574                                 ); 
    575                                 $p->set_var($var); 
    576                                 $delete_button = $p->fp('out','form_button'); 
    577                                  
    578                         } 
    579                         $p->set_var('delete_button',$delete_button); 
    580  
    581                         if ($this->bo->return_to) 
    582                         { 
    583                                 $var = Array( 
    584                                         'action_url_button'     => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), 
    585                                         'action_text_button'    => lang('Cancel'), 
    586                                         'action_confirm_button' => '', 
    587                                         'action_extra_field'    => '' 
    588                                 ); 
    589                                 $p->set_var($var); 
    590                                 $cancel_button = $p->fp('out','form_button'); 
    591                         } 
    592                          
    593                         $p->set_var('lang_add_participants',lang("keep add participants")); 
    594                          
    595                         $p->set_var('cancel_button',$cancel_button); 
    596                         $p->pparse('out','edit_entry'); 
    597                          
    598                 } 
    599                  
    600                 function get_organizations($context, $selected='', $recursive = false) 
    601                 { 
    602                         $s = CreateObject('phpgwapi.sector_search_ldap'); 
    603                                                  
    604                         return ($recursive ?  
    605                                 $s->get_organizations($context, $selected, false ,false) : 
    606                                 $s->get_sectors($selected, false, false)); 
    607                 }                
    608                  
    609                 function output_template_array(&$p,$row,$list,$var) 
    610                 { 
    611                         if (!isset($var['hidden_vars'])) 
    612                         { 
    613                                 $var['hidden_vars'] = ''; 
    614                         } 
    615                         if (!isset($var['tr_color'])) 
    616                         { 
    617                                 $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); 
    618                         } 
    619                         $p->set_var($var); 
    620                         $p->parse($row,$list,True); 
    621                 } 
    622                  
    623                 function overlap($params) { 
    624                         ini_set("display_errors","1"); 
    625                         if(!is_array($params)) 
    626                         { 
    627                         } 
    628                         else 
    629                         { 
    630                                 $overlapping_events = $params['o_events']; 
    631                                 $event = $params['this_event']; 
    632                         } 
    633  
    634                         $month = $event['start']['month']; 
    635                         $mday = $event['start']['mday']; 
    636                         $year = $event['start']['year']; 
    637  
    638                         $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; 
    639                         $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    640  
    641                         $overlap = ''; 
    642                         for($i=0;$i<count($overlapping_events);$i++) 
    643                         { 
    644                                 $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); 
    645                                 $overlap .= '<li>'.$this->link_to_entry($overlapped_event,$month,$mday,$year); 
    646                                 $overlap .= '<ul>'; 
    647                                 foreach($overlapped_event['participants'] as $id => $status) 
    648                                 { 
    649                                         $conflict = isset($event['participants'][$id]); 
    650                                         $overlap .= '<li>'.($conflict?'<b>':''). 
    651                                                 $GLOBALS['phpgw']->common->grab_owner_name($id). 
    652                                                 ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>\n"; 
    653                                 } 
    654                                 $overlap .= "</ul>\n"; 
    655                         } 
    656  
    657                         unset($GLOBALS['phpgw_info']['flags']['noheader']); 
    658                         unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
    659                         $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
    660                         $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
    661                         $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); 
    662                         //$GLOBALS['phpgw']->common->phpgw_header(); 
    663  
    664                         $p = $GLOBALS['phpgw']->template; 
    665                         $p->set_file( 
    666                                 Array( 
    667                                         'overlap'       => 'overlap.tpl', 
    668                                         'form_button'   => 'form_button_script.tpl' 
    669                                 ) 
    670                         ); 
    671  
    672                         $var = Array( 
    673                                 'color'         => $this->theme['bg_text'], 
    674                                 'overlap_title' => lang('Scheduling Conflict'), 
    675                                 '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)), 
    676                                 'overlap_list'  => $overlap 
    677                         ); 
    678                         $p->set_var($var); 
    679  
    680                         $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); 
    681                         $var = Array( 
    682                                 'action_url_button'     => $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.update','readsess'=>1)), 
    683                                 'action_text_button'    => lang('Ignore Conflict'), 
    684                                 'action_confirm_button' => '', 
    685                                 'action_extra_field'    => '' 
    686                         ); 
    687                         $this->output_template_array($p,'resubmit_button','form_button',$var); 
    688  
    689                         $var = Array( 
    690                                 'action_url_button'     => $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.edit','readsess'=>1,'date'=>$date)), 
    691                                 'action_text_button'    => lang('Re-Edit Event'), 
    692                                 'action_confirm_button' => '', 
    693                                 'action_extra_field'    => '' 
    694                         ); 
    695                         $this->output_template_array($p,'reedit_button','form_button',$var); 
    696                         $p->pparse('out','overlap'); 
    697                 } 
    698                  
    699                 function link_to_entry($event,$month,$day,$year) 
    700                 { 
    701                         $str = ''; 
    702                         $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); 
    703                         $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); 
    704  
    705                         $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    706                         $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    707                         $rawdate = mktime(0,0,0,$month,$day,$year); 
    708                         $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; 
    709                         $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; 
    710                         if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) 
    711                         { 
    712                                 $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); 
    713                         } 
    714                         elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) 
    715                         { 
    716                                 $time = '[ '.lang('All Day').' ]'; 
    717                         } 
    718                         elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) 
    719                         { 
    720                                 if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) 
    721                                 { 
    722                                         $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); 
    723                                 } 
    724                                 else 
    725                                 { 
    726                                         $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); 
    727                                 } 
    728  
    729                                 if($endtime >= ($rawdate_offset + 86400)) 
    730                                 { 
    731                                         $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); 
    732                                 } 
    733                                 else 
    734                                 { 
    735                                         $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); 
    736                                 } 
    737                                 $time = $start_time.'-'.$end_time; 
    738                         } 
    739                         else 
    740                         { 
    741                                 $time = ''; 
    742                         } 
    743                          
    744                         $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; 
    745  
    746                          
    747                          
    748                         if(!$is_private) 
    749                         { 
    750                                 //$text .= $this->bo->display_status($event['users_status']); 
    751                                  
    752                                 // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation     
    753                                 $textstatus=$this->bo->display_status($event['users_status']);  
    754                                  
    755                         } 
    756  
    757                         /* 
    758                         $text = '<nobr>&nbsp;'.$time.'&nbsp;</nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. 
    759                                 (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). 
    760                                 $GLOBALS['phpgw']->browser->br; 
    761                         */ 
    762                          
    763                         $texttime=$time; 
    764                         $texttitle=$this->bo->get_short_field($event,$is_private,'title'); 
    765                         $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
    766                         // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set 
    767                         $textlocation=$this->bo->get_short_field($event,$is_private,'location'); 
    768  
    769                         if ($viewable) 
    770                         { 
    771                                 $date = sprintf('%04d%02d%02d',$year,$month,$day); 
    772                                 $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); 
    773                                 $this->link_tpl->set_var('lang_view',lang('View this entry')); 
    774                                 $this->link_tpl->set_var('desc', $textdesc); 
    775                                 $this->link_tpl->set_var('location', $textlocation); 
    776                                 $this->link_tpl->parse('picture','link_open',True); 
    777                         } 
    778                         if (!$is_private) 
    779                         { 
    780                                 if($event['priority'] == 3) 
    781                                 { 
    782                                         $picture[] = Array( 
    783                                                 'pict'  => $GLOBALS['phpgw']->common->image('calendar','high'), 
    784                                                 'width' => 16, 
    785                                                 'height'=> 16, 
    786                                                 'title' => lang('high priority') 
    787                                         ); 
    788                                 } 
    789                                 if($event['recur_type'] == MCAL_RECUR_NONE) 
    790                                 { 
    791                                         $picture[] = Array( 
    792                                                 'pict'  => $GLOBALS['phpgw']->common->image('calendar','circle'), 
    793                                                 'width' => 9, 
    794                                                 'height'=> 9, 
    795                                                 'title' => lang('single event') 
    796                                         ); 
    797                                 } 
    798                                 else 
    799                                 { 
    800                                         $picture[] = Array( 
    801                                                 'pict'  => $GLOBALS['phpgw']->common->image('calendar','recur'), 
    802                                                 'width' => 12, 
    803                                                 'height'=> 12, 
    804                                                 'title' => lang('recurring event') 
    805                                         ); 
    806                                 } 
    807                         } 
    808                         $participants = $this->planner_participants($event['participants']); 
    809                         if(count($event['participants']) > 1) 
    810                         { 
    811                                 $picture[] = Array( 
    812                                         'pict'  => $GLOBALS['phpgw']->common->image('calendar','multi_3'), 
    813                                         'width' => 14, 
    814                                         'height'=> 14, 
    815                                         'title' => $participants 
    816                                 ); 
    817                         } 
    818                         else 
    819                         { 
    820                                 $picture[] = Array( 
    821                                         'pict'  =>  $GLOBALS['phpgw']->common->image('calendar','single'), 
    822                                         'width' => 14, 
    823                                         'height'=> 14, 
    824                                         'title' => $participants 
    825                                 ); 
    826                         } 
    827                         if($event['public'] == 0) 
    828                         { 
    829                                 $picture[] = Array( 
    830                                         'pict'  => $GLOBALS['phpgw']->common->image('calendar','private'), 
    831                                         'width' => 13, 
    832                                         'height'=> 13, 
    833                                         'title' => lang('private') 
    834                                 ); 
    835                         } 
    836                         if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) 
    837                         { 
    838                                 // if the alarm is to go off the day before the event 
    839                                 // the icon does not show up because of 'alarm_today' 
    840                                 // - TOM 
    841                                 if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) 
    842                                 { 
    843                                         $picture[] = Array( 
    844                                                 'pict'  => $GLOBALS['phpgw']->common->image('calendar','alarm'), 
    845                                                 'width' => 13, 
    846                                                 'height'=> 13, 
    847                                                 'title' => lang('alarm') 
    848                                         ); 
    849                                 } 
    850                         } 
    851  
    852                         $description = $this->bo->get_short_field($event,$is_private,'description'); 
    853                         for($i=0;$i<count($picture);$i++) 
    854                         { 
    855                                 $var = Array( 
    856                                         'pic_image' => $picture[$i]['pict'], 
    857                                         'width'     => $picture[$i]['width'], 
    858                                         'height'    => $picture[$i]['height'], 
    859                                         'title'     => $picture[$i]['title'] 
    860                                 ); 
    861                                 $this->output_template_array($this->link_tpl,'picture','pict',$var); 
    862                         } 
    863                         if ($texttitle) 
    864                         { 
    865                                 $var = Array( 
    866                         //              'text' => $text, 
    867                                         'time'=> $texttime, 
    868                                         'title'=> $texttitle, 
    869                                         'users_status'=>$textstatus, 
    870                                         'desc'=> $textdesc, 
    871                                         'location'=> "<br><b>Local:</b> ".$textlocation 
    872                                 ); 
    873                                 $this->output_template_array($this->link_tpl,'picture','link_text',$var); 
    874                         } 
    875  
    876                         if ($viewable) 
    877                         { 
    878                                 $this->link_tpl->parse('picture','link_close',True); 
    879                         } 
    880                         $str = $this->link_tpl->fp('out','link_pict'); 
    881                         $this->link_tpl->set_var('picture',''); 
    882                         $this->link_tpl->set_var('out',''); 
    883 //                      unset($p); 
    884                         return $str; 
    885                 } 
    886                  
    887                  
    888                 function planner_participants($parts) 
    889                 { 
    890                         static $id2lid; 
    891  
    892                         $names = ''; 
    893                         while (list($id,$status) = each($parts)) 
    894                         { 
    895                                 $status = substr($this->bo->get_long_status($status),0,1); 
    896  
    897                                 if (!isset($id2lid[$id])) 
    898                                 { 
    899                                         $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); 
    900                                 } 
    901                                 if (strlen($names)) 
    902                                 { 
    903                                         $names .= ",\n"; 
    904                                 } 
    905                                 $names .= $id2lid[$id]." ($status)"; 
    906                         } 
    907                         if($this->debug) 
    908                         { 
    909                                 echo '<!-- Inside participants() : '.$names.' -->'."\n"; 
    910                         } 
    911                         return $names; 
    912                 } 
    913                  
    914                  
    915274        } 
    916275         
    917  
    918          
    919276?> 
  • branches/2.2/mobile/inc/class.ui_mobilemail.inc.php

    r3589 r3590  
    475475                                                continue; 
    476476                                        if($message['from']['name']) 
    477                                                 $from_name = $functions->strach_string($message['from']['name'],20); 
     477                                                $from_name = $message['from']['name']; 
    478478                                        else 
    479                                                 $from_name = $functions->strach_string($message['from']['email'],20); 
     479                                                $from_name = $message['from']['email']; 
    480480                                         
    481481                                        $p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par"); 
     
    866866                                $this->new_msg( $params ); 
    867867                        }else { 
    868                                 $ui_home = CreateObject('mobile.ui_home'); 
    869                                 $params["success_message"] = lang("draft saved"); 
    870                                 $ui_home->index( $params ); 
     868                                header('Location: index.php?menuaction=menuaction=mobile.ui_home.index&success_message='.lang("draft saved")); 
    871869                        }                                
    872870                } 
     
    940938                                $this->new_msg( $params ); 
    941939                        }else { 
    942                                 $ui_home = CreateObject('mobile.ui_home'); 
    943                                 $params["success_message"] = lang("Message sent successfully"); 
    944                                 $ui_home->index($params); 
     940                                header('Location: index.php?menuaction=menuaction=mobile.ui_home.index&success_message='.lang("Message sent successfully")); 
    945941                        } 
    946942                } 
Note: See TracChangeset for help on using the changeset viewer.