<?php

if ( !$user['superAdmin'] ) {
    session_start();
    $_SESSION['error'] = 'Unauthorized';

    header('Location: '.URL_APP_ADMIN);
    exit;
}

if ( !isset($_GET['id']) || !$share = $db->row("SELECT * FROM share WHERE id = ?", $_GET['id']) ) {
    session_start();
    $_SESSION['error'] = 'Invalid share ID';

    header('Location: '.URL_APP_ADMIN.'/?page=pp');
    exit;
}

$db->delete('public_project_share', ['shareId' => $share['id']]);
$db->delete('share', ['id' => $share['id']]);

session_start();
$_SESSION['error'] = 'Public project share link deleted';

header('Location: '.URL_APP_ADMIN.'/?page=pp');
exit;