MDL-26796 convert array parameter cleaning to new functions

This commit is contained in:
Petr Skoda
2011-08-18 08:40:33 +02:00
parent 923aff64fa
commit 18bd7573d6
22 changed files with 48 additions and 34 deletions
+13 -4
View File
@@ -588,18 +588,27 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
* @return integer the itemid, or 0 if there is not one yet.
*/
function file_get_submitted_draft_itemid($elname) {
$param = optional_param($elname, 0, PARAM_INT);
if ($param) {
require_sesskey();
// this is a nasty hack, ideally all new elements should use arrays here or there should be a new parameter
if (!isset($_REQUEST[$elname])) {
return 0;
}
if (is_array($param)) {
if (is_array($_REQUEST[$elname])) {
$param = optional_param_array($elname, 0, PARAM_INT);
if (!empty($param['itemid'])) {
$param = $param['itemid'];
} else {
debugging('Missing itemid, maybe caused by unset maxfiles option', DEBUG_DEVELOPER);
return false;
}
} else {
$param = optional_param($elname, 0, PARAM_INT);
}
if ($param) {
require_sesskey();
}
return $param;
}