Issues (538)

programs/init.php (9 issues)

1
<?php
2
//-------------------------------------------------------------------------
3
// OVIDENTIA http://www.ovidentia.org
4
// Ovidentia is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
// See the GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17
// USA.
18
//-------------------------------------------------------------------------
19
/**
20
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
21
 *
22
 * @copyright Copyright (c) 2019 by CAPWELTON ({@link http://www.capwelton.com})
23
 */
24
25
use Capwelton\LibOrm\MySql\ORMMySqlBackend;
0 ignored issues
show
The type Capwelton\LibOrm\MySql\ORMMySqlBackend was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
28
require_once dirname(__FILE__). '/functions.php';
29
30
31
function LibApp_upgrade($sVersionBase, $sVersionIni)
0 ignored issues
show
The parameter $sVersionBase 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

31
function LibApp_upgrade(/** @scrutinizer ignore-unused */ $sVersionBase, $sVersionIni)

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...
The parameter $sVersionIni 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

31
function LibApp_upgrade($sVersionBase, /** @scrutinizer ignore-unused */ $sVersionIni)

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...
32
{
33
    $addon = bab_getAddonInfosInstance('libapp');
34
    
35
    $addon->unregisterFunctionality('App');
36
    $functionnalities = new bab_functionalities();
37
    $functionnalities->registerNamespace('App',"Capwelton\LibApp\Func_App",$addon->getPhpPath().'Func_App.php');
0 ignored issues
show
The method registerNamespace() does not exist on bab_functionalities. Did you maybe mean register()? ( Ignorable by Annotation )

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

37
    $functionnalities->/** @scrutinizer ignore-call */ 
38
                       registerNamespace('App',"Capwelton\LibApp\Func_App",$addon->getPhpPath().'Func_App.php');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
39
    $addon->addEventListener('bab_eventBeforePageCreated', 'libapp_onBeforePageCreated', 'init.php', -10);
40
    $App = app_App();
41
42
    $babDB = bab_getDB();
43
44
    bab_functionality::get('LibOrm')->initMysql();
0 ignored issues
show
The method initMysql() does not exist on bab_functionality. It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_LibOrm. ( Ignorable by Annotation )

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

44
    bab_functionality::get('LibOrm')->/** @scrutinizer ignore-call */ initMysql();
Loading history...
45
    $backend = new ORMMySqlBackend($babDB);
46
47
    $sql = $backend->setToSql($App->LinkSet());
48
49
    $sql .= $backend->setToSql($App->LogSet());
50
    
51
    $sql .= $backend->setToSql($App->NotificationSet());
52
    
53
    $sql .= $backend->setToSql($App->SSESet());
54
    
55
    $sql .= $backend->setToSql($App->CustomFieldSet());
56
57
    $sql .= $backend->setToSql($App->CustomSectionSet());
58
59
    $sql .= $backend->setToSql($App->CustomContainerSet());
60
    
61
    require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
62
    $synchronize = new bab_synchronizeSql();
63
64
    $synchronize->fromSqlString($sql);
65
66
    // LibApp_InitializePortlets();
67
    
68
    return true;
69
}
70
71
function libApp_onBeforePageCreated(bab_eventBeforePageCreated $event)
0 ignored issues
show
The parameter $event 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

71
function libApp_onBeforePageCreated(/** @scrutinizer ignore-unused */ bab_eventBeforePageCreated $event)

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...
72
{
73
    if (bab_isAjaxRequest()) {
74
        return;
75
    }
76
    
77
    $idx = bab_rp('idx', null);
78
    if ($idx === 'file.open') {
79
        return;
80
    }
81
    
82
    $babBody = bab_getBody();
83
    $addon = bab_getAddonInfosInstance('libapp');
84
    $babBody->addStyleSheet($addon->getStylePath() . '/styles.css');
85
    $babBody->addJavascriptFile($addon->getTemplatePath() . 'libapp.js');
86
    
87
    $App = app_App();
88
    if($App && $App->isSSEEnabled()){
89
        $babBody->addJavascriptFile($addon->getTemplatePath() . 'notification.js');
90
        if(bab_isUserLogged()){
91
            $babBody->babecho('<script>window.libapp={"sseServerUrl": "'.$App->Controller()->SSE()->server()->url().'"}</script>');
0 ignored issues
show
The method server() does not exist on Capwelton\LibApp\Ctrl\AppController. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

91
            $babBody->babecho('<script>window.libapp={"sseServerUrl": "'.$App->Controller()->SSE()->/** @scrutinizer ignore-call */ server()->url().'"}</script>');
Loading history...
92
            $babBody->addJavascriptFile($addon->getTemplatePath().'sse.js');
93
        }
94
    }
95
}
96
97
98
function LibApp_onDeleteAddon()
99
{
100
    $addon = bab_getAddonInfosInstance('libapp');
101
102
    $addon->unregisterFunctionality('App');
103
104
    return true;
105
}
106
107
function LibApp_InitializePortlets()
108
{
109
    @bab_functionality::includefile('PortletBackend');
0 ignored issues
show
The method includefile() does not exist on bab_functionality. It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App. ( Ignorable by Annotation )

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

109
    @bab_functionality::/** @scrutinizer ignore-call */ includefile('PortletBackend');
Loading history...
Security Best Practice introduced by
It seems like you do not handle an error condition for includefile(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

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

109
    /** @scrutinizer ignore-unhandled */ @bab_functionality::includefile('PortletBackend');

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
110
    
111
    if (class_exists('Func_PortletBackend')) {
112
        $addon = bab_getAddonInfosInstance('libapp');
113
        $addonPhpPath = $addon->getPhpPath();
114
        
115
        require_once $GLOBALS['babInstallPath'].'utilit/functionalityincl.php';
116
        require_once dirname(__FILE__) . '/Portlet/Func_PortletBackend_App.php';
117
        $functionalities = new bab_functionalities();
118
        $functionalities->registerClass('Func_PortletBackend_App', $addonPhpPath . '/Portlet/Func_PortletBackend_App.php');
119
    }
120
}