/** * 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; }