From b5987836fcfcc65a1bda30b49d7afe152f6a1a30 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 29 Sep 2015 14:57:19 +0800 Subject: [PATCH] MDL-51315 tablelib: Only display table preferences if necessary. A thank you to Tony Butler for a solution to this issue. --- lib/tablelib.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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'); -- 2.43.0