public static function run() { $sessao = new TSessao(true); include 'util/Validacao.php'; $flashes = null; $usuario = $sessao->getVar('usuario'); include 'app.functions/validate.php'; $valida = validate($usuario); //include 'relatorios/teste.php'; if ($valida) { if ($usuario) { $menu = new TMenu($usuario->permissoes, array('gerenciar')); TApplication::setStyle('menu'); TApplication::setStyle('controler_bar'); } if (!$_GET) { if ($usuario == null) { require "app.comuns/app.control/login.php"; TApplication::setStyle('login'); $templatePage = "app.comuns/template/login.phtml"; } else { if ($sessao->getVar('msg1') != null) { if ($sessao->getVar('msg1') == 5) { Flash::addFlash('Você não tem permissão!'); $flashes = Flash::getFlashes(); $sessao->removeVar('msg1'); } } $templatePage = "app.comuns/template/panel.phtml"; } } else { $modulo = isset($_GET['modulo']) ? $_GET['modulo'] : null; $page = isset($_GET['page']) ? $_GET['page'] : null; if (file_exists("modulos/{$modulo}/app.control/{$page}.php")) { require "modulos/{$modulo}/app.control/{$page}.php"; } if (file_exists("modulos/{$modulo}/template/{$page}.phtml")) { $templatePage = "modulos/{$modulo}/template/{$page}.phtml"; } } if (isset($validacao)) { if ($validacao !== true) { $erros = $validacao; } } if (Flash::hasFlashes()) { $flashes = Flash::getFlashes(); } if (!isset($_GET['ajax'])) { TApplication::setStyle('style'); TApplication::setStyle('principal'); TApplication::setStyle('redmond/jquery-ui-1.8.16.custom'); require 'layout/index.phtml'; } } else { header('location: index.php'); } }
<?php $id = $_GET['key']; $usuario = Utils::findById($id, 'usuarios', 'id_usuario'); $itens = EmpMapper::getEmps($id); if ($sessao->getVar('msg') != null) { if ($sessao->getVar('msg') == 1) { Flash::addFlash('Empréstimo concluído.'); $sessao->removeVar('msg'); } }
$foodOrder->setEmail($email); $foodOrder->setProductId($product_id); //set default status $foodOrder->setStatus('PENDING'); //$foodOrder -> setPickupTime($pickup_time); $foodOrder->setDate(date("Y-m-d H:i:s")); $status = ''; if (isset($_POST['food_order']['status'])) { $status = filter_var($_POST['food_order']['status'], FILTER_SANITIZE_STRING); } else { $status = 'PENDING'; } $data = array('product_id' => $_POST['food_order']['order_list'], 'user_id' => 1, 'full_name' => 'Bob Smith', 'email' => '*****@*****.**', 'phone_number' => '0278839406', 'date' => date("Y-m-d H:i:s"), 'status' => $status); // var_dump($_POST); // die(); // map FoodOrderMapper::map($foodOrder, $data); // validate // $errors = FoodOrderValidator::validate($foodOrder); // if (empty($errors)) { // save $dao = new FoodOrderDao(); $foodOrder = $dao->save($foodOrder); Flash::addFlash('Thank you for ordering with us.'); // redirect Utils::redirect('home'); // } } $productDao = new ProductDao(); $product_id = Utils::getUrlParam('product_id'); $products = $productDao->find();
// private $createdBy; // private $modifiedBy; // private $description; // private $nameOfRestaurant; // private $overallRating; // private $restaurant_id; // private $username; // private $status = self::PENDING; $blogPostData = array('content' => $_POST['content'], 'date' => $_POST['date'] . ' 00:00:00', 'created_by' => 'char', 'modified_by' => 'char', 'description' => $_POST['content'], 'restaurant_id' => '44', 'status' => 'pending', 'modified_date' => $_POST['date'] . ' 00:00:00'); $blogRestaurantData = array('name_of_restaurant' => $_POST['name_of_restaurant'], 'overall_rating' => $_POST['overall_rating']); $blogChipData = array('chip_colour' => $_POST['chip_colour'], 'chip_crunch' => $_POST['chip_crunch'], 'chip_condiments' => $_POST['chip_condiments'], 'chip_consistency' => $_POST['chip_consistency'], 'chip_cash' => $_POST['chip_cash'], 'chip_charisma' => $_POST['chip_charisma']); // map BlogPostMapper::simpleMap($blogPost, $blogPostData); BlogRestaurantMapper::map($blogRestaurant, $blogRestaurantData); BlogChipMapper::map($blogChip, $blogChipData); // validate $errors = BlogPostValidator::validate($blogPost); $errors = BlogRestaurantValidator::validate($blogRestaurant); if (empty($errors)) { // save $blogPostDao = new BlogPostDao(); $blogRestaurantDao = new BlogRestaurantDao(); $blogChipDao = new BlogChipDao(); $blogPost = $blogPostDao->save($blogPost); $blogRestaurant = $blogRestaurantDao->save($blogRestaurant); $blogChip = $blogChipDao->save($blogChip); Flash::addFlash('Thanks for the review Chipper!'); // redirect Utils::redirect('list', array('status' => 'pending')); } }
if (array_key_exists('key', $_GET)) { $id = $_GET['key']; $requisicoes = Utils::findById($id, 'req_manutencao', 'id_requisicao'); if ($requisicoes['requisitante_id'] != $sessao->getVar('usuario')->id_usuario) { $sessao->addVar('msg', 3); header('location:index.php?modulo=manutencoes&page=visualizar'); } } if (array_key_exists('save', $_POST)) { $dados = array('dt_requisicao' => array('Data Atual', 'tipo' => 'data'), 'equipamento_requisicao' => array('Equipamento'), 'local_equipamento' => array('Localização'), 'defeito_requisicao' => array('Defeito')); $validacao = ValidaFormulario($dados); if ($validacao === true) { $data = array('dt_requisicao' => $_POST['dt_requisicao'], 'equipamento_requisicao' => $_POST['equipamento_requisicao'], 'local_equipamento' => $_POST['local_equipamento'], 'defeito_requisicao' => $_POST['defeito_requisicao'], 'requisitante_id' => $sessao->getVar('usuario')->id_usuario, 'estado_id' => '1'); $requisicao = new Requerir(); RequerirMapper::map($requisicao, $data); RequerirMapper::RequisicaoInsert($requisicao); $sessao->addVar('msg', 1); header('location:index.php?modulo=manutencoes&page=visualizar'); } else { Flash::addFlash($validacao); } } if (array_key_exists('update', $_POST)) { $data = array('dt_requisicao' => $_POST['dt_requisicao'], 'equipamento_requisicao' => $_POST['equipamento_requisicao'], 'local_equipamento' => $_POST['local_equipamento'], 'defeito_requisicao' => $_POST['defeito_requisicao'], 'requisitante_id' => $sessao->getVar('usuario')->id_usuario, 'estado_id' => '1'); $requisicao = new Requerir(); $requisicao->setIdRequisicao($id); RequerirMapper::map($requisicao, $data); RequerirMapper::RequisicaoUpdate($requisicao); $sessao->addVar('msg', 2); header('location:index.php?modulo=manutencoes&page=visualizar'); }
<?php $user_id = $_POST['user']['id']; $user_obj = null; $updatedUser_obj = null; $user_obj = new User(); $updatedUser_obj = new User(); if (array_key_exists('find', $_POST)) { $data = array('id' => $_POST['user']['id']); UserMapper::map($user_obj, $data); $dao = new UserDao(); $foundUser = $dao->findById($user_id); } if (array_key_exists('update', $_POST)) { $data = array('id' => $_POST['user']['id'], 'first_name' => $_POST['user']['first_name'], 'user_password' => $_POST['user']['user_password']); UserMapper::map($updatedUser_obj, $data); $dao = new UserDao(); $dao->update($updatedUser_obj); Flash::addFlash('user record(s) updated successfully :)'); }
<?php $criteria = new SearchCriteria(); if (array_key_exists('busca', $_POST)) { $criteria->setValueCriteria($_POST['CampoBusca']); } $usuarios = UsuarioMapper::getUsuarios($criteria); $sessao->addVar('usuarios', $usuarios); if (array_key_exists('empCancel', $_GET)) { $sessao->removeVar('mat'); } if ($sessao->getVar('msg') != null) { if ($sessao->getVar('msg') == 1) { Flash::addFlash('Usuário alterado.'); } elseif ($sessao->getVar('msg') == 2) { Flash::addFlash('Permissão alterada.'); } elseif ($sessao->getVar('msg') == 3) { Flash::addFlash('Empréstimo salvo com sucesso.'); } elseif ($sessao->getVar('msg') == 4) { Flash::addFlash("Usuário excluído"); } $sessao->removeVar('msg'); }
* particular file as subject to the "Classpath" exception as provided * by Oracle in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): * * Portions Copyrighted 2011 Sun Microsystems, Inc. */ $todo = Utils::getTodoByGetId(); $todo->setStatus(Utils::getUrlParam('status')); if (array_key_exists('comment', $_POST)) { $todo->setComment($_POST['comment']); } $dao = new TodoDao(); $dao->save($todo); Flash::addFlash('TODO status changed successfully.'); Utils::redirect('detail', array('id' => $todo->getId()));
<?php if (isset($_GET['item_id'])) { $dao = new MerchandiseDao(); $item_id = Utils::getUrlParam('item_id'); $merchandise = $dao->delete($item_id); Flash::addFlash('Item deleted successfully.'); // redirect Utils::redirect('home'); } else { Flash::addFlash("Cannot delete item."); }
// redirect Utils::redirect('list'); } elseif (array_key_exists('save', $_POST)) { // for security reasons, do not map the whole $_POST['todo'] //pretending to have values in $_POST //$data = array('first_name' => 'Bob', 'no_of_passengers' => 2); // private $id; // private $date; // private $content; // private $createdBy; // private $modifiedBy; // private $description; // private $nameOfRestaurant; // private $overallRating; // private $restaurant_id; // private $username; // private $status = self::PENDING; $data = array('username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_POST['password']); // map BlogMemberMapper::map($blogMember, $data); // validate $errors = BlogMemberValidator::validate($blogMember); if (empty($errors)) { // save $blogMemberDao = new BlogMemberDao(); $blogMember = $blogMemberDao->save($blogMember); Flash::addFlash('Thanks for Registering Chipper!'); // redirect Utils::redirect('list', array('status' => 'pending')); } }
//$flightBooking->setPriority(Todo::PRIORITY_MEDIUM); //$dueOn = new DateTime("+1 day"); //$dueOn->setTime(0, 0, 0); //$flightBooking->setDueOn($dueOn); } if (array_key_exists('cancel', $_POST)) { // redirect Utils::redirect('home'); } elseif (array_key_exists('enter', $_POST)) { // for security reasons, do not map the whole $_POST['todo'] //pretending to have values in $_POST $data = array('username' => 'char', 'password' => 'test', 'email' => '*****@*****.**'); // $data = array( // 'member_id'=> $_POST ['member_id'], // 'username' => $_POST ['username'], // 'password' => $_POST ['password'], // 'email' => $_POST ['email'] // ); // map BlogMemberMapper::map($blogMember, $data); // validate $errors = BlogMemberValidator::validate($blogMember); if (empty($errors)) { // save $blogMemberDao = new BlogMemberDao(); $blogMember = $blogMemberDao->enter($blogMember); Flash::addFlash('Login Succesful!'); // redirect Utils::redirect('list', array('status' => 'pending')); } }
<?php if (isset($_POST['val'])) { $itens = SolMapper::getItens($_POST['val']); echo json_encode($itens); } $criteria = new SearchCriteria(); if (array_key_exists('busca', $_POST)) { $criteria->setValueCriteria($_POST['CampoBusca']); } $solicitacoes = SolMapper::getSolicitacoes($criteria); if ($sessao->getVar('msg') != null) { if ($sessao->getVar('msg') == '2') { Flash::addFlash('Solicitação excluida!'); } if ($sessao->getVar('msg') == '3') { Flash::addFlash('Solicitação registrada!'); } $sessao->removeVar('msg'); }
$merchandise = null; $errors = array(); $id_error = ''; //check if edit $edit = array_key_exists('item_id', $_GET); if ($edit) { $merchandise = Utils::getMerchandiseByGetId(); } else { // set defaults $merchandise = new Merchandise(); } //Breaking dry principle, but can be fixed //netbeans wouldnt work until I added the backslash, not 100% if correct if (array_key_exists('cancel', $_POST)) { } elseif (array_key_exists('save', $_POST)) { $data = array('item_name' => filter_var($_POST['merchandise']['item_name'], FILTER_SANITIZE_STRING), 'item_price' => filter_var($_POST['merchandise']['item_price'], FILTER_SANITIZE_NUMBER_FLOAT), 'original_url' => filter_var($_POST['merchandise']['original_url'], FILTER_SANITIZE_URL), 'img_url' => filter_var($_POST['merchandise']['img_url'], FILTER_SANITIZE_STRING), 'company_id' => filter_var($_POST['merchandise']['company_id'], FILTER_SANITIZE_NUMBER_INT)); // map MerchandiseMapper::map($merchandise, $data); // validate // Couldnt get the company id validation to work after 5 hours, hopefully it doesnt affect my pass grade. $errors = MerchandiseValidator::validate($merchandise); if (empty($errors)) { // save $dao = new MerchandiseDao(); $merchandise = $dao->save($merchandise); Flash::addFlash('Item saved successfully.'); // redirect Utils::redirect('home'); } }
} } } if (array_key_exists('del', $_GET)) { $sessao->delArray('matSol', $_GET['nome']); header('location:index.php?modulo=solicitacoes&page=gerar&items=1&add-mat=1'); } if (array_key_exists('save-aquisicao', $_GET)) { $dados = $sessao->getVar('infos'); $sol = new Sol(); $sol->setRequisitanteId($sessao->getVar('usuario')->id_usuario); SolMapper::map($sol, $dados); $data = explode(' ', $dados['dt_aquisicao_inicial']); $date_inicial = Utils::conv_data_to_us($data[0]); $sol->setDtAquisicaoInicial($date_inicial . ' ' . $data[1]); if ($sessao->getVar('matSol') != null) { foreach ($sessao->getVar('matSol') as $item) { $itemObject = new ItemSol(); ItemSolMapper::map($itemObject, $item); $sol->addItens($itemObject); } SolMapper::insert($sol); $sessao->removeVar('matSol'); $sessao->addVar('msg', 3); $sessao->removeVar('infos'); header('location:index.php?modulo=solicitacoes&page=visualizar'); } else { header('location:index.php?modulo=solicitacoes&page=gerar&items=1'); Flash::addFlash('Por favor adicione um item.'); } }
<?php $errors = array(); $user = null; $edit = array_key_exists('id', $_GET); if ($edit) { $user = Utils::getUserByGetId(); } else { $user = new User(); } if (array_key_exists('cancel', $_POST)) { } elseif (array_key_exists('save', $_POST)) { $data = array('first_name' => $_POST['user']['first_name'], 'user_password' => $_POST['user']['user_password']); // map UserMapper::map($user, $data); // validate $errors = UserValidator::validate($user); // validate if (empty($errors)) { // save $dao = new UserDao(); $user = $dao->save($user); Flash::addFlash('Success sign in :)'); // redirect Utils::redirect('home'); } }
setrawcookie($_SESSION['user_id'], "USER-ID", time() + 86400 * 30, "/"); } isset($_GET['logout']) ?: ($_GET['logout'] = null); if ($_GET['logout'] == 1) { session_unset($_SESSION['user_id']); session_destroy(); Utils::redirect(home); } else { $userObj = new User(); $addressObj = new Address(); if (array_key_exists('submit', $_POST)) { $userData = array('id' => (int) $_SESSION['user_id'], 'first_name' => trim(filter_var($_POST['user']['first_name'], FILTER_SANITIZE_STRING)), 'last_name' => trim(filter_var($_POST['user']['last_name'], FILTER_SANITIZE_STRING))); $addressData = array('street_no' => trim(filter_var($_POST['address']['street_no'], FILTER_SANITIZE_NUMBER_INT)), 'street' => trim(filter_var($_POST['address']['street'], FILTER_SANITIZE_STRING)), 'suburb' => trim(filter_var($_POST['address']['suburb'], FILTER_SANITIZE_STRING)), 'city' => trim(filter_var($_POST['address']['city'], FILTER_SANITIZE_STRING)), 'post_code' => trim(filter_var($_POST['address']['post_code'], FILTER_SANITIZE_NUMBER_INT))); $addressErrors = Validator::validateCompleteAddressFields(); if (empty($addressErrors)) { Flash::addFlash('Thank you for completing your registration.'); UserMapper::map($userObj, $userData); AddressMapper::map($addressObj, $addressData); $userDao = new UserDao(); $addressDao = new AddressDao(); $userDao->completeRegistration($userObj, $addressDao->createAddress($addressObj)->getId()); } } $orderDao = new OrderDao(); $allOrders = $orderDao->readDb(); } if (isset($_POST['user']['first_name'])) { $myFirstName = trim(filter_var($_POST['user']['first_name'], FILTER_SANITIZE_STRING)); } if (isset($_POST['user']['last_name'])) { $myLastName = trim(filter_var($_POST['user']['last_name'], FILTER_SANITIZE_STRING));
$edit = array_key_exists('id', $_GET); if ($edit) { $foc = Utils::getFocByGetId(); } else { // set defaults $foc = new Foc(); $foc->setPriority(Foc::PRIORITY_MEDIUM); $dueOn = new DateTime("+1 day"); $dueOn->setTime(0, 0, 0); $foc->setDueOn($dueOn); } if (array_key_exists('cancel', $_POST)) { // redirect Utils::redirect('detail', array('id' => $foc->getId())); } elseif (array_key_exists('save', $_POST)) { // for security reasons, do not map the whole $_POST['foc'] $data = array('username' => $_POST['foc']['username'], 'firsname' => $_POST['foc']['firsname'], 'lastname' => $_POST['foc']['lastname'], 'email' => $_POST['foc']['email'], 'password' => $_POST['foc']['password']); // map FocMapper::map($foc, $data); // validate $errors = FocValidator::validate($foc); // validate if (empty($errors)) { // save $dao = new FocDao(); $foc = $dao->save($foc); Flash::addFlash('Changes saved successfully.'); // redirect Utils::redirect('detail', array('id' => $foc->getId())); } }
<?php $errors = array(); $user_obj = new User(); if (array_key_exists('add', $_POST)) { $data = array('first_name' => $_POST['user']['first_name'], 'user_password' => $_POST['user']['user_password']); UserMapper::map($user_obj, $data); $errors = UserValidator::validate($user_obj); if (empty($errors)) { $dao = new UserDao(); $dao->add($user_obj); Flash::addFlash('1 user is added to db successfully :)'); } }
<?php require 'Flash.php'; Flash::addFlash('Here is the warning message', 'warning'); Flash::addFlash('Something wrong happend because it\'s an error message', 'error'); Flash::addFlash('Yeah that\'s work fine, well played', 'success'); Flash::addFlash('In reality I hate php.', 'info'); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="css/styles.css"/> </head> <body> <?php if (Flash::hasFlashes()) { foreach (Flash::getFlashes() as $flash) { echo "<p class=\"flash " . $flash['type'] . "\">" . $flash['message'] . "</p>"; } } ?> <h1>Example of utilisation</h1> <?php $code = "<?php \n\n\t"; $code .= "// Require the Flash class \n\t"; $code .= "require 'Flash.php';\n\n\t"; $code .= "// Register flashes messages \n\t"; $code .= "Flash::addFlash('Here is the warning message', 'warning');\n\t"; $code .= "Flash::addFlash('Something wrong happend because it\\'s an error message', 'error');\n\t";
* specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): * * Portions Copyrighted 2011 Sun Microsystems, Inc. */ $todo = Utils::getTodoByGetId(); $dao = new TodoDao(); $dao->delete($todo->getId()); Flash::addFlash('TODO deleted successfully.'); Utils::redirect('list', array('status' => $todo->getStatus()));
<?php $id = $sessao->getVar('usuario')->id_usuario; $usuario = new Usuario(); if (array_key_exists('edit', $_POST)) { $dados = array('nome_usuario' => array('Nome'), 'email_usuario' => array('Email', 'tipo' => 'email'), 'telefone_usuario' => array('Telefone', 'tipo' => 'inteiro'), 'dt_nascimento_usuario' => array('Data Nascimento', 'tipo' => 'data'), 'login_usuario' => array("Login", 'tipo' => 'nome'), 'senha_usuario' => array('Senha'), 'confirma_senha' => array('Repita a Senha', 'tipo' => 'igualdade', 'compara' => 'senha_usuario', 'legenda_2' => 'Senha')); $validacao = ValidaFormulario($dados); if ($validacao === true) { $usuario->setIdUsuario($id); if ($_POST['celular_usuario'] == '') { $usuario->setCelularUsuario(null); } UsuarioMapper::map($usuario, $_POST); UsuarioMapper::update($usuario); Flash::addFlash('Usuario Alterado'); } } $row = Utils::findById($id, 'usuarios', 'id_usuario'); UsuarioMapper::map($usuario, $row);
<?php $errors = array(); $member = null; // set defaults $member = new Member(); //Breaking dry principle, but can be fixed //netbeans wouldnt work until I added the backslash, not 100% if correct if (array_key_exists('sign_up', $_POST)) { $data = array('username' => filter_var($_POST['member']['username'], FILTER_SANITIZE_STRING), 'password' => filter_var($_POST['member']['password'], FILTER_SANITIZE_STRING), 'first_name' => filter_var($_POST['member']['first_name'], FILTER_SANITIZE_STRING), 'last_name' => filter_var($_POST['member']['last_name'], FILTER_SANITIZE_STRING), 'email' => filter_var($_POST['member']['email'], FILTER_SANITIZE_EMAIL)); // map MemberMapper::map($member, $data); // validate // save $dao = new MemberDao(); $member = $dao->save($member); // put new user in session $username = filter_var($_POST['member']['username'], FILTER_SANITIZE_STRING); $password = filter_var($_POST['member']['password'], FILTER_SANITIZE_STRING); $user = $dao->findByUsername($username, $password); $_SESSION['username'] = $user->getUsername(); $_SESSION['user_id'] = $user->getUser_id(); Flash::addFlash('You can now share your thoughts on different items and will recieve our monthly heads up. Awesome!'); // redirect Utils::redirect('home'); }
<?php $foc = Utils::getFocByGetId(); $dao = new FocDao(); $dao->delete($foc->getId()); Flash::addFlash('User deleted successfully.'); Utils::redirect('list', array('status' => $foc->getStatus()));
$edit = array_key_exists('id', $_GET); if ($edit) { $todo = Utils::getTodoByGetId(); } else { // set defaults $todo = new Todo(); $todo->setPriority(Todo::PRIORITY_MEDIUM); $dueOn = new DateTime("+1 day"); $dueOn->setTime(0, 0, 0); $todo->setDueOn($dueOn); } if (array_key_exists('cancel', $_POST)) { // redirect Utils::redirect('detail', array('id' => $todo->getId())); } elseif (array_key_exists('save', $_POST)) { // for security reasons, do not map the whole $_POST['todo'] $data = array('title' => $_POST['todo']['title'], 'due_on' => $_POST['todo']['due_on_date'] . ' ' . $_POST['todo']['due_on_hour'] . ':' . $_POST['todo']['due_on_minute'] . ':00', 'priority' => $_POST['todo']['priority'], 'description' => $_POST['todo']['description'], 'comment' => $_POST['todo']['comment']); // map TodoMapper::map($todo, $data); // validate $errors = TodoValidator::validate($todo); // validate if (empty($errors)) { // save $dao = new TodoDao(); $todo = $dao->save($todo); Flash::addFlash('TODO saved successfully.'); // redirect Utils::redirect('detail', array('id' => $todo->getId())); } }
$flightBooking = Utils::getFlightBookingByGetId(); } else { // set defaults $flightBooking = new FlightBooking(); //$flightBooking->setPriority(Todo::PRIORITY_MEDIUM); //$dueOn = new DateTime("+1 day"); //$dueOn->setTime(0, 0, 0); //$flightBooking->setDueOn($dueOn); } if (array_key_exists('cancel', $_POST)) { // redirect //Utils::redirect('detail', array('id' => $flightBooking->getId())); } elseif (array_key_exists('save', $_POST)) { // for security reasons, do not map the whole $_POST['todo'] //pretending to have values in $_POST // $data = array('first_name' => 'Mary', 'no_of_passengers' => 4); $data = array('first_name' => $_POST['flight_booking']['first_name'], 'no_of_passengers' => $_POST['flight_booking']['no_of_passengers'], 'last_name' => $_POST['flight_booking']['last_name'], 'flight_date' => $_POST['flight_booking']['flight_date']); // map FlightBookingMapper::map($flightBooking, $data); // validate $errors = FlightBookingValidator::validate($flightBooking); // validate if (empty($errors)) { // save $dao = new FlightBookingDao(); $flightBooking = $dao->save($flightBooking); Flash::addFlash('Success Booking :)'); // redirect Utils::redirect('home'); } }
} if ($sessao->getVar('msg') == '2') { Flash::addFlash('Requisição alterada!'); } if ($sessao->getVar('msg') == '3') { Flash::addFlash('Você não pode editar/deletar requisições de outros usuários!'); } if ($sessao->getVar('msg') == '4') { Flash::addFlash('Requisição excluída.'); } $sessao->removeVar('msg'); } if (array_key_exists('key', $_GET)) { if ($sessao->getVar('msg') != null) { if ($sessao->getVar('msg') == '2') { Flash::addFlash('Requisição alterada!'); } $sessao->removeVar('msg'); } $page = 'requerir-detail'; $id = $_GET['key']; $requisicao = RequerirMapper::getRequisicaoByIdRequisicao($id); $sessao->addVar('estado', $requisicao->estado_id); if ($requisicao->estado_id == 3) { $data = array('req_manutencao_id' => $id); $manu = new Manu(); ManuMapper::map($manu, $data); $manutencao = ManuMapper::getManuByRequisicao($manu); } if (array_key_exists('m-manu', $_GET)) { $PageVoltarLista = 'm-manutencoes';
<?php //functionality of status change when delete item. //status of list //$status = Utils::getUrlParam('status'); //command $cmd = Utils::getUrlParam('cmd'); $foodOrder = Utils::getFoodOrderByGetId(); $foodOrder->setStatus($cmd); //if (array_key_exists('comment', $_POST)) { // $todo->setComment($_POST['comment']); //} $dao = new FoodOrderDao(); $dao->save($foodOrder); $msg = ''; //if($cmd === FoodOrder::VOIDED){ $msg = 'Food Order deleted successfully.'; //} //else{ // $msg = 'Food Order status changed successfully.'; //} Flash::addFlash($msg); Utils::redirect('list'); //array('status' => $status)
<?php $user_id = $_POST['user']['id']; $user_obj = null; $user_obj = new User(); if (array_key_exists('delete', $_POST)) { $data = array('id' => $_POST['user']['id']); UserMapper::map($user_obj, $data); $dao = new UserDao(); $dao->delete($user_id); Flash::addFlash('Record' . $user_id . ' deleted successfully :)'); }
<?php //status of list $status = Utils::getUrlParam('status'); //command $cmd = Utils::getUrlParam('cmd'); $flightBooking = Utils::getFlightBookingByGetId(); $flightBooking->setStatus($cmd); $dao = new FlightBookingDao(); $dao->save($flightBooking); $msg = ''; if ($cmd === FlightBooking::VOIDED) { $smg = 'Flight booking deleted successfully.'; } else { $smg = 'Flight boooking changed successfully.'; } Flash::addFlash($smg); Utils::redirect('list', array('status' => $status));
$flightBooking = Utils::getFlightBookingByGetId(); } else { // set defaults $flightBooking = new FlightBooking(); $flightBooking->setDate(new DateTime()); //$flightBooking->setPriority(Todo::PRIORITY_MEDIUM); //$dueOn = new DateTime("+1 day"); //$dueOn->setTime(0, 0, 0); //$flightBooking->setDueOn($dueOn); } if (array_key_exists('cancel', $_POST)) { // redirect Utils::redirect('home'); } elseif (array_key_exists('save', $_POST)) { // for security reasons, do not map the whole $_POST['todo'] //pretending to have values in $_POST //$data = array('first_name' => 'Bob', 'no_of_passengers' => 2); $data = array('first_name' => $_POST['flight_booking']['first_name'], 'no_of_passengers' => $_POST['flight_booking']['no_of_passengers'], 'date' => $_POST['flight_booking']['date'] . ' 00:00:00'); // map FlightBookingMapper::map($flightBooking, $data); // validate $errors = FlightBookingValidator::validate($flightBooking); if (empty($errors)) { // save $dao = new FlightBookingDao(); $flightBooking = $dao->save($flightBooking); Flash::addFlash('Thank you for booking with us. We will be in touch shortly.'); // redirect Utils::redirect('home'); } }