|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Base calendar right panel file. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Model |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright YetiForce S.A. |
|
8
|
|
|
* @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com) |
|
9
|
|
|
* @author Adrian Kon <[email protected]> |
|
10
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Base calendar right panel class. |
|
15
|
|
|
*/ |
|
16
|
|
|
class Vtiger_CalendarRightPanel_Model |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Get users. |
|
20
|
|
|
* |
|
21
|
|
|
* @param string $moduleName |
|
22
|
|
|
* |
|
23
|
|
|
* @return array |
|
24
|
|
|
*/ |
|
25
|
|
|
public static function getUsersList(string $moduleName): array |
|
26
|
|
|
{ |
|
27
|
|
|
$currentUser = Users_Record_Model::getCurrentUserModel(); |
|
28
|
|
|
$roleInstance = Settings_Roles_Record_Model::getInstanceById($currentUser->get('roleid')); |
|
29
|
|
|
$clendarallorecords = $roleInstance->get('clendarallorecords'); |
|
30
|
|
|
switch ($clendarallorecords) { |
|
31
|
|
|
case 3: |
|
32
|
|
|
if (App\Config::performance('SEARCH_SHOW_OWNER_ONLY_IN_LIST') && !\App\Config::module($moduleName, 'DISABLED_SHOW_OWNER_ONLY_IN_LIST', false)) { |
|
33
|
|
|
$usersAndGroup = \App\Fields\Owner::getInstance($moduleName, $currentUser)->getUsersAndGroupForModuleList(); |
|
34
|
|
|
$users = $usersAndGroup['users']; |
|
35
|
|
|
} else { |
|
36
|
|
|
$users = \App\Fields\Owner::getInstance(false, $currentUser)->getAccessibleUsers(); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
break; |
|
39
|
|
|
case 1: |
|
40
|
|
|
case 2: |
|
41
|
|
|
default: |
|
42
|
|
|
$users[$currentUser->getId()] = $currentUser->getName(); |
|
|
|
|
|
|
43
|
|
|
break; |
|
44
|
|
|
} |
|
45
|
|
|
if (!empty($users) && $favouriteUsers = $currentUser->getFavouritesUsers()) { |
|
46
|
|
|
uksort($users, |
|
47
|
|
|
function ($a, $b) use ($favouriteUsers) { |
|
48
|
|
|
return (int) (!isset($favouriteUsers[$a]) && isset($favouriteUsers[$b])); |
|
49
|
|
|
}); |
|
50
|
|
|
} |
|
51
|
|
|
return $users; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Get groups. |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $moduleName |
|
58
|
|
|
* |
|
59
|
|
|
* @return array |
|
60
|
|
|
*/ |
|
61
|
|
|
public static function getGroupsList(string $moduleName): array |
|
62
|
|
|
{ |
|
63
|
|
|
$currentUser = Users_Record_Model::getCurrentUserModel(); |
|
64
|
|
|
$roleInstance = Settings_Roles_Record_Model::getInstanceById($currentUser->get('roleid')); |
|
65
|
|
|
$clendarallorecords = $roleInstance->get('clendarallorecords'); |
|
66
|
|
|
switch ($clendarallorecords) { |
|
67
|
|
|
case 1: |
|
68
|
|
|
$groups = []; |
|
69
|
|
|
break; |
|
70
|
|
|
case 2: |
|
71
|
|
|
$groups = \App\Fields\Owner::getInstance(false, $currentUser)->getAccessibleGroups(); |
|
|
|
|
|
|
72
|
|
|
break; |
|
73
|
|
|
case 3: |
|
74
|
|
|
if (App\Config::performance('SEARCH_SHOW_OWNER_ONLY_IN_LIST') && !\App\Config::module($moduleName, 'DISABLED_SHOW_OWNER_ONLY_IN_LIST', false)) { |
|
75
|
|
|
$usersAndGroup = \App\Fields\Owner::getInstance($moduleName, $currentUser)->getUsersAndGroupForModuleList(); |
|
76
|
|
|
$groups = $usersAndGroup['group']; |
|
77
|
|
|
} else { |
|
78
|
|
|
$groups = \App\Fields\Owner::getInstance(false, $currentUser)->getAccessibleGroups(); |
|
79
|
|
|
} |
|
80
|
|
|
break; |
|
81
|
|
|
default: |
|
82
|
|
|
break; |
|
83
|
|
|
} |
|
84
|
|
|
return $groups; |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Get calendar types. |
|
89
|
|
|
* |
|
90
|
|
|
* @param string $moduleName |
|
91
|
|
|
* |
|
92
|
|
|
* @return array |
|
93
|
|
|
*/ |
|
94
|
|
|
public static function getCalendarTypes(string $moduleName): array |
|
95
|
|
|
{ |
|
96
|
|
|
return Vtiger_Calendar_Model::getInstance($moduleName)->getCalendarTypes(); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|