/**
  * 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.');
     }
 }
 /**
  * assign new trigger condition to target
  */
 function assign()
 {
     if (!isset($_GET['source_id'])) {
         echo "class.ilConditionHandlerInterface: no source_id given";
         return false;
     }
     if (!$_POST['operator']) {
         ilUtil::sendFailure($this->lng->txt('err_check_input'));
         $this->add();
         return false;
     }
     $this->ch_obj->setTargetRefId($this->getTargetRefId());
     $this->ch_obj->setTargetObjId($this->getTargetId());
     $this->ch_obj->setTargetType($this->getTargetType());
     switch ($this->getTargetType()) {
         case 'st':
             $this->ch_obj->setReferenceHandlingType($_POST['ref_handling']);
             break;
         default:
             $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
             break;
     }
     // this has to be changed, if non referenced trigger are implemted
     if (!($trigger_obj =& ilObjectFactory::getInstanceByRefId((int) $_GET['source_id'], false))) {
         echo 'ilConditionHandler: Trigger object does not exist';
     }
     $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
     $this->ch_obj->setTriggerObjId($trigger_obj->getId());
     $this->ch_obj->setTriggerType($trigger_obj->getType());
     $this->ch_obj->setOperator($_POST['operator']);
     $this->ch_obj->setObligatory((int) $_POST['obligatory']);
     $this->ch_obj->setValue('');
     // Save assigned sco's
     if ($this->ch_obj->getTriggerType() == 'sahs') {
         include_once 'Services/Tracking/classes/class.ilLPCollections.php';
         $lp_collection = new ilLPCollections($this->ch_obj->getTriggerObjId());
         $lp_collection->deleteAll();
         $items = is_array($_POST['item_ids']) ? $_POST['item_ids'] : array();
         foreach ($items as $item_id) {
             $lp_collection->add($item_id);
         }
     }
     $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
     if (!$this->ch_obj->storeCondition()) {
         ilUtil::sendFailure($this->ch_obj->getErrorMessage(), true);
     } else {
         ilUtil::sendSuccess($this->lng->txt('added_new_condition'), true);
     }
     $this->ctrl->redirect($this, 'listConditions');
     return true;
 }
 /**
  * Test LP collections 
  * @return
  */
 public function testLPCollections()
 {
     include_once './Services/Tracking/classes/class.ilLPCollections.php';
     $coll = new ilLPCollections(999);
     $coll->add(888);
     $coll->delete(888);
     $coll->add(777);
     ilLPCollections::_deleteAll(999);
 }