ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjPortfolioGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Modules/Portfolio/classes/class.ilObjPortfolioBaseGUI.php');
5
19{
20 protected $ws_access; // [ilWorkspaceAccessHandler]
21
22 public function __construct($a_id = 0)
23 {
24 parent::__construct($a_id, self::PORTFOLIO_OBJECT_ID, 0);
25 }
26
27 public function getType()
28 {
29 return "prtf";
30 }
31
32 protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_node_id = null)
33 {
34 if($a_perm == "create")
35 {
36 return true;
37 }
38 if(!$a_node_id)
39 {
40 $a_node_id = $this->obj_id;
41 }
42 return $this->access_handler->checkAccess($a_perm, "", $a_node_id);
43 }
44
45 function executeCommand()
46 {
47 global $lng;
48
49 $this->checkPermission("read");
50
51 // goto link to portfolio page
52 if($_GET["gtp"])
53 {
54 $_GET["user_page"] = $_GET["gtp"];
55 }
56
58
59 $next_class = $this->ctrl->getNextClass($this);
60 $cmd = $this->ctrl->getCmd("view");
61
62 /*
63 if($_REQUEST["ecal"])
64 {
65 $cmd = "preview";
66 $next_class = "";
67 }
68 */
69
70 switch($next_class)
71 {
72 case "ilworkspaceaccessgui";
73 if($this->checkPermissionBool("write"))
74 {
75 $this->setTabs();
76 $this->tabs_gui->activateTab("share");
77
78 if($this->access_handler->getPermissions($this->object->getId()) &&
79 !$this->object->isOnline())
80 {
81 ilUtil::sendInfo($lng->txt("prtf_shared_offline_info"));
82 }
83
84 $this->tpl->setPermanentLink("prtf", $this->object->getId());
85
86 include_once('./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php');
87 $wspacc = new ilWorkspaceAccessGUI($this->object->getId(), $this->access_handler, true);
88 $this->ctrl->forwardCommand($wspacc);
89 }
90 break;
91
92 case 'ilportfoliopagegui':
93 if($this->determinePageCall())
94 {
95 // only in edit mode
96 $this->addLocator();
97
98 include_once "Services/Form/classes/class.ilFileInputGUI.php";
100 }
101 $this->handlePageCall($cmd);
102 break;
103
104 case "ilnotegui";
105 $this->preview();
106 break;
107
108 case "ilobjstylesheetgui":
109 include_once ("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
110 $this->ctrl->setReturn($this, "editStyleProperties");
111 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
112 $style_gui->omitLocator();
113 if ($cmd == "create" || $_GET["new_type"]=="sty")
114 {
115 $style_gui->setCreationMode(true);
116 }
117
118 if ($cmd == "confirmedDelete")
119 {
120 $this->object->setStyleSheetId(0);
121 $this->object->update();
122 }
123
124 $ret = $this->ctrl->forwardCommand($style_gui);
125
126 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
127 {
128 $style_id = $ret;
129 $this->object->setStyleSheetId($style_id);
130 $this->object->update();
131 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
132 }
133 break;
134
135 case "ilportfolioexercisegui":
136 $this->ctrl->setReturn($this, "view");
137 include_once "Modules/Portfolio/classes/class.ilPortfolioExerciseGUI.php";
138 $gui = new ilPortfolioExerciseGUI($this->user_id, $this->object->getId());
139 $this->ctrl->forwardCommand($gui);
140 break;
141
142 default:
143
144 if($cmd != "preview")
145 {
146 $this->addLocator();
147 $this->setTabs();
148 }
149 $this->$cmd();
150 break;
151 }
152
153 return true;
154 }
155
156 protected function setTabs()
157 {
158 global $ilHelp;
159
160 $ilHelp->setScreenIdComponent("prtf");
161
162 if($this->checkPermissionBool("write"))
163 {
164 $this->tabs_gui->addTab("pages",
165 $this->lng->txt("content"),
166 $this->ctrl->getLinkTarget($this, "view"));
167
168 $this->tabs_gui->addTab("settings",
169 $this->lng->txt("settings"),
170 $this->ctrl->getLinkTarget($this, "edit"));
171
172 $this->tabs_gui->addNonTabbedLink("preview",
173 $this->lng->txt("user_profile_preview"),
174 $this->ctrl->getLinkTarget($this, "preview"));
175
176 $this->lng->loadLanguageModule("wsp");
177 $this->tabs_gui->addTab("share",
178 $this->lng->txt("wsp_permissions"),
179 $this->ctrl->getLinkTargetByClass("ilworkspaceaccessgui", "share"));
180 }
181 }
182
183 protected function addLocator()
184 {
185 if(!$this->creation_mode)
186 {
187 $this->ctrl->setParameter($this, "prt_id", $this->object->getId());
188 }
189
190 parent::addLocatorItems();
191
192 $this->tpl->setLocator();
193 }
194
195 protected function setTitleAndDescription()
196 {
197 // parent::setTitleAndDescription();
198
199 $title = $this->lng->txt("portfolio");
200 if($this->object)
201 {
202 $title .= ": ".$this->object->getTitle();
203 }
204 $this->tpl->setTitle($title);
205 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_prtf.svg"),
206 $this->lng->txt("portfolio"));
207
208 if($this->object &&
209 !$this->object->isOnline())
210 {
211 $this->tpl->setAlertProperties(array(
212 array("alert" => true,
213 "property" => $this->lng->txt("status"),
214 "value" => $this->lng->txt("offline"))
215 ));
216 }
217 }
218
219
220 //
221 // CREATE/EDIT
222 //
223
224 protected function initCreationForms($a_new_type)
225 {
226 return array(self::CFORM_NEW => $this->initCreateForm($a_new_type));
227 }
228
229 protected function initCreateForm($a_new_type)
230 {
231 global $ilSetting;
232
233 $this->ctrl->setParameter($this, "new_type", $this->getType());
234
235 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
236 $form = new ilPropertyFormGUI();
237 $form->setFormAction($this->ctrl->getFormAction($this));
238
239 // title
240 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
241 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
242 $ti->setMaxLength(ilObject::TITLE_LENGTH);
243 $ti->setRequired(true);
244 $form->addItem($ti);
245
246 /* description
247 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
248 $ta->setCols(40);
249 $ta->setRows(2);
250 $form->addItem($ta);
251 */
252
253 $main = new ilRadioGroupInputGUI($this->lng->txt("prtf_creation_mode"), "mode");
254 $main->setValue("mode_scratch");
255 $form->addItem($main);
256
257 $opt_scratch = new ilRadioOption($this->lng->txt("prtf_creation_mode_scratch"), "mode_scratch");
258 $main->addOption($opt_scratch);
259
260
261 // 1st page
262
263 $type = new ilRadioGroupInputGUI($this->lng->txt("prtf_first_page_title"), "ptype");
264 $type->setRequired(true);
265 $opt_scratch->addSubItem($type);
266
267 $type_page = new ilRadioOption($this->lng->txt("page"), "page");
268 $type->addOption($type_page);
269
270 // page type: page
271 $tf = new ilTextInputGUI($this->lng->txt("title"), "fpage");
272 $tf->setMaxLength(128);
273 $tf->setSize(40);
274 $tf->setRequired(true);
275 $type_page->addSubItem($tf);
276
277 // page templates
278 include_once "Services/COPage/Layout/classes/class.ilPageLayout.php";
280 if($templates)
281 {
282 $options = array(0 => $this->lng->txt("none"));
283 foreach ($templates as $templ)
284 {
285 $templ->readObject();
286 $options[$templ->getId()] = $templ->getTitle();
287 }
288
289 $use_template = new ilSelectInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
290 $use_template->setRequired(true);
291 $use_template->setOptions($options);
292 $type_page->addSubItem($use_template);
293 }
294
295 // page type: blog
296 if(!$ilSetting->get('disable_wsp_blogs'))
297 {
298 $options = array();
299 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
300 $tree = new ilWorkspaceTree($this->user_id);
301 $root = $tree->readRootId();
302 if($root)
303 {
304 $root = $tree->getNodeData($root);
305 foreach ($tree->getSubTree($root) as $node)
306 {
307 if ($node["type"] == "blog")
308 {
309 $options[$node["obj_id"]] = $node["title"];
310 }
311 }
312 asort($options);
313 }
314 if(sizeof($options))
315 {
316 $type_blog = new ilRadioOption($this->lng->txt("obj_blog"), "blog");
317 $type->addOption($type_blog);
318
319 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
320 $obj->setRequired(true);
321 $obj->setOptions(array(""=>$this->lng->txt("please_select"))+$options);
322 $type_blog->addSubItem($obj);
323 }
324 else
325 {
326 // #18147
327 $this->lng->loadLanguageModule('pd');
328 $url = $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui", "jumpToWorkspace");
329 $url = '<a href="'.$url.'">'.$this->lng->txt("pd_personal_workspace").'</a>';
330
331 ilUtil::sendInfo(sprintf($this->lng->txt("prtf_no_blogs_info"), $url), true);
332 $type->setValue("page");
333 }
334 }
335
336
337 // portfolio templates
338
339 $opt_tmpl = new ilRadioOption($this->lng->txt("prtf_creation_mode_template"), "mode_tmpl");
340 $main->addOption($opt_tmpl);
341
342 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
344 if(!sizeof($templates))
345 {
346 $opt_tmpl->setDisabled(true);
347 }
348 else
349 {
350 $tmpl = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtt");
351 $tmpl->setRequired(true);
352 $tmpl->setOptions(array(""=>$this->lng->txt("please_select"))+$templates);
353 $opt_tmpl->addSubItem($tmpl);
354
355 // incoming from repository
356 if((int)$_REQUEST["prtt_pre"])
357 {
358 $tmpl->setValue((int)$_REQUEST["prtt_pre"]);
359 $main->setValue("mode_tmpl");
360 }
361 }
362
363
364 $form->setTitle($this->lng->txt("prtf_create_portfolio"));
365 $form->addCommandButton("save", $this->lng->txt("create"));
366 $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
367
368 return $form;
369 }
370
371 public function save()
372 {
373 $form = $this->initCreateForm("prtf");
374 if($form->checkInput())
375 {
376 // trigger portfolio template "import" process
377 if($form->getInput("mode") == "mode_tmpl")
378 {
379 $_REQUEST["pt"] = $form->getInput("title");
380 return $this->createPortfolioFromTemplate();
381 }
382 }
383
384 return parent::save();
385 }
386
387 protected function afterSave(ilObject $a_new_object)
388 {
389 // create 1st page / blog
390 include_once("Modules/Portfolio/classes/class.ilPortfolioPage.php");
391 $page = $this->getPageInstance(null, $a_new_object->getId());
392 if($_POST["ptype"] == "page")
393 {
394 $page->setType(ilPortfolioPage::TYPE_PAGE);
395 $page->setTitle($_POST["fpage"]);
396
397 // use template as basis
398 $layout_id = $_POST["tmpl"];
399 if($layout_id)
400 {
401 include_once("./Services/COPage/Layout/classes/class.ilPageLayout.php");
402 $layout_obj = new ilPageLayout($layout_id);
403 $page->setXMLContent($layout_obj->getXMLContent());
404 }
405 }
406 else
407 {
408 $page->setType(ilPortfolioPage::TYPE_BLOG);
409 $page->setTitle($_POST["blog"]);
410 }
411 $page->create();
412
413 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
414 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
415 $this->ctrl->redirect($this, "view");
416 }
417
418 protected function toRepository()
419 {
420 global $ilAccess;
421
422 // return to exercise (portfolio assignment)
423 $exc_ref_id = (int)$_REQUEST["exc_id"];
424 if($exc_ref_id &&
425 $ilAccess->checkAccess("read", "", $exc_ref_id))
426 {
427 include_once "Services/Link/classes/class.ilLink.php";
428 ilUtil::redirect(ilLink::_getLink($exc_ref_id, "exc"));
429 }
430
431 $this->ctrl->redirectByClass("ilportfoliorepositorygui", "show");
432 }
433
434 protected function initEditForm()
435 {
436 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
437 $form = new ilPropertyFormGUI();
438 $form->setFormAction($this->ctrl->getFormAction($this));
439
440 // title
441 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
442 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
443 $ti->setMaxLength(ilObject::TITLE_LENGTH);
444 $ti->setRequired(true);
445 $ti->setValue($this->object->getTitle());
446 $form->addItem($ti);
447
448 /* description
449 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
450 $ta->setCols(40);
451 $ta->setRows(2);
452 $ta->setValue($this->object->getDescription());
453 $form->addItem($ta);
454 */
455
456 // :TODO: online
457 $online = new ilCheckboxInputGUI($this->lng->txt("online"), "online");
458 $online->setChecked($this->object->isOnline());
459 $form->addItem($online);
460
461 $this->initEditCustomForm($form);
462
463 $form->setTitle($this->lng->txt("prtf_edit_portfolio"));
464 $form->addCommandButton("update", $this->lng->txt("save"));
465 $form->addCommandButton("view", $this->lng->txt("cancel"));
466
467 return $form;
468 }
469
470 protected function getEditFormCustomValues(array &$a_values)
471 {
472 $a_values["online"] = $this->object->isOnline();
473
474 parent::getEditFormCustomValues($a_values);
475 }
476
477 public function updateCustom(ilPropertyFormGUI $a_form)
478 {
479 $this->object->setOnline($a_form->getInput("online"));
480
481 // if portfolio is not online, it cannot be default
482 if(!$a_form->getInput("online"))
483 {
484 ilObjPortfolio::setUserDefault($this->user_id, 0);
485 }
486
487 parent::updateCustom($a_form);
488 }
489
490
491 //
492 // PAGES
493 //
494
502 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
503 {
504 // #11531
505 if(!$a_portfolio_id && $this->object)
506 {
507 $a_portfolio_id = $this->object->getId();
508 }
509 include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
510 $page = new ilPortfolioPage($a_page_id);
511 $page->setPortfolioId($a_portfolio_id);
512 return $page;
513 }
514
521 protected function getPageGUIInstance($a_page_id)
522 {
523 include_once("Modules/Portfolio/classes/class.ilPortfolioPageGUI.php");
524 $page_gui = new ilPortfolioPageGUI(
525 $this->object->getId(),
526 $a_page_id,
527 0,
528 $this->object->hasPublicComments()
529 );
530 $page_gui->setAdditional($this->getAdditional());
531 return $page_gui;
532 }
533
534 public function getPageGUIClassName()
535 {
536 return "ilportfoliopagegui";
537 }
538
539 protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
540 {
541
542 $a_tgt = new ilRadioGroupInputGUI($this->lng->txt("target"), "target");
543 $a_tgt->setRequired(true);
544 $a_form->addItem($a_tgt);
545
546 $old = new ilRadioOption($this->lng->txt("prtf_existing_portfolio"), "old");
547 $a_tgt->addOption($old);
548
549 $options = array();
550 $all = ilObjPortfolio::getPortfoliosOfUser($this->user_id);
551 foreach($all as $item)
552 {
553 $options[$item["id"]] = $item["title"];
554 }
555 $prtf = new ilSelectInputGUI($this->lng->txt("portfolio"), "prtf");
556 $prtf->setRequired(true);
557 $prtf->setOptions($options);
558 $old->addSubItem($prtf);
559
560 $new = new ilRadioOption($this->lng->txt("prtf_new_portfolio"), "new");
561 $a_tgt->addOption($new);
562
563 $tf = new ilTextInputGUI($this->lng->txt("title"), "title");
564 $tf->setMaxLength(128);
565 $tf->setSize(40);
566 $tf->setRequired(true);
567 $new->addSubItem($tf);
568 }
569
570
571 //
572 // BLOG
573 //
574
581 public function initBlogForm()
582 {
583 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
584 $form = new ilPropertyFormGUI();
585 $form->setFormAction($this->ctrl->getFormAction($this));
586
587 $options = array();
588 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
589 $tree = new ilWorkspaceTree($this->user_id);
590 $root = $tree->readRootId();
591 if($root)
592 {
593 $root = $tree->getNodeData($root);
594 foreach ($tree->getSubTree($root, true, "blog") as $node)
595 {
596 $options[$node["obj_id"]] = $node["title"];
597 }
598 asort($options);
599 }
600
601 // no blogs to add?
602 if(!sizeof($options))
603 {
604 // #17218
605 $this->lng->loadLanguageModule('pd');
606 $url = $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui", "jumpToWorkspace");
607 $url = '<a href="'.$url.'">'.$this->lng->txt("pd_personal_workspace").'</a>';
608
609 ilUtil::sendInfo(sprintf($this->lng->txt("prtf_no_blogs_info"), $url), true);
610 $this->ctrl->redirect($this, "view");
611 }
612
613 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
614 $obj->setRequired(true);
615 $obj->setOptions($options);
616 $form->addItem($obj);
617
618 $form->setTitle($this->lng->txt("prtf_add_blog").": ".
619 $this->object->getTitle());
620 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
621 $form->addCommandButton("view", $this->lng->txt("cancel"));
622
623 return $form;
624 }
625
629 public function saveBlog()
630 {
631 $form = $this->initBlogForm();
632 if ($form->checkInput() && $this->checkPermissionBool("write"))
633 {
634 $page = $this->getPageInstance();
635 $page->setType(ilPortfolioPage::TYPE_BLOG);
636 $page->setTitle($form->getInput("blog"));
637 $page->create();
638
639 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
640 $this->ctrl->redirect($this, "view");
641 }
642
643 $this->tabs_gui->clearTargets();
644 $this->tabs_gui->setBackTarget($this->lng->txt("back"),
645 $this->ctrl->getLinkTarget($this, "view"));
646
647 $form->setValuesByPost();
648 $this->tpl->setContent($form->getHtml());
649 }
650
651
652 //
653 // CREATE FROM TEMPLATE
654 //
655
656 protected function createPortfolioFromTemplate(ilPropertyFormGUI $a_form = null)
657 {
658 $title = trim($_REQUEST["pt"]);
659 $prtt_id = (int)$_REQUEST["prtt"];
660
661 // valid template?
662 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
664 if(!sizeof($templates) || !in_array($prtt_id, $templates))
665 {
666 $this->toRepository();
667 }
668 unset($templates);
669
670 $this->ctrl->setParameter($this, "prtt", $prtt_id);
671
672 if(!$a_form)
673 {
674 $a_form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
675 }
676 if($a_form)
677 {
678 $this->tpl->setContent($a_form->getHTML());
679 }
680 else
681 {
683 }
684 }
685
686 protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
687 {
688 global $ilSetting, $ilUser;
689
690 if((int)$_REQUEST["exc_id"])
691 {
692 $this->ctrl->setParameter($this, "exc_id", (int)$_REQUEST["exc_id"]);
693 $this->ctrl->setParameter($this, "ass_id", (int)$_REQUEST["ass_id"]);
694 }
695
696 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
697 $form = new ilPropertyFormGUI();
698 $form->setFormAction($this->ctrl->getFormAction($this));
699
700 $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt"));
701 $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id));
702 $form->addItem($tmpl);
703
704 $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt");
705 $title->setValue($a_title);
706 $form->addItem($title);
707
708 // gather user blogs
709 if(!$ilSetting->get('disable_wsp_blogs'))
710 {
711 $blog_options = array();
712 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
713 $tree = new ilWorkspaceTree($this->user_id);
714 $root = $tree->readRootId();
715 if($root)
716 {
717 $root = $tree->getNodeData($root);
718 foreach ($tree->getSubTree($root, true, "blog") as $node)
719 {
720 $blog_options[$node["obj_id"]] = $node["title"];
721 }
722 asort($blog_options);
723 }
724 }
725
726 $has_form_content = false;
727
728 include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
730 $quota_sum = 0;
731
732 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
733 $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
734 $skill_ids = array();
735
736 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
737 foreach(ilPortfolioTemplatePage::getAllPortfolioPages($a_prtt_id) as $page)
738 {
739 switch($page["type"])
740 {
742 // skills
743 $source_page = new ilPortfolioTemplatePage($page["id"]);
744 $source_page->buildDom(true);
745 $dom = $source_page->getDom();
746 if($dom instanceof php4DOMDocument)
747 {
748 $dom = $dom->myDOMDocument;
749 }
750 $xpath = new DOMXPath($dom);
751 $nodes = $xpath->query("//PageContent/Skills");
752 foreach($nodes as $node)
753 {
754 $skill_id = $node->getAttribute("Id");
755 if(!in_array($skill_id, $pskills))
756 {
757 $skill_ids[] = $skill_id;
758 }
759 }
760 unset($nodes);
761 unset($xpath);
762 unset($dom);
763 if($check_quota)
764 {
765 $quota_sum += $source_page->getPageDiskSize();
766 }
767 if(sizeof($skill_ids))
768 {
769 $has_form_content = true;
770 }
771 break;
772
774 if(!$ilSetting->get('disable_wsp_blogs'))
775 {
776 $has_form_content = true;
777
778 $field_id = "blog_".$page["id"];
779
780 $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog").": ".
781 $page["title"], $field_id);
782 $blog->setRequired(true);
783 $blog->setValue("blog_create");
784 $form->addItem($blog);
785
786 $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create");
787 $blog->addOption($new_blog);
788
789 $title = new ilTextInputGUI($this->lng->txt("title"), $field_id."_create_title");
790 $title->setRequired(true);
791 $new_blog->addSubItem($title);
792
793 if(sizeof($blog_options))
794 {
795 $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse");
796 $blog->addOption($reuse_blog);
797
798 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id."_reuse_blog");
799 $obj->setRequired(true);
800 $obj->setOptions(array(""=>$this->lng->txt("please_select"))+$blog_options);
801 $reuse_blog->addSubItem($obj);
802 }
803
804 $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore"));
805 }
806 break;
807 }
808 }
809
810 if($skill_ids)
811 {
812 include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
813 $skills = new ilCheckboxGroupInputGUI($this->lng->txt("skills"), "skill_ids");
814 $skills->setInfo($this->lng->txt("prtf_template_import_new_skills"));
815 $skills->setValue($skill_ids);
816 foreach($skill_ids as $skill_id)
817 {
818 $skills->addOption(new ilCheckboxOption(ilSkillTreeNode::_lookupTitle($skill_id), $skill_id));
819 }
820 $form->addItem($skills);
821 }
822
823 if($quota_sum)
824 {
825 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
827 {
828 ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true);
829 $this->ctrl->redirect($this, "create");
830 }
831 }
832
833 // no dialog needed, go ahead
834 if(!$has_form_content)
835 {
836 return;
837 }
838
839 $form->setTitle($this->lng->txt("prtf_creation_mode").": ".$this->lng->txt("prtf_creation_mode_template"));
840 $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue"));
841 $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
842
843 return $form;
844 }
845
846 protected function createPortfolioFromTemplateProcess($a_process_form = true)
847 {
848 global $ilSetting, $ilUser, $ilAccess;
849
850 $title = trim($_REQUEST["pt"]);
851 $prtt_id = (int)$_REQUEST["prtt"];
852
853 // valid template?
854 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
856 if(!sizeof($templates) || !in_array($prtt_id, $templates))
857 {
858 $this->toRepository();
859 }
860 unset($templates);
861
862 // build page recipe (aka import form values)
863 $recipe = null;
864 if($a_process_form)
865 {
866 $this->ctrl->setParameter($this, "prtt", $prtt_id);
867
868 $form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
869 if($form->checkInput())
870 {
871 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
872 foreach(ilPortfolioTemplatePage::getAllPortfolioPages($prtt_id) as $page)
873 {
874 switch($page["type"])
875 {
877 if(!$ilSetting->get('disable_wsp_blogs'))
878 {
879 $field_id = "blog_".$page["id"];
880 switch($form->getInput($field_id))
881 {
882 case "blog_create":
883 $recipe[$page["id"]] = array("blog", "create",
884 trim($form->getInput($field_id."_create_title")));
885 break;
886
887 case "blog_resuse":
888 $recipe[$page["id"]] = array("blog", "reuse",
889 (int)$form->getInput($field_id."_reuse_blog"));
890 break;
891
892 case "blog_ignore":
893 $recipe[$page["id"]] = array("blog", "ignore");
894 break;
895 }
896 }
897 break;
898 }
899 }
900
901 $recipe["skills"] = (array)$form->getInput("skill_ids");
902 }
903 else
904 {
905 $form->setValuesByPost();
906 return $this->createPortfolioFromTemplate($form);
907 }
908 }
909
910 $source = new ilObjPortfolioTemplate($prtt_id, false);
911
912 // create portfolio
913 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
914 $target = new ilObjPortfolio();
915 $target->setTitle($title);
916 $target->create();
917 $target_id = $target->getId();
918
919 $source->clonePagesAndSettings($source, $target, $recipe);
920
921 // link portfolio to exercise assignment
922 $exc_ref_id = (int)$_REQUEST["exc_id"];
923 $ass_id = (int)$_REQUEST["ass_id"];
924 if($exc_ref_id &&
925 $ass_id &&
926 $ilAccess->checkAccess("read", "", $exc_ref_id))
927 {
928 include_once "Modules/Exercise/classes/class.ilObjExercise.php";
929 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
930 $exc = new ilObjExercise($exc_ref_id);
931 $ass = new ilExAssignment($ass_id);
932 if($ass->getExerciseId() == $exc->getId() &&
933 $ass->getType() == ilExAssignment::TYPE_PORTFOLIO)
934 {
935 // #16205
936 include_once "Modules/Exercise/classes/class.ilExSubmission.php";
937 $sub = new ilExSubmission($ass, $ilUser->getId());
938 $sub->addResourceObject($target_id);
939 }
940 }
941
942 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
943 $this->ctrl->setParameter($this, "prt_id", $target_id);
944 $this->ctrl->redirect($this, "view");
945 }
946
947 public static function _goto($a_target)
948 {
949 $id = explode("_", $a_target);
950
951 $_GET["baseClass"] = "ilsharedresourceGUI";
952 $_GET["prt_id"] = $id[0];
953 if(sizeof($id) == 2)
954 {
955 $_GET["gtp"] = $id[1];
956 }
957
958 include("ilias.php");
959 exit;
960 }
961}
962
963?>
sprintf('%.4f', $callTime)
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
static isUploadPossible($a_additional_size=null)
Exercise assignment.
Exercise submission.
static setPersonalWorkspaceQuotaCheck($a_value)
This class represents a non editable value in a property form.
Class ilObjExercise.
Portfolio view gui base class.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
getAdditional()
Get Additonal Information.
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
Portfolio view gui class.
getType()
Functions that must be overwritten.
initEditForm()
Init object edit form.
executeCommand()
execute command
getPageGUIInstance($a_page_id)
Get portfolio template page gui instance.
saveBlog()
Create new portfolio blog page.
initCreateForm($a_new_type)
Init object creation form.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
Get portfolio template page instance.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
setTitleAndDescription()
called by prepare output
createPortfolioFromTemplate(ilPropertyFormGUI $a_form=null)
createPortfolioFromTemplateProcess($a_process_form=true)
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
setTabs()
create tabs (repository/workspace switch)
initBlogForm()
Init blog page form.
initCreationForms($a_new_type)
Init creation froms.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
static getAvailablePortfolioTemplates($a_permission="read")
static setUserDefault($a_user_id, $a_portfolio_id=null)
Set the user default portfolio.
static getPortfoliosOfUser($a_user_id)
Get views of user.
Class ilObjStyleSheetGUI.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
Class ilObject Basic functions for all objects.
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
getId()
get object id @access public
Class ilPageLayout.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
Class ilPortfolioExerciseGUI.
Portfolio page gui class.
Page for user portfolio.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
Page for portfolio template.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Tree handler for personal workspace.
$target_id
Definition: goto.php:51
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$old
$cmd
Definition: sahs_server.php:35
$url
Definition: shib_logout.php:72
if(!is_array($argv)) $options
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:93