1: <?php
2: 3: 4:
5: class extends Horde_Form
6: {
7:
8: public function __construct(&$vars, $title = '')
9: {
10: global $conf;
11:
12: parent::__construct($vars, $title);
13:
14: $this->addHidden('', 'id', 'int', true, true);
15:
16: if (!$GLOBALS['registry']->getAuth()) {
17: $this->addVariable(_("Your Email Address"), 'user_email', 'email', true);
18: if (!empty($conf['guests']['captcha'])) {
19: $this->addVariable(
20: _("Spam protection"),
21: 'captcha',
22: 'figlet',
23: true,
24: null,
25: null,
26: array(Whups::getCAPTCHA(!$this->isSubmitted()),
27: $conf['guests']['figlet_font']));
28: }
29: }
30: $this->addVariable(_("Comment"), 'newcomment', 'longtext', false);
31: $this->addVariable(_("Attachment"), 'newattachment', 'file', false);
32: $this->addVariable(_("Watch this ticket"), 'add_watch', 'boolean', false);
33:
34:
35: if ($GLOBALS['registry']->isAdmin(array('permission' => 'whups:admin')) ||
36: $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('whups:hiddenComments', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
37: $groups = $GLOBALS['injector']->getInstance('Horde_Group');
38: $mygroups = $groups->listGroups($GLOBALS['registry']->getAuth());
39: if ($mygroups) {
40: foreach (array_keys($mygroups) as $gid) {
41: $grouplist[$gid] = $groups->getName($gid, true);
42: }
43: asort($grouplist);
44: $grouplist = array_merge(array(0 => _("This comment is visible to everyone")), $grouplist);
45: $this->addVariable(_("Make this comment visible only to members of a group?"), 'group', 'enum', true, false, null, array($grouplist));
46: }
47: }
48: }
49:
50: public function validate(&$vars, $canAutoFill = false)
51: {
52: global $conf;
53:
54: if (!parent::validate($vars, $canAutoFill)) {
55: if (!$GLOBALS['registry']->getAuth() && !empty($conf['guests']['captcha'])) {
56: $vars->remove('captcha');
57: $this->removeVariable($varname = 'captcha');
58: $this->insertVariableBefore('newcomment', _("Spam protection"), 'captcha', 'figlet', true, null, null, array(Whups::getCAPTCHA(true), $conf['guests']['figlet_font']));
59: }
60: return false;
61: }
62:
63: return true;
64: }
65:
66: }
67: