forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomerThread.php
91 lines (83 loc) · 3.18 KB
/
CustomerThread.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class CustomerThreadCore extends ObjectModel
{
public $id;
public $id_shop;
public $id_lang;
public $id_contact;
public $id_customer;
public $id_order;
public $id_product;
public $status;
public $email;
public $token;
public $date_add;
public $date_upd;
protected $table = 'customer_thread';
protected $identifier = 'id_customer_thread';
protected $fieldsRequired = array('id_lang', 'id_contact', 'token');
protected $fieldsSize = array('email' => 254);
protected $fieldsValidate = array('id_lang' => 'isUnsignedId', 'id_contact' => 'isUnsignedId', 'id_shop' => 'isUnsignedId', 'id_customer' => 'isUnsignedId',
'id_order' => 'isUnsignedId', 'id_product' => 'isUnsignedId', 'email' => 'isEmail', 'token' => 'isGenericName');
public function getFields()
{
$this->validateFields();
$fields['id_lang'] = (int)($this->id_lang);
$fields['id_shop'] = (int)$this->id_shop;
$fields['id_contact'] = (int)($this->id_contact);
$fields['id_customer'] = (int)($this->id_customer);
$fields['id_order'] = (int)($this->id_order);
$fields['id_product'] = (int)($this->id_product);
$fields['status'] = pSQL($this->status);
$fields['email'] = pSQL($this->email);
$fields['token'] = pSQL($this->token);
$fields['date_add'] = pSQL($this->date_add);
$fields['date_upd'] = pSQL($this->date_upd);
return $fields;
}
public function delete()
{
if (!Validate::isUnsignedId($this->id))
return false;
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'customer_message` WHERE `id_customer_thread` = '.(int)($this->id));
return (parent::delete());
}
public static function getCustomerMessages($id_customer)
{
return Db::getInstance()->ExecuteS('
SELECT * FROM '._DB_PREFIX_.'customer_thread ct
LEFT JOIN '._DB_PREFIX_.'customer_message cm ON ct.id_customer_thread = cm.id_customer_thread
WHERE id_customer = '.(int)($id_customer));
}
public static function getIdCustomerThreadByEmailAndIdOrder($email, $id_order)
{
return Db::getInstance()->getValue('
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.email = \''.pSQL($email).'\' AND cm.id_shop = '.(int)Context::getContext()->shop->getId(true).' AND cm.id_order = '.(int)$id_order.'');
}
}