Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Σταύρος Παπαδάκης
e-epal
Commits
1eea0731
Commit
1eea0731
authored
Mar 22, 2017
by
Open Source Developer
Browse files
Options
Browse Files
Download
Plain Diff
confl
parents
4471c4fb
1a19f301
Changes
67
Hide whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
1508 additions
and
1446 deletions
+1508
-1446
drupal/modules/epal/epal.routing.yml
drupal/modules/epal/epal.routing.yml
+8
-23
drupal/modules/epal/epal.services.yml
drupal/modules/epal/epal.services.yml
+4
-0
drupal/modules/epal/src/Controller/ApplicationSubmit.php
drupal/modules/epal/src/Controller/ApplicationSubmit.php
+88
-162
drupal/modules/epal/src/Controller/CurrentUser.php
drupal/modules/epal/src/Controller/CurrentUser.php
+67
-22
drupal/modules/epal/src/Controller/Login.php
drupal/modules/epal/src/Controller/Login.php
+0
-190
drupal/modules/epal/src/Entity/EpalClassLimits.php
drupal/modules/epal/src/Entity/EpalClassLimits.php
+4
-4
drupal/modules/epal/src/Entity/EpalCriteria.php
drupal/modules/epal/src/Entity/EpalCriteria.php
+20
-0
drupal/modules/epal/src/Entity/EpalStudent.php
drupal/modules/epal/src/Entity/EpalStudent.php
+197
-57
drupal/modules/epaldeploysystem/config/install/user.role.applicant.yml
...s/epaldeploysystem/config/install/user.role.applicant.yml
+0
-55
drupal/modules/epaldeploysystem/config/install/views.view.criterialist.yml
...aldeploysystem/config/install/views.view.criterialist.yml
+341
-0
drupal/modules/epalreadydata/src/Entity/EepalSchool.php
drupal/modules/epalreadydata/src/Entity/EepalSchool.php
+69
-11
drupal/modules/epalreadydata/src/Entity/EepalSectors.php
drupal/modules/epalreadydata/src/Entity/EepalSectors.php
+1
-1
drupal/modules/epalreadydata/src/Entity/EepalSectorsInEpal.php
...l/modules/epalreadydata/src/Entity/EepalSectorsInEpal.php
+23
-3
drupal/modules/epalreadydata/src/Entity/EepalSpecialtiesInEpal.php
...dules/epalreadydata/src/Entity/EepalSpecialtiesInEpal.php
+23
-3
drupal/modules/epalreadydata/src/Entity/EepalSpecialty.php
drupal/modules/epalreadydata/src/Entity/EepalSpecialty.php
+2
-1
drupal/modules/oauthost/oauthost.services.yml
drupal/modules/oauthost/oauthost.services.yml
+1
-1
drupal/modules/oauthost/src/Controller/CBController.php
drupal/modules/oauthost/src/Controller/CBController.php
+2
-2
source/actions/amkafill.actions.ts
source/actions/amkafill.actions.ts
+0
-21
source/actions/criteria.actions.ts
source/actions/criteria.actions.ts
+19
-2
source/actions/index.ts
source/actions/index.ts
+2
-3
source/actions/logininfo.actions.ts
source/actions/logininfo.actions.ts
+9
-4
source/actions/regionschools.actions.ts
source/actions/regionschools.actions.ts
+4
-3
source/app.settings.deployment.ts
source/app.settings.deployment.ts
+2
-2
source/app.settings.ts
source/app.settings.ts
+0
-1
source/app.ts
source/app.ts
+0
-14
source/components/form-controls/form3.ts
source/components/form-controls/form3.ts
+0
-78
source/components/home.ts
source/components/home.ts
+12
-35
source/components/navbar/navbar.component.html
source/components/navbar/navbar.component.html
+7
-3
source/components/navbar/navbar.component.ts
source/components/navbar/navbar.component.ts
+7
-6
source/components/navbar/navbar.component.ts.save
source/components/navbar/navbar.component.ts.save
+0
-22
source/components/student-application-form/amka-fill.ts
source/components/student-application-form/amka-fill.ts
+0
-93
source/components/student-application-form/application.form.main.html
...nents/student-application-form/application.form.main.html
+49
-50
source/components/student-application-form/application.form.main.ts
...ponents/student-application-form/application.form.main.ts
+59
-63
source/components/student-application-form/application.preview.ts
...omponents/student-application-form/application.preview.ts
+51
-61
source/components/student-application-form/application.submit.ts
...components/student-application-form/application.submit.ts
+62
-85
source/components/student-application-form/parent.form.ts
source/components/student-application-form/parent.form.ts
+74
-0
source/components/student-application-form/region.schools.select.ts
...ponents/student-application-form/region.schools.select.ts
+97
-72
source/components/student-application-form/sector.courses.select.ts
...ponents/student-application-form/sector.courses.select.ts
+24
-45
source/components/student-application-form/sector.fields.select.ts
...mponents/student-application-form/sector.fields.select.ts
+20
-63
source/constants.ts
source/constants.ts
+8
-1
source/containers/main.routes.ts
source/containers/main.routes.ts
+3
-6
source/services/amkacheck-service.ts
source/services/amkacheck-service.ts
+0
-30
source/services/helper-data-service.ts
source/services/helper-data-service.ts
+73
-24
source/store/amkafill/amkafills.initial-state.ts
source/store/amkafill/amkafills.initial-state.ts
+0
-7
source/store/amkafill/amkafills.reducer.ts
source/store/amkafill/amkafills.reducer.ts
+0
-22
source/store/amkafill/amkafills.transformers.ts
source/store/amkafill/amkafills.transformers.ts
+0
-12
source/store/amkafill/amkafills.types.ts
source/store/amkafill/amkafills.types.ts
+0
-11
source/store/amkafill/index.ts
source/store/amkafill/index.ts
+0
-10
source/store/criteria/criteria.initial-state.ts
source/store/criteria/criteria.initial-state.ts
+1
-1
source/store/criteria/criteria.reducer.ts
source/store/criteria/criteria.reducer.ts
+25
-5
source/store/criteria/criteria.transformers.ts
source/store/criteria/criteria.transformers.ts
+1
-2
source/store/criteria/criteria.types.ts
source/store/criteria/criteria.types.ts
+4
-8
source/store/epalclasses/epalclasses.initial-state.ts
source/store/epalclasses/epalclasses.initial-state.ts
+1
-3
source/store/epalclasses/epalclasses.reducer.ts
source/store/epalclasses/epalclasses.reducer.ts
+5
-5
source/store/logininfo/logininfo.initial-state.ts
source/store/logininfo/logininfo.initial-state.ts
+1
-1
source/store/logininfo/logininfo.reducer.ts
source/store/logininfo/logininfo.reducer.ts
+10
-5
source/store/logininfo/logininfo.transformers.ts
source/store/logininfo/logininfo.transformers.ts
+1
-1
source/store/logininfo/logininfo.types.ts
source/store/logininfo/logininfo.types.ts
+1
-0
source/store/regionschools/regionschools.initial-state.ts
source/store/regionschools/regionschools.initial-state.ts
+1
-1
source/store/regionschools/regionschools.reducer.ts
source/store/regionschools/regionschools.reducer.ts
+12
-12
source/store/sectorcourses/sectorcourses.initial-state.ts
source/store/sectorcourses/sectorcourses.initial-state.ts
+1
-1
source/store/sectorcourses/sectorcourses.reducer.ts
source/store/sectorcourses/sectorcourses.reducer.ts
+3
-3
source/store/sectorfields/sectorfields.initial-state.ts
source/store/sectorfields/sectorfields.initial-state.ts
+1
-1
source/store/sectorfields/sectorfields.reducer.ts
source/store/sectorfields/sectorfields.reducer.ts
+3
-3
source/store/store.ts
source/store/store.ts
+2
-7
source/store/studentdatafields/studentdatafields.initial-state.ts
...tore/studentdatafields/studentdatafields.initial-state.ts
+1
-1
source/store/studentdatafields/studentdatafields.reducer.ts
source/store/studentdatafields/studentdatafields.reducer.ts
+2
-2
No files found.
drupal/modules/epal/epal.routing.yml
View file @
1eea0731
epal_is_logged_in
:
path
:
'
/epal/login/check'
defaults
:
_controller
:
'
\Drupal\epal\Controller\Login::helloWorld'
requirements
:
_access
:
'
TRUE'
epal_entityapi_test
:
path
:
'
/epal/entityapi/test'
user_data
:
path
:
'
/epal/userdata'
options
:
_auth
:
[
'
basic_auth'
]
requirements
:
_user_is_logged_in
:
'
TRUE'
defaults
:
_controller
:
'
\Drupal\epal\Controller\Login::testQuery'
epal_auth_test
:
path
:
'
epal/auth/test'
options
:
_auth
:
[
'
oauthost'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\Login::helloWorld'
_title
:
'
Greeting'
_controller
:
'
\Drupal\epal\Controller\CurrentUser::getEpalUserData'
requirements
:
_permission
:
'
access
content'
_user_is_logged_in
:
'
TRUE'
current_user
:
path
:
'
/epal/curuser'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\CurrentUser::
content
'
_controller
:
'
\Drupal\epal\Controller\CurrentUser::
getLoginInfo
'
requirements
:
_
access
:
'
TRUE'
_
user_is_logged_in
:
'
TRUE'
epal.application_submit
:
path
:
'
/epal/appsubmit'
options
:
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\ApplicationSubmit::appSubmit'
requirements
:
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/epal.services.yml
0 → 100644
View file @
1eea0731
services
:
logger.channel.oauth
:
parent
:
'
logger.channel_base'
arguments
:
[
'
oauthost'
]
drupal/modules/epal/src/Controller/ApplicationSubmit.php
View file @
1eea0731
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace
Drupal\epal\Controller
;
...
...
@@ -12,238 +8,168 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Drupal\Core\Controller\ControllerBase
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Drupal\Core\Database\Connection
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\Core\Logger\LoggerChannelFactoryInterface
;
class
ApplicationSubmit
extends
ControllerBase
{
protected
$entity_query
;
protected
$entityTypeManager
;
protected
$logger
;
protected
$connection
;
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
QueryFactory
$entity_query
,
Connection
$connection
,
LoggerChannelFactoryInterface
$loggerChannel
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
entity_query
=
$entity_query
;
$this
->
connection
=
$connection
;
$this
->
logger
=
$loggerChannel
->
get
(
'
oauthost
'
);
$this
->
logger
=
$loggerChannel
->
get
(
'
epal
'
);
}
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity.manager'
),
$container
->
get
(
'entity.query'
),
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'database'
),
$container
->
get
(
'logger.factory'
)
);
}
public
function
appSubmitWORK
()
{
$db
=
\
Drupal\Core\Database\Database
::
getConnection
();
$transaction
=
$db
->
startTransaction
();
try
{
$student
=
array
(
'epaluser_id'
=>
1
,
'name'
=>
'ΝΙΚΟΣ'
,
'studentsurname'
=>
'ΚΑΤΣΑ'
,
'status'
=>
1
);
$entity_manager
=
\
Drupal
::
entityManager
();
$entity_storage_student
=
$entity_manager
->
getStorage
(
'epal_student'
);
$entity_storage_eidikotita
=
$entity_manager
->
getStorage
(
'epal_student_course_field'
);
$entity_object
=
$entity_storage_student
->
create
(
$student
);
$entity_storage_student
->
save
(
$entity_object
);
$created_student_id
=
$entity_object
->
id
();
public
function
appSubmit
(
Request
$request
)
{
$eidikotita
=
array
(
'name'
=>
'record1'
,
'student_id'
=>
1
,
'coursefield_id'
=>
4
,
'status'
=>
1
);
$entity_object
=
$entity_storage_eidikotita
->
create
(
$eidikotita
);
$entity_storage_eidikotita
->
save
(
$entity_object
);
$created_eidikotites_id
=
$entity_object
->
id
();
}
catch
(
\
Exception
$e
)
{
$transaction
->
rollback
();
}
}
public
function
appSubmit2
()
{
$db
=
\
Drupal\Core\Database\Database
::
getConnection
();
$transaction
=
$db
->
startTransaction
();
try
{
$student
=
array
(
'epaluser_id'
=>
1
,
'name'
=>
'ΝΙΚΟΣ'
,
'studentsurname'
=>
'ΚΑΤΣΑ'
,
'status'
=>
1
);
$entity_manager
=
\
Drupal
::
entityManager
();
$entity_storage_student
=
$entity_manager
->
getStorage
(
'epal_student'
);
$entity_storage_course
=
$entity_manager
->
getStorage
(
'epal_student_course_field'
);
$entity_object
=
$entity_storage_student
->
create
(
$student
);
$entity_storage_student
->
save
(
$entity_object
);
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
$created_student_id
=
$entity_object
->
id
();
$course
=
array
(
'name'
=>
'record1'
,
'student_id'
=>
1
,
'coursefield_id'
=>
4
,
'status'
=>
1
);
$entity_object
=
$entity_storage_course
->
create
(
$course
);
$entity_storage_course
->
save
(
$entity_object
);
}
$applicationForm
=
array
();
catch
(
\
Exception
$e
)
{
$transaction
->
rollback
();
}
$content
=
$request
->
getContent
();
}
public
function
appSubmit
()
{
$aitisi
=
array
();
$content
=
\
Drupal
::
request
()
->
getContent
();
if
(
!
empty
(
$content
))
{
$aitisi
=
json_decode
(
$content
,
TRUE
);
//$aitisi[0] --> student data, $aitisi[1][] --> epals chosen, $aitisi[2][] --> criteria, $aitisi[3] --> sector or course chosen
$applicationForm
=
json_decode
(
$content
,
TRUE
);
}
else
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Bad Request"
)
],
Response
::
HTTP_BAD_REQUEST
);
}
$db
=
\
Drupal\Core\Database\Database
::
getConnection
();
$transaction
=
$db
->
startTransaction
();
try
{
$transaction
=
$this
->
connection
->
startTransaction
();
try
{
//insert records in entity: epal_student
$entity_manager
=
\
Drupal
::
entityTypeManager
();
$epaluserid
=
\
Drupal
::
currentUser
()
->
id
();
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
$student
=
array
(
//'epaluser_id' => $aitisi[0][epaluser_id],
'epaluser_id'
=>
$epaluserid
,
'name'
=>
$aitisi
[
0
][
name
],
'studentsurname'
=>
$aitisi
[
0
][
studentsurname
],
//'birthdate' => $aitisi[0][birthdate],
//'fatherfirstname' => $aitisi[0][fatherfirstname],
//'fathersurname' => $aitisi[0][fathersurname],
//'motherfirstname' => $aitisi[0][motherfirstname],
//'mothersurname' => $aitisi[0][mothersurname],
'studentamka'
=>
$aitisi
[
0
][
studentamka
],
'regionaddress'
=>
$aitisi
[
0
][
regionaddress
],
'regionarea'
=>
$aitisi
[
0
][
regionarea
],
'regiontk'
=>
$aitisi
[
0
][
regiontk
],
'certificatetype'
=>
$aitisi
[
0
][
certificatetype
],
//'lastam' => $aitisi[0][lastam],
'currentclass'
=>
$aitisi
[
0
][
currentclass
],
//'currentepal' => $aitisi[0][currentepal],
//'currentsector' => $aitisi[0][currentsector],
'relationtostudent'
=>
$aitisi
[
0
][
relationtostudent
],
'telnum'
=>
$aitisi
[
0
][
telnum
]
'epaluser_id'
=>
$epalUser
->
id
(),
'name'
=>
$applicationForm
[
0
][
name
],
'studentsurname'
=>
$applicationForm
[
0
][
studentsurname
],
//'birthdate' => $applicationForm[0][birthdate],
//'fatherfirstname' => $applicationForm[0][fatherfirstname],
//'fathersurname' => $applicationForm[0][fathersurname],
//'motherfirstname' => $applicationForm[0][motherfirstname],
//'mothersurname' => $applicationForm[0][mothersurname],
'studentamka'
=>
$applicationForm
[
0
][
studentamka
],
'regionaddress'
=>
$applicationForm
[
0
][
regionaddress
],
'regionarea'
=>
$applicationForm
[
0
][
regionarea
],
'regiontk'
=>
$applicationForm
[
0
][
regiontk
],
'certificatetype'
=>
$applicationForm
[
0
][
certificatetype
],
//'lastam' => $applicationForm[0][lastam],
'currentclass'
=>
$applicationForm
[
0
][
currentclass
],
//'currentepal' => $applicationForm[0][currentepal],
//'currentsector' => $applicationForm[0][currentsector],
'relationtostudent'
=>
$applicationForm
[
0
][
relationtostudent
],
'telnum'
=>
$applicationForm
[
0
][
telnum
]
);
$entity_storage_student
=
$entity
_m
anager
->
getStorage
(
'epal_student'
);
$entity_storage_student
=
$
this
->
entity
TypeM
anager
->
getStorage
(
'epal_student'
);
$entity_object
=
$entity_storage_student
->
create
(
$student
);
$entity_storage_student
->
save
(
$entity_object
);
$created_student_id
=
$entity_object
->
id
();
//insert records in entity: epal_student_epal_chosen
for
(
$i
=
0
;
$i
<
sizeof
(
$aitisi
[
1
]);
$i
++
)
{
//insert records in entity: epal_student_epal_chosen
for
(
$i
=
0
;
$i
<
sizeof
(
$applicationForm
[
1
]);
$i
++
)
{
$epalchosen
=
array
(
//'name' => $a
itisi
[1][$i][name],
//'name' => $a
pplicationForm
[1][$i][name],
'student_id'
=>
$created_student_id
,
'epal_id'
=>
$a
itisi
[
1
][
$i
][
epal_id
],
'choice_no'
=>
$a
itisi
[
1
][
$i
][
choice_no
]
//'points_for_order' => $a
itisi
[1][$i][points_for_order],
//'distance_from_epal' => $a
itisi
[1][$i][distance_from_epal],
//'points_for_distance' => $a
itisi
[1][$i][points_for_distance],
'epal_id'
=>
$a
pplicationForm
[
1
][
$i
][
epal_id
],
'choice_no'
=>
$a
pplicationForm
[
1
][
$i
][
choice_no
]
//'points_for_order' => $a
pplicationForm
[1][$i][points_for_order],
//'distance_from_epal' => $a
pplicationForm
[1][$i][distance_from_epal],
//'points_for_distance' => $a
pplicationForm
[1][$i][points_for_distance],
);
$entity_storage_epalchosen
=
$entity
_m
anager
->
getStorage
(
'epal_student_epal_chosen'
);
$entity_storage_epalchosen
=
$
this
->
entity
TypeM
anager
->
getStorage
(
'epal_student_epal_chosen'
);
$entity_object
=
$entity_storage_epalchosen
->
create
(
$epalchosen
);
$entity_storage_epalchosen
->
save
(
$entity_object
);
}
//insert records in entity: epal_student_moria
for
(
$i
=
0
;
$i
<
sizeof
(
$a
itisi
[
2
]);
$i
++
)
{
//insert records in entity: epal_student_moria
for
(
$i
=
0
;
$i
<
sizeof
(
$a
pplicationForm
[
2
]);
$i
++
)
{
$criteria
=
array
(
//'name' => $a
itisi
[2][$i][name],
//'name' => $a
pplicationForm
[2][$i][name],
'student_id'
=>
$created_student_id
,
'income'
=>
$a
itisi
[
2
][
$i
][
income
],
'criterio_id'
=>
$a
itisi
[
2
][
$i
][
criterio_id
],
//'moria' => $a
itisi
[2][$i][moria],
'income'
=>
$a
pplicationForm
[
2
][
$i
][
income
],
'criterio_id'
=>
$a
pplicationForm
[
2
][
$i
][
criterio_id
],
//'moria' => $a
pplicationForm
[2][$i][moria],
);
$entity_storage_criteria
=
$entity
_m
anager
->
getStorage
(
'epal_student_moria'
);
$entity_storage_criteria
=
$
this
->
entity
TypeM
anager
->
getStorage
(
'epal_student_moria'
);
$entity_object
=
$entity_storage_criteria
->
create
(
$criteria
);
$entity_storage_criteria
->
save
(
$entity_object
);
}
//insert records in entity: epal_student_course_field (αφορά μαθητές Γ' Λυκείου)
// or: epal_student_sector_field (αφορά μαθητές Β' Λυκείου)
if
(
$a
itisi
[
0
][
currentclass
]
===
"Γ' Λυκείου"
)
{
//$course = array('name
'=>'record1', 'student_id' => 1, 'coursefield_id' => 4, 'status'=> 1 );
if
(
$a
pplicationForm
[
0
][
currentclass
]
===
"Γ' Λυκείου"
)
{
//$course = array('name
$course
=
array
(
//'name' => $aitisi[3][name],
//'student_id' => $aitis[3][student_i],
'student_id'
=>
$created_student_id
,
'coursefield_id'
=>
$a
itisi
[
3
][
coursefield_id
]
'coursefield_id'
=>
$a
pplicationForm
[
3
][
coursefield_id
]
);
$entity_storage_course
=
$entity
_m
anager
->
getStorage
(
'epal_student_course_field'
);
$entity_storage_course
=
$
this
->
entity
TypeM
anager
->
getStorage
(
'epal_student_course_field'
);
$entity_object
=
$entity_storage_course
->
create
(
$course
);
$entity_storage_course
->
save
(
$entity_object
);
}
else
if
(
$a
itisi
[
0
][
currentclass
]
===
"Β' Λυκείου"
)
{
else
if
(
$a
pplicationForm
[
0
][
currentclass
]
===
"Β' Λυκείου"
)
{
$sector
=
array
(
//'name' => $a
itisi
[3][name],
//'name' => $a
pplicationForm
[3][name],
'student_id'
=>
$created_student_id
,
//'student_id' => $aitis[3][student_i],
'sectorfield_id'
=>
$a
itisi
[
3
][
sectorfield_id
]
'sectorfield_id'
=>
$a
pplicationForm
[
3
][
sectorfield_id
]
);
$entity_storage_sector
=
$entity
_m
anager
->
getStorage
(
'epal_student_sector_field'
);
$entity_storage_sector
=
$
this
->
entity
TypeM
anager
->
getStorage
(
'epal_student_sector_field'
);
$entity_object
=
$entity_storage_sector
->
create
(
$sector
);
$entity_storage_sector
->
save
(
$entity_object
);
}
$returnmsg
=
"Επιτυχής καταχώρηση στοιχείων αίτησης!"
;
$response
=
new
JsonResponse
([
$returnmsg
]);
return
$response
;
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Application saved successfully"
)
],
Response
::
HTTP_OK
);
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
$transaction
->
rollback
();
$returnmsg
=
"Αποτυχία καταχώρησης στοιχείων αίτησης!"
;
$response
=
new
JsonResponse
([
$returnmsg
]);
return
$response
;
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
$res
->
setStatusCode
(
$s
);
return
$res
;
}
}
drupal/modules/epal/src/Controller/CurrentUser.php
View file @
1eea0731
<?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\Request
;
use
Symfony\Component\HttpFoundation\Response
;
class
CurrentUser
extends
ControllerBase
{
protected
$entityTypeManager
;
class
CurrentUser
extends
ControllerBase
{
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
}
public
function
content
()
{
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity_type.manager'
)
);
}
// $name = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$name
=
"LALALA"
;
$authToken
=
"no authToken"
;
$accessKey
=
"no accessKey"
;
public
function
getLoginInfo
(
Request
$request
)
{
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
if
(
\
Drupal
::
request
()
->
headers
->
has
(
'X-AUTH-TOKEN'
))
{
$authToken
=
\
Drupal
::
request
()
->
headers
->
get
(
'X-AUTH-TOKEN'
);
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
if
(
$epalUser
)
{
return
$this
->
respondWithStatus
([
'name'
=>
$epalUser
->
name
->
value
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EPAL user not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
if
(
\
Drupal
::
request
()
->
headers
->
has
(
'X-ACCESS-KEY'
))
{
$accessKey
=
\
Drupal
::
request
()
->
headers
->
get
(
'X-ACCESS-KEY'
);
public
function
getEpalUserData
(
Request
$request
)
{
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
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
;
$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
:
''
,
'userEmail'
=>
mb_substr
(
$user
->
mail
->
value
,
0
,
4
,
'UTF-8'
)
!==
"####"
?
$user
->
mail
->
value
:
''
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"user not found"
),
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EPAL user not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
$response
=
new
JsonResponse
([
$name
]);
$response
->
headers
->
set
(
'X-AUTH-TOKEN'
,
'HELLOTOKEN'
);
return
$response
;
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
$res
->
setStatusCode
(
$s
);
return
$res
;
}
}
drupal/modules/epal/src/Controller/Login.php
deleted
100644 → 0
View file @
4471c4fb
<?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
Drupal\Core\Entity\EntityFieldManagerInterface
;
/**
* Controller routines for page example routes.
*/
class
Login
extends
ControllerBase
{
protected
$query_factory
;
protected
$entityTypeManager
;
protected
$entityFieldManager
;
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
QueryFactory
$query_factory
,
EntityFieldManagerInterface
$entityFieldManager
)
{
// public function __construct(QueryFactory $query_factory) {
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
query_factory
=
$query_factory
;
$this
->
entityFieldManager
=
$entityFieldManager
;
}
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity.query'
),
$container
->
get
(
'entity_field.manager'
)
);
}
public
function
helloWorld
()
{
$name
=
\
Drupal
::
request
()
->
query
->
get
(
'name'
);
$authToken
=
"no authToken"
;
$accessKey
=
"no accessKey"
;
if
(
\
Drupal
::
request
()
->
headers
->
has
(
'X-AUTH-TOKEN'
))
{
$authToken
=
\
Drupal
::
request
()
->
headers
->
get
(
'X-AUTH-TOKEN'
);
}
if
(
\
Drupal
::
request
()
->
headers
->
has
(
'X-ACCESS-KEY'
))
{
$accessKey
=
\
Drupal
::
request
()
->
headers
->
get
(
'X-ACCESS-KEY'
);
}
$response
=
new
JsonResponse
([
'hello'
=>
'world'
,
'name'
=>
$name
,
'authToken'
=>
$authToken
,
'accessKey'
=>
$accessKey
]);
$response
->
headers
->
set
(
'X-AUTH-TOKEN'
,
'HELLOTOKEN'
);
return
$response
;
}
protected
function
simpleQuery
()
{
$query
=
$this
->
query_factory
->
get
(
'student_class'
);
// ->condition('status', 1);
$scids
=
$query
->
execute
();
$studentClass_storage
=
$this
->
entityTypeManager
->
getStorage
(
'student_class'
);
$studentClasses
=
$studentClass_storage
->
loadMultiple
(
$scids
);
$arrayToReturn
=
array
();
foreach
(
$studentClasses
as
$studentClass
)
{
array_push
(
$arrayToReturn
,
array
(
array
(
'data'
=>
$studentClass
->
get
(
'name'
)
->
value
,
'class'
=>
'not-editable'
),
array
(
'data'
=>
"hello"
)