Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        module
5
 * @package         droplet
6
 * @author          Ruud Eisinga (Ruud) John (PCWacht)
7
 * @author          WebsiteBaker Project
8
 * @copyright       Ryan Djurovich
9
 * @copyright       WebsiteBaker Org. e.V.
10
 * @link            http://websitebaker.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.3
13
 * @requirements    PHP 5.3.6 and higher
14
 * @version         $Id: delete_droplet.php 2 2017-07-02 15:14:29Z Manuela $
15
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/droplets/commands/delete_droplet.php $
16
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
17
 *
18
 */
19
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21
if(defined('WB_PATH') == false) { die('Cannot access '.basename(__DIR__).'/'.basename(__FILE__).' directly'); }
22
/* -------------------------------------------------------- */
23
// Get id
24
if ($droplet_id===false) {
25
    $oApp->print_error($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS, $ToolUrl);
26
    exit();
27
}
28

    
29
if( !$oApp->checkFTAN() ){
30
    $oApp->print_error($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS, $ToolUrl );
31
    exit();
32
}
33

    
34
if (!isset( $aRequestVars['DropletsToDelete']))
35
{
36
    $sDropletsToDelete = ( isset($droplet_id) && !isset( $aRequestVars['cb']) ? $droplet_id : '' );
37
    $iDELETED = (isset($droplet_id) ? 1 : 0 );
38
    if( isset( $aRequestVars['cb'])  ) {
39
        $aRequestVars['cb'] = array_flip(  $aRequestVars['cb'] );
40
        $aRequestVars['cb'] = array_unique($aRequestVars['cb'], SORT_NUMERIC);
41
        $iDELETED = sizeof( $aRequestVars['cb'] );
42
        $sDropletsToDelete = ( isset($droplet_id) ? implode(',',$aRequestVars['cb'] ) : '' );
43
    }
44
    $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` '
45
          . 'WHERE `id` IN ('.$sDropletsToDelete.') ';
46
    $inDroplets = '';
47
    if ( $oRes = $oDb->query($sql)) {
48
        while( $aRow = $oRes->fetchRow( MYSQLI_ASSOC ) ) {
49
          $inDroplets .= $aRow['name'].', ';
50
        }
51
    }
52
    $iDropletIdKey = $oApp->getIDKEY($droplet_id);
53
    $aFtan = $admin->getFTAN('');
54
    // prepare default data for phplib and twig
55
    $aTplData = array (
56
        'FTAN_NAME' => $aFtan['name'],
57
        'FTAN_VALUE' => $aFtan['value'],
58
        'iDropletIdKey' => $iDropletIdKey,
59
        'sDropletsToDelete' => $sDropletsToDelete,
60
        'inDroplets' =>  rtrim($inDroplets, ', '),
61
        );
62
// Create new template object with phplib
63
    $oTpl = new Template($sAddonThemePath, 'keep' );
64
    $oTpl->set_file('page', 'delete_droplets.htt');
65
    $oTpl->set_block('page', 'main_block', 'main');
66
//    $oTpl->set_var('FTAN_NAME', $aFtan['name']);
67
//    $oTpl->set_var('FTAN_VALUE', $aFtan['value']);
68
    $oTpl->set_var($aLang);
69
    $oTpl->set_var($aTplDefaults);
70
    $oTpl->set_var($aTplData);
71
/*-- finalize the page -----------------------------------------------------------------*/
72
    $oTpl->parse('main', 'main_block', false);
73
    $oTpl->pparse('output', 'page');
74

    
75
} elseif (!isset($aRequestVars['cancel'])) {
76
    $sDropletsToDelete = $aRequestVars['DropletsToDelete'];
77
    $iDELETED = sizeof( explode(',', $sDropletsToDelete) );
78
    $sql  = 'DELETE FROM `'.TABLE_PREFIX.'mod_droplets` '
79
          . 'WHERE `id` IN ('.$sDropletsToDelete.') ';
80
    // Delete droplet
81
    $oDb->query($sql);
82

    
83
    // Check if there is a db error, otherwise say successful
84
    if($oDb->is_error()) {
85
        msgQueue::add( $oDb->get_error().'<br />'.$sql );
86
    } else {
87
        msgQueue::add( sprintf("%'.02d", $iDELETED ).'  '.$oTrans->DR_TEXT_DROPLETS_DELETED, true );
88
    }
89
} else { /* do nothing */}
(8-8/16)