Skip to content

Commit

Permalink
MDL-65400 block: Support returning settings for core blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Oct 23, 2019
1 parent c9acdfb commit bc72a54
Show file tree
Hide file tree
Showing 19 changed files with 328 additions and 0 deletions.
17 changes: 17 additions & 0 deletions blocks/activity_results/block_activity_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,21 @@ private function get_scale($scaleid) {
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,
];
}
}
16 changes: 16 additions & 0 deletions blocks/blog_recent/block_blog_recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,20 @@ function get_content() {
$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(),
];
}
}
16 changes: 16 additions & 0 deletions blocks/blog_tags/block_blog_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@ function get_content() {
}
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) {
Expand Down
21 changes: 21 additions & 0 deletions blocks/course_list/block_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,27 @@ function get_remote_courses() {
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,
];
}
}


16 changes: 16 additions & 0 deletions blocks/glossary_random/block_glossary_random.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,21 @@ function get_content() {

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(),
];
}
}

19 changes: 19 additions & 0 deletions blocks/html/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,23 @@ function html_attributes() {

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,
];
}
}
16 changes: 16 additions & 0 deletions blocks/mentees/block_mentees.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,21 @@ function get_content() {
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(),
];
}
}

16 changes: 16 additions & 0 deletions blocks/myoverview/block_myoverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,21 @@ public function applicable_formats() {
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,
];
}
}

15 changes: 15 additions & 0 deletions blocks/myprofile/block_myprofile.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,19 @@ public function after_install() {
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(),
];
}
}
16 changes: 16 additions & 0 deletions blocks/navigation/block_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,20 @@ protected function trim_center($string, $length) {
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(),
];
}
}
21 changes: 21 additions & 0 deletions blocks/online_users/block_online_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ function get_content() {

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,
];
}
}


16 changes: 16 additions & 0 deletions blocks/recentlyaccessedcourses/block_recentlyaccessedcourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,20 @@ public function applicable_formats() {
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,
];
}
}
22 changes: 22 additions & 0 deletions blocks/rss_client/block_rss_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,26 @@ function format_title($title,$max=64) {
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,
];
}
}
17 changes: 17 additions & 0 deletions blocks/section_links/block_section_links.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ public function instance_allow_config() {
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,
];
}
}


16 changes: 16 additions & 0 deletions blocks/settings/block_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,20 @@ function get_content() {
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(),
];
}
}
16 changes: 16 additions & 0 deletions blocks/starredcourses/block_starredcourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,20 @@ public function applicable_formats() {
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,
];
}
}
16 changes: 16 additions & 0 deletions blocks/tag_flickr/block_tag_flickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ function build_photo_url ($photo, $size='medium') {
}
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(),
];
}
}


Loading

0 comments on commit bc72a54

Please sign in to comment.