Example #1
0
function displayForm($originPage, $defaultOutputDir, $checkReportsDirError, $isJob2, $isJob3, $isJob4, $isJob5, $job2, $job3, $job4, $job5, $job_support, $job_sideTasks, $jobSupport_color, $jobNA_color, $job2_color, $job3_color, $job4_color, $job5_color, $projectList, $groupExtID, $extIdCustomFieldCandidates, $extIdCustomField, $userList, $admin_id, $statusList, $status_new, $status_feedback, $status_open, $status_closed, $is_modified = "false")
{
    checkMantisPluginDir();
    echo "<form id='form1' name='form1' method='post' action='{$originPage}' >\n";
    // ------ Reports
    echo "<h2>" . T_("Path to output files") . "</h2>\n";
    echo "<span class='help_font'>" . T_("Path to log files and other temporary files.") . "<br>" . T_("Note: <b>/var/local/codevtt</b> is a good location for this, but you'll need to create it first and give read/write access.") . "</span><br><br>\n";
    echo "<code><input size='50' type='text' style='font-family: sans-serif' name='outputDir'  id='outputDir' value='{$defaultOutputDir}'></code></td>\n";
    echo "<input type=button value='" . T_("Check") . "' onClick='javascript: checkReportsDir()'>\n";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;";
    if (!is_null($checkReportsDirError)) {
        if (FALSE === strstr($checkReportsDirError, "SUCCESS")) {
            echo "<span class='error_font'>{$checkReportsDirError}</span>\n";
        } else {
            echo "<span class='success_font'>{$checkReportsDirError}</span>\n";
        }
    }
    echo "  <br/>\n";
    echo "  <br/>\n";
    // ------ Status
    echo "<h2>" . T_("Workflow") . "</h2>\n";
    echo "<span class='help_font'>" . T_("Set equivalences in accordance to your Mantis workflow") . "</span><br><br>\n";
    echo '<table class="invisible">';
    echo '<tr>';
    echo '<td>Status NEW</td>';
    echo '<td>';
    echo '<select id="status_new" name="status_new">' . "<br>\n";
    foreach ($statusList as $statusid => $name) {
        if ($status_new == $statusid) {
            echo "<option value='{$statusid}' selected='selected'>{$name}</option>\n";
        } else {
            echo "<option value='{$statusid}'>{$name}</option>\n";
        }
    }
    echo '</select>';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Status FEEDBACK</td>';
    echo '<td>';
    echo '<select id="status_feedback" name="status_feedback">' . "<br>\n";
    foreach ($statusList as $statusid => $name) {
        if ($status_feedback == $statusid) {
            echo "<option value='{$statusid}' selected='selected'>{$name}</option>\n";
        } else {
            echo "<option value='{$statusid}'>{$name}</option>\n";
        }
    }
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Status OPEN</td>';
    echo '<td>';
    echo '<select id="status_open" name="status_open">' . "<br>\n";
    foreach ($statusList as $statusid => $name) {
        if ($status_open == $statusid) {
            echo "<option value='{$statusid}' selected='selected'>{$name}</option>\n";
        } else {
            echo "<option value='{$statusid}'>{$name}</option>\n";
        }
    }
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Status CLOSED</td>';
    echo '<td>';
    echo '<select id="status_closed" name="status_closed">' . "<br>\n";
    foreach ($statusList as $statusid => $name) {
        if ($status_closed == $statusid) {
            echo "<option value='{$statusid}' selected='selected'>{$name}</option>\n";
        } else {
            echo "<option value='{$statusid}'>{$name}</option>\n";
        }
    }
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    // ------ Administrator
    echo "<h2>" . T_("CodevTT Administrator") . "</h2>\n";
    echo '<select id="codevttAdmin" name="codevttAdmin">' . "<br>\n";
    #echo '   <option value="0"> </option>'."\n";
    foreach ($userList as $userid => $name) {
        if ($admin_id == $userid) {
            echo "<option value='{$userid}' selected='selected'>{$name}</option>\n";
        } else {
            echo "<option value='{$userid}'>{$name}</option>\n";
        }
    }
    echo '</select>';
    echo "&nbsp;&nbsp;&nbsp;&nbsp;<span class='help_font'>" . T_("More administrators can be defined later, for now you just need one.") . "</span>\n";
    echo "<br><br>\n";
    // ------- External ID
    echo "<h2>" . T_("Tasks external ID field") . "</h2>";
    echo "<div align='left'>\n";
    echo "<script type='text/javascript'>\n";
    echo "\n      function setCheckedValue(radioObj, newValue) {\n         if(!radioObj)\n            return;\n         var radioLength = radioObj.length;\n         if(radioLength == undefined) {\n            radioObj.checked = (radioObj.value == newValue.toString());\n            return;\n         }\n         for(var i = 0; i < radioLength; i++) {\n            radioObj[i].checked = false;\n            if(radioObj[i].value == newValue.toString()) {\n               radioObj[i].checked = true;\n            }\n         }\n      }\n   ";
    echo "</script>";
    $checked = 'createExtID' === $groupExtID ? 'CHECKED' : '';
    echo "<input type='radio' name='groupExtID' value='createExtID' {$checked} > " . T_("Create a new CustomField") . "<br>\n";
    $checked = 'createExtID' !== $groupExtID ? 'CHECKED' : '';
    echo "<input type='radio' name='groupExtID' value='existingExtID' {$checked} > " . T_("Use this CustomField :") . "\n";
    echo '<select id="extIdCustomField" name="extIdCustomField" onChange="javascript:setCheckedValue(document.forms[\'form1\'].elements[\'groupExtID\'], \'existingExtID\');">' . "\n";
    echo '   <option value="0"> </option>' . "\n";
    foreach ($extIdCustomFieldCandidates as $fieldid => $fname) {
        if ($extIdCustomField == $fieldid) {
            echo "<option value='{$fieldid}'  selected='selected'>{$fname}</option>\n";
        } else {
            echo "<option value='{$fieldid}'>{$fname}</option>\n";
        }
    }
    echo '</select><br>';
    #echo "<input type='radio' name='groupExtID' value='noExtID' > ".T_("I don't need any").'<br>';
    echo "</div>\n";
    // ------ Default ExternalTasks
    /*
      echo "<h2>".T_("Default ExternalTasks")."</h2>\n";
      echo "<table class='invisible'>\n";
      echo "  <tr>\n";
      echo "    <td width='100'><input type=CHECKBOX  CHECKED DISABLED name='cb_taskLeave' id='cb_taskLeave'>".
           T_("Absence")."</input></td>\n";
      echo "    <td><input size='40' type='text' name='task_leave'  id='task_leave' value='$task_leave'></td>\n";
      echo "  </tr>\n";
    */
    // ------
    echo "  <br/>\n";
    echo "<h2>" . T_("Default Jobs") . "</h2>\n";
    echo "<table class='invisible'>\n";
    echo "  <tr>\n";
    echo "    <td width='10'><input type=CHECKBOX CHECKED DISABLED name='cb_job_support' id='cb_support' /></td>\n";
    echo "    <td>";
    echo "         <table class='invisible'><tr>";
    echo "            <td width='70'>{$job_support}</td>";
    echo "            <td><span class='help_font'>" . T_("CodevTT support management") . "</span></td>";
    echo "         </tr></table>";
    echo "    </td>\n";
    echo "    <td>" . T_("Color") . ": <input name='jobSupport_color' id='jobSupport_color' type='text' value='{$jobSupport_color}' size='6' maxlength='6' style='background-color: #{$jobSupport_color};' onblur='javascript: refresh()'>";
    echo "   &nbsp;&nbsp;&nbsp;<a href='http://www.colorpicker.com' target='_blank' title='" . T_("open a colorPicker in a new Tab") . "'>ColorPicker</A></td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td width='10'><input type=CHECKBOX CHECKED DISABLED name='cb_job_support' id='cb_support' /></td>\n";
    echo "    <td>";
    echo "         <table class='invisible'><tr>";
    echo "            <td width='70'>{$job_sideTasks}</td>";
    echo "            <td><span class='help_font'>" . T_("Specific to SideTasks") . "</span></td>";
    echo "         </tr></table>";
    echo "    </td>\n";
    echo "    <td>" . T_("Color") . ":  <input name='jobNA_color' id='jobNA_color' type='text' value='{$jobNA_color}' size='6' maxlength='6' style='background-color: #{$jobNA_color};' onblur='javascript: refresh()'></td>";
    echo "  </tr>\n";
    $isChecked = $isJob2 ? "CHECKED" : "";
    echo "    <td width='10'><input type=CHECKBOX  {$isChecked} name='cb_job2' id='cb_job2' /></td>\n";
    echo '    <td><input size="40" type="text" name="job2"  id="job2" value="' . $job2 . '"></td>' . "\n";
    echo "    <td>" . T_("Color") . ": <input name='job2_color' id='job2_color' type='text' value='{$job2_color}' size='6' maxlength='6' style='background-color: #{$job2_color};' onblur='javascript: refresh()'></td>\n";
    echo "  </tr>\n";
    $isChecked = $isJob3 ? "CHECKED" : "";
    echo "    <td width='10'><input type=CHECKBOX  {$isChecked} name='cb_job3' id='cb_job3' /></td>\n";
    echo '    <td><input size="40" type="text" name="job3"  id="job3" value="' . $job3 . '"></td>' . "\n";
    echo "    <td>" . T_("Color") . ": <input name='job3_color' id='job3_color' type='text' value='{$job3_color}' size='6' maxlength='6' style='background-color: #{$job3_color};' onblur='javascript: refresh()'></td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    $isChecked = $isJob4 ? "CHECKED" : "";
    echo "    <td width='10'><input type=CHECKBOX  {$isChecked} name='cb_job4' id='cb_job4' /></td>\n";
    echo '    <td><input size="40" type="text" name="job4"  id="job4" value="' . $job4 . '"></td>' . "\n";
    echo "    <td>" . T_("Color") . ": <input name='job4_color' id='job4_color' type='text' value='{$job4_color}' size='6' maxlength='6' style='background-color: #{$job4_color};' onblur='javascript: refresh()'></td>\n";
    echo "  </tr>\n";
    $isChecked = $isJob5 ? "CHECKED" : "";
    echo "    <td width='10'><input type=CHECKBOX  {$isChecked} name='cb_job5' id='cb_job5' /></td>\n";
    echo '    <td><input size="40" type="text" name="job5"  id="job5" value="' . $job5 . '"></td>' . "\n";
    echo "    <td>" . T_("Color") . ": <input name='job5_color' id='job5_color' type='text' value='{$job5_color}' size='6' maxlength='6' style='background-color: #{$job5_color};' onblur='javascript: refresh()'></td>\n";
    echo "  </tr>\n";
    echo "</table>\n";
    // ------ Add custom fields to existing projects
    echo "  <br/>\n";
    echo "<h2>" . T_("Configure existing Projects") . "</h2>\n";
    echo "<span class='help_font'>" . T_("Select the projects to be managed with CodevTT") . "</span><br/>\n";
    echo "  <br/>\n";
    echo "<select name='projects[]' multiple size='5'>\n";
    foreach ($projectList as $id => $name) {
        echo "<option selected value='{$id}'>{$name}</option>\n";
    }
    echo "</select>\n";
    echo "  <br/>\n";
    echo "  <br/>\n";
    echo "<div  style='text-align: center;'>\n";
    echo "<input type=button style='font-size:150%' value='" . T_("Proceed Step 3") . "' onClick='javascript: proceedStep3()'>\n";
    echo "</div>\n";
    // ------
    echo "<input type=hidden name=action      value=noAction>\n";
    echo "<input type=hidden name=is_modified value={$is_modified}>\n";
    echo "</form>";
}
Example #2
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;
    }
}