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
gredu_labs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
1fe5273a
Commit
1fe5273a
authored
Dec 19, 2016
by
Σταύρος Παπαδάκης
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'volunteer-forms' into 'master'
Volunteer forms See merge request
!29
parents
7f10e8cc
b7d1935e
Changes
32
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
2259 additions
and
980 deletions
+2259
-980
config/app.config.php
config/app.config.php
+2
-1
config/settings/acl.global.php
config/settings/acl.global.php
+3
-1
config/settings/enable_db_login.global.php
config/settings/enable_db_login.global.php
+27
-0
config/settings/nav.global.php
config/settings/nav.global.php
+6
-0
module/admin/README.md
module/admin/README.md
+20
-0
module/admin/bootstrap.php
module/admin/bootstrap.php
+36
-0
module/admin/src/Action/Index.php
module/admin/src/Action/Index.php
+38
-0
module/admin/templates/admin/index.twig
module/admin/templates/admin/index.twig
+40
-0
module/application/templates/navigation/main.twig
module/application/templates/navigation/main.twig
+17
-7
module/csv_export/bootstrap.php
module/csv_export/bootstrap.php
+310
-168
module/enable_db_login/README.md
module/enable_db_login/README.md
+51
-0
module/enable_db_login/bootstrap.php
module/enable_db_login/bootstrap.php
+53
-0
module/enable_db_login/src/Action/Index.php
module/enable_db_login/src/Action/Index.php
+35
-0
module/enable_db_login/src/Middleware/EnableDBLogin.php
module/enable_db_login/src/Middleware/EnableDBLogin.php
+56
-0
module/teacher_form/bootstrap.php
module/teacher_form/bootstrap.php
+22
-15
module/teacher_form/data/migration-161219-01-up.mysql.sql
module/teacher_form/data/migration-161219-01-up.mysql.sql
+2
-0
module/teacher_form/public/js/teacher_form/index-1.1.js
module/teacher_form/public/js/teacher_form/index-1.1.js
+30
-30
module/teacher_form/src/Action/Display.php
module/teacher_form/src/Action/Display.php
+43
-0
module/teacher_form/src/Service/TeacherFormService.php
module/teacher_form/src/Service/TeacherFormService.php
+46
-11
module/teacher_form/src/Service/TeacherFormServiceInterface.php
.../teacher_form/src/Service/TeacherFormServiceInterface.php
+7
-1
module/teacher_form/templates/teacher_form/display.twig
module/teacher_form/templates/teacher_form/display.twig
+48
-0
module/teacher_form/templates/teacher_form/form.twig
module/teacher_form/templates/teacher_form/form.twig
+56
-77
module/university_form/bootstrap.php
module/university_form/bootstrap.php
+23
-24
module/university_form/public/js/university_form/index-1.1.js
...le/university_form/public/js/university_form/index-1.1.js
+479
-0
module/university_form/src/Action/Display.php
module/university_form/src/Action/Display.php
+43
-0
module/university_form/src/Service/UniversityFormService.php
module/university_form/src/Service/UniversityFormService.php
+82
-18
module/university_form/src/Service/UniversityFormServiceInterface.php
...rsity_form/src/Service/UniversityFormServiceInterface.php
+5
-0
module/university_form/templates/university_form/display.twig
...le/university_form/templates/university_form/display.twig
+52
-0
module/university_form/templates/university_form/form.twig
module/university_form/templates/university_form/form.twig
+75
-85
public/js/teacher_form/index-1.1.js
public/js/teacher_form/index-1.1.js
+73
-0
public/js/university_form/index-1.1.js
public/js/university_form/index-1.1.js
+479
-0
public/js/university_form/index.js
public/js/university_form/index.js
+0
-542
No files found.
config/app.config.php
View file @
1fe5273a
...
...
@@ -28,7 +28,8 @@ return [
'module/open_data/bootstrap.php'
,
'module/university_form/bootstrap.php'
,
'module/teacher_form/bootstrap.php'
,
'module/enable_db_login/bootstrap.php'
,
'module/admin/bootstrap.php'
,
],
'cache_config'
=>
'data/cache/config/settings.php'
,
];
config/settings/acl.global.php
View file @
1fe5273a
...
...
@@ -47,7 +47,9 @@ return [
[
'/teacher-form'
,
[
'guest'
],
[
'get'
,
'post'
]],
[
'/teacher-form/submit-success'
,[
'guest'
],
[
'get'
,
'post'
]],
[
'/teacher-form/mm'
,[
'guest'
],
[
'get'
]],
[
'/admin'
,
[
'admin'
],
[
'get'
]],
[
'/admin/university-form/display'
,
[
'admin'
],
[
'get'
]],
[
'/admin/teacher-form/display'
,
[
'admin'
],
[
'get'
]],
],
],
],
...
...
config/settings/enable_db_login.global.php
0 → 100644
View file @
1fe5273a
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
[
'enabledblogin'
=>
[
'enable_routes'
=>
[
'enabledblogin'
],
'enable_patterns'
=>
[
'/enabledblogin'
],
'disable_routes'
=>
[
'disabledblogin'
,
'user.logout'
],
'disable_patterns'
=>
[
'/disabledblogin'
,
'/user/logout'
],
],
];
config/settings/nav.global.php
View file @
1fe5273a
...
...
@@ -79,5 +79,11 @@ return [
],
],
'admin'
=>
[
'adminhome'
=>
[
'label'
=>
'Σελίδα διαχειριστή'
,
'route'
=>
'admin'
,
],
]
],
];
module/admin/README.md
0 → 100644
View file @
1fe5273a
# Υποσύστημα διαχειριστή
Παρέχει πρόσβαση σε διαχειριστικές λειτουργίες. Εφόσον ο χρήστης πιστοποιείται
με ρόλο admin εμφανίζεται το μενού διαχειριστικών λειτουργιών.
## Routes
Διαθέσιμα routes (paths) και λειτουργίες.
-
admin (/admin): αρχική σελίδα διαχειριστή
## Οδηγίες
Για να είναι προσβάσιμο, πρέπει:
-
να προσθέσετε την παρακάτω γραμμή στο
`acl.global.php`
ή
`acl.local.php`
,
στο acl.guards.routes
```
['/admin', ['admin'], ['get']],
```
module/admin/bootstrap.php
0 → 100644
View file @
1fe5273a
<?php
use
Slim\App
;
use
Slim\Container
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
function
(
App
$app
)
{
$container
=
$app
->
getContainer
();
$events
=
$container
[
'events'
];
$events
(
'on'
,
'app.autoload'
,
function
(
$autoloader
)
{
$autoloader
->
addPsr4
(
'GrEduLabs\\Admin\\'
,
__DIR__
.
'/src/'
);
});
$events
(
'on'
,
'app.services'
,
function
(
Container
$container
)
{
$container
[
GrEduLabs\Admin\Action\Index
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Admin\Action\Index
(
$c
[
'view'
]);
};
});
$events
(
'on'
,
'app.bootstrap'
,
function
(
App
$app
,
Container
$c
)
{
$view
=
$c
->
get
(
'view'
);
$view
->
getEnvironment
()
->
getLoader
()
->
prependPath
(
__DIR__
.
'/templates'
);
$app
->
get
(
'/admin'
,
GrEduLabs\Admin\Action\Index
::
class
)
->
setName
(
'admin'
);
});
};
module/admin/src/Action/Index.php
0 → 100644
View file @
1fe5273a
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Admin\Action
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
use
Slim\Views\Twig
;
class
Index
{
/**
* @var Twig
*/
protected
$view
;
/**
* Constructor.
*
* @param Twig $view
*/
public
function
__construct
(
Twig
$view
)
{
$this
->
view
=
$view
;
}
public
function
__invoke
(
Request
$req
,
Response
$res
)
{
return
$this
->
view
->
render
(
$res
,
'admin/index.twig'
);
}
}
module/admin/templates/admin/index.twig
0 → 100644
View file @
1fe5273a
{%
extends
"layout.twig"
%}
{%
block
content
%}
<div
id=
"adminarea"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4>
Σελίδα διαχειριστή
</h4>
</div>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Διαθέσιμες διαχειριστικές λειτουργίες
</th>
<th>
</th>
<tr>
</thead>
<tbody>
<tr>
<td>
Καταχωρημένες αιτήσεις εθελοντών - Εκπαιδευτικοί
</td>
<td
class=
"text-right"
>
<a
class=
"btn btn-primary btn-sm"
href=
"
{{
path_for
(
'export.csv'
,
{
type
:
'volunteer_teachers'
}
)
}}
"
><i
class=
"fa fa-download"
></i>
Αρχείο .csv
</a>
<a
class=
"btn btn-default btn-sm"
href=
"
{{
path_for
(
'admin.volunteer.teacher'
)
}}
"
><span
class=
"fa fa-list"
></span>
Προβολή
</a>
</td>
</tr>
<tr>
<td>
Καταχωρημένες αιτήσεις εθελοντών - Ιδρύματα
</td>
<td
class=
"text-right"
>
<a
class=
"btn btn-primary btn-sm"
href=
"
{{
path_for
(
'export.csv'
,
{
type
:
'volunteer_institutions'
}
)
}}
"
><span
class=
"fa fa-download"
></span>
Αρχείο .csv
</a>
<a
class=
"btn btn-default btn-sm"
href=
"
{{
path_for
(
'admin.volunteer.univ'
)
}}
"
><span
class=
"fa fa-list"
></span>
Προβολή
</a>
</td>
</tr>
</tbody>
</table>
<div
class=
"panel-footer text-center"
>
<a
class=
"btn btn-sm btn-default"
href=
"
{{
path_for
(
'index'
)
}}
"
><span
class=
"fa fa-home"
></span>
Αρχική
</a>
<a
class=
"btn btn-sm btn-primary"
href=
"
{{
path_for
(
'admin'
)
}}
"
><span
class=
"fa fa-user-secret"
></span>
Διαχειριστής
</a>
<a
class=
"btn btn-sm btn-default"
href=
"
{{
path_for
(
'user.logout'
)
}}
"
><span
class=
"fa fa-lock"
></span>
Αποσύνδεση
</a>
</div>
</div>
</div>
{%
endblock
%}
module/application/templates/navigation/main.twig
View file @
1fe5273a
...
...
@@ -27,6 +27,16 @@
{%
for
page
in
nav
(
'main'
)
%}
{{
macros.li
(
page
)
}}
{%
endfor
%}
{%
if
not
nav
(
'admin'
)
is
empty
%}
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-haspopup=
"true"
aria-expanded=
"false"
><span
class=
"fa fa-user-secret"
></span>
Διαχειριστής
<span
class=
"caret"
></span></a>
<ul
class=
"dropdown-menu"
>
{%
for
page
in
nav
(
'admin'
)
%}
{{
macros.li
(
page
)
}}
{%
endfor
%}
</ul>
</li>
{%
endif
%}
</ul>
<ul
class=
"nav navbar-nav navbar-right"
>
{%
for
page
in
nav
(
'authentication'
)
%}
...
...
module/csv_export/bootstrap.php
View file @
1fe5273a
...
...
@@ -7,6 +7,7 @@ use Slim\App;
use
Slim\Container
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
use
GrEduLabs\UniversityForm\Service\UniversityFormService
;
/**
* gredu_labs.
...
...
@@ -22,6 +23,13 @@ return function (App $app) {
$events
(
'on'
,
'app.services'
,
function
(
Container
$c
)
{
$c
[
'csv_export_protected_exports'
]
=
function
(
$c
)
{
return
[
'volunteer_teachers'
,
'volunteer_institutions'
,
];
};
$c
[
'csv_export_config'
]
=
function
(
$c
)
{
return
[
...
...
@@ -95,7 +103,6 @@ return function (App $app) {
'Σχόλια - Παρατηρήσεις'
,
],
],
'appnewforms'
=>
[
'data_callback'
=>
'csv_export_appnewforms'
,
'headers'
=>
[
...
...
@@ -107,8 +114,6 @@ return function (App $app) {
'Σχόλια - Παρατηρήσεις'
,
],
],
'appforms_items'
=>
[
'data_callback'
=>
'csv_export_appforms_items'
,
'headers'
=>
[
...
...
@@ -142,6 +147,63 @@ return function (App $app) {
'Αιτιολογία χρήσης'
,
],
],
'volunteer_teachers'
=>
[
'data_callback'
=>
'csv_export_volunteer_teachers'
,
'headers'
=>
[
'ID'
,
'Όνομα'
,
'Επώνυμο'
,
'Ειδικότητα'
,
'Ειδικότητα (λεκτικό)'
,
'Αριθμός Μητρώου'
,
'Τηλέφωνο'
,
'Email'
,
'Σχολείο που υπηρετεί'
,
'Τηλέφωνο Σχολείου'
,
'Σχόλια/Παρατηρήσεις'
,
'Σχετική δράση που συμμετείχε'
,
'URL δράσης που συμμετείχε'
,
'Περιγραφή δράσης που συμμετείχε'
,
'Έργο 1'
,
'Έργο 2'
,
'Έργο 3'
,
'Έργο 4'
,
'Έργο 5'
,
'Έργο 6'
,
'Έργο 7'
,
'Έργο 8'
,
'Έργο 9'
,
'Έργο 10'
,
],
],
'volunteer_institutions'
=>
[
'data_callback'
=>
'csv_export_volunteer_institutions'
,
'headers'
=>
[
'ID'
,
'Ίδρυμα'
,
'Σχολή'
,
'Τμήμα'
,
'Ερευνητικό Κέντρο'
,
'Ινστιτούτο'
,
'Άλλο'
,
'Υπεύθυνος Επικοινωνίας'
,
'Τηλέφωνο'
,
'Email'
,
'Σχόλια/Παρατηρήσεις'
,
'Έργα'
,
'Περιγραφή (ακολουθούν ανά στήλη)'
,
'Έργο 1'
,
'Έργο 2'
,
'Έργο 3'
,
'Έργο 4'
,
'Έργο 5'
,
'Έργο 6'
,
'Έργο 7'
,
'Έργο 8'
,
'Έργο 9'
,
'Έργο 10'
,
],
],
];
};
...
...
@@ -179,6 +241,78 @@ return function (App $app) {
};
};
$c
[
'csv_export_volunteer_teachers'
]
=
function
(
$c
)
{
return
function
()
{
$sql
=
'SELECT `volunteerteachers`.`id`, '
.
'`volunteerteachers`.`name`, '
.
'`volunteerteachers`.`surname`, '
.
'`volunteerteachers`.`eidikothta`, '
.
'`branch`.`name` AS `eidikothta_name`, '
.
'`volunteerteachers`.`arithmitroou`, '
.
'`volunteerteachers`.`telef`, '
.
'`volunteerteachers`.`email`, '
.
'`volunteerteachers`.`school`, '
.
'`volunteerteachers`.`schooltelef`, '
.
'`volunteerteachers`.`comments`, '
.
'`volunteerteachers`.`projecttitle`, '
.
'`volunteerteachers`.`projecturl`, '
.
'`volunteerteachers`.`projectdescription` '
.
' FROM `volunteerteachers` JOIN `branch` ON (`volunteerteachers`.`eidikothta` = `branch`.`id`) '
// . ' FROM `volunteerteachers` '
.
' ORDER BY id '
;
$volunteer_teachers
=
R
::
getAll
(
$sql
);
$volunteer_teachers
=
array_map
(
function
(
$row
)
{
$row
[
'projectdescription'
]
=
UniversityFormService
::
recomposeProjects
(
$row
[
'projectdescription'
],
false
);
if
((
$projects
=
preg_split
(
'/'
.
UniversityFormService
::
PLAIN_TEXT_SEPARATOR
.
'/msUu'
,
$row
[
'projectdescription'
]))
!==
false
)
{
foreach
(
$projects
as
$i
=>
$proj
)
{
$row
[
"project
{
$i
}
"
]
=
$proj
;
}
}
return
$row
;
},
$volunteer_teachers
);
return
$volunteer_teachers
;
};
};
$c
[
'csv_export_volunteer_institutions'
]
=
function
(
$c
)
{
return
function
()
{
$sql
=
'SELECT `id`, '
.
'`idrima`, '
.
'`sxolh`, '
.
'`tmhma`, '
.
'`ereunitiko`, '
.
'`institute`, '
.
'`other`,'
.
'`person`, '
.
'`telef`, '
.
'`email`, '
.
'`comments`, '
.
'`erga`, '
.
'`projectdescription` '
.
' FROM `univ` '
.
' ORDER BY id'
;
$volunteer_institutions
=
R
::
getAll
(
$sql
);
$volunteer_institutions
=
array_map
(
function
(
$row
)
{
$row
[
'projectdescription'
]
=
UniversityFormService
::
recomposeProjects
(
$row
[
'projectdescription'
],
false
);
if
((
$projects
=
preg_split
(
'/'
.
UniversityFormService
::
PLAIN_TEXT_SEPARATOR
.
'/msUu'
,
$row
[
'projectdescription'
]))
!==
false
)
{
foreach
(
$projects
as
$i
=>
$proj
)
{
$row
[
"project
{
$i
}
"
]
=
$proj
;
}
}
return
$row
;
},
$volunteer_institutions
);
return
$volunteer_institutions
;
};
};
$c
[
'csv_export_schools'
]
=
function
(
$c
)
{
return
function
()
{
...
...
@@ -347,7 +481,6 @@ return function (App $app) {
$appForms
=
R
::
getAll
(
$sql
,
$appFormIds
);
return
$appForms
;
};
};
...
...
@@ -392,7 +525,7 @@ return function (App $app) {
$c
[
'csv_export_appforms_items'
]
=
function
(
$c
)
{
return
function
()
use
(
$c
){
return
function
()
use
(
$c
)
{
$settings
=
$c
->
get
(
'settings'
);
$version
=
$settings
[
'application_form'
][
'itemcategory'
][
'currentversion'
];
...
...
@@ -487,13 +620,22 @@ return function (App $app) {
return
$appForms
;
};
};
});
$events
(
'on'
,
'app.bootstrap'
,
function
(
App
$app
,
Container
$c
)
{
$app
->
get
(
'/export/csv/edulabs_{type}.csv'
,
function
(
Request
$req
,
Response
$res
,
array
$args
)
use
(
$c
)
{
$type
=
$args
[
'type'
];
$role
=
call_user_func
(
$c
[
'current_role'
]);
if
(
in_array
(
$type
,
$c
[
'csv_export_protected_exports'
]))
{
if
(
$role
!==
'admin'
)
{
$res
=
$res
->
withStatus
(
403
);
$res
->
getBody
()
->
write
(
'Forbidden. The information requested in not available.'
);
return
$res
;
}
}
try
{
$config
=
$c
[
'csv_export_config'
];
...
...
module/enable_db_login/README.md
0 → 100644
View file @
1fe5273a
# Ενεργοποίηση σύνδεσης μέσω βάσης δεδομένων
Το συγκεκριμένο module ενεργοποιεί τη φόρμα σύνδεσης μέσω βάση δεδομένων
άσχετα από τη ρύθμιση Container
[
'settings'
][
'sso'
]
['enable_database_login'].
Χρειάζεται να ενεργοποιηθεί μόνο στην περίπτωση που έχει ενεργοποιηθεί το
module sch_sso και απαιτείται σύνδεση τοπικού χρήστη για συγκεκριμένες
λειτουργίες.
## Ρυθμίσεις
Το αρχείο
`enable_db_login.{global,local}.php χρησιμοποιείται για την
παραμετροποίηση. Οι προεπιλεγμένες ρυθμίσεις είναι οι παρακάτω.
```
'enabledblogin' => [
'enable_routes' => [
'enabledblogin'
],
'enable_patterns' => [
'/enabledblogin'
],
'disable_routes' => [
'disabledblogin',
'user.logout'
],
'disable_patterns' => [
'/disabledblogin',
'/user/logout'
],
],
```
Οι ρυθμίσεις έχουν ως εξής:
- enable_routes: ονόματα routes που ενεργοποιούν τη σύνδεση μέσω ΒΔ
- enable_patterns: url paths που ενεργοποιούν τη σύνδεση μέσω ΒΔ
- disable_routes: ονόματα routes που απενεργοποιούν τη σύνδεση μέσω ΒΔ
- disable_patterns: url paths που απενεργοποιούν τη σύνδεση μέσω ΒΔ
_Προτεραιότητα έχει η απενεργοποίηση._
##Routes
Το module δηλώνει δύο routes (στα αντίστοιχα paths) ώστε να παρέχεται ένα
παράδειγμα χρήσης.
- enabledblogin (/enabledblogin) που ενεργοποιεί τη σύνδεση μέσω ΒΔ
- disabledblogin (/disabledblogin) που απενεργοποιεί τη σύνδεση μέσω ΒΔ
*Δεν* είναι απαραίτητο να προστεθούν τα routes στο `
acl.{global,local}.php
`
(acl.guards.routes).
module/enable_db_login/bootstrap.php
0 → 100644
View file @
1fe5273a
<?php
use
Slim\App
;
use
Slim\Container
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
function
(
App
$app
)
{
$container
=
$app
->
getContainer
();
$events
=
$container
[
'events'
];
$events
(
'on'
,
'app.autoload'
,
function
(
$autoloader
)
{
$autoloader
->
addPsr4
(
'GrEduLabs\\EnableDBLogin\\'
,
__DIR__
.
'/src/'
);
});
$events
(
'on'
,
'app.services'
,
function
(
Container
$container
)
{
$container
[
GrEduLabs\EnableDBLogin\Middleware\EnableDBLogin
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\EnableDBLogin\Middleware\EnableDBLogin
(
$c
);
};
$container
[
GrEduLabs\EnableDBLogin\Action\Index
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\EnableDBLogin\Action\Index
(
$c
);
};
});
$events
(
'on'
,
'app.bootstrap'
,
function
(
App
$app
,
Container
$c
)
{
$app
->
add
(
GrEduLabs\EnableDBLogin\Middleware\EnableDBLogin
::
class
);
});
$events
(
'on'
,
'app.bootstrap'
,
function
(
App
$app
,
Container
$c
)
{
if
(
isset
(
$_SESSION
[
'enableDLogin'
]))
{
$c
[
'router'
]
->
getNamedRoute
(
'user.login'
)
->
add
(
function
(
Request
$req
,
Response
$res
,
callable
$next
)
use
(
$c
)
{
$c
[
'view'
][
'enable_database_login'
]
=
true
;
return
$next
(
$req
,
$res
);
});
}
},
-
98
);
// must be in order to set last
$events
(
'on'
,
'app.bootstrap'
,
function
(
App
$app
,
Container
$c
)
{
$app
->
get
(
'/enabledblogin'
,
GrEduLabs\EnableDBLogin\Action\Index
::
class
)
->
setName
(
'enabledblogin'
);
$app
->
get
(
'/disabledblogin'
,
GrEduLabs\EnableDBLogin\Action\Index
::
class
)
->
setName
(
'disabledblogin'
);
});
};
module/enable_db_login/src/Action/Index.php
0 → 100644
View file @
1fe5273a
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\EnableDBLogin\Action
;
use
Slim\Container
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
class
Index
{
protected
$_c
;
/**
* Constructor.
*
* @param Twig $view
*/
public
function
__construct
(
Container
$c
)
{
$this
->
_c
=
$c
;
}
public
function
__invoke
(
Request
$req
,
Response
$res
)
{
return
$res
->
withRedirect
(
$this
->
_c
[
'router'
]
->
pathFor
(
'index'
));
}
}
module/enable_db_login/src/Middleware/EnableDBLogin.php
0 → 100644
View file @
1fe5273a
<?php
/**
* EnableDBLogin enables the database login form for specific routes or urls.
* To use set the enable_db_login.{global,local}.php
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\EnableDBLogin\Middleware
;
use
Slim\Container
;
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
class
EnableDBLogin
{
private
$_c
;
public
function
__construct
(
Container
$c
)
{
$this
->
_c
=
$c
;
}
public
function
__invoke
(
ServerRequestInterface
$req
,
ResponseInterface
$res
,
callable
$next
)
{
$route
=
$req
->
getAttribute
(
'route'
);
if
(
$route
)
{
$routeName
=
$route
->
getName
();
$routePattern
=
$route
->
getPattern
();
$dblogin_settings
=
$this
->
_c
->
get
(
'settings'
)
->
get
(
'enabledblogin'
);
if
(
$dblogin_settings
)
{
$enableRouteNames
=
isset
(
$dblogin_settings
[
'enable_routes'
])
?
$dblogin_settings
[
'enable_routes'
]
:
[];
$enableRoutePatterns
=
isset
(
$dblogin_settings
[
'enable_patterns'
])
?
$dblogin_settings
[
'enable_patterns'
]
:
[];
$disableRouteNames
=
isset
(
$dblogin_settings
[
'disable_routes'
])
?
$dblogin_settings
[
'disable_routes'
]
:
[];
$disableRoutePatterns
=
isset
(
$dblogin_settings
[
'disable_patterns'
])
?
$dblogin_settings
[
'disable_patterns'
]
:
[];
if
(
in_array
(
$routeName
,
$enableRouteNames
)
||
in_array
(
$routePattern
,
$enableRoutePatterns
))
{
$_SESSION
[
'enableDLogin'
]
=
true
;
$this
->
_c
[
'logger'
]
->
info
(
"SET enableDLogin via route=["
.
var_export
(
$routeName
,
true
)
.
'], path=['
.
var_export
(
$routePattern
,
true
)
.
']'
);
}
if
(
in_array
(
$routeName
,
$disableRouteNames
)
||
in_array
(
$routePattern
,
$disableRoutePatterns
))
{
unset
(
$_SESSION
[
'enableDLogin'
]);