2017-04-17 12:49:03 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Check role
|
|
|
|
// ============================================================================
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
if ($Login->role()!=='admin') {
|
|
|
|
Alert::set($Language->g('You do not have sufficient permissions'));
|
2017-07-29 21:03:18 +02:00
|
|
|
Redirect::page('dashboard');
|
2017-04-17 12:49:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2017-07-29 21:03:18 +02:00
|
|
|
if (isset($_POST['delete'])) {
|
|
|
|
deleteCategory($_POST['categoryKey']);
|
2017-04-17 12:49:03 +02:00
|
|
|
}
|
2017-07-29 21:03:18 +02:00
|
|
|
elseif (isset($_POST['edit'])) {
|
|
|
|
editCategory($_POST['categoryKey'], $_POST['category']);
|
2017-04-17 12:49:03 +02:00
|
|
|
}
|
2017-07-29 21:03:18 +02:00
|
|
|
|
|
|
|
Redirect::page('categories');
|
2017-04-17 12:49:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
|
|
|
// ============================================================================
|
2017-04-17 13:23:43 +02:00
|
|
|
$categoryKey = $layout['parameters'];
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
if (!$dbCategories->exists($categoryKey)) {
|
2017-04-17 13:23:43 +02:00
|
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the category: '.$categoryKey);
|
2017-05-16 00:46:20 +02:00
|
|
|
Redirect::page('categories');
|
2017-04-17 12:49:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$category = $dbCategories->getName($layout['parameters']);
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
// Title of the page
|
|
|
|
$layout['title'] .= ' - '.$Language->g('Edit Category').' - '.$category;
|