ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserUtil.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
22  static function getNamePresentation($a_user_id,
23  $a_user_image = false, $a_profile_link = false, $a_profile_back_link = "",
24  $a_force_first_lastname = false)
25  {
26  global $lng, $ilCtrl, $ilDB;
27 
28  if (!($return_as_array = is_array($a_user_id)))
29  $a_user_id = array($a_user_id);
30 
31  $sql = 'SELECT
32  a.usr_id,
33  firstname,
34  lastname,
35  title,
36  login,
37  value public_profile
38  FROM
39  usr_data a
40  LEFT JOIN
41  usr_pref b ON
42  a.usr_id = b.usr_id AND
43  keyword = %s
44  WHERE ' . $ilDB->in('a.usr_id', $a_user_id, false, 'integer');
45 
46  $userrow = $ilDB->queryF($sql, array('text'), array('public_profile'));
47 
48  $names = array();
49 
50  while ($row = $ilDB->fetchObject($userrow))
51  {
52  if ($a_force_first_lastname ||
53  $has_public_profile = in_array($row->public_profile, array("y", "g")))
54  {
55  $pres = $row->lastname.", ".($t = $row->title ? $t . " " : "").$row->firstname." ";
56  }
57 
58  $pres.= "[".$row->login."]";
59 
60  if ($a_profile_link && $has_public_profile)
61  {
62  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user", $row->usr_id);
63  if ($a_profile_back_link != "")
64  {
65  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "back_url",
66  rawurlencode($a_profile_back_link));
67  }
68  $pres = '<a href="'.$ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML").'">'.$pres.'</a>';
69  }
70 
71  if ($a_user_image)
72  {
73  $img = ilObjUser::_getPersonalPicturePath($row->usr_id, "xxsmall");
74  $pres = '<img border="0" src="'.$img.'" alt="'.$lng->txt("icon").
75  " ".$lng->txt("user_picture").'" /> '.$pres;
76  }
77 
78  $names[$row->usr_id] = $pres;
79  }
80 
81  foreach($a_user_id as $id)
82  {
83  if (!$names[$id])
84  $names[$id] = "unknown";
85  }
86 
87  return $return_as_array ? $names : $names[$a_user_id[0]];
88  }
89 
90 }
91 ?>