Skip to content

Commit 4e71026

Browse files
committed
Implement admin page enabling
1 parent cf401b4 commit 4e71026

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

classes/table/snippets_overview.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ public function col_actions($data) {
188188
$actions[] = [
189189
'url' => new \moodle_url('/theme/boost_union/snippets/overview.php',
190190
['action' => 'enable', 'id' => $data->id, 'sesskey' => sesskey()]),
191-
'icon' => new \pix_icon('t/hide', get_string('snippetsenable', 'theme_boost_union')),
191+
'icon' => new \pix_icon('t/show', get_string('snippetsenable', 'theme_boost_union')),
192192
'attributes' => ['class' => 'action-enable'],
193193
];
194194
} else {
195195
$actions[] = [
196196
'url' => new \moodle_url('/theme/boost_union/snippets/overview.php',
197197
['action' => 'disable', 'id' => $data->id, 'sesskey' => sesskey()]),
198-
'icon' => new \pix_icon('t/show', get_string('snippetsdisable', 'theme_boost_union')),
198+
'icon' => new \pix_icon('t/hide', get_string('snippetsdisable', 'theme_boost_union')),
199199
'attributes' => ['class' => 'action-disable'],
200200
];
201201
}

lang/en/theme_boost_union.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@
11101110
$string['snippetsdisable'] = 'Disable';
11111111
$string['snippetsscope'] = 'Scope';
11121112
$string['snippetsscopeglobal'] = 'Global';
1113+
$string['snippetsscopecourse'] = 'Course';
11131114
$string['snippetsgoal'] = 'Goal';
11141115
$string['snippetsgoaleyecandy'] = 'Eye candy';
11151116
$string['snippetsgoalbugfix'] = 'Bugfix';
@@ -1297,10 +1298,6 @@
12971298
$string['smartmenussavechangesandconfigure'] = 'Save and configure items';
12981299
$string['smartmenussettings'] = 'Smart menu settings';
12991300

1300-
// CSS Snippets.
1301-
$string['snippetsscopelogin'] = 'snippets scope login';
1302-
$string['snippetsscopecourse'] = 'snippets scope course';
1303-
13041301
// Privacy API.
13051302
$string['privacy:metadata'] = 'The Boost Union theme does not store any personal data about any user.';
13061303

snippets/builtin/fix_font.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
return [
2828
'domain' => 'theme_boost_union',
2929
'title' => 'Fix font color',
30-
'scope' => 'login',
30+
'scope' => 'global',
3131
'goal' => 'eyecandy',
3232
'description' => 'Those borders are annoying',
3333
'css' => 'body {color: 4px;}',

snippets/overview.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,24 @@
8888
}
8989
break;
9090
case 'disable':
91-
// TODO
91+
// Get the snippet record and disable it in the database.
92+
$currentsnippet = $DB->get_record('theme_boost_union_snippets', ['id' => $snippetid]);
93+
$currentsnippet->enabled = false;
94+
$DB->update_record('theme_boost_union_snippets', $currentsnippet);
95+
96+
// Purge the theme cache (as the list of CSS snippets has changed and the SCSS has to be re-compiled).
97+
theme_reset_all_caches();
98+
9299
break;
93100
case 'enable':
94-
// TODO
101+
// Get the snippet record and enable it in the database.
102+
$currentsnippet = $DB->get_record('theme_boost_union_snippets', ['id' => $snippetid]);
103+
$currentsnippet->enabled = true;
104+
$DB->update_record('theme_boost_union_snippets', $currentsnippet);
105+
106+
// Purge the theme cache (as the list of CSS snippets has changed and the SCSS has to be re-compiled).
107+
theme_reset_all_caches();
108+
95109
break;
96110
}
97111

0 commit comments

Comments
 (0)