@@ -42,8 +42,8 @@ |
||
42 | 42 | $file_url = Database::escape_string($file_url); |
43 | 43 | $title = $_GET['title']; |
44 | 44 | $path_attachment = api_get_path(SYS_ARCHIVE_PATH); |
45 | -$path_message_attach = $path_attachment . 'plugin_ticket_messageattch/'; |
|
46 | -$full_file_name = $path_message_attach . $file_url; |
|
45 | +$path_message_attach = $path_attachment.'plugin_ticket_messageattch/'; |
|
46 | +$full_file_name = $path_message_attach.$file_url; |
|
47 | 47 | if (Security::check_abs_path($full_file_name, $path_message_attach)) { |
48 | 48 | DocumentManager::file_send_for_download($full_file_name, true, $title); |
49 | 49 | } |
@@ -289,8 +289,9 @@ |
||
289 | 289 | |
290 | 290 | if ($start_date != '' || $end_date != '') { |
291 | 291 | $sql .= " HAVING "; |
292 | - if ($start_date != '') |
|
293 | - $sql .= " access_date >= '$start_date' "; |
|
292 | + if ($start_date != '') { |
|
293 | + $sql .= " access_date >= '$start_date' "; |
|
294 | + } |
|
294 | 295 | if ($end_date != '') { |
295 | 296 | $sql = ($start_date == '') ? $sql : ($sql . " AND "); |
296 | 297 | $sql .= " access_date <= '$end_date' "; |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | $htmlHeadXtra[] = '<script> |
20 | 20 | $(document).ready(function(){ |
21 | - $( "#keyword_start_date_start" ).datepicker({ dateFormat: ' . "'yy-mm-dd'" . ' }); |
|
22 | - $( "#keyword_start_date_end" ).datepicker({ dateFormat: ' . "'yy-mm-dd'" . ' }); |
|
21 | + $( "#keyword_start_date_start" ).datepicker({ dateFormat: ' . "'yy-mm-dd'".' }); |
|
22 | + $( "#keyword_start_date_end" ).datepicker({ dateFormat: ' . "'yy-mm-dd'".' }); |
|
23 | 23 | }); |
24 | 24 | |
25 | 25 | function validate() { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function js_str($s) |
92 | 92 | { |
93 | - return '"' . addcslashes($s, "\0..\37\"\\") . '"'; |
|
93 | + return '"'.addcslashes($s, "\0..\37\"\\").'"'; |
|
94 | 94 | } |
95 | 95 | /** |
96 | 96 | * This function is to show the ticket form |
@@ -100,29 +100,29 @@ discard block |
||
100 | 100 | { |
101 | 101 | global $tools; |
102 | 102 | echo '<div class="ticket-form">'; |
103 | - echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket" |
|
103 | + echo '<form enctype="multipart/form-data" action="'.api_get_self().'" method="post" name="send_ticket" id="send_ticket" |
|
104 | 104 | onsubmit="return validate()" style="width:100%">'; |
105 | 105 | $select_course = '<div id="user_request" > |
106 | 106 | </div>'; |
107 | 107 | echo $select_course; |
108 | 108 | //select status |
109 | 109 | $select_tool = '<div class="row" > |
110 | - <div class="label2" >' . get_lang('Tool') .':</div> |
|
110 | + <div class="label2" >' . get_lang('Tool').':</div> |
|
111 | 111 | <div class="formw2">'; |
112 | 112 | $select_tool .= '<select style="width: 95%; " name = "tool" id="tool" >'; |
113 | 113 | |
114 | 114 | foreach ($tools as $tool) { |
115 | - $select_tool .= "<option value = '" . $tool['id'] . "' selected >" . $tool['name'] . "</option>"; |
|
115 | + $select_tool .= "<option value = '".$tool['id']."' selected >".$tool['name']."</option>"; |
|
116 | 116 | } |
117 | 117 | $select_tool .= "</select>"; |
118 | 118 | $select_tool .= '</div></div>'; |
119 | 119 | echo $select_tool; |
120 | 120 | echo '<div class="row"> |
121 | - <div class="label2">' . get_lang('From') . ':</div> |
|
121 | + <div class="label2">' . get_lang('From').':</div> |
|
122 | 122 | <div class="formw2"><input id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div> |
123 | 123 | </div> |
124 | 124 | <div class="row"> |
125 | - <div class="label2"> ' . get_lang('To') . '</div> |
|
125 | + <div class="label2"> ' . get_lang('To').'</div> |
|
126 | 126 | <div class="formw2"><input id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div> |
127 | 127 | </div>'; |
128 | 128 | echo '</div>'; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | <div class="label2"> |
131 | 131 | </div> |
132 | 132 | <div class="formw2"> |
133 | - <button class="save" name="report" type="submit" id="btnsubmit" disabled="disabled">' . get_lang('CompleteReport') .'</button> |
|
133 | + <button class="save" name="report" type="submit" id="btnsubmit" disabled="disabled">' . get_lang('CompleteReport').'</button> |
|
134 | 134 | </div> |
135 | 135 | </div>'; |
136 | 136 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u"; |
146 | 146 | if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) { |
147 | 147 | $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
148 | - $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)"; |
|
148 | + $sql .= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)"; |
|
149 | 149 | } |
150 | 150 | if (isset($_GET['keyword'])) { |
151 | 151 | $keyword = Database::escape_string(trim($_GET['keyword'])); |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | $webPath = api_get_path(WEB_PATH); |
221 | 221 | while ($user = Database::fetch_row($res)) { |
222 | 222 | $userPicture = UserManager::getUserPicture($user[0]); |
223 | - $photo = '<img src="' . $userPicture . '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />'; |
|
223 | + $photo = '<img src="'.$userPicture.'" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
224 | 224 | $user_id = $user[0]; |
225 | - $button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')"> |
|
226 | - <img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" src="' . $webPath . 'img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/> |
|
225 | + $button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')"> |
|
226 | + <img onclick="load_course_list(\'div_' . $user_id.'\','.$user_id.')" src="'.$webPath.'img/view_more_stats.gif" title="'.get_lang('Courses').'" alt="'.get_lang('Courses').'"/> |
|
227 | 227 | </a> '; |
228 | 228 | $users[] = array( |
229 | 229 | $photo, |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | Display::display_header('Reports'); |
243 | 243 | echo '<div class="actions"> |
244 | - <form action="' . api_get_self() . '" method="get" name="search_simple" id="search_simple"> |
|
244 | + <form action="' . api_get_self().'" method="get" name="search_simple" id="search_simple"> |
|
245 | 245 | <input name="user_id_request" id="user_id_request" type="hidden" value=""> |
246 | 246 | <span><label for="keyword">Búsqueda del usuario: </label><input size="25" name="keyword" type="text" id="keyword"></span> |
247 | 247 | <span><button class="search" name="submit" type="submit">Buscar</button></span> |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | u.username , CONCAT(u.lastname, ' ', u.firstname) AS fullname, |
276 | 276 | DATE_SUB(access.access_date,INTERVAL 5 HOUR) AS access_date, |
277 | 277 | c.title AS course, access_tool AS tool |
278 | - FROM " . Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS) . " access |
|
279 | - LEFT JOIN " . Database::get_main_table(TABLE_MAIN_USER) . " u ON access.access_user_id = u.user_id |
|
280 | - LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE) . " c ON access.c_id = c.id |
|
281 | - WHERE access.c_id = " . $course_info['real_id'] . " AND u.user_id = $user_id "; |
|
278 | + FROM " . Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS)." access |
|
279 | + LEFT JOIN " . Database::get_main_table(TABLE_MAIN_USER)." u ON access.access_user_id = u.user_id |
|
280 | + LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE)." c ON access.c_id = c.id |
|
281 | + WHERE access.c_id = " . $course_info['real_id']." AND u.user_id = $user_id "; |
|
282 | 282 | if ($tool != '') { |
283 | - $sql.="AND access.access_tool = '$tool' "; |
|
283 | + $sql .= "AND access.access_tool = '$tool' "; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | $start_date = Database::escape_string($_POST['keyword_start_date_start']); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | if ($start_date != '') |
292 | 292 | $sql .= " access_date >= '$start_date' "; |
293 | 293 | if ($end_date != '') { |
294 | - $sql = ($start_date == '') ? $sql : ($sql . " AND "); |
|
294 | + $sql = ($start_date == '') ? $sql : ($sql." AND "); |
|
295 | 295 | $sql .= " access_date <= '$end_date' "; |
296 | 296 | } |
297 | 297 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | $courseSelect = Display::select('course_id', $arrCourseList, 0, array(), false); |
39 | 39 | $courseControl = Display::div($courseSelect, array('class' => 'controls')); |
40 | 40 | |
41 | -$userDiv = Display::div($userLabel . " " . $userControl, array('class' => 'control-group')); |
|
42 | -$courseDiv = Display::div($courseLabel . " " . $courseControl, array('class' => 'control-group')); |
|
41 | +$userDiv = Display::div($userLabel." ".$userControl, array('class' => 'control-group')); |
|
42 | +$courseDiv = Display::div($courseLabel." ".$courseControl, array('class' => 'control-group')); |
|
43 | 43 | echo $userDiv; |
44 | 44 | echo $courseDiv; |
45 | 45 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | /** |
37 | 37 | * Instance the plugin |
38 | 38 | * @staticvar null $result |
39 | - * @return Tour |
|
39 | + * @return AzureActiveDirectory |
|
40 | 40 | */ |
41 | 41 | static function create() |
42 | 42 | { |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | $settings = []; |
64 | 64 | |
65 | 65 | foreach ($settingsInfo as $settingInfo) { |
66 | - $variable = str_replace($this->get_name() . '_', '', $settingInfo['variable']); |
|
66 | + $variable = str_replace($this->get_name().'_', '', $settingInfo['variable']); |
|
67 | 67 | |
68 | 68 | $settings[$variable] = $settingInfo['selected_value']; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $url = "https://login.microsoftonline.com/{$settings[self::SETTING_TENANT]}/oauth2/v2.0/"; |
72 | - $callback = api_get_path(WEB_PLUGIN_PATH) . $this->get_name() . '/src/callback.php'; |
|
72 | + $callback = api_get_path(WEB_PLUGIN_PATH).$this->get_name().'/src/callback.php'; |
|
73 | 73 | |
74 | 74 | if ($urlType === self::URL_TYPE_SIGNOUT) { |
75 | 75 | $action = 'logout'; |
@@ -97,6 +97,6 @@ discard block |
||
97 | 97 | ]; |
98 | 98 | } |
99 | 99 | |
100 | - return $url . $action . '?' . http_build_query($urlParams); |
|
100 | + return $url.$action.'?'.http_build_query($urlParams); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | \ No newline at end of file |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -require dirname(__FILE__) . '/../../../main/inc/global.inc.php'; |
|
3 | -require_once dirname(__FILE__) . '/../../../main/auth/external_login/functions.inc.php'; |
|
2 | +require dirname(__FILE__).'/../../../main/inc/global.inc.php'; |
|
3 | +require_once dirname(__FILE__).'/../../../main/auth/external_login/functions.inc.php'; |
|
4 | 4 | |
5 | 5 | if (isset($_POST['error']) || empty($_REQUEST)) { |
6 | - header('Location: ' . api_get_path(WEB_PATH) . 'index.php?logout=logout'); |
|
6 | + header('Location: '.api_get_path(WEB_PATH).'index.php?logout=logout'); |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | 'username' => $jwtPayload->emails[0], |
26 | 26 | 'language' => 'en', |
27 | 27 | 'password' => 'azure_active_directory', |
28 | - 'auth_source' => 'azure_active_directory ' . $jwtPayload->idp, |
|
28 | + 'auth_source' => 'azure_active_directory '.$jwtPayload->idp, |
|
29 | 29 | 'extra' => array() |
30 | 30 | ); |
31 | 31 | |
@@ -51,5 +51,5 @@ discard block |
||
51 | 51 | $_SESSION['_user'] = $_user; |
52 | 52 | } |
53 | 53 | |
54 | -header('Location: ' . api_get_path(WEB_PATH)); |
|
54 | +header('Location: '.api_get_path(WEB_PATH)); |
|
55 | 55 | exit; |
@@ -7,5 +7,5 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | require_once __DIR__.'/../inc/global.inc.php'; |
10 | -header('Location:' . api_get_path(WEB_CODE_PATH) . 'ticket/tickets.php'); |
|
10 | +header('Location:'.api_get_path(WEB_CODE_PATH).'ticket/tickets.php'); |
|
11 | 11 | exit; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $tool_name = get_lang('ConfigureInscription'); |
47 | 47 | if (!empty($action)) { |
48 | 48 | $interbreadcrumb[] = array('url' => 'configure_inscription.php', 'name' => get_lang('ConfigureInscription')); |
49 | - switch($action) { |
|
49 | + switch ($action) { |
|
50 | 50 | case 'edit_top': |
51 | 51 | $tool_name = get_lang('EditTopRegister'); |
52 | 52 | break; |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | // This request is only the preparation for the update of the home_top |
142 | 142 | $home_top = ''; |
143 | 143 | if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) { |
144 | - $home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext); |
|
144 | + $home_top = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext); |
|
145 | 145 | } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) { |
146 | - $home_top = @(string)file_get_contents($homep.$topf.$lang.$ext); |
|
146 | + $home_top = @(string) file_get_contents($homep.$topf.$lang.$ext); |
|
147 | 147 | } else { |
148 | 148 | $errorMsg = get_lang('HomePageFilesNotReadable'); |
149 | 149 | } |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | if (api_is_western_name_order()) { |
185 | 185 | // FIRST NAME and LAST NAME |
186 | 186 | $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled')); |
187 | - $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled')); |
|
187 | + $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled')); |
|
188 | 188 | } else { |
189 | 189 | // LAST NAME and FIRST NAME |
190 | - $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled')); |
|
190 | + $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled')); |
|
191 | 191 | $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled')); |
192 | 192 | } |
193 | 193 | $form->applyFilter('firstname', 'trim'); |
194 | 194 | $form->applyFilter('lastname', 'trim'); |
195 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
195 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
196 | 196 | $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
197 | 197 | |
198 | 198 | |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); |
211 | 211 | $form->addRule('username', get_lang('UsernameWrong'), 'username'); |
212 | 212 | $form->addRule('username', get_lang('UserTaken'), 'username_available'); |
213 | - $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); |
|
213 | + $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); |
|
214 | 214 | |
215 | 215 | // PASSWORD |
216 | - $form->addElement('password', 'pass1', get_lang('Pass'), array('size' => 40, 'disabled' => 'disabled')); |
|
216 | + $form->addElement('password', 'pass1', get_lang('Pass'), array('size' => 40, 'disabled' => 'disabled')); |
|
217 | 217 | $form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 40, 'disabled' => 'disabled')); |
218 | 218 | $form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required'); |
219 | 219 | $form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required'); |
@@ -241,25 +241,25 @@ discard block |
||
241 | 241 | |
242 | 242 | // EXTENDED FIELDS |
243 | 243 | if (api_get_setting('extended_profile') == 'true' && |
244 | - api_get_setting('extendedprofile_registration','mycomptetences') == 'true' |
|
244 | + api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true' |
|
245 | 245 | ) { |
246 | 246 | $form->addHtmlEditor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); |
247 | 247 | } |
248 | 248 | |
249 | 249 | if (api_get_setting('extended_profile') == 'true' && |
250 | - api_get_setting('extendedprofile_registration','mydiplomas') == 'true' |
|
250 | + api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true' |
|
251 | 251 | ) { |
252 | 252 | $form->addHtmlEditor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); |
253 | 253 | } |
254 | 254 | |
255 | 255 | if (api_get_setting('extended_profile') == 'true' && |
256 | - api_get_setting('extendedprofile_registration','myteach') == 'true' |
|
256 | + api_get_setting('extendedprofile_registration', 'myteach') == 'true' |
|
257 | 257 | ) { |
258 | 258 | $form->addHtmlEditor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); |
259 | 259 | } |
260 | 260 | |
261 | 261 | if (api_get_setting('extended_profile') == 'true' && |
262 | - api_get_setting('extendedprofile_registration','mypersonalopenarea') == 'true' |
|
262 | + api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true' |
|
263 | 263 | ) { |
264 | 264 | $form->addHtmlEditor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); |
265 | 265 | } |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | |
350 | 350 | $form->setDefaults($defaults); |
351 | 351 | |
352 | -switch ($action){ |
|
352 | +switch ($action) { |
|
353 | 353 | case 'edit_top': |
354 | 354 | if ($action == 'edit_top') { |
355 | 355 | $name = $topf; |
356 | 356 | $open = $home_top; |
357 | 357 | } else { |
358 | 358 | $name = $newsf; |
359 | - $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext); |
|
359 | + $open = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext); |
|
360 | 360 | $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
361 | 361 | } |
362 | 362 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | $default = array(); |
368 | 368 | $form = new FormValidator('configure_inscription_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;')); |
369 | - $renderer =& $form->defaultRenderer(); |
|
369 | + $renderer = & $form->defaultRenderer(); |
|
370 | 370 | $renderer->setHeaderTemplate(''); |
371 | 371 | $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>'); |
372 | 372 | $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>'); |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | |
386 | 386 | $open = ''; |
387 | 387 | if (file_exists($homep.$topf.'_'.$lang.$ext)) { |
388 | - $open = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext); |
|
388 | + $open = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext); |
|
389 | 389 | } else { |
390 | - $open = @(string)file_get_contents($homep.$topf.$ext); |
|
390 | + $open = @(string) file_get_contents($homep.$topf.$ext); |
|
391 | 391 | } |
392 | 392 | $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
393 | 393 | if (!empty($open)) { |
@@ -42,10 +42,10 @@ |
||
42 | 42 | // this 2 "mask" function are here just because the SortableTable |
43 | 43 | function get_legal_data_mask($id, $params = null, $row = null) |
44 | 44 | { |
45 | - return LegalManager::get_legal_data($id, $params, $row); |
|
45 | + return LegalManager::get_legal_data($id, $params, $row); |
|
46 | 46 | } |
47 | 47 | function count_mask() |
48 | 48 | { |
49 | - return LegalManager::count(); |
|
49 | + return LegalManager::count(); |
|
50 | 50 | } |
51 | 51 | Display :: display_footer(); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | require_once __DIR__.'/../inc/global.inc.php'; |
11 | 11 | $this_section = SECTION_PLATFORM_ADMIN; |
12 | 12 | api_protect_admin_script(); |
13 | -$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
13 | +$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
14 | 14 | $tool_name = get_lang('TermsAndConditions'); |
15 | 15 | Display :: display_header($tool_name); |
16 | 16 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | // action menu |
20 | 20 | echo '<div class="actions">'; |
21 | 21 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/legal_add.php">'. |
22 | - Display::return_icon('edit.gif',get_lang('EditTermsAndConditions'), '').get_lang('EditTermsAndConditions').'</a> '; |
|
22 | + Display::return_icon('edit.gif', get_lang('EditTermsAndConditions'), '').get_lang('EditTermsAndConditions').'</a> '; |
|
23 | 23 | echo '</div>'; |
24 | 24 | |
25 | 25 | $legal_count = LegalManager::count(); |
@@ -1212,6 +1212,7 @@ |
||
1212 | 1212 | * Restore a forum-post |
1213 | 1213 | * @TODO Restore tree-structure of posts. For example: attachments to posts. |
1214 | 1214 | * @param false|string $topic_id |
1215 | + * @param false|string $forum_id |
|
1215 | 1216 | */ |
1216 | 1217 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1217 | 1218 | { |
@@ -2801,8 +2801,9 @@ |
||
2801 | 2801 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2802 | 2802 | }*/ |
2803 | 2803 | } elseif(is_dir($path)) { |
2804 | - if (!is_dir($dest . '/' . $file)) |
|
2805 | - mkdir($dest . '/' . $file); |
|
2804 | + if (!is_dir($dest . '/' . $file)) { |
|
2805 | + mkdir($dest . '/' . $file); |
|
2806 | + } |
|
2806 | 2807 | self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
2807 | 2808 | } |
2808 | 2809 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $params['lastedit_date'] = self::DBUTF8($property['lastedit_date']); |
218 | 218 | $params['ref'] = $resource->destination_id; |
219 | 219 | $params['lastedit_type'] = self::DBUTF8($property['lastedit_type']); |
220 | - $params['lastedit_user_id'] = $this->checkUserId($property['lastedit_user_id']); |
|
220 | + $params['lastedit_user_id'] = $this->checkUserId($property['lastedit_user_id']); |
|
221 | 221 | $params['visibility'] = self::DBUTF8($property['visibility']); |
222 | 222 | $params['start_visible'] = self::DBUTF8($property['start_visible']); |
223 | 223 | $params['end_visible'] = self::DBUTF8($property['end_visible']); |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
579 | 579 | $file_exists = file_exists($path.$new_file_name); |
580 | 580 | while ($file_exists) { |
581 | - $i ++; |
|
581 | + $i++; |
|
582 | 582 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
583 | 583 | $file_exists = file_exists($path.$new_file_name); |
584 | 584 | } |
@@ -622,9 +622,9 @@ discard block |
||
622 | 622 | $new_base_path = $_SESSION['new_base_path']; |
623 | 623 | } |
624 | 624 | |
625 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
626 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
627 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
625 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
626 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
627 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
628 | 628 | $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
629 | 629 | |
630 | 630 | copy_folder_course_session( |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | // Replace old course code with the new destination code see BT#1985 |
644 | 644 | if (file_exists($dest_document_path)) { |
645 | 645 | $file_info = pathinfo($dest_document_path); |
646 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
646 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
647 | 647 | $content = file_get_contents($dest_document_path); |
648 | 648 | if (UTF8_CONVERT) { |
649 | 649 | $content = utf8_encode($content); |
@@ -705,8 +705,8 @@ discard block |
||
705 | 705 | //Replace old course code with the new destination code see BT#1985 |
706 | 706 | if (file_exists($path.$new_file_name)) { |
707 | 707 | $file_info = pathinfo($path.$new_file_name); |
708 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
709 | - $content = file_get_contents($path.$new_file_name); |
|
708 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
709 | + $content = file_get_contents($path.$new_file_name); |
|
710 | 710 | if (UTF8_CONVERT) { |
711 | 711 | $content = utf8_encode($content); |
712 | 712 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | // Replace old course code with the new destination code see BT#1985 |
771 | 771 | if (file_exists($path.$new_file_name)) { |
772 | 772 | $file_info = pathinfo($path.$new_file_name); |
773 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
773 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
774 | 774 | $content = file_get_contents($path.$new_file_name); |
775 | 775 | if (UTF8_CONVERT) { |
776 | 776 | $content = utf8_encode($content); |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | // Replace old course code with the new destination code see BT#1985 |
846 | 846 | if (file_exists($path.$document->path)) { |
847 | 847 | $file_info = pathinfo($path.$document->path); |
848 | - if (isset($file_info['extension']) && in_array($file_info['extension'], array('html','htm'))) { |
|
848 | + if (isset($file_info['extension']) && in_array($file_info['extension'], array('html', 'htm'))) { |
|
849 | 849 | $content = file_get_contents($path.$document->path); |
850 | 850 | if (UTF8_CONVERT) { |
851 | 851 | $content = utf8_encode($content); |
@@ -945,8 +945,8 @@ discard block |
||
945 | 945 | case FILE_OVERWRITE: |
946 | 946 | rmdirr($path.$document->path); |
947 | 947 | copyDirTo( |
948 | - $this->course->backup_path . '/' . $document->path, |
|
949 | - $path . dirname($document->path), |
|
948 | + $this->course->backup_path.'/'.$document->path, |
|
949 | + $path.dirname($document->path), |
|
950 | 950 | false |
951 | 951 | ); |
952 | 952 | break; |
@@ -968,23 +968,23 @@ discard block |
||
968 | 968 | $file_exists = file_exists($path.$new_file_name); |
969 | 969 | |
970 | 970 | while ($file_exists) { |
971 | - $i ++; |
|
971 | + $i++; |
|
972 | 972 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
973 | 973 | $file_exists = file_exists($path.$new_file_name); |
974 | 974 | } |
975 | 975 | |
976 | 976 | rename( |
977 | - $this->course->backup_path . '/' . $document->path, |
|
978 | - $this->course->backup_path . '/' . $new_file_name |
|
977 | + $this->course->backup_path.'/'.$document->path, |
|
978 | + $this->course->backup_path.'/'.$new_file_name |
|
979 | 979 | ); |
980 | 980 | copyDirTo( |
981 | - $this->course->backup_path . '/' . $new_file_name, |
|
982 | - $path . dirname($new_file_name), |
|
981 | + $this->course->backup_path.'/'.$new_file_name, |
|
982 | + $path.dirname($new_file_name), |
|
983 | 983 | false |
984 | 984 | ); |
985 | 985 | rename( |
986 | - $this->course->backup_path . '/' . $new_file_name, |
|
987 | - $this->course->backup_path . '/' . $document->path |
|
986 | + $this->course->backup_path.'/'.$new_file_name, |
|
987 | + $this->course->backup_path.'/'.$document->path |
|
988 | 988 | ); |
989 | 989 | |
990 | 990 | break; |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | } else { |
993 | 993 | // end if file exists |
994 | 994 | copyDirTo( |
995 | - $this->course->backup_path . '/' . $document->path, |
|
996 | - $path . dirname($document->path), |
|
995 | + $this->course->backup_path.'/'.$document->path, |
|
996 | + $path.dirname($document->path), |
|
997 | 997 | false |
998 | 998 | ); |
999 | 999 | } |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | $table_forum = Database::get_course_table(TABLE_FORUM); |
1014 | 1014 | $resources = $this->course->resources; |
1015 | 1015 | foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
1016 | - $params = (array)$forum->obj; |
|
1016 | + $params = (array) $forum->obj; |
|
1017 | 1017 | $cat_id = ''; |
1018 | 1018 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
1019 | 1019 | isset($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']])) { |
@@ -1066,13 +1066,13 @@ discard block |
||
1066 | 1066 | foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
1067 | 1067 | if ($topic->obj->forum_id == $id) { |
1068 | 1068 | $this->restore_topic($topic_id, $new_id, $sessionId); |
1069 | - $forum_topics ++; |
|
1069 | + $forum_topics++; |
|
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | if ($forum_topics > 0) { |
1074 | 1074 | $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
1075 | - WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
|
1075 | + WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int) $new_id; |
|
1076 | 1076 | Database::query($sql); |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
1135 | 1135 | $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
1136 | 1136 | |
1137 | - $params = (array)$topic->obj; |
|
1137 | + $params = (array) $topic->obj; |
|
1138 | 1138 | $params = self::DBUTF8_array($params); |
1139 | 1139 | $params['c_id'] = $this->destination_course_id; |
1140 | 1140 | $params['forum_id'] = $forum_id; |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | FROM $link_table |
1249 | 1249 | WHERE |
1250 | 1250 | c_id = ".$this->destination_course_id." AND |
1251 | - category_id='" . intval($cat_id). "'"; |
|
1251 | + category_id='" . intval($cat_id)."'"; |
|
1252 | 1252 | $result = Database::query($sql); |
1253 | 1253 | list($max_order) = Database::fetch_array($result); |
1254 | 1254 | |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | $params['description'] = self::DBUTF8($link->description); |
1264 | 1264 | $params['category_id'] = $cat_id; |
1265 | 1265 | $params['on_homepage'] = $link->on_homepage; |
1266 | - $params['display_order'] = $max_order+1; |
|
1266 | + $params['display_order'] = $max_order + 1; |
|
1267 | 1267 | |
1268 | 1268 | $id = Database::insert($link_table, $params); |
1269 | 1269 | |
@@ -1686,7 +1686,7 @@ discard block |
||
1686 | 1686 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
1687 | 1687 | $sql = "SELECT path FROM $table_doc |
1688 | 1688 | WHERE |
1689 | - c_id = " . $this->destination_course_id . " AND |
|
1689 | + c_id = ".$this->destination_course_id." AND |
|
1690 | 1690 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1691 | 1691 | $doc = Database::query($sql); |
1692 | 1692 | $doc = Database::fetch_object($doc); |
@@ -1723,17 +1723,17 @@ discard block |
||
1723 | 1723 | 'random' => $quiz->random, |
1724 | 1724 | 'active' => $quiz->active, |
1725 | 1725 | 'sound' => self::DBUTF8($doc), |
1726 | - 'max_attempt' => (int)$quiz->max_attempt, |
|
1727 | - 'results_disabled' => (int)$quiz->results_disabled, |
|
1726 | + 'max_attempt' => (int) $quiz->max_attempt, |
|
1727 | + 'results_disabled' => (int) $quiz->results_disabled, |
|
1728 | 1728 | 'access_condition' => $quiz->access_condition, |
1729 | 1729 | 'pass_percentage' => $quiz->pass_percentage, |
1730 | - 'feedback_type' => (int)$quiz->feedback_type, |
|
1731 | - 'random_answers' => (int)$quiz->random_answers, |
|
1730 | + 'feedback_type' => (int) $quiz->feedback_type, |
|
1731 | + 'random_answers' => (int) $quiz->random_answers, |
|
1732 | 1732 | 'random_by_category' => $quiz->random_by_category, |
1733 | 1733 | 'review_answers' => $quiz->review_answers, |
1734 | 1734 | 'propagate_neg' => $quiz->propagate_neg, |
1735 | 1735 | 'text_when_finished' => $quiz->text_when_finished, |
1736 | - 'expired_time' => (int)$quiz->expired_time, |
|
1736 | + 'expired_time' => (int) $quiz->expired_time, |
|
1737 | 1737 | 'start_time' => $quiz->start_time, |
1738 | 1738 | 'end_time' => $quiz->end_time, |
1739 | 1739 | 'save_correct_answers' => 0, |
@@ -1773,10 +1773,10 @@ discard block |
||
1773 | 1773 | $qid = $this->restore_quiz_question($question_id); |
1774 | 1774 | $question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order; |
1775 | 1775 | $sql = "INSERT IGNORE INTO $table_rel SET |
1776 | - c_id = " . $this->destination_course_id . ", |
|
1776 | + c_id = ".$this->destination_course_id.", |
|
1777 | 1777 | question_id = $qid , |
1778 | 1778 | exercice_id = $new_id , |
1779 | - question_order = " . $question_order; |
|
1779 | + question_order = ".$question_order; |
|
1780 | 1780 | Database::query($sql); |
1781 | 1781 | } |
1782 | 1782 | } |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | $sql = "UPDATE $table_que SET |
1849 | 1849 | picture = '$picture_name' |
1850 | 1850 | WHERE |
1851 | - c_id = " . $this->destination_course_id . " AND |
|
1851 | + c_id = ".$this->destination_course_id." AND |
|
1852 | 1852 | id = $new_id "; |
1853 | 1853 | Database::query($sql); |
1854 | 1854 | } |
@@ -2082,7 +2082,7 @@ discard block |
||
2082 | 2082 | $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table |
2083 | 2083 | if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) { |
2084 | 2084 | $resources = $this->course->resources; |
2085 | - foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory ) { |
|
2085 | + foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory) { |
|
2086 | 2086 | $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $id; |
2087 | 2087 | // check if this test_category already exist in the destination BDD |
2088 | 2088 | // do not Database::escape_string $title and $description, it will be done later |
@@ -2233,7 +2233,7 @@ discard block |
||
2233 | 2233 | break; |
2234 | 2234 | case FILE_RENAME: |
2235 | 2235 | $survey_code = $survey->code.'_'; |
2236 | - $i=1; |
|
2236 | + $i = 1; |
|
2237 | 2237 | $temp_survey_code = $survey_code.$i; |
2238 | 2238 | while (!$this->is_survey_code_available($temp_survey_code)) { |
2239 | 2239 | $temp_survey_code = $survey_code.++$i; |
@@ -2265,15 +2265,15 @@ discard block |
||
2265 | 2265 | $sql = "SELECT * FROM $table_sur |
2266 | 2266 | WHERE |
2267 | 2267 | c_id = ".$this->destination_course_id." AND |
2268 | - survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
|
2268 | + survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'"; |
|
2269 | 2269 | $result = Database::query($sql); |
2270 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2270 | + $survey_data = Database::fetch_array($result, 'ASSOC'); |
|
2271 | 2271 | |
2272 | 2272 | // if the survey is shared => also delete the shared content |
2273 | 2273 | if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
2274 | - SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
|
2274 | + SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id); |
|
2275 | 2275 | } |
2276 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2276 | + SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id); |
|
2277 | 2277 | |
2278 | 2278 | // Insert the new source survey |
2279 | 2279 | $new_id = Database::insert($table_sur, $params); |
@@ -2458,13 +2458,13 @@ discard block |
||
2458 | 2458 | |
2459 | 2459 | // Adding the author's image |
2460 | 2460 | if (!empty($lp->preview_image)) { |
2461 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2461 | + $new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image)); |
|
2462 | 2462 | if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
2463 | 2463 | $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
2464 | 2464 | if ($copy_result) { |
2465 | 2465 | $lp->preview_image = $new_filename; |
2466 | 2466 | } else { |
2467 | - $lp->preview_image =''; |
|
2467 | + $lp->preview_image = ''; |
|
2468 | 2468 | } |
2469 | 2469 | } |
2470 | 2470 | } |
@@ -2638,20 +2638,20 @@ discard block |
||
2638 | 2638 | $next_item_ids[$new_item_id] = $item['next_item_id']; |
2639 | 2639 | |
2640 | 2640 | if (!empty($item['prerequisite'])) { |
2641 | - if ($lp->lp_type =='2') { |
|
2641 | + if ($lp->lp_type == '2') { |
|
2642 | 2642 | // if is an sco |
2643 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2643 | + $old_prerequisite[$new_item_id] = $item['prerequisite']; |
|
2644 | 2644 | } else { |
2645 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2645 | + $old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']]; |
|
2646 | 2646 | } |
2647 | 2647 | } |
2648 | 2648 | |
2649 | 2649 | if (!empty($ref)) { |
2650 | - if ($lp->lp_type =='2') { |
|
2650 | + if ($lp->lp_type == '2') { |
|
2651 | 2651 | // if is an sco |
2652 | - $old_refs[$new_item_id]= $ref; |
|
2652 | + $old_refs[$new_item_id] = $ref; |
|
2653 | 2653 | } elseif (isset($new_item_ids[$ref])) { |
2654 | - $old_refs[$new_item_id]= $new_item_ids[$ref]; |
|
2654 | + $old_refs[$new_item_id] = $new_item_ids[$ref]; |
|
2655 | 2655 | } |
2656 | 2656 | } |
2657 | 2657 | |
@@ -2660,7 +2660,7 @@ discard block |
||
2660 | 2660 | |
2661 | 2661 | // Updating prerequisites |
2662 | 2662 | foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
2663 | - if ($my_old_prerequisite != ''){ |
|
2663 | + if ($my_old_prerequisite != '') { |
|
2664 | 2664 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
2665 | 2665 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2666 | 2666 | Database::query($sql); |
@@ -2678,7 +2678,7 @@ discard block |
||
2678 | 2678 | |
2679 | 2679 | foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
2680 | 2680 | $parent_new_id = 0; |
2681 | - if($parent_item_old_id != 0){ |
|
2681 | + if ($parent_item_old_id != 0) { |
|
2682 | 2682 | $parent_new_id = $new_item_ids[$parent_item_old_id]; |
2683 | 2683 | } |
2684 | 2684 | $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
@@ -2687,7 +2687,7 @@ discard block |
||
2687 | 2687 | } |
2688 | 2688 | foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
2689 | 2689 | $previous_new_id = 0; |
2690 | - if ($previous_item_old_id != 0){ |
|
2690 | + if ($previous_item_old_id != 0) { |
|
2691 | 2691 | $previous_new_id = $new_item_ids[$previous_item_old_id]; |
2692 | 2692 | } |
2693 | 2693 | $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
@@ -2697,7 +2697,7 @@ discard block |
||
2697 | 2697 | |
2698 | 2698 | foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
2699 | 2699 | $next_new_id = 0; |
2700 | - if ($next_item_old_id != 0){ |
|
2700 | + if ($next_item_old_id != 0) { |
|
2701 | 2701 | $next_new_id = $new_item_ids[$next_item_old_id]; |
2702 | 2702 | } |
2703 | 2703 | $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
@@ -2707,7 +2707,7 @@ discard block |
||
2707 | 2707 | |
2708 | 2708 | foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
2709 | 2709 | $prerequisite_new_id = 0; |
2710 | - if ($prerequisite_old_id != 0){ |
|
2710 | + if ($prerequisite_old_id != 0) { |
|
2711 | 2711 | $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
2712 | 2712 | } |
2713 | 2713 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
@@ -2828,16 +2828,16 @@ discard block |
||
2828 | 2828 | if ($handle = opendir($source)) { // if the folder exploration is sucsessful, continue |
2829 | 2829 | while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue |
2830 | 2830 | if ($file != '.' && $file != '..') { |
2831 | - $path = $source . '/' . $file; |
|
2831 | + $path = $source.'/'.$file; |
|
2832 | 2832 | if (is_file($path)) { |
2833 | 2833 | /* if (!is_file($dest . '/' . $file) || $overwrite) |
2834 | 2834 | if (!@copy($path, $dest . '/' . $file)) { |
2835 | 2835 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2836 | 2836 | }*/ |
2837 | - } elseif(is_dir($path)) { |
|
2838 | - if (!is_dir($dest . '/' . $file)) |
|
2839 | - mkdir($dest . '/' . $file); |
|
2840 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
2837 | + } elseif (is_dir($path)) { |
|
2838 | + if (!is_dir($dest.'/'.$file)) |
|
2839 | + mkdir($dest.'/'.$file); |
|
2840 | + self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite); |
|
2841 | 2841 | } |
2842 | 2842 | } |
2843 | 2843 | } |
@@ -3035,7 +3035,7 @@ discard block |
||
3035 | 3035 | $this->course->backup_path, |
3036 | 3036 | $this->course->info['path'] |
3037 | 3037 | ); |
3038 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
3038 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
3039 | 3039 | unset($thematic->params['id']); |
3040 | 3040 | unset($thematic->params['iid']); |
3041 | 3041 | |
@@ -3059,7 +3059,7 @@ discard block |
||
3059 | 3059 | unset($thematic_advance['iid']); |
3060 | 3060 | $thematic_advance['attendance_id'] = 0; |
3061 | 3061 | $thematic_advance['thematic_id'] = $last_id; |
3062 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
3062 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
3063 | 3063 | |
3064 | 3064 | $my_id = Database::insert( |
3065 | 3065 | $table_thematic_advance, |
@@ -3082,7 +3082,7 @@ discard block |
||
3082 | 3082 | } |
3083 | 3083 | } |
3084 | 3084 | |
3085 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3085 | + foreach ($thematic->thematic_plan_list as $thematic_plan) { |
|
3086 | 3086 | unset($thematic_plan['id']); |
3087 | 3087 | unset($thematic_plan['iid']); |
3088 | 3088 | $thematic_plan['thematic_id'] = $last_id; |
@@ -3198,7 +3198,7 @@ discard block |
||
3198 | 3198 | // re-create dir |
3199 | 3199 | // @todo check security against injection of dir in crafted course backup here! |
3200 | 3200 | $path = $obj->params['url']; |
3201 | - $path = '/'.str_replace('/','',substr($path,1)); |
|
3201 | + $path = '/'.str_replace('/', '', substr($path, 1)); |
|
3202 | 3202 | |
3203 | 3203 | $workData = array(); |
3204 | 3204 | switch ($this->file_option) { |
@@ -3220,9 +3220,9 @@ discard block |
||
3220 | 3220 | $obj->params['new_dir'] = $obj->params['title']; |
3221 | 3221 | |
3222 | 3222 | if (!empty($this->course_origin_id)) { |
3223 | - $sql = 'SELECT * FROM ' . $table_work_assignment . ' |
|
3223 | + $sql = 'SELECT * FROM '.$table_work_assignment.' |
|
3224 | 3224 | WHERE |
3225 | - c_id = ' . $this->course_origin_id . ' AND |
|
3225 | + c_id = ' . $this->course_origin_id.' AND |
|
3226 | 3226 | publication_id = ' . $id_work; |
3227 | 3227 | |
3228 | 3228 | $result = Database::query($sql); |
@@ -3333,7 +3333,7 @@ discard block |
||
3333 | 3333 | public function DBUTF8_array($array) |
3334 | 3334 | { |
3335 | 3335 | if (UTF8_CONVERT) { |
3336 | - foreach ($array as &$item) { |
|
3336 | + foreach ($array as &$item) { |
|
3337 | 3337 | $item = utf8_encode($item); |
3338 | 3338 | } |
3339 | 3339 | return $array; |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | class CourseRestorer |
25 | 25 | { |
26 | 26 | /** |
27 | - * The course-object |
|
28 | - */ |
|
27 | + * The course-object |
|
28 | + */ |
|
29 | 29 | public $course; |
30 | 30 | public $destination_course_info; |
31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'events', |
45 | 45 | 'forum_category', |
46 | 46 | 'forums', |
47 | - // 'forum_topics', |
|
47 | + // 'forum_topics', |
|
48 | 48 | 'glossary', |
49 | 49 | 'quizzes', |
50 | 50 | 'test_category', |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $this->tool_copy_settings = $array; |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Restore a course. |
|
116 | + /** |
|
117 | + * Restore a course. |
|
118 | 118 | * |
119 | - * @param string $destination_course_code code of the Chamilo-course in |
|
120 | - * @param int $session_id |
|
121 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
119 | + * @param string $destination_course_code code of the Chamilo-course in |
|
120 | + * @param int $session_id |
|
121 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
122 | 122 | * @param bool $respect_base_content |
123 | 123 | * @return false|null |
124 | - */ |
|
124 | + */ |
|
125 | 125 | public function restore( |
126 | 126 | $destination_course_code = '', |
127 | 127 | $session_id = 0, |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
241 | - * Restore only harmless course settings: |
|
240 | + /** |
|
241 | + * Restore only harmless course settings: |
|
242 | 242 | * course_language, visibility, department_name,department_url, |
243 | 243 | * subscribe, unsubscribe ,category_code |
244 | - * |
|
245 | - * @param string $destination_course_code |
|
246 | - */ |
|
244 | + * |
|
245 | + * @param string $destination_course_code |
|
246 | + */ |
|
247 | 247 | public function restore_course_settings($destination_course_code) |
248 | 248 | { |
249 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
250 | - $course_info = $this->course->info; |
|
249 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
250 | + $course_info = $this->course->info; |
|
251 | 251 | $params['course_language'] = $course_info['language']; |
252 | 252 | $params['visibility'] = $course_info['visibility']; |
253 | 253 | $params['department_name'] = $course_info['department_name']; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | $params['subscribe'] = $course_info['subscribe_allowed']; |
258 | 258 | $params['unsubscribe'] = $course_info['unsubscribe']; |
259 | 259 | CourseManager::update_attributes($origin_course_info['real_id'], $params); |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Restore documents |
@@ -923,56 +923,56 @@ discard block |
||
923 | 923 | unset($_SESSION['new_base_foldername']); |
924 | 924 | unset($_SESSION['orig_base_foldername']); |
925 | 925 | unset($_SESSION['new_base_path']); |
926 | - } |
|
926 | + } |
|
927 | 927 | |
928 | - /** |
|
929 | - * Restore scorm documents |
|
930 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
928 | + /** |
|
929 | + * Restore scorm documents |
|
930 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
931 | 931 | * see #7029 |
932 | - */ |
|
933 | - public function restore_scorm_documents() |
|
932 | + */ |
|
933 | + public function restore_scorm_documents() |
|
934 | 934 | { |
935 | - $perm = api_get_permissions_for_new_directories(); |
|
935 | + $perm = api_get_permissions_for_new_directories(); |
|
936 | 936 | |
937 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
938 | - $resources = $this->course->resources; |
|
937 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
938 | + $resources = $this->course->resources; |
|
939 | 939 | |
940 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
941 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
942 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
940 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
941 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
942 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
943 | 943 | |
944 | - if (file_exists($path.$document->path)) { |
|
945 | - switch ($this->file_option) { |
|
946 | - case FILE_OVERWRITE: |
|
947 | - rmdirr($path.$document->path); |
|
944 | + if (file_exists($path.$document->path)) { |
|
945 | + switch ($this->file_option) { |
|
946 | + case FILE_OVERWRITE: |
|
947 | + rmdirr($path.$document->path); |
|
948 | 948 | copyDirTo( |
949 | 949 | $this->course->backup_path . '/' . $document->path, |
950 | 950 | $path . dirname($document->path), |
951 | 951 | false |
952 | 952 | ); |
953 | - break; |
|
954 | - case FILE_SKIP: |
|
955 | - break; |
|
953 | + break; |
|
954 | + case FILE_SKIP: |
|
955 | + break; |
|
956 | 956 | case FILE_RENAME: |
957 | - $i = 1; |
|
958 | - $ext = explode('.', basename($document->path)); |
|
959 | - if (count($ext) > 1) { |
|
960 | - $ext = array_pop($ext); |
|
961 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
962 | - $ext = '.'.$ext; |
|
963 | - } else { |
|
964 | - $ext = ''; |
|
965 | - $file_name_no_ext = $document->path; |
|
966 | - } |
|
967 | - |
|
968 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
969 | - $file_exists = file_exists($path.$new_file_name); |
|
970 | - |
|
971 | - while ($file_exists) { |
|
972 | - $i ++; |
|
973 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
974 | - $file_exists = file_exists($path.$new_file_name); |
|
975 | - } |
|
957 | + $i = 1; |
|
958 | + $ext = explode('.', basename($document->path)); |
|
959 | + if (count($ext) > 1) { |
|
960 | + $ext = array_pop($ext); |
|
961 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
962 | + $ext = '.'.$ext; |
|
963 | + } else { |
|
964 | + $ext = ''; |
|
965 | + $file_name_no_ext = $document->path; |
|
966 | + } |
|
967 | + |
|
968 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
969 | + $file_exists = file_exists($path.$new_file_name); |
|
970 | + |
|
971 | + while ($file_exists) { |
|
972 | + $i ++; |
|
973 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
974 | + $file_exists = file_exists($path.$new_file_name); |
|
975 | + } |
|
976 | 976 | |
977 | 977 | rename( |
978 | 978 | $this->course->backup_path . '/' . $document->path, |
@@ -988,32 +988,32 @@ discard block |
||
988 | 988 | $this->course->backup_path . '/' . $document->path |
989 | 989 | ); |
990 | 990 | |
991 | - break; |
|
992 | - } // end switch |
|
993 | - } else { |
|
991 | + break; |
|
992 | + } // end switch |
|
993 | + } else { |
|
994 | 994 | // end if file exists |
995 | 995 | copyDirTo( |
996 | 996 | $this->course->backup_path . '/' . $document->path, |
997 | 997 | $path . dirname($document->path), |
998 | 998 | false |
999 | 999 | ); |
1000 | - } |
|
1001 | - } // end for each |
|
1002 | - } |
|
1003 | - } |
|
1000 | + } |
|
1001 | + } // end for each |
|
1002 | + } |
|
1003 | + } |
|
1004 | 1004 | |
1005 | - /** |
|
1006 | - * Restore forums |
|
1005 | + /** |
|
1006 | + * Restore forums |
|
1007 | 1007 | * |
1008 | 1008 | * @param int $sessionId |
1009 | 1009 | */ |
1010 | - public function restore_forums($sessionId = 0) |
|
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 |
||
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)) { |
@@ -1124,16 +1124,16 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | } |
1127 | - } |
|
1127 | + } |
|
1128 | 1128 | |
1129 | - /** |
|
1130 | - * Restore a forum-topic |
|
1131 | - * @param false|string $forum_id |
|
1132 | - */ |
|
1129 | + /** |
|
1130 | + * Restore a forum-topic |
|
1131 | + * @param false|string $forum_id |
|
1132 | + */ |
|
1133 | 1133 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1134 | 1134 | { |
1135 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1136 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1135 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1136 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1137 | 1137 | |
1138 | 1138 | $params = (array)$topic->obj; |
1139 | 1139 | $params = self::DBUTF8_array($params); |
@@ -1170,27 +1170,27 @@ discard block |
||
1170 | 1170 | $sessionId |
1171 | 1171 | ); |
1172 | 1172 | |
1173 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1174 | - $topic_replies = -1; |
|
1175 | - |
|
1176 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1177 | - if ($post->obj->thread_id == $thread_id) { |
|
1178 | - $topic_replies++; |
|
1179 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1180 | - } |
|
1181 | - } |
|
1182 | - return $new_id; |
|
1183 | - } |
|
1184 | - |
|
1185 | - /** |
|
1186 | - * Restore a forum-post |
|
1187 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1188 | - * @param false|string $topic_id |
|
1189 | - */ |
|
1173 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1174 | + $topic_replies = -1; |
|
1175 | + |
|
1176 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1177 | + if ($post->obj->thread_id == $thread_id) { |
|
1178 | + $topic_replies++; |
|
1179 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1180 | + } |
|
1181 | + } |
|
1182 | + return $new_id; |
|
1183 | + } |
|
1184 | + |
|
1185 | + /** |
|
1186 | + * Restore a forum-post |
|
1187 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1188 | + * @param false|string $topic_id |
|
1189 | + */ |
|
1190 | 1190 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1191 | 1191 | { |
1192 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1193 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1192 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1193 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1194 | 1194 | $params = (array) $post->obj; |
1195 | 1195 | $params['c_id'] = $this->destination_course_id; |
1196 | 1196 | $params['forum_id'] = $forum_id; |
@@ -1226,37 +1226,37 @@ discard block |
||
1226 | 1226 | null, |
1227 | 1227 | $sessionId |
1228 | 1228 | ); |
1229 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1229 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1230 | 1230 | |
1231 | - return $new_id; |
|
1232 | - } |
|
1231 | + return $new_id; |
|
1232 | + } |
|
1233 | 1233 | |
1234 | - /** |
|
1235 | - * Restore links |
|
1236 | - */ |
|
1234 | + /** |
|
1235 | + * Restore links |
|
1236 | + */ |
|
1237 | 1237 | public function restore_links($session_id = 0) |
1238 | 1238 | { |
1239 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1240 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
1241 | - $resources = $this->course->resources; |
|
1239 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1240 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
1241 | + $resources = $this->course->resources; |
|
1242 | 1242 | |
1243 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1243 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1244 | 1244 | $cat_id = $this->restore_link_category( |
1245 | 1245 | $link->category_id, |
1246 | 1246 | $session_id |
1247 | 1247 | ); |
1248 | - $sql = "SELECT MAX(display_order) |
|
1248 | + $sql = "SELECT MAX(display_order) |
|
1249 | 1249 | FROM $link_table |
1250 | 1250 | WHERE |
1251 | 1251 | c_id = ".$this->destination_course_id." AND |
1252 | 1252 | category_id='" . intval($cat_id). "'"; |
1253 | - $result = Database::query($sql); |
|
1254 | - list($max_order) = Database::fetch_array($result); |
|
1253 | + $result = Database::query($sql); |
|
1254 | + list($max_order) = Database::fetch_array($result); |
|
1255 | 1255 | |
1256 | 1256 | $params = []; |
1257 | - if (!empty($session_id)) { |
|
1257 | + if (!empty($session_id)) { |
|
1258 | 1258 | $params['session_id'] = $session_id; |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | |
1261 | 1261 | $params['c_id'] = $this->destination_course_id; |
1262 | 1262 | $params['url'] = self::DBUTF8($link->url); |
@@ -1285,9 +1285,9 @@ discard block |
||
1285 | 1285 | } |
1286 | 1286 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
1287 | 1287 | } |
1288 | - } |
|
1289 | - } |
|
1290 | - } |
|
1288 | + } |
|
1289 | + } |
|
1290 | + } |
|
1291 | 1291 | |
1292 | 1292 | /** |
1293 | 1293 | * Restore a link-category |
@@ -1331,21 +1331,21 @@ discard block |
||
1331 | 1331 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
1332 | 1332 | } |
1333 | 1333 | |
1334 | - /** |
|
1335 | - * Restore tool intro |
|
1336 | - */ |
|
1334 | + /** |
|
1335 | + * Restore tool intro |
|
1336 | + */ |
|
1337 | 1337 | public function restore_tool_intro($sessionId = 0) |
1338 | 1338 | { |
1339 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1339 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1340 | 1340 | $sessionId = intval($sessionId); |
1341 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1342 | - $resources = $this->course->resources; |
|
1343 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1344 | - $sql = "DELETE FROM $tool_intro_table |
|
1341 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1342 | + $resources = $this->course->resources; |
|
1343 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1344 | + $sql = "DELETE FROM $tool_intro_table |
|
1345 | 1345 | WHERE |
1346 | 1346 | c_id = ".$this->destination_course_id." AND |
1347 | 1347 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
1348 | - Database::query($sql); |
|
1348 | + Database::query($sql); |
|
1349 | 1349 | |
1350 | 1350 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1351 | 1351 | $tool_intro->intro_text, |
@@ -1370,21 +1370,21 @@ discard block |
||
1370 | 1370 | |
1371 | 1371 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
1372 | 1372 | } |
1373 | - } |
|
1374 | - } |
|
1375 | - } |
|
1373 | + } |
|
1374 | + } |
|
1375 | + } |
|
1376 | 1376 | |
1377 | - /** |
|
1378 | - * Restore events |
|
1379 | - */ |
|
1377 | + /** |
|
1378 | + * Restore events |
|
1379 | + */ |
|
1380 | 1380 | public function restore_events($sessionId = 0) |
1381 | 1381 | { |
1382 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1382 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1383 | 1383 | $sessionId = intval($sessionId); |
1384 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
1385 | - $resources = $this->course->resources; |
|
1386 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1387 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1384 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
1385 | + $resources = $this->course->resources; |
|
1386 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1387 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1388 | 1388 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1389 | 1389 | $event->content, |
1390 | 1390 | $this->course->code, |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | 'end_date' => $event->end_date, |
1403 | 1403 | 'session_id' => $sessionId, |
1404 | 1404 | ]; |
1405 | - $new_event_id = Database::insert($table, $params); |
|
1405 | + $new_event_id = Database::insert($table, $params); |
|
1406 | 1406 | |
1407 | 1407 | if ($new_event_id) { |
1408 | 1408 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1414,32 +1414,32 @@ discard block |
||
1414 | 1414 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
1415 | 1415 | } |
1416 | 1416 | |
1417 | - // Copy event attachment |
|
1418 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1419 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1417 | + // Copy event attachment |
|
1418 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1419 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1420 | 1420 | |
1421 | - if (!empty($this->course->orig)) { |
|
1421 | + if (!empty($this->course->orig)) { |
|
1422 | 1422 | |
1423 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1424 | - $sql = 'SELECT path, comment, size, filename |
|
1423 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1424 | + $sql = 'SELECT path, comment, size, filename |
|
1425 | 1425 | FROM '.$table_attachment.' |
1426 | 1426 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
1427 | - $attachment_event = Database::query($sql); |
|
1428 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1427 | + $attachment_event = Database::query($sql); |
|
1428 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1429 | 1429 | |
1430 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1430 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1431 | 1431 | !is_dir($origin_path.$attachment_event->path) |
1432 | 1432 | ) { |
1433 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1433 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1434 | 1434 | $copy_result = copy( |
1435 | 1435 | $origin_path.$attachment_event->path, |
1436 | 1436 | $destination_path.$new_filename |
1437 | 1437 | ); |
1438 | - //$copy_result = true; |
|
1439 | - if ($copy_result) { |
|
1440 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1438 | + //$copy_result = true; |
|
1439 | + if ($copy_result) { |
|
1440 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1441 | 1441 | |
1442 | - $params = [ |
|
1442 | + $params = [ |
|
1443 | 1443 | 'c_id' => $this->destination_course_id, |
1444 | 1444 | 'path' => self::DBUTF8($new_filename), |
1445 | 1445 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1453,20 +1453,20 @@ discard block |
||
1453 | 1453 | Database::query($sql); |
1454 | 1454 | } |
1455 | 1455 | } |
1456 | - } |
|
1457 | - } else { |
|
1458 | - // get the info of the file |
|
1459 | - if (!empty($event->attachment_path) && |
|
1456 | + } |
|
1457 | + } else { |
|
1458 | + // get the info of the file |
|
1459 | + if (!empty($event->attachment_path) && |
|
1460 | 1460 | is_file($origin_path.$event->attachment_path) && |
1461 | 1461 | is_readable($origin_path.$event->attachment_path) |
1462 | 1462 | ) { |
1463 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1463 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1464 | 1464 | $copy_result = copy( |
1465 | 1465 | $origin_path.$event->attachment_path, |
1466 | 1466 | $destination_path.$new_filename |
1467 | 1467 | ); |
1468 | - if ($copy_result) { |
|
1469 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1468 | + if ($copy_result) { |
|
1469 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1470 | 1470 | |
1471 | 1471 | $params = [ |
1472 | 1472 | 'c_id' => $this->destination_course_id, |
@@ -1482,29 +1482,29 @@ discard block |
||
1482 | 1482 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
1483 | 1483 | Database::query($sql); |
1484 | 1484 | } |
1485 | - } |
|
1486 | - } |
|
1487 | - } |
|
1488 | - } |
|
1489 | - } |
|
1490 | - } |
|
1491 | - |
|
1492 | - /** |
|
1493 | - * Restore course-description |
|
1494 | - */ |
|
1485 | + } |
|
1486 | + } |
|
1487 | + } |
|
1488 | + } |
|
1489 | + } |
|
1490 | + } |
|
1491 | + |
|
1492 | + /** |
|
1493 | + * Restore course-description |
|
1494 | + */ |
|
1495 | 1495 | public function restore_course_descriptions($session_id = 0) |
1496 | 1496 | { |
1497 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1498 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1499 | - $resources = $this->course->resources; |
|
1500 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1497 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1498 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1499 | + $resources = $this->course->resources; |
|
1500 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1501 | 1501 | $courseDescription = (array) $cd; |
1502 | 1502 | |
1503 | 1503 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
1504 | 1504 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
1505 | 1505 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
1506 | 1506 | |
1507 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1507 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1508 | 1508 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1509 | 1509 | $content, |
1510 | 1510 | $this->course->code, |
@@ -1533,22 +1533,22 @@ discard block |
||
1533 | 1533 | } |
1534 | 1534 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
1535 | 1535 | } |
1536 | - } |
|
1537 | - } |
|
1538 | - } |
|
1536 | + } |
|
1537 | + } |
|
1538 | + } |
|
1539 | 1539 | |
1540 | - /** |
|
1541 | - * Restore announcements |
|
1542 | - */ |
|
1540 | + /** |
|
1541 | + * Restore announcements |
|
1542 | + */ |
|
1543 | 1543 | public function restore_announcements($sessionId = 0) |
1544 | 1544 | { |
1545 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1545 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1546 | 1546 | $sessionId = intval($sessionId); |
1547 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1548 | - $resources = $this->course->resources; |
|
1549 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1547 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1548 | + $resources = $this->course->resources; |
|
1549 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1550 | 1550 | |
1551 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1551 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1552 | 1552 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1553 | 1553 | $announcement->content, |
1554 | 1554 | $this->course->code, |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | 'session_id' => $sessionId, |
1568 | 1568 | ]; |
1569 | 1569 | |
1570 | - $new_announcement_id = Database::insert($table, $params); |
|
1570 | + $new_announcement_id = Database::insert($table, $params); |
|
1571 | 1571 | |
1572 | 1572 | if ($new_announcement_id) { |
1573 | 1573 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1579,32 +1579,32 @@ discard block |
||
1579 | 1579 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
1580 | 1580 | } |
1581 | 1581 | |
1582 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1583 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1582 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1583 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1584 | 1584 | |
1585 | - // Copy announcement attachment file |
|
1586 | - if (!empty($this->course->orig)) { |
|
1585 | + // Copy announcement attachment file |
|
1586 | + if (!empty($this->course->orig)) { |
|
1587 | 1587 | |
1588 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1589 | - $sql = 'SELECT path, comment, size, filename |
|
1588 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1589 | + $sql = 'SELECT path, comment, size, filename |
|
1590 | 1590 | FROM '.$table_attachment.' |
1591 | 1591 | WHERE |
1592 | 1592 | c_id = '.$this->destination_course_id.' AND |
1593 | 1593 | announcement_id = '.$id; |
1594 | - $attachment_event = Database::query($sql); |
|
1595 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1594 | + $attachment_event = Database::query($sql); |
|
1595 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1596 | 1596 | |
1597 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1597 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1598 | 1598 | !is_dir($origin_path.$attachment_event->path) |
1599 | 1599 | ) { |
1600 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1600 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1601 | 1601 | $copy_result = copy( |
1602 | 1602 | $origin_path.$attachment_event->path, |
1603 | 1603 | $destination_path.$new_filename |
1604 | 1604 | ); |
1605 | 1605 | |
1606 | - if ($copy_result) { |
|
1607 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1606 | + if ($copy_result) { |
|
1607 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1608 | 1608 | |
1609 | 1609 | $params = [ |
1610 | 1610 | 'c_id' => $this->destination_course_id, |
@@ -1621,19 +1621,19 @@ discard block |
||
1621 | 1621 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1622 | 1622 | Database::query($sql); |
1623 | 1623 | } |
1624 | - } |
|
1625 | - } |
|
1626 | - } else { |
|
1627 | - // get the info of the file |
|
1628 | - if (!empty($announcement->attachment_path) && |
|
1624 | + } |
|
1625 | + } |
|
1626 | + } else { |
|
1627 | + // get the info of the file |
|
1628 | + if (!empty($announcement->attachment_path) && |
|
1629 | 1629 | is_file($origin_path.$announcement->attachment_path) && |
1630 | 1630 | is_readable($origin_path.$announcement->attachment_path) |
1631 | 1631 | ) { |
1632 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1633 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1632 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1633 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1634 | 1634 | |
1635 | - if ($copy_result) { |
|
1636 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1635 | + if ($copy_result) { |
|
1636 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1637 | 1637 | |
1638 | 1638 | $params = [ |
1639 | 1639 | 'c_id' => $this->destination_course_id, |
@@ -1650,12 +1650,12 @@ discard block |
||
1650 | 1650 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1651 | 1651 | Database::query($sql); |
1652 | 1652 | } |
1653 | - } |
|
1654 | - } |
|
1655 | - } |
|
1656 | - } |
|
1657 | - } |
|
1658 | - } |
|
1653 | + } |
|
1654 | + } |
|
1655 | + } |
|
1656 | + } |
|
1657 | + } |
|
1658 | + } |
|
1659 | 1659 | |
1660 | 1660 | /** |
1661 | 1661 | * Restore Quiz |
@@ -1666,13 +1666,13 @@ discard block |
||
1666 | 1666 | $session_id = 0, |
1667 | 1667 | $respect_base_content = false |
1668 | 1668 | ) { |
1669 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1670 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1671 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1672 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1673 | - $resources = $this->course->resources; |
|
1669 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1670 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1671 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1672 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1673 | + $resources = $this->course->resources; |
|
1674 | 1674 | |
1675 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1675 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1676 | 1676 | if (isset($quiz->obj)) { |
1677 | 1677 | //For new imports |
1678 | 1678 | $quiz = $quiz->obj; |
@@ -1681,7 +1681,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,31 +1781,31 @@ discard block |
||
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 | 1794 | $em = Database::getManager(); |
1795 | - $resources = $this->course->resources; |
|
1795 | + $resources = $this->course->resources; |
|
1796 | 1796 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
1797 | 1797 | |
1798 | - $new_id = 0; |
|
1798 | + $new_id = 0; |
|
1799 | 1799 | |
1800 | - if (is_object($question)) { |
|
1801 | - if ($question->is_restored()) { |
|
1802 | - return $question->destination_id; |
|
1803 | - } |
|
1804 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1805 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1800 | + if (is_object($question)) { |
|
1801 | + if ($question->is_restored()) { |
|
1802 | + return $question->destination_id; |
|
1803 | + } |
|
1804 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1805 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1806 | 1806 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
1807 | 1807 | |
1808 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1808 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1809 | 1809 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1810 | 1810 | $question->description, |
1811 | 1811 | $this->course->code, |
@@ -1826,7 +1826,7 @@ discard block |
||
1826 | 1826 | 'extra' => self::DBUTF8($question->extra), |
1827 | 1827 | ]; |
1828 | 1828 | |
1829 | - $new_id = Database::insert($table_que, $params); |
|
1829 | + $new_id = Database::insert($table_que, $params); |
|
1830 | 1830 | |
1831 | 1831 | if ($new_id) { |
1832 | 1832 | $sql = "UPDATE $table_que SET id = iid WHERE iid = $new_id"; |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | $allAnswers = []; |
1862 | 1862 | $onlyAnswers = []; |
1863 | 1863 | |
1864 | - if (in_array($question->quiz_type, [DRAGGABLE, MATCHING, MATCHING_DRAGGABLE])) { |
|
1864 | + if (in_array($question->quiz_type, [DRAGGABLE, MATCHING, MATCHING_DRAGGABLE])) { |
|
1865 | 1865 | $allAnswers = array_column($question->answers, 'answer', 'id'); |
1866 | 1866 | } |
1867 | 1867 | |
@@ -1901,11 +1901,11 @@ discard block |
||
1901 | 1901 | $correctAnswers[$answerId] = $answer['correct']; |
1902 | 1902 | $onlyAnswers[$answerId] = $answer['answer']; |
1903 | 1903 | } |
1904 | - } |
|
1905 | - } else { |
|
1904 | + } |
|
1905 | + } else { |
|
1906 | 1906 | |
1907 | - foreach ($question->answers as $index => $answer) { |
|
1908 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1907 | + foreach ($question->answers as $index => $answer) { |
|
1908 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1909 | 1909 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1910 | 1910 | $answer['answer'], |
1911 | 1911 | $this->course->code, |
@@ -1945,8 +1945,8 @@ discard block |
||
1945 | 1945 | |
1946 | 1946 | $correctAnswers[$answerId] = $answer['correct']; |
1947 | 1947 | $onlyAnswers[$answerId] = $answer['answer']; |
1948 | - } |
|
1949 | - } |
|
1948 | + } |
|
1949 | + } |
|
1950 | 1950 | |
1951 | 1951 | // Current course id |
1952 | 1952 | $course_id = api_get_course_int_id(); |
@@ -2067,13 +2067,13 @@ discard block |
||
2067 | 2067 | } |
2068 | 2068 | } |
2069 | 2069 | |
2070 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2071 | - } |
|
2070 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2071 | + } |
|
2072 | 2072 | |
2073 | - return $new_id; |
|
2074 | - } |
|
2073 | + return $new_id; |
|
2074 | + } |
|
2075 | 2075 | |
2076 | - /** |
|
2076 | + /** |
|
2077 | 2077 | * @todo : add session id when used for session |
2078 | 2078 | */ |
2079 | 2079 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2158,21 +2158,21 @@ discard block |
||
2158 | 2158 | $sessionId = intval($sessionId); |
2159 | 2159 | |
2160 | 2160 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
2161 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2162 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2163 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2164 | - $resources = $this->course->resources; |
|
2165 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2161 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2162 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2163 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2164 | + $resources = $this->course->resources; |
|
2165 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2166 | 2166 | |
2167 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2167 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2168 | 2168 | WHERE |
2169 | 2169 | c_id = '.$this->destination_course_id.' AND |
2170 | 2170 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
2171 | 2171 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
2172 | 2172 | |
2173 | - $result_check = Database::query($sql); |
|
2173 | + $result_check = Database::query($sql); |
|
2174 | 2174 | |
2175 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2175 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2176 | 2176 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2177 | 2177 | $survey->title, |
2178 | 2178 | $this->course->code, |
@@ -2226,20 +2226,20 @@ discard block |
||
2226 | 2226 | 'session_id' => $sessionId, |
2227 | 2227 | ]; |
2228 | 2228 | |
2229 | - //An existing survey exists with the same code and the same language |
|
2230 | - if (Database::num_rows($result_check) == 1) { |
|
2231 | - switch ($this->file_option) { |
|
2232 | - case FILE_SKIP: |
|
2233 | - //Do nothing |
|
2234 | - break; |
|
2235 | - case FILE_RENAME: |
|
2236 | - $survey_code = $survey->code.'_'; |
|
2237 | - $i=1; |
|
2238 | - $temp_survey_code = $survey_code.$i; |
|
2239 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2240 | - $temp_survey_code = $survey_code.++$i; |
|
2241 | - } |
|
2242 | - $survey_code = $temp_survey_code; |
|
2229 | + //An existing survey exists with the same code and the same language |
|
2230 | + if (Database::num_rows($result_check) == 1) { |
|
2231 | + switch ($this->file_option) { |
|
2232 | + case FILE_SKIP: |
|
2233 | + //Do nothing |
|
2234 | + break; |
|
2235 | + case FILE_RENAME: |
|
2236 | + $survey_code = $survey->code.'_'; |
|
2237 | + $i=1; |
|
2238 | + $temp_survey_code = $survey_code.$i; |
|
2239 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2240 | + $temp_survey_code = $survey_code.++$i; |
|
2241 | + } |
|
2242 | + $survey_code = $temp_survey_code; |
|
2243 | 2243 | |
2244 | 2244 | $params['code'] = $survey_code; |
2245 | 2245 | $new_id = Database::insert($table_sur, $params); |
@@ -2258,25 +2258,25 @@ discard block |
||
2258 | 2258 | Database::query($sql); |
2259 | 2259 | } |
2260 | 2260 | } |
2261 | - break; |
|
2262 | - case FILE_OVERWRITE: |
|
2263 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
2264 | - // getting the information of the survey (used for when the survey is shared) |
|
2261 | + break; |
|
2262 | + case FILE_OVERWRITE: |
|
2263 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
2264 | + // getting the information of the survey (used for when the survey is shared) |
|
2265 | 2265 | |
2266 | - $sql = "SELECT * FROM $table_sur |
|
2266 | + $sql = "SELECT * FROM $table_sur |
|
2267 | 2267 | WHERE |
2268 | 2268 | c_id = ".$this->destination_course_id." AND |
2269 | 2269 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
2270 | - $result = Database::query($sql); |
|
2271 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2270 | + $result = Database::query($sql); |
|
2271 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2272 | 2272 | |
2273 | - // if the survey is shared => also delete the shared content |
|
2274 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2273 | + // if the survey is shared => also delete the shared content |
|
2274 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2275 | 2275 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
2276 | - } |
|
2277 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2276 | + } |
|
2277 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2278 | 2278 | |
2279 | - // Insert the new source survey |
|
2279 | + // Insert the new source survey |
|
2280 | 2280 | $new_id = Database::insert($table_sur, $params); |
2281 | 2281 | |
2282 | 2282 | if ($new_id) { |
@@ -2297,11 +2297,11 @@ discard block |
||
2297 | 2297 | Database::query($sql); |
2298 | 2298 | } |
2299 | 2299 | } |
2300 | - break; |
|
2301 | - default: |
|
2302 | - break; |
|
2303 | - } |
|
2304 | - } else { |
|
2300 | + break; |
|
2301 | + default: |
|
2302 | + break; |
|
2303 | + } |
|
2304 | + } else { |
|
2305 | 2305 | // No existing survey with the same language and the same code, we just copy the survey |
2306 | 2306 | $new_id = Database::insert($table_sur, $params); |
2307 | 2307 | |
@@ -2323,48 +2323,48 @@ discard block |
||
2323 | 2323 | Database::query($sql); |
2324 | 2324 | } |
2325 | 2325 | } |
2326 | - } |
|
2327 | - } |
|
2328 | - } |
|
2329 | - } |
|
2330 | - |
|
2331 | - /** |
|
2332 | - * Check availability of a survey code |
|
2333 | - * @param string $survey_code |
|
2334 | - */ |
|
2326 | + } |
|
2327 | + } |
|
2328 | + } |
|
2329 | + } |
|
2330 | + |
|
2331 | + /** |
|
2332 | + * Check availability of a survey code |
|
2333 | + * @param string $survey_code |
|
2334 | + */ |
|
2335 | 2335 | public function is_survey_code_available($survey_code) |
2336 | 2336 | { |
2337 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2338 | - $sql = "SELECT * FROM $table_sur |
|
2337 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2338 | + $sql = "SELECT * FROM $table_sur |
|
2339 | 2339 | WHERE |
2340 | 2340 | c_id = ".$this->destination_course_id." AND |
2341 | 2341 | code = '".self::DBUTF8escapestring($survey_code)."'"; |
2342 | - $result = Database::query($sql); |
|
2342 | + $result = Database::query($sql); |
|
2343 | 2343 | if (Database::num_rows($result) > 0) { |
2344 | 2344 | return false; |
2345 | 2345 | } else { |
2346 | 2346 | return true; |
2347 | 2347 | } |
2348 | - } |
|
2348 | + } |
|
2349 | 2349 | |
2350 | - /** |
|
2351 | - * Restore survey-questions |
|
2352 | - * @param string $survey_id |
|
2353 | - */ |
|
2350 | + /** |
|
2351 | + * Restore survey-questions |
|
2352 | + * @param string $survey_id |
|
2353 | + */ |
|
2354 | 2354 | public function restore_survey_question($id, $survey_id) |
2355 | 2355 | { |
2356 | - $resources = $this->course->resources; |
|
2357 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2356 | + $resources = $this->course->resources; |
|
2357 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2358 | 2358 | $new_id = 0; |
2359 | 2359 | |
2360 | - if (is_object($question)) { |
|
2361 | - if ($question->is_restored()) { |
|
2362 | - return $question->destination_id; |
|
2363 | - } |
|
2364 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2365 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2360 | + if (is_object($question)) { |
|
2361 | + if ($question->is_restored()) { |
|
2362 | + return $question->destination_id; |
|
2363 | + } |
|
2364 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2365 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2366 | 2366 | |
2367 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2367 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2368 | 2368 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2369 | 2369 | $question->survey_question, |
2370 | 2370 | $this->course->code, |
@@ -2418,10 +2418,10 @@ discard block |
||
2418 | 2418 | } |
2419 | 2419 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
2420 | 2420 | } |
2421 | - } |
|
2421 | + } |
|
2422 | 2422 | |
2423 | - return $new_id; |
|
2424 | - } |
|
2423 | + return $new_id; |
|
2424 | + } |
|
2425 | 2425 | |
2426 | 2426 | /** |
2427 | 2427 | * Restoring learning paths |
@@ -2432,19 +2432,19 @@ discard block |
||
2432 | 2432 | { |
2433 | 2433 | $session_id = intval($session_id); |
2434 | 2434 | |
2435 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2435 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2436 | 2436 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
2437 | 2437 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
2438 | 2438 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
2439 | 2439 | |
2440 | - $resources = $this->course->resources; |
|
2440 | + $resources = $this->course->resources; |
|
2441 | 2441 | |
2442 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2443 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2442 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2443 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2444 | 2444 | |
2445 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2446 | - $condition_session = ''; |
|
2447 | - if (!empty($session_id)) { |
|
2445 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2446 | + $condition_session = ''; |
|
2447 | + if (!empty($session_id)) { |
|
2448 | 2448 | if ($respect_base_content) { |
2449 | 2449 | $my_session_id = $lp->session_id; |
2450 | 2450 | if (!empty($lp->session_id)) { |
@@ -2455,20 +2455,20 @@ discard block |
||
2455 | 2455 | $session_id = intval($session_id); |
2456 | 2456 | $condition_session = $session_id; |
2457 | 2457 | } |
2458 | - } |
|
2459 | - |
|
2460 | - // Adding the author's image |
|
2461 | - if (!empty($lp->preview_image)) { |
|
2462 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2463 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2464 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2465 | - if ($copy_result) { |
|
2466 | - $lp->preview_image = $new_filename; |
|
2467 | - } else { |
|
2468 | - $lp->preview_image =''; |
|
2469 | - } |
|
2470 | - } |
|
2471 | - } |
|
2458 | + } |
|
2459 | + |
|
2460 | + // Adding the author's image |
|
2461 | + if (!empty($lp->preview_image)) { |
|
2462 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2463 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2464 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2465 | + if ($copy_result) { |
|
2466 | + $lp->preview_image = $new_filename; |
|
2467 | + } else { |
|
2468 | + $lp->preview_image =''; |
|
2469 | + } |
|
2470 | + } |
|
2471 | + } |
|
2472 | 2472 | |
2473 | 2473 | if ($this->add_text_in_items) { |
2474 | 2474 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2526,7 +2526,7 @@ discard block |
||
2526 | 2526 | $params['session_id'] = $condition_session; |
2527 | 2527 | } |
2528 | 2528 | |
2529 | - $new_lp_id = Database::insert($table_main, $params); |
|
2529 | + $new_lp_id = Database::insert($table_main, $params); |
|
2530 | 2530 | |
2531 | 2531 | if ($new_lp_id) { |
2532 | 2532 | |
@@ -2587,13 +2587,13 @@ discard block |
||
2587 | 2587 | $old_refs = array(); |
2588 | 2588 | $prerequisite_ids = array(); |
2589 | 2589 | |
2590 | - foreach ($lp->get_items() as $index => $item) { |
|
2591 | - // we set the ref code here and then we update in a for loop |
|
2592 | - $ref = $item['ref']; |
|
2590 | + foreach ($lp->get_items() as $index => $item) { |
|
2591 | + // we set the ref code here and then we update in a for loop |
|
2592 | + $ref = $item['ref']; |
|
2593 | 2593 | |
2594 | - // Dealing with path the same way as ref as some data has |
|
2594 | + // Dealing with path the same way as ref as some data has |
|
2595 | 2595 | // been put into path when it's a local resource |
2596 | - // Only fix the path for no scos |
|
2596 | + // Only fix the path for no scos |
|
2597 | 2597 | if ($item['item_type'] == 'sco') { |
2598 | 2598 | $path = $item['path']; |
2599 | 2599 | } else { |
@@ -2624,128 +2624,128 @@ discard block |
||
2624 | 2624 | 'launch_data' => self::DBUTF8($item['launch_data']), |
2625 | 2625 | ]; |
2626 | 2626 | |
2627 | - $new_item_id = Database::insert($table_item, $params); |
|
2627 | + $new_item_id = Database::insert($table_item, $params); |
|
2628 | 2628 | |
2629 | 2629 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
2630 | 2630 | Database::query($sql); |
2631 | 2631 | |
2632 | - //save a link between old and new item IDs |
|
2633 | - $new_item_ids[$item['id']] = $new_item_id; |
|
2634 | - //save a reference of items that need a parent_item_id refresh |
|
2635 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2636 | - //save a reference of items that need a previous_item_id refresh |
|
2637 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2638 | - //save a reference of items that need a next_item_id refresh |
|
2639 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2640 | - |
|
2641 | - if (!empty($item['prerequisite'])) { |
|
2642 | - if ($lp->lp_type =='2') { |
|
2643 | - // if is an sco |
|
2644 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2645 | - } else { |
|
2646 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2647 | - } |
|
2648 | - } |
|
2649 | - |
|
2650 | - if (!empty($ref)) { |
|
2651 | - if ($lp->lp_type =='2') { |
|
2652 | - // if is an sco |
|
2653 | - $old_refs[$new_item_id]= $ref; |
|
2654 | - } elseif (isset($new_item_ids[$ref])) { |
|
2632 | + //save a link between old and new item IDs |
|
2633 | + $new_item_ids[$item['id']] = $new_item_id; |
|
2634 | + //save a reference of items that need a parent_item_id refresh |
|
2635 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2636 | + //save a reference of items that need a previous_item_id refresh |
|
2637 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2638 | + //save a reference of items that need a next_item_id refresh |
|
2639 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2640 | + |
|
2641 | + if (!empty($item['prerequisite'])) { |
|
2642 | + if ($lp->lp_type =='2') { |
|
2643 | + // if is an sco |
|
2644 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2645 | + } else { |
|
2646 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2647 | + } |
|
2648 | + } |
|
2649 | + |
|
2650 | + if (!empty($ref)) { |
|
2651 | + if ($lp->lp_type =='2') { |
|
2652 | + // if is an sco |
|
2653 | + $old_refs[$new_item_id]= $ref; |
|
2654 | + } elseif (isset($new_item_ids[$ref])) { |
|
2655 | 2655 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
2656 | 2656 | } |
2657 | - } |
|
2657 | + } |
|
2658 | 2658 | |
2659 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2660 | - } |
|
2659 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2660 | + } |
|
2661 | 2661 | |
2662 | - // Updating prerequisites |
|
2663 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2664 | - if ($my_old_prerequisite != ''){ |
|
2665 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2662 | + // Updating prerequisites |
|
2663 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2664 | + if ($my_old_prerequisite != ''){ |
|
2665 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2666 | 2666 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2667 | - Database::query($sql); |
|
2668 | - } |
|
2669 | - } |
|
2670 | - |
|
2671 | - // Updating refs |
|
2672 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
2673 | - if ($my_old_ref != '') { |
|
2674 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2667 | + Database::query($sql); |
|
2668 | + } |
|
2669 | + } |
|
2670 | + |
|
2671 | + // Updating refs |
|
2672 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
2673 | + if ($my_old_ref != '') { |
|
2674 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2675 | 2675 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2676 | - Database::query($sql); |
|
2677 | - } |
|
2678 | - } |
|
2679 | - |
|
2680 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2681 | - $parent_new_id = 0; |
|
2682 | - if($parent_item_old_id != 0){ |
|
2683 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2684 | - } |
|
2685 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2676 | + Database::query($sql); |
|
2677 | + } |
|
2678 | + } |
|
2679 | + |
|
2680 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2681 | + $parent_new_id = 0; |
|
2682 | + if($parent_item_old_id != 0){ |
|
2683 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2684 | + } |
|
2685 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2686 | 2686 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2687 | - Database::query($sql); |
|
2688 | - } |
|
2689 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2690 | - $previous_new_id = 0; |
|
2691 | - if ($previous_item_old_id != 0){ |
|
2692 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2693 | - } |
|
2694 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2687 | + Database::query($sql); |
|
2688 | + } |
|
2689 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2690 | + $previous_new_id = 0; |
|
2691 | + if ($previous_item_old_id != 0){ |
|
2692 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2693 | + } |
|
2694 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2695 | 2695 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2696 | - Database::query($sql); |
|
2697 | - } |
|
2698 | - |
|
2699 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2700 | - $next_new_id = 0; |
|
2701 | - if ($next_item_old_id != 0){ |
|
2702 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2703 | - } |
|
2704 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2696 | + Database::query($sql); |
|
2697 | + } |
|
2698 | + |
|
2699 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2700 | + $next_new_id = 0; |
|
2701 | + if ($next_item_old_id != 0){ |
|
2702 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2703 | + } |
|
2704 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2705 | 2705 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2706 | - Database::query($sql); |
|
2707 | - } |
|
2708 | - |
|
2709 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2710 | - $prerequisite_new_id = 0; |
|
2711 | - if ($prerequisite_old_id != 0){ |
|
2712 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2713 | - } |
|
2714 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2706 | + Database::query($sql); |
|
2707 | + } |
|
2708 | + |
|
2709 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2710 | + $prerequisite_new_id = 0; |
|
2711 | + if ($prerequisite_old_id != 0){ |
|
2712 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2713 | + } |
|
2714 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2715 | 2715 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2716 | - Database::query($sql); |
|
2717 | - } |
|
2718 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2719 | - } |
|
2720 | - } |
|
2721 | - } |
|
2722 | - |
|
2723 | - /** |
|
2724 | - * Restore works |
|
2716 | + Database::query($sql); |
|
2717 | + } |
|
2718 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2719 | + } |
|
2720 | + } |
|
2721 | + } |
|
2722 | + |
|
2723 | + /** |
|
2724 | + * Restore works |
|
2725 | 2725 | * @deprecated use restore_works |
2726 | 2726 | * |
2727 | - */ |
|
2728 | - public function restore_student_publication($sessionId = 0) |
|
2727 | + */ |
|
2728 | + public function restore_student_publication($sessionId = 0) |
|
2729 | 2729 | { |
2730 | 2730 | $sessionId = intval($sessionId); |
2731 | 2731 | $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
2732 | 2732 | $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION); |
2733 | 2733 | $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY); |
2734 | 2734 | |
2735 | - // Query in student publication |
|
2736 | - $sql = 'SELECT * FROM '.$work_table.' |
|
2735 | + // Query in student publication |
|
2736 | + $sql = 'SELECT * FROM '.$work_table.' |
|
2737 | 2737 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
2738 | 2738 | |
2739 | - $result = Database::query($sql); |
|
2740 | - $folders = Database::store_result($result, 'ASSOC'); |
|
2739 | + $result = Database::query($sql); |
|
2740 | + $folders = Database::store_result($result, 'ASSOC'); |
|
2741 | 2741 | |
2742 | - foreach ($folders as $folder) { |
|
2743 | - $old_id = $folder['id']; |
|
2742 | + foreach ($folders as $folder) { |
|
2743 | + $old_id = $folder['id']; |
|
2744 | 2744 | unset($folder['id']); |
2745 | - $folder['c_id'] = $this->destination_course_id; |
|
2745 | + $folder['c_id'] = $this->destination_course_id; |
|
2746 | 2746 | $folder['parent_id'] = 0; |
2747 | 2747 | $folder['session_id'] = $sessionId ? $sessionId : null; |
2748 | - $new_id = Database::insert($work_table, $folder); |
|
2748 | + $new_id = Database::insert($work_table, $folder); |
|
2749 | 2749 | |
2750 | 2750 | if ($new_id) { |
2751 | 2751 | // query in item property |
@@ -2804,23 +2804,23 @@ discard block |
||
2804 | 2804 | } |
2805 | 2805 | } |
2806 | 2806 | } |
2807 | - } |
|
2807 | + } |
|
2808 | 2808 | |
2809 | 2809 | $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/'; |
2810 | 2810 | $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/'; |
2811 | 2811 | self::allow_create_all_directory($origin, $destination, false); |
2812 | - } |
|
2812 | + } |
|
2813 | 2813 | |
2814 | 2814 | /** |
2815 | - * copy all directory and sub directory |
|
2816 | - * @param string The path origin |
|
2817 | - * @param string The path destination |
|
2818 | - * @param boolean Option Overwrite |
|
2819 | - * @param string $source |
|
2820 | - * @param string $dest |
|
2821 | - * @return void() |
|
2822 | - * @deprecated |
|
2823 | - */ |
|
2815 | + * copy all directory and sub directory |
|
2816 | + * @param string The path origin |
|
2817 | + * @param string The path destination |
|
2818 | + * @param boolean Option Overwrite |
|
2819 | + * @param string $source |
|
2820 | + * @param string $dest |
|
2821 | + * @return void() |
|
2822 | + * @deprecated |
|
2823 | + */ |
|
2824 | 2824 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
2825 | 2825 | { |
2826 | 2826 | if (!is_dir($dest)) { |
@@ -2831,7 +2831,7 @@ discard block |
||
2831 | 2831 | if ($file != '.' && $file != '..') { |
2832 | 2832 | $path = $source . '/' . $file; |
2833 | 2833 | if (is_file($path)) { |
2834 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2834 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2835 | 2835 | if (!@copy($path, $dest . '/' . $file)) { |
2836 | 2836 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2837 | 2837 | }*/ |
@@ -2846,12 +2846,12 @@ discard block |
||
2846 | 2846 | } |
2847 | 2847 | } |
2848 | 2848 | |
2849 | - /** |
|
2850 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2851 | - * @param string Tool name |
|
2852 | - * @param integer Old ID |
|
2853 | - * @return integer New ID |
|
2854 | - */ |
|
2849 | + /** |
|
2850 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2851 | + * @param string Tool name |
|
2852 | + * @param integer Old ID |
|
2853 | + * @return integer New ID |
|
2854 | + */ |
|
2855 | 2855 | public function get_new_id($tool, $ref) |
2856 | 2856 | { |
2857 | 2857 | // Check if the value exist in the current array. |
@@ -2873,25 +2873,25 @@ discard block |
||
2873 | 2873 | } |
2874 | 2874 | |
2875 | 2875 | return ''; |
2876 | - } |
|
2876 | + } |
|
2877 | 2877 | |
2878 | - /** |
|
2879 | - * Restore glossary |
|
2880 | - */ |
|
2878 | + /** |
|
2879 | + * Restore glossary |
|
2880 | + */ |
|
2881 | 2881 | public function restore_glossary($session_id = 0) |
2882 | 2882 | { |
2883 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2884 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2885 | - $resources = $this->course->resources; |
|
2886 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2883 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2884 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2885 | + $resources = $this->course->resources; |
|
2886 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2887 | 2887 | |
2888 | 2888 | $params = []; |
2889 | - if (!empty($session_id)) { |
|
2890 | - $session_id = intval($session_id); |
|
2889 | + if (!empty($session_id)) { |
|
2890 | + $session_id = intval($session_id); |
|
2891 | 2891 | $params['session_id'] = $session_id; |
2892 | - } |
|
2892 | + } |
|
2893 | 2893 | |
2894 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2894 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2895 | 2895 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2896 | 2896 | $glossary->description, |
2897 | 2897 | $this->course->code, |
@@ -2925,27 +2925,27 @@ discard block |
||
2925 | 2925 | |
2926 | 2926 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
2927 | 2927 | } |
2928 | - } |
|
2929 | - } |
|
2930 | - } |
|
2928 | + } |
|
2929 | + } |
|
2930 | + } |
|
2931 | 2931 | |
2932 | 2932 | /** |
2933 | 2933 | * @param int $session_id |
2934 | 2934 | */ |
2935 | 2935 | public function restore_wiki($session_id = 0) |
2936 | 2936 | { |
2937 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2938 | - // wiki table of the target course |
|
2939 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2940 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2937 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2938 | + // wiki table of the target course |
|
2939 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2940 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2941 | 2941 | |
2942 | - // storing all the resources that have to be copied in an array |
|
2943 | - $resources = $this->course->resources; |
|
2942 | + // storing all the resources that have to be copied in an array |
|
2943 | + $resources = $this->course->resources; |
|
2944 | 2944 | |
2945 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2946 | - // the sql statement to insert the groups from the old course to the new course |
|
2945 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2946 | + // the sql statement to insert the groups from the old course to the new course |
|
2947 | 2947 | |
2948 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2948 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2949 | 2949 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2950 | 2950 | $wiki->content, |
2951 | 2951 | $this->course->code, |
@@ -2980,7 +2980,7 @@ discard block |
||
2980 | 2980 | 'user_ip' => '', |
2981 | 2981 | ]; |
2982 | 2982 | |
2983 | - $new_id = Database::insert($table_wiki, $params); |
|
2983 | + $new_id = Database::insert($table_wiki, $params); |
|
2984 | 2984 | |
2985 | 2985 | if ($new_id) { |
2986 | 2986 | $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid |
@@ -3010,9 +3010,9 @@ discard block |
||
3010 | 3010 | |
3011 | 3011 | Database::insert($table_wiki_conf, $params); |
3012 | 3012 | } |
3013 | - } |
|
3014 | - } |
|
3015 | - } |
|
3013 | + } |
|
3014 | + } |
|
3015 | + } |
|
3016 | 3016 | |
3017 | 3017 | /** |
3018 | 3018 | * Restore Thematics |
@@ -3020,15 +3020,15 @@ discard block |
||
3020 | 3020 | */ |
3021 | 3021 | public function restore_thematic($session_id = 0) |
3022 | 3022 | { |
3023 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
3023 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
3024 | 3024 | $table_thematic = Database::get_course_table(TABLE_THEMATIC); |
3025 | 3025 | $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); |
3026 | 3026 | $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); |
3027 | 3027 | |
3028 | - $resources = $this->course->resources; |
|
3029 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
3028 | + $resources = $this->course->resources; |
|
3029 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
3030 | 3030 | |
3031 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3031 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3032 | 3032 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3033 | 3033 | $thematic->params['content'], |
3034 | 3034 | $this->course->code, |
@@ -3036,13 +3036,13 @@ discard block |
||
3036 | 3036 | $this->course->backup_path, |
3037 | 3037 | $this->course->info['path'] |
3038 | 3038 | ); |
3039 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
3040 | - unset($thematic->params['id']); |
|
3039 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
3040 | + unset($thematic->params['id']); |
|
3041 | 3041 | unset($thematic->params['iid']); |
3042 | 3042 | |
3043 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3043 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3044 | 3044 | |
3045 | - if ($last_id) { |
|
3045 | + if ($last_id) { |
|
3046 | 3046 | |
3047 | 3047 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
3048 | 3048 | Database::query($sql); |
@@ -3055,12 +3055,12 @@ discard block |
||
3055 | 3055 | api_get_user_id() |
3056 | 3056 | ); |
3057 | 3057 | |
3058 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3059 | - unset($thematic_advance['id']); |
|
3058 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3059 | + unset($thematic_advance['id']); |
|
3060 | 3060 | unset($thematic_advance['iid']); |
3061 | - $thematic_advance['attendance_id'] = 0; |
|
3062 | - $thematic_advance['thematic_id'] = $last_id; |
|
3063 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
3061 | + $thematic_advance['attendance_id'] = 0; |
|
3062 | + $thematic_advance['thematic_id'] = $last_id; |
|
3063 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
3064 | 3064 | |
3065 | 3065 | $my_id = Database::insert( |
3066 | 3066 | $table_thematic_advance, |
@@ -3068,7 +3068,7 @@ discard block |
||
3068 | 3068 | false |
3069 | 3069 | ); |
3070 | 3070 | |
3071 | - if ($my_id) { |
|
3071 | + if ($my_id) { |
|
3072 | 3072 | |
3073 | 3073 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
3074 | 3074 | Database::query($sql); |
@@ -3080,17 +3080,17 @@ discard block |
||
3080 | 3080 | 'ThematicAdvanceAdded', |
3081 | 3081 | api_get_user_id() |
3082 | 3082 | ); |
3083 | - } |
|
3084 | - } |
|
3083 | + } |
|
3084 | + } |
|
3085 | 3085 | |
3086 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3087 | - unset($thematic_plan['id']); |
|
3086 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3087 | + unset($thematic_plan['id']); |
|
3088 | 3088 | unset($thematic_plan['iid']); |
3089 | - $thematic_plan['thematic_id'] = $last_id; |
|
3090 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
3091 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3089 | + $thematic_plan['thematic_id'] = $last_id; |
|
3090 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
3091 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3092 | 3092 | |
3093 | - if ($my_id) { |
|
3093 | + if ($my_id) { |
|
3094 | 3094 | |
3095 | 3095 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
3096 | 3096 | Database::query($sql); |
@@ -3102,12 +3102,12 @@ discard block |
||
3102 | 3102 | 'ThematicPlanAdded', |
3103 | 3103 | api_get_user_id() |
3104 | 3104 | ); |
3105 | - } |
|
3106 | - } |
|
3107 | - } |
|
3108 | - } |
|
3109 | - } |
|
3110 | - } |
|
3105 | + } |
|
3106 | + } |
|
3107 | + } |
|
3108 | + } |
|
3109 | + } |
|
3110 | + } |
|
3111 | 3111 | |
3112 | 3112 | /** |
3113 | 3113 | * Restore Attendance |
@@ -3115,14 +3115,14 @@ discard block |
||
3115 | 3115 | */ |
3116 | 3116 | public function restore_attendance($session_id = 0) |
3117 | 3117 | { |
3118 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3119 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3120 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3118 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3119 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3120 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3121 | 3121 | |
3122 | - $resources = $this->course->resources; |
|
3123 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3122 | + $resources = $this->course->resources; |
|
3123 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3124 | 3124 | |
3125 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3125 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3126 | 3126 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3127 | 3127 | $obj->params['description'], |
3128 | 3128 | $this->course->code, |
@@ -3134,11 +3134,11 @@ discard block |
||
3134 | 3134 | unset($obj->params['id']); |
3135 | 3135 | unset($obj->params['iid']); |
3136 | 3136 | |
3137 | - $obj->params['c_id'] = $this->destination_course_id; |
|
3137 | + $obj->params['c_id'] = $this->destination_course_id; |
|
3138 | 3138 | |
3139 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
3139 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
3140 | 3140 | |
3141 | - if (is_numeric($last_id)) { |
|
3141 | + if (is_numeric($last_id)) { |
|
3142 | 3142 | |
3143 | 3143 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
3144 | 3144 | Database::query($sql); |
@@ -3152,11 +3152,11 @@ discard block |
||
3152 | 3152 | ); |
3153 | 3153 | |
3154 | 3154 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
3155 | - unset($attendance_calendar['id']); |
|
3155 | + unset($attendance_calendar['id']); |
|
3156 | 3156 | unset($attendance_calendar['iid']); |
3157 | 3157 | |
3158 | - $attendance_calendar['attendance_id'] = $last_id; |
|
3159 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3158 | + $attendance_calendar['attendance_id'] = $last_id; |
|
3159 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3160 | 3160 | $attendanceCalendarId = Database::insert( |
3161 | 3161 | $table_attendance_calendar, |
3162 | 3162 | $attendance_calendar |
@@ -3164,11 +3164,11 @@ discard block |
||
3164 | 3164 | |
3165 | 3165 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
3166 | 3166 | Database::query($sql); |
3167 | - } |
|
3168 | - } |
|
3169 | - } |
|
3170 | - } |
|
3171 | - } |
|
3167 | + } |
|
3168 | + } |
|
3169 | + } |
|
3170 | + } |
|
3171 | + } |
|
3172 | 3172 | |
3173 | 3173 | /** |
3174 | 3174 | * Restore Works |
@@ -3340,11 +3340,11 @@ discard block |
||
3340 | 3340 | */ |
3341 | 3341 | public function DBUTF8($str) |
3342 | 3342 | { |
3343 | - if (UTF8_CONVERT) { |
|
3343 | + if (UTF8_CONVERT) { |
|
3344 | 3344 | $str = utf8_encode($str); |
3345 | 3345 | } |
3346 | - return $str; |
|
3347 | - } |
|
3346 | + return $str; |
|
3347 | + } |
|
3348 | 3348 | |
3349 | 3349 | /** |
3350 | 3350 | * @param string $str |
@@ -3355,8 +3355,8 @@ discard block |
||
3355 | 3355 | if (UTF8_CONVERT) { |
3356 | 3356 | $str = utf8_encode($str); |
3357 | 3357 | } |
3358 | - return Database::escape_string($str); |
|
3359 | - } |
|
3358 | + return Database::escape_string($str); |
|
3359 | + } |
|
3360 | 3360 | |
3361 | 3361 | /** |
3362 | 3362 | * @param array $array |