Commit a52ded3b authored by Open Source Developer's avatar Open Source Developer

Capacity cahsnges

parents 26cd365b efb927c5
...@@ -173,7 +173,7 @@ class CASLogin extends ControllerBase ...@@ -173,7 +173,7 @@ class CASLogin extends ControllerBase
}; };
$umdobject = $filterAttribute("umdobject"); $umdobject = $filterAttribute("umdobject");
$physicaldeliveryofficename = $filterAttribute("physicaldeliveryofficename"); // $physicaldeliveryofficename = $filterAttribute("physicaldeliveryofficename");
/****** the following is for production : Χρήση μόνο από ΕΠΙΣΗΜΟΥΣ ΛΟΓΑΡΙΑΣΜΟΥΣ ***************************/ /****** the following is for production : Χρήση μόνο από ΕΠΙΣΗΜΟΥΣ ΛΟΓΑΡΙΑΣΜΟΥΣ ***************************/
...@@ -186,12 +186,27 @@ class CASLogin extends ControllerBase ...@@ -186,12 +186,27 @@ class CASLogin extends ControllerBase
} }
*/ */
phpCAS::trace($umdobject); phpCAS::trace($umdobject);
phpCAS::trace($physicaldeliveryofficename); phpCAS::trace($physicaldeliveryofficename);
$gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended'); $gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended');
$gsnunitcode = substr($gsnunitcodedn, strpos($gsnunitcodedn, ";") + 1); $gsnunitcode = substr($gsnunitcodedn, strpos($gsnunitcodedn, ";") + 1);
phpCAS::trace($gsnunitcode); phpCAS::trace($gsnunitcode);
/* check if myschool account */
if (!$umdobject || $umdobject !== "ISaccount") {
return $this->redirectForbidden($configRowName, '5002');
}
if (!$gsnunitcode || $gsnunitcode !== $CASUser) {
return $this->redirectForbidden($configRowName, '5003');
}
/* end of checking myschool account */
$userAssigned = $this->assignRoleToUser($gsnunitcode); $userAssigned = $this->assignRoleToUser($gsnunitcode);
if (sizeof($userAssigned) === 0) { if (sizeof($userAssigned) === 0) {
return $this->redirectForbidden($configRowName, '5004'); return $this->redirectForbidden($configRowName, '5004');
} }
......
ws_endpoint: 'https://the.url'
ws_username: 'username'
ws_password: 'password'
verbose: true
NO_SAFE_CURL: false
...@@ -182,6 +182,14 @@ epal.ministry.massive_mail_unallocated: ...@@ -182,6 +182,14 @@ epal.ministry.massive_mail_unallocated:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudents' _controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudents'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.ministry.massive_mail_unallocated_smallclass:
path: '/ministry/send-unallocated-sc-massive-mail'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudentsSC'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.massive_mail_located: epal.ministry.massive_mail_located:
path: '/ministry/send-located-massive-mail' path: '/ministry/send-located-massive-mail'
options: options:
...@@ -278,3 +286,27 @@ epal.applicant.creationpdf: ...@@ -278,3 +286,27 @@ epal.applicant.creationpdf:
_controller: '\Drupal\epal\Controller\PdfCreator::createApplicantPDF' _controller: '\Drupal\epal\Controller\PdfCreator::createApplicantPDF'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.svc.getdidacticyears:
path: '/epal/get-didactic-years'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\WSConsumer::getAllDidactiYear'
requirements:
_user_is_logged_in: 'TRUE'
epal.svc.getstudentpromotion:
path: '/epal/get-student-promotion/{didactic_year_id}/{lastname}/{firstname}/{father_firstname}/{mother_firstname}/{birthdate}/{registry_no}/{level_name}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalPromotion'
requirements:
_user_is_logged_in: 'TRUE'
epal.svc.getstudentcertification:
path: '/epal/get-student-certification/{didactic_year_id}/{lastname}/{firstname}/{father_firstname}/{mother_firstname}/{birthdate}/{registry_no}/{level_name}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalCertification'
requirements:
_user_is_logged_in: 'TRUE'
This diff is collapsed.
...@@ -559,9 +559,10 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup, ...@@ -559,9 +559,10 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
//Αν δεν απέμειναν θέσεις (δηλαδή αν η χωρητικότητα είναι μικρότερη ή ίση από το πλήθος μαθητών που ήδη φοιτούν στο σχολείο) //Αν δεν απέμειναν θέσεις (δηλαδή αν η χωρητικότητα είναι μικρότερη ή ίση από το πλήθος μαθητών που ήδη φοιτούν στο σχολείο)
//τότε διέγραψέ τους από τον προσωρινό πίνακα αποτελεσμάτων και βάλε τους στον στον πίνακα εκκρεμοτήτων //τότε διέγραψέ τους από τον προσωρινό πίνακα αποτελεσμάτων και βάλε τους στον στον πίνακα εκκρεμοτήτων
if ($newlimit <= 0) {
foreach($students as $student) { foreach($students as $student) {
if ($student->currentepal !== $student->epal_id) { if ($student->currentepal !== $student->epal_id) {
if ($newlimit <= 0) {
//print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id); //print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id);
array_push($this->pendingStudents, $student->student_id); array_push($this->pendingStudents, $student->student_id);
try { try {
...@@ -574,9 +575,27 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup, ...@@ -574,9 +575,27 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
$transaction->rollback(); $transaction->rollback();
return ERROR_DB; return ERROR_DB;
} }
} //end if currentepal } //endif new limit
} //end foreach else { //$newlimit > 0
} //endif newlimit //NEW CODE LINES
if ($this->choice_id !== 1)
$this->removeFromPendingStudents($student->student_id);
}
//END NEW CODE LINES
} //endif currentepal
} //end foreach
//NEW CODE LINES
/*
else {
foreach($students as $student)
if ($student->currentepal !== $student->epal_id)
if ($this->choice_id !== 1)
$this->removeFromPendingStudents($student->student_id);
}
*/
//END NEW CODE LINES
return SUCCESS; return SUCCESS;
......
...@@ -92,14 +92,15 @@ class InformUnlocatedStudents extends ControllerBase { ...@@ -92,14 +92,15 @@ class InformUnlocatedStudents extends ControllerBase {
$cnt_success = 0; $cnt_success = 0;
$cnt_fail = 0; $cnt_fail = 0;
// εύρεση μαθητών που η αίτησή τους ΔΕΝ ικανοποιήθηκε // εύρεση μαθητών που η αίτησή τους ΔΕΝ ικανοποιήθηκε,
//(δεν κατανεμήθηκαν πουθενά)
$sCon = $this->connection->select('epal_student_class', 'eStudent') $sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('student_id')) ->fields('eStudent', array('student_id'));
->condition('eStudent.finalized', 0 , '='); //->condition('eStudent.finalized', 0 , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ); $epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$studentIds = array(); $studentIds = array();
//array_push($studentIds,-1); array_push($studentIds,-1);
foreach ($epalStudents as $epalStudent) foreach ($epalStudents as $epalStudent)
array_push($studentIds, $epalStudent->student_id); array_push($studentIds, $epalStudent->student_id);
...@@ -107,7 +108,6 @@ class InformUnlocatedStudents extends ControllerBase { ...@@ -107,7 +108,6 @@ class InformUnlocatedStudents extends ControllerBase {
$sCon = $this->connection->select('epal_student', 'eStudent') $sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'user_id', 'created')) ->fields('eStudent', array('id', 'user_id', 'created'))
->condition('eStudent.id', $studentIds, 'NOT IN'); ->condition('eStudent.id', $studentIds, 'NOT IN');
//$numNoAllocated = $sCon->countQuery()->execute()->fetchField();
$epalNonLocatedStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ); $epalNonLocatedStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalNonLocatedStudents as $epalNonLocatedStudent) { foreach ($epalNonLocatedStudents as $epalNonLocatedStudent) {
...@@ -155,6 +155,106 @@ class InformUnlocatedStudents extends ControllerBase { ...@@ -155,6 +155,106 @@ class InformUnlocatedStudents extends ControllerBase {
} }
public function sendMailToUnallocatedStudentsSC(Request $request) {
try {
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
//user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//user role validation
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role)
if ($role === "ministry") {
$validRole = true;
break;
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
$cnt_success = 0;
$cnt_fail = 0;
// εύρεση μαθητών που η αίτησή τους ΔΕΝ ικανοποιήθηκε,
//(δεν κατανεμήθηκαν πουθενά)
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('student_id'))
->condition('eStudent.finalized', 0 , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$studentIds = array();
array_push($studentIds,-1);
foreach ($epalStudents as $epalStudent)
array_push($studentIds, $epalStudent->student_id);
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'user_id', 'created'))
->condition('eStudent.id', $studentIds, 'IN');
$epalNonLocatedStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalNonLocatedStudents as $epalNonLocatedStudent) {
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('user_id' => $epalNonLocatedStudent->user_id));
$epalUser = reset($epalUsers);
if ($epalUser) {
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
//$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('uid' => $epalUser->user_id));
//$user = reset($users);
if ($user) {
$langcode = $user->getPreferredLangcode();
if ($this->sendEmailToUnallocated($user->getEmail(), $epalNonLocatedStudent->id, $epalNonLocatedStudent->created, $langcode))
$cnt_success++;
}
else {
return $this->respondWithStatus([
'message' => t("user not found"),
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
} else {
$cnt_fail++;
}
} //end foreach
return $this->respondWithStatus([
'message' => t("post successful"),
'num_success_mail' => $cnt_success,
'num_fail_mail' => $cnt_fail,
//'test' => $test,
], Response::HTTP_OK);
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during sendMailToStudents Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
//sendEmail(e-mail address, A/A, application Date, lang) //sendEmail(e-mail address, A/A, application Date, lang)
private function sendEmailToUnallocated($email, $appId, $appDate, $langcode) { private function sendEmailToUnallocated($email, $appId, $appDate, $langcode) {
$mailManager = \Drupal::service('plugin.manager.mail'); $mailManager = \Drupal::service('plugin.manager.mail');
...@@ -163,9 +263,10 @@ class InformUnlocatedStudents extends ControllerBase { ...@@ -163,9 +263,10 @@ class InformUnlocatedStudents extends ControllerBase {
$key = 'massive_mail_unallocated'; //to be checked.. $key = 'massive_mail_unallocated'; //to be checked..
$to = $email; $to = $email;
$params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " - " . date('d-m-y H:i:s', $appDate) $params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " / " . date('d-m-y H:i:s', $appDate)
. " δεν ικανοποιήθηκε. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης / Τμήμα Επαγγελματικής Εκπαίδευσης," . " δεν ικανοποιήθηκε. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης / Τμήμα Επαγγελματικής Εκπαίδευσης."
. "\r\nΤεστ1\nΤεστ2" ;//e-mail body . "\r\n\r\n Ομάδα Διαχείρισης της εφαρμογής e-epal."
. "\r\n Προσοχή: το μήνυμα που διαβάζετε είναι αυτοματοποιημένο. Παρακαλώ μην απαντάτε σε αυτό το μήνυμα.." ;//e-mail body" ;//e-mail body
//add new lines with SENDER name - check it //add new lines with SENDER name - check it
//$params['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ'); //$params['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ');
...@@ -231,7 +332,7 @@ class InformUnlocatedStudents extends ControllerBase { ...@@ -231,7 +332,7 @@ class InformUnlocatedStudents extends ControllerBase {
$studentIds = array(); $studentIds = array();
//if sizeof(studentIds = 0..distribution has not been made!) //if sizeof(studentIds = 0..distribution has not been made!)
//array_push($studentIds, -1); array_push($studentIds, -1);
foreach ($epalStudents as $epalStudent) foreach ($epalStudents as $epalStudent)
array_push($studentIds, $epalStudent->student_id); array_push($studentIds, $epalStudent->student_id);
...@@ -328,12 +429,13 @@ class InformUnlocatedStudents extends ControllerBase { ...@@ -328,12 +429,13 @@ class InformUnlocatedStudents extends ControllerBase {
$key = 'massive_mail_located'; $key = 'massive_mail_located';
$to = $email; $to = $email;
$params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " - " . date('d-m-y H:i:s', $appDate) $params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " / " . date('d-m-y H:i:s', $appDate)
. " ΙΚΑΝΟΠΟΙΗΘΗΚΕ. Έχετε επιλεγεί να γίνει η εγγραφή σας στο " . $schName .", που βρίσκεται στη διεύθυνση: " . $schStreet . " ΙΚΑΝΟΠΟΙΗΘΗΚΕ. Έχετε επιλεγεί να γίνει η εγγραφή σας στο " . $schName .", που βρίσκεται στη διεύθυνση: " . $schStreet
. ". Παρακαλώ επικοινωνήστε άμεσα με τη Σχολική Μονάδα τοποθέτησής σας" . ". Παρακαλώ επικοινωνήστε άμεσα με τη Σχολική Μονάδα τοποθέτησής σας"
. ", ώστε να ενημερωθείτε για τη διαδικασία που πρέπει να ακολουθήσετε για την εγγραφή σας στο σχολείο. " . ", ώστε να ενημερωθείτε για τη διαδικασία που πρέπει να ακολουθήσετε για την εγγραφή σας στο σχολείο. "
. "Τηλέφωνο επικοινωνίας σχολείου: " . $schTel . "Τηλέφωνο επικοινωνίας σχολείου: " . $schTel
. "\r\nΤεστ1\nΤεστ2" ;//e-mail body . "\r\n\r\n Ομάδα Διαχείρισης της εφαρμογής e-epal."
. "\r\n Προσοχή: το μήνυμα που διαβάζετε είναι αυτοματοποιημένο. Παρακαλώ μην απαντάτε σε αυτό το μήνυμα." ;//e-mail body
//$this->logger->info($params['message']); //$this->logger->info($params['message']);
......
...@@ -86,9 +86,27 @@ class SubmitedApplications extends ControllerBase ...@@ -86,9 +86,27 @@ class SubmitedApplications extends ControllerBase
$i = 0; $i = 0;
if ($epalStudents) { if ($epalStudents) {
$list = array(); $list = array();
foreach ($epalStudents as $object) { foreach ($epalStudents as $object) {
$sectorName = '';
$courseName = '';
if ($object->currentclass->value === '2') {
$sectors = $this->entityTypeManager->getStorage('epal_student_sector_field')->loadByProperties(array('student_id' => $object->id()));
$sector = reset($sectors);
if ($sector)
$sectorName = $this->entityTypeManager->getStorage('eepal_sectors')->load($sector->sectorfield_id->target_id)->name->value;
}
else if ($object->currentclass->value === '3' || $object->currentclass->value === '4') {
$courses = $this->entityTypeManager->getStorage('epal_student_course_field')->loadByProperties(array('student_id' => $object->id()));
$course = reset($courses);
if ($course)
$courseName = $this->entityTypeManager->getStorage('eepal_specialty')->load($course->coursefield_id->target_id)->name->value;
}
$list[] = array( $list[] = array(
'applicationId' => $object->id(),
'name' => $object -> name ->value, 'name' => $object -> name ->value,
'studentsurname' => $object -> studentsurname ->value, 'studentsurname' => $object -> studentsurname ->value,
'fatherfirstname' => $object -> fatherfirstname ->value, 'fatherfirstname' => $object -> fatherfirstname ->value,
...@@ -101,7 +119,10 @@ class SubmitedApplications extends ControllerBase ...@@ -101,7 +119,10 @@ class SubmitedApplications extends ControllerBase
'guardian_mothername' =>$object -> guardian_mothername ->value, 'guardian_mothername' =>$object -> guardian_mothername ->value,
'lastschool_schoolname' =>$object -> lastschool_schoolname ->value, 'lastschool_schoolname' =>$object -> lastschool_schoolname ->value,
'lastschool_schoolyear' =>$object -> lastschool_schoolyear ->value, 'lastschool_schoolyear' =>$object -> lastschool_schoolyear ->value,
'lastschool_class' =>$object -> currentclass ->value, 'lastschool_class' =>$object -> lastschool_class ->value,
'currentclass' =>$object -> currentclass ->value,
'currentsector' =>$sectorName,
'currentcourse' =>$courseName,
'regionaddress' =>$object -> regionaddress ->value, 'regionaddress' =>$object -> regionaddress ->value,
'regiontk' =>$object -> regiontk ->value, 'regiontk' =>$object -> regiontk ->value,
'regionarea' =>$object -> regionarea ->value, 'regionarea' =>$object -> regionarea ->value,
...@@ -109,7 +130,9 @@ class SubmitedApplications extends ControllerBase ...@@ -109,7 +130,9 @@ class SubmitedApplications extends ControllerBase
'graduation_year' =>$object -> graduation_year ->value, 'graduation_year' =>$object -> graduation_year ->value,
'telnum' =>$object -> telnum ->value, 'telnum' =>$object -> telnum ->value,
'relationtostudent' =>$object -> relationtostudent ->value, 'relationtostudent' =>$object -> relationtostudent ->value,
'birthdate' =>$object -> birthdate ->value, 'birthdate' => substr($object->birthdate->value, 8, 2) . '/' . substr($object->birthdate->value, 6, 2) . '/' . substr($object->birthdate->value, 0, 4),
'created' => date('d/m/Y H:i', $object -> created ->value),
); );
$i++; $i++;
......
<?php
namespace Drupal\epal\Controller;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Database\Connection;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\epal\Client;
class WSConsumer extends ControllerBase
{
protected $entityTypeManager;
protected $logger;
protected $client;
protected $settings;
public function __construct(EntityTypeManagerInterface $entityTypeManager, LoggerChannelFactoryInterface $loggerChannel)
{
$config = $this->config('epal.settings');
foreach (['ws_endpoint', 'ws_username', 'ws_password', 'verbose', 'NO_SAFE_CURL'] as $setting) {
$this->settings[$setting] = $config->get($setting);
}
$this->entityTypeManager = $entityTypeManager;
$this->logger = $loggerChannel->get('epal-school');
$this->client = new Client($this->settings, $this->logger);
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity_type.manager'), $container->get('logger.factory')
);
}
public function getPing(Request $request)
{
return (new JsonResponse(['message' => 'Ping!!!']))
->setStatusCode(Response::HTTP_OK);
}
public function getAllDidactiYear()
{
$ts_start = microtime(true);
try {
$catalog = $this->client->getAllDidactiYear();
} catch (\Exception $e) {
return (new JsonResponse(['message' => $e->getMessage()]))
->setStatusCode(($code = $e->getCode()) == 0 ? Response::HTTP_INTERNAL_SERVER_ERROR : $code);
}
$duration = microtime(true) - $ts_start;
$this->logger->info(__METHOD__ . " :: timed [{$duration}]");
return (new JsonResponse([
'message' => 'Επιτυχία',
'data' => $catalog
]))
->setStatusCode(Response::HTTP_OK);
}
public function getStudentEpalPromotion($didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name)
{
$ts_start = microtime(true);
try {
$result = $this->client->getStudentEpalPromotion($didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name);
} catch (\Exception $e) {
return (new JsonResponse(['message' => $e->getMessage()]))
->setStatusCode(($code = $e->getCode()) == 0 ? Response::HTTP_INTERNAL_SERVER_ERROR : $code);
}
$duration = microtime(true) - $ts_start;
$this->logger->info(__METHOD__ . " :: timed [{$duration}]");
return (new JsonResponse([
'message' => 'Επιτυχία',
'data' => $result
]))
->setStatusCode(Response::HTTP_OK);
}
public function getStudentEpalCertification($didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name)
{
$ts_start = microtime(true);
try {
$result = $this->client->getStudentEpalCertification($didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name);
} catch (\Exception $e) {
return (new JsonResponse(['message' => $e->getMessage()]))
->setStatusCode(($code = $e->getCode()) == 0 ? Response::HTTP_INTERNAL_SERVER_ERROR : $code);
}
$duration = microtime(true) - $ts_start;
$this->logger->info(__METHOD__ . " :: timed [{$duration}]");
return (new JsonResponse([
'message' => 'Επιτυχία',
'data' => $result
]))
->setStatusCode(Response::HTTP_OK);
}
private function generateRandomString($length)
{
$characters = ['Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω'];
$charactersLength = count($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
// private function respondWithStatus($arr, $s)
// {
// $res = new JsonResponse($arr);
// $res->setStatusCode($s);
// return $res;
// }
}
<?php
namespace Drupal\epal;
use Defuse\Crypto\Key;
use Defuse\Crypto\Crypto;
use \Exception;
class Crypt
{
private $fname; // store
public function __construct($fname)
{
if (is_string($fname)) {
$this->fname = $fname;
} else {
$this->fname = __DIR__ . "/../../../../../app.txt";
}
}
/**
* @throws \Exception If key is not found
* @return string The key to use
*/
protected function loadKey()
{
if (!is_readable($this->fname) || !is_file($this->fname)) {
throw new \Exception(__METHOD__ . ':: No file');
}
$keystring = file_get_contents($this->fname);
if ($keystring === false) {
throw new \Exception(__METHOD__ . ':: Cannot load file');
}
return Key::loadFromAsciiSafeString($keystring);
}
/**
* Provided a string value, encrypt and return encrypted value
*
* @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException if encryption cannot be performed
* @throws \Exception If value to encode is not string
* @return hex encoded encrypted value
*/
public function encrypt($data)
{
if (!is_string($data)) {
throw new \Exception("Data to be encoded can only be strings");
}
$key = $this->loadKey();
$dataenc = Crypto::encrypt($data, $key);
return $dataenc;
}
/**
* Provided a hex encoded encrypted value, decrypt and return original value
*
* @throws \Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException if decrypt failed!
* @return string the original value
*/
public function decrypt($dataenc)
{
$key = $this->loadKey();
$data = Crypto::decrypt($dataenc, $key);
return $data;
}
}
...@@ -527,7 +527,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface ...@@ -527,7 +527,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface
->setLabel(t('Όνομα μαθητή')) ->setLabel(t('Όνομα μαθητή'))
->setDescription(t('Δώσε το μικρό μαθητή.')) ->setDescription(t('Δώσε το μικρό μαθητή.'))
->setSettings(array( ->setSettings(array(
'max_length' => 50, 'max_length' => 1000,
'text_processing' => 0, 'text_processing' => 0,
)) ))
->setRequired(true) ->setRequired(true)
...@@ -548,7 +548,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface ...@@ -548,7 +548,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface
->setLabel(t('Επώνυμο μαθητή')) ->setLabel(t('Επώνυμο μαθητή'))
->setDescription(t('Δώσε το επώνυμο μαθητή.')) ->setDescription(t('Δώσε το επώνυμο μαθητή.'))
->setSettings(array( ->setSettings(array(
'max_length' => 50, 'max_length' => 1000,
'text_processing' => 0, 'text_processing' => 0,
)) ))
->setRequired(true) ->setRequired(true)
...@@ -604,7 +604,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface ...@@ -604,7 +604,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface
->setLabel(t('Όνομα του πατέρα')) ->setLabel(t('Όνομα του πατέρα'))
->setDescription(t('Δώσε το όνομα του πατέρα.')) ->setDescription(t('Δώσε το όνομα του πατέρα.'))
->setSettings(array( ->setSettings(array(
'max_length' => 50, 'max_length' => 1000,
'text_processing' => 0, 'text_processing' => 0,
)) ))
->setRequired(true) ->setRequired(true)
...@@ -646,7 +646,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface ...@@ -646,7 +646,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface
->setLabel(t('Όνομα μητέρας')) ->setLabel(t('Όνομα μητέρας'))
->setDescription(t('Δώσε το όνομα της μητέρας.')) ->setDescription(t('Δώσε το όνομα της μητέρας.'))
->setSettings(array( ->setSettings(array(
'max_length' => 50, 'max_length' => 1000,
'text_processing' => 0, 'text_processing' => 0,
)) ))
->setRequired(true) ->setRequired(true)
...@@ -709,7 +709,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface ...@@ -709,7 +709,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface