2001-07-16 13:38:40 +02:00
< ? php
/************************************************************************** \
* phpGroupWare - Calendar *
* http :// www . phpgroupware . org *
* Based on Webcalendar by Craig Knudsen < cknudsen @ radix . net > *
* http :// www . radix . net /~ cknudsen *
* Modified by Mark Peters < skeeter @ phpgroupware . org > *
* -------------------------------------------- *
* 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 ;
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_html ;
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 ;
var $planner_days_in_end_month ;
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 ,
'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 ,
'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' );
2001-08-26 14:31:28 +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 );
2001-07-16 13:38:40 +02:00
2001-07-22 01:35:22 +02:00
if ( $this -> debug )
{
echo " BO Owner : " . $this -> bo -> owner . " <br> \n " ;
}
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
$this -> cat = CreateObject ( 'phpgwapi.categories' );
2001-08-28 05:41:16 +02:00
$this -> holiday_color = ( substr ( $this -> theme [ 'bg06' ], 0 , 1 ) == '#' ? '' : '#' ) . $this -> theme [ 'bg06' ];
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 (
Array (
'link_picture' => 'link_pict.tpl'
)
);
$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 )
{
$this -> save_sessiondata ();
}
2001-07-16 13:38:40 +02:00
if ( $this -> debug )
{
$this -> _debug_sqsof ();
}
}
/* Public functions */
2001-08-13 06:49:19 +02:00
function mini_calendar ( $params )
2001-07-16 13:38:40 +02:00
{
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' ]
)
);
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' ]);
2001-08-13 06:49:19 +02:00
$month_ago = intval ( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ] - 1 , $params [ 'day' ], $params [ 'year' ])));
$month_ahead = intval ( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ] + 1 , $params [ 'day' ], $params [ 'year' ])));
$monthstart = intval ( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $params [ 'month' ], 1 , $params [ 'year' ])));
$monthend = intval ( 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
if ( $this -> debug )
{
echo '<!-- mini_calendar:monthstart = ' . $monthstart . ' -->' . " \n " ;
echo '<!-- mini_calendar:weekstarttime = ' . date ( 'Ymd H:i:s' , $weekstarttime ) . ' -->' . " \n " ;
}
2001-07-16 13:38:40 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_unknowns ( 'remove' );
2001-08-06 04:41:36 +02:00
$p -> set_file (
Array (
'mini_calendar' => 'mini_cal.tpl'
)
2001-07-16 13:38:40 +02:00
);
$p -> set_block ( 'mini_calendar' , 'mini_cal' , 'mini_cal' );
$p -> set_block ( 'mini_calendar' , 'mini_week' , 'mini_week' );
$p -> set_block ( 'mini_calendar' , 'mini_day' , 'mini_day' );
2001-07-18 19:32:10 +02:00
if ( $this -> bo -> printer_friendly == False )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
$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>' ;
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 (
2001-08-12 16:47:23 +02:00
'cal_img_root' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'mini-calendar-bar.gif' ),
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
);
$p -> set_var ( $var );
2001-08-13 06:49:19 +02:00
switch ( strtolower ( $params [ 'buttons' ]))
2001-07-16 13:38:40 +02:00
{
case 'right' :
$var = Array (
2001-08-12 16:47:23 +02:00
'nextmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ahead ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'right.gif' ) . '" border="0"></a>'
2001-07-16 13:38:40 +02:00
);
break ;
case 'left' :
$var = Array (
2001-08-12 16:47:23 +02:00
'prevmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ago ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'left.gif' ) . '" border="0"></a>'
2001-07-16 13:38:40 +02:00
);
break ;
case 'both' :
$var = Array (
2001-08-12 16:47:23 +02:00
'prevmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ago ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'left.gif' ) . '" border="0"></a>' ,
'nextmonth' => '<a href="' . $this -> page ( 'month' , '&date=' . $month_ahead ) . '"><img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'right.gif' ) . '" border="0"></a>'
2001-07-16 13:38:40 +02:00
);
break ;
case 'none' :
default :
$var = Array (
'prevmonth' => '' ,
'nextmonth' => ''
);
break ;
}
$p -> set_var ( $var );
for ( $i = 0 ; $i < 7 ; $i ++ )
{
2001-08-06 04:41:36 +02:00
$var = Array (
2002-06-25 01:24:24 +02:00
'dayname' => '<b>' . substr ( lang ( $GLOBALS [ 'phpgw' ] -> datetime -> days [ $i ][ 'name' ]), 0 , 2 ) . '</b>' ,
2001-08-06 04:41:36 +02:00
'day_image' => ''
);
$this -> output_template_array ( $p , 'daynames' , 'mini_day' , $var );
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 );
2001-07-16 13:38:40 +02:00
@ reset ( $daily );
while ( list ( $date , $day_params ) = each ( $daily ))
{
2001-07-28 15:17:30 +02:00
if ( $this -> debug )
{
echo 'Mini-Cal Date : ' . $date . " <br> \n " ;
}
2001-07-16 13:38:40 +02:00
$year = intval ( substr ( $date , 0 , 4 ));
$month = intval ( substr ( $date , 4 , 2 ));
$day = intval ( substr ( $date , 6 , 2 ));
$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
{
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
{
$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 ++ )
{
$this -> output_template_array ( $p , 'monthweek_day' , 'mini_day' , $var [ $l ]);
}
$p -> parse ( 'display_monthweek' , 'mini_week' , True );
$p -> set_var ( 'dayname' , '' );
$p -> set_var ( 'monthweek_day' , '' );
}
$return_value = $p -> fp ( 'out' , 'mini_cal' );
unset ( $p );
return $return_value ;
}
2001-07-28 15:17:30 +02:00
function index ( $params = '' )
2001-07-16 13:38:40 +02:00
{
2001-07-28 15:17:30 +02:00
Header ( 'Location: ' . $this -> page ( '' , $params ));
2001-08-13 23:12:16 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-07-16 13:38:40 +02:00
}
2002-03-14 01:10:50 +01:00
function printer_friendly ( $body )
{
if ( $this -> bo -> printer_friendly )
{
$new_body = '<html>' . " \n "
. '<head>' . " \n "
. '<STYLE type="text/css">' . " \n "
. '<!--' . " \n "
. ' body { margin-top: 0px; margin-right: 0px; margin-left: 0px; font-family: "' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'font' ] . '" }' . " \n "
. ' .tablink { color: #000000; }' . " \n "
. ' ' . $this -> css () . " \n "
. '-->' . " \n "
. '</STYLE>' . " \n "
. '</head>' . " \n "
2002-04-07 16:12:53 +02:00
. $this -> bo -> debug_string . $body
2002-03-14 01:10:50 +01:00
. '</body>' . " \n "
. '</html>' . " \n " ;
}
else
2001-11-05 04:48:14 +01: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' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2002-04-07 16:12:53 +02:00
$new_body = $this -> bo -> debug_string . $body ;
2001-11-05 04:48:14 +01:00
}
2002-04-07 16:12:53 +02:00
return $new_body ;
}
function month ()
{
2002-03-14 01:10:50 +01:00
echo $this -> printer_friendly ( $this -> get_month ());
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 );
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 ,
'link' => 'day'
)
);
2001-12-24 04:07:24 +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 ,
'link' => 'day'
)
);
}
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 = '' ;
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' ] . '">' ;
$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 ,
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 ),
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
);
2001-07-28 15:17:30 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$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
{
2002-03-14 01:10:50 +01:00
echo $this -> printer_friendly ( $this -> get_week ());
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
{
$minical_this = '' ;
$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
{
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>' ;
$print = '<a href="' . $this -> page ( 'week' , '&friendly=1' ) . " \" 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
{
2001-08-13 16:11:07 +02:00
$printer = '<body bgcolor="' . $this -> theme [ 'bg_color' ] . '">' ;
2001-07-16 13:38:40 +02: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 (
2002-05-05 19:47:15 +02:00
'printer_friendly' => $printer ,
'bg_text' => $this -> theme [ 'bg_text' ],
'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
)
),
2002-05-05 19:47:15 +02:00
'print' => $print
2001-07-16 13:38:40 +02:00
);
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 ();
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 = '' ;
}
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 );
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$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 ()
{
2002-03-14 01:10:50 +01:00
echo $this -> printer_friendly ( $this -> get_year ());
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' ;
2001-07-28 15:17:30 +02:00
$printer = '<a href="' . $this -> page ( 'year' , '&friendly=1' ) . '" 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
{
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
);
$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' );
$p -> set_block ( 'year_t' , 'month' , 'month' );
$p -> set_block ( 'year_t' , 'month_sep' , 'month_sep' );
$p -> set_var ( $var );
for ( $i = 1 ; $i <= 12 ; $i ++ )
2001-07-16 13:38:40 +02:00
{
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' , '' );
if (( $i % 3 ) == 0 )
{
$p -> parse ( 'row' , 'month_sep' , True );
}
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
}
2001-09-20 03:39:46 +02:00
function view ( $vcal_id = 0 , $cal_date = 0 )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
2001-10-03 02:31:03 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2002-09-17 04:25:40 +02:00
2001-10-03 02:31:03 +02:00
echo '<center>' ;
2001-07-16 13:38:40 +02:00
2002-09-17 04:25:40 +02:00
$cal_id = get_var ( 'cal_id' , Array ( 'GET' , 'POST' , 'DEFAULT' ), $vcal_id );
$date = get_var ( 'date' , Array ( 'GET' , 'DEFAULT' ), $cal_date );
2001-07-16 13:38:40 +02:00
// First, make sure they have permission to this entry
if ( $cal_id < 1 )
{
2001-10-26 01:52:15 +02:00
echo lang ( 'Invalid entry id.' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-07-16 13:38:40 +02:00
}
2002-09-17 04:25:40 +02:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $cal_id ))
2001-07-16 13:38:40 +02:00
{
2001-10-26 01:52:15 +02:00
echo lang ( 'You do not have permission to read this record!' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-07-16 13:38:40 +02:00
}
$event = $this -> bo -> read_entry ( $cal_id );
2001-10-03 02:31:03 +02:00
if ( ! isset ( $event [ 'id' ]))
2001-07-16 13:38:40 +02:00
{
2001-10-26 01:52:15 +02:00
echo lang ( " Sorry, this event does not exist " ) . '.' . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
2001-07-28 15:17:30 +02:00
}
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
2001-11-29 04:12:01 +01:00
$ret_value = $this -> view_event ( $event , True );
echo $ret_value ;
2001-10-21 15:39:45 +02:00
2001-11-29 04:12:01 +01:00
if ( $ret_value == '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' )
{
echo '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
2001-10-26 01:52:15 +02:00
2001-11-29 04:12:01 +01:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_file (
Array (
'form_button' => 'form_button_script.tpl'
)
);
2001-10-26 01:52:15 +02:00
2002-09-17 04:25:40 +02:00
// if($this->bo->owner == $event['owner'] || $this->bo->member_of_group($this->bo->owner))
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 ($this->bo->check_perms(PHPGW_ACL_EDIT,$event['owner']))
// {
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' => '' ,
'action_extra_field' => '<input type="hidden" name="edit_type" value="single">' . " \n "
. '<input type="hidden" name="date" value="' . sprintf ( '%04d%02d%02d' , $this -> bo -> year , $this -> bo -> month , $this -> bo -> day ) . '">'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
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' => '' ,
2002-09-17 04:25:40 +02:00
'action_extra_field' => '<input type="hidden" name="edit_type" value="series">'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
}
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 );
echo $p -> fp ( 'out' , 'form_button' );
}
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' => '' ,
'action_extra_field' => '<input type="hidden" name="cal_id" value="' . $cal_id . '">'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
}
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. " ) . " ') \" " ,
'action_extra_field' => '<input type="hidden" name="delete_type" value="single">'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
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. " ) . " ') \" " ,
'action_extra_field' => '<input type="hidden" name="delete_type" value="series">'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
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 );
echo $p -> fp ( 'out' , 'form_button' );
}
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 );
echo $p -> fp ( 'out' , 'form_button' );
}
// }
2001-07-16 13:38:40 +02:00
}
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' => '' ,
2001-12-10 04:58:44 +01:00
'action_extra_field' => '<input type="hidden" name="cal_id" value="' . $cal_id . '">'
2001-11-29 04:12:01 +01:00
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' ) . '</center>' ;
2002-09-17 04:25:40 +02:00
$GLOBALS [ 'phpgw' ] -> hooks -> process ( 'calendar_view' );
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-07-28 15:17:30 +02:00
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
2001-07-16 13:38:40 +02:00
{
2001-07-28 15:17:30 +02:00
$this -> no_edit ();
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
2001-09-28 04:06:35 +02:00
if ( isset ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'readsess' ]))
{
$params [ 'readsess' ] = $GLOBALS [ 'HTTP_GET_VARS' ][ 'readsess' ];
$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
}
2001-08-27 03:30:40 +02:00
elseif ( isset ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]))
2001-07-16 13:38:40 +02:00
{
2001-08-27 03:30:40 +02:00
$cal_id = $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ];
$event = $this -> bo -> read_entry ( intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]));
2002-08-25 06:07:21 +02:00
2001-09-07 20:30:35 +02:00
if ( ! $this -> bo -> can_user_edit ( $event ))
2001-07-16 13:38:40 +02:00
{
2001-09-07 20:47:48 +02:00
Header ( 'Location: ' . $this -> page ( 'view' , '&cal_id=' . $cal_id ));
2001-09-07 20:30:35 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-08-27 03:30:40 +02:00
}
if ( @ isset ( $GLOBALS [ 'HTTP_POST_VARS' ][ 'edit_type' ]) && $GLOBALS [ 'HTTP_POST_VARS' ][ 'edit_type' ] == 'single' )
{
$event [ 'id' ] = 0 ;
$event [ 'start' ][ 'month' ] = $this -> bo -> month ;
$event [ 'start' ][ 'mday' ] = $this -> bo -> day ;
$event [ 'start' ][ 'year' ] = $this -> bo -> year ;
$event [ 'end' ][ 'month' ] = $this -> bo -> month ;
$event [ 'end' ][ 'mday' ] = $this -> bo -> day ;
$event [ 'end' ][ 'year' ] = $this -> bo -> year ;
$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 ;
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
2001-08-29 21:18:32 +02:00
function export ( $vcal_id = 0 )
{
2001-12-10 04:58:44 +01:00
if ( ! isset ( $GLOBALS [ 'HTTP_POST_VARS' ][ 'cal_id' ]) || ! $GLOBALS [ 'HTTP_POST_VARS' ][ 'cal_id' ])
{
Header ( 'Location: ' . $this -> index ());
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
}
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
if ( ! isset ( $GLOBALS [ 'HTTP_POST_VARS' ][ 'output_file' ]) || ! $GLOBALS [ 'HTTP_POST_VARS' ][ 'output_file' ])
{
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_file (
Array (
'form_button' => 'form_button_script.tpl'
)
);
$var = Array (
'action_url_button' => $this -> page ( 'export' ),
'action_text_button' => lang ( 'Submit' ),
'action_confirm_button' => '' ,
'action_extra_field' => " \n " . lang ( 'Enter Output Filename: ( .vcs appended )' ) . " \n " . ' <input name="output_file" size="25" maxlength="80" value="">' . " \n "
. ' <input type="hidden" name="cal_id" value="' . $GLOBALS [ 'HTTP_POST_VARS' ][ 'cal_id' ] . '">'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
}
else
{
$output_file = $GLOBALS [ 'HTTP_POST_VARS' ][ 'output_file' ] . '.vcs' ;
$vfs = CreateObject ( 'phpgwapi.vfs' );
// if(!$vfs->file_exists('.calendar',array(RELATIVE_USER)))
// {
// $vfs->mkdir('.calendar',array(RELATIVE_USER));
// }
$content = ExecMethod ( 'calendar.boicalendar.export' , $GLOBALS [ 'HTTP_POST_VARS' ][ 'cal_id' ]);
$vfs -> cd ( '/' , True , array ( RELATIVE_USER ));
$vfs -> write ( $output_file , array ( RELATIVE_USER ), $content );
// $vfs->write($output_file, array (RELATIVE_USER_APP), $content);
2002-04-16 18:52:36 +02:00
if ( $this -> debug )
{
echo '<!-- DEBUG: Output Filename = ' . $output_file . ' -->' . " \n " ;
echo '<!-- DEBUG: Fakebase = ' . $vfs -> fakebase . ' -->' . " \n " ;
echo '<!-- DEBUG: Path = ' . $vfs -> pwd () . ' -->' . " \n " ;
}
2001-12-10 04:58:44 +01:00
Header ( 'Location: ' . $this -> index ());
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
}
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 ))
{
$this -> no_edit ();
}
elseif ( ! $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
$this -> index ();
}
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
echo '<center>' ;
$cal_id = ( isset ( $params [ 'cal_id' ]) ? intval ( $params [ 'cal_id' ]) : '' );
$cal_id = ( $cal_id == '' ? intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]) : $cal_id );
if ( $cal_id < 1 )
{
echo lang ( 'Invalid entry id.' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_READ ))
{
echo lang ( 'You do not have permission to read this record!' ) . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
$event = $this -> bo -> read_entry ( $cal_id );
if ( ! isset ( $event [ 'id' ]))
{
echo lang ( 'Sorry, this event does not exist' ) . '.' . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
elseif ( ! isset ( $event [ 'recur_exception' ]))
{
echo lang ( 'Sorry, this event does not have exceptions defined' ) . '.' . '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
$ret_value = $this -> view_event ( $event , True );
echo $ret_value ;
if ( $ret_value == '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' )
{
echo '</center>' . " \n " ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$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 " ;
}
$var = Array (
'action_url_button' => $this -> page ( 'reinstate' , '&cal_id=' . $cal_id ),
'action_text_button' => lang ( 'Reinstate' ),
'action_confirm_button' => '' ,
'action_extra_field' => " \n " . ' <select name="reinstate_index[]" multiple size="5">' . " \n " . $str . ' </select>'
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' );
$var = Array (
'action_url_button' => $this -> page ( '' ),
'action_text_button' => lang ( 'Cancel' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
echo $p -> fp ( 'out' , 'form_button' ) . '</center>' ;
}
function reinstate ( $params = '' )
{
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
{
$this -> no_edit ();
}
elseif ( ! $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
{
$this -> index ();
}
$cal_id = ( isset ( $params [ 'cal_id' ]) ? intval ( $params [ 'cal_id' ]) : '' );
$cal_id = ( $cal_id == '' ? intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]) : $cal_id );
$reinstate_index = ( isset ( $params [ 'reinstate_index' ]) ? intval ( $params [ 'reinstate_index' ]) : '' );
$reinstate_index = ( $reinstate_index == '' ? intval ( $GLOBALS [ 'HTTP_POST_VARS' ][ 'reinstate_index' ]) : $reinstate_index );
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 " ;
}
Header ( 'Location: ' . $this -> page ( '' ,( $cd ? '&cd=' . $cd : '' )));
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
}
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 ();
}
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 ;
2001-09-07 19:51:48 +02:00
$thishour = ( isset ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'hour' ]) ? intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'hour' ]) : 0 );
2001-10-03 02:31:03 +02:00
$thisminute = ( isset ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'minute' ]) ? intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'minute' ]) : 0 );
2001-07-18 19:32:10 +02:00
$this -> bo -> set_start ( $this -> bo -> year , $this -> bo -> month , $this -> bo -> day , $thishour , $thisminute , 0 );
$this -> bo -> set_end ( $this -> bo -> year , $this -> bo -> month , $this -> bo -> day , $thishour , $thisminute , 0 );
$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
}
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 ()
{
2002-09-17 04:25:40 +02:00
$cal_id = get_var ( 'cal_id' , Array ( 'GET' ));
if ( ! $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 )));
$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 );
2001-09-07 19:51:48 +02:00
$event = $this -> bo -> read_entry ( intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]));
2002-09-17 04:25:40 +02:00
// if(($GLOBALS['HTTP_GET_VARS']['cal_id'] > 0) && ($event['owner'] == $this->bo->owner) && $this->bo->check_perms(PHPGW_ACL_DELETE))
if ( $this -> bo -> check_perms ( PHPGW_ACL_DELETE , $event ))
2001-07-16 13:38:40 +02:00
{
2002-09-17 04:25:40 +02:00
$delete_type = get_var ( 'delete_type' , Array ( 'POST' ));
if ( $delete_type == 'single' )
2001-11-03 02:52:26 +01:00
{
2001-11-05 03:08:31 +01:00
$cd = $this -> bo -> delete_single (
Array (
2002-09-17 04:25:40 +02:00
'id' => intval ( $cal_id ),
2001-11-05 03:08:31 +01:00
'year' => $this -> bo -> year ,
'month' => $this -> bo -> month ,
'day' => $this -> bo -> day
)
);
2001-11-03 02:52:26 +01:00
}
2002-09-17 04:25:40 +02:00
// elseif((isset($GLOBALS['HTTP_POST_VARS']['delete_type']) && $GLOBALS['HTTP_POST_VARS']['delete_type'] == 'series') || !isset($GLOBALS['HTTP_POST_VARS']['delete_type']))
else
2001-11-03 02:52:26 +01:00
{
2002-09-17 04:25:40 +02:00
$cd = $this -> bo -> delete_entry ( intval ( $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
}
2001-08-13 16:11:07 +02:00
Header ( 'Location: ' . $this -> page ( '' , '&date=' . $date . ( $cd ? '&cd=' . $cd : '' )));
2001-08-13 23:12:16 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-07-28 15:17:30 +02:00
}
function day ()
{
$this -> bo -> read_holidays ();
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
{
$minical = '' ;
}
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
{
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
$m = mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year );
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$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
2001-07-28 15:17:30 +02:00
$var = Array (
2001-10-03 02:31:03 +02:00
'printer_friendly' => $printer ,
2001-11-05 04:48:14 +01:00
'bg_text' => $this -> theme [ 'bg_text' ],
2001-10-03 02:31:03 +02:00
'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 ,
2001-10-23 12:58:53 +02:00
'username' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ),
2001-10-03 02:31:03 +02:00
'print' => $print
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' );
2002-03-14 01:10:50 +01:00
echo $this -> printer_friendly ( $p -> fp ( 'out' , 'day' ));
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 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 ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-28 15:17:30 +02:00
2001-09-07 19:51:48 +02:00
$event = $this -> bo -> read_entry ( $GLOBALS [ 'HTTP_GET_VARS' ][ '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
{
2001-08-12 16:47:23 +02:00
echo '<center>The user ' . $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ) . ' is not participating in this event!</center>' ;
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
if ( ! $this -> bo -> check_perms ( PHPGW_ACL_EDIT ))
2001-07-16 13:38:40 +02:00
{
2001-07-28 15:17:30 +02: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' ]
)
);
2001-07-28 15:17:30 +02:00
2001-10-21 15:30:40 +02:00
$event = $this -> bo -> read_entry ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]);
2001-07-28 15:17:30 +02:00
echo $this -> view_event ( $event );
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
2001-09-07 19:51:48 +02:00
$this -> bo -> set_status ( intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ]), intval ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'action' ]));
2001-07-28 15:17:30 +02:00
Header ( 'Location: ' . $this -> page ( '' , '' ));
2001-10-03 02:31:03 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-07-16 13:38:40 +02:00
}
2001-07-28 15:17:30 +02:00
function planner ()
2001-07-18 19:32:10 +02:00
{
2002-09-17 04:25:40 +02:00
if ( floor ( phpversion ()) == 4 )
{
eval ( '
// generate header and set global/member variables
//
$this -> planner_prepare ();
// process events within selected interval
//
$this -> planner_process_interval ();
// generate the planner view
//
$this -> planner_print_rows ();
' );
}
}
/**
* planner_prepare - prepare the planner view
*
* - sets global environment variables
* - initializes class member variables used in multiple planner related functions
* - generates header lines for the planner view ( month , calendar week , days )
*/
function planner_prepare ()
{
if ( floor ( phpversion ()) == 4 )
{
eval ( '
// set some globals
//
unset ( $GLOBALS [ \ ' phpgw_info\ ' ][ \ ' flags\ ' ][ \ ' noheader\ ' ]);
unset ( $GLOBALS [ \ ' phpgw_info\ ' ][ \ ' flags\ ' ][ \ ' nonavbar\ ' ]);
$GLOBALS [ \ ' phpgw\ ' ] -> common -> phpgw_header ();
// 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\ ' ];
2001-09-07 18:37:11 +02:00
2002-09-17 04:25:40 +02:00
// set title for table and rows of planner view
//
if ( $this -> bo -> sortby == \ ' category\ ' )
{
$title = lang ( \ ' Category\ ' );
}
elseif ( $this -> bo -> sortby == \ ' user\ ' )
{
$title = lang ( \ ' User\ ' );
2001-09-07 18:37:11 +02:00
2002-09-17 04:25:40 +02:00
$o = $this -> bo -> owner ;
$type = $GLOBALS [ \ ' phpgw\ ' ] -> accounts -> get_type ( $o );
2001-07-28 15:17:30 +02:00
2002-09-17 04:25:40 +02:00
if ( $type == \ ' g\ ' ) // display schedule of all group members
{
$this -> planner_group_members = $GLOBALS [ \ ' phpgw\ ' ] -> acl -> get_ids_for_location ( $o , 1 , \ ' phpgw_group\ ' );
}
else // display schedule of owner only
{
$this -> planner_group_members [ 0 ] = $o ;
}
}
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02:00
// create/initialize variables directly used for HTML code generation
//
$this -> planner_html = CreateObject ( \ ' calendar . html\ ' );
$this -> planner_header = array ();
$this -> planner_rows = array ();
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02:00
// generate header lines with days and associated months
//
$hdr = & $this -> planner_header ;
$hdr [ 0 ][ \ ' 0 \ ' ] = $title ;
$hdr [ 0 ][ \ ' . 0 \ ' ] = \ ' rowspan = " 3 " \ ' ;
$this -> planner_days = 0 ; // reset
2001-07-28 15:17:30 +02:00
2002-09-17 04:25:40 +02:00
$m = $this -> bo -> month ;
$y = $this -> bo -> year ;
for ( $i = 1 ; $i <= $this -> bo -> num_months ; $i ++ , $m ++ )
{
if ( $m == 13 )
{
$m = 1 ; $y ++ ; // "wrap-around" into new year
}
$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 );
$color = $m % 2 == 0 ? " ccffff " : " ccffcc " ;
$cols = $days * $intervals_per_day ;
$hdr [ 0 ][ \ ' . \ ' . $i ] = \ ' bgcolor = " # \ '. $color . \ ' " colspan = " \ '. $cols . \ ' " align = " center " \ ' ;
$hdr [ 0 ][ $i ] = \ ' < font size = " -2 " > \ ' . $month . \ ' </ font > \ ' ;
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 " \ ' ;
$hdr [ 2 ][ $index ] = \ ' < a href = " \ '. $this->planner_html ->link( \ '/index.php \ ',
2001-07-28 15:17:30 +02:00
array (
2001-09-07 18:37:11 +02:00
\ ' menuaction\ ' => \ ' calendar . uicalendar . add\ ' ,
2002-09-17 04:25:40 +02:00
\ ' date\ ' => sprintf ( " %04d%02d%02d " , $y , $m , $d )
2001-07-28 15:17:30 +02:00
)
2001-09-07 18:37:11 +02:00
) . \ ' " > \ '. $dayname . \ '<br> \ '. $d . \ '</a> \ ';
2002-09-17 04:25:40 +02:00
}
$this -> planner_days += $days ;
}
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02: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 );
$this -> planner_firstday = intval ( date ( \ ' Ymd\ ' , mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year )));
$this -> planner_lastday = intval ( date ( \ ' Ymd\ ' , mktime ( 0 , 0 , 0 , $this -> planner_end_month , $this -> planner_days_in_end_month , $this -> planner_end_year )));
// generate line with calendar weeks in observed interval
//
$d = mktime ( 0 , 0 , 0 , $this -> bo -> month , 1 , $this -> bo -> year );
$w = date ( \ ' W\ ' , $d );
$offset = ( 7 - date ( " w " , $d ) + 1 ) % 7 ;
$offset = $offset == 0 ? 7 : $offset ;
$color = $w % 2 == 0 ? " ccccff " : " ffffcc " ;
$hdr [ 1 ][ \ ' . \ ' . $w ] = \ ' bgcolor = " # \ '. $color . \ ' " colspan = " \ '. $intervals_per_day * $offset . \ ' " align = " left " \ ' ;
$hdr [ 1 ][ $w ] = \ ' \ ' ;
if ( $offset >= 3 )
{
$hdr [ 1 ][ $w ] .= \ ' < font size = " -2 " > \ ' . lang ( \ ' WN \ ' ) . $w . \ ' </ font > \ ' ;
}
$days_left = $this -> planner_days - $offset ;
2001-08-06 05:36:58 +02:00
2002-09-17 04:25:40 +02: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 );
$w += ( isset ( $hdr [ 1 ][ $w ])) ? 1 : 0 ; // bug in "date(\'W\')" ?
$color = $w % 2 == 0 ? " ccccff " : " ffffcc " ;
$hdr [ 1 ][ \ ' . \ ' . $w ] = \ ' bgcolor = " # \ '. $color . \ ' " colspan = " \ '. $colspan . \ ' " align = " left " \ ' ;
$hdr [ 1 ][ $w ] = \ ' \ ' ;
if ( $days_left >= 3 )
{
$hdr [ 1 ][ $w ] .= \ ' < font size = " -2 " > \ ' . lang ( \ ' WN \ ' ) . $w . \ ' </ font > \ ' ;
}
$days_left -= 7 ;
}
return $hdr ;
' );
}
}
/**
* planner_update_row - update a row of the planner view
*
* parameters are :
* - 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
*/
function planner_update_row ( $params )
{
if ( floor ( phpversion ()) == 4 )
{
eval ( '
$index = $params [ \ ' index\ ' ];
$name = $params [ \ ' name\ ' ];
$event = $params [ \ ' event\ ' ];
$cat = $params [ \ ' category\ ' ];
$start_cell = $params [ \ ' start_cell\ ' ];
$end_cell = $params [ \ ' end_cell\ ' ];
$rows = & $this -> planner_rows ;
$intervals_per_day = $this -> bo -> prefs [ \ ' calendar\ ' ][ \ ' planner_intervals_per_day\ ' ];
$is_private = ! $event [ \ ' public \ ' ] && $this -> bo -> owner != $event [ \ ' owner\ ' ]
|| ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event );
$view = $this -> planner_html -> link ( \ ' / index . php\ ' ,
2001-07-28 15:17:30 +02:00
array (
2001-09-07 18:37:11 +02:00
\ ' menuaction\ ' => \ ' calendar . uicalendar . view\ ' ,
\ ' cal_id\ ' => $event [ \ ' id\ ' ]
2001-07-28 15:17:30 +02:00
)
);
2002-09-17 04:25:40 +02:00
// check how many lines are needed for this "row" (currently: user or category)
$i = 0 ;
2001-07-28 15:17:30 +02:00
do {
++ $i ;
2002-09-17 04:25:40 +02:00
$k = $index . \ ' _\ ' . $i ;
2001-09-07 18:37:11 +02:00
$ka = \ ' . nr_\ ' . $k ;
2002-09-17 04:25:40 +02:00
2001-07-28 15:17:30 +02:00
if ( ! isset ( $rows [ $k ]))
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
if ( $i > 1 ) // further line - no name
{
$rows [ $k ] = array ();
2002-09-17 04:25:40 +02:00
$rows [ $index . \ ' _1\ ' ][ \ ' . _name\ ' ] = \ ' rowspan = " \ '. $i . \ ' " \ ' ;
2001-07-28 15:17:30 +02:00
}
else
{
2002-09-17 04:25:40 +02:00
$rows [ $k ][ \ ' _name\ ' ] = $name ;
2001-07-28 15:17:30 +02:00
}
$rows [ $ka ] = 0 ;
2001-07-18 19:32:10 +02:00
}
2002-09-17 04:25:40 +02:00
$rows [ $index . \ ' _1\ ' ][ \ ' . _name\ ' ] .= \ ' nowrap\ ' ; // title must be one row
2001-07-28 15:17:30 +02:00
$row = & $rows [ $k ];
$akt_cell = & $rows [ $ka ];
} while ( $akt_cell > $start_cell );
if ( $akt_cell < $start_cell )
{
2001-09-29 03:40:47 +02:00
$row [ $event [ \ ' id\ ' ] . \ ' _1\ ' ] = \ ' & nbsp ; \ ' ;
2001-09-07 18:37:11 +02:00
$row [ \ ' . \ ' . $event [ \ ' id\ ' ] . \ ' _1\ ' ] = \ ' colspan = " \ '.( $start_cell - $akt_cell ). \ ' " \ ' ;
2001-07-18 19:32:10 +02:00
}
2001-09-07 18:37:11 +02:00
$opt = & $row [ \ ' . \ ' . $event [ \ ' id\ ' ] . \ ' _2\ ' ];
$cel = & $row [ $event [ \ ' id\ ' ] . \ ' _2\ ' ];
2002-09-17 04:25:40 +02:00
// if possible, display information about event within cells representing it
//
2001-07-28 15:17:30 +02:00
if ( $start_cell < $end_cell )
{
2002-09-17 04:25:40 +02:00
$colspan = $end_cell - $start_cell ;
$opt .= " colspan= " . ( 1 + $colspan );
if ( ! $is_private )
{
// FIXME: how many chars can be displayed in the event\'s cell?
//
$max_chars = 4 * $colspan / $intervals_per_day - 5 ;
$max_chars /= ( $colspan < 9 ? 2 : 1 );
$min_chars = 3 ; // minimum for max_chars to display -> this should be configurable
if ( $max_chars >= $min_chars )
{
$len_title = strlen ( $event [ \ ' title\ ' ]);
if ( $len_title < $max_chars )
{
$title = $event [ \ ' title\ ' ];
$max_chars -= $len_title - 3 ; // 3 chars for separator: " - "
$len_descr = strlen ( $event [ \ ' description\ ' ]);
if ( $len_descr > 0 && $len_descr <= $max_chars )
{
$event [ \ ' print_description\ ' ] = \ ' yes\ ' ;
}
}
else
{
$title = substr ( $event [ \ ' title\ ' ], 0 , $max_chars ) . \ ' ... \ ' ;
}
$event [ \ ' print_title\ ' ] = \ ' yes\ ' ;
}
}
2001-07-28 15:17:30 +02:00
}
2001-07-18 19:32:10 +02:00
2001-09-07 18:37:11 +02:00
if ( $bgcolor = $cat [ \ ' color\ ' ])
2001-07-28 15:17:30 +02:00
{
2001-09-07 18:37:11 +02:00
$opt .= \ ' bgcolor = " \ '. $bgcolor . \ ' " \ ' ;
2001-07-28 15:17:30 +02:00
}
2002-09-17 04:25:40 +02:00
if ( ! $is_private )
{
$opt .= \ ' title = " \ '.lang( \ 'Title \ '). " : " . $event[\'title\'] ;
if ( $event [ \ ' description\ ' ])
{
$opt .= " \n " . lang ( \ ' Description\ ' ) . " : " . $event [ \ ' description\ ' ];
}
}
else
{
$opt .= \ ' title = " \ '.lang( \ 'You do not have permission to read this record! \ '). \ ' " \ ' ;
}
$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 );
$opt .= " \n " . lang ( \ ' Start Date / Time\ ' ) . " : " . $start . " \n " . lang ( \ ' End Date / Time\ ' ) . " : " . $end ;
if ( $event [ \ ' location\ ' ])
{
$opt .= " \n " . lang ( \ ' Location\ ' ) . " : " . $event [ \ ' location\ ' ];
}
if ( ! $is_private )
{
$opt .= " \" onClick= \" location= \ ' " . $view . " \ ' \" " ;
$cel = \ ' < a href = " \ '. $view . \ ' " > \ ' ; // FIXME
}
else
2001-07-28 15:17:30 +02:00
{
2002-09-17 04:25:40 +02:00
$cel = \ ' \ ' ;
2001-07-28 15:17:30 +02:00
}
2002-09-17 04:25:40 +02:00
2001-09-07 18:37:11 +02:00
if ( $event [ \ ' priority\ ' ] == 3 )
2001-07-28 15:17:30 +02:00
{
2002-09-17 04:25:40 +02:00
$cel .= $this -> planner_html -> image ( \ ' calendar\ ' , \ ' mini - calendar - bar . gif\ ' , \ ' \ ' , \ ' border = " 0 " \ ' );
2001-07-28 15:17:30 +02:00
}
2002-09-17 04:25:40 +02:00
$cel .= $this -> planner_html -> image ( \ ' calendar\ ' , count ( $event [ \ ' participants\ ' ]) > 1 ? \ ' multi_3 . gif\ ' : \ ' single . gif\ ' , $this -> planner_participants ( $event [ \ ' participants\ ' ]), \ ' border = " 0 " \ ' );
2001-09-07 18:37:11 +02:00
$cel .= \ ' </ a > \ ' ;
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02:00
if ( isset ( $event [ \ ' print_title\ ' ]) && $event [ \ ' print_title\ ' ] == \ ' yes\ ' )
{
$cel .= \ ' < font size = " -2 " > \ ' . $title . \ ' </ font > \ ' ;
}
if ( isset ( $event [ \ ' print_description\ ' ]) && $event [ \ ' print_description\ ' ] == \ ' yes\ ' )
{
$cel .= \ ' < font size = " -2 " > - \ ' . $event [ \ ' description\ ' ] . \ ' </ font > \ ' ;
}
2001-07-28 15:17:30 +02:00
$akt_cell = $end_cell + 1 ;
2002-09-17 04:25:40 +02:00
return $rows ;
' );
2001-09-29 03:40:47 +02:00
}
2002-09-17 04:25:40 +02:00
}
function planner_process_event ( $event )
{
if ( floor ( phpversion ()) == 4 )
{
eval ( '
$intervals_per_day = $this -> bo -> prefs [ \ ' calendar\ ' ][ \ ' planner_intervals_per_day\ ' ];
$last_cell = $intervals_per_day * $this -> planner_days - 1 ;
$rows = & $this -> planner_rows ;
// caluculate start and end of event
//
$event_start = intval ( date ( \ ' Ymd\ ' , mktime ( 0 , 0 , 0 , $event [ \ ' start\ ' ][ \ ' month\ ' ],
$event [ \ ' start\ ' ][ \ ' mday\ ' ],
$event [ \ ' start\ ' ][ \ ' year\ ' ])));
$event_end = intval ( date ( \ ' Ymd\ ' , mktime ( 0 , 0 , 0 , $event [ \ ' end\ ' ][ \ ' month\ ' ],
$event [ \ ' end\ ' ][ \ ' mday\ ' ],
$event [ \ ' end\ ' ][ \ ' year\ ' ])));
// calculate first cell of event within observed interval
//
if ( $event_start >= $this -> planner_firstday )
2001-07-28 15:17:30 +02:00
{
2002-09-17 04:25:40 +02:00
$days_between = $GLOBALS [ \ ' phpgw\ ' ] -> datetime -> days_between ( $this -> bo -> month , 1 , $this -> bo -> year , $event [ \ ' start\ ' ][ \ ' month\ ' ], $event [ \ ' start\ ' ][ \ ' mday\ ' ], $event [ \ ' start\ ' ][ \ ' year\ ' ]);
$start_cell = $intervals_per_day * $days_between + $interval [ $event [ \ ' start\ ' ][ \ ' hour\ ' ]];
2001-07-28 15:17:30 +02:00
}
2002-09-17 04:25:40 +02:00
else
{
$start_cell = 0 ;
}
// calculate last cell of event within observed interval
//
if ( $event_end <= $this -> planner_lastday )
{
$days_between = $GLOBALS [ \ ' phpgw\ ' ] -> datetime -> days_between ( $event [ \ ' end\ ' ][ \ ' month\ ' ], $event [ \ ' end\ ' ][ \ ' mday\ ' ], $event [ \ ' end\ ' ][ \ ' year\ ' ], $this -> planner_end_month , $this -> planner_days_in_end_month , $this -> planner_end_year );
$end_cell = $last_cell - $intervals_per_day * ( $days_between + 1 ) + $interval [ $event [ \ ' end\ ' ][ \ ' hour\ ' ]] + 1 ;
}
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\ ' ));
}
// 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 (
Array (
\ ' index\ ' => $c ,
\ ' name\ ' => $pcat [ \ ' name\ ' ],
\ ' event\ ' => $event ,
\ ' category\ ' => $cat ,
\ ' start_cell\ ' => $start_cell ,
\ ' end_cell\ ' => $end_cell
)
);
}
elseif ( $this -> bo -> sortby == \ ' user\ ' )
{
// event needs to show up in rows of all participants that are also owners
//
for ( $j = 0 ; $j < count ( $this -> planner_group_members ); $j ++ )
{
$id = $this -> planner_group_members [ $j ];
$status = $event [ \ ' participants\ ' ][ $id ];
if ( isset ( $status ) && $status != \ ' R\ ' )
{
$user_name = $GLOBALS [ \ ' phpgw\ ' ] -> common -> grab_owner_name ( $id );
$this -> planner_update_row (
Array (
\ ' index\ ' => $id ,
\ ' name\ ' => $user_name ,
\ ' event\ ' => $event ,
\ ' category\ ' => $cat ,
\ ' start_cell\ ' => $start_cell ,
\ ' end_cell\ ' => $end_cell
)
);
}
}
}
' );
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 ()
{
if ( floor ( phpversion ()) == 4 )
2001-09-29 03:40:47 +02:00
{
2002-09-17 04:25:40 +02:00
eval ( '
$rows = & $this -> planner_rows ;
if ( $this -> bo -> sortby == \ ' user\ ' )
{
// add empty rows for users that do not participante in any event
//
for ( $j = 0 ; $j < count ( $this -> planner_group_members ); $j ++ )
{
$id = $this -> planner_group_members [ $j ];
$k = $id . \ ' _1\ ' ;
$ka = \ ' . nr_\ ' . $k ;
if ( ! isset ( $rows [ $k ]))
{
$rows [ $k ][ \ ' _name\ ' ] = $GLOBALS [ \ ' phpgw\ ' ] -> common -> grab_owner_name ( $id );
$rows [ $k ][ \ ' . _name\ ' ] .= \ ' nowrap\ ' ;
$rows [ $ka ] = 0 ;
}
}
}
// fill the remaining cols
//
$last_cell = $this -> bo -> prefs [ \ ' calendar\ ' ][ \ ' planner_intervals_per_day\ ' ] * $this -> planner_days - 1 ;
ksort ( $rows );
while ( list ( $k , $r ) = each ( $rows ))
{
if ( is_array ( $r ))
{
$rows [ \ ' . \ ' . $k ] = \ ' bgcolor = " \ '. $GLOBALS[\'phpgw\'] ->nextmatchs->alternate_row_color(). \ ' " \ ' ;
$row = & $rows [ $k ];
$akt_cell = & $rows [ \ ' . nr_\ ' . $k ];
if ( $akt_cell <= $last_cell )
{
$row [ \ ' 3 \ ' ] = \ ' & nbsp\ ' ;
$row [ \ ' . 3 \ ' ] = \ ' colspan = " \ '.(1+ $last_cell - $akt_cell ). \ ' " \ ' ;
}
}
}
' );
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 ()
{
if ( floor ( phpversion ()) == 4 )
{
eval ( '
$rows = & $this -> planner_rows ;
$bgcolor = \ ' bgcolor = " \ '. $this->theme [ \ 'th_bg \ ']. \ ' " \ ' ;
$intervals_per_day = $this -> bo -> prefs [ \ ' calendar\ ' ][ \ ' planner_intervals_per_day\ ' ];
if ( $this -> debug )
{
_debug_array ( $rows );
reset ( $rows );
}
echo $this -> planner_html -> table (
array (
\ ' _hdr0\ ' => $this -> planner_header [ 0 ],
\ ' . _hdr0\ ' => $bgcolor
) +
array (
\ ' _hdr1\ ' => $this -> planner_header [ 1 ],
\ ' . _hdr1\ ' => $bgcolor
) +
array (
\ ' _hdr2\ ' => $this -> planner_header [ 2 ],
\ ' . _hdr2\ ' => $bgcolor
) + $rows ,
\ ' width = " 100% " cols = " \ '.(1+ $this->planner_days_in_end_month * $intervals_per_day ). \ ' " \ '
);
' );
}
}
function planner_process_interval ()
{
if ( floor ( phpversion ()) == 4 )
{
eval ( '
// 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 );
// process all events within observed interval
//
for ( $v = $this -> planner_firstday ; $v <= $this -> planner_lastday ; $v ++ )
{
$daily = $this -> bo -> cached_events [ $v ];
@ reset ( $daily );
print_debug ( \ ' For Date\ ' , $v );
print_debug ( \ ' Count of items\ ' , count ( $daily ));
// process all events on day $v
//
while ( list ( $nul , $event ) = @ each ( $daily ))
{
$this -> planner_process_event ( $event );
}
}
$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
2001-08-12 16:47:23 +02:00
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$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
2001-07-28 15:17:30 +02:00
$vars = Array (
2001-10-03 02:31:03 +02:00
'matrix_action' => lang ( 'Daily Matrix View' ),
'action_url' => $this -> page ( 'viewmatrix' )
2001-07-28 15:17:30 +02:00
);
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
$p -> set_var ( $vars );
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 (
$sb -> getYears ( 'year' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'Y' )), intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'Y' ))),
$sb -> getMonthText ( 'month' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime , 'n' ))),
$sb -> getDays ( 'day' , intval ( $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
2001-08-12 16:47:23 +02:00
$accounts = $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( 'run' , 1 , 'calendar' );
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
}
2001-07-28 15:17:30 +02:00
$str = '' ;
@ asort ( $users );
@ reset ( $users );
while ( $user = each ( $users ))
{
2001-08-12 16:47:23 +02:00
if (( $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $user [ 0 ]) && $this -> bo -> check_perms ( PHPGW_ACL_READ , $user [ 0 ])) || $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $user [ 0 ]) == 'g' )
2001-07-18 19:32:10 +02:00
{
2001-08-12 16:47:23 +02:00
$str .= ' <option value="' . $user [ 0 ] . '">(' . $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $user [ 0 ]) . ') ' . $user [ 1 ] . '</option>' . " \n " ;
2001-07-18 19:32:10 +02:00
}
2001-07-28 15:17:30 +02:00
}
$var [] = Array (
'field' => lang ( 'Participants' ),
'data' => " \n " . ' <select name="participants[]" multiple size="' . $size . '">' . " \n " . $str . ' </select>' . " \n "
);
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 (
'submit_button' => lang ( 'Submit' ),
'action_url_button' => '' ,
'action_text_button' => lang ( 'Cancel' ),
'action_confirm_button' => 'onClick="history.back(-1)"' ,
'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 ()
{
2001-09-07 19:51:48 +02:00
$participants = $GLOBALS [ 'HTTP_POST_VARS' ][ 'participants' ];
2001-07-28 15:17:30 +02:00
$parts = Array ();
$acct = CreateObject ( 'phpgwapi.accounts' , $this -> bo -> owner );
2001-08-12 16:47:23 +02:00
$c_participants = count ( $participants );
for ( $i = 0 ; $i < $c_participants ; $i ++ )
2001-07-28 15:17:30 +02:00
{
2001-08-12 16:47:23 +02:00
switch ( $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $participants [ $i ]))
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
case 'g' :
2001-10-23 12:58:53 +02:00
$members = $acct -> member ( intval ( $participants [ $i ]));
2001-07-28 15:17:30 +02:00
while ( $members != False && list ( $index , $member ) = each ( $members ))
{
if ( $this -> bo -> check_perms ( PHPGW_ACL_READ , $member [ 'account_id' ]) && ! isset ( $parts [ $member [ 'account_id' ]]))
{
$parts [ $member [ 'account_id' ]] = 1 ;
}
}
break ;
case 'u' :
if ( $this -> bo -> check_perms ( PHPGW_ACL_READ , $participants [ $i ]) && ! isset ( $parts [ $participants [ $i ]]))
{
$parts [ $participants [ $i ]] = 1 ;
}
break ;
2001-07-18 19:32:10 +02:00
}
2001-07-28 15:17:30 +02:00
}
unset ( $acct );
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
$participants = Array ();
reset ( $parts );
while ( list ( $key , $value ) = each ( $parts ))
{
$participants [] = $key ;
}
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
reset ( $participants );
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' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02:00
$matrixtype = get_var ( 'matrixtype' , Array ( 'POST' ));
switch ( $matrixtype )
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
case 'free/busy' :
2002-06-25 01:24:24 +02:00
$freetime = $GLOBALS [ 'phpgw' ] -> datetime -> gmtdate ( mktime ( 0 , 0 , 0 , $this -> bo -> month , $this -> bo -> day , $this -> bo -> year ));
2001-08-12 16:47:23 +02:00
echo $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' :
2001-08-12 16:47:23 +02:00
echo $this -> display_weekly (
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
}
2001-07-28 15:17:30 +02:00
echo " \n " . '<center>' . " \n " ;
echo ' <form action="' . $this -> page ( 'viewmatrix' ) . '" method="post" name="matrixform" target="viewmatrix">' . " \n " ;
echo ' <input type="hidden" name="year" value="' . $this -> bo -> year . '">' . " \n " ;
echo ' <input type="hidden" name="month" value="' . $this -> bo -> month . '">' . " \n " ;
echo ' <input type="hidden" name="day" value="' . $this -> bo -> day . '">' . " \n " ;
2002-09-17 04:25:40 +02:00
echo ' <input type="hidden" name="matrixtype" value="' . $matrixtype . '">' . " \n " ;
2001-08-12 16:47:23 +02:00
reset ( $parts );
while ( list ( $key , $value ) = each ( $parts ))
2001-07-18 19:32:10 +02:00
{
2001-08-12 16:47:23 +02:00
echo ' <input type="hidden" name="participants[]" value="' . $key . '">' . " \n " ;
2001-07-18 19:32:10 +02:00
}
2001-07-28 15:17:30 +02:00
echo ' <input type="submit" value="' . lang ( 'refresh' ) . '">' . " \n " ;
echo ' </form>' . " \n " ;
echo '</center>' . " \n " ;
}
2001-07-18 19:32:10 +02:00
2001-07-28 15:17:30 +02:00
function search ()
{
2002-09-17 04:25:40 +02:00
$keywords = get_var ( 'keywords' , Array ( 'POST' ));
if ( ! $keywords )
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
// If we reach this, it is because they didn't search for anything,
// attempt to send them back to where they where.
2002-04-25 15:10:22 +02:00
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( $from ));
2001-09-21 04:10:00 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
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' ]);
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-28 15:17:30 +02:00
$error = '' ;
2001-07-18 19:32:10 +02:00
2002-09-17 04:25:40 +02:00
if ( strlen ( $keywords ) == 0 )
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
echo '<b>' . lang ( 'Error' ) . ':</b>' ;
echo lang ( 'You must enter one or more search keywords.' );
return ;
2001-07-18 19:32:10 +02:00
}
2002-09-17 04:25:40 +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
2002-09-17 04:25:40 +02:00
$event_ids = $this -> bo -> search_keywords ( $keywords );
2001-07-28 15:17:30 +02:00
$ids = Array ();
while ( list ( $key , $id ) = each ( $event_ids ))
{
$event = $this -> bo -> read_entry ( $id );
2002-09-17 04:25:40 +02:00
if ( ! $event [ 'public' ] && ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event ))
{
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
2001-07-30 00:09:24 +02:00
$ids [ strval ( $event [ 'id' ])] ++ ;
2001-08-12 16:47:23 +02:00
$info [ strval ( $event [ 'id' ])] = $GLOBALS [ 'phpgw' ] -> common -> show_date ( $datetime ) . $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 > 0 )
{
$matches = count ( $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 )
{
$quantity = lang ( 'x matches found' , $matches ) . '.' ;
2001-07-18 19:32:10 +02:00
}
else
{
2001-08-13 16:11:07 +02:00
echo '<b>' . lang ( 'Error' ) . ':</b>' . lang ( 'no matches found.' );
2001-07-28 15:17:30 +02:00
return ;
2001-07-18 19:32:10 +02:00
}
2001-07-16 13:38:40 +02:00
2001-07-22 01:35:22 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
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 (
2001-10-03 02:31:03 +02:00
'color' => $this -> theme [ 'bg_text' ],
'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
}
2001-07-28 15:17:30 +02:00
// now sort by number of hits
arsort ( $ids );
for ( reset ( $ids ); $key = key ( $ids ); next ( $ids ))
2001-07-18 19:32:10 +02:00
{
2001-07-28 15:17:30 +02:00
$p -> set_var ( 'result_desc' , $info [ $key ]);
$p -> parse ( 'rows' , 'search_list' , True );
2001-07-22 01:35:22 +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
);
echo '<br>UI:' ;
_debug_array ( $data );
}
/* Called only by get_list(), just prior to page footer. */
function save_sessiondata ()
{
$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 ,
'date' => $this -> bo -> date ,
'sortby' => $this -> bo -> sortby ,
'num_months' => $this -> bo -> num_months
2001-07-16 13:38:40 +02:00
);
$this -> bo -> save_sessiondata ( $data );
}
function output_template_array ( & $p , $row , $list , $var )
{
2002-08-25 06:07:21 +02:00
if ( ! isset ( $var [ 'hidden_vars' ]))
{
$var [ 'hidden_vars' ] = '' ;
}
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 ];
2002-09-17 04:25:40 +02:00
if ( $_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
}
}
2001-08-13 06:49:19 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'home' )
{
$page_app = 'calendar' ;
}
else
{
$page_app = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
}
2001-10-02 03:13:53 +02:00
return $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=' . $page_app . '.ui' . $page_app . '.' . $_page . $params );
2001-07-16 13:38:40 +02:00
}
function header ()
{
$cols = 8 ;
if ( $this -> bo -> check_perms ( PHPGW_ACL_PRIVATE ) == True )
{
$cols ++ ;
}
2001-09-20 23:29:16 +02:00
2001-07-16 13:38:40 +02:00
$tpl = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$tpl -> set_unknowns ( 'remove' );
include ( $this -> template_dir . '/header.inc.php' );
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 ()
{
2002-09-17 04:25:40 +02:00
list (,, $method ) = explode ( '.' , MENUACTION );
2001-07-16 13:38:40 +02:00
2001-07-18 19:32:10 +02:00
if ( @ $this -> bo -> printer_friendly )
2001-07-16 13:38:40 +02:00
{
2001-07-28 15:17:30 +02:00
return ;
2001-07-16 13:38:40 +02:00
}
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
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 );
2002-09-17 04:25:40 +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 ++ )
{
$begin = $sun + ( 604800 * $i );
$end = $begin + 604799 ;
$str .= '<option value="' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $begin , 'Ymd' ) . '"' . ( $begin <= $thisdate && $end >= $thisdate ? ' selected' : '' ) . '>'
. $GLOBALS [ 'phpgw' ] -> common -> show_date ( $begin , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]) . ' - '
. $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]);
}
$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
}
$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 );
2002-09-17 04:25:40 +02:00
if ( MENUACTION == 'calendar.uicalendar.planner' )
{
$str = '' ;
$date_str = '' ;
$date = get_var ( 'date' , Array ( 'GET' ));
if ( $date )
{
$date_str .= ' <input type="hidden" name="date" value="' . $date . '">' . " \n " ;
}
$date_str .= ' <input type="hidden" name="month" value="' . $this -> bo -> month . '">' . " \n " ;
$date_str .= ' <input type="hidden" name="day" value="' . $this -> bo -> day . '">' . " \n " ;
$date_str .= ' <input type="hidden" name="year" value="' . $this -> bo -> year . '">' . " \n " ;
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' ),
'hidden_vars' => $date_str ,
'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 );
$p -> parse ( 'table_row' , 'blank_row' , True );
2001-07-16 13:38:40 +02:00
$p -> pparse ( 'out' , 'footer_table' );
unset ( $p );
}
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' )
{
$time_width = ( intval ( $this -> bo -> prefs [ 'common' ][ 'time_format' ]) == 12 ? 12 : 8 );
}
else
{
$time_width = ( intval ( $this -> bo -> prefs [ 'common' ][ 'time_format' ]) == 12 ? 10 : 7 );
}
2002-01-03 13:37:15 +01:00
return 'A.minicalendar { color: #000000; font: xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalendar { color: #336699; font: italic bold xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.minicalendargrey { color: #999999; font: xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalendargrey { color: #336699; font: italic bold xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.minicalhol { background: ' . $this -> holiday_color . '; color: #000000; font: xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalhol { background: ' . $this -> holiday_color . '; color: #336699; font: italic bold xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.minicalgreyhol { background: ' . $this -> holiday_color . '; color: #999999; font: xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
. ' A.bminicalgreyhol { background: ' . $this -> holiday_color . '; color: #999999; font: italic bold xx-small ' . $this -> theme [ 'font' ] . ' }' . " \n "
2002-04-18 01:43:29 +02:00
. ' .event-on { background: ' . $this -> theme [ 'row_on' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 100 80%/110% ' . $this -> theme [ 'font' ] . '; vertical-align: middle }' . " \n "
. ' .event-off { background: ' . $this -> theme [ 'row_off' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 100 80%/110% ' . $this -> theme [ 'font' ] . '; vertical-align: middle }' . " \n "
. ' .event-holiday { background: ' . $this -> theme [ 'bg04' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 100 80%/110% ' . $this -> theme [ 'font' ] . '; vertical-align: middle }' . " \n "
2002-04-19 16:02:31 +02:00
. ' .time { background: ' . $this -> theme [ 'navbar_bg' ] . '; color: ' . $this -> theme [ 'bg_text' ] . '; font: 65%/100% ' . $this -> theme [ 'font' ] . '; width: ' . $time_width . '%; border: 1px ' . $this -> theme [ 'navbar_text' ] . '; vertical-align: middle }' . " \n "
2002-04-18 01:43:29 +02:00
. ' .tablecell { width: 80px; height: 80px }' ;
2001-08-28 05:41:16 +02:00
}
2001-07-28 15:17:30 +02:00
function no_edit ()
{
2001-10-03 02:31:03 +02:00
if ( ! $isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]))
{
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ] = True ;
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ] = True ;
$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 = $this->bo->is_private($event,$event['owner']);
// $editable = ((!$this->bo->printer_friendly) && (($is_private && $this->bo->check_perms(PHPGW_ACL_PRIVATE)) || !$is_private));
$is_private = ! $event [ 'public' ] && ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event );
$editable = ! $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 ;
2001-08-12 16:47:23 +02:00
if ( intval ( $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' ) . ' ]' ;
}
2001-08-12 16:47:23 +02:00
elseif ( intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $starttime , 'Hi' )) || $starttime != $endtime )
2001-07-16 13:38:40 +02:00
{
2001-07-30 00:09:24 +02: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 = '' ;
}
2002-04-19 16:02:31 +02:00
$text = '' ;
2001-07-16 13:38:40 +02:00
if ( ! $is_private )
{
2001-07-30 00:09:24 +02:00
$text .= $this -> bo -> display_status ( $event [ 'users_status' ]);
2001-07-16 13:38:40 +02:00
}
2002-09-17 04:25:40 +02:00
// $text = '<font size="-2" face="'.$this->theme['font'].'"><nobr>'.$time.'</nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text.'</font>'.$GLOBALS['phpgw']->browser->br;
$text = '<font size="-2" face="' . $this -> theme [ 'font' ] . '"><nobr> ' . $time . ' </nobr> ' . $this -> bo -> get_short_field ( $event , $is_private , 'title' ) . $text . ': <I>' . $this -> bo -> get_short_field ( $event , $is_private , 'description' ) . '</I></font>' . $GLOBALS [ 'phpgw' ] -> browser -> br ;
2002-04-19 16:02:31 +02:00
2001-07-16 13:38:40 +02:00
if ( $editable )
{
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' ));
$this -> link_tpl -> parse ( 'picture' , 'link_open' , True );
2001-07-16 13:38:40 +02:00
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' ),
2001-07-16 13:38:40 +02:00
'width' => 8 ,
2002-09-17 04:25:40 +02:00
'height' => 17 ,
'alt' => lang ( 'high priority' ),
'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' ),
2001-07-16 13:38:40 +02:00
'width' => 5 ,
2002-09-17 04:25:40 +02:00
'height' => 7 ,
'alt' => lang ( 'single event' ),
'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 ,
'alt' => lang ( 'recurring event' ),
'title' => lang ( 'recurring event' )
2001-07-16 13:38:40 +02:00
);
}
2002-09-17 04:25:40 +02:00
$participants = $this -> planner_participants ( $event [ 'participants' ]);
2001-07-30 00:09:24 +02:00
if ( count ( $event [ 'participants' ]) > 1 )
2001-07-16 13:38:40 +02:00
{
$picture [] = Array (
2002-02-17 04:56:58 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'multi_3' ),
2001-07-16 13:38:40 +02:00
'width' => 14 ,
2002-09-17 04:25:40 +02:00
'height' => 14 ,
'alt' => $participants ,
'title' => $participants
);
}
else
{
$picture [] = Array (
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'single' ),
'width' => 14 ,
'height' => 14 ,
'alt' => $participants ,
'title' => $participants
2001-07-16 13:38:40 +02:00
);
}
2001-07-30 00:09:24 +02:00
if ( $event [ 'public' ] == 0 )
2001-07-16 13:38:40 +02:00
{
$picture [] = Array (
2002-02-17 04:56:58 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'private' ),
2001-07-16 13:38:40 +02:00
'width' => 13 ,
2002-09-17 04:25:40 +02:00
'height' => 13 ,
'alt' => lang ( 'private' ),
'title' => lang ( 'private' )
2001-07-16 13:38:40 +02:00
);
}
2001-09-08 10:48:38 +02:00
if ( @ isset ( $event [ 'alarm' ]) && count ( $event [ 'alarm' ]) >= 1 )
{
if ( $this -> bo -> alarm_today ( $event , $rawdate_offset , $starttime ))
{
$picture [] = Array (
2002-02-17 04:56:58 +01:00
'pict' => $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'alarm' ),
2001-09-08 10:48:38 +02:00
'width' => 13 ,
2002-09-17 04:25:40 +02:00
'height' => 13 ,
'alt' => lang ( 'alarm' ),
'title' => lang ( 'alarm' )
2001-09-08 10:48:38 +02:00
);
}
}
2002-08-25 06:07:21 +02:00
$description = $this -> bo -> get_short_field ( $event , $is_private , 'description' );
2001-07-16 13:38:40 +02:00
for ( $i = 0 ; $i < count ( $picture ); $i ++ )
{
$var = Array (
2002-09-17 04:25:40 +02:00
'pic_image' => $picture [ $i ][ 'pict' ],
'width' => $picture [ $i ][ 'width' ],
'height' => $picture [ $i ][ 'height' ],
'alt' => $picture [ $i ][ 'alt' ],
'title' => $picture [ $i ][ 'title' ]
2001-07-16 13:38:40 +02:00
);
2002-06-25 01:24:24 +02:00
$this -> output_template_array ( $this -> link_tpl , 'picture' , 'pict' , $var );
2001-07-16 13:38:40 +02:00
}
}
2002-04-19 16:02:31 +02:00
else
{
$text .= '<font size="-2" face="' . $this -> theme [ 'font' ] . '">' . nl2br ( $this -> bo -> get_short_field ( $event , $is_private , 'description' )) . '</font>' . $GLOBALS [ 'phpgw' ] -> browser -> br ;
}
2001-07-16 13:38:40 +02:00
if ( $text )
{
$var = Array (
'text' => $text
);
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
}
if ( $editable )
{
2002-06-25 01:24:24 +02:00
$this -> link_tpl -> parse ( 'picture' , 'link_close' , True );
2001-07-16 13:38:40 +02:00
}
2002-06-25 01:24:24 +02:00
$str = $this -> link_tpl -> fp ( 'out' , 'link_pict' );
$this -> link_tpl -> set_var ( 'picture' , '' );
$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 ++ )
{
2002-04-18 01:43:29 +02:00
$overlapped_event = $this -> bo -> read_entry ( $overlapping_events [ $i ]);
2002-04-17 02:42:53 +02:00
$overlap .= '<li> [' . $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $overlapped_event [ 'owner' ]) . '] ' . $this -> link_to_entry ( $overlapped_event , $month , $mday , $year );
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 ;
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-28 15:17:30 +02:00
2001-08-06 04:41:36 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
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' ),
'overlap_text' => lang ( 'Your suggested time of <B> x - x </B> conflicts with the following existing calendar entries:' , $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start ), $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end )),
'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 ;
2001-07-28 15:17:30 +02:00
$names = '' ;
while ( list ( $id , $status ) = each ( $parts ))
{
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 ;
}
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 , ',' ))
{
$id_array = explode ( ',' , $ids );
}
else
{
$id_array [ 0 ] = $ids ;
}
}
@ reset ( $id_array );
$ret_val = Array ();
while ( list ( $index , $id ) = each ( $id_array ))
{
if ( ! isset ( $cats [ $id ]))
{
$cat_arr = $this -> cat -> return_single ( $id );
$cats [ $id ] = $cat_arr [ 0 ];
$cats [ $id ][ 'color' ] = strstr ( $cats [ $id ][ 'description' ], '#' );
}
$ret_val [] = $cats [ $id ];
2001-07-28 15:17:30 +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 (
2001-10-03 02:31:03 +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 (
2001-10-03 02:31:03 +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
$col_width = 14 ;
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 );
2002-04-18 01:43:29 +02:00
$col_width = 12 ;
}
2002-06-25 01:24:24 +02:00
if ( $GLOBALS [ 'phpgw' ] -> datetime -> days [ $i ][ 'weekday' ])
2002-04-18 01:43:29 +02:00
{
switch ( $col_width )
{
case 12 :
$col_width = 16 ;
break ;
case 14 :
$col_width = 20 ;
break ;
}
2001-07-16 13:38:40 +02:00
}
2002-08-25 06:07:21 +02:00
2002-04-18 01:43:29 +02:00
$p -> set_var ( 'col_width' , $col_width );
2001-07-16 13:38:40 +02:00
for ( $i = 0 ; $i < 7 ; $i ++ )
{
2002-06-25 01:24:24 +02:00
if ( $this -> bo -> prefs [ 'calendar' ][ 'weekdays_only' ] && $GLOBALS [ 'phpgw' ] -> datetime -> days [ $i ][ 'weekday' ])
2002-04-18 01:43:29 +02:00
{
2002-06-25 01:24:24 +02:00
$p -> set_var ( 'col_title' , lang ( $GLOBALS [ 'phpgw' ] -> datetime -> days [ $i ][ 'name' ]));
2002-04-18 01:43:29 +02:00
$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' );
2002-08-25 06:07:21 +02:00
2001-07-28 15:17:30 +02:00
$p -> set_file (
2002-05-05 19:47:15 +02:00
Array (
'month_header' => 'month_header.tpl' ,
'month_day' => 'month_day.tpl'
)
2002-08-25 06:07:21 +02:00
);
2001-07-16 13:38:40 +02:00
$p -> set_block ( 'month_header' , 'monthly_header' , 'monthly_header' );
$p -> set_block ( 'month_header' , 'month_column' , 'month_column' );
$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' );
$p -> set_var ( 'extra' , '' );
$p -> set_var ( 'col_width' , '14' );
if ( $display_name )
{
2001-08-12 16:47:23 +02:00
$p -> set_var ( 'column_data' , $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $owner ));
2001-07-16 13:38:40 +02:00
$p -> parse ( 'column_header' , 'month_column' , True );
$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 );
2001-07-16 13:38:40 +02:00
@ reset ( $daily );
while ( list ( $date , $day_params ) = each ( $daily ))
{
$year = intval ( substr ( $date , 0 , 4 ));
$month = intval ( substr ( $date , 4 , 2 ));
$day = intval ( substr ( $date , 6 , 2 ));
2002-06-25 01:24:24 +02:00
$dow = $GLOBALS [ 'phpgw' ] -> datetime -> day_of_week ( $year , $month , $day );
2002-04-18 01:43:29 +02:00
if ( $this -> bo -> prefs [ 'calendar' ][ 'weekdays_only' ] && ( $dow == 0 || $dow == 6 ))
{
continue ;
}
2001-07-16 13:38:40 +02:00
$var = Array (
2001-10-03 02:31:03 +02:00
'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' ])
{
2001-08-06 04:41:36 +02:00
$new_event_link = '<a href="' . $this -> page ( 'add' , '&date=' . $date ) . '">'
2001-08-12 16:47:23 +02:00
. '<img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'new.gif' ) . '" width="10" height="10" alt="' . 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
);
$p -> set_var ( $var );
2001-08-13 16:11:07 +02:00
if ( @ $day_params [ 'holidays' ])
2001-07-16 13:38:40 +02:00
{
reset ( $day_params [ 'holidays' ]);
while ( list ( $key , $value ) = each ( $day_params [ 'holidays' ]))
{
$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 );
$rep_events = $this -> bo -> cached_events [ $date ];
2001-08-13 16:11:07 +02:00
$c_rep_events = count ( $rep_events );
for ( $k = 0 ; $k < $c_rep_events ; $k ++ )
2001-07-16 13:38:40 +02:00
{
$lr_events = $rep_events [ $k ];
$p -> set_var ( 'day_events' , $this -> link_to_entry ( $lr_events , $month , $day , $year ));
$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' , '' );
if ( $day_params [ 'week' ])
{
$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' , '' );
}
}
$p -> parse ( 'column_header' , 'month_column' , True );
$p -> set_var ( 'column_data' , '' );
}
2001-07-18 19:32:10 +02:00
$this -> bo -> owner = $temp_owner ;
2001-07-16 13:38:40 +02:00
return $p -> fp ( 'out' , 'monthly_header' );
}
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
$monthstart = intval ( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $month , 1 , $year )));
$monthend = intval ( date ( 'Ymd' , mktime ( 0 , 0 , 0 , $month + 1 , 0 , $year )));
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' );
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' );
2001-07-28 15:17:30 +02:00
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
2002-08-25 06:07:21 +02:00
for ( $i = intval ( $start + $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ); intval ( 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' ];
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' );
2002-06-25 01:24:24 +02:00
$start = $GLOBALS [ 'phpgw' ] -> datetime -> get_weekday_start ( $year , $month , $day );
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
}
2002-04-18 01:43:29 +02:00
if ( $this -> bo -> prefs [ 'calendar' ][ 'weekdays_only' ])
{
$cols -= 2 ;
}
2001-07-28 15:17:30 +02:00
$var = Array (
'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
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 ];
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
$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' );
}
function view_add_day ( $day , & $repeat_days )
{
if ( $repeat_days )
{
$repeat_days .= ', ' ;
}
$repeat_days .= $day . ' ' ;
}
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->member_of_group()) || (!$event['public'] && !$this->bo->check_perms(PHPGW_ACL_PRIVATE)))
if (( ! $event [ 'participants' ][ $this -> bo -> owner ] && ! $this -> bo -> check_perms ( PHPGW_ACL_READ , $event )))
2001-08-01 13:07:04 +02:00
{
return '<center>' . lang ( 'You do not have permission to read this record!' ) . '</center>' ;
}
2001-07-16 13:38:40 +02:00
$pri = Array (
1 => lang ( 'Low' ),
2 => lang ( 'Normal' ),
3 => lang ( 'High' )
);
$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 (
'view' => 'view.tpl'
)
);
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
$var = Array (
2001-10-03 02:31:03 +02:00
'bg_text' => $this -> theme [ 'bg_text' ],
'name' => $event [ 'title' ]
2001-07-16 13:38:40 +02:00
);
$p -> set_var ( $var );
unset ( $var );
// Some browser add a \n when its entered in the database. Not a big deal
// this will be printed even though its not needed.
2001-08-17 21:32:03 +02:00
if ( $event [ 'description' ])
2001-07-16 13:38:40 +02:00
{
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Description' ),
'data' => $event [ 'description' ]
2001-07-16 13:38:40 +02:00
);
}
2001-07-30 00:09:24 +02:00
if ( $event [ 'category' ])
2001-07-16 13:38:40 +02:00
{
2001-10-01 04:34:45 +02:00
$category = Array ();
2001-07-18 19:32:10 +02:00
$this -> cat -> categories ( $this -> bo -> owner , 'calendar' );
2001-10-01 04:34:45 +02:00
if ( strpos ( $event [ 'category' ], ',' ))
{
$category = explode ( ',' , $event [ 'category' ]);
}
else
{
$category [] = $event [ 'category' ];
}
2001-09-17 04:33:19 +02:00
@ reset ( $category );
while ( list ( $key , $cat ) = each ( $category ))
{
$_cat = $this -> cat -> return_single ( $cat );
$cat_string [] = $_cat [ 0 ][ 'name' ];
}
@ reset ( $cat_string );
2001-07-16 13:38:40 +02:00
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Category' ),
'data' => implode ( ',' , $cat_string )
2001-07-16 13:38:40 +02:00
);
}
2001-09-07 18:37:11 +02:00
if ( $event [ 'location' ])
{
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Location' ),
'data' => $event [ 'location' ]
2001-09-07 18:37:11 +02:00
);
}
2001-07-16 13:38:40 +02:00
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Start Date/Time' ),
2002-08-25 06:07:21 +02:00
'data' => $GLOBALS [ 'phpgw' ] -> common -> show_date ( $this -> bo -> maketime ( $event [ 'start' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset )
2001-07-16 13:38:40 +02:00
);
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'End Date/Time' ),
2002-08-25 06:07:21 +02:00
'data' => $GLOBALS [ 'phpgw' ] -> common -> show_date ( $this -> bo -> maketime ( $event [ 'end' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset )
2001-07-16 13:38:40 +02:00
);
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Priority' ),
'data' => $pri [ $event [ 'priority' ]]
2001-07-16 13:38:40 +02:00
);
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Created By' ),
'data' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $event [ 'owner' ])
2001-07-16 13:38:40 +02:00
);
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Updated' ),
2002-08-25 06:07:21 +02:00
'data' => $GLOBALS [ 'phpgw' ] -> common -> show_date ( $this -> bo -> maketime ( $event [ 'modtime' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset )
2001-07-16 13:38:40 +02:00
);
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Private' ),
'data' => $event [ 'public' ] == True ? 'False' : 'True'
2001-07-16 13:38:40 +02:00
);
2001-09-07 20:11:38 +02:00
if ( @ isset ( $event [ 'groups' ][ 0 ]))
2001-07-16 13:38:40 +02:00
{
$cal_grps = '' ;
2001-07-30 00:09:24 +02:00
for ( $i = 0 ; $i < count ( $event [ 'groups' ]); $i ++ )
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
if ( $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $event [ 'groups' ][ $i ]))
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
$cal_grps .= ( $i > 0 ? '<br>' : '' ) . $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $event [ 'groups' ][ $i ]);
2001-07-16 13:38:40 +02:00
}
}
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Groups' ),
'data' => $cal_grps
2001-07-16 13:38:40 +02:00
);
}
$str = '' ;
2001-07-30 00:09:24 +02:00
reset ( $event [ 'participants' ]);
while ( list ( $user , $short_status ) = each ( $event [ 'participants' ]))
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
if ( $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $user ))
2001-07-16 13:38:40 +02:00
{
2001-08-12 16:47:23 +02:00
$str .= ( $str ? '<br>' : '' ) . $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $user ) . ' (' . ( $this -> bo -> check_perms ( PHPGW_ACL_EDIT , $user ) ? '<a href="' . $this -> page ( 'edit_status' , '&cal_id=' . $event [ 'id' ] . '&owner=' . $user ) . '">' . $this -> bo -> get_long_status ( $short_status ) . '</a>' : $this -> bo -> get_long_status ( $short_status )) . ')' . " \n " ;
2001-07-16 13:38:40 +02:00
}
}
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Participants' ),
'data' => $str
2001-07-16 13:38:40 +02:00
);
// Repeated Events
$rpt_type = Array (
2001-10-03 02:31:03 +02:00
MCAL_RECUR_NONE => 'none' ,
MCAL_RECUR_DAILY => 'daily' ,
MCAL_RECUR_WEEKLY => 'weekly' ,
MCAL_RECUR_MONTHLY_WDAY => 'monthlybyday' ,
MCAL_RECUR_MONTHLY_MDAY => 'monthlybydate' ,
MCAL_RECUR_YEARLY => 'yearly'
2001-07-16 13:38:40 +02:00
);
2001-07-30 00:09:24 +02:00
$str = lang ( $rpt_type [ $event [ 'recur_type' ]]);
if ( $event [ 'recur_type' ] <> MCAL_RECUR_NONE )
2001-07-16 13:38:40 +02:00
{
$str_extra = '' ;
2001-07-30 00:09:24 +02:00
if ( $event [ 'recur_enddate' ][ 'mday' ] != 0 && $event [ 'recur_enddate' ][ 'month' ] != 0 && $event [ 'recur_enddate' ][ 'year' ] != 0 )
2001-07-16 13:38:40 +02:00
{
2001-08-01 13:07:04 +02:00
$recur_end = $this -> bo -> maketime ( $event [ 'recur_enddate' ]);
2001-07-16 13:38:40 +02:00
if ( $recur_end != 0 )
{
2002-08-25 06:07:21 +02:00
$recur_end -= $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-08-12 16:47:23 +02:00
$str_extra .= lang ( 'ends' ) . ': ' . lang ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'l' )) . ', ' . lang ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'F' )) . ' ' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'd, Y' ) . ' ' ;
2001-07-16 13:38:40 +02:00
}
}
2001-07-30 00:09:24 +02:00
if ( $event [ 'recur_type' ] == MCAL_RECUR_WEEKLY || $event [ 'recur_type' ] == MCAL_RECUR_DAILY )
2001-07-16 13:38:40 +02:00
{
$repeat_days = '' ;
2001-07-18 19:32:10 +02:00
if ( $this -> bo -> prefs [ 'calendar' ][ 'weekdaystarts' ] == 'Sunday' )
2001-07-16 13:38:40 +02:00
{
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_SUNDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Sunday' ), $repeat_days );
}
}
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_MONDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Monday' ), $repeat_days );
}
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_TUESDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Tuesday' ), $repeat_days );
}
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_WEDNESDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Wednesday' ), $repeat_days );
}
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_THURSDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Thursday' ), $repeat_days );
}
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_FRIDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Friday' ), $repeat_days );
}
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_SATURDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Saturday' ), $repeat_days );
}
2001-07-18 19:32:10 +02:00
if ( $this -> bo -> prefs [ 'calendar' ][ 'weekdaystarts' ] == 'Monday' )
2001-07-16 13:38:40 +02:00
{
2001-07-30 00:09:24 +02:00
if ( !! ( $event [ 'recur_data' ] & MCAL_M_SUNDAY ) == True )
2001-07-16 13:38:40 +02:00
{
$this -> view_add_day ( lang ( 'Sunday' ), $repeat_days );
}
}
if ( $repeat_days <> '' )
{
$str_extra .= lang ( 'days repeated' ) . ': ' . $repeat_days ;
}
}
2001-08-26 14:31:28 +02:00
if ( $event [ 'recur_interval' ] != 0 )
2001-07-16 13:38:40 +02:00
{
2001-07-30 00:09:24 +02:00
$str_extra .= lang ( 'Interval' ) . ': ' . $event [ 'recur_interval' ];
2001-07-16 13:38:40 +02:00
}
if ( $str_extra )
{
$str .= ' (' . $str_extra . ')' ;
}
$var [] = Array (
2001-10-03 02:31:03 +02:00
'field' => lang ( 'Repetition' ),
'data' => $str
2001-07-16 13:38:40 +02:00
);
}
for ( $i = 0 ; $i < count ( $var ); $i ++ )
{
$this -> output_template_array ( $p , 'row' , 'list' , $var [ $i ]);
}
2001-10-26 01:52:15 +02:00
if ( $alarms && @ isset ( $event [ 'alarm' ]))
2001-09-04 05:17:49 +02:00
{
$p -> set_var ( 'hr_text' , '<hr>' );
$p -> parse ( 'row' , 'hr' , True );
$p -> set_var ( 'hr_text' , '<center><b>' . lang ( 'Alarms' ) . '</b></center><br>' );
$p -> parse ( 'row' , 'hr' , True );
2001-09-08 10:48:38 +02:00
@ reset ( $event [ 'alarm' ]);
while ( list ( $key , $alarm ) = each ( $event [ 'alarm' ]))
2001-09-04 05:17:49 +02:00
{
2001-09-08 10:48:38 +02:00
$icon = '<img src="' . $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' ,( $alarm [ 'enabled' ] ? 'enabled.gif' : 'disabled.gif' )) . '" width="13" height="13">' ;
2001-09-04 05:17:49 +02:00
$var = Array (
2001-10-03 02:31:03 +02:00
'field' => $icon . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $alarm [ 'time' ]),
'data' => $alarm [ 'text' ]
2001-09-04 05:17:49 +02:00
);
$this -> output_template_array ( $p , 'row' , 'list' , $var );
}
}
$p -> set_var ( 'hr_text' , '<hr>' );
$p -> parse ( 'row' , 'hr' , True );
2001-07-16 13:38:40 +02:00
return $p -> fp ( 'out' , 'view_event' );
}
2001-07-18 19:32:10 +02: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 (
2001-08-13 16:11:07 +02:00
'syear' => $params [ 'year' ],
2001-11-03 02:52:26 +01:00
'smonth' => $params [ 'month' ],
2001-08-13 16:11:07 +02:00
'sday' => $params [ 'day' ],
'eyear' => $params [ 'year' ],
2001-11-03 02:52:26 +01:00
'emonth' => $params [ 'month' ],
2001-08-13 16:11:07 +02:00
'eday' => $params [ 'day' ]
2001-08-13 03:34:32 +02:00
)
);
2001-07-18 19:32:10 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_unknowns ( 'keep' );
$templates = Array (
2001-10-03 02:31:03 +02:00
'day_cal' => 'day_cal.tpl'
2001-07-18 19:32:10 +02: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' );
if ( ! $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ] &&
! $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ])
{
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'workdaystarts' , 8 );
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'workdayends' , 16 );
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
2001-07-18 19:32:10 +02:00
$this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ] = 8 ;
$this -> bo -> prefs [ 'calendar' ][ 'workdayends' ] = 16 ;
}
2001-08-13 06:49:19 +02:00
if ( ! isset ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]))
{
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'interval' , 60 );
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
$this -> bo -> prefs [ 'calendar' ][ 'interval' ] = 60 ;
}
2002-09-17 04:25:40 +02:00
print_debug ( 'Interval set to' , intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]));
2001-08-13 03:34:32 +02:00
2001-07-18 19:32:10 +02:00
for ( $i = 0 ; $i < 24 ; $i ++ )
{
2001-08-13 03:34:32 +02:00
for ( $j = 0 ; $j < ( 60 / intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ])); $j ++ )
{
$rowspan_arr [ $i ][ $j ] = 0 ;
2002-08-25 06:07:21 +02:00
$time [ $ind ][ $j ] = '' ;
2001-08-13 03:34:32 +02:00
}
2001-07-18 19:32:10 +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
$time = Array ();
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 );
2001-07-22 01:35:22 +02:00
if ( $daily [ $date_to_eval ][ 'appts' ])
2002-08-25 06:07:21 +02:00
{
2002-05-05 19:47:15 +02:00
$starttime = 0 ;
$endtime = 0 ;
2001-07-18 19:32:10 +02:00
$events = $this -> bo -> cached_events [ $date_to_eval ];
$c_events = count ( $events );
2002-09-17 04:25:40 +02:00
print_debug ( 'Date' , $date_to_eval );
print_debug ( 'Count' , $c_events );
2001-07-18 19:32:10 +02:00
for ( $i = 0 ; $i < $c_events ; $i ++ )
{
2001-08-12 16:47:23 +02:00
if ( $events [ $i ][ 'recur_type' ] == MCAL_RECUR_NONE )
{
2002-02-17 04:56:58 +01:00
$ind = 0 ;
$interval_start = 0 ;
2001-08-13 16:11:07 +02:00
if ( $events [ $i ][ 'start' ][ 'mday' ] < $params [ 'day' ])
2001-08-12 16:47:23 +02:00
{
2001-08-13 16:11:07 +02:00
if ( $events [ $i ][ 'end' ][ 'mday' ] > $params [ 'day' ])
2001-08-12 16:47:23 +02:00
{
$ind = 99 ;
2001-08-13 03:34:32 +02:00
$interval_start = 0 ;
2001-08-12 16:47:23 +02:00
}
2001-08-13 16:11:07 +02:00
elseif ( $events [ $i ][ 'end' ][ 'mday' ] == $params [ 'day' ])
2001-08-12 16:47:23 +02:00
{
$ind = 0 ;
2001-08-13 03:34:32 +02:00
$interval_start = 0 ;
2001-08-12 16:47:23 +02:00
}
}
2001-08-13 16:11:07 +02:00
elseif ( $events [ $i ][ 'start' ][ 'mday' ] == $params [ 'day' ])
2001-08-12 16:47:23 +02:00
{
$ind = intval ( $events [ $i ][ 'start' ][ 'hour' ]);
2001-08-13 03:34:32 +02:00
$interval_start = intval ( $events [ $i ][ 'start' ][ 'min' ] / intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]));
2002-09-17 04:25:40 +02:00
print_debug ( 'Start Time Minutes' , $events [ $i ][ 'start' ][ 'min' ]);
print_debug ( 'Interval' , $interval_start );
2001-08-12 16:47:23 +02:00
}
}
else
{
2001-10-03 02:31:03 +02:00
$ind = intval ( $events [ $i ][ 'start' ][ 'hour' ]);
2001-08-13 03:34:32 +02:00
$interval_start = intval ( $events [ $i ][ 'start' ][ 'min' ] / intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]));
2001-10-03 02:31:03 +02:00
}
2001-07-28 15:17:30 +02:00
2002-02-17 04:56:58 +01:00
if (( $ind < intval ( $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ])) || ( $ind > intval ( $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ])))
{
$ind = 99 ;
2001-08-13 03:34:32 +02:00
$interval_start = 0 ;
2002-02-17 04:56:58 +01:00
}
if ((( $ind <> 99 ) && ( $ind <> 0 )) && (( $starttime <> 0 ) && ( $endtime <> 0 )))
{
2002-09-17 04:25:40 +02:00
print_debug ( 'IND before' , $ind );
2002-02-18 01:28:54 +01:00
if (( $ind >= date ( 'H' , $last_starttime )) && ( $ind <= date ( 'H' , $last_endtime )))
2002-02-17 04:56:58 +01:00
{
$ind = $last_ind ;
$interval_start = $last_interval_start ;
}
2002-09-17 04:25:40 +02:00
print_debug ( 'IND after' , $ind );
2002-02-17 04:56:58 +01:00
}
2001-07-28 15:17:30 +02:00
2001-08-13 16:11:07 +02:00
$time [ $ind ][ $interval_start ] .= $this -> link_to_entry ( $events [ $i ], $params [ 'month' ], $params [ 'day' ], $params [ 'year' ]);
2001-07-28 15:17:30 +02:00
2002-09-17 04:25:40 +02:00
print_debug ( 'IND' , $ind );
print_debug ( 'TIME' , $time [ $ind ][ $interval_start ]);
2002-02-17 04:56:58 +01:00
2001-08-12 16:47:23 +02:00
$starttime = $this -> bo -> maketime ( $events [ $i ][ 'start' ]);
$endtime = $this -> bo -> maketime ( $events [ $i ][ 'end' ]);
2001-07-28 15:17:30 +02:00
if ( $starttime <> $endtime )
{
2002-02-17 04:56:58 +01:00
$rowspan = $rowspan_arr [ $ind ][ $interval_start ];
if ( $rowspan == 0 )
{
$rowspan = intval (( $endtime - $starttime ) / ( 60 * intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ])));
}
elseif ( $last_endtime < $endtime )
{
$rowspan = intval (( $endtime - $last_starttime ) / ( 60 * intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ])));
}
2002-08-25 06:07:21 +02:00
2001-07-28 15:17:30 +02:00
$mins = ( int )((( $endtime - $starttime ) / 60 ) % 60 );
2002-08-25 06:07:21 +02:00
2001-08-13 06:49:19 +02:00
if (( $mins <> 0 && $mins <= intval ( 60 / intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]))) || ( $mins == 0 && date ( 'i' , $endtime ) > intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ])))
2001-07-28 15:17:30 +02:00
{
$rowspan += 1 ;
}
2002-09-17 04:25:40 +02:00
print_debug ( 'Rowspan being set to' , $rowspan );
2001-08-13 03:34:32 +02:00
if ( $rowspan > $rowspan_arr [ $ind ][ $interval_start ] && $rowspan > 1 )
{
$rowspan_arr [ $ind ][ $interval_start ] = $rowspan ;
2001-07-28 15:17:30 +02:00
}
}
2002-02-17 04:56:58 +01:00
$last_ind = $ind ;
$last_interval_start = $interval_start ;
$last_starttime = $starttime ;
$last_endtime = $endtime ;
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 ));
print_debug ( 'Start' , $ind );
print_debug ( 'Interval #' , $interval_start );
2001-07-18 19:32:10 +02:00
}
}
// squish events that use the same cell into the same cell.
// For example, an event from 8:00-9:15 and another from 9:30-9:45 both
// want to show up in the 8:00-9:59 cell.
$holiday_names = $daily [ $date_to_eval ][ 'holidays' ];
if ( ! $holiday_names )
{
2002-01-03 13:37:15 +01:00
if ( $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color () == $this -> theme [ 'row_on' ])
{
$row_to_print = '_on' ;
}
else
{
$row_to_print = '_off' ;
}
2001-07-18 19:32:10 +02:00
}
else
{
2002-01-03 13:37:15 +01:00
$row_to_print = '_holiday' ;
2001-07-18 19:32:10 +02:00
while ( list ( $index , $name ) = each ( $holiday_names ))
{
2001-08-13 03:34:32 +02:00
$time [ 99 ][ 0 ] = '<center>' . $name . '</center>' . $time [ 99 ][ 0 ];
2001-07-18 19:32:10 +02:00
}
}
2001-08-13 03:34:32 +02:00
if ( isset ( $time [ 99 ][ 0 ]))
2001-07-18 19:32:10 +02:00
{
2002-01-03 13:37:15 +01:00
$var [ 'event' ] = $time [ 99 ][ 0 ];
$this -> output_template_array ( $p , 'item' , 'day_event' . $row_to_print , $var );
2001-07-18 19:32:10 +02:00
$var = Array (
2001-10-03 02:31:03 +02:00
'open_link' => '' ,
'time' => ' ' ,
'close_link' => ''
2001-07-18 19:32:10 +02:00
);
2001-07-22 01:35:22 +02:00
$this -> output_template_array ( $p , 'item' , 'day_time' , $var );
2001-07-18 19:32:10 +02:00
$p -> parse ( 'row' , 'day_row' , True );
$p -> set_var ( 'item' , '' );
}
$rowspan = 0 ;
2001-07-22 01:35:22 +02:00
for ( $i = ( int ) $this -> bo -> prefs [ 'calendar' ][ 'workdaystarts' ]; $i <= ( int ) $this -> bo -> prefs [ 'calendar' ][ 'workdayends' ]; $i ++ )
2001-07-18 19:32:10 +02:00
{
2001-08-13 03:34:32 +02:00
for ( $j = 0 ; $j < ( 60 / intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ])); $j ++ )
2001-07-18 19:32:10 +02:00
{
2001-08-13 03:34:32 +02:00
$dtime = $this -> bo -> build_time_for_display (( $i * 10000 ) + (( $j * intval ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ])) * 100 ));
$p -> set_var ( 'extras' , '' );
$p -> set_var ( 'event' , ' ' );
if ( $rowspan > 1 )
2001-07-18 19:32:10 +02:00
{
2001-08-13 03:34:32 +02:00
// this might mean there's an overlap, or it could mean one event
// ends at 11:15 and another starts at 11:30.
if ( isset ( $time [ $i ][ $j ]))
{
$p -> set_var ( 'event' , $time [ $i ][ $j ]);
2002-01-03 13:37:15 +01:00
if ( $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color () == $this -> theme [ 'row_on' ])
{
$row_to_print = '_on' ;
}
else
{
$row_to_print = '_off' ;
}
$p -> parse ( 'item' , 'day_event' . $row_to_print , False );
2001-08-13 03:34:32 +02:00
}
$rowspan -- ;
}
elseif ( ! isset ( $time [ $i ][ $j ]))
{
$p -> set_var ( 'event' , ' ' );
2002-01-03 13:37:15 +01:00
if ( $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color () == $this -> theme [ 'row_on' ])
{
$row_to_print = '_on' ;
}
else
{
$row_to_print = '_off' ;
}
$p -> parse ( 'item' , 'day_event' . $row_to_print , False );
2001-07-18 19:32:10 +02:00
}
2001-08-13 03:34:32 +02:00
else
2001-07-18 19:32:10 +02:00
{
2001-08-13 03:34:32 +02:00
$rowspan = intval ( $rowspan_arr [ $i ][ $j ]);
if ( $rowspan > 1 )
{
$p -> set_var ( 'extras' , ' rowspan="' . $rowspan . '"' );
}
$p -> set_var ( 'event' , $time [ $i ][ $j ]);
2002-01-03 13:37:15 +01:00
if ( $GLOBALS [ 'phpgw' ] -> nextmatchs -> alternate_row_color () == $this -> theme [ 'row_on' ])
{
$row_to_print = '_on' ;
}
else
{
$row_to_print = '_off' ;
}
$p -> parse ( 'item' , 'day_event' . $row_to_print , False );
2001-07-18 19:32:10 +02:00
}
2001-08-13 03:34:32 +02:00
$open_link = ' - ' ;
$close_link = '' ;
2002-09-17 04:25:40 +02:00
2001-08-13 03:34:32 +02:00
if ( ! $this -> bo -> printer_friendly && $this -> bo -> check_perms ( PHPGW_ACL_ADD ))
2001-07-18 19:32:10 +02:00
{
2001-08-13 03:34:32 +02:00
$new_hour = intval ( substr ( $dtime , 0 , strpos ( $dtime , ':' )));
if ( $this -> bo -> prefs [ 'common' ][ 'timeformat' ] == '12' && $i > 12 )
{
$new_hour += 12 ;
}
2002-09-17 04:25:40 +02:00
2001-08-13 03:34:32 +02:00
$open_link .= '<a href="' . $this -> page ( 'add' , '&date=' . $date_to_eval . '&hour=' . $new_hour . '&minute=' . substr ( $dtime , strpos ( $dtime , ':' ) + 1 , 2 )) . '">' ;
2002-09-17 04:25:40 +02:00
2001-08-13 03:34:32 +02:00
$close_link = '</a>' ;
}
2001-07-18 19:32:10 +02:00
2001-08-13 03:34:32 +02:00
$var = Array (
2001-10-03 02:31:03 +02:00
'open_link' => $open_link ,
'time' => ( intval ( substr ( $dtime , 0 , strpos ( $dtime , ':' ))) < 10 ? '0' . $dtime : $dtime ),
'close_link' => $close_link
2001-08-13 03:34:32 +02:00
);
2002-09-17 04:25:40 +02:00
2001-08-13 03:34:32 +02:00
$this -> output_template_array ( $p , 'item' , 'day_time' , $var );
$p -> parse ( 'row' , 'day_row' , True );
$p -> set_var ( 'event' , '' );
$p -> set_var ( 'item' , '' );
}
2001-07-18 19:32:10 +02:00
} // end for
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' ];
2001-07-22 01:35:22 +02:00
if ( ! isset ( $this -> bo -> prefs [ 'calendar' ][ 'interval' ]))
{
$this -> bo -> prefs [ 'calendar' ][ 'interval' ] = 15 ;
2001-08-12 16:47:23 +02:00
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'calendar' , 'interval' , 15 );
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
2001-07-22 01:35:22 +02:00
}
2002-05-05 19:47:15 +02:00
$increment = $this -> bo -> prefs [ 'calendar' ][ 'interval' ];
// $increment = 15;
2001-07-22 01:35:22 +02:00
$interval = ( int )( 60 / $increment );
2002-05-05 19:47:15 +02:00
$pix = $GLOBALS [ 'phpgw' ] -> common -> image ( 'calendar' , 'pix' );
2001-07-28 15:17:30 +02:00
2001-08-12 16:47:23 +02:00
$str = '<center>' . lang ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $date [ 'raw' ], 'l' ))
. ', ' . lang ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $date [ 'raw' ], 'F' ))
. ' ' . $GLOBALS [ 'phpgw' ] -> common -> show_date ( $date [ 'raw' ], 'd, Y' ) . '<br>'
2001-07-28 15:17:30 +02:00
. '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="' . (( 24 * $interval ) + 1 ) . '">'
. '<tr><td height="1" colspan="' . (( 24 * $interval ) + 1 ) . '" bgcolor="black"><img src="' . $pix . '"></td></tr>'
2001-08-13 16:11:07 +02:00
. '<tr><td width="15%"><font color="' . $this -> theme [ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">' . lang ( 'Participant' ) . '</font></td>' ;
2001-07-22 01:35:22 +02:00
for ( $i = 0 ; $i < 24 ; $i ++ )
{
for ( $j = 0 ; $j < $interval ; $j ++ )
{
switch ( $j )
{
case 0 :
case 1 :
switch ( $j )
{
case 0 :
$pre = '0' ;
break ;
case 1 :
$pre = substr ( strval ( $i ), 0 , 1 );
break ;
}
$k = ( $i <= 9 ? $pre : substr ( $i , $j , $j + 1 ));
if ( $increment == 60 )
{
$k .= substr ( strval ( $i ), strlen ( strval ( $i )) - 1 , 1 );
}
2001-08-13 16:11:07 +02:00
$str .= '<td align="left" bgcolor="' . $this -> theme [ 'bg_color' ] . '"><font color="' . $phpgw_info [ 'theme' ][ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">'
2001-07-28 15:17:30 +02:00
. '<a href="' . $this -> page ( 'add' , '&date=' . $date [ 'full' ] . '&hour=' . $i . '&minute=' . ( interval * $j )) . " \" onMouseOver= \" window.status=' " . $i . ':' . (( $increment * $j ) <= 9 ? '0' : '' ) . ( $increment * $j ) . " '; return true; \" > "
. $k . '</a></font></td>' ;
2001-07-22 01:35:22 +02:00
break ;
default :
2001-08-13 16:11:07 +02:00
$str .= '<td align="left" bgcolor="' . $this -> theme [ 'bg_color' ] . '"><font color="' . $phpgw_info [ 'theme' ][ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">'
2001-07-28 15:17:30 +02:00
. '<a href="' . $this -> page ( 'add' , '&date=' . $date [ 'full' ] . '&hour=' . $i . '&minute=' . ( interval * $j )) . " \" onMouseOver= \" window.status=' " . $i . ':' . ( $increment * $j ) . " '; return true; \" > "
. ' </a></font></td>' ;
2001-07-22 01:35:22 +02:00
break ;
}
}
}
2001-07-28 15:17:30 +02:00
$str .= '</tr>'
. '<tr><td height="1" colspan="' . (( 24 * $interval ) + 1 ) . '" bgcolor="black"><img src="' . $pix . '"></td></tr>' ;
2001-07-22 01:35:22 +02:00
if ( ! $endtime )
{
$endtime = $starttime ;
}
$owner = $this -> bo -> owner ;
while ( list ( $part , $status ) = each ( $participants ))
{
2001-07-28 15:17:30 +02:00
$str .= '<tr>'
2001-08-13 16:11:07 +02:00
. '<td width="15%"><font color="' . $this -> theme [ 'bg_text' ] . '" face="' . $this -> theme [ 'font' ] . '" size="-2">' . $this -> bo -> get_fullname ( $part ) . '</font></td>' ;
2001-07-22 01:35:22 +02:00
$this -> bo -> cached_events = Array ();
$this -> bo -> owner = $part ;
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' ]])
{
for ( $j = 0 ; $j < 24 ; $j ++ )
{
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
}
}
}
else
{
$time_slice = $this -> bo -> prepare_matrix ( $interval , $increment , $part , $status , $date [ 'full' ]);
for ( $h = 0 ; $h < 24 ; $h ++ )
{
$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' ];
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' ];
2001-07-22 01:35:22 +02:00
break ;
}
2001-08-13 16:11:07 +02:00
$str .= '<td height="1" align="left" bgcolor="' . $time_slice [ $index ][ 'color' ] . " \" color= \" #999999 \" onMouseOver= \" window.status=' " . $time_slice [ $index ][ 'description' ] . " '; return true; \" > " . '<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
}
}
}
2001-07-28 15:17:30 +02:00
$str .= '</tr>'
. '<tr><td height="1" colspan="' . (( 24 * $interval ) + 1 ) . '" bgcolor="#999999"><img src="' . $pix . '"></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 " ;
2001-07-22 01:35:22 +02:00
}
function get_response ( $cal_id )
{
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
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 ))
{
2001-08-27 05:03:41 +02:00
if ( ! ( $param == REJECTED && $ev [ 'owner' ] == $this -> bo -> owner ))
{
$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 " ;
}
2001-07-22 01:35:22 +02:00
}
2001-07-28 15:17:30 +02:00
return '<table width="100%" cols="4"><tr align="center">' . " \n " . $str . '</tr></table>' . " \n " ;
}
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 );
$sb = CreateObject ( 'phpgwapi.sbox' );
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 ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
2001-07-28 15:17:30 +02:00
$p = CreateObject ( 'phpgwapi.Template' , $this -> template_dir );
$p -> set_file (
Array (
2001-10-03 02:31:03 +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' );
$vars = Array (
2001-10-03 02:31:03 +02:00
'font' => $this -> theme [ 'font' ],
'bg_color' => $this -> theme [ 'bg_text' ],
'calendar_action' => ( $event [ 'id' ] ? lang ( 'Calendar - Edit' ) : lang ( 'Calendar - Add' )),
'action_url' => $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , Array ( 'menuaction' => 'calendar.bocalendar.update' )),
2002-01-06 06:58:49 +01:00
'common_hidden' => '<input type="hidden" name="cal[id]" value="' . $event [ 'id' ] . '">' . " \n "
. '<input type="hidden" name="cal[owner]" value="' . $this -> bo -> owner . '">' . " \n "
. '<input type="hidden" name="cal[uid]" value="' . $event [ 'uid' ] . '">' . " \n "
. ( $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ] && $event [ 'id' ] == 0 ? '<input type="hidden" name="cal[reference]" value="' . $GLOBALS [ 'HTTP_GET_VARS' ][ 'cal_id' ] . '">' . " \n " :
( @ isset ( $event [ 'reference' ]) ? '<input type="hidden" name="cal[reference]" value="' . $event [ 'reference' ] . '">' . " \n " : '' ))
. ( @ isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'deny_user_grants_access' ]) && $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'deny_user_grants_access' ] ?
'<input type="hidden" name="participants[]" value="' . $this -> bo -> owner . '">' . " \n " : '' ),
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
$var [] = Array (
'field' => lang ( 'Title' ),
2001-07-30 00:09:24 +02:00
'data' => '<input name="cal[title]" size="25" maxlength="80" value="' . $event [ 'title' ] . '">'
2001-07-28 15:17:30 +02:00
);
// Full Description
$var [] = Array (
'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 ))
{
$check_cats [] = intval ( $value );
}
}
elseif ( $event [ 'category' ])
{
$check_cats [] = intval ( $event [ 'category' ]);
}
else
{
$check_cats [] = 0 ;
}
2001-07-28 15:17:30 +02:00
$var [] = Array (
'field' => lang ( 'Category' ),
2001-09-20 03:39:46 +02:00
'data' => '<select name="categories[]" multiple size="5"><option value="0">' . lang ( 'Choose the category' ) . '</option>' . $this -> cat -> formated_list ( 'select' , 'all' , $check_cats , True ) . '</select>'
2001-09-07 18:37:11 +02:00
);
// Location
$var [] = Array (
'field' => lang ( 'Location' ),
'data' => '<input name="cal[location]" size="25" maxlength="80" value="' . $event [ 'location' ] . '">'
2001-07-28 15:17:30 +02:00
);
// Date
2002-08-25 06:07:21 +02:00
$start = $this -> bo -> maketime ( $event [ 'start' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-07-28 15:17:30 +02:00
$var [] = Array (
'field' => lang ( 'Start Date' ),
2001-08-12 16:47:23 +02:00
'data' => $GLOBALS [ 'phpgw' ] -> common -> dateformatorder (
$sb -> getYears ( 'start[year]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start , 'Y' ))),
$sb -> getMonthText ( 'start[month]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start , 'n' ))),
$sb -> getDays ( 'start[mday]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $start , 'd' )))
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
}
$var [] = Array (
'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 ;
2001-07-28 15:17:30 +02:00
$var [] = Array (
'field' => lang ( 'End Date' ),
2001-08-12 16:47:23 +02:00
'data' => $GLOBALS [ 'phpgw' ] -> common -> dateformatorder (
$sb -> getYears ( 'end[year]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , 'Y' ))),
$sb -> getMonthText ( 'end[month]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , 'n' ))),
$sb -> getDays ( 'end[mday]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $end , 'd' )))
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
}
$var [] = 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
$var [] = Array (
'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
$var [] = Array (
'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
{
2002-01-06 06:58:49 +01:00
$accounts = $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( 'run' , 1 , 'calendar' );
$users = Array ();
$this -> build_part_list ( $users , $accounts , $this -> bo -> owner );
2002-08-25 06:07:21 +02:00
2002-01-06 06:58:49 +01:00
$str = '' ;
@ asort ( $users );
@ reset ( $users );
while ( list ( $id , $user_array ) = each ( $users ))
2001-07-28 15:17:30 +02:00
{
2002-01-06 06:58:49 +01:00
if ( $id != intval ( $this -> bo -> owner ))
{
$str .= ' <option value="' . $id . '"' . ( $event [ 'participants' ][ $id ] ? ' selected' : '' ) . '>(' . $user_array [ 'type' ] . ') ' . $user_array [ 'name' ] . '</option>' . " \n " ;
}
2001-07-28 15:17:30 +02:00
}
2002-01-06 06:58:49 +01:00
$var [] = Array (
'field' => lang ( 'Participants' ),
'data' => " \n " . ' <select name="participants[]" multiple size="5">' . " \n " . $str . ' </select>'
);
2001-07-28 15:17:30 +02:00
// I Participate
2002-01-06 06:58:49 +01:00
if ((( $event [ 'id' ] > 0 ) && isset ( $event [ 'participants' ][ $this -> bo -> owner ])) || ! $event [ 'id' ])
{
$checked = ' checked' ;
}
else
{
$checked = '' ;
}
$var [] = Array (
'field' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $this -> bo -> owner ) . ' ' . lang ( 'Participates' ),
'data' => '<input type="checkbox" name="participants[]" value="' . $this -> bo -> owner . '"' . $checked . '>'
);
2001-10-03 02:31:03 +02:00
}
2002-01-06 06:58:49 +01:00
2001-07-28 15:17:30 +02:00
for ( $i = 0 ; $i < count ( $var ); $i ++ )
{
$this -> output_template_array ( $p , 'row' , 'list' , $var [ $i ]);
}
unset ( $var );
// Repeat Type
$p -> set_var ( 'hr_text' , '<hr>' );
$p -> parse ( 'row' , 'hr' , True );
$p -> set_var ( 'hr_text' , '<center><b>' . lang ( 'Repeating Event Information' ) . '</b></center><br>' );
$p -> parse ( 'row' , 'hr' , True );
$rpt_type = Array (
MCAL_RECUR_NONE ,
MCAL_RECUR_DAILY ,
MCAL_RECUR_WEEKLY ,
MCAL_RECUR_MONTHLY_WDAY ,
MCAL_RECUR_MONTHLY_MDAY ,
MCAL_RECUR_YEARLY
);
$rpt_type_out = Array (
2001-10-03 02:31:03 +02:00
MCAL_RECUR_NONE => 'None' ,
MCAL_RECUR_DAILY => 'Daily' ,
MCAL_RECUR_WEEKLY => 'Weekly' ,
MCAL_RECUR_MONTHLY_WDAY => 'Monthly (by day)' ,
MCAL_RECUR_MONTHLY_MDAY => 'Monthly (by date)' ,
MCAL_RECUR_YEARLY => 'Yearly'
2001-07-28 15:17:30 +02:00
);
$str = '' ;
for ( $l = 0 ; $l < count ( $rpt_type ); $l ++ )
{
2001-07-30 00:09:24 +02:00
$str .= '<option value="' . $rpt_type [ $l ] . '"' . ( $event [ 'recur_type' ] == $rpt_type [ $l ] ? ' selected' : '' ) . '>' . lang ( $rpt_type_out [ $rpt_type [ $l ]]) . '</option>' ;
2001-07-28 15:17:30 +02:00
}
$var [] = Array (
'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
}
$var [] = Array (
'field' => lang ( 'Repeat End Date' ),
'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"' . $checked . '>' . lang ( 'Use End Date' ) . ' '
2001-08-12 16:47:23 +02:00
. $GLOBALS [ 'phpgw' ] -> common -> dateformatorder (
$sb -> getYears ( 'recur_enddate[year]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'Y' ))),
$sb -> getMonthText ( 'recur_enddate[month]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'n' ))),
$sb -> getDays ( 'recur_enddate[mday]' , intval ( $GLOBALS [ 'phpgw' ] -> common -> show_date ( $recur_end , 'd' )))
2001-07-28 15:17:30 +02:00
)
);
$var [] = Array (
'field' => lang ( 'Repeat Day' ) . '<br>' . lang ( '(for weekly)' ),
2001-07-30 00:09:24 +02:00
'data' => '<input type="checkbox" name="cal[rpt_sun]" value="' . MCAL_M_SUNDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_SUNDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Sunday' ) . ' '
. '<input type="checkbox" name="cal[rpt_mon]" value="' . MCAL_M_MONDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_MONDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Monday' ) . ' '
. '<input type="checkbox" name="cal[rpt_tue]" value="' . MCAL_M_TUESDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_TUESDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Tuesday' ) . ' '
. '<input type="checkbox" name="cal[rpt_wed]" value="' . MCAL_M_WEDNESDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_WEDNESDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Wednesday' ) . ' <br>'
. '<input type="checkbox" name="cal[rpt_thu]" value="' . MCAL_M_THURSDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_THURSDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Thursday' ) . ' '
. '<input type="checkbox" name="cal[rpt_fri]" value="' . MCAL_M_FRIDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_FRIDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Friday' ) . ' '
. '<input type="checkbox" name="cal[rpt_sat]" value="' . MCAL_M_SATURDAY . '"' . (( $event [ 'recur_data' ] & MCAL_M_SATURDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Saturday' ) . ' '
2001-07-28 15:17:30 +02:00
);
$var [] = 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
);
for ( $i = 0 ; $i < count ( $var ); $i ++ )
{
$this -> output_template_array ( $p , 'row' , 'list' , $var [ $i ]);
}
$p -> set_var ( 'submit_button' , lang ( 'Submit' ));
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' ),
'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 );
$p -> parse ( 'delete_button' , 'form_button' );
}
else
{
$p -> set_var ( 'delete_button' , '' );
}
$p -> pparse ( 'out' , 'edit_entry' );
}
function build_part_list ( & $users , $accounts , $owner )
{
if ( $accounts == False )
{
return ;
}
2001-09-07 18:37:11 +02:00
@ reset ( $accounts );
2001-07-28 15:17:30 +02:00
while ( list ( $index , $id ) = each ( $accounts ))
{
2001-09-11 05:09:18 +02:00
$i_id = intval ( $id );
if ( $i_id == $owner )
2001-07-28 15:17:30 +02:00
{
continue ;
}
2001-09-11 05:09:18 +02:00
elseif ( ! isset ( $users [ $i_id ]))
2001-07-28 15:17:30 +02:00
{
2001-09-11 05:09:18 +02:00
if ( $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $i_id ) == True )
2001-07-28 15:17:30 +02:00
{
2001-09-11 05:09:18 +02:00
$users [ $i_id ] = Array (
'name' => $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $i_id ),
'type' => $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $i_id )
);
2001-07-28 15:17:30 +02:00
}
2001-09-11 05:09:18 +02:00
if ( $GLOBALS [ 'phpgw' ] -> accounts -> get_type ( $i_id ) == 'g' )
2001-07-28 15:17:30 +02:00
{
2001-09-11 05:09:18 +02:00
$this -> build_part_list ( $users , $GLOBALS [ 'phpgw' ] -> acl -> get_ids_for_location ( $i_id , 1 , 'phpgw_group' ), $owner );
2001-07-28 15:17:30 +02:00
}
}
}
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
{
$date = date ( 'Ymd' , $datetime );
if ( $this -> debug )
{
2002-04-16 18:52:36 +02:00
echo '<!-- set_week_array : Date : ' . $date . ' -->' . " \n " ;
2001-08-26 14:31:28 +02:00
}
2001-08-28 05:41:16 +02:00
if ( $this -> bo -> cached_events [ $date ])
{
if ( $this -> debug )
{
2002-04-16 18:52:36 +02:00
echo '<!-- Date : ' . $date . ' Appointments found : ' . count ( $this -> bo -> cached_events [ $date ]) . ' -->' . " \n " ;
2001-08-28 05:41:16 +02:00
}
$appts = True ;
}
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 );
}
$day_image = '' ;
if ( $holidays )
{
$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 )
{
$extra = ' bgcolor="' . $cellcolor . '"' ;
2001-08-28 05:41:16 +02:00
$class = ( $appts ? 'b' : '' ) . 'minicalendar' ;
2001-08-26 14:31:28 +02:00
}
else
{
$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 = '' ;
if ( ! $j || ( $j && substr ( $date , 6 , 2 ) == '01' ))
{
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
}
return $daily ;
}
2001-07-16 13:38:40 +02:00
}
?>