*/
@define('SHOUT_BASE', dirname(__FILE__));
require_once SHOUT_BASE . '/lib/base.php';
+require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php';
//require_once SHOUT_BASE . '/lib/Shout.php';
$action = Horde_Util::getFormData('action');
$extension = Horde_Util::getFormData('extension');
+$extensions = $shout_extensions->getExtensions($context);
$vars = Horde_Variables::getDefaultVariables();
-$tabs = Shout::getTabs($context, $vars);
+//$tabs = Shout::getTabs($context, $vars);
$RENDERER = new Horde_Form_Renderer();
# Treat adds just like an empty edit
$action = 'edit';
- $extension = 0;
+
case 'edit':
$title .= sprintf(_("Edit Extension %s"), $extension);
- $beendone = 0;
- $wereerrors = 0;
-
$FormName = 'UserDetailsForm';
+ $vars = new Horde_Variables($extensions[$extension]);
$Form = &Horde_Form::singleton($FormName, $vars);
- if (is_a($Form, 'PEAR_Error')) {
- $notification->push($Form);
- } else {
- $FormValid = $Form->validate($vars, true);
- if (is_a($FormValid, 'PEAR_Error')) {
- $notification->push($FormValid);
- } else {
- $Form->fillUserForm($vars, $extension);
- }
- }
+ $Form->open($RENDERER, $vars, 'index.php', 'post');
+ $Form->preserveVarByPost($vars, 'extension');
+ $Form->preserveVarByPost($vars, 'context');
+ $Form->preserveVarByPost($vars, 'section');
- if (!$FormValid || !$Form->isSubmitted()) {
- # Display the form for editing
- $Form->open($RENDERER, $vars, 'index.php', 'post');
- $Form->preserveVarByPost($vars, 'extension');
- $Form->preserveVarByPost($vars, 'context');
- $Form->preserveVarByPost($vars, 'section');
- $RENDERER->beginActive($Form->getTitle());
- $RENDERER->renderFormActive($Form, $vars);
- $RENDERER->submit();
- $RENDERER->end();
- $Form->close($RENDERER);
- } else {
- # Process the Valid and Submitted form
- $notification->push("How did we get HERE?!", 'horde.error');
- }
-
break;
case 'save':
$title .= sprintf(_("Save Extension %s"), $extension);
break;
case 'delete':
$title .= sprintf(_("Delete Extension %s"), $extension);
- $context = Horde_Util::getFormData('context');
$extension = Horde_Util::getFormData('extension');
$res = $shout->deleteUser($context, $extension);
default:
$action = 'list';
$title .= _("List Users");
- $extensions = $shout_extensions->getExtensions($context);
}
require SHOUT_TEMPLATES . '/common-header.inc';
$notification->notify();
-echo $tabs->render($section);
+//echo $tabs->render($section);
require SHOUT_TEMPLATES . '/extensions/' . $action . '.inc';
-require $registry->get('templates', 'horde') . '/common-footer.inc';
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
$entries[$context] = array();
$i = 0;
while ($i < $res['count']) {
- list($extension) = explode('@', $res[$i]['AstVoicemailMailbox'][0]);
- $entries[$context][$extension] = array();
+ list($extension) = explode('@', $res[$i]['astvoicemailmailbox'][0]);
+ $entries[$context][$extension] = array('extension' => $extension);
$j = 0;
$entries[$context][$extension]['mailboxopts'] = array();
/**
* $Id$
*
- * Copyright 2005 Ben Klang <ben@alkaloid.net>
+ * Copyright 2005-2009 Ben Klang <ben@alkaloid.net>
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.php.
// {{{
class UserDetailsForm extends Horde_Form {
- var $_userdetails = false; // Store the user's details for fillUserForm
-
function UserDetailsForm(&$vars)
{
- global $shout, $notification;
+ global $shout_extensions;
$context = $vars->get('context');
- $extension = $vars->get('extension');
-
- $users = &$shout->getUsers($context);
- if (is_a($users, 'PEAR_Error')) {
- $notification->push($users);
- }
- if (array_key_exists($extension, $users)) {
- # We must be editing an existing user
-// $this->fillUserForm(&$vars, $users[$extension]);
- $this->_userdetails = $users[$extension];
- $limits = &$shout->getLimits($context, $extension);
- if (is_a($limits, 'PEAR_Error')) {
- $notification->push($limits);
- }
+ if ($vars->exists('extension')) {
$formtitle = "Edit User";
- $this->addHidden('', 'uid', 'text', true);
+ $extension = $vars->get('extension');
} else {
- $limits = &$shout->getLimits($context);
- if (is_a($limits, 'PEAR_Error')) {
- $notification->push($limits);
- }
$formtitle = "Add User";
}
- parent::Horde_Form($vars, _("$formtitle - Context: $context"));
-
+ parent::__construct($vars, _("$formtitle - Context: $context"));
$this->addHidden('', 'action', 'text', true);
$vars->set('action', 'save');
+ $this->addHidden('', 'extension', 'int', true);
+ $vars->set('newextension', $extension);
$this->addVariable(_("Full Name"), 'name', 'text', true);
$this->addVariable(_("Extension"), 'newextension', 'int', true);
$this->addVariable(_("E-Mail Address"), 'email', 'email', true);
$this->addVariable(_("Pager E-Mail Address"), 'pageremail', 'email', false);
- # TODO: Integrate with To-Be-Written user manager and possibly make this
- # TODO: new user also an email account.
$this->addVariable(_("PIN"), 'mailboxpin', 'int', true);
- # FIXME: Make this work if limits don't exist.
- $t = 1;
- while ($t <= $limits['telephonenumbersmax']) {
- $this->addVariable(_("Telephone Number $t:"), "telephonenumber[$t]",
- 'cellphone', false);
- $t++;
- }
-
- $this->addVariable(_("Music on Hold while transferring"), 'moh',
- 'boolean', true, false);#, _("When checked, a calling user will hear music on hold while the caller is connected"));
- $this->addVariable(_("Allow Call Transfers"), 'transfer',
- 'boolean', true, false);#, _("When checked, the called user will be allowed to transfer the incoming call to other extensions"));
- $this->addVariable(_("Explicit Call Acceptance"), 'eca',
- 'boolean', true, false);#, _("When checked, the called user will be required to press 1 to accept the call. Only turn this off if you really know what you're doing!"));
-// $this->addVariable(_("Call Appearance"), 'callappearance',
-// 'radio', $vars->get('eca'), false, null, array('values' =>
-// array('caller' => 'From Calling Party',
-// 'self' => 'From Self',
-// 'switch' => 'From V-Office',
-// )
-// )
-// );
-
return true;
}
- // {{{ fillUserForm method
- /**
- * Fill in the blanks for the UserDetailsForm
- *
- * @param object Reference to a Variables object to fill in
- *
- * @param array User details
- *
- * @return boolean True if successful, Pear::raiseError object on failure
- */
- function fillUserForm(&$vars)
- {
- #Array ( [dialopts] => Array ( [0] => m [1] => t ) [mailboxopts] => Array (
- #) [mailboxpin] => 1234 [name] => Ricardo Paul [phonenumbers] => Array ( )
- #[dialtimeout] => 30 [email] => ricardo.paul@v-office.biz [pageremail] => )
- if (!$this->_userdetails) {
- return true;
- }
- foreach(array('name', 'email', 'pageremail', 'mailboxpin', 'uid', 'telephonenumber') as $var) {
- # FIXME This will be done the Right Way in Shout 0.7
- $vars->set($var, $this->_userdetails[$var]);
- }
-// $vars->set('name', $this->_userdetails['name']);
-// $vars->set('email', $this->_userdetails['email']);
-// $vars->set('pager', $this->_userdetails['pager']);
-// $vars->set('mailboxpin', $this->_userdetails['mailboxpin']);
-// $vars->set('uid', $this->_userdetails['uid']);
- $vars->set('newextension', $vars->get('extension'));
-
- $vars->set('moh', false);
- $vars->set('eca', false);
- $vars->set('transfer', false);
-// $vars->set('callappearance', 'caller');
-
-
- foreach ($this->_userdetails['dialopts'] as $opt) {
- if ($opt == 'm') {
- $vars->set('moh', true);
- }
- if ($opt == 't') {
- $vars->set('transfer', true);
- }
- if (preg_match('/^e(\(.*\))*/', $opt, $matches)) {
- # This matches 'e' and 'e(ARGS)'
- $vars->set('eca', true);
-// if (count($matches) > 1) {
-// # We must have found an argument
-// switch($matches[1]) {
-// case '(${VOFFICENUM})':
-// $vars->set('callappearance', 'switch');
-// break;
-//
-// case '(${CALLERANI})':
-// $vars->set('callappearance', 'self');
-// break;
-//
-// case '(${CALLERIDNUM})':
-// default:
-// $vars->set('callappearance', 'caller');
-// break;
-//
-// }
-// }
- }
- }
- return true;
- }
- // }}}
-}
-// }}}
+}
\ No newline at end of file
require_once 'Horde/Menu.php';
$menu = new Horde_Menu(HORDE_MENU_MASK_ALL);
- $permprefix = "shout:contexts:$context";
-
- if (isset($context) && $section == "usermgr" &&
- Shout::checkRights("$permprefix:users",
- PERMS_EDIT, 1)) {
- $url = Horde::applicationUrl("index.php");
- $url = Horde_Util::addParameter($url, array('context' => $context,
- 'section' => $section,
- 'action' => 'add'));
-
- # Goofy hack to make the icon make a little more sense
- # when editing/deleting users
-// if (!isset($action)) {
- $icontitle = "Add";
-// } else {
-// $icontitle = $action;
-// $icontitle[0] = strtoupper($action[0]);
-// }
- # End goofy hack
-
- $menu->add($url, _("$icontitle User"), "add-user.gif");
- }
- if (isset($context) && isset($section) && $section == "dialplan" &&
- Shout::checkRights("$permprefix:dialplan",
- PERMS_EDIT, 1)) {
- $url = Horde::applicationUrl("dialplan.php");
- $url = Horde_Util::addParameter($url, array('context' => $context,
- 'section' => $section,
- 'action' => 'add'));
-
- # Goofy hack to make the icon make a little sense
- # when editing/deleting users
- if (!isset($action)) {
- $icontitle = "Add";
- } else {
- $icontitle = $action;
- $icontitle[0] = strtoupper($action[0]);
- }
- # End goofy hack
+ $menu->add(Horde::applicationUrl('extensions.php'), _("Extensions"), "user.png");
+ $menu->add(Horde::applicationUrl('routes.php'), _("Call Paths"));
- $menu->add($url, _("$icontitle Extension"), "add-extension.gif");
- }
if ($returnType == 'object') {
return $menu;
if (Shout::checkRights($permprefix . ':extensions', null, 1)) {
$url = Horde::applicationUrl('extensions.php');
- $url = Horde_Util::addParameter($url, 'context', $context);
- $tabs->addTab(_("_Extensions"), $url, 'usermgr');
+ $tabs->addTab(_("_Extensions"), $url, 'extensions');
}
if (Shout::checkRights($permprefix . ':dialplan', null, 1)) {
$url = Horde::applicationUrl('dialplan.php');
- $url = Horde_Util::addParameter($url, 'context', $context);
$tabs->addTab(_("_Automated Attendant"), $url, 'dialplan');
}
if (Shout::checkRights($permprefix . ':conference', null, 1)) {
$url = Horde::applicationUrl('conference.php');
- $url = Horde_Util::addParameter($url, 'context', $context);
$tabs->addTab(_("_Conference Rooms"), $url, 'conference');
}
if (Shout::checkRights($permprefix . ':moh', null, 1)) {
$url = Horde::applicationUrl('moh.php');
- $url = Horde_Util::addParameter($url, 'context', $context);
$tabs->addTab(_("_Music on Hold"), $url, 'moh');
}
--- /dev/null
+<?php
+$RENDERER->beginActive($Form->getTitle());
+$RENDERER->renderFormActive($Form, $vars);
+$RENDERER->submit();
+$RENDERER->end();
+$Form->close($RENDERER);
\ No newline at end of file
</tr>
<?php
$line = 0;
- foreach ($extensions as $extension => $user) {
- $rowcolor = $line % 2;
- $line++;
- $url = Horde::applicationUrl("index.php");
+ foreach ($extensions as $extension => $info) {
+
+ $url = Horde::applicationUrl("extensions.php");
$url = Horde_Util::addParameter($url,
array(
- 'context' => $context,
'extension' => $extension,
- 'section' => $section,
)
);
- $editurl = Horde_Util::addParameter($url, "action=edit");
- $deleteurl = Horde_Util::addParameter($url, "action=delete");
+ $editurl = Horde_Util::addParameter($url, 'action', 'edit');
+ $deleteurl = Horde_Util::addParameter($url, 'action', 'delete');
?>
- <tr class="item<?php echo $rowcolor; ?>">
+ <tr class="item">
<td style="width: 20%">
<?php echo Horde::link($editurl); echo $extension; ?></a>
</td>
<td style="width: 35%;">
- <?php echo Horde::link($editurl); echo $user['name']; ?></a>
+ <?php echo Horde::link($editurl); echo $info['name']; ?></a>
</td>
<td style="width: 45%">
- <?php echo $user['email']; ?>
+ <?php echo $info['email']; ?>
</td>
</tr>
<?php