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\Group; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* eZPublish implementation of the customer group class |
16
|
|
|
* |
17
|
|
|
* @package MShop |
18
|
|
|
* @subpackage Customer |
19
|
|
|
*/ |
20
|
|
|
class Ezpublish |
21
|
|
|
extends \Aimeos\MShop\Customer\Manager\Group\Standard |
22
|
|
|
implements \Aimeos\MShop\Customer\Manager\Group\Iface |
23
|
|
|
{ |
24
|
|
|
private $searchConfig = array( |
25
|
|
|
'customer.group.id' => array( |
26
|
|
|
'code' => 'customer.group.id', |
27
|
|
|
'internalcode' => 'ezro."id"', |
28
|
|
|
'label' => 'Customer group ID', |
29
|
|
|
'type' => 'integer', |
30
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
31
|
|
|
), |
32
|
|
|
'customer.group.code' => array( |
33
|
|
|
'code' => 'customer.group.code', |
34
|
|
|
'internalcode' => 'ezro."id"', |
35
|
|
|
'label' => 'Customer group code', |
36
|
|
|
'type' => 'string', |
37
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
38
|
|
|
), |
39
|
|
|
'customer.group.label' => array( |
40
|
|
|
'code' => 'customer.group.label', |
41
|
|
|
'internalcode' => 'ezro."name"', |
42
|
|
|
'label' => 'Customer group label', |
43
|
|
|
'type' => 'string', |
44
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
45
|
|
|
), |
46
|
|
|
'customer.group.ctime'=> array( |
47
|
|
|
'code' => 'customer.group.ctime', |
48
|
|
|
'internalcode' => null, |
49
|
|
|
'label' => 'Customer group creation time', |
50
|
|
|
'type' => 'datetime', |
51
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
52
|
|
|
), |
53
|
|
|
'customer.group.mtime'=> array( |
54
|
|
|
'code' => 'customer.group.mtime', |
55
|
|
|
'internalcode' => null, |
56
|
|
|
'label' => 'Customer group modification time', |
57
|
|
|
'type' => 'datetime', |
58
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
59
|
|
|
), |
60
|
|
|
'customer.group.editor'=> array( |
61
|
|
|
'code' => 'customer.group.editor', |
62
|
|
|
'internalcode' => null, |
63
|
|
|
'label' => 'Customer group editor', |
64
|
|
|
'type' => 'string', |
65
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
66
|
|
|
), |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Removes old entries from the database |
72
|
|
|
* |
73
|
|
|
* @param integer[] $siteids List of IDs for sites whose entries should be deleted |
74
|
|
|
*/ |
75
|
|
|
public function clear( array $siteids ) |
76
|
|
|
{ |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Removes multiple items specified by their IDs |
82
|
|
|
* |
83
|
|
|
* @param array $ids List of IDs |
84
|
|
|
*/ |
85
|
|
|
public function deleteItems( array $ids ) |
86
|
|
|
{ |
87
|
|
|
throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Deleting groups is not supported, please use the eZ Publish backend' ) ); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Returns the attributes that can be used for searching. |
93
|
|
|
* |
94
|
|
|
* @param boolean $withsub Return also attributes of sub-managers if true |
95
|
|
|
* @return array Returns a list of attribtes implementing \Aimeos\MW\Criteria\Attribute\Iface |
96
|
|
|
*/ |
97
|
|
|
public function getSearchAttributes( $withsub = true ) |
98
|
|
|
{ |
99
|
|
|
$path = 'mshop/customer/manager/group/submanagers'; |
100
|
|
|
|
101
|
|
|
return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub ); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Returns a new manager for customer group extensions |
107
|
|
|
* |
108
|
|
|
* @param string $manager Name of the sub manager type in lower case |
109
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
110
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions |
111
|
|
|
*/ |
112
|
|
|
public function getSubManager( $manager, $name = null ) |
113
|
|
|
{ |
114
|
|
|
return $this->getSubManagerBase( 'customer/group', $manager, ( $name === null ? 'Ezpublish' : $name ) ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Inserts a new or updates an existing customer group item |
120
|
|
|
* |
121
|
|
|
* @param \Aimeos\MShop\Customer\Item\Group\Iface $item Customer group item |
122
|
|
|
* @param boolean $fetch True if the new ID should be returned in the item |
123
|
|
|
*/ |
124
|
|
|
public function saveItem( \Aimeos\MShop\Customer\Item\Group\Iface $item, $fetch = true ) |
125
|
|
|
{ |
126
|
|
|
throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Saving groups is not supported, please use the eZ Publish backend' ) ); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Returns the item objects matched by the given search criteria. |
132
|
|
|
* |
133
|
|
|
* @param \Aimeos\MW\Criteria\Iface $search Search criteria object |
134
|
|
|
* @param array $ref List of domain items that should be fetched too |
135
|
|
|
* @param integer &$total Number of items that are available in total |
136
|
|
|
* @return array List of items implementing \Aimeos\MShop\Customer\Item\Group\Iface |
137
|
|
|
* @throws \Aimeos\MShop\Exception If retrieving items failed |
138
|
|
|
*/ |
139
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null ) |
140
|
|
|
{ |
141
|
|
|
$map = []; |
142
|
|
|
$context = $this->getContext(); |
143
|
|
|
|
144
|
|
|
$dbm = $context->getDatabaseManager(); |
145
|
|
|
$dbname = $this->getResourceName(); |
146
|
|
|
$conn = $dbm->acquire( $dbname ); |
147
|
|
|
|
148
|
|
|
try |
149
|
|
|
{ |
150
|
|
|
$required = array( 'customer.group' ); |
151
|
|
|
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
152
|
|
|
$cfgPathSearch = 'mshop/customer/manager/group/ezpublish/search'; |
153
|
|
|
$cfgPathCount = 'mshop/customer/manager/group/ezpublish/count'; |
154
|
|
|
|
155
|
|
|
$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level ); |
156
|
|
|
|
157
|
|
|
while( ( $row = $results->fetch() ) !== false ) { |
158
|
|
|
$map[(string) $row['customer.group.id']] = $this->createItemBase( $row ); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
$dbm->release( $conn, $dbname ); |
162
|
|
|
} |
163
|
|
|
catch( \Exception $e ) |
164
|
|
|
{ |
165
|
|
|
$dbm->release( $conn, $dbname ); |
166
|
|
|
throw $e; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
return $map; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|