x Sorry, these patches are not available anymore due to data migration. Please run a fresh inspection.
Completed
Push — 1.10.x ( ac2491...356be2 )
by Angel Fernando Quiroz
227:50 queued 184:04
created
main/admin/ldap_import_students_to_session.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -53,93 +53,93 @@  discard block
 block discarded – undo
53 53
 //if ($annee == "" && $composante == "" && $etape == "") {
54 54
 if (empty($annee) && empty($id_session))
55 55
 {
56
-		Display::display_header($tool_name);
57
-		echo '<div style="align:center">';
58
-		echo Display::return_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')).' '.get_lang('LDAPSelectFilterOnUsersOU');
59
-		echo '<form method="get" action="'.api_get_self().'"><br />';
60
-		echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
61
-		echo '<input  type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"> ';
62
-		echo '<input type="submit" value="'.get_lang('Submit').'">';
63
-		echo '</form>';
64
-		echo '</div>';
56
+        Display::display_header($tool_name);
57
+        echo '<div style="align:center">';
58
+        echo Display::return_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')).' '.get_lang('LDAPSelectFilterOnUsersOU');
59
+        echo '<form method="get" action="'.api_get_self().'"><br />';
60
+        echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
61
+        echo '<input  type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"> ';
62
+        echo '<input type="submit" value="'.get_lang('Submit').'">';
63
+        echo '</form>';
64
+        echo '</div>';
65 65
 
66 66
 }
67 67
 elseif(!empty($annee) && empty($id_session))
68 68
 {
69
-	Display::display_header($tool_name);
70
-	echo '<div style="align:center">';
71
-	echo Display::return_icon(
72
-			'course.png',
73
-			get_lang('SelectSessionToImportUsersTo')).' '.get_lang('SelectSessionToImportUsersTo').'<br />';
74
-	echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
75
-	echo '<select name="id_session">';
76
-
77
-	$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
78
-	$sql = "SELECT id,name,nbr_courses,access_start_date,access_end_date " .
79
-		" FROM $tbl_session ".
80
-		" ORDER BY name";
81
-	$result = Database::query($sql);
82
-
83
-	$sessions=Database::store_result($result);
84
-	$nbr_results=count($sessions);
85
-	foreach($sessions as $row) {
86
-		echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name']).' ('.$row['access_start_date'].' - '.$row['access_end_date'].')</option>';
87
-	}
88
-	echo '</select>';
89
-	echo '<input type="submit" value="'.get_lang('Submit').'">';
90
-	echo '</form>';
91
-	echo '</div>';
69
+    Display::display_header($tool_name);
70
+    echo '<div style="align:center">';
71
+    echo Display::return_icon(
72
+            'course.png',
73
+            get_lang('SelectSessionToImportUsersTo')).' '.get_lang('SelectSessionToImportUsersTo').'<br />';
74
+    echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
75
+    echo '<select name="id_session">';
76
+
77
+    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
78
+    $sql = "SELECT id,name,nbr_courses,access_start_date,access_end_date " .
79
+        " FROM $tbl_session ".
80
+        " ORDER BY name";
81
+    $result = Database::query($sql);
82
+
83
+    $sessions=Database::store_result($result);
84
+    $nbr_results=count($sessions);
85
+    foreach($sessions as $row) {
86
+        echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name']).' ('.$row['access_start_date'].' - '.$row['access_end_date'].')</option>';
87
+    }
88
+    echo '</select>';
89
+    echo '<input type="submit" value="'.get_lang('Submit').'">';
90
+    echo '</form>';
91
+    echo '</div>';
92 92
 }
93 93
 // form4  annee != 0; composante != 0 etape != 0
94 94
 //elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') {
95 95
 elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed']))
96 96
 {
97
-	Display::display_header($tool_name);
98
-	echo '<div style="align: center;">';
99
-	echo '<br />';
100
-	echo '<br />';
101
-	echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
102
-	//echo "Connection ...";
103
-	$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
104
-	ldap_set_version($ds);
105
-
106
-	if ($ds) {
107
-
108
-		$r = false;
109
-		$res = ldap_handle_bind($ds, $r);
110
-
111
-		//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
112
-		//echo "(ou=*$annee,ou=$composante)";
113
-		$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
114
-
115
-		$info = ldap_get_entries($ds, $sr);
116
-
117
-		for ($key = 0; $key < $info["count"]; $key ++) {
118
-			$nom_form[] = $info[$key]["sn"][0];
119
-			$prenom_form[] = $info[$key]["givenname"][0];
120
-			$email_form[] = $info[$key]["mail"][0];
121
-			// Get uid from dn
122
-			//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
123
-			//$username_form[] = $dn_array[0]; // uid is first key
124
-			$username_form[] = $info[$key]['uid'][0];
125
-			$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
126
-			//$val = ldap_get_values_len($ds, $entry, "userPassword");
127
-			//$password_form[] = $val[0];
128
-			$password_form[] = $info[$key]['userPassword'][0];
129
-		}
130
-		ldap_unbind($ds);
131
-
132
-		/*-----------------------------------------------*/
133
-
134
-		asort($nom_form);
135
-		reset($nom_form);
136
-
137
-		$statut=5;
138
-		include ('ldap_form_add_users_group.php');
139
-	} else {
140
-		echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
141
-	}
142
-	echo '<br /><br />';
97
+    Display::display_header($tool_name);
98
+    echo '<div style="align: center;">';
99
+    echo '<br />';
100
+    echo '<br />';
101
+    echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
102
+    //echo "Connection ...";
103
+    $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
104
+    ldap_set_version($ds);
105
+
106
+    if ($ds) {
107
+
108
+        $r = false;
109
+        $res = ldap_handle_bind($ds, $r);
110
+
111
+        //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
112
+        //echo "(ou=*$annee,ou=$composante)";
113
+        $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
114
+
115
+        $info = ldap_get_entries($ds, $sr);
116
+
117
+        for ($key = 0; $key < $info["count"]; $key ++) {
118
+            $nom_form[] = $info[$key]["sn"][0];
119
+            $prenom_form[] = $info[$key]["givenname"][0];
120
+            $email_form[] = $info[$key]["mail"][0];
121
+            // Get uid from dn
122
+            //$dn_array=ldap_explode_dn($info[$key]["dn"],1);
123
+            //$username_form[] = $dn_array[0]; // uid is first key
124
+            $username_form[] = $info[$key]['uid'][0];
125
+            $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
126
+            //$val = ldap_get_values_len($ds, $entry, "userPassword");
127
+            //$password_form[] = $val[0];
128
+            $password_form[] = $info[$key]['userPassword'][0];
129
+        }
130
+        ldap_unbind($ds);
131
+
132
+        /*-----------------------------------------------*/
133
+
134
+        asort($nom_form);
135
+        reset($nom_form);
136
+
137
+        $statut=5;
138
+        include ('ldap_form_add_users_group.php');
139
+    } else {
140
+        echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
141
+    }
142
+    echo '<br /><br />';
143 143
     echo '<a href="ldap_import_students.php?annee=">'.get_lang('BackToNewSearch').'</a>';
144 144
     echo '<br /><br />';
145 145
     echo '</div>';
@@ -147,23 +147,23 @@  discard block
 block discarded – undo
147 147
 }
148 148
 elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed']=='yes'))
149 149
 {
150
-	$id=$_POST['username_form'];
151
-	$UserList=array();
152
-	$userid_match_login = array();
153
-	foreach ($id as $form_index=>$user_id)
154
-	{
155
-		if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
156
-		{
157
-			$tmp = ldap_add_user($user_id);
158
-			$UserList[]= $tmp;
159
-			$userid_match_login[$tmp] = $user_id;
160
-		}
161
-	}
162
-	if (!empty($_POST['id_session'])) {
163
-		$num = 0;
164
-		$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
165
-		$tbl_session	  = Database::get_main_table(TABLE_MAIN_SESSION);
166
-		foreach ($UserList as $user_id) {
150
+    $id=$_POST['username_form'];
151
+    $UserList=array();
152
+    $userid_match_login = array();
153
+    foreach ($id as $form_index=>$user_id)
154
+    {
155
+        if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
156
+        {
157
+            $tmp = ldap_add_user($user_id);
158
+            $UserList[]= $tmp;
159
+            $userid_match_login[$tmp] = $user_id;
160
+        }
161
+    }
162
+    if (!empty($_POST['id_session'])) {
163
+        $num = 0;
164
+        $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
165
+        $tbl_session	  = Database::get_main_table(TABLE_MAIN_SESSION);
166
+        foreach ($UserList as $user_id) {
167 167
                     $res_user = Database::insert(
168 168
                         $tbl_session_user,
169 169
                         [
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
                     if ($res_user !== false) {
176 176
                         $num++;
177 177
                     }
178
-		}
179
-
180
-		if($num>0) {
181
-			$sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session);
182
-			$res = Database::query($sql);
183
-		}
184
-		header('Location: resume_session.php?id_session='.Security::remove_XSS($_POST['id_session']));
185
-	}
186
-	/*
178
+        }
179
+
180
+        if($num>0) {
181
+            $sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session);
182
+            $res = Database::query($sql);
183
+        }
184
+        header('Location: resume_session.php?id_session='.Security::remove_XSS($_POST['id_session']));
185
+    }
186
+    /*
187 187
 	else
188 188
 	{
189 189
 		Display :: display_header($tool_name);
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 		Display :: display_normal_message($message,false);
203 203
 	}
204 204
 	*/
205
-	else
206
-	{
207
-		Display::display_header($tool_name);
208
-		$message=get_lang('NoUserAdded');
209
-		Display :: display_normal_message($message,false);
210
-	}
211
-	echo '<br /><br />';
205
+    else
206
+    {
207
+        Display::display_header($tool_name);
208
+        $message=get_lang('NoUserAdded');
209
+        Display :: display_normal_message($message,false);
210
+    }
211
+    echo '<br /><br />';
212 212
     echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
213 213
     echo '<br /><br />';
214 214
 }
Please login to merge, or discard this patch.
main/admin/ldap_import_students.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
 //if ($annee == "" && $composante == "" && $etape == "") {
57 57
 if (empty($annee) && empty($course))
58 58
 {
59
-		Display::display_header($tool_name);
60
-		echo '<div style="align:center">';
61
-		Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU'));
62
-		echo get_lang('LDAPSelectFilterOnUsersOU');
63
-		//echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />';
64
-		///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />';
65
-
66
-		echo '<form method="get" action="'.api_get_self().'"><br />';
67
-		echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
68
-		echo '<input  type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />';
69
-		echo '<input type="submit" value="'.get_lang('Submit').'">';
70
-		echo '</form>';
71
-		echo '</div>';
59
+        Display::display_header($tool_name);
60
+        echo '<div style="align:center">';
61
+        Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU'));
62
+        echo get_lang('LDAPSelectFilterOnUsersOU');
63
+        //echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />';
64
+        ///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />';
65
+
66
+        echo '<form method="get" action="'.api_get_self().'"><br />';
67
+        echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
68
+        echo '<input  type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />';
69
+        echo '<input type="submit" value="'.get_lang('Submit').'">';
70
+        echo '</form>';
71
+        echo '</div>';
72 72
 
73 73
 }
74 74
 /*
@@ -200,71 +200,71 @@  discard block
 block discarded – undo
200 200
 */
201 201
 elseif(!empty($annee) && empty($course))
202 202
 {
203
-	Display::display_header($tool_name);
204
-	echo '<div style="align:center">';
205
-	echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />';
206
-	echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
207
-	echo '<select name="course">';
208
-	$courses = CourseManager::get_courses_list();
209
-	foreach($courses as $row)
210
-	{
211
-		echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
212
-	}
213
-	echo '</select>';
214
-	echo '<input type="submit" value="'.get_lang('Submit').'">';
215
-	echo '</form>';
216
-	echo '</div>';
203
+    Display::display_header($tool_name);
204
+    echo '<div style="align:center">';
205
+    echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />';
206
+    echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
207
+    echo '<select name="course">';
208
+    $courses = CourseManager::get_courses_list();
209
+    foreach($courses as $row)
210
+    {
211
+        echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
212
+    }
213
+    echo '</select>';
214
+    echo '<input type="submit" value="'.get_lang('Submit').'">';
215
+    echo '</form>';
216
+    echo '</div>';
217 217
 }
218 218
 // form4  annee != 0; composante != 0 etape != 0
219 219
 //elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') {
220 220
 elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed']))
221 221
 {
222
-	Display::display_header($tool_name);
223
-	echo '<div style="align: center;">';
224
-	echo '<br />';
225
-	echo '<br />';
226
-	echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
227
-	//echo "Connection ...";
228
-	$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
229
-	ldap_set_version($ds);
230
-
231
-	if ($ds) {
232
-
233
-		$r = false;
234
-		$res = ldap_handle_bind($ds, $r);
235
-
236
-		//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
237
-		//echo "(ou=*$annee,ou=$composante)";
238
-		$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
239
-
240
-		$info = ldap_get_entries($ds, $sr);
241
-
242
-		for ($key = 0; $key < $info["count"]; $key ++) {
243
-			$nom_form[] = $info[$key]["sn"][0];
244
-			$prenom_form[] = $info[$key]["givenname"][0];
245
-			$email_form[] = $info[$key]["mail"][0];
246
-			// Get uid from dn
247
-			//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
248
-			//$username_form[] = $dn_array[0]; // uid is first key
249
-			$username_form[] = $info[$key]['uid'][0];
250
-			$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
251
-			//$val = ldap_get_values_len($ds, $entry, "userPassword");
252
-			//$password_form[] = $val[0];
253
-			$password_form[] = $info[$key]['userPassword'][0];
254
-		}
255
-		ldap_unbind($ds);
256
-
257
-		/*-----------------------------------------------*/
258
-
259
-		asort($nom_form);
260
-		reset($nom_form);
261
-
262
-		$statut=5;
263
-		include ('ldap_form_add_users_group.php');
264
-	} else {
265
-		echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
266
-	}
267
-	echo '<br /><br />';
222
+    Display::display_header($tool_name);
223
+    echo '<div style="align: center;">';
224
+    echo '<br />';
225
+    echo '<br />';
226
+    echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
227
+    //echo "Connection ...";
228
+    $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
229
+    ldap_set_version($ds);
230
+
231
+    if ($ds) {
232
+
233
+        $r = false;
234
+        $res = ldap_handle_bind($ds, $r);
235
+
236
+        //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
237
+        //echo "(ou=*$annee,ou=$composante)";
238
+        $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
239
+
240
+        $info = ldap_get_entries($ds, $sr);
241
+
242
+        for ($key = 0; $key < $info["count"]; $key ++) {
243
+            $nom_form[] = $info[$key]["sn"][0];
244
+            $prenom_form[] = $info[$key]["givenname"][0];
245
+            $email_form[] = $info[$key]["mail"][0];
246
+            // Get uid from dn
247
+            //$dn_array=ldap_explode_dn($info[$key]["dn"],1);
248
+            //$username_form[] = $dn_array[0]; // uid is first key
249
+            $username_form[] = $info[$key]['uid'][0];
250
+            $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
251
+            //$val = ldap_get_values_len($ds, $entry, "userPassword");
252
+            //$password_form[] = $val[0];
253
+            $password_form[] = $info[$key]['userPassword'][0];
254
+        }
255
+        ldap_unbind($ds);
256
+
257
+        /*-----------------------------------------------*/
258
+
259
+        asort($nom_form);
260
+        reset($nom_form);
261
+
262
+        $statut=5;
263
+        include ('ldap_form_add_users_group.php');
264
+    } else {
265
+        echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
266
+    }
267
+    echo '<br /><br />';
268 268
     echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
269 269
     echo '<br /><br />';
270 270
     echo '</div>';
@@ -272,27 +272,27 @@  discard block
 block discarded – undo
272 272
 }
273 273
 elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes'))
274 274
 {
275
-	$id=$_POST['username_form'];
276
-	$UserList=array();
277
-	$userid_match_login = array();
278
-	foreach ($id as $form_index=>$user_id)
279
-	{
280
-		if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
281
-		{
282
-			$tmp = ldap_add_user($user_id);
283
-			$UserList[]= $tmp;
284
-			$userid_match_login[$tmp] = $user_id;
285
-		}
286
-	}
287
-	if (!empty($_POST['course']))
288
-	{
289
-		foreach($UserList as $user_id)
290
-		{
291
-			CourseManager::add_user_to_course($user_id,$_POST['course']);
292
-		}
293
-		header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
294
-	}
295
-	/*
275
+    $id=$_POST['username_form'];
276
+    $UserList=array();
277
+    $userid_match_login = array();
278
+    foreach ($id as $form_index=>$user_id)
279
+    {
280
+        if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
281
+        {
282
+            $tmp = ldap_add_user($user_id);
283
+            $UserList[]= $tmp;
284
+            $userid_match_login[$tmp] = $user_id;
285
+        }
286
+    }
287
+    if (!empty($_POST['course']))
288
+    {
289
+        foreach($UserList as $user_id)
290
+        {
291
+            CourseManager::add_user_to_course($user_id,$_POST['course']);
292
+        }
293
+        header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
294
+    }
295
+    /*
296 296
 	else
297 297
 	{
298 298
 		Display :: display_header($tool_name);
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
 		Display :: display_normal_message($message,false);
312 312
 	}
313 313
 	*/
314
-	else
315
-	{
316
-		Display::display_header($tool_name);
317
-		$message=get_lang('NoUserAdded');
318
-		Display :: display_normal_message($message,false);
319
-	}
320
-	echo '<br /><br />';
314
+    else
315
+    {
316
+        Display::display_header($tool_name);
317
+        $message=get_lang('NoUserAdded');
318
+        Display :: display_normal_message($message,false);
319
+    }
320
+    echo '<br /><br />';
321 321
     echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
322 322
     echo '<br /><br />';
323 323
 }
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 1 patch
Indentation   +862 added lines, -862 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
                     $extend_link = '';
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
314
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
             case 'last_30_days':
1320 1320
                 $new_date = date('Y-m-d H:i:s', strtotime('-30 day'));
1321 1321
                 $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") ';
1322
-               break;
1322
+                break;
1323 1323
             case 'custom':
1324 1324
                 if (!empty($start_date) && !empty($end_date)) {
1325 1325
                     $start_date = Database::escape_string($start_date);
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
                 break;
1330 1330
         }
1331 1331
 
1332
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1332
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1333 1333
     	        FROM '.$tbl_track_login.'
1334 1334
                 WHERE '.$userCondition.$condition_time;
1335
-    	$rs = Database::query($sql);
1335
+        $rs = Database::query($sql);
1336 1336
         $row = Database::fetch_array($rs, 'ASSOC');
1337 1337
         $diff = $row['diff'];
1338 1338
 
@@ -1354,18 +1354,18 @@  discard block
 block discarded – undo
1354 1354
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1355 1355
     {
1356 1356
         $courseId = intval($courseId);
1357
-    	$session_id  = intval($session_id);
1358
-
1359
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360
-    	if (is_array($user_id)) {
1361
-    	    $user_id = array_map('intval', $user_id);
1362
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1363
-    	} else {
1364
-    		$user_id = intval($user_id);
1365
-    		$condition_user = " AND user_id = $user_id ";
1366
-    	}
1367
-
1368
-    	$sql = "SELECT
1357
+        $session_id  = intval($session_id);
1358
+
1359
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360
+        if (is_array($user_id)) {
1361
+            $user_id = array_map('intval', $user_id);
1362
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1363
+        } else {
1364
+            $user_id = intval($user_id);
1365
+            $condition_user = " AND user_id = $user_id ";
1366
+        }
1367
+
1368
+        $sql = "SELECT
1369 1369
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1370 1370
                 FROM $tbl_track_course
1371 1371
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1381,9 +1381,9 @@  discard block
 block discarded – undo
1381 1381
         $sql .= $condition_user;
1382 1382
 
1383 1383
         $rs = Database::query($sql);
1384
-    	$row = Database::fetch_array($rs);
1384
+        $row = Database::fetch_array($rs);
1385 1385
 
1386
-    	return $row['nb_seconds'];
1386
+        return $row['nb_seconds'];
1387 1387
     }
1388 1388
 
1389 1389
     /**
@@ -1394,25 +1394,25 @@  discard block
 block discarded – undo
1394 1394
      */
1395 1395
     public static function get_first_connection_date($student_id)
1396 1396
     {
1397
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398
-    	$sql = 'SELECT login_date
1397
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398
+        $sql = 'SELECT login_date
1399 1399
     	        FROM ' . $tbl_track_login . '
1400 1400
                 WHERE login_user_id = ' . intval($student_id) . '
1401 1401
                 ORDER BY login_date ASC
1402 1402
                 LIMIT 0,1';
1403 1403
 
1404
-    	$rs = Database::query($sql);
1405
-    	if (Database::num_rows($rs)>0) {
1406
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1404
+        $rs = Database::query($sql);
1405
+        if (Database::num_rows($rs)>0) {
1406
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1407 1407
                 return api_convert_and_format_date(
1408 1408
                     $first_login_date,
1409 1409
                     DATE_FORMAT_SHORT,
1410 1410
                     date_default_timezone_get()
1411 1411
                 );
1412
-    		}
1413
-    	}
1412
+            }
1413
+        }
1414 1414
 
1415
-    	return false;
1415
+        return false;
1416 1416
     }
1417 1417
 
1418 1418
     /**
@@ -1425,38 +1425,38 @@  discard block
 block discarded – undo
1425 1425
      */
1426 1426
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1427 1427
     {
1428
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429
-    	$sql = 'SELECT login_date
1428
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429
+        $sql = 'SELECT login_date
1430 1430
     	        FROM ' . $table . '
1431 1431
                 WHERE login_user_id = ' . intval($student_id) . '
1432 1432
                 ORDER BY login_date
1433 1433
                 DESC LIMIT 0,1';
1434 1434
 
1435
-    	$rs = Database::query($sql);
1436
-    	if (Database::num_rows($rs) > 0) {
1437
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1438
-    			$last_login_date = api_get_local_time($last_login_date);
1439
-    			if ($return_timestamp) {
1440
-    				return api_strtotime($last_login_date,'UTC');
1441
-    			} else {
1442
-    				if (!$warning_message) {
1443
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444
-    				} else {
1445
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1446
-    					$currentTimestamp = time();
1447
-
1448
-    					//If the last connection is > than 7 days, the text is red
1449
-    					//345600 = 7 days in seconds
1450
-    					if ($currentTimestamp - $timestamp > 604800) {
1451
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1452
-    					} else {
1453
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454
-    					}
1455
-    				}
1456
-    			}
1457
-    		}
1458
-    	}
1459
-    	return false;
1435
+        $rs = Database::query($sql);
1436
+        if (Database::num_rows($rs) > 0) {
1437
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1438
+                $last_login_date = api_get_local_time($last_login_date);
1439
+                if ($return_timestamp) {
1440
+                    return api_strtotime($last_login_date,'UTC');
1441
+                } else {
1442
+                    if (!$warning_message) {
1443
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444
+                    } else {
1445
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1446
+                        $currentTimestamp = time();
1447
+
1448
+                        //If the last connection is > than 7 days, the text is red
1449
+                        //345600 = 7 days in seconds
1450
+                        if ($currentTimestamp - $timestamp > 604800) {
1451
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1452
+                        } else {
1453
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454
+                        }
1455
+                    }
1456
+                }
1457
+            }
1458
+        }
1459
+        return false;
1460 1460
     }
1461 1461
 
1462 1462
     /**
@@ -1510,30 +1510,30 @@  discard block
 block discarded – undo
1510 1510
         $session_id = 0,
1511 1511
         $convert_date = true
1512 1512
     ) {
1513
-    	$student_id  = intval($student_id);
1513
+        $student_id  = intval($student_id);
1514 1514
         $courseId = intval($courseId);
1515
-    	$session_id  = intval($session_id);
1515
+        $session_id  = intval($session_id);
1516 1516
 
1517
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1518
-    	$sql = 'SELECT login_course_date
1517
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1518
+        $sql = 'SELECT login_course_date
1519 1519
     	        FROM '.$tbl_track_login.'
1520 1520
                 WHERE
1521 1521
                     user_id = '.$student_id.' AND
1522 1522
                     c_id = '.$courseId.' AND
1523 1523
                     session_id = '.$session_id.'
1524 1524
                 ORDER BY login_course_date ASC LIMIT 0,1';
1525
-    	$rs = Database::query($sql);
1526
-    	if (Database::num_rows($rs) > 0) {
1527
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1528
-    			if ($convert_date) {
1529
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1530
-    			} else {
1531
-    				return $first_login_date;
1532
-    			}
1533
-    		}
1534
-    	}
1535
-
1536
-    	return false;
1525
+        $rs = Database::query($sql);
1526
+        if (Database::num_rows($rs) > 0) {
1527
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1528
+                if ($convert_date) {
1529
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1530
+                } else {
1531
+                    return $first_login_date;
1532
+                }
1533
+            }
1534
+        }
1535
+
1536
+        return false;
1537 1537
     }
1538 1538
 
1539 1539
     /**
@@ -1549,13 +1549,13 @@  discard block
 block discarded – undo
1549 1549
         $session_id = 0,
1550 1550
         $convert_date = true
1551 1551
     ) {
1552
-    	// protect data
1553
-    	$student_id  = intval($student_id);
1552
+        // protect data
1553
+        $student_id  = intval($student_id);
1554 1554
         $courseId = $courseInfo['real_id'];
1555
-    	$session_id  = intval($session_id);
1555
+        $session_id  = intval($session_id);
1556 1556
 
1557
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1558
-    	$sql = 'SELECT access_date
1557
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1558
+        $sql = 'SELECT access_date
1559 1559
                 FROM '.$tbl_track_e_access.'
1560 1560
                 WHERE   access_user_id = '.$student_id.' AND
1561 1561
                         c_id = "'.$courseId.'" AND
@@ -1563,39 +1563,39 @@  discard block
 block discarded – undo
1563 1563
                 ORDER BY access_date DESC
1564 1564
                 LIMIT 0,1';
1565 1565
 
1566
-    	$rs = Database::query($sql);
1567
-    	if (Database::num_rows($rs) > 0) {
1568
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1566
+        $rs = Database::query($sql);
1567
+        if (Database::num_rows($rs) > 0) {
1568
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1569 1569
                 if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
1570 1570
                     return false;
1571 1571
                 }
1572 1572
                 //see #5736
1573 1573
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1574
-    			$now = time();
1575
-    			//If the last connection is > than 7 days, the text is red
1576
-    			//345600 = 7 days in seconds
1577
-    			if ($now - $last_login_date_timestamp > 604800) {
1578
-    				if ($convert_date) {
1574
+                $now = time();
1575
+                //If the last connection is > than 7 days, the text is red
1576
+                //345600 = 7 days in seconds
1577
+                if ($now - $last_login_date_timestamp > 604800) {
1578
+                    if ($convert_date) {
1579 1579
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1580 1580
                         $icon = api_is_allowed_to_edit() ?
1581 1581
                             '<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1582 1582
                               '.Display::return_icon('messagebox_warning.gif').'
1583 1583
                              </a>'
1584 1584
                             : null;
1585
-    					return $icon. Display::label($last_login_date, 'warning');
1586
-    				} else {
1587
-    					return $last_login_date;
1588
-    				}
1589
-    			} else {
1590
-    				if ($convert_date) {
1591
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1592
-    				} else {
1593
-    					return $last_login_date;
1594
-    				}
1595
-    			}
1596
-    		}
1597
-    	}
1598
-    	return false;
1585
+                        return $icon. Display::label($last_login_date, 'warning');
1586
+                    } else {
1587
+                        return $last_login_date;
1588
+                    }
1589
+                } else {
1590
+                    if ($convert_date) {
1591
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1592
+                    } else {
1593
+                        return $last_login_date;
1594
+                    }
1595
+                }
1596
+            }
1597
+        }
1598
+        return false;
1599 1599
     }
1600 1600
 
1601 1601
     /**
@@ -1608,36 +1608,36 @@  discard block
 block discarded – undo
1608 1608
      */
1609 1609
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1610 1610
     {
1611
-    	if ($start < 0) {
1612
-    		$start = 0;
1613
-    	}
1614
-    	if (!isset($stop) or ($stop < 0)) {
1615
-    		$stop = api_get_utc_datetime();
1616
-    	}
1611
+        if ($start < 0) {
1612
+            $start = 0;
1613
+        }
1614
+        if (!isset($stop) or ($stop < 0)) {
1615
+            $stop = api_get_utc_datetime();
1616
+        }
1617 1617
 
1618 1618
         $start = Database::escape_string($start);
1619 1619
         $stop = Database::escape_string($stop);
1620 1620
 
1621
-    	$month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1621
+        $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1622 1622
 
1623 1623
         $courseId = intval($courseId);
1624
-    	$session_id  = intval($session_id);
1625
-    	$count = 0;
1624
+        $session_id  = intval($session_id);
1625
+        $count = 0;
1626 1626
 
1627
-    	$tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1628
-    	$sql = "SELECT count(*) as count_connections
1627
+        $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1628
+        $sql = "SELECT count(*) as count_connections
1629 1629
                 FROM $tbl_track_e_course_access
1630 1630
                 WHERE
1631 1631
                     c_id = $courseId AND
1632 1632
                     session_id = $session_id
1633 1633
                     $month_filter";
1634
-    	$rs = Database::query($sql);
1635
-    	if (Database::num_rows($rs)>0) {
1636
-    		$row = Database::fetch_object($rs);
1637
-    		$count = $row->count_connections;
1638
-    	}
1634
+        $rs = Database::query($sql);
1635
+        if (Database::num_rows($rs)>0) {
1636
+            $row = Database::fetch_object($rs);
1637
+            $count = $row->count_connections;
1638
+        }
1639 1639
 
1640
-    	return $count;
1640
+        return $count;
1641 1641
     }
1642 1642
 
1643 1643
     /**
@@ -1648,25 +1648,25 @@  discard block
 block discarded – undo
1648 1648
      */
1649 1649
     public static function count_course_per_student($user_id, $include_sessions = true)
1650 1650
     {
1651
-    	$user_id = intval($user_id);
1652
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1653
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1651
+        $user_id = intval($user_id);
1652
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1653
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1654 1654
 
1655
-    	$sql = 'SELECT DISTINCT c_id
1655
+        $sql = 'SELECT DISTINCT c_id
1656 1656
                 FROM ' . $tbl_course_rel_user . '
1657 1657
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1658
-    	$rs = Database::query($sql);
1659
-    	$nb_courses = Database::num_rows($rs);
1658
+        $rs = Database::query($sql);
1659
+        $nb_courses = Database::num_rows($rs);
1660 1660
 
1661
-    	if ($include_sessions) {
1662
-    		$sql = 'SELECT DISTINCT c_id
1661
+        if ($include_sessions) {
1662
+            $sql = 'SELECT DISTINCT c_id
1663 1663
                     FROM ' . $tbl_session_course_rel_user . '
1664 1664
                     WHERE user_id = ' . $user_id;
1665
-    		$rs = Database::query($sql);
1666
-    		$nb_courses += Database::num_rows($rs);
1667
-    	}
1665
+            $rs = Database::query($sql);
1666
+            $nb_courses += Database::num_rows($rs);
1667
+        }
1668 1668
 
1669
-    	return $nb_courses;
1669
+        return $nb_courses;
1670 1670
     }
1671 1671
 
1672 1672
     /**
@@ -1697,25 +1697,25 @@  discard block
 block discarded – undo
1697 1697
         $into_lp = 0
1698 1698
     ) {
1699 1699
         $course_code = Database::escape_string($course_code);
1700
-    	$course_info = api_get_course_info($course_code);
1701
-    	if (!empty($course_info)) {
1702
-    		// table definition
1703
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1704
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1705
-
1706
-    		// Compose a filter based on optional exercise given
1707
-    		$condition_quiz = "";
1708
-    		if (!empty($exercise_id)) {
1709
-    			$exercise_id = intval($exercise_id);
1710
-    			$condition_quiz =" AND id = $exercise_id ";
1711
-    		}
1712
-
1713
-    		// Compose a filter based on optional session id given
1714
-    		$condition_session = "";
1715
-    		if (isset($session_id)) {
1716
-    			$session_id = intval($session_id);
1717
-    			$condition_session = " AND session_id = $session_id ";
1718
-    		}
1700
+        $course_info = api_get_course_info($course_code);
1701
+        if (!empty($course_info)) {
1702
+            // table definition
1703
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1704
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1705
+
1706
+            // Compose a filter based on optional exercise given
1707
+            $condition_quiz = "";
1708
+            if (!empty($exercise_id)) {
1709
+                $exercise_id = intval($exercise_id);
1710
+                $condition_quiz =" AND id = $exercise_id ";
1711
+            }
1712
+
1713
+            // Compose a filter based on optional session id given
1714
+            $condition_session = "";
1715
+            if (isset($session_id)) {
1716
+                $session_id = intval($session_id);
1717
+                $condition_session = " AND session_id = $session_id ";
1718
+            }
1719 1719
             if ($active_filter == 1) {
1720 1720
                 $condition_active = 'AND active <> -1';
1721 1721
             } elseif ($active_filter == 0) {
@@ -1731,25 +1731,25 @@  discard block
 block discarded – undo
1731 1731
                 $select_lp_id = ', orig_lp_id as lp_id ';
1732 1732
             }
1733 1733
 
1734
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1734
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1735 1735
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1736
-    		$count_quiz = Database::fetch_row(Database::query($sql));
1736
+            $count_quiz = Database::fetch_row(Database::query($sql));
1737 1737
 
1738
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1739
-    			if (is_array($student_id)) {
1738
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1739
+                if (is_array($student_id)) {
1740 1740
                     $student_id = array_map('intval', $student_id);
1741
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1742
-    			} else {
1741
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1742
+                } else {
1743 1743
                     $student_id = intval($student_id);
1744
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1745
-    			}
1744
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1745
+                }
1746 1746
 
1747
-    			if (empty($exercise_id)) {
1748
-    				$sql = "SELECT id FROM $tbl_course_quiz
1747
+                if (empty($exercise_id)) {
1748
+                    $sql = "SELECT id FROM $tbl_course_quiz
1749 1749
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1750 1750
                     $result = Database::query($sql);
1751 1751
                     $exercise_list = array();
1752
-    				$exercise_id = null;
1752
+                    $exercise_id = null;
1753 1753
                     if (Database::num_rows($result)) {
1754 1754
                         while ($row = Database::fetch_array($result)) {
1755 1755
                             $exercise_list[] = $row['id'];
@@ -1758,11 +1758,11 @@  discard block
 block discarded – undo
1758 1758
                     if (!empty($exercise_list)) {
1759 1759
                         $exercise_id = implode("','",$exercise_list);
1760 1760
                     }
1761
-    			}
1761
+                }
1762 1762
 
1763
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1763
+                $count_quiz = Database::fetch_row(Database::query($sql));
1764 1764
 
1765
-    			$sql = "SELECT
1765
+                $sql = "SELECT
1766 1766
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1767 1767
     			        COUNT(*) as num_attempts
1768 1768
     			        $select_lp_id
@@ -1776,20 +1776,20 @@  discard block
 block discarded – undo
1776 1776
                             $condition_into_lp
1777 1777
                         ORDER BY exe_date DESC";
1778 1778
 
1779
-    			$res = Database::query($sql);
1780
-    			$row = Database::fetch_array($res);
1781
-    			$quiz_avg_score = null;
1779
+                $res = Database::query($sql);
1780
+                $row = Database::fetch_array($res);
1781
+                $quiz_avg_score = null;
1782 1782
 
1783
-    			if (!empty($row['avg_score'])) {
1784
-    				$quiz_avg_score = round($row['avg_score'],2);
1785
-    			}
1783
+                if (!empty($row['avg_score'])) {
1784
+                    $quiz_avg_score = round($row['avg_score'],2);
1785
+                }
1786 1786
 
1787
-    			if(!empty($row['num_attempts'])) {
1788
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1789
-    			}
1790
-    			if (is_array($student_id)) {
1791
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1792
-    			}
1787
+                if(!empty($row['num_attempts'])) {
1788
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1789
+                }
1790
+                if (is_array($student_id)) {
1791
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1792
+                }
1793 1793
                 if ($into_lp == 0) {
1794 1794
                     return $quiz_avg_score;
1795 1795
                 } else {
@@ -1812,9 +1812,9 @@  discard block
 block discarded – undo
1812 1812
                         return array($quiz_avg_score, null);
1813 1813
                     }
1814 1814
                 }
1815
-    		}
1816
-    	}
1817
-    	return null;
1815
+            }
1816
+        }
1817
+        return null;
1818 1818
     }
1819 1819
 
1820 1820
     /**
@@ -1847,15 +1847,15 @@  discard block
 block discarded – undo
1847 1847
         $find_all_lp = 0
1848 1848
     ) {
1849 1849
         $courseId = intval($courseId);
1850
-    	$student_id  = intval($student_id);
1851
-    	$exercise_id = intval($exercise_id);
1852
-    	$session_id  = intval($session_id);
1850
+        $student_id  = intval($student_id);
1851
+        $exercise_id = intval($exercise_id);
1852
+        $session_id  = intval($session_id);
1853 1853
 
1854
-    	$lp_id = intval($lp_id);
1854
+        $lp_id = intval($lp_id);
1855 1855
         $lp_item_id = intval($lp_item_id);
1856
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1856
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1857 1857
 
1858
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1858
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1859 1859
                 WHERE  ex.c_id = $courseId
1860 1860
                 AND ex.exe_exo_id = $exercise_id
1861 1861
                 AND status = ''
@@ -1870,11 +1870,11 @@  discard block
 block discarded – undo
1870 1870
                 AND orig_lp_item_id = $lp_item_id";
1871 1871
         }
1872 1872
 
1873
-    	$rs = Database::query($sql);
1874
-    	$row = Database::fetch_row($rs);
1875
-    	$count_attempts = $row[0];
1873
+        $rs = Database::query($sql);
1874
+        $row = Database::fetch_row($rs);
1875
+        $count_attempts = $row[0];
1876 1876
 
1877
-    	return $count_attempts;
1877
+        return $count_attempts;
1878 1878
     }
1879 1879
 
1880 1880
     /**
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
      * @param int    $user_id
1885 1885
      * @param int    $courseId
1886 1886
      * @param int    $session_id
1887
-    */
1887
+     */
1888 1888
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1889 1889
     {
1890 1890
         $courseId = intval($courseId);
@@ -3500,8 +3500,8 @@  discard block
 block discarded – undo
3500 3500
 
3501 3501
         $condition_session = '';
3502 3502
         if (isset($session_id)) {
3503
-             $session_id = intval($session_id);
3504
-             $condition_session = ' AND f.session_id = '. $session_id;
3503
+                $session_id = intval($session_id);
3504
+                $condition_session = ' AND f.session_id = '. $session_id;
3505 3505
         }
3506 3506
 
3507 3507
         $groupId = intval($groupId);
@@ -5400,9 +5400,9 @@  discard block
 block discarded – undo
5400 5400
     }
5401 5401
 
5402 5402
     /**
5403
-    * @param FormValidator $form
5404
-    * @return mixed
5405
-    */
5403
+     * @param FormValidator $form
5404
+     * @return mixed
5405
+     */
5406 5406
     public static function setUserSearchForm($form)
5407 5407
     {
5408 5408
         global $_configuration;
@@ -5681,26 +5681,26 @@  discard block
 block discarded – undo
5681 5681
         $session_id = api_get_session_id();
5682 5682
         $course_id = api_get_course_int_id();
5683 5683
 
5684
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5685
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5684
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5685
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5686 5686
 
5687
-    	$sql = "SELECT count(tool) AS total_number_of_items
5687
+        $sql = "SELECT count(tool) AS total_number_of_items
5688 5688
     	        FROM $table_item_property track_resource, $table_user user
5689 5689
     	        WHERE
5690 5690
                     track_resource.c_id = $course_id AND
5691 5691
                     track_resource.insert_user_id = user.user_id AND
5692 5692
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5693 5693
 
5694
-    	if (isset($_GET['keyword'])) {
5695
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5696
-    		$sql .= " AND (
5694
+        if (isset($_GET['keyword'])) {
5695
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5696
+            $sql .= " AND (
5697 5697
     		            user.username LIKE '%".$keyword."%' OR
5698 5698
     		            lastedit_type LIKE '%".$keyword."%' OR
5699 5699
     		            tool LIKE '%".$keyword."%'
5700 5700
                     )";
5701
-    	}
5701
+        }
5702 5702
 
5703
-    	$sql .= " AND tool IN (
5703
+        $sql .= " AND tool IN (
5704 5704
     	            'document',
5705 5705
     	            'learnpath',
5706 5706
     	            'quiz',
@@ -5712,10 +5712,10 @@  discard block
 block discarded – undo
5712 5712
     	            'thematic_advance',
5713 5713
     	            'thematic_plan'
5714 5714
                 )";
5715
-    	$res = Database::query($sql);
5716
-    	$obj = Database::fetch_object($res);
5715
+        $res = Database::query($sql);
5716
+        $obj = Database::fetch_object($res);
5717 5717
 
5718
-    	return $obj->total_number_of_items;
5718
+        return $obj->total_number_of_items;
5719 5719
     }
5720 5720
 
5721 5721
     /**
@@ -5730,12 +5730,12 @@  discard block
 block discarded – undo
5730 5730
         $session_id = api_get_session_id();
5731 5731
         $course_id = api_get_course_int_id();
5732 5732
 
5733
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5734
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5735
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5736
-    	$session_id = intval($session_id);
5733
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5734
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5735
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5736
+        $session_id = intval($session_id);
5737 5737
 
5738
-    	$sql = "SELECT
5738
+        $sql = "SELECT
5739 5739
                     tool as col0,
5740 5740
                     lastedit_type as col1,
5741 5741
                     ref as ref,
@@ -5749,16 +5749,16 @@  discard block
 block discarded – undo
5749 5749
                   track_resource.insert_user_id = user.user_id AND
5750 5750
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5751 5751
 
5752
-    	if (isset($_GET['keyword'])) {
5753
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5754
-    		$sql .= " AND (
5752
+        if (isset($_GET['keyword'])) {
5753
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5754
+            $sql .= " AND (
5755 5755
     		            user.username LIKE '%".$keyword."%' OR
5756 5756
     		            lastedit_type LIKE '%".$keyword."%' OR
5757 5757
     		            tool LIKE '%".$keyword."%'
5758 5758
                      ) ";
5759
-    	}
5759
+        }
5760 5760
 
5761
-    	$sql .= " AND tool IN (
5761
+        $sql .= " AND tool IN (
5762 5762
     	            'document',
5763 5763
     	            'learnpath',
5764 5764
     	            'quiz',
@@ -5771,41 +5771,41 @@  discard block
 block discarded – undo
5771 5771
     	            'thematic_plan'
5772 5772
                 )";
5773 5773
 
5774
-    	if ($column == 0) {
5775
-    		$column = '0';
5776
-    	}
5777
-    	if ($column != '' && $direction != '') {
5778
-    		if ($column != 2 && $column != 4) {
5779
-    			$sql .= " ORDER BY col$column $direction";
5780
-    		}
5781
-    	} else {
5782
-    		$sql .= " ORDER BY col5 DESC ";
5783
-    	}
5774
+        if ($column == 0) {
5775
+            $column = '0';
5776
+        }
5777
+        if ($column != '' && $direction != '') {
5778
+            if ($column != 2 && $column != 4) {
5779
+                $sql .= " ORDER BY col$column $direction";
5780
+            }
5781
+        } else {
5782
+            $sql .= " ORDER BY col5 DESC ";
5783
+        }
5784 5784
 
5785 5785
         $from = intval($from);
5786 5786
         $number_of_items = intval($number_of_items);
5787 5787
 
5788
-    	$sql .= " LIMIT $from, $number_of_items ";
5789
-
5790
-    	$res = Database::query($sql);
5791
-    	$resources = array();
5792
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5793
-    	while ($row = Database::fetch_array($res)) {
5794
-    		$ref = $row['ref'];
5795
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5796
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5797
-
5798
-    		$id = $table_name['id_tool'];
5799
-    		$recorset = false;
5788
+        $sql .= " LIMIT $from, $number_of_items ";
5800 5789
 
5801
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5802
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5803
-    			$sql = "SELECT thematic_id FROM $table_tool
5790
+        $res = Database::query($sql);
5791
+        $resources = array();
5792
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5793
+        while ($row = Database::fetch_array($res)) {
5794
+            $ref = $row['ref'];
5795
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5796
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5797
+
5798
+            $id = $table_name['id_tool'];
5799
+            $recorset = false;
5800
+
5801
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5802
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5803
+                $sql = "SELECT thematic_id FROM $table_tool
5804 5804
     			        WHERE c_id = $course_id AND id = $ref";
5805
-    			$rs_thematic  = Database::query($sql);
5806
-    			if (Database::num_rows($rs_thematic)) {
5807
-    				$row_thematic = Database::fetch_array($rs_thematic);
5808
-    				$thematic_id = $row_thematic['thematic_id'];
5805
+                $rs_thematic  = Database::query($sql);
5806
+                if (Database::num_rows($rs_thematic)) {
5807
+                    $row_thematic = Database::fetch_array($rs_thematic);
5808
+                    $thematic_id = $row_thematic['thematic_id'];
5809 5809
 
5810 5810
                     $sql = "SELECT session.id, session.name, user.username
5811 5811
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5814,9 +5814,9 @@  discard block
 block discarded – undo
5814 5814
                               t.session_id = session.id AND
5815 5815
                               session.id_coach = user.user_id AND
5816 5816
                               t.id = $thematic_id";
5817
-    				$recorset = Database::query($sql);
5818
-    			}
5819
-    		} else {
5817
+                    $recorset = Database::query($sql);
5818
+                }
5819
+            } else {
5820 5820
                 $sql = "SELECT session.id, session.name, user.username
5821 5821
                           FROM $table_tool tool, $table_session session, $table_user user
5822 5822
     			          WHERE
@@ -5824,127 +5824,127 @@  discard block
 block discarded – undo
5824 5824
     			              tool.session_id = session.id AND
5825 5825
     			              session.id_coach = user.user_id AND
5826 5826
     			              tool.$id = $ref";
5827
-    			$recorset = Database::query($sql);
5828
-    		}
5829
-
5830
-    		if (!empty($recorset)) {
5831
-    			$obj = Database::fetch_object($recorset);
5832
-
5833
-    			$name_session = '';
5834
-    			$coach_name = '';
5835
-    			if (!empty($obj)) {
5836
-    				$name_session = $obj->name;
5837
-    				$coach_name   = $obj->username;
5838
-    			}
5839
-
5840
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5841
-    			$row[0] = '';
5842
-    			if ($row['col6'] != 2) {
5843
-    				if (in_array($row['col0'], $thematic_tools)) {
5844
-
5845
-    					$exp_thematic_tool = explode('_', $row['col0']);
5846
-    					$thematic_tool_title = '';
5847
-    					if (is_array($exp_thematic_tool)) {
5848
-    						foreach ($exp_thematic_tool as $exp) {
5849
-    							$thematic_tool_title .= api_ucfirst($exp);
5850
-    						}
5851
-    					} else {
5852
-    						$thematic_tool_title = api_ucfirst($row['col0']);
5853
-    					}
5854
-
5855
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5856
-    				} else {
5857
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5858
-    				}
5859
-    			} else {
5860
-    				$row[0] = api_ucfirst($row['col0']);
5861
-    			}
5862
-    			$row[1] = get_lang($row[1]);
5863
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5864
-    			$row[5] = '';
5865
-    			//@todo Improve this code please
5866
-    			switch ($table_name['table_name']) {
5867
-    				case 'document' :
5868
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5827
+                $recorset = Database::query($sql);
5828
+            }
5829
+
5830
+            if (!empty($recorset)) {
5831
+                $obj = Database::fetch_object($recorset);
5832
+
5833
+                $name_session = '';
5834
+                $coach_name = '';
5835
+                if (!empty($obj)) {
5836
+                    $name_session = $obj->name;
5837
+                    $coach_name   = $obj->username;
5838
+                }
5839
+
5840
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5841
+                $row[0] = '';
5842
+                if ($row['col6'] != 2) {
5843
+                    if (in_array($row['col0'], $thematic_tools)) {
5844
+
5845
+                        $exp_thematic_tool = explode('_', $row['col0']);
5846
+                        $thematic_tool_title = '';
5847
+                        if (is_array($exp_thematic_tool)) {
5848
+                            foreach ($exp_thematic_tool as $exp) {
5849
+                                $thematic_tool_title .= api_ucfirst($exp);
5850
+                            }
5851
+                        } else {
5852
+                            $thematic_tool_title = api_ucfirst($row['col0']);
5853
+                        }
5854
+
5855
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5856
+                    } else {
5857
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5858
+                    }
5859
+                } else {
5860
+                    $row[0] = api_ucfirst($row['col0']);
5861
+                }
5862
+                $row[1] = get_lang($row[1]);
5863
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5864
+                $row[5] = '';
5865
+                //@todo Improve this code please
5866
+                switch ($table_name['table_name']) {
5867
+                    case 'document' :
5868
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
5869 5869
                                 WHERE c_id = $course_id AND id = $ref";
5870
-    					$rs_document = Database::query($sql);
5871
-    					$obj_document = Database::fetch_object($rs_document);
5872
-    					$row[5] = $obj_document->title;
5870
+                        $rs_document = Database::query($sql);
5871
+                        $obj_document = Database::fetch_object($rs_document);
5872
+                        $row[5] = $obj_document->title;
5873 5873
 
5874
-    					break;
5875
-    				case 'announcement':
5874
+                        break;
5875
+                    case 'announcement':
5876 5876
                         $sql = "SELECT title FROM $table_tool
5877 5877
                                 WHERE c_id = $course_id AND id = $ref";
5878
-    					$rs_document = Database::query($sql);
5879
-    					$obj_document = Database::fetch_object($rs_document);
5878
+                        $rs_document = Database::query($sql);
5879
+                        $obj_document = Database::fetch_object($rs_document);
5880 5880
                         if ($obj_document) {
5881 5881
                             $row[5] = $obj_document->title;
5882 5882
                         }
5883
-    					break;
5884
-    				case 'glossary':
5883
+                        break;
5884
+                    case 'glossary':
5885 5885
                         $sql = "SELECT name FROM $table_tool
5886 5886
     					        WHERE c_id = $course_id AND glossary_id = $ref";
5887
-    					$rs_document = Database::query($sql);
5888
-    					$obj_document = Database::fetch_object($rs_document);
5887
+                        $rs_document = Database::query($sql);
5888
+                        $obj_document = Database::fetch_object($rs_document);
5889 5889
                         if ($obj_document) {
5890 5890
                             $row[5] = $obj_document->name;
5891 5891
                         }
5892
-    					break;
5893
-    				case 'lp':
5892
+                        break;
5893
+                    case 'lp':
5894 5894
                         $sql = "SELECT name
5895 5895
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
5896
-    					$rs_document = Database::query($sql);
5897
-    					$obj_document = Database::fetch_object($rs_document);
5898
-    					$row[5] = $obj_document->name;
5899
-    					break;
5900
-    				case 'quiz':
5896
+                        $rs_document = Database::query($sql);
5897
+                        $obj_document = Database::fetch_object($rs_document);
5898
+                        $row[5] = $obj_document->name;
5899
+                        break;
5900
+                    case 'quiz':
5901 5901
                         $sql = "SELECT title FROM $table_tool
5902 5902
                                 WHERE c_id = $course_id AND id = $ref";
5903
-    					$rs_document = Database::query($sql);
5904
-    					$obj_document = Database::fetch_object($rs_document);
5903
+                        $rs_document = Database::query($sql);
5904
+                        $obj_document = Database::fetch_object($rs_document);
5905 5905
                         if ($obj_document) {
5906 5906
                             $row[5] = $obj_document->title;
5907 5907
                         }
5908
-    					break;
5909
-    				case 'course_description':
5908
+                        break;
5909
+                    case 'course_description':
5910 5910
                         $sql = "SELECT title FROM $table_tool
5911 5911
                                 WHERE c_id = $course_id AND id = $ref";
5912
-    					$rs_document = Database::query($sql);
5913
-    					$obj_document = Database::fetch_object($rs_document);
5912
+                        $rs_document = Database::query($sql);
5913
+                        $obj_document = Database::fetch_object($rs_document);
5914 5914
                         if ($obj_document) {
5915 5915
                             $row[5] = $obj_document->title;
5916 5916
                         }
5917
-    					break;
5918
-    				case 'thematic':
5919
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5920
-    					if (Database::num_rows($rs) > 0) {
5921
-    						$obj = Database::fetch_object($rs);
5922
-    						$row[5] = $obj->title;
5923
-    					}
5924
-    					break;
5925
-    				case 'thematic_advance':
5926
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5927
-    					if (Database::num_rows($rs) > 0) {
5928
-    						$obj = Database::fetch_object($rs);
5929
-    						$row[5] = $obj->content;
5930
-    					}
5931
-    					break;
5932
-    				case 'thematic_plan':
5933
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5934
-    					if (Database::num_rows($rs) > 0) {
5935
-    						$obj = Database::fetch_object($rs);
5936
-    						$row[5] = $obj->title;
5937
-    					}
5938
-    					break;
5939
-    				default:
5940
-    					break;
5941
-    			}
5942
-
5943
-    			$row2 = $name_session;
5944
-    			if (!empty($coach_name)) {
5945
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
5946
-    			}
5947
-    			$row[2] = $row2;
5917
+                        break;
5918
+                    case 'thematic':
5919
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5920
+                        if (Database::num_rows($rs) > 0) {
5921
+                            $obj = Database::fetch_object($rs);
5922
+                            $row[5] = $obj->title;
5923
+                        }
5924
+                        break;
5925
+                    case 'thematic_advance':
5926
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5927
+                        if (Database::num_rows($rs) > 0) {
5928
+                            $obj = Database::fetch_object($rs);
5929
+                            $row[5] = $obj->content;
5930
+                        }
5931
+                        break;
5932
+                    case 'thematic_plan':
5933
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5934
+                        if (Database::num_rows($rs) > 0) {
5935
+                            $obj = Database::fetch_object($rs);
5936
+                            $row[5] = $obj->title;
5937
+                        }
5938
+                        break;
5939
+                    default:
5940
+                        break;
5941
+                }
5942
+
5943
+                $row2 = $name_session;
5944
+                if (!empty($coach_name)) {
5945
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
5946
+                }
5947
+                $row[2] = $row2;
5948 5948
                 if (!empty($row['col3'])) {
5949 5949
                     $userInfo = api_get_user_info($row['user_id']);
5950 5950
 
@@ -5961,11 +5961,11 @@  discard block
 block discarded – undo
5961 5961
                     $row[4] = $ip;
5962 5962
                 }
5963 5963
 
5964
-    			$resources[] = $row;
5965
-    		}
5966
-    	}
5964
+                $resources[] = $row;
5965
+            }
5966
+        }
5967 5967
 
5968
-    	return $resources;
5968
+        return $resources;
5969 5969
     }
5970 5970
 
5971 5971
     /**
@@ -5975,63 +5975,63 @@  discard block
 block discarded – undo
5975 5975
      */
5976 5976
     public static function get_tool_name_table($tool)
5977 5977
     {
5978
-    	switch ($tool) {
5979
-    		case 'document':
5980
-    			$table_name = TABLE_DOCUMENT;
5981
-    			$link_tool = 'document/document.php';
5982
-    			$id_tool = 'id';
5983
-    			break;
5984
-    		case 'learnpath':
5985
-    			$table_name = TABLE_LP_MAIN;
5986
-    			$link_tool = 'newscorm/lp_controller.php';
5987
-    			$id_tool = 'id';
5988
-    			break;
5989
-    		case 'quiz':
5990
-    			$table_name = TABLE_QUIZ_TEST;
5991
-    			$link_tool = 'exercice/exercice.php';
5992
-    			$id_tool = 'id';
5993
-    			break;
5994
-    		case 'glossary':
5995
-    			$table_name = TABLE_GLOSSARY;
5996
-    			$link_tool = 'glossary/index.php';
5997
-    			$id_tool = 'glossary_id';
5998
-    			break;
5999
-    		case 'link':
6000
-    			$table_name = TABLE_LINK;
6001
-    			$link_tool = 'link/link.php';
6002
-    			$id_tool = 'id';
6003
-    			break;
6004
-    		case 'course_description':
6005
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6006
-    			$link_tool = 'course_description/';
6007
-    			$id_tool = 'id';
6008
-    			break;
6009
-    		case 'announcement':
6010
-    			$table_name = TABLE_ANNOUNCEMENT;
6011
-    			$link_tool = 'announcements/announcements.php';
6012
-    			$id_tool = 'id';
6013
-    			break;
6014
-    		case 'thematic':
6015
-    			$table_name = TABLE_THEMATIC;
6016
-    			$link_tool = 'course_progress/index.php';
6017
-    			$id_tool = 'id';
6018
-    			break;
6019
-    		case 'thematic_advance':
6020
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6021
-    			$link_tool = 'course_progress/index.php';
6022
-    			$id_tool = 'id';
6023
-    			break;
6024
-    		case 'thematic_plan':
6025
-    			$table_name = TABLE_THEMATIC_PLAN;
6026
-    			$link_tool = 'course_progress/index.php';
6027
-    			$id_tool = 'id';
6028
-    			break;
6029
-    		default:
6030
-    			$table_name = $tool;
6031
-    		break;
6032
-    	}
6033
-
6034
-    	return array(
5978
+        switch ($tool) {
5979
+            case 'document':
5980
+                $table_name = TABLE_DOCUMENT;
5981
+                $link_tool = 'document/document.php';
5982
+                $id_tool = 'id';
5983
+                break;
5984
+            case 'learnpath':
5985
+                $table_name = TABLE_LP_MAIN;
5986
+                $link_tool = 'newscorm/lp_controller.php';
5987
+                $id_tool = 'id';
5988
+                break;
5989
+            case 'quiz':
5990
+                $table_name = TABLE_QUIZ_TEST;
5991
+                $link_tool = 'exercice/exercice.php';
5992
+                $id_tool = 'id';
5993
+                break;
5994
+            case 'glossary':
5995
+                $table_name = TABLE_GLOSSARY;
5996
+                $link_tool = 'glossary/index.php';
5997
+                $id_tool = 'glossary_id';
5998
+                break;
5999
+            case 'link':
6000
+                $table_name = TABLE_LINK;
6001
+                $link_tool = 'link/link.php';
6002
+                $id_tool = 'id';
6003
+                break;
6004
+            case 'course_description':
6005
+                $table_name = TABLE_COURSE_DESCRIPTION;
6006
+                $link_tool = 'course_description/';
6007
+                $id_tool = 'id';
6008
+                break;
6009
+            case 'announcement':
6010
+                $table_name = TABLE_ANNOUNCEMENT;
6011
+                $link_tool = 'announcements/announcements.php';
6012
+                $id_tool = 'id';
6013
+                break;
6014
+            case 'thematic':
6015
+                $table_name = TABLE_THEMATIC;
6016
+                $link_tool = 'course_progress/index.php';
6017
+                $id_tool = 'id';
6018
+                break;
6019
+            case 'thematic_advance':
6020
+                $table_name = TABLE_THEMATIC_ADVANCE;
6021
+                $link_tool = 'course_progress/index.php';
6022
+                $id_tool = 'id';
6023
+                break;
6024
+            case 'thematic_plan':
6025
+                $table_name = TABLE_THEMATIC_PLAN;
6026
+                $link_tool = 'course_progress/index.php';
6027
+                $id_tool = 'id';
6028
+                break;
6029
+            default:
6030
+                $table_name = $tool;
6031
+            break;
6032
+        }
6033
+
6034
+        return array(
6035 6035
             'table_name' => $table_name,
6036 6036
             'link_tool' => $link_tool,
6037 6037
             'id_tool' => $id_tool
@@ -6040,45 +6040,45 @@  discard block
 block discarded – undo
6040 6040
 
6041 6041
     public static function display_additional_profile_fields()
6042 6042
     {
6043
-    	// getting all the extra profile fields that are defined by the platform administrator
6044
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6045
-
6046
-    	// creating the form
6047
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6048
-
6049
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6050
-    	// the information the users have entered or selected.
6051
-    	$return .= '<select name="additional_profile_field">';
6052
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6053
-    	$extra_fields_to_show = 0;
6054
-    	foreach ($extra_fields as $key=>$field) {
6055
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6056
-    		if ($field[6]==1 && $field[8] == 1) {
6057
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6058
-    				$selected = 'selected="selected"';
6059
-    			} else {
6060
-    				$selected = '';
6061
-    			}
6062
-    			$extra_fields_to_show++;
6063
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6064
-    		}
6065
-    	}
6066
-    	$return .= '</select>';
6067
-
6068
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6069
-    	foreach ($_GET as $key=>$value){
6070
-    		if ($key <> 'additional_profile_field')    {
6071
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6072
-    		}
6073
-    	}
6074
-    	// the submit button
6075
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6076
-    	$return .= '</form>';
6077
-    	if ($extra_fields_to_show > 0) {
6078
-    		return $return;
6079
-    	} else {
6080
-    		return '';
6081
-    	}
6043
+        // getting all the extra profile fields that are defined by the platform administrator
6044
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6045
+
6046
+        // creating the form
6047
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6048
+
6049
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6050
+        // the information the users have entered or selected.
6051
+        $return .= '<select name="additional_profile_field">';
6052
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6053
+        $extra_fields_to_show = 0;
6054
+        foreach ($extra_fields as $key=>$field) {
6055
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6056
+            if ($field[6]==1 && $field[8] == 1) {
6057
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6058
+                    $selected = 'selected="selected"';
6059
+                } else {
6060
+                    $selected = '';
6061
+                }
6062
+                $extra_fields_to_show++;
6063
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6064
+            }
6065
+        }
6066
+        $return .= '</select>';
6067
+
6068
+        // the form elements for the $_GET parameters (because the form is passed through GET
6069
+        foreach ($_GET as $key=>$value){
6070
+            if ($key <> 'additional_profile_field')    {
6071
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6072
+            }
6073
+        }
6074
+        // the submit button
6075
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6076
+        $return .= '</form>';
6077
+        if ($extra_fields_to_show > 0) {
6078
+            return $return;
6079
+        } else {
6080
+            return '';
6081
+        }
6082 6082
     }
6083 6083
 
6084 6084
     /**
@@ -6097,31 +6097,31 @@  discard block
 block discarded – undo
6097 6097
      */
6098 6098
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6099 6099
     {
6100
-    	// Database table definition
6101
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6102
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6100
+        // Database table definition
6101
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6102
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6103 6103
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6104
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6105
-
6106
-    	if (!empty($users)) {
6107
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6108
-    			foreach($users as $user_id) {
6109
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6110
-    				$tag_list = array();
6111
-    				foreach($user_result as $item) {
6112
-    					$tag_list[] = $item['tag'];
6113
-    				}
6114
-    				$return[$user_id][] = implode(', ',$tag_list);
6115
-    			}
6116
-    		} else {
6117
-    			$new_user_array = array();
6118
-    			foreach ($users as $user_id) {
6119
-    				$new_user_array[]= "'".$user_id."'";
6120
-    			}
6121
-    			$users = implode(',',$new_user_array);
6104
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6105
+
6106
+        if (!empty($users)) {
6107
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6108
+                foreach($users as $user_id) {
6109
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6110
+                    $tag_list = array();
6111
+                    foreach($user_result as $item) {
6112
+                        $tag_list[] = $item['tag'];
6113
+                    }
6114
+                    $return[$user_id][] = implode(', ',$tag_list);
6115
+                }
6116
+            } else {
6117
+                $new_user_array = array();
6118
+                foreach ($users as $user_id) {
6119
+                    $new_user_array[]= "'".$user_id."'";
6120
+                }
6121
+                $users = implode(',',$new_user_array);
6122 6122
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6123
-    			// Selecting only the necessary information NOT ALL the user list
6124
-    			$sql = "SELECT user.user_id, v.value
6123
+                // Selecting only the necessary information NOT ALL the user list
6124
+                $sql = "SELECT user.user_id, v.value
6125 6125
     			        FROM $table_user user
6126 6126
     			        INNER JOIN $table_user_field_values v
6127 6127
                         ON (user.user_id = v.item_id)
@@ -6132,27 +6132,27 @@  discard block
 block discarded – undo
6132 6132
                             v.field_id=".intval($field_id)." AND
6133 6133
                             user.user_id IN ($users)";
6134 6134
 
6135
-    			$result = Database::query($sql);
6136
-    			while($row = Database::fetch_array($result)) {
6137
-    				// get option value for field type double select by id
6138
-    				if (!empty($row['value'])) {
6139
-    					if ($result_extra_field['field_type'] ==
6135
+                $result = Database::query($sql);
6136
+                while($row = Database::fetch_array($result)) {
6137
+                    // get option value for field type double select by id
6138
+                    if (!empty($row['value'])) {
6139
+                        if ($result_extra_field['field_type'] ==
6140 6140
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6141 6141
                         ) {
6142
-    						$id_double_select = explode(';', $row['value']);
6143
-    						if (is_array($id_double_select)) {
6144
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6145
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6146
-    							$row['value'] = ($value1.';'.$value2);
6147
-    						}
6148
-    					}
6149
-    				}
6150
-    				// get other value from extra field
6151
-    				$return[$row['user_id']][] = $row['value'];
6152
-    			}
6153
-    		}
6154
-    	}
6155
-    	return $return;
6142
+                            $id_double_select = explode(';', $row['value']);
6143
+                            if (is_array($id_double_select)) {
6144
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6145
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6146
+                                $row['value'] = ($value1.';'.$value2);
6147
+                            }
6148
+                        }
6149
+                    }
6150
+                    // get other value from extra field
6151
+                    $return[$row['user_id']][] = $row['value'];
6152
+                }
6153
+            }
6154
+        }
6155
+        return $return;
6156 6156
     }
6157 6157
 
6158 6158
     /**
@@ -6161,18 +6161,18 @@  discard block
 block discarded – undo
6161 6161
      */
6162 6162
     public function count_student_in_course()
6163 6163
     {
6164
-    	global $nbStudents;
6165
-    	return $nbStudents;
6164
+        global $nbStudents;
6165
+        return $nbStudents;
6166 6166
     }
6167 6167
 
6168 6168
     public function sort_users($a, $b)
6169 6169
     {
6170
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6170
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6171 6171
     }
6172 6172
 
6173 6173
     public function sort_users_desc($a, $b)
6174 6174
     {
6175
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6175
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6176 6176
     }
6177 6177
 
6178 6178
     /**
@@ -6181,8 +6181,8 @@  discard block
 block discarded – undo
6181 6181
      */
6182 6182
     public static function get_number_of_users()
6183 6183
     {
6184
-    	global $user_ids;
6185
-    	return count($user_ids);
6184
+        global $user_ids;
6185
+        return count($user_ids);
6186 6186
     }
6187 6187
 
6188 6188
     /**
@@ -6198,37 +6198,37 @@  discard block
 block discarded – undo
6198 6198
     {
6199 6199
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6200 6200
 
6201
-    	$course_code = Database::escape_string($course_code);
6202
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6203
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6201
+        $course_code = Database::escape_string($course_code);
6202
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6203
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6204 6204
 
6205
-    	$access_url_id = api_get_current_access_url_id();
6205
+        $access_url_id = api_get_current_access_url_id();
6206 6206
 
6207
-    	// get all users data from a course for sortable with limit
6208
-    	if (is_array($user_ids)) {
6209
-    		$user_ids = array_map('intval', $user_ids);
6210
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6211
-    	} else {
6212
-    		$user_ids = intval($user_ids);
6213
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6214
-    	}
6207
+        // get all users data from a course for sortable with limit
6208
+        if (is_array($user_ids)) {
6209
+            $user_ids = array_map('intval', $user_ids);
6210
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6211
+        } else {
6212
+            $user_ids = intval($user_ids);
6213
+            $condition_user = " WHERE user.user_id = $user_ids ";
6214
+        }
6215 6215
 
6216
-    	if (!empty($_GET['user_keyword'])) {
6217
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6218
-    		$condition_user .=  " AND (
6216
+        if (!empty($_GET['user_keyword'])) {
6217
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6218
+            $condition_user .=  " AND (
6219 6219
                 user.firstname LIKE '%".$keyword."%' OR
6220 6220
                 user.lastname LIKE '%".$keyword."%'  OR
6221 6221
                 user.username LIKE '%".$keyword."%'  OR
6222 6222
                 user.email LIKE '%".$keyword."%'
6223 6223
              ) ";
6224
-    	}
6224
+        }
6225 6225
 
6226 6226
         $url_table = null;
6227 6227
         $url_condition = null;
6228
-    	if (api_is_multiple_url_enabled()) {
6229
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6230
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6231
-    	}
6228
+        if (api_is_multiple_url_enabled()) {
6229
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6230
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6231
+        }
6232 6232
 
6233 6233
         $invitedUsersCondition = '';
6234 6234
 
@@ -6236,7 +6236,7 @@  discard block
 block discarded – undo
6236 6236
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6237 6237
         }
6238 6238
 
6239
-    	$sql = "SELECT  user.user_id as user_id,
6239
+        $sql = "SELECT  user.user_id as user_id,
6240 6240
                     user.official_code  as col0,
6241 6241
                     user.lastname       as col1,
6242 6242
                     user.firstname      as col2,
@@ -6244,17 +6244,17 @@  discard block
 block discarded – undo
6244 6244
                 FROM $tbl_user as user $url_table
6245 6245
     	        $condition_user $url_condition $invitedUsersCondition";
6246 6246
 
6247
-    	if (!in_array($direction, array('ASC','DESC'))) {
6248
-    		$direction = 'ASC';
6249
-    	}
6247
+        if (!in_array($direction, array('ASC','DESC'))) {
6248
+            $direction = 'ASC';
6249
+        }
6250 6250
 
6251
-    	$column = intval($column);
6251
+        $column = intval($column);
6252 6252
 
6253
-    	$from = intval($from);
6254
-    	$number_of_items = intval($number_of_items);
6253
+        $from = intval($from);
6254
+        $number_of_items = intval($number_of_items);
6255 6255
 
6256
-    	$sql .= " ORDER BY col$column $direction ";
6257
-    	$sql .= " LIMIT $from,$number_of_items";
6256
+        $sql .= " ORDER BY col$column $direction ";
6257
+        $sql .= " LIMIT $from,$number_of_items";
6258 6258
 
6259 6259
         $res = Database::query($sql);
6260 6260
         $users = array();
@@ -6288,7 +6288,7 @@  discard block
 block discarded – undo
6288 6288
             }
6289 6289
         }
6290 6290
 
6291
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6291
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6292 6292
             $courseInfo = api_get_course_info($course_code);
6293 6293
             $courseId = $courseInfo['real_id'];
6294 6294
 
@@ -6319,10 +6319,10 @@  discard block
 block discarded – undo
6319 6319
                 $session_id
6320 6320
             );
6321 6321
 
6322
-    		if (empty($avg_student_progress)) {
6322
+            if (empty($avg_student_progress)) {
6323 6323
                 $avg_student_progress = 0;
6324
-    		}
6325
-    		$user['average_progress'] = $avg_student_progress.'%';
6324
+            }
6325
+            $user['average_progress'] = $avg_student_progress.'%';
6326 6326
 
6327 6327
             $total_user_exercise = Tracking::get_exercise_student_progress(
6328 6328
                 $total_exercises,
@@ -6342,11 +6342,11 @@  discard block
 block discarded – undo
6342 6342
 
6343 6343
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6344 6344
 
6345
-    		if (is_numeric($avg_student_score)) {
6346
-    			$user['student_score']  = $avg_student_score.'%';
6347
-    		} else {
6348
-    			$user['student_score']  = $avg_student_score;
6349
-    		}
6345
+            if (is_numeric($avg_student_score)) {
6346
+                $user['student_score']  = $avg_student_score.'%';
6347
+            } else {
6348
+                $user['student_score']  = $avg_student_score;
6349
+            }
6350 6350
 
6351 6351
             $user['count_assignments'] = Tracking::count_student_assignments(
6352 6352
                 $user['user_id'],
@@ -6369,29 +6369,29 @@  discard block
 block discarded – undo
6369 6369
                 $session_id
6370 6370
             );
6371 6371
 
6372
-    		// we need to display an additional profile field
6373
-    		$user['additional'] = '';
6372
+            // we need to display an additional profile field
6373
+            $user['additional'] = '';
6374 6374
 
6375
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6376
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6375
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6376
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6377 6377
                     is_array($additional_user_profile_info[$user['user_id']])
6378 6378
                 ) {
6379
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6380
-    			}
6381
-    		}
6379
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6380
+                }
6381
+            }
6382 6382
 
6383 6383
             if (empty($session_id)) {
6384 6384
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6385 6385
             }
6386 6386
 
6387
-    		$user['link'] = '<center>
6387
+            $user['link'] = '<center>
6388 6388
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6389 6389
     		                 '.Display::return_icon('2rightarrow.png').'
6390 6390
     		                 </a>
6391 6391
                          </center>';
6392 6392
 
6393
-    		// store columns in array $users
6394
-    		$is_western_name_order = api_is_western_name_order();
6393
+            // store columns in array $users
6394
+            $is_western_name_order = api_is_western_name_order();
6395 6395
             $user_row = array();
6396 6396
             $user_row[]= $user['official_code']; //0
6397 6397
             if ($is_western_name_order) {
@@ -6424,21 +6424,21 @@  discard block
 block discarded – undo
6424 6424
 
6425 6425
             $users[] = $user_row;
6426 6426
 
6427
-    		if ($export_csv) {
6428
-    		    if (empty($session_id)) {
6427
+            if ($export_csv) {
6428
+                if (empty($session_id)) {
6429 6429
                     $user_row = array_map('strip_tags', $user_row);
6430
-    			    unset($user_row[14]);
6431
-    			    unset($user_row[15]);
6430
+                    unset($user_row[14]);
6431
+                    unset($user_row[15]);
6432 6432
                 } else {
6433 6433
                     $user_row = array_map('strip_tags', $user_row);
6434 6434
                     unset($user_row[13]);
6435 6435
                     unset($user_row[14]);
6436 6436
                 }
6437 6437
 
6438
-    			$csv_content[] = $user_row;
6439
-    		}
6440
-    	}
6441
-    	return $users;
6438
+                $csv_content[] = $user_row;
6439
+            }
6440
+        }
6441
+        return $users;
6442 6442
     }
6443 6443
 }
6444 6444
 
@@ -6456,18 +6456,18 @@  discard block
 block discarded – undo
6456 6456
      */
6457 6457
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6458 6458
     {
6459
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6460
-
6461
-    	// protected data
6462
-    	$user_id = intval($user_id);
6463
-    	$session_id = intval($session_id);
6464
-    	$course_id = Database::escape_string($course_id);
6465
-
6466
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6467
-    	$tempView = $view;
6468
-    	if(substr($view,0,1) == '1') {
6469
-    		$new_view = substr_replace($view,'0',0,1);
6470
-    		echo "
6459
+        $MonthsLong = $GLOBALS['MonthsLong'];
6460
+
6461
+        // protected data
6462
+        $user_id = intval($user_id);
6463
+        $session_id = intval($session_id);
6464
+        $course_id = Database::escape_string($course_id);
6465
+
6466
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6467
+        $tempView = $view;
6468
+        if(substr($view,0,1) == '1') {
6469
+            $new_view = substr_replace($view,'0',0,1);
6470
+            echo "
6471 6471
                 <tr>
6472 6472
                     <td valign='top'>
6473 6473
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6475,9 +6475,9 @@  discard block
 block discarded – undo
6475 6475
                     </td>
6476 6476
                 </tr>
6477 6477
                 ";
6478
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6478
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6479 6479
 
6480
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6480
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6481 6481
                         FROM $track_access_table
6482 6482
                         WHERE access_user_id = $user_id
6483 6483
                         AND c_id = $course_id
@@ -6485,11 +6485,11 @@  discard block
 block discarded – undo
6485 6485
                         GROUP BY YEAR(access_date),MONTH(access_date)
6486 6486
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6487 6487
 
6488
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6489
-    		$results = getManyResults3Col($sql);
6488
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6489
+            $results = getManyResults3Col($sql);
6490 6490
 
6491
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6492
-    		echo "<tr>
6491
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6492
+            echo "<tr>
6493 6493
                     <td class='secLine'>
6494 6494
                     ".get_lang('LoginsTitleMonthColumn')."
6495 6495
                     </td>
@@ -6497,36 +6497,36 @@  discard block
 block discarded – undo
6497 6497
                     ".get_lang('LoginsTitleCountColumn')."
6498 6498
                     </td>
6499 6499
                 </tr>";
6500
-    		$total = 0;
6501
-    		if (is_array($results)) {
6502
-    			for($j = 0 ; $j < count($results) ; $j++) {
6503
-    				echo "<tr>";
6504
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6505
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6506
-    				echo"</tr>";
6507
-    				$total = $total + $results[$j][1];
6508
-    			}
6509
-    			echo "<tr>";
6510
-    			echo "<td>".get_lang('Total')."</td>";
6511
-    			echo "<td align='right' class='content'>".$total."</td>";
6512
-    			echo"</tr>";
6513
-    		} else {
6514
-    			echo "<tr>";
6515
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6516
-    			echo"</tr>";
6517
-    		}
6518
-    		echo "</table>";
6519
-    		echo "</td></tr>";
6520
-    	} else {
6521
-    		$new_view = substr_replace($view,'1',0,1);
6522
-    		echo "
6500
+            $total = 0;
6501
+            if (is_array($results)) {
6502
+                for($j = 0 ; $j < count($results) ; $j++) {
6503
+                    echo "<tr>";
6504
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6505
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6506
+                    echo"</tr>";
6507
+                    $total = $total + $results[$j][1];
6508
+                }
6509
+                echo "<tr>";
6510
+                echo "<td>".get_lang('Total')."</td>";
6511
+                echo "<td align='right' class='content'>".$total."</td>";
6512
+                echo"</tr>";
6513
+            } else {
6514
+                echo "<tr>";
6515
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6516
+                echo"</tr>";
6517
+            }
6518
+            echo "</table>";
6519
+            echo "</td></tr>";
6520
+        } else {
6521
+            $new_view = substr_replace($view,'1',0,1);
6522
+            echo "
6523 6523
                 <tr>
6524 6524
                     <td valign='top'>
6525 6525
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6526 6526
                     </td>
6527 6527
                 </tr>
6528 6528
             ";
6529
-    	}
6529
+        }
6530 6530
     }
6531 6531
 
6532 6532
     /**
@@ -6539,38 +6539,38 @@  discard block
 block discarded – undo
6539 6539
      */
6540 6540
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6541 6541
     {
6542
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6542
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6543 6543
         $courseId = api_get_course_int_id($courseCode);
6544
-    	if(substr($view,1,1) == '1') {
6545
-    		$new_view = substr_replace($view,'0',1,1);
6546
-    		echo "<tr>
6544
+        if(substr($view,1,1) == '1') {
6545
+            $new_view = substr_replace($view,'0',1,1);
6546
+            echo "<tr>
6547 6547
                     <td valign='top'>
6548 6548
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6549 6549
                     </td>
6550 6550
                 </tr>";
6551
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6551
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6552 6552
 
6553
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6553
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6554 6554
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6555 6555
                     WHERE te.c_id = $courseId
6556 6556
                         AND te.exe_user_id = ".intval($user_id)."
6557 6557
                         AND te.exe_exo_id = ce.id
6558 6558
                     ORDER BY ce.title ASC, te.exe_date ASC";
6559 6559
 
6560
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6560
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6561 6561
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6562 6562
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6563 6563
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6564 6564
 
6565
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6565
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6566 6566
 
6567
-    		$NoTestRes = 0;
6568
-    		$NoHPTestRes = 0;
6567
+            $NoTestRes = 0;
6568
+            $NoHPTestRes = 0;
6569 6569
 
6570
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6571
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6572
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6573
-    		echo "
6570
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6571
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6572
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6573
+            echo "
6574 6574
                 <tr bgcolor='#E6E6E6'>
6575 6575
                     <td>
6576 6576
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6583,28 +6583,28 @@  discard block
 block discarded – undo
6583 6583
                     </td>
6584 6584
                 </tr>";
6585 6585
 
6586
-    		if (is_array($results)) {
6587
-    			for($i = 0; $i < sizeof($results); $i++) {
6588
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6589
-    				echo "<tr>\n";
6590
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6591
-    				echo "<td class='content'>".$display_date."</td>\n";
6592
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6593
-    				echo "</tr>\n";
6594
-    			}
6595
-    		} else {
6596
-    			// istvan begin
6597
-    			$NoTestRes = 1;
6598
-    		}
6599
-
6600
-    		// The Result of Tests
6601
-    		if (is_array($hpresults)) {
6602
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6603
-    				$title = GetQuizName($hpresults[$i][0],'');
6604
-    				if ($title == '')
6605
-    				$title = basename($hpresults[$i][0]);
6606
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6607
-    				?>
6586
+            if (is_array($results)) {
6587
+                for($i = 0; $i < sizeof($results); $i++) {
6588
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6589
+                    echo "<tr>\n";
6590
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6591
+                    echo "<td class='content'>".$display_date."</td>\n";
6592
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6593
+                    echo "</tr>\n";
6594
+                }
6595
+            } else {
6596
+                // istvan begin
6597
+                $NoTestRes = 1;
6598
+            }
6599
+
6600
+            // The Result of Tests
6601
+            if (is_array($hpresults)) {
6602
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6603
+                    $title = GetQuizName($hpresults[$i][0],'');
6604
+                    if ($title == '')
6605
+                    $title = basename($hpresults[$i][0]);
6606
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6607
+                    ?>
6608 6608
                     <tr>
6609 6609
                         <td class="content"><?php echo $title; ?></td>
6610 6610
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6614,26 +6614,26 @@  discard block
 block discarded – undo
6614 6614
 
6615 6615
                     <?php
6616 6616
                 }
6617
-    		} else {
6618
-    			$NoHPTestRes = 1;
6619
-    		}
6620
-
6621
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6622
-    			echo "<tr>\n";
6623
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6624
-    			echo "</tr>\n";
6625
-    		}
6626
-    		echo "</table>";
6627
-    		echo "</td>\n</tr>\n";
6628
-    	} else {
6629
-    		$new_view = substr_replace($view,'1',1,1);
6630
-    		echo "
6617
+            } else {
6618
+                $NoHPTestRes = 1;
6619
+            }
6620
+
6621
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6622
+                echo "<tr>\n";
6623
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6624
+                echo "</tr>\n";
6625
+            }
6626
+            echo "</table>";
6627
+            echo "</td>\n</tr>\n";
6628
+        } else {
6629
+            $new_view = substr_replace($view,'1',1,1);
6630
+            echo "
6631 6631
                 <tr>
6632 6632
                     <td valign='top'>
6633 6633
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6634 6634
                     </td>
6635 6635
                 </tr>";
6636
-    	}
6636
+        }
6637 6637
     }
6638 6638
 
6639 6639
     /**
@@ -6642,27 +6642,27 @@  discard block
 block discarded – undo
6642 6642
      */
6643 6643
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6644 6644
     {
6645
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6645
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6646 6646
         $_course = api_get_course_info_by_id($course_id);
6647 6647
 
6648
-    	if (substr($view,2,1) == '1') {
6649
-    		$new_view = substr_replace($view,'0',2,1);
6650
-    		echo "<tr>
6648
+        if (substr($view,2,1) == '1') {
6649
+            $new_view = substr_replace($view,'0',2,1);
6650
+            echo "<tr>
6651 6651
                     <td valign='top'>
6652 6652
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6653 6653
                     </td>
6654 6654
                 </tr>";
6655
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6656
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6655
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6656
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6657 6657
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6658 6658
                     WHERE u.upload_work_id = w.id
6659 6659
                         AND u.upload_user_id = '".intval($user_id)."'
6660 6660
                         AND u.c_id = '".intval($course_id)."'
6661 6661
                     ORDER BY u.upload_date DESC";
6662
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6663
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6664
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6665
-    		echo "<tr>
6662
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6663
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6664
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6665
+            echo "<tr>
6666 6666
                     <td class='secLine' width='40%'>
6667 6667
                     ".get_lang('WorkTitle')."
6668 6668
                     </td>
@@ -6673,35 +6673,35 @@  discard block
 block discarded – undo
6673 6673
                     ".get_lang('Date')."
6674 6674
                     </td>
6675 6675
                 </tr>";
6676
-    		if (is_array($results)) {
6677
-    			for($j = 0 ; $j < count($results) ; $j++) {
6678
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6679
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6680
-    				echo "<tr>";
6681
-    				echo "<td class='content'>"
6682
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6683
-    				."</td>";
6684
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6685
-    				echo "<td class='content'>".$beautifulDate."</td>";
6686
-    				echo"</tr>";
6687
-    			}
6688
-    		} else {
6689
-    			echo "<tr>";
6690
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6691
-    			echo"</tr>";
6692
-    		}
6693
-    		echo "</table>";
6694
-    		echo "</td></tr>";
6695
-    	} else {
6696
-    		$new_view = substr_replace($view,'1',2,1);
6697
-    		echo "
6676
+            if (is_array($results)) {
6677
+                for($j = 0 ; $j < count($results) ; $j++) {
6678
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6679
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6680
+                    echo "<tr>";
6681
+                    echo "<td class='content'>"
6682
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6683
+                    ."</td>";
6684
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6685
+                    echo "<td class='content'>".$beautifulDate."</td>";
6686
+                    echo"</tr>";
6687
+                }
6688
+            } else {
6689
+                echo "<tr>";
6690
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6691
+                echo"</tr>";
6692
+            }
6693
+            echo "</table>";
6694
+            echo "</td></tr>";
6695
+        } else {
6696
+            $new_view = substr_replace($view,'1',2,1);
6697
+            echo "
6698 6698
                 <tr>
6699 6699
                     <td valign='top'>
6700 6700
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6701 6701
                     </td>
6702 6702
                 </tr>
6703 6703
             ";
6704
-    	}
6704
+        }
6705 6705
     }
6706 6706
 
6707 6707
     /**
@@ -6710,55 +6710,55 @@  discard block
 block discarded – undo
6710 6710
      */
6711 6711
     public function display_links_tracking_info($view, $user_id, $courseCode)
6712 6712
     {
6713
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6713
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6714 6714
         $courseId = api_get_course_int_id($courseCode);
6715
-    	if (substr($view,3,1) == '1') {
6716
-    		$new_view = substr_replace($view,'0',3,1);
6717
-    		echo "
6715
+        if (substr($view,3,1) == '1') {
6716
+            $new_view = substr_replace($view,'0',3,1);
6717
+            echo "
6718 6718
                 <tr>
6719 6719
                         <td valign='top'>
6720 6720
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
6721 6721
                         </td>
6722 6722
                 </tr>
6723 6723
             ";
6724
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6725
-    		$sql = "SELECT cl.title, cl.url
6724
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6725
+            $sql = "SELECT cl.title, cl.url
6726 6726
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6727 6727
                     WHERE sl.links_link_id = cl.id
6728 6728
                         AND sl.c_id = $courseId
6729 6729
                         AND sl.links_user_id = ".intval($user_id)."
6730 6730
                     GROUP BY cl.title, cl.url";
6731
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6732
-    		$results = StatsUtils::getManyResults2Col($sql);
6733
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6734
-    		echo "<tr>
6731
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6732
+            $results = StatsUtils::getManyResults2Col($sql);
6733
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6734
+            echo "<tr>
6735 6735
                     <td class='secLine'>
6736 6736
                     ".get_lang('LinksTitleLinkColumn')."
6737 6737
                     </td>
6738 6738
                 </tr>";
6739
-    		if (is_array($results)) {
6740
-    			for($j = 0 ; $j < count($results) ; $j++) {
6741
-    				echo "<tr>";
6742
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6743
-    				echo"</tr>";
6744
-    			}
6745
-    		} else {
6746
-    			echo "<tr>";
6747
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6748
-    			echo"</tr>";
6749
-    		}
6750
-    		echo "</table>";
6751
-    		echo "</td></tr>";
6752
-    	} else {
6753
-    		$new_view = substr_replace($view,'1',3,1);
6754
-    		echo "
6739
+            if (is_array($results)) {
6740
+                for($j = 0 ; $j < count($results) ; $j++) {
6741
+                    echo "<tr>";
6742
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6743
+                    echo"</tr>";
6744
+                }
6745
+            } else {
6746
+                echo "<tr>";
6747
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6748
+                echo"</tr>";
6749
+            }
6750
+            echo "</table>";
6751
+            echo "</td></tr>";
6752
+        } else {
6753
+            $new_view = substr_replace($view,'1',3,1);
6754
+            echo "
6755 6755
                 <tr>
6756 6756
                     <td valign='top'>
6757 6757
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
6758 6758
                     </td>
6759 6759
                 </tr>
6760 6760
             ";
6761
-    	}
6761
+        }
6762 6762
     }
6763 6763
 
6764 6764
     /**
@@ -6771,61 +6771,61 @@  discard block
 block discarded – undo
6771 6771
      */
6772 6772
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6773 6773
     {
6774
-    	// protect data
6774
+        // protect data
6775 6775
         $user_id = intval($user_id);
6776 6776
         $courseId = api_get_course_int_id($course_code);
6777
-    	$session_id = intval($session_id);
6777
+        $session_id = intval($session_id);
6778 6778
 
6779
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6780
-    	if(substr($view,4,1) == '1') {
6781
-    		$new_view = substr_replace($view,'0',4,1);
6782
-    		echo "
6779
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6780
+        if(substr($view,4,1) == '1') {
6781
+            $new_view = substr_replace($view,'0',4,1);
6782
+            echo "
6783 6783
                 <tr>
6784 6784
                     <td valign='top'>
6785 6785
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
6786 6786
                     </td>
6787 6787
                 </tr>
6788 6788
             ";
6789
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6789
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6790 6790
 
6791
-    		$sql = "SELECT down_doc_path
6791
+            $sql = "SELECT down_doc_path
6792 6792
                     FROM $downloads_table
6793 6793
                     WHERE c_id = $courseId
6794 6794
                         AND down_user_id = $user_id
6795 6795
                         AND down_session_id = $session_id
6796 6796
                     GROUP BY down_doc_path";
6797 6797
 
6798
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6799
-    		$results = StatsUtils::getManyResults1Col($sql);
6800
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6801
-    		echo "<tr>
6798
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6799
+            $results = StatsUtils::getManyResults1Col($sql);
6800
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6801
+            echo "<tr>
6802 6802
                     <td class='secLine'>
6803 6803
                     ".get_lang('DocumentsTitleDocumentColumn')."
6804 6804
                     </td>
6805 6805
                 </tr>";
6806
-    		if (is_array($results)) {
6807
-    			for($j = 0 ; $j < count($results) ; $j++) {
6808
-    				echo "<tr>";
6809
-    				echo "<td class='content'>".$results[$j]."</td>";
6810
-    				echo"</tr>";
6811
-    			}
6812
-    		} else {
6813
-    			echo "<tr>";
6814
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6815
-    			echo"</tr>";
6816
-    		}
6817
-    		echo "</table>";
6818
-    		echo "</td></tr>";
6819
-    	} else {
6820
-    		$new_view = substr_replace($view,'1',4,1);
6821
-    		echo "
6806
+            if (is_array($results)) {
6807
+                for($j = 0 ; $j < count($results) ; $j++) {
6808
+                    echo "<tr>";
6809
+                    echo "<td class='content'>".$results[$j]."</td>";
6810
+                    echo"</tr>";
6811
+                }
6812
+            } else {
6813
+                echo "<tr>";
6814
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6815
+                echo"</tr>";
6816
+            }
6817
+            echo "</table>";
6818
+            echo "</td></tr>";
6819
+        } else {
6820
+            $new_view = substr_replace($view,'1',4,1);
6821
+            echo "
6822 6822
                 <tr>
6823 6823
                     <td valign='top'>
6824 6824
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
6825 6825
                     </td>
6826 6826
                 </tr>
6827 6827
             ";
6828
-    	}
6828
+        }
6829 6829
     }
6830 6830
 
6831 6831
     /**
@@ -6882,43 +6882,43 @@  discard block
 block discarded – undo
6882 6882
      */
6883 6883
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6884 6884
     {
6885
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6886
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6887
-
6888
-    	// protected data
6889
-    	$user_id    = intval($user_id);
6890
-    	$session_id = intval($session_id);
6891
-    	$course_id  = intval($course_id);
6892
-
6893
-    	$tempView = $view;
6894
-    	if (substr($view,0,1) == '1') {
6895
-    		$new_view = substr_replace($view,'0',0,1);
6896
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6897
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6885
+        $MonthsLong = $GLOBALS['MonthsLong'];
6886
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6887
+
6888
+        // protected data
6889
+        $user_id    = intval($user_id);
6890
+        $session_id = intval($session_id);
6891
+        $course_id  = intval($course_id);
6892
+
6893
+        $tempView = $view;
6894
+        if (substr($view,0,1) == '1') {
6895
+            $new_view = substr_replace($view,'0',0,1);
6896
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6897
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6898 6898
                     FROM $track_access_table
6899 6899
                     WHERE access_user_id = $user_id
6900 6900
                     AND c_id = $course_id
6901 6901
                     AND access_session_id = $session_id
6902 6902
                     GROUP BY YEAR(access_date),MONTH(access_date)
6903 6903
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6904
-    		//$results = getManyResults2Col($sql);
6905
-    		$results = getManyResults3Col($sql);
6906
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6907
-    		$line='';
6908
-    		$total = 0;
6909
-    		if (is_array($results)) {
6910
-    			for($j = 0 ; $j < count($results) ; $j++) {
6911
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
6912
-    				$total = $total + $results[$j][1];
6913
-    			}
6914
-    			$line .= get_lang('Total').";".$total."\n";
6915
-    		} else {
6916
-    			$line= get_lang('NoResult')."</center></td>";
6917
-    		}
6918
-    	} else {
6919
-    		$new_view = substr_replace($view,'1',0,1);
6920
-    	}
6921
-    	return array($title_line, $line);
6904
+            //$results = getManyResults2Col($sql);
6905
+            $results = getManyResults3Col($sql);
6906
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6907
+            $line='';
6908
+            $total = 0;
6909
+            if (is_array($results)) {
6910
+                for($j = 0 ; $j < count($results) ; $j++) {
6911
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
6912
+                    $total = $total + $results[$j][1];
6913
+                }
6914
+                $line .= get_lang('Total').";".$total."\n";
6915
+            } else {
6916
+                $line= get_lang('NoResult')."</center></td>";
6917
+            }
6918
+        } else {
6919
+            $new_view = substr_replace($view,'1',0,1);
6920
+        }
6921
+        return array($title_line, $line);
6922 6922
     }
6923 6923
 
6924 6924
     /**
@@ -6931,67 +6931,67 @@  discard block
 block discarded – undo
6931 6931
      */
6932 6932
     public function display_exercise_tracking_info($view, $userId, $courseCode)
6933 6933
     {
6934
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6934
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6935 6935
         $courseId = api_get_course_int_id($courseCode);
6936 6936
         $userId = intval($userId);
6937
-    	if (substr($view,1,1) == '1') {
6938
-    		$new_view = substr_replace($view,'0',1,1);
6939
-    		$title[1] = get_lang('ExercicesDetails');
6940
-    		$line = '';
6941
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6937
+        if (substr($view,1,1) == '1') {
6938
+            $new_view = substr_replace($view,'0',1,1);
6939
+            $title[1] = get_lang('ExercicesDetails');
6940
+            $line = '';
6941
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6942 6942
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6943 6943
                     WHERE te.c_id = $courseId
6944 6944
                         AND te.exe_user_id = $userId
6945 6945
                         AND te.exe_exo_id = ce.id
6946 6946
                     ORDER BY ce.title ASC, te.exe_date ASC";
6947 6947
 
6948
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6948
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6949 6949
                         FROM $TABLETRACK_HOTPOTATOES AS te
6950 6950
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
6951 6951
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6952 6952
 
6953
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6953
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6954 6954
 
6955
-    		$NoTestRes = 0;
6956
-    		$NoHPTestRes = 0;
6955
+            $NoTestRes = 0;
6956
+            $NoHPTestRes = 0;
6957 6957
 
6958
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6959
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6958
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6959
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6960 6960
 
6961
-    		if (is_array($results)) {
6962
-    			for($i = 0; $i < sizeof($results); $i++)
6963
-    			{
6964
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6965
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
6966
-    			}
6967
-    		} else {
6961
+            if (is_array($results)) {
6962
+                for($i = 0; $i < sizeof($results); $i++)
6963
+                {
6964
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6965
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
6966
+                }
6967
+            } else {
6968 6968
                 // istvan begin
6969
-    			$NoTestRes = 1;
6970
-    		}
6971
-
6972
-    		// The Result of Tests
6973
-    		if (is_array($hpresults)) {
6974
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6975
-    				$title = GetQuizName($hpresults[$i][0],'');
6976
-
6977
-    				if ($title == '')
6978
-    				$title = basename($hpresults[$i][0]);
6979
-
6980
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6981
-
6982
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
6983
-    			}
6984
-    		} else {
6985
-    			$NoHPTestRes = 1;
6986
-    		}
6987
-
6988
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6989
-    			$line=get_lang('NoResult');
6990
-    		}
6991
-    	} else {
6992
-    		$new_view = substr_replace($view,'1',1,1);
6993
-    	}
6994
-    	return array($title_line, $line);
6969
+                $NoTestRes = 1;
6970
+            }
6971
+
6972
+            // The Result of Tests
6973
+            if (is_array($hpresults)) {
6974
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6975
+                    $title = GetQuizName($hpresults[$i][0],'');
6976
+
6977
+                    if ($title == '')
6978
+                    $title = basename($hpresults[$i][0]);
6979
+
6980
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6981
+
6982
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
6983
+                }
6984
+            } else {
6985
+                $NoHPTestRes = 1;
6986
+            }
6987
+
6988
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6989
+                $line=get_lang('NoResult');
6990
+            }
6991
+        } else {
6992
+            $new_view = substr_replace($view,'1',1,1);
6993
+        }
6994
+        return array($title_line, $line);
6995 6995
     }
6996 6996
 
6997 6997
     /**
@@ -7000,37 +7000,37 @@  discard block
 block discarded – undo
7000 7000
      */
7001 7001
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7002 7002
     {
7003
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7003
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7004 7004
         $_course = api_get_course_info();
7005 7005
         $user_id = intval($user_id);
7006 7006
         $course_id = intval($course_id);
7007 7007
 
7008
-    	if (substr($view,2,1) == '1') {
7009
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7008
+        if (substr($view,2,1) == '1') {
7009
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7010 7010
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7011 7011
                     WHERE
7012 7012
                         u.upload_work_id = w.id AND
7013 7013
                         u.upload_user_id = '$user_id' AND
7014 7014
                         u.c_id = '$course_id'
7015 7015
                     ORDER BY u.upload_date DESC";
7016
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7017
-
7018
-    		$title[1]=get_lang('WorksDetails');
7019
-    		$line='';
7020
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7021
-
7022
-    		if (is_array($results)) {
7023
-    			for($j = 0 ; $j < count($results) ; $j++) {
7024
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7025
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7026
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7027
-    			}
7028
-
7029
-    		} else {
7030
-    			$line= get_lang('NoResult');
7031
-    		}
7032
-    	}
7033
-    	return array($title_line, $line);
7016
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7017
+
7018
+            $title[1]=get_lang('WorksDetails');
7019
+            $line='';
7020
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7021
+
7022
+            if (is_array($results)) {
7023
+                for($j = 0 ; $j < count($results) ; $j++) {
7024
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7025
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7026
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7027
+                }
7028
+
7029
+            } else {
7030
+                $line= get_lang('NoResult');
7031
+            }
7032
+        }
7033
+        return array($title_line, $line);
7034 7034
     }
7035 7035
 
7036 7036
     /**
@@ -7039,32 +7039,32 @@  discard block
 block discarded – undo
7039 7039
      */
7040 7040
     public function display_links_tracking_info($view, $userId, $courseCode)
7041 7041
     {
7042
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7042
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7043 7043
         $courseId = api_get_course_int_id($courseCode);
7044 7044
         $userId = intval($userId);
7045 7045
         $line = null;
7046
-    	if (substr($view,3,1) == '1') {
7047
-    		$new_view = substr_replace($view,'0',3,1);
7048
-    		$title[1]=get_lang('LinksDetails');
7049
-    		$sql = "SELECT cl.title, cl.url
7046
+        if (substr($view,3,1) == '1') {
7047
+            $new_view = substr_replace($view,'0',3,1);
7048
+            $title[1]=get_lang('LinksDetails');
7049
+            $sql = "SELECT cl.title, cl.url
7050 7050
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7051 7051
                         WHERE sl.links_link_id = cl.id
7052 7052
                             AND sl.c_id = $courseId
7053 7053
                             AND sl.links_user_id = $userId
7054 7054
                         GROUP BY cl.title, cl.url";
7055
-    		$results = StatsUtils::getManyResults2Col($sql);
7056
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7057
-    		if (is_array($results)) {
7058
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7059
-    				$line .= $results[$j][0]."\n";
7060
-    			}
7061
-    		} else {
7062
-    			$line=get_lang('NoResult');
7063
-    		}
7064
-    	} else {
7065
-    		$new_view = substr_replace($view,'1',3,1);
7066
-    	}
7067
-    	return array($title_line, $line);
7055
+            $results = StatsUtils::getManyResults2Col($sql);
7056
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7057
+            if (is_array($results)) {
7058
+                for ($j = 0 ; $j < count($results) ; $j++) {
7059
+                    $line .= $results[$j][0]."\n";
7060
+                }
7061
+            } else {
7062
+                $line=get_lang('NoResult');
7063
+            }
7064
+        } else {
7065
+            $new_view = substr_replace($view,'1',3,1);
7066
+        }
7067
+        return array($title_line, $line);
7068 7068
     }
7069 7069
 
7070 7070
     /**
@@ -7077,38 +7077,38 @@  discard block
 block discarded – undo
7077 7077
      */
7078 7078
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7079 7079
     {
7080
-    	// protect data
7081
-    	$user_id     = intval($user_id);
7080
+        // protect data
7081
+        $user_id     = intval($user_id);
7082 7082
         $courseId = api_get_course_int_id($courseCode);
7083
-    	$session_id = intval($session_id);
7083
+        $session_id = intval($session_id);
7084 7084
 
7085
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7085
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7086 7086
 
7087
-    	if (substr($view,4,1) == '1') {
7088
-    		$new_view = substr_replace($view,'0',4,1);
7089
-    		$title[1]= get_lang('DocumentsDetails');
7087
+        if (substr($view,4,1) == '1') {
7088
+            $new_view = substr_replace($view,'0',4,1);
7089
+            $title[1]= get_lang('DocumentsDetails');
7090 7090
 
7091
-    		$sql = "SELECT down_doc_path
7091
+            $sql = "SELECT down_doc_path
7092 7092
                         FROM $downloads_table
7093 7093
                         WHERE c_id = $courseId
7094 7094
                             AND down_user_id = $user_id
7095 7095
                             AND down_session_id = $session_id
7096 7096
                         GROUP BY down_doc_path";
7097 7097
 
7098
-    		$results = StatsUtils::getManyResults1Col($sql);
7099
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7098
+            $results = StatsUtils::getManyResults1Col($sql);
7099
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7100 7100
             $line = null;
7101
-    		if (is_array($results)) {
7102
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7103
-    				$line .= $results[$j]."\n";
7104
-    			}
7105
-    		} else {
7106
-    			$line = get_lang('NoResult');
7107
-    		}
7108
-    	} else {
7109
-    		$new_view = substr_replace($view,'1',4,1);
7110
-    	}
7111
-    	return array($title_line, $line);
7101
+            if (is_array($results)) {
7102
+                for ($j = 0 ; $j < count($results) ; $j++) {
7103
+                    $line .= $results[$j]."\n";
7104
+                }
7105
+            } else {
7106
+                $line = get_lang('NoResult');
7107
+            }
7108
+        } else {
7109
+            $new_view = substr_replace($view,'1',4,1);
7110
+        }
7111
+        return array($title_line, $line);
7112 7112
     }
7113 7113
 
7114 7114
     /**
Please login to merge, or discard this patch.
main/document/create_paint.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 // Please, do not modify this dirname formatting
51 51
 
52 52
 if (strstr($dir, '..')) {
53
-	$dir = '/';
53
+    $dir = '/';
54 54
 }
55 55
 
56 56
 if ($dir[0] == '.') {
57
-	$dir = substr($dir, 1);
57
+    $dir = substr($dir, 1);
58 58
 }
59 59
 
60 60
 if ($dir[0] != '/') {
61
-	$dir = '/'.$dir;
61
+    $dir = '/'.$dir;
62 62
 }
63 63
 
64 64
 if ($dir[strlen($dir) - 1] != '/') {
65
-	$dir .= '/';
65
+    $dir .= '/';
66 66
 }
67 67
 
68 68
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
69 69
 
70 70
 if (!is_dir($filepath)) {
71
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
72
-	$dir = '/';
71
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
72
+    $dir = '/';
73 73
 }
74 74
 
75 75
 $groupId = api_get_group_id();
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 }
98 98
 
99 99
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
100
-	DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id()))
100
+    DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id()))
101 101
 ) {
102 102
     api_not_allowed(true);
103 103
 }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 // Interbreadcrumb for the current directory root path
116 116
 if (empty($document_data['parents'])) {
117
-	$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
117
+    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
118 118
 } else {
119 119
     foreach ($document_data['parents'] as $document_sub_data) {
120 120
         $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 $locktitle="false";
148 148
 
149 149
 if ($_SERVER['HTTP_HOST']=="localhost") {
150
-	$path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
151
-	if (!file_exists($path_and_file)) {
152
-		$crossdomain='<?xml version="1.0"?>
150
+    $path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
151
+    if (!file_exists($path_and_file)) {
152
+        $crossdomain='<?xml version="1.0"?>
153 153
 			<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
154 154
 			<cross-domain-policy>
155 155
 				<allow-access-from domain="cdn.pixlr.com" />
156 156
 				<site-control permitted-cross-domain-policies="master-only"/>
157 157
 				<allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/>
158 158
 			</cross-domain-policy>';//more open domain="*"
159
-		@file_put_contents($path_and_file, $crossdomain);
160
-	}
159
+        @file_put_contents($path_and_file, $crossdomain);
160
+    }
161 161
     $credentials = "true";
162 162
 } else {
163 163
     $credentials = "false";
Please login to merge, or discard this patch.
main/document/edit_draw.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 //path for svg-edit save
39 39
 $_SESSION['draw_dir']=Security::remove_XSS($dir);
40 40
 if ($_SESSION['draw_dir']=='/'){
41
-	$_SESSION['draw_dir'] = '';
41
+    $_SESSION['draw_dir'] = '';
42 42
 }
43 43
 $_SESSION['draw_file']=basename(Security::remove_XSS($file_path));
44 44
 $get_file = Security::remove_XSS($file_path);
@@ -55,42 +55,42 @@  discard block
 block discarded – undo
55 55
 /* Please, do not modify this dirname formatting */
56 56
 
57 57
 if (strstr($dir, '..')) {
58
-	$dir = '/';
58
+    $dir = '/';
59 59
 }
60 60
 
61 61
 if ($dir[0] == '.') {
62
-	$dir = substr($dir, 1);
62
+    $dir = substr($dir, 1);
63 63
 }
64 64
 
65 65
 if ($dir[0] != '/') {
66
-	$dir = '/'.$dir;
66
+    $dir = '/'.$dir;
67 67
 }
68 68
 
69 69
 if ($dir[strlen($dir) - 1] != '/') {
70
-	$dir .= '/';
70
+    $dir .= '/';
71 71
 }
72 72
 
73 73
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
74 74
 
75 75
 if (!is_dir($filepath)) {
76
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
77
-	$dir = '/';
76
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
77
+    $dir = '/';
78 78
 }
79 79
 
80 80
 //groups //TODO:clean
81 81
 if (!empty($group_id)) {
82
-	$req_gid = '&amp;gidReq='.$group_id;
83
-	$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace'));
84
-	$group_document = true;
85
-	$noPHP_SELF = true;
82
+    $req_gid = '&amp;gidReq='.$group_id;
83
+    $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace'));
84
+    $group_document = true;
85
+    $noPHP_SELF = true;
86 86
 }
87 87
 
88 88
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
89 89
 
90 90
 if (!$is_certificate_mode)
91
-	$interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
91
+    $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
92 92
 else
93
-	$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
93
+    $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
94 94
 
95 95
 // Interbreadcrumb for the current directory root path
96 96
 if (empty($document_data['parents'])) {
@@ -105,30 +105,30 @@  discard block
 block discarded – undo
105 105
 }
106 106
 
107 107
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] ||
108
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
108
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
109 109
 
110 110
 if (!$is_allowedToEdit) {
111
-	api_not_allowed(true);
111
+    api_not_allowed(true);
112 112
 }
113 113
 
114 114
 Event::event_access_tool(TOOL_DOCUMENT);
115 115
 
116 116
 Display :: display_header($nameTools, 'Doc');
117 117
 echo '<div class="actions">';
118
-		echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
119
-		echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.$req_gid.'&origin=editdraw">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
118
+        echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
119
+        echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.$req_gid.'&origin=editdraw">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
120 120
 echo '</div>';
121 121
 
122 122
 if (api_browser_support('svg')) {
123
-	//automatic loading the course language
124
-	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
125
-	$langsvgedit  = api_get_language_isocode();
126
-	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
127
-	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'svg-edit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
123
+    //automatic loading the course language
124
+    $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
125
+    $langsvgedit  = api_get_language_isocode();
126
+    $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
127
+    $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'svg-edit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
128 128
 
129
-	$svg_url= api_get_path(WEB_LIBRARY_PATH).'svg-edit/svg-editor.php?url=../../../../courses/'.$courseDir.$dir.$file.'&amp;lang='.$langsvgedit;
129
+    $svg_url= api_get_path(WEB_LIBRARY_PATH).'svg-edit/svg-editor.php?url=../../../../courses/'.$courseDir.$dir.$file.'&amp;lang='.$langsvgedit;
130 130
 
131
-	?>
131
+    ?>
132 132
 
133 133
 	<script type="text/javascript">
134 134
 
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 
149 149
     <?php
150 150
     echo '<noscript>';
151
-	echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
152
-	echo '</noscript>';
151
+    echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
152
+    echo '</noscript>';
153 153
 } else {
154
-	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
154
+    Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
155 155
 }
156 156
 Display::display_footer();
Please login to merge, or discard this patch.
main/document/edit_paint.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -61,44 +61,44 @@  discard block
 block discarded – undo
61 61
 /* Please, do not modify this dirname formatting */
62 62
 
63 63
 if (strstr($dir, '..')) {
64
-	$dir = '/';
64
+    $dir = '/';
65 65
 }
66 66
 
67 67
 if ($dir[0] == '.') {
68
-	$dir = substr($dir, 1);
68
+    $dir = substr($dir, 1);
69 69
 }
70 70
 
71 71
 if ($dir[0] != '/') {
72
-	$dir = '/'.$dir;
72
+    $dir = '/'.$dir;
73 73
 }
74 74
 
75 75
 if ($dir[strlen($dir) - 1] != '/') {
76
-	$dir .= '/';
76
+    $dir .= '/';
77 77
 }
78 78
 
79 79
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
80 80
 
81 81
 if (!is_dir($filepath)) {
82
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
83
-	$dir = '/';
82
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
83
+    $dir = '/';
84 84
 }
85 85
 
86 86
 //groups //TODO:clean
87 87
 if (!empty($groupId)) {
88
-	$interbreadcrumb[] = array(
89
-		'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
90
-		'name' => get_lang('GroupSpace'),
91
-	);
92
-	$group_document = true;
93
-	$noPHP_SELF = true;
88
+    $interbreadcrumb[] = array(
89
+        'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
90
+        'name' => get_lang('GroupSpace'),
91
+    );
92
+    $group_document = true;
93
+    $noPHP_SELF = true;
94 94
 }
95 95
 
96 96
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
97 97
 
98 98
 if (!$is_certificate_mode)
99
-	$interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents'));
99
+    $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents'));
100 100
 else
101
-	$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
101
+    $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
102 102
 
103 103
 // Interbreadcrumb for the current directory root path
104 104
 if (empty($document_data['parents'])) {
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 }
114 114
 
115 115
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] ||
116
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
116
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
117 117
 
118 118
 if (!$is_allowedToEdit) {
119
-	api_not_allowed(true);
119
+    api_not_allowed(true);
120 120
 }
121 121
 
122 122
 Event::event_access_tool(TOOL_DOCUMENT);
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
 $locktitle="false";
149 149
 
150 150
 if ($_SERVER['HTTP_HOST']=="localhost") {
151
-	$path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
152
-	if (!file_exists($path_and_file)) {
153
-		$crossdomain='<?xml version="1.0"?>
151
+    $path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
152
+    if (!file_exists($path_and_file)) {
153
+        $crossdomain='<?xml version="1.0"?>
154 154
 			<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
155 155
 			<cross-domain-policy>
156 156
 				<allow-access-from domain="cdn.pixlr.com" />
157 157
 				<site-control permitted-cross-domain-policies="master-only"/>
158 158
 				<allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/>
159 159
 			</cross-domain-policy>';//more open domain="*"
160
-		@file_put_contents($path_and_file, $crossdomain);
161
-	}
162
-	$credentials="true";
160
+        @file_put_contents($path_and_file, $crossdomain);
161
+    }
162
+    $credentials="true";
163 163
 }
164 164
 else {
165
-	$credentials="false";
165
+    $credentials="false";
166 166
 }
167 167
 
168 168
 //make temp images
@@ -175,23 +175,23 @@  discard block
 block discarded – undo
175 175
 $htaccess=api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess';
176 176
 if (!file_exists($htaccess)) {
177 177
 
178
-	$htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes";
178
+    $htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes";
179 179
 
180
-	$fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w');
181
-	if ($fp) {
182
-		fwrite($fp, $htaccess_content);
183
-		fclose($fp);
184
-	}
180
+    $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w');
181
+    if ($fp) {
182
+        fwrite($fp, $htaccess_content);
183
+        fclose($fp);
184
+    }
185 185
 }
186 186
 
187 187
 $html_index=api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html';
188 188
 if (!file_exists($html_index)) {
189
-	$html_index_content="<html><head></head><body></body></html>";
190
-	$fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w');
191
-	if ($fp) {
192
-		fwrite($fp, $html_index_content);
193
-		fclose($fp);
194
-	}
189
+    $html_index_content="<html><head></head><body></body></html>";
190
+    $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w');
191
+    if ($fp) {
192
+        fwrite($fp, $html_index_content);
193
+        fclose($fp);
194
+    }
195 195
 }
196 196
 
197 197
 //encript temp name file
Please login to merge, or discard this patch.
main/inc/lib/pear/HTML/QuickForm.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
     public function &addElement($element)
631 631
     {
632 632
         if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) {
633
-           $elementObject = &$element;
634
-           $elementObject->onQuickFormEvent('updateValue', null, $this);
633
+            $elementObject = &$element;
634
+            $elementObject->onQuickFormEvent('updateValue', null, $this);
635 635
         } else {
636 636
             $args = func_get_args();
637 637
             $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1));
@@ -676,22 +676,22 @@  discard block
 block discarded – undo
676 676
     // }}}
677 677
     // {{{ insertElementBefore()
678 678
 
679
-   /**
680
-    * Inserts a new element right before the other element
681
-    *
682
-    * Warning: it is not possible to check whether the $element is already
683
-    * added to the form, therefore if you want to move the existing form
684
-    * element to a new position, you'll have to use removeElement():
685
-    * $form->insertElementBefore($form->removeElement('foo', false), 'bar');
686
-    *
687
-    * @access   public
688
-    * @since    3.2.4
689
-    * @param    HTML_QuickForm_element  Element to insert
690
-    * @param    string                  Name of the element before which the new
691
-    *                                   one is inserted
692
-    * @return   HTML_QuickForm_element  reference to inserted element
693
-    * @throws   HTML_QuickForm_Error
694
-    */
679
+    /**
680
+     * Inserts a new element right before the other element
681
+     *
682
+     * Warning: it is not possible to check whether the $element is already
683
+     * added to the form, therefore if you want to move the existing form
684
+     * element to a new position, you'll have to use removeElement():
685
+     * $form->insertElementBefore($form->removeElement('foo', false), 'bar');
686
+     *
687
+     * @access   public
688
+     * @since    3.2.4
689
+     * @param    HTML_QuickForm_element  Element to insert
690
+     * @param    string                  Name of the element before which the new
691
+     *                                   one is inserted
692
+     * @return   HTML_QuickForm_element  reference to inserted element
693
+     * @throws   HTML_QuickForm_Error
694
+     */
695 695
     function &insertElementBefore(&$element, $nameAfter)
696 696
     {
697 697
         if (!empty($this->_duplicateIndex[$nameAfter])) {
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
             if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) {
871 871
                 $props = array('name', 'type', 'size', 'tmp_name', 'error');
872 872
                 $code  = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" .
873
-                         "    return null;\n" .
874
-                         "} else {\n" .
875
-                         "    \$v = array();\n";
873
+                            "    return null;\n" .
874
+                            "} else {\n" .
875
+                            "    \$v = array();\n";
876 876
                 foreach ($props as $prop) {
877 877
                     $code .= "    \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n";
878 878
                 }
@@ -917,13 +917,13 @@  discard block
 block discarded – undo
917 917
         return $value;
918 918
     }
919 919
 
920
-   /**
921
-    * A helper function to change the indexes in $_FILES array
922
-    *
923
-    * @param  mixed   Some value from the $_FILES array
924
-    * @param  string  The key from the $_FILES array that should be appended
925
-    * @return array
926
-    */
920
+    /**
921
+     * A helper function to change the indexes in $_FILES array
922
+     *
923
+     * @param  mixed   Some value from the $_FILES array
924
+     * @param  string  The key from the $_FILES array that should be appended
925
+     * @return array
926
+     */
927 927
     function _reindexFiles($value, $key)
928 928
     {
929 929
         if (!is_array($value)) {
@@ -976,27 +976,27 @@  discard block
 block discarded – undo
976 976
         }
977 977
     } // end func setElementError
978 978
 
979
-     // }}}
980
-     // {{{ getElementType()
981
-
982
-     /**
983
-      * Returns the type of the given element
984
-      *
985
-      * @param      string    $element    Name of form element
986
-      * @since      1.1
987
-      * @access     public
988
-      * @return     string    Type of the element, false if the element is not found
989
-      */
990
-     function getElementType($element)
991
-     {
992
-         if (isset($this->_elementIndex[$element])) {
993
-             return $this->_elements[$this->_elementIndex[$element]]->getType();
994
-         }
995
-         return false;
996
-     } // end func getElementType
997
-
998
-     // }}}
999
-     // {{{ updateElementAttr()
979
+        // }}}
980
+        // {{{ getElementType()
981
+
982
+        /**
983
+         * Returns the type of the given element
984
+         *
985
+         * @param      string    $element    Name of form element
986
+         * @since      1.1
987
+         * @access     public
988
+         * @return     string    Type of the element, false if the element is not found
989
+         */
990
+        function getElementType($element)
991
+        {
992
+            if (isset($this->_elementIndex[$element])) {
993
+                return $this->_elements[$this->_elementIndex[$element]]->getType();
994
+            }
995
+            return false;
996
+        } // end func getElementType
997
+
998
+        // }}}
999
+        // {{{ updateElementAttr()
1000 1000
 
1001 1001
     /**
1002 1002
      * Updates Attributes for one or more elements
@@ -1263,18 +1263,18 @@  discard block
 block discarded – undo
1263 1263
     // }}}
1264 1264
     // {{{ addFormRule()
1265 1265
 
1266
-   /**
1267
-    * Adds a global validation rule
1268
-    *
1269
-    * This should be used when for a rule involving several fields or if
1270
-    * you want to use some completely custom validation for your form.
1271
-    * The rule function/method should return true in case of successful
1272
-    * validation and array('element name' => 'error') when there were errors.
1273
-    *
1274
-    * @access   public
1275
-    * @param    mixed   Callback, either function name or array(&$object, 'method')
1276
-    * @throws   HTML_QuickForm_Error
1277
-    */
1266
+    /**
1267
+     * Adds a global validation rule
1268
+     *
1269
+     * This should be used when for a rule involving several fields or if
1270
+     * you want to use some completely custom validation for your form.
1271
+     * The rule function/method should return true in case of successful
1272
+     * validation and array('element name' => 'error') when there were errors.
1273
+     *
1274
+     * @access   public
1275
+     * @param    mixed   Callback, either function name or array(&$object, 'method')
1276
+     * @throws   HTML_QuickForm_Error
1277
+     */
1278 1278
     function addFormRule($rule)
1279 1279
     {
1280 1280
         if (!is_callable($rule)) {
@@ -1351,18 +1351,18 @@  discard block
 block discarded – undo
1351 1351
     // }}}
1352 1352
     // {{{ arrayMerge()
1353 1353
 
1354
-   /**
1355
-    * Merges two arrays
1356
-    *
1357
-    * Merges two array like the PHP function array_merge but recursively.
1358
-    * The main difference is that existing keys will not be renumbered
1359
-    * if they are integers.
1360
-    *
1361
-    * @access   public
1362
-    * @param    array   $a  original array
1363
-    * @param    array   $b  array which will be merged into first one
1364
-    * @return   array   merged array
1365
-    */
1354
+    /**
1355
+     * Merges two arrays
1356
+     *
1357
+     * Merges two array like the PHP function array_merge but recursively.
1358
+     * The main difference is that existing keys will not be renumbered
1359
+     * if they are integers.
1360
+     *
1361
+     * @access   public
1362
+     * @param    array   $a  original array
1363
+     * @param    array   $b  array which will be merged into first one
1364
+     * @return   array   merged array
1365
+     */
1366 1366
     static function arrayMerge($a, $b)
1367 1367
     {
1368 1368
         foreach ($b as $k => $v) {
@@ -1493,10 +1493,10 @@  discard block
 block discarded – undo
1493 1493
      */
1494 1494
     function isElementFrozen($element)
1495 1495
     {
1496
-         if (isset($this->_elementIndex[$element])) {
1497
-             return $this->_elements[$this->_elementIndex[$element]]->isFrozen();
1498
-         }
1499
-         return false;
1496
+            if (isset($this->_elementIndex[$element])) {
1497
+                return $this->_elements[$this->_elementIndex[$element]]->isFrozen();
1498
+            }
1499
+            return false;
1500 1500
     } // end func isElementFrozen
1501 1501
 
1502 1502
     // }}}
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
      */
1686 1686
     function isFrozen()
1687 1687
     {
1688
-         return $this->_freezeAll;
1688
+            return $this->_freezeAll;
1689 1689
     }
1690 1690
 
1691 1691
     /**
@@ -1707,14 +1707,14 @@  discard block
 block discarded – undo
1707 1707
         return call_user_func($callback, $values);
1708 1708
     }
1709 1709
 
1710
-   /**
1711
-    * Accepts a renderer
1712
-    *
1713
-    * @param object     An HTML_QuickForm_Renderer object
1714
-    * @since 3.0
1715
-    * @access public
1716
-    * @return void
1717
-    */
1710
+    /**
1711
+     * Accepts a renderer
1712
+     *
1713
+     * @param object     An HTML_QuickForm_Renderer object
1714
+     * @since 3.0
1715
+     * @access public
1716
+     * @return void
1717
+     */
1718 1718
     function accept(&$renderer) {
1719 1719
         $renderer->startForm($this);
1720 1720
         foreach (array_keys($this->_elements) as $key) {
@@ -1727,13 +1727,13 @@  discard block
 block discarded – undo
1727 1727
         $renderer->finishForm($this);
1728 1728
     }
1729 1729
 
1730
-   /**
1731
-    * Returns a reference to default renderer object
1732
-    *
1733
-    * @access public
1734
-    * @since 3.0
1735
-    * @return HTML_QuickForm_Renderer_Default
1736
-    */
1730
+    /**
1731
+     * Returns a reference to default renderer object
1732
+     *
1733
+     * @access public
1734
+     * @since 3.0
1735
+     * @return HTML_QuickForm_Renderer_Default
1736
+     */
1737 1737
     function &defaultRenderer() {
1738 1738
         if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) {
1739 1739
             // Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
         //
1890 1890
         $this->accept($renderer);
1891 1891
         return $renderer->toArray();
1892
-     }
1892
+        }
1893 1893
 
1894 1894
     /**
1895 1895
      * Returns a 'safe' element's value
@@ -1961,15 +1961,15 @@  discard block
 block discarded – undo
1961 1961
         return $values;
1962 1962
     }
1963 1963
 
1964
-   /**
1965
-    * Tells whether the form was already submitted
1966
-    *
1967
-    * This is useful since the _submitFiles and _submitValues arrays
1968
-    * may be completely empty after the trackSubmit value is removed.
1969
-    *
1970
-    * @access public
1971
-    * @return bool
1972
-    */
1964
+    /**
1965
+     * Tells whether the form was already submitted
1966
+     *
1967
+     * This is useful since the _submitFiles and _submitValues arrays
1968
+     * may be completely empty after the trackSubmit value is removed.
1969
+     *
1970
+     * @access public
1971
+     * @return bool
1972
+     */
1973 1973
     function isSubmitted()
1974 1974
     {
1975 1975
         return $this->_flagSubmitted;
@@ -2056,21 +2056,21 @@  discard block
 block discarded – undo
2056 2056
 {
2057 2057
 
2058 2058
     /**
2059
-    * Prefix for all error messages
2060
-    * @var string
2061
-    */
2059
+     * Prefix for all error messages
2060
+     * @var string
2061
+     */
2062 2062
     var $error_message_prefix = 'QuickForm Error: ';
2063 2063
 
2064 2064
     /**
2065
-    * Creates a quickform error object, extending the PEAR_Error class
2066
-    *
2067
-    * @param int   $code the error code
2068
-    * @param int   $mode the reaction to the error, either return, die or trigger/callback
2069
-    * @param int   $level intensity of the error (PHP error code)
2070
-    * @param mixed $debuginfo any information that can inform user as to nature of the error
2071
-    */
2065
+     * Creates a quickform error object, extending the PEAR_Error class
2066
+     *
2067
+     * @param int   $code the error code
2068
+     * @param int   $mode the reaction to the error, either return, die or trigger/callback
2069
+     * @param int   $level intensity of the error (PHP error code)
2070
+     * @param mixed $debuginfo any information that can inform user as to nature of the error
2071
+     */
2072 2072
     function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN,
2073
-                         $level = E_USER_NOTICE, $debuginfo = null)
2073
+                            $level = E_USER_NOTICE, $debuginfo = null)
2074 2074
     {
2075 2075
         if (is_int($code)) {
2076 2076
             $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo);
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseRestorer.class.php 1 patch
Indentation   +710 added lines, -710 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class CourseRestorer
38 38
 {
39
-	/**
40
-	 * The course-object
41
-	 */
39
+    /**
40
+     * The course-object
41
+     */
42 42
     public $course;
43 43
     public $destination_course_info;
44 44
 
45
-	/**
46
-	 * What to do with files with same name (FILE_SKIP, FILE_RENAME or
47
-	 * FILE_OVERWRITE)
48
-	 */
45
+    /**
46
+     * What to do with files with same name (FILE_SKIP, FILE_RENAME or
47
+     * FILE_OVERWRITE)
48
+     */
49 49
     public $file_option;
50 50
     public $set_tools_invisible_by_default;
51 51
     public $skip_content;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         'events',
58 58
         'forum_category',
59 59
         'forums',
60
-       // 'forum_topics',
60
+        // 'forum_topics',
61 61
         'glossary',
62 62
         'quizzes',
63 63
         'test_category',
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
         $this->tool_copy_settings = $array;
127 127
     }
128 128
 
129
-	/**
130
-	 * Restore a course.
129
+    /**
130
+     * Restore a course.
131 131
      *
132
-	 * @param string    $destination_course_code code of the Chamilo-course in
133
-	 * @param int	    $session_id
134
-	 * @param bool	    $update_course_settings Course settings are going to be restore?
132
+     * @param string    $destination_course_code code of the Chamilo-course in
133
+     * @param int	    $session_id
134
+     * @param bool	    $update_course_settings Course settings are going to be restore?
135 135
      * @param bool      $respect_base_content
136 136
      * @return bool
137
-	 */
137
+     */
138 138
     public function restore(
139 139
         $destination_course_code = '',
140 140
         $session_id = 0,
@@ -277,17 +277,17 @@  discard block
 block discarded – undo
277 277
         }
278 278
     }
279 279
 
280
-	/**
281
-	 * Restore only harmless course settings:
280
+    /**
281
+     * Restore only harmless course settings:
282 282
      * course_language, visibility, department_name,department_url,
283 283
      * subscribe, unsubscribe ,category_code
284
-	 *
285
-	 * @param string $destination_course_code
286
-	 */
284
+     *
285
+     * @param string $destination_course_code
286
+     */
287 287
     public function restore_course_settings($destination_course_code)
288 288
     {
289
-	    $origin_course_info = api_get_course_info($destination_course_code);
290
-	    $course_info = $this->course->info;
289
+        $origin_course_info = api_get_course_info($destination_course_code);
290
+        $course_info = $this->course->info;
291 291
         $params['course_language'] = $course_info['language'];
292 292
         $params['visibility'] = $course_info['visibility'];
293 293
         $params['department_name'] = $course_info['department_name'];
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
         $params['category_code'] = $course_info['categoryCode'];
297 297
         $params['subscribe'] = $course_info['subscribe_allowed'];
298 298
         $params['unsubscribe'] = $course_info['unsubscribe'];
299
-	    CourseManager::update_attributes($origin_course_info['real_id'], $params);
300
-	}
299
+        CourseManager::update_attributes($origin_course_info['real_id'], $params);
300
+    }
301 301
 
302 302
     /**
303 303
      * Restore documents
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
         $course_info = api_get_course_info($destination_course_code);
312 312
 
313 313
         if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
314
-			$table = Database :: get_course_table(TABLE_DOCUMENT);
315
-			$resources = $this->course->resources;
314
+            $table = Database :: get_course_table(TABLE_DOCUMENT);
315
+            $resources = $this->course->resources;
316 316
             $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
317 317
 
318
-			foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
318
+            foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
319 319
 
320 320
                 if (empty($document->item_properties[0]['id_session'])) {
321 321
                     $my_session_id = 0;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                             }
386 386
                         }
387 387
                     }
388
-		    	} elseif ($document->file_type == DOCUMENT) {
388
+                } elseif ($document->file_type == DOCUMENT) {
389 389
                     //Checking if folder exists in the database otherwise we created it
390 390
                     $dir_to_create = dirname($document->path);
391 391
 
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
                         }
442 442
                     }
443 443
 
444
-					if (file_exists($path.$document->path)) {
445
-						switch ($this->file_option) {
446
-							case FILE_OVERWRITE:
444
+                    if (file_exists($path.$document->path)) {
445
+                        switch ($this->file_option) {
446
+                            case FILE_OVERWRITE:
447 447
                                 $origin_path = $this->course->backup_path.'/'.$document->path;
448 448
 
449
-								if (file_exists($origin_path)) {
450
-        						    copy($origin_path, $path.$document->path);
449
+                                if (file_exists($origin_path)) {
450
+                                    copy($origin_path, $path.$document->path);
451 451
                                     $sql = "SELECT id FROM $table
452 452
                                             WHERE
453 453
                                                 c_id = ".$this->destination_course_id." AND
454 454
                                                 path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'";
455 455
 
456
-        						    $res = Database::query($sql);
456
+                                    $res = Database::query($sql);
457 457
                                     $count = Database::num_rows($res);
458 458
 
459 459
                                     if ($count == 0) {
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                                             'session_id' => $my_session_id,
468 468
                                         ];
469 469
 
470
-    									$document_id = Database::insert($table, $params);
470
+                                        $document_id = Database::insert($table, $params);
471 471
 
472 472
                                         if ($document_id) {
473 473
                                             $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
@@ -575,83 +575,83 @@  discard block
 block discarded – undo
575 575
                                             ],
576 576
                                         ]
577 577
                                     );
578
-								}
578
+                                }
579 579
 
580
-								break;
581
-							case FILE_SKIP:
582
-								$sql = "SELECT id FROM $table
580
+                                break;
581
+                            case FILE_SKIP:
582
+                                $sql = "SELECT id FROM $table
583 583
 								        WHERE
584 584
 								            c_id = ".$this->destination_course_id." AND
585 585
 								            path='/".self::DBUTF8escapestring(substr($document->path, 9))."'";
586
-								$res = Database::query($sql);
587
-								$obj = Database::fetch_object($res);
588
-								$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
589
-								break;
590
-							case FILE_RENAME:
591
-								$i = 1;
592
-								$ext = explode('.', basename($document->path));
593
-								if (count($ext) > 1) {
594
-									$ext = array_pop($ext);
595
-									$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
596
-									$ext = '.'.$ext;
597
-								} else {
598
-									$ext = '';
599
-									$file_name_no_ext = $document->path;
600
-								}
601
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
602
-								$file_exists = file_exists($path.$new_file_name);
603
-								while ($file_exists) {
604
-									$i ++;
605
-									$new_file_name = $file_name_no_ext.'_'.$i.$ext;
606
-									$file_exists = file_exists($path.$new_file_name);
607
-								}
608
-
609
-								if (!empty($session_id)) {
610
-
611
-									$document_path = explode('/',$document->path,3);
612
-									$course_path = $path;
613
-									$orig_base_folder = $document_path[1];
614
-									$orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
615
-
616
-									if (is_dir($orig_base_path)) {
617
-
618
-										$new_base_foldername = $orig_base_folder;
619
-										$new_base_path = $orig_base_path;
620
-
621
-										if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
622
-											unset($_SESSION['new_base_foldername']);
623
-											unset($_SESSION['orig_base_foldername']);
624
-											unset($_SESSION['new_base_path']);
625
-										}
626
-
627
-										$folder_exists = file_exists($new_base_path);
628
-										if ($folder_exists) {
629
-											$_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
630
-											$x = '';
631
-											while ($folder_exists) {
632
-												$x = $x + 1;
633
-												$new_base_foldername = $document_path[1].'_'.$x;
634
-												$new_base_path = $orig_base_path.'_'.$x;
586
+                                $res = Database::query($sql);
587
+                                $obj = Database::fetch_object($res);
588
+                                $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
589
+                                break;
590
+                            case FILE_RENAME:
591
+                                $i = 1;
592
+                                $ext = explode('.', basename($document->path));
593
+                                if (count($ext) > 1) {
594
+                                    $ext = array_pop($ext);
595
+                                    $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
596
+                                    $ext = '.'.$ext;
597
+                                } else {
598
+                                    $ext = '';
599
+                                    $file_name_no_ext = $document->path;
600
+                                }
601
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
602
+                                $file_exists = file_exists($path.$new_file_name);
603
+                                while ($file_exists) {
604
+                                    $i ++;
605
+                                    $new_file_name = $file_name_no_ext.'_'.$i.$ext;
606
+                                    $file_exists = file_exists($path.$new_file_name);
607
+                                }
608
+
609
+                                if (!empty($session_id)) {
610
+
611
+                                    $document_path = explode('/',$document->path,3);
612
+                                    $course_path = $path;
613
+                                    $orig_base_folder = $document_path[1];
614
+                                    $orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
615
+
616
+                                    if (is_dir($orig_base_path)) {
617
+
618
+                                        $new_base_foldername = $orig_base_folder;
619
+                                        $new_base_path = $orig_base_path;
620
+
621
+                                        if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
622
+                                            unset($_SESSION['new_base_foldername']);
623
+                                            unset($_SESSION['orig_base_foldername']);
624
+                                            unset($_SESSION['new_base_path']);
625
+                                        }
626
+
627
+                                        $folder_exists = file_exists($new_base_path);
628
+                                        if ($folder_exists) {
629
+                                            $_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
630
+                                            $x = '';
631
+                                            while ($folder_exists) {
632
+                                                $x = $x + 1;
633
+                                                $new_base_foldername = $document_path[1].'_'.$x;
634
+                                                $new_base_path = $orig_base_path.'_'.$x;
635 635
                                                 if ($_SESSION['new_base_foldername'] == $new_base_foldername) {
636 636
                                                     break;
637 637
                                                 }
638
-												$folder_exists = file_exists($new_base_path);
639
-											}
640
-											$_SESSION['new_base_foldername'] = $new_base_foldername;
641
-											$_SESSION['new_base_path'] = $new_base_path;
642
-										}
643
-
644
-										if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
645
-											$new_base_foldername = $_SESSION['new_base_foldername'];
646
-											$new_base_path = $_SESSION['new_base_path'];
647
-										}
648
-
649
-										$dest_document_path = $new_base_path.'/'.$document_path[2];		// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
650
-										$basedir_dest_path 	= dirname($dest_document_path);				// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
651
-										$base_path_document = $course_path.$document_path[0];			// e.g: "/var/www/wiener/courses/CURSO4/document"
652
-										$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
653
-
654
-										copy_folder_course_session(
638
+                                                $folder_exists = file_exists($new_base_path);
639
+                                            }
640
+                                            $_SESSION['new_base_foldername'] = $new_base_foldername;
641
+                                            $_SESSION['new_base_path'] = $new_base_path;
642
+                                        }
643
+
644
+                                        if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
645
+                                            $new_base_foldername = $_SESSION['new_base_foldername'];
646
+                                            $new_base_path = $_SESSION['new_base_path'];
647
+                                        }
648
+
649
+                                        $dest_document_path = $new_base_path.'/'.$document_path[2];		// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
650
+                                        $basedir_dest_path 	= dirname($dest_document_path);				// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
651
+                                        $base_path_document = $course_path.$document_path[0];			// e.g: "/var/www/wiener/courses/CURSO4/document"
652
+                                        $path_title = '/'.$new_base_foldername.'/'.$document_path[2];
653
+
654
+                                        copy_folder_course_session(
655 655
                                             $basedir_dest_path,
656 656
                                             $base_path_document,
657 657
                                             $session_id,
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
                                             'session_id' => $my_session_id,
694 694
                                         ];
695 695
 
696
-										$document_id = Database::insert($table, $params);
696
+                                        $document_id = Database::insert($table, $params);
697 697
 
698 698
                                         if ($document_id) {
699 699
                                             $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
@@ -722,10 +722,10 @@  discard block
 block discarded – undo
722 722
                                             null,
723 723
                                             $my_session_id
724 724
                                         );
725
-									} else {
726
-									    if (file_exists($path.$document->path)) {
725
+                                    } else {
726
+                                        if (file_exists($path.$document->path)) {
727 727
                                             copy($path.$document->path, $path.$new_file_name);
728
-									    }
728
+                                        }
729 729
                                         //Replace old course code with the new destination code see BT#1985
730 730
                                         if (file_exists($path.$new_file_name)) {
731 731
                                             $file_info = pathinfo($path.$new_file_name);
@@ -784,10 +784,10 @@  discard block
 block discarded – undo
784 784
                                                 $my_session_id
785 785
                                             );
786 786
                                         }
787
-									}
788
-								} else {
787
+                                    }
788
+                                } else {
789 789
 
790
-									copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
790
+                                    copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
791 791
 
792 792
                                     //Replace old course code with the new destination code see BT#1985
793 793
                                     if (file_exists($path.$new_file_name)) {
@@ -847,20 +847,20 @@  discard block
 block discarded – undo
847 847
                                         null,
848 848
                                         $my_session_id
849 849
                                     );
850
-								}
851
-								break;
852
-
853
-						} // end switch
854
-					} else {
855
-					    // end if file exists
856
-						//make sure the source file actually exists
857
-						if (is_file($this->course->backup_path.'/'.$document->path) &&
850
+                                }
851
+                                break;
852
+
853
+                        } // end switch
854
+                    } else {
855
+                        // end if file exists
856
+                        //make sure the source file actually exists
857
+                        if (is_file($this->course->backup_path.'/'.$document->path) &&
858 858
                             is_readable($this->course->backup_path.'/'.$document->path) &&
859 859
                             is_dir(dirname($path.$document->path)) &&
860 860
                             is_writeable(dirname($path.$document->path))
861 861
                         ) {
862
-						    //echo 'Copying';
863
-							copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
862
+                            //echo 'Copying';
863
+                            copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
864 864
 
865 865
                             //Replace old course code with the new destination code see BT#1985
866 866
                             if (file_exists($path.$document->path)) {
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                                 Database::query($sql);
899 899
                             }
900 900
 
901
-							$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
901
+                            $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
902 902
 
903 903
                             $itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : '';
904 904
                             $insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id();
@@ -920,79 +920,79 @@  discard block
 block discarded – undo
920 920
                                 null,
921 921
                                 $my_session_id
922 922
                             );
923
-						} else {
924
-							if (is_file($this->course->backup_path.'/'.$document->path) &&
923
+                        } else {
924
+                            if (is_file($this->course->backup_path.'/'.$document->path) &&
925 925
                                 is_readable($this->course->backup_path.'/'.$document->path)
926 926
                             ) {
927
-								error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found');
928
-							}
929
-							if (!is_dir(dirname($path.$document->path))) {
930
-								error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found');
931
-							}
932
-							if (!is_writeable(dirname($path.$document->path))) {
933
-								error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable');
934
-							}
935
-						}
936
-					} // end file doesn't exist
937
-				}
938
-			} // end for each
939
-
940
-    		// Delete sessions for the copy the new folder in session
941
-    		unset($_SESSION['new_base_foldername']);
942
-    		unset($_SESSION['orig_base_foldername']);
943
-    		unset($_SESSION['new_base_path']);
944
-		}
945
-	}
946
-
947
-	/**
948
-	 * Restore scorm documents
949
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
927
+                                error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found');
928
+                            }
929
+                            if (!is_dir(dirname($path.$document->path))) {
930
+                                error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found');
931
+                            }
932
+                            if (!is_writeable(dirname($path.$document->path))) {
933
+                                error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable');
934
+                            }
935
+                        }
936
+                    } // end file doesn't exist
937
+                }
938
+            } // end for each
939
+
940
+            // Delete sessions for the copy the new folder in session
941
+            unset($_SESSION['new_base_foldername']);
942
+            unset($_SESSION['orig_base_foldername']);
943
+            unset($_SESSION['new_base_path']);
944
+        }
945
+    }
946
+
947
+    /**
948
+     * Restore scorm documents
949
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
950 950
      * see #7029
951
-	 */
952
-	public function restore_scorm_documents()
951
+     */
952
+    public function restore_scorm_documents()
953 953
     {
954
-		$perm = api_get_permissions_for_new_directories();
954
+        $perm = api_get_permissions_for_new_directories();
955 955
 
956
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
957
-			$resources = $this->course->resources;
956
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
957
+            $resources = $this->course->resources;
958 958
 
959
-			foreach ($resources[RESOURCE_SCORM] as $document) {
960
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
959
+            foreach ($resources[RESOURCE_SCORM] as $document) {
960
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
961 961
 
962
-				@mkdir(dirname($path.$document->path), $perm, true);
962
+                @mkdir(dirname($path.$document->path), $perm, true);
963 963
 
964
-				if (file_exists($path.$document->path)) {
965
-					switch ($this->file_option) {
966
-						case FILE_OVERWRITE:
967
-							rmdirr($path.$document->path);
964
+                if (file_exists($path.$document->path)) {
965
+                    switch ($this->file_option) {
966
+                        case FILE_OVERWRITE:
967
+                            rmdirr($path.$document->path);
968 968
                             copyDirTo(
969 969
                                 $this->course->backup_path . '/' . $document->path,
970 970
                                 $path . dirname($document->path),
971 971
                                 false
972 972
                             );
973
-							break;
974
-						case FILE_SKIP:
975
-							break;
973
+                            break;
974
+                        case FILE_SKIP:
975
+                            break;
976 976
                         case FILE_RENAME:
977
-							$i = 1;
978
-							$ext = explode('.', basename($document->path));
979
-							if (count($ext) > 1) {
980
-								$ext = array_pop($ext);
981
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
982
-								$ext = '.'.$ext;
983
-							} else {
984
-								$ext = '';
985
-								$file_name_no_ext = $document->path;
986
-							}
987
-
988
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
989
-							$file_exists = file_exists($path.$new_file_name);
990
-
991
-							while ($file_exists) {
992
-								$i ++;
993
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
994
-								$file_exists = file_exists($path.$new_file_name);
995
-							}
977
+                            $i = 1;
978
+                            $ext = explode('.', basename($document->path));
979
+                            if (count($ext) > 1) {
980
+                                $ext = array_pop($ext);
981
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
982
+                                $ext = '.'.$ext;
983
+                            } else {
984
+                                $ext = '';
985
+                                $file_name_no_ext = $document->path;
986
+                            }
987
+
988
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
989
+                            $file_exists = file_exists($path.$new_file_name);
990
+
991
+                            while ($file_exists) {
992
+                                $i ++;
993
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
994
+                                $file_exists = file_exists($path.$new_file_name);
995
+                            }
996 996
 
997 997
                             rename(
998 998
                                 $this->course->backup_path . '/' . $document->path,
@@ -1008,30 +1008,30 @@  discard block
 block discarded – undo
1008 1008
                                 $this->course->backup_path . '/' . $document->path
1009 1009
                             );
1010 1010
 
1011
-							break;
1012
-					} // end switch
1013
-				} else {
1011
+                            break;
1012
+                    } // end switch
1013
+                } else {
1014 1014
                     // end if file exists
1015 1015
                     copyDirTo(
1016 1016
                         $this->course->backup_path . '/' . $document->path,
1017 1017
                         $path . dirname($document->path),
1018 1018
                         false
1019 1019
                     );
1020
-				}
1021
-			} // end for each
1022
-		}
1023
-	}
1024
-
1025
-	/**
1026
-	 * Restore forums
1027
-	 */
1028
-	public function restore_forums($sessionId = 0)
1020
+                }
1021
+            } // end for each
1022
+        }
1023
+    }
1024
+
1025
+    /**
1026
+     * Restore forums
1027
+     */
1028
+    public function restore_forums($sessionId = 0)
1029 1029
     {
1030
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
1030
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
1031 1031
             $sessionId = intval($sessionId);
1032
-			$table_forum = Database::get_course_table(TABLE_FORUM);
1033
-			$resources = $this->course->resources;
1034
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1032
+            $table_forum = Database::get_course_table(TABLE_FORUM);
1033
+            $resources = $this->course->resources;
1034
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1035 1035
                 $params = (array)$forum->obj;
1036 1036
                 $cat_id = '';
1037 1037
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1077,33 +1077,33 @@  discard block
 block discarded – undo
1077 1077
                     Database::query($sql);
1078 1078
                 }
1079 1079
 
1080
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1081
-
1082
-				$forum_topics = 0;
1083
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1084
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1085
-						if ($topic->obj->forum_id == $id) {
1086
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1087
-							$forum_topics ++;
1088
-						}
1089
-					}
1090
-				}
1091
-				if ($forum_topics > 0) {
1092
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1080
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1081
+
1082
+                $forum_topics = 0;
1083
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1084
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1085
+                        if ($topic->obj->forum_id == $id) {
1086
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1087
+                            $forum_topics ++;
1088
+                        }
1089
+                    }
1090
+                }
1091
+                if ($forum_topics > 0) {
1092
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1093 1093
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1094
-					Database::query($sql);
1095
-				}
1096
-			}
1097
-		}
1098
-	}
1099
-
1100
-	/**
1101
-	 * Restore forum-categories
1102
-	 */
1094
+                    Database::query($sql);
1095
+                }
1096
+            }
1097
+        }
1098
+    }
1099
+
1100
+    /**
1101
+     * Restore forum-categories
1102
+     */
1103 1103
     public function restore_forum_category($my_id = null, $sessionId = 0)
1104 1104
     {
1105
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1106
-		$resources = $this->course->resources;
1105
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1106
+        $resources = $this->course->resources;
1107 1107
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1108 1108
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1109 1109
                 if (!empty($my_id)) {
@@ -1150,15 +1150,15 @@  discard block
 block discarded – undo
1150 1150
                 }
1151 1151
             }
1152 1152
         }
1153
-	}
1153
+    }
1154 1154
 
1155
-	/**
1156
-	 * Restore a forum-topic
1157
-	 */
1155
+    /**
1156
+     * Restore a forum-topic
1157
+     */
1158 1158
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1159 1159
     {
1160
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1161
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1160
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1161
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1162 1162
 
1163 1163
         $params = (array)$topic->obj;
1164 1164
         $params = self::DBUTF8_array($params);
@@ -1194,27 +1194,27 @@  discard block
 block discarded – undo
1194 1194
             $sessionId
1195 1195
         );
1196 1196
 
1197
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1197
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1198 1198
 
1199
-		$topic_replies = -1;
1199
+        $topic_replies = -1;
1200 1200
 
1201
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1202
-			if ($post->obj->thread_id == $thread_id) {
1203
-				$topic_replies++;
1204
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1205
-			}
1206
-		}
1207
-		return $new_id;
1208
-	}
1201
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1202
+            if ($post->obj->thread_id == $thread_id) {
1203
+                $topic_replies++;
1204
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1205
+            }
1206
+        }
1207
+        return $new_id;
1208
+    }
1209 1209
 
1210
-	/**
1211
-	 * Restore a forum-post
1212
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1213
-	 */
1210
+    /**
1211
+     * Restore a forum-post
1212
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1213
+     */
1214 1214
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1215 1215
     {
1216
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1217
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1216
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1217
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1218 1218
         $params = (array) $post->obj;
1219 1219
         $params['c_id'] = $this->destination_course_id;
1220 1220
         $params['forum_id'] = $forum_id;
@@ -1249,37 +1249,37 @@  discard block
 block discarded – undo
1249 1249
             null,
1250 1250
             $sessionId
1251 1251
         );
1252
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1252
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1253 1253
 
1254
-		return $new_id;
1255
-	}
1254
+        return $new_id;
1255
+    }
1256 1256
 
1257
-	/**
1258
-	 * Restore links
1259
-	 */
1257
+    /**
1258
+     * Restore links
1259
+     */
1260 1260
     public function restore_links($session_id = 0)
1261 1261
     {
1262
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1263
-			$link_table = Database :: get_course_table(TABLE_LINK);
1264
-			$resources = $this->course->resources;
1262
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1263
+            $link_table = Database :: get_course_table(TABLE_LINK);
1264
+            $resources = $this->course->resources;
1265 1265
 
1266
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1266
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1267 1267
                 $cat_id = $this->restore_link_category(
1268 1268
                     $link->category_id,
1269 1269
                     $session_id
1270 1270
                 );
1271
-				$sql = "SELECT MAX(display_order)
1271
+                $sql = "SELECT MAX(display_order)
1272 1272
 				        FROM $link_table
1273 1273
 				        WHERE
1274 1274
 				            c_id = ".$this->destination_course_id." AND
1275 1275
 				            category_id='" . intval($cat_id). "'";
1276
-				$result = Database::query($sql);
1277
-    			list($max_order) = Database::fetch_array($result);
1276
+                $result = Database::query($sql);
1277
+                list($max_order) = Database::fetch_array($result);
1278 1278
 
1279 1279
                 $params = [];
1280
-    			if (!empty($session_id)) {
1280
+                if (!empty($session_id)) {
1281 1281
                     $params['session_id'] = $session_id;
1282
-    			}
1282
+                }
1283 1283
 
1284 1284
                 $params['c_id'] = $this->destination_course_id;
1285 1285
                 $params['url'] = self::DBUTF8($link->url);
@@ -1308,9 +1308,9 @@  discard block
 block discarded – undo
1308 1308
                     }
1309 1309
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1310 1310
                 }
1311
-			}
1312
-		}
1313
-	}
1311
+            }
1312
+        }
1313
+    }
1314 1314
 
1315 1315
     /**
1316 1316
      * Restore a link-category
@@ -1354,21 +1354,21 @@  discard block
 block discarded – undo
1354 1354
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1355 1355
     }
1356 1356
 
1357
-	/**
1358
-	 * Restore tool intro
1359
-	 */
1357
+    /**
1358
+     * Restore tool intro
1359
+     */
1360 1360
     public function restore_tool_intro($sessionId = 0)
1361 1361
     {
1362
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1362
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1363 1363
             $sessionId = intval($sessionId);
1364
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1365
-			$resources = $this->course->resources;
1366
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1367
-				$sql = "DELETE FROM ".$tool_intro_table."
1364
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1365
+            $resources = $this->course->resources;
1366
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1367
+                $sql = "DELETE FROM ".$tool_intro_table."
1368 1368
 				        WHERE
1369 1369
 				            c_id = ".$this->destination_course_id." AND
1370 1370
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1371
-				Database::query($sql);
1371
+                Database::query($sql);
1372 1372
 
1373 1373
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1374 1374
                     $tool_intro->intro_text,
@@ -1396,21 +1396,21 @@  discard block
 block discarded – undo
1396 1396
 
1397 1397
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1398 1398
                 }
1399
-			}
1400
-		}
1401
-	}
1399
+            }
1400
+        }
1401
+    }
1402 1402
 
1403
-	/**
1404
-	 * Restore events
1405
-	 */
1403
+    /**
1404
+     * Restore events
1405
+     */
1406 1406
     public function restore_events($sessionId = 0)
1407 1407
     {
1408
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1408
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1409 1409
             $sessionId = intval($sessionId);
1410
-			$table = Database :: get_course_table(TABLE_AGENDA);
1411
-			$resources = $this->course->resources;
1412
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1413
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1410
+            $table = Database :: get_course_table(TABLE_AGENDA);
1411
+            $resources = $this->course->resources;
1412
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1413
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1414 1414
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1415 1415
                     $event->content,
1416 1416
                     $this->course->code,
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
                     'end_date' => $event->end_date,
1429 1429
                     'session_id' => $sessionId,
1430 1430
                 ];
1431
-				$new_event_id = Database::insert($table, $params);
1431
+                $new_event_id = Database::insert($table, $params);
1432 1432
 
1433 1433
                 if ($new_event_id) {
1434 1434
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1441,30 +1441,30 @@  discard block
 block discarded – undo
1441 1441
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1442 1442
                 }
1443 1443
 
1444
-				// Copy event attachment
1444
+                // Copy event attachment
1445 1445
 
1446
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1447
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1446
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1447
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1448 1448
 
1449
-				if (!empty($this->course->orig)) {
1449
+                if (!empty($this->course->orig)) {
1450 1450
 
1451
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1452
-					$sql = 'SELECT path, comment, size, filename
1451
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1452
+                    $sql = 'SELECT path, comment, size, filename
1453 1453
 					        FROM '.$table_attachment.'
1454 1454
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1455
-					$attachment_event = Database::query($sql);
1456
-					$attachment_event = Database::fetch_object($attachment_event);
1455
+                    $attachment_event = Database::query($sql);
1456
+                    $attachment_event = Database::fetch_object($attachment_event);
1457 1457
 
1458
-					if (file_exists($origin_path.$attachment_event->path) &&
1458
+                    if (file_exists($origin_path.$attachment_event->path) &&
1459 1459
                         !is_dir($origin_path.$attachment_event->path)
1460 1460
                     ) {
1461
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1462
-						$copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1463
-						//$copy_result = true;
1464
-						if ($copy_result) {
1465
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1461
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1462
+                        $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1463
+                        //$copy_result = true;
1464
+                        if ($copy_result) {
1465
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1466 1466
 
1467
-							$params = [
1467
+                            $params = [
1468 1468
                                 'c_id' => $this->destination_course_id,
1469 1469
                                 'path' => self::DBUTF8($new_filename),
1470 1470
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1478,17 +1478,17 @@  discard block
 block discarded – undo
1478 1478
                                 Database::query($sql);
1479 1479
                             }
1480 1480
                         }
1481
-					}
1482
-				} else {
1483
-					// get the info of the file
1484
-					if (!empty($event->attachment_path) &&
1481
+                    }
1482
+                } else {
1483
+                    // get the info of the file
1484
+                    if (!empty($event->attachment_path) &&
1485 1485
                         is_file($origin_path.$event->attachment_path) &&
1486 1486
                         is_readable($origin_path.$event->attachment_path)
1487 1487
                     ) {
1488
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1489
-						$copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1490
-						if ($copy_result) {
1491
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1488
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1489
+                        $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1490
+                        if ($copy_result) {
1491
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1492 1492
 
1493 1493
                             $params = [
1494 1494
                                 'c_id' => $this->destination_course_id,
@@ -1504,29 +1504,29 @@  discard block
 block discarded – undo
1504 1504
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1505 1505
                                 Database::query($sql);
1506 1506
                             }
1507
-						}
1508
-					}
1509
-				}
1510
-			}
1511
-		}
1512
-	}
1513
-
1514
-	/**
1515
-	 * Restore course-description
1516
-	 */
1507
+                        }
1508
+                    }
1509
+                }
1510
+            }
1511
+        }
1512
+    }
1513
+
1514
+    /**
1515
+     * Restore course-description
1516
+     */
1517 1517
     public function restore_course_descriptions($session_id = 0)
1518 1518
     {
1519
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1520
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1521
-			$resources = $this->course->resources;
1522
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1519
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1520
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1521
+            $resources = $this->course->resources;
1522
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1523 1523
                 $courseDescription = (array) $cd;
1524 1524
 
1525 1525
                 $content = isset($courseDescription['content']) ? $courseDescription['content'] : '';
1526 1526
                 $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : '';
1527 1527
                 $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
1528 1528
 
1529
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1529
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1530 1530
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1531 1531
                     $content,
1532 1532
                     $this->course->code,
@@ -1554,22 +1554,22 @@  discard block
 block discarded – undo
1554 1554
                     }
1555 1555
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1556 1556
                 }
1557
-			}
1558
-		}
1559
-	}
1557
+            }
1558
+        }
1559
+    }
1560 1560
 
1561
-	/**
1562
-	 * Restore announcements
1563
-	 */
1561
+    /**
1562
+     * Restore announcements
1563
+     */
1564 1564
     public function restore_announcements($sessionId = 0)
1565 1565
     {
1566
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1566
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1567 1567
             $sessionId = intval($sessionId);
1568
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1569
-			$resources = $this->course->resources;
1570
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1568
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1569
+            $resources = $this->course->resources;
1570
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1571 1571
 
1572
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1572
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1573 1573
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1574 1574
                     $announcement->content,
1575 1575
                     $this->course->code,
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
                     'session_id' => $sessionId,
1589 1589
                 ];
1590 1590
 
1591
-				$new_announcement_id = Database::insert($table, $params);
1591
+                $new_announcement_id = Database::insert($table, $params);
1592 1592
 
1593 1593
                 if ($new_announcement_id) {
1594 1594
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1600,32 +1600,32 @@  discard block
 block discarded – undo
1600 1600
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1601 1601
                 }
1602 1602
 
1603
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1604
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1603
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1604
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1605 1605
 
1606
-				// Copy announcement attachment file
1607
-				if (!empty($this->course->orig)) {
1606
+                // Copy announcement attachment file
1607
+                if (!empty($this->course->orig)) {
1608 1608
 
1609
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1610
-					$sql = 'SELECT path, comment, size, filename
1609
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1610
+                    $sql = 'SELECT path, comment, size, filename
1611 1611
 					        FROM '.$table_attachment.'
1612 1612
 					        WHERE
1613 1613
 					            c_id = '.$this->destination_course_id.' AND
1614 1614
 					            announcement_id = '.$id;
1615
-					$attachment_event = Database::query($sql);
1616
-					$attachment_event = Database::fetch_object($attachment_event);
1615
+                    $attachment_event = Database::query($sql);
1616
+                    $attachment_event = Database::fetch_object($attachment_event);
1617 1617
 
1618
-					if (file_exists($origin_path.$attachment_event->path) &&
1618
+                    if (file_exists($origin_path.$attachment_event->path) &&
1619 1619
                         !is_dir($origin_path.$attachment_event->path)
1620 1620
                     ) {
1621
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1621
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1622 1622
                         $copy_result = copy(
1623 1623
                             $origin_path.$attachment_event->path,
1624 1624
                             $destination_path.$new_filename
1625 1625
                         );
1626 1626
 
1627
-						if ($copy_result) {
1628
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1627
+                        if ($copy_result) {
1628
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1629 1629
 
1630 1630
                             $params = [
1631 1631
                                 'c_id' => $this->destination_course_id,
@@ -1642,20 +1642,20 @@  discard block
 block discarded – undo
1642 1642
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1643 1643
                                 Database::query($sql);
1644 1644
                             }
1645
-						}
1646
-					}
1647
-				} else {
1648
-					// get the info of the file
1649
-					if (!empty($announcement->attachment_path) &&
1645
+                        }
1646
+                    }
1647
+                } else {
1648
+                    // get the info of the file
1649
+                    if (!empty($announcement->attachment_path) &&
1650 1650
                         is_file($origin_path.$announcement->attachment_path) &&
1651 1651
                         is_readable($origin_path.$announcement->attachment_path)
1652 1652
                     ) {
1653
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1654
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1653
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1654
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1655 1655
 
1656
-						if ($copy_result) {
1657
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1658
-							/*$sql = "INSERT INTO ".$table_attachment." SET
1656
+                        if ($copy_result) {
1657
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1658
+                            /*$sql = "INSERT INTO ".$table_attachment." SET
1659 1659
 							        c_id = ".$this->destination_course_id." ,
1660 1660
 							        path = '".self::DBUTF8escapestring($new_filename)."',
1661 1661
 							        comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."',
@@ -1678,12 +1678,12 @@  discard block
 block discarded – undo
1678 1678
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1679 1679
                                 Database::query($sql);
1680 1680
                             }
1681
-						}
1682
-					}
1683
-				}
1684
-			}
1685
-		}
1686
-	}
1681
+                        }
1682
+                    }
1683
+                }
1684
+            }
1685
+        }
1686
+    }
1687 1687
 
1688 1688
     /**
1689 1689
      * Restore Quiz
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
         $session_id = 0,
1695 1695
         $respect_base_content = false
1696 1696
     ) {
1697
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1698
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1699
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1700
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1701
-			$resources = $this->course->resources;
1697
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1698
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1699
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1700
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1701
+            $resources = $this->course->resources;
1702 1702
 
1703
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1703
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1704 1704
 
1705 1705
                 if (isset($quiz->obj)) {
1706 1706
                     //For new imports
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
                     $quiz->obj = $quiz;
1711 1711
                 }
1712 1712
 
1713
-				$doc = '';
1713
+                $doc = '';
1714 1714
                 if (!empty($quiz->sound)) {
1715 1715
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1716 1716
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
@@ -1718,14 +1718,14 @@  discard block
 block discarded – undo
1718 1718
                                 WHERE
1719 1719
                                     c_id = " . $this->destination_course_id . "  AND
1720 1720
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1721
-						$doc = Database::query($sql);
1722
-						$doc = Database::fetch_object($doc);
1723
-						$doc = str_replace('/audio/', '', $doc->path);
1724
-					}
1725
-				}
1726
-
1727
-				if ($id != -1) {
1728
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1721
+                        $doc = Database::query($sql);
1722
+                        $doc = Database::fetch_object($doc);
1723
+                        $doc = str_replace('/audio/', '', $doc->path);
1724
+                    }
1725
+                }
1726
+
1727
+                if ($id != -1) {
1728
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1729 1729
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1730 1730
                         $quiz->description,
1731 1731
                         $this->course->code,
@@ -1734,13 +1734,13 @@  discard block
 block discarded – undo
1734 1734
                         $this->course->info['path']
1735 1735
                     );
1736 1736
 
1737
-					global $_custom;
1738
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1737
+                    global $_custom;
1738
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1739 1739
                         $_custom['exercises_clean_dates_when_restoring']
1740 1740
                     ) {
1741
-						$quiz->start_time = null;
1742
-						$quiz->end_time   = null;
1743
-					}
1741
+                        $quiz->start_time = null;
1742
+                        $quiz->end_time   = null;
1743
+                    }
1744 1744
 
1745 1745
                     $params = array(
1746 1746
                         'c_id' => $this->destination_course_id,
@@ -1772,10 +1772,10 @@  discard block
 block discarded – undo
1772 1772
                         }
1773 1773
                         $params['session_id'] = $my_session_id;
1774 1774
                     } else {
1775
-        				if (!empty($session_id)) {
1776
-        					$session_id = intval($session_id);
1775
+                        if (!empty($session_id)) {
1776
+                            $session_id = intval($session_id);
1777 1777
                             $params['session_id'] = $session_id;
1778
-    				    }
1778
+                        }
1779 1779
                     }
1780 1780
                     $new_id = Database::insert($table_qui, $params);
1781 1781
 
@@ -1784,15 +1784,15 @@  discard block
 block discarded – undo
1784 1784
                         Database::query($sql);
1785 1785
                     }
1786 1786
 
1787
-				} else {
1788
-					// $id = -1 identifies the fictionary test for collecting
1789
-					// orphan questions. We do not store it in the database.
1790
-					$new_id = -1;
1791
-				}
1787
+                } else {
1788
+                    // $id = -1 identifies the fictionary test for collecting
1789
+                    // orphan questions. We do not store it in the database.
1790
+                    $new_id = -1;
1791
+                }
1792 1792
 
1793
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1793
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1794 1794
 
1795
-				$order = 0;
1795
+                $order = 0;
1796 1796
                 if (!empty($quiz->question_ids)) {
1797 1797
                     foreach ($quiz->question_ids as $index => $question_id) {
1798 1798
                         $qid = $this->restore_quiz_question($question_id);
@@ -1805,30 +1805,30 @@  discard block
 block discarded – undo
1805 1805
                         Database::query($sql);
1806 1806
                     }
1807 1807
                 }
1808
-			}
1809
-		}
1810
-	}
1808
+            }
1809
+        }
1810
+    }
1811 1811
 
1812
-	/**
1813
-	 * Restore quiz-questions
1812
+    /**
1813
+     * Restore quiz-questions
1814 1814
      * @params int question id
1815
-	 */
1815
+     */
1816 1816
     public function restore_quiz_question($id)
1817 1817
     {
1818
-		$resources = $this->course->resources;
1818
+        $resources = $this->course->resources;
1819 1819
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1820 1820
 
1821
-		$new_id = 0;
1821
+        $new_id = 0;
1822 1822
 
1823
-		if (is_object($question)) {
1824
-			if ($question->is_restored()) {
1825
-				return $question->destination_id;
1826
-			}
1827
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1828
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1823
+        if (is_object($question)) {
1824
+            if ($question->is_restored()) {
1825
+                return $question->destination_id;
1826
+            }
1827
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1828
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1829 1829
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1830 1830
 
1831
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1831
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1832 1832
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1833 1833
                 $question->description,
1834 1834
                 $this->course->code,
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
                 'extra' => self::DBUTF8($question->extra),
1850 1850
             ];
1851 1851
 
1852
-			$new_id = Database::insert($table_que, $params);
1852
+            $new_id = Database::insert($table_que, $params);
1853 1853
 
1854 1854
             if ($new_id) {
1855 1855
 
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
                 foreach ($temp as $index => $answer) {
1892 1892
                     //id = '".$index."',
1893
-					$params = [
1893
+                    $params = [
1894 1894
                         'c_id' => $this->destination_course_id,
1895 1895
                         'question_id' => $new_id,
1896 1896
                         'answer' => self::DBUTF8($answer['answer']),
@@ -1907,12 +1907,12 @@  discard block
 block discarded – undo
1907 1907
                         $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId";
1908 1908
                         Database::query($sql);
1909 1909
                     }
1910
-				}
1911
-			} else {
1910
+                }
1911
+            } else {
1912 1912
                 $correct_answers = array();
1913
-				foreach ($question->answers as $index => $answer) {
1913
+                foreach ($question->answers as $index => $answer) {
1914 1914
 
1915
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1915
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1916 1916
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1917 1917
                         $answer['answer'],
1918 1918
                         $this->course->code,
@@ -1951,8 +1951,8 @@  discard block
 block discarded – undo
1951 1951
                     }
1952 1952
 
1953 1953
                     $correct_answers[$answerId] = $answer['correct'];
1954
-				}
1955
-			}
1954
+                }
1955
+            }
1956 1956
 
1957 1957
             //Current course id
1958 1958
             $course_id = api_get_course_int_id();
@@ -2049,12 +2049,12 @@  discard block
 block discarded – undo
2049 2049
                     }
2050 2050
                 }
2051 2051
             }
2052
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2053
-		}
2054
-		return $new_id;
2055
-	}
2052
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2053
+        }
2054
+        return $new_id;
2055
+    }
2056 2056
 
2057
-	/**
2057
+    /**
2058 2058
      * @todo : add session id when used for session
2059 2059
      */
2060 2060
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2134,21 +2134,21 @@  discard block
 block discarded – undo
2134 2134
         $sessionId = intval($sessionId);
2135 2135
 
2136 2136
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2137
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2138
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2139
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2140
-			$resources = $this->course->resources;
2141
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2137
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2138
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2139
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2140
+            $resources = $this->course->resources;
2141
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2142 2142
 
2143
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2143
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2144 2144
                         WHERE
2145 2145
                             c_id = '.$this->destination_course_id.' AND
2146 2146
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2147 2147
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2148 2148
 
2149
-				$result_check = Database::query($sql);
2149
+                $result_check = Database::query($sql);
2150 2150
 
2151
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2151
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2152 2152
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2153 2153
                     $survey->title,
2154 2154
                     $this->course->code,
@@ -2202,20 +2202,20 @@  discard block
 block discarded – undo
2202 2202
                     'session_id' => $sessionId,
2203 2203
                 ];
2204 2204
 
2205
-				//An existing survey exists with the same code and the same language
2206
-				if (Database::num_rows($result_check) == 1) {
2207
-					switch ($this->file_option) {
2208
-						case FILE_SKIP:
2209
-							//Do nothing
2210
-							break;
2211
-						case FILE_RENAME:
2212
-							$survey_code = $survey->code.'_';
2213
-							$i=1;
2214
-							$temp_survey_code = $survey_code.$i;
2215
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2216
-								$temp_survey_code = $survey_code.++$i;
2217
-							}
2218
-							$survey_code = $temp_survey_code;
2205
+                //An existing survey exists with the same code and the same language
2206
+                if (Database::num_rows($result_check) == 1) {
2207
+                    switch ($this->file_option) {
2208
+                        case FILE_SKIP:
2209
+                            //Do nothing
2210
+                            break;
2211
+                        case FILE_RENAME:
2212
+                            $survey_code = $survey->code.'_';
2213
+                            $i=1;
2214
+                            $temp_survey_code = $survey_code.$i;
2215
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2216
+                                $temp_survey_code = $survey_code.++$i;
2217
+                            }
2218
+                            $survey_code = $temp_survey_code;
2219 2219
 
2220 2220
                             $params['code'] = $survey_code;
2221 2221
                             $new_id = Database::insert($table_sur, $params);
@@ -2234,25 +2234,25 @@  discard block
 block discarded – undo
2234 2234
                                     Database::query($sql);
2235 2235
                                 }
2236 2236
                             }
2237
-							break;
2238
-						case FILE_OVERWRITE:
2239
-							// Delete the existing survey with the same code and language and import the one of the source course
2240
-							// getting the information of the survey (used for when the survey is shared)
2237
+                            break;
2238
+                        case FILE_OVERWRITE:
2239
+                            // Delete the existing survey with the same code and language and import the one of the source course
2240
+                            // getting the information of the survey (used for when the survey is shared)
2241 2241
 
2242
-							$sql = "SELECT * FROM $table_sur
2242
+                            $sql = "SELECT * FROM $table_sur
2243 2243
 							        WHERE
2244 2244
 							            c_id = ".$this->destination_course_id." AND
2245 2245
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2246
-							$result = Database::query($sql);
2247
-							$survey_data = Database::fetch_array($result,'ASSOC');
2246
+                            $result = Database::query($sql);
2247
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2248 2248
 
2249
-							// if the survey is shared => also delete the shared content
2250
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2249
+                            // if the survey is shared => also delete the shared content
2250
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2251 2251
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2252
-							}
2253
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2252
+                            }
2253
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2254 2254
 
2255
-							// Insert the new source survey
2255
+                            // Insert the new source survey
2256 2256
                             $new_id = Database::insert($table_sur, $params);
2257 2257
 
2258 2258
                             if ($new_id) {
@@ -2273,11 +2273,11 @@  discard block
 block discarded – undo
2273 2273
                                     Database::query($sql);
2274 2274
                                 }
2275 2275
                             }
2276
-							break;
2277
-						default:
2278
-							break;
2279
-					}
2280
-				} else {
2276
+                            break;
2277
+                        default:
2278
+                            break;
2279
+                    }
2280
+                } else {
2281 2281
                     // No existing survey with the same language and the same code, we just copy the survey
2282 2282
                     $new_id = Database::insert($table_sur, $params);
2283 2283
 
@@ -2299,43 +2299,43 @@  discard block
 block discarded – undo
2299 2299
                             Database::query($sql);
2300 2300
                         }
2301 2301
                     }
2302
-				}
2303
-			}
2304
-		}
2305
-	}
2306
-
2307
-	/**
2308
-	 * Check availability of a survey code
2309
-	 */
2302
+                }
2303
+            }
2304
+        }
2305
+    }
2306
+
2307
+    /**
2308
+     * Check availability of a survey code
2309
+     */
2310 2310
     public function is_survey_code_available($survey_code)
2311 2311
     {
2312
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2313
-		$sql = "SELECT * FROM $table_sur
2312
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2313
+        $sql = "SELECT * FROM $table_sur
2314 2314
 		        WHERE
2315 2315
 		            c_id = ".$this->destination_course_id." AND
2316 2316
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2317
-		$result = Database::query($sql);
2318
-		if (Database::num_rows($result) > 0) return false; else return true;
2319
-	}
2317
+        $result = Database::query($sql);
2318
+        if (Database::num_rows($result) > 0) return false; else return true;
2319
+    }
2320 2320
 
2321
-	/**
2322
-	 * Restore survey-questions
2323
-	 */
2321
+    /**
2322
+     * Restore survey-questions
2323
+     */
2324 2324
     public function restore_survey_question($id, $survey_id)
2325 2325
     {
2326
-		$resources = $this->course->resources;
2327
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2326
+        $resources = $this->course->resources;
2327
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2328 2328
 
2329
-		$new_id=0;
2329
+        $new_id=0;
2330 2330
 
2331
-		if (is_object($question)) {
2332
-			if ($question->is_restored()) {
2333
-				return $question->destination_id;
2334
-			}
2335
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2336
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2331
+        if (is_object($question)) {
2332
+            if ($question->is_restored()) {
2333
+                return $question->destination_id;
2334
+            }
2335
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2336
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2337 2337
 
2338
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2338
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2339 2339
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2340 2340
                 $question->survey_question,
2341 2341
                 $this->course->code,
@@ -2389,10 +2389,10 @@  discard block
 block discarded – undo
2389 2389
                 }
2390 2390
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2391 2391
             }
2392
-		}
2392
+        }
2393 2393
 
2394
-		return $new_id;
2395
-	}
2394
+        return $new_id;
2395
+    }
2396 2396
 
2397 2397
     /**
2398 2398
      * Restoring learning paths
@@ -2403,20 +2403,20 @@  discard block
 block discarded – undo
2403 2403
     {
2404 2404
         $session_id = intval($session_id);
2405 2405
 
2406
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2406
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2407 2407
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2408 2408
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2409 2409
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2410 2410
 
2411
-			$resources = $this->course->resources;
2411
+            $resources = $this->course->resources;
2412 2412
 
2413
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2414
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2413
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2414
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2415 2415
 
2416
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2416
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2417 2417
 
2418
-				$condition_session = "";
2419
-				if (!empty($session_id)) {
2418
+                $condition_session = "";
2419
+                if (!empty($session_id)) {
2420 2420
                     if ($respect_base_content) {
2421 2421
                         $my_session_id = $lp->session_id;
2422 2422
                         if (!empty($lp->session_id)) {
@@ -2427,21 +2427,21 @@  discard block
 block discarded – undo
2427 2427
                         $session_id = intval($session_id);
2428 2428
                         $condition_session = $session_id;
2429 2429
                     }
2430
-				}
2431
-
2432
-				// Adding the author's image
2433
-				if (!empty($lp->preview_image)) {
2434
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2435
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2436
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2437
-						//$copy_result = true;
2438
-						if ($copy_result) {
2439
-							$lp->preview_image = $new_filename;
2440
-						} else {
2441
-							$lp->preview_image ='';
2442
-						}
2443
-					}
2444
-				}
2430
+                }
2431
+
2432
+                // Adding the author's image
2433
+                if (!empty($lp->preview_image)) {
2434
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2435
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2436
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2437
+                        //$copy_result = true;
2438
+                        if ($copy_result) {
2439
+                            $lp->preview_image = $new_filename;
2440
+                        } else {
2441
+                            $lp->preview_image ='';
2442
+                        }
2443
+                    }
2444
+                }
2445 2445
 
2446 2446
                 if ($this->add_text_in_items) {
2447 2447
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
                     $params['session_id'] = $condition_session;
2489 2489
                 }
2490 2490
 
2491
-				$new_lp_id = Database::insert($table_main, $params);
2491
+                $new_lp_id = Database::insert($table_main, $params);
2492 2492
 
2493 2493
                 if ($new_lp_id) {
2494 2494
 
@@ -2549,13 +2549,13 @@  discard block
 block discarded – undo
2549 2549
                 $old_refs = array();
2550 2550
                 $prerequisite_ids = array();
2551 2551
 
2552
-				foreach ($lp->get_items() as $index => $item) {
2553
-					// we set the ref code here and then we update in a for loop
2554
-					$ref = $item['ref'];
2552
+                foreach ($lp->get_items() as $index => $item) {
2553
+                    // we set the ref code here and then we update in a for loop
2554
+                    $ref = $item['ref'];
2555 2555
 
2556
-					// Dealing with path the same way as ref as some data has
2556
+                    // Dealing with path the same way as ref as some data has
2557 2557
                     // been put into path when it's a local resource
2558
-					// Only fix the path for no scos
2558
+                    // Only fix the path for no scos
2559 2559
                     if ($item['item_type'] == 'sco') {
2560 2560
                         $path = $item['path'];
2561 2561
                     } else {
@@ -2584,128 +2584,128 @@  discard block
 block discarded – undo
2584 2584
                         'launch_data' => self::DBUTF8($item['launch_data']),
2585 2585
                     ];
2586 2586
 
2587
-					$new_item_id = Database::insert($table_item, $params);
2587
+                    $new_item_id = Database::insert($table_item, $params);
2588 2588
 
2589 2589
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2590 2590
                     Database::query($sql);
2591 2591
 
2592
-					//save a link between old and new item IDs
2593
-					$new_item_ids[$item['id']] = $new_item_id;
2594
-					//save a reference of items that need a parent_item_id refresh
2595
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2596
-					//save a reference of items that need a previous_item_id refresh
2597
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2598
-					//save a reference of items that need a next_item_id refresh
2599
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2600
-
2601
-					if (!empty($item['prerequisite'])) {
2602
-						if ($lp->lp_type =='2') {
2603
-							// if is an sco
2604
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2605
-						} else {
2606
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2607
-						}
2608
-					}
2609
-
2610
-					if (!empty($ref)) {
2611
-						if ($lp->lp_type =='2') {
2612
-							// if is an sco
2613
-							$old_refs[$new_item_id]= $ref;
2614
-						} else {
2592
+                    //save a link between old and new item IDs
2593
+                    $new_item_ids[$item['id']] = $new_item_id;
2594
+                    //save a reference of items that need a parent_item_id refresh
2595
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2596
+                    //save a reference of items that need a previous_item_id refresh
2597
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2598
+                    //save a reference of items that need a next_item_id refresh
2599
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2600
+
2601
+                    if (!empty($item['prerequisite'])) {
2602
+                        if ($lp->lp_type =='2') {
2603
+                            // if is an sco
2604
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2605
+                        } else {
2606
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2607
+                        }
2608
+                    }
2609
+
2610
+                    if (!empty($ref)) {
2611
+                        if ($lp->lp_type =='2') {
2612
+                            // if is an sco
2613
+                            $old_refs[$new_item_id]= $ref;
2614
+                        } else {
2615 2615
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2616
-						}
2617
-					}
2616
+                        }
2617
+                    }
2618 2618
 
2619
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2620
-				}
2619
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2620
+                }
2621 2621
 
2622
-				// Updating prerequisites
2623
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2624
-					if($my_old_prerequisite != ''){
2625
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2622
+                // Updating prerequisites
2623
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2624
+                    if($my_old_prerequisite != ''){
2625
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2626 2626
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2627
-						Database::query($sql);
2628
-					}
2629
-				}
2630
-
2631
-				// Updating refs
2632
-				foreach ($old_refs  as $key=>$my_old_ref) {
2633
-					if ($my_old_ref != '') {
2634
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2627
+                        Database::query($sql);
2628
+                    }
2629
+                }
2630
+
2631
+                // Updating refs
2632
+                foreach ($old_refs  as $key=>$my_old_ref) {
2633
+                    if ($my_old_ref != '') {
2634
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2635 2635
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2636
-						Database::query($sql);
2637
-					}
2638
-				}
2639
-
2640
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2641
-					$parent_new_id = 0;
2642
-					if($parent_item_old_id != 0){
2643
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2644
-					}
2645
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2636
+                        Database::query($sql);
2637
+                    }
2638
+                }
2639
+
2640
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2641
+                    $parent_new_id = 0;
2642
+                    if($parent_item_old_id != 0){
2643
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2644
+                    }
2645
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2646 2646
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2647
-					Database::query($sql);
2648
-				}
2649
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2650
-					$previous_new_id = 0;
2651
-					if($previous_item_old_id != 0){
2652
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2653
-					}
2654
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2647
+                    Database::query($sql);
2648
+                }
2649
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2650
+                    $previous_new_id = 0;
2651
+                    if($previous_item_old_id != 0){
2652
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2653
+                    }
2654
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2655 2655
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2656
-					Database::query($sql);
2657
-				}
2658
-
2659
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2660
-					$next_new_id = 0;
2661
-					if($next_item_old_id != 0){
2662
-						$next_new_id = $new_item_ids[$next_item_old_id];
2663
-					}
2664
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2656
+                    Database::query($sql);
2657
+                }
2658
+
2659
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2660
+                    $next_new_id = 0;
2661
+                    if($next_item_old_id != 0){
2662
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2663
+                    }
2664
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2665 2665
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2666
-					Database::query($sql);
2667
-				}
2668
-
2669
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2670
-					$prerequisite_new_id = 0;
2671
-					if($prerequisite_old_id != 0){
2672
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2673
-					}
2674
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2666
+                    Database::query($sql);
2667
+                }
2668
+
2669
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2670
+                    $prerequisite_new_id = 0;
2671
+                    if($prerequisite_old_id != 0){
2672
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2673
+                    }
2674
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2675 2675
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2676
-					Database::query($sql);
2677
-				}
2678
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2679
-			}
2680
-		}
2681
-	}
2682
-
2683
-	/**
2684
-	 * Restore works
2676
+                    Database::query($sql);
2677
+                }
2678
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2679
+            }
2680
+        }
2681
+    }
2682
+
2683
+    /**
2684
+     * Restore works
2685 2685
      * @deprecated use restore_works
2686 2686
      *
2687
-	 */
2688
-	public function restore_student_publication($sessionId = 0)
2687
+     */
2688
+    public function restore_student_publication($sessionId = 0)
2689 2689
     {
2690 2690
         $sessionId = intval($sessionId);
2691
-		$work_assignment_table  = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2692
-		$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2693
-		$item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2691
+        $work_assignment_table  = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2692
+        $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2693
+        $item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2694 2694
 
2695
-		// Query in student publication
2696
-		$sql = 'SELECT * FROM '.$work_table.'
2695
+        // Query in student publication
2696
+        $sql = 'SELECT * FROM '.$work_table.'
2697 2697
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2698 2698
 
2699
-		$result = Database::query($sql);
2700
-		$folders = Database::store_result($result, 'ASSOC');
2699
+        $result = Database::query($sql);
2700
+        $folders = Database::store_result($result, 'ASSOC');
2701 2701
 
2702
-		foreach ($folders  as $folder) {
2703
-		    $old_id = $folder['id'];
2702
+        foreach ($folders  as $folder) {
2703
+            $old_id = $folder['id'];
2704 2704
             unset($folder['id']);
2705
-			$folder['c_id'] = $this->destination_course_id;
2705
+            $folder['c_id'] = $this->destination_course_id;
2706 2706
             $folder['parent_id'] = 0;
2707 2707
             $folder['session_id'] = $sessionId;
2708
-			$new_id = Database::insert($work_table, $folder);
2708
+            $new_id = Database::insert($work_table, $folder);
2709 2709
 
2710 2710
             if ($new_id) {
2711 2711
                 //query in item property
@@ -2764,21 +2764,21 @@  discard block
 block discarded – undo
2764 2764
                     }
2765 2765
                 }
2766 2766
             }
2767
-		}
2767
+        }
2768 2768
 
2769
-		$destination = '../../courses/'.$this->course->destination_path.'/work/';
2770
-		$origin = '../../courses/'.$this->course->info['path'].'/work/';
2771
-		self::allow_create_all_directory($origin,$destination,false);
2772
-	}
2769
+        $destination = '../../courses/'.$this->course->destination_path.'/work/';
2770
+        $origin = '../../courses/'.$this->course->info['path'].'/work/';
2771
+        self::allow_create_all_directory($origin,$destination,false);
2772
+    }
2773 2773
 
2774 2774
     /**
2775
-    * copy all directory and sub directory
2776
-    * @param string The path origin
2777
-    * @param string The path destination
2778
-    * @param boolean Option Overwrite
2779
-    * @return void()
2780
-    * @deprecated
2781
-    */
2775
+     * copy all directory and sub directory
2776
+     * @param string The path origin
2777
+     * @param string The path destination
2778
+     * @param boolean Option Overwrite
2779
+     * @return void()
2780
+     * @deprecated
2781
+     */
2782 2782
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2783 2783
     {
2784 2784
         if (!is_dir($dest)) {
@@ -2789,14 +2789,14 @@  discard block
 block discarded – undo
2789 2789
                 if ($file != '.' && $file != '..') {
2790 2790
                     $path = $source . '/' . $file;
2791 2791
                     if (is_file($path)) {
2792
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
2792
+                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2793 2793
                         if (!@copy($path, $dest . '/' . $file)) {
2794 2794
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2795 2795
                         }*/
2796 2796
                     } elseif(is_dir($path)) {
2797 2797
                         if (!is_dir($dest . '/' . $file))
2798 2798
                         mkdir($dest . '/' . $file);
2799
-                       self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2799
+                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2800 2800
                     }
2801 2801
                 }
2802 2802
             }
@@ -2804,12 +2804,12 @@  discard block
 block discarded – undo
2804 2804
         }
2805 2805
     }
2806 2806
 
2807
-	/**
2808
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2809
-	 * @param	string	Tool name
2810
-	 * @param	integer	Old ID
2811
-	 * @return	integer	New ID
2812
-	 */
2807
+    /**
2808
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2809
+     * @param	string	Tool name
2810
+     * @param	integer	Old ID
2811
+     * @return	integer	New ID
2812
+     */
2813 2813
     public function get_new_id($tool, $ref)
2814 2814
     {
2815 2815
         // Check if the value exist in the current array.
@@ -2831,25 +2831,25 @@  discard block
 block discarded – undo
2831 2831
         }
2832 2832
 
2833 2833
         return '';
2834
-	}
2834
+    }
2835 2835
 
2836
-	/**
2837
-	 * Restore glossary
2838
-	 */
2836
+    /**
2837
+     * Restore glossary
2838
+     */
2839 2839
     public function restore_glossary($session_id = 0)
2840 2840
     {
2841
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2842
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2843
-			$resources = $this->course->resources;
2844
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2841
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2842
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2843
+            $resources = $this->course->resources;
2844
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2845 2845
 
2846 2846
                 $params = [];
2847
-    			if (!empty($session_id)) {
2848
-    				$session_id = intval($session_id);
2847
+                if (!empty($session_id)) {
2848
+                    $session_id = intval($session_id);
2849 2849
                     $params['session_id'] = $session_id;
2850
-    			}
2850
+                }
2851 2851
 
2852
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2852
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2853 2853
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2854 2854
                     $glossary->description,
2855 2855
                     $this->course->code,
@@ -2883,27 +2883,27 @@  discard block
 block discarded – undo
2883 2883
 
2884 2884
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2885 2885
                 }
2886
-			}
2887
-		}
2888
-	}
2886
+            }
2887
+        }
2888
+    }
2889 2889
 
2890 2890
     /**
2891 2891
      * @param int $session_id
2892 2892
      */
2893 2893
     public function restore_wiki($session_id = 0)
2894 2894
     {
2895
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2896
-			// wiki table of the target course
2897
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2898
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2895
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2896
+            // wiki table of the target course
2897
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2898
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2899 2899
 
2900
-			// storing all the resources that have to be copied in an array
2901
-			$resources = $this->course->resources;
2900
+            // storing all the resources that have to be copied in an array
2901
+            $resources = $this->course->resources;
2902 2902
 
2903
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2904
-				// the sql statement to insert the groups from the old course to the new course
2903
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2904
+                // the sql statement to insert the groups from the old course to the new course
2905 2905
 
2906
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2906
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2907 2907
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2908 2908
                     $wiki->content,
2909 2909
                     $this->course->code,
@@ -2926,7 +2926,7 @@  discard block
 block discarded – undo
2926 2926
                     'session_id' => !empty($session_id) ? intval($session_id) : 0,
2927 2927
                 ];
2928 2928
 
2929
-				$new_id = Database::insert($table_wiki, $params);
2929
+                $new_id = Database::insert($table_wiki, $params);
2930 2930
 
2931 2931
                 if ($new_id) {
2932 2932
 
@@ -2957,9 +2957,9 @@  discard block
 block discarded – undo
2957 2957
 
2958 2958
                     Database::insert($table_wiki_conf, $params);
2959 2959
                 }
2960
-			}
2961
-		}
2962
-	}
2960
+            }
2961
+        }
2962
+    }
2963 2963
 
2964 2964
     /**
2965 2965
      * Restore Thematics
@@ -2967,15 +2967,15 @@  discard block
 block discarded – undo
2967 2967
      */
2968 2968
     public function restore_thematic($session_id = 0)
2969 2969
     {
2970
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2970
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2971 2971
             $table_thematic = Database:: get_course_table(TABLE_THEMATIC);
2972 2972
             $table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE);
2973 2973
             $table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN);
2974 2974
 
2975
-			$resources = $this->course->resources;
2976
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2975
+            $resources = $this->course->resources;
2976
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2977 2977
 
2978
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2978
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2979 2979
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2980 2980
                     $thematic->params['content'],
2981 2981
                     $this->course->code,
@@ -2983,13 +2983,13 @@  discard block
 block discarded – undo
2983 2983
                     $this->course->backup_path,
2984 2984
                     $this->course->info['path']
2985 2985
                 );
2986
-				$thematic->params['c_id']  = $this->destination_course_id;
2987
-				unset($thematic->params['id']);
2986
+                $thematic->params['c_id']  = $this->destination_course_id;
2987
+                unset($thematic->params['id']);
2988 2988
                 unset($thematic->params['iid']);
2989 2989
 
2990
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
2990
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
2991 2991
 
2992
-				if ($last_id) {
2992
+                if ($last_id) {
2993 2993
 
2994 2994
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
2995 2995
                     Database::query($sql);
@@ -3002,19 +3002,19 @@  discard block
 block discarded – undo
3002 3002
                         api_get_user_id()
3003 3003
                     );
3004 3004
 
3005
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
3006
-						unset($thematic_advance['id']);
3005
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
3006
+                        unset($thematic_advance['id']);
3007 3007
                         unset($thematic_advance['iid']);
3008
-						$thematic_advance['attendance_id'] = 0;
3009
-						$thematic_advance['thematic_id'] = $last_id;
3010
-						$thematic_advance['c_id']  = $this->destination_course_id;
3008
+                        $thematic_advance['attendance_id'] = 0;
3009
+                        $thematic_advance['thematic_id'] = $last_id;
3010
+                        $thematic_advance['c_id']  = $this->destination_course_id;
3011 3011
                         $my_id = Database::insert(
3012 3012
                             $table_thematic_advance,
3013 3013
                             $thematic_advance,
3014 3014
                             false
3015 3015
                         );
3016 3016
 
3017
-						if ($my_id) {
3017
+                        if ($my_id) {
3018 3018
 
3019 3019
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
3020 3020
                             Database::query($sql);
@@ -3026,17 +3026,17 @@  discard block
 block discarded – undo
3026 3026
                                 "ThematicAdvanceAdded",
3027 3027
                                 api_get_user_id()
3028 3028
                             );
3029
-						}
3030
-					}
3029
+                        }
3030
+                    }
3031 3031
 
3032
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3033
-						unset($thematic_plan['id']);
3032
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
3033
+                        unset($thematic_plan['id']);
3034 3034
                         unset($thematic_plan['iid']);
3035
-						$thematic_plan['thematic_id'] = $last_id;
3036
-						$thematic_plan['c_id'] = $this->destination_course_id;
3037
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3035
+                        $thematic_plan['thematic_id'] = $last_id;
3036
+                        $thematic_plan['c_id'] = $this->destination_course_id;
3037
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3038 3038
 
3039
-						if ($my_id) {
3039
+                        if ($my_id) {
3040 3040
 
3041 3041
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
3042 3042
                             Database::query($sql);
@@ -3048,12 +3048,12 @@  discard block
 block discarded – undo
3048 3048
                                 "ThematicPlanAdded",
3049 3049
                                 api_get_user_id()
3050 3050
                             );
3051
-						}
3052
-					}
3053
-				}
3054
-			}
3055
-		}
3056
-	}
3051
+                        }
3052
+                    }
3053
+                }
3054
+            }
3055
+        }
3056
+    }
3057 3057
 
3058 3058
     /**
3059 3059
      * Restore Attendance
@@ -3061,14 +3061,14 @@  discard block
 block discarded – undo
3061 3061
      */
3062 3062
     public function restore_attendance($session_id = 0)
3063 3063
     {
3064
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3065
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3066
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3064
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3065
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3066
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3067 3067
 
3068
-			$resources = $this->course->resources;
3069
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3068
+            $resources = $this->course->resources;
3069
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3070 3070
 
3071
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3071
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3072 3072
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3073 3073
                     $obj->params['description'],
3074 3074
                     $this->course->code,
@@ -3080,11 +3080,11 @@  discard block
 block discarded – undo
3080 3080
                 unset($obj->params['id']);
3081 3081
                 unset($obj->params['iid']);
3082 3082
 
3083
-				$obj->params['c_id'] = $this->destination_course_id;
3083
+                $obj->params['c_id'] = $this->destination_course_id;
3084 3084
 
3085
-				$last_id = Database::insert($table_attendance, $obj->params);
3085
+                $last_id = Database::insert($table_attendance, $obj->params);
3086 3086
 
3087
-				if (is_numeric($last_id)) {
3087
+                if (is_numeric($last_id)) {
3088 3088
 
3089 3089
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3090 3090
                     Database::query($sql);
@@ -3098,11 +3098,11 @@  discard block
 block discarded – undo
3098 3098
                     );
3099 3099
 
3100 3100
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3101
-						unset($attendance_calendar['id']);
3101
+                        unset($attendance_calendar['id']);
3102 3102
                         unset($attendance_calendar['iid']);
3103 3103
 
3104
-						$attendance_calendar['attendance_id'] = $last_id;
3105
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3104
+                        $attendance_calendar['attendance_id'] = $last_id;
3105
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3106 3106
                         $attendanceCalendarId = Database::insert(
3107 3107
                             $table_attendance_calendar,
3108 3108
                             $attendance_calendar
@@ -3110,11 +3110,11 @@  discard block
 block discarded – undo
3110 3110
 
3111 3111
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3112 3112
                         Database::query($sql);
3113
-					}
3114
-				}
3115
-			}
3116
-		}
3117
-	}
3113
+                    }
3114
+                }
3115
+            }
3116
+        }
3117
+    }
3118 3118
 
3119 3119
     /**
3120 3120
      * Restore Works
@@ -3256,11 +3256,11 @@  discard block
 block discarded – undo
3256 3256
      */
3257 3257
     public function DBUTF8($str)
3258 3258
     {
3259
-		if (UTF8_CONVERT) {
3259
+        if (UTF8_CONVERT) {
3260 3260
             $str = utf8_encode($str);
3261 3261
         }
3262
-		return $str;
3263
-	}
3262
+        return $str;
3263
+    }
3264 3264
 
3265 3265
     /**
3266 3266
      * @param string $str
@@ -3271,8 +3271,8 @@  discard block
 block discarded – undo
3271 3271
         if (UTF8_CONVERT) {
3272 3272
             $str = utf8_encode($str);
3273 3273
         }
3274
-		return Database::escape_string($str);
3275
-	}
3274
+        return Database::escape_string($str);
3275
+    }
3276 3276
 
3277 3277
     /**
3278 3278
      * @param array $array
Please login to merge, or discard this patch.
main/document/slideshow.php 1 patch
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 $slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null;
16 16
 
17 17
 if (empty($slide_id)) {
18
-	$edit_slide_id = 1;
18
+    $edit_slide_id = 1;
19 19
 } else {
20
-	$edit_slide_id = $slide_id;
20
+    $edit_slide_id = $slide_id;
21 21
 }
22 22
 
23 23
 if ($path != '/') {
24
-	$folder = $path.'/';
24
+    $folder = $path.'/';
25 25
 } else {
26
-	$folder = '/';
26
+    $folder = '/';
27 27
 }
28 28
 $sys_course_path = api_get_path(SYS_COURSE_PATH);
29 29
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 
42 42
 // Loading the slides from the session
43 43
 if (isset($_SESSION['image_files_only'])) {
44
-	$image_files_only = $_SESSION['image_files_only'];
44
+    $image_files_only = $_SESSION['image_files_only'];
45 45
 }
46 46
 
47 47
 // Calculating the current slide, next slide, previous slide and the number of slides
48 48
 $slide = null;
49 49
 if ($slide_id != 'all') {
50
-	$slide = $slide_id ? $slide_id : 0;
51
-	$previous_slide = $slide - 1;
52
-	$next_slide = $slide + 1;
50
+    $slide = $slide_id ? $slide_id : 0;
51
+    $previous_slide = $slide - 1;
52
+    $next_slide = $slide + 1;
53 53
 }
54 54
 $total_slides = count($image_files_only);
55 55
 ?>
@@ -62,62 +62,62 @@  discard block
 block discarded – undo
62 62
 <?php
63 63
 
64 64
 if ($slide_id != 'all') {
65
-	$image = null;
66
-	if (isset($image_files_only[$slide])) {
67
-		$image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide];
68
-	}
69
-	if (file_exists($image)) {
70
-		echo '<div class="actions-pagination">';
71
-
72
-		// Back forward buttons
73
-		if ($slide == 0) {
74
-			$imgp = 'action_prev_na.png';
75
-			$first = Display::return_icon('action_first_na.png');
76
-		} else {
77
-			$imgp = 'action_prev.png';
78
-			$first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'">
65
+    $image = null;
66
+    if (isset($image_files_only[$slide])) {
67
+        $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide];
68
+    }
69
+    if (file_exists($image)) {
70
+        echo '<div class="actions-pagination">';
71
+
72
+        // Back forward buttons
73
+        if ($slide == 0) {
74
+            $imgp = 'action_prev_na.png';
75
+            $first = Display::return_icon('action_first_na.png');
76
+        } else {
77
+            $imgp = 'action_prev.png';
78
+            $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'">
79 79
 			          '.Display::return_icon('action_first.png', get_lang('FirstSlide')).'
80 80
 			          </a>';
81
-		}
81
+        }
82 82
 
83
-		// First slide
84
-		echo $first;
83
+        // First slide
84
+        echo $first;
85 85
 
86
-		// Previous slide
87
-		if ($slide > 0) {
88
-			echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">';
89
-		}
86
+        // Previous slide
87
+        if ($slide > 0) {
88
+            echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">';
89
+        }
90 90
 
91 91
         echo Display::return_icon($imgp, get_lang('Previous'));
92
-		if ($slide > 0) {
93
-			echo '</a>';
94
-		}
95
-
96
-		// Divider
97
-		echo ' [ '.$next_slide.'/'.$total_slides.' ] ';
98
-
99
-		// Next slide
100
-		if ($slide < $total_slides - 1) {
101
-			echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">';
102
-		}
103
-		if ($slide == $total_slides - 1) {
104
-			$imgn = 'action_next_na.png';
92
+        if ($slide > 0) {
93
+            echo '</a>';
94
+        }
95
+
96
+        // Divider
97
+        echo ' [ '.$next_slide.'/'.$total_slides.' ] ';
98
+
99
+        // Next slide
100
+        if ($slide < $total_slides - 1) {
101
+            echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">';
102
+        }
103
+        if ($slide == $total_slides - 1) {
104
+            $imgn = 'action_next_na.png';
105 105
             $last = Display::return_icon('action_last_na.png', get_lang('LastSlide'));
106
-		} else {
107
-			$imgn = 'action_next.png';
108
-			$last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'">
106
+        } else {
107
+            $imgn = 'action_next.png';
108
+            $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'">
109 109
 			        '.Display::return_icon('action_last.png', get_lang('LastSlide')).'
110 110
                 </a>';
111
-		}
111
+        }
112 112
         echo Display::return_icon($imgn, get_lang('Next'));
113
-		if ($slide > 0) {
114
-			echo '</a>';
115
-		}
116
-
117
-		// Last slide
118
-		echo $last;
119
-		echo '</div>';
120
-	}
113
+        if ($slide > 0) {
114
+            echo '</a>';
115
+        }
116
+
117
+        // Last slide
118
+        echo $last;
119
+        echo '</div>';
120
+    }
121 121
 }
122 122
 
123 123
 // Exit the slideshow
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 
127 127
 // Show thumbnails
128 128
 if ($slide_id != 'all') {
129
-	echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
129
+    echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
130 130
         Display::return_icon('thumbnails.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM).'</a>';
131 131
 } else {
132
-	echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM);
132
+    echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM);
133 133
 }
134 134
 // Slideshow options
135 135
 echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
@@ -142,24 +142,24 @@  discard block
 block discarded – undo
142 142
 
143 143
 // If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
144 144
 if (isset($_POST['Submit'])) {
145
-	// We come from slideshowoptions.php
146
-	//$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']);
147
-	$_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']);
148
-	if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') {
149
-		//echo "resizing";
150
-		$_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']);
151
-		$_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']);
152
-	} else {
153
-		//echo "unsetting the session heighte and width";
154
-		$_SESSION["image_resizing_width"] = null;
155
-		$_SESSION["image_resizing_height"] = null;
156
-	}
145
+    // We come from slideshowoptions.php
146
+    //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']);
147
+    $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']);
148
+    if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') {
149
+        //echo "resizing";
150
+        $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']);
151
+        $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']);
152
+    } else {
153
+        //echo "unsetting the session heighte and width";
154
+        $_SESSION["image_resizing_width"] = null;
155
+        $_SESSION["image_resizing_height"] = null;
156
+    }
157 157
 }
158 158
 $target_width = $target_height = null;
159 159
 // The target height and width depends if we choose resizing or no resizing
160 160
 if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == "resizing") {
161
-	$target_width = $_SESSION["image_resizing_width"];
162
-	$target_height = $_SESSION["image_resizing_height"];
161
+    $target_width = $_SESSION["image_resizing_width"];
162
+    $target_height = $_SESSION["image_resizing_height"];
163 163
 }
164 164
 
165 165
 /*	THUMBNAIL VIEW */
@@ -169,59 +169,59 @@  discard block
 block discarded – undo
169 169
 $html = '';
170 170
 if ($slide_id == 'all') {
171 171
 
172
-	// Config for make thumbnails
172
+    // Config for make thumbnails
173 173
     $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png');
174
-	$max_thumbnail_width     = 250;
175
-	$max_thumbnail_height    = 250;
176
-	$png_compression	     = 0; // 0(none)-9
177
-	$jpg_quality  	         = 75; // from 0 to 100 (default is 75). More quality less compression
174
+    $max_thumbnail_width     = 250;
175
+    $max_thumbnail_height    = 250;
176
+    $png_compression	     = 0; // 0(none)-9
177
+    $jpg_quality  	         = 75; // from 0 to 100 (default is 75). More quality less compression
178 178
 
179
-	$directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/';
179
+    $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/';
180 180
 
181
-	//Other parameters only for show tumbnails
182
-	$row_items 			     = 4;//only in slideshow.php
183
-	$number_image 			 = 7;//num icons cols to show
184
-	$thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x
185
-	$thumbnail_height_frame = $max_thumbnail_height;
181
+    //Other parameters only for show tumbnails
182
+    $row_items 			     = 4;//only in slideshow.php
183
+    $number_image 			 = 7;//num icons cols to show
184
+    $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x
185
+    $thumbnail_height_frame = $max_thumbnail_height;
186 186
 
187
-	// Create the template_thumbnails folder (if no exist)
187
+    // Create the template_thumbnails folder (if no exist)
188 188
 
189
-	if (!file_exists($directory_thumbnails)) {
190
-		@mkdir($directory_thumbnails, api_get_permissions_for_new_directories());
189
+    if (!file_exists($directory_thumbnails)) {
190
+        @mkdir($directory_thumbnails, api_get_permissions_for_new_directories());
191 191
     }
192 192
 
193
-	// check files and thumbnails
194
-	if (is_array($image_files_only)) {
193
+    // check files and thumbnails
194
+    if (is_array($image_files_only)) {
195 195
 
196
-		foreach ($image_files_only as $one_image_file) {
197
-			$image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file;
198
-			$image_thumbnail= $directory_thumbnails.'.'.$one_image_file;
196
+        foreach ($image_files_only as $one_image_file) {
197
+            $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file;
198
+            $image_thumbnail= $directory_thumbnails.'.'.$one_image_file;
199 199
 
200
-			if (file_exists($image)) {
201
-				//check thumbnail
202
-				$imagetype = explode(".", $image);
200
+            if (file_exists($image)) {
201
+                //check thumbnail
202
+                $imagetype = explode(".", $image);
203 203
                 //or check $imagetype = image_type_to_extension(exif_imagetype($image), false);
204
-				$imagetype = strtolower($imagetype[count($imagetype)-1]);
204
+                $imagetype = strtolower($imagetype[count($imagetype)-1]);
205 205
 
206
-				if (in_array($imagetype,$allowed_thumbnail_types)) {
207
-					if (!file_exists($image_thumbnail)){
206
+                if (in_array($imagetype,$allowed_thumbnail_types)) {
207
+                    if (!file_exists($image_thumbnail)){
208 208
                         //run each once we view thumbnails is too heavy, then need move into  !file_exists($image_thumbnail, and only run when haven't the thumbnail
209
-						$original_image_size = api_getimagesize($image);
210
-
211
-						switch($imagetype) {
212
-							case 'gif':
213
-								$source_img = imagecreatefromgif($image);
214
-								break;
215
-							case 'jpg':
216
-								$source_img = imagecreatefromjpeg($image);
217
-								break;
218
-							case 'jpeg':
219
-								$source_img = imagecreatefromjpeg($image);
220
-								break;
221
-							case 'png':
222
-								$source_img = imagecreatefrompng($image);
223
-								break;
224
-						}
209
+                        $original_image_size = api_getimagesize($image);
210
+
211
+                        switch($imagetype) {
212
+                            case 'gif':
213
+                                $source_img = imagecreatefromgif($image);
214
+                                break;
215
+                            case 'jpg':
216
+                                $source_img = imagecreatefromjpeg($image);
217
+                                break;
218
+                            case 'jpeg':
219
+                                $source_img = imagecreatefromjpeg($image);
220
+                                break;
221
+                            case 'png':
222
+                                $source_img = imagecreatefrompng($image);
223
+                                break;
224
+                        }
225 225
 
226 226
                         $new_thumbnail_size = api_calculate_image_size(
227 227
                             $original_image_size['width'],
@@ -229,33 +229,33 @@  discard block
 block discarded – undo
229 229
                             $max_thumbnail_width,
230 230
                             $max_thumbnail_height
231 231
                         );
232
-						if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){
233
-							$new_thumbnail_size['width']=$original_image_size['width'];
234
-							$new_thumbnail_size['height']=$original_image_size['height'];
235
-						}
236
-
237
-						$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
238
-
239
-						// preserve transparency
240
-						if ($imagetype == "png"){
241
-							imagesavealpha($crop, true);
242
-							$color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127);
243
-							imagefill($crop, 0, 0, $color);
244
-						}
245
-
246
-						if ($imagetype == "gif") {
247
-							$transindex = imagecolortransparent($source_img);
232
+                        if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){
233
+                            $new_thumbnail_size['width']=$original_image_size['width'];
234
+                            $new_thumbnail_size['height']=$original_image_size['height'];
235
+                        }
236
+
237
+                        $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
238
+
239
+                        // preserve transparency
240
+                        if ($imagetype == "png"){
241
+                            imagesavealpha($crop, true);
242
+                            $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127);
243
+                            imagefill($crop, 0, 0, $color);
244
+                        }
245
+
246
+                        if ($imagetype == "gif") {
247
+                            $transindex = imagecolortransparent($source_img);
248 248
                             $palletsize = imagecolorstotal($source_img);
249
-							 //GIF89a for transparent and anim (first clip), either GIF87a
250
-							 if ($transindex >= 0 && $transindex < $palletsize){
251
-								 $transcol = imagecolorsforindex($source_img, $transindex);
252
-								 $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
253
-								 imagefill($crop, 0, 0, $transindex);
254
-								 imagecolortransparent($crop, $transindex);
255
-							 }
256
-						}
257
-
258
-						//resampled image
249
+                                //GIF89a for transparent and anim (first clip), either GIF87a
250
+                                if ($transindex >= 0 && $transindex < $palletsize){
251
+                                    $transcol = imagecolorsforindex($source_img, $transindex);
252
+                                    $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
253
+                                    imagefill($crop, 0, 0, $transindex);
254
+                                    imagecolortransparent($crop, $transindex);
255
+                                }
256
+                        }
257
+
258
+                        //resampled image
259 259
                         imagecopyresampled(
260 260
                             $crop,
261 261
                             $source_img,
@@ -269,69 +269,69 @@  discard block
 block discarded – undo
269 269
                             $original_image_size['height']
270 270
                         );
271 271
 
272
-						switch ($imagetype) {
273
-							case 'gif':
274
-								imagegif($crop,$image_thumbnail);
275
-								break;
276
-							case 'jpg':
277
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
278
-								break;
279
-							case 'jpeg':
280
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
281
-								break;
282
-							case 'png':
283
-								imagepng($crop,$image_thumbnail,$png_compression);
284
-								break;
285
-						}
286
-
287
-						//clean memory
288
-						imagedestroy($crop);
289
-					}//end !exist thumbnail
290
-
291
-					//show thumbnail and link
292
-
293
-					$one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail
294
-					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
295
-					$image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
296
-				} else {
297
-					//if images aren't support by gd (not gif, jpg, jpeg, png)
298
-					if ($imagetype=="bmp") {
272
+                        switch ($imagetype) {
273
+                            case 'gif':
274
+                                imagegif($crop,$image_thumbnail);
275
+                                break;
276
+                            case 'jpg':
277
+                                imagejpeg($crop,$image_thumbnail,$jpg_quality);
278
+                                break;
279
+                            case 'jpeg':
280
+                                imagejpeg($crop,$image_thumbnail,$jpg_quality);
281
+                                break;
282
+                            case 'png':
283
+                                imagepng($crop,$image_thumbnail,$png_compression);
284
+                                break;
285
+                        }
286
+
287
+                        //clean memory
288
+                        imagedestroy($crop);
289
+                    }//end !exist thumbnail
290
+
291
+                    //show thumbnail and link
292
+
293
+                    $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail
294
+                    $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
295
+                    $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
296
+                } else {
297
+                    //if images aren't support by gd (not gif, jpg, jpeg, png)
298
+                    if ($imagetype=="bmp") {
299 299
                         // use getimagesize instead api_getimagesize($image); becasuse api_getimagesize doesn't support bmp files. Put here for each show, only for a few bmp files isn't heavy
300
-						$original_image_size = getimagesize($image);
301
-						if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){
302
-							$thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files
303
-							$image_height = $thumbnail_size['height'];
304
-							$image_width  = $thumbnail_size['width'];
305
-						} else {
306
-							$image_height=$original_image_size[0];
307
-							$image_width=$original_image_size[1];
308
-						}
309
-					} else {
310
-						//example for svg files,...
311
-						$image_width=$max_thumbnail_width;
312
-						$image_height=$max_thumbnail_height;
313
-					}
314
-
315
-					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
316
-					$image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
317
-
318
-				}//end allowed image types
319
-			}//end if exist file image
320
-		}//end foreach
321
-	}//end image files only
322
-
323
-	// Creating the table
324
-	$html_table = '';
325
-
326
-	$i = 0;
327
-	$count_image = count($image_tag);
328
-	$number_iteration = ceil($count_image/$number_image);
329
-	$p = 0;
300
+                        $original_image_size = getimagesize($image);
301
+                        if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){
302
+                            $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files
303
+                            $image_height = $thumbnail_size['height'];
304
+                            $image_width  = $thumbnail_size['width'];
305
+                        } else {
306
+                            $image_height=$original_image_size[0];
307
+                            $image_width=$original_image_size[1];
308
+                        }
309
+                    } else {
310
+                        //example for svg files,...
311
+                        $image_width=$max_thumbnail_width;
312
+                        $image_height=$max_thumbnail_height;
313
+                    }
314
+
315
+                    $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
316
+                    $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
317
+
318
+                }//end allowed image types
319
+            }//end if exist file image
320
+        }//end foreach
321
+    }//end image files only
322
+
323
+    // Creating the table
324
+    $html_table = '';
325
+
326
+    $i = 0;
327
+    $count_image = count($image_tag);
328
+    $number_iteration = ceil($count_image/$number_image);
329
+    $p = 0;
330 330
     $html = '';
331 331
     $html .= '<div class="gallery">';
332
-	for ($k = 0; $k < $number_iteration; $k++) {
333
-		for ($i = 0; $i < $number_image; $i++) {
334
-			if (isset($image_tag[$p])) {
332
+    for ($k = 0; $k < $number_iteration; $k++) {
333
+        for ($i = 0; $i < $number_image; $i++) {
334
+            if (isset($image_tag[$p])) {
335 335
                             $html .= '<div class="col-xs-6 col-sm-3 col-md-2">';
336 336
                             $html .= '<div class="canvas-one">';
337 337
                             $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">';
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
                             $html .= '</a>';
344 344
                             $html .= '</div>';
345 345
                             $html .= '</div>';
346
-			}
347
-			$p++;
348
-		}
349
-	}
346
+            }
347
+            $p++;
348
+        }
349
+    }
350 350
     $html .= '</div>';
351 351
 
352 352
 }//end slide==all
@@ -357,43 +357,43 @@  discard block
 block discarded – undo
357 357
 // This is for viewing all the images in the slideshow one at a time.
358 358
 
359 359
 if ($slide_id != 'all' && !empty($image_files_only)) {
360
-	if (file_exists($image) && is_file($image)) {
361
-		$image_height_width = resize_image($image, $target_width, $target_height);
362
-
363
-		$image_height = $image_height_width[0];
364
-		$image_width = $image_height_width[1];
365
-
366
-		$height_width_tags = null;
367
-		if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
368
-			$height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
369
-		}
370
-
371
-		// This is done really quickly and should be cleaned up a little bit using the API functions
372
-		$tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
373
-		if ($path == '/') {
374
-			$pathpart = '/';
375
-		} else {
376
-			$pathpart = $path.'/';
377
-		}
378
-		$sql = "SELECT * FROM $tbl_documents
360
+    if (file_exists($image) && is_file($image)) {
361
+        $image_height_width = resize_image($image, $target_width, $target_height);
362
+
363
+        $image_height = $image_height_width[0];
364
+        $image_width = $image_height_width[1];
365
+
366
+        $height_width_tags = null;
367
+        if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
368
+            $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
369
+        }
370
+
371
+        // This is done really quickly and should be cleaned up a little bit using the API functions
372
+        $tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
373
+        if ($path == '/') {
374
+            $pathpart = '/';
375
+        } else {
376
+            $pathpart = $path.'/';
377
+        }
378
+        $sql = "SELECT * FROM $tbl_documents
379 379
 		        WHERE c_id = $course_id AND path='".Database::escape_string($pathpart.$image_files_only[$slide])."'";
380
-		$result = Database::query($sql);
381
-		$row = Database::fetch_array($result);
380
+        $result = Database::query($sql);
381
+        $row = Database::fetch_array($result);
382 382
 
383 383
         echo '<div class="thumbnail">';
384
-		if ($slide < $total_slides - 1 && $slide_id != 'all') {
385
-			echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
386
-		} else {
387
-			echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>";
388
-		}
384
+        if ($slide < $total_slides - 1 && $slide_id != 'all') {
385
+            echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
386
+        } else {
387
+            echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>";
388
+        }
389 389
         if ($path == '/') {
390
-        	$path = '';
390
+            $path = '';
391 391
         }
392 392
 
393
-		list($width, $height) = getimagesize($image);
394
-		// Auto resize
395
-		if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == 'resizing') {
396
-		?>
393
+        list($width, $height) = getimagesize($image);
394
+        // Auto resize
395
+        if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == 'resizing') {
396
+        ?>
397 397
 
398 398
 		<script type="text/javascript">
399 399
 			var initial_width='<?php echo $width; ?>';
@@ -446,21 +446,21 @@  discard block
 block discarded – undo
446 446
 
447 447
 		</script>
448 448
     <?php
449
-		} else {
450
-			echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
451
-		}
449
+        } else {
450
+            echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
451
+        }
452 452
 
453
-		echo '</a>';
453
+        echo '</a>';
454 454
         echo '<div class="caption text-center">';
455 455
         echo Display::tag('h3', $row['title']);
456 456
         echo '<p>' . $row['comment'] . '</p>';
457 457
         echo '</div>';
458 458
         echo '</div>';
459 459
 
460
-		if (api_is_allowed_to_edit(null, true)) {
460
+        if (api_is_allowed_to_edit(null, true)) {
461 461
             echo '<ul class="list-unstyled">';
462
-			$aux = explode('.', htmlspecialchars($image_files_only[$slide]));
463
-			$ext = $aux[count($aux) - 1];
462
+            $aux = explode('.', htmlspecialchars($image_files_only[$slide]));
463
+            $ext = $aux[count($aux) - 1];
464 464
 
465 465
             if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
466 466
                 $resize_info = get_lang('Resizing').'<br />';
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
                 $resize_height = get_lang('Auto');
473 473
             } else {
474 474
                 $resize_info = get_lang('NoResizing').'<br />';
475
-				$resize_width = '';
476
-				$resize_height = '';
475
+                $resize_width = '';
476
+                $resize_height = '';
477 477
             }
478 478
 
479 479
             echo '<li class="text-center">';
@@ -493,16 +493,16 @@  discard block
 block discarded – undo
493 493
             );
494 494
             echo '</li>';
495 495
             echo '<li class="text-center">' . $width.' x '.$height . '</li>';
496
-			echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>';
496
+            echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>';
497 497
             echo '<li class="text-center">' . $resize_info . '</li>';
498
-			echo '<li class="text-center">' . $resize_width . '</li>';
499
-			echo '<li class="text-center">' . $resize_height . '</li>';
498
+            echo '<li class="text-center">' . $resize_width . '</li>';
499
+            echo '<li class="text-center">' . $resize_height . '</li>';
500 500
             echo '</ul>';
501
-		}
501
+        }
502 502
 
503
-	} else {
504
-		Display::display_warning_message(get_lang('FileNotFound'));
505
-	}
503
+    } else {
504
+        Display::display_warning_message(get_lang('FileNotFound'));
505
+    }
506 506
 } else {
507 507
     if ($slide_id != 'all') {
508 508
         Display::display_warning_message(get_lang('NoDataAvailable'));
Please login to merge, or discard this patch.