source: branches/2.2/calendar/inc/class.uipublicview.inc.php @ 3201

Revision 3201, 30.3 KB checked in by wmerlotto, 14 years ago (diff)

Ticket #1182 - Corrigi a interpretação do e-mail do participante do agendamento

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Calendar                                                    *
4  * http://www.eGroupWare.org                                                *
5  * Maintained and further developed by RalfBecker@outdoor-training.de       *
6  * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net>               *
7  *          http://www.radix.net/~cknudsen                                  *
8  * Originaly modified by Mark Peters <skeeter@phpgroupware.org>             *
9  * --------------------------------------------                             *
10  *  This program is free software; you can redistribute it and/or modify it *
11  *  under the terms of the GNU General Public License as published by the   *
12  *  Free Software Foundation; either version 2 of the License, or (at your  *
13  *  option) any later version.                                              *
14  \**************************************************************************/
15
16
17        class uipublicview
18        {
19                var $template;
20                var $template_dir;
21
22                var $bo;
23                var $cat;
24
25                var $holidays;
26                var $holiday_color;
27               
28                // Variable defined to view public calendars;
29                var $publicView = False;
30                var $user = False;
31
32                var $debug = False;
33//              var $debug = True;
34
35                var $cat_id;
36                var $theme;
37                var $link_tpl;
38
39                // planner related variables
40                var $planner_header;
41                var $planner_rows;
42
43                var $planner_group_members;
44
45                var $planner_firstday;
46                var $planner_lastday;
47                var $planner_days;
48
49                var $planner_end_month;
50                var $planner_end_year;
51                var $planner_days_in_end_month;
52
53                var $planner_intervals = array( // conversation hour and interval depending on intervals_per_day
54                                        //                                  1 1 1 1 1 1 1 1 1 1 2 2 2 2
55                                        //              0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
56                                                '1' => array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), // 0=0-23h
57                                                '2' => array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0), // 0=0-12h, 1=12-23h
58                                                '3' => array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2), // 0=0-12h, 2=12-18h, 3=18-23h
59                                                '4' => array(0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3)  // 0=0-7, 7-12h, 3=12-18h, 4=18-23h
60                                        );
61
62                var $public_functions = array(         
63                        'index' => True,
64                        'publicView'  => True,
65                        'get_publicView' => True,
66                        'view' => True,
67                        'header' => True,
68                        'footer' => True,
69                       
70                );
71
72                function uipublicview()
73                {
74                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
75                        $GLOBALS['phpgw']->browser    = CreateObject('phpgwapi.browser');
76
77                        $this->theme = $GLOBALS['phpgw_info']['theme'];
78
79                        $this->bo = CreateObject('calendar.bocalendar',1);
80                        $this->cat = &$this->bo->cat;
81                        print_debug('BO Owner',$this->bo->owner);
82
83                        $this->template = $GLOBALS['phpgw']->template;
84                        $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar');
85                        $this->holiday_color = (substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06'];
86
87                        $this->cat_id   = $this->bo->cat_id;
88
89                        $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir);
90                        $this->link_tpl->set_unknowns('remove');
91                        $this->link_tpl->set_file(
92                                Array(
93                                        'link_picture'  => 'link_pict.tpl'
94                                )
95                        );
96                       
97                        $this->link_tpl->set_block('link_picture','link_pict','link_pict');
98                        $this->link_tpl->set_block('link_picture','pict','pict');
99                        $this->link_tpl->set_block('link_picture','link_open','link_open');
100                        $this->link_tpl->set_block('link_picture','link_close','link_close');
101                        $this->link_tpl->set_block('link_picture','link_text','link_text');
102
103                        if($this->bo->use_session)
104                        {
105                                // save return-fkt for add, view, ...
106                                list(,,$fkt) = explode('.',$_GET['menuaction']);
107                                if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner')
108                                {
109                                        $this->bo->return_to = $_GET['menuaction'].
110                                                sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day);
111                                }
112                                $this->bo->save_sessiondata();
113                        }
114                        $this->always_app_header = True;
115                       
116                       
117                        print_debug('UI',$this->_debug_sqsof());
118
119                        if (!is_object($GLOBALS['phpgw']->html))
120                        {
121                                $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
122                        }
123                        $this->html = &$GLOBALS['phpgw']->html;
124                }
125
126                /* Public functions */
127
128                function index($params='')
129                {
130                        if (!$params)
131                        {
132                                foreach(array('date','year','month','day') as $field)
133                                {
134                                        if (isset($_GET[$field]))
135                                        {
136                                                $params[$field] = $_GET[$field];
137                                        }
138                                }
139                        }
140                        $GLOBALS['phpgw']->redirect($this->page('',$params));
141                }
142
143                /* Private functions */
144                function _debug_sqsof()
145                {
146                        $data = array(
147                                'filter'     => $this->bo->filter,
148                                'cat_id'     => $this->bo->cat_id,
149                                'owner'      => $this->bo->owner,
150                                'year'       => $this->bo->year,
151                                'month'      => $this->bo->month,
152                                'day'        => $this->bo->day,
153                                'sortby'     => $this->bo->sortby,
154                                'num_months' => $this->bo->num_months
155                        );
156                        Return _debug_array($data,False);
157                }
158
159                function output_template_array(&$p,$row,$list,$var)
160                {
161                        if (!isset($var['hidden_vars']))
162                        {
163                                $var['hidden_vars'] = '';
164                        }
165                        if (!isset($var['tr_color']))
166                        {
167                                $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color();
168                        }
169                        $p->set_var($var);
170                        $p->parse($row,$list,True);
171                }
172
173                function page($_page='',$params='')
174                {
175                        if($_page == '')
176                        {
177                                $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']);
178                                $_page = $page_[0];
179
180                                if ($_page=='planner_cat' || $_page=='planner_user')
181                                {
182                                        $_page = 'planner';
183                                }
184                                elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner'))
185                                {
186                                        $_page = 'month';
187                                        $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month');
188                                        $GLOBALS['phpgw']->preferences->save_repository();
189                                }
190                        }
191                       
192                        if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' ||
193                                strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))   // email, felamimail, ...
194                        {       
195                                $page_app = 'calendar';
196                        }
197                        else
198                        {       
199                                $page_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
200                        }
201                        $page_app = 'calendar.uipublicview.publicView';
202                       
203                        if (is_array($params))
204                        {
205                                $params['menuaction'] = $page_app;
206                        }
207                        else
208                        {
209                                $params = 'menuaction='.$page_app.$params;
210                        }
211                        return $GLOBALS['phpgw']->link('/index.php',$params);
212                }
213
214                function header()
215                {
216                        $cols = 8;
217                        if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True)
218                        {
219                                $cols++;
220                        }
221
222                        $tpl = $GLOBALS['phpgw']->template;
223                        $tpl->set_unknowns('remove');
224
225                        if (!file_exists($file = $this->template_dir.'/header.inc.php'))
226                        {
227                                $file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php';
228                        }
229                        include($file);
230                        $header = $tpl->fp('out','head');
231                        unset($tpl);
232                        echo $header;
233                }
234
235                function footer(){
236               
237                }
238                function selectFilter()
239                {
240                       
241                        $menuaction = $_GET['menuaction'];
242
243                        list(,,$method) = explode('.',$menuaction);
244
245                        if (@$this->bo->printer_friendly)
246                        {
247                                return;
248                        }
249
250                        $p = $GLOBALS['phpgw']->template;
251                       
252                        $p->set_file(
253                                Array(
254                                        'footer'        => 'footer.tpl',
255                                        'form_button'   => 'form_button_script.tpl'
256
257                                )
258                        );
259                        $p->set_block('footer','footer_table','footer_table');
260                        $p->set_block('footer','footer_row','footer_row');
261                        $p->set_block('footer','blank_row','blank_row');
262
263                        $m = $this->bo->month;
264                        $y = $this->bo->year;
265
266                        $thisdate = date('Ymd',mktime(0,0,0,$m,1,$y));
267                        $y--;
268
269                        $str = '';
270                        for ($i = 0; $i < 25; $i++)
271                        {
272                                $m++;
273                                if ($m > 12)
274                                {
275                                        $m = 1;
276                                        $y++;
277                                }
278                                $d = mktime(0,0,0,$m,1,$y);
279                                $d_ymd = date('Ymd',$d);
280                                $str .= '<option value="'.$d_ymd.'"'.($d_ymd == $thisdate?' selected':'').'>'.lang(date('F', $d)).strftime(' %Y', $d).'</option>'."\n";
281                        }
282                       
283                        $var = Array(
284                                'action_url'    => $this->page($method,''),
285                                'form_name'     => 'SelectMonth',
286                                'label'         => lang('Month'),
287                                'user'  => $this->user,
288                                'form_label'    => 'date',
289                                'form_onchange' => 'document.SelectMonth.submit()',
290                                'row'           => $str,
291                                'go'            => lang('Go!')
292                        );
293                       
294                        $this->output_template_array($p,'table_row','footer_row',$var);
295
296                   if($menuaction == 'calendar.uipublicview.week' || $menuaction == 'calendar.uipublicview.publicView')
297                   {
298                                unset($thisdate);
299                                $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset;
300                                $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset;
301
302                                $str = '';
303                                for ($i = -7; $i <= 7; $i++)
304                                {
305                                        $begin = $sun + (7*24*60*60 * $i) + 12*60*60;   // we use midday, that changes in daylight-saveing does not effect us
306                                        $end = $begin + 6*24*60*60;
307                    $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate+12*60*60 && $end >= $thisdate+12*60*60 ? ' selected':'').'>'                   
308                                                . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - '
309                        . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
310                        . '</option>' . "\n";                       
311                                }
312
313                                $var = Array(
314                                        'action_url'    => $this->page($method,''),
315                                        'form_name'     => 'SelectWeek',
316                                        'label'         => lang('Week'),
317                                        'form_label'    => 'date',
318                                        'user'  => $this->user,
319                                        'form_onchange' => 'document.SelectWeek.submit()',
320                                        'row'           => $str,
321                                        'go'            => lang('Go!')
322                                );
323
324                                $this->output_template_array($p,'table_row','footer_row',$var);
325                        }
326
327                        $str = '';
328                        for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); $i++)
329                        {
330                                $str .= '<option value="'.$i.'"'.($i == $this->bo->year?' selected':'').'>'.$i.'</option>'."\n";
331                        }
332
333                        $var = Array(
334                                'action_url'    => $this->page($method,''),
335                                'form_name'     => 'SelectYear',
336                                'label'         => lang('Year'),
337                                'user'  => $this->user,
338                                'form_label'    => 'year',
339                                'form_onchange' => 'document.SelectYear.submit()',
340                                'row'           => $str,
341                                'go'            => lang('Go!')
342                        );
343                        $this->output_template_array($p,'table_row','footer_row',$var);
344
345                        if($menuaction == 'calendar.uipublicview.planner')
346                        {
347                                $str = '';
348                                $date_str = '';
349
350                                if(isset($_GET['date']) && $_GET['date'])
351                                {
352                                        $date_str .= '    <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n";
353                                }
354                                $date_str .= '    <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n";
355                                $date_str .= '    <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n";
356                                $date_str .= '    <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n";
357
358                                for($i=1; $i<=6; $i++)
359                                {
360                                        $str .= '<option value="'.$i.'"'.($i == $this->bo->num_months?' selected':'').'>'.$i.'</option>'."\n";
361                                }
362                               
363                                $var = Array(
364                                        'action_url'    => $this->page($method,''),
365                                        'form_name'     => 'SelectNumberOfMonths',
366                                        'label'         => lang('Number of Months'),
367                                        'hidden_vars' => $date_str,
368                                        'form_label'    => 'num_months',
369                                        'form_onchange' => 'document.SelectNumberOfMonths.submit()',
370                                        'action_extra_field'    => $date_str,
371                                        'user'  => $this->user,
372                                        'row'           => $str,
373                                        'go'            => lang('Go!')
374                                );
375                               
376
377                                $this->output_template_array($p,'table_row','footer_row',$var);
378                        }
379                               
380                        $p->pparse('out','footer_table');
381                        unset($p);
382                }
383
384
385                function link_to_entry($event,$month,$day,$year)
386                {
387                        $str = '';
388                        $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event);
389                        $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event);
390
391                        $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
392                        $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
393                        $rawdate = mktime(0,0,0,$month,$day,$year);
394                        $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset;
395                        $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset;
396                        if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime)
397                        {
398                                $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
399                        }
400                        elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60)
401                        {
402                                $time = '[ '.lang('All Day').' ]';
403                        }
404                        elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime)
405                        {
406                                if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE)
407                                {
408                                        $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat);
409                                }
410                                else
411                                {
412                                        $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
413                                }
414
415                                if($endtime >= ($rawdate_offset + 86400))
416                                {
417                                        $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat);
418                                }
419                                else
420                                {
421                                        $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat);
422                                }
423                                $time = $start_time.'-'.$end_time;
424                        }
425                        else
426                        {
427                                $time = '';
428                        }
429                       
430                        $texttitle = $texttime = $textdesc = $textlocation = $textstatus = '';
431
432                       
433                       
434                        if(!$is_private)
435                        {
436                                // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation   
437                                $textstatus=$this->bo->display_status($event['users_status']);
438                               
439                        }
440
441                       
442                        $texttime=$time;
443                        $texttitle=$this->bo->get_short_field($event,$is_private,'title');
444                        $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):'');
445                        // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set
446                        $textlocation=$this->bo->get_short_field($event,$is_private,'location');
447
448                        if (!$is_private)
449                        {
450                                if($event['priority'] == 3)
451                                {
452                                        $picture[] = Array(
453                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','high'),
454                                                'width' => 16,
455                                                'height'=> 16,
456                                                'title' => lang('high priority')
457                                        );
458                                }
459                                if($event['recur_type'] == MCAL_RECUR_NONE)
460                                {
461                                        $picture[] = Array(
462                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','circle'),
463                                                'width' => 9,
464                                                'height'=> 9,
465                                                'title' => lang('single event')
466                                        );
467                                }
468                                else
469                                {
470                                        $picture[] = Array(
471                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','recur'),
472                                                'width' => 12,
473                                                'height'=> 12,
474                                                'title' => lang('recurring event')
475                                        );
476                                }
477                        }
478                        $participants = $this->planner_participants($event['participants']);
479                        if(count($event['participants']) > 1)
480                        {
481                                $picture[] = Array(
482                                        'pict'  => $GLOBALS['phpgw']->common->image('calendar','multi_3'),
483                                        'width' => 14,
484                                        'height'=> 14,
485                                        'title' => $participants
486                                );
487                        }
488                        else
489                        {
490                                $picture[] = Array(
491                                        'pict'  =>  $GLOBALS['phpgw']->common->image('calendar','single'),
492                                        'width' => 14,
493                                        'height'=> 14,
494                                        'title' => $participants
495                                );
496                        }
497                        if($event['public'] == 0)
498                        {
499                                $picture[] = Array(
500                                        'pict'  => $GLOBALS['phpgw']->common->image('calendar','private'),
501                                        'width' => 13,
502                                        'height'=> 13,
503                                        'title' => lang('private')
504                                );
505                        }
506                        if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
507                        {
508                                // if the alarm is to go off the day before the event
509                                // the icon does not show up because of 'alarm_today'
510                                // - TOM
511                                if($this->bo->alarm_today($event,$rawdate_offset,$starttime))
512                                {
513                                        $picture[] = Array(
514                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','alarm'),
515                                                'width' => 13,
516                                                'height'=> 13,
517                                                'title' => lang('alarm')
518                                        );
519                                }
520                        }
521
522                        $description = $this->bo->get_short_field($event,$is_private,'description');
523                        for($i=0;$i<count($picture);$i++)
524                        {
525                                $var = Array(
526                                        'pic_image' => $picture[$i]['pict'],
527                                        'width'     => $picture[$i]['width'],
528                                        'height'    => $picture[$i]['height'],
529                                        'title'     => $picture[$i]['title']
530                                );
531                                $this->output_template_array($this->link_tpl,'picture','pict',$var);
532                        }
533                        if ($texttitle)
534                        {
535                                $var = Array(
536                        //              'text' => $text,
537                                        'time'=> $texttime,
538                                        'title'=> $texttitle,
539                                        'users_status'=>$textstatus,
540                                        'desc'=> $textdesc,
541                                        'location'=> $textlocation
542                                );
543                                $this->output_template_array($this->link_tpl,'picture','link_text',$var);
544                        }
545
546                        if ($viewable)
547                        {
548                                $this->link_tpl->parse('picture','link_close',True);
549                        }
550                        $str = $this->link_tpl->fp('out','link_pict');
551                        $this->link_tpl->set_var('picture','');
552                        $this->link_tpl->set_var('out','');
553//                      unset($p);
554                        return $str;
555                }
556
557                function planner_participants($parts)
558                {
559                        static $id2lid;
560
561                        $names = '';
562                        while (list($id,$status) = each($parts))
563                        {
564                                $status = substr($this->bo->get_long_status($status),0,1);
565
566                                if (!isset($id2lid[$id]))
567                                {
568                                        $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id);
569                                }
570                                if (strlen($names))
571                                {
572                                        $names .= ",\n";
573                                }
574                                $names .= $id2lid[$id]." ($status)";
575                        }
576                        if($this->debug)
577                        {
578                                echo '<!-- Inside participants() : '.$names.' -->'."\n";
579                        }
580                        return $names;
581                }
582
583
584                function week_header($month,$year,$display_name = False)
585                {
586                        $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1);
587
588                        $p = CreateObject('phpgwapi.Template',$this->template_dir);
589                        $p->set_unknowns('remove');
590                        $p->set_file(
591                                Array (
592                                        'month_header' => 'month_header.tpl'
593                                )
594                        );
595                        $p->set_block('month_header','monthly_header','monthly_header');
596                        $p->set_block('month_header','column_title','column_title');
597
598                        $var = Array(
599                                'bgcolor'       => $this->theme['th_bg'],
600                                'font_color'    => $this->theme['th_text']
601                        );
602                        if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white'])
603                        {
604                                $var = Array(
605                                        'bgcolor'       => '',
606                                        'font_color'    => ''
607                                );
608                        }
609                        $p->set_var($var);
610
611                        $p->set_var('col_width','14');
612                        if($display_name == True)
613                        {
614                                $p->set_var('col_title',lang('name'));
615                                $p->parse('column_header','column_title',True);
616                                $p->set_var('col_width','12');
617                        }
618
619                        for($i=0;$i<7;$i++)
620                        {
621                                $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i]));
622                                $p->parse('column_header','column_title',True);
623                        }
624                        return $p->fp('out','monthly_header');
625                }
626
627                function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0)
628                {       
629                        if($owner == 0)
630                        {
631                                $owner = $GLOBALS['phpgw_info']['user']['account_id'];
632                        }
633
634                        $temp_owner = $this->bo->owner;
635                        $publicView = $this -> publicView;
636
637                        $str = '';
638                        $p = CreateObject('phpgwapi.Template',$this->template_dir);
639                        $p->set_unknowns('keep');
640
641                        $p->set_file(
642                                Array(
643                                        'month_header'  => 'month_header.tpl',
644                                        'month_day'     => 'month_day.tpl'
645                                )
646                        );
647                        $p->set_block('month_header','monthly_header','monthly_header');
648                        $p->set_block('month_header','month_column','month_column');
649                        $p->set_block('month_day','month_daily','month_daily');
650                        $p->set_block('month_day','day_event','day_event');
651                        $p->set_block('month_day','event','event');
652
653                        $p->set_var('extra','');
654                        $p->set_var('col_width','14');
655                        if($display_name)
656                        {
657                                $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner));
658                                $p->parse('column_header','month_column',True);
659                                $p->set_var('col_width','12');
660                        }
661                        $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
662                        $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
663                        foreach($daily as $date => $day_params)
664                        {
665                                $year  = (int)substr($date,0,4);
666                                $month = (int)substr($date,4,2);
667                                $day   = (int)substr($date,6,2);
668                                $var   = Array(
669                                        'column_data' => '',
670                                        'extra' => ''
671                                );
672                                $p->set_var($var);
673                                if ($weekly || ($date >= $monthstart && $date <= $monthend))
674                                {
675                                        if ($day_params['new_event'] && !$publicView)
676                                        {
677                                                $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">'
678                                                        . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">'
679                                                        . '</a>';
680                                                $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>';
681                                        }
682                                        else
683                                        {
684                                                $new_event_link = '';
685                                                $day_number = $day;
686                                        }
687
688                                        $var = Array(
689                                                'extra'         => $day_params['extra'],
690                                                'new_event_link'=> $new_event_link,
691                                                'day_number'    => $day_number
692                                        );
693                                                        $p->set_var($var);
694
695                                        if(@$day_params['holidays'])
696                                        {
697                                                foreach($day_params['holidays'] as $key => $value)
698                                                {
699                                                        $var = Array(
700                                                                'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br
701                                                        );
702                                                        $this->output_template_array($p,'daily_events','event',$var);
703                                                }
704                                        }
705
706                                        if($day_params['appts'])
707                                        {
708                                                $var = Array(
709                                                        'week_day_font_size'    => '2',
710                                                        'events'                => ''
711                                                );
712                                                $p->set_var($var);
713                                                $events = $this->bo->cached_events[$date];
714                                                foreach($events as $event)
715                                                {
716                                                        if ($this->bo->rejected_no_show($event))
717                                                        {
718                                                                continue;       // user does not want to see rejected events
719                                                        }
720                                                        $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year));
721                                                        $p->parse('events','event',True);
722                                                        $p->set_var('day_events','');
723                                                }
724                                        }
725                                        $p->parse('daily_events','day_event',True);
726                                        $p->parse('column_data','month_daily',True);
727                                        $p->set_var('daily_events','');
728                                        $p->set_var('events','');
729                                }
730                                $p->parse('column_header','month_column',True);
731                                $p->set_var('column_data','');
732                        }
733                        $this->bo->owner = $temp_owner;
734                        return $p->fp('out','monthly_header');
735                }
736
737                function display_month($month,$year,$showyear,$owner=0)
738                {
739                        if($this->debug)
740                        {
741                                echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n";
742                        }
743
744                        $this->bo->store_to_cache(
745                                Array(
746                                        'syear' => $year,
747                                        'smonth'=> $month,
748                                        'sday'  => 1
749                                )
750                        );
751
752                        $monthstart = (int)(date('Ymd',mktime(0,0,0,$month    ,1,$year)));
753                        $monthend   = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year)));
754
755                        $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1);
756
757                        if($this->debug)
758                        {
759                                echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n";
760                                echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n";
761                        }
762
763                        $p = CreateObject('phpgwapi.Template',$this->template_dir);
764                        $p->set_unknowns('keep');
765
766                        $p->set_file(
767                                Array(
768                                        'week' => 'month_day.tpl'
769                                )
770                        );
771                        $p->set_block('week','m_w_table','m_w_table');
772                        $p->set_block('week','event','event');
773
774                        $var = Array(
775                                'cols'      => 7,
776                                'day_events'=> $this->week_header($month,$year,False)
777                        );
778                        $this->output_template_array($p,'row','event',$var);
779
780                        $cellcolor = $this->theme['row_on'];
781
782                        for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800)
783                        {
784                                $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor);
785                                $var = Array(
786                                        'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend)
787                                );
788                                $this->output_template_array($p,'row','event',$var);
789                        }
790                        return $p->fp('out','m_w_table');
791                }
792
793                function display_weekly($params, $accountId)
794                {
795                        if(!is_array($params))
796                        {
797                                $this->index();
798                        }
799
800                        $year = substr($params['date'],0,4);
801                        $month = substr($params['date'],4,2);
802                        $day = substr($params['date'],6,2);
803                        $showyear = $params['showyear'];
804                        $owners = $params['owners'];
805                       
806                       
807                        $p = CreateObject('phpgwapi.Template',$this->template_dir);
808                        $p->set_unknowns('keep');
809
810                        $p->set_file(
811                                Array(
812                                        'week'  => 'month_day.tpl'
813                                )
814                        );
815                        $p->set_block('week','m_w_table','m_w_table');
816                        $p->set_block('week','event','event');
817
818                        $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset;
819
820                        $cellcolor = $this->theme['row_off'];
821
822                        $true_printer_friendly = $this->bo->printer_friendly;
823
824                        if(is_array($owners))
825                        {
826                                $display_name = True;
827                                $counter = count($owners);
828                                $owners_array = $owners;
829                                $cols = 8;
830                        }
831                        else
832                        {
833                                $display_name = False;
834                                $counter = 1;
835                                $owners_array[0] = $owners;
836                                $cols = 7;
837                        }
838                        $var = Array(
839                                'cols'         => $cols,
840                                'day_events'   => $this->week_header($month,$year,$display_name)
841                        );
842                        $this->output_template_array($p,'row','event',$var);
843
844                        $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset;
845                        $tstop = $tstart + 604800;
846                        $original_owner = $this->bo->so->owner;
847
848                        $this->bo->so->owner = $accountId;
849                        $this->bo->so->open_box($accountId);
850                        $this->bo->store_to_cache(
851                                        Array(
852                                                'syear'  => date('Y',$tstart),
853                                                'owner' => $original_owner,
854                                                'smonth' => date('m',$tstart),
855                                                'sday'   => date('d',$tstart),
856                                                'eyear'  => date('Y',$tstop),
857                                                'emonth' => date('m',$tstop),
858                                                'eday'   => date('d',$tstop)
859                                        )
860                                );
861                               
862                        $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$accountId, True));
863                                $p->parse('row','event',True);
864                       
865                        $this->bo->so->owner = $original_owner;
866                        $this->bo->printer_friendly = $true_printer_friendly;
867                        return $p->fp('out','m_w_table');
868                }
869               
870                function set_week_array($startdate,$cellcolor,$weekly)
871                {
872                        for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400)
873                        {
874                                $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset
875                                print_debug('set_week_array : Date ',$date);
876
877                                if($events = $this->bo->cached_events[$date])
878                                {
879                                        print_debug('Date',$date);
880                                        print_debug('Appointments Found',count($events));
881
882                                        if (!$this->bo->prefs['calendar']['show_rejected'])
883                                        {
884                                                $appts = False;
885                                                foreach($events as $event)      // check for a not-rejected event
886                                                {
887                                                        if (!$this->bo->rejected_no_show($event))
888                                                        {
889                                                                $appts = True;
890                                                                break;
891                                                        }
892                                                }
893                                        }
894                                        else
895                                        {
896                                                $appts = True;
897                                        }
898                                }
899                                else
900                                {
901                                        $appts = False;
902                                }
903
904                                $holidays = $this->bo->cached_holidays[$date];
905                                if($weekly)
906                                {
907                                        $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor);
908                                }
909
910                                $day_image = '';
911                                if($holidays)
912                                {
913                                        $extra = ' bgcolor="'.$this->bo->holiday_color.'"';
914                                        $class = ($appts?'b':'').'minicalhol';
915                                        if ($date == $this->bo->today)
916                                        {
917                                                $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
918                                        }
919                                }
920                                elseif ($date != $this->bo->today)
921                                {
922                                        $extra = ' bgcolor="'.$cellcolor.'"';
923                                        $class = ($appts?'b':'').'minicalendar';
924                                }
925                                else
926                                {
927                                        $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"';
928                                        $class = ($appts?'b':'').'minicalendar';
929                                        $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
930                                }
931
932                                if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white'])
933                                {
934                                        $extra = '';
935                                }
936
937                                if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD))
938                                {
939                                        $new_event = True;
940                                }
941                                else
942                                {
943                                        $new_event = False;
944                                }
945                                $holiday_name = Array();
946                                if($holidays)
947                                {
948                                        for($k=0;$k<count($holidays);$k++)
949                                        {
950                                                $holiday_name[] = $holidays[$k]['name'];
951                                        }
952                                }
953                                $week = '';
954                                if (!$j || (!$weekly && $j && substr($date,6,2) == '01'))
955                                {
956                                        $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7);
957                                }
958                                $daily[$date] = Array(
959                                        'extra'         => $extra,
960                                        'new_event'     => $new_event,
961                                        'holidays'      => $holiday_name,
962                                        'appts'         => $appts,
963                                        'week'          => $week,
964                                        'day_image'     => $day_image,
965                                        'class'         => $class
966                                );
967                        }
968
969                        if($this->debug)
970                        {
971                                _debug_array($daily);
972                        }
973
974                        return $daily;
975                }
976               
977                function publicView()
978                {       
979                                                                       
980                        $account_name = $_POST['user'] ?
981                                                        $_POST['user'] :
982                                                        ($_GET['account_name'] ?
983                                                         $_GET['account_name'] : '');
984
985                        $theme_css = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/css/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'].'.css';
986               
987                        echo '<html>'."\n"
988                                .'<head>'."\n"
989                                .'<LINK href="'.$theme_css.'" type=text/css rel=StyleSheet>'."\n"
990                                .'</head><body>'
991                                .'<div id="divAppboxHeader">'
992                                .lang('weekly agenda of events')
993                                .'</div><div id="divAppbox"  align="center" >';
994                                                         
995                        if(!$account_name){                     
996                                echo '<font color="GREEN" size="+1">'.lang('it types login of the user to have access public agenda').'</font></center></div>';
997                                return True;
998                        }
999                                                         
1000                        $accounts = CreateObject('phpgwapi.accounts');
1001                        $accountId = $accounts->name2id($account_name);
1002
1003                        if(!$accountId){                       
1004                                echo '<font color="RED" size="+1">'.lang('this user does not exist').'</font></center></div>';
1005                                return True;
1006                        }
1007
1008                        $prefs = CreateObject('phpgwapi.preferences', $accountId);
1009                        $account_prefs = $prefs->read();
1010                       
1011                        $publicView = $account_prefs['calendar']['public_view'];
1012                       
1013                        if($publicView){
1014                                $this -> user = $account_name;
1015                                $this-> selectFilter();                         
1016                                echo $this->printer_publicView($this->get_publicView($accountId));
1017                               
1018                        }
1019                        else {
1020                                echo '<font color="RED" size="+1">'.lang('it types login of the user to have access public agenda').'</font></center></div>';
1021                        }
1022
1023                        return True;   
1024                }
1025
1026                function get_publicView($accountId)
1027                {
1028                        // allow users to view public calendars;
1029                        $this -> publicView = True;
1030                        $this->bo->read_holidays();
1031
1032                        $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year);
1033                        $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year);
1034
1035                        $var = Array(
1036                                'week_display'          =>      $this->display_weekly(
1037                                        Array(
1038                                                'date'          => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day),
1039                                                'showyear'      => true, False
1040                                        ),$accountId
1041                                ),
1042                                'print'                 =>      $print
1043                        );
1044
1045                        $p = CreateObject('phpgwapi.Template',$this->template_dir);
1046                        $p->set_file(
1047                                Array(
1048                                        'week_t' => 'publicView.tpl'
1049                                )
1050                        );
1051                        $p->set_var($var);
1052                        return $p->fp('out','week_t');
1053
1054                }
1055               
1056                function printer_publicView($body)
1057                {                               
1058                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
1059                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1060                        unset($GLOBALS['phpgw_info']['flags']['noappheader']);
1061                        unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
1062                       
1063                        $new_body .= $this->bo->debug_string.$body;
1064                        return $new_body;
1065                }
1066               
1067               
1068        }
1069?>
Note: See TracBrowser for help on using the repository browser.