Skip to content

Commit

Permalink
DASH-195 Add global disable all dashes setting
Browse files Browse the repository at this point in the history
  • Loading branch information
moodledev committed Dec 16, 2020
1 parent 62f23c1 commit 1f40739
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ Typical use cases:
*List all students of a teacher (all participants of all courses where the current user has a teacher role)
*List all participants including their picture and group

## Troubleshooting

If your site is not loading properly you may wish to temporarily disable Dash from outputting block content. There are two ways to do this:

1. Go to *Site administration / Plugins / Blocks / Dash*. Enable **Disable all Dash output** OR
2. Edit your `config.php` and add `$CFG->block_dash_disableall = true;`

# Development

### Key terms
Expand Down
7 changes: 7 additions & 0 deletions block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

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

require_once("$CFG->dirroot/blocks/dash/lib.php");

/**
* Dash block class.
*/
Expand Down Expand Up @@ -100,6 +102,11 @@ public function get_content() {

$this->content = new \stdClass();

if (block_dash_is_disabled()) {
$this->content->text = is_siteadmin() ? get_string('disableallmessage', 'block_dash') : '';
return $this->content;
}

try {
$bb = block_builder::create($this);

Expand Down
12 changes: 12 additions & 0 deletions lang/en/block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
$string['addnewfield'] = 'Add new field';
$string['availablefields'] = 'Available fields';
$string['availablefields_help'] = 'Choose all possible fields this data source will utilize. The user will be able to select which fields to include for their own purposes. For example, if you are displaying user information, try to include as many user fields as possible.';
$string['badgecolorfield'] = 'Badge color field';
$string['badgecolorfield_help'] = 'Choose a field that returns colors to be used for timeline item badges.';
$string['blocktitle'] = 'Block title';
$string['blocktitle_help'] = 'Title displayed in block heading. Enter a short and descriptive title for what this block displays to the user.';
$string['blockwidth'] = 'Block width';
Expand Down Expand Up @@ -101,6 +103,9 @@
$string['deletecustomdatasource'] = 'Delete custom data source';
$string['deletecustomlayout'] = 'Delete custom layout';
$string['deletedashboard'] = 'Delete dashboard';
$string['disableall'] = 'Disable all Dash output';
$string['disableall_help'] = 'Warning: For troubleshooting purposes or troubleshooting broken pages';
$string['disableallmessage'] = 'Dash output is disabled. Check Dash settings.';
$string['dragitem'] = 'Drag item';
$string['edit'] = 'Edit';
$string['editcustomdatasource'] = 'Edit data source';
Expand All @@ -120,6 +125,10 @@
$string['enrollmentstatus'] = 'Enrollment status';
$string['enrollmenttimeend'] = 'Enrollment end date';
$string['enrollmenttimestart'] = 'Enrollment start date';
$string['eventcolor'] = 'Event color';
$string['eventdescription'] = 'Event description';
$string['eventicon'] = 'Event icon';
$string['eventtime'] = 'Event time';
$string['extracontent'] = 'Extra content';
$string['fieldname'] = 'Field name';
$string['fieldnotfound'] = 'Field not found.';
Expand Down Expand Up @@ -156,6 +165,7 @@
$string['layoutdoesnotsupportfiltering'] = 'The chosen layout does not support filtering';
$string['layoutgrid'] = 'Table layout';
$string['layoutonestat'] = 'One figure + label layout';
$string['layouttimeline'] = 'Timeline layout';
$string['layouttwostat'] = 'One figure / other figure layout';
$string['layouttype'] = 'Layout type';
$string['loggedinuser'] = 'Logged in user';
Expand Down Expand Up @@ -198,6 +208,7 @@
$string['stattodisplayother'] = 'Other figure to display';
$string['status'] = 'Status';
$string['subheadingfield'] = 'Subheading field';
$string['subheadingfieldicon'] = 'Subheading icon';
$string['supportsfieldvisibility'] = 'Supports field visibility';
$string['supportsfieldvisibility_help'] = 'When enabled, allow admin to conditionally enable and disable fields.';
$string['supportsfiltering'] = 'Supports filtering';
Expand All @@ -220,6 +231,7 @@
$string['tablealias_sl'] = 'Site logs';
$string['tablealias_u'] = 'User';
$string['tablealias_ue'] = 'User enrollment';
$string['timesinceevent'] = 'Time since event';
$string['titleoverride'] = 'Title override';
$string['totalactivities'] = 'Total activities';
$string['totalactivitiescompletion'] = 'Total activities (completion relevant)';
Expand Down
20 changes: 20 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,24 @@ function block_dash_is_totara() {
*/
function block_dash_has_pro() {
return array_key_exists('dash', core_component::get_plugin_list('local'));
}

/**
* Check if dash output should be disabled.
*
* @return bool
* @throws dml_exception
*/
function block_dash_is_disabled() {
global $CFG;

if (get_config('block_dash', 'disableall')) {
return true;
}

if (isset($CFG->block_dash_disableall) && $CFG->block_dash_disableall) {
return true;
}

return false;
}
18 changes: 14 additions & 4 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@
require_once("$CFG->dirroot/blocks/dash/lib.php");

// Default high scores.
$setting = new admin_setting_configselect('block_dash/bootstrap_version',
$settings->add(new admin_setting_configselect(
'block_dash/bootstrap_version',
get_string('bootstrapversion', 'block_dash'),
get_string('bootstrapversion_desc', 'block_dash'), block_dash_is_totara() ? 3 : 4, [
get_string('bootstrapversion_desc', 'block_dash'),
block_dash_is_totara() ? 3 : 4,
[
3 => 'Bootstrap 3.x',
4 => 'Bootstrap 4.x'
]);
$settings->add($setting);
]
));

$settings->add(new admin_setting_configcheckbox(
'block_dash/disableall',
get_string('disableall', 'block_dash'),
get_string('disableall_help', 'block_dash'),
0
));
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

$plugin->version = 2020111700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2020121500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2017051509; // Requires this Moodle version.
$plugin->component = 'block_dash'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_BETA;
Expand Down

0 comments on commit 1f40739

Please sign in to comment.