Coding standards
Security in ResourceSpace
Developer reference
Database
Mcp browse functions
Mcp report functions

mcp_event_dates()

Description

Validate inclusive event dates and return a parameterised restriction on the log event date.

Parameters

ColumnTypeDefaultDescription
$args: array
as $to]

Location

include/mcp_report_functions.php lines 6 to 20

Definition

 
function mcp_event_dates(array $args): PreparedStatementQuery
{
    require_once 
__DIR__ . '/log_functions.php';
    
$from = $args['date_from'] ?? '';
    
$to = $args['date_to'] ?? '';
    foreach ([
$from, $to] as $date) {
        if (
$date !== '' && (!preg_match('/^\d{4}-\d{2}-\d{2}$/D', $date) || !validateDatetime($date, 'Y-m-d'))) {
            throw new 
DomainException('Use YYYY-MM-DD for event dates.');
        }
    }
    if (
$from !== '' && $to !== '' && $from > $to) {
        throw new 
DomainException('The end date precedes the start date.');
    }
    return 
log_date_condition('r.date', ['from' => $from, 'to' => $to]);
}

This article was last updated 3rd December 2026 16:35 Europe/London time based on the source file dated 3rd December 2026 16:30 Europe/London time.