From 3011a4c4f03f9669ee8625098cb512839b39330e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 1 Jun 2010 14:29:33 -0600 Subject: [PATCH] Move convertUsername() from horde/Auth to horde/Core --- folks/account/resetpassword.php | 2 +- folks/lib/Folks.php | 2 +- folks/lib/Friends.php | 2 +- folks/perms.php | 4 ++-- framework/Auth/lib/Horde/Auth.php | 19 ------------------- framework/Auth/package.xml | 2 -- framework/Core/lib/Horde/Registry.php | 19 +++++++++++++++++++ horde/services/portal/index.php | 2 +- horde/services/shares/edit.php | 4 ++-- horde/templates/shares/edit.inc | 14 +++++++------- kronolith/lib/Ajax/Application.php | 2 +- kronolith/lib/Kronolith.php | 8 ++++---- kronolith/templates/panel.inc | 2 +- kronolith/templates/perms/perms.inc | 12 ++++++------ nag/templates/panel.inc | 2 +- skoli/templates/panel.inc | 2 +- 16 files changed, 48 insertions(+), 50 deletions(-) diff --git a/folks/account/resetpassword.php b/folks/account/resetpassword.php index 764dfce82..aa7a3607c 100644 --- a/folks/account/resetpassword.php +++ b/folks/account/resetpassword.php @@ -50,7 +50,7 @@ $form->setButtons(_("Continue")); // Get user security pass $user = Horde_Util::getFormData('username'); if ($user) { - $u_prefs = Horde_Prefs::singleton($conf['prefs']['driver'], 'horde', Horde_Auth::convertUsername($user, true), '', null, false); + $u_prefs = Horde_Prefs::singleton($conf['prefs']['driver'], 'horde', $registry->convertUsername($user, true), '', null, false); $u_prefs->retrieve(); $answer = $u_prefs->getValue('security_answer'); $question = $u_prefs->getValue('security_question'); diff --git a/folks/lib/Folks.php b/folks/lib/Folks.php index c2adba31b..7d727ab9c 100644 --- a/folks/lib/Folks.php +++ b/folks/lib/Folks.php @@ -260,7 +260,7 @@ class Folks { static public function getUserEmail($user) { // We should always realy on registration data - // $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'horde', Horde_Auth::convertUsername($user, true), '', null, false); + // $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'horde', $registry->convertUsername($user, true), '', null, false); // $prefs->retrieve(); // $email = $prefs->getValue('alternate_email') ? $prefs->getValue('alternate_email') : $prefs->getValue('from_addr'); diff --git a/folks/lib/Friends.php b/folks/lib/Friends.php index 9657e4ad2..f217eca1f 100644 --- a/folks/lib/Friends.php +++ b/folks/lib/Friends.php @@ -143,7 +143,7 @@ class Folks_Friends { return (boolean)$GLOBALS['prefs']->getValue('friends_approval'); } - $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'folks', Horde_Auth::convertUsername($user, true), '', null, false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'folks', $registry->convertUsername($user, true), '', null, false); $prefs->retrieve(); return (boolean)$prefs->getValue('friends_approval'); diff --git a/folks/perms.php b/folks/perms.php index 4a7ba0d96..4bc2a9076 100644 --- a/folks/perms.php +++ b/folks/perms.php @@ -50,7 +50,7 @@ case 'editform': // Process owner and owner permissions. $old_owner = $share->get('owner'); - $new_owner = Horde_Auth::convertUsername(Horde_Util::getFormData('owner', $old_owner), true); + $new_owner = $registry->convertUsername(Horde_Util::getFormData('owner', $old_owner), true); if ($old_owner !== $new_owner && !empty($new_owner)) { if ($old_owner != Horde_Auth::getAuth() && !$registry->isAdmin()) { $notification->push(_("Only the owner or system administrator may change ownership or owner permissions for a share"), 'horde.error'); @@ -135,7 +135,7 @@ case 'editform': foreach ($u_names as $key => $user) { // Apply backend hooks - $user = Horde_Auth::convertUsername($user, true); + $user = $registry->convertUsername($user, true); // If the user is empty, or we've already set permissions // via the owner_ options, don't do anything here. if (empty($user) || $user == $new_owner) { diff --git a/framework/Auth/lib/Horde/Auth.php b/framework/Auth/lib/Horde/Auth.php index 13e927400..57214f4a2 100644 --- a/framework/Auth/lib/Horde/Auth.php +++ b/framework/Auth/lib/Horde/Auth.php @@ -612,25 +612,6 @@ class Horde_Auth } /** - * Converts an authentication username to a unique Horde username. - * - * @param string $username The username to convert. - * @param boolean $toHorde If true, convert to a Horde username. If - * false, convert to the auth username. - * - * @return string The converted username. - * @throws Horde_Exception - */ - static public function convertUsername($userId, $toHorde) - { - try { - return Horde::callHook('authusername', array($userId, $toHorde)); - } catch (Horde_Exception_HookNotSet $e) { - return $userId; - } - } - - /** * Runs the pre/post-authenticate hook and parses the result. * * @param string $userId The userId who has been authorized. diff --git a/framework/Auth/package.xml b/framework/Auth/package.xml index 6bd59ddb0..e587514f3 100644 --- a/framework/Auth/package.xml +++ b/framework/Auth/package.xml @@ -32,8 +32,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> LGPL * Removed Krb5 driver. * Moved signup code to horde/Core. - * Replaced Horde_Auth::addHook() and Horde_Auth::removeHook() with - Horde_Auth::convertUsername(). * Add ability to retrieve app-specific credentials via Horde_Auth::getCredential(). * Add Horde_Auth::getOriginalAuth(). diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index ea7e83939..9687267f8 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -1784,4 +1784,23 @@ class Horde_Registry return Horde::getServiceLink('login', 'horde')->add($params)->setRaw(true); } + /** + * Converts an authentication username to a unique Horde username. + * + * @param string $username The username to convert. + * @param boolean $toHorde If true, convert to a Horde username. If + * false, convert to the auth username. + * + * @return string The converted username. + * @throws Horde_Exception + */ + public function convertUsername($userId, $toHorde) + { + try { + return Horde::callHook('authusername', array($userId, $toHorde)); + } catch (Horde_Exception_HookNotSet $e) { + return $userId; + } + } + } diff --git a/horde/services/portal/index.php b/horde/services/portal/index.php index 1d52252b6..81395b73f 100644 --- a/horde/services/portal/index.php +++ b/horde/services/portal/index.php @@ -15,7 +15,7 @@ Horde_Registry::appInit('horde'); $identity = $injector->getInstance('Horde_Prefs_Identity')->getIdentity(); $fullname = $identity->getValue('fullname'); if (empty($fullname)) { - $fullname = Horde_Auth::convertUsername(Horde_Auth::getAuth(), false); + $fullname = $registry->convertUsername(Horde_Auth::getAuth(), false); } // Get refresh interval. diff --git a/horde/services/shares/edit.php b/horde/services/shares/edit.php index e3b91333a..7a96b054f 100644 --- a/horde/services/shares/edit.php +++ b/horde/services/shares/edit.php @@ -82,7 +82,7 @@ case 'editform': // Process owner and owner permissions. $old_owner = $share->get('owner'); $new_owner_backend = Horde_Util::getFormData('owner_select', Horde_Util::getFormData('owner_input', $old_owner)); - $new_owner = Horde_Auth::convertUsername($new_owner_backend, true); + $new_owner = $registry->convertUsername($new_owner_backend, true); if ($old_owner !== $new_owner && !empty($new_owner)) { if ($old_owner != Horde_Auth::getAuth() && !$registry->isAdmin()) { $notification->push(_("Only the owner or system administrator may change ownership or owner permissions for a share"), 'horde.error'); @@ -172,7 +172,7 @@ case 'editform': foreach ($u_names as $key => $user_backend) { // Apply backend hooks - $user = Horde_Auth::convertUsername($user_backend, true); + $user = $registry->convertUsername($user_backend, true); // If the user is empty, or we've already set permissions // via the owner_ options, don't do anything here. if (empty($user) || $user == $new_owner) { diff --git a/horde/templates/shares/edit.inc b/horde/templates/shares/edit.inc index 772b14bb9..19aa853d5 100644 --- a/horde/templates/shares/edit.inc +++ b/horde/templates/shares/edit.inc @@ -38,14 +38,14 @@ if (isset($userperms[$owner])) { - + @@ -174,7 +174,7 @@ if (isset($userperms[$owner])) { $uperm) { if ($user != $owner) { - $user = Horde_Auth::convertUsername($user, false); + $user = $registry->convertUsername($user, false); ?> @@ -206,8 +206,8 @@ foreach ($userperms as $user => $uperm) { convertUsername($user, true)]) && + $user != $registry->convertUsername($owner, false)) { ?> diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index 20e342aea..1065f96c3 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -717,7 +717,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base $calendar = $GLOBALS['all_calendars'][$this->_vars->cal]; $tagger = Kronolith::getTagger(); $result->calendar = array( - 'name' => (!$calendar->get('owner') ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ') . $calendar->get('name'), + 'name' => (!$calendar->get('owner') ? '' : '[' . $GLOBALS['registry']->convertUsername($calendar->get('owner'), false) . '] ') . $calendar->get('name'), 'desc' => $calendar->get('desc'), 'owner' => false, 'fg' => Kronolith::foregroundColor($calendar), diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 81559fc0b..157f20a9a 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -255,7 +255,7 @@ class Kronolith $calendar->get('owner') == Horde_Auth::getAuth(); if (($my && $owner) || (!$my && !$owner)) { $code['conf']['calendars']['internal'][$id] = array( - 'name' => ($owner || !$calendar->get('owner') ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ') + 'name' => ($owner || !$calendar->get('owner') ? '' : '[' . $GLOBALS['registry']->convertUsername($calendar->get('owner'), false) . '] ') . $calendar->get('name'), 'desc' => $calendar->get('desc'), 'owner' => $owner, @@ -284,7 +284,7 @@ class Kronolith $tasklist->get('owner') == Horde_Auth::getAuth(); if (($my && $owner) || (!$my && !$owner)) { $code['conf']['calendars']['tasklists']['tasks/' . $id] = array( - 'name' => ($owner || !$tasklist->get('owner') ? '' : '[' . Horde_Auth::convertUsername($tasklist->get('owner'), false) . '] ') + 'name' => ($owner || !$tasklist->get('owner') ? '' : '[' . $GLOBALS['registry']->convertUsername($tasklist->get('owner'), false) . '] ') . $tasklist->get('name'), 'desc' => $tasklist->get('desc'), 'owner' => $owner, @@ -1611,7 +1611,7 @@ class Kronolith // Process owner and owner permissions. $old_owner = $share->get('owner'); $new_owner_backend = Horde_Util::getFormData('owner_select', Horde_Util::getFormData('owner_input', $old_owner)); - $new_owner = Horde_Auth::convertUsername($new_owner_backend, true); + $new_owner = $GLOBALS['registry']->convertUsername($new_owner_backend, true); if ($old_owner !== $new_owner && !empty($new_owner)) { if ($old_owner != Horde_Auth::getAuth() && !$GLOBALS['registry']->isAdmin()) { $errors[] = _("Only the owner or system administrator may change ownership or owner permissions for a share"); @@ -1740,7 +1740,7 @@ class Kronolith $perm->removeUserPermission(null, null, false); foreach ($u_names as $key => $user_backend) { // Apply backend hooks - $user = Horde_Auth::convertUsername($user_backend, true); + $user = $GLOBALS['registry']->convertUsername($user_backend, true); // If the user is empty, or we've already set permissions // via the owner_ options, don't do anything here. if (empty($user) || $user == $new_owner) { diff --git a/kronolith/templates/panel.inc b/kronolith/templates/panel.inc index 4023f297f..39420fe83 100644 --- a/kronolith/templates/panel.inc +++ b/kronolith/templates/panel.inc @@ -127,7 +127,7 @@ $ta->attach();

diff --git a/kronolith/templates/perms/perms.inc b/kronolith/templates/perms/perms.inc index ffc7ea47e..a2ea972d7 100644 --- a/kronolith/templates/perms/perms.inc +++ b/kronolith/templates/perms/perms.inc @@ -28,14 +28,14 @@ - + @@ -183,7 +183,7 @@ $uperm) { if ($user != $owner) { - $user = Horde_Auth::convertUsername($user, false); + $user = $registry->convertUsername($user, false); ?> @@ -220,8 +220,8 @@ foreach ($userperms as $user => $uperm) { convertUsername($user, true)]) && + $user != $registry->convertUsername($owner, false)) { ?> diff --git a/nag/templates/panel.inc b/nag/templates/panel.inc index 1b430b753..399dd141d 100644 --- a/nag/templates/panel.inc +++ b/nag/templates/panel.inc @@ -85,7 +85,7 @@ document.observe('dom:loaded', function() {

diff --git a/skoli/templates/panel.inc b/skoli/templates/panel.inc index ead9ed579..31133b9d6 100644 --- a/skoli/templates/panel.inc +++ b/skoli/templates/panel.inc @@ -62,7 +62,7 @@ function sbarToggle()

-- 2.11.0