mirror of
https://github.com/moodle/moodle.git
synced 2025-04-09 02:12:22 +02:00
MDL-65149 emoticons: Do not show all emoticons
Allow some emoticons to still work, but not be selectable from the text editor plugins.
This commit is contained in:
parent
3271c39c74
commit
f65a888901
@ -36,7 +36,7 @@ function atto_emoticon_strings_for_js() {
|
||||
|
||||
// Load the strings required by the emotes.
|
||||
$manager = get_emoticon_manager();
|
||||
foreach ($manager->get_emoticons() as $emote) {
|
||||
foreach ($manager->get_emoticons(true) as $emote) {
|
||||
$PAGE->requires->string_for_js($emote->altidentifier, $emote->altcomponent);
|
||||
}
|
||||
}
|
||||
@ -49,6 +49,6 @@ function atto_emoticon_strings_for_js() {
|
||||
function atto_emoticon_params_for_js($elementid, $options, $fpoptions) {
|
||||
$manager = get_emoticon_manager();
|
||||
return array(
|
||||
'emoticons' => $manager->get_emoticons()
|
||||
'emoticons' => $manager->get_emoticons(true)
|
||||
);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ header('X-UA-Compatible: IE=edge');
|
||||
<table border="0" align="center" style="width:100%;">
|
||||
<?php
|
||||
|
||||
$emoticons = $emoticonmanager->get_emoticons();
|
||||
$emoticons = $emoticonmanager->get_emoticons(true);
|
||||
// This is tricky - we must somehow include the information about the original
|
||||
// emoticon text so that we can replace the image back with it on editor save.
|
||||
// so we are going to encode the index of the emoticon. this will break when the
|
||||
|
@ -52,7 +52,7 @@ class tinymce_moodleemoticon extends editor_tinymce_plugin {
|
||||
|
||||
// Extra params specifically for emoticon plugin.
|
||||
$manager = get_emoticon_manager();
|
||||
$emoticons = $manager->get_emoticons();
|
||||
$emoticons = $manager->get_emoticons(true);
|
||||
$imgs = array();
|
||||
// See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
|
||||
$index = 0;
|
||||
|
@ -7348,10 +7348,12 @@ class emoticon_manager {
|
||||
/**
|
||||
* Returns the currently enabled emoticons
|
||||
*
|
||||
* @param boolean $selectable - If true, only return emoticons that should be selectable from a list.
|
||||
* @return array of emoticon objects
|
||||
*/
|
||||
public function get_emoticons() {
|
||||
public function get_emoticons($selectable = false) {
|
||||
global $CFG;
|
||||
$notselectable = ['martin', 'egg'];
|
||||
|
||||
if (empty($CFG->emoticons)) {
|
||||
return array();
|
||||
@ -7364,6 +7366,14 @@ class emoticon_manager {
|
||||
debugging('Invalid format of emoticons setting, please resave the emoticons settings form', DEBUG_NORMAL);
|
||||
return array();
|
||||
}
|
||||
if ($selectable) {
|
||||
foreach ($emoticons as $index => $emote) {
|
||||
if (in_array($emote->altidentifier, $notselectable)) {
|
||||
// Skip this one.
|
||||
unset($emoticons[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $emoticons;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user