From 71ac1fdf07263acff5e22c94fd7a34b09cf526c8 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Fri, 16 Jul 2021 19:42:42 +0430 Subject: [PATCH 01/76] Add a simple db/access.php file, for adding and viewing instances --- db/access.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 db/access.php diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..075f909 --- /dev/null +++ b/db/access.php @@ -0,0 +1,29 @@ + [ + 'riskbitmask' => RISK_XSS, + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => [ + 'manager' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + ], + 'clonepermissionsfrom' => 'moodle/course:manageactivities', + ], + + // Ability to view instances, regardless of the type + 'mod/gharar:view_instance' => [ + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'archetypes' => [ + 'student' => CAP_ALLOW, + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ] + ], +]; From e63f9afe631707362347a21d5c01ae36221832f9 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Fri, 16 Jul 2021 20:37:51 +0430 Subject: [PATCH 02/76] Add DB structure into db/install.xml with minimal fields --- db/install.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 db/install.xml diff --git a/db/install.xml b/db/install.xml new file mode 100644 index 0000000..6b0d653 --- /dev/null +++ b/db/install.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + +
+
+
From d847f3c1efcb0103419641b7019c29c133af91f3 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sat, 17 Jul 2021 15:54:12 +0430 Subject: [PATCH 03/76] Add simple index.php to only bring an empty view --- index.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..bc41346 --- /dev/null +++ b/index.php @@ -0,0 +1,24 @@ +get_record('course', ['id' => $courseId], '*', MUST_EXIST); + +require_login($course); + +// TODO: Make these more dynamic, e.g. use get_string for set_title +$PAGE->set_url('/mod/gharar/index.php', ['id' => $courseId]); +$PAGE->set_title('Gharar'); +$PAGE->set_heading($course->fullname); +$PAGE->set_cacheable(false); +$PAGE->set_pagelayout('incourse'); + +$PAGE->navbar->add($PAGE->title, $PAGE->url); + +// TODO: Add a rendered to show all the meetings +echo $OUTPUT->header(); +echo $OUTPUT->heading('Gharar meetings'); +echo $OUTPUT->footer(); From 4df1736b87530dd70a7ee295fcd37124c37039e9 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sat, 17 Jul 2021 17:36:59 +0430 Subject: [PATCH 04/76] Add a simple view.php without bringing main functionality (dummy) --- view.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 view.php diff --git a/view.php b/view.php new file mode 100644 index 0000000..7c01653 --- /dev/null +++ b/view.php @@ -0,0 +1,19 @@ +get_record('course', ['id' => $courseId], '*', MUST_EXIST); + +require_login($course); + +// TODO: +$PAGE->set_url('/mod/gharar/view.php', ['id' => $courseId]); +$PAGE->set_title('Gharar meeting'); +$PAGE->set_heading($course->fullname); +$PAGE->set_cacheable(false); + +echo $OUTPUT->header(); +echo $OUTPUT->heading('Gharar meeting'); +echo $OUTPUT->footer(); From d5867172d322e7f1afb02782db8d72970c1ea03d Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sat, 17 Jul 2021 17:48:52 +0430 Subject: [PATCH 05/76] Add a few strings in Persian in lang/fa/gharar.php --- lang/fa/gharar.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lang/fa/gharar.php diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php new file mode 100644 index 0000000..6e20e9e --- /dev/null +++ b/lang/fa/gharar.php @@ -0,0 +1,8 @@ + Date: Sun, 18 Jul 2021 13:45:34 +0430 Subject: [PATCH 06/76] Add util::forbid_access_if_not_from_moodle, and use it in two files Using a function is a better idea than plain code. --- classes/util.php | 13 +++++++++++++ db/access.php | 4 +++- version.php | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 classes/util.php diff --git a/classes/util.php b/classes/util.php new file mode 100644 index 0000000..f1079f9 --- /dev/null +++ b/classes/util.php @@ -0,0 +1,13 @@ +component = "mod_gharar"; $plugin->version = 2021071600; From 54e2c1d8f5aa530d04bb9c08c136ade894ab393f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 14:39:29 +0430 Subject: [PATCH 07/76] Add moodle_vars class for accessing global variables provided by moodle Using globals directly should not be a good idea. Wrapping it inside a class is cleaner and better to work with. --- classes/moodle_vars.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 classes/moodle_vars.php diff --git a/classes/moodle_vars.php b/classes/moodle_vars.php new file mode 100644 index 0000000..628eb56 --- /dev/null +++ b/classes/moodle_vars.php @@ -0,0 +1,34 @@ +database = $DB; + $this->config = $CFG; + $this->output = $OUTPUT; + } + + public function getDatabase() + { + return $this->database; + } + + public function getConfig() + { + return $this->config; + } + + public function getOutput() + { + return $this->output; + } +} From 88322ff89086e23345bb0fae339b9ee461effeaf Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 15:11:54 +0430 Subject: [PATCH 08/76] Add plugin class to hold plugin info, add util::get_string util::get_string eliminates the use of plugin-name as the second argument. --- classes/plugin.php | 8 ++++++++ classes/util.php | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 classes/plugin.php diff --git a/classes/plugin.php b/classes/plugin.php new file mode 100644 index 0000000..bb686dd --- /dev/null +++ b/classes/plugin.php @@ -0,0 +1,8 @@ + Date: Sun, 18 Jul 2021 15:35:03 +0430 Subject: [PATCH 09/76] Add mod_form.php with some new related language strings --- lang/fa/gharar.php | 3 +++ mod_form.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 mod_form.php diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index 6e20e9e..512e01b 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -6,3 +6,6 @@ $string['plugin_name'] = 'قرار'; $string['plugin_name_plural'] = "{$_pluginName}ها"; + +$string['meeting_name'] = 'نام'; +$string['meeting_link'] = 'پیوند'; diff --git a/mod_form.php b/mod_form.php new file mode 100644 index 0000000..283b235 --- /dev/null +++ b/mod_form.php @@ -0,0 +1,44 @@ +dirroot}/course/moodleform_mod.php"; + +class mod_gharar_mod_form extends moodleform_mod +{ + private $moodle; + + public function __construct($current, $section, $courseModule, $course) + { + $this->moodle = new moodle_vars(); + + parent::__construct($current, $section, $courseModule, $course); + } + + public function definition() + { + $this->add_name_field(); + $this->add_link_field(); + } + + private function add_name_field() + { + $this->_form->addElement('text', 'name', util::get_string( + 'meeting_name' + ), ['size' => 256]); + $this->_form->setType('name', PARAM_TEXT); + $this->_form->addRule('name', null, 'required', null, 'client'); + } + + private function add_link_field() + { + $this->_form->addElement('text', 'link', util::get_string( + 'meeting_link' + ), ['size' => 512]); + $this->_form->setType('link', PARAM_TEXT); + $this->_form->addRule('name', null, 'required', null, 'client'); + } +} From 0829d7873e0cdca1b8ddc8b5bb67c763ca519df5 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 19:44:54 +0430 Subject: [PATCH 10/76] Make moodle_vars singleton, remove some its useless usages --- classes/moodle_vars.php | 19 +++++++++++++++---- mod_form.php | 9 --------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/classes/moodle_vars.php b/classes/moodle_vars.php index 628eb56..b0be28e 100644 --- a/classes/moodle_vars.php +++ b/classes/moodle_vars.php @@ -4,11 +4,13 @@ class moodle_vars { + private static $instance = null; + private $database; private $config; private $output; - public function __construct() + private function __construct() { global $DB, $CFG, $OUTPUT; @@ -17,17 +19,26 @@ public function __construct() $this->output = $OUTPUT; } - public function getDatabase() + public static function get_instance() + { + if ($this->instance === null) { + $this->instance = new self(); + } + + return $this->instance; + } + + public function get_database() { return $this->database; } - public function getConfig() + public function get_config() { return $this->config; } - public function getOutput() + public function get_output() { return $this->output; } diff --git a/mod_form.php b/mod_form.php index 283b235..a988865 100644 --- a/mod_form.php +++ b/mod_form.php @@ -9,15 +9,6 @@ class mod_gharar_mod_form extends moodleform_mod { - private $moodle; - - public function __construct($current, $section, $courseModule, $course) - { - $this->moodle = new moodle_vars(); - - parent::__construct($current, $section, $courseModule, $course); - } - public function definition() { $this->add_name_field(); From b9a61dcb55c4f790d8a5ba08b830f82d8fe16d46 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 20:05:36 +0430 Subject: [PATCH 11/76] Update XMLDB to include link field as well, remove intro field --- db/install.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/install.xml b/db/install.xml index 6b0d653..94331f2 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,5 +1,5 @@ - - + From ae3ba89a30aa83f1ebb5d939af29b59d470906e1 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 20:13:35 +0430 Subject: [PATCH 12/76] Add gharar_*_instance() functions in lib.php --- lib.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib.php diff --git a/lib.php b/lib.php new file mode 100644 index 0000000..cc5dfb3 --- /dev/null +++ b/lib.php @@ -0,0 +1,38 @@ +get_database()->insert_record('gharar', $ghararRecordData); + + return $id; +} + +function gharar_update_instance($ghararRecord) +{ + $moodle = moodle_vars::get_instance(); + + $id = $moodle->get_database()->update_record('gharar', $ghararRecordData); + + return true; +} + +function gharar_delete_instance($recordId) +{ + $moodle = moodle_vars::get_instance(); + + if (!$moodle->get_database()->get_record('gharar', ['id' => $recordId])) { + return false; + } + + if (!$moodle->get_database()->delete_records('gharar', ['id' => $recordId])) { + $result = false; + } + return true; +} From 3eec0a8b42ae38f72fe91bcf907abffa7c6b14d4 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 20:56:22 +0430 Subject: [PATCH 13/76] Add lazy table view of the links of Gharar available in a course --- index.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index bc41346..b3e7ca0 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,8 @@ set_url('/mod/gharar/index.php', ['id' => $courseId]); -$PAGE->set_title('Gharar'); +$PAGE->set_title(util::get_string('plugin_name_plural')); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); $PAGE->set_pagelayout('incourse'); @@ -20,5 +23,28 @@ // TODO: Add a rendered to show all the meetings echo $OUTPUT->header(); -echo $OUTPUT->heading('Gharar meetings'); +echo $OUTPUT->heading(util::get_string('plugin_name_plural')); + +// TODO: Wrap it inside a renderable +$table = new html_table(); +$table->attributes['class'] = 'generaltable mod_index'; + +$table->head = [util::get_string('meeting_name'), util::get_string('meeting_link')]; +$table->align = ['center', 'center']; + +$instances = moodle_vars::get_instance()->get_database()->get_records('gharar', [ + 'course' => $courseId +]); + +foreach ($instances as $instace) { + $row = [ + html_writer::link(new moodle_url('view.php', ['id' => $courseId], $instance->name)), + $instance->link, + ]; + + $table->data[] = $row; +} + +echo html_writer::table($table); + echo $OUTPUT->footer(); From d4df02f100251b0205e9a6f65c7985cf19251a17 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 21:07:16 +0430 Subject: [PATCH 14/76] View Gharar meetings in view.php as a one-column table --- view.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/view.php b/view.php index 7c01653..ab3f26a 100644 --- a/view.php +++ b/view.php @@ -1,5 +1,7 @@ set_url('/mod/gharar/view.php', ['id' => $courseId]); -$PAGE->set_title('Gharar meeting'); +$PAGE->set_title(util::get_string('plugin_name_plural')); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); echo $OUTPUT->header(); -echo $OUTPUT->heading('Gharar meeting'); +echo $OUTPUT->heading(util::get_string('plugin_name_plural')); + +$table = new html_table(); +$table->attributes['class'] = 'generaltable mod_index'; + +$table->head = [util::get_string('meeting_name')]; +$table->align = ['center']; + +$instances = moodle_vars::get_instance()->get_database()->get_records('gharar', [ + 'course' => $courseId +]); + +foreach ($instances as $instace) { + $row = [ + html_writer::link($instance->name, $instance->link) + ]; + + $table->data[] = $row; +} + +echo html_writer::table($table); + echo $OUTPUT->footer(); From 50f3da6351cab6df34c05f816957cff4d04490f7 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 21:18:44 +0430 Subject: [PATCH 15/76] Add English language support --- lang/en/gharar.php | 13 +++++++++++++ lang/fa/gharar.php | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 lang/en/gharar.php diff --git a/lang/en/gharar.php b/lang/en/gharar.php new file mode 100644 index 0000000..b104ceb --- /dev/null +++ b/lang/en/gharar.php @@ -0,0 +1,13 @@ + Date: Sun, 18 Jul 2021 21:19:36 +0430 Subject: [PATCH 16/76] Bump plugin version --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 55e6772..422b754 100644 --- a/version.php +++ b/version.php @@ -5,4 +5,4 @@ util::forbid_access_if_not_from_moodle(); $plugin->component = "mod_gharar"; -$plugin->version = 2021071600; +$plugin->version = 2021071601; From ec44a2835e4479582742e39eb26afdf79d7523de Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 23:03:01 +0430 Subject: [PATCH 17/76] Add a shell script to build the zip for deployment --- build-zip.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 build-zip.sh diff --git a/build-zip.sh b/build-zip.sh new file mode 100755 index 0000000..88149c3 --- /dev/null +++ b/build-zip.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Config +# Create a temporary directory to prevent conflictions +tmpDirname='.tmp' +pluginName='gharar' +outputFilename='moodle-mod-gharar.zip' + +mainRepoDir="$(pwd)" +tmpDir="$mainRepoDir/../$tmpDirname" + +mkdir "$tmpDir" +cd "$tmpDir" + +# Make sure the resulting file includes only one directory matching the plugin's name +rsync -av "$mainRepoDir/" "./$pluginName" --exclude ".git" > /dev/null + +# Create the zip file in the current directory +zip -r "$mainRepoDir/$outputFilename" "./$pluginName" > /dev/null + +# Cleanup +cd "$mainRepoDir" +rm -r "$tmpDir" + +echo "Zip file created successfully." From 624bc23ea114ed96baa1ee91909ed8c87bc92920 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 23:45:25 +0430 Subject: [PATCH 18/76] Fix a namespace issue --- classes/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/util.php b/classes/util.php index bb9ec1e..395b1e8 100644 --- a/classes/util.php +++ b/classes/util.php @@ -6,7 +6,7 @@ class util { public static function forbid_access_if_not_from_moodle() { - if (!\defined(MOODLE_INTERNAL::class)) { + if (!\defined(\MOODLE_INTERNAL::class)) { exit("Access forbidden"); } } From 5ea2c5c1a69d9987378a58cd73f8090023c64613 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 23:48:51 +0430 Subject: [PATCH 19/76] Include modulename in the language files --- lang/en/gharar.php | 2 ++ lang/fa/gharar.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lang/en/gharar.php b/lang/en/gharar.php index b104ceb..20fc0c1 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -6,6 +6,8 @@ $_pluginName = 'Gharar'; +$string['modulename'] = '{$_pluginName}'; + $string['plugin_name'] = '{$_pluginName}'; $string['plugin_name_plural'] = "{$_pluginName}s"; diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index 323f3c5..6c31a6c 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -6,6 +6,8 @@ $_pluginName = 'قرار'; +$string['modulename'] = '{$_pluginName}'; + $string['plugin_name'] = '{$_pluginName}'; $string['plugin_name_plural'] = "{$_pluginName}ها"; From 43e919a783311d85f1f3b123694f0ad839f623b7 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 18 Jul 2021 23:55:06 +0430 Subject: [PATCH 20/76] Fix language strings, and improve them by using constants --- lang/en/gharar.php | 8 ++++---- lang/fa/gharar.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lang/en/gharar.php b/lang/en/gharar.php index 20fc0c1..5e492c7 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -4,12 +4,12 @@ util::forbid_access_if_not_from_moodle(); -$_pluginName = 'Gharar'; +const PLUGIN_NAME = 'Gharar'; -$string['modulename'] = '{$_pluginName}'; +$string['modulename'] = PLUGIN_NAME; -$string['plugin_name'] = '{$_pluginName}'; -$string['plugin_name_plural'] = "{$_pluginName}s"; +$string['plugin_name'] = PLUGIN_NAME; +$string['plugin_name_plural'] = PLUGIN_NAME . 's'; $string['meeting_name'] = 'Name'; $string['meeting_link'] = 'Link'; diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index 6c31a6c..6396ee7 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -4,12 +4,12 @@ util::forbid_access_if_not_from_moodle(); -$_pluginName = 'قرار'; +const PLUGIN_NAME = 'قرار'; -$string['modulename'] = '{$_pluginName}'; +$string['modulename'] = PLUGIN_NAME; -$string['plugin_name'] = '{$_pluginName}'; -$string['plugin_name_plural'] = "{$_pluginName}ها"; +$string['plugin_name'] = PLUGIN_NAME; +$string['plugin_name_plural'] = PLUGIN_NAME . 'ها'; $string['meeting_name'] = 'نام'; $string['meeting_link'] = 'پیوند'; From ff2efe148e83833bb57928cc3518351397351bc6 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 00:14:02 +0430 Subject: [PATCH 21/76] Fix XMLDB file, make tag and attribute names uppercase The XMLDB file is case-sensitive (unfortunately), and does not work with lowercase identifiers. --- db/install.xml | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/db/install.xml b/db/install.xml index 94331f2..abc386c 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - -
-
-
+ + + + + + + + + + + + + + +
+
+
From 4eeb14e910a8a1fbff89f3e010e38527b1f73ee3 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 00:37:32 +0430 Subject: [PATCH 22/76] Fix a wrong identifier, fix mod_form.php not showing elements --- mod_form.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mod_form.php b/mod_form.php index a988865..84665d6 100644 --- a/mod_form.php +++ b/mod_form.php @@ -13,6 +13,9 @@ public function definition() { $this->add_name_field(); $this->add_link_field(); + + $this->standard_coursemodule_elements(); + $this->add_action_buttons(); } private function add_name_field() @@ -30,6 +33,6 @@ private function add_link_field() 'meeting_link' ), ['size' => 512]); $this->_form->setType('link', PARAM_TEXT); - $this->_form->addRule('name', null, 'required', null, 'client'); + $this->_form->addRule('link', null, 'required', null, 'client'); } } From 04021cc1075cc4e42b37ee8a72437544f637f4f6 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 00:41:06 +0430 Subject: [PATCH 23/76] Fix a $this-> in a static function instead of self:: --- classes/moodle_vars.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/moodle_vars.php b/classes/moodle_vars.php index b0be28e..4f5093d 100644 --- a/classes/moodle_vars.php +++ b/classes/moodle_vars.php @@ -21,11 +21,10 @@ private function __construct() public static function get_instance() { - if ($this->instance === null) { - $this->instance = new self(); + if (self::$instance === null) { + self::$instance = new self(); } - - return $this->instance; + return self::$instance; } public function get_database() From 0719003391fe47f40b94a205babceb831d154c98 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 00:45:11 +0430 Subject: [PATCH 24/76] Fix two wrong variable names --- lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib.php b/lib.php index cc5dfb3..9f30120 100644 --- a/lib.php +++ b/lib.php @@ -5,20 +5,20 @@ util::forbid_access_if_not_from_moodle(); -function gharar_add_instance($ghararRecord) +function gharar_add_instance($record) { $moodle = moodle_vars::get_instance(); - $id = $moodle->get_database()->insert_record('gharar', $ghararRecordData); + $id = $moodle->get_database()->insert_record('gharar', $record); return $id; } -function gharar_update_instance($ghararRecord) +function gharar_update_instance($record) { $moodle = moodle_vars::get_instance(); - $id = $moodle->get_database()->update_record('gharar', $ghararRecordData); + $id = $moodle->get_database()->update_record('gharar', $record); return true; } From 367d758074a94377c1b7b77aa21f5a268b068d45 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 01:16:31 +0430 Subject: [PATCH 25/76] Fix a parenthese error, add a missing use statement --- index.php | 2 +- view.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index b3e7ca0..cee3ada 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ foreach ($instances as $instace) { $row = [ - html_writer::link(new moodle_url('view.php', ['id' => $courseId], $instance->name)), + html_writer::link(new moodle_url('view.php', ['id' => $courseId]), $instance->name), $instance->link, ]; diff --git a/view.php b/view.php index ab3f26a..a59c757 100644 --- a/view.php +++ b/view.php @@ -1,6 +1,7 @@ Date: Mon, 19 Jul 2021 01:22:10 +0430 Subject: [PATCH 26/76] Fix two wrong variable names :| --- index.php | 2 +- view.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index cee3ada..74bd728 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ 'course' => $courseId ]); -foreach ($instances as $instace) { +foreach ($instances as $instance) { $row = [ html_writer::link(new moodle_url('view.php', ['id' => $courseId]), $instance->name), $instance->link, diff --git a/view.php b/view.php index a59c757..acee230 100644 --- a/view.php +++ b/view.php @@ -29,7 +29,7 @@ 'course' => $courseId ]); -foreach ($instances as $instace) { +foreach ($instances as $instance) { $row = [ html_writer::link($instance->name, $instance->link) ]; From 46c7c5238f676d7d17b1a417a9627b45644f0061 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 01:45:54 +0430 Subject: [PATCH 27/76] Add Gharar icon in the pix directory --- pix/icon.png | Bin 0 -> 5597 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pix/icon.png diff --git a/pix/icon.png b/pix/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..64369df9a96116c35d5866002630e9274d8b782c GIT binary patch literal 5597 zcmbuDcTiJXx4;uZ3B5Pzgk~U+&%&; z1(dD`3P@GB^j?$~zj-s?H*e_cWoIU5v-pLkbhKzLA=l}o!;|(LU z6H%aPvo^#Q#p=3>cH~|(?+oLzdu;h zTpQQwxmejY@%o^q5cJ`BhvY@)$6C*?Y6{JxJ5eX|y(iQ(|EHGdLH)FxhQP6ZD5()& z1|OMd%hnsq&rqW{1Iy6b=hXacljes;DM9?d(!%`;kabvQ#`vJdtTpaq&~^0bak)4+3Io3?}EoCpqvLo7Gf7B(`U%Hp_pL9XSzZ1yWp>7&4>@B#}rOUh_)EtTMa zsHHEhXZ%M-C#Fj^oJ8H%(gJaP0>_U-WJSHAWj@!gWt=+OX9Wk=Nx?U zE7*;TOWY`*fMkK18Ha_*q4ffNY_5;bR3?izMN$uY%z?Kjc_OsMP<*G5MfAn+WJ>e6 zpPIrCykc??ev>%QMHg}2ePime#JEHGg{gm_OrcRsB%f&bIoOj@g*{x$YfVCQ8=|0~}xonx~M3D<t#%3wp;-od><{Wm)1}rfCGH|tWG*S_q)(rIRk=>C~AICedIhAKjfNJq)ZV~>@R|))?`G{|IIQOcQTj2prwOM62c?#Ke!^+fW0&_ zdNud#_8CMn_Y1K{d`AP>Ra&g*fcpx?xc8zw**u|`dsFxB-^Q{c5 zzewAH(O_cG?+B?PYWo;!%pb8Xx)7fJqLi3J7^_lLaL4s&0mA@V@5)`!>56PpX|%|3 zP_51k@JnJ7xLr4DJB4gyn5dQfN$GFTES#-j>vDS*Y>l>IDx3PqX<$k9)@~v$orfwX zG*W#m)BRziy78nzF-73;s1BmhH=MR2DI?*0AQ_KXvF`z$23#|W@#pY?ut=%CqPyah zGF|zciW+YBaDPyD*ie8>4KUWYfYH&Gxy} zs&wEx+ach)k?6D+GJh8M|Nv#yBFv^L%pcZ8>QYzwyrgbues~dCdAY$qzWjQ#944A0U zV)Y4^ZY@au6e}h!wixhD(CGxeKUhYl}}x-$b+?ylA0Lpn*_6 zL#5(-wJDLgIN2-vY6n*sj&p2sPGu~o^zOssVC%dtI?m=+P=v2YCis_RAFNLf*n#Ev z)&CtZ4}R{>$t*$l;D;9PsY1*CRCYO~=&WeYN()7u6C;syKC+27FAjbmDZia%zzwDB zVpIwtp^ZuzjMq;e=6onnO-50Kh%9xbp8xH!jCNJq^(n7XgmzISjqFfWia|>T2zvH$ z(nKIzMTRmvC*yp)?RUQ{v7rK*E|zIC!@Y*e;tZZYsH3UA({)xny<1s)47t7NB00TH zD$ZKk#NQH~AF2fQ(qD>0mwy=f-W-;nr*cP(SEvPpZW5h?Uy)$tETg(~LF$|8ZbZZL zZ*xiWR?jIesrPBR**okU%t~c8W^hd7o4n4B#5oH`BD*jFJ;@T0b^rcg+z+g@Gs_;7 zGHZ`YD(PH=Ek9W8aLf#%TH8q5s(N5@(ooS{1$pSDobuW4<__g0)JvIaQ7Px5 zDI40l1S8DJD9jf}%G7`EXUm~wX>C@BW5{?$P%n`)zY4{s#~~7vSf+xplxND@y7NCU zSmtfoGxeZYEwoK;J80BqkLXDtnA7h)++^kLjk^>juAfs24~Iv*52;SfT;Nh-uj9xR zrSap>&oq9vUh?QQW5oGz9f@X$6}3!Hvgw`dx~DGydnpfME>jmsOj$J37K`j^4=BbG zr81-VzXBJU*?-tx8ExJ!GWJsnw2O;@MKBTlWcOIX=qY9e+2yMJ!@&YRYjdRG$1Y_no>|3m!~Q(#17Z@P&2sx6OgvY&0W*D$Qq z>S?_QbI%|2o?I_HGWoIzff{@jZPDuHF)Oe*jj2NB6^(}Z9=t~1&uZ9E2#pSCV2kS_L4w@NOrQ}kQkxVgfxWa_FW-Q{f zo~x|YOYc&rHDQ+0$uuVbAA3yzv|39`uKUFs2(*s@RG zIv$wa%1cWu2)tM47@ANQS8F)GK4-{p5b%EE` zI;XBOZ@WHu^uG}pIJ2ZuX}1MSU5HS$oI>>bfN9^&rN&89E=U8gR+Ua!x0 zwOs|hZ?$ymjhKF%5+t)mUdot>2Z^etlbosGO6ONAdZ+nM(jyKN0X?ZrqUD4GIJc~v)3XAITVT_fI?cH z+oRHMP?7cluc?#9C%cBcm;A;bpD{;K&tTJG49P<*9_i*noj*PDa>c~`JHgFs)nF?9u1?=-DpBFUDhI4(boZHTxQ*OR3(b(R zAxi@o-laBhRJibD`S~Fi@!Ovsr!0fJZVO! zar|LY_1;Tu!P;EXW_~N<*~2`x?gue5mje|f3Whkd*$bz1`IHU~W5!ZPv1>{vy&&<^ z-qc;eUHGS5OaIy7v870;Ub#Hfs0;WV;&7AHe<0PzI~XR3=eBHb^p9RUhTqiau1-4F zs;BrRSQc&=&+6$GaAT!UEfvj2WNJz{?|RV#r{LG4%5)J?HJIKGXH;Vn67jt2ezPN5 z@KkKy=@YxaZokB$3&MA7qMzw4aQ7wZAh#0kPx$H4M(~aFIwtQ*Jur)_04 ztv0kAcN`8Y)J8y=(E%ei#Z}j#PCE?kJBm9=M*G2PGJg)HuRA*u{Iz zPp_S(w8aY8IDbyrw2I5C)y`Y|%W{WbZtN2imjwq&MEuYxC^OgcC!#z6rGL@My3w;| z=SK9V-slJyXo{WC6(sx$W%u>I1#4}I&pBRQTbL5IrLbSw%UP|lq|={;^G%nX`46UA z1jKr03Hs$EJ=W&BFOT)Wp)$E)~;t12O41{i2BK=^f|>WRzw1p{_(; z#rPlcmg9=}k^Yg=;xFmdiT5?~K04=kuwgzru^C;c)!K~ja@pR`co&g`;=c7qQy1r| zevF|0N?gkN*9Qk$~o4e^l zqd`j9>VCRdWTYo`AaAoP7&+sB-TCW`)O^X>5*YtZ#QN}rH>b_MVV+O-N0zv6SiyJg zZ;x)q(vbhsS!Q`B8H(Y|uN_ZheS_EYNhCzk)Jme+%1bRKdk5**6ILfZe-Eu);TPYW znRBEk_!2AwC*i-|B?MXAid`P-uQPwbXGxZ1705*E1pAlANl}%=8w4mk zX}=NjC(=i9#p2f%z0uzX(mM|eBc?&-_C4IW@eI00Z=sWHUZC9osa+oH$%iOpTLRqX#l{-}HAU&3#I8X}{nM}d)^ED5?tkVp<1{JS9l?lFctIL#!LLwS6Mq3mNEN>kS8dY8x{zEFT-=o{u;nrvUrD^RG z3GtP&kH?+$<*8lSpi7hgQMq1nZC@RKd*ao3->d!G+J6nUW4BAXQw|HCjUU_8VyXDS zL0b}2J3`Iw93>)?#lQAgXDa3 z;FdU+qd?~j+u}fn+d>UXDtX>v#Evs*!j2@EhR776GVvgx_>7I~E@}`$bpnaoEl0Mtx2cWqMiW;IN)EaNu}-v2D6PidD?pO)K`B=AGt~-l)hr+Nwsq2O5U%| z_=jzAYwb#d#GMOy3aI&n4P=>ai5Vq*GvomYZ>`{=kLs)MZ|JPM7A9^Cb`mj->}N_v z26U%(P82ms5vwEl&Y2nSo+q-+paR?Js5tUwGHeTujIPw3=%Qo@G``?&!w_ps?BM?JY0C~7P90pg0Ar!0;aHIkP30IVc!;x^fu-WYI zTfu(^_y>6Uct!m00ha9UZR7xh-xY!ayn@5r0x^Ia{%+nFQ#WrPkGsOkvMREwFg0O$ zI6@HySArqrg)I@v!r0(o98yj$EG$gc=Qm9jGA$br==~*Oi<}U^^E;z8HpJf@i9`o@ zg!p6b1tXCbWHbnXsJiNu`yb4|Y9f(XjE^@q7=TcdX9fg5CNtdsk>|ge+diJb*x$%x ztq7Qm@csv4>f?_Ij=*66|C*H??w+?+ldakR$YW|vrT_>fHF>zAqP()=GtlT8GQ#{H zd2abcVgPVm-JDX*f5=)oI=j9ga;}LK#NbcV+Motx> z>Z#_ggi*$Lc&K@)xxrO17*7?1BHUfsO&Q^(Doc)#CC@KklY)y}0dPa#4E<8q_0fL; DZ?l|H literal 0 HcmV?d00001 From 5b713215db8bcdb382e5689398b855ba3ca2a288 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 01:54:45 +0430 Subject: [PATCH 28/76] Add pluginname language string (used by moodle) --- lang/en/gharar.php | 2 ++ lang/fa/gharar.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lang/en/gharar.php b/lang/en/gharar.php index 5e492c7..01c812d 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -6,7 +6,9 @@ const PLUGIN_NAME = 'Gharar'; +// Moodle-specific $string['modulename'] = PLUGIN_NAME; +$string['pluginname'] = PLUGIN_NAME; $string['plugin_name'] = PLUGIN_NAME; $string['plugin_name_plural'] = PLUGIN_NAME . 's'; diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index 6396ee7..bbbb1aa 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -6,7 +6,9 @@ const PLUGIN_NAME = 'قرار'; +// Moodle-specific $string['modulename'] = PLUGIN_NAME; +$string['pluginname'] = PLUGIN_NAME; $string['plugin_name'] = PLUGIN_NAME; $string['plugin_name_plural'] = PLUGIN_NAME . 'ها'; From 9112a3dd6dc286dcb2d0c8ca18aea5ba4003adba Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 01:56:59 +0430 Subject: [PATCH 29/76] Add release information in version.php --- version.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.php b/version.php index 422b754..0d9b855 100644 --- a/version.php +++ b/version.php @@ -4,5 +4,6 @@ util::forbid_access_if_not_from_moodle(); -$plugin->component = "mod_gharar"; +$plugin->component = 'mod_gharar'; $plugin->version = 2021071601; +$plugin->release = '0.1.0-alpha.1'; From 4fef566f9171edb5db6dd0a723f43c24170369a5 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 02:52:32 +0430 Subject: [PATCH 30/76] Fix not setting id for moodle_database::update_record() in lib.php Along with other fixes. --- lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib.php b/lib.php index 9f30120..aec71a3 100644 --- a/lib.php +++ b/lib.php @@ -18,9 +18,12 @@ function gharar_update_instance($record) { $moodle = moodle_vars::get_instance(); - $id = $moodle->get_database()->update_record('gharar', $record); + // Important: The id is not stored in the 'id' field, but the 'instance' one + $record->id = $record->instance; - return true; + $result = $moodle->get_database()->update_record('gharar', $record); + + return $result; } function gharar_delete_instance($recordId) @@ -32,7 +35,7 @@ function gharar_delete_instance($recordId) } if (!$moodle->get_database()->delete_records('gharar', ['id' => $recordId])) { - $result = false; + return false; } return true; } From 4d9f53e8454410cb49df14ddeb01ebf8518daa3e Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 02:57:04 +0430 Subject: [PATCH 31/76] Ignore generated zip file from build-zip.sh, exclude git ignore from it --- .gitignore | 2 ++ build-zip.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9cb482b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# The zip file generated by build-zip.sh +moodle-mod-gharar.zip diff --git a/build-zip.sh b/build-zip.sh index 88149c3..14831aa 100755 --- a/build-zip.sh +++ b/build-zip.sh @@ -13,7 +13,7 @@ mkdir "$tmpDir" cd "$tmpDir" # Make sure the resulting file includes only one directory matching the plugin's name -rsync -av "$mainRepoDir/" "./$pluginName" --exclude ".git" > /dev/null +rsync -av "$mainRepoDir/" "./$pluginName" --exclude 'git' --exclude '.gitignore' > /dev/null # Create the zip file in the current directory zip -r "$mainRepoDir/$outputFilename" "./$pluginName" > /dev/null From c09dd9c943171323e8f8aabfeeead0cb6ca80a2e Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 03:15:10 +0430 Subject: [PATCH 32/76] Fix view.php trying to do the same action as index.php Previously, view.php considered the id parameter passed to it as course id, not course module id (due to misunderstandings), and as a result of this, the code tried to load the course related to that id instead, which was plain wrong. --- index.php | 2 -- view.php | 32 ++++++++------------------------ 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/index.php b/index.php index 74bd728..ce27974 100644 --- a/index.php +++ b/index.php @@ -5,14 +5,12 @@ require_once __DIR__ . '/../../config.php'; -// Get id parameter, using GET (as in GET and POST) method $courseId = required_param('id', PARAM_INT); $course = $DB->get_record('course', ['id' => $courseId], '*', MUST_EXIST); require_login($course); -// TODO: Make these more dynamic, e.g. use get_string for set_title $PAGE->set_url('/mod/gharar/index.php', ['id' => $courseId]); $PAGE->set_title(util::get_string('plugin_name_plural')); $PAGE->set_heading($course->fullname); diff --git a/view.php b/view.php index acee230..8150ffb 100644 --- a/view.php +++ b/view.php @@ -5,38 +5,22 @@ require_once __DIR__ . '/../../config.php'; -$courseId = required_param('id', PARAM_INT); +$courseModuleId = required_param('id', PARAM_INT); -$course = $DB->get_record('course', ['id' => $courseId], '*', MUST_EXIST); +[$course, $courseModule] = get_course_and_cm_from_cmid($courseModuleId, 'gharar'); -require_login($course); +$instance = $DB->get_record('gharar', ['id'=> $courseModule->instance], '*', MUST_EXIST); -$PAGE->set_url('/mod/gharar/view.php', ['id' => $courseId]); -$PAGE->set_title(util::get_string('plugin_name_plural')); +require_login($course, true, $courseModule); + +$PAGE->set_url('/mod/gharar/view.php', ['id' => $courseModuleId]); +$PAGE->set_title($instance->fullname); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); echo $OUTPUT->header(); echo $OUTPUT->heading(util::get_string('plugin_name_plural')); -$table = new html_table(); -$table->attributes['class'] = 'generaltable mod_index'; - -$table->head = [util::get_string('meeting_name')]; -$table->align = ['center']; - -$instances = moodle_vars::get_instance()->get_database()->get_records('gharar', [ - 'course' => $courseId -]); - -foreach ($instances as $instance) { - $row = [ - html_writer::link($instance->name, $instance->link) - ]; - - $table->data[] = $row; -} - -echo html_writer::table($table); +echo html_writer::link($instance->name, 'Enter'); echo $OUTPUT->footer(); From cdad064e27523935c3ebcc79e686a52ae59468cc Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 03:17:59 +0430 Subject: [PATCH 33/76] Add language string for entering a meeting link Also, bump version to 0.1.0-beta.1 --- lang/en/gharar.php | 2 ++ lang/fa/gharar.php | 2 ++ version.php | 4 ++-- view.php | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lang/en/gharar.php b/lang/en/gharar.php index 01c812d..ce739ee 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -15,3 +15,5 @@ $string['meeting_name'] = 'Name'; $string['meeting_link'] = 'Link'; + +$string['enter_meeting_link'] = 'Enter'; diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index bbbb1aa..eb640bf 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -15,3 +15,5 @@ $string['meeting_name'] = 'نام'; $string['meeting_link'] = 'پیوند'; + +$string['enter_meeting_link'] = 'ورود'; diff --git a/version.php b/version.php index 0d9b855..01b9818 100644 --- a/version.php +++ b/version.php @@ -5,5 +5,5 @@ util::forbid_access_if_not_from_moodle(); $plugin->component = 'mod_gharar'; -$plugin->version = 2021071601; -$plugin->release = '0.1.0-alpha.1'; +$plugin->version = 2021071602; +$plugin->release = '0.1.0-beta.1'; diff --git a/view.php b/view.php index 8150ffb..5b3d47a 100644 --- a/view.php +++ b/view.php @@ -21,6 +21,6 @@ echo $OUTPUT->header(); echo $OUTPUT->heading(util::get_string('plugin_name_plural')); -echo html_writer::link($instance->name, 'Enter'); +echo html_writer::link($instance->name, util::get_string('enter_meeting_link')); echo $OUTPUT->footer(); From fd3ab6746035a1d3ab7e4dd91f73310aa559a247 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 15:19:21 +0430 Subject: [PATCH 34/76] Fix the entering link in view.php, fix the title there --- view.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view.php b/view.php index 5b3d47a..9061cec 100644 --- a/view.php +++ b/view.php @@ -14,13 +14,13 @@ require_login($course, true, $courseModule); $PAGE->set_url('/mod/gharar/view.php', ['id' => $courseModuleId]); -$PAGE->set_title($instance->fullname); +$PAGE->set_title($instance->name); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); echo $OUTPUT->header(); echo $OUTPUT->heading(util::get_string('plugin_name_plural')); -echo html_writer::link($instance->name, util::get_string('enter_meeting_link')); +echo html_writer::link($instance->link, util::get_string('enter_meeting_link')); echo $OUTPUT->footer(); From 2afaa053b445e3decaa8a34dbb698456f14eff51 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 15:22:26 +0430 Subject: [PATCH 35/76] Make view.php title and heading showing instance name --- view.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view.php b/view.php index 9061cec..387a768 100644 --- a/view.php +++ b/view.php @@ -14,12 +14,12 @@ require_login($course, true, $courseModule); $PAGE->set_url('/mod/gharar/view.php', ['id' => $courseModuleId]); -$PAGE->set_title($instance->name); +$PAGE->set_title("$course->shortname: $instance->name"); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); echo $OUTPUT->header(); -echo $OUTPUT->heading(util::get_string('plugin_name_plural')); +echo $OUTPUT->heading($instance->name); echo html_writer::link($instance->link, util::get_string('enter_meeting_link')); From 847882f5bc0c981b7e78bd53eeb3b9367a4f589f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 15:24:56 +0430 Subject: [PATCH 36/76] Remove the zip file before building in build-zip.sh Also, ignore the shell file from being included in the resulting zip file. --- build-zip.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-zip.sh b/build-zip.sh index 14831aa..7dd5015 100755 --- a/build-zip.sh +++ b/build-zip.sh @@ -13,8 +13,12 @@ mkdir "$tmpDir" cd "$tmpDir" # Make sure the resulting file includes only one directory matching the plugin's name -rsync -av "$mainRepoDir/" "./$pluginName" --exclude 'git' --exclude '.gitignore' > /dev/null +rsync -av "$mainRepoDir/" "./$pluginName" \ + --exclude '.git' --exclude '.gitignore' --exclude 'build-zip.sh' > /dev/null +# Remove previous zip file to prevent files to remain there +# TODO: Remove this? +rm "$mainRepoDir/$outputFilename" # Create the zip file in the current directory zip -r "$mainRepoDir/$outputFilename" "./$pluginName" > /dev/null From 1fe85715171a0bfb16713f5c8ddd53bd716304b2 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 19 Jul 2021 15:28:27 +0430 Subject: [PATCH 37/76] Improve index.php title, bump version to 0.1.0-beta.2 --- index.php | 2 +- version.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index ce27974..e3365c2 100644 --- a/index.php +++ b/index.php @@ -12,7 +12,7 @@ require_login($course); $PAGE->set_url('/mod/gharar/index.php', ['id' => $courseId]); -$PAGE->set_title(util::get_string('plugin_name_plural')); +$PAGE->set_title("$course->shortname " . util::get_string('plugin_name_plural')); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); $PAGE->set_pagelayout('incourse'); diff --git a/version.php b/version.php index 01b9818..a403a55 100644 --- a/version.php +++ b/version.php @@ -5,5 +5,5 @@ util::forbid_access_if_not_from_moodle(); $plugin->component = 'mod_gharar'; -$plugin->version = 2021071602; -$plugin->release = '0.1.0-beta.1'; +$plugin->version = 2021071603; +$plugin->release = '0.1.0-beta.2'; From a33fa82cb67d257b566a1254d047c592f8a87046 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sat, 28 Aug 2021 18:10:39 +0430 Subject: [PATCH 38/76] Add usage of Composer, use Psalm as a development package --- .gitignore | 2 + composer.json | 18 + composer.lock | 2049 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2069 insertions(+) create mode 100644 composer.json create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 9cb482b..aa77b89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # The zip file generated by build-zip.sh moodle-mod-gharar.zip + +/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..5987324 --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "machitgarha/moodle-mod-gharar", + "description": "Gharar plugin for Moodle", + "type": "library", + "license": "GPLv3", + "authors": [ + { + "name": "Mohammad Amin Chitgarha", + "email": "machitgarha@outlook.com" + } + ], + "require": { + "php": "^7.2" + }, + "require-dev": { + "vimeo/psalm": "^4.9" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5a54eb3 --- /dev/null +++ b/composer.lock @@ -0,0 +1,2049 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "6458fbea12208af97491f1480750423f", + "packages": [], + "packages-dev": [ + { + "name": "amphp/amp", + "version": "v2.6.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/amp.git", + "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/caa95edeb1ca1bf7532e9118ede4a3c3126408cc", + "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "ext-json": "*", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^7 | ^8 | ^9", + "psalm/phar": "^3.11@dev", + "react/promise": "^2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Amp\\": "lib" + }, + "files": [ + "lib/functions.php", + "lib/Internal/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A non-blocking concurrency framework for PHP applications.", + "homepage": "http://amphp.org/amp", + "keywords": [ + "async", + "asynchronous", + "awaitable", + "concurrency", + "event", + "event-loop", + "future", + "non-blocking", + "promise" + ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/amp/issues", + "source": "https://github.com/amphp/amp/tree/v2.6.0" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2021-07-16T20:06:06+00:00" + }, + { + "name": "amphp/byte-stream", + "version": "v1.8.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/byte-stream.git", + "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/acbd8002b3536485c997c4e019206b3f10ca15bd", + "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd", + "shasum": "" + }, + "require": { + "amphp/amp": "^2", + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1.4", + "friendsofphp/php-cs-fixer": "^2.3", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^6 || ^7 || ^8", + "psalm/phar": "^3.11.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Amp\\ByteStream\\": "lib" + }, + "files": [ + "lib/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A stream abstraction to make working with non-blocking I/O simple.", + "homepage": "http://amphp.org/byte-stream", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "non-blocking", + "stream" + ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/byte-stream/issues", + "source": "https://github.com/amphp/byte-stream/tree/v1.8.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2021-03-30T17:13:30+00:00" + }, + { + "name": "composer/package-versions-deprecated", + "version": "1.11.99.3", + "source": { + "type": "git", + "url": "https://github.com/composer/package-versions-deprecated.git", + "reference": "fff576ac850c045158a250e7e27666e146e78d18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/fff576ac850c045158a250e7e27666e146e78d18", + "reference": "fff576ac850c045158a250e7e27666e146e78d18", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1.0 || ^2.0", + "php": "^7 || ^8" + }, + "replace": { + "ocramius/package-versions": "1.11.99" + }, + "require-dev": { + "composer/composer": "^1.9.3 || ^2.0@dev", + "ext-zip": "^1.13", + "phpunit/phpunit": "^6.5 || ^7" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "support": { + "issues": "https://github.com/composer/package-versions-deprecated/issues", + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-08-17T13:49:14+00:00" + }, + { + "name": "composer/semver", + "version": "3.2.5", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/31f3ea725711245195f62e54ffa402d8ef2fdba9", + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.54", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.2.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-05-24T12:41:47+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-07-31T17:03:58+00:00" + }, + { + "name": "dnoegel/php-xdg-base-dir", + "version": "v0.1.1", + "source": { + "type": "git", + "url": "https://github.com/dnoegel/php-xdg-base-dir.git", + "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", + "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~7.0|~6.0|~5.0|~4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "XdgBaseDir\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "implementation of xdg base directory specification for php", + "support": { + "issues": "https://github.com/dnoegel/php-xdg-base-dir/issues", + "source": "https://github.com/dnoegel/php-xdg-base-dir/tree/v0.1.1" + }, + "time": "2019-12-04T15:06:13+00:00" + }, + { + "name": "felixfbecker/advanced-json-rpc", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "shasum": "" + }, + "require": { + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "php": "^7.1 || ^8.0", + "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "AdvancedJsonRpc\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "A more advanced JSONRPC implementation", + "support": { + "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1" + }, + "time": "2021-06-11T22:34:44+00:00" + }, + { + "name": "felixfbecker/language-server-protocol", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-language-server-protocol.git", + "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/9d846d1f5cf101deee7a61c8ba7caa0a975cd730", + "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpstan/phpstan": "*", + "squizlabs/php_codesniffer": "^3.1", + "vimeo/psalm": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "LanguageServerProtocol\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "PHP classes for the Language Server Protocol", + "keywords": [ + "language", + "microsoft", + "php", + "server" + ], + "support": { + "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/1.5.1" + }, + "time": "2021-02-22T14:02:09+00:00" + }, + { + "name": "netresearch/jsonmapper", + "version": "v4.0.0", + "source": { + "type": "git", + "url": "https://github.com/cweiske/jsonmapper.git", + "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", + "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0", + "squizlabs/php_codesniffer": "~3.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "JsonMapper": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@cweiske.de", + "homepage": "http://github.com/cweiske/jsonmapper/", + "role": "Developer" + } + ], + "description": "Map nested JSON structures onto PHP classes", + "support": { + "email": "cweiske@cweiske.de", + "issues": "https://github.com/cweiske/jsonmapper/issues", + "source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0" + }, + "time": "2020-12-01T19:48:11+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.12.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + }, + "time": "2021-07-21T10:44:31+00:00" + }, + { + "name": "openlss/lib-array2xml", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/nullivex/lib-array2xml.git", + "reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nullivex/lib-array2xml/zipball/a91f18a8dfc69ffabe5f9b068bc39bb202c81d90", + "reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "LSS": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Bryan Tong", + "email": "bryan@nullivex.com", + "homepage": "https://www.nullivex.com" + }, + { + "name": "Tony Butler", + "email": "spudz76@gmail.com", + "homepage": "https://www.nullivex.com" + } + ], + "description": "Array2XML conversion library credit to lalit.org", + "homepage": "https://www.nullivex.com", + "keywords": [ + "array", + "array conversion", + "xml", + "xml conversion" + ], + "support": { + "issues": "https://github.com/nullivex/lib-array2xml/issues", + "source": "https://github.com/nullivex/lib-array2xml/tree/master" + }, + "time": "2019-03-29T20:06:56+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.2.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, + "time": "2020-09-03T19:13:55+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, + "time": "2020-09-17T18:55:26+00:00" + }, + { + "name": "psr/container", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.1" + }, + "time": "2021-03-05T17:36:06+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "symfony/console", + "version": "v5.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2", + "symfony/string": "^5.1" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.3.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-27T19:10:22+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-28T13:41:28+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-04-01T10:43:52+00:00" + }, + { + "name": "symfony/string", + "version": "v5.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.3.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-27T11:44:38+00:00" + }, + { + "name": "vimeo/psalm", + "version": "4.9.3", + "source": { + "type": "git", + "url": "https://github.com/vimeo/psalm.git", + "reference": "4c262932602b9bbab5020863d1eb22d49de0dbf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/4c262932602b9bbab5020863d1eb22d49de0dbf4", + "reference": "4c262932602b9bbab5020863d1eb22d49de0dbf4", + "shasum": "" + }, + "require": { + "amphp/amp": "^2.4.2", + "amphp/byte-stream": "^1.5", + "composer/package-versions-deprecated": "^1.8.0", + "composer/semver": "^1.4 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^1.1 || ^2.0", + "dnoegel/php-xdg-base-dir": "^0.1.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-tokenizer": "*", + "felixfbecker/advanced-json-rpc": "^3.0.3", + "felixfbecker/language-server-protocol": "^1.5", + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "nikic/php-parser": "^4.12", + "openlss/lib-array2xml": "^1.0", + "php": "^7.1|^8", + "sebastian/diff": "^3.0 || ^4.0", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "webmozart/path-util": "^2.3" + }, + "provide": { + "psalm/psalm": "self.version" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.2", + "brianium/paratest": "^4.0||^6.0", + "ext-curl": "*", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpdocumentor/reflection-docblock": "^5", + "phpmyadmin/sql-parser": "5.1.0||dev-master", + "phpspec/prophecy": ">=1.9.0", + "phpunit/phpunit": "^9.0", + "psalm/plugin-phpunit": "^0.16", + "slevomat/coding-standard": "^7.0", + "squizlabs/php_codesniffer": "^3.5", + "symfony/process": "^4.3 || ^5.0", + "weirdan/prophecy-shim": "^1.0 || ^2.0" + }, + "suggest": { + "ext-igbinary": "^2.0.5" + }, + "bin": [ + "psalm", + "psalm-language-server", + "psalm-plugin", + "psalm-refactor", + "psalter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev", + "dev-3.x": "3.x-dev", + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psalm\\": "src/Psalm/" + }, + "files": [ + "src/functions.php", + "src/spl_object_id.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Brown" + } + ], + "description": "A static analysis tool for finding errors in PHP applications", + "keywords": [ + "code", + "inspection", + "php" + ], + "support": { + "issues": "https://github.com/vimeo/psalm/issues", + "source": "https://github.com/vimeo/psalm/tree/4.9.3" + }, + "time": "2021-08-14T16:19:38+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, + "time": "2021-03-09T10:59:23+00:00" + }, + { + "name": "webmozart/path-util", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/path-util.git", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "webmozart/assert": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\PathUtil\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", + "support": { + "issues": "https://github.com/webmozart/path-util/issues", + "source": "https://github.com/webmozart/path-util/tree/2.3.0" + }, + "time": "2015-12-17T08:42:14+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.1.0" +} From 25373c6a00bb1e0b6d69065ffe48fb7c59f9f779 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sat, 28 Aug 2021 20:43:34 +0430 Subject: [PATCH 39/76] Add PSR-4 autoloading rule in composer.json --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 5987324..3efd823 100644 --- a/composer.json +++ b/composer.json @@ -14,5 +14,10 @@ }, "require-dev": { "vimeo/psalm": "^4.9" + }, + "autoload": { + "psr-4": { + "MAChitgarha\\MoodleModGharar\\": "src" + } } } From 670e436143bb067587da5440c9fd46673200da97 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sat, 28 Aug 2021 20:46:51 +0430 Subject: [PATCH 40/76] Move moodle_vars class from classes into src, re-namespace and rename it --- classes/moodle_vars.php => src/Moodle/Globals.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename classes/moodle_vars.php => src/Moodle/Globals.php (73%) diff --git a/classes/moodle_vars.php b/src/Moodle/Globals.php similarity index 73% rename from classes/moodle_vars.php rename to src/Moodle/Globals.php index 4f5093d..a89c8d6 100644 --- a/classes/moodle_vars.php +++ b/src/Moodle/Globals.php @@ -1,8 +1,8 @@ output = $OUTPUT; } - public static function get_instance() + public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); @@ -27,17 +27,17 @@ public static function get_instance() return self::$instance; } - public function get_database() + public function getDatabase() { return $this->database; } - public function get_config() + public function getConfig() { return $this->config; } - public function get_output() + public function getOutput() { return $this->output; } From ac3f50fd541212627abd40b2b5e1d209ce2cbc46 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 29 Aug 2021 21:00:47 +0430 Subject: [PATCH 41/76] Move util to Util, from classes into src, rename identifiers --- classes/util.php | 18 ------------------ src/Util.php | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 classes/util.php create mode 100644 src/Util.php diff --git a/classes/util.php b/classes/util.php deleted file mode 100644 index 395b1e8..0000000 --- a/classes/util.php +++ /dev/null @@ -1,18 +0,0 @@ - Date: Sun, 29 Aug 2021 21:03:30 +0430 Subject: [PATCH 42/76] Update version.php for recent Composer migrations Composer migrations mean, the use of its autoloader instead of Moodle's. This helps following PSR rules better (e.g. PascalCase for classes and camelCase for methods), as well as using third-party packages more easily. --- classes/plugin.php | 8 -------- version.php | 6 ++++-- 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 classes/plugin.php diff --git a/classes/plugin.php b/classes/plugin.php deleted file mode 100644 index bb686dd..0000000 --- a/classes/plugin.php +++ /dev/null @@ -1,8 +0,0 @@ -component = 'mod_gharar'; $plugin->version = 2021071603; From 505da85b306b4b0205e62f6e46c53efa001cbcbb Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Sun, 29 Aug 2021 21:25:35 +0430 Subject: [PATCH 43/76] Add Globals::getPage(), add type hints for Globals class Type hints are being added supposing that the Moodle files presents somewhere in the project files, e.g. perhaps in vendor by a soft link to Moodle lib directory. This way, the autocompletion packages for IDEs and text-editors work great (as I tested, php-ide-serenata for Atom works perfect). Also, after adding Psalm static analyzer, there might be a method to escape from its errors. --- src/Moodle/Globals.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index a89c8d6..1e9f086 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -2,21 +2,34 @@ namespace MAChitgarha\MoodleModGharar\Moodle; +use moodle_page; +use mysqli_native_moodle_database; +use core_renderer; + +// For using $CFG global +require_once __DIR__ . "/../../../../config.php"; + class Globals { private static $instance = null; + /** @var mysqli_native_moodle_database */ private $database; + /** @var stdClass */ private $config; + /** @var core_renderer */ private $output; + /** @var moodle_page */ + private $page; private function __construct() { - global $DB, $CFG, $OUTPUT; + global $DB, $CFG, $OUTPUT, $PAGE; $this->database = $DB; $this->config = $CFG; $this->output = $OUTPUT; + $this->page = $PAGE; } public static function getInstance() @@ -27,18 +40,23 @@ public static function getInstance() return self::$instance; } - public function getDatabase() + public function getDatabase(): mysqli_native_moodle_database { return $this->database; } - public function getConfig() + public function getConfig(): stdClass { return $this->config; } - public function getOutput() + public function getOutput(): core_renderer { return $this->output; } + + public function getPage(): moodle_page + { + return $this->page; + } } From 8e4f4882af9c940d5b3459812ab5eb476350bfc4 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 11:57:46 +0430 Subject: [PATCH 44/76] Move actions done in view.php into a new ViewPageBuilder class Add Plugin class, including information about the plugin (i.e. metadata) for now (may be extended). Other improvements. --- src/Moodle/Globals.php | 2 +- src/Plugin.php | 11 ++++ src/ViewPageBuilder.php | 122 ++++++++++++++++++++++++++++++++++++++++ view.php | 27 ++------- 4 files changed, 139 insertions(+), 23 deletions(-) create mode 100644 src/Plugin.php create mode 100644 src/ViewPageBuilder.php diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index 1e9f086..7669672 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -32,7 +32,7 @@ private function __construct() $this->page = $PAGE; } - public static function getInstance() + public static function getInstance(): self { if (self::$instance === null) { self::$instance = new self(); diff --git a/src/Plugin.php b/src/Plugin.php new file mode 100644 index 0000000..c337bbf --- /dev/null +++ b/src/Plugin.php @@ -0,0 +1,11 @@ +initParams() + ->initCourseAndCourseModule() + ->initModuleInstance() + ->requireLogin(); + } + + private function initParams(): self + { + $this->courseModuleId = \required_param("id", \PARAM_INT); + + return $this; + } + + private function initCourseAndCourseModule(): self + { + [ + $this->course, + $this->courseModule, + ] = \get_course_and_cm_from_cmid( + $this->courseModuleId, + Plugin::MODULE_NAME, + ); + + return $this; + } + + private function initModuleInstance(): self + { + $this->moduleInstance = Globals::getInstance() + ->getDatabase() + ->get_record( + Plugin::DATABASE_MAIN_TABLE_NAME, + ["id" => $this->courseModule->instance], + "*", + \MUST_EXIST, + ); + + return $this; + } + + private function requireLogin(): self + { + \require_login($this->course, true, $this->courseModule); + + return $this; + } + + public function build(): self + { + $this + ->buildPage() + ->buildOutput(); + + return $this; + } + + private function buildPage(): self + { + $page = Globals::getInstance()->getPage(); + + $page->set_url(self::URL, ["id" => $this->courseModuleId]); + $page->set_title( + "{$this->course->shortname}: {$this->moduleInstance->name}" + ); + $page->set_heading($this->course->fullname); + $page->set_cacheable(false); + + return $this; + } + + private function buildOutput(): self + { + $output = Globals::getInstance()->getOutput(); + + $this->output .= $output->header(); + $this->output .= $output->heading($this->moduleInstance->name); + $this->output .= $this->generateMainContent(); + $this->output .= $output->footer(); + + return $this; + } + + private function generateMainContent(): string + { + return \html_writer::link( + $this->moduleInstance->link, + Util::getString('enter_meeting_link') + ); + } + + public function getOutput(): string + { + return $this->output; + } +} diff --git a/view.php b/view.php index 387a768..47937bf 100644 --- a/view.php +++ b/view.php @@ -1,26 +1,9 @@ get_record('gharar', ['id'=> $courseModule->instance], '*', MUST_EXIST); - -require_login($course, true, $courseModule); - -$PAGE->set_url('/mod/gharar/view.php', ['id' => $courseModuleId]); -$PAGE->set_title("$course->shortname: $instance->name"); -$PAGE->set_heading($course->fullname); -$PAGE->set_cacheable(false); - -echo $OUTPUT->header(); -echo $OUTPUT->heading($instance->name); - -echo html_writer::link($instance->link, util::get_string('enter_meeting_link')); - -echo $OUTPUT->footer(); +$x = (new ViewPageBuilder()) + ->build() + ->getOutput(); From dc545a830352a561fd631b14055e37db6aa6fe4c Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 12:21:39 +0430 Subject: [PATCH 45/76] Use Plugin::COMPONENT_NAME in version.php, for $plugin->component --- version.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.php b/version.php index 24b9355..5b212fa 100644 --- a/version.php +++ b/version.php @@ -3,9 +3,10 @@ require __DIR__ . "/vendor/autoload.php"; use MAChitgarha\MoodleModGharar\Util; +use MAChitgarha\MoodleModGharar\Plugin; Util::forbidNonMoodleAccess(); -$plugin->component = 'mod_gharar'; +$plugin->component = Plugin::COMPONENT_NAME; $plugin->version = 2021071603; $plugin->release = '0.1.0-beta.2'; From 5946caba4c32a73af656518cd804c0fbc2fd70a9 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 16:09:53 +0430 Subject: [PATCH 46/76] Make AbstractPageBuilder parent of ViewPageBuilder Add Plugin::RELATIVE_PATH, to be used as the URL of page builder. --- src/PageBuilding/AbstractPageBuilder.php | 42 ++++++++++++++++++++++ src/{ => PageBuilding}/ViewPageBuilder.php | 40 +++++---------------- src/Plugin.php | 7 ++++ 3 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 src/PageBuilding/AbstractPageBuilder.php rename src/{ => PageBuilding}/ViewPageBuilder.php (68%) diff --git a/src/PageBuilding/AbstractPageBuilder.php b/src/PageBuilding/AbstractPageBuilder.php new file mode 100644 index 0000000..1f438ee --- /dev/null +++ b/src/PageBuilding/AbstractPageBuilder.php @@ -0,0 +1,42 @@ +buildPage() + ->buildOutput(); + + return $this; + } + + abstract protected function buildPage(): self; + + protected function buildOutput(): self + { + $output = Globals::getInstance()->getOutput(); + + $this->output .= $output->header(); + $this->output .= $output->heading($this->generateOutputHeading()); + $this->output .= $this->generateOutputMainContent(); + $this->output .= $output->footer(); + + return $this; + } + + abstract protected function generateOutputHeading(): string; + abstract protected function generateOutputMainContent(): string; + + public function getOutput(): string + { + return $this->output; + } +} diff --git a/src/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php similarity index 68% rename from src/ViewPageBuilder.php rename to src/PageBuilding/ViewPageBuilder.php index eda277a..f34adba 100644 --- a/src/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -1,12 +1,12 @@ buildPage() - ->buildOutput(); - - return $this; - } - - private function buildPage(): self + protected function buildPage(): self { $page = Globals::getInstance()->getPage(); @@ -95,28 +83,16 @@ private function buildPage(): self return $this; } - private function buildOutput(): self + protected function generateOutputHeading(): string { - $output = Globals::getInstance()->getOutput(); - - $this->output .= $output->header(); - $this->output .= $output->heading($this->moduleInstance->name); - $this->output .= $this->generateMainContent(); - $this->output .= $output->footer(); - - return $this; + return $this->moduleInstance->name; } - private function generateMainContent(): string + protected function generateOutputMainContent(): string { return \html_writer::link( $this->moduleInstance->link, - Util::getString('enter_meeting_link') + Util::getString("enter_meeting_link") ); } - - public function getOutput(): string - { - return $this->output; - } } diff --git a/src/Plugin.php b/src/Plugin.php index c337bbf..9235375 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -8,4 +8,11 @@ class Plugin public const COMPONENT_NAME = "mod_gharar"; public const DATABASE_MAIN_TABLE_NAME = "gharar"; + + /** + * Path of the plugin, relative to Moodle root directory, without no + * trailing slashes. + * @var string + */ + public const RELATIVE_PATH = "/mod/" . self::MODULE_NAME; } From 8c4280b13f0c36e31b1490b6f14b98ba90be76e0 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 16:27:28 +0430 Subject: [PATCH 47/76] Move index.php functionality into IndexPageBuilder --- index.php | 49 ++---------- src/PageBuilding/IndexPageBuilder.php | 108 ++++++++++++++++++++++++++ src/PageBuilding/ViewPageBuilder.php | 2 +- 3 files changed, 114 insertions(+), 45 deletions(-) create mode 100644 src/PageBuilding/IndexPageBuilder.php diff --git a/index.php b/index.php index e3365c2..235c0be 100644 --- a/index.php +++ b/index.php @@ -1,48 +1,9 @@ get_record('course', ['id' => $courseId], '*', MUST_EXIST); - -require_login($course); - -$PAGE->set_url('/mod/gharar/index.php', ['id' => $courseId]); -$PAGE->set_title("$course->shortname " . util::get_string('plugin_name_plural')); -$PAGE->set_heading($course->fullname); -$PAGE->set_cacheable(false); -$PAGE->set_pagelayout('incourse'); - -$PAGE->navbar->add($PAGE->title, $PAGE->url); - -// TODO: Add a rendered to show all the meetings -echo $OUTPUT->header(); -echo $OUTPUT->heading(util::get_string('plugin_name_plural')); - -// TODO: Wrap it inside a renderable -$table = new html_table(); -$table->attributes['class'] = 'generaltable mod_index'; - -$table->head = [util::get_string('meeting_name'), util::get_string('meeting_link')]; -$table->align = ['center', 'center']; - -$instances = moodle_vars::get_instance()->get_database()->get_records('gharar', [ - 'course' => $courseId -]); - -foreach ($instances as $instance) { - $row = [ - html_writer::link(new moodle_url('view.php', ['id' => $courseId]), $instance->name), - $instance->link, - ]; - - $table->data[] = $row; -} - -echo html_writer::table($table); - -echo $OUTPUT->footer(); +echo (new IndexPageBuilder()) + ->build() + ->getOutput(); diff --git a/src/PageBuilding/IndexPageBuilder.php b/src/PageBuilding/IndexPageBuilder.php new file mode 100644 index 0000000..4ae33a6 --- /dev/null +++ b/src/PageBuilding/IndexPageBuilder.php @@ -0,0 +1,108 @@ +initParams() + ->initCourse() + ->requireLogin(); + } + + private function initParams(): self + { + $this->courseId = \required_param('id', \PARAM_INT); + + return $this; + } + + private function initCourse(): self + { + $this->course = $DB->get_record( + "course", + ["id" => $this->courseId], + "*", + \MUST_EXIST + ); + + return $this; + } + + private function requireLogin(): self + { + \require_login($this->course); + + return $this; + } + + protected function buildPage(): self + { + $page = Globals::getInstance()->getPage(); + + $page->set_url(self::URL, ["id" => $courseId]); + $page->set_title( + "{$this->course->shortname} " . + Util::getString("plugin_name_plural") + ); + $page->set_heading($this->course->fullname); + $page->set_cacheable(false); + $page->set_pagelayout("incourse"); + + $page->navbar->add($page->title, $page->url); + } + + protected function generateOutputHeading(): string + { + return Util::getString("plugin_name_plural"); + } + + protected function generateOutputMainContent(): string + { + // TODO: Wrap it inside a renderable + $table = new \html_table(); + $table->attributes["class"] = "generaltable mod_index"; + + $table->head = [ + Util::getString("meeting_name"), + Util::getString("meeting_link") + ]; + $table->align = ["center", "center"]; + + $instances = Globals::getInstance() + ->getDatabase() + ->get_records( + Plugin::DATABASE_MAIN_TABLE_NAME, + ["course" => $this->courseId] + ); + + foreach ($instances as $instance) { + $table->data[] = [ + \html_writer::link( + new \moodle_url( + ViewPageBuilder::URL, + ["id" => $this->courseId] + ), + $instance->name + ), + $instance->link, + ]; + } + + return \html_writer::table($table); + } +} diff --git a/src/PageBuilding/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php index f34adba..dd5b397 100644 --- a/src/PageBuilding/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -6,7 +6,7 @@ class ViewPageBuilder extends AbstractPageBuilder { - private const URL = Plugin::RELATIVE_PATH . "/view.php"; + public const URL = Plugin::RELATIVE_PATH . "/view.php"; /** @var int */ private $courseModuleId = null; From 7d345639695210b94006c711ffc4f34209abbda2 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 18:07:46 +0430 Subject: [PATCH 48/76] Update lib.php to use new Composer-autoloader-based classes --- lib.php | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lib.php b/lib.php index aec71a3..dbe5b88 100644 --- a/lib.php +++ b/lib.php @@ -1,41 +1,53 @@ get_database()->insert_record('gharar', $record); +/** + * @return true|int + */ +function gharar_add_instance(object $record): mixed +{ + $id = Globals::getInstance() + ->getDatabase() + ->insert_record(Plugin::DATABASE_MAIN_TABLE_NAME, $record); return $id; } -function gharar_update_instance($record) +function gharar_update_instance(object $record): bool { - $moodle = moodle_vars::get_instance(); - - // Important: The id is not stored in the 'id' field, but the 'instance' one + // Important: The id is not stored in the "id" field, but the "instance" one $record->id = $record->instance; - $result = $moodle->get_database()->update_record('gharar', $record); + $result = Globals::getInstance() + ->getDatabase() + ->update_record(Plugin::DATABASE_MAIN_TABLE_NAME, $record); return $result; } -function gharar_delete_instance($recordId) +function gharar_delete_instance(int $recordId): bool { - $moodle = moodle_vars::get_instance(); - - if (!$moodle->get_database()->get_record('gharar', ['id' => $recordId])) { + $database = Globals::getInstance()->getDatabase(); + + if ( + !$database->get_record( + Plugin::DATABASE_MAIN_TABLE_NAME, + ["id" => $recordId] + ) || + !$database->delete_records( + Plugin::DATABASE_MAIN_TABLE_NAME, + ["id" => $recordId] + ) + ) { return false; } - if (!$moodle->get_database()->delete_records('gharar', ['id' => $recordId])) { - return false; - } return true; } From 1b1596fac86e4be3c30f4666d044ca5dcede930c Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 18:16:07 +0430 Subject: [PATCH 49/76] Use require_once instead of require for Composer autoloader file --- index.php | 2 +- lib.php | 2 +- version.php | 2 +- view.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 235c0be..f9a3433 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ Date: Mon, 30 Aug 2021 18:36:23 +0430 Subject: [PATCH 50/76] Move mod_form.php functionality into InstanceDataForm class Make mod_gharar_mod_form class in the file an alias to it. --- mod_form.php | 38 +++------------------ src/InstanceDataForm.php | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 src/InstanceDataForm.php diff --git a/mod_form.php b/mod_form.php index 84665d6..8d56ed8 100644 --- a/mod_form.php +++ b/mod_form.php @@ -1,38 +1,10 @@ dirroot}/course/moodleform_mod.php"; +Util::forbidNonMoodleAccess(); -class mod_gharar_mod_form extends moodleform_mod -{ - public function definition() - { - $this->add_name_field(); - $this->add_link_field(); - - $this->standard_coursemodule_elements(); - $this->add_action_buttons(); - } - - private function add_name_field() - { - $this->_form->addElement('text', 'name', util::get_string( - 'meeting_name' - ), ['size' => 256]); - $this->_form->setType('name', PARAM_TEXT); - $this->_form->addRule('name', null, 'required', null, 'client'); - } - - private function add_link_field() - { - $this->_form->addElement('text', 'link', util::get_string( - 'meeting_link' - ), ['size' => 512]); - $this->_form->setType('link', PARAM_TEXT); - $this->_form->addRule('link', null, 'required', null, 'client'); - } -} +class_alias(InstanceDataForm::class, mod_gharar_mod_form::class); diff --git a/src/InstanceDataForm.php b/src/InstanceDataForm.php new file mode 100644 index 0000000..311eca1 --- /dev/null +++ b/src/InstanceDataForm.php @@ -0,0 +1,74 @@ +dirroot}/course/moodleform_mod.php"; + +class InstanceDataForm extends \moodleform_mod +{ + private const FIELD_NAME_NAME = "name"; + private const FIELD_NAME_TYPE = "text"; + private const FIELD_NAME_LENGTH = 256; + + private const FIELD_LINK_NAME = "link"; + private const FIELD_LINK_TYPE = "text"; + private const FIELD_LINK_LENGTH = 512; + + public function definition(): void + { + $this + ->addNameField() + ->addLinkField(); + + $this->standard_coursemodule_elements(); + $this->add_action_buttons(); + } + + private function addNameField(): self + { + $this->_form->addElement( + self::FIELD_NAME_TYPE, + self::FIELD_NAME_NAME, + Util::getString("meeting_name"), + ["size" => self::FIELD_NAME_LENGTH], + ); + + $this->_form->setType( + self::FIELD_NAME_NAME, + \PARAM_TEXT, + ); + $this->_form->addRule( + self::FIELD_NAME_NAME, + null, + "required", + null, + "client", + ); + + return $this; + } + + private function addLinkField(): self + { + $this->_form->addElement( + self::FIELD_LINK_TYPE, + self::FIELD_LINK_NAME, + Util::getString("meeting_link"), + ["size" => self::FIELD_NAME_LENGTH], + ); + + $this->_form->setType( + self::FIELD_LINK_NAME, + \PARAM_TEXT, + ); + $this->_form->addRule( + self::FIELD_LINK_NAME, + null, + "required", + null, + "client", + ); + + return $this; + } +} From 1e5a8042aced5f09ed7623bb795799c01eeab113 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 18:48:14 +0430 Subject: [PATCH 51/76] Migrate remaining files to new classes, use " instead of ' To be more consistent across the project, everywhere double- quotation is used instead of single-. --- build-zip.sh | 10 +++---- db/access.php | 38 ++++++++++++++------------- lang/en/gharar.php | 22 +++++++++------- lang/fa/gharar.php | 22 +++++++++------- src/PageBuilding/IndexPageBuilder.php | 2 +- version.php | 2 +- 6 files changed, 51 insertions(+), 45 deletions(-) diff --git a/build-zip.sh b/build-zip.sh index 7dd5015..28930ab 100755 --- a/build-zip.sh +++ b/build-zip.sh @@ -2,9 +2,9 @@ # Config # Create a temporary directory to prevent conflictions -tmpDirname='.tmp' -pluginName='gharar' -outputFilename='moodle-mod-gharar.zip' +tmpDirname=".tmp" +pluginName="gharar" +outputFilename="moodle-mod-gharar.zip" mainRepoDir="$(pwd)" tmpDir="$mainRepoDir/../$tmpDirname" @@ -12,9 +12,9 @@ tmpDir="$mainRepoDir/../$tmpDirname" mkdir "$tmpDir" cd "$tmpDir" -# Make sure the resulting file includes only one directory matching the plugin's name +# Make sure the resulting file includes only one directory matching plugin's name rsync -av "$mainRepoDir/" "./$pluginName" \ - --exclude '.git' --exclude '.gitignore' --exclude 'build-zip.sh' > /dev/null + --exclude ".git" --exclude ".gitignore" --exclude "build-zip.sh" > /dev/null # Remove previous zip file to prevent files to remain there # TODO: Remove this? diff --git a/db/access.php b/db/access.php index 6790c65..92d766b 100644 --- a/db/access.php +++ b/db/access.php @@ -1,31 +1,33 @@ [ - 'riskbitmask' => RISK_XSS, - 'captype' => 'write', - 'contextlevel' => CONTEXT_COURSE, - 'archetypes' => [ - 'manager' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, + "mod/gharar:add_instance" => [ + "riskbitmask" => RISK_XSS, + "captype" => "write", + "contextlevel" => CONTEXT_COURSE, + "archetypes" => [ + "manager" => CAP_ALLOW, + "editingteacher" => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities', + "clonepermissionsfrom" => "moodle/course:manageactivities", ], // Ability to view instances, regardless of the type - 'mod/gharar:view_instance' => [ - 'captype' => 'read', - 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => [ - 'student' => CAP_ALLOW, - 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + "mod/gharar:view_instance" => [ + "captype" => "read", + "contextlevel" => CONTEXT_MODULE, + "archetypes" => [ + "student" => CAP_ALLOW, + "teacher" => CAP_ALLOW, + "editingteacher" => CAP_ALLOW, + "manager" => CAP_ALLOW ] ], ]; diff --git a/lang/en/gharar.php b/lang/en/gharar.php index ce739ee..38db97a 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -1,19 +1,21 @@ courseId = \required_param('id', \PARAM_INT); + $this->courseId = \required_param("id", \PARAM_INT); return $this; } diff --git a/version.php b/version.php index 792e5c0..69c643c 100644 --- a/version.php +++ b/version.php @@ -9,4 +9,4 @@ $plugin->component = Plugin::COMPONENT_NAME; $plugin->version = 2021071603; -$plugin->release = '0.1.0-beta.2'; +$plugin->release = "0.1.0-beta.2"; From edb61793ea8e7000c08aec7fbae437d14e4d96d6 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 18:57:20 +0430 Subject: [PATCH 52/76] Ignore Composer dev dependencies in build-zip.sh --- build-zip.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build-zip.sh b/build-zip.sh index 28930ab..b0af16b 100755 --- a/build-zip.sh +++ b/build-zip.sh @@ -9,6 +9,11 @@ outputFilename="moodle-mod-gharar.zip" mainRepoDir="$(pwd)" tmpDir="$mainRepoDir/../$tmpDirname" +# Remove dev dependencies from vendor/ directory. Otherwise, the resulting file +# will be huge in size. For example, 80KB versus 17MB for the directory alone. +# At last, we will revert this change back. +composer --no-dev install > /dev/null + mkdir "$tmpDir" cd "$tmpDir" @@ -26,4 +31,8 @@ zip -r "$mainRepoDir/$outputFilename" "./$pluginName" > /dev/null cd "$mainRepoDir" rm -r "$tmpDir" +# Revert Composer dev dependencies back +cd "$mainRepoDir" +composer install > /dev/null + echo "Zip file created successfully." From bfe4136da93bc6062f6bc3b2adc0bb03b76ead5a Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 19:03:08 +0430 Subject: [PATCH 53/76] Update dependencies --- composer.lock | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/composer.lock b/composer.lock index 5a54eb3..84600ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6458fbea12208af97491f1480750423f", + "content-hash": "6f3bfaa6d4f297d147a8f3a762687560", "packages": [], "packages-dev": [ { @@ -1013,16 +1013,16 @@ }, { "name": "symfony/console", - "version": "v5.3.6", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2" + "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/51b71afd6d2dc8f5063199357b9880cea8d8bfe2", - "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "url": "https://api.github.com/repos/symfony/console/zipball/8b1008344647462ae6ec57559da166c2bfa5e16a", + "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a", "shasum": "" }, "require": { @@ -1092,7 +1092,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.6" + "source": "https://github.com/symfony/console/tree/v5.3.7" }, "funding": [ { @@ -1108,7 +1108,7 @@ "type": "tidelift" } ], - "time": "2021-07-27T19:10:22+00:00" + "time": "2021-08-25T20:02:16+00:00" }, { "name": "symfony/deprecation-contracts", @@ -1744,16 +1744,16 @@ }, { "name": "symfony/string", - "version": "v5.3.3", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1" + "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", - "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "url": "https://api.github.com/repos/symfony/string/zipball/8d224396e28d30f81969f083a58763b8b9ceb0a5", + "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5", "shasum": "" }, "require": { @@ -1807,7 +1807,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.3.3" + "source": "https://github.com/symfony/string/tree/v5.3.7" }, "funding": [ { @@ -1823,7 +1823,7 @@ "type": "tidelift" } ], - "time": "2021-06-27T11:44:38+00:00" + "time": "2021-08-26T08:00:08+00:00" }, { "name": "vimeo/psalm", @@ -2043,7 +2043,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": "^7.2" + }, "platform-dev": [], "plugin-api-version": "2.1.0" } From 1078fd609444a377513b8534b11744e490f999e2 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 19:55:11 +0430 Subject: [PATCH 54/76] Move build-zip.sh into bin/ directory, improve it Make its error handling better, improve path variables, and exclude the resulting zip from including the zip itself. --- build-zip.sh => bin/build-zip.sh | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) rename build-zip.sh => bin/build-zip.sh (52%) diff --git a/build-zip.sh b/bin/build-zip.sh similarity index 52% rename from build-zip.sh rename to bin/build-zip.sh index b0af16b..b2bd641 100755 --- a/build-zip.sh +++ b/bin/build-zip.sh @@ -6,33 +6,43 @@ tmpDirname=".tmp" pluginName="gharar" outputFilename="moodle-mod-gharar.zip" -mainRepoDir="$(pwd)" +# Exit on error +set -e + +mainRepoDir="$(dirname "$(realpath "$0")")/.." tmpDir="$mainRepoDir/../$tmpDirname" +# The resulting file path +zipFilePath="$mainRepoDir/$outputFilename" + # Remove dev dependencies from vendor/ directory. Otherwise, the resulting file # will be huge in size. For example, 80KB versus 17MB for the directory alone. # At last, we will revert this change back. -composer --no-dev install > /dev/null +echo "Removing Composer dev dependencies..." +composer --no-dev install > /dev/null 2>&1 -mkdir "$tmpDir" +mkdir -p "$tmpDir" cd "$tmpDir" # Make sure the resulting file includes only one directory matching plugin's name rsync -av "$mainRepoDir/" "./$pluginName" \ - --exclude ".git" --exclude ".gitignore" --exclude "build-zip.sh" > /dev/null + --exclude ".git" --exclude ".gitignore" --exclude "bin/" \ + --exclude "$outputFilename" > /dev/null + +# Remove previous zip file to prevent extra removed files to remain there +if [[ -e "$zipFilePath" ]]; then + rm "$zipFilePath" +fi -# Remove previous zip file to prevent files to remain there -# TODO: Remove this? -rm "$mainRepoDir/$outputFilename" # Create the zip file in the current directory -zip -r "$mainRepoDir/$outputFilename" "./$pluginName" > /dev/null +zip -r -y "$zipFilePath" "./$pluginName" > /dev/null # Cleanup cd "$mainRepoDir" rm -r "$tmpDir" -# Revert Composer dev dependencies back -cd "$mainRepoDir" -composer install > /dev/null - echo "Zip file created successfully." + +cd "$mainRepoDir" +echo "Re-adding Composer dev dependencies..." +composer install > /dev/null 2>&1 From 34612f1edb24076c0e83e8b314f94614c1945bd8 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 20:07:31 +0430 Subject: [PATCH 55/76] Set creator role and his homepage for the creator of the project :) --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3efd823..49b1eb5 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,9 @@ "authors": [ { "name": "Mohammad Amin Chitgarha", - "email": "machitgarha@outlook.com" + "email": "machitgarha@outlook.com", + "homepage": "https://github.com/machitgarha", + "role": "Creator" } ], "require": { From 0d401739fd5a2ca46dbe04fc3ec3193b6dc05c87 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 20:25:47 +0430 Subject: [PATCH 56/76] Make version.php static (remove Plugin::COMPONENT_NAME) --- src/Plugin.php | 1 - version.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 9235375..9e8c3bb 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -5,7 +5,6 @@ class Plugin { public const MODULE_NAME = "gharar"; - public const COMPONENT_NAME = "mod_gharar"; public const DATABASE_MAIN_TABLE_NAME = "gharar"; diff --git a/version.php b/version.php index 69c643c..3a45b14 100644 --- a/version.php +++ b/version.php @@ -3,10 +3,9 @@ require_once __DIR__ . "/vendor/autoload.php"; use MAChitgarha\MoodleModGharar\Util; -use MAChitgarha\MoodleModGharar\Plugin; Util::forbidNonMoodleAccess(); -$plugin->component = Plugin::COMPONENT_NAME; +$plugin->component = "mod_gharar"; $plugin->version = 2021071603; $plugin->release = "0.1.0-beta.2"; From 3ff8fdf2f9c8d57849ad8aeb93770e0ceadebeca Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 20:41:33 +0430 Subject: [PATCH 57/76] Add modulenameplural string, used by Moodle --- lang/en/gharar.php | 4 +++- lang/fa/gharar.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/en/gharar.php b/lang/en/gharar.php index 38db97a..ed0acaa 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -7,13 +7,15 @@ Util::forbidNonMoodleAccess(); const PLUGIN_NAME = "Gharar"; +const PLUGIN_NAME_PLURAL = PLUGIN_NAME . "s"; // Moodle-specific $string["modulename"] = PLUGIN_NAME; $string["pluginname"] = PLUGIN_NAME; +$string["modulenameplural"] = PLUGIN_NAME_PLURAL; $string["plugin_name"] = PLUGIN_NAME; -$string["plugin_name_plural"] = PLUGIN_NAME . "s"; +$string["plugin_name_plural"] = PLUGIN_NAME_PLURAL; $string["meeting_name"] = "Name"; $string["meeting_link"] = "Link"; diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index 310b0d4..cceba9f 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -7,13 +7,15 @@ Util::forbidNonMoodleAccess(); const PLUGIN_NAME = "قرار"; +const PLUGIN_NAME_PLURAL = PLUGIN_NAME . "ها"; // Moodle-specific $string["modulename"] = PLUGIN_NAME; $string["pluginname"] = PLUGIN_NAME; +$string["modulenameplural"] = PLUGIN_NAME_PLURAL; $string["plugin_name"] = PLUGIN_NAME; -$string["plugin_name_plural"] = PLUGIN_NAME . "ها"; +$string["plugin_name_plural"] = PLUGIN_NAME_PLURAL; $string["meeting_name"] = "نام"; $string["meeting_link"] = "پیوند"; From 29938834d84dcbf2587257c9778ff6e71f86378c Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 21:02:27 +0430 Subject: [PATCH 58/76] Fix typings in Globals class --- src/Moodle/Globals.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index 7669672..21cf53d 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -15,11 +15,11 @@ class Globals /** @var mysqli_native_moodle_database */ private $database; - /** @var stdClass */ + /** @var \stdClass */ private $config; - /** @var core_renderer */ + /** @var \core_renderer */ private $output; - /** @var moodle_page */ + /** @var \moodle_page */ private $page; private function __construct() @@ -40,22 +40,22 @@ public static function getInstance(): self return self::$instance; } - public function getDatabase(): mysqli_native_moodle_database + public function getDatabase(): \mysqli_native_moodle_database { return $this->database; } - public function getConfig(): stdClass + public function getConfig(): \stdClass { return $this->config; } - public function getOutput(): core_renderer + public function getOutput(): \core_renderer { return $this->output; } - public function getPage(): moodle_page + public function getPage(): \moodle_page { return $this->page; } From a94db6e8fe91c58a2e755f782f1f27522b386e30 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 21:02:54 +0430 Subject: [PATCH 59/76] Move InstanceDataForm back to mod_gharar_mod_form in mod_form.php The parent class, i.e. moodleform_mod, extracts the module name from the name of class using regex, and thus it sounds impossible to have a class not in the form of mod_xx_mod_form. This is the main reason of the change. Also, the globals (including $CFG) required in the parent clas makes the PSR4-based class definitions a bit weird. --- mod_form.php | 74 ++++++++++++++++++++++++++++++++++++++-- src/InstanceDataForm.php | 74 ---------------------------------------- 2 files changed, 72 insertions(+), 76 deletions(-) delete mode 100644 src/InstanceDataForm.php diff --git a/mod_form.php b/mod_form.php index 8d56ed8..2960506 100644 --- a/mod_form.php +++ b/mod_form.php @@ -2,9 +2,79 @@ require_once __DIR__ . "/vendor/autoload.php"; +use MAChitgarha\MoodleModGharar\Moodle\Globals; use MAChitgarha\MoodleModGharar\Util; -use MAChitgarha\MoodleModGharar\InstanceDataForm; Util::forbidNonMoodleAccess(); -class_alias(InstanceDataForm::class, mod_gharar_mod_form::class); +$moodleRootDir = Globals::getInstance()->getConfig()->dirroot; +require_once "{$moodleRootDir}/course/moodleform_mod.php"; + +class mod_gharar_mod_form extends \moodleform_mod +{ + private const FIELD_NAME_NAME = "name"; + private const FIELD_NAME_TYPE = "text"; + private const FIELD_NAME_LENGTH = 256; + + private const FIELD_LINK_NAME = "link"; + private const FIELD_LINK_TYPE = "text"; + private const FIELD_LINK_LENGTH = 512; + + public function definition(): void + { + $this + ->addNameField() + ->addLinkField(); + + $this->standard_coursemodule_elements(); + $this->add_action_buttons(); + } + + private function addNameField(): self + { + $this->_form->addElement( + self::FIELD_NAME_TYPE, + self::FIELD_NAME_NAME, + Util::getString("meeting_name"), + ["size" => self::FIELD_NAME_LENGTH], + ); + + $this->_form->setType( + self::FIELD_NAME_NAME, + \PARAM_TEXT, + ); + $this->_form->addRule( + self::FIELD_NAME_NAME, + null, + "required", + null, + "client", + ); + + return $this; + } + + private function addLinkField(): self + { + $this->_form->addElement( + self::FIELD_LINK_TYPE, + self::FIELD_LINK_NAME, + Util::getString("meeting_link"), + ["size" => self::FIELD_NAME_LENGTH], + ); + + $this->_form->setType( + self::FIELD_LINK_NAME, + \PARAM_TEXT, + ); + $this->_form->addRule( + self::FIELD_LINK_NAME, + null, + "required", + null, + "client", + ); + + return $this; + } +} diff --git a/src/InstanceDataForm.php b/src/InstanceDataForm.php deleted file mode 100644 index 311eca1..0000000 --- a/src/InstanceDataForm.php +++ /dev/null @@ -1,74 +0,0 @@ -dirroot}/course/moodleform_mod.php"; - -class InstanceDataForm extends \moodleform_mod -{ - private const FIELD_NAME_NAME = "name"; - private const FIELD_NAME_TYPE = "text"; - private const FIELD_NAME_LENGTH = 256; - - private const FIELD_LINK_NAME = "link"; - private const FIELD_LINK_TYPE = "text"; - private const FIELD_LINK_LENGTH = 512; - - public function definition(): void - { - $this - ->addNameField() - ->addLinkField(); - - $this->standard_coursemodule_elements(); - $this->add_action_buttons(); - } - - private function addNameField(): self - { - $this->_form->addElement( - self::FIELD_NAME_TYPE, - self::FIELD_NAME_NAME, - Util::getString("meeting_name"), - ["size" => self::FIELD_NAME_LENGTH], - ); - - $this->_form->setType( - self::FIELD_NAME_NAME, - \PARAM_TEXT, - ); - $this->_form->addRule( - self::FIELD_NAME_NAME, - null, - "required", - null, - "client", - ); - - return $this; - } - - private function addLinkField(): self - { - $this->_form->addElement( - self::FIELD_LINK_TYPE, - self::FIELD_LINK_NAME, - Util::getString("meeting_link"), - ["size" => self::FIELD_NAME_LENGTH], - ); - - $this->_form->setType( - self::FIELD_LINK_NAME, - \PARAM_TEXT, - ); - $this->_form->addRule( - self::FIELD_LINK_NAME, - null, - "required", - null, - "client", - ); - - return $this; - } -} From 0f05a8cec06319009f5c51ab5bd7e7111daa1a7a Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 21:11:07 +0430 Subject: [PATCH 60/76] Fix an undefined constant in Util::getString() Re-add Plugin::COMPONENT_NAME. --- src/Plugin.php | 1 + src/Util.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Plugin.php b/src/Plugin.php index 9e8c3bb..9235375 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -5,6 +5,7 @@ class Plugin { public const MODULE_NAME = "gharar"; + public const COMPONENT_NAME = "mod_gharar"; public const DATABASE_MAIN_TABLE_NAME = "gharar"; diff --git a/src/Util.php b/src/Util.php index 0b7439e..9af62ff 100644 --- a/src/Util.php +++ b/src/Util.php @@ -13,6 +13,6 @@ public static function forbidNonMoodleAccess(): void public static function getString($which, ...$otherArgs) { - return get_string($which, plugin::NAME, ...$otherArgs); + return \get_string($which, Plugin::COMPONENT_NAME, ...$otherArgs); } } From 1c0398d2659c77adb5a419cd6f9903369a364f2b Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 21:18:17 +0430 Subject: [PATCH 61/76] Fix mis-wordings in capabilities (db/access.php), remove a mixed type --- db/access.php | 4 ++-- lib.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/access.php b/db/access.php index 92d766b..bf64555 100644 --- a/db/access.php +++ b/db/access.php @@ -8,7 +8,7 @@ $capabilities = [ // Ability to add a new Gharar instance - "mod/gharar:add_instance" => [ + "mod/gharar:addinstance" => [ "riskbitmask" => RISK_XSS, "captype" => "write", "contextlevel" => CONTEXT_COURSE, @@ -20,7 +20,7 @@ ], // Ability to view instances, regardless of the type - "mod/gharar:view_instance" => [ + "mod/gharar:view" => [ "captype" => "read", "contextlevel" => CONTEXT_MODULE, "archetypes" => [ diff --git a/lib.php b/lib.php index abaafc3..d76c98f 100644 --- a/lib.php +++ b/lib.php @@ -11,7 +11,7 @@ /** * @return true|int */ -function gharar_add_instance(object $record): mixed +function gharar_add_instance(object $record) { $id = Globals::getInstance() ->getDatabase() From 416e592ad41d3e0446b285da0c15ff0439f58ffd Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 21:22:41 +0430 Subject: [PATCH 62/76] Fix some require_once paths for Composer autoload --- db/access.php | 2 +- lang/en/gharar.php | 2 +- lang/fa/gharar.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/access.php b/db/access.php index bf64555..a6c0eb2 100644 --- a/db/access.php +++ b/db/access.php @@ -1,6 +1,6 @@ Date: Mon, 30 Aug 2021 23:17:15 +0430 Subject: [PATCH 63/76] Fix missing namespaces, output, and use statements --- index.php | 2 +- src/PageBuilding/IndexPageBuilder.php | 2 +- src/PageBuilding/ViewPageBuilder.php | 1 + view.php | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index f9a3433..4d4c99b 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ require_once __DIR__ . "/vendor/autoload.php"; -use MAChitgarha\MoodleModGharar\IndexPageBuilder; +use MAChitgarha\MoodleModGharar\PageBuilding\IndexPageBuilder; echo (new IndexPageBuilder()) ->build() diff --git a/src/PageBuilding/IndexPageBuilder.php b/src/PageBuilding/IndexPageBuilder.php index d4e7593..88e5800 100644 --- a/src/PageBuilding/IndexPageBuilder.php +++ b/src/PageBuilding/IndexPageBuilder.php @@ -2,8 +2,8 @@ namespace MAChitgarha\MoodleModGharar; +use MAChitgarha\MoodleModGharar\Plugin; use MAChitgarha\MoodleModGharar\Moodle\Globals; - use MAChitgarha\MoodleModGharar\PageBuilding\ViewPageBuilder; class IndexPageBuilder diff --git a/src/PageBuilding/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php index dd5b397..ef1cb12 100644 --- a/src/PageBuilding/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -2,6 +2,7 @@ namespace MAChitgarha\MoodleModGharar\PageBuilding; +use MAChitgarha\MoodleModGharar\Plugin; use MAChitgarha\MoodleModGharar\Moodle\Globals; class ViewPageBuilder extends AbstractPageBuilder diff --git a/view.php b/view.php index 12ae0be..d7ac371 100644 --- a/view.php +++ b/view.php @@ -2,8 +2,8 @@ require_once __DIR__ . "/vendor/autoload.php"; -use MAChitgarha\MoodleModGharar\ViewPageBuilder; +use MAChitgarha\MoodleModGharar\PageBuilding\ViewPageBuilder; -$x = (new ViewPageBuilder()) +echo (new ViewPageBuilder()) ->build() ->getOutput(); From 6652d256ecbfcafbc987224e802c22d76ead073a Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 23:30:35 +0430 Subject: [PATCH 64/76] Fix Globals::getOutput() return type, other improvements --- src/Moodle/Globals.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index 21cf53d..53e6140 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -2,10 +2,6 @@ namespace MAChitgarha\MoodleModGharar\Moodle; -use moodle_page; -use mysqli_native_moodle_database; -use core_renderer; - // For using $CFG global require_once __DIR__ . "/../../../../config.php"; @@ -17,7 +13,7 @@ class Globals private $database; /** @var \stdClass */ private $config; - /** @var \core_renderer */ + /** @var \bootstrap_renderer */ private $output; /** @var \moodle_page */ private $page; @@ -50,7 +46,7 @@ public function getConfig(): \stdClass return $this->config; } - public function getOutput(): \core_renderer + public function getOutput(): \bootstrap_renderer { return $this->output; } From 16c9a0f2ccf74a851787bd4c6f5c9201f70bfb4e Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Mon, 30 Aug 2021 23:40:34 +0430 Subject: [PATCH 65/76] Fix missing stuff, including use and require statements --- src/PageBuilding/AbstractPageBuilder.php | 15 +++++++++++++++ src/PageBuilding/IndexPageBuilder.php | 21 +++++++++++++-------- src/PageBuilding/ViewPageBuilder.php | 1 + 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/PageBuilding/AbstractPageBuilder.php b/src/PageBuilding/AbstractPageBuilder.php index 1f438ee..3720e6e 100644 --- a/src/PageBuilding/AbstractPageBuilder.php +++ b/src/PageBuilding/AbstractPageBuilder.php @@ -4,6 +4,21 @@ use MAChitgarha\MoodleModGharar\Moodle\Globals; +/* + * Bootstrap include file. + * + * The config.php file is not limited to providing $CFG global (although the + * Globals class should be used in this case), unlike its name suggests, but + * also includes all required functions and classes as well, like the + * well-known required_param() function. + * + * As why those parent directories in the path exists: The first two are + * obvious, reaching the root of the plugin; so we must go up two more levels + * to reach the Moodle root. The $CFG or Globals::getConfig() function cannot + * be used either: They rely on the same file we are including. + */ +require_once __DIR__ . "/../../../../config.php"; + abstract class AbstractPageBuilder { /** @var string */ diff --git a/src/PageBuilding/IndexPageBuilder.php b/src/PageBuilding/IndexPageBuilder.php index 88e5800..6433a91 100644 --- a/src/PageBuilding/IndexPageBuilder.php +++ b/src/PageBuilding/IndexPageBuilder.php @@ -1,12 +1,13 @@ course = $DB->get_record( - "course", - ["id" => $this->courseId], - "*", - \MUST_EXIST - ); + $this->course = Globals::getInstance() + ->getDatabase() + ->get_record( + "course", + ["id" => $this->courseId], + "*", + \MUST_EXIST + ); return $this; } @@ -64,6 +67,8 @@ protected function buildPage(): self $page->set_pagelayout("incourse"); $page->navbar->add($page->title, $page->url); + + return $this; } protected function generateOutputHeading(): string diff --git a/src/PageBuilding/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php index ef1cb12..0956da1 100644 --- a/src/PageBuilding/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -2,6 +2,7 @@ namespace MAChitgarha\MoodleModGharar\PageBuilding; +use MAChitgarha\MoodleModGharar\Util; use MAChitgarha\MoodleModGharar\Plugin; use MAChitgarha\MoodleModGharar\Moodle\Globals; From 9a4d59e5639bc25fe6067ea1eab21a86c453ca17 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 11:20:53 +0430 Subject: [PATCH 66/76] Move language strings to classes, add pluginadministration string --- lang/en/gharar.php | 17 ++--------------- lang/fa/gharar.php | 17 ++--------------- src/LanguageString/English.php | 27 +++++++++++++++++++++++++++ src/LanguageString/Farsi.php | 27 +++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 src/LanguageString/English.php create mode 100644 src/LanguageString/Farsi.php diff --git a/lang/en/gharar.php b/lang/en/gharar.php index 9c5d17a..0528b0c 100644 --- a/lang/en/gharar.php +++ b/lang/en/gharar.php @@ -3,21 +3,8 @@ require_once __DIR__ . "/../../vendor/autoload.php"; use MAChitgarha\MoodleModGharar\Util; +use MAChitgarha\MoodleModGharar\LanguageString\English; Util::forbidNonMoodleAccess(); -const PLUGIN_NAME = "Gharar"; -const PLUGIN_NAME_PLURAL = PLUGIN_NAME . "s"; - -// Moodle-specific -$string["modulename"] = PLUGIN_NAME; -$string["pluginname"] = PLUGIN_NAME; -$string["modulenameplural"] = PLUGIN_NAME_PLURAL; - -$string["plugin_name"] = PLUGIN_NAME; -$string["plugin_name_plural"] = PLUGIN_NAME_PLURAL; - -$string["meeting_name"] = "Name"; -$string["meeting_link"] = "Link"; - -$string["enter_meeting_link"] = "Enter"; +$string = English::STRING; diff --git a/lang/fa/gharar.php b/lang/fa/gharar.php index 3360c26..adc4416 100644 --- a/lang/fa/gharar.php +++ b/lang/fa/gharar.php @@ -3,21 +3,8 @@ require_once __DIR__ . "/../../vendor/autoload.php"; use MAChitgarha\MoodleModGharar\Util; +use MAChitgarha\MoodleModGharar\LanguageString\Farsi; Util::forbidNonMoodleAccess(); -const PLUGIN_NAME = "قرار"; -const PLUGIN_NAME_PLURAL = PLUGIN_NAME . "ها"; - -// Moodle-specific -$string["modulename"] = PLUGIN_NAME; -$string["pluginname"] = PLUGIN_NAME; -$string["modulenameplural"] = PLUGIN_NAME_PLURAL; - -$string["plugin_name"] = PLUGIN_NAME; -$string["plugin_name_plural"] = PLUGIN_NAME_PLURAL; - -$string["meeting_name"] = "نام"; -$string["meeting_link"] = "پیوند"; - -$string["enter_meeting_link"] = "ورود"; +$string = Farsi::STRING; diff --git a/src/LanguageString/English.php b/src/LanguageString/English.php new file mode 100644 index 0000000..ac131ff --- /dev/null +++ b/src/LanguageString/English.php @@ -0,0 +1,27 @@ + self::PLUGIN_NAME, + "pluginname" => self::PLUGIN_NAME, + "modulenameplural" => self::PLUGIN_NAME_PLURAL, + + "pluginadministration" => self::PLUGIN_NAME . " administration", + // } + + "plugin_name" => self::PLUGIN_NAME, + "plugin_name_plural" => self::PLUGIN_NAME_PLURAL, + + "meeting_name" => "Name", + "meeting_link" => "Link", + + "enter_meeting_link" => "Enter", + ]; +} diff --git a/src/LanguageString/Farsi.php b/src/LanguageString/Farsi.php new file mode 100644 index 0000000..6d6452b --- /dev/null +++ b/src/LanguageString/Farsi.php @@ -0,0 +1,27 @@ + self::PLUGIN_NAME, + "pluginname" => self::PLUGIN_NAME, + "modulenameplural" => self::PLUGIN_NAME_PLURAL, + + "pluginadministration" => "مدیریت " . self::PLUGIN_NAME, + // } + + "plugin_name" => self::PLUGIN_NAME, + "plugin_name_plural" => self::PLUGIN_NAME_PLURAL, + + "meeting_name" => "نام", + "meeting_link" => "پیوند", + + "enter_meeting_link" => "ورود", + ]; +} From bd5e733af678f1bc2147d088e2ca12493fda5f4b Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 11:48:33 +0430 Subject: [PATCH 67/76] Bump version to 0.1.0-beta.3, add TODOs, improve version.php --- src/LanguageString/Farsi.php | 2 ++ src/PageBuilding/ViewPageBuilder.php | 1 + version.php | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/LanguageString/Farsi.php b/src/LanguageString/Farsi.php index 6d6452b..ee97508 100644 --- a/src/LanguageString/Farsi.php +++ b/src/LanguageString/Farsi.php @@ -14,6 +14,8 @@ class Farsi "modulenameplural" => self::PLUGIN_NAME_PLURAL, "pluginadministration" => "مدیریت " . self::PLUGIN_NAME, + + // TODO: Add modulename_help // } "plugin_name" => self::PLUGIN_NAME, diff --git a/src/PageBuilding/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php index 0956da1..af6c1f1 100644 --- a/src/PageBuilding/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -92,6 +92,7 @@ protected function generateOutputHeading(): string protected function generateOutputMainContent(): string { + // TODO: Open in a new tab return \html_writer::link( $this->moduleInstance->link, Util::getString("enter_meeting_link") diff --git a/version.php b/version.php index 3a45b14..bd6ff21 100644 --- a/version.php +++ b/version.php @@ -7,5 +7,10 @@ Util::forbidNonMoodleAccess(); $plugin->component = "mod_gharar"; -$plugin->version = 2021071603; -$plugin->release = "0.1.0-beta.2"; +$plugin->version = 2021071604; +$plugin->release = "0.1.0-beta.3"; +$plugin->maturity = MATURITY_BETA; + +// Minimum Moodle version is 3.9.0 +$plugin->requires = 2020061500; +$plugin->supported = [39, 311]; From a11f240b5f0e38df9db53f09c6cab0dfbc5fbe63 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 17:22:25 +0430 Subject: [PATCH 68/76] Include machitgarha/bimoo as a dev dependency --- composer.json | 3 ++- composer.lock | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 49b1eb5..91995f0 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "php": "^7.2" }, "require-dev": { - "vimeo/psalm": "^4.9" + "vimeo/psalm": "^4.9", + "machitgarha/bimoo": "^3.11" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 84600ad..79cea85 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6f3bfaa6d4f297d147a8f3a762687560", + "content-hash": "253a8172c9d583771272d6f226ad72d8", "packages": [], "packages-dev": [ { @@ -529,6 +529,43 @@ }, "time": "2021-02-22T14:02:09+00:00" }, + { + "name": "machitgarha/bimoo", + "version": "3.11.1.0", + "source": { + "type": "git", + "url": "https://github.com/machitgarha/bimoo.git", + "reference": "b78fbbdb19b02c706bad6bc9a7d93f5450aabe37" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/machitgarha/bimoo/zipball/b78fbbdb19b02c706bad6bc9a7d93f5450aabe37", + "reference": "b78fbbdb19b02c706bad6bc9a7d93f5450aabe37", + "shasum": "" + }, + "require-dev": { + "php-stubs/generator": "^0.6.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Mohammad Amin Chitgarha", + "email": "machitgarha@outlook.com", + "homepage": "https://github.com/machitgarha", + "role": "Creator" + } + ], + "description": "Moodle declaration stubs, helping IDEs and static analyzers", + "support": { + "issues": "https://github.com/machitgarha/bimoo/issues", + "source": "https://github.com/machitgarha/bimoo/tree/3.11.1.0" + }, + "time": "2021-08-31T12:40:07+00:00" + }, { "name": "netresearch/jsonmapper", "version": "v4.0.0", From ed75a641524866c92c8104c21f08a361824a1f68 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 17:22:52 +0430 Subject: [PATCH 69/76] Add initial psalm.xml, add machitgarha/bimoo stubs file to it --- psalm.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 psalm.xml diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..60908cc --- /dev/null +++ b/psalm.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + From 5ad92a7060027446bf1272aa55a2ea2e4aedaa44 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 17:43:26 +0430 Subject: [PATCH 70/76] Lock machitgarha/bimoo to 3.11.1, update it to 3.11.1.1 --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 91995f0..88a9353 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "vimeo/psalm": "^4.9", - "machitgarha/bimoo": "^3.11" + "machitgarha/bimoo": "^3.11.1" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 79cea85..b92a6cb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "253a8172c9d583771272d6f226ad72d8", + "content-hash": "0a1137ab21a04656a4a2e777df408b9a", "packages": [], "packages-dev": [ { @@ -531,16 +531,16 @@ }, { "name": "machitgarha/bimoo", - "version": "3.11.1.0", + "version": "3.11.1.1", "source": { "type": "git", "url": "https://github.com/machitgarha/bimoo.git", - "reference": "b78fbbdb19b02c706bad6bc9a7d93f5450aabe37" + "reference": "4878e3641c57afd9a4a5953a3d9c0b68a360a2d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/machitgarha/bimoo/zipball/b78fbbdb19b02c706bad6bc9a7d93f5450aabe37", - "reference": "b78fbbdb19b02c706bad6bc9a7d93f5450aabe37", + "url": "https://api.github.com/repos/machitgarha/bimoo/zipball/4878e3641c57afd9a4a5953a3d9c0b68a360a2d5", + "reference": "4878e3641c57afd9a4a5953a3d9c0b68a360a2d5", "shasum": "" }, "require-dev": { @@ -562,9 +562,9 @@ "description": "Moodle declaration stubs, helping IDEs and static analyzers", "support": { "issues": "https://github.com/machitgarha/bimoo/issues", - "source": "https://github.com/machitgarha/bimoo/tree/3.11.1.0" + "source": "https://github.com/machitgarha/bimoo/tree/3.11.1.1" }, - "time": "2021-08-31T12:40:07+00:00" + "time": "2021-08-31T13:09:40+00:00" }, { "name": "netresearch/jsonmapper", From ed22d21e615b92bd9d27968ce3ef74fb8053ef5f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 19:28:26 +0430 Subject: [PATCH 71/76] Fix some default values and types thanks to Psalm --- src/Moodle/Globals.php | 2 +- src/PageBuilding/IndexPageBuilder.php | 4 ++-- src/PageBuilding/ViewPageBuilder.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index 53e6140..419e13a 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -9,7 +9,7 @@ class Globals { private static $instance = null; - /** @var mysqli_native_moodle_database */ + /** @var \mysqli_native_moodle_database */ private $database; /** @var \stdClass */ private $config; diff --git a/src/PageBuilding/IndexPageBuilder.php b/src/PageBuilding/IndexPageBuilder.php index 6433a91..1737f40 100644 --- a/src/PageBuilding/IndexPageBuilder.php +++ b/src/PageBuilding/IndexPageBuilder.php @@ -12,10 +12,10 @@ class IndexPageBuilder extends AbstractPageBuilder private const URL = Plugin::RELATIVE_PATH . "/index.php"; /** @var int */ - private $courseId = null; + private $courseId; /** @var \stdClass */ - private $course = null; + private $course; public function __construct() { diff --git a/src/PageBuilding/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php index af6c1f1..3e121bb 100644 --- a/src/PageBuilding/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -11,15 +11,15 @@ class ViewPageBuilder extends AbstractPageBuilder public const URL = Plugin::RELATIVE_PATH . "/view.php"; /** @var int */ - private $courseModuleId = null; + private $courseModuleId; /** @var \stdClass */ - private $course = null; + private $course; /** @var \cm_info */ - private $courseModule = null; + private $courseModule; /** @var object */ - private $moduleInstance = null; + private $moduleInstance; public function __construct() { From ed73fe0d1f922e12bc5ee738acdd9ed2566ba844 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 19:31:47 +0430 Subject: [PATCH 72/76] Fix a wrong variable name thanks to Psalm --- src/PageBuilding/IndexPageBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PageBuilding/IndexPageBuilder.php b/src/PageBuilding/IndexPageBuilder.php index 1737f40..00aeebb 100644 --- a/src/PageBuilding/IndexPageBuilder.php +++ b/src/PageBuilding/IndexPageBuilder.php @@ -57,7 +57,7 @@ protected function buildPage(): self { $page = Globals::getInstance()->getPage(); - $page->set_url(self::URL, ["id" => $courseId]); + $page->set_url(self::URL, ["id" => $this->courseId]); $page->set_title( "{$this->course->shortname} " . Util::getString("plugin_name_plural") From c4717c9f07a199ef38043dccf87963c1fdfed1e7 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 19:42:23 +0430 Subject: [PATCH 73/76] Update machitgarha/bimoo to 3.11.1.2 --- composer.lock | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index b92a6cb..d587bf5 100644 --- a/composer.lock +++ b/composer.lock @@ -531,22 +531,32 @@ }, { "name": "machitgarha/bimoo", - "version": "3.11.1.1", + "version": "3.11.1.2", "source": { "type": "git", "url": "https://github.com/machitgarha/bimoo.git", - "reference": "4878e3641c57afd9a4a5953a3d9c0b68a360a2d5" + "reference": "4fb87dc7b5efc1a28d81caf65fb6bd2641767fcc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/machitgarha/bimoo/zipball/4878e3641c57afd9a4a5953a3d9c0b68a360a2d5", - "reference": "4878e3641c57afd9a4a5953a3d9c0b68a360a2d5", + "url": "https://api.github.com/repos/machitgarha/bimoo/zipball/4fb87dc7b5efc1a28d81caf65fb6bd2641767fcc", + "reference": "4fb87dc7b5efc1a28d81caf65fb6bd2641767fcc", "shasum": "" }, + "require": { + "php": "^7.4|^8.0" + }, "require-dev": { - "php-stubs/generator": "^0.6.0" + "php-stubs/generator": "^0.6.0", + "symfony/console": "^5.3", + "webmozart/path-util": "^2.3" }, "type": "library", + "autoload": { + "psr-4": { + "MAChitgarha\\Bimoo\\": "src" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" @@ -562,9 +572,9 @@ "description": "Moodle declaration stubs, helping IDEs and static analyzers", "support": { "issues": "https://github.com/machitgarha/bimoo/issues", - "source": "https://github.com/machitgarha/bimoo/tree/3.11.1.1" + "source": "https://github.com/machitgarha/bimoo/tree/3.11.1.2" }, - "time": "2021-08-31T13:09:40+00:00" + "time": "2021-08-31T15:08:27+00:00" }, { "name": "netresearch/jsonmapper", From 46adceff6fb44102500fa229a029cca2515e13eb Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 20:00:32 +0430 Subject: [PATCH 74/76] Ignore some Psalm errors, because of being incorrect For example, including config.php file in Globals.php. --- psalm.xml | 5 +++++ src/Moodle/Globals.php | 5 ++++- src/PageBuilding/AbstractPageBuilder.php | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/psalm.xml b/psalm.xml index 60908cc..97b7ded 100644 --- a/psalm.xml +++ b/psalm.xml @@ -15,4 +15,9 @@ + + + + + diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index 419e13a..c29f4d7 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -2,7 +2,10 @@ namespace MAChitgarha\MoodleModGharar\Moodle; -// For using $CFG global +/** + * For using $CFG global. + * @psalm-suppress MissingFile + */ require_once __DIR__ . "/../../../../config.php"; class Globals diff --git a/src/PageBuilding/AbstractPageBuilder.php b/src/PageBuilding/AbstractPageBuilder.php index 3720e6e..c07189b 100644 --- a/src/PageBuilding/AbstractPageBuilder.php +++ b/src/PageBuilding/AbstractPageBuilder.php @@ -4,7 +4,7 @@ use MAChitgarha\MoodleModGharar\Moodle\Globals; -/* +/** * Bootstrap include file. * * The config.php file is not limited to providing $CFG global (although the @@ -16,6 +16,8 @@ * obvious, reaching the root of the plugin; so we must go up two more levels * to reach the Moodle root. The $CFG or Globals::getConfig() function cannot * be used either: They rely on the same file we are including. + * + * @psalm-suppress MissingFile */ require_once __DIR__ . "/../../../../config.php"; From 67c2a5855098d8e8d62ef188e9e68bd511f1d89f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 20:07:33 +0430 Subject: [PATCH 75/76] Fix some typings --- src/Moodle/Globals.php | 1 + src/Util.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Moodle/Globals.php b/src/Moodle/Globals.php index c29f4d7..5f99bd4 100644 --- a/src/Moodle/Globals.php +++ b/src/Moodle/Globals.php @@ -10,6 +10,7 @@ class Globals { + /** @var ?self */ private static $instance = null; /** @var \mysqli_native_moodle_database */ diff --git a/src/Util.php b/src/Util.php index 9af62ff..f485f20 100644 --- a/src/Util.php +++ b/src/Util.php @@ -11,7 +11,10 @@ public static function forbidNonMoodleAccess(): void } } - public static function getString($which, ...$otherArgs) + /** + * @param mixed ...$otherArgs + */ + public static function getString(string $which, ...$otherArgs): string { return \get_string($which, Plugin::COMPONENT_NAME, ...$otherArgs); } From 01fb8c632a8baf6235fff98179f000c5563b3a37 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Chitgarha Date: Tue, 31 Aug 2021 20:14:05 +0430 Subject: [PATCH 76/76] Open links of index.php and view.php in a new tab --- src/PageBuilding/IndexPageBuilder.php | 3 ++- src/PageBuilding/ViewPageBuilder.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PageBuilding/IndexPageBuilder.php b/src/PageBuilding/IndexPageBuilder.php index 00aeebb..69e99ac 100644 --- a/src/PageBuilding/IndexPageBuilder.php +++ b/src/PageBuilding/IndexPageBuilder.php @@ -102,7 +102,8 @@ protected function generateOutputMainContent(): string ViewPageBuilder::URL, ["id" => $this->courseId] ), - $instance->name + $instance->name, + ["target" => "_blank"], ), $instance->link, ]; diff --git a/src/PageBuilding/ViewPageBuilder.php b/src/PageBuilding/ViewPageBuilder.php index 3e121bb..b7c77b9 100644 --- a/src/PageBuilding/ViewPageBuilder.php +++ b/src/PageBuilding/ViewPageBuilder.php @@ -92,10 +92,10 @@ protected function generateOutputHeading(): string protected function generateOutputMainContent(): string { - // TODO: Open in a new tab return \html_writer::link( $this->moduleInstance->link, - Util::getString("enter_meeting_link") + Util::getString("enter_meeting_link"), + ["target" => "_blank"], ); } }