Page 1 of 1
Fusion 4.1.6 - restrict visibility of the 'customlink' ...
Posted: Thu Apr 18, 2019 10:00 pm
by vishfx
Hi Nagios Team,
Ref:
https://support.nagios.com/forum/viewto ... 4&start=10
Additionally, w.r.t above post , I am using customlinks feature.
How can I restrict visibility of the 'customlink' in a page based on contact/contactgroups ?
For eg:
If a page has
link1
link2
link3
link4
contact A should see
link1
link2
contact B should see
link3
link4
Kindly assist.
Regards,
Vish.
Re: Fusion 4.1.6 - restrict visibility of the 'customlink' .
Posted: Fri Apr 19, 2019 10:48 am
by ssax
Here are some updated examples for you that should do what you want:
Code: Select all
<?php
// fusioncustomlinks.inc.php
//
// This component allows you to add custom sections
// and custom links to the Nagios Fusion menus.
register_fusioncustomlinks();
function register_fusioncustomlinks() {
$component_args = array(
COMPONENT_TYPE => COMPONENT,
COMPONENT_NAME => 'fusioncustomlinks',
COMPONENT_TITLE => _('Fusion Custom Links Component'),
COMPONENT_VERSION => '1.0.2',
COMPONENT_DATE => '04/19/2019',
COMPONENT_AUTHOR => 'Nagios Enterprises, LLC',
COMPONENT_DESCRIPTION => _('Provides Custom Menu Entries'),
COMPONENT_REQUIRES_VERSION => 4100,
COMPONENT_FUNCTION => 'fusioncustomlinks_successful_registration',
);
register_component($component_args);
}
function fusioncustomlinks_successful_registration() {
register_fusioncustomlinks_callbacks();
}
function register_fusioncustomlinks_menu($cb, &$menu) {
// Add a section for all users
$menu->add_section('home', _('Stuff'), 'home-stuff');
// Add a custom link to the new section
$menu->add_link(menu_link(_('Nagios'), 'http://www.nagios.com'), 'home-stuff');
// Add a section for Admins only
if (is_admin()) {
$menu->add_section('home', _('Admin Tools'), 'home-admintools');
$menu->add_link(menu_link(_('My Custom Admin Link'), rawurlencode('https://YOURFUSIONSERVER/nagiosfusion/foo.php?arg1=foo&arg2=bar')), 'home-admintools');
}
$username = $_SESSION['username'];
// Add a section for specific users only
if (in_array("$username", array('nagiosadmin', 'ssax'))) {
$menu->add_section('home', _('Power Tools'), 'home-powertools');
$menu->add_link(menu_link(_('My Custom Power Tools Link'), rawurlencode('https://YOURFUSIONSERVER/nagiosfusion/bar.php?arg1=foo&arg2=bar')), 'home-powertools');
}
// Add a link with basic auth to the new session, if your URL has special characters in it, use rawurlencode() like below
$menu->add_link(menu_link(_('My Custom Link'), rawurlencode('https://username:[email protected]/website/')), 'home-stuff');
// Add a link to Home > Server Status section
$menu->add_link(menu_link(_('Custom Server Status Link 1'), 'includes/components/fusioncustomlinks/tactical_overview.php'), 'home-server-status');
// Add a link to Home > Alerts section
$menu->add_link(menu_link(_('Custom Alerts Link 1'), 'includes/components/fusioncustomlinks/recent_alerts.php'), 'home-alerts');
// Add a link to the Home > Visuaalizations section
$menu->add_link(menu_link(_('Custom Visualization Link 1'), 'includes/components/fusioncustomlinks/service_health.php'), 'home-visualizations');
}
// Register callbacks for fusion functionality
function register_fusioncustomlinks_callbacks() {
register_callback(CALLBACK_MENU_INITIALIZED, 'register_fusioncustomlinks_menu');
}
?>
Re: Fusion 4.1.6 - restrict visibility of the 'customlink' .
Posted: Wed Apr 24, 2019 9:00 am
by vishfx
Thanks Sean.
This solution is manageable for a small group of users.
But if we have few 100 users or more, this would a real pain.
It will be nice to have this feature in-built in Fusion.
Regards,
Vish.
Re: Fusion 4.1.6 - restrict visibility of the 'customlink' .
Posted: Wed Apr 24, 2019 4:47 pm
by ssax
There is no user group functionality in XI or Fusion yet so that's the only option you have at this point.
Re: Fusion 4.1.6 - restrict visibility of the 'customlink' .
Posted: Wed Apr 24, 2019 10:19 pm
by vishfx
Thanks for your help on this request.
We will proceed with this approach for now.
This request can be closed.
Regards,
Vish.
Re: Fusion 4.1.6 - restrict visibility of the 'customlink' .
Posted: Thu Apr 25, 2019 3:42 pm
by benjaminsmith
Hi Vish,
Thanks for your help on this request.
We will proceed with this approach for now.
This request can be closed.
Sounds good. We'll close this out.