ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilUserProfileBadge Class Reference
+ Inheritance diagram for ilUserProfileBadge:
+ Collaboration diagram for ilUserProfileBadge:

Public Member Functions

 getId ()
 Get typ id (unique for component) More...
 
 getCaption ()
 Get caption. More...
 
 isSingleton ()
 Can only be created once? More...
 
 getValidObjectTypes ()
 Get valid (repository) "parent" object types. More...
 
 getConfigGUIInstance ()
 Get GUI config instance. More...
 
 evaluate ($a_user_id, array $a_params, array $a_config)
 Evaluate if given user has earned badge. More...
 

Detailed Description

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

Member Function Documentation

◆ evaluate()

ilUserProfileBadge::evaluate (   $a_user_id,
array  $a_params,
array  $a_config 
)

Evaluate if given user has earned badge.

Parameters
int$a_user_id
array$a_params
array$a_config
Returns
bool

Implements ilBadgeAuto.

Definition at line 44 of file class.ilUserProfileBadge.php.

References $ilSetting, $m, array, and ilObjPortfolio\getDefaultPortfolio().

45  {
46  global $ilSetting;
47 
48  $user = new ilObjUser($a_user_id);
49 
50  // active profile portfolio?
51  $has_prtf = false;
52  if ($ilSetting->get('user_portfolios')) {
53  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
54  $has_prtf = ilObjPortfolio::getDefaultPortfolio($a_user_id);
55  }
56  if (!$has_prtf) {
57  // is profile public?
58  if (!in_array($user->getPref("public_profile"), array("y", "g"))) {
59  return false;
60  }
61  }
62 
63  // use getter mapping from user profile
64  include_once("./Services/User/classes/class.ilUserProfile.php");
65  $up = new ilUserProfile();
66  $pfields = $up->getStandardFields();
67 
68  // check for value AND publication status
69 
70  foreach ($a_config["profile"] as $field) {
71  $field = substr($field, 4);
72 
73  if (substr($field, 0, 4) == "udf_") {
74  $udf_field_id = substr($field, 4);
75  if ($user->getPref("public_udf_" . $udf_field_id) != "y") {
76  return false;
77  }
78  $udf = $user->getUserDefinedData();
79  if ($udf["f_" . $udf_field_id] == "") {
80  return false;
81  }
82  }
83  // picture
84  else {
85  if ($user->getPref("public_" . $field) != "y") {
86  return false;
87  }
88  if ($field == "upload") {
89  if (!ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true)) {
90  return false;
91  }
92  }
93  // use profile mapping if possible
94  else {
95  if (isset($pfields[$field]["method"])) {
96  $m = $pfields[$field]["method"];
97  if (!$user->{$m}()) {
98  return false;
99  }
100  }
101  }
102  }
103  }
104 
105  return true;
106  }
Class ilUserProfile.
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
+ Here is the call graph for this function:

◆ getCaption()

ilUserProfileBadge::getCaption ( )

Get caption.

Returns
string

Implements ilBadgeType.

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

References $lng.

23  {
24  global $lng;
25  return $lng->txt("badge_user_profile");
26  }
global $lng
Definition: privfeed.php:17

◆ getConfigGUIInstance()

ilUserProfileBadge::getConfigGUIInstance ( )

Get GUI config instance.

Returns
ilBadgeTypeGUI|null

Implements ilBadgeType.

Definition at line 38 of file class.ilUserProfileBadge.php.

39  {
40  include_once "Services/User/classes/Badges/class.ilUserProfileBadgeGUI.php";
41  return new ilUserProfileBadgeGUI();
42  }

◆ getId()

ilUserProfileBadge::getId ( )

Get typ id (unique for component)

Returns
string

Implements ilBadgeType.

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

18  {
19  return "profile";
20  }

◆ getValidObjectTypes()

ilUserProfileBadge::getValidObjectTypes ( )

Get valid (repository) "parent" object types.

Returns
array

Implements ilBadgeType.

Definition at line 33 of file class.ilUserProfileBadge.php.

References array.

34  {
35  return array("bdga");
36  }
Create styles array
The data for the language used.

◆ isSingleton()

ilUserProfileBadge::isSingleton ( )

Can only be created once?

Returns
bool

Implements ilBadgeType.

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

29  {
30  return false;
31  }

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