mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
* Admin: Add copy account action
This commit is contained in:
parent
65294a3e19
commit
8590939709
@ -10,9 +10,9 @@
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Acl;
|
||||
use EGroupware\Api\Etemplate;
|
||||
use EGroupware\Api\Framework;
|
||||
|
||||
/**
|
||||
* UI for admin: edit/add account
|
||||
@ -28,6 +28,13 @@ class admin_account
|
||||
'delete' => true,
|
||||
);
|
||||
|
||||
// Copying account uses addressbook fields, but we explicitly clear these
|
||||
protected static $copy_clear_fields = array(
|
||||
'account_firstname','account_lastname','account_fullname', 'person_id',
|
||||
'account_id','account_lid',
|
||||
'account_lastlogin','accountlastloginfrom','account_lastpwd_change'
|
||||
);
|
||||
|
||||
/**
|
||||
* Hook to edit account data via "Account" tab in addressbook edit dialog
|
||||
*
|
||||
@ -104,18 +111,24 @@ class admin_account
|
||||
}
|
||||
$readonlys['account_passwd'] = $readonlys['account_passwd2'] = true;
|
||||
}
|
||||
// save old values to only trigger save, if one of the following values change (contact data get saved anyway)
|
||||
$preserve = empty($content['id']) ? array() :
|
||||
array('old_account' => array_intersect_key($account, array_flip(array(
|
||||
'account_lid', 'account_status', 'account_groups', 'anonymous', 'changepassword',
|
||||
'mustchangepassword', 'account_primary_group', 'homedirectory', 'loginshell',
|
||||
'account_expires', 'account_firstname', 'account_lastname', 'account_email'))),
|
||||
'deny_edit' => $deny_edit);
|
||||
|
||||
if($content && $_GET['copy'])
|
||||
{
|
||||
$this->copy($content, $account, $preserve);
|
||||
}
|
||||
return array(
|
||||
'name' => 'admin.account',
|
||||
'prepend' => true,
|
||||
'label' => 'Account',
|
||||
'data' => $account,
|
||||
// save old values to only trigger save, if one of the following values change (contact data get saved anyway)
|
||||
'preserve' => empty($content['id']) ? array() :
|
||||
array('old_account' => array_intersect_key($account, array_flip(array(
|
||||
'account_lid', 'account_status', 'account_groups', 'anonymous', 'changepassword',
|
||||
'mustchangepassword', 'account_primary_group', 'homedirectory', 'loginshell',
|
||||
'account_expires', 'account_firstname', 'account_lastname', 'account_email'))),
|
||||
'deny_edit' => $deny_edit),
|
||||
'preserve' => $preserve,
|
||||
'readonlys' => $readonlys,
|
||||
'pre_save_callback' => $deny_edit ? null : 'admin_account::addressbook_pre_save',
|
||||
);
|
||||
@ -243,6 +256,35 @@ class admin_account
|
||||
}
|
||||
}
|
||||
|
||||
public function copy(array &$content, array &$account, array &$preserve)
|
||||
{
|
||||
// We skipped the addressbook copy, call it now
|
||||
$ab_ui = new addressbook_ui();
|
||||
$ab_ui->copy_contact($content, true);
|
||||
|
||||
// copy_contact() reset the owner, fix it
|
||||
$content['owner'] = '0';
|
||||
|
||||
// Explicitly, always clear these
|
||||
static $clear_content = Array(
|
||||
'n_family','n_given','n_middle','n_suffix','n_fn','n_fileas',
|
||||
'account_id','contact_id','id','etag','carddav_name','uid'
|
||||
);
|
||||
foreach($clear_content as $field)
|
||||
{
|
||||
$account[$field] ='';
|
||||
$preserve[$field] = '';
|
||||
}
|
||||
$account['link_to']['to_id'] = 0;
|
||||
unset($preserve['old_account']);
|
||||
|
||||
// Never copy these on an account
|
||||
foreach(static::$copy_clear_fields as $field)
|
||||
{
|
||||
unset($account[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an account
|
||||
*
|
||||
|
@ -11,10 +11,10 @@
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Egw;
|
||||
use EGroupware\Api\Etemplate;
|
||||
use EGroupware\Api\Etemplate\Widget\Tree;
|
||||
use EGroupware\Api\Link;
|
||||
|
||||
/**
|
||||
* UI for admin
|
||||
@ -154,6 +154,13 @@ class admin_ui
|
||||
'onExecute' => 'javaScript:app.admin.account',
|
||||
'group' => $group,
|
||||
),
|
||||
'copy' => array(
|
||||
'caption' => 'Copy',
|
||||
'url' => 'menuaction=addressbook.addressbook_ui.edit&makecp=1&contact_id=$id',
|
||||
'onExecute' => 'javaScript:app.admin.account',
|
||||
'allowOnMultiple' => false,
|
||||
'icon' => 'copy',
|
||||
),
|
||||
);
|
||||
// generate urls for add/edit accounts via addressbook
|
||||
$edit = Link::get_registry('addressbook', 'edit');
|
||||
|
@ -760,11 +760,17 @@ var AdminApp = /** @class */ (function (_super) {
|
||||
AdminApp.prototype.account = function (_action, _senders) {
|
||||
var params = jQuery.extend({}, this.egw.link_get_registry('addressbook', 'edit'));
|
||||
var popup = this.egw.link_get_registry('addressbook', 'edit_popup');
|
||||
if (_action.id == 'add') {
|
||||
params.owner = '0';
|
||||
}
|
||||
else {
|
||||
params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part
|
||||
switch (_action.id) {
|
||||
case 'add':
|
||||
params.owner = '0';
|
||||
break;
|
||||
case 'copy':
|
||||
params.owner = '0';
|
||||
params.copy = true;
|
||||
// Fall through
|
||||
default:
|
||||
params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part
|
||||
break;
|
||||
}
|
||||
this.egw.open_link(this.egw.link('/index.php', params), 'admin', popup);
|
||||
};
|
||||
@ -1217,4 +1223,3 @@ var AdminApp = /** @class */ (function (_super) {
|
||||
*/
|
||||
));
|
||||
app.classes.admin = AdminApp;
|
||||
//# sourceMappingURL=app.js.map
|
@ -17,7 +17,7 @@ import 'jqueryui';
|
||||
import '../jsapi/egw_global';
|
||||
import '../etemplate/et2_types';
|
||||
|
||||
import { EgwApp } from '../../api/js/jsapi/egw_app';
|
||||
import {EgwApp} from '../../api/js/jsapi/egw_app';
|
||||
|
||||
/**
|
||||
* UI for Admin
|
||||
@ -888,14 +888,20 @@ class AdminApp extends EgwApp
|
||||
var params = jQuery.extend({}, this.egw.link_get_registry('addressbook', 'edit'));
|
||||
var popup = <string>this.egw.link_get_registry('addressbook', 'edit_popup');
|
||||
|
||||
if (_action.id == 'add')
|
||||
switch(_action.id)
|
||||
{
|
||||
params.owner = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part
|
||||
case 'add':
|
||||
params.owner = '0';
|
||||
break;
|
||||
case 'copy':
|
||||
params.owner = '0';
|
||||
params.copy = true;
|
||||
// Fall through
|
||||
default:
|
||||
params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part
|
||||
break;
|
||||
}
|
||||
|
||||
this.egw.open_link(this.egw.link('/index.php', params), 'admin', popup);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user