Skip to content

Commit

Permalink
User: Add Panel To Contain Portfolio Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Sep 4, 2023
1 parent c85934c commit 40ef81b
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 315 deletions.
208 changes: 104 additions & 104 deletions Modules/Portfolio/classes/class.ilObjPortfolioGUI.php

Large diffs are not rendered by default.

128 changes: 64 additions & 64 deletions Modules/Portfolio/classes/class.ilObjPortfolioTemplateGUI.php

Large diffs are not rendered by default.

88 changes: 44 additions & 44 deletions Modules/Portfolio/classes/class.ilPortfolioRepositoryGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ilPortfolioRepositoryGUI
* @var \ILIAS\DI\UIServices
*/
protected $ui;

public function __construct()
{
global $DIC;
Expand All @@ -84,10 +84,10 @@ public function __construct()
$lng->loadLanguageModule("user");

$this->access_handler = new ilPortfolioAccessHandler();

$this->user_id = $ilUser->getId();
}

public function executeCommand()
{
$ilCtrl = $this->ctrl;
Expand All @@ -101,7 +101,7 @@ public function executeCommand()

$next_class = $ilCtrl->getNextClass($this);
$cmd = $ilCtrl->getCmd("show");

$tpl->setTitle($lng->txt("portfolio"));
$tpl->setTitleIcon(
ilUtil::getImagePath("icon_prtf.svg"),
Expand Down Expand Up @@ -135,28 +135,28 @@ public function executeCommand()

return true;
}

public function setTabs()
{
$ilTabs = $this->tabs;
$lng = $this->lng;
$ilCtrl = $this->ctrl;
$ilHelp = $this->help;

$ilHelp->setScreenIdComponent("prtf");

$ilTabs->addTab(
"mypf",
$lng->txt("prtf_tab_portfolios"),
$ilCtrl->getLinkTarget($this)
);

$ilTabs->addTab(
"otpf",
$lng->txt("prtf_tab_other_users"),
$ilCtrl->getLinkTarget($this, "showotherFilter")
);

$ilTabs->activateTab("mypf");
}

Expand All @@ -166,15 +166,15 @@ protected function setLocator()
$lng = $this->lng;
$ilCtrl = $this->ctrl;
$tpl = $this->tpl;

$ilLocator->addItem(
$lng->txt("portfolio"),
$ilCtrl->getLinkTarget($this, "show")
);

$tpl->setLocator();
}

protected function checkAccess($a_permission, $a_portfolio_id = null)
{
if ($a_portfolio_id) {
Expand All @@ -183,19 +183,19 @@ protected function checkAccess($a_permission, $a_portfolio_id = null)
// currently only object-based permissions
return true;
}


//
// LIST INCL. ACTIONS
//

protected function show()
{
$tpl = $this->tpl;
$lng = $this->lng;
$ilToolbar = $this->toolbar;
$ilCtrl = $this->ctrl;

$button = ilLinkButton::getInstance();
$button->setCaption("prtf_add_portfolio");
$button->setUrl($ilCtrl->getLinkTargetByClass("ilObjPortfolioGUI", "create"));
Expand Down Expand Up @@ -242,7 +242,7 @@ protected function getPortfolioList()
// ... preview
$ctrl->setParameterByClass("ilobjportfoliogui", "prt_id", $port["id"]);
$preview_action = $ctrl->getLinkTargetByClass($prtf_path, "preview");
$action[] = $f->button()->shy($lng->txt("user_profile_preview"), $preview_action);
$action[] = $f->button()->shy($lng->txt("preview"), $preview_action);
// ... edit content
$action[] = $f->button()->shy(
$lng->txt("prtf_edit_content"),
Expand Down Expand Up @@ -389,7 +389,7 @@ protected function saveTitles()
{
$ilCtrl = $this->ctrl;
$lng = $this->lng;

foreach ($_POST["title"] as $id => $title) {
if (trim($title)) {
if ($this->checkAccess("write", $id)) {
Expand All @@ -406,11 +406,11 @@ protected function saveTitles()
}
}
}

ilUtil::sendSuccess($lng->txt("saved_successfully"), true);
$ilCtrl->redirect($this, "show");
}

protected function confirmPortfolioDeletion()
{
$ilCtrl = $this->ctrl;
Expand Down Expand Up @@ -456,12 +456,12 @@ protected function deletePortfolios()
ilUtil::sendSuccess($lng->txt("prtf_portfolio_deleted"), true);
$ilCtrl->redirect($this, "show");
}


//
// DEFAULT PORTFOLIO (aka profile)
//

protected function unsetDefault()
{
$ilCtrl = $this->ctrl;
Expand All @@ -472,13 +472,13 @@ protected function unsetDefault()
// #12845
$ilUser->setPref("public_profile", "n");
$ilUser->writePrefs();

ilObjPortfolio::setUserDefault($this->user_id);
ilUtil::sendSuccess($lng->txt("prtf_unset_default_share_info"), true);
}
$ilCtrl->redirect($this, "show");
}

/**
* Confirm sharing when setting default
*/
Expand All @@ -489,16 +489,16 @@ protected function setDefaultConfirmation()
$tpl = $this->tpl;
$ilTabs = $this->tabs;
$ilSetting = $this->settings;

$prtf_id = (int) $_REQUEST["prt_id"];

if ($prtf_id && $this->checkAccess("write")) {
// if already shared, no need to ask again
if ($this->access_handler->hasRegisteredPermission($prtf_id) ||
$this->access_handler->hasGlobalPermission($prtf_id)) {
return $this->setDefault($prtf_id);
}

$ilTabs->clearTargets();
$ilTabs->setBackTarget(
$lng->txt("cancel"),
Expand All @@ -518,37 +518,37 @@ protected function setDefaultConfirmation()
$cgui->setCancel($lng->txt("prtf_set_default_publish_global"), "setDefaultGlobal");
$cgui->setConfirm($lng->txt("prtf_set_default_publish_registered"), "setDefaultRegistered");
$tpl->setContent($cgui->getHTML());

return;
}

$ilCtrl->redirect($this, "show");
}

protected function setDefaultGlobal()
{
$ilCtrl = $this->ctrl;

$prtf_id = (int) $_REQUEST["prt_id"];
if ($prtf_id && $this->checkAccess("write")) {
$this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_ALL);
$this->setDefault($prtf_id);
}
$ilCtrl->redirect($this, "show");
}

protected function setDefaultRegistered()
{
$ilCtrl = $this->ctrl;

$prtf_id = (int) $_REQUEST["prt_id"];
if ($prtf_id && $this->checkAccess("write")) {
$this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_REGISTERED);
$this->setDefault($prtf_id);
}
$ilCtrl->redirect($this, "show");
}

protected function setDefault($a_prtf_id)
{
$ilCtrl = $this->ctrl;
Expand All @@ -572,42 +572,42 @@ protected function setDefault($a_prtf_id)
$ilCtrl->redirect($this, "show");
}


//
// SHARE
//

protected function showOtherFilter()
{
$this->showOther(false);
}

protected function showOther($a_load_data = true)
{
$tpl = $this->tpl;
$ilTabs = $this->tabs;

$ilTabs->activateTab("otpf");

$tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler, null, $a_load_data);
$tpl->setContent($tbl->getHTML());
}

protected function applyShareFilter()
{
$tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
$tbl->resetOffset();
$tbl->writeFilterToSession();

$this->showOther();
}

protected function resetShareFilter()
{
$tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
$tbl->resetOffset();
$tbl->resetFilter();

$this->showOther();
}
}
24 changes: 12 additions & 12 deletions Modules/Portfolio/classes/class.ilPortfolioTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id)
$lng = $DIC->language();

$this->user_id = (int) $a_user_id;

parent::__construct($a_parent_obj, $a_parent_cmd);

$this->setTitle($lng->txt("prtf_portfolios"));
Expand All @@ -48,20 +48,20 @@ public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id)
$this->addCommandButton("saveTitles", $lng->txt("prtf_save_status_and_titles"));

$this->getItems();

$lng->loadLanguageModule("wsp");
}

protected function getItems()
{
$ilUser = $this->user;

$access_handler = new ilPortfolioAccessHandler();

$data = ilObjPortfolio::getPortfoliosOfUser($this->user_id);

$this->shared_objects = $access_handler->getObjectsIShare(false);

$this->setData($data);
}

Expand All @@ -72,7 +72,7 @@ protected function fillRow($a_set)
{
$lng = $this->lng;
$ilCtrl = $this->ctrl;

$this->tpl->setCurrentBlock("title_form");
$this->tpl->setVariable("VAL_ID", $a_set["id"]);
$this->tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($a_set["title"]));
Expand All @@ -99,7 +99,7 @@ protected function fillRow($a_set)
($a_set["is_default"]) ? $lng->txt("yes") : ""
);
$this->tpl->parseCurrentBlock();

$prtf_path = array(get_class($this->parent_obj), "ilobjportfoliogui");

$ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", $a_set["id"]);
Expand All @@ -109,7 +109,7 @@ protected function fillRow($a_set)
"URL_ACTION",
$ilCtrl->getLinkTargetByClass($prtf_path, "preview")
);
$this->tpl->setVariable("TXT_ACTION", $lng->txt("user_profile_preview"));
$this->tpl->setVariable("TXT_ACTION", $lng->txt("preview"));
$this->tpl->parseCurrentBlock();

$this->tpl->setVariable(
Expand All @@ -118,20 +118,20 @@ protected function fillRow($a_set)
);
$this->tpl->setVariable("TXT_ACTION", $lng->txt("prtf_edit_portfolio"));
$this->tpl->parseCurrentBlock();

$ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", "");

if ($a_set["is_online"]) {
if (!$a_set["is_default"]) {
$ilCtrl->setParameter($this->parent_obj, "prt_id", $a_set["id"]);

$this->tpl->setVariable(
"URL_ACTION",
$ilCtrl->getLinkTarget($this->parent_obj, "setDefaultConfirmation")
);
$this->tpl->setVariable("TXT_ACTION", $lng->txt("prtf_set_as_default"));
$this->tpl->parseCurrentBlock();

$ilCtrl->setParameter($this->parent_obj, "prt_id", "");
} else {
$this->tpl->setVariable(
Expand Down
Loading

0 comments on commit 40ef81b

Please sign in to comment.