move app-specific settings to app-handler

This commit is contained in:
Ralf Becker 2012-02-04 01:24:34 +00:00
parent d21be8d871
commit c5ca42a4b1
5 changed files with 135 additions and 78 deletions

View File

@ -815,4 +815,52 @@ class addressbook_groupdav extends groupdav_handler
}
return $shared;
}
/**
* Return appliction specific settings
*
* return array of array with settings
*/
static function get_settings()
{
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]); // allways synced
unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
}
$addressbooks = array(
'A' => lang('All'),
'G' => lang('Primary Group'),
'U' => lang('Accounts'),
) + $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 = array();
$settings['addressbook-home-set'] = array(
'type' => 'multiselect',
'label' => 'Addressbooks to sync in addition to personal addressbook',
'name' => 'addressbook-home-set',
'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"'),
'values' => $addressbooks,
'xmlrpc' => True,
'admin' => False,
);
return $settings;
}
}

View File

@ -1251,4 +1251,43 @@ class calendar_groupdav extends groupdav_handler
}
return $shared;
}
/**
* Return appliction specific settings
*
* return array of array with settings
*/
static function get_settings()
{
if ($hook_data['setup'])
{
$calendars = array();
}
else
{
$user = $GLOBALS['egw_info']['user']['account_id'];
$cal_bo = new calendar_bo();
foreach ($cal_bo->list_cals() as $entry)
{
$calendars[$entry['grantor']] = $entry['name'];
}
unset($calendars[$user]);
}
$calendars = array(
'A' => lang('All'),
'G' => lang('Primary Group'),
) + $calendars;
$settings = array();
$settings['calendar-home-set'] = array(
'type' => 'multiselect',
'label' => 'Calendars to sync in addition to personal calendar',
'name' => 'calendar-home-set',
'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
'values' => $calendars,
'xmlrpc' => True,
'admin' => False,
);
return $settings;
}
}

View File

@ -612,4 +612,35 @@ class infolog_groupdav extends groupdav_handler
return $handler;
}
/**
* Return appliction specific settings
*
* return array of array with settings
*/
static function get_settings()
{
translation::add_app('infolog');
$infolog = new infolog_bo();
if (!($types = $infolog->enums['type']))
{
$types = array(
'task' => 'Tasks',
);
}
$settings = array();
$settings['infolog-types'] = array(
'type' => 'multiselect',
'label' => 'InfoLog types to sync',
'name' => 'infolog-types',
'help' => 'Which InfoLog types should be synced with the device, default only tasks.',
'values' => $types,
'default' => 'task',
'xmlrpc' => True,
'admin' => False,
);
return $settings;
}
}

View File

@ -467,6 +467,16 @@ abstract class groupdav_handler
return array();
}
/**
* Return appliction specific settings
*
* return array of array with settings
*/
static function get_settings()
{
return array();
}
/**
* Add a resource
*

View File

@ -54,91 +54,20 @@ class groupdav_hooks
if ($hook_data['setup'])
{
$addressbooks = array();
$apps = array('addressbook','calendar','infolog');
}
else
{
$user = $GLOBALS['egw_info']['user']['account_id'];
$addressbook_bo = new addressbook_bo();
$addressbooks = $addressbook_bo->get_addressbooks(EGW_ACL_READ);
unset($addressbooks[$user]); // allways synced
unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
$apps = array_keys($GLOBALS['egw_info']['user']['apps']);
}
$addressbooks = array(
'A' => lang('All'),
'G' => lang('Primary Group'),
'U' => lang('Accounts'),
) + $addressbooks;
// rewriting owner=0 to 'U', as 0 get's always selected by prefs
if (!isset($addressbooks[0]))
foreach($apps as $app)
{
unset($addressbooks['U']);
}
else
$class_name = $app.'_groupdav';
if (class_exists($class_name, true))
{
unset($addressbooks[0]);
$settings += call_user_func(array($class_name,'get_settings'));
}
$settings['addressbook-home-set'] = array(
'type' => 'multiselect',
'label' => 'Addressbooks to sync in addition to personal addressbook',
'name' => 'addressbook-home-set',
'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"'),
'values' => $addressbooks,
'xmlrpc' => True,
'admin' => False,
);
if ($hook_data['setup'])
{
$calendars = array();
}
else
{
$user = $GLOBALS['egw_info']['user']['account_id'];
$cal_bo = new calendar_bo();
foreach ($cal_bo->list_cals() as $entry)
{
$calendars[$entry['grantor']] = $entry['name'];
}
unset($calendars[$user]);
}
$calendars = array(
'A' => lang('All'),
'G' => lang('Primary Group'),
) + $calendars;
$settings['calendar-home-set'] = array(
'type' => 'multiselect',
'label' => 'Calendars to sync in addition to personal calendar',
'name' => 'calendar-home-set',
'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
'values' => $calendars,
'xmlrpc' => True,
'admin' => False,
);
translation::add_app('infolog');
$infolog = new infolog_bo();
if (!($types = $infolog->enums['type']))
{
$types = array(
'task' => 'Tasks',
);
}
$settings['infolog-types'] = array(
'type' => 'multiselect',
'label' => 'InfoLog types to sync',
'name' => 'infolog-types',
'help' => 'Which InfoLog types should be synced with the device, default only tasks.',
'values' => $types,
'default' => 'task',
'xmlrpc' => True,
'admin' => False,
);
$settings['debug_level'] = array(
'type' => 'select',