1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Vilma_Form_EditUser extends Horde_Form
12: {
13: public function __construct($vars)
14: {
15: $type = $vars->get('type');
16: $editing = $vars->get('mode') == 'edit';
17: switch ($type) {
18: case 'group':
19: $title = sprintf(_("Edit Group for \"%s\""), $vars->get('domain'));
20: $name = _("Group Name");
21: break;
22: case 'forward':
23: $title = sprintf(_("Edit Forward for \"%s\""), $vars->get('domain'));
24: $name = _("Forward Name");
25: break;
26: default:
27: $title = sprintf(_("Edit User for \"%s\""), $vars->get('domain'));
28: $name = _("User Name");
29: break;
30: }
31: if (!$editing) {
32: $title = sprintf(_("New User @%s"), $vars->get('domain'));
33: }
34: parent::Horde_Form($vars, $title);
35:
36:
37: $this->setButtons(true, true);
38: $this->addHidden('', 'address', 'text', false);
39: $this->addHidden('', 'mode', 'text', false);
40: $this->addHidden('', 'domain', 'text', false);
41: $this->addHidden('', 'id', 'text', false);
42: if ($editing) {
43: $this->addHidden('', 'user_name', 'text', false);
44: }
45: $this->addVariable($name, 'user_name', 'text', true, $editing, _("Name must begin with an alphanumeric character, must contain only alphanumeric and '._-' characters, and must end with an alphanumeric character."), array('~^[a-zA-Z0-9]{1,1}[a-zA-Z0-9._-]*[a-zA-Z0-9]$~'));
46: if ($editing) {
47: $this->addVariable(_("Password"), 'password', 'passwordconfirm', false, false, _("Only enter a password if you wish to change this user's password"));
48: } else {
49: $this->addVariable(_("Password"), 'password', 'passwordconfirm', true);
50: }
51: $this->addVariable(_("Full Name"), 'user_full_name', 'text', true);
52: $attrs = $GLOBALS['vilma']->driver->getUserFormAttributes();
53: foreach ($attrs as $attr) {
54: $v = $this->addVariable($attr['label'], $attr['name'],
55: $attr['type'], $attr['required'],
56: $attr['readonly'], $attr['description'],
57: $attr['params']);
58: if (isset($attr['default'])) {
59: $v->setDefault($attr['default']);
60: }
61: }
62: }
63: }
64: