19 declare(strict_types=1);
95 $this->rbacsystem = $DIC->rbac()->system();
97 $this->obj_definition = $DIC[
"objDefinition"];
98 $this->access = $DIC->access();
99 $this->
ui = $DIC->ui();
100 $this->
http = $DIC->http();
101 $this->objectService = $DIC->object();
103 $this->tree = $DIC->repositoryTree();
104 $this->logging = $DIC->logger()->root();
108 $this->lng = $DIC->language();
109 $this->ctrl = $DIC->ctrl();
110 $this->
user = $DIC->user();
112 $this->lng->loadLanguageModule(
'pd');
113 $this->lng->loadLanguageModule(
'cntr');
114 $this->lng->loadLanguageModule(
'rep');
118 $this->allow_moving =
false;
123 if ($this->viewSettings->isTilePresentation()) {
137 $this->viewSettings->parse();
141 $this->ctrl->setParameter($this,
'view', $this->viewSettings->getCurrentView());
154 $this->favourites->add($this->
user->getId(), (int)
$_GET[
"item_ref_id"]);
155 ilUtil::sendSuccess($this->lng->txt(
"rep_added_to_favourites"),
true);
164 $this->ctrl->setParameterByClass(
'ildashboardgui',
'view', $this->viewSettings->getCurrentView());
165 $this->ctrl->redirectByClass(
'ildashboardgui',
'show');
173 $this->lng->loadLanguageModule(
"rep");
174 $this->favourites->remove($this->
user->getId(), (int)
$_GET[
"item_ref_id"]);
175 ilUtil::sendSuccess($this->lng->txt(
"rep_removed_from_favourites"),
true);
184 return static::$block_type;
193 if ($cmd ===
'post') {
195 $cmd = key($DIC->http()->request()->getParsedBody()[
'cmd']);
199 case 'confirmRemove':
221 return $this->blockView->getTitle();
232 $DIC->database()->useSlave(
true);
235 $this->ctrl->clearParameters($this);
236 $DIC->database()->useSlave(
false);
238 return parent::getHTML();
243 $next_class = $this->ctrl->getNextClass();
244 $cmd = $this->ctrl->getCmd(
'getHTML');
246 switch ($next_class) {
247 case 'ilcommonactiondispatchergui':
248 include_once(
'Services/Object/classes/class.ilCommonActionDispatcherGUI.php');
250 $this->ctrl->forwardCommand($gui);
254 if (method_exists($this, $cmd)) {
255 return $this->$cmd();
257 return $this->{$cmd .
'Object'}();
269 $this->content = $a_content;
280 $this->tpl->setVariable(
'BLOCK_ROW', $this->
getContent());
296 $sortingCommands = [];
297 $sortings = $this->viewSettings->getSelectableSortingModes();
298 $effectiveSorting = $this->viewSettings->getEffectiveSortingMode();
299 foreach ($sortings as $sorting) {
300 $this->ctrl->setParameter($this,
'sorting', $sorting);
301 $sortingCommands[] = [
302 'txt' => $this->lng->txt(
'dash_sort_by_' . $sorting),
303 'url' => $this->ctrl->getLinkTarget($this,
'changePDItemSorting'),
304 'xxxasyncUrl' => $this->ctrl->getLinkTarget($this,
'changePDItemSorting',
'',
true),
305 'active' => $sorting === $effectiveSorting,
307 $this->ctrl->setParameter($this,
'sorting', null);
310 if (count($sortingCommands) > 1) {
311 $commandGroups[] = $sortingCommands;
315 return $commandGroups;
318 $presentationCommands = [];
319 $presentations = $this->viewSettings->getSelectablePresentationModes();
320 $effectivePresentation = $this->viewSettings->getEffectivePresentationMode();
322 $this->ctrl->setParameter($this,
'presentation', $presentation);
323 $presentationCommands[] = [
324 'txt' => $this->lng->txt(
'pd_presentation_mode_' . $presentation),
325 'url' => $this->ctrl->getLinkTarget($this,
'changePDItemPresentation'),
326 'xxxasyncUrl' => $this->ctrl->getLinkTarget($this,
'changePDItemPresentation',
'',
true),
327 'active' => $presentation === $effectivePresentation,
329 $this->ctrl->setParameter($this,
'presentation', null);
332 if (count($presentationCommands) > 1) {
333 $commandGroups[] = $presentationCommands;
338 'txt' => $this->viewSettings->isSelectedItemsViewActive() ?
339 $this->lng->txt(
'pd_remove_multiple') :
340 $this->lng->txt(
'pd_unsubscribe_multiple_memberships'),
341 'url' => $this->ctrl->getLinkTarget($this,
'manage'),
347 return $commandGroups;
357 if ($this->blockView->isInManageMode()) {
363 foreach ($groupedCommands as $group) {
364 foreach ($group as $command) {
379 if (0 === count($grouped_items)) {
383 if ($this->viewSettings->isTilePresentation()) {
386 $this->
ui->factory(),
387 $this->
ui->renderer(),
395 return $renderer->
render($grouped_items, $showHeader);
400 $this->
ui->factory(),
401 $this->
ui->renderer(),
409 return $renderer->
render($grouped_items, $showHeader);
415 $this->blockView->getItemGroups()
421 $this->viewSettings->storeActorPresentationMode(
429 $this->viewSettings->storeActorSortingMode(
440 if ($this->ctrl->isAsynch()) {
445 if (
$_GET[
"manage"]) {
446 $this->ctrl->redirect($this,
'manage');
454 $this->blockView->setIsInManageMode(
true);
457 $top_tb->setFormAction($this->ctrl->getFormAction($this));
458 $top_tb->setLeadingImage(
ilUtil::getImagePath(
'arrow_upright.svg'), $this->lng->txt(
'actions'));
461 $grouped_items = $this->blockView->getItemGroups();
462 if ($this->viewSettings->isSelectedItemsViewActive()) {
463 $button->setCaption(
'remove');
465 $button->setCaption(
'pd_unsubscribe_memberships');
466 foreach ($grouped_items as $group) {
467 $items = $group->getItems();
468 $group->setItems([]);
469 foreach ($items as $item) {
470 if ($this->rbacsystem->checkAccess(
'leave', $item[
'ref_id'])) {
472 $item[
'type'] !==
'crs' ||
475 $group->pushItem($item);
481 $button->setCommand(
'confirmRemove');
482 $top_tb->addStickyItem($button);
484 $top_tb->setCloseFormTag(
false);
487 $bot_tb->setLeadingImage(
ilUtil::getImagePath(
'arrow_downright.svg'), $this->lng->txt(
'actions'));
488 $bot_tb->addStickyItem($button);
489 $bot_tb->setOpenFormTag(
false);
491 return $top_tb->getHTML() . $this->
renderManageList($grouped_items) . $bot_tb->getHTML();
496 $this->ctrl->returnToParent($this);
501 $this->ctrl->setParameter($this,
'view', $this->viewSettings->getCurrentView());
503 $refIds = (array) ($this->
http->request()->getParsedBody()[
'id'] ?? []);
504 if (0 === count($refIds)) {
506 $this->ctrl->redirect($this,
'manage');
509 if ($this->viewSettings->isSelectedItemsViewActive()) {
510 $question = $this->lng->txt(
'dash_info_sure_remove_from_favs');
511 $cmd =
'confirmedRemove';
513 $question = $this->lng->txt(
'mmbr_info_delete_sure_unsubscribe');
514 $cmd =
'confirmedUnsubscribe';
517 include_once(
'./Services/Utilities/classes/class.ilConfirmationGUI.php');
519 $cgui->setHeaderText($question);
521 $cgui->setFormAction($this->ctrl->getFormAction($this));
522 $cgui->setCancel($this->lng->txt(
'cancel'),
'manage');
523 $cgui->setConfirm($this->lng->txt(
'confirm'), $cmd);
525 foreach ($refIds as $ref_id) {
535 $this->lng->txt(
'icon') .
' ' . $this->lng->txt(
'obj_' .
$type)
539 return $cgui->getHTML();
544 $refIds = (array) ($this->
http->request()->getParsedBody()[
'ref_id'] ?? []);
545 if (0 === count($refIds)) {
546 $this->ctrl->redirect($this,
'manage');
549 foreach ($refIds as $ref_id) {
550 $this->favourites->remove($this->
user->getId(), (int) $ref_id);
554 ilUtil::sendSuccess($this->lng->txt(
'pd_remove_multi_confirm'),
true);
555 $this->ctrl->redirect($this,
'manage');
560 $refIds = (array) ($this->
http->request()->getParsedBody()[
'ref_id'] ?? []);
561 if (0 === count($refIds)) {
562 $this->ctrl->redirect($this,
'manage');
565 foreach ($refIds as $ref_id) {
566 if ($this->access->checkAccess(
'leave',
'', (
int) $ref_id)) {
570 $members->delete($this->
user->getId());
572 $members->sendUnsubscribeNotificationToAdmins($this->
user->getId());
573 $members->sendNotification(
574 $members->NOTIFY_UNSUBSCRIBE,
581 $members->delete($this->
user->getId());
583 $members->sendNotification(
587 $members->sendNotification(
597 include_once
'./Modules/Forum/classes/class.ilForumNotification.php';
602 ilUtil::sendSuccess($this->lng->txt(
'mmbr_unsubscribed_from_objs'),
true);
603 $this->ctrl->returnToParent($this);
611 $groupedItems = $this->blockView->getItemGroups();
613 foreach ($groupedCommands as $group) {
614 foreach ($group as $command) {
616 (
string) $command[
'url'],
617 (
string) $command[
'txt'],
618 (
string) $command[
'asyncUrl']
626 foreach ($groupedItems as $group) {
629 foreach ($group->getItems() as $item) {
633 $this->logging->warning(
'Listing failed for item with ID ' . $item[
'obj_id'] .
': ' . $e->getMessage());
637 if (count($list_items) > 0) {
638 $item_groups[] = $this->
ui->factory()->item()->group((
string) $group->getLabel(), $list_items);
650 $itemListGui = $this->list_factory->byType($data[
'type']);
653 $list_item = $itemListGui->getAsListItem(
654 (
int) $data[
'ref_id'],
655 (
int) $data[
'obj_id'],
656 (
string) $data[
'type'],
657 (
string) $data[
'title'],
658 (
string) $data[
'description']
666 $itemListGui = $this->list_factory->byType($item[
'type']);
669 $card = $itemListGui->getAsCard(
670 (
int) $item[
'ref_id'],
671 (
int) $item[
'obj_id'],
672 (
string) $item[
'type'],
673 (
string) $item[
'title'],
674 (
string) $item[
'description']
686 foreach ($groupedCommands as $group) {
687 foreach ($group as $command) {
689 (
string) $command[
'url'],
690 (
string) $command[
'txt'],
691 (
string) $command[
'asyncUrl']
696 $groupedItems = $this->blockView->getItemGroups();
699 foreach ($groupedItems as $group) {
702 foreach ($group->getItems() as $item) {
706 $this->logging->warning(
'Listing failed for item with ID ' . $item[
'obj_id'] .
': ' . $e->getMessage());
710 if (count($cards) > 0) {
711 $subs[] = $this->
ui->factory()->panel()->sub(
713 $this->
ui->factory()->deck($cards)->withNormalCardsSize()
718 if (count($subs) > 0) {
719 return $this->
ui->renderer()->render($subs);
729 $this->ctrl->setParameter($this,
"manage",
"1");
731 foreach ($groupedCommands as $group) {
732 foreach ($group as $command) {
734 (
string) $command[
'url'],
735 (
string) $command[
'txt'],
736 (
string) $command[
'asyncUrl']
741 if (is_array($groupedCommands[0])) {
742 $actions = array_map(
static function ($item) use (
$ui) {
743 return $ui->factory()->link()->standard($item[
"txt"], $item[
"url"]);
744 }, $groupedCommands[0]);
745 if (count($actions) > 0) {
746 $dd = $this->
ui->factory()->dropdown()->standard($actions);
747 $this->main_tpl->setHeaderActionMenu(
$ui->renderer()->render($dd));
759 $txt = $this->lng->txt(
"rep_fav_intro1") .
"<br>";
761 $this->lng->txt(
'rep_fav_intro2'),
764 $txt .= $this->lng->txt(
"rep_fav_intro3");
765 $mbox = $this->
ui->factory()->messageBox()->info(
$txt);
767 return $this->
ui->renderer()->render($mbox);
772 $nd = $this->tree->getNodeData($this->tree->getRootId());
776 $title = $this->lng->txt(
'repository');
renderGroupedItems(array $grouped_items, bool $showHeader=true)
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Dashboard objects table renderer.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TYPE_NOTIFICATION_UNSUBSCRIBE
Class ilPDSelectedItemsListRenderer.
getListItemForData(array $data)
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
renderManageList(array $grouped_items)
getCardForData(array $item)
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
static _lookupTitle($a_id)
lookup object title
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
Class ilPDSelectedItemsBlockListGUIFactory.
Manages favourites, currently the interface for other components, needs discussion.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_content)
static _lookupObjectId($a_ref_id)
lookup object id
static getInstance($a_ref_id)
Get instance by ref_id.
static http()
Fetches the global http state from ILIAS.
changePDItemPresentation()
setTitle($a_title)
Set Title.
static bySettings(ilPDSelectedItemsBlockViewSettings $viewSettings)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setData($a_data)
Set Data.
static _lookupObjId($a_id)
Common interface to all items.
Class ilPDObjectsTileRenderer.
const TYPE_UNSUBSCRIBE_MEMBER
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
render(array $groupedItems, bool $showHeader)
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static checkForumsExistsDelete($ref_id, $user_id=0)
render(array $groupedItems, bool $showHeader)
setLimit($a_limit)
Set Limit.
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
ilPDSelectedItemsBlockGUI: ilColumnGUI ilPDSelectedItemsBlockGUI: ilCommonActionDispatcherGUI ...
__construct(Container $dic, ilPlugin $plugin)
This class represents a block method of a block.
getGroupedCommandsForView($manage=false)
addBlockCommand(string $a_href, string $a_text, string $a_onclick="")
Add Block Command.
const VIEW_SELECTED_ITEMS
setPresentation(int $type)
Set presentation.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.