Completed
Pull Request — 1.11.x (#1318)
by José
66:27 queued 30:05
created
main/exercise/hotspot_updatescore.inc.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@
 block discarded – undo
20 20
 $exerciseId = $objExercise->selectId();
21 21
 if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
22 22
     $hit = 0;
23
-	$answerId = $hotspotId;
23
+    $answerId = $hotspotId;
24 24
 
25
-	// remove from session
26
-	unset($_SESSION['exerciseResult'][$questionId][$answerId]);
25
+    // remove from session
26
+    unset($_SESSION['exerciseResult'][$questionId][$answerId]);
27 27
 } else { // user clicked ON a hotspot
28
-	$hit = 1;
29
-	$answerId = $hotspotId;
28
+    $hit = 1;
29
+    $answerId = $hotspotId;
30 30
 
31
-	// Save into session
32
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
31
+    // Save into session
32
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
33 33
 }
34 34
 
35 35
 //round-up the coordinates
Please login to merge, or discard this patch.
main/user/add_users_to_session.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -49,29 +49,29 @@  discard block
 block discarded – undo
49 49
     $extra_field_list = UserManager::get_extra_fields();
50 50
     $new_field_list = array();
51 51
     if (is_array($extra_field_list)) {
52
-    	foreach ($extra_field_list as $extra_field) {
53
-    		//if is enabled to filter and is a "<select>" field type
54
-    		if ($extra_field[8]==1 && $extra_field[2]==4 ) {
52
+        foreach ($extra_field_list as $extra_field) {
53
+            //if is enabled to filter and is a "<select>" field type
54
+            if ($extra_field[8]==1 && $extra_field[2]==4 ) {
55 55
                 $new_field_list[] = array(
56 56
                     'name' => $extra_field[3],
57 57
                     'variable' => $extra_field[1],
58 58
                     'data' => $extra_field[9],
59 59
                 );
60
-    		}
61
-    	}
60
+            }
61
+        }
62 62
     }
63 63
 
64 64
     function search_users($needle, $type)
65 65
     {
66
-    	global $id_session;
66
+        global $id_session;
67 67
 
68 68
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
69 69
         $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
70 70
 
71
-    	$xajax_response = new xajaxResponse();
72
-    	$return = '';
71
+        $xajax_response = new xajaxResponse();
72
+        $return = '';
73 73
 
74
-    	if (!empty($needle) && !empty($type)) {
74
+        if (!empty($needle) && !empty($type)) {
75 75
 
76 76
             //normal behaviour
77 77
             if ($type == 'any_session' && $needle == 'false')  {
@@ -79,32 +79,32 @@  discard block
 block discarded – undo
79 79
                 $needle = '';
80 80
             }
81 81
 
82
-    		// xajax send utf8 datas... datas in db can be non-utf8 datas
83
-    		$charset = api_get_system_encoding();
84
-    		$needle = Database::escape_string($needle);
85
-    		$needle = api_convert_encoding($needle, $charset, 'utf-8');
82
+            // xajax send utf8 datas... datas in db can be non-utf8 datas
83
+            $charset = api_get_system_encoding();
84
+            $needle = Database::escape_string($needle);
85
+            $needle = api_convert_encoding($needle, $charset, 'utf-8');
86 86
 
87
-    		$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
88
-    		$cond_user_id = '';
87
+            $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
88
+            $cond_user_id = '';
89 89
 
90 90
             //Only for single & multiple
91 91
             if (in_array($type, array('single','multiple'))) {
92
-        		if (!empty($id_session)) {
93
-        		    $id_session = intval($id_session);
94
-        			// check id_user from session_rel_user table
95
-        			$sql = 'SELECT user_id FROM '.$tbl_session_rel_user.'
92
+                if (!empty($id_session)) {
93
+                    $id_session = intval($id_session);
94
+                    // check id_user from session_rel_user table
95
+                    $sql = 'SELECT user_id FROM '.$tbl_session_rel_user.'
96 96
         			        WHERE session_id ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
97
-        			$res = Database::query($sql);
98
-        			$user_ids = array();
99
-        			if (Database::num_rows($res) > 0) {
100
-        				while ($row = Database::fetch_row($res)) {
101
-        					$user_ids[] = (int)$row[0];
102
-        				}
103
-        			}
104
-        			if (count($user_ids) > 0) {
105
-        				$cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
106
-        			}
107
-        		}
97
+                    $res = Database::query($sql);
98
+                    $user_ids = array();
99
+                    if (Database::num_rows($res) > 0) {
100
+                        while ($row = Database::fetch_row($res)) {
101
+                            $user_ids[] = (int)$row[0];
102
+                        }
103
+                    }
104
+                    if (count($user_ids) > 0) {
105
+                        $cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
106
+                    }
107
+                }
108 108
             }
109 109
 
110 110
             switch ($type) {
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
                                 user.status <> 6 '.$cond_user_id.
137 137
                             $order_clause;
138 138
                     break;
139
-    		}
140
-    		if (api_is_multiple_url_enabled()) {
141
-    			$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
142
-    			$access_url_id = api_get_current_access_url_id();
143
-    			if ($access_url_id != -1) {
139
+            }
140
+            if (api_is_multiple_url_enabled()) {
141
+                $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
142
+                $access_url_id = api_get_current_access_url_id();
143
+                if ($access_url_id != -1) {
144 144
                     switch ($type) {
145 145
                         case 'single':
146 146
                             $sql = 'SELECT user.user_id, username, lastname, firstname
@@ -178,36 +178,36 @@  discard block
 block discarded – undo
178 178
                                         user.status<>6 '.$cond_user_id.
179 179
                             $order_clause;
180 180
                             break;
181
-    				}
182
-    			}
183
-    		}
181
+                    }
182
+                }
183
+            }
184 184
 
185
-    		$rs = Database::query($sql);
185
+            $rs = Database::query($sql);
186 186
             $i=0;
187
-    		if ($type == 'single') {
188
-    			while ($user = Database::fetch_array($rs)) {
189
-    	            $i++;
190
-    	            if ($i<=10) {
191
-                		$person_name = api_get_person_name($user['firstname'], $user['lastname']);
192
-    					$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
193
-    	            } else {
194
-    	            	$return .= '...<br />';
195
-    	            }
196
-    			}
197
-
198
-    			$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
199
-    		} else {
200
-    			$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
201
-    			while ($user = Database :: fetch_array($rs)) {
202
-    				$person_name = api_get_person_name($user['firstname'], $user['lastname']);
203
-    	            $return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
204
-    			}
205
-    			$return .= '</select>';
206
-    			$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
207
-    		}
208
-    	}
187
+            if ($type == 'single') {
188
+                while ($user = Database::fetch_array($rs)) {
189
+                    $i++;
190
+                    if ($i<=10) {
191
+                        $person_name = api_get_person_name($user['firstname'], $user['lastname']);
192
+                        $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
193
+                    } else {
194
+                        $return .= '...<br />';
195
+                    }
196
+                }
197
+
198
+                $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
199
+            } else {
200
+                $return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
201
+                while ($user = Database :: fetch_array($rs)) {
202
+                    $person_name = api_get_person_name($user['firstname'], $user['lastname']);
203
+                    $return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
204
+                }
205
+                $return .= '</select>';
206
+                $xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
207
+            }
208
+        }
209 209
 
210
-    	return $xajax_response;
210
+        return $xajax_response;
211 211
     }
212 212
 
213 213
     $xajax -> processRequests();
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 
348 348
         if ($use_extra_fields) {
349 349
             $final_result = array();
350
-           	if (count($extra_field_result)>1) {
351
-    	    for($i=0;$i<count($extra_field_result)-1;$i++) {
350
+                if (count($extra_field_result)>1) {
351
+            for($i=0;$i<count($extra_field_result)-1;$i++) {
352 352
                     if (is_array($extra_field_result[$i+1])) {
353 353
                         $final_result = array_intersect(
354 354
                             $extra_field_result[$i],
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
                     'un' => $user['username']
427 427
                 );
428 428
                 unset($users[$uid]);
429
-    	}
429
+        }
430 430
         }
431 431
         unset($users); //clean to free memory
432 432
 
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
     }
472 472
 
473 473
     if ($add_type === 'multiple') {
474
-    	$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
475
-    	$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
474
+        $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
475
+        $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
476 476
     } else {
477
-    	$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
478
-    	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
477
+        $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
478
+        $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
479 479
     }
480
-    	$link_add_group = '<a href="usergroups.php">'.
480
+        $link_add_group = '<a href="usergroups.php">'.
481 481
             Display::return_icon('multiple.gif', get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>';
482 482
     ?>
483 483
     <div class="actions">
@@ -487,30 +487,30 @@  discard block
 block discarded – undo
487 487
     <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
488 488
     <?php
489 489
     if ($add_type === 'multiple') {
490
-    	if (is_array($extra_field_list)) {
491
-    		if (is_array($new_field_list) && count($new_field_list)>0 ) {
492
-    			echo '<h3>'.get_lang('FilterUsers').'</h3>';
493
-    			foreach ($new_field_list as $new_field) {
494
-    				echo $new_field['name'];
495
-    				$varname = 'field_'.$new_field['variable'];
496
-    				echo '&nbsp;<select name="'.$varname.'">';
497
-    				echo '<option value="0">--'.get_lang('Select').'--</option>';
498
-    				foreach	($new_field['data'] as $option) {
499
-    					$checked='';
500
-    					if (isset($_POST[$varname])) {
501
-    						if ($_POST[$varname] == $option[1]) {
502
-    							$checked = 'selected="true"';
503
-    						}
504
-    					}
505
-    					echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
506
-    				}
507
-    				echo '</select>';
508
-    				echo '&nbsp;&nbsp;';
509
-    			}
510
-    			echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
511
-    			echo '<br /><br />';
512
-    		}
513
-    	}
490
+        if (is_array($extra_field_list)) {
491
+            if (is_array($new_field_list) && count($new_field_list)>0 ) {
492
+                echo '<h3>'.get_lang('FilterUsers').'</h3>';
493
+                foreach ($new_field_list as $new_field) {
494
+                    echo $new_field['name'];
495
+                    $varname = 'field_'.$new_field['variable'];
496
+                    echo '&nbsp;<select name="'.$varname.'">';
497
+                    echo '<option value="0">--'.get_lang('Select').'--</option>';
498
+                    foreach	($new_field['data'] as $option) {
499
+                        $checked='';
500
+                        if (isset($_POST[$varname])) {
501
+                            if ($_POST[$varname] == $option[1]) {
502
+                                $checked = 'selected="true"';
503
+                            }
504
+                        }
505
+                        echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
506
+                    }
507
+                    echo '</select>';
508
+                    echo '&nbsp;&nbsp;';
509
+                }
510
+                echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
511
+                echo '<br /><br />';
512
+            }
513
+        }
514 514
     }
515 515
     ?>
516 516
     <input type="hidden" name="form_sent" value="1" />
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                 <div id="content_source">
534 534
                 <?php
535 535
                 if (!($add_type == 'multiple')) {
536
-                  ?>
536
+                    ?>
537 537
                   <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
538 538
                   <div id="ajax_list_users_single"></div>
539 539
                   <?php
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
                 <div id="ajax_list_users_multiple">
543 543
                 <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="span5">
544 544
                   <?php
545
-                  foreach ($nosessionUsersList as $uid => $enreg) {
546
-                  ?>
545
+                    foreach ($nosessionUsersList as $uid => $enreg) {
546
+                    ?>
547 547
                       <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; ?></option>
548 548
                   <?php
549
-                  }
550
-                  ?>
549
+                    }
550
+                    ?>
551 551
                 </select>
552 552
                 </div>
553 553
                     <input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id">
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                 <?php
556 556
                 }
557 557
                 unset($nosessionUsersList);
558
-               ?>
558
+                ?>
559 559
             </div>
560 560
         </div>
561 561
 
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
             <br />
583 583
             <br />
584 584
     		<?php
585
-    		if (isset($_GET['add'])) {
586
-    			echo '<button class="btn btn-primary" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
585
+            if (isset($_GET['add'])) {
586
+                echo '<button class="btn btn-primary" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
587 587
             } else {
588 588
                 //@todo see that the call to "valide()" doesn't duplicate the onsubmit of the form (necessary to avoid delete on "enter" key pressed)
589
-    			echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>';
589
+                echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>';
590 590
             }
591
-    		?>
591
+            ?>
592 592
         </div>
593 593
         <div class="span5">
594 594
             <div class="multiple_select_header">
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php 1 patch
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class CourseSelectForm
19 19
 {
20
-	/**
21
-	 * Display the form
20
+    /**
21
+     * Display the form
22 22
      * @param array $course
23
-	 * @param array $hidden_fields Hidden fields to add to the form.
24
-	 * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
25
-	 */
26
-	public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
23
+     * @param array $hidden_fields Hidden fields to add to the form.
24
+     * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
25
+     */
26
+    public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
27 27
     {
28 28
         global $charset;
29 29
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
@@ -138,48 +138,48 @@  discard block
 block discarded – undo
138 138
             }
139 139
 		</script>
140 140
 		<?php
141
-		// get destination course title
142
-		if (!empty($hidden_fields['destination_course'])) {
141
+        // get destination course title
142
+        if (!empty($hidden_fields['destination_course'])) {
143 143
             $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null;
144 144
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
145
-			echo '<h3>';
146
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
147
-			echo '</h3>';
148
-		}
145
+            echo '<h3>';
146
+            echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
147
+            echo '</h3>';
148
+        }
149 149
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
150
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
150
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
151 151
         $icon = Display::returnIconPath('myprogress_bar.gif');
152 152
         echo '<div class="tool-backups-options">';
153
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
154
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
153
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
154
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
155 155
 
156
-		if (!empty($hidden_fields['destination_course']) &&
156
+        if (!empty($hidden_fields['destination_course']) &&
157 157
             !empty($hidden_fields['origin_course']) &&
158 158
             !empty($hidden_fields['destination_session']) &&
159 159
             !empty($hidden_fields['origin_session'])
160 160
         ) {
161
-			echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
162
-			echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
163
-			echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
164
-			echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
165
-		}
161
+            echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
162
+            echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
163
+            echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
164
+            echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
165
+        }
166 166
 
167
-		$element_count = 0;
167
+        $element_count = 0;
168 168
         $forum_categories = array();
169 169
         $forums = array();
170 170
         $forum_topics = array();
171 171
 
172 172
         echo '<p>';
173
-		echo get_lang('SelectResources');
174
-		echo '</p>';
173
+        echo get_lang('SelectResources');
174
+        echo '</p>';
175 175
 
176 176
         Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt'));
177 177
 
178 178
         foreach ($course->resources as $type => $resources) {
179 179
             if (count($resources) > 0) {
180
-				switch ($type) {
181
-					//Resources to avoid
182
-					case RESOURCE_FORUMCATEGORY:
180
+                switch ($type) {
181
+                    //Resources to avoid
182
+                    case RESOURCE_FORUMCATEGORY:
183 183
                         foreach ($resources as $id => $resource) {
184 184
                             $forum_categories[$id] = $resource;
185 185
                         }
@@ -206,30 +206,30 @@  discard block
 block discarded – undo
206 206
                         break;
207 207
                     default:
208 208
                         echo '<div class="item-backup" onclick="javascript:exp('."'$type'".');">';
209
-						echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
210
-						echo '<span class="title">'.$resource_titles[$type].'</span></div>';
211
-						echo '<div class="item-content" id="div_'.$type.'">';
212
-						if ($type == RESOURCE_LEARNPATH) {
213
-    						Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
214
-    						Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
215
-						}
216
-						if ($type == RESOURCE_DOCUMENT) {
209
+                        echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
210
+                        echo '<span class="title">'.$resource_titles[$type].'</span></div>';
211
+                        echo '<div class="item-content" id="div_'.$type.'">';
212
+                        if ($type == RESOURCE_LEARNPATH) {
213
+                            Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
214
+                            Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
215
+                        }
216
+                        if ($type == RESOURCE_DOCUMENT) {
217 217
                             if (api_get_setting('show_glossary_in_documents') != 'none') {
218 218
                                 Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
219 219
                             }
220
-						}
220
+                        }
221 221
 
222
-						echo '<div class="well">';
222
+                        echo '<div class="well">';
223 223
 
224 224
                         echo '<div class="btn-group">';
225
-						echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
225
+                        echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
226 226
                         echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>";
227
-						echo '</div>';
227
+                        echo '</div>';
228 228
                         echo '<ul class="list-backups-options">';
229
-						foreach ($resources as $id => $resource) {
229
+                        foreach ($resources as $id => $resource) {
230 230
                             if ($resource) {
231 231
                                 echo '<li>';
232
-								// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
232
+                                // Event obj in 1.9.x in 1.10.x the class is CalendarEvent
233 233
                                 Resource::setClassType($resource);
234 234
                                 echo '<label class="checkbox">';
235 235
                                 echo '<input type="checkbox" name="resource['.$type.']['.$id.']"  id="resource['.$type.']['.$id.']" />';
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
                                 echo '</label>';
238 238
                                 echo '</li>';
239 239
                             }
240
-						}
240
+                        }
241 241
                         echo '</ul>';
242
-						echo '</div>';
243
-						echo '</div>';
244
-						echo '<script language="javascript">exp('."'$type'".')</script>';
245
-						$element_count++;
242
+                        echo '</div>';
243
+                        echo '</div>';
244
+                        echo '<script language="javascript">exp('."'$type'".')</script>';
245
+                        $element_count++;
246 246
                 }
247
-			}
248
-		}
247
+            }
248
+        }
249 249
 
250 250
         //Fixes forum order
251 251
         if (!empty($forum_categories)) {
@@ -301,66 +301,66 @@  discard block
 block discarded – undo
301 301
             echo '<script language="javascript">exp('."'$type'".')</script>';
302 302
         }
303 303
 
304
-		if ($avoid_serialize) {
305
-			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
304
+        if ($avoid_serialize) {
305
+            /*Documents are avoided due the huge amount of memory that the serialize php function "eats"
306 306
 			(when there are directories with hundred/thousand of files) */
307
-			// this is a known issue of serialize
308
-			$course->resources['document']= null;
309
-		}
307
+            // this is a known issue of serialize
308
+            $course->resources['document']= null;
309
+        }
310 310
 
311
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
311
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
312 312
 
313
-		if (is_array($hidden_fields)) {
314
-			foreach ($hidden_fields as $key => $value) {
315
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
316
-			}
317
-		}
313
+        if (is_array($hidden_fields)) {
314
+            foreach ($hidden_fields as $key => $value) {
315
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
316
+            }
317
+        }
318 318
 
319 319
         $recycleOption = isset($_POST['recycle_option']) ? true : false;
320 320
 
321
-		if (empty($element_count)) {
322
-		    Display::display_warning_message(get_lang('NoDataAvailable'));
323
-		} else {
324
-    		if (!empty($hidden_fields['destination_session'])) {
325
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
321
+        if (empty($element_count)) {
322
+            Display::display_warning_message(get_lang('NoDataAvailable'));
323
+        } else {
324
+            if (!empty($hidden_fields['destination_session'])) {
325
+                echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
326 326
                     get_lang('Ok').'</button>';
327
-    		} else {
327
+            } else {
328 328
                 if ($recycleOption) {
329 329
                     echo '<br /><button class="save" type="submit">'.
330 330
                         get_lang('Ok').'</button>';
331 331
                 } else {
332
-    			    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
332
+                    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
333 333
                     get_lang('Ok').'</button>';
334 334
                 }
335
-    		}
336
-		}
335
+            }
336
+        }
337 337
 
338
-		CourseSelectForm::display_hidden_quiz_questions($course);
339
-		CourseSelectForm::display_hidden_scorm_directories($course);
340
-		echo '</form>';
338
+        CourseSelectForm::display_hidden_quiz_questions($course);
339
+        CourseSelectForm::display_hidden_scorm_directories($course);
340
+        echo '</form>';
341 341
         echo '</div>';
342
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
343
-	}
342
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
343
+    }
344 344
 
345 345
     /**
346 346
      * @param $course
347 347
      */
348 348
     public static function display_hidden_quiz_questions($course)
349 349
     {
350
-		if(is_array($course->resources)){
351
-			foreach ($course->resources as $type => $resources) {
352
-				if (count($resources) > 0) {
353
-					switch ($type) {
354
-						case RESOURCE_QUIZQUESTION:
355
-							foreach ($resources as $id => $resource) {
356
-								echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
357
-							}
358
-							break;
359
-					}
360
-				}
361
-			}
362
-		}
363
-	}
350
+        if(is_array($course->resources)){
351
+            foreach ($course->resources as $type => $resources) {
352
+                if (count($resources) > 0) {
353
+                    switch ($type) {
354
+                        case RESOURCE_QUIZQUESTION:
355
+                            foreach ($resources as $id => $resource) {
356
+                                echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
357
+                            }
358
+                            break;
359
+                    }
360
+                }
361
+            }
362
+        }
363
+    }
364 364
 
365 365
     /**
366 366
      * @param $course
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
     public static function display_hidden_scorm_directories($course)
369 369
     {
370 370
         if (is_array($course->resources)){
371
-			foreach ($course->resources as $type => $resources) {
372
-				if (count($resources) > 0) {
373
-					switch($type) {
374
-						case RESOURCE_SCORM:
375
-							foreach ($resources as $id => $resource) {
376
-								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
377
-							}
378
-							break;
379
-					}
380
-				}
381
-			}
382
-		}
383
-	}
371
+            foreach ($course->resources as $type => $resources) {
372
+                if (count($resources) > 0) {
373
+                    switch($type) {
374
+                        case RESOURCE_SCORM:
375
+                            foreach ($resources as $id => $resource) {
376
+                                echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
377
+                            }
378
+                            break;
379
+                    }
380
+                }
381
+            }
382
+        }
383
+    }
384 384
 
385
-	/**
386
-	 * Get the posted course
387
-	 * @param string $from who calls the function?
385
+    /**
386
+     * Get the posted course
387
+     * @param string $from who calls the function?
388 388
      * It can be copy_course, create_backup, import_backup or recycle_course
389 389
      * @param int $session_id
390 390
      * @param string $course_code
391
-	 * @return course The course-object with all resources selected by the user
392
-	 * in the form given by display_form(...)
393
-	 */
394
-	public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
391
+     * @return course The course-object with all resources selected by the user
392
+     * in the form given by display_form(...)
393
+     */
394
+    public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
395 395
     {
396 396
         $course = null;
397 397
 
@@ -401,30 +401,30 @@  discard block
 block discarded – undo
401 401
             return false;
402 402
         }
403 403
 
404
-		// Create the resource DOCUMENT objects
405
-		// Loading the results from the checkboxes of ethe javascript
406
-		$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
404
+        // Create the resource DOCUMENT objects
405
+        // Loading the results from the checkboxes of ethe javascript
406
+        $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
407 407
 
408
-		$course_info = api_get_course_info($course_code);
409
-		$table_doc = Database::get_course_table(TABLE_DOCUMENT);
410
-		$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
411
-		$course_id = $course_info['real_id'];
408
+        $course_info = api_get_course_info($course_code);
409
+        $table_doc = Database::get_course_table(TABLE_DOCUMENT);
410
+        $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
411
+        $course_id = $course_info['real_id'];
412 412
 
413
-		/* Searching the documents resource that have been set to null because
413
+        /* Searching the documents resource that have been set to null because
414 414
         $avoid_serialize is true in the display_form() function*/
415
-		if ($from === 'copy_course') {
416
-			if (is_array($resource)) {
417
-				$resource = array_keys($resource);
415
+        if ($from === 'copy_course') {
416
+            if (is_array($resource)) {
417
+                $resource = array_keys($resource);
418 418
 
419
-				foreach	($resource as $resource_item) {
419
+                foreach	($resource as $resource_item) {
420 420
 
421
-					$condition_session = '';
422
-					if (!empty($session_id)) {
423
-						$session_id = intval($session_id);
424
-						$condition_session = ' AND d.session_id ='.$session_id;
425
-					}
421
+                    $condition_session = '';
422
+                    if (!empty($session_id)) {
423
+                        $session_id = intval($session_id);
424
+                        $condition_session = ' AND d.session_id ='.$session_id;
425
+                    }
426 426
 
427
-					$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
427
+                    $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
428 428
 							FROM '.$table_doc.' d, '.$table_prop.' p
429 429
 							WHERE
430 430
 							    d.c_id = '.$course_id.' AND
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
                                 p.ref = d.id AND p.visibility != 2 AND
434 434
                                 d.id = '.$resource_item.$condition_session.'
435 435
 							ORDER BY path';
436
-					$db_result = Database::query($sql);
437
-					while ($obj = Database::fetch_object($db_result)) {
436
+                    $db_result = Database::query($sql);
437
+                    while ($obj = Database::fetch_object($db_result)) {
438 438
                         $doc = new Document(
439 439
                             $obj->id,
440 440
                             $obj->path,
@@ -458,25 +458,25 @@  discard block
 block discarded – undo
458 458
                             }
459 459
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
460 460
                         }
461
-					}
462
-				}
463
-			}
464
-		}
461
+                    }
462
+                }
463
+            }
464
+        }
465 465
 
466
-		if (is_array($course->resources)) {
467
-			foreach ($course->resources as $type => $resources) {
466
+        if (is_array($course->resources)) {
467
+            foreach ($course->resources as $type => $resources) {
468 468
 
469
-				switch ($type) {
470
-					case RESOURCE_SURVEYQUESTION:
471
-						foreach($resources as $id => $obj) {
472
-						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
469
+                switch ($type) {
470
+                    case RESOURCE_SURVEYQUESTION:
471
+                        foreach($resources as $id => $obj) {
472
+                            if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
473 473
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
474 474
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
475 475
                             ) {
476
-								unset($course->resources[$type][$id]);
477
-							}
478
-						}
479
-						break;
476
+                                unset($course->resources[$type][$id]);
477
+                            }
478
+                        }
479
+                        break;
480 480
                     case RESOURCE_FORUMTOPIC:
481 481
                     case RESOURCE_FORUMPOST:
482 482
                        //Add post from topic
@@ -528,63 +528,63 @@  discard block
 block discarded – undo
528 528
                                 }
529 529
                             }
530 530
                         }
531
-					case RESOURCE_LINKCATEGORY:
532
-					case RESOURCE_FORUMCATEGORY:
533
-					case RESOURCE_QUIZQUESTION:
534
-					case RESOURCE_DOCUMENT:
535
-						// Mark folders to import which are not selected by the user to import,
536
-						// but in which a document was selected.
537
-						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
538
-						if (!empty($resources) && is_array($resources))
539
-							foreach ($resources as $id => $obj) {
540
-								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
531
+                    case RESOURCE_LINKCATEGORY:
532
+                    case RESOURCE_FORUMCATEGORY:
533
+                    case RESOURCE_QUIZQUESTION:
534
+                    case RESOURCE_DOCUMENT:
535
+                        // Mark folders to import which are not selected by the user to import,
536
+                        // but in which a document was selected.
537
+                        $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
538
+                        if (!empty($resources) && is_array($resources))
539
+                            foreach ($resources as $id => $obj) {
540
+                                if (isset($obj->file_type) && $obj->file_type == 'folder' &&
541 541
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
542 542
                                     is_array($documents)
543 543
                                 ) {
544
-									foreach ($documents as $id_to_check => $post_value) {
545
-										$obj_to_check = $resources[$id_to_check];
546
-										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
547
-										if ($id_to_check != $id && $obj->path == $shared_path_part) {
548
-											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
549
-											break;
550
-										}
551
-									}
552
-								}
553
-							}
554
-					default :
555
-						if (!empty($resources) && is_array($resources)) {
556
-							foreach ($resources as $id => $obj) {
557
-								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
558
-								// check if document is in a quiz (audio/video)
559
-								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
560
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
544
+                                    foreach ($documents as $id_to_check => $post_value) {
545
+                                        $obj_to_check = $resources[$id_to_check];
546
+                                        $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
547
+                                        if ($id_to_check != $id && $obj->path == $shared_path_part) {
548
+                                            $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
549
+                                            break;
550
+                                        }
551
+                                    }
552
+                                }
553
+                            }
554
+                    default :
555
+                        if (!empty($resources) && is_array($resources)) {
556
+                            foreach ($resources as $id => $obj) {
557
+                                $resource_is_used_elsewhere = $course->is_linked_resource($obj);
558
+                                // check if document is in a quiz (audio/video)
559
+                                if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
560
+                                    foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
561 561
                                         $quiz = $quiz->obj;
562
-										if (isset($quiz->media) && $quiz->media == $id) {
563
-											$resource_is_used_elsewhere = true;
564
-										}
565
-									}
566
-								}
567
-								if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
568
-									unset($course->resources[$type][$id]);
569
-								}
570
-							}
571
-						}
572
-				}
573
-			}
574
-		}
562
+                                        if (isset($quiz->media) && $quiz->media == $id) {
563
+                                            $resource_is_used_elsewhere = true;
564
+                                        }
565
+                                    }
566
+                                }
567
+                                if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
568
+                                    unset($course->resources[$type][$id]);
569
+                                }
570
+                            }
571
+                        }
572
+                }
573
+            }
574
+        }
575 575
 
576
-		return $course;
577
-	}
576
+        return $course;
577
+    }
578 578
 
579
-	/**
580
-	 * Display the form session export
579
+    /**
580
+     * Display the form session export
581 581
      * @param array $list_course
582
-	 * @param array $hidden_fields Hidden fields to add to the form.
582
+     * @param array $hidden_fields Hidden fields to add to the form.
583 583
      * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
584
-	 */
585
-	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
586
-     {
587
-         ?>
584
+     */
585
+        public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
586
+        {
587
+            ?>
588 588
 		<script>
589 589
 			function exp(item) {
590 590
 				el = document.getElementById('div_'+item);
@@ -626,68 +626,68 @@  discard block
 block discarded – undo
626 626
 		</script>
627 627
 		<?php
628 628
 
629
-		//get destination course title
630
-		if(!empty($hidden_fields['destination_course'])) {
631
-             if (!empty($hidden_fields['destination_session'])) {
632
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
633
-             } else {
634
-                 $sessionTitle = null;
635
-             }
629
+        //get destination course title
630
+        if(!empty($hidden_fields['destination_course'])) {
631
+                if (!empty($hidden_fields['destination_session'])) {
632
+                    $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
633
+                } else {
634
+                    $sessionTitle = null;
635
+                }
636 636
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
637
-			echo '<h3>';
638
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
639
-			echo '</h3>';
640
-		}
637
+            echo '<h3>';
638
+                echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
639
+            echo '</h3>';
640
+        }
641 641
 
642
-		echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
643
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
642
+        echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
643
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
644 644
         $icon = Display::returnIconPath('progress_bar.gif');
645 645
         echo '<div class="tool-backups-options">';
646
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
647
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
648
-		foreach ($list_course as $course) {
649
-			foreach ($course->resources as $type => $resources) {
650
-				if (count($resources) > 0) {
646
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
647
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
648
+        foreach ($list_course as $course) {
649
+            foreach ($course->resources as $type => $resources) {
650
+                if (count($resources) > 0) {
651 651
                     echo '<div class="item-backup" onclick="javascript:exp('."'$course->code'".');">';
652
-					echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
653
-					echo '<span class="title"> '.$course->code.'</span></div>';
654
-					echo '<div class="item-content" id="div_'.$course->code.'">';
655
-					echo '<blockquote>';
652
+                    echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
653
+                    echo '<span class="title"> '.$course->code.'</span></div>';
654
+                    echo '<div class="item-content" id="div_'.$course->code.'">';
655
+                    echo '<blockquote>';
656 656
 
657 657
                     echo '<div class="btn-group">';
658
-					echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
658
+                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
659 659
                     echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>";
660
-					echo '</div>';
660
+                    echo '</div>';
661 661
 
662
-					foreach ($resources as $id => $resource) {
663
-						echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
662
+                    foreach ($resources as $id => $resource) {
663
+                        echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
664 664
                         echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
665
-						$resource->show();
666
-						echo '</label>';
667
-					}
668
-					echo '</blockquote>';
669
-					echo '</div>';
670
-					echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
671
-				}
672
-			}
673
-		}
674
-		if ($avoid_serialize) {
675
-			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
676
-			// this is a known issue of serialize
677
-			$course->resources['document']= null;
678
-		}
679
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
680
-		if (is_array($hidden_fields)) {
681
-			foreach ($hidden_fields as $key => $value) {
682
-				echo "\n";
683
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
684
-			}
685
-		}
686
-		echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
687
-		CourseSelectForm :: display_hidden_quiz_questions($course);
688
-		CourseSelectForm :: display_hidden_scorm_directories($course);
689
-		echo '</form>';
665
+                        $resource->show();
666
+                        echo '</label>';
667
+                    }
668
+                    echo '</blockquote>';
669
+                    echo '</div>';
670
+                    echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
671
+                }
672
+            }
673
+        }
674
+        if ($avoid_serialize) {
675
+            //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
676
+            // this is a known issue of serialize
677
+            $course->resources['document']= null;
678
+        }
679
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
680
+        if (is_array($hidden_fields)) {
681
+            foreach ($hidden_fields as $key => $value) {
682
+                echo "\n";
683
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
684
+            }
685
+        }
686
+        echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
687
+        CourseSelectForm :: display_hidden_quiz_questions($course);
688
+        CourseSelectForm :: display_hidden_scorm_directories($course);
689
+        echo '</form>';
690 690
         echo '</div>';
691
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
692
-	}
691
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
692
+    }
693 693
 }
Please login to merge, or discard this patch.
main/admin/skills_import.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $oskill = new Skill();
71 71
             $skill_id = $oskill->add($skill);
72 72
             $parents[$saved_id] = $skill_id;
73
-		}
73
+        }
74 74
     }
75 75
 }
76 76
 
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function parse_csv_data($file)
83 83
 {
84
-	$skills = Import :: csvToArray($file);
85
-	foreach ($skills as $index => $skill) {
86
-		$skills[$index] = $skill;
87
-	}
84
+    $skills = Import :: csvToArray($file);
85
+    foreach ($skills as $index => $skill) {
86
+        $skills[$index] = $skill;
87
+    }
88 88
 
89
-	return $skills;
89
+    return $skills;
90 90
 }
91 91
 
92 92
 /**
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
  */
95 95
 function element_start($parser, $data)
96 96
 {
97
-	$data = api_utf8_decode($data);
98
-	global $skill;
99
-	global $current_tag;
100
-	switch ($data) {
101
-		case 'Skill' :
102
-			$skill = array ();
103
-			break;
104
-		default :
105
-			$current_tag = $data;
106
-	}
97
+    $data = api_utf8_decode($data);
98
+    global $skill;
99
+    global $current_tag;
100
+    switch ($data) {
101
+        case 'Skill' :
102
+            $skill = array ();
103
+            break;
104
+        default :
105
+            $current_tag = $data;
106
+    }
107 107
 }
108 108
 
109 109
 /**
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function element_end($parser, $data)
113 113
 {
114
-	$data = api_utf8_decode($data);
115
-	global $skill;
116
-	global $skills;
117
-	global $current_value;
118
-	switch ($data) {
119
-		case 'Skill' :
120
-			$skills[] = $skill;
121
-			break;
122
-		default :
123
-			$skill[$data] = $current_value;
124
-			break;
125
-	}
114
+    $data = api_utf8_decode($data);
115
+    global $skill;
116
+    global $skills;
117
+    global $current_value;
118
+    switch ($data) {
119
+        case 'Skill' :
120
+            $skills[] = $skill;
121
+            break;
122
+        default :
123
+            $skill[$data] = $current_value;
124
+            break;
125
+    }
126 126
 }
127 127
 
128 128
 /**
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
  */
131 131
 function character_data($parser, $data)
132 132
 {
133
-	$data = trim(api_utf8_decode($data));
134
-	global $current_value;
135
-	$current_value = $data;
133
+    $data = trim(api_utf8_decode($data));
134
+    global $current_value;
135
+    $current_value = $data;
136 136
 }
137 137
 
138 138
 /**
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
  */
143 143
 function parse_xml_data($file)
144 144
 {
145
-	global $current_tag;
146
-	global $current_value;
147
-	global $skill;
148
-	global $skills;
149
-	$skills = array();
150
-	$parser = xml_parser_create('UTF-8');
151
-	xml_set_element_handler($parser, 'element_start', 'element_end');
152
-	xml_set_character_data_handler($parser, 'character_data');
153
-	xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
154
-	xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
155
-	xml_parser_free($parser);
145
+    global $current_tag;
146
+    global $current_value;
147
+    global $skill;
148
+    global $skills;
149
+    $skills = array();
150
+    $parser = xml_parser_create('UTF-8');
151
+    xml_set_element_handler($parser, 'element_start', 'element_end');
152
+    xml_set_character_data_handler($parser, 'character_data');
153
+    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
154
+    xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
155
+    xml_parser_free($parser);
156 156
 
157
-	return $skills;
157
+    return $skills;
158 158
 }
159 159
 
160 160
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -169,73 +169,73 @@  discard block
 block discarded – undo
169 169
 $error_message = '';
170 170
 
171 171
 if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) {
172
-	$file_type = $_POST['file_type'];
173
-	Security::clear_token();
174
-	$tok = Security::get_token();
175
-	$allowed_file_mimetype = array('csv','xml');
176
-	$error_kind_file = false;
172
+    $file_type = $_POST['file_type'];
173
+    Security::clear_token();
174
+    $tok = Security::get_token();
175
+    $allowed_file_mimetype = array('csv','xml');
176
+    $error_kind_file = false;
177 177
     $error_message = '';
178 178
 
179
-	$ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'],'.')+1));
179
+    $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'],'.')+1));
180 180
 
181
-	if (in_array($ext_import_file,$allowed_file_mimetype)) {
182
-		if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) {
183
-			$skills	= parse_csv_data($_FILES['import_file']['tmp_name']);
184
-			$errors = validate_data($skills);
185
-			$error_kind_file = false;
186
-		} elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) {
187
-			$skills = parse_xml_data($_FILES['import_file']['tmp_name']);
188
-			$errors = validate_data($skills);
189
-			$error_kind_file = false;
190
-		} else {
191
-			$error_kind_file = true;
192
-		}
193
-	} else {
194
-		$error_kind_file = true;
195
-	}
181
+    if (in_array($ext_import_file,$allowed_file_mimetype)) {
182
+        if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) {
183
+            $skills	= parse_csv_data($_FILES['import_file']['tmp_name']);
184
+            $errors = validate_data($skills);
185
+            $error_kind_file = false;
186
+        } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) {
187
+            $skills = parse_xml_data($_FILES['import_file']['tmp_name']);
188
+            $errors = validate_data($skills);
189
+            $error_kind_file = false;
190
+        } else {
191
+            $error_kind_file = true;
192
+        }
193
+    } else {
194
+        $error_kind_file = true;
195
+    }
196 196
 
197
-	// List skill id with error.
198
-	$skills_to_insert = $skill_id_error = array();
199
-	if (is_array($errors)) {
200
-		foreach ($errors as $my_errors) {
201
-			$skill_id_error[] = $my_errors['SkillName'];
202
-		}
203
-	}
204
-	if (is_array($skills)) {
205
-		foreach ($skills as $my_skill) {
206
-			if (isset($my_skill['name']) && !in_array($my_skill['name'], $skill_id_error)) {
207
-				$skills_to_insert[] = $my_skill;
208
-			}
209
-		}
210
-	}
197
+    // List skill id with error.
198
+    $skills_to_insert = $skill_id_error = array();
199
+    if (is_array($errors)) {
200
+        foreach ($errors as $my_errors) {
201
+            $skill_id_error[] = $my_errors['SkillName'];
202
+        }
203
+    }
204
+    if (is_array($skills)) {
205
+        foreach ($skills as $my_skill) {
206
+            if (isset($my_skill['name']) && !in_array($my_skill['name'], $skill_id_error)) {
207
+                $skills_to_insert[] = $my_skill;
208
+            }
209
+        }
210
+    }
211 211
 
212
-	if (strcmp($file_type, 'csv') === 0) {
213
-		save_data($skills_to_insert);
214
-	} elseif (strcmp($file_type, 'xml') === 0) {
215
-		save_data($skills_to_insert);
216
-	} else {
217
-		$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
218
-	}
212
+    if (strcmp($file_type, 'csv') === 0) {
213
+        save_data($skills_to_insert);
214
+    } elseif (strcmp($file_type, 'xml') === 0) {
215
+        save_data($skills_to_insert);
216
+    } else {
217
+        $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
218
+    }
219 219
 
220
-	if (count($errors) > 0) {
221
-		$see_message_import = get_lang('FileImportedJustSkillsThatAreNotRegistered');
222
-	} else {
223
-		$see_message_import = get_lang('FileImported');
224
-	}
220
+    if (count($errors) > 0) {
221
+        $see_message_import = get_lang('FileImportedJustSkillsThatAreNotRegistered');
222
+    } else {
223
+        $see_message_import = get_lang('FileImported');
224
+    }
225 225
 
226
-	if (count($errors) != 0) {
227
-		$warning_message = '<ul>';
228
-		foreach ($errors as $index => $error_skill) {
229
-			$warning_message .= '<li><b>'.$error_skill['error'].'</b>: ';
230
-			$warning_message .= '<strong>'.$error_skill['SkillName'].'</strong>&nbsp;('.$error_skill['SkillName'].')';
231
-			$warning_message .= '</li>';
232
-		}
233
-		$warning_message .= '</ul>';
234
-	}
226
+    if (count($errors) != 0) {
227
+        $warning_message = '<ul>';
228
+        foreach ($errors as $index => $error_skill) {
229
+            $warning_message .= '<li><b>'.$error_skill['error'].'</b>: ';
230
+            $warning_message .= '<strong>'.$error_skill['SkillName'].'</strong>&nbsp;('.$error_skill['SkillName'].')';
231
+            $warning_message .= '</li>';
232
+        }
233
+        $warning_message .= '</ul>';
234
+    }
235 235
 
236 236
     if ($error_kind_file) {
237
-		$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
238
-	}
237
+        $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
238
+    }
239 239
 }
240 240
 
241 241
 $interbreadcrumb[] = array ("url" => 'skill_list.php', "name" => get_lang('ManageSkills'));
@@ -243,34 +243,34 @@  discard block
 block discarded – undo
243 243
 Display :: display_header($tool_name);
244 244
 
245 245
 if (!empty($error_message)) {
246
-	Display::display_error_message($error_message);
246
+    Display::display_error_message($error_message);
247 247
 }
248 248
 if (!empty($see_message_import)) {
249
-	Display::display_normal_message($see_message_import);
249
+    Display::display_normal_message($see_message_import);
250 250
 }
251 251
 
252 252
 $toolbar = Display::toolbarButton(
253
-	get_lang('ManageSkills'),
254
-	api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php',
255
-	'list',
256
-	'success',
257
-	['title' => get_lang('CreateSkill')]
253
+    get_lang('ManageSkills'),
254
+    api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php',
255
+    'list',
256
+    'success',
257
+    ['title' => get_lang('CreateSkill')]
258 258
 );
259 259
 $toolbar .= '&nbsp;&nbsp;';
260 260
 $toolbar .= Display::toolbarButton(
261
-	get_lang('SkillsWheel'),
262
-	api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php',
263
-	'bullseye',
264
-	'primary',
265
-	['title' => get_lang('CreateSkill')]
261
+    get_lang('SkillsWheel'),
262
+    api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php',
263
+    'bullseye',
264
+    'primary',
265
+    ['title' => get_lang('CreateSkill')]
266 266
 );
267 267
 $toolbar .= '&nbsp;&nbsp;';
268 268
 $toolbar .= Display::toolbarButton(
269
-	get_lang('BadgesManagement'),
270
-	api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php',
271
-	'shield',
272
-	'warning',
273
-	['title' => get_lang('BadgesManagement')]
269
+    get_lang('BadgesManagement'),
270
+    api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php',
271
+    'shield',
272
+    'warning',
273
+    ['title' => get_lang('BadgesManagement')]
274 274
 );
275 275
 $toolbar .= '<br /><br />';
276 276
 
@@ -296,16 +296,16 @@  discard block
 block discarded – undo
296 296
 $i = 0;
297 297
 $count_fields = count($extra_fields);
298 298
 if ($count_fields > 0) {
299
-	foreach ($extra_fields as $extra) {
300
-		$list[] = $extra[1];
301
-		$list_reponse[] = 'xxx';
302
-		$spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
303
-		$result_xml .= $spaces.'&lt;'.$extra[1].'&gt;xxx&lt;/'.$extra[1].'&gt;';
304
-		if ($i != $count_fields - 1) {
305
-			$result_xml .= '<br/>';
306
-		}
307
-		$i++;
308
-	}
299
+    foreach ($extra_fields as $extra) {
300
+        $list[] = $extra[1];
301
+        $list_reponse[] = 'xxx';
302
+        $spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
303
+        $result_xml .= $spaces.'&lt;'.$extra[1].'&gt;xxx&lt;/'.$extra[1].'&gt;';
304
+        if ($i != $count_fields - 1) {
305
+            $result_xml .= '<br/>';
306
+        }
307
+        $i++;
308
+    }
309 309
 }
310 310
 ?>
311 311
 <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
Please login to merge, or discard this patch.
main/session/add_users_to_session.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 $add_type = 'unique';
39 39
 
40 40
 if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
41
-	$add_type = Security::remove_XSS($_REQUEST['add_type']);
41
+    $add_type = Security::remove_XSS($_REQUEST['add_type']);
42 42
 }
43 43
 
44 44
 $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null;
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 
427 427
     if ($use_extra_fields) {
428 428
         $final_result = array();
429
-       	if (count($extra_field_result)>1) {
430
-	    for($i=0;$i<count($extra_field_result)-1;$i++) {
429
+            if (count($extra_field_result)>1) {
430
+        for($i=0;$i<count($extra_field_result)-1;$i++) {
431 431
                 if (is_array($extra_field_result[$i+1])) {
432 432
                     $final_result  = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]);
433 433
                 }
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                 'official_code' => $user['official_code']
504 504
             ) ;
505 505
             unset($users[$uid]);
506
-	}
506
+    }
507 507
     }
508 508
     unset($users); //clean to free memory
509 509
 
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
 }
548 548
 
549 549
 if ($add_type == 'multiple') {
550
-	$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.
550
+    $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.
551 551
         Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
552
-	$link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), '');
552
+    $link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), '');
553 553
 } else {
554
-	$link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), '');
555
-	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
554
+    $link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), '');
555
+    $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
556 556
 }
557 557
 $link_add_group = Display::url(
558 558
     Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups'),
@@ -580,17 +580,17 @@  discard block
 block discarded – undo
580 580
 <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
581 581
 <?php
582 582
 if ($add_type=='multiple') {
583
-	if (is_array($extra_field_list)) {
584
-		if (is_array($new_field_list) && count($new_field_list)>0 ) {
585
-			echo '<h3>'.get_lang('FilterUsers').'</h3>';
586
-			foreach ($new_field_list as $new_field) {
587
-				echo $new_field['name'];
588
-				$varname = 'field_'.$new_field['variable'];
583
+    if (is_array($extra_field_list)) {
584
+        if (is_array($new_field_list) && count($new_field_list)>0 ) {
585
+            echo '<h3>'.get_lang('FilterUsers').'</h3>';
586
+            foreach ($new_field_list as $new_field) {
587
+                echo $new_field['name'];
588
+                $varname = 'field_'.$new_field['variable'];
589 589
                 $fieldtype = $new_field['type'];
590
-				echo '&nbsp;<select name="'.$varname.'">';
591
-				echo '<option value="0">--'.get_lang('Select').'--</option>';
592
-				foreach	($new_field['data'] as $option) {
593
-					$checked='';
590
+                echo '&nbsp;<select name="'.$varname.'">';
591
+                echo '<option value="0">--'.get_lang('Select').'--</option>';
592
+                foreach	($new_field['data'] as $option) {
593
+                    $checked='';
594 594
                     if ($fieldtype == ExtraField::FIELD_TYPE_TAG) {
595 595
                         if (isset($_POST[$varname])) {
596 596
                             if ($_POST[$varname] == $option['tag']) {
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
                 $extraHidden = $fieldtype == ExtraField::FIELD_TYPE_TAG ? '<input type="hidden" name="field_id" value="'.$option['field_id'].'" />' : '';
612 612
                 echo $extraHidden;
613 613
                 echo '&nbsp;&nbsp;';
614
-			}
615
-			echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
616
-			echo '<br /><br />';
617
-		}
618
-	}
614
+            }
615
+            echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
616
+            echo '<br /><br />';
617
+        }
618
+    }
619 619
 }
620 620
 ?>
621 621
 <input type="hidden" name="form_sent" value="1" />
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 
624 624
 <?php
625 625
 if (!empty($errorMsg)) {
626
-	Display::display_normal_message($errorMsg); //main API
626
+    Display::display_normal_message($errorMsg); //main API
627 627
 }
628 628
 ?>
629 629
 <div id="multiple-add-session" class="row">
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             <label><?php echo get_lang('UserListInPlatform') ?> </label>
633 633
             <?php
634 634
             if (!($add_type=='multiple')) {
635
-              ?>
635
+                ?>
636 636
               <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" class="form-control" />
637 637
               <div id="ajax_list_users_single" class="select-list-ajax"></div>
638 638
               <?php
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
             <div id="ajax_list_users_multiple">
642 642
             <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="form-control">
643 643
               <?php
644
-              foreach ($nosessionUsersList as $uid => $enreg) {
645
-              ?>
644
+                foreach ($nosessionUsersList as $uid => $enreg) {
645
+                ?>
646 646
                   <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>>
647 647
                       <?php
648
-                      $personName = api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code'];
649
-                      if ($showOfficialCode) {
650
-                          $officialCode = !empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - ';
651
-                          $personName = $officialCode.api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')';
652
-                      }
653
-                      echo $personName;
654
-                      ?>
648
+                        $personName = api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code'];
649
+                        if ($showOfficialCode) {
650
+                            $officialCode = !empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - ';
651
+                            $personName = $officialCode.api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')';
652
+                        }
653
+                        echo $personName;
654
+                        ?>
655 655
                   </option>
656 656
               <?php
657
-              }
658
-              ?>
657
+                }
658
+                ?>
659 659
             </select>
660 660
             </div>
661 661
                 <input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id">
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
             <?php
664 664
             }
665 665
             unset($nosessionUsersList);
666
-           ?>
666
+            ?>
667 667
         </div>
668 668
     </div>
669 669
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
               <?php
708 708
             }
709 709
             if (!empty($addProcess)) {
710
-		echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
710
+        echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
711 711
             } else {
712 712
                 echo '<button class="btn btn-success" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>';
713 713
             }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php 1 patch
Indentation   +586 added lines, -586 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class CourseRestorer
23 23
 {
24
-	/**
25
-	 * The course-object
26
-	 */
24
+    /**
25
+     * The course-object
26
+     */
27 27
     public $course;
28 28
     public $destination_course_info;
29 29
 
30
-	/**
31
-	 * What to do with files with same name (FILE_SKIP, FILE_RENAME or
32
-	 * FILE_OVERWRITE)
33
-	 */
30
+    /**
31
+     * What to do with files with same name (FILE_SKIP, FILE_RENAME or
32
+     * FILE_OVERWRITE)
33
+     */
34 34
     public $file_option;
35 35
     public $set_tools_invisible_by_default;
36 36
     public $skip_content;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         'events',
43 43
         'forum_category',
44 44
         'forums',
45
-       // 'forum_topics',
45
+        // 'forum_topics',
46 46
         'glossary',
47 47
         'quizzes',
48 48
         'test_category',
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
         $this->tool_copy_settings = $array;
111 111
     }
112 112
 
113
-	/**
114
-	 * Restore a course.
113
+    /**
114
+     * Restore a course.
115 115
      *
116
-	 * @param string    $destination_course_code code of the Chamilo-course in
117
-	 * @param int	    $session_id
118
-	 * @param bool	    $update_course_settings Course settings are going to be restore?
116
+     * @param string    $destination_course_code code of the Chamilo-course in
117
+     * @param int	    $session_id
118
+     * @param bool	    $update_course_settings Course settings are going to be restore?
119 119
      * @param bool      $respect_base_content
120 120
      * @return false|null
121
-	 */
121
+     */
122 122
     public function restore(
123 123
         $destination_course_code = '',
124 124
         $session_id = 0,
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
         }
262 262
     }
263 263
 
264
-	/**
265
-	 * Restore only harmless course settings:
264
+    /**
265
+     * Restore only harmless course settings:
266 266
      * course_language, visibility, department_name,department_url,
267 267
      * subscribe, unsubscribe ,category_code
268
-	 *
269
-	 * @param string $destination_course_code
270
-	 */
268
+     *
269
+     * @param string $destination_course_code
270
+     */
271 271
     public function restore_course_settings($destination_course_code)
272 272
     {
273
-	    $origin_course_info = api_get_course_info($destination_course_code);
274
-	    $course_info = $this->course->info;
273
+        $origin_course_info = api_get_course_info($destination_course_code);
274
+        $course_info = $this->course->info;
275 275
         $params['course_language'] = $course_info['language'];
276 276
         $params['visibility'] = $course_info['visibility'];
277 277
         $params['department_name'] = $course_info['department_name'];
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
         $params['category_code'] = $course_info['categoryCode'];
281 281
         $params['subscribe'] = $course_info['subscribe_allowed'];
282 282
         $params['unsubscribe'] = $course_info['unsubscribe'];
283
-	    CourseManager::update_attributes($origin_course_info['real_id'], $params);
284
-	}
283
+        CourseManager::update_attributes($origin_course_info['real_id'], $params);
284
+    }
285 285
 
286 286
     /**
287 287
      * Restore documents
@@ -925,56 +925,56 @@  discard block
 block discarded – undo
925 925
         unset($_SESSION['new_base_foldername']);
926 926
         unset($_SESSION['orig_base_foldername']);
927 927
         unset($_SESSION['new_base_path']);
928
-	}
928
+    }
929 929
 
930
-	/**
931
-	 * Restore scorm documents
932
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
930
+    /**
931
+     * Restore scorm documents
932
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
933 933
      * see #7029
934
-	 */
935
-	public function restore_scorm_documents()
934
+     */
935
+    public function restore_scorm_documents()
936 936
     {
937
-		$perm = api_get_permissions_for_new_directories();
937
+        $perm = api_get_permissions_for_new_directories();
938 938
 
939
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
940
-			$resources = $this->course->resources;
939
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
940
+            $resources = $this->course->resources;
941 941
 
942
-			foreach ($resources[RESOURCE_SCORM] as $document) {
943
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
944
-				@mkdir(dirname($path.$document->path), $perm, true);
942
+            foreach ($resources[RESOURCE_SCORM] as $document) {
943
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
944
+                @mkdir(dirname($path.$document->path), $perm, true);
945 945
 
946
-				if (file_exists($path.$document->path)) {
947
-					switch ($this->file_option) {
948
-						case FILE_OVERWRITE:
949
-							rmdirr($path.$document->path);
946
+                if (file_exists($path.$document->path)) {
947
+                    switch ($this->file_option) {
948
+                        case FILE_OVERWRITE:
949
+                            rmdirr($path.$document->path);
950 950
                             copyDirTo(
951 951
                                 $this->course->backup_path . '/' . $document->path,
952 952
                                 $path . dirname($document->path),
953 953
                                 false
954 954
                             );
955
-							break;
956
-						case FILE_SKIP:
957
-							break;
955
+                            break;
956
+                        case FILE_SKIP:
957
+                            break;
958 958
                         case FILE_RENAME:
959
-							$i = 1;
960
-							$ext = explode('.', basename($document->path));
961
-							if (count($ext) > 1) {
962
-								$ext = array_pop($ext);
963
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
964
-								$ext = '.'.$ext;
965
-							} else {
966
-								$ext = '';
967
-								$file_name_no_ext = $document->path;
968
-							}
969
-
970
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
971
-							$file_exists = file_exists($path.$new_file_name);
972
-
973
-							while ($file_exists) {
974
-								$i ++;
975
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
976
-								$file_exists = file_exists($path.$new_file_name);
977
-							}
959
+                            $i = 1;
960
+                            $ext = explode('.', basename($document->path));
961
+                            if (count($ext) > 1) {
962
+                                $ext = array_pop($ext);
963
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
964
+                                $ext = '.'.$ext;
965
+                            } else {
966
+                                $ext = '';
967
+                                $file_name_no_ext = $document->path;
968
+                            }
969
+
970
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
971
+                            $file_exists = file_exists($path.$new_file_name);
972
+
973
+                            while ($file_exists) {
974
+                                $i ++;
975
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
976
+                                $file_exists = file_exists($path.$new_file_name);
977
+                            }
978 978
 
979 979
                             rename(
980 980
                                 $this->course->backup_path . '/' . $document->path,
@@ -990,30 +990,30 @@  discard block
 block discarded – undo
990 990
                                 $this->course->backup_path . '/' . $document->path
991 991
                             );
992 992
 
993
-							break;
994
-					} // end switch
995
-				} else {
993
+                            break;
994
+                    } // end switch
995
+                } else {
996 996
                     // end if file exists
997 997
                     copyDirTo(
998 998
                         $this->course->backup_path . '/' . $document->path,
999 999
                         $path . dirname($document->path),
1000 1000
                         false
1001 1001
                     );
1002
-				}
1003
-			} // end for each
1004
-		}
1005
-	}
1006
-
1007
-	/**
1008
-	 * Restore forums
1009
-	 */
1010
-	public function restore_forums($sessionId = 0)
1002
+                }
1003
+            } // end for each
1004
+        }
1005
+    }
1006
+
1007
+    /**
1008
+     * Restore forums
1009
+     */
1010
+    public function restore_forums($sessionId = 0)
1011 1011
     {
1012
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
1012
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
1013 1013
             $sessionId = intval($sessionId);
1014
-			$table_forum = Database::get_course_table(TABLE_FORUM);
1015
-			$resources = $this->course->resources;
1016
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1014
+            $table_forum = Database::get_course_table(TABLE_FORUM);
1015
+            $resources = $this->course->resources;
1016
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1017 1017
                 $params = (array)$forum->obj;
1018 1018
                 $cat_id = '';
1019 1019
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1060,33 +1060,33 @@  discard block
 block discarded – undo
1060 1060
                     Database::query($sql);
1061 1061
                 }
1062 1062
 
1063
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1064
-
1065
-				$forum_topics = 0;
1066
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1067
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1068
-						if ($topic->obj->forum_id == $id) {
1069
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1070
-							$forum_topics ++;
1071
-						}
1072
-					}
1073
-				}
1074
-				if ($forum_topics > 0) {
1075
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1063
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1064
+
1065
+                $forum_topics = 0;
1066
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1067
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1068
+                        if ($topic->obj->forum_id == $id) {
1069
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1070
+                            $forum_topics ++;
1071
+                        }
1072
+                    }
1073
+                }
1074
+                if ($forum_topics > 0) {
1075
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1076 1076
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1077
-					Database::query($sql);
1078
-				}
1079
-			}
1080
-		}
1081
-	}
1082
-
1083
-	/**
1084
-	 * Restore forum-categories
1085
-	 */
1077
+                    Database::query($sql);
1078
+                }
1079
+            }
1080
+        }
1081
+    }
1082
+
1083
+    /**
1084
+     * Restore forum-categories
1085
+     */
1086 1086
     public function restore_forum_category($my_id = null, $sessionId = 0)
1087 1087
     {
1088
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1089
-		$resources = $this->course->resources;
1088
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1089
+        $resources = $this->course->resources;
1090 1090
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1091 1091
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1092 1092
                 if (!empty($my_id)) {
@@ -1123,16 +1123,16 @@  discard block
 block discarded – undo
1123 1123
                 }
1124 1124
             }
1125 1125
         }
1126
-	}
1126
+    }
1127 1127
 
1128
-	/**
1129
-	 * Restore a forum-topic
1130
-	 * @param false|string $forum_id
1131
-	 */
1128
+    /**
1129
+     * Restore a forum-topic
1130
+     * @param false|string $forum_id
1131
+     */
1132 1132
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1133 1133
     {
1134
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1135
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1134
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1135
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1136 1136
 
1137 1137
         $params = (array)$topic->obj;
1138 1138
         $params = self::DBUTF8_array($params);
@@ -1169,27 +1169,27 @@  discard block
 block discarded – undo
1169 1169
             $sessionId
1170 1170
         );
1171 1171
 
1172
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1173
-		$topic_replies = -1;
1174
-
1175
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1176
-			if ($post->obj->thread_id == $thread_id) {
1177
-				$topic_replies++;
1178
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1179
-			}
1180
-		}
1181
-		return $new_id;
1182
-	}
1183
-
1184
-	/**
1185
-	 * Restore a forum-post
1186
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1187
-	 * @param false|string $topic_id
1188
-	 */
1172
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1173
+        $topic_replies = -1;
1174
+
1175
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1176
+            if ($post->obj->thread_id == $thread_id) {
1177
+                $topic_replies++;
1178
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1179
+            }
1180
+        }
1181
+        return $new_id;
1182
+    }
1183
+
1184
+    /**
1185
+     * Restore a forum-post
1186
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1187
+     * @param false|string $topic_id
1188
+     */
1189 1189
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1190 1190
     {
1191
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1192
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1191
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1192
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1193 1193
         $params = (array) $post->obj;
1194 1194
         $params['c_id'] = $this->destination_course_id;
1195 1195
         $params['forum_id'] = $forum_id;
@@ -1224,37 +1224,37 @@  discard block
 block discarded – undo
1224 1224
             null,
1225 1225
             $sessionId
1226 1226
         );
1227
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1227
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1228 1228
 
1229
-		return $new_id;
1230
-	}
1229
+        return $new_id;
1230
+    }
1231 1231
 
1232
-	/**
1233
-	 * Restore links
1234
-	 */
1232
+    /**
1233
+     * Restore links
1234
+     */
1235 1235
     public function restore_links($session_id = 0)
1236 1236
     {
1237
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1238
-			$link_table = Database :: get_course_table(TABLE_LINK);
1239
-			$resources = $this->course->resources;
1237
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1238
+            $link_table = Database :: get_course_table(TABLE_LINK);
1239
+            $resources = $this->course->resources;
1240 1240
 
1241
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1241
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1242 1242
                 $cat_id = $this->restore_link_category(
1243 1243
                     $link->category_id,
1244 1244
                     $session_id
1245 1245
                 );
1246
-				$sql = "SELECT MAX(display_order)
1246
+                $sql = "SELECT MAX(display_order)
1247 1247
 				        FROM $link_table
1248 1248
 				        WHERE
1249 1249
 				            c_id = ".$this->destination_course_id." AND
1250 1250
 				            category_id='" . intval($cat_id). "'";
1251
-				$result = Database::query($sql);
1252
-    			list($max_order) = Database::fetch_array($result);
1251
+                $result = Database::query($sql);
1252
+                list($max_order) = Database::fetch_array($result);
1253 1253
 
1254 1254
                 $params = [];
1255
-    			if (!empty($session_id)) {
1255
+                if (!empty($session_id)) {
1256 1256
                     $params['session_id'] = $session_id;
1257
-    			}
1257
+                }
1258 1258
 
1259 1259
                 $params['c_id'] = $this->destination_course_id;
1260 1260
                 $params['url'] = self::DBUTF8($link->url);
@@ -1283,9 +1283,9 @@  discard block
 block discarded – undo
1283 1283
                     }
1284 1284
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1285 1285
                 }
1286
-			}
1287
-		}
1288
-	}
1286
+            }
1287
+        }
1288
+    }
1289 1289
 
1290 1290
     /**
1291 1291
      * Restore a link-category
@@ -1329,21 +1329,21 @@  discard block
 block discarded – undo
1329 1329
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1330 1330
     }
1331 1331
 
1332
-	/**
1333
-	 * Restore tool intro
1334
-	 */
1332
+    /**
1333
+     * Restore tool intro
1334
+     */
1335 1335
     public function restore_tool_intro($sessionId = 0)
1336 1336
     {
1337
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1337
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1338 1338
             $sessionId = intval($sessionId);
1339
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1340
-			$resources = $this->course->resources;
1341
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1342
-				$sql = "DELETE FROM ".$tool_intro_table."
1339
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1340
+            $resources = $this->course->resources;
1341
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1342
+                $sql = "DELETE FROM ".$tool_intro_table."
1343 1343
 				        WHERE
1344 1344
 				            c_id = ".$this->destination_course_id." AND
1345 1345
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1346
-				Database::query($sql);
1346
+                Database::query($sql);
1347 1347
 
1348 1348
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1349 1349
                     $tool_intro->intro_text,
@@ -1373,21 +1373,21 @@  discard block
 block discarded – undo
1373 1373
 
1374 1374
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1375 1375
                 }
1376
-			}
1377
-		}
1378
-	}
1376
+            }
1377
+        }
1378
+    }
1379 1379
 
1380
-	/**
1381
-	 * Restore events
1382
-	 */
1380
+    /**
1381
+     * Restore events
1382
+     */
1383 1383
     public function restore_events($sessionId = 0)
1384 1384
     {
1385
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1385
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1386 1386
             $sessionId = intval($sessionId);
1387
-			$table = Database :: get_course_table(TABLE_AGENDA);
1388
-			$resources = $this->course->resources;
1389
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1390
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1387
+            $table = Database :: get_course_table(TABLE_AGENDA);
1388
+            $resources = $this->course->resources;
1389
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1390
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1391 1391
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1392 1392
                     $event->content,
1393 1393
                     $this->course->code,
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
                     'end_date' => $event->end_date,
1406 1406
                     'session_id' => $sessionId,
1407 1407
                 ];
1408
-				$new_event_id = Database::insert($table, $params);
1408
+                $new_event_id = Database::insert($table, $params);
1409 1409
 
1410 1410
                 if ($new_event_id) {
1411 1411
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1418,30 +1418,30 @@  discard block
 block discarded – undo
1418 1418
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1419 1419
                 }
1420 1420
 
1421
-				// Copy event attachment
1421
+                // Copy event attachment
1422 1422
 
1423
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1424
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1423
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1424
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1425 1425
 
1426
-				if (!empty($this->course->orig)) {
1426
+                if (!empty($this->course->orig)) {
1427 1427
 
1428
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1429
-					$sql = 'SELECT path, comment, size, filename
1428
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1429
+                    $sql = 'SELECT path, comment, size, filename
1430 1430
 					        FROM '.$table_attachment.'
1431 1431
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1432
-					$attachment_event = Database::query($sql);
1433
-					$attachment_event = Database::fetch_object($attachment_event);
1432
+                    $attachment_event = Database::query($sql);
1433
+                    $attachment_event = Database::fetch_object($attachment_event);
1434 1434
 
1435
-					if (file_exists($origin_path.$attachment_event->path) &&
1435
+                    if (file_exists($origin_path.$attachment_event->path) &&
1436 1436
                         !is_dir($origin_path.$attachment_event->path)
1437 1437
                     ) {
1438
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1439
-						$copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1440
-						//$copy_result = true;
1441
-						if ($copy_result) {
1442
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1438
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1439
+                        $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1440
+                        //$copy_result = true;
1441
+                        if ($copy_result) {
1442
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1443 1443
 
1444
-							$params = [
1444
+                            $params = [
1445 1445
                                 'c_id' => $this->destination_course_id,
1446 1446
                                 'path' => self::DBUTF8($new_filename),
1447 1447
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1455,17 +1455,17 @@  discard block
 block discarded – undo
1455 1455
                                 Database::query($sql);
1456 1456
                             }
1457 1457
                         }
1458
-					}
1459
-				} else {
1460
-					// get the info of the file
1461
-					if (!empty($event->attachment_path) &&
1458
+                    }
1459
+                } else {
1460
+                    // get the info of the file
1461
+                    if (!empty($event->attachment_path) &&
1462 1462
                         is_file($origin_path.$event->attachment_path) &&
1463 1463
                         is_readable($origin_path.$event->attachment_path)
1464 1464
                     ) {
1465
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1466
-						$copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1467
-						if ($copy_result) {
1468
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1465
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1466
+                        $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1467
+                        if ($copy_result) {
1468
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1469 1469
 
1470 1470
                             $params = [
1471 1471
                                 'c_id' => $this->destination_course_id,
@@ -1481,29 +1481,29 @@  discard block
 block discarded – undo
1481 1481
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1482 1482
                                 Database::query($sql);
1483 1483
                             }
1484
-						}
1485
-					}
1486
-				}
1487
-			}
1488
-		}
1489
-	}
1490
-
1491
-	/**
1492
-	 * Restore course-description
1493
-	 */
1484
+                        }
1485
+                    }
1486
+                }
1487
+            }
1488
+        }
1489
+    }
1490
+
1491
+    /**
1492
+     * Restore course-description
1493
+     */
1494 1494
     public function restore_course_descriptions($session_id = 0)
1495 1495
     {
1496
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1497
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1498
-			$resources = $this->course->resources;
1499
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1496
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1497
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1498
+            $resources = $this->course->resources;
1499
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1500 1500
                 $courseDescription = (array) $cd;
1501 1501
 
1502 1502
                 $content = isset($courseDescription['content']) ? $courseDescription['content'] : '';
1503 1503
                 $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : '';
1504 1504
                 $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
1505 1505
 
1506
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1506
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1507 1507
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1508 1508
                     $content,
1509 1509
                     $this->course->code,
@@ -1532,22 +1532,22 @@  discard block
 block discarded – undo
1532 1532
                     }
1533 1533
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1534 1534
                 }
1535
-			}
1536
-		}
1537
-	}
1535
+            }
1536
+        }
1537
+    }
1538 1538
 
1539
-	/**
1540
-	 * Restore announcements
1541
-	 */
1539
+    /**
1540
+     * Restore announcements
1541
+     */
1542 1542
     public function restore_announcements($sessionId = 0)
1543 1543
     {
1544
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1544
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1545 1545
             $sessionId = intval($sessionId);
1546
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1547
-			$resources = $this->course->resources;
1548
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1546
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1547
+            $resources = $this->course->resources;
1548
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1549 1549
 
1550
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1550
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1551 1551
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1552 1552
                     $announcement->content,
1553 1553
                     $this->course->code,
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
                     'session_id' => $sessionId,
1567 1567
                 ];
1568 1568
 
1569
-				$new_announcement_id = Database::insert($table, $params);
1569
+                $new_announcement_id = Database::insert($table, $params);
1570 1570
 
1571 1571
                 if ($new_announcement_id) {
1572 1572
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1578,32 +1578,32 @@  discard block
 block discarded – undo
1578 1578
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1579 1579
                 }
1580 1580
 
1581
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1582
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1581
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1582
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1583 1583
 
1584
-				// Copy announcement attachment file
1585
-				if (!empty($this->course->orig)) {
1584
+                // Copy announcement attachment file
1585
+                if (!empty($this->course->orig)) {
1586 1586
 
1587
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1588
-					$sql = 'SELECT path, comment, size, filename
1587
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1588
+                    $sql = 'SELECT path, comment, size, filename
1589 1589
 					        FROM '.$table_attachment.'
1590 1590
 					        WHERE
1591 1591
 					            c_id = '.$this->destination_course_id.' AND
1592 1592
 					            announcement_id = '.$id;
1593
-					$attachment_event = Database::query($sql);
1594
-					$attachment_event = Database::fetch_object($attachment_event);
1593
+                    $attachment_event = Database::query($sql);
1594
+                    $attachment_event = Database::fetch_object($attachment_event);
1595 1595
 
1596
-					if (file_exists($origin_path.$attachment_event->path) &&
1596
+                    if (file_exists($origin_path.$attachment_event->path) &&
1597 1597
                         !is_dir($origin_path.$attachment_event->path)
1598 1598
                     ) {
1599
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1599
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1600 1600
                         $copy_result = copy(
1601 1601
                             $origin_path.$attachment_event->path,
1602 1602
                             $destination_path.$new_filename
1603 1603
                         );
1604 1604
 
1605
-						if ($copy_result) {
1606
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1605
+                        if ($copy_result) {
1606
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1607 1607
 
1608 1608
                             $params = [
1609 1609
                                 'c_id' => $this->destination_course_id,
@@ -1620,19 +1620,19 @@  discard block
 block discarded – undo
1620 1620
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1621 1621
                                 Database::query($sql);
1622 1622
                             }
1623
-						}
1624
-					}
1625
-				} else {
1626
-					// get the info of the file
1627
-					if (!empty($announcement->attachment_path) &&
1623
+                        }
1624
+                    }
1625
+                } else {
1626
+                    // get the info of the file
1627
+                    if (!empty($announcement->attachment_path) &&
1628 1628
                         is_file($origin_path.$announcement->attachment_path) &&
1629 1629
                         is_readable($origin_path.$announcement->attachment_path)
1630 1630
                     ) {
1631
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1632
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1631
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1632
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1633 1633
 
1634
-						if ($copy_result) {
1635
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1634
+                        if ($copy_result) {
1635
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1636 1636
 
1637 1637
                             $params = [
1638 1638
                                 'c_id' => $this->destination_course_id,
@@ -1649,12 +1649,12 @@  discard block
 block discarded – undo
1649 1649
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1650 1650
                                 Database::query($sql);
1651 1651
                             }
1652
-						}
1653
-					}
1654
-				}
1655
-			}
1656
-		}
1657
-	}
1652
+                        }
1653
+                    }
1654
+                }
1655
+            }
1656
+        }
1657
+    }
1658 1658
 
1659 1659
     /**
1660 1660
      * Restore Quiz
@@ -1665,13 +1665,13 @@  discard block
 block discarded – undo
1665 1665
         $session_id = 0,
1666 1666
         $respect_base_content = false
1667 1667
     ) {
1668
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1669
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1670
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1671
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1672
-			$resources = $this->course->resources;
1668
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1669
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1670
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1671
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1672
+            $resources = $this->course->resources;
1673 1673
 
1674
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1674
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1675 1675
 
1676 1676
                 if (isset($quiz->obj)) {
1677 1677
                     //For new imports
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
                     $quiz->obj = $quiz;
1682 1682
                 }
1683 1683
 
1684
-				$doc = '';
1684
+                $doc = '';
1685 1685
                 if (!empty($quiz->sound)) {
1686 1686
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1687 1687
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
@@ -1689,14 +1689,14 @@  discard block
 block discarded – undo
1689 1689
                                 WHERE
1690 1690
                                     c_id = " . $this->destination_course_id . "  AND
1691 1691
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1692
-						$doc = Database::query($sql);
1693
-						$doc = Database::fetch_object($doc);
1694
-						$doc = str_replace('/audio/', '', $doc->path);
1695
-					}
1696
-				}
1697
-
1698
-				if ($id != -1) {
1699
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1692
+                        $doc = Database::query($sql);
1693
+                        $doc = Database::fetch_object($doc);
1694
+                        $doc = str_replace('/audio/', '', $doc->path);
1695
+                    }
1696
+                }
1697
+
1698
+                if ($id != -1) {
1699
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1700 1700
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1701 1701
                         $quiz->description,
1702 1702
                         $this->course->code,
@@ -1708,13 +1708,13 @@  discard block
 block discarded – undo
1708 1708
                     $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time;
1709 1709
                     $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time;
1710 1710
 
1711
-					global $_custom;
1712
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1711
+                    global $_custom;
1712
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1713 1713
                         $_custom['exercises_clean_dates_when_restoring']
1714 1714
                     ) {
1715
-						$quiz->start_time = null;
1716
-						$quiz->end_time   = null;
1717
-					}
1715
+                        $quiz->start_time = null;
1716
+                        $quiz->end_time   = null;
1717
+                    }
1718 1718
 
1719 1719
                     $params = array(
1720 1720
                         'c_id' => $this->destination_course_id,
@@ -1748,10 +1748,10 @@  discard block
 block discarded – undo
1748 1748
                         }
1749 1749
                         $params['session_id'] = $my_session_id;
1750 1750
                     } else {
1751
-        				if (!empty($session_id)) {
1752
-        					$session_id = intval($session_id);
1751
+                        if (!empty($session_id)) {
1752
+                            $session_id = intval($session_id);
1753 1753
                             $params['session_id'] = $session_id;
1754
-    				    }
1754
+                        }
1755 1755
                     }
1756 1756
                     $new_id = Database::insert($table_qui, $params);
1757 1757
 
@@ -1760,15 +1760,15 @@  discard block
 block discarded – undo
1760 1760
                         Database::query($sql);
1761 1761
                     }
1762 1762
 
1763
-				} else {
1764
-					// $id = -1 identifies the fictionary test for collecting
1765
-					// orphan questions. We do not store it in the database.
1766
-					$new_id = -1;
1767
-				}
1763
+                } else {
1764
+                    // $id = -1 identifies the fictionary test for collecting
1765
+                    // orphan questions. We do not store it in the database.
1766
+                    $new_id = -1;
1767
+                }
1768 1768
 
1769
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1769
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1770 1770
 
1771
-				$order = 0;
1771
+                $order = 0;
1772 1772
                 if (!empty($quiz->question_ids)) {
1773 1773
                     foreach ($quiz->question_ids as $index => $question_id) {
1774 1774
                         $qid = $this->restore_quiz_question($question_id);
@@ -1781,30 +1781,30 @@  discard block
 block discarded – undo
1781 1781
                         Database::query($sql);
1782 1782
                     }
1783 1783
                 }
1784
-			}
1785
-		}
1786
-	}
1784
+            }
1785
+        }
1786
+    }
1787 1787
 
1788
-	/**
1789
-	 * Restore quiz-questions
1788
+    /**
1789
+     * Restore quiz-questions
1790 1790
      * @params int question id
1791
-	 */
1791
+     */
1792 1792
     public function restore_quiz_question($id)
1793 1793
     {
1794
-		$resources = $this->course->resources;
1794
+        $resources = $this->course->resources;
1795 1795
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1796 1796
 
1797
-		$new_id = 0;
1797
+        $new_id = 0;
1798 1798
 
1799
-		if (is_object($question)) {
1800
-			if ($question->is_restored()) {
1801
-				return $question->destination_id;
1802
-			}
1803
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1804
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1799
+        if (is_object($question)) {
1800
+            if ($question->is_restored()) {
1801
+                return $question->destination_id;
1802
+            }
1803
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1804
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1805 1805
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1806 1806
 
1807
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1807
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1808 1808
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1809 1809
                 $question->description,
1810 1810
                 $this->course->code,
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
                 'extra' => self::DBUTF8($question->extra),
1826 1826
             ];
1827 1827
 
1828
-			$new_id = Database::insert($table_que, $params);
1828
+            $new_id = Database::insert($table_que, $params);
1829 1829
 
1830 1830
             if ($new_id) {
1831 1831
 
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 
1867 1867
                 foreach ($temp as $index => $answer) {
1868 1868
                     //id = '".$index."',
1869
-					$params = [
1869
+                    $params = [
1870 1870
                         'c_id' => $this->destination_course_id,
1871 1871
                         'question_id' => $new_id,
1872 1872
                         'answer' => self::DBUTF8($answer['answer']),
@@ -1885,12 +1885,12 @@  discard block
 block discarded – undo
1885 1885
                         $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId";
1886 1886
                         Database::query($sql);
1887 1887
                     }
1888
-				}
1889
-			} else {
1888
+                }
1889
+            } else {
1890 1890
                 $correct_answers = array();
1891
-				foreach ($question->answers as $index => $answer) {
1891
+                foreach ($question->answers as $index => $answer) {
1892 1892
 
1893
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1893
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1894 1894
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1895 1895
                         $answer['answer'],
1896 1896
                         $this->course->code,
@@ -1929,8 +1929,8 @@  discard block
 block discarded – undo
1929 1929
                     }
1930 1930
 
1931 1931
                     $correct_answers[$answerId] = $answer['correct'];
1932
-				}
1933
-			}
1932
+                }
1933
+            }
1934 1934
 
1935 1935
             //Current course id
1936 1936
             $course_id = api_get_course_int_id();
@@ -2027,12 +2027,12 @@  discard block
 block discarded – undo
2027 2027
                     }
2028 2028
                 }
2029 2029
             }
2030
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2031
-		}
2032
-		return $new_id;
2033
-	}
2030
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2031
+        }
2032
+        return $new_id;
2033
+    }
2034 2034
 
2035
-	/**
2035
+    /**
2036 2036
      * @todo : add session id when used for session
2037 2037
      */
2038 2038
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2112,21 +2112,21 @@  discard block
 block discarded – undo
2112 2112
         $sessionId = intval($sessionId);
2113 2113
 
2114 2114
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2115
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2116
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2117
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2118
-			$resources = $this->course->resources;
2119
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2115
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2116
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2117
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2118
+            $resources = $this->course->resources;
2119
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2120 2120
 
2121
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2121
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2122 2122
                         WHERE
2123 2123
                             c_id = '.$this->destination_course_id.' AND
2124 2124
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2125 2125
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2126 2126
 
2127
-				$result_check = Database::query($sql);
2127
+                $result_check = Database::query($sql);
2128 2128
 
2129
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2129
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2130 2130
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2131 2131
                     $survey->title,
2132 2132
                     $this->course->code,
@@ -2180,20 +2180,20 @@  discard block
 block discarded – undo
2180 2180
                     'session_id' => $sessionId,
2181 2181
                 ];
2182 2182
 
2183
-				//An existing survey exists with the same code and the same language
2184
-				if (Database::num_rows($result_check) == 1) {
2185
-					switch ($this->file_option) {
2186
-						case FILE_SKIP:
2187
-							//Do nothing
2188
-							break;
2189
-						case FILE_RENAME:
2190
-							$survey_code = $survey->code.'_';
2191
-							$i=1;
2192
-							$temp_survey_code = $survey_code.$i;
2193
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2194
-								$temp_survey_code = $survey_code.++$i;
2195
-							}
2196
-							$survey_code = $temp_survey_code;
2183
+                //An existing survey exists with the same code and the same language
2184
+                if (Database::num_rows($result_check) == 1) {
2185
+                    switch ($this->file_option) {
2186
+                        case FILE_SKIP:
2187
+                            //Do nothing
2188
+                            break;
2189
+                        case FILE_RENAME:
2190
+                            $survey_code = $survey->code.'_';
2191
+                            $i=1;
2192
+                            $temp_survey_code = $survey_code.$i;
2193
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2194
+                                $temp_survey_code = $survey_code.++$i;
2195
+                            }
2196
+                            $survey_code = $temp_survey_code;
2197 2197
 
2198 2198
                             $params['code'] = $survey_code;
2199 2199
                             $new_id = Database::insert($table_sur, $params);
@@ -2212,25 +2212,25 @@  discard block
 block discarded – undo
2212 2212
                                     Database::query($sql);
2213 2213
                                 }
2214 2214
                             }
2215
-							break;
2216
-						case FILE_OVERWRITE:
2217
-							// Delete the existing survey with the same code and language and import the one of the source course
2218
-							// getting the information of the survey (used for when the survey is shared)
2215
+                            break;
2216
+                        case FILE_OVERWRITE:
2217
+                            // Delete the existing survey with the same code and language and import the one of the source course
2218
+                            // getting the information of the survey (used for when the survey is shared)
2219 2219
 
2220
-							$sql = "SELECT * FROM $table_sur
2220
+                            $sql = "SELECT * FROM $table_sur
2221 2221
 							        WHERE
2222 2222
 							            c_id = ".$this->destination_course_id." AND
2223 2223
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2224
-							$result = Database::query($sql);
2225
-							$survey_data = Database::fetch_array($result,'ASSOC');
2224
+                            $result = Database::query($sql);
2225
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2226 2226
 
2227
-							// if the survey is shared => also delete the shared content
2228
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2227
+                            // if the survey is shared => also delete the shared content
2228
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2229 2229
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2230
-							}
2231
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2230
+                            }
2231
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2232 2232
 
2233
-							// Insert the new source survey
2233
+                            // Insert the new source survey
2234 2234
                             $new_id = Database::insert($table_sur, $params);
2235 2235
 
2236 2236
                             if ($new_id) {
@@ -2251,11 +2251,11 @@  discard block
 block discarded – undo
2251 2251
                                     Database::query($sql);
2252 2252
                                 }
2253 2253
                             }
2254
-							break;
2255
-						default:
2256
-							break;
2257
-					}
2258
-				} else {
2254
+                            break;
2255
+                        default:
2256
+                            break;
2257
+                    }
2258
+                } else {
2259 2259
                     // No existing survey with the same language and the same code, we just copy the survey
2260 2260
                     $new_id = Database::insert($table_sur, $params);
2261 2261
 
@@ -2277,48 +2277,48 @@  discard block
 block discarded – undo
2277 2277
                             Database::query($sql);
2278 2278
                         }
2279 2279
                     }
2280
-				}
2281
-			}
2282
-		}
2283
-	}
2284
-
2285
-	/**
2286
-	 * Check availability of a survey code
2287
-	 * @param string $survey_code
2288
-	 */
2280
+                }
2281
+            }
2282
+        }
2283
+    }
2284
+
2285
+    /**
2286
+     * Check availability of a survey code
2287
+     * @param string $survey_code
2288
+     */
2289 2289
     public function is_survey_code_available($survey_code)
2290 2290
     {
2291
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2292
-		$sql = "SELECT * FROM $table_sur
2291
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2292
+        $sql = "SELECT * FROM $table_sur
2293 2293
 		        WHERE
2294 2294
 		            c_id = ".$this->destination_course_id." AND
2295 2295
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2296
-		$result = Database::query($sql);
2296
+        $result = Database::query($sql);
2297 2297
         if (Database::num_rows($result) > 0) {
2298 2298
             return false;
2299 2299
         } else {
2300 2300
             return true;
2301 2301
         }
2302
-	}
2302
+    }
2303 2303
 
2304
-	/**
2305
-	 * Restore survey-questions
2306
-	 * @param string $survey_id
2307
-	 */
2304
+    /**
2305
+     * Restore survey-questions
2306
+     * @param string $survey_id
2307
+     */
2308 2308
     public function restore_survey_question($id, $survey_id)
2309 2309
     {
2310
-		$resources = $this->course->resources;
2311
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2310
+        $resources = $this->course->resources;
2311
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2312 2312
         $new_id = 0;
2313 2313
 
2314
-		if (is_object($question)) {
2315
-			if ($question->is_restored()) {
2316
-				return $question->destination_id;
2317
-			}
2318
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2319
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2314
+        if (is_object($question)) {
2315
+            if ($question->is_restored()) {
2316
+                return $question->destination_id;
2317
+            }
2318
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2319
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2320 2320
 
2321
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2321
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2322 2322
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2323 2323
                 $question->survey_question,
2324 2324
                 $this->course->code,
@@ -2372,10 +2372,10 @@  discard block
 block discarded – undo
2372 2372
                 }
2373 2373
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2374 2374
             }
2375
-		}
2375
+        }
2376 2376
 
2377
-		return $new_id;
2378
-	}
2377
+        return $new_id;
2378
+    }
2379 2379
 
2380 2380
     /**
2381 2381
      * Restoring learning paths
@@ -2386,19 +2386,19 @@  discard block
 block discarded – undo
2386 2386
     {
2387 2387
         $session_id = intval($session_id);
2388 2388
 
2389
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2389
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2390 2390
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2391 2391
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2392 2392
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2393 2393
 
2394
-			$resources = $this->course->resources;
2394
+            $resources = $this->course->resources;
2395 2395
 
2396
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2397
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2396
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2397
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2398 2398
 
2399
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2400
-				$condition_session = '';
2401
-				if (!empty($session_id)) {
2399
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2400
+                $condition_session = '';
2401
+                if (!empty($session_id)) {
2402 2402
                     if ($respect_base_content) {
2403 2403
                         $my_session_id = $lp->session_id;
2404 2404
                         if (!empty($lp->session_id)) {
@@ -2409,20 +2409,20 @@  discard block
 block discarded – undo
2409 2409
                         $session_id = intval($session_id);
2410 2410
                         $condition_session = $session_id;
2411 2411
                     }
2412
-				}
2413
-
2414
-				// Adding the author's image
2415
-				if (!empty($lp->preview_image)) {
2416
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2417
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2418
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2419
-						if ($copy_result) {
2420
-							$lp->preview_image = $new_filename;
2421
-						} else {
2422
-							$lp->preview_image ='';
2423
-						}
2424
-					}
2425
-				}
2412
+                }
2413
+
2414
+                // Adding the author's image
2415
+                if (!empty($lp->preview_image)) {
2416
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2417
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2418
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2419
+                        if ($copy_result) {
2420
+                            $lp->preview_image = $new_filename;
2421
+                        } else {
2422
+                            $lp->preview_image ='';
2423
+                        }
2424
+                    }
2425
+                }
2426 2426
 
2427 2427
                 if ($this->add_text_in_items) {
2428 2428
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2480,7 +2480,7 @@  discard block
 block discarded – undo
2480 2480
                     $params['session_id'] = $condition_session;
2481 2481
                 }
2482 2482
 
2483
-				$new_lp_id = Database::insert($table_main, $params);
2483
+                $new_lp_id = Database::insert($table_main, $params);
2484 2484
 
2485 2485
                 if ($new_lp_id) {
2486 2486
 
@@ -2541,13 +2541,13 @@  discard block
 block discarded – undo
2541 2541
                 $old_refs = array();
2542 2542
                 $prerequisite_ids = array();
2543 2543
 
2544
-				foreach ($lp->get_items() as $index => $item) {
2545
-					// we set the ref code here and then we update in a for loop
2546
-					$ref = $item['ref'];
2544
+                foreach ($lp->get_items() as $index => $item) {
2545
+                    // we set the ref code here and then we update in a for loop
2546
+                    $ref = $item['ref'];
2547 2547
 
2548
-					// Dealing with path the same way as ref as some data has
2548
+                    // Dealing with path the same way as ref as some data has
2549 2549
                     // been put into path when it's a local resource
2550
-					// Only fix the path for no scos
2550
+                    // Only fix the path for no scos
2551 2551
                     if ($item['item_type'] == 'sco') {
2552 2552
                         $path = $item['path'];
2553 2553
                     } else {
@@ -2576,128 +2576,128 @@  discard block
 block discarded – undo
2576 2576
                         'launch_data' => self::DBUTF8($item['launch_data']),
2577 2577
                     ];
2578 2578
 
2579
-					$new_item_id = Database::insert($table_item, $params);
2579
+                    $new_item_id = Database::insert($table_item, $params);
2580 2580
 
2581 2581
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2582 2582
                     Database::query($sql);
2583 2583
 
2584
-					//save a link between old and new item IDs
2585
-					$new_item_ids[$item['id']] = $new_item_id;
2586
-					//save a reference of items that need a parent_item_id refresh
2587
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2588
-					//save a reference of items that need a previous_item_id refresh
2589
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2590
-					//save a reference of items that need a next_item_id refresh
2591
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2592
-
2593
-					if (!empty($item['prerequisite'])) {
2594
-						if ($lp->lp_type =='2') {
2595
-							// if is an sco
2596
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2597
-						} else {
2598
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2599
-						}
2600
-					}
2601
-
2602
-					if (!empty($ref)) {
2603
-						if ($lp->lp_type =='2') {
2604
-							// if is an sco
2605
-							$old_refs[$new_item_id]= $ref;
2606
-						} elseif (isset($new_item_ids[$ref])) {
2584
+                    //save a link between old and new item IDs
2585
+                    $new_item_ids[$item['id']] = $new_item_id;
2586
+                    //save a reference of items that need a parent_item_id refresh
2587
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2588
+                    //save a reference of items that need a previous_item_id refresh
2589
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2590
+                    //save a reference of items that need a next_item_id refresh
2591
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2592
+
2593
+                    if (!empty($item['prerequisite'])) {
2594
+                        if ($lp->lp_type =='2') {
2595
+                            // if is an sco
2596
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2597
+                        } else {
2598
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2599
+                        }
2600
+                    }
2601
+
2602
+                    if (!empty($ref)) {
2603
+                        if ($lp->lp_type =='2') {
2604
+                            // if is an sco
2605
+                            $old_refs[$new_item_id]= $ref;
2606
+                        } elseif (isset($new_item_ids[$ref])) {
2607 2607
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2608 2608
                         }
2609
-					}
2609
+                    }
2610 2610
 
2611
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2612
-				}
2611
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2612
+                }
2613 2613
 
2614
-				// Updating prerequisites
2615
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2616
-					if ($my_old_prerequisite != ''){
2617
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2614
+                // Updating prerequisites
2615
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2616
+                    if ($my_old_prerequisite != ''){
2617
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2618 2618
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2619
-						Database::query($sql);
2620
-					}
2621
-				}
2622
-
2623
-				// Updating refs
2624
-				foreach ($old_refs  as $key=>$my_old_ref) {
2625
-					if ($my_old_ref != '') {
2626
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2619
+                        Database::query($sql);
2620
+                    }
2621
+                }
2622
+
2623
+                // Updating refs
2624
+                foreach ($old_refs  as $key=>$my_old_ref) {
2625
+                    if ($my_old_ref != '') {
2626
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2627 2627
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2628
-						Database::query($sql);
2629
-					}
2630
-				}
2631
-
2632
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2633
-					$parent_new_id = 0;
2634
-					if($parent_item_old_id != 0){
2635
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2636
-					}
2637
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2628
+                        Database::query($sql);
2629
+                    }
2630
+                }
2631
+
2632
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2633
+                    $parent_new_id = 0;
2634
+                    if($parent_item_old_id != 0){
2635
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2636
+                    }
2637
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2638 2638
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2639
-					Database::query($sql);
2640
-				}
2641
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2642
-					$previous_new_id = 0;
2643
-					if ($previous_item_old_id != 0){
2644
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2645
-					}
2646
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2639
+                    Database::query($sql);
2640
+                }
2641
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2642
+                    $previous_new_id = 0;
2643
+                    if ($previous_item_old_id != 0){
2644
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2645
+                    }
2646
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2647 2647
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2648
-					Database::query($sql);
2649
-				}
2650
-
2651
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2652
-					$next_new_id = 0;
2653
-					if ($next_item_old_id != 0){
2654
-						$next_new_id = $new_item_ids[$next_item_old_id];
2655
-					}
2656
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2648
+                    Database::query($sql);
2649
+                }
2650
+
2651
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2652
+                    $next_new_id = 0;
2653
+                    if ($next_item_old_id != 0){
2654
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2655
+                    }
2656
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2657 2657
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2658
-					Database::query($sql);
2659
-				}
2660
-
2661
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2662
-					$prerequisite_new_id = 0;
2663
-					if ($prerequisite_old_id != 0){
2664
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2665
-					}
2666
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2658
+                    Database::query($sql);
2659
+                }
2660
+
2661
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2662
+                    $prerequisite_new_id = 0;
2663
+                    if ($prerequisite_old_id != 0){
2664
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2665
+                    }
2666
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2667 2667
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2668
-					Database::query($sql);
2669
-				}
2670
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2671
-			}
2672
-		}
2673
-	}
2674
-
2675
-	/**
2676
-	 * Restore works
2668
+                    Database::query($sql);
2669
+                }
2670
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2671
+            }
2672
+        }
2673
+    }
2674
+
2675
+    /**
2676
+     * Restore works
2677 2677
      * @deprecated use restore_works
2678 2678
      *
2679
-	 */
2680
-	public function restore_student_publication($sessionId = 0)
2679
+     */
2680
+    public function restore_student_publication($sessionId = 0)
2681 2681
     {
2682 2682
         $sessionId = intval($sessionId);
2683 2683
         $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2684 2684
         $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
2685 2685
         $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY);
2686 2686
 
2687
-		// Query in student publication
2688
-		$sql = 'SELECT * FROM '.$work_table.'
2687
+        // Query in student publication
2688
+        $sql = 'SELECT * FROM '.$work_table.'
2689 2689
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2690 2690
 
2691
-		$result = Database::query($sql);
2692
-		$folders = Database::store_result($result, 'ASSOC');
2691
+        $result = Database::query($sql);
2692
+        $folders = Database::store_result($result, 'ASSOC');
2693 2693
 
2694
-		foreach ($folders  as $folder) {
2695
-		    $old_id = $folder['id'];
2694
+        foreach ($folders  as $folder) {
2695
+            $old_id = $folder['id'];
2696 2696
             unset($folder['id']);
2697
-			$folder['c_id'] = $this->destination_course_id;
2697
+            $folder['c_id'] = $this->destination_course_id;
2698 2698
             $folder['parent_id'] = 0;
2699 2699
             $folder['session_id'] = $sessionId;
2700
-			$new_id = Database::insert($work_table, $folder);
2700
+            $new_id = Database::insert($work_table, $folder);
2701 2701
 
2702 2702
             if ($new_id) {
2703 2703
                 // query in item property
@@ -2756,23 +2756,23 @@  discard block
 block discarded – undo
2756 2756
                     }
2757 2757
                 }
2758 2758
             }
2759
-		}
2759
+        }
2760 2760
 
2761 2761
         $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/';
2762 2762
         $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/';
2763 2763
         self::allow_create_all_directory($origin, $destination, false);
2764
-	}
2764
+    }
2765 2765
 
2766 2766
     /**
2767
-    * copy all directory and sub directory
2768
-    * @param string The path origin
2769
-    * @param string The path destination
2770
-    * @param boolean Option Overwrite
2771
-    * @param string $source
2772
-    * @param string $dest
2773
-    * @return void()
2774
-    * @deprecated
2775
-    */
2767
+     * copy all directory and sub directory
2768
+     * @param string The path origin
2769
+     * @param string The path destination
2770
+     * @param boolean Option Overwrite
2771
+     * @param string $source
2772
+     * @param string $dest
2773
+     * @return void()
2774
+     * @deprecated
2775
+     */
2776 2776
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2777 2777
     {
2778 2778
         if (!is_dir($dest)) {
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
                 if ($file != '.' && $file != '..') {
2784 2784
                     $path = $source . '/' . $file;
2785 2785
                     if (is_file($path)) {
2786
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
2786
+                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2787 2787
                         if (!@copy($path, $dest . '/' . $file)) {
2788 2788
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2789 2789
                         }*/
@@ -2798,12 +2798,12 @@  discard block
 block discarded – undo
2798 2798
         }
2799 2799
     }
2800 2800
 
2801
-	/**
2802
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2803
-	 * @param	string	Tool name
2804
-	 * @param	integer	Old ID
2805
-	 * @return	integer	New ID
2806
-	 */
2801
+    /**
2802
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2803
+     * @param	string	Tool name
2804
+     * @param	integer	Old ID
2805
+     * @return	integer	New ID
2806
+     */
2807 2807
     public function get_new_id($tool, $ref)
2808 2808
     {
2809 2809
         // Check if the value exist in the current array.
@@ -2825,25 +2825,25 @@  discard block
 block discarded – undo
2825 2825
         }
2826 2826
 
2827 2827
         return '';
2828
-	}
2828
+    }
2829 2829
 
2830
-	/**
2831
-	 * Restore glossary
2832
-	 */
2830
+    /**
2831
+     * Restore glossary
2832
+     */
2833 2833
     public function restore_glossary($session_id = 0)
2834 2834
     {
2835
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2836
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2837
-			$resources = $this->course->resources;
2838
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2835
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2836
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2837
+            $resources = $this->course->resources;
2838
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2839 2839
 
2840 2840
                 $params = [];
2841
-    			if (!empty($session_id)) {
2842
-    				$session_id = intval($session_id);
2841
+                if (!empty($session_id)) {
2842
+                    $session_id = intval($session_id);
2843 2843
                     $params['session_id'] = $session_id;
2844
-    			}
2844
+                }
2845 2845
 
2846
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2846
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2847 2847
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2848 2848
                     $glossary->description,
2849 2849
                     $this->course->code,
@@ -2877,27 +2877,27 @@  discard block
 block discarded – undo
2877 2877
 
2878 2878
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2879 2879
                 }
2880
-			}
2881
-		}
2882
-	}
2880
+            }
2881
+        }
2882
+    }
2883 2883
 
2884 2884
     /**
2885 2885
      * @param int $session_id
2886 2886
      */
2887 2887
     public function restore_wiki($session_id = 0)
2888 2888
     {
2889
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2890
-			// wiki table of the target course
2891
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2892
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2889
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2890
+            // wiki table of the target course
2891
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2892
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2893 2893
 
2894
-			// storing all the resources that have to be copied in an array
2895
-			$resources = $this->course->resources;
2894
+            // storing all the resources that have to be copied in an array
2895
+            $resources = $this->course->resources;
2896 2896
 
2897
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2898
-				// the sql statement to insert the groups from the old course to the new course
2897
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2898
+                // the sql statement to insert the groups from the old course to the new course
2899 2899
 
2900
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2900
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2901 2901
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2902 2902
                     $wiki->content,
2903 2903
                     $this->course->code,
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
                     'user_ip' => ''
2933 2933
                 ];
2934 2934
 
2935
-				$new_id = Database::insert($table_wiki, $params);
2935
+                $new_id = Database::insert($table_wiki, $params);
2936 2936
 
2937 2937
                 if ($new_id) {
2938 2938
                     $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid
@@ -2962,9 +2962,9 @@  discard block
 block discarded – undo
2962 2962
 
2963 2963
                     Database::insert($table_wiki_conf, $params);
2964 2964
                 }
2965
-			}
2966
-		}
2967
-	}
2965
+            }
2966
+        }
2967
+    }
2968 2968
 
2969 2969
     /**
2970 2970
      * Restore Thematics
@@ -2972,15 +2972,15 @@  discard block
 block discarded – undo
2972 2972
      */
2973 2973
     public function restore_thematic($session_id = 0)
2974 2974
     {
2975
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2975
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2976 2976
             $table_thematic = Database::get_course_table(TABLE_THEMATIC);
2977 2977
             $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
2978 2978
             $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
2979 2979
 
2980
-			$resources = $this->course->resources;
2981
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2980
+            $resources = $this->course->resources;
2981
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2982 2982
 
2983
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2983
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2984 2984
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2985 2985
                     $thematic->params['content'],
2986 2986
                     $this->course->code,
@@ -2988,13 +2988,13 @@  discard block
 block discarded – undo
2988 2988
                     $this->course->backup_path,
2989 2989
                     $this->course->info['path']
2990 2990
                 );
2991
-				$thematic->params['c_id']  = $this->destination_course_id;
2992
-				unset($thematic->params['id']);
2991
+                $thematic->params['c_id']  = $this->destination_course_id;
2992
+                unset($thematic->params['id']);
2993 2993
                 unset($thematic->params['iid']);
2994 2994
 
2995
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
2995
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
2996 2996
 
2997
-				if ($last_id) {
2997
+                if ($last_id) {
2998 2998
 
2999 2999
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
3000 3000
                     Database::query($sql);
@@ -3007,12 +3007,12 @@  discard block
 block discarded – undo
3007 3007
                         api_get_user_id()
3008 3008
                     );
3009 3009
 
3010
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
3011
-						unset($thematic_advance['id']);
3010
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
3011
+                        unset($thematic_advance['id']);
3012 3012
                         unset($thematic_advance['iid']);
3013
-						$thematic_advance['attendance_id'] = 0;
3014
-						$thematic_advance['thematic_id'] = $last_id;
3015
-						$thematic_advance['c_id']  = $this->destination_course_id;
3013
+                        $thematic_advance['attendance_id'] = 0;
3014
+                        $thematic_advance['thematic_id'] = $last_id;
3015
+                        $thematic_advance['c_id']  = $this->destination_course_id;
3016 3016
 
3017 3017
                         $my_id = Database::insert(
3018 3018
                             $table_thematic_advance,
@@ -3020,7 +3020,7 @@  discard block
 block discarded – undo
3020 3020
                             false
3021 3021
                         );
3022 3022
 
3023
-						if ($my_id) {
3023
+                        if ($my_id) {
3024 3024
 
3025 3025
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
3026 3026
                             Database::query($sql);
@@ -3032,17 +3032,17 @@  discard block
 block discarded – undo
3032 3032
                                 'ThematicAdvanceAdded',
3033 3033
                                 api_get_user_id()
3034 3034
                             );
3035
-						}
3036
-					}
3035
+                        }
3036
+                    }
3037 3037
 
3038
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3039
-						unset($thematic_plan['id']);
3038
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
3039
+                        unset($thematic_plan['id']);
3040 3040
                         unset($thematic_plan['iid']);
3041
-						$thematic_plan['thematic_id'] = $last_id;
3042
-						$thematic_plan['c_id'] = $this->destination_course_id;
3043
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3041
+                        $thematic_plan['thematic_id'] = $last_id;
3042
+                        $thematic_plan['c_id'] = $this->destination_course_id;
3043
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3044 3044
 
3045
-						if ($my_id) {
3045
+                        if ($my_id) {
3046 3046
 
3047 3047
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
3048 3048
                             Database::query($sql);
@@ -3054,12 +3054,12 @@  discard block
 block discarded – undo
3054 3054
                                 'ThematicPlanAdded',
3055 3055
                                 api_get_user_id()
3056 3056
                             );
3057
-						}
3058
-					}
3059
-				}
3060
-			}
3061
-		}
3062
-	}
3057
+                        }
3058
+                    }
3059
+                }
3060
+            }
3061
+        }
3062
+    }
3063 3063
 
3064 3064
     /**
3065 3065
      * Restore Attendance
@@ -3067,14 +3067,14 @@  discard block
 block discarded – undo
3067 3067
      */
3068 3068
     public function restore_attendance($session_id = 0)
3069 3069
     {
3070
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3071
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3072
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3070
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3071
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3072
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3073 3073
 
3074
-			$resources = $this->course->resources;
3075
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3074
+            $resources = $this->course->resources;
3075
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3076 3076
 
3077
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3077
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3078 3078
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3079 3079
                     $obj->params['description'],
3080 3080
                     $this->course->code,
@@ -3086,11 +3086,11 @@  discard block
 block discarded – undo
3086 3086
                 unset($obj->params['id']);
3087 3087
                 unset($obj->params['iid']);
3088 3088
 
3089
-				$obj->params['c_id'] = $this->destination_course_id;
3089
+                $obj->params['c_id'] = $this->destination_course_id;
3090 3090
 
3091
-				$last_id = Database::insert($table_attendance, $obj->params);
3091
+                $last_id = Database::insert($table_attendance, $obj->params);
3092 3092
 
3093
-				if (is_numeric($last_id)) {
3093
+                if (is_numeric($last_id)) {
3094 3094
 
3095 3095
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3096 3096
                     Database::query($sql);
@@ -3104,11 +3104,11 @@  discard block
 block discarded – undo
3104 3104
                     );
3105 3105
 
3106 3106
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3107
-						unset($attendance_calendar['id']);
3107
+                        unset($attendance_calendar['id']);
3108 3108
                         unset($attendance_calendar['iid']);
3109 3109
 
3110
-						$attendance_calendar['attendance_id'] = $last_id;
3111
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3110
+                        $attendance_calendar['attendance_id'] = $last_id;
3111
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3112 3112
                         $attendanceCalendarId = Database::insert(
3113 3113
                             $table_attendance_calendar,
3114 3114
                             $attendance_calendar
@@ -3116,11 +3116,11 @@  discard block
 block discarded – undo
3116 3116
 
3117 3117
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3118 3118
                         Database::query($sql);
3119
-					}
3120
-				}
3121
-			}
3122
-		}
3123
-	}
3119
+                    }
3120
+                }
3121
+            }
3122
+        }
3123
+    }
3124 3124
 
3125 3125
     /**
3126 3126
      * Restore Works
@@ -3261,11 +3261,11 @@  discard block
 block discarded – undo
3261 3261
      */
3262 3262
     public function DBUTF8($str)
3263 3263
     {
3264
-		if (UTF8_CONVERT) {
3264
+        if (UTF8_CONVERT) {
3265 3265
             $str = utf8_encode($str);
3266 3266
         }
3267
-		return $str;
3268
-	}
3267
+        return $str;
3268
+    }
3269 3269
 
3270 3270
     /**
3271 3271
      * @param string $str
@@ -3276,8 +3276,8 @@  discard block
 block discarded – undo
3276 3276
         if (UTF8_CONVERT) {
3277 3277
             $str = utf8_encode($str);
3278 3278
         }
3279
-		return Database::escape_string($str);
3280
-	}
3279
+        return Database::escape_string($str);
3280
+    }
3281 3281
 
3282 3282
     /**
3283 3283
      * @param array $array
Please login to merge, or discard this patch.
main/group/group_creation.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
             exit;
58 58
             break;
59 59
         case 'create_subgroups':
60
-			GroupManager::create_subgroups(
61
-				$_POST['base_group'],
62
-				$_POST['number_of_groups']
63
-			);
60
+            GroupManager::create_subgroups(
61
+                $_POST['base_group'],
62
+                $_POST['number_of_groups']
63
+            );
64 64
             Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
65 65
             header("Location: ".$currentUrl);
66 66
             exit;
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 if (isset($_POST['number_of_groups'])) {
85 85
     if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) {
86 86
         Display :: display_error_message(
87
-			get_lang('PleaseEnterValidNumber').'<br /><br />
87
+            get_lang('PleaseEnterValidNumber').'<br /><br />
88 88
 			<a href="group_creation.php?'.api_get_cidreq().'">&laquo; '.get_lang('Back').'</a>',
89
-			false
90
-		);
89
+            false
90
+        );
91 91
     } else {
92 92
         $number_of_groups = intval($_POST['number_of_groups']);
93 93
         if ($number_of_groups > 1) {
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
     }
126 126
     </script>
127 127
     <?php
128
-		}
129
-		$group_categories = GroupManager::get_categories();
130
-		$group_id = GroupManager :: get_number_of_groups() + 1;
131
-		$cat_options = [];
132
-		foreach ($group_categories as $index => $category) {
133
-			$cat_options[$category['id']] = $category['title'];
134
-		}
128
+        }
129
+        $group_categories = GroupManager::get_categories();
130
+        $group_id = GroupManager :: get_number_of_groups() + 1;
131
+        $cat_options = [];
132
+        foreach ($group_categories as $index => $category) {
133
+            $cat_options[$category['id']] = $category['title'];
134
+        }
135 135
         $form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq());
136 136
 
137
-		// Modify the default templates
138
-		$renderer = $form->defaultRenderer();
139
-		$form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>";
140
-		$renderer->setFormTemplate($form_template);
141
-		$element_template = <<<EOT
137
+        // Modify the default templates
138
+        $renderer = $form->defaultRenderer();
139
+        $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>";
140
+        $renderer->setFormTemplate($form_template);
141
+        $element_template = <<<EOT
142 142
         <tr class="separate">
143 143
 		<td>
144 144
 			<!-- BEGIN required -->
@@ -151,25 +151,25 @@  discard block
 block discarded – undo
151 151
 	</tr>
152 152
 
153 153
 EOT;
154
-		$renderer->setCustomElementTemplate($element_template);
154
+        $renderer->setCustomElementTemplate($element_template);
155 155
         $form->addElement('header', $nameTools);
156
-		$form->addElement('hidden', 'action');
157
-		$form->addElement('hidden', 'number_of_groups');
158
-		$defaults = array();
159
-		// Table heading
160
-		$group_el = array();
161
-		$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
156
+        $form->addElement('hidden', 'action');
157
+        $form->addElement('hidden', 'number_of_groups');
158
+        $defaults = array();
159
+        // Table heading
160
+        $group_el = array();
161
+        $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
162 162
 
163
-		if (api_get_setting('allow_group_categories') === 'true') {
164
-			$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
165
-		}
166
-		$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
167
-		$form->addGroup($group_el, 'groups', null, "</td><td>", false);
168
-		// Checkboxes
169
-		if ($_POST['number_of_groups'] > 1) {
170
-			$group_el = array ();
171
-			$group_el[] = $form->createElement('static', null, null, ' ');
172
-			if (api_get_setting('allow_group_categories') === 'true') {
163
+        if (api_get_setting('allow_group_categories') === 'true') {
164
+            $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
165
+        }
166
+        $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
167
+        $form->addGroup($group_el, 'groups', null, "</td><td>", false);
168
+        // Checkboxes
169
+        if ($_POST['number_of_groups'] > 1) {
170
+            $group_el = array ();
171
+            $group_el[] = $form->createElement('static', null, null, ' ');
172
+            if (api_get_setting('allow_group_categories') === 'true') {
173 173
                 $group_el[] = $form->createElement(
174 174
                     'checkbox',
175 175
                     'same_category',
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     get_lang('SameForAll'),
178 178
                     array('onclick' => "javascript: switch_state('category');")
179 179
                 );
180
-			}
180
+            }
181 181
             $group_el[] = $form->createElement(
182 182
                 'checkbox',
183 183
                 'same_places',
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
                 get_lang('SameForAll'),
186 186
                 array('onclick' => "javascript: switch_state('places');")
187 187
             );
188
-			$form->addGroup($group_el, 'groups', null, '</td><td>', false);
189
-		}
190
-		// Properties for all groups
191
-		for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
192
-			$group_el = array();
193
-			$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
194
-			if (api_get_setting('allow_group_categories') === 'true') {
188
+            $form->addGroup($group_el, 'groups', null, '</td><td>', false);
189
+        }
190
+        // Properties for all groups
191
+        for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
192
+            $group_el = array();
193
+            $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
194
+            if (api_get_setting('allow_group_categories') === 'true') {
195 195
                 $group_el[] = $form->createElement(
196 196
                     'select',
197 197
                     'group_'.$group_number.'_category',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $cat_options,
200 200
                     array('id' => 'category_'.$group_number)
201 201
                 );
202
-			}
202
+            }
203 203
             $group_el[] = $form->createElement(
204 204
                 'text',
205 205
                 'group_'.$group_number.'_places',
@@ -207,110 +207,110 @@  discard block
 block discarded – undo
207 207
                 array('class' => 'span1', 'id' => 'places_'.$group_number)
208 208
             );
209 209
 
210
-			if ($_POST['number_of_groups'] < 10000) {
211
-				if ($group_id < 10) {
212
-					$prev = '000';
213
-				} elseif ($group_id < 100) {
214
-					$prev = '00';
215
-				} elseif ($group_id<1000) {
216
-					$prev = '0';
217
-				} else {
218
-					$prev = '';
219
-				}
220
-			}
210
+            if ($_POST['number_of_groups'] < 10000) {
211
+                if ($group_id < 10) {
212
+                    $prev = '000';
213
+                } elseif ($group_id < 100) {
214
+                    $prev = '00';
215
+                } elseif ($group_id<1000) {
216
+                    $prev = '0';
217
+                } else {
218
+                    $prev = '';
219
+                }
220
+            }
221 221
 
222
-			$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
223
-			$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
224
-		}
225
-		$defaults['action'] = 'create_groups';
226
-		$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
227
-		$form->setDefaults($defaults);
228
-		$form->addButtonCreate(get_lang('CreateGroup'), 'submit');
222
+            $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
223
+            $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
224
+        }
225
+        $defaults['action'] = 'create_groups';
226
+        $defaults['number_of_groups'] = intval($_POST['number_of_groups']);
227
+        $form->setDefaults($defaults);
228
+        $form->addButtonCreate(get_lang('CreateGroup'), 'submit');
229 229
         $form->display();
230
-	}
230
+    }
231 231
 } else {
232
-	/*
232
+    /*
233 233
 	 * Show form to generate new groups
234 234
 	 */
235
-	$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
236
-	$create_groups_form->addElement('header', $nameTools);
235
+    $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
236
+    $create_groups_form->addElement('header', $nameTools);
237 237
     $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1'));
238 238
     $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary');
239
-	$defaults = array();
240
-	$defaults['number_of_groups'] = 1;
241
-	$create_groups_form->setDefaults($defaults);
242
-	$create_groups_form->display();
239
+    $defaults = array();
240
+    $defaults['number_of_groups'] = 1;
241
+    $create_groups_form->setDefaults($defaults);
242
+    $create_groups_form->display();
243 243
 
244
-	/*
244
+    /*
245 245
 	 * Show form to generate subgroups
246 246
 	 */
247
-	if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) {
248
-		$base_group_options = array ();
249
-		$groups = GroupManager :: get_group_list();
250
-		foreach ($groups as $index => $group) {
251
-			$number_of_students = GroupManager :: number_of_students($group['id']);
252
-			if ($number_of_students > 0) {
253
-				$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
254
-			}
255
-		}
256
-		if (count($base_group_options) > 0) {
257
-			$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
247
+    if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) {
248
+        $base_group_options = array ();
249
+        $groups = GroupManager :: get_group_list();
250
+        foreach ($groups as $index => $group) {
251
+            $number_of_students = GroupManager :: number_of_students($group['id']);
252
+            if ($number_of_students > 0) {
253
+                $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
254
+            }
255
+        }
256
+        if (count($base_group_options) > 0) {
257
+            $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
258 258
             $create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
259 259
             $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
260
-			$create_subgroups_form->addElement('hidden', 'action');
261
-			$group_el = array();
262
-			$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
263
-			$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
264
-			$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
265
-			$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
266
-			$group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
267
-			$create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
268
-			$defaults = array();
269
-			$defaults['action'] = 'create_subgroups';
270
-			$create_subgroups_form->setDefaults($defaults);
271
-			$create_subgroups_form->display();
272
-		}
273
-	}
260
+            $create_subgroups_form->addElement('hidden', 'action');
261
+            $group_el = array();
262
+            $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
263
+            $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
264
+            $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
265
+            $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
266
+            $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
267
+            $create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
268
+            $defaults = array();
269
+            $defaults['action'] = 'create_subgroups';
270
+            $create_subgroups_form->setDefaults($defaults);
271
+            $create_subgroups_form->display();
272
+        }
273
+    }
274 274
 
275
-	/*
275
+    /*
276 276
 	 * Show form to generate groups from classes subscribed to the course
277 277
 	 */
278 278
     $options['where'] = array(" usergroup.course_id = ? " =>  api_get_course_int_id());
279 279
     $obj = new UserGroup();
280 280
     $classes = $obj->getUserGroupInCourse($options);
281
-	if (count($classes) > 0) {
282
-		echo '<b>'.get_lang('GroupsFromClasses').'</b>';
283
-		echo '<blockquote>';
284
-		echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
285
-		echo '<ul>';
286
-		foreach ($classes as $index => $class) {
287
-			$number_of_users = count($obj->get_users_by_usergroup($class['id']));
288
-			echo '<li>';
289
-			echo $class['name'];
290
-			echo ' ('.$number_of_users.' '.get_lang('Users').')';
291
-			echo '</li>';
292
-		}
293
-		echo '</ul>';
281
+    if (count($classes) > 0) {
282
+        echo '<b>'.get_lang('GroupsFromClasses').'</b>';
283
+        echo '<blockquote>';
284
+        echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
285
+        echo '<ul>';
286
+        foreach ($classes as $index => $class) {
287
+            $number_of_users = count($obj->get_users_by_usergroup($class['id']));
288
+            echo '<li>';
289
+            echo $class['name'];
290
+            echo ' ('.$number_of_users.' '.get_lang('Users').')';
291
+            echo '</li>';
292
+        }
293
+        echo '</ul>';
294 294
 
295
-		$create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
296
-		$create_class_groups_form->addElement('hidden', 'action');
297
-		if (api_get_setting('allow_group_categories') === 'true') {
298
-			$group_categories = GroupManager :: get_categories();
299
-			$cat_options = array();
300
-			foreach ($group_categories as $index => $category) {
301
-				$cat_options[$category['id']] = $category['title'];
302
-			}
303
-			$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
304
-		} else {
305
-			$create_class_groups_form->addElement('hidden', 'group_category');
306
-		}
307
-		$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
308
-		$defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
309
-		$defaults['action'] = 'create_class_groups';
310
-		$create_class_groups_form->setDefaults($defaults);
311
-		$create_class_groups_form->display();
312
-		echo '</blockquote>';
313
-	}
295
+        $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
296
+        $create_class_groups_form->addElement('hidden', 'action');
297
+        if (api_get_setting('allow_group_categories') === 'true') {
298
+            $group_categories = GroupManager :: get_categories();
299
+            $cat_options = array();
300
+            foreach ($group_categories as $index => $category) {
301
+                $cat_options[$category['id']] = $category['title'];
302
+            }
303
+            $create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
304
+        } else {
305
+            $create_class_groups_form->addElement('hidden', 'group_category');
306
+        }
307
+        $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
308
+        $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
309
+        $defaults['action'] = 'create_class_groups';
310
+        $create_class_groups_form->setDefaults($defaults);
311
+        $create_class_groups_form->display();
312
+        echo '</blockquote>';
313
+    }
314 314
 }
315 315
 
316 316
 Display :: display_footer();
Please login to merge, or discard this patch.
main/upload/upload.document.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  */
48 48
 //user has submitted a file
49 49
 if (isset($_FILES['user_upload'])) {
50
-	$upload_ok = process_uploaded_file($_FILES['user_upload']);
51
-	if ($upload_ok) {
52
-		//file got on the server without problems, now process it
50
+    $upload_ok = process_uploaded_file($_FILES['user_upload']);
51
+    if ($upload_ok) {
52
+        //file got on the server without problems, now process it
53 53
         $new_path = handle_uploaded_document(
54 54
             $_course,
55 55
             $_FILES['user_upload'],
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
             $_POST['unzip'],
62 62
             $_POST['if_exists']
63 63
         );
64
-    	$new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : '';
65
-    	$new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : '';
64
+        $new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : '';
65
+        $new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : '';
66 66
 
67
-    	if ($new_path && ($new_comment || $new_title))
68
-    	if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
69
-        	$table_document = Database::get_course_table(TABLE_DOCUMENT);
70
-        	$ct = '';
67
+        if ($new_path && ($new_comment || $new_title))
68
+        if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
69
+            $table_document = Database::get_course_table(TABLE_DOCUMENT);
70
+            $ct = '';
71 71
             if ($new_comment) {
72 72
                 $ct .= ", comment='$new_comment'";
73 73
             }
74 74
             if ($new_title) {
75 75
                 $ct .= ", title='$new_title'";
76 76
             }
77
-        	Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'");
78
-    	}
77
+            Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'");
78
+        }
79 79
         //check for missing images in html files
80 80
         $missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path);
81 81
         if ($missing_files) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 //they want to create a directory
134 134
 if (isset($_POST['create_dir']) && $_POST['dirname']!='') {
135 135
     $added_slash = $path == '/' ? '' : '/';
136
-	$dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']);
136
+    $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']);
137 137
     $created_dir = create_unexisting_directory(
138 138
         $_course,
139 139
         api_get_user_id(),
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 }
154 154
 
155 155
 if (isset($_GET['createdir'])) {
156
-	//create the form that asks for the directory name
157
-	$new_folder_text = '<form action="'.api_get_self().'" method="POST">';
158
-	$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
159
-	$new_folder_text .= get_lang('NewDir') .' ';
160
-	$new_folder_text .= '<input type="text" name="dirname"/>';
161
-	$new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>';
162
-	$new_folder_text .= '</form>';
163
-	//show the form
164
-	Display::display_normal_message($new_folder_text);
156
+    //create the form that asks for the directory name
157
+    $new_folder_text = '<form action="'.api_get_self().'" method="POST">';
158
+    $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
159
+    $new_folder_text .= get_lang('NewDir') .' ';
160
+    $new_folder_text .= '<input type="text" name="dirname"/>';
161
+    $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>';
162
+    $new_folder_text .= '</form>';
163
+    //show the form
164
+    Display::display_normal_message($new_folder_text);
165 165
 } else {	//give them a link to create a directory
166 166
 ?>
167 167
 	<p>
Please login to merge, or discard this patch.
main/exercise/hotpotatoes_exercise_result.class.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     //stores the results
15 15
     private $results = array();
16 16
 
17
-	/**
18
-	 * Gets the results of all students (or just one student if access is limited)
19
-	 * @param	string		The document path (for HotPotatoes retrieval)
20
-	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
-	 * @param string $document_path
22
-	 */
23
-	public function getExercisesReporting($document_path, $hotpotato_name)
17
+    /**
18
+     * Gets the results of all students (or just one student if access is limited)
19
+     * @param	string		The document path (for HotPotatoes retrieval)
20
+     * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+     * @param string $document_path
22
+     */
23
+    public function getExercisesReporting($document_path, $hotpotato_name)
24 24
     {
25
-		$return = array();
25
+        $return = array();
26 26
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
27 27
         $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $hotpotato_name  = Database::escape_string($hotpotato_name);
35 35
 
36 36
         if (!empty($exercise_id)) {
37
-          $session_id_and .= " AND exe_exo_id = $exercise_id ";
37
+            $session_id_and .= " AND exe_exo_id = $exercise_id ";
38 38
         }
39 39
 
40 40
         if (empty($user_id)) {
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         $this->results = $return;
112 112
 
113 113
         return true;
114
-	}
114
+    }
115 115
 
116 116
 
117
-	/**
118
-	 * Exports the complete report as a CSV file
119
-	 * @param	string		Document path inside the document tool
120
-	 * @param	integer		Optional user ID
121
-	 * @param	boolean		Whether to include user fields or not
122
-	 * @return	boolean		False on error
123
-	 */
124
-	public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
117
+    /**
118
+     * Exports the complete report as a CSV file
119
+     * @param	string		Document path inside the document tool
120
+     * @param	integer		Optional user ID
121
+     * @param	boolean		Whether to include user fields or not
122
+     * @return	boolean		False on error
123
+     */
124
+    public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
125 125
     {
126
-		global $charset;
127
-		$this->getExercisesReporting($document_path, $hotpotato_name);
128
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
129
-		if (!empty($user_id)) {
130
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
-		}
132
-		$data = '';
126
+        global $charset;
127
+        $this->getExercisesReporting($document_path, $hotpotato_name);
128
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
129
+        if (!empty($user_id)) {
130
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
+        }
132
+        $data = '';
133 133
 
134 134
         if (api_is_western_name_order()) {
135 135
             if(!empty($this->results[0]['first_name'])) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         }
149 149
         $data .= get_lang('Email').';';
150 150
 
151
-		/*if ($export_user_fields) {
151
+        /*if ($export_user_fields) {
152 152
 			//show user fields section with a big th colspan that spans over all fields
153 153
 			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
154 154
 			$num = count($extra_user_fields);
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 			}
158 158
 		}*/
159 159
 
160
-		$data .= get_lang('Title').';';
161
-		$data .= get_lang('StartDate').';';
162
-		$data .= get_lang('Score').';';
163
-		$data .= get_lang('Total').';';
164
-		$data .= "\n";
160
+        $data .= get_lang('Title').';';
161
+        $data .= get_lang('StartDate').';';
162
+        $data .= get_lang('Score').';';
163
+        $data .= get_lang('Total').';';
164
+        $data .= "\n";
165 165
 
166
-		//results
167
-		foreach($this->results as $row) {
166
+        //results
167
+        foreach($this->results as $row) {
168 168
             if (api_is_western_name_order()) {
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
169
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
171 171
             } else {
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
172
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
174 174
             }
175 175
 
176 176
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
177 177
 
178
-			/*if ($export_user_fields) {
178
+            /*if ($export_user_fields) {
179 179
 				//show user fields data, if any, for this user
180 180
 				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
181 181
 				foreach($user_fields_values as $value) {
@@ -183,40 +183,40 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 			}*/
185 185
 
186
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
189
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
190
-			$data .= "\n";
191
-		}
192
-
193
-		//output the results
194
-		$len = strlen($data);
195
-		header('Content-type: application/octet-stream');
196
-		header('Content-Type: application/force-download');
197
-		header('Content-length: '.$len);
198
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
-			header('Content-Disposition: filename= '.$filename);
200
-		} else {
201
-			header('Content-Disposition: attachment; filename= '.$filename);
202
-		}
203
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
-			header('Pragma: ');
205
-			header('Cache-Control: ');
206
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
-		}
208
-		header('Content-Description: '.$filename);
209
-		header('Content-transfer-encoding: binary');
210
-		// @todo add this utf-8 header for all csv files
211
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
-		echo $data;
213
-		return true;
214
-	}
215
-
216
-	/**
217
-	 * Exports the complete report as an XLS file
218
-	 * @return	boolean		False on error
219
-	 */
186
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
+            $data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
189
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
190
+            $data .= "\n";
191
+        }
192
+
193
+        //output the results
194
+        $len = strlen($data);
195
+        header('Content-type: application/octet-stream');
196
+        header('Content-Type: application/force-download');
197
+        header('Content-length: '.$len);
198
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
+            header('Content-Disposition: filename= '.$filename);
200
+        } else {
201
+            header('Content-Disposition: attachment; filename= '.$filename);
202
+        }
203
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
+            header('Pragma: ');
205
+            header('Cache-Control: ');
206
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
+        }
208
+        header('Content-Description: '.$filename);
209
+        header('Content-transfer-encoding: binary');
210
+        // @todo add this utf-8 header for all csv files
211
+        echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
+        echo $data;
213
+        return true;
214
+    }
215
+
216
+    /**
217
+     * Exports the complete report as an XLS file
218
+     * @return	boolean		False on error
219
+     */
220 220
     public function exportCompleteReportXLS(
221 221
         $document_path = '',
222 222
         $user_id = null,
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
         $exercise_id = 0,
226 226
         $hotpotato_name = null
227 227
     ) {
228
-		global $charset;
229
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
231
-		if (!empty($user_id)) {
232
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
-		}
228
+        global $charset;
229
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
231
+        if (!empty($user_id)) {
232
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
+        }
234 234
 
235 235
         $spreadsheet = new PHPExcel();
236 236
         $spreadsheet->setActiveSheetIndex(0);
237 237
         $worksheet = $spreadsheet->getActiveSheet();
238 238
 
239 239
 
240
-		$line = 0;
241
-		$column = 0; //skip the first column (row titles)
240
+        $line = 0;
241
+        $column = 0; //skip the first column (row titles)
242 242
 
243
-		// check if exists column 'user'
244
-		$with_column_user = false;
245
-		foreach ($this->results as $result) {
246
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
-				$with_column_user = true;
248
-				break;
249
-			}
250
-		}
243
+        // check if exists column 'user'
244
+        $with_column_user = false;
245
+        foreach ($this->results as $result) {
246
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
+                $with_column_user = true;
248
+                break;
249
+            }
250
+        }
251 251
 
252
-		if ($with_column_user) {
253
-		    $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email'));
254
-		    $column++;
252
+        if ($with_column_user) {
253
+            $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email'));
254
+            $column++;
255 255
 
256 256
             if (api_is_western_name_order()) {
257
-    			$worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
258
-    			$column++;
257
+                $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
258
+                $column++;
259 259
                 $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName'));
260 260
                 $column++;
261 261
             } else {
@@ -264,36 +264,36 @@  discard block
 block discarded – undo
264 264
                 $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
265 265
                 $column++;
266 266
             }
267
-		}
267
+        }
268 268
 
269
-		if ($export_user_fields) {
270
-			//show user fields section with a big th colspan that spans over all fields
271
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
269
+        if ($export_user_fields) {
270
+            //show user fields section with a big th colspan that spans over all fields
271
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
272 272
 
273
-			//show the fields names for user fields
274
-			foreach ($extra_user_fields as $field) {
275
-				$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
276
-				$column++;
277
-			}
278
-		}
273
+            //show the fields names for user fields
274
+            foreach ($extra_user_fields as $field) {
275
+                $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
276
+                $column++;
277
+            }
278
+        }
279 279
 
280
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title'));
281
-		$column++;
282
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate'));
280
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title'));
281
+        $column++;
282
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate'));
283 283
         $column++;
284 284
         $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate'));
285 285
         $column++;
286 286
         $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
287
-		$column++;
288
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score'));
289
-		$column++;
290
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total'));
291
-		$column++;
287
+        $column++;
288
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score'));
289
+        $column++;
290
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total'));
291
+        $column++;
292 292
         $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status'));
293
-		$line++;
293
+        $line++;
294 294
 
295
-		foreach ($this->results as $row) {
296
-			$column = 0;
295
+        foreach ($this->results as $row) {
296
+            $column = 0;
297 297
 
298 298
             if ($with_column_user) {
299 299
                 $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
                     $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
311 311
                     $column++;
312 312
                 }
313
-			}
313
+            }
314 314
 
315
-			if ($export_user_fields) {
316
-				//show user fields data, if any, for this user
317
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
-				foreach($user_fields_values as $value) {
319
-					$worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320
-					$column++;
321
-				}
322
-			}
315
+            if ($export_user_fields) {
316
+                //show user fields data, if any, for this user
317
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
+                foreach($user_fields_values as $value) {
319
+                    $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320
+                    $column++;
321
+                }
322
+            }
323 323
 
324
-			$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
325
-			$column++;
326
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']);
324
+            $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
325
+            $column++;
326
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']);
327 327
             $column++;
328
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']);
328
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']);
329
+            $column++;
330
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']);
331
+            $column++;
332
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']);
333
+            $column++;
334
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']);
329 335
             $column++;
330
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']);
331
-			$column++;
332
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']);
333
-			$column++;
334
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']);
335
-			$column++;
336 336
             $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']);
337
-			$line++;
338
-		}
337
+            $line++;
338
+        }
339 339
 
340 340
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
341 341
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
342 342
         $writer->save($file);
343 343
         DocumentManager::file_send_for_download($file, true, $filename);
344 344
 
345
-		return true;
346
-	}
345
+        return true;
346
+    }
347 347
 }
Please login to merge, or discard this patch.