ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailMemberSearchDataProvider Class Reference

Class ilMailMemberSearchDataProvider. More...

+ Collaboration diagram for ilMailMemberSearchDataProvider:

Public Member Functions

 __construct ($objParticipants, $a_ref_id)
 
 getData ()
 

Protected Attributes

 $access
 
 $ref_id
 
 $type = 'crs'
 
 $data = []
 
 $objParticipants = null
 
 $dataCache
 
 $roleSortWeightMap
 
 $lng
 

Private Member Functions

 collectTableData ()
 
 sortRoles (array $roleTitles)
 
 buildRoleTitle (string $role)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailMemberSearchDataProvider::__construct (   $objParticipants,
  $a_ref_id 
)
Parameters
ilParticipants$objParticipants
int$a_ref_id

Definition at line 46 of file class.ilMailMemberSearchDataProvider.php.

47 {
48 global $DIC;
49
50 $this->dataCache = $DIC['ilObjDataCache'];
51 $this->access = $DIC->access();
52 $this->objParticipants = $objParticipants;
53 $this->type = $this->objParticipants->getType();
54 $this->lng = $DIC['lng'];
55
56 $this->ref_id = $a_ref_id;
57
58 $this->collectTableData();
59 }
global $DIC
Definition: saml.php:7

References $DIC, $objParticipants, and collectTableData().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildRoleTitle()

ilMailMemberSearchDataProvider::buildRoleTitle ( string  $role)
private

Definition at line 143 of file class.ilMailMemberSearchDataProvider.php.

143 : string
144 {
145 return ilObjRole::_getTranslation($role);
146 }
static _getTranslation($a_role_title)

References ilObjRole\_getTranslation().

Referenced by collectTableData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ collectTableData()

ilMailMemberSearchDataProvider::collectTableData ( )
private

Definition at line 61 of file class.ilMailMemberSearchDataProvider.php.

62 {
63 $participants = $this->objParticipants->getParticipants();
64 if ($this->type === 'crs' || $this->type === 'grp') {
65 $participants = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
66 'read',
67 'manage_members',
68 $this->ref_id,
69 $participants
70 );
71 }
72
73 $preloadedRoleIds = [];
74 foreach ($participants as $user_id) {
76 if (!$user || !($user instanceof ilObjUser)) {
77 continue;
78 }
79
80 if (!$user->getActive()) {
81 continue;
82 }
83
84 $login = $user->getLogin();
85
86 $publicName = '';
87 if (in_array($user->getPref('public_profile'), ['g', 'y'])) {
88 $publicName = $user->getLastname() . ', ' . $user->getFirstname();
89 }
90
91 $this->data[$user_id]['user_id'] = $user_id;
92 $this->data[$user_id]['login'] = $login;
93 $this->data[$user_id]['name'] = $publicName;
94
95 $assignedRoles = $this->objParticipants->getAssignedRoles($user_id);
96 $rolesToPreload = array_diff($assignedRoles, $preloadedRoleIds);
97 $this->dataCache->preloadObjectCache($rolesToPreload);
98
99 $roleTitles = [];
100 foreach ($assignedRoles as $roleId) {
101 $preloadedRoleIds[$roleId] = $roleId;
102 $title = $this->dataCache->lookupTitle($roleId);
103 $roleTitles[] = $title;
104 }
105
106 $roleTitles = $this->sortRoles($roleTitles);
107
108 $roleTitles = array_map(function (string $roleTitle) : string {
109 return $this->buildRoleTitle($roleTitle);
110 }, $roleTitles);
111
112 $this->data[$user_id]['role'] = implode(', ', $roleTitles);
113 }
114 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$login
Definition: cron.php:13
$user
Definition: migrateto20.php:57
$this data['403_header']

References $login, $title, $user, buildRoleTitle(), data, ilObjectFactory\getInstanceByObjId(), and sortRoles().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getData()

ilMailMemberSearchDataProvider::getData ( )

Definition at line 148 of file class.ilMailMemberSearchDataProvider.php.

References $data.

◆ sortRoles()

ilMailMemberSearchDataProvider::sortRoles ( array  $roleTitles)
private
Parameters
string[]$roleTitles
Returns
string[]

Definition at line 120 of file class.ilMailMemberSearchDataProvider.php.

120 : array
121 {
122 usort($roleTitles, function (string $a, string $b) : int {
123 $leftPrefixTitle = substr($a, 0, 8);
124 $rightPrefixTitle = substr($b, 0, 8);
125
126 $leftRating = $this->roleSortWeightMap[$leftPrefixTitle] ?? 0;
127 $rightRating = $this->roleSortWeightMap[$rightPrefixTitle] ?? 0;
128
129 if ($leftRating > 0 || $rightRating > 0) {
130 if ($leftRating !== $rightRating) {
131 return $rightRating - $leftRating > 0 ? 1 : -1;
132 }
133
134 return 0;
135 }
136
137 return strcmp($a, $b);
138 });
139
140 return $roleTitles;
141 }

Referenced by collectTableData().

+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilMailMemberSearchDataProvider::$access
protected

Definition at line 13 of file class.ilMailMemberSearchDataProvider.php.

◆ $data

ilMailMemberSearchDataProvider::$data = []
protected

Definition at line 22 of file class.ilMailMemberSearchDataProvider.php.

Referenced by getData().

◆ $dataCache

ilMailMemberSearchDataProvider::$dataCache
protected

Definition at line 28 of file class.ilMailMemberSearchDataProvider.php.

◆ $lng

ilMailMemberSearchDataProvider::$lng
protected

Definition at line 40 of file class.ilMailMemberSearchDataProvider.php.

◆ $objParticipants

ilMailMemberSearchDataProvider::$objParticipants = null
protected

Definition at line 25 of file class.ilMailMemberSearchDataProvider.php.

Referenced by __construct().

◆ $ref_id

ilMailMemberSearchDataProvider::$ref_id
protected

Definition at line 16 of file class.ilMailMemberSearchDataProvider.php.

◆ $roleSortWeightMap

ilMailMemberSearchDataProvider::$roleSortWeightMap
protected
Initial value:
= [
'il_crs_a' => 10,
'il_grp_a' => 10,
'il_crs_t' => 9,
'il_crs_m' => 8,
'il_grp_m' => 8,
]

Definition at line 31 of file class.ilMailMemberSearchDataProvider.php.

◆ $type

ilMailMemberSearchDataProvider::$type = 'crs'
protected

Definition at line 19 of file class.ilMailMemberSearchDataProvider.php.


The documentation for this class was generated from the following file: