Passed
Push — developer ( 4e3135...f5c82a )
by Radosław
30:25 queued 12:59
created

Vtiger_MailsList_Dashboard   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
eloc 21
dl 0
loc 27
rs 10
c 0
b 0
f 0
ccs 0
cts 19
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 25 6
1
<?php
2
3
/**
4
 * Vtiger MailsList dashboard class.
5
 *
6
 * @package Dashboard
7
 *
8
 * @copyright YetiForce S.A.
9
 * @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
10
 */
11
class Vtiger_MailsList_Dashboard extends Vtiger_IndexAjax_View
12
{
13
	public function process(App\Request $request, $widget = null)
0 ignored issues
show
Unused Code introduced by
The parameter $widget is not used and could be removed. ( Ignorable by Annotation )

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

13
	public function process(App\Request $request, /** @scrutinizer ignore-unused */ $widget = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14
	{
15
		$messages = [];
16
		$moduleName = $request->getModule();
17
		$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
18
		$limit = (int) $widget->get('limit') ?: 5;
19
		$users = OSSMail_Autologin_Model::getAutologinUsers();
20
		$user = $request->isEmpty('mailAccount') ? key($users) : $request->getInteger('mailAccount');
21
22
		if ($user && isset($users[$user])) {
23
			$messages = \App\Mail\Account::getInstanceById($user)->openImap()->getLastMessages($limit);
24
		}
25
26
		$viewer = $this->getViewer($request);
27
		$viewer->assign('SCRIPTS', null);
28
		$viewer->assign('STYLES', null);
29
		$viewer->assign('MODULE_NAME', $moduleName);
30
		$viewer->assign('WIDGET', $widget);
31
		$viewer->assign('USER', $user);
32
		$viewer->assign('MAILS', $messages);
33
		if ($request->has('content')) {
34
			$viewer->view('dashboards/MailsListContents.tpl', $moduleName);
35
		} else {
36
			$viewer->assign('ACCOUNTSLIST', $users);
37
			$viewer->view('dashboards/MailsList.tpl', $moduleName);
38
		}
39
	}
40
}
41