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

Settings_Groups_DeleteAjax_Action   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 13
c 0
b 0
f 0
dl 0
loc 21
rs 10
ccs 0
cts 15
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 4
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