ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMailMemberSearchDataProvider Class Reference

Class ilMailMemberSearchDataProvider. More...

+ Collaboration diagram for ilMailMemberSearchDataProvider:

Public Member Functions

 __construct ($objParticipants)
 
 getData ()
 

Protected Attributes

 $type = 'crs'
 
 $data = array()
 
 $objParticipants = null
 
 $lng
 
 $dataCache
 
 $roleSortWeightMap
 

Private Member Functions

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailMemberSearchDataProvider::__construct (   $objParticipants)
Parameters
\ilParticipants$objParticipants

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

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

42  {
43  global $DIC;
44 
45  $this->dataCache = $DIC['ilObjDataCache'];
46  $this->objParticipants = $objParticipants;
47  $this->type = $this->objParticipants->getType();
48  $this->lng = $DIC['lng'];
49 
50  $this->collectTableData();
51  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ buildRoleTitle()

ilMailMemberSearchDataProvider::buildRoleTitle (   $role)
private
Parameters
string$role
Returns
string

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

131  {
132  require_once 'Services/AccessControl/classes/class.ilObjRole.php';
133  return \ilObjRole::_getTranslation($role);
134  }

◆ collectTableData()

ilMailMemberSearchDataProvider::collectTableData ( )
private

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

References $name, $title, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), array, data, and sortRoles().

Referenced by __construct().

57  {
58  $participants = $this->objParticipants->getParticipants();
59  foreach ($participants as $user_id) {
60  $name = ilObjUser::_lookupName($user_id);
61  $login = ilObjUser::_lookupLogin($user_id);
62 
63  $publicName = '';
64  if (in_array(ilObjUser::_lookupPref($user_id, 'public_profile'), array('g', 'y'))) {
65  $publicName = $name['lastname'] . ', ' . $name['firstname'];
66  }
67 
68  $this->data[$user_id]['user_id'] = $user_id;
69  $this->data[$user_id]['login'] = $login;
70  $this->data[$user_id]['name'] = $publicName;
71 
72  $assignedRoles = $this->objParticipants->getAssignedRoles($user_id);
73  $this->dataCache->preloadObjectCache($assignedRoles);
74  $roleTitles = [];
75  foreach ($assignedRoles as $roleId) {
76  $title = $this->dataCache->lookupTitle($roleId);
77  $roleTitles[] = $title;
78  }
79 
80  $roleTitles = $this->sortRoles($roleTitles);
81 
82  $that = $this;
83  $roleTitles = array_map(function ($roleTitle) use ($that) {
84  return $that->buildRoleTitle($roleTitle);
85  }, $roleTitles);
86 
87  $this->data[$user_id]['role'] = implode(', ', $roleTitles);
88  }
89  }
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
Add some data
if($format !==null) $name
Definition: metadata.php:146
Create styles array
The data for the language used.
static _lookupPref($a_usr_id, $a_keyword)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getData()

ilMailMemberSearchDataProvider::getData ( )
Returns
array

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

References $data.

◆ sortRoles()

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

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

Referenced by collectTableData().

96  {
97  $that = $this;
98  usort($roleTitles, function ($a, $b) use ($that) {
99  $leftPrefixTitle = substr($a, 0, 8);
100  $rightPrefixTitle = substr($b, 0, 8);
101 
102  $leftRating = 0;
103  if (isset($that->roleSortWeightMap[$leftPrefixTitle])) {
104  $leftRating = $that->roleSortWeightMap[$leftPrefixTitle];
105  }
106 
107  $rightRating = 0;
108  if (isset($that->roleSortWeightMap[$rightPrefixTitle])) {
109  $rightRating = $that->roleSortWeightMap[$rightPrefixTitle];
110  }
111 
112  if ($leftRating > 0 || $rightRating > 0) {
113  if ($leftRating !== $rightRating) {
114  return $rightRating - $leftRating > 0 ? 1 : -1;
115  } else {
116  return 0;
117  }
118  }
119 
120  return strcmp($a, $b);
121  });
122 
123  return $roleTitles;
124  }
+ Here is the caller graph for this function:

Field Documentation

◆ $data

ilMailMemberSearchDataProvider::$data = array()
protected

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

Referenced by getData().

◆ $dataCache

ilMailMemberSearchDataProvider::$dataCache
protected

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

◆ $lng

ilMailMemberSearchDataProvider::$lng
protected

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

◆ $objParticipants

ilMailMemberSearchDataProvider::$objParticipants = null
protected

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

Referenced by __construct().

◆ $roleSortWeightMap

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

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

◆ $type

ilMailMemberSearchDataProvider::$type = 'crs'
protected

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


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