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

Settings_Groups_DeleteAjax_Action::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 18
rs 9.8666
ccs 0
cts 14
cp 0
cc 4
nc 4
nop 1
crap 20
1
<?php
2
/* +***********************************************************************************
3
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
4
 * ("License"); You may not use this file except in compliance with the License
5
 * The Original Code is:  vtiger CRM Open Source
6
 * The Initial Developer of the Original Code is vtiger.
7
 * Portions created by vtiger are Copyright (C) vtiger.
8
 * All Rights Reserved.
9
 * Contributor(s): YetiForce S.A.
10
 * *********************************************************************************** */
11
12
class Settings_Groups_DeleteAjax_Action extends Settings_Vtiger_Delete_Action
13
{
14
	/** {@inheritdoc} */
15
	public function process(App\Request $request)
16
	{
17
		$recordId = $request->getInteger('record');
18
		$transferRecordId = $request->getInteger('transfer_record');
19
20
		$recordModel = Settings_Groups_Record_Model::getInstance($recordId);
21
		if (\App\User::isExists($transferRecordId)) {
22
			$transferToOwner = Users_Record_Model::getInstanceById($transferRecordId, 'Users');
23
		} else {
24
			$transferToOwner = Settings_Groups_Record_Model::getInstance($transferRecordId);
25
		}
26
		if ($recordModel && $transferToOwner) {
27
			$recordModel->delete($transferToOwner);
28
		}
29
30
		$response = new Vtiger_Response();
31
		$response->setResult(['success' => true]);
32
		$response->emit();
33
	}
34
}
35