diff --git a/app/Controllers/Account/Edit.php b/app/Controllers/Account/Edit.php
index 5d9c3ec..8287528 100644
--- a/app/Controllers/Account/Edit.php
+++ b/app/Controllers/Account/Edit.php
@@ -34,11 +34,17 @@ class Edit extends Controller
*/
public function __construct()
{
+ helper('aauth');
+
+ if (! is_loggedin())
+ {
+ return service('response')->redirect('/');
+ }
+
$this->config = new AauthConfig();
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');
- helper('aauth');
}
/**
@@ -81,8 +87,6 @@ class Edit extends Controller
$data['useUsername'] = $this->config->loginUseUsername;
- echo view('Templates/Header', $data);
echo view('Account/Edit', $data);
- echo view('Templates/Footer', $data);
}
}
diff --git a/app/Controllers/Account/Home.php b/app/Controllers/Account/Home.php
index c0dee00..7ab1d27 100644
--- a/app/Controllers/Account/Home.php
+++ b/app/Controllers/Account/Home.php
@@ -19,6 +19,7 @@ namespace App\Controllers\Account;
use CodeIgniter\Controller;
use App\Libraries\Aauth;
+use Config\Aauth as AauthConfig;
use App\Models\Aauth\UserModel;
/**
@@ -33,12 +34,13 @@ class Home extends Controller
*/
public function __construct()
{
- $this->aauth = new Aauth();
+ $this->aauth = new Aauth();
+ $this->config = new AauthConfig();
helper('aauth');
if (! $this->aauth->isLoggedIn())
{
- redirect()->to('/');
+ return service('response')->redirect('/');
}
}
@@ -51,8 +53,6 @@ class Home extends Controller
{
$data['user'] = $this->aauth->getUser();
- echo view('Templates/Header');
echo view('Account/Home', $data);
- echo view('Templates/Footer');
}
}
diff --git a/app/Controllers/Account/Login.php b/app/Controllers/Account/Login.php
index 75a8237..b992074 100644
--- a/app/Controllers/Account/Login.php
+++ b/app/Controllers/Account/Login.php
@@ -57,17 +57,20 @@ class Login extends Controller
}
else
{
- $this->response->redirect('/account');
+ $this->response->redirect(site_url('/account'));
}
}
+ if (session('errors'))
+ {
+ $data['errors'] = isset($data['errors']) ? $data['errors'] . '
' . session('errors') : session('errors');
+ }
+
$data['useUsername'] = $this->config->loginUseUsername;
$data['cssFiles'] = [
'/assets/css/login.css'
];
- echo view('Templates/HeaderBlank', $data);
echo view('Account/Login', $data);
- echo view('Templates/FooterBlank', $data);
}
}
diff --git a/app/Controllers/Account/Register.php b/app/Controllers/Account/Register.php
index 288b5d5..06ef87b 100644
--- a/app/Controllers/Account/Register.php
+++ b/app/Controllers/Account/Register.php
@@ -59,13 +59,21 @@ class Register extends Controller
}
}
+ if (session('errors'))
+ {
+ $data['errors'] = isset($data['errors']) ? $data['errors'] . '
' . session('errors') : session('errors');
+ }
+
+ if (session('infos'))
+ {
+ $data['infos'] = isset($data['infos']) ? $data['infos'] . '
' . session('infos') : session('infos');
+ }
+
$data['useUsername'] = $this->config->loginUseUsername;
$data['cssFiles'] = [
'/assets/css/login.css'
];
- echo view('Templates/HeaderBlank', $data);
echo view('Account/Register', $data);
- echo view('Templates/FooterBlank', $data);
}
}
diff --git a/app/Controllers/Account/Remind_password.php b/app/Controllers/Account/Remind_password.php
index 7fcda60..80be4bd 100644
--- a/app/Controllers/Account/Remind_password.php
+++ b/app/Controllers/Account/Remind_password.php
@@ -61,8 +61,6 @@ class Remind_password extends Controller
'/assets/css/login.css'
];
- echo view('Templates/HeaderBlank', $data);
echo view('Account/RemindPassword', $data);
- echo view('Templates/FooterBlank', $data);
}
}
diff --git a/app/Controllers/Account/Reset_password.php b/app/Controllers/Account/Reset_password.php
index 4cf2b2b..e658b21 100644
--- a/app/Controllers/Account/Reset_password.php
+++ b/app/Controllers/Account/Reset_password.php
@@ -64,8 +64,6 @@ class Reset_password extends Controller
'/assets/css/login.css'
];
- echo view('Templates/HeaderBlank', $data);
echo view('Account/ResetPassword', $data);
- echo view('Templates/FooterBlank', $data);
}
}
diff --git a/app/Controllers/Account/Verification.php b/app/Controllers/Account/Verification.php
index fdf7ca9..539aad8 100644
--- a/app/Controllers/Account/Verification.php
+++ b/app/Controllers/Account/Verification.php
@@ -64,8 +64,6 @@ class Verification extends Controller
'/assets/css/login.css'
];
- echo view('Templates/HeaderBlank', $data);
echo view('Account/Verification', $data);
- echo view('Templates/FooterBlank', $data);
}
}
diff --git a/app/Controllers/Admin/Groups.php b/app/Controllers/Admin/Groups.php
index 303484b..85bec14 100644
--- a/app/Controllers/Admin/Groups.php
+++ b/app/Controllers/Admin/Groups.php
@@ -33,10 +33,16 @@ class Groups extends Controller
*/
public function __construct()
{
+ helper('aauth');
+
+ if (! is_admin())
+ {
+ return service('response')->redirect('/');
+ }
+
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');
- helper('aauth');
}
/**
@@ -48,13 +54,12 @@ class Groups extends Controller
{
$data = $this->aauth->listGroupsPaginated();
- $data['cssFiles'] = [
+ $data['pagerLinks'] = $data['pager']->links();
+ $data['cssFiles'] = [
'/assets/css/admin/groups/index.css'
];
- echo view('Templates/HeaderAdmin', $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['perms'] = $this->aauth->listPerms();
- echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/New', $data);
- echo view('Templates/FooterAdmin');
}
/**
* Create
*
- * @return void
+ * @return redirect
*/
public function create()
{
@@ -90,7 +93,7 @@ class Groups extends Controller
foreach ($subGroups as $subgroupId => $state)
{
- if ($state === 1)
+ if ((int) $state === 1)
{
$this->aauth->addSubgroup($groupId, $subgroupId);
}
@@ -98,7 +101,7 @@ class Groups extends Controller
foreach ($perms as $permId => $state)
{
- if ($state === 1)
+ if ((int) $state === 1)
{
$this->aauth->allowGroup($permId, $groupId);
}
@@ -110,63 +113,69 @@ class Groups extends Controller
/**
* Edit
*
- * @return void
+ * @param integer $groupId Group Id
+ *
+ * @return redirect|void
*/
- public function edit($groupId)
+ public function edit(int $groupId)
{
- $data['group'] = $this->aauth->getGroup($groupId);
- $data['groups'] = $this->aauth->listGroups();
- $data['perms'] = $this->aauth->listPerms();
- $data['activeGroups'] = $this->aauth->getSubgroups($groupId);
- $data['activePerms'] = $this->aauth->getGroupPerms($groupId);
+ if (! $this->aauth->getGroup($groupId))
+ {
+ return redirect()->to('/admin/groups');
+ }
+
+ $data['group'] = $this->aauth->getGroup($groupId);
+ $data['groups'] = $this->aauth->listGroupSubgroups($groupId);
+ $data['perms'] = $this->aauth->listGroupPerms($groupId);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/Edit', $data);
- echo view('Templates/FooterAdmin');
}
/**
* Update
*
- * @return void
+ * @param integer $groupId Group Id
+ *
+ * @return redirect
*/
- public function update($groupId)
+ public function update(int $groupId)
{
$name = $this->request->getPost('name');
$definition = $this->request->getPost('definition');
$subGroups = $this->request->getPost('sub_groups');
$perms = $this->request->getPost('perms');
-
if (! $this->aauth->updateGroup($groupId, empty($name) ? null : $name, empty($definition) ? null : $definition))
{
return redirect()->back()->with('errors', $this->aauth->getErrorsArray());
}
$activeSubGroups = $this->aauth->getSubgroups($groupId);
- $activePerms = $this->aauth->getGroupPerms($groupId, 1);
-
+ $activePerms = $this->aauth->getGroupPerms($groupId);
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);
}
- 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);
}
}
-
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);
}
- 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);
}
+ 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);
@@ -175,35 +184,39 @@ class Groups extends Controller
/**
* Show
*
- * @return void
+ * @param integer $groupId Group Id
+ *
+ * @return redirect|void
*/
- public function show($groupId)
+ public function show(int $groupId)
{
- $data['group'] = $this->aauth->getGroup($groupId);
- $data['groups'] = $this->aauth->listGroups();
- $data['perms'] = $this->aauth->listPerms();
- $data['activeGroups'] = $this->aauth->getSubgroups($groupId);
- $data['activePerms'] = $this->aauth->getGroupPerms($groupId);
+ if (! $this->aauth->getGroup($groupId))
+ {
+ return redirect()->to('/admin/groups');
+ }
+
+ $data['group'] = $this->aauth->getGroup($groupId);
+ $data['groups'] = $this->aauth->listGroupSubgroups($groupId);
+ $data['perms'] = $this->aauth->listGroupPerms($groupId);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/Show', $data);
- echo view('Templates/FooterAdmin');
}
/**
* 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))
{
return redirect()->to('/admin/groups');
}
- $id = $this->request->getPost('id');
- if ($groupId === $id)
+ if ($groupId === $this->request->getPost('id'))
{
if ($this->aauth->deleteGroup($groupId))
{
@@ -211,15 +224,11 @@ class Groups extends Controller
}
}
- $data['group'] = $this->aauth->getGroup($groupId);
- $data['groups'] = $this->aauth->listGroups();
- $data['perms'] = $this->aauth->listPerms();
- $data['activeGroups'] = $this->aauth->getSubgroups($groupId);
- $data['activePerms'] = $this->aauth->getGroupPerms($groupId);
+ $data['group'] = $this->aauth->getGroup($groupId);
+ $data['groups'] = $this->aauth->listGroupSubgroups($groupId);
+ $data['perms'] = $this->aauth->listGroupPerms($groupId);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Groups/Delete', $data);
- echo view('Templates/FooterAdmin');
}
}
diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php
index 3edd27f..bd78419 100644
--- a/app/Controllers/Admin/Home.php
+++ b/app/Controllers/Admin/Home.php
@@ -29,13 +29,17 @@ class Home extends Controller
/**
* Index
*
- * @return void
+ * @return void|redirect
*/
public function index()
{
helper('aauth');
- echo view('Templates/HeaderAdmin');
+
+ if (! is_admin())
+ {
+ return service('response')->redirect('/');
+ }
+
echo view('Admin/Home');
- echo view('Templates/FooterAdmin');
}
}
diff --git a/app/Controllers/Admin/Migrate.php b/app/Controllers/Admin/Migrate.php
index d31f5a7..96c100a 100644
--- a/app/Controllers/Admin/Migrate.php
+++ b/app/Controllers/Admin/Migrate.php
@@ -34,20 +34,18 @@ class Migrate extends Controller
public function index()
{
helper('aauth');
+
$config = new \Config\Aauth();
$migrate = \Config\Services::migrations();
+ $db = \Config\Database::connect();
try
{
- $migrated = $migrate->latest('App', $config->dbProfile);
+ $migrate->latest('App', $config->dbProfile);
}
catch (\Exception $e)
{
- // Do something with the error here...
+ echo $e->getMessage();
}
-
- echo view('Templates/Header');
- echo view('Admin/Migrate');
- echo view('Templates/Footer');
}
}
diff --git a/app/Controllers/Admin/Perms.php b/app/Controllers/Admin/Perms.php
index 33f22cb..bca7cf7 100644
--- a/app/Controllers/Admin/Perms.php
+++ b/app/Controllers/Admin/Perms.php
@@ -33,10 +33,16 @@ class Perms extends Controller
*/
public function __construct()
{
+ helper('aauth');
+
+ if (! is_admin())
+ {
+ return service('response')->redirect('/');
+ }
+
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');
- helper('aauth');
}
/**
@@ -48,13 +54,12 @@ class Perms extends Controller
{
$data = $this->aauth->listPermsPaginated();
- $data['cssFiles'] = [
+ $data['pagerLinks'] = $data['pager']->links();
+ $data['cssFiles'] = [
'/assets/css/admin/perms/index.css'
];
- echo view('Templates/HeaderAdmin', $data);
echo view('Admin/Perms/Home', $data);
- echo view('Templates/FooterAdmin');
}
/**
@@ -64,15 +69,13 @@ class Perms extends Controller
*/
public function new()
{
- echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/New');
- echo view('Templates/FooterAdmin');
}
/**
* Create
*
- * @return void
+ * @return redirect
*/
public function create()
{
@@ -90,23 +93,30 @@ class Perms extends Controller
/**
* 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);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/Edit', $data);
- echo view('Templates/FooterAdmin');
}
/**
* Update
*
- * @return void
+ * @param integer $permId Perm Id
+ *
+ * @return redirect
*/
- public function update($permId)
+ public function update(int $permId)
{
$name = $this->request->getPost('name');
$definition = $this->request->getPost('definition');
@@ -122,31 +132,37 @@ class Perms extends Controller
/**
* 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);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/Show', $data);
- echo view('Templates/FooterAdmin');
}
/**
* 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))
{
return redirect()->to('/admin/perms');
}
- $id = $this->request->getPost('id');
- if ($permId === $id)
+ if ($permId === $this->request->getPost('id'))
{
if ($this->aauth->deletePerm($permId))
{
@@ -156,9 +172,7 @@ class Perms extends Controller
$data['perm'] = $this->aauth->getPerm($permId);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Perms/Delete', $data);
- echo view('Templates/FooterAdmin');
}
}
diff --git a/app/Controllers/Admin/Users.php b/app/Controllers/Admin/Users.php
index 5068e80..c18032c 100644
--- a/app/Controllers/Admin/Users.php
+++ b/app/Controllers/Admin/Users.php
@@ -34,11 +34,17 @@ class Users extends Controller
*/
public function __construct()
{
- $this->config = new AauthConfig();
+ helper('aauth');
+
+ if (! is_admin())
+ {
+ return service('response')->redirect('/');
+ }
+
$this->aauth = new Aauth();
+ $this->config = new AauthConfig();
$this->request = Services::request();
helper('form');
- helper('aauth');
}
/**
@@ -50,13 +56,12 @@ class Users extends Controller
{
$data = $this->aauth->listUsersPaginated();
- $data['cssFiles'] = [
+ $data['pagerLinks'] = $data['pager']->links();
+ $data['cssFiles'] = [
'/assets/css/admin/users/index.css'
];
- echo view('Templates/HeaderAdmin', $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['perms'] = $this->aauth->listPerms();
- echo view('Templates/HeaderAdmin');
echo view('Admin/Users/New', $data);
- echo view('Templates/FooterAdmin');
}
/**
* Create
*
- * @return void
+ * @return redirect
*/
public function create()
{
@@ -97,26 +100,33 @@ class Users extends Controller
/**
* 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['user'] = $this->aauth->getUser($userId);
- $data['groups'] = $this->aauth->listGroups();
- $data['perms'] = $this->aauth->listPerms();
+ $data['groups'] = $this->aauth->listUserGroups($userId);
+ $data['perms'] = $this->aauth->listUserPerms($userId);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Users/Edit', $data);
- echo view('Templates/FooterAdmin');
}
/**
* Update
*
- * @return void
+ * @param integer $userId User Id
+ *
+ * @return redirect
*/
- public function update($userId)
+ public function update(int $userId)
{
$email = $this->request->getPost('email');
$username = $this->request->getPost('username');
@@ -139,11 +149,11 @@ class Users extends Controller
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);
}
- 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);
}
@@ -151,11 +161,11 @@ class Users extends Controller
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);
}
- 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);
}
@@ -167,33 +177,39 @@ class Users extends Controller
/**
* 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['groups'] = $this->aauth->listGroups();
- $data['perms'] = $this->aauth->listPerms();
+ $data['groups'] = $this->aauth->listUserGroups($userId);
+ $data['perms'] = $this->aauth->listUserPerms($userId);
- echo view('Templates/HeaderAdmin');
echo view('Admin/Users/Show', $data);
- echo view('Templates/FooterAdmin');
}
/**
* 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))
{
return redirect()->to('/admin/users');
}
- $id = $this->request->getPost('id');
- if ($userId === $id)
+ if ($userId === $this->request->getPost('id'))
{
if ($this->aauth->deleteUser($userId))
{
@@ -205,9 +221,7 @@ class Users extends Controller
$data['groups'] = $this->aauth->listGroups();
$data['perms'] = $this->aauth->listPerms();
- echo view('Templates/HeaderAdmin');
echo view('Admin/Users/Delete', $data);
- echo view('Templates/FooterAdmin');
}
}
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index 1331b28..ef561a0 100644
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -34,8 +34,7 @@ class Home extends Controller
public function index()
{
helper('aauth');
- echo view('Templates/Header');
+
echo view('Home');
- echo view('Templates/Footer');
}
}
diff --git a/app/Views/Account/Edit.php b/app/Views/Account/Edit.php
index fe13d4e..590c3a0 100644
--- a/app/Views/Account/Edit.php
+++ b/app/Views/Account/Edit.php
@@ -1,32 +1,36 @@
-
* =lang('Account.registerRequired')?>
- - = form_close() ?> -* =lang('Account.registerRequired')?>
+ + = form_close() ?> +=lang('Account.remindPasswordText')?>
- -