-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathms.php
More file actions
executable file
·148 lines (129 loc) · 4.44 KB
/
ms.php
File metadata and controls
executable file
·148 lines (129 loc) · 4.44 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/php -q
<?php
define('ELGG-MULTISITE-CONSOLE', true);
require_once(dirname(__FILE__) . '/elgg/elgg-config/settings.php');
/* Load Multisite Classes */
spl_autoload_register(function($class) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$basedir = dirname(__FILE__) . '/multisite/classes/';
if (file_exists($basedir . $class . '.php')) {
include_once($basedir . $class . '.php');
}
});
/* Load symfony */
spl_autoload_register(function($class) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$basedir = dirname(__FILE__) . '/multisite/vendor/';
if (file_exists($basedir . $class . '.php')) {
include_once($basedir . $class . '.php');
}
});
// Create new console application
global $console;
$console = new \Symfony\Component\Console\Application('Elgg Multisite', \ElggMultisite\Version::version());
/**
* Display version
*/
$console
->register('version')
->setDescription('Returns the current Elgg Multisite version')
->setDefinition([])
->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
$output->writeln(file_get_contents(dirname(__FILE__) . '/version.ini'));
});
/**
* List domains
*/
$console
->register('show')
->setDescription('List all multisite domains currently created.')
->setDefinition([])
->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
$forms = \ElggMultisite\Domain::getDomainTypes();
if ($domains = \ElggMultisite\Domain::getDomains()) {
foreach ($domains as $domain)
{
$label = $forms[get_class($domain)];
$url = $domain->getDomain();
$out = "* $url ($label)";
if (!$domain->isSiteAccessible())
$out .= ': DISABLED';
$output->writeln($out);
}
}
});
/**
* Enable
*/
$console
->register('enable')
->setDescription('Enable a domain')
->setDefinition([
new \Symfony\Component\Console\Input\InputArgument('domain', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'Domain to enable'),
])
->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
if ($d = $input->getArgument('domain')) {
if ($domain = \ElggMultisite\Domain::getByDomain($d)) {
$domain->enable();
} else {
throw new \Exception("Domain $domain could not be found.");
}
}
});
/**
* Disable
*/
$console
->register('disable')
->setDescription('Disable a domain')
->setDefinition([
new \Symfony\Component\Console\Input\InputArgument('domain', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'Domain to disable'),
])
->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
if ($d = $input->getArgument('domain')) {
if ($domain = \ElggMultisite\Domain::getByDomain($d)) {
$domain->disable();
} else {
throw new \Exception("Domain $domain could not be found.");
}
}
});
/**
* Delete a domain
*/
$console
->register('destroy')
->setDescription('Destroy a domain, warning this can not be undone!')
->setDefinition([
new \Symfony\Component\Console\Input\InputArgument('domain', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'Domain to remove'),
])
->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
if ($d = $input->getArgument('domain')) {
if ($domain = \ElggMultisite\Domain::getByDomain($d)) {
$domain->delete();
} else {
throw new \Exception("Domain $domain could not be found.");
}
}
});
/**
* Add a domain
*/
$console
->register('new')
->setDescription('Create a new site, with all plugins enabled by default')
->setDefinition([
new \Symfony\Component\Console\Input\InputArgument('domain', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'Domain name to add'),
])
->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
if ($d = $input->getArgument('domain')) {
\ElggMultisite\Domain::addDomain(
$d,
[], // Use default database settings
\ElggMultisite\Site::site()->getInstalledPlugins(),
'ElggMultisite\\Domain'
);
$output->writeln("Domain $d created.");
}
});
$console->run();