Fix import / export available and exported fields

This commit is contained in:
Nathan Gray 2011-04-12 22:23:40 +00:00
parent 64e2ada353
commit 50296c519a
5 changed files with 24 additions and 15 deletions

View File

@ -24,7 +24,7 @@ class admin_egw_user_record implements importexport_iface_egw_record
// Used in conversions
static $types = array(
'date-time' => array('account_lastlogin', 'account_lastpwd_change', 'account_expires'),
'select-account' => array('account_primary_group'),
'select-account' => array('account_primary_group', 'account_groups'),
'select' => array('account_status'),
);
@ -93,6 +93,7 @@ class admin_egw_user_record implements importexport_iface_egw_record
*/
public function set_record(array $_record){
$this->user = $_record;
$this->account_groups = $GLOBALS['egw']->accounts->memberships($this->identifier, true);
}
/**

View File

@ -39,14 +39,16 @@ class admin_export_users_csv implements importexport_iface_export_plugin {
$export_object->set_mapping($options['mapping']);
$lookups = array(
'account_status' => array('A' => lang('Enabled'), '' => lang('Disabled'), 'D' => lang('Disabled')),
'account_status' => array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')),
);
// $_record is an array, that's what search() returns
foreach ($selection as $_record) {
$record = new admin_egw_user_record($_record);
if($options['convert']) {
$never_expires = ($record->account_expires == -1);
importexport_export_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
if($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it
} else {
// Implode arrays, so they don't say 'Array'
foreach($record->get_record_array() as $key => $value) {

View File

@ -120,11 +120,18 @@ class admin_import_users_csv implements importexport_iface_import_plugin {
// Failures
$this->errors = array();
$lookups = array(
'account_status' => array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')),
);
while ( $record = $import_csv->get_record() ) {
$success = false;
// don't import empty records
if( count( array_unique( $record ) ) < 2 ) continue;
if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
if ( $_definition->plugin_options['conditions'] ) {
foreach ( $_definition->plugin_options['conditions'] as $condition ) {
switch ( $condition['type'] ) {

View File

@ -22,14 +22,13 @@ class admin_wizard_export_users_csv extends importexport_wizard_basic_export_csv
'account_firstname' => lang('First Name'),
'account_lastname' => lang('Last Name'),
'account_email' => lang('email'),
'account_passwd' => lang('Password'),
'account_active' => lang('Account active'),
'account_primary_group' => lang('primary Group'),
'account_pwd' => lang('Password'),
'account_status' => lang('Status'),
'account_primary_group' => lang('Primary Group'),
'account_groups' => lang('Groups'),
'account_expires' => lang('Expires'),
'anonymous' => lang('Anonymous User (not shown in list sessions)'),
'changepassword' => lang('Can change password'),
'mustchangepassword' => lang('Must change password upon next login'),
'account_lastlogin' => lang('Last login'),
'account_lastpwd_change'=> lang('Last password change'),
);
// Custom fields - not really used in admin...

View File

@ -31,7 +31,7 @@ class admin_wizard_import_users_csv extends importexport_wizard_basic_import_csv
'account_lastname' => lang('Last Name'),
'account_email' => lang('email'),
'account_passwd' => lang('Password'),
'account_active' => lang('Account active'),
'account_status' => lang('Status'),
'account_primary_group' => lang('primary Group'),
'account_groups' => lang('Groups'),
'account_expires' => lang('Expires'),