diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index a090b746af..70dc278606 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -89,6 +89,8 @@ class groupdav extends HTTP_WebDAV_Server /** * Debug level: 0 = nothing, 1 = function calls, 2 = more info, 3 = complete $_SERVER array * + * Can now be enabled on a per user basis in GroupDAV prefs, if it is set here to 0! + * * The debug messages are send to the apache error_log * * @var integer @@ -123,6 +125,8 @@ class groupdav extends HTTP_WebDAV_Server function __construct() { + if (!$this->debug) $this->debug = (int)$GLOBALS['egw_info']['user']['preferences']['groupdav']['debug_level']; + if ($this->debug > 2) error_log('groupdav: $_SERVER='.array2string($_SERVER)); // identify clients, which do NOT support path AND full url in of PROPFIND request @@ -164,7 +168,7 @@ class groupdav extends HTTP_WebDAV_Server '//' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '/'; } $this->principalURL .= 'principals/users/'.$GLOBALS['egw_info']['user']['account_lid'].'/'; - + // if client requires pathes instead of URLs if ($this->client_require_href_as_url === false) { @@ -277,7 +281,7 @@ class groupdav extends HTTP_WebDAV_Server { $displayname = 'EGroupware (Cal|Card|Group)DAV server'; } - + $displayname = translation::convert($displayname, translation::charset(),'utf-8'); // self url $props = array( @@ -354,18 +358,15 @@ class groupdav extends HTTP_WebDAV_Server $files['files'][0] = array( 'path' => $path.$app.'/', // KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes - 'props' => $this->_properties($app,$app=='addressbook'&&strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') !== false,$user,$path), + 'props' => $this->_properties($app,$app=='addressbook'&&$handler->get_agent()=='kde',$user,$path), ); - } - if ($method != 'REPORT' && isset($options['depth']) && !$options['depth'] && !$id) - { // add ctag if handler implements it (only for depth 0) if (method_exists($handler,'getctag')) { $files['files'][0]['props'][] = HTTP_WebDAV_Server::mkprop( groupdav::CALENDARSERVER,'getctag',$handler->getctag($options['path'],$user)); } - return true; // depth 0 --> show only the self url + if (!$options['depth']) return true; // depth 0 --> show only the self url } return $handler->propfind($this->_slashify($options['path']),$options,$files,$user,$id); } @@ -383,7 +384,7 @@ class groupdav extends HTTP_WebDAV_Server */ function _properties($app,$no_extra_types=false,$user=null,$path='/') { - if ($this->debug) error_log(__CLASS__."::$method: user='$user', app='$app'"); + if ($this->debug) ;error_log(__CLASS__."::$method(app='$app', no_extra_types=$no_extra_types, user='$user', path='$path')"); if ($user) { $account_lid = $this->accounts->id2name($user); @@ -395,7 +396,7 @@ class groupdav extends HTTP_WebDAV_Server $account = $this->accounts->read($account_lid); $displayname = $GLOBALS['egw']->translation->convert($account['account_fullname'], $GLOBALS['egw']->translation->charset(),'utf-8'); - + if ($user < 0) { $principalType = 'groups'; @@ -404,7 +405,7 @@ class groupdav extends HTTP_WebDAV_Server { $principalType = 'users'; } - + $props = array( self::mkprop('current-user-principal',array(self::mkprop('href',$this->principalURL))), self::mkprop('owner',array(self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/'))), @@ -421,7 +422,7 @@ class groupdav extends HTTP_WebDAV_Server self::mkprop('href','urn:uuid:'.$GLOBALS['egw_info']['user']['account_lid']))), self::mkprop(groupdav::CALENDARSERVER,'email-address-set',array( self::mkprop(groupdav::CALENDARSERVER,'email-address',$GLOBALS['egw_info']['user']['email']))), - self::mkprop('getetag','EGw-no-etag-wGE'), // iPhone addressbook requires an etag here! + self::mkprop('getetag','EGw-no-etag-wGE'), // iPhone addressbook requires an etag here! ); switch ($app) @@ -707,16 +708,16 @@ class groupdav extends HTTP_WebDAV_Server } } if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); - + $this->_parse_path($options['path'],$id,$app,$user); - + if (($handler = self::app_handler($app)) && method_exists($handler, 'post')) { return $handler->post($options,$id,$user); } return '501 Not Implemented'; } - + /** * PUT method handler * @@ -734,7 +735,7 @@ class groupdav extends HTTP_WebDAV_Server $options['content'] .= fread($options['stream'],8192); } } - + if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); if (!$this->_parse_path($options['path'],$id,$app,$user,$prefix)) @@ -926,7 +927,7 @@ class groupdav extends HTTP_WebDAV_Server } $parts = explode('/', $this->_unslashify($path)); - if (($account_id = $this->accounts->name2id($parts[0], 'account_lid')) || + if (($account_id = $this->accounts->name2id($parts[0], 'account_lid')) || ($account_id = $this->accounts->name2id($parts[0]=urldecode($parts[0])))) { // /$user/$app/... diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index 06607dfeb6..3ff46b6e44 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -246,7 +246,7 @@ abstract class groupdav_handler { if ($return_no_access && !is_null($entry)) { - if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) is_null(\$entry)=".(int)is_null($entry).", set to false"); + if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); $return_no_access = false; } else @@ -277,7 +277,7 @@ abstract class groupdav_handler if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); return '304 Not Modified'; } - } + } } if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { @@ -341,8 +341,10 @@ abstract class groupdav_handler 'bionicmessage.net' => 'funambol', // funambol GroupDAV connector from bionicmessage.net 'zideone' => 'zideone', // zideone outlook plugin 'lightning' => 'lightning', // Lighting (SOGo connector for addressbook) + 'webkit' => 'webkit', // Webkit Browser (also reports KHTML!) 'khtml' => 'kde', // KDE clients - 'neon' => 'neon' + 'neon' => 'neon', + 'ical4ol' => 'ical4ol', // iCal4OL client ) as $pattern => $name) { if (strpos($user_agent,$pattern) !== false) @@ -364,12 +366,13 @@ abstract class groupdav_handler { if ((int)$matches[1] < 868) $agent .= '_old'; } + break; } } } - + if ($debug) error_log(__METHOD__."GroupDAV client: $agent"); - + return $agent; } } diff --git a/phpgwapi/inc/class.groupdav_hooks.inc.php b/phpgwapi/inc/class.groupdav_hooks.inc.php index a48a1147ba..d0daf725d1 100644 --- a/phpgwapi/inc/class.groupdav_hooks.inc.php +++ b/phpgwapi/inc/class.groupdav_hooks.inc.php @@ -18,7 +18,7 @@ class groupdav_hooks { /** * Show GroupDAV preferences link in preferences - * + * * @param string|array $args */ public static function menus($args) @@ -41,7 +41,7 @@ class groupdav_hooks } } } - + /** * populates $settings for the preferences * @@ -71,7 +71,7 @@ class groupdav_hooks 'O' => lang('All in one'), 'A' => lang('All'), ) + $addressbooks; - + // rewriting owner=0 to 'U', as 0 get's always selected by prefs if (!isset($addressbooks[0])) { @@ -82,7 +82,7 @@ class groupdav_hooks unset($addressbooks[0]); } - $settings['add_default'] = array( + $settings['addressbook-home-set'] = array( 'type' => 'multiselect', 'label' => 'Addressbooks to sync with Apple clients', 'name' => 'addressbook-home-set', @@ -92,6 +92,22 @@ class groupdav_hooks 'admin' => False, 'default' => 'P', ); + + $settings['debug_level'] = array( + 'type' => 'select', + 'label' => 'Debug level for Apache/PHP error-log', + 'name' => 'debug_level', + 'help' => 'Enables debug-messages to Apache/PHP error-log, allowing to diagnose problems on a per user basis.', + 'values' => array( + '0' => '0 - off', + '1' => '1 - function calls', + '2' => '2 - more info', + '3' => '3 - complete $_SERVER array', + ), + 'xmlrpc' => true, + 'admin' => false, + 'default' => '0', + ); return $settings; } } \ No newline at end of file