Fix missing infolog custom types

This commit is contained in:
Nathan Gray 2014-11-19 21:15:48 +00:00
parent 3ec33534dc
commit 4da6635a51
2 changed files with 41 additions and 21 deletions

View File

@ -113,7 +113,7 @@ class customfields
$this->content_types = (array)egw_link::get_registry($this->appname,'default_types');
}
// Set this now, we need to know it for updates
$this->content_type = $content['content_types']['types'];
$this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : (array_key_exists(0,$this->content_types) ? $this->content_types[0] : key($this->content_types));
// Common type changes - add, delete
if($content['content_types']['delete'])
@ -122,7 +122,11 @@ class customfields
}
elseif($content['content_types']['create'])
{
$content['content_types']['types'] = $this->create_content_type($content);
if($new_type = $this->create_content_type($content))
{
$content['content_types']['types'] = $this->content_type = $new_type;
}
unset($content['content_types']['create']);
unset($content['content_types']['name']);
}
// No common type change and type didn't change, try an update
@ -181,7 +185,6 @@ class customfields
$content['type_template'] = $this->appname . '.admin.types';
$content['content_types']['appname'] = $this->appname;
$content_types = array_keys($this->content_types);
$this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : $content_types[0];
$content['content_type_options'] = $this->content_types[$this->content_type]['options'];
$content['content_type_options']['type'] = $this->types2[$this->content_type];
@ -535,6 +538,12 @@ class customfields
}
}
/**
* Validate and create a new content type
*
* @param array $content
* @return string|boolean New type ID, or false for error
*/
function create_content_type(&$content)
{
$new_name = trim($content['content_types']['name']);

View File

@ -71,6 +71,11 @@ class infolog_customfields extends customfields
}
$readonlys['content_type_options']['status']["create$name"] = True;
}
$content['content_type_options']['status'][++$n] = array(
'name' => '',
'label' => '',
'disabled' => False
);
$content['content_type_options']['status']['default'] = $this->status['defaults'][$this->content_type];
$content['content_type_options']['group_owner'] = $this->group_owners[$this->content_type];
$readonlys['content_types']['delete'] = isset($this->bo->stock_enums['type'][$this->content_type]);
@ -250,18 +255,25 @@ class infolog_customfields extends customfields
$this->save_repository();
}
function create(&$content)
function create_content_type(&$content)
{
$new_name = trim($content['new_name']);
unset($content['new_name']);
if (empty($new_name) || isset($this->content_types[$new_name]))
$new_name = trim($content['content_types']['name']);
if (empty($new_name))
{
$content['error_msg'] .= empty($new_name) ?
lang('You have to enter a name, to create a new typ!!!') :
lang("Typ '%1' already exists !!!",$new_name);
$this->tmpl->set_validation_error('content_types[name]','You have to enter a name, to create a new type!!!');
return false;
}
else
{
foreach($this->content_types as $letter => $name)
{
if($name == $new_name)
{
$this->tmpl->set_validation_error('content_types[name]',lang("type '%1' already exists !!!",$new_name));
return false;
}
}
}
$this->content_types[$new_name] = $new_name;
$this->status[$new_name] = array(
'ongoing' => 'ongoing',
@ -271,10 +283,9 @@ class infolog_customfields extends customfields
// save changes to repository
$this->save_repository();
return $new_name;
}
$content['type2'] = $new_name; // show the new entry
}
}
function save_repository()
{
// save changes to repository