adding own columns for admin_cmd attributes app and account and add columns to periodically run (and log) admin_cmds (db schema only so far)

This commit is contained in:
Ralf Becker 2018-08-28 17:06:04 +02:00
parent 73b3354b12
commit 05541e5d9c
4 changed files with 74 additions and 3 deletions

View File

@ -43,6 +43,8 @@ use EGroupware\Api\Acl;
* @property-read string $uid uuid of command (necessary if command is send to a remote system to execute)
* @property int|NULL $remote_id id of remote system, if command is not meant to run on local system
* foreign key into egw_admin_remote (table of remote systems administrated by this one)
* @property-read int $account account_id of user affected by this cmd or NULL
* @property-read string $app app-name affected by this cmd or NULL
*/
abstract class admin_cmd
{
@ -92,6 +94,8 @@ abstract class admin_cmd
protected $uid;
private $type = __CLASS__;
public $remote_id;
protected $account;
protected $app;
/**
* Display name of command, default ucfirst(str_replace(['_cmd_', '_'], ' ', __CLASS__))

3
admin/setup/setup.inc.php Executable file → Normal file
View File

@ -9,7 +9,7 @@
*/
$setup_info['admin']['name'] = 'admin';
$setup_info['admin']['version'] = '17.1';
$setup_info['admin']['version'] = '18.1';
$setup_info['admin']['app_order'] = 1;
$setup_info['admin']['tables'] = array('egw_admin_queue','egw_admin_remote');
$setup_info['admin']['enable'] = 1;
@ -42,3 +42,4 @@ $setup_info['admin']['depends'][] = array(
'appname' => 'api',
'versions' => Array('17.1')
);

View File

@ -32,11 +32,16 @@ $phpgw_baseline = array(
'cmd_requested_email' => array('type' => 'varchar','precision' => '128'),
'cmd_comment' => array('type' => 'varchar','precision' => '255'),
'cmd_data' => array('type' => 'ascii','precision' => '16384'),
'remote_id' => array('type' => 'int','precision' => '4')
'remote_id' => array('type' => 'int','precision' => '4'),
'cmd_app' => array('type' => 'ascii','precision' => '16','comment' => 'affected app'),
'cmd_account' => array('type' => 'int','meta' => 'account','precision' => '4','comment' => 'affected account'),
'cmd_rrule' => array('type' => 'varchar','precision' => '128','comment' => 'rrule for periodic execution'),
'cmd_parent' => array('type' => 'int','precision' => '4','comment' => 'cmd_id of periodic command'),
'cmd_run' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'periodic execution time')
),
'pk' => array('cmd_id'),
'fk' => array(),
'ix' => array('cmd_status','cmd_scheduled'),
'ix' => array('cmd_status','cmd_scheduled','cmd_app','cmd_account','cmd_parent'),
'uc' => array('cmd_uid')
),
'egw_admin_remote' => array(

View File

@ -11,6 +11,8 @@
* @subpackage setup
*/
use EGroupware\Api;
function admin_upgrade1_2()
{
return $GLOBALS['setup_info']['admin']['currentver'] = '1.4';
@ -182,3 +184,62 @@ function admin_upgrade16_1()
{
return $GLOBALS['setup_info']['admin']['currentver'] = '17.1';
}
function admin_upgrade17_1()
{
$GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','cmd_app',array(
'type' => 'ascii',
'precision' => '16',
'comment' => 'affected app'
));
$GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','cmd_account',array(
'type' => 'int',
'meta' => 'account',
'precision' => '4',
'comment' => 'affected account'
));
$GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','cmd_rrule',array(
'type' => 'varchar',
'precision' => '128',
'comment' => 'rrule for periodic execution'
));
$GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','cmd_parent',array(
'type' => 'int',
'precision' => '4',
'comment' => 'cmd_id of periodic command'
));
$GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','cmd_run',array(
'type' => 'int',
'meta' => 'timestamp',
'precision' => '8',
'comment' => 'periodic execution time'
));
// fill cmd_account/app from
foreach($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data',
"cmd_data LIKE '%\"account\":%' OR cmd_data LIKE '%\"app\":%'",
__LINE__, __FILE__, false, '', 'admin') as $row)
{
$data = json_php_unserialize($row['cmd_data']);
if (!empty($data['account']))
{
$row['cmd_account'] = $data['account'];
unset($data['account']);
}
if (!empty($data['app']))
{
$row['cmd_app'] = $data['app'];
unset($data['app']);
}
if (isset($row['cmd_account']) || isset($row['cmd_app']))
{
$cmd_id = $row['cmd_id'];
unset($row['cmd_id']);
$row['cmd_data'] = json_encode($data);
$GLOBALS['egw_setup']->db->update('egw_admin_queue', $row, array('cmd_id' => $cmd_id), __LINE__, __FILE__, 'admin');
}
}
return $GLOBALS['setup_info']['admin']['currentver'] = '18.1';
}