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: save_rename.php 2 2017-07-02 15:14:29Z Manuela $
15
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/droplets/commands/save_rename.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')) {
22
    require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
23
    throw new IllegalFileException();
24
} else {
25
    if (($droplet_id === false)) {
26
     //   $oApp->print_header();
27
        $oApp->print_error('IDKEY_DROPLET::'. $oTrans->MESSAGE_GENERIC_SECURITY_ACCESS, $ToolUrl );
28
    }
29
    $modified_when = time();
30
    $modified_by   = (int) $oApp->get_user_id();
31
    $sNewName      = trim($aRequestVars['title']);
32
    if (!$sNewName) {
33
        msgQueue::add($oTrans->DROPLET_MESSAGE_GENERIC_MISSING_TITLE);
34
    } else {
35
        $sOldName      = trim(@$aRequestVars['existingTitle']?:$sNewName);
36
        $sGenericNewName = getUniqueName($oDb, $sNewName);
37
        switch ($subCommand):
38
            case 'add_droplet':
39
                $sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_droplets` SET '
40
                  .    '`name`=\''.$oDb->escapeString($sGenericNewName).'\','
41
                  .    '`code`=\'\', '
42
                  .    '`description`=\'\', '
43
                 .     '`modified_when`='.$modified_when.','
44
                 .     '`modified_by`='.$modified_by.','
45
                  .    '`active`=0,'
46
                  .    '`admin_edit`=0,'
47
                  .    '`admin_view`=0,'
48
                  .    '`show_wysiwyg`=0,'
49
                  .    '`comments`=\'\'';
50
                break;
51
            case 'copy_droplet':
52
                $sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_droplets` '
53
                  .        'SELECT '
54
                  .        'NULL,'
55
                  .        '\''.$oDb->escapeString($sGenericNewName).'\','
56
                  .        '`code`,`description`,'.$modified_when.','.$modified_by.','
57
                  .        '`active`,`admin_edit`,`admin_view`,`show_wysiwyg`,`comments`'
58
                 . 'FROM `'.TABLE_PREFIX.'mod_droplets` '
59
                     .     'WHERE `name`=\''.$oDb->escapeString($sOldName).'\'';
60
                break;
61
            case 'rename_droplet':
62
                if ($sNewName == $sOldName) {$sGenericNewName = $sOldName;}
63
                $sql = 'UPDATE `'.TABLE_PREFIX.'mod_droplets` '
64
                     . 'SET `name`=\''.$sGenericNewName.'\', '
65
                  .        '`modified_when`='.$modified_when.','
66
                  .        '`modified_by`='.$modified_by.' '
67
                     . 'WHERE `name`=\''.$sOldName.'\'';
68
                break;
69
            default: /* do nothing */  break;
70
        endswitch;
71
        if (!$oDb->query($sql))
72
        {
73
            if($oDb->is_error()) {
74
                msgQueue::add($oDb->get_error());
75
            }
76
        } else {
77
            msgQueue::add($oTrans->TEXT_SUCCESS, true );
78
        }
79
    }
80
}
(15-15/16)