From 122486b2635bcb763b84003f28afd38b18a046e2 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Thu, 19 Jun 2008 19:22:59 +0000 Subject: [PATCH] Allow alternative extensions to be specified for a user. (closes issue #12830) Reported by: jcollie Patches: astertisk-trunk-121496-alternate-extensions.patch uploaded by jcollie (license 412) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@124049 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- CHANGES | 2 ++ configs/users.conf.sample | 6 ++++++ pbx/pbx_config.c | 14 +++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 8843e13f67..300c939f19 100644 --- a/CHANGES +++ b/CHANGES @@ -785,3 +785,5 @@ Miscellaneous * If compiled with DEBUG_THREADS enabled and if you have glibc, then issuing the "core show locks" CLI command will give lock information output as well as a backtrace of the stack which led to the lock calls. + * users.conf now sports an optional alternativeexts property, which permits + allocation of additional extensions which will reach the specified user. diff --git a/configs/users.conf.sample b/configs/users.conf.sample index 11ec54a54b..171b891c15 100644 --- a/configs/users.conf.sample +++ b/configs/users.conf.sample @@ -77,3 +77,9 @@ pickupgroup = 1 ;hasmanager = no ;callwaiting = no ;context = international +; +; Some administrators choose alphanumeric extensions, but still want their +; users to be reachable by traditional numeric extensions, specified by the +; alternateexts entry. +; +;alternateexts = 7057,3249 diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index dddd8ef5c1..9d482f6b52 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1549,10 +1549,11 @@ static void pbx_load_users(void) struct ast_config *cfg; char *cat, *chan; const char *dahdichan; - const char *hasexten; + const char *hasexten, *altexts; char tmp[256]; char iface[256]; char dahdicopy[256]; + char *ext, altcopy[256]; char *c; int len; int hasvoicemail; @@ -1643,6 +1644,17 @@ static void pbx_load_users(void) } else { ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", strdup("${HINT}"), ast_free_ptr, registrar); } + altexts = ast_variable_retrieve(cfg, cat, "alternateexts"); + if (!ast_strlen_zero(altexts)) { + snprintf(tmp, sizeof(tmp), "%s,1", cat); + ast_copy_string(altcopy, altexts, sizeof(altcopy)); + c = altcopy; + ext = strsep(&c, ","); + while (ext) { + ast_add_extension2(con, 0, ext, 1, NULL, NULL, "Goto", strdup(tmp), ast_free, registrar); + ext = strsep(&c, ","); + } + } } } ast_config_destroy(cfg);