|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2025 |
|
7
|
|
|
* @package MShop |
|
8
|
|
|
* @subpackage Customer |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace Aimeos\MShop\Customer\Manager; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Typo3 implementation of the customer class. |
|
17
|
|
|
* |
|
18
|
|
|
* @package MShop |
|
19
|
|
|
* @subpackage Customer |
|
20
|
|
|
*/ |
|
21
|
|
|
class Typo3 |
|
22
|
|
|
extends \Aimeos\MShop\Customer\Manager\Standard |
|
23
|
|
|
{ |
|
24
|
|
|
private array $plugins = []; |
|
25
|
|
|
private int $pid; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Initializes a new customer manager object using the given context object. |
|
30
|
|
|
* |
|
31
|
|
|
* @param \Aimeos\MShop\ContextIface $context Context object with required objects |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct( \Aimeos\MShop\ContextIface $context ) |
|
34
|
|
|
{ |
|
35
|
|
|
parent::__construct( $context ); |
|
36
|
|
|
|
|
37
|
|
|
$plugin = new \Aimeos\Base\Criteria\Plugin\T3Datetime(); |
|
38
|
|
|
$this->plugins['customer.ctime'] = $plugin; |
|
39
|
|
|
$this->plugins['customer.mtime'] = $plugin; |
|
40
|
|
|
$this->plugins['customer.salutation'] = new \Aimeos\Base\Criteria\Plugin\T3Salutation(); |
|
41
|
|
|
$this->plugins['customer.status'] = new \Aimeos\Base\Criteria\Plugin\T3Status(); |
|
42
|
|
|
$this->plugins['customer.birthday'] = new \Aimeos\Base\Criteria\Plugin\T3Date(); |
|
43
|
|
|
|
|
44
|
|
|
/** mshop/customer/manager/typo3/pid-default |
|
45
|
|
|
* Page ID the customer records are assigned to |
|
46
|
|
|
* |
|
47
|
|
|
* In TYPO3, you can assign fe_user records to different sysfolders based |
|
48
|
|
|
* on their page ID and for checking user credentials at login, the configured |
|
49
|
|
|
* sysfolder is used. Thus, the page ID of the same sysfolder must be assigned |
|
50
|
|
|
* to the user records so they are allowed to log in after they are created |
|
51
|
|
|
* or modified by Aimeos. |
|
52
|
|
|
* |
|
53
|
|
|
* @param int TYPO3 page ID |
|
54
|
|
|
* @since 2016.10 |
|
55
|
|
|
* @see mshop/group/manager/typo3/pid-default |
|
56
|
|
|
*/ |
|
57
|
|
|
$this->pid = (int) $context->config()->get( 'mshop/customer/manager/typo3/pid-default', 0 ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Counts the number items that are available for the values of the given key. |
|
63
|
|
|
* |
|
64
|
|
|
* @param \Aimeos\Base\Criteria\Iface $search Search criteria |
|
65
|
|
|
* @param array|string $key Search key or list of key to aggregate items for |
|
66
|
|
|
* @param string|null $value Search key for aggregating the value column |
|
67
|
|
|
* @param string|null $type Type of the aggregation, empty string for count or "sum" or "avg" (average) |
|
68
|
|
|
* @return \Aimeos\Map List of the search keys as key and the number of counted items as value |
|
69
|
|
|
*/ |
|
70
|
|
|
public function aggregate( \Aimeos\Base\Criteria\Iface $search, $key, ?string $value = null, ?string $type = null ) : \Aimeos\Map |
|
71
|
|
|
{ |
|
72
|
|
|
/** mshop/customer/manager/typo3//aggregate/mysql |
|
73
|
|
|
* Counts the number of records grouped by the values in the key column and matched by the given criteria |
|
74
|
|
|
* |
|
75
|
|
|
* @see mshop/customer/manager/typo3//aggregate/ansi |
|
76
|
|
|
*/ |
|
77
|
|
|
|
|
78
|
|
|
/** mshop/customer/manager/typo3//aggregate/ansi |
|
79
|
|
|
* Counts the number of records grouped by the values in the key column and matched by the given criteria |
|
80
|
|
|
* |
|
81
|
|
|
* Groups all records by the values in the key column and counts their |
|
82
|
|
|
* occurence. The matched records can be limited by the given criteria |
|
83
|
|
|
* from the customer database. The records must be from one of the sites |
|
84
|
|
|
* that are configured via the context item. If the current site is part |
|
85
|
|
|
* of a tree of sites, the statement can count all records from the |
|
86
|
|
|
* current site and the complete sub-tree of sites. |
|
87
|
|
|
* |
|
88
|
|
|
* As the records can normally be limited by criteria from sub-managers, |
|
89
|
|
|
* their tables must be joined in the SQL context. This is done by |
|
90
|
|
|
* using the "internaldeps" property from the definition of the ID |
|
91
|
|
|
* column of the sub-managers. These internal dependencies specify |
|
92
|
|
|
* the JOIN between the tables and the used columns for joining. The |
|
93
|
|
|
* ":joins" placeholder is then replaced by the JOIN strings from |
|
94
|
|
|
* the sub-managers. |
|
95
|
|
|
* |
|
96
|
|
|
* To limit the records matched, conditions can be added to the given |
|
97
|
|
|
* criteria object. It can contain comparisons like column names that |
|
98
|
|
|
* must match specific values which can be combined by AND, OR or NOT |
|
99
|
|
|
* operators. The resulting string of SQL conditions replaces the |
|
100
|
|
|
* ":cond" placeholder before the statement is sent to the database |
|
101
|
|
|
* server. |
|
102
|
|
|
* |
|
103
|
|
|
* This statement doesn't return any records. Instead, it returns pairs |
|
104
|
|
|
* of the different values found in the key column together with the |
|
105
|
|
|
* number of records that have been found for that key values. |
|
106
|
|
|
* |
|
107
|
|
|
* The SQL statement should conform to the ANSI standard to be |
|
108
|
|
|
* compatible with most relational database systems. This also |
|
109
|
|
|
* includes using double quotes for table and column names. |
|
110
|
|
|
* |
|
111
|
|
|
* @param string SQL statement for aggregating customer items |
|
112
|
|
|
* @since 2021.04 |
|
113
|
|
|
* @category Developer |
|
114
|
|
|
* @see mshop/customer/manager/typo3//insert/ansi |
|
115
|
|
|
* @see mshop/customer/manager/typo3//update/ansi |
|
116
|
|
|
* @see mshop/customer/manager/typo3//newid/ansi |
|
117
|
|
|
* @see mshop/customer/manager/typo3//delete/ansi |
|
118
|
|
|
* @see mshop/customer/manager/typo3//search/ansi |
|
119
|
|
|
* @see mshop/customer/manager/typo3//count/ansi |
|
120
|
|
|
*/ |
|
121
|
|
|
|
|
122
|
|
|
$cfgkey = 'mshop/customer/manager/typo3/aggregate' . $type; |
|
123
|
|
|
return $this->aggregateBase( $search, $key, $cfgkey, ['customer'], $value ); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Removes old entries from the storage. |
|
129
|
|
|
* |
|
130
|
|
|
* @param iterable $siteids List of IDs for sites whose entries should be deleted |
|
131
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Same object for fluent interface |
|
132
|
|
|
*/ |
|
133
|
|
|
public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface |
|
134
|
|
|
{ |
|
135
|
|
|
$path = 'mshop/customer/manager/submanagers'; |
|
136
|
|
|
|
|
137
|
|
|
foreach( $this->context()->config()->get( $path, [] ) as $domain ) { |
|
138
|
|
|
$this->object()->getSubManager( $domain )->clear( $siteids ); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
return $this->clearBase( $siteids, 'mshop/customer/manager/typo3/clear' ); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Creates a new empty item instance |
|
147
|
|
|
* |
|
148
|
|
|
* @param array $values Values the item should be initialized with |
|
149
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface New customer item object |
|
150
|
|
|
*/ |
|
151
|
|
|
public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface |
|
152
|
|
|
{ |
|
153
|
|
|
return parent::create( $this->transform( $values ) ); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Removes multiple items. |
|
159
|
|
|
* |
|
160
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $items List of item objects or IDs of the items |
|
161
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager object for chaining method calls |
|
162
|
|
|
*/ |
|
163
|
|
|
public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->deleteItemsBase( $items, 'mshop/customer/manager/typo3/delete', true, 'uid' ); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* Returns the list attributes that can be used for searching. |
|
171
|
|
|
* |
|
172
|
|
|
* @param bool $withsub Return also attributes of sub-managers if true |
|
173
|
|
|
* @return array List of attribute items implementing \Aimeos\Base\Criteria\Attribute\Iface |
|
174
|
|
|
*/ |
|
175
|
|
|
public function getSearchAttributes( bool $withsub = true ) : array |
|
176
|
|
|
{ |
|
177
|
|
|
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
|
178
|
|
|
$level = $this->context()->config()->get( 'mshop/customer/manager/sitemode', $level ); |
|
179
|
|
|
|
|
180
|
|
|
return array_replace( parent::getSearchAttributes( $withsub ), $this->createAttributes( [ |
|
181
|
|
|
'customer.id' => [ |
|
182
|
|
|
'label' => 'ID', |
|
183
|
|
|
'internalcode' => 'uid', |
|
184
|
|
|
'type' => 'int', |
|
185
|
|
|
'public' => false, |
|
186
|
|
|
], |
|
187
|
|
|
'customer.code' => [ |
|
188
|
|
|
'label' => 'Username', |
|
189
|
|
|
'internalcode' => 'username', |
|
190
|
|
|
], |
|
191
|
|
|
'customer.label' => [ |
|
192
|
|
|
'label' => 'Label', |
|
193
|
|
|
'internalcode' => 'name', |
|
194
|
|
|
], |
|
195
|
|
|
'customer.salutation' => [ |
|
196
|
|
|
'label' => 'Salutation', |
|
197
|
|
|
'internalcode' => 'gender', |
|
198
|
|
|
], |
|
199
|
|
|
'customer.firstname' => [ |
|
200
|
|
|
'label' => 'Firstname', |
|
201
|
|
|
'internalcode' => 'first_name', |
|
202
|
|
|
], |
|
203
|
|
|
'customer.lastname' => [ |
|
204
|
|
|
'label' => 'Lastname', |
|
205
|
|
|
'internalcode' => 'last_name', |
|
206
|
|
|
], |
|
207
|
|
|
'customer.address1' => [ |
|
208
|
|
|
'label' => 'Address part one', |
|
209
|
|
|
'internalcode' => 'address', |
|
210
|
|
|
], |
|
211
|
|
|
'customer.address2' => [ |
|
212
|
|
|
'label' => 'Address part two', |
|
213
|
|
|
'internalcode' => 'address', |
|
214
|
|
|
], |
|
215
|
|
|
'customer.address3' => [ |
|
216
|
|
|
'label' => 'Address part three', |
|
217
|
|
|
'internalcode' => 'address', |
|
218
|
|
|
], |
|
219
|
|
|
'customer.postal' => [ |
|
220
|
|
|
'label' => 'Postal', |
|
221
|
|
|
'internalcode' => 'zip', |
|
222
|
|
|
], |
|
223
|
|
|
'customer.state' => [ |
|
224
|
|
|
'label' => 'State', |
|
225
|
|
|
'internalcode' => 'zone', |
|
226
|
|
|
], |
|
227
|
|
|
'customer.languageid' => [ |
|
228
|
|
|
'label' => 'Language', |
|
229
|
|
|
'internalcode' => 'language', |
|
230
|
|
|
], |
|
231
|
|
|
'customer.countryid' => [ |
|
232
|
|
|
'label' => 'Country', |
|
233
|
|
|
'internalcode' => 'static_info_country', |
|
234
|
|
|
], |
|
235
|
|
|
'customer.telefax' => [ |
|
236
|
|
|
'label' => 'Facsimile', |
|
237
|
|
|
'internalcode' => 'fax', |
|
238
|
|
|
], |
|
239
|
|
|
'customer.website' => [ |
|
240
|
|
|
'label' => 'Web site', |
|
241
|
|
|
'internalcode' => 'www', |
|
242
|
|
|
], |
|
243
|
|
|
'customer.birthday' => [ |
|
244
|
|
|
'label' => 'Birthday', |
|
245
|
|
|
'internalcode' => 'date_of_birth', |
|
246
|
|
|
], |
|
247
|
|
|
'customer.status' => [ |
|
248
|
|
|
'label' => 'Status', |
|
249
|
|
|
'internalcode' => 'disable', |
|
250
|
|
|
'type' => 'int', |
|
251
|
|
|
], |
|
252
|
|
|
'customer.ctime' => [ |
|
253
|
|
|
'label' => 'Create date/time', |
|
254
|
|
|
'internalcode' => 'crdate', |
|
255
|
|
|
'type' => 'datetime', |
|
256
|
|
|
'public' => false, |
|
257
|
|
|
], |
|
258
|
|
|
'customer.mtime' => [ |
|
259
|
|
|
'label' => 'Modify date/time', |
|
260
|
|
|
'internalcode' => 'tstamp', |
|
261
|
|
|
'type' => 'datetime', |
|
262
|
|
|
'public' => false, |
|
263
|
|
|
], |
|
264
|
|
|
'customer:has' => [ |
|
265
|
|
|
'code' => 'customer:has()', |
|
266
|
|
|
'internalcode' => ':site AND :key AND mcusli."id"', |
|
267
|
|
|
'internaldeps' => ['LEFT JOIN "fe_users_list" AS mcusli ON ( mcusli."parentid" = mcus."uid" )'], |
|
268
|
|
|
'label' => 'Customer has list item, parameter(<domain>[,<list type>[,<reference ID>)]]', |
|
269
|
|
|
'type' => 'null', |
|
270
|
|
|
'public' => false, |
|
271
|
|
|
'function' => function( &$source, array $params ) use ( $level ) { |
|
272
|
|
|
$keys = []; |
|
273
|
|
|
|
|
274
|
|
|
foreach( (array) ( $params[1] ?? '' ) as $type ) { |
|
275
|
|
|
foreach( (array) ( $params[2] ?? '' ) as $id ) { |
|
276
|
|
|
$keys[] = $params[0] . '|' . ( $type ? $type . '|' : '' ) . $id; |
|
277
|
|
|
} |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
$sitestr = $this->siteString( 'mcusli."siteid"', $level ); |
|
281
|
|
|
$keystr = $this->toExpression( 'mcusli."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' ); |
|
282
|
|
|
$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source ); |
|
283
|
|
|
|
|
284
|
|
|
return $params; |
|
285
|
|
|
} |
|
286
|
|
|
], |
|
287
|
|
|
'customer:prop' => [ |
|
288
|
|
|
'code' => 'customer:prop()', |
|
289
|
|
|
'internalcode' => ':site AND :key AND mcuspr."id"', |
|
290
|
|
|
'internaldeps' => ['LEFT JOIN "fe_users_property" AS mcuspr ON ( mcuspr."parentid" = mcus."uid" )'], |
|
291
|
|
|
'label' => 'Customer has property item, parameter(<property type>[,<language code>[,<property value>]])', |
|
292
|
|
|
'type' => 'null', |
|
293
|
|
|
'public' => false, |
|
294
|
|
|
'function' => function( &$source, array $params ) use ( $level ) { |
|
295
|
|
|
$keys = []; |
|
296
|
|
|
$langs = array_key_exists( 1, $params ) ? ( $params[1] ?? 'null' ) : ''; |
|
297
|
|
|
|
|
298
|
|
|
foreach( (array) $langs as $lang ) { |
|
299
|
|
|
foreach( (array) ( $params[2] ?? '' ) as $val ) { |
|
300
|
|
|
$keys[] = substr( $params[0] . '|' . ( $lang === null ? 'null|' : ( $lang ? $lang . '|' : '' ) ) . $val, 0, 255 ); |
|
301
|
|
|
} |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
$sitestr = $this->siteString( 'mcuspr."siteid"', $level ); |
|
305
|
|
|
$keystr = $this->toExpression( 'mcuspr."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' ); |
|
306
|
|
|
$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source ); |
|
307
|
|
|
|
|
308
|
|
|
return $params; |
|
309
|
|
|
} |
|
310
|
|
|
], |
|
311
|
|
|
// TYPO3 specific |
|
312
|
|
|
'customer.groups' => [ |
|
313
|
|
|
'label' => 'Customer groups', |
|
314
|
|
|
'internalcode' => 'mcus."usergroup"', |
|
315
|
|
|
'type' => 'string', |
|
316
|
|
|
] |
|
317
|
|
|
] ) ); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* Saves a customer item object. |
|
323
|
|
|
* |
|
324
|
|
|
* @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
|
325
|
|
|
* @param bool $fetch True if the new ID should be returned in the item |
|
326
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface $item Updated item including the generated ID |
|
327
|
|
|
*/ |
|
328
|
|
|
protected function saveItem( \Aimeos\MShop\Customer\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Customer\Item\Iface |
|
329
|
|
|
{ |
|
330
|
|
|
if( !$item->isModified() ) { |
|
331
|
|
|
return $this->object()->saveRefs( $item, $fetch ); |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
$context = $this->context(); |
|
335
|
|
|
$conn = $context->db( $this->getResourceName() ); |
|
336
|
|
|
$time = date_create_from_format( 'Y-m-d H:i:s', $context->datetime() )->getTimestamp(); |
|
337
|
|
|
|
|
338
|
|
|
$id = $item->getId(); |
|
339
|
|
|
$billingAddress = $item->getPaymentAddress(); |
|
340
|
|
|
$columns = $this->object()->getSaveAttributes(); |
|
341
|
|
|
|
|
342
|
|
|
if( $id === null ) |
|
343
|
|
|
{ |
|
344
|
|
|
/** mshop/customer/manager/typo3/insert |
|
345
|
|
|
* Inserts a new customer record into the database table |
|
346
|
|
|
* |
|
347
|
|
|
* Items with no ID yet (i.e. the ID is NULL) will be created in |
|
348
|
|
|
* the database and the newly created ID retrieved afterwards |
|
349
|
|
|
* using the "newid" SQL statement. |
|
350
|
|
|
* |
|
351
|
|
|
* The SQL statement must be a string suitable for being used as |
|
352
|
|
|
* prepared statement. It must include question marks for binding |
|
353
|
|
|
* the values from the customer item to the statement before they are |
|
354
|
|
|
* sent to the database server. The number of question marks must |
|
355
|
|
|
* be the same as the number of columns listed in the INSERT |
|
356
|
|
|
* statement. The order of the columns must correspond to the |
|
357
|
|
|
* order in the save() method, so the correct values are |
|
358
|
|
|
* bound to the columns. |
|
359
|
|
|
* |
|
360
|
|
|
* The SQL statement should conform to the ANSI standard to be |
|
361
|
|
|
* compatible with most relational database systems. This also |
|
362
|
|
|
* includes using double quotes for table and column names. |
|
363
|
|
|
* |
|
364
|
|
|
* @param string SQL statement for inserting records |
|
365
|
|
|
* @since 2014.03 |
|
366
|
|
|
* @category Developer |
|
367
|
|
|
* @see mshop/customer/manager/typo3/update |
|
368
|
|
|
* @see mshop/customer/manager/typo3/newid |
|
369
|
|
|
* @see mshop/customer/manager/typo3/delete |
|
370
|
|
|
* @see mshop/customer/manager/typo3/search |
|
371
|
|
|
* @see mshop/customer/manager/typo3/count |
|
372
|
|
|
*/ |
|
373
|
|
|
$path = 'mshop/customer/manager/typo3/insert'; |
|
374
|
|
|
$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ) ); |
|
|
|
|
|
|
375
|
|
|
} |
|
376
|
|
|
else |
|
377
|
|
|
{ |
|
378
|
|
|
/** mshop/customer/manager/typo3/update |
|
379
|
|
|
* Updates an existing customer record in the database |
|
380
|
|
|
* |
|
381
|
|
|
* Items which already have an ID (i.e. the ID is not NULL) will |
|
382
|
|
|
* be updated in the database. |
|
383
|
|
|
* |
|
384
|
|
|
* The SQL statement must be a string suitable for being used as |
|
385
|
|
|
* prepared statement. It must include question marks for binding |
|
386
|
|
|
* the values from the customer item to the statement before they are |
|
387
|
|
|
* sent to the database server. The order of the columns must |
|
388
|
|
|
* correspond to the order in the save() method, so the |
|
389
|
|
|
* correct values are bound to the columns. |
|
390
|
|
|
* |
|
391
|
|
|
* The SQL statement should conform to the ANSI standard to be |
|
392
|
|
|
* compatible with most relational database systems. This also |
|
393
|
|
|
* includes using double quotes for table and column names. |
|
394
|
|
|
* |
|
395
|
|
|
* @param string SQL statement for updating records |
|
396
|
|
|
* @since 2014.03 |
|
397
|
|
|
* @category Developer |
|
398
|
|
|
* @see mshop/customer/manager/typo3/insert |
|
399
|
|
|
* @see mshop/customer/manager/typo3/newid |
|
400
|
|
|
* @see mshop/customer/manager/typo3/delete |
|
401
|
|
|
* @see mshop/customer/manager/typo3/search |
|
402
|
|
|
* @see mshop/customer/manager/typo3/count |
|
403
|
|
|
*/ |
|
404
|
|
|
$path = 'mshop/customer/manager/typo3/update'; |
|
405
|
|
|
$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ), false ); |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
$address = join( '|', array_filter( [ |
|
409
|
|
|
$billingAddress->getAddress1(), |
|
410
|
|
|
$billingAddress->getAddress2(), |
|
411
|
|
|
$billingAddress->getAddress3(), |
|
412
|
|
|
] ) ); |
|
413
|
|
|
|
|
414
|
|
|
$idx = 1; |
|
415
|
|
|
$stmt = $this->getCachedStatement( $conn, $path, $sql ); |
|
416
|
|
|
|
|
417
|
|
|
foreach( $columns as $name => $entry ) { |
|
418
|
|
|
$stmt->bind( $idx++, $item->get( $name ), \Aimeos\Base\Criteria\SQL::type( $entry->getType() ) ); |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
// TYPO3 fe_users.static_info_country is a three letter ISO code instead a two letter one |
|
422
|
|
|
$stmt->bind( $idx++, $item->getLabel() ); |
|
423
|
|
|
$stmt->bind( $idx++, $item->getCode() ); |
|
424
|
|
|
$stmt->bind( $idx++, $this->plugins['customer.salutation']->translate( $billingAddress->getSalutation() ), \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
|
425
|
|
|
$stmt->bind( $idx++, $billingAddress->getCompany() ); |
|
426
|
|
|
$stmt->bind( $idx++, $billingAddress->getVatID() ); |
|
427
|
|
|
$stmt->bind( $idx++, $billingAddress->getTitle() ); |
|
428
|
|
|
$stmt->bind( $idx++, $billingAddress->getFirstname() ); |
|
429
|
|
|
$stmt->bind( $idx++, $billingAddress->getLastname() ); |
|
430
|
|
|
$stmt->bind( $idx++, $address ); |
|
431
|
|
|
$stmt->bind( $idx++, $billingAddress->getPostal() ); |
|
432
|
|
|
$stmt->bind( $idx++, $billingAddress->getCity() ); |
|
433
|
|
|
$stmt->bind( $idx++, $billingAddress->getState() ); |
|
434
|
|
|
$stmt->bind( $idx++, $billingAddress->getLanguageId() ); |
|
435
|
|
|
$stmt->bind( $idx++, $billingAddress->getTelephone() ); |
|
436
|
|
|
$stmt->bind( $idx++, $billingAddress->getMobile() ); |
|
437
|
|
|
$stmt->bind( $idx++, $billingAddress->getEmail() ); |
|
438
|
|
|
$stmt->bind( $idx++, $billingAddress->getTelefax() ); |
|
439
|
|
|
$stmt->bind( $idx++, $billingAddress->getWebsite() ); |
|
440
|
|
|
$stmt->bind( $idx++, $billingAddress->getLongitude(), \Aimeos\Base\DB\Statement\Base::PARAM_FLOAT ); |
|
441
|
|
|
$stmt->bind( $idx++, $billingAddress->getLatitude(), \Aimeos\Base\DB\Statement\Base::PARAM_FLOAT ); |
|
442
|
|
|
$stmt->bind( $idx++, $this->plugins['customer.birthday']->translate( $billingAddress->getBirthday() ), \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
|
443
|
|
|
$stmt->bind( $idx++, $this->plugins['customer.status']->translate( $item->getStatus() ), \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
|
444
|
|
|
$stmt->bind( $idx++, $item->getPassword() ); |
|
445
|
|
|
$stmt->bind( $idx++, $time, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); // Modification time |
|
446
|
|
|
$stmt->bind( $idx++, $billingAddress->getCountryId() ); |
|
447
|
|
|
$stmt->bind( $idx++, implode( ',', $item->getGroups() ) ); |
|
448
|
|
|
$stmt->bind( $idx++, $this->pid, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); // TYPO3 PID value |
|
449
|
|
|
$stmt->bind( $idx++, $context->editor() ); |
|
450
|
|
|
|
|
451
|
|
|
if( $id !== null ) { |
|
452
|
|
|
$stmt->bind( $idx++, $context->locale()->getSiteId() . '%' ); |
|
453
|
|
|
$stmt->bind( $idx++, (string) $context->user()?->getSiteId() ); |
|
454
|
|
|
$stmt->bind( $idx, $id, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
|
455
|
|
|
$item->setId( $id ); |
|
456
|
|
|
} else { |
|
457
|
|
|
$stmt->bind( $idx++, $this->siteId( $item->getSiteId(), \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE ) ); |
|
458
|
|
|
$stmt->bind( $idx, $time, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); // Creation time |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
$stmt->execute()->finish(); |
|
462
|
|
|
|
|
463
|
|
|
if( $id === null && $fetch === true ) |
|
464
|
|
|
{ |
|
465
|
|
|
/** mshop/customer/manager/typo3/newid |
|
466
|
|
|
* Retrieves the ID generated by the database when inserting a new record |
|
467
|
|
|
* |
|
468
|
|
|
* As soon as a new record is inserted into the database table, |
|
469
|
|
|
* the database server generates a new and unique identifier for |
|
470
|
|
|
* that record. This ID can be used for retrieving, updating and |
|
471
|
|
|
* deleting that specific record from the table again. |
|
472
|
|
|
* |
|
473
|
|
|
* For MySQL: |
|
474
|
|
|
* SELECT LAST_INSERT_ID() |
|
475
|
|
|
* For PostgreSQL: |
|
476
|
|
|
* SELECT currval('seq_mcus_id') |
|
477
|
|
|
* For SQL Server: |
|
478
|
|
|
* SELECT SCOPE_IDENTITY() |
|
479
|
|
|
* For Oracle: |
|
480
|
|
|
* SELECT "seq_mcus_id".CURRVAL FROM DUAL |
|
481
|
|
|
* |
|
482
|
|
|
* There's no way to retrive the new ID by a SQL statements that |
|
483
|
|
|
* fits for most database servers as they implement their own |
|
484
|
|
|
* specific way. |
|
485
|
|
|
* |
|
486
|
|
|
* @param string SQL statement for retrieving the last inserted record ID |
|
487
|
|
|
* @since 2014.03 |
|
488
|
|
|
* @category Developer |
|
489
|
|
|
* @see mshop/customer/manager/typo3/insert |
|
490
|
|
|
* @see mshop/customer/manager/typo3/update |
|
491
|
|
|
* @see mshop/customer/manager/typo3/delete |
|
492
|
|
|
* @see mshop/customer/manager/typo3/search |
|
493
|
|
|
* @see mshop/customer/manager/typo3/count |
|
494
|
|
|
*/ |
|
495
|
|
|
$path = 'mshop/customer/manager/typo3/newid'; |
|
496
|
|
|
$id = $this->newId( $conn, $path ); |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
return $this->object()->saveRefs( $item->setId( $id ), $fetch ); |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
|
|
503
|
|
|
/** |
|
504
|
|
|
* Returns the full configuration key for the passed last part |
|
505
|
|
|
* |
|
506
|
|
|
* @param string $name Configuration last part |
|
507
|
|
|
* @return string Full configuration key |
|
508
|
|
|
*/ |
|
509
|
|
|
protected function getConfigKey( string $name, string $default = '' ) : string |
|
510
|
|
|
{ |
|
511
|
|
|
if( $this->context()->config()->get( 'mshop/customer/manager/typo3/' . $name ) ) { |
|
512
|
|
|
return 'mshop/customer/manager/typo3/' . $name; |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
return parent::getConfigKey( $name, $default ); |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
|
|
519
|
|
|
/** |
|
520
|
|
|
* Returns a new manager for customer extensions |
|
521
|
|
|
* |
|
522
|
|
|
* @param string $manager Name of the sub manager type in lower case |
|
523
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
|
524
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc. |
|
525
|
|
|
*/ |
|
526
|
|
|
public function getSubManager( string $manager, ?string $name = null ) : \Aimeos\MShop\Common\Manager\Iface |
|
527
|
|
|
{ |
|
528
|
|
|
return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Typo3' : $name ) ); |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
|
|
532
|
|
|
/** |
|
533
|
|
|
* Returns the name of the used table |
|
534
|
|
|
* |
|
535
|
|
|
* @return string Table name |
|
536
|
|
|
*/ |
|
537
|
|
|
protected function table() : string |
|
538
|
|
|
{ |
|
539
|
|
|
return 'fe_users'; |
|
540
|
|
|
} |
|
541
|
|
|
|
|
542
|
|
|
|
|
543
|
|
|
/** |
|
544
|
|
|
* Returns the search plugins for transforming the search criteria |
|
545
|
|
|
* |
|
546
|
|
|
* @return \Aimeos\MW\Criteria\Plugin\Iface[] List of search plugins |
|
547
|
|
|
*/ |
|
548
|
|
|
protected function searchPlugins() : array |
|
549
|
|
|
{ |
|
550
|
|
|
return $this->plugins; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
|
|
554
|
|
|
/** |
|
555
|
|
|
* Transforms the application specific values to Aimeos standard values. |
|
556
|
|
|
* |
|
557
|
|
|
* @param array $values Associative list of key/value pairs from the storage |
|
558
|
|
|
* @return array Associative list of key/value pairs with standard Aimeos values |
|
559
|
|
|
*/ |
|
560
|
|
|
protected function transform( array $values ) : array |
|
561
|
|
|
{ |
|
562
|
|
|
if( array_key_exists( 'customer.birthday', $values ) ) { |
|
563
|
|
|
$values['customer.birthday'] = $this->plugins['customer.birthday']->reverse( $values['customer.birthday'] ); |
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
if( array_key_exists( 'customer.salutation', $values ) ) { |
|
567
|
|
|
$values['customer.salutation'] = $this->plugins['customer.salutation']->reverse( $values['customer.salutation'] ); |
|
568
|
|
|
} |
|
569
|
|
|
|
|
570
|
|
|
if( array_key_exists( 'customer.status', $values ) ) { |
|
571
|
|
|
$values['customer.status'] = $this->plugins['customer.status']->reverse( $values['customer.status'] ); |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
|
|
if( array_key_exists( 'customer.mtime', $values ) ) { |
|
575
|
|
|
$values['customer.mtime'] = $this->plugins['customer.mtime']->reverse( $values['customer.mtime'] ); |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
if( array_key_exists( 'customer.ctime', $values ) ) { |
|
579
|
|
|
$values['customer.ctime'] = $this->plugins['customer.ctime']->reverse( $values['customer.ctime'] ); |
|
580
|
|
|
} |
|
581
|
|
|
|
|
582
|
|
|
if( array_key_exists( 'customer.groups', $values ) ) { |
|
583
|
|
|
$values['customer.groups'] = $values['customer.groups'] !== '' ? explode( ',', $values['customer.groups'] ) : []; |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
if( array_key_exists( 'customer.address1', $values ) ) |
|
587
|
|
|
{ |
|
588
|
|
|
$parts = explode( '|', (string) $values['customer.address1'] ); |
|
589
|
|
|
$values['customer.address1'] = $parts[0] ?? ''; |
|
590
|
|
|
$values['customer.address2'] = $parts[1] ?? ''; |
|
591
|
|
|
$values['customer.address3'] = join( ', ', array_slice( $parts, 2 ) ); |
|
592
|
|
|
} |
|
593
|
|
|
|
|
594
|
|
|
return $values; |
|
595
|
|
|
} |
|
596
|
|
|
} |
|
597
|
|
|
|