# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: moodle/mod/resource/db/upgrade.php --- moodle/mod/resource/db/upgrade.php Base (1.5.2.1) +++ moodle/mod/resource/db/upgrade.php Locally Modified (Based On 1.5.2.1) @@ -63,8 +63,58 @@ } } -//===== 1.9.0 upgrade line ======// + //Set 'Show navigation' setting to "Yes, without frame" for PDF file resources + //Explanation: due to MDL-20320 bug, PDF can now be displayed as 'No', 'Yes, with frame' and 'Yes, without frame'. + //The default being 'no', PDF resources on previous installations need to be set back to 'Yes, without frame' + if ($result && $oldversion < 2007101510) { + require_once($CFG->libdir .'/filelib.php'); //for mimeinfo() function + $resourceids = array(); + //retrieve all file resource + if ($rs = get_recordset('resource', 'type', 'file','','id, reference, popup, options')) { + while ($resource = rs_fetch_next_record($rs)) { + + //only process if the mimetype is a pdf (pdf, fdf, xdf, ...) + if (strcmp(mimeinfo('type', $resource->reference),"application/pdf")===0) { + + //check that the 'Show navigation setting' is set to 'no' or 'yes, with frame' + //(it could be set to forcedownload, and we don't want to change it in this case) + if (empty($resource->popup) && (empty($resource->options) || $resource->options == 'frame' )) { + //the resource will be updated later (for performance issue) + $resourceids[] = $resource->id; + } + } + } + rs_close($rs); + } + + //process the resources update by group of 20 resources at the time + //(it should improve performance on site with lots of PDF) + $resourcenumber = 0; + foreach($resourceids as $resourceid) { + if ($resourcenumber == 0) { + $blocktoupdate = 'IN ('.$resourceid; + $resourcenumber = $resourcenumber +1; + } else { + $blocktoupdate .= ', '.$resourceid; + if ($resourcenumber == 20) { + $blocktoupdate .= ')'; + $sql = "UPDATE {$CFG->prefix}resource SET options = 'objectframe' WHERE id ".$blocktoupdate; + execute_sql($sql); + $resourcenumber = 0; + } else { + $resourcenumber = $resourcenumber +1; + } + } + } + if ($resourcenumber>0) { + $blocktoupdate .= ')'; + $sql = "UPDATE {$CFG->prefix}resource SET options = 'objectframe' WHERE id ".$blocktoupdate; + execute_sql($sql); + } + } + +//===== 1.9.0 upgrade line ======// return $result; } Index: moodle/mod/resource/version.php --- moodle/mod/resource/version.php Base (1.36.2.1) +++ moodle/mod/resource/version.php Locally Modified (Based On 1.36.2.1) @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2007101509; -$module->requires = 2007101509; // Requires this Moodle version +$module->version = 2007101510; +$module->requires = 2007101510; // Requires this Moodle version $module->cron = 0; ?>