aboutsummaryrefslogtreecommitdiff
path: root/lib/webservices/api/studip_contentmodule.php
blob: 0f317190ca62f46095134f315f053fa9390e004b (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
<?php
/*
 * studip_contentmodule.php - base class for content modules
 *
 * 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.
 */

class StudipContentmoduleHelper
{
    public static function find_seminars_using_contentmodule($system_type, $module_id)
    {
        $db = DBManager::get();

        $stmt = $db->prepare('SELECT s.Seminar_id FROM seminare s
                              LEFT JOIN object_contentmodules oc
                              ON (s.Seminar_id = oc.object_id)
                              WHERE oc.module_id = ? AND oc.system_type = ?');
        $stmt->execute([$module_id, $system_type]);

        return $stmt->fetchAll(PDO::FETCH_COLUMN);
    }

    public static function find_institutes_using_contentmodule($system_type, $module_id)
    {
        $db = DBManager::get();

        $stmt = $db->prepare('SELECT i.Institut_id FROM Institute i
                              LEFT JOIN object_contentmodules oc
                              ON (i.Institut_id = oc.object_id)
                              WHERE oc.module_id = ? AND oc.system_type = ?');
        $stmt->execute([$module_id, $system_type]);

        return $stmt->fetchAll(PDO::FETCH_COLUMN);
    }
}