|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* phpBB Gallery - ACP Import Extension |
|
4
|
|
|
* |
|
5
|
|
|
* @package phpbbgallery/acpimport |
|
6
|
|
|
* @author nickvergessen |
|
7
|
|
|
* @author satanasov |
|
8
|
|
|
* @author Leinad4Mind |
|
9
|
|
|
* @copyright 2007-2012 nickvergessen, 2014- satanasov, 2018- Leinad4Mind |
|
10
|
|
|
* @license GPL-2.0-only |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace phpbbgallery\acpimport\migrations; |
|
14
|
|
|
|
|
15
|
|
|
use phpbb\db\migration\migration; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class m1_init extends migration |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Migration dependencies |
|
21
|
|
|
* |
|
22
|
|
|
* @return array Array of migration dependencies |
|
23
|
|
|
*/ |
|
24
|
|
|
public static function depends_on(): array |
|
25
|
|
|
{ |
|
26
|
|
|
return ['\phpbbgallery\core\migrations\release_1_2_0']; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Revert the changes |
|
31
|
|
|
* |
|
32
|
|
|
* @return array Array of update data |
|
33
|
|
|
*/ |
|
34
|
|
|
public function revert_data(): array |
|
35
|
|
|
{ |
|
36
|
|
|
return [ |
|
37
|
|
|
['custom', [[&$this, 'remove_file_system']]], |
|
38
|
|
|
]; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Update data |
|
43
|
|
|
* |
|
44
|
|
|
* @return array Array of update data |
|
45
|
|
|
*/ |
|
46
|
|
|
public function update_data(): array |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
['permission.add', ['a_gallery_import', true, 'a_board']], |
|
50
|
|
|
['module.add', [ |
|
51
|
|
|
'acp', |
|
52
|
|
|
'PHPBB_GALLERY', |
|
53
|
|
|
[ |
|
54
|
|
|
'module_basename' => '\phpbbgallery\acpimport\acp\main_module', |
|
55
|
|
|
'module_langname' => 'ACP_IMPORT_ALBUMS', |
|
56
|
|
|
'module_mode' => 'import_images', |
|
57
|
|
|
'module_auth' => 'ext_phpbbgallery/acpimport && acl_a_gallery_import', |
|
58
|
|
|
] |
|
59
|
|
|
]], |
|
60
|
|
|
['custom', [[&$this, 'create_file_system']]], |
|
61
|
|
|
]; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Create import directory |
|
66
|
|
|
* |
|
67
|
|
|
* @return void |
|
68
|
|
|
*/ |
|
69
|
|
|
public function create_file_system(): void |
|
70
|
|
|
{ |
|
71
|
|
|
global $phpbb_root_path; |
|
72
|
|
|
|
|
73
|
|
|
$phpbbgallery_import_file = $phpbb_root_path . 'files/phpbbgallery/import'; |
|
74
|
|
|
|
|
75
|
|
|
if (!is_dir($phpbbgallery_import_file)) |
|
76
|
|
|
{ |
|
77
|
|
|
if (is_writable($phpbb_root_path . 'files')) |
|
78
|
|
|
{ |
|
79
|
|
|
@mkdir($phpbbgallery_import_file, 0755, true); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Remove import directory |
|
86
|
|
|
* |
|
87
|
|
|
* @return void |
|
88
|
|
|
*/ |
|
89
|
|
|
public function remove_file_system(): void |
|
90
|
|
|
{ |
|
91
|
|
|
global $phpbb_root_path; |
|
92
|
|
|
|
|
93
|
|
|
$phpbbgallery_import_file = $phpbb_root_path . 'files/phpbbgallery/import'; |
|
94
|
|
|
|
|
95
|
|
|
// Clean dirs |
|
96
|
|
|
if (is_dir($phpbbgallery_import_file)) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->recursiveRemoveDirectory($phpbbgallery_import_file); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Recursively remove a directory |
|
104
|
|
|
* |
|
105
|
|
|
* @param string $directory Directory path |
|
106
|
|
|
* @return void |
|
107
|
|
|
*/ |
|
108
|
|
|
private function recursiveRemoveDirectory(string $directory): void |
|
109
|
|
|
{ |
|
110
|
|
|
if (!is_dir($directory)) |
|
111
|
|
|
{ |
|
112
|
|
|
return; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
$files = new \FilesystemIterator($directory); |
|
116
|
|
|
foreach ($files as $file) |
|
117
|
|
|
{ |
|
118
|
|
|
if ($file->isDir()) |
|
119
|
|
|
{ |
|
120
|
|
|
$this->recursiveRemoveDirectory($file->getPathname()); |
|
121
|
|
|
} |
|
122
|
|
|
else |
|
123
|
|
|
{ |
|
124
|
|
|
@unlink($file->getPathname()); |
|
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
@rmdir($directory); |
|
|
|
|
|
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
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