aboutsummaryrefslogtreecommitdiffstats
path: root/admin/user
diff options
context:
space:
mode:
Diffstat (limited to 'admin/user')
-rw-r--r--admin/user/delete.php44
-rw-r--r--admin/user/index.php68
-rw-r--r--admin/user/insert.php44
-rw-r--r--admin/user/update.php45
4 files changed, 80 insertions, 121 deletions
diff --git a/admin/user/delete.php b/admin/user/delete.php
index 16f0d76..18a57cf 100644
--- a/admin/user/delete.php
+++ b/admin/user/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('HTML', $User->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('user/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('user/form');
+ $FormTemplate->set('HTML', $User->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('user/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_user_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -63,4 +54,3 @@ try {
catch(User\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/user/index.php b/admin/user/index.php
index dc5a4e7..8276d91 100644
--- a/admin/user/index.php
+++ b/admin/user/index.php
@@ -13,8 +13,8 @@ require '../../core/application.php';
#===============================================================================
# Pagination
#===============================================================================
-$site_size = Application::get('POST.LIST_SIZE');
-$site_sort = Application::get('POST.LIST_SORT');
+$site_size = Application::get('ADMIN.POST.LIST_SIZE');
+$site_sort = Application::get('ADMIN.POST.LIST_SORT');
$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', User\Attribute::TABLE))->fetchColumn() / $site_size);
@@ -31,45 +31,35 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$Statement = $Database->query(sprintf($execSQL, User\Attribute::TABLE));
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- while($Attribute = $Statement->fetchObject('User\Attribute')) {
- try {
- $User = User\Factory::buildByAttribute($Attribute);
- $ItemTemplate = generateUserItemTemplate($User);
-
- $users[] = $ItemTemplate;
- } catch(User\Exception $Exception){}
- }
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('user/?site=%d'));
-
- $ListTemplate = Template\Factory::build('user/index');
- $ListTemplate->set('LIST', [
- 'USERS' => $users ?? []
- ]);
+while($Attribute = $Statement->fetchObject('User\Attribute')) {
+ try {
+ $User = User\Factory::buildByAttribute($Attribute);
+ $ItemTemplate = generateUserItemTemplate($User);
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ $users[] = $ItemTemplate;
+ } catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('user/?site=%d'));
+
+$ListTemplate = Template\Factory::build('user/index');
+$ListTemplate->set('LIST', [
+ 'USERS' => $users ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_user_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/user/insert.php b/admin/user/insert.php
index 53d35df..59b9444 100644
--- a/admin/user/insert.php
+++ b/admin/user/insert.php
@@ -40,30 +40,20 @@ if(HTTP::issetPOST('id', 'slug', 'username', 'password', 'fullname', 'mailaddr',
}
#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $InsertTemplate = Template\Factory::build('user/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+# Build document
+#===============================================================================
+$FormTemplate = Template\Factory::build('user/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('user/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_user_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/user/update.php b/admin/user/update.php
index becfdc5..b9b5f08 100644
--- a/admin/user/update.php
+++ b/admin/user/update.php
@@ -30,8 +30,7 @@ try {
if(HTTP::issetPOST(['token' => Application::getSecurityToken()])) {
try {
- if($Attribute->databaseUPDATE($Database)) {
- }
+ $Attribute->databaseUPDATE($Database);
} catch(PDOException $Exception) {
$messages[] = $Exception->getMessage();
}
@@ -42,33 +41,24 @@ try {
}
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ #===============================================================================
+ # Build document
+ #===============================================================================
+ $FormTemplate = Template\Factory::build('user/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
- $InsertTemplate = Template\Factory::build('user/update');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_update'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
- }
+ $InsertTemplate = Template\Factory::build('user/update');
+ $InsertTemplate->set('HTML', $FormTemplate);
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_user_update'));
+ $MainTemplate->set('HTML', $InsertTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -77,4 +67,3 @@ try {
catch(User\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file