Completed
Pull Request — master (#2)
by Michael
07:48
created

getEditor.php ➔ adminer_object()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 49
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 49
rs 9.2258

4 Methods

Rating   Name   Duplication   Size   Complexity  
A AdminerCustomization::name() 0 4 1
A AdminerCustomization::credentials() 0 4 1
A AdminerCustomization::database() 0 4 1
A AdminerCustomization::login() 0 4 1
1
<?php
2
/**
3
 * Adminer Module based on Ghost Module
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright            The XOOPS Project http://sourceforge.net/projects/xoops/
13
 * @license              http://www.fsf.org/copyleft/gpl.html GNU public license
14
 * @package              Adminer Module
15
 * @since                2.3.0
16
 * @author               Kris <http://www.xoofoo.org>
17
 * @version              $Id $
18
 **/
19
// connect xoops database
20
include_once __DIR__ . '/admin_header.php';
21
22 View Code Duplication
if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    exit(_NOPERM);
24
}
25
26
function adminer_object()
27
{
28
    // required to run any plugin
29
    include_once dirname(__DIR__) . '/include/plugins/plugin.php';
30
    //    include_once dirname(__DIR__) . "/include/plugins/plugin.php";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
31
    include_once dirname(__DIR__) . '/include/plugins/frames.php';
32
33
    // autoloader
34
    //    foreach (glob("plugins/*.php") as $filename) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
35
    //        include_once "./$filename";
36
    //    }
37
38
    $plugins = array(
39
        // specify enabled plugins here
40
        //        new AdminerDumpXml,
41
        //        new AdminerTinymce,
42
        //        new AdminerFileUpload("data/"),
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
        //        new AdminerSlugify,
44
        //        new AdminerTranslation,
45
        //        new AdminerForeignSystem,
46
        new AdminerFrames,
47
    );
48
49
    //    It is possible to combine customization and plugins:
50
    class AdminerCustomization extends AdminerPlugin
51
    {
52
        public function name()
53
        {
54
            return 'XOOPS Admin';
55
        }
56
57
        public function credentials()
58
        {
59
            return array(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
60
        }
61
62
        public function database()
63
        {
64
            return XOOPS_DB_NAME;
65
        }
66
67
        public function login($login, $password)
68
        {
69
            return ($login == XOOPS_DB_USER);
70
        }
71
    }
72
73
    return new AdminerCustomization($plugins);
74
}
75
76
// include original Adminer or Adminer Editor
77
include_once dirname(__DIR__) . '/include/editor.php';
78