Ejemplo n.º 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;
}
Ejemplo n.º 2
0
 function get_plugin_dependencies($plugin_name, $force_inclusion = FALSE, $do_parse = TRUE)
 {
     $plugin_dependencies = get_plugin_requirement($plugin_name, 'required_plugins', $force_inclusion);
     // the plugin is simply incompatible, no need to continue here
     //
     if ($plugin_dependencies === SQ_INCOMPATIBLE) {
         return $plugin_dependencies;
     }
     // not an array of requirements?  wrong format, just return FALSE
     //
     if (!is_array($plugin_dependencies)) {
         return FALSE;
     }
     // make sure everything is in order...
     //
     if (!empty($plugin_dependencies)) {
         $new_plugin_dependencies = array();
         foreach ($plugin_dependencies as $plugin_name => $plugin_requirements) {
             // if $plugin_requirements isn't an array, this is old-style,
             // where only the version number was given...
             //
             if (is_string($plugin_requirements)) {
                 $plugin_requirements = array('version' => $plugin_requirements, 'activate' => FALSE);
             }
             // trap badly formatted requirements arrays that don't have
             // needed info
             //
             if (!is_array($plugin_requirements) || !isset($plugin_requirements['version'])) {
                 continue;
             }
             if (!isset($plugin_requirements['activate'])) {
                 $plugin_requirements['activate'] = FALSE;
             }
             // parse version into something we understand?
             //
             if ($do_parse) {
                 // massage version number into something we understand
                 //
                 // the first regexp strips everything and anything that follows
                 // the first occurance of a non-digit (or non decimal point), so
                 // beware that putting letters in the middle of a version string
                 // will effectively truncate the version string right there (but
                 // this also just helps remove the SquirrelMail version part off
                 // of versions such as "1.2.3-1.4.4")
                 //
                 // the second regexp just strips out non-digits/non-decimal points
                 // (and might be redundant(?))
                 //
                 // the regexps are wrapped in a trim that makes sure the version
                 // does not start or end with a decimal point
                 //
                 $plugin_requirements['version'] = trim(preg_replace(array('/[^0-9.]+.*$/', '/[^0-9.]/'), '', $plugin_requirements['version']), '.');
             }
             $new_plugin_dependencies[$plugin_name] = $plugin_requirements;
         }
         $plugin_dependencies = $new_plugin_dependencies;
     }
     return $plugin_dependencies;
 }
Ejemplo n.º 3
0
             foreach ($hooked_plugins as $hooked_plugin => $hooked_function) {
                 if ($hooked_plugin == $name && (empty($static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin]) || $static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin] != $hooked_function)) {
                     do_err('The plugin <i>' . $name . '</i> is supposed to be registered on the <i>' . $hook_name . '</i> hook, but it is not.  You need to re-run the configuration utility and re-save your configuration file.', FALSE);
                 }
             }
         }
     }
 }
 $squirrelmail_plugin_hooks = $static_squirrelmail_plugin_hooks;
 /**
  * Print plugin versions
  */
 echo $IND . "Plugin versions...<br />\n";
 foreach ($plugins as $name) {
     $plugin_version = get_plugin_version($name);
     $english_name = get_plugin_requirement($name, 'english_name');
     echo $IND . $IND . (empty($english_name) ? $name . ' ' : $english_name . ' (' . $name . ') ') . (empty($plugin_version) ? '??' : $plugin_version) . "<br />\n";
     // check if this plugin has any other plugin
     // dependencies and if they are satisfied
     //
     $failed_dependencies = check_plugin_dependencies($name);
     if ($failed_dependencies === SQ_INCOMPATIBLE) {
         do_err($name . ' is NOT COMPATIBLE with this version of SquirrelMail', FALSE);
     } else {
         if (is_array($failed_dependencies)) {
             $missing_plugins = '';
             $incompatible_plugins = '';
             foreach ($failed_dependencies as $depend_name => $depend_requirements) {
                 if ($depend_requirements['version'] == SQ_INCOMPATIBLE) {
                     $incompatible_plugins .= ', ' . $depend_name;
                 } else {