MDL-34290 using moodleform cast to int in dropbox repository settings
authorDan Poltawski <dan@moodle.com>
Tue, 14 Aug 2012 02:49:20 +0000 (10:49 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 29 Aug 2012 05:12:07 +0000 (13:12 +0800)
repository/dropbox/lang/en/repository_dropbox.php
repository/dropbox/lib.php

index 4937c13..abf16c1 100644 (file)
@@ -32,5 +32,4 @@ $string['secret'] = 'Dropbox secret';
 $string['instruction'] = 'You can get your API Key and secret from <a href="http://www.dropbox.com/developers/apps">Dropbox developers</a>. 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';
index c0edef3..a0af82f 100644 (file)
@@ -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
      *