Passed
Push — develop ( 103543...417183 )
by Michael
05:44
created

helper.php (4 issues)

Labels
Severity
1
<?php
2
use dokuwiki\plugin\struct\meta\AccessTable;
1 ignored issue
show
The type dokuwiki\plugin\struct\meta\AccessTable 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...
3
use dokuwiki\plugin\struct\meta\StructException;
1 ignored issue
show
The type dokuwiki\plugin\struct\meta\StructException 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...
4
5
/**
6
 * DokuWiki Plugin swarmzapierstructwebhook (Helper Component)
7
 *
8
 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
9
 * @author  Michael Große <[email protected]>
10
 */
11
12
class helper_plugin_swarmzapierstructwebhook extends DokuWiki_Plugin
1 ignored issue
show
The type DokuWiki_Plugin 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...
13
{
14
    /**
15
     * @param array $data associative array in the form of [columnname => columnvalue]
16
     */
17
    public function saveDataToLookup(array $data)
18
    {
19
        $access = AccessTable::byTableName('swarm', 0, 0);
20
        if (!$access->getSchema()->isEditable()) {
21
            throw new StructException('lookup save error: no permission for schema');
22
        }
23
        $validator = $access->getValidator($data);
24
        if (!$validator->validate()) {
25
            throw new StructException("Validation failed:\n%s", implode("\n", $validator->getErrors()));
26
        }
27
        if (!$validator->saveData()) {
28
            throw new StructException('No data saved');
29
        }
30
    }
31
32
    /**
33
     * Deletes a checkin from the lookup
34
     *
35
     * @param string $checkinid
36
     */
37
    public function deleteCheckinFromLookup($checkinid)
38
    {
39
        $tablename = 'swarm';
40
41
        /** @var remote_plugin_struct $remote */
42
        $remote = plugin_load('remote', 'struct');
1 ignored issue
show
The function plugin_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

42
        $remote = /** @scrutinizer ignore-call */ plugin_load('remote', 'struct');
Loading history...
43
        $rows = $remote->getAggregationData(
44
            [$tablename],
45
            ['%rowid%'],
46
            [['logic'=> 'and', 'condition' => "checkinid = $checkinid"]]
47
        );
48
49
        $pids = array_column($rows, '%rowid%');
50
51
        if (empty($pids)) {
52
            return;
53
        }
54
        foreach ($pids as $pid) { // should only be a single entry
55
            $schemadata = AccessTable::byTableName($tablename, $pid);
56
            if (!$schemadata->getSchema()->isEditable()) {
57
                throw new StructException('lookup delete error: no permission for schema');
58
            }
59
            $schemadata->clearData();
60
        }
61
    }
62
}
63