Fix namespaces/use

pull/2487/head
jmontoyaa 9 years ago
parent dbfe8396ae
commit c76eecd53e
  1. 9
      main/coursecopy/copy_course_session.php
  2. 13
      main/coursecopy/copy_course_session_selected.php
  3. 12
      src/Chamilo/CourseBundle/Component/CourseCopy/Course.php
  4. 2
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseArchiver.php
  5. 38
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php
  6. 10
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php
  7. 40
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php
  8. 20
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php

@ -3,6 +3,7 @@
use Chamilo\CourseBundle\Component\CourseCopy\CourseSelectForm;
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
/**
* Copy resources from one course in a session to another one.
@ -14,7 +15,7 @@ use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
$cidReset = true;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_MAINTENANCE;
$current_course_tool = TOOL_COURSE_MAINTENANCE;
api_protect_global_admin_script();
api_protect_limit_for_session_admin();
@ -91,7 +92,6 @@ function display_form()
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM).
'</a>';
$html .= Display::toolbarAction('toolbar-copysession', array(0 => $actionsLeft));
$html .= Display::return_message(get_lang('CopyCourseFromSessionToSessionExplanation'), 'warning');
@ -132,7 +132,6 @@ function display_form()
// Add Security token
$html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">';
$html .= '</div></div>';
$html .= '</form>';
echo $html;
@ -158,8 +157,8 @@ function search_courses($id_session, $type)
}
$return .= '</select>';
$_SESSION['course_list'] = $temp_course_list;
$_SESSION['session_origin'] = $id_session;
$_SESSION['course_list'] = $temp_course_list;
$_SESSION['session_origin'] = $id_session;
// Build select for destination sessions where is not included current session from select origin
if (!empty($id_session)) {

@ -3,6 +3,7 @@
use Chamilo\CourseBundle\Component\CourseCopy\CourseSelectForm;
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
/**
* Copy resources from one course in a session to another one.
@ -46,9 +47,7 @@ if (function_exists('ini_set')) {
$this_section = SECTION_COURSES;
$nameTools = get_lang('CopyCourse');
$returnLink = api_get_path(
WEB_CODE_PATH
) . 'course_info/maintenance_coach.php?' . api_get_cidreq();
$returnLink = api_get_path(WEB_CODE_PATH) . 'course_info/maintenance_coach.php?' . api_get_cidreq();
$interbreadcrumb[] = array(
'url' => $returnLink,
'name' => get_lang('Maintenance')
@ -383,10 +382,12 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
echo '<div style="float:right"><a href="javascript:window.history.go(-1);">' .
Display::return_icon(
'back.png', get_lang('Back') . ' ' . get_lang('To') . ' ' . get_lang(
'back.png',
get_lang('Back').' '.get_lang('To').' '.get_lang(
'PlatformAdmin'
), array('style' => 'vertical-align:middle')
) .
),
array('style' => 'vertical-align:middle')
).
get_lang('Back') . '</a></div>';
} else {
Display::display_error_message(

@ -3,6 +3,8 @@
namespace Chamilo\CourseBundle\Component\CourseCopy;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Resource;
/**
* A course-object to use in Export/Import/Backup/Copy
* @author Bart Mollet <bart.mollet@hogent.be>
@ -37,7 +39,7 @@ class Course
foreach ($this->resources as $type => $resources) {
if (is_array($resources)) {
foreach ($resources as $resource) {
Coursecopy\Resource::setClassType($resource);
Resource::setClassType($resource);
if ($resource->links_to($resource_to_check) ) {
return true;
}
@ -175,12 +177,12 @@ class Course
$description = $resource->content;
break;
case RESOURCE_THEMATIC:
$title = $resource->title;
$description = $resource->content;
$title = $resource->title;
$description = $resource->content;
break;
case RESOURCE_ATTENDANCE:
$title = $resource->params['name'];
$description = $resource->params['description'];
$title = $resource->params['name'];
$description = $resource->params['description'];
break;
case RESOURCE_WORK:
$title = $resource->title;

@ -3,8 +3,6 @@
namespace Chamilo\CourseBundle\Component\CourseCopy;
use Chamilo\CourseBundle\Component\CourseCopy\Course;
/**
* Some functions to write a course-object to a zip-file and to read a course-
* object from such a zip-file.

@ -3,11 +3,38 @@
namespace Chamilo\CourseBundle\Component\CourseCopy;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\GradeBookBackup;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\QuizQuestion;
use Database;
use TestCategory;
use Category;
use CourseManager;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Announcement;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Attendance;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\CalendarEvent;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyLearnpath;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyTestcategory;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseDescription;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseSession;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Document;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\DummyCourseCreator;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Forum;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\ForumCategory;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\ForumPost;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\ForumTopic;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Glossary;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\GradeBookBackup;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Link;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\LinkCategory;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Quiz;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\QuizQuestion;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\QuizQuestionOption;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\ScormDocument;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Survey;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\SurveyInvitation;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\SurveyQuestion;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Thematic;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\ToolIntro;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Wiki;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Work;
/**
* Class CourseBuilder
@ -784,7 +811,7 @@ class CourseBuilder
'title' => get_lang('OrphanQuestions', ''),
'type' => 2
);
$newQuiz = new Quiz((object)$obj);
$newQuiz = new Quiz((object) $obj);
if (!empty($orphanQuestionIds)) {
foreach ($orphanQuestionIds as $index => $orphanId) {
$order = $index + 1;
@ -944,7 +971,8 @@ class CourseBuilder
* Build the Survey Questions
* @param int $courseId Internal course ID
*/
public function build_survey_questions($courseId) {
public function build_survey_questions($courseId)
{
$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_opt = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
@ -1129,7 +1157,7 @@ class CourseBuilder
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
$cd = new \Coursecopy\CourseDescription(
$cd = new CourseDescription(
$obj->id,
$obj->title,
$obj->content,

@ -3,6 +3,9 @@
namespace Chamilo\CourseBundle\Component\CourseCopy;
use Database;
use TestCategory;
/**
* Class to delete items from a Chamilo-course
* @author Bart Mollet <bart.mollet@hogent.be>
@ -44,12 +47,11 @@ class CourseRecycler
return false;
}
$this->type = $type;
$table_tool_intro = Database::get_course_table(TABLE_TOOL_INTRO);
$table_linked_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
$table_item_properties = Database::get_course_table(TABLE_ITEM_PROPERTY);
$this->type = $type;
$this->recycle_links();
$this->recycle_link_categories();
$this->recycle_events();
@ -70,7 +72,7 @@ class CourseRecycler
foreach ($this->course->resources as $type => $resources) {
foreach ($resources as $id => $resource) {
$sql = "DELETE FROM ".$table_linked_resources."
$sql = "DELETE FROM $table_linked_resources
WHERE
c_id = ".$this->course_id." AND
(source_type = '".$type."' AND source_id = '".$id."') OR
@ -201,7 +203,7 @@ class CourseRecycler
$table_thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
$table_thread_qualify_log = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY_LOG);
if ($this->type == 'full_backup') {
if ($this->type === 'full_backup') {
$sql = "DELETE FROM ".$table_category." WHERE c_id = ".$this->course_id;
Database::query($sql);
$sql = "DELETE FROM ".$table_forum." WHERE c_id = ".$this->course_id;

@ -3,6 +3,13 @@
namespace Chamilo\CourseBundle\Component\CourseCopy;
use DocumentManager;
use Database;
use CourseManager;
use stdClass;
use TestCategory;
use SurveyManager;
/**
* Class CourseRestorer
*
@ -492,7 +499,7 @@ class CourseRestorer
'c_id = ? AND path = ?' => [
$this->destination_course_id,
"/".self::DBUTF8escapestring(substr($document->path, 9)),
],
]
]
);
@ -770,7 +777,7 @@ class CourseRestorer
if (file_exists($path.$new_file_name)) {
$file_info = pathinfo($path.$new_file_name);
if (in_array($file_info['extension'], array('html','htm'))) {
$content = file_get_contents($path.$new_file_name);
$content = file_get_contents($path.$new_file_name);
if (UTF8_CONVERT) {
$content = utf8_encode($content);
}
@ -936,7 +943,6 @@ class CourseRestorer
foreach ($resources[RESOURCE_SCORM] as $document) {
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
@mkdir(dirname($path.$document->path), $perm, true);
if (file_exists($path.$document->path)) {
@ -1176,7 +1182,6 @@ class CourseRestorer
);
$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
$topic_replies = -1;
foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
@ -1728,7 +1733,6 @@ class CourseRestorer
$quiz->end_time = null;
}
$params = array(
'c_id' => $this->destination_course_id,
'title' => self::DBUTF8($quiz->title),
@ -2309,7 +2313,11 @@ class CourseRestorer
c_id = ".$this->destination_course_id." AND
code='".self::DBUTF8escapestring($survey_code)."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) return false; else return true;
if (Database::num_rows($result) > 0) {
return false;
} else {
return true;
}
}
/**
@ -2625,7 +2633,7 @@ class CourseRestorer
// Updating prerequisites
foreach ($old_prerequisite as $key=>$my_old_prerequisite) {
if($my_old_prerequisite != ''){
if ($my_old_prerequisite != ''){
$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' ";
Database::query($sql);
@ -2652,7 +2660,7 @@ class CourseRestorer
}
foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
$previous_new_id = 0;
if($previous_item_old_id != 0){
if ($previous_item_old_id != 0){
$previous_new_id = $new_item_ids[$previous_item_old_id];
}
$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
@ -2662,7 +2670,7 @@ class CourseRestorer
foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
$next_new_id = 0;
if($next_item_old_id != 0){
if ($next_item_old_id != 0){
$next_new_id = $new_item_ids[$next_item_old_id];
}
$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
@ -2672,7 +2680,7 @@ class CourseRestorer
foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
$prerequisite_new_id = 0;
if($prerequisite_old_id != 0){
if ($prerequisite_old_id != 0){
$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
}
$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
@ -2692,9 +2700,9 @@ class CourseRestorer
public function restore_student_publication($sessionId = 0)
{
$sessionId = intval($sessionId);
$work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
$item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY);
// Query in student publication
$sql = 'SELECT * FROM '.$work_table.'
@ -2985,9 +2993,9 @@ class CourseRestorer
public function restore_thematic($session_id = 0)
{
if ($this->course->has_resources(RESOURCE_THEMATIC)) {
$table_thematic = Database:: get_course_table(TABLE_THEMATIC);
$table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE);
$table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN);
$table_thematic = Database::get_course_table(TABLE_THEMATIC);
$table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
$resources = $this->course->resources;
foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {

@ -3,6 +3,12 @@
namespace Chamilo\CourseBundle\Component\CourseCopy;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Resource;
use Database;
use \CourseManager;
use Display;
use Chamilo\CourseBundle\Component\CourseCopy\Resources\Document;
/**
* Class to show a form to select resources
* @author Bart Mollet <bart.mollet@hogent.be>
@ -230,7 +236,7 @@ class CourseSelectForm
if ($resource) {
echo '<li>';
// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
Coursecopy\Resource::setClassType($resource);
Resource::setClassType($resource);
echo '<label class="checkbox">';
echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />';
$resource->show();
@ -336,8 +342,8 @@ class CourseSelectForm
}
}
CourseSelectForm :: display_hidden_quiz_questions($course);
CourseSelectForm :: display_hidden_scorm_directories($course);
CourseSelectForm::display_hidden_quiz_questions($course);
CourseSelectForm::display_hidden_scorm_directories($course);
echo '</form>';
echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
}
@ -412,7 +418,7 @@ class CourseSelectForm
/* Searching the documents resource that have been set to null because
$avoid_serialize is true in the display_form() function*/
if ($from == 'copy_course') {
if ($from === 'copy_course') {
if (is_array($resource)) {
$resource = array_keys($resource);
@ -528,9 +534,9 @@ class CourseSelectForm
}
}
}
case RESOURCE_LINKCATEGORY :
case RESOURCE_FORUMCATEGORY :
case RESOURCE_QUIZQUESTION :
case RESOURCE_LINKCATEGORY:
case RESOURCE_FORUMCATEGORY:
case RESOURCE_QUIZQUESTION:
case RESOURCE_DOCUMENT:
// Mark folders to import which are not selected by the user to import,
// but in which a document was selected.

Loading…
Cancel
Save