. declare(strict_types=1); namespace core_reportbuilder\local\models; use context; use context_system; use core\persistent; use core_reportbuilder\local\report\base; /** * Persistent class to represent a report * * @package core_reportbuilder * @copyright 2018 Alberto Lara Hernández * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class report extends persistent { /** @var string The table name. */ public const TABLE = 'reportbuilder_report'; /** * Return the definition of the properties of this model * * @return array */ protected static function define_properties(): array { return [ 'source' => [ 'type' => PARAM_RAW, ], 'type' => [ 'type' => PARAM_INT, 'choices' => [ base::TYPE_CUSTOM_REPORT, base::TYPE_SYSTEM_REPORT, ], ], 'contextid' => [ 'type' => PARAM_INT, 'default' => static function(): int { return context_system::instance()->id; } ], 'component' => [ 'type' => PARAM_COMPONENT, 'default' => '', ], 'area' => [ 'type' => PARAM_AREA, 'default' => '', ], 'itemid' => [ 'type' => PARAM_INT, 'default' => 0, ], 'usercreated' => [ 'type' => PARAM_INT, 'default' => static function(): int { global $USER; return (int) $USER->id; }, ], ]; } /** * Return report context, used by exporters * * @return context */ public function get_context(): context { return context::instance_by_id($this->raw_get('contextid')); } }