Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
4bebed40
Commit
4bebed40
authored
Jul 11, 2018
by
Adrian Greeve
Browse files
MDL-53697 mod: Final deprecation of xxx_get_types().
parent
f61ee4e8
Changes
5
Hide whitespace changes
Inline
Side-by-side
course/format/singleactivity/lib.php
View file @
4bebed40
...
...
@@ -342,8 +342,7 @@ class format_singleactivity extends format_base {
/**
* Checks if the activity type has multiple items in the activity chooser.
* This may happen as a result of defining callback modulename_get_shortcuts()
* or [deprecated] modulename_get_types() - TODO MDL-53697 remove this line.
* This may happen as a result of defining callback modulename_get_shortcuts().
*
* @return bool|null (null if the check is not possible)
*/
...
...
course/lib.php
View file @
4bebed40
...
...
@@ -669,9 +669,6 @@ function get_module_metadata($course, $modnames, $sectionreturn = null) {
}
$defaultmodule
->
archetype
=
plugin_supports
(
'mod'
,
$modname
,
FEATURE_MOD_ARCHETYPE
,
MOD_ARCHETYPE_OTHER
);
// Legacy support for callback get_types() - do not use any more, use get_shortcuts() instead!
$typescallbackexists
=
component_callback_exists
(
$modname
,
'get_types'
);
// Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list
// of elements to be added to activity chooser.
$items
=
component_callback
(
$modname
,
'get_shortcuts'
,
array
(
$defaultmodule
),
null
);
...
...
@@ -699,58 +696,14 @@ function get_module_metadata($course, $modnames, $sectionreturn = null) {
$modlist
[
$course
->
id
][
$modname
][
$item
->
name
]
=
$item
;
}
$return
+=
$modlist
[
$course
->
id
][
$modname
];
if
(
$typescallbackexists
)
{
debugging
(
'Both callbacks get_shortcuts() and get_types() are found in module '
.
$modname
.
'. Callback get_types() will be completely ignored'
,
DEBUG_DEVELOPER
);
}
// If get_shortcuts() callback is defined, the default module action is not added.
// It is a responsibility of the callback to add it to the return value unless it is not needed.
continue
;
}
if
(
$typescallbackexists
)
{
debugging
(
'Callback get_types() is found in module '
.
$modname
.
', this functionality is deprecated, '
.
'please use callback get_shortcuts() instead'
,
DEBUG_DEVELOPER
);
}
$types
=
component_callback
(
$modname
,
'get_types'
,
array
(),
MOD_SUBTYPE_NO_CHILDREN
);
if
(
$types
!==
MOD_SUBTYPE_NO_CHILDREN
)
{
// Legacy support for deprecated callback get_types(). To be removed in Moodle 3.5. TODO MDL-53697.
if
(
is_array
(
$types
)
&&
count
(
$types
)
>
0
)
{
$grouptitle
=
$modnamestr
;
$icon
=
$OUTPUT
->
pix_icon
(
'icon'
,
''
,
$modname
,
array
(
'class'
=>
'icon'
));
foreach
(
$types
as
$type
)
{
if
(
$type
->
typestr
===
'--'
)
{
continue
;
}
if
(
strpos
(
$type
->
typestr
,
'--'
)
===
0
)
{
$grouptitle
=
str_replace
(
'--'
,
''
,
$type
->
typestr
);
continue
;
}
// Set the Sub Type metadata.
$subtype
=
new
stdClass
();
$subtype
->
title
=
get_string
(
'activitytypetitle'
,
''
,
(
object
)[
'activity'
=>
$grouptitle
,
'type'
=>
$type
->
typestr
]);
$subtype
->
type
=
str_replace
(
'&'
,
'&'
,
$type
->
type
);
$typename
=
preg_replace
(
'/.*type=/'
,
''
,
$subtype
->
type
);
$subtype
->
archetype
=
$type
->
modclass
;
if
(
!
empty
(
$type
->
help
))
{
$subtype
->
help
=
$type
->
help
;
}
else
if
(
get_string_manager
()
->
string_exists
(
'help'
.
$subtype
->
name
,
$modname
))
{
$subtype
->
help
=
get_string
(
'help'
.
$subtype
->
name
,
$modname
);
}
$subtype
->
link
=
new
moodle_url
(
$urlbase
,
array
(
'add'
=>
$modname
,
'type'
=>
$typename
));
$subtype
->
name
=
$modname
.
':'
.
$subtype
->
link
;
$subtype
->
icon
=
$icon
;
$modlist
[
$course
->
id
][
$modname
][
$subtype
->
name
]
=
$subtype
;
}
$return
+=
$modlist
[
$course
->
id
][
$modname
];
}
}
else
{
// Neither get_shortcuts() nor get_types() callbacks found, use the default item for the activity chooser.
$modlist
[
$course
->
id
][
$modname
][
$modname
]
=
$defaultmodule
;
$return
[
$modname
]
=
$defaultmodule
;
}
// The callback get_shortcuts() was not found, use the default item for the activity chooser.
$modlist
[
$course
->
id
][
$modname
][
$modname
]
=
$defaultmodule
;
$return
[
$modname
]
=
$defaultmodule
;
}
core_collator
::
asort_objects_by_property
(
$return
,
'title'
);
...
...
lib/moodlelib.php
View file @
4bebed40
...
...
@@ -453,13 +453,6 @@ define('MOD_ARCHETYPE_ASSIGNMENT', 2);
/** System (not user-addable) module archetype */
define
(
'MOD_ARCHETYPE_SYSTEM'
,
3
);
/**
* Return this from modname_get_types callback to use default display in activity chooser.
* Deprecated, will be removed in 3.5, TODO MDL-53697.
* @deprecated since Moodle 3.1
*/
define
(
'MOD_SUBTYPE_NO_CHILDREN'
,
'modsubtypenochildren'
);
/**
* Security token used for allowing access
* from external application such as web services.
...
...
mod/lti/lib.php
View file @
4bebed40
...
...
@@ -231,28 +231,6 @@ function lti_get_shortcuts($defaultitem) {
// Add items defined in ltisource plugins.
foreach
(
core_component
::
get_plugin_list
(
'ltisource'
)
as
$pluginname
=>
$dir
)
{
if
(
$moretypes
=
component_callback
(
"ltisource_
$pluginname
"
,
'get_types'
))
{
// Callback 'get_types()' in 'ltisource' plugins is deprecated in 3.1 and will be removed in 3.5, TODO MDL-53697.
debugging
(
'Deprecated callback get_types() is found in ltisource_'
.
$pluginname
.
', use get_shortcuts() instead'
,
DEBUG_DEVELOPER
);
$grouptitle
=
get_string
(
'modulenameplural'
,
'mod_lti'
);
foreach
(
$moretypes
as
$subtype
)
{
// Instead of adding subitems combine the name of the group with the name of the subtype.
$subtype
->
title
=
get_string
(
'activitytypetitle'
,
''
,
(
object
)[
'activity'
=>
$grouptitle
,
'type'
=>
$subtype
->
typestr
]);
// Re-implement the logic of get_module_metadata() in Moodle 3.0 and below for converting
// subtypes into items in activity chooser.
$subtype
->
type
=
str_replace
(
'&'
,
'&'
,
$subtype
->
type
);
$subtype
->
name
=
preg_replace
(
'/.*type=/'
,
''
,
$subtype
->
type
);
$subtype
->
link
=
new
moodle_url
(
$defaultitem
->
link
,
array
(
'type'
=>
$subtype
->
name
));
if
(
empty
(
$subtype
->
help
)
&&
!
empty
(
$subtype
->
name
)
&&
get_string_manager
()
->
string_exists
(
'help'
.
$subtype
->
name
,
$pluginname
))
{
$subtype
->
help
=
get_string
(
'help'
.
$subtype
->
name
,
$pluginname
);
}
unset
(
$subtype
->
typestr
);
$types
[]
=
$subtype
;
}
}
// LTISOURCE plugins can also implement callback get_shortcuts() to add items to the activity chooser.
// The return values are the same as of the 'mod' callbacks except that $defaultitem is only passed for reference and
// should not be added to the return value.
...
...
mod/upgrade.txt
View file @
4bebed40
This files describes API changes in /mod/* - activity modules,
information provided here is intended especially for developers.
=== 3.6 ===
* The final deprecation of xxx_get_types() callback means that this function will no longer be called.
Please use get_shortcuts() instead.
* lti_get_shortcuts has been deprecated. Please use get_shortcuts() instead to add items to the activity chooser.
=== 3.5 ===
* There is a new privacy API that every subsystem and plugin has to implement so that the site can become GDPR
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment