61 lines
2.2 KiB
PHP
61 lines
2.2 KiB
PHP
<?php
|
|
|
|
require("./models/project_model.php");
|
|
require("./entities/project_entity.php");
|
|
require("./models/category_model.php");
|
|
require("./entities/category_entity.php");
|
|
require("./models/image_model.php");
|
|
require("./entities/image_entity.php");
|
|
require("./models/user_model.php");
|
|
require("./entities/user_entity.php");
|
|
require("mother_controller.php");
|
|
|
|
/**
|
|
* Le controller de la partie accessible uniquement par l'admin
|
|
* @author Laura
|
|
*/
|
|
|
|
class AdminCtrl extends MotherCtrl{
|
|
|
|
public function admin(){
|
|
/*accès à la page admin
|
|
if (!isset($_SESSION['user']) && ($_SESSION['user']['user_status'] != 1 )){
|
|
header("Location:index.php?ctrl=error&action=error_403");
|
|
exit;
|
|
}*/
|
|
$objCategoryModel = new CategoryModel;
|
|
|
|
if (!empty($_POST['new_category'])) {
|
|
$objNewCategory = new Category;
|
|
if (!empty($objNewCategory->getName())) {
|
|
$objNewCategory = $_POST['new_category'];
|
|
$objCategoryModel->insertCategory($objNewCategory);
|
|
header("Location:index.php?ctrl=admin&action=admin");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
if (!empty($_POST['edit_category'])) {
|
|
$objEditCategory = new Category;
|
|
if ($objEditCategory->getId() > 0) {
|
|
$objEditCategory = $_POST['edit_category'];
|
|
$objCategoryModel->editCategory($objEditCategory);
|
|
header("Location:index.php?ctrl=admin&action=admin");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$arrCategory = $objCategoryModel->findAllCategory();
|
|
$arrCategoryToDisplay = array();
|
|
|
|
foreach($arrCategory as $arrDetCategory){
|
|
$objCategory = new Category;
|
|
$objCategory->hydrate($arrDetCategory);
|
|
$arrCategoryToDisplay[] = $objCategory;
|
|
}
|
|
|
|
$this->_arrData['arrCategoryToDisplay'] = $arrCategoryToDisplay;
|
|
//$this->_arrData['intCategory'] = $objCategoryModel->;
|
|
$this->_display("admin");
|
|
}
|
|
}
|