2001-07-16 13:38:40 +02:00
< ? php
/************************************************************************** \
2003-11-03 10:21:26 +01:00
* eGroupWare - Calendar *
* http :// www . eGroupWare . org *
* Maintained and further developed by RalfBecker @ outdoor - training . de *
2001-07-16 13:38:40 +02:00
* Based on Webcalendar by Craig Knudsen < cknudsen @ radix . net > *
* http :// www . radix . net /~ cknudsen *
2003-11-03 10:21:26 +01:00
* Originaly modified by Mark Peters < skeeter @ phpgroupware . org > *
2001-07-16 13:38:40 +02:00
* -------------------------------------------- *
* This program is free software ; you can redistribute it and / or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation ; either version 2 of the License , or ( at your *
* option ) any later version . *
\ **************************************************************************/
/* $Id$ */
class uicalendar
{
var $template ;
var $template_dir ;
var $bo ;
var $cat ;
var $holidays ;
var $holiday_color ;
2003-08-28 16:31:11 +02:00
2001-07-16 13:38:40 +02:00
var $debug = False ;
2002-04-13 05:20:53 +02:00
// var $debug = True;
2001-07-16 13:38:40 +02:00
var $cat_id ;
2001-08-13 16:11:07 +02:00
var $theme ;
2002-06-25 01:24:24 +02:00
var $link_tpl ;
2001-07-16 13:38:40 +02:00
2002-09-17 04:25:40 +02:00
// planner related variables
var $planner_header ;
var $planner_rows ;
var $planner_group_members ;
var $planner_firstday ;
var $planner_lastday ;
var $planner_days ;
var $planner_end_month ;
var $planner_end_year ;
2003-09-07 20:33:52 +02:00
var $planner_days_in_end_month ;
2002-11-23 15:19:56 +01:00
var $planner_intervals = array ( // conversation hour and interval depending on intervals_per_day
// 1 1 1 1 1 1 1 1 1 1 2 2 2 2
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
'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
'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
'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
'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
);
2002-09-17 04:25:40 +02:00
2001-07-16 13:38:40 +02:00
var $public_functions = array (
'mini_calendar' => True ,
'index' => True ,
'month' => True ,
2001-11-05 04:48:14 +01:00
'get_month' => True ,
2001-07-16 13:38:40 +02:00
'week' => True ,
2002-08-22 05:07:54 +02:00
'get_week' => True ,
2001-07-16 13:38:40 +02:00
'year' => True ,
'view' => True ,
'edit' => True ,
2001-08-29 21:18:32 +02:00
'export' => True ,
2001-11-05 03:08:31 +01:00
'reinstate_list' => True ,
'reinstate' => True ,
2001-07-28 15:17:30 +02:00
'add' => True ,
2001-07-18 19:32:10 +02:00
'delete' => True ,
'preferences' => True ,
2001-07-22 01:35:22 +02:00
'day' => True ,
'edit_status' => True ,
'set_action' => True ,
2001-07-28 15:17:30 +02:00
'planner' => True ,
2003-08-28 16:31:11 +02:00
'modify_ext_partlist' => True ,
2001-07-28 15:17:30 +02:00
'matrixselect' => True ,
'viewmatrix' => True ,
'search' => True ,
2001-07-22 01:35:22 +02:00
'header' => True ,
2001-08-28 05:41:16 +02:00
'footer' => True ,
2003-08-28 16:31:11 +02:00
'css' => True ,
2001-07-16 13:38:40 +02:00
);
function uicalendar ()
{
2001-08-26 14:31:28 +02:00
$GLOBALS [ 'phpgw' ] -> nextmatchs = CreateObject ( 'phpgwapi.nextmatchs' );
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> browser = CreateObject ( 'phpgwapi.browser' );
2003-09-07 20:33:52 +02:00
2001-08-13 16:11:07 +02:00
$this -> theme = $GLOBALS [ 'phpgw_info' ][ 'theme' ];
2001-07-16 13:38:40 +02:00
2001-07-18 19:32:10 +02:00
$this -> bo = CreateObject ( 'calendar.bocalendar' , 1 );
2003-08-28 16:31:11 +02:00
$this -> cat = & $this -> bo -> cat ;
2001-07-16 13:38:40 +02:00
2002-09-21 23:50:30 +02:00
print_debug ( 'BO Owner' , $this -> bo -> owner );
2001-07-22 01:35:22 +02:00
2001-08-12 16:47:23 +02:00
$this -> template = $GLOBALS [ 'phpgw' ] -> template ;
$this -> template_dir = $GLOBALS [ 'phpgw' ] -> common -> get_tpl_dir ( 'calendar' );
2001-07-16 13:38:40 +02:00
2001-08-28 05:41:16 +02:00
$this -> holiday_color = ( substr ( $this -> theme [ 'bg06' ], 0 , 1 ) == '#' ? '' : '#' ) . $this -> theme [ 'bg06' ];
2004-01-04 01:47:37 +01:00
2001-07-16 13:38:40 +02:00
$this -> cat_id = $this -> bo -> cat_id ;
2002-06-25 01:24:24 +02:00
$this -> link_tpl = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$this -> link_tpl -> set_unknowns ( 'remove' );
$this -> link_tpl -> set_file (
2004-01-04 01:47:37 +01:00
Array (
'link_picture' => 'link_pict.tpl'
)
2002-06-25 01:24:24 +02:00
);
$this -> link_tpl -> set_block ( 'link_picture' , 'link_pict' , 'link_pict' );
$this -> link_tpl -> set_block ( 'link_picture' , 'pict' , 'pict' );
$this -> link_tpl -> set_block ( 'link_picture' , 'link_open' , 'link_open' );
$this -> link_tpl -> set_block ( 'link_picture' , 'link_close' , 'link_close' );
$this -> link_tpl -> set_block ( 'link_picture' , 'link_text' , 'link_text' );
2001-07-18 19:32:10 +02:00
if ( $this -> bo -> use_session )
{
2002-11-23 15:19:56 +01:00
// save return-fkt for add, view, ...
2003-08-28 16:31:11 +02:00
list (,, $fkt ) = explode ( '.' , $_GET [ 'menuaction' ]);
2002-11-23 15:19:56 +01:00
if ( $fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner' )
{
2003-08-28 16:31:11 +02:00
$this -> bo -> return_to = $_GET [ 'menuaction' ] .
2002-11-23 15:19:56 +01:00
sprintf ( '&date=%04d%02d%02d' , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day );
2004-07-12 00:07:24 +02:00
// reset the matrixview participants
$GLOBALS [ 'phpgw' ] -> session -> appsession ( 'participants' , NULL , '' );
2002-11-23 15:19:56 +01:00
}
$this -> bo -> save_sessiondata ();
2001-07-18 19:32:10 +02:00
}
2003-08-28 16:31:11 +02:00
$this -> always_app_header = $this -> bo -> prefs [ 'common' ][ 'template_set' ] == 'idots' ;
2001-07-16 13:38:40 +02:00
2003-08-28 16:31:11 +02:00
print_debug ( 'UI' , $this -> _debug_sqsof ());
2003-09-14 14:51:31 +02:00
if ( ! is_object ( $GLOBALS [ 'phpgw' ] -> html ))
{
$GLOBALS [ 'phpgw' ] -> html = CreateObject ( 'phpgwapi.html' );
}
$this -> html = & $GLOBALS [ 'phpgw' ] -> html ;
2004-08-01 17:36:04 +02:00
// jscalendar is needed by the new navigation-menu AND it need to be loaded befor the header !!!
if ( ! is_object ( $GLOBALS [ 'phpgw' ] -> jscalendar ))
{
$GLOBALS [ 'phpgw' ] -> jscalendar = CreateObject ( 'phpgwapi.jscalendar' );
}
$this -> jscal = & $GLOBALS [ 'phpgw' ] -> jscalendar ;
2004-08-19 12:29:57 +02:00
if ( ! isset ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]))
{
$this -> bo -> prefs [ 'calendar' ][ 'interval' ] = 30 ;
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'interval' , 30 );
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
}
2003-04-21 13:00:53 +02:00
}
2001-07-16 13:38:40 +02:00
/* Public functions */
2001-08-13 06:49:19 +02:00
function mini_calendar ( $params )
2001-07-16 13:38:40 +02:00
{
2002-09-19 04:14:41 +02:00
static $mini_cal_tpl ;
2001-08-13 06:49:19 +02:00
if ( ! is_array ( $params ))
{
return ;
}
2001-12-24 04:07:24 +01:00
if ( $params [ 'month' ] == 0 )
{
$params [ 'month' ] = 12 ;
$params [ 'year' ] = $params [ 'year' ] - 1 ;
}
elseif ( $params [ 'month' ] == 13 )
{
$params [ 'month' ] = 1 ;
$params [ 'year' ] = $params [ 'year' ] + 1 ;
}
2001-08-28 05:41:16 +02:00
$this -> bo -> store_to_cache (
Array (
'smonth' => $params [ 'month' ],
'sday' => 1 ,
'syear' => $params [ 'year' ]
)
);
2004-01-04 01:47:37 +01:00
2001-08-25 05:22:01 +02:00
$params [ 'link' ] = ( ! isset ( $params [ 'link' ]) ? '' : $params [ 'link' ]);
$params [ 'buttons' ] = ( ! isset ( $params [ 'buttons' ]) ? 'none' : $params [ 'buttons' ]);
$params [ 'outside_month' ] = ( ! isset ( $params [ 'outside_month' ]) ? True : $params [ 'outside_month' ]);
2001-08-13 06:49:19 +02:00
2001-12-24 04:07:24 +01:00
$this -> bo -> read_holidays ( $params [ 'year' ]);
2001-07-16 13:38:40 +02:00
2002-06-25 01:24:24 +02:00
$date = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $params [ 'month' ], $params [ 'day' ], $params [ 'year' ]);
2004-01-04 01:47:37 +01:00
$month_ago = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ] - 1 , $params [ 'day' ], $params [ 'year' ])));
$month_ahead = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ] + 1 , $params [ 'day' ], $params [ 'year' ])));
$monthstart = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ], 1 , $params [ 'year' ])));
$monthend = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ] + 1 , 0 , $params [ 'year' ])));
2001-07-16 13:38:40 +02:00
2002-06-25 01:24:24 +02:00
$weekstarttime = $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $params [ 'year' ], $params [ 'month' ], 1 );
2002-04-16 18:52:36 +02:00
2002-09-19 04:14:41 +02:00
print_debug ( 'mini_calendar:monthstart' , $monthstart );
print_debug ( 'mini_calendar:weekstarttime' , date ( 'Ymd H:i:s' , $weekstarttime ));
2001-07-16 13:38:40 +02:00
2002-09-19 04:14:41 +02:00
if ( ! is_object ( $mini_cal_tpl ))
{
$mini_cal_tpl = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$mini_cal_tpl -> set_unknowns ( 'remove' );
$mini_cal_tpl -> set_file (
Array (
'mini_calendar' => 'mini_cal.tpl'
)
);
$mini_cal_tpl -> set_block ( 'mini_calendar' , 'mini_cal' , 'mini_cal' );
$mini_cal_tpl -> set_block ( 'mini_calendar' , 'mini_week' , 'mini_week' );
$mini_cal_tpl -> set_block ( 'mini_calendar' , 'mini_day' , 'mini_day' );
}
2001-07-16 13:38:40 +02:00
2003-08-28 16:31:11 +02:00
2001-07-18 19:32:10 +02:00
if ( $this -> bo -> printer_friendly == False )
2001-07-16 13:38:40 +02:00
{
2004-03-16 23:02:34 +01:00
//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>';
$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>' ;
2001-07-16 13:38:40 +02:00
}
else
{
2001-08-12 16:47:23 +02:00
$month = lang ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $date [ 'raw' ], 'F' )) . ' ' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $date [ 'raw' ], 'Y' );
2001-07-16 13:38:40 +02:00
}
$var = Array (
2002-09-19 04:14:41 +02:00
'cal_img_root' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'mini-calendar-bar' ),
2001-08-13 16:11:07 +02:00
'bgcolor' => $this -> theme [ 'bg_color' ],
'bgcolor1' => $this -> theme [ 'bg_color' ],
2001-07-16 13:38:40 +02:00
'month' => $month ,
2001-08-13 16:11:07 +02:00
'bgcolor2' => $this -> theme [ 'cal_dayview' ],
2001-07-16 13:38:40 +02:00
'holiday_color' => $this -> holiday_color
);
2002-09-19 04:14:41 +02:00
$mini_cal_tpl -> set_var ( $var );
2001-07-16 13:38:40 +02:00
2001-08-13 06:49:19 +02:00
switch ( strtolower ( $params [ 'buttons' ]))
2001-07-16 13:38:40 +02:00
{
case 'right' :
$var = Array (
2002-09-19 04:14:41 +02:00
'nextmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ahead ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'right' ) . '" border="0"></a>'
2001-07-16 13:38:40 +02:00
);
break ;
case 'left' :
$var = Array (
2002-09-19 04:14:41 +02:00
'prevmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ago ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'left' ) . '" border="0"></a>'
2004-01-04 01:47:37 +01:00
);
2001-07-16 13:38:40 +02:00
break ;
case 'both' :
$var = Array (
2002-09-19 04:14:41 +02:00
'prevmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ago ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'left' ) . '" border="0"></a>' ,
'nextmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ahead ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'right' ) . '" border="0"></a>'
2001-07-16 13:38:40 +02:00
);
break ;
case 'none' :
default :
$var = Array (
'prevmonth' => '' ,
'nextmonth' => ''
);
break ;
}
2002-09-19 04:14:41 +02:00
$mini_cal_tpl -> set_var ( $var );
2001-07-16 13:38:40 +02:00
2002-09-19 04:14:41 +02:00
if ( ! $mini_cal_tpl -> get_var ( 'daynames' ))
2001-07-16 13:38:40 +02:00
{
2002-09-19 04:14:41 +02:00
for ( $i = 0 ; $i < 7 ; $i ++ )
{
$var = Array (
2003-12-17 00:16:41 +01:00
'dayname' => '<b>' . lang ( $GLOBALS [ 'phpgw' ] -> datetime -> days_short [ $i ]) . '</b>' ,
2002-09-19 04:14:41 +02:00
'day_image' => ''
);
2002-09-22 14:24:45 +02:00
$this -> output_template_array ( $mini_cal_tpl , 'daynames' , 'mini_day' , $var );
2002-09-19 04:14:41 +02:00
}
2001-07-16 13:38:40 +02:00
}
2002-08-25 06:07:21 +02:00
$today = date ( 'Ymd' , $GLOBALS [ 'phpgw' ] -> datetime -> users_localtime );
2001-07-16 13:38:40 +02:00
unset ( $date );
2002-08-25 06:07:21 +02:00
for ( $i = $weekstarttime + $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ; date ( 'Ymd' , $i ) <= $monthend ; $i += ( 24 * 3600 * 7 ))
2001-07-16 13:38:40 +02:00
{
unset ( $var );
2002-08-25 06:07:21 +02:00
$daily = $this -> set_week_array ( $i - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset , $cellcolor , $weekly );
2003-08-28 16:31:11 +02:00
foreach ( $daily as $date => $day_params )
2001-07-16 13:38:40 +02:00
{
2002-09-19 04:14:41 +02:00
print_debug ( 'Mini-Cal Date' , $date );
2004-01-04 01:47:37 +01:00
$year = ( int )( substr ( $date , 0 , 4 ));
$month = ( int )( substr ( $date , 4 , 2 ));
$day = ( int )( substr ( $date , 6 , 2 ));
2001-07-16 13:38:40 +02:00
$str = '' ;
2001-08-13 06:49:19 +02:00
if (( $date >= $monthstart && $date <= $monthend ) || $params [ 'outside_month' ] == True )
2001-07-16 13:38:40 +02:00
{
2001-08-13 06:49:19 +02:00
if ( ! $this -> bo -> printer_friendly && $params [ 'link' ])
2001-07-16 13:38:40 +02:00
{
2004-03-15 00:14:41 +01:00
//NDEE: class def what for?
2001-08-13 06:49:19 +02:00
$str = '<a href="' . $this -> page ( $params [ 'link' ], '&date=' . $date ) . '" class="' . $day_params [ 'class' ] . '">' . $day . '</a>' ;
2001-07-16 13:38:40 +02:00
}
else
{
2004-03-15 00:14:41 +01:00
//NDEE: printer-friendly (mini-calendar)
2001-07-16 13:38:40 +02:00
$str = $day ;
}
}
2002-03-14 01:10:50 +01:00
else
{
$day_params [ 'day_image' ] = '' ;
}
2001-07-16 13:38:40 +02:00
$var [] = Array (
'day_image' => $day_params [ 'day_image' ],
'dayname' => $str
);
}
for ( $l = 0 ; $l < count ( $var ); $l ++ )
{
2002-09-19 04:14:41 +02:00
$this -> output_template_array ( $mini_cal_tpl , 'monthweek_day' , 'mini_day' , $var [ $l ]);
2001-07-16 13:38:40 +02:00
}
2002-09-19 04:14:41 +02:00
$mini_cal_tpl -> parse ( 'display_monthweek' , 'mini_week' , True );
$mini_cal_tpl -> set_var ( 'dayname' , '' );
$mini_cal_tpl -> set_var ( 'monthweek_day' , '' );
2001-07-16 13:38:40 +02:00
}
2004-01-04 01:47:37 +01:00
2002-09-19 04:14:41 +02:00
$return_value = $mini_cal_tpl -> fp ( 'out' , 'mini_cal' );
$mini_cal_tpl -> set_var ( 'display_monthweek' , '' );
2003-08-28 16:31:11 +02:00
// $mini_cal_tpl->set_var('daynames','');
// unset($p);
2001-07-16 13:38:40 +02:00
return $return_value ;
}
2001-07-28 15:17:30 +02:00
function index ( $params = '' )
2001-07-16 13:38:40 +02:00
{
2003-11-03 10:21:26 +01:00
if ( ! $params )
{
foreach ( array ( 'date' , 'year' , 'month' , 'day' ) as $field )
{
if ( isset ( $_GET [ $field ]))
{
$params [ $field ] = $_GET [ $field ];
}
}
}
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> redirect ( $this -> page ( '' , $params ));
2001-07-16 13:38:40 +02:00
}
2004-03-15 00:14:41 +01:00
// NDEE: printer-friendly
2003-08-28 16:31:11 +02:00
function printer_friendly ( $body , $app_header = '' )
2002-11-23 21:48:42 +01:00
{
2003-08-28 16:31:11 +02:00
if ( $this -> bo -> printer_friendly )
2002-11-23 21:48:42 +01:00
{
2003-08-28 16:31:11 +02:00
$new_body = '<html>' . " \n "
. '<head>' . " \n "
2004-03-15 00:14:41 +01:00
// .'<STYLE type="text/css">'."\n"
// .'<!-- '."\n"
// .' .tablink { color: #000000; }'."\n"
// .' '.$this->css()."\n"
// .'-->'."\n"
// .'</STYLE>'."\n"
. '<LINK href="' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '/calendar/templates/default/app_print.css" type=text/css rel=StyleSheet>' . " \n "
. ' </ head >
< table id = " calendar_print_main " class = " calendar_print_main " >
< tr >
< td id = " calendar_print_content " class = " calendar_print_content " > ' . " \n "
2003-08-28 16:31:11 +02:00
. $this -> bo -> debug_string . $body
2004-03-15 00:14:41 +01:00
. ' </ td >
</ tr >
</ table ></ body > ' . " \n "
2003-08-28 16:31:11 +02:00
. '</html>' . " \n " ;
2002-11-23 21:48:42 +01:00
}
else
{
2003-08-28 16:31:11 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ]);
if ( $app_header && $this -> always_app_header )
2002-11-23 21:48:42 +01:00
{
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . $app_header ;
2002-11-23 21:48:42 +01:00
}
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
$new_body = $this -> bo -> debug_string . $body ;
2002-11-23 21:48:42 +01:00
}
2003-08-28 16:31:11 +02:00
return $new_body ;
2002-04-07 16:12:53 +02:00
}
function month ()
{
2003-08-28 16:31:11 +02:00
echo $this -> printer_friendly ( $this -> get_month (), lang ( 'Monthview' ));
2001-11-05 04:48:14 +01:00
}
function get_month ()
2001-07-16 13:38:40 +02:00
{
$m = mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year );
2003-11-07 17:32:23 +01:00
$next = $this -> bo -> month + 1 ;
$prev = $this -> bo -> month - 1 ;
$nextyear = $this -> bo -> year ;
$prevyear = $this -> bo -> year ;
if ( $this -> bo -> month == 12 )
{
$next = 1 ;
$nextyear = $nextyear + 1 ;
}
elseif ( $this -> bo -> month == 1 )
{
$prev = 12 ;
$prevyear = $prevyear - 1 ;
}
2001-11-05 03:08:31 +01:00
if ( ! $this -> bo -> printer_friendly || ( $this -> bo -> printer_friendly && @ $this -> bo -> prefs [ 'calendar' ][ 'display_minicals' ]))
2001-08-13 06:49:19 +02:00
{
$minical_prev = $this -> mini_calendar (
Array (
'day' => 1 ,
'month' => $this -> bo -> month - 1 ,
'year' => $this -> bo -> year ,
2003-11-07 17:32:23 +01:00
'link' => 'day' ,
'outside_month' => False
2001-08-13 06:49:19 +02:00
)
);
2003-11-07 17:32:23 +01:00
2001-08-13 06:49:19 +02:00
$minical_next = $this -> mini_calendar (
Array (
'day' => 1 ,
'month' => $this -> bo -> month + 1 ,
'year' => $this -> bo -> year ,
2003-11-07 17:32:23 +01:00
'link' => 'day' ,
'outside_month' => False
2001-08-13 06:49:19 +02:00
)
);
}
else
{
$minical_prev = '' ;
$minical_next = '' ;
}
2001-07-18 19:32:10 +02:00
if ( ! $this -> bo -> printer_friendly )
2001-07-16 13:38:40 +02:00
{
$printer = '' ;
2003-11-07 17:32:23 +01:00
$prev_month_link = '<a href="' . $this -> page ( 'month' , '&year=' . $prevyear . '&month=' . $prev ) . '"><<</a>' ;
$next_month_link = '<a href="' . $this -> page ( 'month' , '&year=' . $nextyear . '&month=' . $next ) . '">>></a>' ;
2001-07-18 19:32:10 +02:00
$param = '&year=' . $this -> bo -> year . '&month=' . $this -> bo -> month . '&friendly=1' ;
2001-07-16 13:38:40 +02:00
$print = '<a href="' . $this -> page ( 'month' . $param ) . " \" TARGET= \" cal_printer_friendly \" onMouseOver= \" window.status = ' " . lang ( 'Generate printer-friendly version' ) . " ' \" >[ " . lang ( 'Printer Friendly' ) . ']</a>' ;
}
else
{
$printer = '<body bgcolor="' . $phpgw_info [ 'theme' ][ 'bg_color' ] . '">' ;
2003-11-07 17:32:23 +01:00
$prev_month_link = '' ;
$next_month_link = '' ;
2001-07-16 13:38:40 +02:00
$print = '' ;
2001-10-01 04:34:45 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nofooter' ] = True ;
2001-07-16 13:38:40 +02:00
}
2001-12-24 04:07:24 +01:00
$this -> bo -> read_holidays ();
2001-07-16 13:38:40 +02:00
$var = Array (
'printer_friendly' => $printer ,
2001-08-13 16:11:07 +02:00
'bg_text' => $this -> theme [ 'bg_text' ],
2001-07-16 13:38:40 +02:00
'small_calendar_prev' => $minical_prev ,
2003-11-07 17:32:23 +01:00
'prev_month_link' => $prev_month_link ,
2001-07-28 15:17:30 +02:00
'month_identifier' => lang ( strftime ( " %B " , $m )) . ' ' . $this -> bo -> year ,
2001-08-12 16:47:23 +02:00
'username' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ),
2003-11-07 17:32:23 +01:00
'next_month_link' => $next_month_link ,
2001-07-16 13:38:40 +02:00
'small_calendar_next' => $minical_next ,
2001-07-18 19:32:10 +02:00
'large_month' => $this -> display_month ( $this -> bo -> month , $this -> bo -> year , True , $this -> bo -> owner ),
2001-07-16 13:38:40 +02:00
'print' => $print
);
2003-04-27 09:27:05 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
2001-07-28 15:17:30 +02:00
$p -> set_unknowns ( 'remove' );
2001-08-06 04:41:36 +02:00
$p -> set_file (
Array (
'index_t' => 'index.tpl'
)
2001-07-28 15:17:30 +02:00
);
2001-07-18 19:32:10 +02:00
$p -> set_var ( $var );
2001-11-05 04:48:14 +01:00
return $p -> fp ( 'out' , 'index_t' );
2001-07-16 13:38:40 +02:00
}
function week ()
2001-11-05 04:48:14 +01:00
{
2003-08-28 16:31:11 +02:00
echo $this -> printer_friendly ( $this -> get_week (), lang ( 'Weekview' ));
2001-11-05 04:48:14 +01:00
}
function get_week ()
2001-07-16 13:38:40 +02:00
{
2001-07-18 19:32:10 +02:00
$this -> bo -> read_holidays ();
2002-06-25 01:24:24 +02:00
$next = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day + 7 , $this -> bo -> year );
$prev = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day - 7 , $this -> bo -> year );
2001-07-16 13:38:40 +02:00
2001-09-29 03:40:47 +02:00
if ( ! $this -> bo -> printer_friendly || ( $this -> bo -> printer_friendly && @ $this -> bo -> prefs [ 'calendar' ][ 'display_minicals' ]))
2001-08-13 06:49:19 +02:00
{
$minical_this = $this -> mini_calendar (
Array (
'day' => $this -> bo -> day ,
'month' => $this -> bo -> month ,
'year' => $this -> bo -> year ,
'link' => 'day' ,
'butons' => 'none' ,
'outside_month' => False
)
);
$minical_prev = $this -> mini_calendar (
Array (
'day' => $this -> bo -> day ,
'month' => $this -> bo -> month - 1 ,
'year' => $this -> bo -> year ,
'link' => 'day' ,
'butons' => 'left' ,
'outside_month' => False
)
);
$minical_next = $this -> mini_calendar (
Array (
'day' => $this -> bo -> day ,
'month' => $this -> bo -> month + 1 ,
'year' => $this -> bo -> year ,
'link' => 'day' ,
'butons' => 'right' ,
'outside_month' => False
)
);
}
else
{
2004-03-15 00:14:41 +01:00
//NDEE: printer-friendly what?
2001-08-13 06:49:19 +02:00
$minical_this = '' ;
$minical_prev = '' ;
$minical_next = '' ;
}
2004-01-04 01:47:37 +01:00
2001-07-18 19:32:10 +02:00
if ( ! $this -> bo -> printer_friendly )
2001-07-16 13:38:40 +02:00
{
2001-07-18 19:32:10 +02:00
$printer = '' ;
2001-07-28 15:17:30 +02:00
$prev_week_link = '<a href="' . $this -> page ( 'week' , '&date=' . $prev [ 'full' ]) . '"><<</a>' ;
$next_week_link = '<a href="' . $this -> page ( 'week' , '&date=' . $next [ 'full' ]) . '">>></a>' ;
2003-02-26 19:58:01 +01:00
$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>' ;
2001-07-16 13:38:40 +02:00
}
else
{
2004-03-15 00:14:41 +01:00
//NDEE: printer-friendly (weekly-view)
2001-08-13 16:11:07 +02:00
$printer = '<body bgcolor="' . $this -> theme [ 'bg_color' ] . '">' ;
2003-02-26 19:58:01 +01:00
$prev_week_link = '' ;
$next_week_link = '' ;
2001-07-18 19:32:10 +02:00
$print = '' ;
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nofooter' ] = True ;
2001-07-16 13:38:40 +02:00
}
$var = Array (
2003-08-28 16:31:11 +02:00
'printer_friendly' => $printer ,
2004-05-06 02:59:47 +02:00
'bg_text' => $this -> theme [ 'bg_text' ],
2003-08-28 16:31:11 +02:00
'small_calendar_prev' => $minical_prev ,
'prev_week_link' => $prev_week_link ,
'small_calendar_this' => $minical_this ,
'week_identifier' => $this -> bo -> get_week_label (),
'next_week_link' => $next_week_link ,
'username' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ),
'small_calendar_next' => $minical_next ,
'week_display' => $this -> display_weekly (
2001-08-13 06:49:19 +02:00
Array (
'date' => sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day ),
'showyear' => true ,
2002-05-05 19:47:15 +02:00
'owners' => $this -> bo -> owner
2001-08-13 06:49:19 +02:00
)
),
2003-08-28 16:31:11 +02:00
'print' => $print
2001-07-16 13:38:40 +02:00
);
2004-01-14 13:59:07 +01:00
//todo
2001-07-28 15:17:30 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
2001-08-06 04:41:36 +02:00
$p -> set_file (
Array (
'week_t' => 'week.tpl'
)
2001-07-28 15:17:30 +02:00
);
2001-07-16 13:38:40 +02:00
$p -> set_var ( $var );
2001-11-05 04:48:14 +01:00
return $p -> fp ( 'out' , 'week_t' );
2002-02-17 04:56:58 +01:00
/*
$this -> bo -> read_holidays ();
2004-01-04 01:47:37 +01:00
2002-02-17 04:56:58 +01:00
if ( ! $this -> bo -> printer_friendly || ( $this -> bo -> printer_friendly && @ $this -> bo -> prefs [ 'calendar' ][ 'display_minicals' ]))
{
$minical = $this -> mini_calendar (
Array (
'day' => $this -> bo -> day ,
'month' => $this -> bo -> month ,
'year' => $this -> bo -> year ,
'link' => 'day'
)
);
}
else
{
$minical = '' ;
}
2004-01-04 01:47:37 +01:00
2002-02-17 04:56:58 +01:00
if ( ! $this -> bo -> printer_friendly )
{
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
$printer = '' ;
$param = '&date=' . sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day ) . '&friendly=1' ;
$print = '<a href="' . $this -> page ( 'day' . $param ) . " \" TARGET= \" cal_printer_friendly \" onMouseOver= \" window.status = ' " . lang ( 'Generate printer-friendly version' ) . " ' \" >[ " . lang ( 'Printer Friendly' ) . ']</a>' ;
}
else
{
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nofooter' ] = True ;
$printer = '<body bgcolor="' . $this -> theme [ 'bg_color' ] . '">' ;
$print = '' ;
}
2002-06-25 01:24:24 +02:00
$now = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year );
2002-08-25 06:07:21 +02:00
$now [ 'raw' ] += $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2002-02-17 04:56:58 +01:00
$m = mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year );
2003-04-21 13:00:53 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2002-02-17 04:56:58 +01:00
$p -> set_file (
Array (
'day_t' => 'day.tpl'
)
);
$p -> set_block ( 'day_t' , 'day' , 'day' );
$p -> set_block ( 'day_t' , 'day_event' , 'day_event' );
$var = Array (
'printer_friendly' => $printer ,
'bg_text' => $this -> theme [ 'bg_text' ],
'daily_events' => $this -> print_day (
Array (
'year' => $this -> bo -> year ,
'month' => $this -> bo -> month ,
'day' => $this -> bo -> day
)
),
'small_calendar' => $minical ,
'date' => lang ( date ( 'F' , $m )) . ' ' . sprintf ( " %02d " , $this -> bo -> day ) . ', ' . $this -> bo -> year ,
'username' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ),
'print' => $print
);
$p -> set_var ( $var );
$p -> parse ( 'day_events' , 'day_event' );
$p -> pparse ( 'out' , 'day' );
*/
2001-07-16 13:38:40 +02:00
}
function year ()
{
2003-04-21 13:00:53 +02:00
if ( $this -> bo -> printer_friendly )
{
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nofooter' ] = True ;
}
2003-08-28 16:31:11 +02:00
echo $this -> printer_friendly ( $this -> get_year (), lang ( 'Yearview' ));
2001-11-05 04:48:14 +01:00
}
2001-11-05 19:13:30 +01:00
function get_year ()
2001-11-05 04:48:14 +01:00
{
if ( ! $this -> bo -> printer_friendly )
{
2001-07-28 15:17:30 +02:00
$print = '' ;
$left_link = '<a href="' . $this -> page ( 'year' , '&year=' . ( $this -> bo -> year - 1 )) . '"><<</a>' ;
$right_link = '<a href="' . $this -> page ( 'year' , '&year=' . ( $this -> bo -> year + 1 )) . '">>></a>' ;
2001-10-03 02:31:03 +02:00
$link = 'day' ;
2003-02-26 19:58:01 +01:00
$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>' ;
2001-07-16 13:38:40 +02:00
}
else
{
2004-03-15 00:14:41 +01:00
//NDEE: printer-friendly (year-view)
2001-08-13 16:11:07 +02:00
$print = '<body bgcolor="' . $this -> theme [ 'bg_color' ] . '">' ;
2001-07-28 15:17:30 +02:00
$left_link = '' ;
$right_link = '' ;
2001-07-16 13:38:40 +02:00
$link = '' ;
2001-07-28 15:17:30 +02:00
$printer = '' ;
2001-07-16 13:38:40 +02:00
}
2001-07-28 15:17:30 +02:00
$var = Array (
'print' => $print ,
'left_link' => $left_link ,
2001-08-13 16:11:07 +02:00
'font' => $this -> theme [ 'font' ],
2001-07-28 15:17:30 +02:00
'year_text' => $this -> bo -> year ,
'right_link' => $right_link ,
'printer_friendly' => $printer
);
2003-04-27 09:27:05 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
2001-08-06 04:41:36 +02:00
$p -> set_file (
Array (
'year_t' => 'year.tpl'
)
2001-07-28 15:17:30 +02:00
);
$p -> set_block ( 'year_t' , 'year' , 'year' );
2003-04-21 13:00:53 +02:00
$p -> set_block ( 'year_t' , 'month' , 'month_handle' );
$p -> set_block ( 'year_t' , 'month_sep' , 'month_sep_handle' );
2001-07-28 15:17:30 +02:00
$p -> set_var ( $var );
for ( $i = 1 ; $i <= 12 ; $i ++ )
2001-07-16 13:38:40 +02:00
{
2003-04-21 13:00:53 +02:00
if (( $i % 3 ) == 1 )
{
$p -> parse ( 'row' , 'month_sep' , True );
}
2001-08-13 06:49:19 +02:00
$p -> set_var ( 'mini_month' , $this -> mini_calendar (
Array (
'day' => 1 ,
'month' => $i ,
'year' => $this -> bo -> year ,
'link' => $link ,
'buttons' => 'none' ,
'outside_month' => False
)
)
);
2001-07-28 15:17:30 +02:00
$p -> parse ( 'row' , 'month' , True );
$p -> set_var ( 'mini_month' , '' );
2001-07-16 13:38:40 +02:00
}
2001-11-05 04:48:14 +01:00
return $p -> fp ( 'out' , 'year_t' );
2001-07-16 13:38:40 +02:00
}
2004-01-04 01:47:37 +01:00
2001-09-20 03:39:46 +02:00
function view ( $vcal_id = 0 , $cal_date = 0 )
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'View' );
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
$cal_id = get_var ( 'cal_id' , array ( 'GET' , 'POST' ), $vcal_id );
2004-01-04 01:47:37 +01:00
$date = $cal_date ? $cal_date : 0 ;
2004-08-22 20:44:47 +02:00
$date = $date ? $date : ( int ) $this -> bo -> date ;
2001-07-16 13:38:40 +02:00
// First, make sure they have permission to this entry
if ( $cal_id < 1 )
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'Invalid entry id.' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-07-16 13:38:40 +02:00
}
2003-08-28 16:31:11 +02:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $cal_id ))
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2003-04-21 13:00:53 +02:00
}
2003-08-28 16:31:11 +02:00
$event = $this -> bo -> read_entry ( $cal_id );
if ( ! isset ( $event [ 'id' ]))
2003-04-21 13:00:53 +02:00
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'Sorry, this event does not exist' ) . '.' . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-07-28 15:17:30 +02:00
}
2004-08-19 12:29:57 +02:00
if ( isset ( $event [ 'description' ]))
{
$event [ 'description' ] = str_replace ( array ( " \n " , " \r " ), array ( '<br/>' , '' ), $event [ 'description' ]);
}
2001-07-16 13:38:40 +02:00
2001-11-29 04:12:01 +01:00
$this -> bo -> repeating_events = Array ();
$this -> bo -> cached_events = Array ();
$this -> bo -> repeating_events [ 0 ] = $event ;
2002-08-25 06:07:21 +02:00
$datetime = mktime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-11-29 04:12:01 +01:00
$this -> bo -> check_repeating_events ( $datetime );
$check_date = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'Ymd' );
if ( is_array ( $this -> bo -> cached_events [ $check_date ][ 0 ]) &&
$this -> bo -> cached_events [ $check_date ][ 0 ][ 'id' ] == $event [ 'id' ])
{
$starttime = $this -> bo -> maketime ( $event [ 'start' ]);
$endtime = $this -> bo -> maketime ( $event [ 'end' ]);
$event [ 'start' ][ 'month' ] = $this -> bo -> month ;
$event [ 'start' ][ 'mday' ] = $this -> bo -> day ;
$event [ 'start' ][ 'year' ] = $this -> bo -> year ;
$temp_end = $this -> bo -> maketime ( $event [ 'start' ]) + ( $endtime - $starttime );
$event [ 'end' ][ 'month' ] = date ( 'm' , $temp_end );
$event [ 'end' ][ 'mday' ] = date ( 'd' , $temp_end );
$event [ 'end' ][ 'year' ] = date ( 'Y' , $temp_end );
}
2001-07-30 00:09:24 +02:00
2003-04-21 13:00:53 +02:00
if ( ! $this -> view_event ( $event , True ))
2001-11-29 04:12:01 +01:00
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-11-29 04:12:01 +01:00
}
2001-10-26 01:52:15 +02:00
2003-08-28 16:31:11 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2001-11-29 04:12:01 +01:00
$p -> set_file (
Array (
'form_button' => 'form_button_script.tpl'
)
);
2001-10-26 01:52:15 +02:00
2003-04-21 13:00:53 +02:00
$button_left = $button_center = $button_right = '' ;
2003-08-28 16:31:11 +02:00
2002-09-17 04:25:40 +02:00
if ( $this -> bo -> check_perms ( PHPGW_ACL_EDIT , $event ))
2001-11-29 04:12:01 +01:00
{
2002-09-17 04:25:40 +02:00
if ( $event [ 'recur_type' ] != MCAL_RECUR_NONE )
2001-07-30 00:09:24 +02:00
{
2002-09-17 04:25:40 +02:00
$var = Array (
'action_url_button' => $this -> page ( 'edit' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Edit Single' ),
'action_confirm_button' => '' ,
2003-09-14 14:51:31 +02:00
'action_extra_field' => $this -> html -> input_hidden ( array (
'edit_type' => 'single' ,
'date' => sprintf ( '%04d%02d%02d' , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day )
))
2002-09-17 04:25:40 +02:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_left .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2001-10-26 01:52:15 +02:00
2001-11-29 04:12:01 +01:00
$var = Array (
2002-09-17 04:25:40 +02:00
'action_url_button' => $this -> page ( 'edit' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Edit Series' ),
2001-11-29 04:12:01 +01:00
'action_confirm_button' => '' ,
2003-09-14 14:51:31 +02:00
'action_extra_field' => $this -> html -> input_hidden ( 'edit_type' , 'series' )
2002-09-17 04:25:40 +02:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_left .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2002-09-17 04:25:40 +02:00
}
else
{
$var = Array (
'action_url_button' => $this -> page ( 'edit' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Edit' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
2001-11-29 04:12:01 +01:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_left .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2001-11-29 04:12:01 +01:00
}
2002-09-17 04:25:40 +02:00
$var = Array (
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=calendar.uialarm.manager' ),
'action_text_button' => lang ( 'Alarm Management' ),
'action_confirm_button' => '' ,
2003-09-14 14:51:31 +02:00
'action_extra_field' => $this -> html -> input_hidden ( array (
'cal_id' => $cal_id ,
'return_to' => $this -> bo -> return_to
))
2002-09-17 04:25:40 +02:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_center .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2002-09-17 04:25:40 +02:00
}
if ( $this -> bo -> check_perms ( PHPGW_ACL_DELETE , $event ))
{
if ( $event [ 'recur_type' ] != MCAL_RECUR_NONE )
2001-11-29 04:12:01 +01:00
{
2002-09-17 04:25:40 +02:00
$var = Array (
'action_url_button' => $this -> page ( 'delete' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Delete Single' ),
'action_confirm_button' => " onClick= \" return confirm(' " . lang ( " Are you sure \\ nyou want to \\ ndelete this single occurence ? \\ n \\ nThis will delete \\ nthis entry for all users. " ) . " ') \" " ,
2003-09-14 14:51:31 +02:00
'action_extra_field' => $this -> html -> input_hidden ( array (
'delete_type' => 'single' ,
'date' => sprintf ( '%04d%02d%02d' , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day )
))
2002-09-17 04:25:40 +02:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_right .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2001-11-03 02:52:26 +01:00
2002-09-17 04:25:40 +02:00
$var = Array (
'action_url_button' => $this -> page ( 'delete' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Delete Series' ),
'action_confirm_button' => " onClick= \" return confirm(' " . lang ( " Are you sure \\ nyou want to \\ ndelete this entry ? \\ n \\ nThis will delete \\ nthis entry for all users. " ) . " ') \" " ,
2003-09-14 14:51:31 +02:00
'action_extra_field' => $this -> html -> input_hidden ( 'delete_type' , 'series' )
2002-09-17 04:25:40 +02:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_right .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2001-11-05 03:08:31 +01:00
2002-09-17 04:25:40 +02:00
if ( $event [ 'recur_exception' ])
2001-11-29 04:12:01 +01:00
{
$var = Array (
2002-09-17 04:25:40 +02:00
'action_url_button' => $this -> page ( 'reinstate_list' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Reinstate' ),
'action_confirm_button' => '' ,
2001-11-29 04:12:01 +01:00
'action_extra_field' => ''
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_center .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2001-11-29 04:12:01 +01:00
}
2001-07-30 00:09:24 +02:00
}
2002-09-17 04:25:40 +02:00
else
{
$var = Array (
'action_url_button' => $this -> page ( 'delete' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Delete' ),
'action_confirm_button' => " onClick= \" return confirm(' " . lang ( " Are you sure \\ nyou want to \\ ndelete this entry ? \\ n \\ nThis will delete \\ nthis entry for all users. " ) . " ') \" " ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_right .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2002-09-17 04:25:40 +02:00
}
2001-07-16 13:38:40 +02:00
}
2003-08-28 16:31:11 +02:00
else
{
// allow me (who I am logged in as) to set up an alarm
// if I am a participant, but not the owner
reset ( $event [ 'participants' ]);
while ( list ( $user , $short_status ) = each ( $event [ 'participants' ]))
{
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ] == $user )
{
$var = Array (
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=calendar.uialarm.manager' ),
'action_text_button' => lang ( 'Alarm Management' ),
'action_confirm_button' => '' ,
2003-09-14 14:51:31 +02:00
'action_extra_field' => $this -> html -> input_hidden ( array (
'cal_id' => $cal_id ,
'return_to' => $this -> bo -> return_to
))
2003-08-28 16:31:11 +02:00
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
}
}
}
2001-11-29 04:12:01 +01:00
2004-07-11 19:01:23 +02:00
$export_params [ 'cal_id' ] = $cal_id ;
2001-11-29 04:12:01 +01:00
$var = Array (
2001-12-10 04:58:44 +01:00
'action_url_button' => $this -> page ( 'export' ),
2001-11-29 04:12:01 +01:00
'action_text_button' => lang ( 'Export' ),
'action_confirm_button' => '' ,
2004-07-11 19:01:23 +02:00
'action_extra_field' => $this -> html -> input_hidden ( $export_params )
2001-11-29 04:12:01 +01:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_center .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
2002-11-23 15:19:56 +01:00
if ( $this -> bo -> return_to )
{
$var = Array (
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ),
'action_text_button' => lang ( 'Done' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_left .= '<td>' . $p -> fp ( 'button' , 'form_button' ) . '</td>' ;
}
$p -> set_var ( array (
'button_left' => $button_left ,
'button_center' => $button_center ,
'button_right' => $button_right
));
2003-08-28 16:31:11 +02:00
$p -> pfp ( 'phpgw_body' , 'view_event' );
2004-01-04 01:47:37 +01:00
2003-04-30 02:06:08 +02:00
$GLOBALS [ 'phpgw' ] -> hooks -> process ( array (
'location' => 'calendar_view' ,
'cal_id' => $cal_id
));
2001-07-16 13:38:40 +02:00
}
2001-08-12 16:47:23 +02:00
function edit ( $params = '' )
2001-07-16 13:38:40 +02:00
{
2001-11-08 01:18:42 +01:00
if ( $this -> debug )
{
echo '<!-- params[readsess] = ' . $params [ 'readsess' ] . ' -->' . " \n " ;
echo '<!-- params[cd] = ' . $params [ 'cd' ] . ' -->' . " \n " ;
}
2001-08-12 16:47:23 +02:00
2003-08-28 16:31:11 +02:00
if ( isset ( $_GET [ 'readsess' ]))
2001-09-28 04:06:35 +02:00
{
2003-08-28 16:31:11 +02:00
$params [ 'readsess' ] = $_GET [ 'readsess' ];
2001-09-28 04:06:35 +02:00
$params [ 'cd' ] = 0 ;
}
2001-11-08 01:18:42 +01:00
if ( $this -> debug )
{
echo '<!-- params[readsess] = ' . $params [ 'readsess' ] . ' -->' . " \n " ;
echo '<!-- params[cd] = ' . $params [ 'cd' ] . ' -->' . " \n " ;
}
if ( $params != '' && @ is_array ( $params ) && @ isset ( $params [ 'readsess' ]))
2001-07-16 13:38:40 +02:00
{
2001-07-28 15:17:30 +02:00
$can_edit = True ;
2001-08-12 16:47:23 +02:00
$this -> edit_form (
Array (
2001-11-08 01:18:42 +01:00
'event' => $this -> bo -> restore_from_appsession (),
2001-08-12 16:47:23 +02:00
'cd' => $params [ 'cd' ]
)
);
2001-07-16 13:38:40 +02:00
}
2003-08-28 16:31:11 +02:00
elseif ( isset ( $_GET [ 'cal_id' ]))
2001-07-16 13:38:40 +02:00
{
2004-01-04 01:47:37 +01:00
$cal_id = ( int ) $_GET [ 'cal_id' ];
2002-11-23 15:19:56 +01:00
$event = $this -> bo -> read_entry ( $cal_id );
2002-08-25 06:07:21 +02:00
2002-11-23 15:19:56 +01:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT , $event ))
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
Header ( 'Location: ' . $this -> page ( 'view' , '&cal_id=' . $cal_id ));
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-08-27 03:30:40 +02:00
}
2003-08-28 16:31:11 +02:00
if ( @ isset ( $_POST [ 'edit_type' ]) && $_POST [ 'edit_type' ] == 'single' )
2001-08-27 03:30:40 +02:00
{
$event [ 'id' ] = 0 ;
2003-08-28 16:31:11 +02:00
$this -> bo -> set_recur_date ( $event , $_POST [ 'date' ]);
2001-08-27 03:30:40 +02:00
$event [ 'recur_type' ] = MCAL_RECUR_NONE ;
$event [ 'recur_interval' ] = 0 ;
$event [ 'recur_data' ] = 0 ;
$event [ 'recur_enddate' ][ 'month' ] = 0 ;
$event [ 'recur_enddate' ][ 'mday' ] = 0 ;
$event [ 'recur_enddate' ][ 'year' ] = 0 ;
2003-04-21 18:43:51 +02:00
$event [ 'recur_exception' ] = array ();
2001-07-16 13:38:40 +02:00
}
2001-08-12 16:47:23 +02:00
$this -> edit_form (
Array (
'event' => $event ,
'cd' => $cd
)
);
2001-07-16 13:38:40 +02:00
}
2001-08-12 16:47:23 +02:00
}
2001-07-28 15:17:30 +02:00
2004-07-11 19:01:23 +02:00
function export ()
2001-08-29 21:18:32 +02:00
{
2004-07-11 19:01:23 +02:00
$jscal = CreateObject ( 'phpgwapi.jscalendar' );
$GLOBALS [ 'phpgw' ] -> browser = CreateObject ( 'phpgwapi.browser' );
2001-12-10 04:58:44 +01:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
2004-07-11 20:26:28 +02:00
if ( ! isset ( $_REQUEST [ 'output_file' ]) || ! $_REQUEST [ 'output_file' ])
2001-12-10 04:58:44 +01:00
{
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
2003-04-21 13:00:53 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Export' );
2001-12-10 04:58:44 +01:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2004-01-04 01:47:37 +01:00
2003-04-21 13:00:53 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2001-12-10 04:58:44 +01:00
$p -> set_file (
Array (
'form_button' => 'form_button_script.tpl'
)
);
2004-07-11 19:01:23 +02:00
$extra_field_text = '' ;
$extra_field_text = " \n " . lang ( 'Enter Output Filename: ( .vcs appended )' ) . " \n " . ' <input name="output_file" size="25" maxlength="80" value="">' . " \n " ;
2004-07-11 20:26:28 +02:00
if ( isset ( $_POST [ 'output_file' ]))
{
$extra_field_text .= '<font color="red">' . lang ( 'please enter a filename !!!' ) . " </font> \n " ;
}
2004-07-11 19:01:23 +02:00
if ( isset ( $_POST [ 'cal_id' ]))
2004-08-22 20:44:47 +02:00
$extra_field_text .= ' ' . $this -> html -> input_hidden ( 'cal_id' ,( int ) $_POST [ 'cal_id' ]);
2004-07-11 19:01:23 +02:00
if ( ! isset ( $_POST [ 'cal_id' ]) || ! $_POST [ 'cal_id' ])
{
$start_date = '' ;
if ( isset ( $_POST [ 'custom_start' ]) && $_POST [ 'custom_start' ])
$start_date = $_POST [ 'custom_start' ];
else
$start_date = $GLOBALS [ 'phpgw' ] -> datetime -> gmtnow ;
$stop_date = '' ;
if ( isset ( $_POST [ 'custom_stop' ]) && $_POST [ 'custom_stop' ])
$stop_date = $_POST [ 'custom_stop' ];
else
$stop_date = $GLOBALS [ 'phpgw' ] -> datetime -> gmtnow ;
$extra_field_text .= " <p> " ;
$extra_field_text .= lang ( 'Start Date' );
$extra_field_text .= " " ;
$extra_field_text .= $jscal -> input ( 'custom_start' , $start_date );
$extra_field_text .= " </p> \n <p> " ;
$extra_field_text .= lang ( 'End Date' );
$extra_field_text .= "   \n " ;
$extra_field_text .= $jscal -> input ( 'custom_stop' , $stop_date );
$extra_field_text .= " </p> \n " ;
}
2001-12-10 04:58:44 +01:00
$var = Array (
'action_url_button' => $this -> page ( 'export' ),
2004-07-11 19:01:23 +02:00
'action_text_button' => lang ( 'Download' ),
2001-12-10 04:58:44 +01:00
'action_confirm_button' => '' ,
2004-07-11 19:01:23 +02:00
'action_extra_field' => $extra_field_text
2001-12-10 04:58:44 +01:00
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
}
else
{
2004-07-11 19:01:23 +02:00
unset ( $cal_ids );
$cal_ids = Array ();
2004-07-11 20:26:28 +02:00
$output_filename = $_REQUEST [ 'output_file' ];
2004-07-11 19:01:23 +02:00
if ( ! preg_match ( '/\.vcs$/i' , $output_filename ))
2002-04-16 18:52:36 +02:00
{
2004-07-11 19:01:23 +02:00
$output_filename .= '.vcs' ;
2002-04-16 18:52:36 +02:00
}
2004-07-11 20:26:28 +02:00
if ( isset ( $_REQUEST [ 'custom_start' ]) && $_REQUEST [ 'custom_start' ])
2004-07-11 19:01:23 +02:00
{
2004-07-11 20:26:28 +02:00
$start_date = $jscal -> input2date ( $_REQUEST [ 'custom_start' ], False );
2004-07-11 19:01:23 +02:00
2004-07-11 20:26:28 +02:00
if ( isset ( $_REQUEST [ 'custom_stop' ]) && $_REQUEST [ 'custom_stop' ])
2004-07-11 19:01:23 +02:00
{
2004-07-11 20:26:28 +02:00
$stop_date = $jscal -> input2date ( $_REQUEST [ 'custom_stop' ], False );
2004-07-11 19:01:23 +02:00
}
else
{
$stop_date = array ( 'year' => 0 , 'month' => '0' , 'day' => 0 );
}
$cal_ids = $this -> bo -> so -> list_events ( $start_date [ 'year' ], $start_date [ 'month' ], $start_date [ 'day' ],
$stop_date [ 'year' ], $stop_date [ 'month' ], $stop_date [ 'day' ]);
}
elseif ( isset ( $_POST [ 'cal_id' ]) && $_POST [ 'cal_id' ])
2002-11-23 15:19:56 +01:00
{
2004-07-11 19:01:23 +02:00
$cal_ids [ 0 ] = $_POST [ 'cal_id' ];
2002-11-23 15:19:56 +01:00
}
2004-07-11 19:01:23 +02:00
$content = " BEGIN:VCALENDAR \n " ;
foreach ( $cal_ids as $cal_id )
2002-11-23 15:19:56 +01:00
{
2004-07-11 19:01:23 +02:00
$mycontent = ExecMethod ( 'calendar.boicalendar.export' , Array (
'l_event_id' => $cal_id ,
'chunk_split' => False ,
));
$content .= str_replace ( array ( " \r " , " METHOD:PUBLISH \n " , " BEGIN:VCALENDAR \n " , " END:VCALENDAR \n " ), " " , $mycontent );
2002-11-23 15:19:56 +01:00
}
2004-07-11 19:01:23 +02:00
$content .= " END:VCALENDAR \n " ;
$GLOBALS [ 'phpgw' ] -> browser -> content_header ( $output_filename , 'text/calendar' , strlen ( $content ));
echo $content ;
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-12-10 04:58:44 +01:00
}
2001-10-03 02:31:03 +02:00
}
2001-08-29 21:18:32 +02:00
2001-11-05 03:08:31 +01:00
function reinstate_list ( $params = '' )
{
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
{
2004-01-04 01:47:37 +01:00
$this -> no_edit ();
2001-11-05 03:08:31 +01:00
}
elseif ( ! $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
$this -> index ();
}
2003-04-21 13:00:53 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Reinstate' );
2001-11-05 03:08:31 +01:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2003-04-21 13:00:53 +02:00
$cal_id = get_var ( 'cal_id' , array ( 'GET' ), $params [ 'cal_id' ]);
2001-11-05 03:08:31 +01:00
if ( $cal_id < 1 )
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'Invalid entry id.' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-11-05 03:08:31 +01:00
}
2003-08-28 16:31:11 +02:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_READ ))
2001-11-05 03:08:31 +01:00
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-11-05 03:08:31 +01:00
}
$event = $this -> bo -> read_entry ( $cal_id );
if ( ! isset ( $event [ 'id' ]))
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'Sorry, this event does not exist' ) . '.' . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-11-05 03:08:31 +01:00
}
elseif ( ! isset ( $event [ 'recur_exception' ]))
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'Sorry, this event does not have exceptions defined' ) . '.' . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-11-05 03:08:31 +01:00
}
2003-04-21 13:00:53 +02:00
if ( ! $this -> view_event ( $event , True ))
2001-11-05 03:08:31 +01:00
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-11-05 03:08:31 +01:00
}
2003-04-21 13:00:53 +02:00
$p = & $GLOBALS [ 'phpgw' ] -> template ;
2001-11-05 03:08:31 +01:00
$p -> set_file (
Array (
'form_button' => 'form_button_script.tpl'
)
);
$str = '' ;
for ( $i = 0 ; $i < count ( $event [ 'recur_exception' ]); $i ++ )
{
$str .= ' <option value="' . $i . '">' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $event [ 'recur_exception' ][ $i ]) . '</option>' . " \n " ;
}
2003-04-21 13:00:53 +02:00
$this -> output_template_array ( $p , 'row' , 'list' , array (
2003-04-21 18:43:51 +02:00
'field' => lang ( 'Exceptions' ),
2003-04-21 13:00:53 +02:00
'data' => '<select name="reinstate_index[]" multiple size="5">' . " \n " . $str . '</select>'
));
2001-11-05 03:08:31 +01:00
$var = Array (
'action_url_button' => $this -> page ( 'reinstate' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Reinstate' ),
'action_confirm_button' => '' ,
2003-04-21 13:00:53 +02:00
'action_extra_field' => ''
2001-11-05 03:08:31 +01:00
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_left = '<td>' . $p -> fp ( 'out' , 'form_button' ) . '</td>' ;
2001-11-05 03:08:31 +01:00
$var = Array (
2002-11-23 15:19:56 +01:00
'action_url_button' => $this -> bo -> return_to ? $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ) : $this -> page ( '' ),
2001-11-05 03:08:31 +01:00
'action_text_button' => lang ( 'Cancel' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$button_left .= '<td>' . $p -> fp ( 'out' , 'form_button' ) . '</td>' ;
2004-01-04 01:47:37 +01:00
2003-04-21 13:00:53 +02:00
$p -> set_var ( 'button_left' , $button_left );
$p -> pfp ( 'phpgw_body' , 'view_event' );
2001-11-05 03:08:31 +01:00
}
function reinstate ( $params = '' )
{
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
{
2004-01-04 01:47:37 +01:00
$this -> no_edit ();
2001-11-05 03:08:31 +01:00
}
elseif ( ! $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
$this -> index ();
}
2004-01-04 01:47:37 +01:00
$cal_id = ( isset ( $params [ 'cal_id' ]) ? ( int ) $params [ 'cal_id' ] : '' );
$cal_id = ( $cal_id == '' ? ( int ) $_GET [ 'cal_id' ] : $cal_id );
2001-11-05 03:08:31 +01:00
2004-01-04 01:47:37 +01:00
$reinstate_index = ( isset ( $params [ 'reinstate_index' ]) ? ( int ) $params [ 'reinstate_index' ] : '' );
$reinstate_index = ( $reinstate_index == '' ? ( int ) $_POST [ 'reinstate_index' ] : $reinstate_index );
2001-11-05 03:08:31 +01:00
if ( $this -> debug )
{
echo '<!-- Calling bo->reinstate -->' . " \n " ;
}
$cd = $this -> bo -> reinstate (
Array (
'cal_id' => $cal_id ,
'reinstate_index' => $reinstate_index
)
);
if ( $this -> debug )
{
echo '<!-- Return Value = ' . $cd . ' -->' . " \n " ;
}
2002-11-23 15:19:56 +01:00
if ( $this -> bo -> return_to )
{
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ));
2004-01-04 01:47:37 +01:00
}
2002-11-23 15:19:56 +01:00
else
{
Header ( 'Location: ' . $this -> page ( '' ,( $cd ? '&cd=' . $cd : '' )));
}
2004-01-04 01:47:37 +01:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-11-05 03:08:31 +01:00
}
2001-08-06 04:41:36 +02:00
function add ( $cd = 0 , $readsess = 0 )
2001-07-28 15:17:30 +02:00
{
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
$this -> index ();
}
2004-01-04 01:47:37 +01:00
2001-08-06 04:41:36 +02:00
if ( $readsess )
2001-07-16 13:38:40 +02:00
{
2001-07-18 19:32:10 +02:00
$event = $this -> bo -> restore_from_appsession ;
2001-07-30 00:09:24 +02:00
if ( ! $event [ 'owner' ])
2001-07-16 13:38:40 +02:00
{
2001-07-18 19:32:10 +02:00
$this -> bo -> add_attribute ( 'owner' , $this -> bo -> owner );
2001-07-16 13:38:40 +02:00
}
$can_edit = True ;
}
else
{
2001-07-18 19:32:10 +02:00
$this -> bo -> event_init ();
$this -> bo -> add_attribute ( 'id' , 0 );
2001-07-16 13:38:40 +02:00
$can_edit = True ;
2004-03-13 19:35:16 +01:00
$participants = ( string )( get_var ( 'participants' , array ( 'GET' ), FALSE ));
2004-01-04 01:47:37 +01:00
$starthour = ( int )( get_var ( 'hour' , array ( 'GET' ), $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ]));
$startmin = ( int )( get_var ( 'minute' , array ( 'GET' ), 0 ));
$endmin = $startmin + ( int ) $this -> bo -> prefs [ 'calendar' ][ 'defaultlength' ];
2003-08-28 16:31:11 +02:00
$endhour = $starthour + $this -> bo -> normalizeminutes ( $endmin );
;
$this -> bo -> set_start ( $this -> bo -> year , $this -> bo -> month , $this -> bo -> day , $starthour , $startmin , 0 );
$this -> bo -> set_end ( $this -> bo -> year , $this -> bo -> month , $this -> bo -> day , $endhour , $endmin , 0 );
2001-07-18 19:32:10 +02:00
$this -> bo -> set_title ( '' );
$this -> bo -> set_description ( '' );
2001-09-07 18:37:11 +02:00
$this -> bo -> add_attribute ( 'location' , '' );
$this -> bo -> add_attribute ( 'uid' , '' );
2001-07-18 19:32:10 +02:00
$this -> bo -> add_attribute ( 'priority' , 2 );
2001-07-28 15:17:30 +02:00
if ( @ $this -> bo -> prefs [ 'calendar' ][ 'default_private' ])
2001-07-16 13:38:40 +02:00
{
2001-07-18 19:32:10 +02:00
$this -> bo -> set_class ( False );
2001-07-16 13:38:40 +02:00
}
else
{
2001-07-18 19:32:10 +02:00
$this -> bo -> set_class ( True );
2001-07-16 13:38:40 +02:00
}
2004-07-12 00:07:24 +02:00
// Add participants from matrixview
2004-08-07 16:22:58 +02:00
foreach ( explode ( ';' , $GLOBALS [ 'phpgw' ] -> session -> appsession ( " participants " )) as $part )
2004-03-10 18:08:46 +01:00
{
2004-08-07 16:22:58 +02:00
if ( $part ) $this -> bo -> add_attribute ( 'participants' , 'U' , $part );
2004-03-10 18:08:46 +01:00
}
// Add misc
2001-07-30 00:09:24 +02:00
$this -> bo -> add_attribute ( 'participants' , 'A' , $this -> bo -> owner );
2001-07-18 19:32:10 +02:00
$this -> bo -> set_recur_none ();
$event = $this -> bo -> get_cached_event ();
2001-07-16 13:38:40 +02:00
}
2001-10-03 02:31:03 +02:00
$this -> edit_form (
Array (
'event' => $event ,
'cd' => $cd
)
);
2001-07-28 15:17:30 +02:00
}
2001-07-16 13:38:40 +02:00
2001-07-28 15:17:30 +02:00
function delete ()
{
2003-08-28 16:31:11 +02:00
if ( ! isset ( $_GET [ 'cal_id' ]))
2001-08-12 16:47:23 +02:00
{
2001-08-13 23:12:16 +02:00
Header ( 'Location: ' . $this -> page ( '' , '&date=' . sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day )));
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-08-12 16:47:23 +02:00
}
2001-11-05 03:08:31 +01:00
$date = sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day );
2004-01-04 01:47:37 +01:00
if ( $this -> bo -> check_perms ( PHPGW_ACL_DELETE , $cal_id = ( int ) $_GET [ 'cal_id' ]))
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
if ( isset ( $_POST [ 'delete_type' ]) && $_POST [ 'delete_type' ] == 'single' )
2001-11-03 02:52:26 +01:00
{
2003-08-28 16:31:11 +02:00
$date = $_POST [ 'date' ];
2001-11-05 03:08:31 +01:00
$cd = $this -> bo -> delete_single (
Array (
2003-08-28 16:31:11 +02:00
'id' => $cal_id ,
2003-02-26 17:42:04 +01:00
'year' => substr ( $date , 0 , 4 ),
'month' => substr ( $date , 4 , 2 ),
'day' => substr ( $date , 6 , 2 )
2001-11-05 03:08:31 +01:00
)
);
2001-11-03 02:52:26 +01:00
}
2003-08-28 16:31:11 +02:00
elseif (( isset ( $_POST [ 'delete_type' ]) && $_POST [ 'delete_type' ] == 'series' ) || ! isset ( $_POST [ 'delete_type' ]))
2001-11-03 02:52:26 +01:00
{
2003-08-28 16:31:11 +02:00
$cd = $this -> bo -> delete_entry ( $cal_id );
2001-11-05 03:08:31 +01:00
$this -> bo -> expunge ();
2001-11-03 02:52:26 +01:00
}
2001-07-16 13:38:40 +02:00
}
else
{
2001-07-28 15:17:30 +02:00
$cd = '' ;
2001-07-16 13:38:40 +02:00
}
2002-11-23 15:19:56 +01:00
if ( $this -> bo -> return_to )
{
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ));
}
else
{
Header ( 'Location: ' . $this -> page ( '' , '&date=' . $date . ( $cd ? '&cd=' . $cd : '' )));
}
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-07-28 15:17:30 +02:00
}
function day ()
{
$this -> bo -> read_holidays ();
2003-09-07 20:33:52 +02:00
2001-11-05 03:08:31 +01:00
if ( ! $this -> bo -> printer_friendly || ( $this -> bo -> printer_friendly && @ $this -> bo -> prefs [ 'calendar' ][ 'display_minicals' ]))
2001-08-13 06:49:19 +02:00
{
$minical = $this -> mini_calendar (
Array (
'day' => $this -> bo -> day ,
'month' => $this -> bo -> month ,
'year' => $this -> bo -> year ,
'link' => 'day'
)
);
}
else
{
2004-03-15 00:14:41 +01:00
//NDEE: printer-friendly (what?)
2001-08-13 06:49:19 +02:00
$minical = '' ;
}
2004-01-04 01:47:37 +01:00
2001-07-28 15:17:30 +02:00
if ( ! $this -> bo -> printer_friendly )
2001-07-16 13:38:40 +02:00
{
2001-07-28 15:17:30 +02:00
$printer = '' ;
2001-08-12 16:47:23 +02:00
$param = '&date=' . sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day ) . '&friendly=1' ;
2001-07-28 15:17:30 +02:00
$print = '<a href="' . $this -> page ( 'day' . $param ) . " \" TARGET= \" cal_printer_friendly \" onMouseOver= \" window.status = ' " . lang ( 'Generate printer-friendly version' ) . " ' \" >[ " . lang ( 'Printer Friendly' ) . ']</a>' ;
2001-07-16 13:38:40 +02:00
}
else
{
2004-03-15 00:14:41 +01:00
//NDEE: printer-friendly (daily-view)
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nofooter' ] = True ;
2001-08-13 16:11:07 +02:00
$printer = '<body bgcolor="' . $this -> theme [ 'bg_color' ] . '">' ;
2001-07-28 15:17:30 +02:00
$print = '' ;
2001-07-16 13:38:40 +02:00
}
2002-06-25 01:24:24 +02:00
$now = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year );
2002-08-25 06:07:21 +02:00
$now [ 'raw' ] += $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-28 15:17:30 +02:00
2003-04-21 13:00:53 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2001-07-28 15:17:30 +02:00
$p -> set_file (
2001-10-03 02:31:03 +02:00
Array (
'day_t' => 'day.tpl'
)
);
2001-11-05 03:08:31 +01:00
$p -> set_block ( 'day_t' , 'day' , 'day' );
$p -> set_block ( 'day_t' , 'day_event' , 'day_event' );
2001-07-16 13:38:40 +02:00
2003-09-07 18:55:36 +02:00
$todos = $this -> get_todos ( $todo_label );
2001-07-28 15:17:30 +02:00
$var = Array (
2003-08-28 16:31:11 +02:00
'printer_friendly' => $printer ,
2001-11-05 04:48:14 +01:00
'bg_text' => $this -> theme [ 'bg_text' ],
2003-08-28 16:31:11 +02:00
'daily_events' => $this -> print_day (
2001-10-03 02:31:03 +02:00
Array (
'year' => $this -> bo -> year ,
'month' => $this -> bo -> month ,
'day' => $this -> bo -> day
)
),
2003-08-28 16:31:11 +02:00
'small_calendar' => $minical ,
2002-11-23 15:19:56 +01:00
'date' => $this -> bo -> long_date ( $now ),
2001-10-23 12:58:53 +02:00
'username' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ),
2003-09-07 18:55:36 +02:00
'print' => $print ,
'lang_todos' => $todo_label ,
'todos' => $this -> bo -> printer_friendly ? $todos :
2004-03-15 00:14:41 +01:00
//NDEE: todo's layout
2003-09-08 02:23:09 +02:00
" <div style= \" overflow: auto; max-height: 200px \" > \n $todos </div> \n "
2001-07-16 13:38:40 +02:00
);
2001-07-28 15:17:30 +02:00
$p -> set_var ( $var );
2001-11-05 03:08:31 +01:00
$p -> parse ( 'day_events' , 'day_event' );
2003-08-28 16:31:11 +02:00
echo $this -> printer_friendly ( $p -> fp ( 'out' , 'day' ), lang ( 'Dayview' ));
2001-07-28 15:17:30 +02:00
}
2001-07-16 13:38:40 +02:00
2003-09-07 18:55:36 +02:00
function get_todos ( & $todo_label )
{
$todos_from_hook = $GLOBALS [ 'phpgw' ] -> hooks -> process ( array (
'location' => 'calendar_include_todos' ,
'year' => $this -> bo -> year ,
'month' => $this -> bo -> month ,
'day' => $this -> bo -> day ,
'owner' => $this -> bo -> owner // num. id of the user, not necessary current user
));
2003-11-20 07:15:03 +01:00
if ( is_array ( $todo_label ))
{
list ( $label , $showall ) = $todo_label ;
2004-01-04 01:47:37 +01:00
}
2003-11-20 07:15:03 +01:00
else
{
$label = $todo_label ;
$showall = true ;
}
2004-01-04 01:47:37 +01:00
$maxshow = ( int ) $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'infolog' ][ 'mainscreen_maxshow' ];
2003-11-20 07:15:03 +01:00
if ( $maxshow <= 0 )
{
$maxshow = 10 ;
2004-01-04 01:47:37 +01:00
}
2003-11-20 07:15:03 +01:00
//print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow");
2003-09-07 18:55:36 +02:00
$content = $todo_label = '' ;
2003-09-08 02:23:09 +02:00
if ( is_array ( $todos_from_hook ) && count ( $todos_from_hook ))
2003-09-07 18:55:36 +02:00
{
2003-11-20 07:15:03 +01:00
$todo_label = ! empty ( $label ) ? $label : lang ( " open ToDo's: " );
2004-01-04 01:47:37 +01:00
2003-09-07 18:55:36 +02:00
foreach ( $todos_from_hook as $todos )
{
2003-11-20 07:15:03 +01:00
$i = 0 ;
2003-09-07 18:55:36 +02:00
if ( is_array ( $todos ) && count ( $todos ))
{
foreach ( $todos as $todo )
{
2004-08-01 18:45:04 +02:00
if ( ! $showall && ( $i ++>= $maxshow ))
2004-01-04 01:47:37 +01:00
{
2003-11-20 07:15:03 +01:00
break ;
}
2003-09-07 18:55:36 +02:00
$icons = '' ;
foreach ( $todo [ 'icons' ] as $name => $app )
{
$icons .= ( $icons ? ' ' : '' ) . $GLOBALS [ 'phpgw' ] -> html -> image ( $app , $name , lang ( $name ), 'border="0" width="15" height="15"' );
}
2003-09-08 01:42:22 +02:00
$class = $class == 'row_on' ? 'row_off' : 'row_on' ;
2004-03-15 00:14:41 +01:00
//NDEE <tr starts here
$content .= " <tr id= \" debug \" class= \" $class\ " > \n < td valign = \ " top \" width= \" 15% \" nowrap> " .
2003-09-07 18:55:36 +02:00
( $this -> bo -> printer_friendly ? $icons : $GLOBALS [ 'phpgw' ] -> html -> a_href ( $icons , $todo [ 'view' ])) .
" </td> \n <td> " . ( $this -> bo -> printer_friendly ? $todo [ 'title' ] :
$GLOBALS [ 'phpgw' ] -> html -> a_href ( $todo [ 'title' ], $todo [ 'view' ])) . " </td> \n </tr> \n " ;
}
}
}
}
if ( ! empty ( $content ))
{
2003-09-14 14:51:31 +02:00
return " <table border= \" 0 \" width= \" 100% \" > \n $content </table> \n " ;
2003-09-07 18:55:36 +02:00
}
return False ;
}
2001-07-28 15:17:30 +02:00
function edit_status ()
{
2001-08-12 16:47:23 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
2003-04-21 13:00:53 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Change Status' );
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
$event = $this -> bo -> read_entry ( $_GET [ 'cal_id' ]);
2001-07-16 13:38:40 +02:00
2001-07-30 00:09:24 +02:00
reset ( $event [ 'participants' ]);
2001-07-28 15:17:30 +02:00
2001-08-20 02:10:16 +02:00
if ( ! $event [ 'participants' ][ $this -> bo -> owner ])
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
echo '<center>' . lang ( 'The user %1 is not participating in this event!' , $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner )) . '</center>' ;
return ;
2001-07-16 13:38:40 +02:00
}
2001-07-28 15:17:30 +02:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
2001-07-16 13:38:40 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> no_edit ();
return ;
2001-07-16 13:38:40 +02:00
}
2001-07-28 15:17:30 +02:00
2002-08-25 06:07:21 +02:00
$freetime = $GLOBALS [ 'phpgw' ] -> datetime -> localdates ( mktime ( 0 , 0 , 0 , $event [ 'start' ][ 'month' ], $event [ 'start' ][ 'mday' ], $event [ 'start' ][ 'year' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset );
2001-08-12 16:47:23 +02:00
echo $this -> timematrix (
Array (
'date' => $freetime ,
'starttime' => $this -> bo -> splittime ( '000000' , False ),
'endtime' => 0 ,
'participants' => $event [ 'participants' ]
)
2003-04-21 13:00:53 +02:00
) . '<br>' ;
2001-07-28 15:17:30 +02:00
2003-08-28 16:31:11 +02:00
$event = $this -> bo -> read_entry ( $_GET [ 'cal_id' ]);
2003-04-21 13:00:53 +02:00
$this -> view_event ( $event );
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> template -> pfp ( 'phpgw_body' , 'view_event' );
2001-07-28 15:17:30 +02:00
2001-07-30 00:09:24 +02:00
echo $this -> get_response ( $event [ 'id' ]);
2001-07-28 15:17:30 +02:00
}
function set_action ()
{
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
2001-07-16 13:38:40 +02:00
{
2001-10-03 02:31:03 +02:00
$this -> no_edit ();
2001-07-28 15:17:30 +02:00
return ;
2001-07-16 13:38:40 +02:00
}
2001-07-28 15:17:30 +02:00
2004-01-04 01:47:37 +01:00
$this -> bo -> set_status (( int ) $_GET [ 'cal_id' ],( int ) $_GET [ 'action' ]);
2001-07-28 15:17:30 +02:00
2002-11-23 15:19:56 +01:00
if ( $this -> bo -> return_to )
{
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ));
}
else
{
2004-01-04 01:47:37 +01:00
Header ( 'Location: ' . $this -> page ( '' , '' ));
2002-11-23 15:19:56 +01:00
}
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-07-16 13:38:40 +02:00
}
2003-08-28 16:31:11 +02:00
2001-07-28 15:17:30 +02:00
function planner ()
2001-07-18 19:32:10 +02:00
{
2002-11-23 15:19:56 +01:00
if ( floor ( phpversion ()) < 4 )
{
return ;
}
2003-08-28 16:31:11 +02:00
$home = strstr ( $_SERVER [ 'PHP_SELF' ], 'home' ) !== False ;
2002-11-23 15:19:56 +01:00
// generate header and set global/member variables
//
$this -> planner_prepare ( $home );
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// process events within selected interval
//
$this -> planner_process_interval ();
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// generate the planner view
//
if ( ! $home )
{
echo '<p>' . $this -> planner_print_rows ();
}
else
{
return $this -> planner_print_rows ();
}
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
function set_planner_group_members ()
{
$type = $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $this -> bo -> owner );
if ( $type == 'g' ) // display schedule of all group members
{
$members = array ();
$ids = $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( $this -> bo -> owner , 1 , 'phpgw_group' );
while ( list (, $id ) = each ( $ids ))
{
if ( $this -> bo -> check_perms ( PHPGW_ACL_READ , 0 , $id ))
{
$members [ $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $id )] = $id ;
}
}
ksort ( $members );
$this -> planner_group_members = $members ;
}
else
{
2004-01-04 01:47:37 +01:00
$this -> planner_group_members = array (
2002-11-23 15:19:56 +01:00
$GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ) => $this -> bo -> owner
);
2002-09-17 04:25:40 +02:00
}
}
/**
* planner_prepare - prepare the planner view
*
2002-11-23 15:19:56 +01:00
* - sets global environment variables
2002-09-17 04:25:40 +02:00
* - initializes class member variables used in multiple planner related functions
* - generates header lines for the planner view ( month , calendar week , days )
*/
2002-11-23 15:19:56 +01:00
function planner_prepare ( $no_header = False )
2002-09-17 04:25:40 +02:00
{
2002-11-23 15:19:56 +01:00
// set some globals
//
if ( ! $no_header )
{
2003-08-28 16:31:11 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
if ( $this -> always_app_header ) $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Group Planner' );
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2002-11-23 15:19:56 +01:00
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// intervals_per_day can be configured in preferences now :-)
//
if ( ! $this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ])
{
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'planner_intervals_per_day' , 3 );
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
$this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ] = 3 ;
}
$intervals_per_day = $this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ];
$this -> bo -> save_sessiondata (); // need to save $this->bo->save_owner
2001-09-07 18:37:11 +02:00
2002-11-23 15:19:56 +01:00
// set title for table and rows of planner view
//
if ( $this -> bo -> sortby == 'category' )
{
$title = lang ( 'Category' );
}
else
{
$title = lang ( 'User' );
2001-09-07 18:37:11 +02:00
2002-11-23 15:19:56 +01:00
$this -> set_planner_group_members ();
}
2001-07-18 19:32:10 +02:00
2002-11-23 15:19:56 +01:00
// create/initialize variables directly used for HTML code generation
//
$this -> planner_header = array ();
$this -> planner_rows = array ();
2001-07-18 19:32:10 +02:00
2002-11-23 15:19:56 +01:00
// generate header lines with days and associated months
//
$hdr = & $this -> planner_header ;
$hdr [ 0 ][ '0' ] = $title ;
$hdr [ 0 ][ '.0' ] = 'rowspan="3"' ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
$this -> planner_days = 0 ; // reset
2001-07-28 15:17:30 +02:00
2002-11-23 15:19:56 +01:00
$m = $this -> bo -> month ;
$y = $this -> bo -> year ;
$this -> bo -> read_holidays ( $y );
for ( $i = 1 ; $i <= $this -> bo -> num_months ; $i ++ , $m ++ )
{
if ( $m == 13 )
{
$m = 1 ; $y ++ ; // "wrap-around" into new year
$this -> bo -> read_holidays ( $y );
}
$days = $GLOBALS [ 'phpgw' ] -> datetime -> days_in_month ( $m , $y );
$d = mktime ( 0 , 0 , 0 , $m , 1 , $y );
$month = lang ( date ( 'F' , $d )) . strftime ( ' %Y' , $d );
2003-08-28 16:31:11 +02:00
$color = $this -> theme [ $m % 2 || $this -> bo -> num_months == 1 ? 'th_bg' : 'row_on' ];
2002-11-23 15:19:56 +01:00
$cols = $days * $intervals_per_day ;
2003-08-28 16:31:11 +02:00
$hdr [ 0 ][ '.' . $i ] = 'bgcolor="' . $color . '" colspan="' . $cols . '" align="center"' ;
2002-11-23 15:19:56 +01:00
$prev_month = sprintf ( '%04d%02d01' , $y - ( $m == 1 ), $m > 1 ? $m - 1 : 12 );
$next_month = sprintf ( '%04d%02d01' , $y + ( $m == 12 ), $m < 12 ? $m + 1 : 1 );
$prev_link = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , " menuaction=calendar.uicalendar.planner&date= $prev_month " );
$next_link = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , " menuaction=calendar.uicalendar.planner&date= $next_month " );
$hdr [ 0 ][ $i ] = " <b><a href= \" $prev_link\ " >& lt ; & lt ; </ a > & nbsp $month & nbsp < a href = \ " $next_link\ " >& gt ; & gt ; </ a ></ b > " ;
$add_owner = array (); // if no add-rights on the showed cal use own cal
if ( ! $this -> bo -> save_owner && ! $this -> bo -> check_perms ( PHPGW_ACL_ADD ) ||
! $this -> bo -> check_perms ( PHPGW_ACL_ADD , 0 , $this -> bo -> save_owner ))
{
$add_owner = array (
'owner' => $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]
);
}
for ( $d = 1 ; $d <= $days ; $d ++ )
{
$dayname = substr ( lang ( date ( 'D' , mktime ( 0 , 0 , 0 , $m , $d , $y ))), 0 , 2 );
$index = $d + $this -> planner_days ;
$hdr [ 2 ][ '.' . $index ] = 'colspan="' . $intervals_per_day . '" align="center"' ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// highlight today, saturday, sunday and holidays
//
2003-08-28 16:31:11 +02:00
$color = $this -> theme [ 'row_off' ];
2002-11-23 15:19:56 +01:00
$dow = $GLOBALS [ 'phpgw' ] -> datetime -> day_of_week ( $y , $m , $d );
$date = sprintf ( " %04d%02d%02d " , $y , $m , $d );
if ( $date == date ( 'Ymd' ))
{
2003-08-28 16:31:11 +02:00
$color = $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'cal_today' ];
2002-11-23 15:19:56 +01:00
}
elseif ( $this -> bo -> cached_holidays [ $date ])
{
2003-08-28 16:31:11 +02:00
$color = $this -> bo -> holiday_color ;
2002-11-23 15:19:56 +01:00
$hdr [ 2 ][ '.' . $index ] .= ' title="' . $this -> bo -> cached_holidays [ $date ][ 0 ][ 'name' ] . '"' ;
}
elseif ( $dow == 0 || $dow == 6 )
{
2003-08-28 16:31:11 +02:00
$color = $this -> bo -> theme [ 'th_bg' ];
2002-11-23 15:19:56 +01:00
}
2002-09-17 04:25:40 +02:00
2003-08-28 16:31:11 +02:00
$hdr [ 2 ][ '.' . $index ] .= " bgcolor= \" $color\ " " ;
2002-09-17 04:25:40 +02:00
2003-09-14 14:51:31 +02:00
$hdr [ 2 ][ $index ] = '<a href="' . $this -> html -> link ( '/index.php' ,
2002-11-23 15:19:56 +01:00
array (
'menuaction' => 'calendar.uicalendar.add' ,
'date' => $date
) + $add_owner
) . '">' . $dayname . '<br>' . $d . '</a>' ;
}
$this -> planner_days += $days ;
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// create/initialize member variables describing the time interval to be displayed
//
$this -> planner_end_month = $m - 1 ;
$this -> planner_end_year = $y ;
$this -> planner_days_in_end_month = $GLOBALS [ 'phpgw' ] -> datetime -> days_in_month ( $this -> planner_end_month , $this -> planner_end_year );
2004-01-04 01:47:37 +01:00
$this -> planner_firstday = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year )));
$this -> planner_lastday = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $this -> planner_end_month , $this -> planner_days_in_end_month , $this -> planner_end_year )));
2002-09-20 01:45:19 +02:00
2002-11-23 15:19:56 +01:00
// generate line with calendar weeks in observed interval
//
$d = mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year );
$w = date ( 'W' , $d );
if ( $w == 'W' ) // php < 4.1
{
2004-01-04 01:47:37 +01:00
$w = 1 + ( int )( date ( 'z' , $d ) / 7 ); // a bit simplistic
2002-11-23 15:19:56 +01:00
}
2004-01-04 01:47:37 +01:00
$offset = ( 7 - date ( 'w' , $d ) + 1 ) % 7 ;
2002-11-23 15:19:56 +01:00
$offset = $offset == 0 ? 7 : $offset ;
2003-08-28 16:31:11 +02:00
$color = $this -> theme [ $w % 2 ? 'th_bg' : 'row_on' ];
2002-09-20 01:45:19 +02:00
2003-08-28 16:31:11 +02:00
$hdr [ 1 ][ '.' . $w ] = 'bgcolor="' . $color . '" colspan="' . $intervals_per_day * $offset . '" align="left"' ;
2002-11-23 15:19:56 +01:00
$hdr [ 1 ][ $w ] = '' ;
if ( $offset >= 3 )
{
2004-03-15 00:14:41 +01:00
//NDEE: style! (groupplanner)
2002-11-23 15:19:56 +01:00
$hdr [ 1 ][ $w ] .= '<font size="-2"> ' . lang ( 'week' ) . ' ' . $w . ' </font>' ;
}
$days_left = $this -> planner_days - $offset ;
2001-07-18 19:32:10 +02:00
2002-11-23 15:19:56 +01:00
$colspan = 7 * $intervals_per_day ;
while ( $days_left > 0 )
{
$colspan = ( $days_left < 7 ) ? $days_left * $intervals_per_day : $colspan ;
$d += 604800 ; // 7 days whith 24 hours (1h == 3600 seconds) each
$w = date ( 'W' , $d );
if ( $w == 'W' ) // php < 4.1
{
2004-01-04 01:47:37 +01:00
$w = 1 + ( int )( date ( 'z' , $d ) / 7 ); // a bit simplistic
2002-11-23 15:19:56 +01:00
}
$w += ( isset ( $hdr [ 1 ][ $w ])) ? 1 : 0 ; // bug in "date('W')" ?
2002-09-17 04:25:40 +02:00
2003-08-28 16:31:11 +02:00
$color = $this -> theme [ $w % 2 ? 'th_bg' : 'row_on' ];
$hdr [ 1 ][ '.' . $w ] = 'bgcolor="' . $color . '" colspan="' . $colspan . '" align="left"' ;
2002-11-23 15:19:56 +01:00
$hdr [ 1 ][ $w ] = '' ;
if ( $days_left >= 3 )
{
2004-03-15 00:14:41 +01:00
//NDEE: style! (groupplanner)
2002-11-23 15:19:56 +01:00
$hdr [ 1 ][ $w ] .= '<font size="-2"> ' . lang ( 'week' ) . ' ' . $w . ' </font>' ;
}
2001-08-06 05:36:58 +02:00
2002-11-23 15:19:56 +01:00
$days_left -= 7 ;
2002-09-17 04:25:40 +02:00
}
2002-11-23 15:19:56 +01:00
return $hdr ;
2002-09-17 04:25:40 +02:00
}
2004-08-01 16:16:46 +02:00
/**
* tooltip for all calendar views
*
* displays title , time , description , location and participants , should be composed via a template in the next version
*
* @ param $event array containing the event
* @ return the onmouseover attribute ( incl . onmouseover = ) to be included in an html - element , eg . div or table - cell
*/
function event_tooltip ( $event , $always_show_time = False )
{
$start = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $this -> bo -> maketime ( $event [ 'start' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset );
$end = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $this -> bo -> maketime ( $event [ 'end' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset );
$multiday = substr ( $start , 0 , 10 ) != substr ( $end , 0 , 10 ); // start and end on same day?
return $this -> html -> tooltip (
( $always_show_time || $multiday ? '<p style="margin: 0px;"><b>' . $start . ( ! $multiday ? substr ( $end , 10 ) : ' -- ' . $end ) . '</b></p>' : '' ) .
'<p style="margin: 0px;">' . $event [ 'description' ] . '</p>' .
( $event [ 'location' ] ? '<p style="background: silver; margin: 0px; padding: 1px;">' . $event [ 'location' ] . '</p>' : '' ) .
( count ( $event [ 'participants' ]) > 1 || ! isset ( $event [ 'participants' ][ $this -> bo -> owner ]) ? '<p style="margin: 0px;">' . $this -> planner_participants ( $event [ 'participants' ]) . '</p>' : '' ),
False , array (
'TITLE' => $event [ 'title' ],
'WIDTH' => 250 ,
));
}
2002-09-17 04:25:40 +02:00
/**
* planner_update_row - update a row of the planner view
*
2003-02-26 17:42:04 +01:00
* parameters are :
2002-09-17 04:25:40 +02:00
* - index ( e . g . user id , category id , ... ) of the row
* - name / title of the row ( e . g . user name , category name )
* - the event to be integrated
* - list of categories associated with the event
* - first and last cell of the row
*/
2002-11-23 15:19:56 +01:00
function planner_update_row ( $index , $name , $event , $cat , $start_cell , $end_cell )
2002-09-17 04:25:40 +02:00
{
2002-11-23 15:19:56 +01:00
$rows = & $this -> planner_rows ;
$intervals_per_day = $this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ];
$is_private = ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event );
2004-01-04 01:47:37 +01:00
2003-09-14 14:51:31 +02:00
$view = $this -> html -> link ( '/index.php' ,
2002-11-23 15:19:56 +01:00
array (
'menuaction' => 'calendar.uicalendar.view' ,
2003-02-26 17:42:04 +01:00
'cal_id' => $event [ 'id' ],
'date' => date ( 'Ymd' , $this -> bo -> maketime ( $event [ 'start' ]))
2002-11-23 15:19:56 +01:00
)
);
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// check how many lines are needed for this "row" (currently: user or category)
$i = 0 ;
do {
++ $i ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
$k = $index . '_' . $i ;
$ka = '.nr_' . $k ;
2001-07-28 15:17:30 +02:00
2002-11-23 15:19:56 +01:00
if ( ! isset ( $rows [ $k ]))
{
if ( $i > 1 ) // further line - no name
2001-07-28 15:17:30 +02:00
{
2002-11-23 15:19:56 +01:00
$rows [ $k ] = array ();
$rows [ $index . '_1' ][ '._name' ] = 'rowspan="' . $i . '"' ;
2001-07-18 19:32:10 +02:00
}
2002-11-23 15:19:56 +01:00
else
{
$rows [ $k ][ '_name' ] = $name ;
}
$rows [ $ka ] = 0 ;
}
$rows [ $index . '_1' ][ '._name' ] .= ' nowrap' ; // title must be one row
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
$row = & $rows [ $k ];
$akt_cell = & $rows [ $ka ];
} while ( $akt_cell > $start_cell );
2003-02-26 17:42:04 +01:00
$id = $event [ 'id' ] . '-' . date ( 'Ymd' , $this -> bo -> maketime ( $event [ 'start' ]));
2002-11-23 15:19:56 +01:00
if ( $akt_cell < $start_cell )
{
2003-02-26 17:42:04 +01:00
$row [ $id . '_1' ] = ' ' ;
$row [ '.' . $id . '_1' ] = 'colspan="' . ( $start_cell - $akt_cell ) . '"' ;
2002-11-23 15:19:56 +01:00
}
2003-02-26 17:42:04 +01:00
$opt = & $row [ '.' . $id . '_2' ];
$cel = & $row [ $id . '_2' ];
2002-11-23 15:19:56 +01:00
// if possible, display information about event within cells representing it
//
if ( $start_cell < $end_cell )
{
$colspan = $end_cell - $start_cell ;
$opt .= " colspan= " . ( 1 + $colspan );
if ( ! $is_private )
{
2004-01-04 01:47:37 +01:00
$max_chars = ( int )( 3 * $colspan / $intervals_per_day - 2 );
2002-11-23 15:19:56 +01:00
$min_chars = 3 ; // minimum for max_chars to display -> this should be configurable
if ( $max_chars >= $min_chars )
2001-07-28 15:17:30 +02:00
{
2002-11-23 15:19:56 +01:00
$len_title = strlen ( $event [ 'title' ]);
2002-09-17 04:25:40 +02:00
2003-08-28 16:31:11 +02:00
if ( $len_title <= $max_chars )
2002-09-17 04:25:40 +02:00
{
2002-11-23 15:19:56 +01:00
$title = $event [ 'title' ];
2003-08-28 16:31:11 +02:00
$max_chars -= $len_title + 3 ; // 3 chars for separator: " - "
2002-11-23 15:19:56 +01:00
$len_descr = strlen ( $event [ 'description' ]);
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
if ( $len_descr > 0 && $len_descr <= $max_chars )
2002-09-17 04:25:40 +02:00
{
2002-11-23 15:19:56 +01:00
$event [ 'print_description' ] = 'yes' ;
2002-09-17 04:25:40 +02:00
}
}
2002-11-23 15:19:56 +01:00
else
2002-09-17 04:25:40 +02:00
{
2003-08-28 16:31:11 +02:00
$has_amp = strpos ( $event [ 'title' ], '&' );
2004-03-15 00:14:41 +01:00
//NDEE: event title gets cut here
2003-08-28 16:31:11 +02:00
$title = substr ( $event [ 'title' ], 0 , $max_chars - 1 + ( $has_amp !== False && $has_amp < $max_chars ? 4 : 0 )) . '...' ;
2002-09-17 04:25:40 +02:00
}
2002-11-23 15:19:56 +01:00
$event [ 'print_title' ] = 'yes' ;
2002-09-17 04:25:40 +02:00
}
2002-11-23 15:19:56 +01:00
}
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
if ( $bgcolor = $cat [ 'color' ])
{
$opt .= ' bgcolor="' . $bgcolor . '"' ;
}
2001-07-18 19:32:10 +02:00
2002-11-23 15:19:56 +01:00
if ( ! $is_private )
{
2004-08-01 16:16:46 +02:00
$opt .= $this -> event_tooltip ( $event , True );
$opt .= ' onClick="location=\'' . $view . '\'"' ;
2002-11-23 15:19:56 +01:00
$cel = '<a href="' . $view . '">' ;
}
else
{
2004-08-01 16:16:46 +02:00
$opt .= ' title="' . lang ( 'You do not have permission to read this record!' ) . '"' ;
2002-11-23 15:19:56 +01:00
$cel = '' ;
}
2003-09-08 01:42:22 +02:00
$opt .= ' class="planner-cell"' ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
if ( $event [ 'priority' ] == 3 )
{
2004-08-01 16:16:46 +02:00
$cel .= $this -> html -> image ( 'calendar' , 'high.gif' , '' , 'border="0"' );
2002-11-23 15:19:56 +01:00
}
2003-02-26 17:42:04 +01:00
if ( $event [ 'recur_type' ])
{
2003-09-14 14:51:31 +02:00
$cel .= $this -> html -> image ( 'calendar' , 'recur.gif' , '' , 'border="0"' );
2003-02-26 17:42:04 +01:00
}
2004-08-01 16:16:46 +02:00
$cel .= $this -> html -> image ( 'calendar' , count ( $event [ 'participants' ]) > 1 ? 'multi_3.gif' : 'single.gif' ,
$is_private ? $this -> planner_participants ( $event [ 'participants' ]) : '' , 'border="0"' );
2002-11-23 15:19:56 +01:00
$cel .= '</a>' ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
if ( isset ( $event [ 'print_title' ]) && $event [ 'print_title' ] == 'yes' )
{
2004-03-15 00:14:41 +01:00
//NDEE: style! where?
2002-11-23 15:19:56 +01:00
$cel .= '<font size="-2"> ' . $title . ' </font>' ;
2001-09-29 03:40:47 +02:00
}
2002-11-23 15:19:56 +01:00
if ( isset ( $event [ 'print_description' ]) && $event [ 'print_description' ] == 'yes' )
{
2004-03-15 00:14:41 +01:00
//NDEE: style! where ?
2002-11-23 15:19:56 +01:00
$cel .= '<font size="-2"> - ' . $event [ 'description' ] . ' </font>' ;
}
2003-08-28 16:31:11 +02:00
2002-11-23 15:19:56 +01:00
$akt_cell = $end_cell + 1 ;
return $rows ;
2002-09-17 04:25:40 +02:00
}
function planner_process_event ( $event )
{
2002-11-23 15:19:56 +01:00
$intervals_per_day = $this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ];
$interval = $this -> planner_intervals [ $intervals_per_day ];
$last_cell = $intervals_per_day * $this -> planner_days - 1 ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
$rows = & $this -> planner_rows ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// caluculate start and end of event
//
2004-01-04 01:47:37 +01:00
$event_start = ( int )( date ( 'Ymd' , mktime (
0 , 0 , 0 ,
$event [ 'start' ][ 'month' ],
$event [ 'start' ][ 'mday' ],
$event [ 'start' ][ 'year' ]
)));
$event_end = ( int )( date ( 'Ymd' , mktime (
0 , 0 , 0 ,
$event [ 'end' ][ 'month' ],
$event [ 'end' ][ 'mday' ],
$event [ 'end' ][ 'year' ]
)));
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// calculate first cell of event within observed interval
//
if ( $event_start >= $this -> planner_firstday )
{
$days_between = $GLOBALS [ 'phpgw' ] -> datetime -> days_between ( $this -> bo -> month , 1 , $this -> bo -> year , $event [ 'start' ][ 'month' ], $event [ 'start' ][ 'mday' ], $event [ 'start' ][ 'year' ]);
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
$start_cell = $intervals_per_day * $days_between + $interval [ $event [ 'start' ][ 'hour' ]];
}
else
{
$start_cell = 0 ;
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// calculate last cell of event within observed interval
//
if ( $event_end <= $this -> planner_lastday )
{
$days_between = $GLOBALS [ 'phpgw' ] -> datetime -> days_between ( $this -> bo -> month , 1 , $this -> bo -> year , $event [ 'end' ][ 'month' ], $event [ 'end' ][ 'mday' ], $event [ 'end' ][ 'year' ]);
$end_cell = $intervals_per_day * $days_between + $interval [ $event [ 'end' ][ 'hour' ]];
if ( $end_cell == $start_cell && $end_cell < $last_cell )
{
$end_cell ++ ; // min. width 1 interval
}
}
else
{
$end_cell = $last_cell ;
}
// get the categories associated with event
//
if ( $c = $event [ 'category' ])
{
list ( $cat ) = $this -> planner_category ( $event [ 'category' ]);
if ( $cat [ 'parent' ])
{
list ( $pcat ) = $this -> planner_category ( $c = $cat [ 'parent' ]);
}
else
{
$pcat = $cat ;
}
}
else
{
$cat = $pcat = array ( 'name' => lang ( 'none' ));
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// add the event to it`s associated row(s)
//
if ( $this -> bo -> sortby == 'category' )
{
// event needs to show up in it`s category`s row
//
$this -> planner_update_row ( $c , $pcat [ 'name' ], $event , $cat , $start_cell , $end_cell );
}
elseif ( $this -> bo -> sortby == 'user' )
{
// event needs to show up in rows of all participants that are also owners
//
reset ( $this -> planner_group_members );
while ( list ( $user_name , $id ) = each ( $this -> planner_group_members ))
{
$status = $event [ 'participants' ][ $id ];
if ( isset ( $status ) && $status != 'R' )
{
$this -> planner_update_row ( $user_name , $user_name , $event , $cat , $start_cell , $end_cell );
2002-09-17 04:25:40 +02:00
}
2002-11-23 15:19:56 +01:00
}
2001-07-18 19:32:10 +02:00
}
2002-09-17 04:25:40 +02:00
}
2001-09-29 03:40:47 +02:00
2002-09-17 04:25:40 +02:00
function planner_pad_rows ()
2003-04-12 21:21:22 +02:00
{
2002-11-23 15:19:56 +01:00
$rows = & $this -> planner_rows ;
if ( $this -> bo -> sortby == 'user' )
2001-09-29 03:40:47 +02:00
{
2002-11-23 15:19:56 +01:00
// add empty rows for users that do not participante in any event
//
reset ( $this -> planner_group_members );
while ( list ( $user_name , $id ) = each ( $this -> planner_group_members ))
{
$k = $user_name . '_1' ;
$ka = '.nr_' . $k ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
if ( ! isset ( $rows [ $k ]))
2002-09-17 04:25:40 +02:00
{
2002-11-23 15:19:56 +01:00
$rows [ $k ][ '_name' ] = $user_name ;
$rows [ $k ][ '._name' ] .= ' nowrap' ;
$rows [ $ka ] = 0 ;
2002-09-17 04:25:40 +02:00
}
2002-11-23 15:19:56 +01:00
}
}
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// fill the remaining cols
//
$last_cell = $this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ] * $this -> planner_days - 1 ;
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
ksort ( $rows );
while ( list ( $k , $r ) = each ( $rows ))
{
if ( is_array ( $r ))
{
2003-08-28 16:31:11 +02:00
$rows [ '.' . $k ] = 'bgcolor="' . $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color () . '"' ;
2002-11-23 15:19:56 +01:00
$row = & $rows [ $k ];
$akt_cell = & $rows [ '.nr_' . $k ];
if ( $akt_cell < $last_cell )
2002-09-17 04:25:40 +02:00
{
2002-11-23 15:19:56 +01:00
$row [ '3' ] = ' ' ;
$row [ '.3' ] = 'colspan="' . ( 1 + $last_cell - $akt_cell ) . '"' ;
2002-09-17 04:25:40 +02:00
}
2002-11-23 15:19:56 +01:00
}
2001-09-29 03:40:47 +02:00
}
}
2001-09-07 18:37:11 +02:00
2002-09-17 04:25:40 +02:00
function planner_print_rows ()
2003-04-12 21:21:22 +02:00
{
2003-08-28 16:31:11 +02:00
$bgcolor = 'bgcolor="' . $this -> theme [ 'th_bg' ] . '"' ;
2002-11-23 15:19:56 +01:00
$intervals_per_day = $this -> bo -> prefs [ 'calendar' ][ 'planner_intervals_per_day' ];
if ( $this -> debug )
{
_debug_array ( $this -> planner_rows );
reset ( $this -> planner_rows );
}
2003-09-14 14:51:31 +02:00
return $this -> html -> table (
2002-11-23 15:19:56 +01:00
array (
'_hdr0' => $this -> planner_header [ 0 ],
2003-08-28 16:31:11 +02:00
'._hdr0' => $bgcolor ,
2002-11-23 15:19:56 +01:00
'_hdr1' => $this -> planner_header [ 1 ],
2003-08-28 16:31:11 +02:00
'._hdr1' => $bgcolor ,
2002-11-23 15:19:56 +01:00
'_hdr2' => $this -> planner_header [ 2 ],
2003-08-28 16:31:11 +02:00
'._hdr2' => $bgcolor
2002-11-23 15:19:56 +01:00
) + $this -> planner_rows ,
'width="100%" cols="' . ( 1 + $this -> planner_days_in_end_month * $intervals_per_day ) . '"' );
2003-04-12 21:21:22 +02:00
}
2002-09-17 04:25:40 +02:00
function planner_process_interval ()
{
2002-11-23 15:19:56 +01:00
// generate duplicate free list of events within observed interval
//
$this -> bo -> store_to_cache (
Array (
'syear' => $this -> bo -> year ,
'smonth' => $this -> bo -> month ,
'sday' => 1 ,
'eyear' => $this -> planner_end_year ,
'emonth' => $this -> planner_end_month ,
'eday' => $this -> planner_days_in_end_month
)
);
$this -> bo -> remove_doubles_in_cache ( $this -> planner_firstday , $this -> planner_lastday );
2004-05-06 02:59:47 +02:00
2002-11-23 15:19:56 +01:00
// process all events within observed interval
//
2003-08-28 16:31:11 +02:00
for ( $v = $this -> planner_firstday ; $v <= $this -> planner_lastday ; $v ++ )
2002-11-23 15:19:56 +01:00
{
$daily = $this -> bo -> cached_events [ $v ];
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
print_debug ( 'For Date' , $v );
print_debug ( 'Count of items' , count ( $daily ));
2002-09-17 04:25:40 +02:00
2002-11-23 15:19:56 +01:00
// process all events on day $v
//
2003-08-28 16:31:11 +02:00
if ( is_array ( $daily )) foreach ( $daily as $event )
2002-11-23 15:19:56 +01:00
{
2003-02-26 17:42:04 +01:00
if ( $event [ 'recur_type' ]) // calculate start- + end-datetime for recuring events
{
$this -> bo -> set_recur_date ( $event , $v );
}
2003-08-28 16:31:11 +02:00
if ( ! $this -> bo -> rejected_no_show ( $event ))
{
$this -> planner_process_event ( $event );
}
2002-11-23 15:19:56 +01:00
}
}
$this -> planner_pad_rows ();
2001-07-28 15:17:30 +02:00
}
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
function matrixselect ()
{
2002-08-25 06:07:21 +02:00
$datetime = mktime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
$sb = CreateObject ( 'phpgwapi.sbox' );
2002-08-25 06:07:21 +02:00
2003-08-28 16:31:11 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
if ( $this -> always_app_header ) $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Matrixview' );
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-18 19:32:10 +02:00
2003-04-21 13:00:53 +02:00
$p = & $GLOBALS [ 'phpgw' ] -> template ;
2001-07-28 15:17:30 +02:00
$p -> set_file (
Array (
2001-10-03 02:31:03 +02:00
'mq' => 'matrix_query.tpl' ,
'form_button' => 'form_button_script.tpl'
2001-07-28 15:17:30 +02:00
)
);
$p -> set_block ( 'mq' , 'matrix_query' , 'matrix_query' );
$p -> set_block ( 'mq' , 'list' , 'list' );
2001-07-18 19:32:10 +02:00
2003-04-21 13:00:53 +02:00
$p -> set_var ( array (
'title' => lang ( 'Daily Matrix View' ),
2003-08-28 16:31:11 +02:00
'th_bg' => $this -> theme [ 'th_bg' ],
2001-10-03 02:31:03 +02:00
'action_url' => $this -> page ( 'viewmatrix' )
2003-04-21 13:00:53 +02:00
));
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
// Date
$var [] = Array (
'field' => lang ( 'Date' ),
2001-08-12 16:47:23 +02:00
'data' => $GLOBALS [ 'phpgw' ] -> common -> dateformatorder (
2004-01-04 01:47:37 +01:00
$sb -> getYears ( 'year' ,( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'Y' ),( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'Y' )),
$sb -> getMonthText ( 'month' ,( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'n' )),
$sb -> getDays ( 'day' ,( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'd' ))
2001-07-28 15:17:30 +02:00
)
);
2002-08-25 06:07:21 +02:00
2001-07-28 15:17:30 +02:00
// View type
$var [] = Array (
'field' => lang ( 'View' ),
'data' => '<select name="matrixtype">' . " \n "
. '<option value="free/busy" selected>' . lang ( 'free/busy' ) . '</option>' . " \n "
. '<option value="weekly">' . lang ( 'Weekly' ) . '</option>' . " \n "
. '</select>' . " \n "
);
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
// Participants
2004-06-30 00:39:00 +02:00
if ( ! is_object ( $GLOBALS [ 'phpgw' ] -> uiaccountsel ))
{
$GLOBALS [ 'phpgw' ] -> uiaccountsel = CreateObject ( 'phpgwapi.uiaccountsel' );
}
2001-08-12 16:47:23 +02:00
$accounts = $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( 'run' , 1 , 'calendar' );
2004-06-30 00:39:00 +02:00
2001-07-28 15:17:30 +02:00
$users = Array ();
for ( $i = 0 ; $i < count ( $accounts ); $i ++ )
2001-07-18 19:32:10 +02:00
{
2001-10-03 02:31:03 +02:00
$user = $accounts [ $i ];
2001-07-28 15:17:30 +02:00
if ( ! isset ( $users [ $user ]))
2001-07-18 19:32:10 +02:00
{
2001-08-12 16:47:23 +02:00
$users [ $user ] = $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $user );
if ( $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $user ) == 'g' )
2001-07-28 15:17:30 +02:00
{
2001-08-12 16:47:23 +02:00
$group_members = $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( $user , 1 , 'phpgw_group' );
2001-07-28 15:17:30 +02:00
if ( $group_members != False )
{
for ( $j = 0 ; $j < count ( $group_members ); $j ++ )
{
if ( ! isset ( $users [ $group_members [ $j ]]))
{
2001-08-12 16:47:23 +02:00
$users [ $group_members [ $j ]] = $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $group_members [ $j ]);
2001-07-28 15:17:30 +02:00
}
}
}
}
2001-07-18 19:32:10 +02:00
}
}
2001-09-17 04:33:19 +02:00
$num_users = count ( $users );
2001-07-28 15:17:30 +02:00
if ( $num_users > 50 )
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
$size = 15 ;
}
elseif ( $num_users > 5 )
{
$size = 5 ;
2001-07-18 19:32:10 +02:00
}
else
{
2001-07-28 15:17:30 +02:00
$size = $num_users ;
2001-07-18 19:32:10 +02:00
}
2004-06-30 00:39:00 +02:00
$select = array ();
@ uasort ( $users , 'strcasecmp' );
foreach ( $users as $id => $name )
2001-07-28 15:17:30 +02:00
{
2004-06-30 00:39:00 +02:00
if ( ! ( $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $id ) && $this -> bo -> check_perms ( PHPGW_ACL_READ , 0 , $id ) || $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $id ) == 'g' ))
2001-07-18 19:32:10 +02:00
{
2004-06-30 00:39:00 +02:00
unset ( $users [ $id ]);
2001-07-18 19:32:10 +02:00
}
2001-07-28 15:17:30 +02:00
}
$var [] = Array (
'field' => lang ( 'Participants' ),
2004-06-30 00:39:00 +02:00
'data' => " \n " . $GLOBALS [ 'phpgw' ] -> uiaccountsel -> selection ( 'participants[]' , 'uicalendar_matrix_users' , array (), 'calendar+' , $size , False , '' , '' , $users )
2001-07-28 15:17:30 +02:00
);
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
for ( $i = 0 ; $i < count ( $var ); $i ++ )
{
$this -> output_template_array ( $p , 'rows' , 'list' , $var [ $i ]);
}
2002-09-17 04:25:40 +02:00
2001-07-28 15:17:30 +02:00
$vars = Array (
2003-04-21 13:00:53 +02:00
'submit_button' => lang ( 'View' ),
'action_url_button' => $this -> bo -> return_to ? $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ) : $this -> page ( '' ),
2001-07-28 15:17:30 +02:00
'action_text_button' => lang ( 'Cancel' ),
2003-04-21 13:00:53 +02:00
'action_confirm_button' => '' ,
2001-07-28 15:17:30 +02:00
'action_extra_field' => ''
);
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
$p -> set_var ( $vars );
$p -> parse ( 'cancel_button' , 'form_button' );
$p -> pparse ( 'out' , 'matrix_query' );
}
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
function viewmatrix ()
{
2003-08-28 16:31:11 +02:00
if ( $_POST [ 'cancel' ])
{
$this -> index ();
}
2004-08-01 17:36:04 +02:00
$participants = get_var ( " participants " , array ( " GET " , " POST " ));
$date [ " year " ] = get_var ( " year " , array ( " GET " , " POST " ));
$date [ " month " ] = get_var ( " month " , array ( " GET " , " POST " ));
$date [ " day " ] = get_var ( " day " , array ( " GET " , " POST " ));
2001-07-28 15:17:30 +02:00
$parts = Array ();
$acct = CreateObject ( 'phpgwapi.accounts' , $this -> bo -> owner );
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
if ( is_array ( $participants ))
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
foreach ( $participants as $participant )
2001-07-18 19:32:10 +02:00
{
2003-08-28 16:31:11 +02:00
switch ( $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $participant ))
{
case 'g' :
2004-01-04 01:47:37 +01:00
if ( $members = $acct -> member (( int ) $participant ))
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
foreach ( $members as $member )
{
if ( $this -> bo -> check_perms ( PHPGW_ACL_READ , 0 , $member [ 'account_id' ]))
{
$parts [ $member [ 'account_id' ]] = True ;
}
}
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
break ;
case 'u' :
if ( $this -> bo -> check_perms ( PHPGW_ACL_READ , 0 , $participant ))
{
$parts [ $participant ] = 1 ;
}
break ;
}
2001-07-18 19:32:10 +02:00
}
2003-08-28 16:31:11 +02:00
unset ( $acct );
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
$participants = array_keys ( $parts ); // get id's as values and a numeric index
2001-07-18 19:32:10 +02:00
2004-03-31 17:34:33 +02:00
// Defined - into session - who participates
$GLOBALS [ 'phpgw' ] -> session -> appsession ( " participants " , NULL , implode ( " ; " , $participants ));
2003-08-28 16:31:11 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
if ( $this -> always_app_header ) $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Matrixview' );
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-18 19:32:10 +02:00
2004-08-01 17:36:04 +02:00
switch ( get_var ( " matrixtype " , array ( " GET " , " POST " )) )
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
case 'free/busy' :
2004-08-01 17:36:04 +02:00
if ( get_var ( " sevendays " , array ( " GET " , " POST " )) )
{
$_f_daysend = 7 ;
}
for ( $_f_days = 0 ; $_f_days <= $_f_daysend ; $_f_days ++ )
{
$freetime = $GLOBALS [ 'phpgw' ] -> datetime -> gmtdate ( mktime ( 0 , 0 , 0 , $date [ " month " ],( $date [ " day " ] + $_f_days ), $date [ " year " ]));
echo '<br>' . $this -> timematrix (
Array (
'date' => $freetime ,
'starttime' => $this -> bo -> splittime ( '000000' , False ),
'endtime' => 0 ,
'participants' => $parts
)
);
}
2001-07-28 15:17:30 +02:00
break ;
case 'weekly' :
2003-08-28 16:31:11 +02:00
echo '<br>' . $this -> display_weekly (
2001-08-12 16:47:23 +02:00
Array (
'date' => sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day ),
'showyear' => true ,
2001-10-03 02:31:03 +02:00
'owners' => $participants
2001-08-12 16:47:23 +02:00
)
);
2001-07-28 15:17:30 +02:00
break ;
2001-07-18 19:32:10 +02:00
}
2003-08-28 16:31:11 +02:00
echo " \n <br> \n " . '<form action="' . $this -> page ( 'viewmatrix' ) . '" method="post" name="matrixform">' . " \n " ;
echo ' <table cellpadding="5"><tr><td>' . " \n " ;
2004-08-22 20:44:47 +02:00
echo ' ' . $this -> html -> input_hidden ( 'year' , $this -> bo -> year );
echo ' ' . $this -> html -> input_hidden ( 'month' , $this -> bo -> month );
echo ' ' . $this -> html -> input_hidden ( 'day' , $this -> bo -> day );
echo ' ' . $this -> html -> input_hidden ( 'matrixtype' , $_REQUEST [ 'matrixtype' ]);
2003-08-28 16:31:11 +02:00
foreach ( $participants as $part )
{
2004-08-22 20:44:47 +02:00
$part = substr ( $part , 0 , 2 ) == 'g_' ? 'g_' . ( int ) substr ( $part , 2 ) : ( int ) $part ;
echo ' ' . $this -> html -> input_hidden ( 'participants[]' , $part );
2003-08-28 16:31:11 +02:00
}
echo ' <input type="submit" name="refresh" value="' . lang ( 'Refresh' ) . '">' . " \n " ;
echo ' </td><td>' . " \n " ;
echo ' <input type="submit" name="cancel" value="' . lang ( 'Cancel' ) . '">' . " \n " ;
2004-08-01 17:36:04 +02:00
echo ' </td><td>' . " \n " ;
// Seven days
if ( get_var ( " matrixtype " , array ( " GET " , " POST " )) == " free/busy " )
{
if ( ! get_var ( " sevendays " , array ( " GET " , " POST " )) )
echo ' <input type="submit" name="sevendays" value="' . lang ( 'Show next seven days' ) . '">' . " \n " ;
else
echo ' <input type="submit" name="oneday" value="' . lang ( 'Show only one day' ) . '">' . " \n " ;
}
2003-08-28 16:31:11 +02:00
echo ' </td></tr></table>' . " \n " ;
echo '</form>' . " \n " ;
2001-07-28 15:17:30 +02:00
}
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
function search ()
{
2003-08-28 16:31:11 +02:00
if ( empty ( $_POST [ 'keywords' ]))
2001-07-18 19:32:10 +02:00
{
2003-11-03 10:21:26 +01:00
// If we reach this, it is because they didn't search for anything
// or they used one of the selectboxes (year, month, week) in the search-result
// attempt to send them back to where they came from.
$vars [ 'menuaction' ] = isset ( $_POST [ 'from' ]) && $_POST [ 'from' ] != 'calendar.uicalendar.search' ?
$_POST [ 'from' ] : 'calendar.uicalendar.index' ;
foreach ( array ( 'date' , 'year' , 'month' , 'day' ) as $field )
{
if ( isset ( $_POST [ $field ]))
{
$vars [ $field ] = $_POST [ $field ];
}
}
$GLOBALS [ 'phpgw' ] -> redirect_link ( '/index.php' , $vars );
2001-07-18 19:32:10 +02:00
}
2001-08-12 16:47:23 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
2003-04-21 13:00:53 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Search Results' );
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-28 15:17:30 +02:00
$error = '' ;
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
$matches = 0 ;
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
// There is currently a problem searching in with repeated events.
// It spits back out the date it was entered. I would like to to say that
// it is a repeated event.
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
// This has been solved by the little icon indicator for recurring events.
2001-07-18 19:32:10 +02:00
2003-08-28 16:31:11 +02:00
$event_ids = $this -> bo -> search_keywords ( $_POST [ 'keywords' ]);
2003-04-21 13:00:53 +02:00
foreach ( $event_ids as $key => $id )
2001-07-28 15:17:30 +02:00
{
$event = $this -> bo -> read_entry ( $id );
2002-09-17 04:25:40 +02:00
2003-04-21 13:00:53 +02:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event ))
2002-09-17 04:25:40 +02:00
{
continue ;
}
2002-08-25 06:07:21 +02:00
$datetime = $this -> bo -> maketime ( $event [ 'start' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2002-09-17 04:25:40 +02:00
2003-04-21 13:00:53 +02:00
$info [ strval ( $event [ 'id' ])] = array (
'tr_color' => $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color (),
'date' => $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime ),
'link' => $this -> link_to_entry ( $event , $event [ 'start' ][ 'month' ], $event [ 'start' ][ 'mday' ], $event [ 'start' ][ 'year' ])
);
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
}
$matches = count ( $event_ids );
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
if ( $matches == 1 )
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
$quantity = lang ( '1 match found' ) . '.' ;
}
elseif ( $matches > 0 )
{
2003-02-27 23:57:55 +01:00
$quantity = lang ( '%1 matches found' , $matches ) . '.' ;
2001-07-18 19:32:10 +02:00
}
else
{
2003-08-28 16:31:11 +02:00
echo '<b>' . lang ( 'Error' ) . ':</b>' . lang ( 'no matches found' );
return ;
2001-07-18 19:32:10 +02:00
}
2001-07-16 13:38:40 +02:00
2003-04-21 13:00:53 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2001-07-28 15:17:30 +02:00
$p -> set_file (
Array (
2001-10-03 02:31:03 +02:00
'search_form' => 'search.tpl'
2001-07-28 15:17:30 +02:00
)
2001-07-22 01:35:22 +02:00
);
2001-07-28 15:17:30 +02:00
$p -> set_block ( 'search_form' , 'search' , 'search' );
$p -> set_block ( 'search_form' , 'search_list_header' , 'search_list_header' );
$p -> set_block ( 'search_form' , 'search_list' , 'search_list' );
$p -> set_block ( 'search_form' , 'search_list_footer' , 'search_list_footer' );
2002-08-25 06:07:21 +02:00
2001-07-18 19:32:10 +02:00
$var = Array (
2003-08-28 16:31:11 +02:00
'th_bg' => $this -> theme [ 'th_bg' ],
2001-10-03 02:31:03 +02:00
'search_text' => lang ( 'Search Results' ),
'quantity' => $quantity
2001-07-18 19:32:10 +02:00
);
$p -> set_var ( $var );
2001-07-28 15:17:30 +02:00
if ( $matches > 0 )
2001-07-22 01:35:22 +02:00
{
2001-07-28 15:17:30 +02:00
$p -> parse ( 'rows' , 'search_list_header' , True );
2001-07-22 01:35:22 +02:00
}
2003-08-28 16:31:11 +02:00
foreach ( $info as $id => $data )
2001-07-18 19:32:10 +02:00
{
2003-08-28 16:31:11 +02:00
$p -> set_var ( $data );
2001-07-28 15:17:30 +02:00
$p -> parse ( 'rows' , 'search_list' , True );
2001-07-22 01:35:22 +02:00
}
2003-08-28 16:31:11 +02:00
2001-07-28 15:17:30 +02:00
if ( $matches > 0 )
2001-07-22 01:35:22 +02:00
{
2001-07-28 15:17:30 +02:00
$p -> parse ( 'rows' , 'search_list_footer' , True );
2001-07-18 19:32:10 +02:00
}
2001-07-22 01:35:22 +02:00
2001-07-28 15:17:30 +02:00
$p -> pparse ( 'out' , 'search' );
2001-07-18 19:32:10 +02:00
}
2001-07-22 01:35:22 +02:00
2001-07-18 19:32:10 +02:00
/* Private functions */
2001-07-16 13:38:40 +02:00
function _debug_sqsof ()
{
$data = array (
2002-08-25 06:07:21 +02:00
'filter' => $this -> bo -> filter ,
'cat_id' => $this -> bo -> cat_id ,
'owner' => $this -> bo -> owner ,
'year' => $this -> bo -> year ,
'month' => $this -> bo -> month ,
'day' => $this -> bo -> day ,
'sortby' => $this -> bo -> sortby ,
'num_months' => $this -> bo -> num_months
2001-07-16 13:38:40 +02:00
);
2003-08-28 16:31:11 +02:00
Return _debug_array ( $data , False );
2001-07-16 13:38:40 +02:00
}
function output_template_array ( & $p , $row , $list , $var )
{
2002-08-25 06:07:21 +02:00
if ( ! isset ( $var [ 'hidden_vars' ]))
{
$var [ 'hidden_vars' ] = '' ;
}
2003-04-21 13:00:53 +02:00
if ( ! isset ( $var [ 'tr_color' ]))
{
$var [ 'tr_color' ] = $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color ();
}
2001-07-16 13:38:40 +02:00
$p -> set_var ( $var );
$p -> parse ( $row , $list , True );
}
2001-10-02 03:13:53 +02:00
function page ( $_page = '' , $params = '' )
2001-07-16 13:38:40 +02:00
{
2001-10-02 03:13:53 +02:00
if ( $_page == '' )
2001-07-16 13:38:40 +02:00
{
2001-07-18 19:32:10 +02:00
$page_ = explode ( '.' , $this -> bo -> prefs [ 'calendar' ][ 'defaultcalendar' ]);
2001-10-02 03:13:53 +02:00
$_page = $page_ [ 0 ];
2003-08-28 16:31:11 +02:00
2002-09-20 01:45:19 +02:00
if ( $_page == 'planner_cat' || $_page == 'planner_user' )
{
$_page = 'planner' ;
}
elseif ( $_page == 'index' || ( $_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner' ))
2001-07-16 13:38:40 +02:00
{
2001-10-02 03:13:53 +02:00
$_page = 'month' ;
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'defaultcalendar' , 'month' );
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
2001-07-16 13:38:40 +02:00
}
}
2002-11-24 11:34:28 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'home' ||
2004-01-04 01:47:37 +01:00
strstr ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], 'mail' )) // email, felamimail, ...
2001-08-13 06:49:19 +02:00
{
$page_app = 'calendar' ;
}
else
{
$page_app = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
}
2004-08-01 17:36:04 +02:00
$page_class = $_page == 'day' || $_page == 'week' || $_page == 'month' ? 'uiviews' : 'uicalendar' ;
if ( is_array ( $params ))
{
$params [ 'menuaction' ] = $page_app . '.' . $page_class . '.' . $_page ;
}
else
{
$params = 'menuaction=' . $page_app . '.' . $page_class . '.' . $_page . $params ;
2003-11-03 10:21:26 +01:00
}
return $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , $params );
2001-07-16 13:38:40 +02:00
}
function header ()
{
2004-08-01 17:36:04 +02:00
return ;
2001-07-16 13:38:40 +02:00
$cols = 8 ;
if ( $this -> bo -> check_perms ( PHPGW_ACL_PRIVATE ) == True )
{
$cols ++ ;
}
2001-09-20 23:29:16 +02:00
2003-04-21 13:00:53 +02:00
$tpl = $GLOBALS [ 'phpgw' ] -> template ;
2001-07-16 13:38:40 +02:00
$tpl -> set_unknowns ( 'remove' );
2003-08-28 16:31:11 +02:00
if ( ! file_exists ( $file = $this -> template_dir . '/header.inc.php' ))
{
$file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php' ;
}
include ( $file );
2001-07-22 01:35:22 +02:00
$header = $tpl -> fp ( 'out' , 'head' );
unset ( $tpl );
echo $header ;
2001-07-16 13:38:40 +02:00
}
function footer ()
{
2004-08-01 17:36:04 +02:00
return ;
2003-08-28 16:31:11 +02:00
$menuaction = $_GET [ 'menuaction' ];
list (,, $method ) = explode ( '.' , $menuaction );
2004-01-04 01:47:37 +01:00
2001-07-18 19:32:10 +02:00
if ( @ $this -> bo -> printer_friendly )
2001-07-16 13:38:40 +02:00
{
2004-01-04 01:47:37 +01:00
return ;
2001-07-16 13:38:40 +02:00
}
2003-08-28 16:31:11 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2004-01-04 01:47:37 +01:00
2001-08-06 04:41:36 +02:00
$p -> set_file (
Array (
2001-10-03 02:31:03 +02:00
'footer' => 'footer.tpl' ,
'form_button' => 'form_button_script.tpl'
2001-08-06 04:41:36 +02:00
)
2001-07-16 13:38:40 +02:00
);
$p -> set_block ( 'footer' , 'footer_table' , 'footer_table' );
$p -> set_block ( 'footer' , 'footer_row' , 'footer_row' );
2001-09-07 18:37:11 +02:00
$p -> set_block ( 'footer' , 'blank_row' , 'blank_row' );
2001-07-16 13:38:40 +02:00
$m = $this -> bo -> month ;
$y = $this -> bo -> year ;
2001-08-13 16:11:07 +02:00
$thisdate = date ( 'Ymd' , mktime ( 0 , 0 , 0 , $m , 1 , $y ));
2001-07-16 13:38:40 +02:00
$y -- ;
$str = '' ;
for ( $i = 0 ; $i < 25 ; $i ++ )
{
$m ++ ;
if ( $m > 12 )
{
$m = 1 ;
$y ++ ;
}
$d = mktime ( 0 , 0 , 0 , $m , 1 , $y );
2001-08-13 16:11:07 +02:00
$d_ymd = date ( 'Ymd' , $d );
$str .= '<option value="' . $d_ymd . '"' . ( $d_ymd == $thisdate ? ' selected' : '' ) . '>' . lang ( date ( 'F' , $d )) . strftime ( ' %Y' , $d ) . '</option>' . " \n " ;
2001-07-16 13:38:40 +02:00
}
$var = Array (
2001-10-03 02:31:03 +02:00
'action_url' => $this -> page ( $method , '' ),
'form_name' => 'SelectMonth' ,
'label' => lang ( 'Month' ),
'form_label' => 'date' ,
'form_onchange' => 'document.SelectMonth.submit()' ,
'row' => $str ,
'go' => lang ( 'Go!' )
2001-07-16 13:38:40 +02:00
);
$this -> output_template_array ( $p , 'table_row' , 'footer_row' , $var );
2003-08-28 16:31:11 +02:00
if ( $menuaction == 'calendar.uicalendar.week' )
2001-07-16 13:38:40 +02:00
{
2002-09-17 04:25:40 +02:00
unset ( $thisdate );
$thisdate = mktime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
$sun = $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $this -> bo -> year , $this -> bo -> month , $this -> bo -> day ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-16 13:38:40 +02:00
2002-09-17 04:25:40 +02:00
$str = '' ;
for ( $i = - 7 ; $i <= 7 ; $i ++ )
{
2003-03-09 22:05:29 +01:00
$begin = $sun + ( 7 * 24 * 60 * 60 * $i ) + 12 * 60 * 60 ; // we use midday, that changes in daylight-saveing does not effect us
$end = $begin + 6 * 24 * 60 * 60 ;
// echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end);
2004-04-19 13:41:02 +02:00
$str .= '<option value="' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $begin , 'Ymd' ) . '"' . ( $begin <= $thisdate + 12 * 60 * 60 && $end >= $thisdate + 12 * 60 * 60 ? ' selected' : '' ) . '>'
2004-01-04 01:47:37 +01:00
. $GLOBALS [ 'phpgw' ] -> common -> show_date ( $begin , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]) . ' - '
2004-04-19 13:41:02 +02:00
. $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ])
. '</option>' . " \n " ;
2002-09-17 04:25:40 +02:00
}
$var = Array (
'action_url' => $this -> page ( $method , '' ),
'form_name' => 'SelectWeek' ,
'label' => lang ( 'Week' ),
'form_label' => 'date' ,
'form_onchange' => 'document.SelectWeek.submit()' ,
'row' => $str ,
'go' => lang ( 'Go!' )
);
$this -> output_template_array ( $p , 'table_row' , 'footer_row' , $var );
}
2001-07-16 13:38:40 +02:00
$str = '' ;
2001-09-17 04:33:19 +02:00
for ( $i = ( $this -> bo -> year - 3 ); $i < ( $this -> bo -> year + 3 ); $i ++ )
2001-07-16 13:38:40 +02:00
{
2001-09-17 04:33:19 +02:00
$str .= '<option value="' . $i . '"' . ( $i == $this -> bo -> year ? ' selected' : '' ) . '>' . $i . '</option>' . " \n " ;
2001-07-16 13:38:40 +02:00
}
2002-11-23 15:19:56 +01:00
2001-07-16 13:38:40 +02:00
$var = Array (
2001-10-03 02:31:03 +02:00
'action_url' => $this -> page ( $method , '' ),
'form_name' => 'SelectYear' ,
'label' => lang ( 'Year' ),
'form_label' => 'year' ,
'form_onchange' => 'document.SelectYear.submit()' ,
'row' => $str ,
'go' => lang ( 'Go!' )
2001-07-16 13:38:40 +02:00
);
$this -> output_template_array ( $p , 'table_row' , 'footer_row' , $var );
2003-08-28 16:31:11 +02:00
if ( $menuaction == 'calendar.uicalendar.planner' )
2002-09-17 04:25:40 +02:00
{
$str = '' ;
$date_str = '' ;
2003-08-28 16:31:11 +02:00
2004-08-22 20:44:47 +02:00
if ( $this -> bo -> date )
2002-09-17 04:25:40 +02:00
{
2004-08-22 20:44:47 +02:00
$date_str .= ' ' . $this -> html -> input_hidden ( 'date' , $this -> bo -> date );
2002-09-17 04:25:40 +02:00
}
2004-08-22 20:44:47 +02:00
$date_str .= ' ' . $this -> html -> input_hidden ( 'month' , $this -> bo -> month );
$date_str .= ' ' . $this -> html -> input_hidden ( 'day' , $this -> bo -> day );
$date_str .= ' ' . $this -> html -> input_hidden ( 'year' , $this -> bo -> year );
2002-09-17 04:25:40 +02:00
for ( $i = 1 ; $i <= 6 ; $i ++ )
{
$str .= '<option value="' . $i . '"' . ( $i == $this -> bo -> num_months ? ' selected' : '' ) . '>' . $i . '</option>' . " \n " ;
}
$var = Array (
'action_url' => $this -> page ( $method , '' ),
'form_name' => 'SelectNumberOfMonths' ,
'label' => lang ( 'Number of Months' ),
2002-11-23 15:19:56 +01:00
'hidden_vars' => $date_str ,
2002-09-17 04:25:40 +02:00
'form_label' => 'num_months' ,
'form_onchange' => 'document.SelectNumberOfMonths.submit()' ,
'action_extra_field' => $date_str ,
'row' => $str ,
'go' => lang ( 'Go!' )
);
$this -> output_template_array ( $p , 'table_row' , 'footer_row' , $var );
}
2001-09-07 18:37:11 +02:00
$var = Array (
'submit_button' => lang ( 'Submit' ),
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=calendar.uiicalendar.import' ),
'action_text_button' => lang ( 'Import' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$this -> output_template_array ( $p , 'b_row' , 'form_button' , $var );
2004-07-11 20:26:28 +02:00
$p -> parse ( 'table_row' , 'blank_row' , True );
2004-07-11 19:01:23 +02:00
if ( $menuaction != 'calendar.uicalendar.view' )
{
2004-07-11 20:26:28 +02:00
switch ( $menuaction )
{
case 'calendar.uicalendar.year' :
$start_string = mktime ( 0 , 0 , 0 , 1 , 1 , $this -> bo -> year );
$stop_string = mktime ( 0 , 0 , 0 , 12 , 31 , $this -> bo -> year );
break ;
case 'calendar.uicalendar.month' :
$start_string = mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year );
$stop_string = mktime ( 0 , 0 , 0 , $this -> bo -> month + 1 , 0 , $this -> bo -> year );
break ;
case 'calendar.uicalendar.week' :
$stop_string = $start_string = mktime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year );
$stop_string += 7 * 24 * 60 * 60 - 1 ;
break ;
case 'calendar.uicalendar.day' :
$stop_string = $start_string = mktime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year );
break ;
}
$extra_field = Array (
'custom_start' => $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start_string , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]),
'custom_stop' => $GLOBALS [ 'phpgw' ] -> common -> show_date ( $stop_string , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]),
);
2004-07-11 19:01:23 +02:00
$var = Array (
'submit_button' => lang ( 'Submit' ),
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=calendar.uicalendar.export' ),
'action_text_button' => lang ( 'Export' ),
'action_confirm_button' => '' ,
'action_extra_field' => $this -> html -> input_hidden ( $extra_field )
);
2004-07-11 20:26:28 +02:00
$p -> set_var ( 'b_row' , '' );
2004-07-11 19:01:23 +02:00
$this -> output_template_array ( $p , 'b_row' , 'form_button' , $var );
2004-07-11 20:26:28 +02:00
$p -> parse ( 'table_row' , 'blank_row' , True );
2004-07-11 19:01:23 +02:00
}
2003-08-28 16:31:11 +02:00
$p -> pparse ( 'out' , 'footer_table' );
unset ( $p );
2001-07-16 13:38:40 +02:00
}
2001-08-28 05:41:16 +02:00
function css ()
{
2001-11-05 03:08:31 +01:00
$GLOBALS [ 'phpgw' ] -> browser -> browser ();
if ( $GLOBALS [ 'phpgw' ] -> browser -> get_agent () == 'MOZILLA' )
{
2004-01-04 01:47:37 +01:00
$time_width = (( int )( $this -> bo -> prefs [ 'common' ][ 'time_format' ]) == 12 ? 12 : 8 );
2001-11-05 03:08:31 +01:00
}
else
{
2004-01-04 01:47:37 +01:00
$time_width = (( int )( $this -> bo -> prefs [ 'common' ][ 'time_format' ]) == 12 ? 10 : 7 );
2001-11-05 03:08:31 +01:00
}
2004-03-10 01:18:15 +01:00
// moved to app.css in templates/default for future separation of code and style [NDEE 10.03.04]
/*
return 'A.minicalendar { color: #000000; font-size: 72%; font-family: ' . $this -> theme [ 'font' ] . ' }' . " \n "
2003-09-07 18:55:36 +02:00
. ' A.bminicalendar { color: #336699; font: italic bold x-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
2004-03-10 01:18:15 +01:00
. ' A.minicalendargrey { color: #999999; font-size: 8px; font-family: ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalendargrey { color: #336699; font-style: italic; font-size:8px; font-family ' . $this -> theme [ 'font' ] . ' }' . " \n "
2003-09-07 18:55:36 +02:00
. ' A.minicalhol { padding-left:3px; padding-right:3px; background: ' . $this -> holiday_color . '; color: #000000; font: x-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalhol { padding-left:3px; padding-right:3px; background: ' . $this -> holiday_color . '; color: #336699; font: italic bold x-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: ' . $this -> holiday_color . '; color: #999999; font: x-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: ' . $this -> holiday_color . '; color: #999999; font: italic bold x-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' .event-on { background: ' . $this -> theme [ 'row_on' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 100% ' . $this -> theme [ 'font' ] . '; vertical-align: middle }' . " \n "
. ' .event-off { background: ' . $this -> theme [ 'row_off' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 100% ' . $this -> theme [ 'font' ] . '; vertical-align: middle }' . " \n "
. ' .event-holiday { background: ' . $this -> theme [ 'bg04' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 100% ' . $this -> theme [ 'font' ] . '; vertical-align: middle }' . " \n "
2003-09-30 04:48:12 +02:00
. ' .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 "
2003-08-28 16:31:11 +02:00
. ' .tablecell { width: 80px; height: 80px }' . " \n "
. ' .planner-cell { cursor:pointer; cursor:hand; border: thin solid black; }' ;
2004-03-10 01:18:15 +01:00
*/
2001-08-28 05:41:16 +02:00
}
2001-07-28 15:17:30 +02:00
function no_edit ()
{
2002-09-20 01:45:19 +02:00
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]))
2001-10-03 02:31:03 +02:00
{
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
2003-04-21 13:00:53 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Permission denied' );
2001-10-03 02:31:03 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
}
2001-07-28 15:17:30 +02:00
echo '<center>You do not have permission to edit this appointment!</center>' ;
2001-10-03 02:31:03 +02:00
return ;
2001-07-28 15:17:30 +02:00
}
2001-07-16 13:38:40 +02:00
function link_to_entry ( $event , $month , $day , $year )
{
$str = '' ;
2002-09-17 04:25:40 +02:00
$is_private = ! $event [ 'public' ] && ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event );
2003-11-15 16:28:15 +01:00
$viewable = ! $this -> bo -> printer_friendly && $this -> bo -> check_perms ( PHPGW_ACL_READ , $event );
2001-07-16 13:38:40 +02:00
2002-08-25 06:07:21 +02:00
$starttime = $this -> bo -> maketime ( $event [ 'start' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
$endtime = $this -> bo -> maketime ( $event [ 'end' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-16 13:38:40 +02:00
$rawdate = mktime ( 0 , 0 , 0 , $month , $day , $year );
2002-08-25 06:07:21 +02:00
$rawdate_offset = $rawdate - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
$nextday = mktime ( 0 , 0 , 0 , $month , $day + 1 , $year ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2004-01-04 01:47:37 +01:00
if (( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $starttime , 'Hi' ) && $starttime == $endtime )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
$time = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $starttime , $this -> bo -> users_timeformat );
2001-07-16 13:38:40 +02:00
}
elseif ( $starttime <= $rawdate_offset && $endtime >= $nextday - 60 )
{
$time = '[ ' . lang ( 'All Day' ) . ' ]' ;
}
2004-01-04 01:47:37 +01:00
elseif (( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $starttime , 'Hi' ) || $starttime != $endtime )
2001-07-16 13:38:40 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $starttime < $rawdate_offset && $event [ 'recur_type' ] == MCAL_RECUR_NONE )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
$start_time = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $rawdate_offset , $this -> bo -> users_timeformat );
2001-07-16 13:38:40 +02:00
}
else
{
2001-08-12 16:47:23 +02:00
$start_time = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $starttime , $this -> bo -> users_timeformat );
2001-07-16 13:38:40 +02:00
}
if ( $endtime >= ( $rawdate_offset + 86400 ))
{
2002-08-25 06:07:21 +02:00
$end_time = $GLOBALS [ 'phpgw' ] -> common -> show_date ( mktime ( 23 , 59 , 59 , $month , $day , $year ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset , $this -> bo -> users_timeformat );
2001-07-16 13:38:40 +02:00
}
else
{
2001-08-12 16:47:23 +02:00
$end_time = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $endtime , $this -> bo -> users_timeformat );
2001-07-16 13:38:40 +02:00
}
$time = $start_time . '-' . $end_time ;
}
else
{
$time = '' ;
}
2004-01-08 13:33:20 +01:00
$texttitle = $texttime = $textdesc = $textlocation = $textstatus = '' ;
2003-11-15 16:28:15 +01:00
2004-01-08 13:33:20 +01:00
2001-07-16 13:38:40 +02:00
if ( ! $is_private )
{
2004-01-08 13:33:20 +01:00
//$text .= $this->bo->display_status($event['users_status']);
// split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation
$textstatus = $this -> bo -> display_status ( $event [ 'users_status' ]);
2001-07-16 13:38:40 +02:00
}
2004-01-08 13:33:20 +01:00
/*
2003-11-15 16:28:15 +01:00
$text = '<nobr> ' . $time . ' </nobr> ' . $this -> bo -> get_short_field ( $event , $is_private , 'title' ) . $text .
2004-01-08 13:33:20 +01:00
( ! $is_private && $event [ 'description' ] ? ': <i>' . $this -> bo -> get_short_field ( $event , $is_private , 'description' ) . '</i>' : '' ) .
2003-11-15 16:28:15 +01:00
$GLOBALS [ 'phpgw' ] -> browser -> br ;
2004-01-08 13:33:20 +01:00
*/
$texttime = $time ;
$texttitle = $this -> bo -> get_short_field ( $event , $is_private , 'title' );
$textdesc = ( ! $is_private && $event [ 'description' ] ? $this -> bo -> get_short_field ( $event , $is_private , 'description' ) : '' );
// added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set
$textlocation = $this -> bo -> get_short_field ( $event , $is_private , 'location' );
2002-04-19 16:02:31 +02:00
2003-11-15 16:28:15 +01:00
if ( $viewable )
2001-07-16 13:38:40 +02:00
{
2001-08-27 03:30:40 +02:00
$date = sprintf ( '%04d%02d%02d' , $year , $month , $day );
2002-06-25 01:24:24 +02:00
$this -> link_tpl -> set_var ( 'link_link' , $this -> page ( 'view' , '&cal_id=' . $event [ 'id' ] . '&date=' . $date ));
$this -> link_tpl -> set_var ( 'lang_view' , lang ( 'View this entry' ));
2004-08-01 16:16:46 +02:00
$this -> link_tpl -> set_var ( 'tooltip' , $this -> event_tooltip ( $event ));
// quoting title, describtion and location for wz_tooltips
2002-06-25 01:24:24 +02:00
$this -> link_tpl -> parse ( 'picture' , 'link_open' , True );
2003-11-15 16:28:15 +01:00
}
if ( ! $is_private )
{
2001-07-30 00:09:24 +02:00
if ( $event [ 'priority' ] == 3 )
2001-07-16 13:38:40 +02:00
{
$picture [] = Array (
2002-02-17 04:56:58 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'high' ),
2003-11-18 11:59:13 +01:00
'width' => 16 ,
'height' => 16 ,
2002-09-17 04:25:40 +02:00
'title' => lang ( 'high priority' )
2001-07-16 13:38:40 +02:00
);
}
2001-07-30 00:09:24 +02:00
if ( $event [ 'recur_type' ] == MCAL_RECUR_NONE )
2001-07-16 13:38:40 +02:00
{
$picture [] = Array (
2002-02-17 04:56:58 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'circle' ),
2003-11-18 11:59:13 +01:00
'width' => 9 ,
'height' => 9 ,
2002-09-17 04:25:40 +02:00
'title' => lang ( 'single event' )
2001-07-16 13:38:40 +02:00
);
}
else
{
$picture [] = Array (
2002-02-17 04:56:58 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'recur' ),
2001-07-16 13:38:40 +02:00
'width' => 12 ,
2002-09-17 04:25:40 +02:00
'height' => 12 ,
'title' => lang ( 'recurring event' )
2001-07-16 13:38:40 +02:00
);
}
2003-11-15 16:28:15 +01:00
}
$participants = $this -> planner_participants ( $event [ 'participants' ]);
if ( count ( $event [ 'participants' ]) > 1 )
{
$picture [] = Array (
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'multi_3' ),
'width' => 14 ,
'height' => 14 ,
'title' => $participants
);
}
else
{
$picture [] = Array (
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'single' ),
'width' => 14 ,
'height' => 14 ,
'title' => $participants
);
}
if ( $event [ 'public' ] == 0 )
{
$picture [] = Array (
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'private' ),
'width' => 13 ,
'height' => 13 ,
'title' => lang ( 'private' )
);
}
if ( @ isset ( $event [ 'alarm' ]) && count ( $event [ 'alarm' ]) >= 1 && ! $is_private )
{
// if the alarm is to go off the day before the event
// the icon does not show up because of 'alarm_today'
// - TOM
if ( $this -> bo -> alarm_today ( $event , $rawdate_offset , $starttime ))
2001-07-16 13:38:40 +02:00
{
$picture [] = Array (
2004-01-04 01:47:37 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'alarm' ),
'width' => 13 ,
2002-09-17 04:25:40 +02:00
'height' => 13 ,
2003-11-15 16:28:15 +01:00
'title' => lang ( 'alarm' )
2001-07-16 13:38:40 +02:00
);
}
2003-11-15 16:28:15 +01:00
}
2001-09-08 10:48:38 +02:00
2003-11-15 16:28:15 +01:00
$description = $this -> bo -> get_short_field ( $event , $is_private , 'description' );
for ( $i = 0 ; $i < count ( $picture ); $i ++ )
{
$var = Array (
2004-01-04 01:47:37 +01:00
'pic_image' => $picture [ $i ][ 'pict' ],
'width' => $picture [ $i ][ 'width' ],
'height' => $picture [ $i ][ 'height' ],
'title' => $picture [ $i ][ 'title' ]
2003-11-15 16:28:15 +01:00
);
$this -> output_template_array ( $this -> link_tpl , 'picture' , 'pict' , $var );
2001-07-16 13:38:40 +02:00
}
2004-01-08 13:33:20 +01:00
if ( $texttitle )
2001-07-16 13:38:40 +02:00
{
$var = Array (
2004-01-08 13:33:20 +01:00
// 'text' => $text,
'time' => $texttime ,
'title' => $texttitle ,
'users_status' => $textstatus ,
'desc' => $textdesc ,
'location' => $textlocation
2001-07-16 13:38:40 +02:00
);
2002-06-25 01:24:24 +02:00
$this -> output_template_array ( $this -> link_tpl , 'picture' , 'link_text' , $var );
2001-07-16 13:38:40 +02:00
}
2003-11-15 16:28:15 +01:00
if ( $viewable )
2001-07-16 13:38:40 +02:00
{
2002-06-25 01:24:24 +02:00
$this -> link_tpl -> parse ( 'picture' , 'link_close' , True );
2001-07-16 13:38:40 +02:00
}
2004-07-16 14:28:15 +02:00
//NDEE(160704) for event tooltips
$this -> link_tpl -> set_var ( 'loctitle' , lang ( 'location' ));
2002-06-25 01:24:24 +02:00
$str = $this -> link_tpl -> fp ( 'out' , 'link_pict' );
2004-01-04 01:47:37 +01:00
$this -> link_tpl -> set_var ( 'picture' , '' );
2002-06-25 01:24:24 +02:00
$this -> link_tpl -> set_var ( 'out' , '' );
// unset($p);
2001-07-16 13:38:40 +02:00
return $str ;
}
2001-09-21 04:10:00 +02:00
function overlap ( $params )
2001-07-28 15:17:30 +02:00
{
2001-09-21 04:10:00 +02:00
if ( ! is_array ( $params ))
{
}
else
{
$overlapping_events = $params [ 'o_events' ];
$event = $params [ 'this_event' ];
}
2001-10-03 02:31:03 +02:00
$month = $event [ 'start' ][ 'month' ];
$mday = $event [ 'start' ][ 'mday' ];
$year = $event [ 'start' ][ 'year' ];
2001-07-28 15:17:30 +02:00
2002-08-25 06:07:21 +02:00
$start = mktime ( $event [ 'start' ][ 'hour' ], $event [ 'start' ][ 'min' ], $event [ 'start' ][ 'sec' ], $month , $mday , $year ) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
$end = $this -> bo -> maketime ( $event [ 'end' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-28 15:17:30 +02:00
$overlap = '' ;
for ( $i = 0 ; $i < count ( $overlapping_events ); $i ++ )
{
2003-11-03 20:51:04 +01:00
$overlapped_event = $this -> bo -> read_entry ( $overlapping_events [ $i ], True );
$overlap .= '<li>' . $this -> link_to_entry ( $overlapped_event , $month , $mday , $year );
$overlap .= '<ul>' ;
foreach ( $overlapped_event [ 'participants' ] as $id => $status )
{
$conflict = isset ( $event [ 'participants' ][ $id ]);
$overlap .= '<li>' . ( $conflict ? '<b>' : '' ) .
$GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $id ) .
( $conflict ? '</b> - ' . lang ( 'Scheduling conflict' ) : '' ) . " </li> \n " ;
}
$overlap .= " </ul> \n " ;
2001-07-28 15:17:30 +02:00
}
2001-08-12 16:47:23 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
2001-09-07 20:11:38 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
2003-04-21 13:00:53 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'title' ] . ' - ' . lang ( 'Scheduling Conflict' );
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-28 15:17:30 +02:00
2003-04-21 13:00:53 +02:00
$p = $GLOBALS [ 'phpgw' ] -> template ;
2001-07-28 15:17:30 +02:00
$p -> set_file (
2001-10-03 02:31:03 +02:00
Array (
'overlap' => 'overlap.tpl' ,
'form_button' => 'form_button_script.tpl'
)
2001-07-28 15:17:30 +02:00
);
$var = Array (
2001-10-03 02:31:03 +02:00
'color' => $this -> theme [ 'bg_text' ],
'overlap_title' => lang ( 'Scheduling Conflict' ),
2003-02-27 23:57:55 +01:00
'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 )),
2001-10-03 02:31:03 +02:00
'overlap_list' => $overlap
2001-07-28 15:17:30 +02:00
);
$p -> set_var ( $var );
2002-09-17 04:25:40 +02:00
$date = sprintf ( " %04d%02d%02d " , $this -> bo -> year , $this -> bo -> month , $this -> bo -> mday );
2001-07-28 15:17:30 +02:00
$var = Array (
2001-08-12 16:47:23 +02:00
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , Array ( 'menuaction' => 'calendar.bocalendar.update' , 'readsess' => 1 )),
2001-07-28 15:17:30 +02:00
'action_text_button' => lang ( 'Ignore Conflict' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$this -> output_template_array ( $p , 'resubmit_button' , 'form_button' , $var );
$var = Array (
2001-08-12 16:47:23 +02:00
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , Array ( 'menuaction' => 'calendar.uicalendar.edit' , 'readsess' => 1 , 'date' => $date )),
2001-07-28 15:17:30 +02:00
'action_text_button' => lang ( 'Re-Edit Event' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
2001-08-06 04:41:36 +02:00
$this -> output_template_array ( $p , 'reedit_button' , 'form_button' , $var );
2001-07-28 15:17:30 +02:00
$p -> pparse ( 'out' , 'overlap' );
}
function planner_participants ( $parts )
{
2001-08-17 02:24:20 +02:00
static $id2lid ;
2004-01-04 01:47:37 +01:00
2001-07-28 15:17:30 +02:00
$names = '' ;
while ( list ( $id , $status ) = each ( $parts ))
{
2002-11-23 15:19:56 +01:00
$status = substr ( $this -> bo -> get_long_status ( $status ), 0 , 1 );
2004-01-04 01:47:37 +01:00
2001-07-28 15:17:30 +02:00
if ( ! isset ( $id2lid [ $id ]))
{
2001-08-12 16:47:23 +02:00
$id2lid [ $id ] = $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $id );
2001-07-28 15:17:30 +02:00
}
if ( strlen ( $names ))
{
$names .= " , \n " ;
}
$names .= $id2lid [ $id ] . " ( $status ) " ;
}
if ( $this -> debug )
{
2002-04-16 18:52:36 +02:00
echo '<!-- Inside participants() : ' . $names . ' -->' . " \n " ;
2001-07-28 15:17:30 +02:00
}
return $names ;
}
2004-01-04 01:47:37 +01:00
2001-09-29 03:40:47 +02:00
function planner_category ( $ids )
2001-07-28 15:17:30 +02:00
{
2001-08-17 02:24:20 +02:00
static $cats ;
2001-09-29 03:40:47 +02:00
if ( ! is_array ( $ids ))
2001-07-28 15:17:30 +02:00
{
2001-09-29 03:40:47 +02:00
if ( strpos ( $ids , ',' ))
{
2003-08-28 16:31:11 +02:00
$id_array = explode ( ',' , $ids );
2001-09-29 03:40:47 +02:00
}
else
{
2003-08-28 16:31:11 +02:00
$id_array [ 0 ] = $ids ;
2001-09-29 03:40:47 +02:00
}
}
$ret_val = Array ();
2004-05-26 12:16:46 +02:00
foreach ( $id_array as $id )
2001-09-29 03:40:47 +02:00
{
if ( ! isset ( $cats [ $id ]))
{
2004-05-26 12:16:46 +02:00
list ( $cat ) = $this -> cat -> return_single ( $id );
$cat [ 'data' ] = unserialize ( $cat [ 'data' ]);
$cat [ 'color' ] = $cat [ 'data' ][ 'color' ] ? $cat [ 'data' ][ 'color' ] : strstr ( $cat [ 'description' ], '#' );
$cats [ $id ] = $cat ;
2001-09-29 03:40:47 +02:00
}
$ret_val [] = $cats [ $id ];
2003-08-28 16:31:11 +02:00
}
2001-10-01 04:34:45 +02:00
return $ret_val ;
2001-07-28 15:17:30 +02:00
}
2001-07-16 13:38:40 +02:00
function week_header ( $month , $year , $display_name = False )
{
2002-06-25 01:24:24 +02:00
$this -> weekstarttime = $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $year , $month , 1 );
2001-07-16 13:38:40 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_unknowns ( 'remove' );
2001-07-28 15:17:30 +02:00
$p -> set_file (
2001-10-03 02:31:03 +02:00
Array (
'month_header' => 'month_header.tpl'
)
2001-07-16 13:38:40 +02:00
);
$p -> set_block ( 'month_header' , 'monthly_header' , 'monthly_header' );
$p -> set_block ( 'month_header' , 'column_title' , 'column_title' );
2002-08-25 06:07:21 +02:00
2001-07-16 13:38:40 +02:00
$var = Array (
2003-08-28 16:31:11 +02:00
'bgcolor' => $this -> theme [ 'th_bg' ],
2001-08-13 16:11:07 +02:00
'font_color' => $this -> theme [ 'th_text' ]
2001-07-16 13:38:40 +02:00
);
2001-07-18 19:32:10 +02:00
if ( $this -> bo -> printer_friendly && @ $this -> bo -> prefs [ 'calendar' ][ 'print_black_white' ])
2001-07-16 13:38:40 +02:00
{
$var = Array (
2003-08-28 16:31:11 +02:00
'bgcolor' => '' ,
2001-07-16 13:38:40 +02:00
'font_color' => ''
);
}
$p -> set_var ( $var );
2002-04-18 01:43:29 +02:00
2001-07-16 13:38:40 +02:00
$p -> set_var ( 'col_width' , '14' );
if ( $display_name == True )
{
$p -> set_var ( 'col_title' , lang ( 'name' ));
$p -> parse ( 'column_header' , 'column_title' , True );
2003-08-28 16:31:11 +02:00
$p -> set_var ( 'col_width' , '12' );
2001-07-16 13:38:40 +02:00
}
2002-08-25 06:07:21 +02:00
2001-07-16 13:38:40 +02:00
for ( $i = 0 ; $i < 7 ; $i ++ )
{
2003-08-28 16:31:11 +02:00
$p -> set_var ( 'col_title' , lang ( $GLOBALS [ 'phpgw' ] -> datetime -> days [ $i ]));
$p -> parse ( 'column_header' , 'column_title' , True );
2001-07-16 13:38:40 +02:00
}
return $p -> fp ( 'out' , 'monthly_header' );
}
function display_week ( $startdate , $weekly , $cellcolor , $display_name = False , $owner = 0 , $monthstart = 0 , $monthend = 0 )
{
2002-04-18 01:43:29 +02:00
if ( $owner == 0 )
{
$owner = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ];
}
2001-07-16 13:38:40 +02:00
2001-07-18 19:32:10 +02:00
$temp_owner = $this -> bo -> owner ;
2001-07-16 13:38:40 +02:00
$str = '' ;
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_unknowns ( 'keep' );
2004-01-04 01:47:37 +01:00
2001-07-28 15:17:30 +02:00
$p -> set_file (
2003-08-28 16:31:11 +02:00
Array (
2002-05-05 19:47:15 +02:00
'month_header' => 'month_header.tpl' ,
2003-08-28 16:31:11 +02:00
'month_day' => 'month_day.tpl'
)
2002-08-25 06:07:21 +02:00
);
2004-07-11 20:26:28 +02:00
$p -> set_block ( 'month_header' , 'monthly_row' , 'monthly_row' );
2001-07-16 13:38:40 +02:00
$p -> set_block ( 'month_header' , 'month_column' , 'month_column' );
2004-08-19 13:09:26 +02:00
$p -> set_block ( 'month_header' , 'column_title' , 'column_title' );
2001-07-16 13:38:40 +02:00
$p -> set_block ( 'month_day' , 'month_daily' , 'month_daily' );
$p -> set_block ( 'month_day' , 'day_event' , 'day_event' );
$p -> set_block ( 'month_day' , 'event' , 'event' );
2003-08-28 16:31:11 +02:00
2001-07-16 13:38:40 +02:00
$p -> set_var ( 'extra' , '' );
$p -> set_var ( 'col_width' , '14' );
if ( $display_name )
{
2004-08-19 13:09:26 +02:00
$p -> set_var ( 'col_title' , $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $owner ));
$p -> parse ( 'column_row' , 'column_title' , True );
2001-07-16 13:38:40 +02:00
$p -> set_var ( 'col_width' , '12' );
}
2002-06-25 01:24:24 +02:00
$today = date ( 'Ymd' , $GLOBALS [ 'phpgw' ] -> datetime -> users_localtime );
2002-08-25 06:07:21 +02:00
$daily = $this -> set_week_array ( $startdate - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset , $cellcolor , $weekly );
2003-08-28 16:31:11 +02:00
foreach ( $daily as $date => $day_params )
2001-07-16 13:38:40 +02:00
{
2004-01-04 01:47:37 +01:00
$year = ( int ) substr ( $date , 0 , 4 );
$month = ( int ) substr ( $date , 4 , 2 );
$day = ( int ) substr ( $date , 6 , 2 );
$var = Array (
'column_data' => '' ,
'extra' => ''
2001-07-16 13:38:40 +02:00
);
$p -> set_var ( $var );
if ( $weekly || ( $date >= $monthstart && $date <= $monthend ))
{
if ( $day_params [ 'new_event' ])
{
2002-11-23 15:19:56 +01:00
$new_event_link = ' <a href="' . $this -> page ( 'add' , '&date=' . $date ) . '">'
2003-11-18 11:59:13 +01:00
. '<img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'new3' ) . '" width="10" height="10" title="' . lang ( 'New Entry' ) . '" border="0" align="center">'
2001-07-16 13:38:40 +02:00
. '</a>' ;
2001-08-12 16:47:23 +02:00
$day_number = '<a href="' . $this -> page ( 'day' , '&date=' . $date ) . '">' . $day . '</a>' ;
2001-07-16 13:38:40 +02:00
}
else
{
$new_event_link = '' ;
$day_number = $day ;
}
$var = Array (
2001-10-03 02:31:03 +02:00
'extra' => $day_params [ 'extra' ],
'new_event_link' => $new_event_link ,
'day_number' => $day_number
2001-07-16 13:38:40 +02:00
);
2002-11-23 15:19:56 +01:00
if ( $day_params [ 'week' ])
{
2004-03-15 00:14:41 +01:00
//NDEE: style! m_w_table in month_day.tpl
// week-hilite
//$var['new_event_link'] .= '<font size="-2"> '.
$var [ 'new_event_link' ] .= ' ' .
( ! $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>' );
2002-11-23 15:19:56 +01:00
}
2001-07-16 13:38:40 +02:00
$p -> set_var ( $var );
2004-01-04 01:47:37 +01:00
2001-08-13 16:11:07 +02:00
if ( @ $day_params [ 'holidays' ])
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
foreach ( $day_params [ 'holidays' ] as $key => $value )
2001-07-16 13:38:40 +02:00
{
$var = Array (
2001-08-13 16:11:07 +02:00
'day_events' => '<font face="' . $this -> theme [ 'font' ] . '" size="-1">' . $value . '</font>' . $GLOBALS [ 'phpgw' ] -> browser -> br
2001-07-16 13:38:40 +02:00
);
$this -> output_template_array ( $p , 'daily_events' , 'event' , $var );
}
}
if ( $day_params [ 'appts' ])
{
$var = Array (
2001-10-03 02:31:03 +02:00
'week_day_font_size' => '2' ,
'events' => ''
2001-07-16 13:38:40 +02:00
);
$p -> set_var ( $var );
2003-08-28 16:31:11 +02:00
$events = $this -> bo -> cached_events [ $date ];
foreach ( $events as $event )
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
if ( $this -> bo -> rejected_no_show ( $event ))
{
continue ; // user does not want to see rejected events
}
$p -> set_var ( 'day_events' , $this -> link_to_entry ( $event , $month , $day , $year ));
2001-07-16 13:38:40 +02:00
$p -> parse ( 'events' , 'event' , True );
$p -> set_var ( 'day_events' , '' );
}
}
$p -> parse ( 'daily_events' , 'day_event' , True );
$p -> parse ( 'column_data' , 'month_daily' , True );
$p -> set_var ( 'daily_events' , '' );
$p -> set_var ( 'events' , '' );
2002-11-23 15:19:56 +01:00
/* if ( $day_params [ 'week' ])
2001-07-16 13:38:40 +02:00
{
$var = Array (
2001-10-03 02:31:03 +02:00
'week_day_font_size' => '-2' ,
'events' => ( ! $this -> bo -> printer_friendly ? '<a href="' . $this -> page ( 'week' , '&date=' . $date ) . '">' . $day_params [ 'week' ] . '</a>' : $day_params [ 'week' ])
2001-07-16 13:38:40 +02:00
);
$this -> output_template_array ( $p , 'column_data' , 'day_event' , $var );
$p -> set_var ( 'events' , '' );
2002-11-23 15:19:56 +01:00
} */
2001-07-16 13:38:40 +02:00
}
2004-07-11 20:26:28 +02:00
$p -> parse ( 'column_row' , 'month_column' , True );
2001-07-16 13:38:40 +02:00
$p -> set_var ( 'column_data' , '' );
}
2001-07-18 19:32:10 +02:00
$this -> bo -> owner = $temp_owner ;
2004-07-11 20:26:28 +02:00
return $p -> fp ( 'out' , 'monthly_row' );
2001-07-16 13:38:40 +02:00
}
2004-01-04 01:47:37 +01:00
2001-07-16 13:38:40 +02:00
function display_month ( $month , $year , $showyear , $owner = 0 )
{
2002-04-16 18:52:36 +02:00
if ( $this -> debug )
{
2002-06-25 01:24:24 +02:00
echo '<!-- datetime:gmtdate = ' . $GLOBALS [ 'phpgw' ] -> datetime -> cv_gmtdate . ' -->' . " \n " ;
2002-04-16 18:52:36 +02:00
}
2001-08-13 03:34:32 +02:00
$this -> bo -> store_to_cache (
Array (
'syear' => $year ,
2001-10-03 02:31:03 +02:00
'smonth' => $month ,
2001-08-13 03:34:32 +02:00
'sday' => 1
)
);
2001-07-16 13:38:40 +02:00
2004-01-04 01:47:37 +01:00
$monthstart = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $month , 1 , $year )));
$monthend = ( int )( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $month + 1 , 0 , $year )));
2001-07-16 13:38:40 +02:00
2002-06-25 01:24:24 +02:00
$start = $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $year , $month , 1 );
2002-04-16 18:52:36 +02:00
if ( $this -> debug )
{
echo '<!-- display_month:monthstart = ' . $monthstart . ' -->' . " \n " ;
echo '<!-- display_month:start = ' . date ( 'Ymd H:i:s' , $start ) . ' -->' . " \n " ;
}
2001-07-16 13:38:40 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_unknowns ( 'keep' );
2004-01-04 01:47:37 +01:00
2001-07-28 15:17:30 +02:00
$p -> set_file (
2001-10-03 02:31:03 +02:00
Array (
2004-01-04 01:47:37 +01:00
'week' => 'month_day.tpl'
)
2001-10-03 02:31:03 +02:00
);
2001-07-16 13:38:40 +02:00
$p -> set_block ( 'week' , 'm_w_table' , 'm_w_table' );
$p -> set_block ( 'week' , 'event' , 'event' );
2001-10-03 02:31:03 +02:00
$var = Array (
'cols' => 7 ,
'day_events' => $this -> week_header ( $month , $year , False )
);
2001-07-28 15:17:30 +02:00
$this -> output_template_array ( $p , 'row' , 'event' , $var );
2001-07-16 13:38:40 +02:00
2001-08-13 16:11:07 +02:00
$cellcolor = $this -> theme [ 'row_on' ];
2001-07-16 13:38:40 +02:00
2004-01-04 01:47:37 +01:00
for ( $i = ( int )( $start + $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset );( int )( date ( 'Ymd' , $i )) <= $monthend ; $i += 604800 )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
$cellcolor = $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color ( $cellcolor );
2001-07-16 13:38:40 +02:00
$var = Array (
'day_events' => $this -> display_week ( $i , False , $cellcolor , False , $owner , $monthstart , $monthend )
);
$this -> output_template_array ( $p , 'row' , 'event' , $var );
}
return $p -> fp ( 'out' , 'm_w_table' );
}
2001-08-12 16:47:23 +02:00
function display_weekly ( $params )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
if ( ! is_array ( $params ))
{
$this -> index ();
}
2001-07-16 13:38:40 +02:00
2001-08-12 16:47:23 +02:00
$year = substr ( $params [ 'date' ], 0 , 4 );
$month = substr ( $params [ 'date' ], 4 , 2 );
2001-08-13 16:11:07 +02:00
$day = substr ( $params [ 'date' ], 6 , 2 );
2001-08-12 16:47:23 +02:00
$showyear = $params [ 'showyear' ];
$owners = $params [ 'owners' ];
2004-01-04 01:47:37 +01:00
2001-07-16 13:38:40 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_unknowns ( 'keep' );
2001-07-28 15:17:30 +02:00
$p -> set_file (
2001-10-03 02:31:03 +02:00
Array (
'week' => 'month_day.tpl'
)
2001-07-16 13:38:40 +02:00
);
$p -> set_block ( 'week' , 'm_w_table' , 'm_w_table' );
$p -> set_block ( 'week' , 'event' , 'event' );
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
$start = $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $year , $month , $day ) + $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-16 13:38:40 +02:00
2001-08-13 16:11:07 +02:00
$cellcolor = $this -> theme [ 'row_off' ];
2001-07-16 13:38:40 +02:00
2001-07-18 19:32:10 +02:00
$true_printer_friendly = $this -> bo -> printer_friendly ;
2001-07-16 13:38:40 +02:00
if ( is_array ( $owners ))
{
$display_name = True ;
$counter = count ( $owners );
$owners_array = $owners ;
2001-07-28 15:17:30 +02:00
$cols = 8 ;
2001-07-16 13:38:40 +02:00
}
else
{
$display_name = False ;
$counter = 1 ;
$owners_array [ 0 ] = $owners ;
2001-07-28 15:17:30 +02:00
$cols = 7 ;
2001-07-16 13:38:40 +02:00
}
2001-07-28 15:17:30 +02:00
$var = Array (
2004-01-04 01:47:37 +01:00
'cols' => $cols ,
'day_events' => $this -> week_header ( $month , $year , $display_name )
2001-10-03 02:31:03 +02:00
);
2001-07-28 15:17:30 +02:00
$this -> output_template_array ( $p , 'row' , 'event' , $var );
2001-07-16 13:38:40 +02:00
2003-08-28 16:31:11 +02:00
$tstart = $start - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
$tstop = $tstart + 604800 ;
2001-08-24 13:14:40 +02:00
$original_owner = $this -> bo -> so -> owner ;
2001-07-16 13:38:40 +02:00
for ( $i = 0 ; $i < $counter ; $i ++ )
{
2001-08-24 13:14:40 +02:00
$this -> bo -> so -> owner = $owners_array [ $i ];
2003-08-28 16:31:11 +02:00
$this -> bo -> so -> open_box ( $owners_array [ $i ]);
2001-08-13 03:34:32 +02:00
$this -> bo -> store_to_cache (
Array (
2003-08-28 16:31:11 +02:00
'syear' => date ( 'Y' , $tstart ),
'smonth' => date ( 'm' , $tstart ),
'sday' => date ( 'd' , $tstart ),
'eyear' => date ( 'Y' , $tstop ),
'emonth' => date ( 'm' , $tstop ),
'eday' => date ( 'd' , $tstop )
2001-08-13 03:34:32 +02:00
)
);
2001-07-16 13:38:40 +02:00
$p -> set_var ( 'day_events' , $this -> display_week ( $start , True , $cellcolor , $display_name , $owners_array [ $i ]));
$p -> parse ( 'row' , 'event' , True );
}
2001-08-24 13:14:40 +02:00
$this -> bo -> so -> owner = $original_owner ;
2001-07-18 19:32:10 +02:00
$this -> bo -> printer_friendly = $true_printer_friendly ;
2001-07-16 13:38:40 +02:00
return $p -> fp ( 'out' , 'm_w_table' );
}
2001-10-26 01:52:15 +02:00
function view_event ( $event , $alarms = False )
2001-07-16 13:38:40 +02:00
{
2002-09-17 04:25:40 +02:00
if (( ! $event [ 'participants' ][ $this -> bo -> owner ] && ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event )))
2001-08-01 13:07:04 +02:00
{
2003-04-21 13:00:53 +02:00
return False ;
2001-08-01 13:07:04 +02:00
}
2003-04-21 13:00:53 +02:00
$p = & $GLOBALS [ 'phpgw' ] -> template ;
2001-07-16 13:38:40 +02:00
2001-07-28 15:17:30 +02:00
$p -> set_file (
2001-10-03 02:31:03 +02:00
Array (
2003-08-28 16:31:11 +02:00
'view' => 'view.tpl'
)
2001-10-03 02:31:03 +02:00
);
2001-07-16 13:38:40 +02:00
$p -> set_block ( 'view' , 'view_event' , 'view_event' );
$p -> set_block ( 'view' , 'list' , 'list' );
2001-09-04 05:17:49 +02:00
$p -> set_block ( 'view' , 'hr' , 'hr' );
2001-07-16 13:38:40 +02:00
2003-08-28 16:31:11 +02:00
$vars = $this -> bo -> event2array ( $event );
$vars [ 'title' ][ 'tr_color' ] = $this -> theme [ 'th_bg' ];
2001-07-16 13:38:40 +02:00
2004-08-19 17:38:01 +02:00
if ( isset ( $vars [ 'participants' ][ 'data' ]) && is_array ( $vars [ 'participants' ][ 'data' ]))
2001-07-16 13:38:40 +02:00
{
2004-08-19 17:38:01 +02:00
foreach ( $vars [ 'participants' ][ 'data' ] as $user => $str )
2001-07-16 13:38:40 +02:00
{
2004-08-19 17:38:01 +02:00
if ( $this -> bo -> check_perms ( PHPGW_ACL_EDIT , 0 , $user ) && ereg ( '^(.*) \((.*)\)$' , $str , $parts ))
{
$vars [ 'participants' ][ 'data' ][ $user ] = $parts [ 1 ] . ' (<a href="' . $this -> page ( 'edit_status' , '&cal_id=' . $event [ 'id' ] . '&owner=' . $user ) . '">' . $parts [ 2 ] . '</a>)' ;
}
2001-07-16 13:38:40 +02:00
}
2004-08-19 17:38:01 +02:00
$vars [ 'participants' ][ 'data' ] = implode ( " <br> \n " , $vars [ 'participants' ][ 'data' ]);
2001-07-16 13:38:40 +02:00
}
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
foreach ( $vars as $var )
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
if ( strlen ( $var [ 'data' ]))
2001-07-16 13:38:40 +02:00
{
2003-08-28 16:31:11 +02:00
$this -> output_template_array ( $p , 'row' , 'list' , $var );
2001-07-16 13:38:40 +02:00
}
}
2003-08-28 16:31:11 +02:00
if ( $alarms && count ( $event [ 'alarm' ]))
2001-09-04 05:17:49 +02:00
{
2003-08-28 16:31:11 +02:00
$p -> set_var ( 'th_bg' , $this -> theme [ 'th_bg' ]);
2003-04-21 13:00:53 +02:00
$p -> set_var ( 'hr_text' , lang ( 'Alarms' ));
2001-09-04 05:17:49 +02:00
$p -> parse ( 'row' , 'hr' , True );
2003-04-21 13:00:53 +02:00
foreach ( $event [ 'alarm' ] as $key => $alarm )
2001-09-04 05:17:49 +02:00
{
2002-09-19 04:14:41 +02:00
$icon = '<img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' ,( $alarm [ 'enabled' ] ? 'enabled' : 'disabled' )) . '" width="13" height="13">' ;
2001-09-04 05:17:49 +02:00
$var = Array (
2004-02-22 21:23:52 +01:00
'field' => $icon . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $alarm [ 'time' ]),
2003-09-11 14:01:16 +02:00
'data' => lang ( 'Email Notification for %1' , $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $alarm [ 'owner' ]))
2001-09-04 05:17:49 +02:00
);
$this -> output_template_array ( $p , 'row' , 'list' , $var );
}
}
2003-04-21 13:00:53 +02:00
return True ;
2001-07-16 13:38:40 +02:00
}
2001-07-18 19:32:10 +02:00
2003-04-12 21:21:22 +02:00
function nm_on_off ()
{
2003-08-28 16:31:11 +02:00
if ( $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color () == $this -> theme [ 'row_on' ])
2003-04-12 21:21:22 +02:00
{
return '_on' ;
}
return '_off' ;
}
2003-08-28 16:31:11 +02:00
function slot_num ( $time , $set_day_start = 0 , $set_day_end = 0 )
{
static $day_start , $day_end , $interval = 0 ;
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
if ( $set_day_start ) $day_start = $set_day_start ;
if ( $set_day_end ) $day_end = $set_day_end ;
if ( ! $interval ) $interval = 60 * $this -> bo -> prefs [ 'calendar' ][ 'interval' ];
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
if ( $time > $day_end )
{
$time = $day_end ;
}
2004-01-04 01:47:37 +01:00
$slot = ( int )(( $time - $day_start ) / $interval );
2003-08-28 16:31:11 +02:00
return $slot < 0 ? 0 : 1 + $slot ;
}
2004-01-04 01:47:37 +01:00
2001-08-13 16:11:07 +02:00
function print_day ( $params )
2001-07-18 19:32:10 +02:00
{
2001-08-13 16:11:07 +02:00
if ( ! is_array ( $params ))
2001-08-12 16:47:23 +02:00
{
$this -> index ();
}
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02:00
print_debug ( 'in print_day()' );
2001-11-03 02:52:26 +01:00
2001-08-13 03:34:32 +02:00
$this -> bo -> store_to_cache (
Array (
2003-08-28 16:31:11 +02:00
'syear' => $params [ 'year' ],
'smonth' => $params [ 'month' ],
'sday' => $params [ 'day' ],
'eyear' => $params [ 'year' ],
'emonth' => $params [ 'month' ],
'eday' => $params [ 'day' ]
2001-08-13 03:34:32 +02:00
)
);
2001-07-18 19:32:10 +02:00
2003-04-27 09:27:05 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
2001-07-18 19:32:10 +02:00
$p -> set_unknowns ( 'keep' );
2003-12-01 18:42:23 +01:00
$tpl = 'day_cal.tpl' ;
2003-12-23 06:28:36 +01:00
if (( int )( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'calendar' ][ 'mainscreen_showevents' ]) == 2 &&
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'home' )
2003-12-01 18:42:23 +01:00
{
$tpl = 'day_list.tpl' ;
}
$templates = Array (
'day_cal' => $tpl
);
2004-01-04 01:47:37 +01:00
2002-05-05 19:47:15 +02:00
$p -> set_file ( $templates );
2001-07-18 19:32:10 +02:00
$p -> set_block ( 'day_cal' , 'day' , 'day' );
$p -> set_block ( 'day_cal' , 'day_row' , 'day_row' );
2002-01-03 13:37:15 +01:00
$p -> set_block ( 'day_cal' , 'day_event_on' , 'day_event_on' );
$p -> set_block ( 'day_cal' , 'day_event_off' , 'day_event_off' );
$p -> set_block ( 'day_cal' , 'day_event_holiday' , 'day_event_holiday' );
2001-07-18 19:32:10 +02:00
$p -> set_block ( 'day_cal' , 'day_time' , 'day_time' );
2003-09-07 18:55:36 +02:00
2001-08-13 16:11:07 +02:00
$date_to_eval = sprintf ( " %04d%02d%02d " , $params [ 'year' ], $params [ 'month' ], $params [ 'day' ]);
2001-07-18 19:32:10 +02:00
2003-12-23 06:28:36 +01:00
$day_start = mktime (( int )( $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ]), 0 , 0 , $params [ 'month' ], $params [ 'day' ], $params [ 'year' ]);
$day_end = mktime (( int )( $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ]), 0 , 1 , $params [ 'month' ], $params [ 'day' ], $params [ 'year' ]);
2002-06-25 01:24:24 +02:00
$daily = $this -> set_week_array ( $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $params [ 'year' ], $params [ 'month' ], $params [ 'day' ]), $this -> theme [ 'row_on' ], True );
2002-09-17 04:25:40 +02:00
print_debug ( 'Date to Eval' , $date_to_eval );
2003-09-07 20:33:52 +02:00
$events_to_show = array ();
2001-07-22 01:35:22 +02:00
if ( $daily [ $date_to_eval ][ 'appts' ])
2002-08-25 06:07:21 +02:00
{
2001-07-18 19:32:10 +02:00
$events = $this -> bo -> cached_events [ $date_to_eval ];
2002-09-17 04:25:40 +02:00
print_debug ( 'Date' , $date_to_eval );
2003-04-12 21:21:22 +02:00
print_debug ( 'Count' , count ( $events ));
foreach ( $events as $event )
2001-07-18 19:32:10 +02:00
{
2003-08-28 16:31:11 +02:00
if ( $this -> bo -> rejected_no_show ( $event ))
{
continue ; // user does not want to see rejected events
}
2003-04-12 21:21:22 +02:00
if ( $event [ 'recur_type' ]) // calculate start- + end-datetime for recuring events
{
$this -> bo -> set_recur_date ( $event , $date_to_eval );
}
2003-09-07 18:55:36 +02:00
$events_to_show [] = array (
'starttime' => $this -> bo -> maketime ( $event [ 'start' ]),
'endtime' => $this -> bo -> maketime ( $event [ 'end' ]),
'content' => $this -> link_to_entry ( $event , $params [ 'month' ], $params [ 'day' ], $params [ 'year' ])
);
}
2003-09-07 20:33:52 +02:00
}
//echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n";
$other = $GLOBALS [ 'phpgw' ] -> hooks -> process ( array (
'location' => 'calendar_include_events' ,
'year' => $params [ 'year' ],
'month' => $params [ 'month' ],
'day' => $params [ 'day' ],
'owner' => $this -> bo -> owner // num. id of the user, not necessary current user
));
2003-09-07 18:55:36 +02:00
2003-09-07 20:33:52 +02:00
if ( is_array ( $other ))
{
foreach ( $other as $evts )
2003-09-07 18:55:36 +02:00
{
2003-09-07 20:33:52 +02:00
if ( is_array ( $evts ))
2003-09-07 18:55:36 +02:00
{
2003-09-07 20:33:52 +02:00
$events_to_show = array_merge ( $events_to_show , $evts );
2003-09-07 18:55:36 +02:00
}
}
2003-09-07 20:33:52 +02:00
usort ( $events_to_show , create_function ( '$a,$b' , 'return $a[\'starttime\']-$b[\'starttime\'];' ));
//echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n";
}
2003-09-07 18:55:36 +02:00
2003-09-07 20:33:52 +02:00
if ( count ( $events_to_show ))
{
2003-09-07 18:55:36 +02:00
$last_slot_end = - 1 ;
foreach ( $events_to_show as $event )
{
$slot = $this -> slot_num ( $event [ 'starttime' ], $day_start , $day_end );
$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
2002-11-23 15:19:56 +01:00
2003-08-28 16:31:11 +02:00
if ( $slot <= $last_slot_end )
2002-02-17 04:56:58 +01:00
{
2003-08-28 16:31:11 +02:00
$slot = $last_slot ;
$slot_end = max ( $last_slot_end , $slot_end );
2002-02-17 04:56:58 +01:00
}
2003-09-07 18:55:36 +02:00
$rows [ $slot ] .= $event [ 'content' ];
2001-07-28 15:17:30 +02:00
2003-08-28 16:31:11 +02:00
print_debug ( 'slot' , $slot );
print_debug ( 'row' , $rows [ $slot ]);
2002-02-17 04:56:58 +01:00
2003-08-28 16:31:11 +02:00
$row_span [ $slot ] = 1 + $slot_end - $slot ;
2003-09-07 18:55:36 +02:00
2003-08-28 16:31:11 +02:00
$last_slot = $slot ;
$last_slot_end = $slot_end ;
2002-09-17 04:25:40 +02:00
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 ));
2003-08-28 16:31:11 +02:00
print_debug ( 'Slot' , $slot );
2001-07-18 19:32:10 +02:00
}
2003-08-28 16:31:11 +02:00
//echo "rows=<pre>"; print_r($rows); echo "<br>row_span="; print_r($row_span); echo "</pre>\n";
2001-07-18 19:32:10 +02:00
}
$holiday_names = $daily [ $date_to_eval ][ 'holidays' ];
if ( ! $holiday_names )
{
2003-04-12 21:21:22 +02:00
$row_to_print = $this -> nm_on_off ();
2001-07-18 19:32:10 +02:00
}
else
{
2002-01-03 13:37:15 +01:00
$row_to_print = '_holiday' ;
2003-08-28 16:31:11 +02:00
foreach ( $holiday_names as $name )
2001-07-18 19:32:10 +02:00
{
2003-08-28 16:31:11 +02:00
$rows [ 0 ] = '<center>' . $name . '</center>' . $rows [ 0 ];
2001-07-18 19:32:10 +02:00
}
}
2003-08-28 16:31:11 +02:00
$last_slot = $this -> slot_num ( $day_end , $day_start , $day_end );
2003-04-12 21:21:22 +02:00
$rowspan = 0 ;
2003-08-28 16:31:11 +02:00
for ( $slot = 0 ; $slot <= $last_slot ; ++ $slot )
2001-07-18 19:32:10 +02:00
{
2003-08-28 16:31:11 +02:00
$p -> set_var ( 'extras' , '' );
if ( $rowspan > 1 )
2001-07-18 19:32:10 +02:00
{
2003-09-07 18:55:36 +02:00
$p -> set_var ( 'event' , '' );
2003-08-28 16:31:11 +02:00
$rowspan -- ;
2001-08-13 03:34:32 +02:00
}
2003-08-28 16:31:11 +02:00
elseif ( ! isset ( $rows [ $slot ]))
2003-04-12 21:21:22 +02:00
{
2004-05-14 17:38:15 +02:00
if (( int )( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'calendar' ][ 'mainscreen_showevents' ]) == 2 &&
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'home' )
{
$p -> set_var ( 'event' , '' );
}
else
{
$p -> set_var ( 'event' , ' ' );
$row_to_print = $this -> nm_on_off ();
$p -> parse ( 'event' , 'day_event' . $row_to_print );
}
2003-04-12 21:21:22 +02:00
}
2003-08-28 16:31:11 +02:00
else
2002-11-23 15:19:56 +01:00
{
2004-01-04 01:47:37 +01:00
$rowspan = ( int ) $row_span [ $slot ];
2003-08-28 16:31:11 +02:00
if ( $rowspan > 1 )
{
$p -> set_var ( 'extras' , ' rowspan="' . $rowspan . '"' );
}
$p -> set_var ( 'event' , $rows [ $slot ]);
$row_to_print = $this -> nm_on_off ();
2003-09-07 18:55:36 +02:00
$p -> parse ( 'event' , 'day_event' . $row_to_print );
2002-11-23 15:19:56 +01:00
}
2003-08-28 16:31:11 +02:00
$open_link = $close_link = '' ;
$time = ' ' ;
if ( 0 < $slot && $slot < $last_slot ) // normal time-slot not before or after day_start/end
2002-11-23 15:19:56 +01:00
{
2003-08-28 16:31:11 +02:00
$time = $day_start + ( $slot - 1 ) * 60 * $this -> bo -> prefs [ 'calendar' ][ 'interval' ];
$hour = date ( 'H' , $time );
$min = date ( 'i' , $time );
$time = $GLOBALS [ 'phpgw' ] -> common -> formattime ( $hour , $min );
if ( ! $this -> bo -> printer_friendly && $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
2003-09-07 18:55:36 +02:00
$open_link = ' <a href="' . $this -> page ( 'add' , " &date= $date_to_eval &hour= $hour &minute= $min " ) . '">' ;
$close_link = '</a> ' ;
2003-08-28 16:31:11 +02:00
}
2002-11-23 15:19:56 +01:00
}
2003-09-07 18:55:36 +02:00
$p -> set_var ( Array (
2003-08-28 16:31:11 +02:00
'open_link' => $open_link ,
'time' => $time ,
'close_link' => $close_link ,
'tr_color' => '' // dummy to stop output_template_array to set it
2003-09-07 18:55:36 +02:00
));
$p -> parse ( 'time' , 'day_time' );
2003-08-28 16:31:11 +02:00
$p -> parse ( 'row' , 'day_row' , True );
}
2001-07-18 19:32:10 +02:00
return $p -> fp ( 'out' , 'day' );
} // end function
2001-07-22 01:35:22 +02:00
2001-08-12 16:47:23 +02:00
function timematrix ( $param )
2001-07-22 01:35:22 +02:00
{
2001-08-12 16:47:23 +02:00
if ( ! is_array ( $param ))
{
$this -> index ();
}
$date = $param [ 'date' ];
$starttime = $param [ 'starttime' ];
$endtime = $param [ 'endtime' ];
$participants = $param [ 'participants' ];
2003-08-28 16:31:11 +02:00
foreach ( $participants as $part => $nul )
{
$participants [ $part ] = $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $part );
2004-03-10 18:08:46 +01:00
// Much better for processor :)
2004-08-01 17:36:04 +02:00
$participants_id [] = $part ;
2003-08-28 16:31:11 +02:00
}
uasort ( $participants , 'strnatcasecmp' ); // sort them after their fullname
2001-07-22 01:35:22 +02:00
2002-05-05 19:47:15 +02:00
$increment = $this -> bo -> prefs [ 'calendar' ][ 'interval' ];
2001-07-22 01:35:22 +02:00
$interval = ( int )( 60 / $increment );
2004-08-01 17:36:04 +02:00
$colspan = $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ] - $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ];
2001-07-22 01:35:22 +02:00
2002-05-05 19:47:15 +02:00
$pix = $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'pix' );
2001-07-28 15:17:30 +02:00
2004-08-01 17:36:04 +02:00
/* Make link */
$url_parts = " &participants[]= " . implode ( " &participants[]= " , array_keys ( $param [ " participants " ]));
if ( get_var ( " sevendays " , array ( " GET " , " POST " ) ) )
$sevendays = " &sevendays=yes " ;
$_f_date = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $date [ " month " ], ( $date [ " day " ] - 1 ), $date [ " year " ]);
$url_prevday = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' ,
" menuaction=calendar.uicalendar.viewmatrix "
. " &year= " . $_f_date [ " year " ]
. " &month= " . $_f_date [ " month " ]
. " &day= " . $_f_date [ " day " ]
. " &matrixtype= " . get_var ( " matrixtype " , array ( " POST " , " GET " ))
. $url_parts
. $sevendays
);
$_f_date = $GLOBALS [ 'phpgw' ] -> datetime -> makegmttime ( 0 , 0 , 0 , $date [ " month " ], ( $date [ " day " ] + 1 ), $date [ " year " ]);
$url_nextday = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' ,
" menuaction=calendar.uicalendar.viewmatrix "
. " &year= " . $_f_date [ " year " ]
. " &month= " . $_f_date [ " month " ]
. " &day= " . $_f_date [ " day " ]
. " &matrixtype= " . get_var ( " matrixtype " , array ( " POST " , " GET " ))
. $url_parts
. $sevendays
);
$str = '<table border="0" align="center" width="90%">'
. '<tr>'
. ' <td align="left"><a href="' . $url_prevday . '"><< ' . lang ( 'previous day' ) . '</a></td>'
. ' <td align="center">' . lang ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $date [ 'raw' ], 'l' ))
. ', ' . $this -> bo -> long_date ( $date )
. ' </td>'
. ' <td align="right"><a href="' . $url_nextday . '">' . lang ( 'next day' ) . ' >></a></td>'
. '</tr>'
. '</table>'
. '<table width="90%" align="center" border="0" cellspacing="0" cellpadding="0" cols="' . (( 24 * $interval ) + 1 ) . '">'
. '<tr><td colspan="' . (( $colspan * $interval ) + 1 ) . '"><hr noshade></td></tr>'
. '<tr><td bgcolor="' . $this -> theme [ 'bg02' ] . '">'
. '<font color="' . $this -> theme [ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">'
. lang ( 'Participant' ) . '</font>'
. '</td>' ;
// Destroy old variable
unset ( $_f_date );
unset ( $url_parts );
unset ( $url_prevday );
unset ( $url_nextday );
// Show TimeMatrix
for ( $i = $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ];
$i < $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ];
$i ++ )
2001-07-22 01:35:22 +02:00
{
for ( $j = 0 ; $j < $interval ; $j ++ )
{
2003-08-28 16:31:11 +02:00
$k = ( $j == 0 ? sprintf ( '%02d' , $i ) . '<br>' : '' ) . sprintf ( '%02d' , $j * $increment );
2004-01-04 01:47:37 +01:00
2004-08-01 17:36:04 +02:00
$str .= '<td align="left" bgcolor="' . $this -> theme [ 'bg02' ] . '"><font color="' . $phpgw_info [ 'theme' ][ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">'
2004-03-31 17:34:33 +02:00
. '<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; \" > "
2003-08-28 16:31:11 +02:00
. $k . " </a> </font></td> \n " ;
2001-07-22 01:35:22 +02:00
}
}
2001-07-28 15:17:30 +02:00
$str .= '</tr>'
2004-08-01 17:36:04 +02:00
. '<tr><td colspan="' . (( $colspan * $interval ) + 1 ) . '"><hr noshade></td></tr>' ;
2001-07-22 01:35:22 +02:00
if ( ! $endtime )
{
$endtime = $starttime ;
}
$owner = $this -> bo -> owner ;
2003-08-28 16:31:11 +02:00
foreach ( $participants as $part => $fullname )
2001-07-22 01:35:22 +02:00
{
2003-08-28 16:31:11 +02:00
$str .= '<tr align="center">'
2004-08-01 17:36:04 +02:00
. '<td width="15%" align="left" bgcolor="' . $this -> theme [ 'th_bg' ] . '"><font color="' . $this -> theme [ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">' . $fullname . '</font></td>' ;
2001-07-22 01:35:22 +02:00
$this -> bo -> cached_events = Array ();
2002-06-25 01:24:24 +02:00
$this -> bo -> so -> owner = $part ;
$this -> bo -> so -> open_box ( $part );
2001-08-13 03:34:32 +02:00
$this -> bo -> store_to_cache (
Array (
'syear' => $date [ 'year' ],
2001-10-03 02:31:03 +02:00
'smonth' => $date [ 'month' ],
2001-08-13 03:34:32 +02:00
'sday' => $date [ 'day' ],
'eyear' => 0 ,
2001-10-03 02:31:03 +02:00
'emonth' => 0 ,
2001-08-13 03:34:32 +02:00
'eday' => $date [ 'day' ] + 1
)
);
2001-07-22 01:35:22 +02:00
if ( ! $this -> bo -> cached_events [ $date [ 'full' ]])
{
2004-08-01 17:36:04 +02:00
for ( $j = $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ];
$j < $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ];
$j ++ )
2001-07-22 01:35:22 +02:00
{
for ( $k = 0 ; $k < $interval ; $k ++ )
{
2001-08-13 16:11:07 +02:00
$str .= '<td height="1" align="left" bgcolor="' . $this -> theme [ 'bg_color' ] . '" color="#999999"> </td>' ;
2001-07-22 01:35:22 +02:00
}
2003-08-28 16:31:11 +02:00
$str .= " \n " ;
2001-07-22 01:35:22 +02:00
}
}
else
{
2003-08-28 16:31:11 +02:00
$time_slice = $this -> bo -> prepare_matrix ( $interval , $increment , $part , $date [ 'full' ]);
2004-08-01 17:36:04 +02:00
for ( $h = $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ];
$h < $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ];
$h ++ )
2001-07-22 01:35:22 +02:00
{
$hour = $h * 10000 ;
for ( $m = 0 ; $m < $interval ; $m ++ )
{
$index = ( $hour + (( $m * $increment ) * 100 ));
switch ( $time_slice [ $index ][ 'marker' ])
{
case ' ' :
2001-08-13 16:11:07 +02:00
$time_slice [ $index ][ 'color' ] = $this -> theme [ 'bg_color' ];
2003-08-28 16:31:11 +02:00
$extra = '' ;
2001-07-22 01:35:22 +02:00
break ;
case '-' :
2001-08-13 16:11:07 +02:00
$time_slice [ $index ][ 'color' ] = $this -> theme [ 'bg01' ];
2003-08-28 16:31:11 +02:00
$link = $this -> page ( 'view' , '&cal_id=' . $time_slice [ $index ][ 'id' ] . '&date=' . $date [ 'full' ]);
$extra = ' title="' . $time_slice [ $index ][ 'description' ] . '" onClick="location.href=\'' . $link . '\';" style="cursor:pointer; cursor:hand;"' ;
2001-07-22 01:35:22 +02:00
break ;
}
2003-08-28 16:31:11 +02:00
$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>' ;
2001-07-22 01:35:22 +02:00
}
2003-08-28 16:31:11 +02:00
$str .= " \n " ;
2001-07-22 01:35:22 +02:00
}
}
2001-07-28 15:17:30 +02:00
$str .= '</tr>'
2004-08-01 17:36:04 +02:00
. '<tr><td colspan="' . (( $colspan * $interval ) + 1 ) . '"><hr noshade></td></tr>' ;
2001-07-22 01:35:22 +02:00
}
$this -> bo -> owner = $owner ;
2002-06-25 01:24:24 +02:00
$this -> bo -> so -> owner = $owner ;
$this -> bo -> so -> open_box ( $owner );
2001-07-28 15:17:30 +02:00
return $str . '</table></center>' . " \n " ;
2004-01-04 01:47:37 +01:00
}
2001-07-22 01:35:22 +02:00
function get_response ( $cal_id )
{
2003-04-21 13:00:53 +02:00
$p = & $GLOBALS [ 'phpgw' ] -> template ;
2001-07-28 15:17:30 +02:00
$p -> set_file (
Array (
'form_button' => 'form_button_script.tpl'
)
2001-07-22 01:35:22 +02:00
);
2001-08-27 05:03:41 +02:00
$ev = $this -> bo -> get_cached_event ();
2001-07-22 01:35:22 +02:00
$response_choices = Array (
ACCEPTED => lang ( 'Accept' ),
REJECTED => lang ( 'Reject' ),
TENTATIVE => lang ( 'Tentative' ),
NO_RESPONSE => lang ( 'No Response' )
);
2001-07-28 15:17:30 +02:00
$str = '' ;
2001-07-22 01:35:22 +02:00
while ( list ( $param , $text ) = each ( $response_choices ))
{
2002-11-23 15:19:56 +01:00
$var = Array (
'action_url_button' => $this -> page ( 'set_action' , '&cal_id=' . $cal_id . '&action=' . $param ),
'action_text_button' => ' ' . $text . ' ' ,
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
$str .= '<td>' . $p -> fp ( 'out' , 'form_button' ) . '</td>' . " \n " ;
}
if ( $this -> bo -> return_to )
{
$var = Array (
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ),
'action_text_button' => lang ( 'cancel' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
$str .= '<td>' . $p -> fp ( 'out' , 'form_button' ) . '</td>' . " \n " ;
2001-07-22 01:35:22 +02:00
}
2002-11-23 15:19:56 +01:00
$str = '<td><b>' . $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ) . " :</b></td> \n " . $str ;
return '<table width="100%"><tr align="center">' . " \n " . $str . '</tr></table>' . " \n " ;
2001-07-28 15:17:30 +02:00
}
2001-08-12 16:47:23 +02:00
function edit_form ( $param )
2001-07-28 15:17:30 +02:00
{
2001-08-12 16:47:23 +02:00
if ( ! is_array ( $param ))
{
2001-09-07 19:31:34 +02:00
$this -> index ();
2001-08-12 16:47:23 +02:00
}
if ( isset ( $param [ 'event' ]))
{
$event = $param [ 'event' ];
}
2001-08-13 03:34:32 +02:00
2001-07-28 15:17:30 +02:00
$hourformat = substr ( $this -> bo -> users_timeformat , 0 , 1 );
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
// $sb = CreateObject('phpgwapi.sbox');
$sb = CreateObject ( 'phpgwapi.sbox2' );
2001-07-28 15:17:30 +02:00
2001-08-12 16:47:23 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
2003-04-21 13:00:53 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = $event [ 'id' ] ? lang ( 'Calendar - Edit' ) : lang ( 'Calendar - Add' );
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2004-07-11 19:01:23 +02:00
2004-05-06 02:59:47 +02:00
$ownerApps = $GLOBALS [ 'phpgw' ] -> acl -> get_user_applications ( $event [ 'owner' ]);
2004-07-11 19:01:23 +02:00
2003-04-21 13:00:53 +02:00
$p = & $GLOBALS [ 'phpgw' ] -> template ;
2001-07-28 15:17:30 +02:00
$p -> set_file (
Array (
2004-07-11 19:01:23 +02:00
'edit' => 'edit.tpl' ,
'form_button' => 'form_button_script.tpl'
2001-07-28 15:17:30 +02:00
)
);
$p -> set_block ( 'edit' , 'edit_entry' , 'edit_entry' );
$p -> set_block ( 'edit' , 'list' , 'list' );
$p -> set_block ( 'edit' , 'hr' , 'hr' );
2004-01-04 01:47:37 +01:00
2001-07-28 15:17:30 +02:00
$vars = Array (
2001-10-03 02:31:03 +02:00
'font' => $this -> theme [ 'font' ],
'bg_color' => $this -> theme [ 'bg_text' ],
'action_url' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , Array ( 'menuaction' => 'calendar.bocalendar.update' )),
2004-08-22 20:44:47 +02:00
'common_hidden' => $this -> html -> input_hidden ( 'cal[id]' , $event [ 'id' ])
. $this -> html -> input_hidden ( 'cal[owner]' , $event [ 'owner' ])
. $this -> html -> input_hidden ( 'cal[uid]' , $event [ 'uid' ])
. ( $_GET [ 'cal_id' ] && $event [ 'id' ] == 0 ? $this -> html -> input_hidden ( 'cal[reference]' , $_GET [ 'cal_id' ]) :
( @ isset ( $event [ 'reference' ]) ? $this -> html -> input_hidden ( 'cal[reference]' , $event [ 'reference' ]) : '' ))
2004-01-04 01:47:37 +01:00
. ( @ isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'deny_user_grants_access' ]) && $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'deny_user_grants_access' ] ?
2004-08-22 20:44:47 +02:00
$this -> html -> input_hidden ( 'participants[]' , $this -> bo -> owner ) : '' ),
2001-11-08 01:18:42 +01:00
'errormsg' => ( $param [ 'cd' ] ? $GLOBALS [ 'phpgw' ] -> common -> check_code ( $param [ 'cd' ]) : '' )
2001-07-28 15:17:30 +02:00
);
$p -> set_var ( $vars );
// Brief Description
2003-08-28 16:31:11 +02:00
$var [ 'title' ] = Array (
'tr_color' => $this -> theme [ 'th_bg' ],
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Title' ),
2003-04-21 13:00:53 +02:00
'data' => '<input name="cal[title]" size="45" maxlength="80" value="' . $event [ 'title' ] . '">'
2001-07-28 15:17:30 +02:00
);
// Full Description
2003-08-28 16:31:11 +02:00
$var [ 'description' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Full Description' ),
2001-07-30 00:09:24 +02:00
'data' => '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">' . $event [ 'description' ] . '</textarea>'
2001-07-28 15:17:30 +02:00
);
// Display Categories
2001-09-20 03:39:46 +02:00
if ( strpos ( $event [ 'category' ], ',' ))
{
$temp_cats = explode ( ',' , $event [ 'category' ]);
@ reset ( $temp_cats );
while ( list ( $key , $value ) = each ( $temp_cats ))
{
2004-01-04 01:47:37 +01:00
$check_cats [] = ( int ) $value ;
2001-09-20 03:39:46 +02:00
}
}
elseif ( $event [ 'category' ])
{
2004-01-04 01:47:37 +01:00
$check_cats [] = ( int ) $event [ 'category' ];
2001-09-20 03:39:46 +02:00
}
else
{
$check_cats [] = 0 ;
}
2003-08-28 16:31:11 +02:00
$var [ 'category' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Category' ),
2003-08-28 16:31:11 +02:00
'data' => '<select name="categories[]" multiple size="5">' . $this -> cat -> formated_list ( 'select' , 'all' , $check_cats , True ) . '</select>'
2001-09-07 18:37:11 +02:00
);
// Location
2003-08-28 16:31:11 +02:00
$var [ 'location' ] = Array (
2001-09-07 18:37:11 +02:00
'field' => lang ( 'Location' ),
2003-04-21 13:00:53 +02:00
'data' => '<input name="cal[location]" size="45" maxlength="255" value="' . $event [ 'location' ] . '">'
2001-07-28 15:17:30 +02:00
);
2004-05-06 02:59:47 +02:00
// Project
if ( $ownerApps [ 'projects' ])
{
$boprojects = createObject ( 'projects.boprojects' );
$projects = $boprojects -> list_projects ( array ( 'limit' => FALSE ) );
$projectOptions = $boprojects -> select_project_list
(
array
(
'action' => 'all' ,
'status' => 'active' ,
'selected' => $event [ 'projectID' ]
)
);
if ( is_array ( $projects ))
{
$projectData = '<select name="cal[project]">' ;
if ( ! isset ( $event [ 'projectID' ]))
$projectData .= '<option value="no_project" selected="selected"></option>' ;
else
$projectData .= '<option value="no_project"></option>' ;
$projectData .= $projectOptions ;
$projectData .= '</select>' ;
}
$var [ 'project' ] = Array (
'field' => lang ( 'Project' ),
'data' => $projectData
);
}
2001-07-28 15:17:30 +02:00
// Date
2003-08-28 16:31:11 +02:00
2002-08-25 06:07:21 +02:00
$start = $this -> bo -> maketime ( $event [ 'start' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2003-08-28 16:31:11 +02:00
$var [ 'startdate' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Start Date' ),
2004-08-01 17:36:04 +02:00
'data' => $this -> jscal -> input ( 'start[str]' , $start )
2001-07-28 15:17:30 +02:00
);
// Time
if ( $this -> bo -> prefs [ 'common' ][ 'timeformat' ] == '12' )
{
2001-08-06 04:41:36 +02:00
$str .= '<input type="radio" name="start[ampm]" value="am"' . ( $event [ 'start' ][ 'hour' ] >= 12 ? '' : ' checked' ) . '>am' . " \n "
. '<input type="radio" name="start[ampm]" value="pm"' . ( $event [ 'start' ][ 'hour' ] >= 12 ? ' checked' : '' ) . '>pm' . " \n " ;
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
$var [ 'starttime' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Start Time' ),
2001-08-12 16:47:23 +02:00
'data' => '<input name="start[hour]" size="2" VALUE="' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start , $hourformat ) . '" maxlength="2">:<input name="start[min]" size="2" value="' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start , 'i' ) . '" maxlength="2">' . " \n " . $str
2001-07-28 15:17:30 +02:00
);
// End Date
2002-08-25 06:07:21 +02:00
$end = $this -> bo -> maketime ( $event [ 'end' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2003-08-28 16:31:11 +02:00
$var [ 'enddate' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'End Date' ),
2004-08-01 17:36:04 +02:00
'data' => $this -> jscal -> input ( 'end[str]' , $end )
2001-07-28 15:17:30 +02:00
);
// End Time
if ( $this -> bo -> prefs [ 'common' ][ 'timeformat' ] == '12' )
{
2001-08-06 04:41:36 +02:00
$str = '<input type="radio" name="end[ampm]" value="am"' . ( $event [ 'end' ][ 'hour' ] >= 12 ? '' : ' checked' ) . '>am' . " \n "
. '<input type="radio" name="end[ampm]" value="pm"' . ( $event [ 'end' ][ 'hour' ] >= 12 ? ' checked' : '' ) . '>pm' . " \n " ;
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
$var [ 'endtime' ] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'End Time' ),
2001-08-12 16:47:23 +02:00
'data' => '<input name="end[hour]" size="2" VALUE="' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , $hourformat ) . '" maxlength="2">:<input name="end[min]" size="2" value="' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , 'i' ) . '" maxlength="2">' . " \n " . $str
2001-07-28 15:17:30 +02:00
);
// Priority
2003-08-28 16:31:11 +02:00
$var [ 'priority' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Priority' ),
2001-07-30 00:09:24 +02:00
'data' => $sb -> getPriority ( 'cal[priority]' , $event [ 'priority' ])
2001-07-28 15:17:30 +02:00
);
// Access
2003-08-28 16:31:11 +02:00
$var [ 'access' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Private' ),
2001-07-30 00:09:24 +02:00
'data' => '<input type="checkbox" name="cal[private]" value="private"' . ( ! $event [ 'public' ] ? ' checked' : '' ) . '>'
2001-07-28 15:17:30 +02:00
);
// Participants
2002-01-06 06:58:49 +01:00
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'deny_user_grants_access' ]) || ! $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'deny_user_grants_access' ])
2001-07-28 15:17:30 +02:00
{
2004-06-12 12:04:48 +02:00
if ( ! is_object ( $GLOBALS [ 'phpgw' ] -> uiaccountsel ))
2001-07-28 15:17:30 +02:00
{
2004-06-12 12:04:48 +02:00
$GLOBALS [ 'phpgw' ] -> uiaccountsel = CreateObject ( 'phpgwapi.uiaccountsel' );
2001-07-28 15:17:30 +02:00
}
2004-06-12 12:04:48 +02:00
$var [ 'participants' ] = array (
'field' => lang ( 'Participants' ),
2004-06-16 02:33:13 +02:00
'data' => " \n " . $GLOBALS [ 'phpgw' ] -> uiaccountsel -> selection ( 'participants[]' , 'uicalendar_select_participants' , $event [ 'participants' ], 'calendar+' , 7 , $event [ 'owner' ]),
2004-06-12 12:04:48 +02:00
);
2003-08-28 16:31:11 +02:00
/*
// External Participants
// FIXME: where does the list of external participants come from?
//
$id = '1_h' ;
$test_contact [ $id ] = array ();
$test_contact [ $id ][ 'name' ] = " Stephan Cremer " ;
$id = '3_b' ;
$test_contact [ $id ] = array ();
$test_contact [ $id ][ 'name' ] = " Stephan_Uni Cremer_Uni " ;
$part = " " ;
$ext_disp = '<textarea name="external_participants" rows="5" cols="40" readonly="readonly">' . " \n " ;
while ( list ( $id , $contact ) = each ( $test_contact )) {
$part .= $part != '' ? ',' : '' ;
$part .= $id ;
$ext_disp .= '(FIXME: b_OR_h)' . $contact [ 'name' ] . " \n " ;
}
$ext_disp .= '</textarea>' . " \n " . '<br>' ;
$url = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , array ( 'menuaction' => 'calendar.uiextpartlist.modify' ));
// $url = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'calendar.uicalendar.modify_ext_partlist'));
$mod_ext = '<script language="JavaScript">' . " \n "
. 'function modify_window(url) {' . " \n "
. ' document.addform.ext_part_id.value="";' . " \n "
. ' awin = window.open(url,"modify","width=500,height=400,toolbar=no,resizable=yes");' . " \n "
// DEBUG START
. '}' . " \n " . 'function show() {' . " \n "
. ' alert("Participants: " + document.addform.ext_part_id.value);' . " \n "
// DEBUG END
. '}' . " \n </script> \n " . $ext_disp . " \n "
// DEBUG START
. '<input type="button" value="Status" onClick="javascript:show()">' . " \n "
// DEBUG END
2004-08-22 20:44:47 +02:00
. '<input type="button" onClick="javascript:modify_window(\$url.' & part = ' . $part
2003-08-28 16:31:11 +02:00
. '\')" value="' . lang ( 'Modify List of External Participants' ) . '">' . " \n "
2004-08-22 20:44:47 +02:00
. $this -> html -> input_hidden ( 'ext_part_id" value="' . $part . '">' . " \n " ;
2003-08-28 16:31:11 +02:00
2002-01-06 06:58:49 +01:00
$var [] = Array (
2003-08-28 16:31:11 +02:00
'field' => " \n " . lang ( 'External Participants' ),
'data' => " \n " . $mod_ext . " \n "
2002-01-06 06:58:49 +01:00
);
2003-08-28 16:31:11 +02:00
*/
2001-07-28 15:17:30 +02:00
// I Participate
2002-11-23 15:19:56 +01:00
if ((( $event [ 'id' ] > 0 ) && isset ( $event [ 'participants' ][ $event [ 'owner' ]])) || ! $event [ 'id' ])
2002-01-06 06:58:49 +01:00
{
$checked = ' checked' ;
}
else
{
$checked = '' ;
}
2003-08-28 16:31:11 +02:00
$var [ 'owner' ] = Array (
2002-11-23 15:19:56 +01:00
'field' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $event [ 'owner' ]) . ' ' . lang ( 'Participates' ),
'data' => '<input type="checkbox" name="participants[]" value="' . $event [ 'owner' ] . $event [ 'participants' ][ $event [ 'owner' ]] . '"' . $checked . '>'
2002-01-06 06:58:49 +01:00
);
2001-10-03 02:31:03 +02:00
}
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
// Reminder
// The user must use "Alarm Management" to change/modify an alarm
// so only display the email reminder fields if this is a new event
// i.e. not editing an existing event
if ( $event [ 'id' ] == 0 ) {
// get defaults
$days = $this -> bo -> prefs [ 'calendar' ][ 'default_email_days' ];
$hours = $this -> bo -> prefs [ 'calendar' ][ 'default_email_hours' ];
$min = $this -> bo -> prefs [ 'calendar' ][ 'default_email_min' ];
if ( count ( $event [ 'alarm' ]) > 1 )
{
// this should not happen because when creating a new event
// only 1 alarm is displayed on the screen
// if the user wants more than 1 alarm they should
// use "Alarm Management"
echo '<!-- how did this happen, too many alarms -->' . " \n " ;
}
// if there was an error pick up what the user entered
if ( @ isset ( $event [ 'alarm' ]))
{
@ reset ( $event [ 'alarm' ]);
// just get the first one see above!!!
list ( $key , $alarm ) = @ each ( $event [ 'alarm' ]);
2004-01-04 01:47:37 +01:00
$diff = $start - $alarm [ 'time' ];
$days = ( int )( $diff / ( 24 * 3600 ));
$hours = ( int )(( $diff - ( $days * 24 * 3600 )) / 3600 );
$min = ( int )(( $diff - ( $days * 24 * 3600 ) - ( $hours * 3600 )) / 60 );
}
2003-08-28 16:31:11 +02:00
// days
$dout = '<select name="cal[alarmdays]">' . " \n " ;
for ( $i = 0 ; $i < 32 ; $i ++ )
{
$dout .= '<option value="' . $i . '"' . ( $i == $days ? ' selected' : '' ) . '>' . $i . '</option>' . " \n " ;
}
$dout .= '</select>' . " \n " . ' ' . lang ( 'days' ) . ' ' ;
// hours
$hout = '<select name="cal[alarmhours]">' . " \n " ;
for ( $i = 0 ; $i < 25 ; $i ++ )
{
$hout .= '<option value="' . $i . '"' . ( $i == $hours ? ' selected' : '' ) . '>' . $i . '</option>' . " \n " ;
}
$hout .= '</select>' . " \n " . ' ' . lang ( 'hours' ) . ' ' ;
// minutes
$mout = '<select name="cal[alarmminutes]">' . " \n " ;
for ( $i = 0 ; $i < 61 ; $i ++ )
{
$mout .= '<option value="' . $i . '"' . ( $i == $min ? ' selected' : '' ) . '>' . $i . '</option>' . " \n " ;
}
$mout .= '</select>' . " \n " . ' ' . lang ( 'minutes' ) . ' ' ;
2001-07-28 15:17:30 +02:00
2003-08-28 16:31:11 +02:00
$var [ 'alarm' ] = Array (
'field' => lang ( 'Alarm' ),
'data' => $dout . $hout . $mout . lang ( 'before the event' )
);
}
2001-07-28 15:17:30 +02:00
// Repeat Type
$str = '' ;
2003-08-28 16:31:11 +02:00
foreach ( $this -> bo -> rpt_type as $type => $label )
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
$str .= '<option value="' . $type . '"' . ( $event [ 'recur_type' ] == $type ? ' selected' : '' ) . '>' . lang ( $label ) . '</option>' ;
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
$var [ 'recure_type' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Repeat Type' ),
'data' => '<select name="cal[recur_type]">' . " \n " . $str . '</select>' . " \n "
);
2001-07-30 00:09:24 +02:00
if ( $event [ 'recur_enddate' ][ 'year' ] != 0 && $event [ 'recur_enddate' ][ 'month' ] != 0 && $event [ 'recur_enddate' ][ 'mday' ] != 0 )
2001-07-28 15:17:30 +02:00
{
$checked = ' checked' ;
2002-08-25 06:07:21 +02:00
$recur_end = $this -> bo -> maketime ( $event [ 'recur_enddate' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-28 15:17:30 +02:00
}
else
{
$checked = '' ;
2002-08-25 06:07:21 +02:00
$recur_end = $this -> bo -> maketime ( $event [ 'start' ]) + 86400 - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-28 15:17:30 +02:00
}
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
$var [ 'recure_enddate' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Repeat End Date' ),
2003-08-28 16:31:11 +02:00
'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"' . $checked . '>' . lang ( 'Use End Date' ) . ' ' .
/*
$GLOBALS [ 'phpgw' ] -> common -> dateformatorder (
2004-01-04 01:47:37 +01:00
$sb -> getYears ( 'recur_enddate[year]' ,( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'Y' )),
$sb -> getMonthText ( 'recur_enddate[month]' ,( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'n' )),
$sb -> getDays ( 'recur_enddate[mday]' ,( int ) $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'd' ))
2003-08-28 16:31:11 +02:00
)
*/
2004-08-01 17:36:04 +02:00
$this -> jscal -> input ( 'recur_enddate[str]' , $recur_end )
2001-07-28 15:17:30 +02:00
);
2003-08-28 16:31:11 +02:00
$i = 0 ; $boxes = '' ;
foreach ( $this -> bo -> rpt_day as $mask => $name )
{
$boxes .= '<input type="checkbox" name="cal[rpt_day][]" value="' . $mask . '"' . ( $event [ 'recur_data' ] & $mask ? ' checked' : '' ) . '> ' . lang ( $name ) . " \n " ;
if ( ++ $i == 5 ) $boxes .= '<br>' ;
}
$var [ 'recure_day' ] = Array (
2001-07-28 15:17:30 +02:00
'field' => lang ( 'Repeat Day' ) . '<br>' . lang ( '(for weekly)' ),
2003-08-28 16:31:11 +02:00
'data' => $boxes
2001-07-28 15:17:30 +02:00
);
2003-08-28 16:31:11 +02:00
$var [ 'recure_interval' ] = Array (
2001-08-25 23:10:54 +02:00
'field' => lang ( 'Interval' ),
2001-07-30 00:09:24 +02:00
'data' => '<input name="cal[recur_interval]" size="4" maxlength="4" value="' . $event [ 'recur_interval' ] . '">'
2001-07-28 15:17:30 +02:00
);
2003-08-28 16:31:11 +02:00
if ( ! isset ( $this -> fields ))
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
$this -> custom_fields = CreateObject ( 'calendar.bocustom_fields' );
$this -> fields = & $this -> custom_fields -> fields ;
$this -> stock_fields = & $this -> custom_fields -> stock_fields ;
}
2004-05-06 02:59:47 +02:00
$ownerApps = $GLOBALS [ 'phpgw' ] -> acl -> get_user_applications ( $event [ 'owner' ]);
if ( $ownerApps [ 'projects' ])
{
// enable project app
$this -> fields [ 'project' ][ 'disabled' ] = false ;
}
2003-08-28 16:31:11 +02:00
$preserved = False ;
foreach ( $this -> fields as $field => $data )
{
if ( ! $data [ 'disabled' ])
{
if ( isset ( $var [ $field ]))
{
switch ( $field )
{
case 'startdate' :
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'startdate' ]);
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'starttime' ]);
break ;
case 'enddate' :
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'enddate' ]);
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'endtime' ]);
break ;
case 'recure_type' :
$p -> set_var ( 'tr_color' , $this -> theme [ 'th_bg' ]);
$p -> set_var ( 'hr_text' , '<center><b>' . lang ( 'Repeating Event Information' ) . '</b></center>' );
$p -> parse ( 'row' , 'hr' , True );
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'recure_type' ]);
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'recure_enddate' ]);
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'recure_day' ]);
$this -> output_template_array ( $p , 'row' , 'list' , $var [ 'recure_interval' ]);
break ;
default :
$this -> output_template_array ( $p , 'row' , 'list' , $var [ $field ]);
}
}
elseif ( ! isset ( $this -> stock_fields [ $field ])) // Custom field
{
$lang = lang ( $name = substr ( $field , 1 ));
$size = 'SIZE=' . ( $data [ 'shown' ] ? $data [ 'shown' ] : ( $data [ 'length' ] ? $data [ 'length' ] : 30 )) .
' MAXLENGTH=' . ( $data [ 'length' ] ? $data [ 'length' ] : 255 );
$v = array (
'field' => $lang == $name . '*' ? $name : $lang ,
'data' => '<input name="cal[' . htmlspecialchars ( $field ) . ']" ' . $size . ' value="' . $event [ '#' . $name ] . '">'
);
if ( $data [ 'title' ])
{
$v [ 'tr_color' ] = $this -> theme [ 'th_bg' ];
}
if ( ! $data [ 'length' ] && $data [ 'title' ])
{
$p -> set_var ( 'tr_color' , $this -> theme [ 'th_bg' ]);
$p -> set_var ( 'hr_text' , '<center><b>' . $v [ 'field' ] . '</b></center>' );
$p -> parse ( 'row' , 'hr' , True );
}
else
{
$this -> output_template_array ( $p , 'row' , 'list' , $v );
}
}
}
else // preserve disabled fields
{
switch ( $field )
{
case 'owner' :
$preserved [ $field ] = $event [ 'id' ] ? $event [ 'participants' ][ $event [ 'owner' ]] : 'A' ;
break ;
case 'recure_type' :
foreach ( array ( 'recur_type' , 'recur_enddate' , 'recur_data' , 'recur_interval' ) as $field )
{
$preserved [ $field ] = $event [ $field ];
}
break ;
case 'startdate' :
case 'enddate' :
$field = substr ( $field , 0 , - 4 );
default :
$preserved [ $field ] = $event [ $field ];
}
}
}
unset ( $var );
if ( is_array ( $preserved ))
{
//echo "preserving<pre>"; print_r($preserved); echo "</pre>\n";
2004-08-22 20:44:47 +02:00
$p -> set_var ( 'common_hidden' , $p -> get_var ( 'common_hidden' ) . $this -> html -> input_hidden ( 'preserved' , serialize ( $preserved )));
2001-07-28 15:17:30 +02:00
}
2003-04-21 13:00:53 +02:00
$p -> set_var ( 'submit_button' , lang ( 'Save' ));
2001-07-28 15:17:30 +02:00
2003-04-21 13:00:53 +02:00
$delete_button = $cancel_button = '' ;
2001-08-15 04:25:26 +02:00
if ( $event [ 'id' ] > 0 )
2001-07-28 15:17:30 +02:00
{
$var = Array (
2001-08-15 04:25:26 +02:00
'action_url_button' => $this -> page ( 'delete' , '&cal_id=' . $event [ 'id' ]),
2001-07-28 15:17:30 +02:00
'action_text_button' => lang ( 'Delete' ),
2003-05-25 23:01:58 +02:00
'action_confirm_button' => " onClick= \" return confirm(' " . lang ( " Are you sure \\ nyou want to \\ ndelete this entry ? \\ n \\ nThis will delete \\ nthis entry for all users. " ) . " ') \" " ,
2001-07-28 15:17:30 +02:00
'action_extra_field' => ''
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$delete_button = $p -> fp ( 'out' , 'form_button' );
2001-07-28 15:17:30 +02:00
}
2003-04-21 13:00:53 +02:00
$p -> set_var ( 'delete_button' , $delete_button );
2002-11-23 15:19:56 +01:00
if ( $this -> bo -> return_to )
2001-07-28 15:17:30 +02:00
{
2002-11-23 15:19:56 +01:00
$var = Array (
'action_url_button' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $this -> bo -> return_to ),
'action_text_button' => lang ( 'Cancel' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
2003-04-21 13:00:53 +02:00
$cancel_button = $p -> fp ( 'out' , 'form_button' );
2001-07-28 15:17:30 +02:00
}
2003-04-21 13:00:53 +02:00
$p -> set_var ( 'cancel_button' , $cancel_button );
2001-07-28 15:17:30 +02:00
$p -> pparse ( 'out' , 'edit_entry' );
}
2003-08-28 16:31:11 +02:00
// modify list of an event's external participants (i.e. non pgpgw users)
//
function modify_ext_partlist ()
{
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
$total_contacts = 0 ;
$participant = array ();
$control_data = array ();
$control_data [ 'action' ] = '' ;
$control_data [ 'delete' ] = array ();
$control_data [ 'part' ] = array ();
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_file (
Array (
'T_edit_partlist' => 'edit_partlist.tpl' ,
'T_edit_partlist_blocks' => 'edit_partlist_blocks.tpl'
)
);
$p -> set_block ( 'T_edit_partlist_blocks' , 'B_alert_msg' , 'V_alert_msg' );
$p -> set_block ( 'T_edit_partlist_blocks' , 'B_partlist' , 'V_partlist' );
$p -> set_block ( 'T_edit_partlist_blocks' , 'B_participants_none' , 'V_participants_none' );
$p -> set_block ( 'T_edit_partlist_blocks' , 'B_delete_btn' , 'V_delete_btn' );
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
global $query_addr ;
$sb = CreateObject ( 'phpgwapi.sbox2' );
$addy = $sb -> getAddress ( 'addr' , '' , $query_addr );
$add_ext = $addy [ 'doSearchFkt' ];
$add_ext .= $addy [ 'addr_title' ] != lang ( 'Address Book' ) ? $addy [ 'addr_title' ] : '' ;
$add_ext .= " " . $addy [ 'addr' ] . $addy [ 'addr_nojs' ];
$p -> set_var ( 'text_add_name' , $add_ext );
if ( isset ( $_GET [ 'part' ]) && $_GET [ 'part' ])
{
$control_data [ 'part' ] = split ( " , " , $_GET [ 'part' ]);
}
else
{
$control_data [ 'part' ] = $_POST [ 'participant' ];
$control_data [ 'action' ] = $_POST [ 'action' ];
$control_data [ 'delete' ] = $_POST [ 'delete' ];
}
for ( $i = 0 ; $i < count ( $control_data [ 'part' ]); $i ++ )
{
2004-01-04 01:47:37 +01:00
$id = $control_data [ 'part' ][ $i ];
list ( $contact ) = $this -> read_contact ( $id );
2003-08-28 16:31:11 +02:00
2004-01-04 01:47:37 +01:00
$participant [ $id ] = array ();
$participant [ $id ][ 'name' ] = $contact [ 'n_given' ] . ' ' . $contact [ 'n_family' ];
2003-08-28 16:31:11 +02:00
}
if ( $control_data [ 'action' ] == lang ( 'Delete selected contacts' ))
{
for ( $i = 0 ; $i < count ( $control_data [ 'delete' ]); $i ++ )
{
$id = $control_data [ 'delete' ][ $i ];
unset ( $participant [ $id ]);
}
}
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
if ( $control_data [ 'action' ] == lang ( 'Add Contact' ))
{
$id = $_POST [ 'id_addr' ];
2004-01-04 01:47:37 +01:00
if ( isset ( $id ) && ( int ) $id != 0 )
2003-08-28 16:31:11 +02:00
{
list ( $contact ) = $this -> read_contact ( $id );
$participant [ $id ] = array ();
$participant [ $id ][ 'name' ] = $contact [ 'n_given' ] . ' ' . $contact [ 'n_family' ];
}
}
// create list of currently selected contacts
//
while ( list ( $id , $contact ) = each ( $participant ))
{
$p -> set_var ( 'hidden_delete_name' , 'participant[]' );
$p -> set_var ( 'hidden_delete_value' , $id );
$p -> set_var ( 'ckbox_delete_name' , 'delete[]' );
$p -> set_var ( 'ckbox_delete_value' , $id );
$p -> set_var ( 'ckbox_delete_participant' , $contact [ 'name' ]);
$p -> parse ( 'V_partlist' , 'B_partlist' , True );
$total_contacts ++ ;
}
if ( $total_contacts == 0 )
{
// no contacts have been selected
// => clear the delete form, remove delete button and show the none block
//
$p -> set_var ( 'V_partlist' , '' );
$p -> set_var ( 'V_delete_btn' , '' );
$p -> set_var ( 'text_none' , lang ( 'None' ));
$p -> parse ( 'V_participants_none' , 'B_participants_none' );
}
else
{
// at least one contact has been selected
// => clear the none block, fill the delete form and add delete button
//
$p -> set_var ( 'V_participants_none' , '' );
$p -> set_var ( 'btn_delete_name' , 'action' );
$p -> set_var ( 'btn_delete_value' , lang ( 'Delete selected contacts' ));
$p -> parse ( 'V_delete_btn' , 'B_delete_btn' );
}
$body_tags = 'bgcolor="' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'bg_color' ]
. '" alink="' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'alink' ]
. '" link="' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'link' ]
. '" vlink="' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'vlink' ] . '"' ;
$form_action = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , array ( 'menuaction' => 'calendar.uicalendar.modify' ));
2004-01-04 01:47:37 +01:00
2003-08-28 16:31:11 +02:00
$charset = lang ( 'charset' );
$p -> set_var ( 'charset' , $charset );
2004-01-04 01:47:37 +01:00
$p -> set_var ( 'page_title' , $GLOBALS [ 'phpgw_flags' ][ 'currentapp' ]
. ' - ' . lang ( 'External Participants' ));
2003-08-28 16:31:11 +02:00
$p -> set_var ( 'font_family' , $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'font' ]);
$p -> set_var ( 'body_tags' , $body_tags );
$p -> set_var ( 'form_method' , 'POST' );
$p -> set_var ( 'form_action' , $form_action );
$p -> set_var ( 'text_add_contact' , lang ( 'External Participants' ));
$p -> set_var ( 'text_contacts_selected' , lang ( 'Selected contacts (%1)' , $total_contacts ));
$p -> set_var ( 'btn_add_name' , 'action' );
$p -> set_var ( 'btn_add_value' , lang ( 'Add Contact' ));
$p -> set_var ( 'btn_done_name' , 'done' );
$p -> set_var ( 'btn_done_value' , lang ( 'Done' ));
$p -> set_var ( 'btn_done_js' , 'copyback()' );
$p -> set_var ( 'form1_name' , 'ext_form' );
2004-01-04 01:47:37 +01:00
$p -> pfp ( 'out' , 'T_edit_partlist' );
2003-08-28 16:31:11 +02:00
}
function read_contact ( $id )
{
$query_fields = Array (
'n_given' => 'n_given' ,
'n_family' => 'n_family' ,
'email' => 'email' ,
'email_home' => 'email_home'
);
2004-01-04 01:47:37 +01:00
/*
2003-08-28 16:31:11 +02:00
if ( $this -> rights & PHPGW_ACL_READ )
{
return $this -> contacts -> read_single_entry ( $id , $fields );
}
else
{
$rtrn = array ( 0 => array ( 'No access' => 'No access' ));
return $rtrn ;
}
2004-01-04 01:47:37 +01:00
*/
2003-08-28 16:31:11 +02:00
2004-01-04 01:47:37 +01:00
$contacts = CreateObject ( 'phpgwapi.contacts' , False );
return $contacts -> read_single_entry ( $id , $query_fields );
2003-08-28 16:31:11 +02:00
}
2001-07-28 15:17:30 +02:00
function build_part_list ( & $users , $accounts , $owner )
{
2003-08-28 16:31:11 +02:00
if ( ! is_array ( $accounts ))
2001-07-28 15:17:30 +02:00
{
return ;
}
2003-08-28 16:31:11 +02:00
foreach ( $accounts as $id )
2001-07-28 15:17:30 +02:00
{
2004-01-04 01:47:37 +01:00
$id = ( int ) $id ;
2003-08-28 16:31:11 +02:00
if ( $id == $owner )
2001-07-28 15:17:30 +02:00
{
continue ;
}
2003-08-28 16:31:11 +02:00
elseif ( ! isset ( $users [ $id ]))
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
if ( $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $id ) == True )
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
$users [ $id ] = Array (
'name' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $id ),
'type' => $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $id )
2001-09-11 05:09:18 +02:00
);
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
if ( $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $id ) == 'g' )
{
$this -> build_part_list ( $users , $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( $id , 1 , 'phpgw_group' ), $owner );
}
}
}
if ( ! function_exists ( 'strcmp_name' ))
{
function strcmp_name ( $arr1 , $arr2 )
{
if ( $diff = strcmp ( $arr1 [ 'type' ], $arr2 [ 'type' ]))
2001-07-28 15:17:30 +02:00
{
2003-08-28 16:31:11 +02:00
return $diff ; // groups before users
2001-07-28 15:17:30 +02:00
}
2003-08-28 16:31:11 +02:00
return strnatcasecmp ( $arr1 [ 'name' ], $arr2 [ 'name' ]);
2001-07-28 15:17:30 +02:00
}
}
2003-08-28 16:31:11 +02:00
uasort ( $users , 'strcmp_name' );
2001-07-22 01:35:22 +02:00
}
2001-08-26 14:31:28 +02:00
function set_week_array ( $startdate , $cellcolor , $weekly )
{
2002-04-16 18:52:36 +02:00
for ( $j = 0 , $datetime = $startdate ; $j < 7 ; $j ++ , $datetime += 86400 )
2001-08-26 14:31:28 +02:00
{
2003-08-28 16:31:11 +02:00
$date = date ( 'Ymd' , $datetime + ( 60 * 60 * 2 )); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset
print_debug ( 'set_week_array : Date ' , $date );
2001-08-26 14:31:28 +02:00
2003-08-28 16:31:11 +02:00
if ( $events = $this -> bo -> cached_events [ $date ])
2001-08-28 05:41:16 +02:00
{
2002-09-19 04:14:41 +02:00
print_debug ( 'Date' , $date );
2003-08-28 16:31:11 +02:00
print_debug ( 'Appointments Found' , count ( $events ));
if ( ! $this -> bo -> prefs [ 'calendar' ][ 'show_rejected' ])
{
$appts = False ;
foreach ( $events as $event ) // check for a not-rejected event
{
if ( ! $this -> bo -> rejected_no_show ( $event ))
{
$appts = True ;
break ;
}
}
}
else
{
$appts = True ;
}
2001-08-28 05:41:16 +02:00
}
else
{
$appts = False ;
}
2001-08-26 14:31:28 +02:00
$holidays = $this -> bo -> cached_holidays [ $date ];
if ( $weekly )
{
$cellcolor = $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color ( $cellcolor );
}
2004-01-04 01:47:37 +01:00
2001-08-26 14:31:28 +02:00
$day_image = '' ;
if ( $holidays )
{
2003-08-28 16:31:11 +02:00
$extra = ' bgcolor="' . $this -> bo -> holiday_color . '"' ;
2001-08-28 05:41:16 +02:00
$class = ( $appts ? 'b' : '' ) . 'minicalhol' ;
2001-08-26 14:31:28 +02:00
if ( $date == $this -> bo -> today )
{
2002-04-16 18:52:36 +02:00
$day_image = ' background="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'mini_day_block' ) . '"' ;
2001-08-26 14:31:28 +02:00
}
}
elseif ( $date != $this -> bo -> today )
{
2003-08-28 16:31:11 +02:00
$extra = ' bgcolor="' . $cellcolor . '"' ;
2001-08-28 05:41:16 +02:00
$class = ( $appts ? 'b' : '' ) . 'minicalendar' ;
2001-08-26 14:31:28 +02:00
}
else
{
2003-08-28 16:31:11 +02:00
$extra = ' bgcolor="' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'cal_today' ] . '"' ;
2001-08-28 05:41:16 +02:00
$class = ( $appts ? 'b' : '' ) . 'minicalendar' ;
2002-04-16 18:52:36 +02:00
$day_image = ' background="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'mini_day_block' ) . '"' ;
2001-08-26 14:31:28 +02:00
}
if ( $this -> bo -> printer_friendly && @ $this -> bo -> prefs [ 'calendar' ][ 'print_black_white' ])
{
$extra = '' ;
}
if ( ! $this -> bo -> printer_friendly && $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
$new_event = True ;
}
else
{
$new_event = False ;
}
$holiday_name = Array ();
if ( $holidays )
{
for ( $k = 0 ; $k < count ( $holidays ); $k ++ )
{
$holiday_name [] = $holidays [ $k ][ 'name' ];
}
}
$week = '' ;
2002-11-23 15:19:56 +01:00
if ( ! $j || ( ! $weekly && $j && substr ( $date , 6 , 2 ) == '01' ))
2001-08-26 14:31:28 +02:00
{
2001-12-22 15:38:54 +01:00
$week = lang ( 'week' ) . ' ' . ( int )(( date ( 'z' ,( $startdate + ( 24 * 3600 * 4 ))) + 7 ) / 7 );
2001-08-26 14:31:28 +02:00
}
$daily [ $date ] = Array (
'extra' => $extra ,
'new_event' => $new_event ,
'holidays' => $holiday_name ,
'appts' => $appts ,
'week' => $week ,
'day_image' => $day_image ,
'class' => $class
);
}
if ( $this -> debug )
{
2002-04-13 05:20:53 +02:00
_debug_array ( $daily );
2001-08-26 14:31:28 +02:00
}
2004-01-04 01:47:37 +01:00
2001-08-26 14:31:28 +02:00
return $daily ;
}
2001-07-16 13:38:40 +02:00
}
?>