Ejemplo n.º 1
0
 protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
 {
     global $ilSetting, $ilUser;
     if ((int) $_REQUEST["exc_id"]) {
         $this->ctrl->setParameter($this, "exc_id", (int) $_REQUEST["exc_id"]);
         $this->ctrl->setParameter($this, "ass_id", (int) $_REQUEST["ass_id"]);
     }
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt"));
     $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id));
     $form->addItem($tmpl);
     $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt");
     $title->setValue($a_title);
     $form->addItem($title);
     // gather user blogs
     if (!$ilSetting->get('disable_wsp_blogs')) {
         $blog_options = array();
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         $tree = new ilWorkspaceTree($this->user_id);
         $root = $tree->readRootId();
         if ($root) {
             $root = $tree->getNodeData($root);
             foreach ($tree->getSubTree($root, true, "blog") as $node) {
                 $blog_options[$node["obj_id"]] = $node["title"];
             }
             asort($blog_options);
         }
     }
     $has_form_content = false;
     include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
     $check_quota = ilDiskQuotaActivationChecker::_isPersonalWorkspaceActive();
     $quota_sum = 0;
     include_once "Services/Skill/classes/class.ilPersonalSkill.php";
     $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
     $skill_ids = array();
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     foreach (ilPortfolioTemplatePage::getAllPages($a_prtt_id) as $page) {
         switch ($page["type"]) {
             case ilPortfolioTemplatePage::TYPE_PAGE:
                 // skills
                 $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);
                 if ($check_quota) {
                     $quota_sum += $source_page->getPageDiskSize();
                 }
                 if (sizeof($skill_ids)) {
                     $has_form_content = true;
                 }
                 break;
             case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                 if (!$ilSetting->get('disable_wsp_blogs')) {
                     $has_form_content = true;
                     $field_id = "blog_" . $page["id"];
                     $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog") . ": " . $page["title"], $field_id);
                     $blog->setRequired(true);
                     $blog->setValue("blog_create");
                     $form->addItem($blog);
                     $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create");
                     $blog->addOption($new_blog);
                     $title = new ilTextInputGUI($this->lng->txt("title"), $field_id . "_create_title");
                     $title->setRequired(true);
                     $new_blog->addSubItem($title);
                     if (sizeof($blog_options)) {
                         $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse");
                         $blog->addOption($reuse_blog);
                         $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id . "_reuse_blog");
                         $obj->setRequired(true);
                         $obj->setOptions(array("" => $this->lng->txt("please_select")) + $blog_options);
                         $reuse_blog->addSubItem($obj);
                     }
                     $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore"));
                 }
                 break;
         }
     }
     if ($skill_ids) {
         include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
         $skills = new ilCheckboxGroupInputGUI($this->lng->txt("skills"), "skill_ids");
         $skills->setInfo($this->lng->txt("prtf_template_import_new_skills"));
         $skills->setValue($skill_ids);
         foreach ($skill_ids as $skill_id) {
             $skills->addOption(new ilCheckboxOption(ilSkillTreeNode::_lookupTitle($skill_id), $skill_id));
         }
         $form->addItem($skills);
     }
     if ($quota_sum) {
         include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
         if (!ilDiskQuotaHandler::isUploadPossible($quota_sum)) {
             ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true);
             $this->ctrl->redirect($this, "create");
         }
     }
     // no dialog needed, go ahead
     if (!$has_form_content) {
         return;
     }
     $form->setTitle($this->lng->txt("prtf_creation_mode") . ": " . $this->lng->txt("prtf_creation_mode_template"));
     $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue"));
     $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
     return $form;
 }
 protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
 {
     global $ilSetting;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt"));
     $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id));
     $form->addItem($tmpl);
     $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt");
     $title->setValue($a_title);
     $form->addItem($title);
     // gather user blogs
     if (!$ilSetting->get('disable_wsp_blogs')) {
         $blog_options = array();
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         $tree = new ilWorkspaceTree($this->user_id);
         $root = $tree->readRootId();
         if ($root) {
             $root = $tree->getNodeData($root);
             foreach ($tree->getSubTree($root) as $node) {
                 if ($node["type"] == "blog") {
                     $blog_options[$node["obj_id"]] = $node["title"];
                 }
             }
             asort($blog_options);
         }
     }
     $has_form_content = false;
     include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
     $check_quota = ilDiskQuotaActivationChecker::_isPersonalWorkspaceActive();
     $quota_sum = 0;
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     foreach (ilPortfolioTemplatePage::getAllPages($a_prtt_id) as $page) {
         switch ($page["type"]) {
             case ilPortfolioTemplatePage::TYPE_PAGE:
                 if ($check_quota) {
                     $source_page = new ilPortfolioTemplatePage($page["id"]);
                     $quota_sum += $source_page->getPageDiskSize();
                 }
                 break;
             case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                 if (!$ilSetting->get('disable_wsp_blogs')) {
                     $has_form_content = true;
                     $field_id = "blog_" . $page["id"];
                     $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog") . ": " . $page["title"], $field_id);
                     $blog->setRequired(true);
                     $blog->setValue("blog_create");
                     $form->addItem($blog);
                     $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create");
                     $blog->addOption($new_blog);
                     $title = new ilTextInputGUI($this->lng->txt("title"), $field_id . "_create_title");
                     $title->setRequired(true);
                     $new_blog->addSubItem($title);
                     if (sizeof($blog_options)) {
                         $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse");
                         $blog->addOption($reuse_blog);
                         $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id . "_reuse_blog");
                         $obj->setRequired(true);
                         $obj->setOptions(array("" => $this->lng->txt("please_select")) + $blog_options);
                         $reuse_blog->addSubItem($obj);
                     }
                     $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore"));
                 }
                 break;
         }
     }
     if ($quota_sum) {
         include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
         if (!ilDiskQuotaHandler::isUploadPossible($quota_sum)) {
             ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true);
             $this->ctrl->redirect($this, "create");
         }
     }
     // no dialog needed, go ahead
     if (!$has_form_content) {
         return;
     }
     $form->setTitle($this->lng->txt("prtf_creation_mode") . ": " . $this->lng->txt("prtf_creation_mode_template"));
     $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue"));
     $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
     return $form;
 }