From: Ben Klang Date: Sun, 17 Jul 2005 06:25:26 +0000 (+0000) Subject: Too tired to continue...commiting broken code (again...) X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=573dbbe2958b0f78c0e09b1ab79041133cd79e19;p=horde.git Too tired to continue...commiting broken code (again...) Major progress on dialplan editing. Current idea is (when editing an extension in a dialplan) to have a master object (ExtensionDetailsForm) for each extension and one sub object (ExtensionPriorityForm) for each priority. We'll see how that flies. git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@65 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/dialplan.php b/dialplan.php index dc1b5745a..efce48e0d 100644 --- a/dialplan.php +++ b/dialplan.php @@ -37,19 +37,19 @@ if (!isset($context)) {#FIXME || !Shout::checkContext()) { switch ($action) { case "add": - $title = _("Add User"); + $title = _("Add Extension"); # Treat adds just like an empty edit unset($extension); $action = 'edit'; break; case "edit": - $title = _("Edit User (Extension") . "$extension)"; + $title = _("Edit Extension") . "$extension"; break; case "save": - $title = _("Save User (Extension") . "$extension)"; + $title = _("Save Extension") . "$extension"; break; case "delete": - $title = _("Delete User (Extension") . "$extension)"; + $title = _("Delete Extension") . "$extension"; break; default: $url = Horde::applicationUrl('/'); @@ -66,6 +66,6 @@ $tabs = &Shout::getTabs($context, $vars); $tabs->preserve('context', $context); echo $tabs->render($section); -require SHOUT_BASE . "/users/$action.php"; +require SHOUT_BASE . "/dialplan/$action.php"; require $registry->get('templates', 'horde') . '/common-footer.inc'; \ No newline at end of file diff --git a/dialplan/edit.php b/dialplan/edit.php new file mode 100644 index 000000000..662657ed8 --- /dev/null +++ b/dialplan/edit.php @@ -0,0 +1,34 @@ + + * + * See the enclosed file LICENSE for license information (GPL). If you + * did not receive this file, see http://www.horde.org/licenses/gpl.php. + */ +@define('SHOUT_BASE', dirname(__FILE__) . '/..'); +require_once SHOUT_BASE . '/lib/Dialplan.php'; +require_once 'Horde/Variables.php'; + +$RENDERER = &new Horde_Form_Renderer(); + +$empty = ''; +$wereerrors = 0; + +$vars = &Variables::getDefaultVariables($empty); +$formname = $vars->get('formname'); + +$UserDetailsForm = &Horde_Form::singleton('UserDetailsForm', $vars); +$UserDetailsFormValid = $UserDetailsForm->validate($vars, true); + +$UserDetailsForm->open($RENDERER, $vars, 'dialplan.php', 'post'); +$UserDetailsForm->preserveVarByPost($vars, "section"); +$UserDetailsForm->preserve($vars); +require SHOUT_TEMPLATES . '/table-limiter-begin.inc'; +$RENDERER->beginActive($UserDetailsForm->getTitle()); +$RENDERER->renderFormActive($UserDetailsForm, $vars); +$RENDERER->submit(); +$RENDERER->end(); +$UserDetailsForm->close($RENDERER); +require SHOUT_TEMPLATES . '/table-limiter-end.inc'; \ No newline at end of file diff --git a/lib/Dialplan.php b/lib/Dialplan.php new file mode 100644 index 000000000..c61ad7113 --- /dev/null +++ b/lib/Dialplan.php @@ -0,0 +1,106 @@ + + * + * See the enclosed file LICENSE for license information (GPL). If you + * did not receive this file, see http://www.horde.org/licenses/gpl.php. + * + * @package Shout + */ +// {{{ +class ExtensionDetailsForm extends Horde_Form { + + function ExtensionDetailsForm(&$vars) + { + global $shout; + $context = $vars->get("context"); + $extension = $vars->get("extension"); + + $dialplan = $shout->getDialplan($context); + if (array_key_exists($extension, $dialplan['extensions'])) { + $formtitle = "Edit Extension"; + } else { + $formtitle = "Add Extension"; + } + + parent::Horde_Form($vars, _("$formtitle - Context: $context")); + + $this->addHidden('', 'context', 'text', true); + $this->addHidden('', 'oldextension', 'text', true); + $vars->set('oldextension', $extension); + $this->addHidden('', 'action', 'text', true); + $vars->set('action', 'save'); + $this->addVariable(_("Extension"), 'extension', 'text', 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 fillExtensionFormPriority(&$vars, $extensiondetails) + { + #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] => ) + $vars->set('name', $userdetails['name']); + $vars->set('email', @$userdetails['email']); + $vars->set('pin', $userdetails['mailboxpin']); + + $i = 1; + foreach($userdetails['phonenumbers'] as $number) { + $vars->set("telephone$i", $number); + $i++; + } + + if (in_array('m', $userdetails['dialopts'])) { + $vars->set('moh', true); + } else { + $vars->set('moh', false); + } + + if (in_array('t', $userdetails['dialopts'])) { + $vars->set('transfer', true); + } else { + $vars->set('transfer', false); + } + + return true; + } + // }}} +} +// }}} + +class ExtensionPriorityForm extends ExtensionDetailsForm { + + function ExtensionPriorityForm(&$vars) + { + global $shout; + $context = $vars->get("context"); + $extension = $vars->get("extension"); + + $dialplan = $shout->getDialplan($context); + if (array_key_exists($extension, $dialplan['extensions'])) { + $formtitle = "Edit Extension"; + } else { + $formtitle = "Add Extension"; + } + + parent::Horde_Form($vars, _("$formtitle - Context: $context")); + + $this->addHidden('', 'context', 'text', true); + $this->addHidden('', 'oldextension', 'text', true); + $vars->set('oldextension', $extension); + $this->addHidden('', 'action', 'text', true); + $vars->set('action', 'save'); + $this->addVariable(_("Extension"), 'extension', 'text', true); + } +} +// }}} \ No newline at end of file diff --git a/lib/User.php b/lib/User.php index 27d6d04d5..4160beb68 100644 --- a/lib/User.php +++ b/lib/User.php @@ -28,8 +28,6 @@ class UserDetailsForm extends Horde_Form { } parent::Horde_Form($vars, _("$formtitle - Context: $context")); - - $users = $shout->getUsers($context); $this->addHidden('', 'context', 'text', true); $this->addHidden('', 'oldextension', 'text', true); diff --git a/main/dialplan.php b/main/dialplan.php index 3d4f11723..51d9332ef 100644 --- a/main/dialplan.php +++ b/main/dialplan.php @@ -2,5 +2,5 @@ if (!defined(SHOUT_BASE)) { define(SHOUT_BASE, dirname(__FILE__)); } - +$dialplan = $shout->getDialplan($context); require SHOUT_TEMPLATES . "/dialplan/dialplanlist.inc"; \ No newline at end of file diff --git a/main/users.php b/main/users.php index 8b2b6f4c4..45304443d 100644 --- a/main/users.php +++ b/main/users.php @@ -2,5 +2,6 @@ if (!defined(SHOUT_BASE)) { define(SHOUT_BASE, dirname(__FILE__)); } - +$users = $shout->getUsers($context); +ksort($users); require SHOUT_TEMPLATES . "/users/userlist.inc"; \ No newline at end of file diff --git a/shout.webprj b/shout.webprj index d2c1d4f6a..7db6eeb67 100644 --- a/shout.webprj +++ b/shout.webprj @@ -57,6 +57,7 @@ + @@ -123,6 +124,10 @@ + + + + diff --git a/templates/dialplan/dialplanlist.inc b/templates/dialplan/dialplanlist.inc index a8ac3f8a3..8e7f6b69f 100644 --- a/templates/dialplan/dialplanlist.inc +++ b/templates/dialplan/dialplanlist.inc @@ -7,7 +7,6 @@ getDialplan($context); if (isset($dialplan['extensions']) && (count($dialplan['extensions']) > 0)) { foreach ($dialplan['extensions'] as $extension => $priorities) { diff --git a/themes/graphics/add-dialplan.gif b/themes/graphics/add-dialplan.gif deleted file mode 100644 index c343e4b8e..000000000 Binary files a/themes/graphics/add-dialplan.gif and /dev/null differ diff --git a/themes/graphics/add-extension.gif b/themes/graphics/add-extension.gif new file mode 100644 index 000000000..c343e4b8e Binary files /dev/null and b/themes/graphics/add-extension.gif differ diff --git a/users/edit.php b/users/edit.php index 5df2c7e44..35d317244 100644 --- a/users/edit.php +++ b/users/edit.php @@ -19,8 +19,6 @@ $wereerrors = 0; $vars = &Variables::getDefaultVariables($empty); $formname = $vars->get('formname'); -$title = _("System Settings"); - $UserDetailsForm = &Horde_Form::singleton('UserDetailsForm', $vars); $UserDetailsFormValid = $UserDetailsForm->validate($vars, true);