Commit 23ec8f0d authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1720883 - Correctly show earliest date for all institutions



in reports for masquerading / user activity as 'mahara' institution
may not be the first institution to do these activities.

behatnotneeded

Change-Id: Id3bf240346636ba729a91637629db7194c5ff04c
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent dbfa06ba
...@@ -4148,8 +4148,12 @@ function report_earliest_date($subtype, $institution = 'mahara') { ...@@ -4148,8 +4148,12 @@ function report_earliest_date($subtype, $institution = 'mahara') {
// A quick way to find possible earliest dates for things // A quick way to find possible earliest dates for things
// This check accepts the fact that 'mahara' institution must exist first // This check accepts the fact that 'mahara' institution must exist first
// therefore the earliest for 'mahara' must be the earliest for 'all' // therefore the earliest for 'mahara' must be the earliest for 'all' for many of the reports
$institution = ($institution == 'all') ? 'mahara' : $institution; $all = false;
if ($institution == 'all') {
$institution = 'mahara';
$all = true;
}
switch ($subtype) { switch ($subtype) {
case "content": case "content":
$date = get_field_sql("SELECT MIN(i.time) FROM {institution_registration} i WHERE i.institution = ?", array($institution)); $date = get_field_sql("SELECT MIN(i.time) FROM {institution_registration} i WHERE i.institution = ?", array($institution));
...@@ -4176,10 +4180,16 @@ function report_earliest_date($subtype, $institution = 'mahara') { ...@@ -4176,10 +4180,16 @@ function report_earliest_date($subtype, $institution = 'mahara') {
WHERE el.event = 'loginas' AND ui.institution = ?", array($institution)); WHERE el.event = 'loginas' AND ui.institution = ?", array($institution));
} }
else { else {
$date = get_field_sql("SELECT MIN(el.ctime) FROM {event_log} el if ($all) {
WHERE el.event = 'loginas' AND el.usr NOT IN ( $date = get_field_sql("SELECT MIN(el.ctime) FROM {event_log} el
SELECT usr FROM {usr_institution} WHERE el.event = 'loginas'");
)"); }
else {
$date = get_field_sql("SELECT MIN(el.ctime) FROM {event_log} el
WHERE el.event = 'loginas' AND el.usr NOT IN (
SELECT usr FROM {usr_institution}
)");
}
} }
break; break;
case "useractivity": case "useractivity":
...@@ -4189,10 +4199,16 @@ function report_earliest_date($subtype, $institution = 'mahara') { ...@@ -4189,10 +4199,16 @@ function report_earliest_date($subtype, $institution = 'mahara') {
WHERE el.event != 'loginas' AND ui.institution = ?", array($institution)); WHERE el.event != 'loginas' AND ui.institution = ?", array($institution));
} }
else { else {
$date = get_field_sql("SELECT MIN(el.ctime) FROM {event_log} el if ($all) {
WHERE el.event != 'loginas' AND el.usr NOT IN ( $date = get_field_sql("SELECT MIN(el.ctime) FROM {event_log} el
SELECT usr FROM {usr_institution} WHERE el.event != 'loginas'");
)"); }
else {
$date = get_field_sql("SELECT MIN(el.ctime) FROM {event_log} el
WHERE el.event != 'loginas' AND el.usr NOT IN (
SELECT usr FROM {usr_institution}
)");
}
} }
break; break;
case "pageactivity": case "pageactivity":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment