ILIAS  release_8 Revision v8.24
ilUserDefinedData Class Reference

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

+ Collaboration diagram for ilUserDefinedData:

Public Member Functions

 __construct (int $a_usr_id)
 
 getUserId ()
 
 set (string $a_field, string $a_value)
 
 get (string $a_field)
 
 getAll ()
 
 update ()
 
 toXML ()
 
 addToXML (ilXmlWriter $xml_writer)
 add user defined field data to xml (using usr dtd) More...
 
 __read ()
 

Static Public Member Functions

static lookupData (array $a_user_ids, array $a_field_ids)
 Lookup data. More...
 
static deleteEntriesOfUser (int $a_user_id)
 
static deleteEntriesOfField (int $a_field_id)
 Delete data of particular field. More...
 
static deleteFieldValue (int $a_field_id, string $a_value)
 Delete data of particular value of a (selection) field. More...
 

Data Fields

ilDBInterface $db = null
 
array $user_data = array()
 
int $usr_id = null
 

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 ilUserDefinedData

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 23 of file class.ilUserDefinedData.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserDefinedData::__construct ( int  $a_usr_id)

Definition at line 29 of file class.ilUserDefinedData.php.

30 {
31 global $DIC;
32
33 $ilDB = $DIC['ilDB'];
34
35 $this->db = $ilDB;
36 $this->usr_id = $a_usr_id;
37
38 $this->__read();
39 }
global $DIC
Definition: feed.php:28

References $DIC, $ilDB, and __read().

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilUserDefinedData::__read ( )

Definition at line 207 of file class.ilUserDefinedData.php.

207 : void
208 {
209 $this->user_data = array();
210 $query = "SELECT * FROM udf_text " .
211 "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer');
212 $res = $this->db->query($query);
213 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
214 $this->user_data["f_" . $row["field_id"]] = $row["value"];
215 }
216 $query = "SELECT * FROM udf_clob " .
217 "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer');
218 $res = $this->db->query($query);
219 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
220 $this->user_data["f_" . $row["field_id"]] = $row["value"];
221 }
222 }
$res
Definition: ltiservices.php:69
$query

References $query, $res, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ addToXML()

ilUserDefinedData::addToXML ( ilXmlWriter  $xml_writer)

add user defined field data to xml (using usr dtd)

Definition at line 190 of file class.ilUserDefinedData.php.

190 : void
191 {
193
194 foreach ($udf_obj->getDefinitions() as $definition) {
195 if ($definition["export"] != false) {
196 $xml_writer->xmlElement(
197 'UserDefinedField',
198 array('Id' => $definition['il_id'],
199 'Name' => $definition['field_name']),
200 (string) ($this->user_data['f_' . (int) $definition['field_id']] ?? '')
201 );
202 }
203 }
204 }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

References ilUserDefinedFields\_getInstance(), and ilXmlWriter\xmlElement().

+ Here is the call graph for this function:

◆ deleteEntriesOfField()

static ilUserDefinedData::deleteEntriesOfField ( int  $a_field_id)
static

Delete data of particular field.

Definition at line 144 of file class.ilUserDefinedData.php.

144 : void
145 {
146 global $DIC;
147
148 $ilDB = $DIC['ilDB'];
149
150 $ilDB->manipulate(
151 "DELETE FROM udf_text WHERE "
152 . " field_id = " . $ilDB->quote($a_field_id, "integer")
153 );
154 $ilDB->manipulate(
155 "DELETE FROM udf_clob WHERE "
156 . " field_id = " . $ilDB->quote($a_field_id, "integer")
157 );
158 }

References $DIC, and $ilDB.

Referenced by ilUserDefinedFields\delete().

+ Here is the caller graph for this function:

◆ deleteEntriesOfUser()

static ilUserDefinedData::deleteEntriesOfUser ( int  $a_user_id)
static

Definition at line 125 of file class.ilUserDefinedData.php.

125 : void
126 {
127 global $DIC;
128
129 $ilDB = $DIC['ilDB'];
130
131 $ilDB->manipulate(
132 "DELETE FROM udf_text WHERE "
133 . " usr_id = " . $ilDB->quote($a_user_id, "integer")
134 );
135 $ilDB->manipulate(
136 "DELETE FROM udf_clob WHERE "
137 . " usr_id = " . $ilDB->quote($a_user_id, "integer")
138 );
139 }

References $DIC, and $ilDB.

Referenced by ilObjUser\deleteUserDefinedFieldEntries().

+ Here is the caller graph for this function:

◆ deleteFieldValue()

static ilUserDefinedData::deleteFieldValue ( int  $a_field_id,
string  $a_value 
)
static

Delete data of particular value of a (selection) field.

Definition at line 163 of file class.ilUserDefinedData.php.

166 : void {
167 global $DIC;
168
169 $ilDB = $DIC['ilDB'];
170
171 $ilDB->manipulate(
172 "UPDATE udf_text SET value = " . $ilDB->quote("", "text") . " WHERE "
173 . " field_id = " . $ilDB->quote($a_field_id, "integer")
174 . " AND value = " . $ilDB->quote($a_value, "text")
175 );
176 }

Referenced by ilCustomUserFieldsGUI\update().

+ Here is the caller graph for this function:

◆ get()

ilUserDefinedData::get ( string  $a_field)

Definition at line 82 of file class.ilUserDefinedData.php.

82 : string
83 {
84 return $this->user_data[$a_field] ?? '';
85 }

Referenced by ilMemberExport\addUserDefinedField().

+ Here is the caller graph for this function:

◆ getAll()

ilUserDefinedData::getAll ( )

Definition at line 87 of file class.ilUserDefinedData.php.

87 : array // Missing array type.
88 {
89 return $this->user_data;
90 }

References $user_data.

◆ getUserId()

ilUserDefinedData::getUserId ( )

Definition at line 72 of file class.ilUserDefinedData.php.

72 : int
73 {
74 return $this->usr_id;
75 }

References $usr_id.

Referenced by ilMemberExport\addUserDefinedField(), and update().

+ Here is the caller graph for this function:

◆ lookupData()

static ilUserDefinedData::lookupData ( array  $a_user_ids,
array  $a_field_ids 
)
static

Lookup data.

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

44 : array // Missing array type.
45 {
46 global $DIC;
47
48 $ilDB = $DIC['ilDB'];
49
50 $query = "SELECT * FROM udf_text " .
51 "WHERE " . $ilDB->in('usr_id', $a_user_ids, false, 'integer') . ' ' .
52 'AND ' . $ilDB->in('field_id', $a_field_ids, false, 'integer');
53 $res = $ilDB->query($query);
54
55 $udfd = array();
56 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
57 $udfd[$row['usr_id']][$row['field_id']] = $row['value'];
58 }
59
61 foreach ($def_helper->getActivePlugins() as $plugin) {
62 foreach ($plugin->lookupUserData($a_user_ids, $a_field_ids) as $user_id => $usr_data) {
63 foreach ($usr_data as $field_id => $value) {
64 $udfd[$user_id][$field_id] = $value;
65 }
66 }
67 }
68
69 return $udfd;
70 }

References $DIC, $ilDB, XapiProxy\$plugin, $query, $res, ilDBConstants\FETCHMODE_ASSOC, and ilCustomUserFieldsHelper\getInstance().

Referenced by ilCourseParticipantsTableGUI\parse(), ilGroupParticipantsTableGUI\parse(), ilLearningSequenceParticipantsTableGUI\parse(), ilRepositoryUserResultTableGUI\parseUserIds(), ilSubscriberTableGUI\readSubscriberData(), and ilWaitingListTableGUI\readUserData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

ilUserDefinedData::set ( string  $a_field,
string  $a_value 
)

Definition at line 77 of file class.ilUserDefinedData.php.

77 : void
78 {
79 $this->user_data[$a_field] = $a_value;
80 }

◆ toXML()

ilUserDefinedData::toXML ( )

Definition at line 178 of file class.ilUserDefinedData.php.

178 : string
179 {
180 $xml_writer = new ilXmlWriter();
181
182 $this->addToXML($xml_writer);
183
184 return $xml_writer->xmlDumpMem(false);
185 }
addToXML(ilXmlWriter $xml_writer)
add user defined field data to xml (using usr dtd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ update()

ilUserDefinedData::update ( )

Definition at line 92 of file class.ilUserDefinedData.php.

92 : void
93 {
94 global $DIC;
95
96 $ilDB = $DIC['ilDB'];
97
99
100 foreach ($udf_obj->getDefinitions() as $definition) {
101 if ($definition["field_type"] == UDF_TYPE_WYSIWYG) {
102 $ilDB->replace(
103 "udf_clob",
104 array(
105 "usr_id" => array("integer", $this->getUserId()),
106 "field_id" => array("integer", $definition['field_id'])),
107 array(
108 "value" => array("clob", $this->get("f_" . $definition['field_id']))
109 )
110 );
111 } else {
112 $ilDB->replace(
113 "udf_text",
114 array(
115 "usr_id" => array("integer", $this->getUserId()),
116 "field_id" => array("integer", $definition['field_id'])),
117 array(
118 "value" => array("text", $this->get("f_" . $definition['field_id']))
119 )
120 );
121 }
122 }
123 }
const UDF_TYPE_WYSIWYG

References $DIC, $ilDB, ilUserDefinedFields\_getInstance(), getUserId(), and UDF_TYPE_WYSIWYG.

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilUserDefinedData::$db = null

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

◆ $user_data

array ilUserDefinedData::$user_data = array()

Definition at line 26 of file class.ilUserDefinedData.php.

Referenced by getAll().

◆ $usr_id

int ilUserDefinedData::$usr_id = null

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

Referenced by getUserId().


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