private function logoutAction() { $oUser = UserManager::getCurrent(); if ($oUser) { UserManager::logout($oUser); } $this->homeAction(); }
/** * Convert a Comment array into a Comment object. * * @param array $aComment Comment. * * @return Comment converted object. */ private static function convertToObject($aComment) { $oComment = new Comment(); $oComment->setComment($aComment['comment']); $oComment->setMark(intval($aComment['mark'])); $oComment->setDate($aComment['date']); $oComment->setName($aComment['name']); $oUser = new User(); $oUser->setEmail($aComment['user_email']); $oComment->setUser(UserManager::get($oUser)); $oComment->setProduct(ProductManager::get($aComment['product_id'])); return $oComment; }
public function signinAction() { if (array_key_exists("connect", $_POST)) { if ($_POST["mail"] && $_POST["pwd"]) { $user = new User(null, $_POST["mail"], $_POST["pwd"], false, null, null, null, null, null, null); $userLogin = UserManager::connect($user); if ($userLogin) { $_SESSION["user"] = $userLogin; header('Location: index.php?controller=Front&method=membre'); } else { header('Location: index.php?controller=Front&method=signin&error1'); } } else { header('Location: index.php?controller=Front&method=signin&error2'); } } if (array_key_exists("error1", $_GET)) { $this->message = "Erreur d'authentification" . "<br>"; } if (array_key_exists("error2", $_GET)) { $this->message = "Champs incomplets" . "<br>"; } require 'src/Ecommerce/view/login.php'; }
private function commentAction() { $name = $_POST['name']; $comment = $_POST['comment']; $iMark = $_POST['stars']; $productId = $_POST['product-id']; $oProduct = ProductManager::get($productId); $oUser = UserManager::getCurrent(); $oComment = new Comment(); $oComment->setDate(date('Y-m-d H:i:s')); $oComment->setMark($iMark); $oComment->setName($name); $oComment->setComment($comment); $oComment->setProduct($oProduct); $oComment->setUser($oUser); try { $result = CommentManager::create($oComment); } catch (\Exception $e) { $result = $e->getMessage(); } echo $result; }
<li><a href="<?php echo $oMenuCategory->getUrl(); ?> "><span class="glyphicon glyphicon-tag"></span> <?php echo $oMenuCategory->getName(); ?> </a> </li> <?php } ?> </ul> </li> <?php if (array_key_exists('email', $_SESSION) && UserManager::getCurrent()->getRole() == 2) { ?> <li class="dropdown"> <a href="index.php?page=account&action=backoffice" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> Back office <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="index.php?page=category&action=list"><span class="glyphicon glyphicon-list"></span> Catégories </a> </li> <li><a href="index.php?page=product&action=list"><span class="glyphicon glyphicon-list"></span> Produits </a> </li> <li><a href="index.php?page=category&action=stats"><span
private function myordersAction() { $oUser = UserManager::getCurrent(); if (!$oUser) { $this->homeAction(); } $aAllOrders = OrderManager::getAllOrders($oUser); require ROOT . 'src/ecommerce/view/myorders.php'; }
private function validateAction() { $iId = intval($_GET['id']); $email = $_GET['email']; $oProduct = ProductManager::get($iId); $oUser = UserManager::getFromEmail($email); $oComment = CommentManager::get($oProduct, $oUser); $oComment = CommentManager::validate($oProduct, $oUser); }