33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
47 $_POST[
'username'] = $username;
48 $_POST[
'password'] = $password;
51 include_once
'./include/inc.header.php';
56 if(!$ilUser->hasAcceptedUserAgreement())
58 return $this->
__raiseError(
'User agreement not accepted',
'Server');
60 return (session_id().
'::'.
$client);
67 $this->sauth->setClient(
$client);
68 $this->sauth->setUsername($username);
69 $this->sauth->setPT($PT);
70 $authenticated =
true;
73 if(!$this->sauth->authenticate())
75 $authenticated =
false;
79 return $this->
__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
81 return $this->sauth->getSid().
'::'.
$client;
125 if(!strlen($user_name))
127 return $this->
__raiseError(
'No username given. Aborting',
'Client');
130 global $rbacsystem, $ilUser ;
133 if($ilUser->getLogin() != $user_name && !$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID))
141 return $user_id ? $user_id :
"0";
155 global $rbacsystem, $ilUser;
159 return $this->
__raiseError(
'Check access failed.',
'Server');
162 if($ilUser->getLoginByUserId($user_id))
169 return $this->
__raiseError(
'User does not exist',
'Client');
182 global $rbacsystem, $ilUser,
$log;
186 return $this->
__raiseError(
'Check access failed.',
'Server');
191 return $this->
__raiseError(
'User with id '.$user_data[
'usr_id'].
' does not exist.',
'Client');
202 if(strlen($user_data[
'passwd']) != 32)
212 $log->write(
'SOAP: updateUser()');
215 if($user_data[
'accepted_agreement'] and !$user_obj->hasAcceptedUserAgreement())
217 $user_obj->writeAccepted();
237 return $this->
__raiseError(
'Check access failed.',
'Server');
242 return $this->
__raiseError(
'No valid user_id given.',
'Client');
245 $tmp_user->replacePassword($new_password);
250 function addUser($sid,$user_data,$global_role_id)
264 return $this->
__raiseError(
'Check access failed.',
'Server');
275 return $this->
__raiseError(
'No role id given',
'Client');
280 $global_roles = $rbacreview->getGlobalRoles();
282 if(!in_array($global_role_id,$global_roles))
284 return $this->
__raiseError(
'Role with id: '.$global_role_id.
' is not a valid global role',
'Client');
289 if(strlen($user_data[
'passwd']) != 32)
299 $ilLog->write(
'SOAP: addUser()');
305 if ($user_data[
"import_id"] !=
"")
307 $new_user->setImportId($user_data[
"import_id"]);
316 if($user_data[
'accepted_agreement'])
322 $rbacadmin->assignUser($global_role_id,
$new_user->getId());
325 $new_user->setLanguage($user_data[
'user_language']);
326 $new_user->setPref(
'style',$user_data[
'user_style']);
327 $new_user->setPref(
'skin',$user_data[
'user_skin']);
328 $new_user->setPref(
'hits_per_page',$ilSetting->get(
'hits_per_page'));
329 $new_user->setPref(
'show_users_online',$ilSetting->get(
'show_users_online'));
347 return $this->
__raiseError(
'No user_id given. Aborting',
'Client');
350 global $rbacsystem, $ilUser,
$log;
354 return $this->
__raiseError(
'Check access failed.',
'Server');
357 if(!$ilUser->getLoginByUserId($user_id))
359 return $this->
__raiseError(
'User id: '.$user_id.
' is not a valid identifier. Aborting',
'Client');
361 if($ilUser->getId() == $user_id)
363 return $this->
__raiseError(
'Cannot delete myself. Aborting',
'Client');
365 if($user_id == SYSTEM_USER_ID)
367 return $this->
__raiseError(
'Cannot delete root account. Aborting',
'Client');
370 $log->write(
'SOAP: deleteUser()');
372 $delete_user->delete();
387 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
393 if(!isset($user_data[
'login']))
397 if(!isset($user_data[
'passwd']) and !$allow_empty_password)
401 if(!isset($user_data[
'email']))
405 if(!isset($user_data[
'user_language']))
407 $user_data[
'user_language'] = $lng->getDefaultLanguage();
410 foreach($user_data as $field => $value)
431 if(!strlen($value) and $allow_empty_password)
448 case 'time_limit_unlimited':
451 if($user_data[
'time_limit_from'] >= $user_data[
'time_limit_until'])
458 case 'user_language':
459 $lang_inst = $lng->getInstalledLanguages();
461 if(!in_array($user_data[
'user_language'],$lang_inst))
463 $this->
__appendMessage(
'Language: '.$user_data[
'user_language'].
' is not installed');
470 if(($user_data[
'user_skin'] and !$user_data[
'user_style']) or
471 (!$user_data[
'user_skin'] and $user_data[
'user_style']))
475 elseif($user_data[
'user_skin'] and $user_data[
'user_style'])
478 $templates = $styleDefinition->getAllTemplates();
479 if (count($templates) > 0 && is_array($templates))
481 foreach($templates as $template)
484 $styleDef->startParsing();
485 $styles = $styleDef->getStyles();
486 foreach ($styles as $style)
488 if ($user_data[
'user_skin'] == $template[
"id"] &&
489 $user_data[
'user_style'] == $style[
"id"])
503 case 'time_limit_owner':
523 if(!$user_data[
'time_limit_from'] and
524 !$user_data[
'time_limit_until'] and
525 !$user_data[
'time_limit_unlimited'])
527 $user_data[
'time_limit_unlimited'] = 1;
529 if(!$user_data[
'time_limit_owner'])
536 $user_data[
'im_icq'] = $user_obj->getInstantMessengerId(
'icq');
537 $user_data[
'im_yahoo'] = $user_obj->getInstantMessengerId(
'yahoo');
538 $user_data[
'im_msn'] = $user_obj->getInstantMessengerId(
'msn');
539 $user_data[
'im_aim'] = $user_obj->getInstantMessengerId(
'aim');
540 $user_data[
'im_skype'] = $user_obj->getInstantMessengerId(
'skype');
541 $user_data[
'im_jabber'] = $user_obj->getInstantMessengerId(
'jabber');
542 $user_data[
'im_voip'] = $user_obj->getInstantMessengerId(
'voip');
544 $user_data[
'delicious'] = $user_obj->getDelicious();
545 $user_data[
'latitude'] = $user_obj->getLatitude();
546 $user_data[
'longitude'] = $user_obj->getLongitude();
547 $user_data[
'loc_zoom'] = $user_obj->getLocationZoom();
550 $user_data[
'auth_mode'] = $user_obj->getAuthMode();
551 $user_data[
'ext_account'] = $user_obj->getExternalAccount();
552 $user_obj->assignData($user_data);
554 if(isset($user_data[
'user_language']))
556 $user_obj->setLanguage($user_data[
'user_language']);
558 if(isset($user_data[
'user_skin']) and isset($user_data[
'user_style']))
560 $user_obj->setPref(
'skin',$user_data[
'user_skin']);
561 $user_obj->setPref(
'style',$user_data[
'user_style']);
568 $usr_data[
'usr_id'] = $usr_obj->getId();
569 $usr_data[
'login'] = $usr_obj->getLogin();
570 $usr_data[
'passwd'] = $usr_obj->getPasswd();
571 $usr_data[
'passwd_type'] = $usr_obj->getPasswdType();
572 $usr_data[
'firstname'] = $usr_obj->getFirstname();
573 $usr_data[
'lastname'] = $usr_obj->getLastname();
574 $usr_data[
'title'] = $usr_obj->getUTitle();
575 $usr_data[
'gender'] = $usr_obj->getGender();
576 $usr_data[
'email'] = $usr_obj->getEmail();
577 $usr_data[
'institution'] = $usr_obj->getInstitution();
578 $usr_data[
'street'] = $usr_obj->getStreet();
579 $usr_data[
'city'] = $usr_obj->getCity();
580 $usr_data[
'zipcode'] = $usr_obj->getZipcode();
581 $usr_data[
'country'] = $usr_obj->getCountry();
582 $usr_data[
'phone_office'] = $usr_obj->getPhoneOffice();
583 $usr_data[
'last_login'] = $usr_obj->getLastLogin();
584 $usr_data[
'last_update'] = $usr_obj->getLastUpdate();
585 $usr_data[
'create_date'] = $usr_obj->getCreateDate();
586 $usr_data[
'hobby'] = $usr_obj->getHobby();
587 $usr_data[
'department'] = $usr_obj->getDepartment();
588 $usr_data[
'phone_home'] = $usr_obj->getPhoneHome();
589 $usr_data[
'phone_mobile'] = $usr_obj->getPhoneMobile();
590 $usr_data[
'fax'] = $usr_obj->getFax();
591 $usr_data[
'time_limit_owner'] = $usr_obj->getTimeLimitOwner();
592 $usr_data[
'time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
593 $usr_data[
'time_limit_from'] = $usr_obj->getTimeLimitFrom();
594 $usr_data[
'time_limit_until'] = $usr_obj->getTimeLimitUntil();
595 $usr_data[
'time_limit_message'] = $usr_obj->getTimeLimitMessage();
596 $usr_data[
'referral_comment'] = $usr_obj->getComment();
597 $usr_data[
'matriculation'] = $usr_obj->getMatriculation();
598 $usr_data[
'active'] = $usr_obj->getActive();
599 $usr_data[
'approve_date'] = $usr_obj->getApproveDate();
600 $usr_data[
'user_skin'] = $usr_obj->getPref(
'skin');
601 $usr_data[
'user_style'] = $usr_obj->getPref(
'style');
602 $usr_data[
'user_language'] = $usr_obj->getLanguage();
603 $usr_data[
'auth_mode'] = $usr_obj->getAuthMode();
604 $usr_data[
'accepted_agreement'] = $usr_obj->hasAcceptedUserAgreement();
605 $usr_data[
'import_id'] = $usr_obj->getImportId();
612 foreach($user_new as $key => $value)
614 $user_old[$key] = $value;
616 return $user_old ? $user_old : array();
625 function importUsers ($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
636 include_once
'./Services/User/classes/class.ilUserImportParser.php';
637 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
638 include_once
'./classes/class.ilObjectFactory.php';
639 global $rbacreview, $rbacsystem, $tree,
$lng,$ilUser,
$ilLog;
652 foreach (
$error as $err) {
653 $msg []=
"(".$err[
"line"].
",".$err[
"col"].
"): ".$err[
"errormessage"];
660 $msg = join(
"\n",$msg);
665 switch ($conflict_rule)
683 if ($folder_id == -1)
690 return $this->
__raiseError(
'Wrong reference id.',
'Server');
693 if ($import_folder->getType() !=
"usrf" && $import_folder->getType() !=
"cat")
694 return $this->
__raiseError(
'Folder must be a usr folder or a category.',
'Server');
697 if(!$rbacsystem->checkAccess(
'create_usr',$folder_id))
699 return $this->
__raiseError(
'Missing permission for creating users within '.$import_folder->getTitle(),
'Server');
708 $importParser->setXMLContent($usr_xml);
709 $importParser->startParsing();
711 switch ($importParser->getErrorLevel())
725 $importParser->setXMLContent($usr_xml);
727 $importParser->startParsing();
729 $roles = $importParser->getCollectedRoles();
736 $permitted_roles = array();
737 foreach ($roles as $role_id => $role)
739 if (!is_numeric ($role_id))
743 $original_role_id = $role_id;
745 if (is_numeric($internalId))
747 $role_id = $internalId;
748 $role_name = $role_id;
752 return $this->
__raiseError(
"Only internal numeric role IDs are supported at this time, and ".$internalId.
" doesn't seem to be either",
'Server');
767 $permitted_roles[$role_id] = $role_id;
772 return $this->
__raiseError(
"Could not find role ".$role_name.
" (original input ".$original_role_id.
"). Either you use an invalid/deleted role ".
773 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
'Server');
777 $global_roles = $rbacreview->getGlobalRoles();
783 foreach ($permitted_roles as $role_id => $role_name)
787 if (in_array($role_id, $global_roles))
789 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
793 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
'Server');
798 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
799 if ($rbacreview->isDeleted($rolf[0])
800 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
803 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
"Server");
812 $importParser->setSendMail($send_account_mail);
814 $importParser->setFolderId($folder_id);
815 $importParser->setXMLContent($usr_xml);
817 $importParser->setRoleAssignment($permitted_roles);
819 $importParser->startParsing();
838 static $checked_roles = array();
839 static $global_roles = null;
842 if(isset($checked_roles[$a_role]))
844 return $checked_roles[$a_role];
847 global $rbacsystem,$rbacreview,$ilUser,$tree,
$ilLog;
849 $ilLog->write(__METHOD__.
': Getting folders assigned to role '.$a_role);
850 $locations = $rbacreview->getFoldersAssignedToRole($a_role,
true);
856 $ilLog->write(__METHOD__.
': Check global role');
862 $ilLog->write(__METHOD__.
': '.$a_folder);
863 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
866 $ilLog->write(__METHOD__.
': No assignment allowed');
867 $checked_roles[$a_role] =
false;
872 if ($a_role == ANONYMOUS_ROLE_ID)
874 $ilLog->write(__METHOD__.
': Anonymous role chosen.');
875 $checked_roles[$a_role] =
false;
879 if($a_role == SYSTEM_ROLE_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
881 $ilLog->write(__METHOD__.
': System role assignment forbidden.');
882 $checked_roles[$a_role] =
false;
887 $ilLog->write(__METHOD__.
': Assignment allowed.');
888 $checked_roles[$a_role] =
true;
893 $ilLog->write(__METHOD__.
': Check local role.');
896 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,
true);
904 if($rbacreview->isDeleted($rolf)
905 || !$rbacsystem->checkAccess(
'edit_permission',$tree->getParentId($rolf)))
907 $ilLog->write(__METHOD__.
': Role deleted or no permission.');
908 $checked_roles[$a_role] =
false;
919 if($a_folder !=
USER_FOLDER_ID and $a_folder != 0 and !$tree->isGrandChild($a_folder,$rolf))
921 $ilLog->write(__METHOD__.
': Not in path of category.');
922 $checked_roles[$a_role] =
false;
925 $ilLog->write(__METHOD__.
': Assignment allowed.');
926 $checked_roles[$a_role] =
true;
945 global
$ilDB, $tree, $rbacreview, $rbacsystem;
955 switch ($object->getType()) {
964 $object->initCourseMemberObject();
967 $roles = $object->__getLocalRoles();
969 foreach($roles as $role_id)
971 $data = array_merge($rbacreview->assignedUsers($role_id, array()),
$data);
977 $member_ids = $object->getGroupMemberIds();
981 $course_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
984 return $this->
__raiseError(
"No course for session",
"Client");
988 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
990 $member_ids = array_keys($event_part->getParticipants());
997 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1000 $xmlWriter->setObjects(
$data);
1001 $xmlWriter->setAttachRoles ($attachRoles);
1003 if($xmlWriter->start())
1005 return $xmlWriter->getXML();
1008 return $this->
__raiseError(
'Error in processing information. This is likely a bug.',
'Server');
1025 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1026 global
$ilDB, $rbacreview, $rbacsystem, $tree,$ilUser;
1029 $global_roles = $rbacreview->getGlobalRoles();
1032 if (in_array($role_id, $global_roles))
1034 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
1037 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1042 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
1043 if ($rbacreview->isDeleted($rolf[0])
1044 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
1046 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1048 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1050 if(!$rbacsystem->checkAccess(
'read',SYSTEM_USER_ID) and
1051 !$rbacsystem->checkAccess(
'export_member_data',$privacy->getPrivacySettingsRefId())) {
1052 return $this->
__raiseError(
"Export of local role members not permitted. ($role_id)",
"Server");
1059 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1062 $xmlWriter->setAttachRoles($attachRoles);
1064 $xmlWriter->setObjects(
$data);
1066 if($xmlWriter->start())
1068 return $xmlWriter->getXML();
1070 return $this->
__raiseError(
'Error in getUsersForRole',
'Server');
1081 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1082 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1085 $xmlResultSet->addColumn (
"userid");
1086 $xmlResultSet->addColumn (
"login");
1087 $xmlResultSet->addColumn (
"action");
1088 $xmlResultSet->addColumn (
"message");
1090 foreach ($a_array as $username =>
$messages)
1096 $xmlRow->setValue (0, 0);
1097 $xmlRow->setValue (1, $username);
1098 $xmlRow->setValue (2,
"");
1099 $xmlRow->setValue (3, $message);
1101 $xmlResultSet->addRow ($xmlRow);
1107 if ($xml_writer->start ())
1108 return $xml_writer->getXML();
1110 return $this->
__raiseError(
'Error in __getImportProtocolAsXML',
'Server');
1121 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1122 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1125 $xmlResultSet->addColumn (
"userid");
1126 $xmlResultSet->addColumn (
"login");
1127 $xmlResultSet->addColumn (
"action");
1128 $xmlResultSet->addColumn (
"message");
1130 if (count($a_array))
1131 foreach ($a_array as $username => $message)
1134 $xmlRow->setValue (0, $username);
1135 $xmlRow->setValue (1, $message[
"login"]);
1136 $xmlRow->setValue (2, $message[
"action"]);
1137 $xmlRow->setValue (3, $message[
"message"]);
1139 $xmlResultSet->addRow ($xmlRow);
1144 if ($xml_writer->start ())
1145 return $xml_writer->getXML();
1147 return $this->
__raiseError(
'Error in __getUserMappingAsXML',
'Server');
1159 function searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active) {
1169 global
$ilDB, $rbacsystem;
1173 return $this->
__raiseError(
'Check access failed.',
'Server');
1177 if (!count($a_keyfields))
1178 $this->
__raiseError(
'At least one keyfield is needed',
'Client');
1180 if (!count ($a_keyvalues))
1181 $this->
__raiseError(
'At least one keyvalue is needed',
'Client');
1183 if (!strcasecmp($query_operator,
"and")==0 || !strcasecmp($query_operator,
"or") == 0)
1184 $this->
__raiseError(
'Query operator must be either \'and\' or \'or\'',
'Client');
1189 $query =
"SELECT usr_data.*, usr_pref.value AS language
1192 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
1193 $ilDB->quote(
"language",
"text").
1195 WHERE 1 = 1 ".$query;
1197 if (is_numeric($active) && $active > -1)
1198 $query .=
" AND active = ". $ilDB->quote($active);
1200 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
1204 $r = $ilDB->query(
$query);
1208 while(
$row = $ilDB->fetchAssoc($r))
1213 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1216 $xmlWriter->setAttachRoles($attach_roles);
1218 $xmlWriter->setObjects(
$data);
1220 if($xmlWriter->start())
1222 return $xmlWriter->getXML();
1224 return $this->
__raiseError(
'Error in searchUser',
'Server');
1239 $allowed_fields = array (
"firstname",
"lastname",
"email",
"login",
"matriculation",
"institution",
"department",
"title",
"ext_account");
1241 foreach ($a_keyfields as $keyfield)
1243 $keyfield = strtolower($keyfield);
1245 if (!in_array($keyfield, $allowed_fields))
1248 $field_query = array ();
1249 foreach ($a_keyvalues as $keyvalue)
1251 if (strlen($keyvalue) >= 3) {
1252 $field_query []= $keyfield.
" like '%".$keyvalue.
"%'";
1256 if (count($field_query))
1257 $query [] = join(
" ".strtoupper($queryOperator).
" ", $field_query);
1261 return count (
$query) ?
" AND ((". join(
") OR (",
$query) .
"))" :
"AND 0";
1282 global $rbacsystem, $ilUser,
$ilDB;
1286 return $this->
__raiseError(
'Check access failed.',
'Server');
1291 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1293 $xmlWriter->setAttachRoles($attach_roles);
1294 $xmlWriter->setObjects(
$data);
1296 if($xmlWriter->start())
1298 return $xmlWriter->getXML();
1301 return $this->
__raiseError(
'User does not exist',
'Client');
1316 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1341 $parts = explode(
'::', $sid);
1342 $query =
"SELECT usr_id FROM usr_session "
1343 .
"INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
1344 $res = $ilDB->queryF(
$query, array(
'text'), array($parts[0]));
1347 if(!(
int)
$data[
'usr_id'])
1352 return (
int)$data[
'usr_id'];