device_edit_top_links

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
lorenplak
Posts: 41
Joined: Wed Feb 23, 2011 11:53 am

device_edit_top_links

Post by lorenplak »

Hy,

i want to add a link in the Host Top links, but this link must have the current host ID.

how to do that ?

Laurent
Cacti 0.8.7g - Windows - poller type : spine
php 5.2.14 - MySQL 5.1.47
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: device_edit_top_links

Post by gandalf »

Are you talking about the links seen on top, when editing a single host?
Whcih method of adding your custom link do you prefer, by writing a plugin (using a plugin hook) or by simply patching the code?
Which base version of cacti are you using?
R.
lorenplak
Posts: 41
Joined: Wed Feb 23, 2011 11:53 am

Re: device_edit_top_links

Post by lorenplak »

hello,
gandalf wrote:Are you talking about the links seen on top, when editing a single host?
yes
gandalf wrote:Whcih method of adding your custom link do you prefer, by writing a plugin (using a plugin hook) or by simply patching the code?
i want to add this within a plugin, so using plugin hook.
gandalf wrote:Which base version of cacti are you using?
my cacti version is 0.8.7i

Laurent
Cacti 0.8.7g - Windows - poller type : spine
php 5.2.14 - MySQL 5.1.47
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: device_edit_top_links

Post by gandalf »

The relevant part of code is

Code: Select all

				<td class="textInfo" valign="top">
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("data_sources.php?host_id=" . $host["id"] . "&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1");?>">Data Source List</a><br>
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs.php?host_id=" . $host["id"] . "&graph_rows=30&filter=&template_id=-1&page=1");?>">Graph List</a>
					<?php api_plugin_hook('device_edit_top_links'); ?>
				</td>
So you will use the hook device_edit_top_links and may want to use get_request_var("id") as the id of the host. It would be safe to use

Code: Select all

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	/* ==================================================== */
as validation before using the id.
R.
lorenplak
Posts: 41
Joined: Wed Feb 23, 2011 11:53 am

Re: device_edit_top_links

Post by lorenplak »

hy,
gandalf wrote:The relevant part of code is

Code: Select all

				<td class="textInfo" valign="top">
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("data_sources.php?host_id=" . $host["id"] . "&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1");?>">Data Source List</a><br>
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs.php?host_id=" . $host["id"] . "&graph_rows=30&filter=&template_id=-1&page=1");?>">Graph List</a>
					<?php api_plugin_hook('device_edit_top_links'); ?>
				</td>
So you will use the hook device_edit_top_links and may want to use get_request_var("id") as the id of the host. It would be safe to use

Code: Select all

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	/* ==================================================== */
as validation before using the id.
R.

Great !
thanks a lot Gandalf.

Laurent
Cacti 0.8.7g - Windows - poller type : spine
php 5.2.14 - MySQL 5.1.47
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests