File: plugins.php

package info (click to toggle)
cacti 0.8.8b%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 9,796 kB
  • sloc: php: 52,273; sql: 2,463; xml: 691; sh: 434; perl: 151; makefile: 30
file content (43 lines) | stat: -rw-r--r-- 1,078 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

/*
 * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
 * Licensed under the GNU GPL. For full terms see the file COPYING.
 */

global $plugin_hooks, $plugins_system, $plugins;
$plugin_hooks = array();
$plugins_system = array('settings', 'boost', 'dsstats');

function use_plugin ($name) {
	global $config;
	if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
		include_once($config['base_path'] . "/plugins/$name/setup.php");
		$function = "plugin_init_$name";
		if (function_exists($function)) {
			$function();
		}
	}
}

/**
 * This function executes a hook.
 * @param string $name Name of hook to fire
 * @return mixed $data
 */
if (!is_array($plugins)) {
	$plugins = array();
}

$oldplugins = read_config_option('oldplugins');
if (strlen(trim($oldplugins))) {
	$oldplugins = explode(',', $oldplugins);
	$plugins    = array_merge($plugins, $oldplugins);
}

/* On startup, register all plugins configured for use. */
if (isset($plugins) && is_array($plugins)) {
	foreach ($plugins as $name) {
		use_plugin($name);
	}
}