From de7a95ab343bcf382b429710f04a14805d64cb9d Mon Sep 17 00:00:00 2001
From: Elke Kreim <elke.kreim@hs-hannover.de>
Date: Thu, 22 Dec 2022 11:34:33 +0100
Subject: [PATCH] Clean code according to code checker

---
 block_hshcourselist.php         | 14 +++++++++-----
 classes/privacy/provider.php    |  4 +---
 db/access.php                   |  4 +++-
 edit_form.php                   |  2 +-
 hshcourselist.php               |  3 ++-
 lang/en/block_hshcourselist.php |  2 +-
 version.php                     |  2 +-
 7 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/block_hshcourselist.php b/block_hshcourselist.php
index 2c43a94..40e3041 100644
--- a/block_hshcourselist.php
+++ b/block_hshcourselist.php
@@ -23,7 +23,6 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-defined('MOODLE_INTERNAL') || die();
 class block_hshcourselist extends block_base {
     private $globalconf;
     public function init() {
@@ -71,7 +70,12 @@ class block_hshcourselist extends block_base {
         $anchor = html_writer::tag('a', '', array('name' => 'hshcourselistanchor'));
 
         $ordercheckbox = html_writer::empty_tag('input',
-            array('type' => 'checkbox', 'name' => 'orderbysemestercheckbox', 'id' => 'orderbysemestercheckbox_id', 'checked' => 'true'));
+            array(
+                'type' => 'checkbox',
+                'name' => 'orderbysemestercheckbox',
+                'id' => 'orderbysemestercheckbox_id',
+                'checked' => 'true')
+        );
         $ordercheckbox .= html_writer::start_tag('label', array('for' => 'orderbysemestercheckbox_id'));
         $ordercheckbox .= get_string('orderbysemester', 'block_hshcourselist');
         $ordercheckbox .= html_writer::end_tag('label');
@@ -207,8 +211,8 @@ class block_hshcourselist extends block_base {
         return $this->content;
     }
 
-    public static function get_courses($search, $blockcontext, $splitterms = false,
-                                       $restrictcontext = false, $pagecontext = null, $idsearch, $orderbysemester) {
+    public static function get_courses($search, $blockcontext, $idsearch, $orderbysemester, $splitterms = false,
+                                       $restrictcontext = false, $pagecontext = null) {
         global $DB;
         $params = array(SITEID);
         $keywordarray = explode(" ", $search);
@@ -266,4 +270,4 @@ class block_hshcourselist extends block_base {
         $courses = $DB->get_recordset_select('course', $where, $params, $order, $fields);
         return $courses;
     }
-}
\ No newline at end of file
+}
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index 2b36edf..8e0e758 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -25,8 +25,6 @@
 
 namespace block_hshcourselist\privacy;
 
-defined('MOODLE_INTERNAL') || die();
-
 /**
  * Privacy Subsystem for block_course_list implementing null_provider.
  *
@@ -44,4 +42,4 @@ class provider implements \core_privacy\local\metadata\null_provider {
     public static function get_reason() : string {
         return 'privacy:metadata';
     }
-}
\ No newline at end of file
+}
diff --git a/db/access.php b/db/access.php
index 2386f46..6fa9c89 100644
--- a/db/access.php
+++ b/db/access.php
@@ -22,6 +22,8 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+defined('MOODLE_INTERNAL') || die();
+
 $capabilities = array(
 
     'block/hshcourselist:myaddinstance' => array(
@@ -46,4 +48,4 @@ $capabilities = array(
 
         'clonepermissionsfrom' => 'moodle/site:manageblocks'
     ),
-);
\ No newline at end of file
+);
diff --git a/edit_form.php b/edit_form.php
index 806d205..90dcb91 100644
--- a/edit_form.php
+++ b/edit_form.php
@@ -55,4 +55,4 @@ class block_hshcourselist_edit_form extends block_edit_form {
         $mform->addElement('text', 'config_footer', get_string('blockfooter', 'block_hshcourselist'));
         $mform->setType('config_footer', PARAM_RAW);
     }
-}
\ No newline at end of file
+}
diff --git a/hshcourselist.php b/hshcourselist.php
index 4c0a0c6..597aeb8 100644
--- a/hshcourselist.php
+++ b/hshcourselist.php
@@ -27,6 +27,7 @@
 require_once('../../config.php');
 require_once($CFG->dirroot . '/blocks/moodleblock.class.php');
 require_once($CFG->dirroot . '/blocks/hshcourselist/block_hshcourselist.php');
+require_login();
 $instanceid = required_param('instanceid', PARAM_INT);
 $context = context_block::instance($instanceid);
 $course = required_param('course', PARAM_TEXT);
@@ -57,4 +58,4 @@ function utf8ize($d) {
         return utf8_encode($d);
     }
     return $d;
-}
\ No newline at end of file
+}
diff --git a/lang/en/block_hshcourselist.php b/lang/en/block_hshcourselist.php
index 85aa8ac..1d55472 100644
--- a/lang/en/block_hshcourselist.php
+++ b/lang/en/block_hshcourselist.php
@@ -61,4 +61,4 @@ $string["hsh_search_help"] = 'Die Kurssuche ist eine Volltextsuche in der Sie au
 Verschiedene Suchbegriffe werden einzeln in den Kursnamen gesucht und dann eine vollständige Liste angezeigt.
 Bsp: WiSe Programmieren => zeigt Ihnen alle Kurse, dessen Kursname oder Kurskurzname "WiSe" ODER "Programmieren" enthalten.
 Kurzsuche: Möchten Sie einen Kurs schnell über die "id" finden, so können Sie dies durch das Voranstellen einer Raute "#" erreichen.
-Bsp: #3303 zeigt Ihnen den Kurs "Moodle Demo-Kurs, ELC"';
\ No newline at end of file
+Bsp: #3303 zeigt Ihnen den Kurs "Moodle Demo-Kurs, ELC"';
diff --git a/version.php b/version.php
index cfbba12..d5db790 100644
--- a/version.php
+++ b/version.php
@@ -26,6 +26,6 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->version = 2022122000;
-$plugin->requires = 2022112800.00 ; // Moodle 4.1
+$plugin->requires = 2022112800.00;  // Moodle 4.1.
 $plugin->component = 'block_hshcourselist';
 $plugin->release = 'hsh_v4.1.0';
-- 
GitLab