[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 uicalendar |
---|
| 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 | var $debug = False; |
---|
[57] | 29 | //var $debug = True; |
---|
[2] | 30 | |
---|
| 31 | var $cat_id; |
---|
| 32 | var $theme; |
---|
| 33 | var $link_tpl; |
---|
| 34 | |
---|
| 35 | // planner related variables |
---|
| 36 | var $planner_header; |
---|
| 37 | var $planner_rows; |
---|
| 38 | |
---|
| 39 | var $planner_group_members; |
---|
| 40 | |
---|
| 41 | var $planner_firstday; |
---|
| 42 | var $planner_lastday; |
---|
| 43 | var $planner_days; |
---|
| 44 | |
---|
| 45 | var $planner_end_month; |
---|
| 46 | var $planner_end_year; |
---|
| 47 | var $planner_days_in_end_month; |
---|
| 48 | |
---|
| 49 | var $planner_intervals = array( // conversation hour and interval depending on intervals_per_day |
---|
| 50 | // 1 1 1 1 1 1 1 1 1 1 2 2 2 2 |
---|
| 51 | // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 |
---|
| 52 | '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 |
---|
| 53 | '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 |
---|
| 54 | '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 |
---|
| 55 | '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 |
---|
| 56 | ); |
---|
| 57 | |
---|
| 58 | var $public_functions = array( |
---|
| 59 | 'mini_calendar' => True, |
---|
| 60 | 'index' => True, |
---|
| 61 | 'month' => True, |
---|
| 62 | 'get_month' => True, |
---|
| 63 | 'week' => True, |
---|
| 64 | 'get_week' => True, |
---|
| 65 | 'year' => True, |
---|
| 66 | 'view' => True, |
---|
| 67 | 'edit' => True, |
---|
| 68 | 'export' => True, |
---|
[57] | 69 | 'export_all' => True, |
---|
[2] | 70 | 'reinstate_list' => True, |
---|
| 71 | 'reinstate' => True, |
---|
| 72 | 'add' => True, |
---|
| 73 | 'delete' => True, |
---|
| 74 | 'preferences' => True, |
---|
| 75 | 'day' => True, |
---|
| 76 | 'edit_status' => True, |
---|
| 77 | 'set_action' => True, |
---|
| 78 | 'planner' => True, |
---|
| 79 | 'modify_ext_partlist' => True, |
---|
| 80 | 'matrixselect' => True, |
---|
| 81 | 'viewmatrix' => True, |
---|
| 82 | 'search' => True, |
---|
| 83 | 'header' => True, |
---|
| 84 | 'footer' => True, |
---|
| 85 | 'css' => True, |
---|
| 86 | 'accounts_popup' => True |
---|
| 87 | ); |
---|
| 88 | |
---|
| 89 | function uicalendar() |
---|
| 90 | { |
---|
| 91 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 92 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
| 93 | |
---|
| 94 | $this->theme = $GLOBALS['phpgw_info']['theme']; |
---|
| 95 | |
---|
| 96 | $this->bo = CreateObject('calendar.bocalendar',1); |
---|
| 97 | $this->cat = &$this->bo->cat; |
---|
| 98 | |
---|
| 99 | print_debug('BO Owner',$this->bo->owner); |
---|
| 100 | |
---|
| 101 | $this->template = $GLOBALS['phpgw']->template; |
---|
| 102 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); |
---|
| 103 | |
---|
| 104 | $this->holiday_color = (substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06']; |
---|
| 105 | |
---|
| 106 | $this->cat_id = $this->bo->cat_id; |
---|
| 107 | |
---|
| 108 | $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 109 | $this->link_tpl->set_unknowns('remove'); |
---|
| 110 | $this->link_tpl->set_file( |
---|
| 111 | Array( |
---|
| 112 | 'link_picture' => 'link_pict.tpl' |
---|
| 113 | ) |
---|
| 114 | ); |
---|
| 115 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
| 116 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
| 117 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
| 118 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
| 119 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
[360] | 120 | |
---|
| 121 | /*************** EVENTO **************************/ |
---|
| 122 | /* Este bloco de codigo foi adicionado pois os eventos de agendamento (exibicao do mes) para impressao serao tratados em outro template |
---|
| 123 | (event_link.tpl) */ |
---|
[2] | 124 | |
---|
[360] | 125 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 126 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 127 | $this->event_tpl->set_unknowns('remove'); |
---|
| 128 | $this->event_tpl->set_file( |
---|
| 129 | Array( |
---|
| 130 | 'link_event' => 'event_link.tpl' |
---|
| 131 | ) |
---|
| 132 | ); |
---|
| 133 | $this->event_tpl->set_block('link_event','link_event_pict','link_event_pict'); |
---|
| 134 | $this->event_tpl->set_block('link_event','event_pict','event_pict'); |
---|
| 135 | $this->event_tpl->set_block('link_event','link_event_open','link_event_open'); |
---|
| 136 | $this->event_tpl->set_block('link_event','link_event_close','link_event_close'); |
---|
| 137 | $this->event_tpl->set_block('link_event','link_event_text','link_event_text'); |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | /*************************************************/ |
---|
| 141 | |
---|
[2] | 142 | if($this->bo->use_session) |
---|
| 143 | { |
---|
| 144 | // save return-fkt for add, view, ... |
---|
| 145 | list(,,$fkt) = explode('.',$_GET['menuaction']); |
---|
| 146 | if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner') |
---|
| 147 | { |
---|
| 148 | $this->bo->return_to = $_GET['menuaction']. |
---|
| 149 | sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day); |
---|
| 150 | } |
---|
| 151 | $this->bo->save_sessiondata(); |
---|
| 152 | } |
---|
| 153 | $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; |
---|
| 154 | |
---|
| 155 | print_debug('UI',$this->_debug_sqsof()); |
---|
| 156 | |
---|
| 157 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
| 158 | { |
---|
| 159 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
| 160 | } |
---|
| 161 | $this->html = &$GLOBALS['phpgw']->html; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | /* Public functions */ |
---|
| 165 | |
---|
| 166 | function mini_calendar($params) |
---|
| 167 | { |
---|
| 168 | static $mini_cal_tpl; |
---|
| 169 | if(!is_array($params)) |
---|
| 170 | { |
---|
| 171 | return; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | if($params['month'] == 0) |
---|
| 175 | { |
---|
| 176 | $params['month'] = 12; |
---|
| 177 | $params['year'] = $params['year'] - 1; |
---|
| 178 | } |
---|
| 179 | elseif($params['month'] == 13) |
---|
| 180 | { |
---|
| 181 | $params['month'] = 1; |
---|
| 182 | $params['year'] = $params['year'] + 1; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | $this->bo->store_to_cache( |
---|
| 186 | Array( |
---|
| 187 | 'smonth' => $params['month'], |
---|
| 188 | 'sday' => 1, |
---|
| 189 | 'syear' => $params['year'] |
---|
| 190 | ) |
---|
| 191 | ); |
---|
| 192 | |
---|
| 193 | $params['link'] = (!isset($params['link'])?'':$params['link']); |
---|
| 194 | $params['buttons'] = (!isset($params['buttons'])?'none':$params['buttons']); |
---|
| 195 | $params['outside_month'] = (!isset($params['outside_month'])?True:$params['outside_month']); |
---|
| 196 | |
---|
| 197 | $this->bo->read_holidays($params['year']); |
---|
| 198 | |
---|
| 199 | $date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); |
---|
| 200 | $month_ago = (int)(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); |
---|
| 201 | $month_ahead = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year']))); |
---|
| 202 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year']))); |
---|
| 203 | $monthend = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year']))); |
---|
| 204 | |
---|
| 205 | $weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1); |
---|
| 206 | |
---|
| 207 | print_debug('mini_calendar:monthstart',$monthstart); |
---|
| 208 | print_debug('mini_calendar:weekstarttime',date('Ymd H:i:s',$weekstarttime)); |
---|
| 209 | |
---|
| 210 | if(!is_object($mini_cal_tpl)) |
---|
| 211 | { |
---|
| 212 | $mini_cal_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 213 | $mini_cal_tpl->set_unknowns('remove'); |
---|
| 214 | $mini_cal_tpl->set_file( |
---|
| 215 | Array( |
---|
| 216 | 'mini_calendar' => 'mini_cal.tpl' |
---|
| 217 | ) |
---|
| 218 | ); |
---|
| 219 | $mini_cal_tpl->set_block('mini_calendar','mini_cal','mini_cal'); |
---|
| 220 | $mini_cal_tpl->set_block('mini_calendar','mini_week','mini_week'); |
---|
| 221 | $mini_cal_tpl->set_block('mini_calendar','mini_day','mini_day'); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | if($this->bo->printer_friendly == False) |
---|
| 226 | { |
---|
| 227 | //NDEE $month = '<a href="' . $this->page('month','&month='.$GLOBALS['phpgw']->common->show_date($date['raw'],'m').'&year='.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y')). '" class="_minicalendar">' . lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>'; |
---|
| 228 | $month = '<a href="' . $this->page('month','&month='.$GLOBALS['phpgw']->common->show_date($date['raw'],'m').'&year='.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y')). '">' . lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>'; |
---|
| 229 | } |
---|
| 230 | else |
---|
| 231 | { |
---|
| 232 | $month = lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y'); |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | $var = Array( |
---|
| 236 | 'cal_img_root' => $GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'), |
---|
| 237 | 'bgcolor' => $this->theme['bg_color'], |
---|
| 238 | 'bgcolor1' => $this->theme['bg_color'], |
---|
| 239 | 'month' => $month, |
---|
| 240 | 'bgcolor2' => $this->theme['cal_dayview'], |
---|
| 241 | 'holiday_color' => $this->holiday_color |
---|
| 242 | ); |
---|
| 243 | |
---|
| 244 | $mini_cal_tpl->set_var($var); |
---|
| 245 | |
---|
| 246 | switch(strtolower($params['buttons'])) |
---|
| 247 | { |
---|
| 248 | case 'right': |
---|
| 249 | $var = Array( |
---|
| 250 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
| 251 | ); |
---|
| 252 | break; |
---|
| 253 | case 'left': |
---|
| 254 | $var = Array( |
---|
| 255 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>' |
---|
| 256 | ); |
---|
| 257 | break; |
---|
| 258 | case 'both': |
---|
| 259 | $var = Array( |
---|
| 260 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>', |
---|
| 261 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
| 262 | ); |
---|
| 263 | break; |
---|
| 264 | case 'none': |
---|
| 265 | default: |
---|
| 266 | $var = Array( |
---|
| 267 | 'prevmonth' => '', |
---|
| 268 | 'nextmonth' => '' |
---|
| 269 | ); |
---|
| 270 | break; |
---|
| 271 | } |
---|
| 272 | $mini_cal_tpl->set_var($var); |
---|
| 273 | |
---|
| 274 | if(!$mini_cal_tpl->get_var('daynames')) |
---|
| 275 | { |
---|
| 276 | for($i=0;$i<7;$i++) |
---|
| 277 | { |
---|
| 278 | $var = Array( |
---|
| 279 | 'dayname' => '<b>' . lang($GLOBALS['phpgw']->datetime->days_short[$i]) . '</b>', |
---|
| 280 | 'day_image' => '' |
---|
| 281 | ); |
---|
| 282 | $this->output_template_array($mini_cal_tpl,'daynames','mini_day',$var); |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 286 | unset($date); |
---|
| 287 | for($i=$weekstarttime + $GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 * 3600 * 7)) |
---|
| 288 | { |
---|
| 289 | unset($var); |
---|
| 290 | $daily = $this->set_week_array($i - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 291 | foreach($daily as $date => $day_params) |
---|
| 292 | { |
---|
| 293 | print_debug('Mini-Cal Date',$date); |
---|
| 294 | $year = (int)(substr($date,0,4)); |
---|
| 295 | $month = (int)(substr($date,4,2)); |
---|
| 296 | $day = (int)(substr($date,6,2)); |
---|
| 297 | $str = ''; |
---|
| 298 | if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True) |
---|
| 299 | { |
---|
| 300 | if(!$this->bo->printer_friendly && $params['link']) |
---|
| 301 | { |
---|
| 302 | //NDEE: class def what for? |
---|
| 303 | $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'">'.$day.'</a>'; |
---|
| 304 | } |
---|
| 305 | else |
---|
| 306 | { |
---|
| 307 | |
---|
| 308 | //NDEE: printer-friendly (mini-calendar) |
---|
| 309 | $str = $day; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | } |
---|
| 313 | else |
---|
| 314 | { |
---|
| 315 | $day_params['day_image'] = ''; |
---|
| 316 | } |
---|
| 317 | $var[] = Array( |
---|
| 318 | 'day_image' => $day_params['day_image'], |
---|
| 319 | 'dayname' => $str |
---|
| 320 | ); |
---|
| 321 | } |
---|
| 322 | for($l=0;$l<count($var);$l++) |
---|
| 323 | { |
---|
| 324 | $this->output_template_array($mini_cal_tpl,'monthweek_day','mini_day',$var[$l]); |
---|
| 325 | } |
---|
| 326 | $mini_cal_tpl->parse('display_monthweek','mini_week',True); |
---|
| 327 | $mini_cal_tpl->set_var('dayname',''); |
---|
| 328 | $mini_cal_tpl->set_var('monthweek_day',''); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | $return_value = $mini_cal_tpl->fp('out','mini_cal'); |
---|
| 332 | $mini_cal_tpl->set_var('display_monthweek',''); |
---|
| 333 | // $mini_cal_tpl->set_var('daynames',''); |
---|
| 334 | // unset($p); |
---|
| 335 | return $return_value; |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | function index($params='') |
---|
| 339 | { |
---|
| 340 | if (!$params) |
---|
| 341 | { |
---|
| 342 | foreach(array('date','year','month','day') as $field) |
---|
| 343 | { |
---|
| 344 | if (isset($_GET[$field])) |
---|
| 345 | { |
---|
| 346 | $params[$field] = $_GET[$field]; |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | $GLOBALS['phpgw']->redirect($this->page('',$params)); |
---|
[15] | 351 | |
---|
[2] | 352 | } |
---|
| 353 | |
---|
| 354 | |
---|
| 355 | |
---|
| 356 | // NDEE: printer-friendly |
---|
| 357 | |
---|
| 358 | function printer_friendly($body,$app_header='') |
---|
[663] | 359 | { |
---|
[602] | 360 | $_SESSION['calendar']['categories'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); |
---|
| 361 | if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) |
---|
| 362 | $_SESSION['calendar']['cals'] = $this->bo->list_cals(); |
---|
| 363 | |
---|
[703] | 364 | if($this->bo->printer_friendly || $_GET['plain'] == 'True') |
---|
[2] | 365 | { |
---|
| 366 | $new_body = '<html>'."\n" |
---|
| 367 | .'<head>'."\n" |
---|
[933] | 368 | .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/app.css" type=text/css rel=StyleSheet>'."\n" |
---|
| 369 | .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/app_print.css" type=text/css rel=StyleSheet media="print">'."\n" |
---|
[2] | 370 | .'</head> |
---|
| 371 | <table id="calendar_print_main" class="calendar_print_main"> |
---|
| 372 | <tr> |
---|
| 373 | <td id="calendar_print_content" class="calendar_print_content">'.$body.'</td> |
---|
| 374 | </tr> |
---|
| 375 | <tr> |
---|
[924] | 376 | <td> |
---|
| 377 | <div> |
---|
| 378 | <input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta página"> |
---|
| 379 | </div> |
---|
| 380 | </td> |
---|
| 381 | </tr> |
---|
[2] | 382 | </table></body>'."\n" |
---|
| 383 | .'</html>'."\n"; |
---|
| 384 | //$new_body = utf8_decode($new_body); |
---|
| 385 | } |
---|
| 386 | else |
---|
| 387 | { |
---|
| 388 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 389 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 390 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
| 391 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
| 392 | if ($app_header && $this->always_app_header) |
---|
| 393 | { |
---|
| 394 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.$app_header; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
[15] | 398 | $new_body = $this->bo->debug_string.$body; |
---|
[2] | 399 | |
---|
| 400 | } |
---|
| 401 | return $new_body; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | function month() |
---|
| 405 | { |
---|
| 406 | echo $this->printer_friendly($this->get_month(),lang('Monthview')); |
---|
[15] | 407 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 408 | } |
---|
| 409 | |
---|
| 410 | function get_month() |
---|
| 411 | { |
---|
| 412 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 413 | |
---|
| 414 | $next = $this->bo->month + 1; |
---|
| 415 | $prev = $this->bo->month - 1; |
---|
| 416 | $nextyear = $this->bo->year; |
---|
| 417 | $prevyear = $this->bo->year; |
---|
| 418 | if ($this->bo->month == 12) |
---|
| 419 | { |
---|
| 420 | $next = 1; |
---|
| 421 | $nextyear = $nextyear + 1; |
---|
| 422 | } |
---|
| 423 | elseif ($this->bo->month == 1) |
---|
| 424 | { |
---|
| 425 | $prev = 12; |
---|
| 426 | $prevyear = $prevyear - 1; |
---|
| 427 | } |
---|
| 428 | |
---|
[934] | 429 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
[2] | 430 | { |
---|
| 431 | $minical_prev = $this->mini_calendar( |
---|
| 432 | Array( |
---|
| 433 | 'day' => 1, |
---|
| 434 | 'month' => $this->bo->month - 1, |
---|
| 435 | 'year' => $this->bo->year, |
---|
| 436 | 'link' => 'day', |
---|
| 437 | 'outside_month' => False |
---|
| 438 | ) |
---|
| 439 | ); |
---|
| 440 | |
---|
| 441 | $minical_next = $this->mini_calendar( |
---|
| 442 | Array( |
---|
| 443 | 'day' => 1, |
---|
| 444 | 'month' => $this->bo->month + 1, |
---|
| 445 | 'year' => $this->bo->year, |
---|
| 446 | 'link' => 'day', |
---|
| 447 | 'outside_month' => False |
---|
| 448 | ) |
---|
| 449 | ); |
---|
| 450 | } |
---|
| 451 | else |
---|
| 452 | { |
---|
| 453 | $minical_prev = ''; |
---|
| 454 | $minical_next = ''; |
---|
| 455 | } |
---|
| 456 | |
---|
[924] | 457 | if($_POST['year']) { |
---|
| 458 | |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
| 462 | $mes_hoje = (int)substr($hoje,4,2); |
---|
| 463 | $sday = 1; |
---|
| 464 | if($_POST['day']) { |
---|
| 465 | $day_ini = (int)$_POST['day']; |
---|
| 466 | } |
---|
| 467 | elseif($_GET['sday']){ |
---|
| 468 | if($_GET['month'] == $mes_hoje) |
---|
| 469 | { |
---|
| 470 | $day_ini = $this->bo->day; |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | else |
---|
| 474 | { |
---|
| 475 | $day_ini = (int)$_GET['sday']; |
---|
| 476 | } |
---|
| 477 | } |
---|
| 478 | elseif( ($_POST['dia_ini']) && ($_POST['dia_ini'] == $this->bo->day) ) |
---|
| 479 | { |
---|
| 480 | $day_ini = (int)substr($hoje,6,2); |
---|
| 481 | } |
---|
| 482 | else |
---|
| 483 | { |
---|
| 484 | $day_ini = $this->bo->day; |
---|
| 485 | } |
---|
| 486 | if($_POST['qtd_dias']) |
---|
| 487 | { |
---|
| 488 | $num_dias = (int)$_POST['qtd_dias']; |
---|
| 489 | } |
---|
| 490 | else |
---|
| 491 | { |
---|
| 492 | $num_dias = 0; |
---|
| 493 | } |
---|
| 494 | |
---|
[2] | 495 | if (!$this->bo->printer_friendly) |
---|
| 496 | { |
---|
| 497 | $printer = ''; |
---|
[924] | 498 | $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'"><<</a>'; |
---|
| 499 | $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">>></a>'; |
---|
| 500 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias; |
---|
| 501 | //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; |
---|
[57] | 502 | $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). |
---|
| 503 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
[360] | 504 | lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 505 | //linha abaixo foi adicionada para exibir a pagina do mes em tela |
---|
| 506 | $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
[2] | 507 | } |
---|
| 508 | else |
---|
| 509 | { |
---|
| 510 | $printer = '<body bgcolor="'.$phpgw_info['theme']['bg_color'].'">'; |
---|
| 511 | $prev_month_link = ''; |
---|
| 512 | $next_month_link = ''; |
---|
| 513 | $print = ''; |
---|
| 514 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
[360] | 515 | //linha abaixo foi adicionada para exibir a pagina do mes para impressao |
---|
| 516 | $large_month = $this->display_month_print($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
[2] | 517 | } |
---|
| 518 | |
---|
| 519 | $this->bo->read_holidays(); |
---|
| 520 | |
---|
| 521 | $var = Array( |
---|
| 522 | 'printer_friendly' => $printer, |
---|
| 523 | 'bg_text' => $this->theme['bg_text'], |
---|
| 524 | 'small_calendar_prev' => $minical_prev, |
---|
| 525 | 'prev_month_link' => $prev_month_link, |
---|
| 526 | 'month_identifier' => lang(strftime("%B",$m)).' '.$this->bo->year, |
---|
| 527 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 528 | 'next_month_link' => $next_month_link, |
---|
| 529 | 'small_calendar_next' => $minical_next, |
---|
[360] | 530 | //'large_month' => $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner), |
---|
| 531 | 'large_month' => $large_month, |
---|
[2] | 532 | 'print' => $print |
---|
| 533 | ); |
---|
| 534 | |
---|
| 535 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 536 | $p->set_unknowns('remove'); |
---|
[360] | 537 | // Alteracao que desvincula o template para tela do template de impressao do mes (month_print teve que ser criado); |
---|
| 538 | if($print != '') |
---|
| 539 | { |
---|
| 540 | $p->set_file( |
---|
| 541 | Array( |
---|
| 542 | 'index_t' => 'index.tpl' |
---|
| 543 | ) |
---|
| 544 | ); |
---|
| 545 | }else { |
---|
| 546 | $p->set_file( |
---|
| 547 | Array( |
---|
| 548 | 'index_t' => 'month_print.tpl' |
---|
| 549 | ) |
---|
| 550 | ); |
---|
| 551 | } |
---|
[2] | 552 | $p->set_var($var); |
---|
| 553 | return $p->fp('out','index_t'); |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | function week() |
---|
| 557 | { |
---|
| 558 | echo $this->printer_friendly($this->get_week(),lang('Weekview')); |
---|
[15] | 559 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 560 | } |
---|
| 561 | |
---|
| 562 | function get_week() |
---|
| 563 | { |
---|
| 564 | $this->bo->read_holidays(); |
---|
| 565 | |
---|
| 566 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
| 567 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
| 568 | |
---|
[934] | 569 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
[2] | 570 | { |
---|
| 571 | $minical_this = $this->mini_calendar( |
---|
| 572 | Array( |
---|
| 573 | 'day' => $this->bo->day, |
---|
| 574 | 'month' => $this->bo->month, |
---|
| 575 | 'year' => $this->bo->year, |
---|
| 576 | 'link' => 'day', |
---|
| 577 | 'butons' => 'none', |
---|
| 578 | 'outside_month' => False |
---|
| 579 | ) |
---|
| 580 | ); |
---|
| 581 | $minical_prev = $this->mini_calendar( |
---|
| 582 | Array( |
---|
| 583 | 'day' => $this->bo->day, |
---|
| 584 | 'month' => $this->bo->month - 1, |
---|
| 585 | 'year' => $this->bo->year, |
---|
| 586 | 'link' => 'day', |
---|
| 587 | 'butons' => 'left', |
---|
| 588 | 'outside_month' => False |
---|
| 589 | ) |
---|
| 590 | ); |
---|
| 591 | $minical_next = $this->mini_calendar( |
---|
| 592 | Array( |
---|
| 593 | 'day' => $this->bo->day, |
---|
| 594 | 'month' => $this->bo->month + 1, |
---|
| 595 | 'year' => $this->bo->year, |
---|
| 596 | 'link' => 'day', |
---|
| 597 | 'butons' => 'right', |
---|
| 598 | 'outside_month' => False |
---|
| 599 | ) |
---|
| 600 | ); |
---|
| 601 | } |
---|
| 602 | else |
---|
| 603 | { |
---|
| 604 | |
---|
| 605 | //NDEE: printer-friendly what? |
---|
| 606 | $minical_this = ''; |
---|
| 607 | $minical_prev = ''; |
---|
| 608 | $minical_next = ''; |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | if (!$this->bo->printer_friendly) |
---|
| 612 | { |
---|
| 613 | $printer = ''; |
---|
| 614 | $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'"><<</a>'; |
---|
| 615 | $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">>></a>'; |
---|
| 616 | $print = '<a href="'.$this->page('week','&friendly=1&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 617 | } |
---|
| 618 | else |
---|
| 619 | { |
---|
| 620 | |
---|
| 621 | //NDEE: printer-friendly (weekly-view) |
---|
| 622 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 623 | $prev_week_link = ''; |
---|
| 624 | $next_week_link = ''; |
---|
| 625 | $print = ''; |
---|
| 626 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 627 | } |
---|
| 628 | |
---|
| 629 | $var = Array( |
---|
| 630 | 'printer_friendly' => $print, |
---|
| 631 | 'bg_text' => $this->theme['bg_text'], |
---|
| 632 | 'small_calendar_prev' => $minical_prev, |
---|
| 633 | 'prev_week_link' => $prev_week_link, |
---|
| 634 | 'small_calendar_this' => $minical_this, |
---|
| 635 | 'week_identifier' => $this->bo->get_week_label(), |
---|
| 636 | 'next_week_link' => $next_week_link, |
---|
| 637 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 638 | 'small_calendar_next' => $minical_next, |
---|
| 639 | 'week_display' => $this->display_weekly( |
---|
| 640 | Array( |
---|
| 641 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 642 | 'showyear' => true, |
---|
| 643 | 'owners' => $this->bo->owner |
---|
| 644 | ) |
---|
| 645 | ), |
---|
| 646 | 'print' => $print |
---|
| 647 | ); |
---|
| 648 | //todo |
---|
| 649 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 650 | $p->set_file( |
---|
| 651 | Array( |
---|
| 652 | 'week_t' => 'week.tpl' |
---|
| 653 | ) |
---|
| 654 | ); |
---|
| 655 | $p->set_var($var); |
---|
[923] | 656 | return $p->fp('out','week_t'); |
---|
| 657 | |
---|
[2] | 658 | } |
---|
| 659 | |
---|
| 660 | function year() |
---|
| 661 | { |
---|
[703] | 662 | if ($_GET['plain'] == "True") |
---|
[2] | 663 | { |
---|
[703] | 664 | |
---|
| 665 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
[2] | 666 | } |
---|
[703] | 667 | else |
---|
| 668 | { |
---|
| 669 | |
---|
| 670 | if($this->bo->printer_friendly) |
---|
| 671 | { |
---|
| 672 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 673 | } |
---|
| 674 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
| 675 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 676 | } |
---|
[2] | 677 | } |
---|
| 678 | |
---|
| 679 | function get_year() |
---|
| 680 | { |
---|
| 681 | if(!$this->bo->printer_friendly) |
---|
| 682 | { |
---|
| 683 | $print = ''; |
---|
| 684 | $left_link = '<a href="'.$this->page('year','&year='.($this->bo->year - 1)).'"><<</a>'; |
---|
| 685 | $right_link = '<a href="'.$this->page('year','&year='.($this->bo->year + 1)).'">>></a>'; |
---|
| 686 | $link = 'day'; |
---|
| 687 | $printer = '<a href="'.$this->page('year','&friendly=1&year='.$this->bo->year).'" target="cal_printer_friendly" onMouseOver="window.status = '."'".lang('Generate printer-friendly version')."'".'">['.lang('Printer Friendly').']</a>'; |
---|
| 688 | } |
---|
| 689 | else |
---|
| 690 | { |
---|
| 691 | //NDEE: printer-friendly (year-view) |
---|
| 692 | $print = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 693 | $left_link = ''; |
---|
| 694 | $right_link = ''; |
---|
| 695 | $link = ''; |
---|
| 696 | $printer = ''; |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | $var = Array( |
---|
| 700 | 'print' => $print, |
---|
| 701 | 'left_link' => $left_link, |
---|
| 702 | 'font' => $this->theme['font'], |
---|
| 703 | 'year_text' => $this->bo->year, |
---|
| 704 | 'right_link'=> $right_link, |
---|
| 705 | 'printer_friendly'=> $printer |
---|
| 706 | ); |
---|
| 707 | |
---|
| 708 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 709 | $p->set_file( |
---|
| 710 | Array( |
---|
| 711 | 'year_t' => 'year.tpl' |
---|
| 712 | ) |
---|
| 713 | ); |
---|
| 714 | $p->set_block('year_t','year','year'); |
---|
| 715 | $p->set_block('year_t','month','month_handle'); |
---|
| 716 | $p->set_block('year_t','month_sep','month_sep_handle'); |
---|
| 717 | $p->set_var($var); |
---|
| 718 | |
---|
| 719 | for($i=1;$i<=12;$i++) |
---|
| 720 | { |
---|
| 721 | if(($i % 3) == 1) |
---|
| 722 | { |
---|
| 723 | $p->parse('row','month_sep',True); |
---|
| 724 | } |
---|
| 725 | $p->set_var('mini_month',$this->mini_calendar( |
---|
| 726 | Array( |
---|
| 727 | 'day' => 1, |
---|
| 728 | 'month' => $i, |
---|
| 729 | 'year' => $this->bo->year, |
---|
| 730 | 'link' => $link, |
---|
| 731 | 'buttons' => 'none', |
---|
| 732 | 'outside_month' => False |
---|
| 733 | ) |
---|
| 734 | ) |
---|
| 735 | ); |
---|
| 736 | $p->parse('row','month',True); |
---|
| 737 | $p->set_var('mini_month',''); |
---|
| 738 | } |
---|
| 739 | return $p->fp('out','year_t'); |
---|
| 740 | } |
---|
| 741 | |
---|
| 742 | function view($vcal_id=0,$cal_date=0) |
---|
| 743 | { |
---|
| 744 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 745 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 746 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('View'); |
---|
[925] | 747 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
[2] | 748 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 749 | |
---|
| 750 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
| 751 | |
---|
| 752 | $date = $cal_date ? $cal_date : 0; |
---|
| 753 | $date = $date ? $date : (int)$_GET['date']; |
---|
| 754 | |
---|
| 755 | // First, make sure they have permission to this entry |
---|
| 756 | if ($cal_id < 1) |
---|
| 757 | { |
---|
| 758 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
| 759 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 760 | } |
---|
| 761 | |
---|
| 762 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id)) |
---|
| 763 | { |
---|
| 764 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
| 765 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | $event = $this->bo->read_entry($cal_id); |
---|
| 769 | |
---|
| 770 | if(!isset($event['id'])) |
---|
| 771 | { |
---|
| 772 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
| 773 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | $this->bo->repeating_events = Array(); |
---|
| 777 | $this->bo->cached_events = Array(); |
---|
| 778 | $this->bo->repeating_events[0] = $event; |
---|
| 779 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 780 | $this->bo->check_repeating_events($datetime); |
---|
| 781 | $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); |
---|
| 782 | if(is_array($this->bo->cached_events[$check_date][0]) && |
---|
| 783 | $this->bo->cached_events[$check_date][0]['id'] == $event['id']) |
---|
| 784 | { |
---|
| 785 | $starttime = $this->bo->maketime($event['start']); |
---|
| 786 | $endtime = $this->bo->maketime($event['end']); |
---|
| 787 | $event['start']['month'] = $this->bo->month; |
---|
| 788 | $event['start']['mday'] = $this->bo->day; |
---|
| 789 | $event['start']['year'] = $this->bo->year; |
---|
| 790 | $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); |
---|
| 791 | $event['end']['month'] = date('m',$temp_end); |
---|
| 792 | $event['end']['mday'] = date('d',$temp_end); |
---|
| 793 | $event['end']['year'] = date('Y',$temp_end); |
---|
| 794 | } |
---|
| 795 | |
---|
| 796 | if(!$this->view_event($event,True)) |
---|
| 797 | { |
---|
| 798 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
| 799 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | $p = $GLOBALS['phpgw']->template; |
---|
| 803 | $p->set_file( |
---|
| 804 | Array( |
---|
| 805 | 'form_button' => 'form_button_script.tpl' |
---|
| 806 | ) |
---|
| 807 | ); |
---|
| 808 | |
---|
| 809 | $button_left = $button_center = $button_right = ''; |
---|
| 810 | |
---|
| 811 | if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
| 812 | { |
---|
| 813 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
| 814 | { |
---|
| 815 | $var = Array( |
---|
| 816 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 817 | 'action_text_button' => lang('Edit Single'), |
---|
| 818 | 'action_confirm_button' => '', |
---|
| 819 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 820 | 'edit_type' => 'single', |
---|
| 821 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
| 822 | )) |
---|
| 823 | ); |
---|
| 824 | $p->set_var($var); |
---|
| 825 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 826 | |
---|
| 827 | $var = Array( |
---|
| 828 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 829 | 'action_text_button' => lang('Edit Series'), |
---|
| 830 | 'action_confirm_button' => '', |
---|
| 831 | 'action_extra_field' => $this->html->input_hidden('edit_type','series') |
---|
| 832 | ); |
---|
| 833 | $p->set_var($var); |
---|
| 834 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 835 | } |
---|
| 836 | else |
---|
| 837 | { |
---|
| 838 | $var = Array( |
---|
| 839 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 840 | 'action_text_button' => lang('Edit'), |
---|
| 841 | 'action_confirm_button' => '', |
---|
| 842 | 'action_extra_field' => '' |
---|
| 843 | ); |
---|
| 844 | $p->set_var($var); |
---|
| 845 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 846 | } |
---|
| 847 | |
---|
| 848 | $var = Array( |
---|
| 849 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
| 850 | 'action_text_button' => lang('Alarm Management'), |
---|
| 851 | 'action_confirm_button' => '', |
---|
| 852 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 853 | 'cal_id' => $cal_id, |
---|
| 854 | 'return_to' => $this->bo->return_to |
---|
| 855 | )) |
---|
| 856 | ); |
---|
| 857 | $p->set_var($var); |
---|
| 858 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 859 | } |
---|
| 860 | |
---|
| 861 | if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) |
---|
| 862 | { |
---|
| 863 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
| 864 | { |
---|
| 865 | $var = Array( |
---|
| 866 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 867 | 'action_text_button' => lang('Delete Single'), |
---|
[204] | 868 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this single occurence?\\nThis will delete this entry for all users.')."')\"", |
---|
[2] | 869 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 870 | 'delete_type' => 'single', |
---|
| 871 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
| 872 | )) |
---|
| 873 | ); |
---|
| 874 | $p->set_var($var); |
---|
| 875 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 876 | |
---|
| 877 | $var = Array( |
---|
| 878 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 879 | 'action_text_button' => lang('Delete Series'), |
---|
[204] | 880 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
[2] | 881 | 'action_extra_field' => $this->html->input_hidden('delete_type','series') |
---|
| 882 | ); |
---|
| 883 | $p->set_var($var); |
---|
| 884 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 885 | |
---|
| 886 | if($event['recur_exception']) |
---|
| 887 | { |
---|
| 888 | $var = Array( |
---|
| 889 | 'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), |
---|
| 890 | 'action_text_button' => lang('Reinstate'), |
---|
| 891 | 'action_confirm_button' => '', |
---|
| 892 | 'action_extra_field' => '' |
---|
| 893 | ); |
---|
| 894 | $p->set_var($var); |
---|
| 895 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 896 | } |
---|
| 897 | } |
---|
| 898 | else |
---|
| 899 | { |
---|
| 900 | $var = Array( |
---|
| 901 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 902 | 'action_text_button' => lang('Delete'), |
---|
[204] | 903 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
[2] | 904 | 'action_extra_field' => '' |
---|
| 905 | ); |
---|
| 906 | $p->set_var($var); |
---|
| 907 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 908 | } |
---|
| 909 | } |
---|
| 910 | else |
---|
| 911 | { |
---|
| 912 | // allow me (who I am logged in as) to set up an alarm |
---|
| 913 | // if I am a participant, but not the owner |
---|
| 914 | reset($event['participants']); |
---|
| 915 | while (list($user,$short_status) = each($event['participants'])) |
---|
| 916 | { |
---|
| 917 | if ($GLOBALS['phpgw_info']['user']['account_id'] == $user) |
---|
| 918 | { |
---|
| 919 | $var = Array( |
---|
| 920 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
| 921 | 'action_text_button' => lang('Alarm Management'), |
---|
| 922 | 'action_confirm_button' => '', |
---|
| 923 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 924 | 'cal_id' => $cal_id, |
---|
| 925 | 'return_to' => $this->bo->return_to |
---|
| 926 | )) |
---|
| 927 | ); |
---|
| 928 | $p->set_var($var); |
---|
| 929 | echo $p->fp('out','form_button'); |
---|
| 930 | } |
---|
| 931 | } |
---|
| 932 | } |
---|
| 933 | |
---|
| 934 | $var = Array( |
---|
| 935 | 'action_url_button' => $this->page('export'), |
---|
| 936 | 'action_text_button' => lang('Export'), |
---|
| 937 | 'action_confirm_button' => '', |
---|
| 938 | 'action_extra_field' => $this->html->input_hidden('cal_id',$cal_id) |
---|
| 939 | ); |
---|
| 940 | $p->set_var($var); |
---|
| 941 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 942 | |
---|
| 943 | if ($this->bo->return_to) |
---|
| 944 | { |
---|
| 945 | $var = Array( |
---|
| 946 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 947 | 'action_text_button' => lang('Done'), |
---|
| 948 | 'action_confirm_button' => '', |
---|
| 949 | 'action_extra_field' => '' |
---|
| 950 | ); |
---|
| 951 | $p->set_var($var); |
---|
| 952 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 953 | } |
---|
| 954 | $p->set_var(array( |
---|
| 955 | 'button_left' => $button_left, |
---|
| 956 | 'button_center' => $button_center, |
---|
| 957 | 'button_right' => $button_right |
---|
| 958 | )); |
---|
| 959 | $p->pfp('phpgw_body','view_event'); |
---|
| 960 | |
---|
| 961 | $GLOBALS['phpgw']->hooks->process(array( |
---|
| 962 | 'location' => 'calendar_view', |
---|
| 963 | 'cal_id' => $cal_id |
---|
| 964 | )); |
---|
| 965 | |
---|
[15] | 966 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 967 | } |
---|
| 968 | |
---|
| 969 | function edit($params='') |
---|
| 970 | { |
---|
| 971 | if($this->debug) |
---|
| 972 | { |
---|
| 973 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
| 974 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
| 975 | } |
---|
| 976 | |
---|
| 977 | if(isset($_GET['readsess'])) |
---|
| 978 | { |
---|
| 979 | $params['readsess'] = $_GET['readsess']; |
---|
| 980 | $params['cd'] = 0; |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | if($this->debug) |
---|
| 984 | { |
---|
| 985 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
| 986 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
| 987 | } |
---|
| 988 | |
---|
| 989 | if($params != '' && @is_array($params) && @isset($params['readsess'])) |
---|
| 990 | { |
---|
| 991 | $can_edit = True; |
---|
| 992 | $this->edit_form( |
---|
| 993 | Array( |
---|
| 994 | 'event' => $this->bo->restore_from_appsession(), |
---|
| 995 | 'cd' => $params['cd'] |
---|
| 996 | ) |
---|
| 997 | ); |
---|
| 998 | } |
---|
| 999 | elseif(isset($_GET['cal_id'])) |
---|
| 1000 | { |
---|
| 1001 | $cal_id = (int)$_GET['cal_id']; |
---|
| 1002 | $event = $this->bo->read_entry($cal_id); |
---|
| 1003 | |
---|
| 1004 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
| 1005 | { |
---|
| 1006 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
| 1007 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1008 | } |
---|
| 1009 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') |
---|
| 1010 | { |
---|
| 1011 | $event['id'] = 0; |
---|
| 1012 | $this->bo->set_recur_date($event,$_POST['date']); |
---|
| 1013 | $event['recur_type'] = MCAL_RECUR_NONE; |
---|
| 1014 | $event['recur_interval'] = 0; |
---|
| 1015 | $event['recur_data'] = 0; |
---|
| 1016 | $event['recur_enddate']['month'] = 0; |
---|
| 1017 | $event['recur_enddate']['mday'] = 0; |
---|
| 1018 | $event['recur_enddate']['year'] = 0; |
---|
| 1019 | $event['recur_exception'] = array(); |
---|
| 1020 | } |
---|
[663] | 1021 | $plain = $_GET['plain']; |
---|
| 1022 | |
---|
[2] | 1023 | $this->edit_form( |
---|
| 1024 | Array( |
---|
| 1025 | 'event' => $event, |
---|
[663] | 1026 | 'cd' => $cd, |
---|
| 1027 | 'plain' => $plain |
---|
[2] | 1028 | ) |
---|
| 1029 | ); |
---|
| 1030 | } |
---|
| 1031 | } |
---|
| 1032 | |
---|
[57] | 1033 | function export_all() |
---|
| 1034 | { |
---|
| 1035 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
| 1036 | srand((double)microtime()*1000000); |
---|
| 1037 | $random_number = rand(100000000,999999999); |
---|
| 1038 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
| 1039 | $filename = $temp_path . $newfilename; |
---|
| 1040 | $attach_fd = fopen($filename,"w+"); |
---|
| 1041 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
| 1042 | foreach($event_ids as $key => $id) |
---|
| 1043 | { |
---|
| 1044 | $event[$key]=$this->bo->read_entry($id); |
---|
| 1045 | } |
---|
| 1046 | include_once('class.bocalendar.inc.php'); |
---|
| 1047 | $cal = new bocalendar; |
---|
| 1048 | $tmpattach=$cal->create_vcard($event); |
---|
| 1049 | fwrite($attach_fd,$tmpattach); |
---|
| 1050 | header ("Content-Type: text/plain"); |
---|
| 1051 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1052 | header('Content-Length: ' . filesize($filename)); |
---|
| 1053 | header("Content-disposition: attachment; filename="."export.vcard"); |
---|
| 1054 | readfile($filename); |
---|
| 1055 | fclose($attach_fd); |
---|
| 1056 | } |
---|
| 1057 | |
---|
[2] | 1058 | function export($vcal_id=0) |
---|
| 1059 | { |
---|
[29] | 1060 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
| 1061 | srand((double)microtime()*1000000); |
---|
| 1062 | $random_number = rand(100000000,999999999); |
---|
| 1063 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
| 1064 | $filename = $temp_path . $newfilename; |
---|
| 1065 | $attach_fd = fopen($filename,"w+"); |
---|
| 1066 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
[57] | 1067 | $event[0] = $this->bo->read_entry($cal_id); |
---|
[29] | 1068 | include_once('class.bocalendar.inc.php'); |
---|
| 1069 | $cal = new bocalendar; |
---|
| 1070 | $tmpattach=$cal->create_vcard($event); |
---|
| 1071 | fwrite($attach_fd,$tmpattach); |
---|
| 1072 | header ("Content-Type: text/plain"); |
---|
| 1073 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1074 | header('Content-Length: ' . filesize($filename)); |
---|
| 1075 | header("Content-disposition: attachment; filename="."export.vcard"); |
---|
| 1076 | readfile($filename); |
---|
| 1077 | fclose($attach_fd); |
---|
[2] | 1078 | } |
---|
| 1079 | |
---|
| 1080 | function reinstate_list($params='') |
---|
| 1081 | { |
---|
| 1082 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1083 | { |
---|
| 1084 | $this->no_edit(); |
---|
| 1085 | } |
---|
| 1086 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1087 | { |
---|
| 1088 | $this->index(); |
---|
| 1089 | } |
---|
| 1090 | |
---|
| 1091 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1092 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1093 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Reinstate'); |
---|
| 1094 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1095 | |
---|
| 1096 | $cal_id = get_var('cal_id',array('GET'),$params['cal_id']); |
---|
| 1097 | |
---|
| 1098 | if ($cal_id < 1) |
---|
| 1099 | { |
---|
| 1100 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
| 1101 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1102 | } |
---|
| 1103 | |
---|
| 1104 | if(!$this->bo->check_perms(PHPGW_ACL_READ)) |
---|
| 1105 | { |
---|
| 1106 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
| 1107 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1108 | } |
---|
| 1109 | |
---|
| 1110 | $event = $this->bo->read_entry($cal_id); |
---|
| 1111 | |
---|
| 1112 | if(!isset($event['id'])) |
---|
| 1113 | { |
---|
| 1114 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
| 1115 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1116 | } |
---|
| 1117 | elseif(!isset($event['recur_exception'])) |
---|
| 1118 | { |
---|
| 1119 | echo '<center>'.lang('Sorry, this event does not have exceptions defined').'.'.'</center>'."\n"; |
---|
| 1120 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1121 | } |
---|
| 1122 | |
---|
| 1123 | if(!$this->view_event($event,True)) |
---|
| 1124 | { |
---|
| 1125 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
| 1126 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1127 | } |
---|
| 1128 | |
---|
| 1129 | $p = &$GLOBALS['phpgw']->template; |
---|
| 1130 | $p->set_file( |
---|
| 1131 | Array( |
---|
| 1132 | 'form_button' => 'form_button_script.tpl' |
---|
| 1133 | ) |
---|
| 1134 | ); |
---|
| 1135 | |
---|
| 1136 | $str = ''; |
---|
| 1137 | |
---|
| 1138 | for($i=0;$i<count($event['recur_exception']);$i++) |
---|
| 1139 | { |
---|
| 1140 | $str .= ' <option value="'.$i.'">'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).'</option>'."\n"; |
---|
| 1141 | } |
---|
| 1142 | $this->output_template_array($p,'row','list',array( |
---|
| 1143 | 'field' => lang('Exceptions'), |
---|
| 1144 | 'data' => '<select name="reinstate_index[]" multiple size="5">'."\n".$str.'</select>' |
---|
| 1145 | )); |
---|
| 1146 | |
---|
| 1147 | $var = Array( |
---|
| 1148 | 'action_url_button' => $this->page('reinstate','&cal_id='.$cal_id), |
---|
| 1149 | 'action_text_button' => lang('Reinstate'), |
---|
| 1150 | 'action_confirm_button' => '', |
---|
| 1151 | 'action_extra_field' => '' |
---|
| 1152 | ); |
---|
| 1153 | $p->set_var($var); |
---|
| 1154 | $button_left = '<td>'.$p->fp('out','form_button').'</td>'; |
---|
| 1155 | |
---|
| 1156 | $var = Array( |
---|
| 1157 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
| 1158 | 'action_text_button' => lang('Cancel'), |
---|
| 1159 | 'action_confirm_button' => '', |
---|
| 1160 | 'action_extra_field' => '' |
---|
| 1161 | ); |
---|
| 1162 | $p->set_var($var); |
---|
| 1163 | $button_left .= '<td>'.$p->fp('out','form_button').'</td>'; |
---|
| 1164 | |
---|
| 1165 | $p->set_var('button_left',$button_left); |
---|
| 1166 | $p->pfp('phpgw_body','view_event'); |
---|
| 1167 | } |
---|
| 1168 | |
---|
| 1169 | function reinstate($params='') |
---|
| 1170 | { |
---|
| 1171 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1172 | { |
---|
| 1173 | $this->no_edit(); |
---|
| 1174 | } |
---|
| 1175 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1176 | { |
---|
| 1177 | $this->index(); |
---|
| 1178 | } |
---|
| 1179 | $cal_id = (isset($params['cal_id']) ? (int)$params['cal_id'] : ''); |
---|
| 1180 | $cal_id = ($cal_id == '' ? (int)$_GET['cal_id'] : $cal_id); |
---|
| 1181 | |
---|
| 1182 | $reinstate_index = (isset($params['reinstate_index']) ? (int)$params['reinstate_index'] : ''); |
---|
| 1183 | $reinstate_index = ($reinstate_index == '' ? (int)$_POST['reinstate_index'] : $reinstate_index); |
---|
| 1184 | if($this->debug) |
---|
| 1185 | { |
---|
| 1186 | echo '<!-- Calling bo->reinstate -->'."\n"; |
---|
| 1187 | } |
---|
| 1188 | $cd = $this->bo->reinstate( |
---|
| 1189 | Array( |
---|
| 1190 | 'cal_id' => $cal_id, |
---|
| 1191 | 'reinstate_index' => $reinstate_index |
---|
| 1192 | ) |
---|
| 1193 | ); |
---|
| 1194 | if($this->debug) |
---|
| 1195 | { |
---|
| 1196 | echo '<!-- Return Value = '.$cd.' -->'."\n"; |
---|
| 1197 | } |
---|
| 1198 | if ($this->bo->return_to) |
---|
| 1199 | { |
---|
| 1200 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1201 | } |
---|
| 1202 | else |
---|
| 1203 | { |
---|
| 1204 | Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); |
---|
| 1205 | } |
---|
| 1206 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1207 | } |
---|
| 1208 | |
---|
| 1209 | function add($cd=0,$readsess=0) |
---|
| 1210 | { |
---|
| 1211 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1212 | { |
---|
| 1213 | $this->index(); |
---|
| 1214 | } |
---|
| 1215 | |
---|
| 1216 | if($readsess) |
---|
| 1217 | { |
---|
| 1218 | $event = $this->bo->restore_from_appsession; |
---|
| 1219 | if(!$event['owner']) |
---|
| 1220 | { |
---|
| 1221 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
| 1222 | } |
---|
| 1223 | $can_edit = True; |
---|
| 1224 | } |
---|
| 1225 | else |
---|
| 1226 | { |
---|
| 1227 | $this->bo->event_init(); |
---|
| 1228 | $this->bo->add_attribute('id',0); |
---|
| 1229 | |
---|
| 1230 | $can_edit = True; |
---|
| 1231 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
| 1232 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); |
---|
| 1233 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
| 1234 | $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; |
---|
| 1235 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
[36] | 1236 | |
---|
| 1237 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
| 1238 | if ($subject != '0') |
---|
| 1239 | { |
---|
| 1240 | $description = (string)(get_var('description',array('GET'),0)); |
---|
| 1241 | $location = (string)(get_var('location',array('GET'),0)); |
---|
| 1242 | } |
---|
| 1243 | else |
---|
| 1244 | unset($subject); |
---|
| 1245 | |
---|
[2] | 1246 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
| 1247 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
[36] | 1248 | $this->bo->set_title($subject); |
---|
| 1249 | $this->bo->set_description($description); |
---|
| 1250 | $this->bo->add_attribute('location',$location); |
---|
[2] | 1251 | $this->bo->set_ex_participants(''); |
---|
| 1252 | $this->bo->add_attribute('uid',''); |
---|
| 1253 | $this->bo->add_attribute('priority',2); |
---|
| 1254 | if(@$this->bo->prefs['calendar']['default_private']) |
---|
| 1255 | { |
---|
| 1256 | $this->bo->set_class(False); |
---|
| 1257 | } |
---|
| 1258 | else |
---|
| 1259 | { |
---|
| 1260 | $this->bo->set_class(True); |
---|
| 1261 | } |
---|
| 1262 | // Add participants |
---|
| 1263 | //$participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); |
---|
| 1264 | //for($_f_part=0; $_f_part<count($participants); $_f_part++) |
---|
| 1265 | //{ |
---|
| 1266 | // $this->bo->add_attribute('participants','A',$participants[$_f_part]); |
---|
| 1267 | //} |
---|
| 1268 | // Add misc |
---|
| 1269 | $this->bo->add_attribute('participants','A',$this->bo->owner); |
---|
| 1270 | $this->bo->set_recur_none(); |
---|
| 1271 | $event = $this->bo->get_cached_event(); |
---|
| 1272 | |
---|
| 1273 | } |
---|
| 1274 | $this->edit_form( |
---|
| 1275 | Array( |
---|
| 1276 | 'event' => $event, |
---|
[663] | 1277 | 'cd' => $cd, |
---|
| 1278 | 'plain' => $_GET['plain'] |
---|
[2] | 1279 | ) |
---|
| 1280 | ); |
---|
[15] | 1281 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 1282 | } |
---|
| 1283 | |
---|
| 1284 | function delete() |
---|
| 1285 | { |
---|
| 1286 | if(!isset($_GET['cal_id'])) |
---|
| 1287 | { |
---|
| 1288 | Header('Location: '.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))); |
---|
| 1289 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1290 | } |
---|
| 1291 | |
---|
| 1292 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); |
---|
| 1293 | if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id = (int)$_GET['cal_id'])) |
---|
| 1294 | { |
---|
| 1295 | if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single') |
---|
| 1296 | { |
---|
| 1297 | $date = $_POST['date']; |
---|
| 1298 | $cd = $this->bo->delete_single( |
---|
| 1299 | Array( |
---|
| 1300 | 'id' => $cal_id, |
---|
| 1301 | 'year' => substr($date,0,4), |
---|
| 1302 | 'month' => substr($date,4,2), |
---|
| 1303 | 'day' => substr($date,6,2) |
---|
| 1304 | ) |
---|
| 1305 | ); |
---|
| 1306 | } |
---|
| 1307 | elseif((isset($_POST['delete_type']) && $_POST['delete_type'] == 'series') || !isset($_POST['delete_type'])) |
---|
| 1308 | { |
---|
| 1309 | $cd = $this->bo->delete_entry($cal_id); |
---|
| 1310 | $this->bo->expunge(); |
---|
| 1311 | } |
---|
| 1312 | } |
---|
| 1313 | else |
---|
| 1314 | { |
---|
| 1315 | $cd = ''; |
---|
| 1316 | } |
---|
| 1317 | if ($this->bo->return_to) |
---|
| 1318 | { |
---|
| 1319 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1320 | } |
---|
| 1321 | else |
---|
| 1322 | { |
---|
| 1323 | Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); |
---|
| 1324 | } |
---|
| 1325 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1326 | } |
---|
| 1327 | |
---|
| 1328 | function day() |
---|
| 1329 | { |
---|
| 1330 | |
---|
| 1331 | $this->bo->read_holidays(); |
---|
| 1332 | |
---|
| 1333 | if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) |
---|
| 1334 | { |
---|
| 1335 | $minical = $this->mini_calendar( |
---|
| 1336 | Array( |
---|
| 1337 | 'day' => $this->bo->day, |
---|
| 1338 | 'month' => $this->bo->month, |
---|
| 1339 | 'year' => $this->bo->year, |
---|
| 1340 | 'link' => 'day' |
---|
| 1341 | ) |
---|
| 1342 | ); |
---|
| 1343 | } |
---|
| 1344 | else |
---|
| 1345 | { |
---|
| 1346 | |
---|
| 1347 | //NDEE: printer-friendly (what?) |
---|
| 1348 | $minical = ''; |
---|
| 1349 | } |
---|
| 1350 | |
---|
| 1351 | if (!$this->bo->printer_friendly) |
---|
| 1352 | { |
---|
| 1353 | $printer = ''; |
---|
| 1354 | $param = '&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day).'&friendly=1'; |
---|
| 1355 | $print = '<a href="'.$this->page('day'.$param)."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 1356 | } |
---|
| 1357 | else |
---|
| 1358 | { |
---|
| 1359 | |
---|
| 1360 | //NDEE: printer-friendly (daily-view) |
---|
| 1361 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 1362 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 1363 | $print = ''; |
---|
| 1364 | } |
---|
| 1365 | |
---|
| 1366 | $now = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); |
---|
| 1367 | $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 1368 | |
---|
| 1369 | $p = $GLOBALS['phpgw']->template; |
---|
| 1370 | $p->set_file( |
---|
| 1371 | Array( |
---|
| 1372 | 'day_t' => 'day.tpl' |
---|
| 1373 | ) |
---|
| 1374 | ); |
---|
| 1375 | $p->set_block('day_t','day','day'); |
---|
| 1376 | $p->set_block('day_t','day_event','day_event'); |
---|
| 1377 | |
---|
| 1378 | $todos = $this->get_todos($todo_label); |
---|
| 1379 | $var = Array( |
---|
| 1380 | 'printer_friendly' => $printer, |
---|
| 1381 | 'bg_text' => $this->theme['bg_text'], |
---|
| 1382 | 'daily_events' => $this->print_day( |
---|
| 1383 | Array( |
---|
| 1384 | 'year' => $this->bo->year, |
---|
| 1385 | 'month' => $this->bo->month, |
---|
| 1386 | 'day' => $this->bo->day |
---|
| 1387 | ) |
---|
| 1388 | ), |
---|
| 1389 | 'small_calendar' => $minical, |
---|
| 1390 | 'date' => $this->bo->long_date($now), |
---|
| 1391 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 1392 | 'print' => $print, |
---|
| 1393 | 'lang_todos' => $todo_label, |
---|
| 1394 | 'todos' => $this->bo->printer_friendly ? $todos : |
---|
| 1395 | |
---|
| 1396 | //NDEE: todo's layout |
---|
| 1397 | "<div style=\"overflow: auto; max-height: 200px\">\n$todos</div>\n" |
---|
| 1398 | ); |
---|
| 1399 | |
---|
| 1400 | $p->set_var($var); |
---|
| 1401 | $p->parse('day_events','day_event'); |
---|
| 1402 | print $this->printer_friendly($p->fp('out','day'),lang('Dayview')); |
---|
[15] | 1403 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 1404 | } |
---|
| 1405 | |
---|
| 1406 | function get_todos(&$todo_label) |
---|
| 1407 | { |
---|
| 1408 | $todos_from_hook = $GLOBALS['phpgw']->hooks->process(array( |
---|
| 1409 | 'location' => 'calendar_include_todos', |
---|
| 1410 | 'year' => $this->bo->year, |
---|
| 1411 | 'month' => $this->bo->month, |
---|
| 1412 | 'day' => $this->bo->day, |
---|
| 1413 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
| 1414 | )); |
---|
| 1415 | |
---|
| 1416 | if(is_array($todo_label)) |
---|
| 1417 | { |
---|
| 1418 | list($label,$showall)=$todo_label; |
---|
| 1419 | } |
---|
| 1420 | else |
---|
| 1421 | { |
---|
| 1422 | $label=$todo_label; |
---|
| 1423 | $showall=true; |
---|
| 1424 | } |
---|
| 1425 | $maxshow = (int)$GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
---|
| 1426 | if($maxshow<=0) |
---|
| 1427 | { |
---|
| 1428 | $maxshow=10; |
---|
| 1429 | } |
---|
| 1430 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
---|
| 1431 | |
---|
| 1432 | $content = $todo_label = ''; |
---|
| 1433 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
---|
| 1434 | { |
---|
| 1435 | $todo_label = !empty($label)?$label:lang("open ToDo's:"); |
---|
| 1436 | |
---|
| 1437 | foreach($todos_from_hook as $todos) |
---|
| 1438 | { |
---|
| 1439 | $i = 0; |
---|
| 1440 | if (is_array($todos) && count($todos)) |
---|
| 1441 | { |
---|
| 1442 | foreach($todos as $todo) |
---|
| 1443 | { |
---|
| 1444 | if(!$showall && ($i++>$maxshow)) |
---|
| 1445 | { |
---|
| 1446 | break; |
---|
| 1447 | } |
---|
| 1448 | $icons = ''; |
---|
| 1449 | foreach($todo['icons'] as $name => $app) |
---|
| 1450 | { |
---|
| 1451 | $icons .= ($icons?' ':'').$GLOBALS['phpgw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"'); |
---|
| 1452 | } |
---|
| 1453 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
---|
| 1454 | |
---|
| 1455 | //NDEE <tr starts here |
---|
| 1456 | $content .= " <tr id=\"debug\" class=\"$class\">\n <td valign=\"top\" width=\"15%\"nowrap>". |
---|
| 1457 | ($this->bo->printer_friendly?$icons:$GLOBALS['phpgw']->html->a_href($icons,$todo['view'])). |
---|
| 1458 | "</td>\n <td>".($this->bo->printer_friendly?$todo['title']: |
---|
| 1459 | $GLOBALS['phpgw']->html->a_href($todo['title'],$todo['view']))."</td>\n </tr>\n"; |
---|
| 1460 | } |
---|
| 1461 | } |
---|
| 1462 | } |
---|
| 1463 | } |
---|
| 1464 | if (!empty($content)) |
---|
| 1465 | { |
---|
| 1466 | return "<table border=\"0\" width=\"100%\">\n$content</table>\n"; |
---|
| 1467 | } |
---|
| 1468 | return False; |
---|
| 1469 | } |
---|
| 1470 | |
---|
| 1471 | function edit_status() |
---|
| 1472 | { |
---|
| 1473 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1474 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1475 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 1476 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 1477 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Change Status'); |
---|
| 1478 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1479 | |
---|
| 1480 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
| 1481 | |
---|
| 1482 | reset($event['participants']); |
---|
| 1483 | |
---|
| 1484 | if(!$event['participants'][$this->bo->owner]) |
---|
| 1485 | { |
---|
| 1486 | echo '<center>'.lang('The user %1 is not participating in this event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)).'</center>'; |
---|
| 1487 | return; |
---|
| 1488 | } |
---|
| 1489 | |
---|
| 1490 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1491 | { |
---|
| 1492 | $this->no_edit(); |
---|
| 1493 | return; |
---|
| 1494 | } |
---|
| 1495 | |
---|
| 1496 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 1497 | echo $this->timematrix( |
---|
| 1498 | Array( |
---|
| 1499 | 'date' => $freetime, |
---|
| 1500 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 1501 | 'endtime' => 0, |
---|
| 1502 | 'participants' => $event['participants'] |
---|
| 1503 | ) |
---|
| 1504 | ).'<br>'; |
---|
| 1505 | |
---|
| 1506 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
| 1507 | $this->view_event($event); |
---|
| 1508 | $GLOBALS['phpgw']->template->pfp('phpgw_body','view_event'); |
---|
| 1509 | |
---|
| 1510 | echo $this->get_response($event['id']); |
---|
| 1511 | } |
---|
| 1512 | |
---|
[212] | 1513 | function confirm_action($duplicated_action) |
---|
[2] | 1514 | { |
---|
| 1515 | if($_GET['response'] == 1) |
---|
| 1516 | { |
---|
[212] | 1517 | if(!$duplicated_action) |
---|
| 1518 | $notify_message = lang('The commitment was accepted successfully!'); |
---|
| 1519 | else |
---|
| 1520 | $notify_message = lang('This commitment has already been accepted!'); |
---|
[2] | 1521 | } |
---|
| 1522 | else |
---|
[212] | 1523 | { |
---|
| 1524 | if(!$duplicated_action) |
---|
| 1525 | $notify_message = lang('The commitment was rejected successfully!'); |
---|
| 1526 | else |
---|
| 1527 | $notify_message = lang('This commitment has already been rejected!'); |
---|
[2] | 1528 | } |
---|
| 1529 | |
---|
| 1530 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 1531 | $body1->set_file(Array('calendar' => 'confirm.tpl')); |
---|
| 1532 | $body1->set_block('calendar','list'); |
---|
| 1533 | $var = Array( 'notify_message' => $notify_message); |
---|
| 1534 | $body1->set_var($var); |
---|
| 1535 | $tmpbody1 = $body1->pfp('out','list'); |
---|
| 1536 | } |
---|
| 1537 | function set_action() |
---|
| 1538 | { |
---|
| 1539 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1540 | { |
---|
| 1541 | $this->no_edit(); |
---|
| 1542 | return; |
---|
| 1543 | } |
---|
| 1544 | |
---|
[212] | 1545 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); |
---|
| 1546 | |
---|
[2] | 1547 | if(isset($_GET['response'])) |
---|
| 1548 | { |
---|
[212] | 1549 | $this->confirm_action($confirm_status); |
---|
[2] | 1550 | $GLOBALS['phpgw']->common->phpgw_exit(False); |
---|
| 1551 | } |
---|
| 1552 | else |
---|
| 1553 | { |
---|
| 1554 | if ($this->bo->return_to) |
---|
| 1555 | { |
---|
| 1556 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1557 | } |
---|
| 1558 | else |
---|
| 1559 | { |
---|
| 1560 | Header('Location: '.$this->page('','')); |
---|
| 1561 | } |
---|
| 1562 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1563 | } |
---|
| 1564 | |
---|
| 1565 | } |
---|
| 1566 | function planner() |
---|
| 1567 | { |
---|
| 1568 | if(floor(phpversion()) < 4) |
---|
| 1569 | { |
---|
| 1570 | return; |
---|
| 1571 | } |
---|
| 1572 | $home = strstr($_SERVER['PHP_SELF'],'home') !== False; |
---|
| 1573 | // generate header and set global/member variables |
---|
| 1574 | // |
---|
| 1575 | $this->planner_prepare($home); |
---|
| 1576 | |
---|
| 1577 | // process events within selected interval |
---|
| 1578 | // |
---|
| 1579 | $this->planner_process_interval(); |
---|
| 1580 | |
---|
| 1581 | // generate the planner view |
---|
| 1582 | // |
---|
| 1583 | if (!$home) |
---|
| 1584 | { |
---|
| 1585 | echo '<p>'.$this->planner_print_rows(); |
---|
| 1586 | } |
---|
| 1587 | else |
---|
| 1588 | { |
---|
| 1589 | return $this->planner_print_rows(); |
---|
| 1590 | } |
---|
| 1591 | } |
---|
| 1592 | |
---|
| 1593 | function set_planner_group_members() |
---|
| 1594 | { |
---|
| 1595 | $type = $GLOBALS['phpgw']->accounts->get_type($this->bo->owner); |
---|
| 1596 | |
---|
| 1597 | if ($type == 'g') // display schedule of all group members |
---|
| 1598 | { |
---|
| 1599 | $members = array(); |
---|
| 1600 | $ids = $GLOBALS['phpgw']->acl->get_ids_for_location($this->bo->owner, 1, 'phpgw_group'); |
---|
| 1601 | while (list(,$id) = each($ids)) |
---|
| 1602 | { |
---|
| 1603 | if ($this->bo->check_perms(PHPGW_ACL_READ,0,$id)) |
---|
| 1604 | { |
---|
| 1605 | $members[$GLOBALS['phpgw']->common->grab_owner_name($id)] = $id; |
---|
| 1606 | } |
---|
| 1607 | } |
---|
| 1608 | ksort($members); |
---|
| 1609 | $this->planner_group_members = $members; |
---|
| 1610 | } |
---|
| 1611 | else |
---|
| 1612 | { |
---|
| 1613 | $this->planner_group_members = array( |
---|
| 1614 | $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) => $this->bo->owner |
---|
| 1615 | ); |
---|
| 1616 | } |
---|
| 1617 | } |
---|
| 1618 | |
---|
| 1619 | /** |
---|
| 1620 | * planner_prepare - prepare the planner view |
---|
| 1621 | * |
---|
| 1622 | * - sets global environment variables |
---|
| 1623 | * - initializes class member variables used in multiple planner related functions |
---|
| 1624 | * - generates header lines for the planner view (month, calendar week, days) |
---|
| 1625 | */ |
---|
| 1626 | function planner_prepare($no_header = False) |
---|
| 1627 | { |
---|
| 1628 | // set some globals |
---|
| 1629 | // |
---|
| 1630 | if (!$no_header) |
---|
| 1631 | { |
---|
| 1632 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1633 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1634 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner'); |
---|
| 1635 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1636 | } |
---|
| 1637 | |
---|
| 1638 | // intervals_per_day can be configured in preferences now :-) |
---|
| 1639 | // |
---|
| 1640 | if (! $this->bo->prefs['calendar']['planner_intervals_per_day']) |
---|
| 1641 | { |
---|
| 1642 | $GLOBALS['phpgw']->preferences->add('calendar','planner_intervals_per_day',3); |
---|
| 1643 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 1644 | $this->bo->prefs['calendar']['planner_intervals_per_day'] = 3; |
---|
| 1645 | } |
---|
| 1646 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 1647 | $this->bo->save_sessiondata(); // need to save $this->bo->save_owner |
---|
| 1648 | |
---|
| 1649 | // set title for table and rows of planner view |
---|
| 1650 | // |
---|
| 1651 | if ($this->bo->sortby == 'category') |
---|
| 1652 | { |
---|
| 1653 | $title = lang('Category'); |
---|
| 1654 | } |
---|
| 1655 | else |
---|
| 1656 | { |
---|
| 1657 | $title = lang('User'); |
---|
| 1658 | |
---|
| 1659 | $this->set_planner_group_members(); |
---|
| 1660 | } |
---|
| 1661 | |
---|
| 1662 | // create/initialize variables directly used for HTML code generation |
---|
| 1663 | // |
---|
| 1664 | $this->planner_header = array(); |
---|
| 1665 | $this->planner_rows = array(); |
---|
| 1666 | |
---|
| 1667 | // generate header lines with days and associated months |
---|
| 1668 | // |
---|
| 1669 | $hdr = &$this->planner_header; |
---|
| 1670 | $hdr[0]['0'] = $title; |
---|
| 1671 | $hdr[0]['.0'] = 'rowspan="3"'; |
---|
| 1672 | |
---|
| 1673 | $this->planner_days = 0; // reset |
---|
| 1674 | |
---|
| 1675 | $m = $this->bo->month; |
---|
| 1676 | $y = $this->bo->year; |
---|
| 1677 | $this->bo->read_holidays($y); |
---|
| 1678 | for ($i=1; $i<=$this->bo->num_months; $i++,$m++) |
---|
| 1679 | { |
---|
| 1680 | if ($m == 13) |
---|
| 1681 | { |
---|
| 1682 | $m = 1; $y++; // "wrap-around" into new year |
---|
| 1683 | $this->bo->read_holidays($y); |
---|
| 1684 | } |
---|
| 1685 | $days = $GLOBALS['phpgw']->datetime->days_in_month($m,$y); |
---|
| 1686 | |
---|
| 1687 | $d = mktime(0,0,0,$m,1,$y); |
---|
| 1688 | $month = lang(date('F', $d)).strftime(' %Y', $d); |
---|
| 1689 | $color = $this->theme[$m % 2 || $this->bo->num_months == 1 ? 'th_bg' : 'row_on']; |
---|
| 1690 | $cols = $days * $intervals_per_day; |
---|
| 1691 | |
---|
| 1692 | $hdr[0]['.'.$i] = 'bgcolor="'.$color.'" colspan="'.$cols.'" align="center"'; |
---|
| 1693 | $prev_month = sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12); |
---|
| 1694 | $next_month = sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1); |
---|
| 1695 | $prev_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month"); |
---|
| 1696 | $next_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$next_month"); |
---|
| 1697 | $hdr[0][$i] = "<b><a href=\"$prev_link\"><<</a>   $month   <a href=\"$next_link\">>></a></b>"; |
---|
| 1698 | |
---|
| 1699 | $add_owner = array(); // if no add-rights on the showed cal use own cal |
---|
| 1700 | if (!$this->bo->save_owner && !$this->bo->check_perms(PHPGW_ACL_ADD) || |
---|
| 1701 | !$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner)) |
---|
| 1702 | { |
---|
| 1703 | $add_owner = array( |
---|
| 1704 | 'owner' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 1705 | ); |
---|
| 1706 | } |
---|
| 1707 | for ($d=1; $d<=$days; $d++) |
---|
| 1708 | { |
---|
| 1709 | $dayname = substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2); |
---|
| 1710 | $index = $d + $this->planner_days; |
---|
| 1711 | |
---|
| 1712 | $hdr[2]['.'.$index] = 'colspan="'.$intervals_per_day.'" align="center"'; |
---|
| 1713 | |
---|
| 1714 | // highlight today, saturday, sunday and holidays |
---|
| 1715 | // |
---|
| 1716 | $color = $this->theme['row_off']; |
---|
| 1717 | $dow = $GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d); |
---|
| 1718 | $date = sprintf("%04d%02d%02d",$y,$m,$d); |
---|
| 1719 | if ($date == date('Ymd')) |
---|
| 1720 | { |
---|
| 1721 | $color = $GLOBALS['phpgw_info']['theme']['cal_today']; |
---|
| 1722 | } |
---|
| 1723 | elseif ($this->bo->cached_holidays[$date]) |
---|
| 1724 | { |
---|
| 1725 | $color = $this->bo->holiday_color; |
---|
| 1726 | $hdr[2]['.'.$index] .= ' title="'.$this->bo->cached_holidays[$date][0]['name'].'"'; |
---|
| 1727 | } |
---|
| 1728 | elseif ($dow == 0 || $dow == 6) |
---|
| 1729 | { |
---|
| 1730 | $color = $this->bo->theme['th_bg']; |
---|
| 1731 | } |
---|
| 1732 | |
---|
| 1733 | $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; |
---|
| 1734 | |
---|
| 1735 | $hdr[2][$index] = '<a href="'.$this->html->link('/index.php', |
---|
| 1736 | array( |
---|
| 1737 | 'menuaction' => 'calendar.uicalendar.add', |
---|
| 1738 | 'date' => $date |
---|
| 1739 | ) + $add_owner |
---|
| 1740 | ).'">'.$dayname.'<br>'.$d.'</a>'; |
---|
| 1741 | } |
---|
| 1742 | $this->planner_days += $days; |
---|
| 1743 | } |
---|
| 1744 | |
---|
| 1745 | // create/initialize member variables describing the time interval to be displayed |
---|
| 1746 | // |
---|
| 1747 | $this->planner_end_month = $m - 1; |
---|
| 1748 | $this->planner_end_year = $y; |
---|
| 1749 | $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); |
---|
| 1750 | $this->planner_firstday = (int)(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); |
---|
| 1751 | $this->planner_lastday = (int)(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); |
---|
| 1752 | |
---|
| 1753 | // generate line with calendar weeks in observed interval |
---|
| 1754 | // |
---|
| 1755 | $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 1756 | $w = date('W', $d); |
---|
| 1757 | if ($w == 'W') // php < 4.1 |
---|
| 1758 | { |
---|
| 1759 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
| 1760 | } |
---|
| 1761 | $offset = (7-date('w', $d)+1)%7; |
---|
| 1762 | $offset = $offset == 0 ? 7 : $offset; |
---|
| 1763 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
| 1764 | |
---|
| 1765 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$intervals_per_day * $offset.'" align="left"'; |
---|
| 1766 | $hdr[1][$w] = ''; |
---|
| 1767 | if ($offset >= 3) |
---|
| 1768 | { |
---|
| 1769 | |
---|
| 1770 | //NDEE: style! (groupplanner) |
---|
| 1771 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
| 1772 | } |
---|
| 1773 | $days_left = $this->planner_days - $offset; |
---|
| 1774 | |
---|
| 1775 | $colspan = 7 * $intervals_per_day; |
---|
| 1776 | while ($days_left > 0) |
---|
| 1777 | { |
---|
| 1778 | $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; |
---|
| 1779 | $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each |
---|
| 1780 | $w = date('W', $d); |
---|
| 1781 | if ($w == 'W') // php < 4.1 |
---|
| 1782 | { |
---|
| 1783 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
| 1784 | } |
---|
| 1785 | $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? |
---|
| 1786 | |
---|
| 1787 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
| 1788 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$colspan.'" align="left"'; |
---|
| 1789 | $hdr[1][$w] = ''; |
---|
| 1790 | if ($days_left >= 3) |
---|
| 1791 | { |
---|
| 1792 | |
---|
| 1793 | //NDEE: style! (groupplanner) |
---|
| 1794 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
| 1795 | } |
---|
| 1796 | |
---|
| 1797 | $days_left -= 7; |
---|
| 1798 | } |
---|
| 1799 | return $hdr; |
---|
| 1800 | } |
---|
| 1801 | |
---|
| 1802 | /** |
---|
| 1803 | * planner_update_row - update a row of the planner view |
---|
| 1804 | * |
---|
| 1805 | * parameters are: |
---|
| 1806 | * - index (e.g. user id, category id, ...) of the row |
---|
| 1807 | * - name/title of the row (e.g. user name, category name) |
---|
| 1808 | * - the event to be integrated |
---|
| 1809 | * - list of categories associated with the event |
---|
| 1810 | * - first and last cell of the row |
---|
| 1811 | */ |
---|
| 1812 | function planner_update_row($index,$name,$event,$cat,$start_cell,$end_cell) |
---|
| 1813 | { |
---|
| 1814 | $rows = &$this->planner_rows; |
---|
| 1815 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 1816 | $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 1817 | |
---|
| 1818 | $view = $this->html->link('/index.php', |
---|
| 1819 | array( |
---|
| 1820 | 'menuaction' => 'calendar.uicalendar.view', |
---|
| 1821 | 'cal_id' => $event['id'], |
---|
| 1822 | 'date' => date('Ymd',$this->bo->maketime($event['start'])) |
---|
| 1823 | ) |
---|
| 1824 | ); |
---|
| 1825 | |
---|
| 1826 | // check how many lines are needed for this "row" (currently: user or category) |
---|
| 1827 | $i = 0; |
---|
| 1828 | do { |
---|
| 1829 | ++$i; |
---|
| 1830 | |
---|
| 1831 | $k = $index.'_'.$i; |
---|
| 1832 | $ka = '.nr_'.$k; |
---|
| 1833 | |
---|
| 1834 | if (!isset($rows[$k])) |
---|
| 1835 | { |
---|
| 1836 | if ($i > 1) // further line - no name |
---|
| 1837 | { |
---|
| 1838 | $rows[$k] = array(); |
---|
| 1839 | $rows[$index.'_1']['._name'] = 'rowspan="'.$i.'"'; |
---|
| 1840 | } |
---|
| 1841 | else |
---|
| 1842 | { |
---|
| 1843 | $rows[$k]['_name'] = $name; |
---|
| 1844 | } |
---|
| 1845 | $rows[$ka] = 0; |
---|
| 1846 | } |
---|
| 1847 | $rows[$index.'_1']['._name'] .= ' nowrap'; // title must be one row |
---|
| 1848 | |
---|
| 1849 | $row = &$rows[$k]; |
---|
| 1850 | $akt_cell = &$rows[$ka]; |
---|
| 1851 | } while ($akt_cell > $start_cell); |
---|
| 1852 | |
---|
| 1853 | $id = $event['id'].'-'.date('Ymd',$this->bo->maketime($event['start'])); |
---|
| 1854 | if ($akt_cell < $start_cell) |
---|
| 1855 | { |
---|
| 1856 | $row[$id.'_1'] = ' '; |
---|
| 1857 | $row['.'.$id.'_1'] = 'colspan="'.($start_cell-$akt_cell).'"'; |
---|
| 1858 | } |
---|
| 1859 | $opt = &$row['.'.$id.'_2']; |
---|
| 1860 | $cel = &$row[$id.'_2']; |
---|
| 1861 | |
---|
| 1862 | // if possible, display information about event within cells representing it |
---|
| 1863 | // |
---|
| 1864 | if ($start_cell < $end_cell) |
---|
| 1865 | { |
---|
| 1866 | $colspan = $end_cell - $start_cell; |
---|
| 1867 | $opt .= "colspan=".(1 + $colspan); |
---|
| 1868 | |
---|
| 1869 | if (!$is_private) |
---|
| 1870 | { |
---|
| 1871 | $max_chars = (int)(3*$colspan/$intervals_per_day-2); |
---|
| 1872 | |
---|
| 1873 | $min_chars = 3; // minimum for max_chars to display -> this should be configurable |
---|
| 1874 | if ($max_chars >= $min_chars) |
---|
| 1875 | { |
---|
| 1876 | $len_title = strlen($event['title']); |
---|
| 1877 | |
---|
| 1878 | if ($len_title <= $max_chars) |
---|
| 1879 | { |
---|
| 1880 | $title = $event['title']; |
---|
| 1881 | $max_chars -= $len_title + 3; // 3 chars for separator: " - " |
---|
| 1882 | $len_descr = strlen($event['description']); |
---|
| 1883 | |
---|
| 1884 | if ($len_descr > 0 && $len_descr <= $max_chars) |
---|
| 1885 | { |
---|
| 1886 | $event['print_description'] = 'yes'; |
---|
| 1887 | } |
---|
| 1888 | } |
---|
| 1889 | else |
---|
| 1890 | { |
---|
| 1891 | $has_amp = strpos($event['title'],'&'); |
---|
| 1892 | |
---|
| 1893 | //NDEE: event title gets cut here |
---|
| 1894 | $title = substr($event['title'], 0 , $max_chars-1+($has_amp!==False&&$has_amp<$max_chars?4:0)).'...'; |
---|
| 1895 | } |
---|
| 1896 | $event['print_title'] = 'yes'; |
---|
| 1897 | } |
---|
| 1898 | } |
---|
| 1899 | } |
---|
| 1900 | |
---|
| 1901 | if ($bgcolor=$cat['color']) |
---|
| 1902 | { |
---|
| 1903 | $opt .= ' bgcolor="'.$bgcolor.'"'; |
---|
| 1904 | } |
---|
| 1905 | if (!$is_private) |
---|
| 1906 | { |
---|
| 1907 | $opt .= ' title="'.lang('Title').": ".$event['title']; |
---|
| 1908 | if ($event['description']) |
---|
| 1909 | { |
---|
| 1910 | $opt .= "\n".lang('Description').": ".$event['description']; |
---|
| 1911 | } |
---|
| 1912 | } |
---|
| 1913 | else |
---|
| 1914 | { |
---|
| 1915 | $opt .= ' title="'.lang('You do not have permission to read this record!'); |
---|
| 1916 | } |
---|
| 1917 | |
---|
| 1918 | $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 1919 | $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 1920 | $opt .= "\n".lang('Start Date/Time').": ".$start."\n".lang('End Date/Time').": ".$end; |
---|
| 1921 | |
---|
| 1922 | if ($event['location'] && !$is_private) |
---|
| 1923 | { |
---|
| 1924 | $opt .= " \n".lang('Location').": ".$event['location']; |
---|
| 1925 | } |
---|
| 1926 | |
---|
| 1927 | if (!$is_private) |
---|
| 1928 | { |
---|
| 1929 | $opt .= '" onClick="location=\''.$view.'\'"'; |
---|
| 1930 | $cel = '<a href="'.$view.'">'; |
---|
| 1931 | } |
---|
| 1932 | else |
---|
| 1933 | { |
---|
| 1934 | $opt .= '"'; |
---|
| 1935 | $cel = ''; |
---|
| 1936 | } |
---|
| 1937 | $opt .= ' class="planner-cell"'; |
---|
| 1938 | |
---|
| 1939 | if ($event['priority'] == 3) |
---|
| 1940 | { |
---|
| 1941 | $cel .= $this->html->image('calendar','mini-calendar-bar.gif','','border="0"'); |
---|
| 1942 | } |
---|
| 1943 | if ($event['recur_type']) |
---|
| 1944 | { |
---|
| 1945 | $cel .= $this->html->image('calendar','recur.gif','','border="0"'); |
---|
| 1946 | } |
---|
| 1947 | $cel .= $this->html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); |
---|
| 1948 | $cel .= '</a>'; |
---|
| 1949 | |
---|
| 1950 | if (isset($event['print_title']) && $event['print_title'] == 'yes') |
---|
| 1951 | { |
---|
| 1952 | |
---|
| 1953 | //NDEE: style! where? |
---|
| 1954 | $cel .= '<font size="-2"> '.$title.' </font>'; |
---|
| 1955 | } |
---|
| 1956 | if (isset($event['print_description']) && $event['print_description'] == 'yes') |
---|
| 1957 | { |
---|
| 1958 | |
---|
| 1959 | //NDEE: style! where ? |
---|
| 1960 | $cel .= '<font size="-2"> - '.$event['description'].' </font>'; |
---|
| 1961 | } |
---|
| 1962 | |
---|
| 1963 | $akt_cell = $end_cell + 1; |
---|
| 1964 | |
---|
| 1965 | return $rows; |
---|
| 1966 | } |
---|
| 1967 | |
---|
| 1968 | function planner_process_event($event) |
---|
| 1969 | { |
---|
| 1970 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 1971 | $interval = $this->planner_intervals[$intervals_per_day]; |
---|
| 1972 | $last_cell = $intervals_per_day * $this->planner_days - 1; |
---|
| 1973 | |
---|
| 1974 | $rows = &$this->planner_rows; |
---|
| 1975 | |
---|
| 1976 | // caluculate start and end of event |
---|
| 1977 | // |
---|
| 1978 | $event_start = (int)(date('Ymd',mktime( |
---|
| 1979 | 0,0,0, |
---|
| 1980 | $event['start']['month'], |
---|
| 1981 | $event['start']['mday'], |
---|
| 1982 | $event['start']['year'] |
---|
| 1983 | ))); |
---|
| 1984 | $event_end = (int)(date('Ymd',mktime( |
---|
| 1985 | 0,0,0, |
---|
| 1986 | $event['end']['month'], |
---|
| 1987 | $event['end']['mday'], |
---|
| 1988 | $event['end']['year'] |
---|
| 1989 | ))); |
---|
| 1990 | |
---|
| 1991 | // calculate first cell of event within observed interval |
---|
| 1992 | // |
---|
| 1993 | if ($event_start >= $this->planner_firstday) |
---|
| 1994 | { |
---|
| 1995 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['start']['month'],$event['start']['mday'],$event['start']['year']); |
---|
| 1996 | |
---|
| 1997 | $start_cell = $intervals_per_day * $days_between + $interval[$event['start']['hour']]; |
---|
| 1998 | } |
---|
| 1999 | else |
---|
| 2000 | { |
---|
| 2001 | $start_cell = 0; |
---|
| 2002 | } |
---|
| 2003 | |
---|
| 2004 | // calculate last cell of event within observed interval |
---|
| 2005 | // |
---|
| 2006 | if ($event_end <= $this->planner_lastday) |
---|
| 2007 | { |
---|
| 2008 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']); |
---|
| 2009 | $end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']]; |
---|
| 2010 | if ($end_cell == $start_cell && $end_cell < $last_cell) |
---|
| 2011 | { |
---|
| 2012 | $end_cell++; // min. width 1 interval |
---|
| 2013 | } |
---|
| 2014 | } |
---|
| 2015 | else |
---|
| 2016 | { |
---|
| 2017 | $end_cell = $last_cell; |
---|
| 2018 | } |
---|
| 2019 | // get the categories associated with event |
---|
| 2020 | // |
---|
| 2021 | if ($c = $event['category']) |
---|
| 2022 | { |
---|
| 2023 | list($cat) = $this->planner_category($event['category']); |
---|
| 2024 | if ($cat['parent']) |
---|
| 2025 | { |
---|
| 2026 | list($pcat) = $this->planner_category($c = $cat['parent']); |
---|
| 2027 | } |
---|
| 2028 | else |
---|
| 2029 | { |
---|
| 2030 | $pcat = $cat; |
---|
| 2031 | } |
---|
| 2032 | } |
---|
| 2033 | else |
---|
| 2034 | { |
---|
| 2035 | $cat = $pcat = array( 'name' => lang('none')); |
---|
| 2036 | } |
---|
| 2037 | |
---|
| 2038 | // add the event to it`s associated row(s) |
---|
| 2039 | // |
---|
| 2040 | if ($this->bo->sortby == 'category') |
---|
| 2041 | { |
---|
| 2042 | // event needs to show up in it`s category`s row |
---|
| 2043 | // |
---|
| 2044 | $this->planner_update_row($c,$pcat['name'],$event,$cat,$start_cell,$end_cell); |
---|
| 2045 | } |
---|
| 2046 | elseif ($this->bo->sortby == 'user') |
---|
| 2047 | { |
---|
| 2048 | // event needs to show up in rows of all participants that are also owners |
---|
| 2049 | // |
---|
| 2050 | reset($this->planner_group_members); |
---|
| 2051 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
| 2052 | { |
---|
| 2053 | $status = $event['participants'][$id]; |
---|
| 2054 | |
---|
| 2055 | if (isset($status) && $status != 'R') |
---|
| 2056 | { |
---|
| 2057 | $this->planner_update_row($user_name,$user_name,$event,$cat,$start_cell,$end_cell); |
---|
| 2058 | } |
---|
| 2059 | } |
---|
| 2060 | } |
---|
| 2061 | } |
---|
| 2062 | |
---|
| 2063 | function planner_pad_rows() |
---|
| 2064 | { |
---|
| 2065 | $rows = &$this->planner_rows; |
---|
| 2066 | |
---|
| 2067 | if ($this->bo->sortby == 'user') |
---|
| 2068 | { |
---|
| 2069 | // add empty rows for users that do not participante in any event |
---|
| 2070 | // |
---|
| 2071 | reset($this->planner_group_members); |
---|
| 2072 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
| 2073 | { |
---|
| 2074 | $k = $user_name.'_1'; |
---|
| 2075 | $ka = '.nr_'.$k; |
---|
| 2076 | |
---|
| 2077 | if (!isset($rows[$k])) |
---|
| 2078 | { |
---|
| 2079 | $rows[$k]['_name'] = $user_name; |
---|
| 2080 | $rows[$k]['._name'] .= ' nowrap'; |
---|
| 2081 | $rows[$ka] = 0; |
---|
| 2082 | } |
---|
| 2083 | } |
---|
| 2084 | } |
---|
| 2085 | |
---|
| 2086 | // fill the remaining cols |
---|
| 2087 | // |
---|
| 2088 | $last_cell = $this->bo->prefs['calendar']['planner_intervals_per_day'] * $this->planner_days - 1; |
---|
| 2089 | |
---|
| 2090 | ksort($rows); |
---|
| 2091 | while (list($k,$r) = each($rows)) |
---|
| 2092 | { |
---|
| 2093 | if (is_array($r)) |
---|
| 2094 | { |
---|
| 2095 | $rows['.'.$k] = 'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"'; |
---|
| 2096 | $row = &$rows[$k]; |
---|
| 2097 | $akt_cell = &$rows['.nr_'.$k]; |
---|
| 2098 | if ($akt_cell < $last_cell) |
---|
| 2099 | { |
---|
| 2100 | $row['3'] = ' '; |
---|
| 2101 | $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; |
---|
| 2102 | } |
---|
| 2103 | } |
---|
| 2104 | } |
---|
| 2105 | } |
---|
| 2106 | |
---|
| 2107 | function planner_print_rows() |
---|
| 2108 | { |
---|
| 2109 | $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"'; |
---|
| 2110 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2111 | |
---|
| 2112 | if ($this->debug) |
---|
| 2113 | { |
---|
| 2114 | _debug_array($this->planner_rows); |
---|
| 2115 | reset($this->planner_rows); |
---|
| 2116 | } |
---|
| 2117 | return $this->html->table( |
---|
| 2118 | array( |
---|
| 2119 | '_hdr0' => $this->planner_header[0], |
---|
| 2120 | '._hdr0' => $bgcolor, |
---|
| 2121 | '_hdr1' => $this->planner_header[1], |
---|
| 2122 | '._hdr1' => $bgcolor, |
---|
| 2123 | '_hdr2' => $this->planner_header[2], |
---|
| 2124 | '._hdr2' => $bgcolor |
---|
| 2125 | )+$this->planner_rows, |
---|
| 2126 | 'width="100%" cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"'); |
---|
| 2127 | } |
---|
| 2128 | |
---|
| 2129 | function planner_process_interval() |
---|
| 2130 | { |
---|
| 2131 | // generate duplicate free list of events within observed interval |
---|
| 2132 | // |
---|
| 2133 | $this->bo->store_to_cache( |
---|
| 2134 | Array( |
---|
| 2135 | 'syear' => $this->bo->year, |
---|
| 2136 | 'smonth' => $this->bo->month, |
---|
| 2137 | 'sday' => 1, |
---|
| 2138 | 'eyear' => $this->planner_end_year, |
---|
| 2139 | 'emonth' => $this->planner_end_month, |
---|
| 2140 | 'eday' => $this->planner_days_in_end_month |
---|
| 2141 | ) |
---|
| 2142 | ); |
---|
| 2143 | $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); |
---|
| 2144 | |
---|
| 2145 | // process all events within observed interval |
---|
| 2146 | // |
---|
| 2147 | for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++) |
---|
| 2148 | { |
---|
| 2149 | $daily = $this->bo->cached_events[$v]; |
---|
| 2150 | |
---|
| 2151 | print_debug('For Date',$v); |
---|
| 2152 | print_debug('Count of items',count($daily)); |
---|
| 2153 | |
---|
| 2154 | // process all events on day $v |
---|
| 2155 | // |
---|
| 2156 | if (is_array($daily)) foreach($daily as $event) |
---|
| 2157 | { |
---|
| 2158 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
| 2159 | { |
---|
| 2160 | $this->bo->set_recur_date($event,$v); |
---|
| 2161 | } |
---|
| 2162 | if (!$this->bo->rejected_no_show($event)) |
---|
| 2163 | { |
---|
| 2164 | $this->planner_process_event($event); |
---|
| 2165 | } |
---|
| 2166 | } |
---|
| 2167 | } |
---|
| 2168 | $this->planner_pad_rows(); |
---|
| 2169 | } |
---|
| 2170 | |
---|
| 2171 | function matrixselect() |
---|
| 2172 | { |
---|
| 2173 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2174 | |
---|
| 2175 | $sb = CreateObject('phpgwapi.sbox'); |
---|
| 2176 | |
---|
| 2177 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2178 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2179 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
| 2180 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2181 | |
---|
| 2182 | $p = &$GLOBALS['phpgw']->template; |
---|
| 2183 | $p->set_file( |
---|
| 2184 | Array( |
---|
| 2185 | 'mq' => 'matrix_query.tpl', |
---|
| 2186 | 'form_button' => 'form_button_script.tpl' |
---|
| 2187 | ) |
---|
| 2188 | ); |
---|
| 2189 | $p->set_block('mq','matrix_query','matrix_query'); |
---|
| 2190 | $p->set_block('mq','list','list'); |
---|
| 2191 | |
---|
| 2192 | $p->set_var(array( |
---|
| 2193 | 'title' => lang('Daily Matrix View'), |
---|
| 2194 | 'th_bg' => $this->theme['th_bg'], |
---|
| 2195 | 'action_url' => $this->page('viewmatrix') |
---|
| 2196 | )); |
---|
| 2197 | |
---|
| 2198 | // Date |
---|
| 2199 | $var[] = Array( |
---|
| 2200 | 'field' => lang('Date'), |
---|
| 2201 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 2202 | $sb->getYears('year',(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y'),(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y')), |
---|
| 2203 | $sb->getMonthText('month',(int)$GLOBALS['phpgw']->common->show_date($datetime,'n')), |
---|
| 2204 | $sb->getDays('day',(int)$GLOBALS['phpgw']->common->show_date($datetime,'d')) |
---|
| 2205 | ) |
---|
| 2206 | ); |
---|
| 2207 | |
---|
| 2208 | // View type |
---|
| 2209 | $var[] = Array( |
---|
| 2210 | 'field' => lang('View'), |
---|
| 2211 | 'data' => '<select name="matrixtype">'."\n" |
---|
| 2212 | . '<option value="free/busy" selected>'.lang('free/busy').'</option>'."\n" |
---|
| 2213 | . '<option value="weekly">'.lang('Weekly').'</option>'."\n" |
---|
| 2214 | . '</select>'."\n" |
---|
| 2215 | ); |
---|
| 2216 | |
---|
| 2217 | // Participants |
---|
| 2218 | $accounts = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'calendar'); |
---|
| 2219 | $users = Array(); |
---|
| 2220 | for($i=0;$i<count($accounts);$i++) |
---|
| 2221 | { |
---|
| 2222 | $user = $accounts[$i]; |
---|
| 2223 | if(!isset($users[$user])) |
---|
| 2224 | { |
---|
| 2225 | $users[$user] = $GLOBALS['phpgw']->common->grab_owner_name($user); |
---|
| 2226 | if($GLOBALS['phpgw']->accounts->get_type($user) == 'g') |
---|
| 2227 | { |
---|
| 2228 | $group_members = $GLOBALS['phpgw']->acl->get_ids_for_location($user,1,'phpgw_group'); |
---|
| 2229 | if($group_members != False) |
---|
| 2230 | { |
---|
| 2231 | for($j=0;$j<count($group_members);$j++) |
---|
| 2232 | { |
---|
| 2233 | if(!isset($users[$group_members[$j]])) |
---|
| 2234 | { |
---|
| 2235 | $users[$group_members[$j]] = $GLOBALS['phpgw']->common->grab_owner_name($group_members[$j]); |
---|
| 2236 | } |
---|
| 2237 | } |
---|
| 2238 | } |
---|
| 2239 | } |
---|
| 2240 | } |
---|
| 2241 | } |
---|
| 2242 | |
---|
| 2243 | $num_users = count($users); |
---|
| 2244 | |
---|
| 2245 | if ($num_users > 50) |
---|
| 2246 | { |
---|
| 2247 | $size = 15; |
---|
| 2248 | } |
---|
| 2249 | elseif ($num_users > 5) |
---|
| 2250 | { |
---|
| 2251 | $size = 5; |
---|
| 2252 | } |
---|
| 2253 | else |
---|
| 2254 | { |
---|
| 2255 | $size = $num_users; |
---|
| 2256 | } |
---|
| 2257 | $str = ''; |
---|
| 2258 | @asort($users); |
---|
| 2259 | @reset($users); |
---|
| 2260 | while ($user = each($users)) |
---|
| 2261 | { |
---|
| 2262 | if(($GLOBALS['phpgw']->accounts->exists($user[0]) && $this->bo->check_perms(PHPGW_ACL_READ,0,$user[0])) || $GLOBALS['phpgw']->accounts->get_type($user[0]) == 'g') |
---|
| 2263 | { |
---|
| 2264 | $str .= ' <option value="'.$user[0].'">('.$GLOBALS['phpgw']->accounts->get_type($user[0]).') '.$user[1].'</option>'."\n"; |
---|
| 2265 | } |
---|
| 2266 | } |
---|
| 2267 | $var[] = Array( |
---|
| 2268 | 'field' => lang('Participants'), |
---|
| 2269 | 'data' => "\n".' <select name="participants[]" multiple size="'.$size.'">'."\n".$str.' </select>'."\n" |
---|
| 2270 | ); |
---|
| 2271 | |
---|
| 2272 | for($i=0;$i<count($var);$i++) |
---|
| 2273 | { |
---|
| 2274 | $this->output_template_array($p,'rows','list',$var[$i]); |
---|
| 2275 | } |
---|
| 2276 | |
---|
| 2277 | $vars = Array( |
---|
| 2278 | 'submit_button' => lang('View'), |
---|
| 2279 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
| 2280 | 'action_text_button' => lang('Cancel'), |
---|
| 2281 | 'action_confirm_button' => '', |
---|
| 2282 | 'action_extra_field' => '' |
---|
| 2283 | ); |
---|
| 2284 | |
---|
| 2285 | $p->set_var($vars); |
---|
| 2286 | $p->parse('cancel_button','form_button'); |
---|
| 2287 | $p->pparse('out','matrix_query'); |
---|
| 2288 | } |
---|
| 2289 | |
---|
| 2290 | function viewmatrix() |
---|
| 2291 | { |
---|
| 2292 | if ($_POST['cancel']) |
---|
| 2293 | { |
---|
| 2294 | $this->index(); |
---|
| 2295 | } |
---|
| 2296 | $participants = $_POST['participants']; |
---|
| 2297 | $parts = Array(); |
---|
| 2298 | $acct = CreateObject('phpgwapi.accounts',$this->bo->owner); |
---|
| 2299 | |
---|
| 2300 | if (is_array($participants)) |
---|
| 2301 | { |
---|
| 2302 | foreach($participants as $participant) |
---|
| 2303 | { |
---|
| 2304 | switch ($GLOBALS['phpgw']->accounts->get_type($participant)) |
---|
| 2305 | { |
---|
| 2306 | case 'g': |
---|
| 2307 | if ($members = $acct->member((int)$participant)) |
---|
| 2308 | { |
---|
| 2309 | foreach($members as $member) |
---|
| 2310 | { |
---|
| 2311 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id'])) |
---|
| 2312 | { |
---|
| 2313 | $parts[$member['account_id']] = True; |
---|
| 2314 | } |
---|
| 2315 | } |
---|
| 2316 | } |
---|
| 2317 | break; |
---|
| 2318 | case 'u': |
---|
| 2319 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$participant)) |
---|
| 2320 | { |
---|
| 2321 | $parts[$participant] = 1; |
---|
| 2322 | } |
---|
| 2323 | break; |
---|
| 2324 | } |
---|
| 2325 | } |
---|
| 2326 | unset($acct); |
---|
| 2327 | } |
---|
| 2328 | $participants = array_keys($parts); // get id's as values and a numeric index |
---|
| 2329 | |
---|
| 2330 | // Defined - into session - who participates |
---|
| 2331 | $GLOBALS['phpgw']->session->appsession("participants", NULL, implode(";", $participants)); |
---|
| 2332 | |
---|
| 2333 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2334 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2335 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
| 2336 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2337 | |
---|
| 2338 | switch($_POST['matrixtype']) |
---|
| 2339 | { |
---|
| 2340 | case 'free/busy': |
---|
| 2341 | $freetime = $GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year)); |
---|
| 2342 | echo '<br>'.$this->timematrix( |
---|
| 2343 | Array( |
---|
| 2344 | 'date' => $freetime, |
---|
| 2345 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 2346 | 'endtime' => 0, |
---|
| 2347 | 'participants' => $parts |
---|
| 2348 | ) |
---|
| 2349 | ); |
---|
| 2350 | break; |
---|
| 2351 | case 'weekly': |
---|
| 2352 | echo '<br>'.$this->display_weekly( |
---|
| 2353 | Array( |
---|
| 2354 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 2355 | 'showyear' => true, |
---|
| 2356 | 'owners' => $participants |
---|
| 2357 | ) |
---|
| 2358 | ); |
---|
| 2359 | break; |
---|
| 2360 | } |
---|
| 2361 | echo "\n<br>\n".'<form action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n"; |
---|
| 2362 | echo ' <table cellpadding="5"><tr><td>'."\n"; |
---|
| 2363 | echo ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
| 2364 | echo ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
| 2365 | echo ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
| 2366 | echo ' <input type="hidden" name="matrixtype" value="'.$_POST['matrixtype'].'">'."\n"; |
---|
| 2367 | foreach($participants as $part) |
---|
| 2368 | { |
---|
| 2369 | echo ' <input type="hidden" name="participants[]" value="'.$part.'">'."\n"; |
---|
| 2370 | } |
---|
| 2371 | echo ' <input type="submit" name="refresh" value="'.lang('Refresh').'">'."\n"; |
---|
| 2372 | echo ' </td><td>'."\n"; |
---|
| 2373 | echo ' <input type="submit" name="cancel" value="'.lang('Cancel').'">'."\n"; |
---|
| 2374 | echo ' </td></tr></table>'."\n"; |
---|
| 2375 | echo '</form>'."\n"; |
---|
| 2376 | } |
---|
| 2377 | |
---|
| 2378 | function search() |
---|
| 2379 | { |
---|
| 2380 | if (empty($_POST['keywords'])) |
---|
| 2381 | { |
---|
| 2382 | // If we reach this, it is because they didn't search for anything |
---|
| 2383 | // or they used one of the selectboxes (year, month, week) in the search-result |
---|
| 2384 | // attempt to send them back to where they came from. |
---|
| 2385 | |
---|
| 2386 | $vars['menuaction'] = isset($_POST['from']) && $_POST['from'] != 'calendar.uicalendar.search' ? |
---|
| 2387 | $_POST['from'] : 'calendar.uicalendar.index'; |
---|
| 2388 | |
---|
| 2389 | foreach(array('date','year','month','day') as $field) |
---|
| 2390 | { |
---|
| 2391 | if (isset($_POST[$field])) |
---|
| 2392 | { |
---|
| 2393 | $vars[$field] = $_POST[$field]; |
---|
| 2394 | } |
---|
| 2395 | } |
---|
| 2396 | $GLOBALS['phpgw']->redirect_link('/index.php',$vars); |
---|
| 2397 | } |
---|
| 2398 | |
---|
| 2399 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2400 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2401 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
| 2402 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2403 | |
---|
| 2404 | $error = ''; |
---|
| 2405 | |
---|
| 2406 | $matches = 0; |
---|
| 2407 | |
---|
| 2408 | // There is currently a problem searching in with repeated events. |
---|
| 2409 | // It spits back out the date it was entered. I would like to to say that |
---|
| 2410 | // it is a repeated event. |
---|
| 2411 | |
---|
| 2412 | // This has been solved by the little icon indicator for recurring events. |
---|
| 2413 | |
---|
| 2414 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
| 2415 | foreach($event_ids as $key => $id) |
---|
| 2416 | { |
---|
| 2417 | $event = $this->bo->read_entry($id); |
---|
| 2418 | |
---|
| 2419 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$event)) |
---|
| 2420 | { |
---|
| 2421 | continue; |
---|
| 2422 | } |
---|
| 2423 | |
---|
| 2424 | $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2425 | |
---|
| 2426 | $info[strval($event['id'])] = array( |
---|
| 2427 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
| 2428 | 'date' => $GLOBALS['phpgw']->common->show_date($datetime), |
---|
| 2429 | 'link' => $this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']) |
---|
| 2430 | ); |
---|
| 2431 | |
---|
| 2432 | } |
---|
| 2433 | $matches = count($event_ids); |
---|
| 2434 | |
---|
| 2435 | if ($matches == 1) |
---|
| 2436 | { |
---|
| 2437 | $quantity = lang('1 match found').'.'; |
---|
| 2438 | } |
---|
| 2439 | elseif ($matches > 0) |
---|
| 2440 | { |
---|
| 2441 | $quantity = lang('%1 matches found',$matches).'.'; |
---|
| 2442 | } |
---|
| 2443 | else |
---|
| 2444 | { |
---|
| 2445 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
| 2446 | return; |
---|
| 2447 | } |
---|
| 2448 | |
---|
| 2449 | $p = $GLOBALS['phpgw']->template; |
---|
| 2450 | $p->set_file( |
---|
| 2451 | Array( |
---|
| 2452 | 'search_form' => 'search.tpl' |
---|
| 2453 | ) |
---|
| 2454 | ); |
---|
| 2455 | $p->set_block('search_form','search','search'); |
---|
| 2456 | $p->set_block('search_form','search_list_header','search_list_header'); |
---|
| 2457 | $p->set_block('search_form','search_list','search_list'); |
---|
| 2458 | $p->set_block('search_form','search_list_footer','search_list_footer'); |
---|
| 2459 | |
---|
| 2460 | $var = Array( |
---|
| 2461 | 'th_bg' => $this->theme['th_bg'], |
---|
| 2462 | 'search_text' => lang('Search Results'), |
---|
| 2463 | 'quantity' => $quantity |
---|
| 2464 | ); |
---|
| 2465 | $p->set_var($var); |
---|
| 2466 | |
---|
| 2467 | if($matches > 0) |
---|
| 2468 | { |
---|
| 2469 | $p->parse('rows','search_list_header',True); |
---|
| 2470 | } |
---|
| 2471 | foreach($info as $id => $data) |
---|
| 2472 | { |
---|
| 2473 | $p->set_var($data); |
---|
| 2474 | $p->parse('rows','search_list',True); |
---|
| 2475 | } |
---|
| 2476 | |
---|
| 2477 | if($matches > 0) |
---|
| 2478 | { |
---|
| 2479 | $p->parse('rows','search_list_footer',True); |
---|
| 2480 | } |
---|
| 2481 | |
---|
| 2482 | $p->pparse('out','search'); |
---|
| 2483 | } |
---|
| 2484 | |
---|
| 2485 | /* Private functions */ |
---|
| 2486 | function _debug_sqsof() |
---|
| 2487 | { |
---|
| 2488 | $data = array( |
---|
| 2489 | 'filter' => $this->bo->filter, |
---|
| 2490 | 'cat_id' => $this->bo->cat_id, |
---|
| 2491 | 'owner' => $this->bo->owner, |
---|
| 2492 | 'year' => $this->bo->year, |
---|
| 2493 | 'month' => $this->bo->month, |
---|
| 2494 | 'day' => $this->bo->day, |
---|
| 2495 | 'sortby' => $this->bo->sortby, |
---|
| 2496 | 'num_months' => $this->bo->num_months |
---|
| 2497 | ); |
---|
| 2498 | Return _debug_array($data,False); |
---|
| 2499 | } |
---|
| 2500 | |
---|
| 2501 | function output_template_array(&$p,$row,$list,$var) |
---|
| 2502 | { |
---|
| 2503 | if (!isset($var['hidden_vars'])) |
---|
| 2504 | { |
---|
| 2505 | $var['hidden_vars'] = ''; |
---|
| 2506 | } |
---|
| 2507 | if (!isset($var['tr_color'])) |
---|
| 2508 | { |
---|
| 2509 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
| 2510 | } |
---|
| 2511 | $p->set_var($var); |
---|
| 2512 | $p->parse($row,$list,True); |
---|
| 2513 | } |
---|
| 2514 | |
---|
| 2515 | function page($_page='',$params='') |
---|
| 2516 | { |
---|
| 2517 | if($_page == '') |
---|
| 2518 | { |
---|
| 2519 | $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); |
---|
| 2520 | $_page = $page_[0]; |
---|
| 2521 | |
---|
| 2522 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
| 2523 | { |
---|
| 2524 | $_page = 'planner'; |
---|
| 2525 | } |
---|
| 2526 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
| 2527 | { |
---|
| 2528 | $_page = 'month'; |
---|
| 2529 | $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); |
---|
| 2530 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 2531 | } |
---|
| 2532 | } |
---|
| 2533 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
| 2534 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
| 2535 | { |
---|
| 2536 | $page_app = 'calendar'; |
---|
| 2537 | } |
---|
| 2538 | else |
---|
| 2539 | { |
---|
| 2540 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
| 2541 | } |
---|
| 2542 | if (is_array($params)) |
---|
| 2543 | { |
---|
| 2544 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
| 2545 | } |
---|
| 2546 | else |
---|
| 2547 | { |
---|
| 2548 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
| 2549 | } |
---|
| 2550 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
| 2551 | } |
---|
| 2552 | |
---|
| 2553 | function header() |
---|
| 2554 | { |
---|
| 2555 | $cols = 8; |
---|
| 2556 | if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) |
---|
| 2557 | { |
---|
| 2558 | $cols++; |
---|
| 2559 | } |
---|
| 2560 | |
---|
| 2561 | $tpl = $GLOBALS['phpgw']->template; |
---|
| 2562 | $tpl->set_unknowns('remove'); |
---|
| 2563 | |
---|
| 2564 | if (!file_exists($file = $this->template_dir.'/header.inc.php')) |
---|
| 2565 | { |
---|
| 2566 | $file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php'; |
---|
| 2567 | } |
---|
[362] | 2568 | |
---|
[2] | 2569 | include($file); |
---|
[362] | 2570 | $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); |
---|
| 2571 | if($refer[2] != 'view') { |
---|
[2] | 2572 | $header = $tpl->fp('out','head'); |
---|
| 2573 | unset($tpl); |
---|
| 2574 | echo $header; |
---|
| 2575 | } |
---|
[362] | 2576 | unset($tpl); |
---|
| 2577 | } |
---|
[2] | 2578 | |
---|
| 2579 | function footer() |
---|
| 2580 | { |
---|
| 2581 | $menuaction = $_GET['menuaction']; |
---|
| 2582 | list(,,$method) = explode('.',$menuaction); |
---|
| 2583 | |
---|
| 2584 | if (@$this->bo->printer_friendly) |
---|
| 2585 | { |
---|
| 2586 | return; |
---|
| 2587 | } |
---|
| 2588 | |
---|
| 2589 | $p = $GLOBALS['phpgw']->template; |
---|
| 2590 | |
---|
| 2591 | $p->set_file( |
---|
| 2592 | Array( |
---|
| 2593 | 'footer' => 'footer.tpl', |
---|
| 2594 | 'form_button' => 'form_button_script.tpl' |
---|
| 2595 | ) |
---|
| 2596 | ); |
---|
| 2597 | $p->set_block('footer','footer_table','footer_table'); |
---|
| 2598 | $p->set_block('footer','footer_row','footer_row'); |
---|
| 2599 | $p->set_block('footer','blank_row','blank_row'); |
---|
[924] | 2600 | $p->set_block('footer','num_dias','num_dias'); |
---|
[2] | 2601 | |
---|
| 2602 | $m = $this->bo->month; |
---|
| 2603 | $y = $this->bo->year; |
---|
| 2604 | |
---|
[924] | 2605 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
| 2606 | $mes_hoje = (int)substr($hoje,4,2); |
---|
| 2607 | $mes_footer = (int)substr($_POST['date'],4,2); |
---|
| 2608 | if($_GET['sday']) |
---|
| 2609 | { |
---|
| 2610 | if($_GET['month'] == $mes_hoje) |
---|
| 2611 | { |
---|
| 2612 | $day = $this->bo->day; |
---|
| 2613 | } |
---|
| 2614 | else |
---|
| 2615 | { |
---|
| 2616 | $day = $_GET['sday']; |
---|
| 2617 | } |
---|
| 2618 | } |
---|
| 2619 | else |
---|
| 2620 | { |
---|
| 2621 | $day = $this->bo->day; |
---|
| 2622 | $dia_ini = $day; |
---|
| 2623 | } |
---|
| 2624 | if($mes_footer == $mes_hoje) |
---|
| 2625 | { |
---|
| 2626 | $dia_ini = (int)substr($hoje,6,2); |
---|
| 2627 | $day = $dia_ini; |
---|
| 2628 | } |
---|
| 2629 | /********************************************************************************************/ |
---|
| 2630 | /* Bloco adicionado para receber o dia a partir do qual a versao para impressao sera gerada */ |
---|
| 2631 | $str_ini = ''; |
---|
| 2632 | for ($i = 1; $i <= ($GLOBALS['phpgw']->datetime->days_in_month($m, $y)); $i++) |
---|
| 2633 | { |
---|
| 2634 | $str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 2635 | } |
---|
| 2636 | $str_qtd = '<option value="'.''.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; |
---|
| 2637 | for ($i = 1; $i <= 45; $i++) |
---|
| 2638 | { |
---|
| 2639 | $str_qtd .= '<option value="'.$i.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 2640 | } |
---|
| 2641 | $display = ''; |
---|
| 2642 | $display_view = ''; |
---|
| 2643 | if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') ) |
---|
| 2644 | { |
---|
| 2645 | $display = 'none'; |
---|
| 2646 | } |
---|
| 2647 | else if( ($menuaction == 'calendar.uicalendar.view') ) |
---|
| 2648 | { |
---|
| 2649 | $display = 'none'; |
---|
| 2650 | $display_view = 'none'; |
---|
| 2651 | } |
---|
| 2652 | $var = Array( |
---|
| 2653 | 'acao' => $this->page($method,''), |
---|
| 2654 | 'formname' => 'SelectDay', |
---|
| 2655 | 'formonchange' => 'document.SelectDay.submit()', |
---|
| 2656 | 'day_ini_label' => lang('print starting in'), |
---|
| 2657 | 'num_dias_label' => lang('quantity of days'), |
---|
| 2658 | 'tip' => lang('empty prints from the day chosen below to the end of the current month'), |
---|
| 2659 | 'day_ini_name' => 'day', |
---|
| 2660 | 'num_dias_name' => 'qtd_dias', |
---|
| 2661 | 'row_ini' => $str_ini, |
---|
| 2662 | 'row_qtd' => $str_qtd, |
---|
| 2663 | 'display' => $display, |
---|
| 2664 | 'display_view' => $display_view, |
---|
| 2665 | 'go' => lang('Go!') |
---|
| 2666 | ); |
---|
| 2667 | $this->output_template_array($p,'table_row','num_dias',$var); |
---|
| 2668 | |
---|
| 2669 | /********************************************************************************************/ |
---|
| 2670 | |
---|
[2] | 2671 | $thisdate = date('Ymd',mktime(0,0,0,$m,1,$y)); |
---|
| 2672 | $y--; |
---|
| 2673 | |
---|
| 2674 | $str = ''; |
---|
[924] | 2675 | for ($i = 0; $i < 20; $i++) |
---|
[2] | 2676 | { |
---|
| 2677 | $m++; |
---|
| 2678 | if ($m > 12) |
---|
| 2679 | { |
---|
| 2680 | $m = 1; |
---|
| 2681 | $y++; |
---|
| 2682 | } |
---|
| 2683 | $d = mktime(0,0,0,$m,1,$y); |
---|
| 2684 | $d_ymd = date('Ymd',$d); |
---|
| 2685 | $str .= '<option value="'.$d_ymd.'"'.($d_ymd == $thisdate?' selected':'').'>'.lang(date('F', $d)).strftime(' %Y', $d).'</option>'."\n"; |
---|
| 2686 | } |
---|
| 2687 | |
---|
| 2688 | $var = Array( |
---|
| 2689 | 'action_url' => $this->page($method,''), |
---|
| 2690 | 'form_name' => 'SelectMonth', |
---|
| 2691 | 'label' => lang('Month'), |
---|
| 2692 | 'form_label' => 'date', |
---|
| 2693 | 'form_onchange' => 'document.SelectMonth.submit()', |
---|
| 2694 | 'row' => $str, |
---|
[924] | 2695 | 'dia_ini' => $dia_ini, |
---|
[2] | 2696 | 'go' => lang('Go!') |
---|
| 2697 | ); |
---|
| 2698 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 2699 | |
---|
| 2700 | if($menuaction == 'calendar.uicalendar.week') |
---|
| 2701 | { |
---|
| 2702 | unset($thisdate); |
---|
| 2703 | $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2704 | $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2705 | |
---|
| 2706 | $str = ''; |
---|
| 2707 | for ($i = -7; $i <= 7; $i++) |
---|
| 2708 | { |
---|
| 2709 | $begin = $sun + (7*24*60*60 * $i) + 12*60*60; // we use midday, that changes in daylight-saveing does not effect us |
---|
| 2710 | $end = $begin + 6*24*60*60; |
---|
| 2711 | // echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end); |
---|
| 2712 | $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate+12*60*60 && $end >= $thisdate+12*60*60 ? ' selected':'').'>' |
---|
| 2713 | . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - ' |
---|
| 2714 | . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) |
---|
| 2715 | . '</option>' . "\n"; |
---|
| 2716 | } |
---|
| 2717 | |
---|
| 2718 | $var = Array( |
---|
| 2719 | 'action_url' => $this->page($method,''), |
---|
| 2720 | 'form_name' => 'SelectWeek', |
---|
| 2721 | 'label' => lang('Week'), |
---|
| 2722 | 'form_label' => 'date', |
---|
| 2723 | 'form_onchange' => 'document.SelectWeek.submit()', |
---|
| 2724 | 'row' => $str, |
---|
| 2725 | 'go' => lang('Go!') |
---|
| 2726 | ); |
---|
| 2727 | |
---|
| 2728 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 2729 | } |
---|
| 2730 | |
---|
| 2731 | $str = ''; |
---|
| 2732 | for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); $i++) |
---|
| 2733 | { |
---|
| 2734 | $str .= '<option value="'.$i.'"'.($i == $this->bo->year?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 2735 | } |
---|
| 2736 | |
---|
| 2737 | $var = Array( |
---|
| 2738 | 'action_url' => $this->page($method,''), |
---|
| 2739 | 'form_name' => 'SelectYear', |
---|
| 2740 | 'label' => lang('Year'), |
---|
| 2741 | 'form_label' => 'year', |
---|
| 2742 | 'form_onchange' => 'document.SelectYear.submit()', |
---|
| 2743 | 'row' => $str, |
---|
| 2744 | 'go' => lang('Go!') |
---|
| 2745 | ); |
---|
| 2746 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 2747 | |
---|
| 2748 | if($menuaction == 'calendar.uicalendar.planner') |
---|
| 2749 | { |
---|
| 2750 | $str = ''; |
---|
| 2751 | $date_str = ''; |
---|
| 2752 | |
---|
| 2753 | if(isset($_GET['date']) && $_GET['date']) |
---|
| 2754 | { |
---|
| 2755 | $date_str .= ' <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n"; |
---|
| 2756 | } |
---|
| 2757 | $date_str .= ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
| 2758 | $date_str .= ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
| 2759 | $date_str .= ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
| 2760 | |
---|
| 2761 | for($i=1; $i<=6; $i++) |
---|
| 2762 | { |
---|
| 2763 | $str .= '<option value="'.$i.'"'.($i == $this->bo->num_months?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 2764 | } |
---|
| 2765 | |
---|
| 2766 | $var = Array( |
---|
| 2767 | 'action_url' => $this->page($method,''), |
---|
| 2768 | 'form_name' => 'SelectNumberOfMonths', |
---|
| 2769 | 'label' => lang('Number of Months'), |
---|
| 2770 | 'hidden_vars' => $date_str, |
---|
| 2771 | 'form_label' => 'num_months', |
---|
| 2772 | 'form_onchange' => 'document.SelectNumberOfMonths.submit()', |
---|
| 2773 | 'action_extra_field' => $date_str, |
---|
| 2774 | 'row' => $str, |
---|
| 2775 | 'go' => lang('Go!') |
---|
| 2776 | ); |
---|
| 2777 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 2778 | } |
---|
| 2779 | |
---|
| 2780 | $var = Array( |
---|
| 2781 | 'submit_button' => lang('Submit'), |
---|
| 2782 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), |
---|
| 2783 | 'action_text_button' => lang('Import'), |
---|
| 2784 | 'action_confirm_button' => '', |
---|
| 2785 | 'action_extra_field' => '' |
---|
| 2786 | ); |
---|
| 2787 | $this->output_template_array($p,'b_row','form_button',$var); |
---|
[57] | 2788 | |
---|
| 2789 | $var = Array( |
---|
| 2790 | 'submit_button' => lang('Submit'), |
---|
| 2791 | 'action_url' => $this->page($method,''), |
---|
| 2792 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.export_all'), |
---|
| 2793 | 'action_text_button' => lang('Export all'), |
---|
| 2794 | 'action_confirm_button' => '', |
---|
| 2795 | 'action_extra_field' => '' |
---|
| 2796 | ); |
---|
| 2797 | $this->output_template_array($p,'b_row2','form_button',$var); |
---|
| 2798 | |
---|
[2] | 2799 | $p->parse('table_row','blank_row',True); |
---|
| 2800 | |
---|
| 2801 | $p->pparse('out','footer_table'); |
---|
| 2802 | unset($p); |
---|
| 2803 | } |
---|
| 2804 | |
---|
| 2805 | function css() |
---|
| 2806 | { |
---|
| 2807 | $GLOBALS['phpgw']->browser->browser(); |
---|
| 2808 | if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA') |
---|
| 2809 | { |
---|
| 2810 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?12:8); |
---|
| 2811 | } |
---|
| 2812 | else |
---|
| 2813 | { |
---|
| 2814 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?10:7); |
---|
| 2815 | } |
---|
| 2816 | |
---|
| 2817 | // moved to app.css in templates/default for future separation of code and style [NDEE 10.03.04] |
---|
| 2818 | /* |
---|
| 2819 | return 'A.minicalendar { color: #000000; font-size: 72%; font-family: '.$this->theme['font'].' }'."\n" |
---|
| 2820 | . ' A.bminicalendar { color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 2821 | . ' A.minicalendargrey { color: #999999; font-size: 8px; font-family: '.$this->theme['font'].' }'."\n" |
---|
| 2822 | . ' A.bminicalendargrey { color: #336699; font-style: italic; font-size:8px; font-family '.$this->theme['font'].' }'."\n" |
---|
| 2823 | . ' A.minicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font: x-small '.$this->theme['font'].' }'."\n" |
---|
| 2824 | . ' A.bminicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 2825 | . ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: x-small '.$this->theme['font'].' }'."\n" |
---|
| 2826 | . ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 2827 | . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 2828 | . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 2829 | . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 2830 | . ' .time { background: '.$this->theme['th_bg'].'; color: '.$this->theme['bg_text'].'; font: bold 100% '.$this->theme['font'].'; width: '.$time_width.'%; vertical-align: middle; text-align: right; }'."\n" |
---|
| 2831 | . ' .tablecell { width: 80px; height: 80px }'."\n" |
---|
| 2832 | . ' .planner-cell { cursor:pointer; cursor:hand; border: thin solid black; }'; |
---|
| 2833 | */ |
---|
| 2834 | } |
---|
| 2835 | |
---|
| 2836 | function no_edit() |
---|
| 2837 | { |
---|
| 2838 | if(!isset($GLOBALS['phpgw_info']['flags']['noheader'])) |
---|
| 2839 | { |
---|
| 2840 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2841 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2842 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 2843 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 2844 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Permission denied'); |
---|
| 2845 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2846 | } |
---|
| 2847 | echo '<center>You do not have permission to edit this appointment!</center>'; |
---|
| 2848 | return; |
---|
| 2849 | } |
---|
| 2850 | |
---|
| 2851 | function link_to_entry($event,$month,$day,$year) |
---|
| 2852 | { |
---|
| 2853 | $str = ''; |
---|
| 2854 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 2855 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 2856 | |
---|
| 2857 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2858 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2859 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
| 2860 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2861 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2862 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
| 2863 | { |
---|
| 2864 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 2865 | } |
---|
| 2866 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
| 2867 | { |
---|
| 2868 | $time = '[ '.lang('All Day').' ]'; |
---|
| 2869 | } |
---|
| 2870 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
| 2871 | { |
---|
| 2872 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 2873 | { |
---|
| 2874 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
| 2875 | } |
---|
| 2876 | else |
---|
| 2877 | { |
---|
| 2878 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 2879 | } |
---|
| 2880 | |
---|
| 2881 | if($endtime >= ($rawdate_offset + 86400)) |
---|
| 2882 | { |
---|
| 2883 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
| 2884 | } |
---|
| 2885 | else |
---|
| 2886 | { |
---|
| 2887 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
| 2888 | } |
---|
| 2889 | $time = $start_time.'-'.$end_time; |
---|
| 2890 | } |
---|
| 2891 | else |
---|
| 2892 | { |
---|
| 2893 | $time = ''; |
---|
| 2894 | } |
---|
| 2895 | |
---|
| 2896 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
| 2897 | |
---|
| 2898 | |
---|
| 2899 | |
---|
| 2900 | if(!$is_private) |
---|
| 2901 | { |
---|
| 2902 | //$text .= $this->bo->display_status($event['users_status']); |
---|
| 2903 | |
---|
| 2904 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
| 2905 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
| 2906 | |
---|
| 2907 | } |
---|
| 2908 | |
---|
| 2909 | /* |
---|
| 2910 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
| 2911 | (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). |
---|
| 2912 | $GLOBALS['phpgw']->browser->br; |
---|
| 2913 | */ |
---|
| 2914 | |
---|
| 2915 | $texttime=$time; |
---|
| 2916 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
| 2917 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
| 2918 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
| 2919 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
| 2920 | |
---|
| 2921 | if ($viewable) |
---|
| 2922 | { |
---|
| 2923 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
| 2924 | $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
| 2925 | $this->link_tpl->set_var('lang_view',lang('View this entry')); |
---|
| 2926 | $this->link_tpl->set_var('desc', $textdesc); |
---|
| 2927 | $this->link_tpl->set_var('location', $textlocation); |
---|
| 2928 | $this->link_tpl->parse('picture','link_open',True); |
---|
| 2929 | } |
---|
| 2930 | if (!$is_private) |
---|
| 2931 | { |
---|
| 2932 | if($event['priority'] == 3) |
---|
| 2933 | { |
---|
| 2934 | $picture[] = Array( |
---|
| 2935 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
| 2936 | 'width' => 16, |
---|
| 2937 | 'height'=> 16, |
---|
| 2938 | 'title' => lang('high priority') |
---|
| 2939 | ); |
---|
| 2940 | } |
---|
| 2941 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 2942 | { |
---|
| 2943 | $picture[] = Array( |
---|
| 2944 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
| 2945 | 'width' => 9, |
---|
| 2946 | 'height'=> 9, |
---|
| 2947 | 'title' => lang('single event') |
---|
| 2948 | ); |
---|
| 2949 | } |
---|
| 2950 | else |
---|
| 2951 | { |
---|
| 2952 | $picture[] = Array( |
---|
| 2953 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
| 2954 | 'width' => 12, |
---|
| 2955 | 'height'=> 12, |
---|
| 2956 | 'title' => lang('recurring event') |
---|
| 2957 | ); |
---|
| 2958 | } |
---|
| 2959 | } |
---|
| 2960 | $participants = $this->planner_participants($event['participants']); |
---|
| 2961 | if(count($event['participants']) > 1) |
---|
| 2962 | { |
---|
| 2963 | $picture[] = Array( |
---|
| 2964 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
| 2965 | 'width' => 14, |
---|
| 2966 | 'height'=> 14, |
---|
| 2967 | 'title' => $participants |
---|
| 2968 | ); |
---|
| 2969 | } |
---|
| 2970 | else |
---|
| 2971 | { |
---|
| 2972 | $picture[] = Array( |
---|
| 2973 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
| 2974 | 'width' => 14, |
---|
| 2975 | 'height'=> 14, |
---|
| 2976 | 'title' => $participants |
---|
| 2977 | ); |
---|
| 2978 | } |
---|
| 2979 | if($event['public'] == 0) |
---|
| 2980 | { |
---|
| 2981 | $picture[] = Array( |
---|
| 2982 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
| 2983 | 'width' => 13, |
---|
| 2984 | 'height'=> 13, |
---|
| 2985 | 'title' => lang('private') |
---|
| 2986 | ); |
---|
| 2987 | } |
---|
| 2988 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
| 2989 | { |
---|
| 2990 | // if the alarm is to go off the day before the event |
---|
| 2991 | // the icon does not show up because of 'alarm_today' |
---|
| 2992 | // - TOM |
---|
| 2993 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
| 2994 | { |
---|
| 2995 | $picture[] = Array( |
---|
| 2996 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
| 2997 | 'width' => 13, |
---|
| 2998 | 'height'=> 13, |
---|
| 2999 | 'title' => lang('alarm') |
---|
| 3000 | ); |
---|
| 3001 | } |
---|
| 3002 | } |
---|
| 3003 | |
---|
| 3004 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
| 3005 | for($i=0;$i<count($picture);$i++) |
---|
| 3006 | { |
---|
| 3007 | $var = Array( |
---|
| 3008 | 'pic_image' => $picture[$i]['pict'], |
---|
| 3009 | 'width' => $picture[$i]['width'], |
---|
| 3010 | 'height' => $picture[$i]['height'], |
---|
| 3011 | 'title' => $picture[$i]['title'] |
---|
| 3012 | ); |
---|
| 3013 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
| 3014 | } |
---|
| 3015 | if ($texttitle) |
---|
| 3016 | { |
---|
| 3017 | $var = Array( |
---|
| 3018 | // 'text' => $text, |
---|
| 3019 | 'time'=> $texttime, |
---|
| 3020 | 'title'=> $texttitle, |
---|
| 3021 | 'users_status'=>$textstatus, |
---|
| 3022 | 'desc'=> $textdesc, |
---|
| 3023 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
| 3024 | ); |
---|
| 3025 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
| 3026 | } |
---|
| 3027 | |
---|
| 3028 | if ($viewable) |
---|
| 3029 | { |
---|
| 3030 | $this->link_tpl->parse('picture','link_close',True); |
---|
| 3031 | } |
---|
| 3032 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
| 3033 | $this->link_tpl->set_var('picture',''); |
---|
| 3034 | $this->link_tpl->set_var('out',''); |
---|
| 3035 | // unset($p); |
---|
| 3036 | return $str; |
---|
| 3037 | } |
---|
| 3038 | |
---|
[360] | 3039 | /*****************************************************************************************/ |
---|
| 3040 | /*Funcao foi duplicada e alterada para tratar os eventos de agendamento (exibicao do mes) para impressao; |
---|
[924] | 3041 | utiliza o template event_link.tpl*/ |
---|
[360] | 3042 | |
---|
| 3043 | function link_to_month_entry($event,$month,$day,$year) |
---|
| 3044 | { |
---|
| 3045 | $str = ''; |
---|
| 3046 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3047 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3048 | |
---|
| 3049 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3050 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3051 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
| 3052 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3053 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3054 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
| 3055 | { |
---|
| 3056 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3057 | } |
---|
| 3058 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
| 3059 | { |
---|
| 3060 | $time = '[ '.lang('All Day').' ]'; |
---|
| 3061 | } |
---|
| 3062 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
| 3063 | { |
---|
| 3064 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3065 | { |
---|
| 3066 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
| 3067 | } |
---|
| 3068 | else |
---|
| 3069 | { |
---|
| 3070 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3071 | } |
---|
| 3072 | |
---|
| 3073 | if($endtime >= ($rawdate_offset + 86400)) |
---|
| 3074 | { |
---|
| 3075 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
| 3076 | } |
---|
| 3077 | else |
---|
| 3078 | { |
---|
| 3079 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
| 3080 | } |
---|
| 3081 | $time = $start_time.' - '.$end_time; |
---|
| 3082 | } |
---|
| 3083 | else |
---|
| 3084 | { |
---|
| 3085 | $time = ''; |
---|
| 3086 | } |
---|
| 3087 | |
---|
| 3088 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
| 3089 | |
---|
| 3090 | |
---|
| 3091 | |
---|
| 3092 | if(!$is_private) |
---|
| 3093 | { |
---|
| 3094 | //$text .= $this->bo->display_status($event['users_status']); |
---|
| 3095 | |
---|
| 3096 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
| 3097 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
| 3098 | |
---|
| 3099 | } |
---|
| 3100 | |
---|
| 3101 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
| 3102 | |
---|
| 3103 | $texttime=$time; |
---|
| 3104 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
| 3105 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
| 3106 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
| 3107 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
| 3108 | |
---|
| 3109 | if ($viewable) |
---|
| 3110 | { |
---|
| 3111 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
| 3112 | $this->event_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
| 3113 | $this->event_tpl->set_var('lang_view',lang('View this entry')); |
---|
| 3114 | $this->event_tpl->set_var('desc', $textdesc); |
---|
| 3115 | $this->event_tpl->set_var('location', $textlocation); |
---|
| 3116 | $this->event_tpl->parse('picture','link_event_open',True); |
---|
| 3117 | } |
---|
| 3118 | if (!$is_private) |
---|
| 3119 | { |
---|
| 3120 | if($event['priority'] == 3) |
---|
| 3121 | { |
---|
| 3122 | $picture[] = Array( |
---|
| 3123 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
| 3124 | 'width' => 16, |
---|
| 3125 | 'height'=> 16, |
---|
| 3126 | 'title' => lang('high priority') |
---|
| 3127 | ); |
---|
| 3128 | } |
---|
| 3129 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3130 | { |
---|
| 3131 | $picture[] = Array( |
---|
| 3132 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
| 3133 | 'width' => 9, |
---|
| 3134 | 'height'=> 9, |
---|
| 3135 | 'title' => lang('single event') |
---|
| 3136 | ); |
---|
| 3137 | } |
---|
| 3138 | else |
---|
| 3139 | { |
---|
| 3140 | $picture[] = Array( |
---|
| 3141 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
| 3142 | 'width' => 12, |
---|
| 3143 | 'height'=> 12, |
---|
| 3144 | 'title' => lang('recurring event') |
---|
| 3145 | ); |
---|
| 3146 | } |
---|
| 3147 | } |
---|
| 3148 | $participants = $this->planner_participants($event['participants']); |
---|
| 3149 | if(count($event['participants']) > 1) |
---|
| 3150 | { |
---|
| 3151 | $picture[] = Array( |
---|
| 3152 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
| 3153 | 'width' => 14, |
---|
| 3154 | 'height'=> 14, |
---|
| 3155 | 'title' => $participants |
---|
| 3156 | ); |
---|
| 3157 | } |
---|
| 3158 | else |
---|
| 3159 | { |
---|
| 3160 | $picture[] = Array( |
---|
| 3161 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
| 3162 | 'width' => 14, |
---|
| 3163 | 'height'=> 14, |
---|
| 3164 | 'title' => $participants |
---|
| 3165 | ); |
---|
| 3166 | } |
---|
| 3167 | if($event['public'] == 0) |
---|
| 3168 | { |
---|
| 3169 | $picture[] = Array( |
---|
| 3170 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
| 3171 | 'width' => 13, |
---|
| 3172 | 'height'=> 13, |
---|
| 3173 | 'title' => lang('private') |
---|
| 3174 | ); |
---|
| 3175 | } |
---|
| 3176 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
| 3177 | { |
---|
| 3178 | // if the alarm is to go off the day before the event |
---|
| 3179 | // the icon does not show up because of 'alarm_today' |
---|
| 3180 | // - TOM |
---|
| 3181 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
| 3182 | { |
---|
| 3183 | $picture[] = Array( |
---|
| 3184 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
| 3185 | 'width' => 13, |
---|
| 3186 | 'height'=> 13, |
---|
| 3187 | 'title' => lang('alarm') |
---|
| 3188 | ); |
---|
| 3189 | } |
---|
| 3190 | } |
---|
| 3191 | |
---|
| 3192 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
| 3193 | for($i=0;$i<count($picture);$i++) |
---|
| 3194 | { |
---|
| 3195 | $var = Array( |
---|
| 3196 | 'pic_image' => $picture[$i]['pict'], |
---|
| 3197 | 'width' => $picture[$i]['width'], |
---|
| 3198 | 'height' => $picture[$i]['height'], |
---|
| 3199 | 'title' => $picture[$i]['title'] |
---|
| 3200 | ); |
---|
| 3201 | $this->output_template_array($this->event_tpl,'picture','event_pict',$var); |
---|
| 3202 | } |
---|
| 3203 | if ($texttitle) |
---|
| 3204 | { |
---|
| 3205 | $var = Array( |
---|
| 3206 | // 'text' => $text, |
---|
| 3207 | 'time'=> $texttime, |
---|
| 3208 | 'title'=> $texttitle, |
---|
| 3209 | 'users_status'=>$textstatus, |
---|
| 3210 | 'desc'=> $textdesc, |
---|
| 3211 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
| 3212 | ); |
---|
| 3213 | $this->output_template_array($this->event_tpl,'picture','link_event_text',$var); |
---|
| 3214 | } |
---|
| 3215 | |
---|
| 3216 | if ($viewable) |
---|
| 3217 | { |
---|
| 3218 | $this->event_tpl->parse('picture','link_event_close',True); |
---|
| 3219 | } |
---|
| 3220 | $str = $this->event_tpl->fp('out','link_event_pict'); |
---|
| 3221 | $this->event_tpl->set_var('picture',''); |
---|
| 3222 | $this->event_tpl->set_var('out',''); |
---|
| 3223 | // unset($p); |
---|
| 3224 | return $str; |
---|
| 3225 | } |
---|
| 3226 | |
---|
| 3227 | /*****************************************************************************************/ |
---|
[625] | 3228 | function normDec($num) |
---|
| 3229 | { |
---|
| 3230 | if ($num > 9) |
---|
| 3231 | return $num; |
---|
| 3232 | else |
---|
| 3233 | return "0".$num; |
---|
| 3234 | } |
---|
[2] | 3235 | function overlap($params) |
---|
| 3236 | { |
---|
| 3237 | if(!is_array($params)) |
---|
| 3238 | { |
---|
| 3239 | } |
---|
| 3240 | else |
---|
| 3241 | { |
---|
| 3242 | $overlapping_events = $params['o_events']; |
---|
| 3243 | $event = $params['this_event']; |
---|
| 3244 | } |
---|
| 3245 | |
---|
| 3246 | $month = $event['start']['month']; |
---|
| 3247 | $mday = $event['start']['mday']; |
---|
| 3248 | $year = $event['start']['year']; |
---|
| 3249 | |
---|
| 3250 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3251 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3252 | |
---|
| 3253 | $overlap = ''; |
---|
| 3254 | for($i=0;$i<count($overlapping_events);$i++) |
---|
| 3255 | { |
---|
| 3256 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
| 3257 | foreach($overlapped_event['participants'] as $id => $status) |
---|
| 3258 | { |
---|
| 3259 | $conflict = isset($event['participants'][$id]); |
---|
| 3260 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
| 3261 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
[625] | 3262 | ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; |
---|
[2] | 3263 | } |
---|
[625] | 3264 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
| 3265 | $overlap .= '<ul><font size="1"><span>'. |
---|
| 3266 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
| 3267 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
| 3268 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
| 3269 | $this->normDec($overlapped_event['end']['min']). |
---|
| 3270 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
| 3271 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
| 3272 | else |
---|
| 3273 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>"; |
---|
[2] | 3274 | } |
---|
| 3275 | |
---|
| 3276 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 3277 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 3278 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 3279 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 3280 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
| 3281 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 3282 | |
---|
| 3283 | $p = $GLOBALS['phpgw']->template; |
---|
| 3284 | $p->set_file( |
---|
| 3285 | Array( |
---|
| 3286 | 'overlap' => 'overlap.tpl', |
---|
| 3287 | 'form_button' => 'form_button_script.tpl' |
---|
| 3288 | ) |
---|
| 3289 | ); |
---|
| 3290 | |
---|
| 3291 | $var = Array( |
---|
| 3292 | 'color' => $this->theme['bg_text'], |
---|
| 3293 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
| 3294 | 'overlap_text' => lang('Your suggested time of <B> %1 - %2 </B> conflicts with the following existing calendar entries:',$GLOBALS['phpgw']->common->show_date($start),$GLOBALS['phpgw']->common->show_date($end)), |
---|
| 3295 | 'overlap_list' => $overlap |
---|
| 3296 | ); |
---|
| 3297 | $p->set_var($var); |
---|
| 3298 | |
---|
| 3299 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
| 3300 | $var = Array( |
---|
| 3301 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), |
---|
| 3302 | 'action_text_button' => lang('Ignore Conflict'), |
---|
| 3303 | 'action_confirm_button' => '', |
---|
[663] | 3304 | 'action_extra_field' => '', |
---|
| 3305 | 'button_id' => 'ignore_button' |
---|
[2] | 3306 | ); |
---|
| 3307 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
| 3308 | |
---|
| 3309 | $var = Array( |
---|
| 3310 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), |
---|
| 3311 | 'action_text_button' => lang('Re-Edit Event'), |
---|
| 3312 | 'action_confirm_button' => '', |
---|
[663] | 3313 | 'action_extra_field' => '', |
---|
| 3314 | 'button_id' => 'redit_button' |
---|
[2] | 3315 | ); |
---|
| 3316 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
| 3317 | $p->pparse('out','overlap'); |
---|
| 3318 | } |
---|
| 3319 | |
---|
| 3320 | function planner_participants($parts) |
---|
| 3321 | { |
---|
| 3322 | static $id2lid; |
---|
| 3323 | |
---|
| 3324 | $names = ''; |
---|
| 3325 | while (list($id,$status) = each($parts)) |
---|
| 3326 | { |
---|
| 3327 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
| 3328 | |
---|
| 3329 | if (!isset($id2lid[$id])) |
---|
| 3330 | { |
---|
| 3331 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
| 3332 | } |
---|
| 3333 | if (strlen($names)) |
---|
| 3334 | { |
---|
| 3335 | $names .= ",\n"; |
---|
| 3336 | } |
---|
| 3337 | $names .= $id2lid[$id]." ($status)"; |
---|
| 3338 | } |
---|
| 3339 | if($this->debug) |
---|
| 3340 | { |
---|
| 3341 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
| 3342 | } |
---|
| 3343 | return $names; |
---|
| 3344 | } |
---|
| 3345 | |
---|
| 3346 | function planner_category($ids) |
---|
| 3347 | { |
---|
| 3348 | static $cats; |
---|
| 3349 | if(!is_array($ids)) |
---|
| 3350 | { |
---|
| 3351 | if (strpos($ids,',')) |
---|
| 3352 | { |
---|
| 3353 | $id_array = explode(',',$ids); |
---|
| 3354 | } |
---|
| 3355 | else |
---|
| 3356 | { |
---|
| 3357 | $id_array[0] = $ids; |
---|
| 3358 | } |
---|
| 3359 | } |
---|
| 3360 | @reset($id_array); |
---|
| 3361 | $ret_val = Array(); |
---|
| 3362 | while(list($index,$id) = each($id_array)) |
---|
| 3363 | { |
---|
| 3364 | if (!isset($cats[$id])) |
---|
| 3365 | { |
---|
| 3366 | $cat_arr = $this->cat->return_single( $id ); |
---|
| 3367 | $cats[$id] = $cat_arr[0]; |
---|
| 3368 | $cats[$id]['color'] = strstr($cats[$id]['description'],'#'); |
---|
| 3369 | } |
---|
| 3370 | $ret_val[] = $cats[$id]; |
---|
| 3371 | } |
---|
| 3372 | return $ret_val; |
---|
| 3373 | } |
---|
| 3374 | |
---|
| 3375 | function week_header($month,$year,$display_name = False) |
---|
| 3376 | { |
---|
| 3377 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 3378 | |
---|
| 3379 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 3380 | $p->set_unknowns('remove'); |
---|
| 3381 | $p->set_file( |
---|
| 3382 | Array ( |
---|
| 3383 | 'month_header' => 'month_header.tpl' |
---|
| 3384 | ) |
---|
| 3385 | ); |
---|
| 3386 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 3387 | $p->set_block('month_header','column_title','column_title'); |
---|
| 3388 | |
---|
| 3389 | $var = Array( |
---|
| 3390 | 'bgcolor' => $this->theme['th_bg'], |
---|
| 3391 | 'font_color' => $this->theme['th_text'] |
---|
| 3392 | ); |
---|
| 3393 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 3394 | { |
---|
| 3395 | $var = Array( |
---|
| 3396 | 'bgcolor' => '', |
---|
| 3397 | 'font_color' => '' |
---|
| 3398 | ); |
---|
| 3399 | } |
---|
| 3400 | $p->set_var($var); |
---|
| 3401 | |
---|
| 3402 | $p->set_var('col_width','14'); |
---|
| 3403 | if($display_name == True) |
---|
| 3404 | { |
---|
| 3405 | $p->set_var('col_title',lang('name')); |
---|
| 3406 | $p->parse('column_header','column_title',True); |
---|
| 3407 | $p->set_var('col_width','12'); |
---|
| 3408 | } |
---|
| 3409 | |
---|
| 3410 | for($i=0;$i<7;$i++) |
---|
| 3411 | { |
---|
| 3412 | $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i])); |
---|
| 3413 | $p->parse('column_header','column_title',True); |
---|
| 3414 | } |
---|
| 3415 | return $p->fp('out','monthly_header'); |
---|
| 3416 | } |
---|
| 3417 | |
---|
| 3418 | function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 3419 | { |
---|
| 3420 | if($owner == 0) |
---|
| 3421 | { |
---|
| 3422 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 3423 | } |
---|
| 3424 | |
---|
| 3425 | $temp_owner = $this->bo->owner; |
---|
| 3426 | |
---|
| 3427 | $str = ''; |
---|
| 3428 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 3429 | $p->set_unknowns('keep'); |
---|
| 3430 | |
---|
| 3431 | $p->set_file( |
---|
| 3432 | Array( |
---|
| 3433 | 'month_header' => 'month_header.tpl', |
---|
| 3434 | 'month_day' => 'month_day.tpl' |
---|
| 3435 | ) |
---|
| 3436 | ); |
---|
| 3437 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 3438 | $p->set_block('month_header','month_column','month_column'); |
---|
| 3439 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 3440 | $p->set_block('month_day','day_event','day_event'); |
---|
| 3441 | $p->set_block('month_day','event','event'); |
---|
| 3442 | |
---|
| 3443 | $p->set_var('extra',''); |
---|
| 3444 | $p->set_var('col_width','14'); |
---|
| 3445 | if($display_name) |
---|
| 3446 | { |
---|
| 3447 | $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner)); |
---|
| 3448 | $p->parse('column_header','month_column',True); |
---|
| 3449 | $p->set_var('col_width','12'); |
---|
| 3450 | } |
---|
| 3451 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 3452 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 3453 | foreach($daily as $date => $day_params) |
---|
| 3454 | { |
---|
| 3455 | $year = (int)substr($date,0,4); |
---|
| 3456 | $month = (int)substr($date,4,2); |
---|
| 3457 | $day = (int)substr($date,6,2); |
---|
| 3458 | $var = Array( |
---|
| 3459 | 'column_data' => '', |
---|
| 3460 | 'extra' => '' |
---|
| 3461 | ); |
---|
| 3462 | $p->set_var($var); |
---|
| 3463 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 3464 | { |
---|
| 3465 | if ($day_params['new_event']) |
---|
| 3466 | { |
---|
| 3467 | $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">' |
---|
| 3468 | . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">' |
---|
| 3469 | . '</a>'; |
---|
| 3470 | $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>'; |
---|
| 3471 | } |
---|
| 3472 | else |
---|
| 3473 | { |
---|
| 3474 | $new_event_link = ''; |
---|
| 3475 | $day_number = $day; |
---|
| 3476 | } |
---|
| 3477 | |
---|
| 3478 | $var = Array( |
---|
| 3479 | 'extra' => $day_params['extra'], |
---|
| 3480 | 'new_event_link'=> $new_event_link, |
---|
| 3481 | 'day_number' => $day_number |
---|
| 3482 | ); |
---|
| 3483 | if($day_params['week']) |
---|
| 3484 | { |
---|
| 3485 | |
---|
| 3486 | //NDEE: style! m_w_table in month_day.tpl |
---|
| 3487 | // week-hilite |
---|
| 3488 | //$var['new_event_link'] .= '<font size="-2"> '. |
---|
| 3489 | $var['new_event_link'] .= ' '. |
---|
| 3490 | (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'"><span id="calendar_weekinfo" class="calendar_weekinfo">' .$day_params['week'].'</span></a>' : '<span id="calendar_weekinfo" class="calendar_weekinfo">'.$day_params['week'].'</span>'); |
---|
| 3491 | } |
---|
| 3492 | |
---|
| 3493 | $p->set_var($var); |
---|
| 3494 | |
---|
| 3495 | if(@$day_params['holidays']) |
---|
| 3496 | { |
---|
| 3497 | foreach($day_params['holidays'] as $key => $value) |
---|
| 3498 | { |
---|
| 3499 | $var = Array( |
---|
| 3500 | 'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br |
---|
| 3501 | ); |
---|
| 3502 | $this->output_template_array($p,'daily_events','event',$var); |
---|
| 3503 | } |
---|
| 3504 | } |
---|
| 3505 | |
---|
| 3506 | if($day_params['appts']) |
---|
| 3507 | { |
---|
| 3508 | $var = Array( |
---|
| 3509 | 'week_day_font_size' => '2', |
---|
| 3510 | 'events' => '' |
---|
| 3511 | ); |
---|
| 3512 | $p->set_var($var); |
---|
| 3513 | $events = $this->bo->cached_events[$date]; |
---|
| 3514 | foreach($events as $event) |
---|
| 3515 | { |
---|
| 3516 | if ($this->bo->rejected_no_show($event)) |
---|
| 3517 | { |
---|
| 3518 | continue; // user does not want to see rejected events |
---|
| 3519 | } |
---|
| 3520 | $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year)); |
---|
| 3521 | $p->parse('events','event',True); |
---|
| 3522 | $p->set_var('day_events',''); |
---|
| 3523 | } |
---|
| 3524 | } |
---|
| 3525 | $p->parse('daily_events','day_event',True); |
---|
| 3526 | $p->parse('column_data','month_daily',True); |
---|
| 3527 | $p->set_var('daily_events',''); |
---|
| 3528 | $p->set_var('events',''); |
---|
| 3529 | /* if($day_params['week']) |
---|
| 3530 | { |
---|
| 3531 | $var = Array( |
---|
| 3532 | 'week_day_font_size' => '-2', |
---|
| 3533 | 'events' => (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'">' .$day_params['week'].'</a>':$day_params['week']) |
---|
| 3534 | ); |
---|
| 3535 | $this->output_template_array($p,'column_data','day_event',$var); |
---|
| 3536 | $p->set_var('events',''); |
---|
| 3537 | } */ |
---|
| 3538 | } |
---|
| 3539 | $p->parse('column_header','month_column',True); |
---|
| 3540 | $p->set_var('column_data',''); |
---|
| 3541 | } |
---|
| 3542 | $this->bo->owner = $temp_owner; |
---|
| 3543 | return $p->fp('out','monthly_header'); |
---|
| 3544 | } |
---|
| 3545 | |
---|
[360] | 3546 | /***************************************************************************************/ |
---|
| 3547 | /*As funcoes abaixo |
---|
| 3548 | month_week_header() |
---|
| 3549 | month_display_week() |
---|
| 3550 | display_month_print() |
---|
| 3551 | month_day_of_week() - esta foi criada mas parte do codigo e de outra funcao da API (day_of_week()); |
---|
| 3552 | |
---|
| 3553 | foram duplicadas e modificadas para atender aas modificacoes do layout de impressao mensal da agenda de eventos; |
---|
| 3554 | TODO: otimizar o codigo |
---|
| 3555 | |
---|
| 3556 | Rommel Cysne |
---|
| 3557 | */ |
---|
| 3558 | |
---|
| 3559 | function month_week_header($month,$year,$display_name = False) |
---|
| 3560 | { |
---|
| 3561 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 3562 | $p->set_unknowns('remove'); |
---|
| 3563 | } |
---|
| 3564 | |
---|
| 3565 | |
---|
| 3566 | function month_day_of_week($year,$month,$day) |
---|
| 3567 | { |
---|
| 3568 | $dia = Array( |
---|
| 3569 | 0 => 'Domingo', |
---|
| 3570 | 1 => 'Segunda', |
---|
| 3571 | 2 => 'Terça', |
---|
| 3572 | 3 => 'Quarta', |
---|
| 3573 | 4 => 'Quinta', |
---|
| 3574 | 5 => 'Sexta', |
---|
| 3575 | 6 => 'Sábado' |
---|
| 3576 | ); |
---|
| 3577 | |
---|
| 3578 | if($month > 2) |
---|
| 3579 | { |
---|
| 3580 | $month -= 2; |
---|
| 3581 | } |
---|
| 3582 | else |
---|
| 3583 | { |
---|
| 3584 | $month += 10; |
---|
| 3585 | $year--; |
---|
| 3586 | } |
---|
| 3587 | $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); |
---|
| 3588 | |
---|
| 3589 | $month_day = ($day - 7 * floor($day / 7)); //retorna o numero do dia da semana (Ex: domingo eh dia 0, terca eh 2); |
---|
| 3590 | $weekday = $dia[$month_day]; //retorna o nome do dia da semana de acordo com seu numero; |
---|
| 3591 | |
---|
| 3592 | return ($weekday); |
---|
| 3593 | |
---|
| 3594 | } |
---|
| 3595 | |
---|
| 3596 | function month_display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 3597 | { |
---|
| 3598 | if($owner == 0) |
---|
| 3599 | { |
---|
| 3600 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 3601 | } |
---|
| 3602 | |
---|
| 3603 | $temp_owner = $this->bo->owner; |
---|
| 3604 | |
---|
| 3605 | $str = ''; |
---|
| 3606 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 3607 | $p->set_unknowns('keep'); |
---|
| 3608 | |
---|
| 3609 | $p->set_file( |
---|
| 3610 | Array( |
---|
| 3611 | 'month_header' => 'month_header_print.tpl', |
---|
| 3612 | 'month_day' => 'month_day_print.tpl' |
---|
| 3613 | ) |
---|
| 3614 | ); |
---|
| 3615 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 3616 | $p->set_block('month_header','month_column','month_column'); |
---|
| 3617 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 3618 | $p->set_block('month_day','day_event','day_event'); |
---|
| 3619 | $p->set_block('month_day','event','event'); |
---|
| 3620 | |
---|
| 3621 | $p->set_var('extra',''); |
---|
| 3622 | $p->set_var('col_width','14'); |
---|
[924] | 3623 | |
---|
[360] | 3624 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 3625 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
[924] | 3626 | |
---|
[360] | 3627 | foreach($daily as $date => $day_params) |
---|
| 3628 | { |
---|
| 3629 | $year = (int)substr($date,0,4); |
---|
| 3630 | $month = (int)substr($date,4,2); |
---|
| 3631 | $day = (int)substr($date,6,2); |
---|
| 3632 | $var = Array( |
---|
| 3633 | 'column_data' => '', |
---|
| 3634 | 'extra' => '' |
---|
| 3635 | ); |
---|
| 3636 | $p->set_var($var); |
---|
| 3637 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 3638 | { |
---|
[924] | 3639 | $new_event_link = ''; |
---|
| 3640 | $day_num = $day; |
---|
| 3641 | $dia_semana = $this->month_day_of_week($year,$month,$day_num); |
---|
| 3642 | $id_aux = mktime(0,0,0,$month,$day,$year); |
---|
| 3643 | $month_identifier = substr(lang(strftime("%B",$id_aux)),0,3); |
---|
| 3644 | $day_number = $month_identifier . " - " . $dia_semana . ", " . $day_num; |
---|
[360] | 3645 | |
---|
| 3646 | $var = Array( |
---|
| 3647 | 'extra' => $day_params['extra'], |
---|
| 3648 | 'new_event_link'=> $new_event_link, |
---|
| 3649 | 'day_number' => $day_number |
---|
| 3650 | ); |
---|
| 3651 | |
---|
| 3652 | $p->set_var($var); |
---|
| 3653 | |
---|
| 3654 | if($day_params['appts']) |
---|
| 3655 | { |
---|
| 3656 | $var = Array( |
---|
| 3657 | 'week_day_font_size' => '2', |
---|
| 3658 | 'events' => '' |
---|
| 3659 | ); |
---|
| 3660 | $p->set_var($var); |
---|
| 3661 | $events = $this->bo->cached_events[$date]; |
---|
| 3662 | foreach($events as $event) |
---|
| 3663 | { |
---|
| 3664 | if ($this->bo->rejected_no_show($event)) |
---|
| 3665 | { |
---|
| 3666 | continue; // user does not want to see rejected events |
---|
| 3667 | } |
---|
| 3668 | $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); |
---|
| 3669 | $p->parse('events','event',True); |
---|
| 3670 | $p->set_var('day_events',''); |
---|
| 3671 | } |
---|
| 3672 | } |
---|
| 3673 | $p->parse('daily_events','day_event',True); |
---|
| 3674 | $p->parse('column_data','month_daily',True); |
---|
| 3675 | $p->set_var('daily_events',''); |
---|
| 3676 | $p->set_var('events',''); |
---|
| 3677 | } |
---|
| 3678 | $p->parse('column_header','month_column',True); |
---|
| 3679 | $p->set_var('column_data',''); |
---|
| 3680 | } |
---|
| 3681 | $this->bo->owner = $temp_owner; |
---|
| 3682 | return $p->fp('out','monthly_header'); |
---|
| 3683 | |
---|
| 3684 | } |
---|
| 3685 | |
---|
| 3686 | function display_month_print($month,$year,$showyear,$owner=0) |
---|
| 3687 | { |
---|
| 3688 | if($this->debug) |
---|
| 3689 | { |
---|
| 3690 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 3691 | } |
---|
| 3692 | |
---|
[924] | 3693 | /* $this->bo->store_to_cache( |
---|
[360] | 3694 | Array( |
---|
| 3695 | 'syear' => $year, |
---|
| 3696 | 'smonth'=> $month, |
---|
| 3697 | 'sday' => 1 |
---|
| 3698 | ) |
---|
| 3699 | ); |
---|
[924] | 3700 | */ |
---|
| 3701 | $day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual; |
---|
| 3702 | $num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial; |
---|
[360] | 3703 | |
---|
| 3704 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
[924] | 3705 | // $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
[360] | 3706 | |
---|
[924] | 3707 | if($num_dias != 0) |
---|
| 3708 | { |
---|
| 3709 | //se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias; |
---|
| 3710 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month,$day_ini+$num_dias,$year))); |
---|
| 3711 | } |
---|
| 3712 | else |
---|
| 3713 | { |
---|
| 3714 | //se a qtde de dias nao for informada, a data final para impressao vai ate o fim do mes corrente; |
---|
| 3715 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 3716 | } |
---|
| 3717 | |
---|
| 3718 | if($day_ini != 0) |
---|
| 3719 | { |
---|
| 3720 | //o dia de inicio para impressao passa a ser o informado em $day_ini do mes corrente; |
---|
| 3721 | $start = mktime(0,0,0,$month,$day_ini,$year); |
---|
| 3722 | } |
---|
| 3723 | else |
---|
| 3724 | { |
---|
| 3725 | //se nao for informado o dia para inicio da impressao, esta comeca no dia 1 do mes corrente; |
---|
| 3726 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 3727 | } |
---|
| 3728 | //$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 15); |
---|
| 3729 | $start_d = (int)(date('Ymd',$start));//variavel auxiliar que recebe a data inicial de impressao no formato 'Ymd'; |
---|
| 3730 | $saux = (int)(substr($start_d,4,2));//variavel auxiliar que recebe o mes do inicio da impressao; |
---|
| 3731 | $eaux = (int)(substr($monthend,4,2)) + 1;//variavel auxiliar que recebe o mes do fim da impressao; |
---|
| 3732 | //A funcao store_to_cache devolve todos os eventos existentes de determinado usuario em um periodo de tempo |
---|
| 3733 | //especifico. Originalmente, na impressao mensal, esse periodo de tempo era o mes corrente exibido na tela. |
---|
| 3734 | //A mudanca consiste no fato de que uma nova variavel ($saux) e enviada com o mes de inicio do periodo |
---|
| 3735 | //atraves do indice 'smonth' e uma segunda variavel ($eaux) envia o mes final do periodo de tempo atraves |
---|
| 3736 | //do indice 'emonth'. Vide mais comentarios sobre esses valores em class.bocalendar.inc.php, |
---|
| 3737 | //function store_to_cache($params); |
---|
| 3738 | $this->bo->store_to_cache( |
---|
| 3739 | Array( |
---|
| 3740 | 'syear' => $year,//ano atual |
---|
| 3741 | 'smonth'=> $saux,//mes inicial |
---|
| 3742 | 'emonth'=> $eaux,//mes final |
---|
| 3743 | 'sday' => 1 |
---|
| 3744 | )); |
---|
[360] | 3745 | |
---|
| 3746 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 3747 | $p->set_unknowns('keep'); |
---|
| 3748 | |
---|
| 3749 | $p->set_file( |
---|
| 3750 | Array( |
---|
| 3751 | 'week' => 'month_day_print.tpl' |
---|
| 3752 | ) |
---|
| 3753 | ); |
---|
| 3754 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 3755 | $p->set_block('week','event','event'); |
---|
| 3756 | |
---|
| 3757 | $var = Array( |
---|
| 3758 | 'cols' => 1, |
---|
| 3759 | 'day_events'=> '' //$this->month_week_header($month,$year,False) |
---|
| 3760 | ); |
---|
| 3761 | // $this->output_template_array($p,'row','event',$var); |
---|
| 3762 | |
---|
| 3763 | $cellcolor = $this->theme['row_on']; |
---|
| 3764 | |
---|
| 3765 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 3766 | { |
---|
| 3767 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 3768 | $var = Array( |
---|
| 3769 | 'day_events' => $this->month_display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 3770 | ); |
---|
| 3771 | $this->output_template_array($p,'row','event',$var); |
---|
| 3772 | } |
---|
| 3773 | return $p->fp('out','m_w_table'); |
---|
| 3774 | } |
---|
| 3775 | |
---|
| 3776 | |
---|
| 3777 | /***************************************************************************************/ |
---|
| 3778 | |
---|
[2] | 3779 | function display_month($month,$year,$showyear,$owner=0) |
---|
| 3780 | { |
---|
| 3781 | if($this->debug) |
---|
| 3782 | { |
---|
| 3783 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 3784 | } |
---|
| 3785 | |
---|
| 3786 | $this->bo->store_to_cache( |
---|
| 3787 | Array( |
---|
| 3788 | 'syear' => $year, |
---|
| 3789 | 'smonth'=> $month, |
---|
| 3790 | 'sday' => 1 |
---|
| 3791 | ) |
---|
| 3792 | ); |
---|
| 3793 | |
---|
| 3794 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
| 3795 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 3796 | |
---|
| 3797 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 3798 | |
---|
| 3799 | if($this->debug) |
---|
| 3800 | { |
---|
| 3801 | echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n"; |
---|
| 3802 | echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n"; |
---|
| 3803 | } |
---|
| 3804 | |
---|
| 3805 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 3806 | $p->set_unknowns('keep'); |
---|
| 3807 | |
---|
| 3808 | $p->set_file( |
---|
| 3809 | Array( |
---|
| 3810 | 'week' => 'month_day.tpl' |
---|
| 3811 | ) |
---|
| 3812 | ); |
---|
| 3813 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 3814 | $p->set_block('week','event','event'); |
---|
| 3815 | |
---|
| 3816 | $var = Array( |
---|
[360] | 3817 | 'cols' => 1, |
---|
[2] | 3818 | 'day_events'=> $this->week_header($month,$year,False) |
---|
| 3819 | ); |
---|
| 3820 | $this->output_template_array($p,'row','event',$var); |
---|
| 3821 | |
---|
| 3822 | $cellcolor = $this->theme['row_on']; |
---|
| 3823 | |
---|
| 3824 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 3825 | { |
---|
| 3826 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 3827 | $var = Array( |
---|
| 3828 | 'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 3829 | ); |
---|
| 3830 | $this->output_template_array($p,'row','event',$var); |
---|
| 3831 | } |
---|
| 3832 | return $p->fp('out','m_w_table'); |
---|
| 3833 | } |
---|
| 3834 | |
---|
| 3835 | function display_weekly($params) |
---|
| 3836 | { |
---|
| 3837 | if(!is_array($params)) |
---|
| 3838 | { |
---|
| 3839 | $this->index(); |
---|
| 3840 | } |
---|
| 3841 | |
---|
| 3842 | $year = substr($params['date'],0,4); |
---|
| 3843 | $month = substr($params['date'],4,2); |
---|
| 3844 | $day = substr($params['date'],6,2); |
---|
| 3845 | $showyear = $params['showyear']; |
---|
| 3846 | $owners = $params['owners']; |
---|
| 3847 | |
---|
| 3848 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 3849 | $p->set_unknowns('keep'); |
---|
| 3850 | |
---|
| 3851 | $p->set_file( |
---|
| 3852 | Array( |
---|
| 3853 | 'week' => 'month_day.tpl' |
---|
| 3854 | ) |
---|
| 3855 | ); |
---|
| 3856 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 3857 | $p->set_block('week','event','event'); |
---|
| 3858 | |
---|
| 3859 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3860 | |
---|
| 3861 | $cellcolor = $this->theme['row_off']; |
---|
| 3862 | |
---|
| 3863 | $true_printer_friendly = $this->bo->printer_friendly; |
---|
| 3864 | |
---|
| 3865 | if(is_array($owners)) |
---|
| 3866 | { |
---|
| 3867 | $display_name = True; |
---|
| 3868 | $counter = count($owners); |
---|
| 3869 | $owners_array = $owners; |
---|
| 3870 | $cols = 8; |
---|
| 3871 | } |
---|
| 3872 | else |
---|
| 3873 | { |
---|
| 3874 | $display_name = False; |
---|
| 3875 | $counter = 1; |
---|
| 3876 | $owners_array[0] = $owners; |
---|
| 3877 | $cols = 7; |
---|
| 3878 | } |
---|
| 3879 | $var = Array( |
---|
| 3880 | 'cols' => $cols, |
---|
| 3881 | 'day_events' => $this->week_header($month,$year,$display_name) |
---|
| 3882 | ); |
---|
| 3883 | $this->output_template_array($p,'row','event',$var); |
---|
| 3884 | |
---|
| 3885 | $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3886 | $tstop = $tstart + 604800; |
---|
| 3887 | $original_owner = $this->bo->so->owner; |
---|
| 3888 | for($i=0;$i<$counter;$i++) |
---|
| 3889 | { |
---|
| 3890 | $this->bo->so->owner = $owners_array[$i]; |
---|
| 3891 | $this->bo->so->open_box($owners_array[$i]); |
---|
| 3892 | $this->bo->store_to_cache( |
---|
| 3893 | Array( |
---|
| 3894 | 'syear' => date('Y',$tstart), |
---|
| 3895 | 'smonth' => date('m',$tstart), |
---|
| 3896 | 'sday' => date('d',$tstart), |
---|
| 3897 | 'eyear' => date('Y',$tstop), |
---|
| 3898 | 'emonth' => date('m',$tstop), |
---|
| 3899 | 'eday' => date('d',$tstop) |
---|
| 3900 | ) |
---|
| 3901 | ); |
---|
| 3902 | $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$owners_array[$i])); |
---|
| 3903 | $p->parse('row','event',True); |
---|
| 3904 | } |
---|
| 3905 | $this->bo->so->owner = $original_owner; |
---|
| 3906 | $this->bo->printer_friendly = $true_printer_friendly; |
---|
| 3907 | return $p->fp('out','m_w_table'); |
---|
| 3908 | } |
---|
| 3909 | |
---|
| 3910 | function view_event($event,$alarms=False) |
---|
| 3911 | { |
---|
| 3912 | if((!$event['participants'][$this->bo->owner] && !$this->bo->check_perms(PHPGW_ACL_READ,$event))) |
---|
| 3913 | { |
---|
| 3914 | return False; |
---|
| 3915 | } |
---|
| 3916 | |
---|
| 3917 | $p = &$GLOBALS['phpgw']->template; |
---|
| 3918 | |
---|
| 3919 | $p->set_file( |
---|
| 3920 | Array( |
---|
| 3921 | 'view' => 'view.tpl' |
---|
| 3922 | ) |
---|
| 3923 | ); |
---|
| 3924 | $p->set_block('view','view_event','view_event'); |
---|
| 3925 | $p->set_block('view','list','list'); |
---|
| 3926 | $p->set_block('view','hr','hr'); |
---|
| 3927 | |
---|
| 3928 | $vars = $this->bo->event2array($event); |
---|
| 3929 | |
---|
| 3930 | $vars['title']['tr_color'] = $this->theme['th_bg']; |
---|
| 3931 | |
---|
| 3932 | foreach($vars['participants']['data'] as $user => $str) |
---|
| 3933 | { |
---|
[21] | 3934 | if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && ereg('^(.*) \((.*)\)$',$str,$parts)) |
---|
[2] | 3935 | { |
---|
| 3936 | $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; |
---|
| 3937 | } |
---|
| 3938 | } |
---|
| 3939 | $vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']); |
---|
| 3940 | foreach($vars as $var) |
---|
| 3941 | { |
---|
| 3942 | if (strlen($var['data'])) |
---|
| 3943 | { |
---|
| 3944 | $this->output_template_array($p,'row','list',$var); |
---|
| 3945 | } |
---|
| 3946 | } |
---|
| 3947 | |
---|
| 3948 | if($alarms && count($event['alarm'])) |
---|
| 3949 | { |
---|
| 3950 | $p->set_var('th_bg',$this->theme['th_bg']); |
---|
| 3951 | $p->set_var('hr_text',lang('Alarms')); |
---|
| 3952 | $p->parse('row','hr',True); |
---|
| 3953 | foreach($event['alarm'] as $key => $alarm) |
---|
| 3954 | { |
---|
[22] | 3955 | if (($this->bo->so->owner == $alarm['owner']) || ($this->bo->so->cal->event['owner'] == $this->bo->so->owner)) // Show only alert from user who is requesting or alert owner |
---|
[21] | 3956 | { |
---|
| 3957 | $icon = '<img src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled':'disabled')).'" width="13" height="13">'; |
---|
[625] | 3958 | $var = Array( |
---|
[21] | 3959 | 'field' => $icon.$GLOBALS['phpgw']->common->show_date($alarm['time']), |
---|
| 3960 | 'data' => lang('Email Notification for %1',$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner'])) |
---|
| 3961 | ); |
---|
| 3962 | $this->output_template_array($p,'row','list',$var); |
---|
| 3963 | } |
---|
[2] | 3964 | } |
---|
| 3965 | } |
---|
| 3966 | return True; |
---|
| 3967 | } |
---|
| 3968 | |
---|
| 3969 | function nm_on_off() |
---|
| 3970 | { |
---|
| 3971 | if($GLOBALS['phpgw']->nextmatchs->alternate_row_color() == $this->theme['row_on']) |
---|
| 3972 | { |
---|
| 3973 | return '_on'; |
---|
| 3974 | } |
---|
| 3975 | return '_off'; |
---|
| 3976 | } |
---|
| 3977 | |
---|
| 3978 | function slot_num($time,$set_day_start=0,$set_day_end=0) |
---|
| 3979 | { |
---|
| 3980 | static $day_start, $day_end, $interval=0; |
---|
| 3981 | |
---|
| 3982 | if ($set_day_start) $day_start = $set_day_start; |
---|
| 3983 | if ($set_day_end) $day_end = $set_day_end; |
---|
| 3984 | if (!$interval) $interval = 60*$this->bo->prefs['calendar']['interval']; |
---|
| 3985 | |
---|
| 3986 | if ($time > $day_end) |
---|
| 3987 | { |
---|
| 3988 | $time = $day_end; |
---|
| 3989 | } |
---|
| 3990 | $slot = (int)(($time - $day_start) / $interval); |
---|
| 3991 | |
---|
| 3992 | return $slot < 0 ? 0 : 1+$slot; |
---|
| 3993 | } |
---|
| 3994 | |
---|
| 3995 | function print_day($params) |
---|
| 3996 | { |
---|
| 3997 | if(!is_array($params)) |
---|
| 3998 | { |
---|
| 3999 | $this->index(); |
---|
| 4000 | } |
---|
| 4001 | |
---|
| 4002 | print_debug('in print_day()'); |
---|
| 4003 | |
---|
| 4004 | $this->bo->store_to_cache( |
---|
| 4005 | Array( |
---|
| 4006 | 'syear' => $params['year'], |
---|
| 4007 | 'smonth' => $params['month'], |
---|
| 4008 | 'sday' => $params['day'], |
---|
| 4009 | 'eyear' => $params['year'], |
---|
| 4010 | 'emonth' => $params['month'], |
---|
| 4011 | 'eday' => $params['day'] |
---|
| 4012 | ) |
---|
| 4013 | ); |
---|
| 4014 | |
---|
| 4015 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4016 | $p->set_unknowns('keep'); |
---|
| 4017 | |
---|
| 4018 | $tpl = 'day_cal.tpl'; |
---|
| 4019 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
| 4020 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
| 4021 | { |
---|
| 4022 | $tpl = 'day_list.tpl'; |
---|
| 4023 | } |
---|
| 4024 | $templates = Array( |
---|
| 4025 | 'day_cal' => $tpl |
---|
| 4026 | ); |
---|
| 4027 | |
---|
| 4028 | $p->set_file($templates); |
---|
| 4029 | $p->set_block('day_cal','day','day'); |
---|
| 4030 | $p->set_block('day_cal','day_row','day_row'); |
---|
| 4031 | $p->set_block('day_cal','day_event_on','day_event_on'); |
---|
| 4032 | $p->set_block('day_cal','day_event_off','day_event_off'); |
---|
| 4033 | $p->set_block('day_cal','day_event_holiday','day_event_holiday'); |
---|
| 4034 | $p->set_block('day_cal','day_time','day_time'); |
---|
| 4035 | |
---|
| 4036 | $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); |
---|
| 4037 | |
---|
| 4038 | $day_start = mktime((int)($this->bo->prefs['calendar']['workdaystarts']),0,0,$params['month'],$params['day'],$params['year']); |
---|
| 4039 | $day_end = mktime((int)($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']); |
---|
| 4040 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
| 4041 | print_debug('Date to Eval',$date_to_eval); |
---|
| 4042 | $events_to_show = array(); |
---|
| 4043 | if($daily[$date_to_eval]['appts']) |
---|
| 4044 | { |
---|
| 4045 | $events = $this->bo->cached_events[$date_to_eval]; |
---|
| 4046 | print_debug('Date',$date_to_eval); |
---|
| 4047 | print_debug('Count',count($events)); |
---|
| 4048 | foreach($events as $event) |
---|
| 4049 | { |
---|
| 4050 | if ($this->bo->rejected_no_show($event)) |
---|
| 4051 | { |
---|
| 4052 | continue; // user does not want to see rejected events |
---|
| 4053 | } |
---|
| 4054 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
| 4055 | { |
---|
| 4056 | $this->bo->set_recur_date($event,$date_to_eval); |
---|
| 4057 | } |
---|
| 4058 | $events_to_show[] = array( |
---|
| 4059 | 'starttime' => $this->bo->maketime($event['start']), |
---|
| 4060 | 'endtime' => $this->bo->maketime($event['end']), |
---|
| 4061 | 'content' => $this->link_to_entry($event,$params['month'],$params['day'],$params['year']) |
---|
| 4062 | ); |
---|
| 4063 | } |
---|
| 4064 | } |
---|
| 4065 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
| 4066 | $other = $GLOBALS['phpgw']->hooks->process(array( |
---|
| 4067 | 'location' => 'calendar_include_events', |
---|
| 4068 | 'year' => $params['year'], |
---|
| 4069 | 'month' => $params['month'], |
---|
| 4070 | 'day' => $params['day'], |
---|
| 4071 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
| 4072 | )); |
---|
| 4073 | |
---|
| 4074 | if (is_array($other)) |
---|
| 4075 | { |
---|
| 4076 | foreach($other as $evts) |
---|
| 4077 | { |
---|
| 4078 | if (is_array($evts)) |
---|
| 4079 | { |
---|
| 4080 | $events_to_show = array_merge($events_to_show,$evts); |
---|
| 4081 | } |
---|
| 4082 | } |
---|
| 4083 | usort($events_to_show,create_function('$a,$b','return $a[\'starttime\']-$b[\'starttime\'];')); |
---|
| 4084 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
| 4085 | } |
---|
| 4086 | |
---|
| 4087 | if (count($events_to_show)) |
---|
| 4088 | { |
---|
| 4089 | $last_slot_end = -1; |
---|
| 4090 | foreach($events_to_show as $event) |
---|
| 4091 | { |
---|
| 4092 | $slot = $this->slot_num($event['starttime'],$day_start,$day_end); |
---|
| 4093 | $slot_end = isset($event['endtime']) ? $this->slot_num($event['endtime']-1) : $slot; // -1 to not occupy eg. the 18.00 slot for a 17-18h date |
---|
| 4094 | |
---|
| 4095 | if ($slot <= $last_slot_end) |
---|
| 4096 | { |
---|
| 4097 | $slot = $last_slot; |
---|
| 4098 | $slot_end = max($last_slot_end,$slot_end); |
---|
| 4099 | } |
---|
| 4100 | $rows[$slot] .= $event['content']; |
---|
| 4101 | |
---|
| 4102 | print_debug('slot',$slot); |
---|
| 4103 | print_debug('row',$rows[$slot]); |
---|
| 4104 | |
---|
| 4105 | $row_span[$slot] = 1 + $slot_end - $slot; |
---|
| 4106 | |
---|
| 4107 | $last_slot = $slot; |
---|
| 4108 | $last_slot_end = $slot_end; |
---|
| 4109 | print_debug('Time',$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['start']) - $GLOBALS['phpgw']->datetime->tz_offset).' - '.$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['end']) - $GLOBALS['phpgw']->datetime->tz_offset)); |
---|
| 4110 | print_debug('Slot',$slot); |
---|
| 4111 | } |
---|
| 4112 | //echo "rows=<pre>"; print_r($rows); echo "<br>row_span="; print_r($row_span); echo "</pre>\n"; |
---|
| 4113 | } |
---|
| 4114 | $holiday_names = $daily[$date_to_eval]['holidays']; |
---|
| 4115 | if(!$holiday_names) |
---|
| 4116 | { |
---|
| 4117 | $row_to_print = $this->nm_on_off(); |
---|
| 4118 | } |
---|
| 4119 | else |
---|
| 4120 | { |
---|
| 4121 | $row_to_print = '_holiday'; |
---|
| 4122 | foreach($holiday_names as $name) |
---|
| 4123 | { |
---|
| 4124 | $rows[0] = '<center>'.$name.'</center>' . $rows[0]; |
---|
| 4125 | } |
---|
| 4126 | } |
---|
| 4127 | $last_slot = $this->slot_num($day_end,$day_start,$day_end); |
---|
| 4128 | $rowspan = 0; |
---|
| 4129 | for ($slot = 0; $slot <= $last_slot; ++$slot) |
---|
| 4130 | { |
---|
| 4131 | $p->set_var('extras',''); |
---|
| 4132 | if ($rowspan > 1) |
---|
| 4133 | { |
---|
| 4134 | $p->set_var('event',''); |
---|
| 4135 | $rowspan--; |
---|
| 4136 | } |
---|
| 4137 | elseif (!isset($rows[$slot])) |
---|
| 4138 | { |
---|
| 4139 | $p->set_var('event',' '); |
---|
| 4140 | $row_to_print = $this->nm_on_off(); |
---|
| 4141 | $p->parse('event','day_event'.$row_to_print); |
---|
| 4142 | } |
---|
| 4143 | else |
---|
| 4144 | { |
---|
| 4145 | $rowspan = (int)$row_span[$slot]; |
---|
| 4146 | if ($rowspan > 1) |
---|
| 4147 | { |
---|
| 4148 | $p->set_var('extras',' rowspan="'.$rowspan.'"'); |
---|
| 4149 | } |
---|
| 4150 | $p->set_var('event',$rows[$slot]); |
---|
| 4151 | $row_to_print = $this->nm_on_off(); |
---|
| 4152 | $p->parse('event','day_event'.$row_to_print); |
---|
| 4153 | } |
---|
| 4154 | $open_link = $close_link = ''; |
---|
| 4155 | $time = ' '; |
---|
| 4156 | |
---|
| 4157 | if (0 < $slot && $slot < $last_slot) // normal time-slot not before or after day_start/end |
---|
| 4158 | { |
---|
| 4159 | $time = $day_start + ($slot-1) * 60 * $this->bo->prefs['calendar']['interval']; |
---|
| 4160 | $hour = date('H',$time); |
---|
| 4161 | $min = date('i',$time); |
---|
| 4162 | $time = $GLOBALS['phpgw']->common->formattime($hour,$min); |
---|
| 4163 | |
---|
| 4164 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 4165 | { |
---|
| 4166 | $open_link = ' <a href="'.$this->page('add',"&date=$date_to_eval&hour=$hour&minute=$min").'">'; |
---|
| 4167 | $close_link = '</a> '; |
---|
| 4168 | } |
---|
| 4169 | } |
---|
| 4170 | $p->set_var(Array( |
---|
| 4171 | 'open_link' => $open_link, |
---|
| 4172 | 'time' => $time, |
---|
| 4173 | 'close_link' => $close_link, |
---|
| 4174 | 'tr_color' => '' // dummy to stop output_template_array to set it |
---|
| 4175 | )); |
---|
| 4176 | $p->parse('time','day_time'); |
---|
| 4177 | |
---|
| 4178 | $p->parse('row','day_row',True); |
---|
| 4179 | } |
---|
| 4180 | return $p->fp('out','day'); |
---|
| 4181 | } // end function |
---|
| 4182 | |
---|
| 4183 | function timematrix($param) |
---|
| 4184 | { |
---|
| 4185 | if(!is_array($param)) |
---|
| 4186 | { |
---|
| 4187 | $this->index(); |
---|
| 4188 | } |
---|
| 4189 | |
---|
| 4190 | $date = $param['date']; |
---|
| 4191 | $starttime = $param['starttime']; |
---|
| 4192 | $endtime = $param['endtime']; |
---|
| 4193 | $participants = $param['participants']; |
---|
| 4194 | foreach($participants as $part => $nul) |
---|
| 4195 | { |
---|
| 4196 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
| 4197 | // Much better for processor :) |
---|
| 4198 | $participants_id[] .= $part; |
---|
| 4199 | } |
---|
| 4200 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
| 4201 | |
---|
| 4202 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
| 4203 | { |
---|
| 4204 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
| 4205 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
| 4206 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 4207 | } |
---|
| 4208 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
| 4209 | $interval = (int)(60 / $increment); |
---|
| 4210 | |
---|
| 4211 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
| 4212 | |
---|
| 4213 | $str = '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
| 4214 | . ', '.$this->bo->long_date($date).'<br>' |
---|
| 4215 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((24 * $interval) + 1).'">' |
---|
| 4216 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
| 4217 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
| 4218 | for($i=0;$i<24;$i++) |
---|
| 4219 | { |
---|
| 4220 | for($j=0;$j<$interval;$j++) |
---|
| 4221 | { |
---|
| 4222 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
| 4223 | |
---|
| 4224 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'"><font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' |
---|
| 4225 | . '<a href="'.$this->page('add','&date='.$date['full'].'&hour='.$i.'&minute='.($increment * $j))."\" onMouseOver=\"window.status='".$i.':'.(($increment * $j)<=9?'0':'').($increment * $j)."'; return true;\">" |
---|
| 4226 | . $k."</a> </font></td>\n"; |
---|
| 4227 | } |
---|
| 4228 | } |
---|
| 4229 | $str .= '</tr>' |
---|
| 4230 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
| 4231 | if(!$endtime) |
---|
| 4232 | { |
---|
| 4233 | $endtime = $starttime; |
---|
| 4234 | } |
---|
| 4235 | $owner = $this->bo->owner; |
---|
| 4236 | foreach($participants as $part => $fullname) |
---|
| 4237 | { |
---|
| 4238 | $str .= '<tr align="center">' |
---|
| 4239 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
| 4240 | |
---|
| 4241 | $this->bo->cached_events = Array(); |
---|
| 4242 | $this->bo->so->owner = $part; |
---|
| 4243 | $this->bo->so->open_box($part); |
---|
| 4244 | $this->bo->store_to_cache( |
---|
| 4245 | Array( |
---|
| 4246 | 'syear' => $date['year'], |
---|
| 4247 | 'smonth'=> $date['month'], |
---|
| 4248 | 'sday' => $date['day'], |
---|
| 4249 | 'eyear' => 0, |
---|
| 4250 | 'emonth'=> 0, |
---|
| 4251 | 'eday' => $date['day'] + 1 |
---|
| 4252 | ) |
---|
| 4253 | ); |
---|
| 4254 | |
---|
| 4255 | if(!$this->bo->cached_events[$date['full']]) |
---|
| 4256 | { |
---|
| 4257 | for($j=0;$j<24;$j++) |
---|
| 4258 | { |
---|
| 4259 | for($k=0;$k<$interval;$k++) |
---|
| 4260 | { |
---|
| 4261 | $str .= '<td height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
| 4262 | } |
---|
| 4263 | $str .= "\n"; |
---|
| 4264 | } |
---|
| 4265 | } |
---|
| 4266 | else |
---|
| 4267 | { |
---|
| 4268 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
| 4269 | for($h=0;$h<24;$h++) |
---|
| 4270 | { |
---|
| 4271 | $hour = $h * 10000; |
---|
| 4272 | for($m=0;$m<$interval;$m++) |
---|
| 4273 | { |
---|
| 4274 | $index = ($hour + (($m * $increment) * 100)); |
---|
| 4275 | switch($time_slice[$index]['marker']) |
---|
| 4276 | { |
---|
| 4277 | case ' ': |
---|
| 4278 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
| 4279 | $extra = ''; |
---|
| 4280 | break; |
---|
| 4281 | case '-': |
---|
| 4282 | $time_slice[$index]['color'] = $this->theme['bg01']; |
---|
| 4283 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
| 4284 | $extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
| 4285 | break; |
---|
| 4286 | } |
---|
| 4287 | $str .= '<td bgcolor="'.$time_slice[$index]['color'].'" color="#999999"'.$extra.'><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$time_slice[$index]['marker'].'</font></td>'; |
---|
| 4288 | } |
---|
| 4289 | $str .= "\n"; |
---|
| 4290 | } |
---|
| 4291 | } |
---|
| 4292 | $str .= '</tr>' |
---|
| 4293 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
| 4294 | } |
---|
| 4295 | $this->bo->owner = $owner; |
---|
| 4296 | $this->bo->so->owner = $owner; |
---|
| 4297 | $this->bo->so->open_box($owner); |
---|
| 4298 | return $str.'</table></center>'."\n"; |
---|
| 4299 | } |
---|
| 4300 | |
---|
| 4301 | function get_response($cal_id) |
---|
| 4302 | { |
---|
| 4303 | $p = &$GLOBALS['phpgw']->template; |
---|
| 4304 | $p->set_file( |
---|
| 4305 | Array( |
---|
| 4306 | 'form_button' => 'form_button_script.tpl' |
---|
| 4307 | ) |
---|
| 4308 | ); |
---|
| 4309 | |
---|
| 4310 | $ev = $this->bo->get_cached_event(); |
---|
| 4311 | $response_choices = Array( |
---|
| 4312 | ACCEPTED => lang('Accept'), |
---|
| 4313 | REJECTED => lang('Reject'), |
---|
| 4314 | TENTATIVE => lang('Tentative') |
---|
| 4315 | ); |
---|
| 4316 | $str = ''; |
---|
| 4317 | while(list($param,$text) = each($response_choices)) |
---|
| 4318 | { |
---|
| 4319 | $var = Array( |
---|
| 4320 | 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param), |
---|
| 4321 | 'action_text_button' => ' '.$text.' ', |
---|
| 4322 | 'action_confirm_button' => '', |
---|
| 4323 | 'action_extra_field' => '' |
---|
| 4324 | ); |
---|
| 4325 | $p->set_var($var); |
---|
| 4326 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
| 4327 | } |
---|
| 4328 | if ($this->bo->return_to) |
---|
| 4329 | { |
---|
| 4330 | $var = Array( |
---|
| 4331 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 4332 | 'action_text_button' => lang('cancel'), |
---|
| 4333 | 'action_confirm_button' => '', |
---|
| 4334 | 'action_extra_field' => '' |
---|
| 4335 | ); |
---|
| 4336 | $p->set_var($var); |
---|
| 4337 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
| 4338 | } |
---|
| 4339 | $str = '<td><b>'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).":</b></td>\n".$str; |
---|
| 4340 | |
---|
| 4341 | return '<table width="100%"><tr align="center">'."\n".$str.'</tr></table>'."\n"; |
---|
| 4342 | } |
---|
| 4343 | |
---|
| 4344 | function accounts_popup() |
---|
| 4345 | { |
---|
| 4346 | $GLOBALS['phpgw']->accounts->accounts_popup('calendar'); |
---|
| 4347 | |
---|
| 4348 | } |
---|
| 4349 | |
---|
| 4350 | function edit_form($param) |
---|
| 4351 | { |
---|
| 4352 | if(!is_array($param)) |
---|
| 4353 | { |
---|
| 4354 | $this->index(); |
---|
| 4355 | } |
---|
| 4356 | |
---|
| 4357 | if(isset($param['event'])) |
---|
| 4358 | { |
---|
| 4359 | $event = $param['event']; |
---|
| 4360 | } |
---|
| 4361 | |
---|
| 4362 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
| 4363 | |
---|
| 4364 | // $sb = CreateObject('phpgwapi.sbox'); |
---|
| 4365 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 4366 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
| 4367 | |
---|
| 4368 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 4369 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 4370 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 4371 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
[204] | 4372 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); |
---|
[663] | 4373 | if ($param['plain'] != "True"){ |
---|
| 4374 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 4375 | } |
---|
| 4376 | else{ |
---|
| 4377 | $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; |
---|
| 4378 | $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; |
---|
| 4379 | } |
---|
[2] | 4380 | |
---|
| 4381 | $p = &$GLOBALS['phpgw']->template; |
---|
| 4382 | $p->set_file( |
---|
| 4383 | Array( |
---|
| 4384 | 'edit' => 'edit.tpl', |
---|
| 4385 | 'form_button' => 'form_button_script.tpl' |
---|
| 4386 | ) |
---|
| 4387 | ); |
---|
| 4388 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
| 4389 | $p->set_block('edit','list','list'); |
---|
| 4390 | $p->set_block('edit','hr','hr'); |
---|
| 4391 | |
---|
| 4392 | $vars = Array( |
---|
| 4393 | 'font' => $this->theme['font'], |
---|
| 4394 | 'bg_color' => $this->theme['bg_text'], |
---|
| 4395 | 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), |
---|
| 4396 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), |
---|
| 4397 | 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" |
---|
| 4398 | . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" |
---|
| 4399 | . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" |
---|
| 4400 | . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": |
---|
| 4401 | (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) |
---|
| 4402 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
| 4403 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
| 4404 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') |
---|
| 4405 | ); |
---|
| 4406 | |
---|
| 4407 | $p->set_var($vars); |
---|
| 4408 | |
---|
| 4409 | // Brief Description |
---|
| 4410 | $var['title'] = Array( |
---|
| 4411 | 'tr_color' => $this->theme['th_bg'], |
---|
| 4412 | 'field' => lang('Title'), |
---|
| 4413 | 'data' => '<input name="cal[title]" size="45" maxlength="80" value="'.$event['title'].'">' |
---|
| 4414 | ); |
---|
| 4415 | |
---|
| 4416 | // Full Description |
---|
| 4417 | $var['description'] = Array( |
---|
| 4418 | 'field' => lang('Full Description'), |
---|
| 4419 | 'data' => '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' |
---|
| 4420 | ); |
---|
| 4421 | |
---|
| 4422 | // Display Categories |
---|
| 4423 | if(strpos($event['category'],',')) |
---|
| 4424 | { |
---|
| 4425 | $temp_cats = explode(',',$event['category']); |
---|
| 4426 | @reset($temp_cats); |
---|
| 4427 | while(list($key,$value) = each($temp_cats)) |
---|
| 4428 | { |
---|
| 4429 | $check_cats[] = (int)$value; |
---|
| 4430 | } |
---|
| 4431 | } |
---|
| 4432 | elseif($event['category']) |
---|
| 4433 | { |
---|
| 4434 | $check_cats[] = (int)$event['category']; |
---|
| 4435 | } |
---|
| 4436 | else |
---|
| 4437 | { |
---|
| 4438 | $check_cats[] = 0; |
---|
| 4439 | } |
---|
| 4440 | $var['category'] = Array( |
---|
| 4441 | 'field' => lang('Category'), |
---|
[583] | 4442 | 'data' => '<select name="categories[]" onchange="javascript:updateTitleField(this)" multiple size="5">'.$this->cat->formated_list('select','all',$check_cats,True).'</select>' |
---|
[2] | 4443 | ); |
---|
| 4444 | |
---|
| 4445 | // Location |
---|
| 4446 | $var['location'] = Array( |
---|
| 4447 | 'field' => lang('Location'), |
---|
| 4448 | 'data' => '<input name="cal[location]" size="45" maxlength="255" value="'.$event['location'].'">' |
---|
| 4449 | ); |
---|
| 4450 | |
---|
| 4451 | // Date |
---|
| 4452 | |
---|
| 4453 | $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4454 | $var['startdate'] = Array( |
---|
| 4455 | 'field' => lang('Start Date'), |
---|
| 4456 | /* |
---|
| 4457 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 4458 | $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), |
---|
| 4459 | $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), |
---|
| 4460 | $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')) |
---|
| 4461 | ) |
---|
| 4462 | */ |
---|
| 4463 | 'data' => $jscal->input('start[str]',$start) |
---|
| 4464 | ); |
---|
| 4465 | |
---|
| 4466 | // Time |
---|
| 4467 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
| 4468 | { |
---|
| 4469 | $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
| 4470 | . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
| 4471 | } |
---|
| 4472 | $var['starttime'] = Array( |
---|
| 4473 | 'field' => lang('Start Time'), |
---|
| 4474 | 'data' => '<input name="start[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$str |
---|
| 4475 | ); |
---|
| 4476 | |
---|
| 4477 | // End Date |
---|
| 4478 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4479 | $var['enddate'] = Array( |
---|
| 4480 | 'field' => lang('End Date'), |
---|
| 4481 | /* |
---|
| 4482 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 4483 | $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), |
---|
| 4484 | $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), |
---|
| 4485 | $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')) |
---|
| 4486 | ) |
---|
| 4487 | */ |
---|
| 4488 | 'data' => $jscal->input('end[str]',$end) |
---|
| 4489 | ); |
---|
| 4490 | |
---|
| 4491 | // End Time |
---|
| 4492 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
| 4493 | { |
---|
| 4494 | $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
| 4495 | . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
| 4496 | } |
---|
| 4497 | $var['endtime'] = Array( |
---|
| 4498 | 'field' => lang('End Time'), |
---|
| 4499 | 'data' => '<input name="end[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$str |
---|
| 4500 | ); |
---|
| 4501 | |
---|
| 4502 | // Priority |
---|
| 4503 | $var['priority'] = Array( |
---|
| 4504 | 'field' => lang('Priority'), |
---|
| 4505 | 'data' => $sb->getPriority('cal[priority]',$event['priority']) |
---|
| 4506 | ); |
---|
| 4507 | |
---|
[583] | 4508 | // Access |
---|
[2] | 4509 | $var['access'] = Array( |
---|
[935] | 4510 | 'field' => lang('Type'), |
---|
| 4511 | 'data' => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.($event['type'] == 'H'?'DISABLED':'').'><option value="normal">'.lang('Normal').'</option><option value="private" '.(!$event['public']?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.(!$event['public']?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>' |
---|
[583] | 4512 | ); //event['public'] |
---|
[2] | 4513 | |
---|
[935] | 4514 | // Participants |
---|
[2] | 4515 | if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) |
---|
| 4516 | { |
---|
| 4517 | switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection']) |
---|
| 4518 | { |
---|
| 4519 | case 'popup': |
---|
| 4520 | while (is_array($event['participants']) && list($id) = each($event['participants'])) |
---|
| 4521 | { |
---|
| 4522 | if($id != (int)$event['owner']) |
---|
| 4523 | { |
---|
| 4524 | $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) |
---|
| 4525 | .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n"; |
---|
| 4526 | } |
---|
| 4527 | } |
---|
| 4528 | $var['participants'] = array |
---|
| 4529 | ( |
---|
| 4530 | 'field' => '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n" |
---|
| 4531 | . '<input type="hidden" name="accountid" value="' . $accountid . '">', |
---|
| 4532 | 'data' => "\n".' <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>' |
---|
| 4533 | ); |
---|
| 4534 | break; |
---|
| 4535 | default: |
---|
| 4536 | foreach($event['participants'] as $id => $participant) |
---|
| 4537 | { |
---|
| 4538 | if (($id != $event['owner']) && ($id != "")) |
---|
| 4539 | { |
---|
| 4540 | $GLOBALS['phpgw']->accounts->get_account_name($id, $lid, $fname, $lname); |
---|
| 4541 | $cn = $fname.' '.$lname; |
---|
| 4542 | $option = ' <option value="' . $id.$participant . '">'.$cn.'</option>'."\n"; |
---|
| 4543 | $str .= $option; |
---|
| 4544 | } |
---|
| 4545 | } |
---|
| 4546 | $str = utf8_decode($str); |
---|
| 4547 | $footer_ext_participantes = '<br> '.lang("The email addresses must be separated by ','"); |
---|
| 4548 | |
---|
| 4549 | $var['participants'] = array |
---|
| 4550 | ( |
---|
| 4551 | 'field' => lang('Participants'), |
---|
| 4552 | 'data' => " |
---|
| 4553 | <table width='100%' border='0'> |
---|
| 4554 | <tr> |
---|
| 4555 | <td width='30%'> |
---|
| 4556 | <center>Participantes</center> |
---|
| 4557 | </td> |
---|
| 4558 | <td width='8%' > </td> |
---|
| 4559 | <td width='40%'> </td> |
---|
| 4560 | </tr> |
---|
| 4561 | <tr> |
---|
| 4562 | <td width='30%'> |
---|
| 4563 | <center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center> |
---|
| 4564 | </td> |
---|
| 4565 | <td width='8%'> |
---|
| 4566 | <center> |
---|
| 4567 | <table width='100%' border='0'> |
---|
| 4568 | <tr height='5'><td> </td></tr> |
---|
| 4569 | <tr><td align='center'> |
---|
| 4570 | <button type='button' onClick='javascript:openListUsers(340,533, " |
---|
| 4571 | .$event['owner']. |
---|
[933] | 4572 | ")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' > Adicionar</button> |
---|
[2] | 4573 | </td> |
---|
| 4574 | </tr> |
---|
| 4575 | <tr height='5'><td> </td></tr> |
---|
| 4576 | <tr><td align='center'> |
---|
[933] | 4577 | <button type='button' onClick='javascript:rem()'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/rem.png' style='vertical-align: middle;' > Remover</button> |
---|
[2] | 4578 | </td> |
---|
| 4579 | </tr> |
---|
| 4580 | </table> |
---|
| 4581 | </center> |
---|
| 4582 | </td> |
---|
| 4583 | <td width='40%'> </td> |
---|
| 4584 | </tr> |
---|
| 4585 | </table> |
---|
[933] | 4586 | <script src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/js/edit.js' type='text/javascript'></script> |
---|
[2] | 4587 | " |
---|
| 4588 | ); |
---|
| 4589 | // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. |
---|
| 4590 | if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { |
---|
| 4591 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
| 4592 | |
---|
| 4593 | if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ |
---|
| 4594 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 4595 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 4596 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
| 4597 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 4598 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 4599 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 4600 | $user_context = array(); |
---|
| 4601 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
| 4602 | if($i) |
---|
| 4603 | $user_context[] = $dn_part; |
---|
| 4604 | } |
---|
[36] | 4605 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
| 4606 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
| 4607 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
[42] | 4608 | // Fim |
---|
| 4609 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
| 4610 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
[930] | 4611 | //$combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
[2] | 4612 | $footer_ext_participantes = lang("Tip: To search in the <b>Global Catalog</b>, type the <b>F9</b> key, like the ExpressoMail."); |
---|
[930] | 4613 | //Caso o minimo de caracteres para a busca nao tenha sido preenchido ele sera por padrao = 3 |
---|
| 4614 | if(!$GLOBALS['phpgw_info']['server']['min_num_characters']){ |
---|
[1122] | 4615 | $GLOBALS['phpgw_info']['server']['min_num_characters'] = 0; |
---|
[930] | 4616 | } |
---|
[703] | 4617 | |
---|
[930] | 4618 | if ($GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '3'){ |
---|
| 4619 | $combo_org = '<option value='.$context.'>'.strtoupper($context).'</option>'; |
---|
| 4620 | }else{ |
---|
| 4621 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
| 4622 | } |
---|
| 4623 | |
---|
[928] | 4624 | if ($param['plain'] != "True"){ |
---|
[703] | 4625 | |
---|
| 4626 | // Begin load array lang |
---|
| 4627 | ob_start(); |
---|
[928] | 4628 | //@include($module_name.'/inc/load_lang.php'); |
---|
[703] | 4629 | $load_lang_vars = ob_get_contents(); |
---|
| 4630 | ob_end_clean(); |
---|
| 4631 | // End load array_lang |
---|
[928] | 4632 | } |
---|
[703] | 4633 | |
---|
[2] | 4634 | $var['participants'] = array |
---|
| 4635 | ( |
---|
| 4636 | 'field' => lang('Participants'), |
---|
| 4637 | 'data' => '<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . |
---|
| 4638 | '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . |
---|
| 4639 | '<input type="hidden" id="txt_users" value="'.lang("Users").'">' . |
---|
| 4640 | '<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' . |
---|
| 4641 | '<table width="100%" border="0">'. |
---|
| 4642 | '<tr>'. |
---|
| 4643 | '<td width="25%"><br>'. |
---|
[923] | 4644 | '<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" > '.lang("Add").'</button>'. |
---|
| 4645 | ' <button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" > '.lang("Remove").'</button>'. |
---|
[2] | 4646 | '<br><br> <b>'.lang("Event's participants").'</b><br>'. |
---|
| 4647 | ' <select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'. |
---|
| 4648 | '</td>'. |
---|
| 4649 | '<td width="30px" valign="middle" align="center"> '. |
---|
| 4650 | '</td>'. |
---|
| 4651 | '<td valign="bottom">'. |
---|
[928] | 4652 | ' '.lang("Organization").': '. |
---|
[1126] | 4653 | ' <select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\',\''.($recursive ? "" : "search").'\');">'.$combo_org.'</select>'. |
---|
[2] | 4654 | ' <br>'. |
---|
| 4655 | ' <font color="red"><span id="cal_span_searching"> </span></font>'. |
---|
| 4656 | ' <br>'.lang("Search for").':'. |
---|
[928] | 4657 | ' <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].')"><br>'. |
---|
[638] | 4658 | ' <b>'.lang("Available users and groups").'</b><br>'. |
---|
[2] | 4659 | ' <select id="user_list_in" style="width: 300px" multiple size="13"></select>'. |
---|
| 4660 | '</td>'. |
---|
| 4661 | '</tr>'. |
---|
[928] | 4662 | '</table>'. |
---|
[2] | 4663 | '<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'. |
---|
| 4664 | '<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'. |
---|
[923] | 4665 | "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/edit_exmail.js' type='text/javascript'></script>" . |
---|
[638] | 4666 | $load_lang_vars. |
---|
[2] | 4667 | "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". |
---|
| 4668 | "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". |
---|
| 4669 | "<script type='text/javascript'>" . |
---|
[1122] | 4670 | "var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$GLOBALS['phpgw_info']['server']['auto_search']."\',\'".$user_context."\',\'".($recursive ? "" : "search")."\')',1000);". |
---|
[2] | 4671 | "</script> " |
---|
| 4672 | ); |
---|
| 4673 | } |
---|
| 4674 | } |
---|
| 4675 | |
---|
| 4676 | $var['participants']['data'] .= '<a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . |
---|
| 4677 | " of this system").'" name="a_ext_participants" onClick="javascript:showExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants"><b>'.lang("Inform").' '.lang("external participants").'</b> <img align="top" ' . |
---|
[923] | 4678 | 'src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif"></a><table id="tbl_ext_participants" width="100%" border="0" style="display:none">'. |
---|
[2] | 4679 | '<tr>'. |
---|
| 4680 | '<td>'. |
---|
[923] | 4681 | ' <b>'.lang("external participants").'</b> <img align="top" src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif">' . |
---|
[2] | 4682 | ' <a title="'.lang("Close").'" name="b_ext_participants" onClick="javascript:hideExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants">['.lang("Close").']</a> '. |
---|
| 4683 | '</td>'. |
---|
| 4684 | '</tr>'. |
---|
| 4685 | '<tr>'. |
---|
| 4686 | '<td>'. |
---|
| 4687 | ' >> '.lang("It types below the email addresses, if you want to invite other people out of this system").':'. |
---|
| 4688 | ' <br><textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br> '. |
---|
| 4689 | $footer_ext_participantes. |
---|
| 4690 | '</tr>'. |
---|
| 4691 | '</table>'; |
---|
| 4692 | break; |
---|
| 4693 | |
---|
| 4694 | } |
---|
| 4695 | if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id']) |
---|
| 4696 | { |
---|
| 4697 | $checked = ' checked'; |
---|
| 4698 | } |
---|
| 4699 | else |
---|
| 4700 | { |
---|
| 4701 | $checked = ''; |
---|
| 4702 | } |
---|
| 4703 | $var['owner'] = Array( |
---|
| 4704 | 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), |
---|
[927] | 4705 | 'data' => '<input type="checkbox" id="usuarioParticipa" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>' |
---|
[2] | 4706 | ); |
---|
| 4707 | } |
---|
| 4708 | |
---|
| 4709 | // Reminder |
---|
| 4710 | // The user must use "Alarm Management" to change/modify an alarm |
---|
| 4711 | // so only display the email reminder fields if this is a new event |
---|
| 4712 | // i.e. not editing an existing event |
---|
| 4713 | |
---|
| 4714 | if ($event['id'] == 0) { |
---|
| 4715 | // get defaults |
---|
| 4716 | $days = $this->bo->prefs['calendar']['default_email_days']; |
---|
| 4717 | $hours = $this->bo->prefs['calendar']['default_email_hours']; |
---|
| 4718 | $min = $this->bo->prefs['calendar']['default_email_min']; |
---|
| 4719 | if (count($event['alarm']) > 1) |
---|
| 4720 | { |
---|
| 4721 | // this should not happen because when creating a new event |
---|
| 4722 | // only 1 alarm is displayed on the screen |
---|
| 4723 | // if the user wants more than 1 alarm they should |
---|
| 4724 | // use "Alarm Management" |
---|
| 4725 | echo '<!-- how did this happen, too many alarms -->'."\n"; |
---|
| 4726 | } |
---|
| 4727 | // if there was an error pick up what the user entered |
---|
| 4728 | if (@isset($event['alarm'])) |
---|
| 4729 | { |
---|
| 4730 | @reset($event['alarm']); |
---|
| 4731 | // just get the first one see above!!! |
---|
| 4732 | list($key,$alarm) = @each($event['alarm']); |
---|
[1122] | 4733 | |
---|
| 4734 | |
---|
| 4735 | //if abaixo trata o caso de um evento repetido nao ter uma data final; |
---|
| 4736 | //se isto acontecer, nao havera alarmes definidos; |
---|
| 4737 | //$alarm['time'] recebe $start para $days, $hours e $min ficarem iguais a 0 |
---|
| 4738 | if(!$alarm['time']) { |
---|
| 4739 | $alarm['time'] = $start; |
---|
| 4740 | } |
---|
| 4741 | |
---|
[2] | 4742 | $diff = $start - $alarm['time']; |
---|
| 4743 | $days = (int)($diff / (24*3600)); |
---|
| 4744 | $hours = (int)(($diff - ($days * 24 * 3600))/3600); |
---|
| 4745 | $min = (int)(($diff - ($days * 24 * 3600) - ($hours * 3600))/60); |
---|
[1122] | 4746 | |
---|
| 4747 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') { |
---|
| 4748 | $days = $diff; |
---|
| 4749 | } |
---|
[2] | 4750 | } |
---|
| 4751 | |
---|
| 4752 | // days |
---|
| 4753 | $dout = '<select name="cal[alarmdays]">'."\n"; |
---|
| 4754 | for($i=0;$i<32;$i++) |
---|
| 4755 | { |
---|
| 4756 | $dout .= '<option value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 4757 | } |
---|
| 4758 | $dout .= '</select>'."\n".' '.lang('days').' '; |
---|
| 4759 | // hours |
---|
| 4760 | $hout = '<select name="cal[alarmhours]">'."\n"; |
---|
| 4761 | for($i=0;$i<25;$i++) |
---|
| 4762 | { |
---|
| 4763 | $hout .= '<option value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 4764 | } |
---|
| 4765 | $hout .= '</select>'."\n".' '.lang('hours').' '; |
---|
| 4766 | // minutes |
---|
| 4767 | $mout = '<select name="cal[alarmminutes]">'."\n"; |
---|
| 4768 | for($i=0;$i<61;$i++) |
---|
| 4769 | { |
---|
| 4770 | $mout .= '<option value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 4771 | } |
---|
| 4772 | $mout .= '</select>'."\n".' '.lang('minutes').' '; |
---|
| 4773 | |
---|
| 4774 | $var['alarm'] = Array( |
---|
| 4775 | 'field' => lang('Alarm'), |
---|
| 4776 | 'data' => $dout.$hout.$mout.lang('before the event') |
---|
| 4777 | ); |
---|
| 4778 | |
---|
| 4779 | } |
---|
| 4780 | |
---|
| 4781 | // Repeat Type |
---|
| 4782 | $str = ''; |
---|
| 4783 | foreach($this->bo->rpt_type as $type => $label) |
---|
| 4784 | { |
---|
| 4785 | $str .= '<option value="'.$type.'"'.($event['recur_type']==$type?' selected':'').'>'.lang($label).'</option>'; |
---|
| 4786 | } |
---|
| 4787 | $var['recure_type'] = Array( |
---|
| 4788 | 'field' => lang('Repeat Type'), |
---|
| 4789 | 'data' => '<select name="cal[recur_type]">'."\n".$str.'</select>'."\n" |
---|
| 4790 | ); |
---|
| 4791 | |
---|
| 4792 | if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) |
---|
| 4793 | { |
---|
| 4794 | $checked = ' checked'; |
---|
| 4795 | $recur_end = $this->bo->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4796 | } |
---|
| 4797 | else |
---|
| 4798 | { |
---|
| 4799 | $checked = ''; |
---|
| 4800 | $recur_end = $this->bo->maketime($event['start']) + 86400 - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4801 | } |
---|
| 4802 | |
---|
| 4803 | $var['recure_enddate'] = Array( |
---|
| 4804 | 'field' => lang('Repeat End Date'), |
---|
| 4805 | 'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '. |
---|
| 4806 | /* |
---|
| 4807 | $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 4808 | $sb->getYears('recur_enddate[year]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'Y')), |
---|
| 4809 | $sb->getMonthText('recur_enddate[month]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'n')), |
---|
| 4810 | $sb->getDays('recur_enddate[mday]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'d')) |
---|
| 4811 | ) |
---|
| 4812 | */ |
---|
| 4813 | $jscal->input('recur_enddate[str]',$recur_end) |
---|
| 4814 | ); |
---|
| 4815 | |
---|
| 4816 | $i = 0; $boxes = ''; |
---|
| 4817 | foreach ($this->bo->rpt_day as $mask => $name) |
---|
| 4818 | { |
---|
| 4819 | $boxes .= '<input type="checkbox" name="cal[rpt_day][]" value="'.$mask.'"'.($event['recur_data'] & $mask ? ' checked' : '').'> '.lang($name)."\n"; |
---|
| 4820 | if (++$i == 5) $boxes .= '<br>'; |
---|
| 4821 | } |
---|
| 4822 | $var['recure_day'] = Array( |
---|
[1122] | 4823 | 'field' => lang('Repeat Day').'<br>'.lang('(required for weekly recursivity)'), |
---|
[2] | 4824 | 'data' => $boxes |
---|
| 4825 | ); |
---|
| 4826 | |
---|
| 4827 | $var['recure_interval'] = Array( |
---|
| 4828 | 'field' => lang('Interval'), |
---|
| 4829 | 'data' => '<input name="cal[recur_interval]" size="4" maxlength="4" value="'.$event['recur_interval'].'">' |
---|
| 4830 | ); |
---|
[583] | 4831 | // $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); |
---|
[2] | 4832 | |
---|
| 4833 | if (!isset($this->fields)) |
---|
| 4834 | { |
---|
| 4835 | $this->custom_fields = CreateObject('calendar.bocustom_fields'); |
---|
| 4836 | $this->fields = &$this->custom_fields->fields; |
---|
| 4837 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
| 4838 | } |
---|
[583] | 4839 | $this->output_template_array($p,'row','list',$var['access']); |
---|
| 4840 | unset($var['access']); |
---|
| 4841 | |
---|
[2] | 4842 | $preserved = False; |
---|
| 4843 | foreach($this->fields as $field => $data) |
---|
| 4844 | { |
---|
| 4845 | if (!$data['disabled']) |
---|
| 4846 | { |
---|
| 4847 | if (isset($var[$field])) |
---|
| 4848 | { |
---|
| 4849 | switch($field) |
---|
| 4850 | { |
---|
| 4851 | case 'startdate': |
---|
| 4852 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
| 4853 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
| 4854 | break; |
---|
| 4855 | case 'enddate': |
---|
| 4856 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
| 4857 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
| 4858 | break; |
---|
| 4859 | case 'recure_type': |
---|
| 4860 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
[583] | 4861 | $p->set_var('hr_text','<center name="cal[rpt_label]"><b>'.lang('Repeating Event Information').'</b></center>'); |
---|
[2] | 4862 | $p->parse('row','hr',True); |
---|
| 4863 | $this->output_template_array($p,'row','list',$var['recure_type']); |
---|
| 4864 | $this->output_template_array($p,'row','list',$var['recure_enddate']); |
---|
| 4865 | $this->output_template_array($p,'row','list',$var['recure_day']); |
---|
| 4866 | $this->output_template_array($p,'row','list',$var['recure_interval']); |
---|
| 4867 | break; |
---|
| 4868 | default: |
---|
| 4869 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
| 4870 | } |
---|
| 4871 | } |
---|
| 4872 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
| 4873 | { |
---|
| 4874 | $lang = lang($name = substr($field,1)); |
---|
| 4875 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
| 4876 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
| 4877 | $v = array( |
---|
| 4878 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
| 4879 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
| 4880 | ); |
---|
| 4881 | if ($data['title']) |
---|
| 4882 | { |
---|
| 4883 | $v['tr_color'] = $this->theme['th_bg']; |
---|
| 4884 | } |
---|
| 4885 | if (!$data['length'] && $data['title']) |
---|
| 4886 | { |
---|
| 4887 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
| 4888 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
| 4889 | $p->parse('row','hr',True); |
---|
| 4890 | } |
---|
| 4891 | else |
---|
| 4892 | { |
---|
| 4893 | $this->output_template_array($p,'row','list',$v); |
---|
| 4894 | } |
---|
| 4895 | } |
---|
| 4896 | } |
---|
| 4897 | else // preserve disabled fields |
---|
| 4898 | { |
---|
| 4899 | switch ($field) |
---|
| 4900 | { |
---|
| 4901 | case 'owner': |
---|
| 4902 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
| 4903 | break; |
---|
| 4904 | case 'recure_type': |
---|
| 4905 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
| 4906 | { |
---|
| 4907 | $preserved[$field] = $event[$field]; |
---|
| 4908 | } |
---|
| 4909 | break; |
---|
| 4910 | case 'startdate': |
---|
| 4911 | case 'enddate': |
---|
| 4912 | $field = substr($field,0,-4); |
---|
| 4913 | default: |
---|
| 4914 | $preserved[$field] = $event[$field]; |
---|
| 4915 | } |
---|
| 4916 | } |
---|
| 4917 | } |
---|
| 4918 | unset($var); |
---|
| 4919 | if (is_array($preserved)) |
---|
| 4920 | { |
---|
| 4921 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
| 4922 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
| 4923 | } |
---|
| 4924 | $p->set_var('submit_button',lang('Save')); |
---|
| 4925 | |
---|
| 4926 | $delete_button = $cancel_button = ''; |
---|
| 4927 | if ($event['id'] > 0) |
---|
| 4928 | { |
---|
| 4929 | $var = Array( |
---|
| 4930 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
| 4931 | 'action_text_button' => lang('Delete'), |
---|
[204] | 4932 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
[663] | 4933 | 'action_extra_field' => '', |
---|
| 4934 | 'button_id' => 'delete_button' |
---|
[2] | 4935 | ); |
---|
| 4936 | $p->set_var($var); |
---|
| 4937 | $delete_button = $p->fp('out','form_button'); |
---|
| 4938 | } |
---|
| 4939 | $p->set_var('delete_button',$delete_button); |
---|
[602] | 4940 | $p->set_var('alert_msg',lang('Required field (category) is empty')); |
---|
[2] | 4941 | |
---|
| 4942 | if ($this->bo->return_to) |
---|
| 4943 | { |
---|
| 4944 | $var = Array( |
---|
| 4945 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 4946 | 'action_text_button' => lang('Cancel'), |
---|
| 4947 | 'action_confirm_button' => '', |
---|
[663] | 4948 | 'action_extra_field' => '', |
---|
| 4949 | 'button_id' => 'cancel_button' |
---|
[2] | 4950 | ); |
---|
| 4951 | $p->set_var($var); |
---|
| 4952 | $cancel_button = $p->fp('out','form_button'); |
---|
| 4953 | } |
---|
| 4954 | $p->set_var('cancel_button',$cancel_button); |
---|
| 4955 | $p->pparse('out','edit_entry'); |
---|
| 4956 | } |
---|
| 4957 | |
---|
| 4958 | // modify list of an event's external participants (i.e. non pgpgw users) |
---|
| 4959 | // |
---|
| 4960 | function modify_ext_partlist() |
---|
| 4961 | { |
---|
| 4962 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
| 4963 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
| 4964 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 4965 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 4966 | |
---|
| 4967 | $total_contacts = 0; |
---|
| 4968 | $participant = array(); |
---|
| 4969 | $control_data= array(); |
---|
| 4970 | |
---|
| 4971 | $control_data['action'] = ''; |
---|
| 4972 | $control_data['delete'] = array(); |
---|
| 4973 | $control_data['part'] = array(); |
---|
| 4974 | |
---|
| 4975 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4976 | $p->set_file( |
---|
| 4977 | Array( |
---|
| 4978 | 'T_edit_partlist' => 'edit_partlist.tpl', |
---|
| 4979 | 'T_edit_partlist_blocks' => 'edit_partlist_blocks.tpl' |
---|
| 4980 | ) |
---|
| 4981 | ); |
---|
| 4982 | |
---|
| 4983 | $p->set_block('T_edit_partlist_blocks','B_alert_msg','V_alert_msg'); |
---|
| 4984 | $p->set_block('T_edit_partlist_blocks','B_partlist','V_partlist'); |
---|
| 4985 | $p->set_block('T_edit_partlist_blocks','B_participants_none','V_participants_none'); |
---|
| 4986 | $p->set_block('T_edit_partlist_blocks','B_delete_btn','V_delete_btn'); |
---|
| 4987 | |
---|
| 4988 | global $query_addr; |
---|
| 4989 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 4990 | $addy = $sb->getAddress('addr','',$query_addr); |
---|
| 4991 | |
---|
| 4992 | $add_ext = $addy['doSearchFkt']; |
---|
| 4993 | $add_ext .= $addy['addr_title']!=lang('Address Book')?$addy['addr_title']:''; |
---|
| 4994 | $add_ext .= " ".$addy['addr'].$addy['addr_nojs']; |
---|
| 4995 | |
---|
| 4996 | $p->set_var('text_add_name',$add_ext); |
---|
| 4997 | |
---|
| 4998 | if(isset($_GET['part']) && $_GET['part']) |
---|
| 4999 | { |
---|
| 5000 | $control_data['part'] = split(",", $_GET['part']); |
---|
| 5001 | } |
---|
| 5002 | else |
---|
| 5003 | { |
---|
| 5004 | $control_data['part'] = $_POST['participant']; |
---|
| 5005 | $control_data['action'] = $_POST['action']; |
---|
| 5006 | $control_data['delete'] = $_POST['delete']; |
---|
| 5007 | } |
---|
| 5008 | |
---|
| 5009 | for ($i=0; $i<count($control_data['part']); $i++) |
---|
| 5010 | { |
---|
| 5011 | $id = $control_data['part'][$i]; |
---|
| 5012 | list($contact) = $this->read_contact($id); |
---|
| 5013 | |
---|
| 5014 | $participant[$id] = array(); |
---|
| 5015 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
| 5016 | } |
---|
| 5017 | |
---|
| 5018 | if ($control_data['action'] == lang('Delete selected contacts')) |
---|
| 5019 | { |
---|
| 5020 | for ($i=0; $i<count($control_data['delete']); $i++) |
---|
| 5021 | { |
---|
| 5022 | $id = $control_data['delete'][$i]; |
---|
| 5023 | unset($participant[$id]); |
---|
| 5024 | } |
---|
| 5025 | } |
---|
| 5026 | |
---|
| 5027 | if ($control_data['action'] == lang('Add Contact')) |
---|
| 5028 | { |
---|
| 5029 | $id = $_POST['id_addr']; |
---|
| 5030 | if (isset($id) && (int)$id != 0) |
---|
| 5031 | { |
---|
| 5032 | list($contact) = $this->read_contact($id); |
---|
| 5033 | $participant[$id] = array(); |
---|
| 5034 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
| 5035 | } |
---|
| 5036 | } |
---|
| 5037 | |
---|
| 5038 | // create list of currently selected contacts |
---|
| 5039 | // |
---|
| 5040 | while(list($id,$contact) = each($participant)) |
---|
| 5041 | { |
---|
| 5042 | $p->set_var('hidden_delete_name','participant[]'); |
---|
| 5043 | $p->set_var('hidden_delete_value',$id); |
---|
| 5044 | $p->set_var('ckbox_delete_name','delete[]'); |
---|
| 5045 | $p->set_var('ckbox_delete_value',$id); |
---|
| 5046 | $p->set_var('ckbox_delete_participant',$contact['name']); |
---|
| 5047 | $p->parse('V_partlist','B_partlist',True); |
---|
| 5048 | $total_contacts++; |
---|
| 5049 | } |
---|
| 5050 | |
---|
| 5051 | if ($total_contacts == 0) |
---|
| 5052 | { |
---|
| 5053 | // no contacts have been selected |
---|
| 5054 | // => clear the delete form, remove delete button and show the none block |
---|
| 5055 | // |
---|
| 5056 | $p->set_var('V_partlist',''); |
---|
| 5057 | $p->set_var('V_delete_btn',''); |
---|
| 5058 | $p->set_var('text_none',lang('None')); |
---|
| 5059 | $p->parse('V_participants_none','B_participants_none'); |
---|
| 5060 | } |
---|
| 5061 | else |
---|
| 5062 | { |
---|
| 5063 | // at least one contact has been selected |
---|
| 5064 | // => clear the none block, fill the delete form and add delete button |
---|
| 5065 | // |
---|
| 5066 | $p->set_var('V_participants_none',''); |
---|
| 5067 | $p->set_var('btn_delete_name','action'); |
---|
| 5068 | $p->set_var('btn_delete_value',lang('Delete selected contacts')); |
---|
| 5069 | $p->parse('V_delete_btn','B_delete_btn'); |
---|
| 5070 | } |
---|
| 5071 | |
---|
| 5072 | $body_tags = 'bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_color'] |
---|
| 5073 | . '" alink="'.$GLOBALS['phpgw_info']['theme']['alink'] |
---|
| 5074 | . '" link="'.$GLOBALS['phpgw_info']['theme']['link'] |
---|
| 5075 | .'" vlink="'.$GLOBALS['phpgw_info']['theme']['vlink'].'"'; |
---|
| 5076 | |
---|
| 5077 | $form_action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'calendar.uicalendar.modify')); |
---|
| 5078 | |
---|
| 5079 | $charset = lang('charset'); |
---|
| 5080 | $p->set_var('charset',$charset); |
---|
| 5081 | $p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp'] |
---|
| 5082 | . ' - ' .lang('External Participants')); |
---|
| 5083 | $p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']); |
---|
| 5084 | $p->set_var('body_tags',$body_tags); |
---|
| 5085 | $p->set_var('form_method','POST'); |
---|
| 5086 | $p->set_var('form_action',$form_action); |
---|
| 5087 | $p->set_var('text_add_contact',lang('External Participants')); |
---|
| 5088 | $p->set_var('text_contacts_selected',lang('Selected contacts (%1)',$total_contacts)); |
---|
| 5089 | $p->set_var('btn_add_name','action'); |
---|
| 5090 | $p->set_var('btn_add_value',lang('Add Contact')); |
---|
| 5091 | $p->set_var('btn_done_name','done'); |
---|
| 5092 | $p->set_var('btn_done_value',lang('Done')); |
---|
| 5093 | $p->set_var('btn_done_js','copyback()'); |
---|
| 5094 | $p->set_var('form1_name','ext_form'); |
---|
| 5095 | |
---|
| 5096 | $p->pfp('out','T_edit_partlist'); |
---|
| 5097 | } |
---|
| 5098 | |
---|
| 5099 | function read_contact($id) |
---|
| 5100 | { |
---|
| 5101 | $query_fields = Array( |
---|
| 5102 | 'n_given' => 'n_given', |
---|
| 5103 | 'n_family' => 'n_family', |
---|
| 5104 | 'email' => 'email', |
---|
| 5105 | 'email_home' => 'email_home' |
---|
| 5106 | ); |
---|
| 5107 | |
---|
| 5108 | /* |
---|
| 5109 | if ($this->rights & PHPGW_ACL_READ) |
---|
| 5110 | { |
---|
| 5111 | return $this->contacts->read_single_entry($id,$fields); |
---|
| 5112 | } |
---|
| 5113 | else |
---|
| 5114 | { |
---|
| 5115 | $rtrn = array(0 => array('No access' => 'No access')); |
---|
| 5116 | return $rtrn; |
---|
| 5117 | } |
---|
| 5118 | */ |
---|
| 5119 | |
---|
| 5120 | $contacts = CreateObject('phpgwapi.contacts', False); |
---|
| 5121 | return $contacts->read_single_entry($id,$query_fields); |
---|
| 5122 | } |
---|
| 5123 | |
---|
| 5124 | function build_part_list(&$users,$accounts,$owner) |
---|
| 5125 | { |
---|
| 5126 | if(!is_array($accounts)) |
---|
| 5127 | { |
---|
| 5128 | return; |
---|
| 5129 | } |
---|
| 5130 | foreach($accounts as $id) |
---|
| 5131 | { |
---|
| 5132 | $id = (int)$id; |
---|
| 5133 | if($id == $owner) |
---|
| 5134 | { |
---|
| 5135 | continue; |
---|
| 5136 | } |
---|
| 5137 | elseif(!isset($users[$id])) |
---|
| 5138 | { |
---|
| 5139 | if($GLOBALS['phpgw']->accounts->exists($id) == True) |
---|
| 5140 | { |
---|
| 5141 | $users[$id] = Array( |
---|
| 5142 | 'name' => $GLOBALS['phpgw']->common->grab_owner_name($id), |
---|
| 5143 | 'type' => $GLOBALS['phpgw']->accounts->get_type($id) |
---|
| 5144 | ); |
---|
| 5145 | } |
---|
| 5146 | if($GLOBALS['phpgw']->accounts->get_type($id) == 'g') |
---|
| 5147 | { |
---|
| 5148 | //$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group'),$owner); |
---|
| 5149 | } |
---|
| 5150 | } |
---|
| 5151 | } |
---|
| 5152 | if (!function_exists('strcmp_name')) |
---|
| 5153 | { |
---|
| 5154 | function strcmp_name($arr1,$arr2) |
---|
| 5155 | { |
---|
| 5156 | if ($diff = strcmp($arr1['type'],$arr2['type'])) |
---|
| 5157 | { |
---|
| 5158 | return $diff; // groups before users |
---|
| 5159 | } |
---|
| 5160 | return strnatcasecmp($arr1['name'],$arr2['name']); |
---|
| 5161 | } |
---|
| 5162 | } |
---|
| 5163 | uasort($users,'strcmp_name'); |
---|
| 5164 | } |
---|
| 5165 | |
---|
| 5166 | function set_week_array($startdate,$cellcolor,$weekly) |
---|
| 5167 | { |
---|
[360] | 5168 | $data = date("m"); |
---|
[2] | 5169 | for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400) |
---|
| 5170 | { |
---|
| 5171 | $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset |
---|
| 5172 | print_debug('set_week_array : Date ',$date); |
---|
| 5173 | |
---|
| 5174 | if($events = $this->bo->cached_events[$date]) |
---|
| 5175 | { |
---|
| 5176 | print_debug('Date',$date); |
---|
| 5177 | print_debug('Appointments Found',count($events)); |
---|
| 5178 | |
---|
| 5179 | if (!$this->bo->prefs['calendar']['show_rejected']) |
---|
| 5180 | { |
---|
| 5181 | $appts = False; |
---|
| 5182 | foreach($events as $event) // check for a not-rejected event |
---|
| 5183 | { |
---|
| 5184 | if (!$this->bo->rejected_no_show($event)) |
---|
| 5185 | { |
---|
| 5186 | $appts = True; |
---|
| 5187 | break; |
---|
| 5188 | } |
---|
| 5189 | } |
---|
| 5190 | } |
---|
| 5191 | else |
---|
| 5192 | { |
---|
| 5193 | $appts = True; |
---|
| 5194 | } |
---|
| 5195 | } |
---|
| 5196 | else |
---|
| 5197 | { |
---|
| 5198 | $appts = False; |
---|
| 5199 | } |
---|
| 5200 | |
---|
| 5201 | $holidays = $this->bo->cached_holidays[$date]; |
---|
| 5202 | if($weekly) |
---|
| 5203 | { |
---|
| 5204 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 5205 | } |
---|
| 5206 | |
---|
| 5207 | $day_image = ''; |
---|
| 5208 | if($holidays) |
---|
| 5209 | { |
---|
| 5210 | $extra = ' bgcolor="'.$this->bo->holiday_color.'"'; |
---|
| 5211 | $class = ($appts?'b':'').'minicalhol'; |
---|
| 5212 | if ($date == $this->bo->today) |
---|
| 5213 | { |
---|
| 5214 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 5215 | } |
---|
| 5216 | } |
---|
| 5217 | elseif ($date != $this->bo->today) |
---|
| 5218 | { |
---|
| 5219 | $extra = ' bgcolor="'.$cellcolor.'"'; |
---|
| 5220 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 5221 | } |
---|
| 5222 | else |
---|
| 5223 | { |
---|
| 5224 | $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"'; |
---|
| 5225 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 5226 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 5227 | } |
---|
| 5228 | |
---|
| 5229 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 5230 | { |
---|
| 5231 | $extra = ''; |
---|
| 5232 | } |
---|
| 5233 | |
---|
| 5234 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 5235 | { |
---|
| 5236 | $new_event = True; |
---|
| 5237 | } |
---|
| 5238 | else |
---|
| 5239 | { |
---|
| 5240 | $new_event = False; |
---|
| 5241 | } |
---|
| 5242 | $holiday_name = Array(); |
---|
| 5243 | if($holidays) |
---|
| 5244 | { |
---|
| 5245 | for($k=0;$k<count($holidays);$k++) |
---|
| 5246 | { |
---|
| 5247 | $holiday_name[] = $holidays[$k]['name']; |
---|
| 5248 | } |
---|
| 5249 | } |
---|
| 5250 | $week = ''; |
---|
| 5251 | if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) |
---|
| 5252 | { |
---|
| 5253 | $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); |
---|
| 5254 | } |
---|
| 5255 | $daily[$date] = Array( |
---|
| 5256 | 'extra' => $extra, |
---|
| 5257 | 'new_event' => $new_event, |
---|
| 5258 | 'holidays' => $holiday_name, |
---|
| 5259 | 'appts' => $appts, |
---|
| 5260 | 'week' => $week, |
---|
| 5261 | 'day_image' => $day_image, |
---|
| 5262 | 'class' => $class |
---|
| 5263 | ); |
---|
| 5264 | } |
---|
| 5265 | |
---|
| 5266 | if($this->debug) |
---|
| 5267 | { |
---|
| 5268 | _debug_array($daily); |
---|
| 5269 | } |
---|
| 5270 | |
---|
| 5271 | return $daily; |
---|
| 5272 | } |
---|
[36] | 5273 | |
---|
[42] | 5274 | function get_organizations($context, $selected='', $recursive = false) |
---|
[23] | 5275 | { |
---|
[2] | 5276 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
[42] | 5277 | |
---|
| 5278 | return ($recursive ? |
---|
| 5279 | $s->get_organizations($context, $selected, false ,false) : |
---|
| 5280 | $s->get_sectors($selected, false, false)); |
---|
| 5281 | } |
---|
[2] | 5282 | } |
---|
[583] | 5283 | ?> |
---|