ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailMemberSearchDataProvider Class Reference

Class ilMailMemberSearchDataProvider. More...

+ Collaboration diagram for ilMailMemberSearchDataProvider:

Public Member Functions

 __construct (protected ilParticipants $objParticipants, protected int $ref_id)
 
 getData ()
 

Protected Attributes

ilAccessHandler $access
 
string $type = 'crs'
 
array $data = []
 
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 ( protected ilParticipants  $objParticipants,
protected int  $ref_id 
)

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

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

45  {
46  global $DIC;
47 
48  $this->dataCache = $DIC['ilObjDataCache'];
49  $this->access = $DIC->access();
50  $this->type = $this->objParticipants->getType();
51  $this->lng = $DIC['lng'];
52 
53  $this->collectTableData();
54  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ buildRoleTitle()

ilMailMemberSearchDataProvider::buildRoleTitle ( string  $role)
private

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

References ilObjRole\_getTranslation().

Referenced by collectTableData().

139  : string
140  {
141  return ilObjRole::_getTranslation($role);
142  }
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 56 of file class.ilMailMemberSearchDataProvider.php.

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

Referenced by __construct().

56  : void
57  {
58  $participants = $this->objParticipants->getParticipants();
59  if ($this->type === 'crs' || $this->type === 'grp') {
60  $participants = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
61  'read',
62  'manage_members',
63  $this->ref_id,
64  $participants
65  );
66  }
67 
68  $preloadedRoleIds = [];
69  foreach ($participants as $user_id) {
70  $user = ilObjectFactory::getInstanceByObjId($user_id, false);
71  if (!($user instanceof ilObjUser)) {
72  continue;
73  }
74 
75  if (!$user->getActive()) {
76  continue;
77  }
78 
79  $login = $user->getLogin();
80 
81  $publicName = '';
82  if (in_array($user->getPref('public_profile'), ['g', 'y'])) {
83  $publicName = $user->getLastname() . ', ' . $user->getFirstname();
84  }
85 
86  $this->data[$user_id]['user_id'] = $user_id;
87  $this->data[$user_id]['login'] = $login;
88  $this->data[$user_id]['name'] = $publicName;
89 
90  $assignedRoles = $this->objParticipants->getAssignedRoles($user_id);
91  $rolesToPreload = array_diff($assignedRoles, $preloadedRoleIds);
92  $this->dataCache->preloadObjectCache($rolesToPreload);
93 
94  $roleTitles = [];
95  foreach ($assignedRoles as $roleId) {
96  $preloadedRoleIds[$roleId] = $roleId;
97  $title = $this->dataCache->lookupTitle((int) $roleId);
98  $roleTitles[] = $title;
99  }
100 
101  $roleTitles = $this->sortRoles($roleTitles);
102 
103  $roleTitles = array_map(
104  fn(string $roleTitle): string => $this->buildRoleTitle($roleTitle),
105  $roleTitles
106  );
107 
108  $this->data[$user_id]['role'] = implode(', ', $roleTitles);
109  }
110  }
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 144 of file class.ilMailMemberSearchDataProvider.php.

References $data.

144  : array
145  {
146  return $this->data;
147  }

◆ sortRoles()

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

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

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

Referenced by collectTableData().

116  : array
117  {
118  usort($roleTitles, function (string $a, string $b): int {
119  $leftPrefixTitle = substr($a, 0, 8);
120  $rightPrefixTitle = substr($b, 0, 8);
121 
122  $leftRating = $this->roleSortWeightMap[$leftPrefixTitle] ?? 0;
123  $rightRating = $this->roleSortWeightMap[$rightPrefixTitle] ?? 0;
124 
125  if ($leftRating > 0 || $rightRating > 0) {
126  if ($leftRating !== $rightRating) {
127  return $rightRating - $leftRating > 0 ? 1 : -1;
128  }
129 
130  return 0;
131  }
132 
133  return strcmp($a, $b);
134  });
135 
136  return $roleTitles;
137  }
$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 29 of file class.ilMailMemberSearchDataProvider.php.

Referenced by getData().

◆ $dataCache

ilObjectDataCache ilMailMemberSearchDataProvider::$dataCache
protected

Definition at line 30 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 36 of file class.ilMailMemberSearchDataProvider.php.

◆ $roleSortWeightMap

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

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

◆ $type

string ilMailMemberSearchDataProvider::$type = 'crs'
protected

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


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