added calendar-timezone property, changed groupdav_handler::extra_properties signature (removed static and added $user parameter), removed calendar-user-address-set property belonging only to principal

This commit is contained in:
Ralf Becker 2011-10-20 13:35:01 +00:00
parent 0a5e2426d1
commit ceaec3d3c1
6 changed files with 63 additions and 29 deletions

View File

@ -574,13 +574,13 @@ class addressbook_groupdav extends groupdav_handler
* @param array $props=array() regular props by the groupdav handler
* @param string $displayname
* @param string $base_uri=null base url of handler
* @param int $user=null account_id of owner of collection
* @return array
*/
static function extra_properties(array $props=array(), $displayname, $base_uri=null)
public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
{
// addressbook description
$displayname = translation::convert(lang('Addressbook of') . ' ' .
$displayname,translation::charset(),'utf-8');
$displayname = translation::convert(lang('Addressbook of'),translation::charset(),'utf-8').' '.$displayname;
$props['addressbook-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-description',$displayname);
// supported reports (required property for CardDAV)
$props['supported-report-set'] = HTTP_WebDAV_Server::mkprop('supported-report-set',array(

View File

@ -1018,21 +1018,16 @@ class calendar_groupdav extends groupdav_handler
* @param array $props=array() regular props by the groupdav handler
* @param string $displayname
* @param string $base_uri=null base url of handler
* @param int $user=null account_id of owner of current collection
* @return array
*/
static function extra_properties(array $props=array(), $displayname, $base_uri=null)
public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
{
// calendar description
$props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname);
// email of the current user, see caldav-sheduling draft
$props['calendar-user-address-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
HTTP_WebDAV_Server::mkprop('href','MAILTO:'.$GLOBALS['egw_info']['user']['email']),
HTTP_WebDAV_Server::mkprop('href',$base_uri.'/principals/users/'.$GLOBALS['egw_info']['user']['account_lid'].'/'),
HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.$GLOBALS['egw_info']['user']['account_lid'])));
// supported components, currently only VEVENT
$props['supported-calendar-component-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-component-set',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VCALENDAR')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VTIMEZONE')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VEVENT')),
));
$props['supported-report-set'] = HTTP_WebDAV_Server::mkprop('supported-report-set',array(
@ -1048,6 +1043,12 @@ class calendar_groupdav extends groupdav_handler
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
// get timezone of calendar
if ($this->groupdav->prop_requested('calendar-timezone'))
{
$props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-timezone',
calendar_timezones::user_timezone($user, 'component'));
}
return $props;
}

View File

@ -368,6 +368,34 @@ class calendar_timezones
return true;
}
/**
* Query timezone of a given user, returns 'tzid' or VTIMEZONE 'component'
*
* @param int $user=null
* @param string $type='component' everything tz2id supports
* @return string
*/
public static function user_timezone($user=null, $type='component')
{
if (!$user || $user == $GLOBALS['egw_info']['user']['account_id'])
{
$tzid = $GLOBALS['egw_info']['user']['preferences']['common']['tz'];
}
else
{
$prefs_obj = new preferences($user);
$prefs = $prefs_obj->read();
$tzid = $prefs['common']['tz'];
}
if (!$tzid) $tzid = egw_time::$server_timezone->getName();
if ($type != 'tzid')
{
return self::tz2id($tzid,$type);
}
return $tzid;
}
}
/*
if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests

View File

@ -584,30 +584,33 @@ class infolog_groupdav extends groupdav_handler
* @param array $props=array() regular props by the groupdav handler
* @param string $displayname
* @param string $base_uri=null base url of handler
* @param int $user=null account_id of owner of collection
* @return array
*/
static function extra_properties(array $props=array(), $displayname, $base_uri=null)
public function extra_properties(array $props=array(), $displayname, $base_uri=null,$user=null)
{
// calendar description
$displayname = translation::convert(lang('Tasks of') . ' ' .
$displayname,translation::charset(),'utf-8');
$displayname = translation::convert(lang('Tasks of'),translation::charset(),'utf-8').' '.$displayname;
$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname);
// email of the current user, see caldav-sheduling draft
$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
HTTP_WebDAV_Server::mkprop('href','MAILTO:'.$GLOBALS['egw_info']['user']['email'])));
// supported components, currently only VEVENT
$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-component-set',array(
// HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VEVENT')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VCALENDAR')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VTIMEZONE')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VTODO')),
));
// supported reports
$props[] = HTTP_WebDAV_Server::mkprop('supported-report-set',array(
HTTP_WebDAV_Server::mkprop('report',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-query',''))),
HTTP_WebDAV_Server::mkprop('supported-report',array(
HTTP_WebDAV_Server::mkprop('report',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget','')))))));
// get timezone of calendar
if ($this->groupdav->prop_requested('calendar-timezone'))
{
$props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-timezone',
calendar_timezones::user_timezone($user, 'component'));
}
return $props;
}

View File

@ -699,16 +699,17 @@ class groupdav extends HTTP_WebDAV_Server
break;
}
}
if (method_exists($app.'_groupdav','extra_properties'))
{
$displayname = translation::convert(
$account['account_id'] > 0 ? $account['account_fullname'] : lang('Group').' '.$account['account_lid'],
translation::charset(),'utf-8');
$props = ExecMethod2($app.'_groupdav::extra_properties',$props,$displayname,$this->base_uri);
}
// add ctag if handler implements it
// add other handler specific properties
if (($handler = self::app_handler($app)))
{
if (method_exists($handler,'extra_properties'))
{
$displayname = translation::convert(
$account['account_id'] > 0 ? $account['account_fullname'] : lang('Group').' '.$account['account_lid'],
translation::charset(),'utf-8');
$props = $handler->extra_properties($props,$displayname,$this->base_uri,$user);
}
// add ctag if handler implements it
if (method_exists($handler,'getctag') && $this->prop_requested('getctag') === true)
{
$props['getctag'] = self::mkprop(
@ -907,7 +908,7 @@ class groupdav extends HTTP_WebDAV_Server
}
else
{
$value = $value[0] == '<' ? '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value);
$value = $value[0] == '<' || strpos($value, "\n") !== false ? '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value);
}
return $value;
}

View File

@ -193,9 +193,10 @@ abstract class groupdav_handler
* @param array $props=array() regular props by the groupdav handler
* @param string $displayname
* @param string $base_uri=null base url of handler
* @param int $user=null account_id of owner of collection
* @return array
*/
static function extra_properties(array $props=array(), $displayname, $base_uri=null)
public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
{
return $props;
}