ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjPortfolioGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
15 {
19  protected $help;
20 
21  protected $ws_access; // [ilWorkspaceAccessHandler]
22 
26  protected $ui;
27 
31  protected $tool_context;
32 
37 
38  public function __construct($a_id = 0)
39  {
40  global $DIC;
41 
42  $this->lng = $DIC->language();
43  $this->help = $DIC["ilHelp"];
44  $this->settings = $DIC->settings();
45  $this->access = $DIC->access();
46  $this->user = $DIC->user();
47  $this->ctrl = $DIC->ctrl();
48  $this->ui = $DIC->ui();
49 
50  $this->tool_context = $DIC->globalScreen()->tool()->context();
51 
52  parent::__construct($a_id, self::PORTFOLIO_OBJECT_ID, 0);
53  $this->declaration_authorship = new ilPortfolioDeclarationOfAuthorship();
54 
55  $this->ctrl->saveParameter($this, "exc_back_ref_id");
56  }
57 
58  public function getType()
59  {
60  return "prtf";
61  }
62 
63  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_node_id = null)
64  {
65  if ($a_perm == "create") {
66  return true;
67  }
68  if (!$a_node_id) {
69  $a_node_id = $this->obj_id;
70  }
71  return $this->access_handler->checkAccess($a_perm, "", $a_node_id);
72  }
73 
74  public function executeCommand()
75  {
76  $lng = $this->lng;
77 
78  $this->checkPermission("read");
79 
80  $this->setTitleAndDescription();
81 
82  $next_class = $this->ctrl->getNextClass($this);
83  $cmd = $this->ctrl->getCmd("view");
84 
85  // we have to init the note js handling here, might go to
86  // a better place in the future
88  $this->ctrl->getLinkTargetByClass(
89  array("ilnotegui"),
90  "",
91  "",
92  true,
93  false
94  )
95  );
96 
97  // trigger assignment tool
98  $this->triggerAssignmentTool();
99 
100  switch ($next_class) {
101  case "ilworkspaceaccessgui":
102  if ($this->checkPermissionBool("write")) {
103  $this->setTabs();
104  $this->tabs_gui->activateTab("share");
105 
106  if ($this->access_handler->getPermissions($this->object->getId()) &&
107  !$this->object->isOnline()) {
108  //ilUtil::sendInfo($lng->txt("prtf_shared_offline_info"));
109  }
110 
111  $this->tpl->setPermanentLink("prtf", $this->object->getId());
112 
113  $wspacc = new ilWorkspaceAccessGUI($this->object->getId(), $this->access_handler, true);
114  $wspacc->setBlockingMessage($this->getOfflineMessage());
115  $this->ctrl->forwardCommand($wspacc);
116  }
117  break;
118 
119  case 'ilportfoliopagegui':
120  if ($this->determinePageCall()) {
121  // only in edit mode
122  $this->addLocator();
123  }
124  $this->handlePageCall($cmd);
125  break;
126 
127  case "ilnotegui":
128  $this->preview();
129  break;
130 
131  case "ilobjstylesheetgui":
132  $this->ctrl->setReturn($this, "editStyleProperties");
133  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
134  $style_gui->enableWrite(true);
135  $style_gui->omitLocator();
136  if ($cmd == "create" || $_GET["new_type"] == "sty") {
137  $style_gui->setCreationMode(true);
138  }
139 
140  if ($cmd == "confirmedDelete") {
141  $this->object->setStyleSheetId(0);
142  $this->object->update();
143  }
144 
145  $ret = $this->ctrl->forwardCommand($style_gui);
146 
147  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
148  $style_id = $ret;
149  $this->object->setStyleSheetId($style_id);
150  $this->object->update();
151  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
152  }
153  break;
154 
155  case "ilportfolioexercisegui":
156  $this->ctrl->setReturn($this, "view");
157  $gui = new ilPortfolioExerciseGUI($this->user_id, $this->object->getId());
158  $this->ctrl->forwardCommand($gui);
159  break;
160 
161  default:
162 
163  if ($cmd != "preview") {
164  $this->addLocator();
165  $this->setTabs();
166  }
167  $this->$cmd();
168  break;
169  }
170 
171  return true;
172  }
173 
179  protected function triggerAssignmentTool()
180  {
181  if (!is_object($this->object) || $this->object->getId() <= 0) {
182  return;
183  }
184  $pe = new ilPortfolioExercise($this->user_id, $this->object->getId());
185  $pe_gui = new ilPortfolioExerciseGUI($this->user_id, $this->object->getId());
186  $assignments = $pe->getAssignmentsOfPortfolio();
187  if (count($assignments) > 0) {
188  $ass_ids = array_map(function ($i) {
189  return $i["ass_id"];
190  }, $assignments);
191  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
192  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
193  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_BUTTONS, $pe_gui->getActionButtons());
194  }
195  }
196 
197  protected function setTabs()
198  {
199  $ilHelp = $this->help;
200 
201  $ilHelp->setScreenIdComponent("prtf");
202 
203  if ($this->checkPermissionBool("write")) {
204  $this->tabs_gui->addTab(
205  "pages",
206  $this->lng->txt("content"),
207  $this->ctrl->getLinkTarget($this, "view")
208  );
209 
210  $this->tabs_gui->addTab(
211  "settings",
212  $this->lng->txt("settings"),
213  $this->ctrl->getLinkTarget($this, "edit")
214  );
215 
216  $this->tabs_gui->addNonTabbedLink(
217  "preview",
218  $this->lng->txt("preview"),
219  $this->ctrl->getLinkTarget($this, "preview")
220  );
221 
222  $this->lng->loadLanguageModule("wsp");
223  $this->tabs_gui->addTab(
224  "share",
225  $this->lng->txt("wsp_permissions"),
226  $this->ctrl->getLinkTargetByClass("ilworkspaceaccessgui", "share")
227  );
228  }
229  }
230 
231  protected function addLocator()
232  {
233  if (!$this->creation_mode) {
234  $this->ctrl->setParameter($this, "prt_id", $this->object->getId());
235  }
236 
237  parent::addLocatorItems();
238 
239  $this->tpl->setLocator();
240  }
241 
242  protected function setTitleAndDescription()
243  {
244  // parent::setTitleAndDescription();
245 
246  $title = $this->lng->txt("portfolio");
247  if ($this->object) {
248  $title .= ": " . $this->object->getTitle();
249  }
250  $this->tpl->setTitle($title);
251  $this->tpl->setTitleIcon(
252  ilUtil::getImagePath("icon_prtf.svg"),
253  $this->lng->txt("portfolio")
254  );
255 
256  if ($this->object &&
257  !$this->object->isOnline()) {
258  $this->tpl->setAlertProperties(array(
259  array("alert" => true,
260  "property" => $this->lng->txt("status"),
261  "value" => $this->lng->txt("offline"))
262  ));
263  }
264  }
265 
266 
267  //
268  // CREATE/EDIT
269  //
270 
276  public function create()
277  {
278  $tpl = $this->tpl;
280 
281  $new_type = $_REQUEST["new_type"];
282 
283  // add new object to custom parent container
284  $this->ctrl->saveParameter($this, "crtptrefid");
285  // use forced callback after object creation
286  $this->ctrl->saveParameter($this, "crtcb");
287 
288  if (!$this->checkPermissionBool("create", "", $new_type)) {
289  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
290  } else {
291  $this->lng->loadLanguageModule($new_type);
292  $this->ctrl->setParameter($this, "new_type", $new_type);
293 
294  $forms = $this->initCreationForms($new_type);
295 
296  // copy form validation error: do not show other creation forms
297  if ($_GET["cpfl"] && isset($forms[self::CFORM_CLONE])) {
298  $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
299  }
300  $tpl->setContent($this->getCreateInfoMessage() . $this->getCreationFormsHTML($forms));
301  }
302  }
303 
310  protected function getCreateInfoMessage()
311  {
312  global $DIC;
313 
314  $ctrl = $this->ctrl;
315  $lng = $this->lng;
316  $ui = $DIC->ui();
317  $ilSetting = $DIC->settings();
318 
319  $message = "";
320  // page type: blog
321  if (!$ilSetting->get('disable_wsp_blogs')) {
322  $options = array();
323  $tree = new ilWorkspaceTree($this->user_id);
324  $root = $tree->readRootId();
325  if ($root) {
326  $root = $tree->getNodeData($root);
327  foreach ($tree->getSubTree($root) as $node) {
328  if ($node["type"] == "blog") {
329  $options[$node["obj_id"]] = $node["title"];
330  }
331  }
332  asort($options);
333  }
334  if (!sizeof($options)) {
335 
336  // #18147
337  $this->lng->loadLanguageModule('pd');
338  $url = $this->ctrl->getLinkTargetByClass("ilDashboardGUI", "jumpToWorkspace");
339  $text = $this->lng->txt("mm_personal_and_shared_r");
340 
341  $text = sprintf($this->lng->txt("prtf_no_blogs_info"), $text);
342 
343  $mbox = $ui->factory()->messageBox()->info($text)
344  ->withLinks([$ui->factory()->link()->standard(
345  $this->lng->txt("mm_personal_and_shared_r"),
346  $url
347  )]);
348 
349  $message = $ui->renderer()->render($mbox);
350  }
351  }
352  return $message;
353  }
354 
355 
356  protected function initCreationForms($a_new_type)
357  {
358  return array(self::CFORM_NEW => $this->initCreateForm($a_new_type));
359  }
360 
361  protected function initCreateForm($a_new_type)
362  {
364 
365  $this->ctrl->setParameter($this, "new_type", $this->getType());
366 
367  $form = new ilPropertyFormGUI();
368  $form->setFormAction($this->ctrl->getFormAction($this));
369 
370  // title
371  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
372  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
373  $ti->setMaxLength(ilObject::TITLE_LENGTH);
374  $ti->setRequired(true);
375  $form->addItem($ti);
376 
377  $main = new ilRadioGroupInputGUI($this->lng->txt("prtf_creation_mode"), "mode");
378  $main->setValue("mode_scratch");
379  $form->addItem($main);
380 
381  $opt_scratch = new ilRadioOption($this->lng->txt("prtf_creation_mode_scratch"), "mode_scratch");
382  $main->addOption($opt_scratch);
383 
384 
385  // 1st page
386 
387  $type = new ilRadioGroupInputGUI($this->lng->txt("prtf_first_page_title"), "ptype");
388  $type->setRequired(true);
389  $opt_scratch->addSubItem($type);
390 
391  $type_page = new ilRadioOption($this->lng->txt("page"), "page");
392  $type->addOption($type_page);
393 
394  // page type: page
395  $tf = new ilTextInputGUI($this->lng->txt("title"), "fpage");
396  $tf->setMaxLength(128);
397  $tf->setSize(40);
398  $tf->setRequired(true);
399  $type_page->addSubItem($tf);
400 
401  // page templates
403  if ($templates) {
404  $options = array(0 => $this->lng->txt("none"));
405  foreach ($templates as $templ) {
406  $templ->readObject();
407  $options[$templ->getId()] = $templ->getTitle();
408  }
409 
410  $use_template = new ilSelectInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
411  $use_template->setRequired(true);
412  $use_template->setOptions($options);
413  $type_page->addSubItem($use_template);
414  }
415 
416  // page type: blog
417  if (!$ilSetting->get('disable_wsp_blogs')) {
418  $options = array();
419  $tree = new ilWorkspaceTree($this->user_id);
420  $root = $tree->readRootId();
421  if ($root) {
422  $root = $tree->getNodeData($root);
423  foreach ($tree->getSubTree($root) as $node) {
424  if ($node["type"] == "blog") {
425  $options[$node["obj_id"]] = $node["title"];
426  }
427  }
428  asort($options);
429  }
430  if (sizeof($options)) {
431  $type_blog = new ilRadioOption($this->lng->txt("obj_blog"), "blog");
432  $type->addOption($type_blog);
433 
434  $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
435  $obj->setRequired(true);
436  $obj->setOptions(array("" => $this->lng->txt("please_select")) + $options);
437  $type_blog->addSubItem($obj);
438  } else {
439  $type->setValue("page");
440  }
441  }
442 
443 
444  // portfolio templates
445 
446  $opt_tmpl = new ilRadioOption($this->lng->txt("prtf_creation_mode_template"), "mode_tmpl");
447  $main->addOption($opt_tmpl);
448 
450  if (!sizeof($templates)) {
451  $opt_tmpl->setDisabled(true);
452  } else {
453  $tmpl = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtt");
454  $tmpl->setRequired(true);
455  $tmpl->setOptions(array("" => $this->lng->txt("please_select")) + $templates);
456  $opt_tmpl->addSubItem($tmpl);
457 
458  // incoming from repository
459  if ((int) $_REQUEST["prtt_pre"]) {
460  $tmpl->setValue((int) $_REQUEST["prtt_pre"]);
461  $main->setValue("mode_tmpl");
462  }
463  }
464 
465 
466  $form->setTitle($this->lng->txt("prtf_create_portfolio"));
467  $form->addCommandButton("save", $this->lng->txt("create"));
468  $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
469 
470  return $form;
471  }
472 
473  public function save()
474  {
475  $form = $this->initCreateForm("prtf");
476  if ($form->checkInput()) {
477  // trigger portfolio template "import" process
478  if ($form->getInput("mode") == "mode_tmpl") {
479  $_REQUEST["pt"] = $form->getInput("title");
480  $_REQUEST["prtt_pre"] = (int) $_REQUEST["prtt"];
481  return $this->createFromTemplateDirect($form->getInput("title"));
482  //return $this->createPortfolioFromTemplate();
483  }
484  }
485 
486  return parent::save();
487  }
488 
489  protected function afterSave(ilObject $a_new_object)
490  {
491  // create 1st page / blog
492  $page = $this->getPageInstance(null, $a_new_object->getId());
493  if ($_POST["ptype"] == "page") {
494  $page->setType(ilPortfolioPage::TYPE_PAGE);
495  $page->setTitle($_POST["fpage"]);
496 
497  // use template as basis
498  $layout_id = $_POST["tmpl"];
499  if ($layout_id) {
500  $layout_obj = new ilPageLayout($layout_id);
501  $page->setXMLContent($layout_obj->getXMLContent());
502  }
503  } else {
504  $page->setType(ilPortfolioPage::TYPE_BLOG);
505  $page->setTitle($_POST["blog"]);
506  }
507  $page->create();
508 
509  ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
510  $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
511  $this->ctrl->redirect($this, "view");
512  }
513 
514  protected function toRepository()
515  {
516  $ilAccess = $this->access;
517 
518  // return to exercise (portfolio assignment)
519  $exc_ref_id = (int) $_REQUEST["exc_id"];
520  if ($exc_ref_id &&
521  $ilAccess->checkAccess("read", "", $exc_ref_id)) {
522  ilUtil::redirect(ilLink::_getLink($exc_ref_id, "exc"));
523  }
524 
525  $this->ctrl->redirectByClass("ilportfoliorepositorygui", "show");
526  }
527 
528  protected function initEditForm()
529  {
530  $form = new ilPropertyFormGUI();
531  $form->setFormAction($this->ctrl->getFormAction($this));
532 
533  // title
534  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
535  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
536  $ti->setMaxLength(ilObject::TITLE_LENGTH);
537  $ti->setRequired(true);
538  $ti->setValue($this->object->getTitle());
539  $form->addItem($ti);
540 
541  /* description
542  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
543  $ta->setCols(40);
544  $ta->setRows(2);
545  $ta->setValue($this->object->getDescription());
546  $form->addItem($ta);
547  */
548 
549  // :TODO: online
550  $online = new ilCheckboxInputGUI($this->lng->txt("online"), "online");
551  $online->setChecked($this->object->isOnline());
552  $form->addItem($online);
553 
554  $this->initEditCustomForm($form);
555 
556  $form->setTitle($this->lng->txt("prtf_edit_portfolio"));
557  $form->addCommandButton("update", $this->lng->txt("save"));
558  $form->addCommandButton("view", $this->lng->txt("cancel"));
559 
560  return $form;
561  }
562 
563  protected function getEditFormCustomValues(array &$a_values)
564  {
565  $a_values["online"] = $this->object->isOnline();
566 
567  parent::getEditFormCustomValues($a_values);
568  }
569 
570  public function updateCustom(ilPropertyFormGUI $a_form)
571  {
572  $this->object->setOnline($a_form->getInput("online"));
573 
574  // if portfolio is not online, it cannot be default
575  if (!$a_form->getInput("online")) {
576  ilObjPortfolio::setUserDefault($this->user_id, 0);
577  }
578 
579  parent::updateCustom($a_form);
580  }
581 
582 
583  //
584  // PAGES
585  //
586 
594  protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
595  {
596  // #11531
597  if (!$a_portfolio_id && $this->object) {
598  $a_portfolio_id = $this->object->getId();
599  }
600  $page = new ilPortfolioPage($a_page_id);
601  $page->setPortfolioId($a_portfolio_id);
602  return $page;
603  }
604 
611  protected function getPageGUIInstance($a_page_id)
612  {
613  $page_gui = new ilPortfolioPageGUI(
614  $this->object->getId(),
615  $a_page_id,
616  0,
617  $this->object->hasPublicComments()
618  );
619  $page_gui->setAdditional($this->getAdditional());
620  return $page_gui;
621  }
622 
623  public function getPageGUIClassName()
624  {
625  return "ilportfoliopagegui";
626  }
627 
628  protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
629  {
630  $a_tgt = new ilRadioGroupInputGUI($this->lng->txt("target"), "target");
631  $a_tgt->setRequired(true);
632  $a_form->addItem($a_tgt);
633 
634  $old = new ilRadioOption($this->lng->txt("prtf_existing_portfolio"), "old");
635  $a_tgt->addOption($old);
636 
637  $options = array();
638  $all = ilObjPortfolio::getPortfoliosOfUser($this->user_id);
639  foreach ($all as $item) {
640  $options[$item["id"]] = $item["title"];
641  }
642  $prtf = new ilSelectInputGUI($this->lng->txt("portfolio"), "prtf");
643  $prtf->setRequired(true);
644  $prtf->setOptions($options);
645  $old->addSubItem($prtf);
646 
647  $new = new ilRadioOption($this->lng->txt("prtf_new_portfolio"), "new");
648  $a_tgt->addOption($new);
649 
650  $tf = new ilTextInputGUI($this->lng->txt("title"), "title");
651  $tf->setMaxLength(128);
652  $tf->setSize(40);
653  $tf->setRequired(true);
654  $new->addSubItem($tf);
655  }
656 
657 
658  //
659  // BLOG
660  //
661 
668  public function initBlogForm()
669  {
670  $form = new ilPropertyFormGUI();
671  $form->setFormAction($this->ctrl->getFormAction($this));
672 
673  $options = array();
674  $tree = new ilWorkspaceTree($this->user_id);
675  $root = $tree->readRootId();
676  if ($root) {
677  $root = $tree->getNodeData($root);
678  foreach ($tree->getSubTree($root, true, "blog") as $node) {
679  $options[$node["obj_id"]] = $node["title"];
680  }
681  asort($options);
682  }
683 
684  // add blog
685  $radg = new ilRadioGroupInputGUI($this->lng->txt("obj_blog"), "creation_mode");
686  $radg->setInfo($this->lng->txt(""));
687  $radg->setValue("new");
688  $radg->setInfo($this->lng->txt(""));
689 
690  $op1 = new ilRadioOption($this->lng->txt("prtf_add_new_blog"), "new", $this->lng->txt("prtf_add_new_blog_info"));
691  $radg->addOption($op1);
692  $form->addItem($radg);
693 
694  // Blog title
695  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
696  $ti->setRequired(true);
697  $op1->addSubItem($ti);
698 
699 
700  if (sizeof($options)) {
701  $op2 = new ilRadioOption($this->lng->txt("prtf_add_existing_blog"), "existing");
702  $radg->addOption($op2);
703 
704  $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
705  $obj->setOptions($options);
706  $op2->addSubItem($obj);
707  }
708 
709  $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
710  $this->object->getTitle());
711  $form->addCommandButton("saveBlog", $this->lng->txt("save"));
712  $form->addCommandButton("view", $this->lng->txt("cancel"));
713 
714  return $form;
715  }
716 
720  public function saveBlog()
721  {
722  global $DIC;
723 
724  $ilUser = $DIC->user();
725 
726  $form = $this->initBlogForm();
727  if ($form->checkInput() && $this->checkPermissionBool("write")) {
728  if ($form->getInput("creation_mode") == "existing") {
729  $page = $this->getPageInstance();
730  $page->setType(ilPortfolioPage::TYPE_BLOG);
731  $page->setTitle($form->getInput("blog"));
732  $page->create();
733  } else {
734  $blog = new ilObjBlog();
735  $blog->setTitle($form->getInput("title"));
736  $blog->create();
737 
738  $tree = new ilWorkspaceTree($ilUser->getId());
739 
740  // @todo: see also e.g. ilExSubmissionObjectGUI->getOverviewContentBlog, this needs refactoring, consumer should not
741  // be responsibel to handle this
742  if (!$tree->getRootId()) {
743  $tree->createTreeForUser($ilUser->getId());
744  }
745 
747  $node_id = $tree->insertObject($tree->readRootId(), $blog->getId());
748  $access_handler->setPermissions($tree->readRootId(), $node_id);
749 
750  $page = $this->getPageInstance();
751  $page->setType(ilPortfolioPage::TYPE_BLOG);
752  $page->setTitle($blog->getId());
753  $page->create();
754  }
755 
756  ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
757  $this->ctrl->redirect($this, "view");
758  }
759 
760  $this->tabs_gui->clearTargets();
761  $this->tabs_gui->setBackTarget(
762  $this->lng->txt("back"),
763  $this->ctrl->getLinkTarget($this, "view")
764  );
765 
766  $form->setValuesByPost();
767  $this->tpl->setContent($form->getHtml());
768  }
769 
770 
771  //
772  // CREATE FROM TEMPLATE
773  //
774 
775  protected function createPortfolioFromTemplate(ilPropertyFormGUI $a_form = null)
776  {
777  $title = trim($_REQUEST["pt"]);
778  $prtt_id = (int) $_REQUEST["prtt"];
779 
780  // valid template?
782  if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
783  $this->toRepository();
784  }
785  unset($templates);
786 
787  $this->ctrl->setParameter($this, "prtt", $prtt_id);
788 
789  if (!$a_form) {
790  $a_form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
791  }
792  if ($a_form) {
793  $this->tpl->setContent($a_form->getHTML());
794  } else {
796  }
797  }
798 
799  protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
800  {
803 
804  if ((int) $_REQUEST["exc_id"]) {
805  $this->ctrl->setParameter($this, "exc_id", (int) $_REQUEST["exc_id"]);
806  $this->ctrl->setParameter($this, "ass_id", (int) $_REQUEST["ass_id"]);
807  }
808 
809  $form = new ilPropertyFormGUI();
810  $form->setFormAction($this->ctrl->getFormAction($this));
811 
812  $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt"));
813  $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id));
814  $form->addItem($tmpl);
815 
816  $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt");
817  $title->setValue($a_title);
818  $form->addItem($title);
819 
820  // gather user blogs
821  if (!$ilSetting->get('disable_wsp_blogs')) {
822  $blog_options = array();
823  $tree = new ilWorkspaceTree($this->user_id);
824  $root = $tree->readRootId();
825  if ($root) {
826  $root = $tree->getNodeData($root);
827  foreach ($tree->getSubTree($root, true, "blog") as $node) {
828  $blog_options[$node["obj_id"]] = $node["title"];
829  }
830  asort($blog_options);
831  }
832  }
833 
834  $has_form_content = false;
835 
836  $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
837  $skill_ids = array();
838 
839  foreach (ilPortfolioTemplatePage::getAllPortfolioPages($a_prtt_id) as $page) {
840  switch ($page["type"]) {
842  // skills
843  $source_page = new ilPortfolioTemplatePage($page["id"]);
844  $source_page->buildDom(true);
845  $skill_ids = $this->getSkillsToPortfolioAssignment($pskills, $skill_ids, $source_page);
846 
847  if (sizeof($skill_ids)) {
848  $has_form_content = true;
849  }
850  break;
851 
853  if (!$ilSetting->get('disable_wsp_blogs')) {
854  $has_form_content = true;
855 
856  $field_id = "blog_" . $page["id"];
857 
858  $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog") . ": " .
859  $page["title"], $field_id);
860  $blog->setRequired(true);
861  $blog->setValue("blog_create");
862  $form->addItem($blog);
863 
864  $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create");
865  $blog->addOption($new_blog);
866 
867  $title = new ilTextInputGUI($this->lng->txt("title"), $field_id . "_create_title");
868  $title->setRequired(true);
869  $new_blog->addSubItem($title);
870 
871  if (sizeof($blog_options)) {
872  $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse");
873  $blog->addOption($reuse_blog);
874 
875  $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id . "_reuse_blog");
876  $obj->setRequired(true);
877  $obj->setOptions(array("" => $this->lng->txt("please_select")) + $blog_options);
878  $reuse_blog->addSubItem($obj);
879  }
880 
881  $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore"));
882  }
883  break;
884  }
885  }
886 
887  if ($skill_ids) {
888  $skills = new ilCheckboxGroupInputGUI($this->lng->txt("skills"), "skill_ids");
889  $skills->setInfo($this->lng->txt("prtf_template_import_new_skills"));
890  $skills->setValue($skill_ids);
891  foreach ($skill_ids as $skill_id) {
892  $skills->addOption(new ilCheckboxOption(ilSkillTreeNode::_lookupTitle($skill_id), $skill_id));
893  }
894  $form->addItem($skills);
895  }
896  // no dialog needed, go ahead
897  if (!$has_form_content) {
898  return;
899  }
900 
901  $form->setTitle($this->lng->txt("prtf_creation_mode") . ": " . $this->lng->txt("prtf_creation_mode_template"));
902  $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue"));
903  $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
904 
905  return $form;
906  }
907 
908  protected function createPortfolioFromTemplateProcess($a_process_form = true)
909  {
912  $ilAccess = $this->access;
913 
914  $title = trim($_REQUEST["pt"]);
915  $prtt_id = (int) $_REQUEST["prtt"];
916 
917  // valid template?
919  if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
920  $this->toRepository();
921  }
922  unset($templates);
923 
924  // build page recipe (aka import form values)
925  $recipe = null;
926  if ($a_process_form) {
927  $this->ctrl->setParameter($this, "prtt", $prtt_id);
928 
929  $form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
930  if ($form->checkInput()) {
931  foreach (ilPortfolioTemplatePage::getAllPortfolioPages($prtt_id) as $page) {
932  switch ($page["type"]) {
934  if (!$ilSetting->get('disable_wsp_blogs')) {
935  $field_id = "blog_" . $page["id"];
936  switch ($form->getInput($field_id)) {
937  case "blog_create":
938  $recipe[$page["id"]] = array("blog", "create",
939  trim($form->getInput($field_id . "_create_title")));
940  break;
941 
942  case "blog_resuse":
943  $recipe[$page["id"]] = array("blog", "reuse",
944  (int) $form->getInput($field_id . "_reuse_blog"));
945  break;
946 
947  case "blog_ignore":
948  $recipe[$page["id"]] = array("blog", "ignore");
949  break;
950  }
951  }
952  break;
953  }
954  }
955 
956  $recipe["skills"] = (array) $form->getInput("skill_ids");
957  } else {
958  $form->setValuesByPost();
959  return $this->createPortfolioFromTemplate($form);
960  }
961  }
962 
963  $source = new ilObjPortfolioTemplate($prtt_id, false);
964 
965  // create portfolio
966  $target = new ilObjPortfolio();
967  $target->setTitle($title);
968  $target->create();
969  $target_id = $target->getId();
970 
971  $source->clonePagesAndSettings($source, $target, $recipe);
972 
973  // link portfolio to exercise assignment
975 
976  ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created_from_template"), true);
977  $this->ctrl->setParameter($this, "prt_id", $target_id);
978  $this->ctrl->redirect($this, "preview");
979  }
980 
984  protected function createFromTemplateDirect($title = "")
985  {
986  $prtt_id = (int) $_REQUEST["prtt_pre"];
987  if ($title == "") {
988  $title = ilObject::_lookupTitle($prtt_id);
989  }
990 
991  // valid template?
993  if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
994  $this->toRepository();
995  }
996  unset($templates);
997 
998  $source = new ilObjPortfolioTemplate($prtt_id, false);
999 
1000  // create portfolio
1001  $target = new ilObjPortfolio();
1002  $target->setTitle($title);
1003  $target->create();
1004  $target_id = $target->getId();
1005 
1006  $source->clonePagesAndSettings($source, $target, null, true);
1007 
1008  // link portfolio to exercise assignment
1009  //$this->linkPortfolioToAssignment($target_id);
1010 
1011  ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created_from_template"), true);
1012  $this->ctrl->setParameter($this, "prt_id", $target_id);
1013  $this->ctrl->redirect($this, "preview");
1014  }
1015 
1016 
1017  public static function _goto($a_target)
1018  {
1020  global $DIC;
1021 
1022  $ctrl = $DIC->ctrl();
1023 
1024  $id = explode("_", $a_target);
1025 
1026  $_GET["baseClass"] = "ilsharedresourceGUI";
1027  $ctrl->setParameterByClass("ilobjportfoliogui", "prt_id", $id[0]);
1028  if (sizeof($id) == 2) {
1029  $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $id[1]);
1030  }
1031  $ctrl->redirectByClass(["ilsharedresourceGUI", "ilobjportfoliogui"], "preview");
1032  }
1033 
1035  {
1036  $ilUser = $this->user;
1038 
1039  $title = trim($_REQUEST["pt"]);
1040  $prtt_id = (int) $_REQUEST["prtt"];
1041 
1042  // get assignment template
1043  $ass_template_id = 0;
1044  if ((int) $_REQUEST["ass_id"] > 0) {
1045  $ass = new ilExAssignment((int) $_REQUEST["ass_id"]);
1046  $ass_template_id = ilObject::_lookupObjectId($ass->getPortfolioTemplateId());
1047  }
1048 
1049  if ($prtt_id > 0) {
1050  $templates = array_keys(ilObjPortfolioTemplate::getAvailablePortfolioTemplates());
1051  if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
1052  if ($ass_template_id != $prtt_id) {
1053  $this->toRepository();
1054  }
1055  }
1056 
1057  //skills manipulation
1058  $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
1059  $skill_ids = array();
1060 
1061  $recipe = array();
1062  foreach (ilPortfolioTemplatePage::getAllPortfolioPages($prtt_id) as $page) {
1063  switch ($page["type"]) {
1065  if (!$ilSetting->get('disable_wsp_blogs')) {
1066  $recipe[$page["id"]] = array("blog", "create", $page['title']);
1067  }
1068  break;
1070  $source_page = new ilPortfolioTemplatePage($page["id"]);
1071  $source_page->buildDom(true);
1072  $skill_ids = $this->getSkillsToPortfolioAssignment($pskills, $skill_ids, $source_page);
1073  break;
1074  }
1075  }
1076 
1077  if ($skill_ids) {
1078  $recipe["skills"] = $skill_ids;
1079  }
1080  }
1081 
1082  // create portfolio
1083  $target = new ilObjPortfolio();
1084  $target->setTitle($title);
1085  $target->create();
1086  $target_id = $target->getId();
1087 
1088  if ($prtt_id) {
1089  $source = new ilObjPortfolioTemplate($prtt_id, false);
1090  $source->clonePagesAndSettings($source, $target, $recipe);
1091  }
1092 
1093  // link portfolio to exercise assignment
1095 
1096  $this->ctrl->setParameter($this, "prt_id", $target_id);
1097  if ($prtt_id) {
1098  ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created_from_template"), true);
1099  $this->ctrl->redirect($this, "preview");
1100  } else {
1101  ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
1102  $this->ctrl->redirect($this, "view");
1103  }
1104  }
1105 
1106  public function linkPortfolioToAssignment($a_target_id)
1107  {
1108  $ilAccess = $this->access;
1109  $ilUser = $this->user;
1110 
1111  $exc_ref_id = (int) $_REQUEST["exc_id"];
1112  $ass_id = (int) $_REQUEST["ass_id"];
1113 
1114  if ($exc_ref_id &&
1115  $ass_id &&
1116  $ilAccess->checkAccess("read", "", $exc_ref_id)) {
1117  $exc = new ilObjExercise($exc_ref_id);
1118  $ass = new ilExAssignment($ass_id);
1119  if ($ass->getExerciseId() == $exc->getId() &&
1120  $ass->getType() == ilExAssignment::TYPE_PORTFOLIO) {
1121  // #16205
1122  $sub = new ilExSubmission($ass, $ilUser->getId());
1123  $sub->addResourceObject($a_target_id);
1124  }
1125  }
1126  }
1127 
1134  public function getSkillsToPortfolioAssignment($a_pskills, $a_skill_ids, $a_source_page)
1135  {
1136  $dom = $a_source_page->getDom();
1137  if ($dom instanceof php4DOMDocument) {
1138  $dom = $dom->myDOMDocument;
1139  }
1140  $xpath = new DOMXPath($dom);
1141  $nodes = $xpath->query("//PageContent/Skills");
1142  foreach ($nodes as $node) {
1143  $skill_id = $node->getAttribute("Id");
1144  if (!in_array($skill_id, $a_pskills)) {
1145  $a_skill_ids[] = $skill_id;
1146  }
1147  }
1148  unset($nodes);
1149  unset($xpath);
1150  unset($dom);
1151 
1152  return $a_skill_ids;
1153  }
1154 
1160  public function exportPDFSelection()
1161  {
1162  global $DIC;
1163 
1164  $tpl = $DIC["tpl"];
1165 
1166  $form = $this->initPDFSelectionForm();
1167 
1168  $tpl->setContent($form->getHTML());
1169  }
1170 
1174  public function initPDFSelectionForm()
1175  {
1176  global $DIC;
1177 
1178  $lng = $this->lng;
1179  $ilCtrl = $this->ctrl;
1180 
1181  $tabs = $DIC->tabs();
1182 
1183  $tabs->clearTargets();
1184  $tabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "view"));
1185 
1186  $pages = ilPortfolioPage::getAllPortfolioPages($this->object->getId());
1187 
1188 
1189  $form = new ilPropertyFormGUI();
1190 
1191  // because of PDF export
1192  $form->setPreventDoubleSubmission(false);
1193 
1194  // declaration of authorship
1195  if ($this->declaration_authorship->getForUser($this->user) != "") {
1196  $cb = new ilCheckboxInputGUI($this->lng->txt("prtf_decl_authorship"), "decl_author");
1197  $cb->setInfo($this->declaration_authorship->getForUser($this->user));
1198  $form->addItem($cb);
1199  }
1200 
1201  // signature
1202  $cb = new ilCheckboxInputGUI($this->lng->txt("prtf_signature"), "signature");
1203  $cb->setInfo($this->lng->txt("prtf_signature_info"));
1204  $form->addItem($cb);
1205 
1206 
1207  // selection type
1208  $radg = new ilRadioGroupInputGUI($lng->txt("prtf_print_selection"), "sel_type");
1209  $radg->setValue("all_pages");
1210  $op2 = new ilRadioOption($lng->txt("prtf_all_pages"), "all_pages");
1211  $radg->addOption($op2);
1212  $op3 = new ilRadioOption($lng->txt("prtf_selected_pages"), "selection");
1213  $radg->addOption($op3);
1214 
1215  $nl = new ilNestedListInputGUI("", "obj_id");
1216  $op3->addSubItem($nl);
1217 
1218  foreach ($pages as $p) {
1219  if ($p["type"] != ilPortfolioPage::TYPE_BLOG) {
1220  $nl->addListNode(
1221  $p["id"],
1222  $p["title"],
1223  0,
1224  false,
1225  false,
1226  ilUtil::getImagePath("icon_pg.svg"),
1227  $lng->txt("page")
1228  );
1229  } else {
1230  $nl->addListNode(
1231  $p["id"],
1232  $lng->txt("obj_blog") . ": " . ilObject::_lookupTitle($p["title"]),
1233  0,
1234  false,
1235  false,
1236  ilUtil::getImagePath("icon_blog.svg"),
1237  $lng->txt("obj_blog")
1238  );
1239  $pages2 = ilBlogPosting::getAllPostings($p["title"]);
1240  foreach ($pages2 as $p2) {
1241  $nl->addListNode(
1242  "b" . $p2["id"],
1243  $p2["title"],
1244  $p["id"],
1245  false,
1246  false,
1247  ilUtil::getImagePath("icon_pg.svg"),
1248  $lng->txt("page")
1249  );
1250  }
1251  }
1252  }
1253 
1254  $form->addItem($radg);
1255 
1256  $form->addCommandButton("exportPDF", $lng->txt("prtf_pdf"));
1257  if (DEVMODE == "1") {
1258  $form->addCommandButton("exportPDFDev", $lng->txt("prtf_pdf") . " (DEV)");
1259  }
1260 
1261  $form->setTitle($lng->txt("prtf_print_options"));
1262  $form->setFormAction($ilCtrl->getFormAction($this, "exportPDF"));
1263 
1264  return $form;
1265  }
1266 
1270  public function exportPDFDev()
1271  {
1272  $this->exportPDF(true);
1273  }
1274 
1279  public function exportPDF($a_dev_mode = false)
1280  {
1282 
1283  // prepare generation before contents are processed (for mathjax)
1284  ilPDFGeneratorUtils::prepareGenerationRequest("Portfolio", "ContentExport");
1285 
1286  $html = $this->printView(true);
1287 
1288  // :TODO: fixing css dummy parameters
1289  $html = preg_replace("/\?dummy\=[0-9]+/", "", $html);
1290  $html = preg_replace("/\?vers\=[0-9A-Za-z\-]+/", "", $html);
1291 
1292  $html = preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $html);
1293  $html = preg_replace("/href=\"\\.\\//ims", "href=\"" . ILIAS_HTTP_PATH . "/", $html);
1294 
1295 
1296  if ($a_dev_mode) {
1297  echo $html;
1298  exit;
1299  }
1300 
1301  //$html = str_replace("&amp;", "&", $html);
1302 
1303  $pdf_factory = new ilHtmlToPdfTransformerFactory();
1304  $pdf_factory->deliverPDFFromHTMLString($html, "portfolio.pdf", ilHtmlToPdfTransformerFactory::PDF_OUTPUT_DOWNLOAD, "Portfolio", "ContentExport");
1305  }
1306 
1307  public function printView($a_pdf_export = false)
1308  {
1309  //global $tpl;
1310 
1311  $lng = $this->lng;
1312 
1313  $pages = ilPortfolioPage::getAllPortfolioPages($this->object->getId());
1314 
1315 
1316  $tpl = new ilGlobalTemplate("tpl.pdf_print_view.html", true, true, "Services/Export/PDF");
1317 
1318  $resource_collector = new \ILIAS\COPage\ResourcesCollector(
1320  new ilPortfolioPage()
1321  );
1322  $resource_injector = new \ILIAS\COPage\ResourcesInjector($resource_collector);
1323 
1324  $tpl->setBodyClass("ilPrtfPdfBody");
1325 
1326  $tpl->addCss(ilUtil::getStyleSheetLocation("filesystem"));
1327  $tpl->addCss(ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId(), false));
1328  $tpl->addCss(ilObjStyleSheet::getContentPrintStyle());
1329  $tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
1330 
1331  $resource_injector->inject($tpl);
1332 
1333 
1334  $page_content = "";
1335 
1336  // cover page
1337  $cover_tpl = new ilTemplate("tpl.prtf_cover.html", true, true, "Modules/Portfolio");
1338  foreach ($pages as $page) {
1339  if ($page["type"] != ilPortfolioPage::TYPE_BLOG) {
1340  if ($_POST["sel_type"] == "selection" && (!is_array($_POST["obj_id"]) || !in_array($page["id"], $_POST["obj_id"]))) {
1341  continue;
1342  }
1343  $cover_tpl->setCurrentBlock("content_item");
1344  $cover_tpl->setVariable("ITEM_TITLE", $page["title"]);
1345  $cover_tpl->parseCurrentBlock();
1346  } else {
1347  $cover_tpl->setCurrentBlock("content_item");
1348  $cover_tpl->setVariable("ITEM_TITLE", $lng->txt("obj_blog") . ": " . ilObject::_lookupTitle($page["title"]));
1349  $cover_tpl->parseCurrentBlock();
1350  }
1351  }
1352 
1353  if ($_POST["signature"]) {
1354  $cover_tpl->setCurrentBlock("signature");
1355  $cover_tpl->setVariable("TXT_SIGNATURE", $lng->txt("prtf_signature_date"));
1356  $cover_tpl->parseCurrentBlock();
1357  }
1358 
1359  if ($_POST["decl_author"]) {
1360  $cover_tpl->setCurrentBlock("decl_author");
1361  $cover_tpl->setVariable(
1362  "TXT_DECL_AUTHOR",
1363  nl2br($this->declaration_authorship->getForUser($this->user))
1364  );
1365  $cover_tpl->parseCurrentBlock();
1366  }
1367 
1368  $cover_tpl->setVariable("PORTFOLIO_TITLE", $this->object->getTitle());
1369  $cover_tpl->setVariable("PORTFOLIO_ICON", ilUtil::getImagePath("icon_prtf.svg"));
1370 
1371  $cover_tpl->setVariable("TXT_AUTHOR", $lng->txt("prtf_author"));
1372  $cover_tpl->setVariable("TXT_LINK", $lng->txt("prtf_link"));
1373  $cover_tpl->setVariable("TXT_DATE", $lng->txt("prtf_date_of_print"));
1374 
1375  $author = ilObjUser::_lookupName($this->object->getOwner());
1376  $author_str = $author["firstname"] . " " . $author["lastname"];
1377  $cover_tpl->setVariable("AUTHOR", $author_str);
1378 
1379  $href = ilLink::_getStaticLink($this->object->getId(), "prtf");
1380  $cover_tpl->setVariable("LINK", $href);
1381 
1383  $date_str = ilDatePresentation::formatDate(new ilDate(date("Y-m-d"), IL_CAL_DATE));
1384  $cover_tpl->setVariable("DATE", $date_str);
1385 
1386  $page_content .= $cover_tpl->get();
1387  $page_content .= '<p style="page-break-after:always;"></p>';
1388 
1389  $page_head_tpl = new ilTemplate("tpl.prtf_page_head.html", true, true, "Modules/Portfolio");
1390  $page_head_tpl->setVariable("AUTHOR", $author_str);
1391  $page_head_tpl->setVariable("DATE", $date_str);
1392  $page_head_str = $page_head_tpl->get();
1393 
1394  foreach ($pages as $page) {
1395  if ($page["type"] != ilPortfolioPage::TYPE_BLOG) {
1396  if ($_POST["sel_type"] == "selection" && (!is_array($_POST["obj_id"]) || !in_array($page["id"], $_POST["obj_id"]))) {
1397  continue;
1398  }
1399 
1400  $page_gui = new ilPortfolioPageGUI($this->object->getId(), $page["id"]);
1401  $page_gui->setOutputMode("print");
1402  $page_gui->setPresentationTitle($page["title"]);
1403  $html = $this->ctrl->getHTML($page_gui);
1404  $page_content .= $page_head_str . $html;
1405 
1406  if ($a_pdf_export) {
1407  $page_content .= '<p style="page-break-after:always;"></p>';
1408  }
1409  } else {
1410  $pages2 = ilBlogPosting::getAllPostings($page["title"]);
1411  foreach ($pages2 as $p2) {
1412  if ($_POST["sel_type"] == "selection" && (!is_array($_POST["obj_id"]) || !in_array("b" . $p2["id"], $_POST["obj_id"]))) {
1413  continue;
1414  }
1415  $page_gui = new ilBlogPostingGUI(0, null, $p2["id"]);
1416  $page_gui->setFileDownloadLink("#");
1417  $page_gui->setFullscreenLink("#");
1418  $page_gui->setSourcecodeDownloadScript("#");
1419  $page_gui->setOutputMode("print");
1420  $page_content .= $page_head_str . $page_gui->showPage(ilObject::_lookupTitle($page["title"]) . ": " . $page_gui->getBlogPosting()->getTitle());
1421 
1422  if ($a_pdf_export) {
1423  $page_content .= '<p style="page-break-after:always;"></p>';
1424  }
1425  }
1426  }
1427  }
1428 
1429  $page_content = '<div class="ilInvisibleBorder">' . $page_content . '</div>';
1430 
1431  if (!$a_pdf_export) {
1432  $page_content .= '<script type="text/javascript" language="javascript1.2">
1433  <!--
1434  il.Util.addOnLoad(function () {
1435  il.Util.print();
1436  });
1437  //-->
1438  </script>';
1439  }
1440 
1441  $tpl->setVariable("CONTENT", $page_content);
1442 
1443  if (!$a_pdf_export) {
1444  $tpl->printToStdout(false);
1445  exit;
1446  } else {
1447  $ret = $tpl->printToString();
1448  //$tpl->fillJavaScriptFiles();
1449  //$ret = $tpl->getSpecial("DEFAULT", false, false, false, true, false, false);
1450  return $ret;
1451  }
1452  }
1453 
1459  protected function getOfflineMessage()
1460  {
1461  $ui = $this->ui;
1462  $lng = $this->lng;
1463  $ctrl = $this->ctrl;
1464 
1465  if (!$this->object->isOnline()) {
1466  $f = $ui->factory();
1467  $renderer = $ui->renderer();
1468 
1469  $buttons = [$f->button()->standard(
1470  $lng->txt("prtf_set_online"),
1471  $ctrl->getLinkTarget($this, "setOnlineAndShare")
1472  )];
1473 
1474  return $renderer->render($f->messageBox()->info($lng->txt("prtf_no_offline_share_info"))
1475  ->withButtons($buttons));
1476  }
1477  return "";
1478  }
1479 
1483  protected function setOnlineAndShare()
1484  {
1485  $ilCtrl = $this->ctrl;
1486  $lng = $this->lng;
1487 
1488  if (ilObjPortfolio::_lookupOwner($this->object->getId()) == $this->user_id) {
1489  $this->object->setOnline(true);
1490  $this->object->update();
1491  ilUtil::sendSuccess($lng->txt("prtf_has_been_set_online"), true);
1492  }
1493  $ilCtrl->redirectByClass("ilworkspaceaccessgui", "");
1494  }
1495 }
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _lookupName($a_user_id)
lookup user name
getPageGUIInstance($a_page_id)
Get portfolio template page gui instance.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
createPortfolioFromTemplate(ilPropertyFormGUI $a_form=null)
This class represents an option in a radio group.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
static getContentPrintStyle()
get content print style
createPortfolioFromTemplateProcess($a_process_form=true)
exit
Definition: login.php:29
createFromTemplateDirect($title="")
Create portfolio template direct.
settings()
Definition: settings.php:2
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
Exercise assignment.
addResourceObject($a_wsp_id, $a_text=null)
Add personal resource or repository object (ref_id) to assigment.
This class represents an option in a checkbox group.
This class represents a property form user interface.
special template class to simplify handling of ITX/PEAR
$type
const TITLE_LENGTH
max length of object title
getPageInstance($a_page_id=null, $a_portfolio_id=null)
Get portfolio template page instance.
getSkillsToPortfolioAssignment($a_pskills, $a_skill_ids, $a_source_page)
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
Class ilBlogPosting GUI class.
static getPortfoliosOfUser($a_user_id)
Get views of user.
Access handler for personal workspace.
$target_id
Definition: goto.php:51
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
getOfflineMessage()
Get offline message for sharing tab.
addItem($a_item)
Add Item (Property, SectionHeader).
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 initJavascript($a_ajax_url, $a_type=IL_NOTE_PRIVATE, ilGlobalTemplateInterface $a_main_tpl=null)
Init javascript.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
user()
Definition: user.php:4
Class ilPortfolioExerciseGUI.
static _lookupOwner($a_id)
Tree handler for personal workspace.
static _lookupObjectId($a_ref_id)
lookup object id
help()
Definition: help.php:2
create()
create new object form
setInfo($a_info)
Set Information Text.
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
setChecked($a_checked)
Set Checked.
saveBlog()
Create new portfolio blog page.
getCreationFormsHTML(array $a_forms)
Get HTML for creation forms (accordion)
Portfolio view gui class.
Class ilObjExercise.
This class represents a property in a property form.
Class for single dates.
getId()
get object id public
Class ilHtmlToPdfTransformerFactory.
initPDFSelectionForm()
Init print view selection form.
afterSave(ilObject $a_new_object)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static setUserDefault($a_user_id, $a_portfolio_id=null)
Set the user default portfolio.
getAdditional()
Get Additonal Information.
global $DIC
Definition: goto.php:24
Class ilObjBlog.
ui()
Definition: ui.php:5
Page for user portfolio.
Page for portfolio template.
static getAvailablePortfolioTemplates($a_permission="read")
This class represents a property in a property form.
static getSyntaxStylePath()
get syntax style path
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.
ACL access handler GUI.
initBlogForm()
Init blog page form.
setOnlineAndShare()
Set online and switch to share screen.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
const IL_CAL_DATE
enableWrite($a_write)
Enable writing.
linkPortfolioToAssignment($a_target_id)
This class represents a non editable value in a property form.
setAdditional($a_additional)
Set Additonal Information.
Class ilObjStyleSheetGUI.
This class represents a (nested) list of checkboxes (could be extended for radio items, too)
global $ilSetting
Definition: privfeed.php:17
__construct(Container $dic, ilPlugin $plugin)
$ret
Definition: parser.php:6
printView($a_pdf_export=false)
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
exportPDF($a_dev_mode=false)
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
$message
Definition: xapiexit.php:14
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
$url
setOutputMode($a_mode=self::PRESENTATION)
Set Output Mode.
$ilUser
Definition: imgupload.php:18
initEditCustomForm(ilPropertyFormGUI $a_form)
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
triggerAssignmentTool()
Trigger assignment tool.
static redirect($a_script)
Exercise info for portfolios.
exportPDFSelection()
Export PDF selection.
$source
Definition: metadata.php:76
setBlockingMessage($a_val)
Set blocking message.
$_POST["username"]
setRequired($a_required)
Set Required.
static prepareGenerationRequest($service, $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
$i
Definition: metadata.php:24
getCreateInfoMessage()
Get cereat info message.