1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
You may not change or alter any portion of this comment or credits |
5
|
|
|
of supporting developers from this source code or any supporting source code |
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Equipment |
15
|
|
|
* |
16
|
|
|
* @category Module |
17
|
|
|
* @package equipment |
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <http://xoops.org> |
19
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
20
|
|
|
* @license GPL 2.0 or later |
21
|
|
|
* @link https://xoops.org/ |
22
|
|
|
* @since 1.0.0 |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use Xmf\Module\Helper\Permission; |
26
|
|
|
|
27
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
28
|
|
|
|
29
|
|
|
$permHelper = new Permission($moduleDirName); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class EquipmentCustomer |
33
|
|
|
*/ |
34
|
|
View Code Duplication |
class EquipmentCustomer extends XoopsObject |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* Constructor |
38
|
|
|
* |
39
|
|
|
* @param null |
40
|
|
|
*/ |
41
|
|
|
public function __construct() |
42
|
|
|
{ |
43
|
|
|
parent::__construct(); |
44
|
|
|
$this->initVar('id', XOBJ_DTYPE_INT); |
45
|
|
|
$this->initVar('first', XOBJ_DTYPE_TXTBOX); |
46
|
|
|
$this->initVar('last', XOBJ_DTYPE_TXTBOX); |
47
|
|
|
$this->initVar('address', XOBJ_DTYPE_TXTBOX); |
48
|
|
|
$this->initVar('city', XOBJ_DTYPE_TXTBOX); |
49
|
|
|
$this->initVar('country', XOBJ_DTYPE_TXTBOX); |
50
|
|
|
$this->initVar('created', XOBJ_DTYPE_TIMESTAMP); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get form |
55
|
|
|
* |
56
|
|
|
* @param null |
57
|
|
|
* @return EquipmentCustomerForm |
58
|
|
|
*/ |
59
|
|
|
public function getForm() |
60
|
|
|
{ |
61
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/equipment/class/form/customer.php'; |
62
|
|
|
|
63
|
|
|
$form = new EquipmentCustomerForm($this); |
64
|
|
|
return $form; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return array|null |
69
|
|
|
*/ |
70
|
|
|
public function getGroupsRead() |
71
|
|
|
{ |
72
|
|
|
global $permHelper; |
73
|
|
|
//return $this->publisher->getHandler('permission')->getGrantedGroupsById('customer_read', id); |
|
|
|
|
74
|
|
|
return $permHelper->getGroupsForItem('sbcolumns_read', $this->getVar('id')); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return array|null |
79
|
|
|
*/ |
80
|
|
|
public function getGroupsSubmit() |
81
|
|
|
{ |
82
|
|
|
global $permHelper; |
83
|
|
|
// return $this->publisher->getHandler('permission')->getGrantedGroupsById('customer_submit', id); |
|
|
|
|
84
|
|
|
return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id')); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return array|null |
89
|
|
|
*/ |
90
|
|
|
public function getGroupsModeration() |
91
|
|
|
{ |
92
|
|
|
global $permHelper; |
93
|
|
|
// return $this->publisher->getHandler('permission')->getGrantedGroupsById('customer_moderation', id); |
|
|
|
|
94
|
|
|
return $permHelper->getGroupsForItem('sbcolumns_moderation', $this->getVar('id')); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Class EquipmentCustomerHandler |
100
|
|
|
*/ |
101
|
|
|
class EquipmentCustomerHandler extends XoopsPersistableObjectHandler |
102
|
|
|
{ |
103
|
|
|
/** |
104
|
|
|
* Constructor |
105
|
|
|
* @param null|XoopsDatabase $db |
106
|
|
|
*/ |
107
|
|
|
|
108
|
|
|
public function __construct(XoopsDatabase $db) |
109
|
|
|
{ |
110
|
|
|
parent::__construct($db, 'equipment_customer', 'EquipmentCustomer', 'id', 'last'); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.