Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Feature/connection tab #52

Open
wants to merge 70 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3d43a64
feat:add connexion tab
May 3, 2018
2dd22a7
add tuupola/slim-basic-auth: PSR-7 and PSR-15 HTTP Basic
May 3, 2018
8345d27
add db migration for user
May 3, 2018
4f1a4e0
add button for connection
May 3, 2018
2645b72
WIP implement register
May 3, 2018
8362e68
Login - Logoff - Register
May 17, 2018
883bd59
Login is mandatory to add reference - State management
May 17, 2018
9302130
define routes and globals
May 17, 2018
74b5253
Profile page
May 17, 2018
dd541b0
Admin view
May 17, 2018
a446a56
Connection form warn - Table td overflow management
May 17, 2018
e81b8e1
New links to login-logoff-register-profile-admin
May 17, 2018
c45a74e
migration file for the features
May 17, 2018
d03354f
Refactor code to update profile
May 22, 2018
8376edb
migration for features
May 22, 2018
ff80d85
factorizing code
May 24, 2018
a0dedf7
added constants for status
May 24, 2018
c990555
empty lines dropped
May 24, 2018
fc3b603
configuration parameters simplifyer
May 24, 2018
7d4e6c1
uncommented recaptcha line
May 24, 2018
f0eb5b7
jquery metgods used - password conditions refactor
May 24, 2018
e766738
factorizing code to load filters and references
May 25, 2018
edb11ce
cs
May 25, 2018
abd9ce0
create navbar on admin page
May 25, 2018
266e1ab
cs + phpdoc
May 25, 2018
9df75c4
method visibility fix
May 25, 2018
97c96da
Route management on adminNavBar
May 28, 2018
64ce95f
admin users's table
May 29, 2018
4be7287
keep datas in database on migration
May 29, 2018
ef71733
delete welcome msg
May 29, 2018
cfd78e6
redesign main navbar with dropdown
May 29, 2018
8003bf3
connection dropdown in navbar
May 31, 2018
dfd2cf3
add title attribute on status img
May 31, 2018
e434dd2
admin form on action, email not mandatory
May 31, 2018
bebee8b
cs
May 31, 2018
8f5820d
Fix undefined index
trasher Jun 1, 2018
a973444
Do not duplicate template and route
trasher Jun 1, 2018
f22fc7e
Do not load login form until required, "better" display
trasher Jun 1, 2018
d3e97a7
Add missing method and action
trasher Jun 1, 2018
cbd8dfe
Fix CSRF and some html issues
trasher Jun 1, 2018
0124e5a
Fix csrf on standlone login page
trasher Jun 1, 2018
cbaeea8
variable name fixed
Jun 1, 2018
cce54c7
reference count on admin tab user's management
Jun 1, 2018
3bc7785
fix merge
Jun 1, 2018
6b8ebad
Other fix merge
Jun 1, 2018
dbe9de5
two differents views: refs and users management
Jun 11, 2018
2d730e9
right encoding
Jun 11, 2018
ad9139d
refactor code to factorize again query requests
Jun 11, 2018
a0b5d85
refactor to adapt it with customs filters
Jun 11, 2018
1046197
refactor to adapt with customs filters to launch query requests
Jun 11, 2018
bcd331f
function to catch username from ref_id
Jun 11, 2018
60e6cfa
convert function
Jun 11, 2018
c6b1106
better request
Jun 11, 2018
bc3d706
references management view improve for mass actions and filters
Jun 11, 2018
d9c7b26
users management view improve for mass actions and filters
Jun 11, 2018
31517be
profile view improve for mass actions and filters
Jun 11, 2018
c241a74
refactor code for filters
Jun 11, 2018
5e0725b
refactor code for filters
Jun 11, 2018
10ec17f
refactor code for filters
Jun 11, 2018
e05f05f
refactor routes
Jun 11, 2018
a913157
refactor mailing action
Jun 11, 2018
bccd5d2
some functions for mass actions
Jun 11, 2018
80e14df
remove this function from this file to globalize it
Jun 11, 2018
b6dcfb4
Filters class and filters table
Jun 11, 2018
4c93ee6
delete die;
Jun 11, 2018
df4fa84
uncomment recaptcha
Jun 11, 2018
155bfef
Fix sur un affichage de debug
Jun 12, 2018
13cdc67
better display for the connection dropdown
Jun 13, 2018
03e7bf9
recaptcha for contact page
Jun 14, 2018
abafe4c
fix massive action string display
AymLaf Jun 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
define routes and globals
Aymeric Lafontaine committed May 17, 2018
commit 9302130b7262da8af05e6f16b30624984b08ac43
110 changes: 110 additions & 0 deletions app/Project.php
Original file line number Diff line number Diff line change
@@ -16,6 +16,13 @@ class Project
private $enable_contact = true;
private $enable_connection = true;
private $enable_register = true;
private $enable_profile = true;
private $enable_admin = true;
private $enable_disconnect_tab;
private $enable_connection_tab;
private $enable_register_tab;
private $enable_profile_tab;
private $enable_admin_tab;
private $footer_links = [
'GLPI project' => [
'faclass' => 'fa fa-globe',
@@ -88,6 +95,27 @@ public function __construct($name, $logger = null)
);
$this->project_path = __DIR__ . '/../projects/' . $this->slug;
$this->templates_path = $this->project_path . '/Templates';

if(isset($_SESSION['user']['username'])) {
$this->enable_disconnect_tab = true;
$this->enable_profile_tab = true;
$this->enable_register_tab = false;
$this->enable_connection_tab = false;
$this->enable_profile = true;
$this->enable_register = false;
if ($_SESSION['user']['is_admin']) {
$this->enable_admin = true;
$this->enable_admin_tab = true;
}
}else{
$this->enable_disconnect_tab = false;
$this->enable_profile_tab = false;
$this->enable_register_tab = true;
$this->enable_connection_tab = true;
$this->enable_profile = false;
$this->enable_admin_tab = false;
$this->enable_admin = false;
}
}

/**
@@ -117,6 +145,18 @@ public function setConfig($config)
$this->enable_register = (bool)$config['enable_register'];
}

if (isset($config['enable_profile'])) {
$this->enable_profile = (bool)$config['enable_profile'];
}

if (isset($config['enable_admin'])) {
$this->enable_admin = (bool)$config['enable_admin'];
}

if (isset($config['enable_disconnect_tab'])) {
$this->enable_disconnect_tab = (bool)$config['enable_disconnect_tab'];
}

if (isset($config['schema'])) {
$this->setSchemaConfig($config['schema']);
}
@@ -492,6 +532,26 @@ public function hasRegisterPage()
return $this->enable_register;
}

/**
* Is profile page active for current project
*
* @return boolean
*/
public function hasProfilePage()
{
return $this->enable_profile;
}

/**
* Is admin page active for current project
*
* @return boolean
*/
public function hasAdminPage()
{
return $this->enable_admin;
}

/**
* Get footer links
*
@@ -524,4 +584,54 @@ public function getDashboardConfig()
}
return $this->dashboard;
}

/**
* Get disconnect tab value
*
* @return array
*/
public function getEnableDisconnectTab()
{
return $this->enable_disconnect_tab;
}

/**
* Get connection tab value
*
* @return array
*/
public function getEnableConnectionTab()
{
return $this->enable_connection_tab;
}

/**
* Get register tab value
*
* @return array
*/
public function getEnableRegisterTab()
{
return $this->enable_register_tab;
}

/**
* Get profile tab value
*
* @return array
*/
public function getEnableProfileTab()
{
return $this->enable_profile_tab;
}

/**
* Get admin tab value
*
* @return array
*/
public function getEnableAdminTab()
{
return $this->enable_admin_tab;
}
}
22 changes: 20 additions & 2 deletions app/init.php
Original file line number Diff line number Diff line change
@@ -114,14 +114,33 @@
$env->addGlobal('enable_connection', $c->project->hasConnectionPage());

//enable register page
$env->addGlobal('enable_connection', $c->project->hasRegisterPage());
$env->addGlobal('enable_register', $c->project->hasRegisterPage());

//enable admin tab
$env->addGlobal('enable_admin_tab', $c->project->getEnableAdminTab());

//enable admin page
$env->addGlobal('enable_admin', $c->project->hasAdminPage());

//enable disconnect tab
$env->addGlobal('enable_disconnect_tab', $c->project->getEnableDisconnectTab());

//enable connection tab
$env->addGlobal('enable_connection_tab', $c->project->getEnableConnectionTab());

//enable register tab
$env->addGlobal('enable_register_tab', $c->project->getEnableRegisterTab());

//enable profile tab
$env->addGlobal('enable_profile_tab', $c->project->getEnableProfileTab());

//footer links
$env->addGlobal('footer_links', $c->project->getFooterLinks());

return $view;
};


//setup recaptcha
$container[Captcha::class] = function ($c) {
return new Captcha($c[ReCaptcha::class]);
@@ -131,7 +150,6 @@
};
$recaptcha = $app->getContainer()->get(Captcha::class);


// system error handling
$container['errorHandler'] = function ($c) {
//CUSTOM Error Handler
94 changes: 93 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
@@ -25,6 +25,10 @@
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('connection');
$app->get('/disconnect', 'GLPI\Telemetry\Controllers\Connection:disconnect')
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('disconnect');
$app->post('/connection', 'GLPI\Telemetry\Controllers\Connection:send')
->add($container['csrf'])
->setName('sendConnection');
@@ -41,6 +45,83 @@
->setName('sendRegister');
}

if ($container->project->hasProfilePage()) {
// profile
$app->get('/profile[/status/{status}[/page/{page:\d+}]]', 'GLPI\Telemetry\Controllers\Profile:view')
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('profile');

//Profile update reference
$app->map(
['get', 'post'],
'/profile/update',
'GLPI\Telemetry\Controllers\Reference:update'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('actionProfileReferenceUpdate');

//Profile delete reference
$app->map(
['get', 'post'],
'/profile/delete',
'GLPI\Telemetry\Controllers\Reference:delete'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('actionProfileReferenceDelete');

//Profile sorting
$app->map(
['get', 'post'],
'/profile/view[/{status}]',
'GLPI\Telemetry\Controllers\Profile:view'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('sorterProfile');
}

if ($container->project->hasAdminPage()) {
// admin
$app->get('/admin[/status/{status}[/page/{page:\d+}]]', 'GLPI\Telemetry\Controllers\Admin:view')
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('admin');

//Admin denied
$app->map(
['get', 'post'],
'/admin/ActionReferencePost',
'GLPI\Telemetry\Controllers\Admin:ActionReferencePost'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('actionAdminReferencesWithMsg');

//Admin sorting
$app->map(
['get', 'post'],
'/admin/view[/{status}]',
'GLPI\Telemetry\Controllers\Admin:view'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('sorterAdmin');

//Admin References filtering
$app->map(
['get', 'post'],
'/admin/filter[/order/{orderby}]',
'GLPI\Telemetry\Controllers\Admin:filter'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('filterAdminReferences');
}


/** References */
//References list
$app->get('/reference[/page/{page:\d+}]', 'GLPI\Telemetry\Controllers\Reference:view')
@@ -58,9 +139,20 @@
->add($container['csrf'])
->setName('filterReferences');

//Profile References filtering
$app->map(
['get', 'post'],
'/profile/filter[/order/{orderby}]',
'GLPI\Telemetry\Controllers\Profile:filter'
)
->add(new GLPI\Telemetry\Middleware\CsrfView($container))
->add($container['csrf'])
->setName('filterProfileReferences');


//Reference registration
$app->post('/reference', 'GLPI\Telemetry\Controllers\Reference:register')
->add($recaptcha)
//->add($recaptcha)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be commented

->add($container['csrf'])
->setName('registerReference');
/** /References */