Skip to content
Snippets Groups Projects
contact.php 2.72 KiB
Newer Older
  • Learn to ignore specific revisions
  • nino2205's avatar
    nino2205 committed
    <?php
    
    require_once(dirname(__FILE__) . '/../../config.php');
    require_once(dirname(__FILE__) . '/contact_form.php');
    require_once(dirname(__FILE__) . '/lib.php');
    // You will process some page parameters at the top here and get the info about
    // what instance of your module and what course you're in etc. Make sure you
    // include hidden variable in your forms which have their defaults set in set_data
    // which pass these variables from page to page.
    global $CFG, $PAGE;
    // Setup $PAGE here.
    $site = get_site();
    $returnurl = new moodle_url('/my');
    $url = new moodle_url('/local/contactform/contact.php');
    $return = optional_param('return', null, PARAM_ALPHANUMEXT);
    $PAGE->set_url($url);
    $context = context_system::instance();
    $PAGE->set_context($context);
    // Set page layout
    $PAGE->set_pagelayout('standard');
    
    $requestform = new contact_form($url);
    $strtitle = get_string('pluginname','local_contactform');
    $PAGE->set_title($strtitle);
    $PAGE->set_heading($strtitle);
    
    
    // Standard form processing if statement.
    if ($requestform->is_cancelled()){
        redirect($returnurl);
    } else if ($data = $requestform->get_data()) {
        // we need $_POST for javascript generated entries
        $data = $_POST;
        $eventdata = new stdClass();
        $eventdata->contacttoselect = $_POST["contacttoselect"];
        $eventdata->subject = $_POST["subject"];
        $eventdata->email = $_POST["email"];
        $eventdata->message  = $_POST["message"];
        $eventdata->lastname = $_POST["lastname"];
        $eventdata->firstname = $_POST["firstname"];
        $eventdata->telephone = $_POST["telephone"];
    
    contactform::create($eventdata);
    //end HsH
        // And redirect back to the course listing.
        notice(get_string('confirmrequest','local_contactform'), $returnurl);
    }
    
    
    $PAGE->navbar->add($strtitle);
    $jsmodule = array(
        'name'  =>  'local_contactform',
        'fullpath'  =>  '/local/contactform/module.js',
        'requires'  =>  array('base', 'node', 'json', 'io')
    );
    $jsdata = array(
        'instanceid' => $context->id,
        'sesskey' => sesskey()
    );
    $PAGE->requires->js_init_call('M.local_contactform.init',
        $jsdata,
        false,
        $jsmodule);
    <<<<<<< HEAD
    $PAGE->requires->strings_for_js(array('contacttoelc','recording','clicker','moodle','loncapa','evaexam','eexam','training', 'other','improvement','technical','usercreate','loginprob','pleasechoose','dataloss'),'local_contactform');
    =======
    $PAGE->requires->strings_for_js(array('contacttoelc','recording','clicker','moodle','loncapa','evaexam','eexam','training', 'other','improvement','technical','usercreate','userdelete','coursedelete','loginprob','pleasechoose','dataloss'),'local_contactform');
    >>>>>>> hsh/develop
    echo $OUTPUT->header();
    echo $OUTPUT->heading($strtitle);
    // Show the request form.
    $requestform->display();
    echo $OUTPUT->footer();