Example #1
0
/**
 * copy plugin in mantis plugins directory
 *
 * @return bool true if success
 */
function installMantisPlugin($pluginName, $isReplace = true)
{
    try {
        $mantisPluginDir = Constants::$mantisPath . DIRECTORY_SEPARATOR . 'plugins';
        $srcDir = realpath("..") . DIRECTORY_SEPARATOR . 'mantis_plugin' . DIRECTORY_SEPARATOR . $pluginName;
        $destDir = $mantisPluginDir . DIRECTORY_SEPARATOR . $pluginName;
        if (!is_writable($mantisPluginDir)) {
            echo "<span class='warn_font'>Path to mantis plugins directory '" . $mantisPluginDir . "' is NOT writable: {$pluginName} plugin must be installed manualy.</span><br/>";
            return false;
        }
        // do not replace if already installed
        if (!$isReplace && is_dir($destDir)) {
            echo "<span class='success_font'>Mantis {$pluginName} plugin is already installed.</span><br/>";
            return true;
        }
        // remove previous installed CodevTT plugin
        if (is_writable($destDir)) {
            Tools::deleteDir($destDir);
        }
        // copy CodevTT plugin
        if (is_dir($srcDir)) {
            $result = Tools::recurse_copy($srcDir, $destDir);
        } else {
            echo "<span class='error_font'>plugin directory '" . $srcDir . "' NOT found: {$pluginName} plugin must be installed manualy.</span><br/>";
            return false;
        }
        if (!$result) {
            echo "<span class='error_font'>mantis plugin installation failed: {$pluginName} plugin must be installed manualy.</span><br/>";
        }
        // activate plugin
        $query = "INSERT INTO mantis_plugin_table (basename, enabled, protected, priority)" . " SELECT * FROM (SELECT '{$pluginName}', '1', '0', '3') AS tmp" . " WHERE NOT EXISTS (" . " SELECT basename FROM mantis_plugin_table WHERE basename = '{$pluginName}') LIMIT 1;";
        $result = SqlWrapper::getInstance()->sql_query($query);
        if (!$result) {
            echo "<span class='warn_font'>mantis {$pluginName} plugin must be activated manualy.</span><br/>";
        }
    } catch (Exception $e) {
        echo "<span class='error_font'>mantis plugin installation failed: " . $e->getMessage() . "</span><br/>";
        echo "<span class='error_font'>{$pluginName} plugin must be installed manualy.</span><br/>";
        $result = false;
    }
    return $result;
}
Example #2
0
/**
 * update 0.99.24 to 0.99.25 (DB v12 to DB v13)
 * update mantis plugin 0.3 -> 0.4
 *
 */
function update_v12_to_v13()
{
    $sqlScriptFilename = '../install/codevtt_update_v12_v13.sql';
    if (!file_exists($sqlScriptFilename)) {
        echo "ERROR: SQL script not found:{$sqlScriptFilename}<br>";
        exit;
    }
    // execute the SQL script
    echo "- Execute SQL script:{$sqlScriptFilename}<br>";
    $retCode = Tools::execSQLscript2($sqlScriptFilename);
    if (0 != $retCode) {
        echo "<span class='error_font'>Could not execSQLscript: {$sqlScriptFilename}</span><br/>";
        exit;
    }
    // update mantis plugin 0.3 -> 0.4
    try {
        $mantisPluginDir = Constants::$mantisPath . DIRECTORY_SEPARATOR . 'plugins';
        $srcDir = Constants::$codevRootDir . DIRECTORY_SEPARATOR . 'mantis_plugin' . DIRECTORY_SEPARATOR . 'CodevTT';
        $destDir = $mantisPluginDir . DIRECTORY_SEPARATOR . 'CodevTT';
        if (!is_writable($mantisPluginDir)) {
            echo "<br><span class='warn_font'>WARN: <b>'" . $mantisPluginDir . "'</b> directory is <b>NOT writable</b>: Please update the mantis plugin manualy.</span><br>";
            return false;
        }
        // remove previous installed CodevTT plugin
        if (is_writable($destDir)) {
            Tools::deleteDir($destDir);
        } else {
            echo "<br><span class='warn_font'>WARN: <b>'" . $destDir . "'</b> directory is <b>NOT writable</b>: Please update the mantis plugin manualy.</span><br>";
            return false;
        }
        // copy CodevTT plugin
        if (is_dir($srcDir)) {
            $result = Tools::recurse_copy($srcDir, $destDir);
            if (!$result) {
                echo "<br><span class='warn_font'>mantis plugin installation failed: CodevTT plugin must be updated manualy.</span><br>";
                return false;
            }
        } else {
            echo "<br><span class='warn_font'>plugin directory '" . $srcDir . "' NOT found: Please update the mantis plugin manualy.</span><br>";
            return false;
        }
    } catch (Exception $e) {
        echo "<span class='warn_font'>mantis plugin installation failed: " . $e->getMessage() . "</span><br>";
        echo "<span class='warn_font'>mantis plugin must be installed manualy.</span><br>";
        return false;
    }
    #echo "<br>SUCCESS: Update 0.99.24 to 0.99.25 (DB v12 to DB v13)<br>";
    return TRUE;
}
Example #3
0
/**
 * copy plugin in mantis plugins directory
 * info: same functyion exists in install_step3.php
 * @return NULL or error string
 */
function installMantisPlugin($pluginName, $isReplace = true)
{
    try {
        $mantisPluginDir = Constants::$mantisPath . DIRECTORY_SEPARATOR . 'plugins';
        // --- check mantis version (config files have been moved in v1.3)
        if (is_dir(Constants::$mantisPath . DIRECTORY_SEPARATOR . 'config')) {
            // mantis v1.3 or higher
            $srcDir = Constants::$codevRootDir . DIRECTORY_SEPARATOR . 'mantis_plugin' . DIRECTORY_SEPARATOR . 'mantis_1_3' . DIRECTORY_SEPARATOR . $pluginName;
        } else {
            // mantis 1.2
            $srcDir = Constants::$codevRootDir . DIRECTORY_SEPARATOR . 'mantis_plugin' . DIRECTORY_SEPARATOR . 'mantis_1_2' . DIRECTORY_SEPARATOR . $pluginName;
        }
        $destDir = $mantisPluginDir . DIRECTORY_SEPARATOR . $pluginName;
        if (!is_writable($mantisPluginDir)) {
            return "ERROR Path to mantis plugins directory '" . $mantisPluginDir . "' is NOT writable: {$pluginName} plugin must be installed manualy.";
        }
        if (!is_dir($srcDir)) {
            return "ERROR mantis plugin directory '" . $srcDir . "' NOT found !";
        }
        // do not replace if already installed
        if (!$isReplace && is_dir($destDir)) {
            echo "<script type=\"text/javascript\">console.info(\"INFO Mantis {$pluginName} plugin is already installed\");</script>";
            return NULL;
        }
        // remove previous installed plugin
        if (is_writable($destDir)) {
            Tools::deleteDir($destDir);
        }
        // copy plugin
        if (is_dir($srcDir)) {
            $result = Tools::recurse_copy($srcDir, $destDir);
        } else {
            return "ERROR: plugin directory '" . $srcDir . "' NOT found: {$pluginName} plugin must be installed manualy";
        }
        if (!$result) {
            return "ERROR: mantis plugin installation failed: {$pluginName} plugin must be installed manualy";
        }
        // activate plugin
        $query = "INSERT INTO mantis_plugin_table (basename, enabled, protected, priority)" . " SELECT * FROM (SELECT '{$pluginName}', '1', '0', '3') AS tmp" . " WHERE NOT EXISTS (" . " SELECT basename FROM mantis_plugin_table WHERE basename = '{$pluginName}') LIMIT 1;";
        $result = SqlWrapper::getInstance()->sql_query($query);
        if (!$result) {
            return "WARNING: mantis {$pluginName} plugin must be activated manualy";
        }
    } catch (Exception $e) {
        echo "<script type=\"text/javascript\">console.error(\"ERROR mantis plugin installation failed: " . $e->getMessage() . "\");</script>";
        return "ERROR: mantis {$pluginName} plugin installation failed: " . $e->getMessage();
    }
    return NULL;
}