ILIAS  release_8 Revision v8.24
class.ilConditionSelector.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/******************************************************************************
6 *
7 * This file is part of ILIAS, a powerful learning management system
8 * published by ILIAS open source e-Learning e.V.
9 *
10 * ILIAS is licensed with the GPL-3.0,
11 * see https://www.gnu.org/licenses/gpl-3.0.en.html
12 * You should have received a copy of said license along with the
13 * source code, too.
14 *
15 * If this is not the case or you just want to try ILIAS, you'll find
16 * us at:
17 * https://www.ilias.de
18 * https://github.com/ILIAS-eLearning
19 *
20 *****************************************************************************/
21
27{
28 protected ?int $highlighted_parent = null;
29 protected ?int $ref_id = null;
30
34 public function __construct(
35 $a_parent_obj,
36 string $a_parent_cmd,
37 $a_selection_gui = null,
38 string $a_selection_cmd = "add",
39 string $a_selection_par = "source_id"
40 ) {
42 $a_parent_obj,
43 $a_parent_cmd,
44 $a_selection_gui,
45 $a_selection_cmd,
46 $a_selection_par
47 );
48
49 $this->setAjax(true);
50 }
51
55 public function isNodeVisible($a_node): bool
56 {
57 global $DIC;
58
59 $ilAccess = $DIC['ilAccess'];
60 $tree = $DIC['tree'];
61
62 if (!$ilAccess->checkAccess('read', '', (int) $a_node["child"])) {
63 return false;
64 }
65 //remove childs of target object
66 if ($tree->getParentId((int) $a_node["child"]) === $this->getRefId()) {
67 return false;
68 }
69
70 return true;
71 }
72
76 public function isNodeClickable($a_node): bool
77 {
78 if (!parent::isNodeClickable($a_node)) {
79 return false;
80 }
81
82 if ($a_node["child"] == $this->getRefId()) {
83 return false;
84 }
85
86 return true;
87 }
88
89 public function setRefId(int $a_ref_id): void
90 {
91 $this->ref_id = $a_ref_id;
92
93 //can target object be highlighted?
94 $target_type = ilObject::_lookupType($a_ref_id, true);
95
96 if (!in_array($target_type, $this->getTypeWhiteList(), true)) {
97 $this->highlighted_parent = $this->tree->getParentId($a_ref_id);
98 }
99 }
100
101 public function getRefId(): ?int
102 {
103 return $this->ref_id;
104 }
105
109 public function isNodeHighlighted($a_node): bool
110 {
111 //highlight parent if target object cant be highlighted
112 if ($this->highlighted_parent == $a_node["child"]) {
113 return true;
114 }
115
116 return parent::isNodeHighlighted($a_node);
117 }
118}
isNodeHighlighted($a_node)
@inheritDoc
isNodeVisible($a_node)
@inheritDoc
isNodeClickable($a_node)
@inheritDoc
__construct( $a_parent_obj, string $a_parent_cmd, $a_selection_gui=null, string $a_selection_cmd="add", string $a_selection_par="source_id")
@inheritDoc
static _lookupType(int $id, bool $reference=false)
Explorer for selecting repository items.
getTypeWhiteList()
Get type white list.
getParentId(int $a_node_id)
get parent id of given node
global $DIC
Definition: feed.php:28
$target_type
Definition: goto.php:51
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc