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-2024 |
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
|
|
|
$path = 'mshop/customer/manager/typo3/delete'; |
166
|
|
|
return $this->deleteItemsBase( $items, $path, true, 'uid' )->deleteRefItems( $items ); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Returns the list attributes that can be used for searching. |
172
|
|
|
* |
173
|
|
|
* @param bool $withsub Return also attributes of sub-managers if true |
174
|
|
|
* @return array List of attribute items implementing \Aimeos\Base\Criteria\Attribute\Iface |
175
|
|
|
*/ |
176
|
|
|
public function getSearchAttributes( bool $withsub = true ) : array |
177
|
|
|
{ |
178
|
|
|
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
179
|
|
|
$level = $this->context()->config()->get( 'mshop/customer/manager/sitemode', $level ); |
180
|
|
|
|
181
|
|
|
return array_replace( parent::getSearchAttributes( $withsub ), $this->createAttributes( [ |
182
|
|
|
'customer.id' => [ |
183
|
|
|
'label' => 'ID', |
184
|
|
|
'internalcode' => 'uid', |
185
|
|
|
'type' => 'int', |
186
|
|
|
'public' => false, |
187
|
|
|
], |
188
|
|
|
'customer.code' => [ |
189
|
|
|
'label' => 'Username', |
190
|
|
|
'internalcode' => 'username', |
191
|
|
|
], |
192
|
|
|
'customer.label' => [ |
193
|
|
|
'label' => 'Label', |
194
|
|
|
'internalcode' => 'name', |
195
|
|
|
], |
196
|
|
|
'customer.salutation' => [ |
197
|
|
|
'label' => 'Salutation', |
198
|
|
|
'internalcode' => 'gender', |
199
|
|
|
], |
200
|
|
|
'customer.firstname' => [ |
201
|
|
|
'label' => 'Firstname', |
202
|
|
|
'internalcode' => 'first_name', |
203
|
|
|
], |
204
|
|
|
'customer.lastname' => [ |
205
|
|
|
'label' => 'Lastname', |
206
|
|
|
'internalcode' => 'last_name', |
207
|
|
|
], |
208
|
|
|
'customer.address1' => [ |
209
|
|
|
'label' => 'Address part one', |
210
|
|
|
'internalcode' => 'address', |
211
|
|
|
], |
212
|
|
|
'customer.address2' => [ |
213
|
|
|
'label' => 'Address part two', |
214
|
|
|
'internalcode' => 'address', |
215
|
|
|
], |
216
|
|
|
'customer.address3' => [ |
217
|
|
|
'label' => 'Address part three', |
218
|
|
|
'internalcode' => 'address', |
219
|
|
|
], |
220
|
|
|
'customer.postal' => [ |
221
|
|
|
'label' => 'Postal', |
222
|
|
|
'internalcode' => 'zip', |
223
|
|
|
], |
224
|
|
|
'customer.state' => [ |
225
|
|
|
'label' => 'State', |
226
|
|
|
'internalcode' => 'zone', |
227
|
|
|
], |
228
|
|
|
'customer.languageid' => [ |
229
|
|
|
'label' => 'Language', |
230
|
|
|
'internalcode' => 'language', |
231
|
|
|
], |
232
|
|
|
'customer.countryid' => [ |
233
|
|
|
'label' => 'Country', |
234
|
|
|
'internalcode' => 'static_info_country', |
235
|
|
|
], |
236
|
|
|
'customer.telefax' => [ |
237
|
|
|
'label' => 'Facsimile', |
238
|
|
|
'internalcode' => 'fax', |
239
|
|
|
], |
240
|
|
|
'customer.website' => [ |
241
|
|
|
'label' => 'Web site', |
242
|
|
|
'internalcode' => 'www', |
243
|
|
|
], |
244
|
|
|
'customer.birthday' => [ |
245
|
|
|
'label' => 'Birthday', |
246
|
|
|
'internalcode' => 'date_of_birth', |
247
|
|
|
], |
248
|
|
|
'customer.status' => [ |
249
|
|
|
'label' => 'Status', |
250
|
|
|
'internalcode' => 'disable', |
251
|
|
|
'type' => 'int', |
252
|
|
|
], |
253
|
|
|
'customer.ctime' => [ |
254
|
|
|
'label' => 'Create date/time', |
255
|
|
|
'internalcode' => 'crdate', |
256
|
|
|
'type' => 'datetime', |
257
|
|
|
'public' => false, |
258
|
|
|
], |
259
|
|
|
'customer.mtime' => [ |
260
|
|
|
'label' => 'Modify date/time', |
261
|
|
|
'internalcode' => 'tstamp', |
262
|
|
|
'type' => 'datetime', |
263
|
|
|
'public' => false, |
264
|
|
|
], |
265
|
|
|
'customer:has' => [ |
266
|
|
|
'code' => 'customer:has()', |
267
|
|
|
'internalcode' => ':site AND :key AND mcusli."id"', |
268
|
|
|
'internaldeps' => ['LEFT JOIN "fe_users_list" AS mcusli ON ( mcusli."parentid" = mcus."uid" )'], |
269
|
|
|
'label' => 'Customer has list item, parameter(<domain>[,<list type>[,<reference ID>)]]', |
270
|
|
|
'type' => 'null', |
271
|
|
|
'public' => false, |
272
|
|
|
'function' => function( &$source, array $params ) use ( $level ) { |
273
|
|
|
$keys = []; |
274
|
|
|
|
275
|
|
|
foreach( (array) ( $params[1] ?? '' ) as $type ) { |
276
|
|
|
foreach( (array) ( $params[2] ?? '' ) as $id ) { |
277
|
|
|
$keys[] = $params[0] . '|' . ( $type ? $type . '|' : '' ) . $id; |
278
|
|
|
} |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
$sitestr = $this->siteString( 'mcusli."siteid"', $level ); |
282
|
|
|
$keystr = $this->toExpression( 'mcusli."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' ); |
283
|
|
|
$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source ); |
284
|
|
|
|
285
|
|
|
return $params; |
286
|
|
|
} |
287
|
|
|
], |
288
|
|
|
'customer:prop' => [ |
289
|
|
|
'code' => 'customer:prop()', |
290
|
|
|
'internalcode' => ':site AND :key AND mcuspr."id"', |
291
|
|
|
'internaldeps' => ['LEFT JOIN "fe_users_property" AS mcuspr ON ( mcuspr."parentid" = mcus."uid" )'], |
292
|
|
|
'label' => 'Customer has property item, parameter(<property type>[,<language code>[,<property value>]])', |
293
|
|
|
'type' => 'null', |
294
|
|
|
'public' => false, |
295
|
|
|
'function' => function( &$source, array $params ) use ( $level ) { |
296
|
|
|
$keys = []; |
297
|
|
|
$langs = array_key_exists( 1, $params ) ? ( $params[1] ?? 'null' ) : ''; |
298
|
|
|
|
299
|
|
|
foreach( (array) $langs as $lang ) { |
300
|
|
|
foreach( (array) ( $params[2] ?? '' ) as $val ) { |
301
|
|
|
$keys[] = substr( $params[0] . '|' . ( $lang === null ? 'null|' : ( $lang ? $lang . '|' : '' ) ) . $val, 0, 255 ); |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
$sitestr = $this->siteString( 'mcuspr."siteid"', $level ); |
306
|
|
|
$keystr = $this->toExpression( 'mcuspr."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' ); |
307
|
|
|
$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source ); |
308
|
|
|
|
309
|
|
|
return $params; |
310
|
|
|
} |
311
|
|
|
], |
312
|
|
|
// TYPO3 specific |
313
|
|
|
'customer.groups' => [ |
314
|
|
|
'label' => 'Customer groups', |
315
|
|
|
'internalcode' => 'mcus."usergroup"', |
316
|
|
|
'type' => 'string', |
317
|
|
|
] |
318
|
|
|
] ) ); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Saves a customer item object. |
324
|
|
|
* |
325
|
|
|
* @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
326
|
|
|
* @param bool $fetch True if the new ID should be returned in the item |
327
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface $item Updated item including the generated ID |
328
|
|
|
*/ |
329
|
|
|
protected function saveItem( \Aimeos\MShop\Customer\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Customer\Item\Iface |
330
|
|
|
{ |
331
|
|
|
if( !$item->isModified() ) { |
332
|
|
|
return $this->saveDeps( $item, $fetch ); |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
$context = $this->context(); |
336
|
|
|
$conn = $context->db( $this->getResourceName() ); |
337
|
|
|
$time = date_create_from_format( 'Y-m-d H:i:s', $context->datetime() )->getTimestamp(); |
338
|
|
|
|
339
|
|
|
$id = $item->getId(); |
340
|
|
|
$billingAddress = $item->getPaymentAddress(); |
341
|
|
|
$columns = $this->object()->getSaveAttributes(); |
342
|
|
|
|
343
|
|
|
if( $id === null ) |
344
|
|
|
{ |
345
|
|
|
/** mshop/customer/manager/typo3/insert |
346
|
|
|
* Inserts a new customer record into the database table |
347
|
|
|
* |
348
|
|
|
* Items with no ID yet (i.e. the ID is NULL) will be created in |
349
|
|
|
* the database and the newly created ID retrieved afterwards |
350
|
|
|
* using the "newid" SQL statement. |
351
|
|
|
* |
352
|
|
|
* The SQL statement must be a string suitable for being used as |
353
|
|
|
* prepared statement. It must include question marks for binding |
354
|
|
|
* the values from the customer item to the statement before they are |
355
|
|
|
* sent to the database server. The number of question marks must |
356
|
|
|
* be the same as the number of columns listed in the INSERT |
357
|
|
|
* statement. The order of the columns must correspond to the |
358
|
|
|
* order in the save() method, so the correct values are |
359
|
|
|
* bound to the columns. |
360
|
|
|
* |
361
|
|
|
* The SQL statement should conform to the ANSI standard to be |
362
|
|
|
* compatible with most relational database systems. This also |
363
|
|
|
* includes using double quotes for table and column names. |
364
|
|
|
* |
365
|
|
|
* @param string SQL statement for inserting records |
366
|
|
|
* @since 2014.03 |
367
|
|
|
* @category Developer |
368
|
|
|
* @see mshop/customer/manager/typo3/update |
369
|
|
|
* @see mshop/customer/manager/typo3/newid |
370
|
|
|
* @see mshop/customer/manager/typo3/delete |
371
|
|
|
* @see mshop/customer/manager/typo3/search |
372
|
|
|
* @see mshop/customer/manager/typo3/count |
373
|
|
|
*/ |
374
|
|
|
$path = 'mshop/customer/manager/typo3/insert'; |
375
|
|
|
$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ) ); |
|
|
|
|
376
|
|
|
} |
377
|
|
|
else |
378
|
|
|
{ |
379
|
|
|
/** mshop/customer/manager/typo3/update |
380
|
|
|
* Updates an existing customer record in the database |
381
|
|
|
* |
382
|
|
|
* Items which already have an ID (i.e. the ID is not NULL) will |
383
|
|
|
* be updated in the database. |
384
|
|
|
* |
385
|
|
|
* The SQL statement must be a string suitable for being used as |
386
|
|
|
* prepared statement. It must include question marks for binding |
387
|
|
|
* the values from the customer item to the statement before they are |
388
|
|
|
* sent to the database server. The order of the columns must |
389
|
|
|
* correspond to the order in the save() method, so the |
390
|
|
|
* correct values are bound to the columns. |
391
|
|
|
* |
392
|
|
|
* The SQL statement should conform to the ANSI standard to be |
393
|
|
|
* compatible with most relational database systems. This also |
394
|
|
|
* includes using double quotes for table and column names. |
395
|
|
|
* |
396
|
|
|
* @param string SQL statement for updating records |
397
|
|
|
* @since 2014.03 |
398
|
|
|
* @category Developer |
399
|
|
|
* @see mshop/customer/manager/typo3/insert |
400
|
|
|
* @see mshop/customer/manager/typo3/newid |
401
|
|
|
* @see mshop/customer/manager/typo3/delete |
402
|
|
|
* @see mshop/customer/manager/typo3/search |
403
|
|
|
* @see mshop/customer/manager/typo3/count |
404
|
|
|
*/ |
405
|
|
|
$path = 'mshop/customer/manager/typo3/update'; |
406
|
|
|
$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ), false ); |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
$address = join( ' ', array_filter( [ |
410
|
|
|
$billingAddress->getAddress1(), |
411
|
|
|
$billingAddress->getAddress2(), |
412
|
|
|
$billingAddress->getAddress3(), |
413
|
|
|
] ) ); |
414
|
|
|
|
415
|
|
|
$idx = 1; |
416
|
|
|
$stmt = $this->getCachedStatement( $conn, $path, $sql ); |
417
|
|
|
|
418
|
|
|
foreach( $columns as $name => $entry ) { |
419
|
|
|
$stmt->bind( $idx++, $item->get( $name ), \Aimeos\Base\Criteria\SQL::type( $entry->getType() ) ); |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
// TYPO3 fe_users.static_info_country is a three letter ISO code instead a two letter one |
423
|
|
|
$stmt->bind( $idx++, $item->getLabel() ); |
424
|
|
|
$stmt->bind( $idx++, $item->getCode() ); |
425
|
|
|
$stmt->bind( $idx++, $this->plugins['customer.salutation']->translate( $billingAddress->getSalutation() ), \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
426
|
|
|
$stmt->bind( $idx++, $billingAddress->getCompany() ); |
427
|
|
|
$stmt->bind( $idx++, $billingAddress->getVatID() ); |
428
|
|
|
$stmt->bind( $idx++, $billingAddress->getTitle() ); |
429
|
|
|
$stmt->bind( $idx++, $billingAddress->getFirstname() ); |
430
|
|
|
$stmt->bind( $idx++, $billingAddress->getLastname() ); |
431
|
|
|
$stmt->bind( $idx++, $address ); |
432
|
|
|
$stmt->bind( $idx++, $billingAddress->getPostal() ); |
433
|
|
|
$stmt->bind( $idx++, $billingAddress->getCity() ); |
434
|
|
|
$stmt->bind( $idx++, $billingAddress->getState() ); |
435
|
|
|
$stmt->bind( $idx++, $billingAddress->getLanguageId() ); |
436
|
|
|
$stmt->bind( $idx++, $billingAddress->getTelephone() ); |
437
|
|
|
$stmt->bind( $idx++, $billingAddress->getMobile() ); |
438
|
|
|
$stmt->bind( $idx++, $billingAddress->getEmail() ); |
439
|
|
|
$stmt->bind( $idx++, $billingAddress->getTelefax() ); |
440
|
|
|
$stmt->bind( $idx++, $billingAddress->getWebsite() ); |
441
|
|
|
$stmt->bind( $idx++, $billingAddress->getLongitude(), \Aimeos\Base\DB\Statement\Base::PARAM_FLOAT ); |
442
|
|
|
$stmt->bind( $idx++, $billingAddress->getLatitude(), \Aimeos\Base\DB\Statement\Base::PARAM_FLOAT ); |
443
|
|
|
$stmt->bind( $idx++, $this->plugins['customer.birthday']->translate( $billingAddress->getBirthday() ), \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
444
|
|
|
$stmt->bind( $idx++, $this->plugins['customer.status']->translate( $item->getStatus() ), \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
445
|
|
|
$stmt->bind( $idx++, $item->getPassword() ); |
446
|
|
|
$stmt->bind( $idx++, $time, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); // Modification time |
447
|
|
|
$stmt->bind( $idx++, $billingAddress->getCountryId() ); |
448
|
|
|
$stmt->bind( $idx++, implode( ',', $item->getGroups() ) ); |
449
|
|
|
$stmt->bind( $idx++, $this->pid, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); // TYPO3 PID value |
450
|
|
|
$stmt->bind( $idx++, $context->editor() ); |
451
|
|
|
|
452
|
|
|
if( $id !== null ) { |
453
|
|
|
$stmt->bind( $idx++, $context->locale()->getSiteId() . '%' ); |
454
|
|
|
$stmt->bind( $idx++, $this->getUser()?->getSiteId() ); |
455
|
|
|
$stmt->bind( $idx, $id, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
456
|
|
|
$item->setId( $id ); |
457
|
|
|
} else { |
458
|
|
|
$stmt->bind( $idx++, $this->siteId( $item->getSiteId(), \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE ) ); |
459
|
|
|
$stmt->bind( $idx, $time, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); // Creation time |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
$stmt->execute()->finish(); |
463
|
|
|
|
464
|
|
|
if( $id === null && $fetch === true ) |
465
|
|
|
{ |
466
|
|
|
/** mshop/customer/manager/typo3/newid |
467
|
|
|
* Retrieves the ID generated by the database when inserting a new record |
468
|
|
|
* |
469
|
|
|
* As soon as a new record is inserted into the database table, |
470
|
|
|
* the database server generates a new and unique identifier for |
471
|
|
|
* that record. This ID can be used for retrieving, updating and |
472
|
|
|
* deleting that specific record from the table again. |
473
|
|
|
* |
474
|
|
|
* For MySQL: |
475
|
|
|
* SELECT LAST_INSERT_ID() |
476
|
|
|
* For PostgreSQL: |
477
|
|
|
* SELECT currval('seq_mcus_id') |
478
|
|
|
* For SQL Server: |
479
|
|
|
* SELECT SCOPE_IDENTITY() |
480
|
|
|
* For Oracle: |
481
|
|
|
* SELECT "seq_mcus_id".CURRVAL FROM DUAL |
482
|
|
|
* |
483
|
|
|
* There's no way to retrive the new ID by a SQL statements that |
484
|
|
|
* fits for most database servers as they implement their own |
485
|
|
|
* specific way. |
486
|
|
|
* |
487
|
|
|
* @param string SQL statement for retrieving the last inserted record ID |
488
|
|
|
* @since 2014.03 |
489
|
|
|
* @category Developer |
490
|
|
|
* @see mshop/customer/manager/typo3/insert |
491
|
|
|
* @see mshop/customer/manager/typo3/update |
492
|
|
|
* @see mshop/customer/manager/typo3/delete |
493
|
|
|
* @see mshop/customer/manager/typo3/search |
494
|
|
|
* @see mshop/customer/manager/typo3/count |
495
|
|
|
*/ |
496
|
|
|
$path = 'mshop/customer/manager/typo3/newid'; |
497
|
|
|
$id = $this->newId( $conn, $path ); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
return $this->saveDeps( $item->setId( $id ), $fetch ); |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
|
504
|
|
|
/** |
505
|
|
|
* Returns the full configuration key for the passed last part |
506
|
|
|
* |
507
|
|
|
* @param string $name Configuration last part |
508
|
|
|
* @return string Full configuration key |
509
|
|
|
*/ |
510
|
|
|
protected function getConfigKey( string $name, string $default = '' ) : string |
511
|
|
|
{ |
512
|
|
|
if( $this->context()->config()->get( 'mshop/customer/manager/typo3/' . $name ) ) { |
513
|
|
|
return 'mshop/customer/manager/typo3/' . $name; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
return parent::getConfigKey( $name, $default ); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* Returns a new manager for customer extensions |
522
|
|
|
* |
523
|
|
|
* @param string $manager Name of the sub manager type in lower case |
524
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
525
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc. |
526
|
|
|
*/ |
527
|
|
|
public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface |
528
|
|
|
{ |
529
|
|
|
return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Typo3' : $name ) ); |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* Returns the name of the used table |
535
|
|
|
* |
536
|
|
|
* @return string Table name |
537
|
|
|
*/ |
538
|
|
|
protected function table() : string |
539
|
|
|
{ |
540
|
|
|
return 'fe_users'; |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Returns the search plugins for transforming the search criteria |
546
|
|
|
* |
547
|
|
|
* @return \Aimeos\MW\Criteria\Plugin\Iface[] List of search plugins |
548
|
|
|
*/ |
549
|
|
|
protected function searchPlugins() : array |
550
|
|
|
{ |
551
|
|
|
return $this->plugins; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* Returns a password helper object based on the configuration. |
557
|
|
|
* |
558
|
|
|
* @return \Aimeos\MShop\Common\Helper\Password\Iface Password helper object |
559
|
|
|
* @throws \Aimeos\MShop\Exception If the name is invalid or the class isn't found |
560
|
|
|
* @deprecated 2025.01 Use \Aimeos\Base\Password\Iface instead |
561
|
|
|
*/ |
562
|
|
|
protected function getPasswordHelper() : \Aimeos\MShop\Common\Helper\Password\Iface |
563
|
|
|
{ |
564
|
|
|
return new \Aimeos\MShop\Common\Helper\Password\Typo3( ['object' => $this->context()->password()] ); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* Transforms the application specific values to Aimeos standard values. |
570
|
|
|
* |
571
|
|
|
* @param array $values Associative list of key/value pairs from the storage |
572
|
|
|
* @return array Associative list of key/value pairs with standard Aimeos values |
573
|
|
|
*/ |
574
|
|
|
protected function transform( array $values ) : array |
575
|
|
|
{ |
576
|
|
|
if( array_key_exists( 'customer.birthday', $values ) ) { |
577
|
|
|
$values['customer.birthday'] = $this->plugins['customer.birthday']->reverse( $values['customer.birthday'] ); |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
if( array_key_exists( 'customer.salutation', $values ) ) { |
581
|
|
|
$values['customer.salutation'] = $this->plugins['customer.salutation']->reverse( $values['customer.salutation'] ); |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
if( array_key_exists( 'customer.status', $values ) ) { |
585
|
|
|
$values['customer.status'] = $this->plugins['customer.status']->reverse( $values['customer.status'] ); |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
if( array_key_exists( 'customer.mtime', $values ) ) { |
589
|
|
|
$values['customer.mtime'] = $this->plugins['customer.mtime']->reverse( $values['customer.mtime'] ); |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
if( array_key_exists( 'customer.ctime', $values ) ) { |
593
|
|
|
$values['customer.ctime'] = $this->plugins['customer.ctime']->reverse( $values['customer.ctime'] ); |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
if( array_key_exists( 'customer.groups', $values ) && $values['customer.groups'] !== '' ) { |
597
|
|
|
$values['customer.groups'] = explode( ',', $values['customer.groups'] ); |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
return $values; |
601
|
|
|
} |
602
|
|
|
} |
603
|
|
|
|