[6779] | 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; |
---|
| 29 | //var $debug = True; |
---|
| 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 | 'screen_delegate_event' => True, |
---|
| 60 | 'delegate_event' => True, |
---|
| 61 | 'mini_calendar' => True, |
---|
| 62 | 'index' => True, |
---|
| 63 | 'month' => True, |
---|
| 64 | 'get_month' => True, |
---|
| 65 | 'week' => True, |
---|
| 66 | 'get_week' => True, |
---|
| 67 | 'year' => True, |
---|
| 68 | 'view' => True, |
---|
| 69 | 'edit' => True, |
---|
| 70 | 'export' => True, |
---|
| 71 | 'export_all' => True, |
---|
| 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, |
---|
| 88 | 'accounts_popup' => True, |
---|
| 89 | 'disponibility' => True |
---|
| 90 | ); |
---|
| 91 | |
---|
| 92 | function uicalendar() |
---|
| 93 | { |
---|
| 94 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 95 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
| 96 | |
---|
| 97 | $this->theme = $GLOBALS['phpgw_info']['theme']; |
---|
| 98 | |
---|
| 99 | $this->bo = CreateObject('calendar.bocalendar',1); |
---|
| 100 | $this->cat = &$this->bo->cat; |
---|
| 101 | |
---|
| 102 | print_debug('BO Owner',$this->bo->owner); |
---|
| 103 | |
---|
| 104 | $this->template = $GLOBALS['phpgw']->template; |
---|
| 105 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); |
---|
| 106 | |
---|
| 107 | $this->holiday_color = (substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06']; |
---|
| 108 | |
---|
| 109 | $this->cat_id = $this->bo->cat_id; |
---|
| 110 | |
---|
| 111 | $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 112 | $this->link_tpl->set_unknowns('remove'); |
---|
| 113 | $this->link_tpl->set_file( |
---|
| 114 | Array( |
---|
| 115 | 'link_picture' => 'link_pict.tpl' |
---|
| 116 | ) |
---|
| 117 | ); |
---|
| 118 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
| 119 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
| 120 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
| 121 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
| 122 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
| 123 | |
---|
| 124 | /*************** EVENTO **************************/ |
---|
| 125 | /* Este bloco de codigo foi adicionado pois os eventos de agendamento (exibicao do mes) para impressao serao tratados em outro template |
---|
| 126 | (event_link.tpl) */ |
---|
| 127 | |
---|
| 128 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 129 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 130 | $this->event_tpl->set_unknowns('remove'); |
---|
| 131 | $this->event_tpl->set_file( |
---|
| 132 | Array( |
---|
| 133 | 'link_event' => 'event_link.tpl' |
---|
| 134 | ) |
---|
| 135 | ); |
---|
| 136 | $this->event_tpl->set_block('link_event','link_event_pict','link_event_pict'); |
---|
| 137 | $this->event_tpl->set_block('link_event','event_pict','event_pict'); |
---|
| 138 | $this->event_tpl->set_block('link_event','link_event_open','link_event_open'); |
---|
| 139 | $this->event_tpl->set_block('link_event','link_event_close','link_event_close'); |
---|
| 140 | $this->event_tpl->set_block('link_event','link_event_text','link_event_text'); |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | /*************************************************/ |
---|
| 144 | |
---|
| 145 | if($this->bo->use_session) |
---|
| 146 | { |
---|
| 147 | // save return-fkt for add, view, ... |
---|
| 148 | list(,,$fkt) = explode('.',$_GET['menuaction']); |
---|
| 149 | if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner') |
---|
| 150 | { |
---|
| 151 | $this->bo->return_to = $_GET['menuaction']. |
---|
| 152 | sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day); |
---|
| 153 | } |
---|
| 154 | $this->bo->save_sessiondata(); |
---|
| 155 | } |
---|
| 156 | $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; |
---|
| 157 | |
---|
| 158 | print_debug('UI',$this->_debug_sqsof()); |
---|
| 159 | |
---|
| 160 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
| 161 | { |
---|
| 162 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
| 163 | } |
---|
| 164 | $this->html = &$GLOBALS['phpgw']->html; |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | function screen_delegate_event($params=NULL) { |
---|
| 168 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
| 169 | |
---|
| 170 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 171 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
| 172 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 173 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 174 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 175 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 176 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Calendar - Edit') : lang('Calendar - Delegate Event'); |
---|
| 177 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 178 | |
---|
| 179 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 180 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 181 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
| 182 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 183 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 184 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 185 | $user_context = array(); |
---|
| 186 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
| 187 | if($i) |
---|
| 188 | $user_context[] = $dn_part; |
---|
| 189 | } |
---|
| 190 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
| 191 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
| 192 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
| 193 | // Fim |
---|
| 194 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
| 195 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
| 196 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
| 197 | |
---|
| 198 | $var = array( |
---|
| 199 | "module_name" => $module_name, |
---|
| 200 | "lang_loading" => lang("Loading"), |
---|
| 201 | "lang_searching" => lang("Searching"), |
---|
| 202 | "lang_users" => lang("Users"), |
---|
| 203 | "lang_groups" => lang("Groups"), |
---|
| 204 | "recursive" => ($recursive)?"":"search", |
---|
| 205 | "options" => $combo_org, |
---|
| 206 | "id_event" => $_REQUEST["id_event"], |
---|
| 207 | "eventArray" => $_REQUEST["eventArray"], |
---|
| 208 | "delegator" => $_REQUEST["delegator"], |
---|
| 209 | "lang_avaliable_users" => lang("Available Users and Groups"), |
---|
| 210 | "lang_search_for" => lang("Search for"), |
---|
| 211 | "lang_ou" => lang("Organization"), |
---|
| 212 | "min_num_characters" => $GLOBALS['phpgw_info']['server']['min_num_characters'], |
---|
| 213 | "date" => $_REQUEST["date"], |
---|
| 214 | "eventDelegation" => 1, |
---|
| 215 | "Delegate" => lang("Delegate"), |
---|
| 216 | 'url_template' => 'calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'] |
---|
| 217 | ); |
---|
| 218 | |
---|
| 219 | if(isset($_REQUEST["error"])) |
---|
| 220 | { |
---|
| 221 | if($_REQUEST["error"] == 999){ |
---|
| 222 | $var['error_msg'] = lang("Problems delegating. Make sure you have selected a user to delegate the appointment."); |
---|
| 223 | }else { |
---|
| 224 | $var['error_msg'] = lang("Problems delegating. Make sure you haven't delegated to a person that was also invited to the meeting"); |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | $template = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 229 | $template->set_file( |
---|
| 230 | array( |
---|
| 231 | "screen"=>"delegate.tpl" |
---|
| 232 | ) |
---|
| 233 | ); |
---|
| 234 | $template->set_var($var); |
---|
| 235 | print $template->fp('out','screen'); |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | function delegate_event($params=NULL) { |
---|
| 240 | //$ldap = CreateObject('expressoMail1_2.ldap_functions'); |
---|
| 241 | //$delegated = $ldap->uid2uidnumber($_REQUEST['delegated']); |
---|
| 242 | |
---|
| 243 | try { |
---|
| 244 | $this->bo->delegar($_REQUEST['delegator'],$_REQUEST['delegated']/*$delegated*/,$_REQUEST['event']); |
---|
| 245 | header("Location: index.php?menuaction=calendar.uicalendar.day&date=".$_REQUEST['date']); |
---|
| 246 | }catch(Exception $e) { |
---|
| 247 | if($e->getMessage() == '999') { |
---|
| 248 | header("Location: index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=". $_REQUEST["event"]."&delegator=".$_REQUEST["delegator"]."&date=".$_REQUEST["date"]."&error=999"); |
---|
| 249 | }else { |
---|
| 250 | header("Location: index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=". $_REQUEST["event"]."&delegator=".$_REQUEST["delegator"]."&date=".$_REQUEST["date"]."&error=1"); |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | /* Public functions */ |
---|
| 256 | |
---|
| 257 | function mini_calendar($params) |
---|
| 258 | { |
---|
| 259 | static $mini_cal_tpl; |
---|
| 260 | if(!is_array($params)) |
---|
| 261 | { |
---|
| 262 | return; |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | if($params['month'] == 0) |
---|
| 266 | { |
---|
| 267 | $params['month'] = 12; |
---|
| 268 | $params['year'] = $params['year'] - 1; |
---|
| 269 | } |
---|
| 270 | elseif($params['month'] == 13) |
---|
| 271 | { |
---|
| 272 | $params['month'] = 1; |
---|
| 273 | $params['year'] = $params['year'] + 1; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | $this->bo->store_to_cache( |
---|
| 277 | Array( |
---|
| 278 | 'smonth' => $params['month'], |
---|
| 279 | 'sday' => 1, |
---|
| 280 | 'syear' => $params['year'] |
---|
| 281 | ) |
---|
| 282 | ); |
---|
| 283 | |
---|
| 284 | $params['link'] = (!isset($params['link'])?'':$params['link']); |
---|
| 285 | $params['buttons'] = (!isset($params['buttons'])?'none':$params['buttons']); |
---|
| 286 | $params['outside_month'] = (!isset($params['outside_month'])?True:$params['outside_month']); |
---|
| 287 | |
---|
| 288 | $this->bo->read_holidays($params['year']); |
---|
| 289 | |
---|
| 290 | $date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); |
---|
| 291 | $month_ago = (int)(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); |
---|
| 292 | $month_ahead = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year']))); |
---|
| 293 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year']))); |
---|
| 294 | $monthend = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year']))); |
---|
| 295 | |
---|
| 296 | $weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1); |
---|
| 297 | |
---|
| 298 | print_debug('mini_calendar:monthstart',$monthstart); |
---|
| 299 | print_debug('mini_calendar:weekstarttime',date('Ymd H:i:s',$weekstarttime)); |
---|
| 300 | |
---|
| 301 | if(!is_object($mini_cal_tpl)) |
---|
| 302 | { |
---|
| 303 | $mini_cal_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 304 | $mini_cal_tpl->set_unknowns('remove'); |
---|
| 305 | $mini_cal_tpl->set_file( |
---|
| 306 | Array( |
---|
| 307 | 'mini_calendar' => 'mini_cal.tpl' |
---|
| 308 | ) |
---|
| 309 | ); |
---|
| 310 | $mini_cal_tpl->set_block('mini_calendar','mini_cal','mini_cal'); |
---|
| 311 | $mini_cal_tpl->set_block('mini_calendar','mini_week','mini_week'); |
---|
| 312 | $mini_cal_tpl->set_block('mini_calendar','mini_day','mini_day'); |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | if($this->bo->printer_friendly == False) |
---|
| 317 | { |
---|
| 318 | //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>'; |
---|
| 319 | $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>'; |
---|
| 320 | } |
---|
| 321 | else |
---|
| 322 | { |
---|
| 323 | $month = lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y'); |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | $var = Array( |
---|
| 327 | 'cal_img_root' => $GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'), |
---|
| 328 | 'bgcolor' => $this->theme['bg_color'], |
---|
| 329 | 'bgcolor1' => $this->theme['bg_color'], |
---|
| 330 | 'month' => $month, |
---|
| 331 | 'bgcolor2' => $this->theme['cal_dayview'], |
---|
| 332 | 'holiday_color' => $this->holiday_color |
---|
| 333 | ); |
---|
| 334 | |
---|
| 335 | $mini_cal_tpl->set_var($var); |
---|
| 336 | |
---|
| 337 | switch(strtolower($params['buttons'])) |
---|
| 338 | { |
---|
| 339 | case 'right': |
---|
| 340 | $var = Array( |
---|
| 341 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
| 342 | ); |
---|
| 343 | break; |
---|
| 344 | case 'left': |
---|
| 345 | $var = Array( |
---|
| 346 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>' |
---|
| 347 | ); |
---|
| 348 | break; |
---|
| 349 | case 'both': |
---|
| 350 | $var = Array( |
---|
| 351 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>', |
---|
| 352 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
| 353 | ); |
---|
| 354 | break; |
---|
| 355 | case 'none': |
---|
| 356 | default: |
---|
| 357 | $var = Array( |
---|
| 358 | 'prevmonth' => '', |
---|
| 359 | 'nextmonth' => '' |
---|
| 360 | ); |
---|
| 361 | break; |
---|
| 362 | } |
---|
| 363 | $mini_cal_tpl->set_var($var); |
---|
| 364 | |
---|
| 365 | if(!$mini_cal_tpl->get_var('daynames')) |
---|
| 366 | { |
---|
| 367 | for($i=0;$i<7;$i++) |
---|
| 368 | { |
---|
| 369 | $var = Array( |
---|
| 370 | 'dayname' => '<b>' . lang($GLOBALS['phpgw']->datetime->days_short[$i]) . '</b>', |
---|
| 371 | 'day_image' => '' |
---|
| 372 | ); |
---|
| 373 | $this->output_template_array($mini_cal_tpl,'daynames','mini_day',$var); |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 377 | unset($date); |
---|
| 378 | for($i=$weekstarttime + $GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 * 3600 * 7)) |
---|
| 379 | { |
---|
| 380 | unset($var); |
---|
| 381 | $daily = $this->set_week_array($i - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 382 | foreach($daily as $date => $day_params) |
---|
| 383 | { |
---|
| 384 | print_debug('Mini-Cal Date',$date); |
---|
| 385 | $year = (int)(substr($date,0,4)); |
---|
| 386 | $month = (int)(substr($date,4,2)); |
---|
| 387 | $day = (int)(substr($date,6,2)); |
---|
| 388 | $str = ''; |
---|
| 389 | if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True) |
---|
| 390 | { |
---|
| 391 | if(!$this->bo->printer_friendly && $params['link']) |
---|
| 392 | { |
---|
| 393 | //NDEE: class def what for? |
---|
| 394 | $dayToday = (int)(substr($today,6,2)); |
---|
| 395 | $seleDay = (int)(substr($_GET['date'],6,2)); |
---|
| 396 | if($day == $dayToday) |
---|
| 397 | { |
---|
| 398 | if($dayToday == $seleDay) |
---|
| 399 | { |
---|
| 400 | $day_params['class'] = 'minicaltodaysel'; |
---|
| 401 | } |
---|
| 402 | else |
---|
| 403 | { |
---|
| 404 | $day_params['class'] = 'minicaltoday'; |
---|
| 405 | } |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | if( isset($params['control']) && $params['control'] ) |
---|
| 409 | { |
---|
| 410 | if($day == $seleDay && $dayToday != $seleDay) |
---|
| 411 | { |
---|
| 412 | $day_params['class'] = 'minicalnottoday'; |
---|
| 413 | } |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'" ' . ($day_params['class']=='bminicalhol' || $day_params['class']=='minicalhol'?' title="' . $day_params['holidays'][0] . '" ' :'') . ' >'.$day.'</a>'; |
---|
| 417 | } |
---|
| 418 | else |
---|
| 419 | { |
---|
| 420 | |
---|
| 421 | //NDEE: printer-friendly (mini-calendar) |
---|
| 422 | $str = $day; |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | } |
---|
| 426 | else |
---|
| 427 | { |
---|
| 428 | $day_params['day_image'] = ''; |
---|
| 429 | } |
---|
| 430 | $var[] = Array( |
---|
| 431 | 'day_image' => $day_params['day_image'], |
---|
| 432 | 'dayname' => $str |
---|
| 433 | ); |
---|
| 434 | } |
---|
| 435 | for($l=0;$l<count($var);$l++) |
---|
| 436 | { |
---|
| 437 | $this->output_template_array($mini_cal_tpl,'monthweek_day','mini_day',$var[$l]); |
---|
| 438 | } |
---|
| 439 | $mini_cal_tpl->parse('display_monthweek','mini_week',True); |
---|
| 440 | $mini_cal_tpl->set_var('dayname',''); |
---|
| 441 | $mini_cal_tpl->set_var('monthweek_day',''); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | $return_value = $mini_cal_tpl->fp('out','mini_cal'); |
---|
| 445 | $mini_cal_tpl->set_var('display_monthweek',''); |
---|
| 446 | // $mini_cal_tpl->set_var('daynames',''); |
---|
| 447 | // unset($p); |
---|
| 448 | return $return_value; |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | function index($params='') |
---|
| 452 | { |
---|
| 453 | if (!$params) |
---|
| 454 | { |
---|
| 455 | foreach(array('date','year','month','day') as $field) |
---|
| 456 | { |
---|
| 457 | if (isset($_GET[$field])) |
---|
| 458 | { |
---|
| 459 | $params[$field] = $_GET[$field]; |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | } |
---|
| 463 | $GLOBALS['phpgw']->redirect($this->page('',$params)); |
---|
| 464 | |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | |
---|
| 468 | |
---|
| 469 | // NDEE: printer-friendly |
---|
| 470 | |
---|
| 471 | function printer_friendly($body,$app_header='') |
---|
| 472 | { |
---|
| 473 | $_SESSION['calendar']['categories'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); |
---|
| 474 | if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) |
---|
| 475 | $_SESSION['calendar']['cals'] = $this->bo->list_cals(); |
---|
| 476 | |
---|
| 477 | if($this->bo->printer_friendly || $_GET['plain'] == 'True') |
---|
| 478 | { |
---|
| 479 | $app_css_path = $_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']; |
---|
| 480 | $app_print_css_path = $app_css_path; |
---|
| 481 | if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_css_path.'/app.css')) |
---|
| 482 | $app_css_path = 'default'; |
---|
| 483 | if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_print_css_path.'/app_print.css')) |
---|
| 484 | $app_print_css_path = 'default'; |
---|
| 485 | |
---|
| 486 | $new_body = '<html>'."\n" |
---|
| 487 | .'<head>'."\n" |
---|
| 488 | .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_css_path.'/app.css" type=text/css rel=StyleSheet>'."\n" |
---|
| 489 | .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_print_css_path.'/app_print.css" type=text/css rel=StyleSheet media="print">'."\n" |
---|
| 490 | .'</head> |
---|
| 491 | <table id="calendar_print_main" class="calendar_print_main"> |
---|
| 492 | <tr> |
---|
| 493 | <td id="calendar_print_content" class="calendar_print_content">'.$body.'</td> |
---|
| 494 | </tr> |
---|
| 495 | <tr> |
---|
| 496 | <td> |
---|
| 497 | <div> |
---|
| 498 | <input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta página"> |
---|
| 499 | </div> |
---|
| 500 | </td> |
---|
| 501 | </tr> |
---|
| 502 | </table></body>'."\n" |
---|
| 503 | .'</html>'."\n"; |
---|
| 504 | //$new_body = utf8_decode($new_body); |
---|
| 505 | } |
---|
| 506 | else |
---|
| 507 | { |
---|
| 508 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 509 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 510 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
| 511 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
| 512 | if ($app_header && $this->always_app_header) |
---|
| 513 | { |
---|
| 514 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.$app_header; |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 518 | $new_body = $this->bo->debug_string.$body; |
---|
| 519 | |
---|
| 520 | } |
---|
| 521 | return $new_body; |
---|
| 522 | } |
---|
| 523 | |
---|
| 524 | function month() |
---|
| 525 | { |
---|
| 526 | if($_GET['month']||$_POST['month']){ |
---|
| 527 | $params['month'] = $_GET['month']?(int)$_GET['month']:(int)$_POST['month']; |
---|
| 528 | $params['year'] = $_GET['year']?(int)$_GET['year']:(int)$_POST['year']; |
---|
| 529 | $params['day'] = 1; |
---|
| 530 | |
---|
| 531 | }else{ |
---|
| 532 | $params['day'] = $_POST['date']?(int)substr($_POST['date'] , 6, 2):(int)substr($_GET['date'] , 6, 2); |
---|
| 533 | $params['month'] = $_POST['date']?(int)substr($_POST['date'] , 4, 2):(int)substr($_GET['date'] , 4, 2); |
---|
| 534 | $params['year'] = $_POST['date']?(int)substr($_POST['date'] , 0, 4):(int)substr($_GET['date'] , 0, 4); |
---|
| 535 | |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | if($_GET['friendly']==1) |
---|
| 539 | { |
---|
| 540 | echo $this->printer_friendly($this->get_month(),lang('Monthview')); |
---|
| 541 | } |
---|
| 542 | else |
---|
| 543 | { |
---|
| 544 | echo $this->printer_friendly($this->print_month_new($params),lang('Monthview')); |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | function get_month() |
---|
| 551 | { |
---|
| 552 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 553 | |
---|
| 554 | $next = $this->bo->month + 1; |
---|
| 555 | $prev = $this->bo->month - 1; |
---|
| 556 | $nextyear = $this->bo->year; |
---|
| 557 | $prevyear = $this->bo->year; |
---|
| 558 | if ($this->bo->month == 12) |
---|
| 559 | { |
---|
| 560 | $next = 1; |
---|
| 561 | $nextyear = $nextyear + 1; |
---|
| 562 | } |
---|
| 563 | elseif ($this->bo->month == 1) |
---|
| 564 | { |
---|
| 565 | $prev = 12; |
---|
| 566 | $prevyear = $prevyear - 1; |
---|
| 567 | } |
---|
| 568 | |
---|
| 569 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
| 570 | { |
---|
| 571 | $minical_prev = $this->mini_calendar( |
---|
| 572 | Array( |
---|
| 573 | 'day' => 1, |
---|
| 574 | 'month' => $this->bo->month - 1, |
---|
| 575 | 'year' => $this->bo->year, |
---|
| 576 | 'link' => 'day', |
---|
| 577 | 'outside_month' => False |
---|
| 578 | ) |
---|
| 579 | ); |
---|
| 580 | |
---|
| 581 | $minical_next = $this->mini_calendar( |
---|
| 582 | Array( |
---|
| 583 | 'day' => 1, |
---|
| 584 | 'month' => $this->bo->month + 1, |
---|
| 585 | 'year' => $this->bo->year, |
---|
| 586 | 'link' => 'day', |
---|
| 587 | 'outside_month' => False |
---|
| 588 | ) |
---|
| 589 | ); |
---|
| 590 | } |
---|
| 591 | else |
---|
| 592 | { |
---|
| 593 | $minical_prev = ''; |
---|
| 594 | $minical_next = ''; |
---|
| 595 | } |
---|
| 596 | $this->bo->read_holidays($params['year']); |
---|
| 597 | if($_POST['year']) { |
---|
| 598 | |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | if (!$this->bo->printer_friendly) |
---|
| 602 | { |
---|
| 603 | $account_name = $_POST['user'] ? $_POST['user'] : ($_GET['account_name'] ? $_GET['account_name'] : ''); |
---|
| 604 | |
---|
| 605 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
| 606 | $accountId = $accounts->name2id($account_name); |
---|
| 607 | |
---|
| 608 | $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
| 609 | $account_prefs = $prefs->read(); |
---|
| 610 | |
---|
| 611 | $printer = ''; |
---|
| 612 | $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'"><<</a>'; |
---|
| 613 | $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">>></a>'; |
---|
| 614 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias; |
---|
| 615 | //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; |
---|
| 616 | /*if($account_prefs['calendar']['type_month_print'] == '0') |
---|
| 617 | { |
---|
| 618 | $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). |
---|
| 619 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
| 620 | lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 621 | } |
---|
| 622 | else |
---|
| 623 | { |
---|
| 624 | $print = '<a href="javascript:void(0)" onclick="scheduler.toPDF('."'calendar/js/dhtmlx/server/generate.php'".')">['.lang('Printer Friendly').']</a>'; |
---|
| 625 | }*/ |
---|
| 626 | |
---|
| 627 | //linha abaixo foi adicionada para exibir a pagina do mes em tela |
---|
| 628 | //$month,$year,$showyear,$owner=0; |
---|
| 629 | $params = Array( |
---|
| 630 | 'month' => $this->bo->month, |
---|
| 631 | 'year' => $this->bo->year, |
---|
| 632 | 'showyear' => True, |
---|
| 633 | 'owner' => $this->bo->owner |
---|
| 634 | ); |
---|
| 635 | $large_month = $this->display_month($params); |
---|
| 636 | } |
---|
| 637 | else |
---|
| 638 | { |
---|
| 639 | $printer = '<body bgcolor="'.$phpgw_info['theme']['bg_color'].'">'; |
---|
| 640 | $prev_month_link = ''; |
---|
| 641 | $next_month_link = ''; |
---|
| 642 | $print = ''; |
---|
| 643 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 644 | //linha abaixo foi adicionada para exibir a pagina do mes para impressao |
---|
| 645 | |
---|
| 646 | //if($_GET['classic_print']==1) |
---|
| 647 | // $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
| 648 | //else |
---|
| 649 | $large_month = $this->display_month_print($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | $this->bo->read_holidays(); |
---|
| 653 | |
---|
| 654 | $aux_month_identifier = lang(strftime("%B",$m)).' '.$this->bo->year; |
---|
| 655 | if(isset($_GET['friendly']) && $_GET['friendly'] ==1) |
---|
| 656 | { |
---|
| 657 | if( isset($_GET['num_dias']) && ($_GET['num_dias'] == 1) ) |
---|
| 658 | { |
---|
| 659 | $year = $_GET['year']; |
---|
| 660 | $month = $_GET['month']; |
---|
| 661 | $day = $_GET['day_ini']; |
---|
| 662 | $aux_month_identifier = $this->month_day_of_week($year,$month,$day).', '.$day.' de '.lang(strftime("%B",$m)).' de '.$this->bo->year; |
---|
| 663 | } |
---|
| 664 | } |
---|
| 665 | |
---|
| 666 | $var = Array( |
---|
| 667 | 'printer_friendly' => $printer, |
---|
| 668 | 'bg_text' => $this->theme['bg_text'], |
---|
| 669 | 'small_calendar_prev' => $minical_prev, |
---|
| 670 | 'prev_month_link' => $prev_month_link, |
---|
| 671 | 'month_identifier' => $aux_month_identifier, |
---|
| 672 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 673 | 'next_month_link' => $next_month_link, |
---|
| 674 | 'small_calendar_next' => $minical_next, |
---|
| 675 | 'large_month' => $large_month, |
---|
| 676 | 'print' => $print |
---|
| 677 | ); |
---|
| 678 | |
---|
| 679 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 680 | $p->set_unknowns('remove'); |
---|
| 681 | // Alteracao que desvincula o template para tela do template de impressao do mes (month_print teve que ser criado); |
---|
| 682 | if($print != '') |
---|
| 683 | { |
---|
| 684 | $p->set_file( |
---|
| 685 | Array( |
---|
| 686 | 'index_t' => 'index.tpl' |
---|
| 687 | ) |
---|
| 688 | ); |
---|
| 689 | }else { |
---|
| 690 | $p->set_file( |
---|
| 691 | Array( |
---|
| 692 | 'index_t' => 'month_print.tpl' |
---|
| 693 | ) |
---|
| 694 | ); |
---|
| 695 | } |
---|
| 696 | $p->set_var($var); |
---|
| 697 | return $p->fp('out','index_t'); |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | function week() |
---|
| 701 | { |
---|
| 702 | |
---|
| 703 | if($_GET['month']||$_POST['month']){ |
---|
| 704 | $params['month'] = $_GET['month']?(int)$_GET['month']:(int)$_POST['month']; |
---|
| 705 | $params['year'] = $_GET['year']?(int)$_GET['year']:(int)$_POST['year']; |
---|
| 706 | $params['day'] = $_GET['day']?(int)$_GET['day']:(int)$_POST['day']; |
---|
| 707 | |
---|
| 708 | }else{ |
---|
| 709 | $params['day'] = $_POST['date']?(int)substr($_POST['date'] , 6, 2):(int)substr($_GET['date'] , 6, 2); |
---|
| 710 | $params['month'] = $_POST['date']?(int)substr($_POST['date'] , 4, 2):(int)substr($_GET['date'] , 4, 2); |
---|
| 711 | $params['year'] = $_POST['date']?(int)substr($_POST['date'] , 0, 4):(int)substr($_GET['date'] , 0, 4); |
---|
| 712 | |
---|
| 713 | } |
---|
| 714 | |
---|
| 715 | echo $this->printer_friendly($this->print_week_new($params),lang('Weekview')); |
---|
| 716 | |
---|
| 717 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 718 | } |
---|
| 719 | |
---|
| 720 | function get_week() |
---|
| 721 | { |
---|
| 722 | $this->bo->read_holidays(); |
---|
| 723 | |
---|
| 724 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
| 725 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
| 726 | |
---|
| 727 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
| 728 | { |
---|
| 729 | $minical_prev = $this->mini_calendar( |
---|
| 730 | Array( |
---|
| 731 | 'day' => $this->bo->day, |
---|
| 732 | 'month' => $this->bo->month - 1, |
---|
| 733 | 'year' => $this->bo->year, |
---|
| 734 | 'link' => 'day', |
---|
| 735 | 'butons' => 'left', |
---|
| 736 | 'outside_month' => False |
---|
| 737 | ) |
---|
| 738 | ); |
---|
| 739 | $minical_next = $this->mini_calendar( |
---|
| 740 | Array( |
---|
| 741 | 'day' => $this->bo->day, |
---|
| 742 | 'month' => $this->bo->month + 1, |
---|
| 743 | 'year' => $this->bo->year, |
---|
| 744 | 'link' => 'day', |
---|
| 745 | 'butons' => 'right', |
---|
| 746 | 'outside_month' => False |
---|
| 747 | ) |
---|
| 748 | ); |
---|
| 749 | $minical_this = $this->mini_calendar( |
---|
| 750 | Array( |
---|
| 751 | 'day' => $this->bo->day, |
---|
| 752 | 'month' => $this->bo->month, |
---|
| 753 | 'year' => $this->bo->year, |
---|
| 754 | 'link' => 'day', |
---|
| 755 | 'butons' => 'none', |
---|
| 756 | 'outside_month' => False |
---|
| 757 | ) |
---|
| 758 | ); |
---|
| 759 | } |
---|
| 760 | else |
---|
| 761 | { |
---|
| 762 | |
---|
| 763 | //NDEE: printer-friendly what? |
---|
| 764 | $minical_this = ''; |
---|
| 765 | $minical_prev = ''; |
---|
| 766 | $minical_next = ''; |
---|
| 767 | } |
---|
| 768 | |
---|
| 769 | if (!$this->bo->printer_friendly) |
---|
| 770 | { |
---|
| 771 | |
---|
| 772 | $printer = ''; |
---|
| 773 | $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'"><<</a>'; |
---|
| 774 | $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">>></a>'; |
---|
| 775 | $print = '<a href="javascript:void(0);" onclick="scheduler.toPDF('."'calendar/js/dhtmlx/server/generate.php'".')">['.lang('Printer Friendly').']</a>'; |
---|
| 776 | |
---|
| 777 | //$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>'; |
---|
| 778 | } |
---|
| 779 | else |
---|
| 780 | { |
---|
| 781 | |
---|
| 782 | //NDEE: printer-friendly (weekly-view) |
---|
| 783 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 784 | $prev_week_link = ''; |
---|
| 785 | $next_week_link = ''; |
---|
| 786 | $print = ''; |
---|
| 787 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 788 | } |
---|
| 789 | |
---|
| 790 | $var = Array( |
---|
| 791 | 'printer_friendly' => $print, |
---|
| 792 | 'bg_text' => $this->theme['bg_text'], |
---|
| 793 | 'small_calendar_prev' => $minical_prev, |
---|
| 794 | 'prev_week_link' => $prev_week_link, |
---|
| 795 | 'small_calendar_this' => $minical_this, |
---|
| 796 | 'week_identifier' => $this->bo->get_week_label(), |
---|
| 797 | 'next_week_link' => $next_week_link, |
---|
| 798 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 799 | 'small_calendar_next' => $minical_next, |
---|
| 800 | 'week_display' => $this->display_weekly( |
---|
| 801 | Array( |
---|
| 802 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 803 | 'showyear' => true, |
---|
| 804 | 'owners' => $this->bo->owner |
---|
| 805 | ) |
---|
| 806 | ), |
---|
| 807 | 'print' => $print |
---|
| 808 | ); |
---|
| 809 | //todo |
---|
| 810 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 811 | $p->set_file( |
---|
| 812 | Array( |
---|
| 813 | 'week_t' => 'week.tpl' |
---|
| 814 | ) |
---|
| 815 | ); |
---|
| 816 | $p->set_var($var); |
---|
| 817 | return $p->fp('out','week_t'); |
---|
| 818 | |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | function year() |
---|
| 822 | { |
---|
| 823 | if ($_GET['plain'] == "True") |
---|
| 824 | { |
---|
| 825 | |
---|
| 826 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
| 827 | } |
---|
| 828 | else |
---|
| 829 | { |
---|
| 830 | |
---|
| 831 | if($this->bo->printer_friendly) |
---|
| 832 | { |
---|
| 833 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 834 | } |
---|
| 835 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
| 836 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | function get_year() |
---|
| 841 | { |
---|
| 842 | if(!$this->bo->printer_friendly) |
---|
| 843 | { |
---|
| 844 | $print = ''; |
---|
| 845 | $left_link = '<a href="'.$this->page('year','&year='.($this->bo->year - 1)).'"><<</a>'; |
---|
| 846 | $right_link = '<a href="'.$this->page('year','&year='.($this->bo->year + 1)).'">>></a>'; |
---|
| 847 | $link = 'day'; |
---|
| 848 | $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>'; |
---|
| 849 | } |
---|
| 850 | else |
---|
| 851 | { |
---|
| 852 | //NDEE: printer-friendly (year-view) |
---|
| 853 | $print = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 854 | $left_link = ''; |
---|
| 855 | $right_link = ''; |
---|
| 856 | $link = ''; |
---|
| 857 | $printer = ''; |
---|
| 858 | } |
---|
| 859 | |
---|
| 860 | $var = Array( |
---|
| 861 | 'print' => $print, |
---|
| 862 | 'left_link' => $left_link, |
---|
| 863 | 'font' => $this->theme['font'], |
---|
| 864 | 'year_text' => $this->bo->year, |
---|
| 865 | 'right_link'=> $right_link, |
---|
| 866 | 'printer_friendly'=> $printer |
---|
| 867 | ); |
---|
| 868 | |
---|
| 869 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 870 | $p->set_file( |
---|
| 871 | Array( |
---|
| 872 | 'year_t' => 'year.tpl' |
---|
| 873 | ) |
---|
| 874 | ); |
---|
| 875 | $p->set_block('year_t','year','year'); |
---|
| 876 | $p->set_block('year_t','month','month_handle'); |
---|
| 877 | $p->set_block('year_t','month_sep','month_sep_handle'); |
---|
| 878 | $p->set_var($var); |
---|
| 879 | |
---|
| 880 | for($i=1;$i<=12;$i++) |
---|
| 881 | { |
---|
| 882 | if(($i % 3) == 1) |
---|
| 883 | { |
---|
| 884 | $p->parse('row','month_sep',True); |
---|
| 885 | } |
---|
| 886 | $p->set_var('mini_month',$this->mini_calendar( |
---|
| 887 | Array( |
---|
| 888 | 'day' => 1, |
---|
| 889 | 'month' => $i, |
---|
| 890 | 'year' => $this->bo->year, |
---|
| 891 | 'link' => $link, |
---|
| 892 | 'buttons' => 'none', |
---|
| 893 | 'outside_month' => False |
---|
| 894 | ) |
---|
| 895 | ) |
---|
| 896 | ); |
---|
| 897 | $p->parse('row','month',True); |
---|
| 898 | $p->set_var('mini_month',''); |
---|
| 899 | } |
---|
| 900 | return $p->fp('out','year_t'); |
---|
| 901 | } |
---|
| 902 | |
---|
| 903 | function view($vcal_id=0,$cal_date=0) |
---|
| 904 | { |
---|
| 905 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 906 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 907 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('View'); |
---|
| 908 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 909 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 910 | |
---|
| 911 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
| 912 | |
---|
| 913 | $date = $cal_date ? $cal_date : 0; |
---|
| 914 | $date = $date ? $date : (int)$_GET['date']; |
---|
| 915 | |
---|
| 916 | // First, make sure they have permission to this entry |
---|
| 917 | if ($cal_id < 1) |
---|
| 918 | { |
---|
| 919 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
| 920 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 921 | } |
---|
| 922 | |
---|
| 923 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id)) |
---|
| 924 | { |
---|
| 925 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
| 926 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | $event = $this->bo->read_entry($cal_id); |
---|
| 930 | |
---|
| 931 | if(!isset($event['id'])) |
---|
| 932 | { |
---|
| 933 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
| 934 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 935 | } |
---|
| 936 | |
---|
| 937 | $this->bo->repeating_events = Array(); |
---|
| 938 | $this->bo->cached_events = Array(); |
---|
| 939 | $this->bo->repeating_events[0] = $event; |
---|
| 940 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 941 | $this->bo->check_repeating_events($datetime); |
---|
| 942 | $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); |
---|
| 943 | if(is_array($this->bo->cached_events[$check_date][0]) && |
---|
| 944 | $this->bo->cached_events[$check_date][0]['id'] == $event['id']) |
---|
| 945 | { |
---|
| 946 | $starttime = $this->bo->maketime($event['start']); |
---|
| 947 | $endtime = $this->bo->maketime($event['end']); |
---|
| 948 | $event['start']['month'] = $this->bo->month; |
---|
| 949 | $event['start']['mday'] = $this->bo->day; |
---|
| 950 | $event['start']['year'] = $this->bo->year; |
---|
| 951 | $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); |
---|
| 952 | $event['end']['month'] = date('m',$temp_end); |
---|
| 953 | $event['end']['mday'] = date('d',$temp_end); |
---|
| 954 | $event['end']['year'] = date('Y',$temp_end); |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | if(!$this->view_event($event,True)) |
---|
| 958 | { |
---|
| 959 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
| 960 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 961 | } |
---|
| 962 | |
---|
| 963 | $p = $GLOBALS['phpgw']->template; |
---|
| 964 | $p->set_file( |
---|
| 965 | Array( |
---|
| 966 | 'form_button' => 'form_button_script.tpl' |
---|
| 967 | ) |
---|
| 968 | ); |
---|
| 969 | |
---|
| 970 | $button_left = $button_center = $button_right = ''; |
---|
| 971 | |
---|
| 972 | if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
| 973 | { |
---|
| 974 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
| 975 | { |
---|
| 976 | $var = Array( |
---|
| 977 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 978 | 'action_text_button' => lang('Edit Single'), |
---|
| 979 | 'action_confirm_button' => '', |
---|
| 980 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 981 | 'edit_type' => 'single', |
---|
| 982 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
| 983 | )) |
---|
| 984 | ); |
---|
| 985 | $p->set_var($var); |
---|
| 986 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 987 | |
---|
| 988 | $var = Array( |
---|
| 989 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 990 | 'action_text_button' => lang('Edit Series'), |
---|
| 991 | 'action_confirm_button' => '', |
---|
| 992 | 'action_extra_field' => $this->html->input_hidden('edit_type','series') |
---|
| 993 | ); |
---|
| 994 | $p->set_var($var); |
---|
| 995 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 996 | } |
---|
| 997 | else |
---|
| 998 | { |
---|
| 999 | $var = Array( |
---|
| 1000 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
| 1001 | 'action_text_button' => lang('Edit'), |
---|
| 1002 | 'action_confirm_button' => '', |
---|
| 1003 | 'action_extra_field' => '' |
---|
| 1004 | ); |
---|
| 1005 | $p->set_var($var); |
---|
| 1006 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1007 | } |
---|
| 1008 | |
---|
| 1009 | $var = Array( |
---|
| 1010 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
| 1011 | 'action_text_button' => lang('Alarm Management'), |
---|
| 1012 | 'action_confirm_button' => '', |
---|
| 1013 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 1014 | 'cal_id' => $cal_id, |
---|
| 1015 | 'return_to' => $this->bo->return_to |
---|
| 1016 | )) |
---|
| 1017 | ); |
---|
| 1018 | $p->set_var($var); |
---|
| 1019 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1020 | } |
---|
| 1021 | |
---|
| 1022 | if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) |
---|
| 1023 | { |
---|
| 1024 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
| 1025 | { |
---|
| 1026 | $var = Array( |
---|
| 1027 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 1028 | 'action_text_button' => lang('Delete Single'), |
---|
| 1029 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this single occurence?').'\\n'.lang('This will delete this entry for all users.')."')\"", |
---|
| 1030 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 1031 | 'delete_type' => 'single', |
---|
| 1032 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
| 1033 | )) |
---|
| 1034 | ); |
---|
| 1035 | $p->set_var($var); |
---|
| 1036 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1037 | |
---|
| 1038 | $var = Array( |
---|
| 1039 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 1040 | 'action_text_button' => lang('Delete Series'), |
---|
| 1041 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
| 1042 | 'action_extra_field' => $this->html->input_hidden('delete_type','series') |
---|
| 1043 | ); |
---|
| 1044 | $p->set_var($var); |
---|
| 1045 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1046 | |
---|
| 1047 | if($event['recur_exception']) |
---|
| 1048 | { |
---|
| 1049 | $var = Array( |
---|
| 1050 | 'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), |
---|
| 1051 | 'action_text_button' => lang('Reinstate'), |
---|
| 1052 | 'action_confirm_button' => '', |
---|
| 1053 | 'action_extra_field' => '' |
---|
| 1054 | ); |
---|
| 1055 | $p->set_var($var); |
---|
| 1056 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1057 | } |
---|
| 1058 | } |
---|
| 1059 | else |
---|
| 1060 | { |
---|
| 1061 | $var = Array( |
---|
| 1062 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
| 1063 | 'action_text_button' => lang('Delete'), |
---|
| 1064 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
| 1065 | 'action_extra_field' => '' |
---|
| 1066 | ); |
---|
| 1067 | $p->set_var($var); |
---|
| 1068 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1069 | } |
---|
| 1070 | } |
---|
| 1071 | else |
---|
| 1072 | { |
---|
| 1073 | // allow me (who I am logged in as) to set up an alarm |
---|
| 1074 | // if I am a participant, but not the owner |
---|
| 1075 | reset($event['participants']); |
---|
| 1076 | while (list($user,$short_status) = each($event['participants'])) |
---|
| 1077 | { |
---|
| 1078 | if ($GLOBALS['phpgw_info']['user']['account_id'] == $user) |
---|
| 1079 | { |
---|
| 1080 | $var = Array( |
---|
| 1081 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
| 1082 | 'action_text_button' => lang('Alarm Management'), |
---|
| 1083 | 'action_confirm_button' => '', |
---|
| 1084 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
| 1085 | 'cal_id' => $cal_id, |
---|
| 1086 | 'return_to' => $this->bo->return_to |
---|
| 1087 | )) |
---|
| 1088 | ); |
---|
| 1089 | $p->set_var($var); |
---|
| 1090 | echo $p->fp('out','form_button'); |
---|
| 1091 | } |
---|
| 1092 | } |
---|
| 1093 | } |
---|
| 1094 | |
---|
| 1095 | $var = Array( |
---|
| 1096 | 'action_url_button' => $this->page('export'), |
---|
| 1097 | 'action_text_button' => lang('Export'), |
---|
| 1098 | 'action_confirm_button' => '', |
---|
| 1099 | 'action_extra_field' => $this->html->input_hidden('cal_id',$cal_id) |
---|
| 1100 | ); |
---|
| 1101 | $p->set_var($var); |
---|
| 1102 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1103 | |
---|
| 1104 | if ($this->bo->return_to) |
---|
| 1105 | { |
---|
| 1106 | $var = Array( |
---|
| 1107 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 1108 | 'action_text_button' => lang('Done'), |
---|
| 1109 | 'action_confirm_button' => '', |
---|
| 1110 | 'action_extra_field' => '' |
---|
| 1111 | ); |
---|
| 1112 | $p->set_var($var); |
---|
| 1113 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
| 1114 | } |
---|
| 1115 | $p->set_var(array( |
---|
| 1116 | 'button_left' => $button_left, |
---|
| 1117 | 'button_center' => $button_center, |
---|
| 1118 | 'button_right' => $button_right |
---|
| 1119 | )); |
---|
| 1120 | $p->pfp('phpgw_body','view_event'); |
---|
| 1121 | |
---|
| 1122 | $GLOBALS['phpgw']->hooks->process(array( |
---|
| 1123 | 'location' => 'calendar_view', |
---|
| 1124 | 'cal_id' => $cal_id |
---|
| 1125 | )); |
---|
| 1126 | |
---|
| 1127 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 1128 | } |
---|
| 1129 | |
---|
| 1130 | function edit($params='') |
---|
| 1131 | { |
---|
| 1132 | if($this->debug) |
---|
| 1133 | { |
---|
| 1134 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
| 1135 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
| 1136 | } |
---|
| 1137 | |
---|
| 1138 | if(isset($_GET['readsess'])) |
---|
| 1139 | { |
---|
| 1140 | $params['readsess'] = $_GET['readsess']; |
---|
| 1141 | $params['cd'] = 0; |
---|
| 1142 | } |
---|
| 1143 | |
---|
| 1144 | if($this->debug) |
---|
| 1145 | { |
---|
| 1146 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
| 1147 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
| 1148 | } |
---|
| 1149 | |
---|
| 1150 | if($params != '' && @is_array($params) && @isset($params['readsess'])) |
---|
| 1151 | { |
---|
| 1152 | $can_edit = True; |
---|
| 1153 | $this->edit_form( |
---|
| 1154 | Array( |
---|
| 1155 | 'event' => $this->bo->restore_from_appsession(), |
---|
| 1156 | 'cd' => $params['cd'] |
---|
| 1157 | ) |
---|
| 1158 | ); |
---|
| 1159 | } |
---|
| 1160 | elseif(isset($_GET['cal_id'])) |
---|
| 1161 | { |
---|
| 1162 | $cal_id = (int)$_GET['cal_id']; |
---|
| 1163 | $event = $this->bo->read_entry($cal_id); |
---|
| 1164 | |
---|
| 1165 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
| 1166 | { |
---|
| 1167 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
| 1168 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1169 | } |
---|
| 1170 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') |
---|
| 1171 | { |
---|
| 1172 | $event['id'] = 0; |
---|
| 1173 | $this->bo->set_recur_date($event,$_POST['date']); |
---|
| 1174 | $event['recur_type'] = MCAL_RECUR_NONE; |
---|
| 1175 | $event['recur_interval'] = 0; |
---|
| 1176 | $event['recur_data'] = 0; |
---|
| 1177 | $event['recur_enddate']['month'] = 0; |
---|
| 1178 | $event['recur_enddate']['mday'] = 0; |
---|
| 1179 | $event['recur_enddate']['year'] = 0; |
---|
| 1180 | $event['recur_exception'] = array(); |
---|
| 1181 | } |
---|
| 1182 | $plain = $_GET['plain']; |
---|
| 1183 | |
---|
| 1184 | $this->edit_form( |
---|
| 1185 | Array( |
---|
| 1186 | 'event' => $event, |
---|
| 1187 | 'cd' => $cd, |
---|
| 1188 | 'plain' => $plain |
---|
| 1189 | ) |
---|
| 1190 | ); |
---|
| 1191 | } |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | function export_all() |
---|
| 1195 | { |
---|
| 1196 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
| 1197 | srand((double)microtime()*1000000); |
---|
| 1198 | $random_number = rand(100000000,999999999); |
---|
| 1199 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
| 1200 | $filename = $temp_path . $newfilename; |
---|
| 1201 | $attach_fd = fopen($filename,"w+"); |
---|
| 1202 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
| 1203 | foreach($event_ids as $key => $id) |
---|
| 1204 | { |
---|
| 1205 | $event[$key]=$this->bo->read_entry($id); |
---|
| 1206 | } |
---|
| 1207 | include_once('class.bocalendar.inc.php'); |
---|
| 1208 | $cal = new bocalendar; |
---|
| 1209 | $tmpattach=$cal->create_vcard($event); |
---|
| 1210 | fwrite($attach_fd,$tmpattach); |
---|
| 1211 | header ("Content-Type: text/plain"); |
---|
| 1212 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1213 | header('Content-Length: ' . filesize($filename)); |
---|
| 1214 | header("Content-disposition: attachment; filename="."export.vcard"); |
---|
| 1215 | readfile($filename); |
---|
| 1216 | fclose($attach_fd); |
---|
| 1217 | } |
---|
| 1218 | |
---|
| 1219 | function export($vcal_id=0) |
---|
| 1220 | { |
---|
| 1221 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
| 1222 | srand((double)microtime()*1000000); |
---|
| 1223 | $random_number = rand(100000000,999999999); |
---|
| 1224 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
| 1225 | $filename = $temp_path . $newfilename; |
---|
| 1226 | $attach_fd = fopen($filename,"w+"); |
---|
| 1227 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
| 1228 | $event[0] = $this->bo->read_entry($cal_id); |
---|
| 1229 | include_once('class.bocalendar.inc.php'); |
---|
| 1230 | $cal = new bocalendar; |
---|
| 1231 | $tmpattach=$cal->create_vcard($event); |
---|
| 1232 | fwrite($attach_fd,$tmpattach); |
---|
| 1233 | header ("Content-Type: text/plain"); |
---|
| 1234 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1235 | header('Content-Length: ' . filesize($filename)); |
---|
| 1236 | header("Content-disposition: attachment; filename="."export.vcard"); |
---|
| 1237 | readfile($filename); |
---|
| 1238 | fclose($attach_fd); |
---|
| 1239 | } |
---|
| 1240 | |
---|
| 1241 | function reinstate_list($params='') |
---|
| 1242 | { |
---|
| 1243 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1244 | { |
---|
| 1245 | $this->no_edit(); |
---|
| 1246 | } |
---|
| 1247 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1248 | { |
---|
| 1249 | $this->index(); |
---|
| 1250 | } |
---|
| 1251 | |
---|
| 1252 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1253 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1254 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Reinstate'); |
---|
| 1255 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1256 | |
---|
| 1257 | $cal_id = get_var('cal_id',array('GET'),$params['cal_id']); |
---|
| 1258 | |
---|
| 1259 | if ($cal_id < 1) |
---|
| 1260 | { |
---|
| 1261 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
| 1262 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1263 | } |
---|
| 1264 | |
---|
| 1265 | if(!$this->bo->check_perms(PHPGW_ACL_READ)) |
---|
| 1266 | { |
---|
| 1267 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
| 1268 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1269 | } |
---|
| 1270 | |
---|
| 1271 | $event = $this->bo->read_entry($cal_id); |
---|
| 1272 | |
---|
| 1273 | if(!isset($event['id'])) |
---|
| 1274 | { |
---|
| 1275 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
| 1276 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1277 | } |
---|
| 1278 | elseif(!isset($event['recur_exception'])) |
---|
| 1279 | { |
---|
| 1280 | echo '<center>'.lang('Sorry, this event does not have exceptions defined').'.'.'</center>'."\n"; |
---|
| 1281 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1282 | } |
---|
| 1283 | |
---|
| 1284 | if(!$this->view_event($event,True)) |
---|
| 1285 | { |
---|
| 1286 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
| 1287 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 1288 | } |
---|
| 1289 | |
---|
| 1290 | $p = &$GLOBALS['phpgw']->template; |
---|
| 1291 | $p->set_file( |
---|
| 1292 | Array( |
---|
| 1293 | 'form_button' => 'form_button_script.tpl' |
---|
| 1294 | ) |
---|
| 1295 | ); |
---|
| 1296 | |
---|
| 1297 | $str = ''; |
---|
| 1298 | |
---|
| 1299 | for($i=0;$i<count($event['recur_exception']);$i++) |
---|
| 1300 | { |
---|
| 1301 | $str .= ' <option value="'.$i.'">'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).'</option>'."\n"; |
---|
| 1302 | } |
---|
| 1303 | $this->output_template_array($p,'row','list',array( |
---|
| 1304 | 'field' => lang('Exceptions'), |
---|
| 1305 | 'data' => '<select name="reinstate_index[]" multiple size="5">'."\n".$str.'</select>' |
---|
| 1306 | )); |
---|
| 1307 | |
---|
| 1308 | $var = Array( |
---|
| 1309 | 'action_url_button' => $this->page('reinstate','&cal_id='.$cal_id), |
---|
| 1310 | 'action_text_button' => lang('Reinstate'), |
---|
| 1311 | 'action_confirm_button' => '', |
---|
| 1312 | 'action_extra_field' => '' |
---|
| 1313 | ); |
---|
| 1314 | $p->set_var($var); |
---|
| 1315 | $button_left = '<td>'.$p->fp('out','form_button').'</td>'; |
---|
| 1316 | |
---|
| 1317 | $var = Array( |
---|
| 1318 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
| 1319 | 'action_text_button' => lang('Cancel'), |
---|
| 1320 | 'action_confirm_button' => '', |
---|
| 1321 | 'action_extra_field' => '' |
---|
| 1322 | ); |
---|
| 1323 | $p->set_var($var); |
---|
| 1324 | $button_left .= '<td>'.$p->fp('out','form_button').'</td>'; |
---|
| 1325 | |
---|
| 1326 | $p->set_var('button_left',$button_left); |
---|
| 1327 | $p->pfp('phpgw_body','view_event'); |
---|
| 1328 | } |
---|
| 1329 | |
---|
| 1330 | function reinstate($params='') |
---|
| 1331 | { |
---|
| 1332 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 1333 | { |
---|
| 1334 | $this->no_edit(); |
---|
| 1335 | } |
---|
| 1336 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1337 | { |
---|
| 1338 | $this->index(); |
---|
| 1339 | } |
---|
| 1340 | $cal_id = (isset($params['cal_id']) ? (int)$params['cal_id'] : ''); |
---|
| 1341 | $cal_id = ($cal_id == '' ? (int)$_GET['cal_id'] : $cal_id); |
---|
| 1342 | |
---|
| 1343 | $reinstate_index = (isset($params['reinstate_index']) ? (int)$params['reinstate_index'] : ''); |
---|
| 1344 | $reinstate_index = ($reinstate_index == '' ? (int)$_POST['reinstate_index'] : $reinstate_index); |
---|
| 1345 | if($this->debug) |
---|
| 1346 | { |
---|
| 1347 | echo '<!-- Calling bo->reinstate -->'."\n"; |
---|
| 1348 | } |
---|
| 1349 | $cd = $this->bo->reinstate( |
---|
| 1350 | Array( |
---|
| 1351 | 'cal_id' => $cal_id, |
---|
| 1352 | 'reinstate_index' => $reinstate_index |
---|
| 1353 | ) |
---|
| 1354 | ); |
---|
| 1355 | if($this->debug) |
---|
| 1356 | { |
---|
| 1357 | echo '<!-- Return Value = '.$cd.' -->'."\n"; |
---|
| 1358 | } |
---|
| 1359 | if ($this->bo->return_to) |
---|
| 1360 | { |
---|
| 1361 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1362 | } |
---|
| 1363 | else |
---|
| 1364 | { |
---|
| 1365 | Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); |
---|
| 1366 | } |
---|
| 1367 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1368 | } |
---|
| 1369 | |
---|
| 1370 | function add($cd=0,$readsess=0) |
---|
| 1371 | { |
---|
| 1372 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 1373 | { |
---|
| 1374 | $this->index(); |
---|
| 1375 | } |
---|
| 1376 | |
---|
| 1377 | if($readsess) |
---|
| 1378 | { |
---|
| 1379 | $event = $this->bo->restore_from_appsession; |
---|
| 1380 | if(!$event['owner']) |
---|
| 1381 | { |
---|
| 1382 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
| 1383 | } |
---|
| 1384 | $can_edit = True; |
---|
| 1385 | } |
---|
| 1386 | else |
---|
| 1387 | { |
---|
| 1388 | $this->bo->event_init(); |
---|
| 1389 | $this->bo->add_attribute('id',0); |
---|
| 1390 | |
---|
| 1391 | $can_edit = True; |
---|
| 1392 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
| 1393 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); |
---|
| 1394 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
| 1395 | $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; |
---|
| 1396 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
| 1397 | |
---|
| 1398 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
| 1399 | if ($subject != '0') |
---|
| 1400 | { |
---|
| 1401 | $description = (string)(get_var('description',array('GET'),0)); |
---|
| 1402 | $location = (string)(get_var('location',array('GET'),0)); |
---|
| 1403 | } |
---|
| 1404 | else |
---|
| 1405 | unset($subject); |
---|
| 1406 | |
---|
| 1407 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
| 1408 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
| 1409 | $this->bo->set_title($subject); |
---|
| 1410 | $this->bo->set_description($description); |
---|
| 1411 | $this->bo->add_attribute('location',$location); |
---|
| 1412 | $this->bo->set_ex_participants(''); |
---|
| 1413 | $this->bo->add_attribute('uid',''); |
---|
| 1414 | $this->bo->add_attribute('priority',2); |
---|
| 1415 | if(@$this->bo->prefs['calendar']['default_private']) |
---|
| 1416 | { |
---|
| 1417 | $this->bo->set_class(False); |
---|
| 1418 | } |
---|
| 1419 | else |
---|
| 1420 | { |
---|
| 1421 | $this->bo->set_class(True); |
---|
| 1422 | } |
---|
| 1423 | // Add participants |
---|
| 1424 | //$participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); |
---|
| 1425 | //for($_f_part=0; $_f_part<count($participants); $_f_part++) |
---|
| 1426 | //{ |
---|
| 1427 | // $this->bo->add_attribute('participants','A',$participants[$_f_part]); |
---|
| 1428 | //} |
---|
| 1429 | // Add misc |
---|
| 1430 | $this->bo->add_attribute('participants','A',$this->bo->owner); |
---|
| 1431 | $this->bo->set_recur_none(); |
---|
| 1432 | $event = $this->bo->get_cached_event(); |
---|
| 1433 | |
---|
| 1434 | } |
---|
| 1435 | $this->edit_form( |
---|
| 1436 | Array( |
---|
| 1437 | 'event' => $event, |
---|
| 1438 | 'cd' => $cd, |
---|
| 1439 | 'plain' => $_GET['plain'] |
---|
| 1440 | ) |
---|
| 1441 | ); |
---|
| 1442 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 1443 | } |
---|
| 1444 | |
---|
| 1445 | function delete() |
---|
| 1446 | { |
---|
| 1447 | if(!isset($_GET['cal_id'])) |
---|
| 1448 | { |
---|
| 1449 | Header('Location: '.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))); |
---|
| 1450 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1451 | } |
---|
| 1452 | |
---|
| 1453 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); |
---|
| 1454 | if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id = (int)$_GET['cal_id'])) |
---|
| 1455 | { |
---|
| 1456 | if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single') |
---|
| 1457 | { |
---|
| 1458 | $date = $_POST['date']; |
---|
| 1459 | $cd = $this->bo->delete_single( |
---|
| 1460 | Array( |
---|
| 1461 | 'id' => $cal_id, |
---|
| 1462 | 'year' => substr($date,0,4), |
---|
| 1463 | 'month' => substr($date,4,2), |
---|
| 1464 | 'day' => substr($date,6,2) |
---|
| 1465 | ) |
---|
| 1466 | ); |
---|
| 1467 | } |
---|
| 1468 | elseif((isset($_POST['delete_type']) && $_POST['delete_type'] == 'series') || !isset($_POST['delete_type'])) |
---|
| 1469 | { |
---|
| 1470 | $cd = $this->bo->delete_entry($cal_id); |
---|
| 1471 | $this->bo->expunge(); |
---|
| 1472 | } |
---|
| 1473 | } |
---|
| 1474 | else |
---|
| 1475 | { |
---|
| 1476 | $cd = ''; |
---|
| 1477 | } |
---|
| 1478 | if ($this->bo->return_to) |
---|
| 1479 | { |
---|
| 1480 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 1481 | } |
---|
| 1482 | else |
---|
| 1483 | { |
---|
| 1484 | Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); |
---|
| 1485 | } |
---|
| 1486 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1487 | } |
---|
| 1488 | |
---|
| 1489 | function disponibility($params) { |
---|
| 1490 | |
---|
| 1491 | if(!isset($_SESSION['phpgw_info']['expresso']['expressoAdmin'])) { |
---|
| 1492 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
| 1493 | $c->read_repository(); |
---|
| 1494 | $current_config = $c->config_data; |
---|
| 1495 | |
---|
| 1496 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 1497 | |
---|
| 1498 | $_SESSION['phpgw_info']['expresso']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 1499 | $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 1500 | $_SESSION['phpgw_info']['expresso']['cc_ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 1501 | $_SESSION['phpgw_info']['expresso']['expressoAdmin'] = $current_config; |
---|
| 1502 | $_SESSION['phpgw_info']['expresso']['global_denied_users'] = $GLOBALS['phpgw_info']['server']['global_denied_users']; |
---|
| 1503 | $_SESSION['phpgw_info']['expresso']['global_denied_groups'] = $GLOBALS['phpgw_info']['server']['global_denied_groups']; |
---|
| 1504 | } |
---|
| 1505 | $str_participants = substr($_GET['participants'],0,strlen($_GET['participants'])-1); //remove the last comma |
---|
| 1506 | $participants= array(); |
---|
| 1507 | |
---|
| 1508 | $participants_splited = explode(",",$str_participants); |
---|
| 1509 | foreach($participants_splited as $participant) { |
---|
| 1510 | $participant = substr($participant,0,strlen($participant)-1); |
---|
| 1511 | $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$participant); |
---|
| 1512 | if($acct_type=='g') { |
---|
| 1513 | $bo_groups = CreateObject('expressoAdmin1_2.group'); |
---|
| 1514 | $users = $bo_groups->get_info($participant,true); |
---|
| 1515 | foreach($users['memberuid_info'] as $user) { |
---|
| 1516 | if($user['type']==u) |
---|
| 1517 | $participants[$user['uidnumber']] = 'U'; |
---|
| 1518 | } |
---|
| 1519 | } |
---|
| 1520 | else { |
---|
| 1521 | $participants[$participant] = 'U'; |
---|
| 1522 | } |
---|
| 1523 | } |
---|
| 1524 | |
---|
| 1525 | $date = explode("/",$_GET['date']); |
---|
| 1526 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$date[1],$date[0],$date[2]) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 1527 | |
---|
| 1528 | echo $this->print_disponibility( |
---|
| 1529 | Array( |
---|
| 1530 | 'date' => $freetime, |
---|
| 1531 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 1532 | 'endtime' => 0, |
---|
| 1533 | 'participants' => $participants |
---|
| 1534 | ) |
---|
| 1535 | ); |
---|
| 1536 | |
---|
| 1537 | |
---|
| 1538 | } |
---|
| 1539 | |
---|
| 1540 | function print_disponibility($param) { |
---|
| 1541 | |
---|
| 1542 | $str = "<html><head> |
---|
| 1543 | <script type='text/javascript'> |
---|
| 1544 | |
---|
| 1545 | var start = null; |
---|
| 1546 | var end = null; |
---|
| 1547 | function set_time(hour,minute) { |
---|
| 1548 | //alert(start); |
---|
| 1549 | if(start == null) { |
---|
| 1550 | start = new Array(); |
---|
| 1551 | start[0] = hour; |
---|
| 1552 | start[1] = minute; |
---|
| 1553 | paint_interval(start,start,'#009ACD',true); |
---|
| 1554 | } |
---|
| 1555 | else if (end == null) { |
---|
| 1556 | end = new Array(); |
---|
| 1557 | end[0] = hour; |
---|
| 1558 | end[1] = minute; |
---|
| 1559 | if(is_lower(start,end)) |
---|
| 1560 | paint_interval(start,end,'#009ACD',true); |
---|
| 1561 | else { |
---|
| 1562 | paint_interval(end,start,'#009ACD',true); |
---|
| 1563 | temp = start; |
---|
| 1564 | start = end; |
---|
| 1565 | end = temp; |
---|
| 1566 | paint_interval(end,end,'#FFFFFF',false); |
---|
| 1567 | } |
---|
| 1568 | parent.document.getElementById('start_hour').value=start[0]; |
---|
| 1569 | parent.document.getElementById('start_minute').value=start[1]; |
---|
| 1570 | parent.document.getElementById('end_hour').value=end[0]; |
---|
| 1571 | parent.document.getElementById('end_minute').value=end[1]; |
---|
| 1572 | |
---|
| 1573 | } |
---|
| 1574 | else { |
---|
| 1575 | end = null; |
---|
| 1576 | start = new Array(); |
---|
| 1577 | start[0] = hour; |
---|
| 1578 | start[1] = minute; |
---|
| 1579 | repaint(); |
---|
| 1580 | |
---|
| 1581 | paint_interval(start,start,'#009ACD',true); |
---|
| 1582 | } |
---|
| 1583 | } |
---|
| 1584 | function paint_column(name_array,color,force) { |
---|
| 1585 | name = name_array[0]+'-'+name_array[1]; |
---|
| 1586 | if(navigator.userAgent.toLowerCase().indexOf('msie') == -1) {//firefox |
---|
| 1587 | for(var i in document.getElementsByName(name)) { |
---|
| 1588 | document.getElementsByName(name)[i].bgColor=color; |
---|
| 1589 | if(document.getElementsByName(name)[i].nodeType==1) { |
---|
| 1590 | if(document.getElementsByName(name)[i].innerHTML.indexOf('>-<')==-1 || force==true) |
---|
| 1591 | document.getElementsByName(name)[i].bgColor=color; |
---|
| 1592 | else |
---|
| 1593 | document.getElementsByName(name)[i].bgColor='".$this->theme['bg11']."'; |
---|
| 1594 | } |
---|
| 1595 | } |
---|
| 1596 | } |
---|
| 1597 | else {//I.E |
---|
| 1598 | cells = document.getElementsByTagName('td'); |
---|
| 1599 | for(var i=0;i<cells.length;i++) { |
---|
| 1600 | if(cells.item(i).name==name) { //getElementsByName in I.E is bugged |
---|
| 1601 | cells.item(i).bgColor=color; |
---|
| 1602 | if(cells.item(i).nodeType==1) { |
---|
| 1603 | if(cells.item(i).innerHTML.indexOf('>-<')==-1 || force==true) |
---|
| 1604 | cells.item(i).bgColor=color; |
---|
| 1605 | else |
---|
| 1606 | cells.item(i).bgColor='".$this->theme['bg11']."'; |
---|
| 1607 | } |
---|
| 1608 | } |
---|
| 1609 | } |
---|
| 1610 | } |
---|
| 1611 | } |
---|
| 1612 | |
---|
| 1613 | function repaint() { |
---|
| 1614 | temp_start = new Array(); |
---|
| 1615 | temp_start[0] = 8; |
---|
| 1616 | temp_start[1] = 0; |
---|
| 1617 | temp_end = new Array(); |
---|
| 1618 | temp_end[0] = 19; |
---|
| 1619 | temp_end[1] = 0; |
---|
| 1620 | paint_interval(temp_start,temp_end,'#FFFFFF',false); |
---|
| 1621 | } |
---|
| 1622 | |
---|
| 1623 | //Considera sempre name1 <= name2 |
---|
| 1624 | function paint_interval(name1,name2,color,force) { |
---|
| 1625 | paint_column(name1,color,force); |
---|
| 1626 | if(name1[0]!=name2[0] || name1[1]!=name2[1]) { |
---|
| 1627 | paint_column(name1,color,force); |
---|
| 1628 | tempHour = name1[0]; |
---|
| 1629 | tempMinute = name1[1]; |
---|
| 1630 | while(tempHour<name2[0]) { |
---|
| 1631 | if(tempHour==name1[0] && tempMinute!=0) |
---|
| 1632 | temp_start = tempMinute/30; |
---|
| 1633 | else |
---|
| 1634 | temp_start = 0; |
---|
| 1635 | for(i=temp_start;i<60/30;i++) { |
---|
| 1636 | temp_column = new Array(); |
---|
| 1637 | temp_column[0] = tempHour; |
---|
| 1638 | temp_column[1] = i*30; |
---|
| 1639 | paint_column(temp_column,color,force); |
---|
| 1640 | } |
---|
| 1641 | tempHour++; |
---|
| 1642 | } |
---|
| 1643 | for(i=0;i<name2[1];i+=30) { |
---|
| 1644 | temp_column = new Array(); |
---|
| 1645 | temp_column[0] = name2[0]; |
---|
| 1646 | temp_column[1] = i; |
---|
| 1647 | paint_column(temp_column,color,force); |
---|
| 1648 | } |
---|
| 1649 | } |
---|
| 1650 | } |
---|
| 1651 | |
---|
| 1652 | function is_lower(array1,array2) { |
---|
| 1653 | if(array1[0]<array2[0]) |
---|
| 1654 | return true; |
---|
| 1655 | else if(array1[0]>array2[0]) |
---|
| 1656 | return false; |
---|
| 1657 | else { |
---|
| 1658 | if(array1[1]<array2[1]) |
---|
| 1659 | return true; |
---|
| 1660 | else |
---|
| 1661 | return false; |
---|
| 1662 | } |
---|
| 1663 | } |
---|
| 1664 | </script></head><body> |
---|
| 1665 | "; |
---|
| 1666 | |
---|
| 1667 | $str.= "<table border=\'1\' bgcolor=\"#FFFFFF\" width=\"100%\" height=\"100%\"><tr><td>"; |
---|
| 1668 | |
---|
| 1669 | |
---|
| 1670 | if(!is_array($param)) |
---|
| 1671 | { |
---|
| 1672 | $this->index(); |
---|
| 1673 | } |
---|
| 1674 | |
---|
| 1675 | $date = $param['date']; |
---|
| 1676 | $starttime = $param['starttime']; |
---|
| 1677 | $endtime = $param['endtime']; |
---|
| 1678 | $participants = $param['participants']; |
---|
| 1679 | foreach($participants as $part => $nul) |
---|
| 1680 | { |
---|
| 1681 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
| 1682 | // Much better for processor :) |
---|
| 1683 | $participants_id[] .= $part; |
---|
| 1684 | } |
---|
| 1685 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
| 1686 | |
---|
| 1687 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
| 1688 | { |
---|
| 1689 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
| 1690 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
| 1691 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 1692 | } |
---|
| 1693 | if($this->bo->prefs['calendar']['interval'] == '42') |
---|
| 1694 | { |
---|
| 1695 | $increment = 30; |
---|
| 1696 | } |
---|
| 1697 | elseif($this->bo->prefs['calendar']['interval'] == '84') |
---|
| 1698 | { |
---|
| 1699 | $increment = 15; |
---|
| 1700 | } |
---|
| 1701 | $interval = (int)(60 / $increment); |
---|
| 1702 | |
---|
| 1703 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
| 1704 | |
---|
| 1705 | $str .= '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
| 1706 | . ', '.$this->bo->long_date($date).'<br>' |
---|
| 1707 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((10 * $interval) + 1).'">' |
---|
| 1708 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
| 1709 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
| 1710 | for($i=8;$i<19;$i++) |
---|
| 1711 | { |
---|
| 1712 | for($j=0;$j<$interval;$j++) |
---|
| 1713 | { |
---|
| 1714 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
| 1715 | |
---|
| 1716 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'" onclick="set_time('.$i.','.($j*$increment).')" style="cursor:hand;cursor:pointer"> |
---|
| 1717 | <font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' . $k." </font></td>\n"; |
---|
| 1718 | } |
---|
| 1719 | } |
---|
| 1720 | $str .= '</tr>' |
---|
| 1721 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
| 1722 | if(!$endtime) |
---|
| 1723 | { |
---|
| 1724 | $endtime = $starttime; |
---|
| 1725 | } |
---|
| 1726 | $owner = $this->bo->owner; |
---|
| 1727 | foreach($participants as $part => $fullname) |
---|
| 1728 | { |
---|
| 1729 | $str .= '<tr align="center">' |
---|
| 1730 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
| 1731 | |
---|
| 1732 | $this->bo->cached_events = Array(); |
---|
| 1733 | $this->bo->so->owner = $part; |
---|
| 1734 | $this->bo->so->open_box($part); |
---|
| 1735 | $this->bo->store_to_cache( |
---|
| 1736 | Array( |
---|
| 1737 | 'syear' => $date['year'], |
---|
| 1738 | 'smonth'=> $date['month'], |
---|
| 1739 | 'sday' => $date['day'], |
---|
| 1740 | 'eyear' => 0, |
---|
| 1741 | 'emonth'=> 0, |
---|
| 1742 | 'eday' => $date['day'] + 1 |
---|
| 1743 | ) |
---|
| 1744 | ); |
---|
| 1745 | |
---|
| 1746 | if(!$this->bo->cached_events[$date['full']]) |
---|
| 1747 | { |
---|
| 1748 | for($j=8;$j<19;$j++) |
---|
| 1749 | { |
---|
| 1750 | for($k=0;$k<$interval;$k++) |
---|
| 1751 | { |
---|
| 1752 | // $helper_name = $k* |
---|
| 1753 | $str .= '<td name="'.$j.'-'.($k*$increment).'" height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
| 1754 | } |
---|
| 1755 | $str .= "\n"; |
---|
| 1756 | } |
---|
| 1757 | } |
---|
| 1758 | else |
---|
| 1759 | { |
---|
| 1760 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
| 1761 | for($h=8;$h<19;$h++) |
---|
| 1762 | { |
---|
| 1763 | $hour = $h * 10000; |
---|
| 1764 | for($m=0;$m<$interval;$m++) |
---|
| 1765 | { |
---|
| 1766 | $index = ($hour + (($m * $increment) * 100)); |
---|
| 1767 | switch($time_slice[$index]['marker']) |
---|
| 1768 | { |
---|
| 1769 | case ' ': |
---|
| 1770 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
| 1771 | //$extra = ''; |
---|
| 1772 | break; |
---|
| 1773 | case '-': |
---|
| 1774 | $time_slice[$index]['color'] = $this->theme['bg11']; |
---|
| 1775 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
| 1776 | //$extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
| 1777 | break; |
---|
| 1778 | } |
---|
| 1779 | $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>'; |
---|
| 1780 | } |
---|
| 1781 | $str .= "\n"; |
---|
| 1782 | } |
---|
| 1783 | } |
---|
| 1784 | $str .= '</tr>' |
---|
| 1785 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
| 1786 | } |
---|
| 1787 | $this->bo->owner = $owner; |
---|
| 1788 | $this->bo->so->owner = $owner; |
---|
| 1789 | $this->bo->so->open_box($owner); |
---|
| 1790 | $str.= "</table></center> \n </td></tr> |
---|
| 1791 | <tr><td onclick=\"parent.document.getElementById('disponibility').style.display='none'\" style='cursor:hand;cursor:pointer' align='center'>Fechar mapa</td></tr> |
---|
| 1792 | </table></body>"; |
---|
| 1793 | return $str; |
---|
| 1794 | } |
---|
| 1795 | |
---|
| 1796 | function day() |
---|
| 1797 | { |
---|
| 1798 | |
---|
| 1799 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 1,$this->bo->year); |
---|
| 1800 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 1,$this->bo->year); |
---|
| 1801 | |
---|
| 1802 | $this->bo->read_holidays(); |
---|
| 1803 | |
---|
| 1804 | $legend_holiday = $this->bo->cached_holidays[$_GET['date']][0]['name']?'('.$this->bo->cached_holidays[$_GET['date']][0]['name'].')':''; |
---|
| 1805 | if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) |
---|
| 1806 | { |
---|
| 1807 | $minical = $this->mini_calendar( |
---|
| 1808 | Array( |
---|
| 1809 | 'day' => 1, |
---|
| 1810 | 'month' => $this->bo->month, |
---|
| 1811 | 'year' => $this->bo->year, |
---|
| 1812 | 'link' => 'day', |
---|
| 1813 | 'control' => True, |
---|
| 1814 | 'outside_month' => False |
---|
| 1815 | ) |
---|
| 1816 | ); |
---|
| 1817 | $minical1 = $this->mini_calendar( |
---|
| 1818 | Array( |
---|
| 1819 | 'day' => 1, |
---|
| 1820 | 'month' => $this->bo->month+1, |
---|
| 1821 | 'year' => $this->bo->year, |
---|
| 1822 | 'link' => 'day', |
---|
| 1823 | 'control' => False, |
---|
| 1824 | 'outside_month' => False |
---|
| 1825 | ) |
---|
| 1826 | ); |
---|
| 1827 | $minical2 = $this->mini_calendar( |
---|
| 1828 | Array( |
---|
| 1829 | 'day' => 1, |
---|
| 1830 | 'month' => $this->bo->month+2, |
---|
| 1831 | 'year' => $this->bo->year, |
---|
| 1832 | 'link' => 'day', |
---|
| 1833 | 'control' => False, |
---|
| 1834 | 'outside_month' => False |
---|
| 1835 | ) |
---|
| 1836 | ); |
---|
| 1837 | } |
---|
| 1838 | else |
---|
| 1839 | { |
---|
| 1840 | |
---|
| 1841 | //NDEE: printer-friendly (what?) |
---|
| 1842 | $minical = ''; |
---|
| 1843 | } |
---|
| 1844 | |
---|
| 1845 | if(isset($_GET['date'])) |
---|
| 1846 | { |
---|
| 1847 | $dia = substr($_GET['date'],-2); |
---|
| 1848 | } |
---|
| 1849 | else |
---|
| 1850 | { |
---|
| 1851 | $dia = $_POST['day']; |
---|
| 1852 | } |
---|
| 1853 | |
---|
| 1854 | if (!$this->bo->printer_friendly) |
---|
| 1855 | { |
---|
| 1856 | $printer = ''; |
---|
| 1857 | $prev_day_link = '<a href="'.$this->page('day','&date='.$prev['full']).'"><<</a>'; |
---|
| 1858 | $next_day_link = '<a href="'.$this->page('day','&date='.$next['full']).'">>></a>'; |
---|
| 1859 | //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$dia.'&num_dias=1'.'&d=1'; |
---|
| 1860 | //$print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). |
---|
| 1861 | // "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
| 1862 | // lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
| 1863 | } |
---|
| 1864 | else |
---|
| 1865 | { |
---|
| 1866 | |
---|
| 1867 | //NDEE: printer-friendly (daily-view) |
---|
| 1868 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
| 1869 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
| 1870 | //$print = ''; |
---|
| 1871 | } |
---|
| 1872 | $print = '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; |
---|
| 1873 | |
---|
| 1874 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$dia.'&num_dias=1'.'&d=1'; |
---|
| 1875 | |
---|
| 1876 | $now = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); |
---|
| 1877 | $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 1878 | |
---|
| 1879 | $week_days = array(lang('Sunday'), |
---|
| 1880 | lang('Monday'), |
---|
| 1881 | lang('Tuesday'), |
---|
| 1882 | lang('Wednesday'), |
---|
| 1883 | lang('Thursday'), |
---|
| 1884 | lang('Friday'), |
---|
| 1885 | lang('Saturday')); |
---|
| 1886 | |
---|
| 1887 | $p = $GLOBALS['phpgw']->template; |
---|
| 1888 | $p->set_file( |
---|
| 1889 | Array( |
---|
| 1890 | 'day_t' => 'day.tpl' |
---|
| 1891 | ) |
---|
| 1892 | ); |
---|
| 1893 | $p->set_block('day_t','day','day'); |
---|
| 1894 | $p->set_block('day_t','day_event','day_event'); |
---|
| 1895 | |
---|
| 1896 | $todos = $this->get_todos($todo_label); |
---|
| 1897 | $var = Array( |
---|
| 1898 | 'printer_friendly' => $printer, |
---|
| 1899 | 'bg_text' => $this->theme['bg_text'], |
---|
| 1900 | 'daily_events' => $this->print_day_new( |
---|
| 1901 | Array( |
---|
| 1902 | 'year' => $this->bo->year, |
---|
| 1903 | 'month' => $this->bo->month, |
---|
| 1904 | 'day' => $this->bo->day |
---|
| 1905 | ) |
---|
| 1906 | ), |
---|
| 1907 | 'small_calendar' => $minical.'<br/>'.$minical1.'<br/>'.$minical2, |
---|
| 1908 | 'date' => $this->bo->long_date($now) . $legend_holiday, |
---|
| 1909 | 'day_of_week' => $week_days[$now['dow']], |
---|
| 1910 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
| 1911 | 'prev_day_link' => $prev_day_link, |
---|
| 1912 | 'next_day_link' => $next_day_link, |
---|
| 1913 | 'iprint' => $print, |
---|
| 1914 | 'param' => $param, |
---|
| 1915 | 'lang_todos' => $todo_label, |
---|
| 1916 | 'todos' => $this->bo->printer_friendly ? $todos : |
---|
| 1917 | |
---|
| 1918 | //NDEE: todo's layout |
---|
| 1919 | "<div style=\"overflow: auto; max-height: 200px\">\n$todos</div>\n" |
---|
| 1920 | ); |
---|
| 1921 | |
---|
| 1922 | $p->set_var($var); |
---|
| 1923 | $p->parse('day_events','day_event'); |
---|
| 1924 | echo $this->printer_friendly($p->fp('out','day'),lang('Dayview')); |
---|
| 1925 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 1926 | } |
---|
| 1927 | |
---|
| 1928 | function get_todos(&$todo_label) |
---|
| 1929 | { |
---|
| 1930 | $todos_from_hook = $GLOBALS['phpgw']->hooks->process(array( |
---|
| 1931 | 'location' => 'calendar_include_todos', |
---|
| 1932 | 'year' => $this->bo->year, |
---|
| 1933 | 'month' => $this->bo->month, |
---|
| 1934 | 'day' => $this->bo->day, |
---|
| 1935 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
| 1936 | )); |
---|
| 1937 | |
---|
| 1938 | if(is_array($todo_label)) |
---|
| 1939 | { |
---|
| 1940 | list($label,$showall)=$todo_label; |
---|
| 1941 | } |
---|
| 1942 | else |
---|
| 1943 | { |
---|
| 1944 | $label=$todo_label; |
---|
| 1945 | $showall=true; |
---|
| 1946 | } |
---|
| 1947 | $maxshow = (int)$GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
---|
| 1948 | if($maxshow<=0) |
---|
| 1949 | { |
---|
| 1950 | $maxshow=10; |
---|
| 1951 | } |
---|
| 1952 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
---|
| 1953 | |
---|
| 1954 | $content = $todo_label = ''; |
---|
| 1955 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
---|
| 1956 | { |
---|
| 1957 | $todo_label = !empty($label)?$label:lang("open ToDo's:"); |
---|
| 1958 | |
---|
| 1959 | foreach($todos_from_hook as $todos) |
---|
| 1960 | { |
---|
| 1961 | $i = 0; |
---|
| 1962 | if (is_array($todos) && count($todos)) |
---|
| 1963 | { |
---|
| 1964 | foreach($todos as $todo) |
---|
| 1965 | { |
---|
| 1966 | if(!$showall && ($i++>$maxshow)) |
---|
| 1967 | { |
---|
| 1968 | break; |
---|
| 1969 | } |
---|
| 1970 | $icons = ''; |
---|
| 1971 | foreach($todo['icons'] as $name => $app) |
---|
| 1972 | { |
---|
| 1973 | $icons .= ($icons?' ':'').$GLOBALS['phpgw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"'); |
---|
| 1974 | } |
---|
| 1975 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
---|
| 1976 | |
---|
| 1977 | //NDEE <tr starts here |
---|
| 1978 | $content .= " <tr id=\"debug\" class=\"$class\">\n <td valign=\"top\" width=\"15%\"nowrap>". |
---|
| 1979 | ($this->bo->printer_friendly?$icons:$GLOBALS['phpgw']->html->a_href($icons,$todo['view'])). |
---|
| 1980 | "</td>\n <td>".($this->bo->printer_friendly?$todo['title']: |
---|
| 1981 | $GLOBALS['phpgw']->html->a_href($todo['title'],$todo['view']))."</td>\n </tr>\n"; |
---|
| 1982 | } |
---|
| 1983 | } |
---|
| 1984 | } |
---|
| 1985 | } |
---|
| 1986 | if (!empty($content)) |
---|
| 1987 | { |
---|
| 1988 | return "<table border=\"0\" width=\"100%\">\n$content</table>\n"; |
---|
| 1989 | } |
---|
| 1990 | return False; |
---|
| 1991 | } |
---|
| 1992 | |
---|
| 1993 | function edit_status() |
---|
| 1994 | { |
---|
| 1995 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1996 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1997 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 1998 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 1999 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Change Status'); |
---|
| 2000 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2001 | |
---|
| 2002 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
| 2003 | |
---|
| 2004 | reset($event['participants']); |
---|
| 2005 | |
---|
| 2006 | if(!$event['participants'][$this->bo->owner]) |
---|
| 2007 | { |
---|
| 2008 | echo '<center>'.lang('The user %1 is not participating in this event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)).'</center>'; |
---|
| 2009 | return; |
---|
| 2010 | } |
---|
| 2011 | |
---|
| 2012 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 2013 | { |
---|
| 2014 | $this->no_edit(); |
---|
| 2015 | return; |
---|
| 2016 | } |
---|
| 2017 | |
---|
| 2018 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 2019 | echo $this->timematrix( |
---|
| 2020 | Array( |
---|
| 2021 | 'date' => $freetime, |
---|
| 2022 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 2023 | 'endtime' => 0, |
---|
| 2024 | 'participants' => $event['participants'] |
---|
| 2025 | ) |
---|
| 2026 | ).'<br>'; |
---|
| 2027 | |
---|
| 2028 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
| 2029 | $this->view_event($event); |
---|
| 2030 | $GLOBALS['phpgw']->template->pfp('phpgw_body','view_event'); |
---|
| 2031 | |
---|
| 2032 | echo $this->get_response($event['id']); |
---|
| 2033 | } |
---|
| 2034 | |
---|
| 2035 | function confirm_action($duplicated_action) |
---|
| 2036 | { |
---|
| 2037 | if($_GET['response'] == 1) |
---|
| 2038 | { |
---|
| 2039 | if(!$duplicated_action) |
---|
| 2040 | $notify_message = lang('The commitment was accepted successfully!'); |
---|
| 2041 | else |
---|
| 2042 | $notify_message = lang('This commitment has already been accepted!'); |
---|
| 2043 | } |
---|
| 2044 | else |
---|
| 2045 | { |
---|
| 2046 | if(!$duplicated_action) |
---|
| 2047 | $notify_message = lang('The commitment was rejected successfully!'); |
---|
| 2048 | else |
---|
| 2049 | $notify_message = lang('This commitment has already been rejected!'); |
---|
| 2050 | } |
---|
| 2051 | |
---|
| 2052 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 2053 | $body1->set_file(Array('calendar' => 'confirm.tpl')); |
---|
| 2054 | $body1->set_block('calendar','list'); |
---|
| 2055 | $var = Array( 'notify_message' => $notify_message); |
---|
| 2056 | $body1->set_var($var); |
---|
| 2057 | $tmpbody1 = $body1->pfp('out','list'); |
---|
| 2058 | } |
---|
| 2059 | |
---|
| 2060 | function confirm_conflict($user_id,$event,$overlapping_events) |
---|
| 2061 | { |
---|
| 2062 | if(!$overlapping_events){ |
---|
| 2063 | $notify_message = lang('This event conflicts with your other event.'); |
---|
| 2064 | |
---|
| 2065 | $action_ignore = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'response' => 1,'user_id' => $user_id, 'ignore_conflict' => 1)); |
---|
| 2066 | $action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0)); |
---|
| 2067 | |
---|
| 2068 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 2069 | $body1->set_file(Array('calendar' => 'conflict.tpl')); |
---|
| 2070 | $body1->set_block('calendar','list'); |
---|
| 2071 | $var = Array( 'notify_message' => $notify_message, |
---|
| 2072 | 'action_url' => $action_url, |
---|
| 2073 | 'ignore_conflict' => 'Ignorar Conflito', |
---|
| 2074 | 'reject_event' => 'Rejeitar Evento', |
---|
| 2075 | 'action_reject' => $action_reject, |
---|
| 2076 | 'action_ignore' => $action_ignore); |
---|
| 2077 | $body1->set_var($var); |
---|
| 2078 | $tmpbody1 = $body1->pfp('out','list'); |
---|
| 2079 | } |
---|
| 2080 | else |
---|
| 2081 | { |
---|
| 2082 | $month = $event['start']['month']; |
---|
| 2083 | $mday = $event['start']['mday']; |
---|
| 2084 | $year = $event['start']['year']; |
---|
| 2085 | |
---|
| 2086 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2087 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2088 | |
---|
| 2089 | $overlap = ''; |
---|
| 2090 | for($i=0;$i<count($overlapping_events);$i++) |
---|
| 2091 | { |
---|
| 2092 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
| 2093 | foreach($overlapped_event['participants'] as $id => $status) |
---|
| 2094 | { |
---|
| 2095 | $conflict = isset($event['participants'][$user_id]); |
---|
| 2096 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
| 2097 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
| 2098 | ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; |
---|
| 2099 | } |
---|
| 2100 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
| 2101 | $overlap .= '<ul><font size="1"><span>'. |
---|
| 2102 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
| 2103 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
| 2104 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
| 2105 | $this->normDec($overlapped_event['end']['min']). |
---|
| 2106 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
| 2107 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
| 2108 | else |
---|
| 2109 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>"; |
---|
| 2110 | } |
---|
| 2111 | |
---|
| 2112 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2113 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2114 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 2115 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 2116 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
| 2117 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2118 | |
---|
| 2119 | $p = $GLOBALS['phpgw']->template; |
---|
| 2120 | $p->set_file( |
---|
| 2121 | Array( |
---|
| 2122 | 'overlap' => 'overlap.tpl', |
---|
| 2123 | 'form_button' => 'form_button_script.tpl' |
---|
| 2124 | ) |
---|
| 2125 | ); |
---|
| 2126 | |
---|
| 2127 | $var = Array( |
---|
| 2128 | 'color' => $this->theme['bg_text'], |
---|
| 2129 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
| 2130 | '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)), |
---|
| 2131 | 'overlap_list' => $overlap |
---|
| 2132 | ); |
---|
| 2133 | $p->set_var($var); |
---|
| 2134 | |
---|
| 2135 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
| 2136 | $var = Array( |
---|
| 2137 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'user_id' => $user_id, 'ignore_conflict' => 1)), |
---|
| 2138 | 'action_text_button' => lang('Ignore Conflict'), |
---|
| 2139 | 'action_confirm_button' => '', |
---|
| 2140 | 'action_extra_field' => '', |
---|
| 2141 | 'button_id' => 'ignore_button' |
---|
| 2142 | ); |
---|
| 2143 | $action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0)); |
---|
| 2144 | |
---|
| 2145 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
| 2146 | |
---|
| 2147 | $var = Array( |
---|
| 2148 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0)), |
---|
| 2149 | 'action_text_button' => lang('Reject'), |
---|
| 2150 | 'action_confirm_button' => '', |
---|
| 2151 | 'action_extra_field' => '', |
---|
| 2152 | 'button_id' => 'redit_button' |
---|
| 2153 | ); |
---|
| 2154 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
| 2155 | $p->pparse('out','overlap'); |
---|
| 2156 | } |
---|
| 2157 | } |
---|
| 2158 | |
---|
| 2159 | function set_action() |
---|
| 2160 | { |
---|
| 2161 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
| 2162 | { |
---|
| 2163 | $this->no_edit(); |
---|
| 2164 | return; |
---|
| 2165 | } |
---|
| 2166 | |
---|
| 2167 | $overlapping_events = false; |
---|
| 2168 | $event = $this->bo->read_entry((int)$_GET['cal_id']); |
---|
| 2169 | if((!$_GET['response'] == 0 && !$_GET['ignore_conflict'] == 1) || |
---|
| 2170 | (!isset($_GET['response']) && $_GET['action'] == 3 && !$_GET['ignore_conflict'] == 1)) |
---|
| 2171 | { |
---|
| 2172 | if($event['id']) |
---|
| 2173 | { |
---|
| 2174 | $event_ids[] = $event['id']; |
---|
| 2175 | } |
---|
| 2176 | if($event['reference']) |
---|
| 2177 | { |
---|
| 2178 | $event_ids[] = $event['reference']; |
---|
| 2179 | } |
---|
| 2180 | |
---|
| 2181 | //$event['participants'] = Array($_SESSION['phpgw_info']['expressomail']['user']['account_id'] => $event['participants'][$_SESSION['phpgw_info']['expressomail']['user']['account_id']]); |
---|
| 2182 | $event['participants'] = Array($GLOBALS['phpgw_info']['user']['account_id'] => $event['participants'][$GLOBALS['phpgw_info']['user']['account_id']]); |
---|
| 2183 | |
---|
| 2184 | $overlapping_events = $this->bo->overlap( |
---|
| 2185 | $this->bo->maketime($event['start']), |
---|
| 2186 | $this->bo->maketime($event['end']), |
---|
| 2187 | $event['participants'], |
---|
| 2188 | $event['owner'], |
---|
| 2189 | $event_ids |
---|
| 2190 | ); |
---|
| 2191 | } |
---|
| 2192 | |
---|
| 2193 | if(isset($_GET['response'])) |
---|
| 2194 | { |
---|
| 2195 | if($overlapping_events) |
---|
| 2196 | { |
---|
| 2197 | $this->confirm_conflict($_GET['user_id'],$event); |
---|
| 2198 | }else |
---|
| 2199 | { |
---|
| 2200 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); |
---|
| 2201 | $this->confirm_action($confirm_status); |
---|
| 2202 | $GLOBALS['phpgw']->common->phpgw_exit(False); |
---|
| 2203 | } |
---|
| 2204 | }else |
---|
| 2205 | { |
---|
| 2206 | if($overlapping_events) |
---|
| 2207 | { |
---|
| 2208 | $this->confirm_conflict($_GET['user_id'],$event,$overlapping_events); |
---|
| 2209 | }else |
---|
| 2210 | { |
---|
| 2211 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); |
---|
| 2212 | if ($this->bo->return_to) |
---|
| 2213 | { |
---|
| 2214 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
| 2215 | } |
---|
| 2216 | else |
---|
| 2217 | { |
---|
| 2218 | Header('Location: '.$this->page('','')); |
---|
| 2219 | } |
---|
| 2220 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 2221 | } |
---|
| 2222 | } |
---|
| 2223 | |
---|
| 2224 | |
---|
| 2225 | } |
---|
| 2226 | function planner() |
---|
| 2227 | { |
---|
| 2228 | if(floor(phpversion()) < 4) |
---|
| 2229 | { |
---|
| 2230 | return; |
---|
| 2231 | } |
---|
| 2232 | $home = strstr($_SERVER['PHP_SELF'],'home') !== False; |
---|
| 2233 | // generate header and set global/member variables |
---|
| 2234 | // |
---|
| 2235 | $this->planner_prepare($home); |
---|
| 2236 | |
---|
| 2237 | // process events within selected interval |
---|
| 2238 | // |
---|
| 2239 | $this->planner_process_interval(); |
---|
| 2240 | |
---|
| 2241 | // generate the planner view |
---|
| 2242 | // |
---|
| 2243 | if (!$home) |
---|
| 2244 | { |
---|
| 2245 | echo '<p>'.$this->planner_print_rows(); |
---|
| 2246 | } |
---|
| 2247 | else |
---|
| 2248 | { |
---|
| 2249 | return $this->planner_print_rows(); |
---|
| 2250 | } |
---|
| 2251 | } |
---|
| 2252 | |
---|
| 2253 | function set_planner_group_members() |
---|
| 2254 | { |
---|
| 2255 | $type = $GLOBALS['phpgw']->accounts->get_type($this->bo->owner); |
---|
| 2256 | |
---|
| 2257 | if ($type == 'g') // display schedule of all group members |
---|
| 2258 | { |
---|
| 2259 | $members = array(); |
---|
| 2260 | $ids = $GLOBALS['phpgw']->acl->get_ids_for_location($this->bo->owner, 1, 'phpgw_group'); |
---|
| 2261 | while (list(,$id) = each($ids)) |
---|
| 2262 | { |
---|
| 2263 | if ($this->bo->check_perms(PHPGW_ACL_READ,0,$id)) |
---|
| 2264 | { |
---|
| 2265 | $members[$GLOBALS['phpgw']->common->grab_owner_name($id)] = $id; |
---|
| 2266 | } |
---|
| 2267 | } |
---|
| 2268 | ksort($members); |
---|
| 2269 | $this->planner_group_members = $members; |
---|
| 2270 | } |
---|
| 2271 | else |
---|
| 2272 | { |
---|
| 2273 | $this->planner_group_members = array( |
---|
| 2274 | $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) => $this->bo->owner |
---|
| 2275 | ); |
---|
| 2276 | } |
---|
| 2277 | } |
---|
| 2278 | |
---|
| 2279 | /** |
---|
| 2280 | * planner_prepare - prepare the planner view |
---|
| 2281 | * |
---|
| 2282 | * - sets global environment variables |
---|
| 2283 | * - initializes class member variables used in multiple planner related functions |
---|
| 2284 | * - generates header lines for the planner view (month, calendar week, days) |
---|
| 2285 | */ |
---|
| 2286 | function planner_prepare($no_header = False) |
---|
| 2287 | { |
---|
| 2288 | // set some globals |
---|
| 2289 | // |
---|
| 2290 | if (!$no_header) |
---|
| 2291 | { |
---|
| 2292 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2293 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2294 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner'); |
---|
| 2295 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2296 | } |
---|
| 2297 | |
---|
| 2298 | // intervals_per_day can be configured in preferences now :-) |
---|
| 2299 | // |
---|
| 2300 | if (! $this->bo->prefs['calendar']['planner_intervals_per_day']) |
---|
| 2301 | { |
---|
| 2302 | $GLOBALS['phpgw']->preferences->add('calendar','planner_intervals_per_day',3); |
---|
| 2303 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 2304 | $this->bo->prefs['calendar']['planner_intervals_per_day'] = 3; |
---|
| 2305 | } |
---|
| 2306 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2307 | $this->bo->save_sessiondata(); // need to save $this->bo->save_owner |
---|
| 2308 | |
---|
| 2309 | // set title for table and rows of planner view |
---|
| 2310 | // |
---|
| 2311 | if ($this->bo->sortby == 'category') |
---|
| 2312 | { |
---|
| 2313 | $title = lang('Category'); |
---|
| 2314 | } |
---|
| 2315 | else |
---|
| 2316 | { |
---|
| 2317 | $title = lang('User'); |
---|
| 2318 | |
---|
| 2319 | $this->set_planner_group_members(); |
---|
| 2320 | } |
---|
| 2321 | |
---|
| 2322 | // create/initialize variables directly used for HTML code generation |
---|
| 2323 | // |
---|
| 2324 | $this->planner_header = array(); |
---|
| 2325 | $this->planner_rows = array(); |
---|
| 2326 | |
---|
| 2327 | // generate header lines with days and associated months |
---|
| 2328 | // |
---|
| 2329 | $hdr = &$this->planner_header; |
---|
| 2330 | $hdr[0]['0'] = $title; |
---|
| 2331 | $hdr[0]['.0'] = 'rowspan="3"'; |
---|
| 2332 | |
---|
| 2333 | $this->planner_days = 0; // reset |
---|
| 2334 | |
---|
| 2335 | $m = $this->bo->month; |
---|
| 2336 | $y = $this->bo->year; |
---|
| 2337 | $this->bo->read_holidays($y); |
---|
| 2338 | for ($i=1; $i<=$this->bo->num_months; $i++,$m++) |
---|
| 2339 | { |
---|
| 2340 | if ($m == 13) |
---|
| 2341 | { |
---|
| 2342 | $m = 1; $y++; // "wrap-around" into new year |
---|
| 2343 | $this->bo->read_holidays($y); |
---|
| 2344 | } |
---|
| 2345 | $days = $GLOBALS['phpgw']->datetime->days_in_month($m,$y); |
---|
| 2346 | |
---|
| 2347 | $d = mktime(0,0,0,$m,1,$y); |
---|
| 2348 | $month = lang(date('F', $d)).strftime(' %Y', $d); |
---|
| 2349 | $color = $this->theme[$m % 2 || $this->bo->num_months == 1 ? 'th_bg' : 'row_on']; |
---|
| 2350 | $cols = $days * $intervals_per_day; |
---|
| 2351 | |
---|
| 2352 | $hdr[0]['.'.$i] = 'bgcolor="'.$color.'" colspan="'.$cols.'" align="center"'; |
---|
| 2353 | $prev_month = sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12); |
---|
| 2354 | $next_month = sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1); |
---|
| 2355 | $prev_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month"); |
---|
| 2356 | $next_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$next_month"); |
---|
| 2357 | $hdr[0][$i] = "<b><a href=\"$prev_link\"><<</a>   $month   <a href=\"$next_link\">>></a></b>"; |
---|
| 2358 | |
---|
| 2359 | $add_owner = array(); // if no add-rights on the showed cal use own cal |
---|
| 2360 | if (!$this->bo->save_owner && !$this->bo->check_perms(PHPGW_ACL_ADD) || |
---|
| 2361 | !$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner)) |
---|
| 2362 | { |
---|
| 2363 | $add_owner = array( |
---|
| 2364 | 'owner' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 2365 | ); |
---|
| 2366 | } |
---|
| 2367 | for ($d=1; $d<=$days; $d++) |
---|
| 2368 | { |
---|
| 2369 | $dayname = substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2); |
---|
| 2370 | $index = $d + $this->planner_days; |
---|
| 2371 | |
---|
| 2372 | $hdr[2]['.'.$index] = 'colspan="'.$intervals_per_day.'" align="center"'; |
---|
| 2373 | |
---|
| 2374 | // highlight today, saturday, sunday and holidays |
---|
| 2375 | // |
---|
| 2376 | $color = $this->theme['row_off']; |
---|
| 2377 | $dow = $GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d); |
---|
| 2378 | $date = sprintf("%04d%02d%02d",$y,$m,$d); |
---|
| 2379 | if ($date == date('Ymd')) |
---|
| 2380 | { |
---|
| 2381 | $color = $GLOBALS['phpgw_info']['theme']['cal_today']; |
---|
| 2382 | } |
---|
| 2383 | elseif ($this->bo->cached_holidays[$date]) |
---|
| 2384 | { |
---|
| 2385 | $color = $this->bo->holiday_color; |
---|
| 2386 | $hdr[2]['.'.$index] .= ' title="'.$this->bo->cached_holidays[$date][0]['name'].'"'; |
---|
| 2387 | } |
---|
| 2388 | elseif ($dow == 0 || $dow == 6) |
---|
| 2389 | { |
---|
| 2390 | $color = $this->bo->theme['th_bg']; |
---|
| 2391 | } |
---|
| 2392 | |
---|
| 2393 | $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; |
---|
| 2394 | |
---|
| 2395 | $hdr[2][$index] = '<a href="'.$this->html->link('/index.php', |
---|
| 2396 | array( |
---|
| 2397 | 'menuaction' => 'calendar.uicalendar.add', |
---|
| 2398 | 'date' => $date |
---|
| 2399 | ) + $add_owner |
---|
| 2400 | ).'">'.$dayname.'<br>'.$d.'</a>'; |
---|
| 2401 | } |
---|
| 2402 | $this->planner_days += $days; |
---|
| 2403 | } |
---|
| 2404 | |
---|
| 2405 | // create/initialize member variables describing the time interval to be displayed |
---|
| 2406 | // |
---|
| 2407 | $this->planner_end_month = $m - 1; |
---|
| 2408 | $this->planner_end_year = $y; |
---|
| 2409 | $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); |
---|
| 2410 | $this->planner_firstday = (int)(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); |
---|
| 2411 | $this->planner_lastday = (int)(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); |
---|
| 2412 | |
---|
| 2413 | // generate line with calendar weeks in observed interval |
---|
| 2414 | // |
---|
| 2415 | $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 2416 | $w = date('W', $d); |
---|
| 2417 | if ($w == 'W') // php < 4.1 |
---|
| 2418 | { |
---|
| 2419 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
| 2420 | } |
---|
| 2421 | $offset = (7-date('w', $d)+1)%7; |
---|
| 2422 | $offset = $offset == 0 ? 7 : $offset; |
---|
| 2423 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
| 2424 | |
---|
| 2425 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$intervals_per_day * $offset.'" align="left"'; |
---|
| 2426 | $hdr[1][$w] = ''; |
---|
| 2427 | if ($offset >= 3) |
---|
| 2428 | { |
---|
| 2429 | |
---|
| 2430 | //NDEE: style! (groupplanner) |
---|
| 2431 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
| 2432 | } |
---|
| 2433 | $days_left = $this->planner_days - $offset; |
---|
| 2434 | |
---|
| 2435 | $colspan = 7 * $intervals_per_day; |
---|
| 2436 | while ($days_left > 0) |
---|
| 2437 | { |
---|
| 2438 | $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; |
---|
| 2439 | $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each |
---|
| 2440 | $w = date('W', $d); |
---|
| 2441 | if ($w == 'W') // php < 4.1 |
---|
| 2442 | { |
---|
| 2443 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
| 2444 | } |
---|
| 2445 | $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? |
---|
| 2446 | |
---|
| 2447 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
| 2448 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$colspan.'" align="left"'; |
---|
| 2449 | $hdr[1][$w] = ''; |
---|
| 2450 | if ($days_left >= 3) |
---|
| 2451 | { |
---|
| 2452 | |
---|
| 2453 | //NDEE: style! (groupplanner) |
---|
| 2454 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
| 2455 | } |
---|
| 2456 | |
---|
| 2457 | $days_left -= 7; |
---|
| 2458 | } |
---|
| 2459 | return $hdr; |
---|
| 2460 | } |
---|
| 2461 | |
---|
| 2462 | /** |
---|
| 2463 | * planner_update_row - update a row of the planner view |
---|
| 2464 | * |
---|
| 2465 | * parameters are: |
---|
| 2466 | * - index (e.g. user id, category id, ...) of the row |
---|
| 2467 | * - name/title of the row (e.g. user name, category name) |
---|
| 2468 | * - the event to be integrated |
---|
| 2469 | * - list of categories associated with the event |
---|
| 2470 | * - first and last cell of the row |
---|
| 2471 | */ |
---|
| 2472 | function planner_update_row($index,$name,$event,$cat,$start_cell,$end_cell) |
---|
| 2473 | { |
---|
| 2474 | $rows = &$this->planner_rows; |
---|
| 2475 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2476 | $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 2477 | |
---|
| 2478 | $view = $this->html->link('/index.php', |
---|
| 2479 | array( |
---|
| 2480 | 'menuaction' => 'calendar.uicalendar.view', |
---|
| 2481 | 'cal_id' => $event['id'], |
---|
| 2482 | 'date' => date('Ymd',$this->bo->maketime($event['start'])) |
---|
| 2483 | ) |
---|
| 2484 | ); |
---|
| 2485 | |
---|
| 2486 | // check how many lines are needed for this "row" (currently: user or category) |
---|
| 2487 | $i = 0; |
---|
| 2488 | do { |
---|
| 2489 | ++$i; |
---|
| 2490 | |
---|
| 2491 | $k = $index.'_'.$i; |
---|
| 2492 | $ka = '.nr_'.$k; |
---|
| 2493 | |
---|
| 2494 | if (!isset($rows[$k])) |
---|
| 2495 | { |
---|
| 2496 | if ($i > 1) // further line - no name |
---|
| 2497 | { |
---|
| 2498 | $rows[$k] = array(); |
---|
| 2499 | $rows[$index.'_1']['._name'] = 'rowspan="'.$i.'"'; |
---|
| 2500 | } |
---|
| 2501 | else |
---|
| 2502 | { |
---|
| 2503 | $rows[$k]['_name'] = $name; |
---|
| 2504 | } |
---|
| 2505 | $rows[$ka] = 0; |
---|
| 2506 | } |
---|
| 2507 | $rows[$index.'_1']['._name'] .= ' nowrap'; // title must be one row |
---|
| 2508 | |
---|
| 2509 | $row = &$rows[$k]; |
---|
| 2510 | $akt_cell = &$rows[$ka]; |
---|
| 2511 | } while ($akt_cell > $start_cell); |
---|
| 2512 | |
---|
| 2513 | $id = $event['id'].'-'.date('Ymd',$this->bo->maketime($event['start'])); |
---|
| 2514 | if ($akt_cell < $start_cell) |
---|
| 2515 | { |
---|
| 2516 | $row[$id.'_1'] = ' '; |
---|
| 2517 | $row['.'.$id.'_1'] = 'colspan="'.($start_cell-$akt_cell).'"'; |
---|
| 2518 | } |
---|
| 2519 | $opt = &$row['.'.$id.'_2']; |
---|
| 2520 | $cel = &$row[$id.'_2']; |
---|
| 2521 | |
---|
| 2522 | // if possible, display information about event within cells representing it |
---|
| 2523 | // |
---|
| 2524 | if ($start_cell < $end_cell) |
---|
| 2525 | { |
---|
| 2526 | $colspan = $end_cell - $start_cell; |
---|
| 2527 | $opt .= "colspan=".(1 + $colspan); |
---|
| 2528 | |
---|
| 2529 | if (!$is_private) |
---|
| 2530 | { |
---|
| 2531 | $max_chars = (int)(3*$colspan/$intervals_per_day-2); |
---|
| 2532 | |
---|
| 2533 | $min_chars = 3; // minimum for max_chars to display -> this should be configurable |
---|
| 2534 | if ($max_chars >= $min_chars) |
---|
| 2535 | { |
---|
| 2536 | $len_title = strlen($event['title']); |
---|
| 2537 | |
---|
| 2538 | if ($len_title <= $max_chars) |
---|
| 2539 | { |
---|
| 2540 | $title = $event['title']; |
---|
| 2541 | $max_chars -= $len_title + 3; // 3 chars for separator: " - " |
---|
| 2542 | $len_descr = strlen($event['description']); |
---|
| 2543 | |
---|
| 2544 | if ($len_descr > 0 && $len_descr <= $max_chars) |
---|
| 2545 | { |
---|
| 2546 | $event['print_description'] = 'yes'; |
---|
| 2547 | } |
---|
| 2548 | } |
---|
| 2549 | else |
---|
| 2550 | { |
---|
| 2551 | $has_amp = strpos($event['title'],'&'); |
---|
| 2552 | |
---|
| 2553 | //NDEE: event title gets cut here |
---|
| 2554 | $title = substr($event['title'], 0 , $max_chars-1+($has_amp!==False&&$has_amp<$max_chars?4:0)).'...'; |
---|
| 2555 | } |
---|
| 2556 | $event['print_title'] = 'yes'; |
---|
| 2557 | } |
---|
| 2558 | } |
---|
| 2559 | } |
---|
| 2560 | |
---|
| 2561 | if ($bgcolor=$cat['color']) |
---|
| 2562 | { |
---|
| 2563 | $opt .= ' bgcolor="'.$bgcolor.'"'; |
---|
| 2564 | } |
---|
| 2565 | if (!$is_private) |
---|
| 2566 | { |
---|
| 2567 | $opt .= ' title="'.lang('Title').": ".$event['title']; |
---|
| 2568 | if ($event['description']) |
---|
| 2569 | { |
---|
| 2570 | $opt .= "\n".lang('Description').": ".$event['description']; |
---|
| 2571 | } |
---|
| 2572 | } |
---|
| 2573 | else |
---|
| 2574 | { |
---|
| 2575 | $opt .= ' title="'.lang('You do not have permission to read this record!'); |
---|
| 2576 | } |
---|
| 2577 | |
---|
| 2578 | $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 2579 | $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
| 2580 | $opt .= "\n".lang('Start Date/Time').": ".$start."\n".lang('End Date/Time').": ".$end; |
---|
| 2581 | |
---|
| 2582 | if ($event['location'] && !$is_private) |
---|
| 2583 | { |
---|
| 2584 | $opt .= " \n".lang('Location').": ".$event['location']; |
---|
| 2585 | } |
---|
| 2586 | |
---|
| 2587 | if (!$is_private) |
---|
| 2588 | { |
---|
| 2589 | $opt .= '" onClick="location=\''.$view.'\'"'; |
---|
| 2590 | $cel = '<a href="'.$view.'">'; |
---|
| 2591 | } |
---|
| 2592 | else |
---|
| 2593 | { |
---|
| 2594 | $opt .= '"'; |
---|
| 2595 | $cel = ''; |
---|
| 2596 | } |
---|
| 2597 | $opt .= ' class="planner-cell"'; |
---|
| 2598 | |
---|
| 2599 | if ($event['priority'] == 3) |
---|
| 2600 | { |
---|
| 2601 | $cel .= $this->html->image('calendar','mini-calendar-bar.gif','','border="0"'); |
---|
| 2602 | } |
---|
| 2603 | if ($event['recur_type']) |
---|
| 2604 | { |
---|
| 2605 | $cel .= $this->html->image('calendar','recur.gif','','border="0"'); |
---|
| 2606 | } |
---|
| 2607 | $cel .= $this->html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); |
---|
| 2608 | $cel .= '</a>'; |
---|
| 2609 | |
---|
| 2610 | if (isset($event['print_title']) && $event['print_title'] == 'yes') |
---|
| 2611 | { |
---|
| 2612 | |
---|
| 2613 | //NDEE: style! where? |
---|
| 2614 | $cel .= '<font size="-2"> '.$title.' </font>'; |
---|
| 2615 | } |
---|
| 2616 | if (isset($event['print_description']) && $event['print_description'] == 'yes') |
---|
| 2617 | { |
---|
| 2618 | |
---|
| 2619 | //NDEE: style! where ? |
---|
| 2620 | $cel .= '<font size="-2"> - '.$event['description'].' </font>'; |
---|
| 2621 | } |
---|
| 2622 | |
---|
| 2623 | $akt_cell = $end_cell + 1; |
---|
| 2624 | |
---|
| 2625 | return $rows; |
---|
| 2626 | } |
---|
| 2627 | |
---|
| 2628 | function planner_process_event($event) |
---|
| 2629 | { |
---|
| 2630 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2631 | $interval = $this->planner_intervals[$intervals_per_day]; |
---|
| 2632 | $last_cell = $intervals_per_day * $this->planner_days - 1; |
---|
| 2633 | |
---|
| 2634 | $rows = &$this->planner_rows; |
---|
| 2635 | |
---|
| 2636 | // caluculate start and end of event |
---|
| 2637 | // |
---|
| 2638 | $event_start = (int)(date('Ymd',mktime( |
---|
| 2639 | 0,0,0, |
---|
| 2640 | $event['start']['month'], |
---|
| 2641 | $event['start']['mday'], |
---|
| 2642 | $event['start']['year'] |
---|
| 2643 | ))); |
---|
| 2644 | $event_end = (int)(date('Ymd',mktime( |
---|
| 2645 | 0,0,0, |
---|
| 2646 | $event['end']['month'], |
---|
| 2647 | $event['end']['mday'], |
---|
| 2648 | $event['end']['year'] |
---|
| 2649 | ))); |
---|
| 2650 | |
---|
| 2651 | // calculate first cell of event within observed interval |
---|
| 2652 | // |
---|
| 2653 | if ($event_start >= $this->planner_firstday) |
---|
| 2654 | { |
---|
| 2655 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['start']['month'],$event['start']['mday'],$event['start']['year']); |
---|
| 2656 | |
---|
| 2657 | $start_cell = $intervals_per_day * $days_between + $interval[$event['start']['hour']]; |
---|
| 2658 | } |
---|
| 2659 | else |
---|
| 2660 | { |
---|
| 2661 | $start_cell = 0; |
---|
| 2662 | } |
---|
| 2663 | |
---|
| 2664 | // calculate last cell of event within observed interval |
---|
| 2665 | // |
---|
| 2666 | if ($event_end <= $this->planner_lastday) |
---|
| 2667 | { |
---|
| 2668 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']); |
---|
| 2669 | $end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']]; |
---|
| 2670 | if ($end_cell == $start_cell && $end_cell < $last_cell) |
---|
| 2671 | { |
---|
| 2672 | $end_cell++; // min. width 1 interval |
---|
| 2673 | } |
---|
| 2674 | } |
---|
| 2675 | else |
---|
| 2676 | { |
---|
| 2677 | $end_cell = $last_cell; |
---|
| 2678 | } |
---|
| 2679 | // get the categories associated with event |
---|
| 2680 | // |
---|
| 2681 | if ($c = $event['category']) |
---|
| 2682 | { |
---|
| 2683 | list($cat) = $this->planner_category($event['category']); |
---|
| 2684 | if ($cat['parent']) |
---|
| 2685 | { |
---|
| 2686 | list($pcat) = $this->planner_category($c = $cat['parent']); |
---|
| 2687 | } |
---|
| 2688 | else |
---|
| 2689 | { |
---|
| 2690 | $pcat = $cat; |
---|
| 2691 | } |
---|
| 2692 | } |
---|
| 2693 | else |
---|
| 2694 | { |
---|
| 2695 | $cat = $pcat = array( 'name' => lang('none')); |
---|
| 2696 | } |
---|
| 2697 | |
---|
| 2698 | // add the event to it`s associated row(s) |
---|
| 2699 | // |
---|
| 2700 | if ($this->bo->sortby == 'category') |
---|
| 2701 | { |
---|
| 2702 | // event needs to show up in it`s category`s row |
---|
| 2703 | // |
---|
| 2704 | $this->planner_update_row($c,$pcat['name'],$event,$cat,$start_cell,$end_cell); |
---|
| 2705 | } |
---|
| 2706 | elseif ($this->bo->sortby == 'user') |
---|
| 2707 | { |
---|
| 2708 | // event needs to show up in rows of all participants that are also owners |
---|
| 2709 | // |
---|
| 2710 | reset($this->planner_group_members); |
---|
| 2711 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
| 2712 | { |
---|
| 2713 | $status = $event['participants'][$id]; |
---|
| 2714 | |
---|
| 2715 | if (isset($status) && $status != 'R') |
---|
| 2716 | { |
---|
| 2717 | $this->planner_update_row($user_name,$user_name,$event,$cat,$start_cell,$end_cell); |
---|
| 2718 | } |
---|
| 2719 | } |
---|
| 2720 | } |
---|
| 2721 | } |
---|
| 2722 | |
---|
| 2723 | function planner_pad_rows() |
---|
| 2724 | { |
---|
| 2725 | $rows = &$this->planner_rows; |
---|
| 2726 | |
---|
| 2727 | if ($this->bo->sortby == 'user') |
---|
| 2728 | { |
---|
| 2729 | // add empty rows for users that do not participante in any event |
---|
| 2730 | // |
---|
| 2731 | reset($this->planner_group_members); |
---|
| 2732 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
| 2733 | { |
---|
| 2734 | $k = $user_name.'_1'; |
---|
| 2735 | $ka = '.nr_'.$k; |
---|
| 2736 | |
---|
| 2737 | if (!isset($rows[$k])) |
---|
| 2738 | { |
---|
| 2739 | $rows[$k]['_name'] = $user_name; |
---|
| 2740 | $rows[$k]['._name'] .= ' nowrap'; |
---|
| 2741 | $rows[$ka] = 0; |
---|
| 2742 | } |
---|
| 2743 | } |
---|
| 2744 | } |
---|
| 2745 | |
---|
| 2746 | // fill the remaining cols |
---|
| 2747 | // |
---|
| 2748 | $last_cell = $this->bo->prefs['calendar']['planner_intervals_per_day'] * $this->planner_days - 1; |
---|
| 2749 | |
---|
| 2750 | ksort($rows); |
---|
| 2751 | while (list($k,$r) = each($rows)) |
---|
| 2752 | { |
---|
| 2753 | if (is_array($r)) |
---|
| 2754 | { |
---|
| 2755 | $rows['.'.$k] = 'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"'; |
---|
| 2756 | $row = &$rows[$k]; |
---|
| 2757 | $akt_cell = &$rows['.nr_'.$k]; |
---|
| 2758 | if ($akt_cell < $last_cell) |
---|
| 2759 | { |
---|
| 2760 | $row['3'] = ' '; |
---|
| 2761 | $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; |
---|
| 2762 | } |
---|
| 2763 | } |
---|
| 2764 | } |
---|
| 2765 | } |
---|
| 2766 | |
---|
| 2767 | function planner_print_rows() |
---|
| 2768 | { |
---|
| 2769 | $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"'; |
---|
| 2770 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
| 2771 | |
---|
| 2772 | if ($this->debug) |
---|
| 2773 | { |
---|
| 2774 | _debug_array($this->planner_rows); |
---|
| 2775 | reset($this->planner_rows); |
---|
| 2776 | } |
---|
| 2777 | return $this->html->table( |
---|
| 2778 | array( |
---|
| 2779 | '_hdr0' => $this->planner_header[0], |
---|
| 2780 | '._hdr0' => $bgcolor, |
---|
| 2781 | '_hdr1' => $this->planner_header[1], |
---|
| 2782 | '._hdr1' => $bgcolor, |
---|
| 2783 | '_hdr2' => $this->planner_header[2], |
---|
| 2784 | '._hdr2' => $bgcolor |
---|
| 2785 | )+$this->planner_rows, |
---|
| 2786 | 'width="100%" cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"'); |
---|
| 2787 | } |
---|
| 2788 | |
---|
| 2789 | function planner_process_interval() |
---|
| 2790 | { |
---|
| 2791 | // generate duplicate free list of events within observed interval |
---|
| 2792 | // |
---|
| 2793 | $this->bo->store_to_cache( |
---|
| 2794 | Array( |
---|
| 2795 | 'syear' => $this->bo->year, |
---|
| 2796 | 'smonth' => $this->bo->month, |
---|
| 2797 | 'sday' => 1, |
---|
| 2798 | 'eyear' => $this->planner_end_year, |
---|
| 2799 | 'emonth' => $this->planner_end_month, |
---|
| 2800 | 'eday' => $this->planner_days_in_end_month |
---|
| 2801 | ) |
---|
| 2802 | ); |
---|
| 2803 | $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); |
---|
| 2804 | |
---|
| 2805 | // process all events within observed interval |
---|
| 2806 | // |
---|
| 2807 | for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++) |
---|
| 2808 | { |
---|
| 2809 | $daily = $this->bo->cached_events[$v]; |
---|
| 2810 | |
---|
| 2811 | print_debug('For Date',$v); |
---|
| 2812 | print_debug('Count of items',count($daily)); |
---|
| 2813 | |
---|
| 2814 | // process all events on day $v |
---|
| 2815 | // |
---|
| 2816 | if (is_array($daily)) foreach($daily as $event) |
---|
| 2817 | { |
---|
| 2818 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
| 2819 | { |
---|
| 2820 | $this->bo->set_recur_date($event,$v); |
---|
| 2821 | } |
---|
| 2822 | if (!$this->bo->rejected_no_show($event)) |
---|
| 2823 | { |
---|
| 2824 | $this->planner_process_event($event); |
---|
| 2825 | } |
---|
| 2826 | } |
---|
| 2827 | } |
---|
| 2828 | $this->planner_pad_rows(); |
---|
| 2829 | } |
---|
| 2830 | |
---|
| 2831 | function matrixselect() |
---|
| 2832 | { |
---|
| 2833 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 2834 | |
---|
| 2835 | $sb = CreateObject('phpgwapi.sbox'); |
---|
| 2836 | |
---|
| 2837 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2838 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2839 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
| 2840 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2841 | |
---|
| 2842 | $p = &$GLOBALS['phpgw']->template; |
---|
| 2843 | $p->set_file( |
---|
| 2844 | Array( |
---|
| 2845 | 'mq' => 'matrix_query.tpl', |
---|
| 2846 | 'form_button' => 'form_button_script.tpl' |
---|
| 2847 | ) |
---|
| 2848 | ); |
---|
| 2849 | $p->set_block('mq','matrix_query','matrix_query'); |
---|
| 2850 | $p->set_block('mq','list','list'); |
---|
| 2851 | |
---|
| 2852 | $p->set_var(array( |
---|
| 2853 | 'title' => lang('Daily Matrix View'), |
---|
| 2854 | 'th_bg' => $this->theme['th_bg'], |
---|
| 2855 | 'action_url' => $this->page('viewmatrix') |
---|
| 2856 | )); |
---|
| 2857 | |
---|
| 2858 | // Date |
---|
| 2859 | $var[] = Array( |
---|
| 2860 | 'field' => lang('Date'), |
---|
| 2861 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 2862 | $sb->getYears('year',(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y'),(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y')), |
---|
| 2863 | $sb->getMonthText('month',(int)$GLOBALS['phpgw']->common->show_date($datetime,'n')), |
---|
| 2864 | $sb->getDays('day',(int)$GLOBALS['phpgw']->common->show_date($datetime,'d')) |
---|
| 2865 | ) |
---|
| 2866 | ); |
---|
| 2867 | |
---|
| 2868 | // View type |
---|
| 2869 | $var[] = Array( |
---|
| 2870 | 'field' => lang('View'), |
---|
| 2871 | 'data' => '<select name="matrixtype">'."\n" |
---|
| 2872 | . '<option value="free/busy" selected>'.lang('free/busy').'</option>'."\n" |
---|
| 2873 | . '<option value="weekly">'.lang('Weekly').'</option>'."\n" |
---|
| 2874 | . '</select>'."\n" |
---|
| 2875 | ); |
---|
| 2876 | |
---|
| 2877 | // Participants |
---|
| 2878 | $accounts = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'calendar'); |
---|
| 2879 | $users = Array(); |
---|
| 2880 | for($i=0;$i<count($accounts);$i++) |
---|
| 2881 | { |
---|
| 2882 | $user = $accounts[$i]; |
---|
| 2883 | if(!isset($users[$user])) |
---|
| 2884 | { |
---|
| 2885 | $users[$user] = $GLOBALS['phpgw']->common->grab_owner_name($user); |
---|
| 2886 | if($GLOBALS['phpgw']->accounts->get_type($user) == 'g') |
---|
| 2887 | { |
---|
| 2888 | $group_members = $GLOBALS['phpgw']->acl->get_ids_for_location($user,1,'phpgw_group'); |
---|
| 2889 | if($group_members != False) |
---|
| 2890 | { |
---|
| 2891 | for($j=0;$j<count($group_members);$j++) |
---|
| 2892 | { |
---|
| 2893 | if(!isset($users[$group_members[$j]])) |
---|
| 2894 | { |
---|
| 2895 | $users[$group_members[$j]] = $GLOBALS['phpgw']->common->grab_owner_name($group_members[$j]); |
---|
| 2896 | } |
---|
| 2897 | } |
---|
| 2898 | } |
---|
| 2899 | } |
---|
| 2900 | } |
---|
| 2901 | } |
---|
| 2902 | |
---|
| 2903 | $num_users = count($users); |
---|
| 2904 | |
---|
| 2905 | if ($num_users > 50) |
---|
| 2906 | { |
---|
| 2907 | $size = 15; |
---|
| 2908 | } |
---|
| 2909 | elseif ($num_users > 5) |
---|
| 2910 | { |
---|
| 2911 | $size = 5; |
---|
| 2912 | } |
---|
| 2913 | else |
---|
| 2914 | { |
---|
| 2915 | $size = $num_users; |
---|
| 2916 | } |
---|
| 2917 | $str = ''; |
---|
| 2918 | @asort($users); |
---|
| 2919 | @reset($users); |
---|
| 2920 | while ($user = each($users)) |
---|
| 2921 | { |
---|
| 2922 | 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') |
---|
| 2923 | { |
---|
| 2924 | $str .= ' <option value="'.$user[0].'">('.$GLOBALS['phpgw']->accounts->get_type($user[0]).') '.$user[1].'</option>'."\n"; |
---|
| 2925 | } |
---|
| 2926 | } |
---|
| 2927 | $var[] = Array( |
---|
| 2928 | 'field' => lang('Participants'), |
---|
| 2929 | 'data' => "\n".' <select name="participants[]" multiple size="'.$size.'">'."\n".$str.' </select>'."\n" |
---|
| 2930 | ); |
---|
| 2931 | |
---|
| 2932 | for($i=0;$i<count($var);$i++) |
---|
| 2933 | { |
---|
| 2934 | $this->output_template_array($p,'rows','list',$var[$i]); |
---|
| 2935 | } |
---|
| 2936 | |
---|
| 2937 | $vars = Array( |
---|
| 2938 | 'submit_button' => lang('View'), |
---|
| 2939 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
| 2940 | 'action_text_button' => lang('Cancel'), |
---|
| 2941 | 'action_confirm_button' => '', |
---|
| 2942 | 'action_extra_field' => '' |
---|
| 2943 | ); |
---|
| 2944 | |
---|
| 2945 | $p->set_var($vars); |
---|
| 2946 | $p->parse('cancel_button','form_button'); |
---|
| 2947 | $p->pparse('out','matrix_query'); |
---|
| 2948 | } |
---|
| 2949 | |
---|
| 2950 | function viewmatrix() |
---|
| 2951 | { |
---|
| 2952 | if ($_POST['cancel']) |
---|
| 2953 | { |
---|
| 2954 | $this->index(); |
---|
| 2955 | } |
---|
| 2956 | $participants = $_POST['participants']; |
---|
| 2957 | $parts = Array(); |
---|
| 2958 | $acct = CreateObject('phpgwapi.accounts',$this->bo->owner); |
---|
| 2959 | |
---|
| 2960 | if (is_array($participants)) |
---|
| 2961 | { |
---|
| 2962 | foreach($participants as $participant) |
---|
| 2963 | { |
---|
| 2964 | switch ($GLOBALS['phpgw']->accounts->get_type($participant)) |
---|
| 2965 | { |
---|
| 2966 | case 'g': |
---|
| 2967 | if ($members = $acct->member((int)$participant)) |
---|
| 2968 | { |
---|
| 2969 | foreach($members as $member) |
---|
| 2970 | { |
---|
| 2971 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id'])) |
---|
| 2972 | { |
---|
| 2973 | $parts[$member['account_id']] = True; |
---|
| 2974 | } |
---|
| 2975 | } |
---|
| 2976 | } |
---|
| 2977 | break; |
---|
| 2978 | case 'u': |
---|
| 2979 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$participant)) |
---|
| 2980 | { |
---|
| 2981 | $parts[$participant] = 1; |
---|
| 2982 | } |
---|
| 2983 | break; |
---|
| 2984 | } |
---|
| 2985 | } |
---|
| 2986 | unset($acct); |
---|
| 2987 | } |
---|
| 2988 | $participants = array_keys($parts); // get id's as values and a numeric index |
---|
| 2989 | |
---|
| 2990 | // Defined - into session - who participates |
---|
| 2991 | $GLOBALS['phpgw']->session->appsession("participants", NULL, implode(";", $participants)); |
---|
| 2992 | |
---|
| 2993 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 2994 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 2995 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
| 2996 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 2997 | |
---|
| 2998 | switch($_POST['matrixtype']) |
---|
| 2999 | { |
---|
| 3000 | case 'free/busy': |
---|
| 3001 | $freetime = $GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year)); |
---|
| 3002 | echo '<br>'.$this->timematrix( |
---|
| 3003 | Array( |
---|
| 3004 | 'date' => $freetime, |
---|
| 3005 | 'starttime' => $this->bo->splittime('000000',False), |
---|
| 3006 | 'endtime' => 0, |
---|
| 3007 | 'participants' => $parts |
---|
| 3008 | ) |
---|
| 3009 | ); |
---|
| 3010 | break; |
---|
| 3011 | case 'weekly': |
---|
| 3012 | echo '<br>'.$this->display_weekly( |
---|
| 3013 | Array( |
---|
| 3014 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
| 3015 | 'showyear' => true, |
---|
| 3016 | 'owners' => $participants |
---|
| 3017 | ) |
---|
| 3018 | ); |
---|
| 3019 | break; |
---|
| 3020 | } |
---|
| 3021 | echo "\n<br>\n".'<form action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n"; |
---|
| 3022 | echo ' <table cellpadding="5"><tr><td>'."\n"; |
---|
| 3023 | echo ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
| 3024 | echo ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
| 3025 | echo ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
| 3026 | echo ' <input type="hidden" name="matrixtype" value="'.$_POST['matrixtype'].'">'."\n"; |
---|
| 3027 | foreach($participants as $part) |
---|
| 3028 | { |
---|
| 3029 | echo ' <input type="hidden" name="participants[]" value="'.$part.'">'."\n"; |
---|
| 3030 | } |
---|
| 3031 | echo ' <input type="submit" name="refresh" value="'.lang('Refresh').'">'."\n"; |
---|
| 3032 | echo ' </td><td>'."\n"; |
---|
| 3033 | echo ' <input type="submit" name="cancel" value="'.lang('Cancel').'">'."\n"; |
---|
| 3034 | echo ' </td></tr></table>'."\n"; |
---|
| 3035 | echo '</form>'."\n"; |
---|
| 3036 | } |
---|
| 3037 | |
---|
| 3038 | function search() |
---|
| 3039 | { |
---|
| 3040 | if (empty($_POST['keywords'])) |
---|
| 3041 | { |
---|
| 3042 | // If we reach this, it is because they didn't search for anything |
---|
| 3043 | // or they used one of the selectboxes (year, month, week) in the search-result |
---|
| 3044 | // attempt to send them back to where they came from. |
---|
| 3045 | |
---|
| 3046 | $vars['menuaction'] = isset($_POST['from']) && $_POST['from'] != 'calendar.uicalendar.search' ? |
---|
| 3047 | $_POST['from'] : 'calendar.uicalendar.index'; |
---|
| 3048 | |
---|
| 3049 | foreach(array('date','year','month','day') as $field) |
---|
| 3050 | { |
---|
| 3051 | if (isset($_POST[$field])) |
---|
| 3052 | { |
---|
| 3053 | $vars[$field] = $_POST[$field]; |
---|
| 3054 | } |
---|
| 3055 | } |
---|
| 3056 | $GLOBALS['phpgw']->redirect_link('/index.php',$vars); |
---|
| 3057 | } |
---|
| 3058 | |
---|
| 3059 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 3060 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 3061 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
| 3062 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 3063 | |
---|
| 3064 | $error = ''; |
---|
| 3065 | |
---|
| 3066 | $matches = 0; |
---|
| 3067 | |
---|
| 3068 | // There is currently a problem searching in with repeated events. |
---|
| 3069 | // It spits back out the date it was entered. I would like to to say that |
---|
| 3070 | // it is a repeated event. |
---|
| 3071 | |
---|
| 3072 | // This has been solved by the little icon indicator for recurring events. |
---|
| 3073 | |
---|
| 3074 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
| 3075 | foreach($event_ids as $key => $id) |
---|
| 3076 | { |
---|
| 3077 | $event = $this->bo->read_entry($id); |
---|
| 3078 | |
---|
| 3079 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$event)) |
---|
| 3080 | { |
---|
| 3081 | continue; |
---|
| 3082 | } |
---|
| 3083 | |
---|
| 3084 | $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3085 | |
---|
| 3086 | $info[strval($event['id'])] = array( |
---|
| 3087 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
| 3088 | 'date' => $GLOBALS['phpgw']->common->show_date($datetime), |
---|
| 3089 | 'link' => $this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']) |
---|
| 3090 | ); |
---|
| 3091 | |
---|
| 3092 | } |
---|
| 3093 | $matches = count($event_ids); |
---|
| 3094 | |
---|
| 3095 | if ($matches == 1) |
---|
| 3096 | { |
---|
| 3097 | $quantity = lang('1 match found').'.'; |
---|
| 3098 | } |
---|
| 3099 | elseif ($matches > 0) |
---|
| 3100 | { |
---|
| 3101 | $quantity = lang('%1 matches found',$matches).'.'; |
---|
| 3102 | } |
---|
| 3103 | else |
---|
| 3104 | { |
---|
| 3105 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
| 3106 | return; |
---|
| 3107 | } |
---|
| 3108 | |
---|
| 3109 | $p = $GLOBALS['phpgw']->template; |
---|
| 3110 | $p->set_file( |
---|
| 3111 | Array( |
---|
| 3112 | 'search_form' => 'search.tpl' |
---|
| 3113 | ) |
---|
| 3114 | ); |
---|
| 3115 | $p->set_block('search_form','search','search'); |
---|
| 3116 | $p->set_block('search_form','search_list_header','search_list_header'); |
---|
| 3117 | $p->set_block('search_form','search_list','search_list'); |
---|
| 3118 | $p->set_block('search_form','search_list_footer','search_list_footer'); |
---|
| 3119 | |
---|
| 3120 | $var = Array( |
---|
| 3121 | 'th_bg' => $this->theme['th_bg'], |
---|
| 3122 | 'search_text' => lang('Search Results'), |
---|
| 3123 | 'quantity' => $quantity |
---|
| 3124 | ); |
---|
| 3125 | $p->set_var($var); |
---|
| 3126 | |
---|
| 3127 | if($matches > 0) |
---|
| 3128 | { |
---|
| 3129 | $p->parse('rows','search_list_header',True); |
---|
| 3130 | } |
---|
| 3131 | foreach($info as $id => $data) |
---|
| 3132 | { |
---|
| 3133 | $p->set_var($data); |
---|
| 3134 | $p->parse('rows','search_list',True); |
---|
| 3135 | } |
---|
| 3136 | |
---|
| 3137 | if($matches > 0) |
---|
| 3138 | { |
---|
| 3139 | $p->parse('rows','search_list_footer',True); |
---|
| 3140 | } |
---|
| 3141 | |
---|
| 3142 | $p->pparse('out','search'); |
---|
| 3143 | } |
---|
| 3144 | |
---|
| 3145 | /* Private functions */ |
---|
| 3146 | function _debug_sqsof() |
---|
| 3147 | { |
---|
| 3148 | $data = array( |
---|
| 3149 | 'filter' => $this->bo->filter, |
---|
| 3150 | 'cat_id' => $this->bo->cat_id, |
---|
| 3151 | 'owner' => $this->bo->owner, |
---|
| 3152 | 'year' => $this->bo->year, |
---|
| 3153 | 'month' => $this->bo->month, |
---|
| 3154 | 'day' => $this->bo->day, |
---|
| 3155 | 'sortby' => $this->bo->sortby, |
---|
| 3156 | 'num_months' => $this->bo->num_months |
---|
| 3157 | ); |
---|
| 3158 | Return _debug_array($data,False); |
---|
| 3159 | } |
---|
| 3160 | |
---|
| 3161 | function output_template_array(&$p,$row,$list,$var) |
---|
| 3162 | { |
---|
| 3163 | if (!isset($var['hidden_vars'])) |
---|
| 3164 | { |
---|
| 3165 | $var['hidden_vars'] = ''; |
---|
| 3166 | } |
---|
| 3167 | if (!isset($var['tr_color'])) |
---|
| 3168 | { |
---|
| 3169 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
| 3170 | } |
---|
| 3171 | $p->set_var($var); |
---|
| 3172 | $p->parse($row,$list,True); |
---|
| 3173 | } |
---|
| 3174 | |
---|
| 3175 | function page($_page='',$params='') |
---|
| 3176 | { |
---|
| 3177 | if($_page == '') |
---|
| 3178 | { |
---|
| 3179 | $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); |
---|
| 3180 | $_page = $page_[0]; |
---|
| 3181 | |
---|
| 3182 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
| 3183 | { |
---|
| 3184 | $_page = 'planner'; |
---|
| 3185 | } |
---|
| 3186 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
| 3187 | { |
---|
| 3188 | $_page = 'month'; |
---|
| 3189 | $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); |
---|
| 3190 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 3191 | } |
---|
| 3192 | } |
---|
| 3193 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
| 3194 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
| 3195 | { |
---|
| 3196 | $page_app = 'calendar'; |
---|
| 3197 | } |
---|
| 3198 | else |
---|
| 3199 | { |
---|
| 3200 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
| 3201 | } |
---|
| 3202 | if (is_array($params)) |
---|
| 3203 | { |
---|
| 3204 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
| 3205 | } |
---|
| 3206 | else |
---|
| 3207 | { |
---|
| 3208 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
| 3209 | } |
---|
| 3210 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
| 3211 | } |
---|
| 3212 | |
---|
| 3213 | function header() |
---|
| 3214 | { |
---|
| 3215 | $cols = 8; |
---|
| 3216 | if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) |
---|
| 3217 | { |
---|
| 3218 | $cols++; |
---|
| 3219 | } |
---|
| 3220 | |
---|
| 3221 | $tpl = $GLOBALS['phpgw']->template; |
---|
| 3222 | $tpl->set_unknowns('remove'); |
---|
| 3223 | |
---|
| 3224 | if (!file_exists($file = $this->template_dir.'/header.inc.php')) |
---|
| 3225 | { |
---|
| 3226 | $file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php'; |
---|
| 3227 | } |
---|
| 3228 | |
---|
| 3229 | include($file); |
---|
| 3230 | $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); |
---|
| 3231 | if($refer[2] != 'view') { |
---|
| 3232 | $header = $tpl->fp('out','head'); |
---|
| 3233 | unset($tpl); |
---|
| 3234 | echo $header; |
---|
| 3235 | } |
---|
| 3236 | unset($tpl); |
---|
| 3237 | } |
---|
| 3238 | |
---|
| 3239 | function footer() |
---|
| 3240 | { |
---|
| 3241 | $menuaction = $_GET['menuaction']; |
---|
| 3242 | list(,,$method) = explode('.',$menuaction); |
---|
| 3243 | |
---|
| 3244 | if (@$this->bo->printer_friendly) |
---|
| 3245 | { |
---|
| 3246 | return; |
---|
| 3247 | } |
---|
| 3248 | |
---|
| 3249 | $p = $GLOBALS['phpgw']->template; |
---|
| 3250 | |
---|
| 3251 | $p->set_file( |
---|
| 3252 | Array( |
---|
| 3253 | 'footer' => 'footer.tpl', |
---|
| 3254 | 'form_button' => 'form_button_script.tpl' |
---|
| 3255 | //'new_component' => 'new_component.tpl' |
---|
| 3256 | ) |
---|
| 3257 | ); |
---|
| 3258 | $p->set_block('footer','footer_table','footer_table'); |
---|
| 3259 | $p->set_block('footer','footer_row','footer_row'); |
---|
| 3260 | $p->set_block('footer','blank_row','blank_row'); |
---|
| 3261 | $p->set_block('footer','num_dias','num_dias'); |
---|
| 3262 | |
---|
| 3263 | $m = $this->bo->month; |
---|
| 3264 | $y = $this->bo->year; |
---|
| 3265 | |
---|
| 3266 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
| 3267 | $mes_hoje = (int)substr($hoje,4,2); |
---|
| 3268 | $mes_footer = (int)substr($_POST['date'],4,2); |
---|
| 3269 | if($_GET['sday']) |
---|
| 3270 | { |
---|
| 3271 | if($_GET['month'] == $mes_hoje) |
---|
| 3272 | { |
---|
| 3273 | $day = $this->bo->day; |
---|
| 3274 | } |
---|
| 3275 | else |
---|
| 3276 | { |
---|
| 3277 | $day = $_GET['sday']; |
---|
| 3278 | } |
---|
| 3279 | } |
---|
| 3280 | else |
---|
| 3281 | { |
---|
| 3282 | $day = $this->bo->day; |
---|
| 3283 | $dia_ini = $day; |
---|
| 3284 | } |
---|
| 3285 | if($mes_footer == $mes_hoje) |
---|
| 3286 | { |
---|
| 3287 | $dia_ini = (int)substr($hoje,6,2); |
---|
| 3288 | $day = $dia_ini; |
---|
| 3289 | } |
---|
| 3290 | /********************************************************************************************/ |
---|
| 3291 | /* Bloco adicionado para receber o dia a partir do qual a versao para impressao sera gerada */ |
---|
| 3292 | $str_ini = ''; |
---|
| 3293 | for ($i = 1; $i <= ($GLOBALS['phpgw']->datetime->days_in_month($m, $y)); $i++) |
---|
| 3294 | { |
---|
| 3295 | $str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3296 | } |
---|
| 3297 | $str_qtd = '<option value="'.''.'"'.(!$_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; |
---|
| 3298 | for ($i = 1; $i <= 45; $i++) |
---|
| 3299 | { |
---|
| 3300 | $str_qtd .= '<option value="'.$i.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3301 | } |
---|
| 3302 | $display = ''; |
---|
| 3303 | $display_view = ''; |
---|
| 3304 | // if ($menuaction == 'calendar.uicalendar.month') |
---|
| 3305 | // { |
---|
| 3306 | // $accounts = CreateObject('phpgwapi.accounts'); |
---|
| 3307 | // $accountId = $accounts->name2id($account_name); |
---|
| 3308 | // $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
| 3309 | // $account_prefs = $prefs->read(); |
---|
| 3310 | // } |
---|
| 3311 | if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') || ($menuaction == 'calendar.uicalendar.year') || ($menuaction == 'calendar.uicalendar.planner')) |
---|
| 3312 | { |
---|
| 3313 | $display = 'none'; |
---|
| 3314 | } |
---|
| 3315 | else if( ($menuaction == 'calendar.uicalendar.view') ) |
---|
| 3316 | { |
---|
| 3317 | $display = 'none'; |
---|
| 3318 | $display_view = 'none'; |
---|
| 3319 | } |
---|
| 3320 | $var = Array( |
---|
| 3321 | 'acao' => $this->page($method,''), |
---|
| 3322 | 'formname' => 'SelectDay', |
---|
| 3323 | 'formonchange' => 'document.SelectDay.submit()', |
---|
| 3324 | 'day_ini_label' => lang('print start day'), |
---|
| 3325 | 'num_dias_label' => lang('quantity of days'), |
---|
| 3326 | 'tip' => lang('empty prints from the start day chosen to the end of the current month'), |
---|
| 3327 | // 'day_ini_name' => 'day', |
---|
| 3328 | // 'num_dias_name' => 'qtd_dias', |
---|
| 3329 | 'row_ini' => $str_ini, |
---|
| 3330 | 'row_qtd' => $str_qtd, |
---|
| 3331 | 'display' => $display, |
---|
| 3332 | 'display_view' => $display_view, |
---|
| 3333 | 'go' => lang('Go!') |
---|
| 3334 | ); |
---|
| 3335 | $this->output_template_array($p,'table_row','num_dias',$var); |
---|
| 3336 | |
---|
| 3337 | /********************************************************************************************/ |
---|
| 3338 | |
---|
| 3339 | $thisdate = date('Ymd',mktime(0,0,0,$m,1,$y)); |
---|
| 3340 | $y--; |
---|
| 3341 | |
---|
| 3342 | $str = ''; |
---|
| 3343 | for ($i = 0; $i < 20; $i++) |
---|
| 3344 | { |
---|
| 3345 | $m++; |
---|
| 3346 | if ($m > 12) |
---|
| 3347 | { |
---|
| 3348 | $m = 1; |
---|
| 3349 | $y++; |
---|
| 3350 | } |
---|
| 3351 | $d = mktime(0,0,0,$m,1,$y); |
---|
| 3352 | $d_ymd = date('Ymd',$d); |
---|
| 3353 | $str .= '<option value="'.$d_ymd.'"'.($d_ymd == $thisdate?' selected':'').'>'.lang(date('F', $d)).strftime(' %Y', $d).'</option>'."\n"; |
---|
| 3354 | } |
---|
| 3355 | |
---|
| 3356 | $var = Array( |
---|
| 3357 | 'action_url' => $this->page($method,''), |
---|
| 3358 | 'form_name' => 'SelectMonth', |
---|
| 3359 | 'label' => lang('Month'), |
---|
| 3360 | 'form_label' => 'date', |
---|
| 3361 | 'form_onchange' => 'document.SelectMonth.submit()', |
---|
| 3362 | 'row' => $str, |
---|
| 3363 | // 'dia_ini' => $dia_ini, |
---|
| 3364 | 'go' => lang('Go!') |
---|
| 3365 | ); |
---|
| 3366 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3367 | |
---|
| 3368 | if($menuaction == 'calendar.uicalendar.week') |
---|
| 3369 | { |
---|
| 3370 | unset($thisdate); |
---|
| 3371 | $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3372 | $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3373 | |
---|
| 3374 | $str = ''; |
---|
| 3375 | for ($i = -7; $i <= 7; $i++) |
---|
| 3376 | { |
---|
| 3377 | $begin = $sun + (7*24*60*60 * $i) + 12*60*60; // we use midday, that changes in daylight-saveing does not effect us |
---|
| 3378 | $end = $begin + 6*24*60*60; |
---|
| 3379 | // echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end); |
---|
| 3380 | $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate+12*60*60 && $end >= $thisdate+12*60*60 ? ' selected':'').'>' |
---|
| 3381 | . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - ' |
---|
| 3382 | . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) |
---|
| 3383 | . '</option>' . "\n"; |
---|
| 3384 | } |
---|
| 3385 | |
---|
| 3386 | $var = Array( |
---|
| 3387 | 'action_url' => $this->page($method,''), |
---|
| 3388 | 'form_name' => 'SelectWeek', |
---|
| 3389 | 'label' => lang('Week'), |
---|
| 3390 | 'form_label' => 'date', |
---|
| 3391 | 'form_onchange' => 'document.SelectWeek.submit()', |
---|
| 3392 | 'row' => $str, |
---|
| 3393 | 'go' => lang('Go!') |
---|
| 3394 | ); |
---|
| 3395 | |
---|
| 3396 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3397 | } |
---|
| 3398 | |
---|
| 3399 | $str = ''; |
---|
| 3400 | for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); $i++) |
---|
| 3401 | { |
---|
| 3402 | $str .= '<option value="'.$i.'"'.($i == $this->bo->year?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3403 | } |
---|
| 3404 | |
---|
| 3405 | $var = Array( |
---|
| 3406 | 'action_url' => $this->page($method,''), |
---|
| 3407 | 'form_name' => 'SelectYear', |
---|
| 3408 | 'label' => lang('Year'), |
---|
| 3409 | 'form_label' => 'year', |
---|
| 3410 | 'form_onchange' => 'document.SelectYear.submit()', |
---|
| 3411 | 'row' => $str, |
---|
| 3412 | 'go' => lang('Go!') |
---|
| 3413 | ); |
---|
| 3414 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3415 | |
---|
| 3416 | if($menuaction == 'calendar.uicalendar.planner') |
---|
| 3417 | { |
---|
| 3418 | $str = ''; |
---|
| 3419 | $date_str = ''; |
---|
| 3420 | |
---|
| 3421 | if(isset($_GET['date']) && $_GET['date']) |
---|
| 3422 | { |
---|
| 3423 | $date_str .= ' <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n"; |
---|
| 3424 | } |
---|
| 3425 | $date_str .= ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
| 3426 | $date_str .= ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
| 3427 | $date_str .= ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
| 3428 | |
---|
| 3429 | for($i=1; $i<=6; $i++) |
---|
| 3430 | { |
---|
| 3431 | $str .= '<option value="'.$i.'"'.($i == $this->bo->num_months?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 3432 | } |
---|
| 3433 | |
---|
| 3434 | $var = Array( |
---|
| 3435 | 'action_url' => $this->page($method,''), |
---|
| 3436 | 'form_name' => 'SelectNumberOfMonths', |
---|
| 3437 | 'label' => lang('Number of Months'), |
---|
| 3438 | 'hidden_vars' => $date_str, |
---|
| 3439 | 'form_label' => 'num_months', |
---|
| 3440 | 'form_onchange' => 'document.SelectNumberOfMonths.submit()', |
---|
| 3441 | 'action_extra_field' => $date_str, |
---|
| 3442 | 'row' => $str, |
---|
| 3443 | 'go' => lang('Go!') |
---|
| 3444 | ); |
---|
| 3445 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
| 3446 | } |
---|
| 3447 | |
---|
| 3448 | $var = Array( |
---|
| 3449 | 'submit_button' => lang('Submit'), |
---|
| 3450 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), |
---|
| 3451 | 'action_text_button' => lang('Import'), |
---|
| 3452 | 'action_confirm_button' => '', |
---|
| 3453 | 'action_extra_field' => '' |
---|
| 3454 | ); |
---|
| 3455 | $this->output_template_array($p,'b_row','form_button',$var); |
---|
| 3456 | |
---|
| 3457 | $var = Array( |
---|
| 3458 | 'submit_button' => lang('Submit'), |
---|
| 3459 | 'action_url' => $this->page($method,''), |
---|
| 3460 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.export_all'), |
---|
| 3461 | 'action_text_button' => lang('Export all'), |
---|
| 3462 | 'action_confirm_button' => '', |
---|
| 3463 | 'action_extra_field' => '' |
---|
| 3464 | ); |
---|
| 3465 | $this->output_template_array($p,'b_row2','form_button',$var); |
---|
| 3466 | |
---|
| 3467 | //$p->set_var('place_component',''); |
---|
| 3468 | $p->parse('table_row','blank_row',True); |
---|
| 3469 | $p->pparse('out','footer_table'); |
---|
| 3470 | unset($p); |
---|
| 3471 | } |
---|
| 3472 | |
---|
| 3473 | function css() |
---|
| 3474 | { |
---|
| 3475 | $GLOBALS['phpgw']->browser->browser(); |
---|
| 3476 | if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA') |
---|
| 3477 | { |
---|
| 3478 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?12:8); |
---|
| 3479 | } |
---|
| 3480 | else |
---|
| 3481 | { |
---|
| 3482 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?10:7); |
---|
| 3483 | } |
---|
| 3484 | |
---|
| 3485 | // moved to app.css in templates/default for future separation of code and style [NDEE 10.03.04] |
---|
| 3486 | /* |
---|
| 3487 | return 'A.minicalendar { color: #000000; font-size: 72%; font-family: '.$this->theme['font'].' }'."\n" |
---|
| 3488 | . ' A.bminicalendar { color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 3489 | . ' A.minicalendargrey { color: #999999; font-size: 8px; font-family: '.$this->theme['font'].' }'."\n" |
---|
| 3490 | . ' A.bminicalendargrey { color: #336699; font-style: italic; font-size:8px; font-family '.$this->theme['font'].' }'."\n" |
---|
| 3491 | . ' A.minicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font: x-small '.$this->theme['font'].' }'."\n" |
---|
| 3492 | . ' A.bminicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 3493 | . ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: x-small '.$this->theme['font'].' }'."\n" |
---|
| 3494 | . ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
| 3495 | . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 3496 | . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 3497 | . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
| 3498 | . ' .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" |
---|
| 3499 | . ' .tablecell { width: 80px; height: 80px }'."\n" |
---|
| 3500 | . ' .planner-cell { cursor:pointer; cursor:hand; border: thin solid black; }'; |
---|
| 3501 | */ |
---|
| 3502 | } |
---|
| 3503 | |
---|
| 3504 | function no_edit() |
---|
| 3505 | { |
---|
| 3506 | if(!isset($GLOBALS['phpgw_info']['flags']['noheader'])) |
---|
| 3507 | { |
---|
| 3508 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 3509 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 3510 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 3511 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 3512 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Permission denied'); |
---|
| 3513 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 3514 | } |
---|
| 3515 | echo '<center>You do not have permission to edit this appointment!</center>'; |
---|
| 3516 | return; |
---|
| 3517 | } |
---|
| 3518 | |
---|
| 3519 | function link_to_entry($event,$month,$day,$year) |
---|
| 3520 | { |
---|
| 3521 | $str = ''; |
---|
| 3522 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3523 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3524 | |
---|
| 3525 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3526 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3527 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
| 3528 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3529 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3530 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
| 3531 | { |
---|
| 3532 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3533 | } |
---|
| 3534 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
| 3535 | { |
---|
| 3536 | $time = '[ '.lang('All Day').' ]'; |
---|
| 3537 | } |
---|
| 3538 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
| 3539 | { |
---|
| 3540 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3541 | { |
---|
| 3542 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
| 3543 | } |
---|
| 3544 | else |
---|
| 3545 | { |
---|
| 3546 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3547 | } |
---|
| 3548 | |
---|
| 3549 | if($endtime >= ($rawdate_offset + 86400)) |
---|
| 3550 | { |
---|
| 3551 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
| 3552 | } |
---|
| 3553 | else |
---|
| 3554 | { |
---|
| 3555 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
| 3556 | } |
---|
| 3557 | $time = $start_time.'-'.$end_time; |
---|
| 3558 | } |
---|
| 3559 | else |
---|
| 3560 | { |
---|
| 3561 | $time = ''; |
---|
| 3562 | } |
---|
| 3563 | |
---|
| 3564 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
| 3565 | |
---|
| 3566 | |
---|
| 3567 | |
---|
| 3568 | if(!$is_private) |
---|
| 3569 | { |
---|
| 3570 | //$text .= $this->bo->display_status($event['users_status']); |
---|
| 3571 | |
---|
| 3572 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
| 3573 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
| 3574 | |
---|
| 3575 | } |
---|
| 3576 | |
---|
| 3577 | /* |
---|
| 3578 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
| 3579 | (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). |
---|
| 3580 | $GLOBALS['phpgw']->browser->br; |
---|
| 3581 | */ |
---|
| 3582 | |
---|
| 3583 | $texttime=$time; |
---|
| 3584 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
| 3585 | |
---|
| 3586 | $account_name = $_POST['user'] ? |
---|
| 3587 | $_POST['user'] : |
---|
| 3588 | ($_GET['account_name'] ? |
---|
| 3589 | $_GET['account_name'] : ''); |
---|
| 3590 | |
---|
| 3591 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
| 3592 | $accountId = $accounts->name2id($account_name); |
---|
| 3593 | |
---|
| 3594 | $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
| 3595 | $account_prefs = $prefs->read(); |
---|
| 3596 | |
---|
| 3597 | $titleView = $account_prefs['calendar']['title_view']; |
---|
| 3598 | if($titleView == "1") |
---|
| 3599 | { |
---|
| 3600 | $textdesc = ''; |
---|
| 3601 | } |
---|
| 3602 | else |
---|
| 3603 | { |
---|
| 3604 | $textdesc = (!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
| 3605 | $textdesc=nl2br($textdesc); |
---|
| 3606 | } |
---|
| 3607 | |
---|
| 3608 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
| 3609 | $textlocation= $event['location']?"<br/><b>Local:</b> ".$this->bo->get_short_field($event,$is_private,'location'):''; |
---|
| 3610 | |
---|
| 3611 | if ($viewable) |
---|
| 3612 | { |
---|
| 3613 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
| 3614 | $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
| 3615 | $this->link_tpl->set_var('lang_view',lang('View this entry')); |
---|
| 3616 | $this->link_tpl->set_var('desc', $textdesc); |
---|
| 3617 | $this->link_tpl->set_var('location', $textlocation); |
---|
| 3618 | $this->link_tpl->parse('picture','link_open',True); |
---|
| 3619 | } |
---|
| 3620 | if (!$is_private) |
---|
| 3621 | { |
---|
| 3622 | if($event['priority'] == 3) |
---|
| 3623 | { |
---|
| 3624 | $picture[] = Array( |
---|
| 3625 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
| 3626 | 'width' => 16, |
---|
| 3627 | 'height'=> 16, |
---|
| 3628 | 'title' => lang('high priority') |
---|
| 3629 | ); |
---|
| 3630 | } |
---|
| 3631 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3632 | { |
---|
| 3633 | $picture[] = Array( |
---|
| 3634 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
| 3635 | 'width' => 9, |
---|
| 3636 | 'height'=> 9, |
---|
| 3637 | 'title' => lang('single event') |
---|
| 3638 | ); |
---|
| 3639 | } |
---|
| 3640 | else |
---|
| 3641 | { |
---|
| 3642 | $picture[] = Array( |
---|
| 3643 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
| 3644 | 'width' => 12, |
---|
| 3645 | 'height'=> 12, |
---|
| 3646 | 'title' => lang('recurring event') |
---|
| 3647 | ); |
---|
| 3648 | } |
---|
| 3649 | } |
---|
| 3650 | $participants = $this->planner_participants($event['participants']); |
---|
| 3651 | if(count($event['participants']) > 1) |
---|
| 3652 | { |
---|
| 3653 | $picture[] = Array( |
---|
| 3654 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
| 3655 | 'width' => 14, |
---|
| 3656 | 'height'=> 14, |
---|
| 3657 | 'title' => $participants |
---|
| 3658 | ); |
---|
| 3659 | } |
---|
| 3660 | else |
---|
| 3661 | {if ($texttitle) |
---|
| 3662 | $picture[] = Array( |
---|
| 3663 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
| 3664 | 'width' => 14, |
---|
| 3665 | 'height'=> 14, |
---|
| 3666 | 'title' => $participants |
---|
| 3667 | ); |
---|
| 3668 | } |
---|
| 3669 | if($event['public'] == 0) |
---|
| 3670 | { |
---|
| 3671 | $picture[] = Array( |
---|
| 3672 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
| 3673 | 'width' => 13, |
---|
| 3674 | 'height'=> 13, |
---|
| 3675 | 'title' => lang('private') |
---|
| 3676 | ); |
---|
| 3677 | } |
---|
| 3678 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
| 3679 | { |
---|
| 3680 | // if the alarm is to go off the day before the event |
---|
| 3681 | // the icon does not show up because of 'alarm_today' |
---|
| 3682 | // - TOM |
---|
| 3683 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
| 3684 | { |
---|
| 3685 | $picture[] = Array( |
---|
| 3686 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
| 3687 | 'width' => 13, |
---|
| 3688 | 'height'=> 13, |
---|
| 3689 | 'title' => lang('alarm') |
---|
| 3690 | ); |
---|
| 3691 | } |
---|
| 3692 | } |
---|
| 3693 | |
---|
| 3694 | if($event['attachment'] != '') |
---|
| 3695 | { |
---|
| 3696 | $picture[] = Array( |
---|
| 3697 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','clip'), |
---|
| 3698 | 'width' => 9, |
---|
| 3699 | 'height'=> 9, |
---|
| 3700 | 'title' => lang('Notification with attachments sent.') |
---|
| 3701 | ); |
---|
| 3702 | } |
---|
| 3703 | |
---|
| 3704 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
| 3705 | for($i=0;$i<count($picture);$i++) |
---|
| 3706 | { |
---|
| 3707 | $var = Array( |
---|
| 3708 | 'pic_image' => $picture[$i]['pict'], |
---|
| 3709 | 'width' => $picture[$i]['width'], |
---|
| 3710 | 'height' => $picture[$i]['height'], |
---|
| 3711 | 'title' => $picture[$i]['title'] |
---|
| 3712 | ); |
---|
| 3713 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
| 3714 | } |
---|
| 3715 | if ($event['type'] == 'H' || $texttitle) |
---|
| 3716 | { |
---|
| 3717 | $var = Array( |
---|
| 3718 | // 'text' => $text, |
---|
| 3719 | 'time'=> $texttime, |
---|
| 3720 | 'title'=> $texttitle, |
---|
| 3721 | 'users_status'=>$textstatus, |
---|
| 3722 | 'desc'=> $textdesc, |
---|
| 3723 | 'location'=> $textlocation |
---|
| 3724 | ); |
---|
| 3725 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
| 3726 | } |
---|
| 3727 | |
---|
| 3728 | if ($viewable) |
---|
| 3729 | { |
---|
| 3730 | $this->link_tpl->parse('picture','link_close',True); |
---|
| 3731 | } |
---|
| 3732 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
| 3733 | $this->link_tpl->set_var('picture',''); |
---|
| 3734 | $this->link_tpl->set_var('out',''); |
---|
| 3735 | // unset($p); |
---|
| 3736 | return $str; |
---|
| 3737 | } |
---|
| 3738 | |
---|
| 3739 | /*****************************************************************************************/ |
---|
| 3740 | /*Funcao foi duplicada e alterada para tratar os eventos de agendamento (exibicao do mes) para impressao; |
---|
| 3741 | utiliza o template event_link.tpl*/ |
---|
| 3742 | |
---|
| 3743 | function link_to_month_entry($event,$month,$day,$year) |
---|
| 3744 | { |
---|
| 3745 | $str = ''; |
---|
| 3746 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3747 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 3748 | |
---|
| 3749 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3750 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3751 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
| 3752 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3753 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3754 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
| 3755 | { |
---|
| 3756 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3757 | } |
---|
| 3758 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
| 3759 | { |
---|
| 3760 | $time = '[ '.lang('All Day').' ]'; |
---|
| 3761 | } |
---|
| 3762 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
| 3763 | { |
---|
| 3764 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3765 | { |
---|
| 3766 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
| 3767 | } |
---|
| 3768 | else |
---|
| 3769 | { |
---|
| 3770 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
| 3771 | } |
---|
| 3772 | |
---|
| 3773 | if($endtime >= ($rawdate_offset + 86400)) |
---|
| 3774 | { |
---|
| 3775 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
| 3776 | } |
---|
| 3777 | else |
---|
| 3778 | { |
---|
| 3779 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
| 3780 | } |
---|
| 3781 | $time = $start_time.' - '.$end_time; |
---|
| 3782 | } |
---|
| 3783 | else |
---|
| 3784 | { |
---|
| 3785 | $time = ''; |
---|
| 3786 | } |
---|
| 3787 | |
---|
| 3788 | $textTitlePrint = $textTimePrint = $textDescPrint = $textLocationPrint = $textObservationsPrint = $textstatus = ''; |
---|
| 3789 | |
---|
| 3790 | if(!$is_private) |
---|
| 3791 | { |
---|
| 3792 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
| 3793 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
| 3794 | |
---|
| 3795 | } |
---|
| 3796 | |
---|
| 3797 | $account_name = $_POST['user'] ? |
---|
| 3798 | $_POST['user'] : |
---|
| 3799 | ($_GET['account_name'] ? |
---|
| 3800 | $_GET['account_name'] : ''); |
---|
| 3801 | |
---|
| 3802 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
| 3803 | $accountId = $accounts->name2id($account_name); |
---|
| 3804 | |
---|
| 3805 | $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
| 3806 | $account_prefs = $prefs->read(); |
---|
| 3807 | |
---|
| 3808 | |
---|
| 3809 | $textTimePrint = $time; |
---|
| 3810 | $textTitlePrint = $is_private ? lang('Private event. You are not allowed to print it.') : ( $event['type'] == 'H' ? 'Apontamento de horas' : $this->bo->get_short_field($event,$is_private,'title' ) ); |
---|
| 3811 | |
---|
| 3812 | $fieldsToPrint = $account_prefs['calendar']['fields_to_print']; |
---|
| 3813 | if($fieldsToPrint == "0") |
---|
| 3814 | { |
---|
| 3815 | $textDescPrint = ''; |
---|
| 3816 | } |
---|
| 3817 | elseif($fieldsToPrint == "1") |
---|
| 3818 | { |
---|
| 3819 | $textDescPrint = (!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
| 3820 | } |
---|
| 3821 | else |
---|
| 3822 | { |
---|
| 3823 | $textDescPrint = (!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
| 3824 | $textObservationsPrint = $event['observations']?"<br /><b>Observações:</b> ".$this->bo->get_short_field($event,$is_private,'observations'):''; |
---|
| 3825 | } |
---|
| 3826 | |
---|
| 3827 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
| 3828 | $textLocationPrint = $event['location']?"<br /><b>Local:</b> ".$this->bo->get_short_field($event,$is_private,'location'):''; |
---|
| 3829 | |
---|
| 3830 | if ($viewable) |
---|
| 3831 | { |
---|
| 3832 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
| 3833 | $this->event_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
| 3834 | $this->event_tpl->set_var('lang_view',lang('View this entry')); |
---|
| 3835 | $this->event_tpl->set_var('desc', $textDescPrint); |
---|
| 3836 | $this->event_tpl->set_var('location', $textLocationPrint); |
---|
| 3837 | $this->event_tpl->set_var('observations', $textObservationsPrint); |
---|
| 3838 | $this->event_tpl->parse('picture','link_event_open',True); |
---|
| 3839 | } |
---|
| 3840 | |
---|
| 3841 | if (!$is_private) |
---|
| 3842 | { |
---|
| 3843 | if($event['priority'] == 3) |
---|
| 3844 | { |
---|
| 3845 | $picture[] = Array( |
---|
| 3846 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
| 3847 | 'width' => 16, |
---|
| 3848 | 'height'=> 16, |
---|
| 3849 | 'title' => lang('high priority') |
---|
| 3850 | ); |
---|
| 3851 | } |
---|
| 3852 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
| 3853 | { |
---|
| 3854 | $picture[] = Array( |
---|
| 3855 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
| 3856 | 'width' => 9, |
---|
| 3857 | 'height'=> 9, |
---|
| 3858 | 'title' => lang('single event') |
---|
| 3859 | ); |
---|
| 3860 | } |
---|
| 3861 | else |
---|
| 3862 | { |
---|
| 3863 | $picture[] = Array( |
---|
| 3864 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
| 3865 | 'width' => 12, |
---|
| 3866 | 'height'=> 12, |
---|
| 3867 | 'title' => lang('recurring event') |
---|
| 3868 | ); |
---|
| 3869 | } |
---|
| 3870 | } |
---|
| 3871 | |
---|
| 3872 | $participants = $this->planner_participants($event['participants']); |
---|
| 3873 | if(count($event['participants']) > 1) |
---|
| 3874 | { |
---|
| 3875 | $picture[] = Array( |
---|
| 3876 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
| 3877 | 'width' => 14, |
---|
| 3878 | 'height'=> 14, |
---|
| 3879 | 'title' => $participants |
---|
| 3880 | ); |
---|
| 3881 | } |
---|
| 3882 | else |
---|
| 3883 | { |
---|
| 3884 | $picture[] = Array( |
---|
| 3885 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
| 3886 | 'width' => 14, |
---|
| 3887 | 'height'=> 14, |
---|
| 3888 | 'title' => $participants |
---|
| 3889 | ); |
---|
| 3890 | } |
---|
| 3891 | if($event['public'] == 0) |
---|
| 3892 | { |
---|
| 3893 | $picture[] = Array( |
---|
| 3894 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
| 3895 | 'width' => 13, |
---|
| 3896 | 'height'=> 13, |
---|
| 3897 | 'title' => lang('private') |
---|
| 3898 | ); |
---|
| 3899 | } |
---|
| 3900 | |
---|
| 3901 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
| 3902 | { |
---|
| 3903 | // if the alarm is to go off the day before the event |
---|
| 3904 | // the icon does not show up because of 'alarm_today' |
---|
| 3905 | // - TOM |
---|
| 3906 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
| 3907 | { |
---|
| 3908 | $picture[] = Array( |
---|
| 3909 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
| 3910 | 'width' => 13, |
---|
| 3911 | 'height'=> 13, |
---|
| 3912 | 'title' => lang('alarm') |
---|
| 3913 | ); |
---|
| 3914 | } |
---|
| 3915 | } |
---|
| 3916 | |
---|
| 3917 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
| 3918 | for($i=0;$i<count($picture);$i++) |
---|
| 3919 | { |
---|
| 3920 | $var = Array( |
---|
| 3921 | 'pic_image' => $picture[$i]['pict'], |
---|
| 3922 | 'width' => $picture[$i]['width'], |
---|
| 3923 | 'height' => $picture[$i]['height'], |
---|
| 3924 | 'title' => $picture[$i]['title'] |
---|
| 3925 | ); |
---|
| 3926 | $this->output_template_array($this->event_tpl,'picture','event_pict',$var); |
---|
| 3927 | } |
---|
| 3928 | |
---|
| 3929 | if ($textTitlePrint) |
---|
| 3930 | { |
---|
| 3931 | $var = Array( |
---|
| 3932 | // 'text' => $text, |
---|
| 3933 | 'time'=> $textTimePrint, |
---|
| 3934 | 'title'=> $textTitlePrint, |
---|
| 3935 | 'users_status'=>$textstatus, |
---|
| 3936 | 'desc'=> $textDescPrint, |
---|
| 3937 | 'location'=> $textLocationPrint, |
---|
| 3938 | 'observations'=> $textObservationsPrint |
---|
| 3939 | ); |
---|
| 3940 | $this->output_template_array($this->event_tpl,'picture','link_event_text',$var); |
---|
| 3941 | } |
---|
| 3942 | |
---|
| 3943 | if ($viewable) |
---|
| 3944 | { |
---|
| 3945 | $this->event_tpl->parse('picture','link_event_close',True); |
---|
| 3946 | } |
---|
| 3947 | $str = $this->event_tpl->fp('out','link_event_pict'); |
---|
| 3948 | $this->event_tpl->set_var('picture',''); |
---|
| 3949 | $this->event_tpl->set_var('out',''); |
---|
| 3950 | // unset($p); |
---|
| 3951 | return $str; |
---|
| 3952 | } |
---|
| 3953 | |
---|
| 3954 | /*****************************************************************************************/ |
---|
| 3955 | function normDec($num) |
---|
| 3956 | { |
---|
| 3957 | if ($num > 9) |
---|
| 3958 | return $num; |
---|
| 3959 | else |
---|
| 3960 | return "0".$num; |
---|
| 3961 | } |
---|
| 3962 | function overlap($params) |
---|
| 3963 | { |
---|
| 3964 | if(!is_array($params)) |
---|
| 3965 | { |
---|
| 3966 | } |
---|
| 3967 | else |
---|
| 3968 | { |
---|
| 3969 | $overlapping_events = $params['o_events']; |
---|
| 3970 | $event = $params['this_event']; |
---|
| 3971 | } |
---|
| 3972 | |
---|
| 3973 | $month = $event['start']['month']; |
---|
| 3974 | $mday = $event['start']['mday']; |
---|
| 3975 | $year = $event['start']['year']; |
---|
| 3976 | |
---|
| 3977 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3978 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 3979 | |
---|
| 3980 | $overlap = ''; |
---|
| 3981 | for($i=0;$i<count($overlapping_events);$i++) |
---|
| 3982 | { |
---|
| 3983 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
| 3984 | foreach($overlapped_event['participants'] as $id => $status) |
---|
| 3985 | { |
---|
| 3986 | $conflict = isset($event['participants'][$id]); |
---|
| 3987 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
| 3988 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
| 3989 | ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; |
---|
| 3990 | } |
---|
| 3991 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
| 3992 | $overlap .= '<ul><font size="1"><span>'. |
---|
| 3993 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
| 3994 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
| 3995 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
| 3996 | $this->normDec($overlapped_event['end']['min']). |
---|
| 3997 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
| 3998 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
| 3999 | else |
---|
| 4000 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>"; |
---|
| 4001 | } |
---|
| 4002 | |
---|
| 4003 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 4004 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 4005 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 4006 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 4007 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
| 4008 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 4009 | |
---|
| 4010 | $p = $GLOBALS['phpgw']->template; |
---|
| 4011 | $p->set_file( |
---|
| 4012 | Array( |
---|
| 4013 | 'overlap' => 'overlap.tpl', |
---|
| 4014 | 'form_button' => 'form_button_script.tpl' |
---|
| 4015 | ) |
---|
| 4016 | ); |
---|
| 4017 | |
---|
| 4018 | $var = Array( |
---|
| 4019 | 'color' => $this->theme['bg_text'], |
---|
| 4020 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
| 4021 | '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)), |
---|
| 4022 | 'overlap_list' => $overlap |
---|
| 4023 | ); |
---|
| 4024 | $p->set_var($var); |
---|
| 4025 | |
---|
| 4026 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
| 4027 | $var = Array( |
---|
| 4028 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), |
---|
| 4029 | 'action_text_button' => lang('Ignore Conflict'), |
---|
| 4030 | 'action_confirm_button' => '', |
---|
| 4031 | 'action_extra_field' => '', |
---|
| 4032 | 'button_id' => 'ignore_button' |
---|
| 4033 | ); |
---|
| 4034 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
| 4035 | |
---|
| 4036 | $var = Array( |
---|
| 4037 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), |
---|
| 4038 | 'action_text_button' => lang('Re-Edit Event'), |
---|
| 4039 | 'action_confirm_button' => '', |
---|
| 4040 | 'action_extra_field' => '', |
---|
| 4041 | 'button_id' => 'redit_button' |
---|
| 4042 | ); |
---|
| 4043 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
| 4044 | $p->pparse('out','overlap'); |
---|
| 4045 | } |
---|
| 4046 | |
---|
| 4047 | function planner_participants($parts) |
---|
| 4048 | { |
---|
| 4049 | static $id2lid; |
---|
| 4050 | |
---|
| 4051 | $names = ''; |
---|
| 4052 | while (list($id,$status) = each($parts)) |
---|
| 4053 | { |
---|
| 4054 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
| 4055 | |
---|
| 4056 | if (!isset($id2lid[$id])) |
---|
| 4057 | { |
---|
| 4058 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
| 4059 | } |
---|
| 4060 | if (strlen($names)) |
---|
| 4061 | { |
---|
| 4062 | $names .= ",\n"; |
---|
| 4063 | } |
---|
| 4064 | $names .= $id2lid[$id]." ($status)"; |
---|
| 4065 | } |
---|
| 4066 | if($this->debug) |
---|
| 4067 | { |
---|
| 4068 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
| 4069 | } |
---|
| 4070 | return $names; |
---|
| 4071 | } |
---|
| 4072 | |
---|
| 4073 | function planner_category($ids) |
---|
| 4074 | { |
---|
| 4075 | static $cats; |
---|
| 4076 | if(!is_array($ids)) |
---|
| 4077 | { |
---|
| 4078 | if (strpos($ids,',')) |
---|
| 4079 | { |
---|
| 4080 | $id_array = explode(',',$ids); |
---|
| 4081 | } |
---|
| 4082 | else |
---|
| 4083 | { |
---|
| 4084 | $id_array[0] = $ids; |
---|
| 4085 | } |
---|
| 4086 | } |
---|
| 4087 | @reset($id_array); |
---|
| 4088 | $ret_val = Array(); |
---|
| 4089 | while(list($index,$id) = each($id_array)) |
---|
| 4090 | { |
---|
| 4091 | if (!isset($cats[$id])) |
---|
| 4092 | { |
---|
| 4093 | $cat_arr = $this->cat->return_single( $id ); |
---|
| 4094 | $cats[$id] = $cat_arr[0]; |
---|
| 4095 | $cats[$id]['color'] = strstr($cats[$id]['description'],'#'); |
---|
| 4096 | } |
---|
| 4097 | $ret_val[] = $cats[$id]; |
---|
| 4098 | } |
---|
| 4099 | return $ret_val; |
---|
| 4100 | } |
---|
| 4101 | |
---|
| 4102 | function week_header($month,$year,$display_name = False) |
---|
| 4103 | { |
---|
| 4104 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 4105 | |
---|
| 4106 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4107 | $p->set_unknowns('remove'); |
---|
| 4108 | $p->set_file( |
---|
| 4109 | Array ( |
---|
| 4110 | 'month_header' => 'month_header.tpl' |
---|
| 4111 | ) |
---|
| 4112 | ); |
---|
| 4113 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 4114 | $p->set_block('month_header','column_title','column_title'); |
---|
| 4115 | |
---|
| 4116 | $var = Array( |
---|
| 4117 | 'bgcolor' => $this->theme['th_bg'], |
---|
| 4118 | 'font_color' => $this->theme['th_text'] |
---|
| 4119 | ); |
---|
| 4120 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 4121 | { |
---|
| 4122 | $var = Array( |
---|
| 4123 | 'bgcolor' => '', |
---|
| 4124 | 'font_color' => '' |
---|
| 4125 | ); |
---|
| 4126 | } |
---|
| 4127 | $p->set_var($var); |
---|
| 4128 | |
---|
| 4129 | $p->set_var('col_width','14'); |
---|
| 4130 | if($display_name == True) |
---|
| 4131 | { |
---|
| 4132 | $p->set_var('col_title',lang('name')); |
---|
| 4133 | $p->parse('column_header','column_title',True); |
---|
| 4134 | $p->set_var('col_width','12'); |
---|
| 4135 | } |
---|
| 4136 | |
---|
| 4137 | for($i=0;$i<7;$i++) |
---|
| 4138 | { |
---|
| 4139 | $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i])); |
---|
| 4140 | $p->parse('column_header','column_title',True); |
---|
| 4141 | } |
---|
| 4142 | return $p->fp('out','monthly_header'); |
---|
| 4143 | } |
---|
| 4144 | |
---|
| 4145 | function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 4146 | { |
---|
| 4147 | if($owner == 0) |
---|
| 4148 | { |
---|
| 4149 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 4150 | } |
---|
| 4151 | |
---|
| 4152 | $temp_owner = $this->bo->owner; |
---|
| 4153 | |
---|
| 4154 | $str = ''; |
---|
| 4155 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4156 | $p->set_unknowns('keep'); |
---|
| 4157 | |
---|
| 4158 | $p->set_file( |
---|
| 4159 | Array( |
---|
| 4160 | 'month_header' => 'month_header.tpl', |
---|
| 4161 | 'month_day' => 'month_day.tpl' |
---|
| 4162 | ) |
---|
| 4163 | ); |
---|
| 4164 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 4165 | $p->set_block('month_header','month_column','month_column'); |
---|
| 4166 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 4167 | $p->set_block('month_day','day_event','day_event'); |
---|
| 4168 | $p->set_block('month_day','event','event'); |
---|
| 4169 | |
---|
| 4170 | $p->set_var('extra',''); |
---|
| 4171 | $p->set_var('col_width','14'); |
---|
| 4172 | if($display_name) |
---|
| 4173 | { |
---|
| 4174 | $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner)); |
---|
| 4175 | $p->parse('column_header','month_column',True); |
---|
| 4176 | $p->set_var('col_width','12'); |
---|
| 4177 | } |
---|
| 4178 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 4179 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 4180 | foreach($daily as $date => $day_params) |
---|
| 4181 | { |
---|
| 4182 | $year = (int)substr($date,0,4); |
---|
| 4183 | $month = (int)substr($date,4,2); |
---|
| 4184 | $day = (int)substr($date,6,2); |
---|
| 4185 | |
---|
| 4186 | $var = Array( |
---|
| 4187 | 'column_data' => '', |
---|
| 4188 | 'extra' => '' |
---|
| 4189 | ); |
---|
| 4190 | $p->set_var($var); |
---|
| 4191 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 4192 | { |
---|
| 4193 | if ($day_params['new_event']) |
---|
| 4194 | { |
---|
| 4195 | $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">' |
---|
| 4196 | . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">' |
---|
| 4197 | . '</a>'; |
---|
| 4198 | $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>'; |
---|
| 4199 | } |
---|
| 4200 | else |
---|
| 4201 | { |
---|
| 4202 | $new_event_link = ''; |
---|
| 4203 | $day_number = $day; |
---|
| 4204 | } |
---|
| 4205 | |
---|
| 4206 | $var = Array( |
---|
| 4207 | 'extra' => $day_params['extra'], |
---|
| 4208 | 'new_event_link'=> $new_event_link, |
---|
| 4209 | 'day_number' => $day_number |
---|
| 4210 | ); |
---|
| 4211 | if($day_params['week']) |
---|
| 4212 | { |
---|
| 4213 | |
---|
| 4214 | //NDEE: style! m_w_table in month_day.tpl |
---|
| 4215 | // week-hilite |
---|
| 4216 | //$var['new_event_link'] .= '<font size="-2"> '. |
---|
| 4217 | $var['new_event_link'] .= ' '. |
---|
| 4218 | (!$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>'); |
---|
| 4219 | } |
---|
| 4220 | |
---|
| 4221 | $p->set_var($var); |
---|
| 4222 | |
---|
| 4223 | if(@$day_params['holidays']) |
---|
| 4224 | { |
---|
| 4225 | foreach($day_params['holidays'] as $key => $value) |
---|
| 4226 | { |
---|
| 4227 | $var = Array( |
---|
| 4228 | 'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br |
---|
| 4229 | ); |
---|
| 4230 | $this->output_template_array($p,'daily_events','event',$var); |
---|
| 4231 | } |
---|
| 4232 | } |
---|
| 4233 | |
---|
| 4234 | if($day_params['appts']) |
---|
| 4235 | { |
---|
| 4236 | $var = Array( |
---|
| 4237 | 'week_day_font_size' => '2', |
---|
| 4238 | 'events' => '' |
---|
| 4239 | ); |
---|
| 4240 | $p->set_var($var); |
---|
| 4241 | $events = $this->bo->cached_events[$date]; |
---|
| 4242 | foreach($events as $event) |
---|
| 4243 | { |
---|
| 4244 | if ($this->bo->rejected_no_show($event)) |
---|
| 4245 | { |
---|
| 4246 | continue; // user does not want to see rejected events |
---|
| 4247 | } |
---|
| 4248 | $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year)); |
---|
| 4249 | $p->parse('events','event',True); |
---|
| 4250 | $p->set_var('day_events',''); |
---|
| 4251 | } |
---|
| 4252 | } |
---|
| 4253 | $p->parse('daily_events','day_event',True); |
---|
| 4254 | $p->parse('column_data','month_daily',True); |
---|
| 4255 | $p->set_var('daily_events',''); |
---|
| 4256 | $p->set_var('events',''); |
---|
| 4257 | /* if($day_params['week']) |
---|
| 4258 | { |
---|
| 4259 | $var = Array( |
---|
| 4260 | 'week_day_font_size' => '-2', |
---|
| 4261 | 'events' => (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'">' .$day_params['week'].'</a>':$day_params['week']) |
---|
| 4262 | ); |
---|
| 4263 | $this->output_template_array($p,'column_data','day_event',$var); |
---|
| 4264 | $p->set_var('events',''); |
---|
| 4265 | } */ |
---|
| 4266 | } |
---|
| 4267 | $p->parse('column_header','month_column',True); |
---|
| 4268 | $p->set_var('column_data',''); |
---|
| 4269 | } |
---|
| 4270 | $this->bo->owner = $temp_owner; |
---|
| 4271 | return $p->fp('out','monthly_header'); |
---|
| 4272 | } |
---|
| 4273 | |
---|
| 4274 | /***************************************************************************************/ |
---|
| 4275 | /*As funcoes abaixo |
---|
| 4276 | month_week_header() |
---|
| 4277 | month_display_week() |
---|
| 4278 | display_month_print() |
---|
| 4279 | month_day_of_week() - esta foi criada mas parte do codigo e de outra funcao da API (day_of_week()); |
---|
| 4280 | |
---|
| 4281 | foram duplicadas e modificadas para atender aas modificacoes do layout de impressao mensal da agenda de eventos; |
---|
| 4282 | TODO: otimizar o codigo |
---|
| 4283 | |
---|
| 4284 | Rommel Cysne |
---|
| 4285 | */ |
---|
| 4286 | |
---|
| 4287 | function month_week_header($month,$year,$display_name = False) |
---|
| 4288 | { |
---|
| 4289 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
| 4290 | $p->set_unknowns('remove'); |
---|
| 4291 | } |
---|
| 4292 | |
---|
| 4293 | |
---|
| 4294 | function month_day_of_week($year,$month,$day) |
---|
| 4295 | { |
---|
| 4296 | $dia = Array( |
---|
| 4297 | 0 => 'Domingo', |
---|
| 4298 | 1 => 'Segunda', |
---|
| 4299 | 2 => 'Terça', |
---|
| 4300 | 3 => 'Quarta', |
---|
| 4301 | 4 => 'Quinta', |
---|
| 4302 | 5 => 'Sexta', |
---|
| 4303 | 6 => 'Sábado' |
---|
| 4304 | ); |
---|
| 4305 | |
---|
| 4306 | if($month > 2) |
---|
| 4307 | { |
---|
| 4308 | $month -= 2; |
---|
| 4309 | } |
---|
| 4310 | else |
---|
| 4311 | { |
---|
| 4312 | $month += 10; |
---|
| 4313 | $year--; |
---|
| 4314 | } |
---|
| 4315 | $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); |
---|
| 4316 | |
---|
| 4317 | $month_day = ($day - 7 * floor($day / 7)); //retorna o numero do dia da semana (Ex: domingo eh dia 0, terca eh 2); |
---|
| 4318 | $weekday = $dia[$month_day]; //retorna o nome do dia da semana de acordo com seu numero; |
---|
| 4319 | |
---|
| 4320 | return ($weekday); |
---|
| 4321 | |
---|
| 4322 | } |
---|
| 4323 | |
---|
| 4324 | function month_display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
| 4325 | { |
---|
| 4326 | if($owner == 0) |
---|
| 4327 | { |
---|
| 4328 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 4329 | } |
---|
| 4330 | |
---|
| 4331 | $temp_owner = $this->bo->owner; |
---|
| 4332 | |
---|
| 4333 | $str = ''; |
---|
| 4334 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4335 | $p->set_unknowns('keep'); |
---|
| 4336 | |
---|
| 4337 | $p->set_file( |
---|
| 4338 | Array( |
---|
| 4339 | 'month_header' => 'month_header_print.tpl', |
---|
| 4340 | 'month_day' => 'month_day_print.tpl' |
---|
| 4341 | ) |
---|
| 4342 | ); |
---|
| 4343 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
| 4344 | $p->set_block('month_header','month_column','month_column'); |
---|
| 4345 | $p->set_block('month_day','month_daily','month_daily'); |
---|
| 4346 | $p->set_block('month_day','day_event','day_event'); |
---|
| 4347 | $p->set_block('month_day','event','event'); |
---|
| 4348 | |
---|
| 4349 | $p->set_var('extra',''); |
---|
| 4350 | $p->set_var('col_width','14'); |
---|
| 4351 | |
---|
| 4352 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
| 4353 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
| 4354 | |
---|
| 4355 | foreach($daily as $date => $day_params) |
---|
| 4356 | { |
---|
| 4357 | $year = (int)substr($date,0,4); |
---|
| 4358 | $month = (int)substr($date,4,2); |
---|
| 4359 | $day = (int)substr($date,6,2); |
---|
| 4360 | |
---|
| 4361 | $p->set_var($var); |
---|
| 4362 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
| 4363 | { |
---|
| 4364 | $new_event_link = ''; |
---|
| 4365 | $day_num = $day; |
---|
| 4366 | $dia_semana = $this->month_day_of_week($year,$month,$day_num); |
---|
| 4367 | $id_aux = mktime(0,0,0,$month,$day,$year); |
---|
| 4368 | $month_identifier = substr(lang(strftime("%B",$id_aux)),0,3); |
---|
| 4369 | $day_number = $dia_semana . ", " . $day_num; |
---|
| 4370 | |
---|
| 4371 | $var = Array( |
---|
| 4372 | 'extra' => $day_params['extra'], |
---|
| 4373 | 'new_event_link'=> $new_event_link, |
---|
| 4374 | 'day_number' => (isset($_GET['num_dias']) && ($_GET['num_dias'] > 1 || $_GET['num_dias'] == "")?$day_number:'') |
---|
| 4375 | ); |
---|
| 4376 | |
---|
| 4377 | $p->set_var($var); |
---|
| 4378 | |
---|
| 4379 | if($day_params['appts']) |
---|
| 4380 | { |
---|
| 4381 | $var = Array( |
---|
| 4382 | 'week_day_font_size' => '2', |
---|
| 4383 | 'events' => '' |
---|
| 4384 | ); |
---|
| 4385 | $p->set_var($var); |
---|
| 4386 | $eventsCached = $this->bo->cached_events[$date]; |
---|
| 4387 | |
---|
| 4388 | if($_GET['d'] == '1') |
---|
| 4389 | { |
---|
| 4390 | |
---|
| 4391 | for($i_events = 0; $i_events < count($eventsCached) ; $i_events++) |
---|
| 4392 | { |
---|
| 4393 | if ($eventsCached[$i_events]['users_status'] == 'R') |
---|
| 4394 | { |
---|
| 4395 | continue; // user does not want to see rejected events |
---|
| 4396 | } |
---|
| 4397 | $events[] = $eventsCached[$i_events]; |
---|
| 4398 | } |
---|
| 4399 | /*echo "<pre>"; |
---|
| 4400 | print_r($events1); |
---|
| 4401 | |
---|
| 4402 | echo "</pre>"; |
---|
| 4403 | exit();*/ |
---|
| 4404 | |
---|
| 4405 | $newEvents = Array(); |
---|
| 4406 | $eventAux = Array |
---|
| 4407 | ( |
---|
| 4408 | 'owner' => '', |
---|
| 4409 | 'id' => '', |
---|
| 4410 | 'type' => '', |
---|
| 4411 | 'public' => '', |
---|
| 4412 | 'category' => '', |
---|
| 4413 | 'title' => '', |
---|
| 4414 | 'description' => '', |
---|
| 4415 | 'alter_by' => '', |
---|
| 4416 | 'observations' => '', |
---|
| 4417 | 'attachment' => '', |
---|
| 4418 | 'ex_participants' => '', |
---|
| 4419 | 'uid' => '', |
---|
| 4420 | 'location' => '', |
---|
| 4421 | 'reference' => '', |
---|
| 4422 | 'start' => Array |
---|
| 4423 | ( |
---|
| 4424 | 'year' => '', |
---|
| 4425 | 'month' => '', |
---|
| 4426 | 'mday' => '', |
---|
| 4427 | 'hour' => '', |
---|
| 4428 | 'min' => '', |
---|
| 4429 | 'sec' => '', |
---|
| 4430 | 'alarm' => '', |
---|
| 4431 | ), |
---|
| 4432 | |
---|
| 4433 | 'modtime' => Array |
---|
| 4434 | ( |
---|
| 4435 | ), |
---|
| 4436 | |
---|
| 4437 | 'end' => Array |
---|
| 4438 | ( |
---|
| 4439 | 'year' => '', |
---|
| 4440 | 'month' => '', |
---|
| 4441 | 'mday' => '', |
---|
| 4442 | 'hour' => '', |
---|
| 4443 | 'min' => '', |
---|
| 4444 | 'sec' => '', |
---|
| 4445 | 'alarm' => '', |
---|
| 4446 | ), |
---|
| 4447 | |
---|
| 4448 | 'priority' => '', |
---|
| 4449 | 'users_status' => '', |
---|
| 4450 | 'participants' => Array |
---|
| 4451 | ( |
---|
| 4452 | ), |
---|
| 4453 | |
---|
| 4454 | 'alarm' => Array |
---|
| 4455 | ( |
---|
| 4456 | ), |
---|
| 4457 | |
---|
| 4458 | ); |
---|
| 4459 | |
---|
| 4460 | $delta = 60; //em segundos |
---|
| 4461 | for($i_events = 0; $i_events < count($events) ; $i_events++) |
---|
| 4462 | { |
---|
| 4463 | |
---|
| 4464 | $newEvents[] = $events[$i_events]; |
---|
| 4465 | |
---|
| 4466 | $hf_current = mktime($events[$i_events]['end']['hour'], 0, 0, $month, $day, $year); |
---|
| 4467 | $hi_prox = mktime($events[$i_events+1]['start']['hour'], 0, 0, $month, $day, $year); |
---|
| 4468 | |
---|
| 4469 | if($events[$i_events]['end']['min'] > 0) |
---|
| 4470 | { |
---|
| 4471 | $hf_current += 60*$delta; |
---|
| 4472 | } |
---|
| 4473 | |
---|
| 4474 | while($hi_prox > $hf_current) |
---|
| 4475 | { |
---|
| 4476 | |
---|
| 4477 | $aux1 = date('Y:m:d:H:i:s',$hf_current); |
---|
| 4478 | $aux2 = explode(':',$aux1); |
---|
| 4479 | $eventAux['start']['year'] = $aux2[0]; |
---|
| 4480 | $eventAux['start']['month'] = $aux2[1]; |
---|
| 4481 | $eventAux['start']['mday'] = $aux2[2]; |
---|
| 4482 | $eventAux['start']['hour'] = $aux2[3]; |
---|
| 4483 | $eventAux['start']['min'] = $aux2[4]; |
---|
| 4484 | $eventAux['start']['sec'] = $aux2[5]; |
---|
| 4485 | |
---|
| 4486 | //$aux3 = date('Y:m:d:H:i:s',$hf_current); |
---|
| 4487 | //$aux4 = explode(':',$aux3); |
---|
| 4488 | $eventAux['end']['year'] = $aux2[0]; |
---|
| 4489 | $eventAux['end']['month'] = $aux2[1]; |
---|
| 4490 | $eventAux['end']['mday'] = $aux2[2]; |
---|
| 4491 | $eventAux['end']['hour'] = $aux2[3]; |
---|
| 4492 | $eventAux['end']['min'] = $aux2[4]; |
---|
| 4493 | $eventAux['end']['sec'] = $aux2[5]; |
---|
| 4494 | |
---|
| 4495 | $eventAux['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 4496 | $eventAux['title'] = "\n\n\n"; |
---|
| 4497 | $eventAux['description'] = ''; |
---|
| 4498 | $eventAux['observations'] = ''; |
---|
| 4499 | $eventAux['location'] = ''; |
---|
| 4500 | |
---|
| 4501 | $newEvents[] = $eventAux; |
---|
| 4502 | $hf_current += 60*$delta; |
---|
| 4503 | |
---|
| 4504 | } |
---|
| 4505 | } |
---|
| 4506 | |
---|
| 4507 | foreach($newEvents as $event) |
---|
| 4508 | { |
---|
| 4509 | $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); |
---|
| 4510 | $p->parse('events','event',True); |
---|
| 4511 | $p->set_var('day_events',''); |
---|
| 4512 | } |
---|
| 4513 | } |
---|
| 4514 | else |
---|
| 4515 | { |
---|
| 4516 | foreach($eventsCached as $event) |
---|
| 4517 | { |
---|
| 4518 | if ($this->bo->rejected_no_show($event) || $event['users_status'] == 'R') |
---|
| 4519 | { |
---|
| 4520 | continue; // user does not want to see rejected events |
---|
| 4521 | } |
---|
| 4522 | $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); |
---|
| 4523 | $p->parse('events','event',True); |
---|
| 4524 | $p->set_var('day_events',''); |
---|
| 4525 | } |
---|
| 4526 | } |
---|
| 4527 | |
---|
| 4528 | /*echo "<pre>"; |
---|
| 4529 | print_r($newEvents); |
---|
| 4530 | |
---|
| 4531 | echo "</pre>"; |
---|
| 4532 | exit();*/ |
---|
| 4533 | } |
---|
| 4534 | $p->parse('daily_events','day_event',True); |
---|
| 4535 | $p->parse('column_data','month_daily',True); |
---|
| 4536 | $p->set_var('daily_events',''); |
---|
| 4537 | $p->set_var('events',''); |
---|
| 4538 | |
---|
| 4539 | } |
---|
| 4540 | $p->parse('column_header','month_column',True); |
---|
| 4541 | $p->set_var('column_data',''); |
---|
| 4542 | } |
---|
| 4543 | $this->bo->owner = $temp_owner; |
---|
| 4544 | return $p->fp('out','monthly_header'); |
---|
| 4545 | |
---|
| 4546 | } |
---|
| 4547 | |
---|
| 4548 | function display_month_print($month,$year,$showyear,$owner=0) |
---|
| 4549 | { |
---|
| 4550 | if($this->debug) |
---|
| 4551 | { |
---|
| 4552 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 4553 | } |
---|
| 4554 | |
---|
| 4555 | $day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual; |
---|
| 4556 | $num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial; |
---|
| 4557 | |
---|
| 4558 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
| 4559 | // $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 4560 | |
---|
| 4561 | if($num_dias != '') |
---|
| 4562 | { |
---|
| 4563 | //se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias; |
---|
| 4564 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month,$day_ini+$num_dias-1,$year))); |
---|
| 4565 | } |
---|
| 4566 | else |
---|
| 4567 | { |
---|
| 4568 | //se a qtde de dias nao for informada, a data final para impressao vai ate o fim do mes corrente; |
---|
| 4569 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 4570 | } |
---|
| 4571 | |
---|
| 4572 | if($day_ini != 0) |
---|
| 4573 | { |
---|
| 4574 | //o dia de inicio para impressao passa a ser o informado em $day_ini do mes corrente; |
---|
| 4575 | $start = mktime(0,0,0,$month,$day_ini,$year); |
---|
| 4576 | } |
---|
| 4577 | else |
---|
| 4578 | { |
---|
| 4579 | //se nao for informado o dia para inicio da impressao, esta comeca no dia 1 do mes corrente; |
---|
| 4580 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 4581 | } |
---|
| 4582 | //$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 15); |
---|
| 4583 | $start_d = (int)(date('Ymd',$start));//variavel auxiliar que recebe a data inicial de impressao no formato 'Ymd'; |
---|
| 4584 | $saux = (int)(substr($start_d,4,2));//variavel auxiliar que recebe o mes do inicio da impressao; |
---|
| 4585 | $eaux = (int)(substr($monthend,4,2)) + 1;//variavel auxiliar que recebe o mes do fim da impressao; |
---|
| 4586 | //A funcao store_to_cache devolve todos os eventos existentes de determinado usuario em um periodo de tempo |
---|
| 4587 | //especifico. Originalmente, na impressao mensal, esse periodo de tempo era o mes corrente exibido na tela. |
---|
| 4588 | //A mudanca consiste no fato de que uma nova variavel ($saux) e enviada com o mes de inicio do periodo |
---|
| 4589 | //atraves do indice 'smonth' e uma segunda variavel ($eaux) envia o mes final do periodo de tempo atraves |
---|
| 4590 | //do indice 'emonth'. Vide mais comentarios sobre esses valores em class.bocalendar.inc.php, |
---|
| 4591 | //function store_to_cache($params); |
---|
| 4592 | $this->bo->store_to_cache( |
---|
| 4593 | Array( |
---|
| 4594 | 'syear' => $year,//ano atual |
---|
| 4595 | 'smonth'=> $saux,//mes inicial |
---|
| 4596 | 'emonth'=> $eaux,//mes final |
---|
| 4597 | 'sday' => 1 |
---|
| 4598 | )); |
---|
| 4599 | |
---|
| 4600 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4601 | $p->set_unknowns('keep'); |
---|
| 4602 | |
---|
| 4603 | $p->set_file( |
---|
| 4604 | Array( |
---|
| 4605 | 'week' => 'month_day_print.tpl' |
---|
| 4606 | ) |
---|
| 4607 | ); |
---|
| 4608 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 4609 | $p->set_block('week','event','event'); |
---|
| 4610 | |
---|
| 4611 | $var = Array( |
---|
| 4612 | 'cols' => 1 |
---|
| 4613 | //'day_events'=> '' |
---|
| 4614 | ); |
---|
| 4615 | |
---|
| 4616 | $cellcolor = $this->theme['row_on']; |
---|
| 4617 | |
---|
| 4618 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 4619 | { |
---|
| 4620 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 4621 | $var = Array( |
---|
| 4622 | 'day_events' => $this->month_display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 4623 | ); |
---|
| 4624 | $this->output_template_array($p,'row','event',$var); |
---|
| 4625 | } |
---|
| 4626 | return $p->fp('out','m_w_table'); |
---|
| 4627 | } |
---|
| 4628 | |
---|
| 4629 | |
---|
| 4630 | /***************************************************************************************/ |
---|
| 4631 | |
---|
| 4632 | function display_month($params) //($month,$year,$showyear,$owner=0) |
---|
| 4633 | { |
---|
| 4634 | $month = $params['month']; |
---|
| 4635 | $year = $params['year']; |
---|
| 4636 | $showyear = $params['showyear']; |
---|
| 4637 | $owner = $params['owner']; |
---|
| 4638 | |
---|
| 4639 | if($this->debug) |
---|
| 4640 | { |
---|
| 4641 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
| 4642 | } |
---|
| 4643 | |
---|
| 4644 | $this->bo->store_to_cache( |
---|
| 4645 | Array( |
---|
| 4646 | 'syear' => $year, |
---|
| 4647 | 'smonth'=> $month, |
---|
| 4648 | 'sday' => 1 |
---|
| 4649 | ) |
---|
| 4650 | ); |
---|
| 4651 | |
---|
| 4652 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
| 4653 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
| 4654 | |
---|
| 4655 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
| 4656 | |
---|
| 4657 | if($this->debug) |
---|
| 4658 | { |
---|
| 4659 | echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n"; |
---|
| 4660 | echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n"; |
---|
| 4661 | } |
---|
| 4662 | |
---|
| 4663 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4664 | $p->set_unknowns('keep'); |
---|
| 4665 | |
---|
| 4666 | $p->set_file( |
---|
| 4667 | Array( |
---|
| 4668 | 'week' => 'month_day.tpl' |
---|
| 4669 | ) |
---|
| 4670 | ); |
---|
| 4671 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 4672 | $p->set_block('week','event','event'); |
---|
| 4673 | |
---|
| 4674 | $var = Array( |
---|
| 4675 | 'cols' => 1, |
---|
| 4676 | 'day_events'=> $this->week_header($month,$year,False) |
---|
| 4677 | ); |
---|
| 4678 | $this->output_template_array($p,'row','event',$var); |
---|
| 4679 | |
---|
| 4680 | $cellcolor = $this->theme['row_on']; |
---|
| 4681 | |
---|
| 4682 | $result_events_json = $this->print_events_to_show_json($params); |
---|
| 4683 | $p->set_var('date','Date(2011,1,1)'); |
---|
| 4684 | $p->set_var('hora_final',$result_events_json['hora_final']); |
---|
| 4685 | $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); |
---|
| 4686 | |
---|
| 4687 | |
---|
| 4688 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
| 4689 | { |
---|
| 4690 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 4691 | $var = Array( |
---|
| 4692 | 'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
| 4693 | ); |
---|
| 4694 | $this->output_template_array($p,'row','event',$var); |
---|
| 4695 | } |
---|
| 4696 | return $p->fp('out','m_w_table'); |
---|
| 4697 | } |
---|
| 4698 | |
---|
| 4699 | function display_weekly($params) |
---|
| 4700 | { |
---|
| 4701 | if(!is_array($params)) |
---|
| 4702 | { |
---|
| 4703 | $this->index(); |
---|
| 4704 | } |
---|
| 4705 | |
---|
| 4706 | $year = substr($params['date'],0,4); |
---|
| 4707 | $month = substr($params['date'],4,2); |
---|
| 4708 | $day = substr($params['date'],6,2); |
---|
| 4709 | $showyear = $params['showyear']; |
---|
| 4710 | $owners = $params['owners']; |
---|
| 4711 | |
---|
| 4712 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4713 | $p->set_unknowns('keep'); |
---|
| 4714 | |
---|
| 4715 | $p->set_file( |
---|
| 4716 | Array( |
---|
| 4717 | 'week' => 'month_day.tpl' |
---|
| 4718 | ) |
---|
| 4719 | ); |
---|
| 4720 | $p->set_block('week','m_w_table','m_w_table'); |
---|
| 4721 | $p->set_block('week','event','event'); |
---|
| 4722 | |
---|
| 4723 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4724 | |
---|
| 4725 | $cellcolor = $this->theme['row_off']; |
---|
| 4726 | |
---|
| 4727 | $true_printer_friendly = $this->bo->printer_friendly; |
---|
| 4728 | |
---|
| 4729 | if(is_array($owners)) |
---|
| 4730 | { |
---|
| 4731 | $display_name = True; |
---|
| 4732 | $counter = count($owners); |
---|
| 4733 | $owners_array = $owners; |
---|
| 4734 | $cols = 8; |
---|
| 4735 | } |
---|
| 4736 | else |
---|
| 4737 | { |
---|
| 4738 | $display_name = False; |
---|
| 4739 | $counter = 1; |
---|
| 4740 | $owners_array[0] = $owners; |
---|
| 4741 | $cols = 7; |
---|
| 4742 | } |
---|
| 4743 | $var = Array( |
---|
| 4744 | 'cols' => $cols, |
---|
| 4745 | 'day_events' => $this->week_header($month,$year,$display_name) |
---|
| 4746 | ); |
---|
| 4747 | $this->output_template_array($p,'row','event',$var); |
---|
| 4748 | |
---|
| 4749 | $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 4750 | $tstop = $tstart + 604800; |
---|
| 4751 | $original_owner = $this->bo->so->owner; |
---|
| 4752 | for($i=0;$i<$counter;$i++) |
---|
| 4753 | { |
---|
| 4754 | $this->bo->so->owner = $owners_array[$i]; |
---|
| 4755 | $this->bo->so->open_box($owners_array[$i]); |
---|
| 4756 | $this->bo->store_to_cache( |
---|
| 4757 | Array( |
---|
| 4758 | 'syear' => date('Y',$tstart), |
---|
| 4759 | 'smonth' => date('m',$tstart), |
---|
| 4760 | 'sday' => date('d',$tstart), |
---|
| 4761 | 'eyear' => date('Y',$tstop), |
---|
| 4762 | 'emonth' => date('m',$tstop), |
---|
| 4763 | 'eday' => date('d',$tstop) |
---|
| 4764 | ) |
---|
| 4765 | ); |
---|
| 4766 | $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$owners_array[$i])); |
---|
| 4767 | $p->parse('row','event',True); |
---|
| 4768 | } |
---|
| 4769 | $this->bo->so->owner = $original_owner; |
---|
| 4770 | $this->bo->printer_friendly = $true_printer_friendly; |
---|
| 4771 | return $p->fp('out','m_w_table'); |
---|
| 4772 | } |
---|
| 4773 | |
---|
| 4774 | function view_event($event,$alarms=False) |
---|
| 4775 | { |
---|
| 4776 | if((!$event['participants'][$this->bo->owner] && !$this->bo->check_perms(PHPGW_ACL_READ,$event))) |
---|
| 4777 | { |
---|
| 4778 | return False; |
---|
| 4779 | } |
---|
| 4780 | |
---|
| 4781 | $p = &$GLOBALS['phpgw']->template; |
---|
| 4782 | |
---|
| 4783 | $p->set_file( |
---|
| 4784 | Array( |
---|
| 4785 | 'view' => 'view.tpl' |
---|
| 4786 | ) |
---|
| 4787 | ); |
---|
| 4788 | $p->set_block('view','view_event','view_event'); |
---|
| 4789 | $p->set_block('view','list','list'); |
---|
| 4790 | $p->set_block('view','hr','hr'); |
---|
| 4791 | |
---|
| 4792 | $vars = $this->bo->event2array($event); |
---|
| 4793 | |
---|
| 4794 | if($vars['attachment']['data'] == "") |
---|
| 4795 | $vars['attachment']['data'] = lang('No Attachment'); |
---|
| 4796 | else{ |
---|
| 4797 | $vars['attachment']['data'] = lang('Has attachment(s)'); |
---|
| 4798 | } |
---|
| 4799 | |
---|
| 4800 | $vars['title']['tr_color'] = $this->theme['th_bg']; |
---|
| 4801 | |
---|
| 4802 | foreach($vars['participants']['data'] as $user => $str) |
---|
| 4803 | { |
---|
| 4804 | if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && ereg('^(.*) \((.*)\)$',$str,$parts)) |
---|
| 4805 | { |
---|
| 4806 | $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; |
---|
| 4807 | $vars['participants']['data'][$user].=' (<a href=\'index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event='.$event['id'].'&delegator='.$user.'&date='.$_REQUEST["date"].'&eventArray='.$event.'\'>'.lang("Delegate event").'</a>)'; |
---|
| 4808 | //system('echo "event: '.$event['start'].'" >>/tmp/controle'); |
---|
| 4809 | } |
---|
| 4810 | } |
---|
| 4811 | $vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']); |
---|
| 4812 | foreach($vars as $var) |
---|
| 4813 | { |
---|
| 4814 | if (strlen($var['data'])) |
---|
| 4815 | { |
---|
| 4816 | $this->output_template_array($p,'row','list',$var); |
---|
| 4817 | } |
---|
| 4818 | } |
---|
| 4819 | |
---|
| 4820 | if($alarms && count($event['alarm'])) |
---|
| 4821 | { |
---|
| 4822 | $p->set_var('th_bg',$this->theme['th_bg']); |
---|
| 4823 | $p->set_var('hr_text',lang('Alarms')); |
---|
| 4824 | $p->parse('row','hr',True); |
---|
| 4825 | foreach($event['alarm'] as $key => $alarm) |
---|
| 4826 | { |
---|
| 4827 | 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 |
---|
| 4828 | { |
---|
| 4829 | $icon = '<img src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled':'disabled')).'" width="13" height="13">'; |
---|
| 4830 | $var = Array( |
---|
| 4831 | 'field' => $icon.$GLOBALS['phpgw']->common->show_date($alarm['time']), |
---|
| 4832 | 'data' => lang('Email Notification for %1',$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner'])) |
---|
| 4833 | ); |
---|
| 4834 | $this->output_template_array($p,'row','list',$var); |
---|
| 4835 | } |
---|
| 4836 | } |
---|
| 4837 | } |
---|
| 4838 | return True; |
---|
| 4839 | } |
---|
| 4840 | |
---|
| 4841 | function nm_on_off() |
---|
| 4842 | { |
---|
| 4843 | if($GLOBALS['phpgw']->nextmatchs->alternate_row_color() == $this->theme['row_on']) |
---|
| 4844 | { |
---|
| 4845 | return '_on'; |
---|
| 4846 | } |
---|
| 4847 | return '_off'; |
---|
| 4848 | } |
---|
| 4849 | |
---|
| 4850 | function slot_num($time,$set_day_start=0,$set_day_end=0) |
---|
| 4851 | { |
---|
| 4852 | static $day_start, $day_end, $interval=0; |
---|
| 4853 | |
---|
| 4854 | if ($set_day_start) $day_start = $set_day_start; |
---|
| 4855 | if ($set_day_end) $day_end = $set_day_end; |
---|
| 4856 | if (!$interval) $interval = 60*$this->bo->prefs['calendar']['interval']; |
---|
| 4857 | |
---|
| 4858 | if ($time > $day_end) |
---|
| 4859 | { |
---|
| 4860 | $time = $day_end; |
---|
| 4861 | } |
---|
| 4862 | $slot = (int)(($time - $day_start) / $interval); |
---|
| 4863 | |
---|
| 4864 | return $slot < 0 ? 0 : 1+$slot; |
---|
| 4865 | } |
---|
| 4866 | |
---|
| 4867 | function print_day($params) |
---|
| 4868 | { |
---|
| 4869 | if(!is_array($params)) |
---|
| 4870 | { |
---|
| 4871 | $this->index(); |
---|
| 4872 | } |
---|
| 4873 | |
---|
| 4874 | print_debug('in print_day()'); |
---|
| 4875 | |
---|
| 4876 | $this->bo->store_to_cache( |
---|
| 4877 | Array( |
---|
| 4878 | 'syear' => $params['year'], |
---|
| 4879 | 'smonth' => $params['month'], |
---|
| 4880 | 'sday' => $params['day'], |
---|
| 4881 | 'eyear' => $params['year'], |
---|
| 4882 | 'emonth' => $params['month'], |
---|
| 4883 | 'eday' => $params['day'] |
---|
| 4884 | ) |
---|
| 4885 | ); |
---|
| 4886 | |
---|
| 4887 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 4888 | $p->set_unknowns('keep'); |
---|
| 4889 | |
---|
| 4890 | $tpl = 'day_cal.tpl'; |
---|
| 4891 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
| 4892 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
| 4893 | { |
---|
| 4894 | $tpl = 'day_list.tpl'; |
---|
| 4895 | } |
---|
| 4896 | $templates = Array( |
---|
| 4897 | 'day_cal' => $tpl |
---|
| 4898 | ); |
---|
| 4899 | |
---|
| 4900 | $p->set_file($templates); |
---|
| 4901 | $p->set_block('day_cal','day','day'); |
---|
| 4902 | $p->set_block('day_cal','day_row','day_row'); |
---|
| 4903 | $p->set_block('day_cal','day_event_on','day_event_on'); |
---|
| 4904 | $p->set_block('day_cal','day_event_off','day_event_off'); |
---|
| 4905 | $p->set_block('day_cal','day_event_holiday','day_event_holiday'); |
---|
| 4906 | $p->set_block('day_cal','day_time','day_time'); |
---|
| 4907 | |
---|
| 4908 | $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); |
---|
| 4909 | |
---|
| 4910 | $day_start = mktime((int)($this->bo->prefs['calendar']['workdaystarts']),0,0,$params['month'],$params['day'],$params['year']); |
---|
| 4911 | $day_end = mktime((int)($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']); |
---|
| 4912 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
| 4913 | print_debug('Date to Eval',$date_to_eval); |
---|
| 4914 | $events_to_show = array(); |
---|
| 4915 | if($daily[$date_to_eval]['appts']) |
---|
| 4916 | { |
---|
| 4917 | $events = $this->bo->cached_events[$date_to_eval]; |
---|
| 4918 | print_debug('Date',$date_to_eval); |
---|
| 4919 | print_debug('Count',count($events)); |
---|
| 4920 | foreach($events as $event) |
---|
| 4921 | { |
---|
| 4922 | if ($this->bo->rejected_no_show($event)) |
---|
| 4923 | { |
---|
| 4924 | continue; // user does not want to see rejected events |
---|
| 4925 | } |
---|
| 4926 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
| 4927 | { |
---|
| 4928 | $this->bo->set_recur_date($event,$date_to_eval); |
---|
| 4929 | } |
---|
| 4930 | $events_to_show[] = array( |
---|
| 4931 | 'starttime' => $this->bo->maketime($event['start']), |
---|
| 4932 | 'endtime' => $this->bo->maketime($event['end']), |
---|
| 4933 | 'content' => $this->link_to_entry($event,$params['month'],$params['day'],$params['year']) |
---|
| 4934 | ); |
---|
| 4935 | } |
---|
| 4936 | } |
---|
| 4937 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
| 4938 | $other = $GLOBALS['phpgw']->hooks->process(array( |
---|
| 4939 | 'location' => 'calendar_include_events', |
---|
| 4940 | 'year' => $params['year'], |
---|
| 4941 | 'month' => $params['month'], |
---|
| 4942 | 'day' => $params['day'], |
---|
| 4943 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
| 4944 | )); |
---|
| 4945 | |
---|
| 4946 | if (is_array($other)) |
---|
| 4947 | { |
---|
| 4948 | foreach($other as $evts) |
---|
| 4949 | { |
---|
| 4950 | if (is_array($evts)) |
---|
| 4951 | { |
---|
| 4952 | $events_to_show = array_merge($events_to_show,$evts); |
---|
| 4953 | } |
---|
| 4954 | } |
---|
| 4955 | usort($events_to_show,create_function('$a,$b','return $a[\'starttime\']-$b[\'starttime\'];')); |
---|
| 4956 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
| 4957 | } |
---|
| 4958 | |
---|
| 4959 | if (count($events_to_show)) |
---|
| 4960 | { |
---|
| 4961 | $last_slot_end = -1; |
---|
| 4962 | foreach($events_to_show as $event) |
---|
| 4963 | { |
---|
| 4964 | $slot = $this->slot_num($event['starttime'],$day_start,$day_end); |
---|
| 4965 | $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 |
---|
| 4966 | |
---|
| 4967 | if ($slot <= $last_slot_end) |
---|
| 4968 | { |
---|
| 4969 | $slot = $last_slot; |
---|
| 4970 | $slot_end = max($last_slot_end,$slot_end); |
---|
| 4971 | } |
---|
| 4972 | $rows[$slot] .= $event['content']; |
---|
| 4973 | |
---|
| 4974 | print_debug('slot',$slot); |
---|
| 4975 | print_debug('row',$rows[$slot]); |
---|
| 4976 | |
---|
| 4977 | $row_span[$slot] = 1 + $slot_end - $slot; |
---|
| 4978 | |
---|
| 4979 | $last_slot = $slot; |
---|
| 4980 | $last_slot_end = $slot_end; |
---|
| 4981 | 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)); |
---|
| 4982 | print_debug('Slot',$slot); |
---|
| 4983 | } |
---|
| 4984 | //echo "rows=<pre>"; print_r($rows); echo "<br>row_span="; print_r($row_span); echo "</pre>\n"; |
---|
| 4985 | } |
---|
| 4986 | $holiday_names = $daily[$date_to_eval]['holidays']; |
---|
| 4987 | if(!$holiday_names) |
---|
| 4988 | { |
---|
| 4989 | $row_to_print = $this->nm_on_off(); |
---|
| 4990 | } |
---|
| 4991 | else |
---|
| 4992 | { |
---|
| 4993 | $row_to_print = '_holiday'; |
---|
| 4994 | foreach($holiday_names as $name) |
---|
| 4995 | { |
---|
| 4996 | $rows[0] = '<center>'.$name.'</center>' . $rows[0]; |
---|
| 4997 | } |
---|
| 4998 | } |
---|
| 4999 | $last_slot = $this->slot_num($day_end,$day_start,$day_end); |
---|
| 5000 | $rowspan = 0; |
---|
| 5001 | for ($slot = 0; $slot <= $last_slot; ++$slot) |
---|
| 5002 | { |
---|
| 5003 | $p->set_var('extras',''); |
---|
| 5004 | if ($rowspan > 1) |
---|
| 5005 | { |
---|
| 5006 | $p->set_var('event',''); |
---|
| 5007 | $rowspan--; |
---|
| 5008 | } |
---|
| 5009 | elseif (!isset($rows[$slot])) |
---|
| 5010 | { |
---|
| 5011 | $p->set_var('event',' '); |
---|
| 5012 | $row_to_print = $this->nm_on_off(); |
---|
| 5013 | $p->parse('event','day_event'.$row_to_print); |
---|
| 5014 | } |
---|
| 5015 | else |
---|
| 5016 | { |
---|
| 5017 | $rowspan = (int)$row_span[$slot]; |
---|
| 5018 | if ($rowspan > 1) |
---|
| 5019 | { |
---|
| 5020 | $p->set_var('extras',' rowspan="'.$rowspan.'"'); |
---|
| 5021 | } |
---|
| 5022 | $p->set_var('event',$rows[$slot]); |
---|
| 5023 | $row_to_print = $this->nm_on_off(); |
---|
| 5024 | $p->parse('event','day_event'.$row_to_print); |
---|
| 5025 | } |
---|
| 5026 | $open_link = $close_link = ''; |
---|
| 5027 | $time = ' '; |
---|
| 5028 | |
---|
| 5029 | if (0 < $slot && $slot < $last_slot) // normal time-slot not before or after day_start/end |
---|
| 5030 | { |
---|
| 5031 | $time = $day_start + ($slot-1) * 60 * $this->bo->prefs['calendar']['interval']; |
---|
| 5032 | $hour = date('H',$time); |
---|
| 5033 | $min = date('i',$time); |
---|
| 5034 | $time = $GLOBALS['phpgw']->common->formattime($hour,$min); |
---|
| 5035 | |
---|
| 5036 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 5037 | { |
---|
| 5038 | $open_link = ' <a href="'.$this->page('add',"&date=$date_to_eval&hour=$hour&minute=$min").'">'; |
---|
| 5039 | $close_link = '</a> '; |
---|
| 5040 | } |
---|
| 5041 | } |
---|
| 5042 | $p->set_var(Array( |
---|
| 5043 | 'open_link' => $open_link, |
---|
| 5044 | 'time' => $time, |
---|
| 5045 | 'close_link' => $close_link, |
---|
| 5046 | 'tr_color' => '' // dummy to stop output_template_array to set it |
---|
| 5047 | )); |
---|
| 5048 | $p->parse('time','day_time'); |
---|
| 5049 | |
---|
| 5050 | $p->parse('row','day_row',True); |
---|
| 5051 | } |
---|
| 5052 | return $p->fp('out','day'); |
---|
| 5053 | } // end function |
---|
| 5054 | |
---|
| 5055 | //função para exibição do calendário novo. |
---|
| 5056 | |
---|
| 5057 | function print_day_new($params){ |
---|
| 5058 | $this->bo->store_to_cache( |
---|
| 5059 | Array( |
---|
| 5060 | 'syear' => $params['year'], |
---|
| 5061 | 'smonth' => $params['month'], |
---|
| 5062 | 'sday' => $params['day'], |
---|
| 5063 | 'eyear' => $params['year'], |
---|
| 5064 | 'emonth' => $params['month'], |
---|
| 5065 | 'eday' => $params['day'] |
---|
| 5066 | ) |
---|
| 5067 | ); |
---|
| 5068 | |
---|
| 5069 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 5070 | $p->set_unknowns('keep'); |
---|
| 5071 | |
---|
| 5072 | $tpl = 'day_cal.tpl'; |
---|
| 5073 | //$new_component_tpl = 'new_component.tpl'; |
---|
| 5074 | |
---|
| 5075 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
| 5076 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
| 5077 | { |
---|
| 5078 | $tpl = 'day_list.tpl'; |
---|
| 5079 | } |
---|
| 5080 | |
---|
| 5081 | $templates = Array( |
---|
| 5082 | 'day_cal' => $tpl |
---|
| 5083 | //'new_component_tpl' => $new_component_tpl |
---|
| 5084 | ); |
---|
| 5085 | |
---|
| 5086 | $templateSet = $GLOBALS['phpgw_info']['server']['template_set']; |
---|
| 5087 | |
---|
| 5088 | if(isset($_GET['date'])) |
---|
| 5089 | { |
---|
| 5090 | $dia = substr($_GET['date'],-2); |
---|
| 5091 | } |
---|
| 5092 | elseif(isset($_POST['day'])) |
---|
| 5093 | { |
---|
| 5094 | $dia = $_POST['day']; |
---|
| 5095 | } |
---|
| 5096 | else |
---|
| 5097 | { |
---|
| 5098 | $dia = $params['day']; |
---|
| 5099 | } |
---|
| 5100 | |
---|
| 5101 | $owner = $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner); //$GLOBALS['phpgw_info']['user']['fullname']; |
---|
| 5102 | $print = '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; |
---|
| 5103 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$dia.'&num_dias=1'.'&d=1'; |
---|
| 5104 | |
---|
| 5105 | $p->set_file($templates); |
---|
| 5106 | $p->set_block('day_cal','day','day'); |
---|
| 5107 | //$p->set_block('new_component_tpl','new_component','new_component'); |
---|
| 5108 | $params['period'] = 1; |
---|
| 5109 | $params['owner'] = $owner; |
---|
| 5110 | $result_events_json = $this->print_events_to_show_json($params); |
---|
| 5111 | $p->set_var('date',$result_events_json['date_events_json']); |
---|
| 5112 | $p->set_var('templateSet',$templateSet); |
---|
| 5113 | $p->set_var('iprint',$print); |
---|
| 5114 | $p->set_var('param',$param); |
---|
| 5115 | $p->set_var('hora_final',$result_events_json['hora_final']); |
---|
| 5116 | $p->set_var('hora_inicial',$result_events_json['hora_inicial']); |
---|
| 5117 | $p->set_var('hour_size_px',$result_events_json['hour_size_px']); |
---|
| 5118 | |
---|
| 5119 | $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); |
---|
| 5120 | return $p->fp('out','day'); |
---|
| 5121 | } |
---|
| 5122 | |
---|
| 5123 | function print_week_new($params){ |
---|
| 5124 | |
---|
| 5125 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 5126 | $p->set_unknowns('keep'); |
---|
| 5127 | |
---|
| 5128 | $tpl = 'new_week.tpl'; |
---|
| 5129 | |
---|
| 5130 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
| 5131 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
| 5132 | { |
---|
| 5133 | $tpl = 'day_list.tpl'; |
---|
| 5134 | } |
---|
| 5135 | |
---|
| 5136 | $minical_prev = $this->mini_calendar( |
---|
| 5137 | Array( |
---|
| 5138 | 'day' => 1, |
---|
| 5139 | 'month' => $this->bo->month, |
---|
| 5140 | 'year' => $this->bo->year, |
---|
| 5141 | 'link' => 'week', |
---|
| 5142 | 'control' => False, |
---|
| 5143 | 'outside_month' => False |
---|
| 5144 | ) |
---|
| 5145 | ); |
---|
| 5146 | |
---|
| 5147 | $minical_next1 = $this->mini_calendar( |
---|
| 5148 | Array( |
---|
| 5149 | 'day' => 1, |
---|
| 5150 | 'month' => $this->bo->month+2, |
---|
| 5151 | 'year' => $this->bo->year, |
---|
| 5152 | 'link' => 'week', |
---|
| 5153 | 'control' => False, |
---|
| 5154 | 'outside_month' => False |
---|
| 5155 | ) |
---|
| 5156 | ); |
---|
| 5157 | |
---|
| 5158 | $minical_next = $this->mini_calendar( |
---|
| 5159 | Array( |
---|
| 5160 | 'day' => 1, |
---|
| 5161 | 'month' => $this->bo->month+1, |
---|
| 5162 | 'year' => $this->bo->year, |
---|
| 5163 | 'link' => 'week', |
---|
| 5164 | 'control' => False, |
---|
| 5165 | 'outside_month' => False |
---|
| 5166 | ) |
---|
| 5167 | ); |
---|
| 5168 | $this->bo->read_holidays($params['year']); |
---|
| 5169 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
| 5170 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
| 5171 | $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'"><<</a>'; |
---|
| 5172 | $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">>></a>'; |
---|
| 5173 | |
---|
| 5174 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
| 5175 | foreach($daily as $key => $value) |
---|
| 5176 | { |
---|
| 5177 | $dates[] = $key; |
---|
| 5178 | } |
---|
| 5179 | |
---|
| 5180 | $day_ini = (int)substr($dates[0],6,2); |
---|
| 5181 | |
---|
| 5182 | $print = '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; |
---|
| 5183 | |
---|
| 5184 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias=7'; |
---|
| 5185 | |
---|
| 5186 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 5187 | |
---|
| 5188 | $templates = Array( |
---|
| 5189 | 'new_week' => $tpl, |
---|
| 5190 | ); |
---|
| 5191 | $feriados_do_ano = Array(); |
---|
| 5192 | foreach ($this->bo->cached_holidays as $key => $value) |
---|
| 5193 | { |
---|
| 5194 | $feriados_do_ano[$key] = utf8_encode($this->bo->cached_holidays[$key][0]['name']); |
---|
| 5195 | } |
---|
| 5196 | $p->set_file($templates); |
---|
| 5197 | $p->set_block('new_week','day','day'); |
---|
| 5198 | $params['period'] = 2; |
---|
| 5199 | $result_events_json = $this->print_events_to_show_json($params); |
---|
| 5200 | $p->set_var('date',$result_events_json['date_events_json']); |
---|
| 5201 | $p->set_var('hora_final',$result_events_json['hora_final']); |
---|
| 5202 | $p->set_var('hora_inicial',$result_events_json['hora_inicial']); |
---|
| 5203 | $p->set_var('minical',$minical_prev.'<br>'.$minical_next.'<br>'.$minical_next1); |
---|
| 5204 | $p->set_var('iprint',$print); |
---|
| 5205 | $p->set_var('param',$param); |
---|
| 5206 | $p->set_var('title',$prev_week_link.' ::'.$this->bo->get_week_label().':: '.$next_week_link); |
---|
| 5207 | $p->set_var('user',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)); |
---|
| 5208 | $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); |
---|
| 5209 | $p->set_var('holidays_json',json_encode($feriados_do_ano)?json_encode($feriados_do_ano):null); |
---|
| 5210 | return $p->fp('out','day'); |
---|
| 5211 | |
---|
| 5212 | } |
---|
| 5213 | |
---|
| 5214 | function print_month_new($params){ |
---|
| 5215 | |
---|
| 5216 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 5217 | $p->set_unknowns('keep'); |
---|
| 5218 | $tpl = 'new_month.tpl'; |
---|
| 5219 | |
---|
| 5220 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
| 5221 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
| 5222 | { |
---|
| 5223 | $tpl = 'day_list.tpl'; |
---|
| 5224 | } |
---|
| 5225 | |
---|
| 5226 | |
---|
| 5227 | |
---|
| 5228 | $templates = Array( |
---|
| 5229 | 'new_month' => $tpl, |
---|
| 5230 | ); |
---|
| 5231 | |
---|
| 5232 | $minical_prev = $this->mini_calendar( |
---|
| 5233 | Array( |
---|
| 5234 | 'day' => 1, |
---|
| 5235 | 'month' => $this->bo->month -1, |
---|
| 5236 | 'year' => $this->bo->year, |
---|
| 5237 | 'link' => 'day', |
---|
| 5238 | 'control' => False, |
---|
| 5239 | 'outside_month' => False |
---|
| 5240 | ) |
---|
| 5241 | ); |
---|
| 5242 | |
---|
| 5243 | $minical_next1 = $this->mini_calendar( |
---|
| 5244 | Array( |
---|
| 5245 | 'day' => 1, |
---|
| 5246 | 'month' => $this->bo->month + 2, |
---|
| 5247 | 'year' => $this->bo->year, |
---|
| 5248 | 'link' => 'day', |
---|
| 5249 | 'control' => False, |
---|
| 5250 | 'outside_month' => False |
---|
| 5251 | ) |
---|
| 5252 | ); |
---|
| 5253 | |
---|
| 5254 | $minical_next = $this->mini_calendar( |
---|
| 5255 | Array( |
---|
| 5256 | 'day' => 1, |
---|
| 5257 | 'month' => $this->bo->month + 1, |
---|
| 5258 | 'year' => $this->bo->year, |
---|
| 5259 | 'link' => 'day', |
---|
| 5260 | 'control' => False, |
---|
| 5261 | 'outside_month' => False |
---|
| 5262 | ) |
---|
| 5263 | ); |
---|
| 5264 | $this->bo->read_holidays($params['year']); |
---|
| 5265 | $print = '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; |
---|
| 5266 | |
---|
| 5267 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; |
---|
| 5268 | |
---|
| 5269 | $next = $this->bo->month + 1; |
---|
| 5270 | $prev = $this->bo->month - 1; |
---|
| 5271 | $nextyear = $this->bo->year; |
---|
| 5272 | $prevyear = $this->bo->year; |
---|
| 5273 | if ($this->bo->month == 12) |
---|
| 5274 | { |
---|
| 5275 | $next = 1; |
---|
| 5276 | $nextyear = $nextyear + 1; |
---|
| 5277 | } |
---|
| 5278 | elseif ($this->bo->month == 1) |
---|
| 5279 | { |
---|
| 5280 | $prev = 12; |
---|
| 5281 | $prevyear = $prevyear - 1; |
---|
| 5282 | } |
---|
| 5283 | |
---|
| 5284 | $feriados_do_ano = Array(); |
---|
| 5285 | foreach ($this->bo->cached_holidays as $key => $value) |
---|
| 5286 | { |
---|
| 5287 | $feriados_do_ano[$key] = utf8_encode($this->bo->cached_holidays[$key][0]['name']); |
---|
| 5288 | } |
---|
| 5289 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
| 5290 | $p->set_file($templates); |
---|
| 5291 | $p->set_block('new_month','day','day'); |
---|
| 5292 | $params['period'] = 3; |
---|
| 5293 | $result_events_json = $this->print_events_to_show_json($params); |
---|
| 5294 | $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'"><<</a>'; |
---|
| 5295 | $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">>></a>'; |
---|
| 5296 | $p->set_var('date',$result_events_json['date_events_json']); |
---|
| 5297 | $p->set_var('hora_final',$result_events_json['hora_final']); |
---|
| 5298 | $p->set_var('hora_inicial',$result_events_json['hora_inicial']); |
---|
| 5299 | $p->set_var('minical',$minical_prev.'<br>'.$minical_next.'<br>'.$minical_next1); |
---|
| 5300 | $p->set_var('iprint',$print); |
---|
| 5301 | $p->set_var('param',$param); |
---|
| 5302 | $p->set_var('title',$prev_month_link." ::".lang(strftime("%B",$m)).' '.$this->bo->year.':: '.$next_month_link); |
---|
| 5303 | $p->set_var('user',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)); |
---|
| 5304 | $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); |
---|
| 5305 | $p->set_var('holidays_json',json_encode($feriados_do_ano)?json_encode($feriados_do_ano):null); |
---|
| 5306 | return $p->fp('out','day'); |
---|
| 5307 | } |
---|
| 5308 | |
---|
| 5309 | //função vai devolver os eventos do mês atual para exibição no novo componente da Agenda |
---|
| 5310 | function print_events_to_show_json($params) |
---|
| 5311 | { |
---|
| 5312 | |
---|
| 5313 | if( (!isset($this->bo->prefs['calendar']['interval'])) || ( (isset($this->bo->prefs['calendar']['interval'])) && ( ($this->bo->prefs['calendar']['interval'] != 42) && ($this->bo->prefs['calendar']['interval'] != 84) ) ) ) |
---|
| 5314 | { |
---|
| 5315 | $this->bo->prefs['calendar']['interval'] = 42; |
---|
| 5316 | $GLOBALS['phpgw']->preferences->add('calendar','interval',42); |
---|
| 5317 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 5318 | } |
---|
| 5319 | |
---|
| 5320 | if(!is_array($params)) |
---|
| 5321 | { |
---|
| 5322 | $this->index(); |
---|
| 5323 | } |
---|
| 5324 | |
---|
| 5325 | // $params['period'] pode ser 1 pra dia, 2 pra semana e 3 pra mes |
---|
| 5326 | |
---|
| 5327 | if(!$params['period'] || $params['period'] == '') |
---|
| 5328 | $period = 3; |
---|
| 5329 | else |
---|
| 5330 | $period = $params['period']; |
---|
| 5331 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
| 5332 | $accountId = $accounts->name2id($account_name); |
---|
| 5333 | $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); |
---|
| 5334 | $dates = array(); |
---|
| 5335 | if($period == 1){ |
---|
| 5336 | $dates[] = $date_to_eval; |
---|
| 5337 | $this->bo->store_to_cache( |
---|
| 5338 | Array( |
---|
| 5339 | 'smonth'=> $params['month'], |
---|
| 5340 | 'sday' => $params['day'], |
---|
| 5341 | 'syear' => $params['year'] |
---|
| 5342 | ) |
---|
| 5343 | ); |
---|
| 5344 | }else if($period == 2){ |
---|
| 5345 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
| 5346 | |
---|
| 5347 | foreach($daily as $key => $value) |
---|
| 5348 | $dates[] = $key; |
---|
| 5349 | |
---|
| 5350 | $this->bo->store_to_cache( |
---|
| 5351 | Array( |
---|
| 5352 | 'smonth'=> (int)substr($dates[0],4,2), |
---|
| 5353 | 'sday' => (int)substr($dates[0],6), |
---|
| 5354 | 'syear' => (int)substr($dates[0],0,4), |
---|
| 5355 | 'eyear' => 0, |
---|
| 5356 | 'emonth'=> 0, |
---|
| 5357 | 'eday' => ((int)substr($dates[0],6))+6, |
---|
| 5358 | ) |
---|
| 5359 | ); |
---|
| 5360 | }else{ |
---|
| 5361 | $month_tmp = substr($date_to_eval, 0, 6); |
---|
| 5362 | |
---|
| 5363 | $this->bo->store_to_cache( |
---|
| 5364 | Array( |
---|
| 5365 | 'smonth'=> (int)substr($date_to_eval,4,2), |
---|
| 5366 | 'sday' => 1, |
---|
| 5367 | 'syear' => (int)substr($date_to_eval,0,4), |
---|
| 5368 | 'eyear' => 0, |
---|
| 5369 | 'emonth'=> 0, |
---|
| 5370 | 'eday' => ((int)substr($date_to_eval,6))+30, |
---|
| 5371 | ) |
---|
| 5372 | ); |
---|
| 5373 | for( $i=1 ; $i<=31; $i++){ |
---|
| 5374 | if($i<10) |
---|
| 5375 | $day= $month_tmp."0".(string)$i; |
---|
| 5376 | else |
---|
| 5377 | $day=$month_tmp.(string)$i; |
---|
| 5378 | $dates[] = $day; |
---|
| 5379 | |
---|
| 5380 | } |
---|
| 5381 | |
---|
| 5382 | } |
---|
| 5383 | |
---|
| 5384 | $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
| 5385 | $account_prefs = $prefs->read(); |
---|
| 5386 | //print_debug('in print_day()'); |
---|
| 5387 | |
---|
| 5388 | $month = (string)((Int)$params['month']-1); |
---|
| 5389 | $date_events_json = 'Date('.$params['year'].','.$month.','.$params['day'].')'; |
---|
| 5390 | |
---|
| 5391 | print_debug('Date to Eval',$date_to_eval); |
---|
| 5392 | |
---|
| 5393 | $hora_inicial = $account_prefs['calendar']['workdaystarts']; |
---|
| 5394 | $hora_final = $account_prefs['calendar']['workdayends']; //18; |
---|
| 5395 | |
---|
| 5396 | $hour_size_px = $account_prefs['calendar']['interval'] ? $account_prefs['calendar']['interval'] : 42; |
---|
| 5397 | |
---|
| 5398 | $title_view = $account_prefs['calendar']['title_view']; |
---|
| 5399 | |
---|
| 5400 | $events_to_show_json = array(); |
---|
| 5401 | $templateSet = $GLOBALS['phpgw_info']['server']['template_set']; |
---|
| 5402 | foreach($dates as $day) |
---|
| 5403 | { |
---|
| 5404 | |
---|
| 5405 | $events = $this->bo->cached_events[$day]; |
---|
| 5406 | |
---|
| 5407 | foreach($events as $event) |
---|
| 5408 | { |
---|
| 5409 | //$is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
| 5410 | if($event['users_status'] == 'R' && $this->bo->prefs['calendar']['show_rejected'] == 0 && $event['owner'] != $GLOBALS['phpgw_info']['user']['account_id']) |
---|
| 5411 | continue; |
---|
| 5412 | |
---|
| 5413 | if($event['recur_type']){ |
---|
| 5414 | $recur = $day; |
---|
| 5415 | $event['start']['year'] = (int)substr($day,0,4); |
---|
| 5416 | $event['start']['month'] = (int)substr($day,4,2); |
---|
| 5417 | $event['start']['mday'] = (int)substr($day,6,2); |
---|
| 5418 | $event['end']['year'] = (int)substr($day,0,4); |
---|
| 5419 | $event['end']['month'] = (int)substr($day,4,2); |
---|
| 5420 | $event['end']['mday'] = (int)substr($day,6,2); |
---|
| 5421 | $event['id'] = $event['id'].'rc'.$day; |
---|
| 5422 | }else{ |
---|
| 5423 | $recur = false; |
---|
| 5424 | } |
---|
| 5425 | |
---|
| 5426 | $isPublic = 1; |
---|
| 5427 | if(($event['type'] == E && $event['public'] == 0)) |
---|
| 5428 | { |
---|
| 5429 | $isPublic = 0; |
---|
| 5430 | $isPublicTitle = lang('restrict'); |
---|
| 5431 | } |
---|
| 5432 | |
---|
| 5433 | if(($event['type'] == P && $event['public'] == 0)) |
---|
| 5434 | { |
---|
| 5435 | $isPublic = 0; |
---|
| 5436 | $isPublicTitle = lang('private'); |
---|
| 5437 | } |
---|
| 5438 | |
---|
| 5439 | $eventTime = ( (mktime($event['end']['hour'], $event['end']['min'], 0, $event['end']['month'], $event['end']['mday'], $event['end']['year'])-mktime($event['start']['hour'], $event['start']['min'], 0, $event['start']['month'], $event['start']['mday'], $event['start']['year']) )/60 ); |
---|
| 5440 | |
---|
| 5441 | $participants = $this->planner_participants($event['participants']); |
---|
| 5442 | $intersection = FALSE; |
---|
| 5443 | |
---|
| 5444 | foreach($events as $ev) |
---|
| 5445 | { |
---|
| 5446 | if($ev['id'] == $event['id']) continue; |
---|
| 5447 | if($ev['users_status'] == 'R') continue; |
---|
| 5448 | $event_start = 60*$event['start']['hour']+$event['start']['min']; |
---|
| 5449 | $event_end = 60*$event['end']['hour']+$event['end']['min']; |
---|
| 5450 | $event_i_start = 60*$ev['start']['hour']+$ev['start']['min']; |
---|
| 5451 | $event_i_end = 60*$ev['end']['hour']+$ev['end']['min']; |
---|
| 5452 | if((($event_start >= $event_i_start) && ($event_start < $event_i_end))||(($event_start < $event_i_start) && ($event_i_start < $event_end))) |
---|
| 5453 | { |
---|
| 5454 | $intersection = TRUE; |
---|
| 5455 | break; |
---|
| 5456 | } |
---|
| 5457 | } |
---|
| 5458 | if($event['users_status'] == 'R') |
---|
| 5459 | { |
---|
| 5460 | $rejected = TRUE; |
---|
| 5461 | } |
---|
| 5462 | else |
---|
| 5463 | { |
---|
| 5464 | $rejected = FALSE; |
---|
| 5465 | } |
---|
| 5466 | |
---|
| 5467 | $evDescription = ''; |
---|
| 5468 | if($title_view == 0) |
---|
| 5469 | { |
---|
| 5470 | $evDescription = " - ".$event['description']; |
---|
| 5471 | } |
---|
| 5472 | |
---|
| 5473 | if($_GET['menuaction'] == 'calendar.uicalendar.day') |
---|
| 5474 | { |
---|
| 5475 | $text = $event['description']; |
---|
| 5476 | } |
---|
| 5477 | elseif($_GET['menuaction'] == 'calendar.uicalendar.week') |
---|
| 5478 | { |
---|
| 5479 | |
---|
| 5480 | $text = $event['end']['hour'].':'.$event['end']['min'] . '<input type="hidden" value="'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).'"/>'; |
---|
| 5481 | |
---|
| 5482 | //is recurrent? |
---|
| 5483 | $text .= (isset($recur) && $recur != false) ? ' ' . '<img width="10px" height="10px" border="0" title="'.lang('recurring event').'" src="calendar/templates/'.$templateSet.'/images/recur.png"/>' : '' ; |
---|
| 5484 | |
---|
| 5485 | //participants? |
---|
| 5486 | if(count($event['participants']) > 1) |
---|
| 5487 | { |
---|
| 5488 | $text .= " " . '<img width="11px" height="10px" border="0" title="'.$participants.'" src="calendar/templates/'.$templateSet.'/images/multi_3.png"/>'; |
---|
| 5489 | } |
---|
| 5490 | else |
---|
| 5491 | { |
---|
| 5492 | $text .= " " . '<img width="11px" height="10px" border="0" title="'.$participants.'" src="calendar/templates/'.$templateSet.'/images/single.png"/>'; |
---|
| 5493 | } |
---|
| 5494 | |
---|
| 5495 | //has attachments? |
---|
| 5496 | $text .= (isset($event['attachment']) && $event['attachment'] != '') ? ' ' . '<img width="10px" height="10px" border="0" title="'.lang('email notifications with attachments has been sent').'" src="calendar/templates/'.$templateSet.'/images/clip.png"/>' : '' ; |
---|
| 5497 | |
---|
| 5498 | //is public? |
---|
| 5499 | $text .= $isPublic == 0 ? ' ' . '<img width="11px" height="10px" border="0" title="'.$isPublicTitle.'" src="calendar/templates/'.$templateSet.'/images/private.png"/>' : '' ; |
---|
| 5500 | |
---|
| 5501 | //has alarm? |
---|
| 5502 | $text .= (isset($event['alarm']) && count($event['alarm']) >= 1) ? ' ' . '<img width="11px" height="10px" border="0" title="'.lang('alarm').'" src="calendar/templates/'.$templateSet.'/images/alarm.png"/>' : '' ; |
---|
| 5503 | |
---|
| 5504 | $text .= ' - ' . $event['title'].$evDescription; |
---|
| 5505 | } |
---|
| 5506 | else |
---|
| 5507 | { |
---|
| 5508 | $text = ' - '.$event['end']['hour'].':'.$event['end']['min'] . ' - '. $event['title'].$evDescription . '<input type="hidden" value="'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).'" id="owner"/>'; |
---|
| 5509 | } |
---|
| 5510 | //$owner = '<input type="hidden" value="'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).'" id="owner"/>' . " "; |
---|
| 5511 | |
---|
| 5512 | $events_to_show_json[] = array( |
---|
| 5513 | start_date => $event['start']['year'].'-'.$event['start']['month'].'-'.$event['start']['mday'].' '.$event['start']['hour'].':'.$event['start']['min'], |
---|
| 5514 | end_date => $event['end']['year'].'-'.$event['end']['month'].'-'.$event['end']['mday'].' '.$event['end']['hour'].':'.$event['end']['min'] . ' - ' . utf8_encode($event['title']), |
---|
| 5515 | text => utf8_encode($text), |
---|
| 5516 | textTitle => utf8_encode($event['description']), //week and month tooltip |
---|
| 5517 | descOnTitle => ($eventTime <= 57) ? 1 : 0, |
---|
| 5518 | title => utf8_encode($event['title']), |
---|
| 5519 | observation => utf8_encode($event['observations']), |
---|
| 5520 | location => utf8_encode($event['location']), |
---|
| 5521 | id => $event['id'], |
---|
| 5522 | participants => (count($event['participants']) > 1) ? 1 : 0, |
---|
| 5523 | participants_title => $participants, |
---|
| 5524 | attachments => $event['attachment'] ? 1 : 0 , |
---|
| 5525 | attachmentsTitle => utf8_encode(lang('email notifications with attachments has been sent')), |
---|
| 5526 | isPublic => $isPublic, |
---|
| 5527 | isPublicTitle => utf8_encode($isPublicTitle), |
---|
| 5528 | alarm => (isset($event['alarm']) && count($event['alarm']) >= 1) ? 1 : 0, |
---|
| 5529 | alarmTitle => utf8_encode(lang('alarm')), |
---|
| 5530 | recur => $recur, |
---|
| 5531 | recurTitle => utf8_encode(lang('recurring event')), |
---|
| 5532 | intersection => $intersection, |
---|
| 5533 | rejected => $rejected, |
---|
| 5534 | title_view => $title_view, |
---|
| 5535 | eventOwner => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) //$params['owner'] |
---|
| 5536 | ); |
---|
| 5537 | |
---|
| 5538 | if($event['start']['hour'] < $hora_inicial) |
---|
| 5539 | { |
---|
| 5540 | $hora_inicial = $event['start']['hour']; |
---|
| 5541 | } |
---|
| 5542 | |
---|
| 5543 | if($event['end']['hour'] >= $hora_final) |
---|
| 5544 | { |
---|
| 5545 | $hora_final = $event['end']['hour'] + 1; |
---|
| 5546 | } |
---|
| 5547 | } |
---|
| 5548 | } |
---|
| 5549 | |
---|
| 5550 | $result = Array( |
---|
| 5551 | 'hora_inicial' => $hora_inicial, |
---|
| 5552 | 'hora_final' => $hora_final, |
---|
| 5553 | 'hour_size_px' => $hour_size_px, |
---|
| 5554 | 'date_events_json' => $date_events_json, |
---|
| 5555 | 'events_to_show_json' => $events_to_show_json |
---|
| 5556 | ); |
---|
| 5557 | |
---|
| 5558 | return $result; |
---|
| 5559 | } // end function |
---|
| 5560 | |
---|
| 5561 | |
---|
| 5562 | |
---|
| 5563 | function timematrix($param) |
---|
| 5564 | { |
---|
| 5565 | if(!is_array($param)) |
---|
| 5566 | { |
---|
| 5567 | $this->index(); |
---|
| 5568 | } |
---|
| 5569 | |
---|
| 5570 | $date = $param['date']; |
---|
| 5571 | $starttime = $param['starttime']; |
---|
| 5572 | $endtime = $param['endtime']; |
---|
| 5573 | $participants = $param['participants']; |
---|
| 5574 | foreach($participants as $part => $nul) |
---|
| 5575 | { |
---|
| 5576 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
| 5577 | // Much better for processor :) |
---|
| 5578 | $participants_id[] .= $part; |
---|
| 5579 | } |
---|
| 5580 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
| 5581 | |
---|
| 5582 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
| 5583 | { |
---|
| 5584 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
| 5585 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
| 5586 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 5587 | } |
---|
| 5588 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
| 5589 | $interval = (int)(60 / $increment); |
---|
| 5590 | |
---|
| 5591 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
| 5592 | |
---|
| 5593 | $str = '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
| 5594 | . ', '.$this->bo->long_date($date).'<br>' |
---|
| 5595 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((24 * $interval) + 1).'">' |
---|
| 5596 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
| 5597 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
| 5598 | for($i=0;$i<24;$i++) |
---|
| 5599 | { |
---|
| 5600 | for($j=0;$j<$interval;$j++) |
---|
| 5601 | { |
---|
| 5602 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
| 5603 | |
---|
| 5604 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'"><font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' |
---|
| 5605 | . '<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;\">" |
---|
| 5606 | . $k."</a> </font></td>\n"; |
---|
| 5607 | } |
---|
| 5608 | } |
---|
| 5609 | $str .= '</tr>' |
---|
| 5610 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
| 5611 | if(!$endtime) |
---|
| 5612 | { |
---|
| 5613 | $endtime = $starttime; |
---|
| 5614 | } |
---|
| 5615 | $owner = $this->bo->owner; |
---|
| 5616 | foreach($participants as $part => $fullname) |
---|
| 5617 | { |
---|
| 5618 | $str .= '<tr align="center">' |
---|
| 5619 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
| 5620 | |
---|
| 5621 | $this->bo->cached_events = Array(); |
---|
| 5622 | $this->bo->so->owner = $part; |
---|
| 5623 | $this->bo->so->open_box($part); |
---|
| 5624 | $this->bo->store_to_cache( |
---|
| 5625 | Array( |
---|
| 5626 | 'syear' => $date['year'], |
---|
| 5627 | 'smonth'=> $date['month'], |
---|
| 5628 | 'sday' => $date['day'], |
---|
| 5629 | 'eyear' => 0, |
---|
| 5630 | 'emonth'=> 0, |
---|
| 5631 | 'eday' => $date['day'] + 1 |
---|
| 5632 | ) |
---|
| 5633 | ); |
---|
| 5634 | |
---|
| 5635 | if(!$this->bo->cached_events[$date['full']]) |
---|
| 5636 | { |
---|
| 5637 | for($j=0;$j<24;$j++) |
---|
| 5638 | { |
---|
| 5639 | for($k=0;$k<$interval;$k++) |
---|
| 5640 | { |
---|
| 5641 | $str .= '<td height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
| 5642 | } |
---|
| 5643 | $str .= "\n"; |
---|
| 5644 | } |
---|
| 5645 | } |
---|
| 5646 | else |
---|
| 5647 | { |
---|
| 5648 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
| 5649 | for($h=0;$h<24;$h++) |
---|
| 5650 | { |
---|
| 5651 | $hour = $h * 10000; |
---|
| 5652 | for($m=0;$m<$interval;$m++) |
---|
| 5653 | { |
---|
| 5654 | $index = ($hour + (($m * $increment) * 100)); |
---|
| 5655 | switch($time_slice[$index]['marker']) |
---|
| 5656 | { |
---|
| 5657 | case ' ': |
---|
| 5658 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
| 5659 | $extra = ''; |
---|
| 5660 | break; |
---|
| 5661 | case '-': |
---|
| 5662 | $time_slice[$index]['color'] = $this->theme['bg01']; |
---|
| 5663 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
| 5664 | $extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
| 5665 | break; |
---|
| 5666 | } |
---|
| 5667 | $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>'; |
---|
| 5668 | } |
---|
| 5669 | $str .= "\n"; |
---|
| 5670 | } |
---|
| 5671 | } |
---|
| 5672 | $str .= '</tr>' |
---|
| 5673 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
| 5674 | } |
---|
| 5675 | $this->bo->owner = $owner; |
---|
| 5676 | $this->bo->so->owner = $owner; |
---|
| 5677 | $this->bo->so->open_box($owner); |
---|
| 5678 | return $str.'</table></center>'."\n"; |
---|
| 5679 | } |
---|
| 5680 | |
---|
| 5681 | function get_response($cal_id) |
---|
| 5682 | { |
---|
| 5683 | $p = &$GLOBALS['phpgw']->template; |
---|
| 5684 | $p->set_file( |
---|
| 5685 | Array( |
---|
| 5686 | 'form_button' => 'form_button_script.tpl' |
---|
| 5687 | ) |
---|
| 5688 | ); |
---|
| 5689 | |
---|
| 5690 | $ev = $this->bo->get_cached_event(); |
---|
| 5691 | $response_choices = Array( |
---|
| 5692 | ACCEPTED => lang('Accept'), |
---|
| 5693 | REJECTED => lang('Reject'), |
---|
| 5694 | TENTATIVE => lang('Tentative') |
---|
| 5695 | ); |
---|
| 5696 | $str = ''; |
---|
| 5697 | while(list($param,$text) = each($response_choices)) |
---|
| 5698 | { |
---|
| 5699 | $var = Array( |
---|
| 5700 | 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user_id='.$this->bo->owner), |
---|
| 5701 | 'action_text_button' => ' '.$text.' ', |
---|
| 5702 | 'action_confirm_button' => '', |
---|
| 5703 | 'action_extra_field' => '' |
---|
| 5704 | ); |
---|
| 5705 | $p->set_var($var); |
---|
| 5706 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
| 5707 | } |
---|
| 5708 | if ($this->bo->return_to) |
---|
| 5709 | { |
---|
| 5710 | $var = Array( |
---|
| 5711 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 5712 | 'action_text_button' => lang('cancel'), |
---|
| 5713 | 'action_confirm_button' => '', |
---|
| 5714 | 'action_extra_field' => '' |
---|
| 5715 | ); |
---|
| 5716 | $p->set_var($var); |
---|
| 5717 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
| 5718 | } |
---|
| 5719 | $str = '<td><b>'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).":</b></td>\n".$str; |
---|
| 5720 | |
---|
| 5721 | return '<table width="100%"><tr align="center">'."\n".$str.'</tr></table>'."\n"; |
---|
| 5722 | } |
---|
| 5723 | |
---|
| 5724 | function accounts_popup() |
---|
| 5725 | { |
---|
| 5726 | $GLOBALS['phpgw']->accounts->accounts_popup('calendar'); |
---|
| 5727 | |
---|
| 5728 | } |
---|
| 5729 | |
---|
| 5730 | function edit_form($param) |
---|
| 5731 | { |
---|
| 5732 | if(!is_array($param)) |
---|
| 5733 | { |
---|
| 5734 | $this->index(); |
---|
| 5735 | } |
---|
| 5736 | |
---|
| 5737 | if(isset($param['event'])) |
---|
| 5738 | { |
---|
| 5739 | $event = $param['event']; |
---|
| 5740 | } |
---|
| 5741 | |
---|
| 5742 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
| 5743 | |
---|
| 5744 | // $sb = CreateObject('phpgwapi.sbox'); |
---|
| 5745 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 5746 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
| 5747 | |
---|
| 5748 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 5749 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 5750 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 5751 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 5752 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); |
---|
| 5753 | if ($param['plain'] != "True"){ |
---|
| 5754 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 5755 | } |
---|
| 5756 | else{ |
---|
| 5757 | $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; |
---|
| 5758 | $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; |
---|
| 5759 | } |
---|
| 5760 | |
---|
| 5761 | $p = &$GLOBALS['phpgw']->template; |
---|
| 5762 | $p->set_file( |
---|
| 5763 | Array( |
---|
| 5764 | 'edit' => 'edit.tpl', |
---|
| 5765 | 'form_button' => 'form_button_script.tpl' |
---|
| 5766 | ) |
---|
| 5767 | ); |
---|
| 5768 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
| 5769 | $p->set_block('edit','list','list'); |
---|
| 5770 | $p->set_block('edit','hr','hr'); |
---|
| 5771 | |
---|
| 5772 | $vars = Array( |
---|
| 5773 | 'font' => $this->theme['font'], |
---|
| 5774 | 'bg_color' => $this->theme['bg_text'], |
---|
| 5775 | 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), |
---|
| 5776 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), |
---|
| 5777 | 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" |
---|
| 5778 | . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" |
---|
| 5779 | . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" |
---|
| 5780 | . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": |
---|
| 5781 | (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) |
---|
| 5782 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
| 5783 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
| 5784 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') |
---|
| 5785 | ); |
---|
| 5786 | |
---|
| 5787 | $p->set_var($vars); |
---|
| 5788 | |
---|
| 5789 | // Brief Description |
---|
| 5790 | $var['title'] = Array( |
---|
| 5791 | 'tr_color' => $this->theme['th_bg'], |
---|
| 5792 | 'field' => lang('Title'), |
---|
| 5793 | 'data' => '<input name="cal[title]" size="103" maxlength="300" value="'.$event['title'].'">' |
---|
| 5794 | ); |
---|
| 5795 | |
---|
| 5796 | // Full Description |
---|
| 5797 | $var['description'] = Array( |
---|
| 5798 | 'field' => lang('Full Description'), |
---|
| 5799 | 'data' => '<textarea name="cal[description]" rows="5" cols="88" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' |
---|
| 5800 | ); |
---|
| 5801 | |
---|
| 5802 | // Display Categories |
---|
| 5803 | if(strpos($event['category'],',')) |
---|
| 5804 | { |
---|
| 5805 | $temp_cats = explode(',',$event['category']); |
---|
| 5806 | @reset($temp_cats); |
---|
| 5807 | while(list($key,$value) = each($temp_cats)) |
---|
| 5808 | { |
---|
| 5809 | $check_cats[] = (int)$value; |
---|
| 5810 | } |
---|
| 5811 | } |
---|
| 5812 | elseif($event['category']) |
---|
| 5813 | { |
---|
| 5814 | $check_cats[] = (int)$event['category']; |
---|
| 5815 | } |
---|
| 5816 | else |
---|
| 5817 | { |
---|
| 5818 | $check_cats[] = 0; |
---|
| 5819 | } |
---|
| 5820 | $var['category'] = Array( |
---|
| 5821 | 'field' => lang('Category'), |
---|
| 5822 | 'data' => '<select name="categories[]" onchange="javascript:updateTitleField(this)" multiple size="5">'.$this->cat->formated_list('select','all',$check_cats,True).'</select>' |
---|
| 5823 | ); |
---|
| 5824 | |
---|
| 5825 | // Location |
---|
| 5826 | $var['location'] = Array( |
---|
| 5827 | 'field' => lang('Location'), |
---|
| 5828 | 'data' => '<input name="cal[location]" size="45" maxlength="255" value="'.$event['location'].'">' |
---|
| 5829 | ); |
---|
| 5830 | |
---|
| 5831 | // Date |
---|
| 5832 | |
---|
| 5833 | $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 5834 | $var['startdate'] = Array( |
---|
| 5835 | 'field' => lang('Start Date'), |
---|
| 5836 | /* |
---|
| 5837 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 5838 | $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), |
---|
| 5839 | $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), |
---|
| 5840 | $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')) |
---|
| 5841 | ) |
---|
| 5842 | */ |
---|
| 5843 | 'data' => $jscal->input('start[str]',$start) |
---|
| 5844 | ); |
---|
| 5845 | |
---|
| 5846 | // Time |
---|
| 5847 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
| 5848 | { |
---|
| 5849 | $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
| 5850 | . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
| 5851 | } |
---|
| 5852 | $var['starttime'] = Array( |
---|
| 5853 | 'field' => lang('Start Time'), |
---|
| 5854 | '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">'."\n".$str |
---|
| 5855 | ); |
---|
| 5856 | |
---|
| 5857 | // End Date |
---|
| 5858 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 5859 | $var['enddate'] = Array( |
---|
| 5860 | 'field' => lang('End Date'), |
---|
| 5861 | /* |
---|
| 5862 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 5863 | $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), |
---|
| 5864 | $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), |
---|
| 5865 | $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')) |
---|
| 5866 | ) |
---|
| 5867 | */ |
---|
| 5868 | 'data' => $jscal->input('end[str]',$end) |
---|
| 5869 | ); |
---|
| 5870 | |
---|
| 5871 | // End Time |
---|
| 5872 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
| 5873 | { |
---|
| 5874 | $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
| 5875 | . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
| 5876 | } |
---|
| 5877 | $var['endtime'] = Array( |
---|
| 5878 | 'field' => lang('End Time'), |
---|
| 5879 | '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">'."\n".$str |
---|
| 5880 | ); |
---|
| 5881 | |
---|
| 5882 | // Priority |
---|
| 5883 | $var['priority'] = Array( |
---|
| 5884 | 'field' => lang('Priority'), |
---|
| 5885 | 'data' => $sb->getPriority('cal[priority]',$event['priority']) |
---|
| 5886 | ); |
---|
| 5887 | |
---|
| 5888 | // Access |
---|
| 5889 | $var['access'] = Array( |
---|
| 5890 | 'field' => lang('Type'), |
---|
| 5891 | 'data' => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.'><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>' |
---|
| 5892 | ); //event['public'] |
---|
| 5893 | |
---|
| 5894 | // Participants |
---|
| 5895 | if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) |
---|
| 5896 | { |
---|
| 5897 | switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection']) |
---|
| 5898 | { |
---|
| 5899 | case 'popup': |
---|
| 5900 | while (is_array($event['participants']) && list($id) = each($event['participants'])) |
---|
| 5901 | { |
---|
| 5902 | if($id != (int)$event['owner']) |
---|
| 5903 | { |
---|
| 5904 | $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) |
---|
| 5905 | .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n"; |
---|
| 5906 | } |
---|
| 5907 | } |
---|
| 5908 | $var['participants'] = array |
---|
| 5909 | ( |
---|
| 5910 | 'field' => '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n" |
---|
| 5911 | . '<input type="hidden" name="accountid" value="' . $accountid . '">', |
---|
| 5912 | 'data' => "\n".' <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>' |
---|
| 5913 | ); |
---|
| 5914 | break; |
---|
| 5915 | default: |
---|
| 5916 | foreach($event['participants'] as $id => $participant) |
---|
| 5917 | { |
---|
| 5918 | if (($id != $event['owner']) && ($id != "")) |
---|
| 5919 | { |
---|
| 5920 | $GLOBALS['phpgw']->accounts->get_account_name($id, $lid, $fname, $lname); |
---|
| 5921 | $cn = $fname.' '.$lname; |
---|
| 5922 | $option = ' <option value="' . $id.$participant . '">'.$cn.'</option>'."\n"; |
---|
| 5923 | $str .= $option; |
---|
| 5924 | } |
---|
| 5925 | } |
---|
| 5926 | $str = utf8_decode($str); |
---|
| 5927 | $footer_ext_participantes = '<br> '.lang("The email addresses must be separated by ','"); |
---|
| 5928 | |
---|
| 5929 | $var['participants'] = array |
---|
| 5930 | ( |
---|
| 5931 | 'field' => lang('Participants'), |
---|
| 5932 | 'data' => " |
---|
| 5933 | <table width='100%' border='0'> |
---|
| 5934 | <tr> |
---|
| 5935 | <td width='30%'> |
---|
| 5936 | <center>Participantes</center> |
---|
| 5937 | </td> |
---|
| 5938 | <td width='8%' > </td> |
---|
| 5939 | <td width='40%'> </td> |
---|
| 5940 | </tr> |
---|
| 5941 | <tr> |
---|
| 5942 | <td width='30%'> |
---|
| 5943 | <center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center> |
---|
| 5944 | </td> |
---|
| 5945 | <td width='8%'> |
---|
| 5946 | <center> |
---|
| 5947 | <table width='100%' border='0'> |
---|
| 5948 | <tr height='5'><td> </td></tr> |
---|
| 5949 | <tr><td align='center'> |
---|
| 5950 | <button type='button' onClick='javascript:openListUsers(340,533, " |
---|
| 5951 | .$event['owner']. |
---|
| 5952 | ")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' > Adicionar</button> |
---|
| 5953 | </td> |
---|
| 5954 | </tr> |
---|
| 5955 | <tr height='5'><td> </td></tr> |
---|
| 5956 | <tr><td align='center'> |
---|
| 5957 | <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> |
---|
| 5958 | </td> |
---|
| 5959 | </tr> |
---|
| 5960 | </table> |
---|
| 5961 | </center> |
---|
| 5962 | </td> |
---|
| 5963 | <td width='40%'> </td> |
---|
| 5964 | </tr> |
---|
| 5965 | </table> |
---|
| 5966 | <script src='calendar/js/edit.js' type='text/javascript'></script> |
---|
| 5967 | " |
---|
| 5968 | ); |
---|
| 5969 | // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. |
---|
| 5970 | if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { |
---|
| 5971 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
| 5972 | |
---|
| 5973 | if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ |
---|
| 5974 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 5975 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 5976 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
| 5977 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 5978 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 5979 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 5980 | $user_context = array(); |
---|
| 5981 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
| 5982 | if($i) |
---|
| 5983 | $user_context[] = $dn_part; |
---|
| 5984 | } |
---|
| 5985 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
| 5986 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
| 5987 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
| 5988 | // Fim |
---|
| 5989 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
| 5990 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
| 5991 | //$combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
| 5992 | $footer_ext_participantes = lang("Tip: To search in the <b>Global Catalog</b>, type the <b>F9</b> key, like the ExpressoMail."); |
---|
| 5993 | //Caso o minimo de caracteres para a busca nao tenha sido preenchido ele sera por padrao = 3 |
---|
| 5994 | if(!$GLOBALS['phpgw_info']['server']['min_num_characters']){ |
---|
| 5995 | $GLOBALS['phpgw_info']['server']['min_num_characters'] = 0; |
---|
| 5996 | } |
---|
| 5997 | |
---|
| 5998 | if ($GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '3'){ |
---|
| 5999 | $combo_org = '<option value='.$context.'>'.strtoupper($context).'</option>'; |
---|
| 6000 | }else{ |
---|
| 6001 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
| 6002 | } |
---|
| 6003 | |
---|
| 6004 | if ($param['plain'] != "True"){ |
---|
| 6005 | |
---|
| 6006 | // Begin load array lang |
---|
| 6007 | ob_start(); |
---|
| 6008 | //@include($module_name.'/inc/load_lang.php'); |
---|
| 6009 | $load_lang_vars = ob_get_contents(); |
---|
| 6010 | ob_end_clean(); |
---|
| 6011 | // End load array_lang |
---|
| 6012 | } |
---|
| 6013 | |
---|
| 6014 | $edit_js_path = 'calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']; |
---|
| 6015 | if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].$edit_js_path.'/js/edit.js')) |
---|
| 6016 | $edit_js_path = 'calendar'; |
---|
| 6017 | |
---|
| 6018 | $var['participants'] = array |
---|
| 6019 | ( |
---|
| 6020 | 'field' => ' |
---|
| 6021 | <script src="'.$edit_js_path.'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'> |
---|
| 6022 | <iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe> |
---|
| 6023 | </div> |
---|
| 6024 | '.lang('Participants'), |
---|
| 6025 | 'data' => ' |
---|
| 6026 | <input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . |
---|
| 6027 | '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . |
---|
| 6028 | '<input type="hidden" id="txt_users" value="'.lang("Users").'">' . |
---|
| 6029 | '<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' . |
---|
| 6030 | '<table width="100%" border="0">'. |
---|
| 6031 | '<tr>'. |
---|
| 6032 | '<td width="25%"><br><br>'. |
---|
| 6033 | '<br><br> <b>'.lang("Event's participants").'</b><br>'. |
---|
| 6034 | ' <select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'. |
---|
| 6035 | '</td>'. |
---|
| 6036 | '<td width="30px" valign="middle" align="center"> '. |
---|
| 6037 | '</td>'. |
---|
| 6038 | '<td valign="bottom">'. |
---|
| 6039 | ' '.lang("Organization").': '. |
---|
| 6040 | ' <select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\');">'.$combo_org.'</select>'. |
---|
| 6041 | ' <br>'. |
---|
| 6042 | ' <font color="red"><span id="cal_span_searching"> </span></font>'. |
---|
| 6043 | ' <br>'.lang("Search for").':'. |
---|
| 6044 | ' <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\')"><br>'. |
---|
| 6045 | ' <b>'.lang("Available users and groups").'</b><br>'. |
---|
| 6046 | ' <select id="user_list_in" style="width: 300px" multiple size="13"></select>'. |
---|
| 6047 | '</td>'. |
---|
| 6048 | '</tr>'. |
---|
| 6049 | '<tr>'. |
---|
| 6050 | '<td width="25%">'. |
---|
| 6051 | '<button type="button" id="time_map" onClick="javascript:show_disponibility();">'.lang("Disponibility map").'</button>'. |
---|
| 6052 | '</td>'. |
---|
| 6053 | '<td width="30px" valign="middle" align="center"> '. |
---|
| 6054 | '</td>'. |
---|
| 6055 | '<td valign="bottom">'. |
---|
| 6056 | '<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>'. |
---|
| 6057 | ' <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>'. |
---|
| 6058 | '</td>'. |
---|
| 6059 | '</tr>'. |
---|
| 6060 | '</table>'. |
---|
| 6061 | '<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'. |
---|
| 6062 | '<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'. |
---|
| 6063 | "<script src='calendar/js/edit_exmail.js' type='text/javascript'></script>" . |
---|
| 6064 | $load_lang_vars. |
---|
| 6065 | "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". |
---|
| 6066 | "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". |
---|
| 6067 | "<script type='text/javascript'>" . |
---|
| 6068 | "var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\',\'".$GLOBALS['phpgw_info']['server']['auto_search']."\')',1000);". |
---|
| 6069 | "</script> " |
---|
| 6070 | ); |
---|
| 6071 | } |
---|
| 6072 | } |
---|
| 6073 | |
---|
| 6074 | $var['participants']['data'] .= '<br /><a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . |
---|
| 6075 | " 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" ' . |
---|
| 6076 | '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">'. |
---|
| 6077 | '<tr>'. |
---|
| 6078 | '<td>'. |
---|
| 6079 | ' <b>'.lang("external participants").'</b> <img align="top" src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif">' . |
---|
| 6080 | ' <a title="'.lang("Close").'" name="b_ext_participants" onClick="javascript:hideExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants">['.lang("Close").']</a> '. |
---|
| 6081 | '</td>'. |
---|
| 6082 | '</tr>'. |
---|
| 6083 | '<tr>'. |
---|
| 6084 | '<td>'. |
---|
| 6085 | ' >> '.lang("It types below the email addresses, if you want to invite other people out of this system").':'. |
---|
| 6086 | ' <br><textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br> '. |
---|
| 6087 | //$footer_ext_participantes. |
---|
| 6088 | '</tr>'. |
---|
| 6089 | '</table>'; |
---|
| 6090 | break; |
---|
| 6091 | |
---|
| 6092 | } |
---|
| 6093 | if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id']) |
---|
| 6094 | { |
---|
| 6095 | $checked = ' checked'; |
---|
| 6096 | } |
---|
| 6097 | else |
---|
| 6098 | { |
---|
| 6099 | $checked = ''; |
---|
| 6100 | } |
---|
| 6101 | $var['owner'] = Array( |
---|
| 6102 | 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), |
---|
| 6103 | 'data' => '<input type="checkbox" id="usuarioParticipa" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>' |
---|
| 6104 | ); |
---|
| 6105 | } |
---|
| 6106 | |
---|
| 6107 | // Reminder |
---|
| 6108 | // The user must use "Alarm Management" to change/modify an alarm |
---|
| 6109 | // so only display the email reminder fields if this is a new event |
---|
| 6110 | // i.e. not editing an existing event |
---|
| 6111 | |
---|
| 6112 | if ($event['id'] == 0) { |
---|
| 6113 | // get defaults |
---|
| 6114 | $days = $this->bo->prefs['calendar']['default_email_days']; |
---|
| 6115 | $hours = $this->bo->prefs['calendar']['default_email_hours']; |
---|
| 6116 | $min = $this->bo->prefs['calendar']['default_email_min']; |
---|
| 6117 | if (count($event['alarm']) > 1) |
---|
| 6118 | { |
---|
| 6119 | // this should not happen because when creating a new event |
---|
| 6120 | // only 1 alarm is displayed on the screen |
---|
| 6121 | // if the user wants more than 1 alarm they should |
---|
| 6122 | // use "Alarm Management" |
---|
| 6123 | echo '<!-- how did this happen, too many alarms -->'."\n"; |
---|
| 6124 | } |
---|
| 6125 | // if there was an error pick up what the user entered |
---|
| 6126 | if (@isset($event['alarm'])) |
---|
| 6127 | { |
---|
| 6128 | @reset($event['alarm']); |
---|
| 6129 | // just get the first one see above!!! |
---|
| 6130 | list($key,$alarm) = @each($event['alarm']); |
---|
| 6131 | |
---|
| 6132 | |
---|
| 6133 | //if abaixo trata o caso de um evento repetido nao ter uma data final; |
---|
| 6134 | //se isto acontecer, nao havera alarmes definidos; |
---|
| 6135 | //$alarm['time'] recebe $start para $days, $hours e $min ficarem iguais a 0 |
---|
| 6136 | if(!$alarm['time']) { |
---|
| 6137 | $alarm['time'] = $start; |
---|
| 6138 | } |
---|
| 6139 | |
---|
| 6140 | $diff = $start - $alarm['time']; |
---|
| 6141 | $days = (int)($diff / (24*3600)); |
---|
| 6142 | $hours = (int)(($diff - ($days * 24 * 3600))/3600); |
---|
| 6143 | $min = (int)(($diff - ($days * 24 * 3600) - ($hours * 3600))/60); |
---|
| 6144 | |
---|
| 6145 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') { |
---|
| 6146 | $days = $diff; |
---|
| 6147 | } |
---|
| 6148 | } |
---|
| 6149 | |
---|
| 6150 | // days |
---|
| 6151 | $dout = '<select name="cal[alarmdays]">'."\n"; |
---|
| 6152 | for($i=0;$i<32;$i++) |
---|
| 6153 | { |
---|
| 6154 | $dout .= '<option value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 6155 | } |
---|
| 6156 | $dout .= '</select>'."\n".' '.lang('days').' '; |
---|
| 6157 | // hours |
---|
| 6158 | $hout = '<select name="cal[alarmhours]">'."\n"; |
---|
| 6159 | for($i=0;$i<25;$i++) |
---|
| 6160 | { |
---|
| 6161 | $hout .= '<option value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 6162 | } |
---|
| 6163 | $hout .= '</select>'."\n".' '.lang('hours').' '; |
---|
| 6164 | // minutes |
---|
| 6165 | $mout = '<select name="cal[alarmminutes]">'."\n"; |
---|
| 6166 | for($i=0;$i<61;$i++) |
---|
| 6167 | { |
---|
| 6168 | $mout .= '<option value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n"; |
---|
| 6169 | } |
---|
| 6170 | $mout .= '</select>'."\n".' '.lang('minutes').' '; |
---|
| 6171 | |
---|
| 6172 | $var['alarm'] = Array( |
---|
| 6173 | 'field' => lang('Alarm'), |
---|
| 6174 | 'data' => $dout.$hout.$mout.lang('before the event') |
---|
| 6175 | ); |
---|
| 6176 | |
---|
| 6177 | } |
---|
| 6178 | |
---|
| 6179 | // Repeat Type |
---|
| 6180 | $str = ''; |
---|
| 6181 | foreach($this->bo->rpt_type as $type => $label) |
---|
| 6182 | { |
---|
| 6183 | $str .= '<option value="'.$type.'"'.($event['recur_type']==$type?' selected':'').'>'.lang($label).'</option>'; |
---|
| 6184 | } |
---|
| 6185 | $var['recure_type'] = Array( |
---|
| 6186 | 'field' => lang('Repeat Type'), |
---|
| 6187 | 'data' => '<select name="cal[recur_type]">'."\n".$str.'</select>'."\n" |
---|
| 6188 | ); |
---|
| 6189 | |
---|
| 6190 | |
---|
| 6191 | $preferences = CreateObject('phpgwapi.preferences',(int)$this->owner); |
---|
| 6192 | $selected_creator = $selected_owner = ''; |
---|
| 6193 | if($event['notifications_owner'] == 1) |
---|
| 6194 | $selected_owner = ' selected'; |
---|
| 6195 | else |
---|
| 6196 | $selected_creator = ' selected'; |
---|
| 6197 | |
---|
| 6198 | $option = '<option value="0" '.$selected_creator.' >'.$GLOBALS['phpgw']->common->grab_owner_name((int)$_SESSION['phpgw_session']['account_id']).'</option>'; |
---|
| 6199 | if($_SESSION['phpgw_session']['account_id'] != $event['owner']){ |
---|
| 6200 | $option .= '<option value="1" '.$selected_owner.' >'.$GLOBALS['phpgw']->common->grab_owner_name((int)$event['owner']).'</option>'; |
---|
| 6201 | } |
---|
| 6202 | |
---|
| 6203 | |
---|
| 6204 | $var['notifications_owner'] = Array( |
---|
| 6205 | 'field' => lang('Send notificatios as'), |
---|
| 6206 | 'data' => '<select name="cal[notifications_owner]" >'.$option.'</select>' |
---|
| 6207 | ); |
---|
| 6208 | |
---|
| 6209 | |
---|
| 6210 | if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) |
---|
| 6211 | { |
---|
| 6212 | $checked = ' checked'; |
---|
| 6213 | $recur_end = $this->bo->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 6214 | } |
---|
| 6215 | else |
---|
| 6216 | { |
---|
| 6217 | $checked = ''; |
---|
| 6218 | $recur_end = $this->bo->maketime($event['start']) + 86400 - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
| 6219 | } |
---|
| 6220 | |
---|
| 6221 | $var['recure_enddate'] = Array( |
---|
| 6222 | 'field' => lang('Repeat End Date'), |
---|
| 6223 | 'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '. |
---|
| 6224 | /* |
---|
| 6225 | $GLOBALS['phpgw']->common->dateformatorder( |
---|
| 6226 | $sb->getYears('recur_enddate[year]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'Y')), |
---|
| 6227 | $sb->getMonthText('recur_enddate[month]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'n')), |
---|
| 6228 | $sb->getDays('recur_enddate[mday]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'d')) |
---|
| 6229 | ) |
---|
| 6230 | */ |
---|
| 6231 | $jscal->input('recur_enddate[str]',$recur_end) |
---|
| 6232 | ); |
---|
| 6233 | |
---|
| 6234 | $i = 0; $boxes = ''; |
---|
| 6235 | foreach ($this->bo->rpt_day as $mask => $name) |
---|
| 6236 | { |
---|
| 6237 | $boxes .= '<input type="checkbox" name="cal[rpt_day][]" value="'.$mask.'"'.($event['recur_data'] & $mask ? ' checked' : '').'> '.lang($name)."\n"; |
---|
| 6238 | if (++$i == 5) $boxes .= '<br>'; |
---|
| 6239 | } |
---|
| 6240 | $var['recure_day'] = Array( |
---|
| 6241 | 'field' => lang('Repeat Day').'<br>'.lang('(required for weekly recursivity)'), |
---|
| 6242 | 'data' => $boxes |
---|
| 6243 | ); |
---|
| 6244 | |
---|
| 6245 | $var['recure_interval'] = Array( |
---|
| 6246 | 'field' => lang('Interval'), |
---|
| 6247 | 'data' => '<input name="cal[recur_interval]" size="4" maxlength="4" value="'.$event['recur_interval'].'">' |
---|
| 6248 | ); |
---|
| 6249 | // $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); |
---|
| 6250 | |
---|
| 6251 | // Observations |
---|
| 6252 | $var['observations'] = Array( |
---|
| 6253 | 'field' => lang('Observations'), |
---|
| 6254 | 'data' => '<textarea name="cal[observations]" rows="5" cols="88" wrap="virtual" maxlength="2048">'.$event['observations'].'</textarea>' |
---|
| 6255 | ); |
---|
| 6256 | |
---|
| 6257 | if ($event['attachment'] == '' || $event['attachment'] == 'ERROR' || is_array($event['attachment'])) |
---|
| 6258 | $data = '<a onClick="javascript:addAttach()" href="#divFiles" >Anexos: adicionar+</a><div id="divFiles"></div>'; |
---|
| 6259 | else |
---|
| 6260 | $data = '<input type="hidden" name="cal[attachment]" value='.$event["attachment"].'>'.lang('Notification with attachments sent.').'<br><a onClick="javascript:addAttach()" href="#divFiles" >Anexos: adicionar+</a><div id="divFiles"</div>'; |
---|
| 6261 | |
---|
| 6262 | $var['attachment'] = Array( |
---|
| 6263 | 'field' => lang('Attachment'), |
---|
| 6264 | //'data' => '<input type="file" name="cal[attachment]" />' |
---|
| 6265 | 'data' => $data |
---|
| 6266 | ); |
---|
| 6267 | |
---|
| 6268 | if (!isset($this->fields)) |
---|
| 6269 | { |
---|
| 6270 | $this->custom_fields = CreateObject('calendar.bocustom_fields'); |
---|
| 6271 | $this->fields = &$this->custom_fields->fields; |
---|
| 6272 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
| 6273 | } |
---|
| 6274 | $this->output_template_array($p,'row','list',$var['access']); |
---|
| 6275 | unset($var['access']); |
---|
| 6276 | |
---|
| 6277 | $preserved = False; |
---|
| 6278 | foreach($this->fields as $field => $data) |
---|
| 6279 | { |
---|
| 6280 | if (!$data['disabled']) |
---|
| 6281 | { |
---|
| 6282 | if (isset($var[$field])) |
---|
| 6283 | { |
---|
| 6284 | switch($field) |
---|
| 6285 | { |
---|
| 6286 | case 'startdate': |
---|
| 6287 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
| 6288 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
| 6289 | break; |
---|
| 6290 | case 'enddate': |
---|
| 6291 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
| 6292 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
| 6293 | break; |
---|
| 6294 | case 'recure_type': |
---|
| 6295 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
| 6296 | $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>'); |
---|
| 6297 | $p->parse('row','hr',True); |
---|
| 6298 | $this->output_template_array($p,'row','list',$var['recure_type']); |
---|
| 6299 | $this->output_template_array($p,'row','list',$var['recure_enddate']); |
---|
| 6300 | $this->output_template_array($p,'row','list',$var['recure_day']); |
---|
| 6301 | $this->output_template_array($p,'row','list',$var['recure_interval']); |
---|
| 6302 | break; |
---|
| 6303 | default: |
---|
| 6304 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
| 6305 | } |
---|
| 6306 | } |
---|
| 6307 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
| 6308 | { |
---|
| 6309 | $lang = lang($name = substr($field,1)); |
---|
| 6310 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
| 6311 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
| 6312 | $v = array( |
---|
| 6313 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
| 6314 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
| 6315 | ); |
---|
| 6316 | if ($data['title']) |
---|
| 6317 | { |
---|
| 6318 | $v['tr_color'] = $this->theme['th_bg']; |
---|
| 6319 | } |
---|
| 6320 | if (!$data['length'] && $data['title']) |
---|
| 6321 | { |
---|
| 6322 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
| 6323 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
| 6324 | $p->parse('row','hr',True); |
---|
| 6325 | } |
---|
| 6326 | else |
---|
| 6327 | { |
---|
| 6328 | $this->output_template_array($p,'row','list',$v); |
---|
| 6329 | } |
---|
| 6330 | } |
---|
| 6331 | } |
---|
| 6332 | else // preserve disabled fields |
---|
| 6333 | { |
---|
| 6334 | switch ($field) |
---|
| 6335 | { |
---|
| 6336 | case 'owner': |
---|
| 6337 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
| 6338 | break; |
---|
| 6339 | case 'recure_type': |
---|
| 6340 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
| 6341 | { |
---|
| 6342 | $preserved[$field] = $event[$field]; |
---|
| 6343 | } |
---|
| 6344 | break; |
---|
| 6345 | case 'startdate': |
---|
| 6346 | case 'enddate': |
---|
| 6347 | $field = substr($field,0,-4); |
---|
| 6348 | default: |
---|
| 6349 | $preserved[$field] = $event[$field]; |
---|
| 6350 | } |
---|
| 6351 | } |
---|
| 6352 | } |
---|
| 6353 | unset($var); |
---|
| 6354 | if (is_array($preserved)) |
---|
| 6355 | { |
---|
| 6356 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
| 6357 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
| 6358 | } |
---|
| 6359 | $p->set_var('submit_button',lang('Save')); |
---|
| 6360 | |
---|
| 6361 | $delete_button = $cancel_button = ''; |
---|
| 6362 | if ($event['id'] > 0) |
---|
| 6363 | { |
---|
| 6364 | $var = Array( |
---|
| 6365 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
| 6366 | 'action_text_button' => lang('Delete'), |
---|
| 6367 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
| 6368 | 'action_extra_field' => '', |
---|
| 6369 | 'button_id' => 'delete_button' |
---|
| 6370 | ); |
---|
| 6371 | $p->set_var($var); |
---|
| 6372 | $delete_button = $p->fp('out','form_button'); |
---|
| 6373 | } |
---|
| 6374 | $p->set_var('delete_button',$delete_button); |
---|
| 6375 | $p->set_var('alert_msg',lang('Required field (category) is empty')); |
---|
| 6376 | |
---|
| 6377 | if ($this->bo->return_to) |
---|
| 6378 | { |
---|
| 6379 | $var = Array( |
---|
| 6380 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
| 6381 | 'action_text_button' => lang('Cancel'), |
---|
| 6382 | 'action_confirm_button' => '', |
---|
| 6383 | 'action_extra_field' => '', |
---|
| 6384 | 'button_id' => 'cancel_button' |
---|
| 6385 | ); |
---|
| 6386 | $p->set_var($var); |
---|
| 6387 | $cancel_button = $p->fp('out','form_button'); |
---|
| 6388 | } |
---|
| 6389 | $p->set_var('cancel_button',$cancel_button); |
---|
| 6390 | $p->pparse('out','edit_entry'); |
---|
| 6391 | } |
---|
| 6392 | |
---|
| 6393 | // modify list of an event's external participants (i.e. non pgpgw users) |
---|
| 6394 | // |
---|
| 6395 | function modify_ext_partlist() |
---|
| 6396 | { |
---|
| 6397 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
| 6398 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
| 6399 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
| 6400 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
| 6401 | |
---|
| 6402 | $total_contacts = 0; |
---|
| 6403 | $participant = array(); |
---|
| 6404 | $control_data= array(); |
---|
| 6405 | |
---|
| 6406 | $control_data['action'] = ''; |
---|
| 6407 | $control_data['delete'] = array(); |
---|
| 6408 | $control_data['part'] = array(); |
---|
| 6409 | |
---|
| 6410 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
| 6411 | $p->set_file( |
---|
| 6412 | Array( |
---|
| 6413 | 'T_edit_partlist' => 'edit_partlist.tpl', |
---|
| 6414 | 'T_edit_partlist_blocks' => 'edit_partlist_blocks.tpl' |
---|
| 6415 | ) |
---|
| 6416 | ); |
---|
| 6417 | |
---|
| 6418 | $p->set_block('T_edit_partlist_blocks','B_alert_msg','V_alert_msg'); |
---|
| 6419 | $p->set_block('T_edit_partlist_blocks','B_partlist','V_partlist'); |
---|
| 6420 | $p->set_block('T_edit_partlist_blocks','B_participants_none','V_participants_none'); |
---|
| 6421 | $p->set_block('T_edit_partlist_blocks','B_delete_btn','V_delete_btn'); |
---|
| 6422 | |
---|
| 6423 | global $query_addr; |
---|
| 6424 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
| 6425 | $addy = $sb->getAddress('addr','',$query_addr); |
---|
| 6426 | |
---|
| 6427 | $add_ext = $addy['doSearchFkt']; |
---|
| 6428 | $add_ext .= $addy['addr_title']!=lang('Address Book')?$addy['addr_title']:''; |
---|
| 6429 | $add_ext .= " ".$addy['addr'].$addy['addr_nojs']; |
---|
| 6430 | |
---|
| 6431 | $p->set_var('text_add_name',$add_ext); |
---|
| 6432 | |
---|
| 6433 | if(isset($_GET['part']) && $_GET['part']) |
---|
| 6434 | { |
---|
| 6435 | $control_data['part'] = split(",", $_GET['part']); |
---|
| 6436 | } |
---|
| 6437 | else |
---|
| 6438 | { |
---|
| 6439 | $control_data['part'] = $_POST['participant']; |
---|
| 6440 | $control_data['action'] = $_POST['action']; |
---|
| 6441 | $control_data['delete'] = $_POST['delete']; |
---|
| 6442 | } |
---|
| 6443 | |
---|
| 6444 | for ($i=0; $i<count($control_data['part']); $i++) |
---|
| 6445 | { |
---|
| 6446 | $id = $control_data['part'][$i]; |
---|
| 6447 | list($contact) = $this->read_contact($id); |
---|
| 6448 | |
---|
| 6449 | $participant[$id] = array(); |
---|
| 6450 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
| 6451 | } |
---|
| 6452 | |
---|
| 6453 | if ($control_data['action'] == lang('Delete selected contacts')) |
---|
| 6454 | { |
---|
| 6455 | for ($i=0; $i<count($control_data['delete']); $i++) |
---|
| 6456 | { |
---|
| 6457 | $id = $control_data['delete'][$i]; |
---|
| 6458 | unset($participant[$id]); |
---|
| 6459 | } |
---|
| 6460 | } |
---|
| 6461 | |
---|
| 6462 | if ($control_data['action'] == lang('Add Contact')) |
---|
| 6463 | { |
---|
| 6464 | $id = $_POST['id_addr']; |
---|
| 6465 | if (isset($id) && (int)$id != 0) |
---|
| 6466 | { |
---|
| 6467 | list($contact) = $this->read_contact($id); |
---|
| 6468 | $participant[$id] = array(); |
---|
| 6469 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
| 6470 | } |
---|
| 6471 | } |
---|
| 6472 | |
---|
| 6473 | // create list of currently selected contacts |
---|
| 6474 | // |
---|
| 6475 | while(list($id,$contact) = each($participant)) |
---|
| 6476 | { |
---|
| 6477 | $p->set_var('hidden_delete_name','participant[]'); |
---|
| 6478 | $p->set_var('hidden_delete_value',$id); |
---|
| 6479 | $p->set_var('ckbox_delete_name','delete[]'); |
---|
| 6480 | $p->set_var('ckbox_delete_value',$id); |
---|
| 6481 | $p->set_var('ckbox_delete_participant',$contact['name']); |
---|
| 6482 | $p->parse('V_partlist','B_partlist',True); |
---|
| 6483 | $total_contacts++; |
---|
| 6484 | } |
---|
| 6485 | |
---|
| 6486 | if ($total_contacts == 0) |
---|
| 6487 | { |
---|
| 6488 | // no contacts have been selected |
---|
| 6489 | // => clear the delete form, remove delete button and show the none block |
---|
| 6490 | // |
---|
| 6491 | $p->set_var('V_partlist',''); |
---|
| 6492 | $p->set_var('V_delete_btn',''); |
---|
| 6493 | $p->set_var('text_none',lang('None')); |
---|
| 6494 | $p->parse('V_participants_none','B_participants_none'); |
---|
| 6495 | } |
---|
| 6496 | else |
---|
| 6497 | { |
---|
| 6498 | // at least one contact has been selected |
---|
| 6499 | // => clear the none block, fill the delete form and add delete button |
---|
| 6500 | // |
---|
| 6501 | $p->set_var('V_participants_none',''); |
---|
| 6502 | $p->set_var('btn_delete_name','action'); |
---|
| 6503 | $p->set_var('btn_delete_value',lang('Delete selected contacts')); |
---|
| 6504 | $p->parse('V_delete_btn','B_delete_btn'); |
---|
| 6505 | } |
---|
| 6506 | |
---|
| 6507 | $body_tags = 'bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_color'] |
---|
| 6508 | . '" alink="'.$GLOBALS['phpgw_info']['theme']['alink'] |
---|
| 6509 | . '" link="'.$GLOBALS['phpgw_info']['theme']['link'] |
---|
| 6510 | .'" vlink="'.$GLOBALS['phpgw_info']['theme']['vlink'].'"'; |
---|
| 6511 | |
---|
| 6512 | $form_action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'calendar.uicalendar.modify')); |
---|
| 6513 | |
---|
| 6514 | $charset = lang('charset'); |
---|
| 6515 | $p->set_var('charset',$charset); |
---|
| 6516 | $p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp'] |
---|
| 6517 | . ' - ' .lang('External Participants')); |
---|
| 6518 | $p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']); |
---|
| 6519 | $p->set_var('body_tags',$body_tags); |
---|
| 6520 | $p->set_var('form_method','POST'); |
---|
| 6521 | $p->set_var('form_action',$form_action); |
---|
| 6522 | $p->set_var('text_add_contact',lang('External Participants')); |
---|
| 6523 | $p->set_var('text_contacts_selected',lang('Selected contacts (%1)',$total_contacts)); |
---|
| 6524 | $p->set_var('btn_add_name','action'); |
---|
| 6525 | $p->set_var('btn_add_value',lang('Add Contact')); |
---|
| 6526 | $p->set_var('btn_done_name','done'); |
---|
| 6527 | $p->set_var('btn_done_value',lang('Done')); |
---|
| 6528 | $p->set_var('btn_done_js','copyback()'); |
---|
| 6529 | $p->set_var('form1_name','ext_form'); |
---|
| 6530 | |
---|
| 6531 | $p->pfp('out','T_edit_partlist'); |
---|
| 6532 | } |
---|
| 6533 | |
---|
| 6534 | function read_contact($id) |
---|
| 6535 | { |
---|
| 6536 | $query_fields = Array( |
---|
| 6537 | 'n_given' => 'n_given', |
---|
| 6538 | 'n_family' => 'n_family', |
---|
| 6539 | 'email' => 'email', |
---|
| 6540 | 'email_home' => 'email_home' |
---|
| 6541 | ); |
---|
| 6542 | |
---|
| 6543 | /* |
---|
| 6544 | if ($this->rights & PHPGW_ACL_READ) |
---|
| 6545 | { |
---|
| 6546 | return $this->contacts->read_single_entry($id,$fields); |
---|
| 6547 | } |
---|
| 6548 | else |
---|
| 6549 | { |
---|
| 6550 | $rtrn = array(0 => array('No access' => 'No access')); |
---|
| 6551 | return $rtrn; |
---|
| 6552 | } |
---|
| 6553 | */ |
---|
| 6554 | |
---|
| 6555 | $contacts = CreateObject('phpgwapi.contacts', False); |
---|
| 6556 | return $contacts->read_single_entry($id,$query_fields); |
---|
| 6557 | } |
---|
| 6558 | |
---|
| 6559 | function build_part_list(&$users,$accounts,$owner) |
---|
| 6560 | { |
---|
| 6561 | if(!is_array($accounts)) |
---|
| 6562 | { |
---|
| 6563 | return; |
---|
| 6564 | } |
---|
| 6565 | foreach($accounts as $id) |
---|
| 6566 | { |
---|
| 6567 | $id = (int)$id; |
---|
| 6568 | if($id == $owner) |
---|
| 6569 | { |
---|
| 6570 | continue; |
---|
| 6571 | } |
---|
| 6572 | elseif(!isset($users[$id])) |
---|
| 6573 | { |
---|
| 6574 | if($GLOBALS['phpgw']->accounts->exists($id) == True) |
---|
| 6575 | { |
---|
| 6576 | $users[$id] = Array( |
---|
| 6577 | 'name' => $GLOBALS['phpgw']->common->grab_owner_name($id), |
---|
| 6578 | 'type' => $GLOBALS['phpgw']->accounts->get_type($id) |
---|
| 6579 | ); |
---|
| 6580 | } |
---|
| 6581 | if($GLOBALS['phpgw']->accounts->get_type($id) == 'g') |
---|
| 6582 | { |
---|
| 6583 | //$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group'),$owner); |
---|
| 6584 | } |
---|
| 6585 | } |
---|
| 6586 | } |
---|
| 6587 | if (!function_exists('strcmp_name')) |
---|
| 6588 | { |
---|
| 6589 | function strcmp_name($arr1,$arr2) |
---|
| 6590 | { |
---|
| 6591 | if ($diff = strcmp($arr1['type'],$arr2['type'])) |
---|
| 6592 | { |
---|
| 6593 | return $diff; // groups before users |
---|
| 6594 | } |
---|
| 6595 | return strnatcasecmp($arr1['name'],$arr2['name']); |
---|
| 6596 | } |
---|
| 6597 | } |
---|
| 6598 | uasort($users,'strcmp_name'); |
---|
| 6599 | } |
---|
| 6600 | |
---|
| 6601 | function set_week_array($startdate,$cellcolor,$weekly) |
---|
| 6602 | { |
---|
| 6603 | $data = date("m"); |
---|
| 6604 | for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400) |
---|
| 6605 | { |
---|
| 6606 | $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset |
---|
| 6607 | print_debug('set_week_array : Date ',$date); |
---|
| 6608 | |
---|
| 6609 | if($events = $this->bo->cached_events[$date]) |
---|
| 6610 | { |
---|
| 6611 | print_debug('Date',$date); |
---|
| 6612 | print_debug('Appointments Found',count($events)); |
---|
| 6613 | |
---|
| 6614 | if (!$this->bo->prefs['calendar']['show_rejected']) |
---|
| 6615 | { |
---|
| 6616 | $appts = False; |
---|
| 6617 | foreach($events as $event) // check for a not-rejected event |
---|
| 6618 | { |
---|
| 6619 | if (!$this->bo->rejected_no_show($event)) |
---|
| 6620 | { |
---|
| 6621 | $appts = True; |
---|
| 6622 | break; |
---|
| 6623 | } |
---|
| 6624 | } |
---|
| 6625 | } |
---|
| 6626 | else |
---|
| 6627 | { |
---|
| 6628 | $appts = True; |
---|
| 6629 | } |
---|
| 6630 | } |
---|
| 6631 | else |
---|
| 6632 | { |
---|
| 6633 | $appts = False; |
---|
| 6634 | } |
---|
| 6635 | |
---|
| 6636 | $holidays = $this->bo->cached_holidays[$date]; |
---|
| 6637 | if($weekly) |
---|
| 6638 | { |
---|
| 6639 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
| 6640 | } |
---|
| 6641 | |
---|
| 6642 | $day_image = ''; |
---|
| 6643 | if($holidays) |
---|
| 6644 | { |
---|
| 6645 | $extra = ' bgcolor="'.$this->bo->holiday_color.'"'; |
---|
| 6646 | $class = ($appts?'b':'').'minicalhol'; |
---|
| 6647 | if ($date == $this->bo->today) |
---|
| 6648 | { |
---|
| 6649 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 6650 | } |
---|
| 6651 | } |
---|
| 6652 | elseif ($date != $this->bo->today) |
---|
| 6653 | { |
---|
| 6654 | $extra = ' bgcolor="'.$cellcolor.'"'; |
---|
| 6655 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 6656 | } |
---|
| 6657 | else |
---|
| 6658 | { |
---|
| 6659 | $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"'; |
---|
| 6660 | $class = ($appts?'b':'').'minicalendar'; |
---|
| 6661 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
| 6662 | } |
---|
| 6663 | |
---|
| 6664 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
| 6665 | { |
---|
| 6666 | $extra = ''; |
---|
| 6667 | } |
---|
| 6668 | |
---|
| 6669 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
| 6670 | { |
---|
| 6671 | $new_event = True; |
---|
| 6672 | } |
---|
| 6673 | else |
---|
| 6674 | { |
---|
| 6675 | $new_event = False; |
---|
| 6676 | } |
---|
| 6677 | $holiday_name = Array(); |
---|
| 6678 | if($holidays) |
---|
| 6679 | { |
---|
| 6680 | for($k=0;$k<count($holidays);$k++) |
---|
| 6681 | { |
---|
| 6682 | $holiday_name[] = $holidays[$k]['name']; |
---|
| 6683 | } |
---|
| 6684 | } |
---|
| 6685 | $week = ''; |
---|
| 6686 | if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) |
---|
| 6687 | { |
---|
| 6688 | $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); |
---|
| 6689 | } |
---|
| 6690 | $daily[$date] = Array( |
---|
| 6691 | 'extra' => $extra, |
---|
| 6692 | 'new_event' => $new_event, |
---|
| 6693 | 'holidays' => $holiday_name, |
---|
| 6694 | 'appts' => $appts, |
---|
| 6695 | 'week' => $week, |
---|
| 6696 | 'day_image' => $day_image, |
---|
| 6697 | 'class' => $class |
---|
| 6698 | ); |
---|
| 6699 | } |
---|
| 6700 | |
---|
| 6701 | if($this->debug) |
---|
| 6702 | { |
---|
| 6703 | _debug_array($daily); |
---|
| 6704 | } |
---|
| 6705 | |
---|
| 6706 | return $daily; |
---|
| 6707 | } |
---|
| 6708 | |
---|
| 6709 | function get_organizations($context, $selected='', $recursive = false) |
---|
| 6710 | { |
---|
| 6711 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
| 6712 | |
---|
| 6713 | return ($recursive ? |
---|
| 6714 | $s->get_organizations($context, $selected, false ,false) : |
---|
| 6715 | $s->get_sectors($selected, false, false)); |
---|
| 6716 | } |
---|
| 6717 | } |
---|
| 6718 | ?> |
---|