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

201 : string
202 {
203 global $DIC;
204 $ctrl = $DIC['ilCtrl'];
205
206 $public_profile = ilObjUser::_lookupPref($a_usr_id, 'public_profile');
207 if ($public_profile != 'y' and $public_profile != 'g') {
208 return '';
209 }
210
211 $ctrl->setParameterByClass(PublicProfileGUI::class, 'user', $a_usr_id);
212 return $ctrl->getLinkTargetByClass(
213 [ilPublicProfileBaseClassGUI::class, PublicProfileGUI::class],
214 'getHTML'
215 );
216 }
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 218 of file class.ilUserUtil.php.

218 : string
219 {
220 return LocalDIC::dic()[StartingPointRepository::class]->getValidAndAccessibleStartingPointAsUrl();
221 }

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 181 of file class.ilUserUtil.php.

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

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: