On Wed, 19 Nov 1997, Vladimir Dubnikov <msvd@pluto.mscc.huji.ac.il> wrote:
>
>If there is possibility to get who's result is sorted by username
>or by host.
Not normally. But try this: We've been using a "who_sort=yes/no"
config option since the 1.93 days. I recently recoded it to make
it more flexible. I'll provide the framework; someone else will
have to add the actual username/host sort functionality.
who_sort = no | alpha | ???
To add your own sort function to the defaults of none or alphanumeric
(such as by_user or by_host):
insert the sort function in majordomo
add an identifier to the who_sort enum in config_parse.pl
add an "if eq identifier" mapping in do_who()
I would suggest that if (a) this patch is worthwhile enough to
be added to the next point release, and (b) you create a sorting
function that might be usable by others, then you contribute
that function as an additional patch so the Majordomo community
may benefit.
Warning: this patch is vs a patched Majordomo that has implemented
other recent 1.94.4 patches including "no MSMail attachments" and
"subscribe/nosubscribe". Line numbers may vary slightly.
--bill
---CUT HERE---
*** src/majordomo-1.94.4/majordomo Mon Nov 10 00:12:12 1997
--- majordomo Thu Nov 20 23:39:06 1997
***************
*** 746,756 ****
#open it up and tell who's on it
print REPLY "Members of list '$clean_list':\n\n";
if (&lopen(LIST, "", "$listdir/$clean_list")) {
! while (<LIST>) {
! print REPLY $_;
! $counter++;
! }
&lclose(LIST);
printf REPLY "\n%s subscriber%s\n\n", ($counter ? $counter : "No"),
($counter == 1 ? "" : "s");
&log("who $clean_list");
--- 746,762 ----
#open it up and tell who's on it
print REPLY "Members of list '$clean_list':\n\n";
if (&lopen(LIST, "", "$listdir/$clean_list")) {
! # snarf the whole list
! local(@subscribers) = <LIST>;
! $counter = @subscribers;
&lclose(LIST);
+ # select a sorting function; add your own!
+ # eg, sort by_login (@subscribers) [if who_sort=login]
+ local($sort);
+ $sort = "" if $config_opts{$clean_list, 'who_sort'} eq "no";
+ $sort = "sort" if $config_opts{$clean_list, 'who_sort'} eq "alpha";
+ # build a sort (or non-sort) command
+ eval "foreach ($sort \@subscribers) {print REPLY \$_;}";
printf REPLY "\n%s subscriber%s\n\n", ($counter ? $counter : "No"),
($counter == 1 ? "" : "s");
&log("who $clean_list");
*** src/majordomo-1.94.4/config_parse.pl Mon Nov 10 18:09:39 1997
--- config_parse.pl Wed Nov 19 23:01:56 1997
***************
*** 76,81 ****
--- 76,82 ----
# otherwise the value is the default value for the keyword.
# if the value starts with #!, the rest of the value is eval'ed
%known_keys = (
+ 'who_sort', "no\001alpha\001no", # sort function for 'who'
'welcome', 'yes', # send welcome msg to new subscribers
'announcements', 'yes', # send sub/unsub audits to list owner
'get_access', "open\001closed\001list\001list", # open, anyone can access
***************
*** 149,154 ****
--- 157,168 ----
# An associative array of comments for all of the keys
# The text is wrapped and filled on output.
%comments = (
+ 'who_sort',
+ "Specifies whether the subscriber list should be sorted when
+ retrieving via a 'who' command. 'no' will not perform any sorting;
+ 'alpha' will perform a simple alphanumeric sort. Other sort functions
+ may be made available by the site administrator.",
+
'welcome',
"If set to yes, a welcome message (and optional 'intro' file) will be
sent to the newly subscribed user.",
***************
*** 433,438 ****
--- 447,453 ----
# match commands to their subsystem, by default only 4 subsystems
# exist, majordomo, resend, digest and config.
%subsystem = (
+ 'who_sort', 'majordomo',
'welcome', 'majordomo',
'announcements', 'majordomo',
'get_access', 'majordomo',
***************
*** 491,496 ****
--- 506,512 ----
# the parse function will be called to parse the value string for
# the keyword
%parse_function = (
+ 'who_sort', 'grab_enum',
'welcome', 'grab_bool',
'announcements', 'grab_bool',
'get_access', 'grab_enum',
|
|