ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB, and __read().

19  {
20  global $ilDB;
21 
22  $this->db = $ilDB;
23  $this->usr_id = $a_usr_id;
24 
25  $this->__read();
26  }
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilUserDefinedData::__read ( )

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

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

Referenced by __construct().

219  {
220  $this->user_data = array();
221  $query = "SELECT * FROM udf_text " .
222  "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . "";
223  $res = $this->db->query($query);
224  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
225  $this->user_data["f_" . $row["field_id"]] = $row["value"];
226  }
227  $query = "SELECT * FROM udf_clob " .
228  "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . "";
229  $res = $this->db->query($query);
230  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
231  $this->user_data["f_" . $row["field_id"]] = $row["value"];
232  }
233  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ 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 200 of file class.ilUserDefinedData.php.

References ilUserDefinedFields\_getInstance(), and array.

Referenced by toXML().

201  {
202  include_once './Services/User/classes/class.ilUserDefinedFields.php';
204 
205  foreach ($udf_obj->getDefinitions() as $definition) {
206  if ($definition["export"] != false) {
207  $xml_writer->xmlElement(
208  'UserDefinedField',
209  array('Id' => $definition['il_id'],
210  'Name' => $definition['field_name']),
211  (string) $this->user_data['f_' . (int) $definition['field_id']]
212  );
213  }
214  }
215  }
static _getInstance()
Get instance.
Create styles array
The data for the language used.
+ 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 155 of file class.ilUserDefinedData.php.

References $ilDB.

Referenced by ilUserDefinedFields\delete().

156  {
157  global $ilDB;
158 
159  $ilDB->manipulate(
160  "DELETE FROM udf_text WHERE "
161  . " field_id = " . $ilDB->quote($a_field_id, "integer")
162  );
163  $ilDB->manipulate(
164  "DELETE FROM udf_clob WHERE "
165  . " field_id = " . $ilDB->quote($a_field_id, "integer")
166  );
167  }
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 136 of file class.ilUserDefinedData.php.

References $ilDB.

Referenced by ilObjUser\deleteUserDefinedFieldEntries().

137  {
138  global $ilDB;
139 
140  $ilDB->manipulate(
141  "DELETE FROM udf_text WHERE "
142  . " usr_id = " . $ilDB->quote($a_user_id, "integer")
143  );
144  $ilDB->manipulate(
145  "DELETE FROM udf_clob WHERE "
146  . " usr_id = " . $ilDB->quote($a_user_id, "integer")
147  );
148  }
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 175 of file class.ilUserDefinedData.php.

References $ilDB.

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

176  {
177  global $ilDB;
178 
179  $ilDB->manipulate(
180  "UPDATE udf_text SET value = " . $ilDB->quote("", "text") . " WHERE "
181  . " field_id = " . $ilDB->quote($a_field_id, "integer")
182  . " AND value = " . $ilDB->quote($a_value, "text")
183  );
184  }
global $ilDB
+ Here is the caller graph for this function:

◆ get()

ilUserDefinedData::get (   $a_field)

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

60  {
61  return isset($this->user_data[$a_field]) ? $this->user_data[$a_field] : '';
62  }

◆ getAll()

ilUserDefinedData::getAll ( )

Get all fields.

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

References $user_data.

68  {
69  return $this->user_data;
70  }

◆ getUserId()

ilUserDefinedData::getUserId ( )

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

References $usr_id.

Referenced by update().

51  {
52  return $this->usr_id;
53  }
+ 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 34 of file class.ilUserDefinedData.php.

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

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

35  {
36  global $ilDB;
37 
38  $query = "SELECT * FROM udf_text " .
39  "WHERE " . $ilDB->in('usr_id', $a_user_ids, false, 'integer') . ' ' .
40  'AND ' . $ilDB->in('field_id', $a_field_ids, false, 'integer');
41  $res = $ilDB->query($query);
42 
43  $udfd = array();
44  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
45  $udfd[$row['usr_id']][$row['field_id']] = $row['value'];
46  }
47  return $udfd;
48  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ set()

ilUserDefinedData::set (   $a_field,
  $a_value 
)

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

Referenced by ilUserImportParser\importEndTag().

56  {
57  $this->user_data[$a_field] = $a_value;
58  }
+ Here is the caller graph for this function:

◆ toXML()

ilUserDefinedData::toXML ( )

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

References addToXML().

187  {
188  include_once './Services/Xml/classes/class.ilXmlWriter.php';
189  $xml_writer = new ilXmlWriter();
190 
191  $this->addToXML($xml_writer);
192 
193  return $xml_writer->xmlDumpMem(false);
194  }
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 75 of file class.ilUserDefinedData.php.

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

76  {
77  global $ilDB;
78 
79  include_once './Services/User/classes/class.ilUserDefinedFields.php';
81 
82  $sql = '';
83  $field_def = array();
84  foreach ($udf_obj->getDefinitions() as $definition) {
85  // $field_def['f_'.$definition['field_id']] = array('text',$this->get($definition['field_id']));
86 
87  // $sql .= ("`".(int) $definition['field_id']."` = ".$this->db->quote($this->get($definition['field_id'])).", ");
88 
89  if ($definition["field_type"] == UDF_TYPE_WYSIWYG) {
90  $ilDB->replace(
91  "udf_clob",
92  array(
93  "usr_id" => array("integer", $this->getUserId()),
94  "field_id" => array("integer", $definition['field_id'])),
95  array(
96  "value" => array("clob", $this->get("f_" . $definition['field_id']))
97  )
98  );
99  } else {
100  $ilDB->replace(
101  "udf_text",
102  array(
103  "usr_id" => array("integer", $this->getUserId()),
104  "field_id" => array("integer", $definition['field_id'])),
105  array(
106  "value" => array("text", $this->get("f_" . $definition['field_id']))
107  )
108  );
109  }
110  }
111  /* if(!$field_def)
112  {
113  return true;
114  }
115 
116  $query = "SELECT usr_id FROM udf_data WHERE usr_id = ".$ilDB->quote($this->getUserId(),'integer');
117  $res = $ilDB->query($query);
118 
119  if($res->numRows())
120  {
121  $ilDB->update('udf_data',$field_def,array('usr_id' => array('integer',$this->getUserId())));
122  }
123  else
124  {
125  $field_def['usr_id'] = array('integer',$this->getUserId());
126  $ilDB->insert('udf_data',$field_def);
127  }*/
128  return true;
129  }
static _getInstance()
Get instance.
const UDF_TYPE_WYSIWYG
Create styles array
The data for the language used.
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: