diff --git a/admin/inc/class.admin_cmd.inc.php b/admin/inc/class.admin_cmd.inc.php index 80ab1d00d8..955fcba09c 100644 --- a/admin/inc/class.admin_cmd.inc.php +++ b/admin/inc/class.admin_cmd.inc.php @@ -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__)) diff --git a/admin/setup/setup.inc.php b/admin/setup/setup.inc.php old mode 100755 new mode 100644 index b54c5274f2..6c8a9c4b24 --- a/admin/setup/setup.inc.php +++ b/admin/setup/setup.inc.php @@ -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') ); + diff --git a/admin/setup/tables_current.inc.php b/admin/setup/tables_current.inc.php index e1d9f2e0b9..160e6b5002 100644 --- a/admin/setup/tables_current.inc.php +++ b/admin/setup/tables_current.inc.php @@ -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( diff --git a/admin/setup/tables_update.inc.php b/admin/setup/tables_update.inc.php index e72916a6bb..bef08a0b01 100644 --- a/admin/setup/tables_update.inc.php +++ b/admin/setup/tables_update.inc.php @@ -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'; +} +