33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
44 function login(
$client,$username,$password)
52 $_POST[
'username'] = $username;
53 $_POST[
'password'] = $password;
58 include_once
'./include/inc.header.php';
67 if($ilUser->hasToAcceptTermsOfService())
69 return $this->
__raiseError(
'User agreement not accepted',
'Server');
72 return (session_id().
'::'.
$client);
79 $this->sauth->setClient(
$client);
80 $this->sauth->setUsername($username);
81 $this->sauth->setPT($PT);
82 $authenticated =
true;
85 if(!$this->sauth->authenticate())
87 $authenticated =
false;
91 return $this->
__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
93 return $this->sauth->getSid().
'::'.
$client;
99 return $this->login(
$client, $username, $password);
107 if(!$this->__checkSession($sid))
132 if(!$this->__checkSession($sid))
137 if(!strlen($user_name))
139 return $this->
__raiseError(
'No username given. Aborting',
'Client');
144 if(strcasecmp($ilUser->getLogin(), $user_name) != 0 && !$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID))
152 return $user_id ? $user_id :
"0";
161 if(!$this->__checkSession($sid))
170 return $this->
__raiseError(
'Check access failed.',
'Server');
173 if($ilUser->getLoginByUserId($user_id))
180 return $this->
__raiseError(
'User does not exist',
'Client');
183 function updateUser($sid,$user_data)
191 if(!$this->__checkSession($sid))
200 return $this->
__raiseError(
'Check access failed.',
'Server');
205 return $this->
__raiseError(
'User with id '.$user_data[
'usr_id'].
' does not exist.',
'Client');
216 if(strlen($user_data[
'passwd']) != 32)
226 $log->write(
'SOAP: updateUser()');
229 if($user_data[
'accepted_agreement'] && $user_obj->hasToAcceptTermsOfService())
231 $user_obj->writeAccepted();
242 if(!$this->__checkSession($sid))
251 return $this->
__raiseError(
'Check access failed.',
'Server');
256 return $this->
__raiseError(
'No valid user_id given.',
'Client');
259 $tmp_user->replacePassword($new_password);
264 function addUser($sid,$user_data,$global_role_id)
269 if(!$this->__checkSession($sid))
278 return $this->
__raiseError(
'Check access failed.',
'Server');
289 return $this->
__raiseError(
'No role id given',
'Client');
294 $global_roles = $rbacreview->getGlobalRoles();
296 if(!in_array($global_role_id,$global_roles))
298 return $this->
__raiseError(
'Role with id: '.$global_role_id.
' is not a valid global role',
'Client');
303 if(strlen($user_data[
'passwd']) != 32)
313 $ilLog->write(
'SOAP: addUser()');
319 if ($user_data[
"import_id"] !=
"")
321 $new_user->setImportId($user_data[
"import_id"]);
330 if($user_data[
'accepted_agreement'])
336 $rbacadmin->assignUser($global_role_id,
$new_user->getId());
339 $new_user->setLanguage($user_data[
'user_language']);
340 $new_user->setPref(
'style',$user_data[
'user_style']);
341 $new_user->setPref(
'skin',$user_data[
'user_skin']);
342 $new_user->setPref(
'hits_per_page',$ilSetting->get(
'hits_per_page'));
343 $new_user->setPref(
'show_users_online',$ilSetting->get(
'show_users_online'));
354 if(!$this->__checkSession($sid))
361 return $this->
__raiseError(
'No user_id given. Aborting',
'Client');
368 return $this->
__raiseError(
'Check access failed.',
'Server');
371 if(!$ilUser->getLoginByUserId($user_id))
373 return $this->
__raiseError(
'User id: '.$user_id.
' is not a valid identifier. Aborting',
'Client');
375 if($ilUser->getId() == $user_id)
377 return $this->
__raiseError(
'Cannot delete myself. Aborting',
'Client');
379 if($user_id == SYSTEM_USER_ID)
381 return $this->
__raiseError(
'Cannot delete root account. Aborting',
'Client');
384 $log->write(
'SOAP: deleteUser()');
386 $delete_user->delete();
401 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
407 if(!isset($user_data[
'login']))
411 if(!isset($user_data[
'passwd']) and !$allow_empty_password)
415 if(!isset($user_data[
'email']))
419 if(!isset($user_data[
'user_language']))
421 $user_data[
'user_language'] = $lng->getDefaultLanguage();
424 foreach($user_data as $field => $value)
445 if(!strlen($value) and $allow_empty_password)
462 case 'time_limit_unlimited':
465 if($user_data[
'time_limit_from'] >= $user_data[
'time_limit_until'])
472 case 'user_language':
473 $lang_inst = $lng->getInstalledLanguages();
475 if(!in_array($user_data[
'user_language'],$lang_inst))
477 $this->
__appendMessage(
'Language: '.$user_data[
'user_language'].
' is not installed');
484 if(($user_data[
'user_skin'] and !$user_data[
'user_style']) or
485 (!$user_data[
'user_skin'] and $user_data[
'user_style']))
489 elseif($user_data[
'user_skin'] and $user_data[
'user_style'])
492 $templates = $styleDefinition->getAllTemplates();
493 if (count($templates) > 0 && is_array($templates))
495 foreach($templates as $template)
498 $styleDef->startParsing();
499 $styles = $styleDef->getStyles();
500 foreach ($styles as $style)
502 if ($user_data[
'user_skin'] == $template[
"id"] &&
503 $user_data[
'user_style'] == $style[
"id"])
517 case 'time_limit_owner':
519 if($type !=
'cat' and $type !=
'usrf')
521 $this->
__appendMessage(
'time_limit_owner must be ref_id of category or user folder'.$type);
537 if(!$user_data[
'time_limit_from'] and
538 !$user_data[
'time_limit_until'] and
539 !$user_data[
'time_limit_unlimited'])
541 $user_data[
'time_limit_unlimited'] = 1;
543 if(!$user_data[
'time_limit_owner'])
550 $user_data[
'im_icq'] = $user_obj->getInstantMessengerId(
'icq');
551 $user_data[
'im_yahoo'] = $user_obj->getInstantMessengerId(
'yahoo');
552 $user_data[
'im_msn'] = $user_obj->getInstantMessengerId(
'msn');
553 $user_data[
'im_aim'] = $user_obj->getInstantMessengerId(
'aim');
554 $user_data[
'im_skype'] = $user_obj->getInstantMessengerId(
'skype');
555 $user_data[
'im_jabber'] = $user_obj->getInstantMessengerId(
'jabber');
556 $user_data[
'im_voip'] = $user_obj->getInstantMessengerId(
'voip');
558 $user_data[
'delicious'] = $user_obj->getDelicious();
559 $user_data[
'latitude'] = $user_obj->getLatitude();
560 $user_data[
'longitude'] = $user_obj->getLongitude();
561 $user_data[
'loc_zoom'] = $user_obj->getLocationZoom();
564 $user_data[
'auth_mode'] = $user_obj->getAuthMode();
565 $user_data[
'ext_account'] = $user_obj->getExternalAccount();
566 $user_obj->assignData($user_data);
568 if(isset($user_data[
'user_language']))
570 $user_obj->setLanguage($user_data[
'user_language']);
572 if(isset($user_data[
'user_skin']) and isset($user_data[
'user_style']))
574 $user_obj->setPref(
'skin',$user_data[
'user_skin']);
575 $user_obj->setPref(
'style',$user_data[
'user_style']);
582 $usr_data[
'usr_id'] = $usr_obj->getId();
583 $usr_data[
'login'] = $usr_obj->getLogin();
584 $usr_data[
'passwd'] = $usr_obj->getPasswd();
585 $usr_data[
'passwd_type'] = $usr_obj->getPasswdType();
586 $usr_data[
'firstname'] = $usr_obj->getFirstname();
587 $usr_data[
'lastname'] = $usr_obj->getLastname();
588 $usr_data[
'title'] = $usr_obj->getUTitle();
589 $usr_data[
'gender'] = $usr_obj->getGender();
590 $usr_data[
'email'] = $usr_obj->getEmail();
591 $usr_data[
'institution'] = $usr_obj->getInstitution();
592 $usr_data[
'street'] = $usr_obj->getStreet();
593 $usr_data[
'city'] = $usr_obj->getCity();
594 $usr_data[
'zipcode'] = $usr_obj->getZipcode();
595 $usr_data[
'country'] = $usr_obj->getCountry();
596 $usr_data[
'phone_office'] = $usr_obj->getPhoneOffice();
597 $usr_data[
'last_login'] = $usr_obj->getLastLogin();
598 $usr_data[
'last_update'] = $usr_obj->getLastUpdate();
599 $usr_data[
'create_date'] = $usr_obj->getCreateDate();
600 $usr_data[
'hobby'] = $usr_obj->getHobby();
601 $usr_data[
'department'] = $usr_obj->getDepartment();
602 $usr_data[
'phone_home'] = $usr_obj->getPhoneHome();
603 $usr_data[
'phone_mobile'] = $usr_obj->getPhoneMobile();
604 $usr_data[
'fax'] = $usr_obj->getFax();
605 $usr_data[
'time_limit_owner'] = $usr_obj->getTimeLimitOwner();
606 $usr_data[
'time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
607 $usr_data[
'time_limit_from'] = $usr_obj->getTimeLimitFrom();
608 $usr_data[
'time_limit_until'] = $usr_obj->getTimeLimitUntil();
609 $usr_data[
'time_limit_message'] = $usr_obj->getTimeLimitMessage();
610 $usr_data[
'referral_comment'] = $usr_obj->getComment();
611 $usr_data[
'matriculation'] = $usr_obj->getMatriculation();
612 $usr_data[
'active'] = $usr_obj->getActive();
613 $usr_data[
'approve_date'] = $usr_obj->getApproveDate();
614 $usr_data[
'user_skin'] = $usr_obj->getPref(
'skin');
615 $usr_data[
'user_style'] = $usr_obj->getPref(
'style');
616 $usr_data[
'user_language'] = $usr_obj->getLanguage();
617 $usr_data[
'auth_mode'] = $usr_obj->getAuthMode();
618 $usr_data[
'accepted_agreement'] = !$usr_obj->hasToAcceptTermsOfService();
619 $usr_data[
'import_id'] = $usr_obj->getImportId();
626 foreach($user_new as $key => $value)
628 $user_old[$key] = $value;
630 return $user_old ? $user_old : array();
639 function importUsers ($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
644 if(!$this->__checkSession($sid))
650 include_once
'./Services/User/classes/class.ilUserImportParser.php';
651 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
652 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
664 if (is_array($error))
666 foreach ($error as $err) {
667 $msg []=
"(".$err[
"line"].
",".$err[
"col"].
"): ".$err[
"errormessage"];
674 $msg = join(
"\n",$msg);
679 switch ($conflict_rule)
697 if ($folder_id == -1)
704 return $this->
__raiseError(
'Wrong reference id.',
'Server');
707 if ($import_folder->getType() !=
"usrf" && $import_folder->getType() !=
"cat")
708 return $this->
__raiseError(
'Folder must be a usr folder or a category.',
'Server');
711 if(!$rbacsystem->checkAccess(
'create_usr',$folder_id))
713 return $this->
__raiseError(
'Missing permission for creating users within '.$import_folder->getTitle(),
'Server');
722 $importParser->setXMLContent($usr_xml);
723 $importParser->startParsing();
725 switch ($importParser->getErrorLevel())
739 $importParser->setXMLContent($usr_xml);
741 $importParser->startParsing();
743 $roles = $importParser->getCollectedRoles();
750 $permitted_roles = array();
751 foreach ($roles as $role_id => $role)
753 if (!is_numeric ($role_id))
758 if (is_numeric($internalId))
760 $role_id = $internalId;
761 $role_name = $role_id;
773 $permitted_roles[$role_id] = $role_id;
778 return $this->
__raiseError(
"Could not find role ".$role_name.
". Either you use an invalid/deleted role ".
779 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
'Server');
783 $global_roles = $rbacreview->getGlobalRoles();
789 foreach ($permitted_roles as $role_id => $role_name)
793 if (in_array($role_id, $global_roles))
795 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
799 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
'Server');
804 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
805 if ($rbacreview->isDeleted($rolf[0])
806 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
809 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
"Server");
818 $importParser->setSendMail($send_account_mail);
820 $importParser->setFolderId($folder_id);
821 $importParser->setXMLContent($usr_xml);
823 $importParser->setRoleAssignment($permitted_roles);
825 $importParser->startParsing();
844 static $checked_roles = array();
845 static $global_roles = null;
848 if(isset($checked_roles[$a_role]))
850 return $checked_roles[$a_role];
855 $locations = $rbacreview->getFoldersAssignedToRole($a_role,
true);
861 $ilLog->write(__METHOD__.
': Check global role');
867 $ilLog->write(__METHOD__.
': '.$a_folder);
868 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
871 $ilLog->write(__METHOD__.
': No assignment allowed');
872 $checked_roles[$a_role] =
false;
877 if ($a_role == ANONYMOUS_ROLE_ID)
879 $ilLog->write(__METHOD__.
': Anonymous role chosen.');
880 $checked_roles[$a_role] =
false;
884 if($a_role == SYSTEM_ROLE_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
886 $ilLog->write(__METHOD__.
': System role assignment forbidden.');
887 $checked_roles[$a_role] =
false;
892 $ilLog->write(__METHOD__.
': Assignment allowed.');
893 $checked_roles[$a_role] =
true;
898 $ilLog->write(__METHOD__.
': Check local role.');
901 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,
true);
909 if($rbacreview->isDeleted($rolf)
910 || !$rbacsystem->checkAccess(
'edit_permission',$tree->getParentId($rolf)))
912 $ilLog->write(__METHOD__.
': Role deleted or no permission.');
913 $checked_roles[$a_role] =
false;
924 if($a_folder !=
USER_FOLDER_ID and $a_folder != 0 and !$tree->isGrandChild($a_folder,$rolf))
926 $ilLog->write(__METHOD__.
': Not in path of category.');
927 $checked_roles[$a_role] =
false;
930 $ilLog->write(__METHOD__.
': Assignment allowed.');
931 $checked_roles[$a_role] =
true;
945 if(!$this->__checkSession($sid))
950 global $ilDB, $tree, $rbacreview, $rbacsystem;
960 switch ($object->getType()) {
970 $roles = $object->__getLocalRoles();
972 foreach($roles as $role_id)
974 $data = array_merge($rbacreview->assignedUsers($role_id, array()),$data);
980 $member_ids = $object->getGroupMemberIds();
984 $course_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
987 return $this->
__raiseError(
"No course for session",
"Client");
991 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
993 $member_ids = array_keys($event_part->getParticipants());
1000 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1003 $xmlWriter->setObjects($data);
1004 $xmlWriter->setAttachRoles ($attachRoles);
1006 if($xmlWriter->start())
1008 return $xmlWriter->getXML();
1011 return $this->
__raiseError(
'Error in processing information. This is likely a bug.',
'Server');
1023 if(!$this->__checkSession($sid))
1028 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1029 global $ilDB, $rbacreview, $rbacsystem, $tree,
$ilUser;
1032 $global_roles = $rbacreview->getGlobalRoles();
1035 if (in_array($role_id, $global_roles))
1037 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
1040 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1045 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
1046 if ($rbacreview->isDeleted($rolf[0])
1047 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
1049 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1051 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1053 if(!$rbacsystem->checkAccess(
'read',SYSTEM_USER_ID) and
1054 !$rbacsystem->checkAccess(
'export_member_data',$privacy->getPrivacySettingsRefId())) {
1055 return $this->
__raiseError(
"Export of local role members not permitted. ($role_id)",
"Server");
1062 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1065 $xmlWriter->setAttachRoles($attachRoles);
1067 $xmlWriter->setObjects($data);
1069 if($xmlWriter->start())
1071 return $xmlWriter->getXML();
1073 return $this->
__raiseError(
'Error in getUsersForRole',
'Server');
1084 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1085 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1088 $xmlResultSet->addColumn (
"userid");
1089 $xmlResultSet->addColumn (
"login");
1090 $xmlResultSet->addColumn (
"action");
1091 $xmlResultSet->addColumn (
"message");
1093 foreach ($a_array as $username =>
$messages)
1099 $xmlRow->setValue (0, 0);
1100 $xmlRow->setValue (1, $username);
1101 $xmlRow->setValue (2,
"");
1102 $xmlRow->setValue (3, $message);
1104 $xmlResultSet->addRow ($xmlRow);
1110 if ($xml_writer->start ())
1111 return $xml_writer->getXML();
1113 return $this->
__raiseError(
'Error in __getImportProtocolAsXML',
'Server');
1124 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1125 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1128 $xmlResultSet->addColumn (
"userid");
1129 $xmlResultSet->addColumn (
"login");
1130 $xmlResultSet->addColumn (
"action");
1131 $xmlResultSet->addColumn (
"message");
1133 if (count($a_array))
1134 foreach ($a_array as $username => $message)
1137 $xmlRow->setValue (0, $username);
1138 $xmlRow->setValue (1, $message[
"login"]);
1139 $xmlRow->setValue (2, $message[
"action"]);
1140 $xmlRow->setValue (3, $message[
"message"]);
1142 $xmlResultSet->addRow ($xmlRow);
1147 if ($xml_writer->start ())
1148 return $xml_writer->getXML();
1150 return $this->
__raiseError(
'Error in __getUserMappingAsXML',
'Server');
1162 function searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active) {
1167 if(!$this->__checkSession($sid))
1172 global $ilDB, $rbacsystem;
1176 return $this->
__raiseError(
'Check access failed.',
'Server');
1180 if (!count($a_keyfields))
1181 $this->
__raiseError(
'At least one keyfield is needed',
'Client');
1183 if (!count ($a_keyvalues))
1184 $this->
__raiseError(
'At least one keyvalue is needed',
'Client');
1186 if (!strcasecmp($query_operator,
"and")==0 || !strcasecmp($query_operator,
"or") == 0)
1187 $this->
__raiseError(
'Query operator must be either \'and\' or \'or\'',
'Client');
1192 $query =
"SELECT usr_data.*, usr_pref.value AS language
1195 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
1196 $ilDB->quote(
"language",
"text").
1198 WHERE 1 = 1 ".$query;
1200 if (is_numeric($active) && $active > -1)
1201 $query .=
" AND active = ". $ilDB->quote($active);
1203 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
1207 $r = $ilDB->query(
$query);
1211 while(
$row = $ilDB->fetchAssoc($r))
1216 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1219 $xmlWriter->setAttachRoles($attach_roles);
1221 $xmlWriter->setObjects($data);
1223 if($xmlWriter->start())
1225 return $xmlWriter->getXML();
1227 return $this->
__raiseError(
'Error in searchUser',
'Server');
1242 $allowed_fields = array (
"firstname",
"lastname",
"email",
"login",
"matriculation",
"institution",
"department",
"title",
"ext_account");
1244 foreach ($a_keyfields as $keyfield)
1246 $keyfield = strtolower($keyfield);
1248 if (!in_array($keyfield, $allowed_fields))
1251 $field_query = array ();
1252 foreach ($a_keyvalues as $keyvalue)
1254 if (strlen($keyvalue) >= 3) {
1255 $field_query []= $keyfield.
" like '%".$keyvalue.
"%'";
1259 if (count($field_query))
1260 $query [] = join(
" ".strtoupper($queryOperator).
" ", $field_query);
1264 return count (
$query) ?
" AND ((". join(
") OR (",
$query) .
"))" :
"AND 0";
1280 if(!$this->__checkSession($sid))
1285 global $rbacsystem,
$ilUser, $ilDB;
1289 if(is_array($a_user_ids) and count($a_user_ids) == 1)
1291 if(end($a_user_ids) == $ilUser->getId())
1296 elseif(is_numeric($a_user_ids))
1298 if($a_user_ids == $ilUser->getId())
1304 if(!$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID) and !$is_self)
1306 return $this->
__raiseError(
'Check access failed.',
'Server');
1313 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1315 $xmlWriter->setAttachRoles($attach_roles);
1316 $xmlWriter->setObjects($data);
1318 if($xmlWriter->start())
1320 return $xmlWriter->getXML();
1323 return $this->
__raiseError(
'User does not exist',
'Client');
1333 if(!$this->__checkSession($sid))
1340 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
1356 if(!$this->__checkSession($sid))
1363 $parts = explode(
'::', $sid);
1364 $query =
"SELECT usr_id FROM usr_session "
1365 .
"INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
1366 $res = $ilDB->queryF(
$query, array(
'text'), array($parts[0]));
1367 $data = $ilDB->fetchAssoc(
$res);
1369 if(!(
int)$data[
'usr_id'])
1374 return (
int)$data[
'usr_id'];