ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
18{
19 protected $ws_access; // [ilWorkspaceAccessHandler]
20
21 public function __construct($a_id = 0)
22 {
23 parent::__construct($a_id, self::PORTFOLIO_OBJECT_ID, 0);
24 }
25
26 public function getType()
27 {
28 return "prtf";
29 }
30
31 protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_node_id = null)
32 {
33 if($a_perm == "create")
34 {
35 return true;
36 }
37 if(!$a_node_id)
38 {
39 $a_node_id = $this->obj_id;
40 }
41 return $this->access_handler->checkAccess($a_perm, "", $a_node_id);
42 }
43
44 function executeCommand()
45 {
46 $this->checkPermission("read");
47
48 // goto link to portfolio page
49 if($_GET["gtp"])
50 {
51 $_GET["user_page"] = $_GET["gtp"];
52 }
53
55
56 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd("view");
58
59 /*
60 if($_REQUEST["ecal"])
61 {
62 $cmd = "preview";
63 $next_class = "";
64 }
65 */
66
67 switch($next_class)
68 {
69 case "ilworkspaceaccessgui";
70 if($this->checkPermissionBool("write"))
71 {
72 $this->setTabs();
73 $this->tabs_gui->activateTab("share");
74
75 $this->tpl->setPermanentLink("prtf", $this->object->getId());
76
77 include_once('./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php');
78 $wspacc = new ilWorkspaceAccessGUI($this->object->getId(), $this->access_handler, true, $plink);
79 $this->ctrl->forwardCommand($wspacc);
80 }
81 break;
82
83 case 'ilportfoliopagegui':
84 if($this->determinePageCall())
85 {
86 // only in edit mode
87 $this->addLocator();
88
89 include_once "Services/Form/classes/class.ilFileInputGUI.php";
91 }
92 $this->handlePageCall($cmd);
93 break;
94
95 case "ilnotegui";
96 $this->preview();
97 break;
98
99 case "ilobjstylesheetgui":
100 include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
101 $this->ctrl->setReturn($this, "editStyleProperties");
102 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
103 $style_gui->omitLocator();
104 if ($cmd == "create" || $_GET["new_type"]=="sty")
105 {
106 $style_gui->setCreationMode(true);
107 }
108
109 if ($cmd == "confirmedDelete")
110 {
111 $this->object->setStyleSheetId(0);
112 $this->object->update();
113 }
114
115 $ret = $this->ctrl->forwardCommand($style_gui);
116
117 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
118 {
119 $style_id = $ret;
120 $this->object->setStyleSheetId($style_id);
121 $this->object->update();
122 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
123 }
124 break;
125
126 default:
127
128 if($cmd != "preview")
129 {
130 $this->addLocator();
131 $this->setTabs();
132 }
133 $this->$cmd();
134 break;
135 }
136
137 return true;
138 }
139
140 protected function setTabs()
141 {
142 global $ilHelp;
143
144 $ilHelp->setScreenIdComponent("prtf");
145
146 if($this->checkPermissionBool("write"))
147 {
148 $this->tabs_gui->addTab("pages",
149 $this->lng->txt("content"),
150 $this->ctrl->getLinkTarget($this, "view"));
151
152 $this->tabs_gui->addTab("settings",
153 $this->lng->txt("settings"),
154 $this->ctrl->getLinkTarget($this, "edit"));
155
156 $this->tabs_gui->addNonTabbedLink("preview",
157 $this->lng->txt("user_profile_preview"),
158 $this->ctrl->getLinkTarget($this, "preview"));
159
160 $this->lng->loadLanguageModule("wsp");
161 $this->tabs_gui->addTab("share",
162 $this->lng->txt("wsp_permissions"),
163 $this->ctrl->getLinkTargetByClass("ilworkspaceaccessgui", "share"));
164 }
165 }
166
167 protected function addLocator()
168 {
169 if(!$this->creation_mode)
170 {
171 $this->ctrl->setParameter($this, "prt_id", $this->object->getId());
172 }
173
174 parent::addLocatorItems();
175
176 $this->tpl->setLocator();
177 }
178
179 protected function setTitleAndDescription()
180 {
181 // parent::setTitleAndDescription();
182
183 $title = $this->lng->txt("portfolio");
184 if($this->object)
185 {
186 $title .= ": ".$this->object->getTitle();
187 }
188 $this->tpl->setTitle($title);
189 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_prtf.svg"),
190 $this->lng->txt("portfolio"));
191
192 if($this->object &&
193 !$this->object->isOnline())
194 {
195 $this->tpl->setAlertProperties(array(
196 array("alert" => true,
197 "property" => $this->lng->txt("status"),
198 "value" => $this->lng->txt("offline"))
199 ));
200 }
201 }
202
203
204 //
205 // CREATE/EDIT
206 //
207
208 protected function initCreationForms($a_new_type)
209 {
210 return array(self::CFORM_NEW => $this->initCreateForm($a_new_type));
211 }
212
213 protected function initCreateForm($a_new_type)
214 {
215 global $ilSetting;
216
217 $this->ctrl->setParameter($this, "new_type", $this->getType());
218
219 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
220 $form = new ilPropertyFormGUI();
221 $form->setFormAction($this->ctrl->getFormAction($this));
222
223 // title
224 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
225 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
226 $ti->setMaxLength(ilObject::TITLE_LENGTH);
227 $ti->setRequired(true);
228 $form->addItem($ti);
229
230 /* description
231 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
232 $ta->setCols(40);
233 $ta->setRows(2);
234 $form->addItem($ta);
235 */
236
237 $main = new ilRadioGroupInputGUI($this->lng->txt("prtf_creation_mode"), "mode");
238 $main->setValue("mode_scratch");
239 $form->addItem($main);
240
241 $opt_scratch = new ilRadioOption($this->lng->txt("prtf_creation_mode_scratch"), "mode_scratch");
242 $main->addOption($opt_scratch);
243
244
245 // 1st page
246
247 $type = new ilRadioGroupInputGUI($this->lng->txt("prtf_first_page_title"), "ptype");
248 $type->setRequired(true);
249 $opt_scratch->addSubItem($type);
250
251 $type_page = new ilRadioOption($this->lng->txt("page"), "page");
252 $type->addOption($type_page);
253
254 // page type: page
255 $tf = new ilTextInputGUI($this->lng->txt("title"), "fpage");
256 $tf->setMaxLength(128);
257 $tf->setSize(40);
258 $tf->setRequired(true);
259 $type_page->addSubItem($tf);
260
261 // page templates
262 include_once "Services/Style/classes/class.ilPageLayout.php";
264 if($templates)
265 {
266 $options = array(0 => $this->lng->txt("none"));
267 foreach ($templates as $templ)
268 {
269 $templ->readObject();
270 $options[$templ->getId()] = $templ->getTitle();
271 }
272
273 $use_template = new ilSelectInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
274 $use_template->setRequired(true);
275 $use_template->setOptions($options);
276 $type_page->addSubItem($use_template);
277 }
278
279 // page type: blog
280 if(!$ilSetting->get('disable_wsp_blogs'))
281 {
282 $options = array();
283 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
284 $tree = new ilWorkspaceTree($this->user_id);
285 $root = $tree->readRootId();
286 if($root)
287 {
288 $root = $tree->getNodeData($root);
289 foreach ($tree->getSubTree($root) as $node)
290 {
291 if ($node["type"] == "blog")
292 {
293 $options[$node["obj_id"]] = $node["title"];
294 }
295 }
296 asort($options);
297 }
298 if(sizeof($options))
299 {
300 $type_blog = new ilRadioOption($this->lng->txt("obj_blog"), "blog");
301 $type->addOption($type_blog);
302
303 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
304 $obj->setRequired(true);
305 $obj->setOptions(array(""=>$this->lng->txt("please_select"))+$options);
306 $type_blog->addSubItem($obj);
307 }
308 else
309 {
310 ilUtil::sendInfo($this->lng->txt("prtf_no_blogs_info"));
311 $type->setValue("page");
312 }
313 }
314
315
316 // portfolio templates
317
318 $opt_tmpl = new ilRadioOption($this->lng->txt("prtf_creation_mode_template"), "mode_tmpl");
319 $main->addOption($opt_tmpl);
320
321 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
323 if(!sizeof($templates))
324 {
325 $opt_tmpl->setDisabled(true);
326 }
327 else
328 {
329 $tmpl = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtt");
330 $tmpl->setRequired(true);
331 $tmpl->setOptions(array(""=>$this->lng->txt("please_select"))+$templates);
332 $opt_tmpl->addSubItem($tmpl);
333
334 // incoming from repository
335 if((int)$_REQUEST["prtt_pre"])
336 {
337 $tmpl->setValue((int)$_REQUEST["prtt_pre"]);
338 $main->setValue("mode_tmpl");
339 }
340 }
341
342
343 $form->setTitle($this->lng->txt("prtf_create_portfolio"));
344 $form->addCommandButton("save", $this->lng->txt("create"));
345 $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
346
347 return $form;
348 }
349
350 public function save()
351 {
352 $form = $this->initCreateForm("prtf");
353 if($form->checkInput())
354 {
355 // trigger portfolio template "import" process
356 if($form->getInput("mode") == "mode_tmpl")
357 {
358 $_REQUEST["pt"] = $form->getInput("title");
359 return $this->createPortfolioFromTemplate();
360 }
361 }
362
363 return parent::save();
364 }
365
366 protected function afterSave(ilObject $a_new_object)
367 {
368 // create 1st page / blog
369 include_once("Modules/Portfolio/classes/class.ilPortfolioPage.php");
370 $page = $this->getPageInstance(null, $a_new_object->getId());
371 if($_POST["ptype"] == "page")
372 {
373 $page->setType(ilPortfolioPage::TYPE_PAGE);
374 $page->setTitle($_POST["fpage"]);
375
376 // use template as basis
377 $layout_id = $_POST["tmpl"];
378 if($layout_id)
379 {
380 include_once("./Services/Style/classes/class.ilPageLayout.php");
381 $layout_obj = new ilPageLayout($layout_id);
382 $page->setXMLContent($layout_obj->getXMLContent());
383 }
384 }
385 else
386 {
387 $page->setType(ilPortfolioPage::TYPE_BLOG);
388 $page->setTitle($_POST["blog"]);
389 }
390 $page->create();
391
392 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
393 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
394 $this->ctrl->redirect($this, "view");
395 }
396
397 protected function toRepository()
398 {
399 global $ilAccess;
400
401 // return to exercise (portfolio assignment)
402 $exc_ref_id = (int)$_REQUEST["exc_id"];
403 if($exc_ref_id &&
404 $ilAccess->checkAccess("read", "", $exc_ref_id))
405 {
406 include_once "Services/Link/classes/class.ilLink.php";
407 ilUtil::redirect(ilLink::_getLink($exc_ref_id, "exc"));
408 }
409
410 $this->ctrl->redirectByClass("ilportfoliorepositorygui", "show");
411 }
412
413 protected function initEditForm()
414 {
415 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
416 $form = new ilPropertyFormGUI();
417 $form->setFormAction($this->ctrl->getFormAction($this));
418
419 // title
420 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
421 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
422 $ti->setMaxLength(ilObject::TITLE_LENGTH);
423 $ti->setRequired(true);
424 $ti->setValue($this->object->getTitle());
425 $form->addItem($ti);
426
427 /* description
428 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
429 $ta->setCols(40);
430 $ta->setRows(2);
431 $ta->setValue($this->object->getDescription());
432 $form->addItem($ta);
433 */
434
435 // :TODO: online
436 $online = new ilCheckboxInputGUI($this->lng->txt("online"), "online");
437 $online->setChecked($this->object->isOnline());
438 $form->addItem($online);
439
440 $this->initEditCustomForm($form);
441
442 $form->setTitle($this->lng->txt("prtf_edit_portfolio"));
443 $form->addCommandButton("update", $this->lng->txt("save"));
444 $form->addCommandButton("view", $this->lng->txt("cancel"));
445
446 return $form;
447 }
448
449 protected function getEditFormCustomValues(array &$a_values)
450 {
451 $a_values["online"] = $this->object->isOnline();
452
453 parent::getEditFormCustomValues($a_values);
454 }
455
456 public function updateCustom(ilPropertyFormGUI $a_form)
457 {
458 $this->object->setOnline($a_form->getInput("online"));
459
460 // if portfolio is not online, it cannot be default
461 if(!$a_form->getInput("online"))
462 {
463 ilObjPortfolio::setUserDefault($this->user_id, 0);
464 }
465
466 parent::updateCustom($a_form);
467 }
468
469
470 //
471 // PAGES
472 //
473
481 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
482 {
483 // #11531
484 if(!$a_portfolio_id && $this->object)
485 {
486 $a_portfolio_id = $this->object->getId();
487 }
488 include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
489 $page = new ilPortfolioPage($a_page_id);
490 $page->setPortfolioId($a_portfolio_id);
491 return $page;
492 }
493
500 protected function getPageGUIInstance($a_page_id)
501 {
502 include_once("Modules/Portfolio/classes/class.ilPortfolioPageGUI.php");
503 $page_gui = new ilPortfolioPageGUI(
504 $this->object->getId(),
505 $a_page_id,
506 0,
507 $this->object->hasPublicComments()
508 );
509 $page_gui->setAdditional($this->getAdditional());
510 return $page_gui;
511 }
512
513 public function getPageGUIClassName()
514 {
515 return "ilportfoliopagegui";
516 }
517
519 {
520 $old = new ilRadioOption($this->lng->txt("prtf_existing_portfolio"), "old");
521 $a_tgt->addOption($old);
522
523 $options = array();
524 $all = ilObjPortfolio::getPortfoliosOfUser($this->user_id);
525 foreach($all as $item)
526 {
527 $options[$item["id"]] = $item["title"];
528 }
529 $prtf = new ilSelectInputGUI($this->lng->txt("portfolio"), "prtf");
530 $prtf->setRequired(true);
531 $prtf->setOptions($options);
532 $old->addSubItem($prtf);
533
534 $new = new ilRadioOption($this->lng->txt("prtf_new_portfolio"), "new");
535 $a_tgt->addOption($new);
536
537 $tf = new ilTextInputGUI($this->lng->txt("title"), "title");
538 $tf->setMaxLength(128);
539 $tf->setSize(40);
540 $tf->setRequired(true);
541 $new->addSubItem($tf);
542 }
543
544
545 //
546 // BLOG
547 //
548
555 public function initBlogForm()
556 {
557 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
558 $form = new ilPropertyFormGUI();
559 $form->setFormAction($this->ctrl->getFormAction($this));
560
561 $options = array();
562 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
563 $tree = new ilWorkspaceTree($this->user_id);
564 $root = $tree->readRootId();
565 if($root)
566 {
567 $root = $tree->getNodeData($root);
568 foreach ($tree->getSubTree($root, true, "blog") as $node)
569 {
570 $options[$node["obj_id"]] = $node["title"];
571 }
572 asort($options);
573 }
574
575 // no blogs to add?
576 if(!sizeof($options))
577 {
578 ilUtil::sendInfo($this->lng->txt("prtf_no_blogs_info"), true);
579 $this->ctrl->redirect($this, "view");
580 }
581
582 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
583 $obj->setRequired(true);
584 $obj->setOptions($options);
585 $form->addItem($obj);
586
587 $form->setTitle($this->lng->txt("prtf_add_blog").": ".
588 $this->object->getTitle());
589 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
590 $form->addCommandButton("view", $this->lng->txt("cancel"));
591
592 return $form;
593 }
594
598 public function saveBlog()
599 {
600 $form = $this->initBlogForm();
601 if ($form->checkInput() && $this->checkPermissionBool("write"))
602 {
603 $page = $this->getPageInstance();
604 $page->setType(ilPortfolioPage::TYPE_BLOG);
605 $page->setTitle($form->getInput("blog"));
606 $page->create();
607
608 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
609 $this->ctrl->redirect($this, "view");
610 }
611
612 $this->tabs_gui->clearTargets();
613 $this->tabs_gui->setBackTarget($this->lng->txt("back"),
614 $this->ctrl->getLinkTarget($this, "view"));
615
616 $form->setValuesByPost();
617 $this->tpl->setContent($form->getHtml());
618 }
619
620
621 //
622 // EXERCISE ASSIGNMENT
623 //
624
625 function getExerciseInfo($a_assignment_id, $a_add_submit = false)
626 {
627 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
628 $ass = new ilExAssignment($a_assignment_id);
629 $exercise_id = $ass->getExerciseId();
630 if(!$exercise_id)
631 {
632 return;
633 }
634
635 // is the assignment still open?
636 $times_up = false;
637 if($ass->getDeadline() && $ass->getDeadline() - time() <= 0)
638 {
639 $times_up = true;
640 }
641
642 // exercise goto
643 include_once "./Services/Link/classes/class.ilLink.php";
644 $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
645 $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
646
647 $info = sprintf($this->lng->txt("prtf_exercise_info"),
648 $ass->getTitle(),
649 "<a href=\"".$exc_link."\">".
650 ilObject::_lookupTitle($exercise_id)."</a>");
651
652 // submit button
653 if($a_add_submit && !$times_up)
654 {
655 $this->ctrl->setParameter($this, "exc", $exercise_id);
656 $this->ctrl->setParameter($this, "ass", $a_assignment_id);
657 $submit_link = $this->ctrl->getLinkTarget($this, "finalize");
658 $this->ctrl->setParameter($this, "ass", "");
659 $this->ctrl->setParameter($this, "exc", "");
660
661 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
662 $button = ilLinkButton::getInstance();
663 $button->setCaption("prtf_finalize_portfolio");
664 $button->setPrimary(true);
665 $button->setUrl($submit_link);
666 $info .= " ".$button->render();
667 }
668
669 // submitted files
670 $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $this->user_id, true);
671 if($submitted)
672 {
673 $submitted = array_pop($submitted);
674
675 $this->ctrl->setParameter($this, "ass", $a_assignment_id);
676 $dl_link = $this->ctrl->getLinkTarget($this, "downloadExcSubFile");
677 $this->ctrl->setParameter($this, "ass", "");
678
681
682 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
683 $button = ilLinkButton::getInstance();
684 $button->setCaption("download");
685 $button->setUrl($dl_link);
686
687 $info .= "<br />".sprintf($this->lng->txt("prtf_exercise_submitted_info"),
689 $button->render());
690
692 }
693
694
695 // work instructions incl. files
696
697 $tooltip = "";
698
699 $ass = $ass->getInstruction();
700 if($ass)
701 {
702 $tooltip .= nl2br($ass);
703 }
704
705 $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id);
706 if (count($ass_files) > 0)
707 {
708 $tooltip .= "<br /><br />";
709
710 foreach($ass_files as $file)
711 {
712 $this->ctrl->setParameter($this, "ass", $a_assignment_id);
713 $this->ctrl->setParameter($this, "file", urlencode($file["name"]));
714 $dl_link = $this->ctrl->getLinkTarget($this, "downloadExcAssFile");
715 $this->ctrl->setParameter($this, "file", "");
716 $this->ctrl->setParameter($this, "ass", "");
717
718 $tooltip .= $file["name"].": <a href=\"".$dl_link."\">".
719 $this->lng->txt("download")."</a>";
720 }
721 }
722
723 if($tooltip)
724 {
725 $ol_id = "exc_ass_".$a_assignment_id;
726
727 include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
728 $overlay = new ilOverlayGUI($ol_id);
729
730 // overlay
731 $overlay->setAnchor($ol_id."_tr");
732 $overlay->setTrigger($ol_id."_tr", "click", $ol_id."_tr");
733 $overlay->setAutoHide(false);
734 // $overlay->setCloseElementId($cl_id);
735 $overlay->add();
736
737 // trigger
738 $overlay->addTrigger($ol_id."_tr", "click", $ol_id."_tr");
739
740 $info .= "<div id=\"".$ol_id."_tr\"><a href=\"#\">".$this->lng->txt("exc_instruction")."</a></div>".
741 "<div id=\"".$ol_id."\" style=\"display:none; background-color:white; border: 1px solid #bbb; padding: 10px;\">".$tooltip."</div>";
742 }
743
744 return $info;
745 }
746
748 {
749 if($_GET["ass"] && $_GET["file"])
750 {
751 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
752 $ass = new ilExAssignment((int)$_GET["ass"]);
753
754 $ass_files = ilExAssignment::getFiles($ass->getExerciseId(), $ass->getId());
755 if (count($ass_files) > 0)
756 {
757 foreach($ass_files as $file)
758 {
759 if($file["name"] == $_GET["file"])
760 {
761 ilUtil::deliverFile($file["fullpath"], $file["name"]);
762 }
763 }
764 }
765 }
766 }
767
769 {
770 if($_GET["ass"])
771 {
772 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
773 $ass = new ilExAssignment((int)$_GET["ass"]);
774
775 $submitted = ilExAssignment::getDeliveredFiles($ass->getExerciseId(), $ass->getId(), $this->user_id);
776 if (count($submitted) > 0)
777 {
778 $submitted = array_pop($submitted);
779
780 $user_data = ilObjUser::_lookupName($submitted["user_id"]);
781 $title = ilObject::_lookupTitle($submitted["obj_id"])." - ".
782 $ass->getTitle()." - ".
783 $user_data["firstname"]." ".
784 $user_data["lastname"]." (".
785 $user_data["login"].").zip";
786
787 ilUtil::deliverFile($submitted["filename"], $title);
788 }
789 }
790 }
791
795 protected function finalize()
796 {
797 // to make exercise gui load assignment
798 $_GET["ass_id"] = $_REQUEST["ass"];
799
800 // #11173 - ref_id is needed for notifications
801 $exc_ref_id = array_shift(ilObject::_getAllReferences($_REQUEST["exc"]));
802
803 include_once "Modules/Exercise/classes/class.ilObjExerciseGUI.php";
804 $exc_gui = new ilObjExerciseGUI(null, $exc_ref_id, true);
805 $exc_gui->submitPortfolio($this->object->getId());
806
807 ilUtil::sendSuccess($this->lng->txt("prtf_finalized"), true);
808 $this->ctrl->redirect($this, "view");
809 }
810
811
812 //
813 // CREATE FROM TEMPLATE
814 //
815
816 protected function createPortfolioFromTemplate(ilPropertyFormGUI $a_form = null)
817 {
818 $title = trim($_REQUEST["pt"]);
819 $prtt_id = (int)$_REQUEST["prtt"];
820
821 // valid template?
822 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
824 if(!sizeof($templates) || !in_array($prtt_id, $templates))
825 {
826 $this->toRepository();
827 }
828 unset($templates);
829
830 $this->ctrl->setParameter($this, "prtt", $prtt_id);
831
832 if(!$a_form)
833 {
834 $a_form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
835 }
836 if($a_form)
837 {
838 $this->tpl->setContent($a_form->getHTML());
839 }
840 else
841 {
843 }
844 }
845
846 protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
847 {
848 global $ilSetting, $ilUser;
849
850 if((int)$_REQUEST["exc_id"])
851 {
852 $this->ctrl->setParameter($this, "exc_id", (int)$_REQUEST["exc_id"]);
853 $this->ctrl->setParameter($this, "ass_id", (int)$_REQUEST["ass_id"]);
854 }
855
856 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
857 $form = new ilPropertyFormGUI();
858 $form->setFormAction($this->ctrl->getFormAction($this));
859
860 $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt"));
861 $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id));
862 $form->addItem($tmpl);
863
864 $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt");
865 $title->setValue($a_title);
866 $form->addItem($title);
867
868 // gather user blogs
869 if(!$ilSetting->get('disable_wsp_blogs'))
870 {
871 $blog_options = array();
872 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
873 $tree = new ilWorkspaceTree($this->user_id);
874 $root = $tree->readRootId();
875 if($root)
876 {
877 $root = $tree->getNodeData($root);
878 foreach ($tree->getSubTree($root, true, "blog") as $node)
879 {
880 $blog_options[$node["obj_id"]] = $node["title"];
881 }
882 asort($blog_options);
883 }
884 }
885
886 $has_form_content = false;
887
888 include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
890 $quota_sum = 0;
891
892 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
893 $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
894 $skill_ids = array();
895
896 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
897 foreach(ilPortfolioTemplatePage::getAllPages($a_prtt_id) as $page)
898 {
899 switch($page["type"])
900 {
902 // skills
903 $source_page = new ilPortfolioTemplatePage($page["id"]);
904 $source_page->buildDom(true);
905 $dom = $source_page->getDom();
906 if($dom instanceof php4DOMDocument)
907 {
908 $dom = $dom->myDOMDocument;
909 }
910 $xpath = new DOMXPath($dom);
911 $nodes = $xpath->query("//PageContent/Skills");
912 foreach($nodes as $node)
913 {
914 $skill_id = $node->getAttribute("Id");
915 if(!in_array($skill_id, $pskills))
916 {
917 $skill_ids[] = $skill_id;
918 }
919 }
920 unset($nodes);
921 unset($xpath);
922 unset($dom);
923 if($check_quota)
924 {
925 $quota_sum += $source_page->getPageDiskSize();
926 }
927 if(sizeof($skill_ids))
928 {
929 $has_form_content = true;
930 }
931 break;
932
934 if(!$ilSetting->get('disable_wsp_blogs'))
935 {
936 $has_form_content = true;
937
938 $field_id = "blog_".$page["id"];
939
940 $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog").": ".
941 $page["title"], $field_id);
942 $blog->setRequired(true);
943 $blog->setValue("blog_create");
944 $form->addItem($blog);
945
946 $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create");
947 $blog->addOption($new_blog);
948
949 $title = new ilTextInputGUI($this->lng->txt("title"), $field_id."_create_title");
950 $title->setRequired(true);
951 $new_blog->addSubItem($title);
952
953 if(sizeof($blog_options))
954 {
955 $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse");
956 $blog->addOption($reuse_blog);
957
958 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id."_reuse_blog");
959 $obj->setRequired(true);
960 $obj->setOptions(array(""=>$this->lng->txt("please_select"))+$blog_options);
961 $reuse_blog->addSubItem($obj);
962 }
963
964 $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore"));
965 }
966 break;
967 }
968 }
969
970 if($skill_ids)
971 {
972 include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
973 $skills = new ilCheckboxGroupInputGUI($this->lng->txt("skills"), "skill_ids");
974 $skills->setInfo($this->lng->txt("prtf_template_import_new_skills"));
975 $skills->setValue($skill_ids);
976 foreach($skill_ids as $skill_id)
977 {
978 $skills->addOption(new ilCheckboxOption(ilSkillTreeNode::_lookupTitle($skill_id), $skill_id));
979 }
980 $form->addItem($skills);
981 }
982
983 if($quota_sum)
984 {
985 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
987 {
988 ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true);
989 $this->ctrl->redirect($this, "create");
990 }
991 }
992
993 // no dialog needed, go ahead
994 if(!$has_form_content)
995 {
996 return;
997 }
998
999 $form->setTitle($this->lng->txt("prtf_creation_mode").": ".$this->lng->txt("prtf_creation_mode_template"));
1000 $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue"));
1001 $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
1002
1003 return $form;
1004 }
1005
1006 protected function createPortfolioFromTemplateProcess($a_process_form = true)
1007 {
1008 global $ilSetting, $ilUser, $ilAccess;
1009
1010 $title = trim($_REQUEST["pt"]);
1011 $prtt_id = (int)$_REQUEST["prtt"];
1012
1013 // valid template?
1014 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
1016 if(!sizeof($templates) || !in_array($prtt_id, $templates))
1017 {
1018 $this->toRepository();
1019 }
1020 unset($templates);
1021
1022 // build page recipe (aka import form values)
1023 $recipe = null;
1024 if($a_process_form)
1025 {
1026 $this->ctrl->setParameter($this, "prtt", $prtt_id);
1027
1028 $form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
1029 if($form->checkInput())
1030 {
1031 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
1032 foreach(ilPortfolioTemplatePage::getAllPages($prtt_id) as $page)
1033 {
1034 switch($page["type"])
1035 {
1037 if(!$ilSetting->get('disable_wsp_blogs'))
1038 {
1039 $field_id = "blog_".$page["id"];
1040 switch($form->getInput($field_id))
1041 {
1042 case "blog_create":
1043 $recipe[$page["id"]] = array("blog", "create",
1044 trim($form->getInput($field_id."_create_title")));
1045 break;
1046
1047 case "blog_resuse":
1048 $recipe[$page["id"]] = array("blog", "reuse",
1049 (int)$form->getInput($field_id."_reuse_blog"));
1050 break;
1051
1052 case "blog_ignore":
1053 $recipe[$page["id"]] = array("blog", "ignore");
1054 break;
1055 }
1056 }
1057 break;
1058 }
1059 }
1060
1061 $recipe["skills"] = (array)$form->getInput("skill_ids");
1062 }
1063 else
1064 {
1065 $form->setValuesByPost();
1066 return $this->createPortfolioFromTemplate($form);
1067 }
1068 }
1069
1070 $source = new ilObjPortfolioTemplate($prtt_id, false);
1071
1072 // create portfolio
1073 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
1074 $target = new ilObjPortfolio();
1075 $target->setTitle($title);
1076 $target->create();
1077 $target_id = $target->getId();
1078
1079 $source->clonePagesAndSettings($source, $target, $recipe);
1080
1081 // link portfolio to exercise assignment
1082 $exc_ref_id = (int)$_REQUEST["exc_id"];
1083 $ass_id = (int)$_REQUEST["ass_id"];
1084 if($exc_ref_id &&
1085 $ass_id &&
1086 $ilAccess->checkAccess("read", "", $exc_ref_id))
1087 {
1088 include_once "Modules/Exercise/classes/class.ilObjExercise.php";
1089 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
1090 $exc = new ilObjExercise($exc_ref_id);
1091 $ass = new ilExAssignment($ass_id);
1092 if($ass->getExerciseId() == $exc->getId() &&
1093 $ass->getType() == ilExAssignment::TYPE_PORTFOLIO)
1094 {
1095 $exc->addResourceObject($target_id, $ass_id, $ilUser->getId());
1096 }
1097 }
1098
1099 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
1100 $this->ctrl->setParameter($this, "prt_id", $target_id);
1101 $this->ctrl->redirect($this, "view");
1102 }
1103
1104 public static function _goto($a_target)
1105 {
1106 $id = explode("_", $a_target);
1107
1108 $_GET["baseClass"] = "ilsharedresourceGUI";
1109 $_GET["prt_id"] = $id[0];
1110 if(sizeof($id) == 2)
1111 {
1112 $_GET["gtp"] = $id[1];
1113 }
1114
1115 include("ilias.php");
1116 exit;
1117 }
1118}
1119
1120?>
print $file
$_GET["client_id"]
const IL_CAL_DATETIME
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 setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
static isUploadPossible($a_additional_size=null)
Exercise assignment.
static getFiles($a_exc_id, $a_ass_id)
Get files.
getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id, $a_filter_empty_filename=false)
was: getDeliveredFiles($a_member_id)
setPersonalWorkspaceQuotaCheck($a_value)
This class represents a property in a property form.
static getInstance()
Factory.
This class represents a non editable value in a property form.
Class ilObjExerciseGUI.
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.
initCopyPageFormOptions(ilFormPropertyGUI $a_tgt)
finalize()
Finalize and submit portfolio to exercise.
getExerciseInfo($a_assignment_id, $a_add_submit=false)
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.
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.
static _lookupName($a_user_id)
lookup user name
checkPermission($a_perm, $a_cmd="")
Class ilObject Basic functions for all objects.
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
This is a utility class for the yui overlays.
Class ilPageLayout.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
Portfolio page gui class.
Page for user portfolio.
static getAllPages($a_portfolio_id)
Get pages of portfolio.
Page for portfolio template.
This class represents a property form user interface.
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)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
Tree handler for personal workspace.
$_POST['username']
Definition: cron.php:12
$target_id
Definition: goto.php:88
exit
Definition: login.php:54
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15