From e71bbd8abe391582088e9a8c89c0bcd17ad88a29 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 10 May 2019 13:33:04 -0600 Subject: [PATCH] Store requester and comment into command history when importing users --- admin/inc/class.admin_import_users_csv.inc.php | 16 +++++++++++----- .../inc/class.importexport_schedule_ui.inc.php | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/admin/inc/class.admin_import_users_csv.inc.php b/admin/inc/class.admin_import_users_csv.inc.php index 7855cd6c96..35434a869f 100644 --- a/admin/inc/class.admin_import_users_csv.inc.php +++ b/admin/inc/class.admin_import_users_csv.inc.php @@ -118,6 +118,7 @@ class admin_import_users_csv implements importexport_iface_import_plugin { // First method is preferred $import_csv->skip_records(1); } + $admin_cmd = $_definition->plugin_options['admin_cmd']; // Start counting successes $count = 0; @@ -163,11 +164,11 @@ class admin_import_users_csv implements importexport_iface_import_plugin { $action = $condition['true']; foreach ( (array)$accounts as $account ) { $record['account_id'] = $account['account_id']; - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); + $success = $this->action( $action['action'], $record, $import_csv->get_current_position(), $admin_cmd ); } } else { $action = $condition['false']; - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); + $success = ($this->action( $action['action'], $record, $import_csv->get_current_position(), $admin_cmd )); } break; @@ -179,7 +180,7 @@ class admin_import_users_csv implements importexport_iface_import_plugin { } } else { // unconditional insert - $success = $this->action( 'create', $record, $import_csv->get_current_position() ); + $success = $this->action( 'create', $record, $import_csv->get_current_position(), $admin_cmd ); } if($success) $count++; } @@ -193,7 +194,7 @@ class admin_import_users_csv implements importexport_iface_import_plugin { * @param array $_data contact data for the action * @return bool success or not */ - private function action ( $_action, $_data, $record_num = 0 ) { + private function action ( $_action, $_data, $record_num = 0, $admin_cmd ) { switch ($_action) { case 'none' : return true; @@ -202,7 +203,12 @@ class admin_import_users_csv implements importexport_iface_import_plugin { $_data['account_expires'] = $_action == 'disable' ? 'already' : ''; case 'create' : case 'update' : - $command = new admin_cmd_edit_user(($_action=='create'?null:$_data['account_lid']), $_data); + $command = new admin_cmd_edit_user(array( + 'account' => $_action=='create'?null:(int)$_data['account_lid'], + 'set' => $_data + )+(array)$admin_cmd); + + if($this->dry_run) { $this->results[$_action]++; return true; diff --git a/importexport/inc/class.importexport_schedule_ui.inc.php b/importexport/inc/class.importexport_schedule_ui.inc.php index 6e22c26656..cd21cdc7a2 100644 --- a/importexport/inc/class.importexport_schedule_ui.inc.php +++ b/importexport/inc/class.importexport_schedule_ui.inc.php @@ -503,6 +503,10 @@ class importexport_schedule_ui } $definition->plugin_options = array_merge($definition->plugin_options, $selection); } + // Set some automatic admin history data, if the plugin wants it + $definition->plugin_options = array_merge($definition->plugin_options, array('admin_cmd' => array( + 'comment' => lang('schedule import / export') . "\n" . $definition->get_title() . "\n" . $target + ))); foreach($targets as $target) {