|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016-2018 |
|
6
|
|
|
* @package MShop |
|
7
|
|
|
* @subpackage Customer |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\MShop\Customer\Manager\Lists; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* ezPublish implementation of the customer list class |
|
16
|
|
|
* |
|
17
|
|
|
* @package MShop |
|
18
|
|
|
* @subpackage Customer |
|
19
|
|
|
*/ |
|
20
|
|
|
class Ezpublish |
|
21
|
|
|
extends \Aimeos\MShop\Customer\Manager\Lists\Standard |
|
22
|
|
|
implements \Aimeos\MShop\Customer\Manager\Lists\Iface, \Aimeos\MShop\Common\Manager\Lists\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
private $searchConfig = array( |
|
25
|
|
|
'customer.lists.id'=> array( |
|
26
|
|
|
'code'=>'customer.lists.id', |
|
27
|
|
|
'internalcode'=>'ezuli."id"', |
|
28
|
|
|
'internaldeps' => array( 'LEFT JOIN "ezuser_list" AS ezuli ON ( ezu."id" = ezuli."parentid" )' ), |
|
29
|
|
|
'label'=>'Customer list ID', |
|
30
|
|
|
'type'=> 'integer', |
|
31
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
|
32
|
|
|
'public' => false, |
|
33
|
|
|
), |
|
34
|
|
|
'customer.lists.siteid'=> array( |
|
35
|
|
|
'code'=>'customer.lists.siteid', |
|
36
|
|
|
'internalcode'=>'ezuli."siteid"', |
|
37
|
|
|
'label'=>'Customer list site ID', |
|
38
|
|
|
'type'=> 'integer', |
|
39
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
|
40
|
|
|
'public' => false, |
|
41
|
|
|
), |
|
42
|
|
|
'customer.lists.parentid'=> array( |
|
43
|
|
|
'code'=>'customer.lists.parentid', |
|
44
|
|
|
'internalcode'=>'ezuli."parentid"', |
|
45
|
|
|
'label'=>'Customer list parent ID', |
|
46
|
|
|
'type'=> 'integer', |
|
47
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
|
48
|
|
|
'public' => false, |
|
49
|
|
|
), |
|
50
|
|
|
'customer.lists.domain'=> array( |
|
51
|
|
|
'code'=>'customer.lists.domain', |
|
52
|
|
|
'internalcode'=>'ezuli."domain"', |
|
53
|
|
|
'label'=>'Customer list domain', |
|
54
|
|
|
'type'=> 'string', |
|
55
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
56
|
|
|
), |
|
57
|
|
|
'customer.lists.type' => array( |
|
58
|
|
|
'code'=>'customer.lists.type', |
|
59
|
|
|
'internalcode'=>'ezuli."type"', |
|
60
|
|
|
'label'=>'Customer list type', |
|
61
|
|
|
'type'=> 'string', |
|
62
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
63
|
|
|
), |
|
64
|
|
|
'customer.lists.refid'=> array( |
|
65
|
|
|
'code'=>'customer.lists.refid', |
|
66
|
|
|
'internalcode'=>'ezuli."refid"', |
|
67
|
|
|
'label'=>'Customer list reference ID', |
|
68
|
|
|
'type'=> 'string', |
|
69
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
70
|
|
|
), |
|
71
|
|
|
'customer.lists.datestart' => array( |
|
72
|
|
|
'code'=>'customer.lists.datestart', |
|
73
|
|
|
'internalcode'=>'ezuli."start"', |
|
74
|
|
|
'label'=>'Customer list start date/time', |
|
75
|
|
|
'type'=> 'datetime', |
|
76
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
77
|
|
|
), |
|
78
|
|
|
'customer.lists.dateend' => array( |
|
79
|
|
|
'code'=>'customer.lists.dateend', |
|
80
|
|
|
'internalcode'=>'ezuli."end"', |
|
81
|
|
|
'label'=>'Customer list end date/time', |
|
82
|
|
|
'type'=> 'datetime', |
|
83
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
84
|
|
|
), |
|
85
|
|
|
'customer.lists.config' => array( |
|
86
|
|
|
'code'=>'customer.lists.config', |
|
87
|
|
|
'internalcode'=>'ezuli."config"', |
|
88
|
|
|
'label'=>'Customer list position', |
|
89
|
|
|
'type'=> 'string', |
|
90
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
91
|
|
|
), |
|
92
|
|
|
'customer.lists.position' => array( |
|
93
|
|
|
'code'=>'customer.lists.position', |
|
94
|
|
|
'internalcode'=>'ezuli."pos"', |
|
95
|
|
|
'label'=>'Customer list position', |
|
96
|
|
|
'type'=> 'integer', |
|
97
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
|
98
|
|
|
), |
|
99
|
|
|
'customer.lists.status' => array( |
|
100
|
|
|
'code'=>'customer.lists.status', |
|
101
|
|
|
'internalcode'=>'ezuli."status"', |
|
102
|
|
|
'label'=>'Customer list status', |
|
103
|
|
|
'type'=> 'integer', |
|
104
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
|
105
|
|
|
), |
|
106
|
|
|
'customer.lists.ctime'=> array( |
|
107
|
|
|
'code'=>'customer.lists.ctime', |
|
108
|
|
|
'internalcode'=>'ezuli."ctime"', |
|
109
|
|
|
'label'=>'Customer list create date/time', |
|
110
|
|
|
'type'=> 'datetime', |
|
111
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
112
|
|
|
), |
|
113
|
|
|
'customer.lists.mtime'=> array( |
|
114
|
|
|
'code'=>'customer.lists.mtime', |
|
115
|
|
|
'internalcode'=>'ezuli."mtime"', |
|
116
|
|
|
'label'=>'Customer list modification date/time', |
|
117
|
|
|
'type'=> 'datetime', |
|
118
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
119
|
|
|
), |
|
120
|
|
|
'customer.lists.editor'=> array( |
|
121
|
|
|
'code'=>'customer.lists.editor', |
|
122
|
|
|
'internalcode'=>'ezuli."editor"', |
|
123
|
|
|
'label'=>'Customer list editor', |
|
124
|
|
|
'type'=> 'string', |
|
125
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
|
126
|
|
|
), |
|
127
|
|
|
); |
|
128
|
|
|
|
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Removes old entries from the storage. |
|
132
|
|
|
* |
|
133
|
|
|
* @param array $siteids List of IDs for sites whose entries should be deleted |
|
134
|
|
|
*/ |
|
135
|
|
|
public function clear( array $siteids ) |
|
136
|
|
|
{ |
|
137
|
|
|
$path = 'mshop/customer/manager/lists/submanagers'; |
|
138
|
|
|
foreach( $this->getContext()->getConfig()->get( $path, [] ) as $domain ) { |
|
139
|
|
|
$this->getObject()->getSubManager( $domain )->clear( $siteids ); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
$this->cleanupBase( $siteids, $this->getConfigPath() . 'delete' ); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Returns the attributes that can be used for searching. |
|
148
|
|
|
* |
|
149
|
|
|
* @param boolean $withsub Return also attributes of sub-managers if true |
|
150
|
|
|
* @return array Returns a list of attribtes implementing \Aimeos\MW\Criteria\Attribute\Iface |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getSearchAttributes( $withsub = true ) |
|
153
|
|
|
{ |
|
154
|
|
|
$path = 'mshop/customer/manager/lists/submanagers'; |
|
155
|
|
|
|
|
156
|
|
|
return $this->getSearchAttributesBase( $this->getSearchConfig(), $path, [], $withsub ); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* Returns a new manager for customer extensions |
|
162
|
|
|
* |
|
163
|
|
|
* @param string $manager Name of the sub manager type in lower case |
|
164
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
|
165
|
|
|
* @return mixed Manager for different extensions, e.g stock, tags, locations, etc. |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getSubManager( $manager, $name = null ) |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->getSubManagerBase( 'customer', 'lists/' . $manager, ( $name === null ? 'Ezpublish' : $name ) ); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Updates or adds a common list item object. |
|
175
|
|
|
* |
|
176
|
|
|
* @param \Aimeos\MShop\Common\Item\Lists\Iface $item List item object which should be saved |
|
177
|
|
|
* @param boolean $fetch True if the new ID should be returned in the item |
|
178
|
|
|
* @return \Aimeos\MShop\Common\Item\Lists\Iface $item Updated item including the generated ID |
|
179
|
|
|
*/ |
|
180
|
|
|
public function saveItem( \Aimeos\MShop\Common\Item\Lists\Iface $item, $fetch = true ) |
|
181
|
|
|
{ |
|
182
|
|
|
if( $item->getDomain() === 'customer/group' ) { |
|
183
|
|
|
throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Adding groups to customers is not supported, please use the eZ Publish backend' ) ); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
return parent::saveItem( $item, $fetch ); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Returns the config path for retrieving the configuration values. |
|
192
|
|
|
* |
|
193
|
|
|
* @return string Configuration path (mshop/customer/manager/lists/ezpublish/) |
|
194
|
|
|
*/ |
|
195
|
|
|
protected function getConfigPath() |
|
196
|
|
|
{ |
|
197
|
|
|
return 'mshop/customer/manager/lists/ezpublish/'; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Returns the search configuration for searching items. |
|
203
|
|
|
* |
|
204
|
|
|
* @return array Associative list of search keys and search definitions |
|
205
|
|
|
*/ |
|
206
|
|
|
protected function getSearchConfig() |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->searchConfig; |
|
209
|
|
|
} |
|
210
|
|
|
} |
|
211
|
|
|
|