Skip to content

Commit 248e358

Browse files
committed
Issue #2: Integration with activity chooser
1 parent ed31092 commit 248e358

File tree

8 files changed

+209
-5
lines changed

8 files changed

+209
-5
lines changed

classes/form/cms_types_form.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class cms_types_form extends persistent_form {
3838

3939
/** @var string Persistent class name. */
40-
protected static $persistentclass = 'mod_cms\\model\\cms_types';
40+
protected static $persistentclass = 'mod_cms\\local\\model\\cms_types';
4141

4242
/**
4343
* Form definition.

classes/model/cms.php classes/local/model/cms.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @copyright Catalyst IT
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
25-
namespace mod_cms\model;
25+
namespace mod_cms\local\model;
2626

2727
use stdClass;
2828
use core\persistent;

classes/model/cms_types.php classes/local/model/cms_types.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @copyright Catalyst IT
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
25-
namespace mod_cms\model;
25+
namespace mod_cms\local\model;
2626

2727
use stdClass;
2828
use context_system;

classes/local/table/content_types_list.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
use html_writer;
2929
use flexible_table;
3030
use mod_cms\helper;
31-
use mod_cms\model\cms_types;
3231
use mod_cms\manage_content_types;
32+
use mod_cms\local\model\cms_types;
3333

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

classes/manage_content_types.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
use stdClass;
2828
use moodle_url;
2929
use core\notification;
30-
use mod_cms\model\cms_types;
3130
use mod_cms\form\cms_types_form;
31+
use mod_cms\local\model\cms_types;
3232
use mod_cms\local\table\content_types_list;
3333

3434
/**

classes/privacy/provider.php

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Privacy subsystem implementation for mod_cms
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
namespace mod_cms\privacy;
26+
27+
use context;
28+
use core_privacy\local\request\userlist;
29+
use core_privacy\local\metadata\collection;
30+
use core_privacy\local\request\contextlist;
31+
use core_privacy\local\request\approved_contextlist;
32+
use core_privacy\local\request\approved_userlist;
33+
34+
class provider implements
35+
\core_privacy\local\metadata\provider,
36+
\core_privacy\local\request\plugin\provider,
37+
\core_privacy\local\request\core_userlist_provider {
38+
39+
/**
40+
* Get information about the user data stored by this plugin.
41+
*
42+
* @param collection $collection An object for storing metadata.
43+
* @return collection The metadata.
44+
*/
45+
public static function get_metadata(collection $collection) : collection {
46+
$collection->add_database_table(
47+
'cms',
48+
[
49+
'usermodified' => 'privacy:metadata:cms:usermodified',
50+
],
51+
'privacy:metadata:cms'
52+
);
53+
$collection->add_database_table(
54+
'cms_types',
55+
[
56+
'moodleuid' => 'privacy:metadata:cms_types:usermodified',
57+
],
58+
'privacy:metadata:cms_types'
59+
);
60+
61+
return $collection;
62+
}
63+
64+
/**
65+
* Get the list of contexts that contain user information for the specified user.
66+
*
67+
* @param int $userid The ID of the user
68+
*
69+
* @return contextlist
70+
*/
71+
public static function get_contexts_for_userid(int $userid) : contextlist {
72+
// Just enough to pass unit tests.
73+
return new contextlist();
74+
}
75+
76+
/**
77+
* Export personal data for the given approved_contextlist.
78+
* User and context information is contained within the contextlist.
79+
*
80+
* @param approved_contextlist $contextlist A list of contexts approved for export.
81+
*/
82+
public static function export_user_data(approved_contextlist $contextlist) {
83+
// Empty on purpose.
84+
}
85+
86+
/**
87+
* Delete all data for all users in the specified context.
88+
*
89+
* @param context $context The context to delete in
90+
*/
91+
public static function delete_data_for_all_users_in_context(context $context) {
92+
// Empty on purpose.
93+
}
94+
95+
/**
96+
* Delete all user data for the specified user, in the specified contexts.
97+
*
98+
* @param approved_contextlist $contextlist A list of contexts approved for deletion
99+
*/
100+
public static function delete_data_for_user(approved_contextlist $contextlist) {
101+
// Empty on purpose.
102+
}
103+
104+
/**
105+
* Get the list of users who have data within a context.
106+
*
107+
* @param userlist $userlist The list of users who have data in this plugin.
108+
*/
109+
public static function get_users_in_context(userlist $userlist) {
110+
// Empty on purpose.
111+
}
112+
113+
/**
114+
* Delete multiple users within a single context.
115+
*
116+
* @param approved_userlist $userlist The approved context and user information to delete.
117+
*/
118+
public static function delete_data_for_users(approved_userlist $userlist) {
119+
// Empty on purpose.
120+
}
121+
}

lang/en/cms.php

+5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
$string['maxgrade'] = 'Default max grade';
3838
$string['maxgrade_desc'] = 'The default max grade when creating a new custom content type instance.';
3939
$string['modulename'] = 'CMS';
40+
$string['modulenameplural'] = 'CMS';
4041
$string['newcontenttype'] = 'Add new content type';
4142
$string['pluginname'] = 'CMS';
43+
$string['privacy:metadata:cms'] = 'Custom content type instances';
44+
$string['privacy:metadata:cms:usermodified'] = 'User who modified the instances';
45+
$string['privacy:metadata:cms_types'] = 'Custom content types';
46+
$string['privacy:metadata:cms_types:usermodified'] = 'User who modified the custom content types';
4247
$string['settings'] = 'Custom content type settings';
4348
$string['table:name'] = 'Custom content type';

lib.php

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Library functions for custom content type module
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
use core_course\local\entity\content_item;
27+
28+
/**
29+
* @uses FEATURE_IDNUMBER
30+
* @uses FEATURE_GROUPS
31+
* @uses FEATURE_GROUPINGS
32+
* @uses FEATURE_MOD_INTRO
33+
* @uses FEATURE_COMPLETION_TRACKS_VIEWS
34+
* @uses FEATURE_GRADE_HAS_GRADE
35+
* @uses FEATURE_GRADE_OUTCOMES
36+
* @param string $feature FEATURE_xx constant for requested feature
37+
*
38+
* @return bool|null
39+
*/
40+
function cms_supports($feature) {
41+
switch($feature) {
42+
case FEATURE_IDNUMBER:
43+
case FEATURE_MOD_INTRO:
44+
case FEATURE_BACKUP_MOODLE2:
45+
case FEATURE_NO_VIEW_LINK:
46+
return true;
47+
case FEATURE_GROUPS:
48+
case FEATURE_GROUPINGS:
49+
case FEATURE_COMPLETION_TRACKS_VIEWS:
50+
case FEATURE_GRADE_HAS_GRADE:
51+
case FEATURE_GRADE_OUTCOMES:
52+
return false;
53+
case FEATURE_MOD_ARCHETYPE:
54+
return MOD_ARCHETYPE_RESOURCE;
55+
case FEATURE_MOD_PURPOSE:
56+
return MOD_PURPOSE_CONTENT;
57+
default:
58+
return null;
59+
}
60+
}
61+
62+
/**
63+
* Return the custom content types which have been predefined.
64+
*
65+
* @param content_item $defaultmodulecontentitem
66+
* @param stdClass $user
67+
* @param stdClass $course
68+
*
69+
* @return array
70+
*/
71+
function cms_get_course_content_items(content_item $defaultmodulecontentitem, stdClass $user,
72+
stdClass $course) {
73+
global $CFG, $OUTPUT;
74+
75+
$types = [];
76+
77+
return $types;
78+
}

0 commit comments

Comments
 (0)