ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailMemberSearchDataProvider Class Reference

Class ilMailMemberSearchDataProvider. More...

+ Collaboration diagram for ilMailMemberSearchDataProvider:

Public Member Functions

 __construct (ilParticipants $objParticipants, int $a_ref_id)
 
 getData ()
 

Protected Attributes

ilAccessHandler $access
 
int $ref_id
 
string $type = 'crs'
 
array $data = []
 
ilParticipants $objParticipants
 
ilObjectDataCache $dataCache
 
array $roleSortWeightMap
 
array ilLanguage $lng
 

Private Member Functions

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, $objParticipants, ILIAS\Repository\access(), collectTableData(), ilParticipants\getType(), and ILIAS\Repository\lng().

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: feed.php:28
+ 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.

References ilObjRole\_getTranslation().

Referenced by collectTableData().

143  : string
144  {
145  return ilObjRole::_getTranslation($role);
146  }
static _getTranslation(string $a_role_title)
+ 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.

References ILIAS\Repository\access(), buildRoleTitle(), ilObjectFactory\getInstanceByObjId(), and sortRoles().

Referenced by __construct().

61  : void
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) {
75  $user = ilObjectFactory::getInstanceByObjId($user_id, false);
76  if (!($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((int) $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(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ 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.

148  : array
149  {
150  return $this->data;
151  }

◆ sortRoles()

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

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

References Vendor\Package\$a, and Vendor\Package\$b.

Referenced by collectTableData().

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  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilMailMemberSearchDataProvider::$access
protected

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

◆ $data

array ilMailMemberSearchDataProvider::$data = []
protected

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

Referenced by getData().

◆ $dataCache

ilObjectDataCache ilMailMemberSearchDataProvider::$dataCache
protected

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

◆ $lng

array ilLanguage ilMailMemberSearchDataProvider::$lng
protected
Initial value:
=> 10,
'il_crs_t' => 9,
'il_crs_m' => 8,
'il_grp_m' => 8,
]

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

◆ $objParticipants

ilParticipants ilMailMemberSearchDataProvider::$objParticipants
protected

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

Referenced by __construct().

◆ $ref_id

int ilMailMemberSearchDataProvider::$ref_id
protected

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

◆ $roleSortWeightMap

array ilMailMemberSearchDataProvider::$roleSortWeightMap
protected
Initial value:
= [
'il_crs_a' => 10

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

◆ $type

string ilMailMemberSearchDataProvider::$type = 'crs'
protected

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


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