Skip to content
Snippets Groups Projects
Commit 7d6597d6 authored by Elke Kreim's avatar Elke Kreim
Browse files

Remove contact form functionality

parent 353ef556
No related branches found
No related tags found
No related merge requests found
<?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/hsh/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_hsh');
$PAGE->set_title($strtitle);
$PAGE->set_heading($strtitle);
$formtitle = get_string('formtitle', 'local_hsh');
$intro_1 = get_string('intro_1', 'local_hsh');
$intro_2 = get_string('intro_2', 'local_hsh');
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_hsh'), $returnurl);
}
$PAGE->navbar->add($strtitle);
echo $OUTPUT->header();
echo $OUTPUT->heading($formtitle);
echo ('<p>' . $intro_1 . '<br />' . $intro_2 . '</p>');
// Show the request form.
$requestform->display();
echo $OUTPUT->footer();
<?php
/**
* User: wernerpe
* Date: 19.01.2015
* Time: 10:43
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->libdir . '/formslib.php');
class contact_form extends moodleform {
function definition() {
global $CFG, $DB, $USER;
$mform = & $this->_form;
$mform->addElement('header', 'personaldetails', get_string('personaldetails', 'local_hsh'));
$mform->addElement('text', 'firstname', get_string('firstname', 'local_hsh'), 'maxlength="254" size="34"');
$mform->addRule('firstname', get_string('firstname_mis', 'local_hsh'), 'required', null, 'client');
$mform->setType('firstname', PARAM_TEXT);
$mform->addElement('text', 'lastname', get_string('lastname', 'local_hsh'), 'maxlength="254" size="34"');
$mform->addRule('lastname', get_string('lastname_mis', 'local_hsh'), 'required', null, 'client');
$mform->setType('lastname', PARAM_TEXT);
$mform->addElement('text', 'email', get_string('email', 'local_hsh'), 'maxlength="254" size="34"');
$mform->addRule('email', get_string('email_mis', 'local_hsh'), 'required', null, 'client');
$mform->addRule('email', get_string('email_mis', 'local_hsh'), 'email', null, 'client');
$mform->setType('email', PARAM_EMAIL);
$mform->addElement('text', 'telephone', get_string('telephone', 'local_hsh'), 'maxlength="254" size="34"');
$mform->setType('telephone', PARAM_TEXT);
$mform->addElement('header', 'messageheader', get_string('message', 'local_hsh'));
$mform->addElement('text', 'subject', get_string('subject', 'local_hsh'), ' style="width: 20em;"');
$mform->setType('subject', PARAM_TEXT);
$mform->addElement('textarea', 'message', get_string('message', 'local_hsh'), 'style="width: 20em;height: 20em"');
$mform->addRule('message', get_string('message_mis', 'local_hsh'), 'required', null, 'client');
if (isloggedin()) {
$mform->setDefault('firstname', $USER->firstname);
$mform->setDefault('lastname', $USER->lastname);
$mform->setDefault('email', $USER->email);
$mform->setDefault('telephone', $USER->phone1);
}
// > 2022-02-01 Elke Kreim: Remove recaptcha as it does not work
// if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) {
// $mform->addElement('recaptcha', 'recaptcha_element', get_string('security_question', 'auth'), 'style="margin: 10em"');
//
// }
// <
$this->add_action_buttons(true, get_string('submit', 'local_hsh'));
}
function validation($data, $files) {
global $CFG;
if(empty($data["lastname"])){
$errors['lastname'] = get_string('missinglastname');
}
if(empty($data["firstname"])){
$errors['firstname'] = get_string('missingfirstname');
}
if(empty($data["message"])){
$errors['message'] = get_string('missingdescription');
}
if (! validate_email($data['email'])) {
$errors['email'] = get_string('invalidemail');
}
// if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) {
// $recaptcha_element = $this->_form->getElement('recaptcha_element');
// if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) {
// $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field'];
// $response_field = $this->_form->_submitValues['recaptcha_response_field'];
// if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) {
// $errors['recaptcha_element'] = $result;
// }
// } else {
// $errors['recaptcha_element'] = get_string('missingrecaptchachallengefield');
// }
// }
return $errors;
}
}
......@@ -518,35 +518,6 @@ class course_request_hsh {
// End HsH
}
class contactform {
public static function create($eventdata) {
global $CFG;
$mail = get_mailer();
$formatted_subject = "";
$formatted_subject .= $eventdata->subject;
$message = 'Sehr geehrtes E-Learning Center, <br /><br />';
$message .= "\n" . $eventdata->message . '<br /><br />';
$message .= 'Mit freundlichen Gr&uuml;&szlig;en <br />';
$message .= $eventdata->firstname . ' ' . $eventdata->lastname . '<br />';
$message .= 'Telefon: ' . $eventdata->telephone;
$mail->Subject = $formatted_subject;
$mail->Body = $message;
$mail->AltBody = $message;
$mail->From = $eventdata->email;
$mail->FromName = $eventdata->lastname . ", " . $eventdata->firstname;
$mail->addAddress("elc@hs-hannover.de");
$mail->send();
return $mail;
}
}
function local_hsh_extend_navigation_course(navigation_node $parentnode, stdClass $course, context_course $context) {
if (has_capability('moodle/grade:export', $context)) {
$strfoo = get_string('navigationtext', 'local_hsh');
......
M.local_contactform = {
sesskey: null,
init: function (Y, instanceid, sesskey) {
this.Y = Y;
this.sesskey = sesskey;
this.instanceid = instanceid;
this.progress = Y.one('#id_contacttoselect');
var moodlestrings = new Array();
moodlestrings.push(M.util.get_string('dataloss','local_contactform'));
moodlestrings.push(M.util.get_string('loginprob','local_contactform'));
moodlestrings.push(M.util.get_string('usercreate','local_contactform'));
moodlestrings.push(M.util.get_string('userdelete','local_contactform'));
moodlestrings.push(M.util.get_string('coursedelete','local_contactform'));
moodlestrings.push(M.util.get_string('technical','local_contactform'));
moodlestrings.push(M.util.get_string('improvement','local_contactform'));
moodlestrings.sort();
moodlestrings.unshift(M.util.get_string('pleasechoose','local_contactform'));
moodlestrings.push(M.util.get_string('other','local_contactform'));
var elcstrings = new Array();
elcstrings.push(M.util.get_string('clicker','local_contactform'));
elcstrings.push(M.util.get_string('eexam','local_contactform'));
elcstrings.push(M.util.get_string('evaexam','local_contactform'));
elcstrings.push(M.util.get_string('loncapa','local_contactform'));
elcstrings.push(M.util.get_string('recording','local_contactform'));
elcstrings.push(M.util.get_string('training','local_contactform'));
elcstrings.sort();
elcstrings.unshift(M.util.get_string('pleasechoose','local_contactform'));
elcstrings.push(M.util.get_string('other','local_contactform'));
Y.one('#id_contacttoselect').on('change', function (e) {
var index = Y.one("#id_contacttoselect").get('selectedIndex');
var value = Y.one("#id_contacttoselect").get("options").item(index).getAttribute('value');
var subject = document.getElementById("id_subject");
var currentarr = new Array();
var i;
for(i=subject.options.length-1;i>=0;i--)
{
subject.remove(i);
}
if (value == 1) {
currentarr = elcstrings;
} else if (value == 0) {
currentarr = moodlestrings;
}
var option;
Y.Array.each(currentarr, function (element) {
option = Y.Node.create('<option>').set('innerHTML', element);
option = Y.Node.set('value',element);
option.appendTo(subject);
});
}, this);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment