/**
  * Parse template action from xml
  * @param ilDidacticTemplateSetting $set
  * @param SimpleXMLElement $root
  * @return void
  */
 protected function parseActions(ilDidacticTemplateSetting $set, SimpleXMLElement $actions = NULL)
 {
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
     if ($actions === NULL) {
         return void;
     }
     ////////////////////////////////////////////////
     // Local role action
     ///////////////////////////////////////////////
     foreach ($actions->localRoleAction as $ele) {
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalRoleAction.php';
         $act = new ilDidacticTemplateLocalRoleAction();
         $act->setTemplateId($set->getId());
         foreach ($ele->roleTemplate as $tpl) {
             // extract role
             foreach ($tpl->role as $roleDef) {
                 include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
                 $rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
                 $role_id = $rimporter->importSimpleXml($roleDef);
                 $act->setRoleTemplateId($role_id);
             }
             $act->save();
         }
     }
     ////////////////////////////////////////////////
     // Block role action
     //////////////////////////////////////////////
     foreach ($actions->blockRoleAction as $ele) {
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateBlockRoleAction.php';
         $act = new ilDidacticTemplateBlockRoleAction();
         $act->setTemplateId($set->getId());
         // Role filter
         foreach ($ele->roleFilter as $rfi) {
             $act->setFilterType((string) $rfi->attributes()->source);
             foreach ($rfi->includePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateIncludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
             foreach ($rfi->excludePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateExcludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
         }
         $act->save();
     }
     ////////////////////////////////////////////
     // Local policy action
     /////////////////////////////////////////////
     foreach ($actions->localPolicyAction as $ele) {
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalPolicyAction.php';
         $act = new ilDidacticTemplateLocalPolicyAction();
         $act->setTemplateId($set->getId());
         // Role filter
         foreach ($ele->roleFilter as $rfi) {
             $act->setFilterType((string) $rfi->attributes()->source);
             foreach ($rfi->includePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateIncludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
             foreach ($rfi->excludePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateExcludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
         }
         // role template assignment
         foreach ($ele->localPolicyTemplate as $lpo) {
             $act->setFilterType(ilDidacticTemplateLocalPolicyAction::FILTER_SOURCE_TITLE);
             switch ((string) $lpo->attributes()->type) {
                 case 'overwrite':
                     $act->setRoleTemplateType(ilDidacticTemplateLocalPolicyAction::TPL_ACTION_OVERWRITE);
                     break;
                 case 'union':
                     $act->setRoleTemplateType(ilDidacticTemplateLocalPolicyAction::TPL_ACTION_UNION);
                     break;
                 case 'intersect':
                     $act->setRoleTemplateType(ilDidacticTemplateLocalPolicyAction::TPL_ACTION_INTERSECT);
                     break;
             }
             // extract role
             foreach ($lpo->role as $roleDef) {
                 include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
                 $rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
                 $role_id = $rimporter->importSimpleXml($roleDef);
                 $act->setRoleTemplateId($role_id);
             }
         }
         // Save action including all filter patterns
         $act->save();
     }
 }
 /**
  * Show delete confirmation screen
  */
 protected function confirmDelete()
 {
     global $ilErr, $ilCtrl;
     if (!$_REQUEST['tpls']) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         return $ilCtrl->redirect($this, 'overview');
     }
     include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
     $confirm = new ilConfirmationGUI();
     $confirm->setFormAction($ilCtrl->getFormAction($this));
     $confirm->setConfirm($this->lng->txt('delete'), 'deleteTemplates');
     $confirm->setCancel($this->lng->txt('cancel'), 'overview');
     foreach ((array) $_REQUEST['tpls'] as $tplid) {
         $tpl = new ilDidacticTemplateSetting($tplid);
         $confirm->addItem('tpls[]', $tpl->getId(), $tpl->getTitle());
     }
     ilUtil::sendQuestion($this->lng->txt('didactic_confirm_delete_msg'));
     $GLOBALS['tpl']->setContent($confirm->getHTML());
 }