1: | <?php
2: | namespace Opencart\Catalog\Model\Account;
3: | /**
4: | * Class Gdpr
5: | *
6: | * @package Opencart\Catalog\Model\Account
7: | */
8: | class Gdpr extends \Opencart\System\Engine\Model {
9: | /**
10: | * Add Gdpr
11: | *
12: | * @param string $code
13: | * @param string $email
14: | * @param string $action
15: | *
16: | * @return void
17: | */
18: | public function addGdpr(string $code, string $email, string $action): void {
19: | $this->db->query("INSERT INTO `" . DB_PREFIX . "gdpr` SET `store_id` = '" . $this->db->escape($this->config->get('config_store_id')) . "', `language_id` = '" . $this->db->escape($this->config->get('config_language_id')) . "', `code` = '" . $this->db->escape($code) . "', `email` = '" . $this->db->escape($email) . "', `action` = '" . $this->db->escape($action) . "', `date_added` = NOW()");
20: | }
21: |
22: | /**
23: | * Edit Status
24: | *
25: | * @param int $gdpr_id
26: | * @param bool $status
27: | *
28: | * @return void
29: | */
30: | public function editStatus(int $gdpr_id, bool $status): void {
31: | $this->db->query("UPDATE `" . DB_PREFIX . "gdpr` SET `status` = '" . (bool)$status . "' WHERE `gdpr_id` = '" . (int)$gdpr_id . "'");
32: | }
33: |
34: | /**
35: | * Get Gdpr
36: | *
37: | * @param int $gdpr_id
38: | *
39: | * @return array<string, mixed>
40: | */
41: | public function getGdpr(int $gdpr_id): array {
42: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "gdpr` WHERE `gdpr_id` = '" . (int)$gdpr_id . "'");
43: |
44: | return $query->row;
45: | }
46: |
47: | /**
48: | * Get Gdpr By Code
49: | *
50: | * @param string $code
51: | *
52: | * @return array<string, mixed>
53: | */
54: | public function getGdprByCode(string $code): array {
55: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "gdpr` WHERE `code` = '" . $this->db->escape($code) . "'");
56: |
57: | return $query->row;
58: | }
59: |
60: | /**
61: | * Get Gdpr(s) By Email
62: | *
63: | * @param string $email
64: | *
65: | * @return array<int, array<string, mixed>>
66: | */
67: | public function getGdprsByEmail(string $email): array {
68: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "gdpr` WHERE `email` = '" . $this->db->escape($email) . "'");
69: |
70: | return $query->rows;
71: | }
72: |
73: | /**
74: | * Get Expires
75: | *
76: | * @return array<int, array<string, mixed>>
77: | */
78: | public function getExpires(): array {
79: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "gdpr` WHERE `status` = '2' AND DATE(`date_added`) <= DATE('" . $this->db->escape(date('Y-m-d', strtotime('+' . (int)$this->config->get('config_gdpr_limit') . ' days'))) . "') ORDER BY `date_added` DESC");
80: |
81: | return $query->rows;
82: | }
83: | }
84: |

OpenCart API API documentation generated by ApiGen dev-master