forked from compilatio/moodle-plagiarism_compilatio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compilatio.class.php
executable file
·144 lines (137 loc) · 5.24 KB
/
compilatio.class.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Description : compilatioservice - based on original compilatio class
* �tablit la communication avec le serveur SOAP de Compilatio.net
* appelle diverses m�thodes concernant la gestion d'un document dans Compilatio.net
*
* Date: 25/07/2012
* @version 1.0 (updated by Dan Marsden <dan@danmarsden.com>
*
*/
class compilatioservice {
/* Clef d'identification pour le compte Compilatio*/
var $key = null;
/*Connexion au Webservice*/
var $soapcli;
/*Constructeur -> on cr�er la connexion avec le webservice*/
//MODIF 2009-03-19: passage des param�tres
function compilatioservice($key,$urlsoap,$proxy_host='',$proxy_port='', $proxy_username='', $proxy_password='') {
try {
if (!empty($key)) {
$this->key = $key;
if (!empty($urlsoap)) {
$param = array('trace'=>false,
'soap_version'=>SOAP_1_2,
'exceptions'=>true);
if(!empty($proxy_host)) {
$param['proxy_host'] = '"' . $proxy_host . '"';
if (!empty($proxy_port)) {
$param['proxy_port'] = $proxy_port;
}
if(!empty($proxy_username) && !empty($proxy_password)) {
$param['proxy_login'] = '"' . $proxy_username . '"';
$param['proxy_password'] = '"' .$proxy_password. '"';
}
}
$this->soapcli = new SoapClient($urlsoap,$param);
} else {
$this->soapcli = 'WS urlsoap not available' ;
}
} else {
$this->soapcli ='API key not available';
}
} catch (SoapFault $fault) {
$this->soapcli = "Error constructor compilatio " . $fault->faultcode ." " .$fault->faultstring ;
} catch (Exception $e) {
$this->soapcli = "Error constructor compilatio with urlsoap" . $urlsoap;
}
}
/*M�thode qui permet le chargement de fichiers sur le compte compilatio*/
function SendDoc($title,$description,$filename,$mimetype,$content) {
try {
if (!is_object($this->soapcli)) {
return("Error in constructor compilatio() " . $this->soapcli);
}
$idDocument = $this->soapcli->__call('addDocumentBase64',array($this->key,utf8_encode($title),utf8_encode($description),utf8_encode($filename),utf8_encode($mimetype),base64_encode($content)));
return $idDocument;
} catch (SoapFault $fault) {
return("Erreur SendDoc()" . $fault->faultcode ." " .$fault->faultstring);
}
}
/*M�thode qui r�cup�re les informations d'un document donn�*/
function GetDoc($compi_hash) {
try {
if (!is_object($this->soapcli)) {
return("Error in constructor compilatio() " . $this->soapcli);
}
$param=array($this->key,$compi_hash);
$idDocument = $this->soapcli->__call('getDocument',$param);
return $idDocument;
} catch (SoapFault $fault) {
return("Erreur GetDoc()" . $fault->faultcode ." " .$fault->faultstring);
}
}
/*M�thode qui permet de r�cup�r� l'url du rapport d'un document donn�*/
function GetReportUrl($compi_hash) {
try {
if (!is_object($this->soapcli)) {
return("Error in constructor compilatio() " . $this->soapcli);
}
$param=array($this->key,$compi_hash);
$idDocument = $this->soapcli->__call('getDocumentReportUrl',$param);
return $idDocument;
} catch (SoapFault $fault) {
return("Erreur GetReportUrl()" . $fault->faultcode ." " .$fault->faultstring);
}
}
/*M�thode qui permet de supprim� sur le compte compilatio un document donn�*/
function DelDoc($compi_hash) {
try {
if (!is_object($this->soapcli)) {
return("Error in constructor compilatio() " . $this->soapcli);
}
$param=array($this->key,$compi_hash);
$this->soapcli->__call('deleteDocument',$param);
$this->soapcli->__call('dellAuteur',$param);
$this->soapcli->__call('deleteAnalyseProgrammee',$param);
} catch (SoapFault $fault) {
return("Erreur DelDoc()" . $fault->faultcode ." " .$fault->faultstring);
}
}
/*M�thode qui permet de lancer l'analyse d'un document donn�*/
function StartAnalyse($compi_hash) {
try {
if (!is_object($this->soapcli)) {
return("Error in constructor compilatio() " . $this->soapcli);
}
$param=array($this->key,$compi_hash);
$this->soapcli->__call('startDocumentAnalyse',$param);
} catch (SoapFault $fault) {
$error = new stdClass();
$error->code = $fault->faultcode;
$error->string = $fault->faultstring;
return $error;
}
return true;
}
/*M�thode qui permet de r�cup�r� les quotas du compte compilatio*/
function GetQuotas($debug=false) {
global $OUTPUT;
try {
if (!is_object($this->soapcli)) {
if ($debug) {
echo $OUTPUT->notification($this->soapcli);
}
return null;
}
$param=array($this->key);
$resultat=$this->soapcli->__call('getAccountQuotas',$param);
return $resultat;
} catch (SoapFault $fault) {
if ($debug) {
echo $OUTPUT->notification($fault);
}
return null;
}
}
}