[Asterisk-Users] Directory - First Name/Last Name - How to, use both? a@h?

Jeremiah Millay jeremiah at rockriver.net
Wed Jun 14 12:17:24 MST 2006


We wrote and submitted a patch to do this. Just modify app_directory.c 
and recompile. It adds a new flag "b" to the directory( ) app where you 
can have it use both first and last name.

  -= Info about application 'Directory' =-

[Synopsis]
Provide directory of voicemail extensions

[Description]
  Directory(vm-context[|dial-context[|options]]): This application will 
present
the calling channel with a directory of extensions from which they can 
search
by name. The list of names and corresponding extensions is retrieved 
from the
voicemail configuration file, voicemail.conf.
  This applicaiton will immediate exit if one of the following DTMF 
digits are
received and the extension to jump to exists:
    0 - Jump to the 'o' extension, if it exists.
    * - Jump to the 'a' extension, if it exists.

  Parameters:
    vm-context   - This is the context within voicemail.conf to use for the
                   Directory.
    dial-context - This is the dialplan context to use when looking for an
                   extension that the user has selected, or when jumping 
to the
                   'o' or 'a' extension.

  Options:
    f - Allow the caller to enter the first name of a user in the directory
        instead of using the last name.
    b - Allow the caller to enter the first name OR last name of a user in
        the directory.




Here is the patch:

Index: app_directory.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_directory.c,v
retrieving revision 1.52
diff -u -r1.52 app_directory.c
--- app_directory.c    11 Nov 2005 15:52:55 -0000    1.52
+++ app_directory.c    12 May 2006 21:58:35 -0000
@@ -63,7 +63,9 @@
"                   'o' or 'a' extension.\n\n"
"  Options:\n"
"    f - Allow the caller to enter the first name of a user in the 
directory\n"
-"        instead of using the last name.\n"; +"        instead of using 
the last name.\n"
+"    b - Allow the caller to enter the first name OR last name of a 
user in\n"
+"        the directory.\n";
/* For simplicity, I'm keeping the format compatible with the voicemail 
config,
   but i'm open to suggestions for isolating it */
@@ -345,6 +347,20 @@
                    pos = strsep(&stringp, ",");
                    if (pos) {
                        ast_copy_string(name, pos, sizeof(name));
+                        if (last == 2) /* Check the first name as well */
+                        {
+                            conv = convert(pos);
+                            if (conv) {
+                                if (!strcmp(conv, ext)) {
+                                    /* Match! */
+                                    found++;
+                                    free(conv);
+                                    free(start);
+                                    break;
+                                }
+                                free(conv);
+                            }
+                        }
                        /* Grab the last name */
                        if (last && strrchr(pos,' '))
                            pos = strrchr(pos, ' ') + 1;
@@ -434,6 +450,8 @@
            options++;             if (strchr(options, 'f'))
                last = 0;
+            if (strchr(options, 'b'))
+                last = 2;
        }
    } else   
        dialcontext = context;
@@ -448,8 +466,10 @@
    if (ast_strlen_zero(dirintro))
        dirintro = ast_variable_retrieve(cfg, "general", "directoryintro");
    if (ast_strlen_zero(dirintro)) {
-        if (last)
+        if (last==1)
            dirintro = "dir-intro";   
+        else if (last==2)
+            dirintro = "dir-intro-fnln";   
        else
            dirintro = "dir-intro-fn";
    }


-- 
______________________________________________________________
Rock River Internet                            Jeremiah Millay
202 W. State St, 8th Floor              jeremiah at rockriver.net
Rockford, IL 61101                      815-968-9888 Ext. 2202
USA                                               fax 968-6888




More information about the asterisk-users mailing list