ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilias,$ilUser;
47
48 parent::__construct();
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)
$ilUser
Definition: imgupload.php:18

References $ilias, and $ilUser.

Member Function Documentation

◆ __addElement()

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

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

290 {
291 if ($this->canExport($tagname, $settingsname)) {
292 if (strlen($value) > 0 || $requiredTag || (is_array($attrs) && count($attrs) > 0)) {
293 $this->xmlElement($tagname, $attrs, $value);
294 }
295 }
296 }
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 280 of file class.ilUserXMLWriter.php.

281 {
282 if (is_array($value) && sizeof($value)) {
283 foreach ($value as $idx => $item) {
284 $this->__addElement($tagname, $item, $attrs, $settingsname, $requiredTag);
285 }
286 }
287 }
__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 112 of file class.ilUserXMLWriter.php.

113 {
114 $this->xmlEndTag('Users');
115 }
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 101 of file class.ilUserXMLWriter.php.

102 {
103 $this->xmlSetDtdDef("<!DOCTYPE Users PUBLIC \"-//ILIAS//DTD UserImport//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_user_5_1.dtd\">");
104 $this->xmlSetGenCmt("User of ilias system");
105 $this->xmlHeader();
106
107 $this->xmlStartTag('Users');
108
109 return true;
110 }
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 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 260 of file class.ilUserXMLWriter.php.

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

References $key, $row, 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 117 of file class.ilUserXMLWriter.php.

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

References $ilDB, $lng, $query, $row, $type, __addElement(), __addElementMulti(), __handlePreferences(), ilObjUser\_getPreferences(), canExport(), ilDBConstants\FETCHMODE_ASSOC, ilObjUserFolder\getExportSettings(), getPictureValue(), setSettings(), settings(), sprintf, 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 298 of file class.ilUserXMLWriter.php.

299 {
300 return !is_array($this->settings) ||
301 in_array(strtolower($tagname), $this->settings) !== false ||
302 in_array($settingsname, $this->settings) !== false;
303 }

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

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

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

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

References $fh, $ilDB, $r, ilDBConstants\FETCHMODE_ASSOC, ilUtil\getWebspaceDir(), and sprintf.

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

96 {
97 return $this->xmlDumpMem(false);
98 }
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 416 of file class.ilUserXMLWriter.php.

417 {
419 }
static getExportablePreferences()
return exportable preference keys as found in db

References $key, and 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 363 of file class.ilUserXMLWriter.php.

364 {
365 $this->attachPreferences = $attachPrefs;
366 }

◆ 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.

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

References $users.

◆ setSettings()

ilUserXMLWriter::setSettings (   $settings)

write access to settings

Parameters
array$settings

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

311 {
312 $this->settings = $settings;
313 }

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

74 {
75 if (!is_array($this->users)) {
76 return false;
77 }
78
79 $this->__buildHeader();
80
81
82 include_once("./Services/User/classes/class.ilUserDefinedFields.php");
84 $udf_data->addToXML($this);
85
86 foreach ($this->users as $user) {
87 $this->__handleUser($user);
88 }
89
90 $this->__buildFooter();
91
92 return true;
93 }
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: