<?  // PHPmyGallery - backend core - delete gallery settings or picture descriptions

/* File description:

This script deletes the gallery settings or picture descriptions from
a given gallery, needs confirmation from the user.

### What this script does:
###
### Included from: adminmenu.index.php
### |
### | (Uses templates from adminmenu)
### +- Delete DB entry (Display page, If user clicked "Yes" delete entry, display Result)
###
*/ 
$delWhat     = $_GET['what'];
$dbEntry     = $_POST['yesnoData'];
$yesnoAnswer = $_POST['yesnoAnswer'];

// Confirm deleting
if ($yesnoAnswer!='yes') {
    // What to delete?
    $pktpl_vars['text_yesnoTopic'] = $group.'/'.$picdir;
    if($delWhat == 'descriptions')
        $pktpl_vars['text_yesnoTopic'] .= ' '.$l['picture_descriptions'];
    elseif($delWhat == 'setup')
        $pktpl_vars['text_yesnoTopic'] .= ' '.$l['gallery_setup'];
    
    // Make yesno box template variables
    $pktpl_vars['text_yesnoData']  = $group.'--.--'.$picdir;
    $pktpl_vars['text_headline']   = $l['confirm_deleting'];
    $pktpl_vars['text_yesbutton']  = $l['yes_delete_this_file'];
    $pktpl_vars['text_nobutton']   = $l['no_dont_delete'];
    $pktpl_vars['text_help']       = $l['no_backups_will_be_made'];
    
    // Make yesno box template
    $pktpl_vars['template_admin_table'] = pktpl('adminmenu/admin_yesnoBox.html');
} // if
// Delete file
elseif ($yesnoAnswer=='yes'&&$dbEntry!='') {
    // Look up from which table we want to delete data
    $table = '';
    if($delWhat == 'descriptions')
        $table = 'picsdescriptions';
    elseif($delWhat == 'setup')
        $table = 'gallerysettings';
    
    // delete file from database
    if($table != '')
        $res = delData($table,$dbEntry);
    
    // Successfully deleted or not?
    if($res == 0 && $table != '')
        $pktpl_vars['text_headline'] = $l['successfully_deleted'];
    else
        $pktpl_vars['text_headline'] = $l['deleting_failed'];
    
    // Make templates
    $pktpl_vars['text_picdir']                    = $picdir;
    $pktpl_vars['template_admin_successBoxLinks'] = pktpl('adminmenu/admin_successBoxFiledeleted.html');
    $pktpl_vars['template_admin_table']           = pktpl('adminmenu/admin_successBox.html');
} // elseif

?>