Skip to content

Issue #157: CI fixes #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/customfield/cmsuserlist_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function get_instance_context(int $instanceid = 0): \context {
*
* @return bool
*/
public function uses_categories() : bool {
public function uses_categories(): bool {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/form/cms_types_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function add_action_buttons($cancel = true, $submitlabel=null) {
if ($cancel) {
$buttonarray[] = &$mform->createElement('cancel');
}
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
$mform->closeHeaderBefore('buttonar');
}

Expand Down
2 changes: 1 addition & 1 deletion classes/local/datasource/roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function config_backup_define_structure(\backup_nested_element $parent) {
$cmstype = $this->cms->get_type();
$config = $cmstype->get_custom_data('roles_config');
$source = is_null($config) ? [] : [
['list' => implode(',', $config->list), 'duplicates' => $config->duplicates]
['list' => implode(',', $config->list), 'duplicates' => $config->duplicates],
];
$roles->set_source_array($source);
}
Expand Down
5 changes: 3 additions & 2 deletions classes/local/datasource/userlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ public function instance_backup_define_structure(\backup_nested_element $parent)

$fields = new \backup_nested_element('userlistfields');
if ($DB->get_manager()->field_exists('customfield_data', 'valuetrust')) {
$field = new \backup_nested_element('userlistfield', ['id'], ['shortname', 'type', 'value', 'valueformat', 'valuetrust']);
$field = new \backup_nested_element('userlistfield', ['id'],
['shortname', 'type', 'value', 'valueformat', 'valuetrust']);
} else {
$field = new \backup_nested_element('userlistfield', ['id'], ['shortname', 'type', 'value', 'valueformat']);
}
Expand All @@ -546,7 +547,7 @@ function ($arr) {
},
$fielddata
)
)
),
];
$fieldsforbackup = array_merge($fieldsforbackup, $this->cfhandler->get_instance_data_for_backup($id));
// Backup annotations. Check for function existence for the sake of backward compatibility.
Expand Down
10 changes: 5 additions & 5 deletions classes/local/model/cms_types.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ protected static function define_properties(): array {
],
'description' => [
'type' => PARAM_RAW,
'default' => ''
'default' => '',
],
'descriptionformat' => [
'type' => PARAM_INT,
'default' => 1
'default' => 1,
],
'title_mustache' => [
'type' => PARAM_TEXT,
'default' => ''
'default' => '',
],
'mustache' => [
'type' => PARAM_RAW,
'default' => '{{{debug}}}'
'default' => '{{{debug}}}',
],
'datasources' => [
'type' => PARAM_TEXT,
'default' => ''
'default' => '',
],
'customdata' => [
'type' => PARAM_TEXT,
Expand Down
2 changes: 0 additions & 2 deletions classes/search/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

namespace mod_cms\search;

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

use mod_cms\local\model\cms;
use mod_cms\local\renderer;

Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
* @copyright 2023, Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once('../../config.php');

// TODO: This is a stub.

$id = required_param('id', PARAM_INT); // Course id.

$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);

require_login($course);
148 changes: 62 additions & 86 deletions lang/en/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,113 +26,89 @@
defined('MOODLE_INTERNAL') || die();

$string['addnewtype'] = 'Add new content type';
$string['chooser:show'] = 'Show in activity chooser';
$string['cachedef_cms_content'] = 'CMS content';
$string['cachedef_cms_content_fields'] = 'CMS fields datasource';
$string['cachedef_cms_content_images'] = 'CMS images datasource';
$string['cachedef_cms_content_roles'] = 'CMS roles datasource';
$string['cachedef_cms_content_userlist'] = 'CMS userlist datasource';
$string['cachedef_cms_name'] = 'CMS name';
$string['chooser:hide'] = 'Hide in activity chooser';
$string['chooser:show'] = 'Show in activity chooser';
$string['cms:addinstance'] = 'Add a new custom content instance';
$string['cms:seeall'] = 'Can see hidden CMS types in the activity chooser';
$string['cms:view'] = 'View a new custom content instance';
$string['cms_type:icon_desc'] = 'This icon will be displayed in the activity chooser menu.';
$string['customfield_manage_heading'] = 'Manage custom fields for content type "{$a}"';
$string['datasources'] = 'Datasources';
$string['datasources_desc'] = 'This is a performance measure. Select datasources to be included in this type. Only selected datasources will be configurable,
or editable at the instance level, or be called upon to provide data. Some datasources are always included and do not appear in
this list.';
$string['editcontenttype'] = 'Edit content type';
$string['error:cant_delete_content_type'] = 'Cannot delete content type.';
$string['error:class_missing'] = 'Datasource class \'{$a}\' does not exist.';
$string['error:invalid'] = 'Invalid: {$a}';
$string['error:must_be_base'] = 'Datasource class \'($a}\' must inherit from mod_cms\\datasource\\base.';
$string['error:name_not_unique'] = 'Datasource class shortname \'($a}\' must be unique.';
$string['error:no_config_hash'] = 'Module {$a} has no config hash.';
$string['error:no_file_uploaded'] = 'No file uploaded';
$string['error:no_instance_hash'] = 'Module {$a} has no instance hash.';
$string['event:cms_type_created'] = 'Custom content type created';
$string['event:cms_type_deleted'] = 'Custom content type deleted';
$string['event:cms_type_updated'] = 'Custom content type updated';
$string['event_cms_type_created_desc'] = 'The user with ID: {$a->userid} has created a custom content type with ID: {$a->typeid}';
$string['event_cms_type_deleted_desc'] = 'The user with ID: {$a->userid} has deleted a custom content type with ID: {$a->typeid}';
$string['event_cms_type_updated_desc'] = 'The user with ID: {$a->userid} has updated a custom content type with ID: {$a->typeid}';
$string['export'] = 'Export';
$string['import'] = 'Import';
$string['fields:config:columns'] = 'Fields and categories';
$string['fields:config:header'] = 'Custom field settings';
$string['fields:custom_fields'] = 'Custom fields';
$string['fields:sample_text'] = 'text';
$string['fields:sample_time'] = 'Thursday, 15 June 2023, 12:00 AM';
$string['idnumber'] = 'ID number';
$string['idnumber_help'] = 'An identifier to uniquely label this CMS type. This will be used in backup and restoring. It must be unique within the system, and ideally, unique universally.';
$string['idnumber_exists'] = 'Id number \'{$a}\' already exists in the system.';
$string['idnumber_help'] = 'An identifier to uniquely label this CMS type. This will be used in backup and restoring. It must be unique within the system, and ideally, unique universally.';
$string['images:config:header'] = 'Images settings';
$string['images:images'] = 'Images';
$string['import'] = 'Import';
$string['import_cms_type'] = 'Import content type';
$string['import_file'] = 'Import file';
$string['instance:header'] = 'Activity fields';
$string['instance:name'] = 'Name';
$string['manage_types_return'] = 'Return to manage types';
$string['managetypes'] = 'Manage content types';
$string['maxgrade'] = 'Default max grade';
$string['maxgrade_desc'] = 'The default max grade when creating a new custom content type instance.';
$string['modulename'] = 'CMS';
$string['modulenameplural'] = 'CMS';
$string['newcontenttype'] = 'Add new content type';
$string['pluginname'] = 'CMS';
$string['settings'] = 'Custom content type settings';
$string['table:name'] = 'Custom content type';
$string['table:numinstances'] = 'Number of instances';
$string['pluginadministration'] = 'Plugin administration';
$string['preview_with_hint'] = 'Preview (click "{$a}" to update)';
$string['customfield_manage_heading'] = 'Manage custom fields for content type "{$a}"';
$string['manage_types_return'] = 'Return to manage types';
$string['sample_value'] = 'Sample value';
$string['some_name'] = 'Some name';
$string['import_file'] = 'Import file';
$string['import_cms_type'] = 'Import content type';
$string['datasources'] = 'Datasources';
$string['datasources_desc'] = 'This is a performance measure. Select datasources to be included in this type. Only selected datasources will be configurable,
or editable at the instance level, or be called upon to provide data. Some datasources are always included and do not appear in
this list.';
$string['visibility_updated'] = 'Visibility updated';

// Cache defs.
$string['cachedef_cms_content'] = 'CMS content';
$string['cachedef_cms_content_fields'] = 'CMS fields datasource';
$string['cachedef_cms_content_images'] = 'CMS images datasource';
$string['cachedef_cms_content_roles'] = 'CMS roles datasource';
$string['cachedef_cms_content_userlist'] = 'CMS userlist datasource';
$string['cachedef_cms_name'] = 'CMS name';

// Template form section.
$string['instance:header'] = 'Activity fields';
$string['instance:name'] = 'Name';
$string['mustache'] = 'Content';
$string['mustache_help'] = 'The two fields above will form the content displayed in the activity. They both will need to be valid {$a}. Variables that are available for use in these templates are given below.';
$string['mustache_template'] = 'mustache templates';
$string['cms_type:icon_desc'] = 'This icon will be displayed in the activity chooser menu.';

// Event strings.
$string['event:cms_type_created'] = 'Custom content type created';
$string['event_cms_type_created_desc'] = 'The user with ID: {$a->userid} has created a custom content type with ID: {$a->typeid}';
$string['event:cms_type_deleted'] = 'Custom content type deleted';
$string['event_cms_type_deleted_desc'] = 'The user with ID: {$a->userid} has deleted a custom content type with ID: {$a->typeid}';
$string['event:cms_type_updated'] = 'Custom content type updated';
$string['event_cms_type_updated_desc'] = 'The user with ID: {$a->userid} has updated a custom content type with ID: {$a->typeid}';

// Capability strings.
$string['cms:addinstance'] = 'Add a new custom content instance';
$string['cms:view'] = 'View a new custom content instance';
$string['cms:seeall'] = 'Can see hidden CMS types in the activity chooser';

// Privacy strings.
$string['newcontenttype'] = 'Add new content type';
$string['pluginadministration'] = 'Plugin administration';
$string['pluginname'] = 'CMS';
$string['preview_with_hint'] = 'Preview (click "{$a}" to update)';
$string['privacy:metadata:cms'] = 'Custom content type instances';
$string['privacy:metadata:cms:usermodified'] = 'User who modified the instances';
$string['privacy:metadata:cms_types'] = 'Custom content types';
$string['privacy:metadata:cms_types:usermodified'] = 'User who modified the custom content types';

// Error strings.
$string['error:class_missing'] = 'Datasource class \'{$a}\' does not exist.';
$string['error:must_be_base'] = 'Datasource class \'($a}\' must inherit from mod_cms\\datasource\\base.';
$string['error:name_not_unique'] = 'Datasource class shortname \'($a}\' must be unique.';
$string['error:no_file_uploaded'] = 'No file uploaded';
$string['error:cant_delete_content_type'] = 'Cannot delete content type.';
$string['error:invalid'] = 'Invalid: {$a}';
$string['error:no_instance_hash'] = 'Module {$a} has no instance hash.';
$string['error:no_config_hash'] = 'Module {$a} has no config hash.';

// Search strings.
$string['roles:config:duplicates'] = 'Duplicates';
$string['roles:config:duplicates:all'] = 'Show in all';
$string['roles:config:duplicates:firstonly'] = 'Show in first';
$string['roles:config:duplicates:nest'] = 'Show in first with roles';
$string['roles:config:header'] = 'Role list settings';
$string['roles:config:list'] = 'Roles included';
$string['roles:displayname'] = 'Roles list';
$string['roles:error:role_does_not_exist'] = 'Role "{$a}" does nor exist.';
$string['sample_value'] = 'Sample value';
$string['search:activity'] = 'CMS - activity information';

// Site datasource strings.
$string['settings'] = 'Custom content type settings';
$string['site:displayname'] = 'Site Info';

// Image datasource strings.
$string['images:config:header'] = 'Images settings';
$string['images:images'] = 'Images';

// Custom field datasource strings.
$string['fields:custom_fields'] = 'Custom fields';
$string['fields:config:columns'] = 'Fields and categories';
$string['fields:config:header'] = 'Custom field settings';
$string['fields:sample_text'] = 'text';
$string['fields:sample_time'] = 'Thursday, 15 June 2023, 12:00 AM';

// User list datasource strings.
$string['some_name'] = 'Some name';
$string['table:name'] = 'Custom content type';
$string['table:numinstances'] = 'Number of instances';
$string['userlist:config:columns'] = 'User list columns';
$string['userlist:config:header'] = 'User list settings';
$string['userlist:displayname'] = 'User list';
$string['userlist:listdata'] = 'List data';
$string['userlist:pageheading'] = 'List definition for \'{$a}\'';

// Roles list datasource strings.
$string['roles:displayname'] = 'Roles list';
$string['roles:config:header'] = 'Role list settings';
$string['roles:config:list'] = 'Roles included';
$string['roles:config:duplicates'] = 'Duplicates';
$string['roles:config:duplicates:all'] = 'Show in all';
$string['roles:config:duplicates:firstonly'] = 'Show in first';
$string['roles:config:duplicates:nest'] = 'Show in first with roles';
$string['roles:error:role_does_not_exist'] = 'Role "{$a}" does nor exist.';
$string['visibility_updated'] = 'Visibility updated';
8 changes: 4 additions & 4 deletions tests/cms_instance_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright 2023, Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cms_instance_test extends \advanced_testcase {
final class cms_instance_test extends \advanced_testcase {
use test_import1_trait;

/**
Expand All @@ -49,7 +49,7 @@ protected function setUp(): void {
* @covers \mod_cms\local\lib::add_instance
* @throws \coding_exception
*/
public function test_add_instance() {
public function test_add_instance(): void {
$cmstype = $this->import();

// Create a course.
Expand Down Expand Up @@ -80,7 +80,7 @@ public function test_add_instance() {
* @covers \mod_cms\local\lib::add_instance
* @throws \coding_exception
*/
public function test_update_instance() {
public function test_update_instance(): void {
$cmstype = $this->import();

// Create a course.
Expand Down Expand Up @@ -113,7 +113,7 @@ public function test_update_instance() {
*
* @covers \mod_cms\local\lib::delete_instance
*/
public function test_delete_instance() {
public function test_delete_instance(): void {
$cmstype = $this->import();

// Create a course.
Expand Down
12 changes: 6 additions & 6 deletions tests/cms_types_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright 2023, Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cms_types_test extends \advanced_testcase {
final class cms_types_test extends \advanced_testcase {
/** Test data for import/export. */
public const IMPORT_DATAFILE = __DIR__ . '/fixtures/type_data.json';

Expand All @@ -54,7 +54,7 @@ protected function setUp(): void {
* @param string $mustache
* @param bool $valid
*/
public function test_mustache_validity(string $field, string $mustache, bool $valid) {
public function test_mustache_validity(string $field, string $mustache, bool $valid): void {
$cmstype = new cms_types();
$cmstype->set($field, $mustache);

Expand All @@ -71,7 +71,7 @@ public function test_mustache_validity(string $field, string $mustache, bool $va
*
* @return array[]
*/
public function mustache_validity_datasource(): array {
public static function mustache_validity_datasource(): array {
return [
['title_mustache', 'test', true],
['title_mustache', '{{test}}', true],
Expand All @@ -92,7 +92,7 @@ public function mustache_validity_datasource(): array {
* @param string|null $idnumber
* @param bool $valid
*/
public function test_idnumber(?string $idnumber, bool $valid) {
public function test_idnumber(?string $idnumber, bool $valid): void {

$cmstype = new cms_types();
$cmstype->set('name', 'name');
Expand All @@ -115,7 +115,7 @@ public function test_idnumber(?string $idnumber, bool $valid) {
*
* @return array[]
*/
public function idnumber_validity_datasource(): array {
public static function idnumber_validity_datasource(): array {
return [
[null, false],
['', false],
Expand All @@ -133,7 +133,7 @@ public function idnumber_validity_datasource(): array {
* @covers \mod_cms\local\model\cms_types::get_cache_key
* @covers \mod_cms\local\model\cms_types::get_icon_metadata
*/
public function test_import() {
public function test_import(): void {
$importdata = json_decode(file_get_contents(self::IMPORT_DATAFILE));
$cmstype = new cms_types();
$cmstype->set_from_import($importdata);
Expand Down
Loading
Loading