public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
 {
     include_once "./Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     $pg_ids = array();
     foreach ($a_ids as $id) {
         foreach (ilPortfolioTemplatePage::getAllPages($id) as $p) {
             $pg_ids[] = "prtt:" . $p["id"];
         }
     }
     return array(array("component" => "Services/COPage", "entity" => "pg", "ids" => $pg_ids));
 }
 protected function deleteAllPages()
 {
     // delete pages
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     $pages = ilPortfolioTemplatePage::getAllPages($this->id);
     foreach ($pages as $page) {
         $page_obj = new ilPortfolioTemplatePage($page["id"]);
         $page_obj->setPortfolioId($this->id);
         $page_obj->delete();
     }
 }
Пример #3
0
 /**
  * @return array
  */
 protected function addSkills()
 {
     $user = $this->getUsrObject();
     $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($user->getId()));
     $skill_ids = array();
     $recipe = array();
     foreach (ilPortfolioTemplatePage::getAllPages($this->getPortfolioTemplateId()) as $page) {
         switch ($page['type']) {
             case ilPortfolioTemplatePage::TYPE_PAGE:
                 $source_page = new ilPortfolioTemplatePage($page['id']);
                 $source_page->buildDom(true);
                 $dom = $source_page->getDom();
                 if ($dom instanceof php4DOMDocument) {
                     $dom = $dom->myDOMDocument;
                 }
                 $xpath = new DOMXPath($dom);
                 $nodes = $xpath->query('//PageContent/Skills');
                 foreach ($nodes as $node) {
                     $skill_id = $node->getAttribute('Id');
                     if (!in_array($skill_id, $pskills)) {
                         $skill_ids[] = $skill_id;
                     }
                 }
                 unset($nodes);
                 unset($xpath);
                 unset($dom);
                 break;
         }
     }
     foreach ($skill_ids as $skill_id) {
         ilPersonalSkill::addPersonalSkill($user->getId(), $skill_id);
     }
 }
Пример #4
0
 protected function createPortfolioFromTemplateProcess($a_process_form = true)
 {
     global $ilSetting, $ilUser, $ilAccess;
     $title = trim($_REQUEST["pt"]);
     $prtt_id = (int) $_REQUEST["prtt"];
     // valid template?
     include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
     $templates = array_keys(ilObjPortfolioTemplate::getAvailablePortfolioTemplates());
     if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
         $this->toRepository();
     }
     unset($templates);
     // build page recipe (aka import form values)
     $recipe = null;
     if ($a_process_form) {
         $this->ctrl->setParameter($this, "prtt", $prtt_id);
         $form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
         if ($form->checkInput()) {
             include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
             foreach (ilPortfolioTemplatePage::getAllPages($prtt_id) as $page) {
                 switch ($page["type"]) {
                     case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                         if (!$ilSetting->get('disable_wsp_blogs')) {
                             $field_id = "blog_" . $page["id"];
                             switch ($form->getInput($field_id)) {
                                 case "blog_create":
                                     $recipe[$page["id"]] = array("blog", "create", trim($form->getInput($field_id . "_create_title")));
                                     break;
                                 case "blog_resuse":
                                     $recipe[$page["id"]] = array("blog", "reuse", (int) $form->getInput($field_id . "_reuse_blog"));
                                     break;
                                 case "blog_ignore":
                                     $recipe[$page["id"]] = array("blog", "ignore");
                                     break;
                             }
                         }
                         break;
                 }
             }
             $recipe["skills"] = (array) $form->getInput("skill_ids");
         } else {
             $form->setValuesByPost();
             return $this->createPortfolioFromTemplate($form);
         }
     }
     $source = new ilObjPortfolioTemplate($prtt_id, false);
     // create portfolio
     include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
     $target = new ilObjPortfolio();
     $target->setTitle($title);
     $target->create();
     $target_id = $target->getId();
     $source->clonePagesAndSettings($source, $target, $recipe);
     // link portfolio to exercise assignment
     $exc_ref_id = (int) $_REQUEST["exc_id"];
     $ass_id = (int) $_REQUEST["ass_id"];
     if ($exc_ref_id && $ass_id && $ilAccess->checkAccess("read", "", $exc_ref_id)) {
         include_once "Modules/Exercise/classes/class.ilObjExercise.php";
         include_once "Modules/Exercise/classes/class.ilExAssignment.php";
         $exc = new ilObjExercise($exc_ref_id);
         $ass = new ilExAssignment($ass_id);
         if ($ass->getExerciseId() == $exc->getId() && $ass->getType() == ilExAssignment::TYPE_PORTFOLIO) {
             $exc->addResourceObject($target_id, $ass_id, $ilUser->getId());
         }
     }
     ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
     $this->ctrl->setParameter($this, "prt_id", $target_id);
     $this->ctrl->redirect($this, "view");
 }