Commit 7aefa0e1 authored by Thomas Citharel's avatar Thomas Citharel 🏃🏻
Browse files

rewrite all user folders to %user%.frama.wiki

parent d649702c
......@@ -62,7 +62,7 @@ class AsyncAccountDoku extends AbstractMakeAccount implements AsyncAccountInterf
public function make(): int
{
$this->configPath = $this->accountsPath . '/' . $this->site->getSubdomain() . '/conf';
$this->configPath = $this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/conf';
$this->checkSubdomain();
$this->makeSubdomain();
......@@ -77,7 +77,7 @@ class AsyncAccountDoku extends AbstractMakeAccount implements AsyncAccountInterf
public function checkSubdomain($subdomain = null)
{
$subdomainToCheck = null === $subdomain ? $this->site->getSubdomain() : $subdomain;
$subdomainToCheck = null === $subdomain ? $this->site->getSubdomain() . '.frama.wiki' : $subdomain;
$fs = new Filesystem();
$accountPath = $this->accountsPath . '/' . strtolower($subdomainToCheck);
if ($fs->exists($accountPath)) {
......@@ -90,7 +90,7 @@ class AsyncAccountDoku extends AbstractMakeAccount implements AsyncAccountInterf
{
$fs = new Filesystem();
$accountPath = $this->accountsPath . '/' . strtolower($this->site->getSubdomain());
$accountPath = $this->accountsPath . '/' . strtolower($this->site->getSubdomain() . '.frama.wiki');
$fs->mkdir($accountPath);
$userData = ['conf', 'data', 'data/cache'];
......@@ -98,20 +98,20 @@ class AsyncAccountDoku extends AbstractMakeAccount implements AsyncAccountInterf
// Create userData folders
foreach ($userData as $file) {
$fs->mkdir($accountPath . '/' . $file);
$fs->chmod($this->accountsPath . '/' . $this->site->getSubdomain() . '/' . $file , 0755);
$fs->chmod($this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/' . $file , 0755);
}
/**
* Copy conf
*/
$fs->copy($this->accountsPath . '/../template/conf/local.protected.php', $this->accountsPath . '/' . $this->site->getSubdomain() . '/conf/local.protected.php');
$fs->copy($this->accountsPath . '/../template/conf/users.auth.php', $this->accountsPath . '/' . $this->site->getSubdomain() . '/conf/users.auth.php');
$fs->copy($this->accountsPath . '/../template/conf/plugins.local.php', $this->accountsPath . '/' . $this->site->getSubdomain() . '/conf/plugins.local.php');
$fs->copy($this->accountsPath . '/../template/conf/local.protected.php', $this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/conf/local.protected.php');
$fs->copy($this->accountsPath . '/../template/conf/users.auth.php', $this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/conf/users.auth.php');
$fs->copy($this->accountsPath . '/../template/conf/plugins.local.php', $this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/conf/plugins.local.php');
/**
* Copy data
*/
$this->rcopy($this->accountsPath . '/../template/data', $this->accountsPath . '/' . $this->site->getSubdomain() . '/data');
$this->rcopy($this->accountsPath . '/../template/data', $this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/data');
}
public function makeSiteConfig()
......@@ -208,7 +208,7 @@ EOT;
public function makeAccount()
{
// just in case
$this->configPath = $this->accountsPath . '/' . $this->site->getSubdomain() . '/conf';
$this->configPath = $this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/conf';
// hash the password
// $phash = new PassHash();
......@@ -233,11 +233,11 @@ EOT;
public function deleteSite()
{
$fs = new Filesystem();
$this->logger->info('Deleting site at subdomain ' . $this->site->getSubdomain() . '...');
if (null == $this->site->getSubdomain() || $this->site->getSubdomain() == '') { // TODO : check against ../../ and such things
$this->logger->info('Deleting site at subdomain ' . $this->site->getSubdomain() . '.frama.wiki' . '...');
if (null == $this->site->getSubdomain() . '.frama.wiki' || $this->site->getSubdomain() . '.frama.wiki' == '') { // TODO : check against ../../ and such things
throw new \Exception("Subdomain is empty, won't delete everything !");
}
$fs->remove($this->accountsPath . '/' . $this->site->getSubdomain());
$fs->remove($this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki');
}
/**
......@@ -246,15 +246,15 @@ EOT;
public function deleteSiteUser()
{
$this->logger->debug($this->user->getUsername() . " tried to delete account " . $this->siteUser->getUsername() . " for website " . $this->site->getSubdomain());
$this->logger->debug($this->user->getUsername() . " tried to delete account " . $this->siteUser->getUsername() . " for website " . $this->site->getSubdomain() . '.frama.wiki');
$fs = new Filesystem();
$finder = new Finder();
if (!$fs->exists($this->accountsPath . '/' . $this->site->getSubdomain() . '/user/accounts' . $this->siteUser->getUsername() . '.yaml')) {
if (!$fs->exists($this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/user/accounts' . $this->siteUser->getUsername() . '.yaml')) {
throw new \Exception("This user doesn't exist. Strange");
}
$files = $finder->files()->in($this->accountsPath . '/' . $this->site->getSubdomain() . '/user/accounts')->name('*.yaml');
$files = $finder->files()->in($this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/user/accounts')->name('*.yaml');
foreach ($files as $file) {
/** @var SplFileInfo $file */
$userData = Yaml::parse($file->getContents());
......@@ -264,7 +264,7 @@ EOT;
/** There's at least one more admin, we can remove this user */
if (isset($userData['access']['admin']) && null !== $userData['access']['admin'] && $file->getRelativePathname() !== $this->siteUser->getUsername()) {
$this->logger->debug("The site user " . $file . " is an admin, so we can delete the site user " . $this->siteUser->getUsername());
$fs->remove($this->accountsPath . '/' . $this->site->getSubdomain() . '/user/accounts/' . $this->siteUser->getUsername() . '.yaml');
$fs->remove($this->accountsPath . '/' . $this->site->getSubdomain() . '.frama.wiki' . '/user/accounts/' . $this->siteUser->getUsername() . '.yaml');
}
}
}
......
  • Faudrait que ce soit un truc configurable : là ça ne fonctionnera que pour les sites en *.frama.wiki. Or on veut que les gens puissent l'installer aussi.

  • mentioned in issue #2

    Toggle commit list
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment