Skip to content

Commit

Permalink
Merge pull request #100 from bdecentgmbh/dev
Browse files Browse the repository at this point in the history
Call it 2.2
  • Loading branch information
stefanscholz authored Nov 5, 2024
2 parents b73451e + cabff70 commit 8352c79
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 29 deletions.
12 changes: 11 additions & 1 deletion block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public function has_config() {
public function specialization() {
global $OUTPUT;

// Verify the dash output is disabled, then use the default title for the block. stop execution here.
if (block_dash_is_disabled()) {
// Use default block title.
$this->title = get_string('newblock', 'block_dash');
return false;
}

if (isset($this->config->title)) {
$this->title = $this->title = format_string($this->config->title, true, ['context' => $this->context]);
} else {
Expand All @@ -73,9 +80,12 @@ public function specialization() {
$bb = block_builder::create($this);
if ($bb->is_collapsible_content_addon()) {
$addclass = "collapsible-block dash-block-collapse-icon";
if (!$bb->is_section_expand_content_addon()) {

$data = ['collapseaction' => true];
if (!$bb->get_configuration()->get_data_source()->is_section_expand_content_addon($data)) {
$addclass .= " collapsed";
}

$attr = [
'data-toggle' => 'collapse',
'class' => $addclass,
Expand Down
24 changes: 2 additions & 22 deletions classes/local/block_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use block_dash\output\query_debug;
use block_dash\output\renderer;
use html_writer;
use moodle_exception;

/**
* Helper class for creating block instance content.
Expand Down Expand Up @@ -86,27 +87,7 @@ public function is_collapsible_content_addon($checksection = false) {
return false;
}

/**
* Confirm the block is configured to display only for the section.
*
* @return bool
*/
public function is_section_expand_content_addon() {
if ($this->is_collapsible_content_addon()) {
$currentsection = optional_param('section', 0, PARAM_INT);
if (isset($this->blockinstance->config->preferences)) {
$preferneces = $this->blockinstance->config->preferences;
if (isset($preferneces['filters'])) {
$restrictedsections = isset($preferneces['filters']['sectiondisplay']['sections']) ?
$preferneces['filters']['sectiondisplay']['sections'] : [];
if (in_array((int)$currentsection, $restrictedsections)) {
return true;
}
}
}
}
return false;
}


/**
* Get content object for block instance.
Expand Down Expand Up @@ -134,7 +115,6 @@ public function get_block_content() {
'pagelayout' => $this->blockinstance->page->pagelayout,
'pagecontext' => $this->blockinstance->page->context->id,
'collapseaction' => $this->is_collapsible_content_addon(),
'showcollapseblock' => $this->is_section_expand_content_addon(),
];

if ($this->configuration->is_fully_configured()) {
Expand Down
2 changes: 1 addition & 1 deletion classes/local/dash_framework/structure/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function add_attribute(field_attribute_interface $attribute) {
*/
public function remove_attribute(field_attribute_interface $attribute) {
foreach ($this->attributes as $key => $fsearchattribute) {
if ($fsearchattribute === $attribute) {
if (get_class($fsearchattribute) === get_class($attribute)) {
unset($this->attributes[$key]);
}
}
Expand Down
35 changes: 35 additions & 0 deletions classes/local/data_grid/filter/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class filter implements filter_interface {
*/
private $preferences;

/**
* Is the filter supports the current user. this will be updated by the datasource.
*
* @var bool
*/
protected $supportcurrentuser = false;

/**
* Filter constructor.
*
Expand Down Expand Up @@ -489,4 +496,32 @@ public function build_settings_form_fields(
$mform->addHelpButton($fieldname . '[enabled]', $identifier, $component);
}
}

/**
* Set this datasource is support the profile page user.
*
* @return void
*/
public function set_support_currentuser() {
$this->supportcurrentuser = true;
}

/**
* Get the current userid.
*
* The current page is user profile page, then use the profile user id. Otherwise returns the current loggedin userid.
*
* @return int
*/
public function get_userid() {
global $PAGE, $USER;

if ($this->supportcurrentuser) {
// Confirm the dash is addon on user profile page, then use the profile page user as report user.
$isprofilepage = $PAGE->pagelayout == 'mypublic' && $PAGE->pagetype == 'user-profile';
$userid = $isprofilepage ? $PAGE->context->instanceid : $USER->id;
}

return $userid ?? $USER->id;
}
}
6 changes: 4 additions & 2 deletions classes/local/data_grid/filter/my_groups_condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ class my_groups_condition extends condition {
* @throws \coding_exception
*/
public function get_values() {

if (is_null($this->values)) {
global $USER;

$userid = $this->get_userid();

$this->values = [];

foreach (group_filter::get_user_groups($USER->id, $this->get_context()) as $group) {
foreach (group_filter::get_user_groups($userid, $this->get_context()) as $group) {
$this->values[] = $group->id;
}
}
Expand Down
55 changes: 55 additions & 0 deletions lang/en/block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,58 @@
$string['viewactivity'] = "View activity";
$string['activitybutton'] = "Activity button";
$string['modulename'] = 'Module name';

// ...Dashaddon calendar events.
$string['calendareventsfallback'] = 'Calendar events fallback image';
$string['calendareventsfallback_desc'] = 'Upload a image to display as fallback for site and other type of events';
// ... Event table fields labels.
$string['event'] = 'Event';
$string['event:title'] = 'Event title';
$string['event:type'] = 'Event type';
$string['event:typefilter'] = 'Event type filter';
// Event types.
$string['event:typesite'] = 'Site';
$string['event:typecourse'] = 'Course';
$string['event:typegroup'] = 'Group';
$string['event:typeuser'] = 'User';
$string['event:typecategory'] = 'Course category';
$string['event:typeother'] = 'Other';
$string['filter:today'] = 'Today';
$string['filter:upcoming'] = 'Upcoming';
$string['filter:thisweek'] = 'This week';
$string['filter:thismonth'] = 'This month';
$string['event:filterdate'] = 'Date';
// ...Filter day
$string['event:filterday'] = 'Day of week';
$string['filter:monday'] = 'Monday';
$string['filter:tuesday'] = 'Tuesday';
$string['filter:wednesday'] = 'Wednesday';
$string['filter:thursday'] = 'Thursday';
$string['filter:friday'] = 'Friday';
$string['filter:saturday'] = 'Saturday';
$string['filter:sunday'] = 'Sunday';
// ...Conditions.
$string['eventstatus'] = 'Event status';
$string['eventcontext'] = 'Context of event';
$string['eventactivitycompletion'] = 'Associated to an activity';
$string['eventactivity:incomplete'] = 'Incomplete activities only';
$string['eventactivity:both'] = 'Incomplete and complete activities';
$string['event:contextevent'] = 'Context of event';
$string['event:contextlinked'] = 'Context of event (linked) ';
$string['event:description'] = 'Description';
$string['event:gotoactivity'] = 'Go to activity';
$string['event:location'] = 'Location';
$string['event:startdate'] = 'Start date';
$string['event:starttime'] = 'Start time';
$string['event:enddate'] = 'End date';
$string['event:endtime'] = 'End time';
$string['event:duration'] = 'Event duration';
$string['event:durationinminutes'] = 'Event duration in minutes ';
$string['event:repeated'] = 'Repeated event';
$string['event:status'] = 'Status';
$string['event:color'] = 'Event color';
$string['even:icon'] = 'Even icon';
$string['event:image'] = 'Event image';
$string['event:imagelinked'] = 'Event image (linked)';
$string['event:imageurl'] = 'Event Image URL';
// ...End of Dashaddon calendar.
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024050802; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024050804; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021051700; // Requires this Moodle version.
$plugin->component = 'block_dash'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '2.1';
$plugin->supported = [401, 404];
$plugin->release = '2.2';
$plugin->supported = [401, 404];

0 comments on commit 8352c79

Please sign in to comment.