Permalink
Browse files

MDL-28483 URL adding validation checks and changing field externalurl…

… to not-null
  • Loading branch information...
ankitagarwal committed Sep 22, 2011
1 parent ec3c9da commit 4373200f88cf235d08e9f5c81f252886036a822e
Showing with 26 additions and 1 deletion.
  1. +14 −0 mod/url/db/upgrade.php
  2. +1 −0 mod/url/lang/en/url.php
  3. +10 −0 mod/url/mod_form.php
  4. +1 −1 mod/url/version.php
View
@@ -53,6 +53,20 @@ function xmldb_url_upgrade($oldversion) {
// Moodle v2.1.0 release upgrade line
// Put any upgrade step following this
+ if ($oldversion < 2011092800) {
+
+ // Changing nullability of field externalurl on table urls to not-null
+ $table = new xmldb_table('url');
+ $field = new xmldb_field('externalurl', XMLDB_TYPE_TEXT, 'small', null,
+ XMLDB_NOTNULL, null, null, 'introformat');
+
+ $DB->set_field_select('url', 'externalurl', $DB->sql_empty(), 'externalurl IS NULL');
+ // Launch change of nullability for field =externalurl
+ $dbman->change_field_notnull($table, $field);
+
+ // url savepoint reached
+ upgrade_mod_savepoint(true, 2011092800, 'url');
+ }
return true;
}
View
@@ -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
@@ -166,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;
+ }
+
}
View
@@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die;
-$module->version = 2010101400;
+$module->version = 2011092800;
$module->requires = 2010080300; // Requires this Moodle version
$module->cron = 0;

0 comments on commit 4373200

Please sign in to comment.