1 | <?php |
||||||
2 | use dokuwiki\plugin\struct\meta\AccessTable; |
||||||
1 ignored issue
–
show
|
|||||||
3 | use dokuwiki\plugin\struct\meta\SchemaImporter; |
||||||
1 ignored issue
–
show
The type
dokuwiki\plugin\struct\meta\SchemaImporter 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
4 | 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
5 | |||||||
6 | /** |
||||||
7 | * DokuWiki Plugin swarmzapierstructwebhook (Helper Component) |
||||||
8 | * |
||||||
9 | * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html |
||||||
10 | * @author Michael Große <[email protected]> |
||||||
11 | */ |
||||||
12 | |||||||
13 | 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
14 | { |
||||||
15 | |||||||
16 | /** |
||||||
17 | * Extract the data to be saved from the payload |
||||||
18 | * |
||||||
19 | * @param array $data |
||||||
20 | * |
||||||
21 | * @return array |
||||||
22 | */ |
||||||
23 | 4 | public function extractDataFromPayload(array $data) |
|||||
24 | { |
||||||
25 | 4 | $checkinID = $data['id']; |
|||||
26 | 4 | $locationName = $data['venue']['name']; |
|||||
27 | |||||||
28 | 4 | $dateTime = $this->getDateTimeInstance($data['createdAt'], $data['timeZoneOffset']); |
|||||
29 | |||||||
30 | $lookupData = [ |
||||||
31 | 4 | 'date' => $dateTime->format('Y-m-d'), |
|||||
32 | 4 | 'time' => $dateTime->format(DateTime::ATOM), |
|||||
33 | 4 | 'checkinid' => $checkinID, |
|||||
34 | 4 | 'locname' => $locationName, |
|||||
35 | ]; |
||||||
36 | 4 | if (!empty($data['shout'])) { |
|||||
37 | 1 | $lookupData['shout'] = $data['shout']; |
|||||
38 | } |
||||||
39 | 4 | return $lookupData; |
|||||
40 | } |
||||||
41 | |||||||
42 | /** |
||||||
43 | * Transforms a timestamp and the timezone offset as provided in the payload into an DateTimeInterface instance |
||||||
44 | * |
||||||
45 | * @param int $timestamp |
||||||
46 | * @param int $payloadTimezoneOffset offset to UTC in minutes |
||||||
47 | * |
||||||
48 | * @return DateTimeInterface |
||||||
49 | */ |
||||||
50 | 4 | protected function getDateTimeInstance($timestamp, $payloadTimezoneOffset) |
|||||
51 | { |
||||||
52 | 4 | $tzSign = $payloadTimezoneOffset >= 0 ? '+' : '-'; |
|||||
53 | 4 | $offsetInHours = $payloadTimezoneOffset / 60; |
|||||
54 | 4 | $tz = $tzSign . str_pad($offsetInHours * 100, 4, '0', STR_PAD_LEFT); |
|||||
55 | 4 | $dateTime = new DateTime('now', new DateTimeZone($tz)); |
|||||
56 | 4 | $dateTime->setTimestamp($timestamp); |
|||||
57 | 4 | return $dateTime; |
|||||
58 | } |
||||||
59 | |||||||
60 | /** |
||||||
61 | * @param array $data associative array in the form of [columnname => columnvalue] |
||||||
62 | */ |
||||||
63 | 2 | public function saveDataToLookup(array $data) |
|||||
64 | { |
||||||
65 | 2 | $access = AccessTable::byTableName('swarm', 0, 0); |
|||||
66 | 2 | if (!$access->getSchema()->isEditable()) { |
|||||
67 | throw new StructException('lookup save error: no permission for schema'); |
||||||
68 | } |
||||||
69 | 2 | $validator = $access->getValidator($data); |
|||||
70 | 2 | if (!$validator->validate()) { |
|||||
71 | throw new StructException("Validation failed:\n%s", implode("\n", $validator->getErrors())); |
||||||
72 | } |
||||||
73 | 2 | if (!$validator->saveData()) { |
|||||
74 | throw new StructException('No data saved'); |
||||||
75 | } |
||||||
76 | 2 | } |
|||||
77 | |||||||
78 | /** |
||||||
79 | * Deletes a checkin from the lookup |
||||||
80 | * |
||||||
81 | * @param string $checkinid |
||||||
82 | */ |
||||||
83 | 2 | public function deleteCheckinFromLookup($checkinid) |
|||||
84 | { |
||||||
85 | 2 | $tablename = 'swarm'; |
|||||
86 | |||||||
87 | /** @var remote_plugin_struct $remote */ |
||||||
88 | 2 | $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
![]() |
|||||||
89 | 2 | $rows = $remote->getAggregationData( |
|||||
90 | 2 | [$tablename], |
|||||
91 | 2 | ['%rowid%'], |
|||||
92 | 2 | [['logic'=> 'and', 'condition' => "checkinid = $checkinid"]] |
|||||
93 | ); |
||||||
94 | |||||||
95 | 2 | $pids = array_column($rows, '%rowid%'); |
|||||
96 | |||||||
97 | 2 | if (empty($pids)) { |
|||||
98 | 1 | return; |
|||||
99 | } |
||||||
100 | 1 | foreach ($pids as $pid) { // should only be a single entry |
|||||
101 | 1 | $schemadata = AccessTable::byTableName($tablename, $pid); |
|||||
102 | 1 | if (!$schemadata->getSchema()->isEditable()) { |
|||||
103 | throw new StructException('lookup delete error: no permission for schema'); |
||||||
104 | } |
||||||
105 | 1 | $schemadata->clearData(); |
|||||
106 | } |
||||||
107 | 1 | } |
|||||
108 | |||||||
109 | /** |
||||||
110 | * Create a new struct schema from the struct json file in the plugin dir |
||||||
111 | */ |
||||||
112 | 1 | public function createNewSwarmSchema() |
|||||
113 | { |
||||||
114 | 1 | $json = file_get_contents(__DIR__ . '/swarm.struct.json'); |
|||||
115 | 1 | $builder = new SchemaImporter('swarm', $json, true); |
|||||
116 | 1 | if (!$builder->build()) { |
|||||
117 | msg('something went wrong while saving', -1); |
||||||
1 ignored issue
–
show
The function
msg 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
![]() |
|||||||
118 | } |
||||||
119 | 1 | touch(action_plugin_struct_cache::getSchemaRefreshFile()); |
|||||
1 ignored issue
–
show
The type
action_plugin_struct_cache 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
120 | 1 | } |
|||||
121 | } |
||||||
122 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths