From 7fa4cd1617d9c367a64f450d4fdbd751e0e73967 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 14 Aug 2012 10:49:20 +0800 Subject: [PATCH] MDL-34290 using moodleform cast to int in dropbox repository settings --- .../dropbox/lang/en/repository_dropbox.php | 1 - repository/dropbox/lib.php | 18 ++---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/repository/dropbox/lang/en/repository_dropbox.php b/repository/dropbox/lang/en/repository_dropbox.php index 4937c1303ff..abf16c19685 100644 --- a/repository/dropbox/lang/en/repository_dropbox.php +++ b/repository/dropbox/lang/en/repository_dropbox.php @@ -32,5 +32,4 @@ $string['secret'] = 'Dropbox secret'; $string['instruction'] = 'You can get your API Key and secret from Dropbox developers. When setting up your key please select "Full Dropbox" as the "Access level".'; $string['cachelimit'] = 'Cache limit'; $string['cachelimit_info'] = 'Enter the maximum size of files (in bytes) to be cached on server for Dropbox aliases/shortcuts. Cached files will be served when the source is no longer available. Empty value or zero mean caching of all files regardless of size.'; -$string['error_cachelimit'] = 'Must be a positive integer or empty value'; $string['dropbox:view'] = 'View a Dropbox folder'; diff --git a/repository/dropbox/lib.php b/repository/dropbox/lib.php index c0edef34cb6..a0af82fae2d 100644 --- a/repository/dropbox/lib.php +++ b/repository/dropbox/lib.php @@ -464,25 +464,11 @@ class repository_dropbox extends repository { $mform->addElement('static', null, '', $str_getkey); $mform->addElement('text', 'dropbox_cachelimit', get_string('cachelimit', 'repository_dropbox'), array('size' => '40')); + $mform->addRule('dropbox_cachelimit', null, 'numeric', null, 'client'); + $mform->setType('dropbox_cachelimit', PARAM_INT); $mform->addElement('static', 'dropbox_cachelimit_info', '', get_string('cachelimit_info', 'repository_dropbox')); } - /** - * Validate Admin Settings Moodle form - * - * @param moodleform $mform Moodle form (passed by reference) - * @param array $data array of ("fieldname"=>value) of submitted data - * @param array $errors array of ("fieldname"=>errormessage) of errors - * @return array array of errors - */ - public static function type_form_validation($mform, $data, $errors) { - if (!empty($data['dropbox_cachelimit']) && (!is_number($data['dropbox_cachelimit']) || - (int)$data['dropbox_cachelimit']<0)) { - $errors['dropbox_cachelimit'] = get_string('error_cachelimit', 'repository_dropbox'); - } - return $errors; - } - /** * Option names of dropbox plugin *