Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-28483-m21' of git://github.com/ankitagarwal/moodle …

…into MOODLE_21_STABLE
  • Loading branch information...
commit 52bc12cedcbf1ee87b372dd4f402cea4c80d8766 2 parents 00a3005 + 6bcfb5f
@stronk7 stronk7 authored
Showing with 12 additions and 0 deletions.
  1. +1 −0  mod/url/lang/en/url.php
  2. +11 −0 mod/url/mod_form.php
View
1  mod/url/lang/en/url.php
@@ -45,6 +45,7 @@
$string['externalurl'] = 'External URL';
$string['framesize'] = 'Frame height';
$string['chooseavariable'] = 'Choose a variable...';
+$string['invalidurl'] = 'Entered URL is invalid';
$string['modulename'] = 'URL';
$string['modulenameplural'] = 'URLs';
$string['neverseen'] = 'Never seen';
View
11 mod/url/mod_form.php
@@ -50,6 +50,7 @@ function definition() {
//-------------------------------------------------------
$mform->addElement('header', 'content', get_string('contentheader', 'url'));
$mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true));
+ $mform->addRule('externalurl', null, 'required', null, 'client');
//-------------------------------------------------------
$mform->addElement('header', 'optionssection', get_string('optionsheader', 'url'));
@@ -165,4 +166,14 @@ function data_preprocessing(&$default_values) {
}
}
+ function validation($data, $files) {
+ $errors = parent::validation($data, $files);
+ //Validating Entered url
+ $data['externalurl'] = clean_param($data['externalurl'], PARAM_URL);
+ if (empty($data['externalurl'])) {
+ $errors['externalurl'] = get_string('invalidurl', 'url');
+ }
+ return $errors;
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.