ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilUserUtil Class Reference

Class ilUserUtil. More...

+ Collaboration diagram for ilUserUtil:

Static Public Member Functions

static getNamePresentation ( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
 Default behaviour is: More...
 
static hasPublicProfile (int $a_user_id)
 
static getProfileLink (int $a_usr_id)
 Get link to personal profile Return empty string in case of not public profile. More...
 
static getStartingPointAsUrl ()
 

Detailed Description

Class ilUserUtil.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Member Function Documentation

◆ getNamePresentation()

static ilUserUtil::getNamePresentation (   $a_user_id,
bool  $a_user_image = false,
bool  $a_profile_link = false,
string  $a_profile_back_link = '',
bool  $a_force_first_lastname = false,
bool  $a_omit_login = false,
bool  $a_sortable = true,
bool  $a_return_data_array = false,
  $a_ctrl_path = null 
)
static

Default behaviour is:

  • lastname, firstname if public profile enabled
  • [loginname] (always) modifications by jposselt at databay . de : if $a_user_id is an array of user ids the method returns an array of 'id' => 'NamePresentation' pairs.
    Parameters
    int | int[]$a_user_id
    string | array$a_ctrl_path
    Returns
    array|false|mixed
    Exceptions
    ilWACException

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

51 {
52 global $DIC;
53 $lng = $DIC['lng'];
54 $ilCtrl = $DIC['ilCtrl'];
55 $ilDB = $DIC['ilDB'];
56
57 if ($a_ctrl_path === null) {
58 $a_ctrl_path = strtolower(PublicProfileGUI::class);
59 }
60
61 if (!is_array($a_ctrl_path)) {
62 $a_ctrl_path = [$a_ctrl_path];
63 }
64
65 if (!($return_as_array = is_array($a_user_id))) {
66 $a_user_id = [$a_user_id];
67 }
68
69 $sql = 'SELECT
70 a.usr_id,
71 firstname,
72 lastname,
73 title,
74 login,
75 b.value public_profile,
76 c.value public_title
77 FROM
78 usr_data a
79 LEFT JOIN
80 usr_pref b ON
81 (a.usr_id = b.usr_id AND
82 b.keyword = %s)
83 LEFT JOIN
84 usr_pref c ON
85 (a.usr_id = c.usr_id AND
86 c.keyword = %s)
87 WHERE ' . $ilDB->in('a.usr_id', $a_user_id, false, 'integer');
88
89 $userrow = $ilDB->queryF($sql, ['text', 'text'], ['public_profile', 'public_title']);
90
91 $names = [];
92
93 $data = [];
94 while ($row = $ilDB->fetchObject($userrow)) {
95 $pres = '';
96 $d = [
97 'id' => (int) $row->usr_id,
98 'title' => '',
99 'lastname' => '',
100 'firstname' => '',
101 'img' => '',
102 'link' => ''
103 ];
104 $has_public_profile = in_array($row->public_profile, ['y', 'g']);
105 if ($a_force_first_lastname || $has_public_profile) {
106 $title = '';
107 if ($row->public_title == 'y' && $row->title) {
108 $title = $row->title . ' ';
109 }
110 $d['title'] = $title;
111 if ($a_sortable) {
112 $pres = $row->lastname;
113 if (strlen($row->firstname)) {
114 $pres .= (', ' . $row->firstname . ' ');
115 }
116 } else {
117 $pres = $title;
118 if (strlen($row->firstname)) {
119 $pres .= $row->firstname . ' ';
120 }
121 $pres .= ($row->lastname . ' ');
122 }
123 $d['firstname'] = $row->firstname;
124 $d['lastname'] = $row->lastname;
125 }
126 $d['login'] = $row->login;
127 $d['public_profile'] = $has_public_profile;
128
129
130 if (!$a_omit_login) {
131 $pres .= '[' . $row->login . ']';
132 }
133
134 if ($a_profile_link && $has_public_profile) {
135 $ilCtrl->setParameterByClass(end($a_ctrl_path), 'user_id', $row->usr_id);
136 if ($a_profile_back_link != '') {
137 $ilCtrl->setParameterByClass(
138 end($a_ctrl_path),
139 'back_url',
140 rawurlencode($a_profile_back_link)
141 );
142 }
143 $link = $ilCtrl->getLinkTargetByClass($a_ctrl_path, 'getHTML');
144 $pres = '<a href="' . $link . '">' . $pres . '</a>';
145 $d['link'] = $link;
146 }
147
148 if ($a_user_image) {
149 $img = ilObjUser::_getPersonalPicturePath($row->usr_id, 'xxsmall');
150 $pres = '<img class="ilUserXXSmall" src="' . $img . '" alt="' . $lng->txt('icon') .
151 ' ' . $lng->txt('user_picture') . '" /> ' . $pres;
152 $d['img'] = $img;
153 }
154
155 $names[$row->usr_id] = $pres;
156 $data[$row->usr_id] = $d;
157 }
158
159 foreach ($a_user_id as $id) {
160 if (!isset($names[$id])) {
161 $names[$id] = $lng->txt('deleted_user');
162 }
163 if ($names[$id] === '') {
164 $names[$id] = $lng->txt('usr_name_undisclosed');
165 }
166 }
167
168 if ($a_return_data_array) {
169 if ($return_as_array) {
170 return $data;
171 } else {
172 return current($data);
173 }
174 }
175 return $return_as_array ? $names : $names[$a_user_id[0]];
176 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false)
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26

References Vendor\Package\$d, $data, $DIC, $id, $ilDB, $lng, ilObjUser\_getPersonalPicturePath(), and ILIAS\Repository\int().

Referenced by ilSurveyAppraiseesTableGUI\__construct(), ILIAS\Survey\Mode\AbstractUIModifier\addApprSelectionToToolbar(), ILIAS\Mail\Placeholder\MailSignatureUserFullnamePlaceholder\addPlaceholder(), ILIAS\Portfolio\Notification\SharedNotification\appendObjectInformation(), ILIAS\Test\Logging\AdditionalInformationGenerator\buildListOfUsers(), ilExSubmissionTeamGUI\buildSubmissionPropertiesAndActions(), ILIAS\Blog\Contributor\ContributorRetrieval\collectData(), ilMDCopyrightUsageTableGUI\collectData(), ilGroupAddToGroupActionGUI\confirmAddUser(), ilSurveyParticipantsGUI\confirmAdminAppraiseesCloseObject(), ilGroupAddToGroupActionGUI\confirmCreateGroupAndAddUser(), ilBadgeManagementGUI\confirmDeassignBadge(), ilExerciseManagementGUI\confirmDeassignMembersObject(), ilSurveyParticipantsGUI\confirmDeleteAppraiseesObject(), ilMailingListsGUI\confirmDeleteMembers(), ilSurveyParticipantsGUI\confirmDeleteRatersObject(), ilConsultationHoursGUI\confirmRejectBooking(), ilExerciseManagementGUI\createTeamsFromGroupsObject(), ilContSkillAdminGUI\deassignCompetencesConfirm(), ILIAS\Survey\Execution\LaunchGUI\determineMainLink(), ilSharedResourceGUI\executeCommand(), ilBookingReservationsTableGUI\fillRow(), ilPageHistoryTableGUI\fillRow(), ilExAssignmentListTextTableGUI\fillRow(), ilHistoryTableGUI\fillRow(), ilWorkspaceShareTableGUI\fillRow(), ilUserForTagTableGUI\fillRow(), ilWikiPagesTableGUI\fillRow(), ilWikiRecentChangesTableGUI\fillRow(), ILIAS\Cron\Job\Manager\UI\JobTable\formatResultInfo(), ILIAS\Cron\Job\Manager\UI\JobTable\formatStatusInfo(), ilExSubmissionTeamGUI\getAdoptForm(), ILIAS\Skill\Table\ProfileUserAssignmentTable\getAssignmentTitle(), ILIAS\OnScreenChat\Repository\Subscriber\getDataByUserIds(), ILIAS\User\Profile\PublicProfileGUI\getEmbeddable(), ilExAssignmentTeamTableGUI\getItems(), ilMessageGUI\getItemTitle(), ilNoteGUI\getItemTitle(), ilLMPageObjectGUI\getLinkXML(), ilPageLinker\getLinkXML(), ILIAS\Awareness\WidgetManager\getListData(), ilLearningModuleNotification\getMailBody(), ILIAS\Repository\Profile\ProfileGUI\getNamePresentation(), ilWikiPagesTableGUI\getPages(), ilExPeerReviewGUI\getPeerReviewReceiverPanel(), ilAbstractUsersGalleryCollectionProvider\getPopulatedGroup(), ilExPeerReviewGUI\getReceivedFeedbackPanel(), ilDclBaseRecordModel\getStandardFieldHTML(), ILIAS\Notifications\Provider\AwarenessToastProvider\getToasts(), ilAppointmentPresentationGUI\getUserName(), ilMailUserHelper\getUsernameMapForIds(), ilInternalLinkGUI\getUserSearchResult(), ILIAS\Blog\News\NewsManager\handle(), ilWorkspaceAccessTableGUI\importData(), ilCalendarCategoryGUI\initFormCategory(), ilExerciseManagementGUI\initGroupForm(), ILIAS\Contact\MailingLists\MailingListsMembersTable\initRecords(), ilBookingPreferencesGUI\listBookingResults(), ilExAssignmentListTextTableGUI\parse(), ilConsultationHourBookingTableGUI\parse(), ilWikiPageGUI\preview(), ilContSkillAdminGUI\publishAssignments(), ilNewsTimelineItemGUI\render(), ilLikeGUI\renderModal(), ILIAS\User\Profile\PublicProfileGUI\renderTitle(), ilBuddySystemNotification\send(), ilDataCollectionMailNotification\send(), ilLMMailNotification\send(), ilMStShowUserGUI\setTitleAndIcon(), ilChatroomBanGUI\show(), ilPageObjectGUI\showEditLockInfo(), ilPageObjectGUI\showPage(), ilExAssignmentPeerReviewOverviewTableGUI\translateUserIds(), and ilPageObject\update().

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

◆ getProfileLink()

static ilUserUtil::getProfileLink ( int  $a_usr_id)
static

Get link to personal profile Return empty string in case of not public profile.

Definition at line 198 of file class.ilUserUtil.php.

198 : string
199 {
200 global $DIC;
201 $ctrl = $DIC['ilCtrl'];
202
203 $public_profile = ilObjUser::_lookupPref($a_usr_id, 'public_profile');
204 if ($public_profile != 'y' and $public_profile != 'g') {
205 return '';
206 }
207
208 $ctrl->setParameterByClass(PublicProfileGUI::class, 'user', $a_usr_id);
209 return $ctrl->getLinkTargetByClass(PublicProfileGUI::class, 'getHTML');
210 }
static _lookupPref(int $a_usr_id, string $a_keyword)

References $DIC, and ilObjUser\_lookupPref().

Referenced by ilMDCopyrightUsageTableGUI\collectData(), ilRepositoryUserResultTableGUI\fillRow(), and ILIAS\Calendar\ConsultationHours\BookingDataProvider\read().

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

◆ getStartingPointAsUrl()

static ilUserUtil::getStartingPointAsUrl ( )
static

Definition at line 212 of file class.ilUserUtil.php.

212 : string
213 {
214 return LocalDIC::dic()[StartingPointRepository::class]->getValidAndAccessibleStartingPointAsUrl();
215 }

Referenced by ilAdministrationGUI\executeCommand(), ILIAS\GlobalScreen\Scope\Layout\Provider\PagePart\StandardPagePartProvider\getStartingPointAsUrl(), ILIAS\StaticURL\Handler\LegacyGotoHandler\handle(), ilInitialisation\redirectToStartingPage(), and ilStartUpGUI\showLogout().

+ Here is the caller graph for this function:

◆ hasPublicProfile()

static ilUserUtil::hasPublicProfile ( int  $a_user_id)
static

Definition at line 178 of file class.ilUserUtil.php.

178 : bool
179 {
180 global $DIC;
181 $ilDB = $DIC['ilDB'];
182
183 $set = $ilDB->query(
184 'SELECT value FROM usr_pref ' .
185 ' WHERE usr_id = ' . $ilDB->quote($a_user_id, 'integer') .
186 ' and keyword = ' . $ilDB->quote('public_profile', 'text')
187 );
188 $rec = $ilDB->fetchAssoc($set);
189
190 return in_array($rec['value'] ?? '', ['y', 'g']);
191 }

References $DIC, and $ilDB.

Referenced by ilLMPageObjectGUI\getLinkXML(), and ilPageLinker\getLinkXML().

+ Here is the caller graph for this function:

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