Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
e-epal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
a18ff2f1
Commit
a18ff2f1
authored
Apr 28, 2017
by
Open Source Developer
Browse files
Options
Browse Files
Download
Plain Diff
conflic
parents
2e84628d
c87596aa
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
1702 additions
and
249 deletions
+1702
-249
drupal/modules/casost/src/Controller/CASLogin.php
drupal/modules/casost/src/Controller/CASLogin.php
+34
-14
drupal/modules/casost/src/Controller/CASLogout.php
drupal/modules/casost/src/Controller/CASLogout.php
+1
-0
drupal/modules/epal/epal.routing.yml
drupal/modules/epal/epal.routing.yml
+27
-1
drupal/modules/epal/src/Controller/Distribution.php
drupal/modules/epal/src/Controller/Distribution.php
+148
-24
drupal/modules/epal/src/Controller/MinistryLogin.php
drupal/modules/epal/src/Controller/MinistryLogin.php
+68
-8
drupal/modules/epal/src/Controller/ReportsCreator.php
drupal/modules/epal/src/Controller/ReportsCreator.php
+344
-0
drupal/modules/epaldeploysystem/config/optional/user.role.eduadmin.yml
...s/epaldeploysystem/config/optional/user.role.eduadmin.yml
+42
-0
drupal/modules/epaldeploysystem/config/optional/user.role.regioneduadmin.yml
...deploysystem/config/optional/user.role.regioneduadmin.yml
+42
-0
source/actions/criteria.actions.ts
source/actions/criteria.actions.ts
+9
-1
source/actions/epalclass.actions.ts
source/actions/epalclass.actions.ts
+9
-5
source/actions/regionschools.actions.ts
source/actions/regionschools.actions.ts
+2
-2
source/actions/studentdatafields.actions.ts
source/actions/studentdatafields.actions.ts
+9
-1
source/app.ts
source/app.ts
+1
-1
source/components/home.ts
source/components/home.ts
+2
-1
source/components/main/main.component.html
source/components/main/main.component.html
+1
-1
source/components/minister/minister-informstudents.ts
source/components/minister/minister-informstudents.ts
+81
-0
source/components/minister/minister-reports.ts
source/components/minister/minister-reports.ts
+387
-0
source/components/minister/minister-view.ts
source/components/minister/minister-view.ts
+57
-6
source/components/minister/reports-schema.ts
source/components/minister/reports-schema.ts
+133
-0
source/components/ministry.home.ts
source/components/ministry.home.ts
+34
-14
source/components/navbar/navbar.component.html
source/components/navbar/navbar.component.html
+25
-12
source/components/navbar/navbar.component.ts
source/components/navbar/navbar.component.ts
+31
-5
source/components/student-application-form/application.preview.ts
...omponents/student-application-form/application.preview.ts
+19
-32
source/components/student-application-form/epal.class.select.ts
.../components/student-application-form/epal.class.select.ts
+0
-9
source/components/student-application-form/schools-order-select.ts
...mponents/student-application-form/schools-order-select.ts
+57
-76
source/constants.ts
source/constants.ts
+6
-1
source/containers/globalstyles.css
source/containers/globalstyles.css
+20
-0
source/containers/main.routes.ts
source/containers/main.routes.ts
+7
-1
source/services/auth.service.ts
source/services/auth.service.ts
+1
-1
source/services/helper-data-service.ts
source/services/helper-data-service.ts
+68
-11
source/store/criteria/criteria.reducer.ts
source/store/criteria/criteria.reducer.ts
+4
-1
source/store/epalclasses/epalclasses.reducer.ts
source/store/epalclasses/epalclasses.reducer.ts
+3
-4
source/store/regionschools/regionschools.reducer.ts
source/store/regionschools/regionschools.reducer.ts
+27
-12
source/store/studentdatafields/studentdatafields.reducer.ts
source/store/studentdatafields/studentdatafields.reducer.ts
+3
-5
No files found.
drupal/modules/casost/src/Controller/CASLogin.php
View file @
a18ff2f1
...
...
@@ -91,9 +91,9 @@ class CASLogin extends ControllerBase
$this
->
allowed2
=
$CASOSTConfig
->
allowed2
->
value
;
$this
->
allowed2Value
=
$CASOSTConfig
->
allowed2value
->
value
;
}
//
phpCAS::setDebug("/home/haris/devel/eepal/drupal/modules/casost/phpcas.log");
phpCAS
::
setDebug
(
"/home/haris/devel/eepal/drupal/modules/casost/phpcas.log"
);
// Enable verbose error messages. Disable in production!
//
phpCAS::setVerbose(true);
//
phpCAS::setVerbose(true);
phpCAS
::
client
(
$this
->
serverVersion
,
$this
->
serverHostname
,
...
...
@@ -124,6 +124,10 @@ class CASLogin extends ControllerBase
return
$response
;
}
$attributes
=
phpCAS
::
getAttributes
();
/* foreach ($attributes as $attr_key => $attr_value) {
$this->logger->warning($attr_key);
$this->logger->warning(phpCAS::getAttribute($attr_key));
} */
/* $isAllowed = true;
$att1 = $attributes[$this->allowed1];
...
...
@@ -166,28 +170,44 @@ class CASLogin extends ControllerBase
$filterAttribute
=
function
(
$attribute
)
use
(
$attributes
)
{
if
(
!
isset
(
$attributes
[
$attribute
]))
{
return
;
}
if
(
is_array
(
$attributes
[
$attribute
]))
{
return
$attributes
[
$attribute
];
return
false
;
}
return
$attributes
[
$attribute
];
};
$exposedRole
=
'director'
;
$internalRole
=
'epal'
;
$CASTitle
=
preg_replace
(
'/\s+/'
,
''
,
$filterAttribute
(
'title'
));
if
(
$CASTitle
===
'ΠΕΡΙΦΕΡΕΙΑΚΗΔΙΕΥΘΥΝΣΗΕΚΠΑΙΔΕΥΣΗΣ-ΠΔΕ'
)
{
$exposedRole
=
'pde'
;
$internalRole
=
'regioneduadmin'
;
}
else
if
(
$CASTitle
===
'ΔΙΕΥΘΥΝΣΗΔΕ-ΔIΔΕ'
)
{
$exposedRole
=
'dide'
;
$internalRole
=
'eduadmin'
;
}
else
if
(
$CASTitle
===
'ΕΠΑΛ'
)
{
$exposedRole
=
'director'
;
$internalRole
=
'epal'
;
}
else
{
$response
=
new
Response
();
$this
->
logger
->
warning
(
t
(
'Access is allowed only to official school accounts or administration'
));
$response
->
setContent
(
t
(
'Access is allowed only to official school accounts or administration'
));
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json;charset=UTF-8'
);
return
$response
;
}
// $this->logger->warning('cn=' . $filterAttribute('cn'));
$epalToken
=
$this
->
authenticatePhase2
(
$request
,
$CASUser
,
$filterAttribute
(
'cn'
));
$epalToken
=
$this
->
authenticatePhase2
(
$request
,
$CASUser
,
$
internalRole
,
$
filterAttribute
(
'cn'
));
if
(
$epalToken
)
{
$cookie
=
new
Cookie
(
'auth_token'
,
$epalToken
,
0
,
'/'
,
null
,
false
,
false
);
$cookie2
=
new
Cookie
(
'auth_role'
,
'director'
,
0
,
'/'
,
null
,
false
,
false
);
$cookie2
=
new
Cookie
(
'auth_role'
,
$exposedRole
,
0
,
'/'
,
null
,
false
,
false
);
return
new
RedirectResponseWithCookie
(
$this
->
redirectUrl
,
302
,
array
(
$cookie
,
$cookie2
));
// $headers = array("auth_token" => $epalToken, "auth_role" => "director");
// return new RedirectResponse($this->redirectUrl, 302, $headers);
}
else
{
$response
=
new
Response
();
$response
->
setContent
(
'
forbidde
n'
);
$response
->
setContent
(
'
No proper authenticatio
n'
);
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
...
...
@@ -196,14 +216,14 @@ class CASLogin extends ControllerBase
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
$response
=
new
Response
();
$response
->
setContent
(
'
forbidden
'
);
$response
->
setContent
(
'
Unexpected Problem
'
);
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
}
public
function
authenticatePhase2
(
$request
,
$CASUser
,
$cn
)
public
function
authenticatePhase2
(
$request
,
$CASUser
,
$
internalRole
,
$
cn
)
{
$trx
=
$this
->
connection
->
startTransaction
();
try
{
...
...
@@ -241,7 +261,7 @@ class CASLogin extends ControllerBase
$user
->
set
(
'preferred_admin_langcode'
,
$language_interface
->
getId
());
//Adding default user role
$user
->
addRole
(
'epal'
);
$user
->
addRole
(
$internalRole
);
$user
->
save
();
}
...
...
drupal/modules/casost/src/Controller/CASLogout.php
View file @
a18ff2f1
...
...
@@ -110,6 +110,7 @@ class CASLogout extends ControllerBase
if
(
!
$user
)
{
$this
->
logger
->
warning
(
"user not found"
);
$response
=
new
Response
();
$response
->
setContent
(
'forbidden'
);
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
...
...
drupal/modules/epal/epal.routing.yml
View file @
a18ff2f1
...
...
@@ -78,10 +78,12 @@ epal.demo_data:
_access
:
'
TRUE'
epal.allocation
:
path
:
'
/epal/distribution'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\Distribution::createDistribution'
requirements
:
_access
:
'
TRUE'
_user_is_logged_in
:
'
TRUE'
sectorperschool
:
path
:
'
/epal/sectorperSchool/{epalId}'
options
:
...
...
@@ -130,3 +132,27 @@ epal.ministry.log_in_go:
_controller
:
'
\Drupal\epal\Controller\MinistryLogin::loginGo'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.log_out_go
:
path
:
'
/ministry/logout'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\MinistryLogin::logoutGo'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.general_report
:
path
:
'
/ministry/general-report'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\ReportsCreator::makegGeneralReport'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.report1
:
path
:
'
/ministry/report-completeness'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\ReportsCreator::makeReportCompleteness'
requirements
:
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/src/Controller/Distribution.php
View file @
a18ff2f1
...
...
@@ -73,15 +73,37 @@ class Distribution extends ControllerBase {
$numDistributions
=
3
;
$sizeOfBlock
=
100000
;
/
*
/
/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
);
}
//clearDistributionResults();
$transaction
=
$this
->
connection
->
startTransaction
();
...
...
@@ -91,18 +113,18 @@ class Distribution extends ControllerBase {
$this
->
connection
->
delete
(
'epal_student_class'
)
->
execute
();
$limitUp_class
=
$this
->
retrieveCapacityLimitUp
(
"Α"
);
print_r
(
"<br> ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ: "
.
$limitUp_class
);
//
print_r("<br> ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ: " . $limitUp_class);
while
(
$this
->
choice_id
<=
$numDistributions
)
{
print_r
(
"<br>ΠΕΡΑΣΜΑ: "
.
$this
->
choice_id
);
//
print_r("<br>ΠΕΡΑΣΜΑ: " . $this->choice_id);
//υπολογισμός πλήθους non-finalized αιτήσεων για να καθοριστεί ο αριθμός των fetches που θα κάνουμε με συγκεκριμένο sizeOfBlock
if
(
$this
->
choice_id
===
1
)
{
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$numData
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
print_r
(
"<br>numData: "
.
$numData
);
//
print_r("<br>numData: " . $numData);
}
$j
=
1
;
...
...
@@ -110,7 +132,7 @@ class Distribution extends ControllerBase {
if
(
$this
->
choice_id
===
1
)
{
while
(
$num
<=
$numData
)
{
print_r
(
"<br>FETCH: "
.
$j
);
//
print_r("<br>FETCH: " . $j);
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
,
'name'
,
'currentclass'
,
'currentepal'
,
'points'
))
->
condition
(
'eStudent.id'
,
1
+
$sizeOfBlock
*
(
$j
-
1
),
'>='
)
...
...
@@ -131,9 +153,6 @@ class Distribution extends ControllerBase {
->
condition
(
'eStudent.id'
,
$this
->
pendingStudents
,
'IN'
);
$epalStudents
=
$sCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
//foreach ($epalStudents as $x)
// print_r("<br> TEST:" . $x->id . " ");
$this
->
locateStudent
(
$this
->
choice_id
,
$epalStudents
);
}
else
{
//αν δεν υπάρχουν εκκρεμότητες, μην συνεχίζεις με άλλο πέρασμα
...
...
@@ -177,6 +196,7 @@ class Distribution extends ControllerBase {
}
//end while
}
//end try
catch
(
\
Exception
$e
)
{
...
...
@@ -187,9 +207,26 @@ class Distribution extends ControllerBase {
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
//return new RedirectResponse($this->redirectUrl . '?auth_token=' . $epalToken.'&auth_role=director', 302, []);
//return new RedirectResponse("../eepal/dist/#/minister/minister-view");
/*
return $this->respondWithStatus([
"message" => t("Distribution has made successfully")
], Response::HTTP_OK);
*/
$postData
=
null
;
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
return
$this
->
respondWithStatus
([
'message'
=>
"Distribution has made successfu"
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"post with no data"
),
],
Response
::
HTTP_BAD_REQUEST
);
}
}
...
...
@@ -204,8 +241,8 @@ class Distribution extends ControllerBase {
try
{
foreach
(
$epalStudents
as
$epalStudent
)
{
print_r
(
"<br>ΚΑΤΑΝΟΜΗ ΜΑΘΗΤΩΝ ΝΟ: "
.
$choice_id
);
print_r
(
"<br>ΜΑΘΗΤΗΣ: "
.
$epalStudent
->
id
);
//
print_r("<br>ΚΑΤΑΝΟΜΗ ΜΑΘΗΤΩΝ ΝΟ: " . $choice_id);
//
print_r("<br>ΜΑΘΗΤΗΣ: " . $epalStudent->id);
$clCon
=
$this
->
connection
->
select
(
'epal_student_epal_chosen'
,
'epals'
)
->
fields
(
'epals'
,
array
(
'student_id'
,
'epal_id'
,
'choice_no'
))
...
...
@@ -215,7 +252,7 @@ class Distribution extends ControllerBase {
if
(
sizeof
(
$epalSchoolsChosen
)
!==
0
)
{
$epalSchoolChos
=
reset
(
$epalSchoolsChosen
);
print_r
(
" SCHOOL_ID:"
.
$epalSchoolChos
->
epal_id
.
" STUDENT_ID "
.
$epalStudent
->
id
);
//
print_r(" SCHOOL_ID:" . $epalSchoolChos->epal_id . " STUDENT_ID " . $epalStudent->id);
$epal_dist_id
=
$epalSchoolChos
->
epal_id
;
if
(
$epalStudent
->
currentclass
===
"2"
)
{
...
...
@@ -316,7 +353,7 @@ class Distribution extends ControllerBase {
->
condition
(
'studentClass.specialization_id'
,
$secCourId
,
'='
);
$epalStudentClass
=
$clCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
print_r
(
"<br> ΣΧΟΛΕΙΟ: "
.
$epalId
.
" ΤΑΞΗ: "
.
$classId
.
" ΤΟΜΕΑΣ/ΕΙΔΙΚΟΤΗΤΑ: "
.
$secCourId
.
" ΧΩΡΗΤΙΚΟΤΗΤΑ: "
.
sizeof
(
$epalStudentClass
));
//
print_r("<br> ΣΧΟΛΕΙΟ: " . $epalId . " ΤΑΞΗ: " . $classId . " ΤΟΜΕΑΣ/ΕΙΔΙΚΟΤΗΤΑ: " . $secCourId . " ΧΩΡΗΤΙΚΟΤΗΤΑ: " . sizeof($epalStudentClass));
//ΕΠΙΠΛΕΟΝ ΕΠΙΠΕΔΟ ΑΣΦΑΛΕΙΑΣ: αν δεν υπάρχει ο συγκεκριμένος τομέας/ειδικότητα στο σχολείο
//ο μαθητής που τοποθετήθηκε με την locateStudent να διαγραφεί
...
...
@@ -337,7 +374,7 @@ class Distribution extends ControllerBase {
$limit
=
$limitup
*
$capacity
;
if
(
sizeof
(
$epalStudentClass
)
>
$limit
)
{
print_r
(
"<br>ΥΠΕΡΧΕΙΛΙΣΗ!"
);
//
print_r("<br>ΥΠΕΡΧΕΙΛΙΣΗ!");
foreach
(
$epalStudentClass
as
$epalStudCl
)
{
//Υπολογισμός μορίων του μαθητή και (πιθανή) αποθήκευσή τους
//ΣΗΜΕΙΩΣΗ: Ο υπoλογισμός γίνεται στο front-end
...
...
@@ -395,7 +432,7 @@ class Distribution extends ControllerBase {
foreach
(
$students
as
$student
)
{
$student
->
student_id
;
print_r
(
"<br>STUDENT_ID:"
.
$student
->
student_id
);
//
print_r("<br>STUDENT_ID:" . $student->student_id);
}
//εύρεση αριθμού μαθητών που ήδη φοιτούσαν στο σχολείο
...
...
@@ -408,11 +445,11 @@ class Distribution extends ControllerBase {
$this
->
removeFromPendingStudents
(
$student
->
student_id
);
}
}
print_r
(
"<br>#ΕΓΓΡΑΦΩΝ ΠΟΥ ΟΙ ΜΑΘΗΤΕΣ ΦΟΙΤΟΥΣΑΝ ΗΔΗ:"
.
$cnt
);
//
print_r("<br>#ΕΓΓΡΑΦΩΝ ΠΟΥ ΟΙ ΜΑΘΗΤΕΣ ΦΟΙΤΟΥΣΑΝ ΗΔΗ:" . $cnt);
$newlimit
=
$limit
-
$cnt
;
print_r
(
"<br>ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ:"
.
$limit
);
print_r
(
"<br>#ΜΑΘΗΤΩΝ ΓΙΑ ΝΑ ΕΠΙΛΕΓΟΥΝ ΜΕ ΜΟΡΙΑ:"
.
$newlimit
);
//
print_r("<br>ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ:" . $limit);
//
print_r("<br>#ΜΑΘΗΤΩΝ ΓΙΑ ΝΑ ΕΠΙΛΕΓΟΥΝ ΜΕ ΜΟΡΙΑ:" . $newlimit);
$points_arr
=
[];
foreach
(
$students
as
$student
)
{
...
...
@@ -421,17 +458,17 @@ class Distribution extends ControllerBase {
}
rsort
(
$points_arr
);
for
(
$i
=
0
;
$i
<
sizeof
(
$points_arr
);
$i
++
)
print_r
(
"<br>ΜΟΡΙΑ ΜΕΤΑ ΤΗΝ ΤΑΞΙΝΟΜΙΣΗ: "
.
$points_arr
[
$i
]);
//
for ($i=0; $i < sizeof($points_arr); $i++)
//
print_r("<br>ΜΟΡΙΑ ΜΕΤΑ ΤΗΝ ΤΑΞΙΝΟΜΙΣΗ: " . $points_arr[$i]);
print_r
(
"<br>ΟΡΙΟ ΜΟΡΙΩΝ: "
.
$points_arr
[
$newlimit
-
1
]);
//
print_r("<br>ΟΡΙΟ ΜΟΡΙΩΝ: " . $points_arr[$newlimit-1]);
$transaction
=
$this
->
connection
->
startTransaction
();
foreach
(
$students
as
$student
)
{
if
(
$student
->
currentepal
!==
$student
->
epal_id
)
{
if
(
$student
->
points
<
$points_arr
[
$newlimit
-
1
])
{
print_r
(
"<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: "
.
$student
->
student_id
);
//
print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id);
//βάλε τον μαθητή στον πίνακα εκκρεμοτήτων και διέγραψέ τον από τον προσωρινό πίνακα αποτελεσμάτων
array_push
(
$this
->
pendingStudents
,
$student
->
student_id
);
try
{
...
...
@@ -476,4 +513,91 @@ class Distribution extends ControllerBase {
public
function
makegGeneralReport
(
Request
$request
)
{
try
{
if
(
!
$request
->
isMethod
(
'GET'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
//Note: $authToken = $postData->username
$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
//$user = \Drupal\user\Entity\User::load($user->id());
$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
);
}
//υπολογισμός αριθμού αιτήσεων
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$numTotal
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
//υπολογισμός αριθμού αιτήσεων που ικανοποιήθηκαν στην i προτίμηση
$numData
=
array
();
for
(
$i
=
0
;
$i
<
3
;
$i
++
)
{
$sCon
=
$this
->
connection
->
select
(
'epal_student_class'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
,
'distribution_id'
))
->
condition
(
'eStudent.distribution_id'
,
$i
+
1
,
'='
);
array_push
(
$numData
,
$sCon
->
countQuery
()
->
execute
()
->
fetchField
());
}
// υπολογισμός αριθμού αιτήσεων που ΔΕΝ ικανοποιήθηκαν
//Σημείωση: υπολογισμός με queries στη βάση
$sCon
=
$this
->
connection
->
select
(
'epal_student_class'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$epalStudents
=
$sCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
$studentIds
=
array
();
foreach
(
$epalStudents
as
$epalStudent
)
array_push
(
$studentIds
,
$epalStudent
->
id
);
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
))
->
condition
(
'eStudent.id'
,
$studentIds
,
'NOT IN'
);
$numNoAllocated
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
$list
[]
=
array
(
'num_applications'
=>
$numTotal
,
'numchoice1'
=>
$numData
[
0
],
'numchoice2'
=>
$numData
[
1
],
'numchoice3'
=>
$numData
[
2
],
'num_noallocated'
=>
$numNoAllocated
,
);
return
$this
->
respondWithStatus
(
$list
,
Response
::
HTTP_OK
);
}
//end try
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured during DELETE proccess in makeSelectionOfStudents Method of Distribution"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
drupal/modules/epal/src/Controller/MinistryLogin.php
View file @
a18ff2f1
...
...
@@ -46,14 +46,15 @@ class MinistryLogin extends ControllerBase
public
function
loginGo
(
Request
$request
)
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
try
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
//Note: $authToken = $postData->username
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
...
...
@@ -86,9 +87,9 @@ class MinistryLogin extends ControllerBase
$postData
=
json_decode
(
$content
);
//return new RedirectResponse("/drupal-8.2.6/eepal/dist/" . '?auth_token=' . $postData->username .'&auth_role=supervisor', 302, []);
return
$this
->
respondWithStatus
([
'auth_token'
=>
$postData
->
username
,
'userpassword'
=>
$postData
->
userpassword
,
'auth_role'
=>
$currentRoleName
,
//
'auth_token' => $postData->username,
//
'userpassword' => $postData->userpassword,
//
'auth_role' => $currentRoleName,
],
Response
::
HTTP_OK
);
}
else
{
...
...
@@ -110,6 +111,65 @@ class MinistryLogin extends ControllerBase
}
public
function
logoutGo
(
Request
$request
)
{
try
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
//Note: $authToken = $postData->username
$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
//$user = \Drupal\user\Entity\User::load($user->id());
/*
$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);
}
*/
session_unset
();
session_destroy
();
$response
=
new
Response
();
$response
->
setContent
(
'logout successful'
);
$response
->
setStatusCode
(
Response
::
HTTP_OK
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
//end try
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
$response
=
new
Response
();
$response
->
setContent
(
'forbidden'
);
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
...
...
drupal/modules/epal/src/Controller/ReportsCreator.php
0 → 100644
View file @
a18ff2f1
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace
Drupal\epal\Controller
;
use
Drupal\Core\Entity\Query\QueryFactory
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Drupal\Core\Controller\ControllerBase
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Database\Connection
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\Core\Logger\LoggerChannelFactoryInterface
;
//use Drupal\Core\Datetime\DrupalDateTime;
use
Drupal\Core\TypedData\Plugin\DataType\TimeStamp
;
use
Drupal\Core\Language\LanguageManagerInterface
;
class
ReportsCreator
extends
ControllerBase
{
protected
$entity_query
;
protected
$entityTypeManager
;
protected
$logger
;
protected
$connection
;
protected
$language
;
protected
$currentuser
;
protected
$pendingStudents
=
array
();
protected
$choice_id
=
1
;
protected
$globalCounterId
=
1
;
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
QueryFactory
$entity_query
,
Connection
$connection
,
LoggerChannelFactoryInterface
$loggerChannel
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
entity_query
=
$entity_query
;
$connection
=
Database
::
getConnection
();
$this
->
connection
=
$connection
;
$language
=
\
Drupal
::
languageManager
()
->
getCurrentLanguage
()
->
getId
();
$this
->
language
=
$language
;
$currentuser
=
\
Drupal
::
currentUser
()
->
id
();
$this
->
currentuser
=
$currentuser
;
$this
->
logger
=
$loggerChannel
->
get
(
'epal'
);
}
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity.query'
),
$container
->
get
(
'database'
),
$container
->
get
(
'logger.factory'
)
);
}
public
function
makegGeneralReport
(
Request
$request
)
{
try
{
if
(
!
$request
->
isMethod
(
'GET'
))
{