name = $name; $field->type = MTrackConfig::get('ticket.custom', "$name.type"); $field->label = MTrackConfig::get('ticket.custom', "$name.label"); $field->group = MTrackConfig::get('ticket.custom', "$name.group"); $field->order = (int)MTrackConfig::get('ticket.custom', "$name.order"); $field->default = MTrackConfig::get('ticket.custom', "$name.default"); $field->options = MTrackConfig::get('ticket.custom', "$name.options"); return $field; } function save() { if (!preg_match("/^x_[a-z_]+$/", $this->name)) { throw new Exception("invalid field name $this->name"); } $name = $this->name; MTrackConfig::set('ticket.custom', "$name.type", $this->type); MTrackConfig::set('ticket.custom', "$name.label", $this->label); MTrackConfig::set('ticket.custom', "$name.group", $this->group); MTrackConfig::set('ticket.custom', "$name.order", (int)$this->order); MTrackConfig::set('ticket.custom', "$name.default", $this->default); MTrackConfig::set('ticket.custom', "$name.options", $this->options); } function ticketData() { /* compatible with the $FIELDSET data used in web/ticket.php */ $data = array( 'label' => $this->label, 'type' => $this->type, ); if (strlen($this->default)) { $data['default'] = $this->default; } switch ($this->type) { case 'multi': case 'wiki': case 'shortwiki': $data['ownrow'] = true; $data['rows'] = 5; $data['cols'] = 78; break; case 'select': case 'multiselect': $options = array('' => ' --- '); foreach (explode('|', $this->options) as $opt) { $options[$opt] = $opt; } $data['options'] = $options; break; } return $data; } }