Skip to content

Commit

Permalink
Revert "Added new {ifuser} tag."
Browse files Browse the repository at this point in the history
This reverts commit 135e160.
  • Loading branch information
michael-milette committed Jul 22, 2024
1 parent 1e3a811 commit 128937e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ Example: To apply the patch for Moodle using git (change the "M403" for other ve
git cherry-pick FETCH_HEAD
```

This is usually enough to make the filters work in the custom menu. However, we have noticed it may not work with some Moodle themes, most notably premium themes. Those themes will need to be patched using the Technique B.
This is usually enough to make the filters work in the custom menu. However, we have noticed it may not work with some Moodle themes, most notably premium themes. Those themes will need to be patched using the technique B.

**Technique B**: If technique A does not work for you, you will need to integrate a few lines of code into your Moodle theme, or ask your theme's developer/maintainer to apply this change for you. Be sure to follow the correct instructions for your version of Moodle.

Expand Down Expand Up @@ -613,11 +613,11 @@ Add this code to the core_renderer section (probably located in /theme/yourtheme
}
```

### For themes based on **boost** (Moodle 3.2 to 3.11 and some 4.0+)
### For themes based on **boost** (Moodle 3.2 and later)

Note: Supported in Moodle 3.2 to 3.11. Most Moodle 4.0 themes do not require this patch but some that were ported for 4.0+ still do.
Note: Supported in Moodle 3.2 and later. If you are using Moodle 4.0 or later, you **must also** integrate the patch **For themes based on boost (Moodle 4.0 and later)** above.

Add the following code to core_renderer section (often found in /theme/yourtheme/classes/output/core_renderer.php) of your theme. Note: Your theme may even already have such a class (they often do). The important lines are chunk of code that starts with "// Filter custom menu items..." including the 5 lines that follow it.
Add the following code to core_renderer section (often found in /theme/yourtheme/classes/output/core_renderer.php) of your theme. Note: Your theme may even already have such a class (they often do):

```php
use filter_manager;
Expand Down
23 changes: 1 addition & 22 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@ public function filter($text, array $options = []) {
if (!empty($grademax = floatval($gradeobj->item->grademax))) {
// Avoid divide by 0 error if no grades have been defined.
$grade = floatval($grademax) > 0 ? (int) ($gradeobj->grade / floatval($grademax) * 100) : 0;

} else {
$grade = 0;
}
Expand Down Expand Up @@ -4742,28 +4743,6 @@ function ($matches) use ($mycohorts) {
}
}

// DO NOT USE THIS TAG. IT WILL BE REMOVED SOON. Use {ifprofile id is 999} instead.
// Tag: {ifuser id}...{/ifuser}.
// Description: Display content only for specified user id.
// Parameters: id number of user.
// Requires content between tags.
if (stripos($text, '{ifuser') !== false) {
$re = '/{ifuser\s+(.*)\}(.*)\{\/ifuser\}/isuU';
$found = preg_match_all($re, $text, $matches);
if ($found > 0) {
foreach ($matches[1] as $user) {
$key = '/{ifuser\s+' . $user . '\}(.*)\{\/ifuser\}/isuU';
if ($user == $USER->id) {
// Just remove the tags.
$replace[$key] = '$1';
} else {
// Remove the ifuser strings.
$replace[$key] = '';
}
}
}
}

// Tag: {iftheme themename}...{/iftheme}.
// Description: Display content only if the current theme matches the one specified.
// Parameters: The name of the directory in which the theme is located.
Expand Down

0 comments on commit 128937e

Please sign in to comment.