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