@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | $this_section = SECTION_COURSES; |
12 | 12 | |
13 | 13 | if (isset($_GET['session']) && $_GET['session']) { |
14 | - $archive_path = api_get_path(SYS_ARCHIVE_PATH).'temp/'; |
|
15 | - $_cid = true; |
|
16 | - $is_courseAdmin = true; |
|
14 | + $archive_path = api_get_path(SYS_ARCHIVE_PATH).'temp/'; |
|
15 | + $_cid = true; |
|
16 | + $is_courseAdmin = true; |
|
17 | 17 | } else { |
18 | - $archive_path = CourseArchiver::getBackupDir(); |
|
18 | + $archive_path = CourseArchiver::getBackupDir(); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $archive_file = isset($_GET['archive']) ? $_GET['archive'] : null; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | $content_type = ''; |
32 | 32 | |
33 | 33 | if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) { |
34 | - $content_type = 'application/force-download'; |
|
34 | + $content_type = 'application/force-download'; |
|
35 | 35 | } elseif ($extension === 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) { |
36 | - $content_type = 'application/force-download'; |
|
36 | + $content_type = 'application/force-download'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if (empty($content_type)) { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || |
46 | 46 | (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup') |
47 | 47 | ) { |
48 | - $export = false; |
|
48 | + $export = false; |
|
49 | 49 | if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') { |
50 | 50 | $FileZip = create_zip(); |
51 | 51 | $to_group_id = 0; |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | $query_session_doc = Database::query($sql_session_doc); |
289 | 289 | while ($rows_course_session_file = Database::fetch_assoc($query_session_doc)) { |
290 | 290 | $zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'], |
291 | - PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$rows_session['name'], |
|
292 | - PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE'] |
|
293 | - ); |
|
291 | + PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$rows_session['name'], |
|
292 | + PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE'] |
|
293 | + ); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $javascript .= "'".$dropbox_person->sentWork[$i]->title."'"; |
217 | 217 | } |
218 | 218 | } |
219 | - $javascript .= "); |
|
219 | + $javascript .= "); |
|
220 | 220 | |
221 | 221 | function checkfile(str) |
222 | 222 | { |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(), |
327 | 327 | 'name' => get_lang('Dropbox', ''), |
328 | 328 | ); |
329 | - $nameTools = get_lang('ReceivedFiles'); |
|
329 | + $nameTools = get_lang('ReceivedFiles'); |
|
330 | 330 | |
331 | - if ($action == 'addreceivedcategory') { |
|
331 | + if ($action == 'addreceivedcategory') { |
|
332 | 332 | $interbreadcrumb[] = array( |
333 | 333 | 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=received&'.api_get_cidreq(), |
334 | 334 | 'name' => get_lang('ReceivedFiles'), |
335 | 335 | ); |
336 | - $nameTools = get_lang('AddNewCategory'); |
|
337 | - } |
|
336 | + $nameTools = get_lang('AddNewCategory'); |
|
337 | + } |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | if ($view == 'sent' || empty($view)) { |
@@ -6,7 +6,6 @@ discard block |
||
6 | 6 | * |
7 | 7 | * Contains several functions dealing with displaying, |
8 | 8 | * editing,... of a blog |
9 | - |
|
10 | 9 | * @package chamilo.blogs |
11 | 10 | * @author Toon Keppens <[email protected]> |
12 | 11 | * @author Julio Montoya - Cleaning code |
@@ -335,7 +334,7 @@ discard block |
||
335 | 334 | // Storing the attachments if any |
336 | 335 | if ($result) { |
337 | 336 | $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
338 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
337 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
339 | 338 | Database::query($sql); |
340 | 339 | $id = Database::insert_id(); |
341 | 340 | if ($id) { |
@@ -479,7 +478,7 @@ discard block |
||
479 | 478 | // Storing the attachments if any |
480 | 479 | if ($result) { |
481 | 480 | $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
482 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
481 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
483 | 482 | Database::query($sql); |
484 | 483 | |
485 | 484 | $id = Database::insert_id(); |
@@ -1398,10 +1397,10 @@ discard block |
||
1398 | 1397 | echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
1399 | 1398 | echo "<table class=\"data_table\">"; |
1400 | 1399 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1401 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1402 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1403 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
1404 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1400 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1401 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1402 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
1403 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1405 | 1404 | "</tr>"; |
1406 | 1405 | |
1407 | 1406 | |
@@ -1433,14 +1432,14 @@ discard block |
||
1433 | 1432 | echo '<td width="50">'; |
1434 | 1433 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">'; |
1435 | 1434 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
1436 | - echo "</a>"; |
|
1437 | - echo '<a href="'.$delete_link.'"'; |
|
1438 | - echo $delete_confirm; |
|
1439 | - echo '>'; |
|
1435 | + echo "</a>"; |
|
1436 | + echo '<a href="'.$delete_link.'"'; |
|
1437 | + echo $delete_confirm; |
|
1438 | + echo '>'; |
|
1440 | 1439 | echo Display::return_icon($delete_icon, $delete_title); |
1441 | - echo "</a>"; |
|
1442 | - echo '</td>'; |
|
1443 | - echo '</tr>'; |
|
1440 | + echo "</a>"; |
|
1441 | + echo '</td>'; |
|
1442 | + echo '</tr>'; |
|
1444 | 1443 | } |
1445 | 1444 | echo "</table>"; |
1446 | 1445 | } |
@@ -1464,11 +1463,11 @@ discard block |
||
1464 | 1463 | echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
1465 | 1464 | echo "<table class=\"data_table\">"; |
1466 | 1465 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1467 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1468 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
1469 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1470 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1471 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1466 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1467 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
1468 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1469 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1470 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1472 | 1471 | "</tr>"; |
1473 | 1472 | |
1474 | 1473 | $course_id = api_get_course_int_id(); |
@@ -2316,7 +2315,7 @@ discard block |
||
2316 | 2315 | * @param Integer $year: the 4-digit year indication e.g. 2005 |
2317 | 2316 | * |
2318 | 2317 | * @return html code |
2319 | - */ |
|
2318 | + */ |
|
2320 | 2319 | public static function display_minimonthcalendar($month, $year, $blog_id) |
2321 | 2320 | { |
2322 | 2321 | // Init |
@@ -2609,34 +2608,34 @@ discard block |
||
2609 | 2608 | */ |
2610 | 2609 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2611 | 2610 | { |
2612 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2613 | - |
|
2614 | - $blog_id = intval($blog_id); |
|
2615 | - $comment_id = intval($comment_id); |
|
2616 | - $post_id = intval($post_id); |
|
2617 | - $row=array(); |
|
2618 | - $where=''; |
|
2619 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2620 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2621 | - } |
|
2622 | - |
|
2623 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2624 | - if (!empty ($post_id)) { |
|
2625 | - $where.= ' AND '; |
|
2626 | - } |
|
2627 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2628 | - } |
|
2611 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2612 | + |
|
2613 | + $blog_id = intval($blog_id); |
|
2614 | + $comment_id = intval($comment_id); |
|
2615 | + $post_id = intval($post_id); |
|
2616 | + $row=array(); |
|
2617 | + $where=''; |
|
2618 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2619 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2620 | + } |
|
2621 | + |
|
2622 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2623 | + if (!empty ($post_id)) { |
|
2624 | + $where.= ' AND '; |
|
2625 | + } |
|
2626 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2627 | + } |
|
2629 | 2628 | |
2630 | 2629 | $course_id = api_get_course_int_id(); |
2631 | 2630 | |
2632 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2631 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2633 | 2632 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2634 | 2633 | |
2635 | - $result=Database::query($sql); |
|
2636 | - if (Database::num_rows($result)!=0) { |
|
2637 | - $row=Database::fetch_array($result); |
|
2638 | - } |
|
2639 | - return $row; |
|
2634 | + $result=Database::query($sql); |
|
2635 | + if (Database::num_rows($result)!=0) { |
|
2636 | + $row=Database::fetch_array($result); |
|
2637 | + } |
|
2638 | + return $row; |
|
2640 | 2639 | } |
2641 | 2640 | |
2642 | 2641 | /** |
@@ -2652,16 +2651,16 @@ discard block |
||
2652 | 2651 | $post_id = null, |
2653 | 2652 | $comment_id = null |
2654 | 2653 | ) { |
2655 | - $_course = api_get_course_info(); |
|
2656 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2657 | - $blog_id = intval($blog_id); |
|
2658 | - $comment_id = intval($comment_id); |
|
2659 | - $post_id = intval($post_id); |
|
2654 | + $_course = api_get_course_info(); |
|
2655 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2656 | + $blog_id = intval($blog_id); |
|
2657 | + $comment_id = intval($comment_id); |
|
2658 | + $post_id = intval($post_id); |
|
2660 | 2659 | |
2661 | 2660 | $course_id = api_get_course_int_id(); |
2662 | - $where = null; |
|
2661 | + $where = null; |
|
2663 | 2662 | |
2664 | - // delete files in DB |
|
2663 | + // delete files in DB |
|
2665 | 2664 | if (!empty ($post_id) && is_numeric($post_id)) { |
2666 | 2665 | $where .= ' AND post_id ="'.$post_id.'" '; |
2667 | 2666 | } |
@@ -2673,25 +2672,25 @@ discard block |
||
2673 | 2672 | $where .= ' comment_id ="'.$comment_id.'" '; |
2674 | 2673 | } |
2675 | 2674 | |
2676 | - // delete all files in directory |
|
2677 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2678 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2679 | - $updir = $sys_course_path.$courseDir; |
|
2675 | + // delete all files in directory |
|
2676 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2677 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2678 | + $updir = $sys_course_path.$courseDir; |
|
2680 | 2679 | |
2681 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2680 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2682 | 2681 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2683 | - $result=Database::query($sql); |
|
2684 | - |
|
2685 | - while ($row=Database::fetch_row($result)) { |
|
2686 | - $file=$updir.'/'.$row[0]; |
|
2687 | - if (Security::check_abs_path($file,$updir) ) |
|
2688 | - { |
|
2689 | - @ unlink($file); |
|
2690 | - } |
|
2691 | - } |
|
2692 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2682 | + $result=Database::query($sql); |
|
2683 | + |
|
2684 | + while ($row=Database::fetch_row($result)) { |
|
2685 | + $file=$updir.'/'.$row[0]; |
|
2686 | + if (Security::check_abs_path($file,$updir) ) |
|
2687 | + { |
|
2688 | + @ unlink($file); |
|
2689 | + } |
|
2690 | + } |
|
2691 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2693 | 2692 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2694 | - Database::query($sql); |
|
2693 | + Database::query($sql); |
|
2695 | 2694 | } |
2696 | 2695 | |
2697 | 2696 | /** |
@@ -2707,7 +2706,7 @@ discard block |
||
2707 | 2706 | $course_id = $course_info['real_id']; |
2708 | 2707 | $user_id = intval($user_id); |
2709 | 2708 | |
2710 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2709 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2711 | 2710 | FROM $tbl_blogs blog |
2712 | 2711 | INNER JOIN $tbl_blog_post post |
2713 | 2712 | ON (blog.blog_id = post.blog_id) |
@@ -2716,19 +2715,19 @@ discard block |
||
2716 | 2715 | post.c_id = $course_id AND |
2717 | 2716 | author_id = $user_id AND visibility = 1 |
2718 | 2717 | ORDER BY post.date_creation DESC "; |
2719 | - $result = Database::query($sql); |
|
2720 | - $return_data = ''; |
|
2721 | - |
|
2722 | - if (Database::num_rows($result)!=0) { |
|
2723 | - while ($row=Database::fetch_array($result)) { |
|
2724 | - $return_data.= '<div class="clear"></div><br />'; |
|
2725 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2726 | - $return_data.= '<br / >'; |
|
2727 | - $return_data.= $row['full_text']; |
|
2728 | - $return_data.= '<br /><br />'; |
|
2729 | - } |
|
2730 | - } |
|
2731 | - return $return_data; |
|
2718 | + $result = Database::query($sql); |
|
2719 | + $return_data = ''; |
|
2720 | + |
|
2721 | + if (Database::num_rows($result)!=0) { |
|
2722 | + while ($row=Database::fetch_array($result)) { |
|
2723 | + $return_data.= '<div class="clear"></div><br />'; |
|
2724 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2725 | + $return_data.= '<br / >'; |
|
2726 | + $return_data.= $row['full_text']; |
|
2727 | + $return_data.= '<br /><br />'; |
|
2728 | + } |
|
2729 | + } |
|
2730 | + return $return_data; |
|
2732 | 2731 | } |
2733 | 2732 | |
2734 | 2733 | /** |
@@ -2745,7 +2744,7 @@ discard block |
||
2745 | 2744 | $course_info = api_get_course_info($course_code); |
2746 | 2745 | $course_id = $course_info['real_id']; |
2747 | 2746 | |
2748 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2747 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2749 | 2748 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2750 | 2749 | ON (blog.blog_id = comment.blog_id) |
2751 | 2750 | WHERE blog.c_id = $course_id AND |
@@ -2753,17 +2752,17 @@ discard block |
||
2753 | 2752 | author_id = $user_id AND |
2754 | 2753 | visibility = 1 |
2755 | 2754 | ORDER BY blog_name"; |
2756 | - $result = Database::query($sql); |
|
2757 | - $return_data = ''; |
|
2758 | - if (Database::num_rows($result)!=0) { |
|
2759 | - while ($row=Database::fetch_array($result)) { |
|
2760 | - $return_data.= '<div class="clear"></div><br />'; |
|
2761 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2762 | - $return_data.= '<br / >'; |
|
2763 | - $return_data.= $row['comment']; |
|
2764 | - $return_data.= '<br />'; |
|
2765 | - } |
|
2766 | - } |
|
2767 | - return $return_data; |
|
2755 | + $result = Database::query($sql); |
|
2756 | + $return_data = ''; |
|
2757 | + if (Database::num_rows($result)!=0) { |
|
2758 | + while ($row=Database::fetch_array($result)) { |
|
2759 | + $return_data.= '<div class="clear"></div><br />'; |
|
2760 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2761 | + $return_data.= '<br / >'; |
|
2762 | + $return_data.= $row['comment']; |
|
2763 | + $return_data.= '<br />'; |
|
2764 | + } |
|
2765 | + } |
|
2766 | + return $return_data; |
|
2768 | 2767 | } |
2769 | 2768 |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * provides a side connection to a vchamilo database |
|
146 | - * @param array $_configuration |
|
145 | + * provides a side connection to a vchamilo database |
|
146 | + * @param array $_configuration |
|
147 | 147 | * |
148 | - * @return \Doctrine\DBAL\Driver\Connection |
|
149 | - */ |
|
148 | + * @return \Doctrine\DBAL\Driver\Connection |
|
149 | + */ |
|
150 | 150 | public static function bootConnection(&$_configuration) |
151 | 151 | { |
152 | 152 | $dbParams = array( |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
257 | - * drop a vchamilo instance databases using the physical connection |
|
258 | - * @param stdClass $params |
|
259 | - * return an array of errors or false if ok |
|
260 | - */ |
|
257 | + * drop a vchamilo instance databases using the physical connection |
|
258 | + * @param stdClass $params |
|
259 | + * return an array of errors or false if ok |
|
260 | + */ |
|
261 | 261 | public static function dropDatabase($params) |
262 | 262 | { |
263 | 263 | $params = clone $params; |
@@ -332,10 +332,10 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | - * get a proper SQLdump command |
|
336 | - * @param object $vchamilodata the complete new host information |
|
337 | - * @return string the shell command |
|
338 | - */ |
|
335 | + * get a proper SQLdump command |
|
336 | + * @param object $vchamilodata the complete new host information |
|
337 | + * @return string the shell command |
|
338 | + */ |
|
339 | 339 | public static function getDatabaseDumpCmd($vchamilodata) |
340 | 340 | { |
341 | 341 | $pgm = self::getConfig('vchamilo', 'mysql_cmd'); |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
495 | - * read manifest values in vchamilo template. |
|
496 | - */ |
|
495 | + * read manifest values in vchamilo template. |
|
496 | + */ |
|
497 | 497 | public static function getVmanifest($version) |
498 | 498 | { |
499 | 499 | $file = api_get_path(SYS_PATH).'/plugin/vchamilo/templates/'.$version.'/manifest.php'; |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
515 | - * make a fake vchamilo that represents the current host |
|
516 | - */ |
|
515 | + * make a fake vchamilo that represents the current host |
|
516 | + */ |
|
517 | 517 | public static function makeThis() |
518 | 518 | { |
519 | 519 | global $_configuration; |
@@ -577,10 +577,10 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
580 | - * this function set will map standard moodle API calls to chamilo |
|
581 | - * internal primitives. This avoids too many changes to do in imported |
|
582 | - * code |
|
583 | - */ |
|
580 | + * this function set will map standard moodle API calls to chamilo |
|
581 | + * internal primitives. This avoids too many changes to do in imported |
|
582 | + * code |
|
583 | + */ |
|
584 | 584 | public static function getConfig($module, $key, $isplugin = true) |
585 | 585 | { |
586 | 586 | if ($isplugin) { |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | ); |
481 | 481 | |
482 | 482 | if (($counter % $batchSize) === 0) { |
483 | - $em->flush(); |
|
484 | - $em->clear(); |
|
483 | + $em->flush(); |
|
484 | + $em->clear(); |
|
485 | 485 | } |
486 | 486 | $counter++; |
487 | 487 | } |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | ); |
503 | 503 | |
504 | 504 | if (($counter % $batchSize) === 0) { |
505 | - $em->flush(); |
|
506 | - $em->clear(); |
|
505 | + $em->flush(); |
|
506 | + $em->clear(); |
|
507 | 507 | } |
508 | 508 | $counter++; |
509 | 509 | } |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) |
1407 | 1407 | ) "; |
1408 | 1408 | } else { |
1409 | - $cond_user_id = " AND ( |
|
1409 | + $cond_user_id = " AND ( |
|
1410 | 1410 | ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id.")) |
1411 | 1411 | )"; |
1412 | 1412 | } |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | $firstname = $userInfo['firstname']; |
373 | 373 | $lastname = $userInfo['lastname']; |
374 | 374 | |
375 | - if (api_is_western_name_order()) { |
|
376 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
377 | - } else { |
|
378 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
379 | - } |
|
375 | + if (api_is_western_name_order()) { |
|
376 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
377 | + } else { |
|
378 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
379 | + } |
|
380 | 380 | |
381 | - if ($userId) { |
|
381 | + if ($userId) { |
|
382 | 382 | |
383 | 383 | // Logout the current user |
384 | 384 | LoginDelete(api_get_user_id()); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | { |
442 | 442 | $sql = prepare_user_sql_query(false); |
443 | 443 | if (!in_array($direction, array('ASC','DESC'))) { |
444 | - $direction = 'ASC'; |
|
444 | + $direction = 'ASC'; |
|
445 | 445 | } |
446 | 446 | $column = intval($column); |
447 | 447 | $from = intval($from); |
@@ -452,23 +452,23 @@ discard block |
||
452 | 452 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
453 | 453 | } |
454 | 454 | |
455 | - $sql .= " ORDER BY col$column $direction "; |
|
456 | - $sql .= " LIMIT $from,$number_of_items"; |
|
455 | + $sql .= " ORDER BY col$column $direction "; |
|
456 | + $sql .= " LIMIT $from,$number_of_items"; |
|
457 | 457 | |
458 | - $res = Database::query($sql); |
|
458 | + $res = Database::query($sql); |
|
459 | 459 | |
460 | - $users = array (); |
|
460 | + $users = array (); |
|
461 | 461 | $t = time(); |
462 | - while ($user = Database::fetch_row($res)) { |
|
463 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
464 | - $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
462 | + while ($user = Database::fetch_row($res)) { |
|
463 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
464 | + $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
465 | 465 | |
466 | 466 | if ($user[7] == 1 && !empty($user[10])) { |
467 | 467 | // check expiration date |
468 | 468 | $expiration_time = convert_sql_date($user[10]); |
469 | 469 | // if expiration date is passed, store a special value for active field |
470 | 470 | if ($expiration_time < $t) { |
471 | - $user[7] = '-1'; |
|
471 | + $user[7] = '-1'; |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | */ |
499 | 499 | function email_filter($email) |
500 | 500 | { |
501 | - return Display :: encrypted_mailto_link($email, $email); |
|
501 | + return Display :: encrypted_mailto_link($email, $email); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | */ |
509 | 509 | function user_filter($name, $params, $row) |
510 | 510 | { |
511 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
511 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -526,17 +526,17 @@ discard block |
||
526 | 526 | $user_is_anonymous = false; |
527 | 527 | $current_user_status_label = $row['7']; |
528 | 528 | |
529 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
530 | - $user_is_anonymous = true; |
|
531 | - } |
|
532 | - $result = ''; |
|
533 | - if (!$user_is_anonymous) { |
|
529 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
530 | + $user_is_anonymous = true; |
|
531 | + } |
|
532 | + $result = ''; |
|
533 | + if (!$user_is_anonymous) { |
|
534 | 534 | $icon = Display::return_icon( |
535 | 535 | 'course.png', |
536 | 536 | get_lang('Courses'), |
537 | 537 | array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')') |
538 | 538 | ); |
539 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
539 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
540 | 540 | '.$icon.' |
541 | 541 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
542 | 542 | </a>'; |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | get_lang('Sessions'), |
547 | 547 | array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')') |
548 | 548 | ); |
549 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
549 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
550 | 550 | '.$icon.' |
551 | 551 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
552 | 552 | </a>'; |
553 | - } else { |
|
554 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
555 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
556 | - } |
|
553 | + } else { |
|
554 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
555 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
556 | + } |
|
557 | 557 | |
558 | 558 | if (api_is_platform_admin()) { |
559 | 559 | if (!$user_is_anonymous) { |
@@ -602,18 +602,18 @@ discard block |
||
602 | 602 | ); |
603 | 603 | } |
604 | 604 | |
605 | - if ($is_admin) { |
|
605 | + if ($is_admin) { |
|
606 | 606 | $result .= Display::return_icon( |
607 | 607 | 'admin_star.png', |
608 | 608 | get_lang('IsAdministrator'), |
609 | 609 | array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL) |
610 | 610 | ); |
611 | - } else { |
|
612 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
613 | - } |
|
611 | + } else { |
|
612 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
613 | + } |
|
614 | 614 | |
615 | - // actions for assigning sessions, courses or users |
|
616 | - if (!api_is_session_admin()) { |
|
615 | + // actions for assigning sessions, courses or users |
|
616 | + if (!api_is_session_admin()) { |
|
617 | 617 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
618 | 618 | $result .= Display::url( |
619 | 619 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | ); |
644 | 644 | } |
645 | 645 | } |
646 | - } |
|
646 | + } |
|
647 | 647 | |
648 | 648 | if (api_is_platform_admin()) { |
649 | 649 | $result .= ' <a data-title="'.get_lang('FreeBusyCalendar').'" href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'. |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
665 | - return $result; |
|
665 | + return $result; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -694,16 +694,16 @@ discard block |
||
694 | 694 | if ($action === 'edit') { |
695 | 695 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
696 | 696 | } elseif ($row['0'] <> $_user['user_id']) { |
697 | - // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
697 | + // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
698 | 698 | $result = Display::return_icon( |
699 | 699 | $image.'.png', |
700 | 700 | get_lang(ucfirst($action)), |
701 | 701 | array('onclick' => 'active_user(this);', 'id' => 'img_'.$row['0']), |
702 | 702 | 16 |
703 | 703 | ); |
704 | - } |
|
704 | + } |
|
705 | 705 | |
706 | - return $result; |
|
706 | + return $result; |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
717 | 717 | */ |
718 | 718 | function status_filter($status) { |
719 | - $statusname = api_get_status_langvars(); |
|
720 | - return $statusname[$status]; |
|
719 | + $statusname = api_get_status_langvars(); |
|
720 | + return $statusname[$status]; |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | |
734 | 734 | if (!empty($action)) { |
735 | 735 | $check = Security::check_token('get'); |
736 | - if ($check) { |
|
737 | - switch ($action) { |
|
736 | + if ($check) { |
|
737 | + switch ($action) { |
|
738 | 738 | case 'add_user_to_my_url': |
739 | 739 | $user_id = $_REQUEST["user_id"]; |
740 | 740 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -744,52 +744,52 @@ discard block |
||
744 | 744 | $message = Display::return_message($message, 'confirmation'); |
745 | 745 | } |
746 | 746 | break; |
747 | - case 'delete_user': |
|
748 | - if (api_is_platform_admin()) { |
|
747 | + case 'delete_user': |
|
748 | + if (api_is_platform_admin()) { |
|
749 | 749 | $user_to_delete = $_GET['user_id']; |
750 | 750 | $userToDeleteInfo = api_get_user_info($user_to_delete); |
751 | 751 | $current_user_id = api_get_user_id(); |
752 | 752 | |
753 | - if ($userToDeleteInfo && $deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
754 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
755 | - $message = Display :: return_message( |
|
756 | - get_lang('UserDeleted').': '.$userToDeleteInfo['complete_name_with_username'], |
|
753 | + if ($userToDeleteInfo && $deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
754 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
755 | + $message = Display :: return_message( |
|
756 | + get_lang('UserDeleted').': '.$userToDeleteInfo['complete_name_with_username'], |
|
757 | 757 | 'confirmation' |
758 | 758 | ); |
759 | - } else { |
|
760 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
761 | - } |
|
762 | - } else { |
|
763 | - $message = Display :: return_message(get_lang('CannotDeleteUser'), 'error'); |
|
764 | - } |
|
765 | - Display::addFlash($message); |
|
766 | - header('Location: '.api_get_self()); |
|
759 | + } else { |
|
760 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
761 | + } |
|
762 | + } else { |
|
763 | + $message = Display :: return_message(get_lang('CannotDeleteUser'), 'error'); |
|
764 | + } |
|
765 | + Display::addFlash($message); |
|
766 | + header('Location: '.api_get_self()); |
|
767 | 767 | exit; |
768 | - } |
|
769 | - break; |
|
768 | + } |
|
769 | + break; |
|
770 | 770 | case 'delete': |
771 | - if (api_is_platform_admin()) { |
|
772 | - $number_of_selected_users = count($_POST['id']); |
|
773 | - $number_of_deleted_users = 0; |
|
774 | - if (is_array($_POST['id'])) { |
|
775 | - foreach ($_POST['id'] as $index => $user_id) { |
|
776 | - if ($user_id != $_user['user_id']) { |
|
777 | - if (UserManager::delete_user($user_id)) { |
|
778 | - $number_of_deleted_users++; |
|
779 | - } |
|
780 | - } |
|
781 | - } |
|
782 | - } |
|
783 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
771 | + if (api_is_platform_admin()) { |
|
772 | + $number_of_selected_users = count($_POST['id']); |
|
773 | + $number_of_deleted_users = 0; |
|
774 | + if (is_array($_POST['id'])) { |
|
775 | + foreach ($_POST['id'] as $index => $user_id) { |
|
776 | + if ($user_id != $_user['user_id']) { |
|
777 | + if (UserManager::delete_user($user_id)) { |
|
778 | + $number_of_deleted_users++; |
|
779 | + } |
|
780 | + } |
|
781 | + } |
|
782 | + } |
|
783 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
784 | 784 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
785 | - } else { |
|
785 | + } else { |
|
786 | 786 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
787 | - } |
|
788 | - } |
|
789 | - break; |
|
790 | - } |
|
791 | - Security::clear_token(); |
|
792 | - } |
|
787 | + } |
|
788 | + } |
|
789 | + break; |
|
790 | + } |
|
791 | + Security::clear_token(); |
|
792 | + } |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | // Create a search-box |
@@ -807,15 +807,15 @@ discard block |
||
807 | 807 | $actionsCenter = ''; |
808 | 808 | $actionsRight = ''; |
809 | 809 | if (api_is_platform_admin()) { |
810 | - $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
811 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
810 | + $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
811 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | $actionsLeft .= $form->returnForm(); |
815 | 815 | $actionsCenter .= $searchAdvanced; |
816 | 816 | |
817 | 817 | if (isset($_GET['keyword'])) { |
818 | - $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
818 | + $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
819 | 819 | } elseif (isset ($_GET['keyword_firstname'])) { |
820 | 820 | $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
821 | 821 | $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | $table->set_header(2, get_lang('OfficialCode')); |
890 | 890 | |
891 | 891 | if (api_is_western_name_order()) { |
892 | - $table->set_header(3, get_lang('FirstName')); |
|
893 | - $table->set_header(4, get_lang('LastName')); |
|
892 | + $table->set_header(3, get_lang('FirstName')); |
|
893 | + $table->set_header(4, get_lang('LastName')); |
|
894 | 894 | } else { |
895 | - $table->set_header(3, get_lang('LastName')); |
|
896 | - $table->set_header(4, get_lang('FirstName')); |
|
895 | + $table->set_header(3, get_lang('LastName')); |
|
896 | + $table->set_header(4, get_lang('FirstName')); |
|
897 | 897 | } |
898 | 898 | $table->set_header(5, get_lang('LoginName')); |
899 | 899 | $table->set_header(6, get_lang('Email')); |
@@ -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', |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | $this->tool_copy_settings = $array; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Restore a course. |
|
115 | + /** |
|
116 | + * Restore a course. |
|
117 | 117 | * |
118 | - * @param string $destination_course_code code of the Chamilo-course in |
|
119 | - * @param int $session_id |
|
120 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
118 | + * @param string $destination_course_code code of the Chamilo-course in |
|
119 | + * @param int $session_id |
|
120 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
121 | 121 | * @param bool $respect_base_content |
122 | 122 | * @return false|null |
123 | - */ |
|
123 | + */ |
|
124 | 124 | public function restore( |
125 | 125 | $destination_course_code = '', |
126 | 126 | $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 |
@@ -903,56 +903,56 @@ discard block |
||
903 | 903 | unset($_SESSION['new_base_foldername']); |
904 | 904 | unset($_SESSION['orig_base_foldername']); |
905 | 905 | unset($_SESSION['new_base_path']); |
906 | - } |
|
906 | + } |
|
907 | 907 | |
908 | - /** |
|
909 | - * Restore scorm documents |
|
910 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
908 | + /** |
|
909 | + * Restore scorm documents |
|
910 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
911 | 911 | * see #7029 |
912 | - */ |
|
913 | - public function restore_scorm_documents() |
|
912 | + */ |
|
913 | + public function restore_scorm_documents() |
|
914 | 914 | { |
915 | - $perm = api_get_permissions_for_new_directories(); |
|
915 | + $perm = api_get_permissions_for_new_directories(); |
|
916 | 916 | |
917 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
918 | - $resources = $this->course->resources; |
|
917 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
918 | + $resources = $this->course->resources; |
|
919 | 919 | |
920 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
921 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
922 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
920 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
921 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
922 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
923 | 923 | |
924 | - if (file_exists($path.$document->path)) { |
|
925 | - switch ($this->file_option) { |
|
926 | - case FILE_OVERWRITE: |
|
927 | - rmdirr($path.$document->path); |
|
924 | + if (file_exists($path.$document->path)) { |
|
925 | + switch ($this->file_option) { |
|
926 | + case FILE_OVERWRITE: |
|
927 | + rmdirr($path.$document->path); |
|
928 | 928 | copyDirTo( |
929 | 929 | $this->course->backup_path . '/' . $document->path, |
930 | 930 | $path . dirname($document->path), |
931 | 931 | false |
932 | 932 | ); |
933 | - break; |
|
934 | - case FILE_SKIP: |
|
935 | - break; |
|
933 | + break; |
|
934 | + case FILE_SKIP: |
|
935 | + break; |
|
936 | 936 | case FILE_RENAME: |
937 | - $i = 1; |
|
938 | - $ext = explode('.', basename($document->path)); |
|
939 | - if (count($ext) > 1) { |
|
940 | - $ext = array_pop($ext); |
|
941 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
942 | - $ext = '.'.$ext; |
|
943 | - } else { |
|
944 | - $ext = ''; |
|
945 | - $file_name_no_ext = $document->path; |
|
946 | - } |
|
947 | - |
|
948 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
949 | - $file_exists = file_exists($path.$new_file_name); |
|
950 | - |
|
951 | - while ($file_exists) { |
|
952 | - $i ++; |
|
953 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
954 | - $file_exists = file_exists($path.$new_file_name); |
|
955 | - } |
|
937 | + $i = 1; |
|
938 | + $ext = explode('.', basename($document->path)); |
|
939 | + if (count($ext) > 1) { |
|
940 | + $ext = array_pop($ext); |
|
941 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
942 | + $ext = '.'.$ext; |
|
943 | + } else { |
|
944 | + $ext = ''; |
|
945 | + $file_name_no_ext = $document->path; |
|
946 | + } |
|
947 | + |
|
948 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
949 | + $file_exists = file_exists($path.$new_file_name); |
|
950 | + |
|
951 | + while ($file_exists) { |
|
952 | + $i ++; |
|
953 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
954 | + $file_exists = file_exists($path.$new_file_name); |
|
955 | + } |
|
956 | 956 | |
957 | 957 | rename( |
958 | 958 | $this->course->backup_path . '/' . $document->path, |
@@ -968,30 +968,30 @@ discard block |
||
968 | 968 | $this->course->backup_path . '/' . $document->path |
969 | 969 | ); |
970 | 970 | |
971 | - break; |
|
972 | - } // end switch |
|
973 | - } else { |
|
971 | + break; |
|
972 | + } // end switch |
|
973 | + } else { |
|
974 | 974 | // end if file exists |
975 | 975 | copyDirTo( |
976 | 976 | $this->course->backup_path . '/' . $document->path, |
977 | 977 | $path . dirname($document->path), |
978 | 978 | false |
979 | 979 | ); |
980 | - } |
|
981 | - } // end for each |
|
982 | - } |
|
983 | - } |
|
984 | - |
|
985 | - /** |
|
986 | - * Restore forums |
|
987 | - */ |
|
988 | - public function restore_forums($sessionId = 0) |
|
980 | + } |
|
981 | + } // end for each |
|
982 | + } |
|
983 | + } |
|
984 | + |
|
985 | + /** |
|
986 | + * Restore forums |
|
987 | + */ |
|
988 | + public function restore_forums($sessionId = 0) |
|
989 | 989 | { |
990 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
990 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
991 | 991 | $sessionId = intval($sessionId); |
992 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
993 | - $resources = $this->course->resources; |
|
994 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
992 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
993 | + $resources = $this->course->resources; |
|
994 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
995 | 995 | $params = (array)$forum->obj; |
996 | 996 | $cat_id = ''; |
997 | 997 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1038,33 +1038,33 @@ discard block |
||
1038 | 1038 | Database::query($sql); |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1042 | - |
|
1043 | - $forum_topics = 0; |
|
1044 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1045 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1046 | - if ($topic->obj->forum_id == $id) { |
|
1047 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1048 | - $forum_topics ++; |
|
1049 | - } |
|
1050 | - } |
|
1051 | - } |
|
1052 | - if ($forum_topics > 0) { |
|
1053 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1041 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1042 | + |
|
1043 | + $forum_topics = 0; |
|
1044 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1045 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1046 | + if ($topic->obj->forum_id == $id) { |
|
1047 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1048 | + $forum_topics ++; |
|
1049 | + } |
|
1050 | + } |
|
1051 | + } |
|
1052 | + if ($forum_topics > 0) { |
|
1053 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1054 | 1054 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
1055 | - Database::query($sql); |
|
1056 | - } |
|
1057 | - } |
|
1058 | - } |
|
1059 | - } |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * Restore forum-categories |
|
1063 | - */ |
|
1055 | + Database::query($sql); |
|
1056 | + } |
|
1057 | + } |
|
1058 | + } |
|
1059 | + } |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * Restore forum-categories |
|
1063 | + */ |
|
1064 | 1064 | public function restore_forum_category($my_id = null, $sessionId = 0) |
1065 | 1065 | { |
1066 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1067 | - $resources = $this->course->resources; |
|
1066 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1067 | + $resources = $this->course->resources; |
|
1068 | 1068 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
1069 | 1069 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
1070 | 1070 | if (!empty($my_id)) { |
@@ -1102,16 +1102,16 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | } |
1104 | 1104 | } |
1105 | - } |
|
1105 | + } |
|
1106 | 1106 | |
1107 | - /** |
|
1108 | - * Restore a forum-topic |
|
1109 | - * @param false|string $forum_id |
|
1110 | - */ |
|
1107 | + /** |
|
1108 | + * Restore a forum-topic |
|
1109 | + * @param false|string $forum_id |
|
1110 | + */ |
|
1111 | 1111 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1112 | 1112 | { |
1113 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1114 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1113 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1114 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1115 | 1115 | |
1116 | 1116 | $params = (array)$topic->obj; |
1117 | 1117 | $params = self::DBUTF8_array($params); |
@@ -1148,27 +1148,27 @@ discard block |
||
1148 | 1148 | $sessionId |
1149 | 1149 | ); |
1150 | 1150 | |
1151 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1152 | - $topic_replies = -1; |
|
1153 | - |
|
1154 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1155 | - if ($post->obj->thread_id == $thread_id) { |
|
1156 | - $topic_replies++; |
|
1157 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1158 | - } |
|
1159 | - } |
|
1160 | - return $new_id; |
|
1161 | - } |
|
1162 | - |
|
1163 | - /** |
|
1164 | - * Restore a forum-post |
|
1165 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1166 | - * @param false|string $topic_id |
|
1167 | - */ |
|
1151 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1152 | + $topic_replies = -1; |
|
1153 | + |
|
1154 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1155 | + if ($post->obj->thread_id == $thread_id) { |
|
1156 | + $topic_replies++; |
|
1157 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1158 | + } |
|
1159 | + } |
|
1160 | + return $new_id; |
|
1161 | + } |
|
1162 | + |
|
1163 | + /** |
|
1164 | + * Restore a forum-post |
|
1165 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1166 | + * @param false|string $topic_id |
|
1167 | + */ |
|
1168 | 1168 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1169 | 1169 | { |
1170 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1171 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1170 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1171 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1172 | 1172 | $params = (array) $post->obj; |
1173 | 1173 | $params['c_id'] = $this->destination_course_id; |
1174 | 1174 | $params['forum_id'] = $forum_id; |
@@ -1204,37 +1204,37 @@ discard block |
||
1204 | 1204 | null, |
1205 | 1205 | $sessionId |
1206 | 1206 | ); |
1207 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1207 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1208 | 1208 | |
1209 | - return $new_id; |
|
1210 | - } |
|
1209 | + return $new_id; |
|
1210 | + } |
|
1211 | 1211 | |
1212 | - /** |
|
1213 | - * Restore links |
|
1214 | - */ |
|
1212 | + /** |
|
1213 | + * Restore links |
|
1214 | + */ |
|
1215 | 1215 | public function restore_links($session_id = 0) |
1216 | 1216 | { |
1217 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1218 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
1219 | - $resources = $this->course->resources; |
|
1217 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1218 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
1219 | + $resources = $this->course->resources; |
|
1220 | 1220 | |
1221 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1221 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1222 | 1222 | $cat_id = $this->restore_link_category( |
1223 | 1223 | $link->category_id, |
1224 | 1224 | $session_id |
1225 | 1225 | ); |
1226 | - $sql = "SELECT MAX(display_order) |
|
1226 | + $sql = "SELECT MAX(display_order) |
|
1227 | 1227 | FROM $link_table |
1228 | 1228 | WHERE |
1229 | 1229 | c_id = ".$this->destination_course_id." AND |
1230 | 1230 | category_id='" . intval($cat_id). "'"; |
1231 | - $result = Database::query($sql); |
|
1232 | - list($max_order) = Database::fetch_array($result); |
|
1231 | + $result = Database::query($sql); |
|
1232 | + list($max_order) = Database::fetch_array($result); |
|
1233 | 1233 | |
1234 | 1234 | $params = []; |
1235 | - if (!empty($session_id)) { |
|
1235 | + if (!empty($session_id)) { |
|
1236 | 1236 | $params['session_id'] = $session_id; |
1237 | - } |
|
1237 | + } |
|
1238 | 1238 | |
1239 | 1239 | $params['c_id'] = $this->destination_course_id; |
1240 | 1240 | $params['url'] = self::DBUTF8($link->url); |
@@ -1263,9 +1263,9 @@ discard block |
||
1263 | 1263 | } |
1264 | 1264 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
1265 | 1265 | } |
1266 | - } |
|
1267 | - } |
|
1268 | - } |
|
1266 | + } |
|
1267 | + } |
|
1268 | + } |
|
1269 | 1269 | |
1270 | 1270 | /** |
1271 | 1271 | * Restore a link-category |
@@ -1309,21 +1309,21 @@ discard block |
||
1309 | 1309 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - /** |
|
1313 | - * Restore tool intro |
|
1314 | - */ |
|
1312 | + /** |
|
1313 | + * Restore tool intro |
|
1314 | + */ |
|
1315 | 1315 | public function restore_tool_intro($sessionId = 0) |
1316 | 1316 | { |
1317 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1317 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1318 | 1318 | $sessionId = intval($sessionId); |
1319 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1320 | - $resources = $this->course->resources; |
|
1321 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1322 | - $sql = "DELETE FROM $tool_intro_table |
|
1319 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1320 | + $resources = $this->course->resources; |
|
1321 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1322 | + $sql = "DELETE FROM $tool_intro_table |
|
1323 | 1323 | WHERE |
1324 | 1324 | c_id = ".$this->destination_course_id." AND |
1325 | 1325 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
1326 | - Database::query($sql); |
|
1326 | + Database::query($sql); |
|
1327 | 1327 | |
1328 | 1328 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1329 | 1329 | $tool_intro->intro_text, |
@@ -1353,21 +1353,21 @@ discard block |
||
1353 | 1353 | |
1354 | 1354 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
1355 | 1355 | } |
1356 | - } |
|
1357 | - } |
|
1358 | - } |
|
1356 | + } |
|
1357 | + } |
|
1358 | + } |
|
1359 | 1359 | |
1360 | - /** |
|
1361 | - * Restore events |
|
1362 | - */ |
|
1360 | + /** |
|
1361 | + * Restore events |
|
1362 | + */ |
|
1363 | 1363 | public function restore_events($sessionId = 0) |
1364 | 1364 | { |
1365 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1365 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1366 | 1366 | $sessionId = intval($sessionId); |
1367 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
1368 | - $resources = $this->course->resources; |
|
1369 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1370 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1367 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
1368 | + $resources = $this->course->resources; |
|
1369 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1370 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1371 | 1371 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1372 | 1372 | $event->content, |
1373 | 1373 | $this->course->code, |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | 'end_date' => $event->end_date, |
1386 | 1386 | 'session_id' => $sessionId |
1387 | 1387 | ]; |
1388 | - $new_event_id = Database::insert($table, $params); |
|
1388 | + $new_event_id = Database::insert($table, $params); |
|
1389 | 1389 | |
1390 | 1390 | if ($new_event_id) { |
1391 | 1391 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1398,30 +1398,30 @@ discard block |
||
1398 | 1398 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
1399 | 1399 | } |
1400 | 1400 | |
1401 | - // Copy event attachment |
|
1401 | + // Copy event attachment |
|
1402 | 1402 | |
1403 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1404 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1403 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1404 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1405 | 1405 | |
1406 | - if (!empty($this->course->orig)) { |
|
1406 | + if (!empty($this->course->orig)) { |
|
1407 | 1407 | |
1408 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1409 | - $sql = 'SELECT path, comment, size, filename |
|
1408 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1409 | + $sql = 'SELECT path, comment, size, filename |
|
1410 | 1410 | FROM '.$table_attachment.' |
1411 | 1411 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
1412 | - $attachment_event = Database::query($sql); |
|
1413 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1412 | + $attachment_event = Database::query($sql); |
|
1413 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1414 | 1414 | |
1415 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1415 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1416 | 1416 | !is_dir($origin_path.$attachment_event->path) |
1417 | 1417 | ) { |
1418 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1419 | - $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1420 | - //$copy_result = true; |
|
1421 | - if ($copy_result) { |
|
1422 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1418 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1419 | + $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1420 | + //$copy_result = true; |
|
1421 | + if ($copy_result) { |
|
1422 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1423 | 1423 | |
1424 | - $params = [ |
|
1424 | + $params = [ |
|
1425 | 1425 | 'c_id' => $this->destination_course_id, |
1426 | 1426 | 'path' => self::DBUTF8($new_filename), |
1427 | 1427 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1435,17 +1435,17 @@ discard block |
||
1435 | 1435 | Database::query($sql); |
1436 | 1436 | } |
1437 | 1437 | } |
1438 | - } |
|
1439 | - } else { |
|
1440 | - // get the info of the file |
|
1441 | - if (!empty($event->attachment_path) && |
|
1438 | + } |
|
1439 | + } else { |
|
1440 | + // get the info of the file |
|
1441 | + if (!empty($event->attachment_path) && |
|
1442 | 1442 | is_file($origin_path.$event->attachment_path) && |
1443 | 1443 | is_readable($origin_path.$event->attachment_path) |
1444 | 1444 | ) { |
1445 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1446 | - $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1447 | - if ($copy_result) { |
|
1448 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1445 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1446 | + $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1447 | + if ($copy_result) { |
|
1448 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1449 | 1449 | |
1450 | 1450 | $params = [ |
1451 | 1451 | 'c_id' => $this->destination_course_id, |
@@ -1461,29 +1461,29 @@ discard block |
||
1461 | 1461 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
1462 | 1462 | Database::query($sql); |
1463 | 1463 | } |
1464 | - } |
|
1465 | - } |
|
1466 | - } |
|
1467 | - } |
|
1468 | - } |
|
1469 | - } |
|
1470 | - |
|
1471 | - /** |
|
1472 | - * Restore course-description |
|
1473 | - */ |
|
1464 | + } |
|
1465 | + } |
|
1466 | + } |
|
1467 | + } |
|
1468 | + } |
|
1469 | + } |
|
1470 | + |
|
1471 | + /** |
|
1472 | + * Restore course-description |
|
1473 | + */ |
|
1474 | 1474 | public function restore_course_descriptions($session_id = 0) |
1475 | 1475 | { |
1476 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1477 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1478 | - $resources = $this->course->resources; |
|
1479 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1476 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1477 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1478 | + $resources = $this->course->resources; |
|
1479 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1480 | 1480 | $courseDescription = (array) $cd; |
1481 | 1481 | |
1482 | 1482 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
1483 | 1483 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
1484 | 1484 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
1485 | 1485 | |
1486 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1486 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1487 | 1487 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1488 | 1488 | $content, |
1489 | 1489 | $this->course->code, |
@@ -1512,22 +1512,22 @@ discard block |
||
1512 | 1512 | } |
1513 | 1513 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
1514 | 1514 | } |
1515 | - } |
|
1516 | - } |
|
1517 | - } |
|
1515 | + } |
|
1516 | + } |
|
1517 | + } |
|
1518 | 1518 | |
1519 | - /** |
|
1520 | - * Restore announcements |
|
1521 | - */ |
|
1519 | + /** |
|
1520 | + * Restore announcements |
|
1521 | + */ |
|
1522 | 1522 | public function restore_announcements($sessionId = 0) |
1523 | 1523 | { |
1524 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1524 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1525 | 1525 | $sessionId = intval($sessionId); |
1526 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1527 | - $resources = $this->course->resources; |
|
1528 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1526 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1527 | + $resources = $this->course->resources; |
|
1528 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1529 | 1529 | |
1530 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1530 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1531 | 1531 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1532 | 1532 | $announcement->content, |
1533 | 1533 | $this->course->code, |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | 'session_id' => $sessionId, |
1547 | 1547 | ]; |
1548 | 1548 | |
1549 | - $new_announcement_id = Database::insert($table, $params); |
|
1549 | + $new_announcement_id = Database::insert($table, $params); |
|
1550 | 1550 | |
1551 | 1551 | if ($new_announcement_id) { |
1552 | 1552 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1558,32 +1558,32 @@ discard block |
||
1558 | 1558 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
1559 | 1559 | } |
1560 | 1560 | |
1561 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1562 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1561 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1562 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1563 | 1563 | |
1564 | - // Copy announcement attachment file |
|
1565 | - if (!empty($this->course->orig)) { |
|
1564 | + // Copy announcement attachment file |
|
1565 | + if (!empty($this->course->orig)) { |
|
1566 | 1566 | |
1567 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1568 | - $sql = 'SELECT path, comment, size, filename |
|
1567 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1568 | + $sql = 'SELECT path, comment, size, filename |
|
1569 | 1569 | FROM '.$table_attachment.' |
1570 | 1570 | WHERE |
1571 | 1571 | c_id = '.$this->destination_course_id.' AND |
1572 | 1572 | announcement_id = '.$id; |
1573 | - $attachment_event = Database::query($sql); |
|
1574 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1573 | + $attachment_event = Database::query($sql); |
|
1574 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1575 | 1575 | |
1576 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1576 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1577 | 1577 | !is_dir($origin_path.$attachment_event->path) |
1578 | 1578 | ) { |
1579 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1579 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1580 | 1580 | $copy_result = copy( |
1581 | 1581 | $origin_path.$attachment_event->path, |
1582 | 1582 | $destination_path.$new_filename |
1583 | 1583 | ); |
1584 | 1584 | |
1585 | - if ($copy_result) { |
|
1586 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1585 | + if ($copy_result) { |
|
1586 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1587 | 1587 | |
1588 | 1588 | $params = [ |
1589 | 1589 | 'c_id' => $this->destination_course_id, |
@@ -1600,19 +1600,19 @@ discard block |
||
1600 | 1600 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1601 | 1601 | Database::query($sql); |
1602 | 1602 | } |
1603 | - } |
|
1604 | - } |
|
1605 | - } else { |
|
1606 | - // get the info of the file |
|
1607 | - if (!empty($announcement->attachment_path) && |
|
1603 | + } |
|
1604 | + } |
|
1605 | + } else { |
|
1606 | + // get the info of the file |
|
1607 | + if (!empty($announcement->attachment_path) && |
|
1608 | 1608 | is_file($origin_path.$announcement->attachment_path) && |
1609 | 1609 | is_readable($origin_path.$announcement->attachment_path) |
1610 | 1610 | ) { |
1611 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1612 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1611 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1612 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1613 | 1613 | |
1614 | - if ($copy_result) { |
|
1615 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1614 | + if ($copy_result) { |
|
1615 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1616 | 1616 | |
1617 | 1617 | $params = [ |
1618 | 1618 | 'c_id' => $this->destination_course_id, |
@@ -1629,12 +1629,12 @@ discard block |
||
1629 | 1629 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1630 | 1630 | Database::query($sql); |
1631 | 1631 | } |
1632 | - } |
|
1633 | - } |
|
1634 | - } |
|
1635 | - } |
|
1636 | - } |
|
1637 | - } |
|
1632 | + } |
|
1633 | + } |
|
1634 | + } |
|
1635 | + } |
|
1636 | + } |
|
1637 | + } |
|
1638 | 1638 | |
1639 | 1639 | /** |
1640 | 1640 | * Restore Quiz |
@@ -1645,13 +1645,13 @@ discard block |
||
1645 | 1645 | $session_id = 0, |
1646 | 1646 | $respect_base_content = false |
1647 | 1647 | ) { |
1648 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1649 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1650 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1651 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1652 | - $resources = $this->course->resources; |
|
1648 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1649 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1650 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1651 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1652 | + $resources = $this->course->resources; |
|
1653 | 1653 | |
1654 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1654 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1655 | 1655 | |
1656 | 1656 | if (isset($quiz->obj)) { |
1657 | 1657 | //For new imports |
@@ -1661,7 +1661,7 @@ discard block |
||
1661 | 1661 | $quiz->obj = $quiz; |
1662 | 1662 | } |
1663 | 1663 | |
1664 | - $doc = ''; |
|
1664 | + $doc = ''; |
|
1665 | 1665 | if (!empty($quiz->sound)) { |
1666 | 1666 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
1667 | 1667 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1669,14 +1669,14 @@ discard block |
||
1669 | 1669 | WHERE |
1670 | 1670 | c_id = " . $this->destination_course_id . " AND |
1671 | 1671 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1672 | - $doc = Database::query($sql); |
|
1673 | - $doc = Database::fetch_object($doc); |
|
1674 | - $doc = str_replace('/audio/', '', $doc->path); |
|
1675 | - } |
|
1676 | - } |
|
1677 | - |
|
1678 | - if ($id != -1) { |
|
1679 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1672 | + $doc = Database::query($sql); |
|
1673 | + $doc = Database::fetch_object($doc); |
|
1674 | + $doc = str_replace('/audio/', '', $doc->path); |
|
1675 | + } |
|
1676 | + } |
|
1677 | + |
|
1678 | + if ($id != -1) { |
|
1679 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1680 | 1680 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1681 | 1681 | $quiz->description, |
1682 | 1682 | $this->course->code, |
@@ -1688,13 +1688,13 @@ discard block |
||
1688 | 1688 | $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time; |
1689 | 1689 | $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time; |
1690 | 1690 | |
1691 | - global $_custom; |
|
1692 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1691 | + global $_custom; |
|
1692 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1693 | 1693 | $_custom['exercises_clean_dates_when_restoring'] |
1694 | 1694 | ) { |
1695 | - $quiz->start_time = null; |
|
1696 | - $quiz->end_time = null; |
|
1697 | - } |
|
1695 | + $quiz->start_time = null; |
|
1696 | + $quiz->end_time = null; |
|
1697 | + } |
|
1698 | 1698 | |
1699 | 1699 | $params = array( |
1700 | 1700 | 'c_id' => $this->destination_course_id, |
@@ -1728,10 +1728,10 @@ discard block |
||
1728 | 1728 | } |
1729 | 1729 | $params['session_id'] = $my_session_id; |
1730 | 1730 | } else { |
1731 | - if (!empty($session_id)) { |
|
1732 | - $session_id = intval($session_id); |
|
1731 | + if (!empty($session_id)) { |
|
1732 | + $session_id = intval($session_id); |
|
1733 | 1733 | $params['session_id'] = $session_id; |
1734 | - } |
|
1734 | + } |
|
1735 | 1735 | } |
1736 | 1736 | $new_id = Database::insert($table_qui, $params); |
1737 | 1737 | |
@@ -1740,15 +1740,15 @@ discard block |
||
1740 | 1740 | Database::query($sql); |
1741 | 1741 | } |
1742 | 1742 | |
1743 | - } else { |
|
1744 | - // $id = -1 identifies the fictionary test for collecting |
|
1745 | - // orphan questions. We do not store it in the database. |
|
1746 | - $new_id = -1; |
|
1747 | - } |
|
1743 | + } else { |
|
1744 | + // $id = -1 identifies the fictionary test for collecting |
|
1745 | + // orphan questions. We do not store it in the database. |
|
1746 | + $new_id = -1; |
|
1747 | + } |
|
1748 | 1748 | |
1749 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1749 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1750 | 1750 | |
1751 | - $order = 0; |
|
1751 | + $order = 0; |
|
1752 | 1752 | if (!empty($quiz->question_ids)) { |
1753 | 1753 | foreach ($quiz->question_ids as $index => $question_id) { |
1754 | 1754 | $qid = $this->restore_quiz_question($question_id); |
@@ -1761,31 +1761,31 @@ discard block |
||
1761 | 1761 | Database::query($sql); |
1762 | 1762 | } |
1763 | 1763 | } |
1764 | - } |
|
1765 | - } |
|
1766 | - } |
|
1764 | + } |
|
1765 | + } |
|
1766 | + } |
|
1767 | 1767 | |
1768 | - /** |
|
1769 | - * Restore quiz-questions |
|
1768 | + /** |
|
1769 | + * Restore quiz-questions |
|
1770 | 1770 | * @params int question id |
1771 | - */ |
|
1771 | + */ |
|
1772 | 1772 | public function restore_quiz_question($id) |
1773 | 1773 | { |
1774 | 1774 | $em = Database::getManager(); |
1775 | - $resources = $this->course->resources; |
|
1775 | + $resources = $this->course->resources; |
|
1776 | 1776 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
1777 | 1777 | |
1778 | - $new_id = 0; |
|
1778 | + $new_id = 0; |
|
1779 | 1779 | |
1780 | - if (is_object($question)) { |
|
1781 | - if ($question->is_restored()) { |
|
1782 | - return $question->destination_id; |
|
1783 | - } |
|
1784 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1785 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1780 | + if (is_object($question)) { |
|
1781 | + if ($question->is_restored()) { |
|
1782 | + return $question->destination_id; |
|
1783 | + } |
|
1784 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1785 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1786 | 1786 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
1787 | 1787 | |
1788 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1788 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1789 | 1789 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1790 | 1790 | $question->description, |
1791 | 1791 | $this->course->code, |
@@ -1806,7 +1806,7 @@ discard block |
||
1806 | 1806 | 'extra' => self::DBUTF8($question->extra) |
1807 | 1807 | ]; |
1808 | 1808 | |
1809 | - $new_id = Database::insert($table_que, $params); |
|
1809 | + $new_id = Database::insert($table_que, $params); |
|
1810 | 1810 | |
1811 | 1811 | if ($new_id) { |
1812 | 1812 | $sql = "UPDATE $table_que SET id = iid WHERE iid = $new_id"; |
@@ -1870,8 +1870,8 @@ discard block |
||
1870 | 1870 | $em->merge($quizAnswer); |
1871 | 1871 | $em->flush(); |
1872 | 1872 | } |
1873 | - } |
|
1874 | - } else { |
|
1873 | + } |
|
1874 | + } else { |
|
1875 | 1875 | $correct_answers = array(); |
1876 | 1876 | $allAnswers = []; |
1877 | 1877 | if ($question->quiz_type == DRAGGABLE) { |
@@ -1879,8 +1879,8 @@ discard block |
||
1879 | 1879 | } |
1880 | 1880 | |
1881 | 1881 | $onlyAnswers = []; |
1882 | - foreach ($question->answers as $index => $answer) { |
|
1883 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1882 | + foreach ($question->answers as $index => $answer) { |
|
1883 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1884 | 1884 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1885 | 1885 | $answer['answer'], |
1886 | 1886 | $this->course->code, |
@@ -1920,8 +1920,8 @@ discard block |
||
1920 | 1920 | |
1921 | 1921 | $correct_answers[$answerId] = $answer['correct']; |
1922 | 1922 | $onlyAnswers[$answerId] = $answer['answer']; |
1923 | - } |
|
1924 | - } |
|
1923 | + } |
|
1924 | + } |
|
1925 | 1925 | |
1926 | 1926 | // Current course id |
1927 | 1927 | $course_id = api_get_course_int_id(); |
@@ -2041,13 +2041,13 @@ discard block |
||
2041 | 2041 | } |
2042 | 2042 | } |
2043 | 2043 | } |
2044 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2045 | - } |
|
2044 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2045 | + } |
|
2046 | 2046 | |
2047 | - return $new_id; |
|
2048 | - } |
|
2047 | + return $new_id; |
|
2048 | + } |
|
2049 | 2049 | |
2050 | - /** |
|
2050 | + /** |
|
2051 | 2051 | * @todo : add session id when used for session |
2052 | 2052 | */ |
2053 | 2053 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2132,21 +2132,21 @@ discard block |
||
2132 | 2132 | $sessionId = intval($sessionId); |
2133 | 2133 | |
2134 | 2134 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
2135 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2136 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2137 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2138 | - $resources = $this->course->resources; |
|
2139 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2135 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2136 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2137 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2138 | + $resources = $this->course->resources; |
|
2139 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2140 | 2140 | |
2141 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2141 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2142 | 2142 | WHERE |
2143 | 2143 | c_id = '.$this->destination_course_id.' AND |
2144 | 2144 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
2145 | 2145 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
2146 | 2146 | |
2147 | - $result_check = Database::query($sql); |
|
2147 | + $result_check = Database::query($sql); |
|
2148 | 2148 | |
2149 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2149 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2150 | 2150 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2151 | 2151 | $survey->title, |
2152 | 2152 | $this->course->code, |
@@ -2200,20 +2200,20 @@ discard block |
||
2200 | 2200 | 'session_id' => $sessionId |
2201 | 2201 | ]; |
2202 | 2202 | |
2203 | - //An existing survey exists with the same code and the same language |
|
2204 | - if (Database::num_rows($result_check) == 1) { |
|
2205 | - switch ($this->file_option) { |
|
2206 | - case FILE_SKIP: |
|
2207 | - //Do nothing |
|
2208 | - break; |
|
2209 | - case FILE_RENAME: |
|
2210 | - $survey_code = $survey->code.'_'; |
|
2211 | - $i=1; |
|
2212 | - $temp_survey_code = $survey_code.$i; |
|
2213 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2214 | - $temp_survey_code = $survey_code.++$i; |
|
2215 | - } |
|
2216 | - $survey_code = $temp_survey_code; |
|
2203 | + //An existing survey exists with the same code and the same language |
|
2204 | + if (Database::num_rows($result_check) == 1) { |
|
2205 | + switch ($this->file_option) { |
|
2206 | + case FILE_SKIP: |
|
2207 | + //Do nothing |
|
2208 | + break; |
|
2209 | + case FILE_RENAME: |
|
2210 | + $survey_code = $survey->code.'_'; |
|
2211 | + $i=1; |
|
2212 | + $temp_survey_code = $survey_code.$i; |
|
2213 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2214 | + $temp_survey_code = $survey_code.++$i; |
|
2215 | + } |
|
2216 | + $survey_code = $temp_survey_code; |
|
2217 | 2217 | |
2218 | 2218 | $params['code'] = $survey_code; |
2219 | 2219 | $new_id = Database::insert($table_sur, $params); |
@@ -2232,25 +2232,25 @@ discard block |
||
2232 | 2232 | Database::query($sql); |
2233 | 2233 | } |
2234 | 2234 | } |
2235 | - break; |
|
2236 | - case FILE_OVERWRITE: |
|
2237 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
2238 | - // getting the information of the survey (used for when the survey is shared) |
|
2235 | + break; |
|
2236 | + case FILE_OVERWRITE: |
|
2237 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
2238 | + // getting the information of the survey (used for when the survey is shared) |
|
2239 | 2239 | |
2240 | - $sql = "SELECT * FROM $table_sur |
|
2240 | + $sql = "SELECT * FROM $table_sur |
|
2241 | 2241 | WHERE |
2242 | 2242 | c_id = ".$this->destination_course_id." AND |
2243 | 2243 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
2244 | - $result = Database::query($sql); |
|
2245 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2244 | + $result = Database::query($sql); |
|
2245 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2246 | 2246 | |
2247 | - // if the survey is shared => also delete the shared content |
|
2248 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2247 | + // if the survey is shared => also delete the shared content |
|
2248 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2249 | 2249 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
2250 | - } |
|
2251 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2250 | + } |
|
2251 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2252 | 2252 | |
2253 | - // Insert the new source survey |
|
2253 | + // Insert the new source survey |
|
2254 | 2254 | $new_id = Database::insert($table_sur, $params); |
2255 | 2255 | |
2256 | 2256 | if ($new_id) { |
@@ -2271,11 +2271,11 @@ discard block |
||
2271 | 2271 | Database::query($sql); |
2272 | 2272 | } |
2273 | 2273 | } |
2274 | - break; |
|
2275 | - default: |
|
2276 | - break; |
|
2277 | - } |
|
2278 | - } else { |
|
2274 | + break; |
|
2275 | + default: |
|
2276 | + break; |
|
2277 | + } |
|
2278 | + } else { |
|
2279 | 2279 | // No existing survey with the same language and the same code, we just copy the survey |
2280 | 2280 | $new_id = Database::insert($table_sur, $params); |
2281 | 2281 | |
@@ -2297,48 +2297,48 @@ discard block |
||
2297 | 2297 | Database::query($sql); |
2298 | 2298 | } |
2299 | 2299 | } |
2300 | - } |
|
2301 | - } |
|
2302 | - } |
|
2303 | - } |
|
2304 | - |
|
2305 | - /** |
|
2306 | - * Check availability of a survey code |
|
2307 | - * @param string $survey_code |
|
2308 | - */ |
|
2300 | + } |
|
2301 | + } |
|
2302 | + } |
|
2303 | + } |
|
2304 | + |
|
2305 | + /** |
|
2306 | + * Check availability of a survey code |
|
2307 | + * @param string $survey_code |
|
2308 | + */ |
|
2309 | 2309 | public function is_survey_code_available($survey_code) |
2310 | 2310 | { |
2311 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2312 | - $sql = "SELECT * FROM $table_sur |
|
2311 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2312 | + $sql = "SELECT * FROM $table_sur |
|
2313 | 2313 | WHERE |
2314 | 2314 | c_id = ".$this->destination_course_id." AND |
2315 | 2315 | code = '".self::DBUTF8escapestring($survey_code)."'"; |
2316 | - $result = Database::query($sql); |
|
2316 | + $result = Database::query($sql); |
|
2317 | 2317 | if (Database::num_rows($result) > 0) { |
2318 | 2318 | return false; |
2319 | 2319 | } else { |
2320 | 2320 | return true; |
2321 | 2321 | } |
2322 | - } |
|
2322 | + } |
|
2323 | 2323 | |
2324 | - /** |
|
2325 | - * Restore survey-questions |
|
2326 | - * @param string $survey_id |
|
2327 | - */ |
|
2324 | + /** |
|
2325 | + * Restore survey-questions |
|
2326 | + * @param string $survey_id |
|
2327 | + */ |
|
2328 | 2328 | public function restore_survey_question($id, $survey_id) |
2329 | 2329 | { |
2330 | - $resources = $this->course->resources; |
|
2331 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2330 | + $resources = $this->course->resources; |
|
2331 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2332 | 2332 | $new_id = 0; |
2333 | 2333 | |
2334 | - if (is_object($question)) { |
|
2335 | - if ($question->is_restored()) { |
|
2336 | - return $question->destination_id; |
|
2337 | - } |
|
2338 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2339 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2334 | + if (is_object($question)) { |
|
2335 | + if ($question->is_restored()) { |
|
2336 | + return $question->destination_id; |
|
2337 | + } |
|
2338 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2339 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2340 | 2340 | |
2341 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2341 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2342 | 2342 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2343 | 2343 | $question->survey_question, |
2344 | 2344 | $this->course->code, |
@@ -2392,10 +2392,10 @@ discard block |
||
2392 | 2392 | } |
2393 | 2393 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
2394 | 2394 | } |
2395 | - } |
|
2395 | + } |
|
2396 | 2396 | |
2397 | - return $new_id; |
|
2398 | - } |
|
2397 | + return $new_id; |
|
2398 | + } |
|
2399 | 2399 | |
2400 | 2400 | /** |
2401 | 2401 | * Restoring learning paths |
@@ -2406,19 +2406,19 @@ discard block |
||
2406 | 2406 | { |
2407 | 2407 | $session_id = intval($session_id); |
2408 | 2408 | |
2409 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2409 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2410 | 2410 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
2411 | 2411 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
2412 | 2412 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
2413 | 2413 | |
2414 | - $resources = $this->course->resources; |
|
2414 | + $resources = $this->course->resources; |
|
2415 | 2415 | |
2416 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2417 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2416 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2417 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2418 | 2418 | |
2419 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2420 | - $condition_session = ''; |
|
2421 | - if (!empty($session_id)) { |
|
2419 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2420 | + $condition_session = ''; |
|
2421 | + if (!empty($session_id)) { |
|
2422 | 2422 | if ($respect_base_content) { |
2423 | 2423 | $my_session_id = $lp->session_id; |
2424 | 2424 | if (!empty($lp->session_id)) { |
@@ -2429,20 +2429,20 @@ discard block |
||
2429 | 2429 | $session_id = intval($session_id); |
2430 | 2430 | $condition_session = $session_id; |
2431 | 2431 | } |
2432 | - } |
|
2433 | - |
|
2434 | - // Adding the author's image |
|
2435 | - if (!empty($lp->preview_image)) { |
|
2436 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2437 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2438 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2439 | - if ($copy_result) { |
|
2440 | - $lp->preview_image = $new_filename; |
|
2441 | - } else { |
|
2442 | - $lp->preview_image =''; |
|
2443 | - } |
|
2444 | - } |
|
2445 | - } |
|
2432 | + } |
|
2433 | + |
|
2434 | + // Adding the author's image |
|
2435 | + if (!empty($lp->preview_image)) { |
|
2436 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2437 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2438 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2439 | + if ($copy_result) { |
|
2440 | + $lp->preview_image = $new_filename; |
|
2441 | + } else { |
|
2442 | + $lp->preview_image =''; |
|
2443 | + } |
|
2444 | + } |
|
2445 | + } |
|
2446 | 2446 | |
2447 | 2447 | if ($this->add_text_in_items) { |
2448 | 2448 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2500,7 +2500,7 @@ discard block |
||
2500 | 2500 | $params['session_id'] = $condition_session; |
2501 | 2501 | } |
2502 | 2502 | |
2503 | - $new_lp_id = Database::insert($table_main, $params); |
|
2503 | + $new_lp_id = Database::insert($table_main, $params); |
|
2504 | 2504 | |
2505 | 2505 | if ($new_lp_id) { |
2506 | 2506 | |
@@ -2561,13 +2561,13 @@ discard block |
||
2561 | 2561 | $old_refs = array(); |
2562 | 2562 | $prerequisite_ids = array(); |
2563 | 2563 | |
2564 | - foreach ($lp->get_items() as $index => $item) { |
|
2565 | - // we set the ref code here and then we update in a for loop |
|
2566 | - $ref = $item['ref']; |
|
2564 | + foreach ($lp->get_items() as $index => $item) { |
|
2565 | + // we set the ref code here and then we update in a for loop |
|
2566 | + $ref = $item['ref']; |
|
2567 | 2567 | |
2568 | - // Dealing with path the same way as ref as some data has |
|
2568 | + // Dealing with path the same way as ref as some data has |
|
2569 | 2569 | // been put into path when it's a local resource |
2570 | - // Only fix the path for no scos |
|
2570 | + // Only fix the path for no scos |
|
2571 | 2571 | if ($item['item_type'] == 'sco') { |
2572 | 2572 | $path = $item['path']; |
2573 | 2573 | } else { |
@@ -2598,128 +2598,128 @@ discard block |
||
2598 | 2598 | 'launch_data' => self::DBUTF8($item['launch_data']), |
2599 | 2599 | ]; |
2600 | 2600 | |
2601 | - $new_item_id = Database::insert($table_item, $params); |
|
2601 | + $new_item_id = Database::insert($table_item, $params); |
|
2602 | 2602 | |
2603 | 2603 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
2604 | 2604 | Database::query($sql); |
2605 | 2605 | |
2606 | - //save a link between old and new item IDs |
|
2607 | - $new_item_ids[$item['id']] = $new_item_id; |
|
2608 | - //save a reference of items that need a parent_item_id refresh |
|
2609 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2610 | - //save a reference of items that need a previous_item_id refresh |
|
2611 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2612 | - //save a reference of items that need a next_item_id refresh |
|
2613 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2614 | - |
|
2615 | - if (!empty($item['prerequisite'])) { |
|
2616 | - if ($lp->lp_type =='2') { |
|
2617 | - // if is an sco |
|
2618 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2619 | - } else { |
|
2620 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2621 | - } |
|
2622 | - } |
|
2623 | - |
|
2624 | - if (!empty($ref)) { |
|
2625 | - if ($lp->lp_type =='2') { |
|
2626 | - // if is an sco |
|
2627 | - $old_refs[$new_item_id]= $ref; |
|
2628 | - } elseif (isset($new_item_ids[$ref])) { |
|
2606 | + //save a link between old and new item IDs |
|
2607 | + $new_item_ids[$item['id']] = $new_item_id; |
|
2608 | + //save a reference of items that need a parent_item_id refresh |
|
2609 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2610 | + //save a reference of items that need a previous_item_id refresh |
|
2611 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2612 | + //save a reference of items that need a next_item_id refresh |
|
2613 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2614 | + |
|
2615 | + if (!empty($item['prerequisite'])) { |
|
2616 | + if ($lp->lp_type =='2') { |
|
2617 | + // if is an sco |
|
2618 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2619 | + } else { |
|
2620 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2621 | + } |
|
2622 | + } |
|
2623 | + |
|
2624 | + if (!empty($ref)) { |
|
2625 | + if ($lp->lp_type =='2') { |
|
2626 | + // if is an sco |
|
2627 | + $old_refs[$new_item_id]= $ref; |
|
2628 | + } elseif (isset($new_item_ids[$ref])) { |
|
2629 | 2629 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
2630 | 2630 | } |
2631 | - } |
|
2631 | + } |
|
2632 | 2632 | |
2633 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2634 | - } |
|
2633 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2634 | + } |
|
2635 | 2635 | |
2636 | - // Updating prerequisites |
|
2637 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2638 | - if ($my_old_prerequisite != ''){ |
|
2639 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2636 | + // Updating prerequisites |
|
2637 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2638 | + if ($my_old_prerequisite != ''){ |
|
2639 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2640 | 2640 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2641 | - Database::query($sql); |
|
2642 | - } |
|
2643 | - } |
|
2644 | - |
|
2645 | - // Updating refs |
|
2646 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
2647 | - if ($my_old_ref != '') { |
|
2648 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2641 | + Database::query($sql); |
|
2642 | + } |
|
2643 | + } |
|
2644 | + |
|
2645 | + // Updating refs |
|
2646 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
2647 | + if ($my_old_ref != '') { |
|
2648 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2649 | 2649 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2650 | - Database::query($sql); |
|
2651 | - } |
|
2652 | - } |
|
2653 | - |
|
2654 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2655 | - $parent_new_id = 0; |
|
2656 | - if($parent_item_old_id != 0){ |
|
2657 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2658 | - } |
|
2659 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2650 | + Database::query($sql); |
|
2651 | + } |
|
2652 | + } |
|
2653 | + |
|
2654 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2655 | + $parent_new_id = 0; |
|
2656 | + if($parent_item_old_id != 0){ |
|
2657 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2658 | + } |
|
2659 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2660 | 2660 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2661 | - Database::query($sql); |
|
2662 | - } |
|
2663 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2664 | - $previous_new_id = 0; |
|
2665 | - if ($previous_item_old_id != 0){ |
|
2666 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2667 | - } |
|
2668 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2661 | + Database::query($sql); |
|
2662 | + } |
|
2663 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2664 | + $previous_new_id = 0; |
|
2665 | + if ($previous_item_old_id != 0){ |
|
2666 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2667 | + } |
|
2668 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2669 | 2669 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2670 | - Database::query($sql); |
|
2671 | - } |
|
2672 | - |
|
2673 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2674 | - $next_new_id = 0; |
|
2675 | - if ($next_item_old_id != 0){ |
|
2676 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2677 | - } |
|
2678 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2670 | + Database::query($sql); |
|
2671 | + } |
|
2672 | + |
|
2673 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2674 | + $next_new_id = 0; |
|
2675 | + if ($next_item_old_id != 0){ |
|
2676 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2677 | + } |
|
2678 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2679 | 2679 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2680 | - Database::query($sql); |
|
2681 | - } |
|
2682 | - |
|
2683 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2684 | - $prerequisite_new_id = 0; |
|
2685 | - if ($prerequisite_old_id != 0){ |
|
2686 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2687 | - } |
|
2688 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2680 | + Database::query($sql); |
|
2681 | + } |
|
2682 | + |
|
2683 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2684 | + $prerequisite_new_id = 0; |
|
2685 | + if ($prerequisite_old_id != 0){ |
|
2686 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2687 | + } |
|
2688 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2689 | 2689 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2690 | - Database::query($sql); |
|
2691 | - } |
|
2692 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2693 | - } |
|
2694 | - } |
|
2695 | - } |
|
2696 | - |
|
2697 | - /** |
|
2698 | - * Restore works |
|
2690 | + Database::query($sql); |
|
2691 | + } |
|
2692 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2693 | + } |
|
2694 | + } |
|
2695 | + } |
|
2696 | + |
|
2697 | + /** |
|
2698 | + * Restore works |
|
2699 | 2699 | * @deprecated use restore_works |
2700 | 2700 | * |
2701 | - */ |
|
2702 | - public function restore_student_publication($sessionId = 0) |
|
2701 | + */ |
|
2702 | + public function restore_student_publication($sessionId = 0) |
|
2703 | 2703 | { |
2704 | 2704 | $sessionId = intval($sessionId); |
2705 | 2705 | $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
2706 | 2706 | $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION); |
2707 | 2707 | $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY); |
2708 | 2708 | |
2709 | - // Query in student publication |
|
2710 | - $sql = 'SELECT * FROM '.$work_table.' |
|
2709 | + // Query in student publication |
|
2710 | + $sql = 'SELECT * FROM '.$work_table.' |
|
2711 | 2711 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
2712 | 2712 | |
2713 | - $result = Database::query($sql); |
|
2714 | - $folders = Database::store_result($result, 'ASSOC'); |
|
2713 | + $result = Database::query($sql); |
|
2714 | + $folders = Database::store_result($result, 'ASSOC'); |
|
2715 | 2715 | |
2716 | - foreach ($folders as $folder) { |
|
2717 | - $old_id = $folder['id']; |
|
2716 | + foreach ($folders as $folder) { |
|
2717 | + $old_id = $folder['id']; |
|
2718 | 2718 | unset($folder['id']); |
2719 | - $folder['c_id'] = $this->destination_course_id; |
|
2719 | + $folder['c_id'] = $this->destination_course_id; |
|
2720 | 2720 | $folder['parent_id'] = 0; |
2721 | 2721 | $folder['session_id'] = $sessionId ? $sessionId : null; |
2722 | - $new_id = Database::insert($work_table, $folder); |
|
2722 | + $new_id = Database::insert($work_table, $folder); |
|
2723 | 2723 | |
2724 | 2724 | if ($new_id) { |
2725 | 2725 | // query in item property |
@@ -2778,23 +2778,23 @@ discard block |
||
2778 | 2778 | } |
2779 | 2779 | } |
2780 | 2780 | } |
2781 | - } |
|
2781 | + } |
|
2782 | 2782 | |
2783 | 2783 | $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/'; |
2784 | 2784 | $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/'; |
2785 | 2785 | self::allow_create_all_directory($origin, $destination, false); |
2786 | - } |
|
2786 | + } |
|
2787 | 2787 | |
2788 | 2788 | /** |
2789 | - * copy all directory and sub directory |
|
2790 | - * @param string The path origin |
|
2791 | - * @param string The path destination |
|
2792 | - * @param boolean Option Overwrite |
|
2793 | - * @param string $source |
|
2794 | - * @param string $dest |
|
2795 | - * @return void() |
|
2796 | - * @deprecated |
|
2797 | - */ |
|
2789 | + * copy all directory and sub directory |
|
2790 | + * @param string The path origin |
|
2791 | + * @param string The path destination |
|
2792 | + * @param boolean Option Overwrite |
|
2793 | + * @param string $source |
|
2794 | + * @param string $dest |
|
2795 | + * @return void() |
|
2796 | + * @deprecated |
|
2797 | + */ |
|
2798 | 2798 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
2799 | 2799 | { |
2800 | 2800 | if (!is_dir($dest)) { |
@@ -2805,7 +2805,7 @@ discard block |
||
2805 | 2805 | if ($file != '.' && $file != '..') { |
2806 | 2806 | $path = $source . '/' . $file; |
2807 | 2807 | if (is_file($path)) { |
2808 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2808 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2809 | 2809 | if (!@copy($path, $dest . '/' . $file)) { |
2810 | 2810 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2811 | 2811 | }*/ |
@@ -2820,12 +2820,12 @@ discard block |
||
2820 | 2820 | } |
2821 | 2821 | } |
2822 | 2822 | |
2823 | - /** |
|
2824 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2825 | - * @param string Tool name |
|
2826 | - * @param integer Old ID |
|
2827 | - * @return integer New ID |
|
2828 | - */ |
|
2823 | + /** |
|
2824 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2825 | + * @param string Tool name |
|
2826 | + * @param integer Old ID |
|
2827 | + * @return integer New ID |
|
2828 | + */ |
|
2829 | 2829 | public function get_new_id($tool, $ref) |
2830 | 2830 | { |
2831 | 2831 | // Check if the value exist in the current array. |
@@ -2847,25 +2847,25 @@ discard block |
||
2847 | 2847 | } |
2848 | 2848 | |
2849 | 2849 | return ''; |
2850 | - } |
|
2850 | + } |
|
2851 | 2851 | |
2852 | - /** |
|
2853 | - * Restore glossary |
|
2854 | - */ |
|
2852 | + /** |
|
2853 | + * Restore glossary |
|
2854 | + */ |
|
2855 | 2855 | public function restore_glossary($session_id = 0) |
2856 | 2856 | { |
2857 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2858 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2859 | - $resources = $this->course->resources; |
|
2860 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2857 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2858 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2859 | + $resources = $this->course->resources; |
|
2860 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2861 | 2861 | |
2862 | 2862 | $params = []; |
2863 | - if (!empty($session_id)) { |
|
2864 | - $session_id = intval($session_id); |
|
2863 | + if (!empty($session_id)) { |
|
2864 | + $session_id = intval($session_id); |
|
2865 | 2865 | $params['session_id'] = $session_id; |
2866 | - } |
|
2866 | + } |
|
2867 | 2867 | |
2868 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2868 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2869 | 2869 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2870 | 2870 | $glossary->description, |
2871 | 2871 | $this->course->code, |
@@ -2899,27 +2899,27 @@ discard block |
||
2899 | 2899 | |
2900 | 2900 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
2901 | 2901 | } |
2902 | - } |
|
2903 | - } |
|
2904 | - } |
|
2902 | + } |
|
2903 | + } |
|
2904 | + } |
|
2905 | 2905 | |
2906 | 2906 | /** |
2907 | 2907 | * @param int $session_id |
2908 | 2908 | */ |
2909 | 2909 | public function restore_wiki($session_id = 0) |
2910 | 2910 | { |
2911 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2912 | - // wiki table of the target course |
|
2913 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2914 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2911 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2912 | + // wiki table of the target course |
|
2913 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2914 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2915 | 2915 | |
2916 | - // storing all the resources that have to be copied in an array |
|
2917 | - $resources = $this->course->resources; |
|
2916 | + // storing all the resources that have to be copied in an array |
|
2917 | + $resources = $this->course->resources; |
|
2918 | 2918 | |
2919 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2920 | - // the sql statement to insert the groups from the old course to the new course |
|
2919 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2920 | + // the sql statement to insert the groups from the old course to the new course |
|
2921 | 2921 | |
2922 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2922 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2923 | 2923 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2924 | 2924 | $wiki->content, |
2925 | 2925 | $this->course->code, |
@@ -2954,7 +2954,7 @@ discard block |
||
2954 | 2954 | 'user_ip' => '' |
2955 | 2955 | ]; |
2956 | 2956 | |
2957 | - $new_id = Database::insert($table_wiki, $params); |
|
2957 | + $new_id = Database::insert($table_wiki, $params); |
|
2958 | 2958 | |
2959 | 2959 | if ($new_id) { |
2960 | 2960 | $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid |
@@ -2984,9 +2984,9 @@ discard block |
||
2984 | 2984 | |
2985 | 2985 | Database::insert($table_wiki_conf, $params); |
2986 | 2986 | } |
2987 | - } |
|
2988 | - } |
|
2989 | - } |
|
2987 | + } |
|
2988 | + } |
|
2989 | + } |
|
2990 | 2990 | |
2991 | 2991 | /** |
2992 | 2992 | * Restore Thematics |
@@ -2994,15 +2994,15 @@ discard block |
||
2994 | 2994 | */ |
2995 | 2995 | public function restore_thematic($session_id = 0) |
2996 | 2996 | { |
2997 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2997 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2998 | 2998 | $table_thematic = Database::get_course_table(TABLE_THEMATIC); |
2999 | 2999 | $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); |
3000 | 3000 | $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); |
3001 | 3001 | |
3002 | - $resources = $this->course->resources; |
|
3003 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
3002 | + $resources = $this->course->resources; |
|
3003 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
3004 | 3004 | |
3005 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3005 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3006 | 3006 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3007 | 3007 | $thematic->params['content'], |
3008 | 3008 | $this->course->code, |
@@ -3010,13 +3010,13 @@ discard block |
||
3010 | 3010 | $this->course->backup_path, |
3011 | 3011 | $this->course->info['path'] |
3012 | 3012 | ); |
3013 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
3014 | - unset($thematic->params['id']); |
|
3013 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
3014 | + unset($thematic->params['id']); |
|
3015 | 3015 | unset($thematic->params['iid']); |
3016 | 3016 | |
3017 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3017 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3018 | 3018 | |
3019 | - if ($last_id) { |
|
3019 | + if ($last_id) { |
|
3020 | 3020 | |
3021 | 3021 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
3022 | 3022 | Database::query($sql); |
@@ -3029,12 +3029,12 @@ discard block |
||
3029 | 3029 | api_get_user_id() |
3030 | 3030 | ); |
3031 | 3031 | |
3032 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3033 | - unset($thematic_advance['id']); |
|
3032 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3033 | + unset($thematic_advance['id']); |
|
3034 | 3034 | unset($thematic_advance['iid']); |
3035 | - $thematic_advance['attendance_id'] = 0; |
|
3036 | - $thematic_advance['thematic_id'] = $last_id; |
|
3037 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
3035 | + $thematic_advance['attendance_id'] = 0; |
|
3036 | + $thematic_advance['thematic_id'] = $last_id; |
|
3037 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
3038 | 3038 | |
3039 | 3039 | $my_id = Database::insert( |
3040 | 3040 | $table_thematic_advance, |
@@ -3042,7 +3042,7 @@ discard block |
||
3042 | 3042 | false |
3043 | 3043 | ); |
3044 | 3044 | |
3045 | - if ($my_id) { |
|
3045 | + if ($my_id) { |
|
3046 | 3046 | |
3047 | 3047 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
3048 | 3048 | Database::query($sql); |
@@ -3054,17 +3054,17 @@ discard block |
||
3054 | 3054 | 'ThematicAdvanceAdded', |
3055 | 3055 | api_get_user_id() |
3056 | 3056 | ); |
3057 | - } |
|
3058 | - } |
|
3057 | + } |
|
3058 | + } |
|
3059 | 3059 | |
3060 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3061 | - unset($thematic_plan['id']); |
|
3060 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3061 | + unset($thematic_plan['id']); |
|
3062 | 3062 | unset($thematic_plan['iid']); |
3063 | - $thematic_plan['thematic_id'] = $last_id; |
|
3064 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
3065 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3063 | + $thematic_plan['thematic_id'] = $last_id; |
|
3064 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
3065 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3066 | 3066 | |
3067 | - if ($my_id) { |
|
3067 | + if ($my_id) { |
|
3068 | 3068 | |
3069 | 3069 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
3070 | 3070 | Database::query($sql); |
@@ -3076,12 +3076,12 @@ discard block |
||
3076 | 3076 | 'ThematicPlanAdded', |
3077 | 3077 | api_get_user_id() |
3078 | 3078 | ); |
3079 | - } |
|
3080 | - } |
|
3081 | - } |
|
3082 | - } |
|
3083 | - } |
|
3084 | - } |
|
3079 | + } |
|
3080 | + } |
|
3081 | + } |
|
3082 | + } |
|
3083 | + } |
|
3084 | + } |
|
3085 | 3085 | |
3086 | 3086 | /** |
3087 | 3087 | * Restore Attendance |
@@ -3089,14 +3089,14 @@ discard block |
||
3089 | 3089 | */ |
3090 | 3090 | public function restore_attendance($session_id = 0) |
3091 | 3091 | { |
3092 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3093 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3094 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3092 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3093 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3094 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3095 | 3095 | |
3096 | - $resources = $this->course->resources; |
|
3097 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3096 | + $resources = $this->course->resources; |
|
3097 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3098 | 3098 | |
3099 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3099 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3100 | 3100 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3101 | 3101 | $obj->params['description'], |
3102 | 3102 | $this->course->code, |
@@ -3108,11 +3108,11 @@ discard block |
||
3108 | 3108 | unset($obj->params['id']); |
3109 | 3109 | unset($obj->params['iid']); |
3110 | 3110 | |
3111 | - $obj->params['c_id'] = $this->destination_course_id; |
|
3111 | + $obj->params['c_id'] = $this->destination_course_id; |
|
3112 | 3112 | |
3113 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
3113 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
3114 | 3114 | |
3115 | - if (is_numeric($last_id)) { |
|
3115 | + if (is_numeric($last_id)) { |
|
3116 | 3116 | |
3117 | 3117 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
3118 | 3118 | Database::query($sql); |
@@ -3126,11 +3126,11 @@ discard block |
||
3126 | 3126 | ); |
3127 | 3127 | |
3128 | 3128 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
3129 | - unset($attendance_calendar['id']); |
|
3129 | + unset($attendance_calendar['id']); |
|
3130 | 3130 | unset($attendance_calendar['iid']); |
3131 | 3131 | |
3132 | - $attendance_calendar['attendance_id'] = $last_id; |
|
3133 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3132 | + $attendance_calendar['attendance_id'] = $last_id; |
|
3133 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3134 | 3134 | $attendanceCalendarId = Database::insert( |
3135 | 3135 | $table_attendance_calendar, |
3136 | 3136 | $attendance_calendar |
@@ -3138,11 +3138,11 @@ discard block |
||
3138 | 3138 | |
3139 | 3139 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
3140 | 3140 | Database::query($sql); |
3141 | - } |
|
3142 | - } |
|
3143 | - } |
|
3144 | - } |
|
3145 | - } |
|
3141 | + } |
|
3142 | + } |
|
3143 | + } |
|
3144 | + } |
|
3145 | + } |
|
3146 | 3146 | |
3147 | 3147 | /** |
3148 | 3148 | * Restore Works |
@@ -3283,11 +3283,11 @@ discard block |
||
3283 | 3283 | */ |
3284 | 3284 | public function DBUTF8($str) |
3285 | 3285 | { |
3286 | - if (UTF8_CONVERT) { |
|
3286 | + if (UTF8_CONVERT) { |
|
3287 | 3287 | $str = utf8_encode($str); |
3288 | 3288 | } |
3289 | - return $str; |
|
3290 | - } |
|
3289 | + return $str; |
|
3290 | + } |
|
3291 | 3291 | |
3292 | 3292 | /** |
3293 | 3293 | * @param string $str |
@@ -3298,8 +3298,8 @@ discard block |
||
3298 | 3298 | if (UTF8_CONVERT) { |
3299 | 3299 | $str = utf8_encode($str); |
3300 | 3300 | } |
3301 | - return Database::escape_string($str); |
|
3302 | - } |
|
3301 | + return Database::escape_string($str); |
|
3302 | + } |
|
3303 | 3303 | |
3304 | 3304 | /** |
3305 | 3305 | * @param array $array |
@@ -132,38 +132,38 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function my_rename($file_path, $new_file_name) { |
134 | 134 | |
135 | - $save_dir = getcwd(); |
|
136 | - $path = dirname($file_path); |
|
137 | - $old_file_name = basename($file_path); |
|
138 | - $new_file_name = api_replace_dangerous_char($new_file_name); |
|
135 | + $save_dir = getcwd(); |
|
136 | + $path = dirname($file_path); |
|
137 | + $old_file_name = basename($file_path); |
|
138 | + $new_file_name = api_replace_dangerous_char($new_file_name); |
|
139 | 139 | |
140 | - // If no extension, take the old one |
|
141 | - if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
142 | - $new_file_name .= substr($old_file_name, $dotpos); |
|
143 | - } |
|
140 | + // If no extension, take the old one |
|
141 | + if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
142 | + $new_file_name .= substr($old_file_name, $dotpos); |
|
143 | + } |
|
144 | 144 | |
145 | - // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
146 | - // This is useful for folder names, where otherwise '.' would be sticky |
|
145 | + // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
146 | + // This is useful for folder names, where otherwise '.' would be sticky |
|
147 | 147 | |
148 | - // Extension PHP is not allowed, change to PHPS |
|
149 | - $new_file_name = php2phps($new_file_name); |
|
148 | + // Extension PHP is not allowed, change to PHPS |
|
149 | + $new_file_name = php2phps($new_file_name); |
|
150 | 150 | |
151 | - if ($new_file_name == $old_file_name) { |
|
152 | - return $old_file_name; |
|
153 | - } |
|
151 | + if ($new_file_name == $old_file_name) { |
|
152 | + return $old_file_name; |
|
153 | + } |
|
154 | 154 | |
155 | - if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
156 | - return false; |
|
157 | - } |
|
158 | - // On a Windows server, it would be better not to do the above check |
|
159 | - // because it succeeds for some new names resembling the old name. |
|
160 | - // But on Unix/Linux the check must be done because rename overwrites. |
|
155 | + if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
156 | + return false; |
|
157 | + } |
|
158 | + // On a Windows server, it would be better not to do the above check |
|
159 | + // because it succeeds for some new names resembling the old name. |
|
160 | + // But on Unix/Linux the check must be done because rename overwrites. |
|
161 | 161 | |
162 | - chdir($path); |
|
163 | - $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
164 | - chdir($save_dir); |
|
162 | + chdir($path); |
|
163 | + $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
164 | + chdir($save_dir); |
|
165 | 165 | |
166 | - return $res; |
|
166 | + return $res; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $file_name = basename($source); |
186 | 186 | // move onto self illegal: mv a/b/c a/b/c or mv a/b/c a/b |
187 | 187 | if (strcasecmp($target, dirname($source)) === 0) { |
188 | - return false; |
|
188 | + return false; |
|
189 | 189 | } |
190 | 190 | $isWindowsOS = api_is_windows_os(); |
191 | 191 | $canExec = function_exists('exec'); |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function getextension($filename) |
267 | 267 | { |
268 | - $bouts = explode('.', $filename); |
|
269 | - return array(array_pop($bouts), implode('.', $bouts)); |
|
268 | + $bouts = explode('.', $filename); |
|
269 | + return array(array_pop($bouts), implode('.', $bouts)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | * @param boolean $recursive if true , include subdirectory in total |
278 | 278 | */ |
279 | 279 | function dirsize($root, $recursive = true) { |
280 | - $dir = @opendir($root); |
|
281 | - $size = 0; |
|
282 | - while ($file = @readdir($dir)) { |
|
283 | - if (!in_array($file, array('.', '..'))) { |
|
284 | - if (is_dir($root.'/'.$file)) { |
|
285 | - $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
286 | - } else { |
|
287 | - $size += @filesize($root.'/'.$file); |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - @closedir($dir); |
|
292 | - return $size; |
|
280 | + $dir = @opendir($root); |
|
281 | + $size = 0; |
|
282 | + while ($file = @readdir($dir)) { |
|
283 | + if (!in_array($file, array('.', '..'))) { |
|
284 | + if (is_dir($root.'/'.$file)) { |
|
285 | + $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
286 | + } else { |
|
287 | + $size += @filesize($root.'/'.$file); |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + @closedir($dir); |
|
292 | + return $size; |
|
293 | 293 | } |