forked from extern/egroupware
* GroupDAV preference for addressbook-home-set (requires to register hooks)
This commit is contained in:
parent
edf5759a50
commit
2575da2575
@ -235,7 +235,7 @@ abstract class groupdav_handler
|
||||
*/
|
||||
function _common_get_put_delete($method,&$options,$id,&$return_no_access=false)
|
||||
{
|
||||
if (!in_array($this->app,array('principals','groups')) && !$GLOBALS['egw_info']['user']['apps'][$this->app])
|
||||
if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app])
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'");
|
||||
return '403 Forbidden'; // no app rights
|
||||
|
97
phpgwapi/inc/class.groupdav_hooks.inc.php
Normal file
97
phpgwapi/inc/class.groupdav_hooks.inc.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* EGroupware: GroupDAV 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 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* GroupDAV hooks: eg. preferences
|
||||
*/
|
||||
class groupdav_hooks
|
||||
{
|
||||
/**
|
||||
* Show GroupDAV preferences link in preferences
|
||||
*
|
||||
* @param string|array $args
|
||||
*/
|
||||
public static function menus($args)
|
||||
{
|
||||
$appname = 'groupdav';
|
||||
$location = is_array($args) ? $args['location'] : $args;
|
||||
|
||||
if ($location == 'preferences')
|
||||
{
|
||||
$file = array(
|
||||
'Preferences' => egw::link('/index.php','menuaction=preferences.uisettings.index&appname='.$appname),
|
||||
);
|
||||
if ($location == 'preferences')
|
||||
{
|
||||
display_section($appname,$file);
|
||||
}
|
||||
else
|
||||
{
|
||||
display_sidebox($appname,lang('Preferences'),$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* populates $settings for the preferences
|
||||
*
|
||||
* @param array|string $hook_data
|
||||
* @return array
|
||||
*/
|
||||
static function settings($hook_data)
|
||||
{
|
||||
$settings = array();
|
||||
|
||||
if ($hook_data['setup'])
|
||||
{
|
||||
$addressbooks = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$user = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$addressbook_bo = new addressbook_bo();
|
||||
$addressbooks = $addressbook_bo->get_addressbooks(EGW_ACL_READ);
|
||||
unset($addressbooks[$user]); // Use P for personal addressbook
|
||||
unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
|
||||
}
|
||||
$addressbooks = array(
|
||||
'P' => lang('Personal'),
|
||||
'G' => lang('Primary Group'),
|
||||
//'U' => lang('Accounts'), // not yet working
|
||||
'O' => lang('All in one'),
|
||||
'A' => lang('All'),
|
||||
) + $addressbooks;
|
||||
|
||||
// rewriting owner=0 to 'U', as 0 get's always selected by prefs
|
||||
if (!isset($addressbooks[0]))
|
||||
{
|
||||
unset($addressbooks['U']);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($addressbooks[0]);
|
||||
}
|
||||
|
||||
$settings['add_default'] = array(
|
||||
'type' => 'multiselect',
|
||||
'label' => 'Addressbooks to sync with Apple clients',
|
||||
'name' => 'addressbook-home-set',
|
||||
'help' => 'Only read when a new account get created on the client! CardDAV attribute addressbook-home-set.',
|
||||
'values' => $addressbooks,
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'default' => 'P',
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
@ -251,20 +251,43 @@ class groupdav_principals extends groupdav_handler
|
||||
$this->base_uri.'/principals/groups/'.$group);
|
||||
}
|
||||
}
|
||||
$addressbooks = array();
|
||||
$calendars = array();
|
||||
$addressbooks = $calendars = array();
|
||||
if ($account['account_id'] == $GLOBALS['egw_info']['user']['account_id'])
|
||||
{
|
||||
$addr_bo = new addressbook_bo();
|
||||
foreach ($addr_bo->get_addressbooks() as $id => $label)
|
||||
$prefs = $GLOBALS['egw_info']['user']['preferences']['groupdav'];
|
||||
$addressbook_home_set = $prefs['addressbook-home-set'];
|
||||
if (empty($addressbook_home_set)) $addressbook_home_set = 'P'; // personal addressbook
|
||||
|
||||
if (strpos($addressbook_home_set,'A') !== false)
|
||||
{
|
||||
if ($id && is_numeric($id))
|
||||
$addressbook_home_set = array_keys(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ));
|
||||
}
|
||||
else
|
||||
{
|
||||
$addressbook_home_set = explode(',',$addressbook_home_set);
|
||||
}
|
||||
foreach($addressbook_home_set as $id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 'P':
|
||||
$id = $GLOBALS['egw_info']['user']['account_id'];
|
||||
break;
|
||||
case 'G':
|
||||
$id = $GLOBALS['egw_info']['user']['account_primary_group'];
|
||||
break;
|
||||
case 'O': // "all in one" from groupdav.php/addressbook/
|
||||
$addressbooks[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/');
|
||||
continue 2;
|
||||
}
|
||||
if (is_numeric($id) && ($owner = $GLOBALS['egw']->accounts->id2name($id)))
|
||||
{
|
||||
$owner = $GLOBALS['egw']->accounts->id2name($id);
|
||||
$addressbooks[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$owner.'/');
|
||||
}
|
||||
}
|
||||
|
||||
$cal_bo = new calendar_bo();
|
||||
foreach ($cal_bo->list_cals() as $label => $entry)
|
||||
{
|
||||
@ -277,7 +300,7 @@ class groupdav_principals extends groupdav_handler
|
||||
else
|
||||
{
|
||||
$addressbooks[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$account['account_lid'].'/');
|
||||
$this->base_uri.'/'.$account['account_lid'].'/');
|
||||
$calendars[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$account['account_lid'].'/');
|
||||
}
|
||||
|
@ -251,7 +251,11 @@ class hooks
|
||||
$f = EGW_SERVER_ROOT . $SEP . $appname . $SEP . 'setup' . $SEP . 'setup.inc.php';
|
||||
$setup_info = array($appname => array());
|
||||
if(@file_exists($f)) include($f);
|
||||
$this->register_hooks($appname,$setup_info[$appname]['hooks']);
|
||||
// some apps have setup_info for more then themselfs (eg. phpgwapi for groupdav)
|
||||
foreach($setup_info as $appname => $data)
|
||||
{
|
||||
if ($data['hooks']) $this->register_hooks($appname,$data['hooks']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user