ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\User\Badges\ProfileBadge Class Reference
+ Inheritance diagram for ILIAS\User\Badges\ProfileBadge:
+ Collaboration diagram for ILIAS\User\Badges\ProfileBadge:

Public Member Functions

 __construct (private readonly Language $lng, private readonly \ilSetting $setting, private readonly RequestInterface $request, private readonly Profile $profile)
 
 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 $user_id, array $params, ?array $config)
 Evaluate if given user has earned badge. More...
 
 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

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 30 of file ProfileBadge.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\User\Badges\ProfileBadge::__construct ( private readonly Language  $lng,
private readonly \ilSetting  $setting,
private readonly RequestInterface  $request,
private readonly Profile  $profile 
)

Definition at line 32 of file ProfileBadge.php.

37 {
38 }

Member Function Documentation

◆ evaluate()

ILIAS\User\Badges\ProfileBadge::evaluate ( int  $a_user_id,
array  $a_params,
?array  $a_config 
)

Evaluate if given user has earned badge.

Implements ilBadgeAuto.

Definition at line 68 of file ProfileBadge.php.

68 : bool
69 {
70 $user = new \ilObjUser($user_id);
71
72 if ($this->setting->get('user_portfolios') !== '1'
73 || array_filter(
75 static fn(array $v): bool => $v['is_default'] === 1
76 ) !== []) {
77 // is profile public?
78 if (!in_array($user->getPref('public_profile'), ['y', 'g'])) {
79 return false;
80 }
81 }
82
83 if ($config === null || !isset($config['profile'])) {
84 return true;
85 }
86
87 foreach ($config['profile'] as $long_field_id) {
88 $field_id = substr($long_field_id, 4);
89 if (substr($field_id, 0, 4) === 'udf_') {
90 $field_id = substr($field_id, 4);
91 }
92
93 $field = $this->profile->getFieldByIdentifier($field_id);
94 if ($field === null) {
95 continue;
96 }
97 if (!$field->isPublishedByUser($user)
98 || empty($field->retrieveValueFromUser($user))) {
99 return false;
100 }
101 }
102
103 return true;
104 }
static getPortfoliosOfUser(int $a_user_id)
Get portfolios of user.

References $user_id, ilObjPortfolio\getPortfoliosOfUser(), and ILIAS\Repository\profile().

+ Here is the call graph for this function:

◆ getCaption()

ILIAS\User\Badges\ProfileBadge::getCaption ( )

Implements ilBadgeType.

Definition at line 45 of file ProfileBadge.php.

45 : string
46 {
47 return $this->lng->txt('badge_user_profile');
48 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getConfigGUIInstance()

ILIAS\User\Badges\ProfileBadge::getConfigGUIInstance ( )

Get GUI config instance.

Implements ilBadgeType.

Definition at line 60 of file ProfileBadge.php.

61 {
62 return new ProfileBadgeGUI(
63 $this->lng,
64 $this->request
65 );
66 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ILIAS\User\Badges\ProfileBadge::getId ( )

Get typ id (unique for component)

Implements ilBadgeType.

Definition at line 40 of file ProfileBadge.php.

40 : string
41 {
42 return 'profile';
43 }

◆ getValidObjectTypes()

ILIAS\User\Badges\ProfileBadge::getValidObjectTypes ( )

Get valid (repository) "parent" object types.

Returns
string[]

Implements ilBadgeType.

Definition at line 55 of file ProfileBadge.php.

55 : array // Missing array type.
56 {
57 return ['bdga'];
58 }

◆ isSingleton()

ILIAS\User\Badges\ProfileBadge::isSingleton ( )

Can only be created once?

Implements ilBadgeType.

Definition at line 50 of file ProfileBadge.php.

50 : bool
51 {
52 return false;
53 }

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