2010-10-20 01:30:16 +02:00
|
|
|
<?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>
|
2012-01-30 06:11:05 +01:00
|
|
|
* @copyright (c) 2010-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2010-10-20 01:30:16 +02:00
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GroupDAV hooks: eg. preferences
|
|
|
|
*/
|
|
|
|
class groupdav_hooks
|
|
|
|
{
|
2012-02-16 17:35:58 +01:00
|
|
|
public $public_functions = array(
|
|
|
|
'log' => true,
|
|
|
|
);
|
|
|
|
|
2010-10-20 01:30:16 +02:00
|
|
|
/**
|
|
|
|
* Show GroupDAV preferences link in preferences
|
2010-10-31 08:56:29 +01:00
|
|
|
*
|
2010-10-20 01:30:16 +02:00
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-31 08:56:29 +01:00
|
|
|
|
2010-10-20 01:30:16 +02:00
|
|
|
/**
|
|
|
|
* populates $settings for the preferences
|
|
|
|
*
|
|
|
|
* @param array|string $hook_data
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
static function settings($hook_data)
|
|
|
|
{
|
|
|
|
$settings = array();
|
|
|
|
|
|
|
|
if ($hook_data['setup'])
|
|
|
|
{
|
2012-02-04 02:24:34 +01:00
|
|
|
$apps = array('addressbook','calendar','infolog');
|
2010-10-20 01:30:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-04 02:24:34 +01:00
|
|
|
$apps = array_keys($GLOBALS['egw_info']['user']['apps']);
|
2010-10-20 01:30:16 +02:00
|
|
|
}
|
2012-02-04 02:24:34 +01:00
|
|
|
foreach($apps as $app)
|
2012-01-25 04:25:42 +01:00
|
|
|
{
|
2012-02-04 02:24:34 +01:00
|
|
|
$class_name = $app.'_groupdav';
|
|
|
|
if (class_exists($class_name, true))
|
2012-01-25 04:25:42 +01:00
|
|
|
{
|
2012-02-14 18:38:45 +01:00
|
|
|
$settings += call_user_func(array($class_name,'get_settings'), $hook_data);
|
2012-01-25 04:25:42 +01:00
|
|
|
}
|
|
|
|
}
|
2011-09-28 14:35:53 +02:00
|
|
|
|
2012-02-16 17:35:58 +01:00
|
|
|
$settings[] = array(
|
|
|
|
'type' => 'section',
|
2012-02-19 13:39:04 +01:00
|
|
|
'title' => 'Logging / debuging',
|
2012-02-16 17:35:58 +01:00
|
|
|
);
|
2010-10-31 08:56:29 +01:00
|
|
|
$settings['debug_level'] = array(
|
|
|
|
'type' => 'select',
|
2012-02-19 13:39:04 +01:00
|
|
|
'label' => 'Enable logging',
|
2010-10-31 08:56:29 +01:00
|
|
|
'name' => 'debug_level',
|
2012-02-19 13:39:04 +01:00
|
|
|
'help' => 'Enables logging of CalDAV/CardDAV traffic to diagnose problems with devices.',
|
2010-10-31 08:56:29 +01:00
|
|
|
'values' => array(
|
2012-02-16 17:35:58 +01:00
|
|
|
'0' => lang('Off'),
|
2012-02-19 13:39:04 +01:00
|
|
|
'r' => lang('Requests and truncated responses to Apache error-log'),
|
2012-02-16 17:35:58 +01:00
|
|
|
'f' => lang('Requests and full responses to files directory'),
|
2010-10-31 08:56:29 +01:00
|
|
|
),
|
|
|
|
'xmlrpc' => true,
|
|
|
|
'admin' => false,
|
|
|
|
'default' => '0',
|
|
|
|
);
|
2012-02-16 17:35:58 +01:00
|
|
|
if ($GLOBALS['type'] === 'forced' || $GLOBALS['type'] === 'user' &&
|
|
|
|
$GLOBALS['egw_info']['user']['preferences']['groupdav']['debug-log'] !== 'never')
|
|
|
|
{
|
|
|
|
if ($GLOBALS['type'] === 'user')
|
|
|
|
{
|
|
|
|
$logs = array();
|
2012-02-17 09:13:50 +01:00
|
|
|
if (file_exists($log_dir=$GLOBALS['egw_info']['server']['files_dir'].'/groupdav') && ($files = scandir($log_dir)))
|
2012-02-16 17:35:58 +01:00
|
|
|
{
|
|
|
|
$account_lid_len = strlen($GLOBALS['egw_info']['user']['account_lid']);
|
|
|
|
foreach($files as $log)
|
|
|
|
{
|
|
|
|
if (substr($log,0,$account_lid_len+1) == $GLOBALS['egw_info']['user']['account_lid'].'-' &&
|
|
|
|
substr($log,-4) == '.log')
|
|
|
|
{
|
|
|
|
$logs['groupdav/'.$log] = egw_time::to(filemtime($log_dir.'/'.$log)).': '.
|
|
|
|
str_replace('!','/',substr($log,$account_lid_len+1,-4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$link = egw::link('/index.php',array(
|
|
|
|
'menuaction' => 'groupdav.groupdav_hooks.log',
|
|
|
|
'filename' => '',
|
|
|
|
));
|
|
|
|
$onchange = "egw_openWindowCentered('$link'+encodeURIComponent(this.value), '_blank', 1000, 500); this.value=''";
|
|
|
|
}
|
|
|
|
else // allow to force users to NOT be able to delete their profiles
|
|
|
|
{
|
|
|
|
$logs = array('never' => lang('Never'));
|
|
|
|
}
|
|
|
|
$settings['show-log'] = array(
|
|
|
|
'type' => 'select',
|
|
|
|
'label' => 'Show log of following device',
|
|
|
|
'name' => 'show-log',
|
2012-02-19 13:39:04 +01:00
|
|
|
'help' => lang('You need to set enable logging to "%1" to create/update a log.',
|
2012-02-16 17:35:58 +01:00
|
|
|
lang('Requests and full responses to files directory')),
|
|
|
|
'values' => $logs,
|
|
|
|
'xmlrpc' => True,
|
|
|
|
'admin' => False,
|
|
|
|
'onchange' => $onchange,
|
|
|
|
);
|
|
|
|
}
|
2010-10-20 01:30:16 +02:00
|
|
|
return $settings;
|
|
|
|
}
|
2012-02-16 17:35:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open log window for log-file specified in GET parameter filename (relative to files_dir)
|
|
|
|
*
|
|
|
|
* $_GET['filename'] has to be in groupdav sub-dir of files_dir and start with account_lid of current user
|
|
|
|
*
|
|
|
|
* @throws egw_exception_wrong_parameter
|
|
|
|
*/
|
|
|
|
public function log()
|
|
|
|
{
|
|
|
|
$filename = $_GET['filename'];
|
|
|
|
if (!preg_match('|^groupdav/'.preg_quote($GLOBALS['egw_info']['user']['account_lid'],'|').'-[^/]+\.log$|',$filename))
|
|
|
|
{
|
|
|
|
throw new egw_exception_wrong_parameter("Access denied to file '$filename'!");
|
|
|
|
}
|
|
|
|
$GLOBALS['egw_info']['flags']['css'] = '
|
|
|
|
body { background-color: #e0e0e0; }
|
|
|
|
pre.tail { background-color: white; padding-left: 5px; margin-left: 5px; }
|
|
|
|
';
|
|
|
|
$header = str_replace('!','/',substr($filename,10+strlen($GLOBALS['egw_info']['user']['account_lid']),-4));
|
|
|
|
$tail = new egw_tail($filename);
|
|
|
|
$GLOBALS['egw']->framework->render($tail->show($header),false,false);
|
|
|
|
}
|
2010-10-20 01:30:16 +02:00
|
|
|
}
|