device_edit_top_links

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Moderators, Developers

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

device_edit_top_links

#1 Post by lorenplak » Thu Feb 16, 2012 5:17 am

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: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: device_edit_top_links

#2 Post by gandalf » Sun Feb 19, 2012 1:52 pm

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

#3 Post by lorenplak » Mon Feb 20, 2012 4:04 am

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: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: device_edit_top_links

#4 Post by gandalf » Tue Feb 21, 2012 4:16 pm

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

#5 Post by lorenplak » Wed Feb 22, 2012 4:09 am

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