37338-vm/patch_save_def.php
2026-03-02 19:32:17 +00:00

44 lines
2.0 KiB
PHP

<?php
$content = file_get_contents('_save_process_definition.php');
// We need to add subject_scope extraction and insert/update
$content = str_replace(
"$definition_json = $_POST['definition_json'] ?? '';",
"$definition_json = $_POST['definition_json'] ?? '';\n $subject_scope = $_POST['subject_scope'] ?? 'person';",
$content
);
$content = str_replace(
"$sql = 'INSERT INTO process_definitions (name, code, definition_json, start_node_id, is_active, version, is_latest) VALUES (?, ?, ?, ?, 1, 1, 1)';",
"$sql = 'INSERT INTO process_definitions (name, code, definition_json, start_node_id, is_active, version, is_latest, subject_scope) VALUES (?, ?, ?, ?, 1, 1, 1, ?)';",
$content
);
$content = str_replace(
"$params = [ $name, $code, $definition_json, $start_node ];",
"$params = [ $name, $code, $definition_json, $start_node, $subject_scope ];",
$content
);
$content = str_replace(
"$stmt_old = $pdo->prepare('SELECT code, version, sort_order, is_active FROM process_definitions WHERE id = ?');",
"$stmt_old = $pdo->prepare('SELECT code, version, sort_order, is_active, subject_scope FROM process_definitions WHERE id = ?');",
$content
);
$content = str_replace(
"$sql = 'INSERT INTO process_definitions (name, code, definition_json, start_node_id, is_active, version, supersedes_definition_id, is_latest, sort_order) VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?)';",
"$sql = 'INSERT INTO process_definitions (name, code, definition_json, start_node_id, is_active, version, supersedes_definition_id, is_latest, sort_order, subject_scope) VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?, ?)';",
$content
);
$content = str_replace(
"$params = [ $name, $db_code, $definition_json, $start_node, $is_active, $new_version, $processId, $old['sort_order'] ];",
"$params = [ $name, $db_code, $definition_json, $start_node, $is_active, $new_version, $processId, $old['sort_order'], $subject_scope ];",
$content
);
file_put_contents('_save_process_definition.php', $content);
echo "Patched _save_process_definition.php\n";