Format code

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

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

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

@ -300,7 +300,6 @@ class CourseRestorer
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
if (empty($document->item_properties[0]['id_session'])) { if (empty($document->item_properties[0]['id_session'])) {
$my_session_id = 0; $my_session_id = 0;
} else { } else {
@ -1035,7 +1034,6 @@ class CourseRestorer
$params['c_id'] = $this->destination_course_id; $params['c_id'] = $this->destination_course_id;
$params['forum_category'] = $cat_id; $params['forum_category'] = $cat_id;
$params['session_id'] = $sessionId; $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['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['end_time'] = isset($params['end_time']) && $params['end_time'] === '0000-00-00 00:00:00' ? null : $params['end_time'];
$params['forum_id'] = 0; $params['forum_id'] = 0;
@ -1099,15 +1097,6 @@ class CourseRestorer
} }
} }
if ($forum_cat && !$forum_cat->is_restored()) { 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 = (array) $forum_cat->obj;
$params['c_id'] = $this->destination_course_id; $params['c_id'] = $this->destination_course_id;
$params['cat_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $params['cat_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
@ -1644,13 +1633,6 @@ class CourseRestorer
if ($copy_result) { if ($copy_result) {
$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); $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 = [ $params = [
'c_id' => $this->destination_course_id, 'c_id' => $this->destination_course_id,
@ -1925,8 +1907,6 @@ class CourseRestorer
$this->course->info['path'] $this->course->info['path']
); );
// id = '". ($index + 1)."',
$params = [ $params = [
'c_id' => $this->destination_course_id, 'c_id' => $this->destination_course_id,
'question_id' => $new_id, 'question_id' => $new_id,
@ -2329,7 +2309,6 @@ class CourseRestorer
{ {
$resources = $this->course->resources; $resources = $this->course->resources;
$question = $resources[RESOURCE_SURVEYQUESTION][$id]; $question = $resources[RESOURCE_SURVEYQUESTION][$id];
$new_id = 0; $new_id = 0;
if (is_object($question)) { if (is_object($question)) {

@ -19,8 +19,9 @@ class CourseSelectForm
{ {
/** /**
* Display the form * Display the form
* @param array $course
* @param array $hidden_fields Hidden fields to add to the form. * @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) public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
{ {
@ -50,12 +51,9 @@ class CourseSelectForm
el = document.getElementById('div_'+item); el = document.getElementById('div_'+item);
if (el.style.display == 'none') { if (el.style.display == 'none') {
el.style.display = ''; 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'; document.getElementById('img_'+item).className = 'fa fa-minus-square-o fa-lg';
} } else {
else{
el.style.display='none'; 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'; document.getElementById('img_'+item).className ='fa fa-plus-square-o fa-lg';
} }
} }
@ -65,7 +63,6 @@ class CourseSelectForm
for (i = 0; i < d.elements.length; i++) { for (i = 0; i < d.elements.length; i++) {
if (d.elements[i].type == "checkbox") { if (d.elements[i].type == "checkbox") {
var name = d.elements[i].attributes.getNamedItem('name').nodeValue; 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) { if ($(d.elements[i]).attr('rel') == item_id) {
d.elements[i].checked = value; d.elements[i].checked = value;
@ -141,13 +138,9 @@ class CourseSelectForm
} }
</script> </script>
<?php <?php
// get destination course title // get destination course title
if (!empty($hidden_fields['destination_course'])) { if (!empty($hidden_fields['destination_course'])) {
$sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name( $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null;
$hidden_fields['destination_session']
) . ')' : null;
$course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
echo '<h3>'; echo '<h3>';
echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
@ -211,7 +204,6 @@ class CourseSelectForm
case RESOURCE_SCORM: case RESOURCE_SCORM:
break; break;
default: default:
//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 '<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 '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />';
echo '<div id="div_'.$type.'">'; echo '<div id="div_'.$type.'">';
@ -256,8 +248,6 @@ class CourseSelectForm
//Fixes forum order //Fixes forum order
if (!empty($forum_categories)) { if (!empty($forum_categories)) {
$type = RESOURCE_FORUMCATEGORY; $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 '<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 '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[RESOURCE_FORUM].'</b><br />';
echo '<div id="div_'.$type.'">'; echo '<div id="div_'.$type.'">';
@ -351,7 +341,7 @@ class CourseSelectForm
/** /**
* @param $course * @param $course
*/ */
static function display_hidden_quiz_questions($course) public static function display_hidden_quiz_questions($course)
{ {
if(is_array($course->resources)){ if(is_array($course->resources)){
foreach ($course->resources as $type => $resources) { foreach ($course->resources as $type => $resources) {
@ -371,7 +361,7 @@ class CourseSelectForm
/** /**
* @param $course * @param $course
*/ */
static function display_hidden_scorm_directories($course) public static function display_hidden_scorm_directories($course)
{ {
if (is_array($course->resources)){ if (is_array($course->resources)){
foreach ($course->resources as $type => $resources) { foreach ($course->resources as $type => $resources) {
@ -584,8 +574,9 @@ class CourseSelectForm
/** /**
* Display the form session export * Display the form session export
* @param array $list_course
* @param array $hidden_fields Hidden fields to add to the form. * @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) public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
{ {
@ -595,12 +586,10 @@ class CourseSelectForm
el = document.getElementById('div_'+item); el = document.getElementById('div_'+item);
if (el.style.display == 'none') { if (el.style.display == 'none') {
el.style.display = ''; 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'); document.getElementById('img_'+item).className('fa fa-minus-square-o fa-lg');
} }
else{ else{
el.style.display = 'none'; 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'); document.getElementById('img_'+item).className('fa fa-plus-square-o fa-lg');
} }
} }
@ -654,7 +643,6 @@ class CourseSelectForm
foreach ($list_course as $course) { foreach ($list_course as $course) {
foreach ($course->resources as $type => $resources) { foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) { 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 '<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 '<b onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
echo '<div id="div_'.$course->code.'">'; echo '<div id="div_'.$course->code.'">';

Loading…
Cancel
Save