1: <?php
2: 3: 4:
5: class Whups_Form_TicketDetails extends Horde_Form
6: {
7: public $attributes = array();
8:
9: 10:
11: public function __construct(&$vars, &$ticket, $title = '')
12: {
13: parent::__construct($vars, $title);
14:
15: $date_params = array($GLOBALS['prefs']->getValue('date_format'));
16: $fields = array('summary', 'queue', 'version', 'type', 'state',
17: 'priority', 'owner', 'requester', 'created', 'due',
18: 'updated', 'assigned', 'resolved', 'attachments');
19: try {
20: $attributes = $ticket->addAttributes();
21: } catch (Whups_Exception $e) {
22: $attributes = array();
23: }
24:
25: foreach ($attributes as $attribute) {
26: $fields[] = 'attribute_' . $attribute['id'];
27: }
28:
29: $grouped_fields = array($fields);
30: $grouped_hook = false;
31: try {
32: $grouped_fields = Horde::callHook(
33: 'group_fields', array($ticket->get('type'), $fields), 'whups');
34: $grouped_hook = true;
35: } catch (Horde_Exception_HookNotSet $e) {
36: } catch (Horde_Exception $e) {
37: Horde::logMessage($e, 'ERR');
38: }
39:
40: foreach ($grouped_fields as $header => $fields) {
41: if ($grouped_hook) {
42: $this->addVariable($header, null, 'header', false);
43: }
44: foreach ($fields as $field) {
45: switch ($field) {
46: case 'summary':
47: $this->addVariable(_("Summary"), 'summary', 'text', true);
48: break;
49:
50: case 'queue':
51: if ($vars->get('queue_link')) {
52: $this->addVariable(
53: _("Queue"), 'queue_link', 'link', true, false, null,
54: array(
55: array(
56: 'url' => $vars->get('queue_link'),
57: 'text' => $vars->get('queue_name'))));
58: } else {
59: $this->addVariable(
60: _("Queue"), 'queue_name', 'text', true);
61: }
62: break;
63:
64: case 'version':
65: if ($vars->get('version_name')) {
66: if ($vars->get('version_link')) {
67: $this->addVariable(
68: _("Queue Version"), 'version_name', 'link',
69: true, false, null,
70: array(
71: array(
72: 'url' => $vars->get('version_link'),
73: 'text' => $vars->get('version_name'))));
74: } else {
75: $this->addVariable(
76: _("Queue Version"), 'version_name', 'text', true);
77: }
78: }
79: break;
80:
81: case 'type':
82: $this->addVariable(_("Type"), 'type_name', 'text', true);
83: break;
84:
85: case 'state':
86: $this->addVariable(_("State"), 'state_name', 'text', true);
87: break;
88:
89: case 'priority':
90: $this->addVariable(
91: _("Priority"), 'priority_name', 'text', true);
92: break;
93:
94: case 'owner':
95: $owner = &$this->addVariable(
96: _("Owners"), 'user_id_owner', 'email', false, false,
97: null, array(false, true));
98: $owner->setDefault(_("Unassigned"));
99: break;
100:
101: case 'requester':
102: $this->addVariable(
103: _("Requester"), 'user_id_requester', 'email', false,
104: false, null, array(false, true));
105: break;
106:
107: case 'created':
108: $this->addVariable(
109: _("Created"), 'timestamp', 'date', false, false, null,
110: $date_params);
111: break;
112:
113: case 'due':
114: $this->addVariable(
115: _("Due"), 'due', 'datetime', false, false, null,
116: $date_params);
117: break;
118:
119: case 'updated':
120: $this->addVariable(
121: _("Updated"), 'date_updated', 'date', false, false,
122: null, $date_params);
123: break;
124:
125: case 'assigned':
126: $this->addVariable(
127: _("Assigned"), 'date_assigned', 'date', false, false,
128: null, $date_params);
129: break;
130:
131: case 'resolved':
132: $this->addVariable(
133: _("Resolved"), 'date_resolved', 'date', false, false,
134: null, $date_params);
135: break;
136:
137: case 'attachments':
138: $this->addVariable(
139: _("Attachments"), 'attachments', 'html', false);
140: break;
141:
142: default:
143: if (substr($field, 0, 10) == 'attribute_' &&
144: isset($attributes[substr($field, 10)])) {
145: $attribute = $attributes[substr($field, 10)];
146: if (!$attribute['params']) {
147: $attribute['params'] = array();
148: }
149: $this->attributes[$attribute['id']] = $this->addVariable(
150: $attribute['human_name'],
151: 'attribute_' . $attribute['id'],
152: $attribute['type'], $attribute['required'],
153: $attribute['readonly'], $attribute['desc'],
154: $attribute['params']);
155: $this->attributes[$attribute['id']]->setDefault($attribute['value']);
156: }
157: break;
158: }
159: }
160: }
161: }
162:
163: }
164: