Skip to content

Commit

Permalink
timespan as setting
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Sep 19, 2024
1 parent 529506e commit 889603b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions lang/en/block_townsquare.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}';
Expand Down
9 changes: 7 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -49,15 +54,15 @@ function townsquare_get_courses(): array {
* @return int
*/
function townsquare_get_timestart(): int {
return time() - 7884000;
return time() - get_config('block_townsquare', 'timespan');
}

/**
* Function for subplugins to get the end time of the search.
* @return int
*/
function townsquare_get_timeend(): int {
return time() + 7884000;
return time() + get_config('block_townsquare', 'timespan');
}

/**
Expand Down
17 changes: 13 additions & 4 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 889603b

Please sign in to comment.