aboutsummaryrefslogtreecommitdiff
path: root/lib/webservices/services/lecture_tree_webservice.php
blob: 5748a5124e92570a455101a259d9bee23c7edf8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO

/*
 * lecture_tree_webservice.php - Provides webservices for infos about
 *  lecture tree
 *
 * Copyright (C) 2006 - Marco Diedrich (mdiedric@uos.de)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

require_once('lib/webservices/api/studip_lecture_tree.php');
require_once('lib/webservices/api/studip_user.php');
require_once('lib/webservices/api/studip_seminar_info.php');
require_once('lib/dates.inc.php');

class LectureTreeService extends AccessControlledService
{
    function __construct()
    {
        $this->add_api_method('get_seminars_by_sem_tree_id',
                                                        ['string',
                                                                    'string',
                                                                    'string'],
                                                        ['Studip_Seminar_Info']);
    }

    function get_seminars_by_sem_tree_id_action($api_key, $sem_tree_id, $term_id)
    {
        $seminar_infos = [];

        $seminar_ids = StudipLectureTreeHelper::get_seminars_by_sem_tree_id($sem_tree_id, $term_id);

          foreach($seminar_ids as $seminar_id)
        {
            $sem_obj = new Seminar($seminar_id['seminar_id']);

            $lecturers = StudipSeminarHelper::get_participants($seminar_id['seminar_id'], 'dozent');

            foreach($lecturers as $lecturer)
            {
                $lecturers [] = Studip_User::find_by_user_name($lecturer);
            }

            $seminar_info = new Studip_Seminar_Info();
            $seminar_info->title = $sem_obj->getName();
            $seminar_info->lecturers = $lecturers;
            $seminar_info->turnus = $sem_obj->getDatesTemplate('dates/seminar_export', ['semester_id' => $term_id]);
            $seminar_info->lecture_number = $sem_obj->seminar_number;

            $seminar_infos [] = $seminar_info;
        }
        return $seminar_infos;
    }



}