Skip to content

Commit

Permalink
Included settings for the category image setup
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Apr 6, 2024
1 parent eda5147 commit a65a2a9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use block_dash\local\data_source\categories_data_source;
use block_dash\local\data_source\form\preferences_form;
use block_dash\local\layout\grid_layout;
use block_dash\local\layout\accordion_layout;
Expand Down Expand Up @@ -63,6 +64,11 @@ function block_dash_register_data_sources() {
'help' => ['name' => 'users', 'component' => 'block_dash'],
'identifier' => users_data_source::class,
],
[
'name' => get_string('categories'),
'help' => ['name' => 'categories', 'component' => 'block_dash'],
'identifier' => categories_data_source::class,
],
];
}

Expand Down Expand Up @@ -175,13 +181,13 @@ function block_dash_output_fragment_block_preferences_form($args) {
*/
function block_dash_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=[]) {

if ($context->contextlevel != CONTEXT_BLOCK) {
if ($context->contextlevel != CONTEXT_BLOCK && $context->contextlevel != CONTEXT_SYSTEM) {
return false;
}

require_login();

if ($filearea == 'images') {
if ($filearea == 'images' || $filearea == 'categoryimg') {

$relativepath = implode('/', $args);

Expand Down
32 changes: 32 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,41 @@
get_string('suggestusers_desc', 'block_dash'), [], $users)
);

if ($ADMIN->fulltree) {// Category images.

$settings->add(new admin_setting_heading('block_dash_categoryimg', get_string('categoryimgheadingsub', 'block_dash'),
format_text(get_string('categoryimgdesc', 'block_dash'), FORMAT_MARKDOWN)));

$name = 'block_dash/categoryimgfallback';
$title = get_string('categoryimgfallback', 'block_dash');
$description = get_string('categoryimgfallbackdesc', 'block_dash');
$default = 'categoryimg';
$setting = new admin_setting_configstoredfile($name, $title, $description, $default, 0);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);

// require_once($CFG->libdir . '/coursecatlib.php');
$coursecats = core_course_category::make_categories_list();

// Go through all categories and create the necessary settings.
foreach ($coursecats as $key => $value) {
// Category Icons for each category.
$name = 'block_dash/categoryimg';
$title = $value;
$description = get_string('categoryimgcategory', 'block_dash', array('category' => $value));
$filearea = 'categoryimg';
$setting = new admin_setting_configstoredfile($name . $key, $title, $description, $default, $key);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
}
unset($coursecats);
}

$PAGE->requires->js_amd_inline("
require(['core/form-autocomplete'], function(module) {
module.enhance('#id_s_block_dash_suggestusers');
});
");


}
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 = 2024040401; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024040402; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2022112800; // Requires Moodle 4.1.
$plugin->component = 'block_dash'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit a65a2a9

Please sign in to comment.