1<?php
2/**
3 * 2007-2016 PrestaShop
4 *
5 * thirty bees is an extension to the PrestaShop e-commerce software developed by PrestaShop SA
6 * Copyright (C) 2017-2018 thirty bees
7 *
8 * NOTICE OF LICENSE
9 *
10 * This source file is subject to the Open Software License (OSL 3.0)
11 * that is bundled with this package in the file LICENSE.txt.
12 * It is also available through the world-wide-web at this URL:
13 * http://opensource.org/licenses/osl-3.0.php
14 * If you did not receive a copy of the license and are unable to
15 * obtain it through the world-wide-web, please send an email
16 * to license@thirtybees.com so we can send you a copy immediately.
17 *
18 * DISCLAIMER
19 *
20 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
21 * versions in the future. If you wish to customize PrestaShop for your
22 * needs please refer to https://www.thirtybees.com for more information.
23 *
24 *  @author    thirty bees <contact@thirtybees.com>
25 *  @author    PrestaShop SA <contact@prestashop.com>
26 *  @copyright 2017-2018 thirty bees
27 *  @copyright 2007-2016 PrestaShop SA
28 *  @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
29 *  PrestaShop is an internationally registered trademark & property of PrestaShop SA
30 */
31
32/**
33 * Class ConfigurationKPICore
34 *
35 * @since 1.0.0
36 */
37class ConfigurationKPICore extends Configuration
38{
39    // @codingStandardsIgnoreStart
40    public static $definition_backup;
41    // @codingStandardsIgnoreEnd
42
43    /**
44     * @since   1.0.0
45     * @version 1.0.0 Initial version
46     */
47    public static function setKpiDefinition()
48    {
49        // @codingStandardsIgnoreStart
50        ConfigurationKPI::$definition_backup = Configuration::$definition;
51        // @codingStandardsIgnoreEnd
52        Configuration::$definition['table'] = 'configuration_kpi';
53        Configuration::$definition['primary'] = 'id_configuration_kpi';
54    }
55
56    /**
57     * @since   1.0.0
58     * @version 1.0.0 Initial version
59     */
60    public static function unsetKpiDefinition()
61    {
62        // @codingStandardsIgnoreStart
63        Configuration::$definition = ConfigurationKPI::$definition_backup;
64        // @codingStandardsIgnoreEnd
65    }
66
67    /**
68     * @param string   $key
69     * @param int|null $idShopGroup
70     * @param int|null $idShop
71     *
72     * @return int
73     *
74     * @since   1.0.0
75     * @version 1.0.0 Initial version
76     * @throws PrestaShopException
77     */
78    public static function getIdByName($key, $idShopGroup = null, $idShop = null)
79    {
80        ConfigurationKPI::setKpiDefinition();
81        $r = parent::getIdByName($key, $idShopGroup, $idShop);
82        ConfigurationKPI::unsetKpiDefinition();
83
84        return $r;
85    }
86
87    /**
88     * @since   1.0.0
89     * @version 1.0.0 Initial version
90     */
91    public static function loadConfiguration()
92    {
93        ConfigurationKPI::setKpiDefinition();
94        parent::loadConfiguration();
95        ConfigurationKPI::unsetKpiDefinition();
96    }
97
98    /**
99     * @param string   $key
100     * @param int|null $idLang
101     * @param int|null $idShopGroup
102     * @param int|null $idShop
103     *
104     * @return string
105     *
106     * @since   1.0.0
107     * @version 1.0.0 Initial version
108     * @throws PrestaShopException
109     */
110    public static function get($key, $idLang = null, $idShopGroup = null, $idShop = null)
111    {
112        ConfigurationKPI::setKpiDefinition();
113        $r = parent::get($key, $idLang, $idShopGroup, $idShop);
114        ConfigurationKPI::unsetKpiDefinition();
115
116        return $r;
117    }
118
119    /**
120     * @param string   $key
121     * @param int|null $idLang
122     *
123     * @return string
124     *
125     * @since   1.0.0
126     * @version 1.0.0 Initial version
127     * @throws PrestaShopException
128     */
129    public static function getGlobalValue($key, $idLang = null)
130    {
131        ConfigurationKPI::setKpiDefinition();
132        $r = parent::getGlobalValue($key, $idLang);
133        ConfigurationKPI::unsetKpiDefinition();
134
135        return $r;
136    }
137
138    /**
139     * @param string   $key
140     * @param int|null $idShopGroup
141     * @param int|null $idShop
142     *
143     * @return array
144     * @since   1.0.0
145     *
146     * @version 1.0.0 Initial version
147     * @throws PrestaShopException
148     */
149    public static function getInt($key, $idShopGroup = null, $idShop = null)
150    {
151        ConfigurationKPI::setKpiDefinition();
152        $r = parent::getInt($key, $idShopGroup, $idShop);
153        ConfigurationKPI::unsetKpiDefinition();
154
155        return $r;
156    }
157
158    /**
159     * @param array $keys
160     * @param null  $idLang
161     * @param null  $idShopGroup
162     * @param null  $idShop
163     *
164     * @return array
165     *
166     * @since   1.0.0
167     * @version 1.0.0 Initial version
168     * @throws PrestaShopException
169     */
170    public static function getMultiple($keys, $idLang = null, $idShopGroup = null, $idShop = null)
171    {
172        ConfigurationKPI::setKpiDefinition();
173        $r = parent::getMultiple($keys, $idLang, $idShopGroup, $idShop);
174        ConfigurationKPI::unsetKpiDefinition();
175
176        return $r;
177    }
178
179    /**
180     * @param string $key
181     * @param null   $idLang
182     * @param null   $idShopGroup
183     * @param null   $idShop
184     *
185     * @return bool
186     *
187     * @since   1.0.0
188     * @version 1.0.0 Initial version
189     */
190    public static function hasKey($key, $idLang = null, $idShopGroup = null, $idShop = null)
191    {
192        ConfigurationKPI::setKpiDefinition();
193        $r = parent::hasKey($key, $idLang, $idShopGroup, $idShop);
194        ConfigurationKPI::unsetKpiDefinition();
195
196        return $r;
197    }
198
199    /**
200     * @param string $key
201     * @param mixed  $values
202     * @param null   $idShopGroup
203     * @param null   $idShop
204     *
205     * @since   1.0.0
206     * @version 1.0.0 Initial version
207     */
208    public static function set($key, $values, $idShopGroup = null, $idShop = null)
209    {
210        ConfigurationKPI::setKpiDefinition();
211        parent::set($key, $values, $idShopGroup, $idShop);
212        ConfigurationKPI::unsetKpiDefinition();
213    }
214
215    /**
216     * @param string $key
217     * @param mixed  $values
218     * @param bool   $html
219     *
220     * @return bool
221     *
222     * @since   1.0.0
223     * @version 1.0.0 Initial version
224     * @throws PrestaShopException
225     */
226    public static function updateGlobalValue($key, $values, $html = false)
227    {
228        ConfigurationKPI::setKpiDefinition();
229        $r = parent::updateGlobalValue($key, $values, $html);
230        ConfigurationKPI::unsetKpiDefinition();
231
232        return $r;
233    }
234
235    /**
236     * @param string   $key
237     * @param mixed    $values
238     * @param bool     $html
239     * @param int|null $idShopGroup
240     * @param int|null $idShop
241     *
242     * @return bool
243     *
244     * @since   1.0.0
245     * @version 1.0.0 Initial version
246     * @throws PrestaShopException
247     */
248    public static function updateValue($key, $values, $html = false, $idShopGroup = null, $idShop = null)
249    {
250        ConfigurationKPI::setKpiDefinition();
251        $r = parent::updateValue($key, $values, $html, $idShopGroup, $idShop);
252        ConfigurationKPI::unsetKpiDefinition();
253
254        return $r;
255    }
256
257    /**
258     * @param string $key
259     *
260     * @return bool
261     *
262     * @throws PrestaShopDatabaseException
263     * @throws PrestaShopException
264     * @since   1.0.0
265     * @version 1.0.0 Initial version
266     */
267    public static function deleteByName($key)
268    {
269        ConfigurationKPI::setKpiDefinition();
270        $r = parent::deleteByName($key);
271        ConfigurationKPI::unsetKpiDefinition();
272
273        return $r;
274    }
275
276    /**
277     * @param string $key
278     *
279     * @throws PrestaShopDatabaseException
280     * @throws PrestaShopException
281     * @since   1.0.0
282     * @version 1.0.0 Initial version
283     */
284    public static function deleteFromContext($key)
285    {
286        ConfigurationKPI::setKpiDefinition();
287        parent::deleteFromContext($key);
288        ConfigurationKPI::unsetKpiDefinition();
289    }
290
291    /**
292     * @param string $key
293     * @param int    $idLang
294     * @param int    $context
295     *
296     * @return bool
297     *
298     * @since   1.0.0
299     * @version 1.0.0 Initial version
300     */
301    public static function hasContext($key, $idLang, $context)
302    {
303        ConfigurationKPI::setKpiDefinition();
304        $r = parent::hasContext($key, $idLang, $context);
305        ConfigurationKPI::unsetKpiDefinition();
306
307        return $r;
308    }
309
310    /**
311     * @param string $key
312     *
313     * @return bool
314     *
315     * @since   1.0.0
316     * @version 1.0.0 Initial version
317     * @throws PrestaShopException
318     */
319    public static function isOverridenByCurrentContext($key)
320    {
321        ConfigurationKPI::setKpiDefinition();
322        $r = parent::isOverridenByCurrentContext($key);
323        ConfigurationKPI::unsetKpiDefinition();
324
325        return $r;
326    }
327
328    /**
329     * @param string $key
330     *
331     * @return bool
332     *
333     * @since   1.0.0
334     * @version 1.0.0 Initial version
335     */
336    public static function isLangKey($key)
337    {
338        ConfigurationKPI::setKpiDefinition();
339        $r = parent::isLangKey($key);
340        ConfigurationKPI::unsetKpiDefinition();
341
342        return $r;
343    }
344
345    /**
346     * @param int $idShopGroup
347     * @param int $idShop
348     *
349     * @return string
350     *
351     * @since   1.0.0
352     * @version 1.0.0 Initial version
353     */
354    protected static function sqlRestriction($idShopGroup, $idShop)
355    {
356        ConfigurationKPI::setKpiDefinition();
357        $r = parent::sqlRestriction($idShopGroup, $idShop);
358        ConfigurationKPI::unsetKpiDefinition();
359
360        return $r;
361    }
362}
363