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
{
@ -106,7 +104,7 @@ class addressbook_groupdav extends groupdav_handler
* @param array &$options
* @param array &$files
* @param int $user account_id
* @param string $id=''
* @param string $id =''
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
function propfind($path,&$options,&$files,$user,$id='')
@ -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;
@ -188,7 +187,7 @@ class addressbook_groupdav extends groupdav_handler
*
* @param string $path
* @param array& $filter
* @param array|boolean $start=false false=return all or array(start,num)
* @param array|boolean $start =false false=return all or array(start,num)
* @return array with "files" array with values for keys path and props
*/
function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true)
@ -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']
@ -537,11 +537,13 @@ class addressbook_groupdav extends groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id
* @param int $user =null account_id
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
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;
@ -561,8 +563,8 @@ class addressbook_groupdav extends groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id of owner, default null
* @param string $prefix=null user prefix from path (eg. /ralf from /ralf/addressbook)
* @param int $user =null account_id of owner, default null
* @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
function put(&$options,$id,$user=null,$prefix=null)
@ -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);
}
@ -830,14 +835,16 @@ class addressbook_groupdav extends groupdav_handler
* </D:supported-report-set>
* @link http://www.mail-archive.com/calendarserver-users@lists.macosforge.org/msg01156.html
*
* @param array $props=array() regular props by the 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
* @param string $base_uri =null base url of 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
@ -946,17 +954,17 @@ class addressbook_groupdav extends groupdav_handler
* the same UID and/or carddav_name as not deleted contacts and would block access to valid entries
*
* @param string|int $id
* @param string $path=null
* @param string $path =null
* @return array|boolean array with entry, false if no read rights, null if $id does not exist
*/
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));
@ -1044,7 +1052,7 @@ class addressbook_groupdav extends groupdav_handler
/**
* Return calendars/addressbooks shared from other users with the current one
*
* @param boolean $ignore_all_in_one=false if true, return selected addressbooks and not array() for all-in-one
* @param boolean $ignore_all_in_one =false if true, return selected addressbooks and not array() for all-in-one
* @return array account_id => account_lid pairs
*/
function get_shared($ignore_all_in_one=false)
@ -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
@ -217,7 +218,7 @@ class infolog_groupdav extends groupdav_handler
*
* @param string $path
* @param array $filter
* @param array|boolean $start=false false=return all or array(start,num)
* @param array|boolean $start =false false=return all or array(start,num)
* @return array with "files" array with values for keys path and props
*/
function &propfind_callback($path,array $filter,$start=false)
@ -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;
}
@ -517,11 +517,13 @@ class infolog_groupdav extends groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id
* @param int $user =null account_id
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
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;
@ -539,12 +541,14 @@ class infolog_groupdav extends groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id of owner, default null
* @param string $prefix=null user prefix from path (eg. /ralf from /ralf/addressbook)
* @param int $user =null account_id of owner, default null
* @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
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');
}
@ -609,7 +613,7 @@ class infolog_groupdav extends groupdav_handler
* Callback for infolog_ical::importVTODO to implement infolog-cat-action
*
* @param array $task
* @param array $oldTask=null
* @param array $oldTask =null
* @return array modified task data
*/
public function cat_action(array $task, $oldTask=null)
@ -768,14 +772,16 @@ class infolog_groupdav extends groupdav_handler
/**
* Add extra properties for calendar collections
*
* @param array $props=array() regular props by the 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
* @param string $base_uri =null base url of 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!");
@ -435,9 +438,9 @@ class groupdav extends HTTP_WebDAV_Server
* Add a collection to a PROPFIND request
*
* @param string $path
* @param array $props=array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
* @param array $privileges=array('read') values for current-user-privilege-set
* @param array $supported_privileges=null default $this->supported_privileges
* @param array $props =array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
* @param array $privileges =array('read') values for current-user-privilege-set
* @param array $supported_privileges =null default $this->supported_privileges
* @return array with values for keys 'path' and 'props'
*/
public function add_collection($path, array $props = array(), array $privileges=array('read','read-acl','read-current-user-privilege-set'), array $supported_privileges=null)
@ -454,9 +457,9 @@ class groupdav extends HTTP_WebDAV_Server
* Add a resource to a PROPFIND request
*
* @param string $path
* @param array $props=array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
* @param array $privileges=array('read') values for current-user-privilege-set
* @param array $supported_privileges=null default $this->supported_privileges
* @param array $props =array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
* @param array $privileges =array('read') values for current-user-privilege-set
* @param array $supported_privileges =null default $this->supported_privileges
* @return array with values for keys 'path' and 'props'
*/
public function add_resource($path, array $props = array(), array $privileges=array('read','read-current-user-privilege-set'), array $supported_privileges=null)
@ -529,7 +532,7 @@ class groupdav extends HTTP_WebDAV_Server
*
* @param string $name name of privilege
* @param string|array $data string with describtion or array with agregated privileges plus value for key '*description*', '*ns*', '*only*'
* @param string $path=null path to match with $data['*only*']
* @param string $path =null path to match with $data['*only*']
* @return array of self::mkprop() arrays
*/
protected function supported_privilege($name, $data, $path=null)
@ -557,8 +560,8 @@ class groupdav extends HTTP_WebDAV_Server
* Checks if a given property was requested in propfind request
*
* @param string $name property name
* @param string $ns=null namespace, if that is to be checked too
* @param boolean $return_prop=false if true return the property array with values for 'name', 'xmlns', 'attrs', 'children'
* @param string $ns =null namespace, if that is to be checked too
* @param boolean $return_prop =false if true return the property array with values for 'name', 'xmlns', 'attrs', 'children'
* @return boolean|string|array true: $name explicitly requested (or autoindex), "all": allprop or "names": propname requested, false: $name was not requested
*/
function prop_requested($name, $ns=null, $return_prop=false)
@ -686,14 +689,14 @@ class groupdav extends HTTP_WebDAV_Server
*
* @param array &$files
* @param string $path / or /<username>/
* @param int $depth=0
* @param int $depth =0
* @return string|boolean http status or true|false
*/
protected function add_resources_collection(array &$files, $path, $depth=0)
{
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))
{
@ -788,9 +791,9 @@ class groupdav extends HTTP_WebDAV_Server
* Add an application collection to a user home or the root
*
* @param string $app
* @param boolean $no_extra_types=false should the GroupDAV and CalDAV types be added (KAddressbook has problems with it in self URL)
* @param int $user=null owner of the collection, default current user
* @param string $path='/'
* @param boolean $no_extra_types =false should the GroupDAV and CalDAV types be added (KAddressbook has problems with it in self URL)
* @param int $user =null owner of the collection, default current user
* @param string $path ='/'
* @return array with values for keys 'path' and 'props'
*/
protected function add_app($app,$no_extra_types=false,$user=null,$path='/')
@ -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 $mime=null mime-type to generate extension
* @param string &$path=null on return path opened
* @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 = '';
@ -1560,8 +1573,8 @@ class groupdav extends HTTP_WebDAV_Server
* Return vfs-path of a managed-id
*
* @param string $managed_id
* @param string $app=null app-name to check against path
* @param string|int $id=null id to check agains path
* @param string $app =null app-name to check against path
* @param string|int $id =null id to check agains path
* @return string|boolean "/apps/$app/$id/something" or false if not found or not belonging to given $app/$id
*/
static public function managed_id2path($managed_id, $app=null, $id=null)
@ -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)
@ -1884,7 +1906,7 @@ class groupdav extends HTTP_WebDAV_Server
* @param int &$id
* @param string &$app addressbook, calendar, infolog (=infolog)
* @param int &$user
* @param string &$user_prefix=null
* @param string &$user_prefix =null
* @return boolean true on success, false on error
*/
function _parse_path($path,&$id,&$app,&$user,&$user_prefix=null)
@ -2019,7 +2041,7 @@ class groupdav extends HTTP_WebDAV_Server
/**
* Log the request
*
* @param string $extra='' extra text to add below request-log, eg. exception thrown
* @param string $extra ='' extra text to add below request-log, eg. exception thrown
*/
protected function log_request($extra='')
{
@ -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);
}
}
}
}
@ -2093,7 +2121,7 @@ class groupdav extends HTTP_WebDAV_Server
* Output xml error element
*
* @param string|array $xml_error string with name for empty element in DAV NS or array with props
* @param string $human_readable=null human readable error message
* @param string $human_readable =null human readable error message
*/
public static function xml_error($xml_error, $human_readable=null)
{
@ -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,14 +151,17 @@ 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
*
* @param array &$options
* @param int $id
* @param int $user=null account_id
* @param int $user =null account_id
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
abstract function get(&$options,$id,$user=null);
@ -168,7 +171,7 @@ abstract class groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id of owner, default null
* @param int $user =null account_id of owner, default null
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
abstract function put(&$options,$id,$user=null);
@ -186,7 +189,7 @@ abstract class groupdav_handler
* Read an entry
*
* @param string|int $id
* @param string $path=null implementation can use it, used in call from _common_get_put_delete
* @param string $path =null implementation can use it, used in call from _common_get_put_delete
* @return array|boolean array with entry, false if no read rights, null if $id does not exist
*/
abstract function read($id /*,$path=null*/);
@ -214,21 +217,23 @@ abstract class groupdav_handler
/**
* Add extra properties for collections
*
* @param array $props=array() regular props by the 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
* @param string $base_uri =null base url of 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)
@ -268,7 +273,7 @@ abstract class groupdav_handler
* @param array &$options
* @param int|string &$id on return self::$path_extension got removed
* @param boolean &$return_no_access=false if set to true on call, instead of '403 Forbidden' the entry is returned and $return_no_access===false
* @param boolean $ignore_if_match=false if true, ignore If-Match precondition
* @param boolean $ignore_if_match =false if true, ignore If-Match precondition
* @return array|string entry on success, string with http-error-code on failure, null for PUT on an unknown id
*/
function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false)
@ -343,7 +348,7 @@ abstract class groupdav_handler
*
* @param array $options
* @param int $id
* @param int $user=null account_id
* @param int $user =null account_id
* @return string|boolean http status of get or null if no representation was requested
*/
public function check_return_representation($options, $id, $user=null)
@ -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;
}
@ -503,12 +505,14 @@ abstract class groupdav_handler
* Priviledges are for the collection, not the resources / entries!
*
* @param string $path path of collection
* @param int $user=null owner of the collection, default current user
* @param int $user =null owner of the collection, default current user
* @return array with privileges
*/
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();
@ -556,8 +560,8 @@ abstract class groupdav_handler
* @param int|array $entry id or array of new created entry
* @param string $path
* @param int|string $retval
* @param boolean $path_attr_is_name=true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
* @param string $etag=null etag, to not calculate it again (if != null)
* @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
* @param string $etag =null etag, to not calculate it again (if != null)
*/
function put_response_headers($entry, $path, $retval, $path_attr_is_name=true, $etag=null)
{
@ -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();
}
@ -655,13 +661,13 @@ abstract class groupdav_handler
*
* base_uri of WebDAV class can be both, depending on EGroupware config
*
* @param boolean $full_uri=true
* @param boolean $full_uri =true
* @return string eg. https://domain.com/egroupware/groupdav.php
*/
public function base_uri($full_uri=true)
{
static $uri;
static $path;
static $uri=null;
static $path=null;
if (!isset($uri))
{
@ -726,7 +732,7 @@ abstract class groupdav_handler
*
* @param string $path
* @param int $user parameter necessary to call getctag, if no $token specified
* @param int $token=null modification time, default call getctag($path, $user) to fetch it
* @param int $token =null modification time, default call getctag($path, $user) to fetch it
* @return string
*/
public function get_sync_token($path, $user, $token=null)
@ -822,7 +828,7 @@ class groupdav_propfind_iterator implements Iterator
*
* @param groupdav_handler $handler
* @param array $filter filter for propfind call
* @param array $files=array() extra files/responses to return too
* @param array $files =array() extra files/responses to return too
*/
public function __construct(groupdav_handler $handler, $path, array $filter,array &$files=array())
{

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$
*/
@ -78,11 +78,13 @@ class groupdav_principals extends groupdav_handler
* Currently we return all reports independed of path
*
* @param string $path eg. '/principals/'
* @param array $reports=null
* @param array $reports =null
* @return array HTTP_WebDAV_Server::mkprop('supported-report-set', ...)
*/
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)
@ -559,7 +564,7 @@ class groupdav_principals extends groupdav_handler
*
* @param string $value value to test
* @param string $match criteria/sub-string
* @param string $match_type='contains' 'starts-with', 'ends-with' or 'equals'
* @param string $match_type ='contains' 'starts-with', 'ends-with' or 'equals'
*/
private static function match($value, $match, $match_type='contains')
{
@ -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)))
@ -972,8 +985,8 @@ class groupdav_principals extends groupdav_handler
* Convert CalDAV principal URL to a calendar uid
*
* @param string $url
* @param string|array $only_type=null allowed types, return false for other (valid) types, eg. "users", "groups" or "resources", default all
* @param string $cn=null common name to be stored in case of an "e" uid
* @param string|array $only_type =null allowed types, return false for other (valid) types, eg. "users", "groups" or "resources", default all
* @param string $cn =null common name to be stored in case of an "e" uid
* @return int|string|boolean integer account_id, string calendar uid or false if not a supported uid
*/
static public function url2uid($url, $only_type=null, $cn=null)
@ -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)
{
@ -1118,11 +1131,12 @@ class groupdav_principals extends groupdav_handler
* Add collection of a single resource to a collection
*
* @param array $resource
* @param boolean $is_location=null
* @param boolean $is_location =null
* @return array with values for keys 'path' and 'props'
*/
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]))
{
@ -1233,7 +1247,7 @@ class groupdav_principals extends groupdav_handler
/**
* Get all resources (we cache the resources here, to only query them once per request)
*
* @param int $user=null account_if of user, or null for current user
* @param int $user =null account_if of user, or null for current user
* @return array of array with values for res_id, cat_id and name (no other values1)
*/
public static function get_resources($user=null)
@ -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))
{
@ -1283,7 +1298,7 @@ class groupdav_principals extends groupdav_handler
* Add a collection
*
* @param string $path
* @param array $props=array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
* @param array $props =array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
* @return array with values for keys 'path' and 'props'
*/
protected function add_collection($path, array $props = array())
@ -1299,8 +1314,8 @@ class groupdav_principals extends groupdav_handler
* Add a principal collection
*
* @param string $principal relative to principal-collection-set, eg. "users/username"
* @param array $props=array() extra properties 'resourcetype' is added anyway
* @param string $principal_url=null include given principal url, relative to principal-collection-set, default $principal
* @param array $props =array() extra properties 'resourcetype' is added anyway
* @param string $principal_url =null include given principal url, relative to principal-collection-set, default $principal
* @return array with values for keys 'path' and 'props'
*/
protected function add_principal($principal, array $props = array(), $principal_url=null)
@ -1327,15 +1342,15 @@ class groupdav_principals extends groupdav_handler
*
* @param string $principal relative to principal-collection-set, eg. "users/username"
* @param string $type eg. 'calendar-proxy-read' or 'calendar-proxy-write'
* @param array $proxys=array()
* @param array $resource=null resource to use (to not query it multiple times from the database)
* @param array $proxys =array()
* @param array $resource =null resource to use (to not query it multiple times from the database)
* @return array with values for 'path' and 'props'
*/
protected function add_proxys($principal, $type, array $proxys=array(), array $resource=null)
{
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':
@ -1405,13 +1420,15 @@ class groupdav_principals extends groupdav_handler
* Create a named property with set or principal-urls
*
* @param string $prop egw. 'group-member-set' or 'membership'
* @param array $accounts=array() account_id => account_lid pairs
* @param string|array $app_proxys=null applications for which proxys should be added
* @param array $accounts =array() account_id => account_lid pairs
* @param string|array $app_proxys =null applications for which proxys should be added
* @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;
@ -1445,7 +1462,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_proxys =null applications for which proxys should be added
* @return array with href props
*/
protected function get_resource_proxy_groups($account)
@ -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')
@ -1515,7 +1532,7 @@ class groupdav_principals extends groupdav_handler
* @param string $name name of group or empty
* @param string $rest rest of path behind account-name
* @param array $options
* @param boolean $do_locations=false false: /principal/resources, true: /principals/locations
* @param boolean $do_locations =false false: /principal/resources, true: /principals/locations
* @return array|string array with files or HTTP error code
*/
protected function propfind_resources($name,$rest,array $options,$do_locations=false)
@ -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));
}
@ -1614,11 +1631,13 @@ class groupdav_principals extends groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id
* @param int $user =null account_id
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
function get(&$options,$id,$user=null)
{
unset($options, $id, $user); // not used, but required by function signature
return false;
}
@ -1627,11 +1646,13 @@ class groupdav_principals extends groupdav_handler
*
* @param array &$options
* @param int $id
* @param int $user=null account_id of owner, default null
* @param int $user =null account_id of owner, default null
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
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)
@ -1705,11 +1730,13 @@ class groupdav_principals extends groupdav_handler
* Privileges are for the collection, not the resources / entries!
*
* @param string $path path of collection
* @param int $user=null owner of the collection, default current user
* @param int $user =null owner of the collection, default current user
* @return array with privileges
*/
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');
}
}