ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserUtil Class Reference

Class ilUserUtil. More...

+ Collaboration diagram for ilUserUtil:

Static Public Member Functions

static getNamePresentation ($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
 Default behaviour is: More...
 
static getProfileLink ($a_usr_id)
 Get link to personal profile Return empty string in case of not public profile. More...
 
static getPossibleStartingPoints ($a_force_all=false)
 Get all valid starting points. More...
 
static setStartingPoint ($a_value, $a_ref_id=null)
 Set starting point setting. More...
 
static getStartingPoint ()
 Get current starting point setting. More...
 
static getStartingPointAsUrl ()
 Get current starting point setting as URL. More...
 
static getStartingObject ()
 Get ref id of starting object. More...
 
static togglePersonalStartingPoint ($a_value)
 Toggle personal starting point setting. More...
 
static hasPersonalStartingPoint ()
 Can starting point be personalized? More...
 
static getPersonalStartingPoint ()
 Get current personal starting point. More...
 
static setPersonalStartingPoint ($a_value, $a_ref_id=null)
 Set personal starting point setting. More...
 
static getPersonalStartingObject ()
 Get ref id of personal starting object. More...
 

Data Fields

const START_PD_OVERVIEW = 1
 
const START_PD_SUBSCRIPTION = 2
 
const START_PD_BOOKMARKS = 3
 
const START_PD_NOTES = 4
 
const START_PD_NEWS = 5
 
const START_PD_WORKSPACE = 6
 
const START_PD_PORTFOLIO = 7
 
const START_PD_SKILLS = 8
 
const START_PD_LP = 9
 
const START_PD_CALENDAR = 10
 
const START_PD_MAIL = 11
 
const START_PD_CONTACTS = 12
 
const START_PD_PROFILE = 13
 
const START_PD_SETTINGS = 14
 
const START_REPOSITORY = 15
 
const START_REPOSITORY_OBJ = 16
 

Detailed Description

Class ilUserUtil.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ getNamePresentation()

static ilUserUtil::getNamePresentation (   $a_user_id,
  $a_user_image = false,
  $a_profile_link = false,
  $a_profile_back_link = "",
  $a_force_first_lastname = false,
  $a_omit_login = false,
  $a_sortable = true 
)
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
booleansortable should be used in table presentions. output is "Doe, John" title is ommited

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

References $ilCtrl, $img, $lng, $row, and ilObjUser\_getPersonalPicturePath().

Referenced by ilSurveyAppraiseesTableGUI\__construct(), ilSystemNotification\compose(), ilSurveyParticipantsGUI\confirmAdminAppraiseesCloseObject(), ilObjExerciseGUI\confirmDeassignMembersObject(), ilSurveyParticipantsGUI\confirmDeleteAppraiseesObject(), ilSurveyParticipantsGUI\confirmDeleteRatersObject(), ilConsultationHoursGUI\confirmRejectBooking(), ilCourseParticipantsGroupsGUI\confirmRemove(), ilObjExerciseGUI\confirmRemoveTeamMemberObject(), ilPageObjectGUI\edit(), ilSharedResourceGUI\executeCommand(), ilObjExerciseGUI\executeCommand(), ilUserForTagTableGUI\fillRow(), ilWikiRecentChangesTableGUI\fillRow(), ilExcDeliveredFilesTableGUI\fillRow(), ilExAssignmentListTextTableGUI\fillRow(), ilWikiPagesTableGUI\fillRow(), ilUsersOnlineBlockGUI\fillRow(), ilWorkspaceShareTableGUI\fillRow(), ilContributorTableGUI\getItems(), ilExAssignmentTeamTableGUI\getItems(), ilCourseParticipantsGroupsTableGUI\getItems(), ilNoteGUI\getNoteListHTML(), ilWikiPagesTableGUI\getPages(), ilDataCollectionRecord\getStandardFieldHTML(), ilWorkspaceAccessTableGUI\importData(), ilObjSurveyGUI\infoScreen(), ilObjFileGUI\infoScreenForward(), ilSurveyExecutionGUI\outSurveyPage(), ilExAssignmentListTextTableGUI\parse(), ilConsultationHourBookingTableGUI\parse(), ilCronManagerTableGUI\parseJobToData(), ilBlogPostingGUI\postOutputProcessing(), ilWikiPageGUI\preview(), ilObjBlogGUI\renderList(), ilObjBlogGUI\renderNavigation(), ilPublicUserProfileGUI\renderTitle(), ilObjDataCollection\sendNotification(), ilWikiUtil\sendNotification(), ilObjSurvey\sendNotificationMail(), ilObjExerciseGUI\showAssignmentTextObject(), ilPageObjectGUI\showPage(), and ilPageObject\update().

45  {
46  global $lng, $ilCtrl, $ilDB;
47 
48  if (!($return_as_array = is_array($a_user_id)))
49  $a_user_id = array($a_user_id);
50 
51  $sql = 'SELECT
52  a.usr_id,
53  firstname,
54  lastname,
55  title,
56  login,
57  b.value public_profile,
58  c.value public_title
59  FROM
60  usr_data a
61  LEFT JOIN
62  usr_pref b ON
63  (a.usr_id = b.usr_id AND
64  b.keyword = %s)
65  LEFT JOIN
66  usr_pref c ON
67  (a.usr_id = c.usr_id AND
68  c.keyword = %s)
69  WHERE ' . $ilDB->in('a.usr_id', $a_user_id, false, 'integer');
70 
71  $userrow = $ilDB->queryF($sql, array('text', 'text'), array('public_profile', 'public_title'));
72 
73  $names = array();
74 
75  while ($row = $ilDB->fetchObject($userrow))
76  {
77  if ($a_force_first_lastname ||
78  $has_public_profile = in_array($row->public_profile, array("y", "g")))
79  {
80  $title = "";
81  if($row->public_title == "y" && $row->title)
82  {
83  $title = $row->title . " ";
84  }
85  if($a_sortable)
86  {
87  $pres = $row->lastname;
88  if(strlen($row->firstname))
89  {
90  $pres .= (', '.$row->firstname.' ');
91  }
92  }
93  else
94  {
95  $pres = $title;
96  if(strlen($row->firstname))
97  {
98  $pres .= $row->firstname.' ';
99  }
100  $pres .= ($row->lastname.' ');
101  }
102 
103  }
104 
105  if(!$a_omit_login)
106  {
107  $pres.= "[".$row->login."]";
108  }
109 
110  if ($a_profile_link && $has_public_profile)
111  {
112  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user", $row->usr_id);
113  if ($a_profile_back_link != "")
114  {
115  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "back_url",
116  rawurlencode($a_profile_back_link));
117  }
118  $pres = '<a href="'.$ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML").'">'.$pres.'</a>';
119  }
120 
121  if ($a_user_image)
122  {
123  $img = ilObjUser::_getPersonalPicturePath($row->usr_id, "xxsmall");
124  $pres = '<img border="0" src="'.$img.'" alt="'.$lng->txt("icon").
125  " ".$lng->txt("user_picture").'" /> '.$pres;
126  }
127 
128  $names[$row->usr_id] = $pres;
129  }
130 
131  foreach($a_user_id as $id)
132  {
133  if (!$names[$id])
134  $names[$id] = "unknown";
135  }
136 
137  return $return_as_array ? $names : $names[$a_user_id[0]];
138  }
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPersonalStartingObject()

static ilUserUtil::getPersonalStartingObject ( )
static

Get ref id of personal starting object.

Returns
int

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

References $ilUser, and $ref_id.

Referenced by ilPersonalSettingsGUI\initGeneralSettingsForm().

431  {
432  global $ilUser;
433 
434  $ref_id = $ilUser->getPref("usr_starting_point_ref_id");
435  if(!$ref_id)
436  {
437  $ref_id = self::getStartingObject();
438  }
439  return $ref_id;
440  }
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
+ Here is the caller graph for this function:

◆ getPersonalStartingPoint()

static ilUserUtil::getPersonalStartingPoint ( )
static

Get current personal starting point.

Returns
int

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

References $ilUser, and $valid.

Referenced by ilPersonalSettingsGUI\initGeneralSettingsForm().

378  {
379  global $ilUser;
380 
381  $valid = array_keys(self::getPossibleStartingPoints());
382  $current = $ilUser->getPref("usr_starting_point");
383  if($current == self::START_REPOSITORY_OBJ)
384  {
385  return $current;
386  }
387  else if(!$current || !in_array($current, $valid))
388  {
389  return self::getStartingPoint();
390  }
391  return $current;
392  }
$valid
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ getPossibleStartingPoints()

static ilUserUtil::getPossibleStartingPoints (   $a_force_all = false)
static

Get all valid starting points.

Returns
array

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

References $ilSetting, $lang, $lng, and ilCalendarSettings\_getInstance().

Referenced by ilPersonalSettingsGUI\initGeneralSettingsForm(), and ilObjSystemFolderGUI\showBasicSettingsObject().

169  {
170  global $ilSetting, $lng;
171 
172  // for all conditions: see ilMainMenuGUI
173 
174  $all = array();
175 
176  $all[self::START_PD_OVERVIEW] = 'overview';
177 
178  if($a_force_all || ($ilSetting->get('disable_my_offers') == 0 &&
179  $ilSetting->get('disable_my_memberships') == 0))
180  {
181  $all[self::START_PD_SUBSCRIPTION] = 'my_courses_groups';
182  }
183 
184  if($a_force_all || !$ilSetting->get("disable_personal_workspace"))
185  {
186  $all[self::START_PD_WORKSPACE] = 'personal_workspace';
187  }
188 
189  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
190  $settings = ilCalendarSettings::_getInstance();
191  if($a_force_all || $settings->isEnabled())
192  {
193  $all[self::START_PD_CALENDAR] = 'calendar';
194  }
195 
196  $all[self::START_REPOSITORY] = 'repository';
197 
198  foreach($all as $idx => $lang)
199  {
200  $all[$idx] = $lng->txt($lang);
201  }
202 
203  return $all;
204  }
static _getInstance()
get singleton instance
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProfileLink()

static ilUserUtil::getProfileLink (   $a_usr_id)
static

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

Parameters
type$a_usr_id
Returns
string

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

References $GLOBALS, and ilObjUser\_lookupPref().

Referenced by ilRepositoryUserResultTableGUI\fillRow().

147  {
148  $public_profile = ilObjUser::_lookupPref($a_usr_id,'public_profile');
149  if($public_profile != 'y' and $public_profile != 'g')
150  {
151  return '';
152  }
153 
154  $GLOBALS['ilCtrl']->setParameterByClass('ilpublicuserprofilegui','user',$a_usr_id);
155  return $GLOBALS['ilCtrl']->getLinkTargetByClass('ilpublicuserprofilegui','getHTML');
156  }
_lookupPref($a_usr_id, $a_keyword)
$GLOBALS['ct_recipient']
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStartingObject()

static ilUserUtil::getStartingObject ( )
static

Get ref id of starting object.

Returns
int

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

References $ilSetting.

Referenced by ilObjSystemFolderGUI\showBasicSettingsObject().

341  {
342  global $ilSetting;
343 
344  return $ilSetting->get("usr_starting_point_ref_id");
345  }
global $ilSetting
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ getStartingPoint()

static ilUserUtil::getStartingPoint ( )
static

Get current starting point setting.

Returns
int

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

References $ilSetting, $ilUser, and $valid.

Referenced by ilObjSystemFolderGUI\showBasicSettingsObject().

243  {
244  global $ilSetting, $ilUser;
245 
246  $valid = array_keys(self::getPossibleStartingPoints());
247  $current = $ilSetting->get("usr_starting_point");
248  if($current == self::START_REPOSITORY_OBJ)
249  {
250  return $current;
251  }
252  else if(!$current || !in_array($current, $valid))
253  {
254  $current = self::START_PD_OVERVIEW;
255 
256  // #10715 - if 1 is disabled overview will display the current default
257  if($ilSetting->get('disable_my_offers') == 0 &&
258  $ilSetting->get('disable_my_memberships') == 0 &&
259  $ilSetting->get('personal_items_default_view') == 1)
260  {
261  $current = self::START_PD_SUBSCRIPTION;
262  }
263 
264  self::setStartingPoint($current);
265  }
266  if($ilUser->getId() == ANONYMOUS_USER_ID)
267  {
268  $current = self::START_REPOSITORY;
269  }
270  return $current;
271  }
$valid
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ getStartingPointAsUrl()

static ilUserUtil::getStartingPointAsUrl ( )
static

Get current starting point setting as URL.

Returns
string

self::START_PD_LP => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToLP',

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

References $ilUser, $ref_id, ilLink\_getStaticLink(), and ilObject\_lookupObjId().

Referenced by ilMainMenuGUI\getHeaderURL(), and ilStartUpGUI\processIndexPHP().

279  {
280  global $tree, $ilUser;
281 
282  $ref_id = 1;
283  if(self::hasPersonalStartingPoint())
284  {
285  $current = self::getPersonalStartingPoint();
286  if($current == self::START_REPOSITORY_OBJ)
287  {
288  $ref_id = self::getPersonalStartingObject();
289  }
290  }
291  else
292  {
293  $current = self::getStartingPoint();
294  if($current == self::START_REPOSITORY_OBJ)
295  {
296  $ref_id = self::getStartingObject();
297  }
298  }
299  switch($current)
300  {
301  case self::START_REPOSITORY:
302  case self::START_REPOSITORY_OBJ:
303  if($ref_id &&
305  !$tree->isDeleted($ref_id))
306  {
307  include_once('./Services/Link/classes/class.ilLink.php');
308  return ilLink::_getStaticLink($ref_id,'',true);
309  }
310  // invalid starting object, overview is fallback
311  $current = self::START_PD_OVERVIEW;
312  // fallthrough
313 
314  default:
315  $map = array(
316  self::START_PD_OVERVIEW => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSelectedItems',
317  self::START_PD_SUBSCRIPTION => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToMemberships',
318  // self::START_PD_BOOKMARKS => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToBookmarks',
319  // self::START_PD_NOTES => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToNotes',
320  // self::START_PD_NEWS => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToNews',
321  self::START_PD_WORKSPACE => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace',
322  // self::START_PD_PORTFOLIO => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToPortfolio',
323  // self::START_PD_SKILLS => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSkills',
325  self::START_PD_CALENDAR => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToCalendar',
326  // self::START_PD_MAIL => 'ilias.php?baseClass=ilMailGUI',
327  // self::START_PD_CONTACTS => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToContacts',
328  // self::START_PD_PROFILE => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToProfile',
329  // self::START_PD_SETTINGS => 'ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSettings'
330  );
331  return $map[$current];
332  }
333  }
static _lookupObjId($a_id)
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasPersonalStartingPoint()

static ilUserUtil::hasPersonalStartingPoint ( )
static

Can starting point be personalized?

Returns
bool

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

References $ilSetting.

Referenced by ilPersonalSettingsGUI\initGeneralSettingsForm(), ilPersonalSettingsGUI\saveGeneralSettings(), and ilObjSystemFolderGUI\showBasicSettingsObject().

365  {
366  global $ilSetting;
367 
368  return $ilSetting->get("usr_starting_point_personal");
369  }
global $ilSetting
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ setPersonalStartingPoint()

static ilUserUtil::setPersonalStartingPoint (   $a_value,
  $a_ref_id = null 
)
static

Set personal starting point setting.

Parameters
int$a_value
int$a_ref_id
Returns
boolean

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

References $ilUser, $valid, and ilObject\_lookupObjId().

Referenced by ilPersonalSettingsGUI\saveGeneralSettings().

402  {
403  global $ilUser, $tree;
404 
405  if($a_value == self::START_REPOSITORY_OBJ)
406  {
407  $a_ref_id = (int)$a_ref_id;
408  if(ilObject::_lookupObjId($a_ref_id) &&
409  !$tree->isDeleted($a_ref_id))
410  {
411  $ilUser->setPref("usr_starting_point", $a_value);
412  $ilUser->setPref("usr_starting_point_ref_id", $a_ref_id);
413  return true;
414  }
415  }
416  $valid = array_keys(self::getPossibleStartingPoints());
417  if(in_array($a_value, $valid))
418  {
419  $ilUser->setPref("usr_starting_point", $a_value);
420  return true;
421  }
422  return false;
423  }
$valid
static _lookupObjId($a_id)
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStartingPoint()

static ilUserUtil::setStartingPoint (   $a_value,
  $a_ref_id = null 
)
static

Set starting point setting.

Parameters
int$a_value
int$a_ref_id
Returns
boolean

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

References $ilSetting, $valid, and ilObject\_lookupObjId().

Referenced by ilObjSystemFolderGUI\saveBasicSettingsObject().

214  {
215  global $ilSetting, $tree;
216 
217  if($a_value == self::START_REPOSITORY_OBJ)
218  {
219  $a_ref_id = (int)$a_ref_id;
220  if(ilObject::_lookupObjId($a_ref_id) &&
221  !$tree->isDeleted($a_ref_id))
222  {
223  $ilSetting->set("usr_starting_point", $a_value);
224  $ilSetting->set("usr_starting_point_ref_id", $a_ref_id);
225  return true;
226  }
227  }
228  $valid = array_keys(self::getPossibleStartingPoints());
229  if(in_array($a_value, $valid))
230  {
231  $ilSetting->set("usr_starting_point", $a_value);
232  return true;
233  }
234  return false;
235  }
$valid
static _lookupObjId($a_id)
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ togglePersonalStartingPoint()

static ilUserUtil::togglePersonalStartingPoint (   $a_value)
static

Toggle personal starting point setting.

Parameters
bool$a_value

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

References $ilSetting.

Referenced by ilObjSystemFolderGUI\saveBasicSettingsObject().

353  {
354  global $ilSetting;
355 
356  $ilSetting->set("usr_starting_point_personal", (bool)$a_value);
357  }
global $ilSetting
Definition: privfeed.php:40
+ Here is the caller graph for this function:

Field Documentation

◆ START_PD_BOOKMARKS

const ilUserUtil::START_PD_BOOKMARKS = 3

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

◆ START_PD_CALENDAR

const ilUserUtil::START_PD_CALENDAR = 10

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

◆ START_PD_CONTACTS

const ilUserUtil::START_PD_CONTACTS = 12

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

◆ START_PD_LP

const ilUserUtil::START_PD_LP = 9

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

◆ START_PD_MAIL

const ilUserUtil::START_PD_MAIL = 11

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

◆ START_PD_NEWS

const ilUserUtil::START_PD_NEWS = 5

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

◆ START_PD_NOTES

const ilUserUtil::START_PD_NOTES = 4

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

◆ START_PD_OVERVIEW

const ilUserUtil::START_PD_OVERVIEW = 1

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

◆ START_PD_PORTFOLIO

const ilUserUtil::START_PD_PORTFOLIO = 7

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

◆ START_PD_PROFILE

const ilUserUtil::START_PD_PROFILE = 13

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

◆ START_PD_SETTINGS

const ilUserUtil::START_PD_SETTINGS = 14

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

◆ START_PD_SKILLS

const ilUserUtil::START_PD_SKILLS = 8

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

◆ START_PD_SUBSCRIPTION

const ilUserUtil::START_PD_SUBSCRIPTION = 2

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

◆ START_PD_WORKSPACE

const ilUserUtil::START_PD_WORKSPACE = 6

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

◆ START_REPOSITORY

const ilUserUtil::START_REPOSITORY = 15

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

◆ START_REPOSITORY_OBJ

const ilUserUtil::START_REPOSITORY_OBJ = 16

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