Moodle
  1. Moodle
  2. MDL-30008

accepted_types ignored by filemanager element

    Details

    • Testing Instructions:
      Hide

      1. Create a new file resource, upload files to it and make sure that it works
      2. Create a database resource with a picture field
      3. Make sure you cannot add something else than a picture
      4. Go to your privates files and upload a bunch of different files, make sure it works
      5. Hack the code of users/filesedit.php and change accepted_types to

      • '.jpg'
      • array('.jpg')
      • array('image')

      6. For the two first ones, make sure the only file uploadable is a jpg
      7. For the array('image') make sure you can only upload standard image files

      Show
      1. Create a new file resource, upload files to it and make sure that it works 2. Create a database resource with a picture field 3. Make sure you cannot add something else than a picture 4. Go to your privates files and upload a bunch of different files, make sure it works 5. Hack the code of users/filesedit.php and change accepted_types to '.jpg' array('.jpg') array('image') 6. For the two first ones, make sure the only file uploadable is a jpg 7. For the array('image') make sure you can only upload standard image files
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:

      Description

      The filemanager form element does not pass the accepted_types option on to the filepicker pop-up.

      Fix:
      In lib/form/filemanager.js, function initializer:

      Find the section with all the 'this.filepicker_options.XXX = ' and add, at the end, the following line:
      this.filepicker_options.accepted_types = options.accepted_types;

      (Original test instructions follows)

      Create a filemanager element and set the 'accepted_types' to, for example, array('*.jpg')
      (e.g. in 'mod/form/post_form.php', line 88 - change "'accepted_types'=>''," to "accepted_types'=>array('.jpg'),")
      Click 'Add'
      Click 'Upload a file'
      Choose any file on your local computer that is NOT a jpeg
      Click 'Upload this file'

      Expected:
      Error message: XX filetype cannot be accepted

      Actual:
      File is accepted without complaint

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Dan Poltawski added a comment -

            Is this still an issue?

            Show
            Dan Poltawski added a comment - Is this still an issue?
            Hide
            Stephen Bourget added a comment -

            Yes, this is still an issue on Moodle 2.1.5 and 2.2.2.

            Show
            Stephen Bourget added a comment - Yes, this is still an issue on Moodle 2.1.5 and 2.2.2.
            Hide
            Andrew Davis added a comment -

            The code change looks fine. Does this need to go into master as well or doesn't it apply there?

            Re the testing instructions, is there no way to modify accepted files through the UI?

            Show
            Andrew Davis added a comment - The code change looks fine. Does this need to go into master as well or doesn't it apply there? Re the testing instructions, is there no way to modify accepted files through the UI?
            Hide
            Frédéric Massart added a comment -

            Hi Andrew. No this doesn't need to be go in master, the file manager has changed so much that it handles it, and differently (I guess).
            About the test instructions, I haven't found a way of doing it without hacking the code. Perhaps I have missed a setting, my knowledge of Moodle is very young .

            Show
            Frédéric Massart added a comment - Hi Andrew. No this doesn't need to be go in master, the file manager has changed so much that it handles it, and differently (I guess). About the test instructions, I haven't found a way of doing it without hacking the code. Perhaps I have missed a setting, my knowledge of Moodle is very young .
            Hide
            Andrew Davis added a comment -

            I would have thought that surely we allow users to modify the list of acceptable file types but Im not able to find any way to do that. Submit for integration whenever you're ready.

            Show
            Andrew Davis added a comment - I would have thought that surely we allow users to modify the list of acceptable file types but Im not able to find any way to do that. Submit for integration whenever you're ready.
            Hide
            Dan Poltawski added a comment -

            Thanks Fred, integrated to 22 and 21.

            Show
            Dan Poltawski added a comment - Thanks Fred, integrated to 22 and 21.
            Hide
            Rajesh Taneja added a comment -

            Works Great, Thanks for fixing this Fred.

            Show
            Rajesh Taneja added a comment - Works Great, Thanks for fixing this Fred.
            Hide
            Sam Hemelryk added a comment -

            Congratulations your code is upstream - gold star for you!

            This issue + 79 others made it in in time for the minor releases.
            Thank you everyone involved for your exuberant efforts.

            Show
            Sam Hemelryk added a comment - Congratulations your code is upstream - gold star for you! This issue + 79 others made it in in time for the minor releases. Thank you everyone involved for your exuberant efforts.
            Hide
            Chris Wharton added a comment -

            Hi. This appears to have caused a regression, described in MDL-34507

            Show
            Chris Wharton added a comment - Hi. This appears to have caused a regression, described in MDL-34507

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: