From b0c9486b32e4fd0fe3c9ed7f44ace0ef59431477 Mon Sep 17 00:00:00 2001 From: tecto Date: Tue, 24 Feb 2026 04:29:24 -0500 Subject: [PATCH] Add hooks for feature plugins to inject users into the users listing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds three hooks so feature plugins can display their users in the standard domain users table and provide creation links: 1. list_plugin_users hook in list_domain_users() — plugins return user hashes that are merged into the users listing (follows the existing list_extra_web_users pattern for virtualmin-htpasswd) 2. edit_url support in users_table() — if a user hash has an edit_url key, it is used for the name link instead of edit_user.cgi 3. users_create_links hook in list_users.cgi — plugins can add "Add" buttons to the users page, placed outside the mailbox quota guard All three are no-ops when no plugins define the hooks. --- list_users.cgi | 7 +++++++ virtual-server-lib-funcs.pl | 23 ++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/list_users.cgi b/list_users.cgi index efc41e621..58e49a443 100755 --- a/list_users.cgi +++ b/list_users.cgi @@ -59,6 +59,13 @@ if ($mleft != 0) { } } } +# Include user creation links from feature plugins +foreach my $f (&list_feature_plugins()) { + if ($d->{$f} && &plugin_defined($f, "users_create_links")) { + my @plinks = &plugin_call($f, "users_create_links", $d); + push(@links, @plinks) if @plinks; + } + } push(@links, [ "mass_ucreate_form.cgi?dom=$in{'dom'}", $text{'users_batch2'}, "right" ]); diff --git a/virtual-server-lib-funcs.pl b/virtual-server-lib-funcs.pl index c44fc1eb2..6e297cfa1 100755 --- a/virtual-server-lib-funcs.pl +++ b/virtual-server-lib-funcs.pl @@ -1127,6 +1127,16 @@ sub list_domain_users push(@users, &list_extra_web_users($d)); } +# Include users from feature plugins that define list_plugin_users +if ($includeextra) { + foreach my $f (&list_feature_plugins()) { + if ($d->{$f} && &plugin_defined($f, "list_plugin_users")) { + my @pu = &plugin_call($f, "list_plugin_users", $d); + push(@users, @pu) if @pu; + } + } + } + # Add any secondary groups in the template local @sgroups = &allowed_secondary_groups($d); if (@sgroups) { @@ -5723,11 +5733,18 @@ sub users_table $u->{'webowner'} && $u->{'pass'} =~ /^(\!|\*)/ ? $pop3_dis : $u->{'webowner'} ? $pop3 : $u->{'pass'} =~ /^(\!|\*)/ ? $pop3_dis : $pop3); - my $col_val = "$col_text"; - if (!$virtualmin_pro && $u->{'extra'}) { + my $col_val; + if ($u->{'edit_url'}) { + $col_val = "$col_text"; + } + elsif (!$virtualmin_pro && $u->{'extra'}) { $col_val = $col_text; } + else { + $col_val = "$col_text"; + } push(@cols, "$col_val\n"); push(@cols, &html_escape($u->{'user'})); push(@cols, &html_escape($u->{'real'}));