Merge branch 'wip-MDL-20053-master' of git://github.com/abgreeve/moodle

This commit is contained in:
David Monllao 2015-01-20 16:43:24 +08:00
commit 97b2e747ac
5 changed files with 37 additions and 6 deletions

View File

@ -1272,6 +1272,10 @@ function data_print_template($template, $records, $data, $search='', $page=0, $r
$replacement[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$record->userid.
'&amp;course='.$data->course.'">'.fullname($record).'</a>';
$patterns[] = '##userpicture##';
$ruser = user_picture::unalias($record, null, 'userid');
$replacement[] = $OUTPUT->user_picture($ruser, array('courseid' => $data->course));
$patterns[]='##export##';
if (!empty($CFG->enableportfolios) && ($template == 'singletemplate' || $template == 'listtemplate')
@ -3611,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,

View File

@ -276,6 +276,7 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') {
echo '<option value="##timeadded##">'.get_string('timeadded', 'data'). ' - ##timeadded##</option>';
echo '<option value="##timemodified##">'.get_string('timemodified', 'data'). ' - ##timemodified##</option>';
echo '<option value="##user##">' .get_string('user'). ' - ##user##</option>';
echo '<option value="##userpicture##">' . get_string('userpic') . ' - ##userpicture##</option>';
if ($mode != 'singletemplate') {
// more points to single template - not useable there
echo '<option value="##comments##">' .get_string('comments', 'data'). ' - ##comments##</option>';

View File

@ -4,6 +4,7 @@ Feature: Users can add entries to database activities
As a user
I need to add entries to databases
@javascript
Scenario: Students can add entries to a database
Given the following "users" exist:
| username | firstname | lastname | email |
@ -54,3 +55,12 @@ Feature: Users can add entries to database activities
And I should not see "Student edited entry"
And I should see "Student second entry"
And I should see "Student third entry"
# Now I will bulk delete the rest of the entries.
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Test database name"
And I press "Select all"
And I press "Delete selected"
And I press "Delete"
And I should see "No entries in database"

View File

@ -172,6 +172,9 @@ class data_advanced_search_sql_test extends advanced_testcase {
$this->finalrecord[6]->lastnamephonetic = $user->lastnamephonetic;
$this->finalrecord[6]->middlename = $user->middlename;
$this->finalrecord[6]->alternatename = $user->alternatename;
$this->finalrecord[6]->picture = $user->picture;
$this->finalrecord[6]->imagealt = $user->imagealt;
$this->finalrecord[6]->email = $user->email;
}
/**

View File

@ -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)) {