Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Admin/default/user/invite_list.php (1 issue)

Check for conflicting imported classes with local classes.

Bug Major
1
<?php
2
3
use Ffcms\Core\Helper\Date;
4
use Ffcms\Templex\Url\Url;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Url. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
5
6
/** @var \Apps\ActiveRecord\Invite[]|\Illuminate\Support\Collection $records */
7
/** @var array $pagination */
8
/** @var array $configs */
9
/** @var \Ffcms\Templex\Template\Template $this */
10
11
$this->layout('_layouts/default', [
12
    'title' => __('Invitation list'),
13
    'breadcrumbs' => [
14
        Url::to('main/index') => __('Main'),
15
        Url::to('application/index') => __('Applications'),
16
        __('Invitation list')
17
    ]
18
]);
19
?>
20
21
<?php $this->start('body') ?>
22
23
<?= $this->insert('user/_tabs') ?>
24
<h1><?= __('Invitation list') ?></h1>
25
<?php if ($configs['registrationType'] !== 0) {
26
    echo $this->bootstrap()->alert('danger', __('Invite system is disabled. Registration is public'));
27
} ?>
28
<div>
29
    <?= Url::a(['user/invite'], __('Send invite'), ['class' => 'btn btn-info']) ?>
30
</div>
31
32
<?php if ($records->count() < 1) {
33
    echo $this->bootstrap()->alert('warning', __('No invites recently send'));
34
    $this->stop();
35
    return;
36
} ?>
37
38
<?php
39
$table = $this->table(['class' => 'table table-striped'])
40
    ->head([
41
        ['text' => '#'],
42
        ['text' => __('Email')],
43
        ['text' => __('Valid')],
44
        ['text' => __('Send date')],
45
        ['text' => __('Actions'), 'properties' => ['class' => 'text-center']]
46
    ]);
47
48
49
foreach ($records as $invite) {
50
    $time = Date::convertToTimestamp($invite->created_at);
51
    $table->row([
52
        ['text' => $invite->id],
53
        ['text' => $invite->email],
54
        ['text' => (time() - $time < \Apps\ActiveRecord\Invite::TOKEN_VALID_TIME ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-minus text-danger"></i>'), 'html' => true],
55
        ['text' => Date::convertToDatetime($invite->created_at, Date::FORMAT_TO_DAY)],
56
        ['text' => Url::a(['user/invitedelete', [$invite->id]], ' <i class="fa fa-trash-o fa-lg"></i>', ['html' => true]),
57
            'properties' => ['class' => 'text-center'], 'html' => true]
58
    ]);
59
}
60
?>
61
62
<div class="table-responsive">
63
    <?= $table->display() ?>
64
</div>
65
66
<?= $this->bootstrap()->pagination($pagination['url'], ['class' => 'pagination justify-content-center'])
67
    ->size($pagination['total'], $pagination['page'], $pagination['step'])
68
    ->display(); ?>
69
70
<?php $this->stop() ?>