コード例 #1
0
 /**
  * clone objective materials
  *
  * @access public
  *
  * @param int source objective
  * @param int target objective
  * @param int copy id
  */
 public function cloneDependencies($a_new_objective, $a_copy_id)
 {
     global $ilObjDataCache, $ilLog;
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     #$ilLog->write(__METHOD__.': 1');
     foreach ($this->getMaterials() as $material) {
         #$ilLog->write(__METHOD__.': 2');
         // Copy action omit ?
         if (!isset($mappings[$material['ref_id']]) or !$mappings[$material['ref_id']]) {
             continue;
         }
         #$ilLog->write(__METHOD__.': 3');
         $material_ref_id = $material['ref_id'];
         $material_rbac_obj_id = $ilObjDataCache->lookupObjId($material_ref_id);
         $material_obj_id = $material['obj_id'];
         $new_ref_id = $mappings[$material_ref_id];
         $new_rbac_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
         #$ilLog->write(__METHOD__.': 4');
         // Link
         if ($new_rbac_obj_id == $material_rbac_obj_id) {
             #$ilLog->write(__METHOD__.': 5');
             $ilLog->write(__METHOD__ . ': Material has been linked. Keeping object id.');
             $new_obj_id = $material_obj_id;
         } elseif ($material['type'] == 'st' or $material['type'] == 'pg') {
             #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($material,TRUE));
             #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($mappings,TRUE));
             #$ilLog->write(__METHOD__.': 6');
             // Chapter assignment
             $new_material_info = isset($mappings[$material_ref_id . '_' . $material_obj_id]) ? $mappings[$material_ref_id . '_' . $material_obj_id] : '';
             $new_material_arr = explode('_', $new_material_info);
             if (!isset($new_material_arr[1]) or !$new_material_arr[1]) {
                 $ilLog->write(__METHOD__ . ': No mapping found for chapter: ' . $material_obj_id);
                 continue;
             }
             $new_obj_id = $new_material_arr[1];
             $ilLog->write(__METHOD__ . ': New material id is: ' . $new_obj_id);
         } else {
             #$ilLog->write(__METHOD__.': 7');
             // Any type
             $new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
         }
         #$ilLog->write(__METHOD__.': 8');
         $new_material = new ilCourseObjectiveMaterials($a_new_objective);
         #$ilLog->write(__METHOD__.': 8.1');
         $new_material->setLMRefId($new_ref_id);
         #$ilLog->write(__METHOD__.': 8.2');
         $new_material->setLMObjId($new_obj_id);
         #$ilLog->write(__METHOD__.': 8.3');
         $new_material->setType($material['type']);
         #$ilLog->write(__METHOD__.': 8.4');
         $new_material->add();
         #$ilLog->write(__METHOD__.': 9');
     }
 }
コード例 #2
0
 public function cloneCollection($a_target_id, $a_copy_id)
 {
     global $ilLog;
     $target_obj_id = ilObject::_lookupObjId($a_target_id);
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     // #12067
     $new_collection = new static($target_obj_id, $this->mode);
     foreach ($this->items as $item) {
         if (!isset($mappings[$item]) or !$mappings[$item]) {
             continue;
         }
         $new_collection->addEntry($mappings[$item]);
     }
     $ilLog->write(__METHOD__ . ': cloned learning progress collection.');
 }
コード例 #3
0
 /**
  * Clone collections
  *
  * @access public
  * @param
  * 
  */
 public function cloneCollections($a_target_id, $a_copy_id)
 {
     global $ilObjDataCache, $ilLog;
     $target_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $new_collections = new ilLPCollections($target_obj_id);
     foreach ($this->items as $item) {
         if (!isset($mappings[$item]) or !$mappings[$item]) {
             continue;
         }
         // @FIXME clone this and not add it
         $new_collections->add($mappings[$item]);
         $ilLog->write(__METHOD__ . ': Added learning progress collection.');
     }
 }
コード例 #4
0
 /**
  * Clone settings
  * @param type $a_copy_id
  * @param type $a_container_id
  * @param type $a_new_container_id
  */
 public static function cloneSettings($a_copy_id, $a_container_id, $a_new_container_id)
 {
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $options = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $options->getMappings();
     $settings = self::getInstanceByObjId($a_container_id);
     $new_settings = self::getInstanceByObjId($a_new_container_id);
     $new_settings->setType($settings->getType());
     $new_settings->setGeneralQualifiedTestVisibility($settings->isGeneralQualifiedTestVisible());
     $new_settings->setQualifiedTestPerObjectiveVisibility($settings->isQualifiedTestPerObjectiveVisible());
     $new_settings->resetResults($settings->isResetResultsEnabled());
     if ($settings->getInitialTest() and array_key_exists($settings->getInitialTest(), $mappings)) {
         $new_settings->setInitialTest($mappings[$settings->getInitialTest()]);
     }
     if ($settings->getQualifiedTest() and array_key_exists($settings->getQualifiedTest(), $mappings)) {
         $new_settings->setQualifiedTest($mappings[$settings->getQualifiedTest()]);
     }
     $new_settings->create();
 }
コード例 #5
0
 /**
  * removes all question set config related data for cloned/copied test
  *
  * @param ilObjTest $cloneTestOBJ
  */
 public function cloneQuestionSetRelatedData($cloneTestOBJ)
 {
     global $ilLog;
     require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
     $cwo = ilCopyWizardOptions::_getInstance($cloneTestOBJ->getId());
     foreach ($this->questions as $key => $question_id) {
         $question = assQuestion::_instanciateQuestion($question_id);
         $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
         $original_id = assQuestion::_getOriginalId($question_id);
         $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
         $question->saveToDb($original_id);
         // Save the mapping of old question id <-> new question id
         // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
         $originalKey = $this->testOBJ->getRefId() . '_' . $question_id;
         $mappedKey = $cloneTestOBJ->getRefId() . '_' . $cloneTestOBJ->questions[$key];
         $cwo->appendMapping($originalKey, $mappedKey);
         $ilLog->write(__METHOD__ . ": Added mapping {$originalKey} <-> {$mappedKey}");
     }
 }
コード例 #6
0
 /**
  * clone objective questions
  *
  * @access public
  *
  * @param int source objective
  * @param int target objective
  * @param int copy id
  */
 public function cloneDependencies($a_new_objective, $a_copy_id)
 {
     global $ilObjDataCache, $ilLog, $ilDB;
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     foreach ($this->getQuestions() as $question) {
         if (!isset($mappings["{$question['ref_id']}"]) or !$mappings["{$question['ref_id']}"]) {
             continue;
         }
         $question_ref_id = $question['ref_id'];
         $question_obj_id = $question['obj_id'];
         $question_qst_id = $question['question_id'];
         $new_ref_id = $mappings[$question_ref_id];
         $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
         if ($new_obj_id == $question_obj_id) {
             $ilLog->write(__METHOD__ . ': Test has been linked. Keeping question id.');
             // Object has been linked
             $new_question_id = $question_qst_id;
         } else {
             $new_question_info = $mappings[$question_ref_id . '_' . $question_qst_id];
             $new_question_arr = explode('_', $new_question_info);
             if (!isset($new_question_arr[1]) or !$new_question_arr[1]) {
                 continue;
             }
             $new_question_id = $new_question_arr[1];
             $ilLog->write(__METHOD__ . ': New question id is: ' . $new_question_id);
         }
         $new_question = new ilCourseObjectiveQuestion($a_new_objective);
         $new_question->setTestRefId($new_ref_id);
         $new_question->setTestObjId($new_obj_id);
         $new_question->setQuestionId($new_question_id);
         $new_question->add();
     }
     // Copy tests
     foreach ($this->getTests() as $test) {
         $new_test_id = $mappings["{$test['ref_id']}"];
         $query = "UPDATE crs_objective_tst " . "SET tst_status = " . $this->db->quote($test['tst_status'], 'integer') . ", " . "tst_limit_p = " . $this->db->quote($test['tst_limit'], 'integer') . " " . "WHERE objective_id = " . $this->db->quote($a_new_objective, 'integer') . " " . "AND ref_id = " . $this->db->quote($new_test_id, 'integer');
         $res = $ilDB->manipulate($query);
     }
 }
コード例 #7
0
 /**
  * Clone dependencies
  *
  * @access public
  * @param int target id
  * @param int copy id
  * 
  */
 public function cloneDependencies($a_target_id, $a_copy_id)
 {
     global $ilObjDataCache, $ilLog;
     $ilLog->write(__METHOD__ . ': Begin course start objects...');
     $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
     $start = new ilCourseStart($a_target_id, $new_obj_id);
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     foreach ($this->getStartObjects() as $start_id => $data) {
         $item_ref_id = $data['item_ref_id'];
         if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
             $ilLog->write(__METHOD__ . ': Clone start object nr. ' . $item_ref_id);
             $start->add($mappings[$item_ref_id]);
         } else {
             $ilLog->write(__METHOD__ . ': No mapping found for start object nr. ' . $item_ref_id);
         }
     }
     $ilLog->write(__METHOD__ . ': ... end course start objects');
     return true;
 }
コード例 #8
0
 /**
  * Fix container item group references after a container has been cloned
  *
  * @param
  * @return
  */
 static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
 {
     global $ilLog;
     $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType());
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $new_container_ref_id = $mappings[$a_source_container->getRefId()];
     $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-');
     $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id);
     include_once "./Services/COPage/classes/class.ilPageObject.php";
     include_once "./Services/Container/classes/class.ilContainerPage.php";
     $ilLog->write(__METHOD__ . ': 3' . $new_container_obj_id . '-');
     if (ilPageObject::_exists("cont", $new_container_obj_id)) {
         $ilLog->write(__METHOD__ . ': 4');
         $new_page = new ilContainerPage($new_container_obj_id);
         $new_page->buildDom();
         include_once "./Services/COPage/classes/class.ilPCResources.php";
         ilPCResources::modifyItemGroupRefIdsByMapping($new_page, $mappings);
         $new_page->update();
     }
     $ilLog->write(__METHOD__ . ': 5');
 }
コード例 #9
0
 /**
  * Clone DCL
  *
  * @param ilObjDataCollection new object
  * @param int                 target ref_id
  * @param int                 copy id
  *
  * @return ilObjPoll
  */
 public function doCloneObject(ilObjDataCollection $new_obj, $a_target_id, $a_copy_id = 0)
 {
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $new_obj->setOnline($this->getOnline());
     }
     $new_obj->cloneStructure($this->getRefId());
     return $new_obj;
 }
コード例 #10
0
 /**
  * Clone glossary
  *
  * @param int target ref_id
  * @param int copy id
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser, $ilias;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($new_obj);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $new_obj->setOnline($this->getOnline());
     }
     //		$new_obj->setTitle($this->getTitle());
     $new_obj->setDescription($this->getDescription());
     $new_obj->setVirtualMode($this->getVirtualMode());
     $new_obj->setPresentationMode($this->getPresentationMode());
     $new_obj->setSnippetLength($this->getSnippetLength());
     $new_obj->update();
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $new_obj->setStyleSheetId($new_id);
         $new_obj->update();
     }
     // copy taxonomy
     if (($tax_id = $this->getTaxonomyId()) > 0) {
         // clone it
         include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php";
         $tax = new ilObjTaxonomy($tax_id);
         $new_tax = $tax->cloneObject(0, 0, true);
         $map = $tax->getNodeMapping();
         // assign new taxonomy to new glossary
         ilObjTaxonomy::saveUsage($new_tax->getId(), $new_obj->getId());
     }
     // assign new tax/new glossary
     // handle mapping
     // prepare tax node assignments objects
     include_once "./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php";
     if ($tax_id > 0) {
         $tax_ass = new ilTaxNodeAssignment("glo", $this->getId(), "term", $tax_id);
         $new_tax_ass = new ilTaxNodeAssignment("glo", $new_obj->getId(), "term", $new_tax->getId());
     }
     // copy terms
     foreach (ilGlossaryTerm::getTermList($this->getId()) as $term) {
         $new_term_id = ilGlossaryTerm::_copyTerm($term["id"], $new_obj->getId());
         // copy tax node assignments
         if ($tax_id > 0) {
             $assignmts = $tax_ass->getAssignmentsOfItem($term["id"]);
             foreach ($assignmts as $a) {
                 if ($map[$a["node_id"]] > 0) {
                     $new_tax_ass->addAssignment($map[$a["node_id"]], $new_term_id);
                 }
             }
         }
     }
     return $new_obj;
 }
コード例 #11
0
 public function cloneDependencies($a_target_id, $a_copy_id)
 {
     parent::cloneDependencies($a_target_id, $a_copy_id);
     // clone taxonomies
     include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php";
     $all_tax = ilObjTaxonomy::getUsageOfObject($this->getId());
     if (sizeof($all_tax)) {
         include_once "./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php";
         $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
         $mappings = $cwo->getMappings();
         foreach ($all_tax as $old_tax_id) {
             if ($old_tax_id) {
                 // clone it
                 $old_tax = new ilObjTaxonomy($old_tax_id);
                 $new_tax = $old_tax->cloneObject(0, 0, true);
                 $tax_map = $old_tax->getNodeMapping();
                 // assign new taxonomy to new category
                 ilObjTaxonomy::saveUsage($new_tax->getId(), ilObject::_lookupObjId($a_target_id));
                 // clone assignments (for all sub-items)
                 foreach ($mappings as $old_ref_id => $new_ref_id) {
                     if ($old_ref_id != $new_ref_id) {
                         $old_obj_id = ilObject::_lookupObjId($old_ref_id);
                         $new_obj_id = ilObject::_lookupObjId($new_ref_id);
                         $obj_type = ilObject::_lookupType($old_obj_id);
                         $tax_ass = new ilTaxNodeAssignment($obj_type, $old_obj_id, "obj", $old_tax_id);
                         $assignmts = $tax_ass->getAssignmentsOfItem($old_obj_id);
                         if (sizeof($assignmts)) {
                             $new_tax_ass = new ilTaxNodeAssignment($obj_type, $new_obj_id, "obj", $new_tax->getId());
                             foreach ($assignmts as $a) {
                                 if ($tax_map[$a["node_id"]]) {
                                     $new_tax_ass->addAssignment($tax_map[$a["node_id"]], $new_obj_id);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #12
0
ファイル: class.ilObject.php プロジェクト: arlendotcn/ilias
 /**
  * Clone object dependencies
  *
  * This method allows to refresh any ref id references to other objects
  * that are affected in the same copy process. Ask ilCopyWizardOptions for
  * the mappings.
  *
  * @access public
  * @param int ref_id of target object
  * @param int copy_id
  * 
  */
 public function cloneDependencies($a_target_id, $a_copy_id)
 {
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $conditions = ilConditionHandler::_getConditionsOfTarget($this->getRefId(), $this->getId());
     foreach ($conditions as $con) {
         if ($mappings[$con['trigger_ref_id']]) {
             $newCondition = new ilConditionHandler();
             $target_obj = ilObject::_lookupObjId($a_target_id);
             $target_typ = ilObject::_lookupType($target_obj);
             $newCondition->setTargetRefId($a_target_id);
             $newCondition->setTargetObjId($target_obj);
             $newCondition->setTargetType($target_typ);
             $trigger_ref = $mappings[$con['trigger_ref_id']];
             $trigger_obj = ilObject::_lookupObjId($trigger_ref);
             $trigger_typ = ilObject::_lookupType($trigger_obj);
             $newCondition->setTriggerRefId($trigger_ref);
             $newCondition->setTriggerObjId($trigger_obj);
             $newCondition->setTriggerType($trigger_typ);
             $newCondition->setOperator($con['operator']);
             $newCondition->setValue($con['value']);
             $newCondition->setReferenceHandlingType($con['ref_handling']);
             $newCondition->setObligatory($con['obligatory']);
             $newCondition->setHiddenStatus(ilConditionHandler::lookupHiddenStatusByTarget($this->getRefId()));
             $newCondition->storeCondition();
         }
     }
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
     $tpl_id = ilDidacticTemplateObjSettings::lookupTemplateId($this->getRefId());
     if ($tpl_id) {
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         $factory = new ilObjectFactory();
         $obj = $factory->getInstanceByRefId($a_target_id, FALSE);
         if ($obj instanceof ilObject) {
             $obj->applyDidacticTemplate($tpl_id);
         }
     }
     return true;
 }
コード例 #13
0
 /**
  * Clone single (not container object)
  * Method is overwritten in ilContainerGUI
  *
  * @access public
  */
 public function cloneAllObject()
 {
     include_once './Services/Link/classes/class.ilLink.php';
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     global $ilErr, $ilUser;
     $new_type = $_REQUEST['new_type'];
     if (!$this->checkPermissionBool("create", "", $new_type)) {
         $ilErr->raiseError($this->lng->txt('permission_denied'));
     }
     if (!(int) $_REQUEST['clone_source']) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         $this->createObject();
         return false;
     }
     if (!$this->checkPermissionBool("write", "", $new_type, (int) $_REQUEST['clone_source'])) {
         $ilErr->raiseError($this->lng->txt('permission_denied'));
     }
     // Save wizard options
     $copy_id = ilCopyWizardOptions::_allocateCopyId();
     $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
     $wizard_options->saveOwner($ilUser->getId());
     $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
     $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
     foreach ($options as $source_id => $option) {
         $wizard_options->addEntry($source_id, $option);
     }
     $wizard_options->read();
     $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
     $new_obj = $orig->cloneObject((int) $_GET['ref_id'], $copy_id);
     // Delete wizard options
     $wizard_options->deleteAll();
     ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
     ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
 }
コード例 #14
0
 /**
  * copy object in repository
  * $sid	session id
  * $settings_xml contains copy wizard settings following ilias_copy_wizard_settings.dtd
  */
 function copyObject($sid, $copy_settings_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     include_once './webservice/soap/classes/class.ilSoapUtils.php';
     global $rbacreview, $objDefinition, $rbacsystem, $lng, $ilUser;
     include_once './webservice/soap/classes/class.ilCopyWizardSettingsXMLParser.php';
     $xml_parser = new ilCopyWizardSettingsXMLParser($copy_settings_xml);
     try {
         $xml_parser->startParsing();
     } catch (ilSaxParserException $se) {
         return $this->__raiseError($se->getMessage(), "Client");
     }
     // checking copy permissions, objects and create permissions
     if (!$rbacsystem->checkAccess('copy', $xml_parser->getSourceId())) {
         return $this->__raiseError("Missing copy permissions for object with reference id " . $xml_parser->getSourceId(), 'Client');
     }
     // checking copy permissions, objects and create permissions
     $source_id = $xml_parser->getSourceId();
     $target_id = $xml_parser->getTargetId();
     // does source object exist
     if (!($source_object_type = ilObjectFactory::getTypeByRefId($source_id, false))) {
         return $this->__raiseError('No valid source given.', 'Client');
     }
     // does target object exist
     if (!($target_object_type = ilObjectFactory::getTypeByRefId($xml_parser->getTargetId(), false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
     if ($this->isFault($canAddType)) {
         return $canAddType;
     }
     // if is container object than clone with sub items
     $options = $xml_parser->getOptions();
     //		print_r($options);
     $source_object = ilObjectFactory::getInstanceByRefId($source_id);
     if ($source_object instanceof ilContainer) {
         // get client id from sid
         $clientid = substr($sid, strpos($sid, "::") + 2);
         $sessionid = str_replace("::" . $clientid, "", $sid);
         // call container clone
         return $source_object->cloneAllObject($sessionid, $clientid, $source_object_type, $target_id, $source_id, $options, true);
     } else {
         // create copy wizard settings
         $copy_id = ilCopyWizardOptions::_allocateCopyId();
         $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
         $wizard_options->saveOwner($ilUser->getId());
         $wizard_options->saveRoot($source_id);
         foreach ($options as $source_id => $option) {
             $wizard_options->addEntry($source_id, $option);
         }
         $wizard_options->read();
         // call object clone
         $newObject = $source_object->cloneObject($xml_parser->getTargetId(), $copy_id);
         return is_object($newObject) ? $newObject->getRefId() : -1;
     }
 }
コード例 #15
0
 /**
  * clone sorting 
  *
  * @return
  * @static
  */
 public function cloneSorting($a_target_id, $a_copy_id)
 {
     global $ilDB;
     global $ilLog;
     $ilLog->write(__METHOD__ . ': Cloning container sorting.');
     $target_obj_id = ilObject::_lookupObjId($a_target_id);
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $mappings = ilCopyWizardOptions::_getInstance($a_copy_id)->getMappings();
     $query = "SELECT * FROM container_sorting " . "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!isset($mappings[$row->child_id]) or !$mappings[$row->child_id]) {
             #$ilLog->write(__METHOD__.': No mapping found for:'.$row->child_id);
             continue;
         }
         if ($row->parent_id and (!isset($mappings[$row->parent_id]) or !$mappings[$row->parent_id])) {
             continue;
         }
         $query = "DELETE FROM container_sorting " . "WHERE obj_id = " . $ilDB->quote($target_obj_id, 'integer') . " " . "AND child_id = " . $ilDB->quote($mappings[$row->child_id], 'integer') . " " . "AND parent_type = " . $ilDB->quote($row->parent_type, 'text') . ' ' . "AND parent_id = " . $ilDB->quote((int) $mappings[$row->parent_id], 'integer');
         $ilDB->manipulate($query);
         // Add new value
         $query = "INSERT INTO container_sorting (obj_id,child_id,position,parent_type,parent_id) " . "VALUES( " . $ilDB->quote($target_obj_id, 'integer') . ", " . $ilDB->quote($mappings[$row->child_id], 'integer') . ", " . $ilDB->quote($row->position, 'integer') . ", " . $ilDB->quote($row->parent_type, 'text') . ", " . $ilDB->quote((int) $mappings[$row->parent_id], 'integer') . ")";
         $ilDB->manipulate($query);
     }
     return true;
 }
コード例 #16
0
 /**
  * Clone dependencies 
  *
  * @param int $a_ref_id
  * @param int $a_target_id
  * @param int $a_copy_id
  */
 public static function cloneDependencies($a_ref_id, $a_target_id, $a_copy_id)
 {
     global $ilLog;
     $ilLog->write(__METHOD__ . ': Begin course items...');
     $items = self::getItems($a_ref_id);
     if (!$items) {
         $ilLog->write(__METHOD__ . ': No course items found.');
         return true;
     }
     // new course item object
     if (!is_object($new_container = ilObjectFactory::getInstanceByRefId($a_target_id, false))) {
         $ilLog->write(__METHOD__ . ': Cannot create target object.');
         return false;
     }
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cp_options->getMappings();
     foreach ($items as $item) {
         if (!isset($mappings[$item['parent_id']]) or !$mappings[$item['parent_id']]) {
             $ilLog->write(__METHOD__ . ': No mapping for parent nr. ' . $item['parent_id']);
             continue;
         }
         if (!isset($mappings[$item['obj_id']]) or !$mappings[$item['obj_id']]) {
             $ilLog->write(__METHOD__ . ': No mapping for item nr. ' . $item['obj_id']);
             continue;
         }
         $new_item_id = $mappings[$item['obj_id']];
         $new_parent = $mappings[$item['parent_id']];
         $new_item = new self();
         $new_item->setTimingType($item['timing_type']);
         $new_item->setTimingStart($item['timing_start']);
         $new_item->setTimingEnd($item['timing_end']);
         $new_item->setSuggestionStart($item['suggestion_start']);
         $new_item->setSuggestionEnd($item['suggestion_end']);
         $new_item->toggleChangeable($item['changeable']);
         $new_item->setEarliestStart($item['earliest_start']);
         $new_item->setLatestEnd($item['latest_end']);
         $new_item->toggleVisible($item['visible']);
         $new_item->update($new_item_id, $new_parent);
         $ilLog->write(__METHOD__ . ': Added new entry for item nr. ' . $item['obj_id']);
     }
     $ilLog->write(__METHOD__ . ': Finished course items.');
 }
コード例 #17
0
 /**
  * Clone object dependencies
  *
  * This method allows to refresh any ref id references to other objects
  * that are affected in the same copy process. Ask ilCopyWizardOptions for
  * the mappings.
  *
  * @access public
  * @param int ref_id of target object
  * @param int copy_id
  * 
  */
 public function cloneDependencies($a_target_id, $a_copy_id)
 {
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $conditions = ilConditionHandler::_getConditionsOfTarget($this->getRefId(), $this->getId());
     foreach ($conditions as $con) {
         if ($mappings[$con['trigger_ref_id']]) {
             $newCondition = new ilConditionHandler();
             $target_obj = ilObject::_lookupObjId($a_target_id);
             $target_typ = ilObject::_lookupType($target_obj);
             $newCondition->setTargetRefId($a_target_id);
             $newCondition->setTargetObjId($target_obj);
             $newCondition->setTargetType($target_typ);
             $trigger_ref = $mappings[$con['trigger_ref_id']];
             $trigger_obj = ilObject::_lookupObjId($trigger_ref);
             $trigger_typ = ilObject::_lookupType($trigger_obj);
             $newCondition->setTriggerRefId($trigger_ref);
             $newCondition->setTriggerObjId($trigger_obj);
             $newCondition->setTriggerType($trigger_typ);
             $newCondition->setOperator($con['operator']);
             $newCondition->setValue($con['value']);
             $newCondition->setReferenceHandlingType($con['ref_handling']);
             $newCondition->setObligatory($con['obligatory']);
             $newCondition->storeCondition();
         }
     }
     return true;
 }
コード例 #18
0
 /**
  * Clone items
  *
  * @access public
  *
  * @param int source event id
  * @param int copy id
  */
 public function cloneItems($a_source_id, $a_copy_id)
 {
     global $ilObjDataCache, $ilLog;
     $ilLog->write(__METHOD__ . ': Begin cloning item group materials ... -' . $a_source_id . '-');
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $new_items = array();
     // check: is this a ref id!?
     $source_ig = new ilItemGroupItems($a_source_id);
     foreach ($source_ig->getItems() as $item_ref_id) {
         if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
             $ilLog->write(__METHOD__ . ': Clone item group item nr. ' . $item_ref_id);
             $new_items[] = $mappings[$item_ref_id];
         } else {
             $ilLog->write(__METHOD__ . ': No mapping found for item group item nr. ' . $item_ref_id);
         }
     }
     $this->setItems($new_items);
     $this->update();
     $ilLog->write(__METHOD__ . ': Finished cloning item group items ...');
     return true;
 }
コード例 #19
0
 /**
  * Clone HTML learning module
  *
  * @param int target ref_id
  * @param int copy id
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser, $ilias;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($new_obj);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $new_obj->setOnline($this->getOnline());
     }
     $new_obj->setTitle($this->getTitle());
     $new_obj->setDescription($this->getDescription());
     $new_obj->setShowLicense($this->getShowLicense());
     $new_obj->setShowBibliographicalData($this->getShowBibliographicalData());
     // copy content
     $new_obj->populateByDirectoy($this->getDataDirectory());
     $new_obj->setStartFile($this->getStartFile());
     $new_obj->update();
     return $new_obj;
 }
コード例 #20
0
 /**
  * Clone object
  *
  * @access public
  * @param int ref id of parent container
  * @param int copy id
  * @return object new test object
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilLog;
     $this->loadFromDb();
     // Copy settings
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($newObj);
     $newObj->setAnonymity($this->getAnonymity());
     $newObj->setAnswerFeedback($this->getAnswerFeedback());
     $newObj->setAnswerFeedbackPoints($this->getAnswerFeedbackPoints());
     $newObj->setAuthor($this->getAuthor());
     $newObj->setCountSystem($this->getCountSystem());
     $newObj->setECTSFX($this->getECTSFX());
     $newObj->setECTSGrades($this->getECTSGrades());
     $newObj->setECTSOutput($this->getECTSOutput());
     $newObj->setEnableProcessingTime($this->getEnableProcessingTime());
     $newObj->setEndingTime($this->getEndingTime());
     $newObj->setFixedParticipants($this->getFixedParticipants());
     $newObj->setInstantFeedbackSolution($this->getInstantFeedbackSolution());
     $newObj->setIntroduction($this->getIntroduction());
     $newObj->setFinalStatement($this->getFinalStatement());
     $newObj->setShowInfo($this->getShowInfo());
     $newObj->setForceJS($this->getForceJS());
     $newObj->setCustomStyle($this->getCustomStyle());
     $newObj->setKiosk($this->getKiosk());
     $newObj->setShowFinalStatement($this->getShowFinalStatement());
     $newObj->setListOfQuestionsSettings($this->getListOfQuestionsSettings());
     $newObj->setMCScoring($this->getMCScoring());
     $newObj->setMailNotification($this->getMailNotification());
     $newObj->setMailNotificationType($this->getMailNotificationType());
     $newObj->setNrOfTries($this->getNrOfTries());
     $newObj->setPassScoring($this->getPassScoring());
     $newObj->setPassword($this->getPassword());
     $newObj->setProcessingTime($this->getProcessingTime());
     $newObj->setRandomQuestionCount($this->getRandomQuestionCount());
     $newObj->setRandomTest($this->isRandomTest());
     $newObj->setReportingDate($this->getReportingDate());
     $newObj->setResetProcessingTime($this->getResetProcessingTime());
     $newObj->setResultsPresentation($this->getResultsPresentation());
     $newObj->setScoreCutting($this->getScoreCutting());
     $newObj->setScoreReporting($this->getScoreReporting());
     $newObj->setSequenceSettings($this->getSequenceSettings());
     $newObj->setShowCancel($this->getShowCancel());
     $newObj->setShowMarker($this->getShowMarker());
     $newObj->setShuffleQuestions($this->getShuffleQuestions());
     $newObj->setStartingTime($this->getStartingTime());
     $newObj->setTitleOutput($this->getTitleOutput());
     $newObj->setUsePreviousAnswers($this->getUsePreviousAnswers());
     $newObj->setCertificateVisibility($this->getCertificateVisibility());
     $newObj->mark_schema = clone $this->mark_schema;
     $newObj->setEnabledViewMode($this->getEnabledViewMode());
     $newObj->setTemplate($this->getTemplate());
     $newObj->setPoolUsage($this->getPoolUsage());
     $newObj->setPrintBestSolutionWithResult($this->isBestSolutionPrintedWithResult());
     $newObj->saveToDb();
     // clone certificate
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $cert = new ilCertificate(new ilTestCertificateAdapter($this));
     $newcert = new ilCertificate(new ilTestCertificateAdapter($newObj));
     $cert->cloneCertificate($newcert);
     if ($this->isRandomTest()) {
         $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
         $this->cloneRandomQuestions($newObj->getTestId());
     } else {
         include_once "./Services/CopyWizard/classes/class.ilCopyWizardOptions.php";
         $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
         // clone the questions
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         foreach ($this->questions as $key => $question_id) {
             $question = ilObjTest::_instanciateQuestion($question_id);
             $newObj->questions[$key] = $question->duplicate(true, null, null, null, $newObj->getId());
             $original_id = assQuestion::_getOriginalId($question_id);
             $question = ilObjTest::_instanciateQuestion($newObj->questions[$key]);
             $question->saveToDb($original_id);
             // Save the mapping of old question id <-> new question id
             // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
             $cwo->appendMapping($this->getRefId() . '_' . $question_id, $newObj->getRefId() . '_' . $newObj->questions[$key]);
             $ilLog->write(__METHOD__ . ': Added mapping ' . $this->getRefId() . '_' . $question_id . ' <-> ' . $newObj->getRefId() . '_' . $newObj->questions[$key]);
         }
     }
     $newObj->saveToDb();
     return $newObj;
 }
コード例 #21
0
 public function cloneCollection($a_target_id, $a_copy_id)
 {
     parent::cloneCollection($a_target_id, $a_copy_id);
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $target_obj_id = ilObject::_lookupObjId($a_target_id);
     $target_collection = new static($target_obj_id, $this->mode);
     // clone (active) groupings
     foreach ($this->getGroupedItemsForLPStatus() as $group) {
         $target_item_ids = array();
         foreach ($group["items"] as $item) {
             if (!isset($mappings[$item]) or !$mappings[$item]) {
                 continue;
             }
             $target_item_ids[] = $mappings[$item];
         }
         // single item left after copy?
         if (sizeof($target_item_ids) > 1) {
             // should not be larger than group
             $num_obligatory = min(sizeof($target_item_ids), $group["num_obligatory"]);
             $target_collection->createNewGrouping($target_item_ids, $num_obligatory);
         }
     }
 }
コード例 #22
0
 /**
  * Copy all pages and chapters
  *
  * @param object $a_target_obj target learning module
  */
 function copyAllPagesAndChapters($a_target_obj, $a_copy_id = 0)
 {
     $parent_id = $a_target_obj->lm_tree->readRootId();
     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     // get all chapters of root lm
     $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st");
     $copied_nodes = array();
     //$time = time();
     foreach ($chapters as $chap) {
         $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id, IL_LAST_NODE, $time, $copied_nodes, true, $this);
         $target = $cid;
     }
     // copy free pages
     $pages = ilLMPageObject::getPageList($this->getId());
     foreach ($pages as $p) {
         if (!$this->lm_tree->isInTree($p["obj_id"])) {
             $item = new ilLMPageObject($this, $p["obj_id"]);
             $target_item = $item->copy($a_target_obj);
             $copied_nodes[$item->getId()] = $target_item->getId();
         }
     }
     // Add mapping for pages and chapters
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $options = ilCopyWizardOptions::_getInstance($a_copy_id);
     foreach ($copied_nodes as $old_id => $new_id) {
         $options->appendMapping($this->getRefId() . '_' . $old_id, $a_target_obj->getRefId() . '_' . $new_id);
     }
     ilLMObject::updateInternalLinks($copied_nodes);
     $a_target_obj->checkTree();
 }
コード例 #23
0
 /**
  * Clone object
  *
  * @access public
  * @param int ref id of parent container
  * @param int copy id
  * @return object new test object
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog, $tree, $ilDB, $ilPluginAdmin;
     $this->loadFromDb();
     // Copy settings
     /** @var $newObj ilObjTest */
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($newObj);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->isOnline());
     }
     $newObj->setAnonymity($this->getAnonymity());
     $newObj->setAnswerFeedback($this->getAnswerFeedback());
     $newObj->setAnswerFeedbackPoints($this->getAnswerFeedbackPoints());
     $newObj->setAuthor($this->getAuthor());
     $newObj->setLimitUsersEnabled($this->isLimitUsersEnabled());
     $newObj->setAllowedUsers($this->getAllowedUsers());
     $newObj->setAllowedUsersTimeGap($this->getAllowedUsersTimeGap());
     $newObj->setCountSystem($this->getCountSystem());
     $newObj->setECTSFX($this->getECTSFX());
     $newObj->setECTSGrades($this->getECTSGrades());
     $newObj->setECTSOutput($this->getECTSOutput());
     $newObj->setEnableProcessingTime($this->getEnableProcessingTime());
     $newObj->setEndingTimeEnabled($this->isEndingTimeEnabled());
     $newObj->setEndingTime($this->getEndingTime());
     $newObj->setFixedParticipants($this->getFixedParticipants());
     $newObj->setInstantFeedbackSolution($this->getInstantFeedbackSolution());
     $newObj->setIntroductionEnabled($this->isIntroductionEnabled());
     $newObj->setIntroduction($this->getIntroduction());
     $newObj->setFinalStatement($this->getFinalStatement());
     $newObj->setShowInfo($this->getShowInfo());
     $newObj->setForceJS($this->getForceJS());
     $newObj->setCustomStyle($this->getCustomStyle());
     $newObj->setKiosk($this->getKiosk());
     $newObj->setShowFinalStatement($this->getShowFinalStatement());
     $newObj->setListOfQuestionsSettings($this->getListOfQuestionsSettings());
     $newObj->setMCScoring($this->getMCScoring());
     $newObj->setMailNotification($this->getMailNotification());
     $newObj->setMailNotificationType($this->getMailNotificationType());
     $newObj->setNrOfTries($this->getNrOfTries());
     $newObj->setPassScoring($this->getPassScoring());
     $newObj->setPasswordEnabled($this->isPasswordEnabled());
     $newObj->setPassword($this->getPassword());
     $newObj->setProcessingTime($this->getProcessingTime());
     $newObj->setQuestionSetType($this->getQuestionSetType());
     $newObj->setReportingDate($this->getReportingDate());
     $newObj->setResetProcessingTime($this->getResetProcessingTime());
     $newObj->setResultsPresentation($this->getResultsPresentation());
     $newObj->setScoreCutting($this->getScoreCutting());
     $newObj->setScoreReporting($this->getScoreReporting());
     $newObj->setSequenceSettings($this->getSequenceSettings());
     $newObj->setShowCancel($this->getShowCancel());
     $newObj->setShowMarker($this->getShowMarker());
     $newObj->setShuffleQuestions($this->getShuffleQuestions());
     $newObj->setStartingTimeEnabled($this->isStartingTimeEnabled());
     $newObj->setStartingTime($this->getStartingTime());
     $newObj->setTitleOutput($this->getTitleOutput());
     $newObj->setUsePreviousAnswers($this->getUsePreviousAnswers());
     $newObj->setRedirectionMode($this->getRedirectionMode());
     $newObj->setRedirectionUrl($this->getRedirectionUrl());
     $newObj->setCertificateVisibility($this->getCertificateVisibility());
     $newObj->mark_schema = clone $this->mark_schema;
     $newObj->setEnabledViewMode($this->getEnabledViewMode());
     $newObj->setTemplate($this->getTemplate());
     $newObj->setPoolUsage($this->getPoolUsage());
     $newObj->setPrintBestSolutionWithResult($this->isBestSolutionPrintedWithResult());
     $newObj->setShowExamIdInTestPassEnabled($this->isShowExamIdInTestPassEnabled());
     $newObj->setShowExamIdInTestResultsEnabled($this->isShowExamIdInTestResultsEnabled());
     $newObj->setEnableExamView($this->getEnableExamview());
     $newObj->setShowExamViewHtml($this->getShowExamviewHtml());
     $newObj->setShowExamViewPdf($this->getShowExamviewPdf());
     $newObj->setEnableArchiving($this->getEnableArchiving());
     $newObj->setSignSubmission($this->getSignSubmission());
     $newObj->setCharSelectorAvailability((int) $this->getCharSelectorAvailability());
     $newObj->setCharSelectorDefinition($this->getCharSelectorDefinition());
     $newObj->setSkillServiceEnabled($this->isSkillServiceEnabled());
     $newObj->setResultFilterTaxIds($this->getResultFilterTaxIds());
     $newObj->setInstantFeedbackAnswerFixationEnabled($this->isInstantFeedbackAnswerFixationEnabled());
     $newObj->saveToDb();
     // clone certificate
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $cert = new ilCertificate(new ilTestCertificateAdapter($this));
     $newcert = new ilCertificate(new ilTestCertificateAdapter($newObj));
     $cert->cloneCertificate($newcert);
     require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
     $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this);
     $testQuestionSetConfigFactory->getQuestionSetConfig()->cloneQuestionSetRelatedData($newObj);
     $newObj->saveToDb();
     $newObj->updateMetaData();
     // #14467
     return $newObj;
 }
コード例 #24
0
ファイル: class.ilObjPoll.php プロジェクト: arlendotcn/ilias
 /**
  * Clone poll
  *
  * @param ilObjPoll new object
  * @param int target ref_id
  * @param int copy id
  * @return ilObjPoll
  */
 public function doCloneObject(ilObjPoll $new_obj, $a_target_id, $a_copy_id = 0)
 {
     // question/image
     $new_obj->setQuestion($this->getQuestion());
     $image = $this->getImageFullPath();
     if ($image) {
         $image = array("tmp_name" => $image, "name" => $this->getImage());
         $new_obj->uploadImage($image, true);
     }
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $new_obj->setOnline($this->isOnline());
     }
     $new_obj->setViewResults($this->getViewResults());
     $new_obj->setShowComments($this->getShowComments());
     $new_obj->setShowResultsAs($this->getShowResultsAs());
     $new_obj->update();
     // answers
     $answers = $this->getAnswers();
     if ($answers) {
         foreach ($answers as $item) {
             $new_obj->saveAnswer($item["answer"]);
         }
     }
     return $new_obj;
 }
コード例 #25
0
 /**
  * Move node: target has been selected, execute
  */
 function performPasteIntoMultipleObjects()
 {
     global $objDefinition, $ilAccess, $ilUser;
     $mode = $_SESSION['clipboard']['cmd'];
     $source_node_id = $_SESSION['clipboard']['source_id'];
     $target_node_id = $_REQUEST['node'];
     if (!$source_node_id) {
         ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'), true);
         $this->ctrl->redirect($this);
     }
     if (!$target_node_id) {
         ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'), true);
         $this->ctrl->redirect($this, "showMoveIntoObjectTree");
     }
     // object instances
     $source_obj_id = $this->tree->lookupObjectId($source_node_id);
     $source_object = ilObjectFactory::getInstanceByObjId($source_obj_id);
     if (!$_SESSION['clipboard']['wsp2repo']) {
         $target_obj_id = $this->tree->lookupObjectId($target_node_id);
     } else {
         $target_obj_id = ilObject::_lookupObjId($target_node_id);
     }
     $target_object = ilObjectFactory::getInstanceByObjId($target_obj_id);
     // sanity checks
     $fail = array();
     if ($source_node_id == $target_node_id) {
         $fail[] = sprintf($this->lng->txt('msg_obj_exists_in_folder'), $source_object->getTitle(), $target_object->getTitle());
     }
     if (!in_array($source_object->getType(), array_keys($objDefinition->getSubObjects($target_object->getType())))) {
         $fail[] = sprintf($this->lng->txt('msg_obj_may_not_contain_objects_of_type'), $target_object->getTitle(), $source_object->getType());
     }
     // if object is shared permission to copy has been checked above
     $owner = $this->tree->lookupOwner($source_node_id);
     if ($mode == "copy" && $ilUser->getId() == $owner && !$this->checkPermissionBool('copy', '', '', $source_node_id)) {
         $fail[] = $this->lng->txt('permission_denied');
     }
     if (!$_SESSION['clipboard']['wsp2repo']) {
         if ($mode == "cut" && $this->tree->isGrandChild($source_node_id, $target_node_id)) {
             $fail[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $source_object->getTitle());
         }
         if (!$this->checkPermissionBool('create', '', $source_object->getType(), $target_node_id)) {
             $fail[] = sprintf($this->lng->txt('msg_no_perm_paste_object_in_folder'), $source_object->getTitle(), $target_object->getTitle());
         }
     } else {
         if (!$ilAccess->checkAccess('create', '', $target_node_id, $source_object->getType())) {
             $fail[] = sprintf($this->lng->txt('msg_no_perm_paste_object_in_folder'), $source_object->getTitle(), $target_object->getTitle());
         }
     }
     if (sizeof($fail)) {
         ilUtil::sendFailure(implode("<br />", $fail), true);
         $this->ctrl->redirect($this);
     }
     // move the node
     if ($mode == "cut") {
         if (!$_SESSION['clipboard']['wsp2repo']) {
             $this->tree->moveTree($source_node_id, $target_node_id);
         } else {
             $parent_id = $this->tree->getParentId($source_node_id);
             // remove from personal workspace
             $this->getAccessHandler()->removePermission($source_node_id);
             $this->tree->deleteReference($source_node_id);
             $source_node = $this->tree->getNodeData($source_node_id);
             $this->tree->deleteTree($source_node);
             // add to repository
             $source_object->createReference();
             $source_object->putInTree($target_node_id);
             $source_object->setPermissions($target_node_id);
             $source_node_id = $parent_id;
         }
     } else {
         if ($mode == "copy") {
             include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
             $copy_id = ilCopyWizardOptions::_allocateCopyId();
             $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
             $wizard_options->saveOwner($ilUser->getId());
             $wizard_options->saveRoot($source_node_id);
             $wizard_options->read();
             $new_obj = $source_object->cloneObject($target_node_id, $copy_id, !$_SESSION['clipboard']['wsp2repo']);
             // insert into workspace tree
             if ($new_obj && !$_SESSION['clipboard']['wsp2repo']) {
                 $new_obj_node_id = $this->tree->insertObject($target_node_id, $new_obj->getId());
                 $this->getAccessHandler()->setPermissions($target_node_id, $new_obj_node_id);
             }
             $wizard_options->deleteAll();
         }
     }
     // redirect to target if not repository
     if (!$_SESSION['clipboard']['wsp2repo']) {
         $redirect_node = $target_node_id;
     } else {
         // reload current folder
         $redirect_node = $this->node_id;
     }
     unset($_SESSION['clipboard']['cmd']);
     unset($_SESSION['clipboard']['source_id']);
     unset($_SESSION['clipboard']['wsp2repo']);
     unset($_SESSION['clipboard']['shared']);
     ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
     $this->ctrl->setParameter($this, "wsp_id", $redirect_node);
     $this->ctrl->redirect($this);
 }
コード例 #26
0
 /**
  * Clone assignments
  * @param type $a_target_id
  * @param type $a_copy_id
  */
 public function cloneSettings($a_copy_id, $a_target_id, $a_objective_id)
 {
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $options = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $options->getMappings();
     if (!array_key_exists($this->getTestRefId(), $mappings)) {
         return FALSE;
     }
     $copy = new ilLOTestAssignment();
     $copy->setContainerId($a_target_id);
     $copy->setAssignmentType($this->getAssignmentType());
     $copy->setObjectiveId($a_objective_id);
     $copy->setTestRefId($mappings[$this->getTestRefId()]);
     $copy->create();
 }
コード例 #27
0
 /**
  * Creates a 1:1 copy of the object and places the copy in a given repository
  *
  * @access public
  */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->getOnline());
     }
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQuestions();
     foreach ($questions as $question_id) {
         $newObj->copyQuestion($question_id, $newObj->getId());
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     return $newObj;
 }
コード例 #28
0
 /**
  * Clone Object
  * @param int $a_target_id
  * @param int $a_copy_id
  * @return object
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     /**
      * @var $ilDB ilDB
      */
     global $ilDB;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneAutoGeneratedRoles($new_obj);
     ilForumProperties::getInstance($this->getId())->copy($new_obj->getId());
     $this->Forum->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($this->getId()));
     $topData = $this->Forum->getOneTopic();
     $nextId = $ilDB->nextId('frm_data');
     $statement = $ilDB->insert('frm_data', array('top_pk' => array('integer', $nextId), 'top_frm_fk' => array('integer', $new_obj->getId()), 'top_name' => array('text', $topData['top_name']), 'top_description' => array('text', $topData['top_description']), 'top_num_posts' => array('integer', $topData['top_num_posts']), 'top_num_threads' => array('integer', $topData['top_num_threads']), 'top_last_post' => array('text', $topData['top_last_post']), 'top_mods' => array('integer', !is_numeric($topData['top_mods']) ? 0 : $topData['top_mods']), 'top_date' => array('timestamp', $topData['top_date']), 'visits' => array('integer', $topData['visits']), 'top_update' => array('timestamp', $topData['top_update']), 'update_user' => array('integer', $topData['update_user']), 'top_usr_id' => array('integer', $topData['top_usr_id'])));
     // read options
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $options = $cwo->getOptions($this->getRefId());
     $options['threads'] = $this->Forum->_getThreads($this->getId());
     // Generate starting threads
     include_once 'Modules/Forum/classes/class.ilFileDataForum.php';
     $new_frm = $new_obj->Forum;
     $new_frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($new_obj->getId()));
     $new_frm->setForumId($new_obj->getId());
     $new_frm->setForumRefId($new_obj->getRefId());
     $new_topic = $new_frm->getOneTopic();
     foreach ($options['threads'] as $thread_id => $thread_subject) {
         $this->Forum->setMDB2WhereCondition('thr_pk = %s ', array('integer'), array($thread_id));
         $old_thread = $this->Forum->getOneThread();
         $old_post_id = $this->Forum->getFirstPostByThread($old_thread['thr_pk']);
         $old_post = $this->Forum->getOnePost($old_post_id);
         // Now create new thread and first post
         $new_post = $new_frm->generateThread($new_topic['top_pk'], $old_thread['thr_usr_id'], $old_thread['thr_subject'], ilForum::_lookupPostMessage($old_post_id), $old_post['notify'], 0, $old_thread['thr_usr_alias'], $old_thread['thr_date']);
         // Copy attachments
         $old_forum_files = new ilFileDataForum($this->getId(), $old_post_id);
         $old_forum_files->ilClone($new_obj->getId(), $new_post);
     }
     return $new_obj;
 }
コード例 #29
0
 /**
  * Clone course (no member data)
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  * 
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneAutoGeneratedRoles($new_obj);
     $this->cloneMetaData($new_obj);
     // Assign admin
     $new_obj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
     // #14596
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     if ($cwo->isRootNode($this->getRefId())) {
         $this->setOfflineStatus(true);
     }
     // Copy settings
     $this->cloneSettings($new_obj);
     // Course Defined Fields
     include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     ilCourseDefinedFieldDefinition::_clone($this->getId(), $new_obj->getId());
     // Clone course files
     include_once 'Modules/Course/classes/class.ilCourseFile.php';
     ilCourseFile::_cloneFiles($this->getId(), $new_obj->getId());
     // Copy learning progress settings
     include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
     $obj_settings = new ilLPObjSettings($this->getId());
     $obj_settings->cloneSettings($new_obj->getId());
     unset($obj_settings);
     // clone icons
     global $ilLog;
     $ilLog->write(__METHOD__ . ': ' . $this->getBigIconPath() . ' ' . $this->getSmallIconPath());
     $new_obj->saveIcons($this->getBigIconPath(), $this->getSmallIconPath(), $this->getTinyIconPath());
     // clone certificate (#11085)
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
     $cert = new ilCertificate(new ilCourseCertificateAdapter($this));
     $newcert = new ilCertificate(new ilCourseCertificateAdapter($new_obj));
     $cert->cloneCertificate($newcert);
     return $new_obj;
 }
コード例 #30
0
 /**
 * Creates a 1:1 copy of the object and places the copy in a given repository
 *
 * @access public
 */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->getOnline());
     }
     $newObj->setShowTaxonomies($this->getShowTaxonomies());
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQplQuestions();
     $questionIdsMap = array();
     foreach ($questions as $question_id) {
         $newQuestionId = $newObj->copyQuestion($question_id, $newObj->getId());
         $questionIdsMap[$question_id] = $newQuestionId;
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
     $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
     $duplicator->setSourceObjId($this->getId());
     $duplicator->setSourceObjType($this->getType());
     $duplicator->setTargetObjId($newObj->getId());
     $duplicator->setTargetObjType($newObj->getType());
     $duplicator->setQuestionIdMapping($questionIdsMap);
     $duplicator->duplicate();
     $duplicatedTaxKeyMap = $duplicator->getDuplicatedTaxonomiesKeysMap();
     $newObj->setNavTaxonomyId($duplicatedTaxKeyMap->getMappedTaxonomyId($this->getNavTaxonomyId()));
     $newObj->saveToDb();
     return $newObj;
 }