00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00038 include_once "./classes/class.ilXmlWriter.php";
00039 include_once "./classes/class.ilObjUserFolder.php";
00040
00041 class ilSoapUserObjectXMLWriter extends ilXmlWriter
00042 {
00043 var $ilias;
00044 var $xml;
00045 var $users;
00046 var $user_id = 0;
00047 var $attachRoles = false;
00048
00056 function ilSoapUserObjectXMLWriter()
00057 {
00058 global $ilias,$ilUser;
00059
00060 parent::ilXmlWriter();
00061
00062 $this->ilias =& $ilias;
00063 $this->user_id = $ilUser->getId();
00064 $this->attachRoles = false;
00065 }
00066
00067 function setAttachRoles ($value)
00068 {
00069 $this->attachRoles = $value == 1? true : false;
00070 }
00071
00072 function setObjects(& $users)
00073 {
00074 $this->users = & $users;
00075 }
00076
00077
00078 function start()
00079 {
00080 if (!is_array($this->users))
00081 return false;
00082
00083 $this->__buildHeader();
00084
00085 foreach ($this->users as $user)
00086 {
00087
00088 $this->__handleUser ($user);
00089
00090 }
00091
00092 $this->__buildFooter();
00093
00094 return true;
00095 }
00096
00097 function getXML()
00098 {
00099 return $this->xmlDumpMem(FALSE);
00100 }
00101
00102
00103 function __buildHeader()
00104 {
00105 $this->xmlSetDtdDef("<!DOCTYPE Users PUBLIC \"-//ILIAS//DTD UserImport//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_user_3_7.dtd\">");
00106 $this->xmlSetGenCmt("User of ilias system");
00107 $this->xmlHeader();
00108
00109 $this->xmlStartTag('Users');
00110
00111 return true;
00112 }
00113
00114 function __buildFooter()
00115 {
00116 $this->xmlEndTag('Users');
00117 }
00118
00119 function __handleUser ($row)
00120 {
00121 global $ilDB;
00122
00123 if (strlen($row["language"]) == 0) $row["language"] = "en";
00124
00125 $attrs = array (
00126 'Id' => "il_".IL_INST_ID."_usr_".$row["usr_id"],
00127 'Language' => $row["language"],
00128 'Action' => "Update");
00129
00130 $this->xmlStartTag("User", $attrs);
00131
00132 $this->xmlElement("Login", null, $row["login"]);
00133
00134 if ($this->attachRoles == TRUE)
00135 {
00136 include_once './classes/class.ilObjRole.php';
00137
00138 $query = sprintf("SELECT object_data.title, object_data.description, rbac_fa.*
00139 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",
00140 $ilDB->quote($row["usr_id"])
00141 );
00142 $rbacresult = $ilDB->query($query);
00143
00144 while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC))
00145 {
00146 if ($rbacrow["assign"] != "y")
00147 continue;
00148
00149 $type = "";
00150
00151 if ($rbacrow["parent"] == ROLE_FOLDER_ID)
00152 {
00153 $type = "Global";
00154 }
00155 else
00156 {
00157 $type = "Local";
00158 }
00159 if (strlen($type))
00160 {
00161 $this->xmlElement("Role",
00162 array ("Id" =>
00163 "il_".IL_INST_ID."_role_".$rbacrow["rol_id"], "Type" => $type),
00164 $rbacrow["title"]);
00165 }
00166 }
00167 }
00168
00173 $this->__addElement ("Firstname", $row["firstname"]);
00174 $this->__addElement ("Lastname", $row["lastname"]);
00175 $this->__addElement ("Title", $row["title"]);
00176 $this->__addElement ("Gender", $row["gender"]);
00177 $this->__addElement ("Email", $row["email"]);
00178 $this->__addElement ("Institution", $row["institution"]);
00179 $this->__addElement ("Street", $row["street"]);
00180 $this->__addElement ("City", $row["city"]);
00181 $this->__addElement ("PostalCode", $row["zipcode"], null, "zipcode");
00182 $this->__addElement ("Country", $row["country"]);
00183 $this->__addElement ("PhoneOffice", $row["phone_office"], null, "phone_office");
00184 $this->__addElement ("PhoneHome", $row["phone_home"], null, "phone_home");
00185 $this->__addElement ("PhoneMobile", $row["phone_mobile"], null, "phone_mobile");
00186 $this->__addElement ("Fax", $row["fax"]);
00187 $this->__addElement ("Department", $row["department"]);
00188 $this->__addElement ("Comment", $row["referral_comment"], null, "referral_comment");
00189 $this->__addElement ("Matriculation", $row["matriculation"]);
00190 $this->__addElement ("Active", $row["active"] ? "true":"false" );
00191 $this->__addElement ("ClientIP", $row["client_ip"], null, "client_ip");
00192 $this->__addElement ("TimeLimitOwner", $row["time_limit_owner"], null, "time_limit_owner");
00193 $this->__addElement ("TimeLimitUnlimited", $row["time_limit_unlimited"], null, "time_limit_unlimited");
00194 $this->__addElement ("TimeLimitFrom", $row["time_limit_from"], null, "time_limit_from");
00195 $this->__addElement ("TimeLimitUntil", $row["time_limit_until"], null, "time_limit_until");
00196 $this->__addElement ("TimeLimitMessage", $row["time_limit_message"], null, "time_limit_message");
00197 $this->__addElement ("ApproveDate", $row["approve_date"], null, "client_ip");
00198 $this->__addElement ("AgreeDate", $row["agree_date"], null, "agree_date");
00199
00200 if ((int) $row["ilinc_id"] !=0) {
00201 $this->__addElement ("iLincID", $row["ilinc_id"], "ilinc_id");
00202 $this->__addElement ("iLincUser", $row["ilinc_user"], "ilinc_user");
00203 $this->__addElement ("iLincPasswd", $row["ilinc_passwd"], "ilinc_passwd");
00204 }
00205
00206 if (strlen($row["auth_mode"])>0)
00207 {
00208 $this->__addElement ("AuthMode", null, array ("type" => $row["auth_mode"]));
00209 }
00210
00211
00212 include_once ("classes/class.ilUserDefinedData.php");
00213 $udf_data = new ilUserDefinedData($row['usr_id']);
00214
00215 $udf_data->addToXML($this);
00216
00217 $this->xmlEndTag('User');
00218 }
00219
00220
00221 function __addElement ($tagname, $value, $attrs = null, $settingsname = null)
00222 {
00223
00224 $this->xmlElement ($tagname, $attrs, $value);
00225
00226 }
00227
00228 }
00229
00230
00231 ?>