-
Notifications
You must be signed in to change notification settings - Fork 55
/
paymentexample.php
821 lines (699 loc) · 25.6 KB
/
paymentexample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
if (!defined('_PS_VERSION_')) {
exit;
}
class PaymentExample extends PaymentModule
{
const CONFIG_OS_OFFLINE = 'PAYMENTEXAMPLE_OS_OFFLINE';
const CONFIG_PO_OFFLINE_ENABLED = 'PAYMENTEXAMPLE_PO_OFFLINE_ENABLED';
const CONFIG_PO_EXTERNAL_ENABLED = 'PAYMENTEXAMPLE_PO_EXTERNAL_ENABLED';
const CONFIG_PO_EMBEDDED_ENABLED = 'PAYMENTEXAMPLE_PO_EMBEDDED_ENABLED';
const CONFIG_PO_BINARY_ENABLED = 'PAYMENTEXAMPLE_PO_BINARY_ENABLED';
const MODULE_ADMIN_CONTROLLER = 'AdminConfigurePaymentExample';
const HOOKS = [
'actionPaymentCCAdd',
'actionObjectShopAddAfter',
'paymentOptions',
'displayAdminOrderLeft',
'displayAdminOrderMainBottom',
'displayCustomerAccount',
'displayOrderConfirmation',
'displayOrderDetail',
'displayPaymentByBinaries',
'displayPaymentReturn',
'displayPDFInvoice',
];
public function __construct()
{
$this->name = 'paymentexample';
$this->tab = 'payments_gateways';
$this->version = '2.0.0';
$this->author = 'PrestaShop';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$this->ps_versions_compliancy = [
'min' => '1.7',
'max' => _PS_VERSION_,
];
$this->controllers = [
'account',
'cancel',
'external',
'validation',
];
parent::__construct();
$this->displayName = $this->l('Payment Example');
$this->description = $this->l('Description of Payment Example');
}
/**
* @return bool
*/
public function install()
{
return (bool) parent::install()
&& (bool) $this->registerHook(static::HOOKS)
&& $this->installOrderState()
&& $this->installConfiguration()
&& $this->installTabs();
}
/**
* @return bool
*/
public function uninstall()
{
return (bool) parent::uninstall()
&& $this->deleteOrderState()
&& $this->uninstallConfiguration()
&& $this->uninstallTabs();
}
/**
* Module configuration page
*/
public function getContent()
{
// Redirect to our ModuleAdminController when click on Configure button
Tools::redirectAdmin($this->context->link->getAdminLink(static::MODULE_ADMIN_CONTROLLER));
}
/**
* This hook is used to save additional information will be displayed on BO Order View, Payment block with "Details" button
*
* @param array $params
*/
public function hookActionPaymentCCAdd(array $params)
{
if (empty($params['paymentCC'])) {
return;
}
/** @var OrderPayment $orderPayment */
$orderPayment = $params['paymentCC'];
if (false === Validate::isLoadedObject($orderPayment) || empty($orderPayment->order_reference)) {
return;
}
/** @var Order[] $orderCollection */
$orderCollection = Order::getByReference($orderPayment->order_reference);
foreach ($orderCollection as $order) {
if ($this->name !== $order->module) {
return;
}
}
if ('embedded' !== Tools::getValue('option') || !Configuration::get(static::CONFIG_PO_EMBEDDED_ENABLED)) {
return;
}
$cardNumber = Tools::getValue('cardNumber');
$cardBrand = Tools::getValue('cardBrand');
$cardHolder = Tools::getValue('cardHolder');
$cardExpiration = Tools::getValue('cardExpiration');
if (false === empty($cardNumber) && Validate::isGenericName($cardNumber)) {
$orderPayment->card_number = $cardNumber;
}
if (false === empty($cardBrand) && Validate::isGenericName($cardBrand)) {
$orderPayment->card_brand = $cardBrand;
}
if (false === empty($cardHolder) && Validate::isGenericName($cardHolder)) {
$orderPayment->card_holder = $cardHolder;
}
if (false === empty($cardExpiration) && Validate::isGenericName($cardExpiration)) {
$orderPayment->card_expiration = $cardExpiration;
}
$orderPayment->save();
}
/**
* This hook called after a new Shop is created
*
* @param array $params
*/
public function hookActionObjectShopAddAfter(array $params)
{
if (empty($params['object'])) {
return;
}
/** @var Shop $shop */
$shop = $params['object'];
if (false === Validate::isLoadedObject($shop)) {
return;
}
$this->addCheckboxCarrierRestrictionsForModule([(int) $shop->id]);
$this->addCheckboxCountryRestrictionsForModule([(int) $shop->id]);
if ($this->currencies_mode === 'checkbox') {
$this->addCheckboxCurrencyRestrictionsForModule([(int) $shop->id]);
} elseif ($this->currencies_mode === 'radio') {
$this->addRadioCurrencyRestrictionsForModule([(int) $shop->id]);
}
}
/**
* @param array $params
*
* @return array Should always return an array
*/
public function hookPaymentOptions(array $params)
{
/** @var Cart $cart */
$cart = $params['cart'];
if (false === Validate::isLoadedObject($cart) || false === $this->checkCurrency($cart)) {
return [];
}
$paymentOptions = [];
if (Configuration::get(static::CONFIG_PO_OFFLINE_ENABLED)) {
$paymentOptions[] = $this->getOfflinePaymentOption();
}
if (Configuration::get(static::CONFIG_PO_EXTERNAL_ENABLED)) {
$paymentOptions[] = $this->getExternalPaymentOption();
}
if (Configuration::get(static::CONFIG_PO_EMBEDDED_ENABLED)) {
$paymentOptions[] = $this->getEmbeddedPaymentOption();
}
if (Configuration::get(static::CONFIG_PO_BINARY_ENABLED)) {
$paymentOptions[] = $this->getBinaryPaymentOption();
}
return $paymentOptions;
}
/**
* This hook is used to display additional information on BO Order View, under Payment block
*
* @since PrestaShop 1.7.7 This hook is replaced by displayAdminOrderMainBottom on migrated BO Order View
*
* @param array $params
*
* @return string
*/
public function hookDisplayAdminOrderLeft(array $params)
{
if (empty($params['id_order'])) {
return '';
}
$order = new Order((int) $params['id_order']);
if (false === Validate::isLoadedObject($order) || $order->module !== $this->name) {
return '';
}
$this->context->smarty->assign([
'moduleName' => $this->name,
'moduleDisplayName' => $this->displayName,
'moduleLogoSrc' => $this->getPathUri() . 'logo.png',
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayAdminOrderLeft.tpl');
}
/**
* This hook is used to display additional information on BO Order View, under Payment block
*
* @since PrestaShop 1.7.7 This hook replace displayAdminOrderLeft on migrated BO Order View
*
* @param array $params
*
* @return string
*/
public function hookDisplayAdminOrderMainBottom(array $params)
{
if (empty($params['id_order'])) {
return '';
}
$order = new Order((int) $params['id_order']);
if (false === Validate::isLoadedObject($order) || $order->module !== $this->name) {
return '';
}
$this->context->smarty->assign([
'moduleName' => $this->name,
'moduleDisplayName' => $this->displayName,
'moduleLogoSrc' => $this->getPathUri() . 'logo.png',
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayAdminOrderMainBottom.tpl');
}
/**
* This hook is used to display information in customer account
*
* @param array $params
*
* @return string
*/
public function hookDisplayCustomerAccount(array $params)
{
$this->context->smarty->assign([
'moduleDisplayName' => $this->displayName,
'moduleLogoSrc' => $this->getPathUri() . 'logo.png',
'transactionsLink' => $this->context->link->getModuleLink(
$this->name,
'account'
),
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayCustomerAccount.tpl');
}
/**
* This hook is used to display additional information on order confirmation page
*
* @param array $params
*
* @return string
*/
public function hookDisplayOrderConfirmation(array $params)
{
if (empty($params['order'])) {
return '';
}
/** @var Order $order */
$order = $params['order'];
if (false === Validate::isLoadedObject($order) || $order->module !== $this->name) {
return '';
}
$transaction = '';
if ($order->getOrderPaymentCollection()->count()) {
/** @var OrderPayment $orderPayment */
$orderPayment = $order->getOrderPaymentCollection()->getFirst();
$transaction = $orderPayment->transaction_id;
}
$this->context->smarty->assign([
'moduleName' => $this->name,
'transaction' => $transaction,
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayOrderConfirmation.tpl');
}
/**
* This hook is used to display additional information on FO (Guest Tracking and Account Orders)
*
* @param array $params
*
* @return string
*/
public function hookDisplayOrderDetail(array $params)
{
if (empty($params['order'])) {
return '';
}
/** @var Order $order */
$order = $params['order'];
if (false === Validate::isLoadedObject($order) || $order->module !== $this->name) {
return '';
}
$transaction = '';
if ($order->getOrderPaymentCollection()->count()) {
/** @var OrderPayment $orderPayment */
$orderPayment = $order->getOrderPaymentCollection()->getFirst();
$transaction = $orderPayment->transaction_id;
}
$this->context->smarty->assign([
'moduleName' => $this->name,
'transaction' => $transaction,
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayOrderDetail.tpl');
}
/**
* This hook displays form generated by binaries during the checkout
*
* @param array $params
*
* @return string
*/
public function hookDisplayPaymentByBinaries(array $params)
{
/** @var Cart $cart */
$cart = $params['cart'];
if (false === Validate::isLoadedObject($cart) || false === $this->checkCurrency($cart)) {
return '';
}
$this->context->smarty->assign([
'action' => $this->context->link->getModuleLink($this->name, 'validation', ['option' => 'binary'], true),
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayPaymentByBinaries.tpl');
}
/**
* This hook is used to display additional information on bottom of order confirmation page
*
* @param array $params
*
* @return string
*/
public function hookDisplayPaymentReturn(array $params)
{
if (empty($params['order'])) {
return '';
}
/** @var Order $order */
$order = $params['order'];
if (false === Validate::isLoadedObject($order) || $order->module !== $this->name) {
return '';
}
$transaction = '';
if ($order->getOrderPaymentCollection()->count()) {
/** @var OrderPayment $orderPayment */
$orderPayment = $order->getOrderPaymentCollection()->getFirst();
$transaction = $orderPayment->transaction_id;
}
$this->context->smarty->assign([
'moduleName' => $this->name,
'transaction' => $transaction,
'transactionsLink' => $this->context->link->getModuleLink(
$this->name,
'account'
),
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayPaymentReturn.tpl');
}
/**
* This hook is used to display additional information on Invoice PDF
*
* @param array $params
*
* @return string
*/
public function hookDisplayPDFInvoice(array $params)
{
if (empty($params['object'])) {
return '';
}
/** @var OrderInvoice $orderInvoice */
$orderInvoice = $params['object'];
if (false === Validate::isLoadedObject($orderInvoice)) {
return '';
}
$order = $orderInvoice->getOrder();
if (false === Validate::isLoadedObject($order) || $order->module !== $this->name) {
return '';
}
$transaction = '';
if ($order->getOrderPaymentCollection()->count()) {
/** @var OrderPayment $orderPayment */
$orderPayment = $order->getOrderPaymentCollection()->getFirst();
$transaction = $orderPayment->transaction_id;
}
$this->context->smarty->assign([
'moduleName' => $this->name,
'transaction' => $transaction,
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/hook/displayPDFInvoice.tpl');
}
/**
* Check if currency is allowed in Payment Preferences
*
* @param Cart $cart
*
* @return bool
*/
private function checkCurrency(Cart $cart)
{
$currency_order = new Currency($cart->id_currency);
/** @var array $currencies_module */
$currencies_module = $this->getCurrency($cart->id_currency);
if (empty($currencies_module)) {
return false;
}
foreach ($currencies_module as $currency_module) {
if ($currency_order->id == $currency_module['id_currency']) {
return true;
}
}
return false;
}
/**
* Factory of PaymentOption for Offline Payment
*
* @return PaymentOption
*/
private function getOfflinePaymentOption()
{
$offlineOption = new PaymentOption();
$offlineOption->setModuleName($this->name);
$offlineOption->setCallToActionText($this->l('Pay offline'));
$offlineOption->setAction($this->context->link->getModuleLink($this->name, 'validation', ['option' => 'offline'], true));
$offlineOption->setAdditionalInformation($this->context->smarty->fetch('module:paymentexample/views/templates/front/paymentOptionOffline.tpl'));
$offlineOption->setLogo(Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/option/offline.png'));
return $offlineOption;
}
/**
* Factory of PaymentOption for External Payment
*
* @return PaymentOption
*/
private function getExternalPaymentOption()
{
$externalOption = new PaymentOption();
$externalOption->setModuleName($this->name);
$externalOption->setCallToActionText($this->l('Pay external'));
$externalOption->setAction($this->context->link->getModuleLink($this->name, 'external', [], true));
$externalOption->setInputs([
'token' => [
'name' => 'token',
'type' => 'hidden',
'value' => '[5cbfniD+(gEV<59lYbG/,3VmHiE<U46;#G9*#NP#X.FA§]sb%ZG?5Q{xQ4#VM|7',
],
]);
$externalOption->setAdditionalInformation($this->context->smarty->fetch('module:paymentexample/views/templates/front/paymentOptionExternal.tpl'));
$externalOption->setLogo(Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/option/external.png'));
return $externalOption;
}
/**
* Factory of PaymentOption for Embedded Payment
*
* @return PaymentOption
*/
private function getEmbeddedPaymentOption()
{
$embeddedOption = new PaymentOption();
$embeddedOption->setModuleName($this->name);
$embeddedOption->setCallToActionText($this->l('Pay embedded'));
$embeddedOption->setForm($this->generateEmbeddedForm());
$embeddedOption->setAdditionalInformation($this->context->smarty->fetch('module:paymentexample/views/templates/front/paymentOptionEmbedded.tpl'));
$embeddedOption->setLogo(Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/option/embedded.png'));
return $embeddedOption;
}
/**
* Factory of PaymentOption for binary Payment
*
* @return PaymentOption
*/
private function getBinaryPaymentOption()
{
$binaryOption = new PaymentOption();
$binaryOption->setModuleName($this->name);
$binaryOption->setCallToActionText($this->l('Pay binary'));
$binaryOption->setAdditionalInformation($this->context->smarty->fetch('module:paymentexample/views/templates/front/paymentOptionBinary.tpl'));
$binaryOption->setLogo(Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/option/binary.png'));
$binaryOption->setBinary(true);
return $binaryOption;
}
/**
* Generate a form for Embedded Payment
*
* @return string
*/
private function generateEmbeddedForm()
{
$this->context->smarty->assign([
'action' => $this->context->link->getModuleLink($this->name, 'validation', ['option' => 'embedded'], true),
]);
return $this->context->smarty->fetch('module:paymentexample/views/templates/front/paymentOptionEmbeddedForm.tpl');
}
/**
* @return bool
*/
private function installOrderState()
{
return $this->createOrderState(
static::CONFIG_OS_OFFLINE,
[
'en' => 'Awaiting offline payment',
],
'#00ffff',
false,
false,
false,
false,
false,
false,
false,
true,
'awaiting-offline-payment'
);
}
/**
* Create custom OrderState used for payment
*
* @param string $configurationKey Configuration key used to store OrderState identifier
* @param array $nameByLangIsoCode An array of name for all languages, default is en
* @param string $color Color of the label
* @param bool $isLogable consider the associated order as validated
* @param bool $isPaid set the order as paid
* @param bool $isInvoice allow a customer to download and view PDF versions of his/her invoices
* @param bool $isShipped set the order as shipped
* @param bool $isDelivery show delivery PDF
* @param bool $isPdfDelivery attach delivery slip PDF to email
* @param bool $isPdfInvoice attach invoice PDF to email
* @param bool $isSendEmail send an email to the customer when his/her order status has changed
* @param string $template Only letters, numbers and underscores are allowed. Email template for both .html and .txt
* @param bool $isHidden hide this status in all customer orders
* @param bool $isUnremovable Disallow delete action for this OrderState
* @param bool $isDeleted Set OrderState deleted
*
* @return bool
*/
private function createOrderState(
$configurationKey,
array $nameByLangIsoCode,
$color,
$isLogable = false,
$isPaid = false,
$isInvoice = false,
$isShipped = false,
$isDelivery = false,
$isPdfDelivery = false,
$isPdfInvoice = false,
$isSendEmail = false,
$template = '',
$isHidden = false,
$isUnremovable = true,
$isDeleted = false
) {
$tabNameByLangId = [];
foreach ($nameByLangIsoCode as $langIsoCode => $name) {
foreach (Language::getLanguages(false) as $language) {
if (Tools::strtolower($language['iso_code']) === $langIsoCode) {
$tabNameByLangId[(int) $language['id_lang']] = $name;
} elseif (isset($nameByLangIsoCode['en'])) {
$tabNameByLangId[(int) $language['id_lang']] = $nameByLangIsoCode['en'];
}
}
}
$orderState = new OrderState();
$orderState->module_name = $this->name;
$orderState->name = $tabNameByLangId;
$orderState->color = $color;
$orderState->logable = $isLogable;
$orderState->paid = $isPaid;
$orderState->invoice = $isInvoice;
$orderState->shipped = $isShipped;
$orderState->delivery = $isDelivery;
$orderState->pdf_delivery = $isPdfDelivery;
$orderState->pdf_invoice = $isPdfInvoice;
$orderState->send_email = $isSendEmail;
$orderState->hidden = $isHidden;
$orderState->unremovable = $isUnremovable;
$orderState->template = $template;
$orderState->deleted = $isDeleted;
$result = (bool) $orderState->add();
if (false === $result) {
$this->_errors[] = sprintf(
'Failed to create OrderState %s',
$configurationKey
);
return false;
}
$result = (bool) Configuration::updateGlobalValue($configurationKey, (int) $orderState->id);
if (false === $result) {
$this->_errors[] = sprintf(
'Failed to save OrderState %s to Configuration',
$configurationKey
);
return false;
}
$orderStateImgPath = $this->getLocalPath() . 'views/img/orderstate/' . $configurationKey . '.png';
if (false === (bool) Tools::file_exists_cache($orderStateImgPath)) {
$this->_errors[] = sprintf(
'Failed to find icon file of OrderState %s',
$configurationKey
);
return false;
}
if (false === (bool) Tools::copy($orderStateImgPath, _PS_ORDER_STATE_IMG_DIR_ . $orderState->id . '.gif')) {
$this->_errors[] = sprintf(
'Failed to copy icon of OrderState %s',
$configurationKey
);
return false;
}
return true;
}
/**
* Delete custom OrderState used for payment
* We mark them as deleted to not break passed Orders
*
* @return bool
*/
private function deleteOrderState()
{
$result = true;
$orderStateCollection = new PrestaShopCollection('OrderState');
$orderStateCollection->where('module_name', '=', $this->name);
/** @var OrderState[] $orderStates */
$orderStates = $orderStateCollection->getAll();
foreach ($orderStates as $orderState) {
$orderState->deleted = true;
$result = $result && (bool) $orderState->save();
}
return $result;
}
/**
* Install default module configuration
*
* @return bool
*/
private function installConfiguration()
{
return (bool) Configuration::updateGlobalValue(static::CONFIG_PO_OFFLINE_ENABLED, '1')
&& (bool) Configuration::updateGlobalValue(static::CONFIG_PO_EXTERNAL_ENABLED, '1')
&& (bool) Configuration::updateGlobalValue(static::CONFIG_PO_EMBEDDED_ENABLED, '1')
&& (bool) Configuration::updateGlobalValue(static::CONFIG_PO_BINARY_ENABLED, '1');
}
/**
* Uninstall module configuration
*
* @return bool
*/
private function uninstallConfiguration()
{
return (bool) Configuration::deleteByName(static::CONFIG_PO_OFFLINE_ENABLED)
&& (bool) Configuration::deleteByName(static::CONFIG_PO_EXTERNAL_ENABLED)
&& (bool) Configuration::deleteByName(static::CONFIG_PO_EMBEDDED_ENABLED)
&& (bool) Configuration::deleteByName(static::CONFIG_PO_BINARY_ENABLED);
}
/**
* Install Tabs
*
* @return bool
*/
public function installTabs()
{
if (Tab::getIdFromClassName(static::MODULE_ADMIN_CONTROLLER)) {
return true;
}
$tab = new Tab();
$tab->class_name = static::MODULE_ADMIN_CONTROLLER;
$tab->module = $this->name;
$tab->active = true;
$tab->id_parent = -1;
$tab->name = array_fill_keys(
Language::getIDs(false),
$this->displayName
);
return (bool) $tab->add();
}
/**
* Uninstall Tabs
*
* @return bool
*/
public function uninstallTabs()
{
$id_tab = (int) Tab::getIdFromClassName(static::MODULE_ADMIN_CONTROLLER);
if ($id_tab) {
$tab = new Tab($id_tab);
return (bool) $tab->delete();
}
return true;
}
}