1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/**
5 * ilForumMoveTopicsExplorer
6 * @author Michael Jansen <mjansen@databay.de>
7 */
8class ilForumMoveTopicsExplorer extends ilRepositorySelectorExplorerGUI
9{
10    /**
11     * @var int
12     */
13    protected $current_frm_ref_id = 0;
14
15    /**
16     * {@inheritdoc}
17     */
18    public function __construct(
19        $a_parent_obj,
20        $a_parent_cmd,
21        $a_selection_gui = null,
22        $a_selection_cmd = "selectObject",
23        $a_selection_par = "sel_ref_id"
24    ) {
25        parent::__construct($a_parent_obj, $a_parent_cmd, $a_selection_gui, $a_selection_cmd, $a_selection_par);
26        $this->setTypeWhiteList(array('root', 'cat', 'fold', 'crs', 'grp', 'frm'));
27        $this->setSelectMode('frm_ref_id');
28    }
29
30    /**
31     * @return int
32     */
33    public function getCurrentFrmRefId()
34    {
35        return $this->current_frm_ref_id;
36    }
37
38    /**
39     * @param int $current_frm_ref_id
40     */
41    public function setCurrentFrmRefId($current_frm_ref_id)
42    {
43        $this->current_frm_ref_id = $current_frm_ref_id;
44    }
45
46    /**
47     * {@inheritdoc}
48     */
49    public function isNodeClickable($a_node)
50    {
51        global $DIC;
52
53        if ($a_node['type'] == 'frm') {
54            if ($this->getCurrentFrmRefId() && $this->getCurrentFrmRefId() == $a_node['child']) {
55                return false;
56            }
57
58            return $DIC->access()->checkAccess('moderate_frm', '', $a_node['child']) && parent::isNodeClickable($a_node);
59        }
60
61        return false;
62    }
63
64    /**
65     * {@inheritdoc}
66     */
67    public function isNodeVisible($a_node)
68    {
69        return parent::isNodeVisible($a_node);
70    }
71
72    /**
73     * {@inheritdoc}
74     */
75    protected function isNodeSelectable($a_node)
76    {
77        global $DIC;
78
79        if ($a_node['type'] == 'frm') {
80            if ($this->getCurrentFrmRefId() && $this->getCurrentFrmRefId() == $a_node['child']) {
81                return false;
82            }
83
84            return $DIC->access()->checkAccess('moderate_frm', '', $a_node['child']) && parent::isNodeSelectable($a_node);
85        }
86
87        return false;
88    }
89}
90