ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserXMLWriter Class Reference

XML writer class. More...

+ Inheritance diagram for ilUserXMLWriter:
+ Collaboration diagram for ilUserXMLWriter:

Public Member Functions

 ilUserXMLWriter ()
 constructor More...
 
 setAttachRoles ($value)
 
 setObjects (& $users)
 
 start ()
 
 getXML ()
 
 __buildHeader ()
 
 __buildFooter ()
 
 __handleUser ($row)
 
 __addElement ($tagname, $value, $attrs=null, $settingsname=null, $requiredTag=false)
 
 setSettings ($settings)
 write access to settings More...
 
 setAttachPreferences ($attachPrefs)
 if set to true, all preferences of a user will be set More...
 
- Public Member Functions inherited from ilXmlWriter
 ilXmlWriter ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 _xmlEscapeData ($data)
 Escapes reserved characters. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header public. More...
 
 xmlStartTag ($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=TRUE, $escape=TRUE)
 Writes data. More...
 
 xmlElement ($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=TRUE)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=TRUE)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr public More...
 

Static Public Member Functions

static getExportablePreferences ()
 return exportable preference keys as found in db More...
 
static isPrefExportable ($key)
 returns wether a key from db is exportable or not More...
 

Data Fields

 $ilias
 
 $xml
 
 $users
 
 $user_id = 0
 
 $attachRoles = false
 
 $attachPreferences = false
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Private Member Functions

 __handlePreferences ($prefs, $row)
 
 canExport ($tagname, $settingsname=null)
 
 getPictureValue ($usr_id)
 return array with baseencoded picture data as key value, encoding type as encoding, and image type as key type. More...
 

Private Attributes

 $settings
 

Static Private Attributes

static $exportablePrefs
 

Detailed Description

XML writer class.

Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilObjectXMLWriter.php,v 1.3 2005/11/04 12:50:24 smeyer Exp

Definition at line 20 of file class.ilUserXMLWriter.php.

Member Function Documentation

◆ __addElement()

ilUserXMLWriter::__addElement (   $tagname,
  $value,
  $attrs = null,
  $settingsname = null,
  $requiredTag = false 
)

Definition at line 310 of file class.ilUserXMLWriter.php.

References canExport(), and ilXmlWriter\xmlElement().

Referenced by __handleUser().

311  {
312  if ($this->canExport($tagname, $settingsname))
313  if (strlen($value) > 0 || $requiredTag || (is_array($attrs) && count($attrs) > 0))
314  $this->xmlElement ($tagname, $attrs, $value);
315 
316  }
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
canExport($tagname, $settingsname=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildFooter()

ilUserXMLWriter::__buildFooter ( )

Definition at line 114 of file class.ilUserXMLWriter.php.

References ilXmlWriter\xmlEndTag().

Referenced by start().

115  {
116  $this->xmlEndTag('Users');
117  }
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildHeader()

ilUserXMLWriter::__buildHeader ( )

Definition at line 103 of file class.ilUserXMLWriter.php.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), ilXmlWriter\xmlSetGenCmt(), and ilXmlWriter\xmlStartTag().

Referenced by start().

104  {
105  $this->xmlSetDtdDef("<!DOCTYPE Users PUBLIC \"-//ILIAS//DTD UserImport//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_user_4_0.dtd\">");
106  $this->xmlSetGenCmt("User of ilias system");
107  $this->xmlHeader();
108 
109  $this->xmlStartTag('Users');
110 
111  return true;
112  }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlHeader()
Writes xml header public.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __handlePreferences()

ilUserXMLWriter::__handlePreferences (   $prefs,
  $row 
)
private

Definition at line 289 of file class.ilUserXMLWriter.php.

References $row, isPrefExportable(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by __handleUser().

290  {
291 
292  include_once ("Services/Mail/classes/class.ilMailOptions.php");
293  $mailOptions = new ilMailOptions($row["usr_id"]);
294  $prefs["mail_incoming_type"] = $mailOptions->getIncomingType();
295  $prefs["mail_signature"] = $mailOptions->getSignature();
296  $prefs["mail_linebreak"] = $mailOptions->getLinebreak();
297  if (count($prefs))
298  {
299  $this->xmlStartTag("Prefs");
300  foreach ($prefs as $key => $value)
301  {
303  $this->xmlElement("Pref", array("key" => $key), $value);
304  }
305  $this->xmlEndTag("Prefs");
306  }
307  }
Class UserMail this class handles user mails.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
static isPrefExportable($key)
returns wether a key from db is exportable or not
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __handleUser()

ilUserXMLWriter::__handleUser (   $row)

only export one password

Definition at line 119 of file class.ilUserXMLWriter.php.

References $lng, $query, $row, __addElement(), __handlePreferences(), ilObjUser\_getPreferences(), canExport(), DB_FETCHMODE_ASSOC, ilObjUserFolder\getExportSettings(), getPictureValue(), setSettings(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

120  {
121  global $ilDB,$lng;
122  if (!is_array ($this->settings)) {
123  include_once ('./Services/User/classes/class.ilObjUserFolder.php');
125  }
126 
127  $prefs = ilObjUser::_getPreferences($row["usr_id"]);
128 
129  if (strlen($row["language"]) == 0)
130  {
131  $row["language"] = $lng->getDefaultLanguage();
132 
133  }
134 
135  $attrs = array (
136  'Id' => "il_".IL_INST_ID."_usr_".$row["usr_id"],
137  'Language' => $row["language"],
138  'Action' => "Update"
139  );
140 
141  $this->xmlStartTag("User", $attrs);
142 
143  $this->xmlElement("Login", null, $row["login"]);
144 
145  if ($this->attachRoles == TRUE)
146  {
147  include_once './Services/AccessControl/classes/class.ilObjRole.php';
148 
149  $query = sprintf("SELECT object_data.title, object_data.description, rbac_fa.* ".
150  "FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.usr_id = %s ".
151  "AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id",
152  $ilDB->quote($row["usr_id"],'integer')
153  );
154  $rbacresult = $ilDB->query($query);
155 
156  while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC))
157  {
158  if ($rbacrow["assign"] != "y")
159  continue;
160 
161  $type = "";
162 
163  if ($rbacrow["parent"] == ROLE_FOLDER_ID)
164  {
165  $type = "Global";
166  }
167  else
168  {
169  $type = "Local";
170  }
171  if (strlen($type))
172  {
173  $this->xmlElement("Role",
174  array ("Id" =>
175  "il_".IL_INST_ID."_role_".$rbacrow["rol_id"], "Type" => $type),
176  $rbacrow["title"]);
177  }
178 
179  }
180  }
181 
185  $i2passwd = FALSE;
186  if ($this->canExport("i2passwd","i2passwd") && strlen($row["i2passwd"]) > 0)
187  {
188  $i2passwd = TRUE;
189  $this->__addElement("Password",$row["i2passwd"], array("Type" => "ILIAS2"),"i2passwd");
190  }
191  if (!$i2passwd && strlen($row["passwd"]) > 0)
192  {
193  $this->__addElement("Password",$row["passwd"], array("Type" => "ILIAS3"),"passwd");
194  }
195 
196 
197  $this->__addElement ("Firstname", $row["firstname"]);
198  $this->__addElement ("Lastname", $row["lastname"]);
199  $this->__addElement ("Title", $row["title"]);
200 
201  if ($this->canExport("PersonalPicture", "upload"))
202  {
203  $imageData = $this->getPictureValue($row["usr_id"]);
204  if ($imageData)
205  {
206  $value = array_shift($imageData); //$imageData["value"];
207  $this->__addElement ("PersonalPicture", $value, $imageData, "upload");
208  }
209  }
210 
211 
212  $this->__addElement ("Gender", $row["gender"]);
213  $this->__addElement ("Email", $row["email"]);
214  $this->__addElement ("Birthday", $row["birthday"]);
215  $this->__addElement ("Institution", $row["institution"]);
216  $this->__addElement ("Street", $row["street"]);
217  $this->__addElement ("City", $row["city"]);
218  $this->__addElement ("PostalCode", $row["zipcode"], null, "zipcode");
219  $this->__addElement ("Country", $row["country"]);
220  $this->__addElement ("PhoneOffice", $row["phone_office"], null, "phone_office");
221  $this->__addElement ("PhoneHome", $row["phone_home"], null, "phone_home");
222  $this->__addElement ("PhoneMobile", $row["phone_mobile"], null, "phone_mobile");
223  $this->__addElement ("Fax", $row["fax"]);
224  $this->__addElement ("Hobby", $row["hobby"]);
225  $this->__addElement ("Department", $row["department"]);
226  $this->__addElement ("Comment", $row["referral_comment"], null, "referral_comment");
227  $this->__addElement ("Matriculation", $row["matriculation"]);
228  $this->__addElement ("Active", $row["active"] ? "true":"false" );
229  $this->__addElement ("ClientIP", $row["client_ip"], null, "client_ip");
230  $this->__addElement ("TimeLimitOwner", $row["time_limit_owner"], null, "time_limit_owner");
231  $this->__addElement ("TimeLimitUnlimited", $row["time_limit_unlimited"], null, "time_limit_unlimited");
232  $this->__addElement ("TimeLimitFrom", $row["time_limit_from"], null, "time_limit_from");
233  $this->__addElement ("TimeLimitUntil", $row["time_limit_until"], null, "time_limit_until");
234  $this->__addElement ("TimeLimitMessage", $row["time_limit_message"], null, "time_limit_message");
235  $this->__addElement ("ApproveDate", $row["approve_date"], null, "approve_date");
236  $this->__addElement ("AgreeDate", $row["agree_date"], null, "agree_date");
237 
238  if ((int) $row["ilinc_id"] !=0) {
239  $this->__addElement ("iLincID", $row["ilinc_id"], "ilinc_id");
240  $this->__addElement ("iLincUser", $row["ilinc_user"], "ilinc_user");
241  $this->__addElement ("iLincPasswd", $row["ilinc_passwd"], "ilinc_passwd");
242  }
243 
244  if (strlen($row["auth_mode"])>0)
245  {
246  $this->__addElement ("AuthMode", null, array ("type" => $row["auth_mode"]),"auth_mode", true);
247  }
248 
249  if (strlen($row["ext_account"])>0)
250  {
251  $this->__addElement ("ExternalAccount", $row["ext_account"], null, "ext_account", true);
252  }
253 
254  if ($this->canExport("Look","skin_style"))
255  {
256  $this->__addElement("Look", null, array(
257  "Skin" => $prefs["skin"], "Style" => $prefs["style"]
258  ), "skin_style", true);
259 
260  }
261 
262 
263  $this->__addElement ("LastUpdate", $row["last_update"], null, "last_update");
264  $this->__addElement ("LastLogin", $row["last_login"], null, "last_login");
265 
266  include_once ("./Services/User/classes/class.ilUserDefinedData.php");
267  $udf_data = new ilUserDefinedData($row['usr_id']);
268  $udf_data->addToXML($this, $this->settings);
269 
270  $msgrs = array ("skype" => "im_skype", "yahoo" => "im_yahoo", "msn"=>"im_msn", "aim"=>"im_aim", "icq"=>"im_icq", "delicious" => "delicious", "external" => "ext_account", "jabber" => "im_jabber", "voip" => "im_voip");
271  foreach ($msgrs as $type => $fieldname) {
272  $this->__addElement("AccountInfo", $row[$fieldname], array("Type" => $type), "instant_messengers");
273  }
274 
275  $this->__addElement("GMapsInfo", null, array (
276  "longitude" => $row["longitude"],
277  "latitude" => $row["latitude"],
278  "zoom" => $row["loc_zoom"]));
279 
280  $this->__addElement("Feedhash", $row["feed_hash"]);
281 
282  if ($this->attachPreferences || $this->canExport("prefs", "preferences"))
283  $this->__handlePreferences ($prefs, $row);
284 
285  $this->xmlEndTag('User');
286  }
getPictureValue($usr_id)
return array with baseencoded picture data as key value, encoding type as encoding, and image type as key type.
Class ilUserDefinedData.
__handlePreferences($prefs, $row)
__addElement($tagname, $value, $attrs=null, $settingsname=null, $requiredTag=false)
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
setSettings($settings)
write access to settings
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
canExport($tagname, $settingsname=null)
xmlEndTag($tag)
Writes an endtag.
static getExportSettings()
getExport Settings
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
global $lng
Definition: privfeed.php:40
static _getPreferences($user_id)
get preferences for user
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canExport()

ilUserXMLWriter::canExport (   $tagname,
  $settingsname = null 
)
private

Definition at line 318 of file class.ilUserXMLWriter.php.

Referenced by __addElement(), and __handleUser().

319  {
320  return !is_array($this->settings) ||
321  in_array(strtolower($tagname), $this->settings) !== FALSE ||
322  in_array($settingsname, $this->settings) !== FALSE;
323  }
+ Here is the caller graph for this function:

◆ getExportablePreferences()

static ilUserXMLWriter::getExportablePreferences ( )
static

return exportable preference keys as found in db

Returns
array of string

Definition at line 392 of file class.ilUserXMLWriter.php.

Referenced by isPrefExportable().

392  {
393  return array (
394  'hits_per_page',
395  'public_city',
396  'public_country',
397  'public_department',
398  'public_email',
399  'public_fax',
400  'public_hobby',
401  'public_institution',
402  'public_matriculation',
403  'public_phone',
404  'public_phone_home',
405  'public_phone_mobile',
406  'public_phone_office',
407  'public_profile',
408  'public_street',
409  'public_upload',
410  'public_zip',
411  'send_info_mails',
412  'show_users_online',
413  'hide_own_online_status',
414  'user_tz',
415  'weekstart',
416  'mail_incoming_type',
417  'mail_signature',
418  'mail_linebreak'
419  );
420  }
+ Here is the caller graph for this function:

◆ getPictureValue()

ilUserXMLWriter::getPictureValue (   $usr_id)
private

return array with baseencoded picture data as key value, encoding type as encoding, and image type as key type.

Parameters
int$usr_id

Definition at line 339 of file class.ilUserXMLWriter.php.

References $r, $usr_id, DB_FETCHMODE_ASSOC, and ilUtil\getWebspaceDir().

Referenced by __handleUser().

339  {
340  global $ilDB;
341  // personal picture
342  $q = sprintf("SELECT value FROM usr_pref WHERE usr_id = %s AND keyword = %s",
343  $ilDB->quote($usr_id, "integer"), $ilDB->quote('profile_image', "text"));
344  $r = $ilDB->query($q);
345  if ($ilDB->numRows($r) == 1)
346  {
347  $personal_picture_data = $r->fetchRow(DB_FETCHMODE_ASSOC);
348  $personal_picture = $personal_picture_data["value"];
349  $webspace_dir = ilUtil::getWebspaceDir();
350  $image_file = $webspace_dir."/usr_images/".$personal_picture;
351  if (@is_file($image_file))
352  {
353  $fh = fopen($image_file, "rb");
354  if ($fh)
355  {
356  $image_data = fread($fh, filesize($image_file));
357  fclose($fh);
358  $base64 = base64_encode($image_data);
359  $imagetype = "image/jpeg";
360  if (preg_match("/.*\.(png|gif)$/", $personal_picture, $matches))
361  {
362  $imagetype = "image/".$matches[1];
363  }
364  return array (
365  "value" => $base64,
366  "encoding" => "Base64",
367  "imagetype" => $imagetype
368  );
369  }
370  }
371  }
372  return false;
373  }
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
static getWebspaceDir($mode="filesystem")
get webspace directory
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilUserXMLWriter::getXML ( )

Definition at line 97 of file class.ilUserXMLWriter.php.

References ilXmlWriter\xmlDumpMem().

98  {
99  return $this->xmlDumpMem(FALSE);
100  }
xmlDumpMem($format=TRUE)
Returns xml document from memory.
+ Here is the call graph for this function:

◆ ilUserXMLWriter()

ilUserXMLWriter::ilUserXMLWriter ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding public

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

References $ilias, and $ilUser.

45  {
46  global $ilias,$ilUser;
47 
48  parent::ilXmlWriter();
49 
50  $this->ilias =& $ilias;
51  $this->user_id = $ilUser->getId();
52  $this->attachRoles = false;
53 
54 /* $this->exportablePrefs = array(
55  "priv_feed_pass", "language", "style", "skin", 'ilPageEditor_HTMLMode',
56  'ilPageEditor_JavaScript', 'ilPageEditor_MediaMode', 'tst_javascript',
57  'tst_lastquestiontype', 'tst_multiline_answers', 'tst_use_previous_answers',
58  'graphicalAnswerSetting', "weekstart"
59  );*/
60  }
redirection script todo: (a better solution should control the processing via a xml file) ...
global $ilUser
Definition: imgupload.php:15

◆ isPrefExportable()

static ilUserXMLWriter::isPrefExportable (   $key)
static

returns wether a key from db is exportable or not

Parameters
string$key
Returns
boolean

Definition at line 428 of file class.ilUserXMLWriter.php.

References getExportablePreferences().

Referenced by __handlePreferences(), ilUserImportParser\importEndTag(), and ilUserImportParser\verifyPref().

428  {
429  return in_array($key, ilUserXMLWriter::getExportablePreferences());
430  }
static getExportablePreferences()
return exportable preference keys as found in db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttachPreferences()

ilUserXMLWriter::setAttachPreferences (   $attachPrefs)

if set to true, all preferences of a user will be set

Parameters
bool$attachPrefs

Definition at line 382 of file class.ilUserXMLWriter.php.

383  {
384  $this->attachPreferences = $attachPrefs;
385  }

◆ setAttachRoles()

ilUserXMLWriter::setAttachRoles (   $value)

Definition at line 62 of file class.ilUserXMLWriter.php.

63  {
64  $this->attachRoles = $value == 1? true : false;
65  }

◆ setObjects()

ilUserXMLWriter::setObjects ( $users)

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

References $users.

68  {
69  $this->users = & $users;
70  }

◆ setSettings()

ilUserXMLWriter::setSettings (   $settings)

write access to settings

Parameters
array$settings

Definition at line 330 of file class.ilUserXMLWriter.php.

References $settings.

Referenced by __handleUser().

330  {
331  $this->settings = $settings;
332  }
+ Here is the caller graph for this function:

◆ start()

ilUserXMLWriter::start ( )

Definition at line 73 of file class.ilUserXMLWriter.php.

References __buildFooter(), __buildHeader(), __handleUser(), and ilUserDefinedFields\_getInstance().

74  {
75  if (!is_array($this->users))
76  return false;
77 
78  $this->__buildHeader();
79 
80 
81  include_once ("./Services/User/classes/class.ilUserDefinedFields.php");
82  $udf_data = & ilUserDefinedFields::_getInstance();
83  $udf_data->addToXML($this);
84 
85  foreach ($this->users as $user)
86  {
87 
88  $this->__handleUser ($user);
89 
90  }
91 
92  $this->__buildFooter();
93 
94  return true;
95  }
static _getInstance()
Get instance.
+ Here is the call graph for this function:

Field Documentation

◆ $attachPreferences

ilUserXMLWriter::$attachPreferences = false

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

◆ $attachRoles

ilUserXMLWriter::$attachRoles = false

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

◆ $exportablePrefs

ilUserXMLWriter::$exportablePrefs
staticprivate

Definition at line 28 of file class.ilUserXMLWriter.php.

◆ $ilias

ilUserXMLWriter::$ilias

Definition at line 22 of file class.ilUserXMLWriter.php.

Referenced by ilUserXMLWriter().

◆ $settings

ilUserXMLWriter::$settings
private

Definition at line 35 of file class.ilUserXMLWriter.php.

Referenced by setSettings().

◆ $user_id

ilUserXMLWriter::$user_id = 0

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

◆ $users

ilUserXMLWriter::$users

Definition at line 24 of file class.ilUserXMLWriter.php.

Referenced by setObjects().

◆ $xml

ilUserXMLWriter::$xml

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


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