Passed
Push — developer ( d5cf61...0a1e92 )
by Radosław
18:21
created

Calendar_RepeatEventsDelete_View   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 15
dl 0
loc 38
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkPermission() 0 8 4
A process() 0 5 1
1
<?php
2
/**
3
 * Modal window for delete repeat events.
4
 *
5
 * @package   View
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Adrian Kon <[email protected]>
10
 */
11
12
/**
13
 * Modal window for delete repeat events class.
14
 */
15
class Calendar_RepeatEventsDelete_View extends \App\Controller\Modal
16
{
17
	/** {@inheritdoc} */
18
	public $successBtnIcon = 'far fa-save';
19
20
	/** {@inheritdoc} */
21
	public $modalIcon = 'fas fa-save mr-2';
22
23
	/** {@inheritdoc} */
24
	protected $pageTitle = 'LBL_TITLE_TYPE_DELETE';
25
26
	/** {@inheritdoc} */
27
	public $showFooter = false;
28
29
	/** @var Vtiger_Record_Model */
30
	private $recordModel;
31
32
	/** {@inheritdoc} */
33
	public $autoRegisterEvents = false;
34
35
	/** {@inheritdoc} */
36
	public function checkPermission(App\Request $request)
37
	{
38
		if ($request->isEmpty('record', true)) {
39
			throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
40
		}
41
		$this->recordModel = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), 'Calendar');
42
		if (!$this->recordModel->privilegeToDelete() || !$this->recordModel->privilegeToMoveToTrash()) {
43
			throw new \App\Exceptions\NoPermitted('ERR_PERMISSION_DENIED', 406);
44
		}
45
	}
46
47
	/** {@inheritdoc} */
48
	public function process(App\Request $request)
49
	{
50
		$viewer = $this->getViewer($request);
51
		$viewer->assign('DELETE_URL', $this->recordModel->getDeleteUrl());
52
		$viewer->view('Modals/RepeatEventsDelete.tpl', $request->getModule());
53
	}
54
}
55