コード例 #1
0
ファイル: tipuri-modele.php プロジェクト: florinp/dexonline
util_assertModerator(PRIV_EDIT);
$showAddForm = util_getRequestParameter('add');
$editId = util_getRequestParameter('editId');
$deleteId = util_getRequestParameter('deleteId');
$submitAddButton = util_getRequestParameter('submitAddButton');
$submitEditButton = util_getRequestParameter('submitEditButton');
$id = util_getRequestParameter('id');
$code = util_getRequestParameter('code');
$canonical = util_getRequestParameter('canonical');
$description = util_getRequestParameter('description');
if ($submitAddButton) {
    $mt = Model::factory('ModelType')->create();
    $mt->code = mb_strtoupper($code);
    $mt->canonical = $canonical;
    $mt->description = $description;
    if (validateAdd($mt)) {
        $mt->save();
        FlashMessage::add("Am adăugat tipul de model '{$mt->code}'.", 'info');
        util_redirect('tipuri-modele.php');
    } else {
        $showAddForm = true;
        SmartyWrap::assign('addModelType', $mt);
    }
}
if ($submitEditButton) {
    $mt = ModelType::get_by_id($id);
    $mt->description = $description;
    if (validateEdit($mt)) {
        $mt->save();
        FlashMessage::add('Am salvat descrierea.', 'info');
        util_redirect('tipuri-modele.php');
コード例 #2
0
ファイル: form.php プロジェクト: axyjo/ptscheduler
<?php

if (isset($_POST['hash'])) {
    if (isset($_GET['add'])) {
        $errors = validateAdd($_POST);
        if (count($errors) == 0) {
            addAppointment($_POST['teacher'], $_POST['parent'], $_POST['time']);
            addNotice($_POST['teacher'], $_POST['parent'], $_POST['time']);
            echo 'success';
        } else {
            echo '<div class="error"><ul>';
            foreach ($errors as $error) {
                echo '<li>' . $error . '</li>';
            }
            echo '</ul></div>';
        }
    } elseif (isset($_GET['delete'])) {
        $errors = validateDelete($_POST);
        if (count($errors) == 0) {
            deleteAppointment($_POST['teacher'], $_POST['parent'], $_POST['time']);
            deleteNotice($_POST['teacher'], $_POST['parent'], $_POST['time']);
            echo 'success';
        } else {
            echo '<div class="error"><ul>';
            foreach ($errors as $error) {
                echo '<li>' . $error . '</li>';
            }
            echo '</ul></div>';
        }
    }
} else {