ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserXMLWriter Class Reference

XML writer class. More...

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

Public Member Functions

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

Static Public Member Functions

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

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.

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

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

{
if ($this->canExport($tagname, $settingsname))
if (strlen($value) > 0 || $requiredTag || (is_array($attrs) && count($attrs) > 0))
$this->xmlElement ($tagname, $attrs, $value);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserXMLWriter::__buildFooter ( )

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

References ilXmlWriter\xmlEndTag().

Referenced by start().

{
$this->xmlEndTag('Users');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserXMLWriter::__buildHeader ( )

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

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

Referenced by start().

{
$this->xmlSetDtdDef("<!DOCTYPE Users PUBLIC \"-//ILIAS//DTD UserImport//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_user_4_0.dtd\">");
$this->xmlSetGenCmt("User of ilias system");
$this->xmlHeader();
$this->xmlStartTag('Users');
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
include_once ("Services/Mail/classes/class.ilMailOptions.php");
$mailOptions = new ilMailOptions($row["usr_id"]);
$prefs["mail_incoming_type"] = $mailOptions->getIncomingType();
$prefs["mail_signature"] = $mailOptions->getSignature();
$prefs["mail_linebreak"] = $mailOptions->getLinebreak();
if (count($prefs))
{
$this->xmlStartTag("Prefs");
foreach ($prefs as $key => $value)
{
$this->xmlElement("Pref", array("key" => $key), $value);
}
$this->xmlEndTag("Prefs");
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
global $ilDB,$lng;
if (!is_array ($this->settings)) {
include_once ('./Services/User/classes/class.ilObjUserFolder.php');
}
$prefs = ilObjUser::_getPreferences($row["usr_id"]);
if (strlen($row["language"]) == 0)
{
$row["language"] = $lng->getDefaultLanguage();
}
$attrs = array (
'Id' => "il_".IL_INST_ID."_usr_".$row["usr_id"],
'Language' => $row["language"],
'Action' => "Update"
);
$this->xmlStartTag("User", $attrs);
$this->xmlElement("Login", null, $row["login"]);
if ($this->attachRoles == TRUE)
{
include_once './Services/AccessControl/classes/class.ilObjRole.php';
$query = sprintf("SELECT object_data.title, object_data.description, rbac_fa.* ".
"FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.usr_id = %s ".
"AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id",
$ilDB->quote($row["usr_id"],'integer')
);
$rbacresult = $ilDB->query($query);
while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC))
{
if ($rbacrow["assign"] != "y")
continue;
$type = "";
if ($rbacrow["parent"] == ROLE_FOLDER_ID)
{
$type = "Global";
}
else
{
$type = "Local";
}
if (strlen($type))
{
$this->xmlElement("Role",
array ("Id" =>
"il_".IL_INST_ID."_role_".$rbacrow["rol_id"], "Type" => $type),
$rbacrow["title"]);
}
}
}
$i2passwd = FALSE;
if ($this->canExport("i2passwd","i2passwd") && strlen($row["i2passwd"]) > 0)
{
$i2passwd = TRUE;
$this->__addElement("Password",$row["i2passwd"], array("Type" => "ILIAS2"),"i2passwd");
}
if (!$i2passwd && strlen($row["passwd"]) > 0)
{
$this->__addElement("Password",$row["passwd"], array("Type" => "ILIAS3"),"passwd");
}
$this->__addElement ("Firstname", $row["firstname"]);
$this->__addElement ("Lastname", $row["lastname"]);
$this->__addElement ("Title", $row["title"]);
if ($this->canExport("PersonalPicture", "upload"))
{
$imageData = $this->getPictureValue($row["usr_id"]);
if ($imageData)
{
$value = array_shift($imageData); //$imageData["value"];
$this->__addElement ("PersonalPicture", $value, $imageData, "upload");
}
}
$this->__addElement ("Gender", $row["gender"]);
$this->__addElement ("Email", $row["email"]);
$this->__addElement ("Birthday", $row["birthday"]);
$this->__addElement ("Institution", $row["institution"]);
$this->__addElement ("Street", $row["street"]);
$this->__addElement ("City", $row["city"]);
$this->__addElement ("PostalCode", $row["zipcode"], null, "zipcode");
$this->__addElement ("Country", $row["country"]);
$this->__addElement ("PhoneOffice", $row["phone_office"], null, "phone_office");
$this->__addElement ("PhoneHome", $row["phone_home"], null, "phone_home");
$this->__addElement ("PhoneMobile", $row["phone_mobile"], null, "phone_mobile");
$this->__addElement ("Fax", $row["fax"]);
$this->__addElement ("Hobby", $row["hobby"]);
$this->__addElement ("Department", $row["department"]);
$this->__addElement ("Comment", $row["referral_comment"], null, "referral_comment");
$this->__addElement ("Matriculation", $row["matriculation"]);
$this->__addElement ("Active", $row["active"] ? "true":"false" );
$this->__addElement ("ClientIP", $row["client_ip"], null, "client_ip");
$this->__addElement ("TimeLimitOwner", $row["time_limit_owner"], null, "time_limit_owner");
$this->__addElement ("TimeLimitUnlimited", $row["time_limit_unlimited"], null, "time_limit_unlimited");
$this->__addElement ("TimeLimitFrom", $row["time_limit_from"], null, "time_limit_from");
$this->__addElement ("TimeLimitUntil", $row["time_limit_until"], null, "time_limit_until");
$this->__addElement ("TimeLimitMessage", $row["time_limit_message"], null, "time_limit_message");
$this->__addElement ("ApproveDate", $row["approve_date"], null, "approve_date");
$this->__addElement ("AgreeDate", $row["agree_date"], null, "agree_date");
if ((int) $row["ilinc_id"] !=0) {
$this->__addElement ("iLincID", $row["ilinc_id"], "ilinc_id");
$this->__addElement ("iLincUser", $row["ilinc_user"], "ilinc_user");
$this->__addElement ("iLincPasswd", $row["ilinc_passwd"], "ilinc_passwd");
}
if (strlen($row["auth_mode"])>0)
{
$this->__addElement ("AuthMode", null, array ("type" => $row["auth_mode"]),"auth_mode", true);
}
if (strlen($row["ext_account"])>0)
{
$this->__addElement ("ExternalAccount", $row["ext_account"], null, "ext_account", true);
}
if ($this->canExport("Look","skin_style"))
{
$this->__addElement("Look", null, array(
"Skin" => $prefs["skin"], "Style" => $prefs["style"]
), "skin_style", true);
}
$this->__addElement ("LastUpdate", $row["last_update"], null, "last_update");
$this->__addElement ("LastLogin", $row["last_login"], null, "last_login");
include_once ("./Services/User/classes/class.ilUserDefinedData.php");
$udf_data = new ilUserDefinedData($row['usr_id']);
$udf_data->addToXML($this, $this->settings);
$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");
foreach ($msgrs as $type => $fieldname) {
$this->__addElement("AccountInfo", $row[$fieldname], array("Type" => $type), "instant_messengers");
}
$this->__addElement("GMapsInfo", null, array (
"longitude" => $row["longitude"],
"latitude" => $row["latitude"],
"zoom" => $row["loc_zoom"]));
$this->__addElement("Feedhash", $row["feed_hash"]);
if ($this->attachPreferences || $this->canExport("prefs", "preferences"))
$this->__handlePreferences ($prefs, $row);
$this->xmlEndTag('User');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Referenced by __addElement(), and __handleUser().

{
return !is_array($this->settings) ||
in_array(strtolower($tagname), $this->settings) !== FALSE ||
in_array($settingsname, $this->settings) !== FALSE;
}

+ Here is the caller graph for this function:

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

{
return array (
'hits_per_page',
'public_city',
'public_country',
'public_department',
'public_email',
'public_fax',
'public_hobby',
'public_institution',
'public_matriculation',
'public_phone',
'public_phone_home',
'public_phone_mobile',
'public_phone_office',
'public_profile',
'public_street',
'public_upload',
'public_zip',
'send_info_mails',
'show_users_online',
'hide_own_online_status',
'user_tz',
'weekstart',
'mail_incoming_type',
'mail_signature',
'mail_linebreak'
);
}

+ Here is the caller graph for this function:

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 $usr_id, DB_FETCHMODE_ASSOC, and ilUtil\getWebspaceDir().

Referenced by __handleUser().

{
global $ilDB;
// personal picture
$q = sprintf("SELECT value FROM usr_pref WHERE usr_id = %s AND keyword = %s",
$ilDB->quote($usr_id, "integer"), $ilDB->quote('profile_image', "text"));
$r = $ilDB->query($q);
if ($ilDB->numRows($r) == 1)
{
$personal_picture_data = $r->fetchRow(DB_FETCHMODE_ASSOC);
$personal_picture = $personal_picture_data["value"];
$webspace_dir = ilUtil::getWebspaceDir();
$image_file = $webspace_dir."/usr_images/".$personal_picture;
if (@is_file($image_file))
{
$fh = fopen($image_file, "rb");
if ($fh)
{
$image_data = fread($fh, filesize($image_file));
fclose($fh);
$base64 = base64_encode($image_data);
$imagetype = "image/jpeg";
if (preg_match("/.*\.(png|gif)$/", $personal_picture, $matches))
{
$imagetype = "image/".$matches[1];
}
return array (
"value" => $base64,
"encoding" => "Base64",
"imagetype" => $imagetype
);
}
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserXMLWriter::getXML ( )

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

References ilXmlWriter\xmlDumpMem().

{
return $this->xmlDumpMem(FALSE);
}

+ Here is the call graph for this function:

ilUserXMLWriter::ilUserXMLWriter ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding public

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

References $ilias, $ilUser, and ilXmlWriter\ilXmlWriter().

{
global $ilias,$ilUser;
$this->ilias =& $ilias;
$this->user_id = $ilUser->getId();
$this->attachRoles = false;
/* $this->exportablePrefs = array(
"priv_feed_pass", "language", "style", "skin", 'ilPageEditor_HTMLMode',
'ilPageEditor_JavaScript', 'ilPageEditor_MediaMode', 'tst_javascript',
'tst_lastquestiontype', 'tst_multiline_answers', 'tst_use_previous_answers',
'graphicalAnswerSetting', "weekstart"
);*/
}

+ Here is the call graph for this function:

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

{
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

{
$this->attachPreferences = $attachPrefs;
}
ilUserXMLWriter::setAttachRoles (   $value)

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

{
$this->attachRoles = $value == 1? true : false;
}
ilUserXMLWriter::setObjects ( $users)

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

References $users.

{
$this->users = & $users;
}
ilUserXMLWriter::setSettings (   $settings)

write access to settings

Parameters
array$settings

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

References $settings.

Referenced by __handleUser().

{
$this->settings = $settings;
}

+ Here is the caller graph for this function:

ilUserXMLWriter::start ( )

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

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

{
if (!is_array($this->users))
return false;
$this->__buildHeader();
include_once ("./Services/User/classes/class.ilUserDefinedFields.php");
$udf_data->addToXML($this);
foreach ($this->users as $user)
{
$this->__handleUser ($user);
}
$this->__buildFooter();
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilUserXMLWriter::$attachPreferences = false

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

ilUserXMLWriter::$attachRoles = false

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

ilUserXMLWriter::$exportablePrefs
staticprivate

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

ilUserXMLWriter::$ilias

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

Referenced by ilUserXMLWriter().

ilUserXMLWriter::$settings
private

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

Referenced by setSettings().

ilUserXMLWriter::$user_id = 0

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

ilUserXMLWriter::$users

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

Referenced by setObjects().

ilUserXMLWriter::$xml

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


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