public static function post() { //Redirect to manageuser page if back to results button was clicked if (isset($_POST['back_to_search_results'])) { header('Location: manageuser', true, 303); } elseif (isset($_POST['cancel'])) { EditUserController::get(); } elseif (isset($_POST['edit'])) { $page = new Page(); $page->data['title'] = 'Gebruiker bewerken'; EditUserController::buildEditUserTopView($page, true, false); if ($_SESSION['Stippers']['user']->isAdmin) { EditUserController::buildEditUserAdminView($page, true, false); } if ($_SESSION['Stippers']['user']->isAdmin || $_SESSION['Stippers']['user']->isMoneyManager) { EditUserController::buildEditUserMoneyManagerView($page); } $page->addView('editUser/EditUserEnabledFormBottomView'); EditUserController::buildMembershipDetailsView($page); $page->showWithMenu(); } else { $page = new Page(); $page->data['title'] = 'Gebruiker bewerken'; $errMsgs = EditUserTopViewValidator::validate($_POST); if (empty($errMsgs)) { //If no error: create a new user from posted data and try to save it $newUser = EditUserController::createUserFromPost(); try { UserDB::updateUser($_SESSION['Stippers']['EditUser']['user'], $newUser); $page->data['SuccessMessageNoDescriptionWithLinkView']['successTitle'] = 'Gebruiker succesvol bijgewerkt'; $page->data['SuccessMessageNoDescriptionWithLinkView']['redirectUrl'] = $_SERVER['REQUEST_URI']; $page->addView('success/SuccessMessageNoDescriptionWithLinkView'); } catch (UserDBException $ex) { //Show correct error message for errors if ($ex->getCode() == UserDBException::USEROUTOFDATE) { $page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Gebruiker niet bijgewerkt'; $page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Iemand anders heeft de gebruiker in tussentijd al gewijzigd.'; $page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI']; $page->addView('error/ErrorMessageWithDescriptionWithLinkView'); } else { EditUserController::buildEditUserTopView($page, true, true); if ($ex->getCode() == UserDBException::EMAILALREADYEXISTS) { $page->data['EditUserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="edit_user_form_error_message">Dit e-mailadres is al in gebruik.</h2>'; } else { $page->data['EditUserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="edit_user_form_error_message">Kan gebruiker niet bijwerken, probeer het opnieuw.</h2>'; } EditUserController::buildMembershipDetailsView($page); if ($_SESSION['Stippers']['user']->isAdmin) { EditUserController::buildEditUserAdminView($page, true, true); } if ($_SESSION['Stippers']['user']->isAdmin || $_SESSION['Stippers']['user']->isMoneyManager) { EditUserController::buildEditUserMoneyManagerView($page); } $page->addView('editUser/EditUserEnabledFormBottomView'); } } catch (Exception $ex) { EditUserController::buildEditUserTopView($page, true, true); if ($ex->getCode() == UserDBException::EMAILALREADYEXISTS) { $page->data['EditUserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="edit_user_form_error_message">Dit e-mailadres is al in gebruik.</h2>'; } else { $page->data['EditUserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="edit_user_form_error_message">Kan gebruiker niet bijwerken, probeer het opnieuw.</h2>'; } EditUserController::buildMembershipDetailsView($page); if ($_SESSION['Stippers']['user']->isAdmin) { EditUserController::buildEditUserAdminView($page, true, true); } if ($_SESSION['Stippers']['user']->isAdmin || $_SESSION['Stippers']['user']->isMoneyManager) { EditUserController::buildEditUserMoneyManagerView($page); } $page->addView('editUser/EditUserEnabledFormBottomView'); } } else { //If we had an error we show the views with enabled controls and take data from POST EditUserController::buildEditUserTopView($page, true, true); $page->data['EditUserTopView']['errMsgs'] = array_merge($page->data['EditUserTopView']['errMsgs'], $errMsgs); EditUserController::buildMembershipDetailsView($page); if ($_SESSION['Stippers']['user']->isAdmin) { EditUserController::buildEditUserAdminView($page, true, true); } if ($_SESSION['Stippers']['user']->isAdmin || $_SESSION['Stippers']['user']->isMoneyManager) { EditUserController::buildEditUserMoneyManagerView($page); } $page->addView('editUser/EditUserEnabledFormBottomView'); } $page->showWithMenu(); } }
<?php include_once dirname(__FILE__) . "/edit_user.controller.php"; $controller = new EditUserController(); $vd = $controller->Execute(); print '<?xml version="1.0" encoding="UTF-8"?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="style.css?v=<?php print DOMA_VERSION; ?> " type="text/css" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title><?php print _SITE_TITLE . " :: " . $vd["Title"]; ?> </title> <link rel="icon" type="image/png" href="gfx/favicon.png" /> <script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="js/edit_user.js?v=<?php print DOMA_VERSION; ?> "></script> <script src="js/common.js?v=<?php print DOMA_VERSION; ?> " type="text/javascript"></script> </head>
* * This page calls the Edit User Controller * * Copyright (c) 2012 OWASP * * LICENSE: * * This file is part of Hackademic CMS (https://www.owasp.org/index.php/OWASP_Hackademic_Challenges_Project). * * Hackademic CMS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any * later version. * * Hackademic CMS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with Hackademic CMS. If not, see * <http://www.gnu.org/licenses/>. * * * @author Pragya Gupta <pragya18nsit[at]gmail[dot]com> * @author Konstantinos Papapanagiotou <conpap[at]gmail[dot]com> * @license http://www.gnu.org/licenses/gpl.html * @copyright 2012 OWASP * */ require_once "../../init.php"; require_once HACKADEMIC_PATH . "admin/controller/class.EditUserController.php"; $controller = new EditUserController(); echo $controller->go();