function handle_change_staged_req()
{
    global $enable_stats;
    echo html_header_message('checking, before handling staging...');
    echo html_form_start();
    $status = get_status(true, false, false);
    if ($status['hash'] != $_POST['statushash']) {
        error('something changed in the directory and/or repository, not doing any changes ! Sorry');
    } else {
        echo html_header_message_update('doing staging/unstaging...');
        $num1 = 0;
        $num2 = 0;
        $arr = array();
        foreach ($status['lines'] as $v) {
            $arr[] = $v['file'];
        }
        $poststaged = array();
        if (isset($_POST['stagecheckbox'])) {
            foreach ($_POST['stagecheckbox'] as $v) {
                $key = array_search($v, $_POST['hash']);
                if ($key !== false) {
                    $poststaged[$key] = 'Y';
                }
            }
        }
        $max = count($_POST['filename']);
        if ($max !== count($arr)) {
            staged_change_checker_error();
        }
        for ($i = 0; $i < $max; $i++) {
            if ($_POST['filename'][$i] !== $arr[$i]) {
                staged_change_checker_error();
            }
            if ($status['lines'][$i]['staged'] == 'N' && isset($poststaged[$i]) && $poststaged[$i] == 'Y') {
                stage_file($arr[$i], $status['lines'][$i]);
            }
            if ($status['lines'][$i]['staged'] == 'Y' && !isset($poststaged[$i])) {
                unstage_file($arr[$i], $status['lines'][$i]);
            }
            echo html_js_remove_container($status['lines'][$i]['prefix']);
        }
        $status = get_status(false, true, $enable_stats);
    }
    view_result($status);
    echo html_header_message_update('doing staging/unstaging... done');
}
Exemple #2
0
function stage_files(&$jobs, $template)
{
    foreach ($jobs as $job) {
        foreach ($job->input_files as $file) {
            if ($file->mode != "remote") {
                $file->name = stage_file($file);
            }
        }
    }
}