Completed
Push — 1.11.x ( 6904fa...6a92e6 )
by José
525:44 queued 484:20
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/course_description/index.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@
 block discarded – undo
24 24
 $actions = array('listing', 'add', 'edit', 'delete', 'history');
25 25
 $action = 'listing';
26 26
 if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
27
-	$action = $_GET['action'];
27
+    $action = $_GET['action'];
28 28
 }
29 29
 
30 30
 $description_type = '';
31 31
 if (isset($_GET['description_type'])) {
32
-	$description_type = intval($_GET['description_type']);
32
+    $description_type = intval($_GET['description_type']);
33 33
 }
34 34
 
35 35
 $id = null;
Please login to merge, or discard this patch.
main/document/slideshow.php 1 patch
Indentation   +245 added lines, -245 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'],
@@ -230,33 +230,33 @@  discard block
 block discarded – undo
230 230
                             $max_thumbnail_height
231 231
                         );
232 232
 
233
-						if($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){
234
-							$new_thumbnail_size['width']=$original_image_size['width'];
235
-							$new_thumbnail_size['height']=$original_image_size['height'];
236
-						}
233
+                        if($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){
234
+                            $new_thumbnail_size['width']=$original_image_size['width'];
235
+                            $new_thumbnail_size['height']=$original_image_size['height'];
236
+                        }
237 237
 
238
-						$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
238
+                        $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
239 239
 
240
-						// preserve transparency
241
-						if($imagetype == "png"){
242
-							imagesavealpha($crop, true);
243
-							$color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127);
244
-							imagefill($crop, 0, 0, $color);
245
-						}
240
+                        // preserve transparency
241
+                        if($imagetype == "png"){
242
+                            imagesavealpha($crop, true);
243
+                            $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127);
244
+                            imagefill($crop, 0, 0, $color);
245
+                        }
246 246
 
247
-						if ($imagetype == "gif") {
248
-							$transindex = imagecolortransparent($source_img);
247
+                        if ($imagetype == "gif") {
248
+                            $transindex = imagecolortransparent($source_img);
249 249
                             $palletsize = imagecolorstotal($source_img);
250
-							 //GIF89a for transparent and anim (first clip), either GIF87a
251
-							 if ($transindex >= 0 && $transindex < $palletsize){
252
-								 $transcol = imagecolorsforindex($source_img, $transindex);
253
-								 $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
254
-								 imagefill($crop, 0, 0, $transindex);
255
-								 imagecolortransparent($crop, $transindex);
256
-							 }
257
-						}
258
-
259
-						//resampled image
250
+                                //GIF89a for transparent and anim (first clip), either GIF87a
251
+                                if ($transindex >= 0 && $transindex < $palletsize){
252
+                                    $transcol = imagecolorsforindex($source_img, $transindex);
253
+                                    $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
254
+                                    imagefill($crop, 0, 0, $transindex);
255
+                                    imagecolortransparent($crop, $transindex);
256
+                                }
257
+                        }
258
+
259
+                        //resampled image
260 260
                         imagecopyresampled(
261 261
                             $crop,
262 262
                             $source_img,
@@ -270,69 +270,69 @@  discard block
 block discarded – undo
270 270
                             $original_image_size['height']
271 271
                         );
272 272
 
273
-						switch ($imagetype) {
274
-							case 'gif':
275
-								imagegif($crop,$image_thumbnail);
276
-								break;
277
-							case 'jpg':
278
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
279
-								break;
280
-							case 'jpeg':
281
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
282
-								break;
283
-							case 'png':
284
-								imagepng($crop,$image_thumbnail,$png_compression);
285
-								break;
286
-						}
287
-
288
-						//clean memory
289
-						imagedestroy($crop);
290
-					}//end !exist thumbnail
291
-
292
-					//show thumbnail and link
293
-
294
-					$one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail
295
-					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
296
-					$image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
297
-				} else {
298
-					//if images aren't support by gd (not gif, jpg, jpeg, png)
299
-					if ($imagetype=="bmp") {
273
+                        switch ($imagetype) {
274
+                            case 'gif':
275
+                                imagegif($crop,$image_thumbnail);
276
+                                break;
277
+                            case 'jpg':
278
+                                imagejpeg($crop,$image_thumbnail,$jpg_quality);
279
+                                break;
280
+                            case 'jpeg':
281
+                                imagejpeg($crop,$image_thumbnail,$jpg_quality);
282
+                                break;
283
+                            case 'png':
284
+                                imagepng($crop,$image_thumbnail,$png_compression);
285
+                                break;
286
+                        }
287
+
288
+                        //clean memory
289
+                        imagedestroy($crop);
290
+                    }//end !exist thumbnail
291
+
292
+                    //show thumbnail and link
293
+
294
+                    $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail
295
+                    $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
296
+                    $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
297
+                } else {
298
+                    //if images aren't support by gd (not gif, jpg, jpeg, png)
299
+                    if ($imagetype=="bmp") {
300 300
                         // 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
301
-						$original_image_size = getimagesize($image);
302
-						if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){
303
-							$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
304
-							$image_height = $thumbnail_size['height'];
305
-							$image_width  = $thumbnail_size['width'];
306
-						} else {
307
-							$image_height=$original_image_size[0];
308
-							$image_width=$original_image_size[1];
309
-						}
310
-					} else {
311
-						//example for svg files,...
312
-						$image_width=$max_thumbnail_width;
313
-						$image_height=$max_thumbnail_height;
314
-					}
315
-
316
-					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
317
-					$image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
318
-
319
-				}//end allowed image types
320
-			}//end if exist file image
321
-		}//end foreach
322
-	}//end image files only
323
-
324
-	// Creating the table
325
-	$html_table = '';
326
-
327
-	$i = 0;
328
-	$count_image = count($image_tag);
329
-	$number_iteration = ceil($count_image/$number_image);
330
-	$p = 0;
301
+                        $original_image_size = getimagesize($image);
302
+                        if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){
303
+                            $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
304
+                            $image_height = $thumbnail_size['height'];
305
+                            $image_width  = $thumbnail_size['width'];
306
+                        } else {
307
+                            $image_height=$original_image_size[0];
308
+                            $image_width=$original_image_size[1];
309
+                        }
310
+                    } else {
311
+                        //example for svg files,...
312
+                        $image_width=$max_thumbnail_width;
313
+                        $image_height=$max_thumbnail_height;
314
+                    }
315
+
316
+                    $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
317
+                    $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
318
+
319
+                }//end allowed image types
320
+            }//end if exist file image
321
+        }//end foreach
322
+    }//end image files only
323
+
324
+    // Creating the table
325
+    $html_table = '';
326
+
327
+    $i = 0;
328
+    $count_image = count($image_tag);
329
+    $number_iteration = ceil($count_image/$number_image);
330
+    $p = 0;
331 331
     $html = '';
332 332
     $html .= '<div class="gallery">';
333
-	for ($k = 0; $k < $number_iteration; $k++) {
334
-		for ($i = 0; $i < $number_image; $i++) {
335
-			if (isset($image_tag[$p])) {
333
+    for ($k = 0; $k < $number_iteration; $k++) {
334
+        for ($i = 0; $i < $number_image; $i++) {
335
+            if (isset($image_tag[$p])) {
336 336
                             $html .= '<div class="col-xs-6 col-sm-3 col-md-2">';
337 337
                             $html .= '<div class="canvas-one">';
338 338
                             $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">';
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
                             $html .= '</a>';
345 345
                             $html .= '</div>';
346 346
                             $html .= '</div>';
347
-			}
348
-			$p++;
349
-		}
350
-	}
347
+            }
348
+            $p++;
349
+        }
350
+    }
351 351
     $html .= '</div>';
352 352
 
353 353
 }//end slide==all
@@ -358,43 +358,43 @@  discard block
 block discarded – undo
358 358
 // This is for viewing all the images in the slideshow one at a time.
359 359
 
360 360
 if ($slide_id != 'all' && !empty($image_files_only)) {
361
-	if (file_exists($image) && is_file($image)) {
362
-		$image_height_width = resize_image($image, $target_width, $target_height);
363
-
364
-		$image_height = $image_height_width[0];
365
-		$image_width = $image_height_width[1];
366
-
367
-		$height_width_tags = null;
368
-		if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
369
-			$height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
370
-		}
371
-
372
-		// This is done really quickly and should be cleaned up a little bit using the API functions
373
-		$tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
374
-		if ($path == '/') {
375
-			$pathpart = '/';
376
-		} else {
377
-			$pathpart = $path.'/';
378
-		}
379
-		$sql = "SELECT * FROM $tbl_documents
361
+    if (file_exists($image) && is_file($image)) {
362
+        $image_height_width = resize_image($image, $target_width, $target_height);
363
+
364
+        $image_height = $image_height_width[0];
365
+        $image_width = $image_height_width[1];
366
+
367
+        $height_width_tags = null;
368
+        if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
369
+            $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
370
+        }
371
+
372
+        // This is done really quickly and should be cleaned up a little bit using the API functions
373
+        $tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
374
+        if ($path == '/') {
375
+            $pathpart = '/';
376
+        } else {
377
+            $pathpart = $path.'/';
378
+        }
379
+        $sql = "SELECT * FROM $tbl_documents
380 380
 		        WHERE c_id = $course_id AND path='".Database::escape_string($pathpart.$image_files_only[$slide])."'";
381
-		$result = Database::query($sql);
382
-		$row = Database::fetch_array($result);
381
+        $result = Database::query($sql);
382
+        $row = Database::fetch_array($result);
383 383
 
384 384
         echo '<div class="thumbnail">';
385
-		if ($slide < $total_slides - 1 && $slide_id != 'all') {
386
-			echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
387
-		} else {
388
-			echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>";
389
-		}
385
+        if ($slide < $total_slides - 1 && $slide_id != 'all') {
386
+            echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
387
+        } else {
388
+            echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>";
389
+        }
390 390
         if ($path == '/') {
391
-        	$path = '';
391
+            $path = '';
392 392
         }
393 393
 
394
-		list($width, $height) = getimagesize($image);
395
-		// Auto resize
396
-		if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == 'resizing') {
397
-		?>
394
+        list($width, $height) = getimagesize($image);
395
+        // Auto resize
396
+        if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == 'resizing') {
397
+        ?>
398 398
 
399 399
 		<script type="text/javascript">
400 400
 			var initial_width='<?php echo $width; ?>';
@@ -447,21 +447,21 @@  discard block
 block discarded – undo
447 447
 
448 448
 		</script>
449 449
     <?php
450
-		} else {
451
-			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.">";
452
-		}
450
+        } else {
451
+            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.">";
452
+        }
453 453
 
454
-		echo '</a>';
454
+        echo '</a>';
455 455
         echo '<div class="caption text-center">';
456 456
         echo Display::tag('h3', $row['title']);
457 457
         echo '<p>' . $row['comment'] . '</p>';
458 458
         echo '</div>';
459 459
         echo '</div>';
460 460
 
461
-		if (api_is_allowed_to_edit(null, true)) {
461
+        if (api_is_allowed_to_edit(null, true)) {
462 462
             echo '<ul class="list-unstyled">';
463
-			$aux = explode('.', htmlspecialchars($image_files_only[$slide]));
464
-			$ext = $aux[count($aux) - 1];
463
+            $aux = explode('.', htmlspecialchars($image_files_only[$slide]));
464
+            $ext = $aux[count($aux) - 1];
465 465
 
466 466
             if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
467 467
                 $resize_info = get_lang('Resizing').'<br />';
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
                 $resize_height = get_lang('Auto');
474 474
             } else {
475 475
                 $resize_info = get_lang('NoResizing').'<br />';
476
-				$resize_width = '';
477
-				$resize_height = '';
476
+                $resize_width = '';
477
+                $resize_height = '';
478 478
             }
479 479
 
480 480
             echo '<li class="text-center">';
@@ -494,16 +494,16 @@  discard block
 block discarded – undo
494 494
             );
495 495
             echo '</li>';
496 496
             echo '<li class="text-center">' . $width.' x '.$height . '</li>';
497
-			echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>';
497
+            echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>';
498 498
             echo '<li class="text-center">' . $resize_info . '</li>';
499
-			echo '<li class="text-center">' . $resize_width . '</li>';
500
-			echo '<li class="text-center">' . $resize_height . '</li>';
499
+            echo '<li class="text-center">' . $resize_width . '</li>';
500
+            echo '<li class="text-center">' . $resize_height . '</li>';
501 501
             echo '</ul>';
502
-		}
502
+        }
503 503
 
504
-	} else {
505
-		Display::display_warning_message(get_lang('FileNotFound'));
506
-	}
504
+    } else {
505
+        Display::display_warning_message(get_lang('FileNotFound'));
506
+    }
507 507
 } else {
508 508
     if ($slide_id != 'all') {
509 509
         Display::display_warning_message(get_lang('NoDataAvailable'));
Please login to merge, or discard this patch.
main/reports/templates/exercicesMultiCourses.reports.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $reports_template['exercicesMultiCourses'] = array(
4
-	'description' => 'Result of each test per student',
5
-	'getSQL' => 'reports_template_exercicesMultiCourses_getSQL',
6
-	'wizard' =>
4
+    'description' => 'Result of each test per student',
5
+    'getSQL' => 'reports_template_exercicesMultiCourses_getSQL',
6
+    'wizard' =>
7 7
 '
8 8
 <span id="exercicesMultiCourses" class="step">
9 9
 	<span class="font_normal_07em_black">Result of each test per student</span><br />
@@ -32,39 +32,39 @@  discard block
 block discarded – undo
32 32
 ');
33 33
 
34 34
 function reports_template_exercicesMultiCourses_getSQL() {
35
-	// foreach quiz
36
-	$result = array();
37
-	$columns = Database::query('select r.id as kid, c.title as course, '.
38
-		'r.child_name as test from '.
39
-		Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '.
40
-		Database::get_main_table(TABLE_MAIN_COURSE).' c '.
41
-		'where r.course_id=c.id and r.tool_id='.
42
-		reports_getToolId(TOOL_QUIZ).
43
-		' order by r.course_id, r.child_name');
44
-	if (Database::num_rows($columns) == 0)
45
-		die('<b>'.get_lang('no data found').'</b>');
46
-	$query = 'select u.lastname Name, u.firstname Firstname';
47
-	$columns = Database::store_result($columns);
48
-	if ($_REQUEST['tattempt'] == 'min' || $_REQUEST['tattempt'] == 'max')
49
-		$function = $_REQUEST['tattempt'];
50
-	else
51
-		$function = 'avg';
52
-	foreach ($columns as $key => $column)
53
-		$query .= ', '.$function.'(k'.$key.'.score) as `'.
54
-				$column['course'].' - '.
55
-				$column['test'].'` ';
56
-	$query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
57
-	foreach ($columns as $key => $column) // fixme sessions
58
-		$query .= 'left outer join '.
59
-			Database::get_main_table(TABLE_MAIN_REPORTS_VALUES).
60
-			' k'.$key.
61
-			' on k'.$key.'.key_id = '.$column['kid'].
62
-				' and k'.$key.'.user_id = u.user_id ';
63
-	$query .= ' group by ';
64
-	foreach ($columns as $key => $column) // grouping attempt
65
-		$query .= 'k'.$key.'.attempt, ';
66
-	$query = substr($query, 0, -2); // removing last ', ';
35
+    // foreach quiz
36
+    $result = array();
37
+    $columns = Database::query('select r.id as kid, c.title as course, '.
38
+        'r.child_name as test from '.
39
+        Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '.
40
+        Database::get_main_table(TABLE_MAIN_COURSE).' c '.
41
+        'where r.course_id=c.id and r.tool_id='.
42
+        reports_getToolId(TOOL_QUIZ).
43
+        ' order by r.course_id, r.child_name');
44
+    if (Database::num_rows($columns) == 0)
45
+        die('<b>'.get_lang('no data found').'</b>');
46
+    $query = 'select u.lastname Name, u.firstname Firstname';
47
+    $columns = Database::store_result($columns);
48
+    if ($_REQUEST['tattempt'] == 'min' || $_REQUEST['tattempt'] == 'max')
49
+        $function = $_REQUEST['tattempt'];
50
+    else
51
+        $function = 'avg';
52
+    foreach ($columns as $key => $column)
53
+        $query .= ', '.$function.'(k'.$key.'.score) as `'.
54
+                $column['course'].' - '.
55
+                $column['test'].'` ';
56
+    $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
57
+    foreach ($columns as $key => $column) // fixme sessions
58
+        $query .= 'left outer join '.
59
+            Database::get_main_table(TABLE_MAIN_REPORTS_VALUES).
60
+            ' k'.$key.
61
+            ' on k'.$key.'.key_id = '.$column['kid'].
62
+                ' and k'.$key.'.user_id = u.user_id ';
63
+    $query .= ' group by ';
64
+    foreach ($columns as $key => $column) // grouping attempt
65
+        $query .= 'k'.$key.'.attempt, ';
66
+    $query = substr($query, 0, -2); // removing last ', ';
67 67
 
68 68
 
69
-	return $query;
69
+    return $query;
70 70
 }
Please login to merge, or discard this patch.
main/session/session_add.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
 function search_coachs($needle)
32 32
 {
33 33
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
34
-	$xajax_response = new xajaxResponse();
35
-	$return = '';
34
+    $xajax_response = new xajaxResponse();
35
+    $return = '';
36 36
 
37
-	if (!empty($needle)) {
38
-		$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
37
+    if (!empty($needle)) {
38
+        $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
39 39
 
40
-		// search users where username or firstname or lastname begins likes $needle
41
-		$sql = 'SELECT username, lastname, firstname
40
+        // search users where username or firstname or lastname begins likes $needle
41
+        $sql = 'SELECT username, lastname, firstname
42 42
 		        FROM '.$tbl_user.' user
43 43
 				WHERE (username LIKE "'.$needle.'%"
44 44
 				OR firstname LIKE "'.$needle.'%"
45 45
 				OR lastname LIKE "'.$needle.'%")
46 46
 				AND status=1'.
47
-				$order_clause.
48
-				' LIMIT 10';
49
-
50
-		if (api_is_multiple_url_enabled()) {
51
-			$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
52
-			$access_url_id = api_get_current_access_url_id();
53
-			if ($access_url_id != -1) {
54
-				$sql = 'SELECT username, lastname, firstname
47
+                $order_clause.
48
+                ' LIMIT 10';
49
+
50
+        if (api_is_multiple_url_enabled()) {
51
+            $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
52
+            $access_url_id = api_get_current_access_url_id();
53
+            if ($access_url_id != -1) {
54
+                $sql = 'SELECT username, lastname, firstname
55 55
                         FROM '.$tbl_user.' user
56 56
                         INNER JOIN '.$tbl_user_rel_access_url.' url_user
57 57
                         ON (url_user.user_id=user.user_id)
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
                             AND status=1'.
66 66
                         $order_clause.'
67 67
                         LIMIT 10';
68
-			}
69
-		}
70
-
71
-		$rs = Database::query($sql);
72
-		while ($user = Database :: fetch_array($rs)) {
73
-			$return .= '<a href="javascript: void(0);" onclick="javascript: fill_coach_field(\''.$user['username'].'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
74
-		}
75
-	}
76
-	$xajax_response -> addAssign('ajax_list_coachs','innerHTML', api_utf8_encode($return));
77
-	return $xajax_response;
68
+            }
69
+        }
70
+
71
+        $rs = Database::query($sql);
72
+        while ($user = Database :: fetch_array($rs)) {
73
+            $return .= '<a href="javascript: void(0);" onclick="javascript: fill_coach_field(\''.$user['username'].'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
74
+        }
75
+    }
76
+    $xajax_response -> addAssign('ajax_list_coachs','innerHTML', api_utf8_encode($return));
77
+    return $xajax_response;
78 78
 }
79 79
 $xajax -> processRequests();
80 80
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 </script>";
118 118
 
119 119
 if (isset($_POST['formSent']) && $_POST['formSent']) {
120
-	$formSent = 1;
120
+    $formSent = 1;
121 121
 }
122 122
 
123 123
 $tool_name = get_lang('AddSession');
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 Display::display_header($tool_name);
210 210
 
211 211
 if (!empty($return)) {
212
-	Display::display_error_message($return, false);
212
+    Display::display_error_message($return, false);
213 213
 }
214 214
 
215 215
 echo '<div class="actions">';
Please login to merge, or discard this patch.
main/gradebook/lib/fe/exportgradebook.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function print_table($data_array,$header_names,$view,$coursename)
16 16
 {
17
-	$printdata = '<!DOCTYPE html
17
+    $printdata = '<!DOCTYPE html
18 18
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
19 19
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
20 20
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.api_get_language_isocode().'" lang="'.api_get_language_isocode().'">
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
  */
98 98
 function export_pdf_attendance($headers_table, $data_table, $headers_pdf, $footers_pdf, $title_pdf)
99 99
 {
100
-	$mpdf = new mPDF('UTF-8', 'A4-L', '', '', 15, 10, 35, 20, 4, 2, 'L');
101
-	$mpdf->useOnlyCoreFonts = true;
102
-	$mpdf->mirrorMargins = 0;
100
+    $mpdf = new mPDF('UTF-8', 'A4-L', '', '', 15, 10, 35, 20, 4, 2, 'L');
101
+    $mpdf->useOnlyCoreFonts = true;
102
+    $mpdf->mirrorMargins = 0;
103 103
     // Use different Odd/Even headers and footers and mirror margins
104 104
 
105
-	if (is_array($headers_pdf)) {
106
-		// preparing headers pdf
107
-		$header = '
105
+    if (is_array($headers_pdf)) {
106
+        // preparing headers pdf
107
+        $header = '
108 108
             <table width="100%"  cellspacing="1" cellpadding="1" border="0" class="strong">
109 109
             <tr>
110 110
                 <td ROWSPAN="3" style="text-align: left;" class="title">
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         $items_per_page = count($data_table);
159 159
     }
160 160
 
161
-	$count_pages = ceil(count($data_table) / $items_per_page);
161
+    $count_pages = ceil(count($data_table) / $items_per_page);
162 162
     $content_table = '';
163 163
     for ($x = 0; $x<$count_pages; $x++) {
164 164
         $content_table .= '<table width="100%" border="1" style="border-collapse:collapse">';
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
  */
327 327
 function export_pdf($pdf, $newarray, $header_names, $format)
328 328
 {
329
-	$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
330
-	$pdf->ezSetCmMargins(0,0,0,0);
331
-	$pdf->ezSetY(($format=='portrait')?'820':'570');
332
-	$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
329
+    $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
330
+    $pdf->ezSetCmMargins(0,0,0,0);
331
+    $pdf->ezSetY(($format=='portrait')?'820':'570');
332
+    $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
333 333
     if ($format == 'portrait') {
334 334
         $pdf->line(40, 790, 540, 790);
335 335
         $pdf->line(40, 40, 540, 40);
@@ -345,5 +345,5 @@  discard block
 block discarded – undo
345 345
         'rowGap' => 3,
346 346
         'width' => (($format == 'portrait') ? '500' : '750'),
347 347
     ));
348
-	$pdf->ezStream();
348
+    $pdf->ezStream();
349 349
 }
Please login to merge, or discard this patch.
main/permissions/permissions_functions.inc.php 1 patch
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
25 25
 function store_permissions($content, $id) {
26 26
     $course_id = api_get_course_int_id();
27 27
     
28
-	// Which database are we using (depending on the $content parameter)
29
-	if ($content=='user')
30
-	{
31
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
32
-		$id_field = user_id;
33
-	}
34
-	if ($content=='group')
35
-	{
36
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
37
-		$id_field = group_id;
38
-	}
39
-	if ($content=='role')
40
-	{
41
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
42
-		$id_field = role_id;
43
-	}
44
-
45
-	// We first delete all the existing permissions for that user/group/role
46
-	$sql="DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
-	$result=Database::query($sql);
48
-
49
-	// looping through the post values to find the permission (containing the string permission* )
50
-	foreach ($_POST as $key => $value)
51
-	{
52
-		if (strstr($key,"permission*"))
53
-		{
54
-			list($brol,$tool,$action)=explode("*",$key);
55
-			$sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')";
56
-			$result=Database::query($sql);
57
-		}
58
-	}
59
-	return get_lang('PermissionsStored');
28
+    // Which database are we using (depending on the $content parameter)
29
+    if ($content=='user')
30
+    {
31
+        $table=Database::get_course_table(TABLE_PERMISSION_USER);
32
+        $id_field = user_id;
33
+    }
34
+    if ($content=='group')
35
+    {
36
+        $table=Database::get_course_table(TABLE_PERMISSION_GROUP);
37
+        $id_field = group_id;
38
+    }
39
+    if ($content=='role')
40
+    {
41
+        $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
42
+        $id_field = role_id;
43
+    }
44
+
45
+    // We first delete all the existing permissions for that user/group/role
46
+    $sql="DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
+    $result=Database::query($sql);
48
+
49
+    // looping through the post values to find the permission (containing the string permission* )
50
+    foreach ($_POST as $key => $value)
51
+    {
52
+        if (strstr($key,"permission*"))
53
+        {
54
+            list($brol,$tool,$action)=explode("*",$key);
55
+            $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')";
56
+            $result=Database::query($sql);
57
+        }
58
+    }
59
+    return get_lang('PermissionsStored');
60 60
 }
61 61
 
62 62
 /**
@@ -70,50 +70,50 @@  discard block
 block discarded – undo
70 70
 * @version 1.0
71 71
 */
72 72
 function store_one_permission($content, $action, $id, $tool,$permission) {
73
-	global $rights_full;
73
+    global $rights_full;
74 74
     $course_id = api_get_course_int_id();
75
-	// for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
75
+    // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
76 76
 
77
-	// check
78
-	//if(!in_array($permission, $rights_full))
79
-	//{
80
-	//	return get_lang('Error');
81
-	//}
77
+    // check
78
+    //if(!in_array($permission, $rights_full))
79
+    //{
80
+    //	return get_lang('Error');
81
+    //}
82 82
 
83
-	// Which database are we using (depending on the $content parameter)
83
+    // Which database are we using (depending on the $content parameter)
84 84
     
85
-	if ($content=='user') {
86
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
87
-		$id_field = user_id;
88
-	}
89
-	if ($content=='group')
90
-	{
91
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
92
-		$id_field = group_id;
93
-	}
94
-	if ($content=='role')
95
-	{
96
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
97
-		$id_field = role_id;
98
-	}
99
-
100
-	// grating a right
101
-	if ($action=='grant') {
102
-		$sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')";
103
-		$result=Database::query($sql);
104
-		if($result) {
105
-			$result_message=get_lang('PermissionGranted');
106
-		}
107
-	}
108
-	if ($action=='revoke')
109
-	{
110
-		$sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'";
111
-		$result=Database::query($sql);
112
-		if($result) {
113
-			$result_message=get_lang('PermissionRevoked');
114
-		}
115
-	}
116
-	return $result_message;
85
+    if ($content=='user') {
86
+        $table=Database::get_course_table(TABLE_PERMISSION_USER);
87
+        $id_field = user_id;
88
+    }
89
+    if ($content=='group')
90
+    {
91
+        $table=Database::get_course_table(TABLE_PERMISSION_GROUP);
92
+        $id_field = group_id;
93
+    }
94
+    if ($content=='role')
95
+    {
96
+        $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
97
+        $id_field = role_id;
98
+    }
99
+
100
+    // grating a right
101
+    if ($action=='grant') {
102
+        $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')";
103
+        $result=Database::query($sql);
104
+        if($result) {
105
+            $result_message=get_lang('PermissionGranted');
106
+        }
107
+    }
108
+    if ($action=='revoke')
109
+    {
110
+        $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'";
111
+        $result=Database::query($sql);
112
+        if($result) {
113
+            $result_message=get_lang('PermissionRevoked');
114
+        }
115
+    }
116
+    return $result_message;
117 117
 }
118 118
 
119 119
 /**
@@ -125,47 +125,47 @@  discard block
 block discarded – undo
125 125
 */
126 126
 function get_permissions($content, $id) {
127 127
     $course_id = api_get_course_int_id();
128
-	$currentpermissions=array();
129
-	// Which database are we using (depending on the $content parameter)
128
+    $currentpermissions=array();
129
+    // Which database are we using (depending on the $content parameter)
130 130
     $course_id_condition = " c_id = $course_id AND ";
131
-	if ($content == 'user')
132
-	{
133
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
134
-		$id_field = 'user_id';
135
-	}
136
-	elseif ($content == 'group')
137
-	{
138
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
139
-		$id_field = 'group_id';
140
-	}
141
-	elseif ($content == 'role')
142
-	{
143
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
144
-		$id_field = 'role_id';
145
-	}
146
-	elseif ($content == 'platform_role')
147
-	{
148
-		$table=Database::get_main_table(TABLE_ROLE_PERMISSION);
149
-		$id_field = 'role_id';
131
+    if ($content == 'user')
132
+    {
133
+        $table=Database::get_course_table(TABLE_PERMISSION_USER);
134
+        $id_field = 'user_id';
135
+    }
136
+    elseif ($content == 'group')
137
+    {
138
+        $table=Database::get_course_table(TABLE_PERMISSION_GROUP);
139
+        $id_field = 'group_id';
140
+    }
141
+    elseif ($content == 'role')
142
+    {
143
+        $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
144
+        $id_field = 'role_id';
145
+    }
146
+    elseif ($content == 'platform_role')
147
+    {
148
+        $table=Database::get_main_table(TABLE_ROLE_PERMISSION);
149
+        $id_field = 'role_id';
150 150
         $course_id_condition = '';
151
-	}
152
-	elseif ($content == 'task')
153
-	{
154
-		$table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155
-		$id_field = 'task_id';
156
-	}
157
-
158
-	// finding all the permissions. We store this in a multidimensional array
159
-	// where the first dimension is the tool.
160
-	$sql="
151
+    }
152
+    elseif ($content == 'task')
153
+    {
154
+        $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155
+        $id_field = 'task_id';
156
+    }
157
+
158
+    // finding all the permissions. We store this in a multidimensional array
159
+    // where the first dimension is the tool.
160
+    $sql="
161 161
 		SELECT * FROM " . $table . "
162 162
 		WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'";
163
-	$result = Database::query($sql);
163
+    $result = Database::query($sql);
164 164
 
165
-	while($row = Database::fetch_array($result))
166
-		$currentpermissions[$row['tool']][] = $row['action'];
165
+    while($row = Database::fetch_array($result))
166
+        $currentpermissions[$row['tool']][] = $row['action'];
167 167
 
168
-	return $currentpermissions;
168
+    return $currentpermissions;
169 169
 }
170 170
 
171 171
 /**
@@ -179,38 +179,38 @@  discard block
 block discarded – undo
179 179
 */
180 180
 function limited_or_full($current_permissions)
181 181
 {
182
-	if (api_get_setting('permissions')=='limited')
183
-	{
184
-		foreach ($current_permissions as $tool=>$tool_rights)
185
-		{
186
-			// we loop through the possible permissions of a tool and unset the entry if it is view
187
-			// if it is visibility or move we have to grant the edit right
188
-			foreach ($tool_rights as $key=>$value)
189
-			{
190
-				if ($value=='View')
191
-				{
192
-					unset($current_permissions[$tool][$key]);
193
-				}
194
-				if ($value=='Visibility' OR $value=='Move')
195
-				{
196
-					if (!in_array('Edit',$current_permissions[$tool]))
197
-					{
198
-						$current_permissions[$tool][]='Edit';
199
-					}
200
-					unset($current_permissions[$tool][$key]);
201
-				}
202
-				//else
203
-				//{
204
-				//	$current_permissions[$tool][]=$value;
205
-				//}
206
-			}
207
-		}
208
-		return $current_permissions;
209
-	}
210
-	if (api_get_setting('permissions')=='full')
211
-	{
212
-		return $current_permissions;
213
-	}
182
+    if (api_get_setting('permissions')=='limited')
183
+    {
184
+        foreach ($current_permissions as $tool=>$tool_rights)
185
+        {
186
+            // we loop through the possible permissions of a tool and unset the entry if it is view
187
+            // if it is visibility or move we have to grant the edit right
188
+            foreach ($tool_rights as $key=>$value)
189
+            {
190
+                if ($value=='View')
191
+                {
192
+                    unset($current_permissions[$tool][$key]);
193
+                }
194
+                if ($value=='Visibility' OR $value=='Move')
195
+                {
196
+                    if (!in_array('Edit',$current_permissions[$tool]))
197
+                    {
198
+                        $current_permissions[$tool][]='Edit';
199
+                    }
200
+                    unset($current_permissions[$tool][$key]);
201
+                }
202
+                //else
203
+                //{
204
+                //	$current_permissions[$tool][]=$value;
205
+                //}
206
+            }
207
+        }
208
+        return $current_permissions;
209
+    }
210
+    if (api_get_setting('permissions')=='full')
211
+    {
212
+        return $current_permissions;
213
+    }
214 214
 }
215 215
 /**
216 216
 * This function displays a checked or unchecked checkbox. The checkbox will be checked if the
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 */
225 225
 function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array())
226 226
 {
227
-	$checked="";
228
-	if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
229
-	{
230
-		$checked="checked";
231
-	}
232
-	echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n";
227
+    $checked="";
228
+    if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
229
+    {
230
+        $checked="checked";
231
+    }
232
+    echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n";
233 233
 
234 234
 }
235 235
 
@@ -245,62 +245,62 @@  discard block
 block discarded – undo
245 245
 */
246 246
 function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
247 247
 {
248
-	if ($course_admin) {
249
-		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
250
-	} else {
251
-		if (in_array($permission,$inherited_permissions[$tool])) {
252
-			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
253
-		} else {
254
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) {
255
-				if ($editable) {
256
-					$url=api_get_self();
257
-					$urlparameters = '';
258
-					foreach($_GET as $key=>$value) {
259
-						$parameter[$key]=$value;
260
-					}
261
-					$parameter['action']='revoke';
262
-					$parameter['permission']=$permission;
263
-					$parameter['tool']=$tool;
264
-					foreach ($parameter as $key=>$value) {
265
-						$urlparameters.=$key.'='.$value.'&amp;';
266
-					}
267
-					$url=$url.'?'.$urlparameters;
268
-
269
-					echo "\t\t\t <a href=\"".$url."\">";
270
-				}
271
-				echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>";
272
-				if ($editable) {
273
-					echo "</a>";
274
-				}
275
-			} else {
276
-				if ($editable)
277
-				{
278
-					$url=api_get_self();
279
-					$urlparameters = '';
280
-					foreach ($_GET as $key=>$value)
281
-					{
282
-						$parameter[$key]=$value;
283
-					}
284
-					$parameter['action']='grant';
285
-					$parameter['permission']=$permission;
286
-					$parameter['tool']=$tool;
287
-					foreach ($parameter as $key=>$value)
288
-					{
289
-						$urlparameters.=$key.'='.$value.'&amp;';
290
-					}
291
-					$url=$url.'?'.$urlparameters;
292
-
293
-					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
294
-					echo "\t\t\t <a href=\"".$url."\">";
295
-				}
296
-				echo "<img src=\"../img/wrong.gif\" border=\"0\"/>";
297
-				if ($editable)
298
-				{
299
-					echo "</a>";
300
-				}
301
-			}
302
-		}
303
-	}
248
+    if ($course_admin) {
249
+        echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
250
+    } else {
251
+        if (in_array($permission,$inherited_permissions[$tool])) {
252
+            echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
253
+        } else {
254
+            if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) {
255
+                if ($editable) {
256
+                    $url=api_get_self();
257
+                    $urlparameters = '';
258
+                    foreach($_GET as $key=>$value) {
259
+                        $parameter[$key]=$value;
260
+                    }
261
+                    $parameter['action']='revoke';
262
+                    $parameter['permission']=$permission;
263
+                    $parameter['tool']=$tool;
264
+                    foreach ($parameter as $key=>$value) {
265
+                        $urlparameters.=$key.'='.$value.'&amp;';
266
+                    }
267
+                    $url=$url.'?'.$urlparameters;
268
+
269
+                    echo "\t\t\t <a href=\"".$url."\">";
270
+                }
271
+                echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>";
272
+                if ($editable) {
273
+                    echo "</a>";
274
+                }
275
+            } else {
276
+                if ($editable)
277
+                {
278
+                    $url=api_get_self();
279
+                    $urlparameters = '';
280
+                    foreach ($_GET as $key=>$value)
281
+                    {
282
+                        $parameter[$key]=$value;
283
+                    }
284
+                    $parameter['action']='grant';
285
+                    $parameter['permission']=$permission;
286
+                    $parameter['tool']=$tool;
287
+                    foreach ($parameter as $key=>$value)
288
+                    {
289
+                        $urlparameters.=$key.'='.$value.'&amp;';
290
+                    }
291
+                    $url=$url.'?'.$urlparameters;
292
+
293
+                    //echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
294
+                    echo "\t\t\t <a href=\"".$url."\">";
295
+                }
296
+                echo "<img src=\"../img/wrong.gif\" border=\"0\"/>";
297
+                if ($editable)
298
+                {
299
+                    echo "</a>";
300
+                }
301
+            }
302
+        }
303
+    }
304 304
 }
305 305
 
306 306
 
@@ -318,72 +318,72 @@  discard block
 block discarded – undo
318 318
 function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
319 319
 {
320 320
 
321
-	if ($course_admin)
322
-	{
323
-		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
324
-	}
325
-	else
326
-	{
327
-		if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
328
-		{
329
-			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330
-		}
331
-		else
332
-		{
333
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
334
-			{
335
-				if ($editable)
336
-				{
337
-					$url = api_get_self();
338
-					$urlparameters = '';
339
-					foreach($_GET as $key => $value)
340
-					{
341
-						$parameter[$key] = $value;
342
-					}
343
-					$parameter['action']='manage_rights';
344
-					$parameter['do']='revoke';
345
-					$parameter['permission']=$permission;
346
-					$parameter['tool']=$tool;
347
-					$parameter['user_id']=$user_id;
348
-					foreach ($parameter as $key=>$value)
349
-					{
350
-						$urlparameters .= $key . '=' . $value . '&amp;';
351
-					}
352
-					$url = $url . '?' . $urlparameters;
353
-
354
-					echo "\t\t\t <a href=\"".$url."\">";
355
-				}
356
-				echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">";
357
-				if ($editable) {
358
-					echo "</a>";
359
-				}
360
-			} else {
361
-				if ($editable) {
362
-					$url = api_get_self();
363
-					$urlparameters = '';
364
-					foreach ($_GET as $key=>$value) {
365
-						$parameter[$key]=$value;
366
-					}
367
-					$parameter['action']='manage_rights';
368
-					$parameter['do']='grant';
369
-					$parameter['permission']=$permission;
370
-					$parameter['tool']=$tool;
371
-					$parameter['user_id']=$user_id;
372
-					foreach ($parameter as $key=>$value) {
373
-						$urlparameters .= $key . '=' . $value . '&amp;';
374
-					}
375
-					$url=$url.'?'.$urlparameters;
376
-
377
-					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
378
-					echo "\t\t\t <a href=\"".$url."\">";
379
-				}
380
-				echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">";
381
-				if ($editable) {
382
-					echo "</a>";
383
-				}
384
-			}
385
-		}
386
-	}
321
+    if ($course_admin)
322
+    {
323
+        echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
324
+    }
325
+    else
326
+    {
327
+        if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
328
+        {
329
+            echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330
+        }
331
+        else
332
+        {
333
+            if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
334
+            {
335
+                if ($editable)
336
+                {
337
+                    $url = api_get_self();
338
+                    $urlparameters = '';
339
+                    foreach($_GET as $key => $value)
340
+                    {
341
+                        $parameter[$key] = $value;
342
+                    }
343
+                    $parameter['action']='manage_rights';
344
+                    $parameter['do']='revoke';
345
+                    $parameter['permission']=$permission;
346
+                    $parameter['tool']=$tool;
347
+                    $parameter['user_id']=$user_id;
348
+                    foreach ($parameter as $key=>$value)
349
+                    {
350
+                        $urlparameters .= $key . '=' . $value . '&amp;';
351
+                    }
352
+                    $url = $url . '?' . $urlparameters;
353
+
354
+                    echo "\t\t\t <a href=\"".$url."\">";
355
+                }
356
+                echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">";
357
+                if ($editable) {
358
+                    echo "</a>";
359
+                }
360
+            } else {
361
+                if ($editable) {
362
+                    $url = api_get_self();
363
+                    $urlparameters = '';
364
+                    foreach ($_GET as $key=>$value) {
365
+                        $parameter[$key]=$value;
366
+                    }
367
+                    $parameter['action']='manage_rights';
368
+                    $parameter['do']='grant';
369
+                    $parameter['permission']=$permission;
370
+                    $parameter['tool']=$tool;
371
+                    $parameter['user_id']=$user_id;
372
+                    foreach ($parameter as $key=>$value) {
373
+                        $urlparameters .= $key . '=' . $value . '&amp;';
374
+                    }
375
+                    $url=$url.'?'.$urlparameters;
376
+
377
+                    //echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
378
+                    echo "\t\t\t <a href=\"".$url."\">";
379
+                }
380
+                echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">";
381
+                if ($editable) {
382
+                    echo "</a>";
383
+                }
384
+            }
385
+        }
386
+    }
387 387
 }
388 388
 
389 389
 
@@ -394,41 +394,41 @@  discard block
 block discarded – undo
394 394
 */
395 395
 function display_role_list($current_course_roles, $current_platform_roles)
396 396
 {
397
-	global $setting_visualisation;
397
+    global $setting_visualisation;
398 398
     $course_id = api_get_course_int_id();
399 399
 
400
-	$coures_roles_table=Database::get_course_table(TABLE_ROLE);
401
-
402
-	// course roles
403
-	$sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
404
-	$result=Database::query($sql);
405
-	while ($row=Database::fetch_array($result))
406
-	{
407
-		if (in_array($row['role_id'], $current_course_roles))
408
-		{
409
-			$checked='checked';
410
-			$image='checkbox_on2.gif';
411
-			$action='revoke';
412
-		}
413
-		else
414
-		{
415
-			$checked='';
416
-			$image='wrong.gif';
417
-			$action='grant';
418
-		}
419
-		if ($setting_visualisation=='checkbox')
420
-		{
421
-			echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
422
-		}
423
-		if ($setting_visualisation=='image')
424
-		{
425
-			echo "<a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>";
426
-		}
427
-
428
-
429
-		echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&amp;scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n";
430
-		echo $row['role_comment']."<br />\n";
431
-	}
400
+    $coures_roles_table=Database::get_course_table(TABLE_ROLE);
401
+
402
+    // course roles
403
+    $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
404
+    $result=Database::query($sql);
405
+    while ($row=Database::fetch_array($result))
406
+    {
407
+        if (in_array($row['role_id'], $current_course_roles))
408
+        {
409
+            $checked='checked';
410
+            $image='checkbox_on2.gif';
411
+            $action='revoke';
412
+        }
413
+        else
414
+        {
415
+            $checked='';
416
+            $image='wrong.gif';
417
+            $action='grant';
418
+        }
419
+        if ($setting_visualisation=='checkbox')
420
+        {
421
+            echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
422
+        }
423
+        if ($setting_visualisation=='image')
424
+        {
425
+            echo "<a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>";
426
+        }
427
+
428
+
429
+        echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&amp;scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n";
430
+        echo $row['role_comment']."<br />\n";
431
+    }
432 432
 }
433 433
 
434 434
 /**
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
 */
443 443
 function get_roles($content,$id, $scope='course') {
444 444
     $course_id  = api_get_course_int_id();    
445
-	if ($content=='user') {
446
-		$table=Database::get_course_table(TABLE_ROLE_USER);
447
-		$id_field = user_id;
448
-	}
449
-	if ($content=='group') {
450
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
451
-		$id_field = 'group_id';
452
-	}
453
-	$table_role=Database::get_course_table(TABLE_ROLE);
454
-
455
-	$current_roles=array();
456
-	//$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";
457
-	$sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'";
458
-	$result=Database::query($sql);
459
-	while ($row=Database::fetch_array($result)) {
460
-		$current_roles[]=$row['role_id'];
461
-	}
462
-	return $current_roles;
445
+    if ($content=='user') {
446
+        $table=Database::get_course_table(TABLE_ROLE_USER);
447
+        $id_field = user_id;
448
+    }
449
+    if ($content=='group') {
450
+        $table=Database::get_course_table(TABLE_ROLE_GROUP);
451
+        $id_field = 'group_id';
452
+    }
453
+    $table_role=Database::get_course_table(TABLE_ROLE);
454
+
455
+    $current_roles=array();
456
+    //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";
457
+    $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'";
458
+    $result=Database::query($sql);
459
+    while ($row=Database::fetch_array($result)) {
460
+        $current_roles[]=$row['role_id'];
461
+    }
462
+    return $current_roles;
463 463
 }
464 464
 
465 465
 /**
@@ -472,25 +472,25 @@  discard block
 block discarded – undo
472 472
     $course_id = api_get_course_int_id();
473 473
     $course_id_condition = " WHERE c_id = $course_id ";
474 474
     
475
-	if ($content=='course')
476
-	{
477
-		$table_role=Database::get_course_table(TABLE_ROLE);
478
-	}
479
-	if ($content=='platform')
480
-	{
481
-		$table_role=Database::get_main_table(TABLE_ROLE);
482
-		$course_id_condition = '';
483
-	}
484
-
485
-	$current_roles=array();
486
-	$sql="SELECT * FROM $table_role $course_id_condition ";
487
-	$result=Database::query($sql);
488
-	while ($row=Database::fetch_array($result))
489
-	{
490
-		$roles[]=$row;
491
-	}
492
-
493
-	return $roles;
475
+    if ($content=='course')
476
+    {
477
+        $table_role=Database::get_course_table(TABLE_ROLE);
478
+    }
479
+    if ($content=='platform')
480
+    {
481
+        $table_role=Database::get_main_table(TABLE_ROLE);
482
+        $course_id_condition = '';
483
+    }
484
+
485
+    $current_roles=array();
486
+    $sql="SELECT * FROM $table_role $course_id_condition ";
487
+    $result=Database::query($sql);
488
+    while ($row=Database::fetch_array($result))
489
+    {
490
+        $roles[]=$row;
491
+    }
492
+
493
+    return $roles;
494 494
 }
495 495
 
496 496
 
@@ -506,34 +506,34 @@  discard block
 block discarded – undo
506 506
 */
507 507
 function get_roles_permissions($content,$id, $scope='course') {
508 508
     $course_id = api_get_course_int_id();
509
-	if ($content == 'user') {
510
-		$table=Database::get_course_table(TABLE_ROLE_USER);
511
-		$id_field = 'user_id';
512
-	}
513
-
514
-	if ($content == 'group') {
515
-		$table = Database::get_course_table(TABLE_ROLE_GROUP);
516
-		$id_field = 'group_id';
517
-	}
518
-
519
-	// course roles or platform roles
520
-	$scope = 'course';
521
-	if ($scope == 'course') {
522
-		$table_role = Database::get_course_table(TABLE_ROLE);
523
-		$table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION);
509
+    if ($content == 'user') {
510
+        $table=Database::get_course_table(TABLE_ROLE_USER);
511
+        $id_field = 'user_id';
512
+    }
513
+
514
+    if ($content == 'group') {
515
+        $table = Database::get_course_table(TABLE_ROLE_GROUP);
516
+        $id_field = 'group_id';
517
+    }
518
+
519
+    // course roles or platform roles
520
+    $scope = 'course';
521
+    if ($scope == 'course') {
522
+        $table_role = Database::get_course_table(TABLE_ROLE);
523
+        $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION);
524 524
         
525 525
         $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND ";
526
-	}
526
+    }
527 527
 
528
-	if ($scope == 'platform') {
529
-		$table_role = Database::get_main_table(TABLE_ROLE);
530
-		$table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION);
528
+    if ($scope == 'platform') {
529
+        $table_role = Database::get_main_table(TABLE_ROLE);
530
+        $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION);
531 531
         $role_condition = '';
532
-	}
532
+    }
533 533
 
534
-	$current_roles = array();
534
+    $current_roles = array();
535 535
 
536
-	$sql = "
536
+    $sql = "
537 537
 		SELECT *
538 538
 		FROM
539 539
 			" . $table . " role_group_user,
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
 			role_group_user.role_id = role.role_id AND
548 548
 			role.role_id = role_permissions.role_id";
549 549
 
550
-	$result = Database::query($sql);
550
+    $result = Database::query($sql);
551 551
     $current_role_permissions = array();
552
-	while ($row=Database::fetch_array($result)) {
553
-		$current_role_permissions[$row['tool']][]=$row['action'];
552
+    while ($row=Database::fetch_array($result)) {
553
+        $current_role_permissions[$row['tool']][]=$row['action'];
554 554
     }
555
-	return $current_role_permissions;
555
+    return $current_role_permissions;
556 556
 }
557 557
 
558 558
 /**
@@ -566,34 +566,34 @@  discard block
 block discarded – undo
566 566
 
567 567
 function assign_role($content, $action, $id, $role_id, $scope='course') {
568 568
     $course_id = api_get_course_int_id();
569
-	// Which database are we using (depending on the $content parameter)
570
-	if ($content=='user') {
571
-		$table=Database::get_course_table(TABLE_ROLE_USER);
572
-		$id_field = 'user_id';
573
-	} elseif($content=='group') {
574
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
575
-		$id_field = 'group_id';
576
-	} else {
577
-		return  get_lang('Error');
578
-	}
579
-
580
-	// grating a right
581
-	if ($action=='grant') {
582
-		$sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')";
583
-		$result=Database::query($sql);
584
-		if ($result) {
585
-			$result_message=get_lang('RoleGranted');
586
-		}
587
-	}
569
+    // Which database are we using (depending on the $content parameter)
570
+    if ($content=='user') {
571
+        $table=Database::get_course_table(TABLE_ROLE_USER);
572
+        $id_field = 'user_id';
573
+    } elseif($content=='group') {
574
+        $table=Database::get_course_table(TABLE_ROLE_GROUP);
575
+        $id_field = 'group_id';
576
+    } else {
577
+        return  get_lang('Error');
578
+    }
579
+
580
+    // grating a right
581
+    if ($action=='grant') {
582
+        $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')";
583
+        $result=Database::query($sql);
584
+        if ($result) {
585
+            $result_message=get_lang('RoleGranted');
586
+        }
587
+    }
588 588
     
589
-	if ($action=='revoke') {
590
-		$sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'";
591
-		$result=Database::query($sql);
592
-		if ($result) {
593
-			$result_message=get_lang('RoleRevoked');
594
-		}
595
-	}
596
-	return $result_message;
589
+    if ($action=='revoke') {
590
+        $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'";
591
+        $result=Database::query($sql);
592
+        if ($result) {
593
+            $result_message=get_lang('RoleRevoked');
594
+        }
595
+    }
596
+    return $result_message;
597 597
 }
598 598
 
599 599
 
@@ -603,21 +603,21 @@  discard block
 block discarded – undo
603 603
 */
604 604
 function permission_array_merge($array1, $array2)
605 605
 {
606
-	foreach ($array2 as $tool=>$permissions)
607
-	{
608
-		foreach ($permissions as $permissionkey=>$permissionvalue)
609
-		{
610
-			$array1[$tool][]=$permissionvalue;
611
-		}
612
-	}
613
-	return $array1;
606
+    foreach ($array2 as $tool=>$permissions)
607
+    {
608
+        foreach ($permissions as $permissionkey=>$permissionvalue)
609
+        {
610
+            $array1[$tool][]=$permissionvalue;
611
+        }
612
+    }
613
+    return $array1;
614 614
 }
615 615
 
616 616
 
617 617
 function my_print_r($array)
618 618
 {
619
-	echo '<pre>';
620
-	print_r($array);
621
-	echo '</pre>';
619
+    echo '<pre>';
620
+    print_r($array);
621
+    echo '</pre>';
622 622
 }
623 623
 ?>
Please login to merge, or discard this patch.
main/tracking/lp_results_by_user.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -16,34 +16,34 @@  discard block
 block discarded – undo
16 16
 $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
17 17
 
18 18
 if (!$is_allowedToTrack) {
19
-	Display :: display_header(null);
20
-	api_not_allowed();
21
-	Display :: display_footer();
19
+    Display :: display_header(null);
20
+    api_not_allowed();
21
+    Display :: display_footer();
22 22
 }
23 23
 
24 24
 $export_to_csv = false;
25 25
 if (isset($_GET['export'])) {
26
-	$export_to_csv = true;
26
+    $export_to_csv = true;
27 27
 }
28 28
 
29 29
 if (api_is_platform_admin() ) {
30
-	$global = true;
30
+    $global = true;
31 31
 } else {
32
-	$global = false;
32
+    $global = false;
33 33
 }
34 34
 
35 35
 if ($global) {
36
-	$temp_course_list = CourseManager :: get_courses_list();
37
-	foreach($temp_course_list  as $temp_course_item) {
38
-		$course_item = CourseManager ::get_course_information($temp_course_item['code']);
36
+    $temp_course_list = CourseManager :: get_courses_list();
37
+    foreach($temp_course_list  as $temp_course_item) {
38
+        $course_item = CourseManager ::get_course_information($temp_course_item['code']);
39 39
         $course_list[] = array(
40 40
             'code' => $course_item['code'],
41 41
             'title' => $course_item['title'],
42 42
         );
43
-	}
43
+    }
44 44
 } else {
45 45
     $current_course['code'] = $_course['id'];
46
-	$course_list = array($current_course);
46
+    $course_list = array($current_course);
47 47
 }
48 48
 
49 49
 $new_course_select = array();
@@ -54,20 +54,20 @@  discard block
 block discarded – undo
54 54
 $form = new FormValidator('search_simple', 'POST', '', '', null, false);
55 55
 $form->addElement('select','course_code',get_lang('Course'), $new_course_select);
56 56
 if ($global) {
57
-	$form->addElement('hidden','view','admin');
57
+    $form->addElement('hidden','view','admin');
58 58
 } else {
59
-	//Get exam lists
59
+    //Get exam lists
60 60
     $course_id = api_get_course_int_id();
61
-	$t_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
62
-	$sqlExercices = "SELECT quiz.title,id FROM ".$t_quiz." AS quiz
61
+    $t_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
62
+    $sqlExercices = "SELECT quiz.title,id FROM ".$t_quiz." AS quiz
63 63
 	                 WHERE c_id = $course_id AND active='1'
64 64
 	                 ORDER BY quiz.title ASC";
65
-	$resultExercices = Database::query($sqlExercices);
66
-	$exercise_list[0] = get_lang('All');
67
-	while($a_exercices = Database::fetch_array($resultExercices)) {
68
-		$exercise_list[$a_exercices['id']] = $a_exercices['title'];
69
-	}
70
-	$form->addElement('select', 'exercise_id', get_lang('Exercise'), $exercise_list);
65
+    $resultExercices = Database::query($sqlExercices);
66
+    $exercise_list[0] = get_lang('All');
67
+    while($a_exercices = Database::fetch_array($resultExercices)) {
68
+        $exercise_list[$a_exercices['id']] = $a_exercices['title'];
69
+    }
70
+    $form->addElement('select', 'exercise_id', get_lang('Exercise'), $exercise_list);
71 71
 }
72 72
 
73 73
 //$form->addElement('submit','submit',get_lang('Filter'));
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 }
82 82
 
83 83
 if (!$export_to_csv) {
84
-	Display :: display_header(get_lang('Reporting'));
85
-	echo '<div class="actions" style ="font-size:10pt;">';
86
-	if ($global) {
84
+    Display :: display_header(get_lang('Reporting'));
85
+    echo '<div class="actions" style ="font-size:10pt;">';
86
+    if ($global) {
87 87
 
88 88
         echo '<div style="float:right"> <a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'">
89 89
                 '.Display::return_icon('csv.gif').'
@@ -93,81 +93,81 @@  discard block
 block discarded – undo
93 93
                 &nbsp;'.get_lang('Print').'</a>
94 94
                 	</div>';
95 95
 
96
-		$menu_items[] = '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher">'.get_lang('TeacherInterface').'</a>';
96
+        $menu_items[] = '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher">'.get_lang('TeacherInterface').'</a>';
97 97
         if (api_is_platform_admin()) {
98
-		  $menu_items[] = '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin">'.get_lang('AdminInterface').'</a>';
98
+            $menu_items[] = '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin">'.get_lang('AdminInterface').'</a>';
99 99
         } else {
100 100
             $menu_items[] = '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=coach">'.get_lang('AdminInterface').'</a>';
101 101
         }
102
-		$menu_items[] = get_lang('ExamTracking');
103
-		$nb_menu_items = count($menu_items);
104
-		if($nb_menu_items>1) {
105
-			foreach($menu_items as $key=> $item) {
106
-				echo $item;
107
-				if($key!=$nb_menu_items-1) {
108
-					echo ' | ';
109
-				}
110
-			}
111
-			echo '<br />';
112
-		}
113
-	} else {
114
-	    echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
102
+        $menu_items[] = get_lang('ExamTracking');
103
+        $nb_menu_items = count($menu_items);
104
+        if($nb_menu_items>1) {
105
+            foreach($menu_items as $key=> $item) {
106
+                echo $item;
107
+                if($key!=$nb_menu_items-1) {
108
+                    echo ' | ';
109
+                }
110
+            }
111
+            echo '<br />';
112
+        }
113
+    } else {
114
+        echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
115 115
 		     <a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;|&nbsp';
116 116
         echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=resources">'.get_lang('ResourcesTracking').'</a>';
117
-		echo ' | '.get_lang('ExamTracking').'';
117
+        echo ' | '.get_lang('ExamTracking').'';
118 118
         echo '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'">
119 119
             '.Display::return_icon('excel.gif').'
120 120
             &nbsp;'.get_lang('ExportAsXLS').'</a><br /><br />';
121 121
 
122
-	}
122
+    }
123 123
     echo '</div>';
124
-	echo '<br /><br />';
125
-	$form->display();
124
+    echo '<br /><br />';
125
+    $form->display();
126 126
 }
127 127
 $main_result = array();
128 128
 $session_id = 0;
129 129
 $user_list = array();
130 130
 // Getting course list
131 131
 foreach ($course_list  as $current_course ) {
132
-	$course_info = api_get_course_info($current_course['code']);
133
-	$_course = $course_info;
134
-
135
-	// Getting LP list
136
-	$list = new LearnpathList('', $current_course['code'], $session_id);
137
-	$lp_list = $list->get_flat_list();
138
-
139
-	// Looping LPs
140
-	$lps = array();
141
-	foreach ($lp_list as $lp_id =>$lp) {
142
-		$exercise_list = Event::get_all_exercises_from_lp($lp_id, $course_info['real_id']);
143
-		$attempt_result = array();
144
-		// Looping Chamilo Exercises in LP
145
-		foreach ($exercise_list as $exercise) {
146
-			$exercise_stats = Event::get_all_exercise_event_from_lp(
147
-				$exercise['path'],
148
-				$course_info['real_id'],
149
-				$session_id
150
-			);
151
-			// Looping Exercise Attempts
152
-			foreach ($exercise_stats as $stats) {
153
-				$attempt_result[$exercise['id']]['users'][$stats['exe_user_id']][$stats['exe_id']] = $stats;
154
-				$user_list[$stats['exe_user_id']] = $stats['exe_user_id'];
155
-			}
156
-			$exercise_list_name[$exercise['id']] = $exercise['title'];
157
-		}
158
-		$lps[$lp_id] = array('lp_name' =>$lp['lp_name'], 'exercises' =>$attempt_result);
159
-		$lp_list_name[$lp_id] = $lp['lp_name'];
160
-	}
161
-	$main_result[$current_course['code']] = $lps;
132
+    $course_info = api_get_course_info($current_course['code']);
133
+    $_course = $course_info;
134
+
135
+    // Getting LP list
136
+    $list = new LearnpathList('', $current_course['code'], $session_id);
137
+    $lp_list = $list->get_flat_list();
138
+
139
+    // Looping LPs
140
+    $lps = array();
141
+    foreach ($lp_list as $lp_id =>$lp) {
142
+        $exercise_list = Event::get_all_exercises_from_lp($lp_id, $course_info['real_id']);
143
+        $attempt_result = array();
144
+        // Looping Chamilo Exercises in LP
145
+        foreach ($exercise_list as $exercise) {
146
+            $exercise_stats = Event::get_all_exercise_event_from_lp(
147
+                $exercise['path'],
148
+                $course_info['real_id'],
149
+                $session_id
150
+            );
151
+            // Looping Exercise Attempts
152
+            foreach ($exercise_stats as $stats) {
153
+                $attempt_result[$exercise['id']]['users'][$stats['exe_user_id']][$stats['exe_id']] = $stats;
154
+                $user_list[$stats['exe_user_id']] = $stats['exe_user_id'];
155
+            }
156
+            $exercise_list_name[$exercise['id']] = $exercise['title'];
157
+        }
158
+        $lps[$lp_id] = array('lp_name' =>$lp['lp_name'], 'exercises' =>$attempt_result);
159
+        $lp_list_name[$lp_id] = $lp['lp_name'];
160
+    }
161
+    $main_result[$current_course['code']] = $lps;
162 162
 }
163 163
 
164 164
 if (!empty($user_list)) {
165 165
     foreach($user_list as $user_id) {
166 166
         $user_data = api_get_user_info($user_id);
167
-		$user_list_name[$user_id] = api_get_person_name(
168
-			$user_data['firstname'],
169
-			$user_data['lastname']
170
-		);
167
+        $user_list_name[$user_id] = api_get_person_name(
168
+            $user_data['firstname'],
169
+            $user_data['lastname']
170
+        );
171 171
     }
172 172
 }
173 173
 $export_array =  array();
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
                         $html_result .= Display::tag('td', $result);
208 208
 
209 209
                         $html_result .= '</tr>';
210
-						$export_array[] = array(
211
-							$course_code,
212
-							$lp_list_name[$lp_id],
213
-							$exercise_list_name[$exercise_id],
214
-							$user_list_name[$user_id],
215
-							$attempt,
216
-							api_get_local_time($attempt_data['exe_date']),
217
-							$result,
218
-						);
210
+                        $export_array[] = array(
211
+                            $course_code,
212
+                            $lp_list_name[$lp_id],
213
+                            $exercise_list_name[$exercise_id],
214
+                            $user_list_name[$user_id],
215
+                            $attempt,
216
+                            api_get_local_time($attempt_data['exe_date']),
217
+                            $result,
218
+                        );
219 219
                         $attempt++;
220 220
                     }
221 221
                 }
@@ -226,30 +226,30 @@  discard block
 block discarded – undo
226 226
 }
227 227
 
228 228
 if (!$export_to_csv) {
229
-	echo $html_result;
229
+    echo $html_result;
230 230
 }
231 231
 $filename = 'learning_path_results-'.date('Y-m-d-h:i:s').'.xls';
232 232
 if ($export_to_csv) {
233 233
     export_complete_report_csv($filename, $export_array);
234
-	exit;
234
+    exit;
235 235
 }
236 236
 
237 237
 function export_complete_report_csv($filename, $array)
238 238
 {
239
-	$header[] = array(
240
-		get_lang('Course'),
241
-		get_lang('LearningPath'),
242
-		get_lang('Exercise'),
243
-		get_lang('User'),
244
-		get_lang('Attempt'),
245
-		get_lang('Date'),
246
-		get_lang('Results'),
247
-	);
248
-	if (!empty($array)) {
249
-		$array = array_merge($header, $array);
250
-		Export :: arrayToCsv($array, $filename);
251
-	}
252
-	exit;
239
+    $header[] = array(
240
+        get_lang('Course'),
241
+        get_lang('LearningPath'),
242
+        get_lang('Exercise'),
243
+        get_lang('User'),
244
+        get_lang('Attempt'),
245
+        get_lang('Date'),
246
+        get_lang('Results'),
247
+    );
248
+    if (!empty($array)) {
249
+        $array = array_merge($header, $array);
250
+        Export :: arrayToCsv($array, $filename);
251
+    }
252
+    exit;
253 253
 
254 254
 }
255 255
 Display :: display_footer();
Please login to merge, or discard this patch.