1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Comment view file. |
4
|
|
|
* |
5
|
|
|
* @package View |
6
|
|
|
* |
7
|
|
|
* @copyright YetiForce Sp. z o.o. |
8
|
|
|
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) |
9
|
|
|
* @author Radosław Skrzypczak <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace YF\Modules\ModComments\View; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Comment view class. |
16
|
|
|
*/ |
17
|
|
|
class Comment extends \App\Controller\View |
18
|
|
|
{ |
19
|
|
|
use \App\Controller\ExposeMethodTrait; |
20
|
|
|
|
21
|
|
|
/** @var int Record ID */ |
22
|
|
|
protected $recordId; |
23
|
|
|
|
24
|
|
|
/** @var int Source ID */ |
25
|
|
|
protected $sourceId; |
26
|
|
|
|
27
|
|
|
/** @var string Module name */ |
28
|
|
|
protected $moduleName; |
29
|
|
|
|
30
|
|
|
/** @var string Source module name */ |
31
|
|
|
protected $sourceModule; |
32
|
|
|
|
33
|
|
|
/** {@inheritdoc} */ |
34
|
|
|
public function __construct(\App\Request $request) |
35
|
|
|
{ |
36
|
|
|
parent::__construct($request); |
37
|
|
|
$this->exposeMethod('getChildren'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** {@inheritdoc} */ |
41
|
|
|
public function checkPermission(): void |
42
|
|
|
{ |
43
|
|
|
$this->recordId = $this->request->getInteger('record'); |
44
|
|
|
$this->sourceId = $this->request->getInteger('sourceId'); |
45
|
|
|
$this->sourceModule = $this->request->getByType('sourceModule', \App\Purifier::ALNUM); |
46
|
|
|
$this->moduleName = $this->request->getModule(); |
47
|
|
|
if (!\App\User::getUser()->isPermitted($this->sourceModule)) { |
48
|
|
|
throw new \App\Exceptions\AppException('ERR_MODULE_PERMISSION_DENIED'); |
49
|
|
|
} |
50
|
|
|
if (!$this->recordId || !$this->sourceId) { |
51
|
|
|
throw new \App\Exceptions\AppException('ERR_PERMISSION_DENIED'); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Gets comment children. |
57
|
|
|
* |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
public function getChildren() |
61
|
|
|
{ |
62
|
|
|
$relatedListModel = \YF\Modules\ModComments\Model\RelatedList::getInstance($this->sourceModule)->setRecordId($this->sourceId)->setConditions([ |
63
|
|
|
'fieldName' => 'parent_comments', |
64
|
|
|
'value' => $this->recordId, |
65
|
|
|
'operator' => 'eid' |
66
|
|
|
]); |
67
|
|
|
$relatedListModel->loadRecordsList(); |
68
|
|
|
$this->viewer->assign('ENTRIES', $relatedListModel->getRecordsListModel()); |
69
|
|
|
$this->viewer->assign('SUB_COMMENT', true); |
70
|
|
|
$this->viewer->view('Detail/Comments.tpl', 'ModComments'); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|