Feature #272 - backup.php, copy_course_session.php, copy_course.php, recycle_course.php: Revision and cleaning.

skala
Ivan Tcholakov 16 years ago
parent fdfec0c922
commit 795dae1c34
  1. 27
      main/coursecopy/backup.php
  2. 75
      main/coursecopy/copy_course.php
  3. 119
      main/coursecopy/copy_course_session.php
  4. 43
      main/coursecopy/recycle_course.php

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Create a backup.
*
@ -7,22 +8,22 @@
* @package chamilo.backup
*/
// name of the language file that needs to be included
// Language files that need to be included
$language_file = array('exercice', 'coursebackup', 'admin');
// including the global file
include ('../inc/global.inc.php');
// Including the global initialization file
require '../inc/global.inc.php';
// Check access rights (only teachers allowed)
if (!api_is_allowed_to_edit())
{
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
// section for the tabs
$this_section=SECTION_COURSES;
// breadcrumbs
$interbreadcrumb[] = array ("url" => "../course_info/maintenance.php", "name" => get_lang('Maintenance'));
// Section for the tabs
$this_section = SECTION_COURSES;
// Breadcrumbs
$interbreadcrumb[] = array('url' => '../course_info/maintenance.php', 'name' => get_lang('Maintenance'));
// Displaying the header
$nameTools = get_lang('Backup');
@ -32,17 +33,17 @@ Display::display_header($nameTools);
api_display_tool_title($nameTools);
/* MAIN CODE */
?>
?>
<ul>
<li><a href="create_backup.php"><?php echo get_lang('CreateBackup') ?></a><br/>
<?php echo get_lang('CreateBackupInfo') ?>
<?php echo get_lang('CreateBackupInfo'); ?>
</li>
<li><a href="import_backup.php"><?php echo get_lang('ImportBackup') ?></a><br/>
<?php echo get_lang('ImportBackupInfo') ?>
<?php echo get_lang('ImportBackupInfo'); ?>
</li>
</ul>
<?php
// Display the footer
Display::display_footer();
?>

@ -1,46 +1,44 @@
<?php // $Id: copy_course.php 22204 2009-07-17 20:31:35Z iflorespaz $
/* For licensing terms, see /dokeos_license.txt */
<?php
/* For licensing terms, see /license.txt */
// name of the language file that needs to be included
// Language files that need to be included
$language_file = array('exercice', 'coursebackup', 'admin');
// setting the global file that gets the general configuration, the databases, the languages, ...
// Setting the global file that gets the general configuration, the databases, the languages, ...
require_once '../inc/global.inc.php';
// including additional libraries
require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
// Including additional libraries
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once 'classes/CourseBuilder.class.php';
require_once 'classes/CourseRestorer.class.php';
require_once 'classes/CourseSelectForm.class.php';
// notice for unauthorized people.
if (!api_is_allowed_to_edit())
{
// Notice for unauthorized people.
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
//remove memory and time limits as much as possible as this might be a long process...
if(function_exists('ini_set'))
{
ini_set('memory_limit','256M');
ini_set('max_execution_time',1800);
// Remove memory and time limits as much as possible as this might be a long process...
if (function_exists('ini_set')) {
ini_set('memory_limit', '256M');
ini_set('max_execution_time', 1800);
}
// breadcrumbs
$interbreadcrumb[] = array ("url" => "../course_info/maintenance.php", "name" => get_lang('Maintenance'));
// Breadcrumbs
$interbreadcrumb[] = array ('url' => '../course_info/maintenance.php', 'name' => get_lang('Maintenance'));
// the section (for the tabs)
$this_section=SECTION_COURSES;
// The section (for the tabs)
$this_section = SECTION_COURSES;
// Display the header
Display::display_header(get_lang('CopyCourse'));
//api_display_tool_title($nameTools);
/*
MAIN CODE
*/
/* MAIN CODE */
// If a CourseSelectForm is posted or we should copy all resources, then copy them
if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') {
if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
$course = CourseSelectForm :: get_posted_course('copy_course');
} else {
$cb = new CourseBuilder();
@ -74,12 +72,12 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
}
$sql .= ' AND target_course_code IS NULL AND cu.user_id = '.$user_info['user_id'].' AND c.code != '."'".$course_info['sysCode']."'".' ORDER BY title ASC';
$res = Database::query($sql);
if( Database::num_rows($res) == 0) {
if (Database::num_rows($res) == 0) {
Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));
} else {
?>
<form method="post" action="copy_course.php">
<?php
<?php
echo get_lang('SelectDestinationCourse');
echo ' <select name="destination_course"/>';
while ($obj = Database::fetch_object($res)) {
@ -90,30 +88,29 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
<br/>
<br/>
<input type="radio" class="checkbox" id="copy_option_1" name="copy_option" value="full_copy"/>
<label for="copy_option_1"><?php echo get_lang('FullCopy') ?></label>
<label for="copy_option_1"><?php echo get_lang('FullCopy'); ?></label>
<br/>
<input type="radio" class="checkbox" id="copy_option_2" name="copy_option" value="select_items" checked="checked"/>
<label for="copy_option_2"><?php echo get_lang('LetMeSelectItems') ?></label>
<label for="copy_option_2"><?php echo get_lang('LetMeSelectItems'); ?></label>
<br/>
<br/>
<?php echo get_lang('SameFilename') ?>
<?php echo get_lang('SameFilename'); ?>
<blockquote>
<input type="radio" class="checkbox" id="same_file_name_option_1" name="same_file_name_option" value="<?php echo FILE_SKIP ?>"/>
<label for="same_file_name_option_1"><?php echo get_lang('SameFilenameSkip') ?></label>
<input type="radio" class="checkbox" id="same_file_name_option_1" name="same_file_name_option" value="<?php echo FILE_SKIP; ?>"/>
<label for="same_file_name_option_1"><?php echo get_lang('SameFilenameSkip'); ?></label>
<br/>
<input type="radio" class="checkbox" id="same_file_name_option_2" name="same_file_name_option" value="<?php echo FILE_RENAME ?>"/>
<label for="same_file_name_option_2"><?php echo get_lang('SameFilenameRename') ?></label>
<input type="radio" class="checkbox" id="same_file_name_option_2" name="same_file_name_option" value="<?php echo FILE_RENAME; ?>"/>
<label for="same_file_name_option_2"><?php echo get_lang('SameFilenameRename'); ?></label>
<br/>
<input type="radio" class="checkbox" id="same_file_name_option_3" name="same_file_name_option" value="<?php echo FILE_OVERWRITE ?>" checked="checked"/>
<label for="same_file_name_option_3"><?php echo get_lang('SameFilenameOverwrite') ?></label>
<input type="radio" class="checkbox" id="same_file_name_option_3" name="same_file_name_option" value="<?php echo FILE_OVERWRITE; ?>" checked="checked"/>
<label for="same_file_name_option_3"><?php echo get_lang('SameFilenameOverwrite'); ?></label>
</blockquote>
<br/>
<button class="save" type="submit"><?php echo get_lang('CopyCourse') ?></button>
<button class="save" type="submit"><?php echo get_lang('CopyCourse'); ?></button>
</form>
<?php
<?php
}
}
/* FOOTER */
/* FOOTER */
Display::display_footer();
?>

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Copy resources from one course in a session to another one.
*
@ -9,12 +10,13 @@
/* INIT SECTION */
// name of the language file that needs to be included
$language_file = array('coursebackup','admin');
// Language files that need to be included
$language_file = array('coursebackup', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'sessionmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
require_once 'classes/CourseBuilder.class.php';
require_once 'classes/CourseRestorer.class.php';
require_once 'classes/CourseSelectForm.class.php';
@ -27,18 +29,16 @@ if (!api_is_allowed_to_edit() && !api_is_session_admin()) {
api_not_allowed(true);
}
//remove memory and time limits as much as possible as this might be a long process...
if(function_exists('ini_set')) {
ini_set('memory_limit','256M');
ini_set('max_execution_time',1800);
// Remove memory and time limits as much as possible as this might be a long process...
if (function_exists('ini_set')) {
ini_set('memory_limit', '256M');
ini_set('max_execution_time', 1800);
}
$this_section=SECTION_PLATFORM_ADMIN;
$this_section = SECTION_PLATFORM_ADMIN;
$nameTools = get_lang('CopyCourse');
$interbreadcrumb[]=array('url' => '../admin/index.php',"name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => '../admin/index.php', 'name' => get_lang('PlatformAdmin'));
// Database Table Definitions
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
@ -49,7 +49,7 @@ $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
/* FUNCTIONS */
function make_select_session_list($name,$sessions,$attr = array()) {
function make_select_session_list($name, $sessions, $attr = array()) {
$attrs = '';
if (count($attr) > 0) {
@ -76,15 +76,13 @@ function make_select_session_list($name,$sessions,$attr = array()) {
function display_form() {
global $charset;
$html = '';
$sessions = SessionManager::get_sessions_list();
// actions
// Actions
$html .= '<div class="sectiontitle">';
// link back to the documents overview
$html .= '<a href="../admin/index.php">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('PlatformAdmin'),array('style'=>'vertical-align:middle')).get_lang('BackTo').' '.get_lang('PlatformAdmin').'</a>';
// Link back to the documents overview
$html .= '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), array('style' => 'vertical-align:middle')).get_lang('BackTo').' '.get_lang('PlatformAdmin').'</a>';
$html .= '</div>';
$html .= '<div class="row"><div class="form_header">'.get_lang('CopyCourse').'</div></div>';
@ -94,9 +92,9 @@ function display_form() {
$html .= '<tr><td width="30%" align="center"><b>'.get_lang('OriginCoursesFromSession').':</b></td>';
$html .= '<td >&nbsp;</td><td align="center" width="30%"><b>'.get_lang('DestinationCoursesFromSession').':</b></td></tr>';
$html .= '<tr><td width="30%" align="center">'.make_select_session_list('sessions_list_origin',$sessions,array('onchange'=>'xajax_search_courses(this.value,\'origin\')')).'</td>';
$html .= '<tr><td width="30%" align="center">'.make_select_session_list('sessions_list_origin', $sessions, array('onchange' => 'javascript: xajax_search_courses(this.value,\'origin\');')).'</td>';
$html .= '<td>&nbsp;</td><td width="30%" align="center"><div id="ajax_sessions_list_destination">';
$html .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$html .= '<select name="sessions_list_destination" onchange = "javascript: xajax_search_courses(this.value,\'destination\');">';
$html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div></td></tr>';
$html .= '<tr><td width="30%" align="center"><div id="ajax_list_courses_origin">';
@ -105,17 +103,14 @@ function display_form() {
// Options configuration
//$html .= '<td align="top"><div class="sectiontitle">'.get_lang('CopyCourse').'</div>';
$html .= '<td align="top">';
$introduction = get_lang('CopyCourseFromSessionToSessionExplanation',true);
$introduction = get_lang('CopyCourseFromSessionToSessionExplanation');
$html .= '<div class="normal-message">'.$introduction.'</div>';
$html .= '<div style="height:150px;padding-top:10px;padding-bottom:50px"><h3>'.get_lang('TypeOfCopy').'</h3>';
$html .= '<input type="radio" class="checkbox" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= '<label for="copy_option_1">'.get_lang('FullCopy').'</label><br/>';
$html .= '<input type="radio" class="checkbox" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
$html .= '<label for="copy_option_2"><span id="title_option2" style="color:#aaa">'.get_lang('LetMeSelectItems').'</span></label><br/><br/>';
$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.get_lang('CopyCourse').'</button></div>';
$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.get_lang('CopyCourse').'</button></div>';
$html .= '</td><td width="30%" align="center">';
$html .= '<div id="ajax_list_courses_destination">';
@ -125,7 +120,8 @@ function display_form() {
echo $html;
}
function search_courses($id_session,$type) {
function search_courses($id_session, $type) {
global $tbl_course, $tbl_session_rel_course, $course_list;
$xajax_response = new XajaxResponse();
@ -137,7 +133,7 @@ function search_courses($id_session,$type) {
if ($type == 'origin') {
// search courses by id_session for origin list
// Search courses by id_session for origin list
$sql = "SELECT c.code, c.visual_code, c.title, src.id_session
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
@ -146,13 +142,12 @@ function search_courses($id_session,$type) {
$course_list = array();
$return .= '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\')">';
while($course = Database :: fetch_array($rs)) {
$return .= '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="javascript: checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\');">';
while ($course = Database :: fetch_array($rs)) {
$course_list[] = "'{$course['code']}'";
$course_title=str_replace("'","\'",$course_title);
$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
$return .= '<option value="'.$course['code'].'" title="'.@htmlspecialchars($course['title'].' ('.$course['visual_code'].')', ENT_QUOTES, api_get_system_encoding()).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
}
$return .= '</select>';
@ -170,34 +165,34 @@ function search_courses($id_session,$type) {
$rs_select_destination = Database::query($sql);
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$select_destination .= '<select name="sessions_list_destination" onchange = "javascript: xajax_search_courses(this.value,\'destination\');">';
$select_destination .= '<option value = "0">'.get_lang('SelectASession').'</option>';
while($session = Database :: fetch_array($rs_select_destination)) {
$select_destination .= '<option value="'.$session['id'].'">'.$session['name'].' ('.$session['category_name'].')</option>';
}
$select_destination .= '</select>';
$xajax_response -> addAssign('ajax_sessions_list_destination','innerHTML',api_utf8_encode($select_destination));
$xajax_response -> addAssign('ajax_sessions_list_destination', 'innerHTML', api_utf8_encode($select_destination));
} else{
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$select_destination .= '<select name="sessions_list_destination" onchange = "javascript: xajax_search_courses(this.value,\'destination\');">';
$select_destination .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option>';
$select_destination .= '</select>';
$xajax_response -> addAssign('ajax_sessions_list_destination','innerHTML',api_utf8_encode($select_destination));
$xajax_response -> addAssign('ajax_sessions_list_destination', 'innerHTML', api_utf8_encode($select_destination));
}
// select multiple destination empty
// Select multiple destination empty
$select_multiple_empty = '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;"></select>';
// send response by ajax
$xajax_response -> addAssign('ajax_list_courses_origin','innerHTML',api_utf8_encode($return));
$xajax_response -> addAssign('ajax_list_courses_destination','innerHTML',api_utf8_encode($select_multiple_empty));
// Send response by ajax
$xajax_response -> addAssign('ajax_list_courses_origin', 'innerHTML', api_utf8_encode($return));
$xajax_response -> addAssign('ajax_list_courses_destination', 'innerHTML', api_utf8_encode($select_multiple_empty));
} else {
$list_courses_origin = implode(',',$_SESSION['course_list']);
$list_courses_origin = implode(',', $_SESSION['course_list']);
$session_origin = $_SESSION['session_origin'];
// search courses by id_session where course codes is include en courses list destination
// Search courses by id_session where course codes is include en courses list destination
$sql = "SELECT c.code, c.visual_code, c.title, src.id_session
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
@ -206,48 +201,46 @@ function search_courses($id_session,$type) {
$rs = Database::query($sql);
$course_list_destination = array();
$return .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;" onmouseover="this.disabled=true;" onmouseout="this.disabled=false;">';
while($course = Database :: fetch_array($rs)) {
$return .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;" onmouseover="javascript: this.disabled=true;" onmouseout="javascript: this.disabled=false;">';
while ($course = Database :: fetch_array($rs)) {
$course_list_destination[] = $course['code'];
$course_title=str_replace("'","\'",$course_title);
$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
$course_title = str_replace("'", "\'", $course_title);
$return .= '<option value="'.$course['code'].'" title="'.@htmlspecialchars($course['title'].' ('.$course['visual_code'].')', ENT_QUOTES, api_get_system_encoding()).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
}
$return .= '</select>';
$_SESSION['course_list_destination'] = $course_list_destination;
// send response by ajax
$xajax_response -> addAssign('ajax_list_courses_destination','innerHTML',api_utf8_encode($return));
// Send response by ajax
$xajax_response -> addAssign('ajax_list_courses_destination', 'innerHTML', api_utf8_encode($return));
// disable option from session courses list origin where if no the same con the destination
// Disable option from session courses list origin where if no the same con the destination
$sql = "SELECT c.code, c.visual_code, c.title, src.id_session
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
AND src.id_session = '".intval($session_origin)."'";
$result = Database::query($sql);
$return_option_disabled = '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\')">';
while($cours = Database :: fetch_array($result)) {
$course_title=str_replace("'","\'",$course_title);
$return_option_disabled = '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="javascript: checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\');">';
while ($cours = Database :: fetch_array($result)) {
$course_title=str_replace("'", "\'", $course_title);
if (count($course_list_destination) > 0) {
if (!in_array($cours['code'],$course_list_destination)) {
if (!in_array($cours['code'], $course_list_destination)) {
$return_option_disabled .= '<optgroup style="color:#ccc" label="'.$cours['title'].' ('.$cours['visual_code'].')" >'.$cours['title'].' ('.$cours['visual_code'].')</optgroup>';
} else {
$return_option_disabled .= '<option value="'.$cours['code'].'" title="'.htmlspecialchars($cours['title'].' ('.$cours['visual_code'].')',ENT_QUOTES).'">'.$cours['title'].' ('.$cours['visual_code'].')</option>';
$return_option_disabled .= '<option value="'.$cours['code'].'" title="'.@htmlspecialchars($cours['title'].' ('.$cours['visual_code'].')', ENT_QUOTES, api_get_system_encoding()).'">'.$cours['title'].' ('.$cours['visual_code'].')</option>';
}
} else {
if (empty($id_session)) {
$return_option_disabled .= '<option value="'.$cours['code'].'" title="'.htmlspecialchars($cours['title'].' ('.$cours['visual_code'].')',ENT_QUOTES).'">'.$cours['title'].' ('.$cours['visual_code'].')</option>';
$return_option_disabled .= '<option value="'.$cours['code'].'" title="'.@htmlspecialchars($cours['title'].' ('.$cours['visual_code'].')', ENT_QUOTES, api_get_system_encoding()).'">'.$cours['title'].' ('.$cours['visual_code'].')</option>';
} else {
$return_option_disabled .= '<optgroup style="color:#ccc" label="'.$cours['title'].'('.$cours['visual_code'].')" >'.$cours['title'].' ('.$cours['visual_code'].')</optgroup>';
}
}
}
$return_option_disabled .= '</select>';
// send response by ajax
$xajax_response -> addAssign('ajax_list_courses_origin','innerHTML',api_utf8_encode($return_option_disabled));
// Send response by ajax
$xajax_response -> addAssign('ajax_list_courses_origin', 'innerHTML', api_utf8_encode($return_option_disabled));
}
}
return $xajax_response;
}
@ -256,7 +249,7 @@ $xajax -> processRequests();
/* HTML head extra */
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '<script language="javascript">
$htmlHeadXtra[] = '<script type="text/javascript">
function checkSelected(id_select,id_radio,id_title,id_destination) {
var num=0;
@ -301,7 +294,7 @@ Display::display_header($nameTools);
/* MAIN CODE */
if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
$destination_course = $origin_course = $destination_session = $origin_session = '';
@ -338,7 +331,7 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
$origin_session = $_POST['sessions_list_origin'];
}
if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
foreach ($arr_course_origin as $course_origin) {
@ -358,7 +351,7 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
}
} elseif (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'select_items') {
} elseif (isset($_POST['copy_option']) && $_POST['copy_option'] == 'select_items') {
// Else, if a CourseSelectForm is requested, show it
if (api_get_setting('show_glossary_in_documents') != 'none') {
@ -393,7 +386,7 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
$hidden_fields['destination_session'] = $destination_session;
$hidden_fields['origin_session'] = $origin_session;
CourseSelectForm :: display_form($course,$hidden_fields, true);
echo '<div style="float:right"><a href="javascript:window.back();">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('PlatformAdmin'),array('style'=>'vertical-align:middle')).get_lang('Back').'</a></div>';
echo '<div style="float:right"><a href="javascript:window.back();">'.Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('PlatformAdmin'), array('style' => 'vertical-align:middle')).get_lang('Back').'</a></div>';
} else {
Display::display_error_message(get_lang('You must select a course from original session and select a destination session'));
display_form();

@ -1,5 +1,6 @@
<?php // $Id: recycle_course.php 19948 2009-04-21 17:27:59Z juliomontoya $
<?php
/* For licensing terms, see /license.txt */
/**
* Delete resources from a course.
*
@ -7,27 +8,28 @@
* @package chamilo.backup
*/
// name of the language file that needs to be included
// Language files that need to be included
$language_file = array ('exercice', 'admin', 'course_info', 'coursebackup');
// including the global file
// Including the global initialization file
require_once '../inc/global.inc.php';
// Check access rights (only teachers are allowed here)
if( ! api_is_allowed_to_edit()) {
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
// section for the tabs
$this_section=SECTION_COURSES;
// breadcrumbs
$interbreadcrumb[] = array ("url" => "../course_info/maintenance.php", "name" => get_lang('Maintenance'));
// Section for the tabs
$this_section = SECTION_COURSES;
// Breadcrumbs
$interbreadcrumb[] = array('url' => '../course_info/maintenance.php', 'name' => get_lang('Maintenance'));
// Displaying the header
$nameTools = get_lang('RecycleCourse');
Display::display_header($nameTools);
// include additional libraries
// Include additional libraries
require_once 'classes/CourseBuilder.class.php';
require_once 'classes/CourseArchiver.class.php';
require_once 'classes/CourseRecycler.class.php';
@ -37,8 +39,9 @@ require_once 'classes/CourseSelectForm.class.php';
api_display_tool_title($nameTools);
/* MAIN CODE */
if( (isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (isset($_POST['recycle_option']) && $_POST['recycle_option'] == 'full_backup' ) ) {
if(isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) {
if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset($_POST['recycle_option']) && $_POST['recycle_option'] == 'full_backup')) {
if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
$course = CourseSelectForm::get_posted_course();
} else {
$cb = new CourseBuilder();
@ -47,31 +50,31 @@ if( (isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (
$cr = new CourseRecycler($course);
$cr->recycle();
Display::display_confirmation_message(get_lang('RecycleFinished'));
} elseif( isset($_POST['recycle_option']) && $_POST['recycle_option'] == 'select_items') {
} elseif (isset($_POST['recycle_option']) && $_POST['recycle_option'] == 'select_items') {
$cb = new CourseBuilder();
$course = $cb->build();
CourseSelectForm::display_form($course);
} else {
$cb = new CourseBuilder();
$course = $cb->build();
if( ! $course->has_resources()) {
if (!$course->has_resources()) {
echo get_lang('NoResourcesToRecycle');
} else {
Display::display_warning_message(get_lang('RecycleWarning'),false);
?>
Display::display_warning_message(get_lang('RecycleWarning'), false);
?>
<form method="post" action="recycle_course.php">
<input type="radio" class="checkbox" id="recycle_option_1" name="recycle_option" value="full_backup" checked="checked"/>
<label for="recycle_option_1"><?php echo get_lang('FullRecycle') ?></label>
<label for="recycle_option_1"><?php echo get_lang('FullRecycle'); ?></label>
<br/>
<input type="radio" class="checkbox" id="recycle_option_2" name="recycle_option" value="select_items"/>
<label for="recycle_option_2"><?php echo get_lang('LetMeSelectItems') ?></label>
<label for="recycle_option_2"><?php echo get_lang('LetMeSelectItems'); ?></label>
<br/>
<br/>
<button class="save" type="submit"><?php echo get_lang('RecycleCourse') ?></button>
<button class="save" type="submit"><?php echo get_lang('RecycleCourse'); ?></button>
</form>
<?php
<?php
}
}
// Display the footer
Display::display_footer();
?>
Loading…
Cancel
Save