If a resource has accessories, you can't change Accessory of and make it an accessory of something else

This commit is contained in:
Nathan Gray 2013-01-08 17:05:55 +00:00
parent 34b64e7a7b
commit 9279c25b1c

View File

@ -531,6 +531,10 @@ class resources_ui
$content['useable'] = $content['useable'] ? $content['useable'] : 1; $content['useable'] = $content['useable'] ? $content['useable'] : 1;
$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of; $content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of;
if($content['res_id'] && $content['accessory_of'] == -1)
{
$content['acc_count'] = count($this->bo->get_acc_list($content['res_id']));
}
$content['history'] = array( $content['history'] = array(
'id' => $res_id, 'id' => $res_id,
'app' => 'resources', 'app' => 'resources',
@ -567,10 +571,18 @@ class resources_ui
$read_only['delete'] = true; $read_only['delete'] = true;
} }
// Can't make a resource with accessories an accessory
$read_only['accessory_of'] = $content['acc_count'];
if($read_only['accessory_of'])
{
$content['accessory_label'] = lang('Remove accessories before changing Accessory of');
}
// Disable custom tab if there are no custom fields defined // Disable custom tab if there are no custom fields defined
$read_only['tabs']['custom'] = !(config::get_customfields('resources',true)); $read_only['tabs']['custom'] = !(config::get_customfields('resources',true));
$preserv = $content; $preserv = $content;
$this->tmpl->read('resources.edit'); $this->tmpl->read('resources.edit');
return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$read_only,$preserv,2); return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$read_only,$preserv,2);
} }