R34994 - /trunk/importexport/inc/class.importexport_definitions_ui.inc.php

Author: nathangray
New Revision: 34994

URL: http://www.egroupware.org/viewvc/egroupware?rev=34994&view=rev
Log:
If user chooses a name already in use, give a nice message with some alternate suggestions

Modified:
trunk/importexport/inc/class.importexport_definitions_ui.inc.php

Modified: trunk/importexport/inc/class.importexport_definitions_ui.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/importexport/inc/class.importexport_definitions_ui.inc.php?rev=34994&r1=34993&r2=34994&view=diff

— trunk/importexport/inc/class.importexport_definitions_ui.inc.php (original)
+++ trunk/importexport/inc/class.importexport_definitions_ui.inc.php Tue May 24 17:33:00 2011
@@ -445,8 +445,42 @@
{
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
    
  •   if ($content['step'] == 'wizard_step21')
    
  •   if ($content['step'] == 'wizard_step21' && !$duplicate)
      {
      	switch (array_search('pressed', $content['button']))
      	{
    

@@ -463,8 +497,9 @@
// init step21
else
{

  •   	$content['msg'] = $this->steps['wizard_step21'];
    
  •   	$content['msg'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : '');
      	$content['step'] = 'wizard_step21';
    
  •   	unset($content['duplicate_error']);
      	$preserv = $content;
      	unset ($preserv['button']);
      	return 'importexport.wizard_choosename';
    

vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1


eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs