Beispiel #1
0
/**
 * 
 * Determine if the plugin should be installed or upgraded
 * 
 * Returns 0 if the plugin is not yet installed
 * Returns 1 if the plugin is already installed
 * 
 * @since 1.3
 * 
 * @return number
 */
function plugin_simcard_currentVersion()
{
    // Saves the current version to not re-detect it on multiple calls
    static $currentVersion = null;
    if ($currentVersion === null) {
        // result not cached
        if (!TableExists('glpi_plugin_simcard_simcards_items') && !TableExists('glpi_plugin_simcard_configs')) {
            // the plugin seems not installed
            $currentVersion = 0;
        } else {
            if (TableExists('glpi_plugin_simcard_configs')) {
                // The plugin is at least 1.3
                // Get the current version in the plugin's configuration
                $pluginSimcardConfig = new PluginSimcardConfig();
                $currentVersion = $pluginSimcardConfig->getValue('Version');
            }
            if ($currentVersion == '') {
                // The plugin is older than 1.3
                $currentVersion = '1.2';
            }
        }
    }
    return $currentVersion;
}