Skip to content

Commit

Permalink
0.6.19
Browse files Browse the repository at this point in the history
  • Loading branch information
mona-shakiba committed Oct 16, 2024
1 parent 77b26bd commit 0386da2
Show file tree
Hide file tree
Showing 91 changed files with 1,119 additions and 398 deletions.
3 changes: 2 additions & 1 deletion admin/tool/forcedcache/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
$plugin->requires = 2017051500;
$plugin->component = 'tool_forcedcache'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_ALPHA;
$plugin->supported = [400, 402];
$plugin->supported = [400, 404];
$plugin->incompatible = 405;
6 changes: 6 additions & 0 deletions customfield/field/textregex/.github/workflows/gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:
# database: [pgsql, mariadb]
matrix:
include:
- php: '8.3'
moodle-branch: 'MOODLE_405_STABLE'
database: mariadb
- php: '8.3'
moodle-branch: 'MOODLE_405_STABLE'
database: pgsql
- php: '8.3'
moodle-branch: 'MOODLE_404_STABLE'
database: mariadb
Expand Down
1 change: 1 addition & 0 deletions customfield/field/textregex/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Privacy Subsystem implementation for 'customfield_textregex'.
*
Expand Down
3 changes: 2 additions & 1 deletion customfield/field/textregex/tests/plugin_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ final class plugin_test extends \advanced_testcase {
* Tests set up.
*/
public function setUp(): void {
parent::setUp();
$this->resetAfterTest();

$this->cfcat = $this->get_generator()->create_category();
Expand Down Expand Up @@ -94,7 +95,7 @@ protected function get_generator(): core_customfield_generator {

/**
* Test for initialising field and data controllers
* @covers \customfield\field_controller::create
* @covers \core_customfield\field_controller::create
*/
public function test_initialise(): void {
$f = field_controller::create($this->cfields[1]->get('id'));
Expand Down
6 changes: 3 additions & 3 deletions customfield/field/textregex/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'customfield_textregex';
$plugin->version = 2024053100;
$plugin->version = 2024101400;
$plugin->requires = 2021051718;
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '1.0.3';
$plugin->supported = [311, 404];
$plugin->release = '1.0.4';
$plugin->supported = [311, 405];
11 changes: 9 additions & 2 deletions filter/filtercodes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.5.2] 2024-10-04 (rc)
## [2.6.1] 2024-10-11
### Update
- Fix-308: Fixed compatibility issue with PHP 8.3.

## [2.6.0] 2024-10-07
### Added
- New {menulanguages} tag.
- New {keyboard}...{/keyboard} tag.
Expand All @@ -17,7 +21,9 @@ All notable changes to this project will be documented in this file.
- New {ifgrouping groupingid}...{/ifgrouping} tag.
- New {ifnotgrouping groupingid}...{/ifnotgrouping} tag.
- New {mygroupings} tag.
- New {ifnotincohort} tag.
### Updated
- Fixed bug with ifactivitycompleted and ifnotactivitycompleted if activity does not exist.
- Fixed issue with %7Bcoursemoduleid%7D leaving % symbol behind.
- Fixed issue when {coursesummary} is used in a block.
- Link to External LTI now only available in Moodle 4.3+.
Expand All @@ -30,6 +36,7 @@ All notable changes to this project will be documented in this file.
- {categories0menu} tag now shows hidden categories if role has moodle/category:viewhiddencategories.
- Fixed a couple of PHP 5.6 compatibility issues. Note that unit tests are still only compatible with PHP 7.1 and later.
- Fix-302: {qrcode} and {urlencode} not processed after replacement tags.
- Fixed compatibility issue with Moodle LMS 4.5.

## [2.5.1] 2024-05-01
### Updated
Expand Down Expand Up @@ -60,7 +67,7 @@ All notable changes to this project will be documented in this file.
- References to PHP and Moodle versions in bug reports.
- Removed support for Travis integration.
- Copyright notice to include 2024.
- Fixed compatibility issue with Moodle LMS 4.4
- Fixed compatibility issue with Moodle LMS 4.4.

## [2.4.3] 2023-11-20
### Added
Expand Down
3 changes: 3 additions & 0 deletions filter/filtercodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ Note: {if*rolename*} and {ifmin*rolename*} type tags are based on role archetype
* {ifcustomrole roleshortname}{/ifcustomrole} : Will display enclosed content only if the user has the custom role specified by its shortname within the current context.
* {ifnotcustomrole roleshortname}{/ifnotcustomrole} : Will display enclosed content only if the user does not have the custom role specified by its shortname within the current context.
* {ifincohort CohortID|idnumber}{/ifincohort} : Will display enclosed content only if user is a member of the specified cohort. You can specify the Cohort ID in your cohort settings or its ID number. Cohort ID can contain a combination of letters from a to z, A to Z, numbers 0 to 9 and underscores. It will not work if it contains spaces, dashes or other special characters.
* {ifnotincohort CohortID|idnumber}{/ifnotincohort} : Will display enclosed content only if user is NOT a member of the specified cohort. You can specify the Cohort ID in your cohort settings or its ID number. Cohort ID can contain a combination of letters from a to z, A to Z, numbers 0 to 9 and underscores. It will not work if it contains spaces, dashes or other special characters.
* {ifhasarolename roleshortname}{/ifhasarolename}: Will display enclosed contnet if the user has the specified role anywhere on the site. This conditional tag works with role shortnames, not role archtypes. It is **not** context sensitive.

#### Miscellanious
Expand Down Expand Up @@ -1347,6 +1348,7 @@ Create a Page on your Moodle site, preferably in a course, so that those tags wo
* If in a section of a course [{ifinsection}]Yes[{/ifinsection}][{ifnotinsection}]No[{/ifnotinsection}]? {ifinsection}Yes{/ifinsection}{ifnotinsection}No{/ifnotinsection}
* If Request a course is enabled [{ifcourserequests}]Yes[{/ifcourserequests}]? {ifcourserequests}Yes{/ifcourserequests}
* Are you a member of the "moodlers" cohort [{ifincohort moodlers}]Yes[{/ifincohort}]? {ifincohort moodlers}Yes{/ifincohort} (will be blank of not a member of cohort)
* Are you not a member of the "moodlers" cohort [{ifnotincohort moodlers}]Yes[{/ifnotincohort}]? {ifnotincohort moodlers}Yes{/ifnotincohort} (will be blank of a member of cohort)
* [{ifhasarolename teacher}]This is a special message just for teachers.[{ifhasarolename}]: {ifhasarolename teacher}This is a special message just for teachers.{ifhasarolename}
* Viewing in: [{ifmobile}]Browser[{/ifmobile}][{ifmobile}]Mobile App[{/ifmobile}]: Viewing in: {ifmobile}Browser{/ifmobile}{ifmobile}Mobile App{/ifmobile}
* Is your tenant id 1? [{iftenant 1}]Yes[{/iftenant}]: {iftenant 1}Yes{/iftenant} Note: In Moodle classic, tenant id is assumed to be 1.
Expand Down Expand Up @@ -1533,6 +1535,7 @@ Michael Milette - Author and Lead Developer

Big thank you to the following contributors. (Please let me know if I forgot to include you in the list):

* golenkovm (Micha Golenkov): FIx global USER change during text filtering (2024).
* 28Smiles (Leon Camus): Bug fix for {qrcode} and {urlencode} tags (2024).
* 28Smiles (Leon Camus): New {ifingouping} tag (2024).
* 28Smiles (Leon Camus): New {ifnotingrouping} tag (2024).
Expand Down
108 changes: 78 additions & 30 deletions filter/filtercodes/classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die;

/**
* Main filter code for FilterCodes.
*
Expand All @@ -25,21 +23,31 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace filter_filtercodes;

defined('MOODLE_INTERNAL') || die;

use block_online_users\fetcher;
use \core_table\local\filter\integer_filter;
use \core_user\table\participants_filterset;
use \core_user\table\participants_search;
use core_table\local\filter\integer_filter;
use core_user\table\participants_filterset;
use core_user\table\participants_search;
use Endroid\QrCode\QrCode;

require_once($CFG->dirroot . '/course/renderer.php');

if (class_exists('\core_filters\text_filter')) {
class_alias('\core_filters\text_filter', 'filtercodes_base_text_filter');
} else {
class_alias('\moodle_text_filter', 'filtercodes_base_text_filter');
}

/**
* Extends the moodle_text_filter class to provide plain text support for new tags.
*
* @copyright 2017-2024 TNG Consulting Inc. - www.tngconsulting.ca
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class text_filter extends \core_filters\text_filter {
class text_filter extends \filtercodes_base_text_filter {
/** @var object $archetypes Object array of Moodle archetypes. */
public $archetypes = [];
/** @var array $customroles array of Roles key is shortname and value is the id */
Expand Down Expand Up @@ -313,14 +321,14 @@ private function getusergroupings($courseid, $userid) {
global $DB;

return $DB->get_records_sql('SELECT gp.id, gp.name, gp.idnumber
FROM {user} u
INNER JOIN {groups_members} gm ON u.id = gm.userid
INNER JOIN {groups} g ON g.id = gm.groupid
INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid
INNER JOIN {groupings} gp ON gp.id = gg.groupingid
WHERE g.courseid = ? AND u.id = ?
GROUP BY gp.id
ORDER BY gp.name ASC', [$courseid, $userid]);
FROM {user} u
INNER JOIN {groups_members} gm ON u.id = gm.userid
INNER JOIN {groups} g ON g.id = gm.groupid
INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid
INNER JOIN {groupings} gp ON gp.id = gg.groupingid
WHERE g.courseid = ? AND u.id = ?
GROUP BY gp.id
ORDER BY gp.name ASC', [$courseid, $userid]);
}

/**
Expand Down Expand Up @@ -600,7 +608,7 @@ private function rendercoursecards($rcourseids, $format = 'vertical') {
. ');height:100px;max-width:300px;padding-top:50%;background-size:cover;'
. 'background-repeat:no-repeat;background-position:center;"></div>
<div class="card-title pt-1 pr-3 pb-1 pl-3 m-0"><span class="sr-only">' . get_string('course') . ': </span>'
. $course->get_formatted_name() . '</div>
. $course->get_formatted_name() . '</div>
</a>
</div>
';
Expand Down Expand Up @@ -648,14 +656,16 @@ private function rendercoursecards($rcourseids, $format = 'vertical') {
$category = $DB->get_record('course_categories', ['id' => $course->category]);
$category = $category->name;

$course->summary == null ? '' : $course->summary;
$summary = $course->summary == null ? '' : $course->summary;
$summary = substr($summary, -4) == '<br>' ? substr($summary, 0, strlen($summary) - 4) : $summary;

$content .= '
<tr class="fc-coursecard-table">
<td class="text-coursename"><a href="' . $courseurl . '">' . $course->get_formatted_name() . '</a></td>
<td class="text-coursecategory">' . $category . '</td>
<td class="text-coursename" style="white-space:normal;">' . $summary . '</td>
<td class="text-coursename col-sm-12 col-md-3 d-block d-md-table-cell"><a href="' . $courseurl . '">'
. $course->get_formatted_name() . '</a></td>
<td class="text-coursecategory col-sm-12 col-md-2 d-block d-md-table-cell">' . $category . '</td>
<td class="text-coursename col-sm-12 col-md-7 d-block d-md-table-cell" style="word-wrap:break-word;">'
. $summary . '</td>
</tr>
';
break;
Expand Down Expand Up @@ -687,9 +697,12 @@ private function getcoursecardinfo($format = null) {
<table class="table table-hover table-responsive">
<thead>
<tr>
<th scope="col">' . get_string('course') . '</th>
<th scope="col">' . get_string('category') . '</th>
<th scope="col">' . get_string('description') . '</th>
<th scope="col" class="col-12 col-md-3 d-block d-md-table-cell">'
. get_string('course') . '</th>
<th scope="col" class="col-12 col-md-2 d-block d-md-table-cell">'
. get_string('category') . '</th>
<th scope="col" class="col-12 col-md-7 d-block d-md-table-cell">'
. get_string('description') . '</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -1075,11 +1088,11 @@ private function generatortags(&$text) {
. "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$url .= (strpos($url, '?') ? '&' : '?');

// Get list of available languages
// Get list of available languages.
$availablelanguages = get_string_manager()->get_list_of_translations();
if (count($availablelanguages) > 1) {
foreach ($availablelanguages as $langcode => $langname) {
// Create a link for each language
// Create a link for each language.
$menu .= '-' . $langname . '|' . $url . 'lang=' . $langcode . PHP_EOL;
}
if (!empty($menu)) {
Expand Down Expand Up @@ -1568,6 +1581,7 @@ public function filter($text, array $options = []) {
static $profiledata;
static $mygroupslist;
static $mygroupingslist;
static $mycohorts;

$replace = []; // Array of key/value filterobjects.

Expand Down Expand Up @@ -2366,7 +2380,7 @@ function ($matches) use ($now) {

// Substitutions.

$u = $USER;
$u = clone $USER;
if (!isloggedin() || isguestuser()) {
$u->firstname = get_string('defaultfirstname', 'filter_filtercodes');
$u->lastname = get_string('defaultsurname', 'filter_filtercodes');
Expand Down Expand Up @@ -3242,7 +3256,8 @@ function ($matches) use ($USER) {
// Add request a course link.
$context = \context_system::instance();
if (!empty($CFG->enablecourserequests) && has_capability('moodle/course:request', $context)) {
$link = '<a href="' . (new \moodle_url('/course/request.php'))->out() . '">' . get_string('requestcourse') . '</a>';
$link = '<a href="' . (new \moodle_url('/course/request.php'))->out() . '">'
. get_string('requestcourse') . '</a>';
} else {
$link = '';
}
Expand Down Expand Up @@ -3964,12 +3979,16 @@ function ($matches) use ($USER) {
$iscompleted = false;

// Only process valid IDs.
if (($cm = get_coursemodule_from_id('', $cmid, 0)) !== false) {
if (($cm = \get_coursemodule_from_id('', $cmid, 0)) !== false) {
// Get the completion data for this activity if it exists.
try {
$data = $completion->get_data($cm, true, $USER->id);
$iscompleted = ($data->completionstate == COMPLETION_COMPLETE);
} catch (Exception $e) {
} catch (\moodle_exception $e) {
// Handle Moodle-specific exceptions.
unset($e);
continue;
} catch (\Exception $e) {
unset($e);
continue;
}
Expand Down Expand Up @@ -4007,11 +4026,15 @@ function ($matches) use ($USER) {
$iscompleted = false;

// Only process valid IDs.
if (($cm = get_coursemodule_from_id('', $cmid, 0)) !== false) {
if (($cm = \get_coursemodule_from_id('', $cmid, 0)) !== false) {
// Get the completion data for this activity.
try {
$data = $completion->get_data($cm, true, $USER->id);
$iscompleted = ($data->completionstate == COMPLETION_COMPLETE);
} catch (\moodle_exception $e) {
// Handle Moodle-specific exceptions.
unset($e);
continue;
} catch (Exception $e) {
unset($e);
continue;
Expand Down Expand Up @@ -4259,7 +4282,6 @@ function ($matches) use ($USER) {
// Parameters: id name or id number of the cohort.
// Requires content between tags.
if (stripos($text, '{ifincohort ') !== false) {
static $mycohorts;
if (empty($mycohorts)) { // Cache list of cohorts.
require_once($CFG->dirroot . '/cohort/lib.php');
$mycohorts = cohort_get_user_cohorts($USER->id);
Expand All @@ -4281,6 +4303,32 @@ function ($matches) use ($mycohorts) {
}
}

// Tag: {ifnotincohort idname|idnumber}...{/ifnotincohort}.
// Description: Will display content if the user is not part of the specified cohort.
// Parameters: id name or id number of the cohort.
// Requires content between tags.
if (stripos($text, '{ifnotincohort ') !== false) {
if (empty($mycohorts)) { // Cache list of cohorts.
require_once($CFG->dirroot . '/cohort/lib.php');
$mycohorts = cohort_get_user_cohorts($USER->id);
}
$newtext = preg_replace_callback(
'/\{ifnotincohort ([\w\-]*)\}(.*)\{\/ifnotincohort\}/isuU',
function ($matches) use ($mycohorts) {
foreach ($mycohorts as $cohort) {
if ($cohort->idnumber == $matches[1] || $cohort->id == $matches[1]) {
return ''; // User is in the cohort, so return an empty string.
}
}
return $matches[2]; // User is not in the cohort, so return the content.
},
$text
);
if ($newtext !== false) {
$text = $newtext;
}
}

// Tag: {ifeditmode}...{/ifeditmode}.
// Description: Will display content if edit mode is turned on.
// Parameters: None.
Expand Down
8 changes: 1 addition & 7 deletions filter/filtercodes/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,5 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

// For backwards compatibility with Moodle 4.4 and below.
if ($CFG->branch < 405) {
class_alias('\moodle_text_filter', '\core_filters\text_filter');
require_once(__DIR__ . '/classes/text_filter.php');
class_alias('\text_filter', '\filter_filtercodes');
}
class_alias(\filter_filtercodes\text_filter::class, \filter_filtercodes::class);
4 changes: 2 additions & 2 deletions filter/filtercodes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024100400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024100701; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014051200; // Requires Moodle version 2.7 or later.
$plugin->component = 'filter_filtercodes'; // Full name of the plugin (used for diagnostics).
$plugin->release = '2.5.2';
$plugin->release = '2.6.1';
$plugin->maturity = MATURITY_STABLE;
Loading

0 comments on commit 0386da2

Please sign in to comment.