Passed
Push — developer ( 6b5868...bed0f9 )
by Radosław
22:42 queued 03:39
created

OSSMailScanner_SaveWidgetConfig_Action   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkPermission() 0 5 2
A process() 0 11 1
1
<?php
2
3
/**
4
 * OSSMailScanner SaveWidgetConfig action class.
5
 *
6
 * @copyright YetiForce S.A.
7
 * @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
8
 */
9
class OSSMailScanner_SaveWidgetConfig_Action extends \App\Controller\Action
10
{
11
	/**
12
	 * Function to check permission.
13
	 *
14
	 * @param \App\Request $request
15
	 *
16
	 * @throws \App\Exceptions\NoPermittedForAdmin
17
	 */
18
	public function checkPermission(App\Request $request)
19
	{
20
		$currentUserModel = Users_Record_Model::getCurrentUserModel();
21
		if (!$currentUserModel->isAdminUser()) {
22
			throw new \App\Exceptions\NoPermittedForAdmin('LBL_PERMISSION_DENIED');
23
		}
24
	}
25
26
	public function process(App\Request $request)
27
	{
28
		$param = $request->get('name');
29
		$val = $request->get('value');
30
		$conf_type = $request->get('conf_type');
31
		$recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
32
		$recordModel->setConfigWidget($conf_type, $param, $val);
0 ignored issues
show
Bug introduced by
The method setConfigWidget() does not exist on Vtiger_Record_Model. It seems like you code against a sub-type of Vtiger_Record_Model such as OSSMailScanner_Record_Model. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
		$recordModel->/** @scrutinizer ignore-call */ 
33
                setConfigWidget($conf_type, $param, $val);
Loading history...
33
		$result = ['success' => true, 'data' => \App\Language::translate('JS_save_config_info', 'OSSMailScanner')];
34
		$response = new Vtiger_Response();
35
		$response->setResult($result);
36
		$response->emit();
37
	}
38
}
39