Merge branch 'MDL-49291_master' of git://github.com/markn86/moodle

This commit is contained in:
Andrew Nicols 2016-01-19 08:04:59 +08:00
commit 441ffe514e
4 changed files with 2 additions and 234 deletions

View File

@ -106,38 +106,6 @@ class manager implements \core\log\manager {
if (empty($interface) || ($reader instanceof $interface)) {
$return[$plugin] = $reader;
}
// TODO MDL-49291 These conditions should be removed as part of the 2nd stage deprecation.
if ($reader instanceof \core\log\sql_internal_reader) {
debugging('\core\log\sql_internal_reader has been deprecated in favour of \core\log\sql_internal_table_reader.' .
' Update ' . get_class($reader) . ' to use the new interface.', DEBUG_DEVELOPER);
} else if ($reader instanceof \core\log\sql_select_reader) {
debugging('\core\log\sql_select_reader has been deprecated in favour of \core\log\sql_reader. Update ' .
get_class($reader) . ' to use the new interface.', DEBUG_DEVELOPER);
}
}
// TODO MDL-49291 This section below (until the final return) should be removed as part of the 2nd stage deprecation.
$isselectreader = (ltrim($interface, '\\') === 'core\log\sql_select_reader');
$isinternalreader = (ltrim($interface, '\\') === 'core\log\sql_internal_reader');
if ($isselectreader || $isinternalreader) {
if ($isselectreader) {
$alternative = '\core\log\sql_reader';
} else {
$alternative = '\core\log\sql_internal_table_reader';
}
if (count($return) === 0) {
// If there are no classes implementing the provided interface and the provided interface is one of
// the deprecated ones, we return the non-deprecated alternatives. It should be safe as the new interface
// is adding a new method but not changing the existing ones.
debugging($interface . ' has been deprecated in favour of ' . $alternative . '. Returning ' . $alternative .
' instances instead. Please call get_readers() using the new interface.', DEBUG_DEVELOPER);
$return = $this->get_readers($alternative);
} else {
debugging($interface . ' has been deprecated in favour of ' . $alternative .
'. Please call get_readers() using the new interface.', DEBUG_DEVELOPER);
}
}
return $return;

View File

@ -1,50 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Log storage sql reader interface.
*
* @package core
* @copyright 2014 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\log;
defined('MOODLE_INTERNAL') || die();
/**
* Sql internal reader.
*
* @deprecated since Moodle 2.9 MDL-48595 - please do not use this interface any more.
* @see sql_reader
* @todo MDL-49291 This will be deleted in Moodle 3.1.
* @package core
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface sql_internal_reader extends sql_select_reader {
/**
* Returns name of the table or database view that holds the log data in standardised format.
*
* Note: this table must be used for reading only,
* it is strongly recommended to use this in complex reports only.
*
* @return string
*/
public function get_internal_log_table_name();
}

View File

@ -1,60 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Log storage reader interface.
*
* @package core
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\log;
defined('MOODLE_INTERNAL') || die();
/**
* Sql select reader.
*
* @deprecated since Moodle 2.9 MDL-48595 - please do not use this interface any more.
* @see sql_reader
* @todo MDL-49291 This will be deleted in Moodle 3.1.
* @package core
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface sql_select_reader extends reader {
/**
* Fetch records using given criteria.
*
* @param string $selectwhere
* @param array $params
* @param string $sort
* @param int $limitfrom
* @param int $limitnum
* @return \core\event\base[]
*/
public function get_events_select($selectwhere, array $params, $sort, $limitfrom, $limitnum);
/**
* Return number of events matching given criteria.
*
* @param string $selectwhere
* @param array $params
* @return int
*/
public function get_events_select_count($selectwhere, array $params);
}

View File

@ -36,13 +36,6 @@ class report_log_table_log extends table_sql {
/** @var array list of user fullnames shown in report */
private $userfullnames = array();
/**
* @deprecated since Moodle 2.9 MDL-48595 - please do not use this argument any more.
* @todo MDL-49291 This will be deleted in 3.1
* @var array list of course short names shown in report.
*/
private $courseshortnames = array();
/** @var array list of context name shown in report */
private $contextname = array();
@ -99,19 +92,9 @@ class report_log_table_log extends table_sql {
* Generate the course column.
*
* @deprecated since Moodle 2.9 MDL-48595 - please do not use this function any more.
* @todo MDL-49291 This will be deleted in 3.1
* @param stdClass $event event data.
* @return string HTML for the course column.
*/
public function col_course($event) {
debugging('col_course() is deprecated, there is no such column', DEBUG_DEVELOPER);
if (empty($event->courseid) || empty($this->courseshortnames[$event->courseid])) {
return '-';
} else {
return $this->courseshortnames[$event->courseid];
}
throw new coding_exception('col_course() can not be used any more, there is no such column.');
}
/**
@ -544,82 +527,9 @@ class report_log_table_log extends table_sql {
* which will be used to render logs in table.
*
* @deprecated since Moodle 2.9 MDL-48595 - please do not use this function any more.
* @todo MDL-49291 This will be deleted in 3.1
* @see self::update_users_used()
*/
public function update_users_and_courses_used() {
global $SITE, $DB;
debugging('update_users_and_courses_used() is deprecated, please use update_users_used() instead.', DEBUG_DEVELOPER);
// We should not call self::update_users_used() as would have to iterate twice around the list of logs.
$this->userfullnames = array();
$this->courseshortnames = array($SITE->id => $SITE->shortname);
$userids = array();
$courseids = array();
// For each event cache full username and course.
// Get list of userids and courseids which will be shown in log report.
foreach ($this->rawdata as $event) {
$logextra = $event->get_logextra();
if (!empty($event->userid) && empty($userids[$event->userid])) {
$userids[$event->userid] = $event->userid;
}
if (!empty($logextra['realuserid']) && empty($userids[$logextra['realuserid']])) {
$userids[$logextra['realuserid']] = $logextra['realuserid'];
}
if (!empty($event->relateduserid) && empty($userids[$event->relateduserid])) {
$userids[$event->relateduserid] = $event->relateduserid;
}
if (!empty($event->courseid) && ($event->courseid != $SITE->id) && !in_array($event->courseid, $courseids)) {
$courseids[] = $event->courseid;
}
}
// Closing it just in case, we can not rewind moodle recordsets anyway.
if ($this->rawdata instanceof \core\dml\recordset_walk ||
$this->rawdata instanceof moodle_recordset) {
$this->rawdata->close();
}
// Get user fullname and put that in return list.
if (!empty($userids)) {
list($usql, $uparams) = $DB->get_in_or_equal($userids);
$users = $DB->get_records_sql("SELECT id," . get_all_user_name_fields(true) . " FROM {user} WHERE id " . $usql,
$uparams);
foreach ($users as $userid => $user) {
$this->userfullnames[$userid] = fullname($user);
unset($userids[$userid]);
}
// We fill the array with false values for the users that don't exist anymore
// in the database so we don't need to query the db again later.
foreach ($userids as $userid) {
$this->userfullnames[$userid] = false;
}
}
// Get course shortname and put that in return list.
if (!empty($courseids)) { // If all logs don't belog to site level then get course info.
list($coursesql, $courseparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
$ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
$ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
$courseparams['contextlevel'] = CONTEXT_COURSE;
$sql = "SELECT c.id,c.shortname $ccselect FROM {course} c
$ccjoin
WHERE c.id " . $coursesql;
$courses = $DB->get_records_sql($sql, $courseparams);
foreach ($courses as $courseid => $course) {
$url = new moodle_url("/course/view.php", array('id' => $courseid));
context_helper::preload_from_record($course);
$context = context_course::instance($courseid, IGNORE_MISSING);
// Method format_string() takes care of missing contexts.
$this->courseshortnames[$courseid] = html_writer::link($url, format_string($course->shortname, true,
array('context' => $context)));
}
}
throw new coding_exception('update_users_and_courses_used() can not be used any more, please use update_users_used() instead.');
}
/**