mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-20053 mod_data: Removal of individual DB call.
The main functions for retrieving records have been updated to include user picture information.
This commit is contained in:
parent
560237b4b3
commit
c910cf308c
@ -1273,8 +1273,8 @@ function data_print_template($template, $records, $data, $search='', $page=0, $r
|
||||
'&course='.$data->course.'">'.fullname($record).'</a>';
|
||||
|
||||
$patterns[] = '##userpicture##';
|
||||
$ruser = $DB->get_record('user', array('id' => $record->userid));
|
||||
$replacement[] = $OUTPUT->user_picture($ruser, array('courseid' => $cm->id));
|
||||
$ruser = user_picture::unalias($record, null, 'userid');
|
||||
$replacement[] = $OUTPUT->user_picture($ruser, array('courseid' => $data->course));
|
||||
|
||||
$patterns[]='##export##';
|
||||
|
||||
@ -3615,7 +3615,10 @@ function data_get_recordids($alias, $searcharray, $dataid, $recordids) {
|
||||
function data_get_advanced_search_sql($sort, $data, $recordids, $selectdata, $sortorder) {
|
||||
global $DB;
|
||||
|
||||
$namefields = get_all_user_name_fields(true, 'u');
|
||||
$namefields = user_picture::fields('u');
|
||||
// Remove the id from the string. This already exists in the sql statement.
|
||||
$namefields = str_replace('u.id,', '', $namefields);
|
||||
|
||||
if ($sort == 0) {
|
||||
$nestselectsql = 'SELECT r.id, r.approved, r.timecreated, r.timemodified, r.userid, ' . $namefields . '
|
||||
FROM {data_content} c,
|
||||
|
@ -379,7 +379,9 @@
|
||||
echo $OUTPUT->notification(get_string('recorddeleted','data'), 'notifysuccess');
|
||||
}
|
||||
} else { // Print a confirmation page
|
||||
$allnamefields = get_all_user_name_fields(true, 'u');
|
||||
$allnamefields = user_picture::fields('u');
|
||||
// Remove the id from the string. This already exists in the sql statement.
|
||||
$allnamefields = str_replace('u.id,', '', $allnamefields);
|
||||
$dbparams = array($delete);
|
||||
if ($deleterecord = $DB->get_record_sql("SELECT dr.*, $allnamefields
|
||||
FROM {data_records} dr
|
||||
@ -415,14 +417,20 @@
|
||||
$validrecords = array();
|
||||
$recordids = array();
|
||||
foreach ($multidelete as $value) {
|
||||
if ($deleterecord = $DB->get_record('data_records', array('id'=>$value))) { // Need to check this is valid
|
||||
if ($deleterecord->dataid == $data->id) { // Must be from this database
|
||||
$allnamefields = user_picture::fields('u');
|
||||
// Remove the id from the string. This already exists in the sql statement.
|
||||
$allnamefields = str_replace('u.id,', '', $allnamefields);
|
||||
$dbparams = array('id' => $value);
|
||||
if ($deleterecord = $DB->get_record_sql("SELECT dr.*, $allnamefields
|
||||
FROM {data_records} dr
|
||||
JOIN {user} u ON dr.userid = u.id
|
||||
WHERE dr.id = ?", $dbparams)) { // Need to check this is valid.
|
||||
if ($deleterecord->dataid == $data->id) { // Must be from this database.
|
||||
$validrecords[] = $deleterecord;
|
||||
$recordids[] = $deleterecord->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$serialiseddata = json_encode($recordids);
|
||||
$submitactions = array('d' => $data->id, 'sesskey' => sesskey(), 'confirm' => '1', 'serialdelete' => $serialiseddata);
|
||||
$action = new moodle_url('/mod/data/view.php', $submitactions);
|
||||
@ -542,7 +550,9 @@ if ($showactivity) {
|
||||
$advparams = array();
|
||||
// This is used for the initial reduction of advanced search results with required entries.
|
||||
$entrysql = '';
|
||||
$namefields = get_all_user_name_fields(true, 'u');
|
||||
$namefields = user_picture::fields('u');
|
||||
// Remove the id from the string. This already exists in the sql statement.
|
||||
$namefields = str_replace('u.id,', '', $namefields);
|
||||
|
||||
/// Find the field we are sorting on
|
||||
if ($sort <= 0 or !$sortfield = data_get_field_from_id($sort, $data)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user