芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/admin/tool/log/store/standard/classes/log/store.php
. /** * Standard log reader/writer. * * @package logstore_standard * @copyright 2013 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace logstore_standard\log; defined('MOODLE_INTERNAL') || die(); class store implements \tool_log\log\writer, \core\log\sql_internal_table_reader { use \tool_log\helper\store, \tool_log\helper\buffered_writer, \tool_log\helper\reader; /** @var string $logguests true if logging guest access */ protected $logguests; public function __construct(\tool_log\log\manager $manager) { $this->helper_setup($manager); // Log everything before setting is saved for the first time. $this->logguests = $this->get_config('logguests', 1); // JSON writing defaults to false (table format compatibility with older versions). // Note: This variable is defined in the buffered_writer trait. $this->jsonformat = (bool)$this->get_config('jsonformat', false); } /** * Should the event be ignored (== not logged)? * @param \core\event\base $event * @return bool */ protected function is_event_ignored(\core\event\base $event) { if ((!CLI_SCRIPT or PHPUNIT_TEST) and !$this->logguests) { // Always log inside CLI scripts because we do not login there. if (!isloggedin() or isguestuser()) { return true; } } return false; } /** * Finally store the events into the database. * * @param array $evententries raw event data */ protected function insert_event_entries($evententries) { global $DB; $DB->insert_records('logstore_standard_log', $evententries); } public function get_events_select($selectwhere, array $params, $sort, $limitfrom, $limitnum) { global $DB; $sort = self::tweak_sort_by_id($sort); $events = array(); $records = $DB->get_recordset_select('logstore_standard_log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum); foreach ($records as $data) { if ($event = $this->get_log_event($data)) { $events[$data->id] = $event; } } $records->close(); return $events; } /** * Fetch records using given criteria returning a Traversable object. * * Note that the traversable object contains a moodle_recordset, so * remember that is important that you call close() once you finish * using it. * * @param string $selectwhere * @param array $params * @param string $sort * @param int $limitfrom * @param int $limitnum * @return \core\dml\recordset_walk|\core\event\base[] */ public function get_events_select_iterator($selectwhere, array $params, $sort, $limitfrom, $limitnum) { global $DB; $sort = self::tweak_sort_by_id($sort); $recordset = $DB->get_recordset_select('logstore_standard_log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum); return new \core\dml\recordset_walk($recordset, array($this, 'get_log_event')); } /** * Returns an event from the log data. * * @param stdClass $data Log data * @return \core\event\base */ public function get_log_event($data) { $extra = array('origin' => $data->origin, 'ip' => $data->ip, 'realuserid' => $data->realuserid); $data = (array)$data; $id = $data['id']; $data['other'] = self::decode_other($data['other']); if ($data['other'] === false) { $data['other'] = array(); } unset($data['origin']); unset($data['ip']); unset($data['realuserid']); unset($data['id']); if (!$event = \core\event\base::restore($data, $extra)) { return null; } return $event; } public function get_events_select_count($selectwhere, array $params) { global $DB; return $DB->count_records_select('logstore_standard_log', $selectwhere, $params); } public function get_internal_log_table_name() { return 'logstore_standard_log'; } /** * Are the new events appearing in the reader? * * @return bool true means new log events are being added, false means no new data will be added */ public function is_logging() { // Only enabled stpres are queried, // this means we can return true here unless store has some extra switch. return true; } }