ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 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 46 of file class.ilUserProfileBadge.php.

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

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

+ 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.

23 {
24 global $DIC;
25
26 $lng = $DIC['lng'];
27 return $lng->txt("badge_user_profile");
28 }
$lng

References $DIC, and $lng.

◆ getConfigGUIInstance()

ilUserProfileBadge::getConfigGUIInstance ( )

Get GUI config instance.

Returns
ilBadgeTypeGUI|null

Implements ilBadgeType.

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

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

◆ 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 35 of file class.ilUserProfileBadge.php.

36 {
37 return array("bdga");
38 }

◆ isSingleton()

ilUserProfileBadge::isSingleton ( )

Can only be created once?

Returns
bool

Implements ilBadgeType.

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

31 {
32 return false;
33 }

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