Browse Source

updated Views and Controller

- merged Templates (Header & Footer into Base, HeaderBlank & FooterBlank into Blank and HeaderAdmin & FooterAdmin into Admin)
- updated to match with new layout functions
- enhanced Users/Groups new & edit with allow & deny perm
- updated PHPdocs overall files
v3-dev
REJack 6 years ago
parent
commit
62ca1957fa
  1. 10
      app/Controllers/Account/Edit.php
  2. 6
      app/Controllers/Account/Home.php
  3. 9
      app/Controllers/Account/Login.php
  4. 12
      app/Controllers/Account/Register.php
  5. 2
      app/Controllers/Account/Remind_password.php
  6. 2
      app/Controllers/Account/Reset_password.php
  7. 2
      app/Controllers/Account/Verification.php
  8. 97
      app/Controllers/Admin/Groups.php
  9. 10
      app/Controllers/Admin/Home.php
  10. 10
      app/Controllers/Admin/Migrate.php
  11. 58
      app/Controllers/Admin/Perms.php
  12. 76
      app/Controllers/Admin/Users.php
  13. 3
      app/Controllers/Home.php
  14. 12
      app/Views/Account/Edit.php
  15. 31
      app/Views/Account/Home.php
  16. 14
      app/Views/Account/Login.php
  17. 17
      app/Views/Account/Register.php
  18. 12
      app/Views/Account/RemindPassword.php
  19. 12
      app/Views/Account/ResetPassword.php
  20. 12
      app/Views/Account/Verification.php
  21. 8
      app/Views/Admin/Groups/Delete.php
  22. 36
      app/Views/Admin/Groups/Edit.php
  23. 6
      app/Views/Admin/Groups/Home.php
  24. 39
      app/Views/Admin/Groups/New.php
  25. 8
      app/Views/Admin/Groups/Show.php
  26. 4
      app/Views/Admin/Home.php
  27. 4
      app/Views/Admin/Migrate.php
  28. 4
      app/Views/Admin/Perms/Delete.php
  29. 4
      app/Views/Admin/Perms/Edit.php
  30. 6
      app/Views/Admin/Perms/Home.php
  31. 4
      app/Views/Admin/Perms/New.php
  32. 4
      app/Views/Admin/Perms/Show.php
  33. 8
      app/Views/Admin/Users/Delete.php
  34. 32
      app/Views/Admin/Users/Edit.php
  35. 6
      app/Views/Admin/Users/Home.php
  36. 31
      app/Views/Admin/Users/New.php
  37. 8
      app/Views/Admin/Users/Show.php
  38. 10
      app/Views/Home.php
  39. 37
      app/Views/Templates/Admin.php
  40. 36
      app/Views/Templates/Base.php
  41. 32
      app/Views/Templates/Blank.php
  42. 18
      app/Views/Templates/Footer.php
  43. 27
      app/Views/Templates/FooterAdmin.php
  44. 12
      app/Views/Templates/FooterBlank.php
  45. 19
      app/Views/Templates/HeaderBlank.php

10
app/Controllers/Account/Edit.php

@ -34,11 +34,17 @@ class Edit extends Controller
*/ */
public function __construct() public function __construct()
{ {
helper('aauth');
if (! is_loggedin())
{
return service('response')->redirect('/');
}
$this->config = new AauthConfig(); $this->config = new AauthConfig();
$this->aauth = new Aauth(); $this->aauth = new Aauth();
$this->request = Services::request(); $this->request = Services::request();
helper('form'); helper('form');
helper('aauth');
} }
/** /**
@ -81,8 +87,6 @@ class Edit extends Controller
$data['useUsername'] = $this->config->loginUseUsername; $data['useUsername'] = $this->config->loginUseUsername;
echo view('Templates/Header', $data);
echo view('Account/Edit', $data); echo view('Account/Edit', $data);
echo view('Templates/Footer', $data);
} }
} }

6
app/Controllers/Account/Home.php

@ -19,6 +19,7 @@ namespace App\Controllers\Account;
use CodeIgniter\Controller; use CodeIgniter\Controller;
use App\Libraries\Aauth; use App\Libraries\Aauth;
use Config\Aauth as AauthConfig;
use App\Models\Aauth\UserModel; use App\Models\Aauth\UserModel;
/** /**
@ -34,11 +35,12 @@ class Home extends Controller
public function __construct() public function __construct()
{ {
$this->aauth = new Aauth(); $this->aauth = new Aauth();
$this->config = new AauthConfig();
helper('aauth'); helper('aauth');
if (! $this->aauth->isLoggedIn()) if (! $this->aauth->isLoggedIn())
{ {
redirect()->to('/'); return service('response')->redirect('/');
} }
} }
@ -51,8 +53,6 @@ class Home extends Controller
{ {
$data['user'] = $this->aauth->getUser(); $data['user'] = $this->aauth->getUser();
echo view('Templates/Header');
echo view('Account/Home', $data); echo view('Account/Home', $data);
echo view('Templates/Footer');
} }
} }

9
app/Controllers/Account/Login.php

@ -57,17 +57,20 @@ class Login extends Controller
} }
else else
{ {
$this->response->redirect('/account'); $this->response->redirect(site_url('/account'));
} }
} }
if (session('errors'))
{
$data['errors'] = isset($data['errors']) ? $data['errors'] . '<br />' . session('errors') : session('errors');
}
$data['useUsername'] = $this->config->loginUseUsername; $data['useUsername'] = $this->config->loginUseUsername;
$data['cssFiles'] = [ $data['cssFiles'] = [
'/assets/css/login.css' '/assets/css/login.css'
]; ];
echo view('Templates/HeaderBlank', $data);
echo view('Account/Login', $data); echo view('Account/Login', $data);
echo view('Templates/FooterBlank', $data);
} }
} }

12
app/Controllers/Account/Register.php

@ -59,13 +59,21 @@ class Register extends Controller
} }
} }
if (session('errors'))
{
$data['errors'] = isset($data['errors']) ? $data['errors'] . '<br />' . session('errors') : session('errors');
}
if (session('infos'))
{
$data['infos'] = isset($data['infos']) ? $data['infos'] . '<br />' . session('infos') : session('infos');
}
$data['useUsername'] = $this->config->loginUseUsername; $data['useUsername'] = $this->config->loginUseUsername;
$data['cssFiles'] = [ $data['cssFiles'] = [
'/assets/css/login.css' '/assets/css/login.css'
]; ];
echo view('Templates/HeaderBlank', $data);
echo view('Account/Register', $data); echo view('Account/Register', $data);
echo view('Templates/FooterBlank', $data);
} }
} }

2
app/Controllers/Account/Remind_password.php

@ -61,8 +61,6 @@ class Remind_password extends Controller
'/assets/css/login.css' '/assets/css/login.css'
]; ];
echo view('Templates/HeaderBlank', $data);
echo view('Account/RemindPassword', $data); echo view('Account/RemindPassword', $data);
echo view('Templates/FooterBlank', $data);
} }
} }

2
app/Controllers/Account/Reset_password.php

@ -64,8 +64,6 @@ class Reset_password extends Controller
'/assets/css/login.css' '/assets/css/login.css'
]; ];
echo view('Templates/HeaderBlank', $data);
echo view('Account/ResetPassword', $data); echo view('Account/ResetPassword', $data);
echo view('Templates/FooterBlank', $data);
} }
} }

2
app/Controllers/Account/Verification.php

@ -64,8 +64,6 @@ class Verification extends Controller
'/assets/css/login.css' '/assets/css/login.css'
]; ];
echo view('Templates/HeaderBlank', $data);
echo view('Account/Verification', $data); echo view('Account/Verification', $data);
echo view('Templates/FooterBlank', $data);
} }
} }

97
app/Controllers/Admin/Groups.php

@ -33,10 +33,16 @@ class Groups extends Controller
*/ */
public function __construct() public function __construct()
{ {
helper('aauth');
if (! is_admin())
{
return service('response')->redirect('/');
}
$this->aauth = new Aauth(); $this->aauth = new Aauth();
$this->request = Services::request(); $this->request = Services::request();
helper('form'); helper('form');
helper('aauth');
} }
/** /**
@ -48,13 +54,12 @@ class Groups extends Controller
{ {
$data = $this->aauth->listGroupsPaginated(); $data = $this->aauth->listGroupsPaginated();
$data['pagerLinks'] = $data['pager']->links();
$data['cssFiles'] = [ $data['cssFiles'] = [
'/assets/css/admin/groups/index.css' '/assets/css/admin/groups/index.css'
]; ];
echo view('Templates/HeaderAdmin', $data);
echo view('Admin/Groups/Home', $data); echo view('Admin/Groups/Home', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
@ -66,15 +71,13 @@ class Groups extends Controller
{ {
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listGroups();
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listPerms();
echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/New', $data); echo view('Admin/Groups/New', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Create * Create
* *
* @return void * @return redirect
*/ */
public function create() public function create()
{ {
@ -90,7 +93,7 @@ class Groups extends Controller
foreach ($subGroups as $subgroupId => $state) foreach ($subGroups as $subgroupId => $state)
{ {
if ($state === 1) if ((int) $state === 1)
{ {
$this->aauth->addSubgroup($groupId, $subgroupId); $this->aauth->addSubgroup($groupId, $subgroupId);
} }
@ -98,7 +101,7 @@ class Groups extends Controller
foreach ($perms as $permId => $state) foreach ($perms as $permId => $state)
{ {
if ($state === 1) if ((int) $state === 1)
{ {
$this->aauth->allowGroup($permId, $groupId); $this->aauth->allowGroup($permId, $groupId);
} }
@ -110,63 +113,69 @@ class Groups extends Controller
/** /**
* Edit * Edit
* *
* @return void * @param integer $groupId Group Id
*
* @return redirect|void
*/ */
public function edit($groupId) public function edit(int $groupId)
{ {
if (! $this->aauth->getGroup($groupId))
{
return redirect()->to('/admin/groups');
}
$data['group'] = $this->aauth->getGroup($groupId); $data['group'] = $this->aauth->getGroup($groupId);
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listGroupSubgroups($groupId);
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listGroupPerms($groupId);
$data['activeGroups'] = $this->aauth->getSubgroups($groupId);
$data['activePerms'] = $this->aauth->getGroupPerms($groupId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/Edit', $data); echo view('Admin/Groups/Edit', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Update * Update
* *
* @return void * @param integer $groupId Group Id
*
* @return redirect
*/ */
public function update($groupId) public function update(int $groupId)
{ {
$name = $this->request->getPost('name'); $name = $this->request->getPost('name');
$definition = $this->request->getPost('definition'); $definition = $this->request->getPost('definition');
$subGroups = $this->request->getPost('sub_groups'); $subGroups = $this->request->getPost('sub_groups');
$perms = $this->request->getPost('perms'); $perms = $this->request->getPost('perms');
if (! $this->aauth->updateGroup($groupId, empty($name) ? null : $name, empty($definition) ? null : $definition)) if (! $this->aauth->updateGroup($groupId, empty($name) ? null : $name, empty($definition) ? null : $definition))
{ {
return redirect()->back()->with('errors', $this->aauth->getErrorsArray()); return redirect()->back()->with('errors', $this->aauth->getErrorsArray());
} }
$activeSubGroups = $this->aauth->getSubgroups($groupId); $activeSubGroups = $this->aauth->getSubgroups($groupId);
$activePerms = $this->aauth->getGroupPerms($groupId, 1); $activePerms = $this->aauth->getGroupPerms($groupId);
foreach ($subGroups as $subgroupId => $state) foreach ($subGroups as $subgroupId => $state)
{ {
if (! in_array(['subgroup_id' => $subgroupId], $activeSubGroups) && $state === 1) if (! in_array(['subgroup_id' => $subgroupId], $activeSubGroups) && (int) $state === 1)
{ {
$this->aauth->addSubgroup($groupId, $subgroupId); $this->aauth->addSubgroup($groupId, $subgroupId);
} }
else if (in_array(['subgroup_id' => $subgroupId], $activeSubGroups) && $state === 0) else if (in_array(['subgroup_id' => $subgroupId], $activeSubGroups) && (int) $state === 0)
{ {
$this->aauth->removeSubgroup($groupId, $subgroupId); $this->aauth->removeSubgroup($groupId, $subgroupId);
} }
} }
foreach ($perms as $permId => $state) foreach ($perms as $permId => $state)
{ {
if (! in_array(['perm_id' => $permId], $activePerms) && $state === 1) if (! in_array(['perm_id' => $permId, 'state' => '1'], $activePerms) && (int) $state === 1)
{ {
$this->aauth->allowGroup($permId, $groupId); $this->aauth->allowGroup($permId, $groupId);
} }
else if (! in_array(['perm_id' => $permId], $activePerms) && $state === 0) else if (! in_array(['perm_id' => $permId, 'state' => '0'], $activePerms) && (int) $state === 0)
{ {
$this->aauth->denyGroup($permId, $groupId); $this->aauth->denyGroup($permId, $groupId);
} }
else if ((in_array(['perm_id' => $permId, 'state' => '0'], $activePerms) || in_array(['perm_id' => $permId, 'state' => '1'], $activePerms)) && (int) $state === -1)
{
$this->aauth->removeGroupPerm($permId, $groupId);
}
} }
return redirect()->to('/admin/groups/edit/' . $groupId); return redirect()->to('/admin/groups/edit/' . $groupId);
@ -175,35 +184,39 @@ class Groups extends Controller
/** /**
* Show * Show
* *
* @return void * @param integer $groupId Group Id
*
* @return redirect|void
*/ */
public function show($groupId) public function show(int $groupId)
{
if (! $this->aauth->getGroup($groupId))
{ {
return redirect()->to('/admin/groups');
}
$data['group'] = $this->aauth->getGroup($groupId); $data['group'] = $this->aauth->getGroup($groupId);
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listGroupSubgroups($groupId);
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listGroupPerms($groupId);
$data['activeGroups'] = $this->aauth->getSubgroups($groupId);
$data['activePerms'] = $this->aauth->getGroupPerms($groupId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/Show', $data); echo view('Admin/Groups/Show', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Delete * Delete
* *
* @return void * @param integer $groupId Group Id
*
* @return redirect|void
*/ */
public function delete($groupId) public function delete(int $groupId)
{ {
if (! $this->aauth->getGroup($groupId)) if (! $this->aauth->getGroup($groupId))
{ {
return redirect()->to('/admin/groups'); return redirect()->to('/admin/groups');
} }
$id = $this->request->getPost('id'); if ($groupId === $this->request->getPost('id'))
if ($groupId === $id)
{ {
if ($this->aauth->deleteGroup($groupId)) if ($this->aauth->deleteGroup($groupId))
{ {
@ -212,14 +225,10 @@ class Groups extends Controller
} }
$data['group'] = $this->aauth->getGroup($groupId); $data['group'] = $this->aauth->getGroup($groupId);
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listGroupSubgroups($groupId);
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listGroupPerms($groupId);
$data['activeGroups'] = $this->aauth->getSubgroups($groupId);
$data['activePerms'] = $this->aauth->getGroupPerms($groupId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/Delete', $data); echo view('Admin/Groups/Delete', $data);
echo view('Templates/FooterAdmin');
} }
} }

10
app/Controllers/Admin/Home.php

@ -29,13 +29,17 @@ class Home extends Controller
/** /**
* Index * Index
* *
* @return void * @return void|redirect
*/ */
public function index() public function index()
{ {
helper('aauth'); helper('aauth');
echo view('Templates/HeaderAdmin');
if (! is_admin())
{
return service('response')->redirect('/');
}
echo view('Admin/Home'); echo view('Admin/Home');
echo view('Templates/FooterAdmin');
} }
} }

10
app/Controllers/Admin/Migrate.php

@ -34,20 +34,18 @@ class Migrate extends Controller
public function index() public function index()
{ {
helper('aauth'); helper('aauth');
$config = new \Config\Aauth(); $config = new \Config\Aauth();
$migrate = \Config\Services::migrations(); $migrate = \Config\Services::migrations();
$db = \Config\Database::connect();
try try
{ {
$migrated = $migrate->latest('App', $config->dbProfile); $migrate->latest('App', $config->dbProfile);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
// Do something with the error here... echo $e->getMessage();
} }
echo view('Templates/Header');
echo view('Admin/Migrate');
echo view('Templates/Footer');
} }
} }

58
app/Controllers/Admin/Perms.php

@ -33,10 +33,16 @@ class Perms extends Controller
*/ */
public function __construct() public function __construct()
{ {
helper('aauth');
if (! is_admin())
{
return service('response')->redirect('/');
}
$this->aauth = new Aauth(); $this->aauth = new Aauth();
$this->request = Services::request(); $this->request = Services::request();
helper('form'); helper('form');
helper('aauth');
} }
/** /**
@ -48,13 +54,12 @@ class Perms extends Controller
{ {
$data = $this->aauth->listPermsPaginated(); $data = $this->aauth->listPermsPaginated();
$data['pagerLinks'] = $data['pager']->links();
$data['cssFiles'] = [ $data['cssFiles'] = [
'/assets/css/admin/perms/index.css' '/assets/css/admin/perms/index.css'
]; ];
echo view('Templates/HeaderAdmin', $data);
echo view('Admin/Perms/Home', $data); echo view('Admin/Perms/Home', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
@ -64,15 +69,13 @@ class Perms extends Controller
*/ */
public function new() public function new()
{ {
echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/New'); echo view('Admin/Perms/New');
echo view('Templates/FooterAdmin');
} }
/** /**
* Create * Create
* *
* @return void * @return redirect
*/ */
public function create() public function create()
{ {
@ -90,23 +93,30 @@ class Perms extends Controller
/** /**
* Edit * Edit
* *
* @return void * @param integer $permId Perm Id
*
* @return redirect|void
*/ */
public function edit($permId) public function edit(int $permId)
{
if (! $this->aauth->getPerm($permId))
{ {
return redirect()->to('/admin/perms');
}
$data['perm'] = $this->aauth->getPerm($permId); $data['perm'] = $this->aauth->getPerm($permId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/Edit', $data); echo view('Admin/Perms/Edit', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Update * Update
* *
* @return void * @param integer $permId Perm Id
*
* @return redirect
*/ */
public function update($permId) public function update(int $permId)
{ {
$name = $this->request->getPost('name'); $name = $this->request->getPost('name');
$definition = $this->request->getPost('definition'); $definition = $this->request->getPost('definition');
@ -122,31 +132,37 @@ class Perms extends Controller
/** /**
* Show * Show
* *
* @return void * @param integer $permId Perm Id
*
* @return redirect|void
*/ */
public function show($permId) public function show(int $permId)
{
if (! $this->aauth->getPerm($permId))
{ {
return redirect()->to('/admin/perms');
}
$data['perm'] = $this->aauth->getPerm($permId); $data['perm'] = $this->aauth->getPerm($permId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/Show', $data); echo view('Admin/Perms/Show', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Delete * Delete
* *
* @return void * @param integer $permId Perm Id
*
* @return redirect|void
*/ */
public function delete($permId) public function delete(int $permId)
{ {
if (! $this->aauth->getPerm($permId)) if (! $this->aauth->getPerm($permId))
{ {
return redirect()->to('/admin/perms'); return redirect()->to('/admin/perms');
} }
$id = $this->request->getPost('id'); if ($permId === $this->request->getPost('id'))
if ($permId === $id)
{ {
if ($this->aauth->deletePerm($permId)) if ($this->aauth->deletePerm($permId))
{ {
@ -156,9 +172,7 @@ class Perms extends Controller
$data['perm'] = $this->aauth->getPerm($permId); $data['perm'] = $this->aauth->getPerm($permId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/Delete', $data); echo view('Admin/Perms/Delete', $data);
echo view('Templates/FooterAdmin');
} }
} }

76
app/Controllers/Admin/Users.php

@ -34,11 +34,17 @@ class Users extends Controller
*/ */
public function __construct() public function __construct()
{ {
$this->config = new AauthConfig(); helper('aauth');
if (! is_admin())
{
return service('response')->redirect('/');
}
$this->aauth = new Aauth(); $this->aauth = new Aauth();
$this->config = new AauthConfig();
$this->request = Services::request(); $this->request = Services::request();
helper('form'); helper('form');
helper('aauth');
} }
/** /**
@ -50,13 +56,12 @@ class Users extends Controller
{ {
$data = $this->aauth->listUsersPaginated(); $data = $this->aauth->listUsersPaginated();
$data['pagerLinks'] = $data['pager']->links();
$data['cssFiles'] = [ $data['cssFiles'] = [
'/assets/css/admin/users/index.css' '/assets/css/admin/users/index.css'
]; ];
echo view('Templates/HeaderAdmin', $data);
echo view('Admin/Users/Home', $data); echo view('Admin/Users/Home', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
@ -70,15 +75,13 @@ class Users extends Controller
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listGroups();
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listPerms();
echo view('Templates/HeaderAdmin');
echo view('Admin/Users/New', $data); echo view('Admin/Users/New', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Create * Create
* *
* @return void * @return redirect
*/ */
public function create() public function create()
{ {
@ -97,26 +100,33 @@ class Users extends Controller
/** /**
* Edit * Edit
* *
* @return void * @param integer $userId User Id
*
* @return redirect|void
*/ */
public function edit($userId) public function edit(int $userId)
{
if (! $this->aauth->getUser($userId))
{ {
return redirect()->to('/admin/users');
}
$data['useUsername'] = $this->config->loginUseUsername; $data['useUsername'] = $this->config->loginUseUsername;
$data['user'] = $this->aauth->getUser($userId); $data['user'] = $this->aauth->getUser($userId);
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listUserGroups($userId);
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listUserPerms($userId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Users/Edit', $data); echo view('Admin/Users/Edit', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Update * Update
* *
* @return void * @param integer $userId User Id
*
* @return redirect
*/ */
public function update($userId) public function update(int $userId)
{ {
$email = $this->request->getPost('email'); $email = $this->request->getPost('email');
$username = $this->request->getPost('username'); $username = $this->request->getPost('username');
@ -139,11 +149,11 @@ class Users extends Controller
continue; continue;
} }
if (! in_array(['group_id' => $groupId], $activeGroups) && $state === 1) if (! in_array(['group_id' => $groupId], $activeGroups) && (int) $state === 1)
{ {
$this->aauth->addMember($groupId, $userId); $this->aauth->addMember($groupId, $userId);
} }
else if (in_array(['group_id' => $groupId], $activeGroups) && $state === 0) else if (in_array(['group_id' => $groupId], $activeGroups) && (int) $state === 0)
{ {
$this->aauth->removeMember($groupId, $userId); $this->aauth->removeMember($groupId, $userId);
} }
@ -151,11 +161,11 @@ class Users extends Controller
foreach ($perms as $permId => $state) foreach ($perms as $permId => $state)
{ {
if (! in_array(['perm_id' => $permId], $activePerms) && $state === 1) if (! in_array(['perm_id' => $permId], $activePerms) && (int) $state === 1)
{ {
$this->aauth->allowUser($permId, $userId); $this->aauth->allowUser($permId, $userId);
} }
else if (in_array(['perm_id' => $permId], $activePerms) && $state === 0) else if (in_array(['perm_id' => $permId], $activePerms) && (int) $state === 0)
{ {
$this->aauth->denyUser($permId, $userId); $this->aauth->denyUser($permId, $userId);
} }
@ -167,33 +177,39 @@ class Users extends Controller
/** /**
* Show * Show
* *
* @return void * @param integer $userId User Id
*
* @return redirect|void
*/ */
public function show($userId) public function show(int $userId)
{
if (! $this->aauth->getUser($userId))
{ {
return redirect()->to('/admin/users');
}
$data['user'] = $this->aauth->getUser($userId); $data['user'] = $this->aauth->getUser($userId);
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listUserGroups($userId);
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listUserPerms($userId);
echo view('Templates/HeaderAdmin');
echo view('Admin/Users/Show', $data); echo view('Admin/Users/Show', $data);
echo view('Templates/FooterAdmin');
} }
/** /**
* Delete * Delete
* *
* @return void * @param integer $userId User Id
*
* @return redirect|void
*/ */
public function delete($userId) public function delete(int $userId)
{ {
if (! $this->aauth->getUser($userId)) if (! $this->aauth->getUser($userId))
{ {
return redirect()->to('/admin/users'); return redirect()->to('/admin/users');
} }
$id = $this->request->getPost('id'); if ($userId === $this->request->getPost('id'))
if ($userId === $id)
{ {
if ($this->aauth->deleteUser($userId)) if ($this->aauth->deleteUser($userId))
{ {
@ -205,9 +221,7 @@ class Users extends Controller
$data['groups'] = $this->aauth->listGroups(); $data['groups'] = $this->aauth->listGroups();
$data['perms'] = $this->aauth->listPerms(); $data['perms'] = $this->aauth->listPerms();
echo view('Templates/HeaderAdmin');
echo view('Admin/Users/Delete', $data); echo view('Admin/Users/Delete', $data);
echo view('Templates/FooterAdmin');
} }
} }

3
app/Controllers/Home.php

@ -34,8 +34,7 @@ class Home extends Controller
public function index() public function index()
{ {
helper('aauth'); helper('aauth');
echo view('Templates/Header');
echo view('Home'); echo view('Home');
echo view('Templates/Footer');
} }
} }

12
app/Views/Account/Edit.php

@ -1,13 +1,16 @@
<?= $this->extend('Templates/Base') ?>
<?= $this->section('content') ?>
<div class="card"> <div class="card">
<div class="card-header"><?=lang('Account.editHeader')?></div> <div class="card-header"><?=lang('Account.editHeader')?></div>
<div class="card-body"> <div class="card-body">
<?= form_open('account/edit') ?> <?= form_open('account/edit') ?>
<?if (isset($errors)):?> <?php if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div> <div class="alert alert-danger"><?=$errors?></div>
<?endif;?> <?php endif;?>
<?if (isset($infos)):?> <?php if (isset($infos)):?>
<div class="alert alert-success"><?=$infos?></div> <div class="alert alert-success"><?=$infos?></div>
<?endif;?> <?php endif;?>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.editLabelEmail')?>" autofocus> <input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.editLabelEmail')?>" autofocus>
@ -30,3 +33,4 @@
<?= form_close() ?> <?= form_close() ?>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

31
app/Views/Account/Home.php

@ -1,3 +1,28 @@
<h2><?= lang('Account.homeText') ?></h2> <br /> <?= $this->extend('Templates/Base') ?>
<?= lang('Account.homeLabelUsername') ?>: <?= $user['username'] ?> <br />
<?= lang('Account.homeLabelEmail') ?>: <?= $user['email'] ?> <br /> <?= $this->section('content') ?>
<div class="card">
<div class="card-header">
<?= lang('Account.homeText') ?>
</div>
<div class="card-body">
<div class="row">
<div class="col-sm-4">
<b><?= lang('Account.homeLabelUsername') ?></b>
</div>
<div class="col-sm-8">
<?= $user['username'] ?>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<b><?= lang('Account.homeLabelEmail') ?></b>
</div>
<div class="col-sm-8">
<?= $user['email'] ?>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>

14
app/Views/Account/Login.php

@ -1,20 +1,23 @@
<?= $this->extend('Templates/Blank') ?>
<?= $this->section('content') ?>
<div class="container"> <div class="container">
<div class="card card-login mx-auto mt-5"> <div class="card card-login mx-auto mt-5">
<div class="card-header"><?=lang('Account.loginHeader')?></div> <div class="card-header"><?=lang('Account.loginHeader')?></div>
<div class="card-body"> <div class="card-body">
<?= form_open('account/login') ?> <?= form_open('account/login') ?>
<?if (isset($errors)):?> <?php if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div> <div class="alert alert-danger"><?=$errors?></div>
<?endif;?> <?php endif;?>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<?if ($useUsername):?> <?php if ($useUsername):?>
<input type="text" name="username" id="inputUsername" class="form-control" placeholder="<?=lang('Account.loginLabelUsername')?>" required autofocus> <input type="text" name="username" id="inputUsername" class="form-control" placeholder="<?=lang('Account.loginLabelUsername')?>" required autofocus>
<label for="inputUsername"><?=lang('Account.loginLabelUsername')?></label> <label for="inputUsername"><?=lang('Account.loginLabelUsername')?></label>
<?else:?> <?php else:?>
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.loginLabelEmail')?>" required autofocus> <input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.loginLabelEmail')?>" required autofocus>
<label for="inputEmail"><?=lang('Account.loginLabelEmail')?></label> <label for="inputEmail"><?=lang('Account.loginLabelEmail')?></label>
<?endif;?> <?php endif;?>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -46,3 +49,4 @@
</div> </div>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

17
app/Views/Account/Register.php

@ -1,23 +1,27 @@
<?= $this->extend('Templates/Blank') ?>
<?= $this->section('content') ?>
<div class="container"> <div class="container">
<div class="card card-register mx-auto mt-5"> <div class="card card-register mx-auto mt-5">
<div class="card-header"><?=lang('Account.registerHeader')?></div> <div class="card-header"><?=lang('Account.registerHeader')?></div>
<div class="card-body"> <div class="card-body">
<?= form_open('account/register') ?> <?= form_open('account/register') ?>
<?if (isset($errors)):?> <?php if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div> <div class="alert alert-danger"><?=$errors?></div>
<?endif;?> <?php endif;?>
<?if (isset($infos)):?> <?php if (isset($infos)):?>
<div class="alert alert-success"><?=$infos?></div> <div class="alert alert-success"><?=$infos?></div>
<?endif;?> <?php endif;?>
<?php $socialData = session('userProfile'); ?>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.registerLabelEmail')?>" required autofocus> <input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.registerLabelEmail')?>" <?= isset($socialData) ? 'readonly value="' . $socialData->email . '"' : 'required autofocus' ?>>
<label for="inputEmail"><?=lang('Account.registerLabelEmail')?>*</label> <label for="inputEmail"><?=lang('Account.registerLabelEmail')?>*</label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<input type="text" name="username" id="inputUsername" class="form-control" placeholder="<?=lang('Account.registerLabelUsername')?>" <?=($useUsername ? 'required' : '')?>> <input type="text" name="username" id="inputUsername" class="form-control" placeholder="<?=lang('Account.registerLabelUsername')?>" <?=($useUsername ? 'required' : '')?> <?= isset($socialData) ? '' : 'autofocus' ?>>
<label for="inputUsername"><?=lang('Account.registerLabelUsername')?><?=($useUsername ? '*' : '')?></label> <label for="inputUsername"><?=lang('Account.registerLabelUsername')?><?=($useUsername ? '*' : '')?></label>
</div> </div>
</div> </div>
@ -43,3 +47,4 @@
</div> </div>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

12
app/Views/Account/RemindPassword.php

@ -1,15 +1,18 @@
<?= $this->extend('Templates/Blank') ?>
<?= $this->section('content') ?>
<div class="container"> <div class="container">
<div class="card card-login mx-auto mt-5"> <div class="card card-login mx-auto mt-5">
<div class="card-header"><?=lang('Account.remindPasswordHeader')?></div> <div class="card-header"><?=lang('Account.remindPasswordHeader')?></div>
<div class="card-body"> <div class="card-body">
<?= form_open('account/remind_password') ?> <?= form_open('account/remind_password') ?>
<p><?=lang('Account.remindPasswordText')?></p> <p><?=lang('Account.remindPasswordText')?></p>
<?if (isset($errors)):?> <?php if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div> <div class="alert alert-danger"><?=$errors?></div>
<?endif;?> <?php endif;?>
<?if (isset($infos)):?> <?php if (isset($infos)):?>
<div class="alert alert-info"><?=$infos?></div> <div class="alert alert-info"><?=$infos?></div>
<?endif;?> <?php endif;?>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.remindPasswordLabelEmail')?>" required autofocus> <input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.remindPasswordLabelEmail')?>" required autofocus>
@ -31,3 +34,4 @@
</div> </div>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

12
app/Views/Account/ResetPassword.php

@ -1,15 +1,18 @@
<?= $this->extend('Templates/Blank') ?>
<?= $this->section('content') ?>
<div class="container"> <div class="container">
<div class="card card-login mx-auto mt-5"> <div class="card card-login mx-auto mt-5">
<div class="card-header"><?=lang('Account.resetPasswordHeader')?></div> <div class="card-header"><?=lang('Account.resetPasswordHeader')?></div>
<div class="card-body"> <div class="card-body">
<?= form_open('account/reset_password') ?> <?= form_open('account/reset_password') ?>
<p><?=lang('Account.resetPasswordText')?></p> <p><?=lang('Account.resetPasswordText')?></p>
<?if (isset($errors)):?> <?php if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div> <div class="alert alert-danger"><?=$errors?></div>
<?endif;?> <?php endif;?>
<?if (isset($infos)):?> <?php if (isset($infos)):?>
<div class="alert alert-info"><?=$infos?></div> <div class="alert alert-info"><?=$infos?></div>
<?endif;?> <?php endif;?>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<input type="test" name="verification_code" id="inputVerificationCode" class="form-control" placeholder="<?=lang('Account.resetPasswordLabelVerificationCode')?>" value="<?=$verificationCode?>" required autofocus> <input type="test" name="verification_code" id="inputVerificationCode" class="form-control" placeholder="<?=lang('Account.resetPasswordLabelVerificationCode')?>" value="<?=$verificationCode?>" required autofocus>
@ -31,3 +34,4 @@
</div> </div>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

12
app/Views/Account/Verification.php

@ -1,15 +1,18 @@
<?= $this->extend('Templates/Blank') ?>
<?= $this->section('content') ?>
<div class="container"> <div class="container">
<div class="card card-login mx-auto mt-5"> <div class="card card-login mx-auto mt-5">
<div class="card-header"><?=lang('Account.verificationHeader')?></div> <div class="card-header"><?=lang('Account.verificationHeader')?></div>
<div class="card-body"> <div class="card-body">
<?= form_open('account/verification') ?> <?= form_open('account/verification') ?>
<p><?=lang('Account.verificationText')?></p> <p><?=lang('Account.verificationText')?></p>
<?if (isset($errors)):?> <?php if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div> <div class="alert alert-danger"><?=$errors?></div>
<?endif;?> <?php endif;?>
<?if (isset($infos)):?> <?php if (isset($infos)):?>
<div class="alert alert-info"><?=$infos?></div> <div class="alert alert-info"><?=$infos?></div>
<?endif;?> <?php endif;?>
<div class="form-group"> <div class="form-group">
<div class="form-label-group"> <div class="form-label-group">
<input type="test" name="verification_code" id="inputVerificationCode" class="form-control" placeholder="<?=lang('Account.verificationLabelVerificationCode')?>" value="<?=$verificationCode?>" required autofocus> <input type="test" name="verification_code" id="inputVerificationCode" class="form-control" placeholder="<?=lang('Account.verificationLabelVerificationCode')?>" value="<?=$verificationCode?>" required autofocus>
@ -31,3 +34,4 @@
</div> </div>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

8
app/Views/Admin/Groups/Delete.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -31,7 +34,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label> <label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $group): ?>
<?php if (! in_array(['subgroup_id' => $group['id']], $activeGroups)): ?> <?php if ((int) $group['subgroup'] !== 1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -46,7 +49,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<?php if (! in_array(['perm_id' => $perm['id'], 'state' => 1], $activePerms)): ?> <?php if ((int) $perm['state'] !== -1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -66,3 +69,4 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>

36
app/Views/Admin/Groups/Edit.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -47,10 +50,13 @@
<div class="form-group"> <div class="form-group">
<label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label> <label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label>
<?php foreach ($groups as $subgroup): ?> <?php foreach ($groups as $subgroup): ?>
<?php $subgroup['subgroup'] = (int) $subgroup['subgroup']; ?>
<?php $subgroup['id'] = (int) $subgroup['id']; ?>
<?php $group['id'] = (int) $group['id']; ?>
<input type="hidden" name="sub_groups[<?= $subgroup['id'] ?>]" value="0"> <input type="hidden" name="sub_groups[<?= $subgroup['id'] ?>]" value="0">
<div class="form-check"> <div class="form-check">
<label> <label>
<input type="checkbox" name="sub_groups[<?= $subgroup['id'] ?>]" value="1" <?= in_array(['subgroup_id' => $subgroup['id']], $activeGroups) ? 'checked' : ($subgroup['id'] === 2 ? 'disabled' : ($subgroup['id'] === 3 ? 'disabled' : ($subgroup['id'] === $group['id'] ? 'disabled' : ''))) ?>> <input type="checkbox" name="sub_groups[<?= $subgroup['id'] ?>]" value="1" <?= $subgroup['subgroup'] === 1 ? 'checked' : ($subgroup['id'] === 2 ? 'disabled' : ($subgroup['id'] === 3 ? 'disabled' : ($subgroup['id'] === $group['id'] ? 'disabled' : ''))) ?>>
<?= $subgroup['definition'] ?> (<?= $subgroup['name'] ?>) <?= $subgroup['definition'] ?> (<?= $subgroup['name'] ?>)
</label> </label>
</div> </div>
@ -61,11 +67,17 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<input type="hidden" name="perms[<?= $perm['id'] ?>]" value="0"> <?php $perm['state'] = (int) $perm['state']; ?>
<input type="hidden" name="perms[<?= $perm['id'] ?>]" value="-1">
<div class="form-check"> <div class="form-check">
<label> <label>
<input type="checkbox" name="perms[<?= $perm['id'] ?>]" value="1" <?= in_array(['perm_id' => $perm['id'], 'state' => 1], $activePerms) ? 'checked' : '' ?>> <input type="checkbox" name="perms[<?= $perm['id'] ?>]" class="perm" <?= $perm['state'] !== -1 ? 'checked' : ''?>> <?= $perm['definition']?> (<?= $perm['name'] ?>)
<?= $perm['definition'] ?> (<?= $perm['name'] ?>) </label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="1" <?= $perm['state'] === 1 ? 'checked' : ''?> <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelAllow')?>
</label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="0" <?= $perm['state'] === 0 ? 'checked' : ''?> <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelDeny')?>
</label> </label>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
@ -79,3 +91,19 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>
<?= $this->section('footer') ?>
<script type="text/javascript">
$(document).on('change', '.perm', function() {
var name = $(this).attr('name');
if ($(this).prop('checked')) {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', false);
$('input[type="radio"][name="'+ name + '"]:eq(0)').prop('checked', true);
} else {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', true);
}
});
</script>
<?= $this->endSection() ?>

6
app/Views/Admin/Groups/Home.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -55,6 +58,7 @@
</div> </div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<?= $pager->links() ?> <?= $pagerLinks ?>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

39
app/Views/Admin/Groups/New.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -32,12 +35,13 @@
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group"> <div class="form-group">
<label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label> <label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $subgroup): ?>
<input type="hidden" name="sub_groups[<?= $group['id'] ?>]" value="0"> <?php $subgroup['id'] = (int) $subgroup['id']; ?>
<input type="hidden" name="sub_groups[<?= $subgroup['id'] ?>]" value="0">
<div class="form-check"> <div class="form-check">
<label> <label>
<input type="checkbox" name="sub_groups[<?= $group['id'] ?>]" value="1" <?= ($group['id'] === 2 ? 'disabled' : ($group['id'] === 3 ? 'disabled' : '')) ?>> <input type="checkbox" name="sub_groups[<?= $subgroup['id'] ?>]" value="1" <?= ($subgroup['id'] === 2 ? 'disabled' : ($subgroup['id'] === 3 ? 'disabled' : '')) ?>>
<?= $group['definition'] ?> (<?= $group['name'] ?>) <?= $subgroup['definition'] ?> (<?= $subgroup['name'] ?>)
</label> </label>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
@ -47,11 +51,16 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<input type="hidden" name="perms[<?= $perm['id'] ?>]" value="0"> <input type="hidden" name="perms[<?= $perm['id'] ?>]" value="-1">
<div class="form-check"> <div class="form-check">
<label> <label>
<input type="checkbox" name="perms[<?= $perm['id'] ?>]" value="1"> <input type="checkbox" name="perms[<?= $perm['id'] ?>]" class="perm"> <?= $perm['definition']?> (<?= $perm['name'] ?>)
<?= $perm['definition'] ?> (<?= $perm['name'] ?>) </label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="1" <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelAllow')?>
</label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="0" <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelDeny')?>
</label> </label>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
@ -65,3 +74,19 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>
<?= $this->section('footer') ?>
<script type="text/javascript">
$(document).on('change', '.perm', function() {
var name = $(this).attr('name');
if ($(this).prop('checked')) {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', false);
$('input[type="radio"][name="'+ name + '"]:eq(0)').prop('checked', true);
} else {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', true);
}
});
</script>
<?= $this->endSection() ?>

8
app/Views/Admin/Groups/Show.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -29,7 +32,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label> <label for="inputSubGroups"><?= lang('Admin.groupsLabelSubGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $group): ?>
<?php if (! in_array(['subgroup_id' => $group['id']], $activeGroups)): ?> <?php if ((int) $group['subgroup'] !== 1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -44,7 +47,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.groupsLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<?php if (! in_array(['perm_id' => $perm['id'], 'state' => 1], $activePerms)): ?> <?php if ((int) $perm['state'] !== -1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -61,3 +64,4 @@
<a href="<?= site_url('admin/groups') ?>" class="btn btn-warning"><?= lang('Admin.groupsLinkBack') ?></a> <a href="<?= site_url('admin/groups') ?>" class="btn btn-warning"><?= lang('Admin.groupsLinkBack') ?></a>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

4
app/Views/Admin/Home.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item active"><?= lang('Admin.homeBreadcrumbTitle') ?></li> <li class="breadcrumb-item active"><?= lang('Admin.homeBreadcrumbTitle') ?></li>
</ol> </ol>
@ -9,3 +12,4 @@
<p class="lead"><?= lang('Admin.homeText') ?></p> <p class="lead"><?= lang('Admin.homeText') ?></p>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

4
app/Views/Admin/Migrate.php

@ -1,4 +1,8 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<div class="pt-5 px-5 mt-5 mx-auto w-50"> <div class="pt-5 px-5 mt-5 mx-auto w-50">
<h1 class="mb-5">CodeIgniter-Aauth v3 Migration</h1> <h1 class="mb-5">CodeIgniter-Aauth v3 Migration</h1>
<p class="lead">Migration done.</p> <p class="lead">Migration done.</p>
</div> </div>
<?= $this->endSection() ?>

4
app/Views/Admin/Perms/Delete.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -32,3 +35,4 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>

4
app/Views/Admin/Perms/Edit.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -49,3 +52,4 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>

6
app/Views/Admin/Perms/Home.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -51,6 +54,7 @@
</div> </div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<?= $pager->links() ?> <?= $pagerLinks ?>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

4
app/Views/Admin/Perms/New.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -35,3 +38,4 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>

4
app/Views/Admin/Perms/Show.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -29,3 +32,4 @@
<a href="<?= site_url('admin/perms') ?>" class="btn btn-warning"><?= lang('Admin.permsLinkBack') ?></a> <a href="<?= site_url('admin/perms') ?>" class="btn btn-warning"><?= lang('Admin.permsLinkBack') ?></a>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

8
app/Views/Admin/Users/Delete.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -30,7 +33,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputSubGroups"><?= lang('Admin.usersLabelGroups') ?></label> <label for="inputSubGroups"><?= lang('Admin.usersLabelGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $group): ?>
<?php if (! is_member($group['id'], $user['id'])): ?> <?php if ((int) $group['member'] !== 1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -45,7 +48,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<?php if (! is_allowed($perm['id'], $user['id'])): ?> <?php if ((int) $perm['state'] !== -1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -64,3 +67,4 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>

32
app/Views/Admin/Users/Edit.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -51,6 +54,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputGroups"><?= lang('Admin.usersLabelGroups') ?></label> <label for="inputGroups"><?= lang('Admin.usersLabelGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $group): ?>
<?php $group['id'] = (int) $group['id']; ?>
<input type="hidden" name="groups[<?= $group['id'] ?>]" value="0"> <input type="hidden" name="groups[<?= $group['id'] ?>]" value="0">
<div class="form-check"> <div class="form-check">
<label> <label>
@ -65,11 +69,17 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<input type="hidden" name="perms[<?= $perm['id'] ?>]" value="0"> <?php $perm['state'] = (int) $perm['state']; ?>
<input type="hidden" name="perms[<?= $perm['id'] ?>]" value="-1">
<div class="form-check"> <div class="form-check">
<label> <label>
<input type="checkbox" name="perms[<?= $perm['id'] ?>]" value="1" <?= (is_allowed($perm['id'], $user['id']) ? 'checked' : '') ?>> <input type="checkbox" name="perms[<?= $perm['id'] ?>]" class="perm" <?= $perm['state'] !== -1 ? 'checked' : ''?>> <?= $perm['definition']?> (<?= $perm['name'] ?>)
<?= $perm['definition'] ?> (<?= $perm['name'] ?>) </label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="1" <?= $perm['state'] === 1 ? 'checked' : ''?> <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelAllow')?>
</label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="0" <?= $perm['state'] === 0 ? 'checked' : ''?> <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelDeny')?>
</label> </label>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
@ -83,3 +93,19 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>
<?= $this->section('footer') ?>
<script type="text/javascript">
$(document).on('change', '.perm', function() {
var name = $(this).attr('name');
if ($(this).prop('checked')) {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', false);
$('input[type="radio"][name="'+ name + '"]:eq(0)').prop('checked', true);
} else {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', true);
}
});
</script>
<?= $this->endSection() ?>

6
app/Views/Admin/Users/Home.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -63,6 +66,7 @@
</div> </div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<?= $pager->links() ?> <?= $pagerLinks ?>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

31
app/Views/Admin/Users/New.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -37,6 +40,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputGroups"><?= lang('Admin.usersLabelGroups') ?></label> <label for="inputGroups"><?= lang('Admin.usersLabelGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $group): ?>
<?php $group['id'] = (int) $group['id']; ?>
<input type="hidden" name="groups[<?= $group['id'] ?>]" value="0"> <input type="hidden" name="groups[<?= $group['id'] ?>]" value="0">
<div class="form-check"> <div class="form-check">
<label> <label>
@ -51,11 +55,16 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<input type="hidden" name="perms[<?= $perm['id'] ?>]" value="0"> <input type="hidden" name="perms[<?= $perm['id'] ?>]" value="-1">
<div class="form-check"> <div class="form-check">
<label> <label>
<input type="checkbox" name="perms[<?= $perm['id'] ?>]" value="1"> <input type="checkbox" name="perms[<?= $perm['id'] ?>]" class="perm"> <?= $perm['definition']?> (<?= $perm['name'] ?>)
<?= $perm['definition'] ?> (<?= $perm['name'] ?>) </label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="1" <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelAllow')?>
</label>
<label>
<input type="radio" name="perms[<?= $perm['id'] ?>]" value="0" <?= $perm['state'] === -1 ? 'disabled' : ''?>><?= lang('Admin.usersLabelDeny')?>
</label> </label>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
@ -69,3 +78,19 @@
</div> </div>
<?= form_close() ?> <?= form_close() ?>
</div> </div>
<?= $this->endSection() ?>
<?= $this->section('footer') ?>
<script type="text/javascript">
$(document).on('change', '.perm', function() {
var name = $(this).attr('name');
if ($(this).prop('checked')) {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', false);
$('input[type="radio"][name="'+ name + '"]:eq(0)').prop('checked', true);
} else {
$('input[type="radio"][name="'+ name + '"]').prop('checked', false).prop('disabled', true);
}
});
</script>
<?= $this->endSection() ?>

8
app/Views/Admin/Users/Show.php

@ -1,3 +1,6 @@
<?= $this->extend('Templates/Admin') ?>
<?= $this->section('content') ?>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a> <a href="<?= site_url('admin') ?>"><?= lang('Admin.homeBreadcrumbTitle') ?></a>
@ -29,7 +32,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputSubGroups"><?= lang('Admin.usersLabelGroups') ?></label> <label for="inputSubGroups"><?= lang('Admin.usersLabelGroups') ?></label>
<?php foreach ($groups as $group): ?> <?php foreach ($groups as $group): ?>
<?php if (! is_member($group['id'], $user['id'])): ?> <?php if ((int) $group['member'] !== 1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -44,7 +47,7 @@
<div class="form-group"> <div class="form-group">
<label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label> <label for="inputPerms"><?= lang('Admin.usersLabelPerms') ?></label>
<?php foreach ($perms as $perm): ?> <?php foreach ($perms as $perm): ?>
<?php if (! is_allowed($perm['id'], $user['id'])): ?> <?php if ((int) $perm['state'] !== -1): ?>
<?php continue; ?> <?php continue; ?>
<?php endif; ?> <?php endif; ?>
<div class="form-check"> <div class="form-check">
@ -61,3 +64,4 @@
<a href="<?= site_url('admin/users') ?>" class="btn btn-warning"><?= lang('Admin.usersLinkBack') ?></a> <a href="<?= site_url('admin/users') ?>" class="btn btn-warning"><?= lang('Admin.usersLinkBack') ?></a>
</div> </div>
</div> </div>
<?= $this->endSection() ?>

10
app/Views/Home.php

@ -1,9 +1,13 @@
<?= $this->extend('Templates/Base') ?>
<?= $this->section('content') ?>
<h1 class="mb-5">Welcome To CodeIgniter-Aauth v3 for CodeIgniter 4.x</h1> <h1 class="mb-5">Welcome To CodeIgniter-Aauth v3 for CodeIgniter 4.x</h1>
<p class="lead">Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite ease of use, it has also very advanced features like groupping, access management, public access etc..</p> <p class="lead">Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite ease of use, it has also very advanced features like groupping, access management, public access etc..</p>
<? if(is_loggedin()): ?> <?php if(is_loggedin()): ?>
<p>You are logged in.</p> <p>You are logged in.</p>
<a href="<?= site_url('account') ?>" class="btn btn-primary px-5">Account Details</a> <a href="<?= site_url('account') ?>" class="btn btn-primary px-5">Account Details</a>
<? else: ?> <?php else: ?>
<p>You can Login now and test it.</p> <p>You can Login now and test it.</p>
<a href="<?= site_url('account/login') ?>" class="btn btn-primary px-5">Login</a> <a href="<?= site_url('account/login') ?>" class="btn btn-primary px-5">Login</a>
<? endif; ?> <?php endif; ?>
<?= $this->endSection() ?>

37
app/Views/Templates/HeaderAdmin.php → app/Views/Templates/Admin.php

@ -15,6 +15,7 @@
<link href="<?= $cssFile; ?>" rel="stylesheet"> <link href="<?= $cssFile; ?>" rel="stylesheet">
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<?= $this->renderSection('header') ?>
</head> </head>
<body id="page-top"> <body id="page-top">
<nav class="navbar navbar-expand navbar-dark bg-dark static-top"> <nav class="navbar navbar-expand navbar-dark bg-dark static-top">
@ -34,7 +35,12 @@
<i class="fas fa-user-circle fa-fw"></i> <i class="fas fa-user-circle fa-fw"></i>
</a> </a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
<a class="dropdown-item" href="<?= site_url('account/edit') ?>">Edit Profile</a> <?php if (is_admin()): ?>
<a class="dropdown-item" href="<?= site_url('admin') ?>">Admin Area</a>
<div class="dropdown-divider"></div>
<?php endif; ?>
<a class="dropdown-item <?= uri_string() === 'account' ? 'active' : '' ?>" href="<?= site_url('account') ?>">Profile</a>
<a class="dropdown-item <?= uri_string() === 'account/edit' ? 'active' : '' ?>" href="<?= site_url('account/edit') ?>">Edit Profile</a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?= site_url('account/logout') ?>">Logout</a> <a class="dropdown-item" href="<?= site_url('account/logout') ?>">Logout</a>
</div> </div>
@ -73,3 +79,32 @@
<div id="content-wrapper"> <div id="content-wrapper">
<div class="container-fluid"> <div class="container-fluid">
<?= $this->renderSection('content') ?>
</div>
<footer class="sticky-footer">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright © Aauth 2018</span>
</div>
</div>
</footer>
</div>
</div>
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/assets/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="/assets/js/sb-admin.min.js"></script>
<?php if (isset($jsFiles)): ?>
<?php foreach ($jsFiles as $jsFiles): ?>
<script type="text/javascript" src="<?= $jsFile; ?>"></script>
<?php endforeach; ?>
<?php endif; ?>
<?= $this->renderSection('footer') ?>
</body>
</html>

36
app/Views/Templates/Header.php → app/Views/Templates/Base.php

@ -6,15 +6,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content=""> <meta name="description" content="">
<meta name="author" content=""> <meta name="author" content="">
<title><? (isset($title) ? $title : '') ?></title> <title><?= (isset($title) ? $title : '') ?></title>
<link href="/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet"> <link href="/assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
<link href="/assets/css/sb-admin.min.css" rel="stylesheet"> <link href="/assets/css/sb-admin.min.css" rel="stylesheet">
<? if (isset($cssFiles)): ?> <?php if (isset($cssFiles)): ?>
<? foreach ($cssFiles as $cssFile): ?> <?php foreach ($cssFiles as $cssFile): ?>
<link href="<?= $cssFile; ?>" rel="stylesheet"> <link href="<?= $cssFile; ?>" rel="stylesheet">
<? endforeach; ?> <?php endforeach; ?>
<? endif; ?> <?php endif; ?>
</head> </head>
<body id="page-top"> <body id="page-top">
<nav class="navbar navbar-expand navbar-dark bg-dark static-top"> <nav class="navbar navbar-expand navbar-dark bg-dark static-top">
@ -25,13 +25,18 @@
</li> </li>
</ul> </ul>
<ul class="navbar-nav ml-auto"> <ul class="navbar-nav ml-auto">
<? if (is_loggedin()): ?> <?php if (is_loggedin()): ?>
<li class="nav-item dropdown no-arrow"> <li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-user-circle fa-fw"></i> <i class="fas fa-user-circle fa-fw"></i>
</a> </a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
<a class="dropdown-item" href="<?= site_url('account/edit') ?>">Edit Profile</a> <?php if (is_admin()): ?>
<a class="dropdown-item" href="<?= site_url('admin') ?>">Admin Area</a>
<div class="dropdown-divider"></div>
<?php endif; ?>
<a class="dropdown-item <?= uri_string() === 'account' ? 'active' : '' ?>" href="<?= site_url('account') ?>">Profile</a>
<a class="dropdown-item <?= uri_string() === 'account/edit' ? 'active' : '' ?>" href="<?= site_url('account/edit') ?>">Edit Profile</a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?= site_url('account/logout') ?>">Logout</a> <a class="dropdown-item" href="<?= site_url('account/logout') ?>">Logout</a>
</div> </div>
@ -40,3 +45,20 @@
</ul> </ul>
</nav> </nav>
<div class="m-5"> <div class="m-5">
<?= $this->renderSection('content') ?>
</div>
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/assets/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="/assets/js/sb-admin.min.js"></script>
<?php if (isset($jsFiles)): ?>
<?php foreach ($jsFiles as $jsFiles): ?>
<script type="text/javascript" src="<?= $jsFile; ?>"></script>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>

32
app/Views/Templates/Blank.php

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title><?= (isset($title) ? $title : '') ?></title>
<link href="/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
<link href="/assets/css/sb-admin.min.css" rel="stylesheet">
<?php if (isset($cssFiles)): ?>
<?php foreach ($cssFiles as $cssFile): ?>
<link href="<?= $cssFile; ?>" rel="stylesheet">
<?php endforeach; ?>
<?php endif; ?>
</head>
<body>
<?= $this->renderSection('content') ?>
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/assets/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="/assets/js/sb-admin.min.js"></script>
<?php if (isset($jsFiles)): ?>
<?php foreach ($jsFiles as $jsFiles): ?>
<script type="text/javascript" src="<?= $jsFile; ?>"></script>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>

18
app/Views/Templates/Footer.php

@ -1,18 +0,0 @@
</div>
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/assets/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="/assets/js/sb-admin.min.js"></script>
<? if (isset($jsFiles)): ?>
<? foreach ($jsFiles as $jsFiles): ?>
<script type="text/javascript" src="<?= $jsFile; ?>"></script>
<? endforeach; ?>
<? endif; ?>
</body>
</html>

27
app/Views/Templates/FooterAdmin.php

@ -1,27 +0,0 @@
</div>
<footer class="sticky-footer">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright © Aauth 2018</span>
</div>
</div>
</footer>
</div>
</div>
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/assets/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="/assets/js/sb-admin.min.js"></script>
<? if (isset($jsFiles)): ?>
<? foreach ($jsFiles as $jsFiles): ?>
<script type="text/javascript" src="<?= $jsFile; ?>"></script>
<? endforeach; ?>
<? endif; ?>
</body>
</html>

12
app/Views/Templates/FooterBlank.php

@ -1,12 +0,0 @@
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/assets/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="/assets/js/sb-admin.min.js"></script>
<? if (isset($jsFiles)): ?>
<? foreach ($jsFiles as $jsFiles): ?>
<script type="text/javascript" src="<?= $jsFile; ?>"></script>
<? endforeach; ?>
<? endif; ?>
</body>
</html>

19
app/Views/Templates/HeaderBlank.php

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title><? (isset($title) ? $title : '') ?></title>
<link href="/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
<link href="/assets/css/sb-admin.min.css" rel="stylesheet">
<? if (isset($cssFiles)): ?>
<? foreach ($cssFiles as $cssFile): ?>
<link href="<?= $cssFile; ?>" rel="stylesheet">
<? endforeach; ?>
<? endif; ?>
</head>
<body>
Loading…
Cancel
Save