diff --git a/.upgradenotes/MDL-86607-2025091110293140.yml b/.upgradenotes/MDL-86607-2025091110293140.yml new file mode 100644 index 00000000000..ae9e444a750 --- /dev/null +++ b/.upgradenotes/MDL-86607-2025091110293140.yml @@ -0,0 +1,7 @@ +issueNumber: MDL-86607 +notes: + mod_feedback: + - message: >- + The method `feedback_init_feedback_session()` has been deprecated, along + with all other direct access to `$SESSION` from the module + type: deprecated diff --git a/public/mod/feedback/deprecatedlib.php b/public/mod/feedback/deprecatedlib.php index fde0df01845..b1b78b94789 100644 --- a/public/mod/feedback/deprecatedlib.php +++ b/public/mod/feedback/deprecatedlib.php @@ -34,3 +34,19 @@ function feedback_check_is_switchrole(): bool { \core\deprecation::emit_deprecation(__FUNCTION__); return isset($USER->switchrole) && is_array($USER->switchrole) && count($USER->switchrole) > 0; } + +/** + * Initialize the feedback session + * + * @deprecated since Moodle 5.2 - please do not use this function any more + */ +#[\core\attribute\deprecated(since: '5.2', mdl: 'MDL-86607')] +function feedback_init_feedback_session() { + global $SESSION; + \core\deprecation::emit_deprecation(__FUNCTION__); + if (!empty($SESSION)) { + if (!isset($SESSION->feedback) || !is_object($SESSION->feedback)) { + $SESSION->feedback = new stdClass(); + } + } +} diff --git a/public/mod/feedback/edit.php b/public/mod/feedback/edit.php index e5f8b488393..f5c584a8851 100644 --- a/public/mod/feedback/edit.php +++ b/public/mod/feedback/edit.php @@ -25,8 +25,6 @@ require_once('../../config.php'); require_once('lib.php'); -feedback_init_feedback_session(); - $id = required_param('id', PARAM_INT); if (($formdata = data_submitted()) AND !confirm_sesskey()) { diff --git a/public/mod/feedback/edit_item.php b/public/mod/feedback/edit_item.php index 00c5c4e8d93..14a5fc69886 100644 --- a/public/mod/feedback/edit_item.php +++ b/public/mod/feedback/edit_item.php @@ -25,8 +25,6 @@ require_once("../../config.php"); require_once("lib.php"); -feedback_init_feedback_session(); - $itemid = optional_param('id', false, PARAM_INT); if (!$itemid) { $cmid = required_param('cmid', PARAM_INT); diff --git a/public/mod/feedback/item/captcha/print_captcha.php b/public/mod/feedback/item/captcha/print_captcha.php deleted file mode 100644 index 7d7e6d0447f..00000000000 --- a/public/mod/feedback/item/captcha/print_captcha.php +++ /dev/null @@ -1,124 +0,0 @@ -. - -require_once('../../../../config.php'); - -$id = required_param('id', PARAM_INT); - -$PAGE->set_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$id)); - -if ($id) { - if (! $cm = get_coursemodule_from_id('feedback', $id)) { - throw new \moodle_exception('invalidcoursemodule'); - } - - if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { - throw new \moodle_exception('coursemisconf'); - } - - if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { - throw new \moodle_exception('invalidcoursemodule'); - } -} - -if (!isset($SESSION->feedback->item->captcha)) { - throw new \moodle_exception('captchanotset', 'feedback'); -} - -$height = 40; -$charcount = $SESSION->feedback->item->captcha->charcount; -$fontfile = $CFG->libdir.'/default.ttf'; - -$ttfbox = imagettfbbox ( 30, 0, $fontfile, 'H' );//the text to measure -$charwidth = $ttfbox[2]; - -$width = $charcount * $charwidth; - -$scale = 0.3; -$elipsesize = intval((($width + $height)/2) / 5); -$factor_x = intval($width * $scale); -$factor_y = intval($height * $scale); - -//I split the colors in three ranges -//given are the max-min-values -$colors = array(array(0, 40), array(50, 200), array(210, 255)); -list($col_text1, $col_el, $col_text2) = $colors; - -//if the text is in color_1 so the elipses can be in color_2 or color_3 -//if the text is in color_2 so the elipses can be in color_1 or color_3 -//and so on. -$textcolnum = rand(1, 3); - -//create the numbers to print out -$nums = array(); -for ($i = 0; $i < $charcount; $i++) { - $nums[] = rand(0, 9); //Ziffern von 0- -} - -//to draw enough elipses so I draw 0.2 * width and 0.2 * height -//we need th colors for that -$properties = array(); -for ($x = 0; $x < $factor_x; $x++) { - for ($y = 0; $y < $factor_y; $y++) { - $propobj = new stdClass(); - $propobj->x = intval($x / $scale); - $propobj->y = intval($y / $scale); - $propobj->red = get_random_color($col_el[0], $col_el[1]); - $propobj->green = get_random_color($col_el[0], $col_el[1]); - $propobj->blue = get_random_color($col_el[0], $col_el[1]); - $properties[] = $propobj; - } -} -shuffle($properties); - -// create a blank image -$image = imagecreatetruecolor($width, $height); -$bg = imagecolorallocate($image, 0, 0, 0); -for ($i = 0; $i < ($factor_x * $factor_y); $i++) { - $propobj = $properties[$i]; - // choose a color for the ellipse - $col_ellipse = imagecolorallocate($image, $propobj->red, $propobj->green, $propobj->blue); - // draw the white ellipse - imagefilledellipse($image, $propobj->x, $propobj->y, $elipsesize, $elipsesize, $col_ellipse); -} - -$checkchar = ''; -for ($i = 0; $i < $charcount; $i++) { - $colnum = rand(1, 2); - $textcol = new stdClass(); - $textcol->red = get_random_color(${'col_text'.$colnum}[0], ${'col_text'.$colnum}[1]); - $textcol->green = get_random_color(${'col_text'.$colnum}[0], ${'col_text'.$colnum}[1]); - $textcol->blue = get_random_color(${'col_text'.$colnum}[0], ${'col_text'.$colnum}[1]); - $color_text = imagecolorallocate($image, $textcol->red, $textcol->green, $textcol->blue); - $angle_text = rand(-20, 20); - $left_text = $i * $charwidth; - $text = $nums[$i]; - $checkchar .= $text; - imagettftext($image, 30, $angle_text, $left_text, 35, $color_text, $fontfile, $text); -} - -$SESSION->feedback->item->captcha->checkchar = $checkchar; - -// output the picture -header("Content-type: image/png"); -imagepng($image); - -function get_random_color($val1 = 0, $val2 = 255) { - $min = $val1 < $val2 ? $val1 : $val2; - $max = $val1 > $val2 ? $val1 : $val2; - - return rand($min, $max); -} diff --git a/public/mod/feedback/lang/en/deprecated.txt b/public/mod/feedback/lang/en/deprecated.txt index eadd0955797..76074f24116 100644 --- a/public/mod/feedback/lang/en/deprecated.txt +++ b/public/mod/feedback/lang/en/deprecated.txt @@ -1 +1,2 @@ -public,mod_feedback \ No newline at end of file +public,mod_feedback +selected_dump,mod_feedback diff --git a/public/mod/feedback/lang/en/feedback.php b/public/mod/feedback/lang/en/feedback.php index bb0785a9f5f..b08d8e0a150 100644 --- a/public/mod/feedback/lang/en/feedback.php +++ b/public/mod/feedback/lang/en/feedback.php @@ -270,7 +270,6 @@ $string['search:activity'] = 'Feedback - activity information'; $string['search_course'] = 'Search course'; $string['searchcourses'] = 'Search courses'; $string['searchcourses_help'] = 'Search for the code or name of the course(s) that you wish to associate with this feedback.'; -$string['selected_dump'] = 'Selected indexes of $SESSION variable are dumped below:'; $string['send'] = 'Send'; $string['send_message'] = 'Send notification'; $string['show_all'] = 'Show all'; @@ -310,3 +309,6 @@ $string['whatfor'] = 'How would you like to apply the template?'; // Deprecated since Moodle 4.5. $string['public'] = 'Public'; + +// Deprecated since Moodle 5.2. +$string['selected_dump'] = 'Selected indexes of $SESSION variable are dumped below:'; diff --git a/public/mod/feedback/lib.php b/public/mod/feedback/lib.php index e78e473cff1..555ddfc8145 100644 --- a/public/mod/feedback/lib.php +++ b/public/mod/feedback/lib.php @@ -2745,16 +2745,6 @@ function feedback_extend_settings_navigation(settings_navigation $settings, navi } } -function feedback_init_feedback_session() { - //initialize the feedback-Session - not nice at all!! - global $SESSION; - if (!empty($SESSION)) { - if (!isset($SESSION->feedback) OR !is_object($SESSION->feedback)) { - $SESSION->feedback = new stdClass(); - } - } -} - /** * Return a list of page types * @param string $pagetype current page type