From 2ea378e63d17e6f2bb2cfd2434404e4d7ad48c64 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 22 Dec 2014 14:49:33 -0800 Subject: [PATCH] Allow modules to veto blocks from other modules --- web-lib-funcs.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 39acba115..ac7a6717f 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -10110,8 +10110,8 @@ to display. Each is a hash ref with the following keys : =item type - Can be "html" for an arbitrary block of HTML, "table" for a table of information, "usage" for a table of usage of some resource, "redirect" for a request to redirect the whole page to another URL, - "warning" for a warning dialog, or "link" for a link to another - page. + "warning" for a warning dialog, "link" for a link to another + page, or "veto" to request removal of a block from another module. =item desc - The title for this section of info @@ -10137,6 +10137,8 @@ to display. Each is a hash ref with the following keys : =item link - In "link" mode, the destination URL +=item veto - In "veto" mode, the ID of the block from some other module to skip + =item target - In "link" mode, can be "new" for a new page, or "window" for the current whole browser window @@ -10189,11 +10191,17 @@ if (&foreign_available("webmin")) { &foreign_require("webmin"); foreach my $n (&webmin::get_webmin_notifications()) { push(@rv, { 'type' => 'warning', + 'id' => 'notifications', 'level' => 'info', 'module' => 'webmin', 'warning' => $n }); } } +# Obey vetos for blocks from other modules +foreach my $veto (grep { $_->{'type'} eq 'veto' } @rv) { + @rv = grep { $_->{'id'} ne $veto->{'veto'} } @rv; + } +@rv = grep { $_->{'type'} ne 'veto' } @rv; return sort { ($b->{'priority'} || 0) <=> ($a->{'priority'} || 0) } @rv; }