*
* Class to admin cron-job like timed calls of eGroupWare methods *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* http://www.egroupware.org/ *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
class uiasyncservice
{
var $public_functions = array(
'index' => True,
);
function index()
{
if ($GLOBALS['egw']->acl->check('asyncservice_access',1,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Asynchronous timed services');
$GLOBALS['egw']->js->validate_file('jscode','openwindow','admin');
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
$async = $GLOBALS['egw']->asyncservice; // use an own instance, as we might set debug=True
$async->debug = !!$_POST['debug'];
$units = array(
'year' => lang('Year'),
'month' => lang('Month'),
'day' => lang('Day'),
'dow' => lang('Day of week
(0-6, 0=Sun)'),
'hour' => lang('Hour
(0-23)'),
'min' => lang('Minute')
);
if ($_POST['send'] || $_POST['test'] || $_POST['cancel'] || $_POST['install'] || $_POST['deinstall'] || $_POST['update'] || isset($_POST['asyncservice']))
{
$times = array();
foreach($units as $u => $ulabel)
{
if ($_POST[$u] !== '')
{
$times[$u] = $_POST[$u];
}
}
if ($_POST['test'])
{
if (!$async->set_timer($times,'test','admin.uiasyncservice.test',$GLOBALS['egw_info']['user']['email']))
{
echo '
'.lang("Error setting timer, wrong syntax or maybe there's one already running !!!")."
\n"; } } if ($_POST['cancel']) { if (!$async->cancel_timer('test')) { echo ''.lang("Error canceling timer, maybe there's none set !!!")."
\n"; } } if ($_POST['install'] || $_POST['deinstall']) { if (!($install = $async->install($_POST['install'] ? $times : False))) { echo ''.lang('Error: %1 not found or other error !!!',$async->crontab)."
\n"; } $_POST['asyncservice'] = $_POST['deinstall'] ? 'fallback' : 'crontab'; } } else { $times = array('min' => '*/5'); // set some default } echo '