ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSoapUserAdministration Class Reference
+ Inheritance diagram for ilSoapUserAdministration:
+ Collaboration diagram for ilSoapUserAdministration:

Public Member Functions

 loginCAS ($client, $PT, $username)
 
 loginLDAP ($client, $username, $password)
 Not required anymode. More...
 
 loginStudipUser ($sid, $user_id)
 login as user from Stud.IP More...
 
 logout ($sid)
 Logout user destroy session. More...
 
 lookupUser ($sid, $user_name)
 
 getUser ($sid, $user_id)
 
 deleteUser ($sid, $user_id)
 
 __readUserData (&$usr_obj)
 
 importUsers ($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
 define ("IL_FAIL_ON_CONFLICT", 1); define ("IL_UPDATE_ON_CONFLICT", 2); define ("IL_IGNORE_ON_CONFLICT", 3); More...
 
 getUsersForContainer ($sid, $ref_id, $attachRoles, $active)
 return list of users following dtd users_3_7 More...
 
 getUserForRole ($sid, $role_id, $attachRoles, $active)
 
 __getImportProtocolAsXML ($a_array)
 Create XML ResultSet. More...
 
 __getUserMappingAsXML ($a_array)
 return user mapping as xml More...
 
 searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active)
 return user xml following dtd 3.7 More...
 
 __buildSearchQuery ($a_keyfields, $queryOperator, $a_keyvalues)
 create search term according to parameters More...
 
 getUserXML ($sid, $a_user_ids, $attach_roles)
 return user xmls for given user ids (csv separated ids) as xml based on usr dtd. More...
 
 hasNewMail ($sid)
 
 getUserIdBySid ($sid)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Protected Member Functions

 isPermittedRole ($a_folder, $a_role)
 check if assignment is allowed More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

Definition at line 35 of file class.ilSoapUserAdministration.php.

Member Function Documentation

◆ __buildSearchQuery()

ilSoapUserAdministration::__buildSearchQuery (   $a_keyfields,
  $queryOperator,
  $a_keyvalues 
)

create search term according to parameters

Parameters
arrayof string $a_keyfields
string$queryOperator
arrayof string $a_keyValues

Definition at line 963 of file class.ilSoapUserAdministration.php.

963 {
964 global $ilDB;
965 $query = array();
966
967 $allowed_fields = array ("firstname","lastname","email","login","matriculation","institution","department","title","ext_account");
968
969 foreach ($a_keyfields as $keyfield)
970 {
971 $keyfield = strtolower($keyfield);
972
973 if (!in_array($keyfield, $allowed_fields))
974 continue;
975
976 $field_query = array ();
977 foreach ($a_keyvalues as $keyvalue)
978 {
979 if (strlen($keyvalue) >= 3) {
980 $field_query []= $keyfield." like '%".$keyvalue."%'";
981 }
982
983 }
984 if (count($field_query))
985 $query [] = join(" ".strtoupper($queryOperator)." ", $field_query);
986
987 }
988
989 return count ($query) ? " AND ((". join(") OR (", $query) ."))" : "AND 0";
990 }
global $ilDB

References $ilDB, and $query.

Referenced by searchUser().

+ Here is the caller graph for this function:

◆ __getImportProtocolAsXML()

ilSoapUserAdministration::__getImportProtocolAsXML (   $a_array)

Create XML ResultSet.

Definition at line 807 of file class.ilSoapUserAdministration.php.

808 {
809 include_once './webservice/soap/classes/class.ilXMLResultSet.php';
810 include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
811
812 $xmlResultSet = new ilXMLResultSet ();
813 $xmlResultSet->addColumn ("userid");
814 $xmlResultSet->addColumn ("login");
815 $xmlResultSet->addColumn ("action");
816 $xmlResultSet->addColumn ("message");
817
818 foreach ($a_array as $username => $messages)
819 {
820 foreach ($messages as $message)
821 {
822
823 $xmlRow = new ilXMLResultSetRow ();
824 $xmlRow->setValue (0, 0);
825 $xmlRow->setValue (1, $username);
826 $xmlRow->setValue (2, "");
827 $xmlRow->setValue (3, $message);
828
829 $xmlResultSet->addRow ($xmlRow);
830 }
831 }
832
833 $xml_writer = new ilXMLResultSetWriter ($xmlResultSet);
834
835 if ($xml_writer->start ())
836 return $xml_writer->getXML();
837
838 return $this->__raiseError('Error in __getImportProtocolAsXML','Server');
839 }
__raiseError($a_message, $a_code)
XML Writer for XMLResultSet.
$messages
Definition: en-x-test.php:7

References $messages, and ilSoapAdministration\__raiseError().

Referenced by importUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getUserMappingAsXML()

ilSoapUserAdministration::__getUserMappingAsXML (   $a_array)

return user mapping as xml

Parameters
array(user_id => login) $a_array
Returns
XML String, following resultset.dtd

Definition at line 847 of file class.ilSoapUserAdministration.php.

848 {
849 include_once './webservice/soap/classes/class.ilXMLResultSet.php';
850 include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
851
852 $xmlResultSet = new ilXMLResultSet ();
853 $xmlResultSet->addColumn ("userid");
854 $xmlResultSet->addColumn ("login");
855 $xmlResultSet->addColumn ("action");
856 $xmlResultSet->addColumn ("message");
857
858 if (count($a_array))
859 foreach ($a_array as $username => $message)
860 {
861 $xmlRow = new ilXMLResultSetRow ();
862 $xmlRow->setValue (0, $username);
863 $xmlRow->setValue (1, $message["login"]);
864 $xmlRow->setValue (2, $message["action"]);
865 $xmlRow->setValue (3, $message["message"]);
866
867 $xmlResultSet->addRow ($xmlRow);
868 }
869
870 $xml_writer = new ilXMLResultSetWriter ( $xmlResultSet);
871
872 if ($xml_writer->start ())
873 return $xml_writer->getXML();
874
875 return $this->__raiseError('Error in __getUserMappingAsXML','Server');
876
877 }

References ilSoapAdministration\__raiseError().

Referenced by importUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __readUserData()

ilSoapUserAdministration::__readUserData ( $usr_obj)

Definition at line 314 of file class.ilSoapUserAdministration.php.

315 {
316 $usr_data['usr_id'] = $usr_obj->getId();
317 $usr_data['login'] = $usr_obj->getLogin();
318 $usr_data['passwd'] = $usr_obj->getPasswd();
319 $usr_data['passwd_type'] = $usr_obj->getPasswdType();
320 $usr_data['firstname'] = $usr_obj->getFirstname();
321 $usr_data['lastname'] = $usr_obj->getLastname();
322 $usr_data['title'] = $usr_obj->getUTitle();
323 $usr_data['gender'] = $usr_obj->getGender();
324 $usr_data['email'] = $usr_obj->getEmail();
325 $usr_data['institution'] = $usr_obj->getInstitution();
326 $usr_data['street'] = $usr_obj->getStreet();
327 $usr_data['city'] = $usr_obj->getCity();
328 $usr_data['zipcode'] = $usr_obj->getZipcode();
329 $usr_data['country'] = $usr_obj->getCountry();
330 $usr_data['phone_office'] = $usr_obj->getPhoneOffice();
331 $usr_data['last_login'] = $usr_obj->getLastLogin();
332 $usr_data['last_update'] = $usr_obj->getLastUpdate();
333 $usr_data['create_date'] = $usr_obj->getCreateDate();
334 $usr_data['hobby'] = $usr_obj->getHobby();
335 $usr_data['department'] = $usr_obj->getDepartment();
336 $usr_data['phone_home'] = $usr_obj->getPhoneHome();
337 $usr_data['phone_mobile'] = $usr_obj->getPhoneMobile();
338 $usr_data['fax'] = $usr_obj->getFax();
339 $usr_data['time_limit_owner'] = $usr_obj->getTimeLimitOwner();
340 $usr_data['time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
341 $usr_data['time_limit_from'] = $usr_obj->getTimeLimitFrom();
342 $usr_data['time_limit_until'] = $usr_obj->getTimeLimitUntil();
343 $usr_data['time_limit_message'] = $usr_obj->getTimeLimitMessage();
344 $usr_data['referral_comment'] = $usr_obj->getComment();
345 $usr_data['matriculation'] = $usr_obj->getMatriculation();
346 $usr_data['active'] = $usr_obj->getActive();
347 $usr_data['approve_date'] = $usr_obj->getApproveDate();
348 $usr_data['user_skin'] = $usr_obj->getPref('skin');
349 $usr_data['user_style'] = $usr_obj->getPref('style');
350 $usr_data['user_language'] = $usr_obj->getLanguage();
351 $usr_data['auth_mode'] = $usr_obj->getAuthMode();
352 $usr_data['accepted_agreement'] = !$usr_obj->hasToAcceptTermsOfService();
353 $usr_data['import_id'] = $usr_obj->getImportId();
354
355 return $usr_data;
356 }

Referenced by getUser().

+ Here is the caller graph for this function:

◆ deleteUser()

ilSoapUserAdministration::deleteUser (   $sid,
  $user_id 
)
Deprecated:

Definition at line 272 of file class.ilSoapUserAdministration.php.

273 {
274 $this->initAuth($sid);
275 $this->initIlias();
276
277 if(!$this->__checkSession($sid))
278 {
279 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
280 }
281
282 if(!isset($user_id))
283 {
284 return $this->__raiseError('No user_id given. Aborting','Client');
285 }
286
287 global $rbacsystem, $ilUser, $log;
288
289 if(!$rbacsystem->checkAccess('delete',USER_FOLDER_ID))
290 {
291 return $this->__raiseError('Check access failed.','Server');
292 }
293
294 if(!$ilUser->getLoginByUserId($user_id))
295 {
296 return $this->__raiseError('User id: '.$user_id.' is not a valid identifier. Aborting','Client');
297 }
298 if($ilUser->getId() == $user_id)
299 {
300 return $this->__raiseError('Cannot delete myself. Aborting','Client');
301 }
302 if($user_id == SYSTEM_USER_ID)
303 {
304 return $this->__raiseError('Cannot delete root account. Aborting','Client');
305 }
306 // Delete him
307 $log->write('SOAP: deleteUser()');
308 $delete_user =& ilObjectFactory::getInstanceByObjId($user_id,false);
309 $delete_user->delete();
310
311 return true;
312 }
const USER_FOLDER_ID
Class ilObjUserFolder.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
$ilUser
Definition: imgupload.php:18

References $ilUser, $log, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ getUser()

ilSoapUserAdministration::getUser (   $sid,
  $user_id 
)

Definition at line 241 of file class.ilSoapUserAdministration.php.

242 {
243 $this->initAuth($sid);
244 $this->initIlias();
245
246 if(!$this->__checkSession($sid))
247 {
248 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
249 }
250
251 global $rbacsystem, $ilUser;
252
253 if(!$rbacsystem->checkAccess('read',USER_FOLDER_ID))
254 {
255 return $this->__raiseError('Check access failed.','Server');
256 }
257
258 if($ilUser->getLoginByUserId($user_id))
259 {
260 $tmp_user =& ilObjectFactory::getInstanceByObjId($user_id);
261 $usr_data = $this->__readUserData($tmp_user);
262
263 return $usr_data;
264 }
265 return $this->__raiseError('User does not exist','Client');
266 }

References $ilUser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), __readUserData(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ getUserForRole()

ilSoapUserAdministration::getUserForRole (   $sid,
  $role_id,
  $attachRoles,
  $active 
)
Returns
list of users of a specific role, following dtd users_3_7

Definition at line 743 of file class.ilSoapUserAdministration.php.

744 {
745 $this->initAuth($sid);
746 $this->initIlias();
747
748 if(!$this->__checkSession($sid))
749 {
750 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
751 }
752
753 include_once './Services/AccessControl/classes/class.ilObjRole.php';
754 global $ilDB, $rbacreview, $rbacsystem, $tree,$ilUser;
755
756
757 $global_roles = $rbacreview->getGlobalRoles();
758
759
760 if (in_array($role_id, $global_roles))
761 {
762 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
763 )
764 {
765 return $this->__raiseError("Role access not permitted. ($role_id)","Server");
766 }
767 }
768 else
769 {
770 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,true);
771 if ($rbacreview->isDeleted($rolf[0])
772 || ! $rbacsystem->checkAccess('write',$rolf[0]))
773 {
774 return $this->__raiseError("Role access not permitted. ($role_id)","Server");
775 }
776 include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
778 if(!$rbacsystem->checkAccess('read',SYSTEM_USER_ID) and
779 !$rbacsystem->checkAccess('export_member_data',$privacy->getPrivacySettingsRefId())) {
780 return $this->__raiseError("Export of local role members not permitted. ($role_id)","Server");
781 }
782
783
784 }
785
786 $data = ilObjUser::_getUsersForRole($role_id, $active);
787 include_once './Services/User/classes/class.ilUserXMLWriter.php';
788
789 $xmlWriter = new ilUserXMLWriter();
790 $xmlWriter->setAttachRoles($attachRoles);
791
792 $xmlWriter->setObjects($data);
793
794 if($xmlWriter->start())
795 {
796 return $xmlWriter->getXML();
797 }
798 return $this->__raiseError('Error in getUsersForRole','Server');
799 }
static _getUsersForRole($role_id, $active=-1)
return array of complete users which belong to a specific role
static _getInstance()
Get instance of ilPrivacySettings.
XML writer class.

References $data, $ilDB, $ilUser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilPrivacySettings\_getInstance(), ilObjUser\_getUsersForRole(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ getUserIdBySid()

ilSoapUserAdministration::getUserIdBySid (   $sid)

Definition at line 1076 of file class.ilSoapUserAdministration.php.

1077 {
1078 $this->initAuth($sid);
1079 $this->initIlias();
1080
1081 if(!$this->__checkSession($sid))
1082 {
1083 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1084 }
1085
1086 global $ilDB;
1087
1088 $parts = explode('::', $sid);
1089 $query = "SELECT usr_id FROM usr_session "
1090 . "INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
1091 $res = $ilDB->queryF($query, array('text'), array($parts[0]));
1092 $data = $ilDB->fetchAssoc($res);
1093
1094 if(!(int)$data['usr_id'])
1095 {
1096 $this->__raiseError('User does not exist', 'Client');
1097 }
1098
1099 return (int)$data['usr_id'];
1100 }

References $data, $ilDB, $query, $res, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ getUsersForContainer()

ilSoapUserAdministration::getUsersForContainer (   $sid,
  $ref_id,
  $attachRoles,
  $active 
)

return list of users following dtd users_3_7

Definition at line 665 of file class.ilSoapUserAdministration.php.

666 {
667 $this->initAuth($sid);
668 $this->initIlias();
669
670 if(!$this->__checkSession($sid))
671 {
672 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
673 }
674
675 global $ilDB, $tree, $rbacreview, $rbacsystem;
676
677 if ($ref_id == -1)
679
680 $object = $this->checkObjectAccess($ref_id, array("crs","cat","grp","usrf","sess"), "read", true);
681 if ($this->isFault($object))
682 return $object;
683
684 $data = array();
685 switch ($object->getType()) {
686 case "usrf":
688 break;
689 case "cat":
691 break;
692 case "crs":
693 {
694 // GET ALL MEMBERS
695 $roles = $object->__getLocalRoles();
696
697 foreach($roles as $role_id)
698 {
699 $data = array_merge($rbacreview->assignedUsers($role_id),$data);
700 }
701
702 break;
703 }
704 case "grp":
705 $member_ids = $object->getGroupMemberIds();
706 $data = ilObjUser::_getUsersForGroup($member_ids, $active);
707 break;
708 case "sess":
709 $course_ref_id = $tree->checkForParentType($ref_id,'crs');
710 if(!$course_ref_id)
711 {
712 return $this->__raiseError("No course for session", "Client");
713 }
714
715 $event_obj_id = ilObject::_lookupObjId($ref_id);
716 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
717 $event_part = new ilEventParticipants($event_obj_id);
718 $member_ids = array_keys($event_part->getParticipants());
719 $data = ilObjUser::_getUsersForIds($member_ids, $active);
720 break;
721 }
722
723 if (is_array($data))
724 {
725 include_once './Services/User/classes/class.ilUserXMLWriter.php';
726
727 $xmlWriter = new ilUserXMLWriter();
728 $xmlWriter->setObjects($data);
729 $xmlWriter->setAttachRoles ($attachRoles);
730
731 if($xmlWriter->start())
732 {
733 return $xmlWriter->getXML();
734 }
735 }
736 return $this->__raiseError('Error in processing information. This is likely a bug.','Server');
737 }
static _getUsersForIds($a_mem_ids, $active=-1, $timelimitowner=-1)
return user data for given user id
static _getUsersForFolder($ref_id, $active)
static _getUsersForGroup($a_mem_ids, $active=-1)
return user data for group members
static _lookupObjId($a_id)
checkObjectAccess($ref_id, $expected_type, $permission, $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true
$ref_id
Definition: sahs_server.php:39

References $data, $ilDB, $ref_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjUser\_getUsersForFolder(), ilObjUser\_getUsersForGroup(), ilObjUser\_getUsersForIds(), ilObject\_lookupObjId(), ilSoapAdministration\checkObjectAccess(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ getUserXML()

ilSoapUserAdministration::getUserXML (   $sid,
  $a_user_ids,
  $attach_roles 
)

return user xmls for given user ids (csv separated ids) as xml based on usr dtd.

Parameters
stringsid session id
stringa_userids array of user ids, may be numeric or ilias ids
booleanattachRoles if true, role assignments will be attached, nothing will be done otherwise
Returns
string xml string based on usr dtd

Definition at line 1000 of file class.ilSoapUserAdministration.php.

1001 {
1002 $this->initAuth($sid);
1003 $this->initIlias();
1004
1005 if(!$this->__checkSession($sid))
1006 {
1007 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1008 }
1009
1010 global $rbacsystem, $ilUser, $ilDB;
1011
1012 // check if own account
1013 $is_self = false;
1014 if(is_array($a_user_ids) and count($a_user_ids) == 1)
1015 {
1016 if(end($a_user_ids) == $ilUser->getId())
1017 {
1018 $is_self = true;
1019 }
1020 }
1021 elseif(is_numeric($a_user_ids))
1022 {
1023 if($a_user_ids == $ilUser->getId())
1024 {
1025 $is_self = true;
1026 }
1027 }
1028
1029 if(!$rbacsystem->checkAccess('read',USER_FOLDER_ID) and !$is_self)
1030 {
1031 return $this->__raiseError('Check access failed.','Server');
1032 }
1033
1034 // begin-patch filemanager
1035 $data = ilObjUser::_getUserData((array) $a_user_ids);
1036 // end-patch filemanager
1037
1038 include_once './Services/User/classes/class.ilUserXMLWriter.php';
1039 $xmlWriter = new ilUserXMLWriter();
1040 $xmlWriter->setAttachRoles($attach_roles);
1041 $xmlWriter->setObjects($data);
1042
1043 if($xmlWriter->start())
1044 {
1045 return $xmlWriter->getXML();
1046 }
1047
1048 return $this->__raiseError('User does not exist','Client');
1049 }
static _getUserData($a_internalids)
return user data for given user ids

References $data, $ilDB, $ilUser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjUser\_getUserData(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ hasNewMail()

ilSoapUserAdministration::hasNewMail (   $sid)

Definition at line 1053 of file class.ilSoapUserAdministration.php.

1054 {
1055 $this->initAuth($sid);
1056 $this->initIlias();
1057
1058 if(!$this->__checkSession($sid))
1059 {
1060 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1061 }
1062
1063 global $ilUser;
1064
1065 include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
1067 {
1068 return true;
1069 }
1070 else
1071 {
1072 return false;
1073 }
1074 }
static getNumberOfNewMailsByUserId($usr_id)
Determines the number of new mails for the passed user id and stores this information in a local cach...

References $ilUser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilMailGlobalServices\getNumberOfNewMailsByUserId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ importUsers()

ilSoapUserAdministration::importUsers (   $sid,
  $folder_id,
  $usr_xml,
  $conflict_rule,
  $send_account_mail 
)

define ("IL_FAIL_ON_CONFLICT", 1); define ("IL_UPDATE_ON_CONFLICT", 2); define ("IL_IGNORE_ON_CONFLICT", 3);

Definition at line 364 of file class.ilSoapUserAdministration.php.

365 {
366 $this->initAuth($sid);
367 $this->initIlias();
368
369 if(!$this->__checkSession($sid))
370 {
371 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
372 }
373
374
375 include_once './Services/User/classes/class.ilUserImportParser.php';
376 include_once './Services/AccessControl/classes/class.ilObjRole.php';
377 include_once './Services/Object/classes/class.ilObjectFactory.php';
378 global $rbacreview, $rbacsystem, $tree, $lng,$ilUser,$ilLog;
379
380 // this takes time but is nescessary
381 $error = false;
382
383
384 // validate to prevent wrong XMLs
385 $this->dom = @domxml_open_mem($usr_xml, DOMXML_LOAD_VALIDATING, $error);
386 if ($error)
387 {
388 $msg = array();
389 if (is_array($error))
390 {
391 foreach ($error as $err) {
392 $msg []= "(".$err["line"].",".$err["col"]."): ".$err["errormessage"];
393 }
394 }
395 else
396 {
397 $msg[] = $error;
398 }
399 $msg = join("\n",$msg);
400 return $this->__raiseError($msg, "Client");
401 }
402
403
404 switch ($conflict_rule)
405 {
406 case 2:
407 $conflict_rule = IL_UPDATE_ON_CONFLICT;
408 break;
409 case 3:
410 $conflict_rule = IL_IGNORE_ON_CONFLICT;
411 break;
412 default:
413 $conflict_rule = IL_FAIL_ON_CONFLICT;
414 }
415
416
417 // folder id 0, means to check permission on user basis!
418 // must have create user right in time_limit_owner property (which is ref_id of container)
419 if ($folder_id != 0)
420 {
421 // determine where to import
422 if ($folder_id == -1)
423 $folder_id = USER_FOLDER_ID;
424
425 // get folder
426 $import_folder = ilObjectFactory::getInstanceByRefId($folder_id, false);
427 // id does not exist
428 if (!$import_folder)
429 return $this->__raiseError('Wrong reference id.','Server');
430
431 // folder is not a folder, can also be a category
432 if ($import_folder->getType() != "usrf" && $import_folder->getType() != "cat")
433 return $this->__raiseError('Folder must be a usr folder or a category.','Server');
434
435 // check access to folder
436 if(!$rbacsystem->checkAccess('create_usr',$folder_id))
437 {
438 return $this->__raiseError('Missing permission for creating users within '.$import_folder->getTitle(),'Server');
439 }
440 }
441
442 // first verify
443
444
445 $importParser = new ilUserImportParser("", IL_VERIFY, $conflict_rule);
446 $importParser->setUserMappingMode(IL_USER_MAPPING_ID);
447 $importParser->setXMLContent($usr_xml);
448 $importParser->startParsing();
449
450 switch ($importParser->getErrorLevel())
451 {
452 case IL_IMPORT_SUCCESS :
453 break;
454 case IL_IMPORT_WARNING :
455 return $this->__getImportProtocolAsXML ($importParser->getProtocol("User Import Log - Warning"));
456 break;
457 case IL_IMPORT_FAILURE :
458 return $this->__getImportProtocolAsXML ($importParser->getProtocol("User Import Log - Failure"));
459 }
460
461 // verify is ok, so get role assignments
462
463 $importParser = new ilUserImportParser("", IL_EXTRACT_ROLES, $conflict_rule);
464 $importParser->setXMLContent($usr_xml);
465 $importParser->setUserMappingMode(IL_USER_MAPPING_ID);
466 $importParser->startParsing();
467
468 $roles = $importParser->getCollectedRoles();
469
470 //print_r($roles);
471
472
473
474 // roles to be assigned, skip if one is not allowed!
475 $permitted_roles = array();
476 foreach ($roles as $role_id => $role)
477 {
478 if (!is_numeric ($role_id))
479 {
480 // check if internal id
481 $internalId = ilUtil::__extractId($role_id, IL_INST_ID);
482
483 if (is_numeric($internalId))
484 {
485 $role_id = $internalId;
486 $role_name = $role_id;
487 }
488/* else // perhaps it is a rolename
489 {
490 $role = ilSoapUserAdministration::__getRoleForRolename ($role_id);
491 $role_name = $role->title;
492 $role_id = $role->role_id;
493 }*/
494 }
495
496 if($this->isPermittedRole($folder_id,$role_id))
497 {
498 $permitted_roles[$role_id] = $role_id;
499 }
500 else
501 {
502 $role_name = ilObject::_lookupTitle($role_id);
503 return $this->__raiseError("Could not find role ".$role_name.". Either you use an invalid/deleted role ".
504 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",'Server');
505 }
506 }
507
508 $global_roles = $rbacreview->getGlobalRoles();
509
510 //print_r ($global_roles);
511
512
513
514 foreach ($permitted_roles as $role_id => $role_name)
515 {
516 if ($role_id != "")
517 {
518 if (in_array($role_id, $global_roles))
519 {
520 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
521 || ($folder_id != USER_FOLDER_ID && $folder_id != 0 && ! ilObjRole::_getAssignUsersStatus($role_id))
522 )
523 {
524 return $this->__raiseError($lng->txt("usrimport_with_specified_role_not_permitted")." $role_name ($role_id)",'Server');
525 }
526 }
527 else
528 {
529 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,true);
530 if ($rbacreview->isDeleted($rolf[0])
531 || ! $rbacsystem->checkAccess('write',$rolf[0]))
532 {
533
534 return $this->__raiseError($lng->txt("usrimport_with_specified_role_not_permitted")." $role_name ($role_id)","Server");
535 }
536 }
537 }
538 }
539
540 //print_r ($permitted_roles);
541
542 $importParser = new ilUserImportParser("", IL_USER_IMPORT, $conflict_rule);
543 $importParser->setSendMail($send_account_mail);
544 $importParser->setUserMappingMode(IL_USER_MAPPING_ID);
545 $importParser->setFolderId($folder_id);
546 $importParser->setXMLContent($usr_xml);
547
548 $importParser->setRoleAssignment($permitted_roles);
549
550 $importParser->startParsing();
551
552 if ($importParser->getErrorLevel() != IL_IMPORT_FAILURE)
553 {
554 return $this->__getUserMappingAsXML ($importParser->getUserMapping());
555 }
556 return $this->__getImportProtocolAsXML ($importParser->getProtocol());
557
558 }
$error
Definition: Error.php:17
const IL_FAIL_ON_CONFLICT
const IL_USER_MAPPING_ID
const IL_IMPORT_FAILURE
const IL_UPDATE_ON_CONFLICT
const IL_EXTRACT_ROLES
const IL_IMPORT_SUCCESS
const IL_USER_IMPORT
const IL_VERIFY
const IL_IGNORE_ON_CONFLICT
const IL_IMPORT_WARNING
static _getAssignUsersStatus($a_role_id)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupTitle($a_id)
lookup object title
__getImportProtocolAsXML($a_array)
Create XML ResultSet.
isPermittedRole($a_folder, $a_role)
check if assignment is allowed
__getUserMappingAsXML($a_array)
return user mapping as xml
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
domxml_open_mem($str, $mode=0, &$error=NULL)
global $lng
Definition: privfeed.php:17

References $error, $ilLog, $ilUser, $lng, ilUtil\__extractId(), __getImportProtocolAsXML(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), __getUserMappingAsXML(), ilSoapAdministration\__raiseError(), ilObjRole\_getAssignUsersStatus(), ilObject\_lookupTitle(), domxml_open_mem(), ilObjectFactory\getInstanceByRefId(), IL_EXTRACT_ROLES, IL_FAIL_ON_CONFLICT, IL_IGNORE_ON_CONFLICT, IL_IMPORT_FAILURE, IL_IMPORT_SUCCESS, IL_IMPORT_WARNING, IL_UPDATE_ON_CONFLICT, IL_USER_IMPORT, IL_USER_MAPPING_ID, IL_VERIFY, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), isPermittedRole(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ isPermittedRole()

ilSoapUserAdministration::isPermittedRole (   $a_folder,
  $a_role 
)
protected

check if assignment is allowed

@access protected

Parameters

return

Definition at line 567 of file class.ilSoapUserAdministration.php.

568 {
569 static $checked_roles = array();
570 static $global_roles = null;
571
572
573 if(isset($checked_roles[$a_role]))
574 {
575 return $checked_roles[$a_role];
576 }
577
578 global $rbacsystem,$rbacreview,$ilUser,$tree,$ilLog;
579
580 $locations = $rbacreview->getFoldersAssignedToRole($a_role,true);
581 $location = $locations[0];
582
583 // global role
584 if($location == ROLE_FOLDER_ID)
585 {
586 $ilLog->write(__METHOD__.': Check global role');
587 // check assignment permission if called from local admin
588
589
590 if($a_folder != USER_FOLDER_ID and $a_folder != 0)
591 {
592 $ilLog->write(__METHOD__.': '.$a_folder);
593 include_once './Services/AccessControl/classes/class.ilObjRole.php';
595 {
596 $ilLog->write(__METHOD__.': No assignment allowed');
597 $checked_roles[$a_role] = false;
598 return false;
599 }
600 }
601 // exclude anonymous role from list
602 if ($a_role == ANONYMOUS_ROLE_ID)
603 {
604 $ilLog->write(__METHOD__.': Anonymous role chosen.');
605 $checked_roles[$a_role] = false;
606 return false;
607 }
608 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
609 if($a_role == SYSTEM_ROLE_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
610 {
611 $ilLog->write(__METHOD__.': System role assignment forbidden.');
612 $checked_roles[$a_role] = false;
613 return false;
614 }
615
616 // Global role assignment ok
617 $ilLog->write(__METHOD__.': Assignment allowed.');
618 $checked_roles[$a_role] = true;
619 return true;
620 }
621 elseif($location)
622 {
623 $ilLog->write(__METHOD__.': Check local role.');
624
625 // It's a local role
626 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,true);
627 $rolf = $rolfs[0];
628
629
630 // only process role folders that are not set to status "deleted"
631 // and for which the user has write permissions.
632 // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
633 // (The ROLE_FOLDER_ID folder contains the global roles).
634 if($rbacreview->isDeleted($rolf)
635 || !$rbacsystem->checkAccess('edit_permission',$rolf))
636 {
637 $ilLog->write(__METHOD__.': Role deleted or no permission.');
638 $checked_roles[$a_role] = false;
639 return false;
640 }
641 // A local role is only displayed, if it is contained in the subtree of
642 // the localy administrated category. If the import function has been
643 // invoked from the user folder object, we show all local roles, because
644 // the user folder object is considered the parent of all local roles.
645 // Thus, if we start from the user folder object, we initializ$isInSubtree = $folder_id == USER_FOLDER_ID || $folder_id == 0;e the
646 // isInSubtree variable with true. In all other cases it is initialized
647 // with false, and only set to true if we find the object id of the
648 // locally administrated category in the tree path to the local role.
649 if($a_folder != USER_FOLDER_ID and $a_folder != 0 and !$tree->isGrandChild($a_folder,$rolf))
650 {
651 $ilLog->write(__METHOD__.': Not in path of category.');
652 $checked_roles[$a_role] = false;
653 return false;
654 }
655 $ilLog->write(__METHOD__.': Assignment allowed.');
656 $checked_roles[$a_role] = true;
657 return true;
658 }
659 }
$location
Definition: buildRTE.php:44

References $ilLog, $ilUser, $location, ilObjRole\_getAssignUsersStatus(), and USER_FOLDER_ID.

Referenced by importUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loginCAS()

ilSoapUserAdministration::loginCAS (   $client,
  $PT,
  $username 
)

Definition at line 108 of file class.ilSoapUserAdministration.php.

109 {
111 $this->sauth->setClient($client);
112 $this->sauth->setUsername($username);
113 $this->sauth->setPT($PT);
114 $authenticated = true;
115 //include_once("./Services/CAS/classes/class.ilCASAuth.php");
116 //include_once("./Services/CAS/phpcas/source/CAS/CAS.php");
117 if(!$this->sauth->authenticate())
118 {
119 $authenticated = false;
120 }
121 if(!$authenticated)
122 {
123 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
124 }
125 return $this->sauth->getSid().'::'.$client;
126 }
const AUTH_CAS
__initAuthenticationObject($a_auth_mode=AUTH_LOCAL)
$client

References $client, ilSoapAdministration\__initAuthenticationObject(), ilSoapAdministration\__raiseError(), and AUTH_CAS.

+ Here is the call graph for this function:

◆ loginLDAP()

ilSoapUserAdministration::loginLDAP (   $client,
  $username,
  $password 
)

Not required anymode.

This method is a simple alias for login()

Parameters
type$client
type$username
type$password
Returns
type
Deprecated:
since version 5.2

Definition at line 137 of file class.ilSoapUserAdministration.php.

138 {
139 return $this->login($client, $username, $password);
140 }

References $client.

◆ loginStudipUser()

ilSoapUserAdministration::loginStudipUser (   $sid,
  $user_id 
)

login as user from Stud.IP

Deprecated:
Parameters
string$sid
int$user_id
Returns
string $sid

Definition at line 149 of file class.ilSoapUserAdministration.php.

150 {
151 global $rbacreview, $ilUser, $ilIliasIniFile;
152
153 $this->initAuth($sid);
154 $this->initIlias();
155 list($admin_sid,$client) = $this->__explodeSid($sid);
156
157 if(!$this->__checkSession($sid))
158 {
159 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
160 }
161
162 if (!$ilIliasIniFile->readVariable('server', 'studip'))
163 {
164 return $this->__raiseError('Stud.IP mode not active.','Server');
165 }
166
167 if(!$rbacreview->isAssigned($ilUser->getId(),SYSTEM_ROLE_ID))
168 {
169 return $this->__raiseError('No permission to initialize user session.','Server');
170 }
171
172 if($ilUser->getLoginByUserId($user_id))
173 {
174 // logout admin
175 include_once './Services/Authentication/classes/class.ilSession.php';
177 $GLOBALS['DIC']['ilAuthSession']->logout();
178 unset($_COOKIE['PHPSESSID']);
179
180 // init session and set user as authenticated
181 $_COOKIE['ilClientId'] = $client;
182 $GLOBALS['DIC']['ilAuthSession']->init();
183 $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, $user_id);
184 return (session_id().'::'.$client);
185 }
186 return $this->__raiseError('User does not exist','Client');
187 }
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
const SESSION_CLOSE_USER
static setClosingContext($a_context)
set closing context (for statistics)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$ilIliasIniFile

References $_COOKIE, $client, $GLOBALS, $ilIliasIniFile, $ilUser, ilSoapAdministration\__explodeSid(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSession\SESSION_CLOSE_USER, and ilSession\setClosingContext().

+ Here is the call graph for this function:

◆ logout()

ilSoapUserAdministration::logout (   $sid)

Logout user destroy session.

Parameters
string$sid
Returns
type

Definition at line 194 of file class.ilSoapUserAdministration.php.

195 {
196 $this->initAuth($sid);
197 $this->initIlias();
198
199 if(!$this->__checkSession($sid))
200 {
201 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
202 }
203
204 include_once './Services/Authentication/classes/class.ilSession.php';
206 $GLOBALS['DIC']['ilAuthSession']->logout();
207 return true;
208 }

References $GLOBALS, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSession\SESSION_CLOSE_USER, and ilSession\setClosingContext().

+ Here is the call graph for this function:

◆ lookupUser()

ilSoapUserAdministration::lookupUser (   $sid,
  $user_name 
)

Definition at line 210 of file class.ilSoapUserAdministration.php.

211 {
212 $this->initAuth($sid);
213 $this->initIlias();
214
215 if(!$this->__checkSession($sid))
216 {
217 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
218 }
219
220 $user_name = trim($user_name);
221
222 if(!strlen($user_name))
223 {
224 return $this->__raiseError('No username given. Aborting','Client');
225 }
226
227 global $rbacsystem, $ilUser ;
228
229 if(strcasecmp($ilUser->getLogin(), $user_name) != 0 && !$rbacsystem->checkAccess('read',USER_FOLDER_ID))
230 {
231 return $this->__raiseError('Check access failed. '.USER_FOLDER_ID,'Server');
232 }
233
234 $user_id = ilObjUser::getUserIdByLogin($user_name);
235
236
237 return $user_id ? $user_id : "0";
238
239 }
static getUserIdByLogin($a_login)

References $ilUser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjUser\getUserIdByLogin(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ searchUser()

ilSoapUserAdministration::searchUser (   $sid,
  $a_keyfields,
  $query_operator,
  $a_keyvalues,
  $attach_roles,
  $active 
)

return user xml following dtd 3.7

Parameters
String$sidsession id
Stringarray $a_keyfields array of user fieldname, following dtd 3.7
String$queryOperatorany logical operator
Stringarray $a_keyValues values separated by space, at least 3 chars per search term

Definition at line 887 of file class.ilSoapUserAdministration.php.

887 {
888
889 $this->initAuth($sid);
890 $this->initIlias();
891
892 if(!$this->__checkSession($sid))
893 {
894 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
895 }
896
897 global $ilDB, $rbacsystem;
898
899 if(!$rbacsystem->checkAccess('read', USER_FOLDER_ID))
900 {
901 return $this->__raiseError('Check access failed.','Server');
902 }
903
904
905 if (!count($a_keyfields))
906 $this->__raiseError('At least one keyfield is needed','Client');
907
908 if (!count ($a_keyvalues))
909 $this->__raiseError('At least one keyvalue is needed','Client');
910
911 if (!strcasecmp($query_operator,"and")==0 || !strcasecmp($query_operator,"or") == 0)
912 $this->__raiseError('Query operator must be either \'and\' or \'or\'','Client');
913
914
915 $query = $this->__buildSearchQuery ($a_keyfields, $query_operator, $a_keyvalues);
916
917 $query = "SELECT usr_data.*, usr_pref.value AS language
918 FROM usr_data
919 LEFT JOIN usr_pref
920 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
921 $ilDB->quote("language", "text").
922 "'language'
923 WHERE 1 = 1 ".$query;
924
925 if (is_numeric($active) && $active > -1)
926 $query .= " AND active = ". $ilDB->quote($active);
927
928 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
929
930 //echo $query;
931
932 $r = $ilDB->query($query);
933
934 $data = array();
935
936 while($row = $ilDB->fetchAssoc($r))
937 {
938 $data[] = $row;
939 }
940
941 include_once './Services/User/classes/class.ilUserXMLWriter.php';
942
943 $xmlWriter = new ilUserXMLWriter();
944 $xmlWriter->setAttachRoles($attach_roles);
945
946 $xmlWriter->setObjects($data);
947
948 if($xmlWriter->start())
949 {
950 return $xmlWriter->getXML();
951 }
952 return $this->__raiseError('Error in searchUser','Server');
953 }
__buildSearchQuery($a_keyfields, $queryOperator, $a_keyvalues)
create search term according to parameters
$r
Definition: example_031.php:79

References $data, $ilDB, $query, $r, $row, __buildSearchQuery(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: