1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17:
18: class Whups_Form_Ticket_CreateStepThree extends Horde_Form
19: {
20: public function __construct(&$vars)
21: {
22: global $whups_driver, $conf;
23:
24: parent::__construct($vars, _("Create Ticket - Step 3"));
25:
26: $states = $whups_driver->getStates($vars->get('type'), 'unconfirmed');
27: $attributes = $whups_driver->getAttributesForType($vars->get('type'));
28:
29: $queue = $vars->get('queue');
30: $info = $whups_driver->getQueue($queue);
31:
32: if ($GLOBALS['registry']->getAuth()) {
33: $states2 = $whups_driver->getStates(
34: $vars->get('type'), array('new', 'assigned'));
35: if (is_array($states2)) {
36: $states = $states + $states2;
37: }
38: }
39:
40: if (Whups::hasPermission($queue, 'queue', 'requester')) {
41: $test = $this->addVariable(
42: _("The Requester's Email Address"), 'user_email',
43: 'whups:whupsemail', false);
44: } elseif (!$GLOBALS['registry']->getAuth()) {
45: $this->addVariable(
46: _("Your Email Address"), 'user_email', 'email', true);
47: if (!empty($conf['guests']['captcha'])) {
48: $this->addVariable(
49: _("Spam protection"), 'captcha', 'figlet', true, null, null,
50: array(
51: Whups::getCAPTCHA(!$this->isSubmitted()),
52: $conf['guests']['figlet_font']));
53: }
54: }
55:
56:
57: if (count($states) == 1) {
58: $vars->set('state', reset(array_keys($states)));
59: $f_state = &$this->addHidden(
60: _("Ticket State"), 'state', 'enum', true, false, null, array($states));
61: } else {
62: $f_state = &$this->addVariable(
63: _("Ticket State"), 'state', 'enum', true, false, null, array($states));
64: $f_state->setDefault(
65: $whups_driver->getDefaultState($vars->get('type')));
66: }
67:
68: $f_priority = &$this->addVariable(
69: _("Priority"), 'priority', 'enum', true, false, null,
70: array($whups_driver->getPriorities($vars->get('type'))));
71: $f_priority->setDefault(
72: $whups_driver->getDefaultPriority($vars->get('type')));
73: $this->addVariable(_("Due Date"), 'due', 'datetime', false, false);
74: $this->addVariable(_("Summary"), 'summary', 'text', true, false);
75: $this->addVariable(_("Attachment"), 'newattachment', 'file', false);
76: $this->addVariable(_("Description"), 'comment', 'longtext', true);
77: foreach ($attributes as $attribute_id => $attribute_value) {
78: $this->addVariable(
79: $attribute_value['human_name'],
80: 'attributes[' . $attribute_id . ']',
81: $attribute_value['type'],
82: $attribute_value['required'],
83: $attribute_value['readonly'],
84: $attribute_value['desc'],
85: $attribute_value['params']);
86: }
87:
88:
89: $groups = $GLOBALS['injector']->getInstance('Horde_Group');
90: $mygroups = $groups->listGroups($GLOBALS['registry']->getAuth());
91: if ($mygroups) {
92: $mygroups = array(0 => _("This comment is visible to everyone")) + $mygroups;
93: $v = $this->addVariable(
94: _("Make this comment visible only to members of a group?"), 'group',
95: 'enum', false, false, null, array($mygroups));
96: $v->setDefault(0);
97: }
98: }
99:
100: public function validate(&$vars, $canAutoFill = false)
101: {
102: global $conf;
103:
104: if (!parent::validate($vars, $canAutoFill)) {
105: if (!$GLOBALS['registry']->getAuth() && !empty($conf['guests']['captcha'])) {
106: $vars->remove('captcha');
107: $this->removeVariable($varname = 'captcha');
108: $this->insertVariableBefore(
109: 'state', _("Spam protection"), 'captcha', 'figlet', true,
110: null, null,
111: array(Whups::getCAPTCHA(true),
112: $conf['guests']['figlet_font']));
113: }
114: return false;
115: }
116:
117: return true;
118: }
119:
120: }