1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: class ExtensionDetailsForm extends Horde_Form {
14:
15: 16: 17: 18: 19: 20: 21:
22: function __construct(&$vars)
23: {
24: $action = $vars->get('action');
25: if ($action == 'edit') {
26: $formtitle = "Edit User";
27: } else {
28: $formtitle = "Add User";
29: }
30:
31: $accountname = $GLOBALS['session']->get('shout', 'curaccount_name');
32: $title = sprintf(_("$formtitle - Account: %s"), $accountname);
33: parent::__construct($vars, $title);
34:
35:
36: $extension = $vars->get('extension');
37:
38: $this->addHidden('', 'action', 'text', true);
39: $this->addHidden('', 'oldextension', 'text', false);
40: $this->addVariable(_("Full Name"), 'name', 'text', true);
41: $this->addVariable(_("Extension"), 'extension', 'int', true);
42: $this->addVariable(_("E-Mail Address"), 'email', 'email', true);
43:
44: $this->addVariable(_("PIN"), 'mailboxpin', 'int', true);
45:
46: return true;
47: }
48:
49: 50: 51: 52: 53: 54:
55: function execute()
56: {
57: $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
58:
59: $extension = $this->_vars->get('extension');
60: $account = $this->_vars->get('account');
61:
62:
63: $details = array(
64: 'name' => $this->_vars->get('name'),
65: 'oldextension' => $this->_vars->get('oldextension'),
66: 'email' => $this->_vars->get('email'),
67:
68: 'mailboxpin' => $this->_vars->get('mailboxpin'),
69: );
70:
71: $shout->extensions->saveExtension($account, $extension, $details);
72: }
73:
74: }
75:
76: class ExtensionDeleteForm extends Horde_Form
77: {
78: function __construct(&$vars)
79: {
80: $extension = $vars->get('extension');
81: $account = $vars->get('account');
82:
83: $title = _("Delete Extension %s - Account: %s");
84: $title = sprintf($title, $extension, $GLOBALS['session']->get('shout', 'curaccount_name'));
85: parent::__construct($vars, $title);
86:
87: $this->addHidden('', 'account', 'text', true);
88: $this->addHidden('', 'extension', 'int', true);
89: $this->addHidden('', 'action', 'text', true);
90: $this->setButtons(array(_("Delete"), _("Cancel")));
91: }
92:
93: function execute()
94: {
95: $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
96: $account = $this->_vars->get('account');
97: $extension = $this->_vars->get('extension');
98: $shout->extensions->deleteExtension($account, $extension);
99: }
100: }
101: