ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 213 of file class.ilUserDefinedData.php.

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

Referenced by __construct().

214  {
215  $this->user_data = array();
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  {
221  $this->user_data["f_".$row["field_id"]] = $row["value"];
222  }
223  $query = "SELECT * FROM udf_clob ".
224  "WHERE usr_id = ".$this->db->quote($this->usr_id,'integer')."";
225  $res = $this->db->query($query);
226  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
227  {
228  $this->user_data["f_".$row["field_id"]] = $row["value"];
229  }
230  }
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 194 of file class.ilUserDefinedData.php.

References ilUserDefinedFields\_getInstance(), and array.

Referenced by toXML().

195  {
196  include_once './Services/User/classes/class.ilUserDefinedFields.php';
197  $udf_obj =& ilUserDefinedFields::_getInstance();
198 
199  foreach($udf_obj->getDefinitions() as $definition)
200  {
201  if ($definition["export"] != FALSE)
202  {
203  $xml_writer->xmlElement('UserDefinedField',
204  array('Id' => $definition['il_id'],
205  'Name' => $definition['field_name']),
206  (string) $this->user_data['f_'.(int) $definition['field_id']]);
207  }
208 
209  }
210  }
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 152 of file class.ilUserDefinedData.php.

References $ilDB.

Referenced by ilUserDefinedFields\delete().

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

References $ilDB.

Referenced by ilObjUser\deleteUserDefinedFieldEntries().

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

References $ilDB.

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

171  {
172  global $ilDB;
173 
174  $ilDB->manipulate("UPDATE udf_text SET value = ".$ilDB->quote("", "text")." WHERE "
175  ." field_id = ".$ilDB->quote($a_field_id, "integer")
176  ." AND value = ".$ilDB->quote($a_value, "text")
177  );
178  }
global $ilDB
+ Here is the caller graph for this function:

◆ get()

ilUserDefinedData::get (   $a_field)

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

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

◆ getAll()

ilUserDefinedData::getAll ( )

Get all fields.

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

References $user_data.

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

◆ getUserId()

ilUserDefinedData::getUserId ( )

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

References $usr_id.

Referenced by update().

52  {
53  return $this->usr_id;
54  }
+ 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  {
46  $udfd[$row['usr_id']][$row['field_id']] = $row['value'];
47  }
48  return $udfd;
49  }
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 56 of file class.ilUserDefinedData.php.

Referenced by ilUserImportParser\importEndTag().

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

◆ toXML()

ilUserDefinedData::toXML ( )

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

References addToXML().

181  {
182  include_once './Services/Xml/classes/class.ilXmlWriter.php';
183  $xml_writer = new ilXmlWriter();
184 
185  $this->addToXML ($xml_writer);
186 
187  return $xml_writer->xmlDumpMem(false);
188  }
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 76 of file class.ilUserDefinedData.php.

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

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