ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 = []
 
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.

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

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: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilUserDefinedData::__read ( )

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

References $res, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by __construct().

213  : void
214  {
215  $this->user_data = [];
216  $query = "SELECT * FROM udf_text " .
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  $query = "SELECT * FROM udf_clob " .
223  "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer');
224  $res = $this->db->query($query);
225  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
226  $this->user_data["f_" . $row["field_id"]] = $row["value"];
227  }
228  }
$res
Definition: ltiservices.php:66
+ 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 196 of file class.ilUserDefinedData.php.

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

Referenced by toXML().

196  : void
197  {
199 
200  foreach ($udf_obj->getDefinitions() as $definition) {
201  if ($definition["export"] != false) {
202  $xml_writer->xmlElement(
203  'UserDefinedField',
204  ['Id' => $definition['il_id'],
205  'Name' => $definition['field_name']],
206  (string) ($this->user_data['f_' . (int) $definition['field_id']] ?? '')
207  );
208  }
209  }
210  }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteEntriesOfField()

static ilUserDefinedData::deleteEntriesOfField ( int  $a_field_id)
static

Delete data of particular field.

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

References $DIC, and $ilDB.

Referenced by ilUserDefinedFields\delete().

150  : void
151  {
152  global $DIC;
153 
154  $ilDB = $DIC['ilDB'];
155 
156  $ilDB->manipulate(
157  "DELETE FROM udf_text WHERE "
158  . " field_id = " . $ilDB->quote($a_field_id, "integer")
159  );
160  $ilDB->manipulate(
161  "DELETE FROM udf_clob WHERE "
162  . " field_id = " . $ilDB->quote($a_field_id, "integer")
163  );
164  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ deleteEntriesOfUser()

static ilUserDefinedData::deleteEntriesOfUser ( int  $a_user_id)
static

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

References $DIC, and $ilDB.

Referenced by ilObjUser\deleteUserDefinedFieldEntries().

131  : void
132  {
133  global $DIC;
134 
135  $ilDB = $DIC['ilDB'];
136 
137  $ilDB->manipulate(
138  "DELETE FROM udf_text WHERE "
139  . " usr_id = " . $ilDB->quote($a_user_id, "integer")
140  );
141  $ilDB->manipulate(
142  "DELETE FROM udf_clob WHERE "
143  . " usr_id = " . $ilDB->quote($a_user_id, "integer")
144  );
145  }
global $DIC
Definition: shib_login.php:22
+ 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 169 of file class.ilUserDefinedData.php.

References $DIC, and $ilDB.

Referenced by ilUserDefinedFields\deleteValue(), and ilCustomUserFieldsGUI\update().

172  : void {
173  global $DIC;
174 
175  $ilDB = $DIC['ilDB'];
176 
177  $ilDB->manipulate(
178  "UPDATE udf_text SET value = " . $ilDB->quote("", "text") . " WHERE "
179  . " field_id = " . $ilDB->quote($a_field_id, "integer")
180  . " AND value = " . $ilDB->quote($a_value, "text")
181  );
182  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ get()

ilUserDefinedData::get ( string  $a_field)

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

Referenced by ilMemberExport\addUserDefinedField().

82  : string
83  {
84  return $this->user_data[$a_field] ?? '';
85  }
+ Here is the caller graph for this function:

◆ getAll()

ilUserDefinedData::getAll ( )
Returns
array<string, string>

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

90  : array
91  {
92  return array_map(
93  static fn($value): string => $value ?? '',
94  $this->user_data
95  );
96  }

◆ getUserId()

ilUserDefinedData::getUserId ( )

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

References $usr_id.

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

72  : int
73  {
74  return $this->usr_id;
75  }
+ 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.

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

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

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 = [];
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  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ 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.

Referenced by ilUserImportParser\importEndTag().

77  : void
78  {
79  $this->user_data[$a_field] = $a_value;
80  }
+ Here is the caller graph for this function:

◆ toXML()

ilUserDefinedData::toXML ( )

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

References addToXML().

184  : string
185  {
186  $xml_writer = new ilXmlWriter();
187 
188  $this->addToXML($xml_writer);
189 
190  return $xml_writer->xmlDumpMem(false);
191  }
addToXML(ilXmlWriter $xml_writer)
add user defined field data to xml (using usr dtd)
+ Here is the call graph for this function:

◆ update()

ilUserDefinedData::update ( )

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

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

98  : void
99  {
100  global $DIC;
101 
102  $ilDB = $DIC['ilDB'];
103 
105 
106  foreach ($udf_obj->getDefinitions() as $definition) {
107  if ($definition["field_type"] == UDF_TYPE_WYSIWYG) {
108  $ilDB->replace(
109  "udf_clob",
110  [
111  "usr_id" => ["integer", $this->getUserId()],
112  "field_id" => ["integer", $definition['field_id']]],
113  [
114  "value" => ["clob", $this->get("f_" . $definition['field_id'])]
115  ]
116  );
117  } else {
118  $ilDB->replace(
119  "udf_text",
120  [
121  "usr_id" => ["integer", $this->getUserId()],
122  "field_id" => ["integer", $definition['field_id']]],
123  [
124  "value" => ["text", $this->get("f_" . $definition['field_id'])]
125  ]
126  );
127  }
128  }
129  }
global $DIC
Definition: shib_login.php:22
const 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 = []

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

◆ $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: