dokeos-backup
[ class tree: dokeos-backup ] [ index: dokeos-backup ] [ all elements ]

Source for file copy_course.php

Documentation is available at copy_course.php

  1. <?php
  2. // $Id: copy_course.php 15281 2008-05-13 23:10:40Z yannoo $
  3. /*
  4. ============================================================================== 
  5.     Dokeos - elearning and course management software
  6.     
  7.     Copyright (c) 2004 Dokeos S.A.
  8.     Copyright (c) 2003 Ghent University (UGent)
  9.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  10.     Copyright (c) Bart Mollet (bart.mollet@hogent.be)
  11.     
  12.     For a full list of contributors, see "credits.txt".
  13.     The full license can be read in "license.txt".
  14.     
  15.     This program is free software; you can redistribute it and/or
  16.     modify it under the terms of the GNU General Public License
  17.     as published by the Free Software Foundation; either version 2
  18.     of the License, or (at your option) any later version.
  19.     
  20.     See the GNU General Public License for more details.
  21.     
  22.     Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  23.     Mail: info@dokeos.com
  24. ============================================================================== 
  25. */
  26. /**
  27.  * ==============================================================================
  28.  * Copy resources from one course to another one.
  29.  * 
  30.  * @author Bart Mollet <bart.mollet@hogent.be>
  31.  * @package dokeos.backup
  32.  *  ==============================================================================
  33.  */
  34. /*
  35. ==============================================================================
  36.         INIT SECTION
  37. ==============================================================================
  38. */ 
  39. // name of the language file that needs to be included 
  40. $language_file array('coursebackup','admin');
  41. include ('../inc/global.inc.php');
  42. include_once(api_get_path(LIBRARY_PATH'fileManage.lib.php');
  43. require_once ('classes/CourseBuilder.class.php');
  44. require_once ('classes/CourseRestorer.class.php');
  45. require_once ('classes/CourseSelectForm.class.php');
  46.  
  47. {
  48.     api_not_allowed(true);
  49. }
  50.  
  51. //remove memory and time limits as much as possible as this might be a long process...
  52. if(function_exists('ini_set'))
  53. {
  54.     ini_set('memory_limit','256M');
  55.     ini_set('max_execution_time',1800);
  56. }
  57.  
  58. $nameTools get_lang('CopyCourse');
  59. $interbreadcrumb[array ("url" => "../course_info/maintenance.php""name" => get_lang('Maintenance'));
  60.  
  61. Display::display_header($nameTools);
  62. //api_display_tool_title($nameTools);
  63. /*
  64. ==============================================================================
  65.         MAIN CODE
  66. ==============================================================================
  67. */ 
  68. // If a CourseSelectForm is posted or we should copy all resources, then copy them
  69. if ((isset ($_POST['action']&& $_POST['action'== 'course_select_form'|| (isset ($_POST['copy_option']&& $_POST['copy_option'== 'full_copy'))
  70. {
  71.     if (isset ($_POST['action']&& $_POST['action'== 'course_select_form')
  72.     {
  73.         $course CourseSelectForm :: get_posted_course();
  74.     }
  75.     else
  76.     {
  77.         $cb new CourseBuilder();
  78.         $course $cb->build();
  79.     }
  80.     $cr new CourseRestorer($course);
  81.     $cr->set_file_option($_POST['same_file_name_option']);
  82.     $cr->restore($_POST['destination_course']);
  83.     Display::display_normal_message(get_lang('CopyFinished'));
  84. }
  85. // Else, if a CourseSelectForm is requested, show it
  86. elseif (isset ($_POST['copy_option']&& $_POST['copy_option'== 'select_items')
  87. {
  88.     Display::display_normal_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
  89.     $cb new CourseBuilder();
  90.     $course $cb->build();
  91.     //echo get_lang('SelectItemsToCopy');
  92.     //echo '<br/><br/>';
  93.     $hidden_fields['same_file_name_option'$_POST['same_file_name_option'];
  94.     $hidden_fields['destination_course'$_POST['destination_course'];
  95.     CourseSelectForm :: display_form($course$hidden_fields);
  96. }
  97. // Else, show the default page
  98. else
  99. {
  100.     $table_c Database :: get_main_table(TABLE_MAIN_COURSE);
  101.     $table_cu Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  102.     $user_info api_get_user_info();
  103.     $course_info api_get_course_info();
  104.     $sql 'SELECT * FROM '.$table_c.' c, '.$table_cu.' cu WHERE cu.course_code = c.code';
  105.     ifapi_is_platform_admin())
  106.     {
  107.         $sql .= ' AND cu.status=1 ';
  108.     }
  109.     $sql .= ' AND target_course_code IS NULL AND cu.user_id = '.$user_info['user_id'].' AND c.code != '."'".$course_info['sysCode']."'".' ';
  110.     $res api_sql_query($sql,__FILE__,__LINE__);
  111.     ifmysql_num_rows($res== 0)
  112.     {
  113.         Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));    
  114.     }
  115.     else
  116.     {
  117. ?>
  118.     <form method="post" action="copy_course.php">
  119.     <?php
  120.     echo get_lang('SelectDestinationCourse');
  121.     echo ' <select name="destination_course"/>';
  122.     while ($obj mysql_fetch_object($res))
  123.     {
  124.         echo '<option value="'.$obj->code.'">'.$obj->title.'</option>';
  125.     }
  126.     echo '</select>';
  127. ?>
  128.     <br/>
  129.     <br/>
  130.     <input type="radio" class="checkbox" id="copy_option_1" name="copy_option" value="full_copy"/>
  131.     <label for="copy_option_1"><?php echo get_lang('FullCopy'?></label>
  132.     <br/>
  133.     <input type="radio" class="checkbox" id="copy_option_2" name="copy_option" value="select_items" checked="checked"/>
  134.     <label for="copy_option_2"><?php echo get_lang('LetMeSelectItems'?></label>
  135.     <br/>
  136.     <br/>
  137.     <?php echo get_lang('SameFilename'?>
  138.     <blockquote>
  139.     <input type="radio" class="checkbox"  id="same_file_name_option_1" name="same_file_name_option" value="<?php echo FILE_SKIP ?>"/>
  140.     <label for="same_file_name_option_1"><?php echo  get_lang('SameFilenameSkip'?></label>
  141.     <br/>
  142.     <input type="radio" class="checkbox" id="same_file_name_option_2" name="same_file_name_option" value="<?php echo FILE_RENAME ?>"/>
  143.     <label for="same_file_name_option_2"><?php echo get_lang('SameFilenameRename'?></label>
  144.     <br/>
  145.     <input type="radio" class="checkbox"  id="same_file_name_option_3" name="same_file_name_option"  value="<?php echo FILE_OVERWRITE ?>"  checked="checked"/>
  146.     <label for="same_file_name_option_3"><?php echo get_lang('SameFilenameOverwrite'?></label>
  147.     </blockquote>
  148.     <br/>
  149.     <input type="submit" value="<?php echo get_lang('CopyCourse'?>"/>
  150.     </form>
  151.     <?php
  152.     }
  153.  
  154. }
  155. /*
  156. ==============================================================================
  157.         FOOTER 
  158. ==============================================================================
  159. */ 
  160. ?>

Documentation generated on Thu, 12 Jun 2008 13:09:47 -0500 by phpDocumentor 1.4.1