Skip to content

Commit

Permalink
bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed May 17, 2024
1 parent a7e4bf0 commit 8480327
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 316 deletions.
91 changes: 0 additions & 91 deletions .github/workflows/cron.yml

This file was deleted.

143 changes: 0 additions & 143 deletions .github/workflows/main.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .infection.json5
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"customPath": "./vendor/bin/phpunit"
},
"initialTestsPhpOptions": "-dxdebug.mode=off -dpcov.enabled=1 -dpcov.directory=.",
"bootstrap": "./vendor/autoloadmoodle.php"
"bootstrap": "./lib/phpunit/bootstrap.php"
}
39 changes: 20 additions & 19 deletions classes/condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,36 @@ public static function get_json($languageid = '') {
* @return bool True if available
*/
public function is_available($not, \core_availability\info $info, $grabthelot, $userid) {
global $CFG, $DB, $USER;
global $CFG, $USER;

// If course has forced language.
$course = $info->get_course();
$allow = false;
if (isset($course->lang) && $course->lang == $this->languageid) {
if (isset($course->lang) && ($course->lang === $this->languageid)) {
$allow = true;
}
if ($userid == $USER->id) {
// Checking the language of the currently logged in user, so do not
// default to the account language, because the session language
// or the language of the current course may be different.
$language = current_language();
} else {
if (is_null($userid)) {
// Fall back to site language or English.
$language = $CFG->lang ?? 'en';
if ($userid === $USER->id) {
// Checking the language of the currently logged in user, so do not
// default to the account language, because the session language
// or the language of the current course may be different.
$language = current_language();
} else {
// Checking access for someone else than the logged in user, so
// use the preferred language of that user account.
// This language is never empty as there is a not-null constraint.
$language = $DB->get_field('user', 'lang', ['id' => $userid]);
if (is_null($userid)) {
// Fall back to site language or English.
$language = $CFG->lang;
} else {
// Checking access for someone else than the logged in user, so
// use the preferred language of that user account.
// This language is never empty as there is a not-null constraint.
$language = \core_user::get_user($userid)->lang;
}
}
if ($language == $this->languageid) {
$allow = true;
}
}
if ($language == $this->languageid) {
$allow = true;
}
if ($not) {
$allow = !$allow;
return !($allow);
}
return $allow;
}
Expand Down
2 changes: 0 additions & 2 deletions classes/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class frontend extends \core_availability\frontend {
* @param cm_info $cm Course-module currently being edited (null if none)
* @param section_info $section Section currently being edited (null if none)
* @return array Array of parameters for the JavaScript function
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null) {
return [self::convert_associative_array_for_js(get_string_manager()->get_list_of_translations(), 'id', 'name')];
Expand All @@ -59,7 +58,6 @@ protected function get_javascript_init_params($course, \cm_info $cm = null, \sec
* @param cm_info $cm Course-module currently being edited (null if none)
* @param section_info $section Section currently being edited (null if none)
* @return bool True if available
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function allow_add($course, \cm_info $cm = null, \section_info $section = null) {
// If forced course language.
Expand Down
Loading

0 comments on commit 8480327

Please sign in to comment.