1 | <?php |
||
2 | |||
3 | /* Divine CMS - Open source CMS for widespread use. |
||
4 | Copyright (c) 2019 Mykola Burakov ([email protected]) |
||
5 | |||
6 | See SOURCE.txt for other and additional information. |
||
7 | |||
8 | This file is part of Divine CMS. |
||
9 | |||
10 | This program is free software: you can redistribute it and/or modify |
||
11 | it under the terms of the GNU General Public License as published by |
||
12 | the Free Software Foundation, either version 3 of the License, or |
||
13 | (at your option) any later version. |
||
14 | |||
15 | This program is distributed in the hope that it will be useful, |
||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | GNU General Public License for more details. |
||
19 | |||
20 | You should have received a copy of the GNU General Public License |
||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
||
22 | |||
23 | class ModelAccountDownload extends \Divine\Engine\Core\Model |
||
0 ignored issues
–
show
|
|||
24 | { |
||
25 | public function getDownload($download_id) |
||
0 ignored issues
–
show
|
|||
26 | { |
||
27 | $implode = array(); |
||
28 | |||
29 | $order_statuses = $this->config->get('config_complete_status'); |
||
30 | |||
31 | foreach ($order_statuses as $order_status_id) { |
||
32 | $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'"; |
||
33 | } |
||
34 | |||
35 | if ($implode) { |
||
36 | $query = $this->db->query(" |
||
37 | SELECT d.filename, d.mask |
||
38 | FROM `order` o |
||
39 | LEFT JOIN order_product op ON (o.order_id = op.order_id) |
||
40 | LEFT JOIN product_to_download p2d ON (op.product_id = p2d.product_id) |
||
41 | LEFT JOIN download d ON (p2d.download_id = d.download_id) |
||
42 | WHERE o.customer_id = '" . (int)$this->customer->getId() . "' |
||
43 | AND (" . implode(" OR ", $implode) . ") |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
OR does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
44 | AND d.download_id = '" . (int)$download_id . "' |
||
45 | "); |
||
46 | |||
47 | return $query->row; |
||
48 | } else { |
||
49 | return; |
||
50 | } |
||
51 | } |
||
52 | |||
53 | public function getDownloads($start = 0, $limit = 20) |
||
54 | { |
||
55 | if ($start < 0) { |
||
56 | $start = 0; |
||
57 | } |
||
58 | |||
59 | if ($limit < 1) { |
||
60 | $limit = 20; |
||
61 | } |
||
62 | |||
63 | $implode = array(); |
||
64 | |||
65 | $order_statuses = $this->config->get('config_complete_status'); |
||
66 | |||
67 | foreach ($order_statuses as $order_status_id) { |
||
68 | $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'"; |
||
69 | } |
||
70 | |||
71 | if ($implode) { |
||
72 | $query = $this->db->query( |
||
73 | " |
||
74 | SELECT DISTINCT d.download_id, o.order_id, o.date_added, dd.name, d.filename FROM `order` o |
||
75 | LEFT JOIN order_product op ON (o.order_id = op.order_id) |
||
76 | LEFT JOIN product_to_download p2d ON (op.product_id = p2d.product_id) |
||
77 | LEFT JOIN download d ON (p2d.download_id = d.download_id) |
||
78 | LEFT JOIN download_description dd ON (d.download_id = dd.download_id) |
||
79 | WHERE o.customer_id = '" . (int)$this->customer->getId() . "' |
||
80 | AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
81 | AND (" . implode(" OR ", $implode) . ") |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
OR does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
) \n ORDE...n LIMIT does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
82 | ORDER BY o.date_added DESC |
||
83 | LIMIT " . (int)$start . "," . (int)$limit |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
, does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
84 | ); |
||
85 | |||
86 | return $query->rows; |
||
87 | } else { |
||
88 | return array(); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | public function getTotalDownloads() |
||
93 | { |
||
94 | $implode = array(); |
||
95 | |||
96 | $order_statuses = $this->config->get('config_complete_status'); |
||
97 | |||
98 | foreach ($order_statuses as $order_status_id) { |
||
99 | $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'"; |
||
100 | } |
||
101 | |||
102 | if ($implode) { |
||
103 | $query = $this->db->query(" |
||
104 | SELECT COUNT(*) AS total |
||
105 | FROM `order` o |
||
106 | LEFT JOIN order_product op ON (o.order_id = op.order_id) |
||
107 | LEFT JOIN product_to_download p2d ON (op.product_id = p2d.product_id) |
||
108 | WHERE o.customer_id = '" . (int)$this->customer->getId() . "' |
||
109 | AND (" . implode(" OR ", $implode) . ") |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
OR does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
)\n does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
110 | "); |
||
111 | |||
112 | return $query->row['total']; |
||
113 | } else { |
||
114 | return 0; |
||
115 | } |
||
116 | } |
||
117 | } |
||
118 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.