diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml index c7c76cd..90ec863 100644 --- a/.github/workflows/moodle-plugin-ci.yml +++ b/.github/workflows/moodle-plugin-ci.yml @@ -33,10 +33,10 @@ jobs: matrix: include: - php: 8.0 - moodle-branch: main + moodle-branch: master database: pgsql - php: 8.1 - moodle-branch: main + moodle-branch: master database: mariadb - php: 8.1 moodle-branch: MOODLE_401_STABLE diff --git a/bouncetest.php b/bouncetest.php index 79a75e7..64395d7 100755 --- a/bouncetest.php +++ b/bouncetest.php @@ -48,4 +48,4 @@ $bounceprocessor->testrun(); } -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/confirm.php b/confirm.php index 985d597..6c4acd7 100755 --- a/confirm.php +++ b/confirm.php @@ -43,7 +43,7 @@ if ($secret && $userid) { if (!$user = get_complete_user_data('id', $userid)) { - print_error("Cannot find user!"); + throw new \moodle_exception("Cannot find user!"); } if ($user->confirmed) { redirect(new moodle_url('/mod/newsletter/view.php', array('id' => $cm->id)), @@ -70,9 +70,9 @@ $welcomemessage, 15); // TODO: user/editadvanced.php?id=2. } else { - print_error('The link you followed is invalid.'); + throw new \moodle_exception('The link you followed is invalid.'); } } } else { - print_error('The link you followed is invalid.'); + throw new \moodle_exception('The link you followed is invalid.'); } diff --git a/db/events.php b/db/events.php index 5164b31..397b638 100644 --- a/db/events.php +++ b/db/events.php @@ -27,4 +27,4 @@ 'callback' => 'mod_newsletter_observer::user_deleted'), array('eventname' => '\core\event\user_enrolment_deleted', 'callback' => 'mod_newsletter_observer::user_enrolment_deleted') - ); \ No newline at end of file + ); diff --git a/db/uninstall.php b/db/uninstall.php deleted file mode 100755 index 6f0cfd8..0000000 --- a/db/uninstall.php +++ /dev/null @@ -1,33 +0,0 @@ -. - -/** - * @see uninstall_plugin() - * - * @package mod_newsletter - * @copyright 2013 Ivan Šakić - * @copyright 2015 onwards David Bogner - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * Custom uninstallation procedure - */ -function xmldb_newsletter_uninstall() { - return true; -} diff --git a/guest_signup_form.php b/guest_signup_form.php index 8d67dba..2da96b9 100755 --- a/guest_signup_form.php +++ b/guest_signup_form.php @@ -49,8 +49,6 @@ public function definition() { $mform->addElement('hidden', NEWSLETTER_PARAM_ACTION, $data[NEWSLETTER_PARAM_ACTION]); $mform->setType(NEWSLETTER_PARAM_ACTION, PARAM_ALPHANUM); - // $mform->addElement('html', '

' . get_string('guestsubscribe', 'mod_newsletter') . '

'); - $mform->addElement('text', 'firstname', get_string('firstname'), array('size' => '64')); $mform->setType('firstname', PARAM_TEXT); $mform->addRule('firstname', null, 'required', null, 'client'); @@ -88,7 +86,7 @@ public function validation($usernew, $files) { $usernew = (object) $usernew; $user = $DB->get_record('user', array('id' => $usernew->id)); - if (!$user or $user->email !== $usernew->email) { + if (!$user || $user->email !== $usernew->email) { if (!validate_email($usernew->email)) { $err['email'] = get_string('invalidemail'); } else if ($DB->record_exists('user', diff --git a/index.php b/index.php index c8344a2..f64e2d9 100755 --- a/index.php +++ b/index.php @@ -32,7 +32,7 @@ $id = required_param('id', PARAM_INT); if (!$course = $DB->get_record("course", array("id" => $id))) { - print_error('invalidcourseid'); + throw new \moodle_exception('invalidcourseid'); } require_login($course); diff --git a/lang/en/newsletter.php b/lang/en/newsletter.php index 6a75638..121ff1d 100644 --- a/lang/en/newsletter.php +++ b/lang/en/newsletter.php @@ -138,7 +138,7 @@ You have requested to be subscribed to \'{$a->newslettername}\' newsletter at \'{$a->sitename}\' -using this email address. +using this email address. Please confirm your subscription by clicking on the following link: diff --git a/mod_form.php b/mod_form.php index b4eeabd..903d26a 100644 --- a/mod_form.php +++ b/mod_form.php @@ -1,5 +1,4 @@ dirroot.'/course/moodleform_mod.php'); require_once($CFG->libdir . '/formslib.php'); - /** * Module instance settings form */ @@ -40,19 +40,7 @@ class mod_newsletter_mod_form extends moodleform_mod { */ public function definition() { global $CFG; - $mform = &$this->_form; - $data = &$this->_customdata; - - $newsletter = $data['newsletter']; - $issue = $data['issue']; - $context = $data['context']; - - $userfilter = $issue ? $issue->userfilter ?? null : null; - $newsletterid = $issue ? $issue->newsletterid : 0; - - $mform = $this->_form; - $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('newslettername', 'mod_newsletter'), @@ -89,7 +77,7 @@ public function definition() { $mform->addElement('header', 'header_profilefield', get_string('header_profilefield', 'mod_newsletter')); $mform->addElement('select', 'profilefield', - get_string('header_profilefield', 'mod_newsletter'), $this->cpf_list()); + get_string('header_profilefield', 'mod_newsletter'), $this->cpf_list()); $mform->addHelpButton('profilefield', 'help_profilefield', 'mod_newsletter'); $this->standard_coursemodule_elements(); @@ -101,21 +89,25 @@ public function definition() { file_prepare_draft_area($draftitemid, $this->context->id, 'mod_newsletter', NEWSLETTER_FILE_AREA_STYLESHEET, $newsletterid, array('subdirs' => NEWSLETTER_FILE_OPTIONS_SUBDIRS, 'maxbytes' => 0, - 'maxfiles' => -1)); + 'maxfiles' => -1)); $entry = new stdClass(); $entry->stylesheets = $draftitemid; parent::set_data($entry); } - public function cpf_list() { + /** + * Get custom profile fields as array. + * @return array + */ + public function cpf_list(): array { global $DB; $userprofilefieldsarray = []; $customuserprofilefields = $DB->get_records('user_info_field', ['datatype' => 'checkbox'], '', 'id, name, shortname'); - + if (!empty($customuserprofilefields)) { - + // Create an array of key => value pairs for the dropdown. foreach ($customuserprofilefields as $cpf) { $userprofilefieldsarray[$cpf->id] = $cpf->name; @@ -128,6 +120,10 @@ public function cpf_list() { return $userprofilefieldsarray; } + /** + * Return subscription modes. + * @return array + */ public function make_subscription_option_list() { $options = array(); $options[NEWSLETTER_SUBSCRIPTION_MODE_OPT_IN] = get_string('sub_mode_opt_in', @@ -139,6 +135,10 @@ public function make_subscription_option_list() { return $options; } + /** + * Returns cohort name and id as key. + * @return array + */ public function make_cohort_option_list() { $cohorts = cohort_get_cohorts($this->context->id); $options = array(); diff --git a/renderer.php b/renderer.php index 1916a0a..5c5d40d 100755 --- a/renderer.php +++ b/renderer.php @@ -22,9 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); - - /** * A custom renderer class that extends the plugin_renderer_base and is used by the newsletter * module. @@ -68,22 +65,11 @@ public function render_newsletter_form(newsletter_form $form) { /** * @param newsletter_section_list $sectionlist * @return string - * @throws coding_exception - * @throws moodle_exception */ public function render_newsletter_section_list(newsletter_section_list $sectionlist) { - $output = ''; - $output .= html_writer::start_tag('div', array('class' => 'mod_newsletter__section-list')); - /* - * // Temporarily unused - * $output .= html_writer::start_tag('h3'); - * $output .= $sectionlist->heading; - * $output .= html_writer::end_tag('h3'); - * // - */ - - $page = optional_param('page', 0, PARAM_INT); - $data = (array)$sectionlist->sections; + $output = html_writer::start_tag('div', array('class' => 'mod_newsletter__section-list')); + $page = optional_param('page', 0, PARAM_INT); + $data = (array) $sectionlist->sections; $totalcount = count($data); $baseurl = newsletter_get_baseurl(); $perpage = 5; @@ -103,10 +89,14 @@ public function render_newsletter_section_list(newsletter_section_list $sectionl return $output; } + /** + * Render section. + * + * @param newsletter_section $section + * @return string + */ public function render_newsletter_section(newsletter_section $section) { - $output = ''; - - $output .= html_writer::start_tag('div', array('class' => 'mod_newsletter__section')); + $output = html_writer::start_tag('div', array('class' => 'mod_newsletter__section')); $output .= html_writer::start_tag('h3'); $output .= $section->heading; $output .= html_writer::end_tag('h3'); @@ -116,10 +106,14 @@ public function render_newsletter_section(newsletter_section $section) { return $output; } + /** + * Render list. + * + * @param newsletter_issue_summary_list $list + * @return string + */ public function render_newsletter_issue_summary_list(newsletter_issue_summary_list $list) { - $output = ''; - - $output .= html_writer::start_tag('div', array('class' => 'mod_newsletter__issue-list')); + $output = html_writer::start_tag('div', array('class' => 'mod_newsletter__issue-list')); $output .= html_writer::start_tag('ul'); foreach ($list->issues as $issue) { $output .= html_writer::start_tag('li'); @@ -132,33 +126,44 @@ public function render_newsletter_issue_summary_list(newsletter_issue_summary_li return $output; } + /** + * Render issue. + * + * @param newsletter_issue $issue + * @return string + */ public function render_newsletter_issue(newsletter_issue $issue) { - $output = ''; - $output .= html_writer::start_tag('div', + $output = html_writer::start_tag('div', array('class' => 'mod_newsletter__issue--full__container')); $output .= $issue->htmlcontent; $output .= html_writer::end_tag('div'); return $output; } + /** + * Render issue summary + * + * @param newsletter_issue_summary $issue + * @return string + */ public function render_newsletter_issue_summary(newsletter_issue_summary $issue) { - global $OUTPUT, $CFG; + global $CFG; $link = ''; if ($CFG->branch >= 33) { - $link .= $OUTPUT->image_icon('icon', '', 'mod_newsletter', + $link .= $this->output->image_icon('icon', '', 'mod_newsletter', array('class' => 'mod_newsletter__issue--summary__link-read-icon')); } else { $link .= html_writer::empty_tag('img', array('src' => $this->output->pix_url('icon', 'mod_newsletter'), - 'class' => 'mod_newsletter__issue--summary__link-read-icon')); + 'class' => 'mod_newsletter__issue--summary__link-read-icon')); } $link .= html_writer::start_tag('span'); $link .= $issue->title . " (" . userdate($issue->publishon, '%d %B %Y') . ")"; $link .= html_writer::end_tag('span'); $url = new moodle_url('/mod/newsletter/view.php', array('id' => $issue->cmid, 'action' => NEWSLETTER_ACTION_READ_ISSUE, - 'issue' => $issue->id)); + 'issue' => $issue->id)); $now = time(); $output = html_writer::start_tag('div', array('class' => 'mod_newsletter__issue--summary')); @@ -196,11 +201,11 @@ public function render_newsletter_issue_summary(newsletter_issue_summary $issue) $output .= $this->render( new newsletter_progressbar($issue->numnotyetdelivered, $issue->numdelivered)); } - + if ($issue->duplicateissue) { - $output .= $this->render( - new newsletter_progressbar($issue->numnotyetdelivered, $issue->numdelivered)); - } + $output .= $this->render( + new newsletter_progressbar($issue->numnotyetdelivered, $issue->numdelivered)); + } } else { $output .= $this->render(new newsletter_publish_countdown($now, $issue->publishon)); } @@ -218,7 +223,7 @@ public function render_newsletter_navigation_bar(newsletter_navigation_bar $navi $url = new moodle_url('/mod/newsletter/view.php'); if (!empty($navigationbar->firstissue)) { $urlparams = array('id' => $navigationbar->currentissue->cmid, - 'action' => NEWSLETTER_ACTION_READ_ISSUE, 'issue' => $navigationbar->firstissue->id); + 'action' => NEWSLETTER_ACTION_READ_ISSUE, 'issue' => $navigationbar->firstissue->id); $link = html_writer::link(new moodle_url($url, $urlparams), '', array('class' => 'mod-newsletter__navigation-bar__button--first')); } @@ -226,8 +231,8 @@ public function render_newsletter_navigation_bar(newsletter_navigation_bar $navi $firstissuelink = $navigationbar->firstissue ? $link : ''; if (!empty($navigationbar->previousissue)) { $urlparams = array('id' => $navigationbar->currentissue->cmid, - 'action' => NEWSLETTER_ACTION_READ_ISSUE, - 'issue' => $navigationbar->previousissue->id); + 'action' => NEWSLETTER_ACTION_READ_ISSUE, + 'issue' => $navigationbar->previousissue->id); $link = html_writer::link(new moodle_url($url, $urlparams), '', array('class' => 'mod-newsletter__navigation-bar__button--previous')); } @@ -235,7 +240,7 @@ public function render_newsletter_navigation_bar(newsletter_navigation_bar $navi $previousissuelink = $navigationbar->previousissue ? $link : ''; if (!empty($navigationbar->nextissue)) { $urlparams = array('id' => $navigationbar->currentissue->cmid, - 'action' => NEWSLETTER_ACTION_READ_ISSUE, 'issue' => $navigationbar->nextissue->id); + 'action' => NEWSLETTER_ACTION_READ_ISSUE, 'issue' => $navigationbar->nextissue->id); $link = html_writer::link(new moodle_url($url, $urlparams), '', array('class' => 'mod-newsletter__navigation-bar__button--next')); } @@ -243,14 +248,13 @@ public function render_newsletter_navigation_bar(newsletter_navigation_bar $navi $nextissuelink = $navigationbar->nextissue ? $link : ''; if (!empty($navigationbar->lastissue)) { $urlparams = array('id' => $navigationbar->currentissue->cmid, - 'action' => NEWSLETTER_ACTION_READ_ISSUE, 'issue' => $navigationbar->lastissue->id); + 'action' => NEWSLETTER_ACTION_READ_ISSUE, 'issue' => $navigationbar->lastissue->id); $link = html_writer::link(new moodle_url($url, $urlparams), '', array('class' => 'mod-newsletter__navigation-bar__button--last')); } $lastissuelink = $navigationbar->lastissue ? $link : ''; - $output = ''; - $output .= html_writer::start_tag('div', + $output = html_writer::start_tag('div', array('class' => 'mod-newsletter__navigation-bar__container')); $output .= html_writer::start_tag('div', array('class' => 'mod-newsletter__navigation-bar')); $output .= $firstissuelink; @@ -275,7 +279,7 @@ public function render_newsletter_action_button(newsletter_action_button $button if ($button->issueid !== 0) { $url = new moodle_url('/mod/newsletter/view.php', array('id' => $button->cmid, 'action' => $button->action, - 'issue' => $button->issueid)); + 'issue' => $button->issueid)); } else { $url = new moodle_url('/mod/newsletter/view.php', array('id' => $button->cmid, 'action' => $button->action)); @@ -287,13 +291,11 @@ public function render_newsletter_action_button(newsletter_action_button $button } public function render_newsletter_main_toolbar(newsletter_main_toolbar $toolbar) { - global $CFG; - $output = html_writer::start_tag('div', ['class' => 'newsletter-toolbar']); $output .= html_writer::tag('div', get_string('groupby', 'mod_newsletter')); $options = array(NEWSLETTER_GROUP_ISSUES_BY_YEAR => get_string('year'), - NEWSLETTER_GROUP_ISSUES_BY_MONTH => get_string('month'), - NEWSLETTER_GROUP_ISSUES_BY_WEEK => get_string('week')); + NEWSLETTER_GROUP_ISSUES_BY_MONTH => get_string('month'), + NEWSLETTER_GROUP_ISSUES_BY_WEEK => get_string('week')); $output .= html_writer::start_div('newsletter-toolbar'); $output .= html_writer::start_tag('form', array('method' => 'GET', 'action' => new moodle_url('/mod/newsletter/view.php'))); @@ -301,7 +303,7 @@ public function render_newsletter_main_toolbar(newsletter_main_toolbar $toolbar) array('type' => 'hidden', 'name' => 'id', 'value' => $toolbar->cmid)); $output .= html_writer::select($options, NEWSLETTER_PARAM_GROUP_BY, $toolbar->groupby, false); $output .= html_writer::empty_tag('input', - array('type' => 'submit', 'value' => get_string('refresh'), 'class' => 'btn btn-secondary m-2')); + array('type' => 'submit', 'value' => get_string('refresh'), 'class' => 'btn btn-secondary m-2')); $output .= html_writer::end_tag('form'); $output .= html_writer::end_div(); if ($toolbar->createissues) { @@ -324,7 +326,7 @@ public function render_newsletter_main_toolbar(newsletter_main_toolbar $toolbar) * * @return string */ - public function render_footer(): string { + public function render_footer() { return $this->output->footer(); } @@ -335,12 +337,10 @@ public function render_footer(): string { * @return string HTML of the form */ public function moodleform(moodleform $mform) { - $output = ''; ob_start(); $mform->display(); $output = ob_get_contents(); ob_end_clean(); - return $output; } @@ -366,14 +366,18 @@ public function render_newsletter_progressbar(newsletter_progressbar $progressba $output .= html_writer::start_tag('div', array('class' => 'progress')); $output .= html_writer::div($completed, '', array('class' => 'progress-bar', 'role' => 'progressbar', - 'aria-valuenow' => $value, 'aria-valuemin' => '0', 'aria-valuemax' => '100', - 'style' => 'width:' . $value . '%')); + 'aria-valuenow' => $value, 'aria-valuemin' => '0', 'aria-valuemax' => '100', + 'style' => 'width:' . $value . '%')); $output .= html_writer::end_tag('div'); return $output; } + /** + * @param newsletter_subscription_list $list + * @return string + */ public function render_newsletter_subscription_list(newsletter_subscription_list $list) { - global $OUTPUT, $CFG; + global $CFG; $table = new html_table(); @@ -399,7 +403,7 @@ public function render_newsletter_subscription_list(newsletter_subscription_list $content = get_string('header_actions', 'mod_newsletter'); break; default: - print_error('Unsupported column type: ' . $column); + throw new \moodle_exception('Unsupported column type: ' . $column, 'mod_newsletter'); break; } $cell = new html_table_cell($content); @@ -438,37 +442,37 @@ public function render_newsletter_subscription_list(newsletter_subscription_list case NEWSLETTER_SUBSCRIPTION_LIST_COLUMN_ACTIONS: $url = new moodle_url('/mod/newsletter/view.php', array(NEWSLETTER_PARAM_ID => $list->cmid, - NEWSLETTER_PARAM_ACTION => NEWSLETTER_ACTION_EDIT_SUBSCRIPTION, - NEWSLETTER_PARAM_SUBSCRIPTION => $subscription->id)); + NEWSLETTER_PARAM_ACTION => NEWSLETTER_ACTION_EDIT_SUBSCRIPTION, + NEWSLETTER_PARAM_SUBSCRIPTION => $subscription->id)); if ($CFG->branch >= 33) { $content = \html_writer::link($url, - $OUTPUT->image_icon('t/edit', get_string('edit')), + $this->output->image_icon('t/edit', get_string('edit')), array('class' => 'editbutton', 'title' => get_string('edit'))); } else { $content = \html_writer::link($url, \html_writer::empty_tag('img', - array('src' => $OUTPUT->pix_url('t/edit'))), + array('src' => $this->output->pix_icon('t/edit'))), array('class' => 'editbutton', 'title' => get_string('edit'))); } $url = new \moodle_url('/mod/newsletter/view.php', array(NEWSLETTER_PARAM_ID => $list->cmid, - NEWSLETTER_PARAM_ACTION => NEWSLETTER_ACTION_DELETE_SUBSCRIPTION, - NEWSLETTER_PARAM_SUBSCRIPTION => $subscription->id)); + NEWSLETTER_PARAM_ACTION => NEWSLETTER_ACTION_DELETE_SUBSCRIPTION, + NEWSLETTER_PARAM_SUBSCRIPTION => $subscription->id)); if ($CFG->branch >= 33) { $content .= \html_writer::link($url, - $OUTPUT->image_icon('t/delete', get_string('delete')), + $this->output->image_icon('t/delete', get_string('delete')), array('class' => 'deletebutton', - 'title' => get_string('delete'))); + 'title' => get_string('delete'))); } else { $content .= \html_writer::link($url, \html_writer::empty_tag('img', - array('src' => $OUTPUT->pix_url('t/delete'))), + array('src' => $this->output->pix_icon('t/delete'))), array('class' => 'deletebutton', - 'title' => get_string('delete'))); + 'title' => get_string('delete'))); } break; default: - print_error('Unsupported column type: ' . $column); + throw new \moodle_exception('Unsupported column type: ' . $column); break; } $cell = new html_table_cell($content); @@ -487,8 +491,7 @@ public function render_newsletter_subscription_list(newsletter_subscription_list * @throws coding_exception */ public function render_newsletter_publish_countdown(newsletter_publish_countdown $countdown) { - $output = ''; - $output .= html_writer::start_tag('span'); + $output = html_writer::start_tag('span'); if ($countdown->now > $countdown->until) { $output .= get_string('already_published', 'mod_newsletter'); } else { @@ -532,8 +535,7 @@ public function render_newsletter_pager(newsletter_pager $pager) { $previouspage = ($from - $pager->count >= $pager->count) ? $from - $pager->count : $firstpage; $nextpage = ($from + $pager->count <= $lastpage) ? $from + $pager->count : $lastpage; - $output = ''; - $output .= html_writer::start_tag('div', array('class' => 'mod_newsletter__pager')); + $output = html_writer::start_tag('div', array('class' => 'mod_newsletter__pager')); $output .= html_writer::span(get_string('allusers', 'mod_newsletter') . $pager->totalentries); $output .= html_writer::span( get_string('filteredusers', 'mod_newsletter') . $pager->totalfiltered); @@ -602,17 +604,15 @@ public function render_newsletter_pager(newsletter_pager $pager) { } public function render_newsletter_attachment_list(newsletter_attachment_list $list) { - global $OUTPUT; - $output = ''; - $output .= html_writer::start_tag('div', array( - 'class' => 'mod_newsletter__attachment_list')); + $output = html_writer::start_tag('div', array( + 'class' => 'mod_newsletter__attachment_list')); $output .= html_writer::start_tag('h3'); $output .= get_string('attachments', 'mod_newsletter'); $output .= html_writer::end_tag('h3'); $output .= html_writer::start_tag('ul'); foreach ($list->files as $file) { $output .= html_writer::start_tag('li'); - $iconimage = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), + $iconimage = $this->output->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')); $output .= html_writer::link($file->link, $iconimage . " " . $file->get_filename()); $output .= html_writer::end_tag('li'); @@ -623,9 +623,8 @@ public function render_newsletter_attachment_list(newsletter_attachment_list $li } public function render_newsletter_attachment_list_empty() { - $output = ''; - $output .= html_writer::start_tag('div', array( - 'class' => 'mod_newsletter__attachment_list')); + $output = html_writer::start_tag('div', array( + 'class' => 'mod_newsletter__attachment_list')); $output .= html_writer::start_tag('h3'); $output .= get_string('attachments_no', 'mod_newsletter'); $output .= html_writer::end_tag('h3'); @@ -634,10 +633,9 @@ public function render_newsletter_attachment_list_empty() { } public function render_newsletter_action_link(newsletter_action_link $link) { - $output = ''; - $output .= html_writer::start_tag('span'); + $output = html_writer::start_tag('span'); $output .= html_writer::link($link->url, $link->text, array('class' => $link->class)); $output .= html_writer::end_tag('span'); return $output; } -} \ No newline at end of file +} diff --git a/subscribe.php b/subscribe.php index 33f3495..887d719 100755 --- a/subscribe.php +++ b/subscribe.php @@ -41,7 +41,7 @@ redirect(new moodle_url('/mod/newsletter/view.php', array('id' => $id)), "The creation of your account was cancelled at your request!", 5); } else { - print_error('The link you followed is invalid.'); + throw new \moodle_exception('The link you followed is invalid.', 'mod_newsletter'); } } } else { @@ -109,7 +109,7 @@ } else if ($confirm == NEWSLETTER_CONFIRM_NO) { redirect(new moodle_url('/mod/newsletter/view.php', array('id' => $id))); } else { - print_error('Wrong ' . NEWSLETTER_PARAM_CONFIRM . ' code: ' . $confirm . '!'); + throw new \moodle_exception('Wrong ' . NEWSLETTER_PARAM_CONFIRM . ' code: ' . $confirm . '!'); } } else { require_capability('mod/newsletter:viewnewsletter', $context); @@ -130,7 +130,8 @@ } else if ($confirm == NEWSLETTER_CONFIRM_NO) { redirect(new moodle_url('/mod/newsletter/view.php', array('id' => $id))); } else { - print_error('Wrong ' . NEWSLETTER_PARAM_CONFIRM . ' code: ' . $confirm . '!'); + throw new \moodle_exception('Wrong ' . NEWSLETTER_PARAM_CONFIRM . ' code: ' . $confirm . '!', + 'mod_newsletter'); } } diff --git a/version.php b/version.php index 66343ab..b4b1bf2 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023071307; // If version == 0 then module will not be installed -$plugin->requires = 2020061500; // Requires this Moodle version -$plugin->maturity = MATURITY_STABLE; // Maturity -$plugin->release = 'v2.3.4-NewYorkTimes'; // Already used names: Der Standard, Le Monde Diplomatique -$plugin->component = 'mod_newsletter'; // To check on upgrade, that module sits in correct place +$plugin->version = 2023071307; +$plugin->requires = 2020061500; +$plugin->maturity = MATURITY_STABLE; +$plugin->release = 'v2.3.5-NewYorkTimes'; // Already used names: Der Standard, Le Monde Diplomatique. +$plugin->component = 'mod_newsletter';