コード例 #1
0
/**
 * converts plugin's array to string and adds version numbers
 * @return string preformated text with installed plugin's information
 * @access private
 */
function br_show_plugins()
{
    global $plugins;
    $str = '';
    if (is_array($plugins) && $plugins != array()) {
        foreach ($plugins as $key => $plugin_name) {
            // note that some plugins may not have been loaded up by now
            // so we do that here to make sure...  also turn on output
            // buffering so they don't screw up our output with spacing
            // or newlines
            //
            ob_start();
            use_plugin($plugin_name);
            ob_end_clean();
            if ($key != 0 || $plugin_name != '') {
                $english_name = get_plugin_requirement($plugin_name, 'english_name');
                $str .= "    * {$key} = " . (!empty($english_name) ? $english_name . " ({$plugin_name}) " : "{$plugin_name} ") . get_plugin_version($plugin_name, TRUE) . "\n";
            }
        }
        // compatibility plugin can be used without needing to enable it in sm config
        if (file_exists(SM_PATH . 'plugins/compatibility/setup.php') && !in_array('compatibility', $plugins)) {
            $str .= '    * Compatibility (compatibility) ' . get_plugin_version('compatibility', TRUE) . "\n";
        }
    }
    if ($str == '') {
        return "    * Nothing listed\n";
    }
    return $str;
}
コード例 #2
0
ファイル: plugins.php プロジェクト: resmon/resmon-cacti
$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);
    }
}
コード例 #3
0
 function is_role_page($lines)
 {
     global $check_role;
     if (!$check_role) {
         return FALSE;
     }
     $cmd = use_plugin('check_role', $lines);
     if ($cmd === FLASE) {
         return FALSE;
     }
     convert_html($cmd);
     // die();
     return TRUE;
 }
コード例 #4
0
ファイル: plugin.php プロジェクト: teammember8/roundcube
/**
 * This function is used for hooks which are to return true or
 * false. If $priority is > 0, any one or more trues will override
 * any falses. If $priority < 0, then one or more falses will
 * override any trues.
 * Priority 0 means majority rules.  Ties will be broken with $tie
 *
 * If any plugin on this hook wants to modify the $args
 * plugin parameter, it simply has to use call-by-reference
 * syntax in the hook function that it has registered for the
 * current hook.  Note that this is in addition to (entirely
 * independent of) the return value for this hook.
 *
 * @param string  $name     The hook name
 * @param mixed   &$args    A single value or an array of arguments 
 *                          that are to be passed to all plugins 
 *                          operating off the hook being called.  
 *                          Note that this argument is passed by 
 *                          reference thus it is liable to be 
 *                          changed after the hook completes.
 * @param int     $priority See explanation above
 * @param boolean $tie      See explanation above
 *
 * @return boolean The result of the function
 *
 */
function boolean_hook_function($name, &$args, $priority = 0, $tie = false)
{
    global $squirrelmail_plugin_hooks, $currentHookName;
    $yea = 0;
    $nay = 0;
    $ret = $tie;
    if (isset($squirrelmail_plugin_hooks[$name]) && is_array($squirrelmail_plugin_hooks[$name])) {
        /* Loop over the plugins that registered the hook */
        $currentHookName = $name;
        foreach ($squirrelmail_plugin_hooks[$name] as $plugin_name => $function) {
            use_plugin($plugin_name);
            if (function_exists($function)) {
                $ret = $function($args);
                if ($ret) {
                    $yea++;
                } else {
                    $nay++;
                }
                // each plugin can call additional hooks, so need
                // to make sure the current hook name is accurate
                // again after each plugin has finished
                //
                $currentHookName = $name;
            }
        }
        $currentHookName = '';
        /* Examine the aftermath and assign the return value appropriately */
        if ($priority > 0 && $yea) {
            $ret = true;
        } elseif ($priority < 0 && $nay) {
            $ret = false;
        } elseif ($yea > $nay) {
            $ret = true;
        } elseif ($nay > $yea) {
            $ret = false;
        } else {
            // There's a tie, no action needed.
        }
        return $ret;
    }
    // If the code gets here, there was a problem - no hooks, etc.
    return NULL;
}