/**
  * Clone course files
  *
  * @access public
  * @static
  *
  * @param int source id
  * @param int target_id
  */
 public static function _cloneFiles($a_source_id, $a_target_id)
 {
     $source = new ilFSStorageCourse($a_source_id);
     foreach (ilCourseFile::_readFilesByCourse($a_source_id) as $file_obj) {
         $new_file = new ilCourseFile();
         $new_file->setCourseId($a_target_id);
         $new_file->setFileName($file_obj->getFileName());
         $new_file->setFileSize($file_obj->getFileSize());
         $new_file->setFileType($file_obj->getFileType());
         $new_file->create(false);
         $target = new ilFSStorageCourse($a_target_id);
         $target->initInfoDirectory();
         $source->copyFile($file_obj->getAbsolutePath(), $new_file->getAbsolutePath());
     }
 }
 function updateInfoObject()
 {
     global $ilErr, $ilAccess;
     $this->checkPermission('write');
     include_once 'Modules/Course/classes/class.ilCourseFile.php';
     $file_obj = new ilCourseFile();
     $file_obj->setCourseId($this->object->getId());
     $file_obj->setFileName(strlen($_POST['file_name']) ? ilUtil::stripSlashes($_POST['file_name']) : $_FILES['file']['name']);
     $file_obj->setFileSize($_FILES['file']['size']);
     $file_obj->setFileType($_FILES['file']['type']);
     $file_obj->setTemporaryName($_FILES['file']['tmp_name']);
     $file_obj->setErrorCode($_FILES['file']['error']);
     $this->object->setImportantInformation(ilUtil::stripSlashes($_POST['important']));
     $this->object->setSyllabus(ilUtil::stripSlashes($_POST['syllabus']));
     $this->object->setContactName(ilUtil::stripSlashes($_POST['contact_name']));
     $this->object->setContactResponsibility(ilUtil::stripSlashes($_POST['contact_responsibility']));
     $this->object->setContactPhone(ilUtil::stripSlashes($_POST['contact_phone']));
     $this->object->setContactEmail(ilUtil::stripSlashes($_POST['contact_email']));
     $this->object->setContactConsultation(ilUtil::stripSlashes($_POST['contact_consultation']));
     // validate
     $error = false;
     $ilErr->setMessage('');
     $file_obj->validate();
     $this->object->validateInfoSettings();
     if (strlen($ilErr->getMessage())) {
         $error = $ilErr->getMessage();
     }
     // needed for proper advanced MD validation
     $form = $this->initInfoEditor();
     $form->checkInput();
     if (!$this->record_gui->importEditFormPostValues()) {
         $error = true;
     }
     if ($error) {
         if ($error !== true) {
             ilUtil::sendFailure($ilErr->getMessage());
         }
         $this->editInfoObject($form);
         return false;
     }
     $this->object->update();
     $file_obj->create();
     $this->record_gui->writeEditForm();
     // Update ecs content
     include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
     $ecs = new ilECSCourseSettings($this->object);
     $ecs->handleContentUpdate();
     ilUtil::sendSuccess($this->lng->txt("crs_settings_saved"));
     $this->editInfoObject();
     return true;
 }
 function updateInfoObject()
 {
     global $ilErr, $ilAccess;
     $this->checkPermission('write');
     include_once 'Modules/Course/classes/class.ilCourseFile.php';
     $file_obj = new ilCourseFile();
     $file_obj->setCourseId($this->object->getId());
     $file_obj->setFileName(strlen($_POST['file_name']) ? ilUtil::stripSlashes($_POST['file_name']) : $_FILES['file']['name']);
     $file_obj->setFileSize($_FILES['file']['size']);
     $file_obj->setFileType($_FILES['file']['type']);
     $file_obj->setTemporaryName($_FILES['file']['tmp_name']);
     $file_obj->setErrorCode($_FILES['file']['error']);
     $this->object->setImportantInformation(ilUtil::stripSlashes($_POST['important']));
     $this->object->setSyllabus(ilUtil::stripSlashes($_POST['syllabus']));
     $this->object->setContactName(ilUtil::stripSlashes($_POST['contact_name']));
     $this->object->setContactResponsibility(ilUtil::stripSlashes($_POST['contact_responsibility']));
     $this->object->setContactPhone(ilUtil::stripSlashes($_POST['contact_phone']));
     $this->object->setContactEmail(ilUtil::stripSlashes($_POST['contact_email']));
     $this->object->setContactConsultation(ilUtil::stripSlashes($_POST['contact_consultation']));
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php';
     $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR, 'crs', $this->object->getId());
     $record_gui->loadFromPost();
     // Validate
     $ilErr->setMessage('');
     $file_obj->validate();
     $this->object->validateInfoSettings();
     if (strlen($ilErr->getMessage())) {
         ilUtil::sendFailure($ilErr->getMessage());
         $this->editInfoObject();
         return false;
     }
     $this->object->update();
     $file_obj->create();
     $record_gui->saveValues();
     // Update ecs content
     include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
     $ecs = new ilECSCourseSettings($this->object);
     $ecs->handleContentUpdate();
     ilUtil::sendSuccess($this->lng->txt("crs_settings_saved"));
     $this->editInfoObject();
     return true;
 }