ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilUserProfileBadge.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Badge/interfaces/interface.ilBadgeType.php";
5require_once "./Services/Badge/interfaces/interface.ilBadgeAuto.php";
6
16{
17 public function getId()
18 {
19 return "profile";
20 }
21
22 public function getCaption()
23 {
24 global $lng;
25 return $lng->txt("badge_user_profile");
26 }
27
28 public function isSingleton()
29 {
30 return false;
31 }
32
33 public function getValidObjectTypes()
34 {
35 return array("bdga");
36 }
37
38 public function getConfigGUIInstance()
39 {
40 include_once "Services/User/classes/Badges/class.ilUserProfileBadgeGUI.php";
41 return new ilUserProfileBadgeGUI();
42 }
43
44 public function evaluate($a_user_id, array $a_params, array $a_config)
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 {
54 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
55 $has_prtf = ilObjPortfolio::getDefaultPortfolio($a_user_id);
56 }
57 if(!$has_prtf)
58 {
59 // is profile public?
60 if(!in_array($user->getPref("public_profile"), array("y", "g")))
61 {
62 return false;
63 }
64 }
65
66 // use getter mapping from user profile
67 include_once("./Services/User/classes/class.ilUserProfile.php");
68 $up = new ilUserProfile();
69 $pfields = $up->getStandardFields();
70
71 // check for value AND publication status
72
73 foreach($a_config["profile"] as $field)
74 {
75 $field = substr($field, 4);
76
77 if(substr($field, 0, 4) == "udf_")
78 {
79 $udf_field_id = substr($field, 4);
80 if($user->getPref("public_udf_".$udf_field_id) != "y")
81 {
82 return false;
83 }
84 $udf = $user->getUserDefinedData();
85 if($udf["f_".$udf_field_id] == "")
86 {
87 return false;
88 }
89 }
90 // picture
91 else
92 {
93 if($user->getPref("public_".$field) != "y")
94 {
95 return false;
96 }
97 if($field == "upload")
98 {
99 if(!ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true))
100 {
101 return false;
102 }
103 }
104 // use profile mapping if possible
105 else
106 {
107 if(isset($pfields[$field]["method"]))
108 {
109 $m = $pfields[$field]["method"];
110 if(!$user->{$m}())
111 {
112 return false;
113 }
114 }
115 }
116 }
117 }
118
119 return true;
120 }
121}
An exception for terminatinating execution or to throw for unit testing.
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.
getValidObjectTypes()
Get valid (repository) "parent" object types.
evaluate($a_user_id, array $a_params, array $a_config)
Evaluate if given user has earned badge.
getId()
Get typ id (unique for component)
getConfigGUIInstance()
Get GUI config instance.
isSingleton()
Can only be created once?
Class ilUserProfile.
Manual Badge Auto.
Badge type interface.
global $lng
Definition: privfeed.php:17
global $ilSetting
Definition: privfeed.php:17