mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-65400 block: Support returning settings for core blocks
This commit is contained in:
parent
c9acdfb6dc
commit
bc72a54cb1
@ -704,4 +704,21 @@ class block_activity_results extends block_base {
|
||||
return $scale;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$instanceconfigs = !empty($this->config) ? $this->config : new stdClass();
|
||||
$pluginconfigs = get_config('block_activity_results');
|
||||
|
||||
return (object) [
|
||||
'instance' => $instanceconfigs,
|
||||
'plugin' => $pluginconfigs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -125,4 +125,20 @@ class block_blog_recent extends block_base {
|
||||
$this->content->text .= get_string('norecentblogentries', 'block_blog_recent');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -206,6 +206,22 @@ class block_blog_tags extends block_base {
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function block_blog_tags_sort($a, $b) {
|
||||
|
@ -177,6 +177,27 @@ class block_course_list extends block_list {
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
global $CFG;
|
||||
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = (object) [
|
||||
'adminview' => $CFG->block_course_list_adminview,
|
||||
'hideallcourseslink' => $CFG->block_course_list_hideallcourseslink
|
||||
];
|
||||
|
||||
return (object) [
|
||||
'instance' => new stdClass(),
|
||||
'plugin' => $configs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,5 +254,21 @@ class block_glossary_random extends block_base {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,4 +209,23 @@ class block_html extends block_base {
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
global $CFG;
|
||||
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$instanceconfigs = !empty($this->config) ? $this->config : new stdClass();
|
||||
$pluginconfigs = (object) ['allowcssclasses' => $CFG->block_html_allowcssclasses];
|
||||
|
||||
return (object) [
|
||||
'instance' => $instanceconfigs,
|
||||
'plugin' => $pluginconfigs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -78,5 +78,21 @@ class block_mentees extends block_base {
|
||||
public function instance_can_be_docked() {
|
||||
return parent::instance_can_be_docked() && isset($this->config->title) && !empty($this->config->title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,5 +82,21 @@ class block_myoverview extends block_base {
|
||||
public function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = get_config('block_myoverview');
|
||||
|
||||
return (object) [
|
||||
'instance' => new stdClass(),
|
||||
'plugin' => $configs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,4 +129,19 @@ class block_myprofile extends block_base {
|
||||
public function before_delete() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -326,4 +326,20 @@ class block_navigation extends block_base {
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -157,6 +157,27 @@ class block_online_users extends block_base {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
global $CFG;
|
||||
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = (object) [
|
||||
'timetosee' => $CFG->block_online_users_timetosee,
|
||||
'onlinestatushiding' => $CFG->block_online_users_onlinestatushiding
|
||||
];
|
||||
|
||||
return (object) [
|
||||
'instance' => new stdClass(),
|
||||
'plugin' => $configs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,4 +76,20 @@ class block_recentlyaccessedcourses extends block_base {
|
||||
public function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = get_config('block_recentlyaccessedcourses');
|
||||
|
||||
return (object) [
|
||||
'instance' => new stdClass(),
|
||||
'plugin' => $configs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -279,4 +279,26 @@
|
||||
return core_text::substr($title, 0, $max - 3) . '...';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
global $CFG;
|
||||
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$instanceconfigs = !empty($this->config) ? $this->config : new stdClass();
|
||||
$pluginconfigs = (object) [
|
||||
'num_entries' => $CFG->block_rss_client_num_entries,
|
||||
'timeout' => $CFG->block_rss_client_timeout
|
||||
];
|
||||
|
||||
return (object) [
|
||||
'instance' => $instanceconfigs,
|
||||
'plugin' => $pluginconfigs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,23 @@ class block_section_links extends block_base {
|
||||
public function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$instanceconfigs = !empty($this->config) ? $this->config : new stdClass();
|
||||
$pluginconfigs = get_config('block_section_links');
|
||||
|
||||
return (object) [
|
||||
'instance' => $instanceconfigs,
|
||||
'plugin' => $pluginconfigs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,4 +160,20 @@ class block_settings extends block_base {
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -81,4 +81,20 @@ class block_starredcourses extends block_base {
|
||||
public function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = get_config('block_starredcourses');
|
||||
|
||||
return (object) [
|
||||
'instance' => new stdClass(),
|
||||
'plugin' => $configs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,22 @@ class block_tag_flickr extends block_base {
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -398,5 +398,25 @@ class block_tag_youtube extends block_base {
|
||||
return $oldcat;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// There is a private key, only admins can see it.
|
||||
$pluginconfigs = get_config('block_tag_youtube');
|
||||
if (!has_capability('moodle/site:config', context_system::instance())) {
|
||||
unset($pluginconfigs->apikey);
|
||||
}
|
||||
$instanceconfigs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $instanceconfigs,
|
||||
'plugin' => $pluginconfigs,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,4 +109,20 @@ class block_tags extends block_base {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugin config settings for external functions.
|
||||
*
|
||||
* @return stdClass the configs for both the block instance and plugin
|
||||
* @since Moodle 3.8
|
||||
*/
|
||||
public function get_config_for_external() {
|
||||
// Return all settings for all users since it is safe (no private keys, etc..).
|
||||
$configs = !empty($this->config) ? $this->config : new stdClass();
|
||||
|
||||
return (object) [
|
||||
'instance' => $configs,
|
||||
'plugin' => new stdClass(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user