Most recent edit on 2006-02-20 10:02:49 by PsybeR [added info for console_after]
Additions:

from the updates plugin:
function plugin_init_update() {
$plugin_hooks['console_after']['update'] = 'update_console_after';
function update_console_after () {
global $config, $plugins;
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='47'"))) {
include_once($config['base_path'] . '/plugins/update/functions.php');
$x = 0;
$cinfo = update_get_plugin_info ();
$info = update_get_cached_plugin_info();
foreach ($plugins as $plugin) {
if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version']))
$x;
}
if ($x > 0) {
print "<table width='98%' align='center'> <tr><td class='textArea'>";
print "<br><br><strong>$x Plugin" . ($x > 1 ? "s have" : " has") . " new <a href='" . $config['url_path'] . "plugins/update/update.php?tab=updates'>Updates</a> to install!</strong>";
print "</td></tr></table>";
}



Deletions:


Edited on 2006-02-07 00:40:07 by JimmyConner [Added a few new hooks that are currently distributed as "testing"]
Additions:
cacti_image
This hook is used to modify the Image displayed on the Cacti Login page. It will also be used in several other places. The option passed to this hook is the path of the image. Setting it to a blank value will cause the image to not display, or you to can set it to whatever image you would like.
This hook is currently under going "testing"
console_before
This hook is used to display information before the normal "You are now logged into Cacti. You can follow these basic steps to get started." message is displayed.
This hook is currently under going "testing"
console_after
This hook is used to display information after the normal "You are now logged into Cacti. You can follow these basic steps to get started." message is displayed. You could use this hook to display a Message of the Day or anything else you required.
This hook is currently under going "testing"
login_before
This hook is used to display information before the Cacti Image on the Login page. You could possiby use this to add hidden items to the login form, or to wrap tables around the login form, etc....
This hook is currently under going "testing"
login_after
This hook is used to display information after the Login Form on the Login page. You could possiby use this to add hidden items to the login form, or to wrap tables around the login form, etc....
This hook is currently under going "testing"
print '<a href="' . $config['url_path'] . 'plugins/myplugin/myplugin.php"><img src="' . $config['url_path'] . 'plugins/myplugin/images/tab_myplugin.png" alt="
MyPlugin" align="absmiddle" border="0"></a>';
Deletions:
print '<a href="' . $config['url_path'] . 'plugins/myplugin/myplugin.php"><img src="' . $config['url_path'] . 'plugins/myplugin/images/tab_myplugin.png"alt="MyPlugin" align="absmiddle" border="0"></a>';
Edited on 2006-02-07 00:23:16 by JimmyConner [Minor spelling fix]
Additions:
$plugin_hooks['draw_navigation_text']['myplugin'] = 'myplugin_draw_navigation_text';
Deletions:
$plugin_hooks['draw_navigation_text']['mypligin'] = 'myplugin_draw_navigation_text';
Edited on 2006-01-30 11:33:53 by PsybeR
Additions:
CategoryDeveloper
Edited on 2006-01-25 02:40:24 by PsybeR [added draw_navigation_text example and graphics]
Additions:

setup.php
$plugin_hooks['draw_navigation_text']['mypligin'] = 'myplugin_draw_navigation_text';
function myplugin_draw_navigation_text ($nav) {
$nav["myplugin.php:"] = array("title" => "
MyPlugin", "mapping" => "index.php:", "url" => "myplugin.php", "level" => "1");
return $nav;
setup.php
setup.php
setup.php
Edited on 2006-01-25 01:57:21 by PsybeR [added graphic]
Additions:
Edited on 2006-01-25 01:21:20 by PsybeR [added top_header_tabs example]
Additions:
See top_header_tabs example
$plugin_hooks['top_header_tabs']['myplugin'] = 'myplugin_show_tab';
function myplugin_show_tab () {
global $config, $user_auth_realms, $user_auth_realm_filenames;
$realm_id2 = 0;
make sure user has rights to tab
if (isset($user_auth_realm_filenames{basename('myplugin.php')})) {
$realm_id2 = $user_auth_realm_filenames{basename('myplugin.php')};
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) {
print '<a href="' . $config['url_path'] . 'plugins/myplugin/myplugin.php"><img src="' . $config['url_path'] . 'plugins/myplugin/images/tab_myplugin.png"alt="
MyPlugin" align="absmiddle" border="0"></a>';
Edited on 2006-01-24 02:35:13 by JimmyConner
Additions:
This hook is called when a Device is saved. You can use this to modify the data before it is saved to the database, or to add your own custom variables to be saved to the database (the column in the database must exist!)
Used to change or add to several different arrays that are used throughout Cacti. See file include/config_arrays.php for the possible variables to modify.
Used to change or add to any of the forms that are displayed in Cacti. See file include/config_forms.php for the possible variables to modify.
Used to change any number of settings that are set in Cacti. See file include/config_settings.php for the possible variables to modify.
Used to Add links or change text on the data source table.
This is very commonly used hook to add the Navigational text that is displayed under the tabs. Without this, you will receive a PHP error anytime you navigate to a plugin page.
Used to add a new tab when ever someone is viewing the Graphs.
This hook is used to modify the time before refreshing the current graph page, or any page that uses the graph header.
Used to add a new tab when ever someone is viewing the Console.
This hook is called anytime that a Host's status changes. You can use it to notify when a host goes down or comes back up.
This hook is called whenever one of the non-default utilities actions are called. You would use this to act upon any utility that you add to the page.
This Hook is used to add a new options in the Utilities Menu. It should be paired with the utilities_action hook inorder to properly work.
Oldest known version of this page was edited on 2006-01-22 17:53:03 by PsybeR []
Page view:
Available Hooks
api_device_save
config_arrays
config_form
config_settings
data_sources_table
draw_navigation_text
graphs_new_top_links
Hook to add a link to the top of the
New Graphs page
example:
function plugin_init_thold
() {
global $plugin_hooks;
$plugin_hooks['graphs_new_top_links']['thold'] =
'thold_graphs_new';
}
function thold_graphs_new
() {
global $_REQUEST,
$config;
print '<span style="color: #c16921;">*</span><a href="' .
$config['url_path'] .
'plugins/thold/thold.php?action=autocreate&hostid=' .
$_REQUEST["host_id"] .
'">Auto-create thresholds</a><br>';
}
poller_bottom
Hook a script to the end of the poller cycle
example:
function plugin_init_myplugin
() {
global $plugin_hooks;
$plugin_hooks['poller_bottom']['myplugin'] =
'myplugin_poller_bottom';
}
function myplugin_poller_bottom
() {
global $config;
$p =
dirname(__FILE__);
if ($config["cacti_server_os"] ==
"unix") {
$command_string = read_config_option
("path_php_binary");
$extra_args =
"-q " .
$p .
"/somescript.php";
} else {
$command_string = read_config_option
("path_php_binary");
$extra_args =
"-q " .
strtolower($p .
"/somescript.php");
}
exec_background
($command_string,
$extra_args);
}
poller_top
Hook a script to the beginning of the poller cycle
example:
Same as poller-bottom except script is run before poller
top_graph_header_tabs
top_graph_refresh
top_header_tabs
update_host_status
utilities_action
utilities_list