2008-06-07 20:06:36 +02:00
< ? php
/**
* eGroupWare - Calendar hooks
*
* @ link http :// www . egroupware . org
* @ package calendar
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
2016-04-24 15:41:36 +02:00
* @ copyright ( c ) 2004 - 16 by RalfBecker - At - outdoor - training . de
2008-06-07 20:06:36 +02:00
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
* @ version $Id $
*/
2016-05-01 19:47:59 +02:00
use EGroupware\Api ;
use EGroupware\Api\Link ;
use EGroupware\Api\Egw ;
use EGroupware\Api\Acl ;
2008-06-07 20:06:36 +02:00
/**
* diverse static calendar hooks
*/
class calendar_hooks
{
/**
* Hook called by link - class to include calendar in the appregistry of the linkage
*
2014-01-30 12:03:16 +01:00
* @ param array | string $location location and other parameters ( not used )
2008-06-07 20:06:36 +02:00
* @ return array with method - names
*/
static function search_link ( $location )
{
2014-01-30 12:03:16 +01:00
unset ( $location ); // not used, but in function signature for hooks
2008-06-07 20:06:36 +02:00
return array (
'query' => 'calendar.calendar_bo.link_query' ,
'title' => 'calendar.calendar_bo.link_title' ,
'view' => array (
'menuaction' => 'calendar.calendar_uiforms.edit' ,
),
'view_id' => 'cal_id' ,
2016-05-06 17:12:27 +02:00
'view_popup' => '850x590' ,
'edit_popup' => '850x590' ,
2015-12-12 01:07:40 +01:00
'list' => array (
'menuaction' => 'calendar.calendar_uiviews.index' ,
'view' => 'listview' ,
'ajax' => 'true'
),
2019-01-10 23:01:05 +01:00
// If calendar is not loaded, load it first, then add
'add' => 'javascript:var promise = framework.setActiveApp(framework.getApplicationByName(\'calendar\')); if(promise) {promise.then(function() {et2_call(\'app.calendar.add\',params);});} else { app.calendar.add(params);}' ,
2008-06-07 20:06:36 +02:00
'add_app' => 'link_app' ,
'add_id' => 'link_id' ,
2008-10-07 11:03:01 +02:00
'file_access' => 'calendar.calendar_bo.file_access' ,
2011-06-26 17:41:21 +02:00
'file_access_user' => true , // file_access supports 4th parameter $user
2012-03-08 19:43:40 +01:00
'mime' => array (
'text/calendar' => array (
'menuaction' => 'calendar.calendar_uiforms.edit' ,
2017-06-08 15:33:08 +02:00
'mime_data' => 'ical_data' ,
'mime_url' => 'ical_url' ,
'mime_popup' => '850x590' ,
'mime_target' => '_blank'
),
'application/ics' => array (
'menuaction' => 'calendar.calendar_uiforms.edit' ,
2015-03-25 19:35:31 +01:00
'mime_data' => 'ical_data' ,
2015-03-24 10:43:38 +01:00
'mime_url' => 'ical_url' ,
2016-05-06 17:12:27 +02:00
'mime_popup' => '850x590' ,
2015-03-26 14:57:58 +01:00
'mime_target' => '_blank'
2012-03-08 19:43:40 +01:00
),
),
2012-07-04 19:00:03 +02:00
'merge' => true ,
2014-10-21 15:51:37 +02:00
'entry' => 'Event' ,
'entries' => 'Events' ,
2020-07-23 19:05:49 +02:00
'push_data' => self :: class . '::prepareEventPush' ,
2008-06-07 20:06:36 +02:00
);
}
2020-07-23 19:05:49 +02:00
/**
* Prepare event to be pushed via Link :: notify_update ()
*
* Remove privacy sensitive data :
* - participants of type email
*
* @ param $event
* @ return array
*/
static public function prepareEventPush ( $event )
{
$event = array_intersect_key ( $event , array_flip ([ 'id' , 'owner' , 'participants' , 'start' , 'end' ]));
foreach ( $event [ 'participants' ] as $uid => $status )
{
if ( $uid [ 0 ] === 'e' ) unset ( $event [ 'participants' ][ $uid ]);
}
return $event ;
}
2011-09-15 16:46:56 +02:00
/**
* Hook called to retrieve a app specific exportLimit
*
2014-01-30 12:03:16 +01:00
* @ param array | string $location location and other parameters ( not used )
2011-09-15 16:46:56 +02:00
* @ return the export_limit to be applied for the app , may be empty , int or string
*/
static function getAppExportLimit ( $location )
{
2014-01-30 12:03:16 +01:00
unset ( $location ); // not used, but in function signature for hooks
2011-09-16 15:03:46 +02:00
return $GLOBALS [ 'egw_info' ][ 'server' ][ 'calendar_export_limit' ];
2011-09-15 16:46:56 +02:00
}
2008-06-07 20:06:36 +02:00
/**
* Entries for calendar ' s admin menu
*/
static function admin ()
{
$file = Array (
2016-05-01 19:47:59 +02:00
'Site Configuration' => Egw :: link ( '/index.php' , 'menuaction=admin.admin_config.index&appname=calendar&ajax=true' ),
2017-01-17 18:24:56 +01:00
'Custom fields' => Egw :: link ( '/index.php' , 'menuaction=admin.admin_customfields.index&appname=calendar&ajax=true' ),
2016-08-12 11:35:30 +02:00
'Global Categories' => Egw :: link ( '/index.php' , 'menuaction=admin.admin_categories.index&appname=calendar&ajax=true' ),
2016-05-01 19:47:59 +02:00
'Category ACL' => Egw :: link ( '/index.php' , 'menuaction=calendar.calendar_uiforms.cat_acl' ),
'Update timezones' => Egw :: link ( '/index.php' , 'menuaction=calendar.calendar_timezones.update' ),
2008-06-07 20:06:36 +02:00
);
display_section ( 'calendar' , 'calendar' , $file );
}
/**
* Calendar preferences
2009-10-18 14:57:30 +02:00
*
* @ param array $hook_data
2008-06-07 20:06:36 +02:00
*/
2009-10-18 14:57:30 +02:00
static function settings ( $hook_data )
2008-06-07 20:06:36 +02:00
{
2009-10-18 14:57:30 +02:00
if ( ! $hook_data [ 'setup' ]) // does not work on setup time
{
2014-05-28 12:03:57 +02:00
$bo = new calendar_bo ();
$bo -> check_set_default_prefs ();
2009-10-18 14:57:30 +02:00
}
2010-11-02 10:47:06 +01:00
$yesno = array (
'1' => lang ( 'Yes' ),
'0' => lang ( 'No' ),
);
2016-01-13 00:55:59 +01:00
$list_views = array (
0 => lang ( 'None' ),
2017-10-04 09:16:52 +02:00
'month' => lang ( 'Monthview' ),
2016-01-13 00:55:59 +01:00
'weekN' => lang ( 'Multiple week view' ),
'week' => lang ( 'Weekview' ),
'day4' => lang ( 'Four days view' ),
2008-06-07 20:06:36 +02:00
'day' => lang ( 'Dayview' ),
);
$updates = array (
'no' => lang ( 'Never' ),
2018-03-26 16:02:42 +02:00
'add_cancel' => lang ( 'on invitation / cancellation only' ),
2008-06-07 20:06:36 +02:00
'time_change_4h' => lang ( 'on time change of more than 4 hours too' ),
'time_change' => lang ( 'on any time change too' ),
'modifications' => lang ( 'on all modification, but responses' ),
'responses' => lang ( 'on participant responses too' )
);
$update_formats = array (
'none' => lang ( 'None' ),
'extended' => lang ( 'Extended' ),
2009-10-18 14:57:30 +02:00
'ical' => lang ( 'iCal / rfc2445' ),
2008-06-07 20:06:36 +02:00
);
$event_details = array (
2021-12-08 19:10:39 +01:00
'to-fullname' => lang ( 'Fullname of person to notify' ),
'to-firstname' => lang ( 'Firstname of person to notify' ),
'to-lastname' => lang ( 'Lastname of person to notify' ),
'title' => lang ( 'Title of the event' ),
'description' => lang ( 'Description' ),
'startdate' => lang ( 'Start Date/Time' ),
'enddate' => lang ( 'End Date/Time' ),
'olddate' => lang ( 'Old Startdate' ),
'category' => lang ( 'Category' ),
'location' => lang ( 'Location' ),
'priority' => lang ( 'Priority' ),
'participants' => lang ( 'Participants' ),
'owner' => lang ( 'Owner' ),
'repetition' => lang ( 'Repetitiondetails (or empty)' ),
'action' => lang ( 'Action that caused the notify: Added, Canceled, Accepted, Rejected, ...' ),
'link' => lang ( 'Link to view the event' ),
'disinvited' => lang ( 'Participants uninvited from an event' ),
'fullname' => lang ( 'Current user' ),
'date' => lang ( 'Current date' )
2008-06-07 20:06:36 +02:00
);
$weekdaystarts = array (
'Monday' => lang ( 'Monday' ),
'Sunday' => lang ( 'Sunday' ),
'Saturday' => lang ( 'Saturday' )
);
2018-03-05 23:07:37 +01:00
$birthdays_as_events = array (
2018-04-10 14:02:38 +02:00
'none' => lang ( 'None' ),
2018-03-05 23:07:37 +01:00
'birthday' => lang ( 'Birthdays' ),
'holiday' => lang ( 'Holidays' )
);
2008-06-07 20:06:36 +02:00
2016-05-02 22:21:59 +02:00
if ( ! isset ( $hook_data [ 'setup' ]))
{
2016-05-03 15:24:21 +02:00
$times = Api\Etemplate\Widget\Select :: typeOptions ( 'select-hour' , '' );
2018-12-14 11:15:28 +01:00
$default_cat_seloptions = Api\Etemplate\Widget\Select :: typeOptions ( 'select-cat' , ',,,calendar' );
2016-05-02 22:21:59 +02:00
}
2016-08-12 17:23:23 +02:00
for ( $i = 2 ; $i <= 9 ; ++ $i )
2008-06-07 20:06:36 +02:00
{
2015-12-15 21:06:03 +01:00
$muliple_weeks [ $i ] = lang ( '%1 weeks' , $i );
2008-06-07 20:06:36 +02:00
}
2016-11-07 16:24:03 +01:00
for ( $i = 2 ; $i <= 20 ; $i ++ )
2015-12-23 00:34:53 +01:00
{
$consolidated [ $i ] = $i ;
}
2008-06-07 20:06:36 +02:00
$intervals = array (
5 => '5' ,
10 => '10' ,
15 => '15' ,
20 => '20' ,
30 => '30' ,
45 => '45' ,
60 => '60'
);
2015-12-29 01:11:29 +01:00
$default_participants = array (
0 => lang ( 'Just me' ),
'selected' => lang ( 'Selected users/groups' )
);
2008-10-10 12:24:31 +02:00
$defaultresource_sel = array (
2018-11-28 17:40:09 +01:00
'resources_conflict' => lang ( 'resources with conflict detection' ),
2018-11-23 18:01:58 +01:00
'resources_without_conflict' => lang ( 'resources except conflicting ones' )
2008-10-10 12:24:31 +02:00
);
2010-06-23 16:47:34 +02:00
$reset_stati_on_shifts = array (
'no' => lang ( 'Never' ),
'all' => lang ( 'Always' ),
'startday' => lang ( 'If start day differs' ),
);
2010-06-26 13:35:11 +02:00
$freebusy_values = array (
0 => lang ( 'No' ),
1 => lang ( 'Yes' ),
2 => lang ( 'With credentials included' ),
);
2010-03-22 15:20:19 +01:00
if ( ! $hook_data [ 'setup' ]) // does not work at setup time
2008-06-07 20:06:36 +02:00
{
2009-10-18 14:57:30 +02:00
$options = array ( '0' => lang ( 'none' ));
2010-04-15 16:10:01 +02:00
foreach ( $GLOBALS [ 'egw' ] -> accounts -> search ( array ( 'type' => 'owngroups' , 'app' => 'calendar' )) as $group )
2008-06-07 20:06:36 +02:00
{
2016-05-01 19:47:59 +02:00
$options [ $group [ 'account_id' ]] = Api\Accounts :: username ( $group [ 'account_id' ]);
2008-06-07 20:06:36 +02:00
}
2009-10-18 14:57:30 +02:00
$freebusy_url = calendar_bo :: freebusy_url ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_lid' ], $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'calendar' ][ 'freebusy_pw' ]);
2010-06-26 13:35:11 +02:00
$freebusy_url = '<a href="' . $freebusy_url . '" target="_blank">' . $freebusy_url . '</a>' ;
$freebusy_help = lang ( 'Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is' );
$freebusy_help .= ' ' . $freebusy_url ;
2008-06-07 20:06:36 +02:00
2010-03-22 15:20:19 +01:00
// Timezone for file exports
2021-11-12 21:08:48 +01:00
$export_tzs = array ([ 'value' => '0' , 'label' => lang ( 'Use Event TZ' )]);
2016-05-01 19:47:59 +02:00
$export_tzs += Api\DateTime :: getTimezones ();
2010-03-22 15:20:19 +01:00
}
2016-05-02 22:21:59 +02:00
$link_title_options = calendar_bo :: get_link_options ();
2011-02-09 16:58:06 +01:00
$settings = array (
2014-05-28 12:03:57 +02:00
'1.section' => array (
2013-01-18 00:55:26 +01:00
'type' => 'section' ,
2013-01-22 17:15:12 +01:00
'title' => lang ( 'General settings' ),
2013-01-18 00:55:26 +01:00
'no_lang' => true ,
'xmlrpc' => False ,
'admin' => False
),
2014-08-27 11:06:20 +02:00
/* disabled until we have a home app again
2013-01-18 00:55:26 +01:00
'mainscreen_showevents' => array (
'type' => 'select' ,
'label' => 'Which view to show on home page' ,
'name' => 'mainscreen_showevents' ,
'values' => $mainscreen ,
'help' => 'Displays this calendar view on the home page (page you get when you enter EGroupware or click on the home page icon)?' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => '1' , // 1 = week
2014-08-27 11:06:20 +02:00
), */
2008-06-07 20:06:36 +02:00
'multiple_weeks' => array (
'type' => 'select' ,
'label' => 'Weeks in multiple week view' ,
'name' => 'multiple_weeks' ,
'values' => $muliple_weeks ,
'help' => 'How many weeks should the multiple week view show?' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2015-12-15 21:06:03 +01:00
'default' => 2 ,
2008-06-07 20:06:36 +02:00
),
'weekdaystarts' => array (
'type' => 'select' ,
'label' => 'weekday starts on' ,
'name' => 'weekdaystarts' ,
2009-10-22 18:55:09 +02:00
'values' => $weekdaystarts ,
2008-06-07 20:06:36 +02:00
'help' => 'This day is shown as first day in the week or month view.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'forced' => 'Monday' ,
2008-06-07 20:06:36 +02:00
),
'workdaystarts' => array (
'type' => 'select' ,
'label' => 'work day starts on' ,
'name' => 'workdaystarts' ,
'values' => $times ,
'help' => 'This defines the start of your dayview. Events before this time, are shown above the dayview.<br>This time is also used as a default starttime for new events.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => 9 ,
2008-06-07 20:06:36 +02:00
),
'workdayends' => array (
'type' => 'select' ,
'label' => 'work day ends on' ,
'name' => 'workdayends' ,
'values' => $times ,
'help' => 'This defines the end of your dayview. Events after this time, are shown below the dayview.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'default' => 18 ,
2008-06-07 20:06:36 +02:00
),
'interval' => array (
'type' => 'select' ,
'label' => 'Length of the time interval' ,
'name' => 'interval' ,
'values' => $intervals ,
'help' => 'How many minutes should each interval last?' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'default' => 30 ,
2008-06-07 20:06:36 +02:00
),
2015-12-23 00:34:53 +01:00
'day_consolidate' => array (
'type' => 'select' ,
'label' => 'Minimum number of users for showing day view as consolidated.' ,
'name' => 'day_consolidate' ,
'values' => $consolidated ,
2018-03-26 16:02:42 +02:00
'help' => 'How many separate calendars to show before merging them together' ,
2015-12-29 17:28:29 +01:00
'default' => 6
2015-12-23 00:34:53 +01:00
),
'week_consolidate' => array (
'type' => 'select' ,
'label' => 'Minimum number of users for showing week view as consolidated.' ,
'name' => 'week_consolidate' ,
'values' => $consolidated ,
2018-03-26 16:02:42 +02:00
'help' => 'How many separate calendars to show before merging them together' ,
2015-12-29 17:28:29 +01:00
'default' => 4
2015-12-23 00:34:53 +01:00
),
2016-01-13 00:55:59 +01:00
'use_time_grid' => array (
'type' => 'multiselect' ,
'label' => 'Views showing a list of events' ,
2013-01-18 00:55:26 +01:00
'name' => 'use_time_grid' ,
2016-01-13 00:55:59 +01:00
'values' => $list_views ,
'help' => 'For which views should calendar just a list of events instead of distinct lines with a fixed time interval.' ,
2010-04-27 21:12:42 +02:00
'xmlrpc' => True ,
2013-01-18 00:55:26 +01:00
'admin' => False ,
2017-08-28 18:01:27 +02:00
'default' => [ 'weekN' , 'month' ],
2016-01-13 00:55:59 +01:00
),
2018-06-05 20:57:01 +02:00
'auto_update_on_sidebox_change' => array (
'type' => 'check' ,
'label' => 'Update calendar view immediately when navigation calendar in sidebox is changed' ,
'name' => 'auto_update_on_sidebox_change' ,
'help' => 'When changing the month' ,
'default' => false
),
2014-05-28 12:03:57 +02:00
'2.section' => array (
2013-01-18 00:55:26 +01:00
'type' => 'section' ,
'title' => lang ( 'appointment settings' ),
'no_lang' => true ,
'xmlrpc' => False ,
2010-04-27 21:12:42 +02:00
'admin' => False
),
2013-01-18 00:55:26 +01:00
'defaultlength' => array (
'type' => 'input' ,
'label' => 'default appointment length (in minutes)' ,
'name' => 'defaultlength' ,
'help' => 'Default length of newly created events. The length is in minutes, eg. 60 for 1 hour.' ,
'default' => '' ,
'size' => 3 ,
'xmlrpc' => True ,
'admin' => False ,
'default' => 60 ,
),
2015-12-29 01:11:29 +01:00
'default_participant' => array (
'type' => 'select' ,
'label' => 'New event participants' ,
'name' => 'default_participant' ,
'values' => $default_participants ,
'help' => 'Participants automatically added to new events' ,
2016-01-05 23:54:33 +01:00
'default' => 'selected' ,
2015-12-29 01:11:29 +01:00
'xmlrpc' => False ,
'admin' => False
),
2018-12-13 22:35:26 +01:00
'default_category' => array (
'type' => 'multiselect' ,
'label' => 'New event category' ,
'name' => 'default_category' ,
'help' => 'Category automatically added to new events' ,
2018-12-14 11:15:28 +01:00
'values' => $default_cat_seloptions ,
2018-12-13 22:35:26 +01:00
'default' => '' ,
'xmlrpc' => False ,
'admin' => False
),
2014-05-28 12:03:57 +02:00
'default-alarm' => array (
2014-06-06 13:59:20 +02:00
'type' => 'date-duration' , //'select',
'label' => lang ( 'Default alarm for regular events' ) . ' (' . lang ( 'empty = no alarm' ) . ')' ,
2014-05-28 12:03:57 +02:00
'name' => 'default-alarm' ,
'help' => 'Alarm added automatic to new events before event start-time' ,
'xmlrpc' => True ,
'admin' => False ,
2014-06-06 13:59:20 +02:00
'default' => '' ,
2014-05-28 12:03:57 +02:00
),
'default-alarm-wholeday' => array (
2014-06-06 13:59:20 +02:00
'type' => 'date-duration' , //'select',
'label' => lang ( 'Default alarm for whole-day events' ) . ' (' . lang ( 'empty = no alarm' ) . ')' ,
2014-05-28 12:03:57 +02:00
'name' => 'default-alarm-wholeday' ,
2014-05-30 15:38:59 +02:00
'help' => lang ( 'Alarm added automatic to new events before event start-time' ) . ' (' . lang ( 'Midnight' ) . ')' ,
'xmlrpc' => True ,
'admin' => False ,
2014-06-06 13:59:20 +02:00
'default' => '' ,
2014-05-30 15:38:59 +02:00
),
2014-05-28 12:03:57 +02:00
);
if ( isset ( $bo )) // add custom time-spans set by CalDAV clients, not in our prefs
{
$prefs = $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'calendar' ];
$data = array (
'prefs' => & $prefs , // use reference to get preference value back
'preprocess' => true ,
'type' => 'user' ,
);
2014-06-06 13:59:20 +02:00
self :: verify_settings_reference ( $data );
2014-05-28 12:03:57 +02:00
}
$settings += array (
2013-01-18 00:55:26 +01:00
'defaultresource_sel' => array (
'type' => 'select' ,
'label' => 'default type of resources selection' ,
'name' => 'defaultresource_sel' ,
'values' => $defaultresource_sel ,
2018-03-26 16:02:42 +02:00
'help' => 'Default type of resources application selected in the calendar participants research form.' ,
2013-01-18 00:55:26 +01:00
'xmlrpc' => True ,
'admin' => False ,
2016-04-29 20:01:17 +02:00
'default' => 'resources'
2013-01-18 00:55:26 +01:00
),
2008-06-07 20:06:36 +02:00
'default_private' => array (
'type' => 'check' ,
'label' => 'Set new events to private' ,
'name' => 'default_private' ,
'help' => 'Should new events created as private by default ?' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'forced' => '0' ,
2008-06-07 20:06:36 +02:00
),
2013-01-18 00:55:26 +01:00
'reset_stati' => array (
'type' => 'select' ,
'label' => 'Reset participant stati on event shifts' ,
'name' => 'reset_stati' ,
2018-03-26 16:02:42 +02:00
'help' => 'Select whether you want the participant stati reset to unknown, if an event is shifted later on.' ,
2013-01-18 00:55:26 +01:00
'values' => $reset_stati_on_shifts ,
2019-06-24 17:41:29 +02:00
'default' => 'all' ,
2013-01-18 00:55:26 +01:00
'xmlrpc' => True ,
'admin' => False ,
),
2017-11-07 18:25:47 +01:00
'no_category_custom_color' => array (
'type' => 'color' ,
'label' => 'Custom event color' ,
'no_lang' => true ,
'name' => 'no_category_custom_color' ,
'help' => lang ( 'Custom color for events without category color' ),
'xmlrpc' => True ,
'admin' => False ,
),
2018-06-15 17:09:51 +02:00
'2.5.section' => array (
'type' => 'section' ,
'title' => lang ( 'Configuration settings' ),
'no_lang' => true ,
'xmlrpc' => False ,
'admin' => False
),
2019-01-07 17:23:40 +01:00
'new_event_dialog' => array (
'type' => 'select' ,
'label' => 'Add appointments via shortened dialog or complete edit window' ,
'name' => 'new_event_dialog' ,
'values' => array ( 'add' => lang ( 'Quick add' ), 'edit' => lang ( 'Regular edit' )),
'help' => 'Use quick add or full edit dialog when creating a new event' ,
'default' => 'add' ,
),
2018-06-15 17:09:51 +02:00
'limit_des_lines' => array (
'type' => 'input' ,
'size' => 5 ,
'label' => 'Limit number of description lines in list view (default 5, 0 for no limit)' ,
'name' => 'limit_des_lines' ,
'help' => 'How many description lines should be directly visible. Further lines are available via a scrollbar.' ,
'xmlrpc' => True ,
'admin' => False
),
'limit_all_day_lines' => array (
'type' => 'input' ,
'size' => 5 ,
'label' => 'Limit number of lines for all day events' ,
'name' => 'limit_all_day_lines' ,
'help' => 'How many lines of all day events should be directly visible. Further lines are available via a mouseover.' ,
'xmlrpc' => True ,
'default' => 3 ,
'admin' => False
),
'planner_show_empty_rows' => array (
'type' => 'select' ,
'label' => 'Show empty rows in Planner' ,
'name' => 'planner_show_empty_rows' ,
'values' => array (
0 => lang ( 'no' ),
'user' => lang ( 'Planner by user' ),
'cat' => lang ( 'Planner by category' ),
'both' => lang ( 'All' ),
),
'help' => 'Should the planner display an empty row for users or categories without any appointment.' ,
'xmlrpc' => True ,
'admin' => False ,
'forced' => 'user' ,
),
'birthdays_as_events' => array (
'type' => 'multiselect' ,
'values' => $birthdays_as_events ,
'label' => 'Show birthdays as events' ,
'name' => 'birthdays_as_events' ,
'help' => 'Show birthdays as all day non-blocking events as well as via mouseover of the date.' ,
'default' => 'none'
),
'link_title' => array (
'type' => 'multiselect' ,
'label' => 'Link title for events to show' ,
'name' => 'link_title' ,
'values' => $link_title_options ,
'help' => 'What should links to the calendar events display in other applications.' ,
'xmlrpc' => True ,
'admin' => false ,
'default' => '' ,
),
2014-05-28 12:03:57 +02:00
'3.section' => array (
2013-01-18 00:55:26 +01:00
'type' => 'section' ,
'title' => lang ( 'notification settings' ),
'no_lang' => true ,
'xmlrpc' => False ,
'admin' => False
),
2008-06-07 20:06:36 +02:00
'receive_updates' => array (
'type' => 'select' ,
'label' => 'Receive email updates' ,
'name' => 'receive_updates' ,
'values' => $updates ,
'help' => " Do you want to be notified about new or changed appointments? You be notified about changes you make yourself.<br>You can limit the notifications to certain changes only. Each item includes all the notification listed above it. All modifications include changes of title, description, participants, but no participant responses. If the owner of an event requested any notifcations, he will always get the participant responses like acceptions and rejections too. " ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => 'time_change' ,
2008-06-07 20:06:36 +02:00
),
2013-01-18 00:55:26 +01:00
'receive_own_updates' => array (
2008-06-07 20:06:36 +02:00
'type' => 'select' ,
2013-01-18 00:55:26 +01:00
'label' => 'Receive notifications about events you created/modified/deleted' ,
'name' => 'receive_own_updates' ,
'values' => $yesno ,
'help' => " Do you want to be notified about changes of appointments you modified? " ,
2008-06-07 20:06:36 +02:00
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2013-01-18 00:55:26 +01:00
'default' => 'false' ,
2008-06-07 20:06:36 +02:00
),
2019-10-28 22:29:36 +01:00
'receive_not_participating' => array (
'type' => 'select' ,
2019-11-20 18:12:45 +01:00
'label' => 'Do you want responses from events you created, but are not participating in?' ,
2019-10-28 22:29:36 +01:00
'name' => 'receive_not_participating' ,
'values' => $yesno ,
2019-11-04 18:51:39 +01:00
'help' => 'Do you want to be notified about participant responses from events you created, but are not participating in?' ,
2019-10-28 22:29:36 +01:00
'default' => '1'
),
2012-01-05 06:47:02 +01:00
'notify_externals' => array (
'type' => 'select' ,
'label' => 'Notify non-EGroupware users about event updates' ,
'name' => 'notify_externals' ,
'values' => $updates ,
'help' => 'Do you want non-EGroupware participants of events you created to be automatically notified about new or changed appointments?' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => 'no' ,
),
2013-01-18 00:55:26 +01:00
'update_format' => array (
2010-06-23 16:47:34 +02:00
'type' => 'select' ,
2013-01-18 00:55:26 +01:00
'label' => 'Format of event updates' ,
'name' => 'update_format' ,
'values' => $update_formats ,
'help' => 'Extended updates always include the complete event-details. iCal\'s can be imported by certain other calendar-applications.' ,
2010-06-23 16:47:34 +02:00
'xmlrpc' => True ,
'admin' => False ,
2013-01-18 00:55:26 +01:00
'forced' => 'ical' ,
2010-06-23 16:47:34 +02:00
),
2008-06-07 20:06:36 +02:00
'notifyAdded' => array (
'type' => 'notify' ,
2009-11-30 14:53:21 +01:00
'label' => 'Notification messages for added events' ,
2008-06-07 20:06:36 +02:00
'name' => 'notifyAdded' ,
'rows' => 5 ,
'cols' => 50 ,
'help' => 'This message is sent to every participant of events you own, who has requested notifcations about new events.<br>You can use certain variables which get substituted with the data of the event. The first line is the subject of the email.' ,
'default' => '' ,
'values' => $event_details ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2008-06-07 20:06:36 +02:00
),
'notifyCanceled' => array (
'type' => 'notify' ,
2009-11-30 14:53:21 +01:00
'label' => 'Notification messages for canceled events' ,
2008-06-07 20:06:36 +02:00
'name' => 'notifyCanceled' ,
'rows' => 5 ,
'cols' => 50 ,
'help' => 'This message is sent for canceled or deleted events.' ,
'default' => '' ,
'values' => $event_details ,
'subst_help' => False ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2008-06-07 20:06:36 +02:00
),
'notifyModified' => array (
'type' => 'notify' ,
2009-11-30 14:53:21 +01:00
'label' => 'Notification messages for modified events' ,
2008-06-07 20:06:36 +02:00
'name' => 'notifyModified' ,
'rows' => 5 ,
'cols' => 50 ,
'help' => 'This message is sent for modified or moved events.' ,
'default' => '' ,
'values' => $event_details ,
'subst_help' => False ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2008-06-07 20:06:36 +02:00
),
'notifyDisinvited' => array (
'type' => 'notify' ,
2018-03-26 16:02:42 +02:00
'label' => 'Notification messages for uninvited participants' ,
2008-06-07 20:06:36 +02:00
'name' => 'notifyDisinvited' ,
'rows' => 5 ,
'cols' => 50 ,
2018-03-26 16:02:42 +02:00
'help' => 'This message is sent to uninvited participants.' ,
2008-06-07 20:06:36 +02:00
'values' => $event_details ,
'subst_help' => False ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2008-06-07 20:06:36 +02:00
),
'notifyResponse' => array (
'type' => 'notify' ,
2009-11-30 14:53:21 +01:00
'label' => 'Notification messages for your responses' ,
2008-06-07 20:06:36 +02:00
'name' => 'notifyResponse' ,
'rows' => 5 ,
'cols' => 50 ,
'help' => 'This message is sent when you accept, tentative accept or reject an event.' ,
'values' => $event_details ,
'subst_help' => False ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2008-06-07 20:06:36 +02:00
),
'notifyAlarm' => array (
'type' => 'notify' ,
'label' => 'Notification messages for your alarms' ,
'name' => 'notifyAlarm' ,
'rows' => 5 ,
'cols' => 50 ,
'help' => 'This message is sent when you set an Alarm for a certain event. Include all information you might need.' ,
'values' => $event_details ,
'subst_help' => False ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2008-06-07 20:06:36 +02:00
),
2014-05-28 12:03:57 +02:00
'4.section' => array (
2013-01-18 00:55:26 +01:00
'type' => 'section' ,
'title' => lang ( 'Data exchange settings' ),
'no_lang' => true ,
'xmlrpc' => False ,
'admin' => False
2010-12-22 16:17:56 +01:00
),
2008-06-07 20:06:36 +02:00
);
2011-02-09 16:58:06 +01:00
// Merge print
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'filemanager' ])
{
2021-10-07 18:22:45 +02:00
$merge = new calendar_merge ();
$settings += $merge -> merge_preferences ();
2011-02-09 16:58:06 +01:00
}
2019-08-02 18:17:16 +02:00
2013-01-18 00:55:26 +01:00
$settings += array (
'export_timezone' => array (
'type' => 'select' ,
'label' => 'Timezone of event iCal file import/export' ,
'name' => 'export_timezone' ,
'values' => $export_tzs ,
'help' => 'Use this timezone to import/export calendar data.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => '0' , // Use event's TZ
),
'freebusy' => array (
'type' => 'select' ,
2018-03-26 16:02:42 +02:00
'label' => 'Make freebusy information available to not logged in persons?' ,
2013-01-18 00:55:26 +01:00
'name' => 'freebusy' ,
'help' => $freebusy_help ,
'values' => $freebusy_values ,
'run_lang' => false ,
'subst_help' => False ,
'xmlrpc' => True ,
'admin' => False ,
'forced' => 0 ,
),
'freebusy_pw' => array (
'type' => 'input' ,
'label' => 'Password for not loged in users to your freebusy information?' ,
'name' => 'freebusy_pw' ,
'help' => 'If you dont set a password here, the information is available to everyone, who knows the URL!!!' ,
'xmlrpc' => True ,
'admin' => False ,
'forced' => ''
),
);
2011-02-09 16:58:06 +01:00
return $settings ;
2008-06-07 20:06:36 +02:00
}
2010-04-22 22:27:14 +02:00
2014-05-28 12:03:57 +02:00
/**
* Verify settings hook called to generate errors about settings used here to store default alarms in CalDAV prefs
*
* @ param array $data
* array $data [ 'prefs' ]
* string $data [ 'type' ] 'user' , 'default' or 'forced'
* boolean $data [ 'preprocess' ] true data just shown to user , false : data stored by user
*/
public static function verify_settings ( array $data )
2014-06-06 13:59:20 +02:00
{
self :: verify_settings_reference ( $data );
}
/**
* Verify settings hook called to generate errors about settings used here to store default alarms in CalDAV prefs
*
* @ param array & $data
* array $data [ 'prefs' ]
* string $data [ 'type' ] 'user' , 'default' or 'forced'
* boolean $data [ 'preprocess' ] true data just shown to user , false : data stored by user
*/
public static function verify_settings_reference ( array & $data )
2014-05-28 12:03:57 +02:00
{
//error_log(__METHOD__."(".array2string($data).")");
// caldav perfs are always user specific and cant by switched off
2014-06-06 13:59:20 +02:00
if ( $data [ 'type' ] != 'user' ) return ;
$account_lid = $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_lid' ];
foreach ( array (
'default-alarm' => 'default-alarm-vevent-datetime:/' . $account_lid . '/:urn:ietf:params:xml:ns:caldav' ,
'default-alarm-wholeday' => 'default-alarm-vevent-date:/' . $account_lid . '/:urn:ietf:params:xml:ns:caldav' ,
) as $name => $dav )
2014-05-28 12:03:57 +02:00
{
2014-06-06 13:59:20 +02:00
$pref =& $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'groupdav' ][ $dav ];
if ( true ) $pref = str_replace ( " \r " , '' , $pref ); // remove CR messing up multiline preg_match
$val =& $data [ 'prefs' ][ $name ];
//error_log(__METHOD__."() groupdav[$dav]=$pref, calendar[$name]=$val");
2014-05-28 12:03:57 +02:00
2014-06-06 13:59:20 +02:00
if ( $data [ 'preprocess' ]) // showing preferences
{
if ( ! isset ( $val )) // no calendar pref --> read value from caldav
2014-05-28 12:03:57 +02:00
{
2014-06-06 13:59:20 +02:00
$matches = null ;
2014-06-11 11:15:43 +02:00
if ( preg_match ( '/^ACTION:NONE$/mi' , $pref ))
2014-05-28 12:03:57 +02:00
{
2014-06-06 13:59:20 +02:00
$val = '' ;
2014-05-28 12:03:57 +02:00
}
2014-06-06 13:59:20 +02:00
elseif ( preg_match ( '/^TRIGGER:-PT(\d+(M|H|D))$/mi' , $pref , $matches ))
{
static $factors = array (
'M' => 1 ,
'H' => 60 ,
'D' => 1440 ,
);
$factor = $factors [ strtoupper ( $matches [ 2 ])];
$val = $factor * ( int ) $matches [ 1 ];
}
else
{
$val = '' ;
}
$GLOBALS [ 'egw' ] -> preferences -> add ( 'calendar' , $name , $val , 'user' );
//error_log(__METHOD__."() setting $name={$val} from $dav='$pref'");
2014-05-28 12:03:57 +02:00
}
2014-06-06 13:59:20 +02:00
}
else // storing preferences
{
if ( empty ( $pref ) || ! preg_match ( '/^TRIGGER:/m' , $pref ))
2014-05-28 12:03:57 +02:00
{
2014-06-06 13:59:20 +02:00
$pref = ' BEGIN : VALARM
2014-05-28 12:03:57 +02:00
TRIGGER :- PT1H
ATTACH ; VALUE = URI : Basso
ACTION : AUDIO
END : VALARM ' ;
}
2014-06-06 13:59:20 +02:00
$trigger = $val < 0 ? 'TRIGGER:PT' : 'TRIGGER:-PT' ;
if (( string ) $val === '' )
{
$pref = preg_replace ( '/^ACTION:.*$/m' , 'ACTION:NONE' , $pref );
}
elseif ( abs ( $val ) < 60 )
{
$pref = preg_replace ( '/^TRIGGER:.*$/m' , $trigger . number_format ( abs ( $val ), 0 ) . 'M' , $pref );
}
else
{
$pref = preg_replace ( '/^TRIGGER:.*$/m' , $trigger . number_format ( abs ( $val ) / 60 , 0 ) . 'H' , $pref );
}
$GLOBALS [ 'egw' ] -> preferences -> add ( 'groupdav' , $dav , $pref , 'user' );
2014-06-11 11:15:43 +02:00
//error_log(__METHOD__."() storing $name=$val --> $dav='$pref'");
2014-05-28 12:03:57 +02:00
}
}
}
2014-05-28 12:57:02 +02:00
/**
* Sync default alarms from CalDAV to Calendar
*
2016-05-01 19:47:59 +02:00
* Gets called by Api\CalDAV :: PROPPATCH () for 'default-alarm-vevent-date(time)' changes
2014-05-28 12:57:02 +02:00
*/
public static function sync_default_alarms ()
{
self :: verify_settings ( array (
'prefs' => array (),
'preprocess' => true ,
'type' => 'user' ,
));
}
2013-08-26 20:25:43 +02:00
public static function config_validate ()
{
2014-04-23 16:36:08 +02:00
$GLOBALS [ 'egw_info' ][ 'server' ][ 'found_validation_hook' ] = array ( 'calendar_purge_old' );
2010-04-22 22:27:14 +02:00
}
2013-08-26 20:25:43 +02:00
/**
* ACL rights and labels used
*
2016-05-01 19:47:59 +02:00
* @ param string | array string with location or array with parameters incl . " location " , specially " owner " for selected Acl owner
* @ return array Acl :: ( READ | ADD | EDIT | DELETE | PRIVAT | CUSTOM ( 1 | 2 | 3 )) => $label pairs
2013-08-26 20:25:43 +02:00
*/
public static function acl_rights ( $params )
{
$rights = array (
2016-05-01 19:47:59 +02:00
Acl :: CUSTOM2 => 'freebusy' ,
Acl :: CUSTOM3 => 'invite' ,
Acl :: READ => 'read' ,
Acl :: ADD => 'add' ,
Acl :: EDIT => 'edit' ,
Acl :: DELETE => 'delete' ,
Acl :: PRIVAT => 'private' ,
2013-08-26 20:25:43 +02:00
);
$require_acl_invite = $GLOBALS [ 'egw_info' ][ 'server' ][ 'require_acl_invite' ];
if ( ! $require_acl_invite || $require_acl_invite == 'groups' && ! ( $params [ 'owner' ] < 0 ))
{
2016-05-01 19:47:59 +02:00
unset ( $rights [ Acl :: CUSTOM3 ]);
2013-08-26 20:25:43 +02:00
}
return $rights ;
}
2013-10-03 11:23:18 +02:00
/**
* Hook to tell framework we use standard categories method
*
* @ param string | array $data hook - data or location
* @ return boolean
*/
public static function categories ( $data )
{
2014-01-30 12:03:16 +01:00
unset ( $data ); // not used, but in function signature for hooks
2013-10-03 11:23:18 +02:00
return true ;
}
2016-04-07 14:42:27 +02:00
2015-04-15 13:23:59 +02:00
/**
* Mail integration hook to import mail message contents into a calendar entry
*
* @ return string method to be executed for calendar mail integration
*/
public static function mail_import ( $args )
{
2016-05-01 19:47:59 +02:00
unset ( $args ); // not used, but required by function signature
2015-04-15 17:55:18 +02:00
return array (
'menuaction' => 'calendar.calendar_uiforms.mail_import' ,
2016-05-01 19:47:59 +02:00
'popup' => Link :: get_registry ( 'calendar' , 'edit_popup' )
2015-04-15 17:55:18 +02:00
);
2015-04-15 13:23:59 +02:00
}
2018-01-24 19:02:35 +01:00
/**
* Method to construct notifications actions
*
* @ param type $params
* @ return type
*/
public static function notifications_actions ( $params )
{
Api\Translation :: add_app ( 'calendar' );
2018-06-27 16:25:10 +02:00
// do not set actions for alarm type
2021-10-05 14:11:11 +02:00
if ( isset ( $params [ 'data' ][ 'type' ]) && $params [ 'data' ][ 'type' ] == 6 )
2020-04-07 17:16:56 +02:00
{
2020-11-19 12:38:03 +01:00
if ( ! empty ( $params [ 'data' ][ 'videoconference' ])
2021-05-17 12:42:24 +02:00
&& ! self :: isVideoconferenceDisabled ())
2020-04-07 17:16:56 +02:00
{
return [
array (
'id' => 'J' ,
'caption' => lang ( 'Join' ),
'icon' => 'accept_call' ,
'onExecute' => 'app.status.openCall("' . $params [ 'data' ][ 'videoconference' ] . '");'
)
];
}
return array ();
}
2021-10-05 14:11:11 +02:00
if ( ! isset ( $params [ 'data' ][ 'event_id' ])) $params [ 'data' ][ 'event_id' ] = '' ;
if ( ! isset ( $params [ 'data' ][ 'user_id' ])) $params [ 'data' ][ 'user_id' ] = '' ;
2018-01-24 19:02:35 +01:00
return array (
array (
'id' => 'A' ,
'caption' => lang ( 'Accept' ),
'icon' => 'accepted' ,
2019-08-14 16:30:59 +02:00
'onExecute' => 'egw().json("calendar.calendar_uiforms.ajax_status",[' . $params [ 'data' ][ 'event_id' ] . ',' . $params [ 'data' ][ 'user_id' ] . ',' . '"A"' . ']).sendRequest(true);this.button_delete(arguments[0], arguments[1]);'
2018-01-24 19:02:35 +01:00
),
array (
'id' => 'R' ,
'caption' => lang ( 'Reject' ),
'icon' => 'rejected' ,
2019-08-14 16:30:59 +02:00
'onExecute' => 'egw().json("calendar.calendar_uiforms.ajax_status",[' . $params [ 'data' ][ 'event_id' ] . ',' . $params [ 'data' ][ 'user_id' ] . ',' . '"R"' . ']).sendRequest(true);this.button_delete(arguments[0], arguments[1]);'
2018-01-24 19:02:35 +01:00
),
array (
'id' => 'T' ,
'caption' => lang ( 'Tentative' ),
'icon' => 'tentative' ,
2019-08-14 16:30:59 +02:00
'onExecute' => 'egw().json("calendar.calendar_uiforms.ajax_status",[' . $params [ 'data' ][ 'event_id' ] . ',' . $params [ 'data' ][ 'user_id' ] . ',' . '"T"' . ']).sendRequest(true);this.button_delete(arguments[0], arguments[1]);'
2018-01-24 19:02:35 +01:00
)
);
}
2021-05-17 12:42:24 +02:00
/**
* Wrapper function to check Status app videoconference status
* it makes sure first the Status app is there before calling its method .
*
* @ return false | mixed
*/
public static function isVideoconferenceDisabled ()
{
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'status' ] && class_exists ( \EGroupware\Status\Hooks :: class )
&& method_exists ( \EGroupware\Status\Hooks :: class , 'isVideoconferenceDisabled' ))
{
return EGroupware\Status\Hooks :: isVideoconferenceDisabled ();
}
return true ;
}
/**
* Wrapper function to check Status app videoConference recording status
* it makes sure first the Status app is there before calling its method .
*
* @ return bool
*/
public static function isVCRecordingSupported ()
{
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'status' ] && class_exists ( \EGroupware\Status\Hooks :: class )
&& method_exists ( \EGroupware\Status\Hooks :: class , 'isVCRecordingSupported' ))
{
return EGroupware\Status\Hooks :: isVCRecordingSupported ();
}
return false ;
}
2010-04-22 22:27:14 +02:00
}
// Not part of the class, since config hooks are still using the old style
2011-06-14 20:16:08 +02:00
function calendar_purge_old ( $config )
{
2010-04-22 22:27:14 +02:00
$id = 'calendar_purge' ;
// Cancel old purge
2016-05-01 19:47:59 +02:00
$async = new Api\Asyncservice ();
$async -> cancel_timer ( $id );
2010-04-22 22:27:14 +02:00
2011-06-15 15:50:17 +02:00
if (( float ) $config > 0 )
2011-06-14 20:16:08 +02:00
{
2016-05-01 19:47:59 +02:00
$result = $async -> set_timer (
2010-07-01 17:27:37 +02:00
array ( 'month' => '*' , 'day' => 1 ),
$id ,
'calendar.calendar_boupdate.purge' ,
2011-06-14 20:16:08 +02:00
( float ) $config
2010-07-01 17:27:37 +02:00
);
2013-06-05 09:22:27 +02:00
if ( ! $result )
{
$GLOBALS [ 'config_error' ] = 'Unable to schedule purge' ;
}
2010-04-22 22:27:14 +02:00
}
2016-05-01 11:57:48 +02:00
}