/** * return user xmls for given user ids (csv separated ids) as xml based on usr dtd. * @param string sid session id * @param string a_userids array of user ids, may be numeric or ilias ids * @param boolean attachRoles if true, role assignments will be attached, nothing will be done otherwise * @return string xml string based on usr dtd */ function getUserXML($sid, $a_user_ids, $attach_roles) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } global $rbacsystem, $ilUser, $ilDB; // check if own account $is_self = false; if (is_array($a_user_ids) and count($a_user_ids) == 1) { if (end($a_user_ids) == $ilUser->getId()) { $is_self = true; } } elseif (is_numeric($a_user_ids)) { if ($a_user_ids == $ilUser->getId()) { $is_self = true; } } if (!$rbacsystem->checkAccess('read', USER_FOLDER_ID) and !$is_self) { return $this->__raiseError('Check access failed.', 'Server'); } // begin-patch filemanager $data = ilObjUser::_getUserData((array) $a_user_ids); // end-patch filemanager include_once './Services/User/classes/class.ilUserXMLWriter.php'; $xmlWriter = new ilUserXMLWriter(); $xmlWriter->setAttachRoles($attach_roles); $xmlWriter->setObjects($data); if ($xmlWriter->start()) { return $xmlWriter->getXML(); } return $this->__raiseError('User does not exist', 'Client'); }
function createXMLExport(&$settings, &$data, $filename) { include_once './Services/User/classes/class.ilUserDefinedData.php'; include_once './Services/User/classes/class.ilObjUser.php'; global $rbacreview; global $ilDB; global $log; $file = fopen($filename, "w"); if (is_array($data)) { include_once './Services/User/classes/class.ilUserXMLWriter.php'; $xmlWriter = new ilUserXMLWriter(); $xmlWriter->setObjects($data); $xmlWriter->setSettings($settings); $xmlWriter->setAttachRoles(true); if ($xmlWriter->start()) { fwrite($file, $xmlWriter->getXML()); } } }
function createXMLExport(&$settings, &$data, $filename) { include_once './Services/User/classes/class.ilUserDefinedData.php'; include_once './Services/User/classes/class.ilObjUser.php'; global $rbacreview; global $ilDB; global $log; $file = fopen($filename, "w"); if (is_array($data)) { include_once './Services/User/classes/class.ilUserXMLWriter.php'; $xmlWriter = new ilUserXMLWriter(); $xmlWriter->setObjects($data); $xmlWriter->setSettings($settings); $xmlWriter->setAttachRoles(true); if ($xmlWriter->start()) { fwrite($file, $xmlWriter->getXML()); } } /* fwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fwrite($file, "<!DOCTYPE Users SYSTEM \"".ILIAS_HTTP_PATH."/xml/ilias_user_3_8.dtd\">\n"); fwrite($file, "<Users>"); foreach ($data as $row) { //$log->write(date("[y-m-d H:i:s] ")."User data export: processing user " . $row["login"]); foreach ($row as $key => $value) { $row[$key] = $this->escapeXML($value); } $userline = ""; // TODO: Define combobox for "Action" ??? if (strlen($row["language"]) == 0) $row["language"] = "en"; $userline .= "<User Id=\"il_".IL_INST_ID."_usr_".$row["usr_id"]."\" Language=\"".$row["language"]."\" Action=\"Insert\">"; if (array_search("login", $settings) !== FALSE) { $userline .= "<Login>".$row["login"]."</Login>"; } // Alternative way to get the roles of a user? $query = sprintf("SELECT object_data.title, 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"]) ); $rbacresult = $ilDB->query($query); while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC)) { $type = ""; if ($rbacrow["assign"] == "y") { if ($rbacrow["parent"] == ROLE_FOLDER_ID) { $type = "Global"; } else { $type = "Local"; } if (strlen($type)) { $userline .= "<Role Id=\"il_".IL_INST_ID."_role_".$rbacrow["rol_id"]."\" Type=\"".$type."\">".$rbacrow["title"]."</Role>"; } } } //$log->write(date("[y-m-d H:i:s] ")."User data export: get all roles"); /* the export of roles is to expensive. on a system with 6000 users the following section needs 37 seconds $roles = $rbacreview->getRolesByFilter(1, $row["usr_id"]); $ass_roles = $rbacreview->assignedRoles($row["usr_id"]); foreach ($roles as $role) { if (array_search($role["obj_id"], $ass_roles) !== FALSE) { $type = ""; switch ($role["role_type"]) { case "global": $type = "Global"; break; case "local": $type = "Local"; break; } if (strlen($type)) { $userline .= "<Role Id=\"".$role["obj_id"]."\" Type=\"".$type."\">".$role["title"]."</Role>"; } } } */ /* //$log->write(date("[y-m-d H:i:s] ")."User data export: got all roles"); $i2passwd = FALSE; if (array_search("i2passwd", $settings) !== FALSE) { if (strlen($row["i2passwd"])) $i2passwd = TRUE; if ($i2passwd) $userline .= "<Password Type=\"ILIAS2\">".$row["i2passwd"]."</Password>"; } if ((!$i2passwd) && (array_search("passwd", $settings) !== FALSE)) { if (strlen($row["passwd"])) $userline .= "<Password Type=\"ILIAS3\">".$row["passwd"]."</Password>"; } if (array_search("firstname", $settings) !== FALSE) { if (strlen($row["firstname"])) $userline .= "<Firstname>".$row["firstname"]."</Firstname>"; } if (array_search("lastname", $settings) !== FALSE) { if (strlen($row["lastname"])) $userline .= "<Lastname>".$row["lastname"]."</Lastname>"; } if (array_search("title", $settings) !== FALSE) { if (strlen($row["title"])) $userline .= "<Title>".$row["title"]."</Title>"; } if (array_search("upload", $settings) !== FALSE) { // personal picture $q = sprintf("SELECT value FROM usr_pref WHERE usr_id=%s AND keyword='profile_image'", $ilDB->quote($row["usr_id"] . "")); $r = $ilDB->query($q); if ($r->numRows() == 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]; } $userline .= "<PersonalPicture imagetype=\"$imagetype\" encoding=\"Base64\">$base64</PersonalPicture>"; } } } } if (array_search("gender", $settings) !== FALSE) { if (strlen($row["gender"])) $userline .= "<Gender>".$row["gender"]."</Gender>"; } if (array_search("email", $settings) !== FALSE) { if (strlen($row["email"])) $userline .= "<Email>".$row["email"]."</Email>"; } if (array_search("institution", $settings) !== FALSE) { if (strlen($row["institution"])) $userline .= "<Institution>".$row["institution"]."</Institution>"; } if (array_search("street", $settings) !== FALSE) { if (strlen($row["street"])) $userline .= "<Street>".$row["street"]."</Street>"; } if (array_search("city", $settings) !== FALSE) { if (strlen($row["city"])) $userline .= "<City>".$row["city"]."</City>"; } if (array_search("zipcode", $settings) !== FALSE) { if (strlen($row["zipcode"])) $userline .= "<PostalCode>".$row["zipcode"]."</PostalCode>"; } if (array_search("country", $settings) !== FALSE) { if (strlen($row["country"])) $userline .= "<Country>".$row["country"]."</Country>"; } if (array_search("phone_office", $settings) !== FALSE) { if (strlen($row["phone_office"])) $userline .= "<PhoneOffice>".$row["phone_office"]."</PhoneOffice>"; } if (array_search("phone_home", $settings) !== FALSE) { if (strlen($row["phone_home"])) $userline .= "<PhoneHome>".$row["phone_home"]."</PhoneHome>"; } if (array_search("phone_mobile", $settings) !== FALSE) { if (strlen($row["phone_mobile"])) $userline .= "<PhoneMobile>".$row["phone_mobile"]."</PhoneMobile>"; } if (array_search("fax", $settings) !== FALSE) { if (strlen($row["fax"])) $userline .= "<Fax>".$row["fax"]."</Fax>"; } if (strlen($row["hobby"])) if (array_search("hobby", $settings) !== FALSE) { $userline .= "<Hobby>".$row["hobby"]."</Hobby>"; } if (array_search("department", $settings) !== FALSE) { if (strlen($row["department"])) $userline .= "<Department>".$row["department"]."</Department>"; } if (array_search("referral_comment", $settings) !== FALSE) { if (strlen($row["referral_comment"])) $userline .= "<Comment>".$row["referral_comment"]."</Comment>"; } if (array_search("matriculation", $settings) !== FALSE) { if (strlen($row["matriculation"])) $userline .= "<Matriculation>".$row["matriculation"]."</Matriculation>"; } if (array_search("active", $settings) !== FALSE) { if ($row["active"]) { $userline .= "<Active>true</Active>"; } else { $userline .= "<Active>false</Active>"; } } if (array_search("client_ip", $settings) !== FALSE) { if (strlen($row["client_ip"])) $userline .= "<ClientIP>".$row["client_ip"]."</ClientIP>"; } if (array_search("time_limit_owner", $settings) !== FALSE) { if (strlen($row["time_limit_owner"])) $userline .= "<TimeLimitOwner>".$row["time_limit_owner"]."</TimeLimitOwner>"; } if (array_search("time_limit_unlimited", $settings) !== FALSE) { if (strlen($row["time_limit_unlimited"])) $userline .= "<TimeLimitUnlimited>".$row["time_limit_unlimited"]."</TimeLimitUnlimited>"; } if (array_search("time_limit_from", $settings) !== FALSE) { if (strlen($row["time_limit_from"])) $userline .= "<TimeLimitFrom>".$row["time_limit_from"]."</TimeLimitFrom>"; } if (array_search("time_limit_until", $settings) !== FALSE) { if (strlen($row["time_limit_until"])) $userline .= "<TimeLimitUntil>".$row["time_limit_until"]."</TimeLimitUntil>"; } if (array_search("time_limit_message", $settings) !== FALSE) { if (strlen($row["time_limit_message"])) $userline .= "<TimeLimitMessage>".$row["time_limit_message"]."</TimeLimitMessage>"; } if (array_search("approve_date", $settings) !== FALSE) { if (strlen($row["approve_date"])) $userline .= "<ApproveDate>".$row["approve_date"]."</ApproveDate>"; } if (array_search("agree_date", $settings) !== FALSE) { if (strlen($row["agree_date"])) $userline .= "<AgreeDate>".$row["agree_date"]."</AgreeDate>"; } if ((int) $row["ilinc_id"] !=0) { if (array_search("ilinc_id", $settings) !== FALSE) { if (strlen($row["ilinc_id"])) $userline .= "<iLincID>".$row["ilinc_id"]."</iLincID>"; } if (array_search("ilinc_login", $settings) !== FALSE) { if (strlen($row["ilinc_login"])) $userline .= "<iLincLogin>".$row["ilinc_login"]."</iLincLogin>"; } if (array_search("ilinc_passwd", $settings) !== FALSE) { if (strlen($row["ilinc_passwd"])) $userline .= "<iLincPasswd>".$row["ilinc_passwd"]."</iLincPasswd>"; } } if (array_search("auth_mode", $settings) !== FALSE) { if (strlen($row["auth_mode"])) $userline .= "<AuthMode type=\"".$row["auth_mode"]."\"></AuthMode>"; } if (array_search("skin_style", $settings) !== FALSE) { $userline .= "<Look Skin=\"" . ilObjUser::_lookupPref($row["usr_id"], "skin") . "\" " . "Style=\"" . ilObjUser::_lookupPref($row["usr_id"], "style") . "\"></Look>"; } if (array_search("last_update", $settings) !== FALSE) { if (strlen($row["last_update"])) $userline .= "<LastUpdate>".$row["last_update"]."</LastUpdate>"; } if (array_search("last_login", $settings) !== FALSE) { if (strlen($row["last_login"])) $userline .= "<LastLogin>".$row["last_login"]."</LastLogin>"; } // Append User defined field data $udf_data = new ilUserDefinedData($row['usr_id']); $userline .= $udf_data->toXML(); $userline .= "</User>"; fwrite($file, $userline); } fwrite($file, "</Users>"); fclose($file);*/ }