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