mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
If user chooses a name already in use, give a nice message with some alternate suggestions
This commit is contained in:
parent
6e26b80c1e
commit
7f06d6af00
@ -445,8 +445,42 @@ class importexport_definitions_ui
|
|||||||
{
|
{
|
||||||
if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true));
|
if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true));
|
||||||
|
|
||||||
|
// Check for duplicate name
|
||||||
|
$duplicate = isset($content['duplicate_error']);
|
||||||
|
if($content['name'] && !$duplicate)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$check_definition = new importexport_definition($content['name']);
|
||||||
|
if($check_definition && $check_definition->definition_id != $content['definition_id'])
|
||||||
|
{
|
||||||
|
throw new Exception('Already exists');
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// throw new Exception('Already exists');
|
||||||
|
$content['duplicate_error'] = lang('Duplicate name, please choose another.');
|
||||||
|
|
||||||
|
// Try some suggestions
|
||||||
|
$suggestions = array(
|
||||||
|
$content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'],
|
||||||
|
$content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'],
|
||||||
|
$content['name'] .'-'. egw_time::to('now', true),
|
||||||
|
//$content['name'] .'-'. rand(0,100),
|
||||||
|
);
|
||||||
|
foreach($suggestions as $key => $suggestion) {
|
||||||
|
$sug_definition = new importexport_definition($suggestion);
|
||||||
|
if($sug_definition->definition_id) {
|
||||||
|
unset($suggestions[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($suggestions) {
|
||||||
|
$content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions);
|
||||||
|
}
|
||||||
|
return $this->get_step($content['step'],0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// return from step21
|
// return from step21
|
||||||
if ($content['step'] == 'wizard_step21')
|
if ($content['step'] == 'wizard_step21' && !$duplicate)
|
||||||
{
|
{
|
||||||
switch (array_search('pressed', $content['button']))
|
switch (array_search('pressed', $content['button']))
|
||||||
{
|
{
|
||||||
@ -463,8 +497,9 @@ class importexport_definitions_ui
|
|||||||
// init step21
|
// init step21
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$content['msg'] = $this->steps['wizard_step21'];
|
$content['msg'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : '');
|
||||||
$content['step'] = 'wizard_step21';
|
$content['step'] = 'wizard_step21';
|
||||||
|
unset($content['duplicate_error']);
|
||||||
$preserv = $content;
|
$preserv = $content;
|
||||||
unset ($preserv['button']);
|
unset ($preserv['button']);
|
||||||
return 'importexport.wizard_choosename';
|
return 'importexport.wizard_choosename';
|
||||||
|
Loading…
Reference in New Issue
Block a user