-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrphanedModules.php
More file actions
92 lines (65 loc) · 1.8 KB
/
OrphanedModules.php
File metadata and controls
92 lines (65 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
class OrphanedModules extends Backend
{
public function __construct()
{
$this->import("Config");
$this->import("Database");
}
public function checkModule($strModule)
{
if (!in_array($strModule, $this->Config->getActiveModules()))
{
throw new Exception("Module ".$strModule." not exists or enabled", 1);
}
$arrCheckGlobals = array(
'BE_FFL' => false,
'TL_PTY' => false,
'TL_FFL' => false,
'FE_MOD' => true,
'TL_CTE' => true
);
$arrGlobalsBackup = array();
foreach ($arrCheckGlobals as $check=>$removeArray)
{
$arrGlobalsBackup[$check] = $GLOBALS[$check];
unset($GLOBALS[$check]);
}
$arrCheck = array();
$objRepInstall = $this->Database->prepare("SELECT * FROM tl_repository_installs WHERE extension=?")->limit(1)->execute($strModule);
$arrCheck['repository']['install'] = (bool) ($objRepInstall->numRows==1);
$arrCheck['repository']['data'] = $objRepInstall->fetchAssoc();
$strConfigFile = sprintf("/system/modules/%s/config/config.php",$strModule);
if (file_exists(TL_ROOT.$strConfigFile))
{
include(TL_ROOT.$strConfigFile);
}
foreach ($arrCheckGlobals as $check=>$removeArray)
{
if (is_array($GLOBALS[$check]))
{
if ($removeArray)
{
if (!is_array($arrCheck[$check]['provided']))
{
$arrCheck[$check]['provided'] = array();
}
foreach ($GLOBALS[$check] as $modKey=>$modData)
{
$arrCheck[$check]['provided'] = array_merge($arrCheck[$check]['provided'],$modData);
}
}
else
{
$arrCheck[$check]['provided'] = $GLOBALS[$check];
}
}
}
// restore old GLOBALS
foreach ($arrCheckGlobals as $check=>$removeArray)
{
$GLOBALS[$check] = $arrGlobalsBackup[$check];
}
return $arrCheck;
}
}