Hi there,
my task is to write a local plugin with which a user should be able to upload icons that will be added to the HTML header for homescreen webapp purposes. The most important functionality to be implemented is to get the url of the picture (saved in the db), so that the browser can download it and use it as the web app icon.
Unfortunately I'm pretty new to the Moodle Dev world and so I have some troubles with realizing this task.
I tell you, what I did so far:
I made a settings page and used the function admin_setting_configstoredfile to get the upload window. Thats working fine. When I drag a picture to this box and save, the picture is also saved to the database in the table mdl_files.
And now the challenge begin.
I found a lot of search results for functions in combination with the configstoredfile-element, but only in connection to theme programming, what is not suitable for the local plugin.
Then I had a look at the File API and there it says following:
Note: In most cases, when developing third party plugins, pluginfile.php looks for a callback function in the appropriate plugin. These functions are stored in lib.php files and are named component_name_pluginfile().
So I added the function
function local_mobileheadertags_pluginfile($course, context $context,$filearea,$args,$forcedownload) { }
to my plugin's lib.php
Unfortunately this function is not called. I added some debug messages within this function but they are never called.
I think that this function will only work for those components mentioned here. Local plugins aren't mentioned.
So at the moment I'm totally stuck because I simply have no idea how to get to the images url, where it can be downloaded.
I hope some of you experienced guys can give me a hint!
Best regards,
Kathrin