Details
Description
I may be being overly fussy, but I think it is important to get the file API function names as clear as possible before it is too late. It will make it much easier for people trying to learn.
Fortunately, grepping the code for 'draft' only finds 13 matches, so I think we can still change it.
I suggest
get_draftarea_info -> file_get_draft_area_info
file_prepare_draftarea -> file_prepare_draft_area
file_convert_draftarea -> file_save_files_from_draft_area
Or even, since this is an important core library, we could drop the 'file_' prefix. The funciton names are sufficiently unique without it.
I also think we should rename all the other functions the run words together in function names (for example pluginfiles, draftitemid). The File API should all be nice new code. I think we should be exemplary in following the coding guidelines.
If there is agreement on this I am happy to make the changes.
It is rather premature to make a patch for this before we have discussed it, but it was only a search and replace, and I wanted to see how the code looked afterwards, so here is a patch.
Note, in file_convert_relative_pluginfiles / rewrite_pluginfile_urls, there was some code that used to read
if ($CFG->slasharguments) { $draftbase = "$CFG->wwwroot/$file/$pluginstub"; } else { $draftbase = "$CFG->wwwroot/draftfile.php?file=/$pluginstub"; }
It looks to me like it should be
if ($CFG->slasharguments) { $draftbase = "$CFG->wwwroot/$file/$pluginstub"; } } else { $draftbase = "$CFG->wwwroot/$file?file=/$pluginstub"; }
Also, for consistency, would it be better to split up the $pluginstub parameter, so that we consistently use separate $contextid, $filearea and $itemid parameters on all these methods?
I also rewrote Dongsheng's page http://docs.moodle.org/en/Development:Convert_Draftarea_Files to use my proposed names, becuase it helped me to understand it. I will of course revert those changes if we do not agree on this soon.