From: Ben Klang Date: Sun, 17 Jul 2005 05:36:36 +0000 (+0000) Subject: User details form populates! X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=65be4cf3d7fc13f497785eb2f33408fa7acd5d82;p=horde.git User details form populates! Various visual bugs fixed. git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@62 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index d0a1d90da..842eef607 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -203,21 +203,37 @@ type"); $extension = $res[$i]['voicemailbox'][0]; $entries[$context][$extension] = array(); - @$entries[$context][$extension]['dialopts'] = - $res[$i]['asteriskuserdialoptions']; + $j = 0; + $entries[$context][$extension]['dialopts'] = array(); + while ($j < @$res[$i]['asteriskuserdialoptions']['count']) { + $entries[$context][$extension]['dialopts'][] = + $res[$i]['asteriskuserdialoptions'][$j]; + $j++; + } - @$entries[$context][$extension]['mailboxopts'] = - $res[$i]['asteriskvoicemailboxoptions']; + $j = 0; + $entries[$context][$extension]['mailboxopts'] = array(); + while ($j < @$res[$i]['asteriskvoicemailboxoptions']['count']) { + $entries[$context][$extension]['mailboxopts'][] = + $res[$i]['asteriskvoicemailboxoptions'][$j]; + $j++; + } - @$entries[$context][$extension]['mailboxpin'] = + $entries[$context][$extension]['mailboxpin'] = $res[$i]['voicemailboxpin'][0]; @$entries[$context][$extension]['name'] = $res[$i]['cn'][0]; - @$entries[$context][$extension]['phonenumbers'] = - $res[$i]['telephonenumber']; + $j = 0; + $entries[$context][$extension]['phonenumbers'] = array(); + while ($j < @$res[$i]['telephonenumber']['count']) { + $entries[$context][$extension]['phonenumbers'][] = + $res[$i]['telephonenumber'][$j]; + $j++; + } + # FIXME Do some sanity checking here. Also set a default? @$entries[$context][$extension]['dialtimeout'] = $res[$i]['asteriskuserdialtimeout'][0]; diff --git a/lib/Shout.php b/lib/Shout.php index 1c976416e..c77182478 100644 --- a/lib/Shout.php +++ b/lib/Shout.php @@ -22,7 +22,7 @@ class Shout */ function getMenu($returnType = 'object') { - global $conf, $context, $section; + global $conf, $context, $section, $action; require_once 'Horde/Menu.php'; @@ -31,11 +31,22 @@ class Shout if (isset($context) && isset($section) && $section == "users" && Shout::checkRights("shout:contexts:$context:users", PERMS_EDIT, 1)) { - $url = Horde::applicationUrl("users/index.php"); + $url = Horde::applicationUrl("users.php"); $url = Util::addParameter($url, array('context' => $context, 'section' => $section, 'action' => 'add')); - $menu->add($url, _("Add User"), "add-user.gif"); + + # 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($url, _("$icontitle User"), "add-user.gif"); } if ($returnType == 'object') { diff --git a/lib/User.php b/lib/User.php index ea2514aa0..27d6d04d5 100644 --- a/lib/User.php +++ b/lib/User.php @@ -1,6 +1,13 @@ + * + * 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 UserDetailsForm extends Horde_Form { @@ -9,12 +16,24 @@ class UserDetailsForm extends Horde_Form { { global $shout; $context = $vars->get("context"); - - parent::Horde_Form($vars, _("Add User - Context: $context")); + $extension = $vars->get("extension"); + + $users = $shout->getUsers($context); + if (array_key_exists($extension, $users)) { + # We must be editing an existing user + $this->fillUserForm(&$vars, $users[$extension]); + $formtitle = "Edit User"; + } else { + $formtitle = "Add User"; + } + + parent::Horde_Form($vars, _("$formtitle - Context: $context")); $users = $shout->getUsers($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(_("Full Name"), 'name', 'text', true); @@ -34,6 +53,50 @@ class UserDetailsForm extends Horde_Form { $this->addVariable(_("Music on Hold while transferring"), 'moh', 'radio', true, false, null, array('values' => array(true => 'Yes', false => 'No'))); + $this->addVariable(_("Allow Call Transfers"), 'transfer', + 'radio', true, false, null, + array('values' => array(true => 'Yes', false => 'No'))); + } + + // {{{ 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, $userdetails) + { + #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; } + // }}} } // }}} \ No newline at end of file diff --git a/shout.webprj b/shout.webprj index 9b650ad4c..92f418811 100644 --- a/shout.webprj +++ b/shout.webprj @@ -9,57 +9,61 @@ - - - - + + + + - + - + - + - - - + + + - + - - - - + + + + - + - + - - + + + + - + - - + + + - + + - + @@ -80,16 +84,16 @@ -//w3c//dtd xhtml 1.0 strict//en - - - + + + - + - - + + - + Ben Klang ben@alkaloid.net Gubed @@ -102,17 +106,20 @@ - + - - + - - - - - - + + + + + + + + + + diff --git a/templates/dialplan/dialplanlist.inc b/templates/dialplan/dialplanlist.inc index d5756cb3c..ed09b0c87 100644 --- a/templates/dialplan/dialplanlist.inc +++ b/templates/dialplan/dialplanlist.inc @@ -41,7 +41,14 @@ } else { echo "Extension $extension"; } - ?> + $editurl = Horde::applicationUrl("dialplan.php"); + $editurl = Util::addParameter($editurl, "context=$context"); + $editurl = Util::addParameter($editurl, "action=edit"); + $editurl = Util::addParameter($editurl, "section=dialplan"); + $editurl = Util::addParameter($editurl, "extension=$extension"); + ?> edit diff --git a/templates/table-limiter-begin.inc b/templates/table-limiter-begin.inc new file mode 100644 index 000000000..91da0375f --- /dev/null +++ b/templates/table-limiter-begin.inc @@ -0,0 +1 @@ + + +
\ No newline at end of file diff --git a/templates/table-limiter-begin.inc~ b/templates/table-limiter-begin.inc~ new file mode 100644 index 000000000..e69de29bb diff --git a/templates/table-limiter-end.inc b/templates/table-limiter-end.inc new file mode 100644 index 000000000..2c0bb586e --- /dev/null +++ b/templates/table-limiter-end.inc @@ -0,0 +1,3 @@ +
\ No newline at end of file diff --git a/templates/table-limiter-end.inc~ b/templates/table-limiter-end.inc~ new file mode 100644 index 000000000..e69de29bb diff --git a/templates/users/userlist.inc b/templates/users/userlist.inc index 9c0939766..bc1a70cd7 100644 --- a/templates/users/userlist.inc +++ b/templates/users/userlist.inc @@ -23,38 +23,22 @@ foreach ($users as $extension => $user) { $rowcolor = $line % 2; $line++; + $url = Horde::applicationUrl("users.php"); + $url = Util::addParameter($url, array('context' => $context, + 'extension' => $extension)); + $editurl = Util::addParameter($url, "action=edit"); + $deleteurl = Util::addParameter($url, "action=delete"); ?> - - + - - +
- - edit -   |   - - delete + edit +  |  + delete
diff --git a/themes/screen.css b/themes/screen.css new file mode 100644 index 000000000..7cb3ae447 --- /dev/null +++ b/themes/screen.css @@ -0,0 +1,9 @@ +.lighthint { + color: #ffffff; + font-size: 10px; +} + +.darkhint { + color: #770000; + font-size: 10px; +} \ No newline at end of file diff --git a/users.php b/users.php index 605c6962c..d746f465b 100644 --- a/users.php +++ b/users.php @@ -1,6 +1,6 @@ * @@ -44,6 +44,9 @@ echo $tabs->render($section); switch ($action) { case "add": + # Treat adds just like an empty edit + unset($extension); + $action = 'edit'; case "edit": case "save": case "delete": diff --git a/users/add.php b/users/add.php deleted file mode 100644 index 2c362b994..000000000 --- a/users/add.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * 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/User.php'; -require_once 'Horde/Variables.php'; - -$RENDERER = &new Horde_Form_Renderer(); - -$empty = ''; -$wereerrors = 0; - -$vars = &Variables::getDefaultVariables($empty); -$formname = $vars->get('formname'); - -$title = _("System Settings"); - -$UserDetailsForm = &Horde_Form::singleton('UserDetailsForm', $vars); -$UserDetailsFormValid = $UserDetailsForm->validate($vars, true); - -$UserDetailsForm->open($RENDERER, $vars, 'users.php', 'post'); -$UserDetailsForm->preserveVarByPost($vars, "section"); -$UserDetailsForm->preserve($vars); -$RENDERER->beginActive($UserDetailsForm->getTitle()); -$RENDERER->renderFormActive($UserDetailsForm, $vars); -$RENDERER->submit(); -$RENDERER->end(); -$UserDetailsForm->close($RENDERER); \ No newline at end of file diff --git a/users/edit.php b/users/edit.php new file mode 100644 index 000000000..5df2c7e44 --- /dev/null +++ b/users/edit.php @@ -0,0 +1,36 @@ + + * + * 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/User.php'; +require_once 'Horde/Variables.php'; + +$RENDERER = &new Horde_Form_Renderer(); + +$empty = ''; +$wereerrors = 0; + +$vars = &Variables::getDefaultVariables($empty); +$formname = $vars->get('formname'); + +$title = _("System Settings"); + +$UserDetailsForm = &Horde_Form::singleton('UserDetailsForm', $vars); +$UserDetailsFormValid = $UserDetailsForm->validate($vars, true); + +$UserDetailsForm->open($RENDERER, $vars, 'users.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