This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
/
Initialize.php
89 lines (82 loc) · 3.48 KB
/
Initialize.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
<?php
/**
* @package DFCom
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Cornelius Weiss <c.weiss@metaways.de>
* @copyright Copyright (c) 2018 Metaways Infosystems GmbH (http://www.metaways.de)
*/
use Tinebase_ModelConfiguration as MC;
/**
* class for DFCom initialization
*
* @package Setup
*/
class DFCom_Setup_Initialize extends Setup_Initialize
{
/**
* init setup authKey
*/
protected function _initializeSetupAuthKey()
{
DFCom_Config::getInstance()->set(DFCom_Config::SETUP_AUTH_KEY, Tinebase_Record_Abstract::generateUID(20));
}
protected function _initializeDefaultContainer()
{
Tinebase_Container::getInstance()->createSystemContainer(
DFCom_Config::APP_NAME,
DFCom_Model_Device::class,
'Devices',
DFCom_Config::DEFAULT_DEVICE_CONTAINER
);
}
protected function _initializeDefaultDeviceLists()
{
DFCom_Config::getInstance()->set(DFCom_Config::DEFAULT_DEVICE_LISTS, [
'DFCom_device_list_employee',
'DFCom_device_list_absenceReasons',
'DFCom_device_list_timeaccounts',
'keyField_DFCom_DeviceListPercentage',
]);
}
protected function _initializeAnonymousRole()
{
try {
$role = Tinebase_Acl_Roles::getInstance()->getRoleByName(DFCom_Config::PUBLIC_ROLE_NAME);
} catch (Tinebase_Exception_NotFound $e) {
$role = Tinebase_Acl_Roles::getInstance()->createRole(new Tinebase_Model_Role([
'name' => DFCom_Config::PUBLIC_ROLE_NAME,
'description' => 'This role will be used by the anonymous user during public api calls',
]));
}
$apps = Tinebase_Application::getInstance()->getApplications();
Tinebase_Acl_Roles::getInstance()->setRoleRights($role->getId(), [
['application_id' => $apps->find('name', 'Addressbook')->getId(), 'right' => Tinebase_Acl_Rights::RUN],
['application_id' => $apps->find('name', 'HumanResources')->getId(), 'right' => Tinebase_Acl_Rights::RUN],
['application_id' => $apps->find('name', Timetracker_Config::APP_NAME)->getId(), 'right' => Tinebase_Acl_Rights::RUN],
]);
}
protected function _initializeSystemCFs()
{
$appId = Tinebase_Application::getInstance()->getApplicationByName(HumanResources_Config::APP_NAME)->getId();
Tinebase_CustomField::getInstance()->addCustomField(new Tinebase_Model_CustomField_Config([
'name' => 'dfcom_id',
'application_id' => $appId,
'model' => HumanResources_Model_Employee::class,
'is_system' => true,
'definition' => [
Tinebase_Model_CustomField_Config::DEF_FIELD => array_merge([
MC::LABEL => 'Transponder Id', //_('Transponder Id')
MC::VALIDATORS => [Zend_Filter_Input::ALLOW_EMPTY => true],
MC::SHY => true,
MC::NULLABLE => true,
], (DFCom_Config::getInstance()->{DFCom_Config::DFCOM_ID_TYPE} === MC::TYPE_BIGINT ? [
MC::TYPE => MC::TYPE_BIGINT,
MC::INPUT_FILTERS => [Zend_Filter_Empty::class => null],
] : [
MC::TYPE => MC::TYPE_STRING,
MC::LENGTH => 255,
])),
]
], true));
}
}