Format code

pull/2487/head
jmontoyaa 9 years ago
parent ec9316274e
commit e2072d89ae
  1. 12
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php
  2. 16
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php
  3. 23
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php
  4. 60
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php

@ -1213,9 +1213,9 @@ class CourseBuilder
if ($db_result) {
while ($obj = Database::fetch_object($db_result)) {
$items = array();
$sql_items = "SELECT * FROM ".$table_item."
WHERE c_id = '$courseId' AND lp_id = ".$obj->id;
$db_items = Database::query($sql_items);
$sql = "SELECT * FROM ".$table_item."
WHERE c_id = '$courseId' AND lp_id = ".$obj->id;
$db_items = Database::query($sql);
while ($obj_item = Database::fetch_object($db_items)) {
$item['id'] = $obj_item->id;
$item['item_type'] = $obj_item->item_type;
@ -1237,12 +1237,12 @@ class CourseBuilder
$items[] = $item;
}
$sql_tool = "SELECT id FROM $table_tool
WHERE
$sql = "SELECT id FROM $table_tool
WHERE
c_id = $courseId AND
(link LIKE '%lp_controller.php%lp_id=".$obj->id."%' AND image='scormbuilder.gif') AND
visibility = '1' ";
$db_tool = Database::query($sql_tool);
$db_tool = Database::query($sql);
if (Database::num_rows($db_tool)) {
$visibility = '1';

@ -35,15 +35,16 @@ class CourseRecycler
* Delete all items from the course.
* This deletes all items in the course-object from the current Chamilo-
* course
* @param string $type 'full_backup' or 'select_items'
* @param string $backupType 'full_backup' or 'select_items'
*
* @return bool
*
* @assert (null) === false
*/
public function recycle($type)
public function recycle($backupType)
{
if (empty($type)) {
if (empty($backupType)) {
return false;
}
@ -51,7 +52,7 @@ class CourseRecycler
$table_linked_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
$table_item_properties = Database::get_course_table(TABLE_ITEM_PROPERTY);
$this->type = $type;
$this->type = $backupType;
$this->recycle_links();
$this->recycle_link_categories();
$this->recycle_events();
@ -99,7 +100,7 @@ class CourseRecycler
$table = Database :: get_course_table(TABLE_DOCUMENT);
$tableItemProperty = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if ($this->type == 'full_backup') {
if ($this->type === 'full_backup') {
$sql = "DELETE FROM $tableItemProperty
WHERE
c_id = ".$this->course_id." AND
@ -635,13 +636,12 @@ class CourseRecycler
$resources = $this->course->resources;
foreach ($resources[RESOURCE_THEMATIC] as $last_id => $thematic) {
if (is_numeric($last_id)) {
foreach($thematic->thematic_advance_list as $thematic_advance) {
$cond = array(
'id = ? AND c_id = ?' => array(
$thematic_advance['id'],
$this->course_id,
),
$this->course_id
)
);
api_item_property_update(
$this->course_info,

@ -300,7 +300,6 @@ class CourseRestorer
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
if (empty($document->item_properties[0]['id_session'])) {
$my_session_id = 0;
} else {
@ -1035,7 +1034,6 @@ class CourseRestorer
$params['c_id'] = $this->destination_course_id;
$params['forum_category'] = $cat_id;
$params['session_id'] = $sessionId;
$params['start_time'] = isset($params['start_time']) && $params['start_time'] === '0000-00-00 00:00:00' ? null : $params['start_time'];
$params['end_time'] = isset($params['end_time']) && $params['end_time'] === '0000-00-00 00:00:00' ? null : $params['end_time'];
$params['forum_id'] = 0;
@ -1099,15 +1097,6 @@ class CourseRestorer
}
}
if ($forum_cat && !$forum_cat->is_restored()) {
/*$title = $forum_cat->obj->cat_title;
if (!empty($title)) {
if (!preg_match('/.*\((.+)\)$/', $title, $matches)) {
// This is for avoiding repetitive adding of training code after several backup/restore cycles.
if ($matches[1] != $this->course->code) {
$title = $title.' ('.$this->course->code.')';
}
}
}*/
$params = (array) $forum_cat->obj;
$params['c_id'] = $this->destination_course_id;
$params['cat_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
@ -1644,13 +1633,6 @@ class CourseRestorer
if ($copy_result) {
$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
/*$sql = "INSERT INTO ".$table_attachment." SET
c_id = ".$this->destination_course_id." ,
path = '".self::DBUTF8escapestring($new_filename)."',
comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."',
size = '".$announcement->attachment_size."', filename = '".$announcement->attachment_filename."',
announcement_id = '".$new_announcement_id."' ";
Database::query($sql);*/
$params = [
'c_id' => $this->destination_course_id,
@ -1925,8 +1907,6 @@ class CourseRestorer
$this->course->info['path']
);
// id = '". ($index + 1)."',
$params = [
'c_id' => $this->destination_course_id,
'question_id' => $new_id,
@ -2329,8 +2309,7 @@ class CourseRestorer
{
$resources = $this->course->resources;
$question = $resources[RESOURCE_SURVEYQUESTION][$id];
$new_id=0;
$new_id = 0;
if (is_object($question)) {
if ($question->is_restored()) {

@ -19,8 +19,9 @@ class CourseSelectForm
{
/**
* Display the form
* @param array $course
* @param array $hidden_fields Hidden fields to add to the form.
* @param boolean the document array will be serialize. This is used in the course_copy.php file
* @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
*/
public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
{
@ -48,14 +49,11 @@ class CourseSelectForm
<script>
function exp(item) {
el = document.getElementById('div_'+item);
if (el.style.display=='none'){
el.style.display='';
//document.getElementById('img_'+item).src='<?php echo Display::returnIconPath('1.gif'); ?>';
document.getElementById('img_'+item).className='fa fa-minus-square-o fa-lg';
}
else{
if (el.style.display == 'none') {
el.style.display = '';
document.getElementById('img_'+item).className = 'fa fa-minus-square-o fa-lg';
} else {
el.style.display='none';
//document.getElementById('img_'+item).src='<?php echo Display::returnIconPath('0.gif'); ?>';
document.getElementById('img_'+item).className ='fa fa-plus-square-o fa-lg';
}
}
@ -65,8 +63,7 @@ class CourseSelectForm
for (i = 0; i < d.elements.length; i++) {
if (d.elements[i].type == "checkbox") {
var name = d.elements[i].attributes.getNamedItem('name').nodeValue;
if( name.indexOf(type) > 0 || type == 'all' ){
if (name.indexOf(type) > 0 || type == 'all') {
if ($(d.elements[i]).attr('rel') == item_id) {
d.elements[i].checked = value;
}
@ -141,13 +138,9 @@ class CourseSelectForm
}
</script>
<?php
//get destination course title
// get destination course title
if (!empty($hidden_fields['destination_course'])) {
$sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name(
$hidden_fields['destination_session']
) . ')' : null;
$sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null;
$course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
echo '<h3>';
echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
@ -204,14 +197,13 @@ class CourseSelectForm
$element_count++;
break;
case RESOURCE_LINKCATEGORY:
case RESOURCE_FORUMPOST:
case RESOURCE_QUIZQUESTION:
case RESOURCE_SURVEYQUESTION:
case RESOURCE_SURVEYINVITATION:
case RESOURCE_SCORM:
break;
default :
//echo '<img id="img_'.$type.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$type'".');" />&nbsp;';
case RESOURCE_FORUMPOST:
case RESOURCE_QUIZQUESTION:
case RESOURCE_SURVEYQUESTION:
case RESOURCE_SURVEYINVITATION:
case RESOURCE_SCORM:
break;
default:
echo '<span id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" onclick="javascript:exp('."'$type'".');" >&nbsp;</span>&nbsp;';
echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />';
echo '<div id="div_'.$type.'">';
@ -256,8 +248,6 @@ class CourseSelectForm
//Fixes forum order
if (!empty($forum_categories)) {
$type = RESOURCE_FORUMCATEGORY;
//echo '<img id="img_'.$type.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$type'".');" />&nbsp;';
echo '<span id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" onclick="javascript:exp('."'$type'".');" >&nbsp;</span>&nbsp;';
echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[RESOURCE_FORUM].'</b><br />';
echo '<div id="div_'.$type.'">';
@ -351,7 +341,7 @@ class CourseSelectForm
/**
* @param $course
*/
static function display_hidden_quiz_questions($course)
public static function display_hidden_quiz_questions($course)
{
if(is_array($course->resources)){
foreach ($course->resources as $type => $resources) {
@ -371,7 +361,7 @@ class CourseSelectForm
/**
* @param $course
*/
static function display_hidden_scorm_directories($course)
public static function display_hidden_scorm_directories($course)
{
if (is_array($course->resources)){
foreach ($course->resources as $type => $resources) {
@ -584,8 +574,9 @@ class CourseSelectForm
/**
* Display the form session export
* @param array $list_course
* @param array $hidden_fields Hidden fields to add to the form.
* @param boolean the document array will be serialize. This is used in the course_copy.php file
* @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
*/
public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
{
@ -593,14 +584,12 @@ class CourseSelectForm
<script>
function exp(item) {
el = document.getElementById('div_'+item);
if (el.style.display=='none'){
el.style.display='';
//document.getElementById('img_'+item).src='<?php echo Display::returnIconPath('1.gif'); ?>';
if (el.style.display == 'none') {
el.style.display = '';
document.getElementById('img_'+item).className('fa fa-minus-square-o fa-lg');
}
else{
el.style.display='none';
//document.getElementById('img_'+item).src='<?php echo Display::returnIconPath('0.gif'); ?>';
el.style.display = 'none';
document.getElementById('img_'+item).className('fa fa-plus-square-o fa-lg');
}
}
@ -651,10 +640,9 @@ class CourseSelectForm
$icon = Display::returnIconPath('progress_bar.gif');
echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
foreach ($list_course as $course){
foreach ($list_course as $course) {
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
//echo '<img id="img_'.$course->code.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$course->code'".');" />';
echo '<span id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg" onclick="javascript:exp('."'$course->code'".');" >&nbsp;</span>';
echo '<b onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
echo '<div id="div_'.$course->code.'">';

Loading…
Cancel
Save