[2] | 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 | { |
---|
[7655] | 219 | ++$cols; |
---|
[2] | 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 = ''; |
---|
[7655] | 270 | for ($i = 0; $i < 25; ++$i) |
---|
[2] | 271 | { |
---|
[7655] | 272 | ++$m; |
---|
[2] | 273 | if ($m > 12) |
---|
| 274 | { |
---|
| 275 | $m = 1; |
---|
[7655] | 276 | ++$y; |
---|
[2] | 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 = ''; |
---|
[7655] | 303 | for ($i = -7; $i <= 7; ++$i) |
---|
[2] | 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 = ''; |
---|
[7655] | 328 | for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); ++$i) |
---|
[2] | 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 | |
---|
[7655] | 358 | for($i=1; $i<=6; ++$i) |
---|
[2] | 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'); |
---|
[7673] | 523 | $picture_count = count($picture); |
---|
| 524 | for($i=0;$i<$picture_count;++$i) |
---|
[2] | 525 | { |
---|
| 526 | $var = Array( |
---|
| 527 | 'pic_image' => $picture[$i]['pict'], |
---|
| 528 | 'width' => $picture[$i]['width'], |
---|
| 529 | 'height' => $picture[$i]['height'], |
---|
| 530 | 'title' => $picture[$i]['title'] |
---|
| 531 | ); |
---|
| 532 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
| 533 | } |
---|
| 534 | if ($texttitle) |
---|
| 535 | { |
---|
| 536 | $var = Array( |
---|
| 537 | // 'text' => $text, |
---|
| 538 | 'time'=> $texttime, |
---|
| 539 | 'title'=> $texttitle, |
---|
| 540 | 'users_status'=>$textstatus, |
---|
| 541 | 'desc'=> $textdesc, |
---|
| 542 | 'location'=> $textlocation |
---|
| 543 | ); |
---|
| 544 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | if ($viewable) |
---|
| 548 | { |
---|
| 549 | $this->link_tpl->parse('picture','link_close',True); |
---|
| 550 | } |
---|
| 551 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
| 552 | $this->link_tpl->set_var('picture',''); |
---|
| 553 | $this->link_tpl->set_var('out',''); |
---|
| 554 | // unset($p); |
---|
| 555 | return $str; |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | function planner_participants($parts) |
---|
| 559 | { |
---|
| 560 | static $id2lid; |
---|
| 561 | |
---|
| 562 | $names = ''; |
---|
| 563 | while (list($id,$status) = each($parts)) |
---|
| 564 | { |
---|
| 565 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
| 566 | |
---|
| 567 | if (!isset($id2lid[$id])) |
---|
| 568 | { |
---|
| 569 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
| 570 | } |
---|
| 571 | if (strlen($names)) |
---|
| 572 | { |
---|
| 573 | $names .= ",\n"; |
---|
| 574 | } |
---|
| 575 | $names .= $id2lid[$id]." ($status)"; |
---|
| 576 | } |
---|
| 577 | if($this->debug) |
---|
| 578 | { |
---|
| 579 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
| 580 | } |
---|
| 581 | return $names; |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | |
---|
| 585 | function week_header($month,$year,$display_name = False) |
---|
| 586 | { |
---|
| 587 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 588 | |
---|
| 589 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 590 | $p->set_unknowns('remove'); |
---|
| 591 | $p->set_file( |
---|
| 592 | Array ( |
---|
| 593 | 'month_header' => 'month_header.tpl' |
---|
| 594 | ) |
---|
| 595 | ); |
---|
| 596 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 597 | $p->set_block('month_header','column_title','column_title'); |
---|
| 598 | |
---|
| 599 | $var = Array( |
---|
| 600 | 'bgcolor' => $this->theme['th_bg'], |
---|
| 601 | 'font_color' => $this->theme['th_text'] |
---|
| 602 | ); |
---|
| 603 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 604 | { |
---|
| 605 | $var = Array( |
---|
| 606 | 'bgcolor' => '', |
---|
| 607 | 'font_color' => '' |
---|
| 608 | ); |
---|
| 609 | } |
---|
| 610 | $p->set_var($var); |
---|
| 611 | |
---|
| 612 | $p->set_var('col_width','14'); |
---|
| 613 | if($display_name == True) |
---|
| 614 | { |
---|
| 615 | $p->set_var('col_title',lang('name')); |
---|
| 616 | $p->parse('column_header','column_title',True); |
---|
| 617 | $p->set_var('col_width','12'); |
---|
| 618 | } |
---|
| 619 | |
---|
[7655] | 620 | for($i=0;$i<7;++$i) |
---|
[2] | 621 | { |
---|
| 622 | $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i])); |
---|
| 623 | $p->parse('column_header','column_title',True); |
---|
| 624 | } |
---|
| 625 | return $p->fp('out','monthly_header'); |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 629 | { |
---|
| 630 | if($owner == 0) |
---|
| 631 | { |
---|
| 632 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | $temp_owner = $this->bo->owner; |
---|
| 636 | $publicView = $this -> publicView; |
---|
| 637 | |
---|
| 638 | $str = ''; |
---|
| 639 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 640 | $p->set_unknowns('keep'); |
---|
| 641 | |
---|
| 642 | $p->set_file( |
---|
| 643 | Array( |
---|
| 644 | 'month_header' => 'month_header.tpl', |
---|
| 645 | 'month_day' => 'month_day.tpl' |
---|
| 646 | ) |
---|
| 647 | ); |
---|
| 648 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 649 | $p->set_block('month_header','month_column','month_column'); |
---|
| 650 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 651 | $p->set_block('month_day','day_event','day_event'); |
---|
| 652 | $p->set_block('month_day','event','event'); |
---|
| 653 | |
---|
| 654 | $p->set_var('extra',''); |
---|
| 655 | $p->set_var('col_width','14'); |
---|
| 656 | if($display_name) |
---|
| 657 | { |
---|
| 658 | $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner)); |
---|
| 659 | $p->parse('column_header','month_column',True); |
---|
| 660 | $p->set_var('col_width','12'); |
---|
| 661 | } |
---|
| 662 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 663 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 664 | foreach($daily as $date => $day_params) |
---|
| 665 | { |
---|
| 666 | $year = (int)substr($date,0,4); |
---|
| 667 | $month = (int)substr($date,4,2); |
---|
| 668 | $day = (int)substr($date,6,2); |
---|
| 669 | $var = Array( |
---|
| 670 | 'column_data' => '', |
---|
| 671 | 'extra' => '' |
---|
| 672 | ); |
---|
| 673 | $p->set_var($var); |
---|
| 674 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 675 | { |
---|
| 676 | if ($day_params['new_event'] && !$publicView) |
---|
| 677 | { |
---|
| 678 | $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">' |
---|
| 679 | . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">' |
---|
| 680 | . '</a>'; |
---|
| 681 | $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>'; |
---|
| 682 | } |
---|
| 683 | else |
---|
| 684 | { |
---|
| 685 | $new_event_link = ''; |
---|
| 686 | $day_number = $day; |
---|
| 687 | } |
---|
| 688 | |
---|
| 689 | $var = Array( |
---|
| 690 | 'extra' => $day_params['extra'], |
---|
| 691 | 'new_event_link'=> $new_event_link, |
---|
| 692 | 'day_number' => $day_number |
---|
| 693 | ); |
---|
| 694 | $p->set_var($var); |
---|
| 695 | |
---|
| 696 | if(@$day_params['holidays']) |
---|
| 697 | { |
---|
| 698 | foreach($day_params['holidays'] as $key => $value) |
---|
| 699 | { |
---|
| 700 | $var = Array( |
---|
| 701 | 'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br |
---|
| 702 | ); |
---|
| 703 | $this->output_template_array($p,'daily_events','event',$var); |
---|
| 704 | } |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | if($day_params['appts']) |
---|
| 708 | { |
---|
| 709 | $var = Array( |
---|
| 710 | 'week_day_font_size' => '2', |
---|
| 711 | 'events' => '' |
---|
| 712 | ); |
---|
| 713 | $p->set_var($var); |
---|
| 714 | $events = $this->bo->cached_events[$date]; |
---|
| 715 | foreach($events as $event) |
---|
| 716 | { |
---|
| 717 | if ($this->bo->rejected_no_show($event)) |
---|
| 718 | { |
---|
| 719 | continue; // user does not want to see rejected events |
---|
| 720 | } |
---|
| 721 | $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year)); |
---|
| 722 | $p->parse('events','event',True); |
---|
| 723 | $p->set_var('day_events',''); |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | $p->parse('daily_events','day_event',True); |
---|
| 727 | $p->parse('column_data','month_daily',True); |
---|
| 728 | $p->set_var('daily_events',''); |
---|
| 729 | $p->set_var('events',''); |
---|
| 730 | } |
---|
| 731 | $p->parse('column_header','month_column',True); |
---|
| 732 | $p->set_var('column_data',''); |
---|
| 733 | } |
---|
| 734 | $this->bo->owner = $temp_owner; |
---|
| 735 | return $p->fp('out','monthly_header'); |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | function display_month($month,$year,$showyear,$owner=0) |
---|
| 739 | { |
---|
| 740 | if($this->debug) |
---|
| 741 | { |
---|
| 742 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | $this->bo->store_to_cache( |
---|
| 746 | Array( |
---|
| 747 | 'syear' => $year, |
---|
| 748 | 'smonth'=> $month, |
---|
| 749 | 'sday' => 1 |
---|
| 750 | ) |
---|
| 751 | ); |
---|
| 752 | |
---|
| 753 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
| 754 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 755 | |
---|
| 756 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 757 | |
---|
| 758 | if($this->debug) |
---|
| 759 | { |
---|
| 760 | echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n"; |
---|
| 761 | echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n"; |
---|
| 762 | } |
---|
| 763 | |
---|
| 764 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 765 | $p->set_unknowns('keep'); |
---|
| 766 | |
---|
| 767 | $p->set_file( |
---|
| 768 | Array( |
---|
| 769 | 'week' => 'month_day.tpl' |
---|
| 770 | ) |
---|
| 771 | ); |
---|
| 772 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 773 | $p->set_block('week','event','event'); |
---|
| 774 | |
---|
| 775 | $var = Array( |
---|
| 776 | 'cols' => 7, |
---|
| 777 | 'day_events'=> $this->week_header($month,$year,False) |
---|
| 778 | ); |
---|
| 779 | $this->output_template_array($p,'row','event',$var); |
---|
| 780 | |
---|
| 781 | $cellcolor = $this->theme['row_on']; |
---|
| 782 | |
---|
| 783 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 784 | { |
---|
| 785 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 786 | $var = Array( |
---|
| 787 | 'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 788 | ); |
---|
| 789 | $this->output_template_array($p,'row','event',$var); |
---|
| 790 | } |
---|
| 791 | return $p->fp('out','m_w_table'); |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | function display_weekly($params, $accountId) |
---|
| 795 | { |
---|
| 796 | if(!is_array($params)) |
---|
| 797 | { |
---|
| 798 | $this->index(); |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | $year = substr($params['date'],0,4); |
---|
| 802 | $month = substr($params['date'],4,2); |
---|
| 803 | $day = substr($params['date'],6,2); |
---|
| 804 | $showyear = $params['showyear']; |
---|
| 805 | $owners = $params['owners']; |
---|
| 806 | |
---|
| 807 | |
---|
| 808 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 809 | $p->set_unknowns('keep'); |
---|
| 810 | |
---|
| 811 | $p->set_file( |
---|
| 812 | Array( |
---|
| 813 | 'week' => 'month_day.tpl' |
---|
| 814 | ) |
---|
| 815 | ); |
---|
| 816 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 817 | $p->set_block('week','event','event'); |
---|
| 818 | |
---|
| 819 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 820 | |
---|
| 821 | $cellcolor = $this->theme['row_off']; |
---|
| 822 | |
---|
| 823 | $true_printer_friendly = $this->bo->printer_friendly; |
---|
| 824 | |
---|
| 825 | if(is_array($owners)) |
---|
| 826 | { |
---|
| 827 | $display_name = True; |
---|
| 828 | $counter = count($owners); |
---|
| 829 | $owners_array = $owners; |
---|
| 830 | $cols = 8; |
---|
| 831 | } |
---|
| 832 | else |
---|
| 833 | { |
---|
| 834 | $display_name = False; |
---|
| 835 | $counter = 1; |
---|
| 836 | $owners_array[0] = $owners; |
---|
| 837 | $cols = 7; |
---|
| 838 | } |
---|
| 839 | $var = Array( |
---|
| 840 | 'cols' => $cols, |
---|
| 841 | 'day_events' => $this->week_header($month,$year,$display_name) |
---|
| 842 | ); |
---|
| 843 | $this->output_template_array($p,'row','event',$var); |
---|
| 844 | |
---|
| 845 | $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 846 | $tstop = $tstart + 604800; |
---|
| 847 | $original_owner = $this->bo->so->owner; |
---|
| 848 | |
---|
| 849 | $this->bo->so->owner = $accountId; |
---|
| 850 | $this->bo->so->open_box($accountId); |
---|
| 851 | $this->bo->store_to_cache( |
---|
| 852 | Array( |
---|
| 853 | 'syear' => date('Y',$tstart), |
---|
| 854 | 'owner' => $original_owner, |
---|
| 855 | 'smonth' => date('m',$tstart), |
---|
| 856 | 'sday' => date('d',$tstart), |
---|
| 857 | 'eyear' => date('Y',$tstop), |
---|
| 858 | 'emonth' => date('m',$tstop), |
---|
| 859 | 'eday' => date('d',$tstop) |
---|
| 860 | ) |
---|
| 861 | ); |
---|
| 862 | |
---|
| 863 | $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$accountId, True)); |
---|
| 864 | $p->parse('row','event',True); |
---|
| 865 | |
---|
| 866 | $this->bo->so->owner = $original_owner; |
---|
| 867 | $this->bo->printer_friendly = $true_printer_friendly; |
---|
| 868 | return $p->fp('out','m_w_table'); |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | function set_week_array($startdate,$cellcolor,$weekly) |
---|
| 872 | { |
---|
[7655] | 873 | for ($j=0,$datetime=$startdate;$j<7;++$j,$datetime += 86400) |
---|
[2] | 874 | { |
---|
| 875 | $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset |
---|
| 876 | print_debug('set_week_array : Date ',$date); |
---|
| 877 | |
---|
| 878 | if($events = $this->bo->cached_events[$date]) |
---|
| 879 | { |
---|
| 880 | print_debug('Date',$date); |
---|
| 881 | print_debug('Appointments Found',count($events)); |
---|
| 882 | |
---|
| 883 | if (!$this->bo->prefs['calendar']['show_rejected']) |
---|
| 884 | { |
---|
| 885 | $appts = False; |
---|
| 886 | foreach($events as $event) // check for a not-rejected event |
---|
| 887 | { |
---|
| 888 | if (!$this->bo->rejected_no_show($event)) |
---|
| 889 | { |
---|
| 890 | $appts = True; |
---|
| 891 | break; |
---|
| 892 | } |
---|
| 893 | } |
---|
| 894 | } |
---|
| 895 | else |
---|
| 896 | { |
---|
| 897 | $appts = True; |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | else |
---|
| 901 | { |
---|
| 902 | $appts = False; |
---|
| 903 | } |
---|
| 904 | |
---|
| 905 | $holidays = $this->bo->cached_holidays[$date]; |
---|
| 906 | if($weekly) |
---|
| 907 | { |
---|
| 908 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 909 | } |
---|
| 910 | |
---|
| 911 | $day_image = ''; |
---|
| 912 | if($holidays) |
---|
| 913 | { |
---|
| 914 | $extra = ' bgcolor="'.$this->bo->holiday_color.'"'; |
---|
| 915 | $class = ($appts?'b':'').'minicalhol'; |
---|
| 916 | if ($date == $this->bo->today) |
---|
| 917 | { |
---|
| 918 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 919 | } |
---|
| 920 | } |
---|
| 921 | elseif ($date != $this->bo->today) |
---|
| 922 | { |
---|
| 923 | $extra = ' bgcolor="'.$cellcolor.'"'; |
---|
| 924 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 925 | } |
---|
| 926 | else |
---|
| 927 | { |
---|
| 928 | $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"'; |
---|
| 929 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 930 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 931 | } |
---|
| 932 | |
---|
| 933 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 934 | { |
---|
| 935 | $extra = ''; |
---|
| 936 | } |
---|
| 937 | |
---|
| 938 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 939 | { |
---|
| 940 | $new_event = True; |
---|
| 941 | } |
---|
| 942 | else |
---|
| 943 | { |
---|
| 944 | $new_event = False; |
---|
| 945 | } |
---|
| 946 | $holiday_name = Array(); |
---|
| 947 | if($holidays) |
---|
| 948 | { |
---|
[7673] | 949 | $holidays_count = count($holidays); |
---|
| 950 | for($k=0;$k<$holidays_count;++$k) |
---|
[2] | 951 | { |
---|
| 952 | $holiday_name[] = $holidays[$k]['name']; |
---|
| 953 | } |
---|
| 954 | } |
---|
| 955 | $week = ''; |
---|
| 956 | if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) |
---|
| 957 | { |
---|
| 958 | $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); |
---|
| 959 | } |
---|
| 960 | $daily[$date] = Array( |
---|
| 961 | 'extra' => $extra, |
---|
| 962 | 'new_event' => $new_event, |
---|
| 963 | 'holidays' => $holiday_name, |
---|
| 964 | 'appts' => $appts, |
---|
| 965 | 'week' => $week, |
---|
| 966 | 'day_image' => $day_image, |
---|
| 967 | 'class' => $class |
---|
| 968 | ); |
---|
| 969 | } |
---|
| 970 | |
---|
| 971 | if($this->debug) |
---|
| 972 | { |
---|
| 973 | _debug_array($daily); |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | return $daily; |
---|
| 977 | } |
---|
| 978 | |
---|
| 979 | function publicView() |
---|
| 980 | { |
---|
| 981 | |
---|
| 982 | $account_name = $_POST['user'] ? |
---|
| 983 | $_POST['user'] : |
---|
| 984 | ($_GET['account_name'] ? |
---|
| 985 | $_GET['account_name'] : ''); |
---|
| 986 | |
---|
[3201] | 987 | $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'; |
---|
[2] | 988 | |
---|
| 989 | echo '<html>'."\n" |
---|
| 990 | .'<head>'."\n" |
---|
| 991 | .'<LINK href="'.$theme_css.'" type=text/css rel=StyleSheet>'."\n" |
---|
| 992 | .'</head><body>' |
---|
| 993 | .'<div id="divAppboxHeader">' |
---|
[41] | 994 | .lang('weekly agenda of events') |
---|
[2] | 995 | .'</div><div id="divAppbox" align="center" >'; |
---|
| 996 | |
---|
| 997 | if(!$account_name){ |
---|
[41] | 998 | echo '<font color="GREEN" size="+1">'.lang('it types login of the user to have access public agenda').'</font></center></div>'; |
---|
[2] | 999 | return True; |
---|
| 1000 | } |
---|
| 1001 | |
---|
| 1002 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
| 1003 | $accountId = $accounts->name2id($account_name); |
---|
| 1004 | |
---|
| 1005 | if(!$accountId){ |
---|
[41] | 1006 | echo '<font color="RED" size="+1">'.lang('this user does not exist').'</font></center></div>'; |
---|
[2] | 1007 | return True; |
---|
| 1008 | } |
---|
| 1009 | |
---|
| 1010 | $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
| 1011 | $account_prefs = $prefs->read(); |
---|
| 1012 | |
---|
| 1013 | $publicView = $account_prefs['calendar']['public_view']; |
---|
| 1014 | |
---|
| 1015 | if($publicView){ |
---|
| 1016 | $this -> user = $account_name; |
---|
| 1017 | $this-> selectFilter(); |
---|
| 1018 | echo $this->printer_publicView($this->get_publicView($accountId)); |
---|
| 1019 | |
---|
| 1020 | } |
---|
| 1021 | else { |
---|
[41] | 1022 | echo '<font color="RED" size="+1">'.lang('it types login of the user to have access public agenda').'</font></center></div>'; |
---|
[2] | 1023 | } |
---|
| 1024 | |
---|
| 1025 | return True; |
---|
| 1026 | } |
---|
| 1027 | |
---|
| 1028 | function get_publicView($accountId) |
---|
| 1029 | { |
---|
| 1030 | // allow users to view public calendars; |
---|
| 1031 | $this -> publicView = True; |
---|
| 1032 | $this->bo->read_holidays(); |
---|
| 1033 | |
---|
| 1034 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
| 1035 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
| 1036 | |
---|
| 1037 | $var = Array( |
---|
| 1038 | 'week_display' => $this->display_weekly( |
---|
| 1039 | Array( |
---|
| 1040 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 1041 | 'showyear' => true, False |
---|
| 1042 | ),$accountId |
---|
| 1043 | ), |
---|
| 1044 | 'print' => $print |
---|
| 1045 | ); |
---|
| 1046 | |
---|
| 1047 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 1048 | $p->set_file( |
---|
| 1049 | Array( |
---|
| 1050 | 'week_t' => 'publicView.tpl' |
---|
| 1051 | ) |
---|
| 1052 | ); |
---|
| 1053 | $p->set_var($var); |
---|
| 1054 | return $p->fp('out','week_t'); |
---|
| 1055 | |
---|
| 1056 | } |
---|
| 1057 | |
---|
| 1058 | function printer_publicView($body) |
---|
| 1059 | { |
---|
| 1060 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1061 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1062 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
| 1063 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
| 1064 | |
---|
| 1065 | $new_body .= $this->bo->debug_string.$body; |
---|
| 1066 | return $new_body; |
---|
| 1067 | } |
---|
| 1068 | |
---|
| 1069 | |
---|
| 1070 | } |
---|
| 1071 | ?> |
---|