Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]

Date condition.

Copyright: 2014 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 307 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: condition  - X-Ref

Date condition.

__construct($structure)   X-Ref
Constructor.

param: \stdClass $structure Data structure from JSON decode

save()   X-Ref
No description

get_json($direction, $time)   X-Ref
Returns a JSON object which corresponds to a condition of this type.

Intended for unit testing, as normally the JSON values are constructed
by JavaScript code.

param: string $direction DIRECTION_xx constant
param: int $time Time in epoch seconds
return: stdClass Object representing condition

is_available($not, \core_availability\info $info, $grabthelot, $userid)   X-Ref
No description

is_available_for_all($not = false)   X-Ref
No description

get_logical_direction($not)   X-Ref
Obtains the actual direction of checking based on the $not value.

param: bool $not True if condition is negated
return: string Direction constant

get_description($full, $not, \core_availability\info $info)   X-Ref
No description

get_standalone_description($full, $not, \core_availability\info $info)   X-Ref
No description

get_either_description($not, $standalone)   X-Ref
Shows the description using the different lang strings for the standalone
version or the full one.

param: bool $not True if NOT is in force
param: bool $standalone True to use standalone lang strings

get_debug_string()   X-Ref
No description

get_time()   X-Ref
Gets time. This function is implemented here rather than calling time()
so that it can be overridden in unit tests. (Would really be nice if
Moodle had a generic way of doing that, but it doesn't.)

return: int Current time (seconds since epoch)

set_current_time_for_test($forcetime = 0)   X-Ref
Forces the current time for unit tests.

param: int $forcetime Time to return from the get_time function

show_time($time, $dateonly, $until = false)   X-Ref
Shows a time either as a date or a full date and time, according to
user's timezone.

param: int $time Time
param: bool $dateonly If true, uses date only
param: bool $until If true, and if using date only, shows previous date
return: string Date

is_midnight($time)   X-Ref
Checks whether a given time refers exactly to midnight (in current user
timezone).

param: int $time Time
return: bool True if time refers to midnight, false otherwise

update_after_restore($restoreid, $courseid, \base_logger $logger, $name)   X-Ref
No description

update_all_dates($courseid, $timeshift)   X-Ref
Changes all date restrictions on a course by the specified shift amount.
Used by the course reset feature.

param: int $courseid Course id
param: int $timeshift Offset in seconds