From 889603beb8b5f6c0e53f1b1a0b11da37a0cffbf8 Mon Sep 17 00:00:00 2001 From: TamaroWalter Date: Thu, 19 Sep 2024 11:33:48 +0200 Subject: [PATCH] timespan as setting --- lang/en/block_townsquare.php | 5 +++++ lib.php | 9 +++++++-- settings.php | 17 +++++++++++++---- version.php | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lang/en/block_townsquare.php b/lang/en/block_townsquare.php index 68074de..11c3c5e 100644 --- a/lang/en/block_townsquare.php +++ b/lang/en/block_townsquare.php @@ -41,6 +41,7 @@ $string['configcompletionlettercolor'] = 'Configuration for the color of the activity completion letters'; $string['configorientationmarkercolor'] = 'Configuration for the color of the orientation marker'; $string['configpostlettercolor'] = 'Configuration for the color of the post letters'; +$string['configtimespan'] = 'Setting, in which time span townsquare will search for events and notifications'; $string['coursefilter'] = 'Course filter'; $string['dataclosemessage'] = 'Please submit your entries until {$a->time}. The database closes afterwards'; $string['dataopenmessage'] = 'The database opens today'; @@ -89,6 +90,10 @@ $string['scormopenmessage'] = 'Scorm Activity opens today'; $string['showmore'] = 'Show more'; $string['timefilter'] = 'Time filter'; +$string['timesixmonths'] = 'Six months'; +$string['timespan'] = 'Search time span'; +$string['timethreemonths'] = 'Three months'; +$string['timetwomonths'] = 'Two months'; $string['workshopcloseassessment'] = 'Assessments for the workshop are due until {$a->time}'; $string['workshopclosesubmission'] = 'Please submit your work until {$a->time}. The workshop closes afterwards'; $string['workshopopenassessment'] = 'The assessment phase starts today at {$a->time}'; diff --git a/lib.php b/lib.php index cea83f0..3036ed6 100644 --- a/lib.php +++ b/lib.php @@ -22,6 +22,11 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +// Time constants. +define('TOWNSQUARE_TIME_TWOMONTHS', 5259486); // 60.87 days +define('TOWNSQUARE_TIME_THREEMONTHS', 7889229); // 91.31 days +define('TOWNSQUARE_TIME_SIXMONTHS', 15778463); // 182,62 days + // Color constants from bootstrap. define('TOWNSQUARE_BASICLETTER_DEFAULTCOLOR', '#0f6cbf'); define('TOWNSQUARE_POSTLETTER_DEFAULTCOLOR', '#f7634d'); @@ -49,7 +54,7 @@ function townsquare_get_courses(): array { * @return int */ function townsquare_get_timestart(): int { - return time() - 7884000; + return time() - get_config('block_townsquare', 'timespan'); } /** @@ -57,7 +62,7 @@ function townsquare_get_timestart(): int { * @return int */ function townsquare_get_timeend(): int { - return time() + 7884000; + return time() + get_config('block_townsquare', 'timespan'); } /** diff --git a/settings.php b/settings.php index 43a254e..1ea6e99 100644 --- a/settings.php +++ b/settings.php @@ -28,25 +28,34 @@ if ($ADMIN->fulltree) { require_once($CFG->dirroot . '/blocks/townsquare/lib.php'); - // Color Setting for the color that will be used on basic letters. + // Time setting for the search span. + $options = []; + $options[TOWNSQUARE_TIME_TWOMONTHS] = get_string('timetwomonths', 'block_townsquare'); + $options[TOWNSQUARE_TIME_THREEMONTHS] = get_string('timethreemonths', 'block_townsquare'); + $options[TOWNSQUARE_TIME_SIXMONTHS] = get_string('timesixmonths', 'block_townsquare'); + + $settings->add(new admin_setting_configselect('block_townsquare/timespan', get_string('timespan', 'block_townsquare'), + get_string('configtimespan', 'block_townsquare'), TOWNSQUARE_TIME_THREEMONTHS, $options)); + + // Color setting for the color that will be used on basic letters. $settings->add(new admin_setting_configcolourpicker('block_townsquare/basiclettercolor', get_string('basiclettercolor', 'block_townsquare'), get_string('configbasiclettercolor', 'block_townsquare'), TOWNSQUARE_BASICLETTER_DEFAULTCOLOR)); - // Color Setting for the color that will be used on post letters. + // Color setting for the color that will be used on post letters. $settings->add(new admin_setting_configcolourpicker('block_townsquare/postlettercolor', get_string('postlettercolor', 'block_townsquare'), get_string('configpostlettercolor', 'block_townsquare'), TOWNSQUARE_POSTLETTER_DEFAULTCOLOR)); - // Color Setting for the color that will be used on completion letters. + // Color setting for the color that will be used on completion letters. $settings->add(new admin_setting_configcolourpicker('block_townsquare/completionlettercolor', get_string('completionlettercolor', 'block_townsquare'), get_string('configcompletionlettercolor', 'block_townsquare'), TOWNSQUARE_COMPLETIONLETTER_DEFAULTCOLOR)); - // Color Setting for the orientation marker. + // Color setting for the orientation marker. $settings->add(new admin_setting_configcolourpicker('block_townsquare/orientationmarkercolor', get_string('orientationmarkercolor', 'block_townsquare'), get_string('configorientationmarkercolor', 'block_townsquare'), diff --git a/version.php b/version.php index 9729b1d..87ec2f8 100644 --- a/version.php +++ b/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'block_townsquare'; $plugin->release = '0.1.0'; -$plugin->version = 2024091700; +$plugin->version = 2024091900; $plugin->requires = 2022041900; $plugin->maturity = MATURITY_ALPHA;