33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
47 $_POST[
'username'] = $username;
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;
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_user',$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))
744 if (is_numeric($internalId))
746 $role_id = $internalId;
747 $role_name = $role_id;
759 $permitted_roles[$role_id] = $role_id;
764 return $this->
__raiseError(
"Could not find role ".$role_name.
". Either you use an invalid/deleted role ".
765 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
'Server');
769 $global_roles = $rbacreview->getGlobalRoles();
775 foreach ($permitted_roles as $role_id => $role_name)
779 if (in_array($role_id, $global_roles))
781 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
785 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
'Server');
790 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
791 if ($rbacreview->isDeleted($rolf[0])
792 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
795 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
"Server");
804 $importParser->setSendMail($send_account_mail);
806 $importParser->setFolderId($folder_id);
807 $importParser->setXMLContent($usr_xml);
809 $importParser->setRoleAssignment($permitted_roles);
811 $importParser->startParsing();
830 static $checked_roles = array();
831 static $global_roles = null;
834 if(isset($checked_roles[$a_role]))
836 return $checked_roles[$a_role];
839 global $rbacsystem,$rbacreview,$ilUser,$tree,
$ilLog;
841 $locations = $rbacreview->getFoldersAssignedToRole($a_role,
true);
847 $ilLog->write(__METHOD__.
': Check global role');
853 $ilLog->write(__METHOD__.
': '.$a_folder);
854 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
857 $ilLog->write(__METHOD__.
': No assignment allowed');
858 $checked_roles[$a_role] =
false;
863 if ($a_role == ANONYMOUS_ROLE_ID)
865 $ilLog->write(__METHOD__.
': Anonymous role chosen.');
866 $checked_roles[$a_role] =
false;
870 if($a_role == SYSTEM_ROLE_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
872 $ilLog->write(__METHOD__.
': System role assignment forbidden.');
873 $checked_roles[$a_role] =
false;
878 $ilLog->write(__METHOD__.
': Assignment allowed.');
879 $checked_roles[$a_role] =
true;
884 $ilLog->write(__METHOD__.
': Check local role.');
887 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,
true);
895 if($rbacreview->isDeleted($rolf)
896 || !$rbacsystem->checkAccess(
'edit_permission',$tree->getParentId($rolf)))
898 $ilLog->write(__METHOD__.
': Role deleted or no permission.');
899 $checked_roles[$a_role] =
false;
910 if($a_folder !=
USER_FOLDER_ID and $a_folder != 0 and !$tree->isGrandChild($a_folder,$rolf))
912 $ilLog->write(__METHOD__.
': Not in path of category.');
913 $checked_roles[$a_role] =
false;
916 $ilLog->write(__METHOD__.
': Assignment allowed.');
917 $checked_roles[$a_role] =
true;
936 global
$ilDB, $tree, $rbacreview, $rbacsystem;
946 switch ($object->getType()) {
955 $object->initCourseMemberObject();
958 $roles = $object->__getLocalRoles();
960 foreach($roles as $role_id)
962 $data = array_merge($rbacreview->assignedUsers($role_id, array()),
$data);
968 $member_ids = $object->getGroupMemberIds();
972 $course_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
975 return $this->
__raiseError(
"No course for session",
"Client");
979 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
981 $member_ids = array_keys($event_part->getParticipants());
988 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
991 $xmlWriter->setObjects(
$data);
992 $xmlWriter->setAttachRoles ($attachRoles);
994 if($xmlWriter->start())
996 return $xmlWriter->getXML();
999 return $this->
__raiseError(
'Error in processing information. This is likely a bug.',
'Server');
1016 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1017 global
$ilDB, $rbacreview, $rbacsystem, $tree,$ilUser;
1020 $global_roles = $rbacreview->getGlobalRoles();
1023 if (in_array($role_id, $global_roles))
1025 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
1028 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1033 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
1034 if ($rbacreview->isDeleted($rolf[0])
1035 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
1037 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1039 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1041 if(!$rbacsystem->checkAccess(
'read',SYSTEM_USER_ID) and
1042 !$rbacsystem->checkAccess(
'export_member_data',$privacy->getPrivacySettingsRefId())) {
1043 return $this->
__raiseError(
"Export of local role members not permitted. ($role_id)",
"Server");
1050 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1053 $xmlWriter->setAttachRoles($attachRoles);
1055 $xmlWriter->setObjects(
$data);
1057 if($xmlWriter->start())
1059 return $xmlWriter->getXML();
1061 return $this->
__raiseError(
'Error in getUsersForRole',
'Server');
1072 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1073 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1076 $xmlResultSet->addColumn (
"userid");
1077 $xmlResultSet->addColumn (
"login");
1078 $xmlResultSet->addColumn (
"action");
1079 $xmlResultSet->addColumn (
"message");
1081 foreach ($a_array as $username =>
$messages)
1087 $xmlRow->setValue (0, 0);
1088 $xmlRow->setValue (1, $username);
1089 $xmlRow->setValue (2,
"");
1090 $xmlRow->setValue (3, $message);
1092 $xmlResultSet->addRow ($xmlRow);
1098 if ($xml_writer->start ())
1099 return $xml_writer->getXML();
1101 return $this->
__raiseError(
'Error in __getImportProtocolAsXML',
'Server');
1112 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1113 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1116 $xmlResultSet->addColumn (
"userid");
1117 $xmlResultSet->addColumn (
"login");
1118 $xmlResultSet->addColumn (
"action");
1119 $xmlResultSet->addColumn (
"message");
1121 if (count($a_array))
1122 foreach ($a_array as $username => $message)
1125 $xmlRow->setValue (0, $username);
1126 $xmlRow->setValue (1, $message[
"login"]);
1127 $xmlRow->setValue (2, $message[
"action"]);
1128 $xmlRow->setValue (3, $message[
"message"]);
1130 $xmlResultSet->addRow ($xmlRow);
1135 if ($xml_writer->start ())
1136 return $xml_writer->getXML();
1138 return $this->
__raiseError(
'Error in __getUserMappingAsXML',
'Server');
1150 function searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active) {
1160 global
$ilDB, $rbacsystem;
1164 return $this->
__raiseError(
'Check access failed.',
'Server');
1168 if (!count($a_keyfields))
1169 $this->
__raiseError(
'At least one keyfield is needed',
'Client');
1171 if (!count ($a_keyvalues))
1172 $this->
__raiseError(
'At least one keyvalue is needed',
'Client');
1174 if (!strcasecmp($query_operator,
"and")==0 || !strcasecmp($query_operator,
"or") == 0)
1175 $this->
__raiseError(
'Query operator must be either \'and\' or \'or\'',
'Client');
1180 $query =
"SELECT usr_data.*, usr_pref.value AS language
1183 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
1184 $ilDB->quote(
"language",
"text").
1186 WHERE 1 = 1 ".$query;
1188 if (is_numeric($active) && $active > -1)
1189 $query .=
" AND active = ". $ilDB->quote($active);
1191 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
1195 $r = $ilDB->query(
$query);
1199 while(
$row = $ilDB->fetchAssoc($r))
1204 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1207 $xmlWriter->setAttachRoles($attach_roles);
1209 $xmlWriter->setObjects(
$data);
1211 if($xmlWriter->start())
1213 return $xmlWriter->getXML();
1215 return $this->
__raiseError(
'Error in searchUser',
'Server');
1230 $allowed_fields = array (
"firstname",
"lastname",
"email",
"login",
"matriculation",
"institution",
"department",
"title",
"ext_account");
1232 foreach ($a_keyfields as $keyfield)
1234 $keyfield = strtolower($keyfield);
1236 if (!in_array($keyfield, $allowed_fields))
1239 $field_query = array ();
1240 foreach ($a_keyvalues as $keyvalue)
1242 if (strlen($keyvalue) >= 3) {
1243 $field_query []= $keyfield.
" like '%".$keyvalue.
"%'";
1247 if (count($field_query))
1248 $query [] = join(
" ".strtoupper($queryOperator).
" ", $field_query);
1252 return count (
$query) ?
" AND ((". join(
") OR (",
$query) .
"))" :
"AND 0";
1273 global $rbacsystem, $ilUser,
$ilDB;
1277 return $this->
__raiseError(
'Check access failed.',
'Server');
1282 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1284 $xmlWriter->setAttachRoles($attach_roles);
1285 $xmlWriter->setObjects(
$data);
1287 if($xmlWriter->start())
1289 return $xmlWriter->getXML();
1292 return $this->
__raiseError(
'User does not exist',
'Client');
1307 include_once (
"Services/Mail/classes/class.ilMailbox.php");