123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?php
- require_once __DIR__.'/../inc/global.inc.php';
- $server = new soap_server();
- $server->configureWSDL('WSUserInfo', 'urn:WSUserInfo');
- $server->wsdl->addComplexType(
- 'courseDetails',
- 'complexType',
- 'struct',
- 'all',
- '',
- [
- 'name' => 'code',
- 'type' => 'xsd:string',
- 'name' => 'title',
- 'type' => 'xsd:string',
- 'name' => 'url',
- 'type' => 'xsd:string',
- 'name' => 'teacher',
- 'type' => 'xsd:string',
- 'name' => 'language',
- 'type' => 'xsd:string',
- ]
- );
- $server->wsdl->addComplexType(
- 'courseList',
- 'complexType',
- 'array',
- '',
- 'SOAP-ENC:Array',
- [],
- [
- [
- 'ref' => 'SOAP-ENC:arrayType',
- 'wsdl:arrayType' => 'tns:courseDetails[]',
- ],
- ],
- 'tns:courseDetails'
- );
- $server->register(
- 'WSCourseListOfUser',
- [
- 'username' => 'xsd:string',
- 'signature' => 'xsd:string',
- ],
- ['return' => 'xsd:Array'],
- 'urn:WSUserInfo',
- 'urn:WSUserInfo#WSUserInfo',
- 'rpc',
- 'encoded',
- 'This service returns a list of courses'
- );
- function WSCourseListOfUser($username, $signature)
- {
- if (empty($username) or empty($signature)) {
- return -1;
- }
- $info = api_get_user_info_from_username($username);
- $user_id = $info['user_id'];
- $list = UserManager::get_api_keys($user_id, 'dokeos');
- $key = '';
- foreach ($list as $key) {
- break;
- }
- $local_key = $username.$key;
- if (!api_is_valid_secret_key($signature, $local_key)) {
- return -1;
- }
- $courses_list = [];
- $courses_list_tmp = CourseManager::get_courses_list_by_user_id($user_id);
- foreach ($courses_list_tmp as $index => $course) {
- $course_info = CourseManager::get_course_information($course['code']);
- $courses_list[] = [
- 'code' => $course['code'],
- 'title' => api_utf8_encode($course_info['title']),
- 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/',
- 'teacher' => api_utf8_encode($course_info['tutor_name']),
- 'language' => $course_info['course_language'],
- ];
- }
- return $courses_list;
- }
- $server->wsdl->addComplexType(
- 'eventDetails',
- 'complexType',
- 'struct',
- 'all',
- '',
- [
- 'name' => 'datestart',
- 'type' => 'xsd:string',
- 'name' => 'dateend',
- 'type' => 'xsd:string',
- 'name' => 'title',
- 'type' => 'xsd:string',
- 'name' => 'link',
- 'type' => 'xsd:string',
- 'name' => 'coursetitle',
- 'type' => 'xsd:string',
- ]
- );
- $server->wsdl->addComplexType(
- 'eventsList',
- 'complexType',
- 'array',
- '',
- 'SOAP-ENC:Array',
- [],
- [
- [
- 'ref' => 'SOAP-ENC:arrayType',
- 'wsdl:arrayType' => 'tns:eventDetails[]',
- ],
- ],
- 'tns:eventDetails'
- );
- $server->register(
- 'WSEventsList',
-
- [
- 'username' => 'xsd:string',
- 'signature' => 'xsd:string',
- 'datestart' => 'xsd:int',
- 'dateend' => 'xsd:int',
- ],
-
- ['return' => 'xsd:Array'],
-
- 'urn:WSUserInfo',
-
- 'urn:WSUserInfo#WSEventsList',
-
- 'rpc',
-
- 'encoded',
-
- 'This service returns a list of events of the courses the given user is subscribed to'
- );
- function WSEventsList($username, $signature, $datestart = 0, $dateend = 0)
- {
- if (empty($username) or empty($signature)) {
- return -1;
- }
- $info = api_get_user_info_from_username($username);
- $user_id = $info['user_id'];
- $list = UserManager::get_api_keys($user_id, 'dokeos');
- $key = '';
- foreach ($list as $key) {
- break;
- }
- $local_key = $username.$key;
- if (!api_is_valid_secret_key($signature, $local_key)) {
- return -1;
- }
- $events_list = [];
- $user_id = UserManager::get_user_id_from_username($username);
- if ($user_id === false) {
- return $events_list;
- }
- $ds = substr($datestart, 0, 4).'-'.substr($datestart, 4, 2).'-'.substr($datestart, 6, 2).' 00:00:00';
- $de = substr($dateend, 0, 4).'-'.substr($dateend, 4, 2).'-'.substr($dateend, 6, 2).' 00:00:00';
- $events_list = Agenda::get_personal_agenda_items_between_dates(
- $user_id,
- $ds,
- $de
- );
- return $events_list;
- }
- $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
- $server->service($HTTP_RAW_POST_DATA);
|