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

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

Check for conflicting imported classes with local classes.

Bug Major
1
<?php
2
3
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...
4
5
/** @var Apps\Model\Admin\User\FormUserUpdate $model */
6
/** @var \Ffcms\Templex\Template\Template $this */
7
8
$this->layout('_layouts/default', [
9
    'title' => __('Manage user'),
10
    'breadcrumbs' => [
11
        Url::to('main/index') => __('Main'),
12
        Url::to('application/index') => __('Applications'),
13
        Url::to('user/index') => __('User list'),
14
        __('Manage user')
15
    ]
16
]);
17
?>
18
19
<?php $this->start('body') ?>
20
<?= $this->insert('user/_tabs') ?>
21
22
<h1><?= __('Manage user') ?></h1>
23
24
<?php $form = $this->form($model) ?>
25
<?= $form->start() ?>
26
27
<?= $form->fieldset()->text('email', null, __('Specify user email')) ?>
28
<?= $form->fieldset()->text('login', null, __('Specify user login')) ?>
29
<?= $form->fieldset()->text('newpassword', null, __('Specify new user password if you want to change it! Less empty field to save current')) ?>
30
<?= $form->fieldset()->select('role_id', ['options' => $model->getRoleList(), 'optionsKey' => true]) ?>
31
<?= $form->field()->hidden('approve_token') ?>
32
<?= $form->fieldset()->boolean('approved', null, __('Set if user is approved or not')) ?>
33
34
<?php if ($model->_user->getId() !== null): ?>
35
    <div class="row mt-3">
36
        <div class="col-md-3">
37
            <div class="text-right"><strong><?= __('Profile preview') ?></strong></div>
38
        </div>
39
        <div class="col-md-9">
40
            <a href="<?= \App::$Alias->scriptUrl . '/profile/show/' . $model->_user->id ?>" target="_blank"><?= __('View profile on website') ?></a>
41
        </div>
42
    </div>
43
    <div class="row mt-3 mb-3">
44
        <div class="col-md-3">
45
            <div class="text-right"><strong><?= __('Profile data') ?></strong></div>
46
        </div>
47
        <div class="col-md-9">
48
            <?= Url::a(['profile/update', [$model->_user->profile->id]], __('Edit profile data')); ?>
49
        </div>
50
    </div>
51
<?php endif; ?>
52
<?= $form->button()->submit(__('Save'), ['class' => 'btn btn-primary']) ?>
53
<?= $form->button()->cancel(__('Cancel'), ['class' => 'btn btn-secondary', 'link' => ['user/index']]) ?>
54
<?= Url::a(['user/clear', [$model->_user->id]], __('Clear'), ['class' => 'btn btn-warning']) ?>&nbsp;
55
<?= Url::a(['user/delete', [$model->_user->id]], __('Delete'), ['class' => 'btn btn-danger']) ?>
56
57
<?= $form->stop() ?>
58
59
<?php $this->stop() ?>
60