Skip to content

Change Service Status Announcements Developer Guide

Ed Mozley edited this page Dec 5, 2026 · 1 revision

Change Service Status announcements - Developer Guide

How a change announces its outage on Service Status as planned maintenance: the column that links the two, the service methods, the endpoint, the section on the change page, and the back link on the Service Status board.

For what it does from a user's point of view, see Change Management - Announcing a change's outage on Service Status. Built by @Dr4inder in PR #511.


In plain words

Planned maintenance already existed (3.2.0): a row in status_planned that shows as upcoming, becomes an ordinary incident at its start and is resolved at its end. Projects could already make one from their Connections tab, and the row remembered which project it came from in status_planned.project_id.

This feature is the same thing for a change. A new nullable column, status_planned.change_id, says which change announced a row. Everything else - the save, the start, the finish, the board, the portal - is the existing planned-maintenance code, unchanged in behaviour. ChangesService::announce() is a deliberate twin of ProjectToolsService::announce().


The shape of it

File Job
includes/service_status_planned.php The planned-maintenance engine. New here: statusPlannedChangeReady() (is the column there yet?), statusPlannedChoices() (services + impact levels for a dialog, shared with Projects), change_id in statusPlannedSave() and statusPlannedList()
includes/services/changes.php ChangesService::announce(), withdrawAnnouncement(), announcements() and the private assertServiceStatus()
api/change-management/announce.php POST only. action = announce or withdraw. A thin adapter: returns the section's data again
api/change-management/get.php adds announcements to the change - null when there is no section to draw
api/service-status/planned.php Service Status's own endpoint - now strips change_id as well as project_id
assets/js/change-management.js renderChangeAnnouncements(), the dialog functions, and the timeline line for action_type = 'announcement'
change-management/index.php the #announceModal dialog; change-management.js?v=52
service-status/index.php renderPlanned() draws From the change CHG-0012
includes/services/project_tools.php ProjectToolsService::announcements() now uses statusPlannedChoices() instead of its own two queries
database/freeitsm.sql, includes/db_verify_schema.php, includes/db_verify_indexes.php, api/system/db_verify.php the column, its index ix_sp_change and its foreign key fk_sp_change
lang/en/change-management.php the announce block, and help.rec_announce_note
lang/en/service-status.php planned.from_change
tests/change-announce-maintenance.php 20 checks - announce, list, withdraw, refusals

The schema

One column, one index, one foreign key, on the existing table. From database/freeitsm.sql:

-- project_id: the project that announced it (Projects -> Connections).
-- change_id: the change that announced it (a change's Service Status section).
-- ----------------------------------------------------------
CREATE TABLE IF NOT EXISTS `status_planned` (
    `id`                      INT NOT NULL AUTO_INCREMENT,
    ...
    `state`                   VARCHAR(12) NOT NULL DEFAULT 'scheduled',
    `incident_id`             INT NULL,
    `project_id`              INT NULL,
    `change_id`               INT NULL,
    `created_by_id`           INT NULL,
    ...
    PRIMARY KEY (`id`),
    KEY `ix_sp_state_start` (`state`, `planned_start_datetime`),
    KEY `ix_sp_project` (`project_id`),
    KEY `ix_sp_change` (`change_id`),
    CONSTRAINT `fk_sp_incident` FOREIGN KEY (`incident_id`) REFERENCES `status_incidents` (`id`) ON DELETE SET NULL,
    CONSTRAINT `fk_sp_project` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE SET NULL,
    CONSTRAINT `fk_sp_change` FOREIGN KEY (`change_id`) REFERENCES `changes` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Database Verification creates the same on an upgrade. The column, in includes/db_verify_schema.php:

        'project_id'             => 'INT NULL',
        'change_id'              => 'INT NULL',   // the change that announced it

The index, in includes/db_verify_indexes.php (a generated file - see the trap below):

    ['status_planned', 'ix_sp_change', 'key', '(`change_id`)'],

The foreign key, in api/system/db_verify.php:

        // The same for a change's announcement: it stays on Service Status if the change goes.
        ['status_planned', 'fk_sp_change', "ALTER TABLE status_planned ADD CONSTRAINT fk_sp_change FOREIGN KEY (change_id) REFERENCES changes (id) ON DELETE SET NULL"],

Why ON DELETE SET NULL, not CASCADE. An announcement is real work on real services, and once it has started it owns an incident with its own history. Deleting the change must not take the outage off Service Status; it only stops saying where it came from. This is the same rule as fk_sp_project.

There is no tenant_id on status_planned: Service Status is install-wide, so the services offered are every active service, not the change's company's. announce() says so in its docblock.


The column guard: statusPlannedChangeReady()

An install runs the new code the moment the files are copied, and Database Verification runs later - sometimes days later. Until then, any query that names status_planned.change_id fails, and the one that fails would be the Service Status board, the portal and Watchtower, because they all list planned maintenance. So nothing names the column until it is there:

/**
 * Has Database Verification added status_planned.change_id? An install runs the new code
 * before anyone runs Verification, so nothing may name the column until it is there.
 */
function statusPlannedChangeReady(PDO $conn): bool
{
    static $ready = null;
    if ($ready === null) {
        try { $ready = (bool)$conn->query("SHOW COLUMNS FROM status_planned LIKE 'change_id'")->fetch(PDO::FETCH_ASSOC); }
        catch (Throwable) { $ready = false; }
    }
    return $ready;
}

It is cached per request (static), like statusPlannedReady() beside it. It is used in three places.

1. The list selects NULL AS change_id until the column exists, so every caller of statusPlannedList() - the board, the portal, Watchtower, Projects - keeps working on an unverified install, and a caller asking for one change's rows gets nothing:

function statusPlannedList(PDO $conn, array $opts = []): array
{
    if (!statusPlannedReady($conn)) return [];
    $changeCol = statusPlannedChangeReady($conn);
    if (isset($opts['change_id']) && !$changeCol) return [];
    $states = $opts['states'] ?? ['scheduled', 'started'];
    $states = array_values(array_intersect($states, STATUS_PLANNED_STATES)) ?: ['scheduled'];
    $where = 'p.state IN (' . implode(',', array_fill(0, count($states), '?')) . ')';
    $args = $states;
    if (isset($opts['project_id'])) { $where .= ' AND p.project_id = ?'; $args[] = (int)$opts['project_id']; }
    if (isset($opts['change_id'])) { $where .= ' AND p.change_id = ?'; $args[] = (int)$opts['change_id']; }
    $st = $conn->prepare("SELECT p.id, p.title, p.comment, p.planned_start_datetime, p.planned_end_datetime, p.state, p.incident_id, p.project_id,
                                 " . ($changeCol ? 'p.change_id' : 'NULL AS change_id') . ",
                                 a.full_name AS created_by_name, pr.name AS project_name
                            FROM status_planned p LEFT JOIN analysts a ON a.id = p.created_by_id
                       LEFT JOIN projects pr ON pr.id = p.project_id

and each row carries it as an int or null:

        'change_id' => $r['change_id'] !== null ? (int)$r['change_id'] : null,

2. The save writes the column in its own statement, and only when there is a change to write - so a save from Service Status or from a project never names it:

    $projectId = !empty($in['project_id']) ? (int)$in['project_id'] : null;
    $changeId  = !empty($in['change_id']) ? (int)$in['change_id'] : null;
    if ($changeId !== null && !statusPlannedChangeReady($conn)) throw new ServiceError('validation', 'not_ready', 'Run System - Database Verification first.');
        } else {
            $conn->prepare("INSERT INTO status_planned (title, comment, planned_start_datetime, planned_end_datetime, state, project_id, created_by_id, created_datetime, updated_datetime)
                            VALUES (?, ?, ?, ?, 'scheduled', ?, ?, UTC_TIMESTAMP(), UTC_TIMESTAMP())")
                 ->execute([$title, $comment, $start, $end, $projectId, $ctx->actorId > 0 ? $ctx->actorId : null]);
            $id = (int)$conn->lastInsertId();
            // Its own statement, so a save without a change never names the column.
            if ($changeId !== null) $conn->prepare("UPDATE status_planned SET change_id = ? WHERE id = ?")->execute([$changeId, $id]);
        }

The UPDATE is inside the same transaction as the INSERT, so a row is never committed half-linked.

3. ChangesService::announcements() returns null until the column exists, so the change page draws no section at all rather than one that cannot work (below).

Why the project or change is set only on a new row

Look at the if ($id > 0) branch of statusPlannedSave() - the edit path:

        if ($id > 0) {
            $cur = statusPlannedLoad($conn, $id);
            if ($cur['state'] !== 'scheduled') throw new ServiceError('validation', 'invalid_field', 'It has already started. Change the incident instead.');
            $conn->prepare("UPDATE status_planned SET title = ?, comment = ?, planned_start_datetime = ?, planned_end_datetime = ?, updated_datetime = UTC_TIMESTAMP() WHERE id = ?")
                 ->execute([$title, $comment, $start, $end, $id]);
            $conn->prepare("DELETE FROM status_planned_services WHERE planned_id = ?")->execute([$id]);

It never touches project_id or change_id. Moving an announcement is done with Edit on Service Status, and the Service Status dialog knows nothing about changes - it does not send a change_id. If the edit path wrote the column from the request, every edit on Service Status would quietly unlink the row from its change. Setting the link once, at birth, means "where it came from" can only ever be written by the module it came from. The docblock says so: "The project or change is set only when it is new; a later edit keeps it." The test checks it ("an edit on Service Status keeps the change").


Why Service Status's own endpoint ignores change_id

api/service-status/planned.php is the endpoint the board's Plan and Edit use. It needs only Service Status access - it has no idea whether the caller may write to Changes, or may see that change's company. If it passed change_id through, anyone with Service Status could attach an announcement to any change id, and it would turn up in that change's section and history. So it strips both links before saving:

    if ($action !== 'save') throw new ServiceError('validation', 'invalid_field', 'Unknown action.');
    // A project or change is attached only by Projects (api/projects/tools.php) or
    // Changes (api/change-management/announce.php), which check it.
    unset($in['project_id'], $in['change_id']);
    $id = statusPlannedSave($conn, $ctx, $in);

The only way a change_id reaches statusPlannedSave() is ChangesService::announce(), which has checked the change first.


The service: ChangesService

In includes/services/changes.php, under the heading Planned maintenance on Service Status - twin of ProjectToolsService::announce.

announce()

    public static function announce(PDO $conn, ActorContext $ctx, int $changeId, array $in): int
    {
        self::assertCanWrite($conn, $ctx);
        self::loadJoined($conn, $ctx, $changeId);   // 404 if gone / out of scope
        self::assertServiceStatus($conn, $ctx);
        require_once __DIR__ . '/../service_status_planned.php';
        if (empty($in['start'])) throw new ServiceError('validation', 'missing_field', 'Say when it starts.');
        $id = statusPlannedSave($conn, $ctx, [
            'title'     => $in['title'] ?? '',
            'comment'   => $in['comment'] ?? null,
            'start'     => $in['start'],
            'end'       => $in['end'] ?? null,
            'services'  => is_array($in['services'] ?? null) ? $in['services'] : [],
            'change_id' => $changeId,
        ]);
        self::auditWrite($conn, $changeId, $ctx->actorId, 'announcement', 'Service Status', null, trim((string)($in['title'] ?? '')));
        $conn->prepare("UPDATE changes SET modified_datetime = UTC_TIMESTAMP() WHERE id = ?")->execute([$changeId]);
        return $id;
    }

The three checks, in order:

  1. assertCanWrite() - Read only access to Changes (#180) is refused with read_only.
  2. loadJoined() - the change exists and the actor's company scope reaches it; otherwise 404. This is the only check on the change's company.
  3. assertServiceStatus() - announcing writes to Service Status, so it needs that module too:
    /** Announcing needs Service Status as well as Changes. */
    private static function assertServiceStatus(PDO $conn, ActorContext $ctx): void
    {
        if ($ctx->actorId > 0 && !analystCanAccessModule($conn, $ctx->actorId, 'service-status')) {
            throw new ServiceError('forbidden', 'forbidden', 'You need Service Status to announce maintenance.');
        }
    }

start is required here, not in statusPlannedSave() - the planned-maintenance engine treats a missing start as "now", which is what Projects' Straight away, as an incident mode relies on. A change always announces a window, so it insists on one. Every other rule (title required, at least one service, each service and impact valid, end after start, a start already passed starts at once) is statusPlannedSave()'s, and the same as on the board.

withdrawAnnouncement()

    public static function withdrawAnnouncement(PDO $conn, ActorContext $ctx, int $changeId, int $plannedId): void
    {
        self::assertCanWrite($conn, $ctx);
        self::loadJoined($conn, $ctx, $changeId);
        self::assertServiceStatus($conn, $ctx);
        require_once __DIR__ . '/../service_status_planned.php';
        $row = statusPlannedLoad($conn, $plannedId);
        if ((int)($row['change_id'] ?? 0) !== $changeId) throw new ServiceError('not_found', 'not_found', 'Planned maintenance not found.');
        statusPlannedCancel($conn, $ctx, $plannedId);
        self::auditWrite($conn, $changeId, $ctx->actorId, 'announcement', 'Service Status', $row['title'], null);
        $conn->prepare("UPDATE changes SET modified_datetime = UTC_TIMESTAMP() WHERE id = ?")->execute([$changeId]);
    }

The ownership check is what stops a change you can write from withdrawing an announcement that belongs to another change (or a project, or nobody). It answers not found, not "not yours" - the same answer as a row that does not exist. statusPlannedLoad() is SELECT *, so change_id is in $row once the column exists; the ?? 0 covers an install where it does not. statusPlannedCancel() refuses anything that is no longer scheduled.

The audit rows

Both write one change_audit row with action_type = 'announcement' and field_name = 'Service Status'. Announcing puts the title in new_value; withdrawing puts it in old_value with new_value null. That is how the timeline tells them apart.

announcements() - what the section needs, or null

    public static function announcements(PDO $conn, int $analystId, int $changeId): ?array
    {
        if ($analystId <= 0 || !analystCanAccessModule($conn, $analystId, 'service-status')) return null;
        require_once __DIR__ . '/../service_status_planned.php';
        if (!statusPlannedReady($conn) || !statusPlannedChangeReady($conn)) return null;
        statusPlannedDue($conn);
        return ['list' => statusPlannedList($conn, ['change_id' => $changeId, 'states' => STATUS_PLANNED_STATES, 'limit' => 50])]
            + statusPlannedChoices($conn);
    }
  • null means "draw no section": no Service Status access, no tables, or no column yet. The page checks for null, not for an empty list - an empty list is a section that says Nothing announced on Service Status yet.
  • All four states, not the default two, so the change's section shows Finished and Withdrawn rows too - its history of what customers were told. The board shows only scheduled and started.
  • statusPlannedDue() first, so a row whose start has just passed reads In progress rather than Upcoming. Like the board, this means opening a change can start or finish due maintenance - that is how planned maintenance works without a cron.
  • It takes an analyst id rather than an ActorContext because get.php calls it with the session's analyst. It does no company check of its own: get.php has already loaded the change through its scope.

statusPlannedChoices() - shared with Projects

The services and impact levels for the dialog. It was two inline queries in ProjectToolsService::announcements(); the PR lifted them into the planned-maintenance file so both modules offer exactly the same choices:

function statusPlannedChoices(PDO $conn): array
{
    return [
        'services' => $conn->query("SELECT id, name FROM status_services WHERE is_active = 1 ORDER BY display_order, name")->fetchAll(PDO::FETCH_ASSOC),
        'impacts'  => $conn->query("SELECT id, name, colour, is_default, counts_as_downtime, severity_order FROM service_impact_levels WHERE is_active = 1 ORDER BY severity_order")->fetchAll(PDO::FETCH_ASSOC),
    ];
}

Projects now ends its array with ] + statusPlannedChoices($conn);.

The twin, and where it differs

ProjectToolsService::announce() ChangesService::announce()
Write check self::changeable() assertCanWrite() + loadJoined()
Service Status check inline assertServiceStatus()
Modes project_disruption setting: planned / now / off always planned - no setting
Start required in planned mode, now in now mode always required
Link column project_id (in the INSERT) change_id (its own UPDATE, guarded)
History ProjectsService::audit(... 'disruption_announced' ...) change_audit, action_type = 'announcement'
Ownership on withdraw (int)$row['project_id'] !== $projectId (int)($row['change_id'] ?? 0) !== $changeId

Keep them in step: a rule added to one (a new check, a new field) almost certainly belongs in the other.


The endpoint: api/change-management/announce.php

A thin adapter. The rules live in the service, so the REST API could call the same methods later with ActorContext::fromApiKey().

// Changes data: never on a GET, which a link on another site can send (csrf.php).
csrfRequireWriteMethod();

header('Content-Type: application/json');

if (!isset($_SESSION['analyst_id'])) {
    echo json_encode(['success' => false, 'error' => 'Not authenticated']);
    exit;
}
requireModuleAccessJson('changes');
requireModuleWriteJson('changes');   // Read only access (#180) changes nothing here

try {
    $in = json_decode(file_get_contents('php://input'), true) ?: [];
    $changeId = (int)($in['change_id'] ?? 0);
    $conn = connectToDatabase();
    $ctx = ActorContext::fromSession($conn);
    $action = (string)($in['action'] ?? '');
    if ($action === 'announce') {
        ChangesService::announce($conn, $ctx, $changeId, $in);
    } elseif ($action === 'withdraw') {
        ChangesService::withdrawAnnouncement($conn, $ctx, $changeId, (int)($in['id'] ?? 0));
    } else {
        throw new ServiceError('validation', 'invalid_field', 'Unknown action.');
    }
    echo json_encode(['success' => true, 'announcements' => ChangesService::announcements($conn, $ctx->actorId, $changeId)]);
} catch (Exception $e) {
    echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}

The request bodies, from its header comment:

POST {action:'announce', change_id, title, comment?, start (ISO UTC), end?, services:[{service_id, impact_level_id}]}
POST {action:'withdraw', change_id, id}

There is no REST API route for this yet.

get.php

The change's JSON gains one key:

    // Planned maintenance announced on Service Status; null without Service Status,
    // and then the page draws no section.
    require_once __DIR__ . '/../../includes/services/changes.php';
    $change['announcements'] = ChangesService::announcements($conn, (int)$_SESSION['analyst_id'], $changeId);

It is sent to Read only analysts too - they see the section, just without buttons.


The front end: assets/js/change-management.js

The section

renderChangeDetail() adds it straight after the linked tickets:

    html += renderLinkedIncidents(c);
    html += renderChangeAnnouncements(c);

It reuses the Linked tickets section's classes (linked-incidents-section, linked-incidents-table, linked-incident-btn), so it looks like its neighbour:

function renderChangeAnnouncements(c) {
    const a = c.announcements;
    if (!a) return '';
    const canWrite = window.MODULE_LEVEL !== 'read';
    const T = (k, p) => window.t('change-management.announce.' + k, p);
    const rows = (a.list || []).map(p => `
        <tr>
            <td>${escapeHtml(p.title)}</td>
            <td>${escapeHtml(p.end ? T('when_range', { start: formatDateTime(p.start), end: formatDateTime(p.end) }) : T('when_open', { start: formatDateTime(p.start) }))}
                <div class="linked-ticket-type">${escapeHtml((p.services || []).map(s => s.name + (s.impact ? ' (' + s.impact + ')' : '')).join(', '))}</div></td>
            <td>${escapeHtml(T('state_' + p.state))}</td>
            <td class="linked-incidents-actions">
                ${canWrite && p.state === 'scheduled' ? `<button class="linked-incident-btn danger" onclick="withdrawAnnouncement(${p.id})" title="${escapeHtml(T('withdraw'))}" aria-label="${escapeHtml(T('withdraw'))}">${CM_UNLINK_SVG}</button>` : ''}
            </td>
        </tr>`).join('');
    const body = rows || `<tr class="linked-incidents-empty"><td colspan="4">${escapeHtml(T('none'))}</td></tr>`;
    return `
        <div class="linked-incidents-section">
            <div class="linked-incidents-head">
                <h3>${escapeHtml(T('title'))} (${(a.list || []).length})</h3>
                ${canWrite && (a.services || []).length ? `<button class="btn btn-secondary btn-sm" onclick="openAnnounceModal()">${escapeHtml(T('button'))}</button>` : ''}
            </div>
            <table class="linked-incidents-table">
                <tbody>${body}</tbody>
            </table>
        </div>
    `;
}

Three conditions to notice: !a (no section at all), canWrite (Read only sees no buttons), and (a.services || []).length - no Announce button while Service Status has no active services, because the save would only refuse with "Choose at least one service".

The state label is state_ + the raw state, so the four keys state_scheduled, state_started, state_finished, state_cancelled in lang/en/change-management.php must match STATUS_PLANNED_STATES.

The dialog

#announceModal lives in change-management/index.php. Opening it fills it from the change - the outage window, or the work window when there is no outage start:

function openAnnounceModal() {
    const c = currentChange;
    if (!c || !c.announcements) return;
    document.getElementById('announceTitle').value = c.title || '';
    document.getElementById('announceStart').value = toDatetimeLocal(c.outage_start_datetime || c.work_start_datetime);
    document.getElementById('announceEnd').value = toDatetimeLocal(c.outage_start_datetime ? c.outage_end_datetime : c.work_end_datetime);
    document.getElementById('announceComment').value = '';
    document.getElementById('announceServices').innerHTML = '';
    addAnnounceServiceRow();
    document.getElementById('announceModal').classList.add('active');
}

The end follows the start's choice (c.outage_start_datetime ? ... : ...), so a change with an outage start but no outage end gets an empty end - it never pairs an outage start with a work end.

Each service row picks its impact by meaning, not by name - the same rule as Service Status's own dialog and Projects:

function addAnnounceServiceRow(serviceId, impactId) {
    const a = currentChange && currentChange.announcements;
    if (!a) return;
    const maint = (a.impacts || []).filter(l => !Number(l.counts_as_downtime) && !Number(l.is_default)).sort((x, y) => x.severity_order - y.severity_order)[0];
    const pick = impactId || (maint && maint.id);

"The most serious level that does not count as downtime and is not the all-clear" is Maintenance on a stock install, and still the right level after somebody renames it (#70).

Saving and withdrawing

Both go through one helper, which reloads the whole change on success, so the section and the Activity timeline show the new row:

async function postAnnouncement(body) {
    const res = await fetch(API_BASE + 'announce.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(Object.assign({ change_id: currentChange.id }, body)) });
    const data = await res.json();
    if (!data.success) throw new Error(data.error || window.t('change-management.announce.failed'));
    viewChange(currentChange.id);
}
async function saveAnnouncement() {
    if (!currentChange) return;
    const services = Array.from(document.querySelectorAll('#announceServices .announce-service-row')).map(r => ({
        service_id: parseInt(r.querySelector('.announce-svc').value, 10), impact_level_id: parseInt(r.querySelector('.announce-impact').value, 10) }));
    try {
        await postAnnouncement({ action: 'announce', services: services,
            title: document.getElementById('announceTitle').value.trim(), comment: document.getElementById('announceComment').value.trim(),
            start: window.inputToUTC(document.getElementById('announceStart').value), end: window.inputToUTC(document.getElementById('announceEnd').value) });
        closeAnnounceModal();
        showToast(window.t('change-management.announce.saved'), 'success');
    } catch (e) { showToast(e.message, 'error'); }
}

The times go through window.inputToUTC(), so what is typed in the analyst's local time is stored as UTC - statusPlannedUtc() reads it as UTC. The server's refusal message is shown as the toast, so "Say when it starts." and "Choose at least one service it affects." reach the user as written.

withdrawAnnouncement(id) asks first with showConfirm() (falling back to confirm()), then posts {action: 'withdraw', id}.

The timeline line

renderActivityTimeline() has its own branch for the audit rows, keyed on action_type:

            } else if (entry.action_type === 'announcement') {
                description = entry.new_value
                    ? `${escapeHtml(window.t('change-management.announce.timeline_announced'))} <span class="new-val">${escapeHtml(entry.new_value)}</span>`
                    : `${escapeHtml(window.t('change-management.announce.timeline_withdrawn'))} <span class="old-val">${escapeHtml(entry.old_value || '')}</span>`;

A new_value means announced; none means withdrawn. The evidence export (change-management/evidence.php) prints every audit row generically, so these show there as announcement - Service Status with no extra code.


The back link on Service Status

renderPlanned() in service-status/index.php adds a chip beside the project one. Whether the analyst may open Change Management is decided in PHP as the page is drawn, so nobody is offered a link into a module they cannot open:

                // The same for a change, while Change Management is reachable.
                const fromChange = p.change_id && <?php echo analystCanAccessModule(connectToDatabase(), (int)$_SESSION['analyst_id'], 'changes') ? 'true' : 'false'; ?> ? '<a class="planned-from" href="../change-management/?change_id=' + encodeURIComponent(p.change_id) + '">'
                    + escapeHtml(window.t('service-status.planned.from_change', { ref: 'CHG-' + String(p.change_id).padStart(4, '0') })) + '</a>' : '';

?change_id=N is the canonical deep link into a change (change-management.js reads it on load). The reference is built the same way the change page builds it, 'CHG-' + String(id).padStart(4, '0').

The portal is untouched: api/self-service/get_dashboard.php maps each planned row to title, comment, start, end and services only, so neither change_id nor project_id ever reaches a customer.


Traps

πŸ”΄ TRAP: never name status_planned.change_id without statusPlannedChangeReady(). The list is read by the board, the portal and Watchtower on every load. One unguarded p.change_id in a SELECT or WHERE breaks all three on every install that has updated its files but not yet run Database Verification. Add the column to a query the way statusPlannedList() does - ($changeCol ? 'p.change_id' : 'NULL AS change_id').

⚠️ TRAP: never let api/service-status/planned.php pass change_id through. It checks Service Status only. The unset($in['project_id'], $in['change_id']) is the whole of the protection that stops a Service Status user attaching maintenance to any change.

⚠️ TRAP: the edit path of statusPlannedSave() must not write the link columns. Service Status's dialog does not send them, so writing them from the request on an edit would unlink every row moved there. The link is written once, on the new row.

⚠️ TRAP: includes/db_verify_indexes.php is generated. Change the index in database/freeitsm.sql and run scripts/gen_db_verify_indexes.php; never hand-edit the file.

ℹ️ Moving a change does not move its announcement. Editing the change's outage window leaves the Service Status row as it is - what customers were told changes only when somebody edits it on Service Status. Edits and withdrawals made there are not written to the change's change_audit.


Testing it

tests/change-announce-maintenance.php - 20 checks, against a test install (it writes, then deletes what it made in a finally). Details on Developer Tests: Change Management.

cd C:/wamp64/www/freeitsm-prtest
php tests/change-announce-maintenance.php

It skips with "run Database Verification first" until the column exists. Its control, from the header: drop the change_id UPDATE in statusPlannedSave() and the checks that the row names the change fail.

By hand:

  1. As an analyst with Changes and Service Status, open a change with an outage window and press Announce. The dialog shows the change's title and outage window and one service row on Maintenance.
  2. Announce. The section shows the row as Upcoming; Activity shows "announced on Service Status". On Service Status the row says From the change CHG-... and the link opens the change.
  3. Edit it on Service Status with a new start. Back on the change, the section shows the new window - still linked.
  4. Press the cross on the change, confirm. The row reads Withdrawn, it is gone from Service Status, and Activity shows "withdrew from Service Status".
  5. Give an analyst Read only on Changes: the section shows, with no buttons. Take Service Status away: no section at all.

Related pages

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally