From 7a12eba40997fe626b2b2bda28fcc1027db779c8 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Sat, 28 Jan 2006 23:59:58 +0000 Subject: [PATCH] Adding UID support git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@277 06cd67b6-e706-0410-b29e-9de616bca6e9 --- andrew.session | 74 ++++++++++++++++++++++++++--------------------------- andrew.webprj | 74 ++++++++++++++++++++++++++--------------------------- lib/Driver/ldap.php | 15 ++++++++--- lib/User.php | 4 ++- usermgr/save.php | 3 ++- 5 files changed, 90 insertions(+), 80 deletions(-) diff --git a/andrew.session b/andrew.session index 34c2b8b20..2f88da28e 100644 --- a/andrew.session +++ b/andrew.session @@ -60,63 +60,63 @@ - - - - + + + + - - + + - - + + - - + + - - - + + + - + - - + + - - + + - + - + - - - - + + + + - - - - + + + + - + - - - - + + + + - - - - + + + + diff --git a/andrew.webprj b/andrew.webprj index 6532fc105..84c09849a 100644 --- a/andrew.webprj +++ b/andrew.webprj @@ -4,39 +4,39 @@ -//w3c//dtd xhtml 1.0 strict//en - + - + - - - - - - + + + + + + - + - - - - + + + + - - - - - - + + + + + + - - - - - + + + + + @@ -99,11 +99,11 @@ templates/ toolbars/ - - + + - - + + @@ -126,15 +126,15 @@ - - - - + + + + - - - - - + + + + + diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index 7a7a20c89..98afe2c40 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -282,7 +282,10 @@ type"); $i = 0; while ($i < $res['count']) { $extension = $res[$i]['voicemailbox'][0]; + $uid = md5($res['dn']); + $entries[$context][$uid] = $extension; $entries[$context][$extension] = array(); + $entries[$context][$extension]['uid'] = $uid; $j = 0; $entries[$context][$extension]['dialopts'] = array(); @@ -714,7 +717,7 @@ for $context")); // $domain = $contexts[$context]['domain']; # Check to ensure the extension is unique within this context - $filter = '(&(objectClass=asteriskVoiceMailbox)(context='.$context.'))'; + $filter = "(&(objectClass=asteriskVoiceMailbox)(context=$context))"; $reqattrs = array('dn', $ldapKey); $res = @ldap_search($this->_LDAP, SHOUT_USERS_BRANCH . ',' . $this->_params['basedn'], @@ -743,10 +746,10 @@ for $context")); } $validusers = &$this->getUsers($context); - if (!isset($validusers[$extension])) { + if (!isset($validusers[$userdetails['uid']])) { # Test to see if we're modifying an existing user that has # no telephone system objectClasses and update that object/user - $rdn = "$ldapKey=".$userdetails[$appKey].','; + $rdn = $ldapKey.'='.$userdetails[$appKey].','; $branch = SHOUT_USERS_BRANCH.','.$this->_params['basedn']; # This test is something of a hack. I want a cheap way to check @@ -808,7 +811,7 @@ for $context")); if (is_a($limits, "PEAR_Error")) { return $limits; } - if (count($validusers) >= $limits['asteriskusers']) { + if (count($validusers) >= $limits['asteriskmaxusers']) { return PEAR::raiseError('Maximum number of users reached.'); } @@ -819,6 +822,10 @@ for $context")); } return true; + } elseif (is_a($res, 'PEAR_Error')) { + # Some kind of internal error; not even sure if this is a + # possible outcome or not but I'll play it safe. + return $res; } } diff --git a/lib/User.php b/lib/User.php index 6bf9572a8..91c7f675e 100644 --- a/lib/User.php +++ b/lib/User.php @@ -31,6 +31,7 @@ class UserDetailsForm extends Horde_Form { $notification->push($limits); } $formtitle = "Edit User"; + $this->addHidden('', 'uid', 'text,' true); } else { $limits = &$shout->getLimits($context); if (is_a($limits, 'PEAR_Error')) { @@ -93,8 +94,9 @@ class UserDetailsForm extends Horde_Form { #) [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('email', $userdetails['email']); $vars->set('pin', $userdetails['mailboxpin']); + $vars->set('uid', $userdetails['uid']); $vars->set('newextension', $vars->get('extension')); $i = 1; diff --git a/usermgr/save.php b/usermgr/save.php index 0ea03385c..d91101ba8 100644 --- a/usermgr/save.php +++ b/usermgr/save.php @@ -34,11 +34,13 @@ if (!$FormValid || !$Form->isSubmitted()) { $limits = $shout->getLimits($context, $extension); + # FIXME: Input Validation (Text::??) $userdetails = array( "newextension" => $vars->get('newextension'), "name" => $vars->get('name'), "pin" => $vars->get('pin'), "email" => $vars->get('email'), + "uid" => $vars->get('uid'), ); $i = 1; @@ -62,7 +64,6 @@ if (!$FormValid || !$Form->isSubmitted()) { $userdetails['dialopts'][] = 'e'; } $res = $shout->saveUser($context, $extension, $userdetails); - $res = $shout->saveUser($context, $extension, $userdetails); if (is_a($res, 'PEAR_Error')) { $notification->push($res); } else { -- 2.11.0