Passed
Push — master ( 17c747...646a8a )
by Michael
02:30
created

b_waiting_wggallery()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 19
c 1
b 0
f 1
nc 4
nop 0
dl 0
loc 28
rs 9.6333
1
<?php
2
/*************************************************************************/
3
4
# Waiting Contents Extensible                                            #
5
# Plugin for module wgGallery                                            #
6
#                                                                        #
7
# Author                                                                 #
8
# goffy - wedega - Webdesign Gabor - [email protected]                #
9
#                                                                        #
10
# Last modified on 27.08.2020                                            #
11
/*************************************************************************/
12
/**
13
 * @return array
14
 */
15
 
16
use XoopsModules\Wggallery\Constants;
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wggallery\Constants 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...
17
18
/**
19
 * @return array
20
 */
21
function b_waiting_wggallery()
22
{
23
    /** @var \XoopsMySQLDatabase $xoopsDB */
24
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
25
    $ret     = [];
26
    // images waiting for approvement
27
    $block  = [];
28
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wggallery_images') . ' WHERE img_state=' . Constants::STATE_APPROVAL_VAL;
29
    $result = $xoopsDB->query($sql);
30
    if ($result) {
31
        $block['adminlink'] = XOOPS_URL . '/modules/wggallery/admin/images.php';
32
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type true; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result, maybe add an additional type check? ( Ignorable by Annotation )

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

32
        [$block['pendingnum']] = $xoopsDB->fetchRow(/** @scrutinizer ignore-type */ $result);
Loading history...
33
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
34
    }
35
    $ret[] = $block;
36
    
37
    // albums waiting for approvement
38
    $block  = [];
39
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wggallery_albums') . ' WHERE alb_state=' . Constants::STATE_APPROVAL_VAL;
40
    $result = $xoopsDB->query($sql);
41
    if ($result) {
42
        $block['adminlink'] = XOOPS_URL . '/modules/wggallery/admin/albums.php';
43
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
44
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
45
    }
46
    $ret[] = $block;
47
48
    return $ret;
49
}
50