~ubuntu-branches/ubuntu/precise/moodle/precise

« back to all changes in this revision

Viewing changes to debian/patches/MSA-12-0013

  • Committer: Package Import Robot
  • Author(s): Tomasz Muras
  • Date: 2012-04-12 21:55:48 UTC
  • mfrom: (3.1.15 sid)
  • Revision ID: package-import@ubuntu.com-20120412215548-4ztlcbh9f346l0as
Tags: 1.9.9.dfsg2-6
* Backporting security fixes from Moodle 1.9.17
   - MSA-12-00013 DB activtity export does not respect groups
       (CVE-2012-1155, closes: #668411)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
commit 312ada2856cfb79d03ac6effe11dd750f2aa67f0
 
2
Author: Adrian Greeve <adrian@moodle.com>
 
3
Date:   Tue Jan 31 12:09:30 2012 +0800
 
4
 
 
5
    MDL-25185 - data - Allowing data from the database to be exported according to group roles.
 
6
 
 
7
diff --git a/mod/data/export.php b/mod/data/export.php
 
8
index 6ac914e..edea566 100644
 
9
--- a/mod/data/export.php
 
10
+++ b/mod/data/export.php
 
11
@@ -60,6 +60,7 @@ if($mform->is_cancelled()) {
 
12
     print_header_simple($data->name, '', $nav,
 
13
         '', '', true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
 
14
         navmenu($course, $cm), '', '');
 
15
+    groups_print_activity_menu($cm, "$CFG->wwwroot/mod/data/export.php?d=$d");
 
16
     print_heading(format_string($data->name));
 
17
 
 
18
     // these are for the tab display
 
19
@@ -83,13 +84,25 @@ foreach($fields as $key => $field) {
 
20
         $exportdata[0][] = $field->field->name;
 
21
     }
 
22
 }
 
23
+$groupid = groups_get_activity_group($cm);
 
24
 
 
25
 $datarecords = get_records('data_records', 'dataid', $data->id);
 
26
 ksort($datarecords);
 
27
 $line = 1;
 
28
 foreach($datarecords as $record) {
 
29
     // get content indexed by fieldid
 
30
-    if( $content = get_records('data_content', 'recordid', $record->id, 'fieldid', 'fieldid, content, content1, content2, content3, content4') ) {
 
31
+    if($groupid) {
 
32
+        $select = "SELECT c.fieldid, c.content, c.content1, c.content2, c.content3, c.content4 
 
33
+            FROM {$CFG->prefix}data_content c, {$CFG->prefix}data_records r 
 
34
+            WHERE c.recordid = $record->id  
 
35
+            AND r.id = c.recordid 
 
36
+            AND r.groupid = $groupid";
 
37
+    } else {
 
38
+        $select = "SELECT fieldid, content, content1, content2, content3, content4 
 
39
+            FROM {$CFG->prefix}data_content 
 
40
+            WHERE recordid = $record->id";
 
41
+    }
 
42
+    if( $content = get_records_sql($select) ) {
 
43
         foreach($fields as $field) {
 
44
             $contents = '';
 
45
             if(isset($content[$field->field->id])) {