diff --git a/admin/inc/class.admin_cmd.inc.php b/admin/inc/class.admin_cmd.inc.php index 0b71f9611a..8a2a1ce5ca 100644 --- a/admin/inc/class.admin_cmd.inc.php +++ b/admin/inc/class.admin_cmd.inc.php @@ -498,6 +498,16 @@ abstract class admin_cmd { $query['col_filter']['remote_id'] = null; } + if ((string)$query['col_filter']['periodic'] === '0') + { + $query['col_filter']['rrule'] = null; + } + else if ((string)$query['col_filter']['periodic'] === '1') + { + $query['col_filter'][] = 'cmd_rrule IS NOT NULL'; + } + unset($query['col_filter']['periodic']); + return admin_cmd::$sql->get_rows($query,$rows,$readonlys); } @@ -1048,15 +1058,17 @@ abstract class admin_cmd // instanciate single periodic execution object $single = $cmd->as_array(); $single['parent'] = $single['id']; - unset($single['id'], $single['uid'], $single['rrule'], $single['created'], $single['modified'], $single['modifier']); + unset($single['id'], $single['uid'], $single['rrule'], $single['created'], $single['modified'], $single['modifier'], $single['async_job_id']); $periodic = admin_cmd::instanciate($single); try { - $periodic->run(null, false); + $value = $periodic->run(null, false); } catch (Exception $ex) { error_log(__METHOD__."(".array2string($data).") periodic execution failed: ".$ex->getMessage()); } + $periodic->value = $value; + $periodic->save(); } /** diff --git a/admin/inc/class.admin_cmds.inc.php b/admin/inc/class.admin_cmds.inc.php index c9eb35056a..7edbb3f037 100644 --- a/admin/inc/class.admin_cmds.inc.php +++ b/admin/inc/class.admin_cmds.inc.php @@ -38,6 +38,7 @@ class admin_cmds if (!$rows) return array(); + $async = new Api\Asyncservice(); foreach($rows as &$row) { try { @@ -47,10 +48,31 @@ class admin_cmds catch (Exception $e) { $row['title'] = $e->getMessage(); } - $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : - json_encode($data+(empty($row['rrule'])?array():array('rrule' => $row['rrule'])), - JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); + if(method_exists($cmd, 'summary')) + { + $row['data'] = $cmd->summary(); + } + else + { + $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : + json_encode($data+(empty($row['rrule'])?array():array('rrule' => $row['rrule'])), + JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); + } + if($row['rrule']) + { + $rrule = calendar_rrule::event2rrule(calendar_rrule::parseRrule($row['rrule'],true)+array( + 'start' => time(), + 'tzid'=> Api\DateTime::$server_timezone->getName() + )); + $row['rrule'] = ''.$rrule; + } + if(!$row['scheduled'] && $cmd && $cmd->async_job_id) + { + $job = $async->read($cmd->async_job_id); + + $row['scheduled'] = $job ? $job[$cmd->async_job_id]['next'] : null; + } if ($row['status'] == admin_cmd::scheduled) { $row['class'] = 'AllowDelete'; @@ -98,7 +120,12 @@ class admin_cmds } unset($cmd); } + $periodic = array( + 0 => 'no', + 1 => 'yes' + ); $tpl->exec('admin.admin_cmds.index',$content,array( + 'periodic' => $periodic, 'status' => admin_cmd::$stati, 'remote_id' => admin_cmd::remote_sites(), ),array(),$content); diff --git a/admin/templates/default/cmds.xet b/admin/templates/default/cmds.xet index 8622c5aaad..c28f825dfc 100644 --- a/admin/templates/default/cmds.xet +++ b/admin/templates/default/cmds.xet @@ -11,6 +11,7 @@ + @@ -20,6 +21,7 @@ + @@ -31,12 +33,14 @@ + +