ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilUserDefinedData Class Reference

Class ilUserDefinedData. More...

+ Collaboration diagram for ilUserDefinedData:

Public Member Functions

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

Static Public Member Functions

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

Data Fields

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

Detailed Description

Class ilUserDefinedData.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilUserDefinedData::__construct (   $a_usr_id)

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

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

19  {
20  global $DIC;
21 
22  $ilDB = $DIC['ilDB'];
23 
24  $this->db = $ilDB;
25  $this->usr_id = $a_usr_id;
26 
27  $this->__read();
28  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilUserDefinedData::__read ( )

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

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

Referenced by __construct().

242  {
243  $this->user_data = array();
244  $query = "SELECT * FROM udf_text " .
245  "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . "";
246  $res = $this->db->query($query);
247  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
248  $this->user_data["f_" . $row["field_id"]] = $row["value"];
249  }
250  $query = "SELECT * FROM udf_clob " .
251  "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . "";
252  $res = $this->db->query($query);
253  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
254  $this->user_data["f_" . $row["field_id"]] = $row["value"];
255  }
256  }
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the caller graph for this function:

◆ addToXML()

ilUserDefinedData::addToXML (   $xml_writer)

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

Parameters
ilXmlWriter$xml_writer

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

References ilUserDefinedFields\_getInstance().

Referenced by toXML().

224  {
225  include_once './Services/User/classes/class.ilUserDefinedFields.php';
226  $udf_obj = &ilUserDefinedFields::_getInstance();
227 
228  foreach ($udf_obj->getDefinitions() as $definition) {
229  if ($definition["export"] != false) {
230  $xml_writer->xmlElement(
231  'UserDefinedField',
232  array('Id' => $definition['il_id'],
233  'Name' => $definition['field_name']),
234  (string) $this->user_data['f_' . (int) $definition['field_id']]
235  );
236  }
237  }
238  }
static _getInstance()
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteEntriesOfField()

static ilUserDefinedData::deleteEntriesOfField (   $a_field_id)
static

Delete data of particular field.

Parameters
intfield id

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

References $DIC, and $ilDB.

Referenced by ilUserDefinedFields\delete().

175  {
176  global $DIC;
177 
178  $ilDB = $DIC['ilDB'];
179 
180  $ilDB->manipulate(
181  "DELETE FROM udf_text WHERE "
182  . " field_id = " . $ilDB->quote($a_field_id, "integer")
183  );
184  $ilDB->manipulate(
185  "DELETE FROM udf_clob WHERE "
186  . " field_id = " . $ilDB->quote($a_field_id, "integer")
187  );
188  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ deleteEntriesOfUser()

static ilUserDefinedData::deleteEntriesOfUser (   $a_user_id)
static

Delete data of user.

Parameters
intuser id

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

References $DIC, and $ilDB.

Referenced by ilObjUser\deleteUserDefinedFieldEntries().

154  {
155  global $DIC;
156 
157  $ilDB = $DIC['ilDB'];
158 
159  $ilDB->manipulate(
160  "DELETE FROM udf_text WHERE "
161  . " usr_id = " . $ilDB->quote($a_user_id, "integer")
162  );
163  $ilDB->manipulate(
164  "DELETE FROM udf_clob WHERE "
165  . " usr_id = " . $ilDB->quote($a_user_id, "integer")
166  );
167  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ deleteFieldValue()

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

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

Parameters
intfield id
stringvalue

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

References $DIC, and $ilDB.

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

197  {
198  global $DIC;
199 
200  $ilDB = $DIC['ilDB'];
201 
202  $ilDB->manipulate(
203  "UPDATE udf_text SET value = " . $ilDB->quote("", "text") . " WHERE "
204  . " field_id = " . $ilDB->quote($a_field_id, "integer")
205  . " AND value = " . $ilDB->quote($a_value, "text")
206  );
207  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ get()

ilUserDefinedData::get (   $a_field)

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

75  {
76  return isset($this->user_data[$a_field]) ? $this->user_data[$a_field] : '';
77  }

◆ getAll()

ilUserDefinedData::getAll ( )

Get all fields.

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

References $user_data.

83  {
84  return $this->user_data;
85  }

◆ getUserId()

ilUserDefinedData::getUserId ( )

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

References $usr_id.

Referenced by update().

66  {
67  return $this->usr_id;
68  }
+ Here is the caller graph for this function:

◆ lookupData()

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

Lookup data.

Parameters
array$a_user_ids
array$a_field_ids
Returns

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

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

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

37  {
38  global $DIC;
39 
40  $ilDB = $DIC['ilDB'];
41 
42  $query = "SELECT * FROM udf_text " .
43  "WHERE " . $ilDB->in('usr_id', $a_user_ids, false, 'integer') . ' ' .
44  'AND ' . $ilDB->in('field_id', $a_field_ids, false, 'integer');
45  $res = $ilDB->query($query);
46 
47  $udfd = array();
48  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
49  $udfd[$row['usr_id']][$row['field_id']] = $row['value'];
50  }
51 
52  include_once './Services/User/classes/class.ilCustomUserFieldsHelper.php';
54  foreach ($def_helper->getActivePlugins() as $plugin) {
55  foreach ($plugin->lookupUserData($a_user_ids, $a_field_ids) as $user_id => $usr_data) {
56  foreach ($usr_data as $field_id => $value) {
57  $udfd[$user_id][$field_id] = $value;
58  }
59  }
60  }
61 
62  return $udfd;
63  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

ilUserDefinedData::set (   $a_field,
  $a_value 
)

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

Referenced by ilUserImportParser\importEndTag().

71  {
72  $this->user_data[$a_field] = $a_value;
73  }
+ Here is the caller graph for this function:

◆ toXML()

ilUserDefinedData::toXML ( )

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

References addToXML().

210  {
211  include_once './Services/Xml/classes/class.ilXmlWriter.php';
212  $xml_writer = new ilXmlWriter();
213 
214  $this->addToXML($xml_writer);
215 
216  return $xml_writer->xmlDumpMem(false);
217  }
XML writer class.
addToXML($xml_writer)
add user defined field data to xml (using usr dtd)
+ Here is the call graph for this function:

◆ update()

ilUserDefinedData::update ( )

Update data.

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

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

91  {
92  global $DIC;
93 
94  $ilDB = $DIC['ilDB'];
95 
96  include_once './Services/User/classes/class.ilUserDefinedFields.php';
98 
99  $sql = '';
100  $field_def = array();
101  foreach ($udf_obj->getDefinitions() as $definition) {
102  // $field_def['f_'.$definition['field_id']] = array('text',$this->get($definition['field_id']));
103 
104  // $sql .= ("`".(int) $definition['field_id']."` = ".$this->db->quote($this->get($definition['field_id'])).", ");
105 
106  if ($definition["field_type"] == UDF_TYPE_WYSIWYG) {
107  $ilDB->replace(
108  "udf_clob",
109  array(
110  "usr_id" => array("integer", $this->getUserId()),
111  "field_id" => array("integer", $definition['field_id'])),
112  array(
113  "value" => array("clob", $this->get("f_" . $definition['field_id']))
114  )
115  );
116  } else {
117  $ilDB->replace(
118  "udf_text",
119  array(
120  "usr_id" => array("integer", $this->getUserId()),
121  "field_id" => array("integer", $definition['field_id'])),
122  array(
123  "value" => array("text", $this->get("f_" . $definition['field_id']))
124  )
125  );
126  }
127  }
128  /* if(!$field_def)
129  {
130  return true;
131  }
132 
133  $query = "SELECT usr_id FROM udf_data WHERE usr_id = ".$ilDB->quote($this->getUserId(),'integer');
134  $res = $ilDB->query($query);
135 
136  if($res->numRows())
137  {
138  $ilDB->update('udf_data',$field_def,array('usr_id' => array('integer',$this->getUserId())));
139  }
140  else
141  {
142  $field_def['usr_id'] = array('integer',$this->getUserId());
143  $ilDB->insert('udf_data',$field_def);
144  }*/
145  return true;
146  }
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
const UDF_TYPE_WYSIWYG
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilUserDefinedData::$db = null

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

◆ $user_data

ilUserDefinedData::$user_data = array()

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

Referenced by getAll().

◆ $usr_id

ilUserDefinedData::$usr_id = null

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

Referenced by getUserId().


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