Exemplo n.º 1
0
 /**
  * Execute command
  * @return <type> 
  */
 public function executeCommand()
 {
     global $ilCtrl;
     $next_class = $ilCtrl->getNextClass($this);
     $cmd = $ilCtrl->getCmd();
     $this->setTabs();
     switch ($next_class) {
         case 'ilcourseobjectivesgui':
             $this->ctrl->setReturn($this, 'listObjectives');
             $GLOBALS['ilTabs']->clearTargets();
             $GLOBALS['ilTabs']->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'listObjectives'));
             include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
             $reg_gui =& new ilCourseObjectivesGUI($this->getParentObject()->getRefId());
             $this->ctrl->forwardCommand($reg_gui);
             break;
         case 'ilcontainerstartobjectsgui':
             include_once './Services/Container/classes/class.ilContainerStartObjectsGUI.php';
             $stgui = new ilContainerStartObjectsGUI($this->getParentObject());
             $ret = $this->ctrl->forwardCommand($stgui);
             $GLOBALS['ilTabs']->activateSubTab('start');
             $GLOBALS['ilTabs']->removeSubTab('manage');
             #$GLOBALS['tpl']->setContent($this->ctrl->getHTML($stgui));
             break;
         case 'ilconditionhandlergui':
             $this->ctrl->saveParameterByClass('ilconditionhandlergui', 'objective_id');
             $GLOBALS['ilTabs']->clearTargets();
             $GLOBALS['ilTabs']->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'listObjectives'));
             include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
             $cond = new ilConditionHandlerGUI($this);
             $cond->setBackButtons(array());
             $cond->setAutomaticValidation(false);
             $cond->setTargetType("lobj");
             $cond->setTargetRefId($this->getParentObject()->getRefId());
             $cond->setTargetId((int) $_REQUEST['objective_id']);
             // objecitve
             include_once './Modules/Course/classes/class.ilCourseObjective.php';
             $obj = new ilCourseObjective($this->getParentObject(), (int) $_REQUEST['objective_id']);
             $cond->setTargetTitle($obj->getTitle());
             $this->ctrl->forwardCommand($cond);
             break;
         case 'illopagegui':
             $this->ctrl->saveParameterByClass('illopagegui', 'objective_id');
             $GLOBALS['ilTabs']->clearTargets();
             $GLOBALS['ilTabs']->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'listObjectives'));
             $objtv_id = (int) $_REQUEST['objective_id'];
             include_once 'Modules/Course/classes/Objectives/class.ilLOPage.php';
             if (!ilLOPage::_exists('lobj', $objtv_id)) {
                 // doesn't exist -> create new one
                 $new_page_object = new ilLOPage();
                 $new_page_object->setParentId($objtv_id);
                 $new_page_object->setId($objtv_id);
                 $new_page_object->createFromXML();
                 unset($new_page_object);
             }
             $this->ctrl->setReturn($this, 'listObjectives');
             include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
             $pgui = new ilLOPageGUI($objtv_id);
             $pgui->setPresentationTitle(ilCourseObjective::lookupObjectiveTitle($objtv_id));
             // needed for editor?
             include_once './Services/Style/classes/class.ilObjStyleSheet.php';
             $pgui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
             // #14895
             $GLOBALS['tpl']->setCurrentBlock("ContentStyle");
             $GLOBALS['tpl']->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
             $GLOBALS['tpl']->parseCurrentBlock();
             $ret = $this->ctrl->forwardCommand($pgui);
             if ($ret) {
                 $GLOBALS['tpl']->setContent($ret);
             }
             break;
         default:
             if (!$cmd) {
                 // get first unaccomplished step
                 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
                 $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep();
             }
             $this->{$cmd}();
             break;
     }
     return true;
 }
Exemplo n.º 2
0
 protected function parseConditions($toggle_id, $conditions, $obligatory = true)
 {
     global $ilAccess, $lng, $objDefinition, $tree;
     $num_required = ilConditionHandler::calculateRequiredTriggers($this->ref_id, $this->obj_id);
     $num_optional_required = $num_required - count($conditions) + count(ilConditionHandler::getOptionalConditionsOfTarget($this->ref_id, $this->obj_id));
     // Check if all conditions are fullfilled
     $visible_conditions = array();
     $passed_optional = 0;
     foreach ($conditions as $condition) {
         if ($obligatory and !$condition['obligatory']) {
             continue;
         }
         if (!$obligatory and $condition['obligatory']) {
             continue;
         }
         if ($tree->isDeleted($condition['trigger_ref_id'])) {
             continue;
         }
         include_once 'Services/Container/classes/class.ilMemberViewSettings.php';
         $ok = ilConditionHandler::_checkCondition($condition['id']) and !ilMemberViewSettings::getInstance()->isActive();
         if (!$ok) {
             $visible_conditions[] = $condition['id'];
         }
         if (!$obligatory and $ok) {
             ++$passed_optional;
             // optional passed
             if ($passed_optional >= $num_optional_required) {
                 return true;
             }
         }
     }
     foreach ($conditions as $condition) {
         if (!in_array($condition['id'], $visible_conditions)) {
             continue;
         }
         include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.php';
         $cond_txt = ilConditionHandlerGUI::translateOperator($condition['trigger_obj_id'], $condition['operator']) . ' ' . $condition['value'];
         // display trigger item
         $class = $objDefinition->getClassName($condition["trigger_type"]);
         $location = $objDefinition->getLocation($condition["trigger_type"]);
         if ($class == "" && $location == "") {
             continue;
         }
         $missing_cond_exist = true;
         $full_class = "ilObj" . $class . "ListGUI";
         include_once $location . "/class." . $full_class . ".php";
         $item_list_gui = new $full_class($this);
         $item_list_gui->setMode(IL_LIST_AS_TRIGGER);
         $item_list_gui->enablePath(false);
         $item_list_gui->enableIcon(true);
         $item_list_gui->setConditionDepth($this->condition_depth + 1);
         $item_list_gui->setParentRefId($this->getUniqueItemId());
         // yes we can
         $item_list_gui->addCustomProperty($this->lng->txt("precondition_required_itemlist"), $cond_txt, false, true);
         $item_list_gui->enableCommands($this->commands_enabled, $this->std_cmd_only);
         $item_list_gui->enableProperties($this->properties_enabled);
         $trigger_html = $item_list_gui->getListItemHTML($condition['trigger_ref_id'], $condition['trigger_obj_id'], ilObject::_lookupTitle($condition["trigger_obj_id"]), "");
         $this->tpl->setCurrentBlock("precondition");
         if ($trigger_html == "") {
             $trigger_html = $this->lng->txt("precondition_not_accessible");
         }
         $this->tpl->setVariable("TXT_CONDITION", trim($cond_txt));
         $this->tpl->setVariable("TRIGGER_ITEM", $trigger_html);
         $this->tpl->parseCurrentBlock();
     }
     if ($missing_cond_exist and $obligatory) {
         $this->tpl->setCurrentBlock("preconditions");
         $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_obl_" . $toggle_id);
         $this->tpl->setVariable("TXT_PRECONDITIONS", $lng->txt("preconditions_obligatory_hint"));
         $this->tpl->parseCurrentBlock();
     } elseif ($missing_cond_exist and !$obligatory) {
         $this->tpl->setCurrentBlock("preconditions");
         $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_opt_" . $toggle_id);
         $this->tpl->setVariable("TXT_PRECONDITIONS", sprintf($lng->txt("preconditions_optional_hint"), $num_optional_required));
         $this->tpl->parseCurrentBlock();
     }
     return !$missing_cond_exist;
 }