aboutsummaryrefslogtreecommitdiff
path: root/lib/soap/StudipSoapClient.class.php
blob: f6c0cadcbb07d7c76dbe7caed587ec839859d8de (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
<?
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
class StudipSoapClient
{
    var $soap_client;
    var $error;
    var $faultstring;

    function __construct($path)
    {
        require_once("vendor/nusoap/nusoap.php");

        $this->soap_client = new soap_client($path, true);
        $this->soap_client->soap_defencoding = 'UTF-8';
        $this->soap_client->decode_utf8 = false;
        $this->soap_client->setDebugLevel(0);

        $err = $this->soap_client->getError();
        if ($err)
            $this->error = "<b>Soap Constructor Error</b><br>" . $err . "<br><br>";
    }

    function _call($method, $params)
    {
        $this->faultstring = "";
        $result = $this->soap_client->call($method, $params);

        if ($this->soap_client->fault)
        {
            $this->faultstring = $result["faultstring"];
            if (!in_array(mb_strtolower($this->faultstring), ["session not valid","session invalid", "session idled"]))
                $this->error .= "<b>" . sprintf(_("SOAP-Fehler, Funktion \"%s\":"), $method) . "</b> " . $result["faultstring"] . " (" . $result["faultcode"] . ")<br>";
        } else {
            $err = $this->soap_client->getError();
            if ($err) {
                $this->error .= "<b>" . sprintf(_("SOAP-Fehler, Funktion \"%s\":"), $method) . "</b> " . $err . "<br>";
            } else {
                return $result;
            }
        }
        error_log($this->error);
        return false;
    }

    function getError()
    {
         $error = $this->error;
         $this->error = "";
         if ($error != "")
             return $error;
        else
            return false;
    }
}
?>