[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, |
---|
[5132] | 67 | //'suggest' => True, |
---|
| 68 | 'send_suggest_owner' => True, |
---|
[2] | 69 | 'edit' => True, |
---|
| 70 | 'export' => True, |
---|
[57] | 71 | 'export_all' => True, |
---|
[2] | 72 | 'reinstate_list' => True, |
---|
| 73 | 'reinstate' => True, |
---|
| 74 | 'add' => True, |
---|
| 75 | 'delete' => True, |
---|
| 76 | 'preferences' => True, |
---|
| 77 | 'day' => True, |
---|
| 78 | 'edit_status' => True, |
---|
| 79 | 'set_action' => True, |
---|
| 80 | 'planner' => True, |
---|
| 81 | 'modify_ext_partlist' => True, |
---|
| 82 | 'matrixselect' => True, |
---|
| 83 | 'viewmatrix' => True, |
---|
| 84 | 'search' => True, |
---|
| 85 | 'header' => True, |
---|
| 86 | 'footer' => True, |
---|
| 87 | 'css' => True, |
---|
[1447] | 88 | 'accounts_popup' => True, |
---|
| 89 | 'disponibility' => True |
---|
[2] | 90 | ); |
---|
| 91 | |
---|
| 92 | function uicalendar() |
---|
| 93 | { |
---|
[5132] | 94 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 95 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 96 | $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar'; |
---|
[5316] | 97 | include_once( dirname(__FILE__).'/../../header.inc.php' ); |
---|
[5132] | 98 | |
---|
[2] | 99 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 100 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
| 101 | |
---|
| 102 | $this->theme = $GLOBALS['phpgw_info']['theme']; |
---|
| 103 | |
---|
| 104 | $this->bo = CreateObject('calendar.bocalendar',1); |
---|
| 105 | $this->cat = &$this->bo->cat; |
---|
| 106 | |
---|
| 107 | print_debug('BO Owner',$this->bo->owner); |
---|
| 108 | |
---|
| 109 | $this->template = $GLOBALS['phpgw']->template; |
---|
| 110 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); |
---|
| 111 | |
---|
| 112 | $this->holiday_color = (substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06']; |
---|
| 113 | |
---|
| 114 | $this->cat_id = $this->bo->cat_id; |
---|
| 115 | |
---|
| 116 | $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 117 | $this->link_tpl->set_unknowns('remove'); |
---|
| 118 | $this->link_tpl->set_file( |
---|
| 119 | Array( |
---|
| 120 | 'link_picture' => 'link_pict.tpl' |
---|
| 121 | ) |
---|
| 122 | ); |
---|
| 123 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
| 124 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
| 125 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
| 126 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
| 127 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
[360] | 128 | |
---|
| 129 | /*************** EVENTO **************************/ |
---|
| 130 | /* Este bloco de codigo foi adicionado pois os eventos de agendamento (exibicao do mes) para impressao serao tratados em outro template |
---|
| 131 | (event_link.tpl) */ |
---|
[2] | 132 | |
---|
[360] | 133 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 134 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 135 | $this->event_tpl->set_unknowns('remove'); |
---|
| 136 | $this->event_tpl->set_file( |
---|
| 137 | Array( |
---|
| 138 | 'link_event' => 'event_link.tpl' |
---|
| 139 | ) |
---|
| 140 | ); |
---|
| 141 | $this->event_tpl->set_block('link_event','link_event_pict','link_event_pict'); |
---|
| 142 | $this->event_tpl->set_block('link_event','event_pict','event_pict'); |
---|
| 143 | $this->event_tpl->set_block('link_event','link_event_open','link_event_open'); |
---|
| 144 | $this->event_tpl->set_block('link_event','link_event_close','link_event_close'); |
---|
| 145 | $this->event_tpl->set_block('link_event','link_event_text','link_event_text'); |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | /*************************************************/ |
---|
| 149 | |
---|
[2] | 150 | if($this->bo->use_session) |
---|
| 151 | { |
---|
| 152 | // save return-fkt for add, view, ... |
---|
| 153 | list(,,$fkt) = explode('.',$_GET['menuaction']); |
---|
| 154 | if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner') |
---|
| 155 | { |
---|
| 156 | $this->bo->return_to = $_GET['menuaction']. |
---|
| 157 | sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day); |
---|
| 158 | } |
---|
| 159 | $this->bo->save_sessiondata(); |
---|
| 160 | } |
---|
| 161 | $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; |
---|
| 162 | |
---|
| 163 | print_debug('UI',$this->_debug_sqsof()); |
---|
| 164 | |
---|
| 165 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
| 166 | { |
---|
| 167 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
| 168 | } |
---|
| 169 | $this->html = &$GLOBALS['phpgw']->html; |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | /* Public functions */ |
---|
| 173 | |
---|
| 174 | function mini_calendar($params) |
---|
| 175 | { |
---|
| 176 | static $mini_cal_tpl; |
---|
| 177 | if(!is_array($params)) |
---|
| 178 | { |
---|
| 179 | return; |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | if($params['month'] == 0) |
---|
| 183 | { |
---|
| 184 | $params['month'] = 12; |
---|
| 185 | $params['year'] = $params['year'] - 1; |
---|
| 186 | } |
---|
| 187 | elseif($params['month'] == 13) |
---|
| 188 | { |
---|
| 189 | $params['month'] = 1; |
---|
| 190 | $params['year'] = $params['year'] + 1; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | $this->bo->store_to_cache( |
---|
| 194 | Array( |
---|
| 195 | 'smonth' => $params['month'], |
---|
| 196 | 'sday' => 1, |
---|
| 197 | 'syear' => $params['year'] |
---|
| 198 | ) |
---|
| 199 | ); |
---|
| 200 | |
---|
| 201 | $params['link'] = (!isset($params['link'])?'':$params['link']); |
---|
| 202 | $params['buttons'] = (!isset($params['buttons'])?'none':$params['buttons']); |
---|
| 203 | $params['outside_month'] = (!isset($params['outside_month'])?True:$params['outside_month']); |
---|
| 204 | |
---|
| 205 | $this->bo->read_holidays($params['year']); |
---|
| 206 | |
---|
| 207 | $date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); |
---|
| 208 | $month_ago = (int)(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); |
---|
| 209 | $month_ahead = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year']))); |
---|
| 210 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year']))); |
---|
| 211 | $monthend = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year']))); |
---|
| 212 | |
---|
| 213 | $weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1); |
---|
| 214 | |
---|
| 215 | print_debug('mini_calendar:monthstart',$monthstart); |
---|
| 216 | print_debug('mini_calendar:weekstarttime',date('Ymd H:i:s',$weekstarttime)); |
---|
| 217 | |
---|
| 218 | if(!is_object($mini_cal_tpl)) |
---|
| 219 | { |
---|
| 220 | $mini_cal_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 221 | $mini_cal_tpl->set_unknowns('remove'); |
---|
| 222 | $mini_cal_tpl->set_file( |
---|
| 223 | Array( |
---|
| 224 | 'mini_calendar' => 'mini_cal.tpl' |
---|
| 225 | ) |
---|
| 226 | ); |
---|
| 227 | $mini_cal_tpl->set_block('mini_calendar','mini_cal','mini_cal'); |
---|
| 228 | $mini_cal_tpl->set_block('mini_calendar','mini_week','mini_week'); |
---|
| 229 | $mini_cal_tpl->set_block('mini_calendar','mini_day','mini_day'); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | if($this->bo->printer_friendly == False) |
---|
| 234 | { |
---|
| 235 | //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>'; |
---|
| 236 | $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>'; |
---|
| 237 | } |
---|
| 238 | else |
---|
| 239 | { |
---|
| 240 | $month = lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y'); |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | $var = Array( |
---|
| 244 | 'cal_img_root' => $GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'), |
---|
| 245 | 'bgcolor' => $this->theme['bg_color'], |
---|
| 246 | 'bgcolor1' => $this->theme['bg_color'], |
---|
| 247 | 'month' => $month, |
---|
| 248 | 'bgcolor2' => $this->theme['cal_dayview'], |
---|
| 249 | 'holiday_color' => $this->holiday_color |
---|
| 250 | ); |
---|
| 251 | |
---|
| 252 | $mini_cal_tpl->set_var($var); |
---|
| 253 | |
---|
| 254 | switch(strtolower($params['buttons'])) |
---|
| 255 | { |
---|
| 256 | case 'right': |
---|
| 257 | $var = Array( |
---|
| 258 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
| 259 | ); |
---|
| 260 | break; |
---|
| 261 | case 'left': |
---|
| 262 | $var = Array( |
---|
| 263 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>' |
---|
| 264 | ); |
---|
| 265 | break; |
---|
| 266 | case 'both': |
---|
| 267 | $var = Array( |
---|
| 268 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>', |
---|
| 269 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
| 270 | ); |
---|
| 271 | break; |
---|
| 272 | case 'none': |
---|
| 273 | default: |
---|
| 274 | $var = Array( |
---|
| 275 | 'prevmonth' => '', |
---|
| 276 | 'nextmonth' => '' |
---|
| 277 | ); |
---|
| 278 | break; |
---|
| 279 | } |
---|
| 280 | $mini_cal_tpl->set_var($var); |
---|
| 281 | |
---|
| 282 | if(!$mini_cal_tpl->get_var('daynames')) |
---|
| 283 | { |
---|
| 284 | for($i=0;$i<7;$i++) |
---|
| 285 | { |
---|
| 286 | $var = Array( |
---|
| 287 | 'dayname' => '<b>' . lang($GLOBALS['phpgw']->datetime->days_short[$i]) . '</b>', |
---|
| 288 | 'day_image' => '' |
---|
| 289 | ); |
---|
| 290 | $this->output_template_array($mini_cal_tpl,'daynames','mini_day',$var); |
---|
| 291 | } |
---|
| 292 | } |
---|
| 293 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 294 | unset($date); |
---|
| 295 | for($i=$weekstarttime + $GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 * 3600 * 7)) |
---|
| 296 | { |
---|
| 297 | unset($var); |
---|
| 298 | $daily = $this->set_week_array($i - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 299 | foreach($daily as $date => $day_params) |
---|
| 300 | { |
---|
| 301 | print_debug('Mini-Cal Date',$date); |
---|
| 302 | $year = (int)(substr($date,0,4)); |
---|
| 303 | $month = (int)(substr($date,4,2)); |
---|
| 304 | $day = (int)(substr($date,6,2)); |
---|
| 305 | $str = ''; |
---|
| 306 | if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True) |
---|
| 307 | { |
---|
| 308 | if(!$this->bo->printer_friendly && $params['link']) |
---|
| 309 | { |
---|
| 310 | //NDEE: class def what for? |
---|
[5132] | 311 | $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'">'.$day.'</a>'; |
---|
[2] | 312 | } |
---|
| 313 | else |
---|
| 314 | { |
---|
| 315 | |
---|
| 316 | //NDEE: printer-friendly (mini-calendar) |
---|
| 317 | $str = $day; |
---|
| 318 | } |
---|
| 319 | |
---|
| 320 | } |
---|
| 321 | else |
---|
| 322 | { |
---|
| 323 | $day_params['day_image'] = ''; |
---|
| 324 | } |
---|
| 325 | $var[] = Array( |
---|
| 326 | 'day_image' => $day_params['day_image'], |
---|
| 327 | 'dayname' => $str |
---|
| 328 | ); |
---|
| 329 | } |
---|
| 330 | for($l=0;$l<count($var);$l++) |
---|
| 331 | { |
---|
| 332 | $this->output_template_array($mini_cal_tpl,'monthweek_day','mini_day',$var[$l]); |
---|
| 333 | } |
---|
| 334 | $mini_cal_tpl->parse('display_monthweek','mini_week',True); |
---|
| 335 | $mini_cal_tpl->set_var('dayname',''); |
---|
| 336 | $mini_cal_tpl->set_var('monthweek_day',''); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | $return_value = $mini_cal_tpl->fp('out','mini_cal'); |
---|
| 340 | $mini_cal_tpl->set_var('display_monthweek',''); |
---|
| 341 | // $mini_cal_tpl->set_var('daynames',''); |
---|
| 342 | // unset($p); |
---|
| 343 | return $return_value; |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | function index($params='') |
---|
| 347 | { |
---|
| 348 | if (!$params) |
---|
| 349 | { |
---|
| 350 | foreach(array('date','year','month','day') as $field) |
---|
| 351 | { |
---|
| 352 | if (isset($_GET[$field])) |
---|
| 353 | { |
---|
| 354 | $params[$field] = $_GET[$field]; |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | } |
---|
| 358 | $GLOBALS['phpgw']->redirect($this->page('',$params)); |
---|
[15] | 359 | |
---|
[2] | 360 | } |
---|
| 361 | |
---|
| 362 | |
---|
| 363 | |
---|
| 364 | // NDEE: printer-friendly |
---|
| 365 | |
---|
| 366 | function printer_friendly($body,$app_header='') |
---|
[663] | 367 | { |
---|
[602] | 368 | $_SESSION['calendar']['categories'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); |
---|
| 369 | if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) |
---|
[5132] | 370 | { |
---|
[602] | 371 | $_SESSION['calendar']['cals'] = $this->bo->list_cals(); |
---|
[5132] | 372 | } |
---|
[602] | 373 | |
---|
[703] | 374 | if($this->bo->printer_friendly || $_GET['plain'] == 'True') |
---|
[2] | 375 | { |
---|
| 376 | $new_body = '<html>'."\n" |
---|
| 377 | .'<head>'."\n" |
---|
[5132] | 378 | .'<SCRIPT type="text/javascript"> |
---|
| 379 | window.onbeforeunload = function() { |
---|
| 380 | return \'Gostaria realmente de fechar essa janela ?\'; |
---|
| 381 | } |
---|
| 382 | </SCRIPT>' |
---|
| 383 | .'<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" |
---|
| 384 | .'<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] | 385 | .'</head> |
---|
| 386 | <table id="calendar_print_main" class="calendar_print_main"> |
---|
| 387 | <tr> |
---|
| 388 | <td id="calendar_print_content" class="calendar_print_content">'.$body.'</td> |
---|
| 389 | </tr> |
---|
[5132] | 390 | |
---|
[2] | 391 | <tr> |
---|
[924] | 392 | <td> |
---|
[5132] | 393 | <br/> |
---|
| 394 | <br/> |
---|
[924] | 395 | <div> |
---|
| 396 | <input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta página"> |
---|
| 397 | </div> |
---|
| 398 | </td> |
---|
| 399 | </tr> |
---|
[2] | 400 | </table></body>'."\n" |
---|
| 401 | .'</html>'."\n"; |
---|
| 402 | //$new_body = utf8_decode($new_body); |
---|
| 403 | } |
---|
| 404 | else |
---|
| 405 | { |
---|
| 406 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 407 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 408 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
| 409 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
| 410 | if ($app_header && $this->always_app_header) |
---|
| 411 | { |
---|
| 412 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.$app_header; |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 416 | |
---|
[5132] | 417 | $new_body = $this->bo->debug_string.$body; |
---|
[2] | 418 | } |
---|
| 419 | |
---|
[4049] | 420 | |
---|
| 421 | |
---|
[5132] | 422 | |
---|
| 423 | return $new_body; |
---|
[4049] | 424 | } |
---|
[4114] | 425 | |
---|
[5132] | 426 | function month() |
---|
[4114] | 427 | { |
---|
| 428 | echo $this->printer_friendly($this->get_month(),lang('Monthview')); |
---|
[15] | 429 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 430 | } |
---|
| 431 | |
---|
| 432 | function get_month() |
---|
| 433 | { |
---|
[5132] | 434 | $this->bo->read_holidays(); |
---|
| 435 | |
---|
[2] | 436 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 437 | |
---|
| 438 | $next = $this->bo->month + 1; |
---|
| 439 | $prev = $this->bo->month - 1; |
---|
| 440 | $nextyear = $this->bo->year; |
---|
| 441 | $prevyear = $this->bo->year; |
---|
| 442 | if ($this->bo->month == 12) |
---|
| 443 | { |
---|
| 444 | $next = 1; |
---|
| 445 | $nextyear = $nextyear + 1; |
---|
| 446 | } |
---|
| 447 | elseif ($this->bo->month == 1) |
---|
| 448 | { |
---|
| 449 | $prev = 12; |
---|
| 450 | $prevyear = $prevyear - 1; |
---|
| 451 | } |
---|
| 452 | |
---|
[934] | 453 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
[2] | 454 | { |
---|
| 455 | $minical_prev = $this->mini_calendar( |
---|
| 456 | Array( |
---|
| 457 | 'day' => 1, |
---|
| 458 | 'month' => $this->bo->month - 1, |
---|
| 459 | 'year' => $this->bo->year, |
---|
| 460 | 'link' => 'day', |
---|
| 461 | 'outside_month' => False |
---|
| 462 | ) |
---|
| 463 | ); |
---|
| 464 | |
---|
| 465 | $minical_next = $this->mini_calendar( |
---|
| 466 | Array( |
---|
| 467 | 'day' => 1, |
---|
| 468 | 'month' => $this->bo->month + 1, |
---|
| 469 | 'year' => $this->bo->year, |
---|
| 470 | 'link' => 'day', |
---|
| 471 | 'outside_month' => False |
---|
| 472 | ) |
---|
| 473 | ); |
---|
| 474 | } |
---|
| 475 | else |
---|
| 476 | { |
---|
| 477 | $minical_prev = ''; |
---|
| 478 | $minical_next = ''; |
---|
| 479 | } |
---|
[5132] | 480 | |
---|
[924] | 481 | if($_POST['year']) { |
---|
| 482 | |
---|
| 483 | } |
---|
| 484 | |
---|
[5132] | 485 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
| 486 | $mes_hoje = (int)substr($hoje,4,2); |
---|
| 487 | $sday = 1; |
---|
| 488 | if($_POST['day']) { |
---|
| 489 | $day_ini = (int)$_POST['day']; |
---|
| 490 | } |
---|
| 491 | elseif($_GET['sday']){ |
---|
| 492 | if($_GET['month'] == $mes_hoje) |
---|
[2] | 493 | { |
---|
[5132] | 494 | $day_ini = $this->bo->day; |
---|
| 495 | } |
---|
[4001] | 496 | |
---|
[5132] | 497 | else |
---|
| 498 | { |
---|
| 499 | $day_ini = (int)$_GET['sday']; |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | elseif( ($_POST['dia_ini']) && ($_POST['dia_ini'] == $this->bo->day) ) |
---|
| 503 | { |
---|
| 504 | $day_ini = (int)substr($hoje,6,2); |
---|
| 505 | } |
---|
| 506 | else |
---|
| 507 | { |
---|
| 508 | $day_ini = $this->bo->day; |
---|
| 509 | } |
---|
| 510 | if($_POST['qtd_dias']) |
---|
| 511 | { |
---|
| 512 | $num_dias = (int)$_POST['qtd_dias']; |
---|
| 513 | } |
---|
| 514 | else |
---|
| 515 | { |
---|
| 516 | $num_dias = 0; |
---|
| 517 | } |
---|
[4001] | 518 | |
---|
[5132] | 519 | if (!$this->bo->printer_friendly) |
---|
| 520 | { |
---|
[4114] | 521 | $printer = ''; |
---|
| 522 | $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'"><<</a>'; |
---|
| 523 | $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">>></a>'; |
---|
| 524 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias; |
---|
| 525 | //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; |
---|
| 526 | $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). |
---|
| 527 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
| 528 | lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 529 | //linha abaixo foi adicionada para exibir a pagina do mes em tela |
---|
[5132] | 530 | $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
[2] | 531 | } |
---|
| 532 | else |
---|
| 533 | { |
---|
[4114] | 534 | $printer = '<body bgcolor="'.$phpgw_info['theme']['bg_color'].'">'; |
---|
| 535 | $prev_month_link = ''; |
---|
| 536 | $next_month_link = ''; |
---|
| 537 | $print = ''; |
---|
| 538 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 539 | //linha abaixo foi adicionada para exibir a pagina do mes para impressao |
---|
| 540 | $large_month = $this->display_month_print($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
[2] | 541 | } |
---|
| 542 | |
---|
| 543 | $this->bo->read_holidays(); |
---|
| 544 | |
---|
| 545 | $var = Array( |
---|
[4001] | 546 | 'printer_friendly' => $printer, |
---|
| 547 | 'bg_text' => $this->theme['bg_text'], |
---|
| 548 | 'small_calendar_prev' => $minical_prev, |
---|
| 549 | 'prev_month_link' => $prev_month_link, |
---|
[5132] | 550 | 'month_identifier' => lang(strftime("%B",$m)).' '.$this->bo->year, |
---|
[4001] | 551 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 552 | 'next_month_link' => $next_month_link, |
---|
| 553 | 'small_calendar_next' => $minical_next, |
---|
[5132] | 554 | //'large_month' => $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner), |
---|
[4001] | 555 | 'large_month' => $large_month, |
---|
| 556 | 'print' => $print |
---|
[2] | 557 | ); |
---|
| 558 | |
---|
| 559 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 560 | $p->set_unknowns('remove'); |
---|
[360] | 561 | // Alteracao que desvincula o template para tela do template de impressao do mes (month_print teve que ser criado); |
---|
| 562 | if($print != '') |
---|
| 563 | { |
---|
| 564 | $p->set_file( |
---|
| 565 | Array( |
---|
| 566 | 'index_t' => 'index.tpl' |
---|
| 567 | ) |
---|
| 568 | ); |
---|
| 569 | }else { |
---|
| 570 | $p->set_file( |
---|
| 571 | Array( |
---|
| 572 | 'index_t' => 'month_print.tpl' |
---|
| 573 | ) |
---|
| 574 | ); |
---|
| 575 | } |
---|
[2] | 576 | $p->set_var($var); |
---|
| 577 | return $p->fp('out','index_t'); |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | function week() |
---|
| 581 | { |
---|
[5132] | 582 | echo $this->printer_friendly($this->get_week(),lang('Weekview')); |
---|
[15] | 583 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 584 | } |
---|
| 585 | |
---|
| 586 | function get_week() |
---|
| 587 | { |
---|
| 588 | $this->bo->read_holidays(); |
---|
| 589 | |
---|
| 590 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
| 591 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
| 592 | |
---|
[934] | 593 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
[2] | 594 | { |
---|
[5132] | 595 | $minical_this = $this->mini_calendar( |
---|
[2] | 596 | Array( |
---|
| 597 | 'day' => $this->bo->day, |
---|
[5132] | 598 | 'month' => $this->bo->month, |
---|
[2] | 599 | 'year' => $this->bo->year, |
---|
| 600 | 'link' => 'day', |
---|
[5132] | 601 | 'butons' => 'none', |
---|
[2] | 602 | 'outside_month' => False |
---|
| 603 | ) |
---|
| 604 | ); |
---|
[5132] | 605 | $minical_prev = $this->mini_calendar( |
---|
[2] | 606 | Array( |
---|
| 607 | 'day' => $this->bo->day, |
---|
[5132] | 608 | 'month' => $this->bo->month - 1, |
---|
[2] | 609 | 'year' => $this->bo->year, |
---|
| 610 | 'link' => 'day', |
---|
[5132] | 611 | 'butons' => 'left', |
---|
[2] | 612 | 'outside_month' => False |
---|
| 613 | ) |
---|
| 614 | ); |
---|
[5132] | 615 | $minical_next = $this->mini_calendar( |
---|
[2] | 616 | Array( |
---|
| 617 | 'day' => $this->bo->day, |
---|
[5132] | 618 | 'month' => $this->bo->month + 1, |
---|
[2] | 619 | 'year' => $this->bo->year, |
---|
| 620 | 'link' => 'day', |
---|
[5132] | 621 | 'butons' => 'right', |
---|
[2] | 622 | 'outside_month' => False |
---|
| 623 | ) |
---|
| 624 | ); |
---|
| 625 | } |
---|
| 626 | else |
---|
| 627 | { |
---|
| 628 | |
---|
[5132] | 629 | //NDEE: printer-friendly what? |
---|
[2] | 630 | $minical_this = ''; |
---|
| 631 | $minical_prev = ''; |
---|
| 632 | $minical_next = ''; |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | if (!$this->bo->printer_friendly) |
---|
| 636 | { |
---|
[4114] | 637 | |
---|
[2] | 638 | $printer = ''; |
---|
| 639 | $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'"><<</a>'; |
---|
| 640 | $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">>></a>'; |
---|
[5132] | 641 | $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>'; |
---|
[2] | 642 | } |
---|
| 643 | else |
---|
| 644 | { |
---|
| 645 | |
---|
[5132] | 646 | //NDEE: printer-friendly (weekly-view) |
---|
[2] | 647 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 648 | $prev_week_link = ''; |
---|
| 649 | $next_week_link = ''; |
---|
| 650 | $print = ''; |
---|
| 651 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | $var = Array( |
---|
| 655 | 'printer_friendly' => $print, |
---|
| 656 | 'bg_text' => $this->theme['bg_text'], |
---|
| 657 | 'small_calendar_prev' => $minical_prev, |
---|
| 658 | 'prev_week_link' => $prev_week_link, |
---|
| 659 | 'small_calendar_this' => $minical_this, |
---|
| 660 | 'week_identifier' => $this->bo->get_week_label(), |
---|
| 661 | 'next_week_link' => $next_week_link, |
---|
| 662 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 663 | 'small_calendar_next' => $minical_next, |
---|
| 664 | 'week_display' => $this->display_weekly( |
---|
| 665 | Array( |
---|
| 666 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 667 | 'showyear' => true, |
---|
| 668 | 'owners' => $this->bo->owner |
---|
| 669 | ) |
---|
| 670 | ), |
---|
| 671 | 'print' => $print |
---|
| 672 | ); |
---|
[5132] | 673 | //todo |
---|
[2] | 674 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 675 | $p->set_file( |
---|
| 676 | Array( |
---|
| 677 | 'week_t' => 'week.tpl' |
---|
| 678 | ) |
---|
| 679 | ); |
---|
| 680 | $p->set_var($var); |
---|
[923] | 681 | return $p->fp('out','week_t'); |
---|
| 682 | |
---|
[2] | 683 | } |
---|
| 684 | |
---|
| 685 | function year() |
---|
| 686 | { |
---|
[703] | 687 | if ($_GET['plain'] == "True") |
---|
[2] | 688 | { |
---|
[703] | 689 | |
---|
| 690 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
[2] | 691 | } |
---|
[703] | 692 | else |
---|
| 693 | { |
---|
| 694 | |
---|
| 695 | if($this->bo->printer_friendly) |
---|
| 696 | { |
---|
| 697 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 698 | } |
---|
| 699 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
| 700 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 701 | } |
---|
[2] | 702 | } |
---|
| 703 | |
---|
| 704 | function get_year() |
---|
| 705 | { |
---|
| 706 | if(!$this->bo->printer_friendly) |
---|
| 707 | { |
---|
| 708 | $print = ''; |
---|
| 709 | $left_link = '<a href="'.$this->page('year','&year='.($this->bo->year - 1)).'"><<</a>'; |
---|
| 710 | $right_link = '<a href="'.$this->page('year','&year='.($this->bo->year + 1)).'">>></a>'; |
---|
| 711 | $link = 'day'; |
---|
| 712 | $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>'; |
---|
| 713 | } |
---|
| 714 | else |
---|
| 715 | { |
---|
| 716 | //NDEE: printer-friendly (year-view) |
---|
| 717 | $print = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 718 | $left_link = ''; |
---|
| 719 | $right_link = ''; |
---|
| 720 | $link = ''; |
---|
| 721 | $printer = ''; |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | $var = Array( |
---|
| 725 | 'print' => $print, |
---|
| 726 | 'left_link' => $left_link, |
---|
| 727 | 'font' => $this->theme['font'], |
---|
| 728 | 'year_text' => $this->bo->year, |
---|
| 729 | 'right_link'=> $right_link, |
---|
| 730 | 'printer_friendly'=> $printer |
---|
| 731 | ); |
---|
| 732 | |
---|
| 733 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 734 | $p->set_file( |
---|
| 735 | Array( |
---|
| 736 | 'year_t' => 'year.tpl' |
---|
| 737 | ) |
---|
| 738 | ); |
---|
| 739 | $p->set_block('year_t','year','year'); |
---|
| 740 | $p->set_block('year_t','month','month_handle'); |
---|
| 741 | $p->set_block('year_t','month_sep','month_sep_handle'); |
---|
| 742 | $p->set_var($var); |
---|
| 743 | |
---|
| 744 | for($i=1;$i<=12;$i++) |
---|
| 745 | { |
---|
| 746 | if(($i % 3) == 1) |
---|
| 747 | { |
---|
| 748 | $p->parse('row','month_sep',True); |
---|
| 749 | } |
---|
| 750 | $p->set_var('mini_month',$this->mini_calendar( |
---|
| 751 | Array( |
---|
| 752 | 'day' => 1, |
---|
| 753 | 'month' => $i, |
---|
| 754 | 'year' => $this->bo->year, |
---|
| 755 | 'link' => $link, |
---|
| 756 | 'buttons' => 'none', |
---|
| 757 | 'outside_month' => False |
---|
| 758 | ) |
---|
| 759 | ) |
---|
| 760 | ); |
---|
| 761 | $p->parse('row','month',True); |
---|
| 762 | $p->set_var('mini_month',''); |
---|
| 763 | } |
---|
| 764 | return $p->fp('out','year_t'); |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | function view($vcal_id=0,$cal_date=0) |
---|
| 768 | { |
---|
| 769 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 770 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 771 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('View'); |
---|
[925] | 772 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
[2] | 773 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 774 | |
---|
| 775 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
| 776 | |
---|
| 777 | $date = $cal_date ? $cal_date : 0; |
---|
| 778 | $date = $date ? $date : (int)$_GET['date']; |
---|
[1639] | 779 | |
---|
[2] | 780 | // First, make sure they have permission to this entry |
---|
| 781 | if ($cal_id < 1) |
---|
| 782 | { |
---|
| 783 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
| 784 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 785 | } |
---|
| 786 | |
---|
| 787 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id)) |
---|
| 788 | { |
---|
| 789 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
| 790 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | $event = $this->bo->read_entry($cal_id); |
---|
| 794 | |
---|
| 795 | if(!isset($event['id'])) |
---|
| 796 | { |
---|
| 797 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
| 798 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | $this->bo->repeating_events = Array(); |
---|
| 802 | $this->bo->cached_events = Array(); |
---|
| 803 | $this->bo->repeating_events[0] = $event; |
---|
| 804 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 805 | $this->bo->check_repeating_events($datetime); |
---|
| 806 | $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); |
---|
| 807 | if(is_array($this->bo->cached_events[$check_date][0]) && |
---|
| 808 | $this->bo->cached_events[$check_date][0]['id'] == $event['id']) |
---|
| 809 | { |
---|
| 810 | $starttime = $this->bo->maketime($event['start']); |
---|
| 811 | $endtime = $this->bo->maketime($event['end']); |
---|
| 812 | $event['start']['month'] = $this->bo->month; |
---|
| 813 | $event['start']['mday'] = $this->bo->day; |
---|
| 814 | $event['start']['year'] = $this->bo->year; |
---|
| 815 | $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); |
---|
| 816 | $event['end']['month'] = date('m',$temp_end); |
---|
| 817 | $event['end']['mday'] = date('d',$temp_end); |
---|
| 818 | $event['end']['year'] = date('Y',$temp_end); |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | if(!$this->view_event($event,True)) |
---|
| 822 | { |
---|
| 823 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
| 824 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | $p = $GLOBALS['phpgw']->template; |
---|
| 828 | $p->set_file( |
---|
| 829 | Array( |
---|
| 830 | 'form_button' => 'form_button_script.tpl' |
---|
| 831 | ) |
---|
| 832 | ); |
---|
| 833 | |
---|
[5132] | 834 | $p->set_file(Array('form_button' => 'form_button_script.tpl' )); |
---|
[2] | 835 | |
---|
[5132] | 836 | $button_left = $button_center = $button_right = $button_right_suggestion = ''; |
---|
| 837 | |
---|
[2] | 838 | if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
| 839 | { |
---|
| 840 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
| 841 | { |
---|
| 842 | $var = Array( |
---|
| 843 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
[5132] | 844 | // added date to the action parameteres so we can add an exception to an edited event |
---|
| 845 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id.'&date='.$date), |
---|
[2] | 846 | 'action_text_button' => lang('Edit Single'), |
---|
| 847 | 'action_confirm_button' => '', |
---|
| 848 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 849 | 'edit_type' => 'single', |
---|
| 850 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
| 851 | )) |
---|
| 852 | ); |
---|
| 853 | $p->set_var($var); |
---|
| 854 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 855 | |
---|
| 856 | $var = Array( |
---|
| 857 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 858 | 'action_text_button' => lang('Edit Series'), |
---|
| 859 | 'action_confirm_button' => '', |
---|
| 860 | 'action_extra_field' => $this->html->input_hidden('edit_type','series') |
---|
| 861 | ); |
---|
| 862 | $p->set_var($var); |
---|
| 863 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 864 | } |
---|
| 865 | else |
---|
| 866 | { |
---|
| 867 | $var = Array( |
---|
| 868 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 869 | 'action_text_button' => lang('Edit'), |
---|
| 870 | 'action_confirm_button' => '', |
---|
| 871 | 'action_extra_field' => '' |
---|
| 872 | ); |
---|
| 873 | $p->set_var($var); |
---|
| 874 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 875 | } |
---|
| 876 | |
---|
| 877 | $var = Array( |
---|
| 878 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
| 879 | 'action_text_button' => lang('Alarm Management'), |
---|
| 880 | 'action_confirm_button' => '', |
---|
| 881 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 882 | 'cal_id' => $cal_id, |
---|
| 883 | 'return_to' => $this->bo->return_to |
---|
| 884 | )) |
---|
| 885 | ); |
---|
| 886 | $p->set_var($var); |
---|
| 887 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 888 | } |
---|
| 889 | |
---|
| 890 | if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) |
---|
| 891 | { |
---|
| 892 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
| 893 | { |
---|
| 894 | $var = Array( |
---|
| 895 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 896 | 'action_text_button' => lang('Delete Single'), |
---|
[5132] | 897 | '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] | 898 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 899 | 'delete_type' => 'single', |
---|
| 900 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
| 901 | )) |
---|
| 902 | ); |
---|
| 903 | $p->set_var($var); |
---|
| 904 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 905 | |
---|
| 906 | $var = Array( |
---|
| 907 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 908 | 'action_text_button' => lang('Delete Series'), |
---|
[204] | 909 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
[2] | 910 | 'action_extra_field' => $this->html->input_hidden('delete_type','series') |
---|
| 911 | ); |
---|
| 912 | $p->set_var($var); |
---|
| 913 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 914 | |
---|
| 915 | if($event['recur_exception']) |
---|
| 916 | { |
---|
| 917 | $var = Array( |
---|
| 918 | 'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), |
---|
| 919 | 'action_text_button' => lang('Reinstate'), |
---|
| 920 | 'action_confirm_button' => '', |
---|
| 921 | 'action_extra_field' => '' |
---|
| 922 | ); |
---|
| 923 | $p->set_var($var); |
---|
| 924 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 925 | } |
---|
| 926 | } |
---|
| 927 | else |
---|
| 928 | { |
---|
| 929 | $var = Array( |
---|
| 930 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 931 | 'action_text_button' => lang('Delete'), |
---|
[204] | 932 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
[2] | 933 | 'action_extra_field' => '' |
---|
| 934 | ); |
---|
| 935 | $p->set_var($var); |
---|
| 936 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 937 | } |
---|
| 938 | } |
---|
| 939 | else |
---|
| 940 | { |
---|
| 941 | // allow me (who I am logged in as) to set up an alarm |
---|
| 942 | // if I am a participant, but not the owner |
---|
| 943 | reset($event['participants']); |
---|
| 944 | while (list($user,$short_status) = each($event['participants'])) |
---|
| 945 | { |
---|
| 946 | if ($GLOBALS['phpgw_info']['user']['account_id'] == $user) |
---|
| 947 | { |
---|
| 948 | $var = Array( |
---|
| 949 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
| 950 | 'action_text_button' => lang('Alarm Management'), |
---|
| 951 | 'action_confirm_button' => '', |
---|
| 952 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 953 | 'cal_id' => $cal_id, |
---|
| 954 | 'return_to' => $this->bo->return_to |
---|
| 955 | )) |
---|
| 956 | ); |
---|
| 957 | $p->set_var($var); |
---|
| 958 | echo $p->fp('out','form_button'); |
---|
| 959 | } |
---|
| 960 | } |
---|
| 961 | } |
---|
[5132] | 962 | $uid = $event['uid']; |
---|
| 963 | $owner = $event['owner']; |
---|
| 964 | $title = $event['title']; |
---|
| 965 | $description = rtrim(utf8_encode($event['description'])); |
---|
| 966 | $location = $event['location']; |
---|
| 967 | $start = $event['start']; |
---|
| 968 | $end = $event['end']; |
---|
| 969 | |
---|
| 970 | $p->set_var( 'suggestion', $this->build_suggestion( $event , $GLOBALS['phpgw_info']['user']['account_id']) ); |
---|
[2] | 971 | |
---|
| 972 | $var = Array( |
---|
| 973 | 'action_url_button' => $this->page('export'), |
---|
| 974 | 'action_text_button' => lang('Export'), |
---|
| 975 | 'action_confirm_button' => '', |
---|
| 976 | 'action_extra_field' => $this->html->input_hidden('cal_id',$cal_id) |
---|
| 977 | ); |
---|
| 978 | $p->set_var($var); |
---|
| 979 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 980 | |
---|
| 981 | if ($this->bo->return_to) |
---|
| 982 | { |
---|
| 983 | $var = Array( |
---|
| 984 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 985 | 'action_text_button' => lang('Done'), |
---|
| 986 | 'action_confirm_button' => '', |
---|
| 987 | 'action_extra_field' => '' |
---|
| 988 | ); |
---|
| 989 | $p->set_var($var); |
---|
| 990 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 991 | } |
---|
[5132] | 992 | |
---|
[5158] | 993 | if($_SESSION['phpgw_info']['expressomail']['user']['account_id'] != $owner){ |
---|
[5132] | 994 | $label_suggest = lang('Suggest new hour'); |
---|
| 995 | $button_right_suggestion = "<td><input type=\"button\" style=\"height: 16px; width: 110px; font-size: 10px;\" value=\"" . $label_suggest . "\"onclick=\"show_suggestion()\";</td>"; |
---|
| 996 | |
---|
[2] | 997 | $p->set_var(array( |
---|
| 998 | 'button_left' => $button_left, |
---|
| 999 | 'button_center' => $button_center, |
---|
[5132] | 1000 | 'button_right' => $button_right, |
---|
| 1001 | 'button_right_suggestion' => $button_right_suggestion |
---|
[2] | 1002 | )); |
---|
[5158] | 1003 | }else{ |
---|
| 1004 | $p->set_var(array( |
---|
| 1005 | 'button_left' => $button_left, |
---|
| 1006 | 'button_center' => $button_center, |
---|
| 1007 | 'button_right' => $button_right, |
---|
| 1008 | )); |
---|
| 1009 | } |
---|
[2] | 1010 | $p->pfp('phpgw_body','view_event'); |
---|
| 1011 | |
---|
| 1012 | $GLOBALS['phpgw']->hooks->process(array( |
---|
| 1013 | 'location' => 'calendar_view', |
---|
| 1014 | 'cal_id' => $cal_id |
---|
| 1015 | )); |
---|
| 1016 | |
---|
[15] | 1017 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 1018 | } |
---|
| 1019 | |
---|
[5132] | 1020 | function build_suggestion( $event , $user = false ) |
---|
| 1021 | { |
---|
| 1022 | $p = $GLOBALS['phpgw']->template; |
---|
| 1023 | |
---|
| 1024 | $p->set_file( |
---|
| 1025 | Array( |
---|
| 1026 | 'suggestion' => 'suggestion.tpl' |
---|
| 1027 | ) |
---|
| 1028 | ); |
---|
| 1029 | |
---|
[5316] | 1030 | include_once(dirname(__FILE__).'/class.ex_participants.inc.php'); |
---|
[5132] | 1031 | $exParticipants = new exParticipants(); |
---|
| 1032 | $exParticipants->setParticipantsBySerializable($event['ex_participants']); |
---|
| 1033 | |
---|
| 1034 | $cal_id = $event['id']; |
---|
| 1035 | $uid = $event['uid']; |
---|
| 1036 | $owner = $event['owner']; |
---|
| 1037 | $title = $event['title']; |
---|
| 1038 | $description = rtrim(utf8_encode($event['description'])); |
---|
| 1039 | $location = $event['location']; |
---|
| 1040 | $start = $event['start']; |
---|
| 1041 | $end = $event['end']; |
---|
| 1042 | |
---|
| 1043 | if( $owner == -2 ) |
---|
| 1044 | { |
---|
| 1045 | $to = $event['organizer']; |
---|
| 1046 | $mail = array(); |
---|
| 1047 | |
---|
| 1048 | if( preg_match ('(<([^>]*@[^>]*)>)', $to, $mail ) ) |
---|
| 1049 | $to = $mail[1]; |
---|
| 1050 | } |
---|
| 1051 | else |
---|
| 1052 | { |
---|
| 1053 | $preferences = CreateObject('phpgwapi.preferences',$owner); |
---|
| 1054 | $to = $preferences->email_address($owner); |
---|
| 1055 | } |
---|
| 1056 | |
---|
| 1057 | |
---|
| 1058 | if(((int)$start['month']) < 10 && strlen($start['month']) == 1) |
---|
| 1059 | $mes = "0" . $start['month']; |
---|
| 1060 | else |
---|
| 1061 | $mes = $start['month']; |
---|
| 1062 | |
---|
| 1063 | if(((int)$start['mday']) < 10 && strlen($start['mday']) == 1) |
---|
| 1064 | $dia = "0" . $start['mday']; |
---|
| 1065 | else |
---|
| 1066 | $dia = $start['mday']; |
---|
| 1067 | |
---|
| 1068 | if(((int)$start['hour']) < 10 && strlen($start['hour']) == 1) |
---|
| 1069 | $hor = "0" . $start['hour']; |
---|
| 1070 | else |
---|
| 1071 | $hor = $start['hour']; |
---|
| 1072 | |
---|
| 1073 | if(((int)$start['min']) < 10 && strlen($start['min']) == 1) |
---|
| 1074 | $min = "0" . $start['min']; |
---|
| 1075 | else |
---|
| 1076 | $min = $start['min']; |
---|
| 1077 | |
---|
| 1078 | if(((int)$end['month']) < 10 && strlen($end['month']) == 1) |
---|
| 1079 | $end['month'] = "0" . $end['month']; |
---|
| 1080 | |
---|
| 1081 | if(((int)$end['mday']) < 10 && strlen($end['mday']) == 1) |
---|
| 1082 | $end['mday'] = "0" . $end['mday']; |
---|
| 1083 | |
---|
| 1084 | if(((int)$end['hour']) < 10 && strlen($end['hour']) == 1) |
---|
| 1085 | $end['hour'] = "0" . $end['hour']; |
---|
| 1086 | |
---|
| 1087 | if(((int)$end['min']) < 10 && strlen($end['min']) == 1) |
---|
| 1088 | $end['min'] = "0" . $end['min']; |
---|
| 1089 | |
---|
| 1090 | $start_date = $dia . "/" . $mes . "/" . $start['year']; |
---|
| 1091 | $start_hour = $hor . ":" . $min; |
---|
| 1092 | $end_date = $end['mday'] . "/" . $mes . "/" . $start['year']; |
---|
| 1093 | $end_hour = $end['hour'] . ":" . $end['min']; |
---|
| 1094 | |
---|
| 1095 | $notify_message = lang('suggest new hour'); |
---|
| 1096 | $start_h = substr($start_hour, 0, strpos($start_hour, ":")); |
---|
| 1097 | $start_m = substr($start_hour, strpos($start_hour, ":")+1); |
---|
| 1098 | $end_h = substr($end_hour, 0, strpos($end_hour, ":")); |
---|
| 1099 | $end_m = substr($end_hour, strpos($end_hour, ":")+1); |
---|
| 1100 | |
---|
| 1101 | $p->set_var('notify_message', $notify_message); |
---|
| 1102 | $p->set_var('action_form', $this->page('send_suggest_owner')); |
---|
| 1103 | $p->set_var('lang_start_hour', lang('Start hour')); |
---|
| 1104 | $p->set_var('lang_end_hour', lang('End hour')); |
---|
| 1105 | $p->set_var('lang_start_date', lang('Start date')); |
---|
| 1106 | $p->set_var('lang_end_date', lang('End date')); |
---|
| 1107 | $p->set_var('lang_suggest_new_hour', lang('Suggest new hour')); |
---|
| 1108 | $p->set_var('cal_id', $cal_id); |
---|
| 1109 | $p->set_var('to', $to); |
---|
| 1110 | $p->set_var('title', $title); |
---|
| 1111 | $p->set_var('description', $description); |
---|
| 1112 | $p->set_var('uid', $uid); |
---|
| 1113 | $p->set_var('location', $location); |
---|
| 1114 | $p->set_var('ex_participants', $exParticipants->getParticipantsMailsString()); |
---|
| 1115 | $p->set_var('start_date', $start_date); |
---|
| 1116 | $p->set_var('start_hour', $start_h); |
---|
| 1117 | $p->set_var('start_minute', $start_m); |
---|
| 1118 | $p->set_var('end_date', $end_date); |
---|
| 1119 | $p->set_var('end_hour', $end_h); |
---|
| 1120 | $p->set_var('end_minute', $end_m); |
---|
| 1121 | $p->set_var('url', $GLOBALS['phpgw_info']['server']['webserver_url']); |
---|
| 1122 | $p->set_var('user', $user); |
---|
| 1123 | |
---|
| 1124 | return $p->fp( 'suggestion', 'suggestion' ); |
---|
| 1125 | } |
---|
| 1126 | |
---|
| 1127 | /** |
---|
| 1128 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 1129 | * @abstract: método que envia a sugestão para o criador do compromisso. |
---|
| 1130 | * @author Prognus Software Livre (http://www.prognus.com.br) |
---|
| 1131 | */ |
---|
| 1132 | function send_suggest_owner() |
---|
| 1133 | { |
---|
| 1134 | $array_data_inicio = explode('/',$_POST['data_inicio']); |
---|
| 1135 | $array_data_final = explode('/',$_POST['data_final']); |
---|
| 1136 | $hora_inicio = $_POST['hora_inicio']; |
---|
| 1137 | $minuto_inicio = $_POST['minuto_inicio']; |
---|
| 1138 | $hora_final = $_POST['hora_final']; |
---|
| 1139 | $minuto_final = $_POST['minuto_final']; |
---|
| 1140 | |
---|
| 1141 | $vars = $_GET['cal_id']; |
---|
| 1142 | $array_vars = explode(";", $vars); |
---|
| 1143 | $cal_id = $array_vars[0]; |
---|
| 1144 | $to = $array_vars[1]; |
---|
| 1145 | $title_ = $array_vars[2]; |
---|
| 1146 | $description_ = $array_vars[3]; |
---|
| 1147 | $uid = $array_vars[4]; |
---|
| 1148 | $location = $array_vars[5]; |
---|
| 1149 | $ex_participants = $array_vars[6]; |
---|
| 1150 | $user = $array_vars[7]; |
---|
| 1151 | $time_suggest = array('hora_inicio' => $hora_inicio, 'hora_final' => $hora_final, 'minuto_inicio' => $minuto_inicio, 'minuto_final' => $minuto_final); |
---|
| 1152 | |
---|
| 1153 | $cal_id = $this->bo->send_suggestion_external_owner($cal_id, $uid, $to, $time_suggest, $array_data_inicio, $array_data_final, $title_, $description_, $location, $ex_participants,$user); |
---|
| 1154 | |
---|
| 1155 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
| 1156 | |
---|
| 1157 | } |
---|
| 1158 | |
---|
| 1159 | |
---|
[2] | 1160 | function edit($params='') |
---|
| 1161 | { |
---|
| 1162 | if($this->debug) |
---|
| 1163 | { |
---|
| 1164 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
| 1165 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
| 1166 | } |
---|
| 1167 | |
---|
| 1168 | if(isset($_GET['readsess'])) |
---|
| 1169 | { |
---|
| 1170 | $params['readsess'] = $_GET['readsess']; |
---|
| 1171 | $params['cd'] = 0; |
---|
| 1172 | } |
---|
| 1173 | |
---|
| 1174 | if($this->debug) |
---|
| 1175 | { |
---|
| 1176 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
| 1177 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | if($params != '' && @is_array($params) && @isset($params['readsess'])) |
---|
| 1181 | { |
---|
| 1182 | $can_edit = True; |
---|
| 1183 | $this->edit_form( |
---|
| 1184 | Array( |
---|
| 1185 | 'event' => $this->bo->restore_from_appsession(), |
---|
| 1186 | 'cd' => $params['cd'] |
---|
| 1187 | ) |
---|
| 1188 | ); |
---|
| 1189 | } |
---|
| 1190 | elseif(isset($_GET['cal_id'])) |
---|
| 1191 | { |
---|
| 1192 | $cal_id = (int)$_GET['cal_id']; |
---|
| 1193 | $event = $this->bo->read_entry($cal_id); |
---|
| 1194 | |
---|
| 1195 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
| 1196 | { |
---|
| 1197 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
| 1198 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1199 | } |
---|
| 1200 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') |
---|
| 1201 | { |
---|
| 1202 | $event['id'] = 0; |
---|
| 1203 | $this->bo->set_recur_date($event,$_POST['date']); |
---|
| 1204 | $event['recur_type'] = MCAL_RECUR_NONE; |
---|
| 1205 | $event['recur_interval'] = 0; |
---|
| 1206 | $event['recur_data'] = 0; |
---|
| 1207 | $event['recur_enddate']['month'] = 0; |
---|
| 1208 | $event['recur_enddate']['mday'] = 0; |
---|
| 1209 | $event['recur_enddate']['year'] = 0; |
---|
| 1210 | $event['recur_exception'] = array(); |
---|
| 1211 | } |
---|
[663] | 1212 | $plain = $_GET['plain']; |
---|
| 1213 | |
---|
[2] | 1214 | $this->edit_form( |
---|
| 1215 | Array( |
---|
| 1216 | 'event' => $event, |
---|
[663] | 1217 | 'cd' => $cd, |
---|
[5132] | 1218 | 'plain' => $plain, |
---|
| 1219 | 'date' => $_GET['date'] |
---|
[2] | 1220 | ) |
---|
| 1221 | ); |
---|
| 1222 | } |
---|
| 1223 | } |
---|
| 1224 | |
---|
[57] | 1225 | function export_all() |
---|
| 1226 | { |
---|
| 1227 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
| 1228 | srand((double)microtime()*1000000); |
---|
| 1229 | $random_number = rand(100000000,999999999); |
---|
| 1230 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
| 1231 | $filename = $temp_path . $newfilename; |
---|
| 1232 | $attach_fd = fopen($filename,"w+"); |
---|
| 1233 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
| 1234 | foreach($event_ids as $key => $id) |
---|
| 1235 | { |
---|
| 1236 | $event[$key]=$this->bo->read_entry($id); |
---|
| 1237 | } |
---|
| 1238 | include_once('class.bocalendar.inc.php'); |
---|
| 1239 | $cal = new bocalendar; |
---|
| 1240 | $tmpattach=$cal->create_vcard($event); |
---|
| 1241 | fwrite($attach_fd,$tmpattach); |
---|
| 1242 | header ("Content-Type: text/plain"); |
---|
| 1243 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1244 | header('Content-Length: ' . filesize($filename)); |
---|
[5269] | 1245 | header("Content-disposition: attachment; filename="."export.ics"); |
---|
[57] | 1246 | readfile($filename); |
---|
| 1247 | fclose($attach_fd); |
---|
| 1248 | } |
---|
| 1249 | |
---|
[2] | 1250 | function export($vcal_id=0) |
---|
| 1251 | { |
---|
[5132] | 1252 | $extern = true; |
---|
| 1253 | $method = 'PUBLISH'; |
---|
[29] | 1254 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
| 1255 | srand((double)microtime()*1000000); |
---|
| 1256 | $random_number = rand(100000000,999999999); |
---|
| 1257 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
| 1258 | $filename = $temp_path . $newfilename; |
---|
| 1259 | $attach_fd = fopen($filename,"w+"); |
---|
| 1260 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
[57] | 1261 | $event[0] = $this->bo->read_entry($cal_id); |
---|
[5132] | 1262 | |
---|
[29] | 1263 | include_once('class.bocalendar.inc.php'); |
---|
| 1264 | $cal = new bocalendar; |
---|
[5132] | 1265 | $tmpattach=$cal->create_vcard($event, $method, $extern); |
---|
[29] | 1266 | fwrite($attach_fd,$tmpattach); |
---|
| 1267 | header ("Content-Type: text/plain"); |
---|
| 1268 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1269 | header('Content-Length: ' . filesize($filename)); |
---|
[5269] | 1270 | header("Content-disposition: attachment; filename="."export.ics"); |
---|
[29] | 1271 | readfile($filename); |
---|
| 1272 | fclose($attach_fd); |
---|
[2] | 1273 | } |
---|
| 1274 | |
---|
| 1275 | function reinstate_list($params='') |
---|
| 1276 | { |
---|
| 1277 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1278 | { |
---|
| 1279 | $this->no_edit(); |
---|
| 1280 | } |
---|
| 1281 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1282 | { |
---|
| 1283 | $this->index(); |
---|
| 1284 | } |
---|
| 1285 | |
---|
| 1286 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1287 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1288 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Reinstate'); |
---|
| 1289 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1290 | |
---|
| 1291 | $cal_id = get_var('cal_id',array('GET'),$params['cal_id']); |
---|
| 1292 | |
---|
| 1293 | if ($cal_id < 1) |
---|
| 1294 | { |
---|
| 1295 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
| 1296 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1297 | } |
---|
| 1298 | |
---|
| 1299 | if(!$this->bo->check_perms(PHPGW_ACL_READ)) |
---|
| 1300 | { |
---|
| 1301 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
| 1302 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1303 | } |
---|
| 1304 | |
---|
| 1305 | $event = $this->bo->read_entry($cal_id); |
---|
| 1306 | |
---|
| 1307 | if(!isset($event['id'])) |
---|
| 1308 | { |
---|
| 1309 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
| 1310 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1311 | } |
---|
| 1312 | elseif(!isset($event['recur_exception'])) |
---|
| 1313 | { |
---|
| 1314 | echo '<center>'.lang('Sorry, this event does not have exceptions defined').'.'.'</center>'."\n"; |
---|
| 1315 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1316 | } |
---|
| 1317 | |
---|
| 1318 | if(!$this->view_event($event,True)) |
---|
| 1319 | { |
---|
| 1320 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
| 1321 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1322 | } |
---|
| 1323 | |
---|
| 1324 | $p = &$GLOBALS['phpgw']->template; |
---|
| 1325 | $p->set_file( |
---|
| 1326 | Array( |
---|
| 1327 | 'form_button' => 'form_button_script.tpl' |
---|
| 1328 | ) |
---|
| 1329 | ); |
---|
| 1330 | |
---|
| 1331 | $str = ''; |
---|
| 1332 | |
---|
| 1333 | for($i=0;$i<count($event['recur_exception']);$i++) |
---|
| 1334 | { |
---|
| 1335 | $str .= ' <option value="'.$i.'">'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).'</option>'."\n"; |
---|
| 1336 | } |
---|
| 1337 | $this->output_template_array($p,'row','list',array( |
---|
| 1338 | 'field' => lang('Exceptions'), |
---|
| 1339 | 'data' => '<select name="reinstate_index[]" multiple size="5">'."\n".$str.'</select>' |
---|
| 1340 | )); |
---|
| 1341 | |
---|
| 1342 | $var = Array( |
---|
| 1343 | 'action_url_button' => $this->page('reinstate','&cal_id='.$cal_id), |
---|
| 1344 | 'action_text_button' => lang('Reinstate'), |
---|
| 1345 | 'action_confirm_button' => '', |
---|
| 1346 | 'action_extra_field' => '' |
---|
| 1347 | ); |
---|
| 1348 | $p->set_var($var); |
---|
| 1349 | $button_left = '<td>'.$p->fp('out','form_button').'</td>'; |
---|
| 1350 | |
---|
| 1351 | $var = Array( |
---|
| 1352 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
| 1353 | 'action_text_button' => lang('Cancel'), |
---|
| 1354 | 'action_confirm_button' => '', |
---|
| 1355 | 'action_extra_field' => '' |
---|
| 1356 | ); |
---|
| 1357 | $p->set_var($var); |
---|
| 1358 | $button_left .= '<td>'.$p->fp('out','form_button').'</td>'; |
---|
| 1359 | |
---|
| 1360 | $p->set_var('button_left',$button_left); |
---|
| 1361 | $p->pfp('phpgw_body','view_event'); |
---|
| 1362 | } |
---|
| 1363 | |
---|
| 1364 | function reinstate($params='') |
---|
| 1365 | { |
---|
| 1366 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1367 | { |
---|
| 1368 | $this->no_edit(); |
---|
| 1369 | } |
---|
| 1370 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1371 | { |
---|
| 1372 | $this->index(); |
---|
| 1373 | } |
---|
| 1374 | $cal_id = (isset($params['cal_id']) ? (int)$params['cal_id'] : ''); |
---|
| 1375 | $cal_id = ($cal_id == '' ? (int)$_GET['cal_id'] : $cal_id); |
---|
| 1376 | |
---|
| 1377 | $reinstate_index = (isset($params['reinstate_index']) ? (int)$params['reinstate_index'] : ''); |
---|
| 1378 | $reinstate_index = ($reinstate_index == '' ? (int)$_POST['reinstate_index'] : $reinstate_index); |
---|
| 1379 | if($this->debug) |
---|
| 1380 | { |
---|
| 1381 | echo '<!-- Calling bo->reinstate -->'."\n"; |
---|
| 1382 | } |
---|
| 1383 | $cd = $this->bo->reinstate( |
---|
| 1384 | Array( |
---|
| 1385 | 'cal_id' => $cal_id, |
---|
| 1386 | 'reinstate_index' => $reinstate_index |
---|
| 1387 | ) |
---|
| 1388 | ); |
---|
| 1389 | if($this->debug) |
---|
| 1390 | { |
---|
| 1391 | echo '<!-- Return Value = '.$cd.' -->'."\n"; |
---|
| 1392 | } |
---|
| 1393 | if ($this->bo->return_to) |
---|
| 1394 | { |
---|
| 1395 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1396 | } |
---|
| 1397 | else |
---|
| 1398 | { |
---|
| 1399 | Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); |
---|
| 1400 | } |
---|
| 1401 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1402 | } |
---|
| 1403 | |
---|
| 1404 | function add($cd=0,$readsess=0) |
---|
| 1405 | { |
---|
| 1406 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1407 | { |
---|
| 1408 | $this->index(); |
---|
| 1409 | } |
---|
| 1410 | |
---|
| 1411 | if($readsess) |
---|
| 1412 | { |
---|
| 1413 | $event = $this->bo->restore_from_appsession; |
---|
| 1414 | if(!$event['owner']) |
---|
| 1415 | { |
---|
| 1416 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
| 1417 | } |
---|
| 1418 | $can_edit = True; |
---|
| 1419 | } |
---|
| 1420 | else |
---|
| 1421 | { |
---|
| 1422 | $this->bo->event_init(); |
---|
| 1423 | $this->bo->add_attribute('id',0); |
---|
| 1424 | |
---|
| 1425 | $can_edit = True; |
---|
| 1426 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
| 1427 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); |
---|
| 1428 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
| 1429 | $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; |
---|
| 1430 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
[36] | 1431 | |
---|
| 1432 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
| 1433 | if ($subject != '0') |
---|
| 1434 | { |
---|
| 1435 | $description = (string)(get_var('description',array('GET'),0)); |
---|
| 1436 | $location = (string)(get_var('location',array('GET'),0)); |
---|
| 1437 | } |
---|
| 1438 | else |
---|
| 1439 | unset($subject); |
---|
| 1440 | |
---|
[2] | 1441 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
| 1442 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
[36] | 1443 | $this->bo->set_title($subject); |
---|
| 1444 | $this->bo->set_description($description); |
---|
| 1445 | $this->bo->add_attribute('location',$location); |
---|
[2] | 1446 | $this->bo->set_ex_participants(''); |
---|
| 1447 | $this->bo->add_attribute('uid',''); |
---|
| 1448 | $this->bo->add_attribute('priority',2); |
---|
| 1449 | if(@$this->bo->prefs['calendar']['default_private']) |
---|
| 1450 | { |
---|
| 1451 | $this->bo->set_class(False); |
---|
| 1452 | } |
---|
| 1453 | else |
---|
| 1454 | { |
---|
| 1455 | $this->bo->set_class(True); |
---|
| 1456 | } |
---|
| 1457 | // Add participants |
---|
[5132] | 1458 | $participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); |
---|
| 1459 | for($_f_part=0; $_f_part<count($participants); $_f_part++) |
---|
| 1460 | { |
---|
| 1461 | $this->bo->add_attribute('participants','A',$participants[$_f_part]); |
---|
| 1462 | } |
---|
[2] | 1463 | // Add misc |
---|
| 1464 | $this->bo->add_attribute('participants','A',$this->bo->owner); |
---|
| 1465 | $this->bo->set_recur_none(); |
---|
| 1466 | $event = $this->bo->get_cached_event(); |
---|
| 1467 | |
---|
| 1468 | } |
---|
| 1469 | $this->edit_form( |
---|
| 1470 | Array( |
---|
| 1471 | 'event' => $event, |
---|
[663] | 1472 | 'cd' => $cd, |
---|
| 1473 | 'plain' => $_GET['plain'] |
---|
[2] | 1474 | ) |
---|
| 1475 | ); |
---|
[15] | 1476 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 1477 | } |
---|
| 1478 | |
---|
| 1479 | function delete() |
---|
| 1480 | { |
---|
| 1481 | if(!isset($_GET['cal_id'])) |
---|
| 1482 | { |
---|
| 1483 | Header('Location: '.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))); |
---|
| 1484 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1485 | } |
---|
| 1486 | |
---|
| 1487 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); |
---|
| 1488 | if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id = (int)$_GET['cal_id'])) |
---|
| 1489 | { |
---|
| 1490 | if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single') |
---|
| 1491 | { |
---|
| 1492 | $date = $_POST['date']; |
---|
| 1493 | $cd = $this->bo->delete_single( |
---|
| 1494 | Array( |
---|
| 1495 | 'id' => $cal_id, |
---|
| 1496 | 'year' => substr($date,0,4), |
---|
| 1497 | 'month' => substr($date,4,2), |
---|
| 1498 | 'day' => substr($date,6,2) |
---|
| 1499 | ) |
---|
| 1500 | ); |
---|
| 1501 | } |
---|
| 1502 | elseif((isset($_POST['delete_type']) && $_POST['delete_type'] == 'series') || !isset($_POST['delete_type'])) |
---|
| 1503 | { |
---|
| 1504 | $cd = $this->bo->delete_entry($cal_id); |
---|
| 1505 | $this->bo->expunge(); |
---|
| 1506 | } |
---|
| 1507 | } |
---|
| 1508 | else |
---|
| 1509 | { |
---|
| 1510 | $cd = ''; |
---|
| 1511 | } |
---|
| 1512 | if ($this->bo->return_to) |
---|
| 1513 | { |
---|
| 1514 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1515 | } |
---|
| 1516 | else |
---|
| 1517 | { |
---|
| 1518 | Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); |
---|
| 1519 | } |
---|
| 1520 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1521 | } |
---|
| 1522 | |
---|
[5132] | 1523 | |
---|
| 1524 | |
---|
| 1525 | function getLdap() |
---|
| 1526 | { |
---|
| 1527 | include_once('../phpgwapi/inc/class.common.inc.php'); |
---|
| 1528 | $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; |
---|
| 1529 | $common = new common(); |
---|
| 1530 | |
---|
| 1531 | if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && |
---|
| 1532 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && |
---|
| 1533 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) |
---|
| 1534 | { |
---|
| 1535 | $ldap = $common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], |
---|
| 1536 | $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], |
---|
| 1537 | $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); |
---|
| 1538 | } |
---|
| 1539 | else |
---|
| 1540 | { |
---|
| 1541 | $ldap = $common->ldapConnect(); |
---|
| 1542 | } |
---|
| 1543 | |
---|
| 1544 | return $ldap; |
---|
| 1545 | } |
---|
| 1546 | |
---|
| 1547 | |
---|
| 1548 | |
---|
[1447] | 1549 | function disponibility($params) { |
---|
[1593] | 1550 | |
---|
[1447] | 1551 | if(!isset($_SESSION['phpgw_info']['expresso']['expressoAdmin'])) { |
---|
| 1552 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
| 1553 | $c->read_repository(); |
---|
| 1554 | $current_config = $c->config_data; |
---|
[1593] | 1555 | |
---|
[1447] | 1556 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
[1593] | 1557 | |
---|
[1447] | 1558 | $_SESSION['phpgw_info']['expresso']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 1559 | $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 1560 | $_SESSION['phpgw_info']['expresso']['cc_ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 1561 | $_SESSION['phpgw_info']['expresso']['expressoAdmin'] = $current_config; |
---|
| 1562 | $_SESSION['phpgw_info']['expresso']['global_denied_users'] = $GLOBALS['phpgw_info']['server']['global_denied_users']; |
---|
| 1563 | $_SESSION['phpgw_info']['expresso']['global_denied_groups'] = $GLOBALS['phpgw_info']['server']['global_denied_groups']; |
---|
| 1564 | } |
---|
| 1565 | $str_participants = substr($_GET['participants'],0,strlen($_GET['participants'])-1); //remove the last comma |
---|
| 1566 | $participants= array(); |
---|
| 1567 | $participants_splited = explode(",",$str_participants); |
---|
[5132] | 1568 | |
---|
| 1569 | |
---|
| 1570 | $ldap = $this->getLdap(); |
---|
| 1571 | foreach ($participants_splited as $participant) |
---|
| 1572 | { |
---|
[1447] | 1573 | $participant = substr($participant,0,strlen($participant)-1); |
---|
[5132] | 1574 | |
---|
| 1575 | $entry = array(); |
---|
| 1576 | $extern_contact = false; |
---|
| 1577 | |
---|
| 1578 | $justthese = array('accountStatus'); |
---|
| 1579 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uidNumber=".(int)$participant."))"; |
---|
| 1580 | $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); |
---|
| 1581 | $entry = ldap_get_entries($ldap, $search); |
---|
| 1582 | |
---|
| 1583 | if($entry[0]['accountstatus'][0] == "false") |
---|
| 1584 | $extern_contact = true; |
---|
| 1585 | |
---|
| 1586 | |
---|
[1447] | 1587 | $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$participant); |
---|
[5132] | 1588 | |
---|
[1447] | 1589 | if($acct_type=='g') { |
---|
| 1590 | $bo_groups = CreateObject('expressoAdmin1_2.group'); |
---|
[5132] | 1591 | $users = $bo_groups->get_info($participant); |
---|
[1447] | 1592 | foreach($users['memberuid_info'] as $user) { |
---|
[5132] | 1593 | if($user['type']==u){ |
---|
| 1594 | if (!$user['uidnumber']){ |
---|
| 1595 | continue; |
---|
| 1596 | } |
---|
[1447] | 1597 | $participants[$user['uidnumber']] = 'U'; |
---|
| 1598 | } |
---|
| 1599 | } |
---|
[5132] | 1600 | } |
---|
| 1601 | else |
---|
| 1602 | { |
---|
| 1603 | if($extern_contact) |
---|
| 1604 | { |
---|
| 1605 | $participants[$participant] = 'I'; |
---|
| 1606 | continue; |
---|
| 1607 | } |
---|
| 1608 | |
---|
| 1609 | if (!$participant) |
---|
| 1610 | continue; |
---|
| 1611 | |
---|
[1447] | 1612 | $participants[$participant] = 'U'; |
---|
| 1613 | } |
---|
| 1614 | } |
---|
[1593] | 1615 | |
---|
[1447] | 1616 | $date = explode("/",$_GET['date']); |
---|
| 1617 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$date[1],$date[0],$date[2]) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 1618 | |
---|
| 1619 | echo $this->print_disponibility( |
---|
| 1620 | Array( |
---|
| 1621 | 'date' => $freetime, |
---|
| 1622 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 1623 | 'endtime' => 0, |
---|
| 1624 | 'participants' => $participants |
---|
| 1625 | ) |
---|
| 1626 | ); |
---|
| 1627 | |
---|
| 1628 | |
---|
| 1629 | } |
---|
| 1630 | |
---|
| 1631 | function print_disponibility($param) { |
---|
| 1632 | |
---|
| 1633 | $str = "<html><head> |
---|
| 1634 | <script type='text/javascript'> |
---|
| 1635 | |
---|
| 1636 | var start = null; |
---|
| 1637 | var end = null; |
---|
| 1638 | function set_time(hour,minute) { |
---|
| 1639 | //alert(start); |
---|
| 1640 | if(start == null) { |
---|
| 1641 | start = new Array(); |
---|
| 1642 | start[0] = hour; |
---|
| 1643 | start[1] = minute; |
---|
[1593] | 1644 | paint_interval(start,start,'#009ACD',true); |
---|
[1447] | 1645 | } |
---|
| 1646 | else if (end == null) { |
---|
| 1647 | end = new Array(); |
---|
| 1648 | end[0] = hour; |
---|
| 1649 | end[1] = minute; |
---|
| 1650 | if(is_lower(start,end)) |
---|
[1593] | 1651 | paint_interval(start,end,'#009ACD',true); |
---|
[1447] | 1652 | else { |
---|
[1593] | 1653 | paint_interval(end,start,'#009ACD',true); |
---|
[1447] | 1654 | temp = start; |
---|
| 1655 | start = end; |
---|
| 1656 | end = temp; |
---|
| 1657 | paint_interval(end,end,'#FFFFFF',false); |
---|
| 1658 | } |
---|
| 1659 | parent.document.getElementById('start_hour').value=start[0]; |
---|
[1593] | 1660 | parent.document.getElementById('start_minute').value=start[1]; |
---|
[1447] | 1661 | parent.document.getElementById('end_hour').value=end[0]; |
---|
| 1662 | parent.document.getElementById('end_minute').value=end[1]; |
---|
| 1663 | |
---|
| 1664 | } |
---|
| 1665 | else { |
---|
| 1666 | end = null; |
---|
| 1667 | start = new Array(); |
---|
| 1668 | start[0] = hour; |
---|
| 1669 | start[1] = minute; |
---|
| 1670 | repaint(); |
---|
| 1671 | |
---|
[1593] | 1672 | paint_interval(start,start,'#009ACD',true); |
---|
[1447] | 1673 | } |
---|
| 1674 | } |
---|
| 1675 | function paint_column(name_array,color,force) { |
---|
| 1676 | name = name_array[0]+'-'+name_array[1]; |
---|
| 1677 | if(navigator.userAgent.toLowerCase().indexOf('msie') == -1) {//firefox |
---|
| 1678 | for(var i in document.getElementsByName(name)) { |
---|
| 1679 | document.getElementsByName(name)[i].bgColor=color; |
---|
| 1680 | if(document.getElementsByName(name)[i].nodeType==1) { |
---|
| 1681 | if(document.getElementsByName(name)[i].innerHTML.indexOf('>-<')==-1 || force==true) |
---|
| 1682 | document.getElementsByName(name)[i].bgColor=color; |
---|
| 1683 | else |
---|
[1593] | 1684 | document.getElementsByName(name)[i].bgColor='".$this->theme['bg11']."'; |
---|
[1447] | 1685 | } |
---|
| 1686 | } |
---|
| 1687 | } |
---|
| 1688 | else {//I.E |
---|
| 1689 | cells = document.getElementsByTagName('td'); |
---|
| 1690 | for(var i=0;i<cells.length;i++) { |
---|
| 1691 | if(cells.item(i).name==name) { //getElementsByName in I.E is bugged |
---|
| 1692 | cells.item(i).bgColor=color; |
---|
| 1693 | if(cells.item(i).nodeType==1) { |
---|
| 1694 | if(cells.item(i).innerHTML.indexOf('>-<')==-1 || force==true) |
---|
| 1695 | cells.item(i).bgColor=color; |
---|
| 1696 | else |
---|
[1593] | 1697 | cells.item(i).bgColor='".$this->theme['bg11']."'; |
---|
[1447] | 1698 | } |
---|
| 1699 | } |
---|
| 1700 | } |
---|
| 1701 | } |
---|
| 1702 | } |
---|
[1593] | 1703 | |
---|
[1447] | 1704 | function repaint() { |
---|
| 1705 | temp_start = new Array(); |
---|
| 1706 | temp_start[0] = 8; |
---|
| 1707 | temp_start[1] = 0; |
---|
| 1708 | temp_end = new Array(); |
---|
| 1709 | temp_end[0] = 19; |
---|
| 1710 | temp_end[1] = 0; |
---|
| 1711 | paint_interval(temp_start,temp_end,'#FFFFFF',false); |
---|
| 1712 | } |
---|
[1593] | 1713 | |
---|
[1447] | 1714 | //Considera sempre name1 <= name2 |
---|
| 1715 | function paint_interval(name1,name2,color,force) { |
---|
| 1716 | paint_column(name1,color,force); |
---|
| 1717 | if(name1[0]!=name2[0] || name1[1]!=name2[1]) { |
---|
| 1718 | paint_column(name1,color,force); |
---|
| 1719 | tempHour = name1[0]; |
---|
| 1720 | tempMinute = name1[1]; |
---|
| 1721 | while(tempHour<name2[0]) { |
---|
| 1722 | if(tempHour==name1[0] && tempMinute!=0) |
---|
| 1723 | temp_start = tempMinute/30; |
---|
| 1724 | else |
---|
| 1725 | temp_start = 0; |
---|
| 1726 | for(i=temp_start;i<60/30;i++) { |
---|
| 1727 | temp_column = new Array(); |
---|
| 1728 | temp_column[0] = tempHour; |
---|
| 1729 | temp_column[1] = i*30; |
---|
| 1730 | paint_column(temp_column,color,force); |
---|
| 1731 | } |
---|
| 1732 | tempHour++; |
---|
| 1733 | } |
---|
| 1734 | for(i=0;i<name2[1];i+=30) { |
---|
| 1735 | temp_column = new Array(); |
---|
| 1736 | temp_column[0] = name2[0]; |
---|
| 1737 | temp_column[1] = i; |
---|
| 1738 | paint_column(temp_column,color,force); |
---|
| 1739 | } |
---|
| 1740 | } |
---|
| 1741 | } |
---|
[1593] | 1742 | |
---|
[1447] | 1743 | function is_lower(array1,array2) { |
---|
| 1744 | if(array1[0]<array2[0]) |
---|
| 1745 | return true; |
---|
| 1746 | else if(array1[0]>array2[0]) |
---|
| 1747 | return false; |
---|
| 1748 | else { |
---|
| 1749 | if(array1[1]<array2[1]) |
---|
| 1750 | return true; |
---|
| 1751 | else |
---|
| 1752 | return false; |
---|
| 1753 | } |
---|
| 1754 | } |
---|
| 1755 | </script></head><body> |
---|
| 1756 | "; |
---|
[1593] | 1757 | |
---|
[5132] | 1758 | $extra_ = ""; |
---|
| 1759 | |
---|
[1447] | 1760 | $str.= "<table border=\'1\' bgcolor=\"#FFFFFF\" width=\"100%\" height=\"100%\"><tr><td>"; |
---|
| 1761 | |
---|
[1593] | 1762 | |
---|
[1447] | 1763 | if(!is_array($param)) |
---|
| 1764 | { |
---|
| 1765 | $this->index(); |
---|
| 1766 | } |
---|
| 1767 | |
---|
| 1768 | $date = $param['date']; |
---|
| 1769 | $starttime = $param['starttime']; |
---|
| 1770 | $endtime = $param['endtime']; |
---|
| 1771 | $participants = $param['participants']; |
---|
| 1772 | foreach($participants as $part => $nul) |
---|
| 1773 | { |
---|
[5132] | 1774 | $extra_ = ""; |
---|
| 1775 | |
---|
| 1776 | if($nul == 'I') |
---|
| 1777 | $extra_ = "(externalI)"; |
---|
| 1778 | |
---|
[1447] | 1779 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
[5132] | 1780 | $participants[$part].= $extra_; |
---|
[1447] | 1781 | // Much better for processor :) |
---|
| 1782 | $participants_id[] .= $part; |
---|
| 1783 | } |
---|
| 1784 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
| 1785 | |
---|
| 1786 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
| 1787 | { |
---|
| 1788 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
| 1789 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
| 1790 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 1791 | } |
---|
[5132] | 1792 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
[1447] | 1793 | $interval = (int)(60 / $increment); |
---|
| 1794 | |
---|
| 1795 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
| 1796 | |
---|
| 1797 | $str .= '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
| 1798 | . ', '.$this->bo->long_date($date).'<br>' |
---|
| 1799 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((10 * $interval) + 1).'">' |
---|
| 1800 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
| 1801 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
| 1802 | for($i=8;$i<19;$i++) |
---|
| 1803 | { |
---|
| 1804 | for($j=0;$j<$interval;$j++) |
---|
| 1805 | { |
---|
| 1806 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
| 1807 | |
---|
| 1808 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'" onclick="set_time('.$i.','.($j*$increment).')" style="cursor:hand;cursor:pointer"> |
---|
| 1809 | <font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' . $k." </font></td>\n"; |
---|
| 1810 | } |
---|
| 1811 | } |
---|
| 1812 | $str .= '</tr>' |
---|
| 1813 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
| 1814 | if(!$endtime) |
---|
| 1815 | { |
---|
| 1816 | $endtime = $starttime; |
---|
| 1817 | } |
---|
| 1818 | $owner = $this->bo->owner; |
---|
| 1819 | foreach($participants as $part => $fullname) |
---|
| 1820 | { |
---|
[5132] | 1821 | $external = false; |
---|
| 1822 | if(strpos($fullname,"(externalI)")) |
---|
| 1823 | { |
---|
| 1824 | $tmp_name = str_replace("(externalI)","",$fullname); |
---|
| 1825 | $fullname = $tmp_name; |
---|
| 1826 | $external = true; |
---|
| 1827 | } |
---|
| 1828 | |
---|
[1447] | 1829 | $str .= '<tr align="center">' |
---|
| 1830 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
| 1831 | |
---|
| 1832 | $this->bo->cached_events = Array(); |
---|
| 1833 | $this->bo->so->owner = $part; |
---|
| 1834 | $this->bo->so->open_box($part); |
---|
| 1835 | $this->bo->store_to_cache( |
---|
| 1836 | Array( |
---|
| 1837 | 'syear' => $date['year'], |
---|
| 1838 | 'smonth'=> $date['month'], |
---|
| 1839 | 'sday' => $date['day'], |
---|
| 1840 | 'eyear' => 0, |
---|
| 1841 | 'emonth'=> 0, |
---|
| 1842 | 'eday' => $date['day'] + 1 |
---|
| 1843 | ) |
---|
| 1844 | ); |
---|
| 1845 | |
---|
[5132] | 1846 | if($external) |
---|
| 1847 | { |
---|
| 1848 | $str .= '<td height="1" align="center" colspan="22" bgcolor="'.$this->theme['bg_color'].'" color="#999999">' .lang('Agenda not available') .'</td>'; |
---|
| 1849 | $str .= '</tr>' |
---|
| 1850 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
| 1851 | continue; |
---|
| 1852 | } |
---|
| 1853 | |
---|
[1447] | 1854 | if(!$this->bo->cached_events[$date['full']]) |
---|
| 1855 | { |
---|
| 1856 | for($j=8;$j<19;$j++) |
---|
| 1857 | { |
---|
| 1858 | for($k=0;$k<$interval;$k++) |
---|
| 1859 | { |
---|
| 1860 | // $helper_name = $k* |
---|
| 1861 | $str .= '<td name="'.$j.'-'.($k*$increment).'" height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
| 1862 | } |
---|
| 1863 | $str .= "\n"; |
---|
| 1864 | } |
---|
| 1865 | } |
---|
| 1866 | else |
---|
| 1867 | { |
---|
| 1868 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
| 1869 | for($h=8;$h<19;$h++) |
---|
| 1870 | { |
---|
| 1871 | $hour = $h * 10000; |
---|
| 1872 | for($m=0;$m<$interval;$m++) |
---|
| 1873 | { |
---|
| 1874 | $index = ($hour + (($m * $increment) * 100)); |
---|
| 1875 | switch($time_slice[$index]['marker']) |
---|
| 1876 | { |
---|
| 1877 | case ' ': |
---|
| 1878 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
| 1879 | //$extra = ''; |
---|
| 1880 | break; |
---|
| 1881 | case '-': |
---|
[5132] | 1882 | $time_slice[$index]['marker'] = "#"; |
---|
[1593] | 1883 | $time_slice[$index]['color'] = $this->theme['bg11']; |
---|
[1447] | 1884 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
| 1885 | //$extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
| 1886 | break; |
---|
| 1887 | } |
---|
| 1888 | $str .= '<td name="'.$h.'-'.($m*$increment).'" bgcolor="'.$time_slice[$index]['color'].'" color="#999999"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$time_slice[$index]['marker'].'</font></td>'; |
---|
| 1889 | } |
---|
| 1890 | $str .= "\n"; |
---|
[1639] | 1891 | } |
---|
| 1892 | } |
---|
[1447] | 1893 | $str .= '</tr>' |
---|
| 1894 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
[1639] | 1895 | } |
---|
[1447] | 1896 | $this->bo->owner = $owner; |
---|
| 1897 | $this->bo->so->owner = $owner; |
---|
| 1898 | $this->bo->so->open_box($owner); |
---|
| 1899 | $str.= "</table></center> \n </td></tr> |
---|
| 1900 | <tr><td onclick=\"parent.document.getElementById('disponibility').style.display='none'\" style='cursor:hand;cursor:pointer' align='center'>Fechar mapa</td></tr> |
---|
| 1901 | </table></body>"; |
---|
| 1902 | return $str; |
---|
| 1903 | } |
---|
| 1904 | |
---|
[2] | 1905 | function day() |
---|
| 1906 | { |
---|
[4008] | 1907 | |
---|
[2] | 1908 | $this->bo->read_holidays(); |
---|
[4008] | 1909 | |
---|
[2] | 1910 | if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) |
---|
| 1911 | { |
---|
| 1912 | $minical = $this->mini_calendar( |
---|
| 1913 | Array( |
---|
[5132] | 1914 | 'day' => $this->bo->day, |
---|
[4167] | 1915 | 'month' => $this->bo->month, |
---|
| 1916 | 'year' => $this->bo->year, |
---|
[5132] | 1917 | 'link' => 'day' |
---|
[2] | 1918 | ) |
---|
| 1919 | ); |
---|
| 1920 | } |
---|
| 1921 | else |
---|
| 1922 | { |
---|
| 1923 | |
---|
[5132] | 1924 | //NDEE: printer-friendly (what?) |
---|
[2] | 1925 | $minical = ''; |
---|
| 1926 | } |
---|
| 1927 | |
---|
| 1928 | if (!$this->bo->printer_friendly) |
---|
| 1929 | { |
---|
| 1930 | $printer = ''; |
---|
[5132] | 1931 | $param = '&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day).'&friendly=1'; |
---|
| 1932 | // $print = '<a href="'.$this->page('day'.$param)."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 1933 | |
---|
| 1934 | //Adiciona modo que o mesmo abra uma nova janela nos navegadores IE e FF |
---|
| 1935 | $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('day'.$param). |
---|
| 1936 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
| 1937 | lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 1938 | |
---|
[2] | 1939 | } |
---|
| 1940 | else |
---|
| 1941 | { |
---|
| 1942 | |
---|
[5132] | 1943 | //NDEE: printer-friendly (daily-view) |
---|
[2] | 1944 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 1945 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
[5132] | 1946 | $print = ''; |
---|
[2] | 1947 | } |
---|
| 1948 | |
---|
| 1949 | $now = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); |
---|
| 1950 | $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 1951 | |
---|
| 1952 | $p = $GLOBALS['phpgw']->template; |
---|
| 1953 | $p->set_file( |
---|
| 1954 | Array( |
---|
| 1955 | 'day_t' => 'day.tpl' |
---|
| 1956 | ) |
---|
| 1957 | ); |
---|
| 1958 | $p->set_block('day_t','day','day'); |
---|
| 1959 | $p->set_block('day_t','day_event','day_event'); |
---|
| 1960 | |
---|
| 1961 | $todos = $this->get_todos($todo_label); |
---|
| 1962 | $var = Array( |
---|
[4114] | 1963 | 'printer_friendly' => $printer, |
---|
| 1964 | 'bg_text' => $this->theme['bg_text'], |
---|
[5132] | 1965 | 'daily_events' => $this->print_day( |
---|
[2] | 1966 | Array( |
---|
[4114] | 1967 | 'year' => $this->bo->year, |
---|
| 1968 | 'month' => $this->bo->month, |
---|
| 1969 | 'day' => $this->bo->day |
---|
[2] | 1970 | ) |
---|
| 1971 | ), |
---|
[5132] | 1972 | 'small_calendar' => $minical, |
---|
| 1973 | 'date' => $this->bo->long_date($now), |
---|
[4114] | 1974 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
[5132] | 1975 | 'print' => $print, |
---|
[4114] | 1976 | 'lang_todos' => $todo_label, |
---|
| 1977 | 'todos' => $this->bo->printer_friendly ? $todos : |
---|
[2] | 1978 | |
---|
[5132] | 1979 | //NDEE: todo's layout |
---|
[2] | 1980 | "<div style=\"overflow: auto; max-height: 200px\">\n$todos</div>\n" |
---|
| 1981 | ); |
---|
| 1982 | |
---|
| 1983 | $p->set_var($var); |
---|
| 1984 | $p->parse('day_events','day_event'); |
---|
[5132] | 1985 | print $this->printer_friendly($p->fp('out','day'),lang('Dayview')); |
---|
[15] | 1986 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
[2] | 1987 | } |
---|
| 1988 | |
---|
| 1989 | function get_todos(&$todo_label) |
---|
| 1990 | { |
---|
| 1991 | $todos_from_hook = $GLOBALS['phpgw']->hooks->process(array( |
---|
| 1992 | 'location' => 'calendar_include_todos', |
---|
| 1993 | 'year' => $this->bo->year, |
---|
| 1994 | 'month' => $this->bo->month, |
---|
| 1995 | 'day' => $this->bo->day, |
---|
| 1996 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
| 1997 | )); |
---|
| 1998 | |
---|
| 1999 | if(is_array($todo_label)) |
---|
| 2000 | { |
---|
| 2001 | list($label,$showall)=$todo_label; |
---|
| 2002 | } |
---|
| 2003 | else |
---|
| 2004 | { |
---|
| 2005 | $label=$todo_label; |
---|
| 2006 | $showall=true; |
---|
| 2007 | } |
---|
| 2008 | $maxshow = (int)$GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
---|
| 2009 | if($maxshow<=0) |
---|
| 2010 | { |
---|
| 2011 | $maxshow=10; |
---|
| 2012 | } |
---|
| 2013 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
---|
| 2014 | |
---|
| 2015 | $content = $todo_label = ''; |
---|
| 2016 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
---|
| 2017 | { |
---|
| 2018 | $todo_label = !empty($label)?$label:lang("open ToDo's:"); |
---|
| 2019 | |
---|
| 2020 | foreach($todos_from_hook as $todos) |
---|
| 2021 | { |
---|
| 2022 | $i = 0; |
---|
| 2023 | if (is_array($todos) && count($todos)) |
---|
| 2024 | { |
---|
| 2025 | foreach($todos as $todo) |
---|
| 2026 | { |
---|
| 2027 | if(!$showall && ($i++>$maxshow)) |
---|
| 2028 | { |
---|
| 2029 | break; |
---|
| 2030 | } |
---|
| 2031 | $icons = ''; |
---|
| 2032 | foreach($todo['icons'] as $name => $app) |
---|
| 2033 | { |
---|
| 2034 | $icons .= ($icons?' ':'').$GLOBALS['phpgw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"'); |
---|
| 2035 | } |
---|
| 2036 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
---|
| 2037 | |
---|
| 2038 | //NDEE <tr starts here |
---|
| 2039 | $content .= " <tr id=\"debug\" class=\"$class\">\n <td valign=\"top\" width=\"15%\"nowrap>". |
---|
| 2040 | ($this->bo->printer_friendly?$icons:$GLOBALS['phpgw']->html->a_href($icons,$todo['view'])). |
---|
| 2041 | "</td>\n <td>".($this->bo->printer_friendly?$todo['title']: |
---|
| 2042 | $GLOBALS['phpgw']->html->a_href($todo['title'],$todo['view']))."</td>\n </tr>\n"; |
---|
| 2043 | } |
---|
| 2044 | } |
---|
| 2045 | } |
---|
| 2046 | } |
---|
| 2047 | if (!empty($content)) |
---|
| 2048 | { |
---|
| 2049 | return "<table border=\"0\" width=\"100%\">\n$content</table>\n"; |
---|
| 2050 | } |
---|
| 2051 | return False; |
---|
| 2052 | } |
---|
| 2053 | |
---|
| 2054 | function edit_status() |
---|
| 2055 | { |
---|
| 2056 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2057 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2058 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 2059 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 2060 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Change Status'); |
---|
| 2061 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2062 | |
---|
| 2063 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
| 2064 | |
---|
| 2065 | reset($event['participants']); |
---|
| 2066 | |
---|
| 2067 | if(!$event['participants'][$this->bo->owner]) |
---|
| 2068 | { |
---|
| 2069 | echo '<center>'.lang('The user %1 is not participating in this event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)).'</center>'; |
---|
| 2070 | return; |
---|
| 2071 | } |
---|
| 2072 | |
---|
| 2073 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 2074 | { |
---|
| 2075 | $this->no_edit(); |
---|
| 2076 | return; |
---|
| 2077 | } |
---|
| 2078 | |
---|
| 2079 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 2080 | echo $this->timematrix( |
---|
| 2081 | Array( |
---|
| 2082 | 'date' => $freetime, |
---|
| 2083 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 2084 | 'endtime' => 0, |
---|
| 2085 | 'participants' => $event['participants'] |
---|
| 2086 | ) |
---|
| 2087 | ).'<br>'; |
---|
| 2088 | |
---|
| 2089 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
| 2090 | $this->view_event($event); |
---|
| 2091 | $GLOBALS['phpgw']->template->pfp('phpgw_body','view_event'); |
---|
| 2092 | |
---|
| 2093 | echo $this->get_response($event['id']); |
---|
| 2094 | } |
---|
| 2095 | |
---|
[212] | 2096 | function confirm_action($duplicated_action) |
---|
[2] | 2097 | { |
---|
| 2098 | if($_GET['response'] == 1) |
---|
| 2099 | { |
---|
[212] | 2100 | if(!$duplicated_action) |
---|
| 2101 | $notify_message = lang('The commitment was accepted successfully!'); |
---|
| 2102 | else |
---|
| 2103 | $notify_message = lang('This commitment has already been accepted!'); |
---|
[2] | 2104 | } |
---|
[5132] | 2105 | else if($_GET['response'] == 2) |
---|
[212] | 2106 | { |
---|
| 2107 | if(!$duplicated_action) |
---|
| 2108 | $notify_message = lang('The commitment was rejected successfully!'); |
---|
| 2109 | else |
---|
| 2110 | $notify_message = lang('This commitment has already been rejected!'); |
---|
[2] | 2111 | } |
---|
[5132] | 2112 | else if($_GET['response'] == 3) |
---|
| 2113 | { |
---|
| 2114 | if(!$duplicated_action) |
---|
| 2115 | $notify_message = lang('The commitment was tentatived successfully!'); |
---|
| 2116 | else |
---|
| 2117 | $notify_message = lang('This commitment has already been tentatived!'); |
---|
| 2118 | } |
---|
[2] | 2119 | |
---|
| 2120 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 2121 | $body1->set_file(Array('calendar' => 'confirm.tpl')); |
---|
| 2122 | $body1->set_block('calendar','list'); |
---|
| 2123 | $var = Array( 'notify_message' => $notify_message); |
---|
| 2124 | $body1->set_var($var); |
---|
| 2125 | $tmpbody1 = $body1->pfp('out','list'); |
---|
| 2126 | } |
---|
| 2127 | function set_action() |
---|
| 2128 | { |
---|
| 2129 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 2130 | { |
---|
| 2131 | $this->no_edit(); |
---|
| 2132 | return; |
---|
| 2133 | } |
---|
| 2134 | |
---|
[5132] | 2135 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action'],(int)$_GET['user']); |
---|
[3306] | 2136 | |
---|
[2] | 2137 | if(isset($_GET['response'])) |
---|
| 2138 | { |
---|
[212] | 2139 | $this->confirm_action($confirm_status); |
---|
[2] | 2140 | $GLOBALS['phpgw']->common->phpgw_exit(False); |
---|
[1849] | 2141 | } |
---|
[5132] | 2142 | else |
---|
[1849] | 2143 | { |
---|
[2] | 2144 | if ($this->bo->return_to) |
---|
| 2145 | { |
---|
| 2146 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 2147 | } |
---|
| 2148 | else |
---|
| 2149 | { |
---|
| 2150 | Header('Location: '.$this->page('','')); |
---|
| 2151 | } |
---|
| 2152 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
[1849] | 2153 | } |
---|
[2] | 2154 | |
---|
| 2155 | } |
---|
| 2156 | function planner() |
---|
| 2157 | { |
---|
| 2158 | if(floor(phpversion()) < 4) |
---|
| 2159 | { |
---|
| 2160 | return; |
---|
| 2161 | } |
---|
| 2162 | $home = strstr($_SERVER['PHP_SELF'],'home') !== False; |
---|
| 2163 | // generate header and set global/member variables |
---|
| 2164 | // |
---|
| 2165 | $this->planner_prepare($home); |
---|
| 2166 | |
---|
| 2167 | // process events within selected interval |
---|
| 2168 | // |
---|
| 2169 | $this->planner_process_interval(); |
---|
| 2170 | |
---|
| 2171 | // generate the planner view |
---|
| 2172 | // |
---|
| 2173 | if (!$home) |
---|
| 2174 | { |
---|
| 2175 | echo '<p>'.$this->planner_print_rows(); |
---|
| 2176 | } |
---|
| 2177 | else |
---|
| 2178 | { |
---|
| 2179 | return $this->planner_print_rows(); |
---|
| 2180 | } |
---|
| 2181 | } |
---|
| 2182 | |
---|
| 2183 | function set_planner_group_members() |
---|
| 2184 | { |
---|
| 2185 | $type = $GLOBALS['phpgw']->accounts->get_type($this->bo->owner); |
---|
| 2186 | |
---|
| 2187 | if ($type == 'g') // display schedule of all group members |
---|
| 2188 | { |
---|
| 2189 | $members = array(); |
---|
| 2190 | $ids = $GLOBALS['phpgw']->acl->get_ids_for_location($this->bo->owner, 1, 'phpgw_group'); |
---|
| 2191 | while (list(,$id) = each($ids)) |
---|
| 2192 | { |
---|
| 2193 | if ($this->bo->check_perms(PHPGW_ACL_READ,0,$id)) |
---|
| 2194 | { |
---|
| 2195 | $members[$GLOBALS['phpgw']->common->grab_owner_name($id)] = $id; |
---|
| 2196 | } |
---|
| 2197 | } |
---|
| 2198 | ksort($members); |
---|
| 2199 | $this->planner_group_members = $members; |
---|
| 2200 | } |
---|
| 2201 | else |
---|
| 2202 | { |
---|
| 2203 | $this->planner_group_members = array( |
---|
| 2204 | $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) => $this->bo->owner |
---|
| 2205 | ); |
---|
| 2206 | } |
---|
| 2207 | } |
---|
| 2208 | |
---|
| 2209 | /** |
---|
| 2210 | * planner_prepare - prepare the planner view |
---|
| 2211 | * |
---|
| 2212 | * - sets global environment variables |
---|
| 2213 | * - initializes class member variables used in multiple planner related functions |
---|
| 2214 | * - generates header lines for the planner view (month, calendar week, days) |
---|
| 2215 | */ |
---|
| 2216 | function planner_prepare($no_header = False) |
---|
| 2217 | { |
---|
| 2218 | // set some globals |
---|
| 2219 | // |
---|
| 2220 | if (!$no_header) |
---|
| 2221 | { |
---|
| 2222 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2223 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2224 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner'); |
---|
| 2225 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
[5132] | 2226 | $this->header(); |
---|
[2] | 2227 | } |
---|
| 2228 | |
---|
| 2229 | // intervals_per_day can be configured in preferences now :-) |
---|
| 2230 | // |
---|
| 2231 | if (! $this->bo->prefs['calendar']['planner_intervals_per_day']) |
---|
| 2232 | { |
---|
| 2233 | $GLOBALS['phpgw']->preferences->add('calendar','planner_intervals_per_day',3); |
---|
| 2234 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 2235 | $this->bo->prefs['calendar']['planner_intervals_per_day'] = 3; |
---|
| 2236 | } |
---|
| 2237 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2238 | $this->bo->save_sessiondata(); // need to save $this->bo->save_owner |
---|
| 2239 | |
---|
| 2240 | // set title for table and rows of planner view |
---|
| 2241 | // |
---|
| 2242 | if ($this->bo->sortby == 'category') |
---|
| 2243 | { |
---|
| 2244 | $title = lang('Category'); |
---|
| 2245 | } |
---|
| 2246 | else |
---|
| 2247 | { |
---|
| 2248 | $title = lang('User'); |
---|
| 2249 | |
---|
| 2250 | $this->set_planner_group_members(); |
---|
| 2251 | } |
---|
| 2252 | |
---|
| 2253 | // create/initialize variables directly used for HTML code generation |
---|
| 2254 | // |
---|
| 2255 | $this->planner_header = array(); |
---|
| 2256 | $this->planner_rows = array(); |
---|
| 2257 | |
---|
| 2258 | // generate header lines with days and associated months |
---|
| 2259 | // |
---|
| 2260 | $hdr = &$this->planner_header; |
---|
| 2261 | $hdr[0]['0'] = $title; |
---|
| 2262 | $hdr[0]['.0'] = 'rowspan="3"'; |
---|
| 2263 | |
---|
| 2264 | $this->planner_days = 0; // reset |
---|
| 2265 | |
---|
| 2266 | $m = $this->bo->month; |
---|
| 2267 | $y = $this->bo->year; |
---|
| 2268 | $this->bo->read_holidays($y); |
---|
| 2269 | for ($i=1; $i<=$this->bo->num_months; $i++,$m++) |
---|
| 2270 | { |
---|
| 2271 | if ($m == 13) |
---|
| 2272 | { |
---|
| 2273 | $m = 1; $y++; // "wrap-around" into new year |
---|
| 2274 | $this->bo->read_holidays($y); |
---|
| 2275 | } |
---|
| 2276 | $days = $GLOBALS['phpgw']->datetime->days_in_month($m,$y); |
---|
| 2277 | |
---|
| 2278 | $d = mktime(0,0,0,$m,1,$y); |
---|
| 2279 | $month = lang(date('F', $d)).strftime(' %Y', $d); |
---|
| 2280 | $color = $this->theme[$m % 2 || $this->bo->num_months == 1 ? 'th_bg' : 'row_on']; |
---|
| 2281 | $cols = $days * $intervals_per_day; |
---|
| 2282 | |
---|
| 2283 | $hdr[0]['.'.$i] = 'bgcolor="'.$color.'" colspan="'.$cols.'" align="center"'; |
---|
| 2284 | $prev_month = sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12); |
---|
| 2285 | $next_month = sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1); |
---|
| 2286 | $prev_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month"); |
---|
| 2287 | $next_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$next_month"); |
---|
| 2288 | $hdr[0][$i] = "<b><a href=\"$prev_link\"><<</a>   $month   <a href=\"$next_link\">>></a></b>"; |
---|
| 2289 | |
---|
| 2290 | $add_owner = array(); // if no add-rights on the showed cal use own cal |
---|
| 2291 | if (!$this->bo->save_owner && !$this->bo->check_perms(PHPGW_ACL_ADD) || |
---|
| 2292 | !$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner)) |
---|
| 2293 | { |
---|
| 2294 | $add_owner = array( |
---|
| 2295 | 'owner' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 2296 | ); |
---|
| 2297 | } |
---|
| 2298 | for ($d=1; $d<=$days; $d++) |
---|
| 2299 | { |
---|
| 2300 | $dayname = substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2); |
---|
| 2301 | $index = $d + $this->planner_days; |
---|
| 2302 | |
---|
| 2303 | $hdr[2]['.'.$index] = 'colspan="'.$intervals_per_day.'" align="center"'; |
---|
| 2304 | |
---|
| 2305 | // highlight today, saturday, sunday and holidays |
---|
| 2306 | // |
---|
| 2307 | $color = $this->theme['row_off']; |
---|
| 2308 | $dow = $GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d); |
---|
| 2309 | $date = sprintf("%04d%02d%02d",$y,$m,$d); |
---|
| 2310 | if ($date == date('Ymd')) |
---|
| 2311 | { |
---|
| 2312 | $color = $GLOBALS['phpgw_info']['theme']['cal_today']; |
---|
| 2313 | } |
---|
| 2314 | elseif ($this->bo->cached_holidays[$date]) |
---|
| 2315 | { |
---|
| 2316 | $color = $this->bo->holiday_color; |
---|
| 2317 | $hdr[2]['.'.$index] .= ' title="'.$this->bo->cached_holidays[$date][0]['name'].'"'; |
---|
| 2318 | } |
---|
| 2319 | elseif ($dow == 0 || $dow == 6) |
---|
| 2320 | { |
---|
| 2321 | $color = $this->bo->theme['th_bg']; |
---|
| 2322 | } |
---|
| 2323 | |
---|
| 2324 | $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; |
---|
| 2325 | |
---|
| 2326 | $hdr[2][$index] = '<a href="'.$this->html->link('/index.php', |
---|
| 2327 | array( |
---|
| 2328 | 'menuaction' => 'calendar.uicalendar.add', |
---|
| 2329 | 'date' => $date |
---|
| 2330 | ) + $add_owner |
---|
| 2331 | ).'">'.$dayname.'<br>'.$d.'</a>'; |
---|
| 2332 | } |
---|
| 2333 | $this->planner_days += $days; |
---|
| 2334 | } |
---|
| 2335 | |
---|
| 2336 | // create/initialize member variables describing the time interval to be displayed |
---|
| 2337 | // |
---|
| 2338 | $this->planner_end_month = $m - 1; |
---|
| 2339 | $this->planner_end_year = $y; |
---|
| 2340 | $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); |
---|
| 2341 | $this->planner_firstday = (int)(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); |
---|
| 2342 | $this->planner_lastday = (int)(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); |
---|
| 2343 | |
---|
| 2344 | // generate line with calendar weeks in observed interval |
---|
| 2345 | // |
---|
| 2346 | $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 2347 | $w = date('W', $d); |
---|
| 2348 | if ($w == 'W') // php < 4.1 |
---|
| 2349 | { |
---|
| 2350 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
| 2351 | } |
---|
| 2352 | $offset = (7-date('w', $d)+1)%7; |
---|
| 2353 | $offset = $offset == 0 ? 7 : $offset; |
---|
| 2354 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
| 2355 | |
---|
| 2356 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$intervals_per_day * $offset.'" align="left"'; |
---|
| 2357 | $hdr[1][$w] = ''; |
---|
| 2358 | if ($offset >= 3) |
---|
| 2359 | { |
---|
| 2360 | |
---|
| 2361 | //NDEE: style! (groupplanner) |
---|
| 2362 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
| 2363 | } |
---|
| 2364 | $days_left = $this->planner_days - $offset; |
---|
| 2365 | |
---|
| 2366 | $colspan = 7 * $intervals_per_day; |
---|
| 2367 | while ($days_left > 0) |
---|
| 2368 | { |
---|
| 2369 | $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; |
---|
| 2370 | $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each |
---|
| 2371 | $w = date('W', $d); |
---|
| 2372 | if ($w == 'W') // php < 4.1 |
---|
| 2373 | { |
---|
| 2374 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
| 2375 | } |
---|
| 2376 | $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? |
---|
| 2377 | |
---|
| 2378 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
| 2379 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$colspan.'" align="left"'; |
---|
| 2380 | $hdr[1][$w] = ''; |
---|
| 2381 | if ($days_left >= 3) |
---|
| 2382 | { |
---|
| 2383 | |
---|
| 2384 | //NDEE: style! (groupplanner) |
---|
| 2385 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
| 2386 | } |
---|
| 2387 | |
---|
| 2388 | $days_left -= 7; |
---|
| 2389 | } |
---|
| 2390 | return $hdr; |
---|
| 2391 | } |
---|
| 2392 | |
---|
| 2393 | /** |
---|
| 2394 | * planner_update_row - update a row of the planner view |
---|
| 2395 | * |
---|
| 2396 | * parameters are: |
---|
| 2397 | * - index (e.g. user id, category id, ...) of the row |
---|
| 2398 | * - name/title of the row (e.g. user name, category name) |
---|
| 2399 | * - the event to be integrated |
---|
| 2400 | * - list of categories associated with the event |
---|
| 2401 | * - first and last cell of the row |
---|
| 2402 | */ |
---|
| 2403 | function planner_update_row($index,$name,$event,$cat,$start_cell,$end_cell) |
---|
| 2404 | { |
---|
| 2405 | $rows = &$this->planner_rows; |
---|
| 2406 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2407 | $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 2408 | |
---|
| 2409 | $view = $this->html->link('/index.php', |
---|
| 2410 | array( |
---|
| 2411 | 'menuaction' => 'calendar.uicalendar.view', |
---|
| 2412 | 'cal_id' => $event['id'], |
---|
| 2413 | 'date' => date('Ymd',$this->bo->maketime($event['start'])) |
---|
| 2414 | ) |
---|
| 2415 | ); |
---|
| 2416 | |
---|
| 2417 | // check how many lines are needed for this "row" (currently: user or category) |
---|
| 2418 | $i = 0; |
---|
| 2419 | do { |
---|
| 2420 | ++$i; |
---|
| 2421 | |
---|
| 2422 | $k = $index.'_'.$i; |
---|
| 2423 | $ka = '.nr_'.$k; |
---|
| 2424 | |
---|
| 2425 | if (!isset($rows[$k])) |
---|
| 2426 | { |
---|
| 2427 | if ($i > 1) // further line - no name |
---|
| 2428 | { |
---|
| 2429 | $rows[$k] = array(); |
---|
| 2430 | $rows[$index.'_1']['._name'] = 'rowspan="'.$i.'"'; |
---|
| 2431 | } |
---|
| 2432 | else |
---|
| 2433 | { |
---|
| 2434 | $rows[$k]['_name'] = $name; |
---|
| 2435 | } |
---|
| 2436 | $rows[$ka] = 0; |
---|
| 2437 | } |
---|
| 2438 | $rows[$index.'_1']['._name'] .= ' nowrap'; // title must be one row |
---|
| 2439 | |
---|
| 2440 | $row = &$rows[$k]; |
---|
| 2441 | $akt_cell = &$rows[$ka]; |
---|
| 2442 | } while ($akt_cell > $start_cell); |
---|
| 2443 | |
---|
| 2444 | $id = $event['id'].'-'.date('Ymd',$this->bo->maketime($event['start'])); |
---|
| 2445 | if ($akt_cell < $start_cell) |
---|
| 2446 | { |
---|
| 2447 | $row[$id.'_1'] = ' '; |
---|
| 2448 | $row['.'.$id.'_1'] = 'colspan="'.($start_cell-$akt_cell).'"'; |
---|
| 2449 | } |
---|
| 2450 | $opt = &$row['.'.$id.'_2']; |
---|
| 2451 | $cel = &$row[$id.'_2']; |
---|
| 2452 | |
---|
| 2453 | // if possible, display information about event within cells representing it |
---|
| 2454 | // |
---|
| 2455 | if ($start_cell < $end_cell) |
---|
| 2456 | { |
---|
| 2457 | $colspan = $end_cell - $start_cell; |
---|
| 2458 | $opt .= "colspan=".(1 + $colspan); |
---|
| 2459 | |
---|
| 2460 | if (!$is_private) |
---|
| 2461 | { |
---|
| 2462 | $max_chars = (int)(3*$colspan/$intervals_per_day-2); |
---|
| 2463 | |
---|
| 2464 | $min_chars = 3; // minimum for max_chars to display -> this should be configurable |
---|
| 2465 | if ($max_chars >= $min_chars) |
---|
| 2466 | { |
---|
| 2467 | $len_title = strlen($event['title']); |
---|
| 2468 | |
---|
| 2469 | if ($len_title <= $max_chars) |
---|
| 2470 | { |
---|
| 2471 | $title = $event['title']; |
---|
| 2472 | $max_chars -= $len_title + 3; // 3 chars for separator: " - " |
---|
| 2473 | $len_descr = strlen($event['description']); |
---|
| 2474 | |
---|
| 2475 | if ($len_descr > 0 && $len_descr <= $max_chars) |
---|
| 2476 | { |
---|
| 2477 | $event['print_description'] = 'yes'; |
---|
| 2478 | } |
---|
| 2479 | } |
---|
| 2480 | else |
---|
| 2481 | { |
---|
| 2482 | $has_amp = strpos($event['title'],'&'); |
---|
| 2483 | |
---|
| 2484 | //NDEE: event title gets cut here |
---|
| 2485 | $title = substr($event['title'], 0 , $max_chars-1+($has_amp!==False&&$has_amp<$max_chars?4:0)).'...'; |
---|
| 2486 | } |
---|
| 2487 | $event['print_title'] = 'yes'; |
---|
| 2488 | } |
---|
| 2489 | } |
---|
| 2490 | } |
---|
| 2491 | |
---|
| 2492 | if ($bgcolor=$cat['color']) |
---|
| 2493 | { |
---|
| 2494 | $opt .= ' bgcolor="'.$bgcolor.'"'; |
---|
| 2495 | } |
---|
| 2496 | if (!$is_private) |
---|
| 2497 | { |
---|
[5132] | 2498 | $opt .= ' title="'.lang('Title').": ".$event['title']." | "; |
---|
[2] | 2499 | if ($event['description']) |
---|
| 2500 | { |
---|
[5132] | 2501 | $opt .= "\n".lang('Description').": ".$event['description']." | "; |
---|
[2] | 2502 | } |
---|
| 2503 | } |
---|
| 2504 | else |
---|
| 2505 | { |
---|
| 2506 | $opt .= ' title="'.lang('You do not have permission to read this record!'); |
---|
| 2507 | } |
---|
| 2508 | |
---|
| 2509 | $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 2510 | $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
[5132] | 2511 | $opt .= "\n".lang('Start Date/Time').": ".$start." | ".lang('End Date/Time').": ".$end." | "; |
---|
[2] | 2512 | |
---|
| 2513 | if ($event['location'] && !$is_private) |
---|
| 2514 | { |
---|
| 2515 | $opt .= " \n".lang('Location').": ".$event['location']; |
---|
| 2516 | } |
---|
| 2517 | |
---|
| 2518 | if (!$is_private) |
---|
| 2519 | { |
---|
| 2520 | $opt .= '" onClick="location=\''.$view.'\'"'; |
---|
| 2521 | $cel = '<a href="'.$view.'">'; |
---|
| 2522 | } |
---|
| 2523 | else |
---|
| 2524 | { |
---|
| 2525 | $opt .= '"'; |
---|
| 2526 | $cel = ''; |
---|
| 2527 | } |
---|
| 2528 | $opt .= ' class="planner-cell"'; |
---|
| 2529 | |
---|
| 2530 | if ($event['priority'] == 3) |
---|
| 2531 | { |
---|
| 2532 | $cel .= $this->html->image('calendar','mini-calendar-bar.gif','','border="0"'); |
---|
| 2533 | } |
---|
| 2534 | if ($event['recur_type']) |
---|
| 2535 | { |
---|
| 2536 | $cel .= $this->html->image('calendar','recur.gif','','border="0"'); |
---|
| 2537 | } |
---|
| 2538 | $cel .= $this->html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); |
---|
| 2539 | $cel .= '</a>'; |
---|
| 2540 | |
---|
| 2541 | if (isset($event['print_title']) && $event['print_title'] == 'yes') |
---|
| 2542 | { |
---|
| 2543 | |
---|
| 2544 | //NDEE: style! where? |
---|
| 2545 | $cel .= '<font size="-2"> '.$title.' </font>'; |
---|
| 2546 | } |
---|
| 2547 | if (isset($event['print_description']) && $event['print_description'] == 'yes') |
---|
| 2548 | { |
---|
| 2549 | |
---|
| 2550 | //NDEE: style! where ? |
---|
| 2551 | $cel .= '<font size="-2"> - '.$event['description'].' </font>'; |
---|
| 2552 | } |
---|
| 2553 | |
---|
| 2554 | $akt_cell = $end_cell + 1; |
---|
| 2555 | |
---|
| 2556 | return $rows; |
---|
| 2557 | } |
---|
| 2558 | |
---|
| 2559 | function planner_process_event($event) |
---|
| 2560 | { |
---|
| 2561 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2562 | $interval = $this->planner_intervals[$intervals_per_day]; |
---|
| 2563 | $last_cell = $intervals_per_day * $this->planner_days - 1; |
---|
| 2564 | |
---|
| 2565 | $rows = &$this->planner_rows; |
---|
| 2566 | |
---|
| 2567 | // caluculate start and end of event |
---|
| 2568 | // |
---|
| 2569 | $event_start = (int)(date('Ymd',mktime( |
---|
| 2570 | 0,0,0, |
---|
| 2571 | $event['start']['month'], |
---|
| 2572 | $event['start']['mday'], |
---|
| 2573 | $event['start']['year'] |
---|
| 2574 | ))); |
---|
| 2575 | $event_end = (int)(date('Ymd',mktime( |
---|
| 2576 | 0,0,0, |
---|
| 2577 | $event['end']['month'], |
---|
| 2578 | $event['end']['mday'], |
---|
| 2579 | $event['end']['year'] |
---|
| 2580 | ))); |
---|
| 2581 | |
---|
| 2582 | // calculate first cell of event within observed interval |
---|
| 2583 | // |
---|
| 2584 | if ($event_start >= $this->planner_firstday) |
---|
| 2585 | { |
---|
| 2586 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['start']['month'],$event['start']['mday'],$event['start']['year']); |
---|
| 2587 | |
---|
| 2588 | $start_cell = $intervals_per_day * $days_between + $interval[$event['start']['hour']]; |
---|
| 2589 | } |
---|
| 2590 | else |
---|
| 2591 | { |
---|
| 2592 | $start_cell = 0; |
---|
| 2593 | } |
---|
| 2594 | |
---|
| 2595 | // calculate last cell of event within observed interval |
---|
| 2596 | // |
---|
| 2597 | if ($event_end <= $this->planner_lastday) |
---|
| 2598 | { |
---|
| 2599 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']); |
---|
| 2600 | $end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']]; |
---|
| 2601 | if ($end_cell == $start_cell && $end_cell < $last_cell) |
---|
| 2602 | { |
---|
| 2603 | $end_cell++; // min. width 1 interval |
---|
| 2604 | } |
---|
| 2605 | } |
---|
| 2606 | else |
---|
| 2607 | { |
---|
| 2608 | $end_cell = $last_cell; |
---|
| 2609 | } |
---|
| 2610 | // get the categories associated with event |
---|
| 2611 | // |
---|
| 2612 | if ($c = $event['category']) |
---|
| 2613 | { |
---|
| 2614 | list($cat) = $this->planner_category($event['category']); |
---|
| 2615 | if ($cat['parent']) |
---|
| 2616 | { |
---|
| 2617 | list($pcat) = $this->planner_category($c = $cat['parent']); |
---|
| 2618 | } |
---|
| 2619 | else |
---|
| 2620 | { |
---|
| 2621 | $pcat = $cat; |
---|
| 2622 | } |
---|
| 2623 | } |
---|
| 2624 | else |
---|
| 2625 | { |
---|
| 2626 | $cat = $pcat = array( 'name' => lang('none')); |
---|
| 2627 | } |
---|
| 2628 | |
---|
| 2629 | // add the event to it`s associated row(s) |
---|
| 2630 | // |
---|
| 2631 | if ($this->bo->sortby == 'category') |
---|
| 2632 | { |
---|
| 2633 | // event needs to show up in it`s category`s row |
---|
| 2634 | // |
---|
| 2635 | $this->planner_update_row($c,$pcat['name'],$event,$cat,$start_cell,$end_cell); |
---|
| 2636 | } |
---|
| 2637 | elseif ($this->bo->sortby == 'user') |
---|
| 2638 | { |
---|
| 2639 | // event needs to show up in rows of all participants that are also owners |
---|
| 2640 | // |
---|
| 2641 | reset($this->planner_group_members); |
---|
| 2642 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
| 2643 | { |
---|
| 2644 | $status = $event['participants'][$id]; |
---|
| 2645 | |
---|
| 2646 | if (isset($status) && $status != 'R') |
---|
| 2647 | { |
---|
| 2648 | $this->planner_update_row($user_name,$user_name,$event,$cat,$start_cell,$end_cell); |
---|
| 2649 | } |
---|
| 2650 | } |
---|
| 2651 | } |
---|
| 2652 | } |
---|
| 2653 | |
---|
| 2654 | function planner_pad_rows() |
---|
| 2655 | { |
---|
| 2656 | $rows = &$this->planner_rows; |
---|
| 2657 | |
---|
| 2658 | if ($this->bo->sortby == 'user') |
---|
| 2659 | { |
---|
| 2660 | // add empty rows for users that do not participante in any event |
---|
| 2661 | // |
---|
| 2662 | reset($this->planner_group_members); |
---|
| 2663 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
| 2664 | { |
---|
| 2665 | $k = $user_name.'_1'; |
---|
| 2666 | $ka = '.nr_'.$k; |
---|
| 2667 | |
---|
| 2668 | if (!isset($rows[$k])) |
---|
| 2669 | { |
---|
| 2670 | $rows[$k]['_name'] = $user_name; |
---|
| 2671 | $rows[$k]['._name'] .= ' nowrap'; |
---|
| 2672 | $rows[$ka] = 0; |
---|
| 2673 | } |
---|
| 2674 | } |
---|
| 2675 | } |
---|
| 2676 | |
---|
| 2677 | // fill the remaining cols |
---|
| 2678 | // |
---|
| 2679 | $last_cell = $this->bo->prefs['calendar']['planner_intervals_per_day'] * $this->planner_days - 1; |
---|
| 2680 | |
---|
| 2681 | ksort($rows); |
---|
| 2682 | while (list($k,$r) = each($rows)) |
---|
| 2683 | { |
---|
| 2684 | if (is_array($r)) |
---|
| 2685 | { |
---|
| 2686 | $rows['.'.$k] = 'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"'; |
---|
| 2687 | $row = &$rows[$k]; |
---|
| 2688 | $akt_cell = &$rows['.nr_'.$k]; |
---|
| 2689 | if ($akt_cell < $last_cell) |
---|
| 2690 | { |
---|
| 2691 | $row['3'] = ' '; |
---|
| 2692 | $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; |
---|
| 2693 | } |
---|
| 2694 | } |
---|
| 2695 | } |
---|
| 2696 | } |
---|
| 2697 | |
---|
| 2698 | function planner_print_rows() |
---|
| 2699 | { |
---|
| 2700 | $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"'; |
---|
| 2701 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2702 | |
---|
| 2703 | if ($this->debug) |
---|
| 2704 | { |
---|
| 2705 | _debug_array($this->planner_rows); |
---|
| 2706 | reset($this->planner_rows); |
---|
| 2707 | } |
---|
| 2708 | return $this->html->table( |
---|
| 2709 | array( |
---|
| 2710 | '_hdr0' => $this->planner_header[0], |
---|
| 2711 | '._hdr0' => $bgcolor, |
---|
| 2712 | '_hdr1' => $this->planner_header[1], |
---|
| 2713 | '._hdr1' => $bgcolor, |
---|
| 2714 | '_hdr2' => $this->planner_header[2], |
---|
| 2715 | '._hdr2' => $bgcolor |
---|
| 2716 | )+$this->planner_rows, |
---|
| 2717 | 'width="100%" cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"'); |
---|
| 2718 | } |
---|
| 2719 | |
---|
| 2720 | function planner_process_interval() |
---|
| 2721 | { |
---|
| 2722 | // generate duplicate free list of events within observed interval |
---|
| 2723 | // |
---|
| 2724 | $this->bo->store_to_cache( |
---|
| 2725 | Array( |
---|
| 2726 | 'syear' => $this->bo->year, |
---|
| 2727 | 'smonth' => $this->bo->month, |
---|
| 2728 | 'sday' => 1, |
---|
| 2729 | 'eyear' => $this->planner_end_year, |
---|
| 2730 | 'emonth' => $this->planner_end_month, |
---|
| 2731 | 'eday' => $this->planner_days_in_end_month |
---|
| 2732 | ) |
---|
| 2733 | ); |
---|
| 2734 | $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); |
---|
| 2735 | |
---|
| 2736 | // process all events within observed interval |
---|
| 2737 | // |
---|
| 2738 | for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++) |
---|
| 2739 | { |
---|
| 2740 | $daily = $this->bo->cached_events[$v]; |
---|
| 2741 | |
---|
| 2742 | print_debug('For Date',$v); |
---|
| 2743 | print_debug('Count of items',count($daily)); |
---|
| 2744 | |
---|
| 2745 | // process all events on day $v |
---|
| 2746 | // |
---|
| 2747 | if (is_array($daily)) foreach($daily as $event) |
---|
| 2748 | { |
---|
| 2749 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
| 2750 | { |
---|
| 2751 | $this->bo->set_recur_date($event,$v); |
---|
| 2752 | } |
---|
| 2753 | if (!$this->bo->rejected_no_show($event)) |
---|
| 2754 | { |
---|
| 2755 | $this->planner_process_event($event); |
---|
| 2756 | } |
---|
| 2757 | } |
---|
| 2758 | } |
---|
| 2759 | $this->planner_pad_rows(); |
---|
| 2760 | } |
---|
| 2761 | |
---|
| 2762 | function matrixselect() |
---|
| 2763 | { |
---|
| 2764 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2765 | |
---|
| 2766 | $sb = CreateObject('phpgwapi.sbox'); |
---|
| 2767 | |
---|
| 2768 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2769 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2770 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
| 2771 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2772 | |
---|
| 2773 | $p = &$GLOBALS['phpgw']->template; |
---|
| 2774 | $p->set_file( |
---|
| 2775 | Array( |
---|
| 2776 | 'mq' => 'matrix_query.tpl', |
---|
| 2777 | 'form_button' => 'form_button_script.tpl' |
---|
| 2778 | ) |
---|
| 2779 | ); |
---|
| 2780 | $p->set_block('mq','matrix_query','matrix_query'); |
---|
| 2781 | $p->set_block('mq','list','list'); |
---|
| 2782 | |
---|
| 2783 | $p->set_var(array( |
---|
| 2784 | 'title' => lang('Daily Matrix View'), |
---|
| 2785 | 'th_bg' => $this->theme['th_bg'], |
---|
| 2786 | 'action_url' => $this->page('viewmatrix') |
---|
| 2787 | )); |
---|
| 2788 | |
---|
| 2789 | // Date |
---|
| 2790 | $var[] = Array( |
---|
| 2791 | 'field' => lang('Date'), |
---|
| 2792 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 2793 | $sb->getYears('year',(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y'),(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y')), |
---|
| 2794 | $sb->getMonthText('month',(int)$GLOBALS['phpgw']->common->show_date($datetime,'n')), |
---|
| 2795 | $sb->getDays('day',(int)$GLOBALS['phpgw']->common->show_date($datetime,'d')) |
---|
| 2796 | ) |
---|
| 2797 | ); |
---|
| 2798 | |
---|
| 2799 | // View type |
---|
| 2800 | $var[] = Array( |
---|
| 2801 | 'field' => lang('View'), |
---|
| 2802 | 'data' => '<select name="matrixtype">'."\n" |
---|
| 2803 | . '<option value="free/busy" selected>'.lang('free/busy').'</option>'."\n" |
---|
| 2804 | . '<option value="weekly">'.lang('Weekly').'</option>'."\n" |
---|
| 2805 | . '</select>'."\n" |
---|
| 2806 | ); |
---|
| 2807 | |
---|
| 2808 | // Participants |
---|
| 2809 | $accounts = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'calendar'); |
---|
| 2810 | $users = Array(); |
---|
| 2811 | for($i=0;$i<count($accounts);$i++) |
---|
| 2812 | { |
---|
| 2813 | $user = $accounts[$i]; |
---|
| 2814 | if(!isset($users[$user])) |
---|
| 2815 | { |
---|
| 2816 | $users[$user] = $GLOBALS['phpgw']->common->grab_owner_name($user); |
---|
| 2817 | if($GLOBALS['phpgw']->accounts->get_type($user) == 'g') |
---|
| 2818 | { |
---|
| 2819 | $group_members = $GLOBALS['phpgw']->acl->get_ids_for_location($user,1,'phpgw_group'); |
---|
| 2820 | if($group_members != False) |
---|
| 2821 | { |
---|
| 2822 | for($j=0;$j<count($group_members);$j++) |
---|
| 2823 | { |
---|
| 2824 | if(!isset($users[$group_members[$j]])) |
---|
| 2825 | { |
---|
| 2826 | $users[$group_members[$j]] = $GLOBALS['phpgw']->common->grab_owner_name($group_members[$j]); |
---|
| 2827 | } |
---|
| 2828 | } |
---|
| 2829 | } |
---|
| 2830 | } |
---|
| 2831 | } |
---|
| 2832 | } |
---|
| 2833 | |
---|
| 2834 | $num_users = count($users); |
---|
| 2835 | |
---|
| 2836 | if ($num_users > 50) |
---|
| 2837 | { |
---|
| 2838 | $size = 15; |
---|
| 2839 | } |
---|
| 2840 | elseif ($num_users > 5) |
---|
| 2841 | { |
---|
| 2842 | $size = 5; |
---|
| 2843 | } |
---|
| 2844 | else |
---|
| 2845 | { |
---|
| 2846 | $size = $num_users; |
---|
| 2847 | } |
---|
| 2848 | $str = ''; |
---|
| 2849 | @asort($users); |
---|
| 2850 | @reset($users); |
---|
| 2851 | while ($user = each($users)) |
---|
| 2852 | { |
---|
| 2853 | 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') |
---|
| 2854 | { |
---|
| 2855 | $str .= ' <option value="'.$user[0].'">('.$GLOBALS['phpgw']->accounts->get_type($user[0]).') '.$user[1].'</option>'."\n"; |
---|
| 2856 | } |
---|
| 2857 | } |
---|
| 2858 | $var[] = Array( |
---|
| 2859 | 'field' => lang('Participants'), |
---|
| 2860 | 'data' => "\n".' <select name="participants[]" multiple size="'.$size.'">'."\n".$str.' </select>'."\n" |
---|
| 2861 | ); |
---|
| 2862 | |
---|
| 2863 | for($i=0;$i<count($var);$i++) |
---|
| 2864 | { |
---|
| 2865 | $this->output_template_array($p,'rows','list',$var[$i]); |
---|
| 2866 | } |
---|
| 2867 | |
---|
| 2868 | $vars = Array( |
---|
| 2869 | 'submit_button' => lang('View'), |
---|
| 2870 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
| 2871 | 'action_text_button' => lang('Cancel'), |
---|
| 2872 | 'action_confirm_button' => '', |
---|
| 2873 | 'action_extra_field' => '' |
---|
| 2874 | ); |
---|
| 2875 | |
---|
| 2876 | $p->set_var($vars); |
---|
| 2877 | $p->parse('cancel_button','form_button'); |
---|
| 2878 | $p->pparse('out','matrix_query'); |
---|
| 2879 | } |
---|
| 2880 | |
---|
| 2881 | function viewmatrix() |
---|
| 2882 | { |
---|
| 2883 | if ($_POST['cancel']) |
---|
| 2884 | { |
---|
| 2885 | $this->index(); |
---|
| 2886 | } |
---|
| 2887 | $participants = $_POST['participants']; |
---|
| 2888 | $parts = Array(); |
---|
| 2889 | $acct = CreateObject('phpgwapi.accounts',$this->bo->owner); |
---|
| 2890 | |
---|
| 2891 | if (is_array($participants)) |
---|
| 2892 | { |
---|
| 2893 | foreach($participants as $participant) |
---|
| 2894 | { |
---|
| 2895 | switch ($GLOBALS['phpgw']->accounts->get_type($participant)) |
---|
| 2896 | { |
---|
| 2897 | case 'g': |
---|
| 2898 | if ($members = $acct->member((int)$participant)) |
---|
| 2899 | { |
---|
| 2900 | foreach($members as $member) |
---|
| 2901 | { |
---|
| 2902 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id'])) |
---|
| 2903 | { |
---|
| 2904 | $parts[$member['account_id']] = True; |
---|
| 2905 | } |
---|
| 2906 | } |
---|
| 2907 | } |
---|
| 2908 | break; |
---|
| 2909 | case 'u': |
---|
| 2910 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$participant)) |
---|
| 2911 | { |
---|
| 2912 | $parts[$participant] = 1; |
---|
| 2913 | } |
---|
| 2914 | break; |
---|
| 2915 | } |
---|
| 2916 | } |
---|
| 2917 | unset($acct); |
---|
| 2918 | } |
---|
| 2919 | $participants = array_keys($parts); // get id's as values and a numeric index |
---|
| 2920 | |
---|
| 2921 | // Defined - into session - who participates |
---|
| 2922 | $GLOBALS['phpgw']->session->appsession("participants", NULL, implode(";", $participants)); |
---|
| 2923 | |
---|
| 2924 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2925 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2926 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
| 2927 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2928 | |
---|
| 2929 | switch($_POST['matrixtype']) |
---|
| 2930 | { |
---|
| 2931 | case 'free/busy': |
---|
| 2932 | $freetime = $GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year)); |
---|
| 2933 | echo '<br>'.$this->timematrix( |
---|
| 2934 | Array( |
---|
| 2935 | 'date' => $freetime, |
---|
| 2936 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 2937 | 'endtime' => 0, |
---|
| 2938 | 'participants' => $parts |
---|
| 2939 | ) |
---|
| 2940 | ); |
---|
| 2941 | break; |
---|
| 2942 | case 'weekly': |
---|
| 2943 | echo '<br>'.$this->display_weekly( |
---|
| 2944 | Array( |
---|
| 2945 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 2946 | 'showyear' => true, |
---|
| 2947 | 'owners' => $participants |
---|
| 2948 | ) |
---|
| 2949 | ); |
---|
| 2950 | break; |
---|
| 2951 | } |
---|
| 2952 | echo "\n<br>\n".'<form action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n"; |
---|
| 2953 | echo ' <table cellpadding="5"><tr><td>'."\n"; |
---|
| 2954 | echo ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
| 2955 | echo ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
| 2956 | echo ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
| 2957 | echo ' <input type="hidden" name="matrixtype" value="'.$_POST['matrixtype'].'">'."\n"; |
---|
| 2958 | foreach($participants as $part) |
---|
| 2959 | { |
---|
| 2960 | echo ' <input type="hidden" name="participants[]" value="'.$part.'">'."\n"; |
---|
| 2961 | } |
---|
| 2962 | echo ' <input type="submit" name="refresh" value="'.lang('Refresh').'">'."\n"; |
---|
| 2963 | echo ' </td><td>'."\n"; |
---|
| 2964 | echo ' <input type="submit" name="cancel" value="'.lang('Cancel').'">'."\n"; |
---|
| 2965 | echo ' </td></tr></table>'."\n"; |
---|
| 2966 | echo '</form>'."\n"; |
---|
| 2967 | } |
---|
| 2968 | |
---|
| 2969 | function search() |
---|
| 2970 | { |
---|
| 2971 | if (empty($_POST['keywords'])) |
---|
| 2972 | { |
---|
| 2973 | // If we reach this, it is because they didn't search for anything |
---|
| 2974 | // or they used one of the selectboxes (year, month, week) in the search-result |
---|
| 2975 | // attempt to send them back to where they came from. |
---|
| 2976 | |
---|
| 2977 | $vars['menuaction'] = isset($_POST['from']) && $_POST['from'] != 'calendar.uicalendar.search' ? |
---|
| 2978 | $_POST['from'] : 'calendar.uicalendar.index'; |
---|
| 2979 | |
---|
| 2980 | foreach(array('date','year','month','day') as $field) |
---|
| 2981 | { |
---|
| 2982 | if (isset($_POST[$field])) |
---|
| 2983 | { |
---|
| 2984 | $vars[$field] = $_POST[$field]; |
---|
| 2985 | } |
---|
| 2986 | } |
---|
[5132] | 2987 | |
---|
| 2988 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2989 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2990 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
| 2991 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2992 | |
---|
| 2993 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
| 2994 | return; |
---|
| 2995 | //$GLOBALS['phpgw']->redirect_link('/index.php',$vars); |
---|
[2] | 2996 | } |
---|
| 2997 | |
---|
| 2998 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2999 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 3000 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
| 3001 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 3002 | |
---|
| 3003 | $error = ''; |
---|
| 3004 | |
---|
| 3005 | $matches = 0; |
---|
| 3006 | |
---|
| 3007 | // There is currently a problem searching in with repeated events. |
---|
| 3008 | // It spits back out the date it was entered. I would like to to say that |
---|
| 3009 | // it is a repeated event. |
---|
| 3010 | |
---|
| 3011 | // This has been solved by the little icon indicator for recurring events. |
---|
| 3012 | |
---|
| 3013 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
| 3014 | foreach($event_ids as $key => $id) |
---|
| 3015 | { |
---|
| 3016 | $event = $this->bo->read_entry($id); |
---|
| 3017 | |
---|
| 3018 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$event)) |
---|
| 3019 | { |
---|
| 3020 | continue; |
---|
| 3021 | } |
---|
| 3022 | |
---|
| 3023 | $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3024 | |
---|
| 3025 | $info[strval($event['id'])] = array( |
---|
| 3026 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
| 3027 | 'date' => $GLOBALS['phpgw']->common->show_date($datetime), |
---|
| 3028 | 'link' => $this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']) |
---|
| 3029 | ); |
---|
| 3030 | |
---|
| 3031 | } |
---|
| 3032 | $matches = count($event_ids); |
---|
| 3033 | |
---|
| 3034 | if ($matches == 1) |
---|
| 3035 | { |
---|
| 3036 | $quantity = lang('1 match found').'.'; |
---|
| 3037 | } |
---|
| 3038 | elseif ($matches > 0) |
---|
| 3039 | { |
---|
| 3040 | $quantity = lang('%1 matches found',$matches).'.'; |
---|
| 3041 | } |
---|
| 3042 | else |
---|
| 3043 | { |
---|
| 3044 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
| 3045 | return; |
---|
| 3046 | } |
---|
| 3047 | |
---|
| 3048 | $p = $GLOBALS['phpgw']->template; |
---|
| 3049 | $p->set_file( |
---|
| 3050 | Array( |
---|
| 3051 | 'search_form' => 'search.tpl' |
---|
| 3052 | ) |
---|
| 3053 | ); |
---|
| 3054 | $p->set_block('search_form','search','search'); |
---|
| 3055 | $p->set_block('search_form','search_list_header','search_list_header'); |
---|
| 3056 | $p->set_block('search_form','search_list','search_list'); |
---|
| 3057 | $p->set_block('search_form','search_list_footer','search_list_footer'); |
---|
| 3058 | |
---|
| 3059 | $var = Array( |
---|
| 3060 | 'th_bg' => $this->theme['th_bg'], |
---|
| 3061 | 'search_text' => lang('Search Results'), |
---|
| 3062 | 'quantity' => $quantity |
---|
| 3063 | ); |
---|
| 3064 | $p->set_var($var); |
---|
| 3065 | |
---|
| 3066 | if($matches > 0) |
---|
| 3067 | { |
---|
| 3068 | $p->parse('rows','search_list_header',True); |
---|
| 3069 | } |
---|
| 3070 | foreach($info as $id => $data) |
---|
| 3071 | { |
---|
| 3072 | $p->set_var($data); |
---|
| 3073 | $p->parse('rows','search_list',True); |
---|
| 3074 | } |
---|
| 3075 | |
---|
| 3076 | if($matches > 0) |
---|
| 3077 | { |
---|
| 3078 | $p->parse('rows','search_list_footer',True); |
---|
| 3079 | } |
---|
| 3080 | |
---|
| 3081 | $p->pparse('out','search'); |
---|
| 3082 | } |
---|
| 3083 | |
---|
| 3084 | /* Private functions */ |
---|
| 3085 | function _debug_sqsof() |
---|
| 3086 | { |
---|
| 3087 | $data = array( |
---|
| 3088 | 'filter' => $this->bo->filter, |
---|
| 3089 | 'cat_id' => $this->bo->cat_id, |
---|
| 3090 | 'owner' => $this->bo->owner, |
---|
| 3091 | 'year' => $this->bo->year, |
---|
| 3092 | 'month' => $this->bo->month, |
---|
| 3093 | 'day' => $this->bo->day, |
---|
| 3094 | 'sortby' => $this->bo->sortby, |
---|
| 3095 | 'num_months' => $this->bo->num_months |
---|
| 3096 | ); |
---|
| 3097 | Return _debug_array($data,False); |
---|
| 3098 | } |
---|
| 3099 | |
---|
| 3100 | function output_template_array(&$p,$row,$list,$var) |
---|
| 3101 | { |
---|
| 3102 | if (!isset($var['hidden_vars'])) |
---|
| 3103 | { |
---|
| 3104 | $var['hidden_vars'] = ''; |
---|
| 3105 | } |
---|
| 3106 | if (!isset($var['tr_color'])) |
---|
| 3107 | { |
---|
| 3108 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
| 3109 | } |
---|
| 3110 | $p->set_var($var); |
---|
| 3111 | $p->parse($row,$list,True); |
---|
| 3112 | } |
---|
| 3113 | |
---|
| 3114 | function page($_page='',$params='') |
---|
| 3115 | { |
---|
| 3116 | if($_page == '') |
---|
| 3117 | { |
---|
| 3118 | $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); |
---|
| 3119 | $_page = $page_[0]; |
---|
| 3120 | |
---|
| 3121 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
| 3122 | { |
---|
| 3123 | $_page = 'planner'; |
---|
| 3124 | } |
---|
| 3125 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
| 3126 | { |
---|
| 3127 | $_page = 'month'; |
---|
| 3128 | $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); |
---|
| 3129 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 3130 | } |
---|
| 3131 | } |
---|
| 3132 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
| 3133 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
| 3134 | { |
---|
| 3135 | $page_app = 'calendar'; |
---|
| 3136 | } |
---|
| 3137 | else |
---|
| 3138 | { |
---|
| 3139 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
| 3140 | } |
---|
| 3141 | if (is_array($params)) |
---|
| 3142 | { |
---|
| 3143 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
| 3144 | } |
---|
| 3145 | else |
---|
| 3146 | { |
---|
| 3147 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
| 3148 | } |
---|
| 3149 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
| 3150 | } |
---|
| 3151 | |
---|
| 3152 | function header() |
---|
| 3153 | { |
---|
| 3154 | $cols = 8; |
---|
| 3155 | if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) |
---|
| 3156 | { |
---|
| 3157 | $cols++; |
---|
| 3158 | } |
---|
| 3159 | |
---|
| 3160 | $tpl = $GLOBALS['phpgw']->template; |
---|
| 3161 | $tpl->set_unknowns('remove'); |
---|
| 3162 | |
---|
| 3163 | if (!file_exists($file = $this->template_dir.'/header.inc.php')) |
---|
| 3164 | { |
---|
| 3165 | $file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php'; |
---|
| 3166 | } |
---|
[362] | 3167 | |
---|
[2] | 3168 | include($file); |
---|
[362] | 3169 | $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); |
---|
| 3170 | if($refer[2] != 'view') { |
---|
[2] | 3171 | $header = $tpl->fp('out','head'); |
---|
| 3172 | unset($tpl); |
---|
| 3173 | echo $header; |
---|
| 3174 | } |
---|
[362] | 3175 | unset($tpl); |
---|
| 3176 | } |
---|
[2] | 3177 | |
---|
| 3178 | function footer() |
---|
| 3179 | { |
---|
| 3180 | $menuaction = $_GET['menuaction']; |
---|
| 3181 | list(,,$method) = explode('.',$menuaction); |
---|
| 3182 | |
---|
| 3183 | if (@$this->bo->printer_friendly) |
---|
| 3184 | { |
---|
| 3185 | return; |
---|
| 3186 | } |
---|
| 3187 | |
---|
| 3188 | $p = $GLOBALS['phpgw']->template; |
---|
| 3189 | |
---|
| 3190 | $p->set_file( |
---|
| 3191 | Array( |
---|
| 3192 | 'footer' => 'footer.tpl', |
---|
[4114] | 3193 | 'form_button' => 'form_button_script.tpl' |
---|
[2] | 3194 | ) |
---|
| 3195 | ); |
---|
| 3196 | $p->set_block('footer','footer_table','footer_table'); |
---|
| 3197 | $p->set_block('footer','footer_row','footer_row'); |
---|
| 3198 | $p->set_block('footer','blank_row','blank_row'); |
---|
[924] | 3199 | $p->set_block('footer','num_dias','num_dias'); |
---|
[2] | 3200 | |
---|
| 3201 | $m = $this->bo->month; |
---|
| 3202 | $y = $this->bo->year; |
---|
| 3203 | |
---|
[924] | 3204 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
| 3205 | $mes_hoje = (int)substr($hoje,4,2); |
---|
| 3206 | $mes_footer = (int)substr($_POST['date'],4,2); |
---|
| 3207 | if($_GET['sday']) |
---|
| 3208 | { |
---|
| 3209 | if($_GET['month'] == $mes_hoje) |
---|
| 3210 | { |
---|
| 3211 | $day = $this->bo->day; |
---|
[4114] | 3212 | } |
---|
[924] | 3213 | else |
---|
| 3214 | { |
---|
| 3215 | $day = $_GET['sday']; |
---|
| 3216 | } |
---|
| 3217 | } |
---|
| 3218 | else |
---|
| 3219 | { |
---|
| 3220 | $day = $this->bo->day; |
---|
| 3221 | $dia_ini = $day; |
---|
| 3222 | } |
---|
| 3223 | if($mes_footer == $mes_hoje) |
---|
| 3224 | { |
---|
| 3225 | $dia_ini = (int)substr($hoje,6,2); |
---|
| 3226 | $day = $dia_ini; |
---|
| 3227 | } |
---|
| 3228 | /********************************************************************************************/ |
---|
| 3229 | /* Bloco adicionado para receber o dia a partir do qual a versao para impressao sera gerada */ |
---|
| 3230 | $str_ini = ''; |
---|
| 3231 | for ($i = 1; $i <= ($GLOBALS['phpgw']->datetime->days_in_month($m, $y)); $i++) |
---|
| 3232 | { |
---|
| 3233 | $str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3234 | } |
---|
[5132] | 3235 | $str_qtd = '<option value="'.''.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; |
---|
[924] | 3236 | for ($i = 1; $i <= 45; $i++) |
---|
| 3237 | { |
---|
| 3238 | $str_qtd .= '<option value="'.$i.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3239 | } |
---|
| 3240 | $display = ''; |
---|
| 3241 | $display_view = ''; |
---|
[5132] | 3242 | if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') ) |
---|
[924] | 3243 | { |
---|
| 3244 | $display = 'none'; |
---|
| 3245 | } |
---|
| 3246 | else if( ($menuaction == 'calendar.uicalendar.view') ) |
---|
| 3247 | { |
---|
| 3248 | $display = 'none'; |
---|
| 3249 | $display_view = 'none'; |
---|
| 3250 | } |
---|
| 3251 | $var = Array( |
---|
| 3252 | 'acao' => $this->page($method,''), |
---|
| 3253 | 'formname' => 'SelectDay', |
---|
| 3254 | 'formonchange' => 'document.SelectDay.submit()', |
---|
[5132] | 3255 | 'day_ini_label' => lang('print starting in'), |
---|
[924] | 3256 | 'num_dias_label' => lang('quantity of days'), |
---|
[5132] | 3257 | 'tip' => lang('empty prints from the day chosen below to the end of the current month'), |
---|
| 3258 | 'day_ini_name' => 'day', |
---|
| 3259 | 'num_dias_name' => 'qtd_dias', |
---|
[924] | 3260 | 'row_ini' => $str_ini, |
---|
| 3261 | 'row_qtd' => $str_qtd, |
---|
| 3262 | 'display' => $display, |
---|
| 3263 | 'display_view' => $display_view, |
---|
| 3264 | 'go' => lang('Go!') |
---|
| 3265 | ); |
---|
| 3266 | $this->output_template_array($p,'table_row','num_dias',$var); |
---|
| 3267 | |
---|
| 3268 | /********************************************************************************************/ |
---|
| 3269 | |
---|
[2] | 3270 | $thisdate = date('Ymd',mktime(0,0,0,$m,1,$y)); |
---|
| 3271 | $y--; |
---|
| 3272 | |
---|
| 3273 | $str = ''; |
---|
[924] | 3274 | for ($i = 0; $i < 20; $i++) |
---|
[2] | 3275 | { |
---|
| 3276 | $m++; |
---|
| 3277 | if ($m > 12) |
---|
| 3278 | { |
---|
| 3279 | $m = 1; |
---|
| 3280 | $y++; |
---|
| 3281 | } |
---|
| 3282 | $d = mktime(0,0,0,$m,1,$y); |
---|
| 3283 | $d_ymd = date('Ymd',$d); |
---|
| 3284 | $str .= '<option value="'.$d_ymd.'"'.($d_ymd == $thisdate?' selected':'').'>'.lang(date('F', $d)).strftime(' %Y', $d).'</option>'."\n"; |
---|
| 3285 | } |
---|
| 3286 | |
---|
| 3287 | $var = Array( |
---|
| 3288 | 'action_url' => $this->page($method,''), |
---|
| 3289 | 'form_name' => 'SelectMonth', |
---|
| 3290 | 'label' => lang('Month'), |
---|
| 3291 | 'form_label' => 'date', |
---|
| 3292 | 'form_onchange' => 'document.SelectMonth.submit()', |
---|
| 3293 | 'row' => $str, |
---|
[5132] | 3294 | 'dia_ini' => $dia_ini, |
---|
[2] | 3295 | 'go' => lang('Go!') |
---|
| 3296 | ); |
---|
| 3297 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3298 | |
---|
| 3299 | if($menuaction == 'calendar.uicalendar.week') |
---|
| 3300 | { |
---|
| 3301 | unset($thisdate); |
---|
| 3302 | $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3303 | $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3304 | |
---|
| 3305 | $str = ''; |
---|
| 3306 | for ($i = -7; $i <= 7; $i++) |
---|
| 3307 | { |
---|
| 3308 | $begin = $sun + (7*24*60*60 * $i) + 12*60*60; // we use midday, that changes in daylight-saveing does not effect us |
---|
| 3309 | $end = $begin + 6*24*60*60; |
---|
| 3310 | // echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end); |
---|
| 3311 | $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate+12*60*60 && $end >= $thisdate+12*60*60 ? ' selected':'').'>' |
---|
| 3312 | . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - ' |
---|
| 3313 | . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) |
---|
| 3314 | . '</option>' . "\n"; |
---|
| 3315 | } |
---|
| 3316 | |
---|
| 3317 | $var = Array( |
---|
| 3318 | 'action_url' => $this->page($method,''), |
---|
| 3319 | 'form_name' => 'SelectWeek', |
---|
| 3320 | 'label' => lang('Week'), |
---|
| 3321 | 'form_label' => 'date', |
---|
| 3322 | 'form_onchange' => 'document.SelectWeek.submit()', |
---|
| 3323 | 'row' => $str, |
---|
| 3324 | 'go' => lang('Go!') |
---|
| 3325 | ); |
---|
| 3326 | |
---|
| 3327 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3328 | } |
---|
| 3329 | |
---|
| 3330 | $str = ''; |
---|
| 3331 | for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); $i++) |
---|
| 3332 | { |
---|
| 3333 | $str .= '<option value="'.$i.'"'.($i == $this->bo->year?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3334 | } |
---|
| 3335 | |
---|
| 3336 | $var = Array( |
---|
| 3337 | 'action_url' => $this->page($method,''), |
---|
| 3338 | 'form_name' => 'SelectYear', |
---|
| 3339 | 'label' => lang('Year'), |
---|
| 3340 | 'form_label' => 'year', |
---|
| 3341 | 'form_onchange' => 'document.SelectYear.submit()', |
---|
| 3342 | 'row' => $str, |
---|
| 3343 | 'go' => lang('Go!') |
---|
| 3344 | ); |
---|
| 3345 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3346 | |
---|
| 3347 | if($menuaction == 'calendar.uicalendar.planner') |
---|
| 3348 | { |
---|
| 3349 | $str = ''; |
---|
| 3350 | $date_str = ''; |
---|
| 3351 | |
---|
| 3352 | if(isset($_GET['date']) && $_GET['date']) |
---|
| 3353 | { |
---|
| 3354 | $date_str .= ' <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n"; |
---|
| 3355 | } |
---|
| 3356 | $date_str .= ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
| 3357 | $date_str .= ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
| 3358 | $date_str .= ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
| 3359 | |
---|
| 3360 | for($i=1; $i<=6; $i++) |
---|
| 3361 | { |
---|
| 3362 | $str .= '<option value="'.$i.'"'.($i == $this->bo->num_months?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3363 | } |
---|
| 3364 | |
---|
| 3365 | $var = Array( |
---|
| 3366 | 'action_url' => $this->page($method,''), |
---|
| 3367 | 'form_name' => 'SelectNumberOfMonths', |
---|
| 3368 | 'label' => lang('Number of Months'), |
---|
| 3369 | 'hidden_vars' => $date_str, |
---|
| 3370 | 'form_label' => 'num_months', |
---|
| 3371 | 'form_onchange' => 'document.SelectNumberOfMonths.submit()', |
---|
| 3372 | 'action_extra_field' => $date_str, |
---|
| 3373 | 'row' => $str, |
---|
| 3374 | 'go' => lang('Go!') |
---|
| 3375 | ); |
---|
| 3376 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3377 | } |
---|
| 3378 | |
---|
| 3379 | $var = Array( |
---|
| 3380 | 'submit_button' => lang('Submit'), |
---|
| 3381 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), |
---|
| 3382 | 'action_text_button' => lang('Import'), |
---|
| 3383 | 'action_confirm_button' => '', |
---|
| 3384 | 'action_extra_field' => '' |
---|
| 3385 | ); |
---|
| 3386 | $this->output_template_array($p,'b_row','form_button',$var); |
---|
[57] | 3387 | |
---|
| 3388 | $var = Array( |
---|
| 3389 | 'submit_button' => lang('Submit'), |
---|
| 3390 | 'action_url' => $this->page($method,''), |
---|
| 3391 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.export_all'), |
---|
| 3392 | 'action_text_button' => lang('Export all'), |
---|
| 3393 | 'action_confirm_button' => '', |
---|
| 3394 | 'action_extra_field' => '' |
---|
| 3395 | ); |
---|
| 3396 | $this->output_template_array($p,'b_row2','form_button',$var); |
---|
[4114] | 3397 | |
---|
[2] | 3398 | $p->parse('table_row','blank_row',True); |
---|
[5132] | 3399 | |
---|
[2] | 3400 | $p->pparse('out','footer_table'); |
---|
| 3401 | unset($p); |
---|
| 3402 | } |
---|
| 3403 | |
---|
| 3404 | function css() |
---|
| 3405 | { |
---|
| 3406 | $GLOBALS['phpgw']->browser->browser(); |
---|
| 3407 | if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA') |
---|
| 3408 | { |
---|
| 3409 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?12:8); |
---|
| 3410 | } |
---|
| 3411 | else |
---|
| 3412 | { |
---|
| 3413 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?10:7); |
---|
| 3414 | } |
---|
| 3415 | |
---|
| 3416 | // moved to app.css in templates/default for future separation of code and style [NDEE 10.03.04] |
---|
| 3417 | /* |
---|
| 3418 | return 'A.minicalendar { color: #000000; font-size: 72%; font-family: '.$this->theme['font'].' }'."\n" |
---|
| 3419 | . ' A.bminicalendar { color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 3420 | . ' A.minicalendargrey { color: #999999; font-size: 8px; font-family: '.$this->theme['font'].' }'."\n" |
---|
| 3421 | . ' A.bminicalendargrey { color: #336699; font-style: italic; font-size:8px; font-family '.$this->theme['font'].' }'."\n" |
---|
| 3422 | . ' A.minicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font: x-small '.$this->theme['font'].' }'."\n" |
---|
| 3423 | . ' A.bminicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 3424 | . ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: x-small '.$this->theme['font'].' }'."\n" |
---|
| 3425 | . ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 3426 | . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 3427 | . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 3428 | . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 3429 | . ' .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" |
---|
| 3430 | . ' .tablecell { width: 80px; height: 80px }'."\n" |
---|
| 3431 | . ' .planner-cell { cursor:pointer; cursor:hand; border: thin solid black; }'; |
---|
| 3432 | */ |
---|
| 3433 | } |
---|
| 3434 | |
---|
| 3435 | function no_edit() |
---|
| 3436 | { |
---|
| 3437 | if(!isset($GLOBALS['phpgw_info']['flags']['noheader'])) |
---|
| 3438 | { |
---|
| 3439 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 3440 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 3441 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 3442 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 3443 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Permission denied'); |
---|
| 3444 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 3445 | } |
---|
| 3446 | echo '<center>You do not have permission to edit this appointment!</center>'; |
---|
| 3447 | return; |
---|
| 3448 | } |
---|
| 3449 | |
---|
| 3450 | function link_to_entry($event,$month,$day,$year) |
---|
| 3451 | { |
---|
| 3452 | $str = ''; |
---|
| 3453 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3454 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3455 | |
---|
[5132] | 3456 | if(!$viewable && $event['type'] == 'E' && !$event['public']){ |
---|
| 3457 | return ""; |
---|
| 3458 | } |
---|
| 3459 | |
---|
[2] | 3460 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3461 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3462 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
| 3463 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3464 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3465 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
| 3466 | { |
---|
| 3467 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3468 | } |
---|
| 3469 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
| 3470 | { |
---|
| 3471 | $time = '[ '.lang('All Day').' ]'; |
---|
| 3472 | } |
---|
| 3473 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
| 3474 | { |
---|
| 3475 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3476 | { |
---|
| 3477 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
| 3478 | } |
---|
| 3479 | else |
---|
| 3480 | { |
---|
| 3481 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3482 | } |
---|
| 3483 | |
---|
[5132] | 3484 | |
---|
| 3485 | // if($endtime >= ($rawdate_offset + 86400 )) |
---|
| 3486 | // { |
---|
| 3487 | // $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
| 3488 | // } |
---|
| 3489 | // else |
---|
| 3490 | // { |
---|
[2] | 3491 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
[5132] | 3492 | // } |
---|
[2] | 3493 | $time = $start_time.'-'.$end_time; |
---|
| 3494 | } |
---|
| 3495 | else |
---|
| 3496 | { |
---|
| 3497 | $time = ''; |
---|
| 3498 | } |
---|
| 3499 | |
---|
| 3500 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
| 3501 | |
---|
| 3502 | |
---|
| 3503 | |
---|
| 3504 | if(!$is_private) |
---|
| 3505 | { |
---|
| 3506 | //$text .= $this->bo->display_status($event['users_status']); |
---|
| 3507 | |
---|
| 3508 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
| 3509 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
| 3510 | |
---|
| 3511 | } |
---|
| 3512 | |
---|
| 3513 | /* |
---|
| 3514 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
| 3515 | (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). |
---|
| 3516 | $GLOBALS['phpgw']->browser->br; |
---|
| 3517 | */ |
---|
| 3518 | |
---|
| 3519 | $texttime=$time; |
---|
| 3520 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
[5132] | 3521 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
[2] | 3522 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
[5132] | 3523 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
[2] | 3524 | |
---|
| 3525 | if ($viewable) |
---|
| 3526 | { |
---|
| 3527 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
| 3528 | $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
| 3529 | $this->link_tpl->set_var('lang_view',lang('View this entry')); |
---|
| 3530 | $this->link_tpl->set_var('desc', $textdesc); |
---|
| 3531 | $this->link_tpl->set_var('location', $textlocation); |
---|
| 3532 | $this->link_tpl->parse('picture','link_open',True); |
---|
| 3533 | } |
---|
| 3534 | if (!$is_private) |
---|
| 3535 | { |
---|
| 3536 | if($event['priority'] == 3) |
---|
| 3537 | { |
---|
| 3538 | $picture[] = Array( |
---|
| 3539 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
| 3540 | 'width' => 16, |
---|
| 3541 | 'height'=> 16, |
---|
| 3542 | 'title' => lang('high priority') |
---|
| 3543 | ); |
---|
| 3544 | } |
---|
| 3545 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3546 | { |
---|
| 3547 | $picture[] = Array( |
---|
| 3548 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
| 3549 | 'width' => 9, |
---|
| 3550 | 'height'=> 9, |
---|
| 3551 | 'title' => lang('single event') |
---|
| 3552 | ); |
---|
| 3553 | } |
---|
| 3554 | else |
---|
| 3555 | { |
---|
| 3556 | $picture[] = Array( |
---|
| 3557 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
| 3558 | 'width' => 12, |
---|
| 3559 | 'height'=> 12, |
---|
| 3560 | 'title' => lang('recurring event') |
---|
| 3561 | ); |
---|
| 3562 | } |
---|
| 3563 | } |
---|
| 3564 | $participants = $this->planner_participants($event['participants']); |
---|
| 3565 | if(count($event['participants']) > 1) |
---|
| 3566 | { |
---|
| 3567 | $picture[] = Array( |
---|
| 3568 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
| 3569 | 'width' => 14, |
---|
| 3570 | 'height'=> 14, |
---|
| 3571 | 'title' => $participants |
---|
| 3572 | ); |
---|
| 3573 | } |
---|
| 3574 | else |
---|
[5132] | 3575 | { |
---|
[2] | 3576 | $picture[] = Array( |
---|
| 3577 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
| 3578 | 'width' => 14, |
---|
| 3579 | 'height'=> 14, |
---|
| 3580 | 'title' => $participants |
---|
| 3581 | ); |
---|
| 3582 | } |
---|
| 3583 | if($event['public'] == 0) |
---|
| 3584 | { |
---|
| 3585 | $picture[] = Array( |
---|
| 3586 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
| 3587 | 'width' => 13, |
---|
| 3588 | 'height'=> 13, |
---|
| 3589 | 'title' => lang('private') |
---|
| 3590 | ); |
---|
| 3591 | } |
---|
| 3592 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
| 3593 | { |
---|
| 3594 | // if the alarm is to go off the day before the event |
---|
| 3595 | // the icon does not show up because of 'alarm_today' |
---|
| 3596 | // - TOM |
---|
| 3597 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
| 3598 | { |
---|
| 3599 | $picture[] = Array( |
---|
| 3600 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
| 3601 | 'width' => 13, |
---|
| 3602 | 'height'=> 13, |
---|
| 3603 | 'title' => lang('alarm') |
---|
| 3604 | ); |
---|
| 3605 | } |
---|
| 3606 | } |
---|
| 3607 | |
---|
| 3608 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
| 3609 | for($i=0;$i<count($picture);$i++) |
---|
| 3610 | { |
---|
| 3611 | $var = Array( |
---|
| 3612 | 'pic_image' => $picture[$i]['pict'], |
---|
| 3613 | 'width' => $picture[$i]['width'], |
---|
| 3614 | 'height' => $picture[$i]['height'], |
---|
| 3615 | 'title' => $picture[$i]['title'] |
---|
| 3616 | ); |
---|
| 3617 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
| 3618 | } |
---|
[5132] | 3619 | if ($texttitle) |
---|
[2] | 3620 | { |
---|
| 3621 | $var = Array( |
---|
| 3622 | // 'text' => $text, |
---|
| 3623 | 'time'=> $texttime, |
---|
| 3624 | 'title'=> $texttitle, |
---|
| 3625 | 'users_status'=>$textstatus, |
---|
| 3626 | 'desc'=> $textdesc, |
---|
[5132] | 3627 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
[2] | 3628 | ); |
---|
| 3629 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
| 3630 | } |
---|
| 3631 | |
---|
| 3632 | if ($viewable) |
---|
| 3633 | { |
---|
| 3634 | $this->link_tpl->parse('picture','link_close',True); |
---|
| 3635 | } |
---|
| 3636 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
| 3637 | $this->link_tpl->set_var('picture',''); |
---|
| 3638 | $this->link_tpl->set_var('out',''); |
---|
| 3639 | // unset($p); |
---|
| 3640 | return $str; |
---|
| 3641 | } |
---|
| 3642 | |
---|
[360] | 3643 | /*****************************************************************************************/ |
---|
| 3644 | /*Funcao foi duplicada e alterada para tratar os eventos de agendamento (exibicao do mes) para impressao; |
---|
[924] | 3645 | utiliza o template event_link.tpl*/ |
---|
[360] | 3646 | |
---|
| 3647 | function link_to_month_entry($event,$month,$day,$year) |
---|
| 3648 | { |
---|
| 3649 | $str = ''; |
---|
| 3650 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3651 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3652 | |
---|
| 3653 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3654 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3655 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
| 3656 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3657 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3658 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
| 3659 | { |
---|
| 3660 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3661 | } |
---|
| 3662 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
| 3663 | { |
---|
| 3664 | $time = '[ '.lang('All Day').' ]'; |
---|
| 3665 | } |
---|
| 3666 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
| 3667 | { |
---|
| 3668 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3669 | { |
---|
| 3670 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
| 3671 | } |
---|
| 3672 | else |
---|
| 3673 | { |
---|
| 3674 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3675 | } |
---|
| 3676 | |
---|
| 3677 | if($endtime >= ($rawdate_offset + 86400)) |
---|
| 3678 | { |
---|
| 3679 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
| 3680 | } |
---|
| 3681 | else |
---|
| 3682 | { |
---|
| 3683 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
| 3684 | } |
---|
| 3685 | $time = $start_time.' - '.$end_time; |
---|
| 3686 | } |
---|
| 3687 | else |
---|
| 3688 | { |
---|
| 3689 | $time = ''; |
---|
| 3690 | } |
---|
| 3691 | |
---|
[5132] | 3692 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
[360] | 3693 | |
---|
[5132] | 3694 | |
---|
| 3695 | |
---|
[360] | 3696 | if(!$is_private) |
---|
| 3697 | { |
---|
[5132] | 3698 | //$text .= $this->bo->display_status($event['users_status']); |
---|
| 3699 | |
---|
[360] | 3700 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
| 3701 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
| 3702 | |
---|
| 3703 | } |
---|
| 3704 | |
---|
[5132] | 3705 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
[3989] | 3706 | |
---|
[5132] | 3707 | $texttime=$time; |
---|
| 3708 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
| 3709 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
[360] | 3710 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
[5132] | 3711 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
[360] | 3712 | |
---|
| 3713 | if ($viewable) |
---|
| 3714 | { |
---|
| 3715 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
| 3716 | $this->event_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
| 3717 | $this->event_tpl->set_var('lang_view',lang('View this entry')); |
---|
[5132] | 3718 | $this->event_tpl->set_var('desc', $textdesc); |
---|
| 3719 | $this->event_tpl->set_var('location', $textlocation); |
---|
[360] | 3720 | $this->event_tpl->parse('picture','link_event_open',True); |
---|
| 3721 | } |
---|
| 3722 | if (!$is_private) |
---|
| 3723 | { |
---|
| 3724 | if($event['priority'] == 3) |
---|
| 3725 | { |
---|
| 3726 | $picture[] = Array( |
---|
| 3727 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
| 3728 | 'width' => 16, |
---|
| 3729 | 'height'=> 16, |
---|
| 3730 | 'title' => lang('high priority') |
---|
| 3731 | ); |
---|
| 3732 | } |
---|
| 3733 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3734 | { |
---|
| 3735 | $picture[] = Array( |
---|
| 3736 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
| 3737 | 'width' => 9, |
---|
| 3738 | 'height'=> 9, |
---|
| 3739 | 'title' => lang('single event') |
---|
| 3740 | ); |
---|
| 3741 | } |
---|
| 3742 | else |
---|
| 3743 | { |
---|
| 3744 | $picture[] = Array( |
---|
| 3745 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
| 3746 | 'width' => 12, |
---|
| 3747 | 'height'=> 12, |
---|
| 3748 | 'title' => lang('recurring event') |
---|
| 3749 | ); |
---|
| 3750 | } |
---|
| 3751 | } |
---|
[3989] | 3752 | |
---|
[360] | 3753 | $participants = $this->planner_participants($event['participants']); |
---|
| 3754 | if(count($event['participants']) > 1) |
---|
| 3755 | { |
---|
| 3756 | $picture[] = Array( |
---|
| 3757 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
| 3758 | 'width' => 14, |
---|
| 3759 | 'height'=> 14, |
---|
| 3760 | 'title' => $participants |
---|
| 3761 | ); |
---|
| 3762 | } |
---|
| 3763 | else |
---|
| 3764 | { |
---|
| 3765 | $picture[] = Array( |
---|
| 3766 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
| 3767 | 'width' => 14, |
---|
| 3768 | 'height'=> 14, |
---|
| 3769 | 'title' => $participants |
---|
| 3770 | ); |
---|
| 3771 | } |
---|
| 3772 | if($event['public'] == 0) |
---|
| 3773 | { |
---|
| 3774 | $picture[] = Array( |
---|
| 3775 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
| 3776 | 'width' => 13, |
---|
| 3777 | 'height'=> 13, |
---|
| 3778 | 'title' => lang('private') |
---|
| 3779 | ); |
---|
| 3780 | } |
---|
[3989] | 3781 | |
---|
[360] | 3782 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
| 3783 | { |
---|
| 3784 | // if the alarm is to go off the day before the event |
---|
| 3785 | // the icon does not show up because of 'alarm_today' |
---|
| 3786 | // - TOM |
---|
| 3787 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
| 3788 | { |
---|
| 3789 | $picture[] = Array( |
---|
| 3790 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
| 3791 | 'width' => 13, |
---|
| 3792 | 'height'=> 13, |
---|
| 3793 | 'title' => lang('alarm') |
---|
| 3794 | ); |
---|
| 3795 | } |
---|
| 3796 | } |
---|
| 3797 | |
---|
| 3798 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
| 3799 | for($i=0;$i<count($picture);$i++) |
---|
| 3800 | { |
---|
| 3801 | $var = Array( |
---|
| 3802 | 'pic_image' => $picture[$i]['pict'], |
---|
| 3803 | 'width' => $picture[$i]['width'], |
---|
| 3804 | 'height' => $picture[$i]['height'], |
---|
| 3805 | 'title' => $picture[$i]['title'] |
---|
| 3806 | ); |
---|
| 3807 | $this->output_template_array($this->event_tpl,'picture','event_pict',$var); |
---|
| 3808 | } |
---|
[5132] | 3809 | if ($texttitle) |
---|
[360] | 3810 | { |
---|
| 3811 | $var = Array( |
---|
| 3812 | // 'text' => $text, |
---|
[5132] | 3813 | 'time'=> $texttime, |
---|
| 3814 | 'title'=> $texttitle, |
---|
[360] | 3815 | 'users_status'=>$textstatus, |
---|
[5132] | 3816 | 'desc'=> $textdesc, |
---|
| 3817 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
[360] | 3818 | ); |
---|
| 3819 | $this->output_template_array($this->event_tpl,'picture','link_event_text',$var); |
---|
| 3820 | } |
---|
| 3821 | |
---|
| 3822 | if ($viewable) |
---|
| 3823 | { |
---|
| 3824 | $this->event_tpl->parse('picture','link_event_close',True); |
---|
| 3825 | } |
---|
| 3826 | $str = $this->event_tpl->fp('out','link_event_pict'); |
---|
| 3827 | $this->event_tpl->set_var('picture',''); |
---|
| 3828 | $this->event_tpl->set_var('out',''); |
---|
| 3829 | // unset($p); |
---|
| 3830 | return $str; |
---|
| 3831 | } |
---|
| 3832 | |
---|
| 3833 | /*****************************************************************************************/ |
---|
[625] | 3834 | function normDec($num) |
---|
| 3835 | { |
---|
| 3836 | if ($num > 9) |
---|
| 3837 | return $num; |
---|
| 3838 | else |
---|
| 3839 | return "0".$num; |
---|
| 3840 | } |
---|
[2] | 3841 | function overlap($params) |
---|
| 3842 | { |
---|
| 3843 | if(!is_array($params)) |
---|
| 3844 | { |
---|
| 3845 | } |
---|
| 3846 | else |
---|
| 3847 | { |
---|
| 3848 | $overlapping_events = $params['o_events']; |
---|
[5132] | 3849 | |
---|
| 3850 | if( is_string( $overlapping_events )) |
---|
| 3851 | $overlapping_events = explode( ';', $overlapping_events ); |
---|
| 3852 | |
---|
[2] | 3853 | $event = $params['this_event']; |
---|
[5132] | 3854 | |
---|
| 3855 | if( is_string( $event ) ) |
---|
| 3856 | $event = $this->bo->read_entry( $event ); |
---|
| 3857 | |
---|
| 3858 | if( !$event ) |
---|
| 3859 | $event = $this->bo->restore_from_appsession(); |
---|
[2] | 3860 | } |
---|
| 3861 | |
---|
| 3862 | $month = $event['start']['month']; |
---|
| 3863 | $mday = $event['start']['mday']; |
---|
| 3864 | $year = $event['start']['year']; |
---|
| 3865 | |
---|
| 3866 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3867 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3868 | |
---|
| 3869 | $overlap = ''; |
---|
| 3870 | for($i=0;$i<count($overlapping_events);$i++) |
---|
| 3871 | { |
---|
| 3872 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
| 3873 | foreach($overlapped_event['participants'] as $id => $status) |
---|
| 3874 | { |
---|
| 3875 | $conflict = isset($event['participants'][$id]); |
---|
| 3876 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
| 3877 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
[5132] | 3878 | ($conflict?'</b> - '.lang('Scheduling conflict'):'').'</li>'; |
---|
[2] | 3879 | } |
---|
[625] | 3880 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
| 3881 | $overlap .= '<ul><font size="1"><span>'. |
---|
| 3882 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
| 3883 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
| 3884 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
| 3885 | $this->normDec($overlapped_event['end']['min']). |
---|
| 3886 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
| 3887 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
| 3888 | else |
---|
[5132] | 3889 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year).'"</ul><br>'; |
---|
[2] | 3890 | } |
---|
| 3891 | |
---|
| 3892 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 3893 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 3894 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 3895 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 3896 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
| 3897 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 3898 | |
---|
[5132] | 3899 | $porig = $GLOBALS['phpgw']->template; |
---|
| 3900 | |
---|
[5316] | 3901 | $GLOBALS['phpgw']->template->root = dirname(__FILE__).'/../templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/'; |
---|
[5132] | 3902 | |
---|
[2] | 3903 | $p = $GLOBALS['phpgw']->template; |
---|
| 3904 | $p->set_file( |
---|
| 3905 | Array( |
---|
| 3906 | 'overlap' => 'overlap.tpl', |
---|
| 3907 | 'form_button' => 'form_button_script.tpl' |
---|
| 3908 | ) |
---|
| 3909 | ); |
---|
| 3910 | |
---|
| 3911 | $var = Array( |
---|
| 3912 | 'color' => $this->theme['bg_text'], |
---|
| 3913 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
| 3914 | '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)), |
---|
| 3915 | 'overlap_list' => $overlap |
---|
| 3916 | ); |
---|
| 3917 | $p->set_var($var); |
---|
| 3918 | |
---|
| 3919 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
[5132] | 3920 | |
---|
| 3921 | $var = Array( |
---|
| 3922 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'calendar.uicalendar.index')), |
---|
| 3923 | 'action_text_button' => lang('Cancel'), |
---|
| 3924 | 'action_confirm_button' => '', |
---|
| 3925 | 'action_extra_field' => '', |
---|
| 3926 | 'button_id' => 'cancel_button' |
---|
| 3927 | ); |
---|
| 3928 | $this->output_template_array($p,'cancel_button','form_button',$var); |
---|
| 3929 | |
---|
[2] | 3930 | $var = Array( |
---|
| 3931 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), |
---|
| 3932 | 'action_text_button' => lang('Ignore Conflict'), |
---|
| 3933 | 'action_confirm_button' => '', |
---|
[663] | 3934 | 'action_extra_field' => '', |
---|
| 3935 | 'button_id' => 'ignore_button' |
---|
[2] | 3936 | ); |
---|
| 3937 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
| 3938 | |
---|
[5132] | 3939 | if( $event['owner'] == -2 || $event['id'] != 0 ) |
---|
| 3940 | { |
---|
| 3941 | $p->set_var( 'suggestion', $this->build_suggestion( $event , $params['this_account']) ); |
---|
| 3942 | |
---|
| 3943 | $var = Array( |
---|
| 3944 | 'action_url_button' => '', |
---|
| 3945 | 'action_text_button' => lang('Suggest new hour'), |
---|
| 3946 | 'action_confirm_button' => 'onsubmit="javascript: return false;" onclick="javascript: return show_suggestion();"', |
---|
| 3947 | 'action_extra_field' => '', |
---|
| 3948 | 'button_id' => 'redit_button' |
---|
| 3949 | ); |
---|
| 3950 | } |
---|
| 3951 | else |
---|
| 3952 | { |
---|
| 3953 | $p->set_var( 'suggestion', '' ); |
---|
| 3954 | |
---|
[2] | 3955 | $var = Array( |
---|
| 3956 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), |
---|
| 3957 | 'action_text_button' => lang('Re-Edit Event'), |
---|
| 3958 | 'action_confirm_button' => '', |
---|
[663] | 3959 | 'action_extra_field' => '', |
---|
| 3960 | 'button_id' => 'redit_button' |
---|
[2] | 3961 | ); |
---|
[5132] | 3962 | } |
---|
[2] | 3963 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
| 3964 | $p->pparse('out','overlap'); |
---|
[5132] | 3965 | //return 'OLA'; |
---|
[2] | 3966 | } |
---|
| 3967 | |
---|
| 3968 | function planner_participants($parts) |
---|
| 3969 | { |
---|
| 3970 | static $id2lid; |
---|
| 3971 | |
---|
| 3972 | $names = ''; |
---|
| 3973 | while (list($id,$status) = each($parts)) |
---|
| 3974 | { |
---|
| 3975 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
| 3976 | |
---|
| 3977 | if (!isset($id2lid[$id])) |
---|
| 3978 | { |
---|
| 3979 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
| 3980 | } |
---|
| 3981 | if (strlen($names)) |
---|
| 3982 | { |
---|
| 3983 | $names .= ",\n"; |
---|
| 3984 | } |
---|
| 3985 | $names .= $id2lid[$id]." ($status)"; |
---|
| 3986 | } |
---|
| 3987 | if($this->debug) |
---|
| 3988 | { |
---|
| 3989 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
| 3990 | } |
---|
| 3991 | return $names; |
---|
| 3992 | } |
---|
| 3993 | |
---|
| 3994 | function planner_category($ids) |
---|
| 3995 | { |
---|
| 3996 | static $cats; |
---|
| 3997 | if(!is_array($ids)) |
---|
| 3998 | { |
---|
| 3999 | if (strpos($ids,',')) |
---|
| 4000 | { |
---|
| 4001 | $id_array = explode(',',$ids); |
---|
| 4002 | } |
---|
| 4003 | else |
---|
| 4004 | { |
---|
| 4005 | $id_array[0] = $ids; |
---|
| 4006 | } |
---|
| 4007 | } |
---|
| 4008 | @reset($id_array); |
---|
| 4009 | $ret_val = Array(); |
---|
| 4010 | while(list($index,$id) = each($id_array)) |
---|
| 4011 | { |
---|
| 4012 | if (!isset($cats[$id])) |
---|
| 4013 | { |
---|
| 4014 | $cat_arr = $this->cat->return_single( $id ); |
---|
| 4015 | $cats[$id] = $cat_arr[0]; |
---|
| 4016 | $cats[$id]['color'] = strstr($cats[$id]['description'],'#'); |
---|
| 4017 | } |
---|
| 4018 | $ret_val[] = $cats[$id]; |
---|
| 4019 | } |
---|
| 4020 | return $ret_val; |
---|
| 4021 | } |
---|
| 4022 | |
---|
| 4023 | function week_header($month,$year,$display_name = False) |
---|
| 4024 | { |
---|
| 4025 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 4026 | |
---|
| 4027 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4028 | $p->set_unknowns('remove'); |
---|
| 4029 | $p->set_file( |
---|
| 4030 | Array ( |
---|
| 4031 | 'month_header' => 'month_header.tpl' |
---|
| 4032 | ) |
---|
| 4033 | ); |
---|
| 4034 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 4035 | $p->set_block('month_header','column_title','column_title'); |
---|
| 4036 | |
---|
| 4037 | $var = Array( |
---|
| 4038 | 'bgcolor' => $this->theme['th_bg'], |
---|
| 4039 | 'font_color' => $this->theme['th_text'] |
---|
| 4040 | ); |
---|
| 4041 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 4042 | { |
---|
| 4043 | $var = Array( |
---|
| 4044 | 'bgcolor' => '', |
---|
| 4045 | 'font_color' => '' |
---|
| 4046 | ); |
---|
| 4047 | } |
---|
| 4048 | $p->set_var($var); |
---|
| 4049 | |
---|
| 4050 | $p->set_var('col_width','14'); |
---|
| 4051 | if($display_name == True) |
---|
| 4052 | { |
---|
| 4053 | $p->set_var('col_title',lang('name')); |
---|
| 4054 | $p->parse('column_header','column_title',True); |
---|
| 4055 | $p->set_var('col_width','12'); |
---|
| 4056 | } |
---|
| 4057 | |
---|
| 4058 | for($i=0;$i<7;$i++) |
---|
| 4059 | { |
---|
| 4060 | $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i])); |
---|
| 4061 | $p->parse('column_header','column_title',True); |
---|
| 4062 | } |
---|
| 4063 | return $p->fp('out','monthly_header'); |
---|
| 4064 | } |
---|
| 4065 | |
---|
| 4066 | function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 4067 | { |
---|
| 4068 | if($owner == 0) |
---|
| 4069 | { |
---|
| 4070 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 4071 | } |
---|
| 4072 | |
---|
| 4073 | $temp_owner = $this->bo->owner; |
---|
| 4074 | |
---|
| 4075 | $str = ''; |
---|
| 4076 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4077 | $p->set_unknowns('keep'); |
---|
| 4078 | |
---|
| 4079 | $p->set_file( |
---|
| 4080 | Array( |
---|
| 4081 | 'month_header' => 'month_header.tpl', |
---|
| 4082 | 'month_day' => 'month_day.tpl' |
---|
| 4083 | ) |
---|
| 4084 | ); |
---|
| 4085 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 4086 | $p->set_block('month_header','month_column','month_column'); |
---|
| 4087 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 4088 | $p->set_block('month_day','day_event','day_event'); |
---|
| 4089 | $p->set_block('month_day','event','event'); |
---|
| 4090 | |
---|
| 4091 | $p->set_var('extra',''); |
---|
| 4092 | $p->set_var('col_width','14'); |
---|
| 4093 | if($display_name) |
---|
| 4094 | { |
---|
| 4095 | $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner)); |
---|
| 4096 | $p->parse('column_header','month_column',True); |
---|
| 4097 | $p->set_var('col_width','12'); |
---|
| 4098 | } |
---|
| 4099 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 4100 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 4101 | foreach($daily as $date => $day_params) |
---|
| 4102 | { |
---|
| 4103 | $year = (int)substr($date,0,4); |
---|
| 4104 | $month = (int)substr($date,4,2); |
---|
| 4105 | $day = (int)substr($date,6,2); |
---|
[4001] | 4106 | |
---|
[2] | 4107 | $var = Array( |
---|
| 4108 | 'column_data' => '', |
---|
| 4109 | 'extra' => '' |
---|
| 4110 | ); |
---|
| 4111 | $p->set_var($var); |
---|
| 4112 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 4113 | { |
---|
| 4114 | if ($day_params['new_event']) |
---|
| 4115 | { |
---|
| 4116 | $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">' |
---|
| 4117 | . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">' |
---|
| 4118 | . '</a>'; |
---|
| 4119 | $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>'; |
---|
| 4120 | } |
---|
| 4121 | else |
---|
| 4122 | { |
---|
| 4123 | $new_event_link = ''; |
---|
| 4124 | $day_number = $day; |
---|
| 4125 | } |
---|
| 4126 | |
---|
| 4127 | $var = Array( |
---|
| 4128 | 'extra' => $day_params['extra'], |
---|
| 4129 | 'new_event_link'=> $new_event_link, |
---|
| 4130 | 'day_number' => $day_number |
---|
| 4131 | ); |
---|
| 4132 | if($day_params['week']) |
---|
| 4133 | { |
---|
| 4134 | |
---|
| 4135 | //NDEE: style! m_w_table in month_day.tpl |
---|
| 4136 | // week-hilite |
---|
| 4137 | //$var['new_event_link'] .= '<font size="-2"> '. |
---|
| 4138 | $var['new_event_link'] .= ' '. |
---|
| 4139 | (!$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>'); |
---|
| 4140 | } |
---|
| 4141 | |
---|
| 4142 | $p->set_var($var); |
---|
| 4143 | |
---|
| 4144 | if(@$day_params['holidays']) |
---|
| 4145 | { |
---|
| 4146 | foreach($day_params['holidays'] as $key => $value) |
---|
| 4147 | { |
---|
| 4148 | $var = Array( |
---|
| 4149 | 'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br |
---|
| 4150 | ); |
---|
| 4151 | $this->output_template_array($p,'daily_events','event',$var); |
---|
| 4152 | } |
---|
| 4153 | } |
---|
| 4154 | |
---|
| 4155 | if($day_params['appts']) |
---|
| 4156 | { |
---|
| 4157 | $var = Array( |
---|
| 4158 | 'week_day_font_size' => '2', |
---|
| 4159 | 'events' => '' |
---|
| 4160 | ); |
---|
| 4161 | $p->set_var($var); |
---|
| 4162 | $events = $this->bo->cached_events[$date]; |
---|
| 4163 | foreach($events as $event) |
---|
| 4164 | { |
---|
| 4165 | if ($this->bo->rejected_no_show($event)) |
---|
| 4166 | { |
---|
| 4167 | continue; // user does not want to see rejected events |
---|
| 4168 | } |
---|
| 4169 | $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year)); |
---|
| 4170 | $p->parse('events','event',True); |
---|
| 4171 | $p->set_var('day_events',''); |
---|
| 4172 | } |
---|
| 4173 | } |
---|
| 4174 | $p->parse('daily_events','day_event',True); |
---|
| 4175 | $p->parse('column_data','month_daily',True); |
---|
| 4176 | $p->set_var('daily_events',''); |
---|
| 4177 | $p->set_var('events',''); |
---|
| 4178 | /* if($day_params['week']) |
---|
| 4179 | { |
---|
| 4180 | $var = Array( |
---|
| 4181 | 'week_day_font_size' => '-2', |
---|
| 4182 | 'events' => (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'">' .$day_params['week'].'</a>':$day_params['week']) |
---|
| 4183 | ); |
---|
| 4184 | $this->output_template_array($p,'column_data','day_event',$var); |
---|
| 4185 | $p->set_var('events',''); |
---|
| 4186 | } */ |
---|
| 4187 | } |
---|
| 4188 | $p->parse('column_header','month_column',True); |
---|
| 4189 | $p->set_var('column_data',''); |
---|
| 4190 | } |
---|
| 4191 | $this->bo->owner = $temp_owner; |
---|
| 4192 | return $p->fp('out','monthly_header'); |
---|
| 4193 | } |
---|
| 4194 | |
---|
[360] | 4195 | /***************************************************************************************/ |
---|
| 4196 | /*As funcoes abaixo |
---|
| 4197 | month_week_header() |
---|
| 4198 | month_display_week() |
---|
| 4199 | display_month_print() |
---|
| 4200 | month_day_of_week() - esta foi criada mas parte do codigo e de outra funcao da API (day_of_week()); |
---|
| 4201 | |
---|
| 4202 | foram duplicadas e modificadas para atender aas modificacoes do layout de impressao mensal da agenda de eventos; |
---|
| 4203 | TODO: otimizar o codigo |
---|
| 4204 | |
---|
| 4205 | Rommel Cysne |
---|
| 4206 | */ |
---|
| 4207 | |
---|
| 4208 | function month_week_header($month,$year,$display_name = False) |
---|
| 4209 | { |
---|
| 4210 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 4211 | $p->set_unknowns('remove'); |
---|
| 4212 | } |
---|
| 4213 | |
---|
| 4214 | |
---|
| 4215 | function month_day_of_week($year,$month,$day) |
---|
| 4216 | { |
---|
| 4217 | $dia = Array( |
---|
| 4218 | 0 => 'Domingo', |
---|
| 4219 | 1 => 'Segunda', |
---|
| 4220 | 2 => 'Terça', |
---|
| 4221 | 3 => 'Quarta', |
---|
| 4222 | 4 => 'Quinta', |
---|
| 4223 | 5 => 'Sexta', |
---|
| 4224 | 6 => 'Sábado' |
---|
| 4225 | ); |
---|
| 4226 | |
---|
| 4227 | if($month > 2) |
---|
| 4228 | { |
---|
| 4229 | $month -= 2; |
---|
| 4230 | } |
---|
| 4231 | else |
---|
| 4232 | { |
---|
| 4233 | $month += 10; |
---|
| 4234 | $year--; |
---|
| 4235 | } |
---|
| 4236 | $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); |
---|
| 4237 | |
---|
| 4238 | $month_day = ($day - 7 * floor($day / 7)); //retorna o numero do dia da semana (Ex: domingo eh dia 0, terca eh 2); |
---|
| 4239 | $weekday = $dia[$month_day]; //retorna o nome do dia da semana de acordo com seu numero; |
---|
| 4240 | |
---|
| 4241 | return ($weekday); |
---|
| 4242 | |
---|
| 4243 | } |
---|
| 4244 | |
---|
| 4245 | function month_display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 4246 | { |
---|
| 4247 | if($owner == 0) |
---|
| 4248 | { |
---|
| 4249 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 4250 | } |
---|
| 4251 | |
---|
| 4252 | $temp_owner = $this->bo->owner; |
---|
| 4253 | |
---|
| 4254 | $str = ''; |
---|
| 4255 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4256 | $p->set_unknowns('keep'); |
---|
| 4257 | |
---|
| 4258 | $p->set_file( |
---|
| 4259 | Array( |
---|
| 4260 | 'month_header' => 'month_header_print.tpl', |
---|
| 4261 | 'month_day' => 'month_day_print.tpl' |
---|
| 4262 | ) |
---|
| 4263 | ); |
---|
| 4264 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 4265 | $p->set_block('month_header','month_column','month_column'); |
---|
| 4266 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 4267 | $p->set_block('month_day','day_event','day_event'); |
---|
| 4268 | $p->set_block('month_day','event','event'); |
---|
| 4269 | |
---|
| 4270 | $p->set_var('extra',''); |
---|
| 4271 | $p->set_var('col_width','14'); |
---|
[924] | 4272 | |
---|
[360] | 4273 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 4274 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
[924] | 4275 | |
---|
[360] | 4276 | foreach($daily as $date => $day_params) |
---|
| 4277 | { |
---|
| 4278 | $year = (int)substr($date,0,4); |
---|
| 4279 | $month = (int)substr($date,4,2); |
---|
| 4280 | $day = (int)substr($date,6,2); |
---|
[5132] | 4281 | $var = Array( |
---|
| 4282 | 'column_data' => '', |
---|
| 4283 | 'extra' => '' |
---|
| 4284 | ); |
---|
[360] | 4285 | $p->set_var($var); |
---|
| 4286 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 4287 | { |
---|
[924] | 4288 | $new_event_link = ''; |
---|
| 4289 | $day_num = $day; |
---|
| 4290 | $dia_semana = $this->month_day_of_week($year,$month,$day_num); |
---|
| 4291 | $id_aux = mktime(0,0,0,$month,$day,$year); |
---|
| 4292 | $month_identifier = substr(lang(strftime("%B",$id_aux)),0,3); |
---|
[5132] | 4293 | $day_number = $month_identifier . " - " . $dia_semana . ", " . $day_num; |
---|
[360] | 4294 | |
---|
| 4295 | $var = Array( |
---|
| 4296 | 'extra' => $day_params['extra'], |
---|
| 4297 | 'new_event_link'=> $new_event_link, |
---|
[5132] | 4298 | 'day_number' => $day_number |
---|
[360] | 4299 | ); |
---|
| 4300 | |
---|
| 4301 | $p->set_var($var); |
---|
| 4302 | |
---|
| 4303 | if($day_params['appts']) |
---|
| 4304 | { |
---|
| 4305 | $var = Array( |
---|
| 4306 | 'week_day_font_size' => '2', |
---|
| 4307 | 'events' => '' |
---|
| 4308 | ); |
---|
| 4309 | $p->set_var($var); |
---|
[5132] | 4310 | $events = $this->bo->cached_events[$date]; |
---|
| 4311 | foreach($events as $event) |
---|
[360] | 4312 | { |
---|
[5132] | 4313 | if ($this->bo->rejected_no_show($event)) |
---|
[4030] | 4314 | { |
---|
[360] | 4315 | continue; // user does not want to see rejected events |
---|
| 4316 | } |
---|
| 4317 | $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); |
---|
| 4318 | $p->parse('events','event',True); |
---|
| 4319 | $p->set_var('day_events',''); |
---|
| 4320 | } |
---|
| 4321 | } |
---|
| 4322 | $p->parse('daily_events','day_event',True); |
---|
| 4323 | $p->parse('column_data','month_daily',True); |
---|
| 4324 | $p->set_var('daily_events',''); |
---|
| 4325 | $p->set_var('events',''); |
---|
[4030] | 4326 | |
---|
[360] | 4327 | } |
---|
| 4328 | $p->parse('column_header','month_column',True); |
---|
| 4329 | $p->set_var('column_data',''); |
---|
| 4330 | } |
---|
| 4331 | $this->bo->owner = $temp_owner; |
---|
| 4332 | return $p->fp('out','monthly_header'); |
---|
| 4333 | |
---|
| 4334 | } |
---|
| 4335 | |
---|
| 4336 | function display_month_print($month,$year,$showyear,$owner=0) |
---|
| 4337 | { |
---|
| 4338 | if($this->debug) |
---|
| 4339 | { |
---|
| 4340 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 4341 | } |
---|
| 4342 | |
---|
[5132] | 4343 | /* $this->bo->store_to_cache( |
---|
| 4344 | Array( |
---|
| 4345 | 'syear' => $year, |
---|
| 4346 | 'smonth'=> $month, |
---|
| 4347 | 'sday' => 1 |
---|
| 4348 | ) |
---|
| 4349 | ); |
---|
| 4350 | */ |
---|
[924] | 4351 | $day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual; |
---|
| 4352 | $num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial; |
---|
[360] | 4353 | |
---|
| 4354 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
[924] | 4355 | // $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
[360] | 4356 | |
---|
[5132] | 4357 | if($num_dias != 0) |
---|
[924] | 4358 | { |
---|
| 4359 | //se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias; |
---|
[3997] | 4360 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month,$day_ini+$num_dias-1,$year))); |
---|
[924] | 4361 | } |
---|
| 4362 | else |
---|
| 4363 | { |
---|
| 4364 | //se a qtde de dias nao for informada, a data final para impressao vai ate o fim do mes corrente; |
---|
| 4365 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 4366 | } |
---|
| 4367 | |
---|
| 4368 | if($day_ini != 0) |
---|
| 4369 | { |
---|
| 4370 | //o dia de inicio para impressao passa a ser o informado em $day_ini do mes corrente; |
---|
| 4371 | $start = mktime(0,0,0,$month,$day_ini,$year); |
---|
| 4372 | } |
---|
| 4373 | else |
---|
| 4374 | { |
---|
| 4375 | //se nao for informado o dia para inicio da impressao, esta comeca no dia 1 do mes corrente; |
---|
| 4376 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 4377 | } |
---|
| 4378 | //$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 15); |
---|
| 4379 | $start_d = (int)(date('Ymd',$start));//variavel auxiliar que recebe a data inicial de impressao no formato 'Ymd'; |
---|
| 4380 | $saux = (int)(substr($start_d,4,2));//variavel auxiliar que recebe o mes do inicio da impressao; |
---|
| 4381 | $eaux = (int)(substr($monthend,4,2)) + 1;//variavel auxiliar que recebe o mes do fim da impressao; |
---|
| 4382 | //A funcao store_to_cache devolve todos os eventos existentes de determinado usuario em um periodo de tempo |
---|
| 4383 | //especifico. Originalmente, na impressao mensal, esse periodo de tempo era o mes corrente exibido na tela. |
---|
| 4384 | //A mudanca consiste no fato de que uma nova variavel ($saux) e enviada com o mes de inicio do periodo |
---|
| 4385 | //atraves do indice 'smonth' e uma segunda variavel ($eaux) envia o mes final do periodo de tempo atraves |
---|
| 4386 | //do indice 'emonth'. Vide mais comentarios sobre esses valores em class.bocalendar.inc.php, |
---|
| 4387 | //function store_to_cache($params); |
---|
| 4388 | $this->bo->store_to_cache( |
---|
| 4389 | Array( |
---|
| 4390 | 'syear' => $year,//ano atual |
---|
| 4391 | 'smonth'=> $saux,//mes inicial |
---|
| 4392 | 'emonth'=> $eaux,//mes final |
---|
| 4393 | 'sday' => 1 |
---|
| 4394 | )); |
---|
[360] | 4395 | |
---|
| 4396 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4397 | $p->set_unknowns('keep'); |
---|
| 4398 | |
---|
| 4399 | $p->set_file( |
---|
| 4400 | Array( |
---|
| 4401 | 'week' => 'month_day_print.tpl' |
---|
| 4402 | ) |
---|
| 4403 | ); |
---|
| 4404 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 4405 | $p->set_block('week','event','event'); |
---|
| 4406 | |
---|
| 4407 | $var = Array( |
---|
[5132] | 4408 | 'cols' => 1, |
---|
| 4409 | 'day_events'=> '' //$this->month_week_header($month,$year,False) |
---|
[360] | 4410 | ); |
---|
[5132] | 4411 | // $this->output_template_array($p,'row','event',$var); |
---|
[360] | 4412 | |
---|
| 4413 | $cellcolor = $this->theme['row_on']; |
---|
| 4414 | |
---|
| 4415 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 4416 | { |
---|
| 4417 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 4418 | $var = Array( |
---|
| 4419 | 'day_events' => $this->month_display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 4420 | ); |
---|
| 4421 | $this->output_template_array($p,'row','event',$var); |
---|
| 4422 | } |
---|
| 4423 | return $p->fp('out','m_w_table'); |
---|
| 4424 | } |
---|
| 4425 | |
---|
| 4426 | |
---|
| 4427 | /***************************************************************************************/ |
---|
| 4428 | |
---|
[5132] | 4429 | function display_month($month,$year,$showyear,$owner=0) |
---|
[2] | 4430 | { |
---|
| 4431 | if($this->debug) |
---|
| 4432 | { |
---|
| 4433 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 4434 | } |
---|
| 4435 | |
---|
| 4436 | $this->bo->store_to_cache( |
---|
| 4437 | Array( |
---|
| 4438 | 'syear' => $year, |
---|
| 4439 | 'smonth'=> $month, |
---|
| 4440 | 'sday' => 1 |
---|
| 4441 | ) |
---|
| 4442 | ); |
---|
| 4443 | |
---|
| 4444 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
| 4445 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 4446 | |
---|
| 4447 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 4448 | |
---|
| 4449 | if($this->debug) |
---|
| 4450 | { |
---|
| 4451 | echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n"; |
---|
| 4452 | echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n"; |
---|
| 4453 | } |
---|
| 4454 | |
---|
| 4455 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4456 | $p->set_unknowns('keep'); |
---|
| 4457 | |
---|
| 4458 | $p->set_file( |
---|
| 4459 | Array( |
---|
| 4460 | 'week' => 'month_day.tpl' |
---|
| 4461 | ) |
---|
| 4462 | ); |
---|
| 4463 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 4464 | $p->set_block('week','event','event'); |
---|
| 4465 | |
---|
| 4466 | $var = Array( |
---|
[360] | 4467 | 'cols' => 1, |
---|
[2] | 4468 | 'day_events'=> $this->week_header($month,$year,False) |
---|
| 4469 | ); |
---|
| 4470 | $this->output_template_array($p,'row','event',$var); |
---|
| 4471 | |
---|
| 4472 | $cellcolor = $this->theme['row_on']; |
---|
| 4473 | |
---|
| 4474 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 4475 | { |
---|
| 4476 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 4477 | $var = Array( |
---|
| 4478 | 'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 4479 | ); |
---|
| 4480 | $this->output_template_array($p,'row','event',$var); |
---|
| 4481 | } |
---|
| 4482 | return $p->fp('out','m_w_table'); |
---|
| 4483 | } |
---|
| 4484 | |
---|
| 4485 | function display_weekly($params) |
---|
| 4486 | { |
---|
| 4487 | if(!is_array($params)) |
---|
| 4488 | { |
---|
| 4489 | $this->index(); |
---|
| 4490 | } |
---|
| 4491 | |
---|
| 4492 | $year = substr($params['date'],0,4); |
---|
| 4493 | $month = substr($params['date'],4,2); |
---|
| 4494 | $day = substr($params['date'],6,2); |
---|
| 4495 | $showyear = $params['showyear']; |
---|
| 4496 | $owners = $params['owners']; |
---|
| 4497 | |
---|
| 4498 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4499 | $p->set_unknowns('keep'); |
---|
| 4500 | |
---|
| 4501 | $p->set_file( |
---|
| 4502 | Array( |
---|
| 4503 | 'week' => 'month_day.tpl' |
---|
| 4504 | ) |
---|
| 4505 | ); |
---|
| 4506 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 4507 | $p->set_block('week','event','event'); |
---|
| 4508 | |
---|
| 4509 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4510 | |
---|
| 4511 | $cellcolor = $this->theme['row_off']; |
---|
| 4512 | |
---|
| 4513 | $true_printer_friendly = $this->bo->printer_friendly; |
---|
| 4514 | |
---|
| 4515 | if(is_array($owners)) |
---|
| 4516 | { |
---|
| 4517 | $display_name = True; |
---|
| 4518 | $counter = count($owners); |
---|
| 4519 | $owners_array = $owners; |
---|
| 4520 | $cols = 8; |
---|
| 4521 | } |
---|
| 4522 | else |
---|
| 4523 | { |
---|
| 4524 | $display_name = False; |
---|
| 4525 | $counter = 1; |
---|
| 4526 | $owners_array[0] = $owners; |
---|
| 4527 | $cols = 7; |
---|
| 4528 | } |
---|
| 4529 | $var = Array( |
---|
| 4530 | 'cols' => $cols, |
---|
| 4531 | 'day_events' => $this->week_header($month,$year,$display_name) |
---|
| 4532 | ); |
---|
| 4533 | $this->output_template_array($p,'row','event',$var); |
---|
| 4534 | |
---|
| 4535 | $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4536 | $tstop = $tstart + 604800; |
---|
| 4537 | $original_owner = $this->bo->so->owner; |
---|
| 4538 | for($i=0;$i<$counter;$i++) |
---|
| 4539 | { |
---|
| 4540 | $this->bo->so->owner = $owners_array[$i]; |
---|
| 4541 | $this->bo->so->open_box($owners_array[$i]); |
---|
| 4542 | $this->bo->store_to_cache( |
---|
| 4543 | Array( |
---|
| 4544 | 'syear' => date('Y',$tstart), |
---|
| 4545 | 'smonth' => date('m',$tstart), |
---|
| 4546 | 'sday' => date('d',$tstart), |
---|
| 4547 | 'eyear' => date('Y',$tstop), |
---|
| 4548 | 'emonth' => date('m',$tstop), |
---|
| 4549 | 'eday' => date('d',$tstop) |
---|
| 4550 | ) |
---|
| 4551 | ); |
---|
| 4552 | $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$owners_array[$i])); |
---|
| 4553 | $p->parse('row','event',True); |
---|
| 4554 | } |
---|
| 4555 | $this->bo->so->owner = $original_owner; |
---|
| 4556 | $this->bo->printer_friendly = $true_printer_friendly; |
---|
| 4557 | return $p->fp('out','m_w_table'); |
---|
| 4558 | } |
---|
| 4559 | |
---|
| 4560 | function view_event($event,$alarms=False) |
---|
| 4561 | { |
---|
| 4562 | if((!$event['participants'][$this->bo->owner] && !$this->bo->check_perms(PHPGW_ACL_READ,$event))) |
---|
| 4563 | { |
---|
| 4564 | return False; |
---|
| 4565 | } |
---|
| 4566 | |
---|
| 4567 | $p = &$GLOBALS['phpgw']->template; |
---|
| 4568 | |
---|
| 4569 | $p->set_file( |
---|
| 4570 | Array( |
---|
| 4571 | 'view' => 'view.tpl' |
---|
| 4572 | ) |
---|
| 4573 | ); |
---|
| 4574 | $p->set_block('view','view_event','view_event'); |
---|
| 4575 | $p->set_block('view','list','list'); |
---|
| 4576 | $p->set_block('view','hr','hr'); |
---|
| 4577 | |
---|
[5316] | 4578 | include_once(dirname(__FILE__).'/class.ex_participants.inc.php'); |
---|
[5132] | 4579 | $langp = array(); |
---|
| 4580 | $langp['ACCEPTED'] = lang('Accepted'); |
---|
| 4581 | $langp['DECLINED'] = lang('Declined'); |
---|
| 4582 | $langp['TENTATIVE'] = lang('Tentative'); |
---|
| 4583 | $langp['DELEGATED'] = lang('Delegated'); |
---|
| 4584 | $langp['NO ANSWER'] = lang('No answer'); |
---|
| 4585 | $exParticipants = new exParticipants($langp); |
---|
| 4586 | $exParticipants->setParticipantsBySerializable($event['ex_participants']); |
---|
| 4587 | $event['ex_participants'] = $exParticipants->getParticipantsView(); |
---|
[2] | 4588 | |
---|
[5132] | 4589 | $vars = $this->bo->event2array($event); |
---|
[3966] | 4590 | |
---|
[2] | 4591 | $vars['title']['tr_color'] = $this->theme['th_bg']; |
---|
| 4592 | |
---|
| 4593 | foreach($vars['participants']['data'] as $user => $str) |
---|
| 4594 | { |
---|
[5921] | 4595 | if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && preg_match('/^(.*) \((.*)\)$/',$str,$parts)) |
---|
[2] | 4596 | { |
---|
| 4597 | $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; |
---|
| 4598 | } |
---|
| 4599 | } |
---|
| 4600 | $vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']); |
---|
| 4601 | foreach($vars as $var) |
---|
| 4602 | { |
---|
| 4603 | if (strlen($var['data'])) |
---|
| 4604 | { |
---|
| 4605 | $this->output_template_array($p,'row','list',$var); |
---|
| 4606 | } |
---|
| 4607 | } |
---|
| 4608 | |
---|
| 4609 | if($alarms && count($event['alarm'])) |
---|
| 4610 | { |
---|
| 4611 | $p->set_var('th_bg',$this->theme['th_bg']); |
---|
| 4612 | $p->set_var('hr_text',lang('Alarms')); |
---|
| 4613 | $p->parse('row','hr',True); |
---|
| 4614 | foreach($event['alarm'] as $key => $alarm) |
---|
| 4615 | { |
---|
[22] | 4616 | 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] | 4617 | { |
---|
| 4618 | $icon = '<img src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled':'disabled')).'" width="13" height="13">'; |
---|
[625] | 4619 | $var = Array( |
---|
[21] | 4620 | 'field' => $icon.$GLOBALS['phpgw']->common->show_date($alarm['time']), |
---|
| 4621 | 'data' => lang('Email Notification for %1',$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner'])) |
---|
| 4622 | ); |
---|
| 4623 | $this->output_template_array($p,'row','list',$var); |
---|
| 4624 | } |
---|
[2] | 4625 | } |
---|
| 4626 | } |
---|
| 4627 | return True; |
---|
| 4628 | } |
---|
| 4629 | |
---|
| 4630 | function nm_on_off() |
---|
| 4631 | { |
---|
| 4632 | if($GLOBALS['phpgw']->nextmatchs->alternate_row_color() == $this->theme['row_on']) |
---|
| 4633 | { |
---|
| 4634 | return '_on'; |
---|
| 4635 | } |
---|
| 4636 | return '_off'; |
---|
| 4637 | } |
---|
| 4638 | |
---|
| 4639 | function slot_num($time,$set_day_start=0,$set_day_end=0) |
---|
| 4640 | { |
---|
| 4641 | static $day_start, $day_end, $interval=0; |
---|
| 4642 | |
---|
| 4643 | if ($set_day_start) $day_start = $set_day_start; |
---|
| 4644 | if ($set_day_end) $day_end = $set_day_end; |
---|
| 4645 | if (!$interval) $interval = 60*$this->bo->prefs['calendar']['interval']; |
---|
| 4646 | |
---|
| 4647 | if ($time > $day_end) |
---|
| 4648 | { |
---|
| 4649 | $time = $day_end; |
---|
| 4650 | } |
---|
| 4651 | $slot = (int)(($time - $day_start) / $interval); |
---|
| 4652 | |
---|
| 4653 | return $slot < 0 ? 0 : 1+$slot; |
---|
| 4654 | } |
---|
| 4655 | |
---|
| 4656 | function print_day($params) |
---|
| 4657 | { |
---|
| 4658 | if(!is_array($params)) |
---|
| 4659 | { |
---|
| 4660 | $this->index(); |
---|
| 4661 | } |
---|
| 4662 | |
---|
| 4663 | print_debug('in print_day()'); |
---|
| 4664 | |
---|
| 4665 | $this->bo->store_to_cache( |
---|
| 4666 | Array( |
---|
| 4667 | 'syear' => $params['year'], |
---|
| 4668 | 'smonth' => $params['month'], |
---|
| 4669 | 'sday' => $params['day'], |
---|
| 4670 | 'eyear' => $params['year'], |
---|
| 4671 | 'emonth' => $params['month'], |
---|
| 4672 | 'eday' => $params['day'] |
---|
| 4673 | ) |
---|
| 4674 | ); |
---|
| 4675 | |
---|
| 4676 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4677 | $p->set_unknowns('keep'); |
---|
| 4678 | |
---|
| 4679 | $tpl = 'day_cal.tpl'; |
---|
| 4680 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
| 4681 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
| 4682 | { |
---|
| 4683 | $tpl = 'day_list.tpl'; |
---|
| 4684 | } |
---|
| 4685 | $templates = Array( |
---|
| 4686 | 'day_cal' => $tpl |
---|
| 4687 | ); |
---|
| 4688 | |
---|
| 4689 | $p->set_file($templates); |
---|
| 4690 | $p->set_block('day_cal','day','day'); |
---|
| 4691 | $p->set_block('day_cal','day_row','day_row'); |
---|
| 4692 | $p->set_block('day_cal','day_event_on','day_event_on'); |
---|
| 4693 | $p->set_block('day_cal','day_event_off','day_event_off'); |
---|
| 4694 | $p->set_block('day_cal','day_event_holiday','day_event_holiday'); |
---|
| 4695 | $p->set_block('day_cal','day_time','day_time'); |
---|
| 4696 | |
---|
| 4697 | $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); |
---|
| 4698 | |
---|
| 4699 | $day_start = mktime((int)($this->bo->prefs['calendar']['workdaystarts']),0,0,$params['month'],$params['day'],$params['year']); |
---|
| 4700 | $day_end = mktime((int)($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']); |
---|
| 4701 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
| 4702 | print_debug('Date to Eval',$date_to_eval); |
---|
| 4703 | $events_to_show = array(); |
---|
| 4704 | if($daily[$date_to_eval]['appts']) |
---|
| 4705 | { |
---|
| 4706 | $events = $this->bo->cached_events[$date_to_eval]; |
---|
| 4707 | print_debug('Date',$date_to_eval); |
---|
| 4708 | print_debug('Count',count($events)); |
---|
| 4709 | foreach($events as $event) |
---|
| 4710 | { |
---|
| 4711 | if ($this->bo->rejected_no_show($event)) |
---|
| 4712 | { |
---|
| 4713 | continue; // user does not want to see rejected events |
---|
| 4714 | } |
---|
| 4715 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
| 4716 | { |
---|
| 4717 | $this->bo->set_recur_date($event,$date_to_eval); |
---|
| 4718 | } |
---|
| 4719 | $events_to_show[] = array( |
---|
| 4720 | 'starttime' => $this->bo->maketime($event['start']), |
---|
| 4721 | 'endtime' => $this->bo->maketime($event['end']), |
---|
| 4722 | 'content' => $this->link_to_entry($event,$params['month'],$params['day'],$params['year']) |
---|
| 4723 | ); |
---|
| 4724 | } |
---|
| 4725 | } |
---|
| 4726 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
| 4727 | $other = $GLOBALS['phpgw']->hooks->process(array( |
---|
| 4728 | 'location' => 'calendar_include_events', |
---|
| 4729 | 'year' => $params['year'], |
---|
| 4730 | 'month' => $params['month'], |
---|
| 4731 | 'day' => $params['day'], |
---|
| 4732 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
| 4733 | )); |
---|
| 4734 | |
---|
| 4735 | if (is_array($other)) |
---|
| 4736 | { |
---|
| 4737 | foreach($other as $evts) |
---|
| 4738 | { |
---|
| 4739 | if (is_array($evts)) |
---|
| 4740 | { |
---|
| 4741 | $events_to_show = array_merge($events_to_show,$evts); |
---|
| 4742 | } |
---|
| 4743 | } |
---|
| 4744 | usort($events_to_show,create_function('$a,$b','return $a[\'starttime\']-$b[\'starttime\'];')); |
---|
| 4745 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
| 4746 | } |
---|
| 4747 | |
---|
| 4748 | if (count($events_to_show)) |
---|
| 4749 | { |
---|
| 4750 | $last_slot_end = -1; |
---|
| 4751 | foreach($events_to_show as $event) |
---|
| 4752 | { |
---|
| 4753 | $slot = $this->slot_num($event['starttime'],$day_start,$day_end); |
---|
| 4754 | $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 |
---|
| 4755 | |
---|
| 4756 | if ($slot <= $last_slot_end) |
---|
| 4757 | { |
---|
| 4758 | $slot = $last_slot; |
---|
| 4759 | $slot_end = max($last_slot_end,$slot_end); |
---|
| 4760 | } |
---|
| 4761 | $rows[$slot] .= $event['content']; |
---|
| 4762 | |
---|
| 4763 | print_debug('slot',$slot); |
---|
| 4764 | print_debug('row',$rows[$slot]); |
---|
| 4765 | |
---|
| 4766 | $row_span[$slot] = 1 + $slot_end - $slot; |
---|
| 4767 | |
---|
| 4768 | $last_slot = $slot; |
---|
| 4769 | $last_slot_end = $slot_end; |
---|
| 4770 | 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)); |
---|
| 4771 | print_debug('Slot',$slot); |
---|
| 4772 | } |
---|
| 4773 | //echo "rows=<pre>"; print_r($rows); echo "<br>row_span="; print_r($row_span); echo "</pre>\n"; |
---|
| 4774 | } |
---|
| 4775 | $holiday_names = $daily[$date_to_eval]['holidays']; |
---|
| 4776 | if(!$holiday_names) |
---|
| 4777 | { |
---|
| 4778 | $row_to_print = $this->nm_on_off(); |
---|
| 4779 | } |
---|
| 4780 | else |
---|
| 4781 | { |
---|
| 4782 | $row_to_print = '_holiday'; |
---|
| 4783 | foreach($holiday_names as $name) |
---|
| 4784 | { |
---|
| 4785 | $rows[0] = '<center>'.$name.'</center>' . $rows[0]; |
---|
| 4786 | } |
---|
| 4787 | } |
---|
| 4788 | $last_slot = $this->slot_num($day_end,$day_start,$day_end); |
---|
| 4789 | $rowspan = 0; |
---|
| 4790 | for ($slot = 0; $slot <= $last_slot; ++$slot) |
---|
| 4791 | { |
---|
| 4792 | $p->set_var('extras',''); |
---|
| 4793 | if ($rowspan > 1) |
---|
| 4794 | { |
---|
| 4795 | $p->set_var('event',''); |
---|
| 4796 | $rowspan--; |
---|
| 4797 | } |
---|
| 4798 | elseif (!isset($rows[$slot])) |
---|
| 4799 | { |
---|
| 4800 | $p->set_var('event',' '); |
---|
| 4801 | $row_to_print = $this->nm_on_off(); |
---|
| 4802 | $p->parse('event','day_event'.$row_to_print); |
---|
| 4803 | } |
---|
| 4804 | else |
---|
| 4805 | { |
---|
| 4806 | $rowspan = (int)$row_span[$slot]; |
---|
| 4807 | if ($rowspan > 1) |
---|
| 4808 | { |
---|
| 4809 | $p->set_var('extras',' rowspan="'.$rowspan.'"'); |
---|
| 4810 | } |
---|
| 4811 | $p->set_var('event',$rows[$slot]); |
---|
| 4812 | $row_to_print = $this->nm_on_off(); |
---|
| 4813 | $p->parse('event','day_event'.$row_to_print); |
---|
| 4814 | } |
---|
| 4815 | $open_link = $close_link = ''; |
---|
| 4816 | $time = ' '; |
---|
| 4817 | |
---|
| 4818 | if (0 < $slot && $slot < $last_slot) // normal time-slot not before or after day_start/end |
---|
| 4819 | { |
---|
| 4820 | $time = $day_start + ($slot-1) * 60 * $this->bo->prefs['calendar']['interval']; |
---|
| 4821 | $hour = date('H',$time); |
---|
| 4822 | $min = date('i',$time); |
---|
| 4823 | $time = $GLOBALS['phpgw']->common->formattime($hour,$min); |
---|
| 4824 | |
---|
| 4825 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 4826 | { |
---|
| 4827 | $open_link = ' <a href="'.$this->page('add',"&date=$date_to_eval&hour=$hour&minute=$min").'">'; |
---|
| 4828 | $close_link = '</a> '; |
---|
| 4829 | } |
---|
| 4830 | } |
---|
| 4831 | $p->set_var(Array( |
---|
| 4832 | 'open_link' => $open_link, |
---|
| 4833 | 'time' => $time, |
---|
| 4834 | 'close_link' => $close_link, |
---|
| 4835 | 'tr_color' => '' // dummy to stop output_template_array to set it |
---|
| 4836 | )); |
---|
| 4837 | $p->parse('time','day_time'); |
---|
| 4838 | |
---|
| 4839 | $p->parse('row','day_row',True); |
---|
| 4840 | } |
---|
| 4841 | return $p->fp('out','day'); |
---|
| 4842 | } // end function |
---|
| 4843 | |
---|
| 4844 | function timematrix($param) |
---|
| 4845 | { |
---|
| 4846 | if(!is_array($param)) |
---|
| 4847 | { |
---|
| 4848 | $this->index(); |
---|
| 4849 | } |
---|
| 4850 | |
---|
| 4851 | $date = $param['date']; |
---|
| 4852 | $starttime = $param['starttime']; |
---|
| 4853 | $endtime = $param['endtime']; |
---|
| 4854 | $participants = $param['participants']; |
---|
| 4855 | foreach($participants as $part => $nul) |
---|
| 4856 | { |
---|
| 4857 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
| 4858 | // Much better for processor :) |
---|
| 4859 | $participants_id[] .= $part; |
---|
| 4860 | } |
---|
| 4861 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
| 4862 | |
---|
| 4863 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
| 4864 | { |
---|
| 4865 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
| 4866 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
| 4867 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 4868 | } |
---|
| 4869 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
| 4870 | $interval = (int)(60 / $increment); |
---|
| 4871 | |
---|
| 4872 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
| 4873 | |
---|
| 4874 | $str = '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
| 4875 | . ', '.$this->bo->long_date($date).'<br>' |
---|
| 4876 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((24 * $interval) + 1).'">' |
---|
| 4877 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
| 4878 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
| 4879 | for($i=0;$i<24;$i++) |
---|
| 4880 | { |
---|
| 4881 | for($j=0;$j<$interval;$j++) |
---|
| 4882 | { |
---|
| 4883 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
| 4884 | |
---|
| 4885 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'"><font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' |
---|
| 4886 | . '<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;\">" |
---|
| 4887 | . $k."</a> </font></td>\n"; |
---|
| 4888 | } |
---|
| 4889 | } |
---|
| 4890 | $str .= '</tr>' |
---|
| 4891 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
| 4892 | if(!$endtime) |
---|
| 4893 | { |
---|
| 4894 | $endtime = $starttime; |
---|
| 4895 | } |
---|
| 4896 | $owner = $this->bo->owner; |
---|
| 4897 | foreach($participants as $part => $fullname) |
---|
| 4898 | { |
---|
| 4899 | $str .= '<tr align="center">' |
---|
| 4900 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
| 4901 | |
---|
| 4902 | $this->bo->cached_events = Array(); |
---|
| 4903 | $this->bo->so->owner = $part; |
---|
| 4904 | $this->bo->so->open_box($part); |
---|
| 4905 | $this->bo->store_to_cache( |
---|
| 4906 | Array( |
---|
| 4907 | 'syear' => $date['year'], |
---|
| 4908 | 'smonth'=> $date['month'], |
---|
| 4909 | 'sday' => $date['day'], |
---|
| 4910 | 'eyear' => 0, |
---|
| 4911 | 'emonth'=> 0, |
---|
| 4912 | 'eday' => $date['day'] + 1 |
---|
| 4913 | ) |
---|
| 4914 | ); |
---|
| 4915 | |
---|
| 4916 | if(!$this->bo->cached_events[$date['full']]) |
---|
| 4917 | { |
---|
| 4918 | for($j=0;$j<24;$j++) |
---|
| 4919 | { |
---|
| 4920 | for($k=0;$k<$interval;$k++) |
---|
| 4921 | { |
---|
| 4922 | $str .= '<td height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
| 4923 | } |
---|
| 4924 | $str .= "\n"; |
---|
| 4925 | } |
---|
| 4926 | } |
---|
| 4927 | else |
---|
| 4928 | { |
---|
| 4929 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
| 4930 | for($h=0;$h<24;$h++) |
---|
| 4931 | { |
---|
| 4932 | $hour = $h * 10000; |
---|
| 4933 | for($m=0;$m<$interval;$m++) |
---|
| 4934 | { |
---|
| 4935 | $index = ($hour + (($m * $increment) * 100)); |
---|
| 4936 | switch($time_slice[$index]['marker']) |
---|
| 4937 | { |
---|
| 4938 | case ' ': |
---|
| 4939 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
| 4940 | $extra = ''; |
---|
| 4941 | break; |
---|
| 4942 | case '-': |
---|
| 4943 | $time_slice[$index]['color'] = $this->theme['bg01']; |
---|
| 4944 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
| 4945 | $extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
| 4946 | break; |
---|
| 4947 | } |
---|
| 4948 | $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>'; |
---|
| 4949 | } |
---|
| 4950 | $str .= "\n"; |
---|
| 4951 | } |
---|
| 4952 | } |
---|
| 4953 | $str .= '</tr>' |
---|
| 4954 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
| 4955 | } |
---|
| 4956 | $this->bo->owner = $owner; |
---|
| 4957 | $this->bo->so->owner = $owner; |
---|
| 4958 | $this->bo->so->open_box($owner); |
---|
| 4959 | return $str.'</table></center>'."\n"; |
---|
| 4960 | } |
---|
| 4961 | |
---|
| 4962 | function get_response($cal_id) |
---|
| 4963 | { |
---|
| 4964 | $p = &$GLOBALS['phpgw']->template; |
---|
| 4965 | $p->set_file( |
---|
| 4966 | Array( |
---|
| 4967 | 'form_button' => 'form_button_script.tpl' |
---|
| 4968 | ) |
---|
| 4969 | ); |
---|
| 4970 | |
---|
| 4971 | $ev = $this->bo->get_cached_event(); |
---|
| 4972 | $response_choices = Array( |
---|
| 4973 | ACCEPTED => lang('Accept'), |
---|
| 4974 | REJECTED => lang('Reject'), |
---|
| 4975 | TENTATIVE => lang('Tentative') |
---|
| 4976 | ); |
---|
| 4977 | $str = ''; |
---|
| 4978 | while(list($param,$text) = each($response_choices)) |
---|
| 4979 | { |
---|
| 4980 | $var = Array( |
---|
[5132] | 4981 | 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user='.$this->bo->owner), |
---|
[2] | 4982 | 'action_text_button' => ' '.$text.' ', |
---|
| 4983 | 'action_confirm_button' => '', |
---|
| 4984 | 'action_extra_field' => '' |
---|
| 4985 | ); |
---|
| 4986 | $p->set_var($var); |
---|
| 4987 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
| 4988 | } |
---|
| 4989 | if ($this->bo->return_to) |
---|
| 4990 | { |
---|
| 4991 | $var = Array( |
---|
| 4992 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 4993 | 'action_text_button' => lang('cancel'), |
---|
| 4994 | 'action_confirm_button' => '', |
---|
| 4995 | 'action_extra_field' => '' |
---|
| 4996 | ); |
---|
| 4997 | $p->set_var($var); |
---|
| 4998 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
| 4999 | } |
---|
| 5000 | $str = '<td><b>'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).":</b></td>\n".$str; |
---|
| 5001 | |
---|
| 5002 | return '<table width="100%"><tr align="center">'."\n".$str.'</tr></table>'."\n"; |
---|
| 5003 | } |
---|
| 5004 | |
---|
| 5005 | function accounts_popup() |
---|
| 5006 | { |
---|
| 5007 | $GLOBALS['phpgw']->accounts->accounts_popup('calendar'); |
---|
| 5008 | |
---|
| 5009 | } |
---|
| 5010 | |
---|
| 5011 | function edit_form($param) |
---|
| 5012 | { |
---|
[5132] | 5013 | $sHValue = '<option></option> |
---|
| 5014 | <option value="07:00">07:00</option> |
---|
| 5015 | <option value="07:30">07:30</option> |
---|
| 5016 | <option value="08:00">08:00</option> |
---|
| 5017 | <option value="08:30">08:30</option> |
---|
| 5018 | <option value="09:00">09:00</option> |
---|
| 5019 | <option value="09:30">09:30</option> |
---|
| 5020 | <option value="10:00">10:00</option> |
---|
| 5021 | <option value="10:30">10:30</option> |
---|
| 5022 | <option value="11:00">11:00</option> |
---|
| 5023 | <option value="11:30">11:30</option> |
---|
| 5024 | <option value="12:00">12:00</option> |
---|
| 5025 | <option value="12:30">12:30</option> |
---|
| 5026 | <option value="13:00">13:00</option> |
---|
| 5027 | <option value="13:30">13:30</option> |
---|
| 5028 | <option value="14:00">14:00</option> |
---|
| 5029 | <option value="14:30">14:30</option> |
---|
| 5030 | <option value="15:00">15:00</option> |
---|
| 5031 | <option value="15:30">15:30</option> |
---|
| 5032 | <option value="16:00">16:00</option> |
---|
| 5033 | <option value="16:30">16:30</option> |
---|
| 5034 | <option value="17:00">17:00</option> |
---|
| 5035 | <option value="17:30">17:30</option> |
---|
| 5036 | <option value="18:00">18:00</option> |
---|
| 5037 | <option value="18:30">18:30</option> |
---|
| 5038 | <option value="19:00">19:00</option> |
---|
| 5039 | <option value="19:30">19:30</option> |
---|
| 5040 | <option value="20:00">20:00</option> |
---|
| 5041 | <option value="20:30">20:30</option> |
---|
| 5042 | <option value="21:00">21:00</option> |
---|
| 5043 | <option value="21:30">21:30</option> |
---|
| 5044 | <option value="22:00">22:00</option>'; |
---|
| 5045 | |
---|
[2] | 5046 | if(!is_array($param)) |
---|
| 5047 | { |
---|
| 5048 | $this->index(); |
---|
| 5049 | } |
---|
| 5050 | |
---|
| 5051 | if(isset($param['event'])) |
---|
| 5052 | { |
---|
| 5053 | $event = $param['event']; |
---|
| 5054 | } |
---|
| 5055 | |
---|
[5316] | 5056 | include_once(dirname(__FILE__).'/class.ex_participants.inc.php'); |
---|
[5132] | 5057 | $langp = array(); |
---|
| 5058 | $langp['ACCEPTED'] = lang('Accepted'); |
---|
| 5059 | $langp['DECLINED'] = lang('Declined'); |
---|
| 5060 | $langp['TENTATIVE'] = lang('Tentative'); |
---|
| 5061 | $langp['DELEGATED'] = lang('Delegated'); |
---|
| 5062 | $langp['NO ANSWER'] = lang('No answer'); |
---|
| 5063 | $exParticipants = new exParticipants($langp); |
---|
| 5064 | $exParticipants->setParticipantsBySerializable($event['ex_participants']); |
---|
| 5065 | $event['ex_participants'] = $exParticipants->getParticipantsMailsString(); |
---|
[2] | 5066 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
| 5067 | // $sb = CreateObject('phpgwapi.sbox'); |
---|
| 5068 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 5069 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
| 5070 | |
---|
| 5071 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 5072 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 5073 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 5074 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
[204] | 5075 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); |
---|
[663] | 5076 | if ($param['plain'] != "True"){ |
---|
| 5077 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 5078 | } |
---|
| 5079 | else{ |
---|
| 5080 | $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; |
---|
| 5081 | $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; |
---|
| 5082 | } |
---|
[2] | 5083 | |
---|
| 5084 | $p = &$GLOBALS['phpgw']->template; |
---|
| 5085 | $p->set_file( |
---|
| 5086 | Array( |
---|
| 5087 | 'edit' => 'edit.tpl', |
---|
| 5088 | 'form_button' => 'form_button_script.tpl' |
---|
| 5089 | ) |
---|
| 5090 | ); |
---|
| 5091 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
| 5092 | $p->set_block('edit','list','list'); |
---|
| 5093 | $p->set_block('edit','hr','hr'); |
---|
[5132] | 5094 | $p->set_var('lang_set_participants', lang('set the participants')); |
---|
[2] | 5095 | $vars = Array( |
---|
| 5096 | 'font' => $this->theme['font'], |
---|
| 5097 | 'bg_color' => $this->theme['bg_text'], |
---|
| 5098 | 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), |
---|
| 5099 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), |
---|
| 5100 | 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" |
---|
[5132] | 5101 | . '<input type="hidden" name="cal[date]" value="'.$param['date'].'">'."\n" |
---|
[2] | 5102 | . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" |
---|
| 5103 | . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" |
---|
| 5104 | . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": |
---|
| 5105 | (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) |
---|
| 5106 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
| 5107 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
| 5108 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') |
---|
| 5109 | ); |
---|
| 5110 | |
---|
| 5111 | $p->set_var($vars); |
---|
| 5112 | |
---|
| 5113 | // Brief Description |
---|
| 5114 | $var['title'] = Array( |
---|
| 5115 | 'tr_color' => $this->theme['th_bg'], |
---|
| 5116 | 'field' => lang('Title'), |
---|
[5132] | 5117 | 'data' => '<input name="cal[title]" size="45" maxlength="80" value="'.$event['title'].'">' |
---|
[2] | 5118 | ); |
---|
| 5119 | |
---|
| 5120 | // Full Description |
---|
| 5121 | $var['description'] = Array( |
---|
| 5122 | 'field' => lang('Full Description'), |
---|
[5132] | 5123 | 'data' => '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' |
---|
[2] | 5124 | ); |
---|
| 5125 | |
---|
| 5126 | // Display Categories |
---|
| 5127 | if(strpos($event['category'],',')) |
---|
| 5128 | { |
---|
| 5129 | $temp_cats = explode(',',$event['category']); |
---|
| 5130 | @reset($temp_cats); |
---|
| 5131 | while(list($key,$value) = each($temp_cats)) |
---|
| 5132 | { |
---|
| 5133 | $check_cats[] = (int)$value; |
---|
| 5134 | } |
---|
| 5135 | } |
---|
| 5136 | elseif($event['category']) |
---|
| 5137 | { |
---|
| 5138 | $check_cats[] = (int)$event['category']; |
---|
| 5139 | } |
---|
| 5140 | else |
---|
| 5141 | { |
---|
| 5142 | $check_cats[] = 0; |
---|
| 5143 | } |
---|
| 5144 | $var['category'] = Array( |
---|
| 5145 | 'field' => lang('Category'), |
---|
[583] | 5146 | 'data' => '<select name="categories[]" onchange="javascript:updateTitleField(this)" multiple size="5">'.$this->cat->formated_list('select','all',$check_cats,True).'</select>' |
---|
[2] | 5147 | ); |
---|
| 5148 | |
---|
| 5149 | // Location |
---|
| 5150 | $var['location'] = Array( |
---|
| 5151 | 'field' => lang('Location'), |
---|
| 5152 | 'data' => '<input name="cal[location]" size="45" maxlength="255" value="'.$event['location'].'">' |
---|
| 5153 | ); |
---|
| 5154 | |
---|
| 5155 | // Date |
---|
| 5156 | |
---|
| 5157 | $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 5158 | $var['startdate'] = Array( |
---|
| 5159 | 'field' => lang('Start Date'), |
---|
| 5160 | /* |
---|
| 5161 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 5162 | $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), |
---|
| 5163 | $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), |
---|
| 5164 | $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')) |
---|
| 5165 | ) |
---|
| 5166 | */ |
---|
| 5167 | 'data' => $jscal->input('start[str]',$start) |
---|
| 5168 | ); |
---|
| 5169 | |
---|
| 5170 | // Time |
---|
| 5171 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
| 5172 | { |
---|
| 5173 | $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
| 5174 | . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
| 5175 | } |
---|
| 5176 | $var['starttime'] = Array( |
---|
| 5177 | 'field' => lang('Start Time'), |
---|
[5132] | 5178 | 'data' => '<input name="start[hour]" id="start_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" id="start_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2"> <select name="sStartHour" onchange="javascript:sChangeHour(this);">'.$sHValue.'</select>'."\n".$str |
---|
[2] | 5179 | ); |
---|
| 5180 | |
---|
| 5181 | // End Date |
---|
| 5182 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 5183 | $var['enddate'] = Array( |
---|
| 5184 | 'field' => lang('End Date'), |
---|
| 5185 | /* |
---|
| 5186 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 5187 | $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), |
---|
| 5188 | $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), |
---|
| 5189 | $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')) |
---|
| 5190 | ) |
---|
| 5191 | */ |
---|
| 5192 | 'data' => $jscal->input('end[str]',$end) |
---|
| 5193 | ); |
---|
| 5194 | |
---|
| 5195 | // End Time |
---|
| 5196 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
| 5197 | { |
---|
| 5198 | $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
| 5199 | . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
| 5200 | } |
---|
| 5201 | $var['endtime'] = Array( |
---|
| 5202 | 'field' => lang('End Time'), |
---|
[5132] | 5203 | 'data' => '<input name="end[hour]" id="end_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" id="end_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2"> <select name="sEndHour" onchange="javascript:sChangeHour(this);">'.$sHValue.'</select>'."\n".$str |
---|
[2] | 5204 | ); |
---|
| 5205 | |
---|
| 5206 | // Priority |
---|
| 5207 | $var['priority'] = Array( |
---|
| 5208 | 'field' => lang('Priority'), |
---|
| 5209 | 'data' => $sb->getPriority('cal[priority]',$event['priority']) |
---|
| 5210 | ); |
---|
| 5211 | |
---|
[583] | 5212 | // Access |
---|
[2] | 5213 | $var['access'] = Array( |
---|
[935] | 5214 | 'field' => lang('Type'), |
---|
[5132] | 5215 | 'data' => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.($event['type'] == 'H'?'DISABLED':'').'><option value="normal" '.(($event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'.lang('Normal').'</option><option value="private" '.((!$event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.($event['type']=='P'?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>' |
---|
[583] | 5216 | ); //event['public'] |
---|
[2] | 5217 | |
---|
[935] | 5218 | // Participants |
---|
[2] | 5219 | if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) |
---|
| 5220 | { |
---|
| 5221 | switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection']) |
---|
| 5222 | { |
---|
| 5223 | case 'popup': |
---|
| 5224 | while (is_array($event['participants']) && list($id) = each($event['participants'])) |
---|
| 5225 | { |
---|
| 5226 | if($id != (int)$event['owner']) |
---|
| 5227 | { |
---|
| 5228 | $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) |
---|
[5132] | 5229 | .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . ' ('. $id.')</option>' . "\n"; |
---|
[2] | 5230 | } |
---|
| 5231 | } |
---|
| 5232 | $var['participants'] = array |
---|
| 5233 | ( |
---|
| 5234 | 'field' => '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n" |
---|
| 5235 | . '<input type="hidden" name="accountid" value="' . $accountid . '">', |
---|
| 5236 | 'data' => "\n".' <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>' |
---|
| 5237 | ); |
---|
| 5238 | break; |
---|
| 5239 | default: |
---|
| 5240 | foreach($event['participants'] as $id => $participant) |
---|
| 5241 | { |
---|
| 5242 | if (($id != $event['owner']) && ($id != "")) |
---|
| 5243 | { |
---|
| 5244 | $GLOBALS['phpgw']->accounts->get_account_name($id, $lid, $fname, $lname); |
---|
| 5245 | $cn = $fname.' '.$lname; |
---|
| 5246 | $option = ' <option value="' . $id.$participant . '">'.$cn.'</option>'."\n"; |
---|
| 5247 | $str .= $option; |
---|
| 5248 | } |
---|
| 5249 | } |
---|
| 5250 | $str = utf8_decode($str); |
---|
| 5251 | $footer_ext_participantes = '<br> '.lang("The email addresses must be separated by ','"); |
---|
| 5252 | |
---|
| 5253 | $var['participants'] = array |
---|
| 5254 | ( |
---|
| 5255 | 'field' => lang('Participants'), |
---|
| 5256 | 'data' => " |
---|
| 5257 | <table width='100%' border='0'> |
---|
| 5258 | <tr> |
---|
| 5259 | <td width='30%'> |
---|
| 5260 | <center>Participantes</center> |
---|
| 5261 | </td> |
---|
| 5262 | <td width='8%' > </td> |
---|
| 5263 | <td width='40%'> </td> |
---|
| 5264 | </tr> |
---|
| 5265 | <tr> |
---|
| 5266 | <td width='30%'> |
---|
| 5267 | <center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center> |
---|
| 5268 | </td> |
---|
| 5269 | <td width='8%'> |
---|
| 5270 | <center> |
---|
| 5271 | <table width='100%' border='0'> |
---|
| 5272 | <tr height='5'><td> </td></tr> |
---|
| 5273 | <tr><td align='center'> |
---|
| 5274 | <button type='button' onClick='javascript:openListUsers(340,533, " |
---|
| 5275 | .$event['owner']. |
---|
[933] | 5276 | ")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' > Adicionar</button> |
---|
[2] | 5277 | </td> |
---|
| 5278 | </tr> |
---|
| 5279 | <tr height='5'><td> </td></tr> |
---|
| 5280 | <tr><td align='center'> |
---|
[933] | 5281 | <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] | 5282 | </td> |
---|
| 5283 | </tr> |
---|
| 5284 | </table> |
---|
| 5285 | </center> |
---|
| 5286 | </td> |
---|
| 5287 | <td width='40%'> </td> |
---|
| 5288 | </tr> |
---|
| 5289 | </table> |
---|
| 5290 | " |
---|
| 5291 | ); |
---|
| 5292 | // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. |
---|
| 5293 | if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { |
---|
| 5294 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
| 5295 | |
---|
| 5296 | if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ |
---|
| 5297 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 5298 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 5299 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
| 5300 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 5301 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 5302 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 5303 | $user_context = array(); |
---|
| 5304 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
| 5305 | if($i) |
---|
| 5306 | $user_context[] = $dn_part; |
---|
| 5307 | } |
---|
[36] | 5308 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
| 5309 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
| 5310 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
[42] | 5311 | // Fim |
---|
| 5312 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
| 5313 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
[930] | 5314 | //$combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
[2] | 5315 | $footer_ext_participantes = lang("Tip: To search in the <b>Global Catalog</b>, type the <b>F9</b> key, like the ExpressoMail."); |
---|
[930] | 5316 | //Caso o minimo de caracteres para a busca nao tenha sido preenchido ele sera por padrao = 3 |
---|
| 5317 | if(!$GLOBALS['phpgw_info']['server']['min_num_characters']){ |
---|
[1122] | 5318 | $GLOBALS['phpgw_info']['server']['min_num_characters'] = 0; |
---|
[930] | 5319 | } |
---|
[703] | 5320 | |
---|
[930] | 5321 | if ($GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '3'){ |
---|
[5132] | 5322 | $context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$context); |
---|
| 5323 | $context = utf8_decode($context); |
---|
[930] | 5324 | $combo_org = '<option value='.$context.'>'.strtoupper($context).'</option>'; |
---|
| 5325 | }else{ |
---|
| 5326 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
[5132] | 5327 | $combo_org = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_org); |
---|
| 5328 | $combo_org = utf8_decode($combo_org); |
---|
[930] | 5329 | } |
---|
| 5330 | |
---|
[928] | 5331 | if ($param['plain'] != "True"){ |
---|
[703] | 5332 | |
---|
| 5333 | // Begin load array lang |
---|
| 5334 | ob_start(); |
---|
[928] | 5335 | //@include($module_name.'/inc/load_lang.php'); |
---|
[703] | 5336 | $load_lang_vars = ob_get_contents(); |
---|
| 5337 | ob_end_clean(); |
---|
| 5338 | // End load array_lang |
---|
[928] | 5339 | } |
---|
[703] | 5340 | |
---|
[2] | 5341 | $var['participants'] = array |
---|
| 5342 | ( |
---|
[1447] | 5343 | 'field' => ' |
---|
[5132] | 5344 | <script src="calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'> |
---|
[1849] | 5345 | <iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe> |
---|
[5132] | 5346 | </div> |
---|
[1593] | 5347 | '.lang('Participants'), |
---|
[5132] | 5348 | 'data' => |
---|
| 5349 | '<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . |
---|
[2] | 5350 | '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . |
---|
| 5351 | '<input type="hidden" id="txt_users" value="'.lang("Users").'">' . |
---|
| 5352 | '<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' . |
---|
[5132] | 5353 | '<input type="hidden" id="txt_shared_accounts" value="'.lang("shared accounts").'">' . |
---|
| 5354 | '<input type="hidden" id="txt_min_search" value="'.lang("Your search argument must be longer than 4 characters.").'">' . |
---|
| 5355 | '<input type="hidden" id="txt_none_result" value="'.lang("None result was found.").'">' . |
---|
| 5356 | '<input type="hidden" id="txt_Select_a_name" value="'.lang("Select a name").'">' . |
---|
| 5357 | '<input type="hidden" id="txt_Close" value="'.lang("Close").'">' . |
---|
| 5358 | '<input type="hidden" id="txt_More_than_%1_results._Please,_try_to_refine_your_search" value="'.lang("More than %1 results. Please, try to refine your search",'%1').'">' . |
---|
| 5359 | '<input type="hidden" id="txt_The_results_were_found_in_the_Global_Catalog" value="'.lang("The results were found in the Global Catalog").'">' . |
---|
[2] | 5360 | '<table width="100%" border="0">'. |
---|
| 5361 | '<tr>'. |
---|
[5132] | 5362 | '<td width="25%"><br>'. |
---|
| 5363 | '<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>'. |
---|
| 5364 | ' <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] | 5365 | '<br><br> <b>'.lang("Event's participants").'</b><br>'. |
---|
| 5366 | ' <select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'. |
---|
| 5367 | '</td>'. |
---|
| 5368 | '<td width="30px" valign="middle" align="center"> '. |
---|
| 5369 | '</td>'. |
---|
| 5370 | '<td valign="bottom">'. |
---|
[928] | 5371 | ' '.lang("Organization").': '. |
---|
[5132] | 5372 | ' <select name="org_context" id="combo_org">'.$combo_org.'</select>'. |
---|
[2] | 5373 | ' <br>'. |
---|
| 5374 | ' <font color="red"><span id="cal_span_searching"> </span></font>'. |
---|
| 5375 | ' <br>'.lang("Search for").':'. |
---|
[5132] | 5376 | ' <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeypress="return optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\', event);"><br>'. |
---|
[638] | 5377 | ' <b>'.lang("Available users and groups").'</b><br>'. |
---|
[2] | 5378 | ' <select id="user_list_in" style="width: 300px" multiple size="13"></select>'. |
---|
[1639] | 5379 | '</td>'. |
---|
| 5380 | '</tr>'. |
---|
[5132] | 5381 | '<tr>' . |
---|
| 5382 | '<td>' . |
---|
| 5383 | '<button onclick="javascript:show_disponibility();" id="time_map" type="button">Mapa de disponibilidade</button><br>' . |
---|
| 5384 | '<b>'.lang("Can have users and groups that doesn't appears on the map").'</b><br>' . |
---|
| 5385 | '<td>' . |
---|
| 5386 | '</tr>' . |
---|
[928] | 5387 | '</table>'. |
---|
[2] | 5388 | '<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'. |
---|
| 5389 | '<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'. |
---|
[5132] | 5390 | "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/finder.js' type='text/javascript'></script>" . |
---|
| 5391 | "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/edit_exmail.js' type='text/javascript'></script>" . |
---|
[638] | 5392 | $load_lang_vars. |
---|
[2] | 5393 | "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". |
---|
| 5394 | "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". |
---|
| 5395 | "<script type='text/javascript'>" . |
---|
[1639] | 5396 | "var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\',\'".$GLOBALS['phpgw_info']['server']['auto_search']."\')',1000);". |
---|
[2] | 5397 | "</script> " |
---|
| 5398 | ); |
---|
| 5399 | } |
---|
| 5400 | } |
---|
| 5401 | |
---|
[5132] | 5402 | $var['participants']['data'] .= '<a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . |
---|
[2] | 5403 | " 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] | 5404 | '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] | 5405 | '<tr>'. |
---|
| 5406 | '<td>'. |
---|
[923] | 5407 | ' <b>'.lang("external participants").'</b> <img align="top" src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif">' . |
---|
[2] | 5408 | ' <a title="'.lang("Close").'" name="b_ext_participants" onClick="javascript:hideExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants">['.lang("Close").']</a> '. |
---|
| 5409 | '</td>'. |
---|
| 5410 | '</tr>'. |
---|
| 5411 | '<tr>'. |
---|
| 5412 | '<td>'. |
---|
| 5413 | ' >> '.lang("It types below the email addresses, if you want to invite other people out of this system").':'. |
---|
[5132] | 5414 | ' <br> <input type="hidden" name="h_exParticipants" id="h_exParticipants" value="'.$exParticipants->getParticipantsSerializable().'" /> |
---|
| 5415 | <textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br> '. |
---|
| 5416 | $footer_ext_participantes. |
---|
[2] | 5417 | '</tr>'. |
---|
| 5418 | '</table>'; |
---|
| 5419 | break; |
---|
| 5420 | |
---|
| 5421 | } |
---|
| 5422 | if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id']) |
---|
| 5423 | { |
---|
| 5424 | $checked = ' checked'; |
---|
| 5425 | } |
---|
| 5426 | else |
---|
| 5427 | { |
---|
| 5428 | $checked = ''; |
---|
| 5429 | } |
---|
| 5430 | $var['owner'] = Array( |
---|
| 5431 | 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), |
---|
[927] | 5432 | 'data' => '<input type="checkbox" id="usuarioParticipa" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>' |
---|
[2] | 5433 | ); |
---|
| 5434 | } |
---|
| 5435 | |
---|
[5132] | 5436 | // Reminder |
---|
[2] | 5437 | // The user must use "Alarm Management" to change/modify an alarm |
---|
| 5438 | // so only display the email reminder fields if this is a new event |
---|
| 5439 | // i.e. not editing an existing event |
---|
| 5440 | |
---|
| 5441 | if ($event['id'] == 0) { |
---|
| 5442 | // get defaults |
---|
| 5443 | $days = $this->bo->prefs['calendar']['default_email_days']; |
---|
| 5444 | $hours = $this->bo->prefs['calendar']['default_email_hours']; |
---|
| 5445 | $min = $this->bo->prefs['calendar']['default_email_min']; |
---|
| 5446 | if (count($event['alarm']) > 1) |
---|
| 5447 | { |
---|
| 5448 | // this should not happen because when creating a new event |
---|
| 5449 | // only 1 alarm is displayed on the screen |
---|
| 5450 | // if the user wants more than 1 alarm they should |
---|
| 5451 | // use "Alarm Management" |
---|
| 5452 | echo '<!-- how did this happen, too many alarms -->'."\n"; |
---|
| 5453 | } |
---|
| 5454 | // if there was an error pick up what the user entered |
---|
| 5455 | if (@isset($event['alarm'])) |
---|
| 5456 | { |
---|
| 5457 | @reset($event['alarm']); |
---|
| 5458 | // just get the first one see above!!! |
---|
| 5459 | list($key,$alarm) = @each($event['alarm']); |
---|
[1122] | 5460 | |
---|
| 5461 | |
---|
| 5462 | //if abaixo trata o caso de um evento repetido nao ter uma data final; |
---|
| 5463 | //se isto acontecer, nao havera alarmes definidos; |
---|
| 5464 | //$alarm['time'] recebe $start para $days, $hours e $min ficarem iguais a 0 |
---|
| 5465 | if(!$alarm['time']) { |
---|
| 5466 | $alarm['time'] = $start; |
---|
| 5467 | } |
---|
| 5468 | |
---|
[2] | 5469 | $diff = $start - $alarm['time']; |
---|
| 5470 | $days = (int)($diff / (24*3600)); |
---|
| 5471 | $hours = (int)(($diff - ($days * 24 * 3600))/3600); |
---|
| 5472 | $min = (int)(($diff - ($days * 24 * 3600) - ($hours * 3600))/60); |
---|
[1122] | 5473 | |
---|
| 5474 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') { |
---|
| 5475 | $days = $diff; |
---|
| 5476 | } |
---|
[2] | 5477 | } |
---|
| 5478 | |
---|
| 5479 | // days |
---|
| 5480 | $dout = '<select name="cal[alarmdays]">'."\n"; |
---|
| 5481 | for($i=0;$i<32;$i++) |
---|
| 5482 | { |
---|
| 5483 | $dout .= '<option value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 5484 | } |
---|
| 5485 | $dout .= '</select>'."\n".' '.lang('days').' '; |
---|
| 5486 | // hours |
---|
| 5487 | $hout = '<select name="cal[alarmhours]">'."\n"; |
---|
| 5488 | for($i=0;$i<25;$i++) |
---|
| 5489 | { |
---|
| 5490 | $hout .= '<option value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 5491 | } |
---|
| 5492 | $hout .= '</select>'."\n".' '.lang('hours').' '; |
---|
| 5493 | // minutes |
---|
| 5494 | $mout = '<select name="cal[alarmminutes]">'."\n"; |
---|
| 5495 | for($i=0;$i<61;$i++) |
---|
| 5496 | { |
---|
| 5497 | $mout .= '<option value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 5498 | } |
---|
| 5499 | $mout .= '</select>'."\n".' '.lang('minutes').' '; |
---|
| 5500 | |
---|
| 5501 | $var['alarm'] = Array( |
---|
| 5502 | 'field' => lang('Alarm'), |
---|
| 5503 | 'data' => $dout.$hout.$mout.lang('before the event') |
---|
| 5504 | ); |
---|
| 5505 | |
---|
| 5506 | } |
---|
| 5507 | |
---|
| 5508 | // Repeat Type |
---|
| 5509 | $str = ''; |
---|
| 5510 | foreach($this->bo->rpt_type as $type => $label) |
---|
| 5511 | { |
---|
| 5512 | $str .= '<option value="'.$type.'"'.($event['recur_type']==$type?' selected':'').'>'.lang($label).'</option>'; |
---|
| 5513 | } |
---|
| 5514 | $var['recure_type'] = Array( |
---|
| 5515 | 'field' => lang('Repeat Type'), |
---|
| 5516 | 'data' => '<select name="cal[recur_type]">'."\n".$str.'</select>'."\n" |
---|
| 5517 | ); |
---|
| 5518 | |
---|
| 5519 | if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) |
---|
| 5520 | { |
---|
| 5521 | $checked = ' checked'; |
---|
| 5522 | $recur_end = $this->bo->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 5523 | } |
---|
| 5524 | else |
---|
| 5525 | { |
---|
| 5526 | $checked = ''; |
---|
| 5527 | $recur_end = $this->bo->maketime($event['start']) + 86400 - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 5528 | } |
---|
| 5529 | |
---|
| 5530 | $var['recure_enddate'] = Array( |
---|
| 5531 | 'field' => lang('Repeat End Date'), |
---|
| 5532 | 'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '. |
---|
| 5533 | /* |
---|
| 5534 | $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 5535 | $sb->getYears('recur_enddate[year]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'Y')), |
---|
| 5536 | $sb->getMonthText('recur_enddate[month]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'n')), |
---|
| 5537 | $sb->getDays('recur_enddate[mday]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'d')) |
---|
| 5538 | ) |
---|
| 5539 | */ |
---|
| 5540 | $jscal->input('recur_enddate[str]',$recur_end) |
---|
| 5541 | ); |
---|
| 5542 | |
---|
| 5543 | $i = 0; $boxes = ''; |
---|
| 5544 | foreach ($this->bo->rpt_day as $mask => $name) |
---|
| 5545 | { |
---|
| 5546 | $boxes .= '<input type="checkbox" name="cal[rpt_day][]" value="'.$mask.'"'.($event['recur_data'] & $mask ? ' checked' : '').'> '.lang($name)."\n"; |
---|
| 5547 | if (++$i == 5) $boxes .= '<br>'; |
---|
| 5548 | } |
---|
| 5549 | $var['recure_day'] = Array( |
---|
[1122] | 5550 | 'field' => lang('Repeat Day').'<br>'.lang('(required for weekly recursivity)'), |
---|
[2] | 5551 | 'data' => $boxes |
---|
| 5552 | ); |
---|
| 5553 | |
---|
| 5554 | $var['recure_interval'] = Array( |
---|
| 5555 | 'field' => lang('Interval'), |
---|
| 5556 | 'data' => '<input name="cal[recur_interval]" size="4" maxlength="4" value="'.$event['recur_interval'].'">' |
---|
| 5557 | ); |
---|
[583] | 5558 | // $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); |
---|
[2] | 5559 | |
---|
| 5560 | if (!isset($this->fields)) |
---|
| 5561 | { |
---|
| 5562 | $this->custom_fields = CreateObject('calendar.bocustom_fields'); |
---|
| 5563 | $this->fields = &$this->custom_fields->fields; |
---|
| 5564 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
| 5565 | } |
---|
[583] | 5566 | $this->output_template_array($p,'row','list',$var['access']); |
---|
| 5567 | unset($var['access']); |
---|
| 5568 | |
---|
[2] | 5569 | $preserved = False; |
---|
| 5570 | foreach($this->fields as $field => $data) |
---|
| 5571 | { |
---|
| 5572 | if (!$data['disabled']) |
---|
| 5573 | { |
---|
| 5574 | if (isset($var[$field])) |
---|
| 5575 | { |
---|
| 5576 | switch($field) |
---|
| 5577 | { |
---|
| 5578 | case 'startdate': |
---|
| 5579 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
| 5580 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
| 5581 | break; |
---|
| 5582 | case 'enddate': |
---|
| 5583 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
| 5584 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
| 5585 | break; |
---|
| 5586 | case 'recure_type': |
---|
| 5587 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
[1626] | 5588 | $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>'); |
---|
[2] | 5589 | $p->parse('row','hr',True); |
---|
| 5590 | $this->output_template_array($p,'row','list',$var['recure_type']); |
---|
| 5591 | $this->output_template_array($p,'row','list',$var['recure_enddate']); |
---|
| 5592 | $this->output_template_array($p,'row','list',$var['recure_day']); |
---|
| 5593 | $this->output_template_array($p,'row','list',$var['recure_interval']); |
---|
| 5594 | break; |
---|
| 5595 | default: |
---|
| 5596 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
| 5597 | } |
---|
| 5598 | } |
---|
| 5599 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
| 5600 | { |
---|
| 5601 | $lang = lang($name = substr($field,1)); |
---|
| 5602 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
| 5603 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
| 5604 | $v = array( |
---|
| 5605 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
| 5606 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
| 5607 | ); |
---|
| 5608 | if ($data['title']) |
---|
| 5609 | { |
---|
| 5610 | $v['tr_color'] = $this->theme['th_bg']; |
---|
| 5611 | } |
---|
| 5612 | if (!$data['length'] && $data['title']) |
---|
| 5613 | { |
---|
| 5614 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
| 5615 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
| 5616 | $p->parse('row','hr',True); |
---|
| 5617 | } |
---|
| 5618 | else |
---|
| 5619 | { |
---|
| 5620 | $this->output_template_array($p,'row','list',$v); |
---|
| 5621 | } |
---|
| 5622 | } |
---|
| 5623 | } |
---|
| 5624 | else // preserve disabled fields |
---|
| 5625 | { |
---|
| 5626 | switch ($field) |
---|
| 5627 | { |
---|
| 5628 | case 'owner': |
---|
| 5629 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
| 5630 | break; |
---|
| 5631 | case 'recure_type': |
---|
| 5632 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
| 5633 | { |
---|
| 5634 | $preserved[$field] = $event[$field]; |
---|
| 5635 | } |
---|
| 5636 | break; |
---|
| 5637 | case 'startdate': |
---|
| 5638 | case 'enddate': |
---|
| 5639 | $field = substr($field,0,-4); |
---|
| 5640 | default: |
---|
| 5641 | $preserved[$field] = $event[$field]; |
---|
| 5642 | } |
---|
| 5643 | } |
---|
| 5644 | } |
---|
| 5645 | unset($var); |
---|
| 5646 | if (is_array($preserved)) |
---|
| 5647 | { |
---|
| 5648 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
| 5649 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
| 5650 | } |
---|
| 5651 | $p->set_var('submit_button',lang('Save')); |
---|
| 5652 | |
---|
| 5653 | $delete_button = $cancel_button = ''; |
---|
| 5654 | if ($event['id'] > 0) |
---|
| 5655 | { |
---|
| 5656 | $var = Array( |
---|
| 5657 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
| 5658 | 'action_text_button' => lang('Delete'), |
---|
[204] | 5659 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
[663] | 5660 | 'action_extra_field' => '', |
---|
| 5661 | 'button_id' => 'delete_button' |
---|
[2] | 5662 | ); |
---|
| 5663 | $p->set_var($var); |
---|
| 5664 | $delete_button = $p->fp('out','form_button'); |
---|
| 5665 | } |
---|
| 5666 | $p->set_var('delete_button',$delete_button); |
---|
[602] | 5667 | $p->set_var('alert_msg',lang('Required field (category) is empty')); |
---|
[2] | 5668 | |
---|
| 5669 | if ($this->bo->return_to) |
---|
| 5670 | { |
---|
| 5671 | $var = Array( |
---|
| 5672 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 5673 | 'action_text_button' => lang('Cancel'), |
---|
| 5674 | 'action_confirm_button' => '', |
---|
[663] | 5675 | 'action_extra_field' => '', |
---|
| 5676 | 'button_id' => 'cancel_button' |
---|
[2] | 5677 | ); |
---|
| 5678 | $p->set_var($var); |
---|
| 5679 | $cancel_button = $p->fp('out','form_button'); |
---|
| 5680 | } |
---|
| 5681 | $p->set_var('cancel_button',$cancel_button); |
---|
| 5682 | $p->pparse('out','edit_entry'); |
---|
| 5683 | } |
---|
| 5684 | |
---|
| 5685 | // modify list of an event's external participants (i.e. non pgpgw users) |
---|
| 5686 | // |
---|
| 5687 | function modify_ext_partlist() |
---|
| 5688 | { |
---|
| 5689 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
| 5690 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
| 5691 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 5692 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 5693 | |
---|
| 5694 | $total_contacts = 0; |
---|
| 5695 | $participant = array(); |
---|
| 5696 | $control_data= array(); |
---|
| 5697 | |
---|
| 5698 | $control_data['action'] = ''; |
---|
| 5699 | $control_data['delete'] = array(); |
---|
| 5700 | $control_data['part'] = array(); |
---|
| 5701 | |
---|
| 5702 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 5703 | $p->set_file( |
---|
| 5704 | Array( |
---|
| 5705 | 'T_edit_partlist' => 'edit_partlist.tpl', |
---|
| 5706 | 'T_edit_partlist_blocks' => 'edit_partlist_blocks.tpl' |
---|
| 5707 | ) |
---|
| 5708 | ); |
---|
| 5709 | |
---|
| 5710 | $p->set_block('T_edit_partlist_blocks','B_alert_msg','V_alert_msg'); |
---|
| 5711 | $p->set_block('T_edit_partlist_blocks','B_partlist','V_partlist'); |
---|
| 5712 | $p->set_block('T_edit_partlist_blocks','B_participants_none','V_participants_none'); |
---|
| 5713 | $p->set_block('T_edit_partlist_blocks','B_delete_btn','V_delete_btn'); |
---|
| 5714 | |
---|
| 5715 | global $query_addr; |
---|
| 5716 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 5717 | $addy = $sb->getAddress('addr','',$query_addr); |
---|
| 5718 | |
---|
| 5719 | $add_ext = $addy['doSearchFkt']; |
---|
| 5720 | $add_ext .= $addy['addr_title']!=lang('Address Book')?$addy['addr_title']:''; |
---|
| 5721 | $add_ext .= " ".$addy['addr'].$addy['addr_nojs']; |
---|
| 5722 | |
---|
| 5723 | $p->set_var('text_add_name',$add_ext); |
---|
| 5724 | |
---|
| 5725 | if(isset($_GET['part']) && $_GET['part']) |
---|
| 5726 | { |
---|
| 5727 | $control_data['part'] = split(",", $_GET['part']); |
---|
| 5728 | } |
---|
| 5729 | else |
---|
| 5730 | { |
---|
| 5731 | $control_data['part'] = $_POST['participant']; |
---|
| 5732 | $control_data['action'] = $_POST['action']; |
---|
| 5733 | $control_data['delete'] = $_POST['delete']; |
---|
| 5734 | } |
---|
| 5735 | |
---|
| 5736 | for ($i=0; $i<count($control_data['part']); $i++) |
---|
| 5737 | { |
---|
| 5738 | $id = $control_data['part'][$i]; |
---|
| 5739 | list($contact) = $this->read_contact($id); |
---|
| 5740 | |
---|
| 5741 | $participant[$id] = array(); |
---|
| 5742 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
| 5743 | } |
---|
| 5744 | |
---|
| 5745 | if ($control_data['action'] == lang('Delete selected contacts')) |
---|
| 5746 | { |
---|
| 5747 | for ($i=0; $i<count($control_data['delete']); $i++) |
---|
| 5748 | { |
---|
| 5749 | $id = $control_data['delete'][$i]; |
---|
| 5750 | unset($participant[$id]); |
---|
| 5751 | } |
---|
| 5752 | } |
---|
| 5753 | |
---|
| 5754 | if ($control_data['action'] == lang('Add Contact')) |
---|
| 5755 | { |
---|
| 5756 | $id = $_POST['id_addr']; |
---|
| 5757 | if (isset($id) && (int)$id != 0) |
---|
| 5758 | { |
---|
| 5759 | list($contact) = $this->read_contact($id); |
---|
| 5760 | $participant[$id] = array(); |
---|
| 5761 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
| 5762 | } |
---|
| 5763 | } |
---|
| 5764 | |
---|
| 5765 | // create list of currently selected contacts |
---|
| 5766 | // |
---|
| 5767 | while(list($id,$contact) = each($participant)) |
---|
| 5768 | { |
---|
| 5769 | $p->set_var('hidden_delete_name','participant[]'); |
---|
| 5770 | $p->set_var('hidden_delete_value',$id); |
---|
| 5771 | $p->set_var('ckbox_delete_name','delete[]'); |
---|
| 5772 | $p->set_var('ckbox_delete_value',$id); |
---|
| 5773 | $p->set_var('ckbox_delete_participant',$contact['name']); |
---|
| 5774 | $p->parse('V_partlist','B_partlist',True); |
---|
| 5775 | $total_contacts++; |
---|
| 5776 | } |
---|
| 5777 | |
---|
| 5778 | if ($total_contacts == 0) |
---|
| 5779 | { |
---|
| 5780 | // no contacts have been selected |
---|
| 5781 | // => clear the delete form, remove delete button and show the none block |
---|
| 5782 | // |
---|
| 5783 | $p->set_var('V_partlist',''); |
---|
| 5784 | $p->set_var('V_delete_btn',''); |
---|
| 5785 | $p->set_var('text_none',lang('None')); |
---|
| 5786 | $p->parse('V_participants_none','B_participants_none'); |
---|
| 5787 | } |
---|
| 5788 | else |
---|
| 5789 | { |
---|
| 5790 | // at least one contact has been selected |
---|
| 5791 | // => clear the none block, fill the delete form and add delete button |
---|
| 5792 | // |
---|
| 5793 | $p->set_var('V_participants_none',''); |
---|
| 5794 | $p->set_var('btn_delete_name','action'); |
---|
| 5795 | $p->set_var('btn_delete_value',lang('Delete selected contacts')); |
---|
| 5796 | $p->parse('V_delete_btn','B_delete_btn'); |
---|
| 5797 | } |
---|
| 5798 | |
---|
| 5799 | $body_tags = 'bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_color'] |
---|
| 5800 | . '" alink="'.$GLOBALS['phpgw_info']['theme']['alink'] |
---|
| 5801 | . '" link="'.$GLOBALS['phpgw_info']['theme']['link'] |
---|
| 5802 | .'" vlink="'.$GLOBALS['phpgw_info']['theme']['vlink'].'"'; |
---|
| 5803 | |
---|
| 5804 | $form_action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'calendar.uicalendar.modify')); |
---|
| 5805 | |
---|
| 5806 | $charset = lang('charset'); |
---|
| 5807 | $p->set_var('charset',$charset); |
---|
| 5808 | $p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp'] |
---|
| 5809 | . ' - ' .lang('External Participants')); |
---|
| 5810 | $p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']); |
---|
| 5811 | $p->set_var('body_tags',$body_tags); |
---|
| 5812 | $p->set_var('form_method','POST'); |
---|
| 5813 | $p->set_var('form_action',$form_action); |
---|
| 5814 | $p->set_var('text_add_contact',lang('External Participants')); |
---|
| 5815 | $p->set_var('text_contacts_selected',lang('Selected contacts (%1)',$total_contacts)); |
---|
| 5816 | $p->set_var('btn_add_name','action'); |
---|
| 5817 | $p->set_var('btn_add_value',lang('Add Contact')); |
---|
| 5818 | $p->set_var('btn_done_name','done'); |
---|
| 5819 | $p->set_var('btn_done_value',lang('Done')); |
---|
| 5820 | $p->set_var('btn_done_js','copyback()'); |
---|
| 5821 | $p->set_var('form1_name','ext_form'); |
---|
| 5822 | |
---|
| 5823 | $p->pfp('out','T_edit_partlist'); |
---|
| 5824 | } |
---|
| 5825 | |
---|
| 5826 | function read_contact($id) |
---|
| 5827 | { |
---|
| 5828 | $query_fields = Array( |
---|
| 5829 | 'n_given' => 'n_given', |
---|
| 5830 | 'n_family' => 'n_family', |
---|
| 5831 | 'email' => 'email', |
---|
| 5832 | 'email_home' => 'email_home' |
---|
| 5833 | ); |
---|
| 5834 | |
---|
| 5835 | /* |
---|
| 5836 | if ($this->rights & PHPGW_ACL_READ) |
---|
| 5837 | { |
---|
| 5838 | return $this->contacts->read_single_entry($id,$fields); |
---|
| 5839 | } |
---|
| 5840 | else |
---|
| 5841 | { |
---|
| 5842 | $rtrn = array(0 => array('No access' => 'No access')); |
---|
| 5843 | return $rtrn; |
---|
| 5844 | } |
---|
| 5845 | */ |
---|
| 5846 | |
---|
| 5847 | $contacts = CreateObject('phpgwapi.contacts', False); |
---|
| 5848 | return $contacts->read_single_entry($id,$query_fields); |
---|
| 5849 | } |
---|
| 5850 | |
---|
| 5851 | function build_part_list(&$users,$accounts,$owner) |
---|
| 5852 | { |
---|
| 5853 | if(!is_array($accounts)) |
---|
| 5854 | { |
---|
| 5855 | return; |
---|
| 5856 | } |
---|
| 5857 | foreach($accounts as $id) |
---|
| 5858 | { |
---|
| 5859 | $id = (int)$id; |
---|
| 5860 | if($id == $owner) |
---|
| 5861 | { |
---|
| 5862 | continue; |
---|
| 5863 | } |
---|
| 5864 | elseif(!isset($users[$id])) |
---|
| 5865 | { |
---|
| 5866 | if($GLOBALS['phpgw']->accounts->exists($id) == True) |
---|
| 5867 | { |
---|
| 5868 | $users[$id] = Array( |
---|
| 5869 | 'name' => $GLOBALS['phpgw']->common->grab_owner_name($id), |
---|
| 5870 | 'type' => $GLOBALS['phpgw']->accounts->get_type($id) |
---|
| 5871 | ); |
---|
| 5872 | } |
---|
| 5873 | if($GLOBALS['phpgw']->accounts->get_type($id) == 'g') |
---|
| 5874 | { |
---|
| 5875 | //$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group'),$owner); |
---|
| 5876 | } |
---|
| 5877 | } |
---|
| 5878 | } |
---|
| 5879 | if (!function_exists('strcmp_name')) |
---|
| 5880 | { |
---|
| 5881 | function strcmp_name($arr1,$arr2) |
---|
| 5882 | { |
---|
| 5883 | if ($diff = strcmp($arr1['type'],$arr2['type'])) |
---|
| 5884 | { |
---|
| 5885 | return $diff; // groups before users |
---|
| 5886 | } |
---|
| 5887 | return strnatcasecmp($arr1['name'],$arr2['name']); |
---|
| 5888 | } |
---|
| 5889 | } |
---|
| 5890 | uasort($users,'strcmp_name'); |
---|
| 5891 | } |
---|
| 5892 | |
---|
| 5893 | function set_week_array($startdate,$cellcolor,$weekly) |
---|
| 5894 | { |
---|
[360] | 5895 | $data = date("m"); |
---|
[2] | 5896 | for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400) |
---|
| 5897 | { |
---|
| 5898 | $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset |
---|
| 5899 | print_debug('set_week_array : Date ',$date); |
---|
| 5900 | |
---|
| 5901 | if($events = $this->bo->cached_events[$date]) |
---|
| 5902 | { |
---|
| 5903 | print_debug('Date',$date); |
---|
| 5904 | print_debug('Appointments Found',count($events)); |
---|
| 5905 | |
---|
| 5906 | if (!$this->bo->prefs['calendar']['show_rejected']) |
---|
| 5907 | { |
---|
| 5908 | $appts = False; |
---|
| 5909 | foreach($events as $event) // check for a not-rejected event |
---|
| 5910 | { |
---|
| 5911 | if (!$this->bo->rejected_no_show($event)) |
---|
| 5912 | { |
---|
| 5913 | $appts = True; |
---|
| 5914 | break; |
---|
| 5915 | } |
---|
| 5916 | } |
---|
| 5917 | } |
---|
| 5918 | else |
---|
| 5919 | { |
---|
| 5920 | $appts = True; |
---|
| 5921 | } |
---|
| 5922 | } |
---|
| 5923 | else |
---|
| 5924 | { |
---|
| 5925 | $appts = False; |
---|
| 5926 | } |
---|
[4001] | 5927 | |
---|
[2] | 5928 | $holidays = $this->bo->cached_holidays[$date]; |
---|
| 5929 | if($weekly) |
---|
| 5930 | { |
---|
| 5931 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 5932 | } |
---|
| 5933 | |
---|
| 5934 | $day_image = ''; |
---|
| 5935 | if($holidays) |
---|
| 5936 | { |
---|
| 5937 | $extra = ' bgcolor="'.$this->bo->holiday_color.'"'; |
---|
| 5938 | $class = ($appts?'b':'').'minicalhol'; |
---|
| 5939 | if ($date == $this->bo->today) |
---|
| 5940 | { |
---|
| 5941 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 5942 | } |
---|
| 5943 | } |
---|
| 5944 | elseif ($date != $this->bo->today) |
---|
| 5945 | { |
---|
| 5946 | $extra = ' bgcolor="'.$cellcolor.'"'; |
---|
| 5947 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 5948 | } |
---|
| 5949 | else |
---|
| 5950 | { |
---|
| 5951 | $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"'; |
---|
| 5952 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 5953 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 5954 | } |
---|
| 5955 | |
---|
| 5956 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 5957 | { |
---|
| 5958 | $extra = ''; |
---|
| 5959 | } |
---|
| 5960 | |
---|
| 5961 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 5962 | { |
---|
| 5963 | $new_event = True; |
---|
| 5964 | } |
---|
| 5965 | else |
---|
| 5966 | { |
---|
| 5967 | $new_event = False; |
---|
| 5968 | } |
---|
| 5969 | $holiday_name = Array(); |
---|
| 5970 | if($holidays) |
---|
| 5971 | { |
---|
| 5972 | for($k=0;$k<count($holidays);$k++) |
---|
| 5973 | { |
---|
| 5974 | $holiday_name[] = $holidays[$k]['name']; |
---|
| 5975 | } |
---|
| 5976 | } |
---|
| 5977 | $week = ''; |
---|
| 5978 | if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) |
---|
| 5979 | { |
---|
| 5980 | $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); |
---|
| 5981 | } |
---|
| 5982 | $daily[$date] = Array( |
---|
| 5983 | 'extra' => $extra, |
---|
| 5984 | 'new_event' => $new_event, |
---|
| 5985 | 'holidays' => $holiday_name, |
---|
| 5986 | 'appts' => $appts, |
---|
| 5987 | 'week' => $week, |
---|
| 5988 | 'day_image' => $day_image, |
---|
| 5989 | 'class' => $class |
---|
| 5990 | ); |
---|
| 5991 | } |
---|
| 5992 | |
---|
| 5993 | if($this->debug) |
---|
| 5994 | { |
---|
| 5995 | _debug_array($daily); |
---|
| 5996 | } |
---|
| 5997 | |
---|
| 5998 | return $daily; |
---|
| 5999 | } |
---|
[36] | 6000 | |
---|
[42] | 6001 | function get_organizations($context, $selected='', $recursive = false) |
---|
[23] | 6002 | { |
---|
[2] | 6003 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
[42] | 6004 | |
---|
| 6005 | return ($recursive ? |
---|
| 6006 | $s->get_organizations($context, $selected, false ,false) : |
---|
| 6007 | $s->get_sectors($selected, false, false)); |
---|
| 6008 | } |
---|
[2] | 6009 | } |
---|
[583] | 6010 | ?> |
---|