ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilUserXMLWriter Class Reference

XML writer class. More...

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

Public Member Functions

 __construct ()
 constructor More...
 
 setAttachRoles ($value)
 
 setObjects (&$users)
 
 start ()
 
 getXML ()
 
 __buildHeader ()
 
 __buildFooter ()
 
 __handleUser ($row)
 
 __addElementMulti ($tagname, $value, $attrs=null, $settingsname=null, $requiredTag=false)
 
 __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
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. 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 @access 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 @access 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...
 
- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. 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.

Constructor & Destructor Documentation

◆ __construct()

ilUserXMLWriter::__construct ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding @access public

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

45 {
46 global $DIC;
47
48 $ilias = $DIC['ilias'];
49 $ilUser = $DIC['ilUser'];
50
52
53 $this->ilias = $ilias;
54 $this->user_id = $ilUser->getId();
55 $this->attachRoles = false;
56
57 /* $this->exportablePrefs = array(
58 "priv_feed_pass", "language", "style", "skin", 'ilPageEditor_HTMLMode',
59 'ilPageEditor_JavaScript', 'ilPageEditor_MediaMode', 'tst_javascript',
60 'tst_lastquestiontype', 'tst_multiline_answers', 'tst_use_previous_answers',
61 'graphicalAnswerSetting', "weekstart"
62 );*/
63 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $ilias, $ilUser, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ __addElement()

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

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

296 {
297 if ($this->canExport($tagname, $settingsname)) {
298 if (strlen($value) > 0 || $requiredTag || (is_array($attrs) && count($attrs) > 0)) {
299 $this->xmlElement($tagname, $attrs, $value);
300 }
301 }
302 }
canExport($tagname, $settingsname=null)
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

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

Referenced by __addElementMulti(), and __handleUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __addElementMulti()

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

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

287 {
288 if (is_array($value) && sizeof($value)) {
289 foreach ($value as $idx => $item) {
290 $this->__addElement($tagname, $item, $attrs, $settingsname, $requiredTag);
291 }
292 }
293 }
__addElement($tagname, $value, $attrs=null, $settingsname=null, $requiredTag=false)

References __addElement().

Referenced by __handleUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildFooter()

ilUserXMLWriter::__buildFooter ( )

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

116 {
117 $this->xmlEndTag('Users');
118 }
xmlEndTag($tag)
Writes an endtag.

References ilXmlWriter\xmlEndTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildHeader()

ilUserXMLWriter::__buildHeader ( )

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

105 {
106 $this->xmlSetDtdDef("<!DOCTYPE Users PUBLIC \"-//ILIAS//DTD UserImport//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_user_5_1.dtd\">");
107 $this->xmlSetGenCmt("User of ilias system");
108 $this->xmlHeader();
109
110 $this->xmlStartTag('Users');
111
112 return true;
113 }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlHeader()
Writes xml header @access public.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

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

Referenced by start().

+ 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 266 of file class.ilUserXMLWriter.php.

267 {
268 //todo nadia: test mail_address_option
269 include_once("Services/Mail/classes/class.ilMailOptions.php");
270 $mailOptions = new ilMailOptions($row["usr_id"]);
271 $prefs["mail_incoming_type"] = $mailOptions->getIncomingType();
272 $prefs["mail_address_option"] = $mailOptions->getEmailAddressMode();
273 $prefs["mail_signature"] = $mailOptions->getSignature();
274 $prefs["mail_linebreak"] = $mailOptions->getLinebreak();
275 if (count($prefs)) {
276 $this->xmlStartTag("Prefs");
277 foreach ($prefs as $key => $value) {
279 $this->xmlElement("Pref", array("key" => $key), $value);
280 }
281 }
282 $this->xmlEndTag("Prefs");
283 }
284 }
Class ilMailOptions this class handles user mails.
static isPrefExportable($key)
returns wether a key from db is exportable or not

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

Referenced by __handleUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __handleUser()

ilUserXMLWriter::__handleUser (   $row)

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

121 {
122 global $DIC;
123
124 $ilDB = $DIC['ilDB'];
125 $lng = $DIC['lng'];
126 if (!is_array($this->settings)) {
127 include_once('./Services/User/classes/class.ilObjUserFolder.php');
129 }
130
131 $prefs = ilObjUser::_getPreferences($row["usr_id"]);
132
133 if (strlen($row["language"]) == 0) {
134 $row["language"] = $lng->getDefaultLanguage();
135 }
136
137 $attrs = array(
138 'Id' => "il_" . IL_INST_ID . "_usr_" . $row["usr_id"],
139 'Language' => $row["language"],
140 'Action' => "Update"
141 );
142
143 $this->xmlStartTag("User", $attrs);
144
145 $this->xmlElement("Login", null, $row["login"]);
146
147 if ($this->attachRoles == true) {
148 include_once './Services/AccessControl/classes/class.ilObjRole.php';
149
150 $query = sprintf(
151 "SELECT object_data.title, object_data.description, rbac_fa.* " .
152 "FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.usr_id = %s " .
153 "AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id",
154 $ilDB->quote($row["usr_id"], 'integer')
155 );
156 $rbacresult = $ilDB->query($query);
157
158 while ($rbacrow = $rbacresult->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
159 if ($rbacrow["assign"] != "y") {
160 continue;
161 }
162
163 $type = "";
164
165 if ($rbacrow["parent"] == ROLE_FOLDER_ID) {
166 $type = "Global";
167 } else {
168 $type = "Local";
169 }
170 if (strlen($type)) {
171 $this->xmlElement(
172 "Role",
173 array("Id" =>
174 "il_" . IL_INST_ID . "_role_" . $rbacrow["rol_id"], "Type" => $type),
175 $rbacrow["title"]
176 );
177 }
178 }
179 }
180
181 $this->__addElement("Firstname", $row["firstname"]);
182 $this->__addElement("Lastname", $row["lastname"]);
183 $this->__addElement("Title", $row["title"]);
184
185 if ($this->canExport("PersonalPicture", "upload")) {
186 $imageData = $this->getPictureValue($row["usr_id"]);
187 if ($imageData) {
188 $value = array_shift($imageData); //$imageData["value"];
189 $this->__addElement("PersonalPicture", $value, $imageData, "upload");
190 }
191 }
192
193
194 $this->__addElement("Gender", $row["gender"]);
195 $this->__addElement("Email", $row["email"]);
196 $this->__addElement("SecondEmail", $row["second_email"], null, "second_email");
197 $this->__addElement("Birthday", $row["birthday"]);
198 $this->__addElement("Institution", $row["institution"]);
199 $this->__addElement("Street", $row["street"]);
200 $this->__addElement("City", $row["city"]);
201 $this->__addElement("PostalCode", $row["zipcode"], null, "zipcode");
202 $this->__addElement("Country", $row["country"]);
203 $this->__addElement("SelCountry", $row["sel_country"], null, "sel_country");
204 $this->__addElement("PhoneOffice", $row["phone_office"], null, "phone_office");
205 $this->__addElement("PhoneHome", $row["phone_home"], null, "phone_home");
206 $this->__addElement("PhoneMobile", $row["phone_mobile"], null, "phone_mobile");
207 $this->__addElement("Fax", $row["fax"]);
208 $this->__addElement("Hobby", $row["hobby"]);
209
210 $this->__addElementMulti("GeneralInterest", $row["interests_general"], null, "interests_general");
211 $this->__addElementMulti("OfferingHelp", $row["interests_help_offered"], null, "interests_help_offered");
212 $this->__addElementMulti("LookingForHelp", $row["interests_help_looking"], null, "interests_help_looking");
213
214 $this->__addElement("Department", $row["department"]);
215 $this->__addElement("Comment", $row["referral_comment"], null, "referral_comment");
216 $this->__addElement("Matriculation", $row["matriculation"]);
217 $this->__addElement("Active", $row["active"] ? "true":"false");
218 $this->__addElement("ClientIP", $row["client_ip"], null, "client_ip");
219 $this->__addElement("TimeLimitOwner", $row["time_limit_owner"], null, "time_limit_owner");
220 $this->__addElement("TimeLimitUnlimited", $row["time_limit_unlimited"], null, "time_limit_unlimited");
221 $this->__addElement("TimeLimitFrom", $row["time_limit_from"], null, "time_limit_from");
222 $this->__addElement("TimeLimitUntil", $row["time_limit_until"], null, "time_limit_until");
223 $this->__addElement("TimeLimitMessage", $row["time_limit_message"], null, "time_limit_message");
224 $this->__addElement("ApproveDate", $row["approve_date"], null, "approve_date");
225 $this->__addElement("AgreeDate", $row["agree_date"], null, "agree_date");
226
227 if (strlen($row["auth_mode"]) > 0) {
228 $this->__addElement("AuthMode", null, array("type" => $row["auth_mode"]), "auth_mode", true);
229 }
230
231 if (strlen($row["ext_account"]) > 0) {
232 $this->__addElement("ExternalAccount", $row["ext_account"], null, "ext_account", true);
233 }
234
235 if ($this->canExport("Look", "skin_style")) {
236 $this->__addElement("Look", null, array(
237 "Skin" => $prefs["skin"], "Style" => $prefs["style"]
238 ), "skin_style", true);
239 }
240
241
242 $this->__addElement("LastUpdate", $row["last_update"], null, "last_update");
243 $this->__addElement("LastLogin", $row["last_login"], null, "last_login");
244
245 include_once("./Services/User/classes/class.ilUserDefinedData.php");
246 $udf_data = new ilUserDefinedData($row['usr_id']);
247 $udf_data->addToXML($this, $this->settings);
248
249 $this->__addElement("AccountInfo", $row["ext_account"], array("Type" => "external"));
250
251 $this->__addElement("GMapsInfo", null, array(
252 "longitude" => $row["longitude"],
253 "latitude" => $row["latitude"],
254 "zoom" => $row["loc_zoom"]));
255
256 $this->__addElement("Feedhash", $row["feed_hash"]);
257
258 if ($this->attachPreferences || $this->canExport("prefs", "preferences")) {
259 $this->__handlePreferences($prefs, $row);
260 }
261
262 $this->xmlEndTag('User');
263 }
static getExportSettings()
getExport Settings
static _getPreferences($user_id)
get preferences for user
Class ilUserDefinedData.
setSettings($settings)
write access to settings
__handlePreferences($prefs, $row)
__addElementMulti($tagname, $value, $attrs=null, $settingsname=null, $requiredTag=false)
getPictureValue($usr_id)
return array with baseencoded picture data as key value, encoding type as encoding,...
$query
$type
$lng
settings()
Definition: settings.php:2
global $ilDB

References $DIC, $ilDB, $lng, $query, $type, __addElement(), __addElementMulti(), __handlePreferences(), ilObjUser\_getPreferences(), canExport(), ilDBConstants\FETCHMODE_ASSOC, ilObjUserFolder\getExportSettings(), getPictureValue(), setSettings(), settings(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ 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 304 of file class.ilUserXMLWriter.php.

305 {
306 return !is_array($this->settings) ||
307 in_array(strtolower($tagname), $this->settings) !== false ||
308 in_array($settingsname, $this->settings) !== false;
309 }

References settings().

Referenced by __addElement(), and __handleUser().

+ Here is the call graph for this function:
+ 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 381 of file class.ilUserXMLWriter.php.

382 {
383 return array(
384 'hits_per_page',
385 'public_city',
386 'public_country',
387 'public_department',
388 'public_email',
389 'public_second_email',
390 'public_fax',
391 'public_hobby',
392 'public_institution',
393 'public_matriculation',
394 'public_phone',
395 'public_phone_home',
396 'public_phone_mobile',
397 'public_phone_office',
398 'public_profile',
399 'public_street',
400 'public_upload',
401 'public_zip',
402 'send_info_mails',
403 /*'show_users_online',*/
404 'hide_own_online_status',
405 'bs_allow_to_contact_me',
406 'chat_osc_accept_msg',
407 'user_tz',
408 'weekstart',
409 'mail_incoming_type',
410 'mail_signature',
411 'mail_linebreak',
412 'public_interests_general',
413 'public_interests_help_offered',
414 'public_interests_help_looking'
415 );
416 }

Referenced by isPrefExportable().

+ 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 326 of file class.ilUserXMLWriter.php.

327 {
328 global $DIC;
329
330 $ilDB = $DIC['ilDB'];
331 // personal picture
332 $q = sprintf(
333 "SELECT value FROM usr_pref WHERE usr_id = %s AND keyword = %s",
334 $ilDB->quote($usr_id, "integer"),
335 $ilDB->quote('profile_image', "text")
336 );
337 $r = $ilDB->query($q);
338 if ($ilDB->numRows($r) == 1) {
339 $personal_picture_data = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
340 $personal_picture = $personal_picture_data["value"];
341 $webspace_dir = ilUtil::getWebspaceDir();
342 $image_file = $webspace_dir . "/usr_images/" . $personal_picture;
343 if (@is_file($image_file)) {
344 $fh = fopen($image_file, "rb");
345 if ($fh) {
346 $image_data = fread($fh, filesize($image_file));
347 fclose($fh);
348 $base64 = base64_encode($image_data);
349 $imagetype = "image/jpeg";
350 if (preg_match("/.*\.(png|gif)$/", $personal_picture, $matches)) {
351 $imagetype = "image/" . $matches[1];
352 }
353 return array(
354 "value" => $base64,
355 "encoding" => "Base64",
356 "imagetype" => $imagetype
357 );
358 }
359 }
360 }
361 return false;
362 }
static getWebspaceDir($mode="filesystem")
get webspace directory

References $DIC, $ilDB, ilDBConstants\FETCHMODE_ASSOC, and ilUtil\getWebspaceDir().

Referenced by __handleUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilUserXMLWriter::getXML ( )

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

99 {
100 return $this->xmlDumpMem(false);
101 }
xmlDumpMem($format=true)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ isPrefExportable()

static ilUserXMLWriter::isPrefExportable (   $key)
static

returns wether a key from db is exportable or not

Parameters
string$key
Returns
boolean

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

425 {
426 return in_array($key, ilUserXMLWriter::getExportablePreferences());
427 }
static getExportablePreferences()
return exportable preference keys as found in db

References getExportablePreferences().

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

+ 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 371 of file class.ilUserXMLWriter.php.

372 {
373 $this->attachPreferences = $attachPrefs;
374 }

◆ setAttachRoles()

ilUserXMLWriter::setAttachRoles (   $value)

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

66 {
67 $this->attachRoles = $value == 1? true : false;
68 }

◆ setObjects()

ilUserXMLWriter::setObjects ( $users)

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

71 {
72 $this->users = &$users;
73 }

References $users.

◆ setSettings()

ilUserXMLWriter::setSettings (   $settings)

write access to settings

Parameters
array$settings

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

317 {
318 $this->settings = $settings;
319 }

References $settings, and settings().

Referenced by __handleUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

ilUserXMLWriter::start ( )

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

77 {
78 if (!is_array($this->users)) {
79 return false;
80 }
81
82 $this->__buildHeader();
83
84
85 include_once("./Services/User/classes/class.ilUserDefinedFields.php");
87 $udf_data->addToXML($this);
88
89 foreach ($this->users as $user) {
90 $this->__handleUser($user);
91 }
92
93 $this->__buildFooter();
94
95 return true;
96 }
static _getInstance()
Get instance.

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

+ 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 __construct().

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