Completed
Push — 1.10.x ( 3c9fe3...995e8b )
by Yannick
116:12 queued 73:22
created
main/survey/survey_invitation.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
15 15
 if (!api_is_allowed_to_edit(false, true)) {
16
-	Display :: display_header(get_lang('ToolSurvey'));
17
-	Display :: display_error_message(get_lang('NotAllowed'), false);
18
-	Display :: display_footer();
19
-	exit;
16
+    Display :: display_header(get_lang('ToolSurvey'));
17
+    Display :: display_error_message(get_lang('NotAllowed'), false);
18
+    Display :: display_footer();
19
+    exit;
20 20
 }
21 21
 
22 22
 // Database table definitions
@@ -33,25 +33,25 @@  discard block
 block discarded – undo
33 33
 // Getting the survey information
34 34
 // We exit here if ther is no valid $_GET parameter
35 35
 if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])) {
36
-	Display :: display_header($tool_name);
37
-	Display :: display_error_message(get_lang('InvallidSurvey'), false);
38
-	Display :: display_footer();
39
-	exit;
36
+    Display :: display_header($tool_name);
37
+    Display :: display_error_message(get_lang('InvallidSurvey'), false);
38
+    Display :: display_footer();
39
+    exit;
40 40
 }
41 41
 
42 42
 $survey_id = Security::remove_XSS($_GET['survey_id']);
43 43
 $survey_data = SurveyManager::get_survey($survey_id);
44 44
 
45 45
 if (empty($survey_data)) {
46
-	Display :: display_header($tool_name);
47
-	Display :: display_error_message(get_lang('InvallidSurvey'), false);
48
-	Display :: display_footer();
49
-	exit;
46
+    Display :: display_header($tool_name);
47
+    Display :: display_error_message(get_lang('InvallidSurvey'), false);
48
+    Display :: display_footer();
49
+    exit;
50 50
 }
51 51
 
52 52
 $urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
53 53
 if (api_strlen(strip_tags($survey_data['title'])) > 40) {
54
-	$urlname .= '...';
54
+    $urlname .= '...';
55 55
 }
56 56
 
57 57
 // Breadcrumbs
@@ -64,32 +64,32 @@  discard block
 block discarded – undo
64 64
 
65 65
 // Checking the parameters
66 66
 if (!is_numeric($survey_id)) {
67
-	Display::display_error_message(get_lang('Error'), false);
68
-	Display::display_footer();
69
-	exit;
67
+    Display::display_error_message(get_lang('Error'), false);
68
+    Display::display_footer();
69
+    exit;
70 70
 }
71 71
 
72 72
 // Getting all the people who have filled this survey
73 73
 $answered_data = SurveyManager::get_people_who_filled_survey($survey_id);
74 74
 if ($survey_data['anonymous'] == 1) {
75
-	Display::display_normal_message(get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count($answered_data).' '.get_lang('PeopleAnswered'));
76
-	$answered_data = array();
75
+    Display::display_normal_message(get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count($answered_data).' '.get_lang('PeopleAnswered'));
76
+    $answered_data = array();
77 77
 }
78 78
 
79 79
 if (!isset($_GET['view']) OR $_GET['view'] == 'invited') {
80
-	echo get_lang('ViewInvited'). ' | ';
80
+    echo get_lang('ViewInvited'). ' | ';
81 81
 } else {
82
-	echo '	<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=invited">'.get_lang('ViewInvited').'</a> |';
82
+    echo '	<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=invited">'.get_lang('ViewInvited').'</a> |';
83 83
 }
84 84
 if ($_GET['view'] == 'answered') {
85
-	echo get_lang('ViewAnswered').' | ';
85
+    echo get_lang('ViewAnswered').' | ';
86 86
 } else {
87
-	echo '	<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=answered">'.get_lang('ViewAnswered').'</a> |';
87
+    echo '	<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=answered">'.get_lang('ViewAnswered').'</a> |';
88 88
 }
89 89
 if ($_GET['view'] == 'unanswered') {
90
-	echo get_lang('ViewUnanswered');
90
+    echo get_lang('ViewUnanswered');
91 91
 } else {
92
-	echo '	<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=unanswered">'.get_lang('ViewUnanswered').'</a>';
92
+    echo '	<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=unanswered">'.get_lang('ViewUnanswered').'</a>';
93 93
 }
94 94
 
95 95
 // Table header
@@ -111,32 +111,32 @@  discard block
 block discarded – undo
111 111
 
112 112
 $res = Database::query($sql);
113 113
 while ($row = Database::fetch_assoc($res)) {
114
-	if (!$_GET['view'] ||
115
-		$_GET['view'] == 'invited' ||
114
+    if (!$_GET['view'] ||
115
+        $_GET['view'] == 'invited' ||
116 116
         ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) ||
117 117
         ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))
118 118
     ) {
119
-		echo '<tr>';
120
-		if (is_numeric($row['user'])) {
119
+        echo '<tr>';
120
+        if (is_numeric($row['user'])) {
121 121
             $userInfo = api_get_user_info($row['user']);
122
-			echo '<td>';
122
+            echo '<td>';
123 123
             echo UserManager::getUserProfileLink($userInfo);
124 124
             echo '</td>';
125
-		} else {
125
+        } else {
126 126
             echo '<td>'.$row['user'].'</td>';
127
-		}
128
-		echo '	<td>'.$row['invitation_date'].'</td>';
129
-		echo '	<td>';
130
-
131
-		if (in_array($row['user'], $answered_data)) {
132
-			echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$survey_id.'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
133
-		} else {
134
-			echo '-';
135
-		}
136
-
137
-		echo '	</td>';
138
-		echo '</tr>';
139
-	}
127
+        }
128
+        echo '	<td>'.$row['invitation_date'].'</td>';
129
+        echo '	<td>';
130
+
131
+        if (in_array($row['user'], $answered_data)) {
132
+            echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$survey_id.'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
133
+        } else {
134
+            echo '-';
135
+        }
136
+
137
+        echo '	</td>';
138
+        echo '</tr>';
139
+    }
140 140
 }
141 141
 
142 142
 // Closing the table
Please login to merge, or discard this patch.
main/survey/preview.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 
44 44
 // We exit here if there is no valid $_GET parameter
45 45
 if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])){
46
-	Display::display_header(get_lang('SurveyPreview'));
47
-	Display::display_error_message(get_lang('InvallidSurvey'), false);
48
-	Display::display_footer();
49
-	exit;
46
+    Display::display_header(get_lang('SurveyPreview'));
47
+    Display::display_error_message(get_lang('InvallidSurvey'), false);
48
+    Display::display_footer();
49
+    exit;
50 50
 }
51 51
 
52 52
 // Getting the survey information
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 $survey_data = SurveyManager::get_survey($survey_id);
55 55
 
56 56
 if (empty($survey_data)) {
57
-	Display::display_header(get_lang('SurveyPreview'));
58
-	Display::display_error_message(get_lang('InvallidSurvey'), false);
59
-	Display::display_footer();
60
-	exit;
57
+    Display::display_header(get_lang('SurveyPreview'));
58
+    Display::display_error_message(get_lang('InvallidSurvey'), false);
59
+    Display::display_footer();
60
+    exit;
61 61
 }
62 62
 
63 63
 $urlname = strip_tags($survey_data['title']);
64 64
 if (api_is_allowed_to_edit()) {
65
-	// Breadcrumbs
66
-	$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList'));
67
-	$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname);
65
+    // Breadcrumbs
66
+    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList'));
67
+    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname);
68 68
 }
69 69
 $courseCode = isset($_GET['cidReq']) ? $_GET['cidReq'] : null;
70 70
 $surveyAnonymous = SurveyManager::get_survey($survey_id, 0, $courseCode);
@@ -92,57 +92,57 @@  discard block
 block discarded – undo
92 92
 $counter_question = 0;
93 93
 // Only a course admin is allowed to preview a survey: you are a course admin
94 94
 if (api_is_course_admin() ||
95
-	(api_is_course_admin() && $_GET['isStudentView'] == 'true') ||
96
-	api_is_allowed_to_session_edit(false, true)
95
+    (api_is_course_admin() && $_GET['isStudentView'] == 'true') ||
96
+    api_is_allowed_to_session_edit(false, true)
97 97
 ) {
98
-	// Survey information
99
-	echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>';
100
-	echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
98
+    // Survey information
99
+    echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>';
100
+    echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
101 101
 
102
-	// Displaying the survey introduction
103
-	if (!isset($_GET['show'])) {
102
+    // Displaying the survey introduction
103
+    if (!isset($_GET['show'])) {
104 104
         if (!empty($survey_data['survey_introduction'])) {
105 105
             echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>';
106 106
         }
107
-		$limit = 0;
108
-	}
107
+        $limit = 0;
108
+    }
109 109
 
110
-	// Displaying the survey thanks message
111
-	if (isset($_POST['finish_survey'])) {
112
-		Display::display_confirmation_message(get_lang('SurveyFinished'));
110
+    // Displaying the survey thanks message
111
+    if (isset($_POST['finish_survey'])) {
112
+        Display::display_confirmation_message(get_lang('SurveyFinished'));
113 113
         echo $survey_data['survey_thanks'];
114
-		Display :: display_footer();
115
-		exit;
116
-	}
114
+        Display :: display_footer();
115
+        exit;
116
+    }
117 117
 
118 118
     $questions = array();
119 119
 
120
-	if (isset($_GET['show'])) {
121
-		// Getting all the questions for this page and add them to a
122
-		// multidimensional array where the first index is the page.
123
-		// as long as there is no pagebreak fount we keep adding questions to the page
124
-		$questions_displayed = array();
125
-		$paged_questions = array();
126
-		$counter = 0;
127
-		$sql = "SELECT * FROM $table_survey_question
120
+    if (isset($_GET['show'])) {
121
+        // Getting all the questions for this page and add them to a
122
+        // multidimensional array where the first index is the page.
123
+        // as long as there is no pagebreak fount we keep adding questions to the page
124
+        $questions_displayed = array();
125
+        $paged_questions = array();
126
+        $counter = 0;
127
+        $sql = "SELECT * FROM $table_survey_question
128 128
 		        WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."'
129 129
 				ORDER BY sort ASC";
130
-		$result = Database::query($sql);
130
+        $result = Database::query($sql);
131 131
         $questions_exists = true;
132 132
         if (Database::num_rows($result)) {
133
-    		while ($row = Database::fetch_array($result)) {
134
-    			if ($row['type'] == 'pagebreak') {
135
-    				$counter++;
136
-    			} else {
137
-    				$paged_questions[$counter][] = $row['question_id'];
138
-    			}
139
-    		}
133
+            while ($row = Database::fetch_array($result)) {
134
+                if ($row['type'] == 'pagebreak') {
135
+                    $counter++;
136
+                } else {
137
+                    $paged_questions[$counter][] = $row['question_id'];
138
+                }
139
+            }
140 140
         } else {
141 141
             $questions_exists = false;
142 142
         }
143 143
 
144
-		if (array_key_exists($_GET['show'], $paged_questions)) {
145
-			$sql = "SELECT
144
+        if (array_key_exists($_GET['show'], $paged_questions)) {
145
+            $sql = "SELECT
146 146
                         survey_question.question_id,
147 147
                         survey_question.survey_id,
148 148
                         survey_question.survey_question,
@@ -164,75 +164,75 @@  discard block
 block discarded – undo
164 164
 						survey_question.c_id =  $course_id
165 165
 					ORDER BY survey_question.sort, survey_question_option.sort ASC";
166 166
 
167
-			$result = Database::query($sql);
168
-			$question_counter_max = Database::num_rows($result);
169
-			$limit = 0;
170
-			while ($row = Database::fetch_array($result)) {
171
-				// If the type is not a pagebreak we store it in the $questions array
172
-				if ($row['type'] != 'pagebreak') {
173
-					$questions[$row['sort']]['question_id'] = $row['question_id'];
174
-					$questions[$row['sort']]['survey_id'] = $row['survey_id'];
175
-					$questions[$row['sort']]['survey_question'] = $row['survey_question'];
176
-					$questions[$row['sort']]['display'] = $row['display'];
177
-					$questions[$row['sort']]['type'] = $row['type'];
178
-					$questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text'];
179
-					$questions[$row['sort']]['maximum_score'] = $row['max_value'];
180
-				} else {
181
-					// If the type is a pagebreak we are finished loading the questions for this page
182
-					break;
183
-				}
184
-				$counter_question++;
185
-			}
186
-		}
187
-	}
188
-
189
-	// Selecting the maximum number of pages
190
-	$sql = "SELECT * FROM $table_survey_question
167
+            $result = Database::query($sql);
168
+            $question_counter_max = Database::num_rows($result);
169
+            $limit = 0;
170
+            while ($row = Database::fetch_array($result)) {
171
+                // If the type is not a pagebreak we store it in the $questions array
172
+                if ($row['type'] != 'pagebreak') {
173
+                    $questions[$row['sort']]['question_id'] = $row['question_id'];
174
+                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
175
+                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
176
+                    $questions[$row['sort']]['display'] = $row['display'];
177
+                    $questions[$row['sort']]['type'] = $row['type'];
178
+                    $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text'];
179
+                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
180
+                } else {
181
+                    // If the type is a pagebreak we are finished loading the questions for this page
182
+                    break;
183
+                }
184
+                $counter_question++;
185
+            }
186
+        }
187
+    }
188
+
189
+    // Selecting the maximum number of pages
190
+    $sql = "SELECT * FROM $table_survey_question
191 191
 	        WHERE
192 192
 	            c_id = $course_id AND
193 193
 	            type='".Database::escape_string('pagebreak')."' AND
194 194
 	            survey_id='".intval($survey_id)."'";
195
-	$result = Database::query($sql);
196
-	$numberofpages = Database::num_rows($result) + 1;
197
-
198
-	// Displaying the form with the questions
199
-	if (isset($_GET['show'])) {
200
-		$show = (int)$_GET['show'] + 1;
201
-	} else {
202
-		$show = 0;
203
-	}
204
-
205
-	$url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show;
206
-	$form = new FormValidator('question', 'post', $url);
207
-
208
-	if (is_array($questions) && count($questions) > 0) {
209
-		foreach ($questions as $key => & $question) {
210
-			$ch_type = 'ch_'.$question['type'];
211
-			/** @var survey_question $display */
212
-			$display = new $ch_type;
213
-			$form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
214
-			$form->addHtml($question['survey_question']);
215
-			$display->render($form, $question);
216
-			$form->addHtml('</div></div>');
217
-		}
218
-	}
219
-
220
-	if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
195
+    $result = Database::query($sql);
196
+    $numberofpages = Database::num_rows($result) + 1;
197
+
198
+    // Displaying the form with the questions
199
+    if (isset($_GET['show'])) {
200
+        $show = (int)$_GET['show'] + 1;
201
+    } else {
202
+        $show = 0;
203
+    }
204
+
205
+    $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show;
206
+    $form = new FormValidator('question', 'post', $url);
207
+
208
+    if (is_array($questions) && count($questions) > 0) {
209
+        foreach ($questions as $key => & $question) {
210
+            $ch_type = 'ch_'.$question['type'];
211
+            /** @var survey_question $display */
212
+            $display = new $ch_type;
213
+            $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
214
+            $form->addHtml($question['survey_question']);
215
+            $display->render($form, $question);
216
+            $form->addHtml('</div></div>');
217
+        }
218
+    }
219
+
220
+    if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
221 221
         if ($show == 0) {
222
-			$form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
222
+            $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
223 223
         } else {
224
-			$form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
224
+            $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
225 225
         }
226
-	}
227
-	if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
228
-		if ($questions_exists == false) {
229
-			echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
230
-		}
231
-		$form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right');
232
-	}
233
-	$form->display();
226
+    }
227
+    if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
228
+        if ($questions_exists == false) {
229
+            echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
230
+        }
231
+        $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right');
232
+    }
233
+    $form->display();
234 234
 } else {
235
-	Display :: display_error_message(get_lang('NotAllowed'), false);
235
+    Display :: display_error_message(get_lang('NotAllowed'), false);
236 236
 }
237 237
 
238 238
 // Footer
Please login to merge, or discard this patch.
main/session/session_course_user_list.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 $result = Database::query($sql);
52 52
 if (!list($session_name,$course_title) = Database::fetch_row($result)) {
53
-	header('Location: session_course_list.php?id_session='.$id_session);
54
-	exit();
53
+    header('Location: session_course_list.php?id_session='.$id_session);
54
+    exit();
55 55
 }
56 56
 
57 57
 switch ($action) {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 <a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>"><?php echo get_lang('Previous');?></a>
123 123
 <?php
124 124
 } else {
125
-	echo get_lang('Previous');
125
+    echo get_lang('Previous');
126 126
 }
127 127
 ?>
128 128
 |
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 <a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>"><?php echo get_lang('Next');?></a>
133 133
 <?php
134 134
 } else {
135
-	echo get_lang('Next');
135
+    echo get_lang('Next');
136 136
 }
137 137
 ?>
138 138
 </div>
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 $i=0;
155 155
 foreach ($users as $key => $enreg) {
156 156
 
157
-	if ($key == $limit) {
158
-		break;
159
-	}
157
+    if ($key == $limit) {
158
+        break;
159
+    }
160 160
     ?>
161 161
     <tr class="<?php echo $i?'row_odd':'row_even'; ?>">
162 162
         <td><input type="checkbox" name="idChecked[]" value="<?php echo $enreg['user_id']; ?>"></td>
Please login to merge, or discard this patch.
main/session/session_course_list.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -30,26 +30,26 @@  discard block
 block discarded – undo
30 30
 $result = Database::query("SELECT name FROM $tbl_session WHERE id='$id_session'");
31 31
 
32 32
 if (!list($session_name)=Database::fetch_row($result)) {
33
-	header('Location: session_list.php');
34
-	exit;
33
+    header('Location: session_list.php');
34
+    exit;
35 35
 }
36 36
 
37 37
 if ($action == 'delete') {
38
-	$idChecked = $_REQUEST['idChecked'];
39
-	if (is_array($idChecked) && count($idChecked)>0) {
40
-		$my_temp = array();
41
-		foreach ($idChecked as $id){
42
-			$my_temp[]= Database::escape_string($id);// forcing the escape_string
43
-		}
44
-		$idChecked = $my_temp;
45
-		$idChecked="'".implode("','", $idChecked)."'";
46
-		$result = Database::query("DELETE FROM $tbl_session_rel_course WHERE session_id='$id_session' AND c_id IN($idChecked)");
47
-		$nbr_affected_rows=Database::affected_rows($result);
48
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id='$id_session' AND c_id IN($idChecked)");
49
-		Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
50
-	}
51
-	header('Location: '.api_get_self().'?id_session='.$id_session.'&sort='.$sort);
52
-	exit();
38
+    $idChecked = $_REQUEST['idChecked'];
39
+    if (is_array($idChecked) && count($idChecked)>0) {
40
+        $my_temp = array();
41
+        foreach ($idChecked as $id){
42
+            $my_temp[]= Database::escape_string($id);// forcing the escape_string
43
+        }
44
+        $idChecked = $my_temp;
45
+        $idChecked="'".implode("','", $idChecked)."'";
46
+        $result = Database::query("DELETE FROM $tbl_session_rel_course WHERE session_id='$id_session' AND c_id IN($idChecked)");
47
+        $nbr_affected_rows=Database::affected_rows($result);
48
+        Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id='$id_session' AND c_id IN($idChecked)");
49
+        Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
50
+    }
51
+    header('Location: '.api_get_self().'?id_session='.$id_session.'&sort='.$sort);
52
+    exit();
53 53
 }
54 54
 
55 55
 $limit  = 20;
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
 $tableCourses = array();
83 83
 
84 84
 foreach ($Courses as $key=>$enreg) {
85
-	$course = array();
86
-	$course[] = '<input type="checkbox" name="idChecked[]" value="'.$enreg['id'].'">';
87
-	$course[] = api_htmlentities($enreg['title'],ENT_QUOTES,$charset);
88
-	$course[] = '<a href="session_course_user_list.php?id_session='.$id_session.'&course_code='.$enreg['code'].'">'.$enreg['nbr_users'].' '.get_lang('Users').'</a>';
89
-	$course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$enreg['code'].'/?id_session='.$id_session.'">'.
90
-		Display::return_icon('course_home.gif', get_lang('Course')).'</a>
85
+    $course = array();
86
+    $course[] = '<input type="checkbox" name="idChecked[]" value="'.$enreg['id'].'">';
87
+    $course[] = api_htmlentities($enreg['title'],ENT_QUOTES,$charset);
88
+    $course[] = '<a href="session_course_user_list.php?id_session='.$id_session.'&course_code='.$enreg['code'].'">'.$enreg['nbr_users'].' '.get_lang('Users').'</a>';
89
+    $course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$enreg['code'].'/?id_session='.$id_session.'">'.
90
+        Display::return_icon('course_home.gif', get_lang('Course')).'</a>
91 91
 			<a href="session_course_edit.php?id_session='.$id_session.'&page=session_course_list.php&course_code='.$enreg['code'].'">'.
92
-		Display::return_icon('edit.png', get_lang('Edit')).'</a>
92
+        Display::return_icon('edit.png', get_lang('Edit')).'</a>
93 93
 			<a href="'.api_get_self().'?id_session='.$id_session.'&sort='.$sort.'&action=delete&idChecked[]='.$enreg['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.
94
-		Display::return_icon('delete.png', get_lang('Delete')).'</a>';
95
-	$tableCourses[] = $course;
94
+        Display::return_icon('delete.png', get_lang('Delete')).'</a>';
95
+    $tableCourses[] = $course;
96 96
 }
97 97
 echo '<form method="post" action="'.api_get_self().'">';
98 98
 Display :: display_sortable_table($tableHeader, $tableCourses, array (), array ());
Please login to merge, or discard this patch.
main/session/index.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 //If session is not active we stop de script
235 235
 if (!api_is_allowed_to_session_edit()) {
236
-	api_not_allowed();
236
+    api_not_allowed();
237 237
 }
238 238
 
239 239
 $entityManager = Database::getManager();
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
                             if ($exercise_info->start_time != '0000-00-00 00:00:00') {
354 354
                                 $allowed_time = api_strtotime($exercise_info->start_time, 'UTC');
355 355
                                 if ($now < $allowed_time) {
356
-                                      continue;
356
+                                        continue;
357 357
                                 }
358 358
                             }
359 359
                             $exercise_info->exercise = Display::url(
@@ -583,11 +583,11 @@  discard block
 block discarded – undo
583 583
 		window.location.href=ui.tab;
584 584
     });
585 585
 <?php
586
-     //Displays js code to use a jqgrid
587
-     echo Display::grid_js('courses',       '',             $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list);
588
-     echo Display::grid_js('list_default',  $url,           $columns,         $column_model,$extra_params,array(), '');
589
-     echo Display::grid_js('list_course',   $url_by_course, $columns,         $column_model,$extra_params_course,array(),'');
590
-     echo Display::grid_js('list_week',     $url_week,      $column_week,     $column_week_model, $extra_params_week,array(),'');
586
+        //Displays js code to use a jqgrid
587
+        echo Display::grid_js('courses',       '',             $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list);
588
+        echo Display::grid_js('list_default',  $url,           $columns,         $column_model,$extra_params,array(), '');
589
+        echo Display::grid_js('list_course',   $url_by_course, $columns,         $column_model,$extra_params_course,array(),'');
590
+        echo Display::grid_js('list_week',     $url_week,      $column_week,     $column_week_model, $extra_params_week,array(),'');
591 591
 
592 592
     if (!api_is_anonymous()) {
593 593
         echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array);
Please login to merge, or discard this patch.
main/session/resume_session.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     $sessionRepository = Database::getManager()->getRepository('ChamiloCoreBundle:Session');
156 156
     $courses = $sessionRepository->getCoursesOrderedByPosition($session);
157 157
 
158
-	foreach ($courses as $course) {
158
+    foreach ($courses as $course) {
159 159
         //select the number of users
160 160
         $sql = "SELECT count(*)
161 161
                 FROM $tbl_session_rel_user sru,
@@ -167,37 +167,37 @@  discard block
 block discarded – undo
167 167
                     sru.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND
168 168
                     srcru.session_id = '".intval($sessionId)."'";
169 169
 
170
-		$rs = Database::query($sql);
170
+        $rs = Database::query($sql);
171 171
         $numberOfUsers = Database::result($rs, 0, 0);
172 172
 
173
-		// Get coachs of the courses in session
173
+        // Get coachs of the courses in session
174 174
 
175
-		$sql = "SELECT user.lastname, user.firstname, user.username
175
+        $sql = "SELECT user.lastname, user.firstname, user.username
176 176
                 FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
177 177
 				WHERE
178 178
 				    session_rcru.user_id = user.user_id AND
179 179
 				    session_rcru.session_id = '".intval($sessionId)."' AND
180 180
 				    session_rcru.c_id ='".intval($course->getId())."' AND
181 181
 				    session_rcru.status=2";
182
-		$rs = Database::query($sql);
182
+        $rs = Database::query($sql);
183 183
 
184
-		$coachs = array();
185
-		if (Database::num_rows($rs) > 0) {
186
-			while($info_coach = Database::fetch_array($rs)) {
184
+        $coachs = array();
185
+        if (Database::num_rows($rs) > 0) {
186
+            while($info_coach = Database::fetch_array($rs)) {
187 187
                 $coachs[] = api_get_person_name(
188 188
                         $info_coach['firstname'],
189 189
                         $info_coach['lastname']
190 190
                     ).' ('.$info_coach['username'].')';
191
-			}
192
-		} else {
193
-			$coach = get_lang('None');
194
-		}
191
+            }
192
+        } else {
193
+            $coach = get_lang('None');
194
+        }
195 195
 
196
-		if (count($coachs) > 0) {
197
-			$coach = implode('<br />',$coachs);
198
-		} else {
199
-			$coach = get_lang('None');
200
-		}
196
+        if (count($coachs) > 0) {
197
+            $coach = implode('<br />',$coachs);
198
+        } else {
199
+            $coach = get_lang('None');
200
+        }
201 201
 
202 202
         $orderButtons = null;
203 203
 
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 
234 234
         $courseUrl = api_get_course_url($course->getCode(), $sessionId);
235 235
 
236
-		// hide_course_breadcrumb the parameter has been added to hide the name
237
-		// of the course, that appeared in the default $interbreadcrumb
236
+        // hide_course_breadcrumb the parameter has been added to hide the name
237
+        // of the course, that appeared in the default $interbreadcrumb
238 238
         $courseItem .= '
239 239
 		<tr>
240 240
 			<td class="title">'.Display::url(
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 			</td>
261 261
 		</tr>';
262 262
         $count++;
263
-	}
263
+    }
264 264
     $courseListToShow .= $courseItem;
265 265
 }
266 266
 $courseListToShow .= '</table><br />';
Please login to merge, or discard this patch.
main/session/add_users_to_session.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 $add_type = 'unique';
39 39
 
40 40
 if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
41
-	$add_type = Security::remove_XSS($_REQUEST['add_type']);
41
+    $add_type = Security::remove_XSS($_REQUEST['add_type']);
42 42
 }
43 43
 
44 44
 $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null;
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 
409 409
     if ($use_extra_fields) {
410 410
         $final_result = array();
411
-       	if (count($extra_field_result)>1) {
412
-	    for($i=0;$i<count($extra_field_result)-1;$i++) {
411
+            if (count($extra_field_result)>1) {
412
+        for($i=0;$i<count($extra_field_result)-1;$i++) {
413 413
                 if (is_array($extra_field_result[$i+1])) {
414 414
                     $final_result  = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]);
415 415
                 }
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
                 'official_code' => $user['official_code']
486 486
             ) ;
487 487
             unset($users[$uid]);
488
-	}
488
+    }
489 489
     }
490 490
     unset($users); //clean to free memory
491 491
 
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
 }
530 530
 
531 531
 if ($add_type == 'multiple') {
532
-	$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.
532
+    $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.
533 533
         Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
534
-	$link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), '');
534
+    $link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), '');
535 535
 } else {
536
-	$link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), '');
537
-	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
536
+    $link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), '');
537
+    $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
538 538
 }
539 539
 $link_add_group = Display::url(
540 540
     Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups'),
@@ -562,30 +562,30 @@  discard block
 block discarded – undo
562 562
 <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
563 563
 <?php
564 564
 if ($add_type=='multiple') {
565
-	if (is_array($extra_field_list)) {
566
-		if (is_array($new_field_list) && count($new_field_list)>0 ) {
567
-			echo '<h3>'.get_lang('FilterUsers').'</h3>';
568
-			foreach ($new_field_list as $new_field) {
569
-				echo $new_field['name'];
570
-				$varname = 'field_'.$new_field['variable'];
571
-				echo '&nbsp;<select name="'.$varname.'">';
572
-				echo '<option value="0">--'.get_lang('Select').'--</option>';
573
-				foreach	($new_field['data'] as $option) {
574
-					$checked='';
575
-					if (isset($_POST[$varname])) {
576
-						if ($_POST[$varname]==$option[1]) {
577
-							$checked = 'selected="true"';
578
-						}
579
-					}
580
-					echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
581
-				}
582
-				echo '</select>';
583
-				echo '&nbsp;&nbsp;';
584
-			}
585
-			echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
586
-			echo '<br /><br />';
587
-		}
588
-	}
565
+    if (is_array($extra_field_list)) {
566
+        if (is_array($new_field_list) && count($new_field_list)>0 ) {
567
+            echo '<h3>'.get_lang('FilterUsers').'</h3>';
568
+            foreach ($new_field_list as $new_field) {
569
+                echo $new_field['name'];
570
+                $varname = 'field_'.$new_field['variable'];
571
+                echo '&nbsp;<select name="'.$varname.'">';
572
+                echo '<option value="0">--'.get_lang('Select').'--</option>';
573
+                foreach	($new_field['data'] as $option) {
574
+                    $checked='';
575
+                    if (isset($_POST[$varname])) {
576
+                        if ($_POST[$varname]==$option[1]) {
577
+                            $checked = 'selected="true"';
578
+                        }
579
+                    }
580
+                    echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
581
+                }
582
+                echo '</select>';
583
+                echo '&nbsp;&nbsp;';
584
+            }
585
+            echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
586
+            echo '<br /><br />';
587
+        }
588
+    }
589 589
 }
590 590
 ?>
591 591
 <input type="hidden" name="form_sent" value="1" />
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 
594 594
 <?php
595 595
 if (!empty($errorMsg)) {
596
-	Display::display_normal_message($errorMsg); //main API
596
+    Display::display_normal_message($errorMsg); //main API
597 597
 }
598 598
 ?>
599 599
 <div id="multiple-add-session" class="row">
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
             <label><?php echo get_lang('UserListInPlatform') ?> </label>
603 603
             <?php
604 604
             if (!($add_type=='multiple')) {
605
-              ?>
605
+                ?>
606 606
               <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" class="form-control" />
607 607
               <div id="ajax_list_users_single" class="select-list-ajax"></div>
608 608
               <?php
@@ -611,21 +611,21 @@  discard block
 block discarded – undo
611 611
             <div id="ajax_list_users_multiple">
612 612
             <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="form-control">
613 613
               <?php
614
-              foreach ($nosessionUsersList as $uid => $enreg) {
615
-              ?>
614
+                foreach ($nosessionUsersList as $uid => $enreg) {
615
+                ?>
616 616
                   <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>>
617 617
                       <?php
618
-                      $personName = api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code'];
619
-                      if ($showOfficialCode) {
620
-                          $officialCode = !empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - ';
621
-                          $personName = $officialCode.api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')';
622
-                      }
623
-                      echo $personName;
624
-                      ?>
618
+                        $personName = api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code'];
619
+                        if ($showOfficialCode) {
620
+                            $officialCode = !empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - ';
621
+                            $personName = $officialCode.api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')';
622
+                        }
623
+                        echo $personName;
624
+                        ?>
625 625
                   </option>
626 626
               <?php
627
-              }
628
-              ?>
627
+                }
628
+                ?>
629 629
             </select>
630 630
             </div>
631 631
                 <input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id">
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
             <?php
634 634
             }
635 635
             unset($nosessionUsersList);
636
-           ?>
636
+            ?>
637 637
         </div>
638 638
     </div>
639 639
 
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
               <?php
678 678
             }
679 679
             if (!empty($addProcess)) {
680
-		echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
680
+        echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
681 681
             } else {
682 682
                 echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>';
683 683
             }
Please login to merge, or discard this patch.
main/session/add_teachers_to_session.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -70,13 +70,13 @@
 block discarded – undo
70 70
     <tr>
71 71
         <td align="center">
72 72
             <?php
73
-             echo Display::select(
74
-                 'sessions[]',
75
-                 $sessionList,
76
-                 '',
77
-                 array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'sessions', 'size'=>'15px'),
78
-                 false
79
-             );
73
+                echo Display::select(
74
+                    'sessions[]',
75
+                    $sessionList,
76
+                    '',
77
+                    array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'sessions', 'size'=>'15px'),
78
+                    false
79
+                );
80 80
             ?>
81 81
         </td>
82 82
         <td align="center">
Please login to merge, or discard this patch.
main/session/session_category_edit.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 $sql = "SELECT * FROM $tbl_session_category WHERE id='".$id."' ORDER BY name";
30 30
 $result = Database::query($sql);
31 31
 if (!$infos = Database::fetch_array($result)) {
32
-	header('Location: session_list.php');
33
-	exit();
32
+    header('Location: session_list.php');
33
+    exit();
34 34
 }
35 35
 
36 36
 list($year_start,$month_start,$day_start)=explode('-',$infos['date_start']);
37 37
 list($year_end,$month_end,$day_end)=explode('-',$infos['date_end']);
38 38
 
39 39
 if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id'] && !api_is_session_admin()) {
40
-	api_not_allowed(true);
40
+    api_not_allowed(true);
41 41
 }
42 42
 
43 43
 if (isset($_POST['formSent']) && $_POST['formSent']) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $day_end
61 61
     );
62 62
     if ($return == strval(intval($return))) {
63
-		Display::addFlash(Display::return_message(get_lang('SessionCategoryUpdate')));
63
+        Display::addFlash(Display::return_message(get_lang('SessionCategoryUpdate')));
64 64
         header('Location: session_category_list.php');
65 65
         exit();
66 66
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 // display the header
74 74
 Display::display_header($tool_name);
75 75
 if (!empty($return)) {
76
-	Display::display_error_message($return,false);
76
+    Display::display_error_message($return,false);
77 77
 }
78 78
 ?>
79 79
 <div class="row">
Please login to merge, or discard this patch.