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 ;
132 if(strcasecmp($ilUser->getLogin(), $user_name) != 0 && !$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID))
140 return $user_id ? $user_id :
"0";
154 global $rbacsystem, $ilUser;
158 return $this->
__raiseError(
'Check access failed.',
'Server');
161 if($ilUser->getLoginByUserId($user_id))
168 return $this->
__raiseError(
'User does not exist',
'Client');
181 global $rbacsystem, $ilUser,
$log;
185 return $this->
__raiseError(
'Check access failed.',
'Server');
190 return $this->
__raiseError(
'User with id '.$user_data[
'usr_id'].
' does not exist.',
'Client');
201 if(strlen($user_data[
'passwd']) != 32)
211 $log->write(
'SOAP: updateUser()');
214 if($user_data[
'accepted_agreement'] and !$user_obj->hasAcceptedUserAgreement())
216 $user_obj->writeAccepted();
236 return $this->
__raiseError(
'Check access failed.',
'Server');
241 return $this->
__raiseError(
'No valid user_id given.',
'Client');
244 $tmp_user->replacePassword($new_password);
249 function addUser($sid,$user_data,$global_role_id)
263 return $this->
__raiseError(
'Check access failed.',
'Server');
274 return $this->
__raiseError(
'No role id given',
'Client');
279 $global_roles = $rbacreview->getGlobalRoles();
281 if(!in_array($global_role_id,$global_roles))
283 return $this->
__raiseError(
'Role with id: '.$global_role_id.
' is not a valid global role',
'Client');
288 if(strlen($user_data[
'passwd']) != 32)
298 $ilLog->write(
'SOAP: addUser()');
304 if ($user_data[
"import_id"] !=
"")
306 $new_user->setImportId($user_data[
"import_id"]);
315 if($user_data[
'accepted_agreement'])
321 $rbacadmin->assignUser($global_role_id,
$new_user->getId());
324 $new_user->setLanguage($user_data[
'user_language']);
325 $new_user->setPref(
'style',$user_data[
'user_style']);
326 $new_user->setPref(
'skin',$user_data[
'user_skin']);
327 $new_user->setPref(
'hits_per_page',$ilSetting->get(
'hits_per_page'));
328 $new_user->setPref(
'show_users_online',$ilSetting->get(
'show_users_online'));
346 return $this->
__raiseError(
'No user_id given. Aborting',
'Client');
349 global $rbacsystem, $ilUser,
$log;
353 return $this->
__raiseError(
'Check access failed.',
'Server');
356 if(!$ilUser->getLoginByUserId($user_id))
358 return $this->
__raiseError(
'User id: '.$user_id.
' is not a valid identifier. Aborting',
'Client');
360 if($ilUser->getId() == $user_id)
362 return $this->
__raiseError(
'Cannot delete myself. Aborting',
'Client');
364 if($user_id == SYSTEM_USER_ID)
366 return $this->
__raiseError(
'Cannot delete root account. Aborting',
'Client');
369 $log->write(
'SOAP: deleteUser()');
371 $delete_user->delete();
386 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
392 if(!isset($user_data[
'login']))
396 if(!isset($user_data[
'passwd']) and !$allow_empty_password)
400 if(!isset($user_data[
'email']))
404 if(!isset($user_data[
'user_language']))
406 $user_data[
'user_language'] = $lng->getDefaultLanguage();
409 foreach($user_data as $field => $value)
430 if(!strlen($value) and $allow_empty_password)
447 case 'time_limit_unlimited':
450 if($user_data[
'time_limit_from'] >= $user_data[
'time_limit_until'])
457 case 'user_language':
458 $lang_inst = $lng->getInstalledLanguages();
460 if(!in_array($user_data[
'user_language'],$lang_inst))
462 $this->
__appendMessage(
'Language: '.$user_data[
'user_language'].
' is not installed');
469 if(($user_data[
'user_skin'] and !$user_data[
'user_style']) or
470 (!$user_data[
'user_skin'] and $user_data[
'user_style']))
474 elseif($user_data[
'user_skin'] and $user_data[
'user_style'])
477 $templates = $styleDefinition->getAllTemplates();
478 if (count($templates) > 0 && is_array($templates))
480 foreach($templates as $template)
483 $styleDef->startParsing();
484 $styles = $styleDef->getStyles();
485 foreach ($styles as $style)
487 if ($user_data[
'user_skin'] == $template[
"id"] &&
488 $user_data[
'user_style'] == $style[
"id"])
502 case 'time_limit_owner':
504 if($type !=
'cat' and $type !=
'usrf')
506 $this->
__appendMessage(
'time_limit_owner must be ref_id of category or user folder'.$type);
522 if(!$user_data[
'time_limit_from'] and
523 !$user_data[
'time_limit_until'] and
524 !$user_data[
'time_limit_unlimited'])
526 $user_data[
'time_limit_unlimited'] = 1;
528 if(!$user_data[
'time_limit_owner'])
535 $user_data[
'im_icq'] = $user_obj->getInstantMessengerId(
'icq');
536 $user_data[
'im_yahoo'] = $user_obj->getInstantMessengerId(
'yahoo');
537 $user_data[
'im_msn'] = $user_obj->getInstantMessengerId(
'msn');
538 $user_data[
'im_aim'] = $user_obj->getInstantMessengerId(
'aim');
539 $user_data[
'im_skype'] = $user_obj->getInstantMessengerId(
'skype');
540 $user_data[
'im_jabber'] = $user_obj->getInstantMessengerId(
'jabber');
541 $user_data[
'im_voip'] = $user_obj->getInstantMessengerId(
'voip');
543 $user_data[
'delicious'] = $user_obj->getDelicious();
544 $user_data[
'latitude'] = $user_obj->getLatitude();
545 $user_data[
'longitude'] = $user_obj->getLongitude();
546 $user_data[
'loc_zoom'] = $user_obj->getLocationZoom();
549 $user_data[
'auth_mode'] = $user_obj->getAuthMode();
550 $user_data[
'ext_account'] = $user_obj->getExternalAccount();
551 $user_obj->assignData($user_data);
553 if(isset($user_data[
'user_language']))
555 $user_obj->setLanguage($user_data[
'user_language']);
557 if(isset($user_data[
'user_skin']) and isset($user_data[
'user_style']))
559 $user_obj->setPref(
'skin',$user_data[
'user_skin']);
560 $user_obj->setPref(
'style',$user_data[
'user_style']);
567 $usr_data[
'usr_id'] = $usr_obj->getId();
568 $usr_data[
'login'] = $usr_obj->getLogin();
569 $usr_data[
'passwd'] = $usr_obj->getPasswd();
570 $usr_data[
'passwd_type'] = $usr_obj->getPasswdType();
571 $usr_data[
'firstname'] = $usr_obj->getFirstname();
572 $usr_data[
'lastname'] = $usr_obj->getLastname();
573 $usr_data[
'title'] = $usr_obj->getUTitle();
574 $usr_data[
'gender'] = $usr_obj->getGender();
575 $usr_data[
'email'] = $usr_obj->getEmail();
576 $usr_data[
'institution'] = $usr_obj->getInstitution();
577 $usr_data[
'street'] = $usr_obj->getStreet();
578 $usr_data[
'city'] = $usr_obj->getCity();
579 $usr_data[
'zipcode'] = $usr_obj->getZipcode();
580 $usr_data[
'country'] = $usr_obj->getCountry();
581 $usr_data[
'phone_office'] = $usr_obj->getPhoneOffice();
582 $usr_data[
'last_login'] = $usr_obj->getLastLogin();
583 $usr_data[
'last_update'] = $usr_obj->getLastUpdate();
584 $usr_data[
'create_date'] = $usr_obj->getCreateDate();
585 $usr_data[
'hobby'] = $usr_obj->getHobby();
586 $usr_data[
'department'] = $usr_obj->getDepartment();
587 $usr_data[
'phone_home'] = $usr_obj->getPhoneHome();
588 $usr_data[
'phone_mobile'] = $usr_obj->getPhoneMobile();
589 $usr_data[
'fax'] = $usr_obj->getFax();
590 $usr_data[
'time_limit_owner'] = $usr_obj->getTimeLimitOwner();
591 $usr_data[
'time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
592 $usr_data[
'time_limit_from'] = $usr_obj->getTimeLimitFrom();
593 $usr_data[
'time_limit_until'] = $usr_obj->getTimeLimitUntil();
594 $usr_data[
'time_limit_message'] = $usr_obj->getTimeLimitMessage();
595 $usr_data[
'referral_comment'] = $usr_obj->getComment();
596 $usr_data[
'matriculation'] = $usr_obj->getMatriculation();
597 $usr_data[
'active'] = $usr_obj->getActive();
598 $usr_data[
'approve_date'] = $usr_obj->getApproveDate();
599 $usr_data[
'user_skin'] = $usr_obj->getPref(
'skin');
600 $usr_data[
'user_style'] = $usr_obj->getPref(
'style');
601 $usr_data[
'user_language'] = $usr_obj->getLanguage();
602 $usr_data[
'auth_mode'] = $usr_obj->getAuthMode();
603 $usr_data[
'accepted_agreement'] = $usr_obj->hasAcceptedUserAgreement();
604 $usr_data[
'import_id'] = $usr_obj->getImportId();
611 foreach($user_new as $key => $value)
613 $user_old[$key] = $value;
615 return $user_old ? $user_old : array();
624 function importUsers ($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
635 include_once
'./Services/User/classes/class.ilUserImportParser.php';
636 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
637 include_once
'./classes/class.ilObjectFactory.php';
638 global $rbacreview, $rbacsystem, $tree,
$lng,$ilUser,
$ilLog;
649 if (is_array($error))
651 foreach ($error as $err) {
652 $msg []=
"(".$err[
"line"].
",".$err[
"col"].
"): ".$err[
"errormessage"];
659 $msg = join(
"\n",$msg);
664 switch ($conflict_rule)
682 if ($folder_id == -1)
689 return $this->
__raiseError(
'Wrong reference id.',
'Server');
692 if ($import_folder->getType() !=
"usrf" && $import_folder->getType() !=
"cat")
693 return $this->
__raiseError(
'Folder must be a usr folder or a category.',
'Server');
696 if(!$rbacsystem->checkAccess(
'create_usr',$folder_id))
698 return $this->
__raiseError(
'Missing permission for creating users within '.$import_folder->getTitle(),
'Server');
707 $importParser->setXMLContent($usr_xml);
708 $importParser->startParsing();
710 switch ($importParser->getErrorLevel())
724 $importParser->setXMLContent($usr_xml);
726 $importParser->startParsing();
728 $roles = $importParser->getCollectedRoles();
735 $permitted_roles = array();
736 foreach ($roles as $role_id => $role)
738 if (!is_numeric ($role_id))
743 if (is_numeric($internalId))
745 $role_id = $internalId;
746 $role_name = $role_id;
758 $permitted_roles[$role_id] = $role_id;
763 return $this->
__raiseError(
"Could not find role ".$role_name.
". Either you use an invalid/deleted role ".
764 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
'Server');
768 $global_roles = $rbacreview->getGlobalRoles();
774 foreach ($permitted_roles as $role_id => $role_name)
778 if (in_array($role_id, $global_roles))
780 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
784 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
'Server');
789 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
790 if ($rbacreview->isDeleted($rolf[0])
791 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
794 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
"Server");
803 $importParser->setSendMail($send_account_mail);
805 $importParser->setFolderId($folder_id);
806 $importParser->setXMLContent($usr_xml);
808 $importParser->setRoleAssignment($permitted_roles);
810 $importParser->startParsing();
829 static $checked_roles = array();
830 static $global_roles = null;
833 if(isset($checked_roles[$a_role]))
835 return $checked_roles[$a_role];
838 global $rbacsystem,$rbacreview,$ilUser,$tree,
$ilLog;
840 $locations = $rbacreview->getFoldersAssignedToRole($a_role,
true);
846 $ilLog->write(__METHOD__.
': Check global role');
852 $ilLog->write(__METHOD__.
': '.$a_folder);
853 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
856 $ilLog->write(__METHOD__.
': No assignment allowed');
857 $checked_roles[$a_role] =
false;
862 if ($a_role == ANONYMOUS_ROLE_ID)
864 $ilLog->write(__METHOD__.
': Anonymous role chosen.');
865 $checked_roles[$a_role] =
false;
869 if($a_role == SYSTEM_ROLE_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
871 $ilLog->write(__METHOD__.
': System role assignment forbidden.');
872 $checked_roles[$a_role] =
false;
877 $ilLog->write(__METHOD__.
': Assignment allowed.');
878 $checked_roles[$a_role] =
true;
883 $ilLog->write(__METHOD__.
': Check local role.');
886 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,
true);
894 if($rbacreview->isDeleted($rolf)
895 || !$rbacsystem->checkAccess(
'edit_permission',$tree->getParentId($rolf)))
897 $ilLog->write(__METHOD__.
': Role deleted or no permission.');
898 $checked_roles[$a_role] =
false;
909 if($a_folder !=
USER_FOLDER_ID and $a_folder != 0 and !$tree->isGrandChild($a_folder,$rolf))
911 $ilLog->write(__METHOD__.
': Not in path of category.');
912 $checked_roles[$a_role] =
false;
915 $ilLog->write(__METHOD__.
': Assignment allowed.');
916 $checked_roles[$a_role] =
true;
935 global
$ilDB, $tree, $rbacreview, $rbacsystem;
945 switch ($object->getType()) {
955 $roles = $object->__getLocalRoles();
957 foreach($roles as $role_id)
959 $data = array_merge($rbacreview->assignedUsers($role_id, array()),
$data);
965 $member_ids = $object->getGroupMemberIds();
969 $course_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
972 return $this->
__raiseError(
"No course for session",
"Client");
976 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
978 $member_ids = array_keys($event_part->getParticipants());
985 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
988 $xmlWriter->setObjects(
$data);
989 $xmlWriter->setAttachRoles ($attachRoles);
991 if($xmlWriter->start())
993 return $xmlWriter->getXML();
996 return $this->
__raiseError(
'Error in processing information. This is likely a bug.',
'Server');
1013 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1014 global
$ilDB, $rbacreview, $rbacsystem, $tree,$ilUser;
1017 $global_roles = $rbacreview->getGlobalRoles();
1020 if (in_array($role_id, $global_roles))
1022 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
1025 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1030 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
1031 if ($rbacreview->isDeleted($rolf[0])
1032 || ! $rbacsystem->checkAccess(
'write',$tree->getParentId($rolf[0])))
1034 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
1036 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1038 if(!$rbacsystem->checkAccess(
'read',SYSTEM_USER_ID) and
1039 !$rbacsystem->checkAccess(
'export_member_data',$privacy->getPrivacySettingsRefId())) {
1040 return $this->
__raiseError(
"Export of local role members not permitted. ($role_id)",
"Server");
1047 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1050 $xmlWriter->setAttachRoles($attachRoles);
1052 $xmlWriter->setObjects(
$data);
1054 if($xmlWriter->start())
1056 return $xmlWriter->getXML();
1058 return $this->
__raiseError(
'Error in getUsersForRole',
'Server');
1069 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1070 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1073 $xmlResultSet->addColumn (
"userid");
1074 $xmlResultSet->addColumn (
"login");
1075 $xmlResultSet->addColumn (
"action");
1076 $xmlResultSet->addColumn (
"message");
1078 foreach ($a_array as $username =>
$messages)
1084 $xmlRow->setValue (0, 0);
1085 $xmlRow->setValue (1, $username);
1086 $xmlRow->setValue (2,
"");
1087 $xmlRow->setValue (3, $message);
1089 $xmlResultSet->addRow ($xmlRow);
1095 if ($xml_writer->start ())
1096 return $xml_writer->getXML();
1098 return $this->
__raiseError(
'Error in __getImportProtocolAsXML',
'Server');
1109 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
1110 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
1113 $xmlResultSet->addColumn (
"userid");
1114 $xmlResultSet->addColumn (
"login");
1115 $xmlResultSet->addColumn (
"action");
1116 $xmlResultSet->addColumn (
"message");
1118 if (count($a_array))
1119 foreach ($a_array as $username => $message)
1122 $xmlRow->setValue (0, $username);
1123 $xmlRow->setValue (1, $message[
"login"]);
1124 $xmlRow->setValue (2, $message[
"action"]);
1125 $xmlRow->setValue (3, $message[
"message"]);
1127 $xmlResultSet->addRow ($xmlRow);
1132 if ($xml_writer->start ())
1133 return $xml_writer->getXML();
1135 return $this->
__raiseError(
'Error in __getUserMappingAsXML',
'Server');
1147 function searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active) {
1157 global
$ilDB, $rbacsystem;
1161 return $this->
__raiseError(
'Check access failed.',
'Server');
1165 if (!count($a_keyfields))
1166 $this->
__raiseError(
'At least one keyfield is needed',
'Client');
1168 if (!count ($a_keyvalues))
1169 $this->
__raiseError(
'At least one keyvalue is needed',
'Client');
1171 if (!strcasecmp($query_operator,
"and")==0 || !strcasecmp($query_operator,
"or") == 0)
1172 $this->
__raiseError(
'Query operator must be either \'and\' or \'or\'',
'Client');
1177 $query =
"SELECT usr_data.*, usr_pref.value AS language
1180 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
1181 $ilDB->quote(
"language",
"text").
1183 WHERE 1 = 1 ".$query;
1185 if (is_numeric($active) && $active > -1)
1186 $query .=
" AND active = ". $ilDB->quote($active);
1188 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
1192 $r = $ilDB->query(
$query);
1196 while(
$row = $ilDB->fetchAssoc($r))
1201 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1204 $xmlWriter->setAttachRoles($attach_roles);
1206 $xmlWriter->setObjects(
$data);
1208 if($xmlWriter->start())
1210 return $xmlWriter->getXML();
1212 return $this->
__raiseError(
'Error in searchUser',
'Server');
1227 $allowed_fields = array (
"firstname",
"lastname",
"email",
"login",
"matriculation",
"institution",
"department",
"title",
"ext_account");
1229 foreach ($a_keyfields as $keyfield)
1231 $keyfield = strtolower($keyfield);
1233 if (!in_array($keyfield, $allowed_fields))
1236 $field_query = array ();
1237 foreach ($a_keyvalues as $keyvalue)
1239 if (strlen($keyvalue) >= 3) {
1240 $field_query []= $keyfield.
" like '%".$keyvalue.
"%'";
1244 if (count($field_query))
1245 $query [] = join(
" ".strtoupper($queryOperator).
" ", $field_query);
1249 return count (
$query) ?
" AND ((". join(
") OR (",
$query) .
"))" :
"AND 0";
1270 global $rbacsystem, $ilUser,
$ilDB;
1274 return $this->
__raiseError(
'Check access failed.',
'Server');
1279 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1281 $xmlWriter->setAttachRoles($attach_roles);
1282 $xmlWriter->setObjects(
$data);
1284 if($xmlWriter->start())
1286 return $xmlWriter->getXML();
1289 return $this->
__raiseError(
'User does not exist',
'Client');
1306 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
1329 $parts = explode(
'::', $sid);
1330 $query =
"SELECT usr_id FROM usr_session "
1331 .
"INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
1332 $res = $ilDB->queryF(
$query, array(
'text'), array($parts[0]));
1335 if(!(
int)
$data[
'usr_id'])
1340 return (
int)$data[
'usr_id'];