Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
49681e06
Commit
49681e06
authored
Jun 14, 2017
by
Open Source Developer
Browse files
bugs
parents
695e19e1
9e92e774
Changes
36
Expand all
Hide whitespace changes
Inline
Side-by-side
drupal/modules/casost/src/Controller/CASLogin.php
View file @
49681e06
...
...
@@ -188,9 +188,11 @@ class CASLogin extends ControllerBase
phpCAS
::
trace
(
$umdobject
);
phpCAS
::
trace
(
$physicaldeliveryofficename
);
$gsnunitcodedn
=
$filterAttribute
(
'edupersonorgunitdn:gsnunitcode:extended'
);
//
phpCAS::trace($physicaldeliveryofficename);
//
$gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended');
$gsnunitcode
=
substr
(
$gsnunitcodedn
,
strpos
(
$gsnunitcodedn
,
";"
)
+
1
);
$gsnunitcode
=
$filterAttribute
(
'edupersonorgunitdn:gsnunitcode'
);
phpCAS
::
trace
(
"
$gsnunitcode
="
);
phpCAS
::
trace
(
$gsnunitcode
);
/* check if myschool account */
...
...
@@ -274,6 +276,7 @@ class CASLogin extends ControllerBase
if
(
$user
)
{
$user
->
setPassword
(
$epalToken
);
$user
->
setUsername
(
$epalToken
);
$user
->
set
(
'init'
,
$userAssigned
[
"id"
]);
$user
->
save
();
}
...
...
drupal/modules/epal/epal.routing.yml
View file @
49681e06
...
...
@@ -46,6 +46,14 @@ epal.submitedapplications:
_controller
:
'
\Drupal\epal\Controller\SubmitedApplications::getSubmittedApplications'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.application_delete
:
path
:
'
/epal/application/delete'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\SubmitedApplications::deleteApplication'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.studentapplication
:
path
:
'
/epal/student/{studentId}'
options
:
...
...
@@ -78,6 +86,14 @@ epal.allocation:
_controller
:
'
\Drupal\epal\Controller\Distribution::createDistribution'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.allocation_second
:
path
:
'
/epal/distribution-secondperiod'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\Distribution::locateSecondPeriodStudents'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.confirmstudents
:
path
:
'
/epal/confirmstudent'
options
:
...
...
@@ -221,7 +237,7 @@ epal.coursesperschools:
defaults
:
_controller
:
'
\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements
:
_user_is_logged_in
:
'
TRUE'
_user_is_logged_in
:
'
TRUE'
epal.critirioschosen
:
path
:
'
/epal/critiriachosen/{studentId}/{type}'
options
:
...
...
@@ -278,6 +294,3 @@ epal.findcoursesperschool:
_controller
:
'
\Drupal\epal\Controller\DirectorView::FindCoursesPerSchool'
requirements
:
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/src/Controller/ApplicationSubmit.php
View file @
49681e06
...
...
@@ -101,7 +101,7 @@ class ApplicationSubmit extends ControllerBase
$regionaddress_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'regionaddress'
]);
$regiontk_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'regiontk'
]);
$regionarea_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'regionarea'
]);
$certificatetype_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'certificatetype'
]);
//
$certificatetype_encoded = $crypt->encrypt($applicationForm[0]['certificatetype']);
$relationtostudent_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'relationtostudent'
]);
$telnum_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'telnum'
]);
$guardian_name_encoded
=
$crypt
->
encrypt
(
$applicationForm
[
0
][
'cu_name'
]);
...
...
@@ -157,8 +157,8 @@ class ApplicationSubmit extends ControllerBase
'regionaddress'
=>
$regionaddress_encoded
,
'regionarea'
=>
$regionarea_encoded
,
'regiontk'
=>
$regiontk_encoded
,
'certificatetype'
=>
$certificatetype_encoded
,
'graduation_year'
=>
$applicationForm
[
0
][
'graduation_year'
],
//
'certificatetype' => $certificatetype_encoded,
//
'graduation_year' => $applicationForm[0]['graduation_year'],
'lastschool_registrynumber'
=>
$applicationForm
[
0
][
'lastschool_registrynumber'
],
'lastschool_unittypeid'
=>
$applicationForm
[
0
][
'lastschool_unittypeid'
],
'lastschool_schoolname'
=>
$applicationForm
[
0
][
'lastschool_schoolname'
],
...
...
@@ -285,6 +285,7 @@ class ApplicationSubmit extends ControllerBase
*/
private
function
validateStudent
(
$student
)
{
$error_code
=
0
;
if
(
!
$student
[
"agreement"
])
{
return
1001
;
}
...
...
@@ -298,6 +299,8 @@ class ApplicationSubmit extends ControllerBase
(
checkdate
(
$date_parts
[
1
],
$date_parts
[
2
],
$date_parts
[
0
])
!==
true
))
{
return
1003
;
}
if
(
intval
(
$date_parts
[
0
])
>=
2003
)
return
1003
;
$birthdate
=
"
{
$date_parts
[
2
]
}
-
{
$date_parts
[
1
]
}
-
{
$date_parts
[
0
]
}
"
;
if
(
!
$student
[
"name"
])
{
...
...
@@ -321,12 +324,14 @@ class ApplicationSubmit extends ControllerBase
if
(
!
$student
[
"regionarea"
])
{
return
1010
;
}
/*
if (!$student["certificatetype"]) {
return 1011;
}
if (!$student["graduation_year"]) {
return 1012;
}
*/
if
(
!
$student
[
"currentclass"
]
||
(
$student
[
"currentclass"
]
!==
"1"
&&
$student
[
"currentclass"
]
!==
"2"
&&
$student
[
"currentclass"
]
!==
"3"
&&
$student
[
"currentclass"
]
!==
"4"
)
)
{
return
1013
;
}
...
...
drupal/modules/epal/src/Controller/CurrentUser.php
View file @
49681e06
...
...
@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Request;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\Core\Database\Connection
;
use
Drupal\Core\Logger\LoggerChannelFactoryInterface
;
use
Drupal\epal\Crypt
;
class
CurrentUser
extends
ControllerBase
{
...
...
@@ -84,16 +85,45 @@ class CurrentUser extends ControllerBase
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
if
(
$epalUser
)
{
$crypt
=
new
Crypt
();
try
{
$name_decoded
=
$crypt
->
decrypt
(
$epalUser
->
name
->
value
);
$surname_decoded
=
$crypt
->
decrypt
(
$epalUser
->
surname
->
value
);
$fathername_decoded
=
$crypt
->
decrypt
(
$epalUser
->
fathername
->
value
);
$mothername_decoded
=
$crypt
->
decrypt
(
$epalUser
->
mothername
->
value
);
}
catch
(
\
Exception
$e
)
{
unset
(
$crypt
);
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"error_code"
=>
5001
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
unset
(
$crypt
);
/*
$userName = $epalUser->name->value;
$userSurname = $epalUser->surname->value;
$userFathername = $epalUser->fathername->value;
$userMothername = $epalUser->mothername->value;
*/
$userName
=
$name_decoded
;
$userSurname
=
$surname_decoded
;
$userFathername
=
$fathername_decoded
;
$userMothername
=
$mothername_decoded
;
$userEmail
=
$user
->
mail
->
value
;
return
$this
->
respondWithStatus
([
'cu_name'
=>
mb_substr
(
$epalUser
->
name
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
name
->
value
:
''
,
'cu_surname'
=>
mb_substr
(
$epalUser
->
surname
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
surname
->
value
:
''
,
'cu_fathername'
=>
mb_substr
(
$epalUser
->
fathername
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
fathername
->
value
:
''
,
'cu_mothername'
=>
mb_substr
(
$epalUser
->
mothername
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
mothername
->
value
:
''
,
//'cu_name' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '',
//'cu_surname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '',
//'cu_fathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '',
//'cu_mothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '',
'cu_name'
=>
mb_substr
(
$userName
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userName
:
''
,
'cu_surname'
=>
mb_substr
(
$userSurname
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userSurname
:
''
,
'cu_fathername'
=>
mb_substr
(
$userFathername
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userFathername
:
''
,
'cu_mothername'
=>
mb_substr
(
$userMothername
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userMothername
:
''
,
'cu_email'
=>
mb_substr
(
$user
->
mail
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$user
->
mail
->
value
:
''
,
'minedu_username'
=>
''
,
'minedu_userpassword'
=>
''
,
...
...
@@ -119,16 +149,39 @@ class CurrentUser extends ControllerBase
if
(
$epalUser
)
{
$user
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
load
(
$epalUser
->
user_id
->
target_id
);
if
(
$user
)
{
$userName
=
$epalUser
->
name
->
value
;
$userSurname
=
$epalUser
->
surname
->
value
;
$userFathername
=
$epalUser
->
fathername
->
value
;
$userMothername
=
$epalUser
->
mothername
->
value
;
$crypt
=
new
Crypt
();
try
{
$userName
=
$crypt
->
decrypt
(
$epalUser
->
name
->
value
);
$userSurname
=
$crypt
->
decrypt
(
$epalUser
->
surname
->
value
);
$userFathername
=
$crypt
->
decrypt
(
$epalUser
->
fathername
->
value
);
$userMothername
=
$crypt
->
decrypt
(
$epalUser
->
mothername
->
value
);
}
catch
(
\
Exception
$e
)
{
unset
(
$crypt
);
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"error_code"
=>
5001
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
unset
(
$crypt
);
//$userName = $epalUser->name->value;
//$userSurname = $epalUser->surname->value;
//$userFathername = $epalUser->fathername->value;
//$userMothername = $epalUser->mothername->value;
$userEmail
=
$user
->
mail
->
value
;
return
$this
->
respondWithStatus
([
'userName'
=>
mb_substr
(
$epalUser
->
name
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
name
->
value
:
''
,
'userSurname'
=>
mb_substr
(
$epalUser
->
surname
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
surname
->
value
:
''
,
'userFathername'
=>
mb_substr
(
$epalUser
->
fathername
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
fathername
->
value
:
''
,
'userMothername'
=>
mb_substr
(
$epalUser
->
mothername
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$epalUser
->
mothername
->
value
:
''
,
//'userName' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '',
//'userSurname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '',
//'userFathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '',
//'userMothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '',
'userName'
=>
mb_substr
(
$userName
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userName
:
''
,
'userSurname'
=>
mb_substr
(
$userSurname
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userSurname
:
''
,
'userFathername'
=>
mb_substr
(
$userFathername
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userFathername
:
''
,
'userMothername'
=>
mb_substr
(
$userMothername
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$userMothername
:
''
,
'userEmail'
=>
mb_substr
(
$user
->
mail
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$user
->
mail
->
value
:
''
,
'verificationCodeVerified'
=>
$epalUser
->
verificationcodeverified
->
value
,
],
Response
::
HTTP_OK
);
...
...
@@ -286,23 +339,56 @@ class CurrentUser extends ControllerBase
$postData
=
null
;
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
$crypt
=
new
Crypt
();
try
{
$name_encoded
=
$crypt
->
encrypt
(
$postData
->
userProfile
->
userName
);
$surname_encoded
=
$crypt
->
encrypt
(
$postData
->
userProfile
->
userSurname
);
$fathername_encoded
=
$crypt
->
encrypt
(
$postData
->
userProfile
->
userMothername
);
$mothername_encoded
=
$crypt
->
encrypt
(
$postData
->
userProfile
->
userFathername
);
}
catch
(
\
Exception
$e
)
{
unset
(
$crypt
);
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"error_code"
=>
5001
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
unset
(
$crypt
);
/*
$epalUser->set('name', $postData->userProfile->userName);
$epalUser->set('surname', $postData->userProfile->userSurname);
$epalUser->set('mothername', $postData->userProfile->userMothername);
$epalUser->set('fathername', $postData->userProfile->userFathername);
*/
$epalUser
->
set
(
'name'
,
$name_encoded
);
$epalUser
->
set
(
'surname'
,
$surname_encoded
);
$epalUser
->
set
(
'mothername'
,
$fathername_encoded
);
$epalUser
->
set
(
'fathername'
,
$mothername_encoded
);
$epalUser
->
save
();
$user
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
load
(
$epalUser
->
user_id
->
target_id
);
if
(
$user
)
{
$user
->
set
(
'mail'
,
$postData
->
userProfile
->
userEmail
);
$user
->
save
();
}
else
{
return
$this
->
respondWithStatus
([
'error_code'
=>
'1001'
,
],
Response
::
HTTP_FORBIDDEN
);
}
return
$this
->
respondWithStatus
([
'
message'
=>
t
(
"profile saved"
)
,
'
error_code'
=>
'0'
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'
message'
=>
t
(
"post with no data"
)
,
'
error_code'
=>
'1002'
,
],
Response
::
HTTP_BAD_REQUEST
);
}
}
else
{
return
$this
->
respondWithStatus
([
'
message'
=>
t
(
"EPAL user not found"
)
,
'
error_code'
=>
'1003'
,
],
Response
::
HTTP_FORBIDDEN
);
}
}
...
...
drupal/modules/epal/src/Controller/DirectorView.php
View file @
49681e06
This diff is collapsed.
Click to expand it.
drupal/modules/epal/src/Controller/DirectorViewold.php
deleted
100644 → 0
View file @
695e19e1
This diff is collapsed.
Click to expand it.
drupal/modules/epal/src/Controller/Distribution.php
View file @
49681e06
...
...
@@ -276,7 +276,7 @@ class Distribution extends ControllerBase {
$this
->
logger
->
warning
(
$e
->
getMessage
());
$transaction
->
rollback
();
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured"
)
"message"
=>
t
(
"An unexpected problem occured
in createDistribution Method
"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
...
...
@@ -346,6 +346,8 @@ class Distribution extends ControllerBase {
$timestamp
=
strtotime
(
date
(
"Y-m-d"
));
$this
->
connection
->
insert
(
'epal_student_class'
)
->
fields
(
array
(
'id'
=>
$this
->
globalCounterId
++
,
'uuid'
=>
\
Drupal
::
service
(
'uuid'
)
->
generate
(),
...
...
@@ -356,7 +358,7 @@ class Distribution extends ControllerBase {
'currentclass'
=>
$epalStudent
->
currentclass
,
'currentepal'
=>
$epalStudent
->
currentepal
,
'specialization_id'
=>
$specialization_id
,
'points'
=>
$epalStudent
->
points
,
//
'points' => $epalStudent->points,
'distribution_id'
=>
$choice_id
,
'finalized'
=>
1
,
'status'
=>
1
,
...
...
@@ -364,6 +366,7 @@ class Distribution extends ControllerBase {
'changed'
=>
$timestamp
,)
)
->
execute
();
}
//end if
}
//foreach
...
...
@@ -797,5 +800,127 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
public
function
locateSecondPeriodStudents
(
Request
$request
)
{
//POST method is checked
if
(
!
$request
->
isMethod
(
'POST'
))
{
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
);
}
//check where distribution can be done now
$secondPeriodEnabled
=
"0"
;
$config_storage
=
$this
->
entityTypeManager
->
getStorage
(
'epal_config'
);
$epalConfigs
=
$config_storage
->
loadByProperties
(
array
(
'id'
=>
1
));
$epalConfig
=
reset
(
$epalConfigs
);
if
(
!
$epalConfig
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EpalConfig Enity not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
else
{
$secondPeriodEnabled
=
$epalConfig
->
activate_second_period
->
getString
();
}
if
(
$secondPeriodEnabled
===
"0"
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"secondPeriodEnabled setting is false"
),
],
Response
::
HTTP_FORBIDDEN
);
}
try
{
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
,
'currentclass'
,
'currentepal'
))
->
condition
(
'eStudent.second_period'
,
1
,
'='
);
$epalStudents
=
$sCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
//$this->globalCounterId = 10000;
$this
->
globalCounterId
=
$this
->
retrieveLastStudentId
()
+
1
;
if
(
$this
->
locateStudent
(
1
,
$epalStudents
)
===
ERROR_DB
)
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Unexpected Error in locateStudent function"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
if
(
$this
->
findSmallClasses
()
===
ERROR_DB
)
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Unexpected Error in findSmallClasses function AFTER locateSecondPeriodStudents!"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
//αν αποτύχει, δεν γίνεται rollback. --> Λύση: διαγρα΄φή των όποιων αποτελεσμάτων ;;
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured in locateSecondPeriodStudents Method"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
$postData
=
null
;
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
return
$this
->
respondWithStatus
([
'message'
=>
"locateSecondPeriodStudents has made successfully"
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"post with no data"
),
],
Response
::
HTTP_BAD_REQUEST
);
}
}
private
function
retrieveLastStudentId
()
{
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$sCon
->
orderBy
(
'eStudent.id'
,
'desc'
);
$epalStudents
=
$sCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
if
(
$epalStudents
)
{
$epalStrudent
=
reset
(
$epalStudents
);
return
$epalStrudent
->
id
;
}
return
0
;
}
}
drupal/modules/epal/src/Controller/PdfCreator.php
View file @
49681e06
...
...
@@ -88,7 +88,8 @@ class PDFCreator extends ControllerBase {
], Response::HTTP_FORBIDDEN);
*/
//New epal-user validation
//Epal-user validation
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
...
...
@@ -101,7 +102,6 @@ class PDFCreator extends ControllerBase {
],
Response
::
HTTP_FORBIDDEN
);
}
}
//end New User validation
//user role validation
...
...
@@ -297,7 +297,7 @@ class PDFCreator extends ControllerBase {
$studentsurname_decoded
=
$this
->
crypt
->
decrypt
(
$student
->
studentsurname
->
value
);
$fatherfirstname_decoded
=
$this
->
crypt
->
decrypt
(
$student
->
fatherfirstname
->
value
);
$motherfirstname_decoded
=
$this
->
crypt
->
decrypt
(
$student
->
motherfirstname
->
value
);
$certificatetype_decoded
=
$this
->
crypt
->
decrypt
(
$student
->
certificatetype
->
value
);
//
$certificatetype_decoded = $this->crypt->decrypt($student->certificatetype->value);
$relationtostudent_decoded
=
$this
->
crypt
->
decrypt
(
$student
->
relationtostudent
->
value
);
$telnum_decoded
=
$this
->
crypt
->
decrypt
(
$student
->
telnum
->
value
);
}
...
...
@@ -375,18 +375,21 @@ class PDFCreator extends ControllerBase {
$this
->
pdf
->
Ln
();
/*
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Τύπος απολυτηρίου:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
//$this->pdf->Cell($width, $height, $this->prepareString($student->certificatetype->value), 0, 'L');
$this->pdf->Cell($width, $height, $this->prepareString($certificatetype_decoded), 0, 'L');
$this->pdf->Ln();
*/
/*
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Έτος κτήσης απολυτηρίου:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString($student->graduation_year->value), 0, 'L');
$this->pdf->Ln();
*/
$this
->
pdf
->
SetFont
(
$this
->
fontLight
,
''
,
$this
->
fontSizeRegular
);
$this
->
pdf
->
Cell
(
$width
+
15
,
$height
,
$this
->
prepareString
(
'Σχολείο τελευταίας φοίτησης:'
),
0
,
'L'
);
...
...
@@ -573,7 +576,7 @@ private function createSchoolChoices($student) {
$this
->
pdf
->
SetFont
(
$this
->
fontBold
,
''
,
$this
->
fontSizeRegular
);
$this
->
pdf
->
Cell
(
$width
,
$height
,
$this
->
prepareString
(
$epalSchool
->
choice_no
->
value
),
0
,
0
,
'C'
);
$this
->
pdf
->
multiCell
(
4
*
width
,
$height
,
$this
->
prepareString
(
$epalSchoolName
->
name
->
value
),
0
,
'L'
);
$this
->
pdf
->
multiCell
(
4
*
$
width
,
$height
,
$this
->
prepareString
(
$epalSchoolName
->
name
->
value
),
0
,
'L'
);
}
}
...
...
drupal/modules/epal/src/Controller/SubmitedApplications.php
View file @
49681e06
...
...
@@ -44,6 +44,86 @@ class SubmitedApplications extends ControllerBase
);
}
public
function
deleteApplication
(
Request
$request
)
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"error_code"
=>
2001
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
$content
=
$request
->
getContent
();
$applicationId
=
0
;
if
(
!
empty
(
$content
))
{
$postArr
=
json_decode
(
$content
,
TRUE
);
$applicationId
=
$postArr
[
'applicationId'
];
}
else
{
return
$this
->
respondWithStatus
([
"error_code"
=>
5002
],
Response
::
HTTP_BAD_REQUEST
);
}
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$transaction
=
$this
->
connection
->
startTransaction
();
try
{
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
if
(
$epalUser
)
{
$userid
=
$epalUser
->
id
();
$epalStudents
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student'
)
->
loadByProperties
(
array
(
'epaluser_id'
=>
$userid
,
'id'
=>
$applicationId
));
$epalStudent
=
reset
(
$epalStudents
);
if
(
$epalStudent
)
{
$epalStudentClasses
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'student_id'
=>
$applicationId
));
$epalStudentClass
=
reset
(
$epalStudentClasses
);
if
(
$epalStudentClass
)
{
return
$this
->
respondWithStatus
([
"error_code"
=>
3002
],
Response
::
HTTP_FORBIDDEN
);
}
$delQuery
=
$this
->
connection
->
delete
(
'epal_student_epal_chosen'
);
$delQuery
->
condition
(
'student_id'
,
$applicationId
);
$delQuery
->
execute
();
$delQuery
=
$this
->
connection
->
delete
(
'epal_student_sector_field'
);
$delQuery
->
condition
(
'student_id'
,
$applicationId
);
$delQuery
->
execute
();
$delQuery
=
$this
->
connection
->
delete
(
'epal_student_course_field'
);
$delQuery
->
condition
(
'student_id'
,
$applicationId
);
$delQuery
->
execute
();
$delQuery
=
$this
->
connection
->
delete
(
'epal_student_class'
);
$delQuery
->
condition
(
'student_id'
,
$applicationId
);
$delQuery
->
execute
();
$epalStudent
->
delete
();
return
$this
->
respondWithStatus
([
'error_code'
=>
0
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'EPAL student not found'
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'EPAL user not found'
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
$transaction
->
rollback
();
return
$this
->
respondWithStatus
([
'error_code'
=>
5001