<commit_before><?php

include_once 'header.php';
include_once 'database.php';
include_once 'mail.php';
include_once 'tohtml.php';
include_once 'check_access_permissions.php';

mustHaveAnyOfTheseRoles( array( 'AWS_ADMIN' ) );

echo userHTML( );


if( ! $_POST[ 'response' ] )
{
    // Go back to previous page.
    goBack( );
    exit;
}
else if( $_POST[ 'response' ] == 'delete' )
{
    // Delete this entry from talks.
    $res = deleteFromTable( 'talks', 'id', $_POST );
    if( $res )
    {
        echo printInfo( 'Successfully deleted talk' );

        $success = true;
        $externalId = "talk." . $_POST[ 'id' ];

        // Now cancel this talk in requests, if there is any.
        $res = updateTable( 
            'bookmyvenue_requests', 'external_id', 'status'
            , array( 'external_id' => $externalId
                    , 'status' => 'CANCELLED' )
            );
        if( ! $res  )
            $success = false;

        // Cancel confirmed event if any.
        $res = updateTable( 
            'events', 'external_id', 'status'
            , array( 'external_id' => $externalId
                    , 'status' => 'CANCELLED' )
            );
        if( ! $res  )
            $success = false;
        
        if( $success )
        {
            echo "Successfully deleted related events/requests";
            goBack( );
            exit;
        }
    }
    else
        echo printWarning( "Failed to delete the talk " );
}
else if( $_POST[ 'response' ] == 'DO_NOTHING' )
{
    echo printInfo( "User said NO!" );
    goBack( 'admin_acad.php' );
    exit;
}
else if( $_POST[ 'response' ] == 'edit' )
{
    echo printInfo( "Here you can only change the host, class, title and description
        of the talk." );
<commit_msg>Modified logic to cancel the booking request/event when talk is deleted.<commit_after><?php

include_once 'header.php';
include_once 'database.php';
include_once 'mail.php';
include_once 'tohtml.php';
include_once 'check_access_permissions.php';

mustHaveAnyOfTheseRoles( array( 'AWS_ADMIN' ) );

echo userHTML( );


if( ! $_POST[ 'response' ] )
{
    // Go back to previous page.
    goBack( );
    exit;
}
else if( $_POST[ 'response' ] == 'delete' )
{
    // Delete this entry from talks.
    $res = deleteFromTable( 'talks', 'id', $_POST );
    if( $res )
    {
        echo printInfo( 'Successfully deleted talk' );

        $success = true;
        $externalId = "talk." . $_POST[ 'id' ];

        $events = getTableEntries( 'events'
            , 'external_id', "external_id='$externalId' AND status='VALID'" 
        );
        $requests = getTableEntries( 'bookmyvenue_requests'
            , 'external_id', "external_id='$externalId' AND status='VALID'" 
        );

        foreach( $events as $e )
        {
            $e[ 'status' ] = 'CANCELLED';
            // Now cancel this talk in requests, if there is any.
            $res = updateTable( 'events', 'external_id', 'status', $e );
        }

        foreach( $requests as $r )
        {
            $r[ 'status' ] = 'CANCELLED';
            $res = updateTable( 
                'bookmyvenue_requests', 'external_id', 'status', $r
                );
        }

        // /* VALIDATION: Check the bookings are deleted  */

        // $events = getTableEntries( 'events'
        //     , 'external_id', "external_id='$externalId' AND status='VALID'" 
        // );
        // $requests = getTableEntries( 'bookmyvenue_requests'
        //     , 'external_id', "external_id='$externalId' AND status='VALID'" 
        // );
        // assert( ! $events );
        // assert( ! $requests );
        
        echo "Successfully deleted related events/requests";
        goBack( );
        exit;
    }
    else
        echo printWarning( "Failed to delete the talk " );
}
else if( $_POST[ 'response' ] == 'DO_NOTHING' )
{
    echo printInfo( "User said NO!" );
    goBack( 'admin_acad.php' );
    exit;
}
else if( $_POST[ 'response' ] == 'edit' )
{
    echo printInfo( "Here you can only change the host, class, title and description
        of the talk." );

{'fraction_non_alphanumeric': 0.14446897228354183, 'fraction_numerical': 0.0, 'mean_word_length': 2.0823885109599396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3085798', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1249, 'n_words': 335}