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
083b47ea
Commit
083b47ea
authored
Jun 14, 2017
by
Σταύρος Παπαδάκης
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for ConfirmStudents
parent
1a3540d5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
217 deletions
+157
-217
drupal/modules/epal/src/Controller/DirectorView.php
drupal/modules/epal/src/Controller/DirectorView.php
+157
-217
No files found.
drupal/modules/epal/src/Controller/DirectorView.php
View file @
083b47ea
...
...
@@ -40,7 +40,6 @@ class DirectorView extends ControllerBase
public
function
getStudentPerSchool
(
Request
$request
,
$classId
,
$sector
,
$specialit
)
{
try
{
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$epalConfigs
=
$this
->
entityTypeManager
->
getStorage
(
'epal_config'
)
->
loadByProperties
(
array
(
'name'
=>
'epal_config'
));
...
...
@@ -72,41 +71,34 @@ class DirectorView extends ControllerBase
$userRoles
=
$user
->
getRoles
();
$userRole
=
''
;
foreach
(
$userRoles
as
$tmpRole
)
{
if
(
$tmpRole
===
'epal'
)
{
foreach
(
$userRoles
as
$tmpRole
)
{
if
(
$tmpRole
===
'epal'
)
{
$userRole
=
$tmpRole
;
}
}
if
(
$userRole
===
''
)
{
if
(
$userRole
===
''
)
{
return
$this
->
respondWithStatus
([
'error_code'
=>
4003
,
],
Response
::
HTTP_FORBIDDEN
);
}
elseif
(
$userRole
===
'epal'
)
{
}
elseif
(
$userRole
===
'epal'
)
{
$selectIdNew
=
$selectId
;
if
(
$classId
==
1
)
if
(
$classId
==
1
)
{
$selectIdNew
=
-
1
;
elseif
(
$classId
==
2
)
}
elseif
(
$classId
==
2
)
{
$selectIdNew
=
$sector
;
else
}
else
{
$selectIdNew
=
$specialit
;
}
$studentPerSchool
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$epalId
,
'specialization_id'
=>
$selectIdNew
,
'currentclass'
=>
$classId
));
}
$i
=
0
;
if
(
$studentPerSchool
)
{
if
(
$studentPerSchool
)
{
$list
=
array
();
foreach
(
$studentPerSchool
as
$object
)
{
foreach
(
$studentPerSchool
as
$object
)
{
$studentId
=
intval
(
$object
->
student_id
->
getString
());
$epalStudents
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student'
)
->
loadByProperties
(
array
(
'id'
=>
$studentId
));
$epalStudent
=
reset
(
$epalStudents
);
if
(
$epalStudents
)
{
if
(
$epalStudents
)
{
$studentIdNew
=
$epalStudent
->
id
();
$checkstatus
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'student_id'
=>
$studentIdNew
));
$checkstudentstatus
=
reset
(
$checkstatus
);
...
...
@@ -115,15 +107,16 @@ class DirectorView extends ControllerBase
if
(
$epalStudent
->
currentclass
->
value
===
'2'
)
{
$sectors
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_sector_field'
)
->
loadByProperties
(
array
(
'student_id'
=>
$studentIdNew
));
$sector
=
reset
(
$sectors
);
if
(
$sector
)
if
(
$sector
)
{
$sectorName
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_sectors'
)
->
load
(
$sector
->
sectorfield_id
->
target_id
)
->
name
->
value
;
}
else
if
(
$epalStudent
->
currentclass
->
value
===
'3'
||
$epalStudent
->
currentclass
->
value
===
'4'
)
{
}
else
if
(
$epalStudent
->
currentclass
->
value
===
'3'
||
$epalStudent
->
currentclass
->
value
===
'4'
)
{
$courses
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_course_field'
)
->
loadByProperties
(
array
(
'student_id'
=>
$studentIdNew
));
$course
=
reset
(
$courses
);
if
(
$course
)
if
(
$course
)
{
$courseName
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialty'
)
->
load
(
$course
->
coursefield_id
->
target_id
)
->
name
->
value
;
}
}
$crypt
=
new
Crypt
();
...
...
@@ -142,7 +135,6 @@ class DirectorView extends ControllerBase
$guardian_surname_decoded
=
$crypt
->
decrypt
(
$epalStudent
->
guardian_surname
->
value
);
$guardian_fathername_decoded
=
$crypt
->
decrypt
(
$epalStudent
->
guardian_fathername
->
value
);
$guardian_mothername_decoded
=
$crypt
->
decrypt
(
$epalStudent
->
guardian_mothername
->
value
);
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
__METHOD__
.
' Decrypt error: '
.
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
...
...
@@ -185,23 +177,17 @@ class DirectorView extends ControllerBase
}
return
$this
->
respondWithStatus
(
$list
,
Response
::
HTTP_OK
);
}
else
{
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Students not found!'
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
else
{
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'User not found!'
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
catch
(
\
Exception
$e
)
{
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Unexpected Error'
),
...
...
@@ -209,18 +195,13 @@ class DirectorView extends ControllerBase
}
}
public
function
ConfirmStudents
(
Request
$request
)
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Method Not Allowed'
),
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Method Not Allowed'
)],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$users
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$authToken
));
$user
=
reset
(
$users
);
if
(
$user
)
{
...
...
@@ -231,74 +212,42 @@ class DirectorView extends ControllerBase
$userRole
=
$tmpRole
;
}
}
if
(
$userRole
===
''
)
{
return
$this
->
respondWithStatus
([
'error_code'
=>
4003
,
],
Response
::
HTTP_FORBIDDEN
);
}
elseif
(
$userRole
===
'epal'
)
{
$postData
=
null
;
if
(
$userRole
===
'epal'
)
{
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
$arr
=
$postData
->
students
;
$type
=
$postData
->
type
;
$valnew
=
intval
(
$arr
);
$typen
=
intval
(
$type
);
$studentForConfirm
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'id'
=>
$valnew
)
);
$studentForConfirm
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
([
'student_id'
=>
$valnew
]
);
$studentConfirm
=
reset
(
$studentForConfirm
);
if
(
$studentConfirm
)
{
if
(
$typen
===
1
)
{
$studentConfirm
->
set
(
'directorconfirm'
,
1
);
$studentConfirm
->
save
();
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'saved'
)
,
],
Response
::
HTTP_OK
);
}
elseif
(
$typen
===
2
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'saved'
)],
Response
::
HTTP_OK
);
}
elseif
(
$typen
===
2
)
{
$studentConfirm
->
set
(
'directorconfirm'
,
0
);
$studentConfirm
->
save
();
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'saved'
)
,
],
Response
::
HTTP_OK
);
}
elseif
(
$typen
===
3
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'saved'
)],
Response
::
HTTP_OK
);
}
elseif
(
$typen
===
3
)
{
unset
(
$studentConfirm
->
{
directorconfirm
});
$studentConfirm
->
save
();
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'saved'
)
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Bad request'
),
],
Response
::
HTTP_FORBIDDEN
);
}
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'saved'
)],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Bad request'
)],
Response
::
HTTP_FORBIDDEN
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Student not found'
),
],
Response
::
HTTP_FORBIDDEN
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'Student not found'
)],
Response
::
HTTP_FORBIDDEN
);
}
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'post with no data'
)],
Response
::
HTTP_BAD_REQUEST
);
}
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'post with no data'
),
],
Response
::
HTTP_BAD_REQUEST
);
return
$this
->
respondWithStatus
([
'error_code'
=>
4003
],
Response
::
HTTP_FORBIDDEN
);
}
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'EPAL user not found'
),
],
Response
::
HTTP_FORBIDDEN
);
return
$this
->
respondWithStatus
([
'message'
=>
t
(
'EPAL user not found'
)],
Response
::
HTTP_FORBIDDEN
);
}
}
...
...
@@ -502,7 +451,8 @@ class DirectorView extends ControllerBase
$list
=
array
();
$categ
=
$SchoolCat
->
metathesis_region
->
value
;
}
$CourseA
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
));
// $CourseA = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id' => $schoolid));
$CourseA
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
));
if
(
$CourseA
)
{
$limit_down
=
$this
->
entityTypeManager
->
getStorage
(
'epal_class_limits'
)
->
loadByProperties
(
array
(
'name'
=>
1
,
'category'
=>
$categ
));
...
...
@@ -688,8 +638,6 @@ class DirectorView extends ControllerBase
$classcapacity
=
reset
(
$CourseA
);
if
(
$classcapacity
)
{
$list
[]
=
array
(
'class'
=>
1
,
'newsector'
=>
0
,
...
...
@@ -703,8 +651,6 @@ class DirectorView extends ControllerBase
++
$i
;
$CourseB
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_sectors_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
));
if
(
$CourseB
)
{
foreach
(
$CourseB
as
$object
)
{
$sectorid
=
$object
->
sector_id
->
entity
->
id
();
...
...
@@ -725,9 +671,7 @@ class DirectorView extends ControllerBase
}
$CourseC
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
));
if
(
$CourseC
)
{
foreach
(
$CourseC
as
$object
)
{
$specialityid
=
$object
->
specialty_id
->
entity
->
id
();
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialty_id'
=>
$specialityid
));
$classcapacity
=
reset
(
$CapacityPerClass
);
...
...
@@ -747,9 +691,7 @@ class DirectorView extends ControllerBase
}
if
(
$CourseC
&&
$operation_shift
!=
'ΗΜΕΡΗΣΙΟ'
)
{
foreach
(
$CourseC
as
$object
)
{
$specialityid
=
$object
->
specialty_id
->
entity
->
id
();
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialty_id'
=>
$specialityid
));
...
...
@@ -869,7 +811,6 @@ class DirectorView extends ControllerBase
$limit
=
$limitdown
->
limit_down
->
value
;
}
foreach
(
$CourseC
as
$object
)
{
$specialityid
=
$object
->
specialty_id
->
entity
->
id
();
$studentPerSchool
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialization_id'
=>
$specialityid
,
'currentclass'
=>
3
));
...
...
@@ -894,7 +835,6 @@ class DirectorView extends ControllerBase
$limit
=
$limitdown
->
limit_down
->
value
;
}
foreach
(
$CourseC
as
$object
)
{
$specialityid
=
$object
->
specialty_id
->
entity
->
id
();
$studentPerSchool
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student_class'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialization_id'
=>
$specialityid
,
'currentclass'
=>
4
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment