Skip to content

Commit

Permalink
Add data source for Dash calendar events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithyanandan committed Sep 25, 2024
1 parent 55057b3 commit 1e00f35
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 4 deletions.
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.
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 = 2024050802; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024050803; // 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;
Expand Down

0 comments on commit 1e00f35

Please sign in to comment.