From: Ben Klang Date: Sat, 28 Jan 2006 21:21:06 +0000 (+0000) Subject: Clarifying variable names X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=cf20f88c1f65acdd314032862f680b86a2d4c217;p=horde.git Clarifying variable names Restoring "broken" parts from half-assed congregation integration Getting save user form to work (ALMOST!) Other bugfixes git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@275 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/andrew.session b/andrew.session index e0931a7a3..34c2b8b20 100644 --- a/andrew.session +++ b/andrew.session @@ -60,63 +60,63 @@ - - - - + + + + - - + + - - + + - - + + - - - + + + - + - - + + - - + + - + - + - - - - + + + + - - - - + + + + - + - - - - + + + + - - - - + + + + diff --git a/andrew.webprj b/andrew.webprj index 565bef8e0..6532fc105 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/index.php b/index.php index 7daac1891..d4f94e5fa 100644 --- a/index.php +++ b/index.php @@ -11,16 +11,6 @@ */ @define('SHOUT_BASE', dirname(__FILE__)); -$shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php') && - @is_readable(SHOUT_BASE . '/config/defines.php'));# && - #@is_readable(SHOUT_BASE . '/config/prefs.php')); -if (!$shout_configured) { - require SHOUT_BASE . '/../lib/Test.php'; - Horde_Test::configFilesMissing('Shout', SHOUT_BASE, - array('conf.php', 'defines.php')); - #, 'prefs.php')); -} - require_once SHOUT_BASE . '/lib/base.php'; require_once SHOUT_BASE . '/lib/Shout.php'; diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index ba69261b0..7a7a20c89 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -35,6 +35,43 @@ class Shout_Driver_ldap extends Shout_Driver { parent::Shout_Driver($params); $this->_connect(); + + /* These next lines will translate between indexes used in the + * application and LDAP. The rationale is that translation here will + * help make Congregation more driver-independant. The keys used to + * contruct user arrays should be more appropriate to human-legibility + * (name instead of 'cn' and email instead of 'mail'). This translation + * is only needed because LDAP indexes users based on an arbitrary + * attribute and the application indexes by extension/context. In my + * environment users are indexed by their 'mail' attribute and others + * may index based on 'cn' or 'uid'. Any time a new $prefs['uid'] needs + * to be supported, this function should be checked and possibly + * extended to handle that translation. + */ + switch($this->_params['uid']) { + case 'cn': + $this->_ldapKey = 'cn'; + $this->_appKey = 'name'; + break; + case 'mail': + $this->_ldapKey = 'mail'; + $this->_appKey = 'email'; + break; + case 'uid': + # FIXME Probably a better app key to map here + # There is no value that maps uid to LDAP so we can choose to use + # either extension or name, or anything really. I want to + # support it since it's a very common DN attribute. + # Since it's entirely administrator's preference, I'll + # set it to name for now + $this->_ldapKey = 'uid'; + $this->_appKey = 'name'; + break; + case 'voiceMailbox': + $this->_ldapKey = 'voiceMailbox'; + $this->_appKey = 'extension'; + break; + } } // }}} @@ -155,16 +192,16 @@ class Shout_Driver_ldap extends Shout_Driver function checkContextType($context, $type) { switch ($type) { case "users": - $searchfilter = "(objectClass=vofficeCustomer)"; + $searchfilter = '(objectClass='.SHOUT_CONTEXT_VOICEMAIL_OBJECTCLASS.')'; break; case "dialplan": - $searchfilter = "(objectClass=asteriskExtensions)"; + $searchfilter = '(objectClass='.SHOUT_CONTEXT_EXTENSIONS_OBJECTCLASS.')'; break; case "moh": - $searchfilter="(objectClass=asteriskMusicOnHold)"; + $searchfilter='(objectClass='.SHOUT_CONTEXT_MOH_OBJECTCLASS.')'; break; case "conference": - $searchfilter="(objectClass=asteriskMeetMe)"; + $searchfilter='(objectClass='.SHOUT_CONTEXT_CONFERENCE_OBJECTCLASS.')'; break; case "all": default: @@ -674,7 +711,7 @@ for $context")); $appKey = &$this->_appKey; $contexts = &$this->getContexts(); - $domain = $contexts[$context]['domain']; +// $domain = $contexts[$context]['domain']; # Check to ensure the extension is unique within this context $filter = '(&(objectClass=asteriskVoiceMailbox)(context='.$context.'))'; @@ -692,18 +729,6 @@ for $context")); return PEAR::raiseError('Duplicate extension found. Not saving changes.'); } - $validusers = &$this->getUsers($context); - $userId = $validusers[$extension][$appKey]; - - $registry = &Registry::singleton(); - require_once $registry->applicationFilePath('%application%/lib/defines.php', 'congregation'); - $userModes = $registry->callByPackage('congregation', 'getUserModes', - array($domain, $userId)); - # FIXME Handle error here - - $registry->callByPackage('congregation', 'saveUser', - array($domain, $userId, $userModes | CONGREGATION_USER_PHONE, )); - $entry = array( 'cn' => $userdetails['name'], 'mail' => $userdetails['email'], @@ -784,7 +809,6 @@ for $context")); return $limits; } if (count($validusers) >= $limits['asteriskusers']) { - print count($validusers).$limits['asteriskusers']; return PEAR::raiseError('Maximum number of users reached.'); } diff --git a/lib/User.php b/lib/User.php index 2b7f48310..6bf9572a8 100644 --- a/lib/User.php +++ b/lib/User.php @@ -17,16 +17,16 @@ class UserDetailsForm extends Horde_Form { { global $shout, $notification; $context = $vars->get('context'); - $curexten = $vars->get('curexten'); + $extension = $vars->get('extension'); $users = &$shout->getUsers($context); if (is_a($users, 'PEAR_Error')) { $notification->push($users); } - if (array_key_exists($curexten, $users)) { + if (array_key_exists($extension, $users)) { # We must be editing an existing user - $this->fillUserForm(&$vars, $users[$curexten]); - $limits = &$shout->getLimits($context, $curexten); + $this->fillUserForm(&$vars, $users[$extension]); + $limits = &$shout->getLimits($context, $extension); if (is_a($limits, 'PEAR_Error')) { $notification->push($limits); } @@ -44,18 +44,18 @@ class UserDetailsForm extends Horde_Form { $this->addHidden('', 'action', 'text', true); $vars->set('action', 'save'); $this->addVariable(_("Full Name"), 'name', 'text', true); - $this->addVariable(_("Extension"), 'newexten', 'int', true); - $this->addVariable(_("E-Mail Address"), 'email', 'text', true); - $this->addVariable(_("Pager E-Mail Address"), 'pageremail', 'text', false); + $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"), 'pin', 'int', true); + # FIXME: Make this work if limits don't exist. $t = 1; while ($t <= $limits['telephonenumbersmax']) { $this->addVariable(_("Telephone Number $t:"), "telephone$t", -'text', - false); + 'cellphone', false); $t++; } @@ -95,7 +95,7 @@ class UserDetailsForm extends Horde_Form { $vars->set('name', $userdetails['name']); $vars->set('email', @$userdetails['email']); $vars->set('pin', $userdetails['mailboxpin']); - $vars->set('newexten', $vars->get('curexten')); + $vars->set('newextension', $vars->get('extension')); $i = 1; foreach($userdetails['phonenumbers'] as $number) { diff --git a/lib/api.php b/lib/api.php index cfba48bb6..7df8fe28a 100644 --- a/lib/api.php +++ b/lib/api.php @@ -34,7 +34,7 @@ function _shout_perms() $perms['tree']['shout']['superadmin'] = false; $perms['title']['shout:superadmin'] = _("Super Administrator"); -// $contexts = $shout->getContexts(); + $contexts = $GLOBALS['shout']->getContexts(); $perms['tree']['shout']['contexts'] = false; $perms['title']['shout:contexts'] = _("Contexts"); diff --git a/lib/base.php b/lib/base.php index acb58c62e..2918ecdae 100644 --- a/lib/base.php +++ b/lib/base.php @@ -7,7 +7,7 @@ * This file brings in all of the dependencies that every Shout * script will need and sets up objects that all scripts use. */ - + // Check for a prior definition of HORDE_BASE (perhaps by an // auto_prepend_file definition for site customization). @@ -33,12 +33,15 @@ $conf = &$GLOBALS['conf']; @define('SHOUT_BASE', dirname(__FILE__) . '/..'); // Ensure Shout is properly configured before use -$shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php') /* && - * @is_readable(SHOUT_BASE . '/config/prefs.php') */); +$shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php') && + @is_readable(SHOUT_BASE . '/config/defines.php') && + @is_readable(SHOUT_BASE . '/config/applist.xml'));# && + #@is_readable(SHOUT_BASE . '/config/prefs.php')); if (!$shout_configured) { require SHOUT_BASE . '/../lib/Test.php'; Horde_Test::configFilesMissing('Shout', SHOUT_BASE, - array('conf.php' /*, 'prefs.php' */)); + array('conf.php', 'defines.php', 'applist.xml')); + #, 'prefs.php')); } // Notification system. @@ -61,7 +64,6 @@ require_once SHOUT_BASE . '/lib/Driver.php'; require_once 'Horde/UI/Tabs.php'; $GLOBALS['shout'] = &Shout_Driver::singleton(); -// $shout = $GLOBALS['shout']; // Horde libraries. require_once 'Horde/Help.php'; \ No newline at end of file diff --git a/templates/users/userlist.inc b/templates/users/userlist.inc index 67c671813..79881f522 100644 --- a/templates/users/userlist.inc +++ b/templates/users/userlist.inc @@ -18,7 +18,7 @@ $url = Util::addParameter($url, array( 'context' => $context, - 'curexten' => $extension, + 'extension' => $extension, 'section' => 'users', ) ); diff --git a/usermgr/edit.php b/usermgr/edit.php index 988d9b29b..7f56f956a 100644 --- a/usermgr/edit.php +++ b/usermgr/edit.php @@ -55,13 +55,13 @@ $notification->notify(); // $Form->getInfo($vars, $info); // // $name = $info['name']; -// $curextension = $info['curextension']; +// $extension = $info['extension']; // $newextension = $info['newextension']; // $email = $info['email']; // $pin = $info['pin']; // // -// $limits = $shout->getLimits($context, $curextension); +// $limits = $shout->getLimits($context, $extension); // // $userdetails = array("newextension" => $newextension, // "name" => $name, diff --git a/usermgr/save.php b/usermgr/save.php index bcc379a80..0ea03385c 100644 --- a/usermgr/save.php +++ b/usermgr/save.php @@ -30,25 +30,21 @@ if (!$FormValid || !$Form->isSubmitted()) { require SHOUT_BASE . '/usermgr/edit.php'; } else { # Form is Valid and Submitted - $name = $vars->get('name'); - $curexten = $vars->get('curexten'); - $newexten = $vars->get('newexten'); - $email = $vars->get('email'); - $pin = $vars->get('pin'); + $extension = $vars->get('extension'); + $limits = $shout->getLimits($context, $extension); - $limits = $shout->getLimits($context, $curexten); - - $userdetails = array("newexten" => $newexten, - "name" => $name, - "pin" => $pin, - "email" => $email); + $userdetails = array( + "newextension" => $vars->get('newextension'), + "name" => $vars->get('name'), + "pin" => $vars->get('pin'), + "email" => $vars->get('email'), + ); $i = 1; $userdetails['telephonenumbers'] = array(); while ($i <= $limits['telephonenumbersmax']) { $tmp = $vars->get("telephone$i"); - $notification->push('Number: '.$tmp, 'horde.warning'); if (!empty($tmp)) { $userdetails['telephonenumbers'][] = $tmp; } @@ -65,10 +61,14 @@ if (!$FormValid || !$Form->isSubmitted()) { if ($vars->get('eca')) { $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 { + $notification->push('User information updated.', 'horde.success'); + } $notification->notify(); - print_r($userdetails); + + require SHOUT_BASE . '/usermgr/edit.php'; } -// $res = $shout->saveUser($context, $curexten, $userdetails); -// if (is_a($res, 'PEAR_Error')) { -// $notification->push($res); -// } \ No newline at end of file