Ejemplo n.º 1
0
/**
 * Implementation of hook_init.
 */
function ft_log_init()
{
    global $ft;
    // Check if DB plugin is loaded.
    if (ft_plugin_exists('db')) {
        // Check if we need to create new table.
        $sql = "CREATE TABLE log (\n    id INTEGER PRIMARY KEY,\n    type TEXT NOT NULL,\n    message TEXT NOT NULL,\n    location TEXT NOL NULL,\n    timestamp DATE NOT NULL,\n    user TEXT NOT NULL,\n    hostname TEXT NOT NULL,\n    severity INTEGER NOT NULL\n    )";
        ft_db_install_table('log', $sql);
    }
}
Ejemplo n.º 2
0
/**
 * Implementation of hook_init.
 */
function ft_fileinfo_init()
{
    // Check if DB plugin is loaded.
    if (!ft_plugin_exists('db')) {
        ft_set_message(t('!name plugin not enabled because required !required plugin was not found.', array('!name' => 'Fileinfo', '!required' => 'db')), 'error');
        ft_plugin_unload('fileinfo');
    } else {
        // Check if we need to create new table.
        $sql = "CREATE TABLE fileinfo (\n      dir TEXT NOT NULL,\n      file TEXT NOT NULL,\n      description TEXT\n    )";
        ft_db_install_table('fileinfo', $sql);
    }
}
Ejemplo n.º 3
0
/**
 * Get a list of available plugins.
 */
function ft_plugins_list()
{
    $plugin_list = array();
    // Get all files in the plugin dir.
    if ($dirlink = @opendir(PLUGINDIR)) {
        while (($file = readdir($dirlink)) !== false) {
            // Only grab files that end in .plugin.php
            if (strstr($file, '.plugin.php')) {
                // Load plugin files if they're not already there.
                $name = substr($file, 0, strpos($file, '.'));
                if (!ft_plugin_exists($name)) {
                    include_once PLUGINDIR . '/' . $file;
                }
                // Get plugin info. We can't use ft_invoke_hook since we need to loop through all plugins, not just the loaded plugins.
                if (function_exists('ft_' . $name . '_info')) {
                    $plugin_list[$name] = call_user_func('ft_' . $name . '_info');
                } else {
                    // If there's no info hook, we at least create some basic info.
                    $plugin_list[$name] = array('name' => $name);
                }
            }
        }
    }
    return $plugin_list;
}