protected function createPortfolioObject() { global $ilUser; $this->checkPermission("read"); include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php"; $portfolio = new ilObjPortfolio(); $portfolio->setTitle($this->object->getTitle() . " - " . $this->ass->getTitle()); $portfolio->create(); $this->object->addResourceObject($portfolio->getId(), $this->ass->getId(), $ilUser->getId()); ilUtil::sendSuccess($this->lng->txt("exc_portfolio_created"), true); $this->ctrl->redirect($this, "showOverview"); }
protected function createPortfolioFromTemplateProcess($a_process_form = true) { global $ilSetting, $ilUser, $ilAccess; $title = trim($_REQUEST["pt"]); $prtt_id = (int) $_REQUEST["prtt"]; // valid template? include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php"; $templates = array_keys(ilObjPortfolioTemplate::getAvailablePortfolioTemplates()); if (!sizeof($templates) || !in_array($prtt_id, $templates)) { $this->toRepository(); } unset($templates); // build page recipe (aka import form values) $recipe = null; if ($a_process_form) { $this->ctrl->setParameter($this, "prtt", $prtt_id); $form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title); if ($form->checkInput()) { include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; foreach (ilPortfolioTemplatePage::getAllPages($prtt_id) as $page) { switch ($page["type"]) { case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE: if (!$ilSetting->get('disable_wsp_blogs')) { $field_id = "blog_" . $page["id"]; switch ($form->getInput($field_id)) { case "blog_create": $recipe[$page["id"]] = array("blog", "create", trim($form->getInput($field_id . "_create_title"))); break; case "blog_resuse": $recipe[$page["id"]] = array("blog", "reuse", (int) $form->getInput($field_id . "_reuse_blog")); break; case "blog_ignore": $recipe[$page["id"]] = array("blog", "ignore"); break; } } break; } } $recipe["skills"] = (array) $form->getInput("skill_ids"); } else { $form->setValuesByPost(); return $this->createPortfolioFromTemplate($form); } } $source = new ilObjPortfolioTemplate($prtt_id, false); // create portfolio include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php"; $target = new ilObjPortfolio(); $target->setTitle($title); $target->create(); $target_id = $target->getId(); $source->clonePagesAndSettings($source, $target, $recipe); // link portfolio to exercise assignment $exc_ref_id = (int) $_REQUEST["exc_id"]; $ass_id = (int) $_REQUEST["ass_id"]; if ($exc_ref_id && $ass_id && $ilAccess->checkAccess("read", "", $exc_ref_id)) { include_once "Modules/Exercise/classes/class.ilObjExercise.php"; include_once "Modules/Exercise/classes/class.ilExAssignment.php"; $exc = new ilObjExercise($exc_ref_id); $ass = new ilExAssignment($ass_id); if ($ass->getExerciseId() == $exc->getId() && $ass->getType() == ilExAssignment::TYPE_PORTFOLIO) { $exc->addResourceObject($target_id, $ass_id, $ilUser->getId()); } } ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true); $this->ctrl->setParameter($this, "prt_id", $target_id); $this->ctrl->redirect($this, "view"); }
/** * check access for an object * * @param integer $a_user_id * @param string $a_permission * @param string $a_cmd * @param int $a_node_id * @param string $a_type (optional) * @return bool */ public function checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_node_id, $a_type = "") { global $rbacreview, $ilUser, $ilSetting; // #12059 if (!$ilSetting->get('user_portfolios')) { return false; } // :TODO: create permission for parent node with type ?! $pf = new ilObjPortfolio($a_node_id, false); if (!$pf->getId()) { return false; } // portfolio owner has all rights if ($pf->getOwner() == $a_user_id) { return true; } // #11921 if (!$pf->isOnline()) { return false; } // other users can only read if ($a_permission == "read" || $a_permission == "visible") { // get all objects with explicit permission $objects = $this->getPermissions($a_node_id); if ($objects) { include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php"; // check if given user is member of object or has role foreach ($objects as $obj_id) { switch ($obj_id) { case ilWorkspaceAccessGUI::PERMISSION_ALL: return true; case ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD: // check against input kept in session if (self::getSharedNodePassword($a_node_id) == self::getSharedSessionPassword($a_node_id) || $a_permission == "visible") { return true; } break; case ilWorkspaceAccessGUI::PERMISSION_REGISTERED: if ($ilUser->getId() != ANONYMOUS_USER_ID) { return true; } break; default: switch (ilObject::_lookupType($obj_id)) { case "grp": // member of group? if (ilGroupParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) { return true; } break; case "crs": // member of course? if (ilCourseParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) { return true; } break; case "role": // has role? if ($rbacreview->isAssigned($a_user_id, $obj_id)) { return true; } break; case "usr": // direct assignment if ($a_user_id == $obj_id) { return true; } break; } break; } } } } return false; }
function copyPage() { $form = $this->initCopyPageForm(); if ($form->checkInput()) { // existing if ($form->getInput("target") == "old") { $portfolio_id = $form->getInput("prtf"); } else { $portfolio = new ilObjPortfolio(); $portfolio->setTitle($form->getInput("title")); $portfolio->create(); $portfolio_id = $portfolio->getId(); } // copy page(s) foreach ($_POST["prtf_pages"] as $page_id) { $source = $this->getPageInstance($page_id); $target = $this->getPageInstance(null, $portfolio_id); $target->setXMLContent($source->copyXmlContent(true)); // copy mobs $target->setType($source->getType()); $target->setTitle($source->getTitle()); $target->create(); } ilUtil::sendSuccess($this->lng->txt("prtf_pages_copied"), true); $this->ctrl->redirect($this, "view"); } $form->setValuesByPost(); $this->copyPageForm($form); }
function copyPage() { global $ilCtrl, $lng; $form = $this->initCopyPageForm(); if ($form->checkInput()) { // existing if ($form->getInput("target") == "old") { $portfolio_id = $form->getInput("prtf"); $portfolio = new ilObjPortfolio($portfolio_id, false); } else { $portfolio = new ilObjPortfolio(); $portfolio->setTitle($form->getInput("title")); $portfolio->create(); $portfolio_id = $portfolio->getId(); } // copy page(s) include_once "Services/Portfolio/classes/class.ilPortfolioPage.php"; foreach ($_POST["prtf_pages"] as $page_id) { $source = new ilPortfolioPage($portfolio_id, $page_id); $target = new ilPortfolioPage($portfolio_id); $target->setXMLContent($source->copyXmlContent()); $target->setType($source->getType()); $target->setTitle($source->getTitle()); $target->create(); } ilUtil::sendSuccess($lng->txt("prtf_pages_copied"), true); $ilCtrl->redirect($this, "pages"); } $form->setValuesByPost(); $this->copyPageForm($form); }