diff --git a/classes/toolbox.php b/classes/toolbox.php index e8e300d7..6f7f0d0d 100644 --- a/classes/toolbox.php +++ b/classes/toolbox.php @@ -166,7 +166,7 @@ public function check_displayed_image($sectionimage, $courseid, $coursecontextid } } else { throw new \moodle_exception( - 'cannotgetimagelock', + 'imagemanagement', 'format_grid', '', get_string('cannotgetmanagesectionimagelock', 'format_grid') @@ -228,7 +228,10 @@ public function setup_displayed_image($sectionimage, $sectionfile, $courseid, $s 'id' => $sectionfile->get_id(), 'itemid' => $sectionfile->get_itemid(), 'filename' => $filename, + 'filemime' => $sectionfile->get_mimetype(), + 'filesize' => $sectionfile->get_filesize(), 'sectionid' => $sectionid, + 'userid' => $sectionfile->get_userid(), ]; $data = self::generate_image( $tmpfilepath, @@ -286,7 +289,7 @@ public function setup_displayed_image($sectionimage, $sectionfile, $courseid, $s ); if ($sectionimage->displayedimagestate == -1) { throw new \moodle_exception( - 'cannotconvertuploadedimagetodisplayedimage', + 'imagemanagement', 'format_grid', '', get_string( @@ -392,7 +395,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei if (empty($imageinfo)) { unlink($filepath); throw new \moodle_exception( - 'noimageinformation', + 'imagemanagement', 'format_grid', '', get_string( @@ -409,7 +412,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei if (empty($originalheight)) { unlink($filepath); throw new \moodle_exception( - 'originalheightempty', + 'imagemanagement', 'format_grid', '', get_string( @@ -422,7 +425,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei if (empty($originalwidth)) { unlink($filepath); throw new \moodle_exception( - 'originalwidthempty', + 'imagemanagement', 'format_grid', '', get_string( @@ -447,7 +450,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei } else { unlink($filepath); throw new \moodle_exception( - 'formatnotsupported', + 'imagemanagement', 'format_grid', '', get_string( @@ -465,7 +468,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei } else { unlink($filepath); throw new \moodle_exception( - 'formatnotsupported', + 'imagemanagement', 'format_grid', '', get_string( @@ -485,7 +488,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei } else { unlink($filepath); throw new \moodle_exception( - 'formatnotsupported', + 'imagemanagement', 'format_grid', '', get_string( @@ -502,7 +505,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei } else { unlink($filepath); throw new \moodle_exception( - 'formatnotsupported', + 'imagemanagement', 'format_grid', '', get_string( @@ -516,7 +519,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei default: unlink($filepath); throw new \moodle_exception( - 'mimetypenotsupported', + 'imagemanagement', 'format_grid', '', get_string( @@ -618,7 +621,7 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei ob_end_clean(); unlink($filepath); throw new \moodle_exception( - 'functionfailed', + 'imagemanagement', 'format_grid', '', get_string( @@ -637,11 +640,14 @@ private static function generate_image($filepath, $requestedwidth, $requestedhei } private static function debugdata_decode($debugdata) { - $o = 'itemid > ' . $debugdata['itemid']; - $o .= ', filename > ' . $debugdata['filename']; - $o .= ' and sectionid > ' . $debugdata['sectionid'] . '. '; + $o = 'id: ' . $debugdata['item']; + $o .= 'itemid: ' . $debugdata['itemid']; + $o .= ', filename: ' . $debugdata['filename']; + $o .= ', filemime: ' . $debugdata['filemime']; + $o .= ', filesize: ' . $debugdata['filesize']; + $o .= ', creator user id: ' . $debugdata['userid']; + $o .= ' and sectionid: ' . $debugdata['sectionid'] . '. '; $o .= get_string('reporterror', 'format_grid'); - return $o; } @@ -718,7 +724,7 @@ private static function update_the_displayed_images($courseid = null) { } } else { throw new \moodle_exception( - 'cannotgetimagelock', + 'imagemanagement', 'format_grid', '', get_string('cannotgetmanagesectionimagelock', 'format_grid') @@ -798,7 +804,7 @@ public static function delete_image($sectionid, $courseid) { } } else { throw new \moodle_exception( - 'cannotgetimagelock', + 'imagemanagement', 'format_grid', '', get_string('cannotgetmanagesectionimagelock', 'format_grid') diff --git a/lang/en/format_grid.php b/lang/en/format_grid.php index 595f28e1..7410b80b 100644 --- a/lang/en/format_grid.php +++ b/lang/en/format_grid.php @@ -149,15 +149,16 @@ $string['versionstable'] = 'Stable version - Could contain bugs. Check on a test server before installing on your production server.'; // Exception messages. -$string['cannotconvertuploadedimagetodisplayedimage'] = 'Cannot convert uploaded image to displayed image - {$a}. Please report error details and the information contained in the php.log file to developer.'; +$string['cannotconvertuploadedimagetodisplayedimage'] = 'Cannot convert uploaded image to displayed image - {$a}.'; $string['cannotgetmanagesectionimagelock'] = 'Cannot get manage section image lock. This can happen if two people are editing the settinsg of the same section on the same course at the same time.'; -$string['formatnotsupported'] = 'Format is not supported at this server, please fix the system configuration to have the GD PHP extension installed - {$a}.'; -$string['functionfailed'] = 'Function failed on image - {$a}.'; -$string['mimetypenotsupported'] = 'Mime type is not supported as an image format in the Grid format - {$a}.'; -$string['originalheightempty'] = 'Original height is empty - {$a}.'; -$string['originalwidthempty'] = 'Original width is empty - {$a}.'; -$string['noimageinformation'] = 'Image information is empty - {$a}.'; -$string['reporterror'] = 'Please report error details and the information contained in the php.log file to developer'; +$string['formatnotsupported'] = 'Format is not supported at this server, please fix the system configuration to have the GD PHP extension installed - {$a}'; +$string['functionfailed'] = 'Function failed on image - {$a}'; +$string['imagemanagement'] = 'Image management: {$a}.'; +$string['mimetypenotsupported'] = 'Mime type is not supported as an image format in the Grid format - {$a}'; +$string['originalheightempty'] = 'Original height is empty - {$a}'; +$string['originalwidthempty'] = 'Original width is empty - {$a}'; +$string['noimageinformation'] = 'Image information is empty - {$a}'; +$string['reporterror'] = 'Please use the error details and the information contained in the php.log to understand the nature of why the uploaded image cannot be used'; // Privacy. $string['privacy:nop'] = 'The Grid format stores lots of settings that pertain to its configuration. None of the settings are related to a specific user. It is your responsibilty to ensure that no user data is entered in any of the free text fields. Setting a setting will result in that action being logged within the core Moodle logging system against the user whom changed it, this is outside of the formats control, please see the core logging system for privacy compliance for this. When uploading images, you should avoid uploading images with embedded location data (EXIF GPS) included or other such personal data. It would be possible to extract any location / personal data from the images. Please examine the code carefully to be sure that it complies with your interpretation of your privacy laws. I am not a lawyer and my analysis is based on my interpretation. If you have any doubt then remove the format forthwith.';