Review Board 1.7.16


Add aliases for Directory

Review Request #2244 - Created Dec. 12, 2012 and submitted

Tilghman Lesher
Reviewers
asterisk-dev
Asterisk
This patch adds extra strings for comparison in the Directory application.  The purpose of this is to enable nicknames that otherwise would not be compared.  For example, Bob "Bongo Boy" Berman might have an alias of "Bongo", for which he would be searchable, even though his name would not normally include it.
Deployed and working on a production machine.

Changes between revision 1 and 3

1 2 3
1 2 3

  1. /trunk/apps/app_directory.c: Loading...
  2. /trunk/configs/voicemail.conf.sample: Loading...
  3. /trunk/contrib/realtime/mysql/voicemail.sql: Loading...
/trunk/apps/app_directory.c
Diff Revision 1 Diff Revision 3
[20] 84 lines
[+20] [+] ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
85
						<para> Allow the caller to enter either the first or the last name
85
						<para> Allow the caller to enter either the first or the last name
86
						of a user in the directory.  If specified, the optional number
86
						of a user in the directory.  If specified, the optional number
87
						argument will be used for the number of characters the user should enter.</para>
87
						argument will be used for the number of characters the user should enter.</para>
88
						<argument name="n" required="true" />
88
						<argument name="n" required="true" />
89
					</option>
89
					</option>

    
   
90
					<option name="a">

    
   
91
						<para>Allow the caller to additionally enter an alias for a user in the

    
   
92
						directory.  This option must be specified in addition to the

    
   
93
						<literal>f</literal>, <literal>l</literal>, or <literal>b</literal>

    
   
94
						option.</para>

    
   
95
					</option>
90
					<option name="m">
96
					<option name="m">
91
						<para>Instead of reading each name sequentially and asking for
97
						<para>Instead of reading each name sequentially and asking for
92
						confirmation, create a menu of up to 8 names.</para>
98
						confirmation, create a menu of up to 8 names.</para>
93
					</option>
99
					</option>
94
					<option name="n">
100
					<option name="n">
[+20] [20] 38 lines
[+20] [+] enum {
133
	OPT_SELECTFROMMENU =  (1 << 3),
139
	OPT_SELECTFROMMENU =  (1 << 3),
134
	OPT_LISTBYLASTNAME =  (1 << 4),
140
	OPT_LISTBYLASTNAME =  (1 << 4),
135
	OPT_LISTBYEITHER =    OPT_LISTBYFIRSTNAME | OPT_LISTBYLASTNAME,
141
	OPT_LISTBYEITHER =    OPT_LISTBYFIRSTNAME | OPT_LISTBYLASTNAME,
136
	OPT_PAUSE =           (1 << 5),
142
	OPT_PAUSE =           (1 << 5),
137
	OPT_NOANSWER =        (1 << 6),
143
	OPT_NOANSWER =        (1 << 6),

    
   
144
	OPT_ALIAS =           (1 << 7),
138
};
145
};
139

    
   
146

   
140
enum {
147
enum {
141
	OPT_ARG_FIRSTNAME =   0,
148
	OPT_ARG_FIRSTNAME =   0,
142
	OPT_ARG_LASTNAME =    1,
149
	OPT_ARG_LASTNAME =    1,
[+20] [20] 19 lines
[+20] [+] AST_APP_OPTIONS(directory_app_options, {
162
	AST_APP_OPTION_ARG('p', OPT_PAUSE, OPT_ARG_PAUSE),
169
	AST_APP_OPTION_ARG('p', OPT_PAUSE, OPT_ARG_PAUSE),
163
	AST_APP_OPTION('e', OPT_SAYEXTENSION),
170
	AST_APP_OPTION('e', OPT_SAYEXTENSION),
164
	AST_APP_OPTION('v', OPT_FROMVOICEMAIL),
171
	AST_APP_OPTION('v', OPT_FROMVOICEMAIL),
165
	AST_APP_OPTION('m', OPT_SELECTFROMMENU),
172
	AST_APP_OPTION('m', OPT_SELECTFROMMENU),
166
	AST_APP_OPTION('n', OPT_NOANSWER),
173
	AST_APP_OPTION('n', OPT_NOANSWER),

    
   
174
	AST_APP_OPTION('a', OPT_ALIAS),
167
});
175
});
168

    
   
176

   
169
static int compare(const char *text, const char *template)
177
static int compare(const char *text, const char *template)
170
{
178
{
171
	char digit;
179
	char digit;
[+20] [20] 316 lines
[+20] [+] static struct ast_config *realtime_directory(char *context)
488
			continue;
496
			continue;
489
		}
497
		}
490
		ast_str_set(&tmp, 0, "no-password,%s", S_OR(fullname, ""));
498
		ast_str_set(&tmp, 0, "no-password,%s", S_OR(fullname, ""));
491
		if (ast_variable_retrieve(rtdata, mailbox, "alias")) {
499
		if (ast_variable_retrieve(rtdata, mailbox, "alias")) {
492
			for (alias = ast_variable_browse(rtdata, mailbox); alias; alias = alias->next) {
500
			for (alias = ast_variable_browse(rtdata, mailbox); alias; alias = alias->next) {
493
				if (!strcmp(alias->name, "alias")) {
501
				if (!strcasecmp(alias->name, "alias")) {
494
					ast_str_append(&tmp, 0, "|alias=%s", alias->value);
502
					ast_str_append(&tmp, 0, "|alias=%s", alias->value);
495
				}
503
				}
496
			}
504
			}
497
		}
505
		}
498

    
   
506

   
[+20] [20] 106 lines
[+20] [+] static int search_directory_sub(const char *context, struct ast_config *vmcfg, struct ast_config *ucfg, const char *ext, struct ast_flags flags, itemlist *alist)
605
			res = check_match(&item, context, pos, v->name, ext, 0 /* use_first_name */);
613
			res = check_match(&item, context, pos, v->name, ext, 0 /* use_first_name */);
606
		}
614
		}
607
		if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) {
615
		if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) {
608
			res = check_match(&item, context, pos, v->name, ext, 1 /* use_first_name */);
616
			res = check_match(&item, context, pos, v->name, ext, 1 /* use_first_name */);
609
		}
617
		}
610
		if (!res && (alias = strcasestr(bufptr, "alias="))) {
618
		if (!res && ast_test_flag(&flags, OPT_ALIAS) && (alias = strcasestr(bufptr, "alias="))) {
611
			char *a;
619
			char *a;
612
			ast_debug(1, "Found alias: %s\n", alias);
620
			ast_debug(1, "Found alias: %s\n", alias);
613
			while ((a = strsep(&alias, "|"))) {
621
			while ((a = strsep(&alias, "|"))) {
614
				if (!strncmp(a, "alias=", 6)) {
622
				if (!strncasecmp(a, "alias=", 6)) {
615
					if ((res = check_match(&item, context, a + 6, v->name, ext, 1))) {
623
					if ((res = check_match(&item, context, a + 6, v->name, ext, 1))) {
616
						break;
624
						break;
617
					}
625
					}
618
				}
626
				}
619
			}
627
			}
[+20] [20] 29 lines
[+20] static int search_directory_sub(const char *context, struct ast_config *vmcfg, struct ast_config *ucfg, const char *ext, struct ast_flags flags, itemlist *alist)
649
				res = check_match(&item, context, position, cat, ext, 0 /* use_first_name */);
657
				res = check_match(&item, context, position, cat, ext, 0 /* use_first_name */);
650
			}
658
			}
651
			if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) {
659
			if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) {
652
				res = check_match(&item, context, position, cat, ext, 1 /* use_first_name */);
660
				res = check_match(&item, context, position, cat, ext, 1 /* use_first_name */);
653
			}
661
			}
654
			if (!res) {
662
			if (!res && ast_test_flag(&flags, OPT_ALIAS)) {
655
				struct ast_variable *alias;
663
				struct ast_variable *alias;
656
				for (alias = ast_variable_browse(ucfg, cat); alias; alias = alias->next) {
664
				for (alias = ast_variable_browse(ucfg, cat); alias; alias = alias->next) {
657
					if (!strcasecmp(v->name, "alias") && (res = check_match(&item, context, v->value, cat, ext, 1))) {
665
					if (!strcasecmp(v->name, "alias") && (res = check_match(&item, context, v->value, cat, ext, 1))) {
658
						break;
666
						break;
659
					}
667
					}
[+20] [20] 278 lines
/trunk/configs/voicemail.conf.sample
Diff Revision 1 Diff Revision 3
 
/trunk/contrib/realtime/mysql/voicemail.sql
Diff Revision 1 Diff Revision 3
 
  1. /trunk/apps/app_directory.c: Loading...
  2. /trunk/configs/voicemail.conf.sample: Loading...
  3. /trunk/contrib/realtime/mysql/voicemail.sql: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.