Passed
Push — 1.10.x ( 55c17b...cec016 )
by Angel Fernando Quiroz
249:43 queued 200:32
created
main/reports/multiquery.lib.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -2,62 +2,62 @@
 block discarded – undo
2 2
 
3 3
 // get fields informations
4 4
 function multiquery_query($array) {
5
-	$result = array();
6
-	$field = 0;
7
-	for ($i = 0; $i <sizeof($array); $i++) {
8
-		// mysql handler
9
-		$result[$i]['mysql'] = mysql_query($array[$i]);
10
-
11
-		if (! $result[$i]['mysql'])
12
-			die("error in query $i : ".$array[$i]);
13
-
14
-		// fields
15
-		$result[$i]['num_fields'] = mysql_num_fields($result[$i]['mysql']);
16
-		for ($j = 0; $j < $result[$i]['num_fields']; $j++) {
17
-			$name = mysql_field_name($result[$i]['mysql'], $j);
18
-			$result['field'][$field]['query']=$i;
19
-			$result['field'][$field]['name']=$name;
20
-			$result['field'][$field]['id']=$j;
21
-			$result['field_assoc'][$name][$field];
22
-			$field++;
23
-		}
24
-	}
25
-	$result['num_queries'] = sizeof($array);
26
-	// rows
27
-	$numberOfResult = mysql_num_rows($result[0]['mysql']);
28
-	for ($i = 1; $i <$result['num_queries']; $i++) 
29
-		if ($numberOfResult != mysql_num_rows($result[$i]['mysql']))
30
-			die("wrong number of row: $numberOfResult vs ".
31
-				mysql_num_rows($result[$i]['mysql'])." on query $i");
32
-
33
-	$result['num_rows'] = $numberOfResult;
34
-	$result['num_fields'] = $field;
35
-
36
-	return $result;
5
+    $result = array();
6
+    $field = 0;
7
+    for ($i = 0; $i <sizeof($array); $i++) {
8
+        // mysql handler
9
+        $result[$i]['mysql'] = mysql_query($array[$i]);
10
+
11
+        if (! $result[$i]['mysql'])
12
+            die("error in query $i : ".$array[$i]);
13
+
14
+        // fields
15
+        $result[$i]['num_fields'] = mysql_num_fields($result[$i]['mysql']);
16
+        for ($j = 0; $j < $result[$i]['num_fields']; $j++) {
17
+            $name = mysql_field_name($result[$i]['mysql'], $j);
18
+            $result['field'][$field]['query']=$i;
19
+            $result['field'][$field]['name']=$name;
20
+            $result['field'][$field]['id']=$j;
21
+            $result['field_assoc'][$name][$field];
22
+            $field++;
23
+        }
24
+    }
25
+    $result['num_queries'] = sizeof($array);
26
+    // rows
27
+    $numberOfResult = mysql_num_rows($result[0]['mysql']);
28
+    for ($i = 1; $i <$result['num_queries']; $i++) 
29
+        if ($numberOfResult != mysql_num_rows($result[$i]['mysql']))
30
+            die("wrong number of row: $numberOfResult vs ".
31
+                mysql_num_rows($result[$i]['mysql'])." on query $i");
32
+
33
+    $result['num_rows'] = $numberOfResult;
34
+    $result['num_fields'] = $field;
35
+
36
+    return $result;
37 37
 }
38 38
 
39 39
 function multiquery_num_rows(&$mq_h) {
40
-	return $mq_h['num_rows'];
40
+    return $mq_h['num_rows'];
41 41
 }
42 42
 
43 43
 function multiquery_num_fields(&$mq_h) {
44
-	return $mq_h['num_fields'];
44
+    return $mq_h['num_fields'];
45 45
 }
46 46
 
47 47
 function multiquery_field_name(&$mq_h, $id) {
48
-	return $mq_h['field'][$id]['name'];
48
+    return $mq_h['field'][$id]['name'];
49 49
 }
50 50
 
51 51
 function multiquery_fetch_row(&$mq_h) {
52
-	$result = array();
53
-	$pos = 0;
54
-	for ($i = 0; $i < $mq_h['num_queries']; $i++) {
55
-		$row = mysql_fetch_row($mq_h[$i]['mysql']);
56
-		if (!$row) return false; // last line
57
-		for ($j = 0; $j < sizeof($row); $j++) {
58
-			$result[$pos] = $row[$j];
59
-			$pos++;
60
-		}
61
-	}
62
-	return $result;
52
+    $result = array();
53
+    $pos = 0;
54
+    for ($i = 0; $i < $mq_h['num_queries']; $i++) {
55
+        $row = mysql_fetch_row($mq_h[$i]['mysql']);
56
+        if (!$row) return false; // last line
57
+        for ($j = 0; $j < sizeof($row); $j++) {
58
+            $result[$pos] = $row[$j];
59
+            $pos++;
60
+        }
61
+    }
62
+    return $result;
63 63
 }
Please login to merge, or discard this patch.
main/reports/modules/quiz.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@
 block discarded – undo
7 7
 }
8 8
 
9 9
 function reports_modules_quiz_init_forEachCourses($course_code, $course_id, $course_db) {
10
-	global $reports_modules;
10
+    global $reports_modules;
11 11
 	
12
-	$reports_modules_quiz_toolid = reports_getToolId(TOOL_QUIZ);
12
+    $reports_modules_quiz_toolid = reports_getToolId(TOOL_QUIZ);
13 13
 
14
-	array_push($reports_modules['quiz'], 
15
-	  array('keys_query' =>  
16
-		'select '.$course_id.' as course_id, '.
17
-		$reports_modules_quiz_toolid.' as tool_id, '.
18
-		'q.id as child_id, q.title as child_name, '.
19
-		"'".$course_code."'".' as course_code from '.Database::get_course_table(TABLE_QUIZ_TEST).' q ',
20
-		'values_query_function' => 'reports_modules_quiz_quizVal'));		
14
+    array_push($reports_modules['quiz'], 
15
+        array('keys_query' =>  
16
+        'select '.$course_id.' as course_id, '.
17
+        $reports_modules_quiz_toolid.' as tool_id, '.
18
+        'q.id as child_id, q.title as child_name, '.
19
+        "'".$course_code."'".' as course_code from '.Database::get_course_table(TABLE_QUIZ_TEST).' q ',
20
+        'values_query_function' => 'reports_modules_quiz_quizVal'));		
21 21
 }
22 22
 
23 23
 function reports_modules_quiz_quizVal($quiz, $key_id) {
24
-	$courseId = api_get_course_int_id($quiz['course_code']);
25
-	return array('type'=> 'sql', 'sql' => 
26
-			'select '.$key_id.', exe_user_id as uid, '.
27
-			'session_id, -1 as attempt, exe_result as score, '.
28
-			REPORTS_PROGRESS_COMPLETED.' as progress, '.
29
-			'exe_duration as time, exe_date as ts from '.
30
-			Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).
31
-			' where c_id = ' . $courseId .
32
-			' and exe_exo_id='.$quiz['child_id']);
24
+    $courseId = api_get_course_int_id($quiz['course_code']);
25
+    return array('type'=> 'sql', 'sql' => 
26
+            'select '.$key_id.', exe_user_id as uid, '.
27
+            'session_id, -1 as attempt, exe_result as score, '.
28
+            REPORTS_PROGRESS_COMPLETED.' as progress, '.
29
+            'exe_duration as time, exe_date as ts from '.
30
+            Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).
31
+            ' where c_id = ' . $courseId .
32
+            ' and exe_exo_id='.$quiz['child_id']);
33 33
 }
Please login to merge, or discard this patch.
main/reports/modules/scorm.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -7,117 +7,117 @@
 block discarded – undo
7 7
 }
8 8
 
9 9
 function reports_modules_scorm_init_forEachCourses($course_code, $course_id, $course_db) {
10
-	global $reports_modules;
10
+    global $reports_modules;
11 11
 	
12
-	$reports_modules_scorm_toolid = reports_getToolId(TOOL_LEARNPATH);
12
+    $reports_modules_scorm_toolid = reports_getToolId(TOOL_LEARNPATH);
13 13
 
14
-	// package level
15
-	array_push($reports_modules['scorm'], 
16
-	  array('keys_query' =>  
17
-		'select '.$course_id.' as course_id, '.
18
-		$reports_modules_scorm_toolid.' as tool_id, '.
19
-		'lp.id as child_id, lp.name as child_name, '.
20
-		"'".$course_db."'".' as course_db from '.
21
-		Database::get_course_table(TABLE_LP_MAIN).' lp',
22
-		'values_query_function' => 'reports_modules_scorm_packageVal'));		
14
+    // package level
15
+    array_push($reports_modules['scorm'], 
16
+        array('keys_query' =>  
17
+        'select '.$course_id.' as course_id, '.
18
+        $reports_modules_scorm_toolid.' as tool_id, '.
19
+        'lp.id as child_id, lp.name as child_name, '.
20
+        "'".$course_db."'".' as course_db from '.
21
+        Database::get_course_table(TABLE_LP_MAIN).' lp',
22
+        'values_query_function' => 'reports_modules_scorm_packageVal'));		
23 23
 
24
-	// sco level
25
-	array_push($reports_modules['scorm'], 
26
-	  array('keys_query' =>  
27
-		'select '.$course_id.' as course_id, '.
28
-		$reports_modules_scorm_toolid.' as tool_id, '.
29
-		'lp.id as child_id, lp.name as child_name, '.
30
-		'lpi.id as subchild_id, lpi.title as subchild_name, '.
31
-		"'".$course_db."'".' as course_db from '.
32
-		Database::get_course_table(TABLE_LP_MAIN, $course_db).
33
-		' lp,'.
34
-		Database::get_course_table(TABLE_LP_ITEM, $course_db).
35
-		' lpi where lp.id = lpi.lp_id',
36
-		'values_query_function' => 'reports_modules_scorm_scoVal'));		
24
+    // sco level
25
+    array_push($reports_modules['scorm'], 
26
+        array('keys_query' =>  
27
+        'select '.$course_id.' as course_id, '.
28
+        $reports_modules_scorm_toolid.' as tool_id, '.
29
+        'lp.id as child_id, lp.name as child_name, '.
30
+        'lpi.id as subchild_id, lpi.title as subchild_name, '.
31
+        "'".$course_db."'".' as course_db from '.
32
+        Database::get_course_table(TABLE_LP_MAIN, $course_db).
33
+        ' lp,'.
34
+        Database::get_course_table(TABLE_LP_ITEM, $course_db).
35
+        ' lpi where lp.id = lpi.lp_id',
36
+        'values_query_function' => 'reports_modules_scorm_scoVal'));		
37 37
 
38
-	// objectives level
39
-	array_push($reports_modules['scorm'], 
40
-	  array('keys_query' =>  
41
-		'select distinct '.$course_id.' as course_id, '.
42
-		$reports_modules_scorm_toolid.' as tool_id, '.
43
-		'lp.id as child_id, lp.name as child_name, '.
44
-		'lpi.id as subchild_id, '.
45
-		'lpi.title as subchild_name, '.
46
-		'null as subsubchild_id, '.
47
-		'lpivo.objective_id as subsubchild_name, '.
48
-		"'".$course_db."'".' as course_db from '.
49
-		Database::get_course_table(TABLE_LP_MAIN, $course_db).
50
-		' lp,'.
51
-		Database::get_course_table(TABLE_LP_ITEM, $course_db).
52
-		' lpi, '.
53
-		Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_db).
54
-		' lpiv, '.
55
-		Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $course_db).
56
-		' lpivo '.
57
-		'where lp.id = lpi.lp_id '.
58
-		'and lpi.id = lpiv.lp_item_id '.
59
-		'and lpiv.id = lpivo.lp_iv_id ',
60
-		'values_query_function' => 'reports_modules_scorm_objVal'));		
38
+    // objectives level
39
+    array_push($reports_modules['scorm'], 
40
+        array('keys_query' =>  
41
+        'select distinct '.$course_id.' as course_id, '.
42
+        $reports_modules_scorm_toolid.' as tool_id, '.
43
+        'lp.id as child_id, lp.name as child_name, '.
44
+        'lpi.id as subchild_id, '.
45
+        'lpi.title as subchild_name, '.
46
+        'null as subsubchild_id, '.
47
+        'lpivo.objective_id as subsubchild_name, '.
48
+        "'".$course_db."'".' as course_db from '.
49
+        Database::get_course_table(TABLE_LP_MAIN, $course_db).
50
+        ' lp,'.
51
+        Database::get_course_table(TABLE_LP_ITEM, $course_db).
52
+        ' lpi, '.
53
+        Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_db).
54
+        ' lpiv, '.
55
+        Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $course_db).
56
+        ' lpivo '.
57
+        'where lp.id = lpi.lp_id '.
58
+        'and lpi.id = lpiv.lp_item_id '.
59
+        'and lpiv.id = lpivo.lp_iv_id ',
60
+        'values_query_function' => 'reports_modules_scorm_objVal'));		
61 61
 }
62 62
 
63 63
 function reports_modules_scorm_packageVal($scorm, $key_id) {
64
-	return array('type'=> 'sql', 'sql' => 
65
-			'select '.$key_id.', user_id as uid, '.
66
-			'session_id, view_count as attempt, null as score, '.
67
-			'progress as progress, '.
68
-			'null as time, null as ts from '.
69
-			Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
70
-			' where lp_id = '.$scorm['child_id']);
64
+    return array('type'=> 'sql', 'sql' => 
65
+            'select '.$key_id.', user_id as uid, '.
66
+            'session_id, view_count as attempt, null as score, '.
67
+            'progress as progress, '.
68
+            'null as time, null as ts from '.
69
+            Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
70
+            ' where lp_id = '.$scorm['child_id']);
71 71
 }
72 72
 
73 73
 function reports_modules_scorm_scoVal($scorm, $key_id) {
74
-	return array('type'=> 'sql', 'sql' => 
75
-			'select '.$key_id.', lpv.user_id as uid, '.
76
-			'lpv.session_id, lpiv.view_count as attempt, '.
77
-			'lpiv.score as score, '.
78
-			'(case lpiv.status '.
79
-				'when "incomplete" then 0 '.
80
-				'when "completed" then 1 '.
81
-				'when "passed" then 2 '.
82
-				'when "failed" then 3 '.
83
-				'when "browsed" then 4 '.
84
-				'when "not attempted" then 5 '.
85
-				'else 6 '.
86
-			'end) as progress, '.
87
-			'lpiv.total_time as time, null as ts from '.
88
-			Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
89
-			' lpv, '.
90
-			Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']).
91
-			' lpiv '.
92
-			' where lpv.lp_id = '.$scorm['child_id'].
93
-			' and lpiv.lp_item_id = '.$scorm['subchild_id'].
94
-			' and lpiv.lp_view_id = lpv.id');
74
+    return array('type'=> 'sql', 'sql' => 
75
+            'select '.$key_id.', lpv.user_id as uid, '.
76
+            'lpv.session_id, lpiv.view_count as attempt, '.
77
+            'lpiv.score as score, '.
78
+            '(case lpiv.status '.
79
+                'when "incomplete" then 0 '.
80
+                'when "completed" then 1 '.
81
+                'when "passed" then 2 '.
82
+                'when "failed" then 3 '.
83
+                'when "browsed" then 4 '.
84
+                'when "not attempted" then 5 '.
85
+                'else 6 '.
86
+            'end) as progress, '.
87
+            'lpiv.total_time as time, null as ts from '.
88
+            Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
89
+            ' lpv, '.
90
+            Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']).
91
+            ' lpiv '.
92
+            ' where lpv.lp_id = '.$scorm['child_id'].
93
+            ' and lpiv.lp_item_id = '.$scorm['subchild_id'].
94
+            ' and lpiv.lp_view_id = lpv.id');
95 95
 }
96 96
 
97 97
 function reports_modules_scorm_objVal($scorm, $key_id) {
98
-	return array('type'=> 'sql', 'sql' => 
99
-			'select '.$key_id.', lpv.user_id as uid, '.
100
-			'lpv.session_id, lpiv.view_count as attempt, '.
101
-			'lpivo.score_raw as score, '.
102
-			'(case lpivo.status '.
103
-				'when "incomplete" then 0 '.
104
-				'when "completed" then 1 '.
105
-				'when "passed" then 2 '.
106
-				'when "failed" then 3 '.
107
-				'when "browsed" then 4 '.
108
-				'when "not attempted" then 5 '.
109
-				'else 6 '.
110
-			'end) as progress, '.
111
-			'null as time, null as ts from '.
112
-			Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
113
-			' lpv, '.
114
-			Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']).
115
-			' lpiv, '.
116
-			Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $scorm['course_db']).
117
-			' lpivo '.
118
-			' where lpv.lp_id = '.$scorm['child_id'].
119
-			' and lpiv.lp_item_id = '.$scorm['subchild_id'].
120
-			' and lpivo.objective_id = "'.$scorm['subsubchild_name'].'" '.
121
-			' and lpiv.lp_view_id = lpv.id'.
122
-			' and lpivo.lp_iv_id=lpiv.id');
98
+    return array('type'=> 'sql', 'sql' => 
99
+            'select '.$key_id.', lpv.user_id as uid, '.
100
+            'lpv.session_id, lpiv.view_count as attempt, '.
101
+            'lpivo.score_raw as score, '.
102
+            '(case lpivo.status '.
103
+                'when "incomplete" then 0 '.
104
+                'when "completed" then 1 '.
105
+                'when "passed" then 2 '.
106
+                'when "failed" then 3 '.
107
+                'when "browsed" then 4 '.
108
+                'when "not attempted" then 5 '.
109
+                'else 6 '.
110
+            'end) as progress, '.
111
+            'null as time, null as ts from '.
112
+            Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
113
+            ' lpv, '.
114
+            Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']).
115
+            ' lpiv, '.
116
+            Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $scorm['course_db']).
117
+            ' lpivo '.
118
+            ' where lpv.lp_id = '.$scorm['child_id'].
119
+            ' and lpiv.lp_item_id = '.$scorm['subchild_id'].
120
+            ' and lpivo.objective_id = "'.$scorm['subsubchild_name'].'" '.
121
+            ' and lpiv.lp_view_id = lpv.id'.
122
+            ' and lpivo.lp_iv_id=lpiv.id');
123 123
 }
Please login to merge, or discard this patch.
main/reports/modules/course.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@
 block discarded – undo
7 7
 }
8 8
 
9 9
 function reports_modules_course_init_forEachCourses($course_code, $course_id, $course_db) {
10
-	global $reports_modules;
10
+    global $reports_modules;
11 11
 
12 12
 //	$reports_modules_course_toolid = reports_getToolId(TOOL_QUIZ);
13 13
 
14
-	array_push($reports_modules['course'],
15
-	  array('keys_query' =>
16
-		'select '.$course_id.' as course_id, "'.$course_code.'" as course_code',
17
-		'values_query_function' => 'reports_modules_course_val'));
14
+    array_push($reports_modules['course'],
15
+        array('keys_query' =>
16
+        'select '.$course_id.' as course_id, "'.$course_code.'" as course_code',
17
+        'values_query_function' => 'reports_modules_course_val'));
18 18
 }
19 19
 
20 20
 function reports_modules_course_val($course, $key_id) {
21
-	return array('type'=> 'sql', 'sql' =>
22
-			'select '.$key_id.', user_id as uid, '.
23
-			'-1 as session_id, -1 as attempt, null as score, '.
24
-			'NULL as progress, '.
25
-			'(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '.
26
-			Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS).
27
-			' where c_id = ' . $course['real_id'] .
28
-			' group by user_id');
21
+    return array('type'=> 'sql', 'sql' =>
22
+            'select '.$key_id.', user_id as uid, '.
23
+            '-1 as session_id, -1 as attempt, null as score, '.
24
+            'NULL as progress, '.
25
+            '(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '.
26
+            Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS).
27
+            ' where c_id = ' . $course['real_id'] .
28
+            ' group by user_id');
29 29
 }
Please login to merge, or discard this patch.
main/reports/templates/courseArticulate.reports.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $reports_template['CourseArticulate'] = array(
4
-	'description' => 'CourseArticulate',
5
-	'getSQL' => 'reports_template_CourseArticulate_getSQL',
6
-	'wizard' =>
4
+    'description' => 'CourseArticulate',
5
+    'getSQL' => 'reports_template_CourseArticulate_getSQL',
6
+    'wizard' =>
7 7
 '
8 8
 <span id="CourseArticulate" class="step">
9 9
 	<span class="font_normal_07em_black">This report does not need any particular settings</span><br />
@@ -12,113 +12,113 @@  discard block
 block discarded – undo
12 12
 ');
13 13
 
14 14
 function reports_template_CourseArticulate_getSQL() {
15
-	// settings
15
+    // settings
16 16
 
17 17
 
18
-	// Nom, prenom
19
-	$query = 'select u.lastname as "Last name", u.firstname as "First name" ';
20
-	$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
21
-	$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
22
-	$query .= ' order by u.user_id ';
23
-	$queries[0] = $query;
24
-	$extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE;
25
-	// Custom Field
26
-	foreach (array("tags" => "tags") as $k => $v) { // FIXME
27
-		$query = 'select ufv.value  as "'.$v.'" ';
28
-		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
29
-		$query .= 'left join'.Database::get_main_table(TABLE_EXTRA_FIELD).' uf ';
30
-		$query .= ' on uf.variable ="'.$k.'" ';
31
-		$query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv ';
32
-		$query .= ' on ufv.item_id = u.user_id and ufv.field_id = uf.id ';
33
-		$query .= 'where ufv.extra_field_type = '.$extraFieldType.' AND u.user_id in ('.reports_getVisibilitySQL().') ';
34
-		$query .= ' order by u.user_id ';
35
-		$queries[] = $query;
36
-	}
18
+    // Nom, prenom
19
+    $query = 'select u.lastname as "Last name", u.firstname as "First name" ';
20
+    $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
21
+    $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
22
+    $query .= ' order by u.user_id ';
23
+    $queries[0] = $query;
24
+    $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE;
25
+    // Custom Field
26
+    foreach (array("tags" => "tags") as $k => $v) { // FIXME
27
+        $query = 'select ufv.value  as "'.$v.'" ';
28
+        $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
29
+        $query .= 'left join'.Database::get_main_table(TABLE_EXTRA_FIELD).' uf ';
30
+        $query .= ' on uf.variable ="'.$k.'" ';
31
+        $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv ';
32
+        $query .= ' on ufv.item_id = u.user_id and ufv.field_id = uf.id ';
33
+        $query .= 'where ufv.extra_field_type = '.$extraFieldType.' AND u.user_id in ('.reports_getVisibilitySQL().') ';
34
+        $query .= ' order by u.user_id ';
35
+        $queries[] = $query;
36
+    }
37 37
 
38 38
 
39
-	// Stored Value
40
-	$sv = array();
41
-	foreach ($sv as $k => $v) {
39
+    // Stored Value
40
+    $sv = array();
41
+    foreach ($sv as $k => $v) {
42 42
         if (!isset($v['sql']))
43 43
                 $v['sql'] = 'FIELD';
44 44
         $sqlField = str_replace('FIELD', 'sv.sv_value', $v['sql']);
45 45
         $query = 'select '.$sqlField.' as "'.$v['title'].'" ';
46 46
 //		$query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
47
-		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
48
-		$query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv ';
49
-		$query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
50
-		$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
51
-		$query .= ' group by u.user_id ';
52
-		$query .= ' order by u.user_id ';
53
-		$queries[] = $query;
54
-	}
47
+        $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
48
+        $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv ';
49
+        $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
50
+        $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
51
+        $query .= ' group by u.user_id ';
52
+        $query .= ' order by u.user_id ';
53
+        $queries[] = $query;
54
+    }
55 55
 
56
-	// first and last connection
57
-	$query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection"  ';
58
-	$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
59
-	$query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
60
-	$query .= ' on tel.login_user_id = u.user_id ';
61
-	$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
62
-	$query .= ' group by u.user_id ';
63
-	$query .= ' order by u.user_id ';
64
-	$queries[] = $query;
56
+    // first and last connection
57
+    $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection"  ';
58
+    $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
59
+    $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
60
+    $query .= ' on tel.login_user_id = u.user_id ';
61
+    $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
62
+    $query .= ' group by u.user_id ';
63
+    $query .= ' order by u.user_id ';
64
+    $queries[] = $query;
65 65
 
66
-	// SCORM Data
67
-	$scormData = array();
66
+    // SCORM Data
67
+    $scormData = array();
68 68
     $course_list = CourseManager::get_courses_list();
69
-	foreach ($course_list as $code => $details) {
70
-		$courseId = $details['id'];
71
-		$list = Database::query('SELECT l.id as lid, l.name as lname, li.id as liid, li.title as lititle '.
72
-					' FROM '.Database::get_course_table(TABLE_LP_MAIN).' l, '.Database::get_course_table(TABLE_LP_ITEM).' li '.
73
-					' WHERE l.c_id = '.$courseId.' AND li.c_id = '.$courseId.' AND l.id = li.lp_id');
74
-		while ($lpItem = Database::fetch_assoc($list)) {
75
-			$scormData[] = array(
76
-						//'coursedb' => $details['db_name'],
77
-						'lid' => $lpItem['lid'],
78
-						'liid' => $lpItem['liid'],
79
-						'target_view_count' => 1,
80
-						'target_indicator' => 'score',
81
-						'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score',
82
-						'sql' => 'FIELD');
83
-			$scormData[] = array(
84
-						//'coursedb' => $details['db_name'],
85
-						'lid' => $lpItem['lid'],
86
-						'liid' => $lpItem['liid'],
87
-						'target_view_count' => 2,
88
-						'target_indicator' => 'score',
89
-						'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score',
90
-						'sql' => 'FIELD');
91
-			$scormData[] = array(
92
-						//'coursedb' => $details['db_name'],
93
-						'lid' => $lpItem['lid'],
94
-						'liid' => $lpItem['liid'],
95
-						'target_view_count' => null,
96
-						'target_indicator' => 'score',
97
-						'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/all/score',
98
-						'sql' => 'avg(FIELD)');
99
-		}
100
-	}
69
+    foreach ($course_list as $code => $details) {
70
+        $courseId = $details['id'];
71
+        $list = Database::query('SELECT l.id as lid, l.name as lname, li.id as liid, li.title as lititle '.
72
+                    ' FROM '.Database::get_course_table(TABLE_LP_MAIN).' l, '.Database::get_course_table(TABLE_LP_ITEM).' li '.
73
+                    ' WHERE l.c_id = '.$courseId.' AND li.c_id = '.$courseId.' AND l.id = li.lp_id');
74
+        while ($lpItem = Database::fetch_assoc($list)) {
75
+            $scormData[] = array(
76
+                        //'coursedb' => $details['db_name'],
77
+                        'lid' => $lpItem['lid'],
78
+                        'liid' => $lpItem['liid'],
79
+                        'target_view_count' => 1,
80
+                        'target_indicator' => 'score',
81
+                        'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score',
82
+                        'sql' => 'FIELD');
83
+            $scormData[] = array(
84
+                        //'coursedb' => $details['db_name'],
85
+                        'lid' => $lpItem['lid'],
86
+                        'liid' => $lpItem['liid'],
87
+                        'target_view_count' => 2,
88
+                        'target_indicator' => 'score',
89
+                        'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score',
90
+                        'sql' => 'FIELD');
91
+            $scormData[] = array(
92
+                        //'coursedb' => $details['db_name'],
93
+                        'lid' => $lpItem['lid'],
94
+                        'liid' => $lpItem['liid'],
95
+                        'target_view_count' => null,
96
+                        'target_indicator' => 'score',
97
+                        'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/all/score',
98
+                        'sql' => 'avg(FIELD)');
99
+        }
100
+    }
101 101
 
102
-	foreach ($scormData as $v) {
102
+    foreach ($scormData as $v) {
103 103
         if (!isset($v['sql'])) {
104 104
             $v['sql'] = 'FIELD';
105 105
         }
106 106
         $sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']);
107 107
         $query = 'select '.$sqlField.' as "'.$v['title'].'" ';
108 108
         $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
109
-		$query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW).' lv ';
110
-		$query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid'];
111
-		$query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW).' liv ';
112
-		$query .= ' on lv.id = liv.lp_view_id ';
113
-		if ($v['target_view_count'])
114
-			$query .= ' and liv.view_count = '.$v['target_view_count'];
115
-		$query .= ' and liv.lp_item_id = '.$v['liid'].' ';
116
-		$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
117
-		$query .= ' group by u.user_id ';
118
-		$query .= ' order by u.user_id ';
119
-		$queries[] = $query;
120
-	}
109
+        $query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW).' lv ';
110
+        $query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid'];
111
+        $query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW).' liv ';
112
+        $query .= ' on lv.id = liv.lp_view_id ';
113
+        if ($v['target_view_count'])
114
+            $query .= ' and liv.view_count = '.$v['target_view_count'];
115
+        $query .= ' and liv.lp_item_id = '.$v['liid'].' ';
116
+        $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
117
+        $query .= ' group by u.user_id ';
118
+        $query .= ' order by u.user_id ';
119
+        $queries[] = $query;
120
+    }
121 121
 
122
-	return $queries;
122
+    return $queries;
123 123
 }
124 124
 
Please login to merge, or discard this patch.
main/reports/templates/generic.reports.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $reports_template['Generic'] = array(
4
-	'description' => 'Generic',
5
-	'getSQL' => 'reports_template_Generic_getSQL',
6
-	'wizard' =>
4
+    'description' => 'Generic',
5
+    'getSQL' => 'reports_template_Generic_getSQL',
6
+    'wizard' =>
7 7
 '
8 8
 <span id="Generic" class="step">
9 9
 	<span class="font_normal_07em_black">This report does not need any particular settings</span><br />
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
 ');
13 13
 
14 14
 function reports_template_Generic_getSQL() {
15
-	// settings
16
-
17
-
18
-	// Nom, prenom
19
-	$query = 'select u.lastname as "Last name", u.firstname as "First name" ';
20
-	$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
21
-	$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
22
-	$query .= ' order by u.user_id ';
23
-	$queries[0] = $query;
24
-
25
-	// Custom Field
26
-	foreach (array(10 => "description") as $k => $v) {
27
-		$query = 'select ufv.value  as "'.$v.'" ';
28
-		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
29
-		$query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv ';
30
-		$query .= ' on ufv.item_id = u.user_id and ufv.field_id = '.$k;
31
-		$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
32
-		$query .= ' order by u.user_id ';
33
-		$queries[] = $query;
34
-	}
35
-
36
-	// Stored Value
37
-	$sv = array();
38
-	foreach ($sv as $k => $v) {
39
-		$query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
40
-		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
41
-		$query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv ';
42
-		$query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
43
-		$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
44
-		$query .= ' order by u.user_id ';
45
-		$queries[] = $query;
46
-	}
47
-
48
-	// premiere connexion
49
-	$query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection"  ';
50
-	$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
51
-	$query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
52
-	$query .= ' on tel.login_user_id = u.user_id ';
53
-	$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
54
-	$query .= ' group by u.user_id ';
55
-	$query .= ' order by u.user_id ';
56
-	$queries[] = $query;
57
-
58
-	return $queries;
15
+    // settings
16
+
17
+
18
+    // Nom, prenom
19
+    $query = 'select u.lastname as "Last name", u.firstname as "First name" ';
20
+    $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
21
+    $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
22
+    $query .= ' order by u.user_id ';
23
+    $queries[0] = $query;
24
+
25
+    // Custom Field
26
+    foreach (array(10 => "description") as $k => $v) {
27
+        $query = 'select ufv.value  as "'.$v.'" ';
28
+        $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
29
+        $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv ';
30
+        $query .= ' on ufv.item_id = u.user_id and ufv.field_id = '.$k;
31
+        $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
32
+        $query .= ' order by u.user_id ';
33
+        $queries[] = $query;
34
+    }
35
+
36
+    // Stored Value
37
+    $sv = array();
38
+    foreach ($sv as $k => $v) {
39
+        $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
40
+        $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
41
+        $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv ';
42
+        $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
43
+        $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
44
+        $query .= ' order by u.user_id ';
45
+        $queries[] = $query;
46
+    }
47
+
48
+    // premiere connexion
49
+    $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection"  ';
50
+    $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
51
+    $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
52
+    $query .= ' on tel.login_user_id = u.user_id ';
53
+    $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
54
+    $query .= ' group by u.user_id ';
55
+    $query .= ' order by u.user_id ';
56
+    $queries[] = $query;
57
+
58
+    return $queries;
59 59
 }
60 60
 
Please login to merge, or discard this patch.
main/reports/templates/courseTime.reports.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -12,30 +12,30 @@
 block discarded – undo
12 12
 ');*/
13 13
 
14 14
 function reports_template_courseTime_getSQL() {
15
-	// fetch columns
16
-	$result = array();
17
-	$query = 'select r.id as kid, c.title as course '.
18
-		'from '.
19
-		Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '.
20
-		Database::get_main_table(TABLE_MAIN_COURSE).' c '.
21
-		'where r.course_id=c.id and r.tool_id is null and r.child_id is null'.
22
-		' order by c.title';
23
-	$columns = Database::query($query);
24
-	if (Database::num_rows($columns) == 0)
25
-		die('<b>'.get_lang('no data found: '.$query).'</b>');
26
-	$columns = Database::store_result($columns);
15
+    // fetch columns
16
+    $result = array();
17
+    $query = 'select r.id as kid, c.title as course '.
18
+        'from '.
19
+        Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '.
20
+        Database::get_main_table(TABLE_MAIN_COURSE).' c '.
21
+        'where r.course_id=c.id and r.tool_id is null and r.child_id is null'.
22
+        ' order by c.title';
23
+    $columns = Database::query($query);
24
+    if (Database::num_rows($columns) == 0)
25
+        die('<b>'.get_lang('no data found: '.$query).'</b>');
26
+    $columns = Database::store_result($columns);
27 27
 
28
-	// fetch data
29
-	$query = 'select u.lastname Name, u.firstname Firstname';
30
-	foreach ($columns as $key => $column)
31
-		$query .= ', sec_to_time(k'.$key.'.report_time) as `'.
32
-				$column['course'].'` '; 
33
-	$query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
34
-	foreach ($columns as $key => $column) // fixme sessions
35
-		$query .= 'left outer join '.
36
-			Database::get_main_table(TABLE_MAIN_REPORTS_VALUES).
37
-			' k'.$key.
38
-			' on k'.$key.'.key_id = '.$column['kid'].
39
-				' and k'.$key.'.user_id = u.user_id ';
40
-	return $query;
28
+    // fetch data
29
+    $query = 'select u.lastname Name, u.firstname Firstname';
30
+    foreach ($columns as $key => $column)
31
+        $query .= ', sec_to_time(k'.$key.'.report_time) as `'.
32
+                $column['course'].'` '; 
33
+    $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
34
+    foreach ($columns as $key => $column) // fixme sessions
35
+        $query .= 'left outer join '.
36
+            Database::get_main_table(TABLE_MAIN_REPORTS_VALUES).
37
+            ' k'.$key.
38
+            ' on k'.$key.'.key_id = '.$column['kid'].
39
+                ' and k'.$key.'.user_id = u.user_id ';
40
+    return $query;
41 41
 }
Please login to merge, or discard this patch.
main/reports/reports.cli.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -4,55 +4,55 @@
 block discarded – undo
4 4
 require_once 'reports.lib.php';
5 5
 
6 6
 $longopts = array(
7
-	'course:',
8
-	'tool:',
9
-	'ci:',
10
-	'cn:',
11
-	'sci:',
12
-	'scn:',
13
-	'ssci:',
14
-	'sscn:',
15
-	'link:',
16
-	'addValue',
17
-	'addKey',
18
-	'help',
19
-	'clearAll',
20
-	'score:',
21
-	'progress:',
22
-	'time:',
23
-	'attempt:',
24
-	'session:',
25
-	'attempt:',
26
-	'uid:',
27
-	'key:',
28
-	'addDBKeys',
29
-	'build');
7
+    'course:',
8
+    'tool:',
9
+    'ci:',
10
+    'cn:',
11
+    'sci:',
12
+    'scn:',
13
+    'ssci:',
14
+    'sscn:',
15
+    'link:',
16
+    'addValue',
17
+    'addKey',
18
+    'help',
19
+    'clearAll',
20
+    'score:',
21
+    'progress:',
22
+    'time:',
23
+    'attempt:',
24
+    'session:',
25
+    'attempt:',
26
+    'uid:',
27
+    'key:',
28
+    'addDBKeys',
29
+    'build');
30 30
 
31 31
 $options = getopt("", $longopts);
32 32
 
33 33
 echo "\n\n";
34 34
 
35 35
 if (array_key_exists('help', $options))
36
-	echo "help message\n";
36
+    echo "help message\n";
37 37
 else if (array_key_exists('clearAll', $options)) {
38
-	reports_clearAll();
38
+    reports_clearAll();
39 39
 } else if (array_key_exists('build', $options)) {
40
-	reports_build();
40
+    reports_build();
41 41
 } else if (array_key_exists('addDBKeys', $options)) {
42
-	reports_addDBKeys();
42
+    reports_addDBKeys();
43 43
 } else if (array_key_exists('addValue', $options)) {
44
-	reports_addValue($options['key'], $options['session'], $options['uid'],
45
-			$options['attempt'], $options['score'],
46
-			$options['progress'], $options['time']);
44
+    reports_addValue($options['key'], $options['session'], $options['uid'],
45
+            $options['attempt'], $options['score'],
46
+            $options['progress'], $options['time']);
47 47
 } else if (array_key_exists('addKey', $options)) {
48
-	echo reports_addKey($options['course'], $options['tool'],
49
-			$options['ci'], $options['cn'],
50
-			$options['sci'], $options['scn'],
51
-			$options['ssci'], $options['sscn'],
52
-			$options['link']);
53
-	echo "\n";
48
+    echo reports_addKey($options['course'], $options['tool'],
49
+            $options['ci'], $options['cn'],
50
+            $options['sci'], $options['scn'],
51
+            $options['ssci'], $options['sscn'],
52
+            $options['link']);
53
+    echo "\n";
54 54
 } else
55
-	echo "action not found\n";
55
+    echo "action not found\n";
56 56
 
57 57
 echo "\n";
58 58
 ?>
Please login to merge, or discard this patch.
main/reports/reports.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
 
35 35
 // "Link" type
36 36
 if ($_REQUEST['format'] == 'link') {
37
-	// converting post vars to get uri
38
-	$params = '';
39
-	$kv = array();
40
-	foreach ($_POST as $key => $value)
41
-		if ($key != 'format')
42
-			$kv[] = $key.'='.urlencode($value);
43
-	$query_string = join("&", $kv);
44
-	die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>');
37
+    // converting post vars to get uri
38
+    $params = '';
39
+    $kv = array();
40
+    foreach ($_POST as $key => $value)
41
+        if ($key != 'format')
42
+            $kv[] = $key.'='.urlencode($value);
43
+    $query_string = join("&", $kv);
44
+    die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>');
45 45
 }
46 46
 
47 47
 if ($_REQUEST['format'] == 'directlink') {
48
-	foreach (array('jquery.dataTables.min.js') as $js)
49
-		$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
48
+    foreach (array('jquery.dataTables.min.js') as $js)
49
+        $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
50 50
 
51
-	$htmlCSSXtra[] = 'dataTable.css';
51
+    $htmlCSSXtra[] = 'dataTable.css';
52 52
 
53 53
 ?>
54 54
     <script type="text/javascript">
@@ -63,62 +63,62 @@  discard block
 block discarded – undo
63 63
 		}
64 64
     </script>
65 65
 <?php
66
-	Display::display_header($tool_name);
67
-	echo '<div id="result" class="result">';
66
+    Display::display_header($tool_name);
67
+    echo '<div id="result" class="result">';
68 68
 }
69 69
 
70 70
 // outputing a link to csv file instead of outputing csv data directly
71 71
 if ($_REQUEST['format'] == 'csv')  {
72
-	// converting post vars to get uri
73
-	$params = '';
74
-	$kv = array();
75
-	foreach ($_POST as $key => $value)
76
-		if ($key != 'format')
77
-			$kv[] = $key.'='.urlencode($value);
78
-	$query_string = join("&", $kv);
79
-	die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>');
72
+    // converting post vars to get uri
73
+    $params = '';
74
+    $kv = array();
75
+    foreach ($_POST as $key => $value)
76
+        if ($key != 'format')
77
+            $kv[] = $key.'='.urlencode($value);
78
+    $query_string = join("&", $kv);
79
+    die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>');
80 80
 } else if ($_REQUEST['format'] == 'downloadcsv') {
81
-	if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) {
82
-		header("Pragma: must-revalidate");
83
-		header("Cache-Control: must-revalidate");
84
-		header("Content-type: application/vnd.ms-excel");
85
-	}
86
-	else {
87
-		header("Content-type: text/csv");
88
-	}
89
-	$date = date("Y-m-d");
90
-	$filename = "reporting-$date.csv";
91
-	header("Content-Disposition: attachment; filename=$filename");
92
-	$_REQUEST['format'] = 'csv';
81
+    if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) {
82
+        header("Pragma: must-revalidate");
83
+        header("Cache-Control: must-revalidate");
84
+        header("Content-type: application/vnd.ms-excel");
85
+    }
86
+    else {
87
+        header("Content-type: text/csv");
88
+    }
89
+    $date = date("Y-m-d");
90
+    $filename = "reporting-$date.csv";
91
+    header("Content-Disposition: attachment; filename=$filename");
92
+    $_REQUEST['format'] = 'csv';
93 93
 }
94 94
 
95 95
 
96 96
 
97 97
 if (is_array($reports_template[$_REQUEST['type']])) {
98
-	$query = $reports_template[$_REQUEST['type']]['getSQL']();
99
-	if (! is_array($query))
100
-		$query = array($query);
101
-	if ($_REQUEST['format'] == 'sql')
102
-		die(var_export($query, true));
98
+    $query = $reports_template[$_REQUEST['type']]['getSQL']();
99
+    if (! is_array($query))
100
+        $query = array($query);
101
+    if ($_REQUEST['format'] == 'sql')
102
+        die(var_export($query, true));
103 103
 
104
-	$result = multiquery_query($query);
104
+    $result = multiquery_query($query);
105 105
 
106 106
 
107
-	// check number of result
108
-	$numberOfResult = multiquery_num_rows($result);
109
-	if ($numberOfResult == 0) {
110
-		// This case should be taken care of by the display template itself, we should let the script run
111
-		//die(get_lang('NoDataAvailable'));
112
-	}
107
+    // check number of result
108
+    $numberOfResult = multiquery_num_rows($result);
109
+    if ($numberOfResult == 0) {
110
+        // This case should be taken care of by the display template itself, we should let the script run
111
+        //die(get_lang('NoDataAvailable'));
112
+    }
113 113
 } else {
114
-	die('<b>'.get_lang('ErrorWhileBuildingReport').'</b>');
114
+    die('<b>'.get_lang('ErrorWhileBuildingReport').'</b>');
115 115
 }
116 116
 
117 117
 if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
118
-	if (isset($reports_template[$_REQUEST['type']]['html_header'])) {
119
-		echo $reports_template[$_REQUEST['type']]['html_header'];
120
-	}
121
-	echo '<script type="text/javascript" charset="utf-8">
118
+    if (isset($reports_template[$_REQUEST['type']]['html_header'])) {
119
+        echo $reports_template[$_REQUEST['type']]['html_header'];
120
+    }
121
+    echo '<script type="text/javascript" charset="utf-8">
122 122
 			$(document).ready(function() {
123 123
 
124 124
 				$("#reportsData'.$idsuffix.'").dataTable({
@@ -143,50 +143,50 @@  discard block
 block discarded – undo
143 143
 				});
144 144
 			} );
145 145
 		</script>';
146
-	echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style
147
-
148
-	// counting fields
149
-	$nfields = multiquery_num_fields($result);
150
-	$columns = array();
151
-	$columns_islink = array();
152
-	echo '<thead><tr>';
153
-	for ($i=0; $i < $nfields; $i++)	{
154
-		$columns[$i] = multiquery_field_name($result, $i);
155
-		if (substr($columns[$i], -5, 5) != '_link') {
156
-			$column_islink[$i] = false;
157
-			echo '<th>'.$columns[$i].'</th>';
158
-		} else
159
-			$columns_islink[$i] = true;
160
-	}
161
-
162
-	// checking resolving link column id
163
-	$columns_flip = array_flip($columns);
164
-	$columns_link = array();
165
-	for ($i=0; $i < $nfields; $i++)
166
-		if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip))
167
-			$columns_link[$i] = $columns_flip[$columns[$i].'_link'];
168
-		else
169
-			$columns_link[$i] = '';
170
-	echo '</tr></thead><tbody>';
171
-	while ($row = multiquery_fetch_row($result)) {
172
-		echo '<tr>';
173
-		for ($i = 0; $i<$nfields; $i++)
174
-			if (!$columns_islink[$i]){ // ignore links
175
-				if ($columns_link[$i] != '') // link is defined
176
-					if (substr($columns_link[$i],0,10) == 'javascript') {
177
-						echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
178
-					}
179
-					else {
180
-						echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
181
-					}
182
-				else
183
-					echo '<td>'.$row[$i].'</td>';
184
-			}
185
-		echo "</tr>\n";
186
-	}
187
-	echo '</tbody></table>';
188
-	if ($_REQUEST['format'] == 'directlink') {
189
-		echo '</div>
146
+    echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style
147
+
148
+    // counting fields
149
+    $nfields = multiquery_num_fields($result);
150
+    $columns = array();
151
+    $columns_islink = array();
152
+    echo '<thead><tr>';
153
+    for ($i=0; $i < $nfields; $i++)	{
154
+        $columns[$i] = multiquery_field_name($result, $i);
155
+        if (substr($columns[$i], -5, 5) != '_link') {
156
+            $column_islink[$i] = false;
157
+            echo '<th>'.$columns[$i].'</th>';
158
+        } else
159
+            $columns_islink[$i] = true;
160
+    }
161
+
162
+    // checking resolving link column id
163
+    $columns_flip = array_flip($columns);
164
+    $columns_link = array();
165
+    for ($i=0; $i < $nfields; $i++)
166
+        if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip))
167
+            $columns_link[$i] = $columns_flip[$columns[$i].'_link'];
168
+        else
169
+            $columns_link[$i] = '';
170
+    echo '</tr></thead><tbody>';
171
+    while ($row = multiquery_fetch_row($result)) {
172
+        echo '<tr>';
173
+        for ($i = 0; $i<$nfields; $i++)
174
+            if (!$columns_islink[$i]){ // ignore links
175
+                if ($columns_link[$i] != '') // link is defined
176
+                    if (substr($columns_link[$i],0,10) == 'javascript') {
177
+                        echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
178
+                    }
179
+                    else {
180
+                        echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
181
+                    }
182
+                else
183
+                    echo '<td>'.$row[$i].'</td>';
184
+            }
185
+        echo "</tr>\n";
186
+    }
187
+    echo '</tbody></table>';
188
+    if ($_REQUEST['format'] == 'directlink') {
189
+        echo '</div>
190 190
 		<div id="result2" class="result" style="margin: 50px;">
191 191
 		</div>
192 192
 		<div id="result3" class="result" style="margin: 100px;">
@@ -194,36 +194,36 @@  discard block
 block discarded – undo
194 194
 		<div id="result4" class="result" style="margin: 150px;">
195 195
 		</div>';
196 196
 
197
-		Display::display_footer();
197
+        Display::display_footer();
198 198
 
199
-	}
199
+    }
200 200
 } else if ($_REQUEST['format'] == 'csv') {
201
-	$nfields = multiquery_num_fields($result);
202
-	$columns = array();
203
-	$columns_islink = array();
204
-	for ($i=0; $i < $nfields; $i++)	{
205
-		$columns[$i] = multiquery_field_name($result, $i);
206
-		if (substr($columns[$i], -5, 5) != '_link') {
207
-			$column_islink[$i] = false;
208
-			echo csv_escaping($columns[$i]).',';
209
-		} else
210
-			$columns_islink[$i] = true;
211
-	}
212
-
213
-	echo "\n";
214
-	while ($row = multiquery_fetch_row($result)) {
215
-		for ($i = 0; $i<$nfields; $i++)
216
-			if (!$columns_islink[$i]) // ignore links
217
-				echo csv_escaping($row[$i]).',';  // fixme
218
-		echo "\n";
219
-	}
201
+    $nfields = multiquery_num_fields($result);
202
+    $columns = array();
203
+    $columns_islink = array();
204
+    for ($i=0; $i < $nfields; $i++)	{
205
+        $columns[$i] = multiquery_field_name($result, $i);
206
+        if (substr($columns[$i], -5, 5) != '_link') {
207
+            $column_islink[$i] = false;
208
+            echo csv_escaping($columns[$i]).',';
209
+        } else
210
+            $columns_islink[$i] = true;
211
+    }
212
+
213
+    echo "\n";
214
+    while ($row = multiquery_fetch_row($result)) {
215
+        for ($i = 0; $i<$nfields; $i++)
216
+            if (!$columns_islink[$i]) // ignore links
217
+                echo csv_escaping($row[$i]).',';  // fixme
218
+        echo "\n";
219
+    }
220 220
 } else die(get_lang('UnknownFormat'));
221 221
 
222 222
 function csv_escaping($value, $csv_separator = ',') {
223
-	$value = str_replace('"','""',$value);
224
-	if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) {
225
-		$value = '"'.$value.'"';
226
-	}
227
-	return $value;
223
+    $value = str_replace('"','""',$value);
224
+    if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) {
225
+        $value = '"'.$value.'"';
226
+    }
227
+    return $value;
228 228
 }
229 229
 ?>
Please login to merge, or discard this patch.