33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
47 $_POST[
'username'] = $username;
48 $_POST[
'password'] = $password;
53 include_once
'./include/inc.header.php';
63 if(!$ilUser->hasAcceptedUserAgreement())
65 return $this->
__raiseError(
'User agreement not accepted',
'Server');
67 return (session_id().
'::'.
$client);
74 $this->sauth->setClient(
$client);
75 $this->sauth->setUsername($username);
76 $this->sauth->setPT($PT);
77 $authenticated =
true;
80 if(!$this->sauth->authenticate())
82 $authenticated =
false;
86 return $this->
__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
88 return $this->sauth->getSid().
'::'.
$client;
132 if(!strlen($user_name))
134 return $this->
__raiseError(
'No username given. Aborting',
'Client');
139 if(strcasecmp($ilUser->getLogin(), $user_name) != 0 && !$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID))
147 return $user_id ? $user_id :
"0";
165 return $this->
__raiseError(
'Check access failed.',
'Server');
168 if($ilUser->getLoginByUserId($user_id))
175 return $this->
__raiseError(
'User does not exist',
'Client');
192 return $this->
__raiseError(
'Check access failed.',
'Server');
197 return $this->
__raiseError(
'User with id '.$user_data[
'usr_id'].
' does not exist.',
'Client');
208 if(strlen($user_data[
'passwd']) != 32)
218 $log->write(
'SOAP: updateUser()');
221 if($user_data[
'accepted_agreement'] and !$user_obj->hasAcceptedUserAgreement())
223 $user_obj->writeAccepted();
243 return $this->
__raiseError(
'Check access failed.',
'Server');
248 return $this->
__raiseError(
'No valid user_id given.',
'Client');
251 $tmp_user->replacePassword($new_password);
256 function addUser($sid,$user_data,$global_role_id)
270 return $this->
__raiseError(
'Check access failed.',
'Server');
281 return $this->
__raiseError(
'No role id given',
'Client');
286 $global_roles = $rbacreview->getGlobalRoles();
288 if(!in_array($global_role_id,$global_roles))
290 return $this->
__raiseError(
'Role with id: '.$global_role_id.
' is not a valid global role',
'Client');
295 if(strlen($user_data[
'passwd']) != 32)
305 $ilLog->write(
'SOAP: addUser()');
311 if ($user_data[
"import_id"] !=
"")
313 $new_user->setImportId($user_data[
"import_id"]);
322 if($user_data[
'accepted_agreement'])
328 $rbacadmin->assignUser($global_role_id,
$new_user->getId());
331 $new_user->setLanguage($user_data[
'user_language']);
332 $new_user->setPref(
'style',$user_data[
'user_style']);
333 $new_user->setPref(
'skin',$user_data[
'user_skin']);
334 $new_user->setPref(
'hits_per_page',$ilSetting->get(
'hits_per_page'));
335 $new_user->setPref(
'show_users_online',$ilSetting->get(
'show_users_online'));
353 return $this->
__raiseError(
'No user_id given. Aborting',
'Client');
360 return $this->
__raiseError(
'Check access failed.',
'Server');
363 if(!$ilUser->getLoginByUserId($user_id))
365 return $this->
__raiseError(
'User id: '.$user_id.
' is not a valid identifier. Aborting',
'Client');
367 if($ilUser->getId() == $user_id)
369 return $this->
__raiseError(
'Cannot delete myself. Aborting',
'Client');
371 if($user_id == SYSTEM_USER_ID)
373 return $this->
__raiseError(
'Cannot delete root account. Aborting',
'Client');
376 $log->write(
'SOAP: deleteUser()');
378 $delete_user->delete();
393 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
399 if(!isset($user_data[
'login']))
403 if(!isset($user_data[
'passwd']) and !$allow_empty_password)
407 if(!isset($user_data[
'email']))
411 if(!isset($user_data[
'user_language']))
413 $user_data[
'user_language'] = $lng->getDefaultLanguage();
416 foreach($user_data as $field => $value)
437 if(!strlen($value) and $allow_empty_password)
454 case 'time_limit_unlimited':
457 if($user_data[
'time_limit_from'] >= $user_data[
'time_limit_until'])
464 case 'user_language':
465 $lang_inst = $lng->getInstalledLanguages();
467 if(!in_array($user_data[
'user_language'],$lang_inst))
469 $this->
__appendMessage(
'Language: '.$user_data[
'user_language'].
' is not installed');
476 if(($user_data[
'user_skin'] and !$user_data[
'user_style']) or
477 (!$user_data[
'user_skin'] and $user_data[
'user_style']))
481 elseif($user_data[
'user_skin'] and $user_data[
'user_style'])
484 $templates = $styleDefinition->getAllTemplates();
485 if (count($templates) > 0 && is_array($templates))
487 foreach($templates as $template)
490 $styleDef->startParsing();
491 $styles = $styleDef->getStyles();
492 foreach ($styles as $style)
494 if ($user_data[
'user_skin'] == $template[
"id"] &&
495 $user_data[
'user_style'] == $style[
"id"])
509 case 'time_limit_owner':
511 if($type !=
'cat' and $type !=
'usrf')
513 $this->
__appendMessage(
'time_limit_owner must be ref_id of category or user folder'.$type);
529 if(!$user_data[
'time_limit_from'] and
530 !$user_data[
'time_limit_until'] and
531 !$user_data[
'time_limit_unlimited'])
533 $user_data[
'time_limit_unlimited'] = 1;
535 if(!$user_data[
'time_limit_owner'])
542 $user_data[
'im_icq'] = $user_obj->getInstantMessengerId(
'icq');
543 $user_data[
'im_yahoo'] = $user_obj->getInstantMessengerId(
'yahoo');
544 $user_data[
'im_msn'] = $user_obj->getInstantMessengerId(
'msn');
545 $user_data[
'im_aim'] = $user_obj->getInstantMessengerId(
'aim');
546 $user_data[
'im_skype'] = $user_obj->getInstantMessengerId(
'skype');
547 $user_data[
'im_jabber'] = $user_obj->getInstantMessengerId(
'jabber');
548 $user_data[
'im_voip'] = $user_obj->getInstantMessengerId(
'voip');
550 $user_data[
'delicious'] = $user_obj->getDelicious();
551 $user_data[
'latitude'] = $user_obj->getLatitude();
552 $user_data[
'longitude'] = $user_obj->getLongitude();
553 $user_data[
'loc_zoom'] = $user_obj->getLocationZoom();
556 $user_data[
'auth_mode'] = $user_obj->getAuthMode();
557 $user_data[
'ext_account'] = $user_obj->getExternalAccount();
558 $user_obj->assignData($user_data);
560 if(isset($user_data[
'user_language']))
562 $user_obj->setLanguage($user_data[
'user_language']);
564 if(isset($user_data[
'user_skin']) and isset($user_data[
'user_style']))
566 $user_obj->setPref(
'skin',$user_data[
'user_skin']);
567 $user_obj->setPref(
'style',$user_data[
'user_style']);
574 $usr_data[
'usr_id'] = $usr_obj->getId();
575 $usr_data[
'login'] = $usr_obj->getLogin();
576 $usr_data[
'passwd'] = $usr_obj->getPasswd();
577 $usr_data[
'passwd_type'] = $usr_obj->getPasswdType();
578 $usr_data[
'firstname'] = $usr_obj->getFirstname();
579 $usr_data[
'lastname'] = $usr_obj->getLastname();
580 $usr_data[
'title'] = $usr_obj->getUTitle();
581 $usr_data[
'gender'] = $usr_obj->getGender();
582 $usr_data[
'email'] = $usr_obj->getEmail();
583 $usr_data[
'institution'] = $usr_obj->getInstitution();
584 $usr_data[
'street'] = $usr_obj->getStreet();
585 $usr_data[
'city'] = $usr_obj->getCity();
586 $usr_data[
'zipcode'] = $usr_obj->getZipcode();
587 $usr_data[
'country'] = $usr_obj->getCountry();
588 $usr_data[
'phone_office'] = $usr_obj->getPhoneOffice();
589 $usr_data[
'last_login'] = $usr_obj->getLastLogin();
590 $usr_data[
'last_update'] = $usr_obj->getLastUpdate();
591 $usr_data[
'create_date'] = $usr_obj->getCreateDate();
592 $usr_data[
'hobby'] = $usr_obj->getHobby();
593 $usr_data[
'department'] = $usr_obj->getDepartment();
594 $usr_data[
'phone_home'] = $usr_obj->getPhoneHome();
595 $usr_data[
'phone_mobile'] = $usr_obj->getPhoneMobile();
596 $usr_data[
'fax'] = $usr_obj->getFax();
597 $usr_data[
'time_limit_owner'] = $usr_obj->getTimeLimitOwner();
598 $usr_data[
'time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
599 $usr_data[
'time_limit_from'] = $usr_obj->getTimeLimitFrom();
600 $usr_data[
'time_limit_until'] = $usr_obj->getTimeLimitUntil();
601 $usr_data[
'time_limit_message'] = $usr_obj->getTimeLimitMessage();
602 $usr_data[
'referral_comment'] = $usr_obj->getComment();
603 $usr_data[
'matriculation'] = $usr_obj->getMatriculation();
604 $usr_data[
'active'] = $usr_obj->getActive();
605 $usr_data[
'approve_date'] = $usr_obj->getApproveDate();
606 $usr_data[
'user_skin'] = $usr_obj->getPref(
'skin');
607 $usr_data[
'user_style'] = $usr_obj->getPref(
'style');
608 $usr_data[
'user_language'] = $usr_obj->getLanguage();
609 $usr_data[
'auth_mode'] = $usr_obj->getAuthMode();
610 $usr_data[
'accepted_agreement'] = $usr_obj->hasAcceptedUserAgreement();
611 $usr_data[
'import_id'] = $usr_obj->getImportId();
618 foreach($user_new as $key => $value)
620 $user_old[$key] = $value;
622 return $user_old ? $user_old : array();
631 function importUsers ($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
642 include_once
'./Services/User/classes/class.ilUserImportParser.php';
643 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
644 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
656 if (is_array($error))
658 foreach ($error as $err) {
659 $msg []=
"(".$err[
"line"].
",".$err[
"col"].
"): ".$err[
"errormessage"];
666 $msg = join(
"\n",$msg);
671 switch ($conflict_rule)
689 if ($folder_id == -1)
696 return $this->
__raiseError(
'Wrong reference id.',
'Server');
699 if ($import_folder->getType() !=
"usrf" && $import_folder->getType() !=
"cat")
700 return $this->
__raiseError(
'Folder must be a usr folder or a category.',
'Server');
703 if(!$rbacsystem->checkAccess(
'create_usr',$folder_id))
705 return $this->
__raiseError(
'Missing permission for creating users within '.$import_folder->getTitle(),
'Server');
714 $importParser->setXMLContent($usr_xml);
715 $importParser->startParsing();
717 switch ($importParser->getErrorLevel())
731 $importParser->setXMLContent($usr_xml);
733 $importParser->startParsing();
735 $roles = $importParser->getCollectedRoles();
742 $permitted_roles = array();
743 foreach ($roles as $role_id => $role)
745 if (!is_numeric ($role_id))
750 if (is_numeric($internalId))
752 $role_id = $internalId;
753 $role_name = $role_id;
765 $permitted_roles[$role_id] = $role_id;
770 return $this->
__raiseError(
"Could not find role ".$role_name.
". Either you use an invalid/deleted role ".
771 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
'Server');
775 $global_roles = $rbacreview->getGlobalRoles();
781 foreach ($permitted_roles as $role_id => $role_name)
785 if (in_array($role_id, $global_roles))
787 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
791 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
'Server');
796 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
797 if ($rbacreview->isDeleted($rolf[0])
798 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
801 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
"Server");
810 $importParser->setSendMail($send_account_mail);
812 $importParser->setFolderId($folder_id);
813 $importParser->setXMLContent($usr_xml);
815 $importParser->setRoleAssignment($permitted_roles);
817 $importParser->startParsing();
836 static $checked_roles = array();
837 static $global_roles = null;
840 if(isset($checked_roles[$a_role]))
842 return $checked_roles[$a_role];
847 $locations = $rbacreview->getFoldersAssignedToRole($a_role,
true);
853 $ilLog->write(__METHOD__.
': Check global role');
859 $ilLog->write(__METHOD__.
': '.$a_folder);
860 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
863 $ilLog->write(__METHOD__.
': No assignment allowed');
864 $checked_roles[$a_role] =
false;
869 if ($a_role == ANONYMOUS_ROLE_ID)
871 $ilLog->write(__METHOD__.
': Anonymous role chosen.');
872 $checked_roles[$a_role] =
false;
876 if($a_role == SYSTEM_ROLE_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
878 $ilLog->write(__METHOD__.
': System role assignment forbidden.');
879 $checked_roles[$a_role] =
false;
884 $ilLog->write(__METHOD__.
': Assignment allowed.');
885 $checked_roles[$a_role] =
true;
890 $ilLog->write(__METHOD__.
': Check local role.');
893 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,
true);
901 if($rbacreview->isDeleted($rolf)
902 || !$rbacsystem->checkAccess(
'edit_permission',$tree->getParentId($rolf)))
904 $ilLog->write(__METHOD__.
': Role deleted or no permission.');
905 $checked_roles[$a_role] =
false;
916 if($a_folder !=
USER_FOLDER_ID and $a_folder != 0 and !$tree->isGrandChild($a_folder,$rolf))
918 $ilLog->write(__METHOD__.
': Not in path of category.');
919 $checked_roles[$a_role] =
false;
922 $ilLog->write(__METHOD__.
': Assignment allowed.');
923 $checked_roles[$a_role] =
true;
942 global $ilDB, $tree, $rbacreview, $rbacsystem;
952 switch ($object->getType()) {
962 $roles = $object->__getLocalRoles();
964 foreach($roles as $role_id)
966 $data = array_merge($rbacreview->assignedUsers($role_id, array()),
$data);
972 $member_ids = $object->getGroupMemberIds();
976 $course_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
979 return $this->
__raiseError(
"No course for session",
"Client");
983 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
985 $member_ids = array_keys($event_part->getParticipants());
992 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
995 $xmlWriter->setObjects(
$data);
996 $xmlWriter->setAttachRoles ($attachRoles);
998 if($xmlWriter->start())
1000 return $xmlWriter->getXML();
1003 return $this->
__raiseError(
'Error in processing information. This is likely a bug.',
'Server');
1020 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1021 global $ilDB, $rbacreview, $rbacsystem, $tree,
$ilUser;
1024 $global_roles = $rbacreview->getGlobalRoles();
1027 if (in_array($role_id, $global_roles))
1029 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
1032 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1037 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
1038 if ($rbacreview->isDeleted($rolf[0])
1039 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
1041 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1043 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1045 if(!$rbacsystem->checkAccess(
'read',SYSTEM_USER_ID) and
1046 !$rbacsystem->checkAccess(
'export_member_data',$privacy->getPrivacySettingsRefId())) {
1047 return $this->
__raiseError(
"Export of local role members not permitted. ($role_id)",
"Server");
1054 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1057 $xmlWriter->setAttachRoles($attachRoles);
1059 $xmlWriter->setObjects(
$data);
1061 if($xmlWriter->start())
1063 return $xmlWriter->getXML();
1065 return $this->
__raiseError(
'Error in getUsersForRole',
'Server');
1076 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1077 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1080 $xmlResultSet->addColumn (
"userid");
1081 $xmlResultSet->addColumn (
"login");
1082 $xmlResultSet->addColumn (
"action");
1083 $xmlResultSet->addColumn (
"message");
1085 foreach ($a_array as $username =>
$messages)
1091 $xmlRow->setValue (0, 0);
1092 $xmlRow->setValue (1, $username);
1093 $xmlRow->setValue (2,
"");
1094 $xmlRow->setValue (3, $message);
1096 $xmlResultSet->addRow ($xmlRow);
1102 if ($xml_writer->start ())
1103 return $xml_writer->getXML();
1105 return $this->
__raiseError(
'Error in __getImportProtocolAsXML',
'Server');
1116 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1117 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1120 $xmlResultSet->addColumn (
"userid");
1121 $xmlResultSet->addColumn (
"login");
1122 $xmlResultSet->addColumn (
"action");
1123 $xmlResultSet->addColumn (
"message");
1125 if (count($a_array))
1126 foreach ($a_array as $username => $message)
1129 $xmlRow->setValue (0, $username);
1130 $xmlRow->setValue (1, $message[
"login"]);
1131 $xmlRow->setValue (2, $message[
"action"]);
1132 $xmlRow->setValue (3, $message[
"message"]);
1134 $xmlResultSet->addRow ($xmlRow);
1139 if ($xml_writer->start ())
1140 return $xml_writer->getXML();
1142 return $this->
__raiseError(
'Error in __getUserMappingAsXML',
'Server');
1154 function searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active) {
1164 global $ilDB, $rbacsystem;
1168 return $this->
__raiseError(
'Check access failed.',
'Server');
1172 if (!count($a_keyfields))
1173 $this->
__raiseError(
'At least one keyfield is needed',
'Client');
1175 if (!count ($a_keyvalues))
1176 $this->
__raiseError(
'At least one keyvalue is needed',
'Client');
1178 if (!strcasecmp($query_operator,
"and")==0 || !strcasecmp($query_operator,
"or") == 0)
1179 $this->
__raiseError(
'Query operator must be either \'and\' or \'or\'',
'Client');
1184 $query =
"SELECT usr_data.*, usr_pref.value AS language
1187 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
1188 $ilDB->quote(
"language",
"text").
1190 WHERE 1 = 1 ".$query;
1192 if (is_numeric($active) && $active > -1)
1193 $query .=
" AND active = ". $ilDB->quote($active);
1195 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
1199 $r = $ilDB->query(
$query);
1203 while(
$row = $ilDB->fetchAssoc($r))
1208 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1211 $xmlWriter->setAttachRoles($attach_roles);
1213 $xmlWriter->setObjects(
$data);
1215 if($xmlWriter->start())
1217 return $xmlWriter->getXML();
1219 return $this->
__raiseError(
'Error in searchUser',
'Server');
1234 $allowed_fields = array (
"firstname",
"lastname",
"email",
"login",
"matriculation",
"institution",
"department",
"title",
"ext_account");
1236 foreach ($a_keyfields as $keyfield)
1238 $keyfield = strtolower($keyfield);
1240 if (!in_array($keyfield, $allowed_fields))
1243 $field_query = array ();
1244 foreach ($a_keyvalues as $keyvalue)
1246 if (strlen($keyvalue) >= 3) {
1247 $field_query []= $keyfield.
" like '%".$keyvalue.
"%'";
1251 if (count($field_query))
1252 $query [] = join(
" ".strtoupper($queryOperator).
" ", $field_query);
1256 return count (
$query) ?
" AND ((". join(
") OR (",
$query) .
"))" :
"AND 0";
1277 global $rbacsystem,
$ilUser, $ilDB;
1281 if(is_array($a_user_ids) and count($a_user_ids) == 1)
1283 if(end($a_user_ids) == $ilUser->getId())
1288 elseif(is_numeric($a_user_ids))
1290 if($a_user_ids == $ilUser->getId())
1296 if(!$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID) and !$is_self)
1298 return $this->
__raiseError(
'Check access failed.',
'Server');
1305 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1307 $xmlWriter->setAttachRoles($attach_roles);
1308 $xmlWriter->setObjects(
$data);
1310 if($xmlWriter->start())
1312 return $xmlWriter->getXML();
1315 return $this->
__raiseError(
'User does not exist',
'Client');
1332 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
1355 $parts = explode(
'::', $sid);
1356 $query =
"SELECT usr_id FROM usr_session "
1357 .
"INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
1358 $res = $ilDB->queryF(
$query, array(
'text'), array($parts[0]));
1361 if(!(
int)
$data[
'usr_id'])
1366 return (
int)$data[
'usr_id'];