1<?php
2/**
3 * This file contains all Horde_Form classes to create a new ticket.
4 *
5 * Copyright 2001-2002 Robert E. Coyle <robertecoyle@hotmail.com>
6 * Copyright 2001-2017 Horde LLC (http://www.horde.org/)
7 *
8 * See the enclosed file LICENSE for license information (BSD). If you
9 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
10 *
11 * @author  Robert E. Coyle <robertecoyle@hotmail.com>
12 * @package Whups
13 */
14
15/**
16 * @package Whups
17 */
18class Whups_Form_Ticket_CreateStepFour extends Horde_Form
19{
20    public function __construct(&$vars)
21    {
22        global $whups_driver, $conf;
23
24        parent::__construct($vars, _("Create Ticket - Step 4"));
25
26        /* Preserve previously uploaded attachments. */
27        $this->addHidden('', 'deferred_attachment', 'text', false);
28
29        /* Groups. */
30        $mygroups = $GLOBALS['injector']
31            ->getInstance('Horde_Group')
32            ->listAll($conf['prefs']['assign_all_groups']
33                      ? null
34                      : $GLOBALS['registry']->getAuth());
35        asort($mygroups);
36
37        $users = $whups_driver->getQueueUsers($vars->get('queue'));
38        $f_users = array();
39        foreach ($users as $user) {
40            $f_users['user:' . $user] = Whups::formatUser($user);
41        }
42
43        $f_groups = array();
44        if (count($mygroups)) {
45            foreach ($mygroups as $id => $group) {
46                $f_groups['group:' . $id] = $group;
47            }
48        }
49
50        if (count($f_users)) {
51            asort($f_users);
52            $owners = $this->addVariable(_("Owners"), 'owners', 'multienum',
53                                          false, false, null, array($f_users));
54        }
55
56        if (count($f_groups)) {
57            asort($f_groups);
58            $group_owners = $this->addVariable(_("Group Owners"),
59                                                'group_owners', 'multienum',
60                                                false, false, null,
61                                                array($f_groups));
62        }
63
64        if (!count($f_users) && !count($f_groups)) {
65            $owner_params = array(
66                _("There are no users to which this ticket can be assigned."));
67            $this->addVariable(_("Owners"), 'owners', 'invalid', false, false,
68                               null, $owner_params);
69        }
70    }
71
72}