Example #1
0
$PAGE->set_url('/blocks/simplehtml/view.php', array('id' => $courseid));
$PAGE->set_pagelayout('standard');
$PAGE->set_heading(get_string('edithtml', 'block_simplehtml'));
$PAGE->set_title('Nuevo Rea');
$simplehtml = new simplehtml_form();
$toform['blockid'] = $blockid;
$toform['courseid'] = $courseid;
$toform['component'] = $component;
$toform['id'] = $id;
$simplehtml->set_data($toform);
$settingsnode = $PAGE->settingsnav->add(get_string('simplehtmlsettings', 'block_simplehtml'));
$editurl = new moodle_url('/blocks/simplehtml/view.php', array('id' => $id, 'courseid' => $courseid, 'blockid' => $blockid, 'component' => $component));
$editnode = $settingsnode->add(get_string('editpage', 'block_simplehtml'), $editurl);
$editnode->make_active();
$url = new moodle_url('/course/view.php', array('id' => $courseid));
if ($simplehtml->is_cancelled()) {
    redirect($url);
} else {
    if ($simplehtml->get_data()) {
        $fromform = $simplehtml->get_data();
        if ($fromform->id != 0) {
            if (!$DB->update_record('block_simplehtml', $fromform)) {
                print_error('updateerror', 'block_simplehtml');
            }
        } else {
            if (!$DB->insert_record('block_simplehtml', $fromform)) {
                print_error('inserterror', 'block_simplehtml');
            }
        }
        redirect($url);
    } else {
Example #2
0
$entry->attachments = $draftitemid;
// Add the draftitemid to the form, so that 'file_get_submitted_draft_itemid' can retrieve it
// Set form data
$mform->set_data($entry);
// ===============
//
//
// PAGE OUTPUT
//
//
// ===============
echo $OUTPUT->header();
// ----------
// Form Submit Status
// ----------
if ($mform->is_cancelled()) {
    // CANCELLED
    echo '<h1>Cancelled</h1>';
    echo '<p>Handle form cancel operation, if cancel button is present on form<p>';
} else {
    if ($data = $mform->get_data()) {
        // SUCCESS
        echo '<h1>Success!</h1>';
        echo '<p>In this case you process validated data. $mform->get_data() returns data posted in form.<p>';
        echo "<p><center><a href='{$CFG->wwwroot}/local/filemanager'>Click here to return and see your File Manager!</a></center><p>";
        // Save the files submitted
        file_save_draft_area_files($draftitemid, $context->id, 'local_filemanager', 'attachment', $itemid, $filemanageropts);
        // Just to show they are all there - output a list of submitted files
        $fs = get_file_storage();
        /** @var stored_file[] $files */
        $files = $fs->get_area_files($context->id, 'local_filemanager', 'attachment', $itemid);
Example #3
0
<?php

require_once '../../config.php';
require_once 'formdesign1.php';
require_login();
global $DB;
global $USER;
$PAGE->set_pagelayout('admin');
$toform = new simplehtml_form();
if ($toform->is_cancelled()) {
} else {
    if ($fromform = $toform->get_data()) {
        //		print_object($fromform);
        $record = new stdClass();
        $result = new stdClass();
        $record->name = $fromform->name;
        //		print_object($record);
        $result = $DB->get_record('form', array('name' => $record->name), $fields = '*', $strictness = IGNORE_MISSING);
        //		$result = $DB->get_record_sql('SELECT * FROM {form}', array('name' => $record->name));
        //		print_object($result);
        //		$toform->set_data('$mform');
        //		print_object($mform);
        $_SESSION['admission'] = $result;
        redirect('fill_form.php?id=' . $USER->id);
    } else {
        echo $OUTPUT->header();
        $toform->display();
        echo $OUTPUT->footer();
    }
}