ModificationHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Wfdownloads;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * Wfdownloads module
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @package         wfdownload
21
 * @since           3.23
22
 * @author          Xoops Development Team
23
 */
24
25
use XoopsModules\Wfdownloads;
26
27
require_once \dirname(__DIR__) . '/include/common.php';
28
29
//require_once XOOPS_ROOT_PATH . '/modules/wfdownloads/class/Download.php';
30
31
/**
32
 * Class ModificationHandler
33
 */
34
class ModificationHandler extends \XoopsPersistableObjectHandler
35
{
36
    /**
37
     * @access public
38
     */
39
    public $helper;
40
41
    /**
42
     * @param \XoopsDatabase|null $db
43
     */
44
    public function __construct(\XoopsDatabase $db = null)
45
    {
46
        parent::__construct($db, 'wfdownloads_mod', Modification::class, 'requestid', 'title');
47
        /** @var \XoopsModules\Wfdownloads\Helper $helper */
48
        $this->helper = Helper::getInstance();
49
    }
50
51
    /**
52
     * @param $requestid
53
     *
54
     * @return bool
55
     */
56
    public function approveModification($requestid)
57
    {
58
        $sql = "UPDATE {$this->table} m, {$this->helper->getHandler('Download')->table} d";
59
        $sql .= " SET
60
            d.cid = m.cid,
61
            d.title = m.title,
62
            d.url = m.url,
63
            d.filename = m.filename,
64
            d.filetype = m.filetype,
65
            d.mirror = m.mirror,
66
            d.license = m.license,
67
            d.features = m.features,
68
            d.homepage = m.homepage,
69
            d.version = m.version,
70
            d.size = m.size,
71
            d.platform = m.platform,
72
            d.screenshot = m.screenshot,
73
            d.screenshot2 = m.screenshot2,
74
            d.screenshot3 = m.screenshot3,
75
            d.screenshot4 = m.screenshot4,
76
            d.publisher = m.publisher,
77
            d.status = '" . \_WFDOWNLOADS_STATUS_UPDATED . "',
78
            d.price = m.price,
79
            d.requirements = m.requirements,
80
            d.homepagetitle = m.homepagetitle,
81
            d.limitations = m.limitations,
82
            d.versiontypes = m.versiontypes,
83
            d.dhistory = m.dhistory,
84
            d.updated = m.updated,
85
            d.summary = m.summary,
86
            d.description = m.description,
87
            d.screenshots = m.screenshots,
88
            d.dohtml = m.dohtml,
89
            d.dosmiley = m.dosmiley,
90
            d.doxcode = m.doxcode,
91
            d.doimage = m.doimage,
92
            d.dobr = m.dobr";
93
        $sql .= " WHERE d.lid = m.lid AND m.requestid='{$requestid}'";
94
        if ($this->db->query($sql)) {
95
            return $this->deleteAll(new \Criteria('requestid', (int)$requestid));
96
        }
97
98
        return false;
99
    }
100
}
101