[dev] Fullname hook suggestion
Atif Ghaffar
aghaffar@developer.ch
Wed, 05 Jun 2002 18:49:24 +0200
This is a multi-part message in MIME format.
---------------------- multipart/mixed attachment
Jan Schneider wrote:
> I'm not quite sure what you changed, a patch would be great to see if this
> should go to the main tree.
Hi Jan,
attached it the patch.
best regards
--
Atif Ghaffar
---------------------------.
+41 78 845 31 64 ¦ tel
aghaffar@developer.ch ¦ email
http://atifghaffar.com ¦ www
8206786 ¦ icq
---------------------- multipart/mixed attachment
Index: login.php
===================================================================
RCS file: /repository/horde/login.php,v
retrieving revision 2.77
diff -u -3 -p -r2.77 login.php
--- login.php 23 Apr 2002 09:28:06 -0000 2.77
+++ login.php 5 Jun 2002 16:47:35 -0000
@@ -74,7 +74,12 @@ if (Auth::getAuth()) {
$refresh_url = Horde::applicationUrl('login.php');
}
include_once HORDE_BASE . '/lib/Menu.php';
- $fullname = ucfirst(Auth::getAuth());
+ if (!empty($conf['hooks']['fullname']) && function_exists($conf['hooks']['fullname'])) {
+ $fullname = call_user_func($conf['hooks']['fullname'], Auth::getAuth());
+ } else {
+ $fullname = ucfirst(Auth::getAuth());
+ }
+
$template = 'user.inc';
$columns = array();
foreach ($registry->applications as $app => $info) {
Index: config/horde.php.dist
===================================================================
RCS file: /repository/horde/config/horde.php.dist,v
retrieving revision 1.67
diff -u -3 -p -r1.67 horde.php.dist
--- config/horde.php.dist 24 May 2002 21:11:05 -0000 1.67
+++ config/horde.php.dist 5 Jun 2002 16:47:35 -0000
@@ -261,3 +261,52 @@ $conf['menu']['images'] = true;
// Should we redirect to the Horde frameset after login?
$conf['menu']['display'] = true;
+
+// A hook to get user's fullname
+// this can be used by all horde apps
+// simply copying the example from imp/conf/conf.php.dist
+// changing function name from imp_set_full_name to horde_set_fullname
+// changing paramter recieved from $imp to $user
+
+// If this is set to a function name, that function will be used
+// to get the user's fullname to use when sending mail. See
+// the 'imp_set_fullname' function below for an example.
+$conf['hooks']['fullname'] = '';
+
+/* Here is an example imp_set_fullname function to set the fullname
+ * from the GECOS information in the passwd file.
+ */
+//if (!function_exists('horde_set_fullname')) {
+// function imp_set_fullname ($user) {
+// $array = posix_getpwnam($user);
+// $gecos_array = explode(',', $array['gecos']);
+// return (empty($gecos_array) ? $imp['user'] : $gecos_array[0]);
+// }
+//}
+
+/* This is another example how to get the user's full name from an ldap server.
+ * In this example we look if a Spanish name exists and return this or the
+ * standard 'cn' entry if not.
+ */
+// if (!function_exists('imp_set_fullname')) {
+// function imp_set_fullname($imp) {
+// $ldapServer = 'ldap.example.com';
+// $ldapPort = '389';
+// $searchBase = 'ou=people,o=example.com';
+//
+// $ds = @ldap_connect($ldapServer, $ldapPort);
+//
+// $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $imp['user']);
+// $information = @ldap_get_entries($ds, $searchResult);
+// if ($information[0]['cn;lang-es'][0] != '') {
+// $name = $information[0]['cn;lang-es'][0];
+// } else {
+// $name = $information[0]['cn'][0];
+// }
+//
+// ldap_close($ds);
+//
+// return (empty($name) ? $imp['user'] : $name);
+// }
+// }
+
Index: imp/config/conf.php.dist
===================================================================
RCS file: /repository/imp/config/conf.php.dist,v
retrieving revision 1.181
diff -u -3 -p -r1.181 conf.php.dist
--- imp/config/conf.php.dist 3 Jun 2002 15:21:32 -0000 1.181
+++ imp/config/conf.php.dist 5 Jun 2002 16:47:36 -0000
@@ -317,47 +317,12 @@ $conf['hooks']['signature'] = '';
// }
// }
-// If this is set to a function name, that function will be used
-// to get the user's fullname to use when sending mail. See
-// the 'imp_set_fullname' function below for an example.
-$conf['hooks']['fullname'] = '';
-
-/* Here is an example imp_set_fullname function to set the fullname
- * from the GECOS information in the passwd file.
- */
-//if (!function_exists('imp_set_fullname')) {
-// function imp_set_fullname ($imp) {
-// $array = posix_getpwnam($imp['user']);
-// $gecos_array = explode(',', $array['gecos']);
-// return (empty($gecos_array) ? $imp['user'] : $gecos_array[0]);
-// }
-//}
-
-/* This is another example how to get the user's full name from an ldap server.
- * In this example we look if a Spanish name exists and return this or the
- * standard 'cn' entry if not.
- */
-// if (!function_exists('imp_set_fullname')) {
-// function imp_set_fullname($imp) {
-// $ldapServer = 'ldap.example.com';
-// $ldapPort = '389';
-// $searchBase = 'ou=people,o=example.com';
-//
-// $ds = @ldap_connect($ldapServer, $ldapPort);
-//
-// $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $imp['user']);
-// $information = @ldap_get_entries($ds, $searchResult);
-// if ($information[0]['cn;lang-es'][0] != '') {
-// $name = $information[0]['cn;lang-es'][0];
-// } else {
-// $name = $information[0]['cn'][0];
-// }
-//
-// ldap_close($ds);
-//
-// return (empty($name) ? $imp['user'] : $name);
-// }
-// }
+// $conf['hooks']['fullname']
+// Please note: The hook for setting up user's fullname
+// is moved to horde/conf/horde.php
+// please set it there.
+// Setting it in horde makes is available to horde framework
+// and its apps
// If this is set to a function name, that function will be used to
// set the $imp['user'] at login time; See the 'imp_get_vinfo'
---------------------- multipart/mixed attachment--