fix all IDE warnings, before moving classes to api, in case we want to merge it back to 14.x

This commit is contained in:
Ralf Becker 2016-04-02 08:40:34 +00:00
parent 3428d82b26
commit 9eb1ecbd36
7 changed files with 246 additions and 170 deletions

View File

@ -1,6 +1,6 @@
<?php
/**
* EGroupware: GroupDAV access: addressbook handler
* EGroupware: CalDAV/CardDAV/GroupDAV access: Addressbook handler
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
@ -21,8 +21,6 @@ use EGroupware\Api;
*
* Permanent error_log() calls should use $this->groupdav->log($str) instead, to be send to PHP error_log()
* and our request-log (prefixed with "### " after request and response, like exceptions).
*
* @todo check/fix contacts in LDAP (no carddav_name column!)
*/
class addressbook_groupdav extends groupdav_handler
{
@ -127,6 +125,7 @@ class addressbook_groupdav extends groupdav_handler
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null;
// process REPORT filters or multiget href's
$nresults = null;
if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options,$filter,$id, $nresults))
{
return false;
@ -384,6 +383,7 @@ class addressbook_groupdav extends groupdav_handler
$options['filters']['attrs']['test'] : 'anyof';
$prop_filters = array();
$matches = $prop_test = $column = null;
foreach($options['filters'] as $n => $filter)
{
if (!is_int($n)) continue; // eg. attributes of filter xml element
@ -464,7 +464,7 @@ class addressbook_groupdav extends groupdav_handler
if ($prop_filters)
{
$filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))';
if ($this->debug) error_log(__METHOD__."($path,...) sql-filter: $filter");
if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
}
}
// parse limit from $options['other']
@ -542,6 +542,8 @@ class addressbook_groupdav extends groupdav_handler
*/
function get(&$options,$id,$user=null)
{
unset($user); // not used, but required by function signature
if (!is_array($contact = $this->_common_get_put_delete('GET',$options,$id)))
{
return $contact;
@ -577,9 +579,9 @@ class addressbook_groupdav extends groupdav_handler
}
$handler = self::_get_handler();
$vCard = htmlspecialchars_decode($options['content']);
// Fix for Apple Addressbook
$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', $vCard);
$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1',
htmlspecialchars_decode($options['content']));
$charset = null;
if (!empty($options['content_type']))
{
@ -733,8 +735,10 @@ class addressbook_groupdav extends groupdav_handler
{
$new_members = array($new_members);
}
foreach($new_members as &$uid) $uid = substr($uid,9); // cut off "urn:uuid:" prefix
foreach($new_members as &$uid)
{
$uid = substr($uid,9); // cut off "urn:uuid:" prefix
}
if ($oldContact)
{
$to_add = array_diff($new_members,$oldContact['members']);
@ -809,6 +813,7 @@ class addressbook_groupdav extends groupdav_handler
$lists_ctag = $this->bo->lists_ctag($user);
}
//error_log(__METHOD__."('$path', ".array2string($user_in).") --> user=".array2string($user)." --> ctag=$ctag=".date('Y-m-d H:i:s',$ctag).", lists_ctag=".($lists_ctag ? $lists_ctag.'='.date('Y-m-d H:i:s',$lists_ctag) : '').' returning '.max($ctag,$lists_ctag));
unset($user_in);
return $ctags[$path] = max($ctag, $accounts_ctag, $lists_ctag);
}
@ -836,8 +841,10 @@ class addressbook_groupdav extends groupdav_handler
* @param int $user =null account_id of owner of collection
* @return array
*/
public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
public function extra_properties(array $props, $displayname, $base_uri=null, $user=null)
{
unset($displayname, $base_uri, $user); // not used, but required by function signature
if (!isset($props['addressbook-description']))
{
// default addressbook description: can be overwritten via PROPPATCH, in which case it's already set
@ -889,6 +896,7 @@ class addressbook_groupdav extends groupdav_handler
$databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names!
// Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone)
$matches = null;
if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520 ||
// iOS 5.1.1 does not display CLASS or CATEGORY, but wrongly escapes multiple, comma-separated categories
// and appends CLASS: PUBLIC to an empty NOTE: field --> leaving them out for iOS
@ -951,12 +959,12 @@ class addressbook_groupdav extends groupdav_handler
*/
function read($id, $path=null)
{
static $non_deleted_tids;
static $non_deleted_tids=null;
if (is_null($non_deleted_tids))
{
$non_deleted_tids = $this->bo->content_types;
unset($non_deleted_tids[Api\Contacts::DELETED_TYPE]);
$non_deleted_tids = array_keys($non_deleted_tids);
$tids = $this->bo->content_types;
unset($tids[Api\Contacts::DELETED_TYPE]);
$non_deleted_tids = array_keys($tids);
}
$contact = $this->bo->read(array(self::$path_attr => $id, 'tid' => $non_deleted_tids));
@ -1065,7 +1073,7 @@ class addressbook_groupdav extends groupdav_handler
$this->home_set_pref[$key] = $id;
}
}
foreach($this->bo->get_addressbooks(EGW_ACL_READ) as $id => $label)
foreach(array_keys($this->bo->get_addressbooks(EGW_ACL_READ)) as $id)
{
if (($id || !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) &&
$GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs

View File

@ -1,13 +1,13 @@
<?php
/**
* EGroupware: CalDAV / GroupDAV access: calendar handler
* EGroupware: CalDAV/CardDAV/GroupDAV access: Calendar handler
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
* @subpackage groupdav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/

View File

@ -1,13 +1,13 @@
<?php
/**
* EGroupware: GroupDAV access: infolog handler
* EGroupware: CalDAV/CardDAV/GroupDAV access: InfoLog handler
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog
* @subpackage groupdav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
@ -146,6 +146,7 @@ class infolog_groupdav extends groupdav_handler
$filter = $this->get_infolog_filter($path, $user);
// process REPORT filters or multiget href's
$nresults = null;
if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options, $filter, $id, $nresults))
{
// return empty collection, as iCal under iOS 5 had problems with returning "404 Not found" status
@ -234,6 +235,7 @@ class infolog_groupdav extends groupdav_handler
$order = 'info_datemodified';
$sort = 'DESC';
$matches = null;
if (preg_match('/^([a-z0-9_]+)( DESC| ASC)?$/i', $filter['order'], $matches))
{
$order = $matches[1];
@ -337,8 +339,6 @@ class infolog_groupdav extends groupdav_handler
{
if ($options['filters'])
{
$cal_filters_in = $cal_filters; // remember filter, to be able to reset standard open-filter, if client sets own filters
foreach($options['filters'] as $filter)
{
switch($filter['name'])
@ -508,7 +508,7 @@ class infolog_groupdav extends groupdav_handler
"NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : '').
')';
$sql = '('.implode(' OR ', $to_or).')';
if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range={$filter['attrs']['start']}-{$filter['attrs']['end']} --> $sql");
if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
return $sql;
}
@ -522,6 +522,8 @@ class infolog_groupdav extends groupdav_handler
*/
function get(&$options,$id,$user=null)
{
unset($user); // not used, but required by function signature
if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id)))
{
return $task;
@ -545,6 +547,8 @@ class infolog_groupdav extends groupdav_handler
*/
function put(&$options,$id,$user=null,$prefix=null)
{
unset($prefix); // not used, but required by function signature
if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
$oldTask = $this->_common_get_put_delete('PUT',$options,$id);
@ -584,9 +588,9 @@ class infolog_groupdav extends groupdav_handler
// send evtl. necessary respose headers: Location, etag, ...
// but only for new entries, as X-INFOLOG-STATUS get's not updated on client, if we confirm with an etag
if ($retval !== true && (!$path_attr_is_name ||
if ($retval !== true)
// POST with add-member query parameter
$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member'])))
//$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member'])))
{
$this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name');
}
@ -774,8 +778,10 @@ class infolog_groupdav extends groupdav_handler
* @param int $user =null account_id of owner of collection
* @return array
*/
public function extra_properties(array $props=array(), $displayname, $base_uri=null,$user=null)
public function extra_properties(array $props, $displayname, $base_uri=null,$user=null)
{
unset($base_uri); // not used, but required by function signature
// calendar description
$displayname = translation::convert(lang('Tasks of'),translation::charset(),'utf-8').' '.$displayname;
$props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname);

View File

@ -252,7 +252,7 @@ class groupdav extends HTTP_WebDAV_Server
$this->dav_powered_by = str_replace('EGroupware','EGroupware '.$GLOBALS['egw_info']['server']['versions']['phpgwapi'],
$this->dav_powered_by);
parent::__Construct();
parent::__construct();
// hack to allow to use query parameters in WebDAV, which HTTP_WebDAV_Server interprets as part of the path
list($this->_SERVER['REQUEST_URI']) = explode('?',$this->_SERVER['REQUEST_URI']);
/*if (substr($this->_SERVER['REQUEST_URI'],-13) == '/;add-member/')
@ -306,6 +306,8 @@ class groupdav extends HTTP_WebDAV_Server
*/
function OPTIONS($path, &$dav, &$allow)
{
unset($allow); // not used, but required by function signature
// locking support
if (!in_array('2', $dav)) $dav[] = '2';
@ -361,6 +363,7 @@ class groupdav extends HTTP_WebDAV_Server
$this->propfind_options = $options;
// parse path in form [/account_lid]/app[/more]
$id = $app = $user = $user_prefix = null;
if (!self::_parse_path($options['path'],$id,$app,$user,$user_prefix) && $app && !$user && $user !== 0)
{
if ($this->debug > 1) error_log(__CLASS__."::$method: user='$user', app='$app', id='$id': 404 not found!");
@ -693,7 +696,7 @@ class groupdav extends HTTP_WebDAV_Server
{
if (!isset($GLOBALS['egw_info']['user']['apps']['resources']))
{
if ($this->debug) error_log(__CLASS__."::$method(path=$path) 403 Forbidden: no app rights for 'resources'");
if ($this->debug) error_log(__METHOD__."(path=$path) 403 Forbidden: no app rights for 'resources'");
return "403 Forbidden: no app rights for 'resources'"; // no rights for the given app
}
list(,$what) = explode('/', $path);
@ -707,7 +710,7 @@ class groupdav extends HTTP_WebDAV_Server
}
if ($depth)
{
foreach(groupdav_principals::get_resources() as $res_id => $resource)
foreach(groupdav_principals::get_resources() as $resource)
{
if ($is_location == groupdav_principals::resource_is_location($resource))
{
@ -800,6 +803,7 @@ class groupdav extends HTTP_WebDAV_Server
if (is_string($user) && $user[0] == 'r' && ($resource = groupdav_principals::read_resource(substr($user, 1))))
{
$is_location = groupdav_principals::resource_is_location($resource);
$displayname = null;
list($principalType, $account_lid) = explode('/', groupdav_principals::resource2name($resource, $is_location, $displayname));
}
elseif ($user)
@ -857,6 +861,7 @@ class groupdav extends HTTP_WebDAV_Server
}
// add props modifyable via proppatch from client, eg. calendar-color, see self::$proppatch_props
$ns = null;
foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $name => $value)
{
unset($ns);
@ -972,6 +977,7 @@ class groupdav extends HTTP_WebDAV_Server
{
if ($this->debug) error_log(__METHOD__.'('.array2string($options).')');
$id = $app = $user = null;
if (!$this->_parse_path($options['path'],$id,$app,$user) || $app == 'principals')
{
return $this->autoindex($options);
@ -1031,6 +1037,7 @@ class groupdav extends HTTP_WebDAV_Server
//'DAV:sync-token' => 'sync-token',
);
$n = 0;
$collection_props = null;
foreach($files['files'] as $file)
{
if (!isset($collection_props))
@ -1042,7 +1049,10 @@ class groupdav extends HTTP_WebDAV_Server
if(!$n++)
{
echo "<table>\n\t<tr class='th'>\n\t\t<th>#</th>\n\t\t<th>".lang('Name')."</th>";
foreach($props2show as $label) echo "\t\t<th>".lang($label)."</th>\n";
foreach($props2show as $label)
{
echo "\t\t<th>".lang($label)."</th>\n";
}
echo "\t</tr>\n";
}
$props = $this->props2array($file['props']);
@ -1083,9 +1093,9 @@ class groupdav extends HTTP_WebDAV_Server
foreach($collection_props as $name => $value)
{
$class = $class == 'row_on' ? 'row_off' : 'row_on';
$ns = explode(':',$name);
$name = array_pop($ns);
$ns = implode(':',$ns);
$parts = explode(':', $name);
$name = array_pop($parts);
$ns = implode(':', $parts);
echo "\t<tr class='$class'>\n\t\t<td>".htmlspecialchars($ns)."</td><td style='white-space: nowrap'>".htmlspecialchars($name)."</td>\n";
echo "\t\t<td>".$value."</td>\n\t</tr>\n";
}
@ -1132,14 +1142,13 @@ class groupdav extends HTTP_WebDAV_Server
{
$value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/','/').')?([^<]+)\<\/(D:)?href\>/i','<\\1href><a href="\\2\\3">\\3</a></\\4href>',$value);
}
$value = $value[0] == '<' || strpos($value, "\n") !== false ? '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value);
$ret = $value[0] == '<' || strpos($value, "\n") !== false ? '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value);
if ($href)
{
$value = preg_replace('/&lt;a href=&quot;(.+)&quot;&gt;/', '<a href="\\1">', $value);
$value = str_replace('&lt;/a&gt;', '</a>', $value);
$ret = str_replace('&lt;/a&gt;', '</a>', preg_replace('/&lt;a href=&quot;(.+)&quot;&gt;/', '<a href="\\1">', $ret));
}
return $value;
return $ret;
}
/**
@ -1204,6 +1213,7 @@ class groupdav extends HTTP_WebDAV_Server
}
if ($this->debug) error_log(__METHOD__.'('.array2string($options).')');
$id = $app = $user = null;
$this->_parse_path($options['path'],$id,$app,$user);
if (($handler = self::app_handler($app)))
@ -1267,12 +1277,14 @@ class groupdav extends HTTP_WebDAV_Server
switch($action)
{
case 'attachment-add':
$matches = null;
if (isset($this->_SERVER['HTTP_CONTENT_DISPOSITION']) &&
substr($this->_SERVER['HTTP_CONTENT_DISPOSITION'], 0, 10) === 'attachment' &&
preg_match('/filename="?([^";]+)/', $this->_SERVER['HTTP_CONTENT_DISPOSITION'], $matches))
{
$filename = egw_vfs::basename($matches[1]);
}
$path = null;
if (!($to = self::fopen_attachment($handler->app, $handler->get_id($entry), $filename, $this->_SERVER['CONTENT_TYPE'], $path)) ||
isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false ||
isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false)
@ -1288,7 +1300,7 @@ class groupdav extends HTTP_WebDAV_Server
case 'attachment-remove':
case 'attachment-update':
if (empty($_GET['managed-id']) || !($path = self::managed_id2path($_GET['managed-id'], $app, $id)))
if (empty($_GET['managed-id']) || !($path = self::managed_id2path($_GET['managed-id'], $handler->app, $id)))
{
self::xml_error(self::mkprop(self::CALDAV, 'valid-managed-id-parameter', ''));
return '403 Forbidden';
@ -1340,7 +1352,7 @@ class groupdav extends HTTP_WebDAV_Server
// check/handle Prefer: return-representation
// we can NOT use 204 No content (forbidds a body) with return=representation, therefore we need to use 200 Ok instead!
if ($handler->check_return_representation($options, $id, $user) && (int)$ret == 204)
if ($handler->check_return_representation($options, $id) && (int)$ret == 204)
{
$ret = '200 Ok';
}
@ -1446,19 +1458,20 @@ class groupdav extends HTTP_WebDAV_Server
*
* @param string $app
* @param int|string $id
* @param string $filename defaults to 'attachment'
* @param string $_filename defaults to 'attachment'
* @param string $mime =null mime-type to generate extension
* @param string &$path =null on return path opened
* @return resource
*/
protected static function fopen_attachment($app, $id, $filename, $mime=null, &$path=null)
protected static function fopen_attachment($app, $id, $_filename, $mime=null, &$path=null)
{
$filename = empty($filename) ? 'attachment' : egw_vfs::basename($filename);
$filename = empty($_filename) ? 'attachment' : egw_vfs::basename($_filename);
if (strpos($mime, ';')) list($mime) = explode(';', $mime); // in case it contains eg. charset info
$ext = !empty($mime) ? mime_magic::mime2ext($mime) : '';
$matches = null;
if (!$ext || substr($filename, -strlen($ext)-1) == '.'.$ext ||
preg_match('/\.([^.]+)$/', $filename, $matches) && mime_magic::ext2mime($matches[1]) == $mime)
{
@ -1494,7 +1507,7 @@ class groupdav extends HTTP_WebDAV_Server
*/
protected static function path2location($path)
{
static $url_prefix;
static $url_prefix = null;
if (!isset($url_prefix))
{
$url_prefix = '';
@ -1619,11 +1632,15 @@ class groupdav extends HTTP_WebDAV_Server
if ($this->debug) error_log(__METHOD__."(".array2string($options).')');
// parse path in form [/account_lid]/app[/more]
$id = $app = $user = $user_prefix = null;
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(__METHOD__.": user='$user', app='$app', id='$id': 404 not found!");
foreach($options['props'] as &$prop) $prop['status'] = '403 Forbidden';
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
@ -1699,6 +1716,7 @@ class groupdav extends HTTP_WebDAV_Server
if ($this->debug) error_log(__METHOD__.'('.array2string($options).')');
$id = $app = $user = $prefix = null;
if (!$this->_parse_path($options['path'],$id,$app,$user,$prefix))
{
return '404 Not Found';
@ -1734,6 +1752,7 @@ class groupdav extends HTTP_WebDAV_Server
{
if ($this->debug) error_log(__METHOD__.'('.array2string($options).')');
$id = $app = $user = null;
if (!$this->_parse_path($options['path'],$id,$app,$user))
{
return '404 Not Found';
@ -1795,6 +1814,7 @@ class groupdav extends HTTP_WebDAV_Server
*/
function LOCK(&$options)
{
$id = $app = $user = null;
self::_parse_path($options['path'],$id,$app,$user);
$path = egw_vfs::app_entry_lock_path($app,$id);
@ -1828,6 +1848,7 @@ class groupdav extends HTTP_WebDAV_Server
*/
function UNLOCK(&$options)
{
$id = $app = $user = null;
self::_parse_path($options['path'],$id,$app,$user);
$path = egw_vfs::app_entry_lock_path($app,$id);
@ -1843,10 +1864,10 @@ class groupdav extends HTTP_WebDAV_Server
*/
function checkLock($path)
{
$id = $app = $user = null;
self::_parse_path($path,$id,$app,$user);
$path = egw_vfs::app_entry_lock_path($app,$id);
return egw_vfs::checkLock($path);
return egw_vfs::checkLock(egw_vfs::app_entry_lock_path($app, $id));
}
/**
@ -1857,9 +1878,10 @@ class groupdav extends HTTP_WebDAV_Server
*/
function ACL(&$options)
{
$id = $app = $user = null;
self::_parse_path($options['path'],$id,$app,$user);
if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$path");
if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$options[path]");
$options['errors'] = array();
switch ($app)
@ -2065,7 +2087,10 @@ class groupdav extends HTTP_WebDAV_Server
$content .= 'HTTP/1.1 '.$this->_http_status."\n";
$content .= 'Date: '.str_replace('+0000', 'GMT', gmdate('r'))."\n";
$content .= 'Server: '.$_SERVER['SERVER_SOFTWARE']."\n";
foreach(headers_list() as $line) $content .= $line."\n";
foreach(headers_list() as $line)
{
$content .= $line."\n";
}
if (($c = ob_get_flush())) $content .= "\n";
if (self::$log_level !== 'f' && strlen($c) > 1536) $c = substr($c,0,1536)."\n*** LOG TRUNKATED\n";
$content .= $c;
@ -2084,7 +2109,10 @@ class groupdav extends HTTP_WebDAV_Server
}
else
{
foreach(explode("\n",$content) as $line) error_log($line);
foreach(explode("\n",$content) as $line)
{
error_log($line);
}
}
}
}
@ -2179,6 +2207,7 @@ class groupdav extends HTTP_WebDAV_Server
public static function exception_handler(Exception $e)
{
// logging exception as regular egw_execption_hander does
$headline = null;
_egw_log_exception($e,$headline);
// exception handler sending message back to the client as basic auth message

View File

@ -1,13 +1,13 @@
<?php
/**
* EGroupware: GroupDAV access: abstract baseclass for groupdav/caldav/carddav handlers
* EGroupware: CalDAV/CardDAV/GroupDAV access: abstract baseclass for application handlers
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage groupdav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
@ -119,7 +119,7 @@ abstract class groupdav_handler
function __construct($app, groupdav $groupdav)
{
$this->app = $app;
if (!is_null($parent->debug)) $this->debug = $groupdav->debug;
if (!is_null($groupdav->debug)) $this->debug = $groupdav->debug;
$this->base_uri = $groupdav->base_uri;
$this->groupdav = $groupdav;
@ -151,7 +151,10 @@ abstract class groupdav_handler
* @param int &$total
* @return array with "files" array with values for keys path and props
*/
function &propfind_callback($path, array $filter,$start,&$total) { }
function &propfind_callback($path, array $filter,$start,&$total)
{
unset($path, $filter, $start, $total); // not used, but required by function signature
}
/**
* Handle get request for an applications entry
@ -220,15 +223,17 @@ abstract class groupdav_handler
* @param int $user =null account_id of owner of collection
* @return array
*/
public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
public function extra_properties(array $props, $displayname, $base_uri=null, $user=null)
{
unset($displayname, $base_uri, $user); // not used, but required by function signature
return $props;
}
/**
* Get the etag for an entry, can be reimplemented for other algorithm or field names
*
* @param array|int $event array with event or cal_id
* @param array|int $entry array with event or cal_id
* @return string|boolean string with etag or false
*/
function get_etag($entry)
@ -385,7 +390,7 @@ abstract class groupdav_handler
*/
public function update_tags($entry)
{
unset($entry); // not used, but required by function signature
}
/**
@ -408,8 +413,6 @@ abstract class groupdav_handler
$handler_cache[$app] = new $class($app, $groupdav);
}
if ($debug) error_log(__METHOD__."('$app')");
return $handler_cache[$app];
}
@ -420,7 +423,7 @@ abstract class groupdav_handler
*/
static function get_agent()
{
static $agent;
static $agent=null;
if (is_null($agent))
{
@ -464,6 +467,7 @@ abstract class groupdav_handler
switch ($agent)
{
case 'cfnetwork':
$matches = null;
if (preg_match('/address%20book\/([0-9.]+)/', $user_agent, $matches))
{
if ((int)$matches[1] < 868) $agent .= '_old';
@ -481,9 +485,7 @@ abstract class groupdav_handler
}
}
}
if ($debug) error_log(__METHOD__."GroupDAV client: $agent");
//error_log(__METHOD__."GroupDAV client: $agent");
return $agent;
}
@ -508,7 +510,9 @@ abstract class groupdav_handler
*/
public function current_user_privileges($path, $user=null)
{
static $grants;
unset($path); // not used, but required by function signature
static $grants=null;
if (is_null($grants))
{
$grants = $this->get_grants();
@ -602,6 +606,8 @@ abstract class groupdav_handler
*/
static function get_settings($hook_data)
{
unset($hook_data); // not used, but required by function signature
return array();
}
@ -660,8 +666,8 @@ abstract class groupdav_handler
*/
public function base_uri($full_uri=true)
{
static $uri;
static $path;
static $uri=null;
static $path=null;
if (!isset($uri))
{

View File

@ -1,13 +1,13 @@
<?php
/**
* EGroupware: GroupDAV hooks: eg. preferences
* EGroupware: CalDAV/CardDAV/GroupDAV access: hooks eg. preferences
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage groupdav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2010-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2010-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/

View File

@ -1,13 +1,13 @@
<?php
/**
* EGroupware: GroupDAV access: groupdav/caldav/carddav principals handlers
* EGroupware: CalDAV/CardDAV/GroupDAV access: Principals handlers
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage groupdav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2008-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2008-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
@ -83,6 +83,8 @@ class groupdav_principals extends groupdav_handler
*/
protected function supported_report_set($path, array $reports=null)
{
unset($path); // not used, but required by function signature
if (is_null($reports)) $reports = $this->supported_reports;
$supported = array();
@ -117,7 +119,7 @@ class groupdav_principals extends groupdav_handler
$this->groupdav->log(__METHOD__."('$path', ".array2string($options).",, $user) not implemented report, returning 501 Not Implemented");
return '501 Not Implemented';
}
list(,$principals,$type,$name,$rest) = explode('/',$path,5);
list(,,$type,$name,$rest) = explode('/',$path,5);
// /principals/users/$name/
// /users/$name/calendar-proxy-read/
// /users/$name/calendar-proxy-write/
@ -291,7 +293,7 @@ class groupdav_principals extends groupdav_handler
continue;
}
// find prop to expand
foreach($prop_files['files'][0]['props'] as $name => $expand_prop)
foreach($prop_files['files'][0]['props'] as $expand_prop)
{
if ($expand_prop['name'] === $prop_name) break;
}
@ -526,7 +528,10 @@ class groupdav_principals extends groupdav_handler
foreach($search_props as $search_prop)
{
// search resource for $search_prop
foreach($resource['props'] as $prop) if ($prop['name'] === $search_prop['name']) break;
foreach($resource['props'] as $prop)
{
if ($prop['name'] === $search_prop['name']) break;
}
if ($prop['name'] === $search_prop['name']) // search_prop NOT found
{
foreach((array)$prop['val'] as $value)
@ -635,6 +640,8 @@ class groupdav_principals extends groupdav_handler
*/
function principal_search_property_set_report($path,&$options,&$files,$user)
{
unset($path, $options, $files, $user); // not used, but required by function signature
static $search_props = array(
// from iOS iCal
'displayname' => 'Display Name',
@ -787,7 +794,10 @@ class groupdav_principals extends groupdav_handler
$this->groupdav->log(__METHOD__."('$name', ...) account '$name' NOT found OR not visible to you (check account-selection preference)!");
return '404 Not Found';
}
while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
while (substr($rest,-1) == '/')
{
$rest = substr($rest,0,-1);
}
switch((string)$rest)
{
case '':
@ -850,7 +860,10 @@ class groupdav_principals extends groupdav_handler
{
return '404 Not Found';
}
while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
while (substr($rest,-1) == '/')
{
$rest = substr($rest,0,-1);
}
switch((string)$rest)
{
case '':
@ -881,9 +894,9 @@ class groupdav_principals extends groupdav_handler
protected function get_shared_addressbooks()
{
$addressbooks = array();
$addressbook_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
if (empty($addressbook_home_set)) $addressbook_home_set = 'P'; // personal addressbook
$addressbook_home_set = explode(',',$addressbook_home_set);
$ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook
$addressbook_home_set = explode(',', $ab_home_set);
// replace symbolic id's with real nummeric id's
foreach(array(
'P' => $GLOBALS['egw_info']['user']['account_id'],
@ -900,7 +913,7 @@ class groupdav_principals extends groupdav_handler
{
$addressbooks[] = '/';
}
foreach(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ) as $id => $label)
foreach(array_keys(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ)) as $id)
{
if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) &&
is_numeric($id) && ($owner = $this->accounts->id2name($id)))
@ -1037,8 +1050,8 @@ class groupdav_principals extends groupdav_handler
list($type, $id, $install_id) = explode('-', $uid);
if ($type == 'accounts' && empty($id)) // groups have a negative id, eg. "urn:uuid:accounts--1-..."
{
list($type, $nul, $id, $install_id) = explode('-', $uid);
$id = -$id;
list($type, , $id_abs, $install_id) = explode('-', $uid);
$id = -$id_abs;
}
// own urn
if ($urn_type === 'uuid' && $install_id === $GLOBALS['egw_info']['server']['install_id'])
@ -1050,7 +1063,7 @@ class groupdav_principals extends groupdav_handler
}
else
{
static $calendar_bo;
static $calendar_bo=null;
if (is_null($calendar_bo)) $calendar_bo = new calendar_bo();
foreach($calendar_bo->resources as $letter => $info)
{
@ -1123,6 +1136,7 @@ class groupdav_principals extends groupdav_handler
*/
protected function add_principal_resource(array $resource, $is_location=null)
{
$displayname = null;
$name = $this->resource2name($resource, $is_location, $displayname);
return $this->add_principal($name, array(
@ -1173,7 +1187,7 @@ class groupdav_principals extends groupdav_handler
*/
public static function resource_is_location($resource)
{
static $location_cats;
static $location_cats=null;
if (is_null($location_cats))
{
$config = config::read('resources');
@ -1194,7 +1208,7 @@ class groupdav_principals extends groupdav_handler
*/
public static function read_resource($res_id)
{
static $cache; // some per-request caching
static $cache=null; // some per-request caching
if (isset(self::$all_resources) && isset(self::$all_resources[$res_id]))
{
@ -1249,6 +1263,7 @@ class groupdav_principals extends groupdav_handler
'start' => 0,
'num_rows' => 10000, // return all aka first 10000 entries
);
$rows = $readonlys = null;
if (self::$resources->get_rows($query, $rows, $readonlys))
{
//_debug_array($rows);
@ -1270,7 +1285,7 @@ class groupdav_principals extends groupdav_handler
*/
protected function get_resource_rights()
{
static $grants;
static $grants=null;
if (is_null($grants))
{
@ -1335,7 +1350,7 @@ class groupdav_principals extends groupdav_handler
{
list($app,,$what) = explode('-', $type);
$proxys = array();
if (true) $proxys = array(); // ignore parameter!
list($account_type,$account) = explode('/', $principal);
switch($account_type)
@ -1366,8 +1381,8 @@ class groupdav_principals extends groupdav_handler
switch($app)
{
case 'resources':
$grants = $this->get_resource_rights();
$grants = (array)$grants[$location]; // returns array($location => $grants)
$res_grants = $this->get_resource_rights();
$grants = (array)$res_grants[$location]; // returns array($location => $grants)
break;
case 'calendar':
@ -1410,8 +1425,10 @@ class groupdav_principals extends groupdav_handler
* @param int $account who is the proxy
* @return array with href props
*/
protected function principal_set($prop, array $accounts=array(), $add_proxys=null, $account=null)
protected function principal_set($prop, array $accounts=array(), $app_proxys=null, $account=null)
{
unset($prop); // not used, but required by function signature
$set = array();
foreach($accounts as $account_id => $account_lid)
{
@ -1420,9 +1437,9 @@ class groupdav_principals extends groupdav_handler
$set[] = HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/principals/'.($account_id < 0 ? 'groups/' : 'users/').$account_lid.'/');
}
}
if ($add_proxys)
if ($app_proxys)
{
foreach((array)$add_proxys as $app)
foreach((array)$app_proxys as $app)
{
if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue;
@ -1489,7 +1506,7 @@ class groupdav_principals extends groupdav_handler
* Get proxy-groups for given user $account: users or groups who GRANT proxy rights to $account
*
* @param int $account who is the proxy
* @param string|array $app_proxys=null applications for which proxys should be added
* @param string|array $app ='calendar' applications for which proxys should be added
* @return array with href props
*/
protected function get_calendar_proxy_groups($account, $app='calendar')
@ -1534,9 +1551,6 @@ class groupdav_principals extends groupdav_handler
if ($options['depth'])
{
$query = array(
);
if (($resources = $this->get_resources()))
{
//_debug_array($resources);
@ -1557,7 +1571,10 @@ class groupdav_principals extends groupdav_handler
return '404 Not Found';
}
$path = ($is_location ? 'locations/' : 'resources/').$name;
while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
while (substr($rest,-1) == '/')
{
$rest = substr($rest,0,-1);
}
switch((string)$rest)
{
case '':
@ -1597,12 +1614,12 @@ class groupdav_principals extends groupdav_handler
if ($options['depth'])
{
if (is_numeric($options['depth'])) --$options['depth'];
$files = array_merge($files,$this->propfind_users('','',$options));
$files = array_merge($files,$this->propfind_groups('','',$options));
$files = array_merge($files, $this->propfind_users('','',$options),
$this->propfind_groups('','',$options));
if ($GLOBALS['egw_info']['user']['apps']['resources'])
{
$files = array_merge($files,$this->propfind_resources('','',$options,false)); // resources
$files = array_merge($files,$this->propfind_resources('','',$options,true)); // locations
$files = array_merge($files, $this->propfind_resources('','',$options,false), // resources
$this->propfind_resources('','',$options,true)); // locations
}
//$files = array_merge($files,$this->propfind_uids('','',$options));
}
@ -1619,6 +1636,8 @@ class groupdav_principals extends groupdav_handler
*/
function get(&$options,$id,$user=null)
{
unset($options, $id, $user); // not used, but required by function signature
return false;
}
@ -1632,6 +1651,8 @@ class groupdav_principals extends groupdav_handler
*/
function put(&$options,$id,$user=null)
{
unset($options, $id, $user); // not used, but required by function signature
return false;
}
@ -1644,17 +1665,21 @@ class groupdav_principals extends groupdav_handler
*/
function delete(&$options,$id)
{
unset($options, $id); // not used, but required by function signature
return false;
}
/**
* Read an entry
*
* @param string/int $id
* @param string|int $id
* @return array/boolean array with entry, false if no read rights, null if $id does not exist
*/
function read($id)
{
unset($id); // not used, but required by function signature
return false;
}
@ -1662,7 +1687,7 @@ class groupdav_principals extends groupdav_handler
* Check if user has the neccessary rights on an entry
*
* @param int $acl EGW_ACL_READ, EGW_ACL_EDIT or EGW_ACL_DELETE
* @param array/int $entry entry-array or id
* @param array|int $entry entry-array or id
* @return boolean null if entry does not exist, false if no access, true if access permitted
*/
function check_access($acl,$entry)
@ -1681,7 +1706,7 @@ class groupdav_principals extends groupdav_handler
/**
* Get the etag for an entry, can be reimplemented for other algorithm or field names
*
* @param array/int $event array with event or cal_id
* @param array|int $account array with event or cal_id
* @return string/boolean string with etag or false
*/
function get_etag($account)
@ -1710,6 +1735,8 @@ class groupdav_principals extends groupdav_handler
*/
public function current_user_privileges($path, $user=null)
{
unset($path, $user); // not used, but required by function signature
return array('read', 'read-current-user-privilege-set');
}
}