diff --git a/include/class.forms.php b/include/class.forms.php index 3b6d129643a8baf1b9d992964b1036df898ab10a..939f1ac55bc78dc7eb547d8a66e0c14df531b3ca 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -702,6 +702,10 @@ class FormField { function isEditable($user=null) { + // Internal editable flag used by internal forms e.g internal lists + if (!$user && isset($this->ht['editable'])) + return $this->ht['editable']; + if ($user instanceof Staff) $flag = DynamicFormField::FLAG_AGENT_EDIT; else @@ -3171,7 +3175,11 @@ class PhoneNumberWidget extends Widget { class ChoicesWidget extends Widget { function render($options=array()) { - $mode = isset($options['mode']) ? $options['mode'] : null; + $mode = null; + if (isset($options['mode'])) + $mode = $options['mode']; + elseif (isset($this->field->options['render_mode'])) + $mode = $this->field->options['render_mode']; if ($mode == 'view') { if (!($val = (string) $this->field)) diff --git a/include/class.list.php b/include/class.list.php index f2b1b1301c028356dfe5db0050676520358c70a6..a60925874bb4dd272d8efbf9d7b79ccb51023d70 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -965,6 +965,7 @@ class TicketStatusList extends CustomListHandler { return array( 'allowreopen' => new BooleanField(array( 'label' =>__('Allow Reopen'), + 'editable' => true, 'default' => isset($source['allowreopen']) ? $source['allowreopen']: true, 'id' => 'allowreopen', @@ -979,6 +980,7 @@ class TicketStatusList extends CustomListHandler { )), 'reopenstatus' => new ChoiceField(array( 'label' => __('Reopen Status'), + 'editable' => true, 'required' => false, 'default' => isset($source['reopenstatus']) ? $source['reopenstatus'] : 0, @@ -1010,8 +1012,10 @@ class TicketStatusList extends CustomListHandler { $extra->setForm($form); $fields->insert(++$k, $extra); } - break; } + + if (!isset($f->ht['editable'])) + $f->ht['editable'] = true; } // Enable selection and display of private states @@ -1253,6 +1257,9 @@ implements CustomListItem, TemplateVariable { function getConfigurationForm($source=null) { if (!$this->_form) { $config = $this->getConfiguration(); + // Forcefully retain state for internal statuses + if ($source && $this->isInternal()) + $source['state'] = $this->getState(); $this->_form = $this->getList()->getConfigurationForm($source); if (!$source && $config) { $fields = $this->_form->getFields(); @@ -1264,6 +1271,13 @@ implements CustomListItem, TemplateVariable { $f->value = $f->get('default'); } } + + if ($this->isInternal() + && ($f=$this->_form->getField('state'))) { + $f->ht['required'] = $f->ht['editable'] = false; + $f->options['render_mode'] = 'view'; + } + } return $this->_form; @@ -1302,10 +1316,10 @@ implements CustomListItem, TemplateVariable { function setConfiguration($vars, &$errors=array()) { $properties = array(); - foreach ($this->getList()->getConfigurationForm($vars)->getFields() as $f) { - if ($this->isInternal() //Item is internal. - && !$f->isEditable()) - continue; + foreach ($this->getConfigurationForm($vars)->getFields() as $f) { + // Only bother with editable fields + if (!$f->isEditable()) continue; + $val = $f->getClean(); $errors = array_merge($errors, $f->errors()); if ($f->errors()) continue; @@ -1326,6 +1340,10 @@ implements CustomListItem, TemplateVariable { } break; case 'state': + // Internal statuses cannot change state + if ($this->isInternal()) + break; + if ($val) $this->set('state', $val); else