From: Adrian Greeve Date: Tue, 29 Sep 2015 06:57:19 +0000 (+0800) Subject: MDL-51315 tablelib: Only display table preferences if necessary. X-Git-Tag: v3.0.0-beta~131^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=b5987836fcfcc65a1bda30b49d7afe152f6a1a30 MDL-51315 tablelib: Only display table preferences if necessary. A thank you to Tony Butler for a solution to this issue. --- diff --git a/lib/tablelib.php b/lib/tablelib.php index c348e1fda40..06516e9c20a 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -1419,6 +1419,21 @@ class flexible_table { * @return string HTML fragment. */ private function render_reset_button() { + $userprefs = false; + // Loop through the user table preferences for a setting. + foreach ($this->prefs as $preference) { + if (!empty($preference)) { + // We have a preference. + $userprefs = true; + // We only need one. + break; + } + } + // If no table preferences have been set then don't show the reset button. + if (!$userprefs) { + return ''; + } + $url = $this->baseurl->out(false, array($this->request[TABLE_VAR_RESET] => 1)); $html = html_writer::start_div('mdl-right');