Completed
Push — 1.11.x ( 3033bc...afd08d )
by José
168:58 queued 132:03
created
main/exercise/hotspot.class.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,81 +12,81 @@  discard block
 block discarded – undo
12 12
  **/
13 13
 class HotSpot extends Question
14 14
 {
15
-	public static $typePicture = 'hotspot.png';
16
-	public static $explanationLangVar = 'HotSpot';
15
+    public static $typePicture = 'hotspot.png';
16
+    public static $explanationLangVar = 'HotSpot';
17 17
 
18 18
     /**
19 19
      * HotSpot constructor.
20 20
      */
21
-	public function __construct()
22
-	{
23
-		parent::__construct();
24
-		$this->type = HOT_SPOT;
25
-	}
26
-
27
-	public function display()
28
-	{
29
-	}
30
-
31
-	/**
32
-	 * @param FormValidator $form
33
-	 * @param int $fck_config
34
-	 */
35
-	public function createForm (&$form, $fck_config=0)
36
-	{
37
-		parent::createForm($form, $fck_config);
38
-
39
-		if (!isset($_GET['editQuestion'])) {
40
-			$form->addElement('file','imageUpload',array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')) );
41
-
42
-			// setting the save button here and not in the question class.php
43
-			// Saving a question
44
-			$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
45
-			//$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
46
-			$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
47
-			$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
48
-		} else {
49
-			// setting the save button here and not in the question class.php
50
-			// Editing a question
51
-			$form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
52
-		}
53
-	}
54
-
55
-	/**
56
-	 * @param FormValidator $form
57
-	 * @param null $objExercise
58
-	 * @return null|false
59
-	 */
60
-	public function processCreation($form, $objExercise = null)
61
-	{
62
-		$file_info = $form->getSubmitValue('imageUpload');
63
-		$_course = api_get_course_info();
64
-		parent::processCreation($form, $objExercise);
65
-
66
-		if(!empty($file_info['tmp_name'])) {
67
-			$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
68
-			$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
69
-			$picturePath   = $documentPath.'/images';
70
-
71
-			// fixed width ang height
72
-			if (file_exists($picturePath.'/'.$this->picture)) {
73
-				$this->resizePicture('width', 800);
74
-				$this->save();
75
-			} else {
76
-				return false;
77
-			}
78
-		}
79
-	}
80
-
81
-	function createAnswersForm ($form)
82
-	{
83
-		// nothing
84
-	}
85
-
86
-	function processAnswersCreation ($form)
87
-	{
88
-		// nothing
89
-	}
21
+    public function __construct()
22
+    {
23
+        parent::__construct();
24
+        $this->type = HOT_SPOT;
25
+    }
26
+
27
+    public function display()
28
+    {
29
+    }
30
+
31
+    /**
32
+     * @param FormValidator $form
33
+     * @param int $fck_config
34
+     */
35
+    public function createForm (&$form, $fck_config=0)
36
+    {
37
+        parent::createForm($form, $fck_config);
38
+
39
+        if (!isset($_GET['editQuestion'])) {
40
+            $form->addElement('file','imageUpload',array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')) );
41
+
42
+            // setting the save button here and not in the question class.php
43
+            // Saving a question
44
+            $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
45
+            //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
46
+            $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
47
+            $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
48
+        } else {
49
+            // setting the save button here and not in the question class.php
50
+            // Editing a question
51
+            $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
52
+        }
53
+    }
54
+
55
+    /**
56
+     * @param FormValidator $form
57
+     * @param null $objExercise
58
+     * @return null|false
59
+     */
60
+    public function processCreation($form, $objExercise = null)
61
+    {
62
+        $file_info = $form->getSubmitValue('imageUpload');
63
+        $_course = api_get_course_info();
64
+        parent::processCreation($form, $objExercise);
65
+
66
+        if(!empty($file_info['tmp_name'])) {
67
+            $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
68
+            $documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
69
+            $picturePath   = $documentPath.'/images';
70
+
71
+            // fixed width ang height
72
+            if (file_exists($picturePath.'/'.$this->picture)) {
73
+                $this->resizePicture('width', 800);
74
+                $this->save();
75
+            } else {
76
+                return false;
77
+            }
78
+        }
79
+    }
80
+
81
+    function createAnswersForm ($form)
82
+    {
83
+        // nothing
84
+    }
85
+
86
+    function processAnswersCreation ($form)
87
+    {
88
+        // nothing
89
+    }
90 90
 }
91 91
 
92 92
 /**
@@ -94,38 +94,38 @@  discard block
 block discarded – undo
94 94
  */
95 95
 class HotSpotDelineation extends HotSpot
96 96
 {
97
-	public static $typePicture = 'hotspot-delineation.png';
98
-	public static $explanationLangVar = 'HotspotDelineation';
97
+    public static $typePicture = 'hotspot-delineation.png';
98
+    public static $explanationLangVar = 'HotspotDelineation';
99 99
 
100 100
     /**
101 101
      * HotSpotDelineation constructor.
102 102
      */
103
-	public function __construct()
104
-	{
105
-		parent::__construct();
106
-		$this -> type = HOT_SPOT_DELINEATION;
107
-
108
-	}
109
-
110
-	function createForm(&$form, $fck_config=0)
111
-	{
112
-		parent::createForm ($form, $fck_config);
113
-	}
114
-
115
-	function processCreation ($form, $objExercise = null)
116
-	{
117
-		$file_info = $form -> getSubmitValue('imageUpload');
118
-		parent::processCreation ($form, $objExercise);
119
-	}
120
-
121
-	function createAnswersForm ($form)
122
-	{
123
-		parent::createAnswersForm ($form);
124
-	}
125
-
126
-	function processAnswersCreation ($form)
127
-	{
128
-		parent::processAnswersCreation ($form);
129
-	}
103
+    public function __construct()
104
+    {
105
+        parent::__construct();
106
+        $this -> type = HOT_SPOT_DELINEATION;
107
+
108
+    }
109
+
110
+    function createForm(&$form, $fck_config=0)
111
+    {
112
+        parent::createForm ($form, $fck_config);
113
+    }
114
+
115
+    function processCreation ($form, $objExercise = null)
116
+    {
117
+        $file_info = $form -> getSubmitValue('imageUpload');
118
+        parent::processCreation ($form, $objExercise);
119
+    }
120
+
121
+    function createAnswersForm ($form)
122
+    {
123
+        parent::createAnswersForm ($form);
124
+    }
125
+
126
+    function processAnswersCreation ($form)
127
+    {
128
+        parent::processAnswersCreation ($form);
129
+    }
130 130
 }
131 131
 
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.
main/user/subscribe_user.php 1 patch
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 // Access restriction
26 26
 if (!api_is_allowed_to_edit()) {
27
-	 api_not_allowed(true);
27
+        api_not_allowed(true);
28 28
 }
29 29
 
30 30
 $tool_name = get_lang("SubscribeUserToCourse");
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 $courseInfo = api_get_course_info();
35 35
 
36 36
 if ($type == COURSEMANAGER) {
37
-	$tool_name = get_lang("SubscribeUserToCourseAsTeacher");
37
+    $tool_name = get_lang("SubscribeUserToCourseAsTeacher");
38 38
 }
39 39
 
40 40
 //extra entries in breadcrumb
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         "url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(),
48 48
         "name" => $tool_name,
49 49
     );
50
-	$tool_name = get_lang('SearchResults');
50
+    $tool_name = get_lang('SearchResults');
51 51
 }
52 52
 
53 53
 $current_session_id = api_get_session_id();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         );
77 77
     }
78 78
 
79
-	$user_id_temp = $_SESSION['session_user_id'];
79
+    $user_id_temp = $_SESSION['session_user_id'];
80 80
 
81 81
     if (is_array($user_id_temp)) {
82 82
         $counter = count($user_id_temp);
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 
170 170
             header('Location:'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type);
171 171
             exit;
172
-			break;
173
-	}
172
+            break;
173
+    }
174 174
 }
175 175
 
176 176
 if (!empty($_SESSION['session_user_id'])) {
177
-	unset($_SESSION['session_user_id']);
177
+    unset($_SESSION['session_user_id']);
178 178
 }
179 179
 
180 180
 if (!empty($_SESSION['session_user_name'])) {
181
-	unset($_SESSION['session_user_name']);
181
+    unset($_SESSION['session_user_name']);
182 182
 }
183 183
 
184 184
 $is_western_name_order = api_is_western_name_order();
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 
187 187
 // Build table
188 188
 $table = new SortableTable(
189
-	'subscribe_users',
190
-	'get_number_of_users',
191
-	'get_user_data',
192
-	($is_western_name_order xor $sort_by_first_name) ? 3 : 2
189
+    'subscribe_users',
190
+    'get_number_of_users',
191
+    'get_user_data',
192
+    ($is_western_name_order xor $sort_by_first_name) ? 3 : 2
193 193
 );
194 194
 $parameters['keyword'] = $keyword;
195 195
 $parameters['type'] = $type;
@@ -271,18 +271,18 @@  discard block
 block discarded – undo
271 271
  */
272 272
 function get_number_of_users()
273 273
 {
274
-	// Database table definition
275
-	$user_table = Database::get_main_table(TABLE_MAIN_USER);
276
-	$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
277
-	$tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
278
-	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
274
+    // Database table definition
275
+    $user_table = Database::get_main_table(TABLE_MAIN_USER);
276
+    $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
277
+    $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
278
+    $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
279 279
 
280 280
     $courseCode = api_get_course_id();
281 281
     $sessionId = api_get_session_id();
282 282
 
283
-	if (isset($_REQUEST['type']) && $_REQUEST['type'] === 'teacher') {
284
-		if (api_get_session_id() != 0) {
285
-			$sql = "SELECT COUNT(u.user_id)
283
+    if (isset($_REQUEST['type']) && $_REQUEST['type'] === 'teacher') {
284
+        if (api_get_session_id() != 0) {
285
+            $sql = "SELECT COUNT(u.user_id)
286 286
 					FROM $user_table u
287 287
 					LEFT JOIN $tbl_session_rel_course_user cu
288 288
 					ON
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 						u.status = 1 AND
295 295
 						(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
296 296
 
297
-			if (api_is_multiple_url_enabled()) {
298
-				$url_access_id = api_get_current_access_url_id();
299
-				if ($url_access_id !=-1) {
300
-					$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
301
-					$sql = "SELECT COUNT(u.user_id)
297
+            if (api_is_multiple_url_enabled()) {
298
+                $url_access_id = api_get_current_access_url_id();
299
+                if ($url_access_id !=-1) {
300
+                    $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
301
+                    $sql = "SELECT COUNT(u.user_id)
302 302
 							FROM $user_table u
303 303
 							LEFT JOIN $tbl_session_rel_course_user cu
304 304
 							ON
@@ -312,34 +312,34 @@  discard block
 block discarded – undo
312 312
 								u.status = 1 AND
313 313
 								(u.official_code <> 'ADMIN' OR u.official_code IS NULL)
314 314
 							";
315
-				}
316
-			}
317
-		} else {
318
-			$sql = "SELECT COUNT(u.user_id)
315
+                }
316
+            }
317
+        } else {
318
+            $sql = "SELECT COUNT(u.user_id)
319 319
 					FROM $user_table u
320 320
 					LEFT JOIN $course_user_table cu
321 321
 					ON u.user_id = cu.user_id and c_id='".api_get_course_int_id()."'
322 322
 				    WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
323 323
 
324
-			if (api_is_multiple_url_enabled()) {
325
-				$url_access_id = api_get_current_access_url_id();
326
-				if ($url_access_id !=-1) {
327
-					$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
324
+            if (api_is_multiple_url_enabled()) {
325
+                $url_access_id = api_get_current_access_url_id();
326
+                if ($url_access_id !=-1) {
327
+                    $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
328 328
 
329
-					$sql = "SELECT COUNT(u.user_id)
329
+                    $sql = "SELECT COUNT(u.user_id)
330 330
 						FROM $user_table u
331 331
 						LEFT JOIN $course_user_table cu
332 332
 						ON u.user_id = cu.user_id AND c_id='".api_get_course_int_id()."'
333 333
 						INNER JOIN  $tbl_url_rel_user as url_rel_user
334 334
 						ON (url_rel_user.user_id = u.user_id)
335 335
 						WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
336
-				}
337
-			}
338
-		}
339
-	} else {
340
-		// students
341
-		if (api_get_session_id() != 0) {
342
-			$sql = "SELECT COUNT(u.user_id)
336
+                }
337
+            }
338
+        }
339
+    } else {
340
+        // students
341
+        if (api_get_session_id() != 0) {
342
+            $sql = "SELECT COUNT(u.user_id)
343 343
 					FROM $user_table u
344 344
 					LEFT JOIN $tbl_session_rel_course_user cu
345 345
 					ON
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 						u.status<>".DRH." AND
352 352
 						(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
353 353
 
354
-			if (api_is_multiple_url_enabled()) {
355
-				$url_access_id = api_get_current_access_url_id();
356
-				if ($url_access_id !=-1) {
357
-					$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
358
-					$sql = "SELECT COUNT(u.user_id)
354
+            if (api_is_multiple_url_enabled()) {
355
+                $url_access_id = api_get_current_access_url_id();
356
+                if ($url_access_id !=-1) {
357
+                    $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
358
+                    $sql = "SELECT COUNT(u.user_id)
359 359
 							FROM $user_table u
360 360
 							LEFT JOIN $tbl_session_rel_course_user cu
361 361
 							ON
@@ -369,21 +369,21 @@  discard block
 block discarded – undo
369 369
 								u.status<>".DRH." AND
370 370
 								access_url_id= $url_access_id AND
371 371
 								(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
372
-				}
373
-			}
374
-		} else {
375
-			$sql = "SELECT COUNT(u.user_id)
372
+                }
373
+            }
374
+        } else {
375
+            $sql = "SELECT COUNT(u.user_id)
376 376
 					FROM $user_table u
377 377
 					LEFT JOIN $course_user_table cu
378 378
 					ON u.user_id = cu.user_id AND c_id='".api_get_course_int_id()."'";
379 379
 
380
-			// we change the SQL when we have a filter
381
-			if (isset($_GET['subscribe_user_filter_value']) &&
380
+            // we change the SQL when we have a filter
381
+            if (isset($_GET['subscribe_user_filter_value']) &&
382 382
                 !empty($_GET['subscribe_user_filter_value']) &&
383 383
                 api_get_setting('ProfilingFilterAddingUsers') == 'true'
384 384
             ){
385
-				$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
386
-				$sql .=	"
385
+                $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
386
+                $sql .=	"
387 387
 					LEFT JOIN $table_user_field_values field_values
388 388
 					ON field_values.item_id = u.user_id
389 389
 					WHERE
@@ -392,32 +392,32 @@  discard block
 block discarded – undo
392 392
 						field_values.field_id = '".intval($field_identification[0])."' AND
393 393
 						field_values.value = '".Database::escape_string($field_identification[1])."'
394 394
 					";
395
-			} else	{
396
-				$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
397
-			}
395
+            } else	{
396
+                $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
397
+            }
398 398
 
399
-			if (api_is_multiple_url_enabled()) {
400
-				$url_access_id = api_get_current_access_url_id();
399
+            if (api_is_multiple_url_enabled()) {
400
+                $url_access_id = api_get_current_access_url_id();
401 401
 
402
-				if ($url_access_id !=-1) {
402
+                if ($url_access_id !=-1) {
403 403
 
404
-					$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
404
+                    $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
405 405
 
406
-					$sql = "SELECT COUNT(u.user_id)
406
+                    $sql = "SELECT COUNT(u.user_id)
407 407
 							FROM $user_table u
408 408
 							LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and c_id='".api_get_course_int_id()."'
409 409
 							INNER JOIN  $tbl_url_rel_user as url_rel_user
410 410
 							ON (url_rel_user.user_id = u.user_id)
411 411
 							WHERE cu.user_id IS NULL AND access_url_id= $url_access_id AND u.status<>".DRH." ";
412
-				}
413
-			}
414
-		}
415
-	}
416
-
417
-	// when there is a keyword then we are searching and we have to change the SQL statement
418
-	if (isset($_GET['keyword']) AND !empty($_GET['keyword'])) {
419
-		$keyword = Database::escape_string(trim($_REQUEST['keyword']));
420
-		$sql .= " AND (
412
+                }
413
+            }
414
+        }
415
+    }
416
+
417
+    // when there is a keyword then we are searching and we have to change the SQL statement
418
+    if (isset($_GET['keyword']) AND !empty($_GET['keyword'])) {
419
+        $keyword = Database::escape_string(trim($_REQUEST['keyword']));
420
+        $sql .= " AND (
421 421
 		    firstname LIKE '%".$keyword."%' OR
422 422
 		    lastname LIKE '%".$keyword."%' OR
423 423
 		    email LIKE '%".$keyword."%' OR
@@ -425,37 +425,37 @@  discard block
 block discarded – undo
425 425
 		    official_code LIKE '%".$keyword."%'
426 426
         )";
427 427
 
428
-		// we also want to search for users who have something in their profile fields that matches the keyword
429
-		if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
430
-			$additional_users = search_additional_profile_fields($keyword);
431
-		}
428
+        // we also want to search for users who have something in their profile fields that matches the keyword
429
+        if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
430
+            $additional_users = search_additional_profile_fields($keyword);
431
+        }
432 432
 
433
-		// getting all the users of the course (to make sure that we do not display users that are already in the course)
434
-		if (!empty($_SESSION["id_session"])) {
433
+        // getting all the users of the course (to make sure that we do not display users that are already in the course)
434
+        if (!empty($_SESSION["id_session"])) {
435 435
             $a_course_users = CourseManager:: get_user_list_from_course_code(
436 436
                 $courseCode,
437 437
                 $sessionId
438 438
             );
439
-		} else {
439
+        } else {
440 440
             $a_course_users = CourseManager:: get_user_list_from_course_code(
441 441
                 $courseCode,
442 442
                 0
443 443
             );
444
-	    }
445
-		foreach ($a_course_users as $user_id=>$course_user) {
446
-			$users_of_course[] = $course_user['user_id'];
447
-	    }
448
-	}
444
+        }
445
+        foreach ($a_course_users as $user_id=>$course_user) {
446
+            $users_of_course[] = $course_user['user_id'];
447
+        }
448
+    }
449 449
     $sql .=" AND u.status <> ".ANONYMOUS." ";
450
-	$res = Database::query($sql);
450
+    $res = Database::query($sql);
451 451
     $count_user = 0;
452 452
 
453 453
     if ($res) {
454
-	   $row = Database::fetch_row($res);
455
-	   $count_user = $row[0];
456
-	}
454
+        $row = Database::fetch_row($res);
455
+        $count_user = $row[0];
456
+    }
457 457
 
458
-	return $count_user;
458
+    return $count_user;
459 459
 }
460 460
 /**
461 461
  * Get the users to display on the current page.
@@ -465,17 +465,17 @@  discard block
 block discarded – undo
465 465
     $url_access_id = api_get_current_access_url_id();
466 466
     $course_code = api_get_course_id();
467 467
     $session_id = api_get_session_id();
468
-	$courseId = api_get_course_int_id();
468
+    $courseId = api_get_course_int_id();
469 469
 
470
-	// Database table definitions
471
-	$user_table = Database::get_main_table(TABLE_MAIN_USER);
472
-	$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
473
-	$tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
474
-	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
470
+    // Database table definitions
471
+    $user_table = Database::get_main_table(TABLE_MAIN_USER);
472
+    $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
473
+    $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
474
+    $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
475 475
     $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
476 476
 
477 477
     // adding teachers
478
-	$is_western_name_order = api_is_western_name_order();
478
+    $is_western_name_order = api_is_western_name_order();
479 479
 
480 480
     if (api_get_setting('show_email_addresses') == 'true') {
481 481
 
@@ -500,10 +500,10 @@  discard block
 block discarded – undo
500 500
                 u.active               AS col4,
501 501
                 u.user_id              AS col5";
502 502
     }
503
-	if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) {
504
-		// adding a teacher through a session
505
-		if (!empty($session_id)) {
506
-			$sql = "SELECT $select_fields
503
+    if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) {
504
+        // adding a teacher through a session
505
+        if (!empty($session_id)) {
506
+            $sql = "SELECT $select_fields
507 507
 					FROM $user_table u
508 508
 					LEFT JOIN $tbl_session_rel_course_user cu
509 509
 					ON
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
                     INNER JOIN  $tbl_url_rel_user as url_rel_user
514 514
                     ON (url_rel_user.user_id = u.user_id) ";
515 515
 
516
-			// applying the filter of the additional user profile fields
517
-			if (isset($_GET['subscribe_user_filter_value']) &&
518
-				!empty($_GET['subscribe_user_filter_value']) &&
519
-				api_get_setting('ProfilingFilterAddingUsers') == 'true'
520
-			) {
521
-				$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
522
-				$sql .=	"
516
+            // applying the filter of the additional user profile fields
517
+            if (isset($_GET['subscribe_user_filter_value']) &&
518
+                !empty($_GET['subscribe_user_filter_value']) &&
519
+                api_get_setting('ProfilingFilterAddingUsers') == 'true'
520
+            ) {
521
+                $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
522
+                $sql .=	"
523 523
 					LEFT JOIN $table_user_field_values field_values
524 524
 						ON field_values.item_id = u.user_id
525 525
 					WHERE
@@ -528,53 +528,53 @@  discard block
 block discarded – undo
528 528
 						(u.official_code <> 'ADMIN' OR u.official_code IS NULL) AND
529 529
 						field_values.field_id = '".intval($field_identification[0])."' AND
530 530
 						field_values.value = '".Database::escape_string($field_identification[1])."'";
531
-			} else {
532
-				$sql .=	"WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
533
-			}
531
+            } else {
532
+                $sql .=	"WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
533
+            }
534 534
 
535 535
             $sql .=	" AND access_url_id= $url_access_id";
536 536
 
537
-		} else {
538
-		     // adding a teacher NOT through a session
539
-			$sql = "SELECT $select_fields
537
+        } else {
538
+                // adding a teacher NOT through a session
539
+            $sql = "SELECT $select_fields
540 540
                     FROM $user_table u
541 541
                     LEFT JOIN $course_user_table cu
542 542
                     ON u.user_id = cu.user_id AND c_id = '".$courseId."'";
543 543
 
544
-				// applying the filter of the additional user profile fields
545
-				if (isset($_GET['subscribe_user_filter_value']) &&
546
-					!empty($_GET['subscribe_user_filter_value']) &&
547
-					api_get_setting('ProfilingFilterAddingUsers') == 'true'
548
-				) {
549
-					$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
550
-					$sql .=	"
544
+                // applying the filter of the additional user profile fields
545
+                if (isset($_GET['subscribe_user_filter_value']) &&
546
+                    !empty($_GET['subscribe_user_filter_value']) &&
547
+                    api_get_setting('ProfilingFilterAddingUsers') == 'true'
548
+                ) {
549
+                    $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
550
+                    $sql .=	"
551 551
 						LEFT JOIN $table_user_field_values field_values
552 552
 							ON field_values.item_id = u.user_id
553 553
 						WHERE
554 554
 							cu.user_id IS NULL AND u.status<>".DRH." AND
555 555
 							field_values.field_id = '".intval($field_identification[0])."' AND
556 556
 							field_values.value = '".Database::escape_string($field_identification[1])."'";
557
-				} else	{
558
-					$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
559
-				}
560
-
561
-				// adding a teacher NOT trough a session on a portal with multiple URLs
562
-				if (api_is_multiple_url_enabled()) {
563
-					if ($url_access_id !=-1) {
564
-						$sql = "SELECT $select_fields
557
+                } else	{
558
+                    $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
559
+                }
560
+
561
+                // adding a teacher NOT trough a session on a portal with multiple URLs
562
+                if (api_is_multiple_url_enabled()) {
563
+                    if ($url_access_id !=-1) {
564
+                        $sql = "SELECT $select_fields
565 565
 						FROM $user_table u
566 566
 						LEFT JOIN $course_user_table cu
567 567
 						ON u.user_id = cu.user_id and c_id='".$courseId."'
568 568
 						INNER JOIN  $tbl_url_rel_user as url_rel_user
569 569
 						ON (url_rel_user.user_id = u.user_id) ";
570 570
 
571
-					// applying the filter of the additional user profile fields
572
-					if (isset($_GET['subscribe_user_filter_value']) &&
573
-						!empty($_GET['subscribe_user_filter_value']) &&
574
-						api_get_setting('ProfilingFilterAddingUsers') == 'true'
575
-					){
576
-						$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
577
-						$sql .=	"
571
+                    // applying the filter of the additional user profile fields
572
+                    if (isset($_GET['subscribe_user_filter_value']) &&
573
+                        !empty($_GET['subscribe_user_filter_value']) &&
574
+                        api_get_setting('ProfilingFilterAddingUsers') == 'true'
575
+                    ){
576
+                        $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
577
+                        $sql .=	"
578 578
 							LEFT JOIN $table_user_field_values field_values
579 579
 								ON field_values.item_id = u.user_id
580 580
 							WHERE
@@ -582,16 +582,16 @@  discard block
 block discarded – undo
582 582
 							 	u.status<>".DRH." AND
583 583
 							 	field_values.field_id = '".intval($field_identification[0])."' AND
584 584
 							 	field_values.value = '".Database::escape_string($field_identification[1])."'";
585
-					} else	{
586
-						$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
587
-					}
588
-				}
589
-			}
590
-		}
591
-	} else {
592
-		// adding a student
593
-		if (!empty($session_id)) {
594
-			$sql = "SELECT $select_fields
585
+                    } else	{
586
+                        $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
587
+                    }
588
+                }
589
+            }
590
+        }
591
+    } else {
592
+        // adding a student
593
+        if (!empty($session_id)) {
594
+            $sql = "SELECT $select_fields
595 595
                     FROM $user_table u
596 596
                     LEFT JOIN $tbl_session_rel_course_user cu
597 597
                     ON
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
                 $sql .=  "AND access_url_id = $url_access_id";
627 627
             }
628 628
 
629
-		} else {
629
+        } else {
630 630
             $sql = "SELECT $select_fields
631 631
                     FROM $user_table u
632 632
                     LEFT JOIN $course_user_table cu
@@ -634,10 +634,10 @@  discard block
 block discarded – undo
634 634
                     	u.user_id = cu.user_id AND
635 635
                     	c_id ='".$courseId."'";
636 636
 
637
-			// applying the filter of the additional user profile fields
638
-			if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){
639
-				$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
640
-				$sql .=	"
637
+            // applying the filter of the additional user profile fields
638
+            if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){
639
+                $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
640
+                $sql .=	"
641 641
 					LEFT JOIN $table_user_field_values field_values
642 642
 						ON field_values.item_id = u.user_id
643 643
 					WHERE
@@ -645,28 +645,28 @@  discard block
 block discarded – undo
645 645
 						u.status<>".DRH." AND
646 646
 						field_values.field_id = '".intval($field_identification[0])."' AND
647 647
 						field_values.value = '".Database::escape_string($field_identification[1])."'";
648
-			} else	{
649
-				$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
650
-			}
648
+            } else	{
649
+                $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
650
+            }
651 651
 
652
-			//showing only the courses of the current Chamilo access_url_id
652
+            //showing only the courses of the current Chamilo access_url_id
653 653
 
654
-			if (api_is_multiple_url_enabled()) {
655
-				if ($url_access_id !=-1) {
656
-					$sql = "SELECT $select_fields
654
+            if (api_is_multiple_url_enabled()) {
655
+                if ($url_access_id !=-1) {
656
+                    $sql = "SELECT $select_fields
657 657
 						FROM $user_table u
658 658
 						LEFT JOIN $course_user_table cu
659 659
 						ON u.user_id = cu.user_id AND c_id='".$courseId."'
660 660
 						INNER JOIN  $tbl_url_rel_user as url_rel_user
661 661
 						ON (url_rel_user.user_id = u.user_id) ";
662 662
 
663
-					// applying the filter of the additional user profile fields
664
-					if (isset($_GET['subscribe_user_filter_value']) &&
665
-						!empty($_GET['subscribe_user_filter_value']) &&
666
-						api_get_setting('ProfilingFilterAddingUsers') == 'true'
667
-					){
668
-						$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
669
-						$sql .=	"
663
+                    // applying the filter of the additional user profile fields
664
+                    if (isset($_GET['subscribe_user_filter_value']) &&
665
+                        !empty($_GET['subscribe_user_filter_value']) &&
666
+                        api_get_setting('ProfilingFilterAddingUsers') == 'true'
667
+                    ){
668
+                        $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
669
+                        $sql .=	"
670 670
 							LEFT JOIN $table_user_field_values field_values
671 671
 								ON field_values.item_id = u.user_id
672 672
 							WHERE
@@ -676,19 +676,19 @@  discard block
 block discarded – undo
676 676
 								field_values.value = '".Database::escape_string($field_identification[1])."' AND
677 677
 								access_url_id = $url_access_id
678 678
                             ";
679
-					} else	{
680
-						$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
681
-					}
682
-				}
683
-			}
684
-		}
685
-	}
686
-
687
-	// adding additional WHERE statements to the SQL for the search functionality
679
+                    } else	{
680
+                        $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
681
+                    }
682
+                }
683
+            }
684
+        }
685
+    }
686
+
687
+    // adding additional WHERE statements to the SQL for the search functionality
688 688
     $additional_users = null;
689
-	if (isset($_REQUEST['keyword'])) {
690
-		$keyword = Database::escape_string(trim($_REQUEST['keyword']));
691
-		$sql .= " AND (
689
+    if (isset($_REQUEST['keyword'])) {
690
+        $keyword = Database::escape_string(trim($_REQUEST['keyword']));
691
+        $sql .= " AND (
692 692
 					firstname LIKE '%".$keyword."%' OR
693 693
 					lastname LIKE '%".$keyword."%' OR
694 694
 					email LIKE '%".$keyword."%' OR
@@ -697,46 +697,46 @@  discard block
 block discarded – undo
697 697
 					)
698 698
 				";
699 699
 
700
-		if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
701
-			// we also want to search for users who have something in
702
-			// their profile fields that matches the keyword
703
-			$additional_users = search_additional_profile_fields($keyword);
704
-		}
705
-
706
-		// getting all the users of the course (to make sure that we do not
707
-		// display users that are already in the course)
708
-		if (!empty($session_id)) {
709
-			$a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id);
710
-		} else {
711
-			$a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0);
712
-	    }
713
-		foreach ($a_course_users as $user_id=>$course_user) {
714
-			$users_of_course[] = $course_user['user_id'];
715
-		}
716
-	}
717
-
718
-	$sql .=" AND u.status != ".ANONYMOUS." ";
719
-
720
-	// Sorting and pagination (used by the sortable table)
721
-	$sql .= " ORDER BY col$column $direction ";
722
-	$sql .= " LIMIT $from,$number_of_items";
723
-
724
-	$res = Database::query($sql);
725
-	$users = array ();
726
-	while ($user = Database::fetch_row($res)) {
727
-		$users[] = $user;
728
-		$_SESSION['session_user_id'][] = $user[0];
729
-		if ($is_western_name_order) {
730
-			$_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]);
731
-		} else {
732
-			$_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]);
733
-		}
734
-	}
735
-	// adding additional users based on the search on the additional profile fields
736
-	if (isset($_REQUEST['keyword'])){
737
-		if (is_array($additional_users)) {
738
-			foreach($additional_users as $additional_user_key=>$additional_user_value){
739
-				if (!in_array($additional_user_key, $_SESSION['session_user_id']) &&
700
+        if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
701
+            // we also want to search for users who have something in
702
+            // their profile fields that matches the keyword
703
+            $additional_users = search_additional_profile_fields($keyword);
704
+        }
705
+
706
+        // getting all the users of the course (to make sure that we do not
707
+        // display users that are already in the course)
708
+        if (!empty($session_id)) {
709
+            $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id);
710
+        } else {
711
+            $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0);
712
+        }
713
+        foreach ($a_course_users as $user_id=>$course_user) {
714
+            $users_of_course[] = $course_user['user_id'];
715
+        }
716
+    }
717
+
718
+    $sql .=" AND u.status != ".ANONYMOUS." ";
719
+
720
+    // Sorting and pagination (used by the sortable table)
721
+    $sql .= " ORDER BY col$column $direction ";
722
+    $sql .= " LIMIT $from,$number_of_items";
723
+
724
+    $res = Database::query($sql);
725
+    $users = array ();
726
+    while ($user = Database::fetch_row($res)) {
727
+        $users[] = $user;
728
+        $_SESSION['session_user_id'][] = $user[0];
729
+        if ($is_western_name_order) {
730
+            $_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]);
731
+        } else {
732
+            $_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]);
733
+        }
734
+    }
735
+    // adding additional users based on the search on the additional profile fields
736
+    if (isset($_REQUEST['keyword'])){
737
+        if (is_array($additional_users)) {
738
+            foreach($additional_users as $additional_user_key=>$additional_user_value){
739
+                if (!in_array($additional_user_key, $_SESSION['session_user_id']) &&
740 740
                     !in_array($additional_user_key,$users_of_course)
741 741
                 ){
742 742
                     $users[] = array(
@@ -748,11 +748,11 @@  discard block
 block discarded – undo
748 748
                         $additional_user_value['col5'],
749 749
                         $additional_user_value['col6'],
750 750
                     );
751
-				}
752
-			}
753
-		}
754
-	}
755
-	return $users;
751
+                }
752
+            }
753
+        }
754
+    }
755
+    return $users;
756 756
 }
757 757
 /**
758 758
 * Returns a mailto-link
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 * @return string HTML-code with a mailto-link
761 761
 */
762 762
 function email_filter($email) {
763
-	return Display :: encrypted_mailto_link($email, $email);
763
+    return Display :: encrypted_mailto_link($email, $email);
764 764
 }
765 765
 /**
766 766
  * Build the reg-column of the table
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
     } else {
774 774
         $type = STUDENT;
775 775
     }
776
-	$result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>';
777
-	return $result;
776
+    $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>';
777
+    return $result;
778 778
 }
779 779
 
780 780
 /**
@@ -788,23 +788,23 @@  discard block
 block discarded – undo
788 788
  */
789 789
 
790 790
 function active_filter($active, $url_params, $row) {
791
-	$_user = api_get_user_info();
792
-	if ($active=='1') {
793
-		$action='AccountActive';
794
-		$image='accept';
795
-	}
796
-
797
-	if ($active=='0') {
798
-		$action='AccountInactive';
799
-		$image='error';
800
-	}
791
+    $_user = api_get_user_info();
792
+    if ($active=='1') {
793
+        $action='AccountActive';
794
+        $image='accept';
795
+    }
796
+
797
+    if ($active=='0') {
798
+        $action='AccountInactive';
799
+        $image='error';
800
+    }
801 801
     $result = null;
802
-	if ($row['0']<>$_user['user_id']) {
803
-	// you cannot lock yourself out otherwise you could disable all the accounts
804
-	// including your own => everybody is locked out and nobody can change it anymore.
805
-		$result = Display::return_icon($image.'.png',  get_lang(ucfirst($action)), array() , ICON_SIZE_TINY);
806
-	}
807
-	return $result;
802
+    if ($row['0']<>$_user['user_id']) {
803
+    // you cannot lock yourself out otherwise you could disable all the accounts
804
+    // including your own => everybody is locked out and nobody can change it anymore.
805
+        $result = Display::return_icon($image.'.png',  get_lang(ucfirst($action)), array() , ICON_SIZE_TINY);
806
+    }
807
+    return $result;
808 808
 }
809 809
 
810 810
 /**
@@ -822,29 +822,29 @@  discard block
 block discarded – undo
822 822
  */
823 823
 function search_additional_profile_fields($keyword)
824 824
 {
825
-	// database table definitions
826
-	$table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
827
-	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
825
+    // database table definitions
826
+    $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
827
+    $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
828 828
     $tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD);
829
-	$table_user = Database::get_main_table(TABLE_MAIN_USER);
829
+    $table_user = Database::get_main_table(TABLE_MAIN_USER);
830 830
 
831
-	// getting the field option text that match this keyword (for radio buttons and checkboxes)
832
-	$sql = "SELECT * FROM $table_user_field_options
831
+    // getting the field option text that match this keyword (for radio buttons and checkboxes)
832
+    $sql = "SELECT * FROM $table_user_field_options
833 833
 	        WHERE display_text LIKE '%".$keyword."%'";
834
-	$result_profiling = Database::query($sql);
835
-	while ($profiling_field_options = Database::fetch_array($result_profiling)) {
836
-		$profiling_field_options_exact_values[] = $profiling_field_options;
837
-	}
834
+    $result_profiling = Database::query($sql);
835
+    while ($profiling_field_options = Database::fetch_array($result_profiling)) {
836
+        $profiling_field_options_exact_values[] = $profiling_field_options;
837
+    }
838 838
     $profiling_field_options_exact_values_sql = '';
839
-	foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){
840
-		$profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') ";
841
-	}
839
+    foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){
840
+        $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') ";
841
+    }
842 842
 
843 843
     $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE;
844 844
 
845
-	// getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword
846
-	// or all the users who have entered the keyword in a free-form field
847
-	$sql = "SELECT
845
+    // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword
846
+    // or all the users who have entered the keyword in a free-form field
847
+    $sql = "SELECT
848 848
 	            user.user_id as col0,
849 849
 	            user.official_code as col1,
850 850
 	            user.lastname as col2,
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
                 user_values.field_id = e.id AND
859 859
                 e.extra_field_type = $extraFieldType AND
860 860
                 (value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")";
861
-	$result = Database::query($sql);
861
+    $result = Database::query($sql);
862 862
     $additional_users = array();
863
-	while ($profiled_users = Database::fetch_array($result)) {
864
-		$additional_users[$profiled_users['col0']] = $profiled_users;
865
-	}
863
+    while ($profiled_users = Database::fetch_array($result)) {
864
+        $additional_users[$profiled_users['col0']] = $profiled_users;
865
+    }
866 866
 
867
-	return $additional_users;
867
+    return $additional_users;
868 868
 }
869 869
 
870 870
 /**
@@ -876,41 +876,41 @@  discard block
 block discarded – undo
876 876
  */
877 877
 function display_extra_profile_fields_filter()
878 878
 {
879
-	// getting all the additional user profile fields
880
-	$extra = UserManager::get_extra_fields(0,50,5,'ASC');
881
-
882
-	$return='<option value="">'.get_lang('SelectFilter').'</option>';
883
-
884
-	// looping through the additional user profile fields
885
-	foreach ($extra as $id => $field_details) {
886
-		// $field_details[2] contains the type of the additional user profile field
887
-		switch ($field_details[2]) {
888
-			// text fields cannot be used as a filter
889
-			case ExtraField::FIELD_TYPE_TEXT:
890
-				break;
891
-			// text area fields cannot be used as a filter
892
-			case ExtraField::FIELD_TYPE_TEXTAREA:
893
-				break;
894
-			case ExtraField::FIELD_TYPE_RADIO:
895
-			case ExtraField::FIELD_TYPE_SELECT:
896
-			case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
897
-				$return .= '<optgroup label="'.$field_details[3].'">';
898
-				foreach($field_details[9] as $option_id => $option_details) {
899
-					if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) {
900
-						$selected = 'selected="selected"';
901
-					} else {
902
-						$selected = false;
903
-					}
904
-					$return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>';
905
-				}
906
-				$return .= '</optgroup>';
907
-				break;
908
-		}
909
-	}
910
-
911
-	echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">';
912
-	echo '	<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />';
913
-	echo   '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>';
914
-	echo   '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>';
915
-	echo '</form>';
879
+    // getting all the additional user profile fields
880
+    $extra = UserManager::get_extra_fields(0,50,5,'ASC');
881
+
882
+    $return='<option value="">'.get_lang('SelectFilter').'</option>';
883
+
884
+    // looping through the additional user profile fields
885
+    foreach ($extra as $id => $field_details) {
886
+        // $field_details[2] contains the type of the additional user profile field
887
+        switch ($field_details[2]) {
888
+            // text fields cannot be used as a filter
889
+            case ExtraField::FIELD_TYPE_TEXT:
890
+                break;
891
+            // text area fields cannot be used as a filter
892
+            case ExtraField::FIELD_TYPE_TEXTAREA:
893
+                break;
894
+            case ExtraField::FIELD_TYPE_RADIO:
895
+            case ExtraField::FIELD_TYPE_SELECT:
896
+            case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
897
+                $return .= '<optgroup label="'.$field_details[3].'">';
898
+                foreach($field_details[9] as $option_id => $option_details) {
899
+                    if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) {
900
+                        $selected = 'selected="selected"';
901
+                    } else {
902
+                        $selected = false;
903
+                    }
904
+                    $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>';
905
+                }
906
+                $return .= '</optgroup>';
907
+                break;
908
+        }
909
+    }
910
+
911
+    echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">';
912
+    echo '	<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />';
913
+    echo   '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>';
914
+    echo   '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>';
915
+    echo '</form>';
916 916
 }
Please login to merge, or discard this patch.
main/document/create_document.php 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 $is_certificate_mode = false;
72 72
 
73 73
 if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
74
-	$is_certificate_mode = true;
74
+    $is_certificate_mode = true;
75 75
 }
76 76
 
77 77
 if ($is_certificate_mode) {
78
-	$nameTools = get_lang('CreateCertificate');
78
+    $nameTools = get_lang('CreateCertificate');
79 79
 } else {
80
-	$nameTools = get_lang('CreateDocument');
80
+    $nameTools = get_lang('CreateDocument');
81 81
 }
82 82
 
83 83
 /*	Constants and variables */
@@ -130,26 +130,26 @@  discard block
 block discarded – undo
130 130
 
131 131
 // Please, do not modify this dirname formatting
132 132
 if (strstr($dir, '..')) {
133
-	$dir = '/';
133
+    $dir = '/';
134 134
 }
135 135
 
136 136
 if ($dir[0] == '.') {
137
-	$dir = substr($dir, 1);
137
+    $dir = substr($dir, 1);
138 138
 }
139 139
 
140 140
 if ($dir[0] != '/') {
141
-	$dir = '/'.$dir;
141
+    $dir = '/'.$dir;
142 142
 }
143 143
 
144 144
 if ($dir[strlen($dir) - 1] != '/') {
145
-	$dir .= '/';
145
+    $dir .= '/';
146 146
 }
147 147
 
148 148
 if ($is_certificate_mode) {
149
-	$document_id 	= DocumentManager::get_document_id(api_get_course_info(), '/certificates');
150
-	$document_data 	= DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
151
-	$folder_id = $document_data['id'];
152
-	$dir = '/certificates/';
149
+    $document_id 	= DocumentManager::get_document_id(api_get_course_info(), '/certificates');
150
+    $document_data 	= DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
151
+    $folder_id = $document_data['id'];
152
+    $dir = '/certificates/';
153 153
 }
154 154
 
155 155
 $doc_tree  = explode('/', $dir);
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 
161 161
     // Level correction for group documents.
162 162
     if (!empty($group_properties['directory'])) {
163
-    	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
163
+        $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
164 164
     }
165 165
 }
166 166
 $relative_url = '';
167 167
 for ($i = 0; $i < ($count_dir); $i++) {
168
-	$relative_url .= '../';
168
+    $relative_url .= '../';
169 169
 }
170 170
 
171 171
 if ($relative_url== '') {
172
-	$relative_url = '/';
172
+    $relative_url = '/';
173 173
 }
174 174
 
175 175
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
     'cols-size' => [2, 10, 0],
182 182
     'FullPage' => true,
183 183
     'InDocument' => true,
184
-	'CreateDocumentDir'    => $relative_url,
185
-	'CreateDocumentWebDir' => (empty($group_properties['directory']))
186
-                        		? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
187
-                        		: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
188
-	'BaseHref'             => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
184
+    'CreateDocumentDir'    => $relative_url,
185
+    'CreateDocumentWebDir' => (empty($group_properties['directory']))
186
+                                ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
187
+                                : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
188
+    'BaseHref'             => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
189 189
 );
190 190
 
191 191
 if ($is_certificate_mode) {
@@ -197,36 +197,36 @@  discard block
 block discarded – undo
197 197
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
198 198
 
199 199
 if (!is_dir($filepath)) {
200
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
201
-	$dir = '/';
200
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
201
+    $dir = '/';
202 202
 }
203 203
 
204 204
 $to_group_id = 0;
205 205
 
206 206
 if (!$is_certificate_mode) {
207
-	if (api_is_in_group()) {
208
-		$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
209
-		$noPHP_SELF = true;
210
-		$to_group_id = api_get_group_id();
211
-		$path = explode('/', $dir);
212
-		if ('/'.$path[1] != $group_properties['directory']) {
213
-			api_not_allowed(true);
214
-		}
215
-	}
216
-	$interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents'));
207
+    if (api_is_in_group()) {
208
+        $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
209
+        $noPHP_SELF = true;
210
+        $to_group_id = api_get_group_id();
211
+        $path = explode('/', $dir);
212
+        if ('/'.$path[1] != $group_properties['directory']) {
213
+            api_not_allowed(true);
214
+        }
215
+    }
216
+    $interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents'));
217 217
 } else {
218
-	$interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
218
+    $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
219 219
 }
220 220
 
221 221
 if (!$is_allowed_in_course) {
222
-	api_not_allowed(true);
222
+    api_not_allowed(true);
223 223
 }
224 224
 
225 225
 if (!($is_allowed_to_edit ||
226 226
     $groupRights ||
227 227
     DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id()))
228 228
 ) {
229
-	api_not_allowed(true);
229
+    api_not_allowed(true);
230 230
 }
231 231
 
232 232
 /*	Header */
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 
235 235
 $display_dir = $dir;
236 236
 if (isset($group_properties)) {
237
-	$display_dir = explode('/', $dir);
238
-	unset($display_dir[0]);
239
-	unset($display_dir[1]);
240
-	$display_dir = implode('/', $display_dir);
237
+    $display_dir = explode('/', $dir);
238
+    unset($display_dir[0]);
239
+    unset($display_dir[1]);
240
+    $display_dir = implode('/', $display_dir);
241 241
 }
242 242
 
243 243
 $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 $form->addElement('header', $nameTools);
255 255
 
256 256
 if ($is_certificate_mode) {//added condition for certicate in gradebook
257
-	$form->addElement('hidden','certificate','true',array('id'=>'certificate'));
258
-	if (isset($_GET['selectcat'])) {
259
-		$form->addElement('hidden','selectcat', $select_cat);
257
+    $form->addElement('hidden','certificate','true',array('id'=>'certificate'));
258
+    if (isset($_GET['selectcat'])) {
259
+        $form->addElement('hidden','selectcat', $select_cat);
260 260
     }
261 261
 }
262 262
 
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 if ($is_certificate_mode) {
292 292
     $form->addText('title', get_lang('CertificateName'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
293 293
 } else {
294
-	$form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
294
+    $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
295 295
 }
296 296
 
297 297
 // Show read-only box only in groups
298 298
 if (!empty($groupId)) {
299
-	$group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
299
+    $group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
300 300
 }
301 301
 $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
302 302
 $form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 // new document created
312 312
 
313 313
 if (!$is_certificate_mode &&
314
-	!DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
314
+    !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
315 315
 ) {
316
-	$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
316
+    $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
317 317
 
318
-	//$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
318
+    //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
319 319
         $parent_select = $form->addSelect('curdirpath', get_lang('DestinationDirectory'),null, array('cols-size' => [2, 10, 0]) );
320
-	// Following two conditions copied from document.inc.php::build_directory_selector()
321
-	$folder_titles = array();
320
+    // Following two conditions copied from document.inc.php::build_directory_selector()
321
+    $folder_titles = array();
322 322
 
323 323
     if (is_array($folders)) {
324 324
         $escaped_folders = array();
@@ -356,22 +356,22 @@  discard block
 block discarded – undo
356 356
         }
357 357
     }
358 358
 
359
-	if (empty($group_dir)) {
360
-		$parent_select -> addOption(get_lang('HomeDirectory'), '/');
361
-		if (is_array($folders)) {
362
-			foreach ($folders as & $folder) {
363
-				//Hide some folders
364
-				if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
359
+    if (empty($group_dir)) {
360
+        $parent_select -> addOption(get_lang('HomeDirectory'), '/');
361
+        if (is_array($folders)) {
362
+            foreach ($folders as & $folder) {
363
+                //Hide some folders
364
+                if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
365 365
                     continue;
366
-				}
367
-				//Admin setting for Hide/Show the folders of all users
368
-				if (api_get_setting('show_users_folders') == 'false' &&
366
+                }
367
+                //Admin setting for Hide/Show the folders of all users
368
+                if (api_get_setting('show_users_folders') == 'false' &&
369 369
                     (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_'))
370 370
                 ){
371
-					continue;
372
-				}
373
-				//Admin setting for Hide/Show Default folders to all users
374
-				if (api_get_setting('show_default_folders') == 'false' &&
371
+                    continue;
372
+                }
373
+                //Admin setting for Hide/Show Default folders to all users
374
+                if (api_get_setting('show_default_folders') == 'false' &&
375 375
                     (
376 376
                         $folder == '/images' ||
377 377
                         $folder == '/flash' ||
@@ -381,82 +381,82 @@  discard block
 block discarded – undo
381 381
                         $folder == '/video/flv'
382 382
                     )
383 383
                 ){
384
-					continue;
385
-				}
386
-				//Admin setting for Hide/Show chat history folder
387
-				if (api_get_setting('show_chat_folder') == 'false' &&
384
+                    continue;
385
+                }
386
+                //Admin setting for Hide/Show chat history folder
387
+                if (api_get_setting('show_chat_folder') == 'false' &&
388 388
                     $folder=='/chat_files'
389 389
                 ){
390
-					continue;
391
-				}
390
+                    continue;
391
+                }
392 392
 
393
-				$selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
394
-				$path_parts = explode('/', $folder);
395
-				$folder_titles[$folder] = cut($folder_titles[$folder], 80);
393
+                $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
394
+                $path_parts = explode('/', $folder);
395
+                $folder_titles[$folder] = cut($folder_titles[$folder], 80);
396 396
                 $space_counter =count($path_parts) - 2;
397 397
                 if ($space_counter > 0) {
398 398
                     $label = str_repeat('&nbsp;&nbsp;&nbsp;', $space_counter).' &mdash; '.$folder_titles[$folder];
399 399
                 } else {
400 400
                     $label = ' &mdash; '.$folder_titles[$folder];
401 401
                 }
402
-				$parent_select -> addOption($label, $folder);
403
-				if ($selected != '') {
404
-					$parent_select->setSelected($folder);
405
-				}
406
-			}
407
-		}
408
-	} else {
409
-		if (is_array($folders) && !empty($folders)) {
410
-			foreach ($folders as & $folder) {
411
-				$selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
412
-				$label = $folder_titles[$folder];
413
-				if ($folder == $group_dir) {
414
-					$label = '/ (' . get_lang('HomeDirectory') . ')';
415
-				} else {
416
-					$path_parts = explode('/', str_replace($group_dir, '', $folder));
417
-					$label = cut($label, 80);
418
-					$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
419
-				}
420
-				$parent_select->addOption($label, $folder);
421
-				if ($selected != '') {
422
-					$parent_select->setSelected($folder);
423
-				}
424
-			}
425
-		}
426
-	}
402
+                $parent_select -> addOption($label, $folder);
403
+                if ($selected != '') {
404
+                    $parent_select->setSelected($folder);
405
+                }
406
+            }
407
+        }
408
+    } else {
409
+        if (is_array($folders) && !empty($folders)) {
410
+            foreach ($folders as & $folder) {
411
+                $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
412
+                $label = $folder_titles[$folder];
413
+                if ($folder == $group_dir) {
414
+                    $label = '/ (' . get_lang('HomeDirectory') . ')';
415
+                } else {
416
+                    $path_parts = explode('/', str_replace($group_dir, '', $folder));
417
+                    $label = cut($label, 80);
418
+                    $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
419
+                }
420
+                $parent_select->addOption($label, $folder);
421
+                if ($selected != '') {
422
+                    $parent_select->setSelected($folder);
423
+                }
424
+            }
425
+        }
426
+    }
427 427
 }
428 428
 
429 429
 $form->addHidden('dirValue', '');
430 430
 
431 431
 if ($is_certificate_mode) {
432
-	$form->addButtonCreate(get_lang('CreateCertificate'));
432
+    $form->addButtonCreate(get_lang('CreateCertificate'));
433 433
 } else {
434
-	$form->addButtonCreate(get_lang('CreateDoc'));
434
+    $form->addButtonCreate(get_lang('CreateDoc'));
435 435
 }
436 436
 
437 437
 $form->setDefaults($defaults);
438 438
 
439 439
 // If form validates -> save the new document
440 440
 if ($form->validate()) {
441
-	$values = $form->exportValues();
442
-	$readonly = isset($values['readonly']) ? 1 : 0;
443
-	$values['title'] = trim($values['title']);
441
+    $values = $form->exportValues();
442
+    $readonly = isset($values['readonly']) ? 1 : 0;
443
+    $values['title'] = trim($values['title']);
444 444
 
445 445
     if (!empty($values['dirValue'])) {
446 446
         $dir = $values['dirValue'];
447 447
     }
448 448
 
449 449
     if ($dir[strlen($dir) - 1] != '/') {
450
-		$dir .= '/';
451
-	}
450
+        $dir .= '/';
451
+    }
452 452
     $filepath = $filepath.$dir;
453 453
 
454 454
     // Setting the filename
455
-	$filename = $values['title'];
456
-	$filename = addslashes(trim($filename));
457
-	$filename = Security::remove_XSS($filename);
458
-	$filename = api_replace_dangerous_char($filename);
459
-	$filename = disable_dangerous_file($filename);
455
+    $filename = $values['title'];
456
+    $filename = addslashes(trim($filename));
457
+    $filename = Security::remove_XSS($filename);
458
+    $filename = api_replace_dangerous_char($filename);
459
+    $filename = disable_dangerous_file($filename);
460 460
     $filename .= DocumentManager::getDocumentSuffix(
461 461
         $_course,
462 462
         api_get_session_id(),
@@ -464,14 +464,14 @@  discard block
 block discarded – undo
464 464
     );
465 465
 
466 466
     // Setting the title
467
-	$title = $values['title'];
467
+    $title = $values['title'];
468 468
 
469 469
     // Setting the extension
470
-	$extension = 'html';
470
+    $extension = 'html';
471 471
 
472
-	$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
472
+    $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
473 473
 
474
-	/*if (strpos($content, '/css/frames.css') == false) {
474
+    /*if (strpos($content, '/css/frames.css') == false) {
475 475
 		$content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
476 476
 	}*/
477 477
 
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
         exit;
485 485
     }
486 486
 
487
-	if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
488
-		//$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
489
-		$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content);
487
+    if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
488
+        //$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
489
+        $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content);
490 490
 
491
-		fputs($fp, $content);
492
-		fclose($fp);
493
-		chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
491
+        fputs($fp, $content);
492
+        fclose($fp);
493
+        chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
494 494
 
495 495
         /*
496 496
 		if (!is_dir($filepath.'css')) {
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 			api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, null, null, null, null, $current_session_id);
509 509
 		}*/
510 510
 
511
-		$file_size = filesize($filepath.$filename.'.'.$extension);
512
-		$save_file_path = $dir.$filename.'.'.$extension;
511
+        $file_size = filesize($filepath.$filename.'.'.$extension);
512
+        $save_file_path = $dir.$filename.'.'.$extension;
513 513
 
514 514
         $document_id = add_document(
515 515
             $_course,
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
             $readonly
522 522
         );
523 523
 
524
-		if ($document_id) {
525
-			api_item_property_update(
524
+        if ($document_id) {
525
+            api_item_property_update(
526 526
                 $_course,
527 527
                 TOOL_DOCUMENT,
528 528
                 $document_id,
@@ -534,13 +534,13 @@  discard block
 block discarded – undo
534 534
                 null,
535 535
                 $current_session_id
536 536
             );
537
-			// Update parent folders
538
-			item_property_update_on_folder($_course, $dir, $userId);
539
-			$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
540
-			$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
537
+            // Update parent folders
538
+            item_property_update_on_folder($_course, $dir, $userId);
539
+            $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
540
+            $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
541 541
             $new_title = htmlspecialchars($new_title);
542
-			if ($new_comment || $new_title) {
543
-				$ct = '';
542
+            if ($new_comment || $new_title) {
543
+                $ct = '';
544 544
                 $params = [];
545 545
                 if ($new_comment) {
546 546
                     $params['comment'] = $new_comment;
@@ -555,38 +555,38 @@  discard block
 block discarded – undo
555 555
                         ['c_id = ? AND id = ?' => [$course_id, $document_id]]
556 556
                     );
557 557
                 }
558
-			}
559
-			$dir= substr($dir,0,-1);
560
-			$selectcat = '';
561
-			if (isset($_REQUEST['selectcat']))
562
-				$selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']);
563
-			$certificate_condition = '';
564
-			if ($is_certificate_mode) {
565
-				$df = DocumentManager::get_default_certificate_id($_course['code']);
558
+            }
559
+            $dir= substr($dir,0,-1);
560
+            $selectcat = '';
561
+            if (isset($_REQUEST['selectcat']))
562
+                $selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']);
563
+            $certificate_condition = '';
564
+            if ($is_certificate_mode) {
565
+                $df = DocumentManager::get_default_certificate_id($_course['code']);
566 566
                 if (!isset($df)) {
567 567
                     DocumentManager::attach_gradebook_certificate ($_course['code'],$document_id);
568
-				}
569
-				$certificate_condition = '&certificate=true&curdirpath=/certificates';
570
-			}
571
-
572
-			header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
573
-			exit();
574
-		} else {
575
-			Display :: display_header($nameTools, 'Doc');
576
-			Display :: display_error_message(get_lang('Impossible'));
577
-			Display :: display_footer();
578
-		}
579
-	} else {
580
-		Display :: display_header($nameTools, 'Doc');
581
-		Display :: display_error_message(get_lang('Impossible'));
582
-		Display :: display_footer();
583
-	}
568
+                }
569
+                $certificate_condition = '&certificate=true&curdirpath=/certificates';
570
+            }
571
+
572
+            header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
573
+            exit();
574
+        } else {
575
+            Display :: display_header($nameTools, 'Doc');
576
+            Display :: display_error_message(get_lang('Impossible'));
577
+            Display :: display_footer();
578
+        }
579
+    } else {
580
+        Display :: display_header($nameTools, 'Doc');
581
+        Display :: display_error_message(get_lang('Impossible'));
582
+        Display :: display_footer();
583
+    }
584 584
 } else {
585
-	// Copied from document.php
586
-	$dir_array = explode('/', $dir);
587
-	$array_len = count($dir_array);
585
+    // Copied from document.php
586
+    $dir_array = explode('/', $dir);
587
+    $array_len = count($dir_array);
588 588
 
589
-	// Breadcrumb for the current directory root path
589
+    // Breadcrumb for the current directory root path
590 590
     if (!empty($document_data)) {
591 591
         if (empty($document_data['parents'])) {
592 592
             $interbreadcrumb[] = array(
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
         }
604 604
     }
605 605
 
606
-	Display :: display_header($nameTools, "Doc");
607
-	// actions
606
+    Display :: display_header($nameTools, "Doc");
607
+    // actions
608 608
 
609
-	// link back to the documents overview
610
-	if ($is_certificate_mode) {
609
+    // link back to the documents overview
610
+    if ($is_certificate_mode) {
611 611
             $actionsLeft =  '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.
612 612
                 Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
613 613
             $actionsLeft .= '<a id="hide_bar_template" href="#">'.
@@ -622,19 +622,19 @@  discard block
 block discarded – undo
622 622
 
623 623
     echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft));
624 624
 
625
-	if ($is_certificate_mode) {
625
+    if ($is_certificate_mode) {
626 626
         $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
627 627
             api_get_user_id(),
628 628
             api_get_course_id()
629 629
         );
630 630
 
631
-		$str_info = '';
632
-		foreach ($all_information_by_create_certificate[0] as $info_value) {
633
-			$str_info.=$info_value.'<br/>';
634
-		}
635
-		$create_certificate = get_lang('CreateCertificateWithTags');
636
-		Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
637
-	}
631
+        $str_info = '';
632
+        foreach ($all_information_by_create_certificate[0] as $info_value) {
633
+            $str_info.=$info_value.'<br/>';
634
+        }
635
+        $create_certificate = get_lang('CreateCertificateWithTags');
636
+        Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
637
+    }
638 638
     
639 639
     // HTML-editor
640 640
     echo '<div class="page-create">
@@ -650,5 +650,5 @@  discard block
 block discarded – undo
650 650
                 '.$form->returnForm().'
651 651
             </div>
652 652
           </div></div>';
653
-	Display :: display_footer();
653
+    Display :: display_footer();
654 654
 }
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/admin/user_edit.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 unset($user_data['password']);
103 103
 
104 104
 if ($userGeolocalization) {
105
-	$htmlHeadXtra[] = '<script>
105
+    $htmlHeadXtra[] = '<script>
106 106
     $(document).ready(function() {
107 107
 
108 108
         var address = "' . $user_data['address'] . '";
@@ -212,27 +212,27 @@  discard block
 block discarded – undo
212 212
 $form->addElement('hidden', 'user_id', $user_id);
213 213
 
214 214
 if (api_is_western_name_order()) {
215
-	// Firstname
216
-	$form->addElement('text', 'firstname', get_lang('FirstName'));
217
-	$form->applyFilter('firstname', 'html_filter');
218
-	$form->applyFilter('firstname', 'trim');
219
-	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
220
-	// Lastname
221
-	$form->addElement('text', 'lastname', get_lang('LastName'));
222
-	$form->applyFilter('lastname', 'html_filter');
223
-	$form->applyFilter('lastname', 'trim');
224
-	$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
215
+    // Firstname
216
+    $form->addElement('text', 'firstname', get_lang('FirstName'));
217
+    $form->applyFilter('firstname', 'html_filter');
218
+    $form->applyFilter('firstname', 'trim');
219
+    $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
220
+    // Lastname
221
+    $form->addElement('text', 'lastname', get_lang('LastName'));
222
+    $form->applyFilter('lastname', 'html_filter');
223
+    $form->applyFilter('lastname', 'trim');
224
+    $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
225 225
 } else {
226
-	// Lastname
227
-	$form->addElement('text', 'lastname', get_lang('LastName'));
228
-	$form->applyFilter('lastname', 'html_filter');
229
-	$form->applyFilter('lastname', 'trim');
230
-	$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
231
-	// Firstname
232
-	$form->addElement('text', 'firstname', get_lang('FirstName'));
233
-	$form->applyFilter('firstname', 'html_filter');
234
-	$form->applyFilter('firstname', 'trim');
235
-	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
226
+    // Lastname
227
+    $form->addElement('text', 'lastname', get_lang('LastName'));
228
+    $form->applyFilter('lastname', 'html_filter');
229
+    $form->applyFilter('lastname', 'trim');
230
+    $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
231
+    // Firstname
232
+    $form->addElement('text', 'firstname', get_lang('FirstName'));
233
+    $form->applyFilter('firstname', 'html_filter');
234
+    $form->applyFilter('firstname', 'trim');
235
+    $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
236 236
 }
237 237
 
238 238
 // Official code
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 
255 255
 // OpenID
256 256
 if (api_get_setting('openid_authentication') == 'true') {
257
-	$form->addElement('text', 'openid', get_lang('OpenIDURL'));
257
+    $form->addElement('text', 'openid', get_lang('OpenIDURL'));
258 258
 }
259 259
 
260 260
 // Phone
261 261
 $form->addElement('text', 'phone', get_lang('PhoneNumber'));
262 262
 
263 263
 if ($userGeolocalization) {
264
-	// Geolocation
265
-	$form->addElement('text', 'address', get_lang('AddressField'), ['id' => 'address']);
266
-	$form->addHtml('
264
+    // Geolocation
265
+    $form->addElement('text', 'address', get_lang('AddressField'), ['id' => 'address']);
266
+    $form->addHtml('
267 267
         <div class="form-group">
268 268
             <label for="geolocalization" class="col-sm-2 control-label"></label>
269 269
             <div class="col-sm-8">
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         </div>
274 274
     ');
275 275
 
276
-	$form->addHtml('
276
+    $form->addHtml('
277 277
         <div class="form-group">
278 278
             <label for="map" class="col-sm-2 control-label">
279 279
                 '.get_lang('Map').'
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
 $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
296 296
 
297 297
 $form->addRule(
298
-	'picture',
299
-	get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
300
-	'filetype',
301
-	$allowed_picture_types
298
+    'picture',
299
+    get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
300
+    'filetype',
301
+    $allowed_picture_types
302 302
 );
303 303
 if (strlen($user_data['picture_uri']) > 0) {
304
-	$form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
304
+    $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
305 305
 }
306 306
 
307 307
 // Username
308 308
 if (api_get_setting('login_is_email') != 'true') {
309
-	$form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH));
309
+    $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH));
310 310
     $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
311 311
     $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
312 312
     $form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username');
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
 
379 379
 // Platform admin
380 380
 if (api_is_platform_admin()) {
381
-	$group = array();
382
-	$group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1);
383
-	$group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0);
381
+    $group = array();
382
+    $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1);
383
+    $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0);
384 384
 
385
-	$user_data['status'] == 1 ? $display = 'block':$display = 'none';
385
+    $user_data['status'] == 1 ? $display = 'block':$display = 'none';
386 386
 
387
-	$form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">');
388
-	$form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false);
389
-	$form->addElement('html', '</div>');
387
+    $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">');
388
+    $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false);
389
+    $form->addElement('html', '</div>');
390 390
 }
391 391
 
392 392
 //Language
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 $form->addElement('label', get_lang('RegistrationDate'), $date);
405 405
 
406 406
 if (!$user_data['platform_admin']) {
407
-	// Expiration Date
408
-	$form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
409
-	$group = array ();
410
-	$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1);
411
-	$group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();'));
412
-	$form->addGroup($group, 'max_member_group', null, null, false);
413
-
414
-	// Active account or inactive account
415
-	$form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1);
416
-	$form->addElement('radio', 'active', '', get_lang('Inactive'), 0);
407
+    // Expiration Date
408
+    $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
409
+    $group = array ();
410
+    $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1);
411
+    $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();'));
412
+    $form->addGroup($group, 'max_member_group', null, null, false);
413
+
414
+    // Active account or inactive account
415
+    $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1);
416
+    $form->addElement('radio', 'active', '', get_lang('Inactive'), 0);
417 417
 }
418 418
 $studentBossList = UserManager::getStudentBossList($user_data['user_id']);
419 419
 
@@ -455,18 +455,18 @@  discard block
 block discarded – undo
455 455
 $expiration_date = $user_data['expiration_date'];
456 456
 
457 457
 if (empty($expiration_date)) {
458
-	$user_data['radio_expiration_date'] = 0;
459
-	$user_data['expiration_date'] = api_get_local_time();
458
+    $user_data['radio_expiration_date'] = 0;
459
+    $user_data['expiration_date'] = api_get_local_time();
460 460
 } else {
461
-	$user_data['radio_expiration_date'] = 1;
462
-	$user_data['expiration_date'] = api_get_local_time($expiration_date);
461
+    $user_data['radio_expiration_date'] = 1;
462
+    $user_data['expiration_date'] = api_get_local_time($expiration_date);
463 463
 }
464 464
 $form->setDefaults($user_data);
465 465
 
466 466
 $error_drh = false;
467 467
 // Validate form
468 468
 if ($form->validate()) {
469
-	$user = $form->getSubmitValues(1);
469
+    $user = $form->getSubmitValues(1);
470 470
     $reset_password = intval($user['reset_password']);
471 471
     if ($reset_password == 2 && empty($user['password'])) {
472 472
         Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort')));
@@ -474,18 +474,18 @@  discard block
 block discarded – undo
474 474
         exit();
475 475
     }
476 476
 
477
-	$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
477
+    $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
478 478
 
479
-	if ($user['status'] == DRH && $is_user_subscribed_in_course) {
480
-		$error_drh = true;
481
-	} else {
482
-		$picture_element = $form->getElement('picture');
483
-		$picture = $picture_element->getValue();
479
+    if ($user['status'] == DRH && $is_user_subscribed_in_course) {
480
+        $error_drh = true;
481
+    } else {
482
+        $picture_element = $form->getElement('picture');
483
+        $picture = $picture_element->getValue();
484 484
 
485
-		$picture_uri = $user_data['picture_uri'];
486
-		if (isset($user['delete_picture']) && $user['delete_picture']) {
487
-			$picture_uri = UserManager::delete_user_picture($user_id);
488
-		} elseif (!empty($picture['name'])) {
485
+        $picture_uri = $user_data['picture_uri'];
486
+        if (isset($user['delete_picture']) && $user['delete_picture']) {
487
+            $picture_uri = UserManager::delete_user_picture($user_id);
488
+        } elseif (!empty($picture['name'])) {
489 489
             $picture_uri = UserManager::update_user_picture(
490 490
                 $user_id,
491 491
                 $_FILES['picture']['name'],
@@ -493,30 +493,30 @@  discard block
 block discarded – undo
493 493
                 $user['picture_crop_result']
494 494
 
495 495
             );
496
-		}
496
+        }
497 497
 
498
-		$lastname = $user['lastname'];
499
-		$firstname = $user['firstname'];
498
+        $lastname = $user['lastname'];
499
+        $firstname = $user['firstname'];
500 500
         $password = $user['password'];
501 501
         $auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source'];
502
-		$official_code = $user['official_code'];
503
-		$email = $user['email'];
504
-		$phone = $user['phone'];
505
-		$username = isset($user['username']) ? $user['username'] : $userInfo['username'];
506
-		$status = intval($user['status']);
507
-		$platform_admin = intval($user['platform_admin']);
508
-		$send_mail = intval($user['send_mail']);
509
-		$reset_password = intval($user['reset_password']);
510
-		$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
511
-		$language = $user['language'];
512
-
513
-		if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
502
+        $official_code = $user['official_code'];
503
+        $email = $user['email'];
504
+        $phone = $user['phone'];
505
+        $username = isset($user['username']) ? $user['username'] : $userInfo['username'];
506
+        $status = intval($user['status']);
507
+        $platform_admin = intval($user['platform_admin']);
508
+        $send_mail = intval($user['send_mail']);
509
+        $reset_password = intval($user['reset_password']);
510
+        $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
511
+        $language = $user['language'];
512
+
513
+        if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
514 514
             $expiration_date = $user['expiration_date'];
515
-		} else {
516
-			$expiration_date = null;
517
-		}
515
+        } else {
516
+            $expiration_date = null;
517
+        }
518 518
 
519
-		$active = $user_data['platform_admin'] ? 1 : intval($user['active']);
519
+        $active = $user_data['platform_admin'] ? 1 : intval($user['active']);
520 520
 
521 521
         //If the user is set to admin the status will be overwrite by COURSEMANAGER = 1
522 522
         if ($platform_admin == 1) {
@@ -548,44 +548,44 @@  discard block
 block discarded – undo
548 548
             null,
549 549
             $send_mail,
550 550
             $reset_password,
551
-			$user['address']
551
+            $user['address']
552 552
         );
553 553
 
554 554
         if (isset($user['student_boss'])) {
555 555
             UserManager::subscribeUserToBossList($user_id, $user['student_boss']);
556 556
         }
557 557
 
558
-		if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) {
559
-			$up = UserManager::update_openid($user_id, $user['openid']);
560
-		}
558
+        if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) {
559
+            $up = UserManager::update_openid($user_id, $user['openid']);
560
+        }
561 561
         $currentUserId = api_get_user_id();
562 562
 
563 563
         $userObj = api_get_user_entity($user_id);
564 564
 
565 565
         UserManager::add_user_as_admin($userObj);
566 566
 
567
-		if ($user_id != $currentUserId) {
568
-			if ($platform_admin == 1) {
569
-				$userObj = api_get_user_entity($user_id);
567
+        if ($user_id != $currentUserId) {
568
+            if ($platform_admin == 1) {
569
+                $userObj = api_get_user_entity($user_id);
570 570
                 UserManager::add_user_as_admin($userObj);
571
-			} else {
571
+            } else {
572 572
                 UserManager::remove_user_admin($user_id);
573
-			}
574
-		}
573
+            }
574
+        }
575 575
 
576 576
         $extraFieldValue = new ExtraFieldValue('user');
577 577
         $extraFieldValue->saveFieldValues($user);
578 578
 
579
-		$tok = Security::get_token();
580
-		header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);
581
-		exit();
582
-	}
579
+        $tok = Security::get_token();
580
+        header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);
581
+        exit();
582
+    }
583 583
 }
584 584
 
585 585
 $message = null;
586 586
 if ($error_drh) {
587
-	$err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager');
588
-	$message = Display::return_message($err_msg, 'error');
587
+    $err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager');
588
+    $message = Display::return_message($err_msg, 'error');
589 589
 }
590 590
 
591 591
 $content = null;
Please login to merge, or discard this patch.