sync CalDAV default-alarm trigger/time to calendar preference

This commit is contained in:
Ralf Becker 2014-05-28 10:57:02 +00:00
parent f0e391220f
commit 960b50b83a
2 changed files with 35 additions and 6 deletions

View File

@ -786,7 +786,8 @@ class calendar_hooks
{
$data['prefs'][$name] = '0';
}
error_log(__METHOD__."() setting $name={$data['prefs'][$name]} from $dav='$pref'");
$GLOBALS['egw']->preferences->add('calendar', $name, $data['prefs'][$name], 'user');
//error_log(__METHOD__."() setting $name={$data['prefs'][$name]} from $dav='$pref'");
}
}
else // storing preferences
@ -812,13 +813,27 @@ END:VALARM';
$pref = preg_replace('/^TRIGGER:.*$/m', 'TRIGGER:-PT'.number_format($val/3600, 0).'H', $pref);
}
$GLOBALS['egw']->preferences->add('groupdav', $dav, $pref, 'user');
error_log(__METHOD__."() storing $name=$val --> $dav='$pref'");
//error_log(__METHOD__."() storing $name=$val --> $dav='$pref'");
}
}
$GLOBALS['egw']->preferences->save_repository();
}
}
/**
* Sync default alarms from CalDAV to Calendar
*
* Gets called by groupdav::PROPPATCH() for 'default-alarm-vevent-date(time)' changes
*/
public static function sync_default_alarms()
{
self::verify_settings(array(
'prefs' => array(),
'preprocess' => true,
'type' => 'user',
));
}
public static function config_validate()
{
$GLOBALS['egw_info']['server']['found_validation_hook'] = array('calendar_purge_old');

View File

@ -1549,17 +1549,18 @@ class groupdav extends HTTP_WebDAV_Server
*/
function PROPPATCH(&$options)
{
if ($this->debug) error_log(__CLASS__."::$method(".array2string($options).')');
if ($this->debug) error_log(__METHOD__."(".array2string($options).')');
// parse path in form [/account_lid]/app[/more]
self::_parse_path($options['path'],$id,$app,$user,$user_prefix); // allways returns false if eg. !$id
if ($app == 'principals' || $id || $options['path'] == '/')
{
if ($this->debug > 1) error_log(__CLASS__."::$method: user='$user', app='$app', id='$id': 404 not found!");
if ($this->debug > 1) error_log(__METHOD__.": user='$user', app='$app', id='$id': 404 not found!");
foreach($options['props'] as &$prop) $prop['status'] = '403 Forbidden';
return 'NOT allowed to PROPPATCH that resource!';
}
// store selected props in preferences, eg. calendar-color, see self::$proppatch_props
$need_save = array();
foreach($options['props'] as &$prop)
{
if ((isset(self::$proppatch_props[$prop['name']]) && self::$proppatch_props[$prop['name']] === $prop['xmlns'] ||
@ -1586,7 +1587,7 @@ class groupdav extends HTTP_WebDAV_Server
{
$GLOBALS['egw']->preferences->delete($app, $name);
}
$need_save = true;
$need_save[] = $name;
}
$prop['status'] = '200 OK';
}
@ -1595,7 +1596,20 @@ class groupdav extends HTTP_WebDAV_Server
$prop['status'] = '409 Conflict'; // could also be "403 Forbidden"
}
}
if ($need_save) $GLOBALS['egw']->preferences->save_repository();
if ($need_save)
{
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->save_repository();
// call calendar-hook, if default-alarms are changed, to sync them to calendar prefs
foreach($need_save as $name)
{
list($name) = explode(':', $name);
if (in_array($name, array('default-alarm-vevent-date', 'default-alarm-vevent-datetime')))
{
calendar_hooks::sync_default_alarms();
break;
}
}
}
}
/**