forked from compilatio/moodle-plagiarism_compilatio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compilatio.class.php
181 lines (172 loc) · 6.25 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?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 __construct($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,($title),($description),($filename),($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() {
try {
if (!is_object($this->soapcli)) {
return array("quotas"=>null, "error"=>$this->soapcli);
}
$param=array($this->key);
$resultat=$this->soapcli->__call('getAccountQuotas',$param);
return array("quotas"=>$resultat, "error"=>null);
} catch (SoapFault $fault) {
return array("quotas"=>null, "error"=>$fault);
}
}
/* Get expiration date of the account linked to the API key. */
function GetAccountExpirationDate()
{
try {
if (!is_object($this->soapcli)) {
return false;
}
$param=array($this->key);
return $this->soapcli->__call('getSubscriptionEndDate',$param);
$resultat;
} catch (SoapFault $fault) {
return false;
}
}
/* Post Moodle Configuration to Compilatio */
function PostConfiguration($releasePHP,$releaseMoodle,$releasePlugin,$language,$cronFrequency)
{
try {
if (!is_object($this->soapcli)) {
return false;
}
$param=array($this->key,$releasePHP,$releaseMoodle,$releasePlugin,$language,$cronFrequency);
$resultat=$this->soapcli->__call('postMoodleConfiguration',$param);
return $resultat==1;
} catch (SoapFault $fault) {
return false;
}
}
/* Get a list of the current Compilatio news */
function GetTechnicalNews()
{
try {
if (!is_object($this->soapcli)) {
return false;
}
$param=array($this->key);
return $this->soapcli->__call('getTechnicalNews',$param);
} catch (SoapFault $fault) {
return false;
}
}
}