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

Calendar_RepeatEvents_View::checkPermission()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 1
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
/**
3
 * Modal window for repeat events purpose.
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 repeat events purpose class.
14
 */
15
class Calendar_RepeatEvents_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_SAVING';
25
26
	/** {@inheritdoc} */
27
	public $showFooter = false;
28
29
	/** {@inheritdoc} */
30
	public $autoRegisterEvents = false;
31
32
	/** {@inheritdoc} */
33
	public function checkPermission(App\Request $request)
34
	{
35
		if ($request->isEmpty('record', true)) {
36
			throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
37
		}
38
		$recordModel = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), 'Calendar');
39
		if (!$recordModel->isEditable()) {
40
			throw new \App\Exceptions\NoPermitted('ERR_PERMISSION_DENIED', 406);
41
		}
42
	}
43
44
	/** {@inheritdoc} */
45
	public function process(App\Request $request)
46
	{
47
		$viewer = $this->getViewer($request);
48
		$viewer->view('Modals/RepeatEvents.tpl', $request->getModule());
49
	}
50
}
51