ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserProfileBadge Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilUserProfileBadge:
+ Collaboration diagram for ilUserProfileBadge:

Public Member Functions

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilUserProfileBadge

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Member Function Documentation

◆ evaluate()

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

Evaluate if given user has earned badge.

Implements ilBadgeAuto.

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

References $DIC, $ilSetting, ilObjUser\_getPersonalPicturePath(), and ilObjPortfolio\getDefaultPortfolio().

55  : bool // Missing array type.
56  {
57  global $DIC;
58 
59  $ilSetting = $DIC['ilSetting'];
60 
61  $user = new ilObjUser($a_user_id);
62 
63  // active profile portfolio?
64  $has_prtf = false;
65  if ($ilSetting->get('user_portfolios')) {
66  $has_prtf = ilObjPortfolio::getDefaultPortfolio($a_user_id);
67  }
68 
69  if (!$has_prtf) {
70  // is profile public?
71  if (!in_array($user->getPref('public_profile'), ['y', 'g'])) {
72  return false;
73  }
74  }
75 
76  // use getter mapping from user profile
77  $up = new ilUserProfile();
78  $pfields = $up->getStandardFields();
79 
80  // check for value AND publication status
81 
82  if ($a_config !== null && isset($a_config['profile'])) {
83  foreach ($a_config['profile'] as $field) {
84  $field = substr($field, 4);
85 
86  if (substr($field, 0, 4) === 'udf_') {
87  $udf_field_id = substr($field, 4);
88  if ($user->getPref('public_udf_' . $udf_field_id) !== 'y') {
89  return false;
90  }
91  $udf = $user->getUserDefinedData();
92  if ($udf['f_' . $udf_field_id] == '') {
93  return false;
94  }
95  } else {
96  if ($user->getPref('public_' . $field) !== 'y') {
97  return false;
98  }
99 
100  if ($field === 'upload') {
101  if (!ilObjUser::_getPersonalPicturePath($a_user_id, 'xsmall', true, true)) {
102  return false;
103  }
104  } elseif (isset($pfields[$field]['method'])) {
105  // use profile mapping if possible
106  $m = $pfields[$field]['method'];
107  if (!$user->{$m}()) {
108  return false;
109  }
110  }
111  }
112  }
113  }
114 
115  return true;
116  }
static getDefaultPortfolio(int $a_user_id)
Get default portfolio of user.
Class ilUserProfile.
global $DIC
Definition: feed.php:28
static _getPersonalPicturePath(int $a_usr_id, string $a_size="small", bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
global $ilSetting
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ getCaption()

ilUserProfileBadge::getCaption ( )

Implements ilBadgeType.

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

References $DIC, and $lng.

32  : string
33  {
34  global $DIC;
35 
36  $lng = $DIC['lng'];
37  return $lng->txt('badge_user_profile');
38  }
$lng
global $DIC
Definition: feed.php:28

◆ getConfigGUIInstance()

ilUserProfileBadge::getConfigGUIInstance ( )

Get GUI config instance.

Implements ilBadgeType.

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

51  {
52  return new ilUserProfileBadgeGUI();
53  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getId()

ilUserProfileBadge::getId ( )

Get typ id (unique for component)

Implements ilBadgeType.

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

27  : string
28  {
29  return 'profile';
30  }

◆ getValidObjectTypes()

ilUserProfileBadge::getValidObjectTypes ( )

Get valid (repository) "parent" object types.

Returns
string[]

Implements ilBadgeType.

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

45  : array // Missing array type.
46  {
47  return ['bdga'];
48  }

◆ isSingleton()

ilUserProfileBadge::isSingleton ( )

Can only be created once?

Implements ilBadgeType.

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

40  : bool
41  {
42  return false;
43  }

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