Example #1
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
         // Admins only
         if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $this->smartyHelper->assign('access', true);
             $is_modified = Tools::getSecurePOSTStringValue('is_modified', 'false');
             // init
             // 'is_modified' is used because it's not possible to make a difference
             // between an unchecked checkBox and an unset checkbox variable
             if ("false" == $is_modified) {
                 $isBackup = true;
             } else {
                 $isBackup = $_POST['cb_backup'];
             }
             $filename = Tools::getSecurePOSTStringValue('backup_filename', "codevtt_backup_" . date("Ymd") . ".sql");
             $this->smartyHelper->assign('isBackup', $isBackup);
             $this->smartyHelper->assign('filename', $filename);
             if (isset($_POST['cb_backup'])) {
                 $result = true;
                 if ($isBackup) {
                     $result = SqlWrapper::getInstance()->sql_dump($filename) && $this->saveConfigFiles();
                     $this->smartyHelper->assign('backupResult', $result);
                 }
                 $this->smartyHelper->assign('stepOneResult', $result);
                 if ($result) {
                     $prjList = $this->displayProjectsToRemove();
                     $this->smartyHelper->assign('projects', $prjList);
                 }
                 $this->smartyHelper->assign('stepTwoResult', $result);
                 if ($result) {
                     $result = $this->removeCustomFields();
                 }
                 $this->smartyHelper->assign('stepThreeResult', $result);
                 if ($result) {
                     $result = Tools::execSQLscript2("uninstall.sql");
                 }
                 $this->smartyHelper->assign('stepFourResult', $result);
                 if ($result) {
                     $result = $this->deleteConfigFiles();
                 }
                 $this->smartyHelper->assign('stepFiveResult', $result);
                 if ($result) {
                     $result = $this->removeCustomMenuItem('CodevTT');
                 }
                 $this->smartyHelper->assign('stepSixResult', $result);
             } else {
                 Config::setQuiet(true);
                 $this->smartyHelper->assign('codevReportsDir', Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports');
                 Config::setQuiet(false);
                 $this->smartyHelper->assign('is_modified', $is_modified);
             }
         }
     }
 }
Example #2
0
/**
 * update 1.0.x to 1.1.0 (DB v14 to DB v15)
 *
 */
function update_v14_to_v15()
{
    echo "- Update classmap.ser<br>";
    try {
        Tools::createClassMap();
    } catch (Exception $e) {
        echo "<span class='error_font'>Could not create classmap: " . $e->getMessage() . "</span><br/>";
        exit;
    }
    $sqlScriptFilename = '../install/codevtt_update_v14_v15.sql';
    if (!file_exists($sqlScriptFilename)) {
        echo "<span class='error_font'>SQL script not found:{$sqlScriptFilename}</span><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;
    }
}
Example #3
0
/**
 * update 1.0.x to 1.1.0 (DB v14 to DB v15)
 *
 * - clasmap.ser
 * - config.ini
 * - remove from mantis menu
 * - mantis-plugins if mantis v1.3
 * - DB
 */
function update_v14_to_v15()
{
    echo "- Update classmap.ser<br>";
    try {
        Tools::createClassMap();
    } catch (Exception $e) {
        echo "<span class='error_font'>Could not create classmap: " . $e->getMessage() . "</span><br/>";
        exit;
    }
    echo "- Add [mantis] 'status_enum_workflow' to config.ini<br>";
    // reload mantis config files
    $path_config_defaults_inc = Constants::$mantisPath . DIRECTORY_SEPARATOR . "config_defaults_inc.php";
    $path_core_constant_inc = Constants::$mantisPath . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "constant_inc.php";
    $path_mantis_config = Constants::$mantisPath;
    if (is_dir(Constants::$mantisPath . DIRECTORY_SEPARATOR . 'config')) {
        $path_mantis_config .= DIRECTORY_SEPARATOR . 'config';
        // mantis v1.3 or higher
    }
    $path_mantis_config_inc = $path_mantis_config . DIRECTORY_SEPARATOR . 'config_inc.php';
    $path_custom_constants = $path_mantis_config . DIRECTORY_SEPARATOR . 'custom_constants_inc.php';
    global $g_status_enum_workflow;
    include_once $path_core_constant_inc;
    include_once $path_custom_constants;
    include_once $path_config_defaults_inc;
    include_once $path_mantis_config_inc;
    // set status_enum_workflow
    Constants::$status_enum_workflow = $g_status_enum_workflow;
    if (!is_array(Constants::$status_enum_workflow)) {
        echo "<span class='error_font'>Could not retrieve status_enum_workflow from Mantis config files</span><br/>";
        exit;
    }
    // write new config file
    if (!update_config_file()) {
        // ask for manual update
        echo "<span class='error_font'>Could not update config.ini</span><br/>";
        exit;
    }
    // if Mantis 1.3, plugins must be updated
    if (Tools::isMantisV1_3()) {
        echo "- Remove 'CodevTT' from Mantis main menu (CodevTT v1.0.x is incompatible with Mantis v1.3.x)<br>";
        $query = "DELETE FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'";
        $result = execQuery($query);
        echo "- Install Mantis plugin: CodevTT (for mantis v1.3.x)<br>";
        if (checkMantisPluginDir()) {
            $errStr = installMantisPlugin('CodevTT', true);
            if (NULL !== $errStr) {
                echo "<span class='error_font'>Please update 'CodevTT' mantis-plugin manualy</span><br/>";
                echo "<script type=\"text/javascript\">console.error(\"{$errStr}\");</script>";
            }
            echo "- Install Mantis plugin: FilterBugList (for mantis v1.3.x)<br>";
            $errStr = installMantisPlugin('FilterBugList', true);
            if (NULL !== $errStr) {
                echo "<span class='error_font'>Please update 'FilterBugList' mantis-plugin manualy</span><br/>";
                echo "<script type=\"text/javascript\">console.error(\"{$errStr}\");</script>";
            }
        }
    }
    // execute the SQL script
    $sqlScriptFilename = Constants::$codevRootDir . '/install/codevtt_update_v14_v15.sql';
    if (!file_exists($sqlScriptFilename)) {
        echo "<span class='error_font'>SQL script not found:{$sqlScriptFilename}</span><br/>";
        exit;
    }
    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;
    }
}