aboutsummaryrefslogtreecommitdiff
path: root/lib/soap/StudipSoapClient_PHP5.class.php
blob: 23bfa9c47d86b1e48d06d19e0f4d5ae6b9a33d09 (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
<?
# Lifter002: TODO
# Lifter010: TODO
/**
* Adapter for using php5 ext:soap with Ilias3Soap
*
*
* @author   Andre Noack <noack@data-quest.de>
* @access   public
* @package  ELearning-Interface
*/
class StudipSoapClient
{
    var $soap_client;
    var $error;

    function __construct($path)
    {
        try {
            $this->soap_client = new SoapClient($path, ['trace' => 0]);
        } catch (SoapFault $fault) {
            $this->error = "<b>Soap Constructor Error</b><br>" . $fault->faultcode . ": ".$fault->faultstring."<br><br>";
        }
    }

    function _call($method, $params)
    {
        $result = false;
        if ($this->soap_client instanceOf SoapClient) {
            $this->faultstring = "";
            try {
                $result = $this->soap_client->__soapCall($method, $params);
            } catch  (SoapFault $fault) {
                $this->faultstring = $fault->faultstring;
                if (!in_array(mb_strtolower($this->faultstring), ["session not valid","session invalid", "session idled"])) {
                    $this->error .= "<hr><font size=\"-1\"><b>" . sprintf(_("SOAP-Fehler, Funktion \"%s\":"), $method) . "</b> " . $fault->faultstring . " (" .  $fault->faultcode . ")<br>".print_r($params,1).'</font><hr>';
                    error_log($this->error);
                }
                $this->soap_client->fault = true;
                return false;
            }
            if (is_object($result)) $result = (array)$result;
            if (is_array($result)){
                foreach($result as $index => $one){
                    if (is_object($one)) $result[$index] = (array)$one;
                }
            }
            $this->soap_client->fault = false;
        }
        return $result;
    }

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