diff --git a/application/libraries/SignatureLib.php b/application/libraries/SignatureLib.php new file mode 100644 index 000000000..132545219 --- /dev/null +++ b/application/libraries/SignatureLib.php @@ -0,0 +1,75 @@ +sendsJson() + ->authenticateWith(SIGNATUR_USER, SIGNATUR_PASSWORD) + ->body('{"filename": "'.basename($inputFileName).'", "content": "'.base64_encode($inputFileContent).'"}') + ->expectsJson() + ->send(); + } + } + catch(\Httpful\Exception\ConnectionErrorException $cee) // Httpful exception + { + error_log($cee->getMessage()); + } + catch (Exception $e) // any other exception + { + error_log($e->getMessage()); + } + + // If the response is fine + if (isset($resultPost->body) && is_object($resultPost->body) + && isset($resultPost->body->retval) && is_array($resultPost->body->retval)) + { + return $resultPost->body->retval; + } + + // Otherwise return a null as error + return null; + } +} + diff --git a/cis/private/lehre/abgabe_lektor_details.php b/cis/private/lehre/abgabe_lektor_details.php index e3bf5c40d..a40136868 100644 --- a/cis/private/lehre/abgabe_lektor_details.php +++ b/cis/private/lehre/abgabe_lektor_details.php @@ -37,6 +37,7 @@ require_once('../../../include/phrasen.class.php'); require_once('../../../include/projektarbeit.class.php'); require_once('../../../include/projektbetreuer.class.php'); require_once('../../../include/sancho.inc.php'); +require_once('../../../application/libraries/SignatureLib.php'); if (!$db = new basis_db()) $db=false; @@ -590,7 +591,9 @@ while ($row=@$db->db_fetch_object($result)) $htmlstr .= "\n"; $htmlstr .= "\n"; $htmlstr .= "\n"; - if(!$row->abgabedatum) + + $uploadedDocumentSigned = null; + if (!$row->abgabedatum) { if ($row->datumdb_fetch_object($result)) $fcol='#000000'; } } - //$htmlstr .= "fixtermin=='t'?'checked=\"checked\"':'')." >"; - //$htmlstr .= "fixtermin=='t'?'checked="checked" style="background-color:#FF0000;"':'')." disabled>"; + if($row->fixtermin=='t') { $htmlstr .= "J"; @@ -659,11 +661,12 @@ while ($row=@$db->db_fetch_object($result)) $htmlstr .= " \n"; $htmlstr .= " \n"; $htmlstr .= " ".($row->abgabedatum==''?' ':$datum_obj->formatDatum($row->abgabedatum,'d.m.Y'))."\n"; - if($user==$row->insertvon && $betreuerart!="Zweitbegutachter") + + if ($user==$row->insertvon && $betreuerart!="Zweitbegutachter") { $htmlstr .= " "; - if(!$row->abgabedatum) + if (!$row->abgabedatum) { $htmlstr .= " "; } @@ -692,6 +695,53 @@ while ($row=@$db->db_fetch_object($result)) { $htmlstr .= "     "; } + + if (file_exists(PAABGABE_PATH.$row->paabgabe_id.'_'.$uid.'.pdf')) + { + $signaturVorhanden = false; + if ($row->paabgabetyp_kurzbz == 'end') + { + // Check if the document is signed + $signList = SignatureLib::list(PAABGABE_PATH.$row->paabgabe_id.'_'.$uid.'.pdf'); + if (is_array($signList) && count($signList) > 0) + { + $signaturVorhanden = true; + // The document is signed + } + elseif ($signList === null) + { + $uploadedDocumentSigned = 'WARNING: signature server error'; + } + else + { + $uploadedDocumentSigned = $p->t('abgabetool/uploadedDocumentNotSigned'); + } + } + if ($uploadedDocumentSigned != null) + { + $htmlstr .= ' + +
+ '.$uploadedDocumentSigned.' +
+ '; + } + elseif($signaturVorhanden) + { + $htmlstr .= ' + +
+ '.$p->t('abgabetool/uploadedDocumentSigned').' +
+ '; + } + } + else + { + $htmlstr .= "     "; + } + + $htmlstr .= " \n"; @@ -710,7 +760,7 @@ $htmlstr .= ''."\n"; //$htmlstr .= ""; $htmlstr .= "  "; -$htmlstr .= " \n"; +$htmlstr .= " \n"; $htmlstr .= " '."\n"; } - else + else // endupload type { //Upload der Endabgabe - Eingabe der Zusatzdaten $command='add'; - if(!$error) + if (!$error) { move_uploaded_file($_FILES['datei']['tmp_name'], PAABGABE_PATH.$paabgabe_id.'_'.$uid.'.pdf'); } - if(file_exists(PAABGABE_PATH.$paabgabe_id.'_'.$uid.'.pdf')) + + $signaturVorhanden = true; + + if (file_exists(PAABGABE_PATH.$paabgabe_id.'_'.$uid.'.pdf')) { + // Check if the document is signed + $signList = SignatureLib::list(PAABGABE_PATH.$paabgabe_id.'_'.$uid.'.pdf'); + if (is_array($signList) && count($signList) > 0) + {$htmlstr .= ''."\n"; + // The document is signed + } + elseif ($signList === null) + { + $uploadedDocumentSigned = 'WARNING: signature server error'; + } + else + { + $signaturVorhanden = false; + $uploadedDocumentSigned = $p->t('abgabetool/uploadedDocumentNotSignedStudent'); + } + /*$qry="UPDATE campus.tbl_paabgabe SET abgabedatum = now(), updatevon = '".$user."', @@ -339,6 +390,7 @@ if($command=="update" && $error!=true) $htmlstr .= ''."\n"; $htmlstr .= ''."\n"; $htmlstr .= ''."\n"; + $htmlstr .= ''."\n"; $htmlstr .= "\n"; $htmlstr .= "".$p->t('abgabetool/spracheDerArbeit').":"; $sprache = @$db->db_query("SELECT sprache FROM public.tbl_sprache"); @@ -372,6 +424,21 @@ if($command=="update" && $error!=true) $htmlstr .= ''.$p->t('abgabetool/seitenanzahl').':* '."\n"; $htmlstr .=" \n"; + + // If there are info about the signed document + if ($uploadedDocumentSigned != null) + { + $htmlstr .= "\n"; + $htmlstr .= ""; + $htmlstr .= '
+ + '.$uploadedDocumentSigned.' +
'; + $htmlstr .= ""; + $htmlstr .= "\n"; + } + + $htmlstr .=" \n"; $htmlstr .="

".$p->t('abgabetool/eidesstattlicheErklaerung')."

\n"; $htmlstr .= "".$p->t('abgabetool/gelesenUndAkzeptiert').":* "; $htmlstr .=" * ".$p->t('abgabetool/pflichtfeld')." diff --git a/config/cis.config-default.inc.php b/config/cis.config-default.inc.php index cb670b5dd..91f998ee9 100644 --- a/config/cis.config-default.inc.php +++ b/config/cis.config-default.inc.php @@ -207,6 +207,23 @@ define('TABLE_ID','_id'); define('TABLE_BEGIN','tbl_'); define('VIEW_BEGIN','vw_'); +/** + * Signatur + * DEFAULT: https://signatur.example.com/api/sign + */ +// Generic URL +define('SIGNATUR_URL', 'https://signatur.dev.technikum-wien.at/api'); +// Sign API +define('SIGNATUR_SIGN_API', 'sign'); +// List API +define('SIGNATUR_LIST_API', 'list'); +// User für Zugriff auf Signaturserver +define('SIGNATUR_USER', 'fhcomplete'); +// Passwort für Zugriff auf Signaturserver +define('SIGNATUR_PASSWORD', 'supersecretpassword'); +// Signaturprofil das verwendet werden soll +define('SIGNATUR_DEFAULT_PROFILE', 'FHC_AMT_GROSS_DE'); + //Gibt an, ob das Studienbuchblatt im CIS gedruckt werden kann define('CIS_DOKUMENTE_STUDIENBUCHLBATT_DRUCKEN',true); diff --git a/config/vilesci.config-default.inc.php b/config/vilesci.config-default.inc.php index e98de9ce0..f738e6fef 100644 --- a/config/vilesci.config-default.inc.php +++ b/config/vilesci.config-default.inc.php @@ -188,11 +188,16 @@ define('FHC_REST_PASSWORD', 'password'); * Signatur * DEFAULT: https://signatur.example.com/api/sign */ -define('SIGNATUR_URL', 'https://signatur.example.com/api/sign'); +// Generic URL +define('SIGNATUR_URL', 'https://signatur.dev.technikum-wien.at/api'); +// Sign API +define('SIGNATUR_SIGN_API', 'sign'); +// List API +define('SIGNATUR_LIST_API', 'list'); // User für Zugriff auf Signaturserver -define('SIGNATUR_USER', 'username'); +define('SIGNATUR_USER', 'fhcomplete'); // Passwort für Zugriff auf Signaturserver -define('SIGNATUR_PASSWORD', 'password'); +define('SIGNATUR_PASSWORD', 'supersecretpassword'); // Signaturprofil das verwendet werden soll define('SIGNATUR_DEFAULT_PROFILE', 'FHC_AMT_GROSS_DE'); diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index 0d4f2c660..7e4aef40e 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -557,7 +557,7 @@ class dokument_export $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL); + curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL.'/'.SIGNATUR_SIGN_API); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7); curl_setopt($ch, CURLOPT_USERAGENT, "FH-Complete"); @@ -589,18 +589,19 @@ class dokument_export curl_close($ch); $resultdata = json_decode($result); - if (isset($resultdata->success) && $resultdata->success == 'true') + // If it is success + if (isset($resultdata->error) && $resultdata->error == 0) { $this->signed_filename = $this->temp_folder .'/signed.pdf'; - file_put_contents($this->signed_filename, base64_decode($resultdata->document)); + file_put_contents($this->signed_filename, base64_decode($resultdata->retval)); return true; } - else + else // otherwise if it is an error { - if(isset($resultdata->errormsg)) - $this->errormsg = $resultdata->errormsg; + if(isset($resultdata->retval)) + $this->errormsg = $resultdata->retval; else - $this->errormsg = 'Unknown Error:'.print_r($resultdata,true); + $this->errormsg = 'Unknown Error:'.print_r($resultdata, true); return false; } } diff --git a/locale/de-AT/abgabetool.php b/locale/de-AT/abgabetool.php index 57906695f..f3b2cfac5 100644 --- a/locale/de-AT/abgabetool.php +++ b/locale/de-AT/abgabetool.php @@ -91,6 +91,9 @@ $this->phrasen['abgabetool/projektbeurteilungDownload']='Projektbeurteilung heru $this->phrasen['abgabetool/projektbeurteilungErstDownload']='Erst-/Begutachter'; $this->phrasen['abgabetool/projektbeurteilungZweitDownload']='Zweitbegutachter'; $this->phrasen['abgabetool/fehlerErmittelnEndabgabeProjektarbeit']='Fehler beim Ermitteln des Enduplaods der Projektarbeit'; +$this->phrasen['abgabetool/uploadedDocumentNotSignedStudent']='Es konnte keine gültige digitale Signatur erkannt werden. Bitte wenden Sie sich an Ihren Studiengang ob Ihre Endabgabe erfolgreich war und die Arbeit zur Benotung vorgelegt werden kann.'; +$this->phrasen['abgabetool/uploadedDocumentNotSigned']='Signatur fehlt'; +$this->phrasen['abgabetool/uploadedDocumentSigned']='Signatur vorhanden'; $this->phrasen['abgabetool/senatsMitglied']='Mitglied Prüfungssenat'; $this->phrasen['abgabetool/abgegeben']='Abgegeben, in Beurteilung'; ?> diff --git a/locale/en-US/abgabetool.php b/locale/en-US/abgabetool.php index 84a882e94..b77e25d92 100644 --- a/locale/en-US/abgabetool.php +++ b/locale/en-US/abgabetool.php @@ -91,6 +91,9 @@ $this->phrasen['abgabetool/projektbeurteilungDownload']='Thesis-Assessment downl $this->phrasen['abgabetool/projektbeurteilungErstDownload']='First-/Assessor'; $this->phrasen['abgabetool/projektbeurteilungZweitDownload']='Second Assessor'; $this->phrasen['abgabetool/fehlerErmittelnEndabgabeProjektarbeit']='Error when getting endupload of project work'; +$this->phrasen['abgabetool/uploadedDocumentNotSignedStudent']='The document does not contain an electronic signature. Please inform your Dregree Programm to verify the upload'; +$this->phrasen['abgabetool/uploadedDocumentNotSigned']='Signature not found'; +$this->phrasen['abgabetool/uploadedDocumentSigned']='Signature found'; $this->phrasen['abgabetool/senatsMitglied']='Examiner'; $this->phrasen['abgabetool/abgegeben']='handed in, in assessment'; ?>